4 * PCB, interactive printed circuit board design
5 * Copyright (C) 2005 DJ Delorie
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.
37 #include "pcb-printf.h"
41 #ifdef HAVE_LIBDMALLOC
46 FlagCurrentStyle (void *data
)
50 if (style
->Thick
== Settings
.LineThickness
&&
51 style
->Diameter
== Settings
.ViaThickness
&&
52 style
->Hole
== Settings
.ViaDrillingHole
&&
53 style
->Keepaway
== Settings
.Keepaway
)
67 FlagGridSize (void *data
)
73 FlagUnitsMm (void *data
)
75 static const Unit
*u
= NULL
;
77 u
= get_unit_struct ("mm");
78 return (Settings
.grid_unit
== u
);
82 FlagUnitsMil (void *data
)
84 static const Unit
*u
= NULL
;
86 u
= get_unit_struct ("mil");
87 return (Settings
.grid_unit
== u
);
91 FlagBuffer (void *data
)
93 return (int) (Settings
.BufferNumber
+ 1);
97 FlagElementName (void *data
)
99 if (TEST_FLAG (NAMEONPCBFLAG
, PCB
))
101 if (TEST_FLAG (DESCRIPTIONFLAG
, PCB
))
107 FlagTESTFLAG (void *data
)
109 int bit
= GPOINTER_TO_INT (data
);
110 return TEST_FLAG (bit
, PCB
) ? 1 : 0;
114 FlagSETTINGS (void *data
)
116 size_t ofs
= (size_t)data
;
117 return *(bool *) ((char *)(&Settings
) + ofs
);
121 FlagMode (void *data
)
123 int x
= GPOINTER_TO_INT (data
);
125 return Settings
.Mode
;
126 return Settings
.Mode
== x
;
130 FlagHaveRegex (void *data
)
132 #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP)
149 FlagLayerShown (void *data
)
151 int n
= GPOINTER_TO_INT (data
);
155 return PCB
->ElementOn
;
163 return PCB
->InvisibleObjectsOn
;
165 return TEST_FLAG (SHOWMASKFLAG
, PCB
);
167 if (n
>= 0 && n
< max_copper_layer
)
168 return PCB
->Data
->Layer
[n
].On
;
174 FlagLayerActive (void *data
)
176 int test_layer
= GPOINTER_TO_INT (data
);
179 current_layer
= FL_RATS
;
180 else if (PCB
->SilkActive
)
181 current_layer
= FL_SILK
;
185 return current_layer
== test_layer
;
188 #define OFFSET_POINTER(a, b) (&(((a *)0)->b))
190 HID_Flag flags_flag_list
[] = {
191 {"style", FlagCurrentStyle
, NULL
},
192 {"grid", FlagGrid
, NULL
},
193 {"gridsize", FlagGridSize
, NULL
},
194 {"elementname", FlagElementName
, NULL
},
195 {"have_regex", FlagHaveRegex
, NULL
},
197 {"silk_shown", FlagLayerShown
, GINT_TO_POINTER (FL_SILK
)},
198 {"pins_shown", FlagLayerShown
, GINT_TO_POINTER (FL_PINS
)},
199 {"rats_shown", FlagLayerShown
, GINT_TO_POINTER (FL_RATS
)},
200 {"vias_shown", FlagLayerShown
, GINT_TO_POINTER (FL_VIAS
)},
201 {"back_shown", FlagLayerShown
, GINT_TO_POINTER (FL_BACK
)},
202 {"mask_shown", FlagLayerShown
, GINT_TO_POINTER (FL_MASK
)},
204 {"silk_active", FlagLayerActive
, GINT_TO_POINTER (FL_SILK
)},
205 {"rats_active", FlagLayerActive
, GINT_TO_POINTER (FL_RATS
)},
207 {"mode", FlagMode
, GINT_TO_POINTER (-1)},
208 {"nomode", FlagMode
, GINT_TO_POINTER (NO_MODE
)},
209 {"arcmode", FlagMode
, GINT_TO_POINTER (ARC_MODE
)},
210 {"arrowmode", FlagMode
, GINT_TO_POINTER (ARROW_MODE
)},
211 {"copymode", FlagMode
, GINT_TO_POINTER (COPY_MODE
)},
212 {"insertpointmode", FlagMode
, GINT_TO_POINTER (INSERTPOINT_MODE
)},
213 {"linemode", FlagMode
, GINT_TO_POINTER (LINE_MODE
)},
214 {"lockmode", FlagMode
, GINT_TO_POINTER (LOCK_MODE
)},
215 {"movemode", FlagMode
, GINT_TO_POINTER (MOVE_MODE
)},
216 {"pastebuffermode", FlagMode
, GINT_TO_POINTER (PASTEBUFFER_MODE
)},
217 {"polygonmode", FlagMode
, GINT_TO_POINTER (POLYGON_MODE
)},
218 {"polygonholemode", FlagMode
, GINT_TO_POINTER (POLYGONHOLE_MODE
)},
219 {"rectanglemode", FlagMode
, GINT_TO_POINTER (RECTANGLE_MODE
)},
220 {"removemode", FlagMode
, GINT_TO_POINTER (REMOVE_MODE
)},
221 {"rotatemode", FlagMode
, GINT_TO_POINTER (ROTATE_MODE
)},
222 {"rubberbandmovemode", FlagMode
, GINT_TO_POINTER (RUBBERBANDMOVE_MODE
)},
223 {"textmode", FlagMode
, GINT_TO_POINTER (TEXT_MODE
)},
224 {"thermalmode", FlagMode
, GINT_TO_POINTER (THERMAL_MODE
)},
225 {"viamode", FlagMode
, GINT_TO_POINTER (VIA_MODE
)},
227 {"shownumber", FlagTESTFLAG
, GINT_TO_POINTER (SHOWNUMBERFLAG
)},
228 {"localref", FlagTESTFLAG
, GINT_TO_POINTER (LOCALREFFLAG
)},
229 {"checkplanes", FlagTESTFLAG
, GINT_TO_POINTER (CHECKPLANESFLAG
)},
230 {"showdrc", FlagTESTFLAG
, GINT_TO_POINTER (SHOWDRCFLAG
)},
231 {"rubberband", FlagTESTFLAG
, GINT_TO_POINTER (RUBBERBANDFLAG
)},
232 {"description", FlagTESTFLAG
, GINT_TO_POINTER (DESCRIPTIONFLAG
)},
233 {"nameonpcb", FlagTESTFLAG
, GINT_TO_POINTER (NAMEONPCBFLAG
)},
234 {"autodrc", FlagTESTFLAG
, GINT_TO_POINTER (AUTODRCFLAG
)},
235 {"alldirection", FlagTESTFLAG
, GINT_TO_POINTER (ALLDIRECTIONFLAG
)},
236 {"swapstartdir", FlagTESTFLAG
, GINT_TO_POINTER (SWAPSTARTDIRFLAG
)},
237 {"uniquename", FlagTESTFLAG
, GINT_TO_POINTER (UNIQUENAMEFLAG
)},
238 {"clearnew", FlagTESTFLAG
, GINT_TO_POINTER (CLEARNEWFLAG
)},
239 {"snappin", FlagTESTFLAG
, GINT_TO_POINTER (SNAPPINFLAG
)},
240 {"showmask", FlagTESTFLAG
, GINT_TO_POINTER (SHOWMASKFLAG
)},
241 {"thindraw", FlagTESTFLAG
, GINT_TO_POINTER (THINDRAWFLAG
)},
242 {"orthomove", FlagTESTFLAG
, GINT_TO_POINTER (ORTHOMOVEFLAG
)},
243 {"liveroute", FlagTESTFLAG
, GINT_TO_POINTER (LIVEROUTEFLAG
)},
244 {"thindrawpoly", FlagTESTFLAG
, GINT_TO_POINTER (THINDRAWPOLYFLAG
)},
245 {"locknames", FlagTESTFLAG
, GINT_TO_POINTER (LOCKNAMESFLAG
)},
246 {"onlynames", FlagTESTFLAG
, GINT_TO_POINTER (ONLYNAMESFLAG
)},
247 {"newfullpoly", FlagTESTFLAG
, GINT_TO_POINTER (NEWFULLPOLYFLAG
)},
248 {"hidenames", FlagTESTFLAG
, GINT_TO_POINTER (HIDENAMESFLAG
)},
250 {"grid_units_mm", FlagUnitsMm
, NULL
},
251 {"grid_units_mil", FlagUnitsMil
, NULL
},
253 {"fullpoly", FlagSETTINGS
, OFFSET_POINTER (SettingType
, FullPoly
)},
254 {"clearline", FlagSETTINGS
, OFFSET_POINTER (SettingType
, ClearLine
)},
255 {"uniquenames", FlagSETTINGS
, OFFSET_POINTER (SettingType
, UniqueNames
)},
256 {"showsolderside", FlagSETTINGS
, OFFSET_POINTER (SettingType
, ShowSolderSide
)},
257 {"savelastcommand", FlagSETTINGS
, OFFSET_POINTER (SettingType
, SaveLastCommand
)},
258 {"saveintmp", FlagSETTINGS
, OFFSET_POINTER (SettingType
, SaveInTMP
)},
259 {"drawgrid", FlagSETTINGS
, OFFSET_POINTER (SettingType
, DrawGrid
)},
260 {"ratwarn", FlagSETTINGS
, OFFSET_POINTER (SettingType
, RatWarn
)},
261 {"stipplepolygons", FlagSETTINGS
, OFFSET_POINTER (SettingType
, StipplePolygons
)},
262 {"alldirectionlines", FlagSETTINGS
, OFFSET_POINTER (SettingType
, AllDirectionLines
)},
263 {"rubberbandmode", FlagSETTINGS
, OFFSET_POINTER (SettingType
, RubberBandMode
)},
264 {"swapstartdirection", FlagSETTINGS
, OFFSET_POINTER (SettingType
, SwapStartDirection
)},
265 {"showdrcmode", FlagSETTINGS
, OFFSET_POINTER (SettingType
, ShowDRC
)},
266 {"resetafterelement", FlagSETTINGS
, OFFSET_POINTER (SettingType
, ResetAfterElement
)},
267 {"ringbellwhenfinished", FlagSETTINGS
, OFFSET_POINTER (SettingType
, RingBellWhenFinished
)},
269 {"buffer", FlagBuffer
, NULL
},
273 REGISTER_FLAGS (flags_flag_list
)