Changeset a75168d in subsurface


Ignore:
Timestamp:
Dec 3, 2013, 12:58:54 PM (4 years ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
Mtest, android_test, dcDownload, foratdotde, gitMerge, gitdebug, gitpictures, ios, master, mergeKirigamiPort, pictimeshift, resolutionIndependence, spinner, testTomaz, testing, v4.0-branch, v4.0.3-branch, v4.2-branch, v4.4-branch, v4.5-branch
Children:
9b51901
Parents:
a7bdf39
git-author:
Tomaz Canabrava <tcanabrava@…> (12/03/13 12:27:44)
git-committer:
Dirk Hohndel <dirk@…> (12/03/13 12:58:54)
Message:

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@…>
Signed-off-by: Dirk Hohndel <dirk@…>

Location:
qt-ui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • qt-ui/profilegraphics.cpp

    rdc03b7e ra75168d  
    591591        QColor c;
    592592        QPointF from, to;
     593        QPointF legendPos = QPointF(scene()->sceneRect().width() * 0.4, scene()->sceneRect().height() - 15);
     594
    593595        if (prefs.pp_graphs.pn2) {
    594596                c = getColor(PN2);
     
    613615                                from = QPointF(SCALEGC(entry->sec, entry->pn2));
    614616                }
     617                createPPLegend(tr("Pn2"),getColor(PN2), legendPos);
    615618        }
    616619
     
    638641                                from = QPointF(SCALEGC(entry->sec, entry->phe));
    639642                }
     643                createPPLegend(tr("PHE"),getColor(PHE), legendPos);
    640644        }
    641645        if (prefs.pp_graphs.po2) {
     
    661665                                from = QPointF(SCALEGC(entry->sec, entry->po2));
    662666                }
    663         }
     667                createPPLegend(tr("PO2"),getColor(PO2), legendPos);
     668        }
     669}
     670
     671void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF& legendPos)
     672{
     673        QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 16, 16);
     674        rect->setFlag(QGraphicsItem::ItemIgnoresTransformations);
     675        rect->setBrush(QBrush(c));
     676        rect->setPos(legendPos);
     677        QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(title);
     678        text->setPos(legendPos.x() + rect->boundingRect().width() + 5, legendPos.y() - 6);
     679        text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
     680        scene()->addItem(rect);
     681        scene()->addItem(text);
     682        legendPos.setX( legendPos.x() + 100);
    664683}
    665684
  • qt-ui/profilegraphics.h

    re8d1f14 ra75168d  
    186186        QColor get_sac_color(int sac, int avg_sac);
    187187        void scrollViewTo(const QPoint pos);
     188        void createPPLegend(QString tr, const QColor& c, QPointF& legendPos);
    188189
    189190        QPen defaultPen;
Note: See TracChangeset for help on using the changeset viewer.