libgeda

struct.h

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * libgeda - gEDA's Library
00003  * Copyright (C) 1998-2010 Ales Hvezda
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00018  * MA 02111-1301 USA.
00019  */
00020 
00021 #ifndef STRUCT_H
00022 #define STRUCT_H
00023 
00024 #include <glib.h>  /* Include needed to make GList work. */
00025 
00026 /* Wrappers around a new list mechanism */
00027 typedef struct _GedaList SELECTION;
00028 typedef struct _GedaList GedaPageList;
00029 
00030 /* gschem structures (gschem) */
00031 typedef struct st_complex COMPLEX;
00032 typedef struct st_line LINE;
00033 typedef struct st_path_section PATH_SECTION;
00034 typedef struct st_path PATH;
00035 typedef struct st_circle CIRCLE;
00036 typedef struct st_arc ARC;
00037 typedef struct st_box BOX;
00038 typedef struct st_picture PICTURE;
00039 typedef struct st_text TEXT;
00040 typedef struct st_point sPOINT;
00041 typedef struct st_transform TRANSFORM;
00042 typedef struct st_bezier BEZIER;
00043 
00044 typedef struct st_object OBJECT;
00045 typedef struct st_page PAGE;
00046 typedef struct st_toplevel TOPLEVEL;
00047 typedef struct st_color COLOR;
00048 typedef struct st_undo UNDO;
00049 typedef struct st_tile TILE;
00050 typedef struct st_bounds BOUNDS;
00051 
00052 typedef struct st_conn CONN;
00053 typedef struct st_bus_ripper BUS_RIPPER;
00054 
00055 /* netlist structures (gnetlist) */
00056 typedef struct st_netlist NETLIST;
00057 typedef struct st_cpinlist CPINLIST;
00058 typedef struct st_net NET;
00059 
00060 /* sch check structures (gschcheck) */
00061 typedef struct st_schcheck SCHCHECK;
00062 typedef struct st_chkerrs CHKERRS;
00063 
00064 /* Managed text buffers */
00065 typedef struct _TextBuffer TextBuffer;
00066 
00067 /* Component library objects */
00068 typedef struct _CLibSource CLibSource;
00069 typedef struct _CLibSymbol CLibSymbol;
00070 
00071 /* Component library search modes */
00072 typedef enum { CLIB_EXACT=0, CLIB_GLOB } CLibSearchMode;
00073 
00074 /* f_open behaviour flags.  See documentation for f_open_flags() in
00075    f_basic.c. */
00076 typedef enum { F_OPEN_RC           = 1,
00077                F_OPEN_CHECK_BACKUP = 2,
00078                F_OPEN_RESTORE_CWD  = 4,
00079 } FOpenFlags;
00080 
00082 typedef enum {END_NONE, END_SQUARE, END_ROUND} OBJECT_END;
00083 
00085 typedef enum {TYPE_SOLID, TYPE_DOTTED, TYPE_DASHED, TYPE_CENTER, TYPE_PHANTOM, TYPE_ERASE} OBJECT_TYPE;
00086 
00088 typedef enum {FILLING_HOLLOW, FILLING_FILL, FILLING_MESH, FILLING_HATCH, FILLING_VOID} OBJECT_FILLING;
00089 
00090 struct st_line {
00091   int x[2];
00092   int y[2];
00093 };
00094 
00095 struct st_point {
00096   gint x;
00097   gint y;
00098 };
00099 
00100 #define LINE_END1 0
00101 #define LINE_END2 1
00102 
00103 typedef enum {
00104     PATH_MOVETO,
00105     PATH_MOVETO_OPEN,
00106     PATH_CURVETO,
00107     PATH_LINETO,
00108     PATH_END
00109 } PATH_CODE;
00110 
00111 struct st_path_section {
00112   PATH_CODE code;
00113   int x1;
00114   int y1;
00115   int x2;
00116   int y2;
00117   int x3;
00118   int y3;
00119 };
00120 
00121 struct st_path {
00122   PATH_SECTION *sections; /* Bezier path segments  */
00123   int num_sections;       /* Number with data      */
00124   int num_sections_max;   /* Number allocated      */
00125 };
00126 
00127 struct st_arc {
00128   int x, y; /* world */
00129 
00130   int width;
00131   int height;
00132 
00133   int start_angle;
00134   int end_angle;
00135 };
00136 
00137 #define ARC_CENTER 0
00138 #define ARC_RADIUS 1
00139 #define ARC_START_ANGLE 2
00140 #define ARC_END_ANGLE 3
00141 
00142 struct st_bezier {
00143   int x[4];
00144   int y[4];
00145 };
00146 
00147 struct st_box {
00148   /* upper is considered the origin */
00149   int upper_x, upper_y; /* world */ 
00150   int lower_x, lower_y;
00151 
00152 };
00153 
00154 #define BOX_UPPER_LEFT 0
00155 #define BOX_LOWER_RIGHT 1
00156 #define BOX_UPPER_RIGHT 2
00157 #define BOX_LOWER_LEFT 3
00158 
00159 struct st_picture {
00160   GdkPixbuf *pixbuf;
00161   gchar *file_content;
00162   gsize file_length;
00163 
00164   double ratio;
00165   char *filename;
00166   int angle;
00167   char mirrored;
00168   char embedded;
00169 
00170   /* upper is considered the origin */
00171   int upper_x, upper_y; /* world */ 
00172   int lower_x, lower_y;
00173 
00174 };
00175 
00176 #define PICTURE_UPPER_LEFT 0
00177 #define PICTURE_LOWER_RIGHT 1
00178 #define PICTURE_UPPER_RIGHT 2
00179 #define PICTURE_LOWER_LEFT 3
00180 
00181 
00182 struct st_text {
00183   int x, y;     /* world origin */
00184 
00185   char *string;         /* text stuff */
00186   char *disp_string;
00187   int length;
00188   int size;
00189   int alignment;    
00190   int angle;
00191 };
00192 
00193 struct st_complex {
00194   int x, y;     /* world origin */
00195 
00196   int angle;                /* orientation, only multiples
00197                                          * of 90 degrees allowed */   
00198   /* in degrees */
00199   int mirror;
00200 
00201   GList *prim_objs;         /* Primitive objects */
00202   /* objects which make up the */
00203   /* complex */
00204 };
00205 
00206 struct st_circle {
00207   int center_x, center_y; /* world */
00208   int radius;
00209 };
00210 
00211 #define CIRCLE_CENTER 0
00212 #define CIRCLE_RADIUS 1
00213 
00214 struct st_object {
00215   int type;             /* Basic information */
00216   int sid;
00217   char *name;
00218 
00219   PAGE *page; /* Parent page */
00220 
00221   int w_top;                /* Bounding box information */
00222   int w_left;               /* in world coords */
00223   int w_right;
00224   int w_bottom;
00225   gboolean w_bounds_valid;
00226 
00227   COMPLEX *complex;
00228   LINE *line; 
00229   CIRCLE *circle; 
00230   ARC *arc;
00231   BOX *box;
00232   TEXT *text;
00233   PICTURE *picture;
00234   PATH *path;
00235 
00236   GList *tiles;         /* tiles */
00237 
00238   GList *conn_list;         /* List of connections */
00239   /* to and from this object */
00240 
00241   /* every graphical primitive have more or less the same options. */
00242   /* depending on its nature a primitive is concerned with one or more */
00243   /* of these fields. If not, value must be ignored. */
00244   OBJECT_END line_end;
00245   OBJECT_TYPE line_type;
00246   int line_width;
00247   int line_space;
00248   int line_length;
00249 
00250   OBJECT_FILLING fill_type;
00251   int fill_width;
00252   int fill_angle1, fill_pitch1;
00253   int fill_angle2, fill_pitch2;
00254 
00255   gboolean complex_embedded;                    /* is embedded component? */
00256   gchar *complex_basename;              /* Component Library Symbol name */
00257   OBJECT *parent;                       /* Parent object pointer */
00258 
00259   int color;                /* Which color */
00260   int dont_redraw;          /* Flag to skip redrawing */
00261   int selectable;           /* object selectable flag */
00262   int selected;             /* object selected flag */
00263   int locked_color;             /* Locked color (used to save */
00264   /* the object's real color */
00265   /* when the object is locked) */
00266 
00267   /* controls which direction bus rippers go */
00268   /* it is either 0 for un-inited, */
00269   /* 1 for right, -1 for left (horizontal bus) */
00270   /* 1 for up, -1 for down (vertial bus) */
00271   int bus_ripper_direction;             /* only valid on buses */
00272 
00273 
00274   int font_text_size;           /* used only with fonts defs */
00275   GList *font_prim_objs;            /* used only with fonts defs */
00276 
00277   int whichend;    /* for pins only, either 0 or 1 */
00278   int pin_type;    /* for pins only, either NET or BUS */
00279 
00280   /* Tracking total number of entities connected by this net */
00281   int net_num_connected;          /* for nets only */
00282   gboolean valid_num_connected;   /* for nets only */
00283 
00284   GList *attribs;       /* attribute stuff */
00285   int show_name_value;
00286   int visibility;
00287   OBJECT *attached_to;  /* when object is an attribute */
00288   OBJECT *copied_to;    /* used when copying attributes */
00289 
00290   GList *weak_refs; /* Weak references */
00291 
00292   /* Attribute notification handling */
00293   int attrib_notify_freeze_count;
00294   int attrib_notify_pending;
00295 
00296   /* Connection notification handling */
00297   int conn_notify_freeze_count;
00298   int conn_notify_pending;
00299 }; 
00300 
00301 
00308 struct st_conn {
00310   OBJECT *other_object;
00313   int type;
00315   int x;
00317   int y;        
00319   int whichone;
00321   int other_whichone;
00322 };
00323 
00324 /* this structure is used in gschem to add rippers when drawing nets */
00325 /* it is never stored in any object, it is only temporary */
00326 struct st_bus_ripper
00327 {
00328   int x[2];
00329   int y[2];
00330 };
00331 
00332 struct st_bounds {
00333   gint min_x;
00334   gint min_y;
00335   gint max_x;
00336   gint max_y;
00337 };
00338 
00344 struct st_transform {
00345   gdouble m[2][3];    /* m[row][column] */
00346 };
00347 
00348 struct st_undo {
00349 
00350   /* one of these is used, depending on if you are doing in-memory */
00351   /* or file based undo state saving */ 
00352   char *filename;
00353   GList *object_list;
00354 
00355   /* either UNDO_ALL or UNDO_VIEWPORT_ONLY */
00356   int type;
00357 
00358   /* viewport information */
00359   int left, top, right, bottom;
00360 
00361   /* up and down the hierarchy */
00362   int up;
00363   /* used to control which pages are viewable when moving around */
00364   int page_control;
00365 
00366   UNDO *prev;
00367   UNDO *next;
00368 };
00369 
00370 
00377 struct st_tile {
00378   GList *objects;
00379 
00380   int top, left, right, bottom;
00381 };
00382 
00383 struct st_page {
00384 
00385   int pid;
00386 
00387   GList *_object_list;
00388   SELECTION *selection_list; /* new selection mechanism */
00389   GList *place_list;
00390   OBJECT *object_lastplace; /* the last found item */
00391 
00392   char *page_filename; 
00393   int CHANGED;          /* changed flag */
00394   /*int zoom_factor; no longer used*/
00395   int left, right, top, bottom;     /* World coord limits */
00396   double coord_aspectratio;     /* Real worldcoords ratio (?) */
00397 
00398   float to_screen_x_constant;
00399   float to_screen_y_constant;
00400 
00401   float to_world_x_constant;
00402   float to_world_y_constant;
00403 
00404   TILE world_tiles[MAX_TILES_X][MAX_TILES_Y];
00405 
00406   /* Undo/Redo Stacks and pointers */   
00407   /* needs to go into page mechanism actually */
00408   UNDO *undo_bottom;    
00409   UNDO *undo_current;
00410   UNDO *undo_tos;   /* Top Of Stack */
00411 
00412   /* up and down the hierarchy */
00413   /* this holds the pid of the parent page */
00414   int up;
00415   /* int down; not needed */
00416 
00417   /* used to control which pages are viewable when moving around */
00418   int page_control;
00419 
00420   /* backup variables */
00421   GTimeVal last_load_or_save_time;
00422   char saved_since_first_loaded;
00423   gint ops_since_last_backup;
00424   gchar do_autosave_backup;
00425 
00426   GList *weak_refs; /* Weak references */
00427 };
00428 
00430 typedef int(*RenderedBoundsFunc)(void *, OBJECT *, int *, int *, int *, int *);
00431 
00433 typedef int(*ChangeNotifyFunc)(void *, OBJECT *);
00434 
00436 typedef void(*NewToplevelFunc)(TOPLEVEL *, void *);
00437 
00439 typedef void(*AttribsChangedFunc)(void *, OBJECT *);
00440 
00442 typedef void(*ConnsChangedFunc)(void *, OBJECT *);
00443 
00445 typedef gboolean(*LoadBackupQueryFunc)(void *, GString *);
00446 
00447 struct st_toplevel {
00448 
00449   /* have to decided on component list stuff */
00450   /* if it should go in here or not */
00451   /* leave outside for now */
00452 
00453   GList *RC_list;                       /* List of RC files which have been read in. */
00454 
00455   char *untitled_name;          /* untitled sch basename */
00456   char *bitmap_directory;       /* path of the bitmaps */
00457 
00458   int init_left, init_right;        /* Starting values for above */
00459   int init_top, init_bottom; 
00460 
00461   int width, height;            /* height, width of window */
00462 
00463   int override_color;           /* used in doing selections */
00464 
00465   int last_ps_color;                    /* used in print code */
00466 
00467   /* page system */
00468   PAGE *page_current;
00469   GedaPageList *pages;
00470 
00471   /* show_hidden_text is used to control which text is hidden in gschem */
00472   int show_hidden_text;
00473 
00474   GList* major_changed_refdes;          /* A list of all refdes's that have */
00475                                         /* major symbol version changes */
00476 
00477   /* backup variables */
00478   int auto_save_interval;
00479   gint auto_save_timeout;
00480 
00481   /* BLOCK SET IN GSCHEM, BUT USED IN LIBGEDA - NEEDS A RETHINK */
00482   int background_color;
00483   int override_net_color;
00484   int override_bus_color;
00485   int override_pin_color;
00486   int pin_style;
00487   int net_style;
00488   int bus_style;
00489   int line_style;
00490   /* END BLOCK - ALTHOUGH THERE ARE MORE CASES! */
00491 
00492   /* controls whether objects are clipped */
00493   int object_clipping; 
00494 
00495   /* either landscape or portrait */
00496   int print_orientation; 
00497 
00498   /* either TRUE or FALSE (color or no color) */
00499   int image_color; 
00500 
00501   /* either TRUE or FALSE (color or no color) */
00502   int print_color; 
00503 
00504   /* color used color ouput for background */ 
00505   int print_color_background;
00506 
00507   /* setpagedevice orientation option enable (TRUE or FALSE) */
00508   int setpagedevice_orientation;
00509 
00510   /* setpagedevice pagesize option enable (TRUE or FALSE) */
00511   int setpagedevice_pagesize;
00512 
00513   /* The name of the prolog file to paste into the Postscript output */
00514   char *postscript_prolog;
00515 
00516   /* controls if the net consolidation code is used */ 
00517   int net_consolidate; 
00518 
00519   /*controls if attribute promotion happens */
00520   int attribute_promotion; 
00521 
00522   /* controls if invisible attribs are promoted */
00523   int promote_invisible; 
00524 
00525   /* controls if invisible attribs are kept and not deleted */
00526   int keep_invisible;   
00527 
00528   /* controls the generation of backup (~) files */
00529   int make_backup_files;
00530 
00531   /* either window or limits */
00532   int print_output_type;
00533 
00534   /* BUTT, ROUND, SQUARE caps */
00535   int print_output_capstyle;        
00536 
00537   /* landscape printing only */
00538   int paper_width, paper_height;
00539 
00540   /* filename of the bus ripper component if set above */
00541   char *bus_ripper_symname;
00542 
00543   /* controls if the whole bounding box is used in the auto whichend code */
00544   int force_boundingbox;
00545 
00546   /* List of attributes to always promote */
00547   GList *always_promote_attributes;
00548 
00549   /* gnetlist specific */
00550   int net_naming_priority;
00551   int hierarchy_traversal;
00552   int hierarchy_uref_mangle;
00553   int hierarchy_netname_mangle;
00554   int hierarchy_netattrib_mangle;
00555   char *hierarchy_uref_separator;
00556   char *hierarchy_netname_separator;
00557   char *hierarchy_netattrib_separator;
00558   int hierarchy_netattrib_order;
00559   int hierarchy_netname_order;
00560   int hierarchy_uref_order;
00561   char *unnamed_netname;
00562   char *unnamed_busname;
00563 
00564   /* Callback function for calculating text bounds */
00565   RenderedBoundsFunc rendered_text_bounds_func;
00566   void *rendered_text_bounds_data;
00567 
00568   /* Callback functions for object change notification */
00569   GList *change_notify_funcs;
00570 
00571   /* Callback functions for object attribute change notification */
00572   GList *attribs_changed_hooks;
00573 
00574   /* Callback functions for object connections change notification */
00575   GList *conns_changed_hooks;
00576 
00577   /* Callback function for deciding whether to load a backup file. */
00578   LoadBackupQueryFunc load_newer_backup_func;
00579   void *load_newer_backup_data;
00580 
00581   GList *weak_refs; /* Weak references */
00582 };
00583 
00584 /* structures below are for gnetlist */
00585 
00586 /* for every component in the object database */
00587 struct st_netlist {
00588 
00589   int nlid;
00590 
00591   char *component_uref;
00592 
00593   OBJECT *object_ptr;
00594 
00595   CPINLIST *cpins;      
00596 
00597   char *hierarchy_tag;
00598   int composite_component;
00599 
00600   NETLIST *prev;
00601   NETLIST *next;
00602 };
00603 
00604 
00605 /* for every pin on a component */
00606 struct st_cpinlist {
00607   int plid;
00608   int type;                             /* PIN_TYPE_NET or PIN_TYPE_BUS */
00609 
00610   char *pin_number;
00611   char *net_name;           /* this is resolved at very end */
00612   char *pin_label;
00613 
00614   NET *nets;
00615 
00616   CPINLIST *prev;
00617   CPINLIST *next;
00618 };
00619 
00620 /* the net run connected to a pin */
00621 struct st_net {
00622 
00623   int nid;
00624 
00625   int net_name_has_priority;
00626   char *net_name;
00627   char *pin_label;
00628 
00629   char *connected_to; /* new to replace above */
00630 
00631   NET *prev;
00632   NET *next;
00633 };
00634 
00635 /* By Jamil Khatib */
00636 /* typedef struct st_chkerrs CHKERRS; */
00637 
00638 /* Schem check struct */
00639 struct st_schcheck {
00640   int no_errors;                /* No of Errors */
00641   int no_warnings;              /* No of Warinings */
00642 
00643   CHKERRS * sheet_errs;
00644 
00645   CHKERRS *float_nets;           /* Header of the list of floating nets */
00646   int net_errs;                 /* No of floating nets */
00647 
00648   OBJECT *float_pins;           /* Header of List of floating pins*/
00649   int pin_errs;                 /* No of floating pins */
00650 
00651   int net_names;                /* No of mismatched net names */
00652 };
00653 
00654 
00655 struct st_chkerrs{
00656 
00657   OBJECT * err_obj;
00658   CHKERRS * next;
00659 
00660 };
00661 
00662 
00663 
00664 struct st_color {
00665   guint8 r, g, b, a;
00666   gboolean enabled;
00667 };
00668 
00669 
00670 struct st_attrib_smob {
00671   TOPLEVEL *world;   /* We need this when updating schematic */
00672   OBJECT   *attribute;
00673 };
00674 
00675 struct st_object_smob {
00676   TOPLEVEL *world;   /* We need this when updating schematic */
00677   OBJECT   *object;
00678 };
00679 
00680 struct st_page_smob {
00681   TOPLEVEL *world;   /* We need this when updating schematic */
00682   PAGE   *page;
00683 };
00684 
00685 /* used by the rc loading mechanisms */
00686 typedef struct {
00687   int   m_val;
00688   char *m_str;
00689 } vstbl_entry;
00690 
00691 /* Used by g_rc_parse_handler() */
00692 typedef void (*ConfigParseErrorFunc)(GError **, void *);
00693 
00694 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines