libgeda

o_arc_basic.c File Reference

functions for the arc object More...

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

Go to the source code of this file.

Functions

OBJECTo_arc_new (TOPLEVEL *toplevel, char type, int color, int x, int y, int radius, int start_angle, int end_angle)
OBJECTo_arc_copy (TOPLEVEL *toplevel, OBJECT *o_current)
void o_arc_modify (TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone)
OBJECTo_arc_read (TOPLEVEL *toplevel, const char buf[], unsigned int release_ver, unsigned int fileformat_ver, GError **err)
char * o_arc_save (TOPLEVEL *toplevel, OBJECT *object)
 create the string representation of an arc object
void o_arc_translate_world (TOPLEVEL *toplevel, int dx, int dy, OBJECT *object)
void o_arc_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object)
void o_arc_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object)
 Mirror the WORLD coordinates of an ARC.
void o_arc_recalc (TOPLEVEL *toplevel, OBJECT *o_current)
void world_get_arc_bounds (TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom)
gboolean o_arc_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object)
 get the position of the center point
void o_arc_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y)
void o_arc_print_solid (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int length, int space, int origin_x, int origin_y)
void o_arc_print_dotted (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int length, int space, int origin_x, int origin_y)
void o_arc_print_dashed (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int length, int space, int origin_x, int origin_y)
void o_arc_print_center (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int length, int space, int origin_x, int origin_y)
void o_arc_print_phantom (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int length, int space, int origin_x, int origin_y)
double o_arc_shortest_distance (OBJECT *object, int x, int y, int force_solid)
 Calculates the distance between the given point and the closest point on the perimeter of the arc.
gboolean o_arc_within_sweep (ARC *arc, gint x, gint y)
 Determines if a point lies within the sweep of the arc.

Detailed Description

Definition in file o_arc_basic.c.


Function Documentation

OBJECT* o_arc_new ( TOPLEVEL toplevel,
char  type,
int  color,
int  x,
int  y,
int  radius,
int  start_angle,
int  end_angle 
)
Function Description
The function creates a new OBJECT of type arc.

The arc is defined by its center in parameters x and y. The radius parameter specifies the radius of the arc. The start angle is given by start_angle and the end angle by end_angle. The line and fill type of the created arc are set to default.

All dimensions are in world unit, except start_angle and end_angle in degrees.

A new object of type OBJECT is allocated. Its type and color are initilized. The description of the arc characteristics are stored in a new ARC structure.

Now fixed for world coordinates.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]type
[in]color
[in]x
[in]y
[in]radius
[in]start_angle
[in]end_angle
Returns:

Note:
The ARC structure is initialized with the parameters. A default initialization is performed for the line and fill type to avoid misunderstanding.

The functions relative to the use of the object are sets.

Definition at line 64 of file o_arc_basic.c.

Here is the call graph for this function:

OBJECT* o_arc_copy ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
This function creates a new object representing an arc.

The values of the o_current pointed OBJECT are then copied to the new object.

The arc, the line options are initialized whereas the fill options are initialized to passive values - as an arc can not be filled.

Parameters:
[in]toplevelThe TOPLEVEL object
[in]o_current
Returns:
The new OBJECT

Definition at line 127 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_modify ( TOPLEVEL toplevel,
OBJECT object,
int  x,
int  y,
int  whichone 
)
Function Description
This function modifies the internal values of the arc object *object according to the whichone parameter.

The new values are given by x and/or y. Their meaning depends on the value of whichone.

If whichone is equal to ARC_CENTER, the (x,y) point is taken as the new center of the arc in world unit.

If whichone is equal to ARC_RADIUS, the x parameter is taken to be the radius of the arc in world unit. The y parameter is ignored.

If whichone is equal to ARC_START_ANGLE, the x parameter is the starting angle of the arc. x is in degrees. y is ignored.

If whichone is equal to ARC_END_ANGLE, the x parameter is the ending angle of the arc. x is in degrees. y is ignored.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]object
[in]x
[in]y
[in]whichone

Definition at line 171 of file o_arc_basic.c.

Here is the call graph for this function:

OBJECT* o_arc_read ( TOPLEVEL toplevel,
const char  buf[],
unsigned int  release_ver,
unsigned int  fileformat_ver,
GError **  err 
)
Function Description
This function reads a formatted text buffer describing an arc in the gEDA file format and initializes the corresponding object.

Depending on the version of the file format the data extraction is performed differently : currently pre-20000704 and 20000704 on one hand and post-20000704 file format version on the other hand are supported. The version is specified in string pointed by fileformat_ver.

To get information on the various file formats have a look to the fileformats.html document.

The object is initialized with the functions o_set_line_options() and o_set_fill_options(). The second one is only used to put initialize unused values for an arc as an arc can not be filled.

The arc is allocated initialized with the function o_arc_new().

A negative or null radius is not allowed.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]buf
[in]release_ver
[in]fileformat_ver
Returns:
The ARC OBJECT that was created, or NULL on error.

Note:
Depending on the version of the file format used to describe this arc, the buffer is parsed differently. The unknown parameters of the less restrictive - the oldest - file format are set to common values

Definition at line 235 of file o_arc_basic.c.

Here is the call graph for this function:

char* o_arc_save ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
This function formats a string in the buffer *buf to describe the arc object *object. A pointer to the new allocated and formated string is returned. The string must be freed at some point.
Parameters:
[in]toplevel
[in]object
Returns:
the string representation of the arc object

Definition at line 311 of file o_arc_basic.c.

void o_arc_translate_world ( TOPLEVEL toplevel,
int  dx,
int  dy,
OBJECT object 
)
Function Description
This function applies a translation of (dx,dy) to the arc described in *object. dx and dy are in world unit.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]dx
[in]dy
[in]object

Definition at line 351 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_rotate_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
int  angle,
OBJECT object 
)
Function Description
This function rotates the world coordinates of an arc of an angle specified by angle. The center of the rotation is given by (world_centerx,world_centery).

The arc is translated in order to put the center of the rotation on the origin. The center of the arc is then rotated of the angle specified by angle. The start angle of the arc is incremented by angle.

The arc is finally back translated to its previous location on the page.

world_centerx and world_centery are in world units, angle is in degrees.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]world_centerx
[in]world_centery
[in]angle
[in]object

Definition at line 387 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_mirror_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
OBJECT object 
)
Function Description
This function mirrors the world coordinates of an arc. The symetry axis is given by the vertical line going through the point (world_centerx,world_centery).

The arc is translated in order to put the point (world_centerx,world_centery) on the origin. The center of the arc is then mirrored. The start angle of the arc and the sweep of the arc are also mirrored.

The arc is finally back translated to its previous location on the page.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]world_centerx
[in]world_centery
[in]object

Definition at line 438 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_recalc ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
This function recalculates internal parameters in screen units of an object containing an arc. The object is given as parameters o_current. The calculation is done according to the zoom factor detailed in the toplevel pointed structure. It also recalculates the OBJECT specific fields and the bounding box of the arc.

The bounding box - in world units - is recalculated with the world_get_arc_bounds() function.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]o_current

Definition at line 478 of file o_arc_basic.c.

Here is the call graph for this function:

void world_get_arc_bounds ( TOPLEVEL toplevel,
OBJECT object,
int *  left,
int *  top,
int *  right,
int *  bottom 
)
Function Description
This function calculates the smallest rectangle the arc can be drawn into. The OBJECT pointed by object is assumed to be an arc. The left, top, right and bottom pointed integers define this rectangle at the end of the function. It is expressed in world units. The process is divided into two steps : the first step is to calculate the coordinates of the two ends of the arc and the coordinates of the center. They forms a first rectangle but (depending on the start angle and the sweep of the arc) not the right.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]object
[out]left
[out]top
[out]right
[out]bottom

Note:
The previous rectangle is extended to the final one by checking whether the arc is over a main axis (vertical or horizontal). If so, the rectangle is extended in these directions.

In the mirror mode, the sweep angle is negativ. To get a CCW arc before this calculation we have to move the start angle to the end angle and reverse the sweep angle.

Definition at line 514 of file o_arc_basic.c.

gboolean o_arc_get_position ( TOPLEVEL toplevel,
gint *  x,
gint *  y,
OBJECT object 
)
Function Description
This function gets the position of the center point of an arc 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 584 of file o_arc_basic.c.

void o_arc_print ( TOPLEVEL toplevel,
FILE *  fp,
OBJECT o_current,
int  origin_x,
int  origin_y 
)
Function Description
This function writes in a postscript file the arc described by the o_current pointed object. The postscript resulting file is described by the fp file pointer.

Parameters of the arc are extracted from object pointed by o_current and formatted to suit future calls to specialized arc printing functions.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpThe postscript document to print to.
[in]o_current
[in]origin_x
[in]origin_y

Note:
Depending on the type of the line for this particular arc, the appropriate function is chosen among o_arc_print_solid(), o_arc_print_dotted(), o_arc_print_dashed(), o_arc_print_center() and o_arc_print_phantom().

The needed parameters for each of these types are 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 arc is printed solid to avoid and endless loop produced by other functions.

Definition at line 607 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_print_solid ( TOPLEVEL toplevel,
FILE *  fp,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2,
int  color,
int  arc_width,
int  length,
int  space,
int  origin_x,
int  origin_y 
)
Function Description
This function prints an arc when a solid line type is required. The arc is defined by its center in x and y, its radius in radius and the start and end angles of the arc on the circle. The postscript file is defined by the file pointer fp.

The parameters length and space are ignored whereas arc_width specifies the width of the printed line.

All dimensions are in mils, except angle1 and angle2 in degrees.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to postscript document.
[in]x
[in]y
[in]radius
[in]angle1
[in]angle2
[in]color
[in]arc_width
[in]length
[in]space
[in]origin_x
[in]origin_y

Definition at line 727 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_print_dotted ( TOPLEVEL toplevel,
FILE *  fp,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2,
int  color,
int  arc_width,
int  length,
int  space,
int  origin_x,
int  origin_y 
)
Function Description
This function prints an arc when a dotted line type is required. The arc is defined by its center in x and y, its radius in radius and the start and end angles of the arc on the circle. The postscript file is defined by the file pointer fp. The parameter length is ignored whereas arc_width specifies the diameter of the dots of the printed line and space the distance between two dots.

A negative value for space leads to an endless loop.

All dimensions are in mils, except angle1 and angle2 in degrees.

The function sets the color the line will be printed with.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to postscript document.
[in]x
[in]y
[in]radius
[in]angle1
[in]angle2
[in]color
[in]arc_width
[in]length
[in]space
[in]origin_x
[in]origin_y

Note:
Depending on the radius of the arc, the space parameter is changed into a small angle da. Starting from angle1 - the start angle - the dots are printed along the arc by increments of this new angle.

As da is rounded as an integer, it can take a null value which will make the function enter an endless loop. In such a case, the arc is printed solid. The da variable should never be negative except if space is negative.

Definition at line 778 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_print_dashed ( TOPLEVEL toplevel,
FILE *  fp,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2,
int  color,
int  arc_width,
int  length,
int  space,
int  origin_x,
int  origin_y 
)
Function Description
This function prints an arc when a dashed line type is required. The arc is defined by its center in x and y, its radius in radius and the start and end angles of the arc on the circle. The postscript file is defined by the file pointer fp. The parameter arc_width specifies the diameter of the dots of the printed line.

A negative value for space or length leads to an endless loop.

All dimensions are in mils, except angle1 and angle2 in degrees.

The function sets the color the line will be printed with.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to postscript document.
[in]x
[in]y
[in]radius
[in]angle1
[in]angle2
[in]color
[in]arc_width
[in]length
[in]space
[in]origin_x
[in]origin_y

Note:
Depending on the radius of the arc, the space (resp. length) parameter is changed into a small angle da (resp. db). Starting from angle1 - the start angle - the dashes are printed along the arc by increments of these new angles.

As da (resp. db) is rounded as an integer, it can take a null value which will make the function enter an endless loop. In such a case, the arc is printed solid. The da (resp. db) variable should never be negative except if space (resp. length) is negative.

It prints as many dashes of length length as possible.

Note:
When the above condition is no more satisfied, then it is not possible to print a dash of length length and the following space. However it may be possible to print the complete dash or a shorter one.

Definition at line 862 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_print_center ( TOPLEVEL toplevel,
FILE *  fp,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2,
int  color,
int  arc_width,
int  length,
int  space,
int  origin_x,
int  origin_y 
)
Function Description
This function prints an arc when a centered line type is required. The arc is defined by its center in x and y, its radius in radius and the start and end angles of the arc on the circle. The postscript file is defined by the file pointer fp. The parameter arc_width specifies the diameter of the dots and the width of the dashes of the printed line.

A negative value for space or length leads to an endless loop.

All dimensions are in mils, except angle1 and angle2 in degrees.

The function sets the color in which the line will be printed with.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to postscript document.
[in]x
[in]y
[in]radius
[in]angle1
[in]angle2
[in]color
[in]arc_width
[in]length
[in]space
[in]origin_x
[in]origin_y

Note:
Depending on the radius of the arc, the space (resp. length) parameter is changed into a small angle da (resp. db). Starting from angle1 - the start angle - the dashes are printed along the arc by increments of these new angles.

As da (resp. db) is rounded as an integer, it can take a null value which will make the function enter an endless loop. In such a case, the arc is printed solid. The da (resp. db) variable should never be negative except if space (resp. length) is negative.

It prints as many sets of dash-dot as possible.

Note:
When the above condition is no more satisfied, then it is not possible to print a dash of length length. However two cases are possible :
*
it is possible to print the dash and the dot
*
it is possible to print the dash or a part of the original dash

Definition at line 967 of file o_arc_basic.c.

Here is the call graph for this function:

void o_arc_print_phantom ( TOPLEVEL toplevel,
FILE *  fp,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2,
int  color,
int  arc_width,
int  length,
int  space,
int  origin_x,
int  origin_y 
)
Note:
A dot is represented by a filled circle. Position of the circle is (xa, ya) and its radius is the arc_width parameter.
Function Description
This function prints an arc when a phantom line type is required. The arc is defined by its center in x and y, its radius in radius and the start and end angles of the arc on the circle. The postscript file is defined by the file pointer fp. The parameter arc_width specifies the diameter of the dots and the width of the dashes of the printed line.

A negative value for space or length leads to an endless loop.

All dimensions are in mils, except angle1 and angle2 in degrees.

The function sets the color in which the line will be printed with.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to postscript document.
[in]x
[in]y
[in]radius
[in]angle1
[in]angle2
[in]color
[in]arc_width
[in]length
[in]space
[in]origin_x
[in]origin_y

Note:
Depending on the radius of the arc, the space (resp. length) parameter is changed into a small angle da (resp. db). Starting from angle1 - the start angle - the dashes are printed along the arc by increments of these new angles.

As da (resp. db) is rounded as an integer, it can take a null value which will make the function enter an endless loop. In such a case, the arc is printed solid. The da (resp. db) variable should never be negative except if space (resp. length) is negative.

It prints as many sets of dash-dot-dot as possible.

Note:
When the above condition is no more satisfied, then it is not possible to print a dash of length length. However three cases are possible :
*
it is possible to print a dash and a dot and a dot
*
it is possible to print a dash and a dot
*
it is possible to print the dash or a part of the original dash

Definition at line 1095 of file o_arc_basic.c.

Here is the call graph for this function:

double o_arc_shortest_distance ( OBJECT object,
int  x,
int  y,
int  force_solid 
)
Parameters:
[in]objectThe arc 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 1226 of file o_arc_basic.c.

Here is the call graph for this function:

gboolean o_arc_within_sweep ( ARC arc,
gint  x,
gint  y 
)
Parameters:
[in]arcThe arc of object
[in]xThe x coordinate of the given point.
[in]yThe y coordinate of the given point.
Returns:
TRUE if the point lies within the sweep of the arc. FALSE if the point lies outside the sweep of the arc. With an invalid parameter, this function returns FALSE.

Definition at line 1282 of file o_arc_basic.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines