[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-45-g52df0d8)



The branch, master has been updated
       via  52df0d861e880e019c7aeea71f1ed448bbed47db (commit)
       via  756dd7ecceed8dc23430a5c36462c36c4244fa46 (commit)
      from  e0e9e2798cc4983bdf05a443ee0c3d64020e4da6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/include/prototype.h |    1 +
 gschem/src/x_grid.c        |  119 +++++++++++++++++++++++++++++++++++---------
 2 files changed, 96 insertions(+), 24 deletions(-)


=================
 Commit Messages
=================

commit 52df0d861e880e019c7aeea71f1ed448bbed47db
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Dec 26 00:18:13 2008 +0000

    gschem: Move update of status bar information out of the grid drawing code.
    
    For now, and in the absence of any better place to hook, just trigger this
    update explicitly when we pan or alter the grid settings.

:100644 100644 12f29bd... c0f9add... M	gschem/src/x_grid.c

commit 756dd7ecceed8dc23430a5c36462c36c4244fa46
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Thu Dec 25 23:57:57 2008 +0000

    gschem: New helper function to query rendered grid spacing.
    
    The status bar contains an label which lists the current rendered grid
    spacing. We should not be forcing an update of this each time we repaint
    a portion of the grid. Introduce a helper function to ask the grid code
    what size it would end up drawing. This will then allow us to query the
    rendered grid size after zoom / grid settings changes, and update there.

:100644 100644 380beec... cfba290... M	gschem/include/prototype.h
:100644 100644 4406a7a... 12f29bd... M	gschem/src/x_grid.c

=========
 Changes
=========

commit 52df0d861e880e019c7aeea71f1ed448bbed47db
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Dec 26 00:18:13 2008 +0000

    gschem: Move update of status bar information out of the grid drawing code.
    
    For now, and in the absence of any better place to hook, just trigger this
    update explicitly when we pan or alter the grid settings.

diff --git a/gschem/src/x_grid.c b/gschem/src/x_grid.c
index 12f29bd..c0f9add 100644
--- a/gschem/src/x_grid.c
+++ b/gschem/src/x_grid.c
@@ -102,9 +102,6 @@ static void draw_dots_grid_region (GSCHEM_TOPLEVEL *w_current,
   if (incr == -1)
     return;
 
-  /* update status bar */
-  i_set_grid (w_current, incr);
-
   gdk_gc_set_foreground (w_current->gc, x_get_color (DOTS_GRID_COLOR));
 
   SCREENtoWORLD (toplevel, x - 1, y + height + 1, &x_start, &y_start);
@@ -263,9 +260,6 @@ static void draw_mesh_grid_region (GSCHEM_TOPLEVEL *w_current,
   incr = toplevel->snap_size;
   screen_incr = SCREENabs (toplevel, incr);
 
-  /* update status bar */
-  i_set_grid (w_current, incr);
-
   SCREENtoWORLD (toplevel, x - 1, y + height + 1, &x_start, &y_start);
   SCREENtoWORLD (toplevel, x + width + 1, y - 1, &x_end, &y_end);
 
@@ -302,7 +296,6 @@ void x_grid_draw_region (GSCHEM_TOPLEVEL *w_current,
 {
   switch (w_current->grid) {
     case GRID_NONE:
-      i_set_grid(w_current, -1);
       return;
 
     case GRID_DOTS:

commit 756dd7ecceed8dc23430a5c36462c36c4244fa46
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Thu Dec 25 23:57:57 2008 +0000

    gschem: New helper function to query rendered grid spacing.
    
    The status bar contains an label which lists the current rendered grid
    spacing. We should not be forcing an update of this each time we repaint
    a portion of the grid. Introduce a helper function to ask the grid code
    what size it would end up drawing. This will then allow us to query the
    rendered grid size after zoom / grid settings changes, and update there.

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 380beec..cfba290 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -779,6 +779,7 @@ void x_fileselect_save(GSCHEM_TOPLEVEL *w_current);
 int x_fileselect_load_backup(TOPLEVEL *toplevel, GString *message);
 /* x_grid.c */
 void x_grid_draw_region(GSCHEM_TOPLEVEL *w_current, int x, int y, int width, int height);
+int x_grid_query_drawn_spacing(GSCHEM_TOPLEVEL *w_current);
 void x_draw_tiles(GSCHEM_TOPLEVEL *w_current);
 /* x_image.c */
 void x_image_lowlevel(GSCHEM_TOPLEVEL *w_current, const char* filename,
diff --git a/gschem/src/x_grid.c b/gschem/src/x_grid.c
index 4406a7a..12f29bd 100644
--- a/gschem/src/x_grid.c
+++ b/gschem/src/x_grid.c
@@ -36,29 +36,21 @@
 #define MESH_COARSE_GRID_MULTIPLIER  5
 
 
-/*! \brief Draw an area of the screen with a dotted grid pattern
+/*! \brief Query the spacing in world coordinates at which the dots grid is drawn.
  *
  *  \par Function Description
- *  Draws the dotted grid pattern over a given region of the screen.
+ *  Returns the world spacing of the rendered grid, taking into account where
+ *  the grid drawing code may drop elelments which are too densly packed for a
+ *  given zoom level.
  *
  *  \param [in] w_current  The GSCHEM_TOPLEVEL.
- *  \param [in] x          The left screen coordinate for the drawing.
- *  \param [in] y          The top screen coordinate for the drawing.
- *  \param [in] width      The width of the region to draw.
- *  \param [in] height     The height of the region to draw.
+ *  \returns The grid spacing in world units of the grid as rendered, or -1
+ *           if there are no items drawn.
  */
-static void draw_dots_grid_region (GSCHEM_TOPLEVEL *w_current,
-                                   int x, int y, int width, int height)
+static int query_dots_grid_spacing (GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int i, j;
-  int dot_x, dot_y;
-  int x_start, y_start, x_end, y_end;
-  int count = 0;
-  GdkPoint points[DOTS_POINTS_ARRAY_SIZE];
-
-  int incr;
-  int screen_incr;
+  int incr, screen_incr;
 
   if (w_current->dots_grid_mode == DOTS_GRID_VARIABLE_MODE) {
     /* In the variable mode around every (DOTS_VARIABLE_MODE_SPACING)'th
@@ -76,10 +68,39 @@ static void draw_dots_grid_region (GSCHEM_TOPLEVEL *w_current,
     incr = toplevel->snap_size;
     screen_incr = SCREENabs (toplevel, incr);
     if (screen_incr < w_current->dots_grid_fixed_threshold) {
-      /* don't draw the grid if the on-screen spacing is less than the threshold */
-      return;
+      /* No grid drawn if the on-screen spacing is less than the threshold */
+      incr = -1;
     }
   }
+  return incr;
+}
+
+
+/*! \brief Draw an area of the screen with a dotted grid pattern
+ *
+ *  \par Function Description
+ *  Draws the dotted grid pattern over a given region of the screen.
+ *
+ *  \param [in] w_current  The GSCHEM_TOPLEVEL.
+ *  \param [in] x          The left screen coordinate for the drawing.
+ *  \param [in] y          The top screen coordinate for the drawing.
+ *  \param [in] width      The width of the region to draw.
+ *  \param [in] height     The height of the region to draw.
+ */
+static void draw_dots_grid_region (GSCHEM_TOPLEVEL *w_current,
+                                   int x, int y, int width, int height)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int i, j;
+  int dot_x, dot_y;
+  int x_start, y_start, x_end, y_end;
+  int count = 0;
+  GdkPoint points[DOTS_POINTS_ARRAY_SIZE];
+
+  int incr = query_dots_grid_spacing (w_current);
+
+  if (incr == -1)
+    return;
 
   /* update status bar */
   i_set_grid (w_current, incr);
@@ -186,6 +207,40 @@ static void draw_mesh (GSCHEM_TOPLEVEL *w_current, int color,
 }
 
 
+/*! \brief Query the spacing in world coordinates at which the mesh grid is drawn.
+ *
+ *  \par Function Description
+ *  Returns the world spacing of the rendered grid, taking into account where
+ *  the grid drawing code may drop elelments which are too densly packed for a
+ *  given zoom level.
+ *
+ *  \param [in] w_current  The GSCHEM_TOPLEVEL.
+ *  \returns The grid spacing in world units of the grid as rendered, or -1
+ *           if there are no items drawn.
+ */
+static int query_mesh_grid_spacing (GSCHEM_TOPLEVEL *w_current)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int incr, screen_incr;
+
+  incr = toplevel->snap_size;
+  screen_incr = SCREENabs (toplevel, incr);
+
+  /* We draw a fine grid if its on-screen spacing is large enough */
+  if (screen_incr >= w_current->mesh_grid_display_threshold) {
+    return incr;
+  }
+
+  incr *= MESH_COARSE_GRID_MULTIPLIER;
+  screen_incr = SCREENabs (toplevel, incr);
+
+  /* We draw a coarse grid if its on-screen spacing is large enough */
+  if (screen_incr >= w_current->mesh_grid_display_threshold)
+    return incr;
+
+  return -1;
+}
+
 /*! \brief Draw an area of the screen with a mesh grid pattern
  *
  *  \par Function Description
@@ -265,6 +320,29 @@ void x_grid_draw_region (GSCHEM_TOPLEVEL *w_current,
 #endif
 }
 
+
+/*! \brief Query the spacing in world coordinates at which the grid is drawn.
+ *
+ *  \par Function Description
+ *  Returns the world spacing of the rendered grid, taking into account where
+ *  the grid drawing code may drop elelments which are too densly packed for a
+ *  given zoom level.
+ *
+ *  \param [in] w_current  The GSCHEM_TOPLEVEL.
+ *  \returns The grid spacing in world units of the grid as rendered, or -1
+ *           if there are no items drawn.
+ */
+int x_grid_query_drawn_spacing (GSCHEM_TOPLEVEL *w_current)
+{
+  switch (w_current->grid) {
+    default:
+    case GRID_NONE: return -1;
+    case GRID_DOTS: return query_dots_grid_spacing (w_current);
+    case GRID_MESH: return query_mesh_grid_spacing (w_current);
+  }
+}
+
+
 /*! \todo Finish function documentation!!!
  *  \brief
  *  \par Function Description




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs