summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-17 16:13:02 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-17 16:15:36 -0700
commitbfa37c3cac22949323bb6a5dfb23557638d20757 (patch)
tree52e35d78c4c0f3a52d2593291eab510dd0cd95f5 /profile.c
parenta094b2b88a21a7161def15ad0a730f79a8c83f09 (diff)
downloadsubsurface-bfa37c3cac22949323bb6a5dfb23557638d20757.tar.gz
First step towards a context menu in the profile view
This is completely bogus as all it does is print out the corresponding time for the spot we right-clicked on the profile. But that at least shows that the infrastructure is working as intended... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/profile.c b/profile.c
index 522e5ae15..6bbb11fb1 100644
--- a/profile.c
+++ b/profile.c
@@ -141,6 +141,15 @@ static const color_t profile_color[] = {
#define SCALEY(gc,y) (((y)-gc->topy)/(gc->bottomy-gc->topy)*gc->maxy)
#define SCALE(gc,x,y) SCALEX(gc,x),SCALEY(gc,y)
+/* keep the last used gc around so we can invert the SCALEX calculation in
+ * order to calculate a time value for an x coordinate */
+static struct graphics_context last_gc;
+int x_to_time(double x)
+{
+ int seconds = (x - last_gc.drawing_area.x) / last_gc.maxx * (last_gc.rightx - last_gc.leftx) + last_gc.leftx;
+ return (seconds > 0) ? seconds : 0;
+}
+
static void move_to(struct graphics_context *gc, double x, double y)
{
cairo_move_to(gc->cr, SCALE(gc, x, y));
@@ -700,6 +709,9 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
gc->leftx = 0; gc->rightx = maxtime;
gc->topy = 0; gc->bottomy = 1.0;
+
+ last_gc = *gc;
+
set_source_rgba(gc, TIME_GRID);
cairo_set_line_width_scaled(gc->cr, 2);