diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-23 17:54:34 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-23 21:11:15 -0800 |
commit | caa45a15396a737ecbef1161e302735b148cc236 (patch) | |
tree | 0a019ed7f5ba0438b36b4268fc2c73d31c7caaee /qt-ui/profile/diveprofileitem.cpp | |
parent | fd45e646dcee98978b85d4776dfbec2eb1587076 (diff) | |
download | subsurface-caa45a15396a737ecbef1161e302735b148cc236.tar.gz |
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 <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
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(); +} |