libgeda
|
functions for the box object More...
#include <config.h>
#include <math.h>
#include <stdio.h>
#include "libgeda_priv.h"
Go to the source code of this file.
Functions | |
OBJECT * | o_box_new (TOPLEVEL *toplevel, char type, int color, int x1, int y1, int x2, int y2) |
Create a BOX OBJECT. | |
OBJECT * | o_box_copy (TOPLEVEL *toplevel, OBJECT *o_current) |
Copy a box to a list. | |
void | o_box_modify_all (TOPLEVEL *toplevel, OBJECT *object, int x1, int y1, int x2, int y2) |
Modify a BOX OBJECT's coordinates. | |
void | o_box_modify (TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone) |
Modify a BOX OBJECT's coordinates. | |
OBJECT * | o_box_read (TOPLEVEL *toplevel, const char buf[], unsigned int release_ver, unsigned int fileformat_ver, GError **err) |
Create a box from a character string. | |
char * | o_box_save (TOPLEVEL *toplevel, OBJECT *object) |
Create a character string representation of a BOX. | |
void | o_box_translate_world (TOPLEVEL *toplevel, int dx, int dy, OBJECT *object) |
Translate a BOX position in WORLD coordinates by a delta. | |
void | o_box_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object) |
Rotate BOX OBJECT using WORLD coordinates. | |
void | o_box_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) |
Mirror BOX using WORLD coordinates. | |
void | o_box_recalc (TOPLEVEL *toplevel, OBJECT *o_current) |
Recalculate BOX coordinates in WORLD units. | |
void | world_get_box_bounds (TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom) |
Get BOX bounding rectangle in WORLD coordinates. | |
gboolean | o_box_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object) |
get the position of the left bottom point | |
void | o_box_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y) |
Print BOX to Postscript document. | |
void | o_box_print_solid (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a solid BOX to Postscript document. | |
void | o_box_print_dotted (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a dotted BOX to Postscript document. | |
void | o_box_print_dashed (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a dashed BOX to Postscript document. | |
void | o_box_print_center (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print centered line type BOX to Postscript document. | |
void | o_box_print_phantom (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print phantom line type BOX to Postscript document. | |
void | o_box_print_filled (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y) |
Print a solid pattern BOX to Postscript document. | |
void | o_box_print_mesh (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y) |
Print a mesh pattern BOX to Postscript document. | |
void | o_box_print_hatch (TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y) |
Print a hatch pattern BOX to Postscript document. | |
double | o_box_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 box. |
Definition in file o_box_basic.c.
The box is described by its upper left corner - x1, y1 - and its lower right corner - x2, y2. The type parameter must be equal to OBJ_BOX. 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 box 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 the o_set_line_options() and o_set_fill_options().
[in] | toplevel | The TOPLEVEL object. |
[in] | type | Box type. |
[in] | color | Box border color. |
[in] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
Definition at line 60 of file o_box_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | o_current | BOX OBJECT to copy. |
Definition at line 101 of file o_box_basic.c.
[in] | toplevel | current TOPLEVEL. |
[in,out] | object | box OBJECT to be modified. |
[in] | x1 | x coordinate of first corner of box. |
[in] | y1 | y coordinate of first corner of box. |
[in] | x2 | x coordinate of second corner of box. |
[in] | y2 | y coordinate of second corner of box, |
Definition at line 151 of file o_box_basic.c.
The coordinates of the corner is modified in the world coordinate system. Screen coordinates and boundings are then updated.
[in] | toplevel | The TOPLEVEL object. |
[in,out] | object | BOX OBJECT to be modified. |
[in] | x | x coordinate. |
[in] | y | y coordinate. |
[in] | whichone | coordinate to change. |
Definition at line 191 of file o_box_basic.c.
OBJECT* o_box_read | ( | TOPLEVEL * | toplevel, |
const char | buf[], | ||
unsigned int | release_ver, | ||
unsigned int | fileformat_ver, | ||
GError ** | err | ||
) |
Depending on *version, the correct file format is considered. Currently two file format revisions are supported :
[in] | toplevel | The TOPLEVEL object. |
[in] | buf | Character string with box description. |
[in] | release_ver | libgeda release version number. |
[in] | fileformat_ver | libgeda file format version number. |
A new object is allocated, initialized and added to the object list. Its filling and line type are set according to the values of the field on the line.
Definition at line 261 of file o_box_basic.c.
[in] | toplevel | The TOPLEVEL structure. |
[in] | object | The BOX OBJECT to create string from. |
Definition at line 378 of file o_box_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | dx | x distance to move. |
[in] | dy | y distance to move. |
[in,out] | object | BOX OBJECT to translate. |
Definition at line 442 of file o_box_basic.c.
void o_box_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 | BOX OBJECT to rotate. |
Definition at line 468 of file o_box_basic.c.
void o_box_mirror_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
OBJECT * | object | ||
) |
The box is first translated to the origin, then mirrored and finally translated back at its previous position.
[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 | BOX OBJECT to mirror. |
Definition at line 533 of file o_box_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in,out] | o_current | BOX OBJECT to be recalculated. |
Definition at line 577 of file o_box_basic.c.
void world_get_box_bounds | ( | TOPLEVEL * | toplevel, |
OBJECT * | object, | ||
int * | left, | ||
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | object | BOX OBJECT to read coordinates from. |
[out] | left | Left box coordinate in WORLD units. |
[out] | top | Top box coordinate in WORLD units. |
[out] | right | Right box coordinate in WORLD units. |
[out] | bottom | Bottom box coordinate in WORLD units. |
Definition at line 607 of file o_box_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 636 of file o_box_basic.c.
The validity of the o_current parameter is verified : a null pointer causes an error message and a return.
The description of the box is extracted from the o_current parameter : the coordinates of the box - upper left corner and width and height of the box -, its line type, its fill type.
The outline and the inside of the box are successively handled by two differend sets of functions.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | o_current | BOX OBJECT to write to document. |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
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.
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 box is printed filled. Unused parameters for each of these functions are set to -1 or any passive value.
Definition at line 668 of file o_box_basic.c.
void o_box_print_solid | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | line_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_line_print_solid() to print the outline. It performs four calls to this function, one for each of its side.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | line_width | BOX Line width. |
[in] | length | Dashed line length. |
[in] | space | Amount of space between dashes. |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 848 of file o_box_basic.c.
void o_box_print_dotted | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | line_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_line_print_dotted() to print the outline. It performs four calls to this function, one for each of its side.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | line_width | BOX Line width. |
[in] | length | Dashed line length. |
[in] | space | Amount of space between dashes. |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 911 of file o_box_basic.c.
void o_box_print_dashed | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | line_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_line_print_dashed() to print the outline. It performs four calls to this function, one for each of its side.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | line_width | BOX Line width. |
[in] | length | Dashed line length. |
[in] | space | Amount of space between dashes. |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 973 of file o_box_basic.c.
void o_box_print_center | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | line_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_line_print_center() to print the outline. It performs four calls to this function, one for each of its side.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | line_width | BOX Line width. |
[in] | length | Dashed line length. |
[in] | space | Amount of space between dashes. |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 1036 of file o_box_basic.c.
void o_box_print_phantom | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | line_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the function o_line_print_phantom() to print the outline. It performs four calls to this function, one for each of its side.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | line_width | BOX Line width. |
[in] | length | Dashed line length. |
[in] | space | Amount of space between dashes. |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 1098 of file o_box_basic.c.
void o_box_print_filled | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | fill_width, | ||
int | angle1, | ||
int | pitch1, | ||
int | angle2, | ||
int | pitch2, | ||
int | origin_x, | ||
int | origin_y | ||
) |
It uses the fbox postscript function defined in the prolog to specify a filled box.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | fill_width | BOX fill width. (unused). |
[in] | angle1 | (unused). |
[in] | pitch1 | (unused). |
[in] | angle2 | (unused). |
[in] | pitch2 | (unused). |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 1166 of file o_box_basic.c.
void o_box_print_mesh | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
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_box_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_box_print_hatch().
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | fill_width | BOX 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 BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 1218 of file o_box_basic.c.
void o_box_print_hatch | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | color, | ||
int | fill_width, | ||
int | angle1, | ||
int | pitch1, | ||
int | angle2, | ||
int | pitch2, | ||
int | origin_x, | ||
int | origin_y | ||
) |
Negative or null values for pitch1 are not allowed as it leads to an endless loop.
All dimensions are in mils.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x | Upper x coordinate of BOX. |
[in] | y | Upper y coordinate of BOX. |
[in] | width | Width of BOX. |
[in] | height | Height of BOX. |
[in] | color | BOX color. |
[in] | fill_width | BOX fill width. |
[in] | angle1 | Angle of hatch pattern. |
[in] | pitch1 | Pitch of hatch pattern. |
[in] | angle2 | (unused). |
[in] | pitch2 | (unused). |
[in] | origin_x | Page x coordinate to place BOX OBJECT. |
[in] | origin_y | Page y coordinate to place BOX OBJECT. |
Definition at line 1273 of file o_box_basic.c.
double o_box_shortest_distance | ( | OBJECT * | object, |
int | x, | ||
int | y, | ||
int | force_solid | ||
) |
[in] | object | The box 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 1325 of file o_box_basic.c.