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