libgeda

o_circle_basic.c File Reference

functions for the circle object More...

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

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
OBJECTo_circle_new (TOPLEVEL *toplevel, char type, int color, int x, int y, int radius)
 Create and add circle OBJECT to list.
OBJECTo_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.
OBJECTo_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.

Detailed Description

Definition in file o_circle_basic.c.


Function Documentation

int dist ( int  x1,
int  y1,
int  x2,
int  y2 
)
Function Description
This function calculates the distance between two points. The two points are defined by the (x1, y1) and (x2, y2) parameters.
Parameters:
[in]x1x-value of the first point
[in]y1y-value of the first point
[in]x2x-value of the second point
[in]y2y-value of the second point
Returns:
the distance
Todo:
Move this function to a different place

Definition at line 47 of file o_circle_basic.c.

OBJECT* o_circle_new ( TOPLEVEL toplevel,
char  type,
int  color,
int  x,
int  y,
int  radius 
)
Function Description
This function creates a new object representing a circle.

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().

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]typeMust be OBJ_CIRCLE.
[in]colorCircle line color.
[in]xCenter x coordinate.
[in]yCenter y coordinate.
[in]radiusRadius of new circle.
Returns:
A pointer to the new end of the object list.

Definition at line 77 of file o_circle_basic.c.

Here is the call graph for this function:

OBJECT* o_circle_copy ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
The function o_circle_copy() creates a verbatim copy of the object pointed by o_current describing a circle.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]o_currentCircle OBJECT to copy.
Returns:
The new OBJECT

Definition at line 115 of file o_circle_basic.c.

Here is the call graph for this function:

void o_circle_modify ( TOPLEVEL toplevel,
OBJECT object,
int  x,
int  y,
int  whichone 
)
Function Description
This function modifies the description of the circle object *object depending on whichone that give the meaning of the x and y parameters.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]objectCircle OBJECT to modify.
[in]xNew center x coordinate, or radius value.
[in]yNew center y coordinate. Unused if radius is being modified.
[in]whichoneWhich circle parameter to modify.

whichone can have the following values:

*
CIRCLE_CENTER
*
CIRCLE_RADIUS

Definition at line 179 of file o_circle_basic.c.

Here is the call graph for this function:

OBJECT* o_circle_read ( TOPLEVEL toplevel,
const char  buf[],
unsigned int  release_ver,
unsigned int  fileformat_ver,
GError **  err 
)
Function Description
The o_circle_read() function gets from the character string *buff the description of a circle.

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

*
the file format used until 2000704 release.
*
the file format used for the releases after 20000704.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]bufCharacter string with circle description.
[in]release_verlibgeda release version number.
[in]fileformat_verlibgeda file format version number.
Returns:
A pointer to the new circle object, or NULL on error.

Definition at line 225 of file o_circle_basic.c.

Here is the call graph for this function:

char* o_circle_save ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
This function formats a string in the buffer *buff to describe the circle object *object. It follows the post-20000704 release file format that handle the line type and fill options.
Parameters:
[in]toplevela TOPLEVEL structure.
[in]objectCircle OBJECT to create string from.
Returns:
A pointer to the circle OBJECT character string.
Note:
Caller must g_free returned character string.

Definition at line 326 of file o_circle_basic.c.

void o_circle_translate_world ( TOPLEVEL toplevel,
int  dx,
int  dy,
OBJECT object 
)
Function Description
This function applies a translation of (x1,y1) to the circle 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]objectCircle OBJECT to translate.

Definition at line 375 of file o_circle_basic.c.

Here is the call graph for this function:

void o_circle_rotate_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
int  angle,
OBJECT object 
)
Function Description
The function o_circle_rotate_world() rotate the circle described by *object around the (world_centerx,world_centery) point by angle angle degrees. The center of rotation is in world unit.
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]objectCircle OBJECT to rotate.

Definition at line 400 of file o_circle_basic.c.

Here is the call graph for this function:

void o_circle_mirror_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
OBJECT object 
)
Function Description
This function recalculates the screen coords of the o_current pointed circle object from its world coords.

The circle coordinates and its bounding are recalculated as well as the OBJECT specific (line width, filling ...).

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]world_centerxOrigin x coordinate in WORLD units.
[in]world_centeryOrigin y coordinate in WORLD units.
[in,out]objectCircle OBJECT to mirror.

Definition at line 452 of file o_circle_basic.c.

Here is the call graph for this function:

void o_circle_recalc ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
This function recalculates the screen coords of the o_current pointed circle object from its world coords.

The circle coordinates and its bounding are recalculated as well as the OBJECT specific (line width, filling ...).

Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]o_currentCircle OBJECT to be recalculated.

Definition at line 484 of file o_circle_basic.c.

Here is the call graph for this function:

void world_get_circle_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 circle object described in *circle in world units.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]objectCircle OBJECT to read coordinates from.
[out]leftLeft circle coordinate in WORLD units.
[out]topTop circle coordinate in WORLD units.
[out]rightRight circle coordinate in WORLD units.
[out]bottomBottom circle coordinate in WORLD units.

Definition at line 515 of file o_circle_basic.c.

gboolean o_circle_get_position ( TOPLEVEL toplevel,
gint *  x,
gint *  y,
OBJECT object 
)
Function Description
This function gets the position of the center point of a circle 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 545 of file o_circle_basic.c.

void o_circle_print ( TOPLEVEL toplevel,
FILE *  fp,
OBJECT o_current,
int  origin_x,
int  origin_y 
)
Function Description
This function prints the circle described by the o_current parameter to a Postscript document. It takes into account its line type and fill type. The Postscript document is descibed by the file pointer fp.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]o_currentCircle OBJECT to write to document.
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 576 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
This function prints the outline of a circle when a solid line type is required. The circle is defined by its center in (x, y) and its radius in radius. It is printed with the color given in color. The parameters length and space are ignored.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusCircle radius.
[in]colorCircle color.
[in]circle_widthWidth of circle.
[in]length(unused).
[in]space(unused).
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 753 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
This function prints the outline of a circle when a dotted line type is required. The circle is defined by its center in (x, y) and its radius in radius. It is printed with the color given in color. The parameter length is ignored.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusCircle radius.
[in]colorCircle color.
[in]circle_widthWidth of circle.
[in]length(unused).
[in]spaceSpace between dots.
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 796 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
This function prints the outline of a circle when a dashed line type is required. The circle is defined by its center in (x, y) and its radius in radius. It is printed with the color given in color.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusCircle radius.
[in]colorCircle color.
[in]circle_widthWidth of circle.
[in]lengthLength of dashed lines.
[in]spaceSpace between dashes.
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 837 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
This function prints the outline of a circle when a centered line type is required. The circle is defined by its center in (x, y) and its radius in radius. It is printed with the color given in color.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusCircle radius.
[in]colorCircle color.
[in]circle_widthWidth of circle.
[in]lengthLength of dashed lines.
[in]spaceSpace between dashes.
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 879 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
This function prints the outline of a circle when a phantom line type is required. The circle is defined by its center in (x, y) and its radius in radius. It is printed with the color given in color.

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.

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusCircle radius.
[in]colorCircle color.
[in]circle_widthWidth of circle.
[in]lengthLength of dashed lines.
[in]spaceSpace between dashes.
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 921 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
The function prints a filled circle with a solid pattern. No outline is printed. The circle is defined by the coordinates of its center in (x,y) and its radius given by the radius parameter. 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 (except angle1 and angle2 in degree).

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusRadius of circle.
[in]colorCircle color.
[in]fill_widthCircle fill width. (unused).
[in]angle1(unused).
[in]pitch1(unused).
[in]angle2(unused).
[in]pitch2(unused).
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 965 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
This function prints a meshed circle. No outline is printed. The circle is defined by the coordinates of its center in (x,y) and its radius by the radius parameter. The Postscript document is defined by the file pointer fp.

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

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusRadius of circle.
[in]colorCircle color.
[in]fill_widthCircle 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 circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 1011 of file o_circle_basic.c.

Here is the call graph for this function:

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 
)
Function Description
The function prints a hatched circle. No outline is printed. The circle is defined by the coordinates of its center in (x,y) and its radius by the radius parameter. The Postscript document is defined by the file pointer fp. angle2 and pitch2 parameters are ignored in this functions but kept for compatibility with other fill functions.

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

Parameters:
[in]toplevelThe TOPLEVEL object.
[in]fpFILE pointer to Postscript document.
[in]xCenter x coordinate of circle.
[in]yCenter y coordinate of circle.
[in]radiusRadius of circle.
[in]colorCircle color.
[in]fill_widthCircle fill width.
[in]angle1Angle for hatch pattern.
[in]pitch1Pitch for hatch pattern.
[in]angle2(unused).
[in]pitch2(unused).
[in]origin_xPage x coordinate to place circle OBJECT.
[in]origin_yPage y coordinate to place circle OBJECT.

Definition at line 1066 of file o_circle_basic.c.

Here is the call graph for this function:

double o_circle_shortest_distance ( OBJECT object,
int  x,
int  y,
int  force_solid 
)
Parameters:
[in]objectThe circle 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 1116 of file o_circle_basic.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines