Fix bug with expanding text.
[geda-pcb/pcjc2.git] / src / change.c
blob1aee7d87ba4b74a7a673501f8ad8187e7bb655cf
1 /*!
2 * \file src/change.c
4 * \brief Functions used to change object properties.
6 * <hr>
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 1994,1995,1996, 2005 Thomas Nau
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Contact addresses for paper mail and Email:
29 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
30 * Thomas.Nau@rz.uni-ulm.de
33 #ifdef HAVE_CONFIG_H
34 #include "config.h"
35 #endif
37 #include <stdlib.h>
38 #include <stdio.h>
40 #include "global.h"
42 #include "change.h"
43 #include "create.h"
44 #include "crosshair.h"
45 #include "data.h"
46 #include "draw.h"
47 #include "error.h"
48 #include "mymem.h"
49 #include "misc.h"
50 #include "mirror.h"
51 #include "polygon.h"
52 #include "rats.h"
53 #include "remove.h"
54 #include "rtree.h"
55 #include "search.h"
56 #include "select.h"
57 #include "set.h"
58 #include "thermal.h"
59 #include "undo.h"
61 #ifdef HAVE_LIBDMALLOC
62 #include <dmalloc.h>
63 #endif
65 /* ---------------------------------------------------------------------------
66 * some local prototypes
68 static void *ChangePinSize (ElementType *, PinType *);
69 static void *ChangePinClearSize (ElementType *, PinType *);
70 static void *ChangePinMaskSize (ElementType *, PinType *);
71 static void *ChangePadSize (ElementType *, PadType *);
72 static void *ChangePadClearSize (ElementType *, PadType *);
73 static void *ChangePadMaskSize (ElementType *, PadType *);
74 static void *ChangePin2ndSize (ElementType *, PinType *);
75 static void *ChangeElement2ndSize (ElementType *);
76 static void *ChangeViaSize (PinType *);
77 static void *ChangeVia2ndSize (PinType *);
78 static void *ChangeViaClearSize (PinType *);
79 static void *ChangeViaMaskSize (PinType *);
80 static void *ChangeLineSize (LayerType *, LineType *);
81 static void *ChangeLineClearSize (LayerType *, LineType *);
82 static void *ChangePolygonClearSize (LayerType *, PolygonType *);
83 static void *ChangeArcSize (LayerType *, ArcType *);
84 static void *ChangeArcClearSize (LayerType *, ArcType *);
85 static void *ChangeTextSize (LayerType *, TextType *);
86 static void *ChangeElementSize (ElementType *);
87 static void *ChangeElementNameSize (ElementType *);
88 static void *ChangePinName (ElementType *, PinType *);
89 static void *ChangePadName (ElementType *, PadType *);
90 static void *ChangeViaName (PinType *);
91 static void *ChangeLineName (LayerType *, LineType *);
92 static void *ChangeElementName (ElementType *);
93 static void *ChangeTextName (LayerType *, TextType *);
94 static void *ChangeElementSquare (ElementType *);
95 static void *SetElementSquare (ElementType *);
96 static void *ClrElementSquare (ElementType *);
97 static void *ChangeElementOctagon (ElementType *);
98 static void *SetElementOctagon (ElementType *);
99 static void *ClrElementOctagon (ElementType *);
100 static void *ChangePinSquare (ElementType *, PinType *);
101 static void *SetPinSquare (ElementType *, PinType *);
102 static void *ClrPinSquare (ElementType *, PinType *);
103 static void *ChangePinOctagon (ElementType *, PinType *);
104 static void *SetPinOctagon (ElementType *, PinType *);
105 static void *ClrPinOctagon (ElementType *, PinType *);
106 static void *ChangeViaOctagon (PinType *);
107 static void *SetViaOctagon (PinType *);
108 static void *ClrViaOctagon (PinType *);
109 static void *ChangePadSquare (ElementType *, PadType *);
110 static void *SetPadSquare (ElementType *, PadType *);
111 static void *ClrPadSquare (ElementType *, PadType *);
112 static void *ChangeViaThermal (PinType *);
113 static void *ChangePinThermal (ElementType *, PinType *);
114 static void *ChangeLineJoin (LayerType *, LineType *);
115 static void *SetLineJoin (LayerType *, LineType *);
116 static void *ClrLineJoin (LayerType *, LineType *);
117 static void *ChangeArcJoin (LayerType *, ArcType *);
118 static void *SetArcJoin (LayerType *, ArcType *);
119 static void *ClrArcJoin (LayerType *, ArcType *);
120 static void *ChangeTextJoin (LayerType *, TextType *);
121 static void *SetTextJoin (LayerType *, TextType *);
122 static void *ClrTextJoin (LayerType *, TextType *);
123 static void *ChangePolyClear (LayerType *, PolygonType *);
125 /* ---------------------------------------------------------------------------
126 * some local identifiers
128 static int Delta; /* change of size */
129 static int Absolute; /* Absolute size */
130 static char *NewName; /* new name */
131 static ObjectFunctionType ChangeSizeFunctions = {
132 ChangeLineSize,
133 ChangeTextSize,
134 ChangePolyClear,
135 ChangeViaSize,
136 ChangeElementSize, /* changes silk screen line width */
137 ChangeElementNameSize,
138 ChangePinSize,
139 ChangePadSize,
140 NULL,
141 NULL,
142 ChangeArcSize,
143 NULL
145 static ObjectFunctionType Change2ndSizeFunctions = {
146 NULL,
147 NULL,
148 NULL,
149 ChangeVia2ndSize,
150 ChangeElement2ndSize,
151 NULL,
152 ChangePin2ndSize,
153 NULL,
154 NULL,
155 NULL,
156 NULL,
157 NULL
159 static ObjectFunctionType ChangeThermalFunctions = {
160 NULL,
161 NULL,
162 NULL,
163 ChangeViaThermal,
164 NULL,
165 NULL,
166 ChangePinThermal,
167 NULL,
168 NULL,
169 NULL,
170 NULL,
171 NULL
173 static ObjectFunctionType ChangeClearSizeFunctions = {
174 ChangeLineClearSize,
175 NULL,
176 ChangePolygonClearSize, /* just to tell the user not to :-) */
177 ChangeViaClearSize,
178 NULL,
179 NULL,
180 ChangePinClearSize,
181 ChangePadClearSize,
182 NULL,
183 NULL,
184 ChangeArcClearSize,
185 NULL
187 static ObjectFunctionType ChangeNameFunctions = {
188 ChangeLineName,
189 ChangeTextName,
190 NULL,
191 ChangeViaName,
192 ChangeElementName,
193 NULL,
194 ChangePinName,
195 ChangePadName,
196 NULL,
197 NULL,
198 NULL,
199 NULL
201 static ObjectFunctionType ChangeSquareFunctions = {
202 NULL,
203 NULL,
204 NULL,
205 NULL,
206 ChangeElementSquare,
207 NULL,
208 ChangePinSquare,
209 ChangePadSquare,
210 NULL,
211 NULL,
212 NULL,
213 NULL
215 static ObjectFunctionType ChangeJoinFunctions = {
216 ChangeLineJoin,
217 ChangeTextJoin,
218 NULL,
219 NULL,
220 NULL,
221 NULL,
222 NULL,
223 NULL,
224 NULL,
225 NULL,
226 ChangeArcJoin,
227 NULL
229 static ObjectFunctionType ChangeOctagonFunctions = {
230 NULL,
231 NULL,
232 NULL,
233 ChangeViaOctagon,
234 ChangeElementOctagon,
235 NULL,
236 ChangePinOctagon,
237 NULL,
238 NULL,
239 NULL,
240 NULL,
241 NULL
243 static ObjectFunctionType ChangeMaskSizeFunctions = {
244 NULL,
245 NULL,
246 NULL,
247 ChangeViaMaskSize,
248 #if 0
249 ChangeElementMaskSize,
250 #else
251 NULL,
252 #endif
253 NULL,
254 ChangePinMaskSize,
255 ChangePadMaskSize,
256 NULL,
257 NULL,
258 NULL,
259 NULL
261 static ObjectFunctionType SetSquareFunctions = {
262 NULL,
263 NULL,
264 NULL,
265 NULL,
266 SetElementSquare,
267 NULL,
268 SetPinSquare,
269 SetPadSquare,
270 NULL,
271 NULL,
272 NULL,
273 NULL
275 static ObjectFunctionType SetJoinFunctions = {
276 SetLineJoin,
277 SetTextJoin,
278 NULL,
279 NULL,
280 NULL,
281 NULL,
282 NULL,
283 NULL,
284 NULL,
285 NULL,
286 SetArcJoin,
287 NULL
289 static ObjectFunctionType SetOctagonFunctions = {
290 NULL,
291 NULL,
292 NULL,
293 SetViaOctagon,
294 SetElementOctagon,
295 NULL,
296 SetPinOctagon,
297 NULL,
298 NULL,
299 NULL,
300 NULL,
301 NULL
303 static ObjectFunctionType ClrSquareFunctions = {
304 NULL,
305 NULL,
306 NULL,
307 NULL,
308 ClrElementSquare,
309 NULL,
310 ClrPinSquare,
311 ClrPadSquare,
312 NULL,
313 NULL,
314 NULL,
315 NULL
317 static ObjectFunctionType ClrJoinFunctions = {
318 ClrLineJoin,
319 ClrTextJoin,
320 NULL,
321 NULL,
322 NULL,
323 NULL,
324 NULL,
325 NULL,
326 NULL,
327 NULL,
328 ClrArcJoin,
329 NULL
331 static ObjectFunctionType ClrOctagonFunctions = {
332 NULL,
333 NULL,
334 NULL,
335 ClrViaOctagon,
336 ClrElementOctagon,
337 NULL,
338 ClrPinOctagon,
339 NULL,
340 NULL,
341 NULL,
342 NULL,
343 NULL
347 * \brief Changes the thermal on a via.
349 * \return TRUE if changed.
351 static void *
352 ChangeViaThermal (PinType *Via)
354 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, false);
355 RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Via);
356 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
357 if (!Delta) /* remove the thermals */
358 CLEAR_THERM (INDEXOFCURRENT, Via);
359 else
360 ASSIGN_THERM (INDEXOFCURRENT, Delta, Via);
361 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, true);
362 ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Via);
363 DrawVia (Via);
364 return Via;
368 * \brief Changes the thermal on a pin.
370 * \return TRUE if changed.
372 static void *
373 ChangePinThermal (ElementType *element, PinType *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);
385 return Pin;
389 * \brief Changes the size of a via.
391 * \return TRUE if changed.
393 static void *
394 ChangeViaSize (PinType *Via)
396 Coord value = Absolute ? Absolute : Via->Thickness + Delta;
398 if (TEST_FLAG (LOCKFLAG, Via))
399 return (NULL);
400 if (!TEST_FLAG (HOLEFLAG, Via) && value <= MAX_PINORVIASIZE &&
401 value >= MIN_PINORVIASIZE &&
402 value >= Via->DrillingHole + MIN_PINORVIACOPPER &&
403 value != Via->Thickness)
405 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
406 EraseVia (Via);
407 r_delete_entry (PCB->Data->via_tree, (BoxType *) Via);
408 RestoreToPolygon (PCB->Data, PIN_TYPE, Via, Via);
409 if (Via->Mask)
411 AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via);
412 Via->Mask += value - Via->Thickness;
414 Via->Thickness = value;
415 SetPinBoundingBox (Via);
416 r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0);
417 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
418 DrawVia (Via);
419 return (Via);
421 return (NULL);
425 * \brief Changes the drilling hole of a via.
427 * \return TRUE if changed.
429 static void *
430 ChangeVia2ndSize (PinType *Via)
432 Coord value = (Absolute) ? Absolute : Via->DrillingHole + Delta;
434 if (TEST_FLAG (LOCKFLAG, Via))
435 return (NULL);
436 if (value <= MAX_PINORVIASIZE &&
437 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Via) ||
438 value <=
439 Via->Thickness - MIN_PINORVIACOPPER)
440 && value != Via->DrillingHole)
442 AddObjectTo2ndSizeUndoList (VIA_TYPE, Via, Via, Via);
443 EraseVia (Via);
444 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
445 Via->DrillingHole = value;
446 if (TEST_FLAG (HOLEFLAG, Via))
448 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
449 Via->Thickness = value;
451 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
452 DrawVia (Via);
453 return (Via);
455 return (NULL);
459 * \brief Changes the clearance size of a via.
461 * \return TRUE if changed.
463 static void *
464 ChangeViaClearSize (PinType *Via)
466 Coord value = (Absolute) ? Absolute : Via->Clearance + Delta;
468 if (TEST_FLAG (LOCKFLAG, Via))
469 return (NULL);
470 value = MIN (MAX_LINESIZE, value);
471 if (value < 0)
472 value = 0;
473 if (Delta < 0 && value < PCB->Bloat * 2)
474 value = 0;
475 if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2)
476 value = PCB->Bloat * 2 + 2;
477 if (Via->Clearance == value)
478 return NULL;
479 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
480 AddObjectToClearSizeUndoList (VIA_TYPE, Via, Via, Via);
481 EraseVia (Via);
482 r_delete_entry (PCB->Data->via_tree, (BoxType *) Via);
483 Via->Clearance = value;
484 SetPinBoundingBox (Via);
485 r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0);
486 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
487 DrawVia (Via);
488 Via->Element = NULL;
489 return (Via);
494 * \brief Changes the size of a pin.
496 * \return TRUE if changed.
498 static void *
499 ChangePinSize (ElementType *Element, PinType *Pin)
501 Coord value = (Absolute) ? Absolute : Pin->Thickness + Delta;
503 if (TEST_FLAG (LOCKFLAG, Pin))
504 return (NULL);
505 if (!TEST_FLAG (HOLEFLAG, Pin) && value <= MAX_PINORVIASIZE &&
506 value >= MIN_PINORVIASIZE &&
507 value >= Pin->DrillingHole + MIN_PINORVIACOPPER &&
508 value != Pin->Thickness)
510 AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin);
511 AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin);
512 ErasePin (Pin);
513 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
514 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
515 Pin->Mask += value - Pin->Thickness;
516 Pin->Thickness = value;
517 /* SetElementBB updates all associated rtrees */
518 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
519 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
520 DrawPin (Pin);
521 return (Pin);
523 return (NULL);
527 * \brief Changes the clearance size of a pin.
529 * \return TRUE if changed.
531 static void *
532 ChangePinClearSize (ElementType *Element, PinType *Pin)
534 Coord value = (Absolute) ? Absolute : Pin->Clearance + Delta;
536 if (TEST_FLAG (LOCKFLAG, Pin))
537 return (NULL);
538 value = MIN (MAX_LINESIZE, value);
539 if (value < 0)
540 value = 0;
541 if (Delta < 0 && value < PCB->Bloat * 2)
542 value = 0;
543 if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2)
544 value = PCB->Bloat * 2 + 2;
545 if (Pin->Clearance == value)
546 return NULL;
547 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
548 AddObjectToClearSizeUndoList (PIN_TYPE, Element, Pin, Pin);
549 ErasePin (Pin);
550 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
551 Pin->Clearance = value;
552 /* SetElementBB updates all associated rtrees */
553 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
554 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
555 DrawPin (Pin);
556 return (Pin);
560 * \brief Changes the size of a pad.
562 * \return TRUE if changed.
564 static void *
565 ChangePadSize (ElementType *Element, PadType *Pad)
567 Coord value = (Absolute) ? Absolute : Pad->Thickness + Delta;
569 if (TEST_FLAG (LOCKFLAG, Pad))
570 return (NULL);
571 if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Thickness)
573 AddObjectToSizeUndoList (PAD_TYPE, Element, Pad, Pad);
574 AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad);
575 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
576 ErasePad (Pad);
577 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
578 Pad->Mask += value - Pad->Thickness;
579 Pad->Thickness = value;
580 /* SetElementBB updates all associated rtrees */
581 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
582 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
583 DrawPad (Pad);
584 return (Pad);
586 return (NULL);
590 * \brief Changes the clearance size of a pad.
592 * \return TRUE if changed.
594 static void *
595 ChangePadClearSize (ElementType *Element, PadType *Pad)
597 Coord value = (Absolute) ? Absolute : Pad->Clearance + Delta;
599 if (TEST_FLAG (LOCKFLAG, Pad))
600 return (NULL);
601 value = MIN (MAX_LINESIZE, value);
602 if (value < 0)
603 value = 0;
604 if (Delta < 0 && value < PCB->Bloat * 2)
605 value = 0;
606 if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2)
607 value = PCB->Bloat * 2 + 2;
608 if (value == Pad->Clearance)
609 return NULL;
610 AddObjectToClearSizeUndoList (PAD_TYPE, Element, Pad, Pad);
611 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
612 ErasePad (Pad);
613 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
614 Pad->Clearance = value;
615 /* SetElementBB updates all associated rtrees */
616 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
617 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
618 DrawPad (Pad);
619 return Pad;
623 * \brief Changes the drilling hole of all pins of an element.
625 * \return TRUE if changed.
627 static void *
628 ChangeElement2ndSize (ElementType *Element)
630 bool changed = false;
631 Coord value;
633 if (TEST_FLAG (LOCKFLAG, Element))
634 return (NULL);
635 PIN_LOOP (Element);
637 value = (Absolute) ? Absolute : pin->DrillingHole + Delta;
638 if (value <= MAX_PINORVIASIZE &&
639 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, pin) ||
640 value <=
641 pin->Thickness -
642 MIN_PINORVIACOPPER)
643 && value != pin->DrillingHole)
645 changed = true;
646 AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, pin, pin);
647 ErasePin (pin);
648 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, pin);
649 pin->DrillingHole = value;
650 if (TEST_FLAG (HOLEFLAG, pin))
652 AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin);
653 pin->Thickness = value;
655 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, pin);
656 DrawPin (pin);
659 END_LOOP;
660 if (changed)
661 return (Element);
662 else
663 return (NULL);
667 * \brief Changes the drilling hole of a pin.
669 * \return TRUE if changed.
671 static void *
672 ChangePin2ndSize (ElementType *Element, PinType *Pin)
674 Coord value = (Absolute) ? Absolute : Pin->DrillingHole + Delta;
676 if (TEST_FLAG (LOCKFLAG, Pin))
677 return (NULL);
678 if (value <= MAX_PINORVIASIZE &&
679 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Pin) ||
680 value <=
681 Pin->Thickness - MIN_PINORVIACOPPER)
682 && value != Pin->DrillingHole)
684 AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, Pin, Pin);
685 ErasePin (Pin);
686 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
687 Pin->DrillingHole = value;
688 if (TEST_FLAG (HOLEFLAG, Pin))
690 AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin);
691 Pin->Thickness = value;
693 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
694 DrawPin (Pin);
695 return (Pin);
697 return (NULL);
701 * \brief Changes the size of a line.
703 * \return TRUE if changed.
705 static void *
706 ChangeLineSize (LayerType *Layer, LineType *Line)
708 Coord value = (Absolute) ? Absolute : Line->Thickness + Delta;
710 if (TEST_FLAG (LOCKFLAG, Line))
711 return (NULL);
712 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
713 value != Line->Thickness)
715 AddObjectToSizeUndoList (LINE_TYPE, Layer, Line, Line);
716 EraseLine (Line);
717 r_delete_entry (Layer->line_tree, (BoxType *) Line);
718 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
719 Line->Thickness = value;
720 SetLineBoundingBox (Line);
721 r_insert_entry (Layer->line_tree, (BoxType *) Line, 0);
722 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
723 DrawLine (Layer, Line);
724 return (Line);
726 return (NULL);
730 * \brief Changes the clearance size of a line.
732 * \return TRUE if changed.
734 static void *
735 ChangeLineClearSize (LayerType *Layer, LineType *Line)
737 Coord value = (Absolute) ? Absolute : Line->Clearance + Delta;
739 if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line))
740 return (NULL);
741 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
742 if (value != Line->Clearance)
744 AddObjectToClearSizeUndoList (LINE_TYPE, Layer, Line, Line);
745 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
746 EraseLine (Line);
747 r_delete_entry (Layer->line_tree, (BoxType *) Line);
748 Line->Clearance = value;
749 if (Line->Clearance == 0)
751 CLEAR_FLAG (CLEARLINEFLAG, Line);
752 Line->Clearance = MIL_TO_COORD(10);
754 SetLineBoundingBox (Line);
755 r_insert_entry (Layer->line_tree, (BoxType *) Line, 0);
756 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
757 DrawLine (Layer, Line);
758 return (Line);
760 return (NULL);
764 * \brief Handle attempts to change the clearance of a polygon.
766 static void *
767 ChangePolygonClearSize (LayerType *Layer, PolygonType *poly)
769 static int shown_this_message = 0;
770 if (!shown_this_message)
772 gui->confirm_dialog (_("To change the clearance of objects in a polygon, "
773 "change the objects, not the polygon.\n"
774 "Hint: To set a minimum clearance for a group of objects, "
775 "select them all then :MinClearGap(Selected,=10,mil)"),
776 "Ok", NULL);
777 shown_this_message = 1;
780 return (NULL);
784 * \brief Changes the size of an arc.
786 * \return TRUE if changed.
788 static void *
789 ChangeArcSize (LayerType *Layer, ArcType *Arc)
791 Coord value = (Absolute) ? Absolute : Arc->Thickness + Delta;
793 if (TEST_FLAG (LOCKFLAG, Arc))
794 return (NULL);
795 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
796 value != Arc->Thickness)
798 AddObjectToSizeUndoList (ARC_TYPE, Layer, Arc, Arc);
799 EraseArc (Arc);
800 r_delete_entry (Layer->arc_tree, (BoxType *) Arc);
801 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
802 Arc->Thickness = value;
803 SetArcBoundingBox (Arc);
804 r_insert_entry (Layer->arc_tree, (BoxType *) Arc, 0);
805 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
806 DrawArc (Layer, Arc);
807 return (Arc);
809 return (NULL);
813 * \brief Changes the clearance size of an arc.
815 * \return TRUE if changed.
817 static void *
818 ChangeArcClearSize (LayerType *Layer, ArcType *Arc)
820 Coord value = (Absolute) ? Absolute : Arc->Clearance + Delta;
822 if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc))
823 return (NULL);
824 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
825 if (value != Arc->Clearance)
827 AddObjectToClearSizeUndoList (ARC_TYPE, Layer, Arc, Arc);
828 EraseArc (Arc);
829 r_delete_entry (Layer->arc_tree, (BoxType *) Arc);
830 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
831 Arc->Clearance = value;
832 if (Arc->Clearance == 0)
834 CLEAR_FLAG (CLEARLINEFLAG, Arc);
835 Arc->Clearance = MIL_TO_COORD(10);
837 SetArcBoundingBox (Arc);
838 r_insert_entry (Layer->arc_tree, (BoxType *) Arc, 0);
839 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
840 DrawArc (Layer, Arc);
841 return (Arc);
843 return (NULL);
847 * \brief Changes the scaling factor of a text object.
849 * \return TRUE if changed.
851 static void *
852 ChangeTextSize (LayerType *Layer, TextType *Text)
854 int value = (Absolute != 0 ? 0 : Text->Scale) +
855 (double)(Absolute != 0 ? Absolute : Delta)
856 / (double)FONT_CAPHEIGHT * 100.;
858 if (TEST_FLAG (LOCKFLAG, Text))
859 return (NULL);
860 if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE &&
861 value != Text->Scale)
863 AddObjectToSizeUndoList (TEXT_TYPE, Layer, Text, Text);
864 EraseText (Layer, Text);
865 r_delete_entry (Layer->text_tree, (BoxType *) Text);
866 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
867 Text->Scale = value;
868 SetTextBoundingBox (&PCB->Font, Text);
869 r_insert_entry (Layer->text_tree, (BoxType *) Text, 0);
870 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
871 DrawText (Layer, Text);
872 return (Text);
874 return (NULL);
878 * \brief Changes the scaling factor of an element's outline.
880 * \return TRUE if changed.
882 static void *
883 ChangeElementSize (ElementType *Element)
885 Coord value;
886 bool changed = false;
888 if (TEST_FLAG (LOCKFLAG, Element))
889 return (NULL);
890 if (PCB->ElementOn)
891 EraseElement (Element);
892 ELEMENTLINE_LOOP (Element);
894 value = (Absolute) ? Absolute : line->Thickness + Delta;
895 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
896 value != line->Thickness)
898 AddObjectToSizeUndoList (ELEMENTLINE_TYPE, Element, line, line);
899 line->Thickness = value;
900 changed = true;
903 END_LOOP;
904 ARC_LOOP (Element);
906 value = (Absolute) ? Absolute : arc->Thickness + Delta;
907 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
908 value != arc->Thickness)
910 AddObjectToSizeUndoList (ELEMENTARC_TYPE, Element, arc, arc);
911 arc->Thickness = value;
912 changed = true;
915 END_LOOP;
916 if (PCB->ElementOn)
918 DrawElement (Element);
920 if (changed)
921 return (Element);
922 return (NULL);
926 * \brief Changes the scaling factor of a elementname object.
928 * \return TRUE if changed.
930 static void *
931 ChangeElementNameSize (ElementType *Element)
933 int value = (Absolute != 0 ? 0 : DESCRIPTION_TEXT (Element).Scale) +
934 (double)(Absolute != 0 ? Absolute : Delta)
935 / (double)FONT_CAPHEIGHT * 100.;
937 if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
938 return (NULL);
939 if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE)
941 EraseElementName (Element);
942 ELEMENTTEXT_LOOP (Element);
944 AddObjectToSizeUndoList (ELEMENTNAME_TYPE, Element, text, text);
945 r_delete_entry (PCB->Data->name_tree[n], (BoxType *) text);
946 text->Scale = value;
947 SetTextBoundingBox (&PCB->Font, text);
948 r_insert_entry (PCB->Data->name_tree[n], (BoxType *) text, 0);
950 END_LOOP;
951 DrawElementName (Element);
952 return (Element);
954 return (NULL);
958 * \brief Changes the name of a via.
960 static void *
961 ChangeViaName (PinType *Via)
963 char *old = Via->Name;
965 if (TEST_FLAG (DISPLAYNAMEFLAG, Via))
967 ErasePinName (Via);
968 Via->Name = NewName;
969 DrawPinName (Via);
971 else
972 Via->Name = NewName;
973 return (old);
977 * \brief Changes the name of a pin.
979 static void *
980 ChangePinName (ElementType *Element, PinType *Pin)
982 char *old = Pin->Name;
984 (void) Element; /* get rid of 'unused...' warnings */
985 if (TEST_FLAG (DISPLAYNAMEFLAG, Pin))
987 ErasePinName (Pin);
988 Pin->Name = NewName;
989 DrawPinName (Pin);
991 else
992 Pin->Name = NewName;
993 return (old);
997 * \brief Changes the name of a pad.
999 static void *
1000 ChangePadName (ElementType *Element, PadType *Pad)
1002 char *old = Pad->Name;
1004 (void) Element; /* get rid of 'unused...' warnings */
1005 if (TEST_FLAG (DISPLAYNAMEFLAG, Pad))
1007 ErasePadName (Pad);
1008 Pad->Name = NewName;
1009 DrawPadName (Pad);
1011 else
1012 Pad->Name = NewName;
1013 return (old);
1017 * \brief Changes the name of a line.
1019 static void *
1020 ChangeLineName (LayerType *Layer, LineType *Line)
1022 char *old = Line->Number;
1024 (void) Layer;
1025 Line->Number = NewName;
1026 return (old);
1030 * \brief Changes the layout-name of an element.
1032 * Change the specified text on an element, either on the board (give
1033 * PCB, PCB->Data) or in a buffer (give NULL, Buffer->Data).
1035 * \return The old string is returned, and must be properly freed by the
1036 * caller.
1038 char *
1039 ChangeElementText (PCBType *pcb, DataType *data, ElementType *Element, int which, char *new_name)
1041 char *old = Element->Name[which].TextString;
1043 #ifdef DEBUG
1044 printf("In ChangeElementText, updating old TextString %s to %s\n", old, new_name);
1045 #endif
1047 if (pcb && which == NAME_INDEX (pcb))
1048 EraseElementName (Element);
1050 r_delete_entry (data->name_tree[which],
1051 & Element->Name[which].BoundingBox);
1053 Element->Name[which].TextString = new_name;
1054 SetTextBoundingBox (&PCB->Font, &Element->Name[which]);
1056 r_insert_entry (data->name_tree[which],
1057 & Element->Name[which].BoundingBox, 0);
1059 if (pcb && which == NAME_INDEX (pcb))
1060 DrawElementName (Element);
1062 return old;
1065 static void *
1066 ChangeElementName (ElementType *Element)
1068 if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
1069 return (NULL);
1070 if (NAME_INDEX (PCB) == NAMEONPCB_INDEX)
1072 if (TEST_FLAG (UNIQUENAMEFLAG, PCB) &&
1073 UniqueElementName (PCB->Data, NewName) != NewName)
1075 Message (_("Error: The name \"%s\" is not unique!\n"), NewName);
1076 return ((char *) -1);
1080 return ChangeElementText (PCB, PCB->Data, Element, NAME_INDEX (PCB), NewName);
1084 * \brief Sets data of a text object and calculates bounding box.
1086 * Memory must have already been allocated.
1087 * The one for the new string is allocated.
1089 * \return True if the string has been changed.
1091 static void *
1092 ChangeTextName (LayerType *Layer, TextType *Text)
1094 char *old = Text->TextString;
1096 if (TEST_FLAG (LOCKFLAG, Text))
1097 return (NULL);
1098 EraseText (Layer, Text);
1099 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1100 Text->TextString = NewName;
1102 /* calculate size of the bounding box */
1103 SetTextBoundingBox (&PCB->Font, Text);
1104 r_insert_entry(Layer->text_tree, (BoxType *) Text, 0);
1105 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1106 DrawText (Layer, Text);
1107 return (old);
1111 * \brief Changes the name of a layout; memory has to be already
1112 * allocated.
1114 bool
1115 ChangeLayoutName (char *Name)
1117 free (PCB->Name);
1118 PCB->Name = Name;
1119 hid_action ("PCBChanged");
1120 return (true);
1124 * \brief Changes the side of the board an element is on.
1126 * \return TRUE if done.
1128 bool
1129 ChangeElementSide (ElementType *Element, Coord yoff)
1131 if (TEST_FLAG (LOCKFLAG, Element))
1132 return (false);
1133 EraseElement (Element);
1134 AddObjectToMirrorUndoList (ELEMENT_TYPE, Element, Element, Element, yoff);
1135 MirrorElementCoordinates (PCB->Data, Element, yoff);
1136 DrawElement (Element);
1137 return (true);
1141 * \brief Changes the name of a layer; memory has to be already
1142 * allocated.
1144 bool
1145 ChangeLayerName (LayerType *Layer, char *Name)
1147 free (CURRENT->Name);
1148 CURRENT->Name = Name;
1149 hid_action ("LayersChanged");
1150 return (true);
1154 * \brief Changes the clearance flag of a line.
1156 static void *
1157 ChangeLineJoin (LayerType *Layer, LineType *Line)
1159 if (TEST_FLAG (LOCKFLAG, Line))
1160 return (NULL);
1161 EraseLine (Line);
1162 if (TEST_FLAG(CLEARLINEFLAG, Line))
1164 AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, false);
1165 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
1167 AddObjectToFlagUndoList (LINE_TYPE, Layer, Line, Line);
1168 TOGGLE_FLAG (CLEARLINEFLAG, Line);
1169 if (TEST_FLAG(CLEARLINEFLAG, Line))
1171 AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, true);
1172 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
1174 DrawLine (Layer, Line);
1175 return (Line);
1179 * \brief Sets the clearance flag of a line.
1181 static void *
1182 SetLineJoin (LayerType *Layer, LineType *Line)
1184 if (TEST_FLAG (LOCKFLAG, Line) || TEST_FLAG (CLEARLINEFLAG, Line))
1185 return (NULL);
1186 return ChangeLineJoin (Layer, Line);
1190 * \brief Clears the clearance flag of a line.
1192 static void *
1193 ClrLineJoin (LayerType *Layer, LineType *Line)
1195 if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line))
1196 return (NULL);
1197 return ChangeLineJoin (Layer, Line);
1201 * \brief Changes the clearance flag of an arc.
1203 static void *
1204 ChangeArcJoin (LayerType *Layer, ArcType *Arc)
1206 if (TEST_FLAG (LOCKFLAG, Arc))
1207 return (NULL);
1208 EraseArc (Arc);
1209 if (TEST_FLAG (CLEARLINEFLAG, Arc))
1211 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
1212 AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, false);
1214 AddObjectToFlagUndoList (ARC_TYPE, Layer, Arc, Arc);
1215 TOGGLE_FLAG (CLEARLINEFLAG, Arc);
1216 if (TEST_FLAG (CLEARLINEFLAG, Arc))
1218 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
1219 AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, true);
1221 DrawArc (Layer, Arc);
1222 return (Arc);
1226 * \brief Sets the clearance flag of an arc.
1228 static void *
1229 SetArcJoin (LayerType *Layer, ArcType *Arc)
1231 if (TEST_FLAG (LOCKFLAG, Arc) || TEST_FLAG (CLEARLINEFLAG, Arc))
1232 return (NULL);
1233 return ChangeArcJoin (Layer, Arc);
1237 * \brief Clears the clearance flag of an arc.
1239 static void *
1240 ClrArcJoin (LayerType *Layer, ArcType *Arc)
1242 if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc))
1243 return (NULL);
1244 return ChangeArcJoin (Layer, Arc);
1248 * \brief Changes the clearance flag of a text.
1250 static void *
1251 ChangeTextJoin (LayerType *Layer, TextType *Text)
1253 if (TEST_FLAG (LOCKFLAG, Text))
1254 return (NULL);
1255 EraseText (Layer, Text);
1256 if (TEST_FLAG(CLEARLINEFLAG, Text))
1258 AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, false);
1259 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1261 AddObjectToFlagUndoList (LINE_TYPE, Layer, Text, Text);
1262 TOGGLE_FLAG (CLEARLINEFLAG, Text);
1263 if (TEST_FLAG(CLEARLINEFLAG, Text))
1265 AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, true);
1266 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1268 DrawText (Layer, Text);
1269 return (Text);
1273 * \brief Sets the clearance flag of a text.
1275 static void *
1276 SetTextJoin (LayerType *Layer, TextType *Text)
1278 if (TEST_FLAG (LOCKFLAG, Text) || TEST_FLAG (CLEARLINEFLAG, Text))
1279 return (NULL);
1280 return ChangeTextJoin (Layer, Text);
1284 * \brief Clears the clearance flag of a text.
1286 static void *
1287 ClrTextJoin (LayerType *Layer, TextType *Text)
1289 if (TEST_FLAG (LOCKFLAG, Text) || !TEST_FLAG (CLEARLINEFLAG, Text))
1290 return (NULL);
1291 return ChangeTextJoin (Layer, Text);
1295 * \brief Changes the square flag of all pins on an element.
1297 static void *
1298 ChangeElementSquare (ElementType *Element)
1300 void *ans = NULL;
1302 if (TEST_FLAG (LOCKFLAG, Element))
1303 return (NULL);
1304 PIN_LOOP (Element);
1306 ans = ChangePinSquare (Element, pin);
1308 END_LOOP;
1309 PAD_LOOP (Element);
1311 ans = ChangePadSquare (Element, pad);
1313 END_LOOP;
1314 return (ans);
1318 * \brief Sets the square flag of all pins on an element.
1320 static void *
1321 SetElementSquare (ElementType *Element)
1323 void *ans = NULL;
1325 if (TEST_FLAG (LOCKFLAG, Element))
1326 return (NULL);
1327 PIN_LOOP (Element);
1329 ans = SetPinSquare (Element, pin);
1331 END_LOOP;
1332 PAD_LOOP (Element);
1334 ans = SetPadSquare (Element, pad);
1336 END_LOOP;
1337 return (ans);
1341 * \brief Clears the square flag of all pins on an element.
1343 static void *
1344 ClrElementSquare (ElementType *Element)
1346 void *ans = NULL;
1348 if (TEST_FLAG (LOCKFLAG, Element))
1349 return (NULL);
1350 PIN_LOOP (Element);
1352 ans = ClrPinSquare (Element, pin);
1354 END_LOOP;
1355 PAD_LOOP (Element);
1357 ans = ClrPadSquare (Element, pad);
1359 END_LOOP;
1360 return (ans);
1364 * \brief Changes the octagon flags of all pins of an element.
1366 static void *
1367 ChangeElementOctagon (ElementType *Element)
1369 void *result = NULL;
1371 if (TEST_FLAG (LOCKFLAG, Element))
1372 return (NULL);
1373 PIN_LOOP (Element);
1375 ChangePinOctagon (Element, pin);
1376 result = Element;
1378 END_LOOP;
1379 return (result);
1383 * \brief Sets the octagon flags of all pins of an element.
1385 static void *
1386 SetElementOctagon (ElementType *Element)
1388 void *result = NULL;
1390 if (TEST_FLAG (LOCKFLAG, Element))
1391 return (NULL);
1392 PIN_LOOP (Element);
1394 SetPinOctagon (Element, pin);
1395 result = Element;
1397 END_LOOP;
1398 return (result);
1402 * \brief Clears the octagon flags of all pins of an element.
1404 static void *
1405 ClrElementOctagon (ElementType *Element)
1407 void *result = NULL;
1409 if (TEST_FLAG (LOCKFLAG, Element))
1410 return (NULL);
1411 PIN_LOOP (Element);
1413 ClrPinOctagon (Element, pin);
1414 result = Element;
1416 END_LOOP;
1417 return (result);
1421 * \brief Changes the square flag of a pad.
1423 static void *
1424 ChangePadSquare (ElementType *Element, PadType *Pad)
1426 if (TEST_FLAG (LOCKFLAG, Pad))
1427 return (NULL);
1428 ErasePad (Pad);
1429 AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, false);
1430 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
1431 AddObjectToFlagUndoList (PAD_TYPE, Element, Pad, Pad);
1432 TOGGLE_FLAG (SQUAREFLAG, Pad);
1433 AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, true);
1434 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
1435 DrawPad (Pad);
1436 return (Pad);
1440 * \brief Sets the square flag of a pad.
1442 static void *
1443 SetPadSquare (ElementType *Element, PadType *Pad)
1446 if (TEST_FLAG (LOCKFLAG, Pad) || TEST_FLAG (SQUAREFLAG, Pad))
1447 return (NULL);
1449 return (ChangePadSquare (Element, Pad));
1454 * \brief Clears the square flag of a pad.
1456 static void *
1457 ClrPadSquare (ElementType *Element, PadType *Pad)
1460 if (TEST_FLAG (LOCKFLAG, Pad) || !TEST_FLAG (SQUAREFLAG, Pad))
1461 return (NULL);
1463 return (ChangePadSquare (Element, Pad));
1468 * \brief Changes the square flag of a pin.
1470 static void *
1471 ChangePinSquare (ElementType *Element, PinType *Pin)
1473 if (TEST_FLAG (LOCKFLAG, Pin))
1474 return (NULL);
1475 ErasePin (Pin);
1476 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false);
1477 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1478 AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin);
1479 TOGGLE_FLAG (SQUAREFLAG, Pin);
1480 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true);
1481 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1482 DrawPin (Pin);
1483 return (Pin);
1487 * \brief Sets the square flag of a pin.
1489 static void *
1490 SetPinSquare (ElementType *Element, PinType *Pin)
1492 if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (SQUAREFLAG, Pin))
1493 return (NULL);
1495 return (ChangePinSquare (Element, Pin));
1499 * \brief Clears the square flag of a pin.
1501 static void *
1502 ClrPinSquare (ElementType *Element, PinType *Pin)
1504 if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (SQUAREFLAG, Pin))
1505 return (NULL);
1507 return (ChangePinSquare (Element, Pin));
1511 * \brief Changes the octagon flag of a via.
1513 static void *
1514 ChangeViaOctagon (PinType *Via)
1516 if (TEST_FLAG (LOCKFLAG, Via))
1517 return (NULL);
1518 EraseVia (Via);
1519 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, false);
1520 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
1521 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
1522 TOGGLE_FLAG (OCTAGONFLAG, Via);
1523 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, true);
1524 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
1525 DrawVia (Via);
1526 return (Via);
1530 * \brief Sets the octagon flag of a via.
1532 static void *
1533 SetViaOctagon (PinType *Via)
1535 if (TEST_FLAG (LOCKFLAG, Via) || TEST_FLAG (OCTAGONFLAG, Via))
1536 return (NULL);
1538 return (ChangeViaOctagon (Via));
1542 * \brief Clears the octagon flag of a via.
1544 static void *
1545 ClrViaOctagon (PinType *Via)
1547 if (TEST_FLAG (LOCKFLAG, Via) || !TEST_FLAG (OCTAGONFLAG, Via))
1548 return (NULL);
1550 return (ChangeViaOctagon (Via));
1554 * \brief Changes the octagon flag of a pin.
1556 static void *
1557 ChangePinOctagon (ElementType *Element, PinType *Pin)
1559 if (TEST_FLAG (LOCKFLAG, Pin))
1560 return (NULL);
1561 ErasePin (Pin);
1562 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false);
1563 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1564 AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin);
1565 TOGGLE_FLAG (OCTAGONFLAG, Pin);
1566 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true);
1567 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1568 DrawPin (Pin);
1569 return (Pin);
1573 * \brief Sets the octagon flag of a pin.
1575 static void *
1576 SetPinOctagon (ElementType *Element, PinType *Pin)
1578 if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (OCTAGONFLAG, Pin))
1579 return (NULL);
1581 return (ChangePinOctagon (Element, Pin));
1585 * \brief Clears the octagon flag of a pin.
1587 static void *
1588 ClrPinOctagon (ElementType *Element, PinType *Pin)
1590 if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (OCTAGONFLAG, Pin))
1591 return (NULL);
1593 return (ChangePinOctagon (Element, Pin));
1597 * \brief Changes the hole flag of a via.
1599 bool
1600 ChangeHole (PinType *Via)
1602 if (TEST_FLAG (LOCKFLAG, Via))
1603 return (false);
1604 EraseVia (Via);
1605 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
1606 AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via);
1607 r_delete_entry (PCB->Data->via_tree, (BoxType *) Via);
1608 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
1609 TOGGLE_FLAG (HOLEFLAG, Via);
1611 if (TEST_FLAG (HOLEFLAG, Via))
1613 /* A tented via becomes an minimally untented hole. An untented
1614 via retains its mask clearance. */
1615 if (Via->Mask > Via->Thickness)
1617 Via->Mask = (Via->DrillingHole
1618 + (Via->Mask - Via->Thickness));
1620 else if (Via->Mask < Via->DrillingHole)
1622 Via->Mask = Via->DrillingHole + 2 * MASKFRAME;
1625 else
1627 Via->Mask = (Via->Thickness
1628 + (Via->Mask - Via->DrillingHole));
1631 SetPinBoundingBox (Via);
1632 r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0);
1633 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
1634 DrawVia (Via);
1635 Draw ();
1636 return (true);
1640 * \brief Changes the nopaste flag of a pad.
1642 bool
1643 ChangePaste (PadType *Pad)
1645 if (TEST_FLAG (LOCKFLAG, Pad))
1646 return (false);
1647 ErasePad (Pad);
1648 AddObjectToFlagUndoList (PAD_TYPE, Pad, Pad, Pad);
1649 TOGGLE_FLAG (NOPASTEFLAG, Pad);
1650 DrawPad (Pad);
1651 Draw ();
1652 return (true);
1656 * \brief Changes the CLEARPOLY flag of a polygon.
1658 static void *
1659 ChangePolyClear (LayerType *Layer, PolygonType *Polygon)
1661 if (TEST_FLAG (LOCKFLAG, Polygon))
1662 return (NULL);
1663 AddObjectToClearPolyUndoList (POLYGON_TYPE, Layer, Polygon, Polygon, true);
1664 AddObjectToFlagUndoList (POLYGON_TYPE, Layer, Polygon, Polygon);
1665 TOGGLE_FLAG (CLEARPOLYFLAG, Polygon);
1666 InitClip (PCB->Data, Layer, Polygon);
1667 DrawPolygon (Layer, Polygon);
1668 return (Polygon);
1672 * \brief Changes the side of all selected and visible elements.
1674 * \return True if anything has changed.
1676 bool
1677 ChangeSelectedElementSide (void)
1679 bool change = false;
1681 /* setup identifiers */
1682 if (PCB->PinOn && PCB->ElementOn)
1683 ELEMENT_LOOP (PCB->Data);
1685 if (TEST_FLAG (SELECTEDFLAG, element))
1687 change |= ChangeElementSide (element, 0);
1690 END_LOOP;
1691 if (change)
1693 Draw ();
1694 IncrementUndoSerialNumber ();
1696 return (change);
1700 * \brief Changes the thermals on all selected and visible pins and/or
1701 * vias.
1703 * \return True if anything has changed.
1705 bool
1706 ChangeSelectedThermals (int types, int therm_style)
1708 bool change = false;
1710 Delta = therm_style;
1711 change = SelectedOperation (&ChangeThermalFunctions, false, types);
1712 if (change)
1714 Draw ();
1715 IncrementUndoSerialNumber ();
1717 return (change);
1721 * \brief Changes the size of all selected and visible object types.
1723 * \return True if anything has changed.
1725 bool
1726 ChangeSelectedSize (int types, Coord Difference, bool fixIt)
1728 bool change = false;
1730 /* setup identifiers */
1731 Absolute = (fixIt) ? Difference : 0;
1732 Delta = Difference;
1734 change = SelectedOperation (&ChangeSizeFunctions, false, types);
1735 if (change)
1737 Draw ();
1738 IncrementUndoSerialNumber ();
1740 return (change);
1744 * \brief Changes the clearance size of all selected and visible objects.
1746 * \return True if anything has changed.
1748 bool
1749 ChangeSelectedClearSize (int types, Coord Difference, bool fixIt)
1751 bool change = false;
1753 /* setup identifiers */
1754 Absolute = (fixIt) ? Difference : 0;
1755 Delta = Difference;
1756 if (TEST_FLAG (SHOWMASKFLAG, PCB))
1757 change = SelectedOperation (&ChangeMaskSizeFunctions, false, types);
1758 else
1759 change = SelectedOperation (&ChangeClearSizeFunctions, false, types);
1760 if (change)
1762 Draw ();
1763 IncrementUndoSerialNumber ();
1765 return (change);
1769 * \brief Changes the 2nd size (drilling hole) of all selected and
1770 * visible objects.
1772 * \return True if anything has changed.
1774 bool
1775 ChangeSelected2ndSize (int types, Coord Difference, bool fixIt)
1777 bool change = false;
1779 /* setup identifiers */
1780 Absolute = (fixIt) ? Difference : 0;
1781 Delta = Difference;
1782 change = SelectedOperation (&Change2ndSizeFunctions, false, types);
1783 if (change)
1785 Draw ();
1786 IncrementUndoSerialNumber ();
1788 return (change);
1792 * \brief Changes the clearance flag (join) of all selected and visible
1793 * lines and/or arcs.
1795 * \return True if anything has changed.
1797 bool
1798 ChangeSelectedJoin (int types)
1800 bool change = false;
1802 change = SelectedOperation (&ChangeJoinFunctions, false, types);
1803 if (change)
1805 Draw ();
1806 IncrementUndoSerialNumber ();
1808 return (change);
1812 * \brief Changes the clearance flag (join) of all selected and visible
1813 * lines and/or arcs.
1815 * \return True if anything has changed.
1817 bool
1818 SetSelectedJoin (int types)
1820 bool change = false;
1822 change = SelectedOperation (&SetJoinFunctions, false, types);
1823 if (change)
1825 Draw ();
1826 IncrementUndoSerialNumber ();
1828 return (change);
1832 * \brief Changes the clearance flag (join) of all selected and visible
1833 * lines and/or arcs.
1835 * \return True if anything has changed.
1837 bool
1838 ClrSelectedJoin (int types)
1840 bool change = false;
1842 change = SelectedOperation (&ClrJoinFunctions, false, types);
1843 if (change)
1845 Draw ();
1846 IncrementUndoSerialNumber ();
1848 return (change);
1852 * \brief Changes the square-flag of all selected and visible pins or
1853 * pads.
1855 * \return True if anything has changed.
1857 bool
1858 ChangeSelectedSquare (int types)
1860 bool change = false;
1862 change = SelectedOperation (&ChangeSquareFunctions, false, types);
1863 if (change)
1865 Draw ();
1866 IncrementUndoSerialNumber ();
1868 return (change);
1872 * \brief Sets the square-flag of all selected and visible pins or pads.
1874 * \return True if anything has changed.
1876 bool
1877 SetSelectedSquare (int types)
1879 bool change = false;
1881 change = SelectedOperation (&SetSquareFunctions, false, types);
1882 if (change)
1884 Draw ();
1885 IncrementUndoSerialNumber ();
1887 return (change);
1891 * \brief Clears the square-flag of all selected and visible pins or
1892 * pads.
1894 * \return True if anything has changed.
1896 bool
1897 ClrSelectedSquare (int types)
1899 bool change = false;
1901 change = SelectedOperation (&ClrSquareFunctions, false, types);
1902 if (change)
1904 Draw ();
1905 IncrementUndoSerialNumber ();
1907 return (change);
1911 * \brief Changes the octagon-flag of all selected and visible pins and
1912 * vias.
1914 * \return True if anything has changed.
1916 bool
1917 ChangeSelectedOctagon (int types)
1919 bool change = false;
1921 change = SelectedOperation (&ChangeOctagonFunctions, false, types);
1922 if (change)
1924 Draw ();
1925 IncrementUndoSerialNumber ();
1927 return (change);
1931 * \brief Sets the octagon-flag of all selected and visible pins and
1932 * vias.
1934 * \return True if anything has changed.
1936 bool
1937 SetSelectedOctagon (int types)
1939 bool change = false;
1941 change = SelectedOperation (&SetOctagonFunctions, false, types);
1942 if (change)
1944 Draw ();
1945 IncrementUndoSerialNumber ();
1947 return (change);
1951 * \brief Clears the octagon-flag of all selected and visible pins and
1952 * vias.
1954 * \return True if anything has changed.
1956 bool
1957 ClrSelectedOctagon (int types)
1959 bool change = false;
1961 change = SelectedOperation (&ClrOctagonFunctions, false, types);
1962 if (change)
1964 Draw ();
1965 IncrementUndoSerialNumber ();
1967 return (change);
1971 * \brief Changes the hole-flag of all selected and visible vias.
1973 * \return True if anything has changed.
1975 bool
1976 ChangeSelectedHole (void)
1978 bool change = false;
1980 if (PCB->ViaOn)
1981 VIA_LOOP (PCB->Data);
1983 if (TEST_FLAG (SELECTEDFLAG, via))
1984 change |= ChangeHole (via);
1986 END_LOOP;
1987 if (change)
1989 Draw ();
1990 IncrementUndoSerialNumber ();
1992 return (change);
1996 * \brief Changes the no paste-flag of all selected and visible pads.
1998 * \return True if anything has changed.
2000 bool
2001 ChangeSelectedPaste (void)
2003 bool change = false;
2005 ALLPAD_LOOP (PCB->Data);
2007 if (TEST_FLAG (SELECTEDFLAG, pad))
2008 change |= ChangePaste (pad);
2010 ENDALL_LOOP;
2011 if (change)
2013 Draw ();
2014 IncrementUndoSerialNumber ();
2016 return (change);
2021 * \brief Changes the size of the passed object.
2023 * \return True if anything is changed.
2025 bool
2026 ChangeObjectSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2027 Coord Difference, bool fixIt)
2029 bool change;
2031 /* setup identifier */
2032 Absolute = (fixIt) ? Difference : 0;
2033 Delta = Difference;
2034 change =
2035 (ObjectOperation (&ChangeSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL);
2036 if (change)
2038 Draw ();
2039 IncrementUndoSerialNumber ();
2041 return (change);
2045 * \brief Changes the clearance size of the passed object.
2047 * \return True if anything is changed.
2049 bool
2050 ChangeObjectClearSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2051 Coord Difference, bool fixIt)
2053 bool change;
2055 /* setup identifier */
2056 Absolute = (fixIt) ? Difference : 0;
2057 Delta = Difference;
2058 if (TEST_FLAG (SHOWMASKFLAG, PCB))
2059 change =
2060 (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2061 NULL);
2062 else
2063 change =
2064 (ObjectOperation (&ChangeClearSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2065 NULL);
2066 if (change)
2068 Draw ();
2069 IncrementUndoSerialNumber ();
2071 return (change);
2075 * \brief Changes the thermal of the passed object.
2077 * \return True if anything is changed.
2080 bool
2081 ChangeObjectThermal (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2082 int therm_type)
2084 bool change;
2086 Delta = Absolute = therm_type;
2087 change =
2088 (ObjectOperation (&ChangeThermalFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2089 NULL);
2090 if (change)
2092 Draw ();
2093 IncrementUndoSerialNumber ();
2095 return (change);
2099 * \brief Changes the 2nd size of the passed object.
2101 * \return True if anything is changed.
2103 bool
2104 ChangeObject2ndSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2105 Coord Difference, bool fixIt, bool incundo)
2107 bool change;
2109 /* setup identifier */
2110 Absolute = (fixIt) ? Difference : 0;
2111 Delta = Difference;
2112 change =
2113 (ObjectOperation (&Change2ndSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2114 NULL);
2115 if (change)
2117 Draw ();
2118 if (incundo)
2119 IncrementUndoSerialNumber ();
2121 return (change);
2125 * \brief Changes the mask size of the passed object.
2127 * \return True if anything is changed.
2129 bool
2130 ChangeObjectMaskSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2131 Coord Difference, bool fixIt)
2133 bool change;
2135 /* setup identifier */
2136 Absolute = (fixIt) ? Difference : 0;
2137 Delta = Difference;
2138 change =
2139 (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2140 NULL);
2141 if (change)
2143 Draw ();
2144 IncrementUndoSerialNumber ();
2146 return (change);
2150 * \brief Changes the name of the passed object.
2152 * \warning The allocated memory isn't freed because the old string is used
2153 * by the undo module.
2155 * \return The old name.
2157 void *
2158 ChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name)
2160 void *result;
2161 /* setup identifier */
2162 NewName = Name;
2163 result = ObjectOperation (&ChangeNameFunctions, Type, Ptr1, Ptr2, Ptr3);
2164 Draw ();
2165 return (result);
2169 * \brief Changes the clearance-flag of the passed object.
2171 * \return True if anything is changed.
2173 bool
2174 ChangeObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2176 if (ObjectOperation (&ChangeJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2178 Draw ();
2179 IncrementUndoSerialNumber ();
2180 return (true);
2182 return (false);
2186 * \brief Sets the clearance-flag of the passed object.
2188 * \return True if anything is changed.
2190 bool
2191 SetObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2193 if (ObjectOperation (&SetJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2195 Draw ();
2196 IncrementUndoSerialNumber ();
2197 return (true);
2199 return (false);
2203 * \brief Clears the clearance-flag of the passed object.
2205 * \return True if anything is changed.
2207 bool
2208 ClrObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2210 if (ObjectOperation (&ClrJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2212 Draw ();
2213 IncrementUndoSerialNumber ();
2214 return (true);
2216 return (false);
2220 * \brief Changes the square-flag of the passed object.
2222 * \return True if anything is changed.
2224 bool
2225 ChangeObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2227 if (ObjectOperation (&ChangeSquareFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2228 NULL)
2230 Draw ();
2231 IncrementUndoSerialNumber ();
2232 return (true);
2234 return (false);
2238 * \brief Sets the square-flag of the passed object.
2240 * \return True if anything is changed.
2242 bool
2243 SetObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2245 if (ObjectOperation (&SetSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2247 Draw ();
2248 IncrementUndoSerialNumber ();
2249 return (true);
2251 return (false);
2255 * \brief Clears the square-flag of the passed object.
2257 * \return True if anything is changed.
2259 bool
2260 ClrObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2262 if (ObjectOperation (&ClrSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2264 Draw ();
2265 IncrementUndoSerialNumber ();
2266 return (true);
2268 return (false);
2272 * \brief Changes the octagon-flag of the passed object.
2274 * \return True if anything is changed.
2276 bool
2277 ChangeObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2279 if (ObjectOperation (&ChangeOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2280 NULL)
2282 Draw ();
2283 IncrementUndoSerialNumber ();
2284 return (true);
2286 return (false);
2290 * \brief Sets the octagon-flag of the passed object.
2292 * \return True if anything is changed.
2294 bool
2295 SetObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2297 if (ObjectOperation (&SetOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2299 Draw ();
2300 IncrementUndoSerialNumber ();
2301 return (true);
2303 return (false);
2307 * \brief Clears the octagon-flag of the passed object.
2309 * \return True if anything is changed.
2311 bool
2312 ClrObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2314 if (ObjectOperation (&ClrOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2316 Draw ();
2317 IncrementUndoSerialNumber ();
2318 return (true);
2320 return (false);
2324 * \bief Queries the user for a new object name and changes it.
2326 * \warning The allocated memory isn't freed because the old string is used
2327 * by the undo module.
2329 void *
2330 QueryInputAndChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2332 char *name = NULL;
2333 char msg[513];
2335 /* if passed an element name, make it an element reference instead */
2336 if (Type == ELEMENTNAME_TYPE)
2338 Type = ELEMENT_TYPE;
2339 Ptr2 = Ptr1;
2340 Ptr3 = Ptr1;
2342 switch (Type)
2344 case LINE_TYPE:
2345 name = gui->prompt_for (_("Linename:"),
2346 EMPTY (((LineType *) Ptr2)->Number));
2347 break;
2349 case VIA_TYPE:
2350 name = gui->prompt_for (_("Vianame:"),
2351 EMPTY (((PinType *) Ptr2)->Name));
2352 break;
2354 case PIN_TYPE:
2355 sprintf (msg, _("%s Pin Name:"), EMPTY (((PinType *) Ptr2)->Number));
2356 name = gui->prompt_for (msg, EMPTY (((PinType *) Ptr2)->Name));
2357 break;
2359 case PAD_TYPE:
2360 sprintf (msg, _("%s Pad Name:"), EMPTY (((PadType *) Ptr2)->Number));
2361 name = gui->prompt_for (msg, EMPTY (((PadType *) Ptr2)->Name));
2362 break;
2364 case TEXT_TYPE:
2365 name = gui->prompt_for (_("Enter text:"),
2366 EMPTY (((TextType *) Ptr2)->TextString));
2367 break;
2369 case ELEMENT_TYPE:
2370 name = gui->prompt_for (_("Elementname:"),
2371 EMPTY (ELEMENT_NAME
2372 (PCB, (ElementType *) Ptr2)));
2373 break;
2375 if (name)
2377 /* NB: ChangeObjectName takes ownership of the passed memory */
2378 char *old = (char *)ChangeObjectName (Type, Ptr1, Ptr2, Ptr3, name);
2379 if (old != (char *) -1)
2381 AddObjectToChangeNameUndoList (Type, Ptr1, Ptr2, Ptr3, old);
2382 IncrementUndoSerialNumber ();
2384 Draw ();
2385 return (Ptr3);
2387 return (NULL);
2391 * \brief Changes the maximum size of a layout, adjusts the scrollbars,
2392 * releases the saved pixmap if necessary and adjusts the cursor
2393 * confinement box.
2395 void
2396 ChangePCBSize (Coord Width, Coord Height)
2398 PCB->MaxWidth = Width;
2399 PCB->MaxHeight = Height;
2401 /* crosshair range is different if pastebuffer-mode
2402 * is enabled
2404 if (Settings.Mode == PASTEBUFFER_MODE)
2405 SetCrosshairRange (PASTEBUFFER->X - PASTEBUFFER->BoundingBox.X1,
2406 PASTEBUFFER->Y - PASTEBUFFER->BoundingBox.Y1,
2407 MAX (0,
2408 Width - (PASTEBUFFER->BoundingBox.X2 -
2409 PASTEBUFFER->X)), MAX (0,
2410 Height -
2411 (PASTEBUFFER->
2412 BoundingBox.Y2 -
2413 PASTEBUFFER->
2414 Y)));
2415 else
2416 SetCrosshairRange (0, 0, Width, Height);
2417 hid_action ("PCBChanged");
2421 * \brief Changes the mask size of a pad.
2423 * \return TRUE if changed.
2425 static void *
2426 ChangePadMaskSize (ElementType *Element, PadType *Pad)
2428 Coord value = (Absolute) ? Absolute : Pad->Mask + Delta;
2430 value = MAX (value, 0);
2431 if (value == Pad->Mask && Absolute == 0)
2432 value = Pad->Thickness;
2433 if (value != Pad->Mask)
2435 AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad);
2436 ErasePad (Pad);
2437 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
2438 Pad->Mask = value;
2439 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
2440 DrawPad (Pad);
2441 return (Pad);
2443 return (NULL);
2447 * \brief Changes the mask size of a pin.
2449 * \return TRUE if changed.
2451 static void *
2452 ChangePinMaskSize (ElementType *Element, PinType *Pin)
2454 Coord value = (Absolute) ? Absolute : Pin->Mask + Delta;
2456 value = MAX (value, 0);
2457 if (value == Pin->Mask && Absolute == 0)
2458 value = Pin->Thickness;
2459 if (value != Pin->Mask)
2461 AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin);
2462 ErasePin (Pin);
2463 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
2464 Pin->Mask = value;
2465 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
2466 DrawPin (Pin);
2467 return (Pin);
2469 return (NULL);
2473 * \brief Changes the mask size of a via.
2475 * \return TRUE if changed.
2477 static void *
2478 ChangeViaMaskSize (PinType *Via)
2480 Coord value;
2482 value = (Absolute) ? Absolute : Via->Mask + Delta;
2483 value = MAX (value, 0);
2484 if (value != Via->Mask)
2486 AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via);
2487 EraseVia (Via);
2488 r_delete_entry (PCB->Data->via_tree, &Via->BoundingBox);
2489 Via->Mask = value;
2490 SetPinBoundingBox (Via);
2491 r_insert_entry (PCB->Data->via_tree, &Via->BoundingBox, 0);
2492 DrawVia (Via);
2493 return (Via);
2495 return (NULL);