diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-21 13:27:08 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-21 09:39:09 -0800 |
commit | 0a4e21a16813592031baf8ca90bc52418aa8965e (patch) | |
tree | 1d9d255b45de6bbe048e911fdca2fcb59d7982b2 | |
parent | caba6500d63e6081565aebd9e872e48b049e5d03 (diff) | |
download | subsurface-0a4e21a16813592031baf8ca90bc52418aa8965e.tar.gz |
Add the depth text.
Depth text got added to the new profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/profile/diveplotdatamodel.cpp | 5 | ||||
-rw-r--r-- | qt-ui/profile/diveplotdatamodel.h | 1 | ||||
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 36 | ||||
-rw-r--r-- | qt-ui/profile/diveprofileitem.h | 4 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 2 | ||||
-rw-r--r-- | qt-ui/profilegraphics.h | 2 |
6 files changed, 48 insertions, 2 deletions
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp index 32067d3e0..b0532f6a9 100644 --- a/qt-ui/profile/diveplotdatamodel.cpp +++ b/qt-ui/profile/diveplotdatamodel.cpp @@ -45,6 +45,11 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const return QVariant(); } +plot_data* DivePlotDataModel::data() +{ + return plotData; +} + int DivePlotDataModel::rowCount(const QModelIndex& parent) const { return sampleCount; diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h index dc032734e..3d4d4958b 100644 --- a/qt-ui/profile/diveplotdatamodel.h +++ b/qt-ui/profile/diveplotdatamodel.h @@ -18,6 +18,7 @@ public: virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; void clear(); void setDive(struct dive *d, const plot_info& pInfo); + plot_data* data(); private: int sampleCount; plot_data *plotData; diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 03ad9c18e..0715bc58b 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -103,6 +103,42 @@ void DiveProfileItem::modelDataChanged(){ pat.setColorAt(1, getColor(DEPTH_BOTTOM)); pat.setColorAt(0, getColor(DEPTH_TOP)); setBrush(QBrush(pat)); + + qDeleteAll(texts); + texts.clear(); + + int last = -1; + for (int i = 0, count = dataModel->rowCount(); i < count; i++) { + + struct plot_data *entry = static_cast<DivePlotDataModel*>(dataModel)->data()+i; + if (entry->depth < 2000) + continue; + + if ((entry == entry->max[2]) && entry->depth / 100 != last) { + plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_DEEP)); + last = entry->depth / 100; + } + + if ((entry == entry->min[2]) && entry->depth / 100 != last) { + plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_SHALLOW)); + last = entry->depth / 100; + } + + if (entry->depth != last) + last = -1; + } +} + +void DiveProfileItem::plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color) +{ + int decimals; + double d = get_depth_units(entry->depth, &decimals, NULL); + DiveTextItem *item = new DiveTextItem(this); + item->setPos(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth)); + item->setText(QString("%1").arg(d, 0, 'f', 1)); + item->setAlignment(flags); + item->setBrush(color); + texts.append(item); } DiveTemperatureItem::DiveTemperatureItem() diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 89c18ff70..b9be3edf4 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -21,6 +21,7 @@ class DiveTextItem; class DiveCartesianAxis; class QAbstractTableModel; +struct plot_data; class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem{ Q_OBJECT @@ -43,13 +44,16 @@ protected: QAbstractTableModel *dataModel; int hDataColumn; int vDataColumn; + QList<DiveTextItem*> texts; }; class DiveProfileItem : public AbstractProfilePolygonItem{ Q_OBJECT + public: virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); virtual void modelDataChanged(); + void plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color); }; class DiveTemperatureItem : public AbstractProfilePolygonItem{ diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 34b87ad78..b76b4d351 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -359,7 +359,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives) scene()->addItem(gasPressureItem); diveComputerText->setText(currentdc->model); - diveComputerText->setPos(1 , sceneRect().height()); + diveComputerText->animateMoveTo(1 , sceneRect().height()); emit startProfileState(); } diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index 8881d0321..e2b858149 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -162,7 +162,7 @@ private: void plot_single_temp_text(int sec, int mkelvin); void plot_depth_text(); void plot_text_samples(); - void plot_depth_sample(struct plot_data *entry, text_render_options_t *tro); + void plot_depth_sample(plot_data* entry, text_render_options_t* tro); void plot_cylinder_pressure_text(); void plot_pressure_value(int mbar, int sec, double xalign, double yalign); void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he); |