libgeda
|
functions for the circle object More...
#include <config.h>
#include <stdio.h>
#include <math.h>
#include "libgeda_priv.h"
Go to the source code of this file.
Functions | |
int | dist (int x1, int y1, int x2, int y2) |
calculate the distance between two points | |
OBJECT * | o_circle_new (TOPLEVEL *toplevel, char type, int color, int x, int y, int radius) |
Create and add circle OBJECT to list. | |
OBJECT * | o_circle_copy (TOPLEVEL *toplevel, OBJECT *o_current) |
Create a copy of a circle. | |
void | o_circle_modify (TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone) |
Modify the description of a circle OBJECT. | |
OBJECT * | o_circle_read (TOPLEVEL *toplevel, const char buf[], unsigned int release_ver, unsigned int fileformat_ver, GError **err) |
Create circle OBJECT from character string. | |
char * | o_circle_save (TOPLEVEL *toplevel, OBJECT *object) |
Create a character string representation of a circle OBJECT. | |
void | o_circle_translate_world (TOPLEVEL *toplevel, int dx, int dy, OBJECT *object) |
Translate a circle position in WORLD coordinates by a delta. | |
void | o_circle_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object) |
Rotate Circle OBJECT using WORLD coordinates. | |
void | o_circle_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) |
Mirror circle using WORLD coordinates. | |
void | o_circle_recalc (TOPLEVEL *toplevel, OBJECT *o_current) |
Recalculate circle coordinates in SCREEN units. | |
void | world_get_circle_bounds (TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom) |
Get circle bounding rectangle in WORLD coordinates. | |
gboolean | o_circle_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object) |
get the position of the center point | |
void | o_circle_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y) |
Print circle to Postscript document. | |
void | o_circle_print_solid (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int circle_width, int length, int space, int origin_x, int origin_y) |
Print a solid circle to Postscript document. | |
void | o_circle_print_dotted (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int circle_width, int length, int space, int origin_x, int origin_y) |
Print a dotted circle to Postscript document. | |
void | o_circle_print_dashed (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int circle_width, int length, int space, int origin_x, int origin_y) |
Print a dashed circle to Postscript document. | |
void | o_circle_print_center (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int circle_width, int length, int space, int origin_x, int origin_y) |
Print a centered line type circle to Postscript document. | |
void | o_circle_print_phantom (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int circle_width, int length, int space, int origin_x, int origin_y) |
Print a phantom line type circle to Postscript document. | |
void | o_circle_print_filled (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y) |
Print a solid pattern circle to Postscript document. | |
void | o_circle_print_mesh (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y) |
Print a mesh pattern circle to Postscript document. | |
void | o_circle_print_hatch (TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y) |
Print a hatch pattern circle to Postscript document. | |
double | o_circle_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 circle. |
Definition in file o_circle_basic.c.
int dist | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
[in] | x1 | x-value of the first point |
[in] | y1 | y-value of the first point |
[in] | x2 | x-value of the second point |
[in] | y2 | y-value of the second point |
Definition at line 47 of file o_circle_basic.c.
The circle is described by its center (x,y) and its radius radius. The type parameter must be equal to OBJ_CIRCLE. The color corresponds to the color the box will be drawn with.
The OBJECT structure is allocated with the s_basic_new_object() function. The structure describing the circle is allocated and initialized with the parameters given to the function.
Both the line type and the filling type are set to default values : solid line type with a width of 0, and no filling. It can be changed after with o_set_line_options() and o_set_fill_options().
[in] | toplevel | The TOPLEVEL object. |
[in] | type | Must be OBJ_CIRCLE. |
[in] | color | Circle line color. |
[in] | x | Center x coordinate. |
[in] | y | Center y coordinate. |
[in] | radius | Radius of new circle. |
Definition at line 77 of file o_circle_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | o_current | Circle OBJECT to copy. |
Definition at line 115 of file o_circle_basic.c.
If whichone is equal to CIRCLE_CENTER, the new center of the circle is given by (x,y) where x and y are in world units.
If whichone is equal to CIRCLE_RADIUS, the radius is given by x - in world units. y is ignored.
The bounding box of the circle object is updated after the modification of its parameters.
[in] | toplevel | The TOPLEVEL object. |
[in,out] | object | Circle OBJECT to modify. |
[in] | x | New center x coordinate, or radius value. |
[in] | y | New center y coordinate. Unused if radius is being modified. |
[in] | whichone | Which circle parameter to modify. |
whichone can have the following values:
Definition at line 179 of file o_circle_basic.c.
OBJECT* o_circle_read | ( | TOPLEVEL * | toplevel, |
const char | buf[], | ||
unsigned int | release_ver, | ||
unsigned int | fileformat_ver, | ||
GError ** | err | ||
) |
Depending on *version, the right file format is considered. Currently two file format revisions are supported :
[in] | toplevel | The TOPLEVEL object. |
[in] | buf | Character string with circle description. |
[in] | release_ver | libgeda release version number. |
[in] | fileformat_ver | libgeda file format version number. |
Definition at line 225 of file o_circle_basic.c.
[in] | toplevel | a TOPLEVEL structure. |
[in] | object | Circle OBJECT to create string from. |
Definition at line 326 of file o_circle_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | dx | x distance to move. |
[in] | dy | y distance to move. |
[in,out] | object | Circle OBJECT to translate. |
Definition at line 375 of file o_circle_basic.c.
void o_circle_rotate_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
int | angle, | ||
OBJECT * | object | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | world_centerx | Rotation center x coordinate in WORLD units. |
[in] | world_centery | Rotation center y coordinate in WORLD units. |
[in] | angle | Rotation angle in degrees (See note below). |
[in,out] | object | Circle OBJECT to rotate. |
Definition at line 400 of file o_circle_basic.c.
void o_circle_mirror_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
OBJECT * | object | ||
) |
The circle coordinates and its bounding are recalculated as well as the OBJECT specific (line width, filling ...).
[in] | toplevel | The TOPLEVEL object. |
[in] | world_centerx | Origin x coordinate in WORLD units. |
[in] | world_centery | Origin y coordinate in WORLD units. |
[in,out] | object | Circle OBJECT to mirror. |
Definition at line 452 of file o_circle_basic.c.
The circle coordinates and its bounding are recalculated as well as the OBJECT specific (line width, filling ...).
[in] | toplevel | The TOPLEVEL object. |
[in,out] | o_current | Circle OBJECT to be recalculated. |
Definition at line 484 of file o_circle_basic.c.
void world_get_circle_bounds | ( | TOPLEVEL * | toplevel, |
OBJECT * | object, | ||
int * | left, | ||
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | object | Circle OBJECT to read coordinates from. |
[out] | left | Left circle coordinate in WORLD units. |
[out] | top | Top circle coordinate in WORLD units. |
[out] | right | Right circle coordinate in WORLD units. |
[out] | bottom | Bottom circle coordinate in WORLD units. |
Definition at line 515 of file o_circle_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 545 of file o_circle_basic.c.
void o_circle_print | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
OBJECT * | o_current, | ||
int | origin_x, | ||
int | origin_y | ||
) |
The validity of the o_current pointer is checked : a null pointer causes an error message and a return.
The description of the circle is extracted from the o_current parameter : the coordinates of the center of the circle, its radius, its line type, its fill type.
The outline and the inside of the circle are successively handled by two differend sets of functions.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | o_current | Circle OBJECT to write to document. |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 576 of file o_circle_basic.c.
void o_circle_print_solid | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | circle_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_arc_print_solid() to print the outline. Therefore it acts as an interface between the way a circle is defined and the way an arc is defined.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Circle radius. |
[in] | color | Circle color. |
[in] | circle_width | Width of circle. |
[in] | length | (unused). |
[in] | space | (unused). |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 753 of file o_circle_basic.c.
void o_circle_print_dotted | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | circle_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_arc_print_dotted() to print the outline. Therefore it acts as an interface between the way a circle is defined and the way an arc is defined.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Circle radius. |
[in] | color | Circle color. |
[in] | circle_width | Width of circle. |
[in] | length | (unused). |
[in] | space | Space between dots. |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 796 of file o_circle_basic.c.
void o_circle_print_dashed | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | circle_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_arc_print_dashed() to print the outline. Therefore it acts as an interface between the way a circle is defined and the way an arc is defined.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Circle radius. |
[in] | color | Circle color. |
[in] | circle_width | Width of circle. |
[in] | length | Length of dashed lines. |
[in] | space | Space between dashes. |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 837 of file o_circle_basic.c.
void o_circle_print_center | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | circle_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_arc_print_center() to print the outline. Therefore it acts as an interface between the way a circle is defined and the way an arc is defined.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Circle radius. |
[in] | color | Circle color. |
[in] | circle_width | Width of circle. |
[in] | length | Length of dashed lines. |
[in] | space | Space between dashes. |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 879 of file o_circle_basic.c.
void o_circle_print_phantom | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | circle_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_arc_print_phantom() to print the outline. Therefore it acts as an interface between the way a circle is defined and the way an arc is defined.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Circle radius. |
[in] | color | Circle color. |
[in] | circle_width | Width of circle. |
[in] | length | Length of dashed lines. |
[in] | space | Space between dashes. |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 921 of file o_circle_basic.c.
void o_circle_print_filled | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | fill_width, | ||
int | angle1, | ||
int | pitch1, | ||
int | angle2, | ||
int | pitch2, | ||
int | origin_x, | ||
int | origin_y | ||
) |
All dimensions are in mils (except angle1 and angle2 in degree).
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Radius of circle. |
[in] | color | Circle color. |
[in] | fill_width | Circle fill width. (unused). |
[in] | angle1 | (unused). |
[in] | pitch1 | (unused). |
[in] | angle2 | (unused). |
[in] | pitch2 | (unused). |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 965 of file o_circle_basic.c.
void o_circle_print_mesh | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | fill_width, | ||
int | angle1, | ||
int | pitch1, | ||
int | angle2, | ||
int | pitch2, | ||
int | origin_x, | ||
int | origin_y | ||
) |
The inside mesh is achieved by two successive call to the o_circle_print_hatch() function, given angle1 and pitch1 the first time and angle2 and pitch2 the second time.
Negative or null values for pitch1 and/or pitch2 are not allowed as it leads to an endless loop in o_circle_print_hatch().
All dimensions are in mils (except angle1 and angle2 in degree).
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Radius of circle. |
[in] | color | Circle color. |
[in] | fill_width | Circle fill width. |
[in] | angle1 | 1st angle for mesh pattern. |
[in] | pitch1 | 1st pitch for mesh pattern. |
[in] | angle2 | 2nd angle for mesh pattern. |
[in] | pitch2 | 2nd pitch for mesh pattern. |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 1011 of file o_circle_basic.c.
void o_circle_print_hatch | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | radius, | ||
int | color, | ||
int | fill_width, | ||
int | angle1, | ||
int | pitch1, | ||
int | angle2, | ||
int | pitch2, | ||
int | origin_x, | ||
int | origin_y | ||
) |
The only attribute of line here is its width from the parameter width.
Negative or null values for pitch1 is not allowed as it leads to an endless loop.
All dimensions are in mils (except angle1 is in degrees).
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Center x coordinate of circle. |
[in] | y | Center y coordinate of circle. |
[in] | radius | Radius of circle. |
[in] | color | Circle color. |
[in] | fill_width | Circle fill width. |
[in] | angle1 | Angle for hatch pattern. |
[in] | pitch1 | Pitch for hatch pattern. |
[in] | angle2 | (unused). |
[in] | pitch2 | (unused). |
[in] | origin_x | Page x coordinate to place circle OBJECT. |
[in] | origin_y | Page y coordinate to place circle OBJECT. |
Definition at line 1066 of file o_circle_basic.c.
double o_circle_shortest_distance | ( | OBJECT * | object, |
int | x, | ||
int | y, | ||
int | force_solid | ||
) |
[in] | object | The circle 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 1116 of file o_circle_basic.c.