libgeda

o_path_basic.c File Reference

#include <config.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "libgeda_priv.h"
Include dependency graph for o_path_basic.c:

Go to the source code of this file.

Typedefs

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)

Functions

OBJECTo_path_new (TOPLEVEL *toplevel, char type, int color, const char *path_string)
 Create and add path OBJECT to list.
OBJECTo_path_copy (TOPLEVEL *toplevel, OBJECT *o_current)
 Create a copy of a path.
OBJECTo_path_read (TOPLEVEL *toplevel, const char *first_line, TextBuffer *tb, unsigned int release_ver, unsigned int fileformat_ver, GError **err)
 Create path OBJECT from character string.
char * o_path_save (TOPLEVEL *toplevel, OBJECT *object)
 Create a character string representation of a path OBJECT.
void o_path_modify (TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone)
 Modify controol point location.
void o_path_translate_world (TOPLEVEL *toplevel, int dx, int dy, OBJECT *object)
 Translate a path position in WORLD coordinates by a delta.
void o_path_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object)
 Rotate Line OBJECT using WORLD coordinates.
void o_path_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object)
 Mirror a path using WORLD coordinates.
void o_path_recalc (TOPLEVEL *toplevel, OBJECT *o_current)
 Recalculate path coordinates in SCREEN units.
void world_get_path_bounds (TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom)
 Get path bounding rectangle in WORLD coordinates.
gboolean o_path_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object)
 get the position of the first path point
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)
 Print a solid PATH to Postscript document.
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)
 Print a dotted PATH to Postscript document.
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)
 Print a dashed PATH to Postscript document.
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)
 Print centered line type PATH to Postscript document.
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)
 Print phantom line type PATH to Postscript document.
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)
 Print a solid pattern PATH to Postscript document.
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)
 Print a hatch pattern PATH to Postscript document.
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)
 Print a mesh pattern PATH to Postscript document.
void o_path_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y)
 Print PATH to Postscript document.
double o_path_shortest_distance (OBJECT *object, int x, int y, int force_solid)
 Calculates the distance between the given point and the closest point on the given path segment.

Typedef Documentation

typedef void(* DRAW_FUNC)(TOPLEVEL *toplevel, FILE *fp, PATH *path, int line_width, int length, int space, int origin_x, int origin_y)

Definition at line 33 of file o_path_basic.c.

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)

Definition at line 38 of file o_path_basic.c.


Function Documentation

OBJECT* o_path_new ( TOPLEVEL toplevel,
char  type,
int  color,
const char *  path_string 
)
Function Description
This function creates a new object representing a path. This object is added to the end of the list object_list pointed object belongs to. The path is described by its two ends - x1,y1 and x2,y2. The type parameter must be equal to OBJ_PATH. The color parameter corresponds to the color the path will be drawn with.

The OBJECT structure is allocated with the s_basic_init_object() function. The structure describing the path is allocated and initialized with the parameters given to the function.

Both the path type and the filling type are set to default values : solid path type with a width of 0, and no filling. It can be changed after with the o_set_line_options() and o_set_fill_options().

The object is added to the end of the list described by the object_list parameter by the #s_basic_link_object().

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]typeMust be OBJ_PATH.
[in]colorThe path color.
[in]path_stringThe string representation of the path
Returns:
A pointer to the new end of the object list.

Definition at line 74 of file o_path_basic.c.

Here is the call graph for this function:

OBJECT* o_path_copy ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
This function creates a verbatim copy of the object pointed by o_current describing a path. The new object is added at the end of the list following the list_tail parameter.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]o_currentLine OBJECT to copy.
Returns:
A new pointer to the end of the object list.

Definition at line 109 of file o_path_basic.c.

Here is the call graph for this function:

OBJECT* o_path_read ( TOPLEVEL toplevel,
const char *  first_line,
TextBuffer tb,
unsigned int  release_ver,
unsigned int  fileformat_ver,
GError **  err 
)
Function Description
This function creates a path OBJECT from the character string *buf and a number of lines following that describing the path, read from *tb.

Depending on *version, the correct file format is considered. Currently two file format revisions are supported :

*
the file format used until 20010704 release.
*
the file format used for the releases after 20010704.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]first_lineCharacter string with path description.
[in]tbText buffer containing the path string.
[in]release_verlibgeda release version number.
[in]fileformat_verlibgeda file format version number.
Returns:
A pointer to the new path object, or NULL on error;

Definition at line 155 of file o_path_basic.c.

Here is the call graph for this function:

char* o_path_save ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
The function formats a string in the buffer *buff to describe the path object *object.
Parameters:
[in]toplevela TOPLEVEL structure
[in]objectpath OBJECT to create string from.
Returns:
A pointer to the path OBJECT character string.
Note:
Caller must g_free returned character string.

Definition at line 246 of file o_path_basic.c.

Here is the call graph for this function:

void o_path_modify ( TOPLEVEL toplevel,
OBJECT object,
int  x,
int  y,
int  whichone 
)
Function Description
This function modifies a control point location of the path object *object. The control point being modified is selected according to the whichone parameter.

The new position is given by x and y.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]objectThe path OBJECT
[in]xNew x coordinate for the control point
[in]yNew y coordinate for the control point
[in]whichoneWhich control point is being modified

Definition at line 300 of file o_path_basic.c.

Here is the call graph for this function:

void o_path_translate_world ( TOPLEVEL toplevel,
int  dx,
int  dy,
OBJECT object 
)
Function Description
This function applies a translation of (x1,y1) to the path described by *object. x1 and y1 are in world unit.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]dxx distance to move.
[in]dyy distance to move.
[in,out]objectLine OBJECT to translate.

Definition at line 354 of file o_path_basic.c.

Here is the call graph for this function:

void o_path_rotate_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
int  angle,
OBJECT object 
)
Function Description
This function rotates the path described by *object around the (world_centerx,world_centery) point by angle degrees. The center of rotation is in world units.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]world_centerxRotation center x coordinate in WORLD units.
[in]world_centeryRotation center y coordinate in WORLD units.
[in]angleRotation angle in degrees (See note below).
[in,out]objectLine OBJECT to rotate.

Definition at line 399 of file o_path_basic.c.

Here is the call graph for this function:

void o_path_mirror_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
OBJECT object 
)
Function Description
This function mirrors the path from the point (world_centerx,world_centery) in world unit.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]world_centerxOrigin x coordinate in WORLD units.
[in]world_centeryOrigin y coordinate in WORLD units.
[in,out]objectLine OBJECT to mirror.

Definition at line 445 of file o_path_basic.c.

Here is the call graph for this function:

void o_path_recalc ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
This function recalculate the bounding box of the o_current
Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]o_currentLine OBJECT to be recalculated.

Definition at line 482 of file o_path_basic.c.

Here is the call graph for this function:

void world_get_path_bounds ( TOPLEVEL toplevel,
OBJECT object,
int *  left,
int *  top,
int *  right,
int *  bottom 
)
Function Description
This function sets the left, top, right and bottom parameters to the boundings of the path object described in *path in world units.
Note:
Bounding box for bezier curves is loose because we just consider the convex hull of the curve control and end-points.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]objectLine OBJECT to read coordinates from.
[out]leftLeft path coordinate in WORLD units.
[out]topTop path coordinate in WORLD units.
[out]rightRight path coordinate in WORLD units.
[out]bottomBottom path coordinate in WORLD units.

Definition at line 518 of file o_path_basic.c.

gboolean o_path_get_position ( TOPLEVEL toplevel,
gint *  x,
gint *  y,
OBJECT object 
)
Function Description
This function gets the position of the first point of an path object.
Parameters:
[in]toplevelThe toplevel environment.
[out]xpointer to the x-position
[out]ypointer to the y-position
[in]objectThe object to get the position.
Returns:
TRUE if successfully determined the position, FALSE otherwise

Definition at line 577 of file o_path_basic.c.

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 
) [static]
Function Description
This function prints the outline of a path when a solid line type is required. The postscript file is defined by the file pointer fp. The parameters length and space are ignored.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]pathThe PATH object ot print
[in]line_widthPATH Line width.
[in]lengthDashed line length.
[in]spaceAmount of space between dashes.
[in]origin_xPage x coordinate to place PATH OBJECT.
[in]origin_yPage y coordinate to place PATH OBJECT.

Definition at line 605 of file o_path_basic.c.

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 
) [static]
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 fp. The parameter length is ignored.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]fpFILE pointer to Postscript document
[in]pathThe PATH object to print
[in]line_widthPATH Line width
[in]lengthDashed line length
[in]spaceAmount of space between dashes
[in]origin_xPage x coordinate to place PATH OBJECT
[in]origin_yPage y coordinate to place PATH OBJECT

Definition at line 662 of file o_path_basic.c.

Here is the call graph for this function:

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 
) [static]
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 fp.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]pathThe PATH object to print.
[in]line_widthPATH Line width.
[in]lengthDashed line length.
[in]spaceAmount of space between dashes.
[in]origin_xPage x coordinate to place PATH OBJECT.
[in]origin_yPage y coordinate to place PATH OBJECT.

Definition at line 687 of file o_path_basic.c.

Here is the call graph for this function:

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 
) [static]
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 fp.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]fpFILE pointer to Postscript document
[in]pathThe PATH object to print
[in]line_widthPATH Line width
[in]lengthDashed line length
[in]spaceAmount of space between dashes
[in]origin_xPage x coordinate to place PATH OBJECT
[in]origin_yPage y coordinate to place PATH OBJECT

Definition at line 712 of file o_path_basic.c.

Here is the call graph for this function:

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 
) [static]
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 fp.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]fpFILE pointer to Postscript document
[in]pathThe PATH object to print
[in]line_widthPATH Line width
[in]lengthDashed line length
[in]spaceAmount of space between dashes
[in]origin_xPage x coordinate to place PATH OBJECT
[in]origin_yPage y coordinate to place PATH OBJECT

Definition at line 737 of file o_path_basic.c.

Here is the call graph for this function:

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 
) [static]
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 fp. fill_width, angle1 and pitch1, angle2 and pitch2 parameters are ignored in this functions but kept for compatibility with other fill functions.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]fpFILE pointer to Postscript document
[in]pathThe PATH object to print
[in]fill_widthPATH fill width (unused)
[in]angle1(unused)
[in]pitch1(unused)
[in]angle2(unused)
[in]pitch2(unused)
[in]origin_xPage x coordinate to place PATH OBJECT
[in]origin_yPage y coordinate to place PATH OBJECT

Definition at line 767 of file o_path_basic.c.

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 
) [static]
Function Description
The function prints a hatched path. No outline is printed. The postscript file is defined by the file pointer fp. fill_width, angle1, pitch1 parameters define the way the path has to be hatched. angle2 and pitch2 parameters are unused but kept for compatibility with other fill functions.

Negative or zero values for pitch1 are not allowed.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]fpFILE pointer to Postscript document
[in]pathThe PATH object to print
[in]fill_widthPATH fill width
[in]angle1Angle of hatch pattern
[in]pitch1Pitch of hatch pattern
[in]angle2(unused)
[in]pitch2(unused)
[in]origin_xPage x coordinate to place PATH OBJECT
[in]origin_yPage y coordinate to place PATH OBJECT

Definition at line 832 of file o_path_basic.c.

Here is the call graph for this function:

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 
) [static]
Function Description
This function prints a meshed path. No outline is printed. The postscript file is defined by the file pointer fp.

Negative or zero values for pitch1 and/or pitch2 are not allowed.

All dimensions are in mils.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]fpFILE pointer to Postscript document
[in]pathThe PATH object to print
[in]fill_widthPATH fill width
[in]angle11st angle for mesh pattern
[in]pitch11st pitch for mesh pattern
[in]angle22nd angle for mesh pattern
[in]pitch22nd pitch for mesh pattern
[in]origin_xPage x coordinate to place PATH OBJECT
[in]origin_yPage y coordinate to place PATH OBJECT

Definition at line 882 of file o_path_basic.c.

Here is the call graph for this function:

void o_path_print ( TOPLEVEL toplevel,
FILE *  fp,
OBJECT o_current,
int  origin_x,
int  origin_y 
)
Function Description
This function prints the path described by the o_current parameter to a Postscript document. The Postscript document is descibed by the file pointer fp.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]o_currentPATH OBJECT to write to document.
[in]origin_xPage x coordinate to place PATH OBJECT.
[in]origin_yPage y coordinate to place PATH OBJECT.

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 o_current 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.

Note:
If the filling type of the path is not HOLLOW, 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 o_current object and corrected afterward.

The case where pitch1 and pitch2 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.

Definition at line 907 of file o_path_basic.c.

Here is the call graph for this function:

double o_path_shortest_distance ( OBJECT object,
int  x,
int  y,
int  force_solid 
)
Parameters:
[in]objectThe path OBJECT.
[in]xThe x coordinate of the given point.
[in]yThe y coordinate of the given point.
[in]force_solidIf true, force treating the object as solid.
Returns:
The shortest distance from the object to the point. With an invalid parameter, this function returns G_MAXDOUBLE.

Definition at line 1055 of file o_path_basic.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines