aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-01-08 16:41:55 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2011-01-08 16:41:55 +0100
commitfe996324d365f3a35e59dda8e10db5327de444e8 (patch)
tree079c2caf9c873d061f2c708873b43a836d30e18b /src
parent909a0352cc4f89cb7493e78715ae089072eaaee1 (diff)
downloadlogdiag-fe996324d365f3a35e59dda8e10db5327de444e8.tar.gz
logdiag-fe996324d365f3a35e59dda8e10db5327de444e8.tar.xz
logdiag-fe996324d365f3a35e59dda8e10db5327de444e8.zip
Take a better approach to drawing the grid.
If the diagram is zoomed out too much, just use bigger steps between dots.
Diffstat (limited to 'src')
-rw-r--r--src/ld-canvas.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ld-canvas.c b/src/ld-canvas.c
index b008fb8..fdec62b 100644
--- a/src/ld-canvas.c
+++ b/src/ld-canvas.c
@@ -1072,11 +1072,13 @@ on_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
static void
draw_grid (GtkWidget *widget, DrawData *data)
{
+ gdouble grid_step;
gdouble x_init, y_init;
gdouble x, y;
- if (data->scale < 2)
- return;
+ grid_step = data->scale;
+ while (grid_step < 5)
+ grid_step *= 5;
ld_canvas_color_apply (COLOR_GET (data->self, COLOR_GRID), data->cr);
cairo_set_line_width (data->cr, 1);
@@ -1090,10 +1092,10 @@ draw_grid (GtkWidget *widget, DrawData *data)
/* Iterate over all the points. */
for (x = x_init; x <= data->exposed_rect.x + data->exposed_rect.width;
- x += data->scale)
+ x += grid_step)
{
for (y = y_init; y <= data->exposed_rect.y + data->exposed_rect.height;
- y += data->scale)
+ y += grid_step)
{
cairo_move_to (data->cr, x, y);
cairo_line_to (data->cr, x, y);