4 * \brief Functions used to change object properties.
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 1994,1995,1996, 2005 Thomas Nau
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Contact addresses for paper mail and Email:
29 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
30 * Thomas.Nau@rz.uni-ulm.de
44 #include "crosshair.h"
61 #ifdef HAVE_LIBDMALLOC
65 /* ---------------------------------------------------------------------------
66 * some local prototypes
68 static void *ChangePinSize (ElementType
*, PinType
*);
69 static void *ChangePinClearSize (ElementType
*, PinType
*);
70 static void *ChangePinMaskSize (ElementType
*, PinType
*);
71 static void *ChangePadSize (ElementType
*, PadType
*);
72 static void *ChangePadClearSize (ElementType
*, PadType
*);
73 static void *ChangePadMaskSize (ElementType
*, PadType
*);
74 static void *ChangePin2ndSize (ElementType
*, PinType
*);
75 static void *ChangeElement2ndSize (ElementType
*);
76 static void *ChangeViaSize (PinType
*);
77 static void *ChangeVia2ndSize (PinType
*);
78 static void *ChangeViaClearSize (PinType
*);
79 static void *ChangeViaMaskSize (PinType
*);
80 static void *ChangeLineSize (LayerType
*, LineType
*);
81 static void *ChangeLineClearSize (LayerType
*, LineType
*);
82 static void *ChangePolygonClearSize (LayerType
*, PolygonType
*);
83 static void *ChangeArcSize (LayerType
*, ArcType
*);
84 static void *ChangeArcClearSize (LayerType
*, ArcType
*);
85 static void *ChangeTextSize (LayerType
*, TextType
*);
86 static void *ChangeElementSize (ElementType
*);
87 static void *ChangeElementNameSize (ElementType
*);
88 static void *ChangePinName (ElementType
*, PinType
*);
89 static void *ChangePadName (ElementType
*, PadType
*);
90 static void *ChangeViaName (PinType
*);
91 static void *ChangeLineName (LayerType
*, LineType
*);
92 static void *ChangeElementName (ElementType
*);
93 static void *ChangeTextName (LayerType
*, TextType
*);
94 static void *ChangeElementSquare (ElementType
*);
95 static void *SetElementSquare (ElementType
*);
96 static void *ClrElementSquare (ElementType
*);
97 static void *ChangeElementOctagon (ElementType
*);
98 static void *SetElementOctagon (ElementType
*);
99 static void *ClrElementOctagon (ElementType
*);
100 static void *ChangePinSquare (ElementType
*, PinType
*);
101 static void *SetPinSquare (ElementType
*, PinType
*);
102 static void *ClrPinSquare (ElementType
*, PinType
*);
103 static void *ChangePinOctagon (ElementType
*, PinType
*);
104 static void *SetPinOctagon (ElementType
*, PinType
*);
105 static void *ClrPinOctagon (ElementType
*, PinType
*);
106 static void *ChangeViaOctagon (PinType
*);
107 static void *SetViaOctagon (PinType
*);
108 static void *ClrViaOctagon (PinType
*);
109 static void *ChangePadSquare (ElementType
*, PadType
*);
110 static void *SetPadSquare (ElementType
*, PadType
*);
111 static void *ClrPadSquare (ElementType
*, PadType
*);
112 static void *ChangeViaThermal (PinType
*);
113 static void *ChangePinThermal (ElementType
*, PinType
*);
114 static void *ChangeLineJoin (LayerType
*, LineType
*);
115 static void *SetLineJoin (LayerType
*, LineType
*);
116 static void *ClrLineJoin (LayerType
*, LineType
*);
117 static void *ChangeArcJoin (LayerType
*, ArcType
*);
118 static void *SetArcJoin (LayerType
*, ArcType
*);
119 static void *ClrArcJoin (LayerType
*, ArcType
*);
120 static void *ChangeTextJoin (LayerType
*, TextType
*);
121 static void *SetTextJoin (LayerType
*, TextType
*);
122 static void *ClrTextJoin (LayerType
*, TextType
*);
123 static void *ChangePolyClear (LayerType
*, PolygonType
*);
125 /* ---------------------------------------------------------------------------
126 * some local identifiers
128 static int Delta
; /* change of size */
129 static int Absolute
; /* Absolute size */
130 static char *NewName
; /* new name */
131 static ObjectFunctionType ChangeSizeFunctions
= {
136 ChangeElementSize
, /* changes silk screen line width */
137 ChangeElementNameSize
,
145 static ObjectFunctionType Change2ndSizeFunctions
= {
150 ChangeElement2ndSize
,
159 static ObjectFunctionType ChangeThermalFunctions
= {
173 static ObjectFunctionType ChangeClearSizeFunctions
= {
176 ChangePolygonClearSize
, /* just to tell the user not to :-) */
187 static ObjectFunctionType ChangeNameFunctions
= {
201 static ObjectFunctionType ChangeSquareFunctions
= {
215 static ObjectFunctionType ChangeJoinFunctions
= {
229 static ObjectFunctionType ChangeOctagonFunctions
= {
234 ChangeElementOctagon
,
243 static ObjectFunctionType ChangeMaskSizeFunctions
= {
249 ChangeElementMaskSize
,
261 static ObjectFunctionType SetSquareFunctions
= {
275 static ObjectFunctionType SetJoinFunctions
= {
289 static ObjectFunctionType SetOctagonFunctions
= {
303 static ObjectFunctionType ClrSquareFunctions
= {
317 static ObjectFunctionType ClrJoinFunctions
= {
331 static ObjectFunctionType ClrOctagonFunctions
= {
347 * \brief Changes the thermal on a via.
349 * \return TRUE if changed.
352 ChangeViaThermal (PinType
*Via
)
354 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
355 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
356 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
357 if (!Delta
) /* remove the thermals */
358 CLEAR_THERM (INDEXOFCURRENT
, Via
);
360 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Via
);
361 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
362 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
368 * \brief Changes the thermal on a pin.
370 * \return TRUE if changed.
373 ChangePinThermal (ElementType
*element
, PinType
*Pin
)
375 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, false);
376 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
377 AddObjectToFlagUndoList (PIN_TYPE
, element
, Pin
, Pin
);
378 if (!Delta
) /* remove the thermals */
379 CLEAR_THERM (INDEXOFCURRENT
, Pin
);
381 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Pin
);
382 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, true);
383 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
389 * \brief Changes the size of a via.
391 * \return TRUE if changed.
394 ChangeViaSize (PinType
*Via
)
396 Coord 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
);
425 * \brief Changes the drilling hole of a via.
427 * \return TRUE if changed.
430 ChangeVia2ndSize (PinType
*Via
)
432 Coord value
= (Absolute
) ? Absolute
: Via
->DrillingHole
+ Delta
;
434 if (TEST_FLAG (LOCKFLAG
, Via
))
436 if (value
<= MAX_PINORVIASIZE
&&
437 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Via
) ||
439 Via
->Thickness
- MIN_PINORVIACOPPER
)
440 && value
!= Via
->DrillingHole
)
442 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
444 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
445 Via
->DrillingHole
= value
;
446 if (TEST_FLAG (HOLEFLAG
, Via
))
448 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
449 Via
->Thickness
= value
;
451 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
459 * \brief Changes the clearance size of a via.
461 * \return TRUE if changed.
464 ChangeViaClearSize (PinType
*Via
)
466 Coord value
= (Absolute
) ? Absolute
: Via
->Clearance
+ Delta
;
468 if (TEST_FLAG (LOCKFLAG
, Via
))
470 value
= MIN (MAX_LINESIZE
, value
);
473 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
475 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
476 value
= PCB
->Bloat
* 2 + 2;
477 if (Via
->Clearance
== value
)
479 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
480 AddObjectToClearSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
482 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
483 Via
->Clearance
= value
;
484 SetPinBoundingBox (Via
);
485 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
486 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
494 * \brief Changes the size of a pin.
496 * \return TRUE if changed.
499 ChangePinSize (ElementType
*Element
, PinType
*Pin
)
501 Coord value
= (Absolute
) ? Absolute
: Pin
->Thickness
+ Delta
;
503 if (TEST_FLAG (LOCKFLAG
, Pin
))
505 if (!TEST_FLAG (HOLEFLAG
, Pin
) && value
<= MAX_PINORVIASIZE
&&
506 value
>= MIN_PINORVIASIZE
&&
507 value
>= Pin
->DrillingHole
+ MIN_PINORVIACOPPER
&&
508 value
!= Pin
->Thickness
)
510 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
511 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
513 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
514 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
515 Pin
->Mask
+= value
- Pin
->Thickness
;
516 Pin
->Thickness
= value
;
517 /* SetElementBB updates all associated rtrees */
518 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
519 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
527 * \brief Changes the clearance size of a pin.
529 * \return TRUE if changed.
532 ChangePinClearSize (ElementType
*Element
, PinType
*Pin
)
534 Coord value
= (Absolute
) ? Absolute
: Pin
->Clearance
+ Delta
;
536 if (TEST_FLAG (LOCKFLAG
, Pin
))
538 value
= MIN (MAX_LINESIZE
, value
);
541 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
543 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
544 value
= PCB
->Bloat
* 2 + 2;
545 if (Pin
->Clearance
== value
)
547 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
548 AddObjectToClearSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
550 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
551 Pin
->Clearance
= value
;
552 /* SetElementBB updates all associated rtrees */
553 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
554 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
560 * \brief Changes the size of a pad.
562 * \return TRUE if changed.
565 ChangePadSize (ElementType
*Element
, PadType
*Pad
)
567 Coord value
= (Absolute
) ? Absolute
: Pad
->Thickness
+ Delta
;
569 if (TEST_FLAG (LOCKFLAG
, Pad
))
571 if (value
<= MAX_PADSIZE
&& value
>= MIN_PADSIZE
&& value
!= Pad
->Thickness
)
573 AddObjectToSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
574 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
575 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
577 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
578 Pad
->Mask
+= value
- Pad
->Thickness
;
579 Pad
->Thickness
= value
;
580 /* SetElementBB updates all associated rtrees */
581 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
582 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
590 * \brief Changes the clearance size of a pad.
592 * \return TRUE if changed.
595 ChangePadClearSize (ElementType
*Element
, PadType
*Pad
)
597 Coord value
= (Absolute
) ? Absolute
: Pad
->Clearance
+ Delta
;
599 if (TEST_FLAG (LOCKFLAG
, Pad
))
601 value
= MIN (MAX_LINESIZE
, value
);
604 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
606 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
607 value
= PCB
->Bloat
* 2 + 2;
608 if (value
== Pad
->Clearance
)
610 AddObjectToClearSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
611 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
613 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
614 Pad
->Clearance
= value
;
615 /* SetElementBB updates all associated rtrees */
616 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
617 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
623 * \brief Changes the drilling hole of all pins of an element.
625 * \return TRUE if changed.
628 ChangeElement2ndSize (ElementType
*Element
)
630 bool changed
= false;
633 if (TEST_FLAG (LOCKFLAG
, Element
))
637 value
= (Absolute
) ? Absolute
: pin
->DrillingHole
+ Delta
;
638 if (value
<= MAX_PINORVIASIZE
&&
639 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, pin
) ||
643 && value
!= pin
->DrillingHole
)
646 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
648 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
649 pin
->DrillingHole
= value
;
650 if (TEST_FLAG (HOLEFLAG
, pin
))
652 AddObjectToSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
653 pin
->Thickness
= value
;
655 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
667 * \brief Changes the drilling hole of a pin.
669 * \return TRUE if changed.
672 ChangePin2ndSize (ElementType
*Element
, PinType
*Pin
)
674 Coord value
= (Absolute
) ? Absolute
: Pin
->DrillingHole
+ Delta
;
676 if (TEST_FLAG (LOCKFLAG
, Pin
))
678 if (value
<= MAX_PINORVIASIZE
&&
679 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Pin
) ||
681 Pin
->Thickness
- MIN_PINORVIACOPPER
)
682 && value
!= Pin
->DrillingHole
)
684 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
686 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
687 Pin
->DrillingHole
= value
;
688 if (TEST_FLAG (HOLEFLAG
, Pin
))
690 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
691 Pin
->Thickness
= value
;
693 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
701 * \brief Changes the size of a line.
703 * \return TRUE if changed.
706 ChangeLineSize (LayerType
*Layer
, LineType
*Line
)
708 Coord value
= (Absolute
) ? Absolute
: Line
->Thickness
+ Delta
;
710 if (TEST_FLAG (LOCKFLAG
, Line
))
712 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
713 value
!= Line
->Thickness
)
715 AddObjectToSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
717 r_delete_entry (Layer
->line_tree
, (BoxType
*) Line
);
718 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
719 Line
->Thickness
= value
;
720 SetLineBoundingBox (Line
);
721 r_insert_entry (Layer
->line_tree
, (BoxType
*) Line
, 0);
722 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
723 DrawLine (Layer
, Line
);
730 * \brief Changes the clearance size of a line.
732 * \return TRUE if changed.
735 ChangeLineClearSize (LayerType
*Layer
, LineType
*Line
)
737 Coord value
= (Absolute
) ? Absolute
: Line
->Clearance
+ Delta
;
739 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
741 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
742 if (value
!= Line
->Clearance
)
744 AddObjectToClearSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
745 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
747 r_delete_entry (Layer
->line_tree
, (BoxType
*) Line
);
748 Line
->Clearance
= value
;
749 if (Line
->Clearance
== 0)
751 CLEAR_FLAG (CLEARLINEFLAG
, Line
);
752 Line
->Clearance
= MIL_TO_COORD(10);
754 SetLineBoundingBox (Line
);
755 r_insert_entry (Layer
->line_tree
, (BoxType
*) Line
, 0);
756 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
757 DrawLine (Layer
, Line
);
764 * \brief Handle attempts to change the clearance of a polygon.
767 ChangePolygonClearSize (LayerType
*Layer
, PolygonType
*poly
)
769 static int shown_this_message
= 0;
770 if (!shown_this_message
)
772 gui
->confirm_dialog (_("To change the clearance of objects in a polygon, "
773 "change the objects, not the polygon.\n"
774 "Hint: To set a minimum clearance for a group of objects, "
775 "select them all then :MinClearGap(Selected,=10,mil)"),
777 shown_this_message
= 1;
784 * \brief Changes the size of an arc.
786 * \return TRUE if changed.
789 ChangeArcSize (LayerType
*Layer
, ArcType
*Arc
)
791 Coord value
= (Absolute
) ? Absolute
: Arc
->Thickness
+ Delta
;
793 if (TEST_FLAG (LOCKFLAG
, Arc
))
795 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
796 value
!= Arc
->Thickness
)
798 AddObjectToSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
800 r_delete_entry (Layer
->arc_tree
, (BoxType
*) Arc
);
801 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
802 Arc
->Thickness
= value
;
803 SetArcBoundingBox (Arc
);
804 r_insert_entry (Layer
->arc_tree
, (BoxType
*) Arc
, 0);
805 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
806 DrawArc (Layer
, Arc
);
813 * \brief Changes the clearance size of an arc.
815 * \return TRUE if changed.
818 ChangeArcClearSize (LayerType
*Layer
, ArcType
*Arc
)
820 Coord value
= (Absolute
) ? Absolute
: Arc
->Clearance
+ Delta
;
822 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
824 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
825 if (value
!= Arc
->Clearance
)
827 AddObjectToClearSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
829 r_delete_entry (Layer
->arc_tree
, (BoxType
*) Arc
);
830 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
831 Arc
->Clearance
= value
;
832 if (Arc
->Clearance
== 0)
834 CLEAR_FLAG (CLEARLINEFLAG
, Arc
);
835 Arc
->Clearance
= MIL_TO_COORD(10);
837 SetArcBoundingBox (Arc
);
838 r_insert_entry (Layer
->arc_tree
, (BoxType
*) Arc
, 0);
839 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
840 DrawArc (Layer
, Arc
);
847 * \brief Changes the scaling factor of a text object.
849 * \return TRUE if changed.
852 ChangeTextSize (LayerType
*Layer
, TextType
*Text
)
854 int value
= (Absolute
!= 0 ? 0 : Text
->Scale
) +
855 (double)(Absolute
!= 0 ? Absolute
: Delta
)
856 / (double)FONT_CAPHEIGHT
* 100.;
858 if (TEST_FLAG (LOCKFLAG
, Text
))
860 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
&&
861 value
!= Text
->Scale
)
863 AddObjectToSizeUndoList (TEXT_TYPE
, Layer
, Text
, Text
);
864 EraseText (Layer
, Text
);
865 r_delete_entry (Layer
->text_tree
, (BoxType
*) Text
);
866 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
868 SetTextBoundingBox (&PCB
->Font
, Text
);
869 r_insert_entry (Layer
->text_tree
, (BoxType
*) Text
, 0);
870 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
871 DrawText (Layer
, Text
);
878 * \brief Changes the scaling factor of an element's outline.
880 * \return TRUE if changed.
883 ChangeElementSize (ElementType
*Element
)
886 bool changed
= false;
888 if (TEST_FLAG (LOCKFLAG
, Element
))
891 EraseElement (Element
);
892 ELEMENTLINE_LOOP (Element
);
894 value
= (Absolute
) ? Absolute
: line
->Thickness
+ Delta
;
895 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
896 value
!= line
->Thickness
)
898 AddObjectToSizeUndoList (ELEMENTLINE_TYPE
, Element
, line
, line
);
899 line
->Thickness
= value
;
906 value
= (Absolute
) ? Absolute
: arc
->Thickness
+ Delta
;
907 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
908 value
!= arc
->Thickness
)
910 AddObjectToSizeUndoList (ELEMENTARC_TYPE
, Element
, arc
, arc
);
911 arc
->Thickness
= value
;
918 DrawElement (Element
);
926 * \brief Changes the scaling factor of a elementname object.
928 * \return TRUE if changed.
931 ChangeElementNameSize (ElementType
*Element
)
933 int value
= (Absolute
!= 0 ? 0 : DESCRIPTION_TEXT (Element
).Scale
) +
934 (double)(Absolute
!= 0 ? Absolute
: Delta
)
935 / (double)FONT_CAPHEIGHT
* 100.;
937 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
939 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
)
941 EraseElementName (Element
);
942 ELEMENTTEXT_LOOP (Element
);
944 AddObjectToSizeUndoList (ELEMENTNAME_TYPE
, Element
, text
, text
);
945 r_delete_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
);
947 SetTextBoundingBox (&PCB
->Font
, text
);
948 r_insert_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
, 0);
951 DrawElementName (Element
);
958 * \brief Changes the name of a via.
961 ChangeViaName (PinType
*Via
)
963 char *old
= Via
->Name
;
965 if (TEST_FLAG (DISPLAYNAMEFLAG
, Via
))
977 * \brief Changes the name of a pin.
980 ChangePinName (ElementType
*Element
, PinType
*Pin
)
982 char *old
= Pin
->Name
;
984 (void) Element
; /* get rid of 'unused...' warnings */
985 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pin
))
997 * \brief Changes the name of a pad.
1000 ChangePadName (ElementType
*Element
, PadType
*Pad
)
1002 char *old
= Pad
->Name
;
1004 (void) Element
; /* get rid of 'unused...' warnings */
1005 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pad
))
1008 Pad
->Name
= NewName
;
1012 Pad
->Name
= NewName
;
1017 * \brief Changes the name of a line.
1020 ChangeLineName (LayerType
*Layer
, LineType
*Line
)
1022 char *old
= Line
->Number
;
1025 Line
->Number
= NewName
;
1030 * \brief Changes the layout-name of an element.
1032 * Change the specified text on an element, either on the board (give
1033 * PCB, PCB->Data) or in a buffer (give NULL, Buffer->Data).
1035 * \return The old string is returned, and must be properly freed by the
1039 ChangeElementText (PCBType
*pcb
, DataType
*data
, ElementType
*Element
, int which
, char *new_name
)
1041 char *old
= Element
->Name
[which
].TextString
;
1044 printf("In ChangeElementText, updating old TextString %s to %s\n", old
, new_name
);
1047 if (pcb
&& which
== NAME_INDEX (pcb
))
1048 EraseElementName (Element
);
1050 r_delete_entry (data
->name_tree
[which
],
1051 & Element
->Name
[which
].BoundingBox
);
1053 Element
->Name
[which
].TextString
= new_name
;
1054 SetTextBoundingBox (&PCB
->Font
, &Element
->Name
[which
]);
1056 r_insert_entry (data
->name_tree
[which
],
1057 & Element
->Name
[which
].BoundingBox
, 0);
1059 if (pcb
&& which
== NAME_INDEX (pcb
))
1060 DrawElementName (Element
);
1066 ChangeElementName (ElementType
*Element
)
1068 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
1070 if (NAME_INDEX (PCB
) == NAMEONPCB_INDEX
)
1072 if (TEST_FLAG (UNIQUENAMEFLAG
, PCB
) &&
1073 UniqueElementName (PCB
->Data
, NewName
) != NewName
)
1075 Message (_("Error: The name \"%s\" is not unique!\n"), NewName
);
1076 return ((char *) -1);
1080 return ChangeElementText (PCB
, PCB
->Data
, Element
, NAME_INDEX (PCB
), NewName
);
1084 * \brief Sets data of a text object and calculates bounding box.
1086 * Memory must have already been allocated.
1087 * The one for the new string is allocated.
1089 * \return True if the string has been changed.
1092 ChangeTextName (LayerType
*Layer
, TextType
*Text
)
1094 char *old
= Text
->TextString
;
1096 if (TEST_FLAG (LOCKFLAG
, Text
))
1098 EraseText (Layer
, Text
);
1099 r_delete_entry (Layer
->text_tree
, (BoxType
*) Text
);
1100 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1101 Text
->TextString
= NewName
;
1103 /* calculate size of the bounding box */
1104 SetTextBoundingBox (&PCB
->Font
, Text
);
1105 r_insert_entry(Layer
->text_tree
, (BoxType
*) Text
, 0);
1106 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1107 DrawText (Layer
, Text
);
1112 * \brief Changes the name of a layout; memory has to be already
1116 ChangeLayoutName (char *Name
)
1120 hid_action ("PCBChanged");
1125 * \brief Changes the side of the board an element is on.
1127 * \return TRUE if done.
1130 ChangeElementSide (ElementType
*Element
, Coord yoff
)
1132 if (TEST_FLAG (LOCKFLAG
, Element
))
1134 EraseElement (Element
);
1135 AddObjectToMirrorUndoList (ELEMENT_TYPE
, Element
, Element
, Element
, yoff
);
1136 MirrorElementCoordinates (PCB
->Data
, Element
, yoff
);
1137 DrawElement (Element
);
1142 * \brief Changes the name of a layer; memory has to be already
1146 ChangeLayerName (LayerType
*Layer
, char *Name
)
1148 free (CURRENT
->Name
);
1149 CURRENT
->Name
= Name
;
1150 hid_action ("LayersChanged");
1155 * \brief Changes the clearance flag of a line.
1158 ChangeLineJoin (LayerType
*Layer
, LineType
*Line
)
1160 if (TEST_FLAG (LOCKFLAG
, Line
))
1163 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1165 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, false);
1166 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1168 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Line
, Line
);
1169 TOGGLE_FLAG (CLEARLINEFLAG
, Line
);
1170 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1172 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, true);
1173 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1175 DrawLine (Layer
, Line
);
1180 * \brief Sets the clearance flag of a line.
1183 SetLineJoin (LayerType
*Layer
, LineType
*Line
)
1185 if (TEST_FLAG (LOCKFLAG
, Line
) || TEST_FLAG (CLEARLINEFLAG
, Line
))
1187 return ChangeLineJoin (Layer
, Line
);
1191 * \brief Clears the clearance flag of a line.
1194 ClrLineJoin (LayerType
*Layer
, LineType
*Line
)
1196 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
1198 return ChangeLineJoin (Layer
, Line
);
1202 * \brief Changes the clearance flag of an arc.
1205 ChangeArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1207 if (TEST_FLAG (LOCKFLAG
, Arc
))
1210 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1212 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1213 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, false);
1215 AddObjectToFlagUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
1216 TOGGLE_FLAG (CLEARLINEFLAG
, Arc
);
1217 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1219 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1220 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, true);
1222 DrawArc (Layer
, Arc
);
1227 * \brief Sets the clearance flag of an arc.
1230 SetArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1232 if (TEST_FLAG (LOCKFLAG
, Arc
) || TEST_FLAG (CLEARLINEFLAG
, Arc
))
1234 return ChangeArcJoin (Layer
, Arc
);
1238 * \brief Clears the clearance flag of an arc.
1241 ClrArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1243 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
1245 return ChangeArcJoin (Layer
, Arc
);
1249 * \brief Changes the clearance flag of a text.
1252 ChangeTextJoin (LayerType
*Layer
, TextType
*Text
)
1254 if (TEST_FLAG (LOCKFLAG
, Text
))
1256 EraseText (Layer
, Text
);
1257 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1259 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, false);
1260 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1262 AddObjectToFlagUndoList (TEXT_TYPE
, Layer
, Text
, Text
);
1263 TOGGLE_FLAG (CLEARLINEFLAG
, Text
);
1264 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1266 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, true);
1267 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1269 DrawText (Layer
, Text
);
1274 * \brief Sets the clearance flag of a text.
1277 SetTextJoin (LayerType
*Layer
, TextType
*Text
)
1279 if (TEST_FLAG (LOCKFLAG
, Text
) || TEST_FLAG (CLEARLINEFLAG
, Text
))
1281 return ChangeTextJoin (Layer
, Text
);
1285 * \brief Clears the clearance flag of a text.
1288 ClrTextJoin (LayerType
*Layer
, TextType
*Text
)
1290 if (TEST_FLAG (LOCKFLAG
, Text
) || !TEST_FLAG (CLEARLINEFLAG
, Text
))
1292 return ChangeTextJoin (Layer
, Text
);
1296 * \brief Changes the square flag of all pins on an element.
1299 ChangeElementSquare (ElementType
*Element
)
1303 if (TEST_FLAG (LOCKFLAG
, Element
))
1307 ans
= ChangePinSquare (Element
, pin
);
1312 ans
= ChangePadSquare (Element
, pad
);
1319 * \brief Sets the square flag of all pins on an element.
1322 SetElementSquare (ElementType
*Element
)
1326 if (TEST_FLAG (LOCKFLAG
, Element
))
1330 ans
= SetPinSquare (Element
, pin
);
1335 ans
= SetPadSquare (Element
, pad
);
1342 * \brief Clears the square flag of all pins on an element.
1345 ClrElementSquare (ElementType
*Element
)
1349 if (TEST_FLAG (LOCKFLAG
, Element
))
1353 ans
= ClrPinSquare (Element
, pin
);
1358 ans
= ClrPadSquare (Element
, pad
);
1365 * \brief Changes the octagon flags of all pins of an element.
1368 ChangeElementOctagon (ElementType
*Element
)
1370 void *result
= NULL
;
1372 if (TEST_FLAG (LOCKFLAG
, Element
))
1376 ChangePinOctagon (Element
, pin
);
1384 * \brief Sets the octagon flags of all pins of an element.
1387 SetElementOctagon (ElementType
*Element
)
1389 void *result
= NULL
;
1391 if (TEST_FLAG (LOCKFLAG
, Element
))
1395 SetPinOctagon (Element
, pin
);
1403 * \brief Clears the octagon flags of all pins of an element.
1406 ClrElementOctagon (ElementType
*Element
)
1408 void *result
= NULL
;
1410 if (TEST_FLAG (LOCKFLAG
, Element
))
1414 ClrPinOctagon (Element
, pin
);
1422 * \brief Changes the square flag of a pad.
1425 ChangePadSquare (ElementType
*Element
, PadType
*Pad
)
1427 if (TEST_FLAG (LOCKFLAG
, Pad
))
1430 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, false);
1431 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1432 AddObjectToFlagUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
1433 TOGGLE_FLAG (SQUAREFLAG
, Pad
);
1434 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, true);
1435 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1441 * \brief Sets the square flag of a pad.
1444 SetPadSquare (ElementType
*Element
, PadType
*Pad
)
1447 if (TEST_FLAG (LOCKFLAG
, Pad
) || TEST_FLAG (SQUAREFLAG
, Pad
))
1450 return (ChangePadSquare (Element
, Pad
));
1455 * \brief Clears the square flag of a pad.
1458 ClrPadSquare (ElementType
*Element
, PadType
*Pad
)
1461 if (TEST_FLAG (LOCKFLAG
, Pad
) || !TEST_FLAG (SQUAREFLAG
, Pad
))
1464 return (ChangePadSquare (Element
, Pad
));
1469 * \brief Changes the square flag of a pin.
1472 ChangePinSquare (ElementType
*Element
, PinType
*Pin
)
1474 if (TEST_FLAG (LOCKFLAG
, Pin
))
1477 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1478 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1479 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1480 TOGGLE_FLAG (SQUAREFLAG
, Pin
);
1481 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1482 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1488 * \brief Sets the square flag of a pin.
1491 SetPinSquare (ElementType
*Element
, PinType
*Pin
)
1493 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (SQUAREFLAG
, Pin
))
1496 return (ChangePinSquare (Element
, Pin
));
1500 * \brief Clears the square flag of a pin.
1503 ClrPinSquare (ElementType
*Element
, PinType
*Pin
)
1505 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (SQUAREFLAG
, Pin
))
1508 return (ChangePinSquare (Element
, Pin
));
1512 * \brief Changes the octagon flag of a via.
1515 ChangeViaOctagon (PinType
*Via
)
1517 if (TEST_FLAG (LOCKFLAG
, Via
))
1520 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
1521 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1522 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1523 TOGGLE_FLAG (OCTAGONFLAG
, Via
);
1524 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
1525 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1531 * \brief Sets the octagon flag of a via.
1534 SetViaOctagon (PinType
*Via
)
1536 if (TEST_FLAG (LOCKFLAG
, Via
) || TEST_FLAG (OCTAGONFLAG
, Via
))
1539 return (ChangeViaOctagon (Via
));
1543 * \brief Clears the octagon flag of a via.
1546 ClrViaOctagon (PinType
*Via
)
1548 if (TEST_FLAG (LOCKFLAG
, Via
) || !TEST_FLAG (OCTAGONFLAG
, Via
))
1551 return (ChangeViaOctagon (Via
));
1555 * \brief Changes the octagon flag of a pin.
1558 ChangePinOctagon (ElementType
*Element
, PinType
*Pin
)
1560 if (TEST_FLAG (LOCKFLAG
, Pin
))
1563 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1564 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1565 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1566 TOGGLE_FLAG (OCTAGONFLAG
, Pin
);
1567 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1568 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1574 * \brief Sets the octagon flag of a pin.
1577 SetPinOctagon (ElementType
*Element
, PinType
*Pin
)
1579 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (OCTAGONFLAG
, Pin
))
1582 return (ChangePinOctagon (Element
, Pin
));
1586 * \brief Clears the octagon flag of a pin.
1589 ClrPinOctagon (ElementType
*Element
, PinType
*Pin
)
1591 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (OCTAGONFLAG
, Pin
))
1594 return (ChangePinOctagon (Element
, Pin
));
1598 * \brief Changes the hole flag of a via.
1601 ChangeHole (PinType
*Via
)
1603 if (TEST_FLAG (LOCKFLAG
, Via
))
1606 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1607 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1608 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
1609 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1610 TOGGLE_FLAG (HOLEFLAG
, Via
);
1612 if (TEST_FLAG (HOLEFLAG
, Via
))
1614 /* A tented via becomes an minimally untented hole. An untented
1615 via retains its mask clearance. */
1616 if (Via
->Mask
> Via
->Thickness
)
1618 Via
->Mask
= (Via
->DrillingHole
1619 + (Via
->Mask
- Via
->Thickness
));
1621 else if (Via
->Mask
< Via
->DrillingHole
)
1623 Via
->Mask
= Via
->DrillingHole
+ 2 * MASKFRAME
;
1628 Via
->Mask
= (Via
->Thickness
1629 + (Via
->Mask
- Via
->DrillingHole
));
1632 SetPinBoundingBox (Via
);
1633 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
1634 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1641 * \brief Changes the nopaste flag of a pad.
1644 ChangePaste (PadType
*Pad
)
1646 if (TEST_FLAG (LOCKFLAG
, Pad
))
1649 AddObjectToFlagUndoList (PAD_TYPE
, Pad
, Pad
, Pad
);
1650 TOGGLE_FLAG (NOPASTEFLAG
, Pad
);
1657 * \brief Changes the CLEARPOLY flag of a polygon.
1660 ChangePolyClear (LayerType
*Layer
, PolygonType
*Polygon
)
1662 if (TEST_FLAG (LOCKFLAG
, Polygon
))
1664 AddObjectToClearPolyUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
, true);
1665 AddObjectToFlagUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
1666 TOGGLE_FLAG (CLEARPOLYFLAG
, Polygon
);
1667 InitClip (PCB
->Data
, Layer
, Polygon
);
1668 DrawPolygon (Layer
, Polygon
);
1673 * \brief Changes the side of all selected and visible elements.
1675 * \return True if anything has changed.
1678 ChangeSelectedElementSide (void)
1680 bool change
= false;
1682 /* setup identifiers */
1683 if (PCB
->PinOn
&& PCB
->ElementOn
)
1684 ELEMENT_LOOP (PCB
->Data
);
1686 if (TEST_FLAG (SELECTEDFLAG
, element
))
1688 change
|= ChangeElementSide (element
, 0);
1695 IncrementUndoSerialNumber ();
1701 * \brief Changes the thermals on all selected and visible pins and/or
1704 * \return True if anything has changed.
1707 ChangeSelectedThermals (int types
, int therm_style
)
1709 bool change
= false;
1711 Delta
= therm_style
;
1712 change
= SelectedOperation (&ChangeThermalFunctions
, false, types
);
1716 IncrementUndoSerialNumber ();
1723 * \brief Changes the thermals on all selected and visible pins and/or
1726 * \return True if anything has changed.
1729 ChangeSelectedViaLayers (int from
, int to
)
1731 bool change
= false;
1736 VIA_LOOP (PCB
->Data
);
1738 if (TEST_FLAG (LOCKFLAG
, via
))
1740 if (TEST_FLAG (SELECTEDFLAG
, via
))
1743 new_from
= (from
!= -1)?from
:via
->BuriedFrom
;
1744 new_to
= (to
!= -1)?to
:via
->BuriedTo
;
1746 if (new_from
== new_to
)
1749 /* special case - changing TH via "from" layer sets "to" layer to bottom layer */
1750 if (!VIA_IS_BURIED (via
)
1752 new_to
= GetMaxBottomLayer ();
1754 for (i
=0; i
< max_copper_layer
; i
++)
1756 /* AddObjectToClearPolyUndoList (VIA_TYPE, &(PCB->Data->Layer[i]), via, via, false); not needed? */
1757 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, &(PCB
->Data
->Layer
[i
]), via
);
1760 AddObjectToSetViaLayersUndoList (via
, via
, via
);
1761 via
->BuriedFrom
= new_from
;
1762 via
->BuriedTo
= new_to
;
1764 if (VIA_IS_BURIED (via
))
1766 SanitizeBuriedVia (via
);
1767 for (i
=0; i
< max_copper_layer
; i
++)
1769 /* AddObjectToClearPolyUndoList (VIA_TYPE, &(PCB->Data->Layer[i]), via, via, true); not needed? */
1770 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, &(PCB
->Data
->Layer
[i
]), via
);
1781 IncrementUndoSerialNumber ();
1787 * \brief Changes the size of all selected and visible object types.
1789 * \return True if anything has changed.
1792 ChangeSelectedSize (int types
, Coord Difference
, bool fixIt
)
1794 bool change
= false;
1796 /* setup identifiers */
1797 Absolute
= (fixIt
) ? Difference
: 0;
1800 change
= SelectedOperation (&ChangeSizeFunctions
, false, types
);
1804 IncrementUndoSerialNumber ();
1810 * \brief Changes the clearance size of all selected and visible objects.
1812 * \return True if anything has changed.
1815 ChangeSelectedClearSize (int types
, Coord Difference
, bool fixIt
)
1817 bool change
= false;
1819 /* setup identifiers */
1820 Absolute
= (fixIt
) ? Difference
: 0;
1822 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1823 change
= SelectedOperation (&ChangeMaskSizeFunctions
, false, types
);
1825 change
= SelectedOperation (&ChangeClearSizeFunctions
, false, types
);
1829 IncrementUndoSerialNumber ();
1835 * \brief Changes the 2nd size (drilling hole) of all selected and
1838 * \return True if anything has changed.
1841 ChangeSelected2ndSize (int types
, Coord Difference
, bool fixIt
)
1843 bool change
= false;
1845 /* setup identifiers */
1846 Absolute
= (fixIt
) ? Difference
: 0;
1848 change
= SelectedOperation (&Change2ndSizeFunctions
, false, types
);
1852 IncrementUndoSerialNumber ();
1858 * \brief Changes the clearance flag (join) of all selected and visible
1859 * lines and/or arcs.
1861 * \return True if anything has changed.
1864 ChangeSelectedJoin (int types
)
1866 bool change
= false;
1868 change
= SelectedOperation (&ChangeJoinFunctions
, false, types
);
1872 IncrementUndoSerialNumber ();
1878 * \brief Changes the clearance flag (join) of all selected and visible
1879 * lines and/or arcs.
1881 * \return True if anything has changed.
1884 SetSelectedJoin (int types
)
1886 bool change
= false;
1888 change
= SelectedOperation (&SetJoinFunctions
, false, types
);
1892 IncrementUndoSerialNumber ();
1898 * \brief Changes the clearance flag (join) of all selected and visible
1899 * lines and/or arcs.
1901 * \return True if anything has changed.
1904 ClrSelectedJoin (int types
)
1906 bool change
= false;
1908 change
= SelectedOperation (&ClrJoinFunctions
, false, types
);
1912 IncrementUndoSerialNumber ();
1918 * \brief Changes the square-flag of all selected and visible pins or
1921 * \return True if anything has changed.
1924 ChangeSelectedSquare (int types
)
1926 bool change
= false;
1928 change
= SelectedOperation (&ChangeSquareFunctions
, false, types
);
1932 IncrementUndoSerialNumber ();
1938 * \brief Sets the square-flag of all selected and visible pins or pads.
1940 * \return True if anything has changed.
1943 SetSelectedSquare (int types
)
1945 bool change
= false;
1947 change
= SelectedOperation (&SetSquareFunctions
, false, types
);
1951 IncrementUndoSerialNumber ();
1957 * \brief Clears the square-flag of all selected and visible pins or
1960 * \return True if anything has changed.
1963 ClrSelectedSquare (int types
)
1965 bool change
= false;
1967 change
= SelectedOperation (&ClrSquareFunctions
, false, types
);
1971 IncrementUndoSerialNumber ();
1977 * \brief Changes the octagon-flag of all selected and visible pins and
1980 * \return True if anything has changed.
1983 ChangeSelectedOctagon (int types
)
1985 bool change
= false;
1987 change
= SelectedOperation (&ChangeOctagonFunctions
, false, types
);
1991 IncrementUndoSerialNumber ();
1997 * \brief Sets the octagon-flag of all selected and visible pins and
2000 * \return True if anything has changed.
2003 SetSelectedOctagon (int types
)
2005 bool change
= false;
2007 change
= SelectedOperation (&SetOctagonFunctions
, false, types
);
2011 IncrementUndoSerialNumber ();
2017 * \brief Clears the octagon-flag of all selected and visible pins and
2020 * \return True if anything has changed.
2023 ClrSelectedOctagon (int types
)
2025 bool change
= false;
2027 change
= SelectedOperation (&ClrOctagonFunctions
, false, types
);
2031 IncrementUndoSerialNumber ();
2037 * \brief Changes the hole-flag of all selected and visible vias.
2039 * \return True if anything has changed.
2042 ChangeSelectedHole (void)
2044 bool change
= false;
2047 VIA_LOOP (PCB
->Data
);
2049 if (TEST_FLAG (SELECTEDFLAG
, via
))
2050 change
|= ChangeHole (via
);
2056 IncrementUndoSerialNumber ();
2062 * \brief Changes the no paste-flag of all selected and visible pads.
2064 * \return True if anything has changed.
2067 ChangeSelectedPaste (void)
2069 bool change
= false;
2071 ALLPAD_LOOP (PCB
->Data
);
2073 if (TEST_FLAG (SELECTEDFLAG
, pad
))
2074 change
|= ChangePaste (pad
);
2080 IncrementUndoSerialNumber ();
2087 * \brief Changes the size of the passed object.
2089 * \return True if anything is changed.
2092 ChangeObjectSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2093 Coord Difference
, bool fixIt
)
2097 /* setup identifier */
2098 Absolute
= (fixIt
) ? Difference
: 0;
2101 (ObjectOperation (&ChangeSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
);
2105 IncrementUndoSerialNumber ();
2111 * \brief Changes the clearance size of the passed object.
2113 * \return True if anything is changed.
2116 ChangeObjectClearSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2117 Coord Difference
, bool fixIt
)
2121 /* setup identifier */
2122 Absolute
= (fixIt
) ? Difference
: 0;
2124 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
2126 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2130 (ObjectOperation (&ChangeClearSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2135 IncrementUndoSerialNumber ();
2141 * \brief Changes the thermal of the passed object.
2143 * \return True if anything is changed.
2147 ChangeObjectThermal (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2152 Delta
= Absolute
= therm_type
;
2154 (ObjectOperation (&ChangeThermalFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2159 IncrementUndoSerialNumber ();
2165 * \brief Changes the thermal of the passed object.
2167 * \return True if anything is changed.
2171 ChangeObjectViaLayers (void *Ptr1
, void *Ptr2
, void *Ptr3
,
2174 bool change
= false;
2175 PinType
*via
= (PinType
*) Ptr1
;
2176 int new_from
= (from
!= -1)?from
:via
->BuriedFrom
;
2177 int new_to
= (to
!= -1)?to
:via
->BuriedTo
;
2180 if (TEST_FLAG (LOCKFLAG
, via
))
2183 if ((new_from
== new_to
)
2187 /* special case - changing TH via "from" layer sets "to" layer to bottom layer */
2188 if (!VIA_IS_BURIED (via
)
2190 new_to
= GetMaxBottomLayer ();
2192 for (i
=0; i
< max_copper_layer
; i
++)
2194 /* AddObjectToClearPolyUndoList (VIA_TYPE, &(PCB->Data->Layer[i]), via, via, false); not needed? */
2195 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, &(PCB
->Data
->Layer
[i
]), via
);
2198 if (from
!= -1 || to
!= -1)
2200 AddObjectToSetViaLayersUndoList (via
, via
, via
);
2204 via
->BuriedFrom
= new_from
;
2205 via
->BuriedTo
= new_to
;
2207 if (VIA_IS_BURIED (via
))
2209 SanitizeBuriedVia (via
);
2210 for (i
=0; i
< max_copper_layer
; i
++)
2212 /* AddObjectToClearPolyUndoList (VIA_TYPE, &(PCB->Data->Layer[i]), via, via, true); not needed? */
2213 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, &(PCB
->Data
->Layer
[i
]), via
);
2221 IncrementUndoSerialNumber ();
2227 * \brief Changes the 2nd size of the passed object.
2229 * \return True if anything is changed.
2232 ChangeObject2ndSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2233 Coord Difference
, bool fixIt
, bool incundo
)
2237 /* setup identifier */
2238 Absolute
= (fixIt
) ? Difference
: 0;
2241 (ObjectOperation (&Change2ndSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2247 IncrementUndoSerialNumber ();
2253 * \brief Changes the mask size of the passed object.
2255 * \return True if anything is changed.
2258 ChangeObjectMaskSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2259 Coord Difference
, bool fixIt
)
2263 /* setup identifier */
2264 Absolute
= (fixIt
) ? Difference
: 0;
2267 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2272 IncrementUndoSerialNumber ();
2278 * \brief Changes the name of the passed object.
2280 * \warning The allocated memory isn't freed because the old string is used
2281 * by the undo module.
2283 * \return The old name.
2286 ChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
, char *Name
)
2289 /* setup identifier */
2291 result
= ObjectOperation (&ChangeNameFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
);
2297 * \brief Changes the clearance-flag of the passed object.
2299 * \return True if anything is changed.
2302 ChangeObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2304 if (ObjectOperation (&ChangeJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2307 IncrementUndoSerialNumber ();
2314 * \brief Sets the clearance-flag of the passed object.
2316 * \return True if anything is changed.
2319 SetObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2321 if (ObjectOperation (&SetJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2324 IncrementUndoSerialNumber ();
2331 * \brief Clears the clearance-flag of the passed object.
2333 * \return True if anything is changed.
2336 ClrObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2338 if (ObjectOperation (&ClrJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2341 IncrementUndoSerialNumber ();
2348 * \brief Changes the square-flag of the passed object.
2350 * \return True if anything is changed.
2353 ChangeObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2355 if (ObjectOperation (&ChangeSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2359 IncrementUndoSerialNumber ();
2366 * \brief Sets the square-flag of the passed object.
2368 * \return True if anything is changed.
2371 SetObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2373 if (ObjectOperation (&SetSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2376 IncrementUndoSerialNumber ();
2383 * \brief Clears the square-flag of the passed object.
2385 * \return True if anything is changed.
2388 ClrObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2390 if (ObjectOperation (&ClrSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2393 IncrementUndoSerialNumber ();
2400 * \brief Changes the octagon-flag of the passed object.
2402 * \return True if anything is changed.
2405 ChangeObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2407 if (ObjectOperation (&ChangeOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2411 IncrementUndoSerialNumber ();
2418 * \brief Sets the octagon-flag of the passed object.
2420 * \return True if anything is changed.
2423 SetObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2425 if (ObjectOperation (&SetOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2428 IncrementUndoSerialNumber ();
2435 * \brief Clears the octagon-flag of the passed object.
2437 * \return True if anything is changed.
2440 ClrObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2442 if (ObjectOperation (&ClrOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2445 IncrementUndoSerialNumber ();
2452 * \bief Queries the user for a new object name and changes it.
2454 * \warning The allocated memory isn't freed because the old string is used
2455 * by the undo module.
2458 QueryInputAndChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2463 /* if passed an element name, make it an element reference instead */
2464 if (Type
== ELEMENTNAME_TYPE
)
2466 Type
= ELEMENT_TYPE
;
2473 name
= gui
->prompt_for (_("Linename:"),
2474 EMPTY (((LineType
*) Ptr2
)->Number
));
2478 name
= gui
->prompt_for (_("Vianame:"),
2479 EMPTY (((PinType
*) Ptr2
)->Name
));
2483 sprintf (msg
, _("%s Pin Name:"), EMPTY (((PinType
*) Ptr2
)->Number
));
2484 name
= gui
->prompt_for (msg
, EMPTY (((PinType
*) Ptr2
)->Name
));
2488 sprintf (msg
, _("%s Pad Name:"), EMPTY (((PadType
*) Ptr2
)->Number
));
2489 name
= gui
->prompt_for (msg
, EMPTY (((PadType
*) Ptr2
)->Name
));
2493 name
= gui
->prompt_for (_("Enter text:"),
2494 EMPTY (((TextType
*) Ptr2
)->TextString
));
2498 name
= gui
->prompt_for (_("Elementname:"),
2500 (PCB
, (ElementType
*) Ptr2
)));
2505 /* NB: ChangeObjectName takes ownership of the passed memory */
2506 char *old
= (char *)ChangeObjectName (Type
, Ptr1
, Ptr2
, Ptr3
, name
);
2507 if (old
!= (char *) -1)
2509 AddObjectToChangeNameUndoList (Type
, Ptr1
, Ptr2
, Ptr3
, old
);
2510 IncrementUndoSerialNumber ();
2519 * \brief Changes the maximum size of a layout, adjusts the scrollbars,
2520 * releases the saved pixmap if necessary and adjusts the cursor
2524 ChangePCBSize (Coord Width
, Coord Height
)
2526 PCB
->MaxWidth
= Width
;
2527 PCB
->MaxHeight
= Height
;
2529 /* crosshair range is different if pastebuffer-mode
2532 if (Settings
.Mode
== PASTEBUFFER_MODE
)
2533 SetCrosshairRange (PASTEBUFFER
->X
- PASTEBUFFER
->BoundingBox
.X1
,
2534 PASTEBUFFER
->Y
- PASTEBUFFER
->BoundingBox
.Y1
,
2536 Width
- (PASTEBUFFER
->BoundingBox
.X2
-
2537 PASTEBUFFER
->X
)), MAX (0,
2544 SetCrosshairRange (0, 0, Width
, Height
);
2545 hid_action ("PCBChanged");
2549 * \brief Changes the mask size of a pad.
2551 * \return TRUE if changed.
2554 ChangePadMaskSize (ElementType
*Element
, PadType
*Pad
)
2556 Coord value
= (Absolute
) ? Absolute
: Pad
->Mask
+ Delta
;
2558 value
= MAX (value
, 0);
2559 if (value
== Pad
->Mask
&& Absolute
== 0)
2560 value
= Pad
->Thickness
;
2561 if (value
!= Pad
->Mask
)
2563 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
2565 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
2567 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2575 * \brief Changes the mask size of a pin.
2577 * \return TRUE if changed.
2580 ChangePinMaskSize (ElementType
*Element
, PinType
*Pin
)
2582 Coord value
= (Absolute
) ? Absolute
: Pin
->Mask
+ Delta
;
2584 value
= MAX (value
, 0);
2585 if (value
== Pin
->Mask
&& Absolute
== 0)
2586 value
= Pin
->Thickness
;
2587 if (value
!= Pin
->Mask
)
2589 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
2591 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
2593 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2601 * \brief Changes the mask size of a via.
2603 * \return TRUE if changed.
2606 ChangeViaMaskSize (PinType
*Via
)
2610 value
= (Absolute
) ? Absolute
: Via
->Mask
+ Delta
;
2611 value
= MAX (value
, 0);
2612 if (value
!= Via
->Mask
)
2614 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
2616 r_delete_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
);
2618 SetPinBoundingBox (Via
);
2619 r_insert_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
, 0);