summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-04 20:18:16 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-04 20:18:16 -0300
commit926224122ebc4cf6a53e3a63eb455293bcfb455d (patch)
tree517dcaa60b6dfd484d306a9de9683e02d114cba7 /qt-ui
parent09597cd2d8729ab368f2e423dbb1ef5235745f58 (diff)
downloadsubsurface-926224122ebc4cf6a53e3a63eb455293bcfb455d.tar.gz
Added the code to plot the actual Graph.
This version already plots the dive-graph, with the gradient and all that jazz. One thing that will be easily spotted is that the size of the line is very thick - easily changed, I'm just using the default. As soon as everything is plotted correctly I'll fix the lines. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profilegraphics.cpp32
-rw-r--r--qt-ui/profilegraphics.h3
2 files changed, 19 insertions, 16 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 891cd81bf..761ef262b 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -337,38 +337,38 @@ void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct
plot_smoothed_profile(gc, pi);
plot_minmax_profile(gc, pi);
}
+#endif
/* Do the depth profile for the neat fill */
gc->topy = 0; gc->bottomy = maxdepth;
- cairo_pattern_t *pat;
- pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
- pattern_add_color_stop_rgba (gc, pat, 1, DEPTH_BOTTOM);
- pattern_add_color_stop_rgba (gc, pat, 0, DEPTH_TOP);
-
- cairo_set_source(gc->cr, pat);
- cairo_pattern_destroy(pat);
- cairo_set_line_width_scaled(gc->cr, 2);
-
entry = pi->entry;
- move_to(gc, 0, 0);
+
+ QGraphicsPolygonItem *neatFill = new QGraphicsPolygonItem();
+ QPolygonF p;
for (i = 0; i < pi->nr; i++, entry++)
- line_to(gc, entry->sec, entry->depth);
+ p.append( QPointF( SCALE(gc, entry->sec, entry->depth) ));
/* Show any ceiling we may have encountered */
for (i = pi->nr - 1; i >= 0; i--, entry--) {
if (entry->ndl) {
/* non-zero NDL implies this is a safety stop, no ceiling */
- line_to(gc, entry->sec, 0);
+ p.append( QPointF( SCALE(gc, entry->sec, 0) ));
} else if (entry->stopdepth < entry->depth) {
- line_to(gc, entry->sec, entry->stopdepth);
+ p.append( QPointF( SCALE(gc, entry->sec, entry->stopdepth) ));
} else {
- line_to(gc, entry->sec, entry->depth);
+ p.append( QPointF( SCALE(gc, entry->sec, entry->depth) ));
}
}
- cairo_close_path(gc->cr);
- cairo_fill(gc->cr);
+ neatFill->setPolygon(p);
+ QLinearGradient pat(0.0,0.0,0.0,p.boundingRect().height());
+ pat.setColorAt(1, profile_color[DEPTH_BOTTOM].first());
+ pat.setColorAt(0, profile_color[DEPTH_TOP].first());
+
+ neatFill->setBrush(QBrush(pat));
+ scene()->addItem(neatFill);
+#if 0
/* if the user wants the deco ceiling more visible, do that here (this
* basically draws over the background that we had allowed to shine
* through so far) */
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h
index 633409b23..a62e55c4d 100644
--- a/qt-ui/profilegraphics.h
+++ b/qt-ui/profilegraphics.h
@@ -14,6 +14,9 @@ protected:
private:
void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi);
+
+ QPen defaultPen;
+ QBrush defaultBrush;
};
#endif