summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-21 14:59:19 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 11:35:09 -0800
commit8065374793908894b47cfd1c2bb0b9913d404bb4 (patch)
treedf2fe4bfec7a05ce3e255cdcf06a38b6f7aded4c
parentb1df7aeb4e06cfc512d19b2f7e7f5b455dea0c22 (diff)
downloadsubsurface-8065374793908894b47cfd1c2bb0b9913d404bb4.tar.gz
Add the DiveCalculatedCeiling item.
This item plots the DiveCalculatedCeiling over the profile. I still need to add the Calc All Tissues version. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp2
-rw-r--r--qt-ui/profile/diveplotdatamodel.h3
-rw-r--r--qt-ui/profile/diveprofileitem.cpp27
-rw-r--r--qt-ui/profile/diveprofileitem.h9
-rw-r--r--qt-ui/profile/profilewidget2.cpp15
-rw-r--r--qt-ui/profile/profilewidget2.h2
-rw-r--r--qt-ui/profilegraphics.cpp1
7 files changed, 56 insertions, 3 deletions
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index e393696dc..b32918bc5 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -34,6 +34,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
case CYLINDERINDEX: return item.cylinderindex;
case SENSOR_PRESSURE: return item.pressure[0];
case INTERPOLATED_PRESSURE: return item.pressure[1];
+ case CEILING: return item.ceiling;
case SAC: return item.sac;
}
}
@@ -73,6 +74,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
case CYLINDERINDEX: return tr("Cylinder Index");
case SENSOR_PRESSURE: return tr("Pressure S");
case INTERPOLATED_PRESSURE: return tr("Pressure I");
+ case CEILING: return tr("Ceiling");
case SAC: return tr("SAC");
}
return QVariant();
diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h
index 3afc580cf..cc391097d 100644
--- a/qt-ui/profile/diveplotdatamodel.h
+++ b/qt-ui/profile/diveplotdatamodel.h
@@ -10,7 +10,8 @@ struct plot_info;
class DivePlotDataModel : public QAbstractTableModel{
Q_OBJECT
public:
- enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE, SAC, COLUMNS};
+ enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE,
+ SAC, CEILING, 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 7c339eba9..cec7667c2 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -318,3 +318,30 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte
}
}
}
+
+void DiveCalculatedCeiling::modelDataChanged()
+{
+ // We don't have enougth data to calculate things, quit.
+ if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1)
+ return;
+ AbstractProfilePolygonItem::modelDataChanged();
+ // Add 2 points to close the polygon.
+ QPolygonF poly = polygon();
+ QPointF p1 = poly.first();
+ QPointF p2 = poly.last();
+
+ poly.prepend(QPointF(p1.x(), vAxis->posAtValue(0)));
+ poly.append(QPointF(p2.x(), vAxis->posAtValue(0)));
+ setPolygon(poly);
+
+ QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
+ pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
+ pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
+ setPen(QPen(QBrush(Qt::NoBrush),0));
+ setBrush(pat);
+}
+
+void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ QGraphicsPolygonItem::paint(painter, option, widget);
+}
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 1aa1af9ad..9e71eac19 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -65,7 +65,6 @@ public:
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
private:
void createTextItem(int seconds, int mkelvin);
- QList<DiveTextItem*> texts;
};
class DiveGasPressureItem : public AbstractProfilePolygonItem{
@@ -80,4 +79,12 @@ private:
QVector<QPolygonF> polygons;
};
+class DiveCalculatedCeiling : public AbstractProfilePolygonItem{
+ Q_OBJECT
+
+public:
+ virtual void modelDataChanged();
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+};
+
#endif \ No newline at end of file
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index b76b4d351..46856ba76 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -38,7 +38,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
gasPressureItem(NULL),
cartesianPlane(new DiveCartesianPlane()),
meanDepth(new DiveLineItem()),
- diveComputerText(new DiveTextItem())
+ diveComputerText(new DiveTextItem()),
+ diveCeiling(NULL)
{
setScene(new QGraphicsScene());
scene()->setSceneRect(0, 0, 100, 100);
@@ -358,6 +359,18 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
scene()->addItem(gasPressureItem);
+ if(diveCeiling){
+ scene()->removeItem(diveCeiling);
+ delete diveCeiling;
+ }
+ diveCeiling = new DiveCalculatedCeiling();
+ diveCeiling->setHorizontalAxis(timeAxis);
+ diveCeiling->setVerticalAxis(profileYAxis);
+ diveCeiling->setModel(dataModel);
+ diveCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
+ diveCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
+ scene()->addItem(diveCeiling);
+
diveComputerText->setText(currentdc->model);
diveComputerText->animateMoveTo(1 , sceneRect().height());
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 7a24008d7..d5d657d40 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -32,6 +32,7 @@ struct DiveCartesianPlane;
struct DiveTemperatureItem;
struct plot_info;
struct DiveGasPressureItem;
+struct DiveCalculatedCeiling;
class ProfileWidget2 : public QGraphicsView {
Q_OBJECT
@@ -83,6 +84,7 @@ private:
DiveLineItem *meanDepth;
QList<DiveEventItem*> eventItems;
DiveTextItem *diveComputerText;
+ DiveCalculatedCeiling *diveCeiling;
};
#endif
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 454bca65a..0bb78d7e6 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -1312,6 +1312,7 @@ void ProfileGraphicsView::plot_depth_profile()
scene()->addItem(neatFill);
}
}
+
/* next show where we have been bad and crossed the dc's ceiling */
if (prefs.profile_dc_ceiling) {
pat.setColorAt(0, getColor(CEILING_SHALLOW));