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

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



The branch, master has been updated
       via  f5423195c8dcd95e028cb5ee6776eb4e58b46e37 (commit)
      from  39ca0bda4ffc59f592d48b64c866ed6a856ed356 (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       |   24 +++++++++++++-----------
 src/hid/gtk/gui-output-events.c |   25 +++++++++++++------------
 src/hid/gtk/gui.h               |    7 ++++---
 3 files changed, 30 insertions(+), 26 deletions(-)


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

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

    hid/gtk: Refactor semantics of, and rename view_x, view_y coordinates
    
    Rather than storing pointer coordinates in the imaginary "view" system,
    where the coordinates (in PCB base units) represent that of an unflipped
    board, store them such that they are directly meaningful on the board.
    
    As they now directly represent the cursor coordinats on the actual board,
    they don't require passing through the SIDE_{X,Y} macros before use with
    APIs that expect board coordinates.
    
    To avoid confusion, view_x and view_y have been renamed to pcb_x and pcb_y
    to reflect the change of semantics.
    
    In a number of cases, SIDE_{X,Y} macro calls were added to preserve
    correct functionality of old code which manipulates the mouse position in
    "view" coordinates. These are primarily concerned with zooming and panning.
    
    Also rename the confusingly titled VIEW_{X,Y} macros to EVENT_TO_PCB_{X,Y}

:100644 100644 a3c3d29... 8500f6a... M	src/hid/gtk/gtkhid-main.c
:100644 100644 abf8f53... 1a10251... M	src/hid/gtk/gui-output-events.c
:100644 100644 1253511... 29a5407... M	src/hid/gtk/gui.h

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

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

    hid/gtk: Refactor semantics of, and rename view_x, view_y coordinates
    
    Rather than storing pointer coordinates in the imaginary "view" system,
    where the coordinates (in PCB base units) represent that of an unflipped
    board, store them such that they are directly meaningful on the board.
    
    As they now directly represent the cursor coordinats on the actual board,
    they don't require passing through the SIDE_{X,Y} macros before use with
    APIs that expect board coordinates.
    
    To avoid confusion, view_x and view_y have been renamed to pcb_x and pcb_y
    to reflect the change of semantics.
    
    In a number of cases, SIDE_{X,Y} macro calls were added to preserve
    correct functionality of old code which manipulates the mouse position in
    "view" coordinates. These are primarily concerned with zooming and panning.
    
    Also rename the confusingly titled VIEW_{X,Y} macros to EVENT_TO_PCB_{X,Y}

diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index a3c3d29..8500f6a 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -241,28 +241,30 @@ zoom_to (double new_zoom, int x, int y)
       gdouble xtmp, ytmp;
       gint x0, y0;
 
-      xtmp = (gport->view_x - gport->view_x0) / (gdouble) gport->view_width;
-      ytmp = (gport->view_y - gport->view_y0) / (gdouble) gport->view_height;
-      
+      xtmp = (SIDE_X (gport->pcb_x) - gport->view_x0) /
+                (gdouble) gport->view_width;
+      ytmp = (SIDE_Y (gport->pcb_y) - gport->view_y0) /
+                (gdouble) gport->view_height;
+
       gport->zoom = new_zoom;
       pixel_slop = new_zoom;
       ghid_port_ranges_scale(FALSE);
 
-      x0 = gport->view_x - xtmp * gport->view_width;
+      x0 = SIDE_X (gport->pcb_x) - xtmp * gport->view_width;
       if (x0 < 0)
-	x0 = 0;
+        x0 = 0;
       gport->view_x0 = x0;
 
-      y0 = gport->view_y - ytmp * gport->view_height;
+      y0 = SIDE_Y (gport->pcb_y) - ytmp * gport->view_height;
       if (y0 < 0)
-	y0 = 0;
+        y0 = 0;
       gport->view_y0 = y0;
-      
+
       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();
     }
 
@@ -1516,12 +1518,12 @@ SwapSides (int argc, char **argv, int x, int y)
      location */
   if (do_flip_x)
     {
-	flipd = PCB->MaxWidth / 2 - gport->view_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 - gport->view_y;
+	flipd = PCB->MaxHeight / 2 - SIDE_Y (gport->pcb_y);
 	ghid_port_ranges_pan (0, 2 * flipd, TRUE);
     }
 
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index abf8f53..1a10251 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -166,19 +166,21 @@ ghid_port_ranges_zoom (gdouble zoom)
   if ((zoom > xtmp && zoom > ytmp) || zoom == 0.0)
     zoom = (xtmp > ytmp) ? xtmp : ytmp;
 
-  xtmp = (gport->view_x - gport->view_x0) / (gdouble) gport->view_width;
-  ytmp = (gport->view_y - gport->view_y0) / (gdouble) gport->view_height;
+  xtmp = (SIDE_X (gport->pcb_x) - gport->view_x0) /
+            (gdouble) gport->view_width;
+  ytmp = (SIDE_Y (gport->pcb_y) - gport->view_y0) /
+            (gdouble) gport->view_height;
 
   gport->zoom = zoom;
   pixel_slop = zoom;
   ghid_port_ranges_scale(FALSE);
 
-  x0 = gport->view_x - xtmp * gport->view_width;
+  x0 = SIDE_X (gport->pcb_x) - xtmp * gport->view_width;
   if (x0 < 0)
     x0 = 0;
   gport->view_x0 = x0;
 
-  y0 = gport->view_y - ytmp * gport->view_height;
+  y0 = SIDE_Y (gport->pcb_y) - ytmp * gport->view_height;
   if (y0 < 0)
     y0 = 0;
   gport->view_y0 = y0;
@@ -203,8 +205,8 @@ ghid_get_coords (const char *msg, int *x, int *y)
     ghid_get_user_xy (msg);
   if (ghid_port.has_entered)
     {
-      *x = SIDE_X (gport->view_x);
-      *y = SIDE_Y (gport->view_y);
+      *x = gport->pcb_x;
+      *y = gport->pcb_y;
     }
 }
 
@@ -224,11 +226,10 @@ ghid_note_event_location (GdkEventButton * ev)
       event_x = ev->x;
       event_y = ev->y;
     }
-  gport->view_x = event_x * gport->zoom + gport->view_x0;
-  gport->view_y = event_y * gport->zoom + gport->view_y0;
+  gport->pcb_x = EVENT_TO_PCB_X (event_x);
+  gport->pcb_y = EVENT_TO_PCB_Y (event_y);
 
-  moved = MoveCrosshairAbsolute (SIDE_X (gport->view_x), 
-				 SIDE_Y (gport->view_y));
+  moved = MoveCrosshairAbsolute (gport->pcb_x, gport->pcb_y);
   if (moved)
     {
       AdjustAttachedObjects ();
@@ -736,8 +737,8 @@ ghid_port_window_leave_cb (GtkWidget * widget,
 	  w = ghid_port.width * gport->zoom;
 	  h = ghid_port.height * gport->zoom;
 
-	  x0 = VIEW_X (0);
-	  y0 = VIEW_Y (0);
+	  x0 = EVENT_TO_PCB_X (0);
+	  y0 = EVENT_TO_PCB_Y (0);
 	  ghid_get_coords (NULL, &x, &y);
 	  x -= x0;
 	  y -= y0;
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 1253511..29a5407 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -68,8 +68,8 @@ extern int ghid_flip_x, ghid_flip_y;
 #define	DRAW_X(x)	(gint)((SIDE_X(x) - gport->view_x0) / gport->zoom)
 #define	DRAW_Y(y)	(gint)((SIDE_Y(y) - gport->view_y0) / gport->zoom)
 
-#define	VIEW_X(x)	SIDE_X((gint)((x) * gport->zoom + gport->view_x0))
-#define	VIEW_Y(y)	SIDE_Y((gint)((y) * gport->zoom + gport->view_y0))
+#define	EVENT_TO_PCB_X(x)	SIDE_X((gint)((x) * gport->zoom + gport->view_x0))
+#define	EVENT_TO_PCB_Y(y)	SIDE_Y((gint)((y) * gport->zoom + gport->view_y0))
 
 /*
  * Used to intercept "special" hotkeys that gtk doesn't usually pass
@@ -177,7 +177,8 @@ typedef struct
   gdouble zoom;			/* PCB units per screen pixel.  Larger */
   /* numbers mean zooming out. */
   gint view_x0,			/* Viewport in PCB coordinates */
-    view_y0, view_width, view_height, view_x, view_y;
+    view_y0, view_width, view_height;
+  Coord pcb_x, pcb_y;
 
   gint crosshair_x, crosshair_y;
 }




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