[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-250-g2d2d9d9)
The branch, master has been updated
via 2d2d9d90d07080ed18a899dcccc34e99c83a7402 (commit)
via 49536f111d55100ea12574a445264074fee321e3 (commit)
from bcaf9f8dafcd25335b61b2ea80d071bde720bbd1 (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_path.c | 430 +++++++++++++++++++++++++++++++++++++++----
libgeda/src/o_path_basic.c | 443 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 803 insertions(+), 70 deletions(-)
=================
Commit Messages
=================
commit 2d2d9d90d07080ed18a899dcccc34e99c83a7402
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Sun Oct 26 10:42:58 2008 +0000
Add place-holders for printing paths with different line / fill styles
Currently, paths are always drawn with a solid stroked outline, and
only solid filling is implemented.
:100644 100644 8ca7ffa... 73569ca... M gschem/src/o_path.c
commit 49536f111d55100ea12574a445264074fee321e3
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Sun Oct 26 10:42:58 2008 +0000
Add place-holders for printing paths with different line / fill styles
Currently, paths are always drawn with a solid stroked outline, and
only solid filling is implemented.
:100644 100644 332cc09... 730f459... M libgeda/src/o_path_basic.c
=========
Changes
=========
commit 2d2d9d90d07080ed18a899dcccc34e99c83a7402
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Sun Oct 26 10:42:58 2008 +0000
Add place-holders for printing paths with different line / fill styles
Currently, paths are always drawn with a solid stroked outline, and
only solid filling is implemented.
diff --git a/gschem/src/o_path.c b/gschem/src/o_path.c
index 8ca7ffa..73569ca 100644
--- a/gschem/src/o_path.c
+++ b/gschem/src/o_path.c
@@ -29,6 +29,17 @@
#endif
+typedef void (*DRAW_FUNC) (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ GdkCapStyle cap,
+ gint line_width, gint length, gint space);
+
+typedef void (*FILL_FUNC) (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_currentm, PATH *path,
+ gint fill_width,
+ gint angle1, gint pitch1, gint angle2, gint pitch2);
+
+
static void path_to_points_modify (GSCHEM_TOPLEVEL *w_current, PATH *path,
int dx, int dy, int new_x, int new_y, int whichone,
GdkPoint **points, int *num_points)
@@ -120,6 +131,280 @@ static void find_points_bounds (GdkPoint *points, int num_points,
}
}
+/*! \brief Draw a path with a solid line type.
+ * \par Function Description
+ * This function draws a path with a solid line type. The length and space
+ * parameters are not used by this function.
+ *
+ * \param [in] w GdkDrawable to draw in
+ * \param [in] gc GdkGC graphics context to draw on
+ * \param [in] color Box line color
+ * \param [in] cap Box line end cap type (unused)
+ * \param [in] path The PATH object to draw
+ * \param [in] line_width Width of line to draw path
+ * \param [in] length (unused)
+ * \param [in] space (unused)
+ */
+void o_path_draw_solid(GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ GdkCapStyle cap, gint line_width,
+ gint length, gint space)
+{
+ GdkPoint *points;
+ int num_points;
+
+ path_to_points (w_current, path, 0, 0, &points, &num_points);
+
+ if (num_points == 0) {
+ g_free (points);
+ return;
+ }
+
+
+ gdk_gc_set_foreground(gc, color);
+
+ /* Set the width, end type and join style of the line */
+ gdk_gc_set_line_attributes(gc, line_width, GDK_LINE_SOLID,
+ cap, GDK_JOIN_MITER);
+
+ if (path->sections[path->num_sections - 1].code == PATH_END) {
+ /* Closed path */
+ gdk_draw_polygon (w_current->backingstore, w_current->gc,
+ FALSE, points, num_points);
+ } else {
+ /* Open path */
+ gdk_draw_lines (w_current->backingstore, w_current->gc,
+ points, num_points);
+ }
+
+ g_free (points);
+}
+
+/*! \brief Draw a path with a dotted line type.
+ * \par Function Description
+ * This function draws a path with a dotted line type. The parameter
+ * <B>space</B> represents the distance between two of the dots. The
+ * parameter <B>length</B> is unused. The diameter of the dots is given by
+ * the width of the line given by <B>width</B>.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box line color.
+ * \param [in] cap Box line end cap type (unused).
+ * \param [in] path The PATH object to draw
+ * \param [in] line_width Width of line to draw path.
+ * \param [in] length (unused)
+ * \param [in] space Space in pixels between dots.
+ */
+
+static void o_path_draw_dotted (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ GdkCapStyle cap, gint line_width,
+ gint length, gint space)
+{
+ o_path_draw_solid (w, gc, color, w_current, path, cap,
+ line_width, length, space);
+}
+
+/*! \brief Draw a path with a dashed line type.
+ * \par Function Description
+ * This function draws a path with a dashed line type. The parameter
+ * <B>space</B> represents the distance between two of the dash. The
+ * parameter <B>length</B> represents the length of a dash.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box line color.
+ * \param [in] cap Box line end cap type (unused).
+ * \param [in] path The PATH object to draw
+ * \param [in] line_width Width of line to draw path.
+ * \param [in] length Length of dash in pixels.
+ * \param [in] space Space between dashes in pixels.
+ */
+static void o_path_draw_dashed (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ GdkCapStyle cap, gint line_width,
+ gint length, gint space)
+{
+ o_path_draw_solid (w, gc, color, w_current, path, cap,
+ line_width, length, space);
+}
+
+/*! \brief Draw a path with a centered line type.
+ * \par Function Description
+ * This function draws a path with a centered line type. The parameter
+ * <B>space</B> represents the distance between a dot and the dash. The
+ * parameter <B>length</B> represents the length of a dash.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box line color.
+ * \param [in] cap Box line end cap type (unused).
+ * \param [in] path The PATH object to draw
+ * \param [in] line_width Width of line to draw path.
+ * \param [in] length (unused)?
+ * \param [in] space (unused)?
+ */
+static void o_path_draw_center (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ GdkCapStyle cap, gint line_width,
+ gint length, gint space)
+{
+ o_path_draw_solid (w, gc, color, w_current, path, cap,
+ line_width, length, space);
+}
+
+/*! \brief Draw a path with a phantom line type.
+ * \par Function Description
+ * This function draws a path with a phantom line type. The parameter
+ * <B>space</B> represents the distance between a dot and a dash.
+ * The parameter <B>length</B> represents the length of a dash.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box line color.
+ * \param [in] cap Box line end cap type (unused).
+ * \param [in] path The PATH object to draw
+ * \param [in] line_width Width of line to draw path.
+ * \param [in] length (unused)?
+ * \param [in] space (unused)?
+ */
+static void o_path_draw_phantom (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ GdkCapStyle cap, gint line_width,
+ gint length, gint space)
+{
+ o_path_draw_solid (w, gc, color, w_current, path, cap,
+ line_width, length, space);
+}
+
+/*! \brief Placeholder filling function.
+ * \par Function Description
+ * This function does nothing. It has the same prototype as all the
+ * filling functions. It prevent from making a difference between filling
+ * in function #o_path_draw().
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box fill color.
+ * \param [in] path The PATH object to draw
+ * \param [in] fill_width PATH pattern fill width.
+ * \param [in] angle1 1st angle for pattern.
+ * \param [in] pitch1 1st pitch for pattern.
+ * \param [in] angle2 2nd angle for pattern.
+ * \param [in] pitch2 2nd pitch for pattern.
+ */
+static void o_path_fill_hollow (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ gint fill_width,
+ gint angle1, gint pitch1,
+ gint angle2, gint pitch2)
+{
+ /* NOP */
+}
+
+/*! \brief Fill inside of path with a solid pattern.
+ * \par Function Description
+ * This function fills the inside of the path with a solid pattern.
+ * Parameters <B>angle1</B>, <B>pitch1</B> and <B>angle2</B>,
+ * <B>pitch2</B> and <B>fill_width</B> are unused here but kept for compatibility
+ * with other path filling functions.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box fill color.
+ * \param [in] path The PATH object to draw
+ * \param [in] fill_width PATH pattern fill width.
+ * \param [in] angle1 (unused)
+ * \param [in] pitch1 (unused)
+ * \param [in] angle2 (unused)
+ * \param [in] pitch2 (unused)
+ */
+static void o_path_fill_fill (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ gint fill_width,
+ gint angle1, gint pitch1,
+ gint angle2, gint pitch2)
+{
+ GdkPoint *points;
+ int num_points;
+
+ gdk_gc_set_foreground(gc, color);
+ gdk_gc_set_line_attributes(gc, 1, GDK_LINE_SOLID,
+ GDK_CAP_BUTT, GDK_JOIN_MITER);
+ path_to_points (w_current, path, 0, 0, &points, &num_points);
+
+ if (num_points == 0) {
+ g_free (points);
+ return;
+ }
+
+ gdk_draw_polygon(w_current->backingstore, w_current->gc,
+ TRUE, points, num_points);
+
+ g_free (points);
+}
+
+/*! \brief Fill inside of path with single line pattern.
+ * \par Function Description
+ * This function fills the inside of the path with a pattern made of lines.
+ * The lines are drawn inside the path with an angle <B>angle1</B> from the
+ * horizontal. The distance between two of these lines is given by
+ * <B>pitch1</B> and their width by <B>fill_width</B>.
+ * Parameters <B>angle2</B> and <B>pitch2</B> are unused here but kept for
+ * compatbility with other path filling functions.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box fill color.
+ * \param [in] path The PATH object to draw
+ * \param [in] fill_width PATH pattern fill width.
+ * \param [in] angle1 1st angle for pattern.
+ * \param [in] pitch1 1st pitch for pattern.
+ * \param [in] angle2 (unused)
+ * \param [in] pitch2 (unused)
+ */
+static void o_path_fill_hatch (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ gint fill_width,
+ gint angle1, gint pitch1,
+ gint angle2, gint pitch2)
+{
+ /* Not implemented */
+}
+
+
+/*! \brief Fill inside of path with mesh pattern.
+ * \par Function Description
+ * This function fills the inside of the path with a pattern made of two
+ * sets of parallel lines in two directions. The first set is drawn inside
+ * the path with an angle <B>angle1</B> from the horizontal. The distance
+ * between two of these lines is given by <B>pitch1</B>.
+ * The second set is drawn inside the path with an angle <B>angle2</B> from
+ * the horizontal. The distance between two of these lines is given
+ * by <B>pitch2</B>.
+ *
+ * \param [in] w GdkDrawable to draw in.
+ * \param [in] gc GdkGC graphics context to draw on.
+ * \param [in] color Box fill color.
+ * \param [in] path The PATH object to draw
+ * \param [in] fill_width PATH pattern fill width.
+ * \param [in] angle1 1st angle for pattern.
+ * \param [in] pitch1 1st pitch for pattern.
+ * \param [in] angle2 2nd angle for pattern.
+ * \param [in] pitch2 2nd pitch for pattern.
+ */
+static void o_path_fill_mesh (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+ GSCHEM_TOPLEVEL *w_current, PATH *path,
+ gint fill_width,
+ gint angle1, gint pitch1,
+ gint angle2, gint pitch2)
+{
+ o_path_fill_hatch (w, gc, color, w_current, path,
+ fill_width, angle1, pitch1, -1, -1);
+ o_path_fill_hatch (w, gc, color, w_current, path,
+ fill_width, angle2, pitch2, -1, -1);
+}
/*! \brief Draw a path on screen.
* \par Function Description
@@ -128,9 +413,6 @@ static void find_points_bounds (GdkPoint *points, int num_points,
* according to the current state, described in the GSCHEM_TOPLEVEL object pointed
* by <B>w_current</B>.
*
- * It first checks if the object is valid or not. If not it returns and do
- * not output anything. That should never happen though.
- *
* \param [in] w_current The GSCHEM_TOPLEVEL object.
* \param [in] o_current The path OBJECT to draw.
*/
@@ -139,9 +421,9 @@ 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 wleft, wtop, wright, wbottom;
- GdkPoint *points;
- int num_points;
+ int fill_width, angle1, pitch1, angle2, pitch2;
+ DRAW_FUNC draw_func = NULL;
+ FILL_FUNC fill_func;
GdkColor *color;
GdkCapStyle path_end;
@@ -150,13 +432,6 @@ void o_path_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
return;
}
- world_get_single_object_bounds(toplevel, o_current,
- &wleft, &wtop, &wright, &wbottom);
- if ( (toplevel->DONT_REDRAW == 1) ||
- (!visible(toplevel, wleft, wtop, wright, wbottom)) ) {
- return;
- }
-
if (toplevel->override_color != -1 )
color = x_get_color(toplevel->override_color);
else
@@ -181,37 +456,117 @@ void o_path_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
length = SCREENabs( toplevel, o_current->line_length );
space = SCREENabs( toplevel, o_current->line_space );
- path_to_points (w_current, path, 0, 0, &points, &num_points);
+ switch(o_current->line_type) {
+ case TYPE_SOLID:
+ length = -1;
+ space = -1;
+ draw_func = o_path_draw_solid;
+ break;
- if (num_points == 0) {
- g_free (points);
- return;
+ case TYPE_DOTTED:
+ length = -1; /* ..._draw_dotted only space is used */
+ draw_func = o_path_draw_dotted;
+ break;
+
+ case TYPE_DASHED:
+ draw_func = o_path_draw_dashed;
+ break;
+
+ case TYPE_CENTER:
+ draw_func = o_path_draw_center;
+ break;
+
+ case TYPE_PHANTOM:
+ draw_func = o_path_draw_phantom;
+ break;
+
+ case TYPE_ERASE:
+ break;
+
+ default:
+ length = -1;
+ space = -1;
+ line_width = 0; /* just to be careful */
+ draw_func = o_path_draw_solid;
+ fprintf(stderr, _("Unknown type for path !\n"));
+ break;
}
- /* TODO: Currently we only support solid line drawing */
- gdk_gc_set_foreground(w_current->gc, color);
- gdk_gc_set_line_attributes(w_current->gc, line_width, GDK_LINE_SOLID,
- path_end, GDK_JOIN_MITER);
+ if((length == 0) || (space == 0))
+ draw_func = o_path_draw_solid;
+
+ (*draw_func) (w_current->backingstore, w_current->gc, color, w_current,
+ o_current->path, path_end, line_width, length, 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( toplevel, o_current->fill_width );
+ if(fill_width <= 0) {
+ fill_width = 1;
+ }
- /* Stroke */
- if (path->sections[path->num_sections - 1].code == PATH_END)
- gdk_draw_polygon (w_current->backingstore, w_current->gc,
- FALSE, points, num_points);
- else
- gdk_draw_lines (w_current->backingstore, w_current->gc,
- points, num_points);
+ angle1 = o_current->fill_angle1;
+ pitch1 = o_current->fill_pitch1;
+ angle2 = o_current->fill_angle2;
+ pitch2 = o_current->fill_pitch2;
+
+ switch(o_current->fill_type) {
+ case FILLING_HOLLOW:
+ angle1 = -1; angle2 = -1;
+ pitch1 = 1; pitch2 = 1;
+ /* this function is empty ! however if it do not use it we have to add
+ * a test before the call. Simply putting a return here instead is not
+ * possible as it would prevent any hollow path from having its grips
+ * drawn
+ */
+ fill_func = o_path_fill_hollow;
+ break;
- /* TODO: Currently we only support solid fill drawing */
- /* Fill */
- if (o_current->fill_type != FILLING_HOLLOW)
- gdk_draw_polygon(w_current->backingstore, w_current->gc,
- TRUE, points, num_points);
+ case FILLING_FILL:
+ angle1 = -1; angle2 = -1;
+ pitch1 = 1; pitch2 = 1;
+ fill_func = o_path_fill_fill;
+ break;
- /* reset line width and reset back to default */
- gdk_gc_set_line_attributes(w_current->gc, 0, GDK_LINE_SOLID,
- GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
+ case FILLING_MESH:
+ fill_func = o_path_fill_mesh;
+ break;
- g_free (points);
+ case FILLING_HATCH:
+ angle2 = -1;
+ pitch2 = 1;
+ fill_func = o_path_fill_hatch;
+ break;
+
+ case FILLING_VOID:
+ default:
+ angle1 = -1; angle2 = -1;
+ pitch1 = 1; pitch2 = 1;
+ fill_func = o_path_fill_hollow;
+ fprintf(stderr, _("Unknown type for path (fill)!\n"));
+ }
+
+ if((pitch1 <= 0) || (pitch2 <= 0)) {
+ fill_func = o_path_fill_fill;
+ }
+
+ (*fill_func) (w_current->backingstore, w_current->gc, color,
+ w_current, path, fill_width, angle1, pitch1, angle2, pitch2);
if (o_current->draw_grips && w_current->draw_grips == TRUE) {
if (!o_current->selected) {
@@ -223,7 +578,6 @@ void o_path_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
o_path_draw_grips(w_current, o_current);
}
}
-
}
commit 49536f111d55100ea12574a445264074fee321e3
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Sun Oct 26 10:42:58 2008 +0000
Add place-holders for printing paths with different line / fill styles
Currently, paths are always drawn with a solid stroked outline, and
only solid filling is implemented.
diff --git a/libgeda/src/o_path_basic.c b/libgeda/src/o_path_basic.c
index 332cc09..730f459 100644
--- a/libgeda/src/o_path_basic.c
+++ b/libgeda/src/o_path_basic.c
@@ -32,6 +32,18 @@
/*! Default setting for path draw function. */
void (*path_draw_func)() = NULL;
+
+typedef void (*DRAW_FUNC) (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int line_width, int length, int space,
+ int origin_x, int origin_y);
+
+
+typedef void (*FILL_FUNC) (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int fill_width,
+ int angle1, int pitch1, int angle2, int pitch2,
+ int origin_x, int origin_y);
+
+
/*! \brief Create and add path OBJECT to list.
* \par Function Description
* This function creates a new object representing a path.
@@ -568,47 +580,197 @@ void world_get_path_bounds (TOPLEVEL *toplevel, OBJECT *object,
}
-/*! \brief Print path to Postscript document.
+/*! \brief Print a solid PATH to Postscript document.
* \par Function Description
- * This function prints the path described by the <B>o_current</B>
- * parameter to a Postscript document.
- * The Postscript document is described by the <B>fp</B> file pointer.
+ * This function prints the outline of a path when a solid line type is
+ * required. The postscript file is defined by the file pointer <B>fp</B>.
+ * The parameters <B>length</B> and <B>space</B> are ignored.
*
- * Parameters of the path are extracted from object pointed by
- * <B>o_current</B>.
+ * All dimensions are in mils.
*
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] fp FILE pointer to Postscript document.
- * \param [in] o_current Line OBJECT to write to document.
- * \param [in] origin_x Page x coordinate to place path OBJECT.
- * \param [in] origin_y Page y coordinate to place path OBJECT.
+ * \param [in] toplevel The TOPLEVEL object.
+ * \param [in] fp FILE pointer to Postscript document.
+ * \param [in] x Upper x coordinate of PATH.
+ * \param [in] y Upper y coordinate of PATH.
+ * \param [in] width Width of PATH.
+ * \param [in] height Height of PATH.
+ * \param [in] line_width PATH Line width.
+ * \param [in] length Dashed line length.
+ * \param [in] space Amount of space between dashes.
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT.
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT.
*/
-void o_path_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
- int origin_x, int origin_y)
+static void o_path_print_solid (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int line_width, int length, int space,
+ int origin_x, int origin_y)
{
- PATH_SECTION *section;
- GString *path_string;
- int line_width;
int i;
- line_width = o_current->line_width;
- if (line_width <=2) {
- if (toplevel->line_style == THICK) {
- line_width = LINE_WIDTH;
- } else {
- line_width = 2;
+ for (i = 0; i < path->num_sections; i++) {
+ PATH_SECTION *section = &path->sections[i];
+
+ if (i > 0)
+ fprintf (fp, " ");
+
+ switch (section->code) {
+ case PATH_MOVETO:
+ fprintf (fp, "closepath ");
+ /* Fall through */
+ case PATH_MOVETO_OPEN:
+ fprintf (fp, "%i %i moveto",
+ section->x3 - origin_x, section->y3 - origin_y);
+ break;
+ case PATH_CURVETO:
+ fprintf (fp, "%i %i %i %i %i %i curveto",
+ section->x1 - origin_x, section->y1 - origin_y,
+ section->x2 - origin_x, section->y2 - origin_y,
+ section->x3 - origin_x, section->y3 - origin_y);
+ break;
+ case PATH_LINETO:
+ fprintf (fp, "%i %i lineto",
+ section->x3 - origin_x, section->y3 - origin_y);
+ break;
+ case PATH_END:
+ fprintf (fp, "closepath ");
+ break;
}
}
- path_string = g_string_new ("");
+ fprintf (fp, "stroke\n");
+}
- if (toplevel->print_color)
- f_print_set_color (fp, o_current->color);
- f_print_set_line_width (fp, line_width);
+/*! \brief Print a dotted PATH to Postscript document.
+ * \par Function Description
+ * This function prints the outline of a path when a dotted line type is
+ * required. The postscript file is defined by the file pointer <B>fp</B>.
+ * The parameter <B>length</B> is ignored.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object
+ * \param [in] fp FILE pointer to Postscript document
+ * \param [in] path The PATH object to print
+ * \param [in] line_width PATH Line width
+ * \param [in] length Dashed line length
+ * \param [in] space Amount of space between dashes
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT
+ */
+static void o_path_print_dotted (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int line_width, int length, int space,
+ int origin_x, int origin_y)
+{
+ o_path_print_solid (toplevel, fp, path, line_width,
+ length, space, origin_x, origin_y);
+}
+
+
+/*! \brief Print a dashed PATH to Postscript document.
+ * \par Function Description
+ * This function prints the outline of a path when a dashed line type is
+ * required. The postscript file is defined by the file pointer <B>fp</B>.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object.
+ * \param [in] fp FILE pointer to Postscript document.
+ * \param [in] path The PATH object to print.
+ * \param [in] line_width PATH Line width.
+ * \param [in] length Dashed line length.
+ * \param [in] space Amount of space between dashes.
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT.
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT.
+ */
+static void o_path_print_dashed (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int line_width, int length, int space,
+ int origin_x, int origin_y)
+{
+ o_path_print_solid (toplevel, fp, path, line_width,
+ length, space, origin_x, origin_y);
+}
+
+
+/*! \brief Print centered line type PATH to Postscript document.
+ * \par Function Description
+ * This function prints the outline of a path when a centered line type is
+ * required. The postscript file is defined by the file pointer <B>fp</B>.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object
+ * \param [in] fp FILE pointer to Postscript document
+ * \param [in] path The PATH object to print
+ * \param [in] line_width PATH Line width
+ * \param [in] length Dashed line length
+ * \param [in] space Amount of space between dashes
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT
+ */
+static void o_path_print_center (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int line_width, int length,
+ int space, int origin_x, int origin_y)
+{
+ o_path_print_solid (toplevel, fp, path, line_width,
+ length, space, origin_x, origin_y);
+}
+
+
+/*! \brief Print phantom line type PATH to Postscript document.
+ * \par Function Description
+ * This function prints the outline of a path when a phantom line type is
+ * required. The postscript file is defined by the file pointer <B>fp</B>.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object
+ * \param [in] fp FILE pointer to Postscript document
+ * \param [in] path The PATH object to print
+ * \param [in] line_width PATH Line width
+ * \param [in] length Dashed line length
+ * \param [in] space Amount of space between dashes
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT
+ */
+static void o_path_print_phantom (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int line_width, int length,
+ int space, int origin_x, int origin_y)
+{
+ o_path_print_solid (toplevel, fp, path, line_width,
+ length, space, origin_x, origin_y);
+}
+
+
+/*! \brief Print a solid pattern PATH to Postscript document.
+ * \par Function Description
+ * The function prints a filled path with a solid pattern. No outline is
+ * printed. The postscript file is defined by the file pointer <B>fp</B>.
+ * <B>fill_width</B>, <B>angle1</B> and <B>pitch1</B>, <B>angle2</B> and <B>pitch2</B>
+ * parameters are ignored in this functions but kept for compatibility
+ * with other fill functions.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object
+ * \param [in] fp FILE pointer to Postscript document
+ * \param [in] path The PATH object to print
+ * \param [in] fill_width PATH fill width (unused)
+ * \param [in] angle1 (unused)
+ * \param [in] pitch1 (unused)
+ * \param [in] angle2 (unused)
+ * \param [in] pitch2 (unused)
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT
+ */
+static void o_path_print_filled (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int fill_width,
+ int angle1, int pitch1, int angle2, int pitch2,
+ int origin_x, int origin_y)
+{
+ int i;
- for (i = 0; i < o_current->path->num_sections; i++) {
- section = &o_current->path->sections[i];
+ for (i = 0; i < path->num_sections; i++) {
+ PATH_SECTION *section = &path->sections[i];
if (i > 0)
fprintf (fp, " ");
@@ -637,10 +799,227 @@ void o_path_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
}
}
- if (o_current->fill_type == FILLING_HOLLOW) {
- fprintf (fp, "stroke\n");
- } else {
- fprintf (fp, "gsave fill grestore stroke\n");
+ fprintf (fp, "fill\n");
+}
+
+
+/*! \brief Print a hatch pattern PATH to Postscript document.
+ * \par Function Description
+ * The function prints a hatched path. No outline is printed.
+ * The postscript file is defined by the file pointer <B>fp</B>.
+ * <B>fill_width</B>, <B>angle1</B>, <B>pitch1</B> parameters define the way the path
+ * has to be hatched.
+ * <B>angle2</B> and <B>pitch2</B> parameters are unused but kept for compatibility
+ * with other fill functions.
+ *
+ * Negative or zero values for <B>pitch1</B> are not allowed.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object
+ * \param [in] fp FILE pointer to Postscript document
+ * \param [in] path The PATH object to print
+ * \param [in] fill_width PATH fill width
+ * \param [in] angle1 Angle of hatch pattern
+ * \param [in] pitch1 Pitch of hatch pattern
+ * \param [in] angle2 (unused)
+ * \param [in] pitch2 (unused)
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT
+ */
+static void o_path_print_hatch (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int fill_width,
+ int angle1, int pitch1, int angle2, int pitch2,
+ int origin_x, int origin_y)
+{
+ /* Not implemented */
+}
+
+
+/*! \brief Print a mesh pattern PATH to Postscript document.
+ * \par Function Description
+ * This function prints a meshed path. No outline is printed.
+ * The postscript file is defined by the file pointer <B>fp</B>.
+ *
+ * Negative or zero values for <B>pitch1</B> and/or <B>pitch2</B> are
+ * not allowed.
+ *
+ * All dimensions are in mils.
+ *
+ * \param [in] toplevel The TOPLEVEL object
+ * \param [in] fp FILE pointer to Postscript document
+ * \param [in] path The PATH object to print
+ * \param [in] fill_width PATH fill width
+ * \param [in] angle1 1st angle for mesh pattern
+ * \param [in] pitch1 1st pitch for mesh pattern
+ * \param [in] angle2 2nd angle for mesh pattern
+ * \param [in] pitch2 2nd pitch for mesh pattern
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT
+ */
+static void o_path_print_mesh (TOPLEVEL *toplevel, FILE *fp, PATH *path,
+ int fill_width,
+ int angle1, int pitch1, int angle2, int pitch2,
+ int origin_x, int origin_y)
+{
+ o_path_print_hatch (toplevel, fp, path, fill_width,
+ angle1, pitch1, -1, -1, origin_x, origin_y);
+
+ o_path_print_hatch (toplevel, fp, path, fill_width,
+ angle2, pitch2, -1, -1, origin_x, origin_y);
+}
+
+
+/*! \brief Print PATH to Postscript document.
+ * \par Function Description
+ * This function prints the path described by the <B>o_current</B>
+ * parameter to a Postscript document.
+ * The Postscript document is descibed by the file pointer <B>fp</B>.
+ *
+ * \param [in] toplevel The TOPLEVEL object.
+ * \param [in] fp FILE pointer to Postscript document.
+ * \param [in] o_current PATH OBJECT to write to document.
+ * \param [in] origin_x Page x coordinate to place PATH OBJECT.
+ * \param [in] origin_y Page y coordinate to place PATH OBJECT.
+ */
+void o_path_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
+ int origin_x, int origin_y)
+{
+ int color;
+ int line_width, length, space;
+ int fill_width, angle1, pitch1, angle2, pitch2;
+ DRAW_FUNC outl_func = NULL;
+ FILL_FUNC fill_func = NULL;
+
+ color = o_current->color;
+
+ /*! \note
+ * Depending on the type of the line for this particular path, the
+ * appropriate function is chosen among #o_path_print_solid(),
+ * #o_path_print_dotted(), #o_path_print_dashed(),
+ * #o_path_print_center() and #o_path_print_phantom().
+ *
+ * The needed parameters for each of these type is extracted from the
+ * <B>o_current</B> object. Depending on the type, unused parameters are
+ * set to -1.
+ *
+ * In the eventuality of a length and/or space null, the line is printed
+ * solid to avoid and endless loop produced by other functions in such a
+ * case.
+ */
+ line_width = o_current->line_width;
+
+ if (line_width <= 2) {
+ if (toplevel->line_style == THICK) {
+ line_width = LINE_WIDTH;
+ } else {
+ line_width=2;
+ }
+ }
+ length = o_current->line_length;
+ space = o_current->line_space;
+
+ switch(o_current->line_type) {
+ case TYPE_SOLID:
+ length = -1; space = -1;
+ outl_func = o_path_print_solid;
+ break;
+
+ case TYPE_DOTTED:
+ length = -1;
+ outl_func = o_path_print_dotted;
+ break;
+
+ case TYPE_DASHED:
+ outl_func = o_path_print_dashed;
+ break;
+
+ case TYPE_CENTER:
+ outl_func = o_path_print_center;
+ break;
+
+ case TYPE_PHANTOM:
+ outl_func = o_path_print_phantom;
+ break;
+
+ case TYPE_ERASE:
+ /* Unused for now, print it solid */
+ length = -1; space = -1;
+ outl_func = o_path_print_solid;
+ break;
+ }
+
+ if((length == 0) || (space == 0)) {
+ length = -1; space = -1;
+ outl_func = o_path_print_solid;
+ }
+
+ if (toplevel->print_color)
+ f_print_set_color (fp, o_current->color);
+
+ f_print_set_line_width (fp, line_width);
+
+ (*outl_func) (toplevel, fp, o_current->path, line_width,
+ length, space, origin_x, origin_y);
+
+ /*! \note
+ * If the filling type of the path is not <B>HOLLOW</B>, the appropriate
+ * function is chosen among #o_path_print_filled(), #o_path_print_mesh()
+ * and #o_path_print_hatch(). The corresponding parameters are extracted
+ * from the <B>o_current</B> object and corrected afterward.
+ *
+ * The case where <B>pitch1</B> and <B>pitch2</B> are null or negative is
+ * avoided as it leads to an endless loop in most of the called functions.
+ * In such a case, the path is printed filled. Unused parameters for each of
+ * these functions are set to -1 or any passive value.
+ */
+ if(o_current->fill_type != FILLING_HOLLOW) {
+ fill_width = o_current->fill_width;
+ angle1 = o_current->fill_angle1;
+ pitch1 = o_current->fill_pitch1;
+ angle2 = o_current->fill_angle2;
+ pitch2 = o_current->fill_pitch2;
+
+ switch(o_current->fill_type) {
+ case FILLING_FILL:
+ angle1 = -1; pitch1 = 1;
+ angle2 = -1; pitch2 = 1;
+ fill_width = -1;
+ fill_func = o_path_print_filled;
+ break;
+
+ case FILLING_MESH:
+ fill_func = o_path_print_mesh;
+ break;
+
+ case FILLING_HATCH:
+ angle2 = -1; pitch2 = 1;
+ fill_func = o_path_print_hatch;
+ break;
+
+ case FILLING_VOID:
+ /* Unused for now, print it filled */
+ angle1 = -1; pitch1 = 1;
+ angle2 = -1; pitch2 = 1;
+ fill_width = -1;
+ fill_func = o_path_print_filled;
+ break;
+
+ case FILLING_HOLLOW:
+ /* nop */
+ break;
+
+ }
+
+ if((pitch1 <= 0) || (pitch2 <= 0)) {
+ angle1 = -1; pitch1 = 1;
+ angle2 = -1; pitch2 = 1;
+ fill_func = o_path_print_filled;
+ }
+
+ (*fill_func) (toplevel, fp,
+ o_current->path, fill_width,
+ angle1, pitch1, angle2, pitch2, origin_x, origin_y);
}
}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs