Introduce POLYGONHOLE_MODE for creating holes in polygons
[geda-pcb/gde.git] / src / change.c
blob5546f1fc78f76e993bc23168fb1f3a21f6dd9fc7
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 *ChangePolygonClearSize (LayerTypePtr, PolygonTypePtr);
86 static void *ChangeArcSize (LayerTypePtr, ArcTypePtr);
87 static void *ChangeArcClearSize (LayerTypePtr, ArcTypePtr);
88 static void *ChangeTextSize (LayerTypePtr, TextTypePtr);
89 static void *ChangeElementSize (ElementTypePtr);
90 static void *ChangeElementNameSize (ElementTypePtr);
91 static void *ChangePinName (ElementTypePtr, PinTypePtr);
92 static void *ChangePadName (ElementTypePtr, PadTypePtr);
93 static void *ChangeViaName (PinTypePtr);
94 static void *ChangeLineName (LayerTypePtr, LineTypePtr);
95 static void *ChangeElementName (ElementTypePtr);
96 static void *ChangeTextName (LayerTypePtr, TextTypePtr);
97 static void *ChangeElementSquare (ElementTypePtr);
98 static void *SetElementSquare (ElementTypePtr);
99 static void *ClrElementSquare (ElementTypePtr);
100 static void *ChangeElementOctagon (ElementTypePtr);
101 static void *SetElementOctagon (ElementTypePtr);
102 static void *ClrElementOctagon (ElementTypePtr);
103 static void *ChangePinSquare (ElementTypePtr, PinTypePtr);
104 static void *SetPinSquare (ElementTypePtr, PinTypePtr);
105 static void *ClrPinSquare (ElementTypePtr, PinTypePtr);
106 static void *ChangePinOctagon (ElementTypePtr, PinTypePtr);
107 static void *SetPinOctagon (ElementTypePtr, PinTypePtr);
108 static void *ClrPinOctagon (ElementTypePtr, PinTypePtr);
109 static void *ChangeViaOctagon (PinTypePtr);
110 static void *SetViaOctagon (PinTypePtr);
111 static void *ClrViaOctagon (PinTypePtr);
112 static void *ChangePadSquare (ElementTypePtr, PadTypePtr);
113 static void *SetPadSquare (ElementTypePtr, PadTypePtr);
114 static void *ClrPadSquare (ElementTypePtr, PadTypePtr);
115 static void *ChangeViaThermal (PinTypePtr);
116 static void *ChangePinThermal (ElementTypePtr, PinTypePtr);
117 static void *ChangeLineJoin (LayerTypePtr, LineTypePtr);
118 static void *SetLineJoin (LayerTypePtr, LineTypePtr);
119 static void *ClrLineJoin (LayerTypePtr, LineTypePtr);
120 static void *ChangeArcJoin (LayerTypePtr, ArcTypePtr);
121 static void *SetArcJoin (LayerTypePtr, ArcTypePtr);
122 static void *ClrArcJoin (LayerTypePtr, ArcTypePtr);
123 static void *ChangeTextJoin (LayerTypePtr, TextTypePtr);
124 static void *SetTextJoin (LayerTypePtr, TextTypePtr);
125 static void *ClrTextJoin (LayerTypePtr, TextTypePtr);
126 static void *ChangePolyClear (LayerTypePtr, PolygonTypePtr);
128 /* ---------------------------------------------------------------------------
129 * some local identifiers
131 static int Delta; /* change of size */
132 static int Absolute; /* Absolute size */
133 static char *NewName; /* new name */
134 static ObjectFunctionType ChangeSizeFunctions = {
135 ChangeLineSize,
136 ChangeTextSize,
137 ChangePolyClear,
138 ChangeViaSize,
139 ChangeElementSize, /* changes silk screen line width */
140 ChangeElementNameSize,
141 ChangePinSize,
142 ChangePadSize,
143 NULL,
144 NULL,
145 ChangeArcSize,
146 NULL
148 static ObjectFunctionType Change2ndSizeFunctions = {
149 NULL,
150 NULL,
151 NULL,
152 ChangeVia2ndSize,
153 ChangeElement2ndSize,
154 NULL,
155 ChangePin2ndSize,
156 NULL,
157 NULL,
158 NULL,
159 NULL,
160 NULL
162 static ObjectFunctionType ChangeThermalFunctions = {
163 NULL,
164 NULL,
165 NULL,
166 ChangeViaThermal,
167 NULL,
168 NULL,
169 ChangePinThermal,
170 NULL,
171 NULL,
172 NULL,
173 NULL,
174 NULL
176 static ObjectFunctionType ChangeClearSizeFunctions = {
177 ChangeLineClearSize,
178 NULL,
179 ChangePolygonClearSize, /* just to tell the user not to :-) */
180 ChangeViaClearSize,
181 NULL,
182 NULL,
183 ChangePinClearSize,
184 ChangePadClearSize,
185 NULL,
186 NULL,
187 ChangeArcClearSize,
188 NULL
190 static ObjectFunctionType ChangeNameFunctions = {
191 ChangeLineName,
192 ChangeTextName,
193 NULL,
194 ChangeViaName,
195 ChangeElementName,
196 NULL,
197 ChangePinName,
198 ChangePadName,
199 NULL,
200 NULL,
201 NULL,
202 NULL
204 static ObjectFunctionType ChangeSquareFunctions = {
205 NULL,
206 NULL,
207 NULL,
208 NULL,
209 ChangeElementSquare,
210 NULL,
211 ChangePinSquare,
212 ChangePadSquare,
213 NULL,
214 NULL,
215 NULL,
216 NULL
218 static ObjectFunctionType ChangeJoinFunctions = {
219 ChangeLineJoin,
220 ChangeTextJoin,
221 NULL,
222 NULL,
223 NULL,
224 NULL,
225 NULL,
226 NULL,
227 NULL,
228 NULL,
229 ChangeArcJoin,
230 NULL
232 static ObjectFunctionType ChangeOctagonFunctions = {
233 NULL,
234 NULL,
235 NULL,
236 ChangeViaOctagon,
237 ChangeElementOctagon,
238 NULL,
239 ChangePinOctagon,
240 NULL,
241 NULL,
242 NULL,
243 NULL,
244 NULL
246 static ObjectFunctionType ChangeMaskSizeFunctions = {
247 NULL,
248 NULL,
249 NULL,
250 ChangeViaMaskSize,
251 #if 0
252 ChangeElementMaskSize,
253 #else
254 NULL,
255 #endif
256 NULL,
257 ChangePinMaskSize,
258 ChangePadMaskSize,
259 NULL,
260 NULL,
261 NULL,
262 NULL
264 static ObjectFunctionType SetSquareFunctions = {
265 NULL,
266 NULL,
267 NULL,
268 NULL,
269 SetElementSquare,
270 NULL,
271 SetPinSquare,
272 SetPadSquare,
273 NULL,
274 NULL,
275 NULL,
276 NULL
278 static ObjectFunctionType SetJoinFunctions = {
279 SetLineJoin,
280 SetTextJoin,
281 NULL,
282 NULL,
283 NULL,
284 NULL,
285 NULL,
286 NULL,
287 NULL,
288 NULL,
289 SetArcJoin,
290 NULL
292 static ObjectFunctionType SetOctagonFunctions = {
293 NULL,
294 NULL,
295 NULL,
296 SetViaOctagon,
297 SetElementOctagon,
298 NULL,
299 SetPinOctagon,
300 NULL,
301 NULL,
302 NULL,
303 NULL,
304 NULL
306 static ObjectFunctionType ClrSquareFunctions = {
307 NULL,
308 NULL,
309 NULL,
310 NULL,
311 ClrElementSquare,
312 NULL,
313 ClrPinSquare,
314 ClrPadSquare,
315 NULL,
316 NULL,
317 NULL,
318 NULL
320 static ObjectFunctionType ClrJoinFunctions = {
321 ClrLineJoin,
322 ClrTextJoin,
323 NULL,
324 NULL,
325 NULL,
326 NULL,
327 NULL,
328 NULL,
329 NULL,
330 NULL,
331 ClrArcJoin,
332 NULL
334 static ObjectFunctionType ClrOctagonFunctions = {
335 NULL,
336 NULL,
337 NULL,
338 ClrViaOctagon,
339 ClrElementOctagon,
340 NULL,
341 ClrPinOctagon,
342 NULL,
343 NULL,
344 NULL,
345 NULL,
346 NULL
349 /* ---------------------------------------------------------------------------
350 * changes the thermal on a via
351 * returns TRUE if changed
353 static void *
354 ChangeViaThermal (PinTypePtr Via)
356 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, false);
357 RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Via);
358 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
359 if (!Delta) /* remove the thermals */
360 CLEAR_THERM (INDEXOFCURRENT, Via);
361 else
362 ASSIGN_THERM (INDEXOFCURRENT, Delta, Via);
363 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, true);
364 ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Via);
365 DrawVia (Via, 0);
366 return Via;
369 /* ---------------------------------------------------------------------------
370 * changes the thermal on a pin
371 * returns TRUE if changed
373 static void *
374 ChangePinThermal (ElementTypePtr element, PinTypePtr Pin)
376 AddObjectToClearPolyUndoList (PIN_TYPE, element, Pin, Pin, false);
377 RestoreToPolygon (PCB->Data, VIA_TYPE, CURRENT, Pin);
378 AddObjectToFlagUndoList (PIN_TYPE, element, Pin, Pin);
379 if (!Delta) /* remove the thermals */
380 CLEAR_THERM (INDEXOFCURRENT, Pin);
381 else
382 ASSIGN_THERM (INDEXOFCURRENT, Delta, Pin);
383 AddObjectToClearPolyUndoList (PIN_TYPE, element, Pin, Pin, true);
384 ClearFromPolygon (PCB->Data, VIA_TYPE, CURRENT, Pin);
385 DrawPin (Pin, 0);
386 return Pin;
389 /* ---------------------------------------------------------------------------
390 * changes the size of a via
391 * returns TRUE if changed
393 static void *
394 ChangeViaSize (PinTypePtr Via)
396 BDimension 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, 0);
419 return (Via);
421 return (NULL);
424 /* ---------------------------------------------------------------------------
425 * changes the drilling hole of a via
426 * returns TRUE if changed
428 static void *
429 ChangeVia2ndSize (PinTypePtr Via)
431 BDimension value = (Absolute) ? Absolute : Via->DrillingHole + Delta;
433 if (TEST_FLAG (LOCKFLAG, Via))
434 return (NULL);
435 if (value <= MAX_PINORVIASIZE &&
436 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Via) ||
437 value <=
438 Via->Thickness - MIN_PINORVIACOPPER)
439 && value != Via->DrillingHole)
441 AddObjectTo2ndSizeUndoList (VIA_TYPE, Via, Via, Via);
442 EraseVia (Via);
443 Via->DrillingHole = value;
444 if (TEST_FLAG (HOLEFLAG, Via))
446 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
447 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
448 Via->Thickness = value;
449 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
451 DrawVia (Via, 0);
452 return (Via);
454 return (NULL);
458 /* ---------------------------------------------------------------------------
459 * changes the clearance size of a via
460 * returns TRUE if changed
462 static void *
463 ChangeViaClearSize (PinTypePtr Via)
465 BDimension value = (Absolute) ? Absolute : Via->Clearance + Delta;
467 if (TEST_FLAG (LOCKFLAG, Via))
468 return (NULL);
469 value = MIN (MAX_LINESIZE, value);
470 if (value < 0)
471 value = 0;
472 if (Delta < 0 && value < PCB->Bloat * 2)
473 value = 0;
474 if ((Delta > 0 || Absolute) && value < PCB->Bloat * 2)
475 value = PCB->Bloat * 2 + 2;
476 if (Via->Clearance == value)
477 return NULL;
478 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
479 AddObjectToClearSizeUndoList (VIA_TYPE, Via, Via, Via);
480 EraseVia (Via);
481 r_delete_entry (PCB->Data->via_tree, (BoxType *) Via);
482 Via->Clearance = value;
483 SetPinBoundingBox (Via);
484 r_insert_entry (PCB->Data->via_tree, (BoxType *) Via, 0);
485 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
486 DrawVia (Via, 0);
487 Via->Element = NULL;
488 return (Via);
492 /* ---------------------------------------------------------------------------
493 * changes the size of a pin
494 * returns TRUE if changed
496 static void *
497 ChangePinSize (ElementTypePtr Element, PinTypePtr Pin)
499 BDimension value = (Absolute) ? Absolute : Pin->Thickness + Delta;
501 if (TEST_FLAG (LOCKFLAG, Pin))
502 return (NULL);
503 if (!TEST_FLAG (HOLEFLAG, Pin) && value <= MAX_PINORVIASIZE &&
504 value >= MIN_PINORVIASIZE &&
505 value >= Pin->DrillingHole + MIN_PINORVIACOPPER &&
506 value != Pin->Thickness)
508 AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin);
509 AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin);
510 ErasePin (Pin);
511 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
512 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
513 Pin->Mask += value - Pin->Thickness;
514 Pin->Thickness = value;
515 /* SetElementBB updates all associated rtrees */
516 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
517 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
518 DrawPin (Pin, 0);
519 return (Pin);
521 return (NULL);
524 /* ---------------------------------------------------------------------------
525 * changes the clearance size of a pin
526 * returns TRUE if changed
528 static void *
529 ChangePinClearSize (ElementTypePtr Element, PinTypePtr Pin)
531 BDimension value = (Absolute) ? Absolute : Pin->Clearance + Delta;
533 if (TEST_FLAG (LOCKFLAG, Pin))
534 return (NULL);
535 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
536 if (Pin->Clearance == value)
537 return NULL;
538 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
539 AddObjectToClearSizeUndoList (PIN_TYPE, Element, Pin, Pin);
540 ErasePin (Pin);
541 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
542 Pin->Clearance = value;
543 /* SetElementBB updates all associated rtrees */
544 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
545 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
546 DrawPin (Pin, 0);
547 return (Pin);
550 /* ---------------------------------------------------------------------------
551 * changes the size of a pad
552 * returns TRUE if changed
554 static void *
555 ChangePadSize (ElementTypePtr Element, PadTypePtr Pad)
557 BDimension value = (Absolute) ? Absolute : Pad->Thickness + Delta;
559 if (TEST_FLAG (LOCKFLAG, Pad))
560 return (NULL);
561 if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Thickness)
563 AddObjectToSizeUndoList (PAD_TYPE, Element, Pad, Pad);
564 AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad);
565 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
566 ErasePad (Pad);
567 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
568 Pad->Mask += value - Pad->Thickness;
569 Pad->Thickness = value;
570 /* SetElementBB updates all associated rtrees */
571 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
572 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
573 DrawPad (Pad, 0);
574 return (Pad);
576 return (NULL);
579 /* ---------------------------------------------------------------------------
580 * changes the clearance size of a pad
581 * returns TRUE if changed
583 static void *
584 ChangePadClearSize (ElementTypePtr Element, PadTypePtr Pad)
586 BDimension value = (Absolute) ? Absolute : Pad->Clearance + Delta;
588 if (TEST_FLAG (LOCKFLAG, Pad))
589 return (NULL);
590 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
591 if (value <= MAX_PADSIZE && value >= MIN_PADSIZE && value != Pad->Clearance)
593 AddObjectToClearSizeUndoList (PAD_TYPE, Element, Pad, Pad);
594 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
595 ErasePad (Pad);
596 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
597 Pad->Clearance = value;
598 /* SetElementBB updates all associated rtrees */
599 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
600 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
601 DrawPad (Pad, 0);
602 return (Pad);
604 return (NULL);
607 /* ---------------------------------------------------------------------------
608 * changes the drilling hole of all pins of an element
609 * returns TRUE if changed
611 static void *
612 ChangeElement2ndSize (ElementTypePtr Element)
614 bool changed = false;
615 BDimension value;
617 if (TEST_FLAG (LOCKFLAG, Element))
618 return (NULL);
619 PIN_LOOP (Element);
621 value = (Absolute) ? Absolute : pin->DrillingHole + Delta;
622 if (value <= MAX_PINORVIASIZE &&
623 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, pin) ||
624 value <=
625 pin->Thickness -
626 MIN_PINORVIACOPPER)
627 && value != pin->DrillingHole)
629 changed = true;
630 AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, pin, pin);
631 ErasePin (pin);
632 pin->DrillingHole = value;
633 DrawPin (pin, 0);
634 if (TEST_FLAG (HOLEFLAG, pin))
636 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, pin);
637 AddObjectToSizeUndoList (PIN_TYPE, Element, pin, pin);
638 pin->Thickness = value;
639 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, pin);
643 END_LOOP;
644 if (changed)
645 return (Element);
646 else
647 return (NULL);
650 /* ---------------------------------------------------------------------------
651 * changes the drilling hole of a pin
652 * returns TRUE if changed
654 static void *
655 ChangePin2ndSize (ElementTypePtr Element, PinTypePtr Pin)
657 BDimension value = (Absolute) ? Absolute : Pin->DrillingHole + Delta;
659 if (TEST_FLAG (LOCKFLAG, Pin))
660 return (NULL);
661 if (value <= MAX_PINORVIASIZE &&
662 value >= MIN_PINORVIAHOLE && (TEST_FLAG (HOLEFLAG, Pin) ||
663 value <=
664 Pin->Thickness - MIN_PINORVIACOPPER)
665 && value != Pin->DrillingHole)
667 AddObjectTo2ndSizeUndoList (PIN_TYPE, Element, Pin, Pin);
668 ErasePin (Pin);
669 Pin->DrillingHole = value;
670 DrawPin (Pin, 0);
671 if (TEST_FLAG (HOLEFLAG, Pin))
673 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
674 AddObjectToSizeUndoList (PIN_TYPE, Element, Pin, Pin);
675 Pin->Thickness = value;
676 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
678 return (Pin);
680 return (NULL);
683 /* ---------------------------------------------------------------------------
684 * changes the size of a line
685 * returns TRUE if changed
687 static void *
688 ChangeLineSize (LayerTypePtr Layer, LineTypePtr Line)
690 BDimension value = (Absolute) ? Absolute : Line->Thickness + Delta;
692 if (TEST_FLAG (LOCKFLAG, Line))
693 return (NULL);
694 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
695 value != Line->Thickness)
697 AddObjectToSizeUndoList (LINE_TYPE, Layer, Line, Line);
698 EraseLine (Line);
699 r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
700 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
701 Line->Thickness = value;
702 SetLineBoundingBox (Line);
703 r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0);
704 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
705 DrawLine (Layer, Line, 0);
706 return (Line);
708 return (NULL);
711 /* ---------------------------------------------------------------------------
712 * changes the clearance size of a line
713 * returns TRUE if changed
715 static void *
716 ChangeLineClearSize (LayerTypePtr Layer, LineTypePtr Line)
718 BDimension value = (Absolute) ? Absolute : Line->Clearance + Delta;
720 if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line))
721 return (NULL);
722 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
723 if (value != Line->Clearance)
725 AddObjectToClearSizeUndoList (LINE_TYPE, Layer, Line, Line);
726 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
727 EraseLine (Line);
728 r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
729 Line->Clearance = value;
730 if (Line->Clearance == 0)
732 CLEAR_FLAG (CLEARLINEFLAG, Line);
733 Line->Clearance = 1000;
735 SetLineBoundingBox (Line);
736 r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0);
737 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
738 DrawLine (Layer, Line, 0);
739 return (Line);
741 return (NULL);
744 /* ---------------------------------------------------------------------------
745 * Handle attepts to change the clearance of a polygon.
747 static void *
748 ChangePolygonClearSize (LayerTypePtr Layer, PolygonTypePtr poly)
750 static int shown_this_message = 0;
751 if (!shown_this_message)
753 gui->confirm_dialog (_("To change the clearance of objects in a polygon, "
754 "change the objects, not the polygon.\n"
755 "Hint: To set a minimum clearance for a group of objects, "
756 "select them all then :MinClearGap(Selected,=10,mil)"),
757 "Ok", NULL);
758 shown_this_message = 1;
761 return (NULL);
764 /* ---------------------------------------------------------------------------
765 * changes the size of an arc
766 * returns TRUE if changed
768 static void *
769 ChangeArcSize (LayerTypePtr Layer, ArcTypePtr Arc)
771 BDimension value = (Absolute) ? Absolute : Arc->Thickness + Delta;
773 if (TEST_FLAG (LOCKFLAG, Arc))
774 return (NULL);
775 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
776 value != Arc->Thickness)
778 AddObjectToSizeUndoList (ARC_TYPE, Layer, Arc, Arc);
779 EraseArc (Arc);
780 r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc);
781 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
782 Arc->Thickness = value;
783 SetArcBoundingBox (Arc);
784 r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0);
785 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
786 DrawArc (Layer, Arc, 0);
787 return (Arc);
789 return (NULL);
792 /* ---------------------------------------------------------------------------
793 * changes the clearance size of an arc
794 * returns TRUE if changed
796 static void *
797 ChangeArcClearSize (LayerTypePtr Layer, ArcTypePtr Arc)
799 BDimension value = (Absolute) ? Absolute : Arc->Clearance + Delta;
801 if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc))
802 return (NULL);
803 value = MIN (MAX_LINESIZE, MAX (value, PCB->Bloat * 2 + 2));
804 if (value != Arc->Clearance)
806 AddObjectToClearSizeUndoList (ARC_TYPE, Layer, Arc, Arc);
807 EraseArc (Arc);
808 r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc);
809 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
810 Arc->Clearance = value;
811 if (Arc->Clearance == 0)
813 CLEAR_FLAG (CLEARLINEFLAG, Arc);
814 Arc->Clearance = 1000;
816 SetArcBoundingBox (Arc);
817 r_insert_entry (Layer->arc_tree, (BoxTypePtr) Arc, 0);
818 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
819 DrawArc (Layer, Arc, 0);
820 return (Arc);
822 return (NULL);
825 /* ---------------------------------------------------------------------------
826 * changes the scaling factor of a text object
827 * returns TRUE if changed
829 static void *
830 ChangeTextSize (LayerTypePtr Layer, TextTypePtr Text)
832 BDimension value = (Absolute) ? Absolute / 45 : Text->Scale + Delta / 45;
834 if (TEST_FLAG (LOCKFLAG, Text))
835 return (NULL);
836 if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE &&
837 value != Text->Scale)
839 AddObjectToSizeUndoList (TEXT_TYPE, Layer, Text, Text);
840 EraseText (Layer, Text);
841 r_delete_entry (Layer->text_tree, (BoxTypePtr) Text);
842 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
843 Text->Scale = value;
844 SetTextBoundingBox (&PCB->Font, Text);
845 r_insert_entry (Layer->text_tree, (BoxTypePtr) Text, 0);
846 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
847 DrawText (Layer, Text, 0);
848 return (Text);
850 return (NULL);
853 /* ---------------------------------------------------------------------------
854 * changes the scaling factor of an element's outline
855 * returns TRUE if changed
857 static void *
858 ChangeElementSize (ElementTypePtr Element)
860 BDimension value;
861 bool changed = false;
863 if (TEST_FLAG (LOCKFLAG, Element))
864 return (NULL);
865 if (PCB->ElementOn)
866 EraseElement (Element);
867 ELEMENTLINE_LOOP (Element);
869 value = (Absolute) ? Absolute : line->Thickness + Delta;
870 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
871 value != line->Thickness)
873 AddObjectToSizeUndoList (ELEMENTLINE_TYPE, Element, line, line);
874 line->Thickness = value;
875 changed = true;
878 END_LOOP;
879 ARC_LOOP (Element);
881 value = (Absolute) ? Absolute : arc->Thickness + Delta;
882 if (value <= MAX_LINESIZE && value >= MIN_LINESIZE &&
883 value != arc->Thickness)
885 AddObjectToSizeUndoList (ELEMENTARC_TYPE, Element, arc, arc);
886 arc->Thickness = value;
887 changed = true;
890 END_LOOP;
891 if (PCB->ElementOn)
893 DrawElement (Element, 0);
895 if (changed)
896 return (Element);
897 return (NULL);
900 /* ---------------------------------------------------------------------------
901 * changes the scaling factor of a elementname object
902 * returns TRUE if changed
904 static void *
905 ChangeElementNameSize (ElementTypePtr Element)
907 BDimension value =
908 (Absolute) ? Absolute / 45 : DESCRIPTION_TEXT (Element).Scale +
909 Delta / 45;
911 if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
912 return (NULL);
913 if (value <= MAX_TEXTSCALE && value >= MIN_TEXTSCALE)
915 EraseElementName (Element);
916 ELEMENTTEXT_LOOP (Element);
918 AddObjectToSizeUndoList (ELEMENTNAME_TYPE, Element, text, text);
919 r_delete_entry (PCB->Data->name_tree[n], (BoxType *) text);
920 text->Scale = value;
921 SetTextBoundingBox (&PCB->Font, text);
922 r_insert_entry (PCB->Data->name_tree[n], (BoxType *) text, 0);
924 END_LOOP;
925 DrawElementName (Element, 0);
926 return (Element);
928 return (NULL);
931 /* ---------------------------------------------------------------------------
932 * changes the name of a via
934 static void *
935 ChangeViaName (PinTypePtr Via)
937 char *old = Via->Name;
939 if (TEST_FLAG (DISPLAYNAMEFLAG, Via))
941 ErasePinName (Via);
942 Via->Name = NewName;
943 DrawPinName (Via, 0);
945 else
946 Via->Name = NewName;
947 return (old);
950 /* ---------------------------------------------------------------------------
951 * changes the name of a pin
953 static void *
954 ChangePinName (ElementTypePtr Element, PinTypePtr Pin)
956 char *old = Pin->Name;
958 Element = Element; /* get rid of 'unused...' warnings */
959 if (TEST_FLAG (DISPLAYNAMEFLAG, Pin))
961 ErasePinName (Pin);
962 Pin->Name = NewName;
963 DrawPinName (Pin, 0);
965 else
966 Pin->Name = NewName;
967 return (old);
970 /* ---------------------------------------------------------------------------
971 * changes the name of a pad
973 static void *
974 ChangePadName (ElementTypePtr Element, PadTypePtr Pad)
976 char *old = Pad->Name;
978 Element = Element; /* get rid of 'unused...' warnings */
979 if (TEST_FLAG (DISPLAYNAMEFLAG, Pad))
981 ErasePadName (Pad);
982 Pad->Name = NewName;
983 DrawPadName (Pad, 0);
985 else
986 Pad->Name = NewName;
987 return (old);
990 /* ---------------------------------------------------------------------------
991 * changes the name of a line
993 static void *
994 ChangeLineName (LayerTypePtr Layer, LineTypePtr Line)
996 char *old = Line->Number;
998 Layer = Layer;
999 Line->Number = NewName;
1000 return (old);
1003 /* ---------------------------------------------------------------------------
1004 * changes the layout-name of an element
1007 char *
1008 ChangeElementText (PCBType *pcb, DataType *data, ElementTypePtr Element, int which, char *new_name)
1010 char *old = Element->Name[which].TextString;
1012 #ifdef DEBUG
1013 printf("In ChangeElementText, updating old TextString %s to %s\n", old, new_name);
1014 #endif
1016 if (pcb && which == NAME_INDEX (pcb))
1017 EraseElementName (Element);
1019 r_delete_entry (data->name_tree[which],
1020 & Element->Name[which].BoundingBox);
1022 Element->Name[which].TextString = new_name;
1023 SetTextBoundingBox (&PCB->Font, &Element->Name[which]);
1025 r_insert_entry (data->name_tree[which],
1026 & Element->Name[which].BoundingBox, 0);
1028 if (pcb && which == NAME_INDEX (pcb))
1029 DrawElementName (Element, 0);
1031 return old;
1034 static void *
1035 ChangeElementName (ElementTypePtr Element)
1037 char *old = ELEMENT_NAME (PCB, Element);
1039 if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
1040 return (NULL);
1041 if (NAME_INDEX (PCB) == NAMEONPCB_INDEX)
1043 if (TEST_FLAG (UNIQUENAMEFLAG, PCB) &&
1044 UniqueElementName (PCB->Data, NewName) != NewName)
1046 Message (_("Error: The name \"%s\" is not unique!\n"), NewName);
1047 return ((char *) -1);
1051 return ChangeElementText (PCB, PCB->Data, Element, NAME_INDEX (PCB), NewName);
1054 /* ---------------------------------------------------------------------------
1055 * sets data of a text object and calculates bounding box
1056 * memory must have already been allocated
1057 * the one for the new string is allocated
1058 * returns true if the string has been changed
1060 static void *
1061 ChangeTextName (LayerTypePtr Layer, TextTypePtr Text)
1063 char *old = Text->TextString;
1065 if (TEST_FLAG (LOCKFLAG, Text))
1066 return (NULL);
1067 EraseText (Layer, Text);
1068 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1069 Text->TextString = NewName;
1071 /* calculate size of the bounding box */
1072 SetTextBoundingBox (&PCB->Font, Text);
1073 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1074 DrawText (Layer, Text, 0);
1075 return (old);
1078 /* ---------------------------------------------------------------------------
1079 * changes the name of a layout; memory has to be already allocated
1081 bool
1082 ChangeLayoutName (char *Name)
1084 PCB->Name = Name;
1085 hid_action ("PCBChanged");
1086 return (true);
1089 /* ---------------------------------------------------------------------------
1090 * changes the side of the board an element is on
1091 * returns TRUE if done
1093 bool
1094 ChangeElementSide (ElementTypePtr Element, LocationType yoff)
1096 if (TEST_FLAG (LOCKFLAG, Element))
1097 return (false);
1098 EraseElement (Element);
1099 AddObjectToMirrorUndoList (ELEMENT_TYPE, Element, Element, Element, yoff);
1100 MirrorElementCoordinates (PCB->Data, Element, yoff);
1101 DrawElement (Element, 0);
1102 return (true);
1105 /* ---------------------------------------------------------------------------
1106 * changes the name of a layer; memory has to be already allocated
1108 bool
1109 ChangeLayerName (LayerTypePtr Layer, char *Name)
1111 CURRENT->Name = Name;
1112 hid_action ("LayersChanged");
1113 return (true);
1116 /* ---------------------------------------------------------------------------
1117 * changes the clearance flag of a line
1119 static void *
1120 ChangeLineJoin (LayerTypePtr Layer, LineTypePtr Line)
1122 if (TEST_FLAG (LOCKFLAG, Line))
1123 return (NULL);
1124 EraseLine (Line);
1125 if (TEST_FLAG(CLEARLINEFLAG, Line))
1127 AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, false);
1128 RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
1130 AddObjectToFlagUndoList (LINE_TYPE, Layer, Line, Line);
1131 TOGGLE_FLAG (CLEARLINEFLAG, Line);
1132 if (TEST_FLAG(CLEARLINEFLAG, Line))
1134 AddObjectToClearPolyUndoList (LINE_TYPE, Layer, Line, Line, true);
1135 ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
1137 DrawLine (Layer, Line, 0);
1138 return (Line);
1141 /* ---------------------------------------------------------------------------
1142 * sets the clearance flag of a line
1144 static void *
1145 SetLineJoin (LayerTypePtr Layer, LineTypePtr Line)
1147 if (TEST_FLAG (LOCKFLAG, Line) || TEST_FLAG (CLEARLINEFLAG, Line))
1148 return (NULL);
1149 return ChangeLineJoin (Layer, Line);
1152 /* ---------------------------------------------------------------------------
1153 * clears the clearance flag of a line
1155 static void *
1156 ClrLineJoin (LayerTypePtr Layer, LineTypePtr Line)
1158 if (TEST_FLAG (LOCKFLAG, Line) || !TEST_FLAG (CLEARLINEFLAG, Line))
1159 return (NULL);
1160 return ChangeLineJoin (Layer, Line);
1163 /* ---------------------------------------------------------------------------
1164 * changes the clearance flag of an arc
1166 static void *
1167 ChangeArcJoin (LayerTypePtr Layer, ArcTypePtr Arc)
1169 if (TEST_FLAG (LOCKFLAG, Arc))
1170 return (NULL);
1171 EraseArc (Arc);
1172 if (TEST_FLAG (CLEARLINEFLAG, Arc))
1174 RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
1175 AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, false);
1177 AddObjectToFlagUndoList (ARC_TYPE, Layer, Arc, Arc);
1178 TOGGLE_FLAG (CLEARLINEFLAG, Arc);
1179 if (TEST_FLAG (CLEARLINEFLAG, Arc))
1181 ClearFromPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
1182 AddObjectToClearPolyUndoList (ARC_TYPE, Layer, Arc, Arc, true);
1184 DrawArc (Layer, Arc, 0);
1185 return (Arc);
1188 /* ---------------------------------------------------------------------------
1189 * sets the clearance flag of an arc
1191 static void *
1192 SetArcJoin (LayerTypePtr Layer, ArcTypePtr Arc)
1194 if (TEST_FLAG (LOCKFLAG, Arc) || TEST_FLAG (CLEARLINEFLAG, Arc))
1195 return (NULL);
1196 return ChangeArcJoin (Layer, Arc);
1199 /* ---------------------------------------------------------------------------
1200 * clears the clearance flag of an arc
1202 static void *
1203 ClrArcJoin (LayerTypePtr Layer, ArcTypePtr Arc)
1205 if (TEST_FLAG (LOCKFLAG, Arc) || !TEST_FLAG (CLEARLINEFLAG, Arc))
1206 return (NULL);
1207 return ChangeArcJoin (Layer, Arc);
1210 /* ---------------------------------------------------------------------------
1211 * changes the clearance flag of a text
1213 static void *
1214 ChangeTextJoin (LayerTypePtr Layer, TextTypePtr Text)
1216 if (TEST_FLAG (LOCKFLAG, Text))
1217 return (NULL);
1218 EraseText (Layer, Text);
1219 if (TEST_FLAG(CLEARLINEFLAG, Text))
1221 AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, false);
1222 RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1224 AddObjectToFlagUndoList (LINE_TYPE, Layer, Text, Text);
1225 TOGGLE_FLAG (CLEARLINEFLAG, Text);
1226 if (TEST_FLAG(CLEARLINEFLAG, Text))
1228 AddObjectToClearPolyUndoList (TEXT_TYPE, Layer, Text, Text, true);
1229 ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
1231 DrawText (Layer, Text, 0);
1232 return (Text);
1235 /* ---------------------------------------------------------------------------
1236 * sets the clearance flag of a text
1238 static void *
1239 SetTextJoin (LayerTypePtr Layer, TextTypePtr Text)
1241 if (TEST_FLAG (LOCKFLAG, Text) || TEST_FLAG (CLEARLINEFLAG, Text))
1242 return (NULL);
1243 return ChangeTextJoin (Layer, Text);
1246 /* ---------------------------------------------------------------------------
1247 * clears the clearance flag of a text
1249 static void *
1250 ClrTextJoin (LayerTypePtr Layer, TextTypePtr Text)
1252 if (TEST_FLAG (LOCKFLAG, Text) || !TEST_FLAG (CLEARLINEFLAG, Text))
1253 return (NULL);
1254 return ChangeTextJoin (Layer, Text);
1257 /* ---------------------------------------------------------------------------
1258 * changes the square flag of all pins on an element
1260 static void *
1261 ChangeElementSquare (ElementTypePtr Element)
1263 void *ans = NULL;
1265 if (TEST_FLAG (LOCKFLAG, Element))
1266 return (NULL);
1267 PIN_LOOP (Element);
1269 ans = ChangePinSquare (Element, pin);
1271 END_LOOP;
1272 PAD_LOOP (Element);
1274 ans = ChangePadSquare (Element, pad);
1276 END_LOOP;
1277 return (ans);
1280 /* ---------------------------------------------------------------------------
1281 * sets the square flag of all pins on an element
1283 static void *
1284 SetElementSquare (ElementTypePtr Element)
1286 void *ans = NULL;
1288 if (TEST_FLAG (LOCKFLAG, Element))
1289 return (NULL);
1290 PIN_LOOP (Element);
1292 ans = SetPinSquare (Element, pin);
1294 END_LOOP;
1295 PAD_LOOP (Element);
1297 ans = SetPadSquare (Element, pad);
1299 END_LOOP;
1300 return (ans);
1303 /* ---------------------------------------------------------------------------
1304 * clears the square flag of all pins on an element
1306 static void *
1307 ClrElementSquare (ElementTypePtr Element)
1309 void *ans = NULL;
1311 if (TEST_FLAG (LOCKFLAG, Element))
1312 return (NULL);
1313 PIN_LOOP (Element);
1315 ans = ClrPinSquare (Element, pin);
1317 END_LOOP;
1318 PAD_LOOP (Element);
1320 ans = ClrPadSquare (Element, pad);
1322 END_LOOP;
1323 return (ans);
1326 /* ---------------------------------------------------------------------------
1327 * changes the octagon flags of all pins of an element
1329 static void *
1330 ChangeElementOctagon (ElementTypePtr Element)
1332 void *result = NULL;
1334 if (TEST_FLAG (LOCKFLAG, Element))
1335 return (NULL);
1336 PIN_LOOP (Element);
1338 ChangePinOctagon (Element, pin);
1339 result = Element;
1341 END_LOOP;
1342 return (result);
1345 /* ---------------------------------------------------------------------------
1346 * sets the octagon flags of all pins of an element
1348 static void *
1349 SetElementOctagon (ElementTypePtr Element)
1351 void *result = NULL;
1353 if (TEST_FLAG (LOCKFLAG, Element))
1354 return (NULL);
1355 PIN_LOOP (Element);
1357 SetPinOctagon (Element, pin);
1358 result = Element;
1360 END_LOOP;
1361 return (result);
1364 /* ---------------------------------------------------------------------------
1365 * clears the octagon flags of all pins of an element
1367 static void *
1368 ClrElementOctagon (ElementTypePtr Element)
1370 void *result = NULL;
1372 if (TEST_FLAG (LOCKFLAG, Element))
1373 return (NULL);
1374 PIN_LOOP (Element);
1376 ClrPinOctagon (Element, pin);
1377 result = Element;
1379 END_LOOP;
1380 return (result);
1383 /* ---------------------------------------------------------------------------
1384 * changes the square flag of a pad
1386 static void *
1387 ChangePadSquare (ElementTypePtr Element, PadTypePtr Pad)
1389 if (TEST_FLAG (LOCKFLAG, Pad))
1390 return (NULL);
1391 ErasePad (Pad);
1392 AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, false);
1393 RestoreToPolygon (PCB->Data, PAD_TYPE, Element, Pad);
1394 AddObjectToFlagUndoList (PAD_TYPE, Element, Pad, Pad);
1395 TOGGLE_FLAG (SQUAREFLAG, Pad);
1396 AddObjectToClearPolyUndoList (PAD_TYPE, Element, Pad, Pad, true);
1397 ClearFromPolygon (PCB->Data, PAD_TYPE, Element, Pad);
1398 DrawPad (Pad, 0);
1399 return (Pad);
1402 /* ---------------------------------------------------------------------------
1403 * sets the square flag of a pad
1405 static void *
1406 SetPadSquare (ElementTypePtr Element, PadTypePtr Pad)
1409 if (TEST_FLAG (LOCKFLAG, Pad) || TEST_FLAG (SQUAREFLAG, Pad))
1410 return (NULL);
1412 return (ChangePadSquare (Element, Pad));
1416 /* ---------------------------------------------------------------------------
1417 * clears the square flag of a pad
1419 static void *
1420 ClrPadSquare (ElementTypePtr Element, PadTypePtr Pad)
1423 if (TEST_FLAG (LOCKFLAG, Pad) || !TEST_FLAG (SQUAREFLAG, Pad))
1424 return (NULL);
1426 return (ChangePadSquare (Element, Pad));
1430 /* ---------------------------------------------------------------------------
1431 * changes the square flag of a pin
1433 static void *
1434 ChangePinSquare (ElementTypePtr Element, PinTypePtr Pin)
1436 if (TEST_FLAG (LOCKFLAG, Pin))
1437 return (NULL);
1438 ErasePin (Pin);
1439 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false);
1440 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1441 AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin);
1442 TOGGLE_FLAG (SQUAREFLAG, Pin);
1443 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true);
1444 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1445 DrawPin (Pin, 0);
1446 return (Pin);
1449 /* ---------------------------------------------------------------------------
1450 * sets the square flag of a pin
1452 static void *
1453 SetPinSquare (ElementTypePtr Element, PinTypePtr Pin)
1455 if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (SQUAREFLAG, Pin))
1456 return (NULL);
1458 return (ChangePinSquare (Element, Pin));
1461 /* ---------------------------------------------------------------------------
1462 * clears the square flag of a pin
1464 static void *
1465 ClrPinSquare (ElementTypePtr Element, PinTypePtr Pin)
1467 if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (SQUAREFLAG, Pin))
1468 return (NULL);
1470 return (ChangePinSquare (Element, Pin));
1473 /* ---------------------------------------------------------------------------
1474 * changes the octagon flag of a via
1476 static void *
1477 ChangeViaOctagon (PinTypePtr Via)
1479 if (TEST_FLAG (LOCKFLAG, Via))
1480 return (NULL);
1481 EraseVia (Via);
1482 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, false);
1483 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
1484 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
1485 TOGGLE_FLAG (OCTAGONFLAG, Via);
1486 AddObjectToClearPolyUndoList (VIA_TYPE, Via, Via, Via, true);
1487 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
1488 DrawVia (Via, 0);
1489 return (Via);
1492 /* ---------------------------------------------------------------------------
1493 * sets the octagon flag of a via
1495 static void *
1496 SetViaOctagon (PinTypePtr Via)
1498 if (TEST_FLAG (LOCKFLAG, Via) || TEST_FLAG (OCTAGONFLAG, Via))
1499 return (NULL);
1501 return (ChangeViaOctagon (Via));
1504 /* ---------------------------------------------------------------------------
1505 * clears the octagon flag of a via
1507 static void *
1508 ClrViaOctagon (PinTypePtr Via)
1510 if (TEST_FLAG (LOCKFLAG, Via) || !TEST_FLAG (OCTAGONFLAG, Via))
1511 return (NULL);
1513 return (ChangeViaOctagon (Via));
1516 /* ---------------------------------------------------------------------------
1517 * changes the octagon flag of a pin
1519 static void *
1520 ChangePinOctagon (ElementTypePtr Element, PinTypePtr Pin)
1522 if (TEST_FLAG (LOCKFLAG, Pin))
1523 return (NULL);
1524 ErasePin (Pin);
1525 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, false);
1526 RestoreToPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1527 AddObjectToFlagUndoList (PIN_TYPE, Element, Pin, Pin);
1528 TOGGLE_FLAG (OCTAGONFLAG, Pin);
1529 AddObjectToClearPolyUndoList (PIN_TYPE, Element, Pin, Pin, true);
1530 ClearFromPolygon (PCB->Data, PIN_TYPE, Element, Pin);
1531 DrawPin (Pin, 0);
1532 return (Pin);
1535 /* ---------------------------------------------------------------------------
1536 * sets the octagon flag of a pin
1538 static void *
1539 SetPinOctagon (ElementTypePtr Element, PinTypePtr Pin)
1541 if (TEST_FLAG (LOCKFLAG, Pin) || TEST_FLAG (OCTAGONFLAG, Pin))
1542 return (NULL);
1544 return (ChangePinOctagon (Element, Pin));
1547 /* ---------------------------------------------------------------------------
1548 * clears the octagon flag of a pin
1550 static void *
1551 ClrPinOctagon (ElementTypePtr Element, PinTypePtr Pin)
1553 if (TEST_FLAG (LOCKFLAG, Pin) || !TEST_FLAG (OCTAGONFLAG, Pin))
1554 return (NULL);
1556 return (ChangePinOctagon (Element, Pin));
1559 /* ---------------------------------------------------------------------------
1560 * changes the hole flag of a via
1562 bool
1563 ChangeHole (PinTypePtr Via)
1565 if (TEST_FLAG (LOCKFLAG, Via))
1566 return (false);
1567 EraseVia (Via);
1568 AddObjectToFlagUndoList (VIA_TYPE, Via, Via, Via);
1569 TOGGLE_FLAG (HOLEFLAG, Via);
1570 if (TEST_FLAG (HOLEFLAG, Via))
1572 RestoreToPolygon (PCB->Data, VIA_TYPE, Via, Via);
1573 AddObjectToSizeUndoList (VIA_TYPE, Via, Via, Via);
1574 Via->Thickness = Via->Mask = Via->DrillingHole;
1575 ClearFromPolygon (PCB->Data, VIA_TYPE, Via, Via);
1577 else
1579 AddObjectTo2ndSizeUndoList (VIA_TYPE, Via, Via, Via);
1580 Via->DrillingHole = Via->Thickness - MIN_PINORVIACOPPER;
1582 DrawVia (Via, 0);
1583 Draw ();
1584 return (true);
1587 /* ---------------------------------------------------------------------------
1588 * changes the nopaste flag of a pad
1590 bool
1591 ChangePaste (PadTypePtr Pad)
1593 if (TEST_FLAG (LOCKFLAG, Pad))
1594 return (false);
1595 ErasePad (Pad);
1596 AddObjectToFlagUndoList (PAD_TYPE, Pad, Pad, Pad);
1597 TOGGLE_FLAG (NOPASTEFLAG, Pad);
1598 DrawPad (Pad, 0);
1599 Draw ();
1600 return (true);
1603 /* ---------------------------------------------------------------------------
1604 * changes the CLEARPOLY flag of a polygon
1606 static void *
1607 ChangePolyClear (LayerTypePtr Layer, PolygonTypePtr Polygon)
1609 if (TEST_FLAG (LOCKFLAG, Polygon))
1610 return (NULL);
1611 AddObjectToClearPolyUndoList (POLYGON_TYPE, Layer, Polygon, Polygon, true);
1612 AddObjectToFlagUndoList (POLYGON_TYPE, Layer, Polygon, Polygon);
1613 TOGGLE_FLAG (CLEARPOLYFLAG, Polygon);
1614 InitClip (PCB->Data, Layer, Polygon);
1615 DrawPolygon (Layer, Polygon, 0);
1616 return (Polygon);
1619 /* ----------------------------------------------------------------------
1620 * changes the side of all selected and visible elements
1621 * returns true if anything has changed
1623 bool
1624 ChangeSelectedElementSide (void)
1626 bool change = false;
1628 /* setup identifiers */
1629 if (PCB->PinOn && PCB->ElementOn)
1630 ELEMENT_LOOP (PCB->Data);
1632 if (TEST_FLAG (SELECTEDFLAG, element))
1634 change |= ChangeElementSide (element, 0);
1637 END_LOOP;
1638 if (change)
1640 Draw ();
1641 IncrementUndoSerialNumber ();
1643 return (change);
1646 /* ----------------------------------------------------------------------
1647 * changes the thermals on all selected and visible pins
1648 * and/or vias. Returns true if anything has changed
1650 bool
1651 ChangeSelectedThermals (int types, int therm_style)
1653 bool change = false;
1655 Delta = therm_style;
1656 change = SelectedOperation (&ChangeThermalFunctions, false, types);
1657 if (change)
1659 Draw ();
1660 IncrementUndoSerialNumber ();
1662 return (change);
1665 /* ----------------------------------------------------------------------
1666 * changes the size of all selected and visible object types
1667 * returns true if anything has changed
1669 bool
1670 ChangeSelectedSize (int types, LocationType Difference, bool fixIt)
1672 bool change = false;
1674 /* setup identifiers */
1675 Absolute = (fixIt) ? Difference : 0;
1676 Delta = Difference;
1678 change = SelectedOperation (&ChangeSizeFunctions, false, types);
1679 if (change)
1681 Draw ();
1682 IncrementUndoSerialNumber ();
1684 return (change);
1687 /* ----------------------------------------------------------------------
1688 * changes the clearance size of all selected and visible objects
1689 * returns true if anything has changed
1691 bool
1692 ChangeSelectedClearSize (int types, LocationType Difference, bool fixIt)
1694 bool change = false;
1696 /* setup identifiers */
1697 Absolute = (fixIt) ? Difference : 0;
1698 Delta = Difference;
1699 if (TEST_FLAG (SHOWMASKFLAG, PCB))
1700 change = SelectedOperation (&ChangeMaskSizeFunctions, false, types);
1701 else
1702 change = SelectedOperation (&ChangeClearSizeFunctions, false, types);
1703 if (change)
1705 Draw ();
1706 IncrementUndoSerialNumber ();
1708 return (change);
1711 /* --------------------------------------------------------------------------
1712 * changes the 2nd size (drilling hole) of all selected and visible objects
1713 * returns true if anything has changed
1715 bool
1716 ChangeSelected2ndSize (int types, LocationType Difference, bool fixIt)
1718 bool change = false;
1720 /* setup identifiers */
1721 Absolute = (fixIt) ? Difference : 0;
1722 Delta = Difference;
1723 change = SelectedOperation (&Change2ndSizeFunctions, false, types);
1724 if (change)
1726 Draw ();
1727 IncrementUndoSerialNumber ();
1729 return (change);
1732 /* ----------------------------------------------------------------------
1733 * changes the clearance flag (join) of all selected and visible lines
1734 * and/or arcs. Returns true if anything has changed
1736 bool
1737 ChangeSelectedJoin (int types)
1739 bool change = false;
1741 change = SelectedOperation (&ChangeJoinFunctions, false, types);
1742 if (change)
1744 Draw ();
1745 IncrementUndoSerialNumber ();
1747 return (change);
1750 /* ----------------------------------------------------------------------
1751 * changes the clearance flag (join) of all selected and visible lines
1752 * and/or arcs. Returns true if anything has changed
1754 bool
1755 SetSelectedJoin (int types)
1757 bool change = false;
1759 change = SelectedOperation (&SetJoinFunctions, false, types);
1760 if (change)
1762 Draw ();
1763 IncrementUndoSerialNumber ();
1765 return (change);
1768 /* ----------------------------------------------------------------------
1769 * changes the clearance flag (join) of all selected and visible lines
1770 * and/or arcs. Returns true if anything has changed
1772 bool
1773 ClrSelectedJoin (int types)
1775 bool change = false;
1777 change = SelectedOperation (&ClrJoinFunctions, false, types);
1778 if (change)
1780 Draw ();
1781 IncrementUndoSerialNumber ();
1783 return (change);
1786 /* ----------------------------------------------------------------------
1787 * changes the square-flag of all selected and visible pins or pads
1788 * returns true if anything has changed
1790 bool
1791 ChangeSelectedSquare (int types)
1793 bool change = false;
1795 change = SelectedOperation (&ChangeSquareFunctions, false, types);
1796 if (change)
1798 Draw ();
1799 IncrementUndoSerialNumber ();
1801 return (change);
1804 /* ----------------------------------------------------------------------
1805 * sets the square-flag of all selected and visible pins or pads
1806 * returns true if anything has changed
1808 bool
1809 SetSelectedSquare (int types)
1811 bool change = false;
1813 change = SelectedOperation (&SetSquareFunctions, false, types);
1814 if (change)
1816 Draw ();
1817 IncrementUndoSerialNumber ();
1819 return (change);
1822 /* ----------------------------------------------------------------------
1823 * clears the square-flag of all selected and visible pins or pads
1824 * returns true if anything has changed
1826 bool
1827 ClrSelectedSquare (int types)
1829 bool change = false;
1831 change = SelectedOperation (&ClrSquareFunctions, false, types);
1832 if (change)
1834 Draw ();
1835 IncrementUndoSerialNumber ();
1837 return (change);
1840 /* ----------------------------------------------------------------------
1841 * changes the octagon-flag of all selected and visible pins and vias
1842 * returns true if anything has changed
1844 bool
1845 ChangeSelectedOctagon (int types)
1847 bool change = false;
1849 change = SelectedOperation (&ChangeOctagonFunctions, false, types);
1850 if (change)
1852 Draw ();
1853 IncrementUndoSerialNumber ();
1855 return (change);
1858 /* ----------------------------------------------------------------------
1859 * sets the octagon-flag of all selected and visible pins and vias
1860 * returns true if anything has changed
1862 bool
1863 SetSelectedOctagon (int types)
1865 bool change = false;
1867 change = SelectedOperation (&SetOctagonFunctions, false, types);
1868 if (change)
1870 Draw ();
1871 IncrementUndoSerialNumber ();
1873 return (change);
1876 /* ----------------------------------------------------------------------
1877 * clears the octagon-flag of all selected and visible pins and vias
1878 * returns true if anything has changed
1880 bool
1881 ClrSelectedOctagon (int types)
1883 bool change = false;
1885 change = SelectedOperation (&ClrOctagonFunctions, false, types);
1886 if (change)
1888 Draw ();
1889 IncrementUndoSerialNumber ();
1891 return (change);
1894 /* ----------------------------------------------------------------------
1895 * changes the hole-flag of all selected and visible vias
1896 * returns true if anything has changed
1898 bool
1899 ChangeSelectedHole (void)
1901 bool change = false;
1903 if (PCB->ViaOn)
1904 VIA_LOOP (PCB->Data);
1906 if (TEST_FLAG (SELECTEDFLAG, via))
1907 change |= ChangeHole (via);
1909 END_LOOP;
1910 if (change)
1912 Draw ();
1913 IncrementUndoSerialNumber ();
1915 return (change);
1918 /* ----------------------------------------------------------------------
1919 * changes the no paste-flag of all selected and visible pads
1920 * returns true if anything has changed
1922 bool
1923 ChangeSelectedPaste (void)
1925 bool change = false;
1927 ALLPAD_LOOP (PCB->Data);
1929 if (TEST_FLAG (SELECTEDFLAG, pad))
1930 change |= ChangePaste (pad);
1932 ENDALL_LOOP;
1933 if (change)
1935 Draw ();
1936 IncrementUndoSerialNumber ();
1938 return (change);
1942 /* ---------------------------------------------------------------------------
1943 * changes the size of the passed object
1944 * Returns true if anything is changed
1946 bool
1947 ChangeObjectSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
1948 LocationType Difference, bool fixIt)
1950 bool change;
1952 /* setup identifier */
1953 Absolute = (fixIt) ? Difference : 0;
1954 Delta = Difference;
1955 change =
1956 (ObjectOperation (&ChangeSizeFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL);
1957 if (change)
1959 Draw ();
1960 IncrementUndoSerialNumber ();
1962 return (change);
1965 /* ---------------------------------------------------------------------------
1966 * changes the clearance size of the passed object
1967 * Returns true if anything is changed
1969 bool
1970 ChangeObjectClearSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
1971 LocationType Difference, bool fixIt)
1973 bool change;
1975 /* setup identifier */
1976 Absolute = (fixIt) ? Difference : 0;
1977 Delta = Difference;
1978 if (TEST_FLAG (SHOWMASKFLAG, PCB))
1979 change =
1980 (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
1981 NULL);
1982 else
1983 change =
1984 (ObjectOperation (&ChangeClearSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
1985 NULL);
1986 if (change)
1988 Draw ();
1989 IncrementUndoSerialNumber ();
1991 return (change);
1994 /* ---------------------------------------------------------------------------
1995 * changes the thermal of the passed object
1996 * Returns true if anything is changed
1999 bool
2000 ChangeObjectThermal (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2001 int therm_type)
2003 bool change;
2005 Delta = Absolute = therm_type;
2006 change =
2007 (ObjectOperation (&ChangeThermalFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2008 NULL);
2009 if (change)
2011 Draw ();
2012 IncrementUndoSerialNumber ();
2014 return (change);
2017 /* ---------------------------------------------------------------------------
2018 * changes the 2nd size of the passed object
2019 * Returns true if anything is changed
2021 bool
2022 ChangeObject2ndSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2023 LocationType Difference, bool fixIt, bool incundo)
2025 bool change;
2027 /* setup identifier */
2028 Absolute = (fixIt) ? Difference : 0;
2029 Delta = Difference;
2030 change =
2031 (ObjectOperation (&Change2ndSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2032 NULL);
2033 if (change)
2035 Draw ();
2036 if (incundo)
2037 IncrementUndoSerialNumber ();
2039 return (change);
2042 /* ---------------------------------------------------------------------------
2043 * changes the mask size of the passed object
2044 * Returns true if anything is changed
2046 bool
2047 ChangeObjectMaskSize (int Type, void *Ptr1, void *Ptr2, void *Ptr3,
2048 LocationType Difference, bool fixIt)
2050 bool change;
2052 /* setup identifier */
2053 Absolute = (fixIt) ? Difference : 0;
2054 Delta = Difference;
2055 change =
2056 (ObjectOperation (&ChangeMaskSizeFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2057 NULL);
2058 if (change)
2060 Draw ();
2061 IncrementUndoSerialNumber ();
2063 return (change);
2066 /* ---------------------------------------------------------------------------
2067 * changes the name of the passed object
2068 * returns the old name
2070 * The allocated memory isn't freed because the old string is used
2071 * by the undo module.
2073 void *
2074 ChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3, char *Name)
2076 void *result;
2077 /* setup identifier */
2078 NewName = Name;
2079 if ((result =
2080 ObjectOperation (&ChangeNameFunctions, Type, Ptr1, Ptr2, Ptr3)));
2081 Draw ();
2082 return (result);
2085 /* ---------------------------------------------------------------------------
2086 * changes the clearance-flag of the passed object
2087 * Returns true if anything is changed
2089 bool
2090 ChangeObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2092 if (ObjectOperation (&ChangeJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2094 Draw ();
2095 IncrementUndoSerialNumber ();
2096 return (true);
2098 return (false);
2101 /* ---------------------------------------------------------------------------
2102 * sets the clearance-flag of the passed object
2103 * Returns true if anything is changed
2105 bool
2106 SetObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2108 if (ObjectOperation (&SetJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2110 Draw ();
2111 IncrementUndoSerialNumber ();
2112 return (true);
2114 return (false);
2117 /* ---------------------------------------------------------------------------
2118 * clears the clearance-flag of the passed object
2119 * Returns true if anything is changed
2121 bool
2122 ClrObjectJoin (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2124 if (ObjectOperation (&ClrJoinFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2126 Draw ();
2127 IncrementUndoSerialNumber ();
2128 return (true);
2130 return (false);
2133 /* ---------------------------------------------------------------------------
2134 * changes the square-flag of the passed object
2135 * Returns true if anything is changed
2137 bool
2138 ChangeObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2140 if (ObjectOperation (&ChangeSquareFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2141 NULL)
2143 Draw ();
2144 IncrementUndoSerialNumber ();
2145 return (true);
2147 return (false);
2150 /* ---------------------------------------------------------------------------
2151 * sets the square-flag of the passed object
2152 * Returns true if anything is changed
2154 bool
2155 SetObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2157 if (ObjectOperation (&SetSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2159 Draw ();
2160 IncrementUndoSerialNumber ();
2161 return (true);
2163 return (false);
2166 /* ---------------------------------------------------------------------------
2167 * clears the square-flag of the passed object
2168 * Returns true if anything is changed
2170 bool
2171 ClrObjectSquare (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2173 if (ObjectOperation (&ClrSquareFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2175 Draw ();
2176 IncrementUndoSerialNumber ();
2177 return (true);
2179 return (false);
2182 /* ---------------------------------------------------------------------------
2183 * changes the octagon-flag of the passed object
2184 * Returns true if anything is changed
2186 bool
2187 ChangeObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2189 if (ObjectOperation (&ChangeOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) !=
2190 NULL)
2192 Draw ();
2193 IncrementUndoSerialNumber ();
2194 return (true);
2196 return (false);
2199 /* ---------------------------------------------------------------------------
2200 * sets the octagon-flag of the passed object
2201 * Returns true if anything is changed
2203 bool
2204 SetObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2206 if (ObjectOperation (&SetOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2208 Draw ();
2209 IncrementUndoSerialNumber ();
2210 return (true);
2212 return (false);
2215 /* ---------------------------------------------------------------------------
2216 * clears the octagon-flag of the passed object
2217 * Returns true if anything is changed
2219 bool
2220 ClrObjectOctagon (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2222 if (ObjectOperation (&ClrOctagonFunctions, Type, Ptr1, Ptr2, Ptr3) != NULL)
2224 Draw ();
2225 IncrementUndoSerialNumber ();
2226 return (true);
2228 return (false);
2231 /* ---------------------------------------------------------------------------
2232 * queries the user for a new object name and changes it
2234 * The allocated memory isn't freed because the old string is used
2235 * by the undo module.
2237 void *
2238 QueryInputAndChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
2240 char *name = NULL;
2241 char msg[513];
2243 /* if passed an element name, make it an element reference instead */
2244 if (Type == ELEMENTNAME_TYPE)
2246 Type = ELEMENT_TYPE;
2247 Ptr2 = Ptr1;
2248 Ptr3 = Ptr1;
2250 switch (Type)
2252 case LINE_TYPE:
2253 name = gui->prompt_for (_("Linename:"),
2254 EMPTY (((LineTypePtr) Ptr2)->Number));
2255 break;
2257 case VIA_TYPE:
2258 name = gui->prompt_for (_("Vianame:"),
2259 EMPTY (((PinTypePtr) Ptr2)->Name));
2260 break;
2262 case PIN_TYPE:
2263 sprintf (msg, _("%s Pin Name:"), EMPTY (((PinTypePtr) Ptr2)->Number));
2264 name = gui->prompt_for (msg, EMPTY (((PinTypePtr) Ptr2)->Name));
2265 break;
2267 case PAD_TYPE:
2268 sprintf (msg, _("%s Pad Name:"), EMPTY (((PadTypePtr) Ptr2)->Number));
2269 name = gui->prompt_for (msg, EMPTY (((PadTypePtr) Ptr2)->Name));
2270 break;
2272 case TEXT_TYPE:
2273 name = gui->prompt_for (_("Enter text:"),
2274 EMPTY (((TextTypePtr) Ptr2)->TextString));
2275 break;
2277 case ELEMENT_TYPE:
2278 name = gui->prompt_for (_("Elementname:"),
2279 EMPTY (ELEMENT_NAME
2280 (PCB, (ElementTypePtr) Ptr2)));
2281 break;
2283 if (name)
2285 /* XXX Memory leak!! */
2286 char *old = ChangeObjectName (Type, Ptr1, Ptr2, Ptr3, name);
2287 if (old != (char *) -1)
2289 AddObjectToChangeNameUndoList (Type, Ptr1, Ptr2, Ptr3, old);
2290 IncrementUndoSerialNumber ();
2292 Draw ();
2293 return (Ptr3);
2295 return (NULL);
2298 /* ---------------------------------------------------------------------------
2299 * changes the maximum size of a layout
2300 * adjusts the scrollbars
2301 * releases the saved pixmap if necessary
2302 * and adjusts the cursor confinement box
2304 void
2305 ChangePCBSize (BDimension Width, BDimension Height)
2307 PCB->MaxWidth = Width;
2308 PCB->MaxHeight = Height;
2310 /* crosshair range is different if pastebuffer-mode
2311 * is enabled
2313 if (Settings.Mode == PASTEBUFFER_MODE)
2314 SetCrosshairRange (PASTEBUFFER->X - PASTEBUFFER->BoundingBox.X1,
2315 PASTEBUFFER->Y - PASTEBUFFER->BoundingBox.Y1,
2316 MAX (0,
2317 Width - (PASTEBUFFER->BoundingBox.X2 -
2318 PASTEBUFFER->X)), MAX (0,
2319 Height -
2320 (PASTEBUFFER->
2321 BoundingBox.Y2 -
2322 PASTEBUFFER->
2323 Y)));
2324 else
2325 SetCrosshairRange (0, 0, (LocationType) Width, (LocationType) Height);
2326 hid_action ("PCBChanged");
2329 /* ---------------------------------------------------------------------------
2330 * changes the mask size of a pad
2331 * returns TRUE if changed
2333 static void *
2334 ChangePadMaskSize (ElementTypePtr Element, PadTypePtr Pad)
2336 BDimension value = (Absolute) ? Absolute : Pad->Mask + Delta;
2338 value = MAX (value, 0);
2339 if (value == Pad->Mask && Absolute == 0)
2340 value = Pad->Thickness;
2341 if (value != Pad->Mask)
2343 AddObjectToMaskSizeUndoList (PAD_TYPE, Element, Pad, Pad);
2344 ErasePad (Pad);
2345 r_delete_entry (PCB->Data->pad_tree, &Pad->BoundingBox);
2346 Pad->Mask = value;
2347 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
2348 DrawPad (Pad, 0);
2349 return (Pad);
2351 return (NULL);
2354 /* ---------------------------------------------------------------------------
2355 * changes the mask size of a pin
2356 * returns TRUE if changed
2358 static void *
2359 ChangePinMaskSize (ElementTypePtr Element, PinTypePtr Pin)
2361 BDimension value = (Absolute) ? Absolute : Pin->Mask + Delta;
2363 value = MAX (value, 0);
2364 if (value == Pin->Mask && Absolute == 0)
2365 value = Pin->Thickness;
2366 if (value != Pin->Mask)
2368 AddObjectToMaskSizeUndoList (PIN_TYPE, Element, Pin, Pin);
2369 ErasePin (Pin);
2370 r_delete_entry (PCB->Data->pin_tree, &Pin->BoundingBox);
2371 Pin->Mask = value;
2372 SetElementBoundingBox (PCB->Data, Element, &PCB->Font);
2373 DrawPin (Pin, 0);
2374 return (Pin);
2376 return (NULL);
2379 /* ---------------------------------------------------------------------------
2380 * changes the mask size of a via
2381 * returns TRUE if changed
2383 static void *
2384 ChangeViaMaskSize (PinTypePtr Via)
2386 BDimension value;
2388 value = (Absolute) ? Absolute : Via->Mask + Delta;
2389 value = MAX (value, 0);
2390 if (value != Via->Mask)
2392 AddObjectToMaskSizeUndoList (VIA_TYPE, Via, Via, Via);
2393 EraseVia (Via);
2394 r_delete_entry (PCB->Data->via_tree, &Via->BoundingBox);
2395 Via->Mask = value;
2396 SetPinBoundingBox (Via);
2397 r_insert_entry (PCB->Data->via_tree, &Via->BoundingBox, 0);
2398 DrawVia (Via, 0);
2399 return (Via);
2401 return (NULL);