[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (8d1d20e9ccc256edbaceec81696eb6496f4c0ac5)
The branch, master has been updated
via 8d1d20e9ccc256edbaceec81696eb6496f4c0ac5 (commit)
via 17d90bcba9db4e96f9c49ed3871f516a8ad28d83 (commit)
from c6338c9b813787819812fa95bfacabb7088e9632 (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 | 107 ++++++++++----------------------------------
1 files changed, 25 insertions(+), 82 deletions(-)
=================
Commit Messages
=================
commit 8d1d20e9ccc256edbaceec81696eb6496f4c0ac5
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Some cleanups to the zoom_to() function
Still confusing, but at least its not the fault of the code formatting now.
:100644 100644 0f9fdea... c71e70b... M src/hid/gtk/gtkhid-main.c
commit 17d90bcba9db4e96f9c49ed3871f516a8ad28d83
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Remove old debugging code from zoom_to and zoom_by() functions
This code was adding to clutter in the functions, and appears in some
cases to be bit-rotten. (The coordinates it operated on don't appear to
be have been consistent with the current GUI code).
:100644 100644 8500f6a... 0f9fdea... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit 8d1d20e9ccc256edbaceec81696eb6496f4c0ac5
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Some cleanups to the zoom_to() function
Still confusing, but at least its not the fault of the code formatting now.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 0f9fdea..c71e70b 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -179,64 +179,46 @@ Zoom (int argc, char **argv, int x, int y)
static void
zoom_to (double new_zoom, int x, int y)
{
- double max_zoom;
+ 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.
*
- * PCB units per screen pixel
- *
* gport->view_width and gport->view_height are in PCB coordinates
*/
- /* Find the zoom that would just make the entire board fit */
- max_zoom = PCB->MaxWidth / gport->width;
- if (max_zoom < PCB->MaxHeight / gport->height)
- max_zoom = PCB->MaxHeight / gport->height;
+ /* Set the "minimum" zoom constant (maximum zoom),
+ * at 1 pixel per PCB unit */
+ min_zoom = 1;
- /*
- * clip the zooming so we can never have more than 1 pixel per PCB
- * unit and never zoom out more than viewing the entire board
- */
-
- if (new_zoom < 1)
- new_zoom = 1;
- if (new_zoom > max_zoom)
- new_zoom = max_zoom;
+ /* 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);
- if (gport->zoom != new_zoom)
- {
- gdouble xtmp, ytmp;
- gint x0, y0;
-
- 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 = SIDE_X (gport->pcb_x) - xtmp * gport->view_width;
- if (x0 < 0)
- x0 = 0;
- gport->view_x0 = x0;
-
- y0 = SIDE_Y (gport->pcb_y) - ytmp * gport->view_height;
- if (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();
- }
+ new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom);
+
+ if (gport->zoom == new_zoom)
+ return;
+
+ xtmp = (SIDE_X (gport->pcb_x) - gport->view_x0) / (double)gport->view_width;
+ ytmp = (SIDE_Y (gport->pcb_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 (gport->pcb_x) - xtmp * gport->view_width);
+ gport->view_y0 = MAX (0, SIDE_Y (gport->pcb_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 ();
}
commit 17d90bcba9db4e96f9c49ed3871f516a8ad28d83
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/gtk: Remove old debugging code from zoom_to and zoom_by() functions
This code was adding to clutter in the functions, and appears in some
cases to be bit-rotten. (The coordinates it operated on don't appear to
be have been consistent with the current GUI code).
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 8500f6a..0f9fdea 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -179,10 +179,7 @@ Zoom (int argc, char **argv, int x, int y)
static void
zoom_to (double new_zoom, int x, int y)
{
- double max_zoom, xfrac, yfrac;
-#ifdef DEBUG
- int cx, cy;
-#endif
+ double max_zoom;
/* gport->zoom:
* zoom value is PCB units per screen pixel. Larger numbers mean zooming
@@ -193,27 +190,11 @@ zoom_to (double new_zoom, int x, int y)
* gport->view_width and gport->view_height are in PCB coordinates
*/
-#ifdef DEBUG
- pcb_printf ("\nzoom_to( %g, %#mS, %#mS)\n", new_zoom, x, y);
-#endif
-
- xfrac = (double) x / (double) gport->view_width;
- yfrac = (double) y / (double) gport->view_height;
-
- if (ghid_flip_x)
- xfrac = 1-xfrac;
- if (ghid_flip_y)
- yfrac = 1-yfrac;
-
/* Find the zoom that would just make the entire board fit */
max_zoom = PCB->MaxWidth / gport->width;
if (max_zoom < PCB->MaxHeight / gport->height)
max_zoom = PCB->MaxHeight / gport->height;
-#ifdef DEBUG
- printf ("zoom_to(): max_zoom = %g\n", max_zoom);
-#endif
-
/*
* clip the zooming so we can never have more than 1 pixel per PCB
* unit and never zoom out more than viewing the entire board
@@ -224,18 +205,6 @@ zoom_to (double new_zoom, int x, int y)
if (new_zoom > max_zoom)
new_zoom = max_zoom;
-#ifdef DEBUG
- printf ("max_zoom = %g, xfrac = %g, yfrac = %g, new_zoom = %g\n",
- max_zoom, xfrac, yfrac, new_zoom);
-
- /* find center x and y */
- cx = gport->view_x0 + gport->view_width * xfrac * gport->zoom;
- cy = gport->view_y0 + gport->view_height * yfrac * gport->zoom;
-
- pcb_printf ("zoom_to(): x0 = %#mS, cx = %#mS\n", gport->view_x0, cx);
- pcb_printf ("zoom_to(): y0 = %#mS, cy = %#mS\n", gport->view_y0, cy);
-#endif
-
if (gport->zoom != new_zoom)
{
gdouble xtmp, ytmp;
@@ -268,20 +237,12 @@ zoom_to (double new_zoom, int x, int y)
ghid_port_ranges_changed();
}
-#ifdef DEBUG
- printf ("zoom_to(): new x0 = %d\n", gport->view_x0);
- printf ("zoom_to(): new y0 = %d\n", gport->view_y0);
-#endif
ghid_set_status_line_label ();
}
void
zoom_by (double factor, int x, int y)
{
-#ifdef DEBUG
- pcb_printf ("\nzoom_by( %g, %#mS, %#mS). old gport->zoom = %g\n",
- factor, x, y, gport->zoom);
-#endif
zoom_to (gport->zoom * factor, x, y);
}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs