libgeda
|
functions for the arc object More...
#include <config.h>
#include <stdio.h>
#include <math.h>
#include "libgeda_priv.h"
Go to the source code of this file.
Functions | |
OBJECT * | o_arc_new (TOPLEVEL *toplevel, char type, int color, int x, int y, int radius, int start_angle, int end_angle) |
OBJECT * | o_arc_copy (TOPLEVEL *toplevel, OBJECT *o_current) |
void | o_arc_modify (TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone) |
OBJECT * | o_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. |
Definition in file o_arc_basic.c.
OBJECT* o_arc_new | ( | TOPLEVEL * | toplevel, |
char | type, | ||
int | color, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | start_angle, | ||
int | end_angle | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | type | |
[in] | color | |
[in] | x | |
[in] | y | |
[in] | radius | |
[in] | start_angle | |
[in] | end_angle |
The functions relative to the use of the object are sets.
Definition at line 64 of file o_arc_basic.c.
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.
[in] | toplevel | The TOPLEVEL object |
[in] | o_current |
Definition at line 127 of file o_arc_basic.c.
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.
[in] | toplevel | The TOPLEVEL object. |
[in,out] | object | |
[in] | x | |
[in] | y | |
[in] | whichone |
Definition at line 171 of file o_arc_basic.c.
OBJECT* o_arc_read | ( | TOPLEVEL * | toplevel, |
const char | buf[], | ||
unsigned int | release_ver, | ||
unsigned int | fileformat_ver, | ||
GError ** | err | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | buf | |
[in] | release_ver | |
[in] | fileformat_ver |
Definition at line 235 of file o_arc_basic.c.
[in] | toplevel | |
[in] | object |
Definition at line 311 of file o_arc_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | dx | |
[in] | dy | |
[in] | object |
Definition at line 351 of file o_arc_basic.c.
void o_arc_rotate_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
int | angle, | ||
OBJECT * | object | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | world_centerx | |
[in] | world_centery | |
[in] | angle | |
[in] | object |
Definition at line 387 of file o_arc_basic.c.
void o_arc_mirror_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
OBJECT * | object | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | world_centerx | |
[in] | world_centery | |
[in] | object |
Definition at line 438 of file o_arc_basic.c.
The bounding box - in world units - is recalculated with the world_get_arc_bounds() function.
[in] | toplevel | The TOPLEVEL object. |
[in] | o_current |
Definition at line 478 of file o_arc_basic.c.
void world_get_arc_bounds | ( | TOPLEVEL * | toplevel, |
OBJECT * | object, | ||
int * | left, | ||
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | object | |
[out] | left | |
[out] | top | |
[out] | right | |
[out] | bottom |
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.
[in] | toplevel | The toplevel environment. |
[out] | x | pointer to the x-position |
[out] | y | pointer to the y-position |
[in] | object | The object to get the position. |
Definition at line 584 of file o_arc_basic.c.
Parameters of the arc are extracted from object pointed by o_current and formatted to suit future calls to specialized arc printing functions.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | The postscript document to print to. |
[in] | o_current | |
[in] | origin_x | |
[in] | origin_y |
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.
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 | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE 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.
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 | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE 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 |
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.
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 | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE 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 |
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.
Definition at line 862 of file o_arc_basic.c.
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 | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE 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 |
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.
Definition at line 967 of file o_arc_basic.c.
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 | ||
) |
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.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE 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 |
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.
Definition at line 1095 of file o_arc_basic.c.
double o_arc_shortest_distance | ( | OBJECT * | object, |
int | x, | ||
int | y, | ||
int | force_solid | ||
) |
[in] | object | The arc OBJECT. |
[in] | x | The x coordinate of the given point. |
[in] | y | The y coordinate of the given point. |
[in] | force_solid | If true, force treating the object as solid. |
Definition at line 1226 of file o_arc_basic.c.
gboolean o_arc_within_sweep | ( | ARC * | arc, |
gint | x, | ||
gint | y | ||
) |
[in] | arc | The arc of object |
[in] | x | The x coordinate of the given point. |
[in] | y | The y coordinate of the given point. |
Definition at line 1282 of file o_arc_basic.c.