libgeda

o_basic.c File Reference

functions for the basic object type More...

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

Go to the source code of this file.

Data Structures

struct  change_notify_entry

Functions

int inside_region (int xmin, int ymin, int xmax, int ymax, int x, int y)
 Check if point is inside a region.
void o_recalc_single_object (TOPLEVEL *toplevel, OBJECT *o_current)
 Recalculate position of the given object.
void o_recalc_object_glist (TOPLEVEL *toplevel, GList *object_glist)
 Recalculate position of a list (GList) of objects.
void o_set_line_options (TOPLEVEL *toplevel, OBJECT *o_current, OBJECT_END end, OBJECT_TYPE type, int width, int length, int space)
 Set an OBJECT's line options.
gboolean o_get_line_options (OBJECT *object, OBJECT_END *end, OBJECT_TYPE *type, int *width, int *length, int *space)
 get OBJECT's line properties.
void o_set_fill_options (TOPLEVEL *toplevel, OBJECT *o_current, OBJECT_FILLING type, int width, int pitch1, int angle1, int pitch2, int angle2)
 Set OBJECT's fill options.
gboolean o_get_fill_options (OBJECT *object, OBJECT_FILLING *type, int *width, int *pitch1, int *angle1, int *pitch2, int *angle2)
 get OBJECT's fill properties.
gboolean o_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object)
 get the base position of an object
void o_translate_world (TOPLEVEL *toplevel, gint dx, gint dy, OBJECT *object)
 Translates an object in world coordinates.
void o_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object)
 Rotates an object in world coordinates.
void o_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object)
 Mirrors an object in world coordinates.
double o_shortest_distance (OBJECT *object, int x, int y)
 Calculates the distance between the given point and the closest point on the given object.
double o_shortest_distance_full (OBJECT *object, int x, int y, int force_solid)
 Calculates the distance between the given point and the closest point on the given object. Allows forcing objects to solid.
void o_bounds_invalidate (TOPLEVEL *toplevel, OBJECT *obj)
 Mark an OBJECT's cached bounds as invalid.
void o_set_color (TOPLEVEL *toplevel, OBJECT *object, int color)
 Change the color of an object.
PAGEo_get_page (TOPLEVEL *toplevel, OBJECT *object)
 Get an object's parent PAGE.
PAGEo_get_page_compat (TOPLEVEL *toplevel, OBJECT *object)
 Get an object's parent PAGE, or fall back to global current page.
OBJECTo_get_parent (TOPLEVEL *toplevel, OBJECT *object)
 Get an object's containing complex object.
void o_add_change_notify (TOPLEVEL *toplevel, ChangeNotifyFunc pre_change_func, ChangeNotifyFunc change_func, void *user_data)
 Add change notification handlers to a TOPLEVEL.
void o_remove_change_notify (TOPLEVEL *toplevel, ChangeNotifyFunc pre_change_func, ChangeNotifyFunc change_func, void *user_data)
 Remove change notification handlers from a TOPLEVEL.
void o_emit_pre_change_notify (TOPLEVEL *toplevel, OBJECT *object)
 Emit an object pre-change notification.
void o_emit_change_notify (TOPLEVEL *toplevel, OBJECT *object)
 Emit an object change notification.
gboolean o_is_visible (TOPLEVEL *toplevel, OBJECT *object)
 Query visibility of the object.
void o_set_visibility (TOPLEVEL *toplevel, OBJECT *object, int visibility)
 Set visibility of the object.

Detailed Description

This file contains the code used to handle OBJECTs (st_object). The object is the basic type of all elements stored in schematic and symbol files.

The object be extended to become concrete objects like a line, a pin, text, a circle or a picture. These extentions are substructures in the object struct. The subobjects are picture (st_picture), path (st_path), arcs (st_arc), a line (st_line), box (st_box), circle (st_circle), text (st_text) and a complex type (st_complex).

Pins, nets and busses are just a kind of a line.

The complex object can carry many primary objects. If the complex object is a symbol, then the complex symbol contains all the pins, the text and the graphics.

o_object_relations.png

Definition in file o_basic.c.


Function Documentation

int inside_region ( int  xmin,
int  ymin,
int  xmax,
int  ymax,
int  x,
int  y 
)
Function Description
This function takes a rectangular region and a point. It will check if the point is located in the region or not.
Parameters:
[in]xminSmaller x coordinate of the region.
[in]yminSmaller y coordinate of the region.
[in]xmaxLarger x coordinate of the region.
[in]ymaxLarger y coordinate of the region.
[in]xx coordinate of the point to check.
[in]yy coordinate of the point to check.
Returns:
1 if the point is inside the region, 0 otherwise.

Definition at line 75 of file o_basic.c.

void o_recalc_single_object ( TOPLEVEL toplevel,
OBJECT o_current 
)
Function Description
This function will take an object and recalculate its position on the screen.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]o_currentOBJECT to recalculate.

Definition at line 89 of file o_basic.c.

Here is the call graph for this function:

void o_recalc_object_glist ( TOPLEVEL toplevel,
GList *  object_glist 
)
Function Description
This function will take a list (GList) of objects and recalculate their positions on the screen.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]object_glistOBJECT list to recalculate.

Definition at line 153 of file o_basic.c.

Here is the call graph for this function:

void o_set_line_options ( TOPLEVEL toplevel,
OBJECT o_current,
OBJECT_END  end,
OBJECT_TYPE  type,
int  width,
int  length,
int  space 
)
Function Description
This function allows a line's end, type, width, length and space to be set. See OBJECT_END and OBJECT_TYPE for information on valid object end and type values.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]o_currentOBJECT to set line options on.
[in]endAn OBJECT_END.
[in]typeAn OBJECT_TYPE.
[in]widthLine width.
[in]lengthLine length.
[in]spaceSpacing between dashes/dots. Cannot be negative.
Todo:
Make space an unsigned int and check for a max value instead. If a max value is not required, then it would simplify the code.

Definition at line 183 of file o_basic.c.

Here is the call graph for this function:

gboolean o_get_line_options ( OBJECT object,
OBJECT_END end,
OBJECT_TYPE type,
int *  width,
int *  length,
int *  space 
)
Function Description
This function get's the OBJECT's line options. See OBJECT_END and OBJECT_TYPE for information on valid object end and type values.
Parameters:
[in]objectOBJECT to read the properties
[out]endAn OBJECT_END.
[out]typeAn OBJECT_TYPE.
[out]widthLine width.
[out]lengthLine length.
[out]spaceSpacing between dashes/dots.
Returns:
TRUE on succes, FALSE otherwise

Definition at line 246 of file o_basic.c.

void o_set_fill_options ( TOPLEVEL toplevel,
OBJECT o_current,
OBJECT_FILLING  type,
int  width,
int  pitch1,
int  angle1,
int  pitch2,
int  angle2 
)
Function Description
This function allows an OBJECT's fill options to be configured. See OBJECT_FILLING for information on valid fill types.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]o_currentOBJECT to be updated.
[in]typeOBJECT_FILLING type.
[in]widthfill width.
[in]pitch1cross hatch line distance
[in]angle1cross hatch angle
[in]pitch2cross hatch line distance
[in]angle2cross hatch angle

Definition at line 281 of file o_basic.c.

Here is the call graph for this function:

gboolean o_get_fill_options ( OBJECT object,
OBJECT_FILLING type,
int *  width,
int *  pitch1,
int *  angle1,
int *  pitch2,
int *  angle2 
)
Function Description
This function get's the OBJECT's fill options. See OBJECT_FILLING for information on valid fill types.
Parameters:
[in]objectOBJECT to read the properties
[out]typeOBJECT_FILLING type
[out]widthfill width.
[out]pitch1cross hatch line distance
[out]angle1cross hatch angle
[out]pitch2cross hatch line distance
[out]angle2cross hatch angle
Returns:
TRUE on succes, FALSE otherwise

Definition at line 319 of file o_basic.c.

gboolean o_get_position ( TOPLEVEL toplevel,
gint *  x,
gint *  y,
OBJECT object 
)
Function Description
This function gets the position of an object in world coordinates.
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 349 of file o_basic.c.

Here is the call graph for this function:

void o_translate_world ( TOPLEVEL toplevel,
gint  dx,
gint  dy,
OBJECT object 
)
Function Description
This function translates the object object by dx and dy.
Parameters:
[in]toplevelThe toplevel environment.
[in]dxAmount to horizontally translate object
[in]dyAmount to vertically translate object
[in]objectThe object to translate.

Definition at line 388 of file o_basic.c.

Here is the call graph for this function:

void o_rotate_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
int  angle,
OBJECT object 
)
Function Description
This function rotates the object object about the coordinates world_centerx and world_centery, by angledegrees.
Parameters:
[in]toplevelThe toplevel environment.
[in]world_centerxX coordinate of rotation center (world coords)
[in]world_centeryY coordinate of rotation center (world coords)
[in]angleAngle of rotation (degrees)
[in]objectThe object to rotate.

Definition at line 427 of file o_basic.c.

Here is the call graph for this function:

void o_mirror_world ( TOPLEVEL toplevel,
int  world_centerx,
int  world_centery,
OBJECT object 
)
Function Description
This function mirrors an object about the point (world_centerx,world_centery) in world units.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]world_centerxOrigin x coordinate in WORLD units.
[in]world_centeryOrigin y coordinate in WORLD units.
[in,out]objectThe OBJECT to mirror.

Definition at line 465 of file o_basic.c.

Here is the call graph for this function:

double o_shortest_distance ( OBJECT object,
int  x,
int  y 
)
Parameters:
[in]objectThe given object.
[in]xThe x coordinate of the given point.
[in]yThe y coordinate of the given point.
Returns:
The shortest distance from the object to the point. If the distance cannot be calculated, this function returns a really large number (G_MAXDOUBLE). If an error occurs, this function returns G_MAXDOUBLE.

Definition at line 504 of file o_basic.c.

Here is the call graph for this function:

double o_shortest_distance_full ( OBJECT object,
int  x,
int  y,
int  force_solid 
)
Parameters:
[in]objectThe given 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. If the distance cannot be calculated, this function returns a really large number (G_MAXDOUBLE). If an error occurs, this function returns G_MAXDOUBLE.

Definition at line 521 of file o_basic.c.

Here is the call graph for this function:

void o_bounds_invalidate ( TOPLEVEL toplevel,
OBJECT obj 
)
Function Description
Recursively marks the cached bounds of the given OBJECT and its parents as having been invalidated and in need of an update. They will be recalculated next time the OBJECT's bounds are requested (e.g. via world_get_single_object_bounds() ).
Parameters:
[in]toplevel
[in]obj
Todo:
Turn this into a macro?

Definition at line 564 of file o_basic.c.

void o_set_color ( TOPLEVEL toplevel,
OBJECT object,
int  color 
)
Function Description
This function changes the color of an object.
Parameters:
[in]toplevelThe TOPLEVEL structure.
[in]objectThe OBJECT to change color.
[in]colorThe new color.

Definition at line 581 of file o_basic.c.

Here is the call graph for this function:

PAGE* o_get_page ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
Returns the PAGE structure which owns object. If object is not currently associated with a PAGE, returns NULL. If object is part of a compound object, recurses upward.
Parameters:
[in]toplevelThe TOPLEVEL structure.
[in]objectThe OBJECT for which to retrieve the parent PAGE.
Returns:
The PAGE which owns object or NULL.
See also:
s_page_append_object() s_page_append() s_page_remove()

Definition at line 607 of file o_basic.c.

Here is the call graph for this function:

PAGE* o_get_page_compat ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
If set, returns the PAGE structure which owns object. If object does not have a parent page set, returns the global current page from toplevel. If the object parent page is inconsistent with the global current page, a critical-level error message is emitted.
Warning:
This function is primarily intended to assist in the migration of code from using the TOPLEVEL current page to using the o_get_page(). It should not be used in new code.
Deprecated:
Use o_get_page() in new code.
Parameters:
[in]toplevelThe TOPLEVEL structure.
[in]objectThe OBJECT for which to retrieve the parent PAGE.
Returns:
The PAGE which owns object, the global current PAGE, or NULL.

Definition at line 635 of file o_basic.c.

Here is the call graph for this function:

OBJECT* o_get_parent ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
If object is part of a complex OBJECT, returns that OBJECT. Otherwise, returns NULL.
Parameters:
[in]toplevelThe TOPLEVEL structure.
[in]objectThe OBJECT for which to get the containing OBJECT.
Returns:
The complex OBJECT which owns object, or NULL.

Definition at line 657 of file o_basic.c.

void o_add_change_notify ( TOPLEVEL toplevel,
ChangeNotifyFunc  pre_change_func,
ChangeNotifyFunc  change_func,
void *  user_data 
)
Function Description
Adds a set of change notification handlers to a TOPLEVEL instance. pre_change_func will be called just before an object is modified, and change_func will be called just after an object is modified, with the affected object and the given user_data.
Parameters:
toplevelTOPLEVEL structure to add handlers to.
pre_change_funcFunction to be called just before changes.
change_funcFunction to be called just after changes.
user_dataUser data to be passed to callback functions.

Definition at line 688 of file o_basic.c.

void o_remove_change_notify ( TOPLEVEL toplevel,
ChangeNotifyFunc  pre_change_func,
ChangeNotifyFunc  change_func,
void *  user_data 
)
Function Description
Removes a set of change notification handlers and their associated user_data from toplevel. If no registered set of handlers matches the given pre_change_func, change_func and user_data, does nothing.
See also:
o_add_change_notify()
Parameters:
toplevelTOPLEVEL structure to remove handlers from.
pre_change_funcFunction called just before changes.
change_funcFunction called just after changes.
user_dataUser data passed to callback functions.

Definition at line 716 of file o_basic.c.

void o_emit_pre_change_notify ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
Calls each pre-change callback function registered with TOPLEVEL to notify listeners that object is about to be modified. All libgeda functions that modify OBJECT structures should call this just before making a change to an OBJECT.
Parameters:
toplevelTOPLEVEL structure to emit notifications from.
objectOBJECT structure to emit notifications for.

Definition at line 751 of file o_basic.c.

void o_emit_change_notify ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
Calls each change callback function registered with TOPLEVEL to notify listeners that object has just been modified. All libgeda functions that modify OBJECT structures should call this just after making a change to an OBJECT.
Parameters:
toplevelTOPLEVEL structure to emit notifications from.
objectOBJECT structure to emit notifications for.

Definition at line 777 of file o_basic.c.

gboolean o_is_visible ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
Attribute getter for the visible field within the object.
Parameters:
toplevelThe TOPLEVEL structure
objectThe OBJECT structure to be queried
Returns:
TRUE when VISIBLE, FALSE otherwise

Definition at line 801 of file o_basic.c.

void o_set_visibility ( TOPLEVEL toplevel,
OBJECT object,
int  visibility 
)
Function Description
Set value of visibility field within the object. If resulting visibility value is changed, invalidate the bounds of the object and parent objects.
Parameters:
toplevelThe TOPLEVEL structure
objectThe OBJECT structure to be modified

Definition at line 817 of file o_basic.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines