1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's Library
3 * Copyright (C) 1998-2004 Ales V. 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
;
28 /* gschem structures (gschem) */
29 typedef struct st_complex COMPLEX
;
30 typedef struct st_line LINE
;
31 typedef struct st_circle CIRCLE
;
32 typedef struct st_arc ARC
;
33 typedef struct st_box BOX
;
34 typedef struct st_picture PICTURE
;
35 typedef struct st_text TEXT
;
37 typedef struct st_attrib ATTRIB
;
38 typedef struct st_object OBJECT
;
39 typedef struct st_page PAGE
;
40 typedef struct st_toplevel TOPLEVEL
;
41 typedef struct st_color COLOR
;
42 typedef struct st_undo UNDO
;
43 typedef struct st_tile TILE
;
44 typedef struct st_tile_loc TILE_LOC
;
46 typedef struct st_conn CONN
;
47 typedef struct st_bus_ripper BUS_RIPPER
;
49 /* Used when you move objects and you want the nets/pins to stretch */
50 typedef struct st_stretch STRETCH
;
52 /* netlist structures (gnetlist) */
53 typedef struct st_netlist NETLIST
;
54 typedef struct st_cpinlist CPINLIST
;
55 typedef struct st_net NET
;
57 /* sch check structures (gschcheck) */
58 typedef struct st_schcheck SCHCHECK
;
59 typedef struct st_chkerrs CHKERRS
;
61 /* Managed text buffers */
62 typedef struct _TextBuffer TextBuffer
;
64 /* Component library objects */
65 typedef struct _CLibSource CLibSource
;
66 typedef struct _CLibSymbol CLibSymbol
;
68 /* Component library search modes */
69 typedef enum { CLIB_EXACT
=0, CLIB_GLOB
} CLibSearchMode
;
71 /* f_open behaviour flags. See documentation for f_open_flags() in
73 typedef enum { F_OPEN_RC
= 1,
74 F_OPEN_CHECK_BACKUP
= 2,
75 F_OPEN_RESTORE_CWD
= 4,
78 /* PB : change begin */
79 /* PB : these enum are constant to define :
80 - the end of open line of an object ;
81 - the type of the line of an object ;
82 - the filling of a closed object. */
83 /* PB : used in struct st_object (predefined type OBJECT)*/
84 typedef enum {END_NONE
, END_SQUARE
, END_ROUND
} OBJECT_END
;
85 typedef enum {TYPE_SOLID
, TYPE_DOTTED
, TYPE_DASHED
, TYPE_CENTER
, TYPE_PHANTOM
, TYPE_ERASE
} OBJECT_TYPE
;
86 typedef enum {FILLING_HOLLOW
, FILLING_FILL
, FILLING_MESH
, FILLING_HATCH
, FILLING_VOID
} OBJECT_FILLING
;
96 /* pb20011014 - name the grips */
101 int x
, y
; /* world */
109 /* pb20011014 - name the grips */
112 #define ARC_START_ANGLE 2
113 #define ARC_END_ANGLE 3
116 /* upper is considered the origin */
117 int upper_x
, upper_y
; /* world */
118 int lower_x
, lower_y
;
121 /* pb20011014 - name the grips */
122 #define BOX_UPPER_LEFT 0
123 #define BOX_LOWER_RIGHT 1
124 #define BOX_UPPER_RIGHT 2
125 #define BOX_LOWER_LEFT 3
128 GdkPixbuf
*original_picture
;
129 GdkPixbuf
*displayed_picture
;
137 /* upper is considered the origin */
138 int upper_x
, upper_y
; /* world */
139 int lower_x
, lower_y
;
143 #define PICTURE_UPPER_LEFT 0
144 #define PICTURE_LOWER_RIGHT 1
145 #define PICTURE_UPPER_RIGHT 2
146 #define PICTURE_LOWER_LEFT 3
150 int x
, y
; /* world origin */
152 char *string
; /* text stuff */
157 int displayed_height
;
164 int x
, y
; /* world origin */
166 int angle
; /* orientation, only multiples
167 * of 90 degrees allowed */
171 OBJECT
*prim_objs
; /* Primitive objects */
172 /* objects which make up the */
177 int center_x
, center_y
; /* world */
180 /* pb20011010 - removed : used only in o_circle_draw_xor() and
183 /* pb20011014 - name the grips */
184 #define CIRCLE_CENTER 0
185 #define CIRCLE_RADIUS 1
188 int type
; /* Basic information */
192 int w_top
; /* Bounding box information */
193 int w_left
; /* in world coords */
205 GList
*tile_locs
; /* tile locations */
207 GList
*conn_list
; /* List of connections */
208 /* to and from this object */
210 /* PB : change begin */
211 /* PB : every graphical primitive have more or less the same options. */
212 /* PB : depending on its nature a primitive is concerned with one or more */
213 /* PB : of these fields. If not, value must be ignored. */
215 OBJECT_TYPE line_type
;
220 OBJECT_FILLING fill_type
;
222 int fill_angle1
, fill_pitch1
;
223 int fill_angle2
, fill_pitch2
;
224 /* PB : change end */
226 int visited
; /* used in gnetlist for travesal purposes */
228 gboolean complex_embedded
; /* is embedded component? */
229 gchar
*complex_basename
; /* Component Library Symbol name */
230 OBJECT
*complex_parent
; /* Complex parent object pointer */
231 /* used only in complex head nodes */
234 void (*action_func
)(); /* Execute function */
236 void (*sel_func
)(); /* Selected function */
237 void (*draw_func
)(); /* Draw function */
239 int color
; /* Which color */
240 int saved_color
; /* Saved color */
241 int selected
; /* object selected flag */
242 int locked_color
; /* Locked color (used to save */
243 /* the object's real color */
244 /* when the object is locked) */
246 int draw_grips
; /* if selected, enables
249 /* controls which direction bus rippers go */
250 /* it is either 0 for un-inited, */
251 /* 1 for right, -1 for left (horizontal bus) */
252 /* 1 for up, -1 for down (vertial bus) */
253 int bus_ripper_direction
; /* only valid on buses */
256 int font_text_size
; /* used only with fonts defs */
257 OBJECT
*font_prim_objs
; /* used only with fonts defs */
259 ATTRIB
*attribs
; /* attribute stuff */
260 ATTRIB
*attached_to
; /* when object is an attribute */
265 int whichend
; /* for pins only, either 0 or 1 */
266 int pin_type
; /* for pins only, either NET or BUS */
274 OBJECT
*object
; /* object attribute is connected to */
276 OBJECT
*copied_to
; /* used when copying attributes */
283 OBJECT
*other_object
; /* The "other" object connected to this one */
284 int type
; /* Always in reference to how the "other" */
285 /* object is connected to the current one */
286 int x
, y
; /* x, y coord of the connection */
287 int whichone
; /* which endpoint of the current object */
288 /* caused this connection */
289 int other_whichone
; /* which endpoint of the "other" object */
290 /* caused this connection */
293 /* this structure is used in gschem to add rippers when drawing nets */
294 /* it is never stored in any object, it is only temporary */
314 /* one of these is used, depending on if you are doing in-memory */
315 /* or file based undo state saving */
319 /* either UNDO_ALL or UNDO_VIEWPORT_ONLY */
322 /* viewport information */
323 int left
, top
, right
, bottom
;
325 /* up and down the hierarchy */
327 /* used to control which pages are viewable when moving around */
337 int top
, left
, right
, bottom
;
341 int i
, j
; /* these are the indices into the tile structure */
350 OBJECT
*object_parent
;
351 SELECTION
*selection_list
; /* new selection mechanism */
352 GList
*complex_place_list
;
353 OBJECT
*attrib_place_head
;
354 OBJECT
*attrib_place_tail
;
355 OBJECT
*object_lastplace
;
356 OBJECT
*object_selected
;
357 STRETCH
*stretch_head
;
358 STRETCH
*stretch_tail
;
361 int CHANGED
; /* changed flag */
362 /*int zoom_factor; no longer used*/
363 int left
, right
, top
, bottom
; /* World coord limits */
364 double coord_aspectratio
; /* Real worldcoords ratio (?) */
366 float to_screen_x_constant
;
367 float to_screen_y_constant
;
369 float to_world_x_constant
;
370 float to_world_y_constant
;
372 TILE world_tiles
[MAX_TILES_X
][MAX_TILES_Y
];
374 /* Undo/Redo Stacks and pointers */
375 /* needs to go into page mechanism actually */
378 UNDO
*undo_tos
; /* Top Of Stack */
380 /* up and down the hierarchy */
381 /* this holds the pid of the parent page */
383 /* int down; not needed */
385 /* used to control which pages are viewable when moving around */
388 /* backup variables */
389 GTimeVal last_load_or_save_time
;
390 char saved_since_first_loaded
;
391 gint ops_since_last_backup
;
392 gchar do_autosave_backup
;
394 /* Function which asks the user wether to load a newer backup file */
395 int (*load_newer_backup_func
)();
397 /* left to right movement */
404 int wid
; /* Window id, always unique */
406 int num_untitled
; /* keep track of untitled wins */
419 /* used by attribute dialog */
420 /* also used by text add dialog */
421 char *current_attribute
;
424 /* used by add picture dialog */
425 GdkPixbuf
*current_pixbuf
;
427 double pixbuf_wh_ratio
; /* width/height ratio of the pixbuf */
428 char *pixbuf_filename
;
430 int current_visible
; /* in o_attrib.c */
432 /* have to decided on attribute list stuff */
433 /* if it should go in here or not */
434 /* leave outside for now */
436 gchar
*internal_symbol_name
;
437 /* have to decided on component list stuff */
438 /* if it should go in here or not */
439 /* leave outside for now */
441 GList
*RC_list
; /* List of RC files which have been read in. */
443 char *series_name
; /* Current series basename */
444 char *untitled_name
; /* untitled sch basename */
445 char *font_directory
; /* path of the vector fonts */
446 char *scheme_directory
; /* path of the scheme scripts */
447 char *bitmap_directory
; /* path of the bitmaps */
449 int event_state
; /* Current event state */
451 int inside_action
; /* Are we doing an action? */
452 int rotated_inside
; /* Was the selection rotated
455 int init_left
, init_right
; /* Starting values for above */
456 int init_top
, init_bottom
;
458 int win_width
, win_height
; /* Actual size of window (?) */
459 int width
, height
; /* height, width of window */
460 int image_width
, image_height
; /* h, w of image write */
461 int snap
; /* Snap on/off*/
462 int grid
; /* Grid on/off*/
463 int min_zoom
; /* minimum zoom factor */
464 int max_zoom
; /* maximum zoom factor */
466 /* starting window width used to control text */
469 /* location to hold current alignment of text */
472 /* location to hold current line type selection */
475 /* location to hold current fill type selection (PB) */
478 int override_color
; /* used in doing selections */
479 int inside_redraw
; /* complex vs list redrawing */
480 double window_aspectratio
; /* Window ratio (?) */
481 int display_height
; /* display params */
482 int display_width
; /* could me made global (?) */
484 int DONT_DRAW_CONN
; /* misc flags */
489 int FORCE_CONN_UPDATE
;
493 int drawbounding_action_mode
; /* outline vs bounding box */
494 int last_drawb_mode
; /* last above mode */
496 int CONTROLKEY
; /* control key pressed? */
497 int SHIFTKEY
; /* shift key pressed? */
498 int ALTKEY
; /* alt key pressed? */
500 int doing_pan
; /* mouse pan status flag */
507 /* buffer_number is used by the buffer copy/cut/paste mechanism */
508 /* in gschem to keep track of the current buffer number */
511 /* show_hidden_text is used to control which text is hidden in gschem */
512 int show_hidden_text
;
514 /* Variable to keep track of what value the complex is at */
517 void (*last_callback
)(); /* Last i_call* cmd executed */
518 char *cwd
; /* current working directory */
520 GList
* major_changed_refdes
; /* A list of all refdes's that have */
521 /* major symbol version changes */
523 /* main window widgets */
524 GtkWidget
*main_window
;
525 GtkWidget
*drawing_area
;
527 GtkWidget
*popup_menu
;
528 GtkWidget
*h_scrollbar
;
529 GtkWidget
*v_scrollbar
;
530 GtkObject
*h_adjustment
;
531 GtkObject
*v_adjustment
;
532 GtkWidget
*left_label
;
533 GtkWidget
*middle_label
;
534 GtkWidget
*right_label
;
535 GtkWidget
*filename_label
;
536 GtkWidget
*grid_label
;
537 GtkWidget
*status_label
;
539 GtkWidget
*toolbar_select
;
540 GtkWidget
*toolbar_net
;
541 GtkWidget
*toolbar_bus
;
542 GtkWidget
*toolbar_edit
;
543 GtkWidget
*toolbar_move
;
544 GtkWidget
*toolbar_copy
;
545 GtkWidget
*toolbar_delete
;
546 GtkWidget
*toolbar_rotate
;
547 GtkWidget
*toolbar_mirror
;
550 GtkWidget
*fowindow
; /* File open */
551 GtkWidget
*fswindow
; /* File save */
552 GtkWidget
*sowindow
; /* Script open */
553 GtkWidget
*pfswindow
; /* Picture File Selection window */
554 GtkWidget
*pcfswindow
; /* Picture Change File Selection window */
555 int saveas_flag
; /* what action after save? */
557 GtkWidget
*aswindow
; /* Attribute select */
558 GtkWidget
*attr_list
;
559 GtkWidget
*asentry_name
;
560 GtkWidget
*asentry_value
;
562 GtkWidget
*cswindow
; /* component select */
563 GtkWidget
*clib_list
;
564 GtkWidget
*basename_list
;
566 GtkWidget
*iwindow
; /* image write dialog box */
567 GtkWidget
*ifilename_entry
;
569 GtkWidget
*pswindow
; /* page select */
572 GtkWidget
*tiwindow
; /* text input */
573 GtkWidget
*tewindow
; /* text edit */
575 GtkWidget
*ltwindow
; /* line type / width edit */
576 GtkWidget
*ftwindow
; /* fill type edit (PB) */
577 GtkWidget
*sewindow
; /* slot edit */
579 GtkWidget
*exwindow
; /* exit confirm */
580 GtkWidget
*aawindow
; /* arc attribs */
581 GtkWidget
*mawindow
; /* multi attribute */
582 GtkWidget
*aewindow
; /* attribute edit */
583 GtkWidget
*aaentry_start
;
584 GtkWidget
*aaentry_sweep
;
585 GtkWidget
*trwindow
; /* translate */
587 GtkWidget
*tswindow
; /* text size */
588 GtkWidget
*tshowwindow
; /* text show window */
589 GtkWidget
*thidewindow
; /* text hide window */
590 GtkWidget
*tfindwindow
; /* text find window */
591 GtkWidget
*tsentry
; /* used in edit/edit and */
592 /* Text size and the snap */
593 /* size dialog boxes */
595 GtkWidget
*abwindow
; /* Help/About... dialog*/
596 GtkWidget
*hkwindow
; /* Help/Hotkeys... dialog*/
598 GtkWidget
*coord_world
;
599 GtkWidget
*coord_screen
;
604 /* this is the drawing_area's X drawable */
607 /* graphics context stuff */
610 GdkGC
*outline_xor_gc
;
611 GdkGC
*bounding_xor_gc
;
614 /* backingstore pixmap */
615 GdkPixmap
*backingstore
;
617 /* used for visual feedback when pressing keyboard accelerators */
618 gchar
*keyaccel_string
;
620 /* rc/user parameters */
625 /* backup variables */
626 int auto_save_interval
;
627 gint auto_save_timeout
;
630 /* not used anywhere yet, but will be */
631 int logic_bubble_color
;
635 int detachedattr_color
;
638 /* used by math funcs for the snapping */
642 int background_color
;
646 int net_endpoint_color
;
650 int override_net_color
;
651 int override_bus_color
;
652 int override_pin_color
;
659 /* can be either OUTLINE or BOUNDINGBOX */
660 int actionfeedback_mode
;
662 /* controls if text is drawn or not in copy/move/place ops */
665 /* zoom factor at which text is displayed completely */
666 int text_display_zoomfactor
;
668 /* can be either NONE, FILLEDBOX, EMPTYBOX, X */
669 int net_endpoint_mode
;
671 /* can be either NONE or FILLED or EMPTY */
672 int net_midpoint_mode
;
674 /* controls whether objects are clipped */
677 /* controls if complex objects are embedded */
680 /* controls if complex objects are included */
683 /* controls how text is printed (vector / PS font) */
686 /* controls if scrollbars are displayed */
689 /* either landscape or portrait */
690 int print_orientation
;
692 /* either TRUE or FALSE (color or no color) */
695 /* either TRUE or FALSE (color or no color) */
698 /* color used color ouput for background */
699 int print_color_background
;
701 /* setpagedevice orientation option enable (TRUE or FALSE) */
702 int setpagedevice_orientation
;
704 /* setpagedevice pagesize option enable (TRUE or FALSE) */
705 int setpagedevice_pagesize
;
707 /* The name of the prolog file to paste into the Postscript output */
708 char *postscript_prolog
;
710 /* Use this as a scaling factor for the output font */
711 float postscript_font_scale
;
713 /* color of the stroke points */
716 /* controls if the log windows mapped on startup */
719 /* controls if the log window is decorated or not */
722 /* controls what the third mouse button does */
725 /* controls what the third mouse button does */
728 /* controls if the net consolidation code is used */
731 /* controls if the preview area is enabled or not */
734 /* controls how much freedom user has when traversing the hierarchy */
735 int enforce_hierarchy
;
737 /* controls if text origin marker is displayed or not */
738 int text_origin_marker
;
740 /* controls if text is completely drawn during mouse pan */
743 /*controls if expose events raise dialog boxes*/
744 int raise_dialog_boxes
;
746 /*controls if attribute promotion happens */
747 int attribute_promotion
;
749 /* controls if invisible attribs are promoted */
750 int promote_invisible
;
752 /* controls if invisible attribs are kept and not deleted */
755 /* controls if after doing a place the */
756 /* same component can be placed again */
757 int continue_component_place
;
759 /* Number of undo levels stored on disk */
762 /* Controls if undo is enabled or not */
765 /* Type of undo (disk/memory) */
768 /* Controls if grips are enabled or not */
771 /* controls if nets are rubberbanded as you move */
772 /* them (or connecting comps) */
773 int netconn_rubberband
;
775 /* sort the component library */
776 int sort_component_library
;
778 /* warp the cursor when zooming */
781 /* controls if the toolbar(s) are enabled or disabled */
784 /* controls if the handleboxes are enabled or disabled */
787 /* either window or limits */
788 int print_output_type
;
790 /* BUTT, ROUND, SQUARE caps */
791 int print_output_capstyle
;
793 /* either window or limits */
794 int image_output_type
;
796 /* landscape printing only */
797 int paper_width
, paper_height
;
799 /* controls the size of the bus rippers */
802 /* controls the type of the bus ripper (either component or net) */
805 /* filename of the bus ripper component if set above */
806 char *bus_ripper_symname
;
808 /* controls whether or not the the bus ripper is symmetric or not */
809 int bus_ripper_rotation
;
811 /* controls if the whole bounding box is used in the auto whichend code */
812 int force_boundingbox
;
814 /* controls the grid dot size */
817 /* controls the mode of the grid (either variable or fixed) */
820 /* controls the mininum number of pixels necessary for the grid to be */
822 int grid_fixed_threshold
;
824 /* controls the threshold (in lines of text) when the multi-line text */
825 /* output font is forced to vector */
826 int print_vector_threshold
;
828 /* controls the offset (in world coordinates) that are added to netname */
829 /* attributes when they are attached to vertical or horizontal nets */
830 int add_attribute_offset
;
832 /* Controls if drag can move objects or not */
835 /* List of attributes to always promote */
836 char *always_promote_attributes
;
838 /* Controls the gain of the mouse pan */
841 /* Controls the gain of the keyboard pan */
842 int keyboardpan_gain
;
844 /* The command to send postscript to when printing */
847 /* Number of pixels around an object we can still select it with */
848 int select_slack_pixels
;
850 /* gnetlist specific */
851 int net_naming_priority
;
852 int hierarchy_traversal
;
853 int hierarchy_uref_mangle
;
854 int hierarchy_netname_mangle
;
855 int hierarchy_netattrib_mangle
;
856 char *hierarchy_uref_separator
;
857 char *hierarchy_netname_separator
;
858 char *hierarchy_netattrib_separator
;
859 int hierarchy_netattrib_order
;
860 int hierarchy_netname_order
;
861 int hierarchy_uref_order
;
862 char *unnamed_netname
;
868 /* structures below are for gnetlist */
870 /* for every component in the object database */
875 char *component_uref
;
882 int composite_component
;
889 /* for every pin on a component */
894 char *net_name
; /* this is resolved at very end */
903 /* the net run connected to a pin */
908 int net_name_has_priority
;
912 char *connected_to
; /* new to replace above */
918 /* By Jamil Khatib */
919 /* typedef struct st_chkerrs CHKERRS; */
921 /* Schem check struct */
923 int no_errors
; /* No of Errors */
924 int no_warnings
; /* No of Warinings */
926 CHKERRS
* sheet_errs
;
928 CHKERRS
*float_nets
; /* Header of the list of floating nets */
929 int net_errs
; /* No of floating nets */
931 OBJECT
*float_pins
; /* Header of List of floating pins*/
932 int pin_errs
; /* No of floating pins */
934 int net_names
; /* No of mismatched net names */
949 char *outline_color_name
;
950 char *ps_color_string
;
951 int image_red
, image_green
, image_blue
;
954 GdkColor
*gtk_outline_color
;
959 struct st_attrib_smob
{
960 TOPLEVEL
*world
; /* We need this when updating schematic */
964 struct st_object_smob
{
965 TOPLEVEL
*world
; /* We need this when updating schematic */
969 struct st_page_smob
{
970 TOPLEVEL
*world
; /* We need this when updating schematic */
974 /* used by the rc loading mechanisms */