Pass r_NoHolesPolygonDicer a POLYAREA *, not a PLINE *
[geda-pcb/gde.git] / src / change.c
blob0599ee444c165584d8f6cfd56cefd0bb32b4fbae
1 /* $Id$ */
3 /*
4 * COPYRIGHT
6 * PCB, interactive printed circuit board design
7 * Copyright (C) 1994,1995,1996, 2005 Thomas Nau
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Contact addresses for paper mail and Email:
24 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
25 * Thomas.Nau@rz.uni-ulm.de
29 /* functions used to change object properties
33 #ifdef HAVE_CONFIG_H
34 #include "config.h"
35 #endif
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <setjmp.h>
41 #include "global.h"
43 #include "change.h"
44 #include "create.h"
45 #include "crosshair.h"
46 #include "data.h"
47 #include "draw.h"
48 #include "error.h"
49 #include "mymem.h"
50 #include "misc.h"
51 #include "mirror.h"
52 #include "polygon.h"
53 #include "rats.h"
54 #include "remove.h"
55 #include "rtree.h"
56 #include "search.h"
57 #include "select.h"
58 #include "set.h"
59 #include "thermal.h"
60 #include "undo.h"
62 #ifdef HAVE_LIBDMALLOC
63 #include <dmalloc.h>
64 #endif
66 RCSID ("$Id$");
68 /* ---------------------------------------------------------------------------
69 * some local prototypes
71 static void *ChangePinSize (ElementTypePtr, PinTypePtr);
72 static void *ChangePinClearSize (ElementTypePtr, PinTypePtr);
73 static void *ChangePinMaskSize (ElementTypePtr, PinTypePtr);
74 static void *ChangePadSize (ElementTypePtr, PadTypePtr);
75 static void *ChangePadClearSize (ElementTypePtr, PadTypePtr);
76 static void *ChangePadMaskSize (ElementTypePtr, PadTypePtr);
77 static void *ChangePin2ndSize (ElementTypePtr, PinTypePtr);
78 static void *ChangeElement2ndSize (ElementTypePtr);
79 static void *ChangeViaSize (PinTypePtr);
80 static void *ChangeVia2ndSize (PinTypePtr);
81 static void *ChangeViaClearSize (PinTypePtr);
82 static void *ChangeViaMaskSize (PinTypePtr);
83 static void *ChangeLineSize (LayerTypePtr, LineTypePtr);
84 static void *ChangeLineClearSize (LayerTypePtr, LineTypePtr);
85 static void *ChangeArcSize (LayerTypePtr, ArcTypePtr);
86 static void *ChangeArcClearSize (LayerTypePtr, ArcTypePtr);
87 static void *ChangeTextSize (LayerTypePtr, TextTypePtr);
88 static void *ChangeElementSize (ElementTypePtr);
89 static void *ChangeElementNameSize (ElementTypePtr);
90 static void *ChangePinName (ElementTypePtr, PinTypePtr);
91 static void *ChangePadName (ElementTypePtr, PadTypePtr);
92 static void *ChangeViaName (PinTypePtr);
93 static void *ChangeLineName (LayerTypePtr, LineTypePtr);
94 static void *ChangeElementName (ElementTypePtr);
95 static void *ChangeTextName (LayerTypePtr, TextTypePtr);
96 static void *ChangeElementSquare (ElementTypePtr);
97 static void *SetElementSquare (ElementTypePtr);
98 static void *ClrElementSquare (ElementTypePtr);
99 static void *ChangeElementOctagon (ElementTypePtr);
100 static void *SetElementOctagon (ElementTypePtr);
101 static void *ClrElementOctagon (ElementTypePtr);
102 static void *ChangePinSquare (ElementTypePtr, PinTypePtr);
103 static void *SetPinSquare (ElementTypePtr, PinTypePtr);
104 static void *ClrPinSquare (ElementTypePtr, PinTypePtr);
105 static void *ChangePinOctagon (ElementTypePtr, PinTypePtr);
106 static void *SetPinOctagon (ElementTypePtr, PinTypePtr);
107 static void *ClrPinOctagon (ElementTypePtr, PinTypePtr);
108 static void *ChangeViaOctagon (PinTypePtr);
109 static void *SetViaOctagon (PinTypePtr);
110 static void *ClrViaOctagon (PinTypePtr);
111 static void *ChangePadSquare (ElementTypePtr, PadTypePtr);
112 static void *SetPadSquare (ElementTypePtr, PadTypePtr);
113 static void *ClrPadSquare (ElementTypePtr, PadTypePtr);
114 static void *ChangeViaThermal (PinTypePtr);
115 static void *ChangePinThermal (ElementTypePtr, PinTypePtr);
116 static void *ChangeLineJoin (LayerTypePtr, LineTypePtr);
117 static void *SetLineJoin (LayerTypePtr, LineTypePtr);
118 static void *ClrLineJoin (LayerTypePtr, LineTypePtr);
119 static void *ChangeArcJoin (LayerTypePtr, ArcTypePtr);
120 static void *SetArcJoin (LayerTypePtr, ArcTypePtr);
121 static void *ClrArcJoin (LayerTypePtr, ArcTypePtr);
122 static void *ChangeTextJoin (LayerTypePtr, TextTypePtr);
123 static void *SetTextJoin (LayerTypePtr, TextTypePtr);
124 static void *ClrTextJoin (LayerTypePtr, TextTypePtr);
125 static void *ChangePolyClear (LayerTypePtr, PolygonTypePtr);
127 /* ---------------------------------------------------------------------------
128 * some local identifiers
130 static int Delta; /* change of size */
131 static int Absolute; /* Absolute size */
132 static char *NewName; /* new name */
133 static ObjectFunctionType ChangeSizeFunctions = {
134 ChangeLineSize,
135 ChangeTextSize,
136 ChangePolyClear,
137 ChangeViaSize,
138 ChangeElementSize, /* changes silk screen line width */
139 ChangeElementNameSize,
140 ChangePinSize,
141 ChangePadSize,
142 NULL,
143 NULL,
144 ChangeArcSize,
145 NULL
147 static ObjectFunctionType Change2ndSizeFunctions = {
148 NULL,
149 NULL,
150 NULL,
151 ChangeVia2ndSize,
152 ChangeElement2ndSize,
153 NULL,
154 ChangePin2ndSize,
155 NULL,
156 NULL,
157 NULL,
158 NULL,
159 NULL
161 static ObjectFunctionType ChangeThermalFunctions = {
162 NULL,
163 NULL,
164 NULL,
165 ChangeViaThermal,
166 NULL,
167 NULL,
168 ChangePinThermal,
169 NULL,
170 NULL,
171 NULL,
172 NULL,
173 NULL
175 static ObjectFunctionType ChangeClearSizeFunctions = {
176 ChangeLineClearSize,
177 NULL,
178 NULL,
179 ChangeViaClearSize,
180 NULL,
181 NULL,
182 ChangePinClearSize,
183 ChangePadClearSize,
184 NULL,
185 NULL,
186 ChangeArcClearSize,
187 NULL
189 static ObjectFunctionType ChangeNameFunctions = {
190 ChangeLineName,
191 ChangeTextName,
192 NULL,
193 ChangeViaName,
194 ChangeElementName,
195 NULL,
196 ChangePinName,
197 ChangePadName,
198 NULL,
199 NULL,
200 NULL,
201 NULL
203 static ObjectFunctionType ChangeSquareFunctions = {
204 NULL,
205 NULL,
206 NULL,
207 NULL,
208 ChangeElementSquare,
209 NULL,
210 ChangePinSquare,
211 ChangePadSquare,
212 NULL,
213 NULL,
214 NULL,
215 NULL
217 static ObjectFunctionType ChangeJoinFunctions = {
218 ChangeLineJoin,
219 ChangeTextJoin,
220 NULL,
221 NULL,
222 NULL,
223 NULL,
224 NULL,
225 NULL,
226 NULL,
227 NULL,
228 ChangeArcJoin,
229 NULL
231 static ObjectFunctionType ChangeOctagonFunctions = {
232 NULL,
233 NULL,
234 NULL,
235 ChangeViaOctagon,
236 ChangeElementOctagon,
237 NULL,
238 ChangePinOctagon,
239 NULL,
240 NULL,
241 NULL,
242 NULL,
243 NULL
245 static ObjectFunctionType ChangeMaskSizeFunctions = {
246 NULL,
247 NULL,
248 NULL,
249 ChangeViaMaskSize,
250 #if 0
251 ChangeElementMaskSize,
252 #else
253 NULL,
254 #endif
255 NULL,
256 ChangePinMaskSize,
257 ChangePadMaskSize,
258 NULL,
259 NULL,
260 NULL,
261 NULL
263 static ObjectFunctionType SetSquareFunctions = {
264 NULL,
265 NULL,
266 NULL,
267 NULL,
268 SetElementSquare,
269 NULL,
270 SetPinSquare,
271 SetPadSquare,
272 NULL,
273 NULL,
274 NULL,
275 NULL
277 static ObjectFunctionType SetJoinFunctions = {
278 SetLineJoin,
279 SetTextJoin,
280 NULL,
281 NULL,
282 NULL,
283 NULL,
284 NULL,
285 NULL,
286 NULL,
287 NULL,
288 SetArcJoin,
289 NULL
291 static ObjectFunctionType SetOctagonFunctions = {
292 NULL,
293 NULL,
294 NULL,
295 SetViaOctagon,
296 SetElementOctagon,
297 NULL,
298 SetPinOctagon,
299 NULL,
300 NULL,
301 NULL,
302 NULL,
303 NULL
305 static ObjectFunctionType ClrSquareFunctions = {
306 NULL,
307 NULL,
308 NULL,
309 NULL,
310 ClrElementSquare,
311 NULL,
312 ClrPinSquare,
313 ClrPadSquare,
314 NULL,
315 NULL,
316 NULL,
317 NULL
319 static ObjectFunctionType ClrJoinFunctions = {
320 ClrLineJoin,
321 ClrTextJoin,
322 NULL,
323 NULL,
324 NULL,
325 NULL,
326 NULL,
327 NULL,
328 NULL,
329 NULL,
330 ClrArcJoin,
331 NULL
333 static ObjectFunctionType ClrOctagonFunctions = {
334 NULL,
335 NULL,
336 NULL,
337 ClrViaOctagon,
338 ClrElementOctagon,
339 NULL,
340 ClrPinOctagon,
341 NULL,
342 NULL,
343 NULL,
344 NULL,
345 NULL
348 /* ---------------------------------------------------------------------------
349 * changes the thermal on a via
350 * returns TRUE if changed
352 static void *
353 ChangeViaThermal (PinTypePtr Via)
355 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, False);
356 RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Via);
357 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
358 if (!Delta) /* remove the thermals */
359 CLEAR_THERM (INDEXOFCURRENT, Via);
360 else
361 ASSIGN_THERM (INDEXOFCURRENT, Delta, Via);
362 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, True);
363 ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Via);
364 DrawVia (Via, 0);
365 return Via;
368 /* ---------------------------------------------------------------------------
369 * changes the thermal on a pin
370 * returns TRUE if changed
372 static void *
373 ChangePinThermal (ElementTypePtr element, PinTypePtr Pin)
375 AddObjectToClearPolyUndoList (PIN_TYPE, element, Pin, Pin, False);
376 RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Pin);
377 AddObjectToFlagUndoList (PIN_TYPE, element, Pin, Pin);
378 if (!Delta) /* remove the thermals */
379 CLEAR_THERM (INDEXOFCURRENT, Pin);
380 else
381 ASSIGN_THERM (INDEXOFCURRENT, Delta, Pin);
382 AddObjectToClearPolyUndoList (PIN_TYPE, element, Pin, Pin, True);
383 ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Pin);
384 DrawPin (Pin, 0);
385 return Pin;
388 /* ---------------------------------------------------------------------------
389 * changes the size of a via
390 * returns TRUE if changed
392 static void *
393 ChangeViaSize (PinTypePtr Via)
395 BDimension value = Absolute ? Absolute : Via->Thickness + Delta;
397 if (TEST_FLAG (LOCKFLAG, Via))
398 return (NULL);
399 if (!TEST_FLAG (HOLEFLAG, Via) && value <= MAX_PINORVIASIZE &&
400 value >= MIN_PINORVIASIZE &&
401 value >= Via->DrillingHole + MIN_PINORVIACOPPER &&
402 value != Via->Thickness)
404 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
405 EraseVia (Via);
406 r_delete_entry (PCB->Data->via_tree, (BoxType *) Via);
407 RestoreToPolygon (PCB->Data, PIN_TYPE, Via, Via);
408 if (Via->Mask)
410 AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via);
411 Via->Mask += value - Via->Thickness;
413 Via->Thickness = value;
414 SetPinBoundingBox (Via);
415 r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0);
416 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
417 DrawVia (Via, 0);
418 return (Via);
420 return (NULL);
423 /* ---------------------------------------------------------------------------
424 * changes the drilling hole of a via
425 * returns TRUE if changed
427 static void *
428 ChangeVia2ndSize (PinTypePtr Via)
430 BDimension value = (Absolute) ? Absolute : Via->DrillingHole + Delta;
432 if (TEST_FLAG (LOCKFLAG, Via))
433 return (NULL);
434 if (value <= MAX_PINORVIASIZE &&
435 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Via) ||
436 value <=
437 Via->Thickness - MIN_PINORVIACOPPER)
438 && value != Via->DrillingHole)
440 AddObjectTo2ndSizeUndoList (VIA_TYPE, Via, Via, Via);
441 EraseVia (Via);
442 Via->DrillingHole = value;
443 if (TEST_FLAG (HOLEFLAG, Via))
445 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
446 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
447 Via->Thickness = value;
448 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
450 DrawVia (Via, 0);
451 return (Via);
453 return (NULL);
457 /* ---------------------------------------------------------------------------
458 * changes the clearance size of a via
459 * returns TRUE if changed
461 static void *
462 ChangeViaClearSize (PinTypePtr Via)
464 BDimension value = (Absolute) ? Absolute : Via->Clearance + Delta;
466 if (TEST_FLAG (LOCKFLAG, Via))
467 return (NULL);
468 value = MIN (MAX_LINESIZE, value);
469 if (value < 0)
470 value = 0;
471 if (Delta < 0 && value < PCB->Bloat * 2)
472 value = 0;
473 if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2)
474 value = PCB->Bloat * 2 + 2;
475 if (Via->Clearance == value)
476 return NULL;
477 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
478 AddObjectToClearSizeUndoList (VIA_TYPE, Via, Via, Via);
479 EraseVia (Via);
480 r_delete_entry (PCB->Data->via_tree, (BoxType *) Via);
481 Via->Clearance = value;
482 SetPinBoundingBox (Via);
483 r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0);
484 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
485 DrawVia (Via, 0);
486 Via->Element = NULL;
487 return (Via);
491 /* ---------------------------------------------------------------------------
492 * changes the size of a pin
493 * returns TRUE if changed
495 static void *
496 ChangePinSize (ElementTypePtr Element, PinTypePtr Pin)
498 BDimension value = (Absolute) ? Absolute : Pin->Thickness + Delta;
500 if (TEST_FLAG (LOCKFLAG, Pin))
501 return (NULL);
502 if (!TEST_FLAG (HOLEFLAG, Pin) && value <= MAX_PINORVIASIZE &&
503 value >= MIN_PINORVIASIZE &&
504 value >= Pin->DrillingHole + MIN_PINORVIACOPPER &&
505 value != Pin->Thickness)
507 AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin);
508 AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin);
509 ErasePin (Pin);
510 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
511 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
512 Pin->Mask += value - Pin->Thickness;
513 Pin->Thickness = value;
514 /* SetElementBB updates all associated rtrees */
515 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
516 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
517 DrawPin (Pin, 0);
518 return (Pin);
520 return (NULL);
523 /* ---------------------------------------------------------------------------
524 * changes the clearance size of a pin
525 * returns TRUE if changed
527 static void *
528 ChangePinClearSize (ElementTypePtr Element, PinTypePtr Pin)
530 BDimension value = (Absolute) ? Absolute : Pin->Clearance + Delta;
532 if (TEST_FLAG (LOCKFLAG, Pin))
533 return (NULL);
534 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
535 if (Pin->Clearance == value)
536 return NULL;
537 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
538 AddObjectToClearSizeUndoList (PIN_TYPE, Element, Pin, Pin);
539 ErasePin (Pin);
540 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
541 Pin->Clearance = value;
542 /* SetElementBB updates all associated rtrees */
543 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
544 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
545 DrawPin (Pin, 0);
546 return (Pin);
549 /* ---------------------------------------------------------------------------
550 * changes the size of a pad
551 * returns TRUE if changed
553 static void *
554 ChangePadSize (ElementTypePtr Element, PadTypePtr Pad)
556 BDimension value = (Absolute) ? Absolute : Pad->Thickness + Delta;
558 if (TEST_FLAG (LOCKFLAG, Pad))
559 return (NULL);
560 if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Thickness)
562 AddObjectToSizeUndoList (PAD_TYPE, Element, Pad, Pad);
563 AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad);
564 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
565 ErasePad (Pad);
566 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
567 Pad->Mask += value - Pad->Thickness;
568 Pad->Thickness = value;
569 /* SetElementBB updates all associated rtrees */
570 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
571 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
572 DrawPad (Pad, 0);
573 return (Pad);
575 return (NULL);
578 /* ---------------------------------------------------------------------------
579 * changes the clearance size of a pad
580 * returns TRUE if changed
582 static void *
583 ChangePadClearSize (ElementTypePtr Element, PadTypePtr Pad)
585 BDimension value = (Absolute) ? Absolute : Pad->Clearance + Delta;
587 if (TEST_FLAG (LOCKFLAG, Pad))
588 return (NULL);
589 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
590 if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Clearance)
592 AddObjectToClearSizeUndoList (PAD_TYPE, Element, Pad, Pad);
593 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
594 ErasePad (Pad);
595 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
596 Pad->Clearance = value;
597 /* SetElementBB updates all associated rtrees */
598 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
599 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
600 DrawPad (Pad, 0);
601 return (Pad);
603 return (NULL);
606 /* ---------------------------------------------------------------------------
607 * changes the drilling hole of all pins of an element
608 * returns TRUE if changed
610 static void *
611 ChangeElement2ndSize (ElementTypePtr Element)
613 Boolean changed = False;
614 BDimension value;
616 if (TEST_FLAG (LOCKFLAG, Element))
617 return (NULL);
618 PIN_LOOP (Element);
620 value = (Absolute) ? Absolute : pin->DrillingHole + Delta;
621 if (value <= MAX_PINORVIASIZE &&
622 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, pin) ||
623 value <=
624 pin->Thickness -
625 MIN_PINORVIACOPPER)
626 && value != pin->DrillingHole)
628 changed = True;
629 AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, pin, pin);
630 ErasePin (pin);
631 pin->DrillingHole = value;
632 DrawPin (pin, 0);
633 if (TEST_FLAG (HOLEFLAG, pin))
635 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, pin);
636 AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin);
637 pin->Thickness = value;
638 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, pin);
642 END_LOOP;
643 if (changed)
644 return (Element);
645 else
646 return (NULL);
649 /* ---------------------------------------------------------------------------
650 * changes the drilling hole of a pin
651 * returns TRUE if changed
653 static void *
654 ChangePin2ndSize (ElementTypePtr Element, PinTypePtr Pin)
656 BDimension value = (Absolute) ? Absolute : Pin->DrillingHole + Delta;
658 if (TEST_FLAG (LOCKFLAG, Pin))
659 return (NULL);
660 if (value <= MAX_PINORVIASIZE &&
661 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Pin) ||
662 value <=
663 Pin->Thickness - MIN_PINORVIACOPPER)
664 && value != Pin->DrillingHole)
666 AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, Pin, Pin);
667 ErasePin (Pin);
668 Pin->DrillingHole = value;
669 DrawPin (Pin, 0);
670 if (TEST_FLAG (HOLEFLAG, Pin))
672 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
673 AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin);
674 Pin->Thickness = value;
675 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
677 return (Pin);
679 return (NULL);
682 /* ---------------------------------------------------------------------------
683 * changes the size of a line
684 * returns TRUE if changed
686 static void *
687 ChangeLineSize (LayerTypePtr Layer, LineTypePtr Line)
689 BDimension value = (Absolute) ? Absolute : Line->Thickness + Delta;
691 if (TEST_FLAG (LOCKFLAG, Line))
692 return (NULL);
693 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
694 value != Line->Thickness)
696 AddObjectToSizeUndoList (LINE_TYPE, Layer, Line, Line);
697 EraseLine (Line);
698 r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
699 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
700 Line->Thickness = value;
701 SetLineBoundingBox (Line);
702 r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0);
703 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
704 DrawLine (Layer, Line, 0);
705 return (Line);
707 return (NULL);
710 /* ---------------------------------------------------------------------------
711 * changes the clearance size of a line
712 * returns TRUE if changed
714 static void *
715 ChangeLineClearSize (LayerTypePtr Layer, LineTypePtr Line)
717 BDimension value = (Absolute) ? Absolute : Line->Clearance + Delta;
719 if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line))
720 return (NULL);
721 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
722 if (value != Line->Clearance)
724 AddObjectToClearSizeUndoList (LINE_TYPE, Layer, Line, Line);
725 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
726 EraseLine (Line);
727 r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
728 Line->Clearance = value;
729 if (Line->Clearance == 0)
731 CLEAR_FLAG (CLEARLINEFLAG, Line);
732 Line->Clearance = 1000;
734 SetLineBoundingBox (Line);
735 r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0);
736 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
737 DrawLine (Layer, Line, 0);
738 return (Line);
740 return (NULL);
743 /* ---------------------------------------------------------------------------
744 * changes the size of an arc
745 * returns TRUE if changed
747 static void *
748 ChangeArcSize (LayerTypePtr Layer, ArcTypePtr Arc)
750 BDimension value = (Absolute) ? Absolute : Arc->Thickness + Delta;
752 if (TEST_FLAG (LOCKFLAG, Arc))
753 return (NULL);
754 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
755 value != Arc->Thickness)
757 AddObjectToSizeUndoList (ARC_TYPE, Layer, Arc, Arc);
758 EraseArc (Arc);
759 r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc);
760 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
761 Arc->Thickness = value;
762 SetArcBoundingBox (Arc);
763 r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0);
764 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
765 DrawArc (Layer, Arc, 0);
766 return (Arc);
768 return (NULL);
771 /* ---------------------------------------------------------------------------
772 * changes the clearance size of an arc
773 * returns TRUE if changed
775 static void *
776 ChangeArcClearSize (LayerTypePtr Layer, ArcTypePtr Arc)
778 BDimension value = (Absolute) ? Absolute : Arc->Clearance + Delta;
780 if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc))
781 return (NULL);
782 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
783 if (value != Arc->Clearance)
785 AddObjectToClearSizeUndoList (ARC_TYPE, Layer, Arc, Arc);
786 EraseArc (Arc);
787 r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc);
788 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
789 Arc->Clearance = value;
790 if (Arc->Clearance == 0)
792 CLEAR_FLAG (CLEARLINEFLAG, Arc);
793 Arc->Clearance = 1000;
795 SetArcBoundingBox (Arc);
796 r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0);
797 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
798 DrawArc (Layer, Arc, 0);
799 return (Arc);
801 return (NULL);
804 /* ---------------------------------------------------------------------------
805 * changes the scaling factor of a text object
806 * returns TRUE if changed
808 static void *
809 ChangeTextSize (LayerTypePtr Layer, TextTypePtr Text)
811 BDimension value = (Absolute) ? Absolute / 45 : Text->Scale + Delta / 45;
813 if (TEST_FLAG (LOCKFLAG, Text))
814 return (NULL);
815 if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE &&
816 value != Text->Scale)
818 AddObjectToSizeUndoList (TEXT_TYPE, Layer, Text, Text);
819 EraseText (Layer, Text);
820 r_delete_entry (Layer->text_tree, (BoxTypePtr) Text);
821 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
822 Text->Scale = value;
823 SetTextBoundingBox (&PCB->Font, Text);
824 r_insert_entry (Layer->text_tree, (BoxTypePtr) Text, 0);
825 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
826 DrawText (Layer, Text, 0);
827 return (Text);
829 return (NULL);
832 /* ---------------------------------------------------------------------------
833 * changes the scaling factor of an element's outline
834 * returns TRUE if changed
836 static void *
837 ChangeElementSize (ElementTypePtr Element)
839 BDimension value;
840 Boolean changed = False;
842 if (TEST_FLAG (LOCKFLAG, Element))
843 return (NULL);
844 if (PCB->ElementOn)
845 EraseElement (Element);
846 ELEMENTLINE_LOOP (Element);
848 value = (Absolute) ? Absolute : line->Thickness + Delta;
849 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
850 value != line->Thickness)
852 AddObjectToSizeUndoList (ELEMENTLINE_TYPE, Element, line, line);
853 line->Thickness = value;
854 changed = True;
857 END_LOOP;
858 ARC_LOOP (Element);
860 value = (Absolute) ? Absolute : arc->Thickness + Delta;
861 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
862 value != arc->Thickness)
864 AddObjectToSizeUndoList (ELEMENTARC_TYPE, Element, arc, arc);
865 arc->Thickness = value;
866 changed = True;
869 END_LOOP;
870 if (PCB->ElementOn)
872 DrawElement (Element, 0);
874 if (changed)
875 return (Element);
876 return (NULL);
879 /* ---------------------------------------------------------------------------
880 * changes the scaling factor of a elementname object
881 * returns TRUE if changed
883 static void *
884 ChangeElementNameSize (ElementTypePtr Element)
886 BDimension value =
887 (Absolute) ? Absolute / 45 : DESCRIPTION_TEXT (Element).Scale +
888 Delta / 45;
890 if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
891 return (NULL);
892 if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE)
894 EraseElementName (Element);
895 ELEMENTTEXT_LOOP (Element);
897 AddObjectToSizeUndoList (ELEMENTNAME_TYPE, Element, text, text);
898 r_delete_entry (PCB->Data->name_tree[n], (BoxType *) text);
899 text->Scale = value;
900 SetTextBoundingBox (&PCB->Font, text);
901 r_insert_entry (PCB->Data->name_tree[n], (BoxType *) text, 0);
903 END_LOOP;
904 DrawElementName (Element, 0);
905 return (Element);
907 return (NULL);
910 /* ---------------------------------------------------------------------------
911 * changes the name of a via
913 static void *
914 ChangeViaName (PinTypePtr Via)
916 char *old = Via->Name;
918 if (TEST_FLAG (DISPLAYNAMEFLAG, Via))
920 ErasePinName (Via);
921 Via->Name = NewName;
922 DrawPinName (Via, 0);
924 else
925 Via->Name = NewName;
926 return (old);
929 /* ---------------------------------------------------------------------------
930 * changes the name of a pin
932 static void *
933 ChangePinName (ElementTypePtr Element, PinTypePtr Pin)
935 char *old = Pin->Name;
937 Element = Element; /* get rid of 'unused...' warnings */
938 if (TEST_FLAG (DISPLAYNAMEFLAG, Pin))
940 ErasePinName (Pin);
941 Pin->Name = NewName;
942 DrawPinName (Pin, 0);
944 else
945 Pin->Name = NewName;
946 return (old);
949 /* ---------------------------------------------------------------------------
950 * changes the name of a pad
952 static void *
953 ChangePadName (ElementTypePtr Element, PadTypePtr Pad)
955 char *old = Pad->Name;
957 Element = Element; /* get rid of 'unused...' warnings */
958 if (TEST_FLAG (DISPLAYNAMEFLAG, Pad))
960 ErasePadName (Pad);
961 Pad->Name = NewName;
962 DrawPadName (Pad, 0);
964 else
965 Pad->Name = NewName;
966 return (old);
969 /* ---------------------------------------------------------------------------
970 * changes the name of a line
972 static void *
973 ChangeLineName (LayerTypePtr Layer, LineTypePtr Line)
975 char *old = Line->Number;
977 Layer = Layer;
978 Line->Number = NewName;
979 return (old);
982 /* ---------------------------------------------------------------------------
983 * changes the layout-name of an element
985 static void *
986 ChangeElementName (ElementTypePtr Element)
988 char *old = ELEMENT_NAME (PCB, Element);
990 if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
991 return (NULL);
992 if (NAME_INDEX (PCB) == NAMEONPCB_INDEX)
994 if (TEST_FLAG (UNIQUENAMEFLAG, PCB) &&
995 UniqueElementName (PCB->Data, NewName) != NewName)
997 Message (_("Error: The name \"%s\" is not unique!\n"), NewName);
998 return ((char *) -1);
1001 EraseElementName (Element);
1002 r_delete_entry (PCB->Data->name_tree[NAME_INDEX (PCB)],
1003 (BoxType *) & ELEMENT_TEXT (PCB, Element));
1004 ELEMENT_NAME (PCB, Element) = NewName;
1005 SetTextBoundingBox (&PCB->Font, &ELEMENT_TEXT (PCB, Element));
1006 r_insert_entry (PCB->Data->name_tree[NAME_INDEX (PCB)],
1007 (BoxType *) & ELEMENT_TEXT (PCB, Element), 0);
1008 DrawElementName (Element, 0);
1009 return (old);
1012 /* ---------------------------------------------------------------------------
1013 * sets data of a text object and calculates bounding box
1014 * memory must have already been allocated
1015 * the one for the new string is allocated
1016 * returns True if the string has been changed
1018 static void *
1019 ChangeTextName (LayerTypePtr Layer, TextTypePtr Text)
1021 char *old = Text->TextString;
1023 if (TEST_FLAG (LOCKFLAG, Text))
1024 return (NULL);
1025 EraseText (Layer, Text);
1026 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1027 Text->TextString = NewName;
1029 /* calculate size of the bounding box */
1030 SetTextBoundingBox (&PCB->Font, Text);
1031 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1032 DrawText (Layer, Text, 0);
1033 return (old);
1036 /* ---------------------------------------------------------------------------
1037 * changes the name of a layout; memory has to be already allocated
1039 Boolean
1040 ChangeLayoutName (char *Name)
1042 PCB->Name = Name;
1043 hid_action ("PCBChanged");
1044 return (True);
1047 /* ---------------------------------------------------------------------------
1048 * changes the side of the board an element is on
1049 * returns TRUE if done
1051 Boolean
1052 ChangeElementSide (ElementTypePtr Element, LocationType yoff)
1054 if (TEST_FLAG (LOCKFLAG, Element))
1055 return (False);
1056 EraseElement (Element);
1057 AddObjectToMirrorUndoList (ELEMENT_TYPE, Element, Element, Element, yoff);
1058 MirrorElementCoordinates (PCB->Data, Element, yoff);
1059 DrawElement (Element, 0);
1060 return (True);
1063 /* ---------------------------------------------------------------------------
1064 * changes the name of a layer; memory has to be already allocated
1066 Boolean
1067 ChangeLayerName (LayerTypePtr Layer, char *Name)
1069 CURRENT->Name = Name;
1070 hid_action ("LayersChanged");
1071 return (True);
1074 /* ---------------------------------------------------------------------------
1075 * changes the clearance flag of a line
1077 static void *
1078 ChangeLineJoin (LayerTypePtr Layer, LineTypePtr Line)
1080 if (TEST_FLAG (LOCKFLAG, Line))
1081 return (NULL);
1082 EraseLine (Line);
1083 if (TEST_FLAG(CLEARLINEFLAG, Line))
1085 AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, False);
1086 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
1088 AddObjectToFlagUndoList (LINE_TYPE, Layer, Line, Line);
1089 TOGGLE_FLAG (CLEARLINEFLAG, Line);
1090 if (TEST_FLAG(CLEARLINEFLAG, Line))
1092 AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, True);
1093 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
1095 DrawLine (Layer, Line, 0);
1096 return (Line);
1099 /* ---------------------------------------------------------------------------
1100 * sets the clearance flag of a line
1102 static void *
1103 SetLineJoin (LayerTypePtr Layer, LineTypePtr Line)
1105 if (TEST_FLAG (LOCKFLAG, Line) || TEST_FLAG (CLEARLINEFLAG, Line))
1106 return (NULL);
1107 return ChangeLineJoin (Layer, Line);
1110 /* ---------------------------------------------------------------------------
1111 * clears the clearance flag of a line
1113 static void *
1114 ClrLineJoin (LayerTypePtr Layer, LineTypePtr Line)
1116 if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line))
1117 return (NULL);
1118 return ChangeLineJoin (Layer, Line);
1121 /* ---------------------------------------------------------------------------
1122 * changes the clearance flag of an arc
1124 static void *
1125 ChangeArcJoin (LayerTypePtr Layer, ArcTypePtr Arc)
1127 if (TEST_FLAG (LOCKFLAG, Arc))
1128 return (NULL);
1129 EraseArc (Arc);
1130 if (TEST_FLAG (CLEARLINEFLAG, Arc))
1132 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
1133 AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, False);
1135 AddObjectToFlagUndoList (ARC_TYPE, Layer, Arc, Arc);
1136 TOGGLE_FLAG (CLEARLINEFLAG, Arc);
1137 if (TEST_FLAG (CLEARLINEFLAG, Arc))
1139 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
1140 AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, True);
1142 DrawArc (Layer, Arc, 0);
1143 return (Arc);
1146 /* ---------------------------------------------------------------------------
1147 * sets the clearance flag of an arc
1149 static void *
1150 SetArcJoin (LayerTypePtr Layer, ArcTypePtr Arc)
1152 if (TEST_FLAG (LOCKFLAG, Arc) || TEST_FLAG (CLEARLINEFLAG, Arc))
1153 return (NULL);
1154 return ChangeArcJoin (Layer, Arc);
1157 /* ---------------------------------------------------------------------------
1158 * clears the clearance flag of an arc
1160 static void *
1161 ClrArcJoin (LayerTypePtr Layer, ArcTypePtr Arc)
1163 if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc))
1164 return (NULL);
1165 return ChangeArcJoin (Layer, Arc);
1168 /* ---------------------------------------------------------------------------
1169 * changes the clearance flag of a text
1171 static void *
1172 ChangeTextJoin (LayerTypePtr Layer, TextTypePtr Text)
1174 if (TEST_FLAG (LOCKFLAG, Text))
1175 return (NULL);
1176 EraseText (Layer, Text);
1177 if (TEST_FLAG(CLEARLINEFLAG, Text))
1179 AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, False);
1180 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1182 AddObjectToFlagUndoList (LINE_TYPE, Layer, Text, Text);
1183 TOGGLE_FLAG (CLEARLINEFLAG, Text);
1184 if (TEST_FLAG(CLEARLINEFLAG, Text))
1186 AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, True);
1187 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1189 DrawText (Layer, Text, 0);
1190 return (Text);
1193 /* ---------------------------------------------------------------------------
1194 * sets the clearance flag of a text
1196 static void *
1197 SetTextJoin (LayerTypePtr Layer, TextTypePtr Text)
1199 if (TEST_FLAG (LOCKFLAG, Text) || TEST_FLAG (CLEARLINEFLAG, Text))
1200 return (NULL);
1201 return ChangeTextJoin (Layer, Text);
1204 /* ---------------------------------------------------------------------------
1205 * clears the clearance flag of a text
1207 static void *
1208 ClrTextJoin (LayerTypePtr Layer, TextTypePtr Text)
1210 if (TEST_FLAG (LOCKFLAG, Text) || !TEST_FLAG (CLEARLINEFLAG, Text))
1211 return (NULL);
1212 return ChangeTextJoin (Layer, Text);
1215 /* ---------------------------------------------------------------------------
1216 * changes the square flag of all pins on an element
1218 static void *
1219 ChangeElementSquare (ElementTypePtr Element)
1221 void *ans = NULL;
1223 if (TEST_FLAG (LOCKFLAG, Element))
1224 return (NULL);
1225 PIN_LOOP (Element);
1227 ans = ChangePinSquare (Element, pin);
1229 END_LOOP;
1230 PAD_LOOP (Element);
1232 ans = ChangePadSquare (Element, pad);
1234 END_LOOP;
1235 return (ans);
1238 /* ---------------------------------------------------------------------------
1239 * sets the square flag of all pins on an element
1241 static void *
1242 SetElementSquare (ElementTypePtr Element)
1244 void *ans = NULL;
1246 if (TEST_FLAG (LOCKFLAG, Element))
1247 return (NULL);
1248 PIN_LOOP (Element);
1250 ans = SetPinSquare (Element, pin);
1252 END_LOOP;
1253 PAD_LOOP (Element);
1255 ans = SetPadSquare (Element, pad);
1257 END_LOOP;
1258 return (ans);
1261 /* ---------------------------------------------------------------------------
1262 * clears the square flag of all pins on an element
1264 static void *
1265 ClrElementSquare (ElementTypePtr Element)
1267 void *ans = NULL;
1269 if (TEST_FLAG (LOCKFLAG, Element))
1270 return (NULL);
1271 PIN_LOOP (Element);
1273 ans = ClrPinSquare (Element, pin);
1275 END_LOOP;
1276 PAD_LOOP (Element);
1278 ans = ClrPadSquare (Element, pad);
1280 END_LOOP;
1281 return (ans);
1284 /* ---------------------------------------------------------------------------
1285 * changes the octagon flags of all pins of an element
1287 static void *
1288 ChangeElementOctagon (ElementTypePtr Element)
1290 void *result = NULL;
1292 if (TEST_FLAG (LOCKFLAG, Element))
1293 return (NULL);
1294 PIN_LOOP (Element);
1296 ChangePinOctagon (Element, pin);
1297 result = Element;
1299 END_LOOP;
1300 return (result);
1303 /* ---------------------------------------------------------------------------
1304 * sets the octagon flags of all pins of an element
1306 static void *
1307 SetElementOctagon (ElementTypePtr Element)
1309 void *result = NULL;
1311 if (TEST_FLAG (LOCKFLAG, Element))
1312 return (NULL);
1313 PIN_LOOP (Element);
1315 SetPinOctagon (Element, pin);
1316 result = Element;
1318 END_LOOP;
1319 return (result);
1322 /* ---------------------------------------------------------------------------
1323 * clears the octagon flags of all pins of an element
1325 static void *
1326 ClrElementOctagon (ElementTypePtr Element)
1328 void *result = NULL;
1330 if (TEST_FLAG (LOCKFLAG, Element))
1331 return (NULL);
1332 PIN_LOOP (Element);
1334 ClrPinOctagon (Element, pin);
1335 result = Element;
1337 END_LOOP;
1338 return (result);
1341 /* ---------------------------------------------------------------------------
1342 * changes the square flag of a pad
1344 static void *
1345 ChangePadSquare (ElementTypePtr Element, PadTypePtr Pad)
1347 if (TEST_FLAG (LOCKFLAG, Pad))
1348 return (NULL);
1349 ErasePad (Pad);
1350 AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, False);
1351 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
1352 AddObjectToFlagUndoList (PAD_TYPE, Element, Pad, Pad);
1353 TOGGLE_FLAG (SQUAREFLAG, Pad);
1354 AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, True);
1355 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
1356 DrawPad (Pad, 0);
1357 return (Pad);
1360 /* ---------------------------------------------------------------------------
1361 * sets the square flag of a pad
1363 static void *
1364 SetPadSquare (ElementTypePtr Element, PadTypePtr Pad)
1367 if (TEST_FLAG (LOCKFLAG, Pad) || TEST_FLAG (SQUAREFLAG, Pad))
1368 return (NULL);
1370 return (ChangePadSquare (Element, Pad));
1374 /* ---------------------------------------------------------------------------
1375 * clears the square flag of a pad
1377 static void *
1378 ClrPadSquare (ElementTypePtr Element, PadTypePtr Pad)
1381 if (TEST_FLAG (LOCKFLAG, Pad) || !TEST_FLAG (SQUAREFLAG, Pad))
1382 return (NULL);
1384 return (ChangePadSquare (Element, Pad));
1388 /* ---------------------------------------------------------------------------
1389 * changes the square flag of a pin
1391 static void *
1392 ChangePinSquare (ElementTypePtr Element, PinTypePtr Pin)
1394 if (TEST_FLAG (LOCKFLAG, Pin))
1395 return (NULL);
1396 ErasePin (Pin);
1397 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, False);
1398 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1399 AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin);
1400 TOGGLE_FLAG (SQUAREFLAG, Pin);
1401 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, True);
1402 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1403 DrawPin (Pin, 0);
1404 return (Pin);
1407 /* ---------------------------------------------------------------------------
1408 * sets the square flag of a pin
1410 static void *
1411 SetPinSquare (ElementTypePtr Element, PinTypePtr Pin)
1413 if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (SQUAREFLAG, Pin))
1414 return (NULL);
1416 return (ChangePinSquare (Element, Pin));
1419 /* ---------------------------------------------------------------------------
1420 * clears the square flag of a pin
1422 static void *
1423 ClrPinSquare (ElementTypePtr Element, PinTypePtr Pin)
1425 if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (SQUAREFLAG, Pin))
1426 return (NULL);
1428 return (ChangePinSquare (Element, Pin));
1431 /* ---------------------------------------------------------------------------
1432 * changes the octagon flag of a via
1434 static void *
1435 ChangeViaOctagon (PinTypePtr Via)
1437 if (TEST_FLAG (LOCKFLAG, Via))
1438 return (NULL);
1439 EraseVia (Via);
1440 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, False);
1441 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
1442 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
1443 TOGGLE_FLAG (OCTAGONFLAG, Via);
1444 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, True);
1445 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
1446 DrawVia (Via, 0);
1447 return (Via);
1450 /* ---------------------------------------------------------------------------
1451 * sets the octagon flag of a via
1453 static void *
1454 SetViaOctagon (PinTypePtr Via)
1456 if (TEST_FLAG (LOCKFLAG, Via) || TEST_FLAG (OCTAGONFLAG, Via))
1457 return (NULL);
1459 return (ChangeViaOctagon (Via));
1462 /* ---------------------------------------------------------------------------
1463 * clears the octagon flag of a via
1465 static void *
1466 ClrViaOctagon (PinTypePtr Via)
1468 if (TEST_FLAG (LOCKFLAG, Via) || !TEST_FLAG (OCTAGONFLAG, Via))
1469 return (NULL);
1471 return (ChangeViaOctagon (Via));
1474 /* ---------------------------------------------------------------------------
1475 * changes the octagon flag of a pin
1477 static void *
1478 ChangePinOctagon (ElementTypePtr Element, PinTypePtr Pin)
1480 if (TEST_FLAG (LOCKFLAG, Pin))
1481 return (NULL);
1482 ErasePin (Pin);
1483 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, False);
1484 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1485 AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin);
1486 TOGGLE_FLAG (OCTAGONFLAG, Pin);
1487 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, True);
1488 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1489 DrawPin (Pin, 0);
1490 return (Pin);
1493 /* ---------------------------------------------------------------------------
1494 * sets the octagon flag of a pin
1496 static void *
1497 SetPinOctagon (ElementTypePtr Element, PinTypePtr Pin)
1499 if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (OCTAGONFLAG, Pin))
1500 return (NULL);
1502 return (ChangePinOctagon (Element, Pin));
1505 /* ---------------------------------------------------------------------------
1506 * clears the octagon flag of a pin
1508 static void *
1509 ClrPinOctagon (ElementTypePtr Element, PinTypePtr Pin)
1511 if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (OCTAGONFLAG, Pin))
1512 return (NULL);
1514 return (ChangePinOctagon (Element, Pin));
1517 /* ---------------------------------------------------------------------------
1518 * changes the hole flag of a via
1520 Boolean
1521 ChangeHole (PinTypePtr Via)
1523 if (TEST_FLAG (LOCKFLAG, Via))
1524 return (False);
1525 EraseVia (Via);
1526 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
1527 TOGGLE_FLAG (HOLEFLAG, Via);
1528 if (TEST_FLAG (HOLEFLAG, Via))
1530 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
1531 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
1532 Via->Thickness = Via->Mask = Via->DrillingHole;
1533 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
1535 else
1537 AddObjectTo2ndSizeUndoList (VIA_TYPE, Via, Via, Via);
1538 Via->DrillingHole = Via->Thickness - MIN_PINORVIACOPPER;
1540 DrawVia (Via, 0);
1541 Draw ();
1542 return (True);
1545 /* ---------------------------------------------------------------------------
1546 * changes the nopaste flag of a pad
1548 Boolean
1549 ChangePaste (PadTypePtr Pad)
1551 if (TEST_FLAG (LOCKFLAG, Pad))
1552 return (False);
1553 ErasePad (Pad);
1554 AddObjectToFlagUndoList (PAD_TYPE, Pad, Pad, Pad);
1555 TOGGLE_FLAG (NOPASTEFLAG, Pad);
1556 DrawPad (Pad, 0);
1557 Draw ();
1558 return (True);
1561 /* ---------------------------------------------------------------------------
1562 * changes the CLEARPOLY flag of a polygon
1564 static void *
1565 ChangePolyClear (LayerTypePtr Layer, PolygonTypePtr Polygon)
1567 if (TEST_FLAG (LOCKFLAG, Polygon))
1568 return (NULL);
1569 AddObjectToClearPolyUndoList (POLYGON_TYPE, Layer, Polygon, Polygon, True);
1570 AddObjectToFlagUndoList (POLYGON_TYPE, Layer, Polygon, Polygon);
1571 TOGGLE_FLAG (CLEARPOLYFLAG, Polygon);
1572 InitClip (PCB->Data, Layer, Polygon);
1573 DrawPolygon (Layer, Polygon, 0);
1574 return (Polygon);
1577 /* ----------------------------------------------------------------------
1578 * changes the side of all selected and visible elements
1579 * returns True if anything has changed
1581 Boolean
1582 ChangeSelectedElementSide (void)
1584 Boolean change = False;
1586 /* setup identifiers */
1587 if (PCB->PinOn && PCB->ElementOn)
1588 ELEMENT_LOOP (PCB->Data);
1590 if (TEST_FLAG (SELECTEDFLAG, element))
1592 change |= ChangeElementSide (element, 0);
1595 END_LOOP;
1596 if (change)
1598 Draw ();
1599 IncrementUndoSerialNumber ();
1601 return (change);
1604 /* ----------------------------------------------------------------------
1605 * changes the thermals on all selected and visible pins
1606 * and/or vias. Returns True if anything has changed
1608 Boolean
1609 ChangeSelectedThermals (int types, int therm_style)
1611 Boolean change = False;
1613 Delta = therm_style;
1614 change = SelectedOperation (&ChangeThermalFunctions, False, types);
1615 if (change)
1617 Draw ();
1618 IncrementUndoSerialNumber ();
1620 return (change);
1623 /* ----------------------------------------------------------------------
1624 * changes the size of all selected and visible object types
1625 * returns True if anything has changed
1627 Boolean
1628 ChangeSelectedSize (int types, LocationType Difference, Boolean fixIt)
1630 Boolean change = False;
1632 /* setup identifiers */
1633 Absolute = (fixIt) ? Difference : 0;
1634 Delta = Difference;
1636 change = SelectedOperation (&ChangeSizeFunctions, False, types);
1637 if (change)
1639 Draw ();
1640 IncrementUndoSerialNumber ();
1642 return (change);
1645 /* ----------------------------------------------------------------------
1646 * changes the clearance size of all selected and visible objects
1647 * returns True if anything has changed
1649 Boolean
1650 ChangeSelectedClearSize (int types, LocationType Difference, Boolean fixIt)
1652 Boolean change = False;
1654 /* setup identifiers */
1655 Absolute = (fixIt) ? Difference : 0;
1656 Delta = Difference;
1657 if (TEST_FLAG (SHOWMASKFLAG, PCB))
1658 change = SelectedOperation (&ChangeMaskSizeFunctions, False, types);
1659 else
1660 change = SelectedOperation (&ChangeClearSizeFunctions, False, types);
1661 if (change)
1663 Draw ();
1664 IncrementUndoSerialNumber ();
1666 return (change);
1669 /* --------------------------------------------------------------------------
1670 * changes the 2nd size (drilling hole) of all selected and visible objects
1671 * returns True if anything has changed
1673 Boolean
1674 ChangeSelected2ndSize (int types, LocationType Difference, Boolean fixIt)
1676 Boolean change = False;
1678 /* setup identifiers */
1679 Absolute = (fixIt) ? Difference : 0;
1680 Delta = Difference;
1681 change = SelectedOperation (&Change2ndSizeFunctions, False, types);
1682 if (change)
1684 Draw ();
1685 IncrementUndoSerialNumber ();
1687 return (change);
1690 /* ----------------------------------------------------------------------
1691 * changes the clearance flag (join) of all selected and visible lines
1692 * and/or arcs. Returns True if anything has changed
1694 Boolean
1695 ChangeSelectedJoin (int types)
1697 Boolean change = False;
1699 change = SelectedOperation (&ChangeJoinFunctions, False, types);
1700 if (change)
1702 Draw ();
1703 IncrementUndoSerialNumber ();
1705 return (change);
1708 /* ----------------------------------------------------------------------
1709 * changes the clearance flag (join) of all selected and visible lines
1710 * and/or arcs. Returns True if anything has changed
1712 Boolean
1713 SetSelectedJoin (int types)
1715 Boolean change = False;
1717 change = SelectedOperation (&SetJoinFunctions, False, types);
1718 if (change)
1720 Draw ();
1721 IncrementUndoSerialNumber ();
1723 return (change);
1726 /* ----------------------------------------------------------------------
1727 * changes the clearance flag (join) of all selected and visible lines
1728 * and/or arcs. Returns True if anything has changed
1730 Boolean
1731 ClrSelectedJoin (int types)
1733 Boolean change = False;
1735 change = SelectedOperation (&ClrJoinFunctions, False, types);
1736 if (change)
1738 Draw ();
1739 IncrementUndoSerialNumber ();
1741 return (change);
1744 /* ----------------------------------------------------------------------
1745 * changes the square-flag of all selected and visible pins or pads
1746 * returns True if anything has changed
1748 Boolean
1749 ChangeSelectedSquare (int types)
1751 Boolean change = False;
1753 change = SelectedOperation (&ChangeSquareFunctions, False, types);
1754 if (change)
1756 Draw ();
1757 IncrementUndoSerialNumber ();
1759 return (change);
1762 /* ----------------------------------------------------------------------
1763 * sets the square-flag of all selected and visible pins or pads
1764 * returns True if anything has changed
1766 Boolean
1767 SetSelectedSquare (int types)
1769 Boolean change = False;
1771 change = SelectedOperation (&SetSquareFunctions, False, types);
1772 if (change)
1774 Draw ();
1775 IncrementUndoSerialNumber ();
1777 return (change);
1780 /* ----------------------------------------------------------------------
1781 * clears the square-flag of all selected and visible pins or pads
1782 * returns True if anything has changed
1784 Boolean
1785 ClrSelectedSquare (int types)
1787 Boolean change = False;
1789 change = SelectedOperation (&ClrSquareFunctions, False, types);
1790 if (change)
1792 Draw ();
1793 IncrementUndoSerialNumber ();
1795 return (change);
1798 /* ----------------------------------------------------------------------
1799 * changes the octagon-flag of all selected and visible pins and vias
1800 * returns True if anything has changed
1802 Boolean
1803 ChangeSelectedOctagon (int types)
1805 Boolean change = False;
1807 change = SelectedOperation (&ChangeOctagonFunctions, False, types);
1808 if (change)
1810 Draw ();
1811 IncrementUndoSerialNumber ();
1813 return (change);
1816 /* ----------------------------------------------------------------------
1817 * sets the octagon-flag of all selected and visible pins and vias
1818 * returns True if anything has changed
1820 Boolean
1821 SetSelectedOctagon (int types)
1823 Boolean change = False;
1825 change = SelectedOperation (&SetOctagonFunctions, False, types);
1826 if (change)
1828 Draw ();
1829 IncrementUndoSerialNumber ();
1831 return (change);
1834 /* ----------------------------------------------------------------------
1835 * clears the octagon-flag of all selected and visible pins and vias
1836 * returns True if anything has changed
1838 Boolean
1839 ClrSelectedOctagon (int types)
1841 Boolean change = False;
1843 change = SelectedOperation (&ClrOctagonFunctions, False, types);
1844 if (change)
1846 Draw ();
1847 IncrementUndoSerialNumber ();
1849 return (change);
1852 /* ----------------------------------------------------------------------
1853 * changes the hole-flag of all selected and visible vias
1854 * returns True if anything has changed
1856 Boolean
1857 ChangeSelectedHole (void)
1859 Boolean change = False;
1861 if (PCB->ViaOn)
1862 VIA_LOOP (PCB->Data);
1864 if (TEST_FLAG (SELECTEDFLAG, via))
1865 change |= ChangeHole (via);
1867 END_LOOP;
1868 if (change)
1870 Draw ();
1871 IncrementUndoSerialNumber ();
1873 return (change);
1876 /* ----------------------------------------------------------------------
1877 * changes the no paste-flag of all selected and visible pads
1878 * returns True if anything has changed
1880 Boolean
1881 ChangeSelectedPaste (void)
1883 Boolean change = False;
1885 ALLPAD_LOOP (PCB->Data);
1887 if (TEST_FLAG (SELECTEDFLAG, pad))
1888 change |= ChangePaste (pad);
1890 ENDALL_LOOP;
1891 if (change)
1893 Draw ();
1894 IncrementUndoSerialNumber ();
1896 return (change);
1900 /* ---------------------------------------------------------------------------
1901 * changes the size of the passed object
1902 * Returns True if anything is changed
1904 Boolean
1905 ChangeObjectSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
1906 LocationType Difference, Boolean fixIt)
1908 Boolean change;
1910 /* setup identifier */
1911 Absolute = (fixIt) ? Difference : 0;
1912 Delta = Difference;
1913 change =
1914 (ObjectOperation (&ChangeSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL);
1915 if (change)
1917 Draw ();
1918 IncrementUndoSerialNumber ();
1920 return (change);
1923 /* ---------------------------------------------------------------------------
1924 * changes the clearance size of the passed object
1925 * Returns True if anything is changed
1927 Boolean
1928 ChangeObjectClearSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
1929 LocationType Difference, Boolean fixIt)
1931 Boolean change;
1933 /* setup identifier */
1934 Absolute = (fixIt) ? Difference : 0;
1935 Delta = Difference;
1936 if (TEST_FLAG (SHOWMASKFLAG, PCB))
1937 change =
1938 (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
1939 NULL);
1940 else
1941 change =
1942 (ObjectOperation (&ChangeClearSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
1943 NULL);
1944 if (change)
1946 Draw ();
1947 IncrementUndoSerialNumber ();
1949 return (change);
1952 /* ---------------------------------------------------------------------------
1953 * changes the thermal of the passed object
1954 * Returns True if anything is changed
1957 Boolean
1958 ChangeObjectThermal (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
1959 int therm_type)
1961 Boolean change;
1963 Delta = Absolute = therm_type;
1964 change =
1965 (ObjectOperation (&ChangeThermalFunctions, Type, Ptr1, Ptr2, Ptr3) !=
1966 NULL);
1967 if (change)
1969 Draw ();
1970 IncrementUndoSerialNumber ();
1972 return (change);
1975 /* ---------------------------------------------------------------------------
1976 * changes the 2nd size of the passed object
1977 * Returns True if anything is changed
1979 Boolean
1980 ChangeObject2ndSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
1981 LocationType Difference, Boolean fixIt, Boolean incundo)
1983 Boolean change;
1985 /* setup identifier */
1986 Absolute = (fixIt) ? Difference : 0;
1987 Delta = Difference;
1988 change =
1989 (ObjectOperation (&Change2ndSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
1990 NULL);
1991 if (change)
1993 Draw ();
1994 if (incundo)
1995 IncrementUndoSerialNumber ();
1997 return (change);
2000 /* ---------------------------------------------------------------------------
2001 * changes the mask size of the passed object
2002 * Returns True if anything is changed
2004 Boolean
2005 ChangeObjectMaskSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2006 LocationType Difference, Boolean fixIt)
2008 Boolean change;
2010 /* setup identifier */
2011 Absolute = (fixIt) ? Difference : 0;
2012 Delta = Difference;
2013 change =
2014 (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2015 NULL);
2016 if (change)
2018 Draw ();
2019 IncrementUndoSerialNumber ();
2021 return (change);
2024 /* ---------------------------------------------------------------------------
2025 * changes the name of the passed object
2026 * returns the old name
2028 * The allocated memory isn't freed because the old string is used
2029 * by the undo module.
2031 void *
2032 ChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name)
2034 void *result;
2035 /* setup identifier */
2036 NewName = Name;
2037 if ((result =
2038 ObjectOperation (&ChangeNameFunctions, Type, Ptr1, Ptr2, Ptr3)));
2039 Draw ();
2040 return (result);
2043 /* ---------------------------------------------------------------------------
2044 * changes the clearance-flag of the passed object
2045 * Returns True if anything is changed
2047 Boolean
2048 ChangeObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2050 if (ObjectOperation (&ChangeJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2052 Draw ();
2053 IncrementUndoSerialNumber ();
2054 return (True);
2056 return (False);
2059 /* ---------------------------------------------------------------------------
2060 * sets the clearance-flag of the passed object
2061 * Returns True if anything is changed
2063 Boolean
2064 SetObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2066 if (ObjectOperation (&SetJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2068 Draw ();
2069 IncrementUndoSerialNumber ();
2070 return (True);
2072 return (False);
2075 /* ---------------------------------------------------------------------------
2076 * clears the clearance-flag of the passed object
2077 * Returns True if anything is changed
2079 Boolean
2080 ClrObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2082 if (ObjectOperation (&ClrJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2084 Draw ();
2085 IncrementUndoSerialNumber ();
2086 return (True);
2088 return (False);
2091 /* ---------------------------------------------------------------------------
2092 * changes the square-flag of the passed object
2093 * Returns True if anything is changed
2095 Boolean
2096 ChangeObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2098 if (ObjectOperation (&ChangeSquareFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2099 NULL)
2101 Draw ();
2102 IncrementUndoSerialNumber ();
2103 return (True);
2105 return (False);
2108 /* ---------------------------------------------------------------------------
2109 * sets the square-flag of the passed object
2110 * Returns True if anything is changed
2112 Boolean
2113 SetObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2115 if (ObjectOperation (&SetSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2117 Draw ();
2118 IncrementUndoSerialNumber ();
2119 return (True);
2121 return (False);
2124 /* ---------------------------------------------------------------------------
2125 * clears the square-flag of the passed object
2126 * Returns True if anything is changed
2128 Boolean
2129 ClrObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2131 if (ObjectOperation (&ClrSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2133 Draw ();
2134 IncrementUndoSerialNumber ();
2135 return (True);
2137 return (False);
2140 /* ---------------------------------------------------------------------------
2141 * changes the octagon-flag of the passed object
2142 * Returns True if anything is changed
2144 Boolean
2145 ChangeObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2147 if (ObjectOperation (&ChangeOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2148 NULL)
2150 Draw ();
2151 IncrementUndoSerialNumber ();
2152 return (True);
2154 return (False);
2157 /* ---------------------------------------------------------------------------
2158 * sets the octagon-flag of the passed object
2159 * Returns True if anything is changed
2161 Boolean
2162 SetObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2164 if (ObjectOperation (&SetOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2166 Draw ();
2167 IncrementUndoSerialNumber ();
2168 return (True);
2170 return (False);
2173 /* ---------------------------------------------------------------------------
2174 * clears the octagon-flag of the passed object
2175 * Returns True if anything is changed
2177 Boolean
2178 ClrObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2180 if (ObjectOperation (&ClrOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2182 Draw ();
2183 IncrementUndoSerialNumber ();
2184 return (True);
2186 return (False);
2189 /* ---------------------------------------------------------------------------
2190 * queries the user for a new object name and changes it
2192 * The allocated memory isn't freed because the old string is used
2193 * by the undo module.
2195 void *
2196 QueryInputAndChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2198 char *name = NULL;
2199 char msg[513];
2201 /* if passed an element name, make it an element reference instead */
2202 if (Type == ELEMENTNAME_TYPE)
2204 Type = ELEMENT_TYPE;
2205 Ptr2 = Ptr1;
2206 Ptr3 = Ptr1;
2208 switch (Type)
2210 case LINE_TYPE:
2211 name = gui->prompt_for (_("Linename:"),
2212 EMPTY (((LineTypePtr) Ptr2)->Number));
2213 break;
2215 case VIA_TYPE:
2216 name = gui->prompt_for (_("Vianame:"),
2217 EMPTY (((PinTypePtr) Ptr2)->Name));
2218 break;
2220 case PIN_TYPE:
2221 sprintf (msg, _("%s Pin Name:"), EMPTY (((PinTypePtr) Ptr2)->Number));
2222 name = gui->prompt_for (msg, EMPTY (((PinTypePtr) Ptr2)->Name));
2223 break;
2225 case PAD_TYPE:
2226 sprintf (msg, _("%s Pad Name:"), EMPTY (((PadTypePtr) Ptr2)->Number));
2227 name = gui->prompt_for (msg, EMPTY (((PadTypePtr) Ptr2)->Name));
2228 break;
2230 case TEXT_TYPE:
2231 name = gui->prompt_for (_("Enter text:"),
2232 EMPTY (((TextTypePtr) Ptr2)->TextString));
2233 break;
2235 case ELEMENT_TYPE:
2236 name = gui->prompt_for (_("Elementname:"),
2237 EMPTY (ELEMENT_NAME
2238 (PCB, (ElementTypePtr) Ptr2)));
2239 break;
2241 if (name)
2243 /* XXX Memory leak!! */
2244 char *old = ChangeObjectName (Type, Ptr1, Ptr2, Ptr3, name);
2245 if (old != (char *) -1)
2247 AddObjectToChangeNameUndoList (Type, Ptr1, Ptr2, Ptr3, old);
2248 IncrementUndoSerialNumber ();
2250 Draw ();
2251 return (Ptr3);
2253 return (NULL);
2256 /* ---------------------------------------------------------------------------
2257 * changes the maximum size of a layout
2258 * adjusts the scrollbars
2259 * releases the saved pixmap if necessary
2260 * and adjusts the cursor confinement box
2262 void
2263 ChangePCBSize (BDimension Width, BDimension Height)
2265 PCB->MaxWidth = Width;
2266 PCB->MaxHeight = Height;
2268 /* crosshair range is different if pastebuffer-mode
2269 * is enabled
2271 if (Settings.Mode == PASTEBUFFER_MODE)
2272 SetCrosshairRange (PASTEBUFFER->X - PASTEBUFFER->BoundingBox.X1,
2273 PASTEBUFFER->Y - PASTEBUFFER->BoundingBox.Y1,
2274 MAX (0,
2275 Width - (PASTEBUFFER->BoundingBox.X2 -
2276 PASTEBUFFER->X)), MAX (0,
2277 Height -
2278 (PASTEBUFFER->
2279 BoundingBox.Y2 -
2280 PASTEBUFFER->
2281 Y)));
2282 else
2283 SetCrosshairRange (0, 0, (LocationType) Width, (LocationType) Height);
2284 hid_action ("PCBChanged");
2287 /* ---------------------------------------------------------------------------
2288 * changes the mask size of a pad
2289 * returns TRUE if changed
2291 static void *
2292 ChangePadMaskSize (ElementTypePtr Element, PadTypePtr Pad)
2294 BDimension value = (Absolute) ? Absolute : Pad->Mask + Delta;
2296 value = MAX (value, 0);
2297 if (value == Pad->Mask && Absolute == 0)
2298 value = Pad->Thickness;
2299 if (value != Pad->Mask)
2301 AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad);
2302 ErasePad (Pad);
2303 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
2304 Pad->Mask = value;
2305 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
2306 DrawPad (Pad, 0);
2307 return (Pad);
2309 return (NULL);
2312 /* ---------------------------------------------------------------------------
2313 * changes the mask size of a pin
2314 * returns TRUE if changed
2316 static void *
2317 ChangePinMaskSize (ElementTypePtr Element, PinTypePtr Pin)
2319 BDimension value = (Absolute) ? Absolute : Pin->Mask + Delta;
2321 value = MAX (value, 0);
2322 if (value == Pin->Mask && Absolute == 0)
2323 value = Pin->Thickness;
2324 if (value != Pin->Mask)
2326 AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin);
2327 ErasePin (Pin);
2328 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
2329 Pin->Mask = value;
2330 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
2331 DrawPin (Pin, 0);
2332 return (Pin);
2334 return (NULL);
2337 /* ---------------------------------------------------------------------------
2338 * changes the mask size of a via
2339 * returns TRUE if changed
2341 static void *
2342 ChangeViaMaskSize (PinTypePtr Via)
2344 BDimension value;
2346 value = (Absolute) ? Absolute : Via->Mask + Delta;
2347 value = MAX (value, 0);
2348 if (value != Via->Mask)
2350 AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via);
2351 EraseVia (Via);
2352 r_delete_entry (PCB->Data->via_tree, &Via->BoundingBox);
2353 Via->Mask = value;
2354 SetPinBoundingBox (Via);
2355 r_insert_entry (PCB->Data->via_tree, &Via->BoundingBox, 0);
2356 DrawVia (Via, 0);
2357 return (Via);
2359 return (NULL);