summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp2
-rw-r--r--qt-ui/profile/diveplotdatamodel.h2
-rw-r--r--qt-ui/profile/diveprofileitem.cpp50
-rw-r--r--qt-ui/profile/diveprofileitem.h13
-rw-r--r--qt-ui/profile/profilewidget2.cpp29
-rw-r--r--qt-ui/profile/profilewidget2.h2
6 files changed, 94 insertions, 4 deletions
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index 6635ff1d0..b523472cf 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -36,6 +36,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
case INTERPOLATED_PRESSURE: return item.pressure[1];
case CEILING: return item.ceiling;
case SAC: return item.sac;
+ case PN2: return item.pn2;
}
}
@@ -81,6 +82,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
case INTERPOLATED_PRESSURE: return tr("Pressure I");
case CEILING: return tr("Ceiling");
case SAC: return tr("SAC");
+ case PN2: return tr("PN2");
}
if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16){
return QString("Ceiling: %1").arg(section - TISSUE_1);
diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h
index b188396ed..3116bcdfe 100644
--- a/qt-ui/profile/diveplotdatamodel.h
+++ b/qt-ui/profile/diveplotdatamodel.h
@@ -12,7 +12,7 @@ Q_OBJECT
public:
enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE,
SAC, CEILING, TISSUE_1,TISSUE_2,TISSUE_3,TISSUE_4,TISSUE_5,TISSUE_6,TISSUE_7,TISSUE_8,TISSUE_9,TISSUE_10,
- TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16,COLUMNS};
+ TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16, PN2,COLUMNS};
explicit DivePlotDataModel(QObject* parent = 0);
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 42c3ecaea..15944e990 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -471,3 +471,53 @@ void MeanDepthLine::setMeanDepth(int value)
leftText->setText(get_depth_string(value, false, false));
rightText->setText(get_depth_string(value, false, false));
}
+
+void PartialPressureGasItem::modelDataChanged()
+{
+ //AbstractProfilePolygonItem::modelDataChanged();
+ if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0)
+ return;
+
+ plot_data *entry = dataModel->data();
+ QPolygonF poly;
+ alertPoly.clear();
+ QSettings s;
+ s.beginGroup("TecDetails");
+ double threshould = s.value(threshouldKey).toDouble();
+
+ for(int i = 0; i < dataModel->rowCount(); i++, entry++){
+ double value = dataModel->index(i, vDataColumn).data().toDouble();
+ int time = dataModel->index(i, hDataColumn).data().toInt();
+ QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
+ poly.push_back( point );
+ if (value >= threshould)
+ alertPoly.push_back(point);
+ }
+
+ setPolygon(poly);
+ /*
+ createPPLegend(trUtf8("pN" UTF8_SUBSCRIPT_2),getColor(PN2), legendPos);
+ */
+}
+void PartialPressureGasItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{//TODO: fix the colors.
+ painter->setPen(getColor(PN2));
+ painter->drawPolyline(polygon());
+ painter->setPen(getColor(PN2_ALERT));
+ painter->drawPolyline(alertPoly);
+}
+
+void PartialPressureGasItem::setThreshouldSettingsKey(const QString& threshouldSettingsKey)
+{
+ threshouldKey = threshouldSettingsKey;
+}
+
+PartialPressureGasItem::PartialPressureGasItem()
+{
+
+}
+
+void PartialPressureGasItem::preferencesChanged()
+{
+ AbstractProfilePolygonItem::preferencesChanged();
+}
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index c6c5b19e3..8da9acee1 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -121,4 +121,17 @@ private:
DiveTextItem *leftText;
DiveTextItem *rightText;
};
+
+class PartialPressureGasItem : public AbstractProfilePolygonItem{
+ Q_OBJECT
+public:
+ PartialPressureGasItem();
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void modelDataChanged();
+ virtual void preferencesChanged();
+ void setThreshouldSettingsKey(const QString& threshouldSettingsKey);
+private:
+ QPolygonF alertPoly;
+ QString threshouldKey;
+};
#endif
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 568b90889..6041bac89 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -54,7 +54,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
// Creating the needed items.
// ORDER: {BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
- gasYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
timeAxis->setOrientation(DiveCartesianAxis::LeftToRight);
// Defaults of the Axis Coordinates:
@@ -66,7 +65,14 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
// Default Sizes of the Items.
profileYAxis->setX(2);
profileYAxis->setTickSize(1);
+
+ gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop);
+ gasYAxis->setX(3);
gasYAxis->setLine(0, 0, 0, 20);
+ gasYAxis->setTickInterval(1);
+ gasYAxis->setTickSize(2);
+ gasYAxis->setY(70);
+ scene()->addItem(gasYAxis);
temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
temperatureAxis->setLine(0, 60, 0, 90);
@@ -99,7 +105,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
diveComputerText->setBrush(getColor(TIME_TEXT));
// insert in the same way it's declared on the Enum. This is needed so we don't use an map.
- QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
+ QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis <<
timeAxis << depthController << timeController <<
temperatureAxis << cylinderPressureAxis << diveComputerText <<
meanDepth;
@@ -164,6 +170,16 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
diveProfileItem->setZValue(0);
scene()->addItem(diveProfileItem);
+ pn2GasItem = new PartialPressureGasItem();
+ pn2GasItem->setHorizontalAxis(timeAxis);
+ pn2GasItem->setVerticalAxis(gasYAxis);
+ pn2GasItem->setModel(dataModel);
+ pn2GasItem->setVerticalDataColumn(DivePlotDataModel::PN2);
+ pn2GasItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+ pn2GasItem->setZValue(0);
+ pn2GasItem->setThreshouldSettingsKey("pn2threshold");
+ scene()->addItem(pn2GasItem);
+
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
@@ -245,7 +261,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
profileState->assignProperty(background, "y", backgroundOffCanvas);
profileState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
//profileState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
- profileState->assignProperty(gasYAxis, "x", 0);
+ profileState->assignProperty(gasYAxis, "x", profileYAxisOnCanvas);
profileState->assignProperty(timeAxis, "y", timeAxisOnCanvas);
profileState->assignProperty(depthController, "y", depthControllerOffCanvas);
profileState->assignProperty(timeController, "y", timeControllerOffCanvas);
@@ -363,6 +379,13 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
cylinderPressureAxis->setMaximum(pInfo.maxpressure);
meanDepth->setMeanDepth(pInfo.meandepth);
meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
+
+ qreal pp = floor(pInfo.maxpp * 10.0) / 10.0 + 0.2;
+ gasYAxis->setMaximum(pp);
+ gasYAxis->setMinimum(0);
+ gasYAxis->setTickInterval(pp > 4 ? 0.5 : 0.25);
+ gasYAxis->updateTicks();
+
dataModel->setDive(current_dive, pInfo);
// The event items are a bit special since we don't know how many events are going to
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index c20a3f333..5b3821e43 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -37,6 +37,7 @@ struct DiveGasPressureItem;
struct DiveCalculatedCeiling;
struct DiveReportedCeiling;
struct DiveCalculatedTissue;
+struct PartialPressureGasItem;
class ProfileWidget2 : public QGraphicsView {
Q_OBJECT
@@ -91,6 +92,7 @@ private:
DiveCalculatedCeiling *diveCeiling;
QList<DiveCalculatedTissue*> allTissues;
DiveReportedCeiling *reportedCeiling;
+ PartialPressureGasItem *pn2GasItem;
};
#endif