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.
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
75 typedef enum { F_OPEN_RC
= 1,
76 F_OPEN_CHECK_BACKUP
= 2,
77 F_OPEN_RESTORE_CWD
= 4,
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
;
110 struct st_path_section
{
121 PATH_SECTION
*sections
; /* Bezier path segments */
122 int num_sections
; /* Number with data */
123 int num_sections_max
; /* Number allocated */
127 int x
, y
; /* world */
138 #define ARC_START_ANGLE 2
139 #define ARC_END_ANGLE 3
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
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
182 int x
, y
; /* world origin */
184 char *string
; /* text stuff */
193 int x
, y
; /* world origin */
195 int angle
; /* orientation, only multiples
196 * of 90 degrees allowed */
200 GList
*prim_objs
; /* Primitive objects */
201 /* objects which make up the */
206 int center_x
, center_y
; /* world */
210 #define CIRCLE_CENTER 0
211 #define CIRCLE_RADIUS 1
214 int type
; /* Basic information */
218 PAGE
*page
; /* Parent page */
220 int w_top
; /* Bounding box information */
221 int w_left
; /* in world coords */
224 gboolean w_bounds_valid
;
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. */
244 OBJECT_TYPE line_type
;
249 OBJECT_FILLING fill_type
;
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 */
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
297 * The connection system in s_conn.c uses this struct
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 */
305 /*! \brief x coord of the connection position */
307 /*! \brief y coord of the connection position */
309 /*! \brief which endpoint of the current object caused this connection */
311 /*! \brief which endpoint of the "other" object caused this connection */
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 */
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] */
341 /* one of these is used, depending on if you are doing in-memory */
342 /* or file based undo state saving */
346 /* either UNDO_ALL or UNDO_VIEWPORT_ONLY */
349 /* viewport information */
350 int left
, top
, right
, bottom
;
352 /* up and down the hierarchy */
354 /* used to control which pages are viewable when moving around */
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.
371 int top
, left
, right
, bottom
;
379 SELECTION
*selection_list
; /* new selection mechanism */
381 OBJECT
*object_lastplace
; /* the last found item */
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 */
401 UNDO
*undo_tos
; /* Top Of Stack */
403 /* up and down the hierarchy */
404 /* this holds the pid of the parent page */
406 /* int down; not needed */
408 /* used to control which pages are viewable when moving around */
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
*);
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 */
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
;
472 /* END BLOCK - ALTHOUGH THERE ARE MORE CASES! */
474 /* controls whether objects are clipped */
477 /* either landscape or portrait */
478 int print_orientation
;
480 /* either TRUE or FALSE (color or no color) */
483 /* either TRUE or FALSE (color or no 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 */
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 */
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 */
567 char *component_uref
;
574 int composite_component
;
581 /* for every pin on a component */
584 int type
; /* PIN_TYPE_NET or PIN_TYPE_BUS */
587 char *net_name
; /* this is resolved at very end */
596 /* the net run connected to a pin */
601 int net_name_has_priority
;
605 char *connected_to
; /* new to replace above */
611 /* By Jamil Khatib */
612 /* typedef struct st_chkerrs CHKERRS; */
614 /* Schem check struct */
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 */
646 struct st_attrib_smob
{
647 TOPLEVEL
*world
; /* We need this when updating schematic */
651 struct st_object_smob
{
652 TOPLEVEL
*world
; /* We need this when updating schematic */
656 struct st_page_smob
{
657 TOPLEVEL
*world
; /* We need this when updating schematic */
661 /* used by the rc loading mechanisms */
667 /* Used by g_rc_parse_handler() */
668 typedef void (*ConfigParseErrorFunc
)(GError
**, void *);