aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-06 19:42:39 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-06 20:30:29 -0700
commit1a8239a240fe14e983da6d9a6048e2fb154ee053 (patch)
tree5e4e2df15aac2004a9f4d4f86f8bc47e996604a0
parent867435442b8f6f4094d7075be2cbc697d1618c26 (diff)
downloadsubsurface-1a8239a240fe14e983da6d9a6048e2fb154ee053.tar.gz
Finish the plotting of the events
Beautification of the triangles done, Tooltips are also displaying Some rework on the code - don't know if dirk will accept, I'v changed an if-else-if-else by a ternary operator, since it improves legibility a little bit. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profilegraphics.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index b3163add4..9f1f115cb 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -13,6 +13,9 @@
#include "../dive.h"
#include "../profile.h"
+#include <libdivecomputer/parser.h>
+#include <libdivecomputer/version.h>
+
#define SAC_COLORS_START_IDX SAC_1
#define SAC_COLORS 9
#define VELOCITY_COLORS_START_IDX VELO_STABLE
@@ -121,6 +124,10 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
setRenderHint(QPainter::HighQualityAntialiasing);
setRenderHint(QPainter::SmoothPixmapTransform);
+ defaultPen.setJoinStyle(Qt::RoundJoin);
+ defaultPen.setCapStyle(Qt::RoundCap);
+ defaultPen.setWidth(2);
+
fill_profile_color();
}
@@ -314,15 +321,18 @@ void ProfileGraphicsView::plot_one_event(struct graphics_context *gc, struct plo
int x = SCALEX(gc, ev->time.seconds);
int y = SCALEY(gc, depth);
+ QPen pen = defaultPen;
+ pen.setBrush(QBrush(profile_color[ALERT_BG].first()));
+
QGraphicsPolygonItem *triangle = new QGraphicsPolygonItem();
triangle->setPolygon(poly);
triangle->setBrush(QBrush(profile_color[ALERT_BG].first()));
- triangle->setPen(QPen(QBrush(profile_color[ALERT_FG].first()), 1));
+ triangle->setPen(pen);
triangle->setFlag(QGraphicsItem::ItemIgnoresTransformations);
triangle->setPos(x, y);
QGraphicsLineItem *line = new QGraphicsLineItem(0,5,0,10, triangle);
- line->setPen(QPen(QBrush(Qt::black), 2));
+ line->setPen(defaultPen);
QGraphicsEllipseItem *ball = new QGraphicsEllipseItem(-1, 12, 2,2, triangle);
ball->setBrush(QBrush(Qt::black));
@@ -335,14 +345,11 @@ void ProfileGraphicsView::plot_one_event(struct graphics_context *gc, struct plo
if (ev->name && name == "gaschange") {
unsigned int he = ev->value >> 16;
unsigned int o2 = ev->value & 0xffff;
- if (he) {
- name += QString("%1/%2").arg(o2, he);
- } else {
- if (o2 == 21)
- name += tr(":air");
- else
- name += QString("%1 %% %2").arg(o2).arg("O" UTF8_SUBSCRIPT_2);
- }
+
+ name += (he) ? QString("%1/%2").arg(o2, he)
+ : (o2 == 21) ? name += tr(":air")
+ : QString("%1 %% %2").arg(o2).arg("O" UTF8_SUBSCRIPT_2);
+
} else if (ev->name && !strcmp(ev->name, "SP change")) {
name += QString(":%1").arg( (double) ev->value / 1000 );
} else {
@@ -351,11 +358,12 @@ void ProfileGraphicsView::plot_one_event(struct graphics_context *gc, struct plo
} else if (ev->name && name == "SP change") {
name += tr("Bailing out to OC");
} else {
- //name += ev->flags == SAMPLE_FLAGS_BEGIN ? C_("Starts with space!"," begin") :
- // ev->flags == SAMPLE_FLAGS_END ? C_("Starts with space!", " end") : "";
+ name += ev->flags == SAMPLE_FLAGS_BEGIN ? tr("Starts with space!"," begin") :
+ ev->flags == SAMPLE_FLAGS_END ? tr("Starts with space!", " end") : "";
}
//attach_tooltip(x-6, y, 12, 12, buffer, ev);
+ triangle->setToolTip(name);
}
void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct plot_info *pi)
@@ -595,7 +603,6 @@ void ProfileGraphicsView::plot_text(struct graphics_context *gc, text_render_opt
item->setPen( QPen(profile_color[BACKGROUND].first()));
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
scene()->addItem(item);
- qDebug() << item->pos();
}