libgeda: add functions to track net connectivity
[geda-gaf/whiteaudio.git] / libgeda / include / libgeda / struct.h
blobeba1305acea7b1fc9d88414e918d257f145761d0
1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's Library
3 * Copyright (C) 1998-2010 Ales Hvezda
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef STRUCT_H
21 #define STRUCT_H
23 #include <glib.h> /* Include needed to make GList work. */
25 /* Wrappers around a new list mechanism */
26 typedef struct _GedaList SELECTION;
27 typedef struct _GedaList GedaPageList;
29 /* gschem structures (gschem) */
30 typedef struct st_complex COMPLEX;
31 typedef struct st_line LINE;
32 typedef struct st_path_section PATH_SECTION;
33 typedef struct st_path PATH;
34 typedef struct st_circle CIRCLE;
35 typedef struct st_arc ARC;
36 typedef struct st_box BOX;
37 typedef struct st_picture PICTURE;
38 typedef struct st_text TEXT;
39 typedef struct st_point sPOINT;
40 typedef struct st_transform TRANSFORM;
41 typedef struct st_bezier BEZIER;
43 typedef struct st_object OBJECT;
44 typedef struct st_page PAGE;
45 typedef struct st_toplevel TOPLEVEL;
46 typedef struct st_color COLOR;
47 typedef struct st_undo UNDO;
48 typedef struct st_tile TILE;
49 typedef struct st_bounds BOUNDS;
51 typedef struct st_conn CONN;
52 typedef struct st_bus_ripper BUS_RIPPER;
54 /* netlist structures (gnetlist) */
55 typedef struct st_netlist NETLIST;
56 typedef struct st_cpinlist CPINLIST;
57 typedef struct st_net NET;
59 /* sch check structures (gschcheck) */
60 typedef struct st_schcheck SCHCHECK;
61 typedef struct st_chkerrs CHKERRS;
63 /* Managed text buffers */
64 typedef struct _TextBuffer TextBuffer;
66 /* Component library objects */
67 typedef struct _CLibSource CLibSource;
68 typedef struct _CLibSymbol CLibSymbol;
70 /* Component library search modes */
71 typedef enum { CLIB_EXACT=0, CLIB_GLOB } CLibSearchMode;
73 /* f_open behaviour flags. See documentation for f_open_flags() in
74 f_basic.c. */
75 typedef enum { F_OPEN_RC = 1,
76 F_OPEN_CHECK_BACKUP = 2,
77 F_OPEN_RESTORE_CWD = 4,
78 } FOpenFlags;
80 /*! \brief line end style for an open line of an object */
81 typedef enum {END_NONE, END_SQUARE, END_ROUND} OBJECT_END;
83 /*! \brief line style of lines, rect, circles, arcs */
84 typedef enum {TYPE_SOLID, TYPE_DOTTED, TYPE_DASHED, TYPE_CENTER, TYPE_PHANTOM, TYPE_ERASE} OBJECT_TYPE;
86 /*! \brief fill style of objects like cirle, rect, path */
87 typedef enum {FILLING_HOLLOW, FILLING_FILL, FILLING_MESH, FILLING_HATCH, FILLING_VOID} OBJECT_FILLING;
89 struct st_line {
90 int x[2];
91 int y[2];
94 struct st_point {
95 gint x;
96 gint y;
99 #define LINE_END1 0
100 #define LINE_END2 1
102 typedef enum {
103 PATH_MOVETO,
104 PATH_MOVETO_OPEN,
105 PATH_CURVETO,
106 PATH_LINETO,
107 PATH_END
108 } PATH_CODE;
110 struct st_path_section {
111 PATH_CODE code;
112 int x1;
113 int y1;
114 int x2;
115 int y2;
116 int x3;
117 int y3;
120 struct st_path {
121 PATH_SECTION *sections; /* Bezier path segments */
122 int num_sections; /* Number with data */
123 int num_sections_max; /* Number allocated */
126 struct st_arc {
127 int x, y; /* world */
129 int width;
130 int height;
132 int start_angle;
133 int end_angle;
136 #define ARC_CENTER 0
137 #define ARC_RADIUS 1
138 #define ARC_START_ANGLE 2
139 #define ARC_END_ANGLE 3
141 struct st_bezier {
142 int x[4];
143 int y[4];
146 struct st_box {
147 /* upper is considered the origin */
148 int upper_x, upper_y; /* world */
149 int lower_x, lower_y;
153 #define BOX_UPPER_LEFT 0
154 #define BOX_LOWER_RIGHT 1
155 #define BOX_UPPER_RIGHT 2
156 #define BOX_LOWER_LEFT 3
158 struct st_picture {
159 GdkPixbuf *pixbuf;
160 gchar *file_content;
161 gsize file_length;
163 double ratio;
164 char *filename;
165 int angle;
166 char mirrored;
167 char embedded;
169 /* upper is considered the origin */
170 int upper_x, upper_y; /* world */
171 int lower_x, lower_y;
175 #define PICTURE_UPPER_LEFT 0
176 #define PICTURE_LOWER_RIGHT 1
177 #define PICTURE_UPPER_RIGHT 2
178 #define PICTURE_LOWER_LEFT 3
181 struct st_text {
182 int x, y; /* world origin */
184 char *string; /* text stuff */
185 char *disp_string;
186 int length;
187 int size;
188 int alignment;
189 int angle;
192 struct st_complex {
193 int x, y; /* world origin */
195 int angle; /* orientation, only multiples
196 * of 90 degrees allowed */
197 /* in degrees */
198 int mirror;
200 GList *prim_objs; /* Primitive objects */
201 /* objects which make up the */
202 /* complex */
205 struct st_circle {
206 int center_x, center_y; /* world */
207 int radius;
210 #define CIRCLE_CENTER 0
211 #define CIRCLE_RADIUS 1
213 struct st_object {
214 int type; /* Basic information */
215 int sid;
216 char *name;
218 PAGE *page; /* Parent page */
220 int w_top; /* Bounding box information */
221 int w_left; /* in world coords */
222 int w_right;
223 int w_bottom;
224 gboolean w_bounds_valid;
226 COMPLEX *complex;
227 LINE *line;
228 CIRCLE *circle;
229 ARC *arc;
230 BOX *box;
231 TEXT *text;
232 PICTURE *picture;
233 PATH *path;
235 GList *tiles; /* tiles */
237 GList *conn_list; /* List of connections */
238 /* to and from this object */
240 /* every graphical primitive have more or less the same options. */
241 /* depending on its nature a primitive is concerned with one or more */
242 /* of these fields. If not, value must be ignored. */
243 OBJECT_END line_end;
244 OBJECT_TYPE line_type;
245 int line_width;
246 int line_space;
247 int line_length;
249 OBJECT_FILLING fill_type;
250 int fill_width;
251 int fill_angle1, fill_pitch1;
252 int fill_angle2, fill_pitch2;
254 gboolean complex_embedded; /* is embedded component? */
255 gchar *complex_basename; /* Component Library Symbol name */
256 OBJECT *parent; /* Parent object pointer */
258 int color; /* Which color */
259 int dont_redraw; /* Flag to skip redrawing */
260 int selectable; /* object selectable flag */
261 int selected; /* object selected flag */
262 int locked_color; /* Locked color (used to save */
263 /* the object's real color */
264 /* when the object is locked) */
266 /* controls which direction bus rippers go */
267 /* it is either 0 for un-inited, */
268 /* 1 for right, -1 for left (horizontal bus) */
269 /* 1 for up, -1 for down (vertial bus) */
270 int bus_ripper_direction; /* only valid on buses */
273 int font_text_size; /* used only with fonts defs */
274 GList *font_prim_objs; /* used only with fonts defs */
276 int whichend; /* for pins only, either 0 or 1 */
277 int pin_type; /* for pins only, either NET or BUS */
279 /* Tracking total number of entities connected by this net */
280 int net_num_connected; /* for nets only */
281 gboolean valid_num_connected; /* for nets only */
283 GList *attribs; /* attribute stuff */
284 int show_name_value;
285 int visibility;
286 OBJECT *attached_to; /* when object is an attribute */
287 OBJECT *copied_to; /* used when copying attributes */
289 GList *weak_refs; /* Weak references */
293 /*! \brief Structure for connections between OBJECTs
295 * The st_conn structure contains a single connection
296 * to another object.
297 * The connection system in s_conn.c uses this struct
299 struct st_conn {
300 /*! \brief The "other" object connected to this one */
301 OBJECT *other_object;
302 /*! \brief type of connection. Always in reference to how the "other"
303 object is connected to the current one */
304 int type;
305 /*! \brief x coord of the connection position */
306 int x;
307 /*! \brief y coord of the connection position */
308 int y;
309 /*! \brief which endpoint of the current object caused this connection */
310 int whichone;
311 /*! \brief which endpoint of the "other" object caused this connection */
312 int other_whichone;
315 /* this structure is used in gschem to add rippers when drawing nets */
316 /* it is never stored in any object, it is only temporary */
317 struct st_bus_ripper
319 int x[2];
320 int y[2];
323 struct st_bounds {
324 gint min_x;
325 gint min_y;
326 gint max_x;
327 gint max_y;
330 /** A structure to store a 2D affine transform.
332 * The transforms get stored in a 3x3 matrix. Code assumes the bottom row to
333 * remain constant at [0 0 1].
335 struct st_transform {
336 gdouble m[2][3]; /* m[row][column] */
339 struct st_undo {
341 /* one of these is used, depending on if you are doing in-memory */
342 /* or file based undo state saving */
343 char *filename;
344 GList *object_list;
346 /* either UNDO_ALL or UNDO_VIEWPORT_ONLY */
347 int type;
349 /* viewport information */
350 int left, top, right, bottom;
352 /* up and down the hierarchy */
353 int up;
354 /* used to control which pages are viewable when moving around */
355 int page_control;
357 UNDO *prev;
358 UNDO *next;
362 /*! \brief structure to split a page into tiles
364 * This structure is used to track objects that are inside
365 * a smaller TILE of o a page.
366 * See s_tile.c for further informations.
368 struct st_tile {
369 GList *objects;
371 int top, left, right, bottom;
374 struct st_page {
376 int pid;
378 GList *_object_list;
379 SELECTION *selection_list; /* new selection mechanism */
380 GList *place_list;
381 OBJECT *object_lastplace; /* the last found item */
383 char *page_filename;
384 int CHANGED; /* changed flag */
385 /*int zoom_factor; no longer used*/
386 int left, right, top, bottom; /* World coord limits */
387 double coord_aspectratio; /* Real worldcoords ratio (?) */
389 float to_screen_x_constant;
390 float to_screen_y_constant;
392 float to_world_x_constant;
393 float to_world_y_constant;
395 TILE world_tiles[MAX_TILES_X][MAX_TILES_Y];
397 /* Undo/Redo Stacks and pointers */
398 /* needs to go into page mechanism actually */
399 UNDO *undo_bottom;
400 UNDO *undo_current;
401 UNDO *undo_tos; /* Top Of Stack */
403 /* up and down the hierarchy */
404 /* this holds the pid of the parent page */
405 int up;
406 /* int down; not needed */
408 /* used to control which pages are viewable when moving around */
409 int page_control;
411 /* backup variables */
412 GTimeVal last_load_or_save_time;
413 char saved_since_first_loaded;
414 gint ops_since_last_backup;
415 gchar do_autosave_backup;
417 GList *weak_refs; /* Weak references */
420 /*! \brief Type of callback function for calculating text bounds */
421 typedef int(*RenderedBoundsFunc)(void *, OBJECT *, int *, int *, int *, int *);
423 /*! \brief Type of callback function for object damage notification */
424 typedef int(*ChangeNotifyFunc)(void *, OBJECT *);
426 /*! \brief Type of callback function for querying loading of backups */
427 typedef gboolean(*LoadBackupQueryFunc)(void *, GString *);
429 struct st_toplevel {
431 /* have to decided on component list stuff */
432 /* if it should go in here or not */
433 /* leave outside for now */
435 GList *RC_list; /* List of RC files which have been read in. */
437 char *untitled_name; /* untitled sch basename */
438 char *bitmap_directory; /* path of the bitmaps */
440 int init_left, init_right; /* Starting values for above */
441 int init_top, init_bottom;
443 int width, height; /* height, width of window */
445 int override_color; /* used in doing selections */
447 int last_ps_color; /* used in print code */
449 /* page system */
450 PAGE *page_current;
451 GedaPageList *pages;
453 /* show_hidden_text is used to control which text is hidden in gschem */
454 int show_hidden_text;
456 GList* major_changed_refdes; /* A list of all refdes's that have */
457 /* major symbol version changes */
459 /* backup variables */
460 int auto_save_interval;
461 gint auto_save_timeout;
463 /* BLOCK SET IN GSCHEM, BUT USED IN LIBGEDA - NEEDS A RETHINK */
464 int background_color;
465 int override_net_color;
466 int override_bus_color;
467 int override_pin_color;
468 int pin_style;
469 int net_style;
470 int bus_style;
471 int line_style;
472 /* END BLOCK - ALTHOUGH THERE ARE MORE CASES! */
474 /* controls whether objects are clipped */
475 int object_clipping;
477 /* either landscape or portrait */
478 int print_orientation;
480 /* either TRUE or FALSE (color or no color) */
481 int image_color;
483 /* either TRUE or FALSE (color or no color) */
484 int print_color;
486 /* color used color ouput for background */
487 int print_color_background;
489 /* setpagedevice orientation option enable (TRUE or FALSE) */
490 int setpagedevice_orientation;
492 /* setpagedevice pagesize option enable (TRUE or FALSE) */
493 int setpagedevice_pagesize;
495 /* The name of the prolog file to paste into the Postscript output */
496 char *postscript_prolog;
498 /* controls if the net consolidation code is used */
499 int net_consolidate;
501 /*controls if attribute promotion happens */
502 int attribute_promotion;
504 /* controls if invisible attribs are promoted */
505 int promote_invisible;
507 /* controls if invisible attribs are kept and not deleted */
508 int keep_invisible;
510 /* controls the generation of backup (~) files */
511 int make_backup_files;
513 /* either window or limits */
514 int print_output_type;
516 /* BUTT, ROUND, SQUARE caps */
517 int print_output_capstyle;
519 /* landscape printing only */
520 int paper_width, paper_height;
522 /* filename of the bus ripper component if set above */
523 char *bus_ripper_symname;
525 /* controls if the whole bounding box is used in the auto whichend code */
526 int force_boundingbox;
528 /* List of attributes to always promote */
529 GList *always_promote_attributes;
531 /* gnetlist specific */
532 int net_naming_priority;
533 int hierarchy_traversal;
534 int hierarchy_uref_mangle;
535 int hierarchy_netname_mangle;
536 int hierarchy_netattrib_mangle;
537 char *hierarchy_uref_separator;
538 char *hierarchy_netname_separator;
539 char *hierarchy_netattrib_separator;
540 int hierarchy_netattrib_order;
541 int hierarchy_netname_order;
542 int hierarchy_uref_order;
543 char *unnamed_netname;
544 char *unnamed_busname;
546 /* Callback function for calculating text bounds */
547 RenderedBoundsFunc rendered_text_bounds_func;
548 void *rendered_text_bounds_data;
550 /* Callback functions for object change notification */
551 GList *change_notify_funcs;
553 /* Callback function for deciding whether to load a backup file. */
554 LoadBackupQueryFunc load_newer_backup_func;
555 void *load_newer_backup_data;
557 GList *weak_refs; /* Weak references */
560 /* structures below are for gnetlist */
562 /* for every component in the object database */
563 struct st_netlist {
565 int nlid;
567 char *component_uref;
569 OBJECT *object_ptr;
571 CPINLIST *cpins;
573 char *hierarchy_tag;
574 int composite_component;
576 NETLIST *prev;
577 NETLIST *next;
581 /* for every pin on a component */
582 struct st_cpinlist {
583 int plid;
584 int type; /* PIN_TYPE_NET or PIN_TYPE_BUS */
586 char *pin_number;
587 char *net_name; /* this is resolved at very end */
588 char *pin_label;
590 NET *nets;
592 CPINLIST *prev;
593 CPINLIST *next;
596 /* the net run connected to a pin */
597 struct st_net {
599 int nid;
601 int net_name_has_priority;
602 char *net_name;
603 char *pin_label;
605 char *connected_to; /* new to replace above */
607 NET *prev;
608 NET *next;
611 /* By Jamil Khatib */
612 /* typedef struct st_chkerrs CHKERRS; */
614 /* Schem check struct */
615 struct st_schcheck {
616 int no_errors; /* No of Errors */
617 int no_warnings; /* No of Warinings */
619 CHKERRS * sheet_errs;
621 CHKERRS *float_nets; /* Header of the list of floating nets */
622 int net_errs; /* No of floating nets */
624 OBJECT *float_pins; /* Header of List of floating pins*/
625 int pin_errs; /* No of floating pins */
627 int net_names; /* No of mismatched net names */
631 struct st_chkerrs{
633 OBJECT * err_obj;
634 CHKERRS * next;
640 struct st_color {
641 guint8 r, g, b, a;
642 gboolean enabled;
646 struct st_attrib_smob {
647 TOPLEVEL *world; /* We need this when updating schematic */
648 OBJECT *attribute;
651 struct st_object_smob {
652 TOPLEVEL *world; /* We need this when updating schematic */
653 OBJECT *object;
656 struct st_page_smob {
657 TOPLEVEL *world; /* We need this when updating schematic */
658 PAGE *page;
661 /* used by the rc loading mechanisms */
662 typedef struct {
663 int m_val;
664 char *m_str;
665 } vstbl_entry;
667 /* Used by g_rc_parse_handler() */
668 typedef void (*ConfigParseErrorFunc)(GError **, void *);
670 #endif