libgeda
|
functions for the line 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_line_new (TOPLEVEL *toplevel, char type, int color, int x1, int y1, int x2, int y2) |
Create and add line OBJECT to list. | |
OBJECT * | o_line_copy (TOPLEVEL *toplevel, OBJECT *o_current) |
Create a copy of a line. | |
void | o_line_modify (TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone) |
Modify the description of a line OBJECT. | |
OBJECT * | o_line_read (TOPLEVEL *toplevel, const char buf[], unsigned int release_ver, unsigned int fileformat_ver, GError **err) |
Create line OBJECT from character string. | |
char * | o_line_save (TOPLEVEL *toplevel, OBJECT *object) |
Create a character string representation of a line OBJECT. | |
void | o_line_translate_world (TOPLEVEL *toplevel, int dx, int dy, OBJECT *object) |
Translate a line position in WORLD coordinates by a delta. | |
void | o_line_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object) |
Rotate Line OBJECT using WORLD coordinates. | |
void | o_line_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) |
Mirror a line using WORLD coordinates. | |
void | o_line_recalc (TOPLEVEL *toplevel, OBJECT *o_current) |
Recalculate line coordinates in SCREEN units. | |
void | world_get_line_bounds (TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom) |
Get line bounding rectangle in WORLD coordinates. | |
gboolean | o_line_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object) |
get the position of the first line point | |
void | o_line_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y) |
Print line to Postscript document. | |
void | o_line_print_solid (TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, int y2, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a solid line to Postscript document. | |
void | o_line_print_dotted (TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, int y2, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a dotted line to Postscript document. | |
void | o_line_print_dashed (TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, int y2, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a dashed line to Postscript document. | |
void | o_line_print_center (TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, int y2, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a centered line type line to Postscript document. | |
void | o_line_print_phantom (TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, int y2, int color, int line_width, int length, int space, int origin_x, int origin_y) |
Print a phantom line type line to Postscript document. | |
void | o_line_scale_world (TOPLEVEL *toplevel, int x_scale, int y_scale, OBJECT *object) |
double | o_line_length (OBJECT *object) |
calculate the lenght of a line object | |
double | o_line_shortest_distance (OBJECT *object, int x, int y, int force_solid) |
Calculates the distance between the given point and the closest point on the given line segment. |
Definition in file o_line_basic.c.
The line is described by its two ends - x1,y1 and x2,y2. The type parameter must be equal to OBJ_LINE. The color parameter 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 line 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 | Must be OBJ_LINE. |
[in] | color | Circle line color. |
[in] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
Definition at line 64 of file o_line_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | o_current | Line OBJECT to copy. |
Definition at line 103 of file o_line_basic.c.
The coordinates of the end of line is modified in the world coordinate system. Screen coordinates and boundings are then updated.
[in] | toplevel | The TOPLEVEL object. |
[in,out] | object | Line OBJECT to modify. |
[in] | x | New x coordinate. |
[in] | y | New y coordinate. |
[in] | whichone | Which line parameter to modify. |
whichone can have the following values:
Definition at line 162 of file o_line_basic.c.
OBJECT* o_line_read | ( | TOPLEVEL * | toplevel, |
const char | buf[], | ||
unsigned int | release_ver, | ||
unsigned int | fileformat_ver, | ||
GError ** | err | ||
) |
The function returns a pointer on the new last element, that is the added line object.
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 line description. |
[in] | release_ver | libgeda release version number. |
[in] | fileformat_ver | libgeda file format version number. |
Definition at line 209 of file o_line_basic.c.
[in] | toplevel | a TOPLEVEL structure. |
[in] | object | Line OBJECT to create string from. |
Definition at line 302 of file o_line_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | dx | x distance to move. |
[in] | dy | y distance to move. |
[in,out] | object | Line OBJECT to translate. |
Definition at line 341 of file o_line_basic.c.
void o_line_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 | Line OBJECT to rotate. |
Definition at line 367 of file o_line_basic.c.
void o_line_mirror_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
OBJECT * | object | ||
) |
The line if 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 | Line OBJECT to mirror. |
Definition at line 422 of file o_line_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in,out] | o_current | Line OBJECT to be recalculated. |
Definition at line 444 of file o_line_basic.c.
void world_get_line_bounds | ( | TOPLEVEL * | toplevel, |
OBJECT * | object, | ||
int * | left, | ||
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | object | Line OBJECT to read coordinates from. |
[out] | left | Left line coordinate in WORLD units. |
[out] | top | Top line coordinate in WORLD units. |
[out] | right | Right line coordinate in WORLD units. |
[out] | bottom | Bottom line coordinate in WORLD units. |
Definition at line 475 of file o_line_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 504 of file o_line_basic.c.
void o_line_print | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
OBJECT * | o_current, | ||
int | origin_x, | ||
int | origin_y | ||
) |
Parameters of the line are extracted from object pointed by o_current.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | o_current | Line OBJECT to write to document. |
[in] | origin_x | Page x coordinate to place line OBJECT. |
[in] | origin_y | Page y coordinate to place line OBJECT. |
Definition at line 528 of file o_line_basic.c.
void o_line_print_solid | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color, | ||
int | line_width, | ||
int | length, | ||
int | space, | ||
int | origin_x, | ||
int | origin_y | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
[in] | color | Line color. |
[in] | line_width | Width of line. |
[in] | length | (unused). |
[in] | space | (unused). |
[in] | origin_x | Page x coordinate to place line OBJECT. |
[in] | origin_y | Page y coordinate to place line OBJECT. |
Definition at line 637 of file o_line_basic.c.
void o_line_print_dotted | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color, | ||
int | line_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.
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] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
[in] | color | Line color. |
[in] | line_width | Width of line. |
[in] | length | (unused). |
[in] | space | Space between dots. |
[in] | origin_x | Page x coordinate to place line OBJECT. |
[in] | origin_y | Page y coordinate to place line OBJECT. |
Definition at line 678 of file o_line_basic.c.
void o_line_print_dashed | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color, | ||
int | line_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.
The function sets the color in which the line will be printed and the width of the line - that is the width of the dashes.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
[in] | color | Line color. |
[in] | line_width | Width of line. |
[in] | length | Length of a dash. |
[in] | space | Space between dashes. |
[in] | origin_x | Page x coordinate to place line OBJECT. |
[in] | origin_y | Page y coordinate to place line OBJECT. |
Definition at line 759 of file o_line_basic.c.
void o_line_print_center | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color, | ||
int | line_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.
The function sets the color in which the line will be printed and the width of the line - that is the width of the dashes and the diameter of the dots.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
[in] | color | Line color. |
[in] | line_width | Width of line. |
[in] | length | Length of a dash. |
[in] | space | Space between dashes. |
[in] | origin_x | Page x coordinate to place line OBJECT. |
[in] | origin_y | Page y coordinate to place line OBJECT. |
Definition at line 862 of file o_line_basic.c.
void o_line_print_phantom | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color, | ||
int | line_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.
The function sets the color in which the line will be printed and the width of the line - that is the width of the dashes and the diameter of the dots.
[in] | toplevel | The TOPLEVEL object. |
[in] | fp | FILE pointer to Postscript document. |
[in] | x1 | Upper x coordinate. |
[in] | y1 | Upper y coordinate. |
[in] | x2 | Lower x coordinate. |
[in] | y2 | Lower y coordinate. |
[in] | color | Line color. |
[in] | line_width | Width of line. |
[in] | length | Length of a dash. |
[in] | space | Space between dashes. |
[in] | origin_x | Page x coordinate to place line OBJECT. |
[in] | origin_y | Page y coordinate to place line OBJECT. |
Definition at line 994 of file o_line_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | x_scale | |
[in] | y_scale | |
[in] | object |
Definition at line 1131 of file o_line_basic.c.
double o_line_length | ( | OBJECT * | object | ) |
[in] | object | a line OBJECT |
Definition at line 1153 of file o_line_basic.c.
double o_line_shortest_distance | ( | OBJECT * | object, |
int | x, | ||
int | y, | ||
int | force_solid | ||
) |
If the closest point on the line resides beyond the line segment's end point, this function returns the distance from the given point to the closest end point.
If the line represents a single point (the endpoints are the same), this function calcualtes the distance to that point.
[in] | object | The line 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 1187 of file o_line_basic.c.