4 * \brief Global source constants.
8 * PCB, interactive printed circuit board design
10 * Copyright (C) 1994,1995,1996 Thomas Nau
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Contact addresses for paper mail and Email:
27 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
28 * Thomas.Nau@rz.uni-ulm.de
37 #include "globalconst.h"
39 /* ---------------------------------------------------------------------------
40 * integer codings for the board sides.
49 * The situation is not ideal, because on top of the ordinary layer stack
50 * there are two (both) silk layers. It was a hack to separate these and
51 * probably done to easier iterate through non-silk layers, only. As we have
52 * layer types now, iterating through any kind of distinct layer type has
53 * become simple, see LAYER_TYPE_LOOP() in macro.h.
55 * *** XXX: FIXME HORRIBLE BADNESS ***
57 * Accordingly, the separation of these two silk layers should go away, they
58 * should return to be "normal" layers. One might want to have more than two
59 * silk layers, after all.
61 * *** XXX: FIXME HORRIBLE BADNESS ***
63 * Anyways, here's the current setup:
67 * Outline layer >- in unspecified order
69 * (...additional layers...) / <== max_copper_layer
70 * Bottom silk layer <== max_copper_layer + BOTTOM_SILK_LAYER
71 * Top silk layer <== max_copper_layer + TOP_SILK_LAYER
72 * (...unused layers...)
73 * (last layer - 2) <== MAX_LAYER
75 * (last layer) <== MAX_ALL_LAYER
76 * ( == MAX_LAYER + EXTRA_LAYERS)
78 * With all layers in use (rarely the case), max_copper_layer == MAX_LAYER.
80 * \note Position on the layer stack does not decide wether a layer is on the
81 * top side, on the bottom side or in between. Each layer is part of a
82 * layer group, and this group represents the physical layer, like top,
86 #define EXTRA_LAYERS 4 /* 2x silkscreen, 2x soldermask layers */
88 /* ---------------------------------------------------------------------------
89 * the layer-numbers of the two additional special (silkscreen) layers
90 * 'bottom' and 'top'. The offset of MAX_LAYER is not added
93 #define BOTTOM_SILK_LAYER 0
94 #define TOP_SILK_LAYER 1
95 #define BOTTOM_SOLDERMASK_LAYER 2
96 #define TOP_SOLDERMASK_LAYER 3
98 /* ---------------------------------------------------------------------------
99 * the resulting maximum number of layers, including additional silk layers
101 #define MAX_ALL_LAYER (MAX_LAYER + EXTRA_LAYERS)
103 /* ---------------------------------------------------------------------------
106 #define MARK_SIZE MIL_TO_COORD(50) /*!< relative marker size */
107 #define UNDO_WARNING_SIZE (1024*1024) /*!< warning limit of undo */
108 #define USERMEDIANAME "user defined" /*!< label of default media */
110 /* ---------------------------------------------------------------------------
111 * some math constants
114 #define M_PI 3.14159265358979323846
117 #define M_SQRT1_2 0.707106781 /*!< 1/sqrt(2) */
119 #define M180 (M_PI/180.0)
120 #define RAD_TO_DEG (180.0/M_PI)
121 #define TAN_22_5_DEGREE_2 0.207106781 /*!< 0.5*tan(22.5) */
122 #define COS_22_5_DEGREE 0.923879533 /*!< cos(22.5) */
123 #define TAN_30_DEGREE 0.577350269 /*!< tan(30) */
124 #define TAN_60_DEGREE 1.732050808 /*!< tan(60) */
125 #define LN_2_OVER_2 0.346573590
127 /* PCB/physical unit conversions */
128 #define COORD_TO_MIL(n) ((n) / 25400.0)
129 #define MIL_TO_COORD(n) ((n) * 25400.0)
130 #define COORD_TO_MM(n) ((n) / 1000000.0)
131 #define MM_TO_COORD(n) ((n) * 1000000.0)
132 #define COORD_TO_INCH(n) (COORD_TO_MIL(n) / 1000.0)
133 #define INCH_TO_COORD(n) (MIL_TO_COORD(n) * 1000.0)
135 /* These need to be carefully written to avoid overflows, and return
137 #define SCALE_TEXT(COORD,TEXTSCALE) ((Coord)((COORD) * ((double)(TEXTSCALE) / 100.0)))
138 #define UNSCALE_TEXT(COORD,TEXTSCALE) ((Coord)((COORD) * (100.0 / (double)(TEXTSCALE))))
140 /* ---------------------------------------------------------------------------
143 #define NO_MODE 0 /*!< no mode selected */
144 #define VIA_MODE 1 /*!< draw vias */
145 #define LINE_MODE 2 /*!< draw lines */
146 #define RECTANGLE_MODE 3 /*!< create rectangles */
147 #define POLYGON_MODE 4 /*!< draw filled polygons */
148 #define PASTEBUFFER_MODE 5 /*!< paste objects from buffer */
149 #define TEXT_MODE 6 /*!< create text objects */
150 #define ROTATE_MODE 102 /*!< rotate objects */
151 #define REMOVE_MODE 103 /*!< remove objects */
152 #define MOVE_MODE 104 /*!< move objects */
153 #define COPY_MODE 105 /*!< copy objects */
154 #define INSERTPOINT_MODE 106 /*!< insert point into line/polygon */
155 #define RUBBERBANDMOVE_MODE 107 /*!< move objects and attached lines */
156 #define THERMAL_MODE 108 /*!< toggle thermal layer flag */
157 #define ARC_MODE 109 /*!< draw arcs */
158 #define ARROW_MODE 110 /*!< selection with arrow mode */
159 #define PAN_MODE 0 /*!< same as no mode */
160 #define LOCK_MODE 111 /*!< lock/unlock objects */
161 #define POLYGONHOLE_MODE 112 /*!< cut holes in filled polygons */
163 /* ---------------------------------------------------------------------------
167 /* %start-doc pcbfile ~objectflags
169 @section Object Flags
171 Note that object flags can be given numerically (like @code{0x0147})
172 or symbolically (like @code{"found,showname,square"}. Some numeric
173 values are reused for different object types. The table below lists
174 the numeric value followed by the symbolic name.
178 If set, this object is a pin. This flag is for internal use only.
182 If set, this object has been found by @code{FindConnection()}.
184 For pins and vias, this flag means that the pin or via is a hole
185 without a copper annulus.
187 For pads, set to prevent a solderpaste stencil opening for the
188 pad. Primarily used for pads used as fiducials.
190 If set for a line, indicates that this line is a rat line instead of a
192 @item 0x0010 pininpoly
193 For pins and pads, this flag is used internally to indicate that the
194 pin or pad overlaps a polygon on some layer.
195 @item 0x0010 clearpoly
196 For polygons, this flag means that pins and vias will normally clear
197 these polygons (thus, thermals are required for electrical
198 connection). When clear, polygons will solidly connect to pins and
200 @item 0x0010 hidename
201 For elements, when set the name of the element is hidden.
202 @item 0x0020 showname
203 For elements, when set the names of pins are shown.
204 @item 0x0020 clearline
205 For lines and arcs, the line/arc will clear polygons instead of
207 @item 0x0020 fullpoly
208 For polygons, the full polygon is drawn (i.e. all parts instead of only the biggest one).
209 @item 0x0040 selected
210 Set when the object is selected.
211 @item 0x0080 onsolder
212 For elements and pads, indicates that they are on the solder side.
214 For lines and vias, indicates that these were created by the
217 For pins and pads, indicates a square (vs round) pin/pad.
218 @item 0x0200 rubberend
219 For lines, used internally for rubber band moves.
221 For pins, vias, and pads, set to indicate a warning.
222 @item 0x0400 usetherm
223 Obsolete, indicates that pins/vias should be drawn with thermal
226 Obsolete, old files used this to indicate lines drawn on silk.
228 Draw pins and vias as octagons.
230 Set for objects that fail DRC.
232 Set for locked objects.
234 For pads, indicates that the second point is closer to the edge. For
235 pins, indicates that the pin is closer to a horizontal edge and thus
236 pinout text should be vertical.
238 Marker used internally to avoid revisiting an object.
239 @item 0x10000 connected
240 If set, this object has been as physically connected by @code{FindConnection()}.
244 #define NOFLAG 0x0000
245 #define PINFLAG 0x0001 /*!< is a pin */
246 #define VIAFLAG 0x0002 /*!< is a via */
247 #define FOUNDFLAG 0x0004 /*!< used by 'FindConnection()' */
248 #define HOLEFLAG 0x0008 /*!< pin or via is only a hole */
249 #define NOPASTEFLAG 0x0008 /*!< pad should not receive
250 solderpaste. This is to
252 #define RATFLAG 0x0010 /*!< indicates line is a rat line */
253 #define PININPOLYFLAG 0x0010 /*!< pin found inside poly - same as */
254 /*!< rat line since not used on lines */
255 #define CLEARPOLYFLAG 0x0010 /*!< pins/vias clear these polygons */
256 #define HIDENAMEFLAG 0x0010 /*!< hide the element name */
257 #define DISPLAYNAMEFLAG 0x0020 /*!< display the names of pins/pads
259 #define CLEARLINEFLAG 0x0020 /*!< line doesn't touch polygons */
260 #define FULLPOLYFLAG 0x0020 /*!< full polygon is drawn (i.e. all parts instead of only the biggest one) */
261 #define SELECTEDFLAG 0x0040 /*!< object has been selected */
262 #define ONSOLDERFLAG 0x0080 /*!< element is on bottom side */
263 #define AUTOFLAG 0x0080 /*!< line/via created by auto-router */
264 #define SQUAREFLAG 0x0100 /*!< pin is square, not round */
265 #define RUBBERENDFLAG 0x0200 /*!< indicates one end already rubber
266 banding same as warn flag
267 since pins/pads won't use it */
268 #define WARNFLAG 0x0200 /*!< Warning for pin/via/pad */
269 #define USETHERMALFLAG 0x0400 /*!< draw pin, via with thermal fingers */
270 #define ONSILKFLAG 0x0400 /*!< old files use this to indicate silk */
271 #define OCTAGONFLAG 0x0800 /*!< draw pin/via as octagon instead of round */
272 #define DRCFLAG 0x1000 /*!< flag like FOUND flag for DRC checking */
273 #define LOCKFLAG 0x2000 /*!< object locked in place */
274 #define EDGE2FLAG 0x4000 /*!< Padr.Point2 is closer to outside edge
275 also pinout text for pins is vertical */
276 #define VISITFLAG 0x8000 /*!< marker to avoid re-visiting an object */
277 #define CONNECTEDFLAG 0x10000 /*!< flag like FOUND flag, but used to identify physically connected objects (not rats) */
280 #define NOCOPY_FLAGS (FOUNDFLAG | CONNECTEDFLAG)
282 /* ---------------------------------------------------------------------------
286 /* %start-doc pcbfile ~pcbflags
291 Pinout displays pin numbers instead of pin names.
293 Use local reference for moves, by setting the mark at the beginning of
296 When set, only polygons and their clearances are drawn, to see if
297 polygons have isolated regions.
299 Display DRC region on crosshair.
301 Do all move, mirror, rotate with rubberband connections.
303 Display descriptions of elements, instead of refdes.
305 Display names of elements, instead of refdes.
307 Auto-DRC flag. When set, PCB doesn't let you place copper that
310 Enable 'all-direction' lines.
312 Switch starting angle after each click.
314 Force unique names on board.
316 New lines/arc clear polygons.
318 Crosshair snaps to pins and pads.
320 Show the solder mask layer.
322 Draw with thin lines.
324 Move items orthogonally.
326 Draw autoroute paths real-time.
328 New polygons are full ones.
330 Names are locked, the mouse cannot select them.
332 Everything but names are locked, the mouse cannot select anything else.
334 New polygons are full polygons.
336 When set, element names are not drawn.
340 #define PCB_FLAGS 0x000fffff /* all used flags */
342 #define SHOWNUMBERFLAG 0x00000001
343 #define LOCALREFFLAG 0x00000002
344 #define CHECKPLANESFLAG 0x00000004
345 #define SHOWDRCFLAG 0x00000008
346 #define RUBBERBANDFLAG 0x00000010
347 #define DESCRIPTIONFLAG 0x00000020
348 #define NAMEONPCBFLAG 0x00000040
349 #define AUTODRCFLAG 0x00000080
350 #define ALLDIRECTIONFLAG 0x00000100
351 #define SWAPSTARTDIRFLAG 0x00000200
352 #define UNIQUENAMEFLAG 0x00000400
353 #define CLEARNEWFLAG 0x00000800
354 #define SNAPPINFLAG 0x00001000
355 #define SHOWMASKFLAG 0x00002000
356 #define THINDRAWFLAG 0x00004000
357 #define ORTHOMOVEFLAG 0x00008000
358 #define LIVEROUTEFLAG 0x00010000
359 #define THINDRAWPOLYFLAG 0x00020000
360 #define LOCKNAMESFLAG 0x00040000
361 #define ONLYNAMESFLAG 0x00080000
362 #define NEWFULLPOLYFLAG 0x00100000
363 #define HIDENAMESFLAG 0x00200000
364 #define AUTOBURIEDVIASFLAG 0x00400000
366 /* ---------------------------------------------------------------------------
369 #define NO_TYPE 0x00000 /*!< no object */
370 #define VIA_TYPE 0x00001
371 #define ELEMENT_TYPE 0x00002
372 #define LINE_TYPE 0x00004
373 #define POLYGON_TYPE 0x00008
374 #define TEXT_TYPE 0x00010
375 #define RATLINE_TYPE 0x00020
377 #define PIN_TYPE 0x00100 /*!< objects that are part */
378 #define PAD_TYPE 0x00200 /*!< 'pin' of SMD element */
379 #define ELEMENTNAME_TYPE 0x00400 /*!< of others */
380 #define POLYGONPOINT_TYPE 0x00800
381 #define LINEPOINT_TYPE 0x01000
382 #define ELEMENTLINE_TYPE 0x02000
383 #define ARC_TYPE 0x04000
384 #define ELEMENTARC_TYPE 0x08000
386 #define LOCKED_TYPE 0x10000 /*!< used to tell search to include locked items. */
387 #define NET_TYPE 0x20000 /*!< used to select whole net. */
388 #define ARCPOINT_TYPE 0x40000
390 #define PIN_TYPES (VIA_TYPE | PIN_TYPE)
391 #define LOCK_TYPES (VIA_TYPE | LINE_TYPE | ARC_TYPE | POLYGON_TYPE | ELEMENT_TYPE \
392 | TEXT_TYPE | ELEMENTNAME_TYPE | LOCKED_TYPE)
394 #define ALL_TYPES (~0) /*!< all bits set */