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
45 #include "crosshair.h"
62 #ifdef HAVE_LIBDMALLOC
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
= {
139 ChangeElementSize
, /* changes silk screen line width */
140 ChangeElementNameSize
,
148 static ObjectFunctionType Change2ndSizeFunctions
= {
153 ChangeElement2ndSize
,
162 static ObjectFunctionType ChangeThermalFunctions
= {
176 static ObjectFunctionType ChangeClearSizeFunctions
= {
179 ChangePolygonClearSize
, /* just to tell the user not to :-) */
190 static ObjectFunctionType ChangeNameFunctions
= {
204 static ObjectFunctionType ChangeSquareFunctions
= {
218 static ObjectFunctionType ChangeJoinFunctions
= {
232 static ObjectFunctionType ChangeOctagonFunctions
= {
237 ChangeElementOctagon
,
246 static ObjectFunctionType ChangeMaskSizeFunctions
= {
252 ChangeElementMaskSize
,
264 static ObjectFunctionType SetSquareFunctions
= {
278 static ObjectFunctionType SetJoinFunctions
= {
292 static ObjectFunctionType SetOctagonFunctions
= {
306 static ObjectFunctionType ClrSquareFunctions
= {
320 static ObjectFunctionType ClrJoinFunctions
= {
334 static ObjectFunctionType ClrOctagonFunctions
= {
349 /* ---------------------------------------------------------------------------
350 * changes the thermal on a via
351 * returns TRUE if changed
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
);
362 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Via
);
363 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
364 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
369 /* ---------------------------------------------------------------------------
370 * changes the thermal on a pin
371 * returns TRUE if changed
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
);
382 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Pin
);
383 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, true);
384 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
389 /* ---------------------------------------------------------------------------
390 * changes the size of a via
391 * returns TRUE if changed
394 ChangeViaSize (PinTypePtr Via
)
396 BDimension value
= Absolute
? Absolute
: Via
->Thickness
+ Delta
;
398 if (TEST_FLAG (LOCKFLAG
, Via
))
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
);
407 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
408 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Via
, Via
);
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
);
424 /* ---------------------------------------------------------------------------
425 * changes the drilling hole of a via
426 * returns TRUE if changed
429 ChangeVia2ndSize (PinTypePtr Via
)
431 BDimension value
= (Absolute
) ? Absolute
: Via
->DrillingHole
+ Delta
;
433 if (TEST_FLAG (LOCKFLAG
, Via
))
435 if (value
<= MAX_PINORVIASIZE
&&
436 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Via
) ||
438 Via
->Thickness
- MIN_PINORVIACOPPER
)
439 && value
!= Via
->DrillingHole
)
441 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, 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
);
458 /* ---------------------------------------------------------------------------
459 * changes the clearance size of a via
460 * returns TRUE if changed
463 ChangeViaClearSize (PinTypePtr Via
)
465 BDimension value
= (Absolute
) ? Absolute
: Via
->Clearance
+ Delta
;
467 if (TEST_FLAG (LOCKFLAG
, Via
))
469 value
= MIN (MAX_LINESIZE
, value
);
472 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
474 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
475 value
= PCB
->Bloat
* 2 + 2;
476 if (Via
->Clearance
== value
)
478 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
479 AddObjectToClearSizeUndoList (VIA_TYPE
, Via
, Via
, 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
);
492 /* ---------------------------------------------------------------------------
493 * changes the size of a pin
494 * returns TRUE if changed
497 ChangePinSize (ElementTypePtr Element
, PinTypePtr Pin
)
499 BDimension value
= (Absolute
) ? Absolute
: Pin
->Thickness
+ Delta
;
501 if (TEST_FLAG (LOCKFLAG
, Pin
))
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
);
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
);
524 /* ---------------------------------------------------------------------------
525 * changes the clearance size of a pin
526 * returns TRUE if changed
529 ChangePinClearSize (ElementTypePtr Element
, PinTypePtr Pin
)
531 BDimension value
= (Absolute
) ? Absolute
: Pin
->Clearance
+ Delta
;
533 if (TEST_FLAG (LOCKFLAG
, Pin
))
535 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
536 if (Pin
->Clearance
== value
)
538 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
539 AddObjectToClearSizeUndoList (PIN_TYPE
, Element
, Pin
, 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
);
550 /* ---------------------------------------------------------------------------
551 * changes the size of a pad
552 * returns TRUE if changed
555 ChangePadSize (ElementTypePtr Element
, PadTypePtr Pad
)
557 BDimension value
= (Absolute
) ? Absolute
: Pad
->Thickness
+ Delta
;
559 if (TEST_FLAG (LOCKFLAG
, Pad
))
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
);
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
);
579 /* ---------------------------------------------------------------------------
580 * changes the clearance size of a pad
581 * returns TRUE if changed
584 ChangePadClearSize (ElementTypePtr Element
, PadTypePtr Pad
)
586 BDimension value
= (Absolute
) ? Absolute
: Pad
->Clearance
+ Delta
;
588 if (TEST_FLAG (LOCKFLAG
, Pad
))
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
);
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
);
607 /* ---------------------------------------------------------------------------
608 * changes the drilling hole of all pins of an element
609 * returns TRUE if changed
612 ChangeElement2ndSize (ElementTypePtr Element
)
614 bool changed
= false;
617 if (TEST_FLAG (LOCKFLAG
, Element
))
621 value
= (Absolute
) ? Absolute
: pin
->DrillingHole
+ Delta
;
622 if (value
<= MAX_PINORVIASIZE
&&
623 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, pin
) ||
627 && value
!= pin
->DrillingHole
)
630 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
632 pin
->DrillingHole
= value
;
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
);
650 /* ---------------------------------------------------------------------------
651 * changes the drilling hole of a pin
652 * returns TRUE if changed
655 ChangePin2ndSize (ElementTypePtr Element
, PinTypePtr Pin
)
657 BDimension value
= (Absolute
) ? Absolute
: Pin
->DrillingHole
+ Delta
;
659 if (TEST_FLAG (LOCKFLAG
, Pin
))
661 if (value
<= MAX_PINORVIASIZE
&&
662 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Pin
) ||
664 Pin
->Thickness
- MIN_PINORVIACOPPER
)
665 && value
!= Pin
->DrillingHole
)
667 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
669 Pin
->DrillingHole
= value
;
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
);
683 /* ---------------------------------------------------------------------------
684 * changes the size of a line
685 * returns TRUE if changed
688 ChangeLineSize (LayerTypePtr Layer
, LineTypePtr Line
)
690 BDimension value
= (Absolute
) ? Absolute
: Line
->Thickness
+ Delta
;
692 if (TEST_FLAG (LOCKFLAG
, Line
))
694 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
695 value
!= Line
->Thickness
)
697 AddObjectToSizeUndoList (LINE_TYPE
, Layer
, Line
, 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);
711 /* ---------------------------------------------------------------------------
712 * changes the clearance size of a line
713 * returns TRUE if changed
716 ChangeLineClearSize (LayerTypePtr Layer
, LineTypePtr Line
)
718 BDimension value
= (Absolute
) ? Absolute
: Line
->Clearance
+ Delta
;
720 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
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
);
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);
744 /* ---------------------------------------------------------------------------
745 * Handle attepts to change the clearance of a polygon.
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)"),
758 shown_this_message
= 1;
764 /* ---------------------------------------------------------------------------
765 * changes the size of an arc
766 * returns TRUE if changed
769 ChangeArcSize (LayerTypePtr Layer
, ArcTypePtr Arc
)
771 BDimension value
= (Absolute
) ? Absolute
: Arc
->Thickness
+ Delta
;
773 if (TEST_FLAG (LOCKFLAG
, Arc
))
775 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
776 value
!= Arc
->Thickness
)
778 AddObjectToSizeUndoList (ARC_TYPE
, Layer
, Arc
, 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);
792 /* ---------------------------------------------------------------------------
793 * changes the clearance size of an arc
794 * returns TRUE if changed
797 ChangeArcClearSize (LayerTypePtr Layer
, ArcTypePtr Arc
)
799 BDimension value
= (Absolute
) ? Absolute
: Arc
->Clearance
+ Delta
;
801 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
803 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
804 if (value
!= Arc
->Clearance
)
806 AddObjectToClearSizeUndoList (ARC_TYPE
, Layer
, Arc
, 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);
825 /* ---------------------------------------------------------------------------
826 * changes the scaling factor of a text object
827 * returns TRUE if changed
830 ChangeTextSize (LayerTypePtr Layer
, TextTypePtr Text
)
832 BDimension value
= (Absolute
) ? Absolute
/ 45 : Text
->Scale
+ Delta
/ 45;
834 if (TEST_FLAG (LOCKFLAG
, Text
))
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
);
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);
853 /* ---------------------------------------------------------------------------
854 * changes the scaling factor of an element's outline
855 * returns TRUE if changed
858 ChangeElementSize (ElementTypePtr Element
)
861 bool changed
= false;
863 if (TEST_FLAG (LOCKFLAG
, Element
))
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
;
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
;
893 DrawElement (Element
, 0);
900 /* ---------------------------------------------------------------------------
901 * changes the scaling factor of a elementname object
902 * returns TRUE if changed
905 ChangeElementNameSize (ElementTypePtr Element
)
908 (Absolute
) ? Absolute
/ 45 : DESCRIPTION_TEXT (Element
).Scale
+
911 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
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
);
921 SetTextBoundingBox (&PCB
->Font
, text
);
922 r_insert_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
, 0);
925 DrawElementName (Element
, 0);
931 /* ---------------------------------------------------------------------------
932 * changes the name of a via
935 ChangeViaName (PinTypePtr Via
)
937 char *old
= Via
->Name
;
939 if (TEST_FLAG (DISPLAYNAMEFLAG
, Via
))
943 DrawPinName (Via
, 0);
950 /* ---------------------------------------------------------------------------
951 * changes the name of a pin
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
))
963 DrawPinName (Pin
, 0);
970 /* ---------------------------------------------------------------------------
971 * changes the name of a pad
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
))
983 DrawPadName (Pad
, 0);
990 /* ---------------------------------------------------------------------------
991 * changes the name of a line
994 ChangeLineName (LayerTypePtr Layer
, LineTypePtr Line
)
996 char *old
= Line
->Number
;
999 Line
->Number
= NewName
;
1003 /* ---------------------------------------------------------------------------
1004 * changes the layout-name of an element
1008 ChangeElementText (PCBType
*pcb
, DataType
*data
, ElementTypePtr Element
, int which
, char *new_name
)
1010 char *old
= Element
->Name
[which
].TextString
;
1013 printf("In ChangeElementText, updating old TextString %s to %s\n", old
, new_name
);
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);
1035 ChangeElementName (ElementTypePtr Element
)
1037 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
1039 if (NAME_INDEX (PCB
) == NAMEONPCB_INDEX
)
1041 if (TEST_FLAG (UNIQUENAMEFLAG
, PCB
) &&
1042 UniqueElementName (PCB
->Data
, NewName
) != NewName
)
1044 Message (_("Error: The name \"%s\" is not unique!\n"), NewName
);
1045 return ((char *) -1);
1049 return ChangeElementText (PCB
, PCB
->Data
, Element
, NAME_INDEX (PCB
), NewName
);
1052 /* ---------------------------------------------------------------------------
1053 * sets data of a text object and calculates bounding box
1054 * memory must have already been allocated
1055 * the one for the new string is allocated
1056 * returns true if the string has been changed
1059 ChangeTextName (LayerTypePtr Layer
, TextTypePtr Text
)
1061 char *old
= Text
->TextString
;
1063 if (TEST_FLAG (LOCKFLAG
, Text
))
1065 EraseText (Layer
, Text
);
1066 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1067 Text
->TextString
= NewName
;
1069 /* calculate size of the bounding box */
1070 SetTextBoundingBox (&PCB
->Font
, Text
);
1071 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1072 DrawText (Layer
, Text
, 0);
1076 /* ---------------------------------------------------------------------------
1077 * changes the name of a layout; memory has to be already allocated
1080 ChangeLayoutName (char *Name
)
1084 hid_action ("PCBChanged");
1088 /* ---------------------------------------------------------------------------
1089 * changes the side of the board an element is on
1090 * returns TRUE if done
1093 ChangeElementSide (ElementTypePtr Element
, LocationType yoff
)
1095 if (TEST_FLAG (LOCKFLAG
, Element
))
1097 EraseElement (Element
);
1098 AddObjectToMirrorUndoList (ELEMENT_TYPE
, Element
, Element
, Element
, yoff
);
1099 MirrorElementCoordinates (PCB
->Data
, Element
, yoff
);
1100 DrawElement (Element
, 0);
1104 /* ---------------------------------------------------------------------------
1105 * changes the name of a layer; memory has to be already allocated
1108 ChangeLayerName (LayerTypePtr Layer
, char *Name
)
1110 free (CURRENT
->Name
);
1111 CURRENT
->Name
= Name
;
1112 hid_action ("LayersChanged");
1116 /* ---------------------------------------------------------------------------
1117 * changes the clearance flag of a line
1120 ChangeLineJoin (LayerTypePtr Layer
, LineTypePtr Line
)
1122 if (TEST_FLAG (LOCKFLAG
, 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);
1141 /* ---------------------------------------------------------------------------
1142 * sets the clearance flag of a line
1145 SetLineJoin (LayerTypePtr Layer
, LineTypePtr Line
)
1147 if (TEST_FLAG (LOCKFLAG
, Line
) || TEST_FLAG (CLEARLINEFLAG
, Line
))
1149 return ChangeLineJoin (Layer
, Line
);
1152 /* ---------------------------------------------------------------------------
1153 * clears the clearance flag of a line
1156 ClrLineJoin (LayerTypePtr Layer
, LineTypePtr Line
)
1158 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
1160 return ChangeLineJoin (Layer
, Line
);
1163 /* ---------------------------------------------------------------------------
1164 * changes the clearance flag of an arc
1167 ChangeArcJoin (LayerTypePtr Layer
, ArcTypePtr Arc
)
1169 if (TEST_FLAG (LOCKFLAG
, 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);
1188 /* ---------------------------------------------------------------------------
1189 * sets the clearance flag of an arc
1192 SetArcJoin (LayerTypePtr Layer
, ArcTypePtr Arc
)
1194 if (TEST_FLAG (LOCKFLAG
, Arc
) || TEST_FLAG (CLEARLINEFLAG
, Arc
))
1196 return ChangeArcJoin (Layer
, Arc
);
1199 /* ---------------------------------------------------------------------------
1200 * clears the clearance flag of an arc
1203 ClrArcJoin (LayerTypePtr Layer
, ArcTypePtr Arc
)
1205 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
1207 return ChangeArcJoin (Layer
, Arc
);
1210 /* ---------------------------------------------------------------------------
1211 * changes the clearance flag of a text
1214 ChangeTextJoin (LayerTypePtr Layer
, TextTypePtr Text
)
1216 if (TEST_FLAG (LOCKFLAG
, Text
))
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);
1235 /* ---------------------------------------------------------------------------
1236 * sets the clearance flag of a text
1239 SetTextJoin (LayerTypePtr Layer
, TextTypePtr Text
)
1241 if (TEST_FLAG (LOCKFLAG
, Text
) || TEST_FLAG (CLEARLINEFLAG
, Text
))
1243 return ChangeTextJoin (Layer
, Text
);
1246 /* ---------------------------------------------------------------------------
1247 * clears the clearance flag of a text
1250 ClrTextJoin (LayerTypePtr Layer
, TextTypePtr Text
)
1252 if (TEST_FLAG (LOCKFLAG
, Text
) || !TEST_FLAG (CLEARLINEFLAG
, Text
))
1254 return ChangeTextJoin (Layer
, Text
);
1257 /* ---------------------------------------------------------------------------
1258 * changes the square flag of all pins on an element
1261 ChangeElementSquare (ElementTypePtr Element
)
1265 if (TEST_FLAG (LOCKFLAG
, Element
))
1269 ans
= ChangePinSquare (Element
, pin
);
1274 ans
= ChangePadSquare (Element
, pad
);
1280 /* ---------------------------------------------------------------------------
1281 * sets the square flag of all pins on an element
1284 SetElementSquare (ElementTypePtr Element
)
1288 if (TEST_FLAG (LOCKFLAG
, Element
))
1292 ans
= SetPinSquare (Element
, pin
);
1297 ans
= SetPadSquare (Element
, pad
);
1303 /* ---------------------------------------------------------------------------
1304 * clears the square flag of all pins on an element
1307 ClrElementSquare (ElementTypePtr Element
)
1311 if (TEST_FLAG (LOCKFLAG
, Element
))
1315 ans
= ClrPinSquare (Element
, pin
);
1320 ans
= ClrPadSquare (Element
, pad
);
1326 /* ---------------------------------------------------------------------------
1327 * changes the octagon flags of all pins of an element
1330 ChangeElementOctagon (ElementTypePtr Element
)
1332 void *result
= NULL
;
1334 if (TEST_FLAG (LOCKFLAG
, Element
))
1338 ChangePinOctagon (Element
, pin
);
1345 /* ---------------------------------------------------------------------------
1346 * sets the octagon flags of all pins of an element
1349 SetElementOctagon (ElementTypePtr Element
)
1351 void *result
= NULL
;
1353 if (TEST_FLAG (LOCKFLAG
, Element
))
1357 SetPinOctagon (Element
, pin
);
1364 /* ---------------------------------------------------------------------------
1365 * clears the octagon flags of all pins of an element
1368 ClrElementOctagon (ElementTypePtr Element
)
1370 void *result
= NULL
;
1372 if (TEST_FLAG (LOCKFLAG
, Element
))
1376 ClrPinOctagon (Element
, pin
);
1383 /* ---------------------------------------------------------------------------
1384 * changes the square flag of a pad
1387 ChangePadSquare (ElementTypePtr Element
, PadTypePtr Pad
)
1389 if (TEST_FLAG (LOCKFLAG
, 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
);
1402 /* ---------------------------------------------------------------------------
1403 * sets the square flag of a pad
1406 SetPadSquare (ElementTypePtr Element
, PadTypePtr Pad
)
1409 if (TEST_FLAG (LOCKFLAG
, Pad
) || TEST_FLAG (SQUAREFLAG
, Pad
))
1412 return (ChangePadSquare (Element
, Pad
));
1416 /* ---------------------------------------------------------------------------
1417 * clears the square flag of a pad
1420 ClrPadSquare (ElementTypePtr Element
, PadTypePtr Pad
)
1423 if (TEST_FLAG (LOCKFLAG
, Pad
) || !TEST_FLAG (SQUAREFLAG
, Pad
))
1426 return (ChangePadSquare (Element
, Pad
));
1430 /* ---------------------------------------------------------------------------
1431 * changes the square flag of a pin
1434 ChangePinSquare (ElementTypePtr Element
, PinTypePtr Pin
)
1436 if (TEST_FLAG (LOCKFLAG
, 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
);
1449 /* ---------------------------------------------------------------------------
1450 * sets the square flag of a pin
1453 SetPinSquare (ElementTypePtr Element
, PinTypePtr Pin
)
1455 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (SQUAREFLAG
, Pin
))
1458 return (ChangePinSquare (Element
, Pin
));
1461 /* ---------------------------------------------------------------------------
1462 * clears the square flag of a pin
1465 ClrPinSquare (ElementTypePtr Element
, PinTypePtr Pin
)
1467 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (SQUAREFLAG
, Pin
))
1470 return (ChangePinSquare (Element
, Pin
));
1473 /* ---------------------------------------------------------------------------
1474 * changes the octagon flag of a via
1477 ChangeViaOctagon (PinTypePtr Via
)
1479 if (TEST_FLAG (LOCKFLAG
, 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
);
1492 /* ---------------------------------------------------------------------------
1493 * sets the octagon flag of a via
1496 SetViaOctagon (PinTypePtr Via
)
1498 if (TEST_FLAG (LOCKFLAG
, Via
) || TEST_FLAG (OCTAGONFLAG
, Via
))
1501 return (ChangeViaOctagon (Via
));
1504 /* ---------------------------------------------------------------------------
1505 * clears the octagon flag of a via
1508 ClrViaOctagon (PinTypePtr Via
)
1510 if (TEST_FLAG (LOCKFLAG
, Via
) || !TEST_FLAG (OCTAGONFLAG
, Via
))
1513 return (ChangeViaOctagon (Via
));
1516 /* ---------------------------------------------------------------------------
1517 * changes the octagon flag of a pin
1520 ChangePinOctagon (ElementTypePtr Element
, PinTypePtr Pin
)
1522 if (TEST_FLAG (LOCKFLAG
, 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
);
1535 /* ---------------------------------------------------------------------------
1536 * sets the octagon flag of a pin
1539 SetPinOctagon (ElementTypePtr Element
, PinTypePtr Pin
)
1541 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (OCTAGONFLAG
, Pin
))
1544 return (ChangePinOctagon (Element
, Pin
));
1547 /* ---------------------------------------------------------------------------
1548 * clears the octagon flag of a pin
1551 ClrPinOctagon (ElementTypePtr Element
, PinTypePtr Pin
)
1553 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (OCTAGONFLAG
, Pin
))
1556 return (ChangePinOctagon (Element
, Pin
));
1559 /* ---------------------------------------------------------------------------
1560 * changes the hole flag of a via
1563 ChangeHole (PinTypePtr Via
)
1565 if (TEST_FLAG (LOCKFLAG
, 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
);
1579 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1580 Via
->DrillingHole
= Via
->Thickness
- MIN_PINORVIACOPPER
;
1587 /* ---------------------------------------------------------------------------
1588 * changes the nopaste flag of a pad
1591 ChangePaste (PadTypePtr Pad
)
1593 if (TEST_FLAG (LOCKFLAG
, Pad
))
1596 AddObjectToFlagUndoList (PAD_TYPE
, Pad
, Pad
, Pad
);
1597 TOGGLE_FLAG (NOPASTEFLAG
, Pad
);
1603 /* ---------------------------------------------------------------------------
1604 * changes the CLEARPOLY flag of a polygon
1607 ChangePolyClear (LayerTypePtr Layer
, PolygonTypePtr Polygon
)
1609 if (TEST_FLAG (LOCKFLAG
, Polygon
))
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);
1619 /* ----------------------------------------------------------------------
1620 * changes the side of all selected and visible elements
1621 * returns true if anything has changed
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);
1641 IncrementUndoSerialNumber ();
1646 /* ----------------------------------------------------------------------
1647 * changes the thermals on all selected and visible pins
1648 * and/or vias. Returns true if anything has changed
1651 ChangeSelectedThermals (int types
, int therm_style
)
1653 bool change
= false;
1655 Delta
= therm_style
;
1656 change
= SelectedOperation (&ChangeThermalFunctions
, false, types
);
1660 IncrementUndoSerialNumber ();
1665 /* ----------------------------------------------------------------------
1666 * changes the size of all selected and visible object types
1667 * returns true if anything has changed
1670 ChangeSelectedSize (int types
, LocationType Difference
, bool fixIt
)
1672 bool change
= false;
1674 /* setup identifiers */
1675 Absolute
= (fixIt
) ? Difference
: 0;
1678 change
= SelectedOperation (&ChangeSizeFunctions
, false, types
);
1682 IncrementUndoSerialNumber ();
1687 /* ----------------------------------------------------------------------
1688 * changes the clearance size of all selected and visible objects
1689 * returns true if anything has changed
1692 ChangeSelectedClearSize (int types
, LocationType Difference
, bool fixIt
)
1694 bool change
= false;
1696 /* setup identifiers */
1697 Absolute
= (fixIt
) ? Difference
: 0;
1699 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1700 change
= SelectedOperation (&ChangeMaskSizeFunctions
, false, types
);
1702 change
= SelectedOperation (&ChangeClearSizeFunctions
, false, types
);
1706 IncrementUndoSerialNumber ();
1711 /* --------------------------------------------------------------------------
1712 * changes the 2nd size (drilling hole) of all selected and visible objects
1713 * returns true if anything has changed
1716 ChangeSelected2ndSize (int types
, LocationType Difference
, bool fixIt
)
1718 bool change
= false;
1720 /* setup identifiers */
1721 Absolute
= (fixIt
) ? Difference
: 0;
1723 change
= SelectedOperation (&Change2ndSizeFunctions
, false, types
);
1727 IncrementUndoSerialNumber ();
1732 /* ----------------------------------------------------------------------
1733 * changes the clearance flag (join) of all selected and visible lines
1734 * and/or arcs. Returns true if anything has changed
1737 ChangeSelectedJoin (int types
)
1739 bool change
= false;
1741 change
= SelectedOperation (&ChangeJoinFunctions
, false, types
);
1745 IncrementUndoSerialNumber ();
1750 /* ----------------------------------------------------------------------
1751 * changes the clearance flag (join) of all selected and visible lines
1752 * and/or arcs. Returns true if anything has changed
1755 SetSelectedJoin (int types
)
1757 bool change
= false;
1759 change
= SelectedOperation (&SetJoinFunctions
, false, types
);
1763 IncrementUndoSerialNumber ();
1768 /* ----------------------------------------------------------------------
1769 * changes the clearance flag (join) of all selected and visible lines
1770 * and/or arcs. Returns true if anything has changed
1773 ClrSelectedJoin (int types
)
1775 bool change
= false;
1777 change
= SelectedOperation (&ClrJoinFunctions
, false, types
);
1781 IncrementUndoSerialNumber ();
1786 /* ----------------------------------------------------------------------
1787 * changes the square-flag of all selected and visible pins or pads
1788 * returns true if anything has changed
1791 ChangeSelectedSquare (int types
)
1793 bool change
= false;
1795 change
= SelectedOperation (&ChangeSquareFunctions
, false, types
);
1799 IncrementUndoSerialNumber ();
1804 /* ----------------------------------------------------------------------
1805 * sets the square-flag of all selected and visible pins or pads
1806 * returns true if anything has changed
1809 SetSelectedSquare (int types
)
1811 bool change
= false;
1813 change
= SelectedOperation (&SetSquareFunctions
, false, types
);
1817 IncrementUndoSerialNumber ();
1822 /* ----------------------------------------------------------------------
1823 * clears the square-flag of all selected and visible pins or pads
1824 * returns true if anything has changed
1827 ClrSelectedSquare (int types
)
1829 bool change
= false;
1831 change
= SelectedOperation (&ClrSquareFunctions
, false, types
);
1835 IncrementUndoSerialNumber ();
1840 /* ----------------------------------------------------------------------
1841 * changes the octagon-flag of all selected and visible pins and vias
1842 * returns true if anything has changed
1845 ChangeSelectedOctagon (int types
)
1847 bool change
= false;
1849 change
= SelectedOperation (&ChangeOctagonFunctions
, false, types
);
1853 IncrementUndoSerialNumber ();
1858 /* ----------------------------------------------------------------------
1859 * sets the octagon-flag of all selected and visible pins and vias
1860 * returns true if anything has changed
1863 SetSelectedOctagon (int types
)
1865 bool change
= false;
1867 change
= SelectedOperation (&SetOctagonFunctions
, false, types
);
1871 IncrementUndoSerialNumber ();
1876 /* ----------------------------------------------------------------------
1877 * clears the octagon-flag of all selected and visible pins and vias
1878 * returns true if anything has changed
1881 ClrSelectedOctagon (int types
)
1883 bool change
= false;
1885 change
= SelectedOperation (&ClrOctagonFunctions
, false, types
);
1889 IncrementUndoSerialNumber ();
1894 /* ----------------------------------------------------------------------
1895 * changes the hole-flag of all selected and visible vias
1896 * returns true if anything has changed
1899 ChangeSelectedHole (void)
1901 bool change
= false;
1904 VIA_LOOP (PCB
->Data
);
1906 if (TEST_FLAG (SELECTEDFLAG
, via
))
1907 change
|= ChangeHole (via
);
1913 IncrementUndoSerialNumber ();
1918 /* ----------------------------------------------------------------------
1919 * changes the no paste-flag of all selected and visible pads
1920 * returns true if anything has changed
1923 ChangeSelectedPaste (void)
1925 bool change
= false;
1927 ALLPAD_LOOP (PCB
->Data
);
1929 if (TEST_FLAG (SELECTEDFLAG
, pad
))
1930 change
|= ChangePaste (pad
);
1936 IncrementUndoSerialNumber ();
1942 /* ---------------------------------------------------------------------------
1943 * changes the size of the passed object
1944 * Returns true if anything is changed
1947 ChangeObjectSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1948 LocationType Difference
, bool fixIt
)
1952 /* setup identifier */
1953 Absolute
= (fixIt
) ? Difference
: 0;
1956 (ObjectOperation (&ChangeSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
);
1960 IncrementUndoSerialNumber ();
1965 /* ---------------------------------------------------------------------------
1966 * changes the clearance size of the passed object
1967 * Returns true if anything is changed
1970 ChangeObjectClearSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1971 LocationType Difference
, bool fixIt
)
1975 /* setup identifier */
1976 Absolute
= (fixIt
) ? Difference
: 0;
1978 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1980 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
1984 (ObjectOperation (&ChangeClearSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
1989 IncrementUndoSerialNumber ();
1994 /* ---------------------------------------------------------------------------
1995 * changes the thermal of the passed object
1996 * Returns true if anything is changed
2000 ChangeObjectThermal (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2005 Delta
= Absolute
= therm_type
;
2007 (ObjectOperation (&ChangeThermalFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2012 IncrementUndoSerialNumber ();
2017 /* ---------------------------------------------------------------------------
2018 * changes the 2nd size of the passed object
2019 * Returns true if anything is changed
2022 ChangeObject2ndSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2023 LocationType Difference
, bool fixIt
, bool incundo
)
2027 /* setup identifier */
2028 Absolute
= (fixIt
) ? Difference
: 0;
2031 (ObjectOperation (&Change2ndSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2037 IncrementUndoSerialNumber ();
2042 /* ---------------------------------------------------------------------------
2043 * changes the mask size of the passed object
2044 * Returns true if anything is changed
2047 ChangeObjectMaskSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2048 LocationType Difference
, bool fixIt
)
2052 /* setup identifier */
2053 Absolute
= (fixIt
) ? Difference
: 0;
2056 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2061 IncrementUndoSerialNumber ();
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.
2074 ChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
, char *Name
)
2077 /* setup identifier */
2080 ObjectOperation (&ChangeNameFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
)));
2085 /* ---------------------------------------------------------------------------
2086 * changes the clearance-flag of the passed object
2087 * Returns true if anything is changed
2090 ChangeObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2092 if (ObjectOperation (&ChangeJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2095 IncrementUndoSerialNumber ();
2101 /* ---------------------------------------------------------------------------
2102 * sets the clearance-flag of the passed object
2103 * Returns true if anything is changed
2106 SetObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2108 if (ObjectOperation (&SetJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2111 IncrementUndoSerialNumber ();
2117 /* ---------------------------------------------------------------------------
2118 * clears the clearance-flag of the passed object
2119 * Returns true if anything is changed
2122 ClrObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2124 if (ObjectOperation (&ClrJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2127 IncrementUndoSerialNumber ();
2133 /* ---------------------------------------------------------------------------
2134 * changes the square-flag of the passed object
2135 * Returns true if anything is changed
2138 ChangeObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2140 if (ObjectOperation (&ChangeSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2144 IncrementUndoSerialNumber ();
2150 /* ---------------------------------------------------------------------------
2151 * sets the square-flag of the passed object
2152 * Returns true if anything is changed
2155 SetObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2157 if (ObjectOperation (&SetSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2160 IncrementUndoSerialNumber ();
2166 /* ---------------------------------------------------------------------------
2167 * clears the square-flag of the passed object
2168 * Returns true if anything is changed
2171 ClrObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2173 if (ObjectOperation (&ClrSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2176 IncrementUndoSerialNumber ();
2182 /* ---------------------------------------------------------------------------
2183 * changes the octagon-flag of the passed object
2184 * Returns true if anything is changed
2187 ChangeObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2189 if (ObjectOperation (&ChangeOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2193 IncrementUndoSerialNumber ();
2199 /* ---------------------------------------------------------------------------
2200 * sets the octagon-flag of the passed object
2201 * Returns true if anything is changed
2204 SetObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2206 if (ObjectOperation (&SetOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2209 IncrementUndoSerialNumber ();
2215 /* ---------------------------------------------------------------------------
2216 * clears the octagon-flag of the passed object
2217 * Returns true if anything is changed
2220 ClrObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2222 if (ObjectOperation (&ClrOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2225 IncrementUndoSerialNumber ();
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.
2238 QueryInputAndChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2243 /* if passed an element name, make it an element reference instead */
2244 if (Type
== ELEMENTNAME_TYPE
)
2246 Type
= ELEMENT_TYPE
;
2253 name
= gui
->prompt_for (_("Linename:"),
2254 EMPTY (((LineTypePtr
) Ptr2
)->Number
));
2258 name
= gui
->prompt_for (_("Vianame:"),
2259 EMPTY (((PinTypePtr
) Ptr2
)->Name
));
2263 sprintf (msg
, _("%s Pin Name:"), EMPTY (((PinTypePtr
) Ptr2
)->Number
));
2264 name
= gui
->prompt_for (msg
, EMPTY (((PinTypePtr
) Ptr2
)->Name
));
2268 sprintf (msg
, _("%s Pad Name:"), EMPTY (((PadTypePtr
) Ptr2
)->Number
));
2269 name
= gui
->prompt_for (msg
, EMPTY (((PadTypePtr
) Ptr2
)->Name
));
2273 name
= gui
->prompt_for (_("Enter text:"),
2274 EMPTY (((TextTypePtr
) Ptr2
)->TextString
));
2278 name
= gui
->prompt_for (_("Elementname:"),
2280 (PCB
, (ElementTypePtr
) Ptr2
)));
2285 /* NB: ChangeObjectName takes ownership of the passed memory */
2286 char *old
= ChangeObjectName (Type
, Ptr1
, Ptr2
, Ptr3
, name
);
2287 if (old
!= (char *) -1)
2289 AddObjectToChangeNameUndoList (Type
, Ptr1
, Ptr2
, Ptr3
, old
);
2290 IncrementUndoSerialNumber ();
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
2305 ChangePCBSize (BDimension Width
, BDimension Height
)
2307 PCB
->MaxWidth
= Width
;
2308 PCB
->MaxHeight
= Height
;
2310 /* crosshair range is different if pastebuffer-mode
2313 if (Settings
.Mode
== PASTEBUFFER_MODE
)
2314 SetCrosshairRange (PASTEBUFFER
->X
- PASTEBUFFER
->BoundingBox
.X1
,
2315 PASTEBUFFER
->Y
- PASTEBUFFER
->BoundingBox
.Y1
,
2317 Width
- (PASTEBUFFER
->BoundingBox
.X2
-
2318 PASTEBUFFER
->X
)), MAX (0,
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
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
);
2345 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
2347 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2354 /* ---------------------------------------------------------------------------
2355 * changes the mask size of a pin
2356 * returns TRUE if changed
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
);
2370 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
2372 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2379 /* ---------------------------------------------------------------------------
2380 * changes the mask size of a via
2381 * returns TRUE if changed
2384 ChangeViaMaskSize (PinTypePtr Via
)
2388 value
= (Absolute
) ? Absolute
: Via
->Mask
+ Delta
;
2389 value
= MAX (value
, 0);
2390 if (value
!= Via
->Mask
)
2392 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
2394 r_delete_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
);
2396 SetPinBoundingBox (Via
);
2397 r_insert_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
, 0);