find.c: Use SetThing, rather than open-coding assignments to thing_*
[geda-pcb/pcjc2.git] / src / const.h
blob7cbf1944ae1b5286c1aba2749ebb8374e7428c31
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
27 /* global source constants
30 #ifndef PCB_CONST_H
31 #define PCB_CONST_H
33 #include <limits.h>
34 #include <math.h>
36 #include "globalconst.h"
38 /* ---------------------------------------------------------------------------
39 * the layer-numbers of the two additional special layers
40 * 'component' and 'solder'. The offset of MAX_LAYER is not added
42 #define SOLDER_LAYER 0
43 #define COMPONENT_LAYER 1
45 /* ---------------------------------------------------------------------------
46 * misc constants
48 #define MARK_SIZE MIL_TO_COORD(50) /* relative marker size */
49 #define UNDO_WARNING_SIZE (1024*1024) /* warning limit of undo */
50 #define USERMEDIANAME "user defined" /* label of default media */
52 /* ---------------------------------------------------------------------------
53 * some math constants
55 #ifndef M_PI
56 #define M_PI 3.14159265358979323846
57 #endif
58 #ifndef M_SQRT1_2
59 #define M_SQRT1_2 0.707106781 /* 1/sqrt(2) */
60 #endif
61 #define M180 (M_PI/180.0)
62 #define RAD_TO_DEG (180.0/M_PI)
63 #define TAN_22_5_DEGREE_2 0.207106781 /* 0.5*tan(22.5) */
64 #define COS_22_5_DEGREE 0.923879533 /* cos(22.5) */
65 #define TAN_30_DEGREE 0.577350269 /* tan(30) */
66 #define TAN_60_DEGREE 1.732050808 /* tan(60) */
67 #define LN_2_OVER_2 0.346573590
69 /* PCB/physical unit conversions */
70 #define COORD_TO_MIL(n) ((n) / 25400.0)
71 #define MIL_TO_COORD(n) ((n) * 25400.0)
72 #define COORD_TO_MM(n) ((n) / 1000000.0)
73 #define MM_TO_COORD(n) ((n) * 1000000.0)
74 #define COORD_TO_INCH(n) (COORD_TO_MIL(n) / 1000.0)
75 #define INCH_TO_COORD(n) (MIL_TO_COORD(n) * 1000.0)
77 /* These need to be carefully written to avoid overflows, and return
78 a Coord type. */
79 #define SCALE_TEXT(COORD,TEXTSCALE) ((Coord)((COORD) * ((double)(TEXTSCALE) / 100.0)))
80 #define UNSCALE_TEXT(COORD,TEXTSCALE) ((Coord)((COORD) * (100.0 / (double)(TEXTSCALE))))
82 /* ---------------------------------------------------------------------------
83 * modes
85 #define NO_MODE 0 /* no mode selected */
86 #define VIA_MODE 1 /* draw vias */
87 #define LINE_MODE 2 /* draw lines */
88 #define RECTANGLE_MODE 3 /* create rectangles */
89 #define POLYGON_MODE 4 /* draw filled polygons */
90 #define PASTEBUFFER_MODE 5 /* paste objects from buffer */
91 #define TEXT_MODE 6 /* create text objects */
92 #define ROTATE_MODE 102 /* rotate objects */
93 #define REMOVE_MODE 103 /* remove objects */
94 #define MOVE_MODE 104 /* move objects */
95 #define COPY_MODE 105 /* copy objects */
96 #define INSERTPOINT_MODE 106 /* insert point into line/polygon */
97 #define RUBBERBANDMOVE_MODE 107 /* move objects and attached lines */
98 #define THERMAL_MODE 108 /* toggle thermal layer flag */
99 #define ARC_MODE 109 /* draw arcs */
100 #define ARROW_MODE 110 /* selection with arrow mode */
101 #define PAN_MODE 0 /* same as no mode */
102 #define LOCK_MODE 111 /* lock/unlock objects */
103 #define POLYGONHOLE_MODE 112 /* cut holes in filled polygons */
105 /* ---------------------------------------------------------------------------
106 * object flags
109 /* %start-doc pcbfile ~objectflags
110 @node Object Flags
111 @section Object Flags
113 Note that object flags can be given numerically (like @code{0x0147})
114 or symbolically (like @code{"found,showname,square"}. Some numeric
115 values are reused for different object types. The table below lists
116 the numeric value followed by the symbolic name.
118 @table @code
119 @item 0x0001 pin
120 If set, this object is a pin. This flag is for internal use only.
121 @item 0x0002 via
122 Likewise, for vias.
123 @item 0x0004 found
124 If set, this object has been found by @code{FindConnection()}.
125 @item 0x0008 hole
126 For pins and vias, this flag means that the pin or via is a hole
127 without a copper annulus.
128 @item 0x0008 nopaste
129 For pads, set to prevent a solderpaste stencil opening for the
130 pad. Primarily used for pads used as fiducials.
131 @item 0x0010 rat
132 If set for a line, indicates that this line is a rat line instead of a
133 copper trace.
134 @item 0x0010 pininpoly
135 For pins and pads, this flag is used internally to indicate that the
136 pin or pad overlaps a polygon on some layer.
137 @item 0x0010 clearpoly
138 For polygons, this flag means that pins and vias will normally clear
139 these polygons (thus, thermals are required for electrical
140 connection). When clear, polygons will solidly connect to pins and
141 vias.
142 @item 0x0010 hidename
143 For elements, when set the name of the element is hidden.
144 @item 0x0020 showname
145 For elements, when set the names of pins are shown.
146 @item 0x0020 clearline
147 For lines and arcs, the line/arc will clear polygons instead of
148 connecting to them.
149 @item 0x0020 fullpoly
150 For polygons, the full polygon is drawn (i.e. all parts instead of only the biggest one).
151 @item 0x0040 selected
152 Set when the object is selected.
153 @item 0x0080 onsolder
154 For elements and pads, indicates that they are on the solder side.
155 @item 0x0080 auto
156 For lines and vias, indicates that these were created by the
157 autorouter.
158 @item 0x0100 square
159 For pins and pads, indicates a square (vs round) pin/pad.
160 @item 0x0200 rubberend
161 For lines, used internally for rubber band moves.
162 @item 0x0200 warn
163 For pins, vias, and pads, set to indicate a warning.
164 @item 0x0400 usetherm
165 Obsolete, indicates that pins/vias should be drawn with thermal
166 fingers.
167 @item 0x0400
168 Obsolete, old files used this to indicate lines drawn on silk.
169 @item 0x0800 octagon
170 Draw pins and vias as octagons.
171 @item 0x1000 drc
172 Set for objects that fail DRC.
173 @item 0x2000 lock
174 Set for locked objects.
175 @item 0x4000 edge2
176 For pads, indicates that the second point is closer to the edge. For
177 pins, indicates that the pin is closer to a horizontal edge and thus
178 pinout text should be vertical.
179 @item 0x8000 marker
180 Marker used internally to avoid revisiting an object.
181 @item 0x10000 connected
182 If set, this object has been as physically connected by @code{FindConnection()}.
183 @end table
184 %end-doc */
186 #define NOFLAG 0x0000
187 #define PINFLAG 0x0001 /* is a pin */
188 #define VIAFLAG 0x0002 /* is a via */
189 #define FOUNDFLAG 0x0004 /* used by 'FindConnection()' */
190 #define HOLEFLAG 0x0008 /* pin or via is only a hole */
191 #define NOPASTEFLAG 0x0008 /* pad should not receive
192 solderpaste. This is to
193 support fiducials */
194 #define RATFLAG 0x0010 /* indicates line is a rat line */
195 #define PININPOLYFLAG 0x0010 /* pin found inside poly - same as */
196 /* rat line since not used on lines */
197 #define CLEARPOLYFLAG 0x0010 /* pins/vias clear these polygons */
198 #define HIDENAMEFLAG 0x0010 /* hide the element name */
199 #define DISPLAYNAMEFLAG 0x0020 /* display the names of pins/pads */
200 /* of an element */
201 #define CLEARLINEFLAG 0x0020 /* line doesn't touch polygons */
202 #define FULLPOLYFLAG 0x0020 /* full polygon is drawn (i.e. all parts instead of only the biggest one) */
203 #define SELECTEDFLAG 0x0040 /* object has been selected */
204 #define ONSOLDERFLAG 0x0080 /* element is on bottom side */
205 #define AUTOFLAG 0x0080 /* line/via created by auto-router */
206 #define SQUAREFLAG 0x0100 /* pin is square, not round */
207 #define RUBBERENDFLAG 0x0200 /* indicates one end already rubber */
208 /* banding same as warn flag */
209 /* since pins/pads won't use it */
210 #define WARNFLAG 0x0200 /* Warning for pin/via/pad */
211 #define USETHERMALFLAG 0x0400 /* draw pin, via with thermal fingers */
212 #define ONSILKFLAG 0x0400 /* old files use this to indicate silk */
213 #define OCTAGONFLAG 0x0800 /* draw pin/via as octagon instead of round */
214 #define DRCFLAG 0x1000 /* flag like FOUND flag for DRC checking */
215 #define LOCKFLAG 0x2000 /* object locked in place */
216 #define EDGE2FLAG 0x4000 /* Padr.Point2 is closer to outside edge */
217 /* also pinout text for pins is vertical */
218 #define VISITFLAG 0x8000 /* marker to avoid re-visiting an object */
219 #define CONNECTEDFLAG 0x10000 /* flag like FOUND flag, but used to identify physically connected objects (not rats) */
222 #define NOCOPY_FLAGS (FOUNDFLAG | CONNECTEDFLAG)
224 /* ---------------------------------------------------------------------------
225 * PCB flags
228 /* %start-doc pcbfile ~pcbflags
229 @node PCBFlags
230 @section PCBFlags
231 @table @code
232 @item 0x00001
233 Pinout displays pin numbers instead of pin names.
234 @item 0x00002
235 Use local reference for moves, by setting the mark at the beginning of
236 each move.
237 @item 0x00004
238 When set, only polygons and their clearances are drawn, to see if
239 polygons have isolated regions.
240 @item 0x00008
241 Display DRC region on crosshair.
242 @item 0x00010
243 Do all move, mirror, rotate with rubberband connections.
244 @item 0x00020
245 Display descriptions of elements, instead of refdes.
246 @item 0x00040
247 Display names of elements, instead of refdes.
248 @item 0x00080
249 Auto-DRC flag. When set, PCB doesn't let you place copper that
250 violates DRC.
251 @item 0x00100
252 Enable 'all-direction' lines.
253 @item 0x00200
254 Switch starting angle after each click.
255 @item 0x00400
256 Force unique names on board.
257 @item 0x00800
258 New lines/arc clear polygons.
259 @item 0x01000
260 Crosshair snaps to pins and pads.
261 @item 0x02000
262 Show the solder mask layer.
263 @item 0x04000
264 Draw with thin lines.
265 @item 0x08000
266 Move items orthogonally.
267 @item 0x10000
268 Draw autoroute paths real-time.
269 @item 0x20000
270 New polygons are full ones.
271 @item 0x40000
272 Names are locked, the mouse cannot select them.
273 @item 0x80000
274 Everything but names are locked, the mouse cannot select anything else.
275 @item 0x100000
276 New polygons are full polygons.
277 @item 0x200000
278 When set, element names are not drawn.
279 @end table
280 %end-doc */
282 #define PCB_FLAGS 0x000fffff /* all used flags */
284 #define SHOWNUMBERFLAG 0x00000001
285 #define LOCALREFFLAG 0x00000002
286 #define CHECKPLANESFLAG 0x00000004
287 #define SHOWDRCFLAG 0x00000008
288 #define RUBBERBANDFLAG 0x00000010
289 #define DESCRIPTIONFLAG 0x00000020
290 #define NAMEONPCBFLAG 0x00000040
291 #define AUTODRCFLAG 0x00000080
292 #define ALLDIRECTIONFLAG 0x00000100
293 #define SWAPSTARTDIRFLAG 0x00000200
294 #define UNIQUENAMEFLAG 0x00000400
295 #define CLEARNEWFLAG 0x00000800
296 #define SNAPPINFLAG 0x00001000
297 #define SHOWMASKFLAG 0x00002000
298 #define THINDRAWFLAG 0x00004000
299 #define ORTHOMOVEFLAG 0x00008000
300 #define LIVEROUTEFLAG 0x00010000
301 #define THINDRAWPOLYFLAG 0x00020000
302 #define LOCKNAMESFLAG 0x00040000
303 #define ONLYNAMESFLAG 0x00080000
304 #define NEWFULLPOLYFLAG 0x00100000
305 #define HIDENAMESFLAG 0x00200000
307 /* ---------------------------------------------------------------------------
308 * object types
310 #define NO_TYPE 0x00000 /* no object */
311 #define VIA_TYPE 0x00001
312 #define ELEMENT_TYPE 0x00002
313 #define LINE_TYPE 0x00004
314 #define POLYGON_TYPE 0x00008
315 #define TEXT_TYPE 0x00010
316 #define RATLINE_TYPE 0x00020
318 #define PIN_TYPE 0x00100 /* objects that are part */
319 #define PAD_TYPE 0x00200 /* 'pin' of SMD element */
320 #define ELEMENTNAME_TYPE 0x00400 /* of others */
321 #define POLYGONPOINT_TYPE 0x00800
322 #define LINEPOINT_TYPE 0x01000
323 #define ELEMENTLINE_TYPE 0x02000
324 #define ARC_TYPE 0x04000
325 #define ELEMENTARC_TYPE 0x08000
327 #define LOCKED_TYPE 0x10000 /* used to tell search to include locked items. */
328 #define NET_TYPE 0x20000 /* used to select whole net. */
329 #define ARCPOINT_TYPE 0x40000
331 #define PIN_TYPES (VIA_TYPE | PIN_TYPE)
332 #define LOCK_TYPES (VIA_TYPE | LINE_TYPE | ARC_TYPE | POLYGON_TYPE | ELEMENT_TYPE \
333 | TEXT_TYPE | ELEMENTNAME_TYPE | LOCKED_TYPE)
335 #define ALL_TYPES (~0) /* all bits set */
337 #endif