This patches fixes a few annoyances and adds the partial pressure gasses. It's important to note that the partial pressure gasses do not follow the settings yet, and thus, you cant disable them.
I accept a bit of help to finish the profile, there's not much left and the API is somewhat stable, I don't think I'll break anything in the near future by changing it. Tomaz
From 31b748f382ac9c2705eba211b276383b2b3bc541 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 15:02:12 -0200 Subject: [PATCH 01/10] Don't recreate the tissues, but instead, reshape them. This patch makes the Tissues be used as a 'cache', it will not be deleted untill the program closes, but whenever a new dive is selected, the old drawings of the tissues will be regenerated, Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/profilewidget2.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 3451ddf..3aa1acd 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -125,6 +125,18 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : diveCeiling->setZValue(1); scene()->addItem(diveCeiling); + for(int i = 0; i < 16; i++){ + DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(); + tissueItem->setHorizontalAxis(timeAxis); + tissueItem->setVerticalAxis(profileYAxis); + tissueItem->setModel(dataModel); + tissueItem->setVerticalDataColumn(DivePlotDataModel::TISSUE_1 + i); + tissueItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + tissueItem->setZValue(1); + allTissues.append(tissueItem); + scene()->addItem(tissueItem); + } + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; @@ -384,21 +396,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives) diveComputerText->setText(currentdc->model); diveComputerText->animateMoveTo(1 , sceneRect().height()); - - qDeleteAll(allTissues); - allTissues.clear(); - for(int i = 0; i < 16; i++){ - DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(); - tissueItem->setHorizontalAxis(timeAxis); - tissueItem->setVerticalAxis(profileYAxis); - tissueItem->setModel(dataModel); - tissueItem->setVerticalDataColumn(DivePlotDataModel::TISSUE_1 + i); - tissueItem->setHorizontalDataColumn(DivePlotDataModel::TIME); - tissueItem->setZValue(1); - allTissues.append(tissueItem); - scene()->addItem(tissueItem); - } - emit startProfileState(); } -- 1.8.5.3
From e45da886e5fdad9c9728788dc1c4d654905b655e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 15:35:32 -0200 Subject: [PATCH 02/10] Move the creation of the Gas Pressure item to the constructor This makes the Gas Pressure Item a 'cached' item, when the dive changes, the item will regenerate the drawing based on it's model. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveprofileitem.cpp | 2 +- qt-ui/profile/profilewidget2.cpp | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 0768f38..c2c95bd 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -258,7 +258,7 @@ void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte void DiveGasPressureItem::modelDataChanged() { // We don't have enougth data to calculate things, quit. - if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1) + if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0) return; int last_index = -1; int lift_pen = false; diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 3aa1acd..e21af21 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -137,6 +137,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : scene()->addItem(tissueItem); } + gasPressureItem = new DiveGasPressureItem(); + gasPressureItem->setHorizontalAxis(timeAxis); + gasPressureItem->setVerticalAxis(cylinderPressureAxis); + gasPressureItem->setModel(dataModel); + gasPressureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE); + gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + gasPressureItem->setZValue(1); + scene()->addItem(gasPressureItem); + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; @@ -381,19 +390,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives) temperatureItem->setZValue(1); scene()->addItem(temperatureItem); - if(gasPressureItem){ - scene()->removeItem(gasPressureItem); - delete gasPressureItem; - } - gasPressureItem = new DiveGasPressureItem(); - gasPressureItem->setHorizontalAxis(timeAxis); - gasPressureItem->setVerticalAxis(cylinderPressureAxis); - gasPressureItem->setModel(dataModel); - gasPressureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE); - gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); - gasPressureItem->setZValue(1); - scene()->addItem(gasPressureItem); - diveComputerText->setText(currentdc->model); diveComputerText->animateMoveTo(1 , sceneRect().height()); emit startProfileState(); -- 1.8.5.3
From 765ce8e8ebaf49015cc8bda55317c1c424109336 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 15:37:50 -0200 Subject: [PATCH 03/10] Fix the ghost-text-on-profile regression The last patch correctly moved the GasPressure item to use a cache-based system, but ignored the fact that the Gas pressure text was not being removed from the scene. this fixed it. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveprofileitem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index c2c95bd..25d6a84 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -284,6 +284,10 @@ void DiveGasPressureItem::modelDataChanged() } setPolygon(boundingPoly); + //TODO: Instead of deleting all texts, move the existing ones to it's new location. + qDeleteAll(texts); + texts.clear(); + int mbar, cyl; int seen_cyl[MAX_CYLINDERS] = { false, }; int last_pressure[MAX_CYLINDERS] = { 0, }; -- 1.8.5.3
From 246e98f0f81be460cd79f38a818ff5215b0a0f24 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 15:44:12 -0200 Subject: [PATCH 04/10] Moved the temperature item as a 'Cache' This patch moves the temperature item as a cache that will be updated as the model updates, instead of deleting / recreating it everytime the dive changes. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveprofileitem.cpp | 2 +- qt-ui/profile/profilewidget2.cpp | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 25d6a84..f00fff6 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -192,7 +192,7 @@ DiveTemperatureItem::DiveTemperatureItem() void DiveTemperatureItem::modelDataChanged() { // We don't have enougth data to calculate things, quit. - if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1) + if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0) return; qDeleteAll(texts); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index e21af21..2f60759 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -146,6 +146,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : gasPressureItem->setZValue(1); scene()->addItem(gasPressureItem); + temperatureItem = new DiveTemperatureItem(); + temperatureItem->setHorizontalAxis(timeAxis); + temperatureItem->setVerticalAxis(temperatureAxis); + temperatureItem->setModel(dataModel); + temperatureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE); + temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + temperatureItem->setZValue(1); + scene()->addItem(temperatureItem); + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; @@ -377,19 +386,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives) event = event->next; } - if(temperatureItem){ - scene()->removeItem(temperatureItem); - delete temperatureItem; - } - temperatureItem = new DiveTemperatureItem(); - temperatureItem->setHorizontalAxis(timeAxis); - temperatureItem->setVerticalAxis(temperatureAxis); - temperatureItem->setModel(dataModel); - temperatureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE); - temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); - temperatureItem->setZValue(1); - scene()->addItem(temperatureItem); - diveComputerText->setText(currentdc->model); diveComputerText->animateMoveTo(1 , sceneRect().height()); emit startProfileState(); -- 1.8.5.3
From 78f77f6a4579432c39f584671a81897920c68ec7 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 16:03:19 -0200 Subject: [PATCH 05/10] Move profile item to be used as cache. the profile item should also use the model to know when to change something, this makes it happen. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveprofileitem.cpp | 3 +++ qt-ui/profile/profilewidget2.cpp | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index f00fff6..774938c 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -107,6 +107,9 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o void DiveProfileItem::modelDataChanged() { + if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1 || dataModel->rowCount() == 0) + return; + AbstractProfilePolygonItem::modelDataChanged(); if (polygon().isEmpty()) return; diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 2f60759..2f7505d 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -155,6 +155,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : temperatureItem->setZValue(1); scene()->addItem(temperatureItem); + diveProfileItem = new DiveProfileItem(); + diveProfileItem->setHorizontalAxis(timeAxis); + diveProfileItem->setVerticalAxis(profileYAxis); + diveProfileItem->setModel(dataModel); + diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH); + diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + diveProfileItem->setZValue(0); + scene()->addItem(diveProfileItem); + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; @@ -356,20 +365,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives) meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth)); dataModel->setDive(current_dive, pInfo); - if (diveProfileItem) { - //diveProfileItem->animateDelete(); - scene()->removeItem(diveProfileItem); - delete diveProfileItem; - } - diveProfileItem = new DiveProfileItem(); - diveProfileItem->setHorizontalAxis(timeAxis); - diveProfileItem->setVerticalAxis(profileYAxis); - diveProfileItem->setModel(dataModel); - diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH); - diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME); - diveProfileItem->setZValue(0); - scene()->addItem(diveProfileItem); - qDeleteAll(eventItems); eventItems.clear(); -- 1.8.5.3
From bbc50515f810e5341fcc53a265b42466e07cdf8d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 16:07:22 -0200 Subject: [PATCH 06/10] Prevent memory leak by removing the texts on the TemperatureItem This patch prevents memory leak by adding the text on the list of 'delete me when model changes' items. it also makes things a bit more snappy because the scene doesn't have to deal with all of the texts bounding rectangles eveytime. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveprofileitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 774938c..42c3eca 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -249,6 +249,7 @@ void DiveTemperatureItem::createTextItem(int sec, int mkelvin) text->setPos(QPointF(hAxis->posAtValue(sec), vAxis->posAtValue(mkelvin))); text->setText(QString("%1%2").arg(deg, 0, 'f', 1).arg(unit)); // text->setSize(TEMP_TEXT_SIZE); //TODO: TEXT SIZE! + texts.append(text); } void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -- 1.8.5.3
From 2450095d818230b92594f6f8fe55f560cdd6cfab Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 16:12:18 -0200 Subject: [PATCH 07/10] Added comments explaining why the events are created on the setDive Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/profilewidget2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 2f7505d..568b908 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -365,9 +365,11 @@ void ProfileWidget2::plotDives(QList<dive*> dives) meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth)); dataModel->setDive(current_dive, pInfo); + // The event items are a bit special since we don't know how many events are going to + // exist on a dive, so I cant create cache items for that. that's why they are here + // while all other items are up there on the constructor. qDeleteAll(eventItems); eventItems.clear(); - struct event *event = currentdc->events; while (event) { DiveEventItem *item = new DiveEventItem(); -- 1.8.5.3
From b79ae16d594c679b19dba96cc5e9a9f67c3bcfb3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 17:54:34 -0200 Subject: [PATCH 08/10] Added the first Partial Gas Pressure: PN2 This makes the beginning of the partial gas pressures, there's two more. but this code uses a good part of the Model View system, and it's way clearer than the old one. Luckly the other 2 missing items will be even more clear ( the diffs ) to do, because I just need to create a new PartialPressureGasItem and set the properties. <3 Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveplotdatamodel.cpp | 2 ++ qt-ui/profile/diveplotdatamodel.h | 2 +- qt-ui/profile/diveprofileitem.cpp | 50 +++++++++++++++++++++++++++++++++++++ qt-ui/profile/diveprofileitem.h | 13 ++++++++++ qt-ui/profile/profilewidget2.cpp | 29 ++++++++++++++++++--- qt-ui/profile/profilewidget2.h | 2 ++ 6 files changed, 94 insertions(+), 4 deletions(-) diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp index 6635ff1..b523472 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 b188396..3116bcd 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 42c3eca..15944e9 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 c6c5b19..8da9ace 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 568b908..6041bac 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 c20a3f3..5b3821e 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 -- 1.8.5.3
From 3c33f3db9641a8120cd31ae1beb210282ce9f75f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 17:59:14 -0200 Subject: [PATCH 09/10] Added the code for the PHE gas pressure. Using the PartialPressureGasItem the addition of a new partial plot is very easy. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveplotdatamodel.cpp | 2 ++ qt-ui/profile/diveplotdatamodel.h | 2 +- qt-ui/profile/profilewidget2.cpp | 10 ++++++++++ qt-ui/profile/profilewidget2.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp index b523472..598391b 100644 --- a/qt-ui/profile/diveplotdatamodel.cpp +++ b/qt-ui/profile/diveplotdatamodel.cpp @@ -37,6 +37,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const case CEILING: return item.ceiling; case SAC: return item.sac; case PN2: return item.pn2; + case PHE: return item.phe; } } @@ -83,6 +84,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation, case CEILING: return tr("Ceiling"); case SAC: return tr("SAC"); case PN2: return tr("PN2"); + case PHE: return tr("PHE"); } 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 3116bcd..4e5897d 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, PN2,COLUMNS}; + TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16, PN2,PHE,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/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 6041bac..8397dcb 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -180,6 +180,16 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : pn2GasItem->setThreshouldSettingsKey("pn2threshold"); scene()->addItem(pn2GasItem); + pheGasItem = new PartialPressureGasItem(); + pheGasItem->setHorizontalAxis(timeAxis); + pheGasItem->setVerticalAxis(gasYAxis); + pheGasItem->setModel(dataModel); + pheGasItem->setVerticalDataColumn(DivePlotDataModel::PHE); + pheGasItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + pheGasItem->setZValue(0); + pheGasItem->setThreshouldSettingsKey("phethreshold"); + scene()->addItem(pheGasItem); + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 5b3821e..eaed477 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -93,6 +93,7 @@ private: QList<DiveCalculatedTissue*> allTissues; DiveReportedCeiling *reportedCeiling; PartialPressureGasItem *pn2GasItem; + PartialPressureGasItem *pheGasItem; }; #endif -- 1.8.5.3
From 59cd778ff780eb101c1e46e2baec86ca45702be4 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tcanabr...@kde.org> Date: Thu, 23 Jan 2014 18:03:28 -0200 Subject: [PATCH 10/10] Added the Po2 Partial Pressure Graph. Important to note that no Partial Pressure Graph handles settings yet. Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org> --- qt-ui/profile/diveplotdatamodel.cpp | 2 ++ qt-ui/profile/diveplotdatamodel.h | 2 +- qt-ui/profile/profilewidget2.cpp | 10 ++++++++++ qt-ui/profile/profilewidget2.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp index 598391b..bf4425a 100644 --- a/qt-ui/profile/diveplotdatamodel.cpp +++ b/qt-ui/profile/diveplotdatamodel.cpp @@ -38,6 +38,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const case SAC: return item.sac; case PN2: return item.pn2; case PHE: return item.phe; + case PO2: return item.po2; } } @@ -85,6 +86,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation, case SAC: return tr("SAC"); case PN2: return tr("PN2"); case PHE: return tr("PHE"); + case PO2: return tr("PO2"); } 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 4e5897d..c5ed175 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, PN2,PHE,COLUMNS}; + TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16, PN2,PHE,PO2,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/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 8397dcb..a39dbad 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -190,6 +190,16 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : pheGasItem->setThreshouldSettingsKey("phethreshold"); scene()->addItem(pheGasItem); + pheGasItem = new PartialPressureGasItem(); + pheGasItem->setHorizontalAxis(timeAxis); + pheGasItem->setVerticalAxis(gasYAxis); + pheGasItem->setModel(dataModel); + pheGasItem->setVerticalDataColumn(DivePlotDataModel::PO2); + pheGasItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + pheGasItem->setZValue(0); + pheGasItem->setThreshouldSettingsKey("po2threshold"); + scene()->addItem(pheGasItem); + background->setFlag(QGraphicsItem::ItemIgnoresTransformations); //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index eaed477..4181901 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -94,6 +94,7 @@ private: DiveReportedCeiling *reportedCeiling; PartialPressureGasItem *pn2GasItem; PartialPressureGasItem *pheGasItem; + PartialPressureGasItem *po2GasItem; }; #endif -- 1.8.5.3
_______________________________________________ subsurface mailing list subsurface@hohndel.org http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface