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

gEDA-cvs: pcb.git: branch: master updated (2c25ce33e7abfaa4f7710abebd620e70fa0e8cd1)



The branch, master has been updated
       via  2c25ce33e7abfaa4f7710abebd620e70fa0e8cd1 (commit)
       via  2b803a8419fbeacc623cc51f4765b141033119de (commit)
       via  f903b4be6b85efc110852f7be40edf8245f0a513 (commit)
      from  db8eb1a6f73366ac920f19dc25f98c7196a97016 (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
=========

 src/hid/gtk/gtkhid-main.c |  261 ++++++++++++++++++++-------------------------
 src/hid/gtk/gui.h         |    3 +-
 2 files changed, 116 insertions(+), 148 deletions(-)


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

commit 2c25ce33e7abfaa4f7710abebd620e70fa0e8cd1
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Rework view flip code

:100644 100644 2baf935... 27ceeb9... M	src/hid/gtk/gtkhid-main.c

commit 2b803a8419fbeacc623cc51f4765b141033119de
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Rework zoom / pan API

:100644 100644 d7549ca... 2baf935... M	src/hid/gtk/gtkhid-main.c
:100644 100644 752c184... 7c0ffb5... M	src/hid/gtk/gui.h

commit f903b4be6b85efc110852f7be40edf8245f0a513
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Some NOOP and whitespace changes to the SwapSides() function
    
    Split from of a later patch which reworks the view flipping APIs.
    Hopefully this makes the function a little simpler.

:100644 100644 68775c1... d7549ca... M	src/hid/gtk/gtkhid-main.c

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

commit 2c25ce33e7abfaa4f7710abebd620e70fa0e8cd1
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Rework view flip code

diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 2baf935..27ceeb9 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -122,6 +122,23 @@ ghid_zoom_view_fit (void)
                                  PCB->MaxHeight / gport->height));
 }
 
+static void
+ghid_flip_view (Coord center_x, Coord center_y, bool flip_x, bool flip_y)
+{
+  int widget_x, widget_y;
+
+  /* Work out where on the screen the flip point is */
+  ghid_pcb_to_event_coords (center_x, center_y, &widget_x, &widget_y);
+
+  ghid_flip_x = ghid_flip_x != flip_x;
+  ghid_flip_y = ghid_flip_y != flip_y;
+
+  /* Pan the board so the center location remains in the same place */
+  ghid_pan_view_abs (center_x, center_y, widget_x, widget_y);
+
+  ghid_invalidate_all ();
+}
+
 /* ------------------------------------------------------------ */
 
 static const char zoom_syntax[] =
@@ -1350,9 +1367,6 @@ side'' of the board.
 static int
 SwapSides (int argc, char **argv, Coord x, Coord y)
 {
-  gint flipd;
-  int do_flip_x = 0;
-  int do_flip_y = 0;
   int active_group = GetLayerGroupNumberByNumber (LayerStack[0]);
   int comp_group = GetLayerGroupNumberByNumber (component_silk_layer);
   int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer);
@@ -1364,26 +1378,20 @@ SwapSides (int argc, char **argv, Coord x, Coord y)
       switch (argv[0][0]) {
         case 'h':
         case 'H':
-          ghid_flip_x = ! ghid_flip_x;
-          do_flip_x = 1;
+          ghid_flip_view (gport->pcb_x, gport->pcb_y, true, false);
           break;
         case 'v':
         case 'V':
-          ghid_flip_y = ! ghid_flip_y;
-          do_flip_y = 1;
+          ghid_flip_view (gport->pcb_x, gport->pcb_y, false, true);
           break;
         case 'r':
         case 'R':
-          ghid_flip_x = ! ghid_flip_x;
-          ghid_flip_y = ! ghid_flip_y;
-          do_flip_x = 1;
-          do_flip_y = 1;
+          ghid_flip_view (gport->pcb_x, gport->pcb_y, true, true);
+          Settings.ShowSolderSide = !Settings.ShowSolderSide; /* Swapped back below */
           break;
         default:
           return 1;
       }
-      /* SwapSides will swap this */
-      Settings.ShowSolderSide = (ghid_flip_x == ghid_flip_y);
     }
 
   Settings.ShowSolderSide = !Settings.ShowSolderSide;
@@ -1399,22 +1407,6 @@ SwapSides (int argc, char **argv, Coord x, Coord y)
                              !new_comp_vis, !new_comp_vis);
     }
 
-  /* Update coordinates so that the current location stays where it was on the
-     other side; we need to do this since the actual flip center is the
-     center of the board while the user expect the center would be the current
-     location */
-  if (do_flip_x)
-    {
-	flipd = PCB->MaxWidth / 2 - SIDE_X (gport->pcb_x);
-	ghid_port_ranges_pan (-2 * flipd, 0, TRUE);
-    }
-  if (do_flip_y)
-    {
-	flipd = PCB->MaxHeight / 2 - SIDE_Y (gport->pcb_y);
-	ghid_port_ranges_pan (0, -2 * flipd, TRUE);
-    }
-
-  ghid_invalidate_all ();
   return 0;
 }
 

commit 2b803a8419fbeacc623cc51f4765b141033119de
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Rework zoom / pan API

diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index d7549ca..2baf935 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -30,16 +30,15 @@
 RCSID ("$Id$");
 
 
-static void zoom_to (double factor, Coord x, Coord y);
-static void zoom_by (double factor, Coord x, Coord y);
-static void zoom_fit (void);
+bool ghid_flip_x = false, ghid_flip_y = false;
 
-int ghid_flip_x = 0, ghid_flip_y = 0;
+static void ghid_zoom_view_fit (void);
 
-
-void
-ghid_pan_fixup ()
+static void
+ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
 {
+  gport->view_x0 = MAX (0, SIDE_X (pcb_x) - widget_x * gport->zoom);
+  gport->view_y0 = MAX (0, SIDE_Y (pcb_y) - widget_y * gport->zoom);
 
   /* Don't pan so far to the right or bottom that we see past the board edge */
   gport->view_x0 = MIN (gport->view_x0, PCB->MaxWidth  - gport->view_width);
@@ -53,7 +52,7 @@ ghid_pan_fixup ()
   if (gport->view_width  > PCB->MaxWidth  &&
       gport->view_height > PCB->MaxHeight)
     {
-      zoom_fit ();
+      ghid_zoom_view_fit ();
       return;
     }
 
@@ -65,6 +64,64 @@ ghid_pan_fixup ()
   ghid_port_ranges_changed();
 }
 
+
+/* gport->zoom:
+ * zoom value is PCB units per screen pixel.  Larger numbers mean zooming
+ * out - the largest value means you are looking at the whole board.
+ *
+ * gport->view_width and gport->view_height are in PCB coordinates
+ */
+
+static void
+ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
+{
+  double min_zoom, max_zoom;
+  double xtmp, ytmp;
+
+  /* Limit the "minimum" zoom constant (maximum zoom), at 1 pixel per PCB
+   * unit, and set the "maximum" zoom constant (minimum zoom), such that
+   * the entire board just fits inside the viewport
+   */
+  min_zoom = 1;
+  max_zoom = MAX (PCB->MaxWidth  / gport->width,
+                  PCB->MaxHeight / gport->height);
+  new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom);
+
+  if (gport->zoom == new_zoom)
+    return;
+
+  xtmp = (SIDE_X (center_x) - gport->view_x0) / (double)gport->view_width;
+  ytmp = (SIDE_Y (center_y) - gport->view_y0) / (double)gport->view_height;
+
+  gport->zoom = new_zoom;
+  pixel_slop = new_zoom;
+  ghid_port_ranges_scale (FALSE);
+
+  gport->view_x0 = MAX (0, SIDE_X (center_x) - xtmp * gport->view_width);
+  gport->view_y0 = MAX (0, SIDE_Y (center_y) - ytmp * gport->view_height);
+
+  ghidgui->adjustment_changed_holdoff = TRUE;
+  gtk_range_set_value (GTK_RANGE (ghidgui->h_range), gport->view_x0);
+  gtk_range_set_value (GTK_RANGE (ghidgui->v_range), gport->view_y0);
+  ghidgui->adjustment_changed_holdoff = FALSE;
+
+  ghid_port_ranges_changed ();
+  ghid_set_status_line_label ();
+}
+
+static void
+ghid_zoom_view_rel (Coord center_x, Coord center_y, double factor)
+{
+  ghid_zoom_view_abs (center_x, center_y, gport->zoom * factor);
+}
+
+static void
+ghid_zoom_view_fit (void)
+{
+  ghid_zoom_view_abs (0, 0, MAX (PCB->MaxWidth  / gport->width,
+                                 PCB->MaxHeight / gport->height));
+}
+
 /* ------------------------------------------------------------ */
 
 static const char zoom_syntax[] =
@@ -124,7 +181,7 @@ Zoom (int argc, char **argv, Coord x, Coord y)
 
   if (argc < 1)
     {
-      zoom_fit ();
+      ghid_zoom_view_fit ();
       return 0;
     }
 
@@ -137,81 +194,20 @@ Zoom (int argc, char **argv, Coord x, Coord y)
   switch (argv[0][0])
     {
     case '-':
-      zoom_by (1 / v, x, y);
+      ghid_zoom_view_rel (x, y, 1 / v);
       break;
     default:
     case '+':
-      zoom_by (v, x, y);
+      ghid_zoom_view_rel (x, y, v);
       break;
     case '=':
-      /* this needs to set the scale factor absolutely*/
-      zoom_to (v, x, y);
+      ghid_zoom_view_abs (x, y, v);
       break;
     }
 
   return 0;
 }
 
-
-static void
-zoom_to (double new_zoom, Coord x, Coord y)
-{
-  double min_zoom, max_zoom;
-  double xtmp, ytmp;
-
-  /* gport->zoom:
-   * zoom value is PCB units per screen pixel.  Larger numbers mean zooming
-   * out - the largest value means you are looking at the whole board.
-   *
-   * gport->view_width and gport->view_height are in PCB coordinates
-   */
-
-  /* Set the "minimum" zoom constant (maximum zoom),
-   * at 1 pixel per PCB unit */
-  min_zoom = 1;
-
-  /* Set the "maximum" zoom constant (minimum zoom),
-   * to make the entire board just fit inside the viewport */
-  max_zoom = MAX (PCB->MaxWidth  / gport->width,
-                  PCB->MaxHeight / gport->height);
-
-  new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom);
-
-  if (gport->zoom == new_zoom)
-    return;
-
-  xtmp = (SIDE_X (x) - gport->view_x0) / (double)gport->view_width;
-  ytmp = (SIDE_Y (y) - gport->view_y0) / (double)gport->view_height;
-
-  gport->zoom = new_zoom;
-  pixel_slop = new_zoom;
-  ghid_port_ranges_scale (FALSE);
-
-  gport->view_x0 = MAX (0, SIDE_X (x) - xtmp * gport->view_width);
-  gport->view_y0 = MAX (0, SIDE_Y (y) - ytmp * gport->view_height);
-
-  ghidgui->adjustment_changed_holdoff = TRUE;
-  gtk_range_set_value (GTK_RANGE (ghidgui->h_range), gport->view_x0);
-  gtk_range_set_value (GTK_RANGE (ghidgui->v_range), gport->view_y0);
-  ghidgui->adjustment_changed_holdoff = FALSE;
-
-  ghid_port_ranges_changed ();
-  ghid_set_status_line_label ();
-}
-
-static void
-zoom_by (double factor, Coord x, Coord y)
-{
-  zoom_to (gport->zoom * factor, x, y);
-}
-
-static void
-zoom_fit (void)
-{
-  zoom_to (MAX (PCB->MaxWidth  / gport->width,
-                PCB->MaxHeight / gport->height), 0, 0);
-}
-
 /* ------------------------------------------------------------ */
 
 void
@@ -320,11 +316,7 @@ ghid_set_crosshair (int x, int y, int action)
       widget_y = pointer_y - offset_y;
 
       ghid_event_to_pcb_coords (widget_x, widget_y, &pcb_x, &pcb_y);
-
-      gport->view_x0 = MAX (0, SIDE_X (pcb_x) - widget_x * gport->zoom);
-      gport->view_y0 = MAX (0, SIDE_Y (pcb_y) - widget_y * gport->zoom);
-
-      ghid_pan_fixup ();
+      ghid_pan_view_abs (pcb_x, pcb_y, widget_x, widget_y);
 
       /* Just in case we couldn't pan the board the whole way,
        * we warp the pointer to where the crosshair DID land.
@@ -1145,7 +1137,7 @@ PCBChanged (int argc, char **argv, Coord x, Coord y)
   RouteStylesChanged (0, NULL, 0, 0);
   ghid_port_ranges_scale (TRUE);
   ghid_port_ranges_pan (0, 0, FALSE);
-  zoom_fit ();
+  ghid_zoom_view_fit ();
   ghid_port_ranges_changed ();
   ghid_sync_with_new_layout ();
   return 0;
@@ -1590,10 +1582,7 @@ Center(int argc, char **argv, Coord pcb_x, Coord pcb_y)
   widget_x = gport->width / 2;
   widget_y = gport->height / 2;
 
-  gport->view_x0 = MAX (0, SIDE_X (pcb_x) - widget_x * gport->zoom);
-  gport->view_y0 = MAX (0, SIDE_Y (pcb_y) - widget_y * gport->zoom);
-
-  ghid_pan_fixup ();
+  ghid_pan_view_abs (pcb_x, pcb_y, widget_x, widget_y);
 
   /* Now move the mouse pointer to the place where the board location
    * actually ended up.
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 752c184..7c0ffb5 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -62,7 +62,7 @@
 #define	FROM_PCB_UNITS(v)	coord_to_unit (Settings.grid_unit, v)
 #define	TO_PCB_UNITS(v)		unit_to_coord (Settings.grid_unit, v)
 
-extern int ghid_flip_x, ghid_flip_y;
+extern bool ghid_flip_x, ghid_flip_y;
 #define SIDE_X(x)   ((ghid_flip_x ? PCB->MaxWidth - (x) : (x)))
 #define SIDE_Y(y)   ((ghid_flip_y ? PCB->MaxHeight - (y) : (y)))
 
@@ -506,7 +506,6 @@ void ghid_lead_user_to_location (Coord x, Coord y);
 void ghid_cancel_lead_user (void);
 
 /* gtkhid-main.c */
-void ghid_pan_fixup (void);
 void ghid_get_coords (const char *msg, Coord *x, Coord *y);
 gint PCBChanged (int argc, char **argv, Coord x, Coord y);
 

commit f903b4be6b85efc110852f7be40edf8245f0a513
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Some NOOP and whitespace changes to the SwapSides() function
    
    Split from of a later patch which reworks the view flipping APIs.
    Hopefully this makes the function a little simpler.

diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 68775c1..d7549ca 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1361,62 +1361,50 @@ SwapSides (int argc, char **argv, Coord x, Coord y)
   gint flipd;
   int do_flip_x = 0;
   int do_flip_y = 0;
+  int active_group = GetLayerGroupNumberByNumber (LayerStack[0]);
   int comp_group = GetLayerGroupNumberByNumber (component_silk_layer);
   int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer);
-  int active_group = GetLayerGroupNumberByNumber (LayerStack[0]);
-  int comp_showing =
-    PCB->Data->Layer[PCB->LayerGroups.Entries[comp_group][0]].On;
-  int solder_showing =
-    PCB->Data->Layer[PCB->LayerGroups.Entries[solder_group][0]].On;
-
+  bool comp_on = LAYER_PTR (PCB->LayerGroups.Entries[comp_group][0])->On;
+  bool solder_on = LAYER_PTR (PCB->LayerGroups.Entries[solder_group][0])->On;
 
   if (argc > 0)
     {
       switch (argv[0][0]) {
-      case 'h':
-      case 'H':
-	ghid_flip_x = ! ghid_flip_x;
-	do_flip_x = 1;
-	break;
-      case 'v':
-      case 'V':
-	ghid_flip_y = ! ghid_flip_y;
-	do_flip_y = 1;
-	break;
-      case 'r':
-      case 'R':
-	ghid_flip_x = ! ghid_flip_x;
-	ghid_flip_y = ! ghid_flip_y;
-	do_flip_x = 1;
-	do_flip_y = 1;
-	break;
-      default:
-	return 1;
+        case 'h':
+        case 'H':
+          ghid_flip_x = ! ghid_flip_x;
+          do_flip_x = 1;
+          break;
+        case 'v':
+        case 'V':
+          ghid_flip_y = ! ghid_flip_y;
+          do_flip_y = 1;
+          break;
+        case 'r':
+        case 'R':
+          ghid_flip_x = ! ghid_flip_x;
+          ghid_flip_y = ! ghid_flip_y;
+          do_flip_x = 1;
+          do_flip_y = 1;
+          break;
+        default:
+          return 1;
       }
       /* SwapSides will swap this */
       Settings.ShowSolderSide = (ghid_flip_x == ghid_flip_y);
     }
 
   Settings.ShowSolderSide = !Settings.ShowSolderSide;
-  if (Settings.ShowSolderSide)
-    {
-      if (active_group == comp_group && comp_showing && !solder_showing)
-	{
-	  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 0,
-				 0);
-	  ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 1,
-				 1);
-	}
-    }
-  else
+
+  if ((active_group == comp_group   && comp_on   && !solder_on) ||
+      (active_group == solder_group && solder_on && !comp_on))
     {
-      if (active_group == solder_group && solder_showing && !comp_showing)
-	{
-	  ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 0,
-				 0);
-	  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 1,
-				 1);
-	}
+      bool new_comp_vis = Settings.ShowSolderSide && active_group == comp_group;
+
+      ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0],
+                             new_comp_vis, new_comp_vis);
+      ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0],
+                             !new_comp_vis, !new_comp_vis);
     }
 
   /* Update coordinates so that the current location stays where it was on the




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