diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-12-03 18:27:44 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-03 12:58:54 -0800 |
commit | a75168dcc977cd140783745327ff33de4e37796b (patch) | |
tree | 24e1e145cf49446765b109c4d2d6fb72a380a36d | |
parent | a7bdf39339923e3f9390762a53c2093d3a01fd5e (diff) | |
download | subsurface-a75168dcc977cd140783745327ff33de4e37796b.tar.gz |
Add legend for the Partial Gass Pressure if active.
This patch adds legend for the partial gass pressures if the
graphs are active. when enabling / disabling the square
that represents the color of a gas will also appear / disappear.
Fixes: #272
[Dirk Hohndel: minor changes to layout and whitespace]
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/profilegraphics.cpp | 19 | ||||
-rw-r--r-- | qt-ui/profilegraphics.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index b1798f750..0d38a89f9 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -590,6 +590,8 @@ void ProfileGraphicsView::plot_pp_gas_profile() setup_pp_limits(&gc); QColor c; QPointF from, to; + QPointF legendPos = QPointF(scene()->sceneRect().width() * 0.4, scene()->sceneRect().height() - 15); + if (prefs.pp_graphs.pn2) { c = getColor(PN2); entry = pi->entry; @@ -612,6 +614,7 @@ void ProfileGraphicsView::plot_pp_gas_profile() else from = QPointF(SCALEGC(entry->sec, entry->pn2)); } + createPPLegend(tr("Pn2"),getColor(PN2), legendPos); } if (prefs.pp_graphs.phe) { @@ -637,6 +640,7 @@ void ProfileGraphicsView::plot_pp_gas_profile() else from = QPointF(SCALEGC(entry->sec, entry->phe)); } + createPPLegend(tr("PHE"),getColor(PHE), legendPos); } if (prefs.pp_graphs.po2) { c = getColor(PO2); @@ -660,9 +664,24 @@ void ProfileGraphicsView::plot_pp_gas_profile() else from = QPointF(SCALEGC(entry->sec, entry->po2)); } + createPPLegend(tr("PO2"),getColor(PO2), legendPos); } } +void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF& legendPos) +{ + QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 16, 16); + rect->setFlag(QGraphicsItem::ItemIgnoresTransformations); + rect->setBrush(QBrush(c)); + rect->setPos(legendPos); + QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(title); + text->setPos(legendPos.x() + rect->boundingRect().width() + 5, legendPos.y() - 6); + text->setFlag(QGraphicsItem::ItemIgnoresTransformations); + scene()->addItem(rect); + scene()->addItem(text); + legendPos.setX( legendPos.x() + 100); +} + void ProfileGraphicsView::plot_deco_text() { if (prefs.profile_calc_ceiling) { diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index 059b66785..2cd5b44d2 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -185,6 +185,7 @@ private: QColor getColor(const color_indice_t i); QColor get_sac_color(int sac, int avg_sac); void scrollViewTo(const QPoint pos); + void createPPLegend(QString tr, const QColor& c, QPointF& legendPos); QPen defaultPen; QBrush defaultBrush; |