gerber.c: Tidy up use_gc() routine to avoid a static anlysis warning
[geda-pcb/pcjc2.git] / src / global.h
blob9f0390bf3f8a64ca3a121bf9d535c57784f744e7
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996, 2004 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
25 * RCS: $Id$
27 /* 15 Oct 2008 Ineiev: add different crosshair shapes */
29 /* definition of types
32 /* Change History:
33 * 10/11/96 11:37 AJF Added support for a Text() driver function.
34 * This was done out of a pressing need to force text to be printed on the
35 * silkscreen layer. Perhaps the design is not the best.
38 #ifndef PCB_GLOBAL_H
39 #define PCB_GLOBAL_H
41 #ifdef HAVE_CONFIG_H
42 #include "config.h"
43 #endif
45 #include "const.h"
46 #include "macro.h"
48 #ifdef HAVE_STDINT_H
49 #include <stdint.h>
50 #endif
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <string.h>
54 #include <strings.h>
55 #include <stdarg.h>
56 #include <math.h>
57 #include <ctype.h>
58 #include <sys/types.h>
59 #include <stdbool.h>
60 #include <glib.h>
62 /* Forward declarations for structures the HIDs need. */
63 typedef struct BoxType BoxType, *BoxTypePtr;
64 typedef struct polygon_st PolygonType, *PolygonTypePtr;
65 typedef struct pad_st PadType, *PadTypePtr;
66 typedef struct pin_st PinType, *PinTypePtr, **PinTypeHandle;
67 typedef struct drc_violation_st DrcViolationType, *DrcViolationTypePtr;
68 typedef struct rtree rtree_t;
69 typedef struct AttributeListType AttributeListType, *AttributeListTypePtr;
71 typedef struct unit Unit;
72 typedef struct increments Increments;
74 typedef COORD_TYPE Coord; /* pcb base unit */
75 typedef double Angle; /* degrees */
77 #include "hid.h"
78 #include "polyarea.h"
80 /* Internationalization support. */
81 #ifdef ENABLE_NLS
82 # include <libintl.h>
83 # define _(S) gettext(S)
84 # if defined(gettext_noop)
85 # define N_(S) gettext_noop(S)
86 # else
87 # define N_(S) (S)
88 # endif
89 #else
90 # define _(S) (S)
91 # define N_(S) (S)
92 # define textdomain(S) (S)
93 # define gettext(S) (S)
94 # define dgettext(D, S) (S)
95 # define dcgettext(D, S, T) (S)
96 # define bindtextdomain(D, Dir) (D)
97 #endif /* ENABLE_NLS */
99 /* This is used by the lexer/parser */
100 typedef struct {
101 int ival;
102 Coord bval;
103 double dval;
104 char has_units;
105 } PLMeasure;
107 #ifndef XtSpecificationRelease
108 typedef unsigned int Cardinal;
109 /*typedef unsigned int Pixel;*/
110 typedef char *String;
111 typedef short Position;
112 typedef short Dimension;
113 #endif
114 typedef unsigned char BYTE;
116 /* Nobody should know about the internals of this except the macros in
117 macros.h that access it. This structure must be simple-assignable
118 for now. */
119 typedef struct
121 unsigned long f; /* generic flags */
122 unsigned char t[(MAX_LAYER + 1) / 2]; /* thermals */
123 } FlagType, *FlagTypePtr;
125 #ifndef __GNUC__
126 #define __FUNCTION1(a,b) a ":" #b
127 #define __FUNCTION2(a,b) __FUNCTION1(a,b)
128 #define __FUNCTION__ __FUNCTION2(__FILE__,__LINE__)
129 #endif
132 /* ---------------------------------------------------------------------------
133 * Macros to annotate branch-prediction information.
134 * Taken from GLib 2.16.3 (LGPL 2).G_ / g_ prefixes have
135 * been removed to avoid namespace clashes.
138 /* The LIKELY and UNLIKELY macros let the programmer give hints to
139 * the compiler about the expected result of an expression. Some compilers
140 * can use this information for optimizations.
142 * The PCB_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
143 * putting assignments inside the test.
145 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
146 #define PCB_BOOLEAN_EXPR(expr) \
147 __extension__ ({ \
148 int _boolean_var_; \
149 if (expr) \
150 _boolean_var_ = 1; \
151 else \
152 _boolean_var_ = 0; \
153 _boolean_var_; \
155 #define LIKELY(expr) (__builtin_expect (PCB_BOOLEAN_EXPR(expr), 1))
156 #define UNLIKELY(expr) (__builtin_expect (PCB_BOOLEAN_EXPR(expr), 0))
157 #else
158 #define LIKELY(expr) (expr)
159 #define UNLIKELY(expr) (expr)
160 #endif
163 /* ---------------------------------------------------------------------------
164 * Do not change the following definitions even if they're not very
165 * nice. It allows us to have functions act on these "base types" and
166 * not need to know what kind of actual object they're working on.
169 /* Any object that uses the "object flags" defined in const.h, or
170 exists as an object on the pcb, MUST be defined using this as the
171 first fields, either directly or through ANYLINEFIELDS. */
172 #define ANYOBJECTFIELDS \
173 BoxType BoundingBox; \
174 long int ID; \
175 FlagType Flags; \
176 // struct LibraryEntryType *net
178 /* Lines, pads, and rats all use this so they can be cross-cast. */
179 #define ANYLINEFIELDS \
180 ANYOBJECTFIELDS; \
181 Coord Thickness, \
182 Clearance; \
183 PointType Point1, \
184 Point2
186 /* ---------------------------------------------------------------------------
187 * some useful values of our widgets
189 typedef struct /* holds information about output window */
191 hidGC bgGC, /* background and foreground; */
192 fgGC, /* changed from some routines */
193 pmGC; /* depth 1 pixmap GC to store clip */
195 OutputType, *OutputTypePtr;
197 /* ----------------------------------------------------------------------
198 * layer group. A layer group identifies layers which are always switched
199 * on/off together.
201 typedef struct
203 Cardinal Number[MAX_LAYER], /* number of entries per groups */
204 Entries[MAX_LAYER][MAX_LAYER + 2];
205 } LayerGroupType, *LayerGroupTypePtr;
207 struct BoxType /* a bounding box */
209 Coord X1, Y1; /* upper left */
210 Coord X2, Y2; /* and lower right corner */
213 typedef struct
215 Coord x, y;
216 Coord width, height;
217 } RectangleType, *RectangleTypePtr;
219 typedef struct
221 char *name;
222 char *value;
223 } AttributeType, *AttributeTypePtr;
225 struct AttributeListType
227 int Number, Max;
228 AttributeType *List;
231 /* ---------------------------------------------------------------------------
232 * the basic object types supported by PCB
235 /* All on-pcb objects (elements, lines, pads, vias, rats, etc) are
236 based on this. */
237 typedef struct {
238 ANYOBJECTFIELDS;
239 } AnyObjectType, *AnyObjectTypePtr;
241 typedef struct /* a line/polygon point */
243 Coord X, Y, X2, Y2; /* so Point type can be cast as BoxType */
244 long int ID;
245 } PointType, *PointTypePtr;
247 /* Lines, rats, pads, etc. */
248 typedef struct {
249 ANYLINEFIELDS;
250 } AnyLineObjectType, *AnyLineObjectTypePtr;
252 typedef struct /* holds information about one line */
254 ANYLINEFIELDS;
255 char *Number;
256 } LineType, *LineTypePtr;
258 typedef struct
260 ANYOBJECTFIELDS;
261 int Scale; /* text scaling in percent */
262 Coord X, Y; /* origin */
263 BYTE Direction;
264 char *TextString; /* string */
265 void *Element;
266 } TextType, *TextTypePtr;
268 struct polygon_st /* holds information about a polygon */
270 ANYOBJECTFIELDS;
271 Cardinal PointN, /* number of points in polygon */
272 PointMax; /* max number from malloc() */
273 POLYAREA *Clipped; /* the clipped region of this polygon */
274 PLINE *NoHoles; /* the polygon broken into hole-less regions */
275 int NoHolesValid; /* Is the NoHoles polygon up to date? */
276 PointTypePtr Points; /* data */
277 Cardinal *HoleIndex; /* Index of hole data within the Points array */
278 Cardinal HoleIndexN; /* number of holes in polygon */
279 Cardinal HoleIndexMax; /* max number from malloc() */
283 typedef struct /* holds information about arcs */
285 ANYOBJECTFIELDS;
286 Coord Thickness, Clearance;
287 PointType Point1;
288 PointType Point2;
289 Coord Width, Height, /* length of axis */
290 X, Y; /* center coordinates */
291 Angle StartAngle, Delta; /* the two limiting angles in degrees */
292 } ArcType, *ArcTypePtr;
294 struct rtree
296 struct rtree_node *root;
297 int size; /* number of entries in tree */
300 typedef struct /* holds information about one layer */
302 char *Name; /* layer name */
303 Cardinal LineN, /* number of lines */
304 TextN, /* labels */
305 PolygonN, /* polygons */
306 ArcN; /* and arcs */
307 GList *Line;
308 GList *Text;
309 GList *Polygon;
310 GList *Arc;
311 rtree_t *line_tree, *text_tree, *polygon_tree, *arc_tree;
312 bool On; /* visible flag */
313 char *Color, /* color */
314 *SelectedColor;
315 AttributeListType Attributes;
316 int no_drc; /* whether to ignore the layer when checking the design rules */
318 LayerType, *LayerTypePtr;
320 typedef struct /* a rat-line */
322 ANYLINEFIELDS;
323 Cardinal group1, group2; /* the layer group each point is on */
324 } RatType, *RatTypePtr;
326 struct pad_st /* a SMD pad */
328 ANYLINEFIELDS;
329 Coord Mask;
330 char *Name, *Number; /* 'Line' */
331 void *Element;
332 void *Spare;
335 struct pin_st
337 ANYOBJECTFIELDS;
338 Coord Thickness, Clearance, Mask, DrillingHole;
339 Coord X, Y; /* center and diameter */
340 char *Name, *Number;
341 void *Element;
342 void *Spare;
345 /* This is the extents of a Pin or Via, depending on whether it's a
346 hole or not. */
347 #define PIN_SIZE(pinptr) (TEST_FLAG(HOLEFLAG, (pinptr)) \
348 ? (pinptr)->DrillingHole \
349 : (pinptr)->Thickness)
351 typedef struct
353 ANYOBJECTFIELDS;
354 TextType Name[MAX_ELEMENTNAMES]; /* the elements names; */
355 /* description text */
356 /* name on PCB second, */
357 /* value third */
358 /* see macro.h */
359 Coord MarkX, MarkY; /* position mark */
360 Cardinal PinN; /* number of pins */
361 Cardinal PadN; /* number of pads */
362 Cardinal LineN; /* number of lines */
363 Cardinal ArcN; /* number of arcs */
364 GList *Pin;
365 GList *Pad;
366 GList *Line;
367 GList *Arc;
368 BoxType VBox;
369 AttributeListType Attributes;
370 } ElementType, *ElementTypePtr, **ElementTypeHandle;
372 /* ---------------------------------------------------------------------------
373 * symbol and font related stuff
375 typedef struct /* a single symbol */
377 LineTypePtr Line;
378 bool Valid;
379 Cardinal LineN, /* number of lines */
380 LineMax;
381 Coord Width, Height, /* size of cell */
382 Delta; /* distance to next symbol */
383 } SymbolType, *SymbolTypePtr;
385 typedef struct /* complete set of symbols */
387 Coord MaxHeight, /* maximum cell width and height */
388 MaxWidth;
389 BoxType DefaultSymbol; /* the default symbol is a filled box */
390 SymbolType Symbol[MAX_FONTPOSITION + 1];
391 bool Valid;
392 } FontType, *FontTypePtr;
394 typedef struct /* holds all objects */
396 Cardinal ViaN, /* number of vias */
397 ElementN, /* and elements */
398 RatN; /* and rat-lines */
399 int LayerN; /* number of layers in this board */
400 GList *Via;
401 GList *Element;
402 GList *Rat;
403 rtree_t *via_tree, *element_tree, *pin_tree, *pad_tree, *name_tree[3], /* for element names */
404 *rat_tree;
405 struct PCBType *pcb;
406 LayerType Layer[MAX_LAYER + 2]; /* add 2 silkscreen layers */
407 } DataType, *DataTypePtr;
409 typedef struct /* holds drill information */
411 Coord DrillSize; /* this drill's diameter */
412 Cardinal ElementN, /* the number of elements using this drill size */
413 ElementMax, /* max number of elements from malloc() */
414 PinCount, /* number of pins drilled this size */
415 ViaCount, /* number of vias drilled this size */
416 UnplatedCount, /* number of these holes that are unplated */
417 PinN, /* number of drill coordinates in the list */
418 PinMax; /* max number of coordinates from malloc() */
419 PinTypePtr *Pin; /* coordinates to drill */
420 ElementTypePtr *Element; /* a pointer to an array of element pointers */
421 } DrillType, *DrillTypePtr;
423 typedef struct /* holds a range of Drill Infos */
425 Cardinal DrillN, /* number of drill sizes */
426 DrillMax; /* max number from malloc() */
427 DrillTypePtr Drill; /* plated holes */
428 } DrillInfoType, *DrillInfoTypePtr;
430 typedef struct
432 Coord Thick, /* line thickness */
433 Diameter, /* via diameter */
434 Hole, /* via drill hole */
435 Keepaway; /* min. separation from other nets */
436 char *Name;
437 int index;
438 } RouteStyleType, *RouteStyleTypePtr;
440 /* ---------------------------------------------------------------------------
441 * structure used by library routines
443 typedef struct
445 char *ListEntry; /* the string for the selection box */
446 char *AllocatedMemory, /* pointer to allocated memory; all others */
447 /* point to parts of the string */
448 *Template, /* m4 template name */
449 *Package, /* package */
450 *Value, /* the value field */
451 *Description; /* some descritional text */
452 } LibraryEntryType, *LibraryEntryTypePtr;
453 //typedef LibraryEntryType *LibraryEntryTypePtr;
455 /* If the internal flag is set, the only field that is valid is Name,
456 and the struct is allocated with malloc instead of
457 CreateLibraryEntry. These "internal" entries are used for
458 electrical paths that aren't yet assigned to a real net. */
460 typedef struct
462 char *Name, /* name of the menu entry */
463 *directory, /* Directory name library elements are from */
464 *Style; /* routing style */
465 Cardinal EntryN, /* number of objects */
466 EntryMax; /* number of reserved memory locations */
467 LibraryEntryTypePtr Entry; /* the entries */
468 char flag; /* used by the netlist window to enable/disable nets */
469 char internal; /* if set, this is an internal-only entry, not
470 part of the global netlist. */
471 } LibraryMenuType, *LibraryMenuTypePtr;
473 typedef struct
475 Cardinal MenuN; /* number of objects */
476 Cardinal MenuMax; /* number of reserved memory locations */
477 LibraryMenuTypePtr Menu; /* the entries */
478 } LibraryType, *LibraryTypePtr;
481 /* The PCBType struct holds information about board layout most of which is
482 | saved with the layout. A new PCB layout struct is first initialized
483 | with values from the user configurable Settings struct and then reset
484 | to the saved layout values when a layout is loaded.
485 | This struct is also used for the remove list and for buffer handling
487 typedef struct PCBType
489 long ID; /* see macro.h */
490 FlagType Flags;
491 char *Name, /* name of board */
492 *Filename, /* name of file (from load) */
493 *PrintFilename, /* from print dialog */
494 *Netlistname, /* name of netlist file */
495 ThermStyle; /* type of thermal to place with thermal tool */
496 bool Changed, /* layout has been changed */
497 ViaOn, /* visibility flags */
498 ElementOn, RatOn, InvisibleObjectsOn, PinOn, SilkActive, /* active layer is actually silk */
499 RatDraw; /* we're drawing rats */
500 char *ViaColor, /* some colors */
501 *ViaSelectedColor,
502 *PinColor,
503 *PinSelectedColor,
504 *PinNameColor,
505 *ElementColor,
506 *RatColor,
507 *InvisibleObjectsColor,
508 *InvisibleMarkColor,
509 *ElementSelectedColor,
510 *RatSelectedColor, *ConnectedColor, *WarnColor, *MaskColor;
511 long CursorX, /* cursor position as saved with layout */
512 CursorY, Clipping;
513 Coord Bloat, /* drc sizes saved with layout */
514 Shrink, minWid, minSlk, minDrill, minRing;
515 Coord GridOffsetX, /* as saved with layout */
516 GridOffsetY, MaxWidth, /* allowed size */
517 MaxHeight;
519 Coord Grid; /* used grid with offsets */
520 double Zoom, /* zoom factor */
521 IsleArea, /* minimum poly island to retain */
522 ThermScale; /* scale factor used with thermals */
523 FontType Font;
524 LayerGroupType LayerGroups;
525 RouteStyleType RouteStyle[NUM_STYLES];
526 LibraryType NetlistLib;
527 AttributeListType Attributes;
528 DataTypePtr Data; /* entire database */
530 bool is_footprint; /* If set, the user has loaded a footprint, not a pcb. */
532 PCBType, *PCBTypePtr;
534 typedef struct /* information about the paste buffer */
536 Coord X, Y; /* offset */
537 BoxType BoundingBox;
538 DataTypePtr Data; /* data; not all members of PCBType */
539 /* are used */
540 } BufferType, *BufferTypePtr;
542 /* ---------------------------------------------------------------------------
543 * some types for cursor drawing, setting of block and lines
544 * as well as for merging of elements
546 typedef struct /* rubberband lines for element moves */
548 LayerTypePtr Layer; /* layer that holds the line */
549 LineTypePtr Line; /* the line itself */
550 PointTypePtr MovedPoint; /* and finally the point */
551 } RubberbandType, *RubberbandTypePtr;
553 typedef struct /* current marked line */
555 PointType Point1, /* start- and end-position */
556 Point2;
557 long int State;
558 bool draw;
559 } AttachedLineType, *AttachedLineTypePtr;
561 typedef struct /* currently marked block */
563 PointType Point1, /* start- and end-position */
564 Point2;
565 long int State;
566 bool otherway;
567 } AttachedBoxType, *AttachedBoxTypePtr;
569 typedef struct /* currently attached object */
571 Coord X, Y; /* saved position when MOVE_MODE */
572 BoxType BoundingBox;
573 long int Type, /* object type */
574 State;
575 void *Ptr1, /* three pointers to data, see */
576 *Ptr2, /* search.c */
577 *Ptr3;
578 Cardinal RubberbandN, /* number of lines in array */
579 RubberbandMax;
580 RubberbandTypePtr Rubberband;
581 } AttachedObjectType, *AttachedObjectTypePtr;
583 enum crosshair_shape
585 Basic_Crosshair_Shape = 0, /* 4-ray */
586 Union_Jack_Crosshair_Shape, /* 8-ray */
587 Dozen_Crosshair_Shape, /* 12-ray */
588 Crosshair_Shapes_Number
591 typedef struct /* holds cursor information */
593 hidGC GC, /* GC for cursor drawing */
594 AttachGC; /* and for displaying buffer contents */
595 Coord X, Y, /* position in PCB coordinates */
596 MinX, MinY, /* lowest and highest coordinates */
597 MaxX, MaxY;
598 AttachedLineType AttachedLine; /* data of new lines... */
599 AttachedBoxType AttachedBox;
600 PolygonType AttachedPolygon;
601 AttachedObjectType AttachedObject; /* data of attached objects */
602 enum crosshair_shape shape; /* shape of crosshair */
603 } CrosshairType, *CrosshairTypePtr;
605 typedef struct
607 bool status;
608 Coord X, Y;
609 } MarkType, *MarkTypePtr;
611 /* ---------------------------------------------------------------------------
612 * our resources
613 * most of them are used as default when a new design is started
615 typedef struct /* some resources... */
617 const Unit *grid_unit;
618 Increments *increments;
620 int verbose;
622 char *BlackColor, *WhiteColor, *BackgroundColor, /* background and cursor color ... */
623 *CrosshairColor, /* different object colors */
624 *CrossColor,
625 *ViaColor,
626 *ViaSelectedColor,
627 *PinColor,
628 *PinSelectedColor,
629 *PinNameColor,
630 *ElementColor,
631 *RatColor,
632 *InvisibleObjectsColor,
633 *InvisibleMarkColor,
634 *ElementSelectedColor,
635 *RatSelectedColor,
636 *ConnectedColor,
637 *OffLimitColor,
638 *GridColor,
639 *LayerColor[MAX_LAYER],
640 *LayerSelectedColor[MAX_LAYER], *WarnColor, *MaskColor;
641 Coord ViaThickness, /* some preset values */
642 ViaDrillingHole, LineThickness, RatThickness, Keepaway, /* default size of a new layout */
643 MaxWidth, MaxHeight,
644 AlignmentDistance, Bloat, /* default drc sizes */
645 Shrink, minWid, minSlk, minDrill, minRing;
646 int TextScale; /* text scaling in % */
647 Coord Grid; /* grid in pcb-units */
648 double Zoom,
649 IsleArea, /* polygon min area */
650 PinoutZoom; /* same for pinout windows */
651 int PinoutNameLength, /* max displayed length of a pinname */
652 Volume, /* the speakers volume -100..100 */
653 CharPerLine, /* width of an output line in characters */
654 Mode, /* currently active mode */
655 BufferNumber; /* number of the current buffer */
656 int BackupInterval; /* time between two backups in seconds */
657 char *DefaultLayerName[MAX_LAYER], *FontCommand, /* commands for file loading... */
658 *FileCommand, *ElementCommand, *PrintFile, *LibraryCommandDir, *LibraryCommand, *LibraryContentsCommand, *LibraryTree, /* path to library tree */
659 *SaveCommand, *LibraryFilename, *FontFile, /* name of default font file */
660 *Groups, /* string with layergroups */
661 *Routes, /* string with route styles */
662 *FilePath, *RatPath, *RatCommand, *FontPath, *PinoutFont, *ElementPath, *LibraryPath, *Size, /* geometry string for size */
663 *BackgroundImage, /* PPM file for board background */
664 *ScriptFilename, /* PCB Actions script to execute on startup */
665 *ActionString, /* PCB Actions string to execute on startup */
666 *FabAuthor, /* Full name of author for FAB drawings */
667 *GnetlistProgram, /* gnetlist program name */
668 *MakeProgram, /* make program name */
669 *InitialLayerStack; /* If set, the initial layer stack is set to this */
670 Coord PinoutOffsetX, /* offset of origin */
671 PinoutOffsetY;
672 Coord PinoutTextOffsetX, /* offset of text from pin center */
673 PinoutTextOffsetY;
674 RouteStyleType RouteStyle[NUM_STYLES]; /* default routing styles */
675 LayerGroupType LayerGroups; /* default layer groups */
676 bool ClearLine, FullPoly,
677 UniqueNames, /* force unique names */
678 SnapPin, /* snap to pins and pads */
679 ShowSolderSide, /* mirror output */
680 SaveLastCommand, /* save the last command entered by user */
681 SaveInTMP, /* always save data in /tmp */
682 DrawGrid, /* draw grid points */
683 RatWarn, /* rats nest has set warnings */
684 StipplePolygons, /* draw polygons with stipple */
685 AllDirectionLines, /* enable lines to all directions */
686 RubberBandMode, /* move, rotate use rubberband connections */
687 SwapStartDirection, /* change starting direction after each click */
688 ShowDRC, /* show drc region on crosshair */
689 AutoDRC, /* */
690 ShowNumber, /* pinout shows number */
691 OrthogonalMoves, /* */
692 ResetAfterElement, /* reset connections after each element */
693 liveRouting, /* autorouter shows tracks in progress */
694 RingBellWhenFinished, /* flag if a signal should be */
695 /* produced when searching of */
696 /* connections is done */
697 AutoPlace; /* flag which says we should force placement of the
698 windows on startup */
700 SettingType, *SettingTypePtr;
702 /* ----------------------------------------------------------------------
703 * pointer to low-level copy, move and rotate functions
705 typedef struct
707 void *(*Line) (LayerTypePtr, LineTypePtr);
708 void *(*Text) (LayerTypePtr, TextTypePtr);
709 void *(*Polygon) (LayerTypePtr, PolygonTypePtr);
710 void *(*Via) (PinTypePtr);
711 void *(*Element) (ElementTypePtr);
712 void *(*ElementName) (ElementTypePtr);
713 void *(*Pin) (ElementTypePtr, PinTypePtr);
714 void *(*Pad) (ElementTypePtr, PadTypePtr);
715 void *(*LinePoint) (LayerTypePtr, LineTypePtr, PointTypePtr);
716 void *(*Point) (LayerTypePtr, PolygonTypePtr, PointTypePtr);
717 void *(*Arc) (LayerTypePtr, ArcTypePtr);
718 void *(*Rat) (RatTypePtr);
719 } ObjectFunctionType, *ObjectFunctionTypePtr;
721 /* ---------------------------------------------------------------------------
722 * structure used by device drivers
725 typedef struct /* holds a connection */
727 Coord X, Y; /* coordinate of connection */
728 long int type; /* type of object in ptr1 - 3 */
729 void *ptr1, *ptr2; /* the object of the connection */
730 Cardinal group; /* the layer group of the connection */
731 LibraryMenuType *menu; /* the netmenu this *SHOULD* belong too */
732 } ConnectionType, *ConnectionTypePtr;
734 typedef struct /* holds a net of connections */
736 Cardinal ConnectionN, /* the number of connections contained */
737 ConnectionMax; /* max connections from malloc */
738 ConnectionTypePtr Connection;
739 RouteStyleTypePtr Style;
740 } NetType, *NetTypePtr;
742 typedef struct /* holds a list of nets */
744 Cardinal NetN, /* the number of subnets contained */
745 NetMax; /* max subnets from malloc */
746 NetTypePtr Net;
747 } NetListType, *NetListTypePtr;
749 typedef struct /* holds a list of net lists */
751 Cardinal NetListN, /* the number of net lists contained */
752 NetListMax; /* max net lists from malloc */
753 NetListTypePtr NetList;
754 } NetListListType, *NetListListTypePtr;
756 typedef struct /* holds a generic list of pointers */
758 Cardinal PtrN, /* the number of pointers contained */
759 PtrMax; /* max subnets from malloc */
760 void **Ptr;
761 } PointerListType, *PointerListTypePtr;
763 typedef struct
765 Cardinal BoxN, /* the number of boxes contained */
766 BoxMax; /* max boxes from malloc */
767 BoxTypePtr Box;
769 } BoxListType, *BoxListTypePtr;
771 struct drc_violation_st
773 char *title;
774 char *explanation;
775 Coord x, y;
776 Angle angle;
777 int have_measured;
778 Coord measured_value;
779 Coord required_value;
780 int object_count;
781 long int *object_id_list;
782 int *object_type_list;
785 /* ---------------------------------------------------------------------------
786 * define supported types of undo operations
787 * note these must be separate bits now
789 #define UNDO_CHANGENAME 0x0001 /* change of names */
790 #define UNDO_MOVE 0x0002 /* moving objects */
791 #define UNDO_REMOVE 0x0004 /* removing objects */
792 #define UNDO_REMOVE_POINT 0x0008 /* removing polygon/... points */
793 #define UNDO_INSERT_POINT 0x0010 /* inserting polygon/... points */
794 #define UNDO_REMOVE_CONTOUR 0x0020 /* removing a contour from a polygon */
795 #define UNDO_INSERT_CONTOUR 0x0040 /* inserting a contour from a polygon */
796 #define UNDO_ROTATE 0x0080 /* rotations */
797 #define UNDO_CREATE 0x0100 /* creation of objects */
798 #define UNDO_MOVETOLAYER 0x0200 /* moving objects to */
799 #define UNDO_FLAG 0x0400 /* toggling SELECTED flag */
800 #define UNDO_CHANGESIZE 0x0800 /* change size of object */
801 #define UNDO_CHANGE2NDSIZE 0x1000 /* change 2ndSize of object */
802 #define UNDO_MIRROR 0x2000 /* change side of board */
803 #define UNDO_CHANGECLEARSIZE 0x4000 /* change clearance size */
804 #define UNDO_CHANGEMASKSIZE 0x8000 /* change mask size */
805 #define UNDO_CHANGEANGLES 0x10000 /* change arc angles */
806 #define UNDO_LAYERCHANGE 0x20000 /* layer new/delete/move */
807 #define UNDO_CLEAR 0x40000 /* clear/restore to polygons */
808 #define UNDO_NETLISTCHANGE 0x80000 /* netlist change */
811 /* ---------------------------------------------------------------------------
812 * add a macro for wrapping RCS ID's in so that ident will still work
813 * but we won't get as many compiler warnings
816 #ifndef GCC_VERSION
817 #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
818 #endif /* GCC_VERSION */
820 #if GCC_VERSION > 2007
821 #define ATTRIBUTE_UNUSED __attribute__((unused))
822 #else
823 #define ATTRIBUTE_UNUSED
824 #endif
826 #define RCSID(x) static char *rcsid ATTRIBUTE_UNUSED = x
828 /* ---------------------------------------------------------------------------
829 * Macros called by various action routines to show usage or to report
830 * a syntax error and fail
832 #define AUSAGE(x) Message ("Usage:\n%s\n", (x##_syntax))
833 #define AFAIL(x) { Message ("Syntax error. Usage:\n%s\n", (x##_syntax)); return 1; }
835 /* ---------------------------------------------------------------------------
836 * Variables with absolute paths to various directories. These are deduced
837 * at runtime to allow pcb to be relocatable
839 extern char *bindir; /* The dir in which PCB installation was found */
840 extern char *pcblibdir; /* The system M4 fp directory */
841 extern char *pcblibpath; /* The search path for M4 fps */
842 extern char *pcbtreedir; /* The system newlib fp directory */
843 extern char *pcbtreepath; /* The search path for newlib fps */
844 extern char *exec_prefix;
845 extern char *homedir;
847 #endif /* PCB_GLOBAL_H */