[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-145-g1626b1a)
The branch, master has been updated
via 1626b1a02a6e55327ac7f2d00dd976aba57855d7 (commit)
via 6079c8102f6ac41ce5bf2a61aef6d65e7bb9df4b (commit)
via 4a217cd1109b03f6d5f75f9fca46513d7679ddb6 (commit)
from 39d552cd16af51eaae793f3837bb1f77fac0723f (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
=========
gschem/include/prototype.h | 14 ++-
gschem/src/a_zoom.c | 12 +--
gschem/src/gschem_cairo.c | 250 ++++++++++++++++++++++++++++++++++----------
gschem/src/m_basic.c | 41 ++------
gschem/src/o_arc.c | 115 ++++++---------------
gschem/src/o_box.c | 93 +++++------------
gschem/src/o_bus.c | 89 +++++-----------
gschem/src/o_circle.c | 126 ++++++----------------
gschem/src/o_cue.c | 70 +++++--------
gschem/src/o_grips.c | 15 ++--
gschem/src/o_line.c | 93 +++++------------
gschem/src/o_net.c | 112 +++++++-------------
gschem/src/o_path.c | 85 +++++----------
gschem/src/o_picture.c | 49 ++++------
gschem/src/o_pin.c | 69 ++++--------
gschem/src/o_place.c | 10 +-
gschem/src/o_select.c | 13 +--
gschem/src/o_text.c | 11 +-
gschem/src/x_grid.c | 2 +-
19 files changed, 515 insertions(+), 754 deletions(-)
=================
Commit Messages
=================
commit 1626b1a02a6e55327ac7f2d00dd976aba57855d7
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon Jan 5 04:44:24 2009 +0000
gschem: Clamp minimum size to draw stoke dots using cairo, apply hinting
Since cairo uses antialiased drawings, a dot of diameter 1px will actually
render ligher than it would have with GDK. Once the line width reaches 1px
switch back to drawing dots as squares.
Also add hinting to the position of the drawn dots drawn along the stroke
to ensure they land centered on pixels.
:100644 100644 f0d22a7... 5ea3298... M gschem/src/gschem_cairo.c
commit 6079c8102f6ac41ce5bf2a61aef6d65e7bb9df4b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon Jan 5 04:23:24 2009 +0000
gschem: Make gschem_cairo_* functions take parameters in world coordinates.
This changes the prototype of all gschem_cairo_* functions to take a
GSCHEM_TOPLEVEL parameter rather than cairo_t as their first argument.
This change cuts down a significant number of lines of code, and also
paves the way to having world-coordinates passed straight into the cairo
routines, should we want to use cairo for printing at some stage.
A few cases of direct cairo usage in screen coordinates remain; these are
in o_cue.c, and x_grid.c. The case in o_cue.c remains because it relates
to a filled box. gschem_cairo_box () hints the path coordinates for a
stroked box and clamps the minimum on-screen stroke width to 1px, thus
rendering it unsuitable for hinting a path to be filled.
:100644 100644 689eed4... ddf5481... M gschem/include/prototype.h
:100644 100644 5b32c34... 5f699aa... M gschem/src/a_zoom.c
:100644 100644 df79e50... f0d22a7... M gschem/src/gschem_cairo.c
:100644 100644 0e02b8c... a92b246... M gschem/src/m_basic.c
:100644 100644 7eba7ec... 5a11ab2... M gschem/src/o_arc.c
:100644 100644 b4b19d0... a24bbf3... M gschem/src/o_box.c
:100644 100644 9b1d87e... 559048c... M gschem/src/o_bus.c
:100644 100644 2c91c91... 33aece6... M gschem/src/o_circle.c
:100644 100644 ccb527e... f81abe6... M gschem/src/o_cue.c
:100644 100644 192df28... d6db1bb... M gschem/src/o_grips.c
:100644 100644 4bc4d5b... c01c99d... M gschem/src/o_line.c
:100644 100644 41f05ca... 48da07c... M gschem/src/o_net.c
:100644 100644 58115ab... 4bce0f8... M gschem/src/o_path.c
:100644 100644 ca26de5... 00caae2... M gschem/src/o_picture.c
:100644 100644 55771d6... 9162551... M gschem/src/o_pin.c
:100644 100644 2001801... 622af0e... M gschem/src/o_place.c
:100644 100644 6617b62... a844755... M gschem/src/o_select.c
:100644 100644 ba59787... a3ef176... M gschem/src/o_text.c
:100644 100644 a98c168... 2e705cf... M gschem/src/x_grid.c
commit 4a217cd1109b03f6d5f75f9fca46513d7679ddb6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon Jan 5 03:36:25 2009 +0000
gschem: Add new primitves to draw a centered arc and box
These primitives take care of hinting specifically to keep the drawn
object looking centered, adjusting to take into account both the
radius / extents of the object being drawn, and how the object we're
trying to center on would have been hinted.
Use these new primitives for drawing cues and grip boxes.
:100644 100644 49915fd... 689eed4... M gschem/include/prototype.h
:100644 100644 4d18239... df79e50... M gschem/src/gschem_cairo.c
:100644 100644 b3c2529... ccb527e... M gschem/src/o_cue.c
:100644 100644 4673e7b... 192df28... M gschem/src/o_grips.c
=========
Changes
=========
commit 1626b1a02a6e55327ac7f2d00dd976aba57855d7
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon Jan 5 04:44:24 2009 +0000
gschem: Clamp minimum size to draw stoke dots using cairo, apply hinting
Since cairo uses antialiased drawings, a dot of diameter 1px will actually
render ligher than it would have with GDK. Once the line width reaches 1px
switch back to drawing dots as squares.
Also add hinting to the position of the drawn dots drawn along the stroke
to ensure they land centered on pixels.
diff --git a/gschem/src/gschem_cairo.c b/gschem/src/gschem_cairo.c
index f0d22a7..5ea3298 100644
--- a/gschem/src/gschem_cairo.c
+++ b/gschem/src/gschem_cairo.c
@@ -257,6 +257,7 @@ void gschem_cairo_stroke (GSCHEM_TOPLEVEL *w_current, int line_type, int line_en
{
double dashes[4];
cairo_line_cap_t cap;
+ cairo_line_cap_t round_cap_if_legible;
int num_dashes;
int width, length, space;
@@ -267,10 +268,13 @@ void gschem_cairo_stroke (GSCHEM_TOPLEVEL *w_current, int line_type, int line_en
cairo_set_line_width (w_current->cr, width);
cairo_set_line_join (w_current->cr, CAIRO_LINE_JOIN_MITER);
+ round_cap_if_legible = (width <= 0) ? CAIRO_LINE_CAP_SQUARE :
+ CAIRO_LINE_CAP_ROUND;
+
switch (line_end) {
case END_NONE: cap = CAIRO_LINE_CAP_BUTT; break;
case END_SQUARE: cap = CAIRO_LINE_CAP_SQUARE; break;
- case END_ROUND: cap = CAIRO_LINE_CAP_ROUND; break;
+ case END_ROUND: cap = round_cap_if_legible; break;
default:
fprintf(stderr, _("Unknown end for line (%d)\n"), line_end);
cap = CAIRO_LINE_CAP_BUTT;
@@ -297,7 +301,7 @@ void gschem_cairo_stroke (GSCHEM_TOPLEVEL *w_current, int line_type, int line_en
num_dashes = 2;
cairo_set_dash (w_current->cr, dashes, num_dashes, 0.);
- cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_cap (w_current->cr, round_cap_if_legible);
cairo_stroke (w_current->cr);
break;
@@ -325,7 +329,7 @@ void gschem_cairo_stroke (GSCHEM_TOPLEVEL *w_current, int line_type, int line_en
num_dashes = 2;
cairo_set_dash (w_current->cr, dashes, num_dashes, -length - space);
- cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_cap (w_current->cr, round_cap_if_legible);
cairo_stroke (w_current->cr);
break;
@@ -345,7 +349,7 @@ void gschem_cairo_stroke (GSCHEM_TOPLEVEL *w_current, int line_type, int line_en
num_dashes = 4;
cairo_set_dash (w_current->cr, dashes, num_dashes, -length - space);
- cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_cap (w_current->cr, round_cap_if_legible);
cairo_stroke (w_current->cr);
break;
}
commit 6079c8102f6ac41ce5bf2a61aef6d65e7bb9df4b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon Jan 5 04:23:24 2009 +0000
gschem: Make gschem_cairo_* functions take parameters in world coordinates.
This changes the prototype of all gschem_cairo_* functions to take a
GSCHEM_TOPLEVEL parameter rather than cairo_t as their first argument.
This change cuts down a significant number of lines of code, and also
paves the way to having world-coordinates passed straight into the cairo
routines, should we want to use cairo for printing at some stage.
A few cases of direct cairo usage in screen coordinates remain; these are
in o_cue.c, and x_grid.c. The case in o_cue.c remains because it relates
to a filled box. gschem_cairo_box () hints the path coordinates for a
stroked box and clamps the minimum on-screen stroke width to 1px, thus
rendering it unsuitable for hinting a path to be filled.
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 689eed4..ddf5481 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -283,13 +283,13 @@ void gschem_quit(void);
void main_prog(void *closure, int argc, char *argv[]);
int main(int argc, char *argv[]);
/* gschem_cairo.c */
-void gschem_cairo_line(cairo_t *cr, int line_end, int line_width, int x1, int y1, int x2, int y2);
-void gschem_cairo_box(cairo_t *cr, int line_width, int x1, int y1, int x2, int y2);
-void gschem_cairo_center_box(cairo_t *cr, int center_width, int line_width, int x1, int y1, int x2, int y2);
-void gschem_cairo_arc(cairo_t *cr, int line_width, double x, double y, double radius, int start_angle, int end_angle);
-void gschem_cairo_center_arc(cairo_t *cr, int center_width, int line_width, int x, int y, int radius, int start_angle, int end_angle);
-void gschem_cairo_stroke(cairo_t *cr, int line_type, int line_end, int width, int length, int space);
-void gschem_cairo_set_source_color(cairo_t *cr, COLOR *color);
+void gschem_cairo_line(GSCHEM_TOPLEVEL *w_current, int line_end, int line_width, int x1, int y1, int x2, int y2);
+void gschem_cairo_box(GSCHEM_TOPLEVEL *w_current, int line_width, int x1, int y1, int x2, int y2);
+void gschem_cairo_center_box(GSCHEM_TOPLEVEL *w_current, int center_width, int line_width, int x1, int y1, int x2, int y2);
+void gschem_cairo_arc(GSCHEM_TOPLEVEL *w_current, int line_width, int x, int y, int radius, int start_angle, int end_angle);
+void gschem_cairo_center_arc(GSCHEM_TOPLEVEL *w_current, int center_width, int line_width, int x, int y, int radius, int start_angle, int end_angle);
+void gschem_cairo_stroke(GSCHEM_TOPLEVEL *w_current, int line_type, int line_end, int width, int length, int space);
+void gschem_cairo_set_source_color(GSCHEM_TOPLEVEL *w_current, COLOR *color);
/* i_basic.c */
void i_show_state(GSCHEM_TOPLEVEL *w_current, const char *message);
void i_set_state(GSCHEM_TOPLEVEL *w_current, enum x_states newstate);
@@ -464,7 +464,7 @@ void SCREENtoWORLD(GSCHEM_TOPLEVEL *w_current, int mx, int my, int *x, int *y);
int snap_grid(GSCHEM_TOPLEVEL *w_current, int input);
int SCREENabs(GSCHEM_TOPLEVEL *w_current, int val);
int WORLDabs(GSCHEM_TOPLEVEL *w_current, int val);
-int SCREENclip_change(GSCHEM_TOPLEVEL *w_current, int *x1, int *y1, int *x2, int *y2);
+int WORLDclip_change(GSCHEM_TOPLEVEL *w_current, int *x1, int *y1, int *x2, int *y2);
int clip_nochange(GSCHEM_TOPLEVEL *w_current, int x1, int y1, int x2, int y2);
int visible(GSCHEM_TOPLEVEL *w_current, int wleft, int wtop, int wright, int wbottom);
double round_5_2_1(double unrounded);
diff --git a/gschem/src/a_zoom.c b/gschem/src/a_zoom.c
index 5b32c34..5f699aa 100644
--- a/gschem/src/a_zoom.c
+++ b/gschem/src/a_zoom.c
@@ -299,16 +299,12 @@ void a_zoom_box_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void a_zoom_box_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- int x1, y1, x2, y2;
-
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy, &x2, &y2);
-
- gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
+ gschem_cairo_box (w_current, 1, w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (ZOOM_BOX_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \todo Finish function documentation!!!
diff --git a/gschem/src/gschem_cairo.c b/gschem/src/gschem_cairo.c
index df79e50..f0d22a7 100644
--- a/gschem/src/gschem_cairo.c
+++ b/gschem/src/gschem_cairo.c
@@ -31,17 +31,30 @@
#endif
-void gschem_cairo_line (cairo_t *cr, int line_end, int line_width,
- int x1, int y1, int x2, int y2)
+static inline int screen_width (GSCHEM_TOPLEVEL *w_current, int w_width)
{
- double offset = ((line_width % 2) == 0) ? 0 : 0.5;
+ int width = SCREENabs (w_current, w_width);
+ if (width < 1)
+ width = 1;
+
+ return width;
+}
+
+void gschem_cairo_line (GSCHEM_TOPLEVEL *w_current, int line_end,
+ int w_line_width,
+ int w_x1, int w_y1, int w_x2, int w_y2)
+{
+ int x1, y1, x2, y2, line_width;
+ double offset;
double xoffset = 0;
double yoffset = 0;
int horizontal = 0;
int vertical = 0;
- if (line_width == 0)
- return;
+ WORLDtoSCREEN (w_current, w_x1, w_y1, &x1, &y1);
+ WORLDtoSCREEN (w_current, w_x2, w_y2, &x2, &y2);
+ line_width = screen_width (w_current, w_line_width);
+ offset = ((line_width % 2) == 0) ? 0 : 0.5;
if (y1 == y2) horizontal = 1;
if (x1 == x2) vertical = 1;
@@ -80,15 +93,22 @@ void gschem_cairo_line (cairo_t *cr, int line_end, int line_width,
break;
}
- cairo_move_to (cr, x1 + xoffset, y1 + yoffset);
- cairo_line_to (cr, x2 + xoffset, y2 + yoffset);
+ cairo_move_to (w_current->cr, x1 + xoffset, y1 + yoffset);
+ cairo_line_to (w_current->cr, x2 + xoffset, y2 + yoffset);
}
-void gschem_cairo_box (cairo_t *cr, int line_width,
+void gschem_cairo_box (GSCHEM_TOPLEVEL *w_current, int line_width,
int x1, int y1, int x2, int y2)
{
- double offset = (line_width == -1 || (line_width % 2) == 0) ? 0 : 0.5;
+ int s_line_width;
+ int s_x1, s_y1, s_x2, s_y2;
+ double offset;
+
+ WORLDtoSCREEN (w_current, x1, y1, &s_x1, &s_y1);
+ WORLDtoSCREEN (w_current, x2, y2, &s_x2, &s_y2);
+ s_line_width = screen_width (w_current, line_width);
+ offset = (line_width == -1 || (s_line_width % 2) == 0) ? 0 : 0.5;
/* Allow filled boxes (inferred from line_width == -1)
* to touch an extra pixel, so the filled span is inclusive */
@@ -97,31 +117,40 @@ void gschem_cairo_box (cairo_t *cr, int line_width,
if (y1 > y2) y1 += 1; else y2 += 1;
}
- cairo_move_to (cr, x2 + offset, y2 + offset);
- cairo_line_to (cr, x1 + offset, y2 + offset);
- cairo_line_to (cr, x1 + offset, y1 + offset);
- cairo_line_to (cr, x2 + offset, y1 + offset);
- cairo_close_path (cr);
+ cairo_move_to (w_current->cr, s_x2 + offset, s_y2 + offset);
+ cairo_line_to (w_current->cr, s_x1 + offset, s_y2 + offset);
+ cairo_line_to (w_current->cr, s_x1 + offset, s_y1 + offset);
+ cairo_line_to (w_current->cr, s_x2 + offset, s_y1 + offset);
+ cairo_close_path (w_current->cr);
}
-void gschem_cairo_center_box (cairo_t *cr,
- int s_center_width,
- int s_line_width, int s_x, int s_y,
- int s_half_width, int s_half_height)
+void gschem_cairo_center_box (GSCHEM_TOPLEVEL *w_current,
+ int center_width,
+ int line_width, int x, int y,
+ int half_width, int half_height)
{
+ int s_center_width, s_line_width;
+ int s_half_width, s_half_height;
+ int s_x, s_y;
int even_center_width;
int even_line_width;
double x1, y1, x2, y2;
double center_offset, radius_offset;
+ WORLDtoSCREEN (w_current, x, y, &s_x, &s_y);
+ s_half_width = SCREENabs (w_current, half_width);
+ s_half_height = SCREENabs (w_current, half_height);
+
/* Hint the center of the box based on where a line
* of thickness center_width (world) would drawn */
- even_center_width = (s_center_width == -1 || (s_center_width % 2) == 0);
+ s_center_width = screen_width (w_current, center_width);
+ even_center_width = (center_width == -1 || (s_center_width % 2) == 0);
center_offset = even_center_width ? 0. : 0.5;
/* Hint the half-widths to land the stroke on the pixel grid */
- even_line_width = (s_line_width == -1 || (s_line_width % 2) == 0);
+ s_line_width = screen_width (w_current, line_width);
+ even_line_width = (line_width == -1 || (s_line_width % 2) == 0);
radius_offset = (even_center_width == even_line_width) ? 0. : 0.5;
x1 = (double) s_x + center_offset - s_half_width - radius_offset;
@@ -131,15 +160,15 @@ void gschem_cairo_center_box (cairo_t *cr,
/* Allow filled boxes (inferred from line_width == -1)
* to touch an extra pixel, so the filled span is inclusive */
- if (s_line_width == -1) {
+ if (line_width == -1) {
x2 += 1; y2 += 1;
}
- cairo_move_to (cr, x2, y2);
- cairo_line_to (cr, x1, y2);
- cairo_line_to (cr, x1, y1);
- cairo_line_to (cr, x2, y1);
- cairo_close_path (cr);
+ cairo_move_to (w_current->cr, x2, y2);
+ cairo_line_to (w_current->cr, x1, y2);
+ cairo_line_to (w_current->cr, x1, y1);
+ cairo_line_to (w_current->cr, x2, y1);
+ cairo_close_path (w_current->cr);
}
@@ -157,51 +186,86 @@ static inline void do_arc (cairo_t *cr, double x, double y, double radius,
}
-void gschem_cairo_arc (cairo_t *cr, int line_width, double x, double y,
- double radius, int start_angle, int end_angle)
+void gschem_cairo_arc (GSCHEM_TOPLEVEL *w_current,
+ int width, int x, int y,
+ int radius, int start_angle, int end_angle)
{
- double offset = ((line_width % 2) == 0) ? 0 : 0.5;
+ int s_width;
+ int x1, y1, x2, y2;
+ double s_x, s_y, s_radius;
+ double offset;
- do_arc (cr, x + offset, y + offset, radius, start_angle, end_angle);
+ WORLDtoSCREEN (w_current, x - radius, y + radius, &x1, &y1);
+ WORLDtoSCREEN (w_current, x + radius, y - radius, &x2, &y2);
+ s_width = screen_width (w_current, width);
+ offset = ((s_width % 2) == 0) ? 0 : 0.5;
+
+ s_x = (double)(x1 + x2) / 2.;
+ s_y = (double)(y1 + y2) / 2.;
+ s_radius = (double)(y2 - y1) / 2.;
+
+ cairo_save (w_current->cr);
+ cairo_translate (w_current->cr, s_x + offset, s_y + offset);
+
+ /* Adjust for non-uniform X/Y scale factor. Note that the + 1
+ allows for the case where x2 == x1 or y2 == y1 */
+ cairo_scale (w_current->cr, (double)(x2 - x1 + 1) /
+ (double)(y2 - y1 + 1), 1.);
+
+ do_arc (w_current->cr, 0., 0., (double) s_radius, start_angle, end_angle);
+
+ cairo_restore (w_current->cr);
}
-void gschem_cairo_center_arc (cairo_t *cr,
- int s_center_width,
- int s_line_width, int s_x, int s_y,
- int s_radius, int start_angle, int end_angle)
+void gschem_cairo_center_arc (GSCHEM_TOPLEVEL *w_current,
+ int center_width,
+ int line_width, int x, int y,
+ int radius, int start_angle, int end_angle)
{
+ int s_center_width, s_line_width;
+ int s_x, s_y, s_radius;
int even_center_width;
int even_line_width;
double center_offset, radius_offset;
+ WORLDtoSCREEN (w_current, x, y, &s_x, &s_y);
+ s_radius = SCREENabs (w_current, radius);
+
/* Hint the center of the arc based on where a line
* of thickness center_width (world) would drawn */
- even_center_width = (s_center_width == -1 || (s_center_width % 2) == 0);
+ s_center_width = screen_width (w_current, center_width);
+ even_center_width = (center_width == -1 || (s_center_width % 2) == 0);
center_offset = even_center_width ? 0. : 0.5;
/* Hint the radius to land its extermity on the pixel grid */
- even_line_width = (s_line_width == -1 || (s_line_width % 2) == 0);
+ s_line_width = screen_width (w_current, line_width);
+ even_line_width = (line_width == -1 || (s_line_width % 2) == 0);
/* radius_offset = (even_center_width == even_line_width) ? 0. : 0.5; */
/* Don't hint the radius, it makes things look strange when drawing cues */
radius_offset = 0.;
- do_arc (cr, (double) s_x + center_offset,
- (double) s_y + center_offset,
- (double) s_radius + radius_offset,
- start_angle, end_angle);
+ do_arc (w_current->cr, (double) s_x + center_offset,
+ (double) s_y + center_offset,
+ (double) s_radius + radius_offset,
+ start_angle, end_angle);
}
-void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
- int width, int length, int space)
+void gschem_cairo_stroke (GSCHEM_TOPLEVEL *w_current, int line_type, int line_end,
+ int wwidth, int wlength, int wspace)
{
double dashes[4];
cairo_line_cap_t cap;
int num_dashes;
+ int width, length, space;
+
+ width = screen_width (w_current, wwidth);
+ length = SCREENabs (w_current, wlength);
+ space = SCREENabs (w_current, wspace);
- cairo_set_line_width (cr, width);
- cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+ cairo_set_line_width (w_current->cr, width);
+ cairo_set_line_join (w_current->cr, CAIRO_LINE_JOIN_MITER);
switch (line_end) {
case END_NONE: cap = CAIRO_LINE_CAP_BUTT; break;
@@ -222,9 +286,9 @@ void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
case TYPE_SOLID:
num_dashes = 0;
- cairo_set_dash (cr, dashes, num_dashes, 0.);
- cairo_set_line_cap (cr, cap);
- cairo_stroke (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, 0.);
+ cairo_set_line_cap (w_current->cr, cap);
+ cairo_stroke (w_current->cr);
break;
case TYPE_DOTTED:
@@ -232,9 +296,9 @@ void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
dashes[1] = space;
num_dashes = 2;
- cairo_set_dash (cr, dashes, num_dashes, 0.);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_stroke (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, 0.);
+ cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke (w_current->cr);
break;
case TYPE_DASHED:
@@ -242,9 +306,9 @@ void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
dashes[1] = space;
num_dashes = 2;
- cairo_set_dash (cr, dashes, num_dashes, 0.);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
- cairo_stroke (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, 0.);
+ cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_BUTT);
+ cairo_stroke (w_current->cr);
break;
case TYPE_CENTER:
@@ -252,17 +316,17 @@ void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
dashes[1] = 2 * space;
num_dashes = 2;
- cairo_set_dash (cr, dashes, num_dashes, 0.);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
- cairo_stroke_preserve (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, 0.);
+ cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_BUTT);
+ cairo_stroke_preserve (w_current->cr);
dashes[0] = 0; /* DOT */
dashes[1] = 2 * space + length;
num_dashes = 2;
- cairo_set_dash (cr, dashes, num_dashes, -length - space);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_stroke (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, -length - space);
+ cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke (w_current->cr);
break;
case TYPE_PHANTOM:
@@ -270,9 +334,9 @@ void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
dashes[1] = 3 * space;
num_dashes = 2;
- cairo_set_dash (cr, dashes, num_dashes, 0.);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
- cairo_stroke_preserve (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, 0.);
+ cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_BUTT);
+ cairo_stroke_preserve (w_current->cr);
dashes[0] = 0; /* DOT */
dashes[1] = space;
@@ -280,20 +344,20 @@ void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
dashes[3] = 2 * space + length;
num_dashes = 4;
- cairo_set_dash (cr, dashes, num_dashes, -length - space);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_stroke (cr);
+ cairo_set_dash (w_current->cr, dashes, num_dashes, -length - space);
+ cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke (w_current->cr);
break;
}
- cairo_set_dash (cr, NULL, 0, 0.);
+ cairo_set_dash (w_current->cr, NULL, 0, 0.);
}
-void gschem_cairo_set_source_color (cairo_t *cr, COLOR *color)
+void gschem_cairo_set_source_color (GSCHEM_TOPLEVEL *w_current, COLOR *color)
{
- cairo_set_source_rgba (cr, (double)color->r / 255.0,
- (double)color->g / 255.0,
- (double)color->b / 255.0,
- (double)color->a / 255.0);
+ cairo_set_source_rgba (w_current->cr, (double)color->r / 255.0,
+ (double)color->g / 255.0,
+ (double)color->b / 255.0,
+ (double)color->a / 255.0);
}
diff --git a/gschem/src/m_basic.c b/gschem/src/m_basic.c
index 0e02b8c..a92b246 100644
--- a/gschem/src/m_basic.c
+++ b/gschem/src/m_basic.c
@@ -309,27 +309,6 @@ struct st_halfspace {
* encode_halfspace and clip are part of the cohen-sutherland clipping
* algorithm. They are used to determine if an object is visible or not
*/
-/*! \brief Encode SCREEN coordinates as halfspace matrix.
- * \par Function Description
- * This function takes a point and checks if it is in the bounds
- * of the current TOPLEVEL object's page coordinates. It
- * handles points with SCREEN coordinates.
- *
- * \param [in] w_current The GSCHEM_TOPLEVEL object.
- * \param [in] point The point in SCREEN coordinates to be checked.
- * \param [out] halfspace The created HALFSPACE structure.
- *
- * \warning halfspace must be allocated before this function is called
- */
-static void SCREENencode_halfspace (GSCHEM_TOPLEVEL *w_current,
- sPOINT *point, HALFSPACE *halfspace)
-{
- halfspace->left = point->x < 0;
- halfspace->right = point->x > w_current->toplevel->width;
- halfspace->bottom = point->y > w_current->toplevel->height;
- halfspace->top = point->y < 0;
-}
-
/*! \brief Encode WORLD coordinates as halfspace matrix.
* \par Function Description
* This function takes a point and checks if it is in the bounds
@@ -356,7 +335,7 @@ static void WORLDencode_halfspace (GSCHEM_TOPLEVEL *w_current,
* This function will check the provided set of coordinates to see if
* they fall within a clipping region. If they do the coordinates will
* be changed to reflect only the region no covered by the clipping window.
- * All coordinates should be in SCREEN units.
+ * All coordinates should be in WORLD units.
*
* \param [in] w_current The GSCHEM_TOPLEVEL object.
* \param [in,out] x1 x coordinate of the first screen point.
@@ -365,8 +344,8 @@ static void WORLDencode_halfspace (GSCHEM_TOPLEVEL *w_current,
* \param [in,out] y2 y coordinate of the second screen point.
* \return TRUE if coordinates are now visible, FALSE otherwise.
*/
-int SCREENclip_change (GSCHEM_TOPLEVEL *w_current,
- int *x1, int *y1, int *x2, int *y2)
+int WORLDclip_change (GSCHEM_TOPLEVEL *w_current,
+ int *x1, int *y1, int *x2, int *y2)
{
HALFSPACE half1, half2;
HALFSPACE tmp_half;
@@ -382,19 +361,17 @@ int SCREENclip_change (GSCHEM_TOPLEVEL *w_current,
point2.x = *x2;
point2.y = *y2;
-
- w_l = 0;
- w_t = 0;
- w_r = w_current->toplevel->width;
- w_b = w_current->toplevel->height;
-
+ w_l = w_current->toplevel->page_current->left;
+ w_t = w_current->toplevel->page_current->top;
+ w_r = w_current->toplevel->page_current->right;
+ w_b = w_current->toplevel->page_current->bottom;
done = FALSE;
visible = FALSE;
do {
- SCREENencode_halfspace (w_current, &point1, &half1);
- SCREENencode_halfspace (w_current, &point2, &half2);
+ WORLDencode_halfspace (w_current, &point1, &half1);
+ WORLDencode_halfspace (w_current, &point2, &half2);
#if DEBUG
printf("starting loop\n");
diff --git a/gschem/src/o_arc.c b/gschem/src/o_arc.c
index 7eba7ec..5a11ab2 100644
--- a/gschem/src/o_arc.c
+++ b/gschem/src/o_arc.c
@@ -28,40 +28,6 @@
#endif
-static void arc_path (GSCHEM_TOPLEVEL *w_current, OBJECT *object)
-{
- ARC *arc = object->arc;
- int line_width;
- int sx1, sy1, sx2, sy2;
- double cx, cy;
- double radius;
-
- WORLDtoSCREEN (w_current, arc->x - arc->width / 2,
- arc->y + arc->height / 2, &sx1, &sy1);
- WORLDtoSCREEN (w_current, arc->x + arc->width / 2,
- arc->y - arc->height / 2, &sx2, &sy2);
- line_width = SCREENabs (w_current, object->line_width);
- if (line_width <= 0) {
- line_width = 1;
- }
-
- cx = (double)(sx1 + sx2) / 2.;
- cy = (double)(sy1 + sy2) / 2.;
- radius = (double)(sy2 - sy1) / 2.;
-
- cairo_translate (w_current->cr, cx, cy);
-
- /* Adjust for non-uniform X/Y scale factor. Note that the + 1
- allows for the case where sx2 == sx1 or sy2 == sy1 */
- cairo_scale (w_current->cr, (double)(sx2 - sx1 + 1) /
- (double)(sy2 - sy1 + 1), 1.);
-
- gschem_cairo_arc (w_current->cr, line_width, 0., 0., radius,
- arc->start_angle, arc->end_angle);
- cairo_identity_matrix (w_current->cr);
-}
-
-
/*! \brief Draw an arc on the screen.
* \par Function Description
* This function is used to draw an arc on screen. The arc is described
@@ -78,9 +44,7 @@ static void arc_path (GSCHEM_TOPLEVEL *w_current, OBJECT *object)
void o_arc_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int line_width;
COLOR *color;
- int length, space;
if (o_current->arc == NULL) {
return;
@@ -94,19 +58,19 @@ void o_arc_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
else
color = x_color_lookup (o_current->color);
- line_width = SCREENabs (w_current, o_current->line_width);
- if(line_width <= 0) {
- line_width = 1;
- }
-
- length = SCREENabs (w_current, o_current->line_length);
- space = SCREENabs (w_current, o_current->line_space);
-
- arc_path (w_current, o_current);
+ gschem_cairo_arc (w_current, o_current->line_width,
+ o_current->arc->x,
+ o_current->arc->y,
+ o_current->arc->width / 2,
+ o_current->arc->start_angle,
+ o_current->arc->end_angle);
- gschem_cairo_set_source_color (w_current->cr, color);
- gschem_cairo_stroke (w_current->cr, o_current->line_type,
- o_current->line_end, line_width, length, space);
+ gschem_cairo_set_source_color (w_current, color);
+ gschem_cairo_stroke (w_current, o_current->line_type,
+ o_current->line_end,
+ o_current->line_width,
+ o_current->line_length,
+ o_current->line_space);
if (o_current->selected && w_current->draw_grips == TRUE) {
o_arc_draw_grips (w_current, o_current);
@@ -145,32 +109,24 @@ void o_arc_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_arc_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
- OBJECT object;
- ARC arc;
int color;
g_return_if_fail (o_current->arc != NULL);
- /* Setup a fake object to pass the drawing routine */
- object.arc = &arc;
- object.line_width = 0; /* clamped to 1 pixel in arc_path */
- arc.x = o_current->arc->x + dx;
- arc.y = o_current->arc->y + dy;
- arc.width = o_current->arc->width;
- arc.height = o_current->arc->height;
- arc.start_angle = o_current->arc->start_angle;
- arc.end_angle = o_current->arc->end_angle;
-
if (o_current->saved_color != -1) {
color = o_current->saved_color;
} else {
color = o_current->color;
}
- arc_path (w_current, &object);
+ gschem_cairo_arc (w_current, 0, o_current->arc->x + dx,
+ o_current->arc->y + dy,
+ o_current->arc->width / 2,
+ o_current->arc->start_angle,
+ o_current->arc->end_angle);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Start process to input a new arc.
@@ -378,25 +334,16 @@ void o_arc_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y, int whichone)
*/
void o_arc_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- OBJECT object;
- ARC arc;
double rad_angle;
int rdx, rdy;
- int x1, y1, x2, y2;
-
- /* Setup a fake object to pass the drawing routine */
- object.arc = &arc;
- object.line_width = 0; /* clamped to 1 pixel in arc_path */
- arc.x = w_current->first_wx;
- arc.y = w_current->first_wy;
- arc.width = w_current->distance * 2;
- arc.height = w_current->distance * 2;
- arc.start_angle = w_current->second_wx;
- arc.end_angle = w_current->second_wy;
- arc_path (w_current, &object);
+ gschem_cairo_arc (w_current, 0, w_current->first_wx,
+ w_current->first_wy,
+ w_current->distance,
+ w_current->second_wx,
+ w_current->second_wy);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
/* draw the radius line */
@@ -404,14 +351,12 @@ void o_arc_draw_rubber (GSCHEM_TOPLEVEL *w_current)
rdx = (double) w_current->distance * cos (rad_angle);
rdy = (double) w_current->distance * sin (rad_angle);
- WORLDtoSCREEN (w_current, w_current->first_wx,
- w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->first_wx + rdx,
- w_current->first_wy + rdy, &x2, &y2);
-
- gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, 0, w_current->first_wx,
+ w_current->first_wy,
+ w_current->first_wx + rdx,
+ w_current->first_wy + rdy);
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Draw grip marks on arc.
diff --git a/gschem/src/o_box.c b/gschem/src/o_box.c
index b4b19d0..a24bbf3 100644
--- a/gschem/src/o_box.c
+++ b/gschem/src/o_box.c
@@ -57,9 +57,7 @@ typedef void (*FILL_FUNC)( GdkDrawable *w, GdkGC *gc, COLOR *color,
void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int s_upper_x, s_upper_y, s_lower_x, s_lower_y;
- int line_width, length, space;
- int fill_width, angle1, pitch1, angle2, pitch2;
+ int angle1, pitch1, angle2, pitch2;
COLOR *color;
FILL_FUNC fill_func;
@@ -69,20 +67,6 @@ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
if (toplevel->DONT_REDRAW == 1)
return;
-
-#if DEBUG
- printf("drawing box\n\n");
-
- printf("drawing box: %d %d %d %d\n",
- o_current->box->upper_x,
- o_current->box->upper_y,
- o_current->box->upper_x +
- abs(o_current->box->lower_x -
- o_current->box->upper_x),
- o_current->box->upper_y +
- abs(o_current->box->lower_y -
- o_current->box->upper_y));
-#endif
/*
* The drawing of the box is divided in two steps : first step is to
@@ -111,18 +95,6 @@ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
* encountered the box is drawn as a solid box independently of its
* initial type.
*/
- line_width = SCREENabs (w_current, o_current->line_width);
- if(line_width <= 0) {
- line_width = 1;
- }
-
- length = SCREENabs (w_current, o_current->line_length);
- space = SCREENabs (w_current, o_current->line_space);
-
- WORLDtoSCREEN (w_current, o_current->box->upper_x, o_current->box->upper_y,
- &s_upper_x, &s_upper_y);
- WORLDtoSCREEN (w_current, o_current->box->lower_x, o_current->box->lower_y,
- &s_lower_x, &s_lower_y);
/*
* The values needed for the fill operation are taken from the
@@ -146,11 +118,7 @@ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
* to be distinct. If such a case is encountered the circle is filled
* hollow (e.q. not filled).
*/
- fill_width = SCREENabs (w_current, o_current->fill_width);
- if(fill_width <= 0) {
- fill_width = 1;
- }
-
+
angle1 = o_current->fill_angle1;
pitch1 = o_current->fill_pitch1;
angle2 = o_current->fill_angle2;
@@ -198,17 +166,21 @@ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
(*fill_func) (w_current->drawable, w_current->gc, color,
w_current, o_current->box,
- fill_width, angle1, pitch1, angle2, pitch2);
+ o_current->fill_width, angle1, pitch1, angle2, pitch2);
- gschem_cairo_set_source_color (w_current->cr, color);
- gschem_cairo_box (w_current->cr, line_width,
- s_lower_x, s_lower_y, s_upper_x, s_upper_y);
+ gschem_cairo_set_source_color (w_current, color);
+ gschem_cairo_box (w_current, o_current->line_width,
+ o_current->box->lower_x, o_current->box->lower_y,
+ o_current->box->upper_x, o_current->box->upper_y);
if (o_current->fill_type == FILLING_FILL)
cairo_fill_preserve (w_current->cr);
- gschem_cairo_stroke (w_current->cr, o_current->line_type,
- o_current->line_end, line_width, length, space);
+ gschem_cairo_stroke (w_current, o_current->line_type,
+ o_current->line_end,
+ o_current->line_width,
+ o_current->line_length,
+ o_current->line_space);
if (o_current->selected && w_current->draw_grips) {
o_box_draw_grips (w_current, o_current);
@@ -315,21 +287,18 @@ void o_box_fill_hatch (GdkDrawable *w, GdkGC *gc, COLOR *color,
int i;
GArray *lines;
- gschem_cairo_set_source_color (w_current->cr, color);
+ gschem_cairo_set_source_color (w_current, color);
lines = g_array_new (FALSE, FALSE, sizeof (LINE));
m_hatch_box (box, angle1, pitch1, lines);
for (i=0; i < lines->len; i++) {
- int x1, y1, x2, y2;
LINE *line = &g_array_index (lines, LINE, i);
- WORLDtoSCREEN (w_current, line->x[0], line->y[0], &x1, &y1);
- WORLDtoSCREEN (w_current, line->x[1], line->y[1], &x2, &y2);
- gschem_cairo_line (w_current->cr, END_NONE, fill_width, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, fill_width, line->x[0], line->y[0],
+ line->x[1], line->y[1]);
}
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE,
- fill_width, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, fill_width, -1, -1);
g_array_free (lines, TRUE);
}
@@ -407,29 +376,24 @@ void o_box_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_box_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int color;
if (o_current->box == NULL) {
return;
}
- WORLDtoSCREEN (w_current, o_current->box->upper_x + dx, o_current->box->upper_y + dy,
- &screen_x1, &screen_y1);
- WORLDtoSCREEN (w_current, o_current->box->lower_x + dx, o_current->box->lower_y + dy,
- &screen_x2, &screen_y2);
-
if (o_current->saved_color != -1) {
color = o_current->saved_color;
} else {
color = o_current->color;
}
- gschem_cairo_box (w_current->cr, 1, screen_x1, screen_y1,
- screen_x2, screen_y2);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_box (w_current, 0, o_current->box->upper_x + dx,
+ o_current->box->upper_y + dy,
+ o_current->box->lower_x + dx,
+ o_current->box->lower_y + dy);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 1, -1, -1);
}
/*! \brief Start process to input a new box.
@@ -581,16 +545,11 @@ void o_box_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
*/
void o_box_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- int x1, y1, x2, y2;
-
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy, &x2, &y2);
-
- gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
-
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_box (w_current, 0, w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Draw grip marks on box.
diff --git a/gschem/src/o_bus.c b/gschem/src/o_bus.c
index 9b1d87e..559048c 100644
--- a/gschem/src/o_bus.c
+++ b/gschem/src/o_bus.c
@@ -35,8 +35,8 @@
void o_bus_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int size;
- int x1, y1, x2, y2; /* screen coords */
+ int x1, y1, x2, y2;
+ int size = 0;
if (o_current == NULL) {
return;
@@ -52,34 +52,18 @@ void o_bus_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
return;
}
-#if DEBUG
- printf("drawing bus\n\n");
-#endif
-
- size = 1;
-
- if (toplevel->bus_style == THICK ) {
- size = SCREENabs (w_current, BUS_WIDTH);
-
- if (size < 1)
- size=1;
- }
-
- cairo_set_line_width (w_current->cr, size);
- cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_SQUARE);
+ if (toplevel->bus_style == THICK)
+ size = BUS_WIDTH;
if (toplevel->override_color != -1 ) {
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (toplevel->override_color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (toplevel->override_color));
} else {
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (o_current->color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (o_current->color));
}
- gschem_cairo_line (w_current->cr, END_SQUARE, size, x1, y1, x2, y2);
- cairo_stroke (w_current->cr);
+ gschem_cairo_line (w_current, END_SQUARE, size, x1, y1, x2, y2);
-#if DEBUG
- printf("drawing bus\n");
-#endif
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_SQUARE, size, -1, -1);
if (o_current->selected && w_current->draw_grips) {
o_line_draw_grips (w_current, o_current);
@@ -94,10 +78,8 @@ void o_bus_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
*/
void o_bus_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
- TOPLEVEL *toplevel = w_current->toplevel;
- int size = 1;
+ int size = 0;
int color;
- int sx[2], sy[2];
if (o_current->line == NULL) {
return;
@@ -109,19 +91,15 @@ void o_bus_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
color = o_current->color;
}
+ if (w_current->toplevel->bus_style == THICK)
+ size = BUS_WIDTH;
- if (toplevel->bus_style == THICK ) {
- size = SCREENabs (w_current, BUS_WIDTH);
- size += 1;
- }
-
- WORLDtoSCREEN (w_current, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
- WORLDtoSCREEN (w_current, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
-
- gschem_cairo_line (w_current->cr, END_NONE, 1, sx[0], sy[0], sx[1], sy[1]);
+ gschem_cairo_line (w_current, END_NONE, size,
+ o_current->line->x[0] + dx, o_current->line->y[0] + dy,
+ o_current->line->x[1] + dx, o_current->line->y[1] + dy);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
/*! \todo Finish function documentation!!!
@@ -134,7 +112,6 @@ void o_bus_draw_stretch (GSCHEM_TOPLEVEL *w_current,
{
int color;
int dx1= - 1, dy1 = - 1, dx2 = -1, dy2 = -1;
- int x1, y1, x2, y2;
if (o_current->line == NULL) {
return;
@@ -158,15 +135,12 @@ void o_bus_draw_stretch (GSCHEM_TOPLEVEL *w_current,
fprintf(stderr, _("Got an invalid which one in o_bus_draw_stretch\n"));
}
- WORLDtoSCREEN (w_current, o_current->line->x[0] + dx1,
- o_current->line->y[0] + dy1, &x1, &y1);
- WORLDtoSCREEN (w_current, o_current->line->x[1] + dx2,
- o_current->line->y[1] + dy2, &x2, &y2);
-
- gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, 0,
+ o_current->line->x[0] + dx1, o_current->line->y[0] + dy1,
+ o_current->line->x[1] + dx2, o_current->line->y[1] + dy2);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief set the start point of a new bus
@@ -329,21 +303,16 @@ void o_bus_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_bus_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- TOPLEVEL *toplevel = w_current->toplevel;
- int x1, y1, x2, y2, size = 0;
-
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy, &x2, &y2);
-
- if (toplevel->bus_style == THICK)
- size = SCREENabs (w_current, BUS_WIDTH);
+ int size = 0;
- if (size < 1)
- size = 1;
+ if (w_current->toplevel->bus_style == THICK)
+ size = BUS_WIDTH;
- gschem_cairo_line (w_current->cr, END_NONE, size, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, size,
+ w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index 2c91c91..33aece6 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -34,39 +34,6 @@ typedef void (*FILL_FUNC)( GdkDrawable *w, GdkGC *gc, COLOR *color,
gint angle2, gint pitch2 );
-static void circle_path (GSCHEM_TOPLEVEL *w_current, OBJECT *object)
-{
- CIRCLE *circle = object->circle;
- int line_width;
- int sx1, sy1, sx2, sy2;
- double cx, cy;
- double radius;
-
- WORLDtoSCREEN (w_current, circle->center_x - circle->radius,
- circle->center_y + circle->radius, &sx1, &sy1);
- WORLDtoSCREEN (w_current, circle->center_x + circle->radius,
- circle->center_y - circle->radius, &sx2, &sy2);
- line_width = SCREENabs (w_current, object->line_width);
- if (line_width <= 0) {
- line_width = 1;
- }
-
- cx = (double)(sx1 + sx2) / 2.;
- cy = (double)(sy1 + sy2) / 2.;
- radius = (double)(sy2 - sy1) / 2.;
-
- cairo_translate (w_current->cr, cx, cy);
-
- /* Adjust for non-uniform X/Y scale factor. Note that the + 1
- allows for the case where sx2 == sx1 or sy2 == sy1 */
- cairo_scale (w_current->cr, (double)(sx2 - sx1 + 1) /
- (double)(sy2 - sy1 + 1), 1.);
-
- gschem_cairo_arc (w_current->cr, line_width, 0., 0., radius, 0., 360);
- cairo_identity_matrix (w_current->cr);
-}
-
-
/*! \brief Draw a circle on the screen.
* \par Function Description
* This function is used to draw a circle on screen. The circle is described
@@ -83,8 +50,7 @@ static void circle_path (GSCHEM_TOPLEVEL *w_current, OBJECT *object)
void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int line_width, length, space;
- int fill_width, angle1, pitch1, angle2, pitch2;
+ int angle1, pitch1, angle2, pitch2;
COLOR *color;
FILL_FUNC fill_func;
@@ -111,13 +77,6 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
color = x_color_lookup (o_current->color);
}
- line_width = SCREENabs (w_current, o_current->line_width);
- if (line_width <= 0) {
- line_width = 1;
- }
-
- length = SCREENabs (w_current, o_current->line_length);
- space = SCREENabs (w_current, o_current->line_space);
/*
* The values needed for the fill operation are taken from the
@@ -140,11 +99,7 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
* distinct. If such a case is encountered the circle is filled hollow
* (e.q. not filled).
*/
- fill_width = SCREENabs (w_current, o_current->fill_width);
- if( fill_width <= 0) {
- fill_width = 1;
- }
-
+
angle1 = o_current->fill_angle1;
pitch1 = o_current->fill_pitch1;
angle2 = o_current->fill_angle2;
@@ -192,15 +147,21 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
(*fill_func) (w_current->drawable, w_current->gc,
color, w_current, o_current->circle,
- fill_width, angle1, pitch1, angle2, pitch2);
+ o_current->fill_width, angle1, pitch1, angle2, pitch2);
- circle_path (w_current, o_current);
+ gschem_cairo_arc (w_current, o_current->line_width,
+ o_current->circle->center_x,
+ o_current->circle->center_y,
+ o_current->circle->radius, 0, 360);
- gschem_cairo_set_source_color (w_current->cr, color);
+ gschem_cairo_set_source_color (w_current, color);
if (o_current->fill_type == FILLING_FILL)
cairo_fill_preserve (w_current->cr);
- gschem_cairo_stroke (w_current->cr, o_current->line_type,
- o_current->line_end, line_width, length, space);
+ gschem_cairo_stroke (w_current, o_current->line_type,
+ o_current->line_end,
+ o_current->line_width,
+ o_current->line_length,
+ o_current->line_space);
if (o_current->selected && w_current->draw_grips) {
o_circle_draw_grips (w_current, o_current);
@@ -313,21 +274,18 @@ void o_circle_fill_hatch (GdkDrawable *w, GdkGC *gc, COLOR *color,
int i;
GArray *lines;
- gschem_cairo_set_source_color (w_current->cr, color);
+ gschem_cairo_set_source_color (w_current, color);
lines = g_array_new (FALSE, FALSE, sizeof (LINE));
m_hatch_circle (circle, angle1, pitch1, lines);
for (i=0; i < lines->len; i++) {
- int x1, y1, x2, y2;
LINE *line = &g_array_index (lines, LINE, i);
- WORLDtoSCREEN (w_current, line->x[0], line->y[0], &x1, &y1);
- WORLDtoSCREEN (w_current, line->x[1], line->y[1], &x2, &y2);
- gschem_cairo_line (w_current->cr, END_NONE, fill_width, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, fill_width, line->x[0], line->y[0],
+ line->x[1], line->y[1]);
}
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE,
- fill_width, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, fill_width, -1, -1);
g_array_free (lines, TRUE);
}
@@ -410,29 +368,22 @@ void o_circle_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_circle_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
- OBJECT object;
- CIRCLE circle;
int color;
g_return_if_fail (o_current->circle != NULL);
- /* Setup a fake object to pass the drawing routine */
- object.circle = &circle;
- object.line_width = 0; /* clamped to 1 pixel in circle_path */
- circle.center_x = o_current->circle->center_x + dx;
- circle.center_y = o_current->circle->center_y + dy;
- circle.radius = o_current->circle->radius;
-
if (o_current->saved_color != -1) {
color = o_current->saved_color;
} else {
color = o_current->color;
}
- circle_path (w_current, &object);
+ gschem_cairo_arc (w_current, 0, o_current->circle->center_x + dx,
+ o_current->circle->center_y + dy,
+ o_current->circle->radius, 0, 360);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Start process to input a new circle.
@@ -572,28 +523,19 @@ void o_circle_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
*/
void o_circle_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- OBJECT object;
- CIRCLE circle;
- int x1, y1, x2, y2;
-
- /* Setup a fake object to pass the drawing routine */
- object.circle = &circle;
- object.line_width = 0; /* clamped to 1 pixel in circle_path */
- circle.center_x = w_current->first_wx;
- circle.center_y = w_current->first_wy;
- circle.radius = w_current->distance;
-
- circle_path (w_current, &object);
-
- WORLDtoSCREEN (w_current, w_current->first_wx,
- w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->first_wx + w_current->distance,
- w_current->first_wy, &x2, &y2);
- gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
-
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_arc (w_current, 0, w_current->first_wx,
+ w_current->first_wy,
+ w_current->distance, 0, 360);
+
+ gschem_cairo_line (w_current, END_NONE, 0,
+ w_current->first_wx,
+ w_current->first_wy,
+ w_current->first_wx + w_current->distance,
+ w_current->first_wy);
+
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Draw grip marks on circle.
diff --git a/gschem/src/o_cue.c b/gschem/src/o_cue.c
index ccb527e..f81abe6 100644
--- a/gschem/src/o_cue.c
+++ b/gschem/src/o_cue.c
@@ -85,9 +85,9 @@ void o_cue_redraw_all (GSCHEM_TOPLEVEL *w_current, GList *list, gboolean draw_se
static void o_cue_set_color(GSCHEM_TOPLEVEL *w_current, int color)
{
if (w_current->toplevel->override_color != -1 ) {
- gschem_cairo_set_source_color(w_current->cr, x_color_lookup (w_current->toplevel->override_color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (w_current->toplevel->override_color));
} else {
- gschem_cairo_set_source_color(w_current->cr, x_color_lookup (color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (color));
}
}
@@ -110,25 +110,21 @@ static void o_cue_set_color(GSCHEM_TOPLEVEL *w_current, int color)
static void draw_junction_cue (GSCHEM_TOPLEVEL *w_current,
int x, int y, int bus_involved)
{
- int s_x, s_y;
int size;
int line_width;
if (w_current->toplevel->DONT_REDRAW)
return;
- WORLDtoSCREEN (w_current, x, y, &s_x, &s_y);
-
if (bus_involved) {
- size = SCREENabs (w_current, JUNCTION_CUE_SIZE_BUS) / 2;
- line_width = SCREENabs (w_current, BUS_WIDTH);
+ size = JUNCTION_CUE_SIZE_BUS / 2;
+ line_width = BUS_WIDTH;
} else {
- size = SCREENabs (w_current, JUNCTION_CUE_SIZE_NET) / 2;
- line_width = SCREENabs (w_current, NET_WIDTH);
+ size = JUNCTION_CUE_SIZE_NET / 2;
+ line_width = NET_WIDTH;
}
- line_width = max (line_width, 1);
- gschem_cairo_center_arc (w_current->cr, line_width, -1, s_x, s_y, size, 0, 360);
+ gschem_cairo_center_arc (w_current, line_width, -1, x, y, size, 0, 360);
o_cue_set_color (w_current, JUNCTION_COLOR);
cairo_fill (w_current->cr);
}
@@ -142,7 +138,7 @@ static void draw_junction_cue (GSCHEM_TOPLEVEL *w_current,
void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichone)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int x, y, screen_x, screen_y;
+ int x, y;
GList *cl_current;
CONN *conn;
int type, count = 0;
@@ -194,17 +190,15 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
#if DEBUG
printf("type: %d count: %d\n", type, count);
#endif
- WORLDtoSCREEN (w_current, x, y, &screen_x, &screen_y);
switch(type) {
case(CONN_ENDPOINT):
if (object->type == OBJ_NET) { /* only nets have these cues */
if (count < 1) { /* Didn't find anything connected there */
- size = SCREENabs (w_current, CUE_BOX_SIZE);
+ size = CUE_BOX_SIZE;
if (toplevel->DONT_REDRAW == 0) {
- gschem_cairo_center_box (w_current->cr, -1, -1,
- screen_x, screen_y, size, size);
+ gschem_cairo_center_box (w_current, -1, -1, x, y, size, size);
o_cue_set_color (w_current, NET_ENDPOINT_COLOR);
cairo_fill (w_current->cr);
}
@@ -215,45 +209,37 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
} else if (object->type == OBJ_PIN) {
/* Didn't find anything connected there */
if (count < 1 && object->whichend == whichone) {
- if (bus_involved) {
- size = SCREENabs (w_current, PIN_CUE_SIZE_BUS);
- } else {
- size = SCREENabs (w_current, PIN_CUE_SIZE_NET);
- }
+ size = (bus_involved) ? PIN_CUE_SIZE_BUS : PIN_CUE_SIZE_NET;
otherone = !whichone;
- pinsize = 1;
+ pinsize = 0;
if (toplevel->pin_style == THICK )
- pinsize = SCREENabs (w_current, object->line_width);
+ pinsize = object->line_width;
if (toplevel->DONT_REDRAW == 0) {
o_cue_set_color (w_current, NET_ENDPOINT_COLOR);
if (object->line->y[whichone] == object->line->y[otherone]) {
/* horizontal line */
if (object->line->x[whichone] <= object->line->x[otherone]) {
- gschem_cairo_line (w_current->cr, END_NONE, pinsize,
- screen_x, screen_y,
- screen_x + size, screen_y);
+ gschem_cairo_line (w_current, END_NONE, pinsize, x, y,
+ x + size, y);
} else {
- gschem_cairo_line (w_current->cr, END_NONE, pinsize,
- screen_x, screen_y,
- screen_x - size, screen_y);
+ gschem_cairo_line (w_current, END_NONE, pinsize, x, y,
+ x - size, y);
}
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID,
+ gschem_cairo_stroke (w_current, TYPE_SOLID,
END_NONE, pinsize, -1, -1);
} else if (object->line->x[0] == object->line->x[1]) {
/* vertical line */
if (object->line->y[whichone] <= object->line->y[otherone]) {
- gschem_cairo_line (w_current->cr, END_NONE, pinsize,
- screen_x, screen_y,
- screen_x, screen_y - size);
+ gschem_cairo_line (w_current, END_NONE, pinsize, x, y,
+ x, y - size);
} else {
- gschem_cairo_line (w_current->cr, END_NONE, pinsize,
- screen_x, screen_y,
- screen_x, screen_y + size);
+ gschem_cairo_line (w_current, END_NONE, pinsize, x, y,
+ x, y + size);
}
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID,
+ gschem_cairo_stroke (w_current, TYPE_SOLID,
END_NONE, pinsize, -1, -1);
} else {
/* angled line */
diff --git a/gschem/src/o_grips.c b/gschem/src/o_grips.c
index 192df28..d6db1bb 100644
--- a/gschem/src/o_grips.c
+++ b/gschem/src/o_grips.c
@@ -1589,7 +1589,6 @@ void o_grips_draw(GSCHEM_TOPLEVEL *w_current, int wx, int wy)
TOPLEVEL *toplevel = w_current->toplevel;
int color;
int size, w_size;
- int x, y;
/*
* Depending on the current zoom level, the size of the grip is
@@ -1618,16 +1617,14 @@ void o_grips_draw(GSCHEM_TOPLEVEL *w_current, int wx, int wy)
* with a width / height of 2 * <B>size</B>.
*/
if (toplevel->DONT_REDRAW == 0) {
- WORLDtoSCREEN (w_current, wx, wy, &x, &y);
-
/* You can only tell an offset of the grip when it is very small,
* at which point, the object it's on is probably drawn 1px wide.
- * Pass 1 as a hint that we're centering on a "hardware" line.
+ * Pass 0 as a hint that we're centering on a "hardware" line.
*/
- gschem_cairo_center_box (w_current->cr, 1, 1, x, y, size, size);
+ gschem_cairo_center_box (w_current, 0, 0, wx, wy, w_size, w_size);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
}
diff --git a/gschem/src/o_line.c b/gschem/src/o_line.c
index 4bc4d5b..c01c99d 100644
--- a/gschem/src/o_line.c
+++ b/gschem/src/o_line.c
@@ -45,7 +45,6 @@ void o_line_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
int x1, y1, x2, y2;
- int line_width, length, space;
COLOR *color;
if (o_current->line == NULL) {
@@ -56,64 +55,27 @@ void o_line_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
(!o_line_visible (w_current, o_current->line, &x1, &y1, &x2, &y2)) ) {
return;
}
-
-#if DEBUG
- printf("drawing line\n\n");
- printf("drawing line : %d,%d to %d,%d\n",
- x1, y1,
- x2, y2);
-#endif
- /*
- * As a line is definetely not a closed shape there is no need to define and
- * call any filling function. Another way to say that is that a line can
- * not be filled. It simply draws the line according to the type.
- *
- * The values describing the line type are extracted from the
- * <B>o_current</B> pointed structure. These are the width of the line, the
- * field called length and the field called space and the desired end type
- * for the line.
- *
- * Depending on the type of the line that has to be used to draw the box
- * the appropriate function is called. Values of space and length are
- * adapted to the type of line. The possible functions are the following :
- * #o_line_draw_solid(), #o_line_draw_dotted(), #o_line_draw_dashed() and
- * #o_line_draw_phantom().
- *
- * The combination <B>length</B> == 0 and <B>space</B> == 0 is avoided as it
- * leads to an endless loop in function called after. If such a case is
- * encountered the line is drawn as a solid line independently of its
- * initial type.
- *
- * Finally the function takes care of the grips.
- */
- if (toplevel->override_color != -1 )
- color = x_color_lookup (toplevel->override_color);
+ if (toplevel->override_color != -1)
+ color = x_color_lookup (toplevel->override_color);
else
- color = x_color_lookup (o_current->color);
-
- line_width = SCREENabs (w_current, o_current->line_width);
- if( line_width <= 0) {
- line_width = 1;
- }
+ color = x_color_lookup (o_current->color);
- length = SCREENabs (w_current, o_current->line_length);
- space = SCREENabs (w_current, o_current->line_space);
- gschem_cairo_line (w_current->cr, o_current->line_end,
- line_width, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, o_current->line_end,
+ o_current->line_width,
+ x1, y1, x2, y2);
- gschem_cairo_set_source_color (w_current->cr, color);
- gschem_cairo_stroke (w_current->cr, o_current->line_type,
- o_current->line_end, line_width, length, space);
+ gschem_cairo_set_source_color (w_current, color);
+ gschem_cairo_stroke (w_current, o_current->line_type,
+ o_current->line_end,
+ o_current->line_width,
+ o_current->line_length,
+ o_current->line_space);
if (o_current->selected && w_current->draw_grips) {
o_line_draw_grips (w_current, o_current);
}
-
-#if DEBUG
- printf("drawing line\n");
-#endif
}
@@ -145,7 +107,6 @@ void o_line_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
void o_line_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
int color;
- int sx[2], sy[2];
if (o_current->line == NULL) {
return;
@@ -157,12 +118,11 @@ void o_line_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
color = o_current->color;
}
- WORLDtoSCREEN (w_current, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
- WORLDtoSCREEN (w_current, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
-
- gschem_cairo_line (w_current->cr, END_NONE, 1, sx[0], sy[0], sx[1], sy[1]);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_line (w_current, END_NONE, 0,
+ o_current->line->x[0] + dx, o_current->line->y[0] + dy,
+ o_current->line->x[1] + dx, o_current->line->y[1] + dy);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Start process to input a new line.
@@ -292,16 +252,13 @@ void o_line_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
*/
void o_line_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- int x1, y1, x2, y2;
-
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy, &x2, &y2);
-
- gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, 0,
+ w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Draw grip marks on line.
@@ -345,8 +302,8 @@ int o_line_visible (GSCHEM_TOPLEVEL *w_current, LINE *line,
return(TRUE);
}
- WORLDtoSCREEN (w_current, line->x[0], line->y[0], x1, y1);
- WORLDtoSCREEN (w_current, line->x[1], line->y[1], x2, y2);
+ *x1 = line->x[0]; *y1 = line->y[0];
+ *x2 = line->x[1]; *y2 = line->y[1];
- return SCREENclip_change (w_current, x1, y1, x2, y2);
+ return WORLDclip_change (w_current, x1, y1, x2, y2);
}
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index 41f05ca..48da07c 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -73,8 +73,8 @@ void o_net_reset(GSCHEM_TOPLEVEL *w_current)
void o_net_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int size;
- int x1, y1, x2, y2; /* screen coords */
+ int x1, y1, x2, y2;
+ int size = 0;
#if NET_DEBUG /* debug */
char *tempstring;
@@ -95,34 +95,17 @@ void o_net_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
return;
}
-#if DEBUG
- printf("drawing net\n\n");
-#endif
-
- size = 1;
-
- if (toplevel->net_style == THICK ) {
- size = SCREENabs (w_current, NET_WIDTH);
-
- if (size < 1)
- size=1;
- }
-
- cairo_set_line_width (w_current->cr, size);
- cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_SQUARE);
+ if (toplevel->net_style == THICK)
+ size = NET_WIDTH;
if (toplevel->override_color != -1 ) {
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (toplevel->override_color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (toplevel->override_color));
} else {
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (o_current->color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (o_current->color));
}
- gschem_cairo_line (w_current->cr, END_SQUARE, size, x1, y1, x2, y2);
- cairo_stroke (w_current->cr);
-
-#if DEBUG
- printf("drew net\n\n");
-#endif
+ gschem_cairo_line (w_current, END_SQUARE, size, x1, y1, x2, y2);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_SQUARE, size, -1, -1);
if (o_current->selected && w_current->draw_grips) {
o_line_draw_grips (w_current, o_current);
@@ -137,10 +120,8 @@ void o_net_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
*/
void o_net_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
- TOPLEVEL *toplevel = w_current->toplevel;
- int size = 1;
+ int size = 0;
int color;
- int sx[2], sy[2];
if (o_current->line == NULL) {
return;
@@ -152,18 +133,14 @@ void o_net_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
color = o_current->color;
}
- if (toplevel->net_style == THICK ) {
- size = SCREENabs (w_current, NET_WIDTH);
- size += 1;
- }
-
- WORLDtoSCREEN (w_current, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
- WORLDtoSCREEN (w_current, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
+ if (w_current->toplevel->net_style == THICK)
+ size = NET_WIDTH;
- gschem_cairo_line (w_current->cr, END_NONE, size, sx[0], sy[0], sx[1], sy[1]);
-
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
+ gschem_cairo_line (w_current, END_NONE, size,
+ o_current->line->x[0] + dx, o_current->line->y[0] + dy,
+ o_current->line->x[1] + dx, o_current->line->y[1] + dy);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
/*! \todo Finish function documentation!!!
@@ -176,7 +153,6 @@ void o_net_draw_stretch (GSCHEM_TOPLEVEL *w_current,
{
int color;
int dx1 = -1, dx2 = -1, dy1 = -1,dy2 = -1;
- int x1, y1, x2, y2;
if (o_current->line == NULL) {
return;
@@ -200,15 +176,12 @@ void o_net_draw_stretch (GSCHEM_TOPLEVEL *w_current,
fprintf(stderr, _("Got an invalid which one in o_net_draw_stretch\n"));
}
- WORLDtoSCREEN (w_current, o_current->line->x[0] + dx1,
- o_current->line->y[0] + dy1, &x1, &y1);
- WORLDtoSCREEN (w_current, o_current->line->x[1] + dx2,
- o_current->line->y[1] + dy2, &x2, &y2);
+ gschem_cairo_line (w_current, END_NONE, 0,
+ o_current->line->x[0] + dx1, o_current->line->y[0] + dy1,
+ o_current->line->x[1] + dx2, o_current->line->y[1] + dy2);
- gschem_cairo_line (w_current->cr, END_NONE, 1, x1, y1, x2, y2);
-
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
@@ -807,44 +780,35 @@ void o_net_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
*/
void o_net_draw_rubber(GSCHEM_TOPLEVEL *w_current)
{
- TOPLEVEL *toplevel = w_current->toplevel;
- int size = 0, magnetic_halfsize;
- int magnetic_x, magnetic_y;
- int first_x, first_y, third_x, third_y, second_x, second_y;
-
- WORLDtoSCREEN (w_current, w_current->magnetic_wx, w_current->magnetic_wy,
- &magnetic_x, &magnetic_y);
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy,
- &first_x, &first_y);
- WORLDtoSCREEN (w_current, w_current->third_wx, w_current->third_wy,
- &third_x, &third_y);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy,
- &second_x, &second_y);
+ int size = 0, w_magnetic_halfsize;
- if (toplevel->net_style == THICK)
- size = SCREENabs (w_current, NET_WIDTH);
+ if (w_current->toplevel->net_style == THICK)
+ size = NET_WIDTH;
- size = max (size, 1);
-
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
if (w_current->magneticnet_mode) {
if (w_current->magnetic_wx != -1 && w_current->magnetic_wy != -1) {
- magnetic_halfsize = max(4*size, MAGNETIC_HALFSIZE);
- gschem_cairo_arc (w_current->cr, size, magnetic_x, magnetic_y,
- magnetic_halfsize, 0, 360);
+ w_magnetic_halfsize = max (4 * size,
+ WORLDabs (w_current, MAGNETIC_HALFSIZE));
+ gschem_cairo_arc (w_current, size, w_current->magnetic_wx,
+ w_current->magnetic_wy,
+ w_magnetic_halfsize, 0, 360);
}
}
/* Primary line */
- gschem_cairo_line (w_current->cr, END_NONE, size,
- first_x, first_y, second_x, second_y);
+ gschem_cairo_line (w_current, END_NONE, size,
+ w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
+
/* Secondary line */
- gschem_cairo_line (w_current->cr, END_NONE, size,
- second_x, second_y, third_x, third_y);
+ gschem_cairo_line (w_current, END_NONE, size,
+ w_current->second_wx, w_current->second_wy,
+ w_current->third_wx, w_current->third_wy);
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
diff --git a/gschem/src/o_path.c b/gschem/src/o_path.c
index 58115ab..4bce0f8 100644
--- a/gschem/src/o_path.c
+++ b/gschem/src/o_path.c
@@ -233,21 +233,18 @@ static void o_path_fill_hatch (GdkDrawable *w, GdkGC *gc, COLOR *color,
int i;
GArray *lines;
- gschem_cairo_set_source_color (w_current->cr, color);
+ gschem_cairo_set_source_color (w_current, color);
lines = g_array_new (FALSE, FALSE, sizeof (LINE));
m_hatch_path (path, angle1, pitch1, lines);
for (i=0; i < lines->len; i++) {
- int x1, y1, x2, y2;
LINE *line = &g_array_index (lines, LINE, i);
- WORLDtoSCREEN (w_current, line->x[0], line->y[0], &x1, &y1);
- WORLDtoSCREEN (w_current, line->x[1], line->y[1], &x2, &y2);
- gschem_cairo_line (w_current->cr, END_NONE, fill_width, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, fill_width, line->x[0], line->y[0],
+ line->x[1], line->y[1]);
}
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE,
- fill_width, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, fill_width, -1, -1);
g_array_free (lines, TRUE);
}
@@ -300,8 +297,7 @@ void o_path_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
PATH *path = o_current->path;
- int line_width, length, space;
- int fill_width, angle1, pitch1, angle2, pitch2;
+ int angle1, pitch1, angle2, pitch2;
FILL_FUNC fill_func;
COLOR *color;
@@ -319,35 +315,6 @@ void o_path_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
color = x_color_lookup (o_current->color);
}
- line_width = SCREENabs (w_current, o_current->line_width);
- if( line_width <= 0) {
- line_width = 1;
- }
-
- length = SCREENabs (w_current, o_current->line_length);
- space = SCREENabs (w_current, o_current->line_space);
-
- /*
- * The values needed for the fill operation are taken from the
- * <B>o_current</B> pointed OBJECT. It include the type of fill required,
- * the width of the lines (if the fill use line) and angles and pitchs
- * for hatch based filling.
- *
- * Once again the width of the line is important as if it is equal to
- * 0 it may not be displayed. That is definetely not what we are looking for.
- *
- * Depending on the type of fill that has to be used inside the path the
- * appropriate function is called. Values of <B>angle1</B>,
- * <B>angle2</B>, <B>pitch1</B> and <B>pitch2</B> are adapted to the type of
- * filling. The possible functions are the following :
- * #o_path_fill_hollow(), #o_path_fill_fill(), #o_path_fill_mesh() and
- * #o_path_fill_hatch().
- */
- fill_width = SCREENabs (w_current, o_current->fill_width);
- if(fill_width <= 0) {
- fill_width = 1;
- }
-
angle1 = o_current->fill_angle1;
pitch1 = o_current->fill_pitch1;
angle2 = o_current->fill_angle2;
@@ -394,17 +361,20 @@ void o_path_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
}
(*fill_func) (w_current->drawable, w_current->gc, color,
- w_current, path, fill_width, angle1, pitch1, angle2, pitch2);
+ w_current, path, o_current->fill_width, angle1, pitch1, angle2, pitch2);
path_path (w_current, o_current);
- gschem_cairo_set_source_color (w_current->cr, color);
+ gschem_cairo_set_source_color (w_current, color);
if (o_current->fill_type == FILLING_FILL)
cairo_fill_preserve (w_current->cr);
- gschem_cairo_stroke (w_current->cr, o_current->line_type,
- o_current->line_end, line_width, length, space);
+ gschem_cairo_stroke (w_current, o_current->line_type,
+ o_current->line_end,
+ o_current->line_width,
+ o_current->line_length,
+ o_current->line_space);
if (o_current->selected && w_current->draw_grips) {
o_path_draw_grips (w_current, o_current);
@@ -488,7 +458,6 @@ void o_path_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
{
OBJECT object;
int color;
- int line_width = 1;
g_return_if_fail (o_current->path != NULL);
@@ -506,8 +475,8 @@ void o_path_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
g_free (object.path->sections);
g_free (object.path);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, line_width, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Start process to input a new path.
@@ -587,7 +556,6 @@ void o_path_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
void o_path_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
OBJECT object;
- int line_width = 1;
/* Setup a fake object to pass the drawing routine */
object.line_width = 0; /* clamped to 1 pixel in circle_path */
@@ -599,8 +567,8 @@ void o_path_draw_rubber (GSCHEM_TOPLEVEL *w_current)
g_free (object.path->sections);
g_free (object.path);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_SQUARE, line_width, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup (SELECT_COLOR));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_SQUARE, 0, -1, -1);
}
@@ -618,7 +586,6 @@ static void draw_control_lines (GSCHEM_TOPLEVEL *w_current,
{
TOPLEVEL *toplevel = w_current->toplevel;
int i;
- int x, y;
int next_x, next_y;
int last_x = 0, last_y = 0;
PATH_SECTION *section;
@@ -633,24 +600,26 @@ static void draw_control_lines (GSCHEM_TOPLEVEL *w_current,
}
/* set the color for the grip */
- gschem_cairo_set_source_color (w_current->cr, color);
+ gschem_cairo_set_source_color (w_current, color);
for (i = 0; i < o_current->path->num_sections; i++) {
section = &o_current->path->sections[i];
- if (section->code != PATH_END)
- WORLDtoSCREEN (w_current, section->x3, section->y3, &next_x, &next_y);
+ if (section->code != PATH_END) {
+ next_x = section->x3;
+ next_y = section->y3;
+ }
switch (section->code) {
case PATH_CURVETO:
/* Two control point grips */
- WORLDtoSCREEN (w_current, section->x1, section->y1, &x, &y);
- gschem_cairo_line (w_current->cr, END_NONE, 1, last_x, last_y, x, y);
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_line (w_current, END_NONE, 0,
+ last_x, last_y, section->x1, section->y1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
- WORLDtoSCREEN (w_current, section->x2, section->y2, &x, &y);
- gschem_cairo_line (w_current->cr, END_NONE, 1, next_x, next_y, x, y);
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_line (w_current, END_NONE, 0,
+ next_x, next_y, section->x2, section->y2);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
/* Fall through */
case PATH_MOVETO:
diff --git a/gschem/src/o_picture.c b/gschem/src/o_picture.c
index ca26de5..00caae2 100644
--- a/gschem/src/o_picture.c
+++ b/gschem/src/o_picture.c
@@ -274,17 +274,16 @@ void o_picture_draw_rubber (GSCHEM_TOPLEVEL *w_current)
int left, top, width, height;
/* get the width/height and the upper left corner of the picture */
- WORLDtoSCREEN (w_current,
- GET_PICTURE_LEFT(w_current), GET_PICTURE_TOP(w_current),
- &left, &top);
- width = SCREENabs (w_current, GET_PICTURE_WIDTH (w_current));
- height = SCREENabs (w_current, GET_PICTURE_HEIGHT(w_current));
+ left = GET_PICTURE_LEFT (w_current);
+ top = GET_PICTURE_TOP (w_current);
+ width = GET_PICTURE_WIDTH (w_current);
+ height = GET_PICTURE_HEIGHT (w_current);
- gschem_cairo_box (w_current->cr, 1, left, top, left + width, top + height);
+ gschem_cairo_box (w_current, 0, left, top, left + width, top + height);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Draw a picture on the screen.
@@ -375,8 +374,6 @@ void o_picture_draw (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
*/
void o_picture_draw_grips(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
- int s_upper_x, s_upper_y, s_lower_x, s_lower_y;
-
if (w_current->draw_grips == FALSE)
return;
@@ -397,17 +394,13 @@ void o_picture_draw_grips(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
o_current->picture->lower_y);
/* Box surrounding the picture */
- WORLDtoSCREEN (w_current, o_current->picture->upper_x, o_current->picture->upper_y,
- &s_upper_x, &s_upper_y );
- WORLDtoSCREEN (w_current, o_current->picture->lower_x, o_current->picture->lower_y,
- &s_lower_x, &s_lower_y );
-
- gschem_cairo_box (w_current->cr, 1, s_lower_x, s_lower_y,
- s_upper_x, s_upper_y);
+ gschem_cairo_box (w_current, 0,
+ o_current->picture->upper_x, o_current->picture->upper_y,
+ o_current->picture->lower_x, o_current->picture->lower_y);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
@@ -426,29 +419,25 @@ void o_picture_draw_grips(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
*/
void o_picture_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int color;
if (o_current->picture == NULL) {
return;
}
- WORLDtoSCREEN (w_current, o_current->picture->upper_x + dx, o_current->picture->upper_y + dy,
- &screen_x1, &screen_y1);
- WORLDtoSCREEN (w_current, o_current->picture->lower_x + dx, o_current->picture->lower_y + dy,
- &screen_x2, &screen_y2);
-
if (o_current->saved_color != -1) {
color = o_current->saved_color;
} else {
color = o_current->color;
}
- gschem_cairo_box (w_current->cr, 1, screen_x1, screen_y1,
- screen_x2, screen_y2);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_box (w_current, 0, o_current->picture->upper_x + dx,
+ o_current->picture->upper_y + dy,
+ o_current->picture->lower_x + dx,
+ o_current->picture->lower_y + dy);
+
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \brief Replace all selected pictures with a new picture
diff --git a/gschem/src/o_pin.c b/gschem/src/o_pin.c
index 55771d6..9162551 100644
--- a/gschem/src/o_pin.c
+++ b/gschem/src/o_pin.c
@@ -36,8 +36,8 @@
void o_pin_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int size;
- int x1, y1, x2, y2; /* screen coords */
+ int x1, y1, x2, y2;
+ int size = 0;
COLOR *color;
if (o_current->line == NULL) {
@@ -50,10 +50,6 @@ void o_pin_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
return;
}
-#if DEBUG
- printf("drawing pin\n\n");
-#endif
-
if (toplevel->override_color != -1 ) {
color = x_color_lookup (toplevel->override_color);
} else {
@@ -61,20 +57,13 @@ void o_pin_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
}
if (toplevel->DONT_REDRAW == 0) {
- size = 1;
- if (toplevel->pin_style == THICK) {
- size = SCREENabs (w_current, o_current->line_width);
- if (size < 1)
- size=1;
- }
+ if (toplevel->pin_style == THICK)
+ size = o_current->line_width;
- cairo_set_line_width (w_current->cr, size);
- cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_BUTT);
+ gschem_cairo_line (w_current, END_NONE, size, x1, y1, x2, y2);
- gschem_cairo_set_source_color (w_current->cr, color);
-
- gschem_cairo_line (w_current->cr, END_NONE, size, x1, y1, x2, y2);
- cairo_stroke (w_current->cr);
+ gschem_cairo_set_source_color (w_current, color);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
/* draw the cue directly */
@@ -98,9 +87,8 @@ void o_pin_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
void o_pin_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int size = 1;
+ int size = 0;
int color;
- int sx[2], sy[2];
if (o_current->line == NULL) {
return;
@@ -112,20 +100,15 @@ void o_pin_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
color = o_current->color;
}
- if (toplevel->pin_style == THICK) {
- size = SCREENabs (w_current, o_current->line_width);
- if (size < 1) {
- size = 1;
- }
- }
-
- WORLDtoSCREEN (w_current, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
- WORLDtoSCREEN (w_current, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
+ if (toplevel->pin_style == THICK)
+ size = o_current->line_width;
- gschem_cairo_line (w_current->cr, END_NONE, size, sx[0], sy[0], sx[1], sy[1]);
+ gschem_cairo_line (w_current, END_NONE, size,
+ o_current->line->x[0] + dx, o_current->line->y[0] + dy,
+ o_current->line->x[1] + dx, o_current->line->y[1] + dy);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
/*! \todo Finish function documentation!!!
@@ -258,23 +241,17 @@ void o_pin_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_pin_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- TOPLEVEL *toplevel = w_current->toplevel;
- int x1, y1, x2, y2;
- int size = 1;
-
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy, &x2, &y2);
+ int size = 0;
/* Pins are always first created as net pins, use net pin width */
- if (toplevel->net_style == THICK )
- size = SCREENabs (w_current, PIN_WIDTH_NET);
-
- if (size < 1)
- size = 1;
+ if (w_current->toplevel->net_style == THICK)
+ size = PIN_WIDTH_NET;
- gschem_cairo_line (w_current->cr, END_NONE, size, x1, y1, x2, y2);
+ gschem_cairo_line (w_current, END_NONE, size,
+ w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, size, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1);
}
diff --git a/gschem/src/o_place.c b/gschem/src/o_place.c
index 2001801..622af0e 100644
--- a/gschem/src/o_place.c
+++ b/gschem/src/o_place.c
@@ -257,7 +257,6 @@ void o_place_draw_rubber (GSCHEM_TOPLEVEL *w_current, int drawing)
TOPLEVEL *toplevel = w_current->toplevel;
int diff_x, diff_y;
int left, top, bottom, right;
- int s_left, s_top, s_bottom, s_right;
g_return_if_fail (toplevel->page_current->place_list != NULL);
@@ -291,14 +290,13 @@ void o_place_draw_rubber (GSCHEM_TOPLEVEL *w_current, int drawing)
world_get_object_glist_bounds (toplevel,
toplevel->page_current->place_list,
&left, &top, &right, &bottom);
- WORLDtoSCREEN (w_current, left + diff_x, top + diff_y, &s_left, &s_top);
- WORLDtoSCREEN (w_current, right + diff_x, bottom + diff_y, &s_right, &s_bottom);
- gschem_cairo_box (w_current->cr, 1, s_left, s_top, s_right, s_bottom);
+ gschem_cairo_box (w_current, 0, left + diff_x, top + diff_y,
+ right + diff_x, bottom + diff_y);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (BOUNDINGBOX_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
} else {
o_glist_draw_place (w_current, diff_x, diff_y,
toplevel->page_current->place_list);
diff --git a/gschem/src/o_select.c b/gschem/src/o_select.c
index 6617b62..a844755 100644
--- a/gschem/src/o_select.c
+++ b/gschem/src/o_select.c
@@ -312,16 +312,13 @@ void o_select_box_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_select_box_draw_rubber (GSCHEM_TOPLEVEL *w_current)
{
- int x1, y1, x2, y2;
-
- WORLDtoSCREEN (w_current, w_current->first_wx, w_current->first_wy, &x1, &y1);
- WORLDtoSCREEN (w_current, w_current->second_wx, w_current->second_wy, &x2, &y2);
-
- gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
+ gschem_cairo_box (w_current, 0,
+ w_current->first_wx, w_current->first_wy,
+ w_current->second_wx, w_current->second_wy);
- gschem_cairo_set_source_color (w_current->cr,
+ gschem_cairo_set_source_color (w_current,
x_color_lookup_dark (SELECT_COLOR));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
/*! \todo Finish function documentation!!!
diff --git a/gschem/src/o_text.c b/gschem/src/o_text.c
index ba59787..a3ef176 100644
--- a/gschem/src/o_text.c
+++ b/gschem/src/o_text.c
@@ -228,7 +228,6 @@ void o_text_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
void o_text_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int top, bottom, left, right;
int color, factor;
if (o_current->visibility == INVISIBLE && !toplevel->show_hidden_text) {
@@ -244,8 +243,6 @@ void o_text_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
} else {
/* text is too small so go through and draw a line in
it's place */
- WORLDtoSCREEN (w_current, o_current->w_left + dx, o_current->w_bottom + dy, &left, &top);
- WORLDtoSCREEN (w_current, o_current->w_right + dx, o_current->w_top + dy, &right, &bottom);
if (o_current->saved_color != -1) {
color = o_current->saved_color;
@@ -253,10 +250,12 @@ void o_text_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
color = o_current->color;
}
- gschem_cairo_box (w_current->cr, 1, left, top, right, bottom);
+ gschem_cairo_box (w_current, 0,
+ o_current->w_left + dx, o_current->w_bottom + dy,
+ o_current->w_right + dx, o_current->w_top + dy);
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
- gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
+ gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color));
+ gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1);
}
}
diff --git a/gschem/src/x_grid.c b/gschem/src/x_grid.c
index a98c168..2e705cf 100644
--- a/gschem/src/x_grid.c
+++ b/gschem/src/x_grid.c
@@ -175,7 +175,7 @@ static void draw_mesh (GSCHEM_TOPLEVEL *w_current, int color,
if (next_coarse_y < y_start) next_coarse_y += coarse_incr;
}
- gschem_cairo_set_source_color (w_current->cr, x_color_lookup (color));
+ gschem_cairo_set_source_color (w_current, x_color_lookup (color));
cairo_set_line_width (w_current->cr, 1.);
cairo_set_line_cap (w_current->cr, CAIRO_LINE_CAP_SQUARE);
commit 4a217cd1109b03f6d5f75f9fca46513d7679ddb6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon Jan 5 03:36:25 2009 +0000
gschem: Add new primitves to draw a centered arc and box
These primitives take care of hinting specifically to keep the drawn
object looking centered, adjusting to take into account both the
radius / extents of the object being drawn, and how the object we're
trying to center on would have been hinted.
Use these new primitives for drawing cues and grip boxes.
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 49915fd..689eed4 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -283,9 +283,11 @@ void gschem_quit(void);
void main_prog(void *closure, int argc, char *argv[]);
int main(int argc, char *argv[]);
/* gschem_cairo.c */
-void gschem_cairo_line(cairo_t *cr, int line_end, int width, int x1, int y1, int x2, int y2);
-void gschem_cairo_box(cairo_t *cr, int width, int x1, int y1, int x2, int y2);
-void gschem_cairo_arc(cairo_t *cr, int width, double x, double y, double radius, int start_angle, int end_angle);
+void gschem_cairo_line(cairo_t *cr, int line_end, int line_width, int x1, int y1, int x2, int y2);
+void gschem_cairo_box(cairo_t *cr, int line_width, int x1, int y1, int x2, int y2);
+void gschem_cairo_center_box(cairo_t *cr, int center_width, int line_width, int x1, int y1, int x2, int y2);
+void gschem_cairo_arc(cairo_t *cr, int line_width, double x, double y, double radius, int start_angle, int end_angle);
+void gschem_cairo_center_arc(cairo_t *cr, int center_width, int line_width, int x, int y, int radius, int start_angle, int end_angle);
void gschem_cairo_stroke(cairo_t *cr, int line_type, int line_end, int width, int length, int space);
void gschem_cairo_set_source_color(cairo_t *cr, COLOR *color);
/* i_basic.c */
diff --git a/gschem/src/gschem_cairo.c b/gschem/src/gschem_cairo.c
index 4d18239..df79e50 100644
--- a/gschem/src/gschem_cairo.c
+++ b/gschem/src/gschem_cairo.c
@@ -31,16 +31,16 @@
#endif
-void gschem_cairo_line (cairo_t *cr, int line_end, int width,
+void gschem_cairo_line (cairo_t *cr, int line_end, int line_width,
int x1, int y1, int x2, int y2)
{
- double offset = ((width % 2) == 0) ? 0 : 0.5;
+ double offset = ((line_width % 2) == 0) ? 0 : 0.5;
double xoffset = 0;
double yoffset = 0;
int horizontal = 0;
int vertical = 0;
- if (width == 0)
+ if (line_width == 0)
return;
if (y1 == y2) horizontal = 1;
@@ -85,14 +85,14 @@ void gschem_cairo_line (cairo_t *cr, int line_end, int width,
}
-void gschem_cairo_box (cairo_t *cr, int width,
+void gschem_cairo_box (cairo_t *cr, int line_width,
int x1, int y1, int x2, int y2)
{
- double offset = (width == -1 || (width % 2) == 0) ? 0 : 0.5;
+ double offset = (line_width == -1 || (line_width % 2) == 0) ? 0 : 0.5;
/* Allow filled boxes (inferred from line_width == -1)
* to touch an extra pixel, so the filled span is inclusive */
- if (width == -1) {
+ if (line_width == -1) {
if (x1 > x2) x1 += 1; else x2 += 1;
if (y1 > y2) y1 += 1; else y2 += 1;
}
@@ -105,24 +105,94 @@ void gschem_cairo_box (cairo_t *cr, int width,
}
-void gschem_cairo_arc (cairo_t *cr, int width, double x, double y,
- double radius, int start_angle, int end_angle)
+void gschem_cairo_center_box (cairo_t *cr,
+ int s_center_width,
+ int s_line_width, int s_x, int s_y,
+ int s_half_width, int s_half_height)
{
- double offset = ((width % 2) == 0) ? 0 : 0.5;
+ int even_center_width;
+ int even_line_width;
+ double x1, y1, x2, y2;
+ double center_offset, radius_offset;
+
+ /* Hint the center of the box based on where a line
+ * of thickness center_width (world) would drawn */
+ even_center_width = (s_center_width == -1 || (s_center_width % 2) == 0);
+ center_offset = even_center_width ? 0. : 0.5;
+
+ /* Hint the half-widths to land the stroke on the pixel grid */
+ even_line_width = (s_line_width == -1 || (s_line_width % 2) == 0);
+ radius_offset = (even_center_width == even_line_width) ? 0. : 0.5;
+
+ x1 = (double) s_x + center_offset - s_half_width - radius_offset;
+ y1 = (double) s_y + center_offset - s_half_height - radius_offset;
+ x2 = (double) s_x + center_offset + s_half_width + radius_offset;
+ y2 = (double) s_y + center_offset + s_half_height + radius_offset;
+
+ /* Allow filled boxes (inferred from line_width == -1)
+ * to touch an extra pixel, so the filled span is inclusive */
+ if (s_line_width == -1) {
+ x2 += 1; y2 += 1;
+ }
+
+ cairo_move_to (cr, x2, y2);
+ cairo_line_to (cr, x1, y2);
+ cairo_line_to (cr, x1, y1);
+ cairo_line_to (cr, x2, y1);
+ cairo_close_path (cr);
+}
+
+static inline void do_arc (cairo_t *cr, double x, double y, double radius,
+ int start_angle, int end_angle)
+{
cairo_new_sub_path (cr);
if (start_angle > start_angle + end_angle) {
- cairo_arc (cr, x + offset, y + offset, radius,
- -start_angle * (M_PI / 180.),
- (-start_angle - end_angle) * (M_PI / 180.));
+ cairo_arc (cr, x, y, radius, -start_angle * (M_PI / 180.),
+ (-start_angle - end_angle) * (M_PI / 180.));
} else {
- cairo_arc_negative (cr, x + offset, y + offset, radius,
- -start_angle * (M_PI / 180.),
- (-start_angle - end_angle) * (M_PI / 180.));
+ cairo_arc_negative (cr, x, y, radius, -start_angle * (M_PI / 180.),
+ (-start_angle - end_angle) * (M_PI / 180.));
}
}
+void gschem_cairo_arc (cairo_t *cr, int line_width, double x, double y,
+ double radius, int start_angle, int end_angle)
+{
+ double offset = ((line_width % 2) == 0) ? 0 : 0.5;
+
+ do_arc (cr, x + offset, y + offset, radius, start_angle, end_angle);
+}
+
+
+void gschem_cairo_center_arc (cairo_t *cr,
+ int s_center_width,
+ int s_line_width, int s_x, int s_y,
+ int s_radius, int start_angle, int end_angle)
+{
+ int even_center_width;
+ int even_line_width;
+ double center_offset, radius_offset;
+
+ /* Hint the center of the arc based on where a line
+ * of thickness center_width (world) would drawn */
+ even_center_width = (s_center_width == -1 || (s_center_width % 2) == 0);
+ center_offset = even_center_width ? 0. : 0.5;
+
+ /* Hint the radius to land its extermity on the pixel grid */
+ even_line_width = (s_line_width == -1 || (s_line_width % 2) == 0);
+ /* radius_offset = (even_center_width == even_line_width) ? 0. : 0.5; */
+ /* Don't hint the radius, it makes things look strange when drawing cues */
+ radius_offset = 0.;
+
+ do_arc (cr, (double) s_x + center_offset,
+ (double) s_y + center_offset,
+ (double) s_radius + radius_offset,
+ start_angle, end_angle);
+}
+
+
void gschem_cairo_stroke (cairo_t *cr, int line_type, int line_end,
int width, int length, int space)
{
diff --git a/gschem/src/o_cue.c b/gschem/src/o_cue.c
index b3c2529..ccb527e 100644
--- a/gschem/src/o_cue.c
+++ b/gschem/src/o_cue.c
@@ -111,7 +111,7 @@ static void draw_junction_cue (GSCHEM_TOPLEVEL *w_current,
int x, int y, int bus_involved)
{
int s_x, s_y;
- int size, x2size;
+ int size;
int line_width;
if (w_current->toplevel->DONT_REDRAW)
@@ -126,10 +126,9 @@ static void draw_junction_cue (GSCHEM_TOPLEVEL *w_current,
size = SCREENabs (w_current, JUNCTION_CUE_SIZE_NET) / 2;
line_width = SCREENabs (w_current, NET_WIDTH);
}
- x2size = size * 2;
line_width = max (line_width, 1);
- gschem_cairo_arc (w_current->cr, line_width, s_x, s_y, size, 0, 360);
+ gschem_cairo_center_arc (w_current->cr, line_width, -1, s_x, s_y, size, 0, 360);
o_cue_set_color (w_current, JUNCTION_COLOR);
cairo_fill (w_current->cr);
}
@@ -148,7 +147,7 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
CONN *conn;
int type, count = 0;
int done = FALSE;
- int size, x2size, pinsize;
+ int size, pinsize;
int otherone;
int bus_involved=FALSE;
@@ -195,9 +194,8 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
#if DEBUG
printf("type: %d count: %d\n", type, count);
#endif
-
WORLDtoSCREEN (w_current, x, y, &screen_x, &screen_y);
-
+
switch(type) {
case(CONN_ENDPOINT):
@@ -205,9 +203,8 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
if (count < 1) { /* Didn't find anything connected there */
size = SCREENabs (w_current, CUE_BOX_SIZE);
if (toplevel->DONT_REDRAW == 0) {
- gschem_cairo_box (w_current->cr, -1,
- screen_x - size, screen_y - size,
- screen_x + size, screen_y + size);
+ gschem_cairo_center_box (w_current->cr, -1, -1,
+ screen_x, screen_y, size, size);
o_cue_set_color (w_current, NET_ENDPOINT_COLOR);
cairo_fill (w_current->cr);
}
@@ -223,7 +220,6 @@ void o_cue_draw_lowlevel(GSCHEM_TOPLEVEL *w_current, OBJECT *object, int whichon
} else {
size = SCREENabs (w_current, PIN_CUE_SIZE_NET);
}
- x2size = size * 2;
otherone = !whichone;
diff --git a/gschem/src/o_grips.c b/gschem/src/o_grips.c
index 4673e7b..192df28 100644
--- a/gschem/src/o_grips.c
+++ b/gschem/src/o_grips.c
@@ -1589,7 +1589,7 @@ void o_grips_draw(GSCHEM_TOPLEVEL *w_current, int wx, int wy)
TOPLEVEL *toplevel = w_current->toplevel;
int color;
int size, w_size;
- int x1, y1, x2, y2;
+ int x, y;
/*
* Depending on the current zoom level, the size of the grip is
@@ -1618,9 +1618,13 @@ void o_grips_draw(GSCHEM_TOPLEVEL *w_current, int wx, int wy)
* with a width / height of 2 * <B>size</B>.
*/
if (toplevel->DONT_REDRAW == 0) {
- WORLDtoSCREEN (w_current, wx - w_size, wy - w_size, &x1, &y1);
- WORLDtoSCREEN (w_current, wx + w_size, wy + w_size, &x2, &y2);
- gschem_cairo_box (w_current->cr, 1, x1, y1, x2, y2);
+ WORLDtoSCREEN (w_current, wx, wy, &x, &y);
+
+ /* You can only tell an offset of the grip when it is very small,
+ * at which point, the object it's on is probably drawn 1px wide.
+ * Pass 1 as a hint that we're centering on a "hardware" line.
+ */
+ gschem_cairo_center_box (w_current->cr, 1, 1, x, y, size, size);
gschem_cairo_set_source_color (w_current->cr, x_color_lookup (color));
gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs