You can subscribe to this list here.
| 2003 |
Jan
|
Feb
(4) |
Mar
(5) |
Apr
|
May
(5) |
Jun
(30) |
Jul
(2) |
Aug
(18) |
Sep
(14) |
Oct
(7) |
Nov
(21) |
Dec
(44) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(63) |
Feb
(94) |
Mar
(54) |
Apr
(39) |
May
(34) |
Jun
(25) |
Jul
(10) |
Aug
(33) |
Sep
(16) |
Oct
(62) |
Nov
(12) |
Dec
(2) |
| 2005 |
Jan
(71) |
Feb
(8) |
Mar
(50) |
Apr
|
May
(2) |
Jun
(12) |
Jul
(19) |
Aug
(8) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(8) |
| 2006 |
Jan
(10) |
Feb
(1) |
Mar
(301) |
Apr
(232) |
May
(26) |
Jun
(20) |
Jul
(26) |
Aug
(79) |
Sep
(92) |
Oct
(174) |
Nov
(17) |
Dec
(93) |
| 2007 |
Jan
(27) |
Feb
(179) |
Mar
(37) |
Apr
(81) |
May
(20) |
Jun
(5) |
Jul
|
Aug
(40) |
Sep
(68) |
Oct
(8) |
Nov
(47) |
Dec
(34) |
| 2008 |
Jan
(154) |
Feb
(15) |
Mar
(5) |
Apr
(21) |
May
(4) |
Jun
(1) |
Jul
(4) |
Aug
(6) |
Sep
(8) |
Oct
(9) |
Nov
(35) |
Dec
(50) |
| 2009 |
Jan
(8) |
Feb
(10) |
Mar
(6) |
Apr
(9) |
May
(7) |
Jun
(40) |
Jul
(7) |
Aug
(5) |
Sep
(2) |
Oct
(16) |
Nov
(42) |
Dec
(5) |
| 2010 |
Jan
(3) |
Feb
(15) |
Mar
(32) |
Apr
(18) |
May
(6) |
Jun
(9) |
Jul
|
Aug
(11) |
Sep
(16) |
Oct
|
Nov
(4) |
Dec
(35) |
| 2011 |
Jan
(24) |
Feb
(6) |
Mar
(27) |
Apr
(119) |
May
(72) |
Jun
(20) |
Jul
(31) |
Aug
(88) |
Sep
(86) |
Oct
(14) |
Nov
(11) |
Dec
(30) |
| 2012 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <gi...@gp...> - 2011-08-27 14:39:36
|
The branch, master has been updated
discards 25af27394efe1259db8e049bac1d6fc380e0c3ee (commit)
via 112045192b260c75012499d5b15543c3dd082495 (commit)
from 25af27394efe1259db8e049bac1d6fc380e0c3ee (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-gdk.c | 156 ++++++++++++++++++++++----------------------
src/hid/gtk/gtkhid-main.c | 4 +-
2 files changed, 80 insertions(+), 80 deletions(-)
=================
Commit Messages
=================
commit 112045192b260c75012499d5b15543c3dd082495
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Encapsulate view parameters in a structure
:100644 100644 817a0fa... 631e5b7... M src/hid/gtk/gtkhid-gdk.c
:100644 100644 8c1e8a2... ea8dd40... M src/hid/gtk/gtkhid-gl.c
:100644 100644 b1af557... 8672b19... M src/hid/gtk/gtkhid-main.c
:100644 100644 81dcd45... 5929a37... M src/hid/gtk/gui-output-events.c
:100644 100644 f8674e6... e2beb3c... M src/hid/gtk/gui-top-window.c
:100644 100644 c3f00a3... ad2a112... M src/hid/gtk/gui.h
=========
Changes
=========
commit 112045192b260c75012499d5b15543c3dd082495
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Encapsulate view parameters in a structure
diff --git a/src/hid/gtk/gtkhid-gdk.c b/src/hid/gtk/gtkhid-gdk.c
index 817a0fa..631e5b7 100644
--- a/src/hid/gtk/gtkhid-gdk.c
+++ b/src/hid/gtk/gtkhid-gdk.c
@@ -172,11 +172,11 @@ ghid_draw_grid (void)
gdk_gc_set_clip_origin (priv->grid_gc, 0, 0);
set_clip (priv, priv->grid_gc);
}
- x1 = GridFit (SIDE_X (gport->view_x0), PCB->Grid, PCB->GridOffsetX);
- y1 = GridFit (SIDE_Y (gport->view_y0), PCB->Grid, PCB->GridOffsetY);
- x2 = GridFit (SIDE_X (gport->view_x0 + gport->view_width - 1),
+ x1 = GridFit (SIDE_X (gport->view.x0), PCB->Grid, PCB->GridOffsetX);
+ y1 = GridFit (SIDE_Y (gport->view.y0), PCB->Grid, PCB->GridOffsetY);
+ x2 = GridFit (SIDE_X (gport->view.x0 + gport->view.width - 1),
PCB->Grid, PCB->GridOffsetX);
- y2 = GridFit (SIDE_Y (gport->view_y0 + gport->view_height - 1),
+ y2 = GridFit (SIDE_Y (gport->view.y0 + gport->view.height - 1),
PCB->Grid, PCB->GridOffsetY);
if (x1 > x2)
{
@@ -233,10 +233,10 @@ ghid_draw_bg_image (void)
if (!ghidgui->bg_pixbuf)
return;
- w = PCB->MaxWidth / gport->zoom;
- h = PCB->MaxHeight / gport->zoom;
- x = gport->view_x0 / gport->zoom;
- y = gport->view_y0 / gport->zoom;
+ w = PCB->MaxWidth / gport->view.coord_per_px;
+ h = PCB->MaxHeight / gport->view.coord_per_px;
+ x = gport->view.x0 / gport->view.coord_per_px;
+ y = gport->view.y0 / gport->view.coord_per_px;
if (w_scaled != w || h_scaled != h)
{
@@ -529,7 +529,7 @@ ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
dy2 = Vy ((double) y2);
if (!ClipLine (0, 0, gport->width, gport->height,
- &dx1, &dy1, &dx2, &dy2, gc->width / gport->zoom))
+ &dx1, &dy1, &dx2, &dy2, gc->width / gport->view.coord_per_px))
return;
USE_GC (gc);
@@ -544,25 +544,25 @@ ghid_draw_arc (hidGC gc, Coord cx, Coord cy,
gint w, h, radius;
render_priv *priv = gport->render_priv;
- w = gport->width * gport->zoom;
- h = gport->height * gport->zoom;
+ w = gport->width * gport->view.coord_per_px;
+ h = gport->height * gport->view.coord_per_px;
radius = (xradius > yradius) ? xradius : yradius;
- if (SIDE_X (cx) < gport->view_x0 - radius
- || SIDE_X (cx) > gport->view_x0 + w + radius
- || SIDE_Y (cy) < gport->view_y0 - radius
- || SIDE_Y (cy) > gport->view_y0 + h + radius)
+ if (SIDE_X (cx) < gport->view.x0 - radius
+ || SIDE_X (cx) > gport->view.x0 + w + radius
+ || SIDE_Y (cy) < gport->view.y0 - radius
+ || SIDE_Y (cy) > gport->view.y0 + h + radius)
return;
USE_GC (gc);
vrx = Vz (xradius);
vry = Vz (yradius);
- if (ghid_flip_x)
+ if (gport->view.flip_x)
{
start_angle = 180 - start_angle;
delta_angle = -delta_angle;
}
- if (ghid_flip_y)
+ if (gport->view.flip_y)
{
start_angle = -start_angle;
delta_angle = -delta_angle;
@@ -583,17 +583,17 @@ ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
render_priv *priv = gport->render_priv;
lw = gc->width;
- w = gport->width * gport->zoom;
- h = gport->height * gport->zoom;
-
- if ((SIDE_X (x1) < gport->view_x0 - lw
- && SIDE_X (x2) < gport->view_x0 - lw)
- || (SIDE_X (x1) > gport->view_x0 + w + lw
- && SIDE_X (x2) > gport->view_x0 + w + lw)
- || (SIDE_Y (y1) < gport->view_y0 - lw
- && SIDE_Y (y2) < gport->view_y0 - lw)
- || (SIDE_Y (y1) > gport->view_y0 + h + lw
- && SIDE_Y (y2) > gport->view_y0 + h + lw))
+ w = gport->width * gport->view.coord_per_px;
+ h = gport->height * gport->view.coord_per_px;
+
+ if ((SIDE_X (x1) < gport->view.x0 - lw
+ && SIDE_X (x2) < gport->view.x0 - lw)
+ || (SIDE_X (x1) > gport->view.x0 + w + lw
+ && SIDE_X (x2) > gport->view.x0 + w + lw)
+ || (SIDE_Y (y1) < gport->view.y0 - lw
+ && SIDE_Y (y2) < gport->view.y0 - lw)
+ || (SIDE_Y (y1) > gport->view.y0 + h + lw
+ && SIDE_Y (y2) > gport->view.y0 + h + lw))
return;
x1 = Vx (x1);
@@ -626,12 +626,12 @@ ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius)
gint w, h, vr;
render_priv *priv = gport->render_priv;
- w = gport->width * gport->zoom;
- h = gport->height * gport->zoom;
- if (SIDE_X (cx) < gport->view_x0 - radius
- || SIDE_X (cx) > gport->view_x0 + w + radius
- || SIDE_Y (cy) < gport->view_y0 - radius
- || SIDE_Y (cy) > gport->view_y0 + h + radius)
+ w = gport->width * gport->view.coord_per_px;
+ h = gport->height * gport->view.coord_per_px;
+ if (SIDE_X (cx) < gport->view.x0 - radius
+ || SIDE_X (cx) > gport->view.x0 + w + radius
+ || SIDE_Y (cy) < gport->view.y0 - radius
+ || SIDE_Y (cy) > gport->view.y0 + h + radius)
return;
USE_GC (gc);
@@ -669,17 +669,17 @@ ghid_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
render_priv *priv = gport->render_priv;
lw = gc->width;
- w = gport->width * gport->zoom;
- h = gport->height * gport->zoom;
-
- if ((SIDE_X (x1) < gport->view_x0 - lw
- && SIDE_X (x2) < gport->view_x0 - lw)
- || (SIDE_X (x1) > gport->view_x0 + w + lw
- && SIDE_X (x2) > gport->view_x0 + w + lw)
- || (SIDE_Y (y1) < gport->view_y0 - lw
- && SIDE_Y (y2) < gport->view_y0 - lw)
- || (SIDE_Y (y1) > gport->view_y0 + h + lw
- && SIDE_Y (y2) > gport->view_y0 + h + lw))
+ w = gport->width * gport->view.coord_per_px;
+ h = gport->height * gport->view.coord_per_px;
+
+ if ((SIDE_X (x1) < gport->view.x0 - lw
+ && SIDE_X (x2) < gport->view.x0 - lw)
+ || (SIDE_X (x1) > gport->view.x0 + w + lw
+ && SIDE_X (x2) > gport->view.x0 + w + lw)
+ || (SIDE_Y (y1) < gport->view.y0 - lw
+ && SIDE_Y (y2) < gport->view.y0 - lw)
+ || (SIDE_Y (y1) > gport->view.y0 + h + lw
+ && SIDE_Y (y2) > gport->view.y0 + h + lw))
return;
x1 = Vx (x1);
@@ -1173,13 +1173,13 @@ ghid_pinout_preview_expose (GtkWidget *widget,
double xz, yz;
render_priv *priv = gport->render_priv;
- save_zoom = gport->zoom;
+ save_zoom = gport->view.coord_per_px;
save_width = gport->width;
save_height = gport->height;
- save_left = gport->view_x0;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
+ save_left = gport->view.x0;
+ save_top = gport->view.y0;
+ save_view_width = gport->view.width;
+ save_view_height = gport->view.height;
/* Setup drawable and zoom factor for drawing routines
*/
@@ -1189,17 +1189,17 @@ ghid_pinout_preview_expose (GtkWidget *widget,
xz = (double) pinout->x_max / da_w;
yz = (double) pinout->y_max / da_h;
if (xz > yz)
- gport->zoom = xz;
+ gport->view.coord_per_px = xz;
else
- gport->zoom = yz;
+ gport->view.coord_per_px = yz;
gport->drawable = widget->window;
gport->width = da_w;
gport->height = da_h;
- gport->view_width = da_w * gport->zoom;
- gport->view_height = da_h * gport->zoom;
- gport->view_x0 = (pinout->x_max - gport->view_width) / 2;
- gport->view_y0 = (pinout->y_max - gport->view_height) / 2;
+ gport->view.width = da_w * gport->view.coord_per_px;
+ gport->view.height = da_h * gport->view.coord_per_px;
+ gport->view.x0 = (pinout->x_max - gport->view.width) / 2;
+ gport->view.y0 = (pinout->y_max - gport->view.height) / 2;
/* clear background */
gdk_draw_rectangle (widget->window, priv->bg_gc, TRUE, 0, 0, da_w, da_h);
@@ -1208,13 +1208,13 @@ ghid_pinout_preview_expose (GtkWidget *widget,
hid_expose_callback (&ghid_hid, NULL, &pinout->element);
gport->drawable = save_drawable;
- gport->zoom = save_zoom;
+ gport->view.coord_per_px = save_zoom;
gport->width = save_width;
gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
- gport->view_width = save_view_width;
- gport->view_height = save_view_height;
+ gport->view.x0 = save_left;
+ gport->view.y0 = save_top;
+ gport->view.width = save_view_width;
+ gport->view.height = save_view_height;
return FALSE;
}
@@ -1232,13 +1232,13 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
render_priv *priv = gport->render_priv;
save_drawable = gport->drawable;
- save_zoom = gport->zoom;
+ save_zoom = gport->view.coord_per_px;
save_width = gport->width;
save_height = gport->height;
- save_left = gport->view_x0;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
+ save_left = gport->view.x0;
+ save_top = gport->view.y0;
+ save_view_width = gport->view.width;
+ save_view_height = gport->view.height;
pixmap = gdk_pixmap_new (NULL, width, height, depth);
@@ -1246,15 +1246,15 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
*/
gport->drawable = pixmap;
- gport->zoom = zoom;
+ gport->view.coord_per_px = zoom;
gport->width = width;
gport->height = height;
- gport->view_width = width * gport->zoom;
- gport->view_height = height * gport->zoom;
- gport->view_x0 = ghid_flip_x ? PCB->MaxWidth - cx : cx;
- gport->view_x0 -= gport->view_height / 2;
- gport->view_y0 = ghid_flip_y ? PCB->MaxHeight - cy : cy;
- gport->view_y0 -= gport->view_width / 2;
+ gport->view.width = width * gport->view.coord_per_px;
+ gport->view.height = height * gport->view.coord_per_px;
+ gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx;
+ gport->view.x0 -= gport->view.height / 2;
+ gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy;
+ gport->view.y0 -= gport->view.width / 2;
/* clear background */
gdk_draw_rectangle (pixmap, priv->bg_gc, TRUE, 0, 0, width, height);
@@ -1273,13 +1273,13 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
hid_expose_callback (&ghid_hid, ®ion, NULL);
gport->drawable = save_drawable;
- gport->zoom = save_zoom;
+ gport->view.coord_per_px = save_zoom;
gport->width = save_width;
gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
- gport->view_width = save_view_width;
- gport->view_height = save_view_height;
+ gport->view.x0 = save_left;
+ gport->view.y0 = save_top;
+ gport->view.width = save_view_width;
+ gport->view.height = save_view_height;
return pixmap;
}
diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 8c1e8a2..ea8dd40 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -538,7 +538,7 @@ ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
{
USE_GC (gc);
- hidgl_draw_line (gc->cap, gc->width, x1, y1, x2, y2, gport->zoom);
+ hidgl_draw_line (gc->cap, gc->width, x1, y1, x2, y2, gport->view.coord_per_px);
}
void
@@ -548,7 +548,7 @@ ghid_draw_arc (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius,
USE_GC (gc);
hidgl_draw_arc (gc->width, cx, cy, xradius, yradius,
- start_angle, delta_angle, gport->zoom);
+ start_angle, delta_angle, gport->view.coord_per_px);
}
void
@@ -565,7 +565,7 @@ ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius)
{
USE_GC (gc);
- hidgl_fill_circle (cx, cy, radius, gport->zoom);
+ hidgl_fill_circle (cx, cy, radius, gport->view.coord_per_px);
}
@@ -582,7 +582,7 @@ ghid_fill_pcb_polygon (hidGC gc, PolygonType *poly, const BoxType *clip_box)
{
USE_GC (gc);
- hidgl_fill_pcb_polygon (poly, clip_box, gport->zoom);
+ hidgl_fill_pcb_polygon (poly, clip_box, gport->view.coord_per_px);
}
void
@@ -745,8 +745,8 @@ ghid_show_crosshair (gboolean paint_new_location)
{
gint x, y, z;
gboolean draw_markers;
- int vcw = VCW * gport->zoom;
- int vcd = VCD * gport->zoom;
+ int vcw = VCW * gport->view.coord_per_px;
+ int vcd = VCD * gport->view.coord_per_px;
static int done_once = 0;
static GdkColor cross_color;
@@ -783,25 +783,25 @@ ghid_show_crosshair (gboolean paint_new_location)
if (x >= 0 && paint_new_location && draw_markers)
{
glBegin (GL_QUADS);
- glVertex3i (SIDE_X (gport->view_x0), y - vcd, z);
- glVertex3i (SIDE_X (gport->view_x0), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + vcd), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + vcd), y - vcd, z);
-
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width), y - vcd, z);
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width - vcd), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width - vcd), y - vcd, z);
-
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0), z);
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0 + vcd), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0 + vcd), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0), z);
-
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0 + gport->view_height - vcd), z);
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0 + gport->view_height), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0 + gport->view_height), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0 + gport->view_height - vcd), z);
+ glVertex3i (SIDE_X (gport->view.x0), y - vcd, z);
+ glVertex3i (SIDE_X (gport->view.x0), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + vcd), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + vcd), y - vcd, z);
+
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width), y - vcd, z);
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width - vcd), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width - vcd), y - vcd, z);
+
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0), z);
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0 + vcd), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0 + vcd), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0), z);
+
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0 + gport->view.height - vcd), z);
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0 + gport->view.height), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0 + gport->view.height), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0 + gport->view.height - vcd), z);
glEnd ();
}
@@ -933,13 +933,13 @@ ghid_drawing_area_expose_cb (GtkWidget *widget,
glLoadIdentity ();
glTranslatef (0.0f, 0.0f, -Z_NEAR);
- glScalef ((ghid_flip_x ? -1. : 1.) / port->zoom,
- (ghid_flip_y ? -1. : 1.) / port->zoom,
- ((ghid_flip_x == ghid_flip_y) ? 1. : -1.) / port->zoom);
- glTranslatef (ghid_flip_x ? port->view_x0 - PCB->MaxWidth :
- -port->view_x0,
- ghid_flip_y ? port->view_y0 - PCB->MaxHeight :
- -port->view_y0, 0);
+ glScalef ((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px,
+ (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px,
+ ((port->view.flip_x == port->view.flip_y) ? 1. : -1.) / port->view.coord_per_px);
+ glTranslatef (port->view.flip_x ? port->view.x0 - PCB->MaxWidth :
+ -port->view.x0,
+ port->view.flip_y ? port->view.y0 - PCB->MaxHeight :
+ -port->view.y0, 0);
glEnable (GL_STENCIL_TEST);
glClearColor (port->offlimits_color.red / 65535.,
@@ -1035,13 +1035,13 @@ ghid_pinout_preview_expose (GtkWidget *widget,
int save_view_width, save_view_height;
double xz, yz;
- save_zoom = gport->zoom;
+ save_zoom = gport->view.coord_per_px;
save_width = gport->width;
save_height = gport->height;
- save_left = gport->view_x0;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
+ save_left = gport->view.x0;
+ save_top = gport->view.y0;
+ save_view_width = gport->view.width;
+ save_view_height = gport->view.height;
/* Setup zoom factor for drawing routines */
@@ -1049,16 +1049,16 @@ ghid_pinout_preview_expose (GtkWidget *widget,
xz = (double) pinout->x_max / da_w;
yz = (double) pinout->y_max / da_h;
if (xz > yz)
- gport->zoom = xz;
+ gport->view.coord_per_px = xz;
else
- gport->zoom = yz;
+ gport->view.coord_per_px = yz;
gport->width = da_w;
gport->height = da_h;
- gport->view_width = da_w * gport->zoom;
- gport->view_height = da_h * gport->zoom;
- gport->view_x0 = (pinout->x_max - gport->view_width) / 2;
- gport->view_y0 = (pinout->y_max - gport->view_height) / 2;
+ gport->view.width = da_w * gport->view.coord_per_px;
+ gport->view.height = da_h * gport->view.coord_per_px;
+ gport->view.x0 = (pinout->x_max - gport->view.width) / 2;
+ gport->view.y0 = (pinout->y_max - gport->view.height) / 2;
/* make GL-context "current" */
if (!gdk_gl_drawable_gl_begin (pGlDrawable, pGlContext)) {
@@ -1097,12 +1097,12 @@ ghid_pinout_preview_expose (GtkWidget *widget,
hidgl_init_triangle_array (&buffer);
ghid_invalidate_current_gc ();
glPushMatrix ();
- glScalef ((ghid_flip_x ? -1. : 1.) / gport->zoom,
- (ghid_flip_y ? -1. : 1.) / gport->zoom, 1);
- glTranslatef (ghid_flip_x ? gport->view_x0 - PCB->MaxWidth :
- -gport->view_x0,
- ghid_flip_y ? gport->view_y0 - PCB->MaxHeight :
- -gport->view_y0, 0);
+ glScalef ((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px,
+ (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1);
+ glTranslatef (gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth :
+ -gport->view.x0,
+ gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight :
+ -gport->view.y0, 0);
hid_expose_callback (&ghid_hid, NULL, &pinout->element);
hidgl_flush_triangles (&buffer);
glPopMatrix ();
@@ -1116,13 +1116,13 @@ ghid_pinout_preview_expose (GtkWidget *widget,
gport->render_priv->in_context = false;
gdk_gl_drawable_gl_end (pGlDrawable);
- gport->zoom = save_zoom;
+ gport->view.coord_per_px = save_zoom;
gport->width = save_width;
gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
- gport->view_width = save_view_width;
- gport->view_height = save_view_height;
+ gport->view.x0 = save_left;
+ gport->view.y0 = save_top;
+ gport->view.width = save_view_width;
+ gport->view.height = save_view_height;
return FALSE;
}
@@ -1142,13 +1142,13 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
int save_view_width, save_view_height;
BoxType region;
- save_zoom = gport->zoom;
+ save_zoom = gport->view.coord_per_px;
save_width = gport->width;
save_height = gport->height;
- save_left = gport->view_x0;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
+ save_left = gport->view.x0;
+ save_top = gport->view.y0;
+ save_view_width = gport->view.width;
+ save_view_height = gport->view.height;
/* Setup rendering context for drawing routines
*/
@@ -1164,15 +1164,15 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
/* Setup zoom factor for drawing routines */
- gport->zoom = zoom;
+ gport->view.coord_per_px = zoom;
gport->width = width;
gport->height = height;
- gport->view_width = width * gport->zoom;
- gport->view_height = height * gport->zoom;
- gport->view_x0 = ghid_flip_x ? PCB->MaxWidth - cx : cx;
- gport->view_x0 -= gport->view_height / 2;
- gport->view_y0 = ghid_flip_y ? PCB->MaxHeight - cy : cy;
- gport->view_y0 -= gport->view_width / 2;
+ gport->view.width = width * gport->view.coord_per_px;
+ gport->view.height = height * gport->view.coord_per_px;
+ gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx;
+ gport->view.x0 -= gport->view.height / 2;
+ gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy;
+ gport->view.y0 -= gport->view.width / 2;
/* make GL-context "current" */
if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) {
@@ -1208,12 +1208,12 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
hidgl_init_triangle_array (&buffer);
ghid_invalidate_current_gc ();
glPushMatrix ();
- glScalef ((ghid_flip_x ? -1. : 1.) / gport->zoom,
- (ghid_flip_y ? -1. : 1.) / gport->zoom, 1);
- glTranslatef (ghid_flip_x ? gport->view_x0 - PCB->MaxWidth :
- -gport->view_x0,
- ghid_flip_y ? gport->view_y0 - PCB->MaxHeight :
- -gport->view_y0, 0);
+ glScalef ((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px,
+ (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1);
+ glTranslatef (gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth :
+ -gport->view.x0,
+ gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight :
+ -gport->view.y0, 0);
region.X1 = MIN(Px(0), Px(gport->width + 1));
region.Y1 = MIN(Py(0), Py(gport->height + 1));
@@ -1240,13 +1240,13 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
g_object_unref (glconfig);
g_object_unref (glcontext);
- gport->zoom = save_zoom;
+ gport->view.coord_per_px = save_zoom;
gport->width = save_width;
gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
- gport->view_width = save_view_width;
- gport->view_height = save_view_height;
+ gport->view.x0 = save_left;
+ gport->view.y0 = save_top;
+ gport->view.width = save_view_width;
+ gport->view.height = save_view_height;
return pixmap;
}
@@ -1275,13 +1275,13 @@ ghid_request_debug_draw (void)
glDisable (GL_STENCIL_TEST);
glPushMatrix ();
- glScalef ((ghid_flip_x ? -1. : 1.) / port->zoom,
- (ghid_flip_y ? -1. : 1.) / port->zoom,
- (ghid_flip_x == ghid_flip_y) ? 1. : -1.);
- glTranslatef (ghid_flip_x ? port->view_x0 - PCB->MaxWidth :
- -port->view_x0,
- ghid_flip_y ? port->view_y0 - PCB->MaxHeight :
- -port->view_y0, 0);
+ glScalef ((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px,
+ (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px,
+ (port->view.flip_x == port->view.flip_y) ? 1. : -1.);
+ glTranslatef (port->view.flip_x ? port->view.x0 - PCB->MaxWidth :
+ -port->view.x0,
+ port->view.flip_y ? port->view.y0 - PCB->MaxHeight :
+ -port->view.y0, 0);
return &ghid_hid;
}
@@ -1364,7 +1364,7 @@ draw_lead_user (render_priv *priv)
/* Draw an arc at radius */
hidgl_draw_arc (width, priv->lead_user_x, priv->lead_user_y,
- radius, radius, 0, 360, gport->zoom);
+ radius, radius, 0, 360, gport->view.coord_per_px);
}
hidgl_flush_triangles (&buffer);
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index b1af557..8672b19 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -30,8 +30,6 @@
RCSID ("$Id$");
-bool ghid_flip_x = false, ghid_flip_y = false;
-
static void
pan_common (GHidPort *port)
{
@@ -42,10 +40,10 @@ pan_common (GHidPort *port)
ghid_pcb_to_event_coords (gport->pcb_x, gport->pcb_y, &event_x, &event_y);
/* Don't pan so far the board is completely off the screen */
- port->view_x0 = MAX (-port->view_width, port->view_x0);
- port->view_y0 = MAX (-port->view_height, port->view_y0);
- port->view_x0 = MIN ( port->view_x0, PCB->MaxWidth);
- port->view_y0 = MIN ( port->view_y0, PCB->MaxHeight);
+ port->view.x0 = MAX (-port->view.width, port->view.x0);
+ port->view.y0 = MAX (-port->view.height, port->view.y0);
+ port->view.x0 = MIN ( port->view.x0, PCB->MaxWidth);
+ port->view.y0 = MIN ( port->view.y0, PCB->MaxHeight);
/* Fix up noted event coordinates to match where we clamped. Alternatively
* we could call ghid_note_event_location (NULL); to get a new pointer
@@ -54,8 +52,8 @@ pan_common (GHidPort *port)
ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y);
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);
+ 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();
@@ -64,8 +62,8 @@ pan_common (GHidPort *port)
static void
ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
{
- gport->view_x0 = SIDE_X (pcb_x) - widget_x * gport->zoom;
- gport->view_y0 = SIDE_Y (pcb_y) - widget_y * gport->zoom;
+ gport->view.x0 = SIDE_X (pcb_x) - widget_x * gport->view.coord_per_px;
+ gport->view.y0 = SIDE_Y (pcb_y) - widget_y * gport->view.coord_per_px;
pan_common (gport);
}
@@ -73,14 +71,14 @@ ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
void
ghid_pan_view_rel (Coord dx, Coord dy)
{
- gport->view_x0 += dx;
- gport->view_y0 += dy;
+ gport->view.x0 += dx;
+ gport->view.y0 += dy;
pan_common (gport);
}
-/* gport->zoom:
+/* gport->view.coord_per_px:
* zoom value is PCB units per screen pixel. Larger numbers mean zooming
* out - the largest value means you are looking at the whole board.
*
@@ -103,18 +101,18 @@ ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
PCB->MaxHeight / gport->height) * ALLOW_ZOOM_OUT_BY;
new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom);
- if (gport->zoom == new_zoom)
+ if (gport->view.coord_per_px == 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;
+ 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;
+ gport->view.coord_per_px = new_zoom;
pixel_slop = new_zoom;
ghid_port_ranges_scale ();
- gport->view_x0 = SIDE_X (center_x) - xtmp * gport->view_width;
- gport->view_y0 = SIDE_Y (center_y) - ytmp * gport->view_height;
+ gport->view.x0 = SIDE_X (center_x) - xtmp * gport->view.width;
+ gport->view.y0 = SIDE_Y (center_y) - ytmp * gport->view.height;
pan_common (gport);
@@ -124,7 +122,7 @@ ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
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);
+ ghid_zoom_view_abs (center_x, center_y, gport->view.coord_per_px * factor);
}
static void
@@ -136,15 +134,15 @@ ghid_zoom_view_fit (void)
}
static void
-ghid_flip_view (Coord center_x, Coord center_y, bool flip_x, bool flip_y)
+gport_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;
+ gport->view.flip_x = gport->view.flip_x != flip_x;
+ gport->view.flip_y = gport->view.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);
@@ -1389,15 +1387,15 @@ SwapSides (int argc, char **argv, Coord x, Coord y)
switch (argv[0][0]) {
case 'h':
case 'H':
- ghid_flip_view (gport->pcb_x, gport->pcb_y, true, false);
+ gport_flip_view (gport->pcb_x, gport->pcb_y, true, false);
break;
case 'v':
case 'V':
- ghid_flip_view (gport->pcb_x, gport->pcb_y, false, true);
+ gport_flip_view (gport->pcb_x, gport->pcb_y, false, true);
break;
case 'r':
case 'R':
- ghid_flip_view (gport->pcb_x, gport->pcb_y, true, true);
+ gport_flip_view (gport->pcb_x, gport->pcb_y, true, true);
Settings.ShowSolderSide = !Settings.ShowSolderSide; /* Swapped back below */
break;
default:
@@ -1653,13 +1651,13 @@ CursorAction(int argc, char **argv, Coord x, Coord y)
{
UnitList extra_units_x = {
{ "grid", PCB->Grid, 0 },
- { "view", gport->view_width, UNIT_PERCENT },
+ { "view", gport->view.width, UNIT_PERCENT },
{ "board", PCB->MaxWidth, UNIT_PERCENT },
{ "", 0, 0 }
};
UnitList extra_units_y = {
{ "grid", PCB->Grid, 0 },
- { "view", gport->view_height, UNIT_PERCENT },
+ { "view", gport->view.height, UNIT_PERCENT },
{ "board", PCB->MaxHeight, UNIT_PERCENT },
{ "", 0, 0 }
};
@@ -1677,10 +1675,10 @@ CursorAction(int argc, char **argv, Coord x, Coord y)
AFAIL (cursor);
dx = GetValueEx (argv[1], argv[3], NULL, extra_units_x, "");
- if (ghid_flip_x)
+ if (gport->view.flip_x)
dx = -dx;
dy = GetValueEx (argv[2], argv[3], NULL, extra_units_y, "");
- if (!ghid_flip_y)
+ if (!gport->view.flip_y)
dy = -dy;
EventMoveCrosshair (Crosshair.X + dx, Crosshair.Y + dy);
@@ -1848,13 +1846,13 @@ ScrollAction (int argc, char **argv, Coord x, Coord y)
div = atoi(argv[1]);
if (strcasecmp (argv[0], "up") == 0)
- dy = -gport->view_height / div;
+ dy = -gport->view.height / div;
else if (strcasecmp (argv[0], "down") == 0)
- dy = gport->view_height / div;
+ dy = gport->view.height / div;
else if (strcasecmp (argv[0], "right") == 0)
- dx = gport->view_width / div;
+ dx = gport->view.width / div;
else if (strcasecmp (argv[0], "left") == 0)
- dx = -gport->view_width / div;
+ dx = -gport->view.width / div;
else
AFAIL (scroll);
@@ -2064,19 +2062,20 @@ REGISTER_ACTIONS (ghid_main_action_list)
static int
flag_flipx (int x)
-{
- return ghid_flip_x;
-}
-static int
+{
+ return gport->view.flip_x;
+}
+
+static int
flag_flipy (int x)
-{
- return ghid_flip_y;
-}
+{
+ return gport->view.flip_y;
+}
HID_Flag ghid_main_flag_list[] = {
{"flip_x", flag_flipx, 0},
{"flip_y", flag_flipy, 0}
-};
+};
REGISTER_FLAGS (ghid_main_flag_list)
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 81dcd45..5929a37 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -60,8 +60,8 @@ ghid_port_ranges_changed (void)
h_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range));
v_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range));
- gport->view_x0 = h_adj->value;
- gport->view_y0 = v_adj->value;
+ gport->view.x0 = h_adj->value;
+ gport->view.y0 = v_adj->value;
ghid_invalidate_all ();
}
@@ -78,21 +78,21 @@ ghid_port_ranges_scale (void)
| drawing area size in pixels to PCB units and that will be
| the page size for the Gtk adjustment.
*/
- gport->view_width = gport->width * gport->zoom;
- gport->view_height = gport->height * gport->zoom;
+ gport->view.width = gport->width * gport->view.coord_per_px;
+ gport->view.height = gport->height * gport->view.coord_per_px;
adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range));
- adj->page_size = MIN (gport->view_width, PCB->MaxWidth);
+ adj->page_size = MIN (gport->view.width, PCB->MaxWidth);
adj->page_increment = adj->page_size / 10.0;
adj->step_increment = adj->page_size / 100.0;
- adj->lower = -gport->view_width;
+ adj->lower = -gport->view.width;
adj->upper = PCB->MaxWidth + adj->page_size;
adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range));
- adj->page_size = MIN (gport->view_height, PCB->MaxHeight);
+ adj->page_size = MIN (gport->view.height, PCB->MaxHeight);
adj->page_increment = adj->page_size / 10.0;
adj->step_increment = adj->page_size / 100.0;
- adj->lower = -gport->view_height;
+ adj->lower = -gport->view.height;
adj->upper = PCB->MaxHeight + adj->page_size;
}
@@ -547,8 +547,8 @@ ghid_port_window_motion_cb (GtkWidget * widget,
if (out->panning)
{
- dx = gport->zoom * (x_prev - ev->x);
- dy = gport->zoom * (y_prev - ev->y);
+ dx = gport->view.coord_per_px * (x_prev - ev->x);
+ dy = gport->view.coord_per_px * (y_prev - ev->y);
if (x_prev > 0)
ghid_pan_view_rel (dx, dy);
x_prev = ev->x;
@@ -604,8 +604,8 @@ ghid_pan_idle_cb (gpointer data)
if (gport->has_entered)
return FALSE;
- dy = gport->zoom * y_pan_speed;
- dx = gport->zoom * x_pan_speed;
+ dy = gport->view.coord_per_px * y_pan_speed;
+ dx = gport->view.coord_per_px * x_pan_speed;
ghid_pan_view_rel (dx, dy);
return TRUE;
}
@@ -639,8 +639,8 @@ ghid_port_window_leave_cb (GtkWidget * widget,
/* GdkEvent coords are set to 0,0 at leave events, so must figure
| out edge the cursor left.
*/
- w = ghid_port.width * gport->zoom;
- h = ghid_port.height * gport->zoom;
+ w = ghid_port.width * out->view.coord_per_px;
+ h = ghid_port.height * out->view.coord_per_px;
x0 = EVENT_TO_PCB_X (0);
y0 = EVENT_TO_PCB_Y (0);
@@ -648,9 +648,9 @@ ghid_port_window_leave_cb (GtkWidget * widget,
x -= x0;
y -= y0;
- if (ghid_flip_x )
+ if (gport->view.flip_x)
x = -x;
- if (ghid_flip_y )
+ if (gport->view.flip_y)
y = -y;
dx = w - x;
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index f8674e6..e2beb3c 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1986,7 +1986,7 @@ ghid_parse_arguments (int *argc, char ***argv)
gtk_init (argc, argv);
gport = &ghid_port;
- gport->zoom = 300.0;
+ gport->view.coord_per_px = 300.0;
pixel_slop = 300;
ghid_init_renderer (argc, argv, gport);
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index c3f00a3..ad2a112 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -62,15 +62,14 @@
#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 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)))
+#define SIDE_X(x) ((gport->view.flip_x ? PCB->MaxWidth - (x) : (x)))
+#define SIDE_Y(y) ((gport->view.flip_y ? PCB->MaxHeight - (y) : (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 DRAW_X(x) (gint)((SIDE_X(x) - gport->view.x0) / gport->view.coord_per_px)
+#define DRAW_Y(y) (gint)((SIDE_Y(y) - gport->view.y0) / gport->view.coord_per_px)
-#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))
+#define EVENT_TO_PCB_X(x) SIDE_X((gint)((x) * gport->view.coord_per_px + gport->view.x0))
+#define EVENT_TO_PCB_Y(y) SIDE_Y((gint)((y) * gport->view.coord_per_px + gport->view.y0))
/*
* Used to intercept "special" hotkeys that gtk doesn't usually pass
@@ -145,6 +144,19 @@ GhidGui;
extern GhidGui _ghidgui, *ghidgui;
+typedef struct
+{
+ double coord_per_px; /* Zoom level described as PCB units per screen pixel */
+
+ Coord x0;
+ Coord y0;
+ Coord width;
+ Coord height;
+
+ bool flip_x;
+ bool flip_y;
+
+} view_data;
/* The output viewport
*/
@@ -168,15 +180,9 @@ typedef struct
gboolean has_entered;
gboolean panning;
-/* zoom value is PCB units per screen pixel. Larger numbers mean zooming
-| out - the largest value means you are looking at the whole board.
-*/
- gdouble zoom; /* PCB units per screen pixel. Larger */
- /* numbers mean zooming out. */
- /* Viewport in PCB coordinates */
- Coord view_x0, view_y0, view_width, view_height;
- Coord pcb_x, pcb_y;
- Coord crosshair_x, crosshair_y;
+ view_data view;
+ Coord pcb_x, pcb_y; /* PCB coordinates of the mouse pointer */
+ Coord crosshair_x, crosshair_y; /* PCB coordinates of the crosshair */
}
GHidPort;
@@ -520,10 +526,10 @@ static inline int
Vx (Coord x)
{
int rv;
- if (ghid_flip_x)
- rv = (PCB->MaxWidth - x - gport->view_x0) / gport->zoom + 0.5;
+ if (gport->view.flip_x)
+ rv = (PCB->MaxWidth - x - gport->view.x0) / gport->view.coord_per_px + 0.5;
else
- rv = (x - gport->view_x0) / gport->zoom + 0.5;
+ rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5;
return rv;
}
@@ -531,41 +537,41 @@ static inline int
Vy (Coord y)
{
int rv;
- if (ghid_flip_y)
- rv = (PCB->MaxHeight - y - gport->view_y0) / gport->zoom + 0.5;
+ if (gport->view.flip_y)
+ rv = (PCB->MaxHeight - y - gport->view.y0) / gport->view.coord_per_px + 0.5;
else
- rv = (y - gport->view_y0) / gport->zoom + 0.5;
+ rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5;
return rv;
}
static inline int
Vz (Coord z)
{
- return z / gport->zoom + 0.5;
+ return z / gport->view.coord_per_px + 0.5;
}
static inline Coord
Px (int x)
{
- Coord rv = x * gport->zoom + gport->view_x0;
- if (ghid_flip_x)
- rv = PCB->MaxWidth - (x * gport->zoom + gport->view_x0);
+ Coord rv = x * gport->view.coord_per_px + gport->view.x0;
+ if (gport->view.flip_x)
+ rv = PCB->MaxWidth - (x * gport->view.coord_per_px + gport->view.x0);
return rv;
}
static inline Coord
Py (int y)
{
- Coord rv = y * gport->zoom + gport->view_y0;
- if (ghid_flip_y)
- rv = PCB->MaxHeight - (y * gport->zoom + gport->view_y0);
+ Coord rv = y * gport->view.coord_per_px + gport->view.y0;
+ if (gport->view.flip_y)
+ rv = PCB->MaxHeight - (y * gport->view.coord_per_px + gport->view.y0);
return rv;
}
static inline Coord
Pz (int z)
{
- return (z * gport->zoom);
+ return (z * gport->view.coord_per_px);
}
#endif /* PCB_HID_GTK_GHID_H */
|
|
From: <gi...@gp...> - 2011-08-27 14:38:39
|
The branch, master has been updated
via 25af27394efe1259db8e049bac1d6fc380e0c3ee (commit)
via e1c619732e14cd7e90025d248c44f8c7e388313e (commit)
from 125e1d58aa82a52777fab7153426ab66c6c9fda7 (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-gl.c | 170 +++++++++++++++++++-------------------
src/hid/gtk/gtkhid-main.c | 81 +++++++++----------
src/hid/gtk/gui-output-events.c | 32 ++++----
src/hid/gtk/gui-top-window.c | 2 +-
src/hid/gtk/gui.h | 66 ++++++++-------
5 files changed, 177 insertions(+), 174 deletions(-)
=================
Commit Messages
=================
commit 25af27394efe1259db8e049bac1d6fc380e0c3ee
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Encapsulate view parameters in a structure
:100644 100644 8c1e8a2... ea8dd40... M src/hid/gtk/gtkhid-gl.c
:100644 100644 b1af557... 2b1cb64... M src/hid/gtk/gtkhid-main.c
:100644 100644 81dcd45... 5929a37... M src/hid/gtk/gui-output-events.c
:100644 100644 f8674e6... e2beb3c... M src/hid/gtk/gui-top-window.c
:100644 100644 c3f00a3... ad2a112... M src/hid/gtk/gui.h
commit e1c619732e14cd7e90025d248c44f8c7e388313e
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove unnecessary prototype
:100644 100644 f5c836c... b1af557... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit 25af27394efe1259db8e049bac1d6fc380e0c3ee
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Encapsulate view parameters in a structure
diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 8c1e8a2..ea8dd40 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -538,7 +538,7 @@ ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
{
USE_GC (gc);
- hidgl_draw_line (gc->cap, gc->width, x1, y1, x2, y2, gport->zoom);
+ hidgl_draw_line (gc->cap, gc->width, x1, y1, x2, y2, gport->view.coord_per_px);
}
void
@@ -548,7 +548,7 @@ ghid_draw_arc (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius,
USE_GC (gc);
hidgl_draw_arc (gc->width, cx, cy, xradius, yradius,
- start_angle, delta_angle, gport->zoom);
+ start_angle, delta_angle, gport->view.coord_per_px);
}
void
@@ -565,7 +565,7 @@ ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius)
{
USE_GC (gc);
- hidgl_fill_circle (cx, cy, radius, gport->zoom);
+ hidgl_fill_circle (cx, cy, radius, gport->view.coord_per_px);
}
@@ -582,7 +582,7 @@ ghid_fill_pcb_polygon (hidGC gc, PolygonType *poly, const BoxType *clip_box)
{
USE_GC (gc);
- hidgl_fill_pcb_polygon (poly, clip_box, gport->zoom);
+ hidgl_fill_pcb_polygon (poly, clip_box, gport->view.coord_per_px);
}
void
@@ -745,8 +745,8 @@ ghid_show_crosshair (gboolean paint_new_location)
{
gint x, y, z;
gboolean draw_markers;
- int vcw = VCW * gport->zoom;
- int vcd = VCD * gport->zoom;
+ int vcw = VCW * gport->view.coord_per_px;
+ int vcd = VCD * gport->view.coord_per_px;
static int done_once = 0;
static GdkColor cross_color;
@@ -783,25 +783,25 @@ ghid_show_crosshair (gboolean paint_new_location)
if (x >= 0 && paint_new_location && draw_markers)
{
glBegin (GL_QUADS);
- glVertex3i (SIDE_X (gport->view_x0), y - vcd, z);
- glVertex3i (SIDE_X (gport->view_x0), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + vcd), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + vcd), y - vcd, z);
-
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width), y - vcd, z);
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width - vcd), y - vcd + vcw, z);
- glVertex3i (SIDE_X (gport->view_x0 + gport->view_width - vcd), y - vcd, z);
-
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0), z);
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0 + vcd), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0 + vcd), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0), z);
-
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0 + gport->view_height - vcd), z);
- glVertex3i (x - vcd, SIDE_Y (gport->view_y0 + gport->view_height), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0 + gport->view_height), z);
- glVertex3i (x - vcd + vcw, SIDE_Y (gport->view_y0 + gport->view_height - vcd), z);
+ glVertex3i (SIDE_X (gport->view.x0), y - vcd, z);
+ glVertex3i (SIDE_X (gport->view.x0), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + vcd), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + vcd), y - vcd, z);
+
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width), y - vcd, z);
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width - vcd), y - vcd + vcw, z);
+ glVertex3i (SIDE_X (gport->view.x0 + gport->view.width - vcd), y - vcd, z);
+
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0), z);
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0 + vcd), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0 + vcd), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0), z);
+
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0 + gport->view.height - vcd), z);
+ glVertex3i (x - vcd, SIDE_Y (gport->view.y0 + gport->view.height), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0 + gport->view.height), z);
+ glVertex3i (x - vcd + vcw, SIDE_Y (gport->view.y0 + gport->view.height - vcd), z);
glEnd ();
}
@@ -933,13 +933,13 @@ ghid_drawing_area_expose_cb (GtkWidget *widget,
glLoadIdentity ();
glTranslatef (0.0f, 0.0f, -Z_NEAR);
- glScalef ((ghid_flip_x ? -1. : 1.) / port->zoom,
- (ghid_flip_y ? -1. : 1.) / port->zoom,
- ((ghid_flip_x == ghid_flip_y) ? 1. : -1.) / port->zoom);
- glTranslatef (ghid_flip_x ? port->view_x0 - PCB->MaxWidth :
- -port->view_x0,
- ghid_flip_y ? port->view_y0 - PCB->MaxHeight :
- -port->view_y0, 0);
+ glScalef ((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px,
+ (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px,
+ ((port->view.flip_x == port->view.flip_y) ? 1. : -1.) / port->view.coord_per_px);
+ glTranslatef (port->view.flip_x ? port->view.x0 - PCB->MaxWidth :
+ -port->view.x0,
+ port->view.flip_y ? port->view.y0 - PCB->MaxHeight :
+ -port->view.y0, 0);
glEnable (GL_STENCIL_TEST);
glClearColor (port->offlimits_color.red / 65535.,
@@ -1035,13 +1035,13 @@ ghid_pinout_preview_expose (GtkWidget *widget,
int save_view_width, save_view_height;
double xz, yz;
- save_zoom = gport->zoom;
+ save_zoom = gport->view.coord_per_px;
save_width = gport->width;
save_height = gport->height;
- save_left = gport->view_x0;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
+ save_left = gport->view.x0;
+ save_top = gport->view.y0;
+ save_view_width = gport->view.width;
+ save_view_height = gport->view.height;
/* Setup zoom factor for drawing routines */
@@ -1049,16 +1049,16 @@ ghid_pinout_preview_expose (GtkWidget *widget,
xz = (double) pinout->x_max / da_w;
yz = (double) pinout->y_max / da_h;
if (xz > yz)
- gport->zoom = xz;
+ gport->view.coord_per_px = xz;
else
- gport->zoom = yz;
+ gport->view.coord_per_px = yz;
gport->width = da_w;
gport->height = da_h;
- gport->view_width = da_w * gport->zoom;
- gport->view_height = da_h * gport->zoom;
- gport->view_x0 = (pinout->x_max - gport->view_width) / 2;
- gport->view_y0 = (pinout->y_max - gport->view_height) / 2;
+ gport->view.width = da_w * gport->view.coord_per_px;
+ gport->view.height = da_h * gport->view.coord_per_px;
+ gport->view.x0 = (pinout->x_max - gport->view.width) / 2;
+ gport->view.y0 = (pinout->y_max - gport->view.height) / 2;
/* make GL-context "current" */
if (!gdk_gl_drawable_gl_begin (pGlDrawable, pGlContext)) {
@@ -1097,12 +1097,12 @@ ghid_pinout_preview_expose (GtkWidget *widget,
hidgl_init_triangle_array (&buffer);
ghid_invalidate_current_gc ();
glPushMatrix ();
- glScalef ((ghid_flip_x ? -1. : 1.) / gport->zoom,
- (ghid_flip_y ? -1. : 1.) / gport->zoom, 1);
- glTranslatef (ghid_flip_x ? gport->view_x0 - PCB->MaxWidth :
- -gport->view_x0,
- ghid_flip_y ? gport->view_y0 - PCB->MaxHeight :
- -gport->view_y0, 0);
+ glScalef ((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px,
+ (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1);
+ glTranslatef (gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth :
+ -gport->view.x0,
+ gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight :
+ -gport->view.y0, 0);
hid_expose_callback (&ghid_hid, NULL, &pinout->element);
hidgl_flush_triangles (&buffer);
glPopMatrix ();
@@ -1116,13 +1116,13 @@ ghid_pinout_preview_expose (GtkWidget *widget,
gport->render_priv->in_context = false;
gdk_gl_drawable_gl_end (pGlDrawable);
- gport->zoom = save_zoom;
+ gport->view.coord_per_px = save_zoom;
gport->width = save_width;
gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
- gport->view_width = save_view_width;
- gport->view_height = save_view_height;
+ gport->view.x0 = save_left;
+ gport->view.y0 = save_top;
+ gport->view.width = save_view_width;
+ gport->view.height = save_view_height;
return FALSE;
}
@@ -1142,13 +1142,13 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
int save_view_width, save_view_height;
BoxType region;
- save_zoom = gport->zoom;
+ save_zoom = gport->view.coord_per_px;
save_width = gport->width;
save_height = gport->height;
- save_left = gport->view_x0;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
+ save_left = gport->view.x0;
+ save_top = gport->view.y0;
+ save_view_width = gport->view.width;
+ save_view_height = gport->view.height;
/* Setup rendering context for drawing routines
*/
@@ -1164,15 +1164,15 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
/* Setup zoom factor for drawing routines */
- gport->zoom = zoom;
+ gport->view.coord_per_px = zoom;
gport->width = width;
gport->height = height;
- gport->view_width = width * gport->zoom;
- gport->view_height = height * gport->zoom;
- gport->view_x0 = ghid_flip_x ? PCB->MaxWidth - cx : cx;
- gport->view_x0 -= gport->view_height / 2;
- gport->view_y0 = ghid_flip_y ? PCB->MaxHeight - cy : cy;
- gport->view_y0 -= gport->view_width / 2;
+ gport->view.width = width * gport->view.coord_per_px;
+ gport->view.height = height * gport->view.coord_per_px;
+ gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx;
+ gport->view.x0 -= gport->view.height / 2;
+ gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy;
+ gport->view.y0 -= gport->view.width / 2;
/* make GL-context "current" */
if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) {
@@ -1208,12 +1208,12 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
hidgl_init_triangle_array (&buffer);
ghid_invalidate_current_gc ();
glPushMatrix ();
- glScalef ((ghid_flip_x ? -1. : 1.) / gport->zoom,
- (ghid_flip_y ? -1. : 1.) / gport->zoom, 1);
- glTranslatef (ghid_flip_x ? gport->view_x0 - PCB->MaxWidth :
- -gport->view_x0,
- ghid_flip_y ? gport->view_y0 - PCB->MaxHeight :
- -gport->view_y0, 0);
+ glScalef ((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px,
+ (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1);
+ glTranslatef (gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth :
+ -gport->view.x0,
+ gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight :
+ -gport->view.y0, 0);
region.X1 = MIN(Px(0), Px(gport->width + 1));
region.Y1 = MIN(Py(0), Py(gport->height + 1));
@@ -1240,13 +1240,13 @@ ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int dept
g_object_unref (glconfig);
g_object_unref (glcontext);
- gport->zoom = save_zoom;
+ gport->view.coord_per_px = save_zoom;
gport->width = save_width;
gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
- gport->view_width = save_view_width;
- gport->view_height = save_view_height;
+ gport->view.x0 = save_left;
+ gport->view.y0 = save_top;
+ gport->view.width = save_view_width;
+ gport->view.height = save_view_height;
return pixmap;
}
@@ -1275,13 +1275,13 @@ ghid_request_debug_draw (void)
glDisable (GL_STENCIL_TEST);
glPushMatrix ();
- glScalef ((ghid_flip_x ? -1. : 1.) / port->zoom,
- (ghid_flip_y ? -1. : 1.) / port->zoom,
- (ghid_flip_x == ghid_flip_y) ? 1. : -1.);
- glTranslatef (ghid_flip_x ? port->view_x0 - PCB->MaxWidth :
- -port->view_x0,
- ghid_flip_y ? port->view_y0 - PCB->MaxHeight :
- -port->view_y0, 0);
+ glScalef ((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px,
+ (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px,
+ (port->view.flip_x == port->view.flip_y) ? 1. : -1.);
+ glTranslatef (port->view.flip_x ? port->view.x0 - PCB->MaxWidth :
+ -port->view.x0,
+ port->view.flip_y ? port->view.y0 - PCB->MaxHeight :
+ -port->view.y0, 0);
return &ghid_hid;
}
@@ -1364,7 +1364,7 @@ draw_lead_user (render_priv *priv)
/* Draw an arc at radius */
hidgl_draw_arc (width, priv->lead_user_x, priv->lead_user_y,
- radius, radius, 0, 360, gport->zoom);
+ radius, radius, 0, 360, gport->view.coord_per_px);
}
hidgl_flush_triangles (&buffer);
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index b1af557..2b1cb64 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -30,8 +30,6 @@
RCSID ("$Id$");
-bool ghid_flip_x = false, ghid_flip_y = false;
-
static void
pan_common (GHidPort *port)
{
@@ -42,10 +40,10 @@ pan_common (GHidPort *port)
ghid_pcb_to_event_coords (gport->pcb_x, gport->pcb_y, &event_x, &event_y);
/* Don't pan so far the board is completely off the screen */
- port->view_x0 = MAX (-port->view_width, port->view_x0);
- port->view_y0 = MAX (-port->view_height, port->view_y0);
- port->view_x0 = MIN ( port->view_x0, PCB->MaxWidth);
- port->view_y0 = MIN ( port->view_y0, PCB->MaxHeight);
+ port->view.x0 = MAX (-port->view.width, port->view.x0);
+ port->view.y0 = MAX (-port->view.height, port->view.y0);
+ port->view.x0 = MIN ( port->view.x0, PCB->MaxWidth);
+ port->view.y0 = MIN ( port->view.y0, PCB->MaxHeight);
/* Fix up noted event coordinates to match where we clamped. Alternatively
* we could call ghid_note_event_location (NULL); to get a new pointer
@@ -54,8 +52,8 @@ pan_common (GHidPort *port)
ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y);
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);
+ 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();
@@ -64,8 +62,8 @@ pan_common (GHidPort *port)
static void
ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
{
- gport->view_x0 = SIDE_X (pcb_x) - widget_x * gport->zoom;
- gport->view_y0 = SIDE_Y (pcb_y) - widget_y * gport->zoom;
+ gport->view.x0 = SIDE_X (pcb_x) - widget_x * gport->view.coord_per_px;
+ gport->view.y0 = SIDE_Y (pcb_y) - widget_y * gport->view.coord_per_px;
pan_common (gport);
}
@@ -73,14 +71,14 @@ ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
void
ghid_pan_view_rel (Coord dx, Coord dy)
{
- gport->view_x0 += dx;
- gport->view_y0 += dy;
+ gport->view.x0 += dx;
+ gport->view.y0 += dy;
pan_common (gport);
}
-/* gport->zoom:
+/* gport->view.coord_per_px:
* zoom value is PCB units per screen pixel. Larger numbers mean zooming
* out - the largest value means you are looking at the whole board.
*
@@ -103,18 +101,18 @@ ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
PCB->MaxHeight / gport->height) * ALLOW_ZOOM_OUT_BY;
new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom);
- if (gport->zoom == new_zoom)
+ if (gport->view.coord_per_px == 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;
+ 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;
+ gport->view.coord_per_px = new_zoom;
pixel_slop = new_zoom;
ghid_port_ranges_scale ();
- gport->view_x0 = SIDE_X (center_x) - xtmp * gport->view_width;
- gport->view_y0 = SIDE_Y (center_y) - ytmp * gport->view_height;
+ gport->view.x0 = SIDE_X (center_x) - xtmp * gport->view.width;
+ gport->view.y0 = SIDE_Y (center_y) - ytmp * gport->view.height;
pan_common (gport);
@@ -124,7 +122,7 @@ ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
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);
+ ghid_zoom_view_abs (center_x, center_y, gport->view.coord_per_px * factor);
}
static void
@@ -136,15 +134,15 @@ ghid_zoom_view_fit (void)
}
static void
-ghid_flip_view (Coord center_x, Coord center_y, bool flip_x, bool flip_y)
+gport_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;
+ gport->view.flip_x = gport->view.flip_x != flip_x;
+ gport->view.flip_y = gport->view.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);
@@ -1389,15 +1387,15 @@ SwapSides (int argc, char **argv, Coord x, Coord y)
switch (argv[0][0]) {
case 'h':
case 'H':
- ghid_flip_view (gport->pcb_x, gport->pcb_y, true, false);
+ gport_flip_view (gport->pcb_x, gport->pcb_y, true, false);
break;
case 'v':
case 'V':
- ghid_flip_view (gport->pcb_x, gport->pcb_y, false, true);
+ gport_flip_view (gport->pcb_x, gport->pcb_y, false, true);
break;
case 'r':
case 'R':
- ghid_flip_view (gport->pcb_x, gport->pcb_y, true, true);
+ gport_flip_view (gport->pcb_x, gport->pcb_y, true, true);
Settings.ShowSolderSide = !Settings.ShowSolderSide; /* Swapped back below */
break;
default:
@@ -1677,10 +1675,10 @@ CursorAction(int argc, char **argv, Coord x, Coord y)
AFAIL (cursor);
dx = GetValueEx (argv[1], argv[3], NULL, extra_units_x, "");
- if (ghid_flip_x)
+ if (gport->view.flip_x)
dx = -dx;
dy = GetValueEx (argv[2], argv[3], NULL, extra_units_y, "");
- if (!ghid_flip_y)
+ if (!gport->view.flip_y)
dy = -dy;
EventMoveCrosshair (Crosshair.X + dx, Crosshair.Y + dy);
@@ -1848,13 +1846,13 @@ ScrollAction (int argc, char **argv, Coord x, Coord y)
div = atoi(argv[1]);
if (strcasecmp (argv[0], "up") == 0)
- dy = -gport->view_height / div;
+ dy = -gport->view.height / div;
else if (strcasecmp (argv[0], "down") == 0)
- dy = gport->view_height / div;
+ dy = gport->view.height / div;
else if (strcasecmp (argv[0], "right") == 0)
- dx = gport->view_width / div;
+ dx = gport->view.width / div;
else if (strcasecmp (argv[0], "left") == 0)
- dx = -gport->view_width / div;
+ dx = -gport->view.width / div;
else
AFAIL (scroll);
@@ -2064,19 +2062,20 @@ REGISTER_ACTIONS (ghid_main_action_list)
static int
flag_flipx (int x)
-{
- return ghid_flip_x;
-}
-static int
+{
+ return gport->view.flip_x;
+}
+
+static int
flag_flipy (int x)
-{
- return ghid_flip_y;
-}
+{
+ return gport->view.flip_y;
+}
HID_Flag ghid_main_flag_list[] = {
{"flip_x", flag_flipx, 0},
{"flip_y", flag_flipy, 0}
-};
+};
REGISTER_FLAGS (ghid_main_flag_list)
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 81dcd45..5929a37 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -60,8 +60,8 @@ ghid_port_ranges_changed (void)
h_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range));
v_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range));
- gport->view_x0 = h_adj->value;
- gport->view_y0 = v_adj->value;
+ gport->view.x0 = h_adj->value;
+ gport->view.y0 = v_adj->value;
ghid_invalidate_all ();
}
@@ -78,21 +78,21 @@ ghid_port_ranges_scale (void)
| drawing area size in pixels to PCB units and that will be
| the page size for the Gtk adjustment.
*/
- gport->view_width = gport->width * gport->zoom;
- gport->view_height = gport->height * gport->zoom;
+ gport->view.width = gport->width * gport->view.coord_per_px;
+ gport->view.height = gport->height * gport->view.coord_per_px;
adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range));
- adj->page_size = MIN (gport->view_width, PCB->MaxWidth);
+ adj->page_size = MIN (gport->view.width, PCB->MaxWidth);
adj->page_increment = adj->page_size / 10.0;
adj->step_increment = adj->page_size / 100.0;
- adj->lower = -gport->view_width;
+ adj->lower = -gport->view.width;
adj->upper = PCB->MaxWidth + adj->page_size;
adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range));
- adj->page_size = MIN (gport->view_height, PCB->MaxHeight);
+ adj->page_size = MIN (gport->view.height, PCB->MaxHeight);
adj->page_increment = adj->page_size / 10.0;
adj->step_increment = adj->page_size / 100.0;
- adj->lower = -gport->view_height;
+ adj->lower = -gport->view.height;
adj->upper = PCB->MaxHeight + adj->page_size;
}
@@ -547,8 +547,8 @@ ghid_port_window_motion_cb (GtkWidget * widget,
if (out->panning)
{
- dx = gport->zoom * (x_prev - ev->x);
- dy = gport->zoom * (y_prev - ev->y);
+ dx = gport->view.coord_per_px * (x_prev - ev->x);
+ dy = gport->view.coord_per_px * (y_prev - ev->y);
if (x_prev > 0)
ghid_pan_view_rel (dx, dy);
x_prev = ev->x;
@@ -604,8 +604,8 @@ ghid_pan_idle_cb (gpointer data)
if (gport->has_entered)
return FALSE;
- dy = gport->zoom * y_pan_speed;
- dx = gport->zoom * x_pan_speed;
+ dy = gport->view.coord_per_px * y_pan_speed;
+ dx = gport->view.coord_per_px * x_pan_speed;
ghid_pan_view_rel (dx, dy);
return TRUE;
}
@@ -639,8 +639,8 @@ ghid_port_window_leave_cb (GtkWidget * widget,
/* GdkEvent coords are set to 0,0 at leave events, so must figure
| out edge the cursor left.
*/
- w = ghid_port.width * gport->zoom;
- h = ghid_port.height * gport->zoom;
+ w = ghid_port.width * out->view.coord_per_px;
+ h = ghid_port.height * out->view.coord_per_px;
x0 = EVENT_TO_PCB_X (0);
y0 = EVENT_TO_PCB_Y (0);
@@ -648,9 +648,9 @@ ghid_port_window_leave_cb (GtkWidget * widget,
x -= x0;
y -= y0;
- if (ghid_flip_x )
+ if (gport->view.flip_x)
x = -x;
- if (ghid_flip_y )
+ if (gport->view.flip_y)
y = -y;
dx = w - x;
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index f8674e6..e2beb3c 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1986,7 +1986,7 @@ ghid_parse_arguments (int *argc, char ***argv)
gtk_init (argc, argv);
gport = &ghid_port;
- gport->zoom = 300.0;
+ gport->view.coord_per_px = 300.0;
pixel_slop = 300;
ghid_init_renderer (argc, argv, gport);
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index c3f00a3..ad2a112 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -62,15 +62,14 @@
#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 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)))
+#define SIDE_X(x) ((gport->view.flip_x ? PCB->MaxWidth - (x) : (x)))
+#define SIDE_Y(y) ((gport->view.flip_y ? PCB->MaxHeight - (y) : (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 DRAW_X(x) (gint)((SIDE_X(x) - gport->view.x0) / gport->view.coord_per_px)
+#define DRAW_Y(y) (gint)((SIDE_Y(y) - gport->view.y0) / gport->view.coord_per_px)
-#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))
+#define EVENT_TO_PCB_X(x) SIDE_X((gint)((x) * gport->view.coord_per_px + gport->view.x0))
+#define EVENT_TO_PCB_Y(y) SIDE_Y((gint)((y) * gport->view.coord_per_px + gport->view.y0))
/*
* Used to intercept "special" hotkeys that gtk doesn't usually pass
@@ -145,6 +144,19 @@ GhidGui;
extern GhidGui _ghidgui, *ghidgui;
+typedef struct
+{
+ double coord_per_px; /* Zoom level described as PCB units per screen pixel */
+
+ Coord x0;
+ Coord y0;
+ Coord width;
+ Coord height;
+
+ bool flip_x;
+ bool flip_y;
+
+} view_data;
/* The output viewport
*/
@@ -168,15 +180,9 @@ typedef struct
gboolean has_entered;
gboolean panning;
-/* zoom value is PCB units per screen pixel. Larger numbers mean zooming
-| out - the largest value means you are looking at the whole board.
-*/
- gdouble zoom; /* PCB units per screen pixel. Larger */
- /* numbers mean zooming out. */
- /* Viewport in PCB coordinates */
- Coord view_x0, view_y0, view_width, view_height;
- Coord pcb_x, pcb_y;
- Coord crosshair_x, crosshair_y;
+ view_data view;
+ Coord pcb_x, pcb_y; /* PCB coordinates of the mouse pointer */
+ Coord crosshair_x, crosshair_y; /* PCB coordinates of the crosshair */
}
GHidPort;
@@ -520,10 +526,10 @@ static inline int
Vx (Coord x)
{
int rv;
- if (ghid_flip_x)
- rv = (PCB->MaxWidth - x - gport->view_x0) / gport->zoom + 0.5;
+ if (gport->view.flip_x)
+ rv = (PCB->MaxWidth - x - gport->view.x0) / gport->view.coord_per_px + 0.5;
else
- rv = (x - gport->view_x0) / gport->zoom + 0.5;
+ rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5;
return rv;
}
@@ -531,41 +537,41 @@ static inline int
Vy (Coord y)
{
int rv;
- if (ghid_flip_y)
- rv = (PCB->MaxHeight - y - gport->view_y0) / gport->zoom + 0.5;
+ if (gport->view.flip_y)
+ rv = (PCB->MaxHeight - y - gport->view.y0) / gport->view.coord_per_px + 0.5;
else
- rv = (y - gport->view_y0) / gport->zoom + 0.5;
+ rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5;
return rv;
}
static inline int
Vz (Coord z)
{
- return z / gport->zoom + 0.5;
+ return z / gport->view.coord_per_px + 0.5;
}
static inline Coord
Px (int x)
{
- Coord rv = x * gport->zoom + gport->view_x0;
- if (ghid_flip_x)
- rv = PCB->MaxWidth - (x * gport->zoom + gport->view_x0);
+ Coord rv = x * gport->view.coord_per_px + gport->view.x0;
+ if (gport->view.flip_x)
+ rv = PCB->MaxWidth - (x * gport->view.coord_per_px + gport->view.x0);
return rv;
}
static inline Coord
Py (int y)
{
- Coord rv = y * gport->zoom + gport->view_y0;
- if (ghid_flip_y)
- rv = PCB->MaxHeight - (y * gport->zoom + gport->view_y0);
+ Coord rv = y * gport->view.coord_per_px + gport->view.y0;
+ if (gport->view.flip_y)
+ rv = PCB->MaxHeight - (y * gport->view.coord_per_px + gport->view.y0);
return rv;
}
static inline Coord
Pz (int z)
{
- return (z * gport->zoom);
+ return (z * gport->view.coord_per_px);
}
#endif /* PCB_HID_GTK_GHID_H */
commit e1c619732e14cd7e90025d248c44f8c7e388313e
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove unnecessary prototype
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index f5c836c..b1af557 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -32,8 +32,6 @@ RCSID ("$Id$");
bool ghid_flip_x = false, ghid_flip_y = false;
-static void ghid_zoom_view_fit (void);
-
static void
pan_common (GHidPort *port)
{
|
|
From: <gi...@gp...> - 2011-08-27 14:06:19
|
The branch, master has been updated
via 125e1d58aa82a52777fab7153426ab66c6c9fda7 (commit)
via a1d1e997090de7d0c8c39a892e4025fd34e1d876 (commit)
from 1ecad8ef9ef72a04c7eaa238748c80b1957bda6c (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/fontmode.c | 1 +
src/hid/gtk/gui.h | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit 125e1d58aa82a52777fab7153426ab66c6c9fda7
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: crosshair_{x,y} should be Coord, not int.
:100644 100644 6fe3a04... c3f00a3... M src/hid/gtk/gui.h
commit a1d1e997090de7d0c8c39a892e4025fd34e1d876
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
fontmode.c: Add missing #include "pcb-printf.h"
:100644 100644 985a38f... dd64f63... M src/fontmode.c
=========
Changes
=========
commit 125e1d58aa82a52777fab7153426ab66c6c9fda7
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: crosshair_{x,y} should be Coord, not int.
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 6fe3a04..c3f00a3 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -176,8 +176,7 @@ typedef struct
/* Viewport in PCB coordinates */
Coord view_x0, view_y0, view_width, view_height;
Coord pcb_x, pcb_y;
-
- gint crosshair_x, crosshair_y;
+ Coord crosshair_x, crosshair_y;
}
GHidPort;
commit a1d1e997090de7d0c8c39a892e4025fd34e1d876
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
fontmode.c: Add missing #include "pcb-printf.h"
diff --git a/src/fontmode.c b/src/fontmode.c
index 985a38f..dd64f63 100644
--- a/src/fontmode.c
+++ b/src/fontmode.c
@@ -46,6 +46,7 @@
#include "rtree.h"
#include "strflags.h"
#include "undo.h"
+#include "pcb-printf.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
|
|
From: <gi...@gp...> - 2011-08-27 03:22:49
|
The branch, master has been updated
via 1ecad8ef9ef72a04c7eaa238748c80b1957bda6c (commit)
via a82f26085b99bd1af02eee0f7dd5ac54e08376d4 (commit)
via 06b2b313635b7eafd6c93b8878ef842021970c85 (commit)
from 419971a4139205e6c3b6cc255b37d7124ae3165b (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/fontmode.c | 9 +++++++++
src/hid/lesstif/dialogs.c | 2 +-
src/parse_l.l | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit 1ecad8ef9ef72a04c7eaa238748c80b1957bda6c
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix FontEdit()
Move top/bottom meta-layers to layers 0 and 1 so they'll exist after we
trim out the layers. Set up DRC values to avoid interfereing with the
font layout.
Closes-bug: lp-808591
:100644 100644 8130b59... 985a38f... M src/fontmode.c
commit a82f26085b99bd1af02eee0f7dd5ac54e08376d4
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Use correct units when setting up the Sizes dialog.
Replace %mm with %mS so it auto-selects units, to match the scanning
that's done when you save the settings.
:100644 100644 75e4a20... 5d744f9... M src/hid/lesstif/dialogs.c
commit 06b2b313635b7eafd6c93b8878ef842021970c85
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Avoid segfault tmp-saving partial board.
Check for both PCB and PCB->Data to avoid trying to save a backup copy
of a partially created layout.
:100644 100644 9ebb8e2... 33a115d... M src/parse_l.l
=========
Changes
=========
commit 1ecad8ef9ef72a04c7eaa238748c80b1957bda6c
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix FontEdit()
Move top/bottom meta-layers to layers 0 and 1 so they'll exist after we
trim out the layers. Set up DRC values to avoid interfereing with the
font layout.
Closes-bug: lp-808591
diff --git a/src/fontmode.c b/src/fontmode.c
index 8130b59..985a38f 100644
--- a/src/fontmode.c
+++ b/src/fontmode.c
@@ -85,6 +85,15 @@ FontEdit (int argc, char **argv, Coord Ux, Coord Uy)
if (hid_actionl ("New", "Font", 0))
return 1;
+ Settings.grid_unit = get_unit_struct("mil");
+ Settings.Bloat = PCB->Bloat = 1;
+ Settings.Shrink = PCB->Shrink = 1;
+ Settings.minWid = PCB->minWid = 1;
+ Settings.minSlk = PCB->minSlk = 1;
+
+ MoveLayerToGroup (max_copper_layer + COMPONENT_LAYER, 0);
+ MoveLayerToGroup (max_copper_layer + SOLDER_LAYER, 1);
+
while (PCB->Data->LayerN > 4)
MoveLayer (4, -1);
for (l = 0; l < 4; l++)
commit a82f26085b99bd1af02eee0f7dd5ac54e08376d4
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Use correct units when setting up the Sizes dialog.
Replace %mm with %mS so it auto-selects units, to match the scanning
that's done when you save the settings.
diff --git a/src/hid/lesstif/dialogs.c b/src/hid/lesstif/dialogs.c
index 75e4a20..5d744f9 100644
--- a/src/hid/lesstif/dialogs.c
+++ b/src/hid/lesstif/dialogs.c
@@ -1141,7 +1141,7 @@ sz_val2str (Widget w, Coord u, int pcbu)
{
static char buf[40];
if (pcbu)
- pcb_sprintf (buf, "%m+%.2mm", Settings.grid_unit->allow, u);
+ pcb_sprintf (buf, "%m+%.2mS", Settings.grid_unit->allow, u);
else
pcb_sprintf (buf, "%#mS %%", u);
XmTextSetString (w, buf);
commit 06b2b313635b7eafd6c93b8878ef842021970c85
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Avoid segfault tmp-saving partial board.
Check for both PCB and PCB->Data to avoid trying to save a backup copy
of a partially created layout.
diff --git a/src/parse_l.l b/src/parse_l.l
index 9ebb8e2..33a115d 100644
--- a/src/parse_l.l
+++ b/src/parse_l.l
@@ -278,7 +278,7 @@ static int Parse(char *Executable, char *Path, char *Filename, char *Parameter)
CreateBeLenient (true);
#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT)
- if (PCB)
+ if (PCB && PCB->Data)
SaveTMPData();
returncode = yyparse();
RemoveTMPData();
|
|
From: <gi...@gp...> - 2011-08-26 22:14:23
|
The branch, master has been updated
via 419971a4139205e6c3b6cc255b37d7124ae3165b (commit)
via 2b050ab4807e047ac3b4d09ebdd201663b723cea (commit)
from 88b7775b936512f3c6310fab9b7f08694e638ab4 (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/gtk-pcb-layer-selector.c | 122 +++++++++++++++++++++++++++++-----
src/hid/gtk/gtk-pcb-layer-selector.h | 2 +
src/hid/gtk/gui-top-window.c | 32 ++++++++-
3 files changed, 137 insertions(+), 19 deletions(-)
=================
Commit Messages
=================
commit 419971a4139205e6c3b6cc255b37d7124ae3165b
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
gtk: Sync selection with pcb state in ghid_layer_buttons_update
It was possible for PCB's active layer to come out of sync with
the selected entry in the layer selector. This fixes that.
:100644 100644 e036ef5... f8674e6... M src/hid/gtk/gui-top-window.c
commit 2b050ab4807e047ac3b4d09ebdd201663b723cea
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Support adding/deletion of layers in GtkPcbLayerSelector
If you add a layer to a GtkPcbLayerSelector, and its ID is already
in the selector, it will update the layer instead of adding a new
one. This way, we can update the layer selector by:
1. Deleting all recently-deleted and non-copper layers.
2. Re-adding all layers (including new ones)
3. Re-adding all non-copper layers (so they go to the end)
The old layer selector maintained MAX_LAYER + n layers (where n was
the number of non-copper layers), and showed/hid the gui widget to
managed deletion and adding of layers. The new one has no notion of
MAX_LAYER, nor does it care whether a layer is copper or not. :)
:100644 100644 b2b30e5... 897cd2c... M src/hid/gtk/gtk-pcb-layer-selector.c
:100644 100644 0773497... 27b0de9... M src/hid/gtk/gtk-pcb-layer-selector.h
:100644 100644 8dc10b7... e036ef5... M src/hid/gtk/gui-top-window.c
=========
Changes
=========
commit 419971a4139205e6c3b6cc255b37d7124ae3165b
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
gtk: Sync selection with pcb state in ghid_layer_buttons_update
It was possible for PCB's active layer to come out of sync with
the selected entry in the layer selector. This fixes that.
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index e036ef5..f8674e6 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1072,11 +1072,24 @@ get_layer_delete (gint layer)
void
ghid_layer_buttons_update (void)
{
+ gint layer;
+
gtk_pcb_layer_selector_delete_layers
(GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector),
get_layer_delete);
make_layer_buttons (ghidgui->layer_selector);
make_virtual_layer_buttons (ghidgui->layer_selector);
+
+ /* Sync selected layer with PCB's state */
+ if (PCB->RatDraw)
+ layer = LAYER_BUTTON_RATS;
+ else if (PCB->SilkActive)
+ layer = LAYER_BUTTON_SILK;
+ else
+ layer = LayerStack[0];
+
+ gtk_pcb_layer_selector_select_layer
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector), layer);
}
commit 2b050ab4807e047ac3b4d09ebdd201663b723cea
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Support adding/deletion of layers in GtkPcbLayerSelector
If you add a layer to a GtkPcbLayerSelector, and its ID is already
in the selector, it will update the layer instead of adding a new
one. This way, we can update the layer selector by:
1. Deleting all recently-deleted and non-copper layers.
2. Re-adding all layers (including new ones)
3. Re-adding all non-copper layers (so they go to the end)
The old layer selector maintained MAX_LAYER + n layers (where n was
the number of non-copper layers), and showed/hid the gui widget to
managed deletion and adding of layers. The new one has no notion of
MAX_LAYER, nor does it care whether a layer is copper or not. :)
diff --git a/src/hid/gtk/gtk-pcb-layer-selector.c b/src/hid/gtk/gtk-pcb-layer-selector.c
index b2b30e5..897cd2c 100644
--- a/src/hid/gtk/gtk-pcb-layer-selector.c
+++ b/src/hid/gtk/gtk-pcb-layer-selector.c
@@ -348,6 +348,9 @@ gtk_pcb_layer_selector_new (void)
* menus (assuming this is a selectable layer). For the first 20 layers,
* keyboard accelerators will be added for selection/visibility toggling.
*
+ * If the user_id passed already exists in the layer selector, that layer
+ * will have its data overwritten with the new stuff.
+ *
* \param [in] ls The selector to be acted on
* \param [in] user_id An ID used to identify the layer; will be passed to selection/visibility callbacks
* \param [in] name The name of the layer; will be used on selector and menus
@@ -364,27 +367,68 @@ gtk_pcb_layer_selector_add_layer (GtkPcbLayerSelector *ls,
gboolean activatable)
{
gchar *pname, *vname, *paccel, *vaccel;
+ gboolean new_iter = TRUE;
+ gboolean last_activatable = TRUE;
GtkTreePath *path;
GtkTreeIter iter;
- if (activatable != ls->last_activatable)
+ /* Look for existing layer with this ID */
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter))
+ do
+ {
+ gboolean is_sep, active;
+ gint read_id;
+ gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store),
+ &iter, USER_ID_COL, &read_id,
+ SEPARATOR_COL, &is_sep,
+ ACTIVATABLE_COL, &active, -1);
+ if (!is_sep)
+ {
+ last_activatable = active;
+ if(read_id == user_id)
+ {
+ new_iter = FALSE;
+ break;
+ }
+ }
+ }
+ while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter));
+
+ /* Handle separator addition */
+ if (new_iter)
{
- /* Add separator between activatable/non-activatable boundaries */
+ if (activatable != last_activatable)
+ {
+ /* Add separator between activatable/non-activatable boundaries */
+ gtk_list_store_append (ls->list_store, &iter);
+ gtk_list_store_set (ls->list_store, &iter,
+ SEPARATOR_COL, TRUE, -1);
+ }
+ /* Create new layer */
gtk_list_store_append (ls->list_store, &iter);
- gtk_list_store_set (ls->list_store, &iter, SEPARATOR_COL, TRUE, -1);
+ gtk_list_store_set (ls->list_store, &iter,
+ INDEX_COL, ls->n_actions,
+ USER_ID_COL, user_id,
+ VISIBLE_COL, visible,
+ COLOR_COL, color_string,
+ TEXT_COL, name,
+ FONT_COL, activatable ? NULL : "Italic",
+ ACTIVATABLE_COL, activatable,
+ SEPARATOR_COL, FALSE,
+ -1);
}
-
- gtk_list_store_append (ls->list_store, &iter);
- gtk_list_store_set (ls->list_store, &iter,
- INDEX_COL, ls->n_actions,
- USER_ID_COL, user_id,
- VISIBLE_COL, visible,
- COLOR_COL, color_string,
- TEXT_COL, name,
- FONT_COL, activatable ? NULL : "Italic",
- ACTIVATABLE_COL, activatable,
- SEPARATOR_COL, FALSE,
- -1);
+ else
+ gtk_list_store_set (ls->list_store, &iter,
+ VISIBLE_COL, visible,
+ COLOR_COL, color_string,
+ TEXT_COL, name,
+ FONT_COL, activatable ? NULL : "Italic",
+ ACTIVATABLE_COL, activatable,
+ -1);
+
+ /* Unless we're adding new actions, we're done now */
+ if (!new_iter)
+ return;
if (activatable && ls->n_actions == 0)
gtk_tree_selection_select_iter (ls->selection, &iter);
@@ -477,7 +521,6 @@ gtk_pcb_layer_selector_add_layer (GtkPcbLayerSelector *ls,
g_free (vname);
g_free (pname);
- ls->last_activatable = activatable;
ls->n_actions++;
}
@@ -708,4 +751,51 @@ gtk_pcb_layer_selector_update_colors (GtkPcbLayerSelector *ls,
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter));
}
+/*! \brief Deletes layers from a layer selector
+ * \par Function Description
+ * Deletes layers according to a callback function: a return value of TRUE
+ * means delete, FALSE means leave it alone. Do not try to delete all layers
+ * using this function; with nothing left to select, pcb will likely go into
+ * an infinite recursion between hid_action() and g_signal().
+ *
+ * Separators will be deleted if the layer AFTER them is deleted.
+ *
+ * \param [in] ls The selector to be acted on
+ * \param [in] callback Takes the user_id of the layer and returns a boolean
+ */
+void
+gtk_pcb_layer_selector_delete_layers (GtkPcbLayerSelector *ls,
+ gboolean (*callback)(int user_id))
+{
+ GtkTreeIter iter, last_iter;
+ gboolean needs_inc;
+ gboolean was_separator = FALSE;
+ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls->list_store), &iter);
+ do
+ {
+ gboolean sep;
+ gint user_id;
+ gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store),
+ &iter, USER_ID_COL, &user_id,
+ SEPARATOR_COL, &sep, -1);
+ /* gtk_list_store_remove will increment the iter for us, so we
+ * don't want to do it again in the loop condition */
+ needs_inc = TRUE;
+ if (!sep && callback (user_id))
+ {
+ if (gtk_list_store_remove (ls->list_store, &iter))
+ needs_inc = FALSE;
+ else
+ return;
+ if (was_separator)
+ gtk_list_store_remove (ls->list_store, &last_iter);
+ }
+ last_iter = iter;
+ was_separator = sep;
+ }
+ while (!needs_inc ||
+ gtk_tree_model_iter_next (GTK_TREE_MODEL (ls->list_store), &iter));
+}
+
+
diff --git a/src/hid/gtk/gtk-pcb-layer-selector.h b/src/hid/gtk/gtk-pcb-layer-selector.h
index 0773497..27b0de9 100644
--- a/src/hid/gtk/gtk-pcb-layer-selector.h
+++ b/src/hid/gtk/gtk-pcb-layer-selector.h
@@ -38,6 +38,8 @@ gboolean gtk_pcb_layer_selector_select_next_visible (GtkPcbLayerSelector *ls);
void gtk_pcb_layer_selector_make_selected_visible (GtkPcbLayerSelector *ls);
void gtk_pcb_layer_selector_update_colors (GtkPcbLayerSelector *ls,
const gchar *(*callback)(int user_id));
+void gtk_pcb_layer_selector_delete_layers (GtkPcbLayerSelector *ls,
+ gboolean (*callback)(int user_id));
G_END_DECLS /* keep c++ happy */
#endif
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 8dc10b7..e036ef5 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -994,8 +994,9 @@ make_cursor_position_labels (GtkWidget * hbox, GHidPort * port)
/* \brief Add "virtual layers" to a layer selector */
static void
-make_virtual_layer_buttons (GtkPcbLayerSelector *layersel)
+make_virtual_layer_buttons (GtkWidget *layer_selector)
{
+ GtkPcbLayerSelector *layersel = GTK_PCB_LAYER_SELECTOR (layer_selector);
gchar *text;
gchar *color_string;
gboolean active;
@@ -1046,7 +1047,6 @@ make_layer_buttons (GtkWidget *layersel)
gchar *text;
gchar *color_string;
gboolean active = TRUE;
- ghidgui->layer_selector = layersel;
for (i = 0; i < max_copper_layer; ++i)
{
@@ -1054,7 +1054,14 @@ make_layer_buttons (GtkWidget *layersel)
gtk_pcb_layer_selector_add_layer (GTK_PCB_LAYER_SELECTOR (layersel), i,
text, color_string, active, TRUE);
}
- make_virtual_layer_buttons (GTK_PCB_LAYER_SELECTOR (layersel));
+}
+
+
+/*! \brief callback for gtk_pcb_layer_selector_delete_layers */
+gboolean
+get_layer_delete (gint layer)
+{
+ return layer >= max_copper_layer;
}
/*! \brief Synchronize layer selector widget with current PCB state
@@ -1065,6 +1072,11 @@ make_layer_buttons (GtkWidget *layersel)
void
ghid_layer_buttons_update (void)
{
+ gtk_pcb_layer_selector_delete_layers
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector),
+ get_layer_delete);
+ make_layer_buttons (ghidgui->layer_selector);
+ make_virtual_layer_buttons (ghidgui->layer_selector);
}
@@ -1462,6 +1474,7 @@ ghid_build_pcb_top_window (void)
/* Build layer menus */
ghidgui->layer_selector = gtk_pcb_layer_selector_new ();
make_layer_buttons (ghidgui->layer_selector);
+ make_virtual_layer_buttons (ghidgui->layer_selector);
g_signal_connect (G_OBJECT (ghidgui->layer_selector), "select_layer",
G_CALLBACK (layer_selector_select_callback),
NULL);
|
|
From: <gi...@gp...> - 2011-08-26 19:30:46
|
The branch, master has been updated
via 88b7775b936512f3c6310fab9b7f08694e638ab4 (commit)
from 7937b28a5be99e9d06398c2e170dc1a4b5318749 (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/gui-drc-window.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
=================
Commit Messages
=================
commit 88b7775b936512f3c6310fab9b7f08694e638ab4
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Fix DRC preview pixmap rendering
Another hard-coded constant in the old PCB coordinate system
:100644 100644 65e64a2... 5972467... M src/hid/gtk/gui-drc-window.c
=========
Changes
=========
commit 88b7775b936512f3c6310fab9b7f08694e638ab4
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Fix DRC preview pixmap rendering
Another hard-coded constant in the old PCB coordinate system
diff --git a/src/hid/gtk/gui-drc-window.c b/src/hid/gtk/gui-drc-window.c
index 65e64a2..5972467 100644
--- a/src/hid/gtk/gui-drc-window.c
+++ b/src/hid/gtk/gui-drc-window.c
@@ -45,7 +45,7 @@
#define VIOLATION_PIXMAP_PIXEL_SIZE 100
#define VIOLATION_PIXMAP_PIXEL_BORDER 5
-#define VIOLATION_PIXMAP_PCB_SIZE 10000
+#define VIOLATION_PIXMAP_PCB_SIZE MIL_TO_COORD (100)
RCSID ("$Id$");
|
|
From: <gi...@gp...> - 2011-08-26 19:13:23
|
The branch, master has been updated
via 7937b28a5be99e9d06398c2e170dc1a4b5318749 (commit)
from 352d0fcf4ba5d5d72b9899eceb4d3ff41df3b257 (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-gdk.c | 36 ------------------------------------
1 files changed, 0 insertions(+), 36 deletions(-)
=================
Commit Messages
=================
commit 7937b28a5be99e9d06398c2e170dc1a4b5318749
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove duplicated render pass in ghid_pinout_preview_expose()
This looks like it was a copy+paste error.
:100644 100644 bf05b6b... 817a0fa... M src/hid/gtk/gtkhid-gdk.c
=========
Changes
=========
commit 7937b28a5be99e9d06398c2e170dc1a4b5318749
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove duplicated render pass in ghid_pinout_preview_expose()
This looks like it was a copy+paste error.
diff --git a/src/hid/gtk/gtkhid-gdk.c b/src/hid/gtk/gtkhid-gdk.c
index bf05b6b..817a0fa 100644
--- a/src/hid/gtk/gtkhid-gdk.c
+++ b/src/hid/gtk/gtkhid-gdk.c
@@ -1213,42 +1213,6 @@ ghid_pinout_preview_expose (GtkWidget *widget,
gport->height = save_height;
gport->view_x0 = save_left;
gport->view_y0 = save_top;
- save_top = gport->view_y0;
- save_view_width = gport->view_width;
- save_view_height = gport->view_height;
-
- /* Setup drawable and zoom factor for drawing routines
- */
- save_drawable = gport->drawable;
-
- gdk_window_get_geometry (widget->window, 0, 0, &da_w, &da_h, 0);
- xz = (double) pinout->x_max / da_w;
- yz = (double) pinout->y_max / da_h;
- if (xz > yz)
- gport->zoom = xz;
- else
- gport->zoom = yz;
-
- gport->drawable = widget->window;
- gport->width = da_w;
- gport->height = da_h;
- gport->view_width = da_w * gport->zoom;
- gport->view_height = da_h * gport->zoom;
- gport->view_x0 = (pinout->x_max - gport->view_width) / 2;
- gport->view_y0 = (pinout->y_max - gport->view_height) / 2;
-
- /* clear background */
- gdk_draw_rectangle (widget->window, priv->bg_gc, TRUE, 0, 0, da_w, da_h);
-
- /* call the drawing routine */
- hid_expose_callback (&ghid_hid, NULL, &pinout->element);
-
- gport->drawable = save_drawable;
- gport->zoom = save_zoom;
- gport->width = save_width;
- gport->height = save_height;
- gport->view_x0 = save_left;
- gport->view_y0 = save_top;
gport->view_width = save_view_width;
gport->view_height = save_view_height;
|
|
From: <gi...@gp...> - 2011-08-26 19:09:20
|
The branch, master has been updated
via 352d0fcf4ba5d5d72b9899eceb4d3ff41df3b257 (commit)
from cc9904cb4abee08306127dc85f1a8e523db5651f (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/gui-pinout-preview.c | 23 +++++++++--------------
src/hid/gtk/gui-pinout-preview.h | 2 --
2 files changed, 9 insertions(+), 16 deletions(-)
=================
Commit Messages
=================
commit 352d0fcf4ba5d5d72b9899eceb4d3ff41df3b257
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Fix pinout preview default zoom after unit conversion
Apparently the scale factor equation was dependant on the old PCB units
of 100th mils to produce a sensible zoom level.
Since this code is monumentally obtuse, just re-write something completley
new. The old code probably bit-rot when we split out the rendering widget.
Lets just suggest a fixed size of 100 pixels natural size for each 150 mil
of element bounding box. That seems to work nicely.
:100644 100644 46806da... 88576a1... M src/hid/gtk/gui-pinout-preview.c
:100644 100644 978bb25... 77fdd1b... M src/hid/gtk/gui-pinout-preview.h
=========
Changes
=========
commit 352d0fcf4ba5d5d72b9899eceb4d3ff41df3b257
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Fix pinout preview default zoom after unit conversion
Apparently the scale factor equation was dependant on the old PCB units
of 100th mils to produce a sensible zoom level.
Since this code is monumentally obtuse, just re-write something completley
new. The old code probably bit-rot when we split out the rendering widget.
Lets just suggest a fixed size of 100 pixels natural size for each 150 mil
of element bounding box. That seems to work nicely.
diff --git a/src/hid/gtk/gui-pinout-preview.c b/src/hid/gtk/gui-pinout-preview.c
index 46806da..88576a1 100644
--- a/src/hid/gtk/gui-pinout-preview.c
+++ b/src/hid/gtk/gui-pinout-preview.c
@@ -51,24 +51,19 @@
RCSID ("$Id$");
-
+/* Just define a sensible scale, lets say (for example), 100 pixel per 150 mil */
+#define SENSIBLE_VIEW_SCALE (100. / MIL_TO_COORD (150.))
static void
-pinout_zoom_fit (GhidPinoutPreview * pinout, gint zoom)
+pinout_set_view (GhidPinoutPreview * pinout)
{
- pinout->zoom = zoom;
-
- /* Should be a function I can call for this:
- */
- pinout->scale = 1.0 / (100.0 * exp (pinout->zoom * LN_2_OVER_2));
+ float scale = SENSIBLE_VIEW_SCALE;
pinout->x_max = pinout->element.BoundingBox.X2 + Settings.PinoutOffsetX;
pinout->y_max = pinout->element.BoundingBox.Y2 + Settings.PinoutOffsetY;
- pinout->w_pixels = (gint) (pinout->scale *
- (pinout->element.BoundingBox.X2 -
- pinout->element.BoundingBox.X1));
- pinout->h_pixels = (gint) (pinout->scale *
- (pinout->element.BoundingBox.Y2 -
- pinout->element.BoundingBox.Y1));
+ pinout->w_pixels = scale * (pinout->element.BoundingBox.X2 -
+ pinout->element.BoundingBox.X1);
+ pinout->h_pixels = scale * (pinout->element.BoundingBox.Y2 -
+ pinout->element.BoundingBox.Y1);
}
@@ -109,7 +104,7 @@ pinout_set_data (GhidPinoutPreview * pinout, ElementType * element)
Settings.PinoutOffsetY -
pinout->element.BoundingBox.Y1);
- pinout_zoom_fit (pinout, 3);
+ pinout_set_view (pinout);
ELEMENTLINE_LOOP (&pinout->element);
{
diff --git a/src/hid/gtk/gui-pinout-preview.h b/src/hid/gtk/gui-pinout-preview.h
index 978bb25..77fdd1b 100644
--- a/src/hid/gtk/gui-pinout-preview.h
+++ b/src/hid/gtk/gui-pinout-preview.h
@@ -52,8 +52,6 @@ struct _GhidPinoutPreview
GtkDrawingArea parent_instance;
ElementType element; /* element data to display */
- gfloat zoom; /* zoom factor of window */
- gfloat scale; /* scale factor of zoom */
gint x_max, y_max;
gint w_pixels, h_pixels; /* natural size of element preview */
};
|
|
From: <gi...@gp...> - 2011-08-26 18:50:14
|
The branch, master has been updated
via cc9904cb4abee08306127dc85f1a8e523db5651f (commit)
via 9baa48602f5253ca71301585ddd7bb1a3b761981 (commit)
via 55f95c6cd266a261961245f9571ff91bcc45c74d (commit)
from 2d21a8ad8f38e07b17450450a096f1ce4b3bef0e (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
=========
globalconst.h | 3 +
src/change.c | 4 +-
src/draw.c | 6 ++-
src/misc.c | 115 ++++++++++++++++++++++++++++++--------------------------
src/report.c | 4 +-
5 files changed, 73 insertions(+), 59 deletions(-)
=================
Commit Messages
=================
commit cc9904cb4abee08306127dc85f1a8e523db5651f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
misc.c: Rework SetTextBoundingBox() to make it more clear how it works.
Add lots of comments, change the coding style and rename variables to make
them more obvious.
:100644 100644 7c6f958... af1e58f... M src/misc.c
commit 9baa48602f5253ca71301585ddd7bb1a3b761981
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Redefine pin / pad name label text size in terms of FONT_CAPHEIGHT
This reduces the proliferation of various "magic numbers" which
combine constants from several sources and aren't appearent why
they are a particular number. There is a slight rounding error
in the converted pin label size, but it is insignificant.
:100644 100644 1315707... 7d7a594... M src/draw.c
commit 55f95c6cd266a261961245f9571ff91bcc45c74d
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Introduce global #define for the text cap-height of the PCB font.
This should save the proliferation of rather opaque MIL_TO_COORD(45)'s
in various places.
:100755 100755 1cf29b6... e85b360... M globalconst.h
:100644 100644 97154fd... 5d44355... M src/change.c
:100644 100644 deb6095... f640ef0... M src/report.c
=========
Changes
=========
commit cc9904cb4abee08306127dc85f1a8e523db5651f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
misc.c: Rework SetTextBoundingBox() to make it more clear how it works.
Add lots of comments, change the coding style and rename variables to make
them more obvious.
diff --git a/src/misc.c b/src/misc.c
index 7c6f958..af1e58f 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -497,76 +497,85 @@ SetTextBoundingBox (FontTypePtr FontPtr, TextTypePtr Text)
{
SymbolTypePtr symbol = FontPtr->Symbol;
unsigned char *s = (unsigned char *) Text->TextString;
- Coord minThick = 0;
int i;
- int space = 0;
+ int space;
Coord minx, miny, maxx, maxy, tx;
- int first_time = 1;
+ Coord min_final_radius;
+ Coord min_unscaled_radius;
+ bool first_time = true;
minx = miny = maxx = maxy = tx = 0;
- if (PCB->minSlk < PCB->minWid)
- minThick = PCB->minWid;
- else
- minThick = PCB->minSlk;
+ /* Calculate the bounding box based on the larger of the thicknesses
+ * the text might clamped at on silk or copper layers.
+ */
+ min_final_radius = MAX (PCB->minWid, PCB->minSlk) / 2;
- minThick /= Text->Scale / 50.0;
+ /* Pre-adjust the line radius for the fact we are initially computing the
+ * bounds of the un-scaled text, and the thickness clamping applies to
+ * scaled text.
+ */
+ min_unscaled_radius = min_final_radius * 100 / Text->Scale;
/* calculate size of the bounding box */
for (; s && *s; s++)
{
if (*s <= MAX_FONTPOSITION && symbol[*s].Valid)
- {
- LineTypePtr line = symbol[*s].Line;
- for (i = 0; i < symbol[*s].LineN; line++, i++)
- {
- Coord t = line->Thickness / 4;
- if (t < minThick)
- t = minThick;
-
- if (first_time)
- {
- minx = maxx = line->Point1.X;
- miny = maxy = line->Point1.Y;
- first_time = 0;
- }
+ {
+ LineTypePtr line = symbol[*s].Line;
+ for (i = 0; i < symbol[*s].LineN; line++, i++)
+ {
+ /* Clamp the width of text lines at the minimum thickness.
+ * NB: Divide 4 in thickness calculation is comprised of a factor
+ * of 1/2 to get a radius from the center-line, and a factor
+ * of 1/2 because some stupid reason we render our glyphs
+ * at half their defined stroke-width.
+ */
+ Coord unscaled_radius = MAX (min_unscaled_radius, line->Thickness / 4);
+
+ if (first_time)
+ {
+ minx = maxx = line->Point1.X;
+ miny = maxy = line->Point1.Y;
+ first_time = false;
+ }
- minx = MIN (minx, line->Point1.X - t + tx);
- miny = MIN (miny, line->Point1.Y - t);
- minx = MIN (minx, line->Point2.X - t + tx);
- miny = MIN (miny, line->Point2.Y - t);
- maxx = MAX (maxx, line->Point1.X + t + tx);
- maxy = MAX (maxy, line->Point1.Y + t);
- maxx = MAX (maxx, line->Point2.X + t + tx);
- maxy = MAX (maxy, line->Point2.Y + t);
- }
- space = symbol[*s].Delta;
- }
+ minx = MIN (minx, line->Point1.X - unscaled_radius + tx);
+ miny = MIN (miny, line->Point1.Y - unscaled_radius);
+ minx = MIN (minx, line->Point2.X - unscaled_radius + tx);
+ miny = MIN (miny, line->Point2.Y - unscaled_radius);
+ maxx = MAX (maxx, line->Point1.X + unscaled_radius + tx);
+ maxy = MAX (maxy, line->Point1.Y + unscaled_radius);
+ maxx = MAX (maxx, line->Point2.X + unscaled_radius + tx);
+ maxy = MAX (maxy, line->Point2.Y + unscaled_radius);
+ }
+ space = symbol[*s].Delta;
+ }
else
- {
- BoxType *ds = &FontPtr->DefaultSymbol;
- Coord w = ds->X2 - ds->X1;
-
- minx = MIN (minx, ds->X1 + tx);
- miny = MIN (miny, ds->Y1);
- minx = MIN (minx, ds->X2 + tx);
- miny = MIN (miny, ds->Y2);
- maxx = MAX (maxx, ds->X1 + tx);
- maxy = MAX (maxy, ds->Y1);
- maxx = MAX (maxx, ds->X2 + tx);
- maxy = MAX (maxy, ds->Y2);
-
- space = w / 5;
- }
+ {
+ BoxType *ds = &FontPtr->DefaultSymbol;
+ Coord w = ds->X2 - ds->X1;
+
+ minx = MIN (minx, ds->X1 + tx);
+ miny = MIN (miny, ds->Y1);
+ minx = MIN (minx, ds->X2 + tx);
+ miny = MIN (miny, ds->Y2);
+ maxx = MAX (maxx, ds->X1 + tx);
+ maxy = MAX (maxy, ds->Y1);
+ maxx = MAX (maxx, ds->X2 + tx);
+ maxy = MAX (maxy, ds->Y2);
+
+ space = w / 5;
+ }
tx += symbol[*s].Width + space;
}
/* scale values */
- minx *= Text->Scale / 100.;
- miny *= Text->Scale / 100.;
- maxx *= Text->Scale / 100.;
- maxy *= Text->Scale / 100.;
+ minx = minx * Text->Scale / 100;
+ miny = miny * Text->Scale / 100;
+ maxx = maxx * Text->Scale / 100;
+ maxy = maxy * Text->Scale / 100;
/* set upper-left and lower-right corner;
* swap coordinates if necessary (origin is already in 'swapped')
commit 9baa48602f5253ca71301585ddd7bb1a3b761981
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Redefine pin / pad name label text size in terms of FONT_CAPHEIGHT
This reduces the proliferation of various "magic numbers" which
combine constants from several sources and aren't appearent why
they are a particular number. There is a slight rounding error
in the converted pin label size, but it is insignificant.
diff --git a/src/draw.c b/src/draw.c
index 1315707..7d7a594 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -199,7 +199,8 @@ _draw_pv_name (PinType *pv)
gui->set_color (Output.fgGC, PCB->PinNameColor);
text.Flags = NoFlags ();
- text.Scale = 100 * pv->Thickness / MIL_TO_COORD (80);
+ /* Set font height to approx 56% of pin thickness */
+ text.Scale = 56 * pv->Thickness / FONT_CAPHEIGHT;
text.X = box.X1;
text.Y = box.Y1;
text.Direction = vert ? 1 : 0;
@@ -284,7 +285,8 @@ draw_pad_name (PadType *pad)
gui->set_color (Output.fgGC, PCB->PinNameColor);
text.Flags = NoFlags ();
- text.Scale = 100 * pad->Thickness / MIL_TO_COORD (50);
+ /* Set font height to approx 90% of pin thickness */
+ text.Scale = 90 * pad->Thickness / FONT_CAPHEIGHT;
text.X = box.X1;
text.Y = box.Y1;
text.Direction = vert ? 1 : 0;
commit 55f95c6cd266a261961245f9571ff91bcc45c74d
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Introduce global #define for the text cap-height of the PCB font.
This should save the proliferation of rather opaque MIL_TO_COORD(45)'s
in various places.
diff --git a/globalconst.h b/globalconst.h
index 1cf29b6..e85b360 100755
--- a/globalconst.h
+++ b/globalconst.h
@@ -126,4 +126,7 @@
/* to enable grid drawing */
/* size of diamond element mark */
#define EMARK_SIZE MIL_TO_COORD (10)
+
+/* (Approximate) capheight size of the default PCB font */
+#define FONT_CAPHEIGHT MIL_TO_COORD (45)
#endif
diff --git a/src/change.c b/src/change.c
index 97154fd..5d44355 100644
--- a/src/change.c
+++ b/src/change.c
@@ -839,7 +839,7 @@ static void *
ChangeTextSize (LayerTypePtr Layer, TextTypePtr Text)
{
int value = (Absolute != 0 ? Text->Scale : 0) +
- (Absolute != 0 ? Absolute : Delta) * 100 / MIL_TO_COORD (45);
+ (Absolute != 0 ? Absolute : Delta) * 100 / FONT_CAPHEIGHT;
if (TEST_FLAG (LOCKFLAG, Text))
return (NULL);
@@ -915,7 +915,7 @@ static void *
ChangeElementNameSize (ElementTypePtr Element)
{
int value = (Absolute != 0 ? DESCRIPTION_TEXT (Element).Scale : 0) +
- (Absolute != 0 ? Absolute : Delta) * 100 / MIL_TO_COORD (45);
+ (Absolute != 0 ? Absolute : Delta) * 100 / FONT_CAPHEIGHT;
if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
return (NULL);
diff --git a/src/report.c b/src/report.c
index deb6095..f640ef0 100644
--- a/src/report.c
+++ b/src/report.c
@@ -423,7 +423,7 @@ ReportDialog (int argc, char **argv, Coord x, Coord y)
EMPTY (element->Name[0].TextString),
EMPTY (element->Name[1].TextString),
EMPTY (element->Name[2].TextString),
- (Coord) (MIL_TO_COORD (45) * element->Name[1].Scale / 100.),
+ (Coord) (FONT_CAPHEIGHT * element->Name[1].Scale / 100.),
element->Name[1].X, element->Name[1].Y,
TEST_FLAG (HIDENAMEFLAG, element) ? ",\n but it's hidden" : "",
element->MarkX, element->MarkY,
@@ -464,7 +464,7 @@ ReportDialog (int argc, char **argv, Coord x, Coord y)
"The bounding box is %$mD %$mD.\n"
"%s\n"
"%s", USER_UNITMASK, text->ID, flags_to_string (text->Flags, TEXT_TYPE),
- text->X, text->Y, (Coord) (MIL_TO_COORD (45) * (float)text->Scale / 100.),
+ text->X, text->Y, (Coord) (FONT_CAPHEIGHT * (float)text->Scale / 100.),
text->TextString, text->Direction,
text->BoundingBox.X1, text->BoundingBox.Y1,
text->BoundingBox.X2, text->BoundingBox.Y2,
|
|
From: <gi...@gp...> - 2011-08-26 17:54:34
|
The branch, master has been updated
via 2d21a8ad8f38e07b17450450a096f1ce4b3bef0e (commit)
from d2458383a60b670ad1c42163ac24fcc63fcab457 (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/change.c | 8 ++++----
src/draw.c | 4 ++--
src/report.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
=================
Commit Messages
=================
commit 2d21a8ad8f38e07b17450450a096f1ce4b3bef0e
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Fix some text scale factors
This commit fixes pin / pad name drawing, the pinout preview and
two actions which change the size of text based on user input.
To recap:
Text->Scale is a percentage scaling (from the font definition). The
default font has has an approximate cap-height of 45-50 mils, and PCB
assumes this to be the case.
Text->Scale is not a Coord, it is an integer, so use int as the resulting
type for any calculations involving this number. (100% is stored as 100
in Text->scale). Code which scales text based upon other object sizes does
so by dividing to a dimensionless scale factor. We may have to be careful
about the width of intermediate results when scaling based on Coords if
Coord is changed to 64bit at some point.
ChangeTextSize() and ChangeElementNameSize accept absolute (or delta)
sizes in units of distance. These are converted to a Scale by
assuming a 100% scaled font is 45mils high. YMMV.
Oh - and just to note.. the line-thickness is drawn at half the width
stored in the font definition. This is clearly bonkers, but we would
break designs if we changed it now. Grr.
(Thanks a bunch commit 66592387176ba2578dfc14023a6fe49226f3a3df).
:100644 100644 fb6e62c... 97154fd... M src/change.c
:100644 100644 8950539... 1315707... M src/draw.c
:100644 100644 56e9be4... deb6095... M src/report.c
=========
Changes
=========
commit 2d21a8ad8f38e07b17450450a096f1ce4b3bef0e
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Fix some text scale factors
This commit fixes pin / pad name drawing, the pinout preview and
two actions which change the size of text based on user input.
To recap:
Text->Scale is a percentage scaling (from the font definition). The
default font has has an approximate cap-height of 45-50 mils, and PCB
assumes this to be the case.
Text->Scale is not a Coord, it is an integer, so use int as the resulting
type for any calculations involving this number. (100% is stored as 100
in Text->scale). Code which scales text based upon other object sizes does
so by dividing to a dimensionless scale factor. We may have to be careful
about the width of intermediate results when scaling based on Coords if
Coord is changed to 64bit at some point.
ChangeTextSize() and ChangeElementNameSize accept absolute (or delta)
sizes in units of distance. These are converted to a Scale by
assuming a 100% scaled font is 45mils high. YMMV.
Oh - and just to note.. the line-thickness is drawn at half the width
stored in the font definition. This is clearly bonkers, but we would
break designs if we changed it now. Grr.
(Thanks a bunch commit 66592387176ba2578dfc14023a6fe49226f3a3df).
diff --git a/src/change.c b/src/change.c
index fb6e62c..97154fd 100644
--- a/src/change.c
+++ b/src/change.c
@@ -838,7 +838,8 @@ ChangeArcClearSize (LayerTypePtr Layer, ArcTypePtr Arc)
static void *
ChangeTextSize (LayerTypePtr Layer, TextTypePtr Text)
{
- Coord value = (Absolute) ? Absolute / 45 : Text->Scale + Delta / 45;
+ int value = (Absolute != 0 ? Text->Scale : 0) +
+ (Absolute != 0 ? Absolute : Delta) * 100 / MIL_TO_COORD (45);
if (TEST_FLAG (LOCKFLAG, Text))
return (NULL);
@@ -913,9 +914,8 @@ ChangeElementSize (ElementTypePtr Element)
static void *
ChangeElementNameSize (ElementTypePtr Element)
{
- Coord value =
- (Absolute) ? Absolute / 45 : DESCRIPTION_TEXT (Element).Scale +
- Delta / 45;
+ int value = (Absolute != 0 ? DESCRIPTION_TEXT (Element).Scale : 0) +
+ (Absolute != 0 ? Absolute : Delta) * 100 / MIL_TO_COORD (45);
if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
return (NULL);
diff --git a/src/draw.c b/src/draw.c
index 8950539..1315707 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -199,7 +199,7 @@ _draw_pv_name (PinType *pv)
gui->set_color (Output.fgGC, PCB->PinNameColor);
text.Flags = NoFlags ();
- text.Scale = pv->Thickness / 80;
+ text.Scale = 100 * pv->Thickness / MIL_TO_COORD (80);
text.X = box.X1;
text.Y = box.Y1;
text.Direction = vert ? 1 : 0;
@@ -284,7 +284,7 @@ draw_pad_name (PadType *pad)
gui->set_color (Output.fgGC, PCB->PinNameColor);
text.Flags = NoFlags ();
- text.Scale = pad->Thickness / 50;
+ text.Scale = 100 * pad->Thickness / MIL_TO_COORD (50);
text.X = box.X1;
text.Y = box.Y1;
text.Direction = vert ? 1 : 0;
diff --git a/src/report.c b/src/report.c
index 56e9be4..deb6095 100644
--- a/src/report.c
+++ b/src/report.c
@@ -423,7 +423,7 @@ ReportDialog (int argc, char **argv, Coord x, Coord y)
EMPTY (element->Name[0].TextString),
EMPTY (element->Name[1].TextString),
EMPTY (element->Name[2].TextString),
- (Coord) (0.45 * element->Name[1].Scale * 100),
+ (Coord) (MIL_TO_COORD (45) * element->Name[1].Scale / 100.),
element->Name[1].X, element->Name[1].Y,
TEST_FLAG (HIDENAMEFLAG, element) ? ",\n but it's hidden" : "",
element->MarkX, element->MarkY,
@@ -464,7 +464,7 @@ ReportDialog (int argc, char **argv, Coord x, Coord y)
"The bounding box is %$mD %$mD.\n"
"%s\n"
"%s", USER_UNITMASK, text->ID, flags_to_string (text->Flags, TEXT_TYPE),
- text->X, text->Y, (Coord) (0.45 * MIL_TO_COORD (text->Scale)),
+ text->X, text->Y, (Coord) (MIL_TO_COORD (45) * (float)text->Scale / 100.),
text->TextString, text->Direction,
text->BoundingBox.X1, text->BoundingBox.Y1,
text->BoundingBox.X2, text->BoundingBox.Y2,
|
|
From: <gi...@gp...> - 2011-08-26 16:22:25
|
The branch, master has been updated
via d2458383a60b670ad1c42163ac24fcc63fcab457 (commit)
via 46549776f564b7060496e22cad6f660087f74908 (commit)
from 6bc04df573b6ac3f71554bdbaf6175da63add1d5 (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/action.c | 1 +
src/hid/ps/ps.c | 15 ++++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
=================
Commit Messages
=================
commit d2458383a60b670ad1c42163ac24fcc63fcab457
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
action.c: Fix missing #include "mirror.h"
:100644 100644 20dbb0a... faa1f21... M src/action.c
:100644 100644 fb9b8cc... 02448e5... M src/hid/ps/ps.c
=========
Changes
=========
commit d2458383a60b670ad1c42163ac24fcc63fcab457
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
action.c: Fix missing #include "mirror.h"
diff --git a/src/action.c b/src/action.c
index 20dbb0a..faa1f21 100644
--- a/src/action.c
+++ b/src/action.c
@@ -55,6 +55,7 @@
#include "line.h"
#include "mymem.h"
#include "misc.h"
+#include "mirror.h"
#include "move.h"
#include "polygon.h"
/*#include "print.h"*/
diff --git a/src/hid/ps/ps.c b/src/hid/ps/ps.c
index fb9b8cc..02448e5 100644
--- a/src/hid/ps/ps.c
+++ b/src/hid/ps/ps.c
@@ -840,14 +840,15 @@ ps_set_layer (const char *name, int group, int empty)
fprintf (global.f, "gsave tx ty translate 1 -1 scale 0 0 moveto ( ) show grestore newpath /ty ty ts sub def\n");
#endif
- /* If we're printing a copper layer other than the outline layer,
- and we want to "print outlines", and we have an outline layer,
+ /* If we're printing a layer other than the outline layer, and
+ we want to "print outlines", and we have an outline layer,
print the outline layer on this layer also. */
- if (global.outline
- && global.outline_layer != NULL
- && global.outline_layer != PCB->Data->Layer+idx
- && strcmp (name, "outline")
- && strcmp (name, "route"))
+ if (global.outline &&
+ global.outline_layer != NULL &&
+ global.outline_layer != PCB->Data->Layer+idx &&
+ strcmp (name, "outline") != 0 &&
+ strcmp (name, "route") != 0
+ )
{
DrawLayer (global.outline_layer, &global.region);
}
|
|
From: <gi...@gp...> - 2011-08-26 14:05:11
|
The branch, master has been updated
via 6bc04df573b6ac3f71554bdbaf6175da63add1d5 (commit)
from e256b71f5e53d5fe4e2f20c3563c1dc20a17b3a9 (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/gtk-pcb-cell-renderer-visibility.c | 11 -----------
1 files changed, 0 insertions(+), 11 deletions(-)
=================
Commit Messages
=================
commit 6bc04df573b6ac3f71554bdbaf6175da63add1d5
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove unused state variable in gtk_pcb_cell_renderer_visibility_render
This looks to be left over from development of the widget, and should
be safe to remove.
:100644 100644 5824adb... 9e8593c... M src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
=========
Changes
=========
commit 6bc04df573b6ac3f71554bdbaf6175da63add1d5
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove unused state variable in gtk_pcb_cell_renderer_visibility_render
This looks to be left over from development of the widget, and should
be safe to remove.
diff --git a/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
index 5824adb..9e8593c 100644
--- a/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
+++ b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
@@ -90,7 +90,6 @@ gtk_pcb_cell_renderer_visibility_render (GtkCellRenderer *cell,
GtkPcbCellRendererVisibility *pcb_cell;
GdkRectangle toggle_rect;
GdkRectangle draw_rect;
- GtkStateType state;
pcb_cell = GTK_PCB_CELL_RENDERER_VISIBILITY (cell);
gtk_pcb_cell_renderer_visibility_get_size (cell, widget, cell_area,
@@ -107,16 +106,6 @@ gtk_pcb_cell_renderer_visibility_render (GtkCellRenderer *cell,
if (toggle_rect.width <= 0 || toggle_rect.height <= 0)
return;
- if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
- {
- if (GTK_WIDGET_HAS_FOCUS (widget))
- state = GTK_STATE_SELECTED;
- else
- state = GTK_STATE_ACTIVE;
- }
- else
- state = GTK_STATE_NORMAL;
-
if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect))
{
GdkColor color;
|
|
From: <gi...@gp...> - 2011-08-26 13:48:20
|
The branch, master has been updated
via e256b71f5e53d5fe4e2f20c3563c1dc20a17b3a9 (commit)
via fc24e82cb90dc29f8d94ab3f8f742e3331eb28cd (commit)
via 68557094b889226e96fdc8b0532c738aa4d321c2 (commit)
via da4dfc2098aaaeaaae0163c1216180b63e2529f6 (commit)
via 30f661098d4a1ae07a55eeab61efdd3cf5c24ecf (commit)
from d78a5ad30f1ad2d183306ec0b4c0e75d9db02ef9 (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 | 45 ++++++++++++++++++++------
src/hid/gtk/gui-output-events.c | 65 ++++++++------------------------------
src/hid/gtk/gui.h | 3 +-
3 files changed, 49 insertions(+), 64 deletions(-)
=================
Commit Messages
=================
commit e256b71f5e53d5fe4e2f20c3563c1dc20a17b3a9
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Allow zooming out past the board size (up to 1/10 viewport size)
The 1/10 viewport size should be the same as the Lesstif HID allows. The
purpose of the limit is to avoid zooming in so small the PCB is lost as a
tiny dot, and also to avoid coodinate overflows when representing screen
coordinats in PCB Coords. (Since we switched to nanometers, this could
potentially raise its head more readily until we move to 64bit integers).
The explicit pan fixup added to ghid_view_zoom_fit() is required as
pan_common() no longer clamps the view back to the origin.
:100644 100644 2e258d1... f5c836c... M src/hid/gtk/gtkhid-main.c
:100644 100644 1c5327d... 81dcd45... M src/hid/gtk/gui-output-events.c
commit fc24e82cb90dc29f8d94ab3f8f742e3331eb28cd
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove ghid_port_ranges_pan for new replacement ghid_pan_view_rel
ghid_pan_view_rel() does less heavy lifting directly, sharing common
code with the other view altering routines for zooming and panning.
:100644 100644 cfb75f2... 2e258d1... M src/hid/gtk/gtkhid-main.c
:100644 100644 ba637c3... 1c5327d... M src/hid/gtk/gui-output-events.c
:100644 100644 782b147... 6fe3a04... M src/hid/gtk/gui.h
commit 68557094b889226e96fdc8b0532c738aa4d321c2
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove prototype for non-existant ghid_port_ranges_update_ranges
The functionality this prototype implies is in ghid_port_ranges_scale().
:100644 100644 134d2fb... 782b147... M src/hid/gtk/gui.h
commit da4dfc2098aaaeaaae0163c1216180b63e2529f6
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Don't recompute view size in PCB coords in ScrollAction()
We aleady keep around the view size in PCB coords, so use it directly.
:100644 100644 f5deb16... cfb75f2... M src/hid/gtk/gtkhid-main.c
commit 30f661098d4a1ae07a55eeab61efdd3cf5c24ecf
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Add fixup for stored gport->pcb_{x,y} coords when changing view
This updates the stored (in PCB coordinates) mouse pointer location on
the board as we perform a pan / zoom. This is mostly relevant to panning
and clipped zoom operations, as non-clipped zoom operations aim to leave
the mouse pointer at the same PCB coordinate anyway.
:100644 100644 dc2ea56... f5deb16... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit e256b71f5e53d5fe4e2f20c3563c1dc20a17b3a9
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Allow zooming out past the board size (up to 1/10 viewport size)
The 1/10 viewport size should be the same as the Lesstif HID allows. The
purpose of the limit is to avoid zooming in so small the PCB is lost as a
tiny dot, and also to avoid coodinate overflows when representing screen
coordinats in PCB Coords. (Since we switched to nanometers, this could
potentially raise its head more readily until we move to 64bit integers).
The explicit pan fixup added to ghid_view_zoom_fit() is required as
pan_common() no longer clamps the view back to the origin.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 2e258d1..f5c836c 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -43,11 +43,11 @@ pan_common (GHidPort *port)
* event so convert it back to event coordinates temporarily. */
ghid_pcb_to_event_coords (gport->pcb_x, gport->pcb_y, &event_x, &event_y);
- /* Don't pan so far that we see past the board edges */
- gport->view_x0 = MAX (0, gport->view_x0);
- gport->view_y0 = MAX (0, gport->view_y0);
- gport->view_x0 = MIN (gport->view_x0, PCB->MaxWidth - gport->view_width);
- gport->view_y0 = MIN (gport->view_y0, PCB->MaxHeight - gport->view_height);
+ /* Don't pan so far the board is completely off the screen */
+ port->view_x0 = MAX (-port->view_width, port->view_x0);
+ port->view_y0 = MAX (-port->view_height, port->view_y0);
+ port->view_x0 = MIN ( port->view_x0, PCB->MaxWidth);
+ port->view_y0 = MIN ( port->view_y0, PCB->MaxHeight);
/* Fix up noted event coordinates to match where we clamped. Alternatively
* we could call ghid_note_event_location (NULL); to get a new pointer
@@ -89,6 +89,7 @@ ghid_pan_view_rel (Coord dx, Coord dy)
* gport->view_width and gport->view_height are in PCB coordinates
*/
+#define ALLOW_ZOOM_OUT_BY 10 /* Arbitrary, and same as the lesstif HID */
static void
ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
{
@@ -101,7 +102,7 @@ ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
*/
min_zoom = 1;
max_zoom = MAX (PCB->MaxWidth / gport->width,
- PCB->MaxHeight / gport->height);
+ PCB->MaxHeight / gport->height) * ALLOW_ZOOM_OUT_BY;
new_zoom = MIN (MAX (min_zoom, new_zoom), max_zoom);
if (gport->zoom == new_zoom)
@@ -131,6 +132,7 @@ ghid_zoom_view_rel (Coord center_x, Coord center_y, double factor)
static void
ghid_zoom_view_fit (void)
{
+ ghid_pan_view_abs (0, 0, 0, 0);
ghid_zoom_view_abs (0, 0, MAX (PCB->MaxWidth / gport->width,
PCB->MaxHeight / gport->height));
}
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 1c5327d..81dcd45 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -81,22 +81,19 @@ ghid_port_ranges_scale (void)
gport->view_width = gport->width * gport->zoom;
gport->view_height = gport->height * gport->zoom;
- if (gport->view_width >= PCB->MaxWidth)
- gport->view_width = PCB->MaxWidth;
- if (gport->view_height >= PCB->MaxHeight)
- gport->view_height = PCB->MaxHeight;
-
adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range));
- adj->page_size = gport->view_width;
- adj->page_increment = adj->page_size/10.0;
- adj->step_increment = adj->page_size/100.0;
- adj->upper = PCB->MaxWidth;
+ adj->page_size = MIN (gport->view_width, PCB->MaxWidth);
+ adj->page_increment = adj->page_size / 10.0;
+ adj->step_increment = adj->page_size / 100.0;
+ adj->lower = -gport->view_width;
+ adj->upper = PCB->MaxWidth + adj->page_size;
adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range));
- adj->page_size = gport->view_height;
- adj->page_increment = adj->page_size/10.0;
- adj->step_increment = adj->page_size/100.0;
- adj->upper = PCB->MaxHeight;
+ adj->page_size = MIN (gport->view_height, PCB->MaxHeight);
+ adj->page_increment = adj->page_size / 10.0;
+ adj->step_increment = adj->page_size / 100.0;
+ adj->lower = -gport->view_height;
+ adj->upper = PCB->MaxHeight + adj->page_size;
}
commit fc24e82cb90dc29f8d94ab3f8f742e3331eb28cd
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove ghid_port_ranges_pan for new replacement ghid_pan_view_rel
ghid_pan_view_rel() does less heavy lifting directly, sharing common
code with the other view altering routines for zooming and panning.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index cfb75f2..2e258d1 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -72,6 +72,15 @@ ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
pan_common (gport);
}
+void
+ghid_pan_view_rel (Coord dx, Coord dy)
+{
+ gport->view_x0 += dx;
+ gport->view_y0 += dy;
+
+ pan_common (gport);
+}
+
/* gport->zoom:
* zoom value is PCB units per screen pixel. Larger numbers mean zooming
@@ -1849,7 +1858,7 @@ ScrollAction (int argc, char **argv, Coord x, Coord y)
else
AFAIL (scroll);
- ghid_port_ranges_pan (dx, dy, TRUE);
+ ghid_pan_view_rel (dx, dy);
return 0;
}
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index ba637c3..1c5327d 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -66,42 +66,6 @@ ghid_port_ranges_changed (void)
ghid_invalidate_all ();
}
-gboolean
-ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative)
-{
- GtkAdjustment *h_adj, *v_adj;
- gdouble x0, y0, x1, y1;
-
- h_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->h_range));
- v_adj = gtk_range_get_adjustment (GTK_RANGE (ghidgui->v_range));
- x0 = h_adj->value;
- y0 = v_adj->value;
-
- x1 = relative ? x + x0 : x;
- y1 = relative ? y + y0 : y;
-
- if (x1 < h_adj->lower)
- x1 = h_adj->lower;
- if (x1 > h_adj->upper - h_adj->page_size)
- x1 = h_adj->upper - h_adj->page_size;
-
- if (y1 < v_adj->lower)
- y1 = v_adj->lower;
- if (y1 > v_adj->upper - v_adj->page_size)
- y1 = v_adj->upper - v_adj->page_size;
-
- ghidgui->adjustment_changed_holdoff = TRUE;
- gtk_range_set_value (GTK_RANGE (ghidgui->h_range), x1);
- gtk_range_set_value (GTK_RANGE (ghidgui->v_range), y1);
- ghidgui->adjustment_changed_holdoff = FALSE;
-
- if ((x0 != x1) || (y0 != y1))
- ghid_port_ranges_changed();
-
- ghid_note_event_location (NULL);
- return ((x0 != x1) || (y0 != y1));
-}
-
/* Do scrollbar scaling based on current port drawing area size and
| overall PCB board size.
*/
@@ -589,7 +553,7 @@ ghid_port_window_motion_cb (GtkWidget * widget,
dx = gport->zoom * (x_prev - ev->x);
dy = gport->zoom * (y_prev - ev->y);
if (x_prev > 0)
- ghid_port_ranges_pan (dx, dy, TRUE);
+ ghid_pan_view_rel (dx, dy);
x_prev = ev->x;
y_prev = ev->y;
return FALSE;
@@ -642,9 +606,11 @@ ghid_pan_idle_cb (gpointer data)
if (gport->has_entered)
return FALSE;
+
dy = gport->zoom * y_pan_speed;
dx = gport->zoom * x_pan_speed;
- return (ghid_port_ranges_pan (dx, dy, TRUE));
+ ghid_pan_view_rel (dx, dy);
+ return TRUE;
}
gint
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 782b147..6fe3a04 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -262,7 +262,6 @@ void ghid_get_pointer (gint *, gint *);
/* gui-output-events.c function prototypes.
*/
void ghid_port_ranges_changed (void);
-gboolean ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative);
void ghid_port_ranges_scale (void);
gboolean ghid_note_event_location (GdkEventButton * ev);
@@ -504,6 +503,7 @@ void ghid_lead_user_to_location (Coord x, Coord y);
void ghid_cancel_lead_user (void);
/* gtkhid-main.c */
+void ghid_pan_view_rel (Coord dx, Coord dy);
void ghid_get_coords (const char *msg, Coord *x, Coord *y);
gint PCBChanged (int argc, char **argv, Coord x, Coord y);
commit 68557094b889226e96fdc8b0532c738aa4d321c2
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Remove prototype for non-existant ghid_port_ranges_update_ranges
The functionality this prototype implies is in ghid_port_ranges_scale().
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 134d2fb..782b147 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -264,7 +264,6 @@ void ghid_get_pointer (gint *, gint *);
void ghid_port_ranges_changed (void);
gboolean ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative);
void ghid_port_ranges_scale (void);
-void ghid_port_ranges_update_ranges (void);
gboolean ghid_note_event_location (GdkEventButton * ev);
gboolean have_crosshair_attachments (void);
commit da4dfc2098aaaeaaae0163c1216180b63e2529f6
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Don't recompute view size in PCB coords in ScrollAction()
We aleady keep around the view size in PCB coords, so use it directly.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index f5deb16..cfb75f2 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1839,13 +1839,13 @@ ScrollAction (int argc, char **argv, Coord x, Coord y)
div = atoi(argv[1]);
if (strcasecmp (argv[0], "up") == 0)
- dy = -(ghid_port.height * gport->zoom / div);
+ dy = -gport->view_height / div;
else if (strcasecmp (argv[0], "down") == 0)
- dy = ghid_port.height * gport->zoom / div;
+ dy = gport->view_height / div;
else if (strcasecmp (argv[0], "right") == 0)
- dx = ghid_port.width * gport->zoom / div;
+ dx = gport->view_width / div;
else if (strcasecmp (argv[0], "left") == 0)
- dx = -(ghid_port.width * gport->zoom / div);
+ dx = -gport->view_width / div;
else
AFAIL (scroll);
commit 30f661098d4a1ae07a55eeab61efdd3cf5c24ecf
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Add fixup for stored gport->pcb_{x,y} coords when changing view
This updates the stored (in PCB coordinates) mouse pointer location on
the board as we perform a pan / zoom. This is mostly relevant to panning
and clipped zoom operations, as non-clipped zoom operations aim to leave
the mouse pointer at the same PCB coordinate anyway.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index dc2ea56..f5deb16 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -37,12 +37,24 @@ static void ghid_zoom_view_fit (void);
static void
pan_common (GHidPort *port)
{
+ int event_x, event_y;
+
+ /* We need to fix up the PCB coordinates corresponding to the last
+ * event so convert it back to event coordinates temporarily. */
+ ghid_pcb_to_event_coords (gport->pcb_x, gport->pcb_y, &event_x, &event_y);
+
/* Don't pan so far that we see past the board edges */
gport->view_x0 = MAX (0, gport->view_x0);
gport->view_y0 = MAX (0, gport->view_y0);
gport->view_x0 = MIN (gport->view_x0, PCB->MaxWidth - gport->view_width);
gport->view_y0 = MIN (gport->view_y0, PCB->MaxHeight - gport->view_height);
+ /* Fix up noted event coordinates to match where we clamped. Alternatively
+ * we could call ghid_note_event_location (NULL); to get a new pointer
+ * location, but this costs us an xserver round-trip (on X11 platforms)
+ */
+ ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y);
+
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);
|
|
From: <gi...@gp...> - 2011-08-26 13:23:11
|
The branch, master has been updated
via d78a5ad30f1ad2d183306ec0b4c0e75d9db02ef9 (commit)
via 6b2b5df93273fd4b6c95ed65679982e39aae8f2d (commit)
from 9d40aaacebbdeaff69be5e28bbd2a186bd6bd304 (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/polygon.c | 26 +++++++++++---------------
1 files changed, 11 insertions(+), 15 deletions(-)
=================
Commit Messages
=================
commit d78a5ad30f1ad2d183306ec0b4c0e75d9db02ef9
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
polygon.c: Fix dicer to give up if the clipping region passed is invalid.
Most of the dance checking return codes from polyBoolean_free was
unnecessary, as it sets the output to NULL if there is a problem, so
remove that. Whilst we're at it, fix up some variable names to make the
operation of the function clearer.
:100644 100644 b17edf0... 14f239d... M src/polygon.c
commit 6b2b5df93273fd4b6c95ed65679982e39aae8f2d
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
polygon.c: Make RectPoly return NULL for zero or negatively sized rectangles
Previously we would hit an assertion failure, where we could indicate the
problem by returning NULL.
I've hit an issue in which some expose events in the GTK (+GL) HID are
collapsing to a zero-width region on the PCB, and some code is tripping
up on the bad clip polygon produced using RectPoly on the coordinates.
This causes segfaults in the branch which contains code to clip rendering
of the soldermask at the board outline.
We could (and perhaps should) test in the expose handler, but the failure
mode here is not ideal. Since most builds of PCB run with asserts disabled,
the asserts are not hit here and a bad polygon is silently gets created
with no contours. This upsets the polygon algebra routines somewhat, but
returning a NULL (empty) polygon would be fine.
:100644 100644 7367968... b17edf0... M src/polygon.c
=========
Changes
=========
commit d78a5ad30f1ad2d183306ec0b4c0e75d9db02ef9
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
polygon.c: Fix dicer to give up if the clipping region passed is invalid.
Most of the dance checking return codes from polyBoolean_free was
unnecessary, as it sets the output to NULL if there is a problem, so
remove that. Whilst we're at it, fix up some variable names to make the
operation of the function clearer.
diff --git a/src/polygon.c b/src/polygon.c
index b17edf0..14f239d 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -1750,29 +1750,23 @@ void
NoHolesPolygonDicer (PolygonTypePtr p, const BoxType * clip,
void (*emit) (PLINE *, void *), void *user_data)
{
- POLYAREA *save, *ans, *cur, *next;
+ POLYAREA *main_contour, *cur, *next;
- ans = save = poly_Create ();
+ main_contour = poly_Create ();
/* copy the main poly only */
- poly_Copy1 (save, p->Clipped);
+ poly_Copy1 (main_contour, p->Clipped);
/* clip to the bounding box */
if (clip)
{
POLYAREA *cbox = RectPoly (clip->X1, clip->X2, clip->Y1, clip->Y2);
- if (cbox)
- {
- int r = poly_Boolean_free (save, cbox, &ans, PBO_ISECT);
- save = ans;
- if (r != err_ok)
- save = NULL;
- }
+ poly_Boolean_free (main_contour, cbox, &main_contour, PBO_ISECT);
}
- if (!save)
+ if (main_contour == NULL)
return;
/* Now dice it up.
* NB: Could be more than one piece (because of the clip above)
*/
- cur = save;
+ cur = main_contour;
do
{
next = cur->f;
@@ -1780,7 +1774,7 @@ NoHolesPolygonDicer (PolygonTypePtr p, const BoxType * clip,
r_NoHolesPolygonDicer (cur, emit, user_data);
/* NB: The POLYAREA was freed by its use in the recursive dicer */
}
- while ((cur = next) != save);
+ while ((cur = next) != main_contour);
}
/* make a polygon split into multiple parts into multiple polygons */
commit 6b2b5df93273fd4b6c95ed65679982e39aae8f2d
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
polygon.c: Make RectPoly return NULL for zero or negatively sized rectangles
Previously we would hit an assertion failure, where we could indicate the
problem by returning NULL.
I've hit an issue in which some expose events in the GTK (+GL) HID are
collapsing to a zero-width region on the PCB, and some code is tripping
up on the bad clip polygon produced using RectPoly on the coordinates.
This causes segfaults in the branch which contains code to clip rendering
of the soldermask at the board outline.
We could (and perhaps should) test in the expose handler, but the failure
mode here is not ideal. Since most builds of PCB run with asserts disabled,
the asserts are not hit here and a bad polygon is silently gets created
with no contours. This upsets the polygon algebra routines somewhat, but
returning a NULL (empty) polygon would be fine.
diff --git a/src/polygon.c b/src/polygon.c
index 7367968..b17edf0 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -335,8 +335,10 @@ RectPoly (Coord x1, Coord x2, Coord y1, Coord y2)
PLINE *contour = NULL;
Vector v;
- assert (x2 > x1);
- assert (y2 > y1);
+ /* Return NULL for zero or negatively sized rectangles */
+ if (x2 <= x1 || y2 <= y1)
+ return NULL;
+
v[0] = x1;
v[1] = y1;
if ((contour = poly_NewContour (v)) == NULL)
|
|
From: <gi...@gp...> - 2011-08-26 05:42:45
|
The branch, master has been updated
via 9d40aaacebbdeaff69be5e28bbd2a186bd6bd304 (commit)
via bf4c0a5374ddaf8bed791daa18c7b628fb74d74a (commit)
via bf2ec895800b351c2df2bebb27c6c2860b26b66f (commit)
via 9d69c8ef2d0e6f2ce6dc8aec36151ba5785415d4 (commit)
via 9eaf239092644e3176bba20cb532ea26cfccbb08 (commit)
from ac0c3a203fc29adbf4e9e01faa86bd7b8ff2ea51 (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/flags.c | 4 +-
src/hid/gtk/gtk-pcb-cell-renderer-visibility.c | 10 ++
src/hid/gtk/gtk-pcb-coord-entry.c | 33 ++++++++
src/hid/gtk/gtk-pcb-layer-selector.c | 5 +-
src/hid/gtk/gui-config.c | 1 -
src/hid/gtk/gui-top-window.c | 1 -
src/pcb-printf.c | 106 ++++++++++++++++++++++--
7 files changed, 148 insertions(+), 12 deletions(-)
=================
Commit Messages
=================
commit 9d40aaacebbdeaff69be5e28bbd2a186bd6bd304
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
gtk: remove call to ghid_layer_buttons_color_update
The call to ghid_layer_buttons_color_update() in config_read()
is now unnecessary; the Gtk layer selection widget does not
exist, nor do the PCB struct's colors need to be synced with
the ones in the Settings struct.
So this call makes no sense. Oh, and it causes a segfault.
Also: remove color-changing debug code from gui-top-window.c
:100644 100644 f44fa25... 215f16a... M src/hid/gtk/gui-config.c
:100644 100644 001d2ca... 8dc10b7... M src/hid/gtk/gui-top-window.c
commit bf4c0a5374ddaf8bed791daa18c7b628fb74d74a
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add doxygen comments to gtk-pcb-coord-entry.c
No code changes.
:100644 100644 83dcaa0... 233dc9b... M src/hid/gtk/gtk-pcb-coord-entry.c
commit bf2ec895800b351c2df2bebb27c6c2860b26b66f
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add doxygen comments to gtk-pcb-cell-renderer-visibility.c
Also fix the file description for gtk-pcb-layer-selector.c.
No code changes.
:100644 100644 8f6d669... 5824adb... M src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
:100644 100644 519ec50... b2b30e5... M src/hid/gtk/gtk-pcb-layer-selector.c
commit 9d69c8ef2d0e6f2ce6dc8aec36151ba5785415d4
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add doxygen comments to pcb-printf.c
No code changes.
:100644 100644 422b761... 88c98ee... M src/pcb-printf.c
commit 9eaf239092644e3176bba20cb532ea26cfccbb08
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Fix const-correctness warning in flags.c
:100644 100644 954d94a... de77b68... M src/flags.c
=========
Changes
=========
commit 9d40aaacebbdeaff69be5e28bbd2a186bd6bd304
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
gtk: remove call to ghid_layer_buttons_color_update
The call to ghid_layer_buttons_color_update() in config_read()
is now unnecessary; the Gtk layer selection widget does not
exist, nor do the PCB struct's colors need to be synced with
the ones in the Settings struct.
So this call makes no sense. Oh, and it causes a segfault.
Also: remove color-changing debug code from gui-top-window.c
diff --git a/src/hid/gtk/gui-config.c b/src/hid/gtk/gui-config.c
index f44fa25..215f16a 100644
--- a/src/hid/gtk/gui-config.c
+++ b/src/hid/gtk/gui-config.c
@@ -506,7 +506,6 @@ config_colors_read (gchar * path)
}
fclose (f);
- ghid_layer_buttons_color_update ();
return TRUE;
}
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 001d2ca..8dc10b7 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1033,7 +1033,6 @@ get_layer_color (gint layer)
void
ghid_layer_buttons_color_update (void)
{
- printf ("UPDATE COLORS\n");
gtk_pcb_layer_selector_update_colors
(GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector), get_layer_color);
pcb_colors_from_settings (PCB);
commit bf4c0a5374ddaf8bed791daa18c7b628fb74d74a
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add doxygen comments to gtk-pcb-coord-entry.c
No code changes.
diff --git a/src/hid/gtk/gtk-pcb-coord-entry.c b/src/hid/gtk/gtk-pcb-coord-entry.c
index 83dcaa0..233dc9b 100644
--- a/src/hid/gtk/gtk-pcb-coord-entry.c
+++ b/src/hid/gtk/gtk-pcb-coord-entry.c
@@ -1,3 +1,14 @@
+/*! \file <gtk-pcb-coord-entry.c>
+ * \brief Implementation of GtkPcbCoordEntry widget
+ * \par Description
+ * This widget is a modified spinbox for the user to enter
+ * pcb coords. It is assigned a default unit (for display),
+ * but this can be changed by the user by typing a new one
+ * or right-clicking on the box.
+ *
+ * Internally, it keeps track of its value in pcb coords.
+ * From the user's perspective, it uses natural human units.
+ */
#include <glib.h>
#include <glib-object.h>
@@ -36,6 +47,7 @@ struct _GtkPcbCoordEntryClass
};
/* SIGNAL HANDLERS */
+/*! \brief Callback for "Change Unit" menu click */
static void
menu_item_activate_cb (GtkMenuItem *item, GtkPcbCoordEntry *ce)
{
@@ -45,6 +57,7 @@ menu_item_activate_cb (GtkMenuItem *item, GtkPcbCoordEntry *ce)
g_signal_emit (ce, gtk_pcb_coord_entry_signals[UNIT_CHANGE_SIGNAL], 0, unit);
}
+/*! \brief Callback for context menu creation */
static void
gtk_pcb_coord_entry_popup_cb (GtkPcbCoordEntry *ce, GtkMenu *menu, gpointer data)
{
@@ -77,6 +90,7 @@ gtk_pcb_coord_entry_popup_cb (GtkPcbCoordEntry *ce, GtkMenu *menu, gpointer data
gtk_widget_show (menu_item);
}
+/*! \brief Callback for user output */
static gboolean
gtk_pcb_coord_entry_output_cb (GtkPcbCoordEntry *ce, gpointer data)
{
@@ -91,6 +105,7 @@ gtk_pcb_coord_entry_output_cb (GtkPcbCoordEntry *ce, gpointer data)
return TRUE;
}
+/*! \brief Callback for user input */
static gboolean
gtk_pcb_coord_text_changed_cb (GtkPcbCoordEntry *entry, gpointer data)
{
@@ -112,6 +127,7 @@ gtk_pcb_coord_text_changed_cb (GtkPcbCoordEntry *entry, gpointer data)
return FALSE;
}
+/*! \brief Callback for change in value (input or ^v clicks) */
static gboolean
gtk_pcb_coord_value_changed_cb (GtkPcbCoordEntry *ce, gpointer data)
{
@@ -126,6 +142,11 @@ gtk_pcb_coord_value_changed_cb (GtkPcbCoordEntry *ce, gpointer data)
return FALSE;
}
+/*! \brief Change the unit used by a coord entry
+ *
+ * \param [in] ce The entry to be acted on
+ * \parin [in] new_unit The new unit to be used
+ */
static void
gtk_pcb_coord_entry_change_unit (GtkPcbCoordEntry *ce, const Unit *new_unit)
{
@@ -215,6 +236,16 @@ gtk_pcb_coord_entry_get_type (void)
return ce_type;
}
+/*! \brief Create a new GtkPcbCoordEntry
+ *
+ * \param [in] min_val The minimum allowed value, in pcb coords
+ * \param [in] max_val The maximum allowed value, in pcb coords
+ * \param [in] value The default value, in pcb coords
+ * \param [in] unit The default unit
+ * \param [in] step_size How large the default increments should be
+ *
+ * \return a freshly-allocated GtkPcbCoordEntry
+ */
GtkWidget *
gtk_pcb_coord_entry_new (Coord min_val, Coord max_val, Coord value,
const Unit *unit, enum ce_step_size step_size)
@@ -264,12 +295,14 @@ gtk_pcb_coord_entry_new (Coord min_val, Coord max_val, Coord value,
return GTK_WIDGET (ce);
}
+/*! \brief Gets a GtkPcbCoordEntry's value, in pcb coords */
Coord
gtk_pcb_coord_entry_get_value (GtkPcbCoordEntry *ce)
{
return ce->value;
}
+/*! \brief Sets a GtkPcbCoordEntry's value, in pcb coords */
void
gtk_pcb_coord_entry_set_value (GtkPcbCoordEntry *ce, Coord val)
{
commit bf2ec895800b351c2df2bebb27c6c2860b26b66f
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add doxygen comments to gtk-pcb-cell-renderer-visibility.c
Also fix the file description for gtk-pcb-layer-selector.c.
No code changes.
diff --git a/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
index 8f6d669..5824adb 100644
--- a/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
+++ b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
@@ -1,3 +1,10 @@
+/*! \file <gtk-pcb-cell-render-visibility.c>
+ * \brief Implementation of GtkCellRenderer for layer visibility toggler
+ * \par More Information
+ * For details on the functions implemented here, see the Gtk
+ * documentation for the GtkCellRenderer object, which defines
+ * the interface we are implementing.
+ */
#include <glib.h>
#include <glib-object.h>
@@ -35,6 +42,7 @@ struct _GtkPcbCellRendererVisibilityClass
};
/* RENDERER FUNCTIONS */
+/*! \brief Calculates the window area the renderer will use */
static void
gtk_pcb_cell_renderer_visibility_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
@@ -69,6 +77,7 @@ gtk_pcb_cell_renderer_visibility_get_size (GtkCellRenderer *cell,
}
}
+/*! \brief Actually renders the swatch */
static void
gtk_pcb_cell_renderer_visibility_render (GtkCellRenderer *cell,
GdkWindow *window,
@@ -144,6 +153,7 @@ gtk_pcb_cell_renderer_visibility_render (GtkCellRenderer *cell,
}
}
+/*! \brief Toggless the swatch */
static gint
gtk_pcb_cell_renderer_visibility_activate (GtkCellRenderer *cell,
GdkEvent *event,
diff --git a/src/hid/gtk/gtk-pcb-layer-selector.c b/src/hid/gtk/gtk-pcb-layer-selector.c
index 519ec50..b2b30e5 100644
--- a/src/hid/gtk/gtk-pcb-layer-selector.c
+++ b/src/hid/gtk/gtk-pcb-layer-selector.c
@@ -1,7 +1,10 @@
/*! \file <gtk-pcb-layer-selector.c>
* \brief Implementation of GtkPcbLayerSelector widget
* \par Description
- * This widget is used for
+ * This widget is the layer selector on the left side of the Gtk
+ * GUI. It also describes (in XML) the relevant sections of the
+ * menu for layer selection and visibility toggling, and makes
+ * sure these stay in sync.
*/
#include <glib.h>
commit 9d69c8ef2d0e6f2ce6dc8aec36151ba5785415d4
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add doxygen comments to pcb-printf.c
No code changes.
diff --git a/src/pcb-printf.c b/src/pcb-printf.c
index 422b761..88c98ee 100644
--- a/src/pcb-printf.c
+++ b/src/pcb-printf.c
@@ -24,6 +24,13 @@
*
*/
+/*! \file <pcb-printf.c>
+ * \brief Implementation of printf wrapper to output pcb coords and angles
+ * \par Description
+ * For details of all supported specifiers, see the comment at the
+ * top of pcb-printf.h
+ */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -74,8 +81,12 @@ static Unit Units[] = {
{ "pcb" } }
};
#define N_UNITS ((int) (sizeof Units / sizeof Units[0]))
-/* The function is needed to avoid "non-constant initializer"
- * errors on the internationalized unit suffixes. */
+/* \brief Initialize non-static data for pcb-printf
+ * \par Function Description
+ * Assigns each unit its index for quick access through the
+ * main units array, and internationalize the units for GUI
+ * display.
+ */
void initialize_units()
{
int i;
@@ -85,6 +96,7 @@ void initialize_units()
Units[i].in_suffix = _(Units[i].suffix);
}
}
+
/* This list -must- contain all printable units from the above list */
/* For now I have just copy/pasted the same values for all metric
* units and the same values for all imperial ones */
@@ -135,7 +147,16 @@ static Increments increments[] = {
};
#define N_INCREMENTS (sizeof increments / sizeof increments[0])
-/* Obtain a unit object from its (non-international) suffix */
+/* \brief Obtain a unit object from its suffix
+ * \par Function Description
+ * Looks up a given suffix in the main units array. Internationalized
+ * unit suffixes are not supported, though pluralized units are, for
+ * backward-compatibility.
+ *
+ * \param [in] const_suffix The suffix to look up
+ *
+ * \return A const pointer to the Unit struct, or NULL if none was found
+ */
const Unit *get_unit_struct (const char *const_suffix)
{
int i;
@@ -174,16 +195,26 @@ const Unit *get_unit_struct (const char *const_suffix)
}
/* ACCESSORS */
+/* \brief Returns the master unit list. This may not be modified. */
const Unit *get_unit_list (void)
{
return Units;
}
+/* \brief Returns the length of the master unit list. */
int get_n_units (void)
{
return N_UNITS;
}
-/* Obtain a increment object from its (non-international) suffix */
+/* \brief Obtain an increment object from its suffix
+ * \par Function Description
+ * Looks up a given suffix in the main increments array. Internationalized
+ * unit suffixes are not supported, nor are pluralized units.
+ *
+ * \param [in] suffix The suffix to look up
+ *
+ * \return A const pointer to the Increments struct, or NULL if none was found
+ */
Increments *get_increments_struct (const char *suffix)
{
int i;
@@ -194,7 +225,13 @@ Increments *get_increments_struct (const char *suffix)
return NULL;
}
-/* Scale factor lookup functions for Unit[] table */
+/* \brief Convert a pcb coord to the given unit
+ *
+ * \param [in] unit The unit to convert to
+ * \param [in] x The quantity to convert
+ *
+ * \return The converted measure
+ */
double coord_to_unit (const Unit *unit, Coord x)
{
double base;
@@ -206,6 +243,13 @@ double coord_to_unit (const Unit *unit, Coord x)
return x * unit->scale_factor * base;
}
+/* \brief Convert a given unit to pcb coords
+ *
+ * \param [in] unit The unit to convert from
+ * \param [in] x The quantity to convert
+ *
+ * \return The converted measure
+ */
Coord unit_to_coord (const Unit *unit, double x)
{
return x / coord_to_unit (unit, 1);
@@ -227,10 +271,21 @@ static int min_sig_figs(double d)
return rv;
}
-/* Converts a (group of) measurement(s) to a comma-deliminated
+/* \brief Internal coord-to-string converter for pcb-printf
+ * \par Function Description
+ * Converts a (group of) measurement(s) to a comma-deliminated
* string, with appropriate units. If more than one coord is
* given, the list is enclosed in parens to make the scope of
- * the unit suffix clear. */
+ * the unit suffix clear.
+ *
+ * \param [in] coord Array of coords to convert
+ * \param [in] n_coords Number of coords in array
+ * \param [in] printf_spec printf sub-specifier to use with %f
+ * \param [in] e_allow Bitmap of units the function may use
+ * \param [in] suffix_type Whether to add a suffix
+ *
+ * \return A string containing the formatted coords. Must be freed with g_free.
+ */
static gchar *CoordsToString(Coord coord[], int n_coords, const char *printf_spec, enum e_allow allow, enum e_suffix suffix_type)
{
GString *buff;
@@ -368,6 +423,17 @@ static gchar *CoordsToString(Coord coord[], int n_coords, const char *printf_spe
return g_string_free (buff, FALSE);
}
+/* \brief Main pcb-printf function
+ * \par Function Description
+ * This is a printf wrapper that accepts new format specifiers to
+ * output pcb coords as various units. See the comment at the top
+ * of pcb-printf.h for full details.
+ *
+ * \param [in] fmt Format specifier
+ * \param [in] args Arguments to specifier
+ *
+ * \return A formatted string. Must be freed with g_free.
+ */
gchar *pcb_vprintf(const char *fmt, va_list args)
{
GString *string = g_string_new ("");
@@ -547,6 +613,13 @@ gchar *pcb_vprintf(const char *fmt, va_list args)
}
+/* \brief Wrapper for pcb_vprintf that outputs to a string
+ *
+ * \param [in] string Pointer to string to output into
+ * \param [in] fmt Format specifier
+ *
+ * \return The length of the written string
+ */
int pcb_sprintf(char *string, const char *fmt, ...)
{
gchar *tmp;
@@ -562,6 +635,13 @@ int pcb_sprintf(char *string, const char *fmt, ...)
return strlen (string);
}
+/* \brief Wrapper for pcb_vprintf that outputs to a file
+ *
+ * \param [in] fh File to output to
+ * \param [in] fmt Format specifier
+ *
+ * \return The length of the written string
+ */
int pcb_fprintf(FILE *fh, const char *fmt, ...)
{
int rv;
@@ -583,6 +663,12 @@ int pcb_fprintf(FILE *fh, const char *fmt, ...)
return rv;
}
+/* \brief Wrapper for pcb_vprintf that outputs to stdout
+ *
+ * \param [in] fmt Format specifier
+ *
+ * \return The length of the written string
+ */
int pcb_printf(const char *fmt, ...)
{
int rv;
@@ -599,6 +685,12 @@ int pcb_printf(const char *fmt, ...)
return rv;
}
+/* \brief Wrapper for pcb_vprintf that outputs to a newly allocated string
+ *
+ * \param [in] fmt Format specifier
+ *
+ * \return The newly allocated string. Must be freed with g_free.
+ */
char *pcb_g_strdup_printf(const char *fmt, ...)
{
gchar *tmp;
commit 9eaf239092644e3176bba20cb532ea26cfccbb08
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Fix const-correctness warning in flags.c
diff --git a/src/flags.c b/src/flags.c
index 954d94a..de77b68 100644
--- a/src/flags.c
+++ b/src/flags.c
@@ -74,7 +74,7 @@ FlagGridSize (int dummy)
static int
FlagUnitsMm (int dummy)
{
- static Unit *u = NULL;
+ static const Unit *u = NULL;
if (u == NULL)
u = get_unit_struct ("mm");
return (Settings.grid_unit == u);
@@ -83,7 +83,7 @@ FlagUnitsMm (int dummy)
static int
FlagUnitsMil (int dummy)
{
- static Unit *u = NULL;
+ static const Unit *u = NULL;
if (u == NULL)
u = get_unit_struct ("mil");
return (Settings.grid_unit == u);
|
|
From: <gi...@gp...> - 2011-08-26 02:27:03
|
The branch, master has been updated
via ac0c3a203fc29adbf4e9e01faa86bd7b8ff2ea51 (commit)
from 2948179e8c693f2ca8666e0ca212198254e76285 (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
=========
globalconst.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
=================
Commit Messages
=================
commit ac0c3a203fc29adbf4e9e01faa86bd7b8ff2ea51
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Make EMARK_SIZE unit-agnostic
Closes-bug: lp-832455
:100755 100755 6599823... 1cf29b6... M globalconst.h
=========
Changes
=========
commit ac0c3a203fc29adbf4e9e01faa86bd7b8ff2ea51
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Make EMARK_SIZE unit-agnostic
Closes-bug: lp-832455
diff --git a/globalconst.h b/globalconst.h
index 6599823..1cf29b6 100755
--- a/globalconst.h
+++ b/globalconst.h
@@ -125,5 +125,5 @@
#define MIN_GRID_DISTANCE 4 /* minimum distance between point */
/* to enable grid drawing */
/* size of diamond element mark */
-#define EMARK_SIZE 1000
+#define EMARK_SIZE MIL_TO_COORD (10)
#endif
|
|
From: <gi...@gp...> - 2011-08-26 02:02:52
|
The branch, master has been updated
via 2948179e8c693f2ca8666e0ca212198254e76285 (commit)
via 6d50fc7871acdddd8f319d1fd21a08d0784c9af8 (commit)
via 12771c69eee43cd5f275a64a031f3947ab172d77 (commit)
from c4df558415e977e406522bfce59c63e5518f4cfa (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/Makefile.am | 4 +
src/hid/gtk/gtk-pcb-cell-renderer-visibility.c | 296 +++++++++
src/hid/gtk/gtk-pcb-cell-renderer-visibility.h | 24 +
src/hid/gtk/gtk-pcb-layer-selector.c | 708 ++++++++++++++++++++++
src/hid/gtk/gtk-pcb-layer-selector.h | 43 ++
src/hid/gtk/gui-top-window.c | 769 +++++-------------------
src/hid/gtk/gui.h | 3 +-
7 files changed, 1242 insertions(+), 605 deletions(-)
create mode 100644 src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
create mode 100644 src/hid/gtk/gtk-pcb-cell-renderer-visibility.h
create mode 100644 src/hid/gtk/gtk-pcb-layer-selector.c
create mode 100644 src/hid/gtk/gtk-pcb-layer-selector.h
=================
Commit Messages
=================
commit 2948179e8c693f2ca8666e0ca212198254e76285
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Use GtkPcbLayerSelector in gtk GUI
Closes-bug: lp-699482
:100644 100644 4e9ae27... 001d2ca... M src/hid/gtk/gui-top-window.c
:100644 100644 9bed4d9... 134d2fb... M src/hid/gtk/gui.h
commit 6d50fc7871acdddd8f319d1fd21a08d0784c9af8
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Introduce GtkPcbLayerSelector widget -- not used yet
This widget will replace the layer-selection buttons in the
Gtk GUI, as well as the layer selection and visibility-toggling
parts of the menu.
This is to make layer manipulation more consistent and
more keyboard-accessible.
In future, it would be good to update this widget with context
menus with things like "hide all but this layer".
:100644 100644 9df4a50... d4c37e0... M src/Makefile.am
:000000 100644 0000000... 8f6d669... A src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
:000000 100644 0000000... 212c4a4... A src/hid/gtk/gtk-pcb-cell-renderer-visibility.h
:000000 100644 0000000... 519ec50... A src/hid/gtk/gtk-pcb-layer-selector.c
:000000 100644 0000000... 0773497... A src/hid/gtk/gtk-pcb-layer-selector.h
commit 12771c69eee43cd5f275a64a031f3947ab172d77
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Change Gtk layer_process() to use colors from Settings, not PCB
Now the only code that uses the colors in the PCB struct is
draw.c. Hopefully in a future commit we can remove this too
and remove the duplication of color data in the Settings and
PCB structs.
:100644 100644 aaab38e... 4e9ae27... M src/hid/gtk/gui-top-window.c
=========
Changes
=========
commit 2948179e8c693f2ca8666e0ca212198254e76285
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Use GtkPcbLayerSelector in gtk GUI
Closes-bug: lp-699482
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 4e9ae27..001d2ca 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -82,6 +82,7 @@ a zoom in/out.
#include <locale.h>
#endif
+#include "gtk-pcb-layer-selector.h"
#include "gtkhid.h"
#include "gui.h"
#include "hid.h"
@@ -157,17 +158,6 @@ typedef struct
}
RouteStyleButton;
-/* Used by the layer buttons */
-typedef struct
-{
- GtkWidget *radio_select_button,
- *layer_enable_button, *layer_enable_ebox, *label;
- gchar *text;
- gint index;
-}
-LayerButtonSet;
-
-
/* ---------------------------------------------------------------------------
* local macros
*/
@@ -197,22 +187,12 @@ static gint tmenuitem_cnt = 0;
static Resource **action_resources = NULL;
static Resource **toggle_action_resources = NULL;
-/* actions for the @layerview menuitems */
-static GtkToggleActionEntry layerview_toggle_entries[N_LAYER_BUTTONS];
-static Resource *layerview_resources[N_LAYER_BUTTONS];
-
-/* actions for the @layerpick menuitems */
-static GtkToggleActionEntry layerpick_toggle_entries[N_LAYER_BUTTONS];
-static Resource *layerpick_resources[N_LAYER_BUTTONS];
-
/* actions for the @routestyles menuitems */
static GtkToggleActionEntry routestyle_toggle_entries[N_ROUTE_STYLES];
static Resource *routestyle_resources[N_ROUTE_STYLES];
#define MENUITEM "MenuItem"
#define TMENUITEM "TMenuItem"
-#define LAYERPICK "LayerPick"
-#define LAYERVIEW "LayerView"
#define ROUTESTYLE "RouteStyle"
@@ -367,21 +347,6 @@ ghid_update_toggle_flags ()
}
}
-
- /* FIXME -- this probably needs to go somewhere else */
-#ifdef notdef
- for (i = 0; i < N_LAYER_BUTTONS; i++)
- {
- sprintf (tmpnm, "%s%d", LAYERVIEW, i);
- a = gtk_action_group_get_action (ghidgui->main_actions, tmpnm);
- if (a != NULL)
- {
- g_object_set_property (G_OBJECT (a), "visible", (i >= max_copper_layer && i < MAX_LAYER) ? &setfalse : &settrue);
- }
-
- }
-#endif
-
for (i = 0; i < N_ROUTE_STYLES; i++)
{
sprintf (tmpnm, "%s%d", ROUTESTYLE, i);
@@ -523,24 +488,6 @@ ghid_menu_cb (GtkAction * action, gpointer data)
else
node = toggle_action_resources[id];
}
- else if ( strncmp (name, LAYERPICK, strlen (LAYERPICK)) == 0)
- {
- id = atoi (name + strlen (LAYERPICK));
-
- if (ghidgui->toggle_holdoff == TRUE)
- node = NULL;
- else
- node = layerpick_resources[id];
- }
- else if ( strncmp (name, LAYERVIEW, strlen (LAYERVIEW)) == 0)
- {
- id = atoi (name + strlen (LAYERVIEW));
-
- if (ghidgui->toggle_holdoff == TRUE)
- node = NULL;
- else
- node = layerview_resources[id];
- }
else if ( strncmp (name, ROUTESTYLE, strlen (ROUTESTYLE)) == 0)
{
id = atoi (name + strlen (ROUTESTYLE));
@@ -730,6 +677,84 @@ layer_process (gchar **color_string, char **text, int *set, int i)
}
}
+/*! \brief Callback for GtkPcbLayerSelector layer selection */
+static void
+layer_selector_select_callback (GtkPcbLayerSelector *ls, int layer, gpointer d)
+{
+ gboolean active;
+ layer_process (NULL, NULL, &active, layer);
+
+ /* Select Layer */
+ PCB->SilkActive = (layer == LAYER_BUTTON_SILK);
+ PCB->RatDraw = (layer == LAYER_BUTTON_RATS);
+ if (layer < max_copper_layer)
+ ChangeGroupVisibility (layer, true, true);
+
+ /* Ensure layer is turned on */
+ gtk_pcb_layer_selector_make_selected_visible (ls);
+
+ ghid_invalidate_all ();
+}
+
+/*! \brief Callback for GtkPcbLayerSelector layer toggling */
+static void
+layer_selector_toggle_callback (GtkPcbLayerSelector *ls, int layer, gpointer d)
+{
+ gboolean redraw = FALSE;
+ gboolean active;
+ layer_process (NULL, NULL, &active, layer);
+
+ active = !active;
+ switch (layer)
+ {
+ case LAYER_BUTTON_SILK:
+ PCB->ElementOn = active;
+ PCB->Data->SILKLAYER.On = PCB->ElementOn;
+ PCB->Data->BACKSILKLAYER.On = PCB->ElementOn;
+ redraw = 1;
+ break;
+ case LAYER_BUTTON_RATS:
+ PCB->RatOn = active;
+ redraw = 1;
+ break;
+ case LAYER_BUTTON_PINS:
+ PCB->PinOn = active;
+ redraw |= (PCB->Data->ElementN != 0);
+ break;
+ case LAYER_BUTTON_VIAS:
+ PCB->ViaOn = active;
+ redraw |= (PCB->Data->ViaN != 0);
+ break;
+ case LAYER_BUTTON_FARSIDE:
+ PCB->InvisibleObjectsOn = active;
+ PCB->Data->BACKSILKLAYER.On = (active && PCB->ElementOn);
+ redraw = TRUE;
+ break;
+ case LAYER_BUTTON_MASK:
+ if (active)
+ SET_FLAG (SHOWMASKFLAG, PCB);
+ else
+ CLEAR_FLAG (SHOWMASKFLAG, PCB);
+ redraw = TRUE;
+ break;
+ default:
+ /* Flip the visibility */
+ ChangeGroupVisibility (layer, active, false);
+ redraw = TRUE;
+ break;
+ }
+
+ /* Jump through hoops in case we just disabled the active layer
+ * (or its group). In this case, select a different one if we
+ * can. If we can't, turn the original layer back on.
+ */
+ if (!gtk_pcb_layer_selector_select_next_visible (ls))
+ gtk_pcb_layer_selector_toggle_layer (ls, layer);
+
+ if (redraw)
+ ghid_invalidate_all();
+}
+
/*
* The intial loading of all actions at startup.
*/
@@ -737,69 +762,10 @@ static void
ghid_make_programmed_menu_actions ()
{
int i;
- gchar * text;
-
Resource *ar;
char av[64];
- for (i = 0; i < N_LAYER_BUTTONS; i++)
- {
- layer_process (NULL, &text, NULL, i);
-#ifdef DEBUG_MENUS
- printf ("ghid_make_programmed_menu_actions(): Added #%2d \"%s\". max_copper_layer = %d, MAX_LAYER = %d\n", i, text, max_copper_layer, MAX_LAYER);
-#endif
- /* name, stock_id, label, accelerator, tooltip, callback */
- layerview_toggle_entries[i].name = g_strdup_printf ("%s%d", LAYERVIEW, i);
- layerview_toggle_entries[i].stock_id = NULL;
- layerview_toggle_entries[i].label = g_strdup (text);
- layerview_toggle_entries[i].accelerator = NULL;
- layerview_toggle_entries[i].tooltip = NULL;
- layerview_toggle_entries[i].callback = G_CALLBACK (ghid_menu_cb);
- layerview_toggle_entries[i].is_active = FALSE;
-
- ar = resource_create (0);
- sprintf (av, "ToggleView(%d)", i + 1);
- resource_add_val (ar, 0, strdup (av), 0);
- resource_add_val (ar, 0, strdup (av), 0);
- ar->flags |= FLAG_V;
- layerview_resources[i] = ar;
-
- /* name, stock_id, label, accelerator, tooltip, callback */
- layerpick_toggle_entries[i].name = g_strdup_printf ("%s%d", LAYERPICK, i);
- layerpick_toggle_entries[i].stock_id = NULL;
- layerpick_toggle_entries[i].label = g_strdup (text);
- layerpick_toggle_entries[i].accelerator = NULL;
- layerpick_toggle_entries[i].tooltip = NULL;
- layerpick_toggle_entries[i].callback = G_CALLBACK (ghid_menu_cb);
- layerpick_toggle_entries[i].is_active = FALSE;
-
- ar = resource_create (0);
-
- switch (i)
- {
- case LAYER_BUTTON_SILK:
- sprintf (av, "SelectLayer(Silk) LayersChanged()");
- if (max_copper_layer < 9)
- layerpick_toggle_entries[i].accelerator = g_strdup_printf ("<Key>%d", max_copper_layer + 1);
- break;
- case LAYER_BUTTON_RATS:
- if (max_copper_layer < 8)
- layerpick_toggle_entries[i].accelerator = g_strdup_printf ("<Key>%d", max_copper_layer + 2);
- sprintf (av, "SelectLayer(Rats) LayersChanged()");
- break;
- default:
- sprintf (av, "SelectLayer(%d) LayersChanged()", i + 1);
- if (i < 9 && i < max_copper_layer)
- layerpick_toggle_entries[i].accelerator = g_strdup_printf ("<Key>%d", i + 1);
- break;
- }
- resource_add_val (ar, 0, strdup (av), 0);
- resource_add_val (ar, 0, strdup (av), 0);
- ar->flags |= FLAG_V;
- layerpick_resources[i] = ar;
- }
-
- for (i = 0; i < N_ROUTE_STYLES; i++)
+ for (i = 0; i < N_ROUTE_STYLES; i++)
{
routestyle_toggle_entries[i].name = g_strdup_printf ("%s%d", ROUTESTYLE, i);
routestyle_toggle_entries[i].stock_id = NULL;
@@ -840,14 +806,6 @@ make_menu_actions (GtkActionGroup * actions, GHidPort * port)
ghid_make_programmed_menu_actions ();
- gtk_action_group_add_toggle_actions (actions,
- layerpick_toggle_entries,
- N_LAYER_BUTTONS, port);
-
- gtk_action_group_add_toggle_actions (actions,
- layerview_toggle_entries,
- N_LAYER_BUTTONS, port);
-
gtk_action_group_add_toggle_actions (actions,
routestyle_toggle_entries,
N_ROUTE_STYLES, port);
@@ -865,6 +823,7 @@ make_top_menubar (GtkWidget * hbox, GHidPort * port)
GtkUIManager *ui;
GtkWidget *frame;
GtkActionGroup *actions;
+ GtkActionGroup *layer_actions;
GError *error = NULL;
frame = gtk_frame_new (NULL);
@@ -879,8 +838,11 @@ make_top_menubar (GtkWidget * hbox, GHidPort * port)
ghidgui->main_actions = actions;
make_menu_actions (actions, port);
-
+ layer_actions = gtk_pcb_layer_selector_get_action_group
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector));
+
gtk_ui_manager_insert_action_group (ui, actions, 0);
+ gtk_ui_manager_insert_action_group (ui, layer_actions, 0);
gtk_window_add_accel_group (GTK_WINDOW (gport->top_window),
gtk_ui_manager_get_accel_group (ui));
@@ -1030,474 +992,80 @@ make_cursor_position_labels (GtkWidget * hbox, GHidPort * port)
}
-
- /* ------------------------------------------------------------------
- | Handle the layer buttons.
- */
-static LayerButtonSet layer_buttons[N_LAYER_BUTTONS];
-
-static gint layer_select_button_index;
-
-static gboolean layer_enable_button_cb_hold_off,
- layer_select_button_cb_hold_off;
-
-static void
-layer_select_button_cb (GtkWidget * widget, LayerButtonSet * lb)
-{
- gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
- static gboolean in_cb = FALSE;
-
- if (!active || layer_select_button_cb_hold_off || in_cb)
- return;
-
- in_cb = TRUE;
-
- PCB->SilkActive = (lb->index == LAYER_BUTTON_SILK);
- PCB->RatDraw = (lb->index == LAYER_BUTTON_RATS);
-
- if (lb->index < max_copper_layer)
- ChangeGroupVisibility (lb->index, true, true);
-
- layer_select_button_index = lb->index;
-
- layer_select_button_cb_hold_off = TRUE;
- layer_enable_button_cb_hold_off = TRUE;
- ghid_layer_buttons_update ();
- layer_select_button_cb_hold_off = FALSE;
- layer_enable_button_cb_hold_off = FALSE;
-
- ghid_invalidate_all ();
- in_cb = FALSE;
-}
-
+/* \brief Add "virtual layers" to a layer selector */
static void
-layer_enable_button_cb (GtkWidget * widget, gpointer data)
+make_virtual_layer_buttons (GtkPcbLayerSelector *layersel)
{
- gint i, group, layer = GPOINTER_TO_INT (data);
- gboolean active, redraw = FALSE;
-
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- if (layer_enable_button_cb_hold_off)
- return;
-
- switch (layer)
- {
- case LAYER_BUTTON_SILK:
- PCB->ElementOn = active;
- PCB->Data->SILKLAYER.On = PCB->ElementOn;
- PCB->Data->BACKSILKLAYER.On = PCB->ElementOn;
- redraw = 1;
- break;
-
- case LAYER_BUTTON_RATS:
- PCB->RatOn = active;
- redraw = 1;
- break;
-
- case LAYER_BUTTON_PINS:
- PCB->PinOn = active;
- redraw |= (PCB->Data->ElementN != 0);
- break;
-
- case LAYER_BUTTON_VIAS:
- PCB->ViaOn = active;
- redraw |= (PCB->Data->ViaN != 0);
- break;
-
- case LAYER_BUTTON_FARSIDE:
- PCB->InvisibleObjectsOn = active;
- PCB->Data->BACKSILKLAYER.On = (active && PCB->ElementOn);
- redraw = TRUE;
- break;
-
- case LAYER_BUTTON_MASK:
- if (active)
- SET_FLAG (SHOWMASKFLAG, PCB);
- else
- CLEAR_FLAG (SHOWMASKFLAG, PCB);
- redraw = TRUE;
- break;
-
- default:
- /* check if active layer is in the group;
- | if YES, make a different one active if possible. Logic from
- | Xt PCB code.
- */
- if ((group = GetGroupOfLayer (layer)) ==
- GetGroupOfLayer (MIN (max_copper_layer, INDEXOFCURRENT)))
- {
- for (i = (layer + 1) % (max_copper_layer + 1); i != layer;
- i = (i + 1) % (max_copper_layer + 1))
- if (PCB->Data->Layer[i].On == true &&
- GetGroupOfLayer (i) != group)
- break;
- if (i != layer)
- {
- ChangeGroupVisibility ((int) i, true, true);
- }
- else
- {
- /* everything else off, we can't turn this off too */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- return;
- }
- }
- /* switch layer group on/off */
- ChangeGroupVisibility (layer, active, false);
- redraw = TRUE;
- break;
- }
-
- layer_select_button_cb_hold_off = TRUE;
- layer_enable_button_cb_hold_off = TRUE;
- ghid_layer_buttons_update ();
- layer_select_button_cb_hold_off = FALSE;
- layer_enable_button_cb_hold_off = FALSE;
-
- if (redraw)
- ghid_invalidate_all();
-}
-
-static void
-layer_button_set_color (LayerButtonSet * lb, gchar * color_string,
- bool set_prelight)
-{
- GdkColor color;
-
- if (!lb->layer_enable_ebox)
- return;
-
- color.red = color.green = color.blue = 0;
- ghid_map_color_string (color_string, &color);
- gtk_widget_modify_bg (lb->layer_enable_ebox, GTK_STATE_ACTIVE, &color);
- gtk_widget_modify_bg (lb->layer_enable_ebox, GTK_STATE_PRELIGHT,
- set_prelight ? &color : NULL);
-
- gtk_widget_modify_fg (lb->label, GTK_STATE_ACTIVE, &WhitePixel);
-}
-
-void
-layer_enable_button_set_label (GtkWidget * label, gchar * text)
-{
- gchar *s;
-
- if (ghidgui->small_label_markup)
- s = g_strdup_printf ("<small>%s</small>", text);
- else
- s = g_strdup (text);
- gtk_label_set_markup (GTK_LABEL (label), s);
- g_free (s);
-}
-
-static void
-ghid_show_layer_buttons(void)
-{
- LayerButtonSet *lb;
- gint i;
-
- for (i = 0; i < MAX_LAYER; ++i)
- {
- lb = &layer_buttons[i];
- if (i < max_copper_layer)
- {
- gtk_widget_show(lb->layer_enable_button);
- gtk_widget_show(lb->radio_select_button);
- }
- else
- {
- gtk_widget_hide(lb->layer_enable_button);
- gtk_widget_hide(lb->radio_select_button);
- }
- }
-}
-
- /* After layers comes some special cases. Since silk and netlist (rats)
- | are selectable as separate drawing areas, they are more consistently
- | placed after the layers in the gui so the select radio buttons will
- | be grouped. This is different from Xt PCB which had a different looking
- | select interface.
- */
-static void
-make_layer_buttons (GtkWidget * vbox, GHidPort * port)
-{
- LayerButtonSet *lb;
- GtkWidget *table, *ebox, *label, *button, *hbox;
- GSList *group = NULL;
gchar *text;
- gint i;
gchar *color_string;
- gboolean active = TRUE;
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 4);
- table = gtk_table_new (N_LAYER_BUTTONS, 2, FALSE);
- gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 3);
-
- for (i = 0; i < N_LAYER_BUTTONS; ++i)
- {
- lb = &layer_buttons[i];
- lb->index = i;
-
- if (i < N_SELECTABLE_LAYER_BUTTONS)
- {
- button = gtk_radio_button_new (group);
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
- gtk_table_attach_defaults (GTK_TABLE (table), button,
- 0, 1, i, i + 1);
-
- lb->radio_select_button = button;
- g_signal_connect (G_OBJECT (button), "toggled",
- G_CALLBACK (layer_select_button_cb), lb);
- }
-
- layer_process (&color_string, &text, &active, i);
-
- button = gtk_check_button_new ();
- label = gtk_label_new ("");
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- layer_enable_button_set_label (label, text);
-
- ebox = gtk_event_box_new ();
- gtk_container_add (GTK_CONTAINER (ebox), label);
- gtk_container_add (GTK_CONTAINER (button), ebox);
- gtk_table_attach_defaults (GTK_TABLE (table), button, 1, 2, i, i + 1);
-/* gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); */
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
-
- lb->layer_enable_button = button;
- lb->layer_enable_ebox = ebox;
- lb->text = g_strdup (text);
- lb->label = label;
-
- layer_button_set_color (lb, color_string, active);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
-
- g_signal_connect (G_OBJECT (button), "toggled",
- G_CALLBACK (layer_enable_button_cb),
- GINT_TO_POINTER (i));
-
-
- }
-}
-
-
- /* If new color scheme is loaded from the config or user changes a color
- | in the preferences, make sure our layer button colors get updated.
- */
+ gboolean active;
+
+ layer_process (&color_string, &text, &active, LAYER_BUTTON_SILK);
+ gtk_pcb_layer_selector_add_layer (layersel, LAYER_BUTTON_SILK,
+ text, color_string, active, TRUE);
+ layer_process (&color_string, &text, &active, LAYER_BUTTON_RATS);
+ gtk_pcb_layer_selector_add_layer (layersel, LAYER_BUTTON_RATS,
+ text, color_string, active, TRUE);
+ layer_process (&color_string, &text, &active, LAYER_BUTTON_PINS);
+ gtk_pcb_layer_selector_add_layer (layersel, LAYER_BUTTON_PINS,
+ text, color_string, active, FALSE);
+ layer_process (&color_string, &text, &active, LAYER_BUTTON_VIAS);
+ gtk_pcb_layer_selector_add_layer (layersel, LAYER_BUTTON_VIAS,
+ text, color_string, active, FALSE);
+ layer_process (&color_string, &text, &active, LAYER_BUTTON_FARSIDE);
+ gtk_pcb_layer_selector_add_layer (layersel, LAYER_BUTTON_FARSIDE,
+ text, color_string, active, FALSE);
+ layer_process (&color_string, &text, &active, LAYER_BUTTON_MASK);
+ gtk_pcb_layer_selector_add_layer (layersel, LAYER_BUTTON_MASK,
+ text, color_string, active, FALSE);
+}
+
+/*! \brief callback for gtk_pcb_layer_selector_update_colors */
+const gchar *
+get_layer_color (gint layer)
+{
+ gchar *rv;
+ layer_process (&rv, NULL, NULL, layer);
+ return rv;
+}
+
+/*! \brief Update a layer selector's color scheme */
void
ghid_layer_buttons_color_update (void)
{
- gchar *color_string;
- LayerButtonSet *lb;
- gint i;
-
- if (!gport->drawing_area)
- return;
-
- /* Fixme: should the color set be maintained in both the PCB and the
- | Settings struct?
- */
+ printf ("UPDATE COLORS\n");
+ gtk_pcb_layer_selector_update_colors
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector), get_layer_color);
pcb_colors_from_settings (PCB);
-
- for (i = 0; i < N_LAYER_BUTTONS; ++i)
- {
- bool active;
-
- lb = &layer_buttons[i];
-
- layer_process (&color_string, NULL, NULL, i);
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lb));
- layer_button_set_color (lb, color_string, active);
- }
}
-
-
- /* Update layer button labels and enabled state to match current PCB.
- */
-void
-ghid_layer_enable_buttons_update (void)
+
+/*! \brief Populate a layer selector with all layers Gtk is aware of */
+static void
+make_layer_buttons (GtkWidget *layersel)
{
- LayerButtonSet *lb;
- gchar *s;
- gchar *color_string;
gint i;
+ gchar *text;
+ gchar *color_string;
+ gboolean active = TRUE;
+ ghidgui->layer_selector = layersel;
-#ifdef DEBUG_MENUS
- printf ("ghid_layer_enable_buttons_update()\n");
-#endif
-
- /* Update layer button labels and active state to state inside of PCB
- */
- layer_enable_button_cb_hold_off = TRUE;
for (i = 0; i < max_copper_layer; ++i)
{
- lb = &layer_buttons[i];
- s = (gchar *)UNKNOWN (PCB->Data->Layer[i].Name);
- if (dup_string (&lb->text, s))
- {
- layer_enable_button_set_label (lb->label, _(s));
- ghid_config_layer_name_update (_(s), i);
- }
- if (Settings.verbose)
- {
- gboolean active, newone;
-
- active =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (lb->layer_enable_button));
- newone = PCB->Data->Layer[i].On;
- if (active != newone)
- printf ("ghid_layer_enable_buttons_update: active=%d new=%d\n",
- active, newone);
- }
- layer_process (&color_string, NULL, NULL, i);
- layer_button_set_color (lb, color_string, PCB->Data->Layer[i].On);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (lb->layer_enable_button),
- PCB->Data->Layer[i].On);
- }
- /* Buttons for elements (silk), rats, pins, vias, and far side don't
- | change labels.
- */
- lb = &layer_buttons[LAYER_BUTTON_SILK];
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lb->layer_enable_button),
- PCB->ElementOn);
-
- lb = &layer_buttons[LAYER_BUTTON_RATS];
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lb->layer_enable_button),
- PCB->RatOn);
-
- lb = &layer_buttons[LAYER_BUTTON_PINS];
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lb->layer_enable_button),
- PCB->PinOn);
-
- lb = &layer_buttons[LAYER_BUTTON_VIAS];
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lb->layer_enable_button),
- PCB->ViaOn);
-
- lb = &layer_buttons[LAYER_BUTTON_FARSIDE];
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lb->layer_enable_button),
- PCB->InvisibleObjectsOn);
- layer_enable_button_cb_hold_off = FALSE;
-}
-
-void
-ghid_layer_button_select (gint layer)
-{
- if (layer != layer_select_button_index)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (layer_buttons[layer].
- radio_select_button), TRUE);
- layer_select_button_index = layer;
+ layer_process (&color_string, &text, &active, i);
+ gtk_pcb_layer_selector_add_layer (GTK_PCB_LAYER_SELECTOR (layersel), i,
+ text, color_string, active, TRUE);
}
+ make_virtual_layer_buttons (GTK_PCB_LAYER_SELECTOR (layersel));
}
- /* Main layer button synchronization with current PCB state. Called when
- | user toggles layer visibility or changes drawing layer or when internal
- | PCB code changes layer visibility.
- */
-
+/*! \brief Synchronize layer selector widget with current PCB state
+ * \par Function Description
+ * Called when user toggles layer visibility or changes drawing layer,
+ * or when layer visibility is changed programatically.
+ */
void
ghid_layer_buttons_update (void)
{
- gint layer;
- gboolean active = FALSE;
- gboolean old_holdoff;
- char tmpnm[40];
- int i;
- int set;
- gchar *text;
- GtkAction *a;
- GValue setfalse = { 0 };
- GValue settrue = { 0 };
- GValue setlabel = { 0 };
-
- g_value_init (&setfalse, G_TYPE_BOOLEAN);
- g_value_init (&settrue, G_TYPE_BOOLEAN);
- g_value_set_boolean (&setfalse, FALSE);
- g_value_set_boolean (&settrue, TRUE);
- g_value_init (&setlabel, G_TYPE_STRING);
-
-#ifdef DEBUG_MENUS
- printf ("ghid_layer_buttons_update()\n");
-#endif
-
- if (!ghidgui || ghidgui->creating)
- return;
-
- ghid_layer_enable_buttons_update ();
-
- /* Turning off a layer that was selected will cause PCB to switch to
- | another layer.
- */
- if (PCB->RatDraw)
- layer = LAYER_BUTTON_RATS;
- else
- layer = PCB->SilkActive ? LAYER_BUTTON_SILK : LayerStack[0];
-
- if (layer < max_copper_layer)
- active = PCB->Data->Layer[layer].On;
- else if (layer == LAYER_BUTTON_SILK)
- active = PCB->ElementOn;
- else if (layer == LAYER_BUTTON_RATS)
- active = PCB->RatOn;
-
- if (Settings.verbose)
- {
- printf ("ghid_layer_buttons_update cur_index=%d update_index=%d\n",
- layer_select_button_index, layer);
- if (active && layer != layer_select_button_index)
- printf ("\tActivating button %d\n", layer);
- }
-
- /* mask the callbacks */
- old_holdoff = ghidgui->toggle_holdoff;
- ghidgui->toggle_holdoff = TRUE;
-
- /* update the check marks in the layer pick menu */
- for (i = 0; i < N_LAYER_BUTTONS ; i++)
- {
- sprintf (tmpnm, "%s%d", LAYERPICK, i);
- a = gtk_action_group_get_action (ghidgui->main_actions, tmpnm);
-
- layer_process (NULL, &text, &set, i);
- g_value_set_string (&setlabel, text);
-
- if (a != NULL)
- {
- g_object_set_property (G_OBJECT (a), "visible", (i >= max_copper_layer && i < MAX_LAYER) ? &setfalse : &settrue);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), (set && (i == layer) ) ? TRUE : FALSE);
- g_object_set_property (G_OBJECT (a), "label", &setlabel);
- }
-
- sprintf (tmpnm, "%s%d", LAYERVIEW, i);
- a = gtk_action_group_get_action (ghidgui->main_actions, tmpnm);
- if (a != NULL)
- {
- g_object_set_property (G_OBJECT (a), "visible", (i >= max_copper_layer && i < MAX_LAYER) ? &setfalse : &settrue);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), set ? TRUE : FALSE);
- g_value_set_string (&setlabel, text);
- g_object_set_property (G_OBJECT (a), "label", &setlabel);
- }
-
-
- }
- g_value_unset (&setfalse);
- g_value_unset (&settrue);
- g_value_unset (&setlabel);
- ghidgui->toggle_holdoff = old_holdoff;
-
- if (active && layer != layer_select_button_index)
- {
- layer_select_button_cb_hold_off = TRUE;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (layer_buttons[layer].
- radio_select_button), TRUE);
- layer_select_button_index = layer;
- layer_select_button_cb_hold_off = FALSE;
- }
}
@@ -1892,6 +1460,16 @@ ghid_build_pcb_top_window (void)
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ /* Build layer menus */
+ ghidgui->layer_selector = gtk_pcb_layer_selector_new ();
+ make_layer_buttons (ghidgui->layer_selector);
+ g_signal_connect (G_OBJECT (ghidgui->layer_selector), "select_layer",
+ G_CALLBACK (layer_selector_select_callback),
+ NULL);
+ g_signal_connect (G_OBJECT (ghidgui->layer_selector), "toggle_layer",
+ G_CALLBACK (layer_selector_toggle_callback),
+ NULL);
+ /* Build main menu */
ghid_load_menus ();
make_top_menubar(hbox, port);
@@ -1972,7 +1550,8 @@ ghid_build_pcb_top_window (void)
vbox = ghid_scrolled_vbox(vbox_left, &scrolled,
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- make_layer_buttons(vbox, port);
+ gtk_box_pack_start (GTK_BOX(vbox), ghidgui->layer_selector,
+ FALSE, FALSE, 0);
vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_left), vbox, FALSE, FALSE, 0);
@@ -2105,7 +1684,6 @@ ghid_build_pcb_top_window (void)
gdk_window_set_back_pixmap (gport->drawing_area->window, NULL, FALSE);
ghid_route_style_temp_buttons_hide ();
- ghid_show_layer_buttons();
}
@@ -2429,7 +2007,6 @@ ghid_do_export (HID_Attr_Val * options)
* are properly initialized and synchronized with the current PCB.
*/
ghid_layer_buttons_update ();
- ghid_show_layer_buttons();
if (stdin_listen)
ghid_create_listener ();
@@ -2449,7 +2026,6 @@ LayersChanged (int argc, char **argv, Coord x, Coord y)
ghid_config_groups_changed();
ghid_layer_buttons_update ();
- ghid_show_layer_buttons();
/* FIXME - if a layer is moved it should retain its color. But layers
| currently can't do that because color info is not saved in the
@@ -2486,7 +2062,6 @@ ToggleView (int argc, char **argv, Coord x, Coord y)
{
int i, l;
static gboolean in_toggle_view = 0;
- gboolean active;
#ifdef DEBUG_MENUS
printf ("Starting ToggleView(). in_toggle_view = %d\n", in_toggle_view);
@@ -2543,10 +2118,8 @@ ToggleView (int argc, char **argv, Coord x, Coord y)
/* Now that we've figured out which toggle button ought to control
* this layer, simply hit the button and let the pre-existing code deal
*/
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (layer_buttons[l].layer_enable_button));
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (layer_buttons[l].layer_enable_button),
- active == TRUE ? FALSE : TRUE);
+ gtk_pcb_layer_selector_toggle_layer
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector), l);
in_toggle_view = 0;
return 0;
}
@@ -2585,8 +2158,8 @@ SelectLayer (int argc, char **argv, Coord x, Coord y)
/* Now that we've figured out which radio button ought to select
* this layer, simply hit the button and let the pre-existing code deal
*/
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (layer_buttons[newl].radio_select_button),
- TRUE);
+ gtk_pcb_layer_selector_select_layer
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector), newl);
return 0;
}
@@ -3285,27 +2858,17 @@ add_resource_to_menu (char * menu, Resource * node, void * callback, int indent)
{
if (strcmp (node->v[i].value, "@layerview") == 0)
{
- int i;
- char tmpid[40];
- for (i = 0 ; i < N_LAYER_BUTTONS; i++)
- {
- sprintf (tmpid, "<menuitem action='%s%d' />\n",
- LAYERVIEW, i);
- ghid_ui_info_indent (indent);
- ghid_ui_info_append (tmpid);
- }
+ gchar *tmp = gtk_pcb_layer_selector_get_view_xml
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector));
+ ghid_ui_info_append (tmp);
+ g_free (tmp);
}
else if (strcmp (node->v[i].value, "@layerpick") == 0)
{
- int i;
- char tmpid[40];
- for (i = 0 ; i < N_SELECTABLE_LAYER_BUTTONS; i++)
- {
- sprintf (tmpid, "<menuitem action='%s%d' />\n",
- LAYERPICK, i);
- ghid_ui_info_indent (indent);
- ghid_ui_info_append (tmpid);
- }
+ gchar *tmp = gtk_pcb_layer_selector_get_pick_xml
+ (GTK_PCB_LAYER_SELECTOR (ghidgui->layer_selector));
+ ghid_ui_info_append (tmp);
+ g_free (tmp);
}
else if (strcmp (node->v[i].value, "@routestyles") == 0)
{
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 9bed4d9..134d2fb 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -108,6 +108,7 @@ typedef struct
*menu_hbox, *compact_vbox, *compact_hbox, *position_hbox, *label_hbox,
*mode_buttons0_vbox, *mode_buttons1_hbox, *mode_buttons1_vbox,
*mode_buttons0_frame, *mode_buttons1_frame, *mode_buttons0_frame_vbox;
+ GtkWidget *layer_selector;
GtkWidget *h_range, *v_range;
GtkObject *h_adjustment, *v_adjustment;
@@ -235,9 +236,7 @@ void ghid_config_files_read (gint * argc, gchar *** argv);
void ghid_mode_buttons_update (void);
void ghid_pack_mode_buttons(void);
-void ghid_layer_enable_buttons_update (void);
void ghid_layer_buttons_update (void);
-void ghid_layer_button_select (gint layer);
void ghid_layer_buttons_color_update (void);
commit 6d50fc7871acdddd8f319d1fd21a08d0784c9af8
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Introduce GtkPcbLayerSelector widget -- not used yet
This widget will replace the layer-selection buttons in the
Gtk GUI, as well as the layer selection and visibility-toggling
parts of the menu.
This is to make layer manipulation more consistent and
more keyboard-accessible.
In future, it would be good to update this widget with context
menus with things like "hide all but this layer".
diff --git a/src/Makefile.am b/src/Makefile.am
index 9df4a50..d4c37e0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -272,6 +272,10 @@ LIBGTK_SRCS = \
hid/hidint.h \
hid/gtk/gtk-pcb-coord-entry.c \
hid/gtk/gtk-pcb-coord-entry.h \
+ hid/gtk/gtk-pcb-layer-selector.c \
+ hid/gtk/gtk-pcb-layer-selector.h \
+ hid/gtk/gtk-pcb-cell-renderer-visibility.c \
+ hid/gtk/gtk-pcb-cell-renderer-visibility.h \
hid/gtk/gtkhid-main.c \
hid/gtk/gtkhid.h \
hid/gtk/gui.h \
diff --git a/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
new file mode 100644
index 0000000..8f6d669
--- /dev/null
+++ b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.c
@@ -0,0 +1,296 @@
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gtkhid.h"
+#include "gui.h"
+
+#include "gtk-pcb-cell-renderer-visibility.h"
+
+enum {
+ TOGGLED,
+ LAST_SIGNAL
+};
+static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
+
+enum {
+ PROP_ACTIVE = 1,
+ PROP_COLOR
+};
+
+struct _GtkPcbCellRendererVisibility
+{
+ GtkCellRenderer parent;
+
+ gboolean active;
+ gchar *color;
+};
+
+struct _GtkPcbCellRendererVisibilityClass
+{
+ GtkCellRendererClass parent_class;
+
+ void (* toggled) (GtkPcbCellRendererVisibility *cell, const gchar *path);
+};
+
+/* RENDERER FUNCTIONS */
+static void
+gtk_pcb_cell_renderer_visibility_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
+{
+ GtkStyle *style = gtk_widget_get_style (widget);
+ gint w, h;
+
+ w = VISIBILITY_TOGGLE_SIZE + 2 * (cell->xpad + style->xthickness);
+ h = VISIBILITY_TOGGLE_SIZE + 2 * (cell->ypad + style->ythickness);
+
+ if (width)
+ *width = w;
+ if (height)
+ *height = h;
+
+ if (cell_area)
+ {
+ if (x_offset)
+ {
+ gint xalign = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ ? 1.0 - cell->xalign
+ : cell->xalign;
+ *x_offset = MAX (0, xalign * (cell_area->width - w));
+ }
+ if (y_offset)
+ *y_offset = MAX(0, cell->yalign * (cell_area->height - h));
+ }
+}
+
+static void
+gtk_pcb_cell_renderer_visibility_render (GtkCellRenderer *cell,
+ GdkWindow *window,
+ GtkWidget *widget,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GdkRectangle *expose_area,
+ GtkCellRendererState flags)
+{
+ GtkPcbCellRendererVisibility *pcb_cell;
+ GdkRectangle toggle_rect;
+ GdkRectangle draw_rect;
+ GtkStateType state;
+
+ pcb_cell = GTK_PCB_CELL_RENDERER_VISIBILITY (cell);
+ gtk_pcb_cell_renderer_visibility_get_size (cell, widget, cell_area,
+ &toggle_rect.x,
+ &toggle_rect.y,
+ &toggle_rect.width,
+ &toggle_rect.height);
+
+ toggle_rect.x += cell_area->x + cell->xpad;
+ toggle_rect.y += cell_area->y + cell->ypad;
+ toggle_rect.width -= cell->xpad * 2;
+ toggle_rect.height -= cell->ypad * 2;
+
+ if (toggle_rect.width <= 0 || toggle_rect.height <= 0)
+ return;
+
+ if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
+ {
+ if (GTK_WIDGET_HAS_FOCUS (widget))
+ state = GTK_STATE_SELECTED;
+ else
+ state = GTK_STATE_ACTIVE;
+ }
+ else
+ state = GTK_STATE_NORMAL;
+
+ if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect))
+ {
+ GdkColor color;
+ cairo_t *cr = gdk_cairo_create (window);
+ if (expose_area)
+ {
+ gdk_cairo_rectangle (cr, expose_area);
+ cairo_clip (cr);
+ }
+ cairo_set_line_width (cr, 1);
+
+ cairo_rectangle (cr, toggle_rect.x + 0.5, toggle_rect.y + 0.5,
+ toggle_rect.width - 1, toggle_rect.height - 1);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_stroke (cr);
+
+ gdk_color_parse (pcb_cell->color, &color);
+ gdk_cairo_set_source_color (cr, &color);
+ if (pcb_cell->active)
+ cairo_rectangle (cr, toggle_rect.x + 0.5, toggle_rect.y + 0.5,
+ toggle_rect.width - 1, toggle_rect.height - 1);
+ else
+ {
+ cairo_move_to (cr, toggle_rect.x + 1, toggle_rect.y + 1);
+ cairo_rel_line_to (cr, toggle_rect.width / 2, 0);
+ cairo_rel_line_to (cr, -toggle_rect.width / 2, toggle_rect.width / 2);
+ cairo_close_path (cr);
+ }
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+ }
+}
+
+static gint
+gtk_pcb_cell_renderer_visibility_activate (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ g_signal_emit (cell, toggle_cell_signals[TOGGLED], 0, path);
+ return TRUE;
+}
+
+/* Setter/Getter */
+static void
+gtk_pcb_cell_renderer_visibility_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkPcbCellRendererVisibility *pcb_cell =
+ GTK_PCB_CELL_RENDERER_VISIBILITY (object);
+
+ switch (param_id)
+ {
+ case PROP_ACTIVE:
+ g_value_set_boolean (value, pcb_cell->active);
+ break;
+ case PROP_COLOR:
+ g_value_set_string (value, pcb_cell->color);
+ break;
+ }
+}
+
+static void
+gtk_pcb_cell_renderer_visibility_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkPcbCellRendererVisibility *pcb_cell =
+ GTK_PCB_CELL_RENDERER_VISIBILITY (object);
+
+ switch (param_id)
+ {
+ case PROP_ACTIVE:
+ pcb_cell->active = g_value_get_boolean (value);
+ break;
+ case PROP_COLOR:
+ g_free (pcb_cell->color);
+ pcb_cell->color = g_value_dup_string (value);
+ break;
+ }
+}
+
+
+/* CONSTRUCTOR */
+static void
+gtk_pcb_cell_renderer_visibility_init (GtkPcbCellRendererVisibility *ls)
+{
+ g_object_set (ls, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
+}
+
+static void
+gtk_pcb_cell_renderer_visibility_class_init (GtkPcbCellRendererVisibilityClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
+
+ object_class->get_property = gtk_pcb_cell_renderer_visibility_get_property;
+ object_class->set_property = gtk_pcb_cell_renderer_visibility_set_property;
+
+ cell_class->get_size = gtk_pcb_cell_renderer_visibility_get_size;
+ cell_class->render = gtk_pcb_cell_renderer_visibility_render;
+ cell_class->activate = gtk_pcb_cell_renderer_visibility_activate;
+
+ g_object_class_install_property (object_class, PROP_ACTIVE,
+ g_param_spec_boolean ("active",
+ _("Visibility state"),
+ _("Visibility of the layer"),
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_COLOR,
+ g_param_spec_string ("color",
+ _("Layer color"),
+ _("Layer color"),
+ FALSE,
+ G_PARAM_READWRITE));
+
+
+ /**
+ * GtkPcbCellRendererVisibility::toggled:
+ * @cell_renderer: the object which received the signal
+ * @path: string representation of #GtkTreePath describing the
+ * event location
+ *
+ * The ::toggled signal is emitted when the cell is toggled.
+ **/
+ toggle_cell_signals[TOGGLED] =
+ g_signal_new (_("toggled"),
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkPcbCellRendererVisibilityClass, toggled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+}
+
+/* PUBLIC FUNCTIONS */
+GType
+gtk_pcb_cell_renderer_visibility_get_type (void)
+{
+ static GType ls_type = 0;
+
+ if (!ls_type)
+ {
+ const GTypeInfo ls_info =
+ {
+ sizeof (GtkPcbCellRendererVisibilityClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_pcb_cell_renderer_visibility_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkPcbCellRendererVisibility),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_pcb_cell_renderer_visibility_init,
+ };
+
+ ls_type = g_type_register_static (GTK_TYPE_CELL_RENDERER,
+ "GtkPcbCellRendererVisibility",
+ &ls_info,
+ 0);
+ }
+
+ return ls_type;
+}
+
+GtkCellRenderer *
+gtk_pcb_cell_renderer_visibility_new (void)
+{
+ GtkPcbCellRendererVisibility *rv =
+ g_object_new (GTK_PCB_CELL_RENDERER_VISIBILITY_TYPE, NULL);
+
+ rv->active = FALSE;
+
+ return GTK_CELL_RENDERER (rv);
+}
+
diff --git a/src/hid/gtk/gtk-pcb-cell-renderer-visibility.h b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.h
new file mode 100644
index 0000000..212c4a4
--- /dev/null
+++ b/src/hid/gtk/gtk-pcb-cell-renderer-visibility.h
@@ -0,0 +1,24 @@
+#ifndef GTK_PCB_CELL_RENDERER_VISIBILITY_H__
+#define GTK_PCB_CELL_RENDERER_VISIBILITY_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS /* keep c++ happy */
+
+#define VISIBILITY_TOGGLE_SIZE 16
+
+#define GTK_PCB_CELL_RENDERER_VISIBILITY_TYPE (gtk_pcb_cell_renderer_visibility_get_type ())
+#define GTK_PCB_CELL_RENDERER_VISIBILITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_PCB_CELL_RENDERER_VISIBILITY_TYPE, GtkPcbCellRendererVisibility))
+#define GTK_PCB_CELL_RENDERER_VISIBILITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_PCB_CELL_RENDERER_VISIBILITY_TYPE, GtkPcbCellRendererVisibilityClass))
+#define IS_GTK_PCB_CELL_RENDERER_VISIBILITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_PCB_CELL_RENDERER_VISIBILITY_TYPE))
+#define IS_GTK_PCB_CELL_RENDERER_VISIBILITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_PCB_CELL_RENDERER_VISIBILITY_TYPE))
+
+typedef struct _GtkPcbCellRendererVisibility GtkPcbCellRendererVisibility;
+typedef struct _GtkPcbCellRendererVisibilityClass GtkPcbCellRendererVisibilityClass;
+
+GType gtk_pcb_cell_renderer_visibility_get_type (void);
+GtkCellRenderer *gtk_pcb_cell_renderer_visibility_new (void);
+
+G_END_DECLS /* keep c++ happy */
+#endif
diff --git a/src/hid/gtk/gtk-pcb-layer-selector.c b/src/hid/gtk/gtk-pcb-layer-selector.c
new file mode 100644
index 0000000..519ec50
--- /dev/null
+++ b/src/hid/gtk/gtk-pcb-layer-selector.c
@@ -0,0 +1,708 @@
+/*! \file <gtk-pcb-layer-selector.c>
+ * \brief Implementation of GtkPcbLayerSelector widget
+ * \par Description
+ * This widget is used for
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "gtkhid.h"
+#include "gui.h"
+#include "pcb-printf.h"
+
+#include "gtk-pcb-layer-selector.h"
+#include "gtk-pcb-cell-renderer-visibility.h"
+
+#define INITIAL_ACTION_MAX 40
+
+/* Forward dec'ls */
+static void gtk_pcb_layer_selector_finalize (GObject *object);
+
+/*! \brief Signals exposed by the widget */
+enum {
+ SELECT_LAYER_SIGNAL,
+ TOGGLE_LAYER_SIGNAL,
+ LAST_SIGNAL
+};
+
+/*! \brief Columns used for internal data store */
+enum {
+ INDEX_COL,
+ USER_ID_COL,
+ VISIBLE_COL,
+ COLOR_COL,
+ TEXT_COL,
+ FONT_COL,
+ ACTIVATABLE_COL,
+ SEPARATOR_COL,
+ N_COLS
+};
+
+static GtkTreeView *gtk_pcb_layer_selector_parent_class;
+static guint gtk_pcb_layer_selector_signals[LAST_SIGNAL] = { 0 };
+
+struct _GtkPcbLayerSelector
+{
+ GtkTreeView parent;
+
+ GtkListStore *list_store;
+ GtkTreeSelection *selection;
+ GtkTreeViewColumn *visibility_column;
+
+ GtkActionGroup *action_group;
+
+ GtkToggleAction **view_actions;
+ GtkRadioAction **pick_actions;
+ GtkTreeRowReference **rows;
+ GSList *radio_group;
+ int max_actions;
+ int n_actions;
+
+ gboolean last_activatable;
+};
+
+struct _GtkPcbLayerSelectorClass
+{
+ GtkTreeViewClass parent_class;
+
+ void (* select_layer) (GtkPcbLayerSelector *, gint);
+ void (* toggle_layer) (GtkPcbLayerSelector *, gint);
+};
+
+/*! \brief Flip the visibility state of a given layer
+ * \par Function Description
+ * Changes the internal toggle state and menu checkbox state
+ * of the layer pointed to by iter. Emits a toggle-layer signal.
+ * ALL internal visibility-flipping needs to go through this
+ * function. Otherwise a signal will not be emitted and it is
+ * likely that pcb will become inconsistent with the selector.
+ *
+ * \param [in] ls The selector to be acted on
+ * \param [in] iter A GtkTreeIter pointed at the relevant layer
+ */
+static void
+toggle_visibility (GtkPcbLayerSelector *ls, GtkTreeIter *iter)
+{
+ gint idx;
+ gboolean toggle;
+ gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), iter,
+ VISIBLE_COL, &toggle, INDEX_COL, &idx, -1);
+ gtk_list_store_set (ls->list_store, iter, VISIBLE_COL, !toggle, -1);
+ gtk_toggle_action_set_active (ls->view_actions[idx], !toggle);
+}
+
+/*! \brief Decide if a GtkListStore entry is a layer or separator */
+static gboolean
+tree_view_separator_func (GtkTreeModel *model, GtkTreeIter *iter,
+ gpointer data)
+{
+ gboolean ret_val;
+ gtk_tree_model_get (model, iter, SEPARATOR_COL, &ret_val, -1);
+ return ret_val;
+}
+
+/*! \brief Decide if a GtkListStore entry may be selected */
+static gboolean
+tree_selection_func (GtkTreeSelection *selection, GtkTreeModel *model,
+ GtkTreePath *path, gboolean selected, gpointer data)
+{
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_get_iter (model, &iter, path))
+ {
+ gboolean activatable;
+ gtk_tree_model_get (model, &iter, ACTIVATABLE_COL, &activatable, -1);
+ return activatable;
+ }
+
+ return FALSE;
+}
+
+/* SIGNAL HANDLERS */
+/*! \brief Callback for mouse-click: toggle visibility */
+static gboolean
+button_press_cb (GtkPcbLayerSelector *ls, GdkEventButton *event)
+{
+ /* Handle visibility independently to prevent changing the active
+ * layer, which will happen if we let this event propagate. */
+ GtkTreeViewColumn *column;
+ GtkTreePath *path;
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (ls),
+ event->x, event->y,
+ &path, &column, NULL, NULL))
+ {
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (ls->list_store), &iter, path);
+ if (column == ls->visibility_column)
+ {
+ toggle_visibility (ls, &iter);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*! \brief Callback for layer selection change: sync menu */
+static void
+selection_changed_cb (GtkTreeSelection *selection, GtkPcbLayerSelector *ls)
+{
+ GtkTreeIter iter;
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ gint idx;
+ gtk_tree_model_get (GTK_TREE_MODEL (ls->list_store), &iter,
+ INDEX_COL, &idx, -1);
+ if (ls->pick_actions[0])
+ gtk_radio_action_set_current_value (ls->pick_actions[0], idx);
+ }
+}
+
+/*! \brief Callback for menu actions: sync layer selection list, emit signal */
+static void
+menu_view_cb (GtkToggleAction *action, GtkTreeRowReference *rref)
+{
+ GtkPcbLayerSelector *ls;
+ GtkTreeModel *model = gtk_tree_row_reference_get_model (rref);
+ GtkTreePath *path = gtk_tree_row_reference_get_path (rref);
+ gboolean state = gtk_toggle_action_get_active (action);
+ GtkTreeIter iter;
+ gint user_id;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, VISIBLE_COL, state, -1);
+ gtk_tree_model_get (model, &iter, USER_ID_COL, &user_id, -1);
+
+ ls = g_object_get_data (G_OBJECT (model), "layer-selector");
+ g_signal_emit (ls, gtk_pcb_layer_selector_signals[TOGGLE_LAYER_SIGNAL],
+ 0, user_id);
+}
+
+/*! \brief Callback for menu actions: sync layer selection list, emit signal */
+static void
+menu_pick_cb (GtkRadioAction *action, GtkPcbLayerSelector *ls)
+{
+ int idx = gtk_radio_action_get_current_value (action);
+ GtkTreeRowReference *rref = ls->rows[idx];
+ GtkTreeModel *model = gtk_tree_row_reference_get_model (rref);
+ GtkTreePath *path = gtk_tree_row_reference_get_path (rref);
+ GtkTreeIter iter;
+ gint user_id;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, USER_ID_COL, &user_id, -1);
+ gtk_tree_selection_select_path (ls->selection, path);
+
+ g_signal_emit (ls, gtk_pcb_layer_selector_signals[SELECT_LAYER_SIGNAL],
+ 0, user_id);
+}
+
+/* CONSTRUCTOR */
+static void
+gtk_pcb_layer_selector_init (GtkPcbLayerSelector *ls)
+{
+ /* Hookup signal handlers */
+}
+
+static void
+gtk_pcb_layer_selector_class_init (GtkPcbLayerSelectorClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *) klass;
+
+ gtk_pcb_layer_selector_signals[SELECT_LAYER_SIGNAL] =
+ g_signal_new ("select-layer",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkPcbLayerSelectorClass, select_layer),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT, G_TYPE_NONE,
+ 1, G_TYPE_INT);
+ gtk_pcb_layer_selector_signals[TOGGLE_LAYER_SIGNAL] =
+ g_signal_new ("toggle-layer",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkPcbLayerSelectorClass, toggle_layer),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT, G_TYPE_NONE,
+ 1, G_TYPE_INT);
+
+ object_class->finalize = gtk_pcb_layer_selector_finalize;
+}
+
+/*! \brief Clean up object before garbage collection
+ */
+static void
+gtk_pcb_layer_selector_finalize (GObject *object)
+{
+ int i;
+ GtkPcbLayerSelector *ls = (GtkPcbLayerSelector *) object;
+
+ g_object_unref (ls->action_group);
+ g_free (ls->view_actions);
+ g_free (ls->pick_actions);
+ for (i = 0; i < ls->n_actions; ++i)
+ gtk_tree_row_reference_free (ls->rows[i]);
+ g_free (ls->rows);
+
+ G_OBJECT_CLASS (gtk_pcb_layer_selector_parent_class)->finalize (object);
+}
+
+/* PUBLIC FUNCTIONS */
+GType
+gtk_pcb_layer_selector_get_type (void)
+{
+ static GType ls_type = 0;
+
+ if (!ls_type)
+ {
+ const GTypeInfo ls_info =
+ {
+ sizeof (GtkPcbLayerSelectorClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_pcb_layer_selector_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkPcbLayerSelector),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_pcb_layer_selector_init,
+ };
+
+ ls_type = g_type_register_static (GTK_TYPE_TREE_VIEW,
+ "GtkPcbLayerSelector",
+ &ls_info,
+ 0);
+ }
+
+ return ls_type;
+}
+
+/*! \brief Create a new GtkPcbLayerSelector
+ *
+ * \return a freshly-allocated GtkPcbLayerSelector.
+ */
+GtkWidget *
+gtk_pcb_layer_selector_new (void)
+{
+ GtkCellRenderer *renderer1 = gtk_pcb_cell_renderer_visibility_new ();
+ GtkCellRenderer *renderer2 = gtk_cell_renderer_text_new ();
+ GtkTreeViewColumn *opacity_col =
+ gtk_tree_view_column_new_with_attributes ("", renderer1,
+ "active", VISIBLE_COL,
+ "color", COLOR_COL, NULL);
+ GtkTreeViewColumn *name_col =
+ gtk_tree_view_column_new_with_attributes ("", renderer2,
+ "text", TEXT_COL,
+ "font", FONT_COL,
+ "sensitive", VISIBLE_COL, NULL);
+
+ GtkPcbLayerSelector *ls = g_object_new (GTK_PCB_LAYER_SELECTOR_TYPE, NULL);
+
+ /* action index, active, color, text, font, is_separator */
+ ls->list_store = gtk_list_store_new (N_COLS, G_TYPE_INT, G_TYPE_INT,
+ G_TYPE_BOOLEAN, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (ls), opacity_col, -1);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (ls), name_col, -1);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (ls), GTK_TREE_MODEL (ls->list_store));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ls), FALSE);
+
+ ls->last_activatable = TRUE;
+ ls->visibility_column = opacity_col;
+ ls->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ls));
+ ls->action_group = gtk_action_group_new ("LayerSelector");
+ ls->n_actions = 0;
+ ls->max_actions = INITIAL_ACTION_MAX;
+ ls->view_actions = g_malloc0 (ls->max_actions * sizeof (*ls->view_actions));
+ ls->pick_actions = g_malloc0 (ls->max_actions * sizeof (*ls->pick_actions));
+ ls->rows = g_malloc0 (ls->max_actions * sizeof (*ls->rows));
+
+ gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (ls),
+ tree_view_separator_func,
+ NULL, NULL);
+ gtk_tree_selection_set_select_function (ls->selection, tree_selection_func,
+ NULL, NULL);
+ gtk_tree_selection_set_mode (ls->selection, GTK_SELECTION_BROWSE);
+
+ g_object_set_data (G_OBJECT (ls->list_store), "layer-selector", ls);
+ g_signal_connect (ls, "button_press_event",
+ G_CALLBACK (button_press_cb), NULL);
+ g_signal_connect (ls->selection, "changed",
+ G_CALLBACK (selection_changed_cb), ls);
+
+ g_object_ref (ls->action_group);
+
+ return GTK_WIDGET (ls);
+}
+
+/*! \brief Add a layer to a GtkPcbLayerSelector.
+ * \par Function Description
+ * This function adds an entry to a GtkPcbLayerSelector, which will
+ * appear in the layer-selection list as well as visibility and selection
+ * menus (assuming this is a selectable layer). For the first 20 layers,
+ * keyboard accelerators will be added for selection/visibility toggling.
+ *
+ * \param [in] ls The selector to be acted on
+ * \param [in] user_id An ID used to identify the layer; will be passed to selection/visibility callbacks
+ * \param [in] name The name of the layer; will be used on selector and menus
+ * \param [in] color_string The color of the layer on selector
+ * \param [in] visibile Whether the layer is visible
+ * \param [in] activatable Whether the layer appears in menus and can be selected
+ */
+void
+gtk_pcb_layer_selector_add_layer (GtkPcbLayerSelector *ls,
+ gint user_id,
+ const gchar *name,
+ const gchar *color_string,
+ gboolean visible,
+ gboolean activatable)
+{
+ gchar *pname, *vname, *paccel, *vaccel;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ if (activatable != ls->last_activatable)
+ {
+ /* Add separator between activatable/non-activatable boundaries */
+ gtk_list_store_append (ls->list_store, &iter);
+ gtk_list_store_set (ls->list_store, &iter, SEPARATOR_COL, TRUE, -1);
+ }
+
+ gtk_list_store_append (ls->list_store, &iter);
+ gtk_list_store_set (ls->list_store, &iter,
+ INDEX_COL, ls->n_actions,
+ USER_ID_COL, user_id,
+ VISIBLE_COL, visible,
+ COLOR_COL, color_string,
+ TEXT_COL, name,
+ FONT_COL, activatable ? NULL : "Italic",
+ ACTIVATABLE_COL, activatable,
+ SEPARATOR_COL, FALSE,
+ -1);
+
+ if (activatable && ls->n_actions == 0)
+ gtk_tree_selection_select_iter (ls->selection, &iter);
+
+ /* Allocate new actions if necessary */
+ if (ls->n_actions == ls->max_actions)
+ {
+ void *tmp[2];
+ ls->max_actions *= 2;
+ tmp[0] = g_realloc (ls->view_actions,
+ ls->max_actions * sizeof (*ls->view_actions));
+ tmp[1] = g_realloc (ls->pick_actions,
+ ls->max_actions * sizeof (*ls->pick_actions));
+ tmp[2] = g_realloc (ls->rows,
+ ls->max_actions * sizeof (*ls->rows));
+ if (tmp[0] == NULL || tmp[1] == NULL || tmp[2] == NULL)
+ g_critical ("realloc failed allocat...
[truncated message content] |
|
From: <gi...@gp...> - 2011-08-25 06:00:16
|
The branch, master has been updated
via c4df558415e977e406522bfce59c63e5518f4cfa (commit)
from a354691f7088c80077658c26268ccbcdfe69356f (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/action.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
=================
Commit Messages
=================
commit c4df558415e977e406522bfce59c63e5518f4cfa
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix File->Import for elements on back side.
Mirror pasted footprints when replacing back-side elements. Also
clear element cache when reloading the new footprint, to avoid getting a
stale pointer.
Closes-bug: lp-699331
:100644 100644 93c17a2... 20dbb0a... M src/action.c
=========
Changes
=========
commit c4df558415e977e406522bfce59c63e5518f4cfa
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix File->Import for elements on back side.
Mirror pasted footprints when replacing back-side elements. Also
clear element cache when reloading the new footprint, to avoid getting a
stale pointer.
Closes-bug: lp-699331
diff --git a/src/action.c b/src/action.c
index 93c17a2..20dbb0a 100644
--- a/src/action.c
+++ b/src/action.c
@@ -7082,6 +7082,8 @@ ActionElementList (int argc, char **argv, Coord x, Coord y)
er = ElementOrientation (e);
pe = PASTEBUFFER->Data->Element->data;
+ if (!FRONT (e))
+ MirrorElementCoordinates (PASTEBUFFER->Data, pe, pe->MarkY*2 - PCB->MaxHeight);
pr = ElementOrientation (pe);
mx = e->MarkX;
@@ -7105,6 +7107,7 @@ ActionElementList (int argc, char **argv, Coord x, Coord y)
}
/* Now reload footprint */
+ element_cache = NULL;
e = find_element_by_refdes (refdes);
old = ChangeElementText (PCB, PCB->Data, e, NAMEONPCB_INDEX, strdup (refdes));
|
|
From: <gi...@gp...> - 2011-08-25 04:41:13
|
The branch, master has been updated
via a354691f7088c80077658c26268ccbcdfe69356f (commit)
from 0988aa477a816841dff9ddd766a3287ed5a5d728 (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/report.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
=================
Commit Messages
=================
commit a354691f7088c80077658c26268ccbcdfe69356f
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix texinfo bug in report.c patch
{} are special characters in texinfo
:100644 100644 cb9afc6... 56e9be4... M src/report.c
=========
Changes
=========
commit a354691f7088c80077658c26268ccbcdfe69356f
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix texinfo bug in report.c patch
{} are special characters in texinfo
diff --git a/src/report.c b/src/report.c
index cb9afc6..56e9be4 100644
--- a/src/report.c
+++ b/src/report.c
@@ -899,7 +899,7 @@ ReportNetLengthByName (char *tofind, int x, int y)
* syntax:
*/
-static const char report_syntax[] = "Report(Object|DrillReport|FoundPins|NetLength|AllNetLengths|{,name})";
+static const char report_syntax[] = "Report(Object|DrillReport|FoundPins|NetLength|AllNetLengths|[,name])";
static const char report_help[] = "Produce various report.";
|
|
From: <gi...@gp...> - 2011-08-25 04:32:55
|
The branch, master has been updated
via 0988aa477a816841dff9ddd766a3287ed5a5d728 (commit)
via 3d23e695a45c4b7c5b3d2aaec4bb1d755b75227a (commit)
from 94fab06336d1c89369cd25b498323dbb16ebe371 (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/flags.c | 10 ++++++++--
src/hid/common/flags.c | 3 ++-
src/hid/lesstif/main.c | 9 +++++++++
3 files changed, 19 insertions(+), 3 deletions(-)
=================
Commit Messages
=================
commit 0988aa477a816841dff9ddd766a3287ed5a5d728
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Lesstif: force widget update on grid unit change
If the grid units change, force a redraw of the coordinates window
and allow a resize.
:100644 100644 ad10772... 30739e9... M src/hid/lesstif/main.c
commit 3d23e695a45c4b7c5b3d2aaec4bb1d755b75227a
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix unitless menu flags.
Numbers without units are counting numbers in flags, not cmil.
Also, cache the lookup of units in flags.c
:100644 100644 a4e5fe5... 954d94a... M src/flags.c
:100644 100644 669b2ab... 92032f9... M src/hid/common/flags.c
=========
Changes
=========
commit 0988aa477a816841dff9ddd766a3287ed5a5d728
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Lesstif: force widget update on grid unit change
If the grid units change, force a redraw of the coordinates window
and allow a resize.
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index ad10772..30739e9 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -2573,7 +2573,9 @@ idle_proc (XtPointer dummy)
{
static int c_x = -2, c_y = -2;
static MarkType saved_mark;
+ static Unit *old_grid_unit = NULL;
if (crosshair_x != c_x || crosshair_y != c_y
+ || Settings.grid_unit != old_grid_unit
|| memcmp (&saved_mark, &Marked, sizeof (MarkType)))
{
static int last_state = 0;
@@ -2611,6 +2613,13 @@ idle_proc (XtPointer dummy)
}
memcpy (&saved_mark, &Marked, sizeof (MarkType));
+ if (old_grid_unit != Settings.grid_unit)
+ {
+ old_grid_unit = Settings.grid_unit;
+ /* Force a resize on units change. */
+ last_state ++;
+ }
+
/* This is obtuse. We want to enable XmRESIZE_ANY long enough
to shrink to fit the new format (if any), then switch it
back to XmRESIZE_GROW to prevent it from shrinking due to
commit 3d23e695a45c4b7c5b3d2aaec4bb1d755b75227a
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Fix unitless menu flags.
Numbers without units are counting numbers in flags, not cmil.
Also, cache the lookup of units in flags.c
diff --git a/src/flags.c b/src/flags.c
index a4e5fe5..954d94a 100644
--- a/src/flags.c
+++ b/src/flags.c
@@ -74,13 +74,19 @@ FlagGridSize (int dummy)
static int
FlagUnitsMm (int dummy)
{
- return (Settings.grid_unit == get_unit_struct ("mm"));
+ static Unit *u = NULL;
+ if (u == NULL)
+ u = get_unit_struct ("mm");
+ return (Settings.grid_unit == u);
}
static int
FlagUnitsMil (int dummy)
{
- return (Settings.grid_unit == get_unit_struct ("mil"));
+ static Unit *u = NULL;
+ if (u == NULL)
+ u = get_unit_struct ("mil");
+ return (Settings.grid_unit == u);
}
static int
diff --git a/src/hid/common/flags.c b/src/hid/common/flags.c
index 669b2ab..92032f9 100644
--- a/src/hid/common/flags.c
+++ b/src/hid/common/flags.c
@@ -114,7 +114,8 @@ hid_get_flag (const char *name)
}
memcpy (buf, name, cp - name);
buf[cp - name] = 0;
- wv = GetValue (cp + 1, NULL, NULL);
+ /* A number without units is just a number. */
+ wv = GetValueEx (cp + 1, NULL, NULL, NULL, NULL);
f = hid_find_flag (buf);
if (!f)
return 0;
|
|
From: <gi...@gp...> - 2011-08-25 03:27:18
|
The branch, master has been updated
via 94fab06336d1c89369cd25b498323dbb16ebe371 (commit)
from cb158bc80241f6d0b18cb678265865eb27af677f (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/report.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 164 insertions(+), 3 deletions(-)
=================
Commit Messages
=================
commit 94fab06336d1c89369cd25b498323dbb16ebe371
Author: Bert Timmerman <ber...@xs...>
Commit: DJ Delorie <dj...@de...>
This patch adds support for doing Report(netlength,net_name)
Affects-bug: lp-699451
Updated patch to nanometers, fixed a few minor bugs, applied.
:100644 100644 d63bb90... cb9afc6... M src/report.c
=========
Changes
=========
commit 94fab06336d1c89369cd25b498323dbb16ebe371
Author: Bert Timmerman <ber...@xs...>
Commit: DJ Delorie <dj...@de...>
This patch adds support for doing Report(netlength,net_name)
Affects-bug: lp-699451
Updated patch to nanometers, fixed a few minor bugs, applied.
diff --git a/src/report.c b/src/report.c
index d63bb90..cb9afc6 100644
--- a/src/report.c
+++ b/src/report.c
@@ -41,6 +41,7 @@
#include "search.h"
#include "misc.h"
#include "mymem.h"
+#include "rats.h"
#include "rtree.h"
#include "strflags.h"
#include "macro.h"
@@ -48,6 +49,17 @@
#include "find.h"
#include "draw.h"
#include "pcb-printf.h"
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
+
+#ifdef HAVE_REGCOMP
+#undef HAVE_RE_COMP
+#endif
+
+#if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP)
+#define USE_RE
+#endif
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
@@ -737,12 +749,157 @@ ReportNetLength (int argc, char **argv, Coord x, Coord y)
}
return 0;
}
+
+static int
+ReportNetLengthByName (char *tofind, int x, int y)
+{
+ int result;
+ char *netname = 0;
+ Coord length = 0;
+ int found = 0;
+ int i;
+ LibraryMenuType *net;
+ ConnectionType conn;
+ int net_found = 0;
+#if defined(USE_RE)
+ int use_re = 0;
+#endif
+#if defined(HAVE_REGCOMP)
+ regex_t elt_pattern;
+ regmatch_t match;
+#endif
+#if defined(HAVE_RE_COMP)
+ char *elt_pattern;
+#endif
+
+ if (!PCB)
+ return 1;
+
+ if (!tofind)
+ return 1;
+
+ SaveUndoSerialNumber ();
+ ResetFoundPinsViasAndPads (true);
+ RestoreUndoSerialNumber ();
+ ResetFoundLinesAndPolygons (true);
+ RestoreUndoSerialNumber ();
+
+#if defined(USE_RE)
+ use_re = 1;
+ for (i = 0; i < PCB->NetlistLib.MenuN; i++)
+ {
+ net = PCB->NetlistLib.Menu + i;
+ if (strcasecmp (tofind, net->Name + 2) == 0)
+ use_re = 0;
+ }
+ if (use_re)
+ {
+#if defined(HAVE_REGCOMP)
+ result =
+ regcomp (&elt_pattern, tofind,
+ REG_EXTENDED | REG_ICASE | REG_NOSUB);
+ if (result)
+ {
+ char errorstring[128];
+
+ regerror (result, &elt_pattern, errorstring, 128);
+ Message (_("regexp error: %s\n"), errorstring);
+ regfree (&elt_pattern);
+ return (1);
+ }
+#endif
+#if defined(HAVE_RE_COMP)
+ if ((elt_pattern = re_comp (tofind)) != NULL)
+ {
+ Message (_("re_comp error: %s\n"), elt_pattern);
+ return (false);
+ }
+#endif
+ }
+#endif
+
+ for (i = 0; i < PCB->NetlistLib.MenuN; i++)
+ {
+ net = PCB->NetlistLib.Menu + i;
+
+#if defined(USE_RE)
+ if (use_re)
+ {
+#if defined(HAVE_REGCOMP)
+ if (regexec (&elt_pattern, net->Name + 2, 1, &match, 0) != 0)
+ continue;
+#endif
+#if defined(HAVE_RE_COMP)
+ if (re_exec (net->Name + 2) != 1)
+ continue;
+#endif
+ }
+ else
+#endif
+ if (strcasecmp (net->Name + 2, tofind))
+ continue;
+
+ if (SeekPad (net->Entry, &conn, false))
+ {
+ switch (conn.type)
+ {
+ case PIN_TYPE:
+ x = ((PinType *) (conn.ptr2))->X;
+ y = ((PinType *) (conn.ptr2))->Y;
+ net_found=1;
+ break;
+ case PAD_TYPE:
+ x = ((PadType *) (conn.ptr2))->Point1.X;
+ y = ((PadType *) (conn.ptr2))->Point1.Y;
+ net_found=1;
+ break;
+ }
+ if (net_found)
+ break;
+ }
+ }
+
+ if (!net_found)
+ {
+ gui->log ("No net named %s\n", tofind);
+ return 1;
+ }
+#ifdef HAVE_REGCOMP
+ if (use_re)
+ regfree (&elt_pattern);
+#endif
+
+ length = XYtoNetLength (x, y, &found);
+ netname = net->Name + 2;
+
+ if (!found && net_found)
+ {
+ gui->log ("Net found, but no lines or arcs were flagged.\n");
+ return 1;
+ }
+ else if (!found)
+ {
+ gui->log ("Net not found.\n");
+ return 1;
+ }
+
+ {
+ char buf[50];
+ pcb_sprintf(buf, "%$m*", Settings.grid_unit->suffix, length);
+ if (netname)
+ gui->log ("Net \"%s\" length: %s\n", netname, buf);
+ else
+ gui->log ("Net length: %s\n", buf);
+ }
+ return 0;
+}
+
/* ---------------------------------------------------------------------------
* reports on an object
* syntax:
*/
-static const char report_syntax[] = "Report(Object|DrillReport|FoundPins|NetLength|AllNetLengths)";
+static const char report_syntax[] = "Report(Object|DrillReport|FoundPins|NetLength|AllNetLengths|{,name})";
static const char report_help[] = "Produce various report.";
@@ -778,7 +935,7 @@ units
static int
Report (int argc, char **argv, Coord x, Coord y)
{
- if (argc < 1)
+ if ((argc < 1) || (argc > 2))
AUSAGE (report);
else if (strcasecmp (argv[0], "Object") == 0)
{
@@ -789,10 +946,14 @@ Report (int argc, char **argv, Coord x, Coord y)
return ReportDrills (argc - 1, argv + 1, x, y);
else if (strcasecmp (argv[0], "FoundPins") == 0)
return ReportFoundPins (argc - 1, argv + 1, x, y);
- else if (strcasecmp (argv[0], "NetLength") == 0)
+ else if ((strcasecmp (argv[0], "NetLength") == 0) && (argc == 1))
return ReportNetLength (argc - 1, argv + 1, x, y);
else if (strcasecmp (argv[0], "AllNetLengths") == 0)
return ReportAllNetLengths (argc - 1, argv + 1, x, y);
+ else if ((strcasecmp (argv[0], "NetLength") == 0) && (argc == 2))
+ return ReportNetLengthByName (argv[1], x, y);
+ else if (argc == 2)
+ AUSAGE (report);
else
AFAIL (report);
return 1;
|
|
From: <gi...@gp...> - 2011-08-24 23:01:17
|
The branch, master has been updated
via cb158bc80241f6d0b18cb678265865eb27af677f (commit)
from 7b12a556ebdfdfffb63cc2438fe91ee1628e4fa1 (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 | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
=================
Commit Messages
=================
commit cb158bc80241f6d0b18cb678265865eb27af677f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Don't compensate for crosshair position when panning
Perhaps this was necessary before.. it is not now, and is causing
the crosshair to be errenously offset whilst panning with the
scroll wheel.
:100644 100644 8fd11ef... dc2ea56... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit cb158bc80241f6d0b18cb678265865eb27af677f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Don't compensate for crosshair position when panning
Perhaps this was necessary before.. it is not now, and is causing
the crosshair to be errenously offset whilst panning with the
scroll wheel.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 8fd11ef..dc2ea56 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1837,11 +1837,7 @@ ScrollAction (int argc, char **argv, Coord x, Coord y)
else
AFAIL (scroll);
- notify_crosshair_change (false);
ghid_port_ranges_pan (dx, dy, TRUE);
- MoveCrosshairRelative (dx, dy);
- AdjustAttachedObjects ();
- notify_crosshair_change (true);
return 0;
}
|
|
From: <gi...@gp...> - 2011-08-24 22:21:22
|
The branch, master has been updated
via 7b12a556ebdfdfffb63cc2438fe91ee1628e4fa1 (commit)
from a8a4eaf68134846504b6c0ff843699aed5581083 (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 | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit 7b12a556ebdfdfffb63cc2438fe91ee1628e4fa1
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Simplify viewport setup in PCBChanged()
This version still works ;)
:100644 100644 be4f1db... 8fd11ef... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit 7b12a556ebdfdfffb63cc2438fe91ee1628e4fa1
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Simplify viewport setup in PCBChanged()
This version still works ;)
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index be4f1db..8fd11ef 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1145,9 +1145,7 @@ PCBChanged (int argc, char **argv, Coord x, Coord y)
return 0;
RouteStylesChanged (0, NULL, 0, 0);
ghid_port_ranges_scale ();
- ghid_port_ranges_pan (0, 0, FALSE);
ghid_zoom_view_fit ();
- ghid_port_ranges_changed ();
ghid_sync_with_new_layout ();
return 0;
}
|
|
From: <gi...@gp...> - 2011-08-24 22:05:54
|
The branch, master has been updated
via a8a4eaf68134846504b6c0ff843699aed5581083 (commit)
from 94d80de0fc0445bc1c1822ff505057182487ccbe (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 | 40 ++++++++++++++++------------------------
1 files changed, 16 insertions(+), 24 deletions(-)
=================
Commit Messages
=================
commit a8a4eaf68134846504b6c0ff843699aed5581083
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Refactor common view clamping code from ghid_{pan,zoom}_view_abs
Inspection of the zoom-fit code which triggers if the view exceeds the
size of the board suggests that it will never be called, so remove it.
:100644 100644 96ff923... be4f1db... M src/hid/gtk/gtkhid-main.c
=========
Changes
=========
commit a8a4eaf68134846504b6c0ff843699aed5581083
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Refactor common view clamping code from ghid_{pan,zoom}_view_abs
Inspection of the zoom-fit code which triggers if the view exceeds the
size of the board suggests that it will never be called, so remove it.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 96ff923..be4f1db 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -35,26 +35,13 @@ bool ghid_flip_x = false, ghid_flip_y = false;
static void ghid_zoom_view_fit (void);
static void
-ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
+pan_common (GHidPort *port)
{
- 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);
- gport->view_y0 = MIN (gport->view_y0, PCB->MaxHeight - gport->view_height);
-
- /* Don't view above or to the left of the board... ever */
+ /* Don't pan so far that we see past the board edges */
gport->view_x0 = MAX (0, gport->view_x0);
gport->view_y0 = MAX (0, gport->view_y0);
-
- /* If we can see the entire board and some, then zoom to fit */
- if (gport->view_width > PCB->MaxWidth &&
- gport->view_height > PCB->MaxHeight)
- {
- ghid_zoom_view_fit ();
- return;
- }
+ gport->view_x0 = MIN (gport->view_x0, PCB->MaxWidth - gport->view_width);
+ gport->view_y0 = MIN (gport->view_y0, PCB->MaxHeight - gport->view_height);
ghidgui->adjustment_changed_holdoff = TRUE;
gtk_range_set_value (GTK_RANGE (ghidgui->h_range), gport->view_x0);
@@ -64,6 +51,15 @@ ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
ghid_port_ranges_changed();
}
+static void
+ghid_pan_view_abs (Coord pcb_x, Coord pcb_y, int widget_x, int widget_y)
+{
+ gport->view_x0 = SIDE_X (pcb_x) - widget_x * gport->zoom;
+ gport->view_y0 = SIDE_Y (pcb_y) - widget_y * gport->zoom;
+
+ pan_common (gport);
+}
+
/* gport->zoom:
* zoom value is PCB units per screen pixel. Larger numbers mean zooming
@@ -97,15 +93,11 @@ ghid_zoom_view_abs (Coord center_x, Coord center_y, double new_zoom)
pixel_slop = new_zoom;
ghid_port_ranges_scale ();
- 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);
+ gport->view_x0 = SIDE_X (center_x) - xtmp * gport->view_width;
+ gport->view_y0 = 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;
+ pan_common (gport);
- ghid_port_ranges_changed ();
ghid_set_status_line_label ();
}
|
|
From: <gi...@gp...> - 2011-08-24 22:04:17
|
The branch, master has been updated
via 94d80de0fc0445bc1c1822ff505057182487ccbe (commit)
from 8ac8d6c6403bd8f322eb146ebe129718cc989a0d (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/gui-output-events.c | 18 +++++-------------
1 files changed, 5 insertions(+), 13 deletions(-)
=================
Commit Messages
=================
commit 94d80de0fc0445bc1c1822ff505057182487ccbe
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: A couple of NOOP cosmetic changes to ghid_port_ranges_pan()
:100644 100644 0fc07f3... ba637c3... M src/hid/gtk/gui-output-events.c
=========
Changes
=========
commit 94d80de0fc0445bc1c1822ff505057182487ccbe
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: A couple of NOOP cosmetic changes to ghid_port_ranges_pan()
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 0fc07f3..ba637c3 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -77,16 +77,8 @@ ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative)
x0 = h_adj->value;
y0 = v_adj->value;
- if (relative)
- {
- x1 = x0 + x;
- y1 = y0 + y;
- }
- else
- {
- x1 = x;
- y1 = y;
- }
+ x1 = relative ? x + x0 : x;
+ y1 = relative ? y + y0 : y;
if (x1 < h_adj->lower)
x1 = h_adj->lower;
@@ -110,9 +102,9 @@ ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative)
return ((x0 != x1) || (y0 != y1));
}
- /* Do scrollbar scaling based on current port drawing area size and
- | overall PCB board size.
- */
+/* Do scrollbar scaling based on current port drawing area size and
+ | overall PCB board size.
+ */
void
ghid_port_ranges_scale (void)
{
|