diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2011-02-01 17:21:08 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2011-02-01 17:21:08 +0100 |
commit | 539f5378462670d10ea6500a7980f3a7f84fe0d5 (patch) | |
tree | f6297c6032321fd4ca9976a3ac3c3eb95c75ba53 /liblogdiag | |
parent | a967a2c3b8cae595d6a9114f4933a28c4818959a (diff) | |
download | logdiag-539f5378462670d10ea6500a7980f3a7f84fe0d5.tar.gz logdiag-539f5378462670d10ea6500a7980f3a7f84fe0d5.tar.xz logdiag-539f5378462670d10ea6500a7980f3a7f84fe0d5.zip |
Fix drawing of the grid.
Diffstat (limited to 'liblogdiag')
-rw-r--r-- | liblogdiag/ld-canvas.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/liblogdiag/ld-canvas.c b/liblogdiag/ld-canvas.c index 1d05b4b..420232d 100644 --- a/liblogdiag/ld-canvas.c +++ b/liblogdiag/ld-canvas.c @@ -1339,12 +1339,17 @@ static void draw_grid (GtkWidget *widget, DrawData *data) { gdouble grid_step; + gint grid_factor; gdouble x_init, y_init; gdouble x, y; grid_step = data->scale; + grid_factor = 1; while (grid_step < 5) + { grid_step *= 5; + grid_factor *= 5; + } ld_canvas_color_apply (COLOR_GET (data->self, COLOR_GRID), data->cr); cairo_set_line_width (data->cr, 1); @@ -1353,8 +1358,14 @@ draw_grid (GtkWidget *widget, DrawData *data) /* Get coordinates of the top-left point. */ ld_canvas_widget_to_diagram_coords (data->self, data->exposed_rect.x, data->exposed_rect.y, &x_init, &y_init); + + x_init = ceil (x_init); + x_init = x_init - (gint) x_init % grid_factor; + y_init = ceil (y_init); + y_init = y_init - (gint) y_init % grid_factor; + ld_canvas_diagram_to_widget_coords (data->self, - ceil (x_init), ceil (y_init), &x_init, &y_init); + x_init, y_init, &x_init, &y_init); /* Iterate over all the points. */ for (x = x_init; x <= data->exposed_rect.x + data->exposed_rect.width; |