[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-107-g212b0cf)
The branch, master has been updated
via 212b0cf870e05a105fc5a6c134b7803cf6c63c28 (commit)
from 8ad9acc2c5ceda2b1e5f4e52461dd0f078f8122c (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/src/o_arc.c | 49 ++++++++++++-----------------
gschem/src/o_box.c | 13 +++-----
gschem/src/o_bus.c | 21 +++---------
gschem/src/o_circle.c | 21 ++++--------
gschem/src/o_line.c | 7 ++--
gschem/src/o_net.c | 20 +++---------
gschem/src/o_path.c | 80 ++++++++++++++++++++++++++++++-----------------
gschem/src/o_picture.c | 13 +++-----
gschem/src/o_pin.c | 22 +++----------
gschem/src/o_text.c | 11 ++-----
10 files changed, 110 insertions(+), 147 deletions(-)
=================
Commit Messages
=================
commit 212b0cf870e05a105fc5a6c134b7803cf6c63c28
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Thu Jan 1 16:38:09 2009 +0000
gschem: Use cairo for drawing when in "place" mode.
Converts all *_draw_place() functions to using cairo.
:100644 100644 c4b0f40... 646946c... M gschem/src/o_arc.c
:100644 100644 bc0f9fe... 9cbf626... M gschem/src/o_box.c
:100644 100644 0e8a5c0... 791cc6f... M gschem/src/o_bus.c
:100644 100644 80f519f... b8d84e4... M gschem/src/o_circle.c
:100644 100644 a3a7c8b... ac76a1d... M gschem/src/o_line.c
:100644 100644 8c96100... a29867c... M gschem/src/o_net.c
:100644 100644 88ad217... 4f5c7d1... M gschem/src/o_path.c
:100644 100644 51ea357... 387dcff... M gschem/src/o_picture.c
:100644 100644 2845cdc... 241a3cc... M gschem/src/o_pin.c
:100644 100644 e5cf68d... 4f6f4ab... M gschem/src/o_text.c
=========
Changes
=========
commit 212b0cf870e05a105fc5a6c134b7803cf6c63c28
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Thu Jan 1 16:38:09 2009 +0000
gschem: Use cairo for drawing when in "place" mode.
Converts all *_draw_place() functions to using cairo.
diff --git a/gschem/src/o_arc.c b/gschem/src/o_arc.c
index c4b0f40..646946c 100644
--- a/gschem/src/o_arc.c
+++ b/gschem/src/o_arc.c
@@ -158,48 +158,41 @@ 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)
{
TOPLEVEL *toplevel = w_current->toplevel;
- int x, y, width, height, start_angle, end_angle;
+ int sx1, sy1, sx2, sy2;
+ int line_width = 1;
int color;
if (o_current->arc == NULL) {
return;
}
- /* diameter */
- width = SCREENabs( toplevel, o_current->arc->width );
- /* height MUST be equal to width, just another name for diameter */
- height = SCREENabs( toplevel, o_current->arc->height );
- /* center */
- WORLDtoSCREEN(toplevel, o_current->arc->x + dx, o_current->arc->y + dy, &x, &y);
- x -= (width / 2);
- y -= (height / 2);
- /* start and end angles */
- start_angle = o_current->arc->start_angle;
- end_angle = o_current->arc->end_angle;
-
- /* check the size of the displayed arc */
- /* do not allow null diameter = arc always displayed */
- if (height < 1) {
- height = 1;
- }
- if (width < 1) {
- width = 1;
- }
-
if (o_current->saved_color != -1) {
color = o_current->saved_color;
} else {
color = o_current->color;
}
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
- /* better to set the line attributes here ? */
- gdk_draw_arc (w_current->drawable, w_current->gc, FALSE,
- x, y, width, height,
- start_angle * 64, end_angle * 64);
+ WORLDtoSCREEN (toplevel, o_current->arc->x + dx - o_current->arc->width / 2,
+ o_current->arc->y + dy + o_current->arc->height / 2,
+ &sx1, &sy1);
+ WORLDtoSCREEN (toplevel, o_current->arc->x + dx + o_current->arc->width / 2,
+ o_current->arc->y + dy- o_current->arc->height / 2,
+ &sx2, &sy2);
- /* backing store? not appropriate here */
+ cairo_translate (w_current->cr, (double)(sx1 + sx2) / 2.,
+ (double)(sy1 + sy2) / 2.);
+
+ /* 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., (double)(sy2 - sy1) / 2.,
+ o_current->arc->start_angle, o_current->arc->end_angle);
+ cairo_identity_matrix (w_current->cr);
+ 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);
}
/*! \brief Start process to input a new arc.
diff --git a/gschem/src/o_box.c b/gschem/src/o_box.c
index bc0f9fe..9cbf626 100644
--- a/gschem/src/o_box.c
+++ b/gschem/src/o_box.c
@@ -421,20 +421,17 @@ void o_box_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
&screen_x1, &screen_y1);
WORLDtoSCREEN(toplevel, 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;
}
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
- gdk_draw_rectangle (w_current->drawable,
- w_current->gc, FALSE,
- screen_x1,
- screen_y1,
- abs(screen_x2 - screen_x1),
- abs(screen_y2 - screen_y1));
+ 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);
}
/*! \brief Start process to input a new box.
diff --git a/gschem/src/o_bus.c b/gschem/src/o_bus.c
index 0e8a5c0..791cc6f 100644
--- a/gschem/src/o_bus.c
+++ b/gschem/src/o_bus.c
@@ -95,7 +95,7 @@ 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;
+ int size = 1;
int color;
int sx[2], sy[2];
@@ -109,30 +109,19 @@ void o_bus_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
color = o_current->color;
}
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
if (toplevel->bus_style == THICK ) {
size = SCREENabs(toplevel, BUS_WIDTH);
- gdk_gc_set_line_attributes (w_current->gc, size+1,
- GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_MITER);
+ size += 1;
}
WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0] );
WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1] );
- gdk_draw_line (w_current->drawable, w_current->gc,
- sx[0], sy[0], sx[1], sy[1]);
+ gschem_cairo_line (w_current->cr, END_NONE, 1, sx[0], sy[0], sx[1], sy[1]);
- /* backing store ? not approriate here */
-
- if (toplevel->bus_style == THICK ) {
- gdk_gc_set_line_attributes (w_current->gc, 0,
- GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_MITER);
- }
+ 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);
}
/*! \todo Finish function documentation!!!
diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index 80f519f..b8d84e4 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -426,22 +426,15 @@ void o_circle_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_
/* radius of the circle */
radius = SCREENabs( toplevel, o_current->circle->radius );
- /* upper left corner of the square the circle is inscribed in */
- /* gdk coords system */
- WORLDtoSCREEN( toplevel,
- o_current->circle->center_x - o_current->circle->radius + dx,
- o_current->circle->center_y + o_current->circle->radius + dy,
- &x, &y );
- /* To draw be sure to setup width height */
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
- gdk_draw_arc (w_current->drawable, w_current->gc,
- FALSE,
- x, y,
- 2 * radius, 2 * radius,
- 0, FULL_CIRCLE);
+ WORLDtoSCREEN (toplevel, o_current->circle->center_x + dx,
+ o_current->circle->center_y + dy, &x, &y);
+
+ cairo_new_sub_path (w_current->cr);
+ cairo_arc (w_current->cr, x + 0.5, y + 0.5, radius, 0., 2 * M_PI);
- /* backing store ? not appropriate here */
+ 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);
}
/*! \brief Start process to input a new circle.
diff --git a/gschem/src/o_line.c b/gschem/src/o_line.c
index a3a7c8b..ac76a1d 100644
--- a/gschem/src/o_line.c
+++ b/gschem/src/o_line.c
@@ -159,13 +159,12 @@ void o_line_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
color = o_current->color;
}
- /* changed for dark color stuff */
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
-
WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
- gdk_draw_line (w_current->drawable, w_current->gc, sx[0], sy[0], 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);
}
/*! \brief Start process to input a new line.
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index 8c96100..a29867c 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -138,7 +138,7 @@ 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;
+ int size = 1;
int color;
int sx[2], sy[2];
@@ -152,28 +152,18 @@ void o_net_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
color = o_current->color;
}
- gdk_gc_set_foreground(w_current->gc, x_get_darkcolor (color));
-
if (toplevel->net_style == THICK ) {
size = SCREENabs(toplevel, NET_WIDTH);
- gdk_gc_set_line_attributes (w_current->gc, size+1,
- GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_MITER);
+ size += 1;
}
WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
- gdk_draw_line (w_current->drawable, w_current->gc,
- sx[0], sy[0], sx[1], sy[1]);
+ gschem_cairo_line (w_current->cr, END_NONE, size, sx[0], sy[0], sx[1], sy[1]);
- if (toplevel->net_style == THICK ) {
- gdk_gc_set_line_attributes(w_current->gc, 0,
- GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_MITER);
- }
+ 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);
}
/*! \todo Finish function documentation!!!
diff --git a/gschem/src/o_path.c b/gschem/src/o_path.c
index 88ad217..4f5c7d1 100644
--- a/gschem/src/o_path.c
+++ b/gschem/src/o_path.c
@@ -132,16 +132,6 @@ static void path_to_points_modify (GSCHEM_TOPLEVEL *w_current, PATH *path,
}
-static void path_to_points (GSCHEM_TOPLEVEL *w_current, PATH *path,
- int dx, int dy,
- GdkPoint **points, int *num_points)
-{
- path_to_points_modify (w_current, path,
- dx, dy, 0, 0, -1,
- points, num_points);
-}
-
-
/*! \brief Placeholder filling function.
* \par Function Description
* This function does nothing. It has the same prototype as all the
@@ -499,37 +489,69 @@ void o_path_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
*/
void o_path_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
{
+ TOPLEVEL *toplevel = w_current->toplevel;
PATH *path = o_current->path;
int color;
- int num_points;
- GdkPoint *points;
-
- path_to_points (w_current, path, dx, dy, &points, &num_points);
+ int line_width = 1;
+ PATH_SECTION *section;
+ int i;
+ int x1, y1, x2, y2, x3, y3;
+ double fx1 = 0.0, fy1 = 0.0;
+ double fx2 = 0.0, fy2 = 0.0;
+ double fx3 = 0.0, fy3 = 0.0;
- if (num_points == 0) {
- g_free (points);
+ if (path == NULL) {
return;
}
- if (o_current->saved_color != -1) {
- color = o_current->saved_color;
+ if (toplevel->override_color != -1 ) {
+ color = toplevel->override_color;
} else {
color = o_current->color;
}
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor(color));
- gdk_gc_set_line_attributes (w_current->gc, 0, GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
+ for (i = 0; i < path->num_sections; i++) {
+ section = &path->sections[i];
- /* Stroke only, no fill for place drawing */
- if (path->sections[path->num_sections - 1].code == PATH_END)
- gdk_draw_polygon (w_current->drawable, w_current->gc,
- FALSE, points, num_points);
- else
- gdk_draw_lines (w_current->drawable, w_current->gc,
- points, num_points);
+ switch (section->code) {
+ case PATH_CURVETO:
+ /* Two control point grips */
+ WORLDtoSCREEN (toplevel, section->x1 + dx, section->y1 + dy, &x1, &y1);
+ WORLDtoSCREEN (toplevel, section->x2 + dx, section->y2 + dy, &x2, &y2);
+ hint_coordinates (x1, y1, &fx1, &fy1, line_width);
+ hint_coordinates (x2, y2, &fx2, &fy2, line_width);
+ /* Fall through */
+ case PATH_MOVETO:
+ case PATH_MOVETO_OPEN:
+ case PATH_LINETO:
+ /* Destination point grip */
+ WORLDtoSCREEN (toplevel, section->x3 + dx, section->y3 + dy, &x3, &y3);
+ hint_coordinates (x3, y3, &fx3, &fy3, line_width);
+ case PATH_END:
+ break;
+ }
- g_free (points);
+ switch (section->code) {
+ case PATH_MOVETO:
+ cairo_close_path (w_current->cr);
+ /* fall-through */
+ case PATH_MOVETO_OPEN:
+ cairo_move_to (w_current->cr, fx3, fy3);
+ break;
+ case PATH_CURVETO:
+ cairo_curve_to (w_current->cr, fx1, fy1, fx2, fy2, fx3, fy3);
+ break;
+ case PATH_LINETO:
+ cairo_line_to (w_current->cr, fx3, fy3);
+ break;
+ case PATH_END:
+ cairo_close_path (w_current->cr);
+ break;
+ }
+ }
+
+ 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);
}
/*! \brief Start process to input a new path.
diff --git a/gschem/src/o_picture.c b/gschem/src/o_picture.c
index 51ea357..387dcff 100644
--- a/gschem/src/o_picture.c
+++ b/gschem/src/o_picture.c
@@ -450,20 +450,17 @@ void o_picture_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o
&screen_x1, &screen_y1 );
WORLDtoSCREEN( toplevel, 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;
}
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor(color));
- gdk_draw_rectangle (w_current->drawable,
- w_current->gc, FALSE,
- screen_x1,
- screen_y1,
- abs(screen_x2 - screen_x1),
- abs(screen_y2 - screen_y1));
+ 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);
}
/*! \brief Replace all selected pictures with a new picture
diff --git a/gschem/src/o_pin.c b/gschem/src/o_pin.c
index 2845cdc..241a3cc 100644
--- a/gschem/src/o_pin.c
+++ b/gschem/src/o_pin.c
@@ -98,7 +98,7 @@ 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;
+ int size = 1;
int color;
int sx[2], sy[2];
@@ -112,28 +112,16 @@ void o_pin_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
color = o_current->color;
}
- gdk_gc_set_foreground(w_current->gc, x_get_darkcolor (color));
-
- if (toplevel->pin_style == THICK ) {
+ if (toplevel->pin_style == THICK )
size = SCREENabs(toplevel, PIN_WIDTH);
- gdk_gc_set_line_attributes (w_current->gc, size,
- GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_MITER);
- }
WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
- gdk_draw_line (w_current->drawable, w_current->gc,
- sx[0], sy[0], sx[1], sy[1]);
+ gschem_cairo_line (w_current->cr, END_NONE, size, sx[0], sy[0], sx[1], sy[1]);
- if (toplevel->pin_style == THICK ) {
- gdk_gc_set_line_attributes (w_current->gc, 0,
- GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_MITER);
- }
+ 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);
}
/*! \todo Finish function documentation!!!
diff --git a/gschem/src/o_text.c b/gschem/src/o_text.c
index e5cf68d..4f6f4ab 100644
--- a/gschem/src/o_text.c
+++ b/gschem/src/o_text.c
@@ -253,15 +253,10 @@ void o_text_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
color = o_current->color;
}
- gdk_gc_set_foreground (w_current->gc, x_get_darkcolor (color));
+ gschem_cairo_box (w_current->cr, 1, left, top, right, bottom);
- gdk_draw_rectangle (w_current->drawable,
- w_current->gc,
- FALSE,
- left,
- top,
- right - left,
- bottom - top);
+ 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);
}
}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs