From caa45a15396a737ecbef1161e302735b148cc236 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 23 Jan 2014 17:54:34 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'qt-ui/profile/diveprofileitem.cpp') 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(); +} -- cgit v1.2.3-70-g09d2