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-07-24 15:39:00
|
The branch, master has been updated
via f5423195c8dcd95e028cb5ee6776eb4e58b46e37 (commit)
from 39ca0bda4ffc59f592d48b64c866ed6a856ed356 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
src/hid/gtk/gtkhid-main.c | 24 +++++++++++++-----------
src/hid/gtk/gui-output-events.c | 25 +++++++++++++------------
src/hid/gtk/gui.h | 7 ++++---
3 files changed, 30 insertions(+), 26 deletions(-)
=================
Commit Messages
=================
commit f5423195c8dcd95e028cb5ee6776eb4e58b46e37
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Refactor semantics of, and rename view_x, view_y coordinates
Rather than storing pointer coordinates in the imaginary "view" system,
where the coordinates (in PCB base units) represent that of an unflipped
board, store them such that they are directly meaningful on the board.
As they now directly represent the cursor coordinats on the actual board,
they don't require passing through the SIDE_{X,Y} macros before use with
APIs that expect board coordinates.
To avoid confusion, view_x and view_y have been renamed to pcb_x and pcb_y
to reflect the change of semantics.
In a number of cases, SIDE_{X,Y} macro calls were added to preserve
correct functionality of old code which manipulates the mouse position in
"view" coordinates. These are primarily concerned with zooming and panning.
Also rename the confusingly titled VIEW_{X,Y} macros to EVENT_TO_PCB_{X,Y}
:100644 100644 a3c3d29... 8500f6a... M src/hid/gtk/gtkhid-main.c
:100644 100644 abf8f53... 1a10251... M src/hid/gtk/gui-output-events.c
:100644 100644 1253511... 29a5407... M src/hid/gtk/gui.h
=========
Changes
=========
commit f5423195c8dcd95e028cb5ee6776eb4e58b46e37
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Refactor semantics of, and rename view_x, view_y coordinates
Rather than storing pointer coordinates in the imaginary "view" system,
where the coordinates (in PCB base units) represent that of an unflipped
board, store them such that they are directly meaningful on the board.
As they now directly represent the cursor coordinats on the actual board,
they don't require passing through the SIDE_{X,Y} macros before use with
APIs that expect board coordinates.
To avoid confusion, view_x and view_y have been renamed to pcb_x and pcb_y
to reflect the change of semantics.
In a number of cases, SIDE_{X,Y} macro calls were added to preserve
correct functionality of old code which manipulates the mouse position in
"view" coordinates. These are primarily concerned with zooming and panning.
Also rename the confusingly titled VIEW_{X,Y} macros to EVENT_TO_PCB_{X,Y}
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index a3c3d29..8500f6a 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -241,28 +241,30 @@ zoom_to (double new_zoom, int x, int y)
gdouble xtmp, ytmp;
gint x0, y0;
- xtmp = (gport->view_x - gport->view_x0) / (gdouble) gport->view_width;
- ytmp = (gport->view_y - gport->view_y0) / (gdouble) gport->view_height;
-
+ xtmp = (SIDE_X (gport->pcb_x) - gport->view_x0) /
+ (gdouble) gport->view_width;
+ ytmp = (SIDE_Y (gport->pcb_y) - gport->view_y0) /
+ (gdouble) gport->view_height;
+
gport->zoom = new_zoom;
pixel_slop = new_zoom;
ghid_port_ranges_scale(FALSE);
- x0 = gport->view_x - xtmp * gport->view_width;
+ x0 = SIDE_X (gport->pcb_x) - xtmp * gport->view_width;
if (x0 < 0)
- x0 = 0;
+ x0 = 0;
gport->view_x0 = x0;
- y0 = gport->view_y - ytmp * gport->view_height;
+ y0 = SIDE_Y (gport->pcb_y) - ytmp * gport->view_height;
if (y0 < 0)
- y0 = 0;
+ y0 = 0;
gport->view_y0 = y0;
-
+
ghidgui->adjustment_changed_holdoff = TRUE;
gtk_range_set_value (GTK_RANGE (ghidgui->h_range), gport->view_x0);
gtk_range_set_value (GTK_RANGE (ghidgui->v_range), gport->view_y0);
ghidgui->adjustment_changed_holdoff = FALSE;
-
+
ghid_port_ranges_changed();
}
@@ -1516,12 +1518,12 @@ SwapSides (int argc, char **argv, int x, int y)
location */
if (do_flip_x)
{
- flipd = PCB->MaxWidth / 2 - gport->view_x;
+ flipd = PCB->MaxWidth / 2 - SIDE_X (gport->pcb_x);
ghid_port_ranges_pan (2 * flipd, 0, TRUE);
}
if (do_flip_y)
{
- flipd = PCB->MaxHeight / 2 - gport->view_y;
+ flipd = PCB->MaxHeight / 2 - SIDE_Y (gport->pcb_y);
ghid_port_ranges_pan (0, 2 * flipd, TRUE);
}
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index abf8f53..1a10251 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -166,19 +166,21 @@ ghid_port_ranges_zoom (gdouble zoom)
if ((zoom > xtmp && zoom > ytmp) || zoom == 0.0)
zoom = (xtmp > ytmp) ? xtmp : ytmp;
- xtmp = (gport->view_x - gport->view_x0) / (gdouble) gport->view_width;
- ytmp = (gport->view_y - gport->view_y0) / (gdouble) gport->view_height;
+ xtmp = (SIDE_X (gport->pcb_x) - gport->view_x0) /
+ (gdouble) gport->view_width;
+ ytmp = (SIDE_Y (gport->pcb_y) - gport->view_y0) /
+ (gdouble) gport->view_height;
gport->zoom = zoom;
pixel_slop = zoom;
ghid_port_ranges_scale(FALSE);
- x0 = gport->view_x - xtmp * gport->view_width;
+ x0 = SIDE_X (gport->pcb_x) - xtmp * gport->view_width;
if (x0 < 0)
x0 = 0;
gport->view_x0 = x0;
- y0 = gport->view_y - ytmp * gport->view_height;
+ y0 = SIDE_Y (gport->pcb_y) - ytmp * gport->view_height;
if (y0 < 0)
y0 = 0;
gport->view_y0 = y0;
@@ -203,8 +205,8 @@ ghid_get_coords (const char *msg, int *x, int *y)
ghid_get_user_xy (msg);
if (ghid_port.has_entered)
{
- *x = SIDE_X (gport->view_x);
- *y = SIDE_Y (gport->view_y);
+ *x = gport->pcb_x;
+ *y = gport->pcb_y;
}
}
@@ -224,11 +226,10 @@ ghid_note_event_location (GdkEventButton * ev)
event_x = ev->x;
event_y = ev->y;
}
- gport->view_x = event_x * gport->zoom + gport->view_x0;
- gport->view_y = event_y * gport->zoom + gport->view_y0;
+ gport->pcb_x = EVENT_TO_PCB_X (event_x);
+ gport->pcb_y = EVENT_TO_PCB_Y (event_y);
- moved = MoveCrosshairAbsolute (SIDE_X (gport->view_x),
- SIDE_Y (gport->view_y));
+ moved = MoveCrosshairAbsolute (gport->pcb_x, gport->pcb_y);
if (moved)
{
AdjustAttachedObjects ();
@@ -736,8 +737,8 @@ ghid_port_window_leave_cb (GtkWidget * widget,
w = ghid_port.width * gport->zoom;
h = ghid_port.height * gport->zoom;
- x0 = VIEW_X (0);
- y0 = VIEW_Y (0);
+ x0 = EVENT_TO_PCB_X (0);
+ y0 = EVENT_TO_PCB_Y (0);
ghid_get_coords (NULL, &x, &y);
x -= x0;
y -= y0;
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 1253511..29a5407 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -68,8 +68,8 @@ extern int ghid_flip_x, ghid_flip_y;
#define DRAW_X(x) (gint)((SIDE_X(x) - gport->view_x0) / gport->zoom)
#define DRAW_Y(y) (gint)((SIDE_Y(y) - gport->view_y0) / gport->zoom)
-#define VIEW_X(x) SIDE_X((gint)((x) * gport->zoom + gport->view_x0))
-#define VIEW_Y(y) SIDE_Y((gint)((y) * gport->zoom + gport->view_y0))
+#define EVENT_TO_PCB_X(x) SIDE_X((gint)((x) * gport->zoom + gport->view_x0))
+#define EVENT_TO_PCB_Y(y) SIDE_Y((gint)((y) * gport->zoom + gport->view_y0))
/*
* Used to intercept "special" hotkeys that gtk doesn't usually pass
@@ -177,7 +177,8 @@ typedef struct
gdouble zoom; /* PCB units per screen pixel. Larger */
/* numbers mean zooming out. */
gint view_x0, /* Viewport in PCB coordinates */
- view_y0, view_width, view_height, view_x, view_y;
+ view_y0, view_width, view_height;
+ Coord pcb_x, pcb_y;
gint crosshair_x, crosshair_y;
}
|
|
From: <gi...@gp...> - 2011-07-24 15:25:53
|
The branch, master has been updated
via 39ca0bda4ffc59f592d48b64c866ed6a856ed356 (commit)
from 93cc05a2b4b7689d56bc69f86fff7ef62e003e11 (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 | 6 +++---
src/hid/gtk/gtkhid-gl.c | 4 ++--
src/hid/gtk/gtkhid-main.c | 6 +++---
src/hid/gtk/gui-output-events.c | 2 +-
src/hid/gtk/gui.h | 2 +-
5 files changed, 10 insertions(+), 10 deletions(-)
=================
Commit Messages
=================
commit 39ca0bda4ffc59f592d48b64c866ed6a856ed356
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Rename {x,y}_crosshair to crosshair_{x,y}
(Just because!)
:100644 100644 48d9fc2... 5da8000... M src/hid/gtk/gtkhid-gdk.c
:100644 100644 419d229... 044d7c5... M src/hid/gtk/gtkhid-gl.c
:100644 100644 6a8d904... a3c3d29... M src/hid/gtk/gtkhid-main.c
:100644 100644 1f9a31a... abf8f53... M src/hid/gtk/gui-output-events.c
:100644 100644 31ee636... 1253511... M src/hid/gtk/gui.h
=========
Changes
=========
commit 39ca0bda4ffc59f592d48b64c866ed6a856ed356
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Rename {x,y}_crosshair to crosshair_{x,y}
(Just because!)
diff --git a/src/hid/gtk/gtkhid-gdk.c b/src/hid/gtk/gtkhid-gdk.c
index 48d9fc2..5da8000 100644
--- a/src/hid/gtk/gtkhid-gdk.c
+++ b/src/hid/gtk/gtkhid-gdk.c
@@ -1005,7 +1005,7 @@ show_crosshair (gboolean paint_new_location)
static GdkGC *xor_gc;
static GdkColor cross_color;
- if (gport->x_crosshair < 0 || ghidgui->creating || !gport->has_entered)
+ if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered)
return;
if (!xor_gc)
@@ -1018,8 +1018,8 @@ show_crosshair (gboolean paint_new_location)
/* FIXME: when CrossColor changed from config */
ghid_map_color_string (Settings.CrossColor, &cross_color);
}
- x = DRAW_X (gport->x_crosshair);
- y = DRAW_Y (gport->y_crosshair);
+ x = DRAW_X (gport->crosshair_x);
+ y = DRAW_Y (gport->crosshair_y);
gdk_gc_set_foreground (xor_gc, &cross_color);
diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 419d229..044d7c5 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -746,8 +746,8 @@ ghid_show_crosshair (gboolean paint_new_location)
/* FIXME: when CrossColor changed from config */
ghid_map_color_string (Settings.CrossColor, &cross_color);
}
- x = gport->x_crosshair;
- y = gport->y_crosshair;
+ x = gport->crosshair_x;
+ y = gport->crosshair_y;
z = 0;
glEnable (GL_COLOR_LOGIC_OP);
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 6a8d904..a3c3d29 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -345,11 +345,11 @@ ghid_mod1_is_pressed ()
void
ghid_set_crosshair (int x, int y, int action)
{
- if (gport->x_crosshair != x || gport->y_crosshair != y)
+ if (gport->crosshair_x != x || gport->crosshair_y != y)
{
ghid_set_cursor_position_labels ();
- gport->x_crosshair = x;
- gport->y_crosshair = y;
+ gport->crosshair_x = x;
+ gport->crosshair_y = y;
/*
* FIXME - does this trigger the idle_proc stuff? It is in the
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 1f9a31a..abf8f53 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -592,7 +592,7 @@ static gboolean check_object_tooltips (GHidPort *out)
char *description;
/* check if there are any pins or pads at that position */
- description = describe_location (out->x_crosshair, out->y_crosshair);
+ description = describe_location (out->crosshair_x, out->crosshair_y);
if (description == NULL)
return FALSE;
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 31ee636..1253511 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -179,7 +179,7 @@ typedef struct
gint view_x0, /* Viewport in PCB coordinates */
view_y0, view_width, view_height, view_x, view_y;
- gint x_crosshair, y_crosshair;
+ gint crosshair_x, crosshair_y;
}
GHidPort;
|
|
From: <gi...@gp...> - 2011-07-24 15:10:38
|
The branch, master has been updated
discards 4778bbafb5208e8d8767d3f234062cf6e84566a8 (commit)
via 93cc05a2b4b7689d56bc69f86fff7ef62e003e11 (commit)
from 4778bbafb5208e8d8767d3f234062cf6e84566a8 (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.h | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
=================
Commit Messages
=================
commit 93cc05a2b4b7689d56bc69f86fff7ef62e003e11
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
gtk+gl: Convert crosshair drawing to use PCB world coordinates
Whilst I'm at it, add a z-coordinate to the crosshair drawing functions
to future proof them for when we add some 3D effects.
:100644 100644 4999005... 419d229... M src/hid/gtk/gtkhid-gl.c
=========
Changes
=========
commit 93cc05a2b4b7689d56bc69f86fff7ef62e003e11
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
gtk+gl: Convert crosshair drawing to use PCB world coordinates
Whilst I'm at it, add a z-coordinate to the crosshair drawing functions
to future proof them for when we add some 3D effects.
diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 4999005..419d229 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -624,114 +624,116 @@ ghid_notify_mark_change (bool changes_complete)
}
static void
-draw_right_cross (gint x, gint y)
+draw_right_cross (gint x, gint y, gint z)
{
- glVertex2i (x, 0);
- glVertex2i (x, gport->height);
- glVertex2i (0, y);
- glVertex2i (gport->width, y);
+ glVertex3i (x, 0, z);
+ glVertex3i (x, PCB->MaxHeight, z);
+ glVertex3i (0, y, z);
+ glVertex3i (PCB->MaxWidth, y, z);
}
static void
-draw_slanted_cross (gint x, gint y)
+draw_slanted_cross (gint x, gint y, gint z)
{
gint x0, y0, x1, y1;
- x0 = x + (gport->height - y);
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x + (PCB->MaxHeight - y);
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x - y;
- x1 = MAX(0, MIN (x1, gport->width));
- y0 = y + (gport->width - x);
- y0 = MAX(0, MIN (y0, gport->height));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
+ y0 = y + (PCB->MaxWidth - x);
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
y1 = y - x;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
- x0 = x - (gport->height - y);
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x - (PCB->MaxHeight - y);
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x + y;
- x1 = MAX(0, MIN (x1, gport->width));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
y0 = y + x;
- y0 = MAX(0, MIN (y0, gport->height));
- y1 = y - (gport->width - x);
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
+ y1 = y - (PCB->MaxWidth - x);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
}
static void
-draw_dozen_cross (gint x, gint y)
+draw_dozen_cross (gint x, gint y, gint z)
{
gint x0, y0, x1, y1;
gdouble tan60 = sqrt (3);
- x0 = x + (gport->height - y) / tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x + (PCB->MaxHeight - y) / tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x - y / tan60;
- x1 = MAX(0, MIN (x1, gport->width));
- y0 = y + (gport->width - x) * tan60;
- y0 = MAX(0, MIN (y0, gport->height));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
+ y0 = y + (PCB->MaxWidth - x) * tan60;
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
y1 = y - x * tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
- x0 = x + (gport->height - y) * tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x + (PCB->MaxHeight - y) * tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x - y * tan60;
- x1 = MAX(0, MIN (x1, gport->width));
- y0 = y + (gport->width - x) / tan60;
- y0 = MAX(0, MIN (y0, gport->height));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
+ y0 = y + (PCB->MaxWidth - x) / tan60;
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
y1 = y - x / tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
- x0 = x - (gport->height - y) / tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x - (PCB->MaxHeight - y) / tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x + y / tan60;
- x1 = MAX(0, MIN (x1, gport->width));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
y0 = y + x * tan60;
- y0 = MAX(0, MIN (y0, gport->height));
- y1 = y - (gport->width - x) * tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
-
- x0 = x - (gport->height - y) * tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
+ y1 = y - (PCB->MaxWidth - x) * tan60;
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
+
+ x0 = x - (PCB->MaxHeight - y) * tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x + y * tan60;
- x1 = MAX(0, MIN (x1, gport->width));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
y0 = y + x / tan60;
- y0 = MAX(0, MIN (y0, gport->height));
- y1 = y - (gport->width - x) / tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
+ y1 = y - (PCB->MaxWidth - x) / tan60;
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
}
static void
-draw_crosshair (gint x, gint y)
+draw_crosshair (gint x, gint y, gint z)
{
static enum crosshair_shape prev = Basic_Crosshair_Shape;
- draw_right_cross (x, y);
+ draw_right_cross (x, y, z);
if (prev == Union_Jack_Crosshair_Shape)
- draw_slanted_cross (x, y);
+ draw_slanted_cross (x, y, z);
if (prev == Dozen_Crosshair_Shape)
- draw_dozen_cross (x, y);
+ draw_dozen_cross (x, y, z);
prev = Crosshair.shape;
}
-#define VCW 16
-#define VCD 8
+#define VCW 16 /* Crosshair pan-marker width in pixels */
+#define VCD 8 /* Crosshair pan-marker depth in pixels */
void
ghid_show_crosshair (gboolean paint_new_location)
{
- gint x, y;
+ gint x, y, z;
gboolean draw_markers;
+ int vcw = VCW * gport->zoom;
+ int vcd = VCD * gport->zoom;
static int done_once = 0;
static GdkColor cross_color;
@@ -744,8 +746,9 @@ ghid_show_crosshair (gboolean paint_new_location)
/* FIXME: when CrossColor changed from config */
ghid_map_color_string (Settings.CrossColor, &cross_color);
}
- x = DRAW_X (gport->x_crosshair);
- y = DRAW_Y (gport->y_crosshair);
+ x = gport->x_crosshair;
+ y = gport->y_crosshair;
+ z = 0;
glEnable (GL_COLOR_LOGIC_OP);
glLogicOp (GL_XOR);
@@ -759,7 +762,7 @@ ghid_show_crosshair (gboolean paint_new_location)
if (x >= 0 && paint_new_location)
{
glBegin (GL_LINES);
- draw_crosshair (x, y);
+ draw_crosshair (x, y, z);
glEnd ();
}
@@ -767,22 +770,26 @@ ghid_show_crosshair (gboolean paint_new_location)
if (x >= 0 && paint_new_location && draw_markers)
{
glBegin (GL_QUADS);
- glVertex2i (0, y - VCD);
- glVertex2i (0, y - VCD + VCW);
- glVertex2i (VCD, y - VCD + VCW);
- glVertex2i (VCD, y - VCD);
- glVertex2i (gport->width, y - VCD);
- glVertex2i (gport->width, y - VCD + VCW);
- glVertex2i (gport->width - VCD, y - VCD + VCW);
- glVertex2i (gport->width - VCD, y - VCD);
- glVertex2i (x - VCD, 0);
- glVertex2i (x - VCD, VCD);
- glVertex2i (x - VCD + VCW, VCD);
- glVertex2i (x - VCD + VCW, 0);
- glVertex2i (x - VCD, gport->height - VCD);
- glVertex2i (x - VCD, gport->height);
- glVertex2i (x - VCD + VCW, gport->height);
- glVertex2i (x - VCD + VCW, gport->height - VCD);
+ 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 ();
}
@@ -904,6 +911,14 @@ 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);
+
glEnable (GL_STENCIL_TEST);
glClearColor (port->offlimits_color.red / 65535.,
port->offlimits_color.green / 65535.,
@@ -928,15 +943,6 @@ ghid_drawing_area_expose_cb (GtkWidget *widget,
port->bg_color.green / 65535.,
port->bg_color.blue / 65535.);
- 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);
-
glBegin (GL_QUADS);
glVertex3i (0, 0, 0);
glVertex3i (PCB->MaxWidth, 0, 0);
@@ -958,7 +964,6 @@ ghid_drawing_area_expose_cb (GtkWidget *widget,
DrawAttached ();
DrawMark ();
hidgl_flush_triangles (&buffer);
- glPopMatrix ();
ghid_show_crosshair (TRUE);
|
|
From: <gi...@gp...> - 2011-07-24 15:10:09
|
The branch, master has been updated
via 4778bbafb5208e8d8767d3f234062cf6e84566a8 (commit)
from 1a4ea522931737a60d238ce7caddf7541e99b2cd (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 | 189 ++++++++++++++++++++++++-----------------------
src/hid/gtk/gui.h | 3 +
2 files changed, 100 insertions(+), 92 deletions(-)
=================
Commit Messages
=================
commit 4778bbafb5208e8d8767d3f234062cf6e84566a8
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
gtk+gl: Convert crosshair drawing to use PCB world coordinates
Whilst I'm at it, add a z-coordinate to the crosshair drawing functions
to future proof them for when we add some 3D effects.
:100644 100644 4999005... 419d229... M src/hid/gtk/gtkhid-gl.c
:100644 100644 31ee636... 5fd8bb5... M src/hid/gtk/gui.h
=========
Changes
=========
commit 4778bbafb5208e8d8767d3f234062cf6e84566a8
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
gtk+gl: Convert crosshair drawing to use PCB world coordinates
Whilst I'm at it, add a z-coordinate to the crosshair drawing functions
to future proof them for when we add some 3D effects.
diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 4999005..419d229 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -624,114 +624,116 @@ ghid_notify_mark_change (bool changes_complete)
}
static void
-draw_right_cross (gint x, gint y)
+draw_right_cross (gint x, gint y, gint z)
{
- glVertex2i (x, 0);
- glVertex2i (x, gport->height);
- glVertex2i (0, y);
- glVertex2i (gport->width, y);
+ glVertex3i (x, 0, z);
+ glVertex3i (x, PCB->MaxHeight, z);
+ glVertex3i (0, y, z);
+ glVertex3i (PCB->MaxWidth, y, z);
}
static void
-draw_slanted_cross (gint x, gint y)
+draw_slanted_cross (gint x, gint y, gint z)
{
gint x0, y0, x1, y1;
- x0 = x + (gport->height - y);
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x + (PCB->MaxHeight - y);
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x - y;
- x1 = MAX(0, MIN (x1, gport->width));
- y0 = y + (gport->width - x);
- y0 = MAX(0, MIN (y0, gport->height));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
+ y0 = y + (PCB->MaxWidth - x);
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
y1 = y - x;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
- x0 = x - (gport->height - y);
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x - (PCB->MaxHeight - y);
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x + y;
- x1 = MAX(0, MIN (x1, gport->width));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
y0 = y + x;
- y0 = MAX(0, MIN (y0, gport->height));
- y1 = y - (gport->width - x);
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
+ y1 = y - (PCB->MaxWidth - x);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
}
static void
-draw_dozen_cross (gint x, gint y)
+draw_dozen_cross (gint x, gint y, gint z)
{
gint x0, y0, x1, y1;
gdouble tan60 = sqrt (3);
- x0 = x + (gport->height - y) / tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x + (PCB->MaxHeight - y) / tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x - y / tan60;
- x1 = MAX(0, MIN (x1, gport->width));
- y0 = y + (gport->width - x) * tan60;
- y0 = MAX(0, MIN (y0, gport->height));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
+ y0 = y + (PCB->MaxWidth - x) * tan60;
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
y1 = y - x * tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
- x0 = x + (gport->height - y) * tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x + (PCB->MaxHeight - y) * tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x - y * tan60;
- x1 = MAX(0, MIN (x1, gport->width));
- y0 = y + (gport->width - x) / tan60;
- y0 = MAX(0, MIN (y0, gport->height));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
+ y0 = y + (PCB->MaxWidth - x) / tan60;
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
y1 = y - x / tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
- x0 = x - (gport->height - y) / tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ x0 = x - (PCB->MaxHeight - y) / tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x + y / tan60;
- x1 = MAX(0, MIN (x1, gport->width));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
y0 = y + x * tan60;
- y0 = MAX(0, MIN (y0, gport->height));
- y1 = y - (gport->width - x) * tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
-
- x0 = x - (gport->height - y) * tan60;
- x0 = MAX(0, MIN (x0, gport->width));
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
+ y1 = y - (PCB->MaxWidth - x) * tan60;
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
+
+ x0 = x - (PCB->MaxHeight - y) * tan60;
+ x0 = MAX(0, MIN (x0, PCB->MaxWidth));
x1 = x + y * tan60;
- x1 = MAX(0, MIN (x1, gport->width));
+ x1 = MAX(0, MIN (x1, PCB->MaxWidth));
y0 = y + x / tan60;
- y0 = MAX(0, MIN (y0, gport->height));
- y1 = y - (gport->width - x) / tan60;
- y1 = MAX(0, MIN (y1, gport->height));
- glVertex2i (x0, y0);
- glVertex2i (x1, y1);
+ y0 = MAX(0, MIN (y0, PCB->MaxHeight));
+ y1 = y - (PCB->MaxWidth - x) / tan60;
+ y1 = MAX(0, MIN (y1, PCB->MaxHeight));
+ glVertex3i (x0, y0, z);
+ glVertex3i (x1, y1, z);
}
static void
-draw_crosshair (gint x, gint y)
+draw_crosshair (gint x, gint y, gint z)
{
static enum crosshair_shape prev = Basic_Crosshair_Shape;
- draw_right_cross (x, y);
+ draw_right_cross (x, y, z);
if (prev == Union_Jack_Crosshair_Shape)
- draw_slanted_cross (x, y);
+ draw_slanted_cross (x, y, z);
if (prev == Dozen_Crosshair_Shape)
- draw_dozen_cross (x, y);
+ draw_dozen_cross (x, y, z);
prev = Crosshair.shape;
}
-#define VCW 16
-#define VCD 8
+#define VCW 16 /* Crosshair pan-marker width in pixels */
+#define VCD 8 /* Crosshair pan-marker depth in pixels */
void
ghid_show_crosshair (gboolean paint_new_location)
{
- gint x, y;
+ gint x, y, z;
gboolean draw_markers;
+ int vcw = VCW * gport->zoom;
+ int vcd = VCD * gport->zoom;
static int done_once = 0;
static GdkColor cross_color;
@@ -744,8 +746,9 @@ ghid_show_crosshair (gboolean paint_new_location)
/* FIXME: when CrossColor changed from config */
ghid_map_color_string (Settings.CrossColor, &cross_color);
}
- x = DRAW_X (gport->x_crosshair);
- y = DRAW_Y (gport->y_crosshair);
+ x = gport->x_crosshair;
+ y = gport->y_crosshair;
+ z = 0;
glEnable (GL_COLOR_LOGIC_OP);
glLogicOp (GL_XOR);
@@ -759,7 +762,7 @@ ghid_show_crosshair (gboolean paint_new_location)
if (x >= 0 && paint_new_location)
{
glBegin (GL_LINES);
- draw_crosshair (x, y);
+ draw_crosshair (x, y, z);
glEnd ();
}
@@ -767,22 +770,26 @@ ghid_show_crosshair (gboolean paint_new_location)
if (x >= 0 && paint_new_location && draw_markers)
{
glBegin (GL_QUADS);
- glVertex2i (0, y - VCD);
- glVertex2i (0, y - VCD + VCW);
- glVertex2i (VCD, y - VCD + VCW);
- glVertex2i (VCD, y - VCD);
- glVertex2i (gport->width, y - VCD);
- glVertex2i (gport->width, y - VCD + VCW);
- glVertex2i (gport->width - VCD, y - VCD + VCW);
- glVertex2i (gport->width - VCD, y - VCD);
- glVertex2i (x - VCD, 0);
- glVertex2i (x - VCD, VCD);
- glVertex2i (x - VCD + VCW, VCD);
- glVertex2i (x - VCD + VCW, 0);
- glVertex2i (x - VCD, gport->height - VCD);
- glVertex2i (x - VCD, gport->height);
- glVertex2i (x - VCD + VCW, gport->height);
- glVertex2i (x - VCD + VCW, gport->height - VCD);
+ 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 ();
}
@@ -904,6 +911,14 @@ 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);
+
glEnable (GL_STENCIL_TEST);
glClearColor (port->offlimits_color.red / 65535.,
port->offlimits_color.green / 65535.,
@@ -928,15 +943,6 @@ ghid_drawing_area_expose_cb (GtkWidget *widget,
port->bg_color.green / 65535.,
port->bg_color.blue / 65535.);
- 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);
-
glBegin (GL_QUADS);
glVertex3i (0, 0, 0);
glVertex3i (PCB->MaxWidth, 0, 0);
@@ -958,7 +964,6 @@ ghid_drawing_area_expose_cb (GtkWidget *widget,
DrawAttached ();
DrawMark ();
hidgl_flush_triangles (&buffer);
- glPopMatrix ();
ghid_show_crosshair (TRUE);
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index 31ee636..5fd8bb5 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -62,6 +62,9 @@
#define TO_PCB_UNITS(v) (Settings.grid_units_mm ? MM_TO_COORD(v) : MIL_TO_COORD(v))
extern int ghid_flip_x, ghid_flip_y;
+#define FLIP_X(x) ((ghid_flip_x ? -(x) : (x)))
+#define FLIP_Y(y) ((ghid_flip_y ? -(y) : (y)))
+
#define SIDE_X(x) ((ghid_flip_x ? PCB->MaxWidth - (x) : (x)))
#define SIDE_Y(y) ((ghid_flip_y ? PCB->MaxHeight - (y) : (y)))
|
|
From: <gi...@gp...> - 2011-07-24 06:21:14
|
The branch, master has been updated
via 1a4ea522931737a60d238ce7caddf7541e99b2cd (commit)
from 8455c14f6bcee89ba120c403eb629e1d230e7f1b (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/file.c | 4 +-
src/global.h | 103 +++++++++++++++++++++++++++--------------------------
src/pcb-printf.c | 33 ++++++++++-------
3 files changed, 74 insertions(+), 66 deletions(-)
=================
Commit Messages
=================
commit 1a4ea522931737a60d238ce7caddf7541e99b2cd
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Introduce Coord/Angle types, convert global.h and pcb-printf to use it
For now Grid (in PCB and Settings) and its increments are still
doubles to avoid serious breakage. Will change these to Coords
in a separate commit.
Also add %ma spec for Angle, tell file.c to use it, to prevent
printf problems with Angle when changing ctypes.
:100644 100644 c325c30... fef1046... M src/file.c
:100644 100644 08abbb8... 94f4fae... M src/global.h
:100644 100644 9f6734b... 7562a57... M src/pcb-printf.c
=========
Changes
=========
commit 1a4ea522931737a60d238ce7caddf7541e99b2cd
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Introduce Coord/Angle types, convert global.h and pcb-printf to use it
For now Grid (in PCB and Settings) and its increments are still
doubles to avoid serious breakage. Will change these to Coords
in a separate commit.
Also add %ma spec for Angle, tell file.c to use it, to prevent
printf problems with Angle when changing ctypes.
diff --git a/src/file.c b/src/file.c
index c325c30..fef1046 100644
--- a/src/file.c
+++ b/src/file.c
@@ -765,7 +765,7 @@ WriteElementData (FILE * FP, DataTypePtr Data)
for (p = element->Arc; p != NULL; p = g_list_next (p))
{
ArcType *arc = p->data;
- pcb_fprintf (FP, "\tElementArc [%mc %mc %mc %mc %d %d %mc]\n",
+ pcb_fprintf (FP, "\tElementArc [%mc %mc %mc %mc %ma %ma %mc]\n",
arc->X - element->MarkX,
arc->Y - element->MarkY,
arc->Width, arc->Height,
@@ -804,7 +804,7 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
for (n = layer->Arc; n != NULL; n = g_list_next (n))
{
ArcType *arc = n->data;
- pcb_fprintf (FP, "\tArc[%mc %mc %mc %mc %mc %mc %d %d %s]\n",
+ pcb_fprintf (FP, "\tArc[%mc %mc %mc %mc %mc %mc %ma %ma %s]\n",
arc->X, arc->Y, arc->Width,
arc->Height, arc->Thickness,
arc->Clearance, arc->StartAngle,
diff --git a/src/global.h b/src/global.h
index 08abbb8..94f4fae 100644
--- a/src/global.h
+++ b/src/global.h
@@ -83,13 +83,19 @@ typedef struct AttributeListType AttributeListType, *AttributeListTypePtr;
# define bindtextdomain(D, Dir) (D)
#endif /* ENABLE_NLS */
+
+typedef int Coord; /* pcb base unit */
+typedef int Angle; /* degrees */
+
+#if 1
typedef int LocationType;
typedef int BDimension; /* big dimension */
+#endif
/* This is used by the lexer/parser */
typedef struct {
int ival;
- BDimension bval;
+ Coord bval;
double dval;
char has_units;
} PLMeasure;
@@ -168,7 +174,7 @@ typedef struct
/* Lines, pads, and rats all use this so they can be cross-cast. */
#define ANYLINEFIELDS \
ANYOBJECTFIELDS; \
- BDimension Thickness, \
+ Coord Thickness, \
Clearance; \
PointType Point1, \
Point2
@@ -196,14 +202,14 @@ typedef struct
struct BoxType /* a bounding box */
{
- LocationType X1, Y1; /* upper left */
- LocationType X2, Y2; /* and lower right corner */
+ Coord X1, Y1; /* upper left */
+ Coord X2, Y2; /* and lower right corner */
};
typedef struct
{
- LocationType x, y;
- int width, height;
+ Coord x, y;
+ Coord width, height;
} RectangleType, *RectangleTypePtr;
typedef struct
@@ -230,7 +236,7 @@ typedef struct {
typedef struct /* a line/polygon point */
{
- LocationType X, Y, X2, Y2; /* so Point type can be cast as BoxType */
+ Coord X, Y, X2, Y2; /* so Point type can be cast as BoxType */
long int ID;
} PointType, *PointTypePtr;
@@ -248,8 +254,8 @@ typedef struct /* holds information about one line */
typedef struct
{
ANYOBJECTFIELDS;
- BDimension Scale; /* text scaling in percent */
- LocationType X, Y; /* origin */
+ int Scale; /* text scaling in percent */
+ Coord X, Y; /* origin */
BYTE Direction;
char *TextString; /* string */
void *Element;
@@ -273,12 +279,10 @@ struct polygon_st /* holds information about a polygon */
typedef struct /* holds information about arcs */
{
ANYOBJECTFIELDS;
- BDimension Thickness, Clearance;
- LocationType Width, /* length of axis */
- Height, X, /* center coordinates */
- Y;
- long int StartAngle, /* the two limiting angles in degrees */
- Delta;
+ Coord Thickness, Clearance;
+ Coord Width, Height, /* length of axis */
+ X, Y; /* center coordinates */
+ Angle StartAngle, Delta; /* the two limiting angles in degrees */
} ArcType, *ArcTypePtr;
struct rtree
@@ -316,7 +320,7 @@ typedef struct /* a rat-line */
struct pad_st /* a SMD pad */
{
ANYLINEFIELDS;
- BDimension Mask;
+ Coord Mask;
char *Name, *Number; /* 'Line' */
void *Element;
void *Spare;
@@ -325,9 +329,8 @@ struct pad_st /* a SMD pad */
struct pin_st
{
ANYOBJECTFIELDS;
- BDimension Thickness, Clearance, Mask, DrillingHole;
- LocationType X, /* center and diameter */
- Y;
+ Coord Thickness, Clearance, Mask, DrillingHole;
+ Coord X, Y; /* center and diameter */
char *Name, *Number;
void *Element;
void *Spare;
@@ -341,8 +344,7 @@ typedef struct
/* name on PCB second, */
/* value third */
/* see macro.h */
- LocationType MarkX, /* position mark */
- MarkY;
+ Coord MarkX, MarkY; /* position mark */
Cardinal PinN; /* number of pins */
Cardinal PadN; /* number of pads */
Cardinal LineN; /* number of lines */
@@ -364,13 +366,13 @@ typedef struct /* a single symbol */
bool Valid;
Cardinal LineN, /* number of lines */
LineMax;
- BDimension Width, /* size of cell */
- Height, Delta; /* distance to next symbol in 0.00001'' */
+ Coord Width, Height, /* size of cell */
+ Delta; /* distance to next symbol */
} SymbolType, *SymbolTypePtr;
typedef struct /* complete set of symbols */
{
- LocationType MaxHeight, /* maximum cell width and height */
+ Coord MaxHeight, /* maximum cell width and height */
MaxWidth;
BoxType DefaultSymbol; /* the default symbol is a filled box */
SymbolType Symbol[MAX_FONTPOSITION + 1];
@@ -394,7 +396,7 @@ typedef struct /* holds all objects */
typedef struct /* holds drill information */
{
- BDimension DrillSize; /* this drill's diameter */
+ Coord DrillSize; /* this drill's diameter */
Cardinal ElementN, /* the number of elements using this drill size */
ElementMax, /* max number of elements from malloc() */
PinCount, /* number of pins drilled this size */
@@ -415,7 +417,7 @@ typedef struct /* holds a range of Drill Infos */
typedef struct
{
- BDimension Thick, /* line thickness */
+ Coord Thick, /* line thickness */
Diameter, /* via diameter */
Hole, /* via drill hole */
Keepaway; /* min. separation from other nets */
@@ -496,14 +498,14 @@ typedef struct PCBType
*RatSelectedColor, *ConnectedColor, *WarnColor, *MaskColor;
long CursorX, /* cursor position as saved with layout */
CursorY, Clipping;
- int Bloat, /* drc sizes saved with layout */
+ Coord Bloat, /* drc sizes saved with layout */
Shrink, minWid, minSlk, minDrill, minRing;
- int GridOffsetX, /* as saved with layout */
+ Coord GridOffsetX, /* as saved with layout */
GridOffsetY, MaxWidth, /* allowed size */
MaxHeight;
- double Grid, /* used grid with offsets */
- Zoom, /* zoom factor */
+ double Grid; /* used grid with offsets */
+ double Zoom, /* zoom factor */
IsleArea, /* minimum poly island to retain */
ThermScale; /* scale factor used with thermals */
FontType Font;
@@ -519,8 +521,7 @@ PCBType, *PCBTypePtr;
typedef struct /* information about the paste buffer */
{
- LocationType X, /* offset */
- Y;
+ Coord X, Y; /* offset */
BoxType BoundingBox;
DataTypePtr Data; /* data; not all members of PCBType */
/* are used */
@@ -555,8 +556,7 @@ typedef struct /* currently marked block */
typedef struct /* currently attached object */
{
- LocationType X, /* saved position when MOVE_MODE */
- Y; /* was entered */
+ Coord X, Y; /* saved position when MOVE_MODE */
BoxType BoundingBox;
long int Type, /* object type */
State;
@@ -580,20 +580,20 @@ typedef struct /* holds cursor information */
{
hidGC GC, /* GC for cursor drawing */
AttachGC; /* and for displaying buffer contents */
- LocationType X, /* position in PCB coordinates */
- Y, MinX, /* lowest and highest coordinates */
- MinY, MaxX, MaxY;
+ Coord X, Y, /* position in PCB coordinates */
+ MinX, MinY, /* lowest and highest coordinates */
+ MaxX, MaxY;
AttachedLineType AttachedLine; /* data of new lines... */
AttachedBoxType AttachedBox;
PolygonType AttachedPolygon;
AttachedObjectType AttachedObject; /* data of attached objects */
- enum crosshair_shape shape; /* shape of crosshair */
+ enum crosshair_shape shape; /* shape of crosshair */
} CrosshairType, *CrosshairTypePtr;
typedef struct
{
bool status;
- long int X, Y;
+ Coord X, Y;
} MarkType, *MarkTypePtr;
/* ---------------------------------------------------------------------------
@@ -625,18 +625,20 @@ typedef struct /* some resources... */
*GridColor,
*LayerColor[MAX_LAYER],
*LayerSelectedColor[MAX_LAYER], *WarnColor, *MaskColor;
- int ViaThickness, /* some preset values */
- ViaDrillingHole, LineThickness, RatThickness, Keepaway, MaxWidth, /* default size of a new layout */
- MaxHeight, TextScale, /* text scaling in % */
+ Coord ViaThickness, /* some preset values */
+ ViaDrillingHole, LineThickness, RatThickness, Keepaway, /* default size of a new layout */
+ MaxWidth, MaxHeight,
AlignmentDistance, Bloat, /* default drc sizes */
Shrink, minWid, minSlk, minDrill, minRing;
- double Grid, /* grid 0.001'' */
- IsleArea, /* polygon min area */
+ int TextScale; /* text scaling in % */
+ double Grid, /* grid in pcb-units */
grid_increment_mm, /* key g and <shift>g value for mil units */
grid_increment_mil, /* key g and <shift>g value for mil units */
size_increment_mm, /* key s and <shift>s value for mil units */
size_increment_mil, /* key s and <shift>s value for mil units */
- line_increment_mm, line_increment_mil, clear_increment_mm, clear_increment_mil, Zoom, /* number of shift operations for zooming */
+ line_increment_mm, line_increment_mil, clear_increment_mm, clear_increment_mil; /* number of shift operations for zooming */
+ double Zoom,
+ IsleArea, /* polygon min area */
PinoutZoom; /* same for pinout windows */
int PinoutNameLength, /* max displayed length of a pinname */
Volume, /* the speakers volume -100..100 */
@@ -659,9 +661,9 @@ typedef struct /* some resources... */
*GnetlistProgram, /* gnetlist program name */
*MakeProgram, /* make program name */
*InitialLayerStack; /* If set, the initial layer stack is set to this */
- LocationType PinoutOffsetX, /* offset of origin */
+ Coord PinoutOffsetX, /* offset of origin */
PinoutOffsetY;
- int PinoutTextOffsetX, /* offset of text from pin center */
+ Coord PinoutTextOffsetX, /* offset of text from pin center */
PinoutTextOffsetY;
RouteStyleType RouteStyle[NUM_STYLES]; /* default routing styles */
LayerGroupType LayerGroups; /* default layer groups */
@@ -716,7 +718,7 @@ typedef struct
typedef struct /* holds a connection */
{
- LocationType X, Y; /* coordinate of connection */
+ Coord X, Y; /* coordinate of connection */
long int type; /* type of object in ptr1 - 3 */
void *ptr1, *ptr2; /* the object of the connection */
Cardinal group; /* the layer group of the connection */
@@ -764,9 +766,8 @@ struct drc_violation_st
{
char *title;
char *explanation;
- int x;
- int y;
- int angle;
+ Coord x, y;
+ Angle angle;
int have_measured;
double measured_value;
double required_value;
diff --git a/src/pcb-printf.c b/src/pcb-printf.c
index 9f6734b..7562a57 100644
--- a/src/pcb-printf.c
+++ b/src/pcb-printf.c
@@ -81,7 +81,7 @@ static int min_sig_figs(double d)
* 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. */
-static gchar *CoordsToString(BDimension coord[], int n_coords, const char *printf_spec, enum e_allow allow, enum e_suffix suffix_type)
+static gchar *CoordsToString(Coord coord[], int n_coords, const char *printf_spec, enum e_allow allow, enum e_suffix suffix_type)
{
GString *buff;
gchar *printf_buff;
@@ -236,7 +236,7 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
{
gchar *unit_str = NULL;
const char *ext_unit = "";
- BDimension value[10];
+ Coord value[10];
int count, i;
g_string_assign (spec, "");
@@ -324,8 +324,8 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
++fmt;
if (*fmt == '*')
ext_unit = va_arg(args, const char *);
- if (*fmt != '+')
- value[0] = va_arg(args, BDimension);
+ if (*fmt != '+' && *fmt != 'a')
+ value[0] = va_arg(args, Coord);
count = 1;
switch(*fmt)
{
@@ -335,20 +335,20 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
case 'L': unit_str = CoordsToString(value, 1, spec->str, mask & ALLOW_IMPERIAL, suffix); break;
case 'r': unit_str = CoordsToString(value, 1, spec->str, ALLOW_READABLE, FILE_MODE); break;
/* All these fallthroughs are deliberate */
- case '9': value[count++] = va_arg(args, BDimension);
- case '8': value[count++] = va_arg(args, BDimension);
- case '7': value[count++] = va_arg(args, BDimension);
- case '6': value[count++] = va_arg(args, BDimension);
- case '5': value[count++] = va_arg(args, BDimension);
- case '4': value[count++] = va_arg(args, BDimension);
- case '3': value[count++] = va_arg(args, BDimension);
+ case '9': value[count++] = va_arg(args, Coord);
+ case '8': value[count++] = va_arg(args, Coord);
+ case '7': value[count++] = va_arg(args, Coord);
+ case '6': value[count++] = va_arg(args, Coord);
+ case '5': value[count++] = va_arg(args, Coord);
+ case '4': value[count++] = va_arg(args, Coord);
+ case '3': value[count++] = va_arg(args, Coord);
case '2':
case 'D':
- value[count++] = va_arg(args, BDimension);
+ value[count++] = va_arg(args, Coord);
unit_str = CoordsToString(value, count, spec->str, mask & ALLOW_ALL, suffix);
break;
case 'd':
- value[1] = va_arg(args, BDimension);
+ value[1] = va_arg(args, Coord);
unit_str = CoordsToString(value, 2, spec->str, ALLOW_MM | ALLOW_MIL, suffix);
break;
case '*':
@@ -358,6 +358,13 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
if (unit_str == NULL)
unit_str = CoordsToString(value, 1, spec->str, mask & ALLOW_ALL, suffix);
break;
+ case 'a':
+ value[0] = va_arg(args, Angle);
+ g_string_append (spec, ".0f");
+ if (suffix == SUFFIX)
+ g_string_append (spec, " deg");
+ unit_str = g_strdup_printf (spec->str, value[0]);
+ break;
case '+':
mask = va_arg(args, enum e_allow);
break;
|
|
From: <gi...@gp...> - 2011-07-24 00:16:11
|
The branch, master has been updated
via 8455c14f6bcee89ba120c403eb629e1d230e7f1b (commit)
from ac84c0aae23879d66f5dfe9740ca0b563adeec04 (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
=========
gts/boolean.c | 32 ++++++++++++++++----------------
gts/cdt.c | 4 ++--
gts/edge.c | 3 ---
gts/partition.c | 6 +++---
gts/split.c | 6 +++---
5 files changed, 24 insertions(+), 27 deletions(-)
=================
Commit Messages
=================
commit 8455c14f6bcee89ba120c403eb629e1d230e7f1b
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
gts: Fixup warnings due to assigned but unused variables
As I'm not 100% familiar with this code, I have commented out some of
the redundant code rather than deleting it completely.
:100644 100644 8b76d42... 79f3e0c... M gts/boolean.c
:100644 100644 2038ab5... 61c4eb5... M gts/cdt.c
:100644 100644 fde7d87... 708c06c... M gts/edge.c
:100644 100644 16dc0e1... 3b73e68... M gts/partition.c
:100644 100644 8283e17... 43fea3a... M gts/split.c
=========
Changes
=========
commit 8455c14f6bcee89ba120c403eb629e1d230e7f1b
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
gts: Fixup warnings due to assigned but unused variables
As I'm not 100% familiar with this code, I have commented out some of
the redundant code rather than deleting it completely.
diff --git a/gts/boolean.c b/gts/boolean.c
index 8b76d42..79f3e0c 100644
--- a/gts/boolean.c
+++ b/gts/boolean.c
@@ -379,10 +379,10 @@ static gint intersection_orientation (GtsTriangle * t1,
GTS_POINT (v2));
}
-#define UPDATE_ORIENTATION if (o > 0) { vi2 = v; e2 = e; } else { vi2 = vi1;\
- e2 = e1;\
- vi1 = v;\
- e1 = e; }
+#define UPDATE_ORIENTATION if (o > 0) { vi2 = v; /* e2 = e; */ } else { vi2 = vi1;\
+ /* e2 = e1; */\
+ vi1 = v;\
+ /* e1 = e; */ }
static void intersect_edges (GtsBBox * bb1, GtsBBox * bb2,
GtsSurfaceInter * si)
@@ -391,15 +391,15 @@ static void intersect_edges (GtsBBox * bb1, GtsBBox * bb2,
GtsTriangle * t1 = GTS_TRIANGLE (bb1->bounded);
GtsTriangle * t2 = GTS_TRIANGLE (bb2->bounded);
GtsVertex * v, * vi1 = NULL, * vi2 = NULL;
- GtsEdge * e1 = NULL, * e2 = NULL, * e;
+ //GtsEdge * e1 = NULL, * e2 = NULL, * e;
vi1 = intersects (t2->e1, t1, s1);
- e1 = t2->e1;
+ //e1 = t2->e1;
v = intersects (t2->e2, t1, s1);
- e = t2->e2;
+ //e = t2->e2;
if (!vi1) {
vi1 = v;
- e1 = e;
+ //e1 = e;
}
else if (v) {
gint o = intersection_orientation (t2, t2->e2, t1);
@@ -407,10 +407,10 @@ static void intersect_edges (GtsBBox * bb1, GtsBBox * bb2,
}
if (!vi2) {
v = intersects (t2->e3, t1, s1);
- e = t2->e3;
+ //e = t2->e3;
if (!vi1) {
vi1 = v;
- e1 = e;
+ //e1 = e;
}
else if (v) {
gint o = intersection_orientation (t2, t2->e3, t1);
@@ -419,10 +419,10 @@ static void intersect_edges (GtsBBox * bb1, GtsBBox * bb2,
}
if (!vi2) {
v = intersects (t1->e1, t2, s1);
- e = t1->e1;
+ //e = t1->e1;
if (!vi1) {
vi1 = v;
- e1 = e;
+ //e1 = e;
}
else if (v) {
gint o = - intersection_orientation (t1, t1->e1, t2);
@@ -431,10 +431,10 @@ static void intersect_edges (GtsBBox * bb1, GtsBBox * bb2,
}
if (!vi2) {
v = intersects (t1->e2, t2, s1);
- e = t1->e2;
+ //e = t1->e2;
if (!vi1) {
vi1 = v;
- e1 = e;
+ //e1 = e;
}
else if (v) {
gint o = - intersection_orientation (t1, t1->e2, t2);
@@ -443,10 +443,10 @@ static void intersect_edges (GtsBBox * bb1, GtsBBox * bb2,
}
if (!vi2) {
v = intersects (t1->e3, t2, s1);
- e = t1->e3;
+ //e = t1->e3;
if (!vi1) {
vi1 = v;
- e1 = e;
+ //e1 = e;
}
else if (v) {
gint o = - intersection_orientation (t1, t1->e3, t2);
diff --git a/gts/cdt.c b/gts/cdt.c
index 2038ab5..61c4eb5 100644
--- a/gts/cdt.c
+++ b/gts/cdt.c
@@ -974,7 +974,7 @@ GSList * gts_delaunay_add_constraint (GtsSurface * surface,
GtsConstraint * c)
{
GSList * constraints;
- GtsVertex * v1, * v2;
+ GtsVertex * v1; //, * v2;
GSList * left = NULL, * right = NULL;
GtsFace * ref = NULL;
@@ -983,7 +983,7 @@ GSList * gts_delaunay_add_constraint (GtsSurface * surface,
g_return_val_if_fail (GTS_IS_CONSTRAINT (c), NULL);
v1 = GTS_SEGMENT (c)->v1;
- v2 = GTS_SEGMENT (c)->v2;
+ //v2 = GTS_SEGMENT (c)->v2;
gts_allow_floating_edges = TRUE;
constraints = remove_intersected_vertex (GTS_SEGMENT (c), v1, surface,
diff --git a/gts/edge.c b/gts/edge.c
index fde7d87..708c06c 100644
--- a/gts/edge.c
+++ b/gts/edge.c
@@ -377,12 +377,9 @@ static void triangle_vertices_edges (GtsTriangle * t,
gboolean gts_edge_belongs_to_tetrahedron (GtsEdge * e)
{
GSList * i;
- GtsVertex * v1, * v2;
g_return_val_if_fail (e != NULL, FALSE);
- v1 = GTS_SEGMENT (e)->v1;
- v2 = GTS_SEGMENT (e)->v2;
i = e->triangles;
while (i) {
GtsEdge * e1, * e2;
diff --git a/gts/partition.c b/gts/partition.c
index 16dc0e1..3b73e68 100644
--- a/gts/partition.c
+++ b/gts/partition.c
@@ -833,19 +833,19 @@ static void update_neighbors (GtsGNode * n, GtsGraphBisection * bg,
if (gts_containee_is_contained (GTS_CONTAINEE (n1),
GTS_CONTAINER (bg->g))) {
GtsEHeap * h;
- GtsGraph * g1, * g2;
+ GtsGraph /* * g1,*/ * g2;
GHashTable * bg1;
if (gts_containee_is_contained (GTS_CONTAINEE (n1),
GTS_CONTAINER (bg->g1))) {
h = h1;
- g1 = bg->g1;
+ //g1 = bg->g1;
g2 = bg->g2;
bg1 = bg->bg1;
}
else {
h = h2;
- g1 = bg->g2;
+ //g1 = bg->g2;
g2 = bg->g1;
bg1 = bg->bg2;
}
diff --git a/gts/split.c b/gts/split.c
index 8283e17..43fea3a 100644
--- a/gts/split.c
+++ b/gts/split.c
@@ -923,8 +923,8 @@ GtsSplit * gts_split_new (GtsSplitClass * klass,
GtsObject * o2)
{
GtsSplit * vs;
- GtsVertex * v1, * v2;
#ifndef DYNAMIC_SPLIT
+ GtsVertex * v1, * v2;
GtsEdge * e;
GSList * i;
GtsSplitCFace * cf;
@@ -939,12 +939,12 @@ GtsSplit * gts_split_new (GtsSplitClass * klass,
vs->v = v;
vs->v1 = o1;
vs->v2 = o2;
- v1 = GTS_SPLIT_V1 (vs);
- v2 = GTS_SPLIT_V2 (vs);
#ifdef DYNAMIC_SPLIT
vs->ncf = 0;
vs->cfaces = NULL;
#else
+ v1 = GTS_SPLIT_V1 (vs);
+ v2 = GTS_SPLIT_V2 (vs);
g_assert ((e = GTS_EDGE (gts_vertices_are_connected (v1, v2))));
i = e->triangles;
vs->ncf = g_slist_length (i);
|
|
From: <gi...@gp...> - 2011-07-23 23:56:00
|
The branch, master has been updated
discards 54c04e4d07ac74e5deabded920313f170056da67 (commit)
via ac84c0aae23879d66f5dfe9740ca0b563adeec04 (commit)
from 54c04e4d07ac74e5deabded920313f170056da67 (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/common/hidgl.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
=================
Commit Messages
=================
commit ac84c0aae23879d66f5dfe9740ca0b563adeec04
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/common/hidgl.c: Cast the function pointers passed to gluTessCallback()
Silences compiler warnings about incompatible pointer types
:100644 100644 bbba217... 992f3e3... M src/hid/common/hidgl.c
=========
Changes
=========
commit ac84c0aae23879d66f5dfe9740ca0b563adeec04
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/common/hidgl.c: Cast the function pointers passed to gluTessCallback()
Silences compiler warnings about incompatible pointer types
diff --git a/src/hid/common/hidgl.c b/src/hid/common/hidgl.c
index bbba217..992f3e3 100644
--- a/src/hid/common/hidgl.c
+++ b/src/hid/common/hidgl.c
@@ -529,10 +529,10 @@ hidgl_fill_polygon (int n_coords, int *x, int *y)
vertices = malloc (sizeof(GLdouble) * n_coords * 3);
tobj = gluNewTess ();
- gluTessCallback(tobj, GLU_TESS_BEGIN, myBegin);
- gluTessCallback(tobj, GLU_TESS_VERTEX, myVertex);
- gluTessCallback(tobj, GLU_TESS_COMBINE, myCombine);
- gluTessCallback(tobj, GLU_TESS_ERROR, myError);
+ gluTessCallback(tobj, GLU_TESS_BEGIN, (_GLUfuncptr)myBegin);
+ gluTessCallback(tobj, GLU_TESS_VERTEX, (_GLUfuncptr)myVertex);
+ gluTessCallback(tobj, GLU_TESS_COMBINE, (_GLUfuncptr)myCombine);
+ gluTessCallback(tobj, GLU_TESS_ERROR, (_GLUfuncptr)myError);
gluTessBeginPolygon (tobj, NULL);
gluTessBeginContour (tobj);
@@ -646,10 +646,10 @@ hidgl_fill_pcb_polygon (PolygonType *poly, const BoxType *clip_box, double scale
info.vertices = malloc (sizeof(GLdouble) * vertex_count * 3);
info.tobj = gluNewTess ();
- gluTessCallback(info.tobj, GLU_TESS_BEGIN, myBegin);
- gluTessCallback(info.tobj, GLU_TESS_VERTEX, myVertex);
- gluTessCallback(info.tobj, GLU_TESS_COMBINE, myCombine);
- gluTessCallback(info.tobj, GLU_TESS_ERROR, myError);
+ gluTessCallback(info.tobj, GLU_TESS_BEGIN, (_GLUfuncptr)myBegin);
+ gluTessCallback(info.tobj, GLU_TESS_VERTEX, (_GLUfuncptr)myVertex);
+ gluTessCallback(info.tobj, GLU_TESS_COMBINE, (_GLUfuncptr)myCombine);
+ gluTessCallback(info.tobj, GLU_TESS_ERROR, (_GLUfuncptr)myError);
glPushAttrib (GL_STENCIL_BUFFER_BIT); /* Save the write mask etc.. for final restore */
glEnable (GL_STENCIL_TEST);
|
|
From: <gi...@gp...> - 2011-07-23 23:55:13
|
The branch, master has been updated
via 54c04e4d07ac74e5deabded920313f170056da67 (commit)
via d8701b55d2175778310e54b389fb28d7bbde796b (commit)
via e84b4de335e2b8ff9d5278b407a5670bbf19212c (commit)
via 398035f5d81e83178387452942f0c1e7224c4527 (commit)
via d592980b0af4763f1c6922edb95b2fef96093285 (commit)
via c3c6c802775c42ca6cd75eabaf294d155ddd6f15 (commit)
via f62032b5d54ce75260155e027b1331ab87e901cd (commit)
via 9e3d49e0818de1ead86439288a8d4187274707cd (commit)
via e7e3e3475e33391e45d42c4251d1204fdc0d4808 (commit)
via f1f60b2242b416be83a4d8311056f6369b0e0fec (commit)
via 8be7f9d519426c349c13f0f330cd60ce7c45e2ef (commit)
via f650381545bd92861eddb809d18216ebd3b57b17 (commit)
via 4b447cfa4a2dbf1823961ef2619f12b29f49fc1f (commit)
via 28657c667c96592bd055e6a4b54ddaafb1439b0a (commit)
via 2d396f64b331748ee4b163afbc5e568c3c49833e (commit)
via 29b0ab3a32aa445544402df46ef2106babd18ce7 (commit)
via 74d35e5730047eb707b53149472799b1dbfbc974 (commit)
from 9e33678b20433f571c54009c704e75d114a3ea10 (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 | 9 ++-----
src/autoroute.c | 6 +++++
src/copy.c | 3 --
src/djopt.c | 4 ---
src/find.c | 5 ----
src/fontmode.c | 3 +-
src/hid/bom/bom.c | 5 +---
src/hid/gcode/trace.c | 6 -----
src/hid/gtk/gtkhid-main.c | 16 +-------------
src/hid/gtk/gui-library-window.c | 2 -
src/hid/gtk/gui-top-window.c | 5 +---
src/line.c | 6 ++++-
src/polygon1.c | 13 +++++++++--
src/print.c | 2 -
src/puller.c | 16 ++++++++++----
src/rtree.c | 9 +++++++-
src/toporouter.c | 39 +++++++++++++++----------------------
src/undo.c | 22 +++++++-------------
18 files changed, 72 insertions(+), 99 deletions(-)
=================
Commit Messages
=================
commit d8701b55d2175778310e54b389fb28d7bbde796b
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
line.c: Fix a bogus compiler warning regarding a (X + c) >= X being always true.
line.c: In function âEnforceLineDRCâ:
line.c:491:7: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
It would appear that gcc (4.6.1-5ubuntu1) is identifying the conditional
portions of INDEXOFCURRENT which would always evaluate a particular way
if a given condition is met. It is "probably" safe to assume that this
warning manifests due to gcc considering each portion of the INDEXOFCURRENT
definition in turn.
It appears we can avoid this particular warning by temporarily assigning
INDEXOFCURRENT into a variable before we test with it.
:100644 100644 0411afc... 7da09dc... M src/line.c
commit e84b4de335e2b8ff9d5278b407a5670bbf19212c
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
toporouter.c: Fixup warnings due to assigned but unused variables
As I'm not 100% familiar with this code, I have commented out some of
the redundant code rather than deleting it completely.
:100644 100644 5a82b14... 3b52f24... M src/toporouter.c
commit 398035f5d81e83178387452942f0c1e7224c4527
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
undo.c: Fixup warnings due to assigned but unused variables
:100644 100644 21b86f4... 971c771... M src/undo.c
commit d592980b0af4763f1c6922edb95b2fef96093285
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
rtree.c: Fixup warnings due to assigned but unused variables
Adds a nasty cludge using #ifndef NDEBUG around a variable assignment
which is only used in a later assert() statement. (NB: assert()
evaluates to nothing if NDEBUG is defined).
:100644 100644 526d2b7... 680be3d... M src/rtree.c
commit c3c6c802775c42ca6cd75eabaf294d155ddd6f15
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
print.c: Fixup warnings due to assigned but unused variables
:100644 100644 1e3abc0... 7e7e412... M src/print.c
commit f62032b5d54ce75260155e027b1331ab87e901cd
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
puller.c: Fixup warnings due to assigned but unused variables
:100644 100644 8550872... 2fd37bc... M src/puller.c
commit 9e3d49e0818de1ead86439288a8d4187274707cd
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
polygon1.c: Fixup warnings due to assigned but unused variables
Adds a nasty cludge using #ifndef NDEBUG around a variable assignment
which is only used in a later assert() statement. (NB: assert()
evaluates to nothing if NDEBUG is defined).
:100644 100644 70d553f... ffb1542... M src/polygon1.c
commit e7e3e3475e33391e45d42c4251d1204fdc0d4808
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
fontmode.c: Fixup warnings due to assigned but unused variables
:100644 100644 69d61ea... 2575a33... M src/fontmode.c
commit f1f60b2242b416be83a4d8311056f6369b0e0fec
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
find.c: Fixup warnings due to assigned but unused variables
:100644 100644 c5159ba... 92c8b35... M src/find.c
commit 8be7f9d519426c349c13f0f330cd60ce7c45e2ef
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
djopt.c: Fixup warnings due to assigned but unused variables
:100644 100644 0b00d8e... d25d621... M src/djopt.c
commit f650381545bd92861eddb809d18216ebd3b57b17
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
copy.c: Fixup warnings due to assigned but unused variables
:100644 100644 b93fcfb... 4091389... M src/copy.c
commit 4b447cfa4a2dbf1823961ef2619f12b29f49fc1f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
autoroute.c: Fixup warnings due to assigned but unused variables
Adds a nasty cludge using #ifndef NDEBUG around a variable assignment
which is only used in a later assert() statement. (NB: assert()
evaluates to nothing if NDEBUG is defined).
:100644 100644 c799e93... 63ab15c... M src/autoroute.c
commit 28657c667c96592bd055e6a4b54ddaafb1439b0a
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
action.c: Fixup warnings due to assigned but unused variables
:100644 100644 8b7e6d5... 9b67924... M src/action.c
commit 2d396f64b331748ee4b163afbc5e568c3c49833e
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gcode: Fixup warnings due to assigned but unused variables
:100644 100644 8d7e5e6... 7fb9012... M src/hid/gcode/trace.c
commit 29b0ab3a32aa445544402df46ef2106babd18ce7
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/bom: Fixup warnings due to assigned but unused variables
:100644 100644 0870bb5... 89bd6eb... M src/hid/bom/bom.c
commit 74d35e5730047eb707b53149472799b1dbfbc974
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Fixup warnings due to assigned but unused variables
:100644 100644 2fcb37b... 6a8d904... M src/hid/gtk/gtkhid-main.c
:100644 100644 3c0c077... 0339cf0... M src/hid/gtk/gui-library-window.c
:100644 100644 b5caff9... b11d32c... M src/hid/gtk/gui-top-window.c
=========
Changes
=========
commit d8701b55d2175778310e54b389fb28d7bbde796b
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
line.c: Fix a bogus compiler warning regarding a (X + c) >= X being always true.
line.c: In function âEnforceLineDRCâ:
line.c:491:7: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
It would appear that gcc (4.6.1-5ubuntu1) is identifying the conditional
portions of INDEXOFCURRENT which would always evaluate a particular way
if a given condition is met. It is "probably" safe to assume that this
warning manifests due to gcc considering each portion of the INDEXOFCURRENT
definition in turn.
It appears we can avoid this particular warning by temporarily assigning
INDEXOFCURRENT into a variable before we test with it.
diff --git a/src/line.c b/src/line.c
index 0411afc..7da09dc 100644
--- a/src/line.c
+++ b/src/line.c
@@ -487,9 +487,13 @@ EnforceLineDRC (void)
bool shift;
float r1, r2;
+ /* Silence a bogus compiler warning by storing this in a variable */
+ int layer_idx = INDEXOFCURRENT;
+
if ( gui->mod1_is_pressed() || gui->control_is_pressed () || PCB->RatDraw
- || INDEXOFCURRENT >= max_copper_layer)
+ || layer_idx >= max_copper_layer)
return;
+
rs.X = r45.X = Crosshair.X;
rs.Y = r45.Y = Crosshair.Y;
/* first try starting straight */
commit e84b4de335e2b8ff9d5278b407a5670bbf19212c
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
toporouter.c: Fixup warnings due to assigned but unused variables
As I'm not 100% familiar with this code, I have commented out some of
the redundant code rather than deleting it completely.
diff --git a/src/toporouter.c b/src/toporouter.c
index 5a82b14..3b52f24 100644
--- a/src/toporouter.c
+++ b/src/toporouter.c
@@ -1487,13 +1487,10 @@ vertices_plane_distance(toporouter_spoint_t *a, toporouter_spoint_t *b) {
static inline void
vertex_outside_segment(toporouter_spoint_t *a, toporouter_spoint_t *b, gdouble r, toporouter_spoint_t *p)
{
- gdouble m;
toporouter_spoint_t temp[2];
- m = vertex_gradient(a,b);
-
vertices_on_line(a, vertex_gradient(a,b), r, &temp[0], &temp[1]);
-
+
if(vertices_plane_distance(&temp[0], b) > vertices_plane_distance(&temp[1], b)) {
p->x = temp[0].x;
p->y = temp[0].y;
@@ -1905,7 +1902,6 @@ read_pads(toporouter_t *r, toporouter_layer_t *l, guint layer)
{
toporouter_spoint_t p[2], rv[5];
gdouble x[2], y[2], t, m;
- GList *objectconstraints;
GList *vlist = NULL;
toporouter_bbox_t *bbox = NULL;
@@ -1926,8 +1922,6 @@ read_pads(toporouter_t *r, toporouter_layer_t *l, guint layer)
if( (l - r->layers == back && TEST_FLAG(ONSOLDERFLAG, pad)) ||
(l - r->layers == front && !TEST_FLAG(ONSOLDERFLAG, pad)) ) {
-
- objectconstraints = NULL;
t = (gdouble)pad->Thickness / 2.0f;
x[0] = pad->Point1.X;
x[1] = pad->Point2.X;
@@ -3407,8 +3401,11 @@ gdouble
triangle_interior_capacity(GtsTriangle *t, toporouter_vertex_t *v)
{
toporouter_edge_t *e = TOPOROUTER_EDGE(gts_triangle_edge_opposite(t, GTS_VERTEX(v)));
- gdouble x, y, m1, m2, c2, c1, len;
-
+ gdouble x, y, m1, m2, c2, c1;
+#ifdef DEBUG_ROUTE
+ gdouble len;
+#endif
+
g_assert(e);
m1 = toporouter_edge_gradient(e);
@@ -3425,9 +3422,8 @@ triangle_interior_capacity(GtsTriangle *t, toporouter_vertex_t *v)
y = (isinf(m2)) ? vy(edge_v1(e)) : (m2 * x) + c2;
- len = gts_point_distance2(GTS_POINT(edge_v1(e)), GTS_POINT(edge_v2(e)));
-
#ifdef DEBUG_ROUTE
+ len = gts_point_distance2(GTS_POINT(edge_v1(e)), GTS_POINT(edge_v2(e)));
printf("%f,%f len = %f v = %f,%f\n", x, y, len, vx(v), vy(v));
#endif
@@ -4843,7 +4839,7 @@ route(toporouter_t *r, toporouter_route_t *data, guint debug)
gint count = 0;
toporouter_vertex_t *srcv = NULL, *destv = NULL, *curpoint = NULL;
- toporouter_layer_t *cur_layer, *dest_layer;
+ toporouter_layer_t *cur_layer; //, *dest_layer;
g_assert(data->src->c != data->dest->c);
@@ -4858,7 +4854,8 @@ route(toporouter_t *r, toporouter_route_t *data, guint debug)
if(!curpoint || !destv) goto routing_return;
srcv = curpoint;
- cur_layer = vlayer(curpoint); dest_layer = vlayer(destv);
+ cur_layer = vlayer(curpoint);
+ //dest_layer = vlayer(destv);
data->path = NULL;
@@ -4897,7 +4894,7 @@ route(toporouter_t *r, toporouter_route_t *data, guint debug)
tempv = closest_dest_vertex(r, curpoint, data);
if(tempv) {
destv = tempv;
- dest_layer = vlayer(destv);//&r->layers[(int)vz(destv)];
+ //dest_layer = vlayer(destv);//&r->layers[(int)vz(destv)];
}
}
@@ -5521,18 +5518,13 @@ gdouble
export_pcb_drawarc(guint layer, toporouter_arc_t *a, guint thickness, guint keepaway)
{
gdouble sa, da, theta;
- gdouble x0, y0, x1, y1, d=0.;
+ gdouble d = 0.;
ArcTypePtr arc;
gint wind;
wind = coord_wind(a->x0, a->y0, a->x1, a->y1, vx(a->centre), vy(a->centre));
sa = coord_xangle(a->x0, a->y0, vx(a->centre), vy(a->centre)) * 180. / M_PI;
-
- x0 = a->x0 - vx(a->centre);
- x1 = a->x1 - vx(a->centre);
- y0 = a->y0 - vy(a->centre);
- y1 = a->y1 - vy(a->centre);
theta = arc_angle(a);
@@ -6201,17 +6193,18 @@ check_adj_pushing_vertex(toporouter_oproute_t *oproute, gdouble x0, gdouble y0,
if(vertex_line_normal_intersection(x0, y0, x1, y1, vx(n), vy(n), &segintx, &seginty)) {
toporouter_edge_t *e = tedge(n, v);
gdouble ms = 0., d = coord_distance(segintx, seginty, vx(n), vy(n));
- toporouter_vertex_t *a, *b;
+ //toporouter_vertex_t *a;
+ toporouter_vertex_t *b;
GList *closestnet = NULL;
g_assert(e);
if(v == tedge_v1(e)) {
- a = tedge_v1(e);
+ //a = tedge_v1(e);
b = tedge_v2(e);
closestnet = edge_routing(e);
}else{
- a = tedge_v2(e);
+ //a = tedge_v2(e);
b = tedge_v1(e);
closestnet = g_list_last(edge_routing(e));
}
commit 398035f5d81e83178387452942f0c1e7224c4527
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
undo.c: Fixup warnings due to assigned but unused variables
diff --git a/src/undo.c b/src/undo.c
index 21b86f4..971c771 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -1288,16 +1288,14 @@ AddObjectToRotateUndoList (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
void
MoveObjectToRemoveUndoList (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
{
- UndoListTypePtr undo;
+ if (Locked)
+ return;
- if (!Locked)
- {
- if (!RemoveList)
- RemoveList = CreateNewBuffer ();
+ if (!RemoveList)
+ RemoveList = CreateNewBuffer ();
- undo = GetUndoSlot (UNDO_REMOVE, OBJECT_ID (Ptr3), Type);
- MoveObjectToBuffer (RemoveList, PCB->Data, Type, Ptr1, Ptr2, Ptr3);
- }
+ GetUndoSlot (UNDO_REMOVE, OBJECT_ID (Ptr3), Type);
+ MoveObjectToBuffer (RemoveList, PCB->Data, Type, Ptr1, Ptr2, Ptr3);
}
/* ---------------------------------------------------------------------------
@@ -1351,10 +1349,8 @@ AddObjectToRemovePointUndoList (int Type,
void
AddObjectToInsertPointUndoList (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
{
- UndoListTypePtr undo;
-
if (!Locked)
- undo = GetUndoSlot (UNDO_INSERT_POINT, OBJECT_ID (Ptr3), Type);
+ GetUndoSlot (UNDO_INSERT_POINT, OBJECT_ID (Ptr3), Type);
}
static void
@@ -1451,10 +1447,8 @@ AddObjectToMoveToLayerUndoList (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
void
AddObjectToCreateUndoList (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
{
- UndoListTypePtr undo;
-
if (!Locked)
- undo = GetUndoSlot (UNDO_CREATE, OBJECT_ID (Ptr3), Type);
+ GetUndoSlot (UNDO_CREATE, OBJECT_ID (Ptr3), Type);
ClearFromPolygon (PCB->Data, Type, Ptr1, Ptr2);
}
commit d592980b0af4763f1c6922edb95b2fef96093285
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
rtree.c: Fixup warnings due to assigned but unused variables
Adds a nasty cludge using #ifndef NDEBUG around a variable assignment
which is only used in a later assert() statement. (NB: assert()
evaluates to nothing if NDEBUG is defined).
diff --git a/src/rtree.c b/src/rtree.c
index 526d2b7..680be3d 100644
--- a/src/rtree.c
+++ b/src/rtree.c
@@ -596,12 +596,19 @@ int
r_region_is_empty (rtree_t * rtree, const BoxType * region)
{
jmp_buf env;
+#ifndef NDEBUG
int r;
+#endif
if (setjmp (env))
return 0;
- r = r_search (rtree, region, NULL, __r_region_is_empty_rect_in_reg, &env);
+#ifndef NDEBUG
+ r =
+#endif
+ r_search (rtree, region, NULL, __r_region_is_empty_rect_in_reg, &env);
+#ifndef NDEBUG
assert (r == 0); /* otherwise longjmp would have been called */
+#endif
return 1; /* no rectangles found */
}
commit c3c6c802775c42ca6cd75eabaf294d155ddd6f15
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
print.c: Fixup warnings due to assigned but unused variables
diff --git a/src/print.c b/src/print.c
index 1e3abc0..7e7e412 100644
--- a/src/print.c
+++ b/src/print.c
@@ -222,12 +222,10 @@ PrintFab_overhang (void)
void
PrintFab (hidGC gc)
{
- PinType tmp_pin;
DrillInfoTypePtr AllDrills;
int i, n, yoff, total_drills = 0, ds = 0;
time_t currenttime;
char utcTime[64];
- tmp_pin.Flags = NoFlags ();
AllDrills = GetDrillInfo (PCB->Data);
RoundDrillInfo (AllDrills, MIL_TO_COORD(1));
yoff = -TEXT_LINE;
commit f62032b5d54ce75260155e027b1331ab87e901cd
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
puller.c: Fixup warnings due to assigned but unused variables
diff --git a/src/puller.c b/src/puller.c
index 8550872..2fd37bc 100644
--- a/src/puller.c
+++ b/src/puller.c
@@ -427,7 +427,10 @@ arc-line intersection was moved to.
static int
Puller (int argc, char **argv, int Ux, int Uy)
{
- double arc_angle, line_angle, rel_angle, base_angle;
+ double arc_angle, base_angle;
+#if TRACE1
+ double line_angle, rel_angle;
+#endif
double tangent;
int new_delta_angle;
@@ -484,13 +487,13 @@ Puller (int argc, char **argv, int Ux, int Uy)
arc_angle = the_arc->StartAngle + the_arc->Delta + 90;
else
arc_angle = the_arc->StartAngle + the_arc->Delta - 90;
- line_angle = r2d (atan2 (ey - y, x - ex));
- rel_angle = line_angle - arc_angle;
base_angle = r2d (atan2 (ey - cy, cx - ex));
tangent = r2d (acos (the_arc->Width / Distance (cx, cy, ex, ey)));
#if TRACE1
+ line_angle = r2d (atan2 (ey - y, x - ex));
+ rel_angle = line_angle - arc_angle;
printf ("arc %g line %g rel %g base %g\n", arc_angle, line_angle, rel_angle,
base_angle);
printf ("tangent %g\n", tangent);
@@ -1827,15 +1830,18 @@ gp_pad_cb (const BoxType *b, void *cb)
static LineTypePtr
create_line (LineTypePtr sample, int x1, int y1, int x2, int y2)
{
- Extra *e;
#if TRACE1
+ Extra *e;
pcb_printf("create_line from %#mD to %#mD\n", x1, y1, x2, y2);
#endif
LineTypePtr line = CreateNewLineOnLayer (CURRENT, x1, y1, x2, y2,
sample->Thickness, sample->Clearance, sample->Flags);
AddObjectToCreateUndoList (LINE_TYPE, CURRENT, line, line);
- e = new_line_extra (line);
+#if TRACE1
+ e =
+#endif
+ new_line_extra (line);
#if TRACE1
printf(" - line extra is %p\n", e);
#endif
commit 9e3d49e0818de1ead86439288a8d4187274707cd
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
polygon1.c: Fixup warnings due to assigned but unused variables
Adds a nasty cludge using #ifndef NDEBUG around a variable assignment
which is only used in a later assert() statement. (NB: assert()
evaluates to nothing if NDEBUG is defined).
diff --git a/src/polygon1.c b/src/polygon1.c
index 70d553f..ffb1542 100644
--- a/src/polygon1.c
+++ b/src/polygon1.c
@@ -1980,7 +1980,7 @@ M_POLYAREA_update_primary (jmp_buf * e, POLYAREA ** pieces,
POLYAREA *anext;
PLINE *curc, *next, *prev;
BoxType box;
- int inv_inside = 0;
+ /* int inv_inside = 0; */
int del_inside = 0;
int del_outside = 0;
int finished;
@@ -1998,7 +1998,7 @@ M_POLYAREA_update_primary (jmp_buf * e, POLYAREA ** pieces,
del_inside = 1;
break;
case PBO_XOR: /* NOT IMPLEMENTED OR USED */
- inv_inside = 1;
+ /* inv_inside = 1; */
assert (0);
break;
}
@@ -2649,7 +2649,9 @@ void
poly_InvContour (PLINE * c)
{
VNODE *cur, *next;
+#ifndef NDEBUG
int r;
+#endif
assert (c != NULL);
cur = &c->head;
@@ -2664,8 +2666,13 @@ poly_InvContour (PLINE * c)
c->Flags.orient ^= 1;
if (c->tree)
{
- r = r_search (c->tree, NULL, NULL, flip_cb, NULL);
+#ifndef NDEBUG
+ r =
+#endif
+ r_search (c->tree, NULL, NULL, flip_cb, NULL);
+#ifndef NDEBUG
assert (r == c->Count);
+#endif
}
}
commit e7e3e3475e33391e45d42c4251d1204fdc0d4808
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
fontmode.c: Fixup warnings due to assigned but unused variables
diff --git a/src/fontmode.c b/src/fontmode.c
index 69d61ea..2575a33 100644
--- a/src/fontmode.c
+++ b/src/fontmode.c
@@ -220,11 +220,10 @@ FontSave (int argc, char **argv, int Ux, int Uy)
LineType *l = ii->data;
int x1 = l->Point1.X;
int y1 = l->Point1.Y;
- int ox, oy, s;
+ int ox, s;
s = XYtoSym (x1, y1);
ox = (s % 16 + 1) * CELL_SIZE;
- oy = (s / 16 + 1) * CELL_SIZE;
symbol = &PCB->Font.Symbol[s];
x1 -= ox;
commit f1f60b2242b416be83a4d8311056f6369b0e0fec
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
find.c: Fixup warnings due to assigned but unused variables
diff --git a/src/find.c b/src/find.c
index c5159ba..92c8b35 100644
--- a/src/find.c
+++ b/src/find.c
@@ -1927,13 +1927,8 @@ static bool
LookupLOConnectionsToArc (ArcTypePtr Arc, Cardinal LayerGroup)
{
Cardinal entry;
- LocationType xlow, xhigh;
struct lo_info info;
- /* the maximum possible distance */
- xlow = Arc->BoundingBox.X1 - MAX (MAX_PADSIZE, MAX_LINESIZE) / 2;
- xhigh = Arc->BoundingBox.X2 + MAX (MAX_PADSIZE, MAX_LINESIZE) / 2;
-
info.arc = *Arc;
EXPAND_BOUNDS (&info.arc);
/* loop over all layers of the group */
commit 8be7f9d519426c349c13f0f330cd60ce7c45e2ef
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
djopt.c: Fixup warnings due to assigned but unused variables
diff --git a/src/djopt.c b/src/djopt.c
index 0b00d8e..d25d621 100644
--- a/src/djopt.c
+++ b/src/djopt.c
@@ -948,7 +948,6 @@ static int
split_line (line_s * l, corner_s * c)
{
int i;
- LayerType *layer;
LineType *pcbline;
line_s *ls;
@@ -965,7 +964,6 @@ split_line (line_s * l, corner_s * c)
}
check (c, l);
- layer = PCB->Data->Layer + l->layer;
pcbline = create_pcb_line (l->layer,
c->x, c->y, l->e->x, l->e->y,
l->line->Thickness, l->line->Clearance,
@@ -2558,7 +2556,6 @@ pinsnap ()
PinType *pin;
int again = 1;
- corner_s *prev_c;
int close = 0;
corner_s *c2;
@@ -2575,7 +2572,6 @@ pinsnap ()
if (!(c->pin || c->via || c->pad))
continue;
- prev_c = c;
pin = 0;
dprintf ("\ncorner %s\n", corner_name (c));
commit f650381545bd92861eddb809d18216ebd3b57b17
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
copy.c: Fixup warnings due to assigned but unused variables
diff --git a/src/copy.c b/src/copy.c
index b93fcfb..4091389 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -294,7 +294,6 @@ CopyElement (ElementTypePtr Element)
Element->Name[1].TextString);
#endif
- bool didDraw = false;
ElementTypePtr element = CopyElementLowLevel (PCB->Data,
NULL, Element,
TEST_FLAG (UNIQUENAMEFLAG,
@@ -307,12 +306,10 @@ CopyElement (ElementTypePtr Element)
{
DrawElementName (element);
DrawElementPackage (element);
- didDraw = true;
}
if (PCB->PinOn)
{
DrawElementPinsAndPads (element);
- didDraw = true;
}
#ifdef DEBUG
printf(" ... Leaving CopyElement.\n");
commit 4b447cfa4a2dbf1823961ef2619f12b29f49fc1f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
autoroute.c: Fixup warnings due to assigned but unused variables
Adds a nasty cludge using #ifndef NDEBUG around a variable assignment
which is only used in a later assert() statement. (NB: assert()
evaluates to nothing if NDEBUG is defined).
diff --git a/src/autoroute.c b/src/autoroute.c
index c799e93..63ab15c 100644
--- a/src/autoroute.c
+++ b/src/autoroute.c
@@ -4751,7 +4751,9 @@ RouteAll (routedata_t * rd)
p->flags.is_bad = 0;
if (!p->flags.fixed)
{
+#ifndef NDEBUG
bool del;
+#endif
assert (!p->flags.homeless);
if (rip)
{
@@ -4773,10 +4775,14 @@ RouteAll (routedata_t * rd)
{
if (TEST_FLAG (LIVEROUTEFLAG, PCB))
ripout_livedraw_obj (p);
+#ifndef NDEBUG
del =
+#endif
r_delete_entry (rd->layergrouptree[p->group],
&p->box);
+#ifndef NDEBUG
assert (del);
+#endif
}
else
{
commit 28657c667c96592bd055e6a4b54ddaafb1439b0a
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
action.c: Fixup warnings due to assigned but unused variables
diff --git a/src/action.c b/src/action.c
index 8b7e6d5..9b67924 100644
--- a/src/action.c
+++ b/src/action.c
@@ -2404,12 +2404,11 @@ static int
ActionDisperseElements (int argc, char **argv, int x, int y)
{
char *function = ARG (0);
- long minx, miny, maxx, maxy, dx, dy;
+ long minx, miny, maxy, dx, dy;
int all = 0, bad = 0;
minx = GAP;
miny = GAP;
- maxx = GAP;
maxy = GAP;
if (!function || !*function)
@@ -7402,8 +7401,6 @@ tempfile_name_new (char * name)
static int
tempfile_unlink (char * name)
{
- int rc;
-
#ifdef DEBUG
/* SDB says: Want to keep old temp files for examiniation when debugging */
return 0;
@@ -7413,7 +7410,7 @@ tempfile_unlink (char * name)
int e, rc2 = 0;
char *dname;
- rc = unlink (name);
+ unlink (name);
/* it is possible that the file was never created so it is OK if the
unlink fails */
@@ -7455,7 +7452,7 @@ tempfile_unlink (char * name)
}
#else
- rc = unlink (name);
+ int rc = unlink (name);
if (rc != 0) {
fprintf (stderr, _("Failed to unlink \"%s\"\n"), name);
commit 2d396f64b331748ee4b163afbc5e568c3c49833e
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gcode: Fixup warnings due to assigned but unused variables
diff --git a/src/hid/gcode/trace.c b/src/hid/gcode/trace.c
index 8d7e5e6..7fb9012 100644
--- a/src/hid/gcode/trace.c
+++ b/src/hid/gcode/trace.c
@@ -1406,10 +1406,7 @@ plotpolygon (privpath_t * pp, FILE * f, double scale)
int i;
int m = pp->m;
int *po = pp->po;
- int n = pp->len;
point_t *pt = pp->pt;
- int x0 = pp->x0;
- int y0 = pp->y0;
/* double scale=1.0/dpi; */
double dm = 0;
@@ -1417,10 +1414,7 @@ plotpolygon (privpath_t * pp, FILE * f, double scale)
return 0;
po = pp->po;
- n = pp->len;
pt = pp->pt;
- x0 = pp->x0;
- y0 = pp->y0;
fprintf (f, "G0 X%f Y%f (start point)\n", pt[po[0]].x * scale,
pt[po[0]].y * scale);
commit 29b0ab3a32aa445544402df46ef2106babd18ce7
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/bom: Fixup warnings due to assigned but unused variables
diff --git a/src/hid/bom/bom.c b/src/hid/bom/bom.c
index 0870bb5..89bd6eb 100644
--- a/src/hid/bom/bom.c
+++ b/src/hid/bom/bom.c
@@ -279,7 +279,7 @@ PrintBOM (void)
double theta = 0.0;
double sumx, sumy;
double pin1x = 0.0, pin1y = 0.0, pin1angle = 0.0;
- double pin2x = 0.0, pin2y = 0.0, pin2angle;
+ double pin2x = 0.0, pin2y = 0.0;
int found_pin1;
int found_pin2;
int pin_cnt;
@@ -364,7 +364,6 @@ PrintBOM (void)
{
pin2x = (double) pin->X;
pin2y = (double) pin->Y;
- pin2angle = 0.0; /* pins have no notion of angle */
found_pin2 = 1;
}
}
@@ -393,8 +392,6 @@ PrintBOM (void)
{
pin2x = (double) (pad->Point1.X + pad->Point2.X) / 2.0;
pin2y = (double) (pad->Point1.Y + pad->Point2.Y) / 2.0;
- pin2angle = (180.0 / M_PI) * atan2 (pad->Point1.Y - pad->Point2.Y,
- pad->Point2.X - pad->Point1.X);
found_pin2 = 1;
}
commit 74d35e5730047eb707b53149472799b1dbfbc974
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
hid/gtk: Fixup warnings due to assigned but unused variables
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 2fcb37b..6a8d904 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -127,7 +127,6 @@ Note that zoom factors of zero are silently ignored.
static int
Zoom (int argc, char **argv, int x, int y)
{
- double factor;
const char *vp;
double v;
@@ -161,17 +160,14 @@ Zoom (int argc, char **argv, int x, int y)
switch (argv[0][0])
{
case '-':
- factor = 1 / v;
zoom_by (1 / v, x, y);
break;
default:
case '+':
- factor = v;
zoom_by (v, x, y);
break;
case '=':
/* this needs to set the scale factor absolutely*/
- factor = 1.0;
zoom_to (v, x, y);
break;
}
@@ -184,7 +180,9 @@ static void
zoom_to (double new_zoom, int x, int y)
{
double max_zoom, xfrac, yfrac;
+#ifdef DEBUG
int cx, cy;
+#endif
/* gport->zoom:
* zoom value is PCB units per screen pixel. Larger numbers mean zooming
@@ -229,13 +227,11 @@ zoom_to (double new_zoom, int x, int y)
#ifdef DEBUG
printf ("max_zoom = %g, xfrac = %g, yfrac = %g, new_zoom = %g\n",
max_zoom, xfrac, yfrac, new_zoom);
-#endif
/* find center x and y */
cx = gport->view_x0 + gport->view_width * xfrac * gport->zoom;
cy = gport->view_y0 + gport->view_height * yfrac * gport->zoom;
-#ifdef DEBUG
pcb_printf ("zoom_to(): x0 = %#mS, cx = %#mS\n", gport->view_x0, cx);
pcb_printf ("zoom_to(): y0 = %#mS, cy = %#mS\n", gport->view_y0, cy);
#endif
@@ -376,11 +372,9 @@ ghid_set_crosshair (int x, int y, int action)
if (action == HID_SC_PAN_VIEWPORT)
{
GdkDisplay *display;
- GdkScreen *screen;
gint pos_x, pos_y, xofs, yofs;
display = gdk_display_get_default ();
- screen = gdk_display_get_default_screen (display);
/* figure out where the pointer is relative to the display */
gdk_display_get_pointer (display, NULL, &pos_x, &pos_y, NULL);
@@ -1648,16 +1642,10 @@ Benchmark (int argc, char **argv, int x, int y)
{
int i = 0;
time_t start, end;
- BoxType region;
GdkDisplay *display;
display = gdk_drawable_get_display (gport->drawable);
- region.X1 = 0;
- region.Y1 = 0;
- region.X2 = PCB->MaxWidth;
- region.Y2 = PCB->MaxHeight;
-
gdk_display_sync (display);
time (&start);
do
diff --git a/src/hid/gtk/gui-library-window.c b/src/hid/gtk/gui-library-window.c
index 3c0c077..0339cf0 100644
--- a/src/hid/gtk/gui-library-window.c
+++ b/src/hid/gtk/gui-library-window.c
@@ -364,7 +364,6 @@ static void
library_window_callback_tree_selection_changed (GtkTreeSelection * selection,
gpointer user_data)
{
- GtkTreeView *view;
GtkTreeModel *model;
GtkTreeIter iter;
GhidLibraryWindow *library_window = (GhidLibraryWindow *) user_data;
@@ -374,7 +373,6 @@ library_window_callback_tree_selection_changed (GtkTreeSelection * selection,
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return;
- view = gtk_tree_selection_get_tree_view (selection);
gtk_tree_model_get (model, &iter, MENU_ENTRY_COLUMN, &entry, -1);
if (entry == NULL)
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index b5caff9..b11d32c 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1073,7 +1073,6 @@ layer_select_button_cb (GtkWidget * widget, LayerButtonSet * lb)
static void
layer_enable_button_cb (GtkWidget * widget, gpointer data)
{
- LayerButtonSet *lb;
gint i, group, layer = GPOINTER_TO_INT (data);
gboolean active, redraw = FALSE;
@@ -1082,7 +1081,6 @@ layer_enable_button_cb (GtkWidget * widget, gpointer data)
if (layer_enable_button_cb_hold_off)
return;
- lb = &layer_buttons[layer];
switch (layer)
{
case LAYER_BUTTON_SILK:
@@ -2292,12 +2290,11 @@ ghid_listener_cb (GIOChannel *source,
static void
ghid_create_listener (void)
{
- guint tag;
GIOChannel *channel;
int fd = fileno (stdin);
channel = g_io_channel_unix_new (fd);
- tag = g_io_add_watch (channel, G_IO_IN, ghid_listener_cb, NULL);
+ g_io_add_watch (channel, G_IO_IN, ghid_listener_cb, NULL);
}
|
|
From: <gi...@gp...> - 2011-07-23 20:01:37
|
The branch, master has been updated
via 9e33678b20433f571c54009c704e75d114a3ea10 (commit)
via 7e6eecd18812912b6be43a890774d0b6e3cef3f4 (commit)
from 17712d53c4b07690ddfc550d8550c39e4b19dfbc (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/crosshair.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 80 insertions(+), 10 deletions(-)
=================
Commit Messages
=================
commit 9e33678b20433f571c54009c704e75d114a3ea10
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Snap to points along off-grid lines when drawing tracks
This should greatly easy making tidy layouts where some lines have
(perhaps by necessity) ended up off-grid.
This patch adds code to snap onto the center of a line. It finds
the nearest grid point to the cursor, then will allow snapping at
the intersections between the line in question and the lines of an
imaginary X and + centered on the nearest grid-point to the cursor.
This allows neat drawing of horizontal, vertical and 45 degree lines
which will land correctly on the existing line.
:100644 100644 6bcd002... 4024881... M src/crosshair.c
commit 7e6eecd18812912b6be43a890774d0b6e3cef3f4
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Rename some variables for clarity
:100644 100644 da8bb92... 6bcd002... M src/crosshair.c
=========
Changes
=========
commit 9e33678b20433f571c54009c704e75d114a3ea10
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Snap to points along off-grid lines when drawing tracks
This should greatly easy making tidy layouts where some lines have
(perhaps by necessity) ended up off-grid.
This patch adds code to snap onto the center of a line. It finds
the nearest grid point to the cursor, then will allow snapping at
the intersections between the line in question and the lines of an
imaginary X and + centered on the nearest grid-point to the cursor.
This allows neat drawing of horizontal, vertical and 45 degree lines
which will land correctly on the existing line.
diff --git a/src/crosshair.c b/src/crosshair.c
index 6bcd002..4024881 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -976,6 +976,75 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
check_snap_object (&snap_data, pnt->X, pnt->Y, true);
}
+ /* Code to snap at some sensible point along a line */
+ /* Pick the nearest grid-point in the x or y direction
+ * to align with, then adjust until we hit the line
+ */
+ ans = NO_TYPE;
+ if (TEST_FLAG (SNAPPINFLAG, PCB))
+ ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
+ LINE_TYPE, &ptr1, &ptr2, &ptr3);
+
+ if (ans != NO_TYPE)
+ {
+ LineType *line = (LineType *)ptr2;
+ LocationType try_x, try_y;
+ double dx, dy;
+ double dist;
+
+ dx = line->Point2.X - line->Point1.X;
+ dy = line->Point2.Y - line->Point1.Y;
+
+ /* Try snapping along the X axis */
+ if (dy != 0.)
+ {
+ /* Move in the X direction until we hit the line */
+ try_x = (nearest_grid_y - line->Point1.Y) / dy * dx + line->Point1.X;
+ try_y = nearest_grid_y;
+ check_snap_object (&snap_data, try_x, try_y, true);
+ }
+
+ /* Try snapping along the Y axis */
+ if (dx != 0.)
+ {
+ try_x = nearest_grid_x;
+ try_y = (nearest_grid_x - line->Point1.X) / dx * dy + line->Point1.Y;
+ check_snap_object (&snap_data, try_x, try_y, true);
+ }
+
+ if (dx != dy) /* If line not parallel with dX = dY direction.. */
+ {
+ /* Try snapping diagonally towards the line in the dX = dY direction */
+
+ if (dy == 0)
+ dist = line->Point1.Y - nearest_grid_y;
+ else
+ dist = ((line->Point1.X - nearest_grid_x) -
+ (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 - dx / dy);
+
+ try_x = nearest_grid_x + dist;
+ try_y = nearest_grid_y + dist;
+
+ check_snap_object (&snap_data, try_x, try_y, true);
+ }
+
+ if (dx != -dy) /* If line not parallel with dX = -dY direction.. */
+ {
+ /* Try snapping diagonally towards the line in the dX = -dY direction */
+
+ if (dy == 0)
+ dist = nearest_grid_y - line->Point1.Y;
+ else
+ dist = ((line->Point1.X - nearest_grid_x) -
+ (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 + dx / dy);
+
+ try_x = nearest_grid_x + dist;
+ try_y = nearest_grid_y - dist;
+
+ check_snap_object (&snap_data, try_x, try_y, true);
+ }
+ }
+
ans = NO_TYPE;
if (TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
commit 7e6eecd18812912b6be43a890774d0b6e3cef3f4
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Rename some variables for clarity
diff --git a/src/crosshair.c b/src/crosshair.c
index da8bb92..6bcd002 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -825,7 +825,7 @@ check_snap_object (struct snap_data *snap_data, LocationType x, LocationType y,
void
FitCrosshairIntoGrid (LocationType X, LocationType Y)
{
- LocationType x, y;
+ LocationType nearest_grid_x, nearest_grid_y;
void *ptr1, *ptr2, *ptr3;
struct snap_data snap_data;
int ans;
@@ -835,31 +835,32 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
if (PCB->RatDraw)
{
- x = -600;
- y = -600;
+ nearest_grid_x = -600;
+ nearest_grid_y = -600;
}
else
{
- x = GRIDFIT_X (Crosshair.X, PCB->Grid);
- y = GRIDFIT_Y (Crosshair.Y, PCB->Grid);
+ nearest_grid_x = GRIDFIT_X (Crosshair.X, PCB->Grid);
+ nearest_grid_y = GRIDFIT_Y (Crosshair.Y, PCB->Grid);
if (Marked.status && TEST_FLAG (ORTHOMOVEFLAG, PCB))
{
int dx = Crosshair.X - Marked.X;
int dy = Crosshair.Y - Marked.Y;
if (ABS (dx) > ABS (dy))
- y = Marked.Y;
+ nearest_grid_y = Marked.Y;
else
- x = Marked.X;
+ nearest_grid_x = Marked.X;
}
}
snap_data.crosshair = &Crosshair;
- snap_data.nearest_sq_dist = crosshair_sq_dist (&Crosshair, x, y);
+ snap_data.nearest_sq_dist =
+ crosshair_sq_dist (&Crosshair, nearest_grid_x, nearest_grid_y);
snap_data.nearest_is_grid = true;
- snap_data.x = x;
- snap_data.y = y;
+ snap_data.x = nearest_grid_x;
+ snap_data.y = nearest_grid_y;
ans = NO_TYPE;
if (!PCB->RatDraw)
|
|
From: <gi...@gp...> - 2011-07-23 18:50:43
|
The branch, master has been updated
via 17712d53c4b07690ddfc550d8550c39e4b19dfbc (commit)
via cdec41df38054f12fdbed7e444c3b71c9e662e93 (commit)
from 4e60f8903dba10c0acad8a912bd8affe76bee2fa (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/crosshair.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
=================
Commit Messages
=================
commit 17712d53c4b07690ddfc550d8550c39e4b19dfbc
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Always allow snapping to the element mark (except in rat-draw mode)
:100644 100644 67613b6... da8bb92... M src/crosshair.c
commit cdec41df38054f12fdbed7e444c3b71c9e662e93
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Don't snap to an element's mark in rat-draw mode.
:100644 100644 b5e35f5... 67613b6... M src/crosshair.c
=========
Changes
=========
commit 17712d53c4b07690ddfc550d8550c39e4b19dfbc
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Always allow snapping to the element mark (except in rat-draw mode)
diff --git a/src/crosshair.c b/src/crosshair.c
index 67613b6..da8bb92 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -862,7 +862,7 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
snap_data.y = y;
ans = NO_TYPE;
- if (!PCB->RatDraw && TEST_FLAG (SNAPPINFLAG, PCB))
+ if (!PCB->RatDraw)
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
ELEMENT_TYPE, &ptr1, &ptr2, &ptr3);
commit cdec41df38054f12fdbed7e444c3b71c9e662e93
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Don't snap to an element's mark in rat-draw mode.
diff --git a/src/crosshair.c b/src/crosshair.c
index b5e35f5..67613b6 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -862,7 +862,7 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
snap_data.y = y;
ans = NO_TYPE;
- if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
+ if (!PCB->RatDraw && TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
ELEMENT_TYPE, &ptr1, &ptr2, &ptr3);
|
|
From: <gi...@gp...> - 2011-07-23 18:11:42
|
The branch, master has been updated
via 4e60f8903dba10c0acad8a912bd8affe76bee2fa (commit)
from 434c8d98aeed40ec39ad4beb90210328cc6789b5 (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/crosshair.c | 32 ++------------------------------
1 files changed, 2 insertions(+), 30 deletions(-)
=================
Commit Messages
=================
commit 4e60f8903dba10c0acad8a912bd8affe76bee2fa
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Drop checks to ensure the crosshair is inside the PCB
It would seem that the MIN, MAX functions applied when setting
Crosshair.X and Crosshair.Y should already constrain the coordinates
such that the removed code was never triggered.
It isn't obvious that these removed checks are even correct, or are
being triggered. Drop the checks in the hope that the now simplified
code continues to "just work" without the special casing.
:100644 100644 b7f3d91... b5e35f5... M src/crosshair.c
=========
Changes
=========
commit 4e60f8903dba10c0acad8a912bd8affe76bee2fa
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
crosshair.c: Drop checks to ensure the crosshair is inside the PCB
It would seem that the MIN, MAX functions applied when setting
Crosshair.X and Crosshair.Y should already constrain the coordinates
such that the removed code was never triggered.
It isn't obvious that these removed checks are even correct, or are
being triggered. Drop the checks in the hope that the now simplified
code continues to "just work" without the special casing.
diff --git a/src/crosshair.c b/src/crosshair.c
index b7f3d91..b5e35f5 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -840,36 +840,8 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
}
else
{
- /* check if new position is inside the output window
- * This might not be true after the window has been resized.
- * In this case we just set it to the center of the window or
- * with respect to the grid (if possible)
- */
- if (Crosshair.X < 0 || Crosshair.X > PCB->MaxWidth)
- {
- if (PCB->MaxWidth + 1 >= PCB->Grid)
- /* there must be a point that matches the grid
- * so we just have to look for it with some integer
- * calculations
- */
- x = GRIDFIT_X (PCB->Grid, PCB->Grid);
- else
- x = PCB->MaxWidth / 2;
- }
- else
- /* check if the new position matches the grid */
- x = GRIDFIT_X (Crosshair.X, PCB->Grid);
-
- /* do the same for the second coordinate */
- if (Crosshair.Y < 0 || Crosshair.Y > PCB->MaxHeight)
- {
- if (PCB->MaxHeight + 1 >= PCB->Grid)
- y = GRIDFIT_Y (PCB->Grid, PCB->Grid);
- else
- y = PCB->MaxHeight / 2;
- }
- else
- y = GRIDFIT_Y (Crosshair.Y, PCB->Grid);
+ x = GRIDFIT_X (Crosshair.X, PCB->Grid);
+ y = GRIDFIT_Y (Crosshair.Y, PCB->Grid);
if (Marked.status && TEST_FLAG (ORTHOMOVEFLAG, PCB))
{
|
|
From: <gi...@gp...> - 2011-07-23 17:54:37
|
The branch, master has been updated
via 434c8d98aeed40ec39ad4beb90210328cc6789b5 (commit)
from c66a3a6c9064559bdead374bf7a01cb4475a256a (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/parse_y.y | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
=================
Commit Messages
=================
commit 434c8d98aeed40ec39ad4beb90210328cc6789b5
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
parse_y.y: Remove unused GRIDFIT macro
:100644 100644 8eaba94... f35d9d0... M src/parse_y.y
=========
Changes
=========
commit 434c8d98aeed40ec39ad4beb90210328cc6789b5
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
parse_y.y: Remove unused GRIDFIT macro
diff --git a/src/parse_y.y b/src/parse_y.y
index 8eaba94..f35d9d0 100644
--- a/src/parse_y.y
+++ b/src/parse_y.y
@@ -42,7 +42,6 @@
#include "config.h"
#endif
-#define GRIDFIT(x,g) (int)(0.5 + (int)(((x)+(g)/2.)/(g))*(g))
#include "global.h"
#include "create.h"
#include "data.h"
|
|
From: <gi...@gp...> - 2011-07-23 17:37:58
|
The branch, master has been updated
via c66a3a6c9064559bdead374bf7a01cb4475a256a (commit)
via d5bf0d106e9b2570abace48d8d24f83990c41d3f (commit)
from 69cc8291eb5e9b2cdcbc33a702b1044a4ce906ff (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/crosshair.c | 228 +++++++++++++++++++++++++------------------------------
1 files changed, 104 insertions(+), 124 deletions(-)
=================
Commit Messages
=================
commit c66a3a6c9064559bdead374bf7a01cb4475a256a
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Try snapping to element marks first, as they are only a weak snap.
Because the element mark is never chosen in preference to a closer grid
point, we should try snapping to it first - rather than last.
Currently, we might have a crosshair location where (say), a pad is snapped
to in preference to the nearest grid-point, then the element mark is tested
and snapped to because it is closer than the pad. This can occur even when
there is a closer grid point than the element mark, since the grid snap
(nearest_is_grid == true) has already been discarded by the snap to the pad.
:100644 100644 62d3da0... b7f3d91... M src/crosshair.c
commit d5bf0d106e9b2570abace48d8d24f83990c41d3f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Refactor crosshair snap code to reduce duplication and improve readability
:100644 100644 c2551ec... 62d3da0... M src/crosshair.c
=========
Changes
=========
commit c66a3a6c9064559bdead374bf7a01cb4475a256a
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Try snapping to element marks first, as they are only a weak snap.
Because the element mark is never chosen in preference to a closer grid
point, we should try snapping to it first - rather than last.
Currently, we might have a crosshair location where (say), a pad is snapped
to in preference to the nearest grid-point, then the element mark is tested
and snapped to because it is closer than the pad. This can occur even when
there is a closer grid point than the element mark, since the grid snap
(nearest_is_grid == true) has already been discarded by the snap to the pad.
diff --git a/src/crosshair.c b/src/crosshair.c
index 62d3da0..b7f3d91 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -892,6 +892,17 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
ans = NO_TYPE;
if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
+ ELEMENT_TYPE, &ptr1, &ptr2, &ptr3);
+
+ if (ans & ELEMENT_TYPE)
+ {
+ ElementType *el = (ElementType *) ptr1;
+ check_snap_object (&snap_data, el->MarkX, el->MarkY, false);
+ }
+
+ ans = NO_TYPE;
+ if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
+ ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
PAD_TYPE, &ptr1, &ptr2, &ptr3);
/* Avoid self-snapping when moving */
@@ -1003,18 +1014,6 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
check_snap_object (&snap_data, pnt->X, pnt->Y, true);
}
-
- ans = NO_TYPE;
- if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
- ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
- ELEMENT_TYPE, &ptr1, &ptr2, &ptr3);
-
- if (ans & ELEMENT_TYPE)
- {
- ElementType *el = (ElementType *) ptr1;
- check_snap_object (&snap_data, el->MarkX, el->MarkY, false);
- }
-
if (snap_data.x >= 0 && snap_data.y >= 0)
{
Crosshair.X = snap_data.x;
commit d5bf0d106e9b2570abace48d8d24f83990c41d3f
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Refactor crosshair snap code to reduce duplication and improve readability
diff --git a/src/crosshair.c b/src/crosshair.c
index c2551ec..62d3da0 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -783,28 +783,60 @@ square (double x)
return x * x;
}
+static double
+crosshair_sq_dist (CrosshairType *crosshair, LocationType x, LocationType y)
+{
+ return square (x - crosshair->X) + square (y - crosshair->Y);
+}
+
+struct snap_data {
+ CrosshairType *crosshair;
+ double nearest_sq_dist;
+ bool nearest_is_grid;
+ LocationType x, y;
+};
+
+/* Snap to a given location if it is the closest thing we found so far.
+ * If "prefer_to_grid" is set, the passed location will take preference
+ * over a closer grid points we already snapped to UNLESS the user is
+ * pressing the SHIFT key. If the SHIFT key is pressed, the closest object
+ * (including grid points), is always preferred.
+ */
+static void
+check_snap_object (struct snap_data *snap_data, LocationType x, LocationType y,
+ bool prefer_to_grid)
+{
+ double sq_dist;
+
+ sq_dist = crosshair_sq_dist (snap_data->crosshair, x, y);
+ if (sq_dist < snap_data->nearest_sq_dist ||
+ (prefer_to_grid && snap_data->nearest_is_grid && !gui->shift_is_pressed()))
+ {
+ snap_data->x = x;
+ snap_data->y = y;
+ snap_data->nearest_sq_dist = sq_dist;
+ snap_data->nearest_is_grid = false;
+ }
+}
+
/* ---------------------------------------------------------------------------
* recalculates the passed coordinates to fit the current grid setting
*/
void
FitCrosshairIntoGrid (LocationType X, LocationType Y)
{
- LocationType x2, y2, x0, y0;
+ LocationType x, y;
void *ptr1, *ptr2, *ptr3;
- double nearest, sq_dist;
+ struct snap_data snap_data;
int ans;
- x0 = 0;
- y0 = 0;
- x2 = PCB->MaxWidth;
- y2 = PCB->MaxHeight;
Crosshair.X = MIN (Crosshair.MaxX, MAX (Crosshair.MinX, X));
Crosshair.Y = MIN (Crosshair.MaxY, MAX (Crosshair.MinY, Y));
if (PCB->RatDraw)
{
- x0 = -600;
- y0 = -600;
+ x = -600;
+ y = -600;
}
else
{
@@ -813,61 +845,66 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
* In this case we just set it to the center of the window or
* with respect to the grid (if possible)
*/
- if (Crosshair.X < x0 || Crosshair.X > x2)
+ if (Crosshair.X < 0 || Crosshair.X > PCB->MaxWidth)
{
- if (x2 + 1 >= PCB->Grid)
+ if (PCB->MaxWidth + 1 >= PCB->Grid)
/* there must be a point that matches the grid
* so we just have to look for it with some integer
* calculations
*/
- x0 = GRIDFIT_X (PCB->Grid, PCB->Grid);
+ x = GRIDFIT_X (PCB->Grid, PCB->Grid);
else
- x0 = (x2) / 2;
+ x = PCB->MaxWidth / 2;
}
else
/* check if the new position matches the grid */
- x0 = GRIDFIT_X (Crosshair.X, PCB->Grid);
+ x = GRIDFIT_X (Crosshair.X, PCB->Grid);
/* do the same for the second coordinate */
- if (Crosshair.Y < y0 || Crosshair.Y > y2)
+ if (Crosshair.Y < 0 || Crosshair.Y > PCB->MaxHeight)
{
- if (y2 + 1 >= PCB->Grid)
- y0 = GRIDFIT_Y (PCB->Grid, PCB->Grid);
+ if (PCB->MaxHeight + 1 >= PCB->Grid)
+ y = GRIDFIT_Y (PCB->Grid, PCB->Grid);
else
- y0 = (y2) / 2;
+ y = PCB->MaxHeight / 2;
}
else
- y0 = GRIDFIT_Y (Crosshair.Y, PCB->Grid);
+ y = GRIDFIT_Y (Crosshair.Y, PCB->Grid);
if (Marked.status && TEST_FLAG (ORTHOMOVEFLAG, PCB))
{
int dx = Crosshair.X - Marked.X;
int dy = Crosshair.Y - Marked.Y;
if (ABS (dx) > ABS (dy))
- y0 = Marked.Y;
+ y = Marked.Y;
else
- x0 = Marked.X;
+ x = Marked.X;
}
}
- nearest = -1;
+ snap_data.crosshair = &Crosshair;
+ snap_data.nearest_sq_dist = crosshair_sq_dist (&Crosshair, x, y);
+ snap_data.nearest_is_grid = true;
+ snap_data.x = x;
+ snap_data.y = y;
+ ans = NO_TYPE;
if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
PAD_TYPE, &ptr1, &ptr2, &ptr3);
- else
- ans = NO_TYPE;
/* Avoid self-snapping when moving */
- if (ans && Settings.Mode == MOVE_MODE &&
+ if (ans != NO_TYPE &&
+ Settings.Mode == MOVE_MODE &&
Crosshair.AttachedObject.Type == ELEMENT_TYPE &&
ptr1 == Crosshair.AttachedObject.Ptr1)
ans = NO_TYPE;
- if (ans && (Settings.Mode == LINE_MODE ||
- (Settings.Mode == MOVE_MODE &&
- Crosshair.AttachedObject.Type == LINEPOINT_TYPE)))
+ if (ans != NO_TYPE &&
+ ( Settings.Mode == LINE_MODE ||
+ (Settings.Mode == MOVE_MODE &&
+ Crosshair.AttachedObject.Type == LINEPOINT_TYPE)))
{
PadTypePtr pad = (PadTypePtr) ptr2;
LayerType *desired_layer;
@@ -901,143 +938,87 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
ans = NO_TYPE;
}
- if (ans)
+ if (ans != NO_TYPE)
{
- PadTypePtr pad = (PadTypePtr) ptr2;
- LocationType px, py;
-
- px = (pad->Point1.X + pad->Point2.X) / 2;
- py = (pad->Point1.Y + pad->Point2.Y) / 2;
-
- sq_dist = square (px - Crosshair.X) + square (py - Crosshair.Y);
-
- if (!gui->shift_is_pressed() ||
- square (x0 - Crosshair.X) + square (y0 - Crosshair.Y) > sq_dist)
- {
- x0 = px;
- y0 = py;
- nearest = sq_dist;
- }
+ PadType *pad = (PadType *)ptr2;
+ check_snap_object (&snap_data, (pad->Point1.X + pad->Point2.X) / 2,
+ (pad->Point1.Y + pad->Point2.Y) / 2,
+ true);
}
+ ans = NO_TYPE;
if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
PIN_TYPE, &ptr1, &ptr2, &ptr3);
- else
- ans = NO_TYPE;
/* Avoid self-snapping when moving */
- if (ans && Settings.Mode == MOVE_MODE &&
+ if (ans != NO_TYPE &&
+ Settings.Mode == MOVE_MODE &&
Crosshair.AttachedObject.Type == ELEMENT_TYPE &&
ptr1 == Crosshair.AttachedObject.Ptr1)
ans = NO_TYPE;
- if (ans)
+ if (ans != NO_TYPE)
{
- PinTypePtr pin = (PinTypePtr) ptr2;
- sq_dist = square (pin->X - Crosshair.X) + square (pin->Y - Crosshair.Y);
- if ((nearest == -1 || sq_dist < nearest) &&
- (!gui->shift_is_pressed() ||
- square (x0 - Crosshair.X) + square (y0 - Crosshair.Y) > sq_dist))
- {
- x0 = pin->X;
- y0 = pin->Y;
- nearest = sq_dist;
- }
+ PinType *pin = (PinType *)ptr2;
+ check_snap_object (&snap_data, pin->X, pin->Y, true);
}
+ ans = NO_TYPE;
if (TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
VIA_TYPE, &ptr1, &ptr2, &ptr3);
- else
- ans = NO_TYPE;
/* Avoid snapping vias to any other vias */
if (Settings.Mode == MOVE_MODE &&
- Crosshair.AttachedObject.Type == VIA_TYPE)
- {
- if (ans & PIN_TYPES)
- ans = NO_TYPE;
- }
+ Crosshair.AttachedObject.Type == VIA_TYPE &&
+ (ans & PIN_TYPES))
+ ans = NO_TYPE;
- if (ans)
+ if (ans != NO_TYPE)
{
- PinTypePtr pin = (PinTypePtr) ptr2;
- sq_dist = square (pin->X - Crosshair.X) + square (pin->Y - Crosshair.Y);
- if ((nearest == -1 || sq_dist < nearest) &&
- (!gui->shift_is_pressed() ||
- square (x0 - Crosshair.X) + square (y0 - Crosshair.Y) > sq_dist))
- {
- x0 = pin->X;
- y0 = pin->Y;
- nearest = sq_dist;
- }
+ PinType *pin = (PinType *)ptr2;
+ check_snap_object (&snap_data, pin->X, pin->Y, true);
}
+ ans = NO_TYPE;
if (TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3);
- else
- ans = NO_TYPE;
- if (ans)
+ if (ans != NO_TYPE)
{
- PointTypePtr pnt = (PointTypePtr) ptr3;
- sq_dist = square (pnt->X - Crosshair.X) + square (pnt->Y - Crosshair.Y);
- if ((nearest == -1 || sq_dist < nearest) &&
- (!gui->shift_is_pressed() ||
- square (x0 - Crosshair.X) + square (y0 - Crosshair.Y) > sq_dist))
- {
- x0 = pnt->X;
- y0 = pnt->Y;
- nearest = sq_dist;
- }
+ PointType *pnt = (PointType *)ptr3;
+ check_snap_object (&snap_data, pnt->X, pnt->Y, true);
}
+ ans = NO_TYPE;
if (TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
POLYGONPOINT_TYPE, &ptr1, &ptr2, &ptr3);
- else
- ans = NO_TYPE;
- if (ans)
+ if (ans != NO_TYPE)
{
- PointTypePtr pnt = (PointTypePtr) ptr3;
- sq_dist = square (pnt->X - Crosshair.X) + square (pnt->Y - Crosshair.Y);
- if ((nearest == -1 || sq_dist < nearest) &&
- (!gui->shift_is_pressed() ||
- square (x0 - Crosshair.X) + square (y0 - Crosshair.Y) > sq_dist))
- {
- x0 = pnt->X;
- y0 = pnt->Y;
- nearest = sq_dist;
- }
+ PointType *pnt = (PointType *)ptr3;
+ check_snap_object (&snap_data, pnt->X, pnt->Y, true);
}
+ ans = NO_TYPE;
if (PCB->RatDraw || TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
ELEMENT_TYPE, &ptr1, &ptr2, &ptr3);
- else
- ans = NO_TYPE;
if (ans & ELEMENT_TYPE)
{
- ElementTypePtr el = (ElementTypePtr) ptr1;
- sq_dist = square (el->MarkX - Crosshair.X) + square (el->MarkY - Crosshair.Y);
- if ((nearest == -1 || sq_dist < nearest) &&
- square (x0 - Crosshair.X) + square (y0 - Crosshair.Y) > sq_dist)
- {
- x0 = el->MarkX;
- y0 = el->MarkY;
- nearest = sq_dist;
- }
+ ElementType *el = (ElementType *) ptr1;
+ check_snap_object (&snap_data, el->MarkX, el->MarkY, false);
}
- if (x0 >= 0 && y0 >= 0)
+ if (snap_data.x >= 0 && snap_data.y >= 0)
{
- Crosshair.X = x0;
- Crosshair.Y = y0;
+ Crosshair.X = snap_data.x;
+ Crosshair.Y = snap_data.y;
}
if (Settings.Mode == ARROW_MODE)
|
|
From: <gi...@gp...> - 2011-07-23 15:16:41
|
The branch, master has been updated
via 69cc8291eb5e9b2cdcbc33a702b1044a4ce906ff (commit)
from 0c2f7e772f0fa11bfc7a7179ad43fb358d44941d (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/search.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit 69cc8291eb5e9b2cdcbc33a702b1044a4ce906ff
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Allow editing of ordinary text objects when element names are hidden
Closes-bug: lp-810678
:100644 100644 30fe883... 60f6f46... M src/search.c
=========
Changes
=========
commit 69cc8291eb5e9b2cdcbc33a702b1044a4ce906ff
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Allow editing of ordinary text objects when element names are hidden
Closes-bug: lp-810678
diff --git a/src/search.c b/src/search.c
index 30fe883..60f6f46 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1167,11 +1167,14 @@ SearchObjectByLocation (int Type,
SearchBox = point_box (X, Y);
}
- if (TEST_FLAG (LOCKNAMESFLAG, PCB)
- || TEST_FLAG (HIDENAMESFLAG, PCB))
+ if (TEST_FLAG (LOCKNAMESFLAG, PCB))
{
Type &= ~ (ELEMENTNAME_TYPE | TEXT_TYPE);
}
+ if (TEST_FLAG (HIDENAMESFLAG, PCB))
+ {
+ Type &= ~ELEMENTNAME_TYPE;
+ }
if (TEST_FLAG (ONLYNAMESFLAG, PCB))
{
Type &= (ELEMENTNAME_TYPE | TEXT_TYPE);
|
|
From: <gi...@gp...> - 2011-07-19 18:26:22
|
The branch, master has been updated
via 0c2f7e772f0fa11bfc7a7179ad43fb358d44941d (commit)
from 39c0925401ecb3862967faf852059e159ddf9c0a (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-netlist-window.c | 65 +++++++++++++++++++++++++------------
1 files changed, 44 insertions(+), 21 deletions(-)
=================
Commit Messages
=================
commit 0c2f7e772f0fa11bfc7a7179ad43fb358d44941d
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Fix crash in netlist window caused by heirarchical netlists
See http://archives.seul.org/geda/user/Jul-2011/msg00133.html
:100644 100644 b60b8ba... 26b97bb... M src/hid/gtk/gui-netlist-window.c
=========
Changes
=========
commit 0c2f7e772f0fa11bfc7a7179ad43fb358d44941d
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Fix crash in netlist window caused by heirarchical netlists
See http://archives.seul.org/geda/user/Jul-2011/msg00133.html
diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index b60b8ba..26b97bb 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -578,14 +578,44 @@ netlist_rip_up_cb (GtkWidget * widget, gpointer data)
}
+/**/
+typedef struct {
+ LibraryEntryType *ret_val;
+ LibraryMenuType *node_net;
+ const gchar *node_name;
+ bool found;
+} node_get_node_from_name_state;
-LibraryEntryType *
-node_get_node_from_name (gchar * node_name, LibraryMenuType ** node_net)
+static gboolean
+node_get_node_from_name_helper (GtkTreeModel *model, GtkTreePath *path,
+ GtkTreeIter *iter, gpointer data)
{
- GtkTreeIter iter;
LibraryMenuType *net;
LibraryEntryType *node;
- gint j;
+ node_get_node_from_name_state *state = data;
+
+ gtk_tree_model_get (net_model, iter, NET_LIBRARY_COLUMN, &net, -1);
+ /* Ignore non-nets (category headers) */
+ if (net == NULL)
+ return FALSE;
+
+ /* Look for the node name in this net. */
+ for (node = net->Entry; node - net->Entry < net->EntryN; node++)
+ if (node->ListEntry && !strcmp (state->node_name, node->ListEntry))
+ {
+ state->node_net = net;
+ state->ret_val = node;
+ /* stop iterating */
+ state->found = TRUE;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+LibraryEntryType *
+node_get_node_from_name (gchar * node_name, LibraryMenuType ** node_net)
+{
+ node_get_node_from_name_state state;
if (!node_name)
return NULL;
@@ -602,25 +632,18 @@ node_get_node_from_name (gchar * node_name, LibraryMenuType ** node_net)
/* Now walk through node entries of each net in the net model looking for
| the node_name.
*/
- if (gtk_tree_model_get_iter_first (net_model, &iter))
- do
- {
- gtk_tree_model_get (net_model, &iter, NET_LIBRARY_COLUMN, &net, -1);
-
- /* Look for the node name in this net.
- */
- for (j = net->EntryN, node = net->Entry; j; j--, node++)
- if (node->ListEntry && !strcmp (node_name, node->ListEntry))
- {
- if (node_net)
- *node_net = net;
- return node;
- }
- }
- while (gtk_tree_model_iter_next (net_model, &iter));
-
+ state.found = 0;
+ state.node_name = node_name;
+ gtk_tree_model_foreach (net_model, node_get_node_from_name_helper, &state);
+ if (state.found)
+ {
+ if (node_net)
+ *node_net = state.node_net;
+ return state.ret_val;
+ }
return NULL;
}
+/**/
/* ---------- Manage the GUI treeview of the data models -----------
*/
|
|
From: <gi...@gp...> - 2011-07-12 17:24:25
|
The branch, master has been updated
via 39c0925401ecb3862967faf852059e159ddf9c0a (commit)
from 2029c9de01e48335a6c4649642748307293979bd (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-top-window.c | 302 +-----------------------------------------
1 files changed, 4 insertions(+), 298 deletions(-)
=================
Commit Messages
=================
commit 39c0925401ecb3862967faf852059e159ddf9c0a
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Remove special grid-change handling from Gtk
:100644 100644 44ad43a... b5caff9... M src/hid/gtk/gui-top-window.c
=========
Changes
=========
commit 39c0925401ecb3862967faf852059e159ddf9c0a
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Remove special grid-change handling from Gtk
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 44ad43a..b5caff9 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -407,60 +407,6 @@ ghid_update_toggle_flags ()
}
-#define N_GRID_SETTINGS 11
-
-static gdouble grid_mil_values[N_GRID_SETTINGS] = {
- MIL_TO_COORD (0.10),
- MIL_TO_COORD (0.20),
- MIL_TO_COORD (0.50),
- MIL_TO_COORD (1.00),
- MIL_TO_COORD (2.00),
- MIL_TO_COORD (5.00),
- MIL_TO_COORD (10.0),
- MIL_TO_COORD (20.0),
- MIL_TO_COORD (25.0),
- MIL_TO_COORD (50.0),
- MIL_TO_COORD (100)
-};
-
-static gdouble grid_mm_values[N_GRID_SETTINGS] = {
- MM_TO_COORD (0.002),
- MM_TO_COORD (0.005),
- MM_TO_COORD (0.01),
- MM_TO_COORD (0.02),
- MM_TO_COORD (0.05),
- MM_TO_COORD (0.1),
- MM_TO_COORD (0.2),
- MM_TO_COORD (0.25),
- MM_TO_COORD (0.5),
- MM_TO_COORD (1.0),
- MM_TO_COORD (2.0)
-};
-
- /* When the user toggles grid units mil<->mm, call this to get an
- | index into the grid values table of the current grid setting. Then a
- | grid in the new units may be selected that is closest to what we had.
- |
- | May want this call to fail if user has altered grid with 'g' key
- | and so current grid does not match any of the presets. In that
- | case we want no item in the grid setting radio group to get set.
- */
-static gint
-get_grid_value_index (gboolean allow_fail)
-{
- gdouble *value;
- gint i;
-
- value = Settings.grid_units_mm ? &grid_mm_values[0] : &grid_mil_values[0];
- for (i = 0; i < N_GRID_SETTINGS; ++i, ++value)
- if (PCB->Grid < *value + 1.0 && PCB->Grid > *value - 1.0)
- break;
- if (i >= N_GRID_SETTINGS)
- i = allow_fail ? -1 : N_GRID_SETTINGS - 1;
-
- return i;
-}
-
static void
h_adjustment_changed_cb (GtkAdjustment * adj, GhidGui * g)
{
@@ -672,162 +618,6 @@ void ghid_hotkey_cb (int which)
/* ============== ViewMenu callbacks =============== */
-
-
- /* Do grid units handling common to a grid units change from the menu or
- | the grid units button.
- */
-static void
-handle_grid_units_change (gboolean active)
-{
- gchar *grid;
- gint i;
-
- i = get_grid_value_index (FALSE);
- Settings.grid_units_mm = active;
- PCB->Grid = Settings.grid_units_mm ? grid_mm_values[i] : grid_mil_values[i];
-
- ghid_grid_setting_update_menu_actions ();
-
- grid = pcb_g_strdup_printf ("%$ms", (BDimension) PCB->Grid);
- hid_actionl ("SetValue", "Grid", grid, "", NULL);
- g_free (grid);
-
- ghid_config_handle_units_changed ();
-
- ghid_set_status_line_label ();
-}
-
-static void
-radio_grid_mil_setting_cb (GtkAction * action, GtkRadioAction * current)
-{
- BDimension value;
- gchar *grid;
- gint index;
-
- printf ("radio_grid_mil_setting_cb()\n");
- if (ghidgui->toggle_holdoff)
- return;
- index = gtk_radio_action_get_current_value (current);
- value = grid_mil_values[index];
- grid = pcb_g_strdup_printf ("%$ms", value);
- hid_actionl ("SetValue", "Grid", grid, "", NULL);
- g_free (grid);
- ghid_set_status_line_label ();
-}
-
-static void
-radio_grid_mm_setting_cb (GtkAction * action, GtkRadioAction * current)
-{
- BDimension value;
- gchar *grid;
- gint index;
-
- printf ("radio_grid_mm_setting_cb()\n");
- if (ghidgui->toggle_holdoff)
- return;
- index = gtk_radio_action_get_current_value (current);
- value = grid_mm_values[index];
- grid = pcb_g_strdup_printf ("%$ms", value);
- hid_actionl ("SetValue", "Grid", grid, "", NULL);
- g_free (grid);
- ghid_set_status_line_label ();
-}
-
-
-static GtkRadioActionEntry radio_grid_mil_setting_entries[] = {
- /* name, stock_id, label, accelerator, tooltip, value */
- {"grid-user", NULL, "user value", NULL, NULL, 0},
- {"grid0", NULL, "0.1 mil", NULL, NULL, 0},
- {"grid1", NULL, "0.2 mil", NULL, NULL, 1},
- {"grid2", NULL, "0.5 mil", NULL, NULL, 2},
- {"grid3", NULL, "1 mil", NULL, NULL, 3},
- {"grid4", NULL, "2 mil", NULL, NULL, 4},
- {"grid5", NULL, "5 mil", NULL, NULL, 5},
- {"grid6", NULL, "10 mil", NULL, NULL, 6},
- {"grid7", NULL, "20 mil", NULL, NULL, 7},
- {"grid8", NULL, "25 mil", NULL, NULL, 8},
- {"grid9", NULL, "50 mil", NULL, NULL, 9},
- {"grid10", NULL, "100 mil", NULL, NULL, 10}
-};
-
-static gint n_radio_grid_mil_setting_entries
- = G_N_ELEMENTS (radio_grid_mil_setting_entries);
-
-
-static GtkRadioActionEntry radio_grid_mm_setting_entries[] = {
- /* name, stock_id, label, accelerator, tooltip, value */
- {"grid-user", NULL, "user value", NULL, NULL, 0},
- {"grid0", NULL, "0.002 mm", NULL, NULL, 0},
- {"grid1", NULL, "0.005 mm", NULL, NULL, 1},
- {"grid2", NULL, "0.01 mm", NULL, NULL, 2},
- {"grid3", NULL, "0.02 mm", NULL, NULL, 3},
- {"grid4", NULL, "0.05 mm", NULL, NULL, 4},
- {"grid5", NULL, "0.1 mm", NULL, NULL, 5},
- {"grid6", NULL, "0.2 mm", NULL, NULL, 6},
- {"grid7", NULL, "0.25 mm", NULL, NULL, 7},
- {"grid8", NULL, "0.5 mm", NULL, NULL, 8},
- {"grid9", NULL, "1 mm", NULL, NULL, 9},
- {"grid10", NULL, "2 mm", NULL, NULL, 10},
-};
-
-static gint n_radio_grid_mm_setting_entries
- = G_N_ELEMENTS (radio_grid_mm_setting_entries);
-
-
-
- /* Grid setting labels must also match user and new layout unit changes.
- */
-void
-ghid_grid_setting_update_menu_actions (void)
-{
- GtkAction *action;
- gint i;
-
- if (ghidgui->grid_actions)
- {
- /* Remove the existing radio grid actions from the menu.
- */
- gtk_ui_manager_remove_action_group (ghidgui->ui_manager,
- ghidgui->grid_actions);
- g_object_unref (ghidgui->grid_actions);
- }
-
- /* And add back actions appropriate for mil or mm grid settings.
- */
- ghidgui->grid_actions = gtk_action_group_new ("GridActions");
- gtk_action_group_set_translation_domain (ghidgui->grid_actions, NULL);
- gtk_ui_manager_insert_action_group (ghidgui->ui_manager,
- ghidgui->grid_actions, 0);
-
- /* Get the index of the radio button to set depending on current
- | PCB Grid value. But if user hits 'g' key and no grid index matches,
- | 'i' will be -1 and no button will be set active. At least Gtk docs
- | say so, but I see different.
- */
- i = get_grid_value_index (TRUE);
-
- if (Settings.grid_units_mm)
- gtk_action_group_add_radio_actions (ghidgui->grid_actions,
- radio_grid_mm_setting_entries,
- n_radio_grid_mm_setting_entries,
- i,
- G_CALLBACK (radio_grid_mm_setting_cb),
- NULL);
- else
- gtk_action_group_add_radio_actions (ghidgui->grid_actions,
- radio_grid_mil_setting_entries,
- n_radio_grid_mil_setting_entries,
- i,
- G_CALLBACK
- (radio_grid_mil_setting_cb), NULL);
- action = gtk_action_group_get_action (ghidgui->grid_actions, "grid-user");
- if (action)
- g_object_set (action, "sensitive", FALSE, NULL);
-}
-
-
-
void
ghid_set_menu_toggle_button (GtkActionGroup * ag, gchar * name,
gboolean state)
@@ -871,89 +661,6 @@ ghid_sync_with_new_layout (void)
ghid_set_status_line_label ();
}
-/*
- * Sync toggle states in the menus at startup to Settings values loaded
- * in the config.
- */
-void
-ghid_init_toggle_states (void)
-{
- GtkAction *action;
- gboolean old_holdoff;
-
- /* Just want to update the state of the menus without calling the
- | action functions at this time because causing a toggle action can
- | undo the initial condition set we want here.
- */
- old_holdoff = ghidgui->toggle_holdoff;
- ghidgui->toggle_holdoff = TRUE;
-
- action =
- gtk_action_group_get_action (ghidgui->main_actions, "ToggleDrawGrid");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.DrawGrid);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleGridUnitsMm");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.grid_units_mm);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "TogglePinoutShowsNumber");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.ShowNumber);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "Toggle45degree");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.AllDirectionLines);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleRubberBand");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.RubberBandMode);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleStartDirection");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.SwapStartDirection);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleUniqueNames");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.UniqueNames);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleSnapPin");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), Settings.SnapPin);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleClearLine");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.ClearLine);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleOrthogonalMoves");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.OrthogonalMoves);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleLiveRoute");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- Settings.liveRouting);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleShowDRC");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), Settings.ShowDRC);
-
- action = gtk_action_group_get_action (ghidgui->main_actions,
- "ToggleAutoDrC");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), Settings.AutoDRC);
-
- ghidgui->toggle_holdoff = old_holdoff;
- ghid_set_status_line_label ();
-}
-
/* ---------------------------------------------------------------------------
*
* layer_process()
@@ -1241,11 +948,10 @@ ghid_window_set_name_label (gchar * name)
static void
grid_units_button_cb (GtkWidget * widget, gpointer data)
{
-
- /* Do handling common to when units are changed from the menu.
- */
- handle_grid_units_change (!Settings.grid_units_mm);
-
+ if (Settings.grid_units_mm)
+ hid_actionl ("SetUnits", "mil", NULL);
+ else
+ hid_actionl ("SetUnits", "mm", NULL);
}
/*
|
|
From: <gi...@gp...> - 2011-07-04 00:28:40
|
The branch, master has been updated
via 2029c9de01e48335a6c4649642748307293979bd (commit)
via bf782a822f9102176de00ec16e77d48fd02584d5 (commit)
via fdc36bf8a0aef329504ec0250dcec05e280ce413 (commit)
via 09913663d0ad5c89bb0baff87a329ab29f973011 (commit)
from fa9ae1f6b1eabaab961795ce7be53afe46eaa735 (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 | 8 +-
src/hid/gtk/gui-dialog-size.c | 3 +-
src/hid/gtk/gui-misc.c | 171 +++++++++++---------------------------
src/hid/gtk/gui-top-window.c | 11 ++-
src/hid/lesstif/dialogs.c | 11 +--
src/hid/lesstif/main.c | 184 ++++++++++++++++++-----------------------
src/hid/lesstif/menu.c | 6 +-
src/pcb-printf.c | 12 ++-
8 files changed, 162 insertions(+), 244 deletions(-)
=================
Commit Messages
=================
commit 2029c9de01e48335a6c4649642748307293979bd
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert lesstif hid to use pcb-printf
Should be no user-visible changes, except this bug:
Closes-bug: lp-805273
:100644 100644 ffe99eb... 8d606ae... M src/hid/lesstif/dialogs.c
:100644 100644 f4d0001... 811ac26... M src/hid/lesstif/main.c
:100644 100644 481bba5... 09bf74b... M src/hid/lesstif/menu.c
commit bf782a822f9102176de00ec16e77d48fd02584d5
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add support for + and .* subspecifiers in pcb-printf
:100644 100644 2c1f912... 9f6734b... M src/pcb-printf.c
commit fdc36bf8a0aef329504ec0250dcec05e280ce413
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Clean up coords_to_widget() in lesstif/main.c
The coords_to_widget() function is used in exactly two places, for
different purposes. To differentiate between the two uses, the ``state''
parameter is set to -1.
The parameter is confusing enough without overloading it in this way.
Therefore I have split the function into two:
mark_delta_to_widget
cursor_pos_to_widget
Further, I have converted the code inside the functions to use
g_printf_strdup instead of a fixed buffer. The functions should both
be easier to read now than the original.
There is one small change to user-visible output, which I think is
justified: if you have a very small metric grid (<= 5um), the
mark_delta output now uses .3f for both cartesian and radial
display. Before it would use .3f for cartesian, .2f for radial.
:100644 100644 f41c4ce... f4d0001... M src/hid/lesstif/main.c
commit 09913663d0ad5c89bb0baff87a329ab29f973011
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert gtk gui to use pcb-printf
There should be no user-visible changes.
Note that as long as base units are cmils, the .9999 bug
in the cursor status is back. This is not a problem with
smaller base units (I am using 17nm and all is okay.)
Note also that the report dialogs are entirely based on
report.c, so that is not part of this commit.
:100644 100644 b5e36d5... 2fcb37b... M src/hid/gtk/gtkhid-main.c
:100644 100644 a5b5888... 0c0f8ef... M src/hid/gtk/gui-dialog-size.c
:100644 100644 21c8161... 730db5e... M src/hid/gtk/gui-misc.c
:100644 100644 23d6401... 44ad43a... M src/hid/gtk/gui-top-window.c
=========
Changes
=========
commit 2029c9de01e48335a6c4649642748307293979bd
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert lesstif hid to use pcb-printf
Should be no user-visible changes, except this bug:
Closes-bug: lp-805273
diff --git a/src/hid/lesstif/dialogs.c b/src/hid/lesstif/dialogs.c
index ffe99eb..8d606ae 100644
--- a/src/hid/lesstif/dialogs.c
+++ b/src/hid/lesstif/dialogs.c
@@ -16,6 +16,7 @@
#include "data.h"
#include "crosshair.h"
#include "misc.h"
+#include "pcb-printf.h"
#include "hid.h"
#include "../hidint.h"
@@ -1146,20 +1147,18 @@ sz_str2val (Widget w, int pcbu)
}
static void
-sz_val2str (Widget w, int u, int pcbu)
+sz_val2str (Widget w, BDimension u, int pcbu)
{
- double d;
static char buf[40];
if (pcbu)
{
if (Settings.grid_units_mm)
- d = COORD_TO_MM (u);
+ pcb_sprintf (buf, "%.2mm", u);
else
- d = COORD_TO_MIL (u);
- sprintf (buf, "%.2f", d + 0.002);
+ pcb_sprintf (buf, "%.2ml", u);
}
else
- sprintf (buf, "%d %%", u);
+ pcb_sprintf (buf, "%#mS %%", u);
XmTextSetString (w, buf);
}
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index f4d0001..811ac26 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -22,6 +22,7 @@
#include "crosshair.h"
#include "mymem.h"
#include "misc.h"
+#include "pcb-printf.h"
#include "resource.h"
#include "clip.h"
#include "error.h"
@@ -47,6 +48,7 @@ RCSID ("$Id$");
/* How big the viewport can be relative to the pcb size. */
#define MAX_ZOOM_SCALE 10
+#define UUNIT (Settings.grid_units_mm ? ALLOW_MM : ALLOW_MIL)
typedef struct hid_gc_struct
{
@@ -347,7 +349,7 @@ PCBChanged (int argc, char **argv, int x, int y)
{
if (work_area == 0)
return 0;
- /*printf("PCB Changed! %d x %d\n", PCB->MaxWidth, PCB->MaxHeight); */
+ /*pcb_printf("PCB Changed! %$mD\n", PCB->MaxWidth, PCB->MaxHeight); */
n = 0;
stdarg (XmNminimum, 0);
stdarg (XmNvalue, 0);
@@ -1413,7 +1415,7 @@ work_area_input (Widget w, XtPointer v, XEvent * e, Boolean * ctd)
#else
alt_pressed = (keys_buttons & Mod1Mask);
#endif
- /*printf("m %d %d\n", Px(e->xmotion.x), Py(e->xmotion.y)); */
+ /*pcb_printf("m %#mS %#mS\n", Px(e->xmotion.x), Py(e->xmotion.y)); */
crosshair_in_window = 1;
in_move_event = 1;
if (panning)
@@ -2299,44 +2301,29 @@ draw_grid ()
}
static void
-mark_delta_to_widget (BDimension x, BDimension y, Widget w)
+mark_delta_to_widget (BDimension dx, BDimension dy, Widget w)
{
char *buf;
- double dx, dy, g;
+ double g = Settings.grid_units_mm ? COORD_TO_MM (PCB->Grid) : COORD_TO_MIL (PCB->Grid);
int prec;
- bool int_grid;
XmString ms;
- if (Settings.grid_units_mm)
- {
- dx = COORD_TO_MM (x);
- dy = COORD_TO_MM (y);
- g = COORD_TO_MM (PCB->Grid);
- }
- else
- {
- dx = COORD_TO_MIL (x);
- dy = COORD_TO_MIL (y);
- g = COORD_TO_MIL (PCB->Grid);
- }
-
- int_grid = (((int) (g * 10000 + 0.5) % 10000) == 0);
-
- if (int_grid)
+ /* Integer-sized grid? */
+ if (((int) (g * 10000 + 0.5) % 10000) == 0)
prec = 0;
else if (Settings.grid_units_mm && g <= 0.005)
prec = 3;
else
prec = 2;
- if (x == 0 && y == 0)
- buf = g_strdup_printf ("%+.*f, %+.*f", prec, dx, prec, dy);
+ if (dx == 0 && dy == 0)
+ buf = pcb_g_strdup_printf ("%m+%+.*mS, %+.*mS", UUNIT, prec, dx, prec, dy);
else
{
int angle = atan2 (dy, -dx) * 180 / M_PI;
- double dist = Distance (0, dx, 0, dy);
+ BDimension dist = Distance (0, dx, 0, dy);
- buf = g_strdup_printf ("%+.*f, %+.*f (%.*f, %d\260)",
+ buf = pcb_g_strdup_printf ("%m+%+.*mS, %+.*mS (%.*mS, %d\260)", UUNIT,
prec, dx, prec, dy, prec, dist, angle);
}
@@ -2348,35 +2335,17 @@ mark_delta_to_widget (BDimension x, BDimension y, Widget w)
}
static int
-cursor_pos_to_widget (int x, int y, Widget w, int prev_state)
+cursor_pos_to_widget (BDimension x, BDimension y, Widget w, int prev_state)
{
int this_state = prev_state;
static char *buf;
- double dx, dy, g;
+ double g = Settings.grid_units_mm ? COORD_TO_MM (PCB->Grid) : COORD_TO_MIL (PCB->Grid);
XmString ms;
int prec;
- bool int_grid;
-
- if (Settings.grid_units_mm)
- {
- /* MM */
- dx = COORD_TO_MM (x);
- dy = COORD_TO_MM (y);
- g = COORD_TO_MM (PCB->Grid);
- }
- else
- {
- /* Mils */
- dx = COORD_TO_MIL (x);
- dy = COORD_TO_MIL (y);
- g = COORD_TO_MIL (PCB->Grid);
- }
-
- int_grid = (((int) (g * 10000 + 0.5) % 10000) == 0);
/* Determine necessary precision (and state) based
* on the user's grid setting */
- if (int_grid)
+ if (((int) (g * 10000 + 0.5) % 10000) == 0)
{
prec = 0;
this_state = 2 + Settings.grid_units_mm;
@@ -2395,7 +2364,7 @@ cursor_pos_to_widget (int x, int y, Widget w, int prev_state)
if (x < 0)
buf = g_strdup ("");
else
- buf = g_strdup_printf ("%.*f, %.*f", prec, dx, prec, dy);
+ buf = pcb_g_strdup_printf ("%m+%.*mS, %.*mS", UUNIT, prec, x, prec, y);
ms = XmStringCreateLocalized (buf);
n = 0;
@@ -2405,59 +2374,38 @@ cursor_pos_to_widget (int x, int y, Widget w, int prev_state)
return this_state;
}
-static char *
-pcb2str (int pcbval)
-{
- static char buf[20][20];
- static int bufp = 0;
- double d;
-
- bufp = (bufp + 1) % 20;
- if (Settings.grid_units_mm)
- d = COORD_TO_MM (pcbval);
- else
- d = COORD_TO_MIL (pcbval);
-
- if ((int) (d * 100 + 0.5) == (int) (d + 0.005) * 100)
- sprintf (buf[bufp], "%d", (int) d);
- else
- sprintf (buf[bufp], "%.2f", d);
- return buf[bufp];
-}
-
-#define u(x) pcb2str(x)
#define S Settings
void
lesstif_update_status_line ()
{
- char buf[100];
+ char *buf = NULL;
char *s45 = cur_clip ();
XmString xs;
- buf[0] = 0;
switch (Settings.Mode)
{
case VIA_MODE:
- sprintf (buf, "%s/%s \370=%s", u (S.ViaThickness),
- u (S.Keepaway), u (S.ViaDrillingHole));
+ buf = pcb_g_strdup_printf ("%m+%.2mS/%.2mS \370=%.2mS", UUNIT,
+ S.ViaThickness, S.Keepaway, S.ViaDrillingHole);
break;
case LINE_MODE:
case ARC_MODE:
- sprintf (buf, "%s/%s %s", u (S.LineThickness), u (S.Keepaway), s45);
+ buf = pcb_g_strdup_printf ("%m+%.2mS/%.2mS %s", UUNIT,
+ S.LineThickness, S.Keepaway, s45);
break;
case RECTANGLE_MODE:
case POLYGON_MODE:
- sprintf (buf, "%s %s", u (S.Keepaway), s45);
+ buf = pcb_g_strdup_printf ("%m+%.2mS %s", UUNIT, S.Keepaway, s45);
break;
case TEXT_MODE:
- sprintf (buf, "%s", u (S.TextScale));
+ buf = g_strdup_printf ("%d %%", S.TextScale);
break;
case MOVE_MODE:
case COPY_MODE:
case INSERTPOINT_MODE:
case RUBBERBANDMOVE_MODE:
- sprintf (buf, "%s", s45);
+ buf = g_strdup_printf ("%s", s45);
break;
case NO_MODE:
case PASTEBUFFER_MODE:
@@ -2466,6 +2414,8 @@ lesstif_update_status_line ()
case THERMAL_MODE:
case ARROW_MODE:
case LOCK_MODE:
+ default:
+ buf = g_strdup("");
break;
}
@@ -2473,9 +2423,9 @@ lesstif_update_status_line ()
n = 0;
stdarg (XmNlabelString, xs);
XtSetValues (m_status, args, n);
+ g_free (buf);
}
-#undef u
#undef S
static int idle_proc_set = 0;
@@ -2656,15 +2606,13 @@ idle_proc (XtPointer dummy)
{
static double old_grid = -1;
- static int old_gx, old_gy, old_mm;
- XmString ms;
+ static BDimension old_gx, old_gy, old_mm;
+ XmString ms;
if (PCB->Grid != old_grid
|| PCB->GridOffsetX != old_gx
|| PCB->GridOffsetY != old_gy || Settings.grid_units_mm != old_mm)
{
static char buf[100];
- double g, x, y;
- char *u;
old_grid = PCB->Grid;
old_gx = PCB->GridOffsetX;
old_gy = PCB->GridOffsetY;
@@ -2675,24 +2623,10 @@ idle_proc (XtPointer dummy)
}
else
{
- if (Settings.grid_units_mm)
- {
- g = COORD_TO_MM (old_grid);
- x = COORD_TO_MM (old_gx);
- y = COORD_TO_MM (old_gy);
- u = "mm";
- }
- else
- {
- g = COORD_TO_MIL (old_grid);
- x = COORD_TO_MIL (old_gx);
- y = COORD_TO_MIL (old_gy);
- u = "mil";
- }
- if (x || y)
- sprintf (buf, "%g %s @%g,%g", g, u, x, y);
+ if (old_gx || old_gy)
+ pcb_sprintf (buf, "%m+%$mS @%mS,%mS", UUNIT, (BDimension) old_grid, old_gx, old_gy);
else
- sprintf (buf, "%g %s", g, u);
+ pcb_sprintf (buf, "%m+%$mS", UUNIT, (BDimension) old_grid);
}
ms = XmStringCreateLocalized (buf);
n = 0;
@@ -3201,7 +3135,7 @@ set_gc (hidGC gc)
abort ();
}
#if 0
- printf ("set_gc c%s %08lx w%d c%d x%d e%d\n",
+ pcb_printf ("set_gc c%s %08lx w%#mS c%d x%d e%d\n",
gc->colorname, gc->color, gc->width, gc->cap, gc->xor_set, gc->erase);
#endif
switch (gc->cap)
@@ -3283,14 +3217,14 @@ lesstif_draw_line (hidGC gc, int x1, int y1, int x2, int y2)
if ((pinout || TEST_FLAG (THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB)) && gc->erase)
return;
#if 0
- printf ("draw_line %d,%d %d,%d @%d", x1, y1, x2, y2, gc->width);
+ pcb_printf ("draw_line %#mD-%#mD @%#mS", x1, y1, x2, y2, gc->width);
#endif
dx1 = Vx (x1);
dy1 = Vy (y1);
dx2 = Vx (x2);
dy2 = Vy (y2);
#if 0
- printf (" = %d,%d %d,%d %s\n", x1, y1, x2, y2, gc->colorname);
+ pcb_printf (" = %#mD-%#mD %s\n", x1, y1, x2, y2, gc->colorname);
#endif
#if 1
@@ -3328,7 +3262,7 @@ lesstif_draw_arc (hidGC gc, int cx, int cy, int width, int height,
if ((pinout || TEST_FLAG (THINDRAWFLAG, PCB)) && gc->erase)
return;
#if 0
- printf ("draw_arc %d,%d %dx%d s %d d %d", cx, cy, width, height, start_angle, delta_angle);
+ pcb_printf ("draw_arc %#mD %#mSx%#mS s %d d %d", cx, cy, width, height, start_angle, delta_angle);
#endif
width = Vz (width);
height = Vz (height);
@@ -3346,7 +3280,7 @@ lesstif_draw_arc (hidGC gc, int cx, int cy, int width, int height,
}
start_angle = (start_angle + 360 + 180) % 360 - 180;
#if 0
- printf (" = %d,%d %dx%d %d %s\n", cx, cy, width, height, gc->width,
+ pcb_printf (" = %#mD %#mSx%#mS %d %s\n", cx, cy, width, height, gc->width,
gc->colorname);
#endif
set_gc (gc);
@@ -3410,7 +3344,7 @@ lesstif_fill_circle (hidGC gc, int cx, int cy, int radius)
if ((TEST_FLAG (THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB)) && gc->erase)
return;
#if 0
- printf ("fill_circle %d,%d %d", cx, cy, radius);
+ pcb_printf ("fill_circle %#mD %#mS", cx, cy, radius);
#endif
radius = Vz (radius);
cx = Vx (cx) - radius;
@@ -3420,7 +3354,7 @@ lesstif_fill_circle (hidGC gc, int cx, int cy, int radius)
if (cy < -2 * radius || cy > view_height)
return;
#if 0
- printf (" = %d,%d %d %lx %s\n", cx, cy, radius, gc->color, gc->colorname);
+ pcb_printf (" = %#mD %#mS %lx %s\n", cx, cy, radius, gc->color, gc->colorname);
#endif
set_gc (gc);
XFillArc (display, pixmap, my_gc, cx, cy,
diff --git a/src/hid/lesstif/menu.c b/src/hid/lesstif/menu.c
index 481bba5..09bf74b 100644
--- a/src/hid/lesstif/menu.c
+++ b/src/hid/lesstif/menu.c
@@ -92,13 +92,13 @@ on one.
%end-doc */
static int
-Debug (int argc, char **argv, int x, int y)
+Debug (int argc, char **argv, BDimension x, BDimension y)
{
int i;
printf ("Debug:");
for (i = 0; i < argc; i++)
printf (" [%d] `%s'", i, argv[i]);
- printf (" x,y %d,%d\n", x, y);
+ pcb_printf (" x,y %$mD\n", x, y);
return 0;
}
@@ -836,7 +836,7 @@ callback (Widget w, Resource * node, XmPushButtonCallbackStruct * pbcs)
if (p == aw)
have_xy = 1;
}
- //printf("have xy from %s: %d %d\n", XtName(aw), action_x, action_y);
+ //pcb_printf("have xy from %s: %$mD\n", XtName(aw), action_x, action_y);
}
lesstif_need_idle_proc ();
commit bf782a822f9102176de00ec16e77d48fd02584d5
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add support for + and .* subspecifiers in pcb-printf
diff --git a/src/pcb-printf.c b/src/pcb-printf.c
index 2c1f912..9f6734b 100644
--- a/src/pcb-printf.c
+++ b/src/pcb-printf.c
@@ -245,8 +245,16 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
g_string_append_c (spec, *fmt++);
while(isdigit(*fmt) || *fmt == '.' || *fmt == ' ' || *fmt == '*'
|| *fmt == '#' || *fmt == 'l' || *fmt == 'L'
- || *fmt == 'h' || *fmt == '-')
- g_string_append_c (spec, *fmt++);
+ || *fmt == 'h' || *fmt == '+' || *fmt == '-')
+ {
+ if (*fmt == '*')
+ {
+ g_string_append_printf (spec, "%d", va_arg (args, int));
+ fmt++;
+ }
+ else
+ g_string_append_c (spec, *fmt++);
+ }
/* Get our sub-specifiers */
if(*fmt == '#')
{
commit fdc36bf8a0aef329504ec0250dcec05e280ce413
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Clean up coords_to_widget() in lesstif/main.c
The coords_to_widget() function is used in exactly two places, for
different purposes. To differentiate between the two uses, the ``state''
parameter is set to -1.
The parameter is confusing enough without overloading it in this way.
Therefore I have split the function into two:
mark_delta_to_widget
cursor_pos_to_widget
Further, I have converted the code inside the functions to use
g_printf_strdup instead of a fixed buffer. The functions should both
be easier to read now than the original.
There is one small change to user-visible output, which I think is
justified: if you have a very small metric grid (<= 5um), the
mark_delta output now uses .3f for both cartesian and radial
display. Before it would use .3f for cartesian, .2f for radial.
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index f41c4ce..f4d0001 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -2298,14 +2298,64 @@ draw_grid ()
}
}
+static void
+mark_delta_to_widget (BDimension x, BDimension y, Widget w)
+{
+ char *buf;
+ double dx, dy, g;
+ int prec;
+ bool int_grid;
+ XmString ms;
+
+ if (Settings.grid_units_mm)
+ {
+ dx = COORD_TO_MM (x);
+ dy = COORD_TO_MM (y);
+ g = COORD_TO_MM (PCB->Grid);
+ }
+ else
+ {
+ dx = COORD_TO_MIL (x);
+ dy = COORD_TO_MIL (y);
+ g = COORD_TO_MIL (PCB->Grid);
+ }
+
+ int_grid = (((int) (g * 10000 + 0.5) % 10000) == 0);
+
+ if (int_grid)
+ prec = 0;
+ else if (Settings.grid_units_mm && g <= 0.005)
+ prec = 3;
+ else
+ prec = 2;
+
+ if (x == 0 && y == 0)
+ buf = g_strdup_printf ("%+.*f, %+.*f", prec, dx, prec, dy);
+ else
+ {
+ int angle = atan2 (dy, -dx) * 180 / M_PI;
+ double dist = Distance (0, dx, 0, dy);
+
+ buf = g_strdup_printf ("%+.*f, %+.*f (%.*f, %d\260)",
+ prec, dx, prec, dy, prec, dist, angle);
+ }
+
+ ms = XmStringCreateLocalized (buf);
+ n = 0;
+ stdarg (XmNlabelString, ms);
+ XtSetValues (w, args, n);
+ g_free (buf);
+}
+
static int
-coords_to_widget (int x, int y, Widget w, int prev_state)
+cursor_pos_to_widget (int x, int y, Widget w, int prev_state)
{
int this_state = prev_state;
- static char buf[60];
+ static char *buf;
double dx, dy, g;
- int frac = 0;
XmString ms;
+ int prec;
+ bool int_grid;
if (Settings.grid_units_mm)
{
@@ -2321,43 +2371,37 @@ coords_to_widget (int x, int y, Widget w, int prev_state)
dy = COORD_TO_MIL (y);
g = COORD_TO_MIL (PCB->Grid);
}
- if (x < 0 && prev_state >= 0)
- buf[0] = 0;
- else if (((int) (g * 10000 + 0.5) % 10000) == 0)
+
+ int_grid = (((int) (g * 10000 + 0.5) % 10000) == 0);
+
+ /* Determine necessary precision (and state) based
+ * on the user's grid setting */
+ if (int_grid)
{
- const char *fmt = prev_state < 0 ? "%+d, %+d" : "%d, %d";
- sprintf (buf, fmt, (int) (dx + 0.5), (int) (dy + 0.5));
+ prec = 0;
this_state = 2 + Settings.grid_units_mm;
- frac = 0;
}
- else if (PCB->Grid <= 20 && Settings.grid_units_mm)
+ else if (Settings.grid_units_mm && g <= 0.005)
{
- const char *fmt = prev_state < 0 ? "%+.3f, %+.3f" : "%.3f, %.3f";
- sprintf (buf, fmt, dx, dy);
+ prec = 3;
this_state = 4 + Settings.grid_units_mm;
- frac = 1;
}
else
{
- const char *fmt = prev_state < 0 ? "%+.2f, %+.2f" : "%.2f, %.2f";
- sprintf (buf, fmt, dx, dy);
+ prec = 2;
this_state = 4 + Settings.grid_units_mm;
- frac = 1;
- }
- if (prev_state < 0 && (x || y))
- {
- int angle = atan2 (dy, -dx) * 180 / M_PI;
- double dist = sqrt (dx * dx + dy * dy);
- if (frac)
- sprintf (buf + strlen (buf), " (%.2f", dist);
- else
- sprintf (buf + strlen (buf), " (%d", (int) (dist + 0.5));
- sprintf (buf + strlen (buf), ", %d\260)", angle);
}
+
+ if (x < 0)
+ buf = g_strdup ("");
+ else
+ buf = g_strdup_printf ("%.*f, %.*f", prec, dx, prec, dy);
+
ms = XmStringCreateLocalized (buf);
n = 0;
stdarg (XmNlabelString, ms);
XtSetValues (w, args, n);
+ g_free (buf);
return this_state;
}
@@ -2552,11 +2596,11 @@ idle_proc (XtPointer dummy)
c_y = crosshair_y;
this_state =
- coords_to_widget (crosshair_x, crosshair_y, m_crosshair,
+ cursor_pos_to_widget (crosshair_x, crosshair_y, m_crosshair,
this_state);
if (Marked.status)
- coords_to_widget (crosshair_x - Marked.X, crosshair_y - Marked.Y,
- m_mark, -1);
+ mark_delta_to_widget (crosshair_x - Marked.X, crosshair_y - Marked.Y,
+ m_mark);
if (Marked.status != saved_mark.status)
{
commit 09913663d0ad5c89bb0baff87a329ab29f973011
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert gtk gui to use pcb-printf
There should be no user-visible changes.
Note that as long as base units are cmils, the .9999 bug
in the cursor status is back. This is not a problem with
smaller base units (I am using 17nm and all is okay.)
Note also that the report dialogs are entirely based on
report.c, so that is not part of this commit.
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index b5e36d5..2fcb37b 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -196,7 +196,7 @@ zoom_to (double new_zoom, int x, int y)
*/
#ifdef DEBUG
- printf ("\nzoom_to( %g, %d, %d)\n", new_zoom, x, y);
+ pcb_printf ("\nzoom_to( %g, %#mS, %#mS)\n", new_zoom, x, y);
#endif
xfrac = (double) x / (double) gport->view_width;
@@ -236,8 +236,8 @@ zoom_to (double new_zoom, int x, int y)
cy = gport->view_y0 + gport->view_height * yfrac * gport->zoom;
#ifdef DEBUG
- printf ("zoom_to(): x0 = %d, cx = %d\n", gport->view_x0, cx);
- printf ("zoom_to(): y0 = %d, cy = %d\n", gport->view_y0, cy);
+ pcb_printf ("zoom_to(): x0 = %#mS, cx = %#mS\n", gport->view_x0, cx);
+ pcb_printf ("zoom_to(): y0 = %#mS, cy = %#mS\n", gport->view_y0, cy);
#endif
if (gport->zoom != new_zoom)
@@ -281,7 +281,7 @@ void
zoom_by (double factor, int x, int y)
{
#ifdef DEBUG
- printf ("\nzoom_by( %g, %d, %d). old gport->zoom = %g\n",
+ pcb_printf ("\nzoom_by( %g, %#mS, %#mS). old gport->zoom = %g\n",
factor, x, y, gport->zoom);
#endif
zoom_to (gport->zoom * factor, x, y);
diff --git a/src/hid/gtk/gui-dialog-size.c b/src/hid/gtk/gui-dialog-size.c
index a5b5888..0c0f8ef 100644
--- a/src/hid/gtk/gui-dialog-size.c
+++ b/src/hid/gtk/gui-dialog-size.c
@@ -43,6 +43,7 @@
#include "error.h"
#include "misc.h"
#include "set.h"
+#include "pcb-printf.h"
#include "gui.h"
@@ -78,7 +79,7 @@ make_route_string(RouteStyleType * rs)
str = g_strdup("");
for (i = 0; i < NUM_STYLES; ++i, ++rs)
{
- s = g_strdup_printf ("%s,%d,%d,%d,%d", rs->Name,
+ s = pcb_g_strdup_printf ("%s,%mc,%mc,%mc,%mc", rs->Name,
rs->Thick, rs->Diameter, rs->Hole, rs->Keepaway);
colon = (i == NUM_STYLES - 1) ? NULL : (gchar *)":";
t = str;
diff --git a/src/hid/gtk/gui-misc.c b/src/hid/gtk/gui-misc.c
index 21c8161..730db5e 100644
--- a/src/hid/gtk/gui-misc.c
+++ b/src/hid/gtk/gui-misc.c
@@ -34,6 +34,7 @@
#include "misc.h"
#include "action.h"
#include "set.h"
+#include "pcb-printf.h"
#include "gui.h"
#include <gdk/gdkkeysyms.h>
@@ -496,114 +497,44 @@ ghid_get_pointer (int *x, int *y)
void
ghid_set_status_line_label (void)
{
- gchar text[512];
-
- if (!Settings.grid_units_mm)
- snprintf (text, sizeof (text),
- _("<b>view</b>=%s "
- "<b>grid</b>=%.1f:%i "
- "%s%s "
- "<b>line</b>=%.1f "
- "<b>via</b>=%.1f(%.1f) %s"
- "<b>clearance</b>=%.1f "
- "<b>text</b>=%i%% "
- "<b>buffer</b>=#%i"),
- Settings.ShowSolderSide ? _("solder") : _("component"),
- COORD_TO_MIL(PCB->Grid),
- (int) Settings.GridFactor,
- TEST_FLAG (ALLDIRECTIONFLAG, PCB) ? "all" :
- (PCB->Clipping == 0 ? "45" :
- (PCB->Clipping == 1 ? "45_/" : "45\\_")),
- TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R " : " ",
- COORD_TO_MIL(Settings.LineThickness),
- COORD_TO_MIL(Settings.ViaThickness),
- COORD_TO_MIL(Settings.ViaDrillingHole),
- ghidgui->compact_horizontal ? "\n" : "",
- COORD_TO_MIL(Settings.Keepaway),
- Settings.TextScale, Settings.BufferNumber + 1);
- else
- snprintf (text, sizeof (text),
- _("<b>view</b>=%s "
- "<b>grid</b>=%5.3f:%i "
- "%s%s "
- "<b>line</b>=%5.3f "
- "<b>via</b>=%5.3f(%5.3f) %s"
- "<b>clearance</b>=%5.3f "
- "<b>text</b>=%i%% "
- "<b>buffer</b>=#%i"),
- Settings.ShowSolderSide ? _("solder") : _("component"),
- COORD_TO_MM(PCB->Grid), (int) Settings.GridFactor,
- TEST_FLAG (ALLDIRECTIONFLAG, PCB) ? "all" :
- (PCB->Clipping == 0 ? "45" :
- (PCB->Clipping == 1 ? "45_/" : "45\\_")),
- TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R " : " ",
- COORD_TO_MM(Settings.LineThickness),
- COORD_TO_MM(Settings.ViaThickness),
- COORD_TO_MM(Settings.ViaDrillingHole),
- ghidgui->compact_horizontal ? "\n" : "",
- COORD_TO_MM(Settings.Keepaway),
- Settings.TextScale, Settings.BufferNumber + 1);
+ gchar *flag = TEST_FLAG (ALLDIRECTIONFLAG, PCB)
+ ? "all"
+ : (PCB->Clipping == 0
+ ? "45"
+ : (PCB->Clipping == 1
+ ? "45_/"
+ : "45\\_"));
+ gchar *text = pcb_g_strdup_printf (
+ Settings.grid_units_mm
+ ? _("<b>view</b>=%s "
+ "<b>grid</b>=%5.3mm:%i "
+ "%s%s "
+ "<b>line</b>=%5.3mm "
+ "<b>via</b>=%5.3mm(%5.3mm) %s"
+ "<b>clearance</b>=%5.3mm "
+ "<b>text</b>=%i%% "
+ "<b>buffer</b>=#%i")
+ : _("<b>view</b>=%s "
+ "<b>grid</b>=%.1ml:%i "
+ "%s%s "
+ "<b>line</b>=%.1ml "
+ "<b>via</b>=%.1ml(%.1ml) %s"
+ "<b>clearance</b>=%.1ml "
+ "<b>text</b>=%i%% "
+ "<b>buffer</b>=#%i"),
+ Settings.ShowSolderSide ? _("solder") : _("component"),
+ (BDimension) PCB->Grid,
+ (int) Settings.GridFactor,
+ flag, TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R " : " ",
+ Settings.LineThickness,
+ Settings.ViaThickness,
+ Settings.ViaDrillingHole,
+ ghidgui->compact_horizontal ? "\n" : "",
+ Settings.Keepaway,
+ Settings.TextScale, Settings.BufferNumber + 1);
ghid_status_line_set_text (text);
-}
-
-/* returns an auxiliary value needed to adjust mm grid.
- the adjustment is needed to prevent ..99 tails in position labels.
-
- All these are a workaround to precision lost
- because of double->integer transform
- while fitting Crosshair to grid in crosshair.c
-
- There is another workaround: report mm dimensions with %.2f, like
- in the Lesstif hid; but this reduces the information */
-static double
-ghid_get_grid_factor(void)
-{
- /* when grid units are mm, they shall be an integer of
- 1 mm / grid_scale */
- const int grid_scale = 10000; /* metric grid step is .1 um */
- double factor, rounded_factor;
-
- /* adjustment is not needed for inches
- probably because x/100 is always 'integer' enough */
- if (!Settings.grid_units_mm)
- return -1;
-
- factor = COORD_TO_MM(PCB->Grid) * grid_scale;
- rounded_factor = floor (factor + .5);
-
- /* check whether the grid is actually metric
- (as of Feb 2011, Settings.grid_units_mm may indicate just that
- the _displayed_ units are mm) */
- if (fabs (factor - rounded_factor) > 1e-3)
- return -1;
-
- return rounded_factor / grid_scale;
-}
-/* transforms a pcb coordinate to selected units
- adjusted to the nearest grid point for mm grid */
-static double
-ghid_grid_pcb_to_units (double x, double grid_factor)
-{
- double x_scaled = (Settings.grid_units_mm ? COORD_TO_MM(1): COORD_TO_MIL(1)) * x;
- double nearest_gridpoint;
-
- if (grid_factor < 0)
- return x_scaled;
-
- x = COORD_TO_MM(x);
-
- nearest_gridpoint = floor (x / grid_factor + .5);
- /* honour snapping to an unaligned object */
- if (fabs (nearest_gridpoint * grid_factor - x) > COORD_TO_MM(1))
- return x_scaled;
- /* without mm-adjusted grid_factor
- (return floor (x / PCB->Grid + .5) * COORD_TO_MM(PCB->Grid)),
- the round-off errors redintroduce the bug for 0.1 or 0.05 mm grid
- at coordinates more than 1500 mm.
- grid_factor makes the stuff work at least up to 254 m,
- which is 100 times more than default maximum board size as of Feb 2011. */
- return nearest_gridpoint * grid_factor;
+ g_free (text);
}
/* ---------------------------------------------------------------------------
@@ -612,28 +543,28 @@ ghid_grid_pcb_to_units (double x, double grid_factor)
void
ghid_set_cursor_position_labels (void)
{
- gchar text[128];
- int prec = Settings.grid_units_mm ? 4: 2;
- double grid_factor = ghid_get_grid_factor();
+ gchar *text;
if (Marked.status)
{
- double dx, dy, r, a;
-
- dx = ghid_grid_pcb_to_units (Crosshair.X - Marked.X, grid_factor);
- dy = ghid_grid_pcb_to_units (Crosshair.Y - Marked.Y, grid_factor);
- r = sqrt (dx * dx + dy * dy);
- a = atan2 (dy, dx) * RAD_TO_DEG;
- snprintf (text, sizeof (text), "r %-.*f; phi %-.1f; %-.*f %-.*f",
- prec, r, a, prec, dx, prec, dy);
+ BDimension dx = Crosshair.X - Marked.X;
+ BDimension dy = Crosshair.Y - Marked.Y;
+ BDimension r = Distance (Crosshair.X, Crosshair.Y, Marked.X, Marked.Y);
+ double a = atan2 (dy, dx) * RAD_TO_DEG;
+
+ text = pcb_g_strdup_printf ("%m+r %-mS; phi %-.1f; %-mS %-mS",
+ Settings.grid_units_mm ? ALLOW_MM : ALLOW_MIL,
+ r, a, dx, dy);
ghid_cursor_position_relative_label_set_text (text);
+ g_free (text);
}
else
ghid_cursor_position_relative_label_set_text ("r __.__; phi __._; __.__ __.__");
- snprintf (text, sizeof (text), "%-.*f %-.*f",
- prec, ghid_grid_pcb_to_units (Crosshair.X, grid_factor),
- prec, ghid_grid_pcb_to_units (Crosshair.Y, grid_factor));
+ text = pcb_g_strdup_printf ("%m+%-mS %-mS",
+ Settings.grid_units_mm ? ALLOW_MM : ALLOW_MIL,
+ Crosshair.X, Crosshair.Y);
ghid_cursor_position_label_set_text (text);
+ g_free (text);
}
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 23d6401..44ad43a 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -107,6 +107,7 @@ a zoom in/out.
#include "mymem.h"
#include "misc.h"
#include "move.h"
+#include "pcb-printf.h"
#include "polygon.h"
#include "rats.h"
#include "remove.h"
@@ -688,7 +689,7 @@ handle_grid_units_change (gboolean active)
ghid_grid_setting_update_menu_actions ();
- grid = g_strdup_printf ("%f", PCB->Grid);
+ grid = pcb_g_strdup_printf ("%$ms", (BDimension) PCB->Grid);
hid_actionl ("SetValue", "Grid", grid, "", NULL);
g_free (grid);
@@ -700,7 +701,7 @@ handle_grid_units_change (gboolean active)
static void
radio_grid_mil_setting_cb (GtkAction * action, GtkRadioAction * current)
{
- gdouble value;
+ BDimension value;
gchar *grid;
gint index;
@@ -709,7 +710,7 @@ radio_grid_mil_setting_cb (GtkAction * action, GtkRadioAction * current)
return;
index = gtk_radio_action_get_current_value (current);
value = grid_mil_values[index];
- grid = g_strdup_printf ("%f", value);
+ grid = pcb_g_strdup_printf ("%$ms", value);
hid_actionl ("SetValue", "Grid", grid, "", NULL);
g_free (grid);
ghid_set_status_line_label ();
@@ -718,7 +719,7 @@ radio_grid_mil_setting_cb (GtkAction * action, GtkRadioAction * current)
static void
radio_grid_mm_setting_cb (GtkAction * action, GtkRadioAction * current)
{
- gdouble value;
+ BDimension value;
gchar *grid;
gint index;
@@ -727,7 +728,7 @@ radio_grid_mm_setting_cb (GtkAction * action, GtkRadioAction * current)
return;
index = gtk_radio_action_get_current_value (current);
value = grid_mm_values[index];
- grid = g_strdup_printf ("%f", value);
+ grid = pcb_g_strdup_printf ("%$ms", value);
hid_actionl ("SetValue", "Grid", grid, "", NULL);
g_free (grid);
ghid_set_status_line_label ();
|
|
From: <gi...@gp...> - 2011-06-29 20:54:52
|
The branch, master has been updated
via fa9ae1f6b1eabaab961795ce7be53afe46eaa735 (commit)
via eedb86fc2369b7b54a765bab3b4d8a1dabeeba5e (commit)
via 21b7bc38226c5a3408681c9c6e1d101c1f9f7489 (commit)
from 9713a872e7e4068a3512ab080644f71e7e4dee87 (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/file.c | 10 +-
src/hid/ps/eps.c | 44 ++--
src/hid/ps/ps.c | 610 +++++++++++++++++++++++++++---------------------------
src/pcb-printf.c | 11 +-
4 files changed, 337 insertions(+), 338 deletions(-)
=================
Commit Messages
=================
commit fa9ae1f6b1eabaab961795ce7be53afe46eaa735
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert ps/eps/lpr HID's to use pcb-printf
The postscript HID now uses pcb-printf to output
all units as inches rather than cmils; therefore
the default scale is now 1:1 rather than 1:10000.
Therefore there will be a change in raw ps output
but not in printed output.
As inches are output with 5 digits after the decimal
point, there will be no loss in precision, though in
future this will be easy to increase.
Also, minor code cleanups in ps.c to reduce global
state and make global variables more visible.
:100644 100644 69430d8... 8fe5d82... M src/hid/ps/eps.c
:100644 100644 c1a62ab... f2e0706... M src/hid/ps/ps.c
commit eedb86fc2369b7b54a765bab3b4d8a1dabeeba5e
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Make pcb_fprintf ignore NULL file handle
There is a lot of code in the HID's that looks like
if (f != NULL)
fprintf (f, "...");
I have moved the NULL check inside pcb-printf to remove
this repetition/potential mistake.
:100644 100644 d2b31b7... 2c1f912... M src/pcb-printf.c
commit 21b7bc38226c5a3408681c9c6e1d101c1f9f7489
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Make sure scale/direction are not output as measures in file.c
:100644 100644 f4fb12e... c325c30... M src/file.c
=========
Changes
=========
commit fa9ae1f6b1eabaab961795ce7be53afe46eaa735
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert ps/eps/lpr HID's to use pcb-printf
The postscript HID now uses pcb-printf to output
all units as inches rather than cmils; therefore
the default scale is now 1:1 rather than 1:10000.
Therefore there will be a change in raw ps output
but not in printed output.
As inches are output with 5 digits after the decimal
point, there will be no loss in precision, though in
future this will be easy to increase.
Also, minor code cleanups in ps.c to reduce global
state and make global variables more visible.
diff --git a/src/hid/ps/eps.c b/src/hid/ps/eps.c
index 69430d8..8fe5d82 100644
--- a/src/hid/ps/eps.c
+++ b/src/hid/ps/eps.c
@@ -13,6 +13,7 @@
#include "global.h"
#include "data.h"
#include "misc.h"
+#include "pcb-printf.h"
#include "hid.h"
#include "../hidint.h"
@@ -230,10 +231,11 @@ eps_hid_export_to_file (FILE * the_file, HID_Attr_Val * options)
in_mono = options[HA_mono].int_value;
-#define pcb2em(x) (int)(COORD_TO_INCH(x) * 72.0 * options[HA_scale].real_value + 1)
- fprintf (f, "%%%%BoundingBox: 0 0 %d %d\n",
+#define pcb2em(x) (BDimension)((x) * 72.0 * options[HA_scale].real_value + INCH_TO_COORD(1))
+ pcb_fprintf (f, "%%%%BoundingBox: 0 0 %mi %mi\n",
pcb2em (bounds->X2 - bounds->X1),
pcb2em (bounds->Y2 - bounds->Y1));
+#undef pcb2em
fprintf (f, "%%%%Pages: 1\n");
fprintf (f,
"save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def\n");
@@ -242,21 +244,17 @@ eps_hid_export_to_file (FILE * the_file, HID_Attr_Val * options)
fprintf (f, "%%%%BeginDocument: %s\n\n", filename);
fprintf (f, "72 72 scale\n");
- fprintf (f, "0.00001 dup neg scale\n");
+ fprintf (f, "1 dup neg scale\n");
fprintf (f, "%g dup scale\n", options[HA_scale].real_value);
- fprintf (f, "%d %d translate\n", -bounds->X1, -bounds->Y2);
- if (options[HA_as_shown].int_value
- && Settings.ShowSolderSide)
- {
- fprintf (f, "-1 1 scale %d 0 translate\n",
- bounds->X1 - bounds->X2);
- }
+ pcb_fprintf (f, "%mi %mi translate\n", -bounds->X1, -bounds->Y2);
+ if (options[HA_as_shown].int_value && Settings.ShowSolderSide)
+ pcb_fprintf (f, "-1 1 scale %mi 0 translate\n", bounds->X1 - bounds->X2);
linewidth = -1;
lastcap = -1;
lastcolor = -1;
-#define Q 1000
- fprintf (f,
- "/nclip { %d %d moveto %d %d lineto %d %d lineto %d %d lineto %d %d lineto eoclip newpath } def\n",
+#define Q (BDimension) MIL_TO_COORD(10)
+ pcb_fprintf (f,
+ "/nclip { %mi %mi moveto %mi %mi lineto %mi %mi lineto %mi %mi lineto %mi %mi lineto eoclip newpath } def\n",
bounds->X1 - Q, bounds->Y1 - Q, bounds->X1 - Q, bounds->Y2 + Q,
bounds->X2 + Q, bounds->Y2 + Q, bounds->X2 + Q, bounds->Y1 - Q,
bounds->X1 - Q, bounds->Y1 - Q);
@@ -490,7 +488,7 @@ use_gc (hidGC gc)
{
if (linewidth != gc->width)
{
- fprintf (f, "%d setlinewidth\n", gc->width);
+ pcb_fprintf (f, "%mi setlinewidth\n", gc->width);
linewidth = gc->width;
}
if (lastcap != gc->cap)
@@ -526,7 +524,7 @@ static void
eps_draw_rect (hidGC gc, int x1, int y1, int x2, int y2)
{
use_gc (gc);
- fprintf (f, "%d %d %d %d r\n", x1, y1, x2, y2);
+ pcb_fprintf (f, "%mi %mi %mi %mi r\n", x1, y1, x2, y2);
}
static void
@@ -551,14 +549,14 @@ eps_draw_line (hidGC gc, int x1, int y1, int x2, int y2)
int vx1 = x1 + dx;
int vy1 = y1 + dy;
- fprintf (f, "%d %d moveto ", vx1, vy1);
- fprintf (f, "%d %d %d %g %g arc\n", x2, y2, w, deg - 90, deg + 90);
- fprintf (f, "%d %d %d %g %g arc\n", x1, y1, w, deg + 90, deg + 270);
+ pcb_fprintf (f, "%mi %mi moveto ", vx1, vy1);
+ pcb_fprintf (f, "%mi %mi %mi %g %g arc\n", x2, y2, w, deg - 90, deg + 90);
+ pcb_fprintf (f, "%mi %mi %mi %g %g arc\n", x1, y1, w, deg + 90, deg + 270);
fprintf (f, "nclip\n");
return;
}
- fprintf (f, "%d %d %d %d %s\n", x1, y1, x2, y2, gc->erase ? "tc" : "t");
+ pcb_fprintf (f, "%mi %mi %mi %mi %s\n", x1, y1, x2, y2, gc->erase ? "tc" : "t");
}
static void
@@ -581,7 +579,7 @@ eps_draw_arc (hidGC gc, int cx, int cy, int width, int height,
cx, cy, width, height, start_angle, delta_angle, sa, ea);
#endif
use_gc (gc);
- fprintf (f, "%d %d %d %d %d %d %g a\n",
+ pcb_fprintf (f, "%d %d %mi %mi %mi %mi %g a\n",
sa, ea, -width, height, cx, cy, (double) linewidth / width);
}
@@ -589,7 +587,7 @@ static void
eps_fill_circle (hidGC gc, int cx, int cy, int radius)
{
use_gc (gc);
- fprintf (f, "%d %d %d %s\n", cx, cy, radius, gc->erase ? "cc" : "c");
+ pcb_fprintf (f, "%mi %mi %mi %s\n", cx, cy, radius, gc->erase ? "cc" : "c");
}
static void
@@ -600,7 +598,7 @@ eps_fill_polygon (hidGC gc, int n_coords, int *x, int *y)
use_gc (gc);
for (i = 0; i < n_coords; i++)
{
- fprintf (f, "%d %d %s\n", x[i], y[i], op);
+ pcb_fprintf (f, "%mi %mi %s\n", x[i], y[i], op);
op = "lineto";
}
fprintf (f, "fill\n");
@@ -610,7 +608,7 @@ static void
eps_fill_rect (hidGC gc, int x1, int y1, int x2, int y2)
{
use_gc (gc);
- fprintf (f, "%d %d %d %d r\n", x1, y1, x2, y2);
+ pcb_fprintf (f, "%mi %mi %mi %mi r\n", x1, y1, x2, y2);
}
static void
diff --git a/src/hid/ps/ps.c b/src/hid/ps/ps.c
index c1a62ab..f2e0706 100644
--- a/src/hid/ps/ps.c
+++ b/src/hid/ps/ps.c
@@ -16,6 +16,7 @@
#include "misc.h"
#include "error.h"
#include "draw.h"
+#include "pcb-printf.h"
#include "hid.h"
#include "../hidint.h"
@@ -33,6 +34,9 @@ RCSID ("$Id$");
#define CRASH fprintf(stderr, "HID error: pcb called unimplemented PS function %s.\n", __FUNCTION__); abort()
+static int ps_set_layer (const char *name, int group, int empty);
+static void use_gc (hidGC gc);
+
typedef struct hid_gc_struct
{
HID *me_pointer;
@@ -43,21 +47,6 @@ typedef struct hid_gc_struct
int faded;
} hid_gc_struct;
-static double calibration_x = 1.0, calibration_y = 1.0;
-
-static FILE *f = 0;
-static int pagecount = 0;
-static int linewidth = -1;
-static int lastgroup = -1;
-static int lastcap = -1;
-static int lastcolor = -1;
-static int print_group[MAX_LAYER];
-static int print_layer[MAX_LAYER];
-static double fade_ratio = 0.4;
-static double antifade_ratio = 0.6;
-static int multi_file = 0;
-static double media_width, media_height, ps_width, ps_height;
-
static const char *medias[] = {
"A0", "A1", "A2", "A3", "A4", "A5",
"A6", "A7", "A8", "A9", "A10",
@@ -74,8 +63,8 @@ static const char *medias[] = {
typedef struct
{
char *name;
- long int Width, Height;
- long int MarginX, MarginY;
+ BDimension Width, Height;
+ BDimension MarginX, MarginY;
} MediaType, *MediaTypePtr;
/*
@@ -216,7 +205,48 @@ HID_Attribute ps_attribute_list[] = {
REGISTER_ATTRIBUTES (ps_attribute_list)
-static HID_Attr_Val ps_values[NUM_OPTIONS];
+/* All file-scope data is in global struct */
+static struct {
+ double calibration_x, calibration_y;
+
+ FILE *f;
+ int pagecount;
+ BDimension linewidth;
+ bool print_group[MAX_LAYER];
+ bool print_layer[MAX_LAYER];
+ double fade_ratio;
+ bool multi_file;
+ BDimension media_width, media_height, ps_width, ps_height;
+
+ char *filename;
+ bool drill_helper;
+ bool align_marks;
+ bool outline;
+ bool mirror;
+ bool fillpage;
+ bool automirror;
+ bool incolor;
+ bool doing_toc;
+ BDimension bloat;
+ bool invert;
+ int media_idx;
+ bool drillcopper;
+ bool legend;
+
+ LayerTypePtr outline_layer;
+
+ double scale_factor;
+
+ BoxType region;
+
+ HID_Attr_Val ps_values[NUM_OPTIONS];
+
+ bool is_mask;
+ bool is_drill;
+ bool is_assy;
+ bool is_copper;
+ bool is_paste;
+} global;
static HID_Attribute *
ps_get_export_options (int *n)
@@ -250,26 +280,6 @@ layer_sort (const void *va, const void *vb)
return b - a;
}
-static char *filename;
-static int drill_helper;
-static int align_marks;
-static int outline;
-static int mirror;
-static int fillpage;
-static int automirror;
-static int incolor;
-static int doing_toc;
-static int bloat;
-static int invert;
-static int media;
-static int drillcopper;
-static int legend;
-
-static LayerTypePtr outline_layer;
-
-static double fill_zoom;
-static double scale_value;
-
void
ps_start_file (FILE *f)
{
@@ -348,12 +358,11 @@ ps_start_file (FILE *f)
*
* Media sizes are in PCB units
*/
- fprintf (f, "%%%%DocumentMedia: %s %g %g 0 \"\" \"\"\n",
- media_data[media].name,
- COORD_TO_INCH(media_data[media].Width) * 72.0,
- COORD_TO_INCH(media_data[media].Height) * 72.0);
- fprintf (f, "%%%%DocumentPaperSizes: %s\n",
- media_data[media].name);
+ pcb_fprintf (f, "%%%%DocumentMedia: %s %mi %mi 0 \"\" \"\"\n",
+ media_data[global.media_idx].name,
+ 72 * media_data[global.media_idx].Width,
+ 72 * media_data[global.media_idx].Height);
+ pcb_fprintf (f, "%%%%DocumentPaperSizes: %s\n", media_data[global.media_idx].name);
/* End General Header Comments. */
@@ -385,7 +394,7 @@ ps_end_file (FILE *f)
* %%Pages was deferred until the end of the document via the
* (atend) mentioned, in the General Header section.
*/
- fprintf (f, "%%%%Pages: %d\n", pagecount );
+ fprintf (f, "%%%%Pages: %d\n", global.pagecount);
/*
* %%EOF DCS signifies the end of the document. When the document
@@ -403,7 +412,7 @@ psopen (const char *base, const char *which)
FILE *ps_open_file;
char *buf, *suff, *buf2;
- if (!multi_file)
+ if (!global.multi_file)
return fopen (base, "w");
buf = (char *)malloc (strlen (base) + strlen (which) + 5);
@@ -425,8 +434,6 @@ psopen (const char *base, const char *which)
return ps_open_file;
}
-static BoxType region;
-
/* This is used by other HIDs that use a postscript format, like lpr
or eps. */
void
@@ -440,117 +447,106 @@ ps_hid_export_to_file (FILE * the_file, HID_Attr_Val * options)
CLEAR_FLAG(THINDRAWFLAG, PCB);
CLEAR_FLAG(THINDRAWPOLYFLAG, PCB);
- f = the_file;
- drill_helper = options[HA_drillhelper].int_value;
- align_marks = options[HA_alignmarks].int_value;
- outline = options[HA_outline].int_value;
- mirror = options[HA_mirror].int_value;
- fillpage = options[HA_fillpage].int_value;
- automirror = options[HA_automirror].int_value;
- incolor = options[HA_color].int_value;
- bloat = options[HA_psbloat].int_value;
- invert = options[HA_psinvert].int_value;
- fade_ratio = options[HA_psfade].real_value;
- media = options[HA_media].int_value;
- media_width = media_data[media].Width / 1e5;
- media_height = media_data[media].Height / 1e5;
- ps_width = media_width - 2.0*media_data[media].MarginX / 1e5;
- ps_height = media_height - 2.0*media_data[media].MarginY / 1e5;
- scale_value = options[HA_scale].real_value;
- calibration_x = options[HA_xcalib].real_value;
- calibration_y = options[HA_ycalib].real_value;
- drillcopper = options[HA_drillcopper].int_value;
- legend = options[HA_legend].int_value;
-
- if (f)
- ps_start_file (f);
-
- if (fade_ratio < 0)
- fade_ratio = 0;
- if (fade_ratio > 1)
- fade_ratio = 1;
- antifade_ratio = 1.0 - fade_ratio;
-
- if (fillpage)
+ global.f = the_file;
+ global.drill_helper = options[HA_drillhelper].int_value;
+ global.align_marks = options[HA_alignmarks].int_value;
+ global.outline = options[HA_outline].int_value;
+ global.mirror = options[HA_mirror].int_value;
+ global.fillpage = options[HA_fillpage].int_value;
+ global.automirror = options[HA_automirror].int_value;
+ global.incolor = options[HA_color].int_value;
+ global.bloat = options[HA_psbloat].int_value;
+ global.invert = options[HA_psinvert].int_value;
+ global.fade_ratio = CLAMP (options[HA_psfade].real_value, 0, 1);
+ global.media_idx = options[HA_media].int_value;
+ global.media_width = media_data[global.media_idx].Width;
+ global.media_height = media_data[global.media_idx].Height;
+ global.ps_width = global.media_width
+ - 2.0 * media_data[global.media_idx].MarginX;
+ global.ps_height = global.media_height
+ - 2.0 * media_data[global.media_idx].MarginY;
+ global.scale_factor = options[HA_scale].real_value;
+ global.calibration_x = options[HA_xcalib].real_value;
+ global.calibration_y = options[HA_ycalib].real_value;
+ global.drillcopper = options[HA_drillcopper].int_value;
+ global.legend = options[HA_legend].int_value;
+
+ if (the_file)
+ ps_start_file (the_file);
+
+ if (global.fillpage)
{
double zx, zy;
if (PCB->MaxWidth > PCB->MaxHeight)
{
- zx = ps_height / PCB->MaxWidth;
- zy = ps_width / PCB->MaxHeight;
+ zx = global.ps_height / PCB->MaxWidth;
+ zy = global.ps_width / PCB->MaxHeight;
}
else
{
- zx = ps_height / PCB->MaxHeight;
- zy = ps_width / PCB->MaxWidth;
+ zx = global.ps_height / PCB->MaxHeight;
+ zy = global.ps_width / PCB->MaxWidth;
}
- if (zx < zy)
- fill_zoom = zx;
- else
- fill_zoom = zy;
+ global.scale_factor *= MIN (zx, zy);
}
- else
- fill_zoom = 0.00001;
+ memset (global.print_group, 0, sizeof (global.print_group));
+ memset (global.print_layer, 0, sizeof (global.print_layer));
- memset (print_group, 0, sizeof (print_group));
- memset (print_layer, 0, sizeof (print_layer));
-
- outline_layer = NULL;
+ global.outline_layer = NULL;
for (i = 0; i < max_copper_layer; i++)
{
LayerType *layer = PCB->Data->Layer + i;
if (layer->LineN || layer->TextN || layer->ArcN || layer->PolygonN)
- print_group[GetLayerGroupNumberByNumber (i)] = 1;
+ global.print_group[GetLayerGroupNumberByNumber (i)] = 1;
if (strcmp (layer->Name, "outline") == 0 ||
strcmp (layer->Name, "route") == 0)
{
- outline_layer = layer;
+ global.outline_layer = layer;
}
}
- print_group[GetLayerGroupNumberByNumber (solder_silk_layer)] = 1;
- print_group[GetLayerGroupNumberByNumber (component_silk_layer)] = 1;
+ global.print_group[GetLayerGroupNumberByNumber (solder_silk_layer)] = 1;
+ global.print_group[GetLayerGroupNumberByNumber (component_silk_layer)] = 1;
for (i = 0; i < max_copper_layer; i++)
- if (print_group[GetLayerGroupNumberByNumber (i)])
- print_layer[i] = 1;
+ if (global.print_group[GetLayerGroupNumberByNumber (i)])
+ global.print_layer[i] = 1;
memcpy (saved_layer_stack, LayerStack, sizeof (LayerStack));
qsort (LayerStack, max_copper_layer, sizeof (LayerStack[0]), layer_sort);
- lastgroup = -1;
- linewidth = -1;
- lastcap = -1;
- lastcolor = -1;
+ global.linewidth = -1;
+ /* reset static vars */
+ ps_set_layer (NULL, 0, -1);
+ use_gc (NULL);
- region.X1 = 0;
- region.Y1 = 0;
- region.X2 = PCB->MaxWidth;
- region.Y2 = PCB->MaxHeight;
+ global.region.X1 = 0;
+ global.region.Y1 = 0;
+ global.region.X2 = PCB->MaxWidth;
+ global.region.Y2 = PCB->MaxHeight;
- if (! multi_file)
+ if (!global.multi_file)
{
- fprintf (f, "%%%%Page: TableOfContents 1\n"); /* %%Page DSC requires both a label and an ordinal */
- fprintf (f, "/Times-Roman findfont 24 scalefont setfont\n");
- fprintf (f,
- "/rightshow { /s exch def s stringwidth pop -1 mul 0 rmoveto s show } def\n");
- fprintf (f,
- "/y 72 9 mul def /toc { 100 y moveto show /y y 24 sub def } bind def\n");
- fprintf (f, "/tocp { /y y 12 sub def 90 y moveto rightshow } bind def\n");
-
- doing_toc = 1;
- pagecount = 1; /* 'pagecount' is modified by hid_expose_callback() call */
- hid_expose_callback (&ps_hid, ®ion, 0);
+ /* %%Page DSC requires both a label and an ordinal */
+ fprintf (the_file, "%%%%Page: TableOfContents 1\n");
+ fprintf (the_file, "/Times-Roman findfont 24 scalefont setfont\n");
+ fprintf (the_file, "/rightshow { /s exch def s stringwidth pop -1 mul 0 rmoveto s show } def\n");
+ fprintf (the_file, "/y 72 9 mul def /toc { 100 y moveto show /y y 24 sub def } bind def\n");
+ fprintf (the_file, "/tocp { /y y 12 sub def 90 y moveto rightshow } bind def\n");
+
+ global.doing_toc = 1;
+ global.pagecount = 1; /* 'pagecount' is modified by hid_expose_callback() call */
+ hid_expose_callback (&ps_hid, &global.region, 0);
}
- pagecount = 1; /* Reset 'pagecount' if single file */
- doing_toc = 0;
- lastgroup = -1;
- hid_expose_callback (&ps_hid, ®ion, 0);
+ global.pagecount = 1; /* Reset 'pagecount' if single file */
+ global.doing_toc = 0;
+ ps_set_layer (NULL, 0, -1); /* reset static vars */
+ hid_expose_callback (&ps_hid, &global.region, 0);
- if (f)
- fprintf (f, "showpage\n");
+ if (the_file)
+ fprintf (the_file, "showpage\n");
memcpy (LayerStack, saved_layer_stack, sizeof (LayerStack));
PCB->Flags = save_thindraw;
@@ -559,6 +555,7 @@ ps_hid_export_to_file (FILE * the_file, HID_Attr_Val * options)
static void
ps_do_export (HID_Attr_Val * options)
{
+ FILE *fh;
int save_ons[MAX_LAYER + 2];
int i;
@@ -566,60 +563,53 @@ ps_do_export (HID_Attr_Val * options)
{
ps_get_export_options (0);
for (i = 0; i < NUM_OPTIONS; i++)
- ps_values[i] = ps_attribute_list[i].default_val;
- options = ps_values;
+ global.ps_values[i] = ps_attribute_list[i].default_val;
+ options = global.ps_values;
}
- filename = options[HA_psfile].str_value;
- if (!filename)
- filename = "pcb-out.ps";
+ global.filename = options[HA_psfile].str_value;
+ if (!global.filename)
+ global.filename = "pcb-out.ps";
- multi_file = options[HA_multifile].int_value;
+ global.multi_file = options[HA_multifile].int_value;
- if (multi_file)
- f = 0;
+ if (global.multi_file)
+ fh = 0;
else
{
- f = psopen (filename, "toc");
- if (!f)
+ fh = psopen (global.filename, "toc");
+ if (!fh)
{
- perror (filename);
+ perror (global.filename);
return;
}
}
hid_save_and_show_layer_ons (save_ons);
- ps_hid_export_to_file (f, options);
+ ps_hid_export_to_file (fh, options);
hid_restore_layer_ons (save_ons);
- multi_file = 0;
- if (f)
+ global.multi_file = 0;
+ if (fh)
{
- ps_end_file (f);
- fclose (f);
+ ps_end_file (fh);
+ fclose (fh);
}
}
static void
ps_parse_arguments (int *argc, char ***argv)
{
- hid_register_attributes (ps_attribute_list,
- sizeof (ps_attribute_list) /
- sizeof (ps_attribute_list[0]));
+ hid_register_attributes (ps_attribute_list, NUM_OPTIONS);
hid_parse_command_line (argc, argv);
}
static void
-corner (int x, int y, int dx, int dy)
+corner (FILE *fh, BDimension x, BDimension y, BDimension dx, BDimension dy)
{
-#if 0
- int len = (PCB->MaxWidth + PCB->MaxHeight) / 10;
- int len2 = (PCB->MaxWidth + PCB->MaxHeight) / 50;
-#else
- int len = MIL_TO_COORD(2000);
- int len2 = MIL_TO_COORD(200);
-#endif
- int thick = 0;
+ BDimension len = MIL_TO_COORD (2000);
+ BDimension len2 = MIL_TO_COORD (200);
+ BDimension thick = 0;
/*
* Originally 'thick' used thicker lines. Currently is uses
* Postscript's "device thin" line - i.e. zero width means one
@@ -629,72 +619,68 @@ corner (int x, int y, int dx, int dy)
* of the thick line.
*/
- fprintf (f, "gsave %d setlinewidth %d %d translate %d %d scale\n",
- thick * 2, x, y, dx, dy);
- fprintf (f, "%d %d moveto %d %d %d 0 90 arc %d %d lineto\n",
- len, thick, thick, thick, len2 + thick, thick, len);
+ pcb_fprintf (fh, "gsave %mi setlinewidth %mi %mi translate %mi %mi scale\n",
+ thick * 2, x, y, dx, dy);
+ pcb_fprintf (fh, "%mi %mi moveto %mi %mi %mi 0 90 arc %mi %mi lineto\n",
+ len, thick, thick, thick, len2 + thick, thick, len);
if (dx < 0 && dy < 0)
- fprintf (f, "%d %d moveto 0 %d rlineto\n",
- len2 * 2 + thick, thick, -len2);
- fprintf (f, "stroke grestore\n");
+ pcb_fprintf (fh, "%mi %mi moveto 0 %mi rlineto\n", len2 * 2 + thick, thick, -len2);
+ fprintf (fh, "stroke grestore\n");
}
-static int is_mask;
-static int is_drill;
-static int is_assy;
-static int is_copper;
-static int is_paste;
-
static int
ps_set_layer (const char *name, int group, int empty)
{
+ static int lastgroup = -1;
time_t currenttime;
- int idx = (group >= 0
- && group <
- max_group) ? PCB->LayerGroups.Entries[group][0] : group;
+ int idx = (group >= 0 && group < max_group)
+ ? PCB->LayerGroups.Entries[group][0]
+ : group;
if (name == 0)
name = PCB->Data->Layer[idx].Name;
+ if (empty == -1)
+ lastgroup = -1;
if (empty)
return 0;
- if (idx >= 0 && idx < max_copper_layer && !print_layer[idx])
+ if (idx >= 0 && idx < max_copper_layer && !global.print_layer[idx])
return 0;
if (strcmp (name, "invisible") == 0)
return 0;
- is_drill = (SL_TYPE (idx) == SL_PDRILL || SL_TYPE (idx) == SL_UDRILL);
- is_mask = (SL_TYPE (idx) == SL_MASK);
- is_assy = (SL_TYPE (idx) == SL_ASSY);
- is_copper = (SL_TYPE (idx) == 0);
- is_paste = (SL_TYPE (idx) == SL_PASTE);
+ global.is_drill = (SL_TYPE (idx) == SL_PDRILL || SL_TYPE (idx) == SL_UDRILL);
+ global.is_mask = (SL_TYPE (idx) == SL_MASK);
+ global.is_assy = (SL_TYPE (idx) == SL_ASSY);
+ global.is_copper = (SL_TYPE (idx) == 0);
+ global.is_paste = (SL_TYPE (idx) == SL_PASTE);
#if 0
- printf ("Layer %s group %d drill %d mask %d\n", name, group, is_drill,
- is_mask);
+ printf ("Layer %s group %d drill %d mask %d\n", name, group, global.is_drill,
+ global.is_mask);
#endif
- if (doing_toc)
+ if (global.doing_toc)
{
if (group < 0 || group != lastgroup)
{
- if( 1 == pagecount )
+ if (global.pagecount == 1)
{
- currenttime = time( NULL );
- fprintf (f, "30 30 moveto (%s) show\n", PCB->Filename);
+ currenttime = time (NULL);
+ fprintf (global.f, "30 30 moveto (%s) show\n", PCB->Filename);
- fprintf (f, "(%d.) tocp\n", pagecount);
- fprintf (f, "(Table of Contents \\(This Page\\)) toc\n" );
+ fprintf (global.f, "(%d.) tocp\n", global.pagecount);
+ fprintf (global.f, "(Table of Contents \\(This Page\\)) toc\n" );
- fprintf (f, "(Created on %s) toc\n", asctime (localtime (¤ttime)));
- fprintf (f, "( ) tocp\n" );
+ fprintf (global.f, "(Created on %s) toc\n", asctime (localtime (¤ttime)));
+ fprintf (global.f, "( ) tocp\n" );
}
- pagecount++;
+ global.pagecount++;
lastgroup = group;
- fprintf (f, "(%d.) tocp\n", pagecount);
+ fprintf (global.f, "(%d.) tocp\n", global.pagecount);
}
- fprintf (f, "(%s) toc\n", name);
+ fprintf (global.f, "(%s) toc\n", name);
return 0;
}
@@ -704,26 +690,26 @@ ps_set_layer (const char *name, int group, int empty)
int mirror_this = 0;
lastgroup = group;
- if (f && pagecount)
+ if (global.pagecount != 0)
{
- fprintf (f, "showpage\n");
+ pcb_fprintf (global.f, "showpage\n");
}
- pagecount++;
- if (multi_file)
+ global.pagecount++;
+ if (global.multi_file)
{
- if (f)
+ if (global.f)
{
- ps_end_file (f);
- fclose (f);
+ ps_end_file (global.f);
+ fclose (global.f);
}
- f = psopen (filename, layer_type_to_file_name (idx, FNS_fixed));
- if (!f)
+ global.f = psopen (global.filename, layer_type_to_file_name (idx, FNS_fixed));
+ if (!global.f)
{
- perror(filename);
+ perror (global.filename);
return 0;
}
- ps_start_file (f);
+ ps_start_file (global.f);
}
/*
@@ -734,137 +720,136 @@ ps_set_layer (const char *name, int group, int empty)
* ordinal page number must reflect the position of that page in
* the body of the PostScript file and must start with 1, not 0.
*/
- fprintf (f, "%%%%Page: %s %d\n", layer_type_to_file_name(idx, FNS_fixed), pagecount);
+ fprintf (global.f, "%%%%Page: %s %d\n", layer_type_to_file_name(idx, FNS_fixed), global.pagecount);
- if (mirror)
- mirror_this = 1 - mirror_this;
- if (automirror
+ if (global.mirror)
+ mirror_this = !mirror_this;
+ if (global.automirror
&&
((idx >= 0 && group == GetLayerGroupNumberByNumber (solder_silk_layer))
|| (idx < 0 && SL_SIDE (idx) == SL_BOTTOM_SIDE)))
- mirror_this = 1 - mirror_this;
+ mirror_this = !mirror_this;
- fprintf (f, "/Helvetica findfont 10 scalefont setfont\n");
- if (legend)
+ fprintf (global.f, "/Helvetica findfont 10 scalefont setfont\n");
+ if (global.legend)
{
- fprintf (f, "30 30 moveto (%s) show\n", PCB->Filename);
+ fprintf (global.f, "30 30 moveto (%s) show\n", PCB->Filename);
if (PCB->Name)
- fprintf (f, "30 41 moveto (%s, %s) show\n",
+ fprintf (global.f, "30 41 moveto (%s, %s) show\n",
PCB->Name, layer_type_to_file_name (idx, FNS_fixed));
else
- fprintf (f, "30 41 moveto (%s) show\n",
+ fprintf (global.f, "30 41 moveto (%s) show\n",
layer_type_to_file_name (idx, FNS_fixed));
if (mirror_this)
- fprintf (f, "( \\(mirrored\\)) show\n");
+ fprintf (global.f, "( \\(mirrored\\)) show\n");
- if (fillpage)
- fprintf (f, "(, not to scale) show\n");
+ if (global.fillpage)
+ fprintf (global.f, "(, not to scale) show\n");
else
- fprintf (f, "(, scale = 1:%.3f) show\n", scale_value);
+ fprintf (global.f, "(, scale = 1:%.3f) show\n", global.scale_factor);
}
- fprintf (f, "newpath\n");
+ fprintf (global.f, "newpath\n");
- fprintf (f, "72 72 scale %g %g translate\n", 0.5*media_width, 0.5*media_height);
+ pcb_fprintf (global.f, "72 72 scale %mi %mi translate\n",
+ global.media_width / 2, global.media_height / 2);
- boffset = 0.5*media_height;
+ boffset = global.media_height / 2;
if (PCB->MaxWidth > PCB->MaxHeight)
{
- fprintf (f, "90 rotate\n");
- boffset = 0.5*media_width;
- fprintf (f, "%g %g scale %% calibration\n", calibration_y, calibration_x);
+ fprintf (global.f, "90 rotate\n");
+ boffset = global.media_width / 2;
+ fprintf (global.f, "%g %g scale %% calibration\n", global.calibration_y, global.calibration_x);
}
else
- fprintf (f, "%g %g scale %% calibration\n", calibration_x, calibration_y);
+ fprintf (global.f, "%g %g scale %% calibration\n", global.calibration_x, global.calibration_y);
if (mirror_this)
- fprintf (f, "1 -1 scale\n");
+ fprintf (global.f, "1 -1 scale\n");
- if (SL_TYPE (idx) == SL_FAB)
- fprintf (f, "0.00001 dup neg scale\n");
- else
- fprintf (f, "%g dup neg scale\n", (fill_zoom * scale_value));
- fprintf (f, "%d %d translate\n",
- -PCB->MaxWidth / 2, -PCB->MaxHeight / 2);
+ fprintf (global.f, "%g dup neg scale\n",
+ (SL_TYPE (idx) == SL_FAB) ? 1.0 : global.scale_factor);
+ pcb_fprintf (global.f, "%mi %mi translate\n", -PCB->MaxWidth / 2, -PCB->MaxHeight / 2);
/* Keep the drill list from falling off the left edge of the paper,
* even if it means some of the board falls off the right edge.
* If users don't want to make smaller boards, or use fewer drill
* sizes, they can always ignore this sheet. */
if (SL_TYPE (idx) == SL_FAB) {
- int natural = (int) ((boffset - 0.5) * INCH_TO_COORD(1)) - PCB->MaxHeight / 2;
- int needed = PrintFab_overhang();
- fprintf (f, "%% PrintFab overhang natural %d, needed %d\n", natural, needed);
+ BDimension natural = boffset - MIL_TO_COORD(500) - PCB->MaxHeight / 2;
+ BDimension needed = PrintFab_overhang ();
+ pcb_fprintf (global.f, "%% PrintFab overhang natural %mi, needed %mi\n", natural, needed);
if (needed > natural)
- fprintf (f, "0 %d translate\n", needed - natural);
+ pcb_fprintf (global.f, "0 %mi translate\n", needed - natural);
}
- if (invert)
+ if (global.invert)
{
- fprintf (f, "/gray { 1 exch sub setgray } bind def\n");
- fprintf (f,
- "/rgb { 1 1 3 { pop 1 exch sub 3 1 roll } for setrgbcolor } bind def\n");
+ fprintf (global.f, "/gray { 1 exch sub setgray } bind def\n");
+ fprintf (global.f,
+ "/rgb { 1 1 3 { pop 1 exch sub 3 1 roll } for setrgbcolor } bind def\n");
}
else
{
- fprintf (f, "/gray { setgray } bind def\n");
- fprintf (f, "/rgb { setrgbcolor } bind def\n");
+ fprintf (global.f, "/gray { setgray } bind def\n");
+ fprintf (global.f, "/rgb { setrgbcolor } bind def\n");
}
- if ((outline && !outline_layer) || invert)
+ if ((global.outline && !global.outline_layer) || global.invert)
{
- fprintf (f,
- "0 setgray 0 setlinewidth 0 0 moveto 0 %d lineto %d %d lineto %d 0 lineto closepath %s\n",
- PCB->MaxHeight, PCB->MaxWidth, PCB->MaxHeight, PCB->MaxWidth,
- invert ? "fill" : "stroke");
+ pcb_fprintf (global.f,
+ "0 setgray 0 setlinewidth 0 0 moveto 0 "
+ "%mi lineto %mi %mi lineto %mi 0 lineto closepath %s\n",
+ PCB->MaxHeight, PCB->MaxWidth, PCB->MaxHeight, PCB->MaxWidth,
+ global.invert ? "fill" : "stroke");
}
- if (align_marks)
+ if (global.align_marks)
{
- corner (0, 0, -1, -1);
- corner (PCB->MaxWidth, 0, 1, -1);
- corner (PCB->MaxWidth, PCB->MaxHeight, 1, 1);
- corner (0, PCB->MaxHeight, -1, 1);
+ corner (global.f, 0, 0, -1, -1);
+ corner (global.f, PCB->MaxWidth, 0, 1, -1);
+ corner (global.f, PCB->MaxWidth, PCB->MaxHeight, 1, 1);
+ corner (global.f, 0, PCB->MaxHeight, -1, 1);
}
- linewidth = -1;
- lastcap = -1;
- lastcolor = -1;
-
- fprintf (f, "/ts 10000 def\n");
- fprintf (f, "/ty ts neg def /tx 0 def /Helvetica findfont ts scalefont setfont\n");
- fprintf (f, "/t { moveto lineto stroke } bind def\n");
- fprintf (f, "/dr { /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n");
- fprintf (f, " x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath stroke } bind def\n");
- fprintf (f, "/r { /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n");
- fprintf (f, " x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath fill } bind def\n");
- fprintf (f, "/c { 0 360 arc fill } bind def\n");
- fprintf (f, "/a { gsave setlinewidth translate scale 0 0 1 5 3 roll arc stroke grestore} bind def\n");
- if (drill_helper)
- fprintf (f,
- "/dh { gsave %f setlinewidth 0 gray %f 0 360 arc stroke grestore} bind def\n",
- MIN_PINORVIAHOLE, MIN_PINORVIAHOLE * 3 / 2);
+ global.linewidth = -1;
+ use_gc (NULL); /* reset static vars */
+
+ fprintf (global.f,
+ "/ts 1 def\n"
+ "/ty ts neg def /tx 0 def /Helvetica findfont ts scalefont setfont\n"
+ "/t { moveto lineto stroke } bind def\n"
+ "/dr { /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n"
+ " x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath stroke } bind def\n"
+ "/r { /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n"
+ " x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath fill } bind def\n"
+ "/c { 0 360 arc fill } bind def\n"
+ "/a { gsave setlinewidth translate scale 0 0 1 5 3 roll arc stroke grestore} bind def\n");
+ if (global.drill_helper)
+ pcb_fprintf (global.f,
+ "/dh { gsave %mi setlinewidth 0 gray %mi 0 360 arc stroke grestore} bind def\n",
+ (BDimension) MIN_PINORVIAHOLE, (BDimension) (MIN_PINORVIAHOLE * 3 / 2));
}
#if 0
/* Try to outsmart ps2pdf's heuristics for page rotation, by putting
* text on all pages -- even if that text is blank */
if (SL_TYPE (idx) != SL_FAB)
- fprintf (f,
+ fprintf (global.f,
"gsave tx ty translate 1 -1 scale 0 0 moveto (Layer %s) show grestore newpath /ty ty ts sub def\n",
name);
else
- fprintf (f, "gsave tx ty translate 1 -1 scale 0 0 moveto ( ) show grestore newpath /ty ty ts sub def\n");
+ 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,
print the outline layer on this layer also. */
- if (outline
- && outline_layer
- && outline_layer != PCB->Data->Layer+idx
+ if (global.outline
+ && global.outline_layer != NULL
+ && global.outline_layer != PCB->Data->Layer+idx
&& strcmp (name, "outline")
&& strcmp (name, "route"))
{
- DrawLayer (outline_layer, ®ion);
+ DrawLayer (global.outline_layer, &global.region);
}
return 1;
@@ -899,7 +884,7 @@ ps_set_color (hidGC gc, const char *name)
gc->r = gc->g = gc->b = 255;
gc->erase = 1;
}
- else if (incolor)
+ else if (global.incolor)
{
int r, g, b;
sscanf (name + 1, "%02x%02x%02x", &r, &g, &b);
@@ -942,16 +927,24 @@ ps_set_draw_faded (hidGC gc, int faded)
static void
use_gc (hidGC gc)
{
+ static BDimension lastcap = -1;
+ static BDimension lastcolor = -1;
+
+ if (gc == NULL)
+ {
+ lastcap = lastcolor = -1;
+ return;
+ }
if (gc->me_pointer != &ps_hid)
{
fprintf (stderr, "Fatal: GC from another HID passed to ps HID\n");
abort ();
}
- if (linewidth != gc->width)
+ if (global.linewidth != gc->width)
{
- fprintf (f, "%d setlinewidth\n",
- gc->width + (gc->erase ? -2 : 2) * bloat);
- linewidth = gc->width;
+ pcb_fprintf (global.f, "%mi setlinewidth\n",
+ gc->width + (gc->erase ? -2 : 2) * global.bloat);
+ global.linewidth = gc->width;
}
if (lastcap != gc->cap)
{
@@ -967,15 +960,15 @@ use_gc (hidGC gc)
c = 2;
break;
}
- fprintf (f, "%d setlinecap %d setlinejoin\n", c, c);
+ fprintf (global.f, "%d setlinecap %d setlinejoin\n", c, c);
lastcap = gc->cap;
}
#define CBLEND(gc) (((gc->r)<<24)|((gc->g)<<16)|((gc->b)<<8)|(gc->faded))
if (lastcolor != CBLEND (gc))
{
- if (is_drill || is_mask)
+ if (global.is_drill || global.is_mask)
{
- fprintf (f, "%d gray\n", gc->erase ? 0 : 1);
+ fprintf (global.f, "%d gray\n", gc->erase ? 0 : 1);
lastcolor = 0;
}
else
@@ -986,14 +979,14 @@ use_gc (hidGC gc)
b = gc->b;
if (gc->faded)
{
- r = antifade_ratio * 255 + fade_ratio * r;
- g = antifade_ratio * 255 + fade_ratio * g;
- b = antifade_ratio * 255 + fade_ratio * b;
+ r = (1 - global.fade_ratio) * 255 + global.fade_ratio * r;
+ g = (1 - global.fade_ratio) * 255 + global.fade_ratio * g;
+ b = (1 - global.fade_ratio) * 255 + global.fade_ratio * b;
}
if (gc->r == gc->g && gc->g == gc->b)
- fprintf (f, "%g gray\n", r / 255.0);
+ fprintf (global.f, "%g gray\n", r / 255.0);
else
- fprintf (f, "%g %g %g rgb\n", r / 255.0, g / 255.0, b / 255.0);
+ fprintf (global.f, "%g %g %g rgb\n", r / 255.0, g / 255.0, b / 255.0);
lastcolor = CBLEND (gc);
}
}
@@ -1003,7 +996,7 @@ static void
ps_draw_rect (hidGC gc, int x1, int y1, int x2, int y2)
{
use_gc (gc);
- fprintf (f, "%d %d %d %d dr\n", x1, y1, x2, y2);
+ pcb_fprintf (global.f, "%mi %mi %mi %mi dr\n", x1, y1, x2, y2);
}
static void ps_fill_rect (hidGC gc, int x1, int y1, int x2, int y2);
@@ -1039,7 +1032,7 @@ ps_draw_line (hidGC gc, int x1, int y1, int x2, int y2)
return;
}
use_gc (gc);
- fprintf (f, "%d %d %d %d t\n", x1, y1, x2, y2);
+ pcb_fprintf (global.f, "%mi %mi %mi %mi t\n", x1, y1, x2, y2);
}
static void
@@ -1062,21 +1055,22 @@ ps_draw_arc (hidGC gc, int cx, int cy, int width, int height,
cx, cy, width, height, start_angle, delta_angle, sa, ea);
#endif
use_gc (gc);
- fprintf (f, "%d %d %d %d %d %d %g a\n",
- sa, ea,
- -width, height, cx, cy, (double) (linewidth + 2 * bloat) / width);
+ pcb_fprintf (global.f, "%d %d %mi %mi %mi %mi %mi a\n",
+ sa, ea, -width, height, cx, cy,
+ (global.linewidth + 2 * global.bloat) / width);
}
static void
ps_fill_circle (hidGC gc, int cx, int cy, int radius)
{
use_gc (gc);
- if (!gc->erase || !is_copper || drillcopper)
+ if (!gc->erase || !global.is_copper || global.drillcopper)
{
- if (gc->erase && is_copper && drill_helper
- && radius >= PCB->minDrill/4)
- radius = PCB->minDrill/4;
- fprintf (f, "%d %d %d c\n", cx, cy, radius + (gc->erase ? -1 : 1) * bloat);
+ if (gc->erase && global.is_copper && global.drill_helper
+ && radius >= PCB->minDrill / 4)
+ radius = PCB->minDrill / 4;
+ pcb_fprintf (global.f, "%mi %mi %mi c\n",
+ cx, cy, radius + (gc->erase ? -1 : 1) * global.bloat);
}
}
@@ -1088,10 +1082,10 @@ ps_fill_polygon (hidGC gc, int n_coords, int *x, int *y)
use_gc (gc);
for (i = 0; i < n_coords; i++)
{
- fprintf (f, "%d %d %s\n", x[i], y[i], op);
+ pcb_fprintf (global.f, "%mi %mi %s\n", x[i], y[i], op);
op = "lineto";
}
- fprintf (f, "fill\n");
+ fprintf (global.f, "fill\n");
}
static void
@@ -1113,14 +1107,14 @@ ps_fill_pcb_polygon (hidGC gc, PolygonType * poly, const BoxType * clip_box)
op = "moveto";
do
{
- fprintf (f, "%d %d %s\n", v->point[0], v->point[1], op);
+ pcb_fprintf (global.f, "%mi %mi %s\n", v->point[0], v->point[1], op);
op = "lineto";
}
while ((v = v->next) != pl->head.next);
}
while ((pl = pl->next) != NULL);
- fprintf (f, "fill\n");
+ fprintf (global.f, "fill\n");
}
static void
@@ -1154,7 +1148,9 @@ ps_fill_rect (hidGC gc, int x1, int y1, int x2, int y2)
return;
}
#endif
- fprintf (f, "%d %d %d %d r\n", x1-bloat, y1-bloat, x2+bloat, y2+bloat);
+ pcb_fprintf (global.f, "%mi %mi %mi %mi r\n",
+ x1 - global.bloat, y1 - global.bloat,
+ x2 + global.bloat, y2 + global.bloat);
}
HID_Attribute ps_calib_attribute_list[] = {
@@ -1259,24 +1255,24 @@ ps_calibrate_1 (double xval, double yval, int use_command)
if (xval > 0 && yval > 0)
{
- if (guess (xval, 4, &calibration_x))
- if (guess (xval, 15, &calibration_x))
- if (guess (xval, 7.5, &calibration_x))
+ if (guess (xval, 4, &global.calibration_x))
+ if (guess (xval, 15, &global.calibration_x))
+ if (guess (xval, 7.5, &global.calibration_x))
{
if (xval < 2)
ps_attribute_list[HA_xcalib].default_val.real_value =
- calibration_x = xval;
+ global.calibration_x = xval;
else
Message("X value of %g is too far off.\n"
"Expecting it near: 1.0, 4.0, 15.0, 7.5\n", xval);
}
- if (guess (yval, 4, &calibration_y))
- if (guess (yval, 20, &calibration_y))
- if (guess (yval, 10, &calibration_y))
+ if (guess (yval, 4, &global.calibration_y))
+ if (guess (yval, 20, &global.calibration_y))
+ if (guess (yval, 10, &global.calibration_y))
{
if (yval < 2)
ps_attribute_list[HA_ycalib].default_val.real_value =
- calibration_y = yval;
+ global.calibration_y = yval;
else
Message("Y value of %g is too far off.\n"
"Expecting it near: 1.0, 4.0, 20.0, 10.0\n", yval);
commit eedb86fc2369b7b54a765bab3b4d8a1dabeeba5e
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Make pcb_fprintf ignore NULL file handle
There is a lot of code in the HID's that looks like
if (f != NULL)
fprintf (f, "...");
I have moved the NULL check inside pcb-printf to remove
this repetition/potential mistake.
diff --git a/src/pcb-printf.c b/src/pcb-printf.c
index d2b31b7..2c1f912 100644
--- a/src/pcb-printf.c
+++ b/src/pcb-printf.c
@@ -402,9 +402,14 @@ int pcb_fprintf(FILE *fh, const char *fmt, ...)
va_list args;
va_start(args, fmt);
- tmp = pcb_vprintf (fmt, args);
- rv = fprintf (fh, "%s", tmp);
- g_free (tmp);
+ if (fh == NULL)
+ rv = -1;
+ else
+ {
+ tmp = pcb_vprintf (fmt, args);
+ rv = fprintf (fh, "%s", tmp);
+ g_free (tmp);
+ }
va_end(args);
return rv;
commit 21b7bc38226c5a3408681c9c6e1d101c1f9f7489
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Make sure scale/direction are not output as measures in file.c
diff --git a/src/file.c b/src/file.c
index f4fb12e..c325c30 100644
--- a/src/file.c
+++ b/src/file.c
@@ -572,7 +572,7 @@ WritePCBDataHeader (FILE * FP)
PrintQuotedString (FP, (char *)EMPTY (PCB->Name));
pcb_fprintf (FP, " %mc %mc]\n\n", PCB->MaxWidth, PCB->MaxHeight);
pcb_fprintf (FP, "Grid[%s %mc %mc %d]\n",
- c_dtostr (PCB->Grid), PCB->GridOffsetX,
+ c_dtostr (COORD_TO_MIL(PCB->Grid) * 100), PCB->GridOffsetX,
PCB->GridOffsetY, Settings.DrawGrid);
pcb_fprintf (FP, "Cursor[%mc %mc %s]\n",
Crosshair.X, Crosshair.Y, c_dtostr (PCB->Zoom));
@@ -717,7 +717,7 @@ WriteElementData (FILE * FP, DataTypePtr Data)
PrintQuotedString (FP, (char *)EMPTY (NAMEONPCB_NAME (element)));
fputc (' ', FP);
PrintQuotedString (FP, (char *)EMPTY (VALUE_NAME (element)));
- pcb_fprintf (FP, " %mc %mc %mc %mc %mc %mc %s]\n(\n",
+ pcb_fprintf (FP, " %mc %mc %mc %mc %d %d %s]\n(\n",
element->MarkX, element->MarkY,
DESCRIPTION_TEXT (element).X - element->MarkX,
DESCRIPTION_TEXT (element).Y - element->MarkY,
@@ -765,7 +765,7 @@ WriteElementData (FILE * FP, DataTypePtr Data)
for (p = element->Arc; p != NULL; p = g_list_next (p))
{
ArcType *arc = p->data;
- pcb_fprintf (FP, "\tElementArc [%mc %mc %mc %mc %mc %mc %mc]\n",
+ pcb_fprintf (FP, "\tElementArc [%mc %mc %mc %mc %d %d %mc]\n",
arc->X - element->MarkX,
arc->Y - element->MarkY,
arc->Width, arc->Height,
@@ -804,7 +804,7 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
for (n = layer->Arc; n != NULL; n = g_list_next (n))
{
ArcType *arc = n->data;
- pcb_fprintf (FP, "\tArc[%mc %mc %mc %mc %mc %mc %mc %mc %s]\n",
+ pcb_fprintf (FP, "\tArc[%mc %mc %mc %mc %mc %mc %d %d %s]\n",
arc->X, arc->Y, arc->Width,
arc->Height, arc->Thickness,
arc->Clearance, arc->StartAngle,
@@ -813,7 +813,7 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
for (n = layer->Text; n != NULL; n = g_list_next (n))
{
TextType *text = n->data;
- pcb_fprintf (FP, "\tText[%mc %mc %mc %mc ",
+ pcb_fprintf (FP, "\tText[%mc %mc %d %d ",
text->X, text->Y,
text->Direction, text->Scale);
PrintQuotedString (FP, (char *)EMPTY (text->TextString));
|
|
From: <gi...@gp...> - 2011-06-25 21:37:22
|
The branch, master has been updated
via 9713a872e7e4068a3512ab080644f71e7e4dee87 (commit)
from 82721122dae63a96c89d273bba7abd8b3e6e8337 (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 9713a872e7e4068a3512ab080644f71e7e4dee87
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Fix typo in unplated hole output in report.c
:100644 100644 afd63ac... 53b8b41... M src/report.c
=========
Changes
=========
commit 9713a872e7e4068a3512ab080644f71e7e4dee87
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Fix typo in unplated hole output in report.c
diff --git a/src/report.c b/src/report.c
index afd63ac..53b8b41 100644
--- a/src/report.c
+++ b/src/report.c
@@ -145,7 +145,7 @@ ReportDialog (int argc, char **argv, int x, int y)
via = (PinTypePtr) ptr2;
if (TEST_FLAG (HOLEFLAG, via))
pcb_sprintf (&report[0], "%m+VIA ID# %ld; Flags:%s\n"
- "(X,Y) = %$mD %s.\n"
+ "(X,Y) = %$mD.\n"
"It is a pure hole of diameter %$mS.\n"
"Name = \"%s\"."
"%s", USER_UNITMASK, via->ID, flags_to_string (via->Flags, VIA_TYPE),
|
|
From: <gi...@gp...> - 2011-06-22 17:59:18
|
The branch, master has been updated
via 82721122dae63a96c89d273bba7abd8b3e6e8337 (commit)
via 571d8795faffc9894ba4ca4dc26b548e38301ec4 (commit)
via c317b9d7a59d806d99ce56836bd3e1462226a0aa (commit)
via 90ca501f3356f116461e945f8e51a70d34af351d (commit)
via b58ba40105160ac0d464aeacd9faef97d678e1e8 (commit)
via d5bdffc18f35fa3538a7911a39939ec75504a33b (commit)
via be8c3bee18c38ff5c634af5f3632446885c0ac80 (commit)
via da86b04ab351c441c88d04eb9221badbe95d9e5a (commit)
via 0586f240cd08ea3f2f9b84cb6536aee6caa37285 (commit)
via de55cc43ba47942b67b7463a62841096182d64f6 (commit)
from 2daa8bb0ab325e4e8667ad3090a75210acd42f9e (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 | 10 ++--
src/autoroute.c | 11 ++--
src/djopt.c | 116 +++++++++++++++++--------------------
src/file.c | 173 +++++++++++++++++++++++------------------------------
src/pcb-printf.c | 21 +++++++
src/pcb-printf.h | 9 ++-
src/polygon.c | 7 +-
src/polygon1.c | 25 ++++----
src/puller.c | 116 +++++++++++++++++-------------------
src/toporouter.c | 13 ++--
10 files changed, 243 insertions(+), 258 deletions(-)
=================
Commit Messages
=================
commit 82721122dae63a96c89d273bba7abd8b3e6e8337
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert toporouter trace code to use pcb-printf
There is still a fair amount of trace code outputting
measurements that are floating-point values. I left
these alone since they will work independently of the
actual type of BDimension.
Everything should still be output in base units.
:100644 100644 402de74... 5a82b14... M src/toporouter.c
commit 571d8795faffc9894ba4ca4dc26b548e38301ec4
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert polygon and polygon1.c debug code to use pcb-printf
:100644 100644 2ff3433... 0b5b2d0... M src/polygon.c
:100644 100644 1dba74c... 70d553f... M src/polygon1.c
commit c317b9d7a59d806d99ce56836bd3e1462226a0aa
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert puller.c trace code to use pcb-printf
Minor changes to trace output (addition of parens,
mainly). Should be no user-visible output. No longer
assumes BDimension == int.
:100644 100644 bcf8fae... 8550872... M src/puller.c
commit 90ca501f3356f116461e945f8e51a70d34af351d
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert djopt.c to use pcb-printf
No change in user-visible output.
Debug output is slightly changed since pcb-printf likes
to put parens around tuples, so "%d,%d" is now effectively
"(%d, %d)". Debug output is all base units, so the numbers
will not change until the base unit size is changed.
:100644 100644 f313127... 0b00d8e... M src/djopt.c
commit b58ba40105160ac0d464aeacd9faef97d678e1e8
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert autoroute.c debug code to use pcb-printf
Should be no change in output. Only change is that
we no longer assume BDimension == int.
:100644 100644 9005259... c799e93... M src/autoroute.c
commit d5bdffc18f35fa3538a7911a39939ec75504a33b
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Change action.c *WARN* lines to use pcb-printf
Now instead of outputting unsuffixed cmils, warnings
about locked/unnamed elements will refer to the part's
position in either mm or mil, with an appropriate suffix.
Non-warning-related output is unchanged.
:100644 100644 4f2e401... 8b7e6d5... M src/action.c
commit be8c3bee18c38ff5c634af5f3632446885c0ac80
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert file.c to use pcb-printf for cmil output
file.c now uses pcb-printf, though in a limited way:
everything is still output in unsuffixed cmils, though
this is now independent of pcb's internal unit size.
I have also removed the old-style output for symbols.
Aside from that, everything should be the same. Any
other change in output, or file format incompatibility
of any kind, is a bug.
:100644 100644 682aa02... f4fb12e... M src/file.c
commit da86b04ab351c441c88d04eb9221badbe95d9e5a
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add # subspecifier to pcb-printf to prevent scaling for debug output
:100644 100644 e0fe9d1... d2b31b7... M src/pcb-printf.c
:100644 100644 6b87a85... bcf319e... M src/pcb-printf.h
commit 0586f240cd08ea3f2f9b84cb6536aee6caa37285
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert puller.c to use Distance() intead of its own function
:100644 100644 3cd2500... bcf8fae... M src/puller.c
commit de55cc43ba47942b67b7463a62841096182d64f6
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add pcb_printf to pcb_*printf family of functions
:100644 100644 2ede73c... e0fe9d1... M src/pcb-printf.c
:100644 100644 2992d1b... 6b87a85... M src/pcb-printf.h
=========
Changes
=========
commit 82721122dae63a96c89d273bba7abd8b3e6e8337
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert toporouter trace code to use pcb-printf
There is still a fair amount of trace code outputting
measurements that are floating-point values. I left
these alone since they will work independently of the
actual type of BDimension.
Everything should still be output in base units.
diff --git a/src/toporouter.c b/src/toporouter.c
index 402de74..5a82b14 100644
--- a/src/toporouter.c
+++ b/src/toporouter.c
@@ -55,6 +55,7 @@
#include "toporouter.h"
+#include "pcb-printf.h"
static void
toporouter_edge_init (toporouter_edge_t *edge)
@@ -2822,7 +2823,7 @@ import_clusters(toporouter_t *r)
cluster_join_bbox(cluster, box);
#ifdef DEBUG_MERGING
- printf("\tLINE %d,%d\n", connection->X, connection->Y);
+ pcb_printf("\tLINE %#mD\n", connection->X, connection->Y);
#endif
}else if(connection->type == PAD_TYPE) {
PadType *pad = (PadType *) connection->ptr2;
@@ -2830,7 +2831,7 @@ import_clusters(toporouter_t *r)
cluster_join_bbox(cluster, box);
#ifdef DEBUG_MERGING
- printf("\tPAD %d,%d\n", connection->X, connection->Y);
+ pcb_printf("\tPAD %#mD\n", connection->X, connection->Y);
#endif
}else if(connection->type == PIN_TYPE) {
@@ -2841,7 +2842,7 @@ import_clusters(toporouter_t *r)
}
#ifdef DEBUG_MERGING
- printf("\tPIN %d,%d\n", connection->X, connection->Y);
+ pcb_printf("\tPIN %#mD\n", connection->X, connection->Y);
#endif
}else if(connection->type == VIA_TYPE) {
@@ -2852,7 +2853,7 @@ import_clusters(toporouter_t *r)
}
#ifdef DEBUG_MERGING
- printf("\tVIA %d,%d\n", connection->X, connection->Y);
+ pcb_printf("\tVIA %#mD\n", connection->X, connection->Y);
#endif
}else if(connection->type == POLYGON_TYPE) {
PolygonType *polygon = (PolygonType *) connection->ptr2;
@@ -2860,7 +2861,7 @@ import_clusters(toporouter_t *r)
cluster_join_bbox(cluster, box);
#ifdef DEBUG_MERGING
- printf("\tPOLYGON %d,%d\n", connection->X, connection->Y);
+ pcb_printf("\tPOLYGON %#mD\n", connection->X, connection->Y);
#endif
}
@@ -6877,7 +6878,7 @@ import_route(toporouter_t *r, RatType *line)
if(!routedata->dest) printf("couldn't locate dest\n");
if(!routedata->src || !routedata->dest) {
- printf("PROBLEM: couldn't locate rat src or dest for rat %d,%d,%d -> %d,%d,%d\n",
+ pcb_printf("PROBLEM: couldn't locate rat src or dest for rat %#mD, %d -> %#mD, %d\n",
line->Point1.X, line->Point1.Y, line->group1, line->Point2.X, line->Point2.Y, line->group2);
free(routedata);
return NULL;
commit 571d8795faffc9894ba4ca4dc26b548e38301ec4
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert polygon and polygon1.c debug code to use pcb-printf
diff --git a/src/polygon.c b/src/polygon.c
index 2ff3433..0b5b2d0 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -90,6 +90,7 @@ dicer output is used for HIDs which cannot render things with holes
#include "find.h"
#include "misc.h"
#include "move.h"
+#include "pcb-printf.h"
#include "polygon.h"
#include "remove.h"
#include "rtree.h"
@@ -1856,12 +1857,12 @@ MorphPolygon (LayerTypePtr layer, PolygonTypePtr poly)
void debug_pline (PLINE *pl)
{
VNODE *v;
- fprintf (stderr, "\txmin %d xmax %d ymin %d ymax %d\n",
+ pcb_fprintf (stderr, "\txmin %#mS xmax %#mS ymin %#mS ymax %#mS\n",
pl->xmin, pl->xmax, pl->ymin, pl->ymax);
v = &pl->head;
while (v)
{
- fprintf(stderr, "\t\tvnode: %d,%d\n", v->point[0], v->point[1]);
+ pcb_fprintf(stderr, "\t\tvnode: %#mD\n", v->point[0], v->point[1]);
v = v->next;
if (v == &pl->head)
break;
@@ -1885,7 +1886,7 @@ debug_polygon (PolygonType *p)
POLYAREA *pa;
fprintf (stderr, "POLYGON %p %d pts\n", p, p->PointN);
for (i=0; i<p->PointN; i++)
- fprintf(stderr, "\t%d: %d, %d\n", i, p->Points[i].X, p->Points[i].Y);
+ pcb_fprintf(stderr, "\t%d: %#mD\n", i, p->Points[i].X, p->Points[i].Y);
if (p->HoleIndexN)
{
fprintf (stderr, "%d holes, starting at indices\n", p->HoleIndexN);
diff --git a/src/polygon1.c b/src/polygon1.c
index 1dba74c..70d553f 100644
--- a/src/polygon1.c
+++ b/src/polygon1.c
@@ -102,7 +102,7 @@ int vect_inters2 (Vector A, Vector B, Vector C, Vector D, Vector S1,
#undef DEBUG_ANGLE
#undef DEBUG
#ifdef DEBUG
-#define DEBUGP(...) fprintf(stderr, ## __VA_ARGS__)
+#define DEBUGP(...) pcb_fprintf(stderr, ## __VA_ARGS__)
#else
#define DEBUGP(...)
#endif
@@ -134,7 +134,7 @@ pline_dump (VNODE * v)
do
{
n = v->next;
- fprintf (stderr, "Line [%d %d %d %d 10 10 \"%s\"]\n",
+ pcb_fprintf (stderr, "Line [%#mS %#mS %#mS %#mS 10 10 \"%s\"]\n",
v->point[0], v->point[1],
n->point[0], n->point[1], theState (v));
}
@@ -254,7 +254,7 @@ new_descriptor (VNODE * a, char poly, char side)
l->angle = ang;
assert (ang >= 0.0 && ang <= 4.0);
#ifdef DEBUG_ANGLE
- DEBUGP ("node on %c at (%d,%d) assigned angle %g on side %c\n", poly,
+ DEBUGP ("node on %c at %#mD assigned angle %g on side %c\n", poly,
a->point[0], a->point[1], ang, side);
#endif
return l;
@@ -637,7 +637,7 @@ seg_in_seg (const BoxType * b, void *cl)
if (new_node != NULL)
{
#ifdef DEBUG_INTERSECT
- DEBUGP ("new intersection on segment \"i\" at (%d, %d)\n",
+ DEBUGP ("new intersection on segment \"i\" at %#mD\n",
cnt > 1 ? s2[0] : s1[0], cnt > 1 ? s2[1] : s1[1]);
#endif
i->node_insert_list =
@@ -649,7 +649,7 @@ seg_in_seg (const BoxType * b, void *cl)
if (new_node != NULL)
{
#ifdef DEBUG_INTERSECT
- DEBUGP ("new intersection on segment \"s\" at (%d, %d)\n",
+ DEBUGP ("new intersection on segment \"s\" at %#mD\n",
cnt > 1 ? s2[0] : s1[0], cnt > 1 ? s2[1] : s1[1]);
#endif
i->node_insert_list =
@@ -1056,7 +1056,7 @@ print_labels (PLINE * a)
do
{
- DEBUGP ("(%d,%d)->(%d,%d) labeled %s\n", c->point[0], c->point[1],
+ DEBUGP ("%#mD->%#mD labeled %s\n", c->point[0], c->point[1],
c->next->point[0], c->next->point[1], theState (c));
}
while ((c = c->next) != &a->head);
@@ -1568,8 +1568,7 @@ jump (VNODE ** cur, DIRECTION * cdir, J_Rule rule)
return TRUE;
}
#ifdef DEBUG_JUMP
- DEBUGP ("jump entering node at (%d, %d)\n", (*cur)->point[0],
- (*cur)->point[1]);
+ DEBUGP ("jump entering node at %$mD\n", (*cur)->point[0], (*cur)->point[1]);
#endif
if (*cdir == FORW)
d = (*cur)->cvc_prev->prev;
@@ -1589,10 +1588,10 @@ jump (VNODE ** cur, DIRECTION * cdir, J_Rule rule)
{
#ifdef DEBUG_JUMP
if (newone == FORW)
- DEBUGP ("jump leaving node at (%d, %d)\n",
+ DEBUGP ("jump leaving node at %#mD\n",
e->next->point[0], e->next->point[1]);
else
- DEBUGP ("jump leaving node at (%d, %d)\n",
+ DEBUGP ("jump leaving node at %#mD\n",
e->point[0], e->point[1]);
#endif
*cur = d->parent;
@@ -1633,7 +1632,7 @@ Gather (VNODE * start, PLINE ** result, J_Rule v_rule, DIRECTION initdir)
poly_InclVertex ((*result)->head.prev, newn);
}
#ifdef DEBUG_GATHER
- DEBUGP ("gather vertex at (%d, %d)\n", cur->point[0], cur->point[1]);
+ DEBUGP ("gather vertex at %#mD\n", cur->point[0], cur->point[1]);
#endif
/* Now mark the edge as included. */
newn = (dir == FORW ? cur : cur->prev);
@@ -3257,7 +3256,7 @@ poly_Valid (POLYAREA * p)
do
{
n = v->next;
- fprintf (stderr, "Line [%d %d %d %d 100 100 \"\"]\n",
+ pcb_fprintf (stderr, "Line [%#mS %#mS %#mS %#mS 100 100 \"\"]\n",
v->point[0], v->point[1], n->point[0], n->point[1]);
}
while ((v = v->next) != &p->contours->head);
@@ -3282,7 +3281,7 @@ poly_Valid (POLYAREA * p)
do
{
n = v->next;
- fprintf (stderr, "Line [%d %d %d %d 100 100 \"\"]\n",
+ pcb_fprintf (stderr, "Line [%#mS %#mS %#mS %#mS 100 100 \"\"]\n",
v->point[0], v->point[1], n->point[0], n->point[1]);
}
while ((v = v->next) != &c->head);
commit c317b9d7a59d806d99ce56836bd3e1462226a0aa
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert puller.c trace code to use pcb-printf
Minor changes to trace output (addition of parens,
mainly). Should be no user-visible output. No longer
assumes BDimension == int.
diff --git a/src/puller.c b/src/puller.c
index bcf8fae..8550872 100644
--- a/src/puller.c
+++ b/src/puller.c
@@ -63,6 +63,7 @@
#include "draw.h"
#include "misc.h"
#include "move.h"
+#include "pcb-printf.h"
#include "remove.h"
#include "rtree.h"
#include "strflags.h"
@@ -137,7 +138,7 @@ arc_endpoint_is (ArcTypePtr a, int angle, int x, int y)
ay += a->Width * sin (rad);
}
#if TRACE1
- printf (" - arc endpoint %d,%d\n", ax, ay);
+ pcb_printf (" - arc endpoint %#mD\n", ax, ay);
#endif
arc_dist = Distance (ax, ay, x, y);
if (arc_exact)
@@ -278,7 +279,7 @@ dist_lp (int x1, int y1, int x2, int y2, int px, int py)
- ((double)x1 - px) * ((double)y2 - y1))
/ den);
#if TRACE1
- printf("dist (%d,%d-%d,%d) to %d,%d is %f\n",
+ pcb_printf("dist %#mD-%#mD to %#mD is %f\n",
x1, y1, x2, y2, px, py, rv);
#endif
return rv;
@@ -312,7 +313,7 @@ line_callback (const BoxType * b, void *cl)
LineTypePtr l = (LineTypePtr) b;
double d1, d2, t;
#if TRACE1
- printf ("line %d,%d .. %d,%d\n",
+ pcb_printf ("line %#mD .. %#mD\n",
l->Point1.X, l->Point1.Y, l->Point2.X, l->Point2.Y);
#endif
d1 = Distance (l->Point1.X, l->Point1.Y, x, y);
@@ -342,7 +343,7 @@ arc_callback (const BoxType * b, void *cl)
ArcTypePtr a = (ArcTypePtr) b;
#if TRACE1
- printf ("arc a %d,%d r %d sa %ld d %ld\n", a->X, a->Y, a->Width,
+ pcb_printf ("arc a %#mD r %#mS sa %ld d %ld\n", a->X, a->Y, a->Width,
a->StartAngle, a->Delta);
#endif
if (!arc_endpoint_is (a, a->StartAngle, x, y)
@@ -380,7 +381,7 @@ find_pair (int Px, int Py)
BoxType spot;
#if TRACE1
- printf ("\nPuller find_pair at %d,%d\n", Crosshair.X, Crosshair.Y);
+ pcb_printf ("\nPuller find_pair at %#mD\n", Crosshair.X, Crosshair.Y);
#endif
x = Px;
@@ -696,7 +697,7 @@ fix_arc_extra (ArcTypePtr a, Extra *e)
e->end.x = a->X - (a->Width * cos (d2r (a->StartAngle+a->Delta)) + 0.5);
e->end.y = a->Y + (a->Height * sin (d2r (a->StartAngle+a->Delta)) + 0.5);
#if TRACE1
- printf("new X,Y is %d,%d to %d,%d\n", e->start.x, e->start.y, e->end.x, e->end.y);
+ pcb_printf("new X,Y is %#mD to %#mD\n", e->start.x, e->start.y, e->end.x, e->end.y);
#endif
}
@@ -725,7 +726,7 @@ find_pair_line_callback (const BoxType * b, void *cl)
abort1();
#endif
#if TRACE1
- printf(" - %p line %d,%d or %d,%d\n", e, line->Point1.X, line->Point1.Y,
+ pcb_printf(" - %p line %#mD or %#mD\n", e, line->Point1.X, line->Point1.Y,
line->Point2.X, line->Point2.Y);
#endif
if ((NEAR (line->Point1.X, fpcs->x) && NEAR (line->Point1.Y, fpcs->y))
@@ -759,7 +760,7 @@ find_pair_arc_callback (const BoxType * b, void *cl)
if (arc == fpcs->me)
return 0;
#if TRACE1
- printf(" - %p arc %d,%d or %d,%d\n", e, e->start.x, e->start.y, e->end.x, e->end.y);
+ pcb_printf(" - %p arc %#mD or %#mD\n", e, e->start.x, e->start.y, e->end.x, e->end.y);
#endif
if ((NEAR (e->start.x, fpcs->x) && NEAR (e->start.y, fpcs->y))
|| (NEAR (e->end.x, fpcs->x) && NEAR (e->end.y, fpcs->y)))
@@ -791,7 +792,7 @@ find_pairs_1 (void *me, Extra **e, int x, int y)
fpcs.x = x;
fpcs.y = y;
#if TRACE1
- printf("looking for %d,%d\n", x, y);
+ pcb_printf("looking for %#mD\n", x, y);
#endif
b.X1 = x - 10;
b.X2 = x + 10;
@@ -850,7 +851,7 @@ find_pair_pinline_callback (const BoxType * b, void *cl)
pin->X, pin->Y) <= pin->Thickness/2)
{
#if TRACE1
- printf("splitting line %d,%d-%d,%d because it passes through pin %d,%d r%d\n",
+ pcb_printf("splitting line %#mD-%#mD because it passes through pin %#mD r%d\n",
line->Point1.X, line->Point1.Y,
line->Point2.X, line->Point2.Y,
pin->X, pin->Y, pin->Thickness/2);
@@ -880,7 +881,7 @@ check_point_in_pad (PadTypePtr pad, int x, int y, End *e)
int inside_p;
int t;
- printf("pad %d,%d - %d,%d t %d vs %d,%d\n", pad->Point1.X, pad->Point1.Y,
+ pcb_printf("pad %#mD - %#mD t %#mS vs %#mD\n", pad->Point1.X, pad->Point1.Y,
pad->Point2.X, pad->Point2.Y, pad->Thickness, x, y);
t = (pad->Thickness+1)/2;
if (TEST_FLAG (SQUAREFLAG, pad))
@@ -986,7 +987,7 @@ find_pair_padline_callback (const BoxType * b, void *cl)
/* It does. */
/* FIXME: we should split the line. */
#if TRACE1
- printf("splitting line %d,%d-%d,%d because it passes through pad %d,%d-%d,%d r%d\n",
+ pcb_printf("splitting line %#mD-%#mD because it passes through pad %#mD-%#mD r %#mS\n",
line->Point1.X, line->Point1.Y,
line->Point2.X, line->Point2.Y,
pad->Point1.X, pad->Point1.Y,
@@ -1255,7 +1256,7 @@ print_extra (Extra *e, Extra *prev)
if (EXTRA_IS_LINE (e))
{
LineTypePtr line = EXTRA2LINE (e);
- printf(" %p L %d,%d-%d,%d", line, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y);
+ pcb_printf(" %p L %#mD-%#mD", line, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y);
printf(" %s %p %s %p\n",
e->start.is_pad ? "pad" : "pin", e->start.pin,
e->end.is_pad ? "pad" : "pin", e->end.pin);
@@ -1263,8 +1264,8 @@ print_extra (Extra *e, Extra *prev)
else if (EXTRA_IS_ARC (e))
{
ArcTypePtr arc = EXTRA2ARC (e);
- printf(" %p A %d,%d-%d,%d", arc, e->start.x, e->start.y, e->end.x, e->end.y);
- printf(" at %d,%d ang %ld,%ld\n", arc->X, arc->Y, arc->StartAngle, arc->Delta);
+ pcb_printf(" %p A %#mD-%#mD", arc, e->start.x, e->start.y, e->end.x, e->end.y);
+ pcb_printf(" at %#mD ang %ld,%ld\n", arc->X, arc->Y, arc->StartAngle, arc->Delta);
}
else if (e == &multi_next)
{
@@ -1423,7 +1424,7 @@ gp_point_force (int x, int y, int t, End *e, int esa, int eda, int force, const
double base_angle, rel_angle, point_angle;
#if TRACE1
- printf("\033[34mgp_point_force %d,%d %d via %s\033[0m\n", x, y, t, name);
+ pcb_printf("\033[34mgp_point_force %#mD %#mS via %s\033[0m\n", x, y, t, name);
#endif
if (start_arc)
@@ -1444,8 +1445,8 @@ gp_point_force (int x, int y, int t, End *e, int esa, int eda, int force, const
/* See if the point is inside our start arc. */
d = Distance (scx, scy, x, y);
#if TRACE1
- printf("%f = dist (%d,%d to %d,%d)\n", d, scx, scy, x, y);
- printf("sr %d r %f d %f\n", sr, r, d);
+ pcb_printf("%f = dist #mD to %#mD\n", d, scx, scy, x, y);
+ pcb_printf("sr %#mS r %f d %f\n", sr, r, d);
#endif
if (d < sr - r)
{
@@ -1468,8 +1469,8 @@ gp_point_force (int x, int y, int t, End *e, int esa, int eda, int force, const
/* angle between points (NOT pcb arc angles) */
base_angle = atan2 (y - scy, x - scx);
#if TRACE1
- printf("%.1f = atan2 (%d-%d = %d, %d-%d = %d)\n",
- r2d(base_angle), y, scy, y-scy, x, scx, x-scx);
+ pcb_printf("%.1f = atan2 (%#mS-%#mS = %#mS, %#mS-%#mS = %#mS)\n",
+ r2d(base_angle), y, scy, y-scy, x, scx, x-scx);
#endif
if ((sa_sign * sr - r) / d > 1
@@ -1539,12 +1540,12 @@ gp_point_force (int x, int y, int t, End *e, int esa, int eda, int force, const
start_line->Point2.X, start_line->Point2.Y,
x, y);
#if TRACE1
- printf("point %d,%d dist %f vs thickness %d\n", x, y, new_r, thickness);
+ pcb_printf("point %#mD dist %#mS vs thickness %#mS\n", x, y, new_r, thickness);
#endif
new_r -= thickness;
new_r = (int)new_r - 1;
#if TRACE1
- printf(" - new thickness %f old %d\n", new_r, t);
+ pcb_printf(" - new thickness %f old %#mS\n", new_r, t);
#endif
if (new_r < t)
gp_point_force (x, y, new_r, e, esa, eda, 1, __FUNCTION__);
@@ -1594,7 +1595,7 @@ gp_point_2 (int x, int y, int t, End *e, int esa, int eda, const char *func)
return 0;
#if TRACE1
- printf("\033[34mgp_point %d,%d %d via %s\033[0m\n", x, y, t, func);
+ pcb_printf("\033[34mgp_point %#mD %#mS via %s\033[0m\n", x, y, t, func);
#endif
/* There are two regions we care about. For points inside our
@@ -1828,7 +1829,7 @@ create_line (LineTypePtr sample, int x1, int y1, int x2, int y2)
{
Extra *e;
#if TRACE1
- printf("create_line from %d,%d to %d,%d\n", x1, y1, x2, y2);
+ pcb_printf("create_line from %#mD to %#mD\n", x1, y1, x2, y2);
#endif
LineTypePtr line = CreateNewLineOnLayer (CURRENT, x1, y1, x2, y2,
sample->Thickness, sample->Clearance, sample->Flags);
@@ -1852,7 +1853,7 @@ create_arc (LineTypePtr sample, int x, int y, int r, int sa, int da)
if (r % 100 == 99)
r++;
#if TRACE1
- printf("create_arc at %d,%d r %d sa %d delta %d\n", x, y, r, sa, da);
+ pcb_printf("create_arc at %#mD r %#mS sa %d delta %d\n", x, y, r, sa, da);
#endif
arc = CreateNewArcOnLayer (CURRENT, x, y, r, r, sa, da,
sample->Thickness, sample->Clearance, sample->Flags);
@@ -1946,7 +1947,7 @@ mark_line_for_deletion (LineTypePtr l)
e->deleted = 1;
unlink_extras (e);
#if TRACE1
- printf("Marked line %p for deletion %d,%d to %d,%d\n",
+ pcb_printf("Marked line %p for deletion %#mD to %#mD\n",
e, l->Point1.X, l->Point1.Y, l->Point2.X, l->Point2.Y);
#endif
#if 0
@@ -2161,7 +2162,7 @@ maybe_pull_1 (LineTypePtr line)
fy = ey;
if (fx < 0)
{
- fprintf(stderr, "end line corrupt? f is %d,%d\n", fx, fy);
+ pcb_fprintf(stderr, "end line corrupt? f is %#mD\n", fx, fy);
print_extra (end_extra, 0);
if (earc_extra)
print_extra(earc_extra, 0);
@@ -2187,7 +2188,7 @@ maybe_pull_1 (LineTypePtr line)
abs_angle = fa + start_angle;
#if TRACE1
- printf("\033[43;30mBest: at %d,%d r %d, angle %.1f fp %d\033[0m\n", fx, fy, fr, r2d(fa), fp);
+ pcb_printf("\033[43;30mBest: at %#mD r %#mS, angle %.1f fp %d\033[0m\n", fx, fy, fr, r2d(fa), fp);
#endif
#if 0
@@ -2230,7 +2231,7 @@ maybe_pull_1 (LineTypePtr line)
new_delta -= 360;
}
#if TRACE1
- printf("merging arcs at %d,%d nd %d\n", start_arc->X, start_arc->Y, new_delta);
+ pcb_printf("merging arcs at %#mS nd %d\n", start_arc->X, start_arc->Y, new_delta);
print_extra(sarc_extra, 0);
print_extra(earc_extra, 0);
#endif
@@ -2255,7 +2256,7 @@ maybe_pull_1 (LineTypePtr line)
new_delta = 180 - r2d(abs_angle);
#if TRACE1
printf("new_delta starts at %d vs %d < %d\n",
- (int)new_delta, start_arc->StartAngle, start_arc->Delta);
+ (int)new_delta, (int)start_arc->StartAngle, (int)start_arc->Delta);
#endif
if (start_arc->Delta < 0)
new_delta = (int)(new_delta) + 90;
@@ -2269,7 +2270,7 @@ maybe_pull_1 (LineTypePtr line)
#if TRACE1
printf("new_delta adjusts to %d\n", (int)new_delta);
printf("fa = %f, new_delta ends at %.1f vs start %d\n",
- fa, new_delta, start_arc->StartAngle);
+ fa, new_delta, (int)start_arc->StartAngle);
#endif
if (new_delta * start_arc->Delta <= 0)
@@ -2297,7 +2298,7 @@ maybe_pull_1 (LineTypePtr line)
double ox = fx + fr * cos(oa);
double oy = fy + fr * sin(oa);
#if TRACE1
- printf("obstacle at %d,%d angle %d = arc starts at %d,%d\n",
+ pcb_printf("obstacle at %#mD angle %d = arc starts at %#mD\n",
fx, fy, (int)r2d(oa), (int)ox, (int)oy);
#endif
@@ -2313,7 +2314,7 @@ maybe_pull_1 (LineTypePtr line)
/* Step 2: If we have no obstacles, connect start and end. */
#if TRACE1
- printf("fx %d ex %d fy %d ey %d\n", fx, ex, fy, ey);
+ pcb_printf("fx %#mS ex %#mS fy %#mS ey %#mS\n", fx, ex, fy, ey);
#endif
if (fx == ex && fy == ey)
{
@@ -2385,8 +2386,8 @@ maybe_pull_1 (LineTypePtr line)
ex = start_line->Point1.X + cos(start_angle + fa) * 10000.0;
ey = start_line->Point1.Y + sin(start_angle + fa) * 10000.0;
#if TRACE1
- printf("temp point %d,%d\n", ex, ey);
- printf("intersect %d,%d-%d,%d with %d,%d-%d,%d\n",
+ pcb_printf("temp point %#mS\n", ex, ey);
+ pcb_printf("intersect %#mS-%#mS with %#mS-%#mS\n",
start_line->Point1.X, start_line->Point1.Y,
ex, ey,
end_line->Point1.X, end_line->Point1.Y,
@@ -2402,7 +2403,7 @@ maybe_pull_1 (LineTypePtr line)
ey = end_line->Point2.Y;
}
#if TRACE1
- printf("new point %d,%d\n", ex, ey);
+ pcb_printf("new point %#mS\n", ex, ey);
#endif
MoveObject (LINEPOINT_TYPE, CURRENT, end_line, &(end_line->Point1),
ex - end_line->Point1.X,
commit 90ca501f3356f116461e945f8e51a70d34af351d
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert djopt.c to use pcb-printf
No change in user-visible output.
Debug output is slightly changed since pcb-printf likes
to put parens around tuples, so "%d,%d" is now effectively
"(%d, %d)". Debug output is all base units, so the numbers
will not change until the base unit size is changed.
diff --git a/src/djopt.c b/src/djopt.c
index f313127..0b00d8e 100644
--- a/src/djopt.c
+++ b/src/djopt.c
@@ -44,6 +44,7 @@
#include "undo.h"
#include "strflags.h"
#include "find.h"
+#include "pcb-printf.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
@@ -55,7 +56,7 @@ RCSID ("$Id$");
#define rint(x) (ceil((x) - 0.5))
#endif
-#define dprintf if(0)printf
+#define dprintf if(0)pcb_printf
#define selected(x) TEST_FLAG (SELECTEDFLAG, (x))
#define autorouted(x) TEST_FLAG (AUTOFLAG, (x))
@@ -198,19 +199,18 @@ corner_name (corner_s * c)
bp = buf[bn] + strlen (buf[bn]);
if (c->pin)
- sprintf (bp, "pin %s:%s at %d,%d", element_name_for (c), c->pin->Number,
- c->x, c->y);
+ pcb_sprintf (bp, "pin %s:%s at %#mD", element_name_for (c), c->pin->Number, c->x, c->y);
else if (c->via)
- sprintf (bp, "via at %d,%d", c->x, c->y);
+ pcb_sprintf (bp, "via at %#mD", c->x, c->y);
else if (c->pad)
{
- sprintf (bp, "pad %s:%s at %d,%d (%d,%d-%d,%d)",
+ pcb_sprintf (bp, "pad %s:%s at %#mD %#mD-%#mD",
element_name_for (c), c->pad->Number, c->x, c->y,
c->pad->Point1.X, c->pad->Point1.Y,
c->pad->Point2.X, c->pad->Point2.Y);
}
else
- sprintf (bp, "at %d,%d", c->x, c->y);
+ pcb_sprintf (bp, "at %#mD", c->x, c->y);
sprintf (bp + strlen (bp), " n%d l%d]\033[0m", c->n_lines, c->layer);
return buf[bn];
}
@@ -278,7 +278,7 @@ check2 (int srcline, corner_s * c, line_s * l)
|| ll->e->x != ll->line->Point2.X
|| ll->e->y != ll->line->Point2.Y))
{
- printf ("line: %d,%d to %d,%d pcbline: %d,%d to %d,%d\n",
+ pcb_printf ("line: %#mD to %#mD pcbline: %#mD to %#mD\n",
ll->s->x, ll->s->y,
ll->e->x, ll->e->y,
ll->line->Point1.X,
@@ -523,7 +523,7 @@ add_line_to_corner (line_s * l, corner_s * c)
c->lines = (line_s **) realloc (c->lines, n * sizeof (line_s *));
c->lines[c->n_lines] = l;
c->n_lines++;
- dprintf ("add_line_to_corner %d %d\n", c->x, c->y);
+ dprintf ("add_line_to_corner %#mD\n", c->x, c->y);
}
static LineType *
@@ -589,7 +589,7 @@ new_line (corner_s * s, corner_s * e, int layer, LineType * example)
{
LineType *nl;
dprintf
- ("New line \033[35m%d,%d to %d,%d from l%d t%d c%d f%s\033[0m\n",
+ ("New line \033[35m%#mD to %#mD from l%d t%#mS c%#mS f%s\033[0m\n",
s->x, s->y, e->x, e->y, layer, example->Thickness,
example->Clearance, flags_to_string (example->Flags, LINE_TYPE));
nl =
@@ -692,7 +692,7 @@ line_in_rect (rect_s * r, line_s * l)
empty_rect (&lr);
add_point_to_rect (&lr, l->s->x, l->s->y, l->line->Thickness / 2);
add_point_to_rect (&lr, l->e->x, l->e->y, l->line->Thickness / 2);
- dprintf ("line_in_rect %d,%d-%d,%d vs %d,%d-%d,%d\n",
+ dprintf ("line_in_rect %#mD-%#mD vs %#mD-%#mD\n",
r->x1, r->y1, r->x2, r->y2, lr.x1, lr.y1, lr.x2, lr.y2);
/* simple intersection of rectangles */
if (lr.x1 < r->x1)
@@ -752,7 +752,7 @@ add_corner_to_rect_if (rect_s * rect, corner_s * c, rect_s * e)
if (c->x > e->x2 && c->y > e->y2 && dist (c->x, c->y, e->x2, e->y2) > diam)
return;
- /*printf("add point %d,%d diam %d\n", c->x, c->y, diam); */
+ /*pcb_printf("add point %#mD diam %#mS\n", c->x, c->y, diam); */
add_point_to_rect (rect, c->x, c->y, diam);
}
@@ -860,8 +860,7 @@ move_corner (corner_s * c, int x, int y)
check (c, 0);
if (c->pad || c->pin)
dj_abort ("move_corner: has pin or pad\n");
- dprintf ("move_corner %p from %d,%d to %d,%d\n", (void *) c, c->x, c->y, x,
- y);
+ dprintf ("move_corner %p from %#mD to %#mD\n", (void *) c, c->x, c->y, x, y);
pad = find_corner_if (x, y, c->layer);
c->x = x;
c->y = y;
@@ -869,7 +868,7 @@ move_corner (corner_s * c, int x, int y)
if (via)
{
MoveObject (VIA_TYPE, via, via, via, x - via->X, y - via->Y);
- dprintf ("via move %d,%d to %d,%d\n", via->X, via->Y, x, y);
+ dprintf ("via move %#mD to %#mD\n", via->X, via->Y, x, y);
}
for (i = 0; i < c->n_lines; i++)
{
@@ -888,7 +887,7 @@ move_corner (corner_s * c, int x, int y)
&tl->Point2, x - (tl->Point2.X),
y - (tl->Point2.Y));
}
- dprintf ("Line %p moved to %d,%d %d,%d\n", (void *) tl,
+ dprintf ("Line %p moved to %#mD %#mD\n", (void *) tl,
tl->Point1.X, tl->Point1.Y, tl->Point2.X, tl->Point2.Y);
}
}
@@ -901,7 +900,7 @@ move_corner (corner_s * c, int x, int y)
&& c->lines[i]->s->y == c->lines[i]->e->y)
{
corner_s *c2 = other_corner (c->lines[i], c);
- dprintf ("move_corner: removing line %d,%d %d,%d %p %p\n",
+ dprintf ("move_corner: removing line %#mD %#mD %p %p\n",
c->x, c->y, c2->x, c2->y, (void *) c, (void *) c2);
remove_line (c->lines[i]);
@@ -976,7 +975,7 @@ split_line (line_s * l, corner_s * c)
check (c, l);
- dprintf ("split line from %d,%d to %d,%d at %d,%d\n",
+ dprintf ("split line from %#mD to %#mD at %#mD\n",
l->s->x, l->s->y, l->e->x, l->e->y, c->x, c->y);
ls = (line_s *) malloc (sizeof (line_s));
@@ -1148,7 +1147,7 @@ simple_optimize_corner (corner_s * c)
{
/* see if no via is needed */
if (selected (c->via))
- dprintf ("via check: line[0] layer %d at %d,%d nl %d\n",
+ dprintf ("via check: line[0] layer %d at %#mD nl %d\n",
c->lines[0]->layer, c->x, c->y, c->n_lines);
/* We can't delete vias that connect to power planes, or vias
that aren't tented (assume they're test points). */
@@ -1158,7 +1157,7 @@ simple_optimize_corner (corner_s * c)
for (i = 1; i < c->n_lines; i++)
{
if (selected (c->via))
- dprintf (" line[%d] layer %d %d,%d to %d,%d\n",
+ dprintf (" line[%d] layer %d %#mD to %#mD\n",
i, c->lines[i]->layer,
c->lines[i]->s->x, c->lines[i]->s->y,
c->lines[i]->e->x, c->lines[i]->e->y);
@@ -1184,7 +1183,7 @@ simple_optimize_corner (corner_s * c)
corner_s *c0 = other_corner (c->lines[0], c);
if (o == line_orient (c->lines[1], c2) && o != DIAGONAL)
{
- dprintf ("straight %d,%d to %d,%d to %d,%d\n",
+ dprintf ("straight %#mD to %#mD to %#mD\n",
c0->x, c0->y, c->x, c->y, c2->x, c2->y);
if (selected (c->lines[0]->line))
SET_FLAG (SELECTEDFLAG, c->lines[1]->line);
@@ -1215,8 +1214,7 @@ simple_optimize_corner (corner_s * c)
* This code is probably worth keeping even when the autorouter bug is
* fixed, as "freckles" could conceivably arise in other ways.
*/
- dprintf ("freckle %d,%d to %d,%d\n",
- c->x, c->y, c0->x, c0->y);
+ dprintf ("freckle %#mD to %#mD\n", c->x, c->y, c0->x, c0->y);
move_corner (c, c0->x, c0->y);
}
}
@@ -1376,7 +1374,7 @@ orthopull_1 (corner_s * c, int fdir, int rdir, int any_sel)
if (max > len || max == -1)
max = len;
}
- dprintf ("c %s %4d %4d cn %d pull %3d max %4d\n",
+ dprintf ("c %s %4#mD cn %d pull %3d max %4#mS\n",
fdir == RIGHT ? "right" : "down ", c->x, c->y, cn, pull, max);
switch (edir)
@@ -1460,8 +1458,7 @@ orthopull_1 (corner_s * c, int fdir, int rdir, int any_sel)
int o, x1, x2, y1, y2;
if (DELETED (l))
continue;
- dprintf ("check line %d,%d to %d,%d\n", l->s->x, l->s->y, l->e->x,
- l->e->y);
+ dprintf ("check line %#mD to %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y);
if (l->s->net == c->net)
{
dprintf (" same net\n");
@@ -1559,8 +1556,7 @@ orthopull_1 (corner_s * c, int fdir, int rdir, int any_sel)
break;
}
len -= r;
- dprintf (" len is %d vs corner at %d,%d\n", len, cs[i]->x,
- cs[i]->y);
+ dprintf (" len is %#mS vs corner at %#mD\n", len, cs[i]->x, cs[i]->y);
if (len <= 0)
return 0;
if (max > len)
@@ -1676,7 +1672,7 @@ orthopull ()
c = c->next;
}
if (rv)
- printf ("orthopull: %f mils saved\n", COORD_TO_MIL(rv));
+ pcb_printf ("orthopull: %ml mils saved\n", rv);
return rv;
}
@@ -1716,8 +1712,7 @@ debumpify ()
if (ORIENT (o) == ORIENT (o1) || o1 != o2 || o1 == DIAGONAL)
continue;
- dprintf ("\nline: %d,%d to %d,%d\n", l->s->x, l->s->y, l->e->x,
- l->e->y);
+ dprintf ("\nline: %#mD to %#mD\n", l->s->x, l->s->y, l->e->x, l->e->y);
w = l->line->Thickness / 2 + SB + 1;
empty_rect (&rr);
add_line_to_rect (&rr, l1);
@@ -1730,7 +1725,7 @@ debumpify ()
rr.y1 -= w;
if (rr.y2 != l->s->y && rr.y2 != l->e->y)
rr.y2 += w;
- dprintf ("range: x %d..%d y %d..%d\n", rr.x1, rr.x2, rr.y1, rr.y2);
+ dprintf ("range: x %#mS..%#mS y %#mS..%#mS\n", rr.x1, rr.x2, rr.y1, rr.y2);
c1 = other_corner (l1, l->s);
c2 = other_corner (l2, l->e);
@@ -1751,7 +1746,7 @@ debumpify ()
rp.y1 = rr.y2;
rp.y2 = rr.y1;
}
- dprintf ("pin r: x %d..%d y %d..%d\n", rp.x1, rp.x2, rp.y1, rp.y2);
+ dprintf ("pin r: x %#mS..%#mS y %#mS..%#mS\n", rp.x1, rp.x2, rp.y1, rp.y2);
switch (o1)
{
@@ -1764,7 +1759,7 @@ debumpify ()
step = l->s->x - c2->x;
if (step > 0)
{
- dprintf ("left step %d at %d,%d\n", step, l->s->x, l->s->y);
+ dprintf ("left step %#mS at %#mD\n", step, l->s->x, l->s->y);
move_corner (l->s, l->s->x - step, l->s->y);
move_corner (l->e, l->e->x - step, l->e->y);
rv += step;
@@ -1779,7 +1774,7 @@ debumpify ()
step = c2->x - l->s->x;
if (step > 0)
{
- dprintf ("right step %d at %d,%d\n", step, l->s->x, l->s->y);
+ dprintf ("right step %#mS at %#mD\n", step, l->s->x, l->s->y);
move_corner (l->s, l->s->x + step, l->s->y);
move_corner (l->e, l->e->x + step, l->e->y);
rv += step;
@@ -1792,7 +1787,7 @@ debumpify ()
l->s->y - c1->y, l->s->y - c2->y);
if (step > 0)
{
- dprintf ("up step %d at %d,%d\n", step, l->s->x, l->s->y);
+ dprintf ("up step %#mS at %#mD\n", step, l->s->x, l->s->y);
move_corner (l->s, l->s->x, l->s->y - step);
move_corner (l->e, l->e->x, l->e->y - step);
rv += step;
@@ -1807,7 +1802,7 @@ debumpify ()
step = c2->y - l->s->y;
if (step > 0)
{
- dprintf ("down step %d at %d,%d\n", step, l->s->x, l->s->y);
+ dprintf ("down step %#mS at %#mD\n", step, l->s->x, l->s->y);
move_corner (l->s, l->s->x, l->s->y + step);
move_corner (l->e, l->e->x, l->e->y + step);
rv += step;
@@ -1819,7 +1814,7 @@ debumpify ()
rv += simple_optimizations ();
if (rv)
- printf ("debumpify: %d mils saved\n", rv / 50);
+ pcb_printf ("debumpify: %ml mils saved\n", rv / 50);
return rv;
}
@@ -1864,7 +1859,7 @@ unjaggy_once ()
&& !(autorouted (c->lines[0]->line)
|| autorouted (c->lines[1]->line)))
continue;
- dprintf ("simple at %d,%d\n", c->x, c->y);
+ dprintf ("simple at %#mD\n", c->x, c->y);
c0 = other_corner (c->lines[0], c);
o0 = line_orient (c->lines[0], c);
@@ -1876,7 +1871,7 @@ unjaggy_once ()
if (!s0 && !s1)
continue;
- dprintf ("simples at %d,%d\n", c->x, c->y);
+ dprintf ("simples at %#mD\n", c->x, c->y);
w = 1;
for (l = 0; l < c0->n_lines; l++)
@@ -1920,11 +1915,11 @@ unjaggy_once ()
if (cc->net != c->net && intersecting_layers (cc->layer, c->layer))
add_corner_to_rect_if (&rp, cc, &rr);
}
- dprintf ("rp x %d..%d y %d..%d\n", rp.x1, rp.x2, rp.y1, rp.y2);
+ dprintf ("rp x %#mS..%#mS y %#mS..%#mS\n", rp.x1, rp.x2, rp.y1, rp.y2);
if (rp.x1 <= rp.x2) /* something triggered */
continue;
- dprintf ("unjaggy at %d,%d layer %d\n", c->x, c->y, c->layer);
+ dprintf ("unjaggy at %#mD layer %d\n", c->x, c->y, c->layer);
if (c->x == c0->x)
move_corner (c, c1->x, c0->y);
else
@@ -2056,8 +2051,8 @@ vianudge ()
/* at this point, we know we can move it */
- dprintf ("vianudge: nudging via at %d,%d by %f mils saving %f\n",
- c->x, c->y, COORD_TO_MIL(len), COORD_TO_MIL(saved));
+ dprintf ("vianudge: nudging via at %#mD by %#mS saving %#mS\n",
+ c->x, c->y, len, saved);
rv += len * saved;
move_corner (c, c2->x, c2->y);
@@ -2068,7 +2063,7 @@ vianudge ()
}
if (rv)
- printf ("vianudge: %f mils saved\n", COORD_TO_MIL(rv));
+ pcb_printf ("vianudge: %ml mils saved\n", rv);
return rv;
}
@@ -2100,7 +2095,7 @@ viatrim ()
my_layer = l->layer;
other_layer = -1;
- dprintf ("line %p on layer %d from %d,%d to %d,%d\n", (void *) l,
+ dprintf ("line %p on layer %d from %#mD to %#mD\n", (void *) l,
l->layer, l->s->x, l->s->y, l->e->x, l->e->y);
for (i = 0; i < l->s->n_lines; i++)
if (l->s->lines[i] != l)
@@ -2152,11 +2147,11 @@ viatrim ()
continue;
if (l2->s->net != l->s->net && l2->layer == other_layer)
{
- dprintf ("checking other line %d,%d to %d,%d\n", l2->s->x,
+ dprintf ("checking other line %#mD to %#mD\n", l2->s->x,
l2->s->y, l2->e->x, l2->e->y);
if (line_in_rect (&r, l2))
{
- dprintf ("line from %d,%d to %d,%d in the way\n",
+ dprintf ("line from %#mD to %#mD in the way\n",
l2->s->x, l2->s->y, l2->e->x, l2->e->y);
goto viatrim_continue;
}
@@ -2482,7 +2477,7 @@ choose_example_line (corner_s * c1, corner_s * c2)
for (ci = 0; ci < 2; ci++)
for (li = 0; li < c[ci]->n_lines; li++)
{
- dprintf (" try[%d,%d] \033[36m<%d,%d-%d,%d t%d c%d f%s>\033[0m\n",
+ dprintf (" try[%d,%d] \033[36m<%#mD-%#mD t%#mS c%#mS f%s>\033[0m\n",
ci, li,
c[ci]->lines[li]->s->x, c[ci]->lines[li]->s->y,
c[ci]->lines[li]->e->x, c[ci]->lines[li]->e->y,
@@ -2516,7 +2511,7 @@ connect_corners (corner_s * c1, corner_s * c2)
LineType *example = ex->line;
dprintf
- ("connect_corners \033[32m%d,%d to %d,%d, example line %d,%d to %d,%d l%d\033[0m\n",
+ ("connect_corners \033[32m%#mD to %#mD, example line %#mD to %#mD l%d\033[0m\n",
c1->x, c1->y, c2->x, c2->y, ex->s->x, ex->s->y, ex->e->x, ex->e->y,
ex->layer);
@@ -2603,7 +2598,7 @@ pinsnap ()
if (c->pad->Point1.X == c->pad->Point2.X)
{
int hy = (c->pad->Point1.Y + c->pad->Point2.Y) / 2;
- dprintf ("pad y %d %d hy %d c %d\n", c->pad->Point1.Y,
+ dprintf ("pad y %#mS %#mS hy %#mS c %#mS\n", c->pad->Point1.Y,
c->pad->Point2.Y, hy, c->y);
if (c->y < hy)
top = hy;
@@ -2613,7 +2608,7 @@ pinsnap ()
else
{
int hx = (c->pad->Point1.X + c->pad->Point2.X) / 2;
- dprintf ("pad x %d %d hx %d c %d\n", c->pad->Point1.X,
+ dprintf ("pad x %#mS %#mS hx %#mS c %#mS\n", c->pad->Point1.X,
c->pad->Point2.X, hx, c->x);
if (c->x < hx)
right = hx;
@@ -2622,8 +2617,7 @@ pinsnap ()
}
}
- dprintf ("%s x %d-%d y %d-%d\n", corner_name (c), left, right,
- bottom, top);
+ dprintf ("%s x %#mS-%#mS y %#mS-%#mS\n", corner_name (c), left, right, bottom, top);
for (l = 0; l <= max_copper_layer; l++)
{
best_dist[l] = close * 2;
@@ -2703,7 +2697,7 @@ pinsnap ()
l = c->lines[0];
lo = line_orient (l, c);
- dprintf ("line end %d,%d orient %d\n", c->x, c->y, lo);
+ dprintf ("line end %#mD orient %d\n", c->x, c->y, lo);
for (t = lines; t; t = t->next)
{
@@ -2721,8 +2715,7 @@ pinsnap ()
&& ((t->s->y < c->y && c->y < t->e->y)
|| (t->e->y < c->y && c->y < t->s->y)))
{
- dprintf ("found %d,%d - %d,%d\n", t->s->x, t->s->y, t->e->x,
- t->e->y);
+ dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y);
move_corner (c, t->s->x, c->y);
}
break;
@@ -2734,8 +2727,7 @@ pinsnap ()
&& ((t->s->y < c->y && c->y < t->e->y)
|| (t->e->y < c->y && c->y < t->s->y)))
{
- dprintf ("found %d,%d - %d,%d\n", t->s->x, t->s->y, t->e->x,
- t->e->y);
+ dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y);
move_corner (c, t->s->x, c->y);
}
break;
@@ -2747,8 +2739,7 @@ pinsnap ()
&& ((t->s->x < c->x && c->x < t->e->x)
|| (t->e->x < c->x && c->x < t->s->x)))
{
- dprintf ("found %d,%d - %d,%d\n", t->s->x, t->s->y, t->e->x,
- t->e->y);
+ dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y);
move_corner (c, c->x, t->s->y);
}
break;
@@ -2760,8 +2751,7 @@ pinsnap ()
&& ((t->s->x < c->x && c->x < t->e->x)
|| (t->e->x < c->x && c->x < t->s->x)))
{
- dprintf ("found %d,%d - %d,%d\n", t->s->x, t->s->y, t->e->x,
- t->e->y);
+ dprintf ("found %#mD - %#mD\n", t->s->x, t->s->y, t->e->x, t->e->y);
move_corner (c, c->x, t->s->y);
}
break;
@@ -2821,7 +2811,7 @@ padcleaner ()
&& ORIENT (line_orient (l, 0)) == pad_orient (pad))
{
dprintf
- ("padcleaner %d,%d-%d,%d %d vs line %d,%d-%d,%d %d\n",
+ ("padcleaner %#mD-%#mD %#mS vs line %#mD-%#mD %#mS\n",
pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y,
pad->Thickness, l->s->x, l->s->y, l->e->x, l->e->y,
l->line->Thickness);
commit b58ba40105160ac0d464aeacd9faef97d678e1e8
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert autoroute.c debug code to use pcb-printf
Should be no change in output. Only change is that
we no longer assume BDimension == int.
diff --git a/src/autoroute.c b/src/autoroute.c
index 9005259..c799e93 100644
--- a/src/autoroute.c
+++ b/src/autoroute.c
@@ -80,6 +80,7 @@
#include "thermal.h"
#include "undo.h"
#include "vector.h"
+#include "pcb-printf.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
@@ -893,7 +894,7 @@ FindRouteBoxOnLayerGroup (routedata_t * rd,
static void
DumpRouteBox (routebox_t * rb)
{
- printf ("RB: (%d,%d)-(%d,%d) l%d; ",
+ pcb_printf ("RB: %#mD-%#mD l%d; ",
rb->box.X1, rb->box.Y1, rb->box.X2, rb->box.Y2, (int) rb->group);
switch (rb->type)
{
@@ -3567,7 +3568,7 @@ TracePath (routedata_t * rd, routebox_t * path, const routebox_t * target,
#if defined(ROUTE_DEBUG) && defined(DEBUG_SHOW_ROUTE_BOXES)
showroutebox (path);
#if defined(ROUTE_VERBOSE)
- printf ("TRACEPOINT start (%d, %d)\n", nextpoint.X, nextpoint.Y);
+ pcb_printf ("TRACEPOINT start %#mD\n", nextpoint.X, nextpoint.Y);
#endif
#endif
@@ -3597,7 +3598,7 @@ TracePath (routedata_t * rd, routebox_t * path, const routebox_t * target,
#if defined(ROUTE_DEBUG_VERBOSE)
printf ("TRACEPATH: ");
DumpRouteBox (path);
- printf ("TRACEPATH: point (%d, %d) to point (%d, %d) layer %d\n",
+ pcb_printf ("TRACEPATH: point %#mD to point %#mD layer %d\n",
lastpoint.X, lastpoint.Y, nextpoint.X, nextpoint.Y,
path->group);
#endif
@@ -3657,8 +3658,8 @@ TracePath (routedata_t * rd, routebox_t * path, const routebox_t * target,
#if defined(ROUTE_DEBUG_VERBOSE)
printf ("TRACEPATH: ");
DumpRouteBox (path);
- printf
- ("TRACEPATH: (to source) point (%d, %d) to point (%d, %d) layer %d\n",
+ pcb_printf
+ ("TRACEPATH: (to source) point %#mD to point %#mD layer %d\n",
nextpoint.X, nextpoint.Y, lastpoint.X, lastpoint.Y,
path->group);
#endif
commit d5bdffc18f35fa3538a7911a39939ec75504a33b
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Change action.c *WARN* lines to use pcb-printf
Now instead of outputting unsuffixed cmils, warnings
about locked/unnamed elements will refer to the part's
position in either mm or mil, with an appropriate suffix.
Non-warning-related output is unchanged.
diff --git a/src/action.c b/src/action.c
index 4f2e401..8b7e6d5 100644
--- a/src/action.c
+++ b/src/action.c
@@ -70,6 +70,7 @@
#include "undo.h"
#include "rtree.h"
#include "macro.h"
+#include "pcb-printf.h"
#include <assert.h>
#include <stdlib.h> /* rand() */
@@ -3401,10 +3402,9 @@ ActionRenumber (int argc, char **argv, int x, int y)
* add to the list of locked elements which we won't try to
* renumber and whose reference designators are now reserved.
*/
- fprintf (out,
- "*WARN* Element \"%s\" at (%d,%d) is locked and will not be renumbered.\n",
- UNKNOWN (NAMEONPCB_NAME (element)), element->MarkX,
- element->MarkY);
+ pcb_fprintf (out,
+ "*WARN* Element \"%s\" at %$md is locked and will not be renumbered.\n",
+ UNKNOWN (NAMEONPCB_NAME (element)), element->MarkX, element->MarkY);
locked_element_list[lock_cnt] = element;
lock_cnt++;
}
@@ -3566,7 +3566,7 @@ ActionRenumber (int argc, char **argv, int x, int y)
}
else
{
- fprintf (out, "*WARN* Element at (%d,%d) has no name.\n",
+ pcb_fprintf (out, "*WARN* Element at %$md has no name.\n",
element_list[i]->MarkX, element_list[i]->MarkY);
}
commit be8c3bee18c38ff5c634af5f3632446885c0ac80
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Convert file.c to use pcb-printf for cmil output
file.c now uses pcb-printf, though in a limited way:
everything is still output in unsuffixed cmils, though
this is now independent of pcb's internal unit size.
I have also removed the old-style output for symbols.
Aside from that, everything should be the same. Any
other change in output, or file format incompatibility
of any kind, is a bug.
diff --git a/src/file.c b/src/file.c
index 682aa02..f4fb12e 100644
--- a/src/file.c
+++ b/src/file.c
@@ -89,6 +89,7 @@
#include "move.h"
#include "mymem.h"
#include "parse_l.h"
+#include "pcb-printf.h"
#include "polygon.h"
#include "rats.h"
#include "remove.h"
@@ -569,28 +570,29 @@ WritePCBDataHeader (FILE * FP)
fputs ("\nPCB[", FP);
PrintQuotedString (FP, (char *)EMPTY (PCB->Name));
- fprintf (FP, " %i %i]\n\n", (int) PCB->MaxWidth, (int) PCB->MaxHeight);
- fprintf (FP, "Grid[%s %i %i %i]\n",
- c_dtostr (PCB->Grid), (int) PCB->GridOffsetX,
- (int) PCB->GridOffsetY, (int) Settings.DrawGrid);
- fprintf (FP, "Cursor[%i %i %s]\n",
- Crosshair.X, Crosshair.Y, c_dtostr (PCB->Zoom));
- fprintf (FP, "PolyArea[%s]\n", c_dtostr (PCB->IsleArea));
- fprintf (FP, "Thermal[%s]\n", c_dtostr (PCB->ThermScale));
- fprintf (FP, "DRC[%i %i %i %i %i %i]\n", PCB->Bloat, PCB->Shrink,
- PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing);
+ pcb_fprintf (FP, " %mc %mc]\n\n", PCB->MaxWidth, PCB->MaxHeight);
+ pcb_fprintf (FP, "Grid[%s %mc %mc %d]\n",
+ c_dtostr (PCB->Grid), PCB->GridOffsetX,
+ PCB->GridOffsetY, Settings.DrawGrid);
+ pcb_fprintf (FP, "Cursor[%mc %mc %s]\n",
+ Crosshair.X, Crosshair.Y, c_dtostr (PCB->Zoom));
+ /* PolyArea should be output in square cmils, no suffix */
+ fprintf (FP, "PolyArea[%s]\n", c_dtostr (COORD_TO_MIL (COORD_TO_MIL (PCB->IsleArea) * 100) * 100));
+ pcb_fprintf (FP, "Thermal[%s]\n", c_dtostr (PCB->ThermScale));
+ pcb_fprintf (FP, "DRC[%mc %mc %mc %mc %mc %mc]\n", PCB->Bloat, PCB->Shrink,
+ PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing);
fprintf (FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags));
fprintf (FP, "Groups(\"%s\")\n", LayerGroupsToString (&PCB->LayerGroups));
fputs ("Styles[\"", FP);
for (group = 0; group < NUM_STYLES - 1; group++)
- fprintf (FP, "%s,%i,%i,%i,%i:", PCB->RouteStyle[group].Name,
- PCB->RouteStyle[group].Thick,
- PCB->RouteStyle[group].Diameter,
- PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway);
- fprintf (FP, "%s,%i,%i,%i,%i\"]\n\n", PCB->RouteStyle[group].Name,
- PCB->RouteStyle[group].Thick,
- PCB->RouteStyle[group].Diameter,
- PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway);
+ pcb_fprintf (FP, "%s,%mc,%mc,%mc,%mc:", PCB->RouteStyle[group].Name,
+ PCB->RouteStyle[group].Thick,
+ PCB->RouteStyle[group].Diameter,
+ PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway);
+ pcb_fprintf (FP, "%s,%mc,%mc,%mc,%mc\"]\n\n", PCB->RouteStyle[group].Name,
+ PCB->RouteStyle[group].Thick,
+ PCB->RouteStyle[group].Diameter,
+ PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway);
}
/* ---------------------------------------------------------------------------
@@ -608,31 +610,16 @@ WritePCBFontData (FILE * FP)
if (!font->Symbol[i].Valid)
continue;
- if (isprint (i) && font->Symbol[i].Delta % 100 == 0)
- fprintf (FP, "Symbol('%c' %i)\n(\n",
- (char) i, (int) font->Symbol[i].Delta / 100);
- else if (isprint (i))
- fprintf (FP, "Symbol['%c' %i]\n(\n",
- (char) i, (int) font->Symbol[i].Delta);
+ if (isprint (i))
+ pcb_fprintf (FP, "Symbol['%c' %mc]\n(\n", i, font->Symbol[i].Delta);
else
- fprintf (FP, "Symbol[%i %i]\n(\n", i, (int) font->Symbol[i].Delta);
+ pcb_fprintf (FP, "Symbol[%i %mc]\n(\n", i, font->Symbol[i].Delta);
line = font->Symbol[i].Line;
for (j = font->Symbol[i].LineN; j; j--, line++)
- {
- if (line->Point1.X % 100 == 0
- && line->Point1.Y % 100 == 0
- && line->Point2.X % 100 == 0
- && line->Point2.Y % 100 == 0 && line->Thickness % 100 == 0)
- fprintf (FP, "\tSymbolLine(%i %i %i %i %i)\n",
- line->Point1.X / 100, line->Point1.Y / 100,
- line->Point2.X / 100, line->Point2.Y / 100,
- line->Thickness / 100);
- else
- fprintf (FP, "\tSymbolLine[%i %i %i %i %i]\n",
- line->Point1.X, line->Point1.Y,
- line->Point2.X, line->Point2.Y, line->Thickness);
- }
+ pcb_fprintf (FP, "\tSymbolLine[%mc %mc %mc %mc %mc]\n",
+ line->Point1.X, line->Point1.Y,
+ line->Point2.X, line->Point2.Y, line->Thickness);
fputs (")\n", FP);
}
}
@@ -648,9 +635,8 @@ WriteViaData (FILE * FP, DataTypePtr Data)
for (iter = Data->Via; iter != NULL; iter = g_list_next (iter))
{
PinType *via = iter->data;
- fprintf (FP, "Via[%i %i %i %i %i %i ",
- via->X, via->Y,
- via->Thickness, via->Clearance, via->Mask, via->DrillingHole);
+ pcb_fprintf (FP, "Via[%mc %mc %mc %mc %mc %mc ", via->X, via->Y,
+ via->Thickness, via->Clearance, via->Mask, via->DrillingHole);
PrintQuotedString (FP, (char *)EMPTY (via->Name));
fprintf (FP, " %s]\n", F2S (via, VIA_TYPE));
}
@@ -667,10 +653,9 @@ WritePCBRatData (FILE * FP)
for (iter = PCB->Data->Rat; iter != NULL; iter = g_list_next (iter))
{
RatType *line = iter->data;
- fprintf (FP, "Rat[%i %i %i %i %i %i ",
- (int) line->Point1.X, (int) line->Point1.Y,
- (int) line->group1, (int) line->Point2.X,
- (int) line->Point2.Y, (int) line->group2);
+ pcb_fprintf (FP, "Rat[%mc %mc %d %mc %mc %d ",
+ line->Point1.X, line->Point1.Y, line->group1,
+ line->Point2.X, line->Point2.Y, line->group2);
fprintf (FP, " %s]\n", F2S (line, RATLINE_TYPE));
}
}
@@ -732,24 +717,22 @@ WriteElementData (FILE * FP, DataTypePtr Data)
PrintQuotedString (FP, (char *)EMPTY (NAMEONPCB_NAME (element)));
fputc (' ', FP);
PrintQuotedString (FP, (char *)EMPTY (VALUE_NAME (element)));
- fprintf (FP, " %i %i %i %i %i %i %s]\n(\n",
- (int) element->MarkX, (int) element->MarkY,
- (int) (DESCRIPTION_TEXT (element).X -
- element->MarkX),
- (int) (DESCRIPTION_TEXT (element).Y -
- element->MarkY),
- (int) DESCRIPTION_TEXT (element).Direction,
- (int) DESCRIPTION_TEXT (element).Scale,
- F2S (&(DESCRIPTION_TEXT (element)), ELEMENTNAME_TYPE));
+ pcb_fprintf (FP, " %mc %mc %mc %mc %mc %mc %s]\n(\n",
+ element->MarkX, element->MarkY,
+ DESCRIPTION_TEXT (element).X - element->MarkX,
+ DESCRIPTION_TEXT (element).Y - element->MarkY,
+ DESCRIPTION_TEXT (element).Direction,
+ DESCRIPTION_TEXT (element).Scale,
+ F2S (&(DESCRIPTION_TEXT (element)), ELEMENTNAME_TYPE));
WriteAttributeList (FP, &element->Attributes, "\t");
for (p = element->Pin; p != NULL; p = g_list_next (p))
{
PinType *pin = p->data;
- fprintf (FP, "\tPin[%i %i %i %i %i %i ",
- (int) (pin->X - element->MarkX),
- (int) (pin->Y - element->MarkY),
- (int) pin->Thickness, (int) pin->Clearance,
- (int) pin->Mask, (int) pin->DrillingHole);
+ pcb_fprintf (FP, "\tPin[%mc %mc %mc %mc %mc %mc ",
+ pin->X - element->MarkX,
+ pin->Y - element->MarkY,
+ pin->Thickness, pin->Clearance,
+ pin->Mask, pin->DrillingHole);
PrintQuotedString (FP, (char *)EMPTY (pin->Name));
fprintf (FP, " ");
PrintQuotedString (FP, (char *)EMPTY (pin->Number));
@@ -758,13 +741,12 @@ WriteElementData (FILE * FP, DataTypePtr Data)
for (p = element->Pad; p != NULL; p = g_list_next (p))
{
PadType *pad = p->data;
- fprintf (FP, "\tPad[%i %i %i %i %i %i %i ",
- (int) (pad->Point1.X - element->MarkX),
- (int) (pad->Point1.Y - element->MarkY),
- (int) (pad->Point2.X - element->MarkX),
- (int) (pad->Point2.Y - element->MarkY),
- (int) pad->Thickness, (int) pad->Clearance,
- (int) pad->Mask);
+ pcb_fprintf (FP, "\tPad[%mc %mc %mc %mc %mc %mc %mc ",
+ pad->Point1.X - element->MarkX,
+ pad->Point1.Y - element->MarkY,
+ pad->Point2.X - element->MarkX,
+ pad->Point2.Y - element->MarkY,
+ pad->Thickness, pad->Clearance, pad->Mask);
PrintQuotedString (FP, (char *)EMPTY (pad->Name));
fprintf (FP, " ");
PrintQuotedString (FP, (char *)EMPTY (pad->Number));
@@ -773,27 +755,22 @@ WriteElementData (FILE * FP, DataTypePtr Data)
for (p = element->Line; p != NULL; p = g_list_next (p))
{
LineType *line = p->data;
- fprintf (FP,
- "\tElementLine [%i %i %i %i %i]\n",
- (int) (line->Point1.X -
- element->MarkX),
- (int) (line->Point1.Y -
- element->MarkY),
- (int) (line->Point2.X -
- element->MarkX),
- (int) (line->Point2.Y -
- element->MarkY), (int) line->Thickness);
+ pcb_fprintf (FP, "\tElementLine [%mc %mc %mc %mc %mc]\n",
+ line->Point1.X - element->MarkX,
+ line->Point1.Y - element->MarkY,
+ line->Point2.X - element->MarkX,
+ line->Point2.Y - element->MarkY,
+ line->Thickness);
}
for (p = element->Arc; p != NULL; p = g_list_next (p))
{
ArcType *arc = p->data;
- fprintf (FP,
- "\tElementArc [%i %i %i %i %i %i %i]\n",
- (int) (arc->X - element->MarkX),
- (int) (arc->Y - element->MarkY),
- (int) arc->Width, (int) arc->Height,
- (int) arc->StartAngle, (int) arc->Delta,
- (int) arc->Thickness);
+ pcb_fprintf (FP, "\tElementArc [%mc %mc %mc %mc %mc %mc %mc]\n",
+ arc->X - element->MarkX,
+ arc->Y - element->MarkY,
+ arc->Width, arc->Height,
+ arc->StartAngle, arc->Delta,
+ arc->Thickness);
}
fputs ("\n\t)\n", FP);
}
@@ -818,27 +795,27 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
for (n = layer->Line; n != NULL; n = g_list_next (n))
{
LineType *line = n->data;
- fprintf (FP, "\tLine[%i %i %i %i %i %i %s]\n",
- (int) line->Point1.X, (int) line->Point1.Y,
- (int) line->Point2.X, (int) line->Point2.Y,
- (int) line->Thickness, (int) line->Clearance,
- F2S (line, LINE_TYPE));
+ pcb_fprintf (FP, "\tLine[%mc %mc %mc %mc %mc %mc %s]\n",
+ line->Point1.X, line->Point1.Y,
+ line->Point2.X, line->Point2.Y,
+ line->Thickness, line->Clearance,
+ F2S (line, LINE_TYPE));
}
for (n = layer->Arc; n != NULL; n = g_list_next (n))
{
ArcType *arc = n->data;
- fprintf (FP, "\tArc[%i %i %i %i %i %i %i %i %s]\n",
- (int) arc->X, (int) arc->Y, (int) arc->Width,
- (int) arc->Height, (int) arc->Thickness,
- (int) arc->Clearance, (int) arc->StartAngle,
- (int) arc->Delta, F2S (arc, ARC_TYPE));
+ pcb_fprintf (FP, "\tArc[%mc %mc %mc %mc %mc %mc %mc %mc %s]\n",
+ arc->X, arc->Y, arc->Width,
+ arc->Height, arc->Thickness,
+ arc->Clearance, arc->StartAngle,
+ arc->Delta, F2S (arc, ARC_TYPE));
}
for (n = layer->Text; n != NULL; n = g_list_next (n))
{
TextType *text = n->data;
- fprintf (FP, "\tText[%i %i %i %i ",
- (int) text->X, (int) text->Y,
- (int) text->Direction, (int) text->Scale);
+ pcb_fprintf (FP, "\tText[%mc %mc %mc %mc ",
+ text->X, text->Y,
+ text->Direction, text->Scale);
PrintQuotedString (FP, (char *)EMPTY (text->TextString));
fprintf (FP, " %s]\n", F2S (text, TEXT_TYPE));
}
@@ -868,7 +845,7 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
if (hole)
fputs ("\t", FP);
}
- fprintf (FP, "[%i %i] ", (int) point->X, (int) point->Y);
+ pcb_fprintf (FP, "[%mc %mc] ", point->X, point->Y);
}
if (hole > 0)
fputs ("\n\t\t)", FP);
commit da86b04ab351c441c88d04eb9221badbe95d9e5a
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add # subspecifier to pcb-printf to prevent scaling for debug output
diff --git a/src/pcb-printf.c b/src/pcb-printf.c
index e0fe9d1..d2b31b7 100644
--- a/src/pcb-printf.c
+++ b/src/pcb-printf.c
@@ -248,6 +248,11 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
|| *fmt == 'h' || *fmt == '-')
g_string_append_c (spec, *fmt++);
/* Get our sub-specifiers */
+ if(*fmt == '#')
+ {
+ mask = ALLOW_CMIL; /* This must be pcb's base unit */
+ fmt++;
+ }
if(*fmt == '$')
{
suffix = SUFFIX;
diff --git a/src/pcb-printf.h b/src/pcb-printf.h
index 6b87a85..bcf319e 100644
--- a/src/pcb-printf.h
+++ b/src/pcb-printf.h
@@ -53,9 +53,11 @@
* %mr output a measure in ...
[truncated message content] |
|
From: <gi...@gp...> - 2011-06-20 20:21:29
|
The branch, master has been updated
via 2daa8bb0ab325e4e8667ad3090a75210acd42f9e (commit)
from 14080c7575340d49c11bd3539ec0d0722615d930 (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
=========
doc/Makefile.am | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
=================
Commit Messages
=================
commit 2daa8bb0ab325e4e8667ad3090a75210acd42f9e
Author: Krzysztof KoÅciuszkiewicz <k.k...@gm...>
Commit: Krzysztof KoÅciuszkiewicz <k.k...@gm...>
doc: do not distribute dvi files
DVI files cannot be generated without LaTeX, and since commit
3afdb7efdaf6cc8094cc6143269e7df519183197 only pdfLaTeX is supported.
:100755 100755 95d1ad3... 6d1e457... M doc/Makefile.am
=========
Changes
=========
commit 2daa8bb0ab325e4e8667ad3090a75210acd42f9e
Author: Krzysztof KoÅciuszkiewicz <k.k...@gm...>
Commit: Krzysztof KoÅciuszkiewicz <k.k...@gm...>
doc: do not distribute dvi files
DVI files cannot be generated without LaTeX, and since commit
3afdb7efdaf6cc8094cc6143269e7df519183197 only pdfLaTeX is supported.
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 95d1ad3..6d1e457 100755
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -63,9 +63,7 @@ EXTRA_DIST= \
eps2png \
extract-docs \
refcard.tex \
- pcb.dvi \
pcb.css \
- refcard.dvi \
${inline_texi} \
${pcb_files} \
${pcb_output_noinst} \
@@ -76,8 +74,8 @@ EXTRA_DIST= \
if GIT_OR_CVS_VERSION
BUILT_SOURCES= ${tab_texi} ${pcb_output} ${inline_texi}
CLEANFILES= \
- refcard.aux refcard.dvi refcard.log refcard.pdf \
- ${pcb_output} ${tab_texi} ${inline_texi} pcb.dvi pcb.html pcb.pdf \
+ refcard.aux refcard.log refcard.pdf \
+ ${pcb_output} ${tab_texi} ${inline_texi} pcb.html pcb.pdf \
${images_output}
else
BUILT_SOURCES=
@@ -137,7 +135,7 @@ else
@echo "Skipping documentation extraction since you are not building from GIT sources"
endif
-SUFFIXES = .dvi .eps .pcb .pdf .png .tab .tex
+SUFFIXES = .eps .pcb .pdf .png .tab .tex
.pcb.eps :
${PCB} -x eps --only-visible --font-path $(top_srcdir)/src --eps-file $@ $<
|
|
From: <gi...@gp...> - 2011-06-20 05:04:30
|
The branch, master has been updated
via 14080c7575340d49c11bd3539ec0d0722615d930 (commit)
from 6ad4d0c9278a9813fc8b3a29bfdc51f5fdcd0754 (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/lesstif/menu.c | 51 +++++++++++++++++++++++------------------------
1 files changed, 25 insertions(+), 26 deletions(-)
=================
Commit Messages
=================
commit 14080c7575340d49c11bd3539ec0d0722615d930
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Allow 1...9 and Ctrl+1...9 accellerators for silk/rats in lesstif
:100644 100644 8de2952... 481bba5... M src/hid/lesstif/menu.c
=========
Changes
=========
commit 14080c7575340d49c11bd3539ec0d0722615d930
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Allow 1...9 and Ctrl+1...9 accellerators for silk/rats in lesstif
diff --git a/src/hid/lesstif/menu.c b/src/hid/lesstif/menu.c
index 8de2952..481bba5 100644
--- a/src/hid/lesstif/menu.c
+++ b/src/hid/lesstif/menu.c
@@ -527,15 +527,18 @@ insert_layerview_buttons (Widget menu)
{
static char namestr[] = "Label ";
char *name = namestr;
+ int accel_idx = i;
Widget btn;
name[5] = 'A' + i;
switch (i)
{
case LB_SILK:
name = "Silk";
+ accel_idx = max_copper_layer;
break;
case LB_RATS:
name = "Rat Lines";
+ accel_idx = max_copper_layer + 1;
break;
case LB_PINS:
name = "Pins/Pads";
@@ -551,12 +554,12 @@ insert_layerview_buttons (Widget menu)
break;
}
n = 0;
- if (i < MAX_LAYER && i < 9)
+ if (accel_idx < 9)
{
char buf[20], av[30];
Resource *ar;
XmString as;
- sprintf (buf, "Ctrl-%d", i + 1);
+ sprintf (buf, "Ctrl-%d", accel_idx + 1);
as = XmStringCreateLocalized (buf);
stdarg (XmNacceleratorText, as);
ar = resource_create (0);
@@ -564,9 +567,9 @@ insert_layerview_buttons (Widget menu)
resource_add_val (ar, 0, strdup (av), 0);
resource_add_val (ar, 0, strdup (av), 0);
ar->flags |= FLAG_V;
- sprintf (av, "Ctrl<Key>%d", i + 1);
+ sprintf (av, "Ctrl<Key>%d", accel_idx + 1);
note_accelerator (av, ar);
- stdarg (XmNmnemonic, i + '1');
+ stdarg (XmNmnemonic, accel_idx + '1');
}
btn = XmCreateToggleButton (menu, name, args, n);
XtManageChild (btn);
@@ -599,46 +602,42 @@ insert_layerpick_buttons (Widget menu)
{
static char namestr[] = "Label ";
char *name = namestr;
+ int accel_idx = i;
+ char buf[20], av[30];
Widget btn;
name[5] = 'A' + i;
switch (i)
{
case LB_SILK:
name = "Silk";
+ accel_idx = max_copper_layer;
+ strcpy (av, "SelectLayer(Silk)");
break;
case LB_RATS:
name = "Rat Lines";
- break;
+ accel_idx = max_copper_layer + 1;
+ strcpy (av, "SelectLayer(Rats)");
+ break;
+ default:
+ sprintf (av, "SelectLayer(%d)", i + 1);
+ break;
}
n = 0;
- if (i < MAX_LAYER && i < 9)
- {
- char buf[20], av[30];
+ if (accel_idx < 9)
+ {
Resource *ar;
XmString as;
- sprintf (buf, "%d", i + 1);
- as = XmStringCreateLocalized (buf);
- stdarg (XmNacceleratorText, as);
ar = resource_create (0);
- switch (i)
- {
- case LB_SILK:
- strcpy (av, "SelectLayer(Silk)");
- break;
- case LB_RATS:
- strcpy (av, "SelectLayer(Rats)");
- break;
- default:
- sprintf (av, "SelectLayer(%d)", i + 1);
- break;
- }
resource_add_val (ar, 0, strdup (av), 0);
resource_add_val (ar, 0, strdup (av), 0);
ar->flags |= FLAG_V;
- sprintf (av, "<Key>%d", i + 1);
+ sprintf (buf, "%d", i + 1);
+ as = XmStringCreateLocalized (buf);
+ stdarg (XmNacceleratorText, as);
+ sprintf (av, "<Key>%d", accel_idx + 1);
note_accelerator (av, ar);
- stdarg (XmNmnemonic, i + '1');
- }
+ stdarg (XmNmnemonic, accel_idx + '1');
+ }
stdarg (XmNindicatorType, XmONE_OF_MANY);
btn = XmCreateToggleButton (menu, name, args, n);
XtManageChild (btn);
|
|
From: <gi...@gp...> - 2011-06-20 04:20:51
|
The branch, master has been updated
via 6ad4d0c9278a9813fc8b3a29bfdc51f5fdcd0754 (commit)
via 92f422433fb31520d885d0c75e3d3264c0d2f3c5 (commit)
from a040ea606fa0b9808a8287803fcbefc5eb39be9b (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/find.c | 25 +++++++++++++++++++++++--
src/global.h | 1 +
src/hid/lesstif/main.c | 3 +++
3 files changed, 27 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit 6ad4d0c9278a9813fc8b3a29bfdc51f5fdcd0754
Author: Levente Kovacs <lev...@gm...>
Commit: DJ Delorie <dj...@de...>
gEDA-user: skpi_drc patch
On Fri, 17 Jun 2011 17:30:22 -0400
DJ Delorie <dj...@de...> wrote:
> You want the (already global) AttributeGet() function.
>
> l->no_drc = AttributeGet (l, "PCB::skip-drc") != NULL;
>
> This does assume that the attribute has *some* value, even if the
> value is the empty string.
Thanks for pointing this out.
Attached is the new patch.
Levente
--
Levente Kovacs
http://levente.logonex.eu
:100644 100644 eb4cac2... c5159ba... M src/find.c
:100644 100644 daa82a9... 08abbb8... M src/global.h
commit 92f422433fb31520d885d0c75e3d3264c0d2f3c5
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Lesstif: ignore crosshair changes before window exists.
:100644 100644 90979c0... f41c4ce... M src/hid/lesstif/main.c
=========
Changes
=========
commit 6ad4d0c9278a9813fc8b3a29bfdc51f5fdcd0754
Author: Levente Kovacs <lev...@gm...>
Commit: DJ Delorie <dj...@de...>
gEDA-user: skpi_drc patch
On Fri, 17 Jun 2011 17:30:22 -0400
DJ Delorie <dj...@de...> wrote:
> You want the (already global) AttributeGet() function.
>
> l->no_drc = AttributeGet (l, "PCB::skip-drc") != NULL;
>
> This does assume that the attribute has *some* value, even if the
> value is the empty string.
Thanks for pointing this out.
Attached is the new patch.
Levente
--
Levente Kovacs
http://levente.logonex.eu
diff --git a/src/find.c b/src/find.c
index eb4cac2..c5159ba 100644
--- a/src/find.c
+++ b/src/find.c
@@ -822,6 +822,8 @@ LookupLOConnectionsToPVList (bool AndRats)
/* now all lines, arcs and polygons of the several layers */
for (layer = 0; layer < max_copper_layer; layer++)
{
+ if (LAYER_PTR (layer)->no_drc)
+ continue;
info.layer = layer;
/* add touching lines */
if (setjmp (info.env) == 0)
@@ -1169,6 +1171,8 @@ LookupPVConnectionsToLOList (bool AndRats)
/* loop over all layers */
for (layer = 0; layer < max_copper_layer; layer++)
{
+ if (LAYER_PTR (layer)->no_drc)
+ continue;
/* do nothing if there are no PV's */
if (TotalP + TotalV == 0)
{
@@ -2901,6 +2905,21 @@ ListsEmpty (bool AndRats)
return (empty);
}
+static void
+reassign_no_drc_flags (void)
+{
+ int layer;
+
+ for (layer = 0; layer < max_copper_layer; layer++)
+ {
+ LayerTypePtr l = LAYER_PTR (layer);
+ l->no_drc = AttributeGet (l, "PCB::skip-drc") != NULL;
+ }
+}
+
+
+
+
/* ---------------------------------------------------------------------------
* loops till no more connections are found
*/
@@ -2908,6 +2927,7 @@ static bool
DoIt (bool AndRats, bool AndDraw)
{
bool newone = false;
+ reassign_no_drc_flags ();
do
{
/* lookup connections; these are the steps (2) to (4)
@@ -3350,6 +3370,7 @@ LookupConnection (LocationType X, LocationType Y, bool AndDraw,
/* check if there are any pins or pads at that position */
+ reassign_no_drc_flags ();
type
= SearchObjectByLocation (LOOKUP_FIRST, &ptr1, &ptr2, &ptr3, X, Y, Range);
@@ -3366,8 +3387,8 @@ LookupConnection (LocationType X, LocationType Y, bool AndDraw,
int laynum = GetLayerNumber (PCB->Data,
(LayerTypePtr) ptr1);
- /* don't mess with silk objects! */
- if (laynum >= max_copper_layer)
+ /* don't mess with non-conducting objects! */
+ if (laynum >= max_copper_layer || ((LayerTypePtr)ptr1)->no_drc)
return;
}
}
diff --git a/src/global.h b/src/global.h
index daa82a9..08abbb8 100644
--- a/src/global.h
+++ b/src/global.h
@@ -303,6 +303,7 @@ typedef struct /* holds information about one layer */
char *Color, /* color */
*SelectedColor;
AttributeListType Attributes;
+ int no_drc; /* whether to ignore the layer when checking the design rules */
}
LayerType, *LayerTypePtr;
commit 92f422433fb31520d885d0c75e3d3264c0d2f3c5
Author: DJ Delorie <dj...@de...>
Commit: DJ Delorie <dj...@de...>
Lesstif: ignore crosshair changes before window exists.
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index 90979c0..f41c4ce 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -2900,6 +2900,9 @@ lesstif_notify_crosshair_change (bool changes_complete)
static int invalidate_depth = 0;
Pixmap save_pixmap;
+ if (! my_gc)
+ return;
+
if (changes_complete)
invalidate_depth --;
|
|
From: <gi...@gp...> - 2011-06-20 04:06:43
|
The branch, master has been updated
via a040ea606fa0b9808a8287803fcbefc5eb39be9b (commit)
from b329249936d9f7da50ccd7c0c6064921e8466889 (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-top-window.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
=================
Commit Messages
=================
commit a040ea606fa0b9808a8287803fcbefc5eb39be9b
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Allow 1..9 accelerator keys to be applied to non-copper layers in gtk
Closes-bug lp-699327
:100644 100644 31be13a... 23d6401... M src/hid/gtk/gui-top-window.c
=========
Changes
=========
commit a040ea606fa0b9808a8287803fcbefc5eb39be9b
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Allow 1..9 accelerator keys to be applied to non-copper layers in gtk
Closes-bug lp-699327
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 31be13a..23d6401 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1066,22 +1066,23 @@ ghid_make_programmed_menu_actions ()
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:
- if (i <= 8)
- layerpick_toggle_entries[i].accelerator =
- g_strdup_printf ("<Key>%d", i + 1);
-
- sprintf (av, "SelectLayer(%d) LayersChanged()",
- i + 1);
-
+ 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);
|
|
From: <gi...@gp...> - 2011-06-20 03:26:17
|
The branch, master has been updated
via b329249936d9f7da50ccd7c0c6064921e8466889 (commit)
via 5b4b82cb9e1e272e8f6a816922383be6cdbac701 (commit)
via f2f9f2beb86f0dd8ff262f18094598c7a621feb4 (commit)
from 8dc7e84aeb03a98232d55b3bc85752732001b192 (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/misc.c | 11 ++
src/misc.h | 2 +
src/pcb-printf.c | 18 ++-
src/pcb-printf.h | 3 +
src/report.c | 352 +++++++++++++++++++++++------------------------------
5 files changed, 181 insertions(+), 205 deletions(-)
=================
Commit Messages
=================
commit b329249936d9f7da50ccd7c0c6064921e8466889
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Change report.c to use pcb-printf
Right now there should be no change in the output from
report.c; this is essentially just a code cleanup. The
prec/UNIT nastiness is cleaned up -- precision is handled
by the defaults in pcb-printf (.2 for mil, .4 for mm,
same as before) and unit selection is done with the %m+
specifier.
It's easy now to expand to allow auto-scaling or even
automatic selection of metric/imperial based on sig.
figs., but I've played around with this and it looks
like mixing units is confusing and hard-to-read, so we're
sticking with just one of mm/mil for now.
:100644 100644 3e71ee7... afd63ac... M src/report.c
commit 5b4b82cb9e1e272e8f6a816922383be6cdbac701
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add %m+ specifier to pcb-printf
As long as our base units are cmils, allowing pcb-printf to guess
the most natural units for displaying measures is a bad idea -- it
cannot reliably count significant figures for many values. The
result, for example, in report.c, is inconsistent and confusing
dialogs with a mix of metric and imperial measurements.
The %m+ specifier is used to force pcb-printf to only use certain
units; in this case, the user's gui setting of metric/imperial.
:100644 100644 31a1e32... 2ede73c... M src/pcb-printf.c
:100644 100644 03aa978... 2992d1b... M src/pcb-printf.h
commit f2f9f2beb86f0dd8ff262f18094598c7a621feb4
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add Distance() function to avoid overflow with sqrt(x*x + y*y)
:100644 100644 e505047... ce2ab4a... M src/misc.c
:100644 100644 fb303d6... 45d6e52... M src/misc.h
=========
Changes
=========
commit b329249936d9f7da50ccd7c0c6064921e8466889
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Change report.c to use pcb-printf
Right now there should be no change in the output from
report.c; this is essentially just a code cleanup. The
prec/UNIT nastiness is cleaned up -- precision is handled
by the defaults in pcb-printf (.2 for mil, .4 for mm,
same as before) and unit selection is done with the %m+
specifier.
It's easy now to expand to allow auto-scaling or even
automatic selection of metric/imperial based on sig.
figs., but I've played around with this and it looks
like mixing units is confusing and hard-to-read, so we're
sticking with just one of mm/mil for now.
diff --git a/src/report.c b/src/report.c
index 3e71ee7..afd63ac 100644
--- a/src/report.c
+++ b/src/report.c
@@ -47,16 +47,14 @@
#include "undo.h"
#include "find.h"
#include "draw.h"
+#include "pcb-printf.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
-static double
-units(double value)
-{return (Settings.grid_units_mm ? COORD_TO_MM(value) : COORD_TO_MIL(value));}
-
-#define UNIT(value) units(value), (Settings.grid_units_mm ? "mm" : "mils")
+/* These should perhaps be ALLOW_METRIC and ALLOW_IMPERIAL to allow scaling */
+#define USER_UNITMASK (Settings.grid_units_mm ? ALLOW_MM : ALLOW_MIL)
static int
ReportDrills (int argc, char **argv, int x, int y)
@@ -65,7 +63,6 @@ ReportDrills (int argc, char **argv, int x, int y)
Cardinal n;
char *stringlist, *thestring;
int total_drills = 0;
- int prec = Settings.grid_units_mm? 4: 2;
AllDrills = GetDrillInfo (PCB->Data);
RoundDrillInfo (AllDrills, 100);
@@ -85,16 +82,16 @@ ReportDrills (int argc, char **argv, int x, int y)
sprintf (stringlist,
"There are %d different drill sizes used in this layout, %d holes total\n\n"
"Drill Diam. (%s)\t# of Pins\t# of Vias\t# of Elements\t# Unplated\n",
- AllDrills->DrillN, total_drills,
- Settings.grid_units_mm? "mm": "mils");
+ AllDrills->DrillN, total_drills, Settings.grid_units_mm ? "mm" : "mil");
thestring = stringlist;
while (*thestring != '\0')
thestring++;
for (n = 0; n < AllDrills->DrillN; n++)
{
- sprintf (thestring,
- "\t%.*f\t\t%d\t\t%d\t\t%d\t\t%d\n",
- prec, units (AllDrills->Drill[n].DrillSize),
+ pcb_sprintf (thestring,
+ "\t%$m*\t\t%d\t\t%d\t\t%d\t\t%d\n",
+ (Settings.grid_units_mm ? "mm" : "mil"),
+ AllDrills->Drill[n].DrillSize,
AllDrills->Drill[n].PinCount, AllDrills->Drill[n].ViaCount,
AllDrills->Drill[n].ElementN,
AllDrills->Drill[n].UnplatedCount);
@@ -125,7 +122,7 @@ static int
ReportDialog (int argc, char **argv, int x, int y)
{
void *ptr1, *ptr2, *ptr3;
- int type, prec = Settings.grid_units_mm? 4: 2;
+ int type;
char report[2048];
type = SearchScreen (x, y, REPORT_TYPES, &ptr1, &ptr2, &ptr3);
@@ -147,32 +144,29 @@ ReportDialog (int argc, char **argv, int x, int y)
#endif
via = (PinTypePtr) ptr2;
if (TEST_FLAG (HOLEFLAG, via))
- sprintf (&report[0], "VIA ID# %ld; Flags:%s\n"
- "(X,Y) = (%.*f, %.*f) %s.\n"
- "It is a pure hole of diameter %.*f %s.\n"
+ pcb_sprintf (&report[0], "%m+VIA ID# %ld; Flags:%s\n"
+ "(X,Y) = %$mD %s.\n"
+ "It is a pure hole of diameter %$mS.\n"
"Name = \"%s\"."
- "%s", via->ID, flags_to_string (via->Flags, VIA_TYPE),
- prec, units (via->X), prec, UNIT (via->Y),
- prec, UNIT (via->DrillingHole),
- EMPTY (via->Name), TEST_FLAG (LOCKFLAG,
- via) ? "It is LOCKED.\n" :
- "");
+ "%s", USER_UNITMASK, via->ID, flags_to_string (via->Flags, VIA_TYPE),
+ via->X, via->Y, via->DrillingHole, EMPTY (via->Name),
+ TEST_FLAG (LOCKFLAG, via) ? "It is LOCKED.\n" : "");
else
- sprintf (&report[0], "VIA ID# %ld; Flags:%s\n"
- "(X,Y) = (%.*f, %.*f) %s.\n"
- "Copper width = %0.*f %s. Drill width = %0.*f %s.\n"
- "Clearance width in polygons = %0.*f %s.\n"
- "Annulus = %0.*f %s.\n"
- "Solder mask hole = %0.*f %s (gap = %0.*f %s).\n"
+ pcb_sprintf (&report[0], "%m+VIA ID# %ld; Flags:%s\n"
+ "(X,Y) = %$mD.\n"
+ "Copper width = %$mS. Drill width = %$mS.\n"
+ "Clearance width in polygons = %$mS.\n"
+ "Annulus = %$mS.\n"
+ "Solder mask hole = %$mS (gap = %$mS).\n"
"Name = \"%s\"."
- "%s", via->ID, flags_to_string (via->Flags, VIA_TYPE),
- prec, units (via->X), prec, UNIT (via->Y),
- prec, UNIT (via->Thickness),
- prec, UNIT (via->DrillingHole),
- prec, UNIT (via->Clearance / 2.),
- prec, UNIT ((via->Thickness - via->DrillingHole)/2),
- prec, UNIT (via->Mask),
- prec, UNIT ((via->Mask - via->Thickness)/2),
+ "%s", USER_UNITMASK, via->ID, flags_to_string (via->Flags, VIA_TYPE),
+ via->X, via->Y,
+ via->Thickness,
+ via->DrillingHole,
+ via->Clearance / 2,
+ (via->Thickness - via->DrillingHole) / 2,
+ via->Mask,
+ (via->Mask - via->Thickness) / 2,
EMPTY (via->Name), TEST_FLAG (LOCKFLAG, via) ?
"It is LOCKED.\n" : "");
break;
@@ -198,33 +192,31 @@ ReportDialog (int argc, char **argv, int x, int y)
}
END_LOOP;
if (TEST_FLAG (HOLEFLAG, Pin))
- sprintf (&report[0], "PIN ID# %ld; Flags:%s\n"
- "(X,Y) = (%.*f, %.*f) %s.\n"
- "It is a mounting hole. Drill width = %0.*f %s.\n"
- "It is owned by element %s.\n"
- "%s", Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE),
- prec, units (Pin->X), prec, UNIT (Pin->Y),
- prec, UNIT (Pin->DrillingHole),
+ pcb_sprintf (&report[0], "%m+PIN ID# %ld; Flags:%s\n"
+ "(X,Y) = %$mD.\n"
+ "It is a mounting hole. Drill width = %$mS.\n"
+ "It is owned by element %$mS.\n"
+ "%s", USER_UNITMASK, Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE),
+ Pin->X, Pin->Y, Pin->DrillingHole,
EMPTY (element->Name[1].TextString),
TEST_FLAG (LOCKFLAG, Pin) ? "It is LOCKED.\n" : "");
else
- sprintf (&report[0],
- "PIN ID# %ld; Flags:%s\n" "(X,Y) = (%.*f, %.*f) %s.\n"
- "Copper width = %0.*f %s. Drill width = %0.*f %s.\n"
- "Clearance width to Polygon = %0.*f %s.\n"
- "Annulus = %0.*f %s.\n"
- "Solder mask hole = %0.*f %s (gap = %0.*f %s).\n"
+ pcb_sprintf (&report[0],
+ "%m+PIN ID# %ld; Flags:%s\n" "(X,Y) = %$mD.\n"
+ "Copper width = %$mS. Drill width = %$mS.\n"
+ "Clearance width to Polygon = %$mS.\n"
+ "Annulus = %$mS.\n"
+ "Solder mask hole = %$mS (gap = %$mS).\n"
"Name = \"%s\".\n"
"It is owned by element %s\n as pin number %s.\n"
- "%s",
+ "%s", USER_UNITMASK,
Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE),
- prec, units(Pin->X), prec, UNIT(Pin->Y),
- prec, UNIT (Pin->Thickness),
- prec, UNIT (Pin->DrillingHole),
- prec, UNIT (Pin->Clearance / 2.),
- prec, UNIT ((Pin->Thickness - Pin->DrillingHole)/2),
- prec, UNIT (Pin->Mask),
- prec, UNIT ((Pin->Mask - Pin->Thickness)/2),
+ Pin->X, Pin->Y, Pin->Thickness,
+ Pin->DrillingHole,
+ Pin->Clearance / 2,
+ (Pin->Thickness - Pin->DrillingHole) / 2,
+ Pin->Mask,
+ (Pin->Mask - Pin->Thickness) / 2,
EMPTY (Pin->Name),
EMPTY (element->Name[1].TextString), EMPTY (Pin->Number),
TEST_FLAG (LOCKFLAG, Pin) ? "It is LOCKED.\n" : "");
@@ -242,22 +234,20 @@ ReportDialog (int argc, char **argv, int x, int y)
}
#endif
line = (LineTypePtr) ptr2;
- sprintf (&report[0], "LINE ID# %ld; Flags:%s\n"
- "FirstPoint(X,Y) = (%.*f, %.*f) %s, ID = %ld.\n"
- "SecondPoint(X,Y) = (%.*f, %.*f) %s, ID = %ld.\n"
- "Width = %0.*f %s.\nClearance width in polygons = %0.*f %s.\n"
+ pcb_sprintf (&report[0], "%m+LINE ID# %ld; Flags:%s\n"
+ "FirstPoint(X,Y) = %$mD, ID = %ld.\n"
+ "SecondPoint(X,Y) = %$mD, ID = %ld.\n"
+ "Width = %$mS.\nClearance width in polygons = %$mS.\n"
"It is on layer %d\n"
"and has name \"%s\".\n"
- "%s",
+ "%s", USER_UNITMASK,
line->ID, flags_to_string (line->Flags, LINE_TYPE),
- prec, units (line->Point1.X), prec, UNIT (line->Point1.Y),
- line->Point1.ID, prec, units (line->Point2.X), prec, UNIT (line->Point2.Y),
- line->Point2.ID, prec, UNIT (line->Thickness),
- prec, UNIT (line->Clearance / 2.), GetLayerNumber (PCB->Data,
- (LayerTypePtr) ptr1),
- UNKNOWN (line->Number), TEST_FLAG (LOCKFLAG,
- line) ? "It is LOCKED.\n" :
- "");
+ line->Point1.X, line->Point1.Y, line->Point1.ID,
+ line->Point2.X, line->Point2.Y, line->Point2.ID,
+ line->Thickness, line->Clearance / 2,
+ GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1),
+ UNKNOWN (line->Number),
+ TEST_FLAG (LOCKFLAG, line) ? "It is LOCKED.\n" : "");
break;
}
case RATLINE_TYPE:
@@ -271,15 +261,15 @@ ReportDialog (int argc, char **argv, int x, int y)
}
#endif
line = (RatTypePtr) ptr2;
- sprintf (&report[0], "RAT-LINE ID# %ld; Flags:%s\n"
- "FirstPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld; "
+ pcb_sprintf (&report[0], "%m+RAT-LINE ID# %ld; Flags:%s\n"
+ "FirstPoint(X,Y) = %$mD; ID = %ld; "
"connects to layer group %d.\n"
- "SecondPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld; "
+ "SecondPoint(X,Y) = %$mD; ID = %ld; "
"connects to layer group %d.\n",
- line->ID, flags_to_string (line->Flags, LINE_TYPE),
- prec, units (line->Point1.X), prec, UNIT (line->Point1.Y),
+ USER_UNITMASK, line->ID, flags_to_string (line->Flags, LINE_TYPE),
+ line->Point1.X, line->Point1.Y,
line->Point1.ID, line->group1,
- prec, units (line->Point2.X), prec, UNIT (line->Point2.Y),
+ line->Point2.X, line->Point2.Y,
line->Point2.ID, line->group2);
break;
}
@@ -298,24 +288,22 @@ ReportDialog (int argc, char **argv, int x, int y)
Arc = (ArcTypePtr) ptr2;
box = GetArcEnds (Arc);
- sprintf (&report[0], "ARC ID# %ld; Flags:%s\n"
- "CenterPoint(X,Y) = (%.*f, %.*f) %s.\n"
- "Radius = %0.*f %s, Thickness = %0.*f %s.\n"
- "Clearance width in polygons = %0.*f %s.\n"
+ pcb_sprintf (&report[0], "%m+ARC ID# %ld; Flags:%s\n"
+ "CenterPoint(X,Y) = %$mD.\n"
+ "Radius = %$mS, Thickness = %$mS.\n"
+ "Clearance width in polygons = %$mS.\n"
"StartAngle = %ld degrees, DeltaAngle = %ld degrees.\n"
- "Bounding Box is (%.*f,%.*f), (%.*f,%.*f) %s.\n"
- "That makes the end points at (%.*f,%.*f) %s and (%.*f,%.*f) %s.\n"
+ "Bounding Box is %$mD, %$mD.\n"
+ "That makes the end points at %$mD and %$mD.\n"
"It is on layer %d.\n"
- "%s", Arc->ID, flags_to_string (Arc->Flags, ARC_TYPE),
- prec, units(Arc->X), prec, UNIT(Arc->Y),
- prec, UNIT (Arc->Width), prec, UNIT (Arc->Thickness),
- prec, UNIT (Arc->Clearance / 2.), Arc->StartAngle, Arc->Delta,
- prec, units (Arc->BoundingBox.X1),
- prec, units (Arc->BoundingBox.Y1),
- prec, units (Arc->BoundingBox.X2),
- prec, UNIT (Arc->BoundingBox.Y2),
- prec, units (box->X1), prec, UNIT (box->Y1),
- prec, units (box->X2), prec, UNIT (box->Y2),
+ "%s", USER_UNITMASK, Arc->ID, flags_to_string (Arc->Flags, ARC_TYPE),
+ Arc->X, Arc->Y,
+ Arc->Width, Arc->Thickness,
+ Arc->Clearance / 2, Arc->StartAngle, Arc->Delta,
+ Arc->BoundingBox.X1, Arc->BoundingBox.Y1,
+ Arc->BoundingBox.X2, Arc->BoundingBox.Y2,
+ box->X1, box->Y1,
+ box->X2, box->Y2,
GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1),
TEST_FLAG (LOCKFLAG, Arc) ? "It is LOCKED.\n" : "");
break;
@@ -333,17 +321,15 @@ ReportDialog (int argc, char **argv, int x, int y)
#endif
Polygon = (PolygonTypePtr) ptr2;
- sprintf (&report[0], "POLYGON ID# %ld; Flags:%s\n"
- "Its bounding box is (%.*f,%.*f) (%.*f,%.*f) %s.\n"
+ pcb_sprintf (&report[0], "%m+POLYGON ID# %ld; Flags:%s\n"
+ "Its bounding box is %$mD %$mD.\n"
"It has %d points and could store %d more\n"
" without using more memory.\n"
"It has %d holes and resides on layer %d.\n"
- "%s", Polygon->ID,
+ "%s", USER_UNITMASK, Polygon->ID,
flags_to_string (Polygon->Flags, POLYGON_TYPE),
- prec, units(Polygon->BoundingBox.X1),
- prec, units(Polygon->BoundingBox.Y1),
- prec, units(Polygon->BoundingBox.X2),
- prec, UNIT(Polygon->BoundingBox.Y2),
+ Polygon->BoundingBox.X1, Polygon->BoundingBox.Y1,
+ Polygon->BoundingBox.X2, Polygon->BoundingBox.Y2,
Polygon->PointN, Polygon->PointMax - Polygon->PointN,
Polygon->HoleIndexN,
GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1),
@@ -352,7 +338,7 @@ ReportDialog (int argc, char **argv, int x, int y)
}
case PAD_TYPE:
{
- int len, dx, dy, mgap;
+ BDimension len;
PadTypePtr Pad;
ElementTypePtr element;
#ifndef NDEBUG
@@ -373,31 +359,25 @@ ReportDialog (int argc, char **argv, int x, int y)
}
}
END_LOOP;
- dx = Pad->Point1.X - Pad->Point2.X;
- dy = Pad->Point1.Y - Pad->Point2.Y;
- len = sqrt (dx*dx+dy*dy);
- mgap = (Pad->Mask - Pad->Thickness)/2;
- sprintf (&report[0], "PAD ID# %ld; Flags:%s\n"
- "FirstPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld.\n"
- "SecondPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld.\n"
- "Width = %0.*f %s. Length = %0.*f %s.\n"
- "Clearance width in polygons = %0.*f %s.\n"
- "Solder mask = %0.*f x %0.*f %s (gap = %0.*f %s).\n"
+ len = Distance (Pad->Point1.X, Pad->Point1.Y, Pad->Point2.X, Pad->Point2.Y);
+ pcb_sprintf (&report[0], "%m+PAD ID# %ld; Flags:%s\n"
+ "FirstPoint(X,Y) = %$mD; ID = %ld.\n"
+ "SecondPoint(X,Y) = %$mD; ID = %ld.\n"
+ "Width = %$mS. Length = %$mS.\n"
+ "Clearance width in polygons = %$mS.\n"
+ "Solder mask = %$mS x %$mS (gap = %$mS).\n"
"Name = \"%s\".\n"
"It is owned by SMD element %s\n"
" as pin number %s and is on the %s\n"
"side of the board.\n"
- "%s", Pad->ID,
+ "%s", USER_UNITMASK, Pad->ID,
flags_to_string (Pad->Flags, PAD_TYPE),
- prec, units (Pad->Point1.X),
- prec, UNIT (Pad->Point1.Y), Pad->Point1.ID,
- prec, units (Pad->Point2.X),
- prec, UNIT (Pad->Point2.Y), Pad->Point2.ID,
- prec, UNIT (Pad->Thickness),
- prec, UNIT (len + Pad->Thickness),
- prec, UNIT (Pad->Clearance / 2.),
- prec, units (Pad->Mask), prec, UNIT (Pad->Mask + len),
- prec, UNIT (mgap),
+ Pad->Point1.X, Pad->Point1.Y, Pad->Point1.ID,
+ Pad->Point2.X, Pad->Point2.Y, Pad->Point2.ID,
+ Pad->Thickness, len + Pad->Thickness,
+ Pad->Clearance / 2,
+ Pad->Mask, len + Pad->Mask,
+ (Pad->Mask - Pad->Thickness) / 2,
EMPTY (Pad->Name),
EMPTY (element->Name[1].TextString),
EMPTY (Pad->Number),
@@ -417,32 +397,27 @@ ReportDialog (int argc, char **argv, int x, int y)
}
#endif
element = (ElementTypePtr) ptr2;
- sprintf (&report[0], "ELEMENT ID# %ld; Flags:%s\n"
- "BoundingBox (%.*f,%.*f) (%.*f,%.*f) %s.\n"
+ pcb_sprintf (&report[0], "%m+ELEMENT ID# %ld; Flags:%s\n"
+ "BoundingBox %$mD %$mD.\n"
"Descriptive Name \"%s\".\n"
"Name on board \"%s\".\n"
"Part number name \"%s\".\n"
- "It is %.*f %s tall and is located at (X,Y) = (%.*f,%.*f)%s.\n"
- "Mark located at point (X,Y) = (%.*f,%.*f).\n"
+ "It is %$mS tall and is located at (X,Y) = %$mD %s.\n"
+ "Mark located at point (X,Y) = %$mD.\n"
"It is on the %s side of the board.\n"
- "%s",
+ "%s", USER_UNITMASK,
element->ID, flags_to_string (element->Flags, ELEMENT_TYPE),
- prec, units(element->BoundingBox.X1),
- prec, units (element->BoundingBox.Y1),
- prec, units(element->BoundingBox.X2),
- prec, UNIT (element->BoundingBox.Y2),
+ element->BoundingBox.X1, element->BoundingBox.Y1,
+ element->BoundingBox.X2, element->BoundingBox.Y2,
EMPTY (element->Name[0].TextString),
EMPTY (element->Name[1].TextString),
EMPTY (element->Name[2].TextString),
- prec, UNIT (0.45 * element->Name[1].Scale * 100.),
- prec, units(element->Name[1].X),
- prec, units(element->Name[1].Y),
- TEST_FLAG (HIDENAMEFLAG, element) ?
- ",\n but it's hidden" : "", prec, units(element->MarkX),
- prec, units(element->MarkY),
- TEST_FLAG (ONSOLDERFLAG, element) ? "solder (bottom)" :
- "component", TEST_FLAG (LOCKFLAG, element) ?
- "It is LOCKED.\n" : "");
+ (BDimension) (0.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,
+ TEST_FLAG (ONSOLDERFLAG, element) ? "solder (bottom)" : "component",
+ TEST_FLAG (LOCKFLAG, element) ? "It is LOCKED.\n" : "");
break;
}
case TEXT_TYPE:
@@ -470,21 +445,18 @@ ReportDialog (int argc, char **argv, int x, int y)
if (type == TEXT_TYPE)
sprintf (laynum, "It is on layer %d.",
GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1));
- sprintf (&report[0], "TEXT ID# %ld; Flags:%s\n"
- "Located at (X,Y) = (%.*f,%.*f) %s.\n"
- "Characters are %0.*f %s tall.\n"
+ pcb_sprintf (&report[0], "%m+TEXT ID# %ld; Flags:%s\n"
+ "Located at (X,Y) = %$mD.\n"
+ "Characters are %$mD tall.\n"
"Value is \"%s\".\n"
"Direction is %d.\n"
- "The bounding box is (%.*f,%.*f) (%.*f, %.*f) %s.\n"
+ "The bounding box is %$mD %$mD.\n"
"%s\n"
- "%s", text->ID, flags_to_string (text->Flags, TEXT_TYPE),
- prec, units(text->X), prec, UNIT (text->Y),
- prec, UNIT (0.45 * text->Scale * 100.),
+ "%s", USER_UNITMASK, text->ID, flags_to_string (text->Flags, TEXT_TYPE),
+ text->X, text->Y, (BDimension) (0.45 * text->Scale * 100),
text->TextString, text->Direction,
- prec, units(text->BoundingBox.X1),
- prec, units(text->BoundingBox.Y1),
- prec, units(text->BoundingBox.X2),
- prec, UNIT (text->BoundingBox.Y2),
+ text->BoundingBox.X1, text->BoundingBox.Y1,
+ text->BoundingBox.X2, text->BoundingBox.Y2,
(type == TEXT_TYPE) ? laynum : "It is an element name.",
TEST_FLAG (LOCKFLAG, text) ? "It is LOCKED.\n" : "");
break;
@@ -493,10 +465,10 @@ ReportDialog (int argc, char **argv, int x, int y)
case POLYGONPOINT_TYPE:
{
PointTypePtr point = (PointTypePtr) ptr2;
- sprintf (&report[0], "POINT ID# %ld.\n"
- "Located at (X,Y) = (%.*f,%.*f) %s.\n"
- "It belongs to a %s on layer %d.\n", point->ID,
- prec, units (point->X), prec, UNIT (point->Y),
+ pcb_sprintf (&report[0], "%m+POINT ID# %ld.\n"
+ "Located at (X,Y) = %$mD.\n"
+ "It belongs to a %s on layer %d.\n", USER_UNITMASK, point->ID,
+ point->X, point->Y,
(type == LINEPOINT_TYPE) ? "line" : "polygon",
GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1));
break;
@@ -607,42 +579,13 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
{
int ni;
int found;
- double length;
- int prec;
- double scale;
- const char *units_name;
-
- units_name = argv[0];
- if (argc < 1)
- units_name = Settings.grid_units_mm ? "mm" : "mil";
-
- if (strcmp (units_name, "mm") == 0)
- {
- prec = 4;
- scale = COORD_TO_MM(1);
- }
- else if (strcmp (units_name, "mil") == 0)
- {
- prec = 2;
- scale = COORD_TO_MIL(1);
- }
- else if (strcmp (units_name, "in") == 0)
- {
- prec = 5;
- scale = COORD_TO_INCH(1);
- }
- else
- {
- prec = 0;
- units_name = "pcb";
- scale = 1;
- }
for (ni = 0; ni < PCB->NetlistLib.MenuN; ni++)
{
char *netname = PCB->NetlistLib.Menu[ni].Name + 2;
char *ename = PCB->NetlistLib.Menu[ni].Entry[0].ListEntry;
char *pname;
+ bool got_one = 0;
ename = strdup (ename);
pname = strchr (ename, '-');
@@ -664,7 +607,8 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
{
x = pin->X;
y = pin->Y;
- goto got_one;
+ got_one = 1;
+ break;
}
}
END_LOOP;
@@ -674,7 +618,8 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
{
x = (pad->Point1.X + pad->Point2.X) / 2;
y = (pad->Point1.Y + pad->Point2.Y) / 2;
- goto got_one;
+ got_one = 1;
+ break;
}
}
END_LOOP;
@@ -682,17 +627,25 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
}
END_LOOP;
- continue;
-
- got_one:
- if (ResetConnections (true))
- Draw ();
- /* NB: XYtoNetLength calls LookupConnection, which performs an undo
- * serial number update, so we don't need to add one here.
- */
- length = XYtoNetLength (x, y, &found);
-
- gui->log("Net %s length %.*f %s\n", netname, prec, length*scale, units_name);
+ if (got_one)
+ {
+ char buf[50];
+ const char *units_name = argv[0];
+ BDimension length;
+
+ if (argc < 1)
+ units_name = (Settings.grid_units_mm ? "mm" : "mil");
+
+ if (ResetConnections (true))
+ Draw ();
+ /* NB: XYtoNetLength calls LookupConnection, which performs an undo
+ * serial number update, so we don't need to add one here.
+ */
+ length = XYtoNetLength (x, y, &found);
+
+ pcb_sprintf(buf, "%$m*", units_name, length);
+ gui->log("Net %s length %s\n", netname, buf);
+ }
}
return 0;
}
@@ -700,7 +653,7 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
static int
ReportNetLength (int argc, char **argv, int x, int y)
{
- double length = 0;
+ BDimension length = 0;
char *netname = 0;
int found = 0;
@@ -776,11 +729,12 @@ ReportNetLength (int argc, char **argv, int x, int y)
got_net_name:
{
- int prec = Settings.grid_units_mm? 4: 2;
+ char buf[50];
+ pcb_sprintf(buf, "%$m*", (Settings.grid_units_mm ? "mm" : "mil"), length);
if (netname)
- gui->log ("Net \"%s\" length: %.*f %s\n", netname, prec, UNIT (length));
+ gui->log ("Net \"%s\" length: %s\n", netname, buf);
else
- gui->log ("Net length: %.*f %s\n", prec, UNIT (length));
+ gui->log ("Net length: %s\n", buf);
}
return 0;
}
commit 5b4b82cb9e1e272e8f6a816922383be6cdbac701
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add %m+ specifier to pcb-printf
As long as our base units are cmils, allowing pcb-printf to guess
the most natural units for displaying measures is a bad idea -- it
cannot reliably count significant figures for many values. The
result, for example, in report.c, is inconsistent and confusing
dialogs with a mix of metric and imperial measurements.
The %m+ specifier is used to force pcb-printf to only use certain
units; in this case, the user's gui setting of metric/imperial.
diff --git a/src/pcb-printf.c b/src/pcb-printf.c
index 31a1e32..2ede73c 100644
--- a/src/pcb-printf.c
+++ b/src/pcb-printf.c
@@ -223,6 +223,8 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
GString *string = g_string_new ("");
GString *spec = g_string_new ("");
+ enum e_allow mask = ALLOW_ALL;
+
if (string == NULL || spec == NULL)
return NULL;
@@ -309,14 +311,15 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
++fmt;
if (*fmt == '*')
ext_unit = va_arg(args, const char *);
- value[0] = va_arg(args, BDimension);
+ if (*fmt != '+')
+ value[0] = va_arg(args, BDimension);
count = 1;
switch(*fmt)
{
case 's': unit_str = CoordsToString(value, 1, spec->str, ALLOW_MM | ALLOW_MIL, suffix); break;
- case 'S': unit_str = CoordsToString(value, 1, spec->str, ALLOW_ALL, suffix); break;
- case 'M': unit_str = CoordsToString(value, 1, spec->str, ALLOW_METRIC, suffix); break;
- case 'L': unit_str = CoordsToString(value, 1, spec->str, ALLOW_IMPERIAL, suffix); break;
+ case 'S': unit_str = CoordsToString(value, 1, spec->str, mask & ALLOW_ALL, suffix); break;
+ case 'M': unit_str = CoordsToString(value, 1, spec->str, mask & ALLOW_METRIC, suffix); break;
+ case 'L': unit_str = CoordsToString(value, 1, spec->str, mask & ALLOW_IMPERIAL, suffix); break;
case 'r': unit_str = CoordsToString(value, 1, spec->str, ALLOW_READABLE, FILE_MODE); break;
/* All these fallthroughs are deliberate */
case '9': value[count++] = va_arg(args, BDimension);
@@ -329,7 +332,7 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
case '2':
case 'D':
value[count++] = va_arg(args, BDimension);
- unit_str = CoordsToString(value, count, spec->str, ALLOW_ALL, suffix);
+ unit_str = CoordsToString(value, count, spec->str, mask & ALLOW_ALL, suffix);
break;
case 'd':
value[1] = va_arg(args, BDimension);
@@ -340,7 +343,10 @@ static gchar *pcb_vprintf(const char *fmt, va_list args)
if (strcmp (ext_unit, Units[i].suffix) == 0)
unit_str = CoordsToString(value, 1, spec->str, Units[i].allow, suffix);
if (unit_str == NULL)
- unit_str = CoordsToString(value, 1, spec->str, ALLOW_ALL, suffix);
+ unit_str = CoordsToString(value, 1, spec->str, mask & ALLOW_ALL, suffix);
+ break;
+ case '+':
+ mask = va_arg(args, enum e_allow);
break;
default:
for (i = 0; i < N_UNITS; ++i)
diff --git a/src/pcb-printf.h b/src/pcb-printf.h
index 03aa978..2992d1b 100644
--- a/src/pcb-printf.h
+++ b/src/pcb-printf.h
@@ -47,6 +47,9 @@
* %m9 output 9 measures in most natural scaled units
* %m* output a measure with unit given as an additional
* const char* parameter
+ * %m+ accepts an e_allow parameter that masks all subsequent
+ * "natural" (S/D/3/.../9) specifiers to only use certain
+ * units
* %mr output a measure in a unit readable by parse_l.l
* (this will always append a unit suffix)
*
commit f2f9f2beb86f0dd8ff262f18094598c7a621feb4
Author: Andrew Poelstra <as...@sf...>
Commit: Andrew Poelstra <as...@sf...>
Add Distance() function to avoid overflow with sqrt(x*x + y*y)
diff --git a/src/misc.c b/src/misc.c
index e505047..ce2ab4a 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -104,6 +104,17 @@ static struct
int cnt;
} SavedStack;
+/* Distance() should be used so that there is only one
+ * place to deal with overflow/precision errors
+ */
+double
+Distance (double x1, double y1, double x2, double y2)
+{
+ double delta_x = (x2 - x1);
+ double delta_y = (y2 - y1);
+ return sqrt(delta_x * delta_x + delta_y * delta_y);
+}
+
/* Get Value returns a numeric value passed from the string and sets the
* bool variable absolute to false if it leads with a +/- character
*/
diff --git a/src/misc.h b/src/misc.h
index fb303d6..45d6e52 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -43,6 +43,8 @@ typedef struct {
enum unitflags flags;
} UnitList[];
+double Distance (double x1, double y1, double x2, double y2);
+
void r_delete_element (DataTypePtr, ElementTypePtr);
void SetLineBoundingBox (LineTypePtr);
void SetArcBoundingBox (ArcTypePtr);
|