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 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1100 Text
->TextString
= NewName
;
1102 /* calculate size of the bounding box */
1103 SetTextBoundingBox (&PCB
->Font
, Text
);
1104 r_insert_entry(Layer
->text_tree
, (BoxType
*) Text
, 0);
1105 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1106 DrawText (Layer
, Text
);
1111 * \brief Changes the name of a layout; memory has to be already
1115 ChangeLayoutName (char *Name
)
1119 hid_action ("PCBChanged");
1124 * \brief Changes the side of the board an element is on.
1126 * \return TRUE if done.
1129 ChangeElementSide (ElementType
*Element
, Coord yoff
)
1131 if (TEST_FLAG (LOCKFLAG
, Element
))
1133 EraseElement (Element
);
1134 AddObjectToMirrorUndoList (ELEMENT_TYPE
, Element
, Element
, Element
, yoff
);
1135 MirrorElementCoordinates (PCB
->Data
, Element
, yoff
);
1136 DrawElement (Element
);
1141 * \brief Changes the name of a layer; memory has to be already
1145 ChangeLayerName (LayerType
*Layer
, char *Name
)
1147 free (CURRENT
->Name
);
1148 CURRENT
->Name
= Name
;
1149 hid_action ("LayersChanged");
1154 * \brief Changes the clearance flag of a line.
1157 ChangeLineJoin (LayerType
*Layer
, LineType
*Line
)
1159 if (TEST_FLAG (LOCKFLAG
, Line
))
1162 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1164 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, false);
1165 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1167 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Line
, Line
);
1168 TOGGLE_FLAG (CLEARLINEFLAG
, Line
);
1169 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1171 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, true);
1172 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1174 DrawLine (Layer
, Line
);
1179 * \brief Sets the clearance flag of a line.
1182 SetLineJoin (LayerType
*Layer
, LineType
*Line
)
1184 if (TEST_FLAG (LOCKFLAG
, Line
) || TEST_FLAG (CLEARLINEFLAG
, Line
))
1186 return ChangeLineJoin (Layer
, Line
);
1190 * \brief Clears the clearance flag of a line.
1193 ClrLineJoin (LayerType
*Layer
, LineType
*Line
)
1195 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
1197 return ChangeLineJoin (Layer
, Line
);
1201 * \brief Changes the clearance flag of an arc.
1204 ChangeArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1206 if (TEST_FLAG (LOCKFLAG
, Arc
))
1209 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1211 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1212 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, false);
1214 AddObjectToFlagUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
1215 TOGGLE_FLAG (CLEARLINEFLAG
, Arc
);
1216 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1218 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1219 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, true);
1221 DrawArc (Layer
, Arc
);
1226 * \brief Sets the clearance flag of an arc.
1229 SetArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1231 if (TEST_FLAG (LOCKFLAG
, Arc
) || TEST_FLAG (CLEARLINEFLAG
, Arc
))
1233 return ChangeArcJoin (Layer
, Arc
);
1237 * \brief Clears the clearance flag of an arc.
1240 ClrArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1242 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
1244 return ChangeArcJoin (Layer
, Arc
);
1248 * \brief Changes the clearance flag of a text.
1251 ChangeTextJoin (LayerType
*Layer
, TextType
*Text
)
1253 if (TEST_FLAG (LOCKFLAG
, Text
))
1255 EraseText (Layer
, Text
);
1256 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1258 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, false);
1259 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1261 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Text
, Text
);
1262 TOGGLE_FLAG (CLEARLINEFLAG
, Text
);
1263 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1265 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, true);
1266 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1268 DrawText (Layer
, Text
);
1273 * \brief Sets the clearance flag of a text.
1276 SetTextJoin (LayerType
*Layer
, TextType
*Text
)
1278 if (TEST_FLAG (LOCKFLAG
, Text
) || TEST_FLAG (CLEARLINEFLAG
, Text
))
1280 return ChangeTextJoin (Layer
, Text
);
1284 * \brief Clears the clearance flag of a text.
1287 ClrTextJoin (LayerType
*Layer
, TextType
*Text
)
1289 if (TEST_FLAG (LOCKFLAG
, Text
) || !TEST_FLAG (CLEARLINEFLAG
, Text
))
1291 return ChangeTextJoin (Layer
, Text
);
1295 * \brief Changes the square flag of all pins on an element.
1298 ChangeElementSquare (ElementType
*Element
)
1302 if (TEST_FLAG (LOCKFLAG
, Element
))
1306 ans
= ChangePinSquare (Element
, pin
);
1311 ans
= ChangePadSquare (Element
, pad
);
1318 * \brief Sets the square flag of all pins on an element.
1321 SetElementSquare (ElementType
*Element
)
1325 if (TEST_FLAG (LOCKFLAG
, Element
))
1329 ans
= SetPinSquare (Element
, pin
);
1334 ans
= SetPadSquare (Element
, pad
);
1341 * \brief Clears the square flag of all pins on an element.
1344 ClrElementSquare (ElementType
*Element
)
1348 if (TEST_FLAG (LOCKFLAG
, Element
))
1352 ans
= ClrPinSquare (Element
, pin
);
1357 ans
= ClrPadSquare (Element
, pad
);
1364 * \brief Changes the octagon flags of all pins of an element.
1367 ChangeElementOctagon (ElementType
*Element
)
1369 void *result
= NULL
;
1371 if (TEST_FLAG (LOCKFLAG
, Element
))
1375 ChangePinOctagon (Element
, pin
);
1383 * \brief Sets the octagon flags of all pins of an element.
1386 SetElementOctagon (ElementType
*Element
)
1388 void *result
= NULL
;
1390 if (TEST_FLAG (LOCKFLAG
, Element
))
1394 SetPinOctagon (Element
, pin
);
1402 * \brief Clears the octagon flags of all pins of an element.
1405 ClrElementOctagon (ElementType
*Element
)
1407 void *result
= NULL
;
1409 if (TEST_FLAG (LOCKFLAG
, Element
))
1413 ClrPinOctagon (Element
, pin
);
1421 * \brief Changes the square flag of a pad.
1424 ChangePadSquare (ElementType
*Element
, PadType
*Pad
)
1426 if (TEST_FLAG (LOCKFLAG
, Pad
))
1429 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, false);
1430 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1431 AddObjectToFlagUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
1432 TOGGLE_FLAG (SQUAREFLAG
, Pad
);
1433 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, true);
1434 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1440 * \brief Sets the square flag of a pad.
1443 SetPadSquare (ElementType
*Element
, PadType
*Pad
)
1446 if (TEST_FLAG (LOCKFLAG
, Pad
) || TEST_FLAG (SQUAREFLAG
, Pad
))
1449 return (ChangePadSquare (Element
, Pad
));
1454 * \brief Clears the square flag of a pad.
1457 ClrPadSquare (ElementType
*Element
, PadType
*Pad
)
1460 if (TEST_FLAG (LOCKFLAG
, Pad
) || !TEST_FLAG (SQUAREFLAG
, Pad
))
1463 return (ChangePadSquare (Element
, Pad
));
1468 * \brief Changes the square flag of a pin.
1471 ChangePinSquare (ElementType
*Element
, PinType
*Pin
)
1473 if (TEST_FLAG (LOCKFLAG
, Pin
))
1476 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1477 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1478 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1479 TOGGLE_FLAG (SQUAREFLAG
, Pin
);
1480 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1481 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1487 * \brief Sets the square flag of a pin.
1490 SetPinSquare (ElementType
*Element
, PinType
*Pin
)
1492 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (SQUAREFLAG
, Pin
))
1495 return (ChangePinSquare (Element
, Pin
));
1499 * \brief Clears the square flag of a pin.
1502 ClrPinSquare (ElementType
*Element
, PinType
*Pin
)
1504 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (SQUAREFLAG
, Pin
))
1507 return (ChangePinSquare (Element
, Pin
));
1511 * \brief Changes the octagon flag of a via.
1514 ChangeViaOctagon (PinType
*Via
)
1516 if (TEST_FLAG (LOCKFLAG
, Via
))
1519 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
1520 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1521 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1522 TOGGLE_FLAG (OCTAGONFLAG
, Via
);
1523 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
1524 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1530 * \brief Sets the octagon flag of a via.
1533 SetViaOctagon (PinType
*Via
)
1535 if (TEST_FLAG (LOCKFLAG
, Via
) || TEST_FLAG (OCTAGONFLAG
, Via
))
1538 return (ChangeViaOctagon (Via
));
1542 * \brief Clears the octagon flag of a via.
1545 ClrViaOctagon (PinType
*Via
)
1547 if (TEST_FLAG (LOCKFLAG
, Via
) || !TEST_FLAG (OCTAGONFLAG
, Via
))
1550 return (ChangeViaOctagon (Via
));
1554 * \brief Changes the octagon flag of a pin.
1557 ChangePinOctagon (ElementType
*Element
, PinType
*Pin
)
1559 if (TEST_FLAG (LOCKFLAG
, Pin
))
1562 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1563 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1564 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1565 TOGGLE_FLAG (OCTAGONFLAG
, Pin
);
1566 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1567 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1573 * \brief Sets the octagon flag of a pin.
1576 SetPinOctagon (ElementType
*Element
, PinType
*Pin
)
1578 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (OCTAGONFLAG
, Pin
))
1581 return (ChangePinOctagon (Element
, Pin
));
1585 * \brief Clears the octagon flag of a pin.
1588 ClrPinOctagon (ElementType
*Element
, PinType
*Pin
)
1590 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (OCTAGONFLAG
, Pin
))
1593 return (ChangePinOctagon (Element
, Pin
));
1597 * \brief Changes the hole flag of a via.
1600 ChangeHole (PinType
*Via
)
1602 if (TEST_FLAG (LOCKFLAG
, Via
))
1605 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1606 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1607 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
1608 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1609 TOGGLE_FLAG (HOLEFLAG
, Via
);
1611 if (TEST_FLAG (HOLEFLAG
, Via
))
1613 /* A tented via becomes an minimally untented hole. An untented
1614 via retains its mask clearance. */
1615 if (Via
->Mask
> Via
->Thickness
)
1617 Via
->Mask
= (Via
->DrillingHole
1618 + (Via
->Mask
- Via
->Thickness
));
1620 else if (Via
->Mask
< Via
->DrillingHole
)
1622 Via
->Mask
= Via
->DrillingHole
+ 2 * MASKFRAME
;
1627 Via
->Mask
= (Via
->Thickness
1628 + (Via
->Mask
- Via
->DrillingHole
));
1631 SetPinBoundingBox (Via
);
1632 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
1633 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1640 * \brief Changes the nopaste flag of a pad.
1643 ChangePaste (PadType
*Pad
)
1645 if (TEST_FLAG (LOCKFLAG
, Pad
))
1648 AddObjectToFlagUndoList (PAD_TYPE
, Pad
, Pad
, Pad
);
1649 TOGGLE_FLAG (NOPASTEFLAG
, Pad
);
1656 * \brief Changes the CLEARPOLY flag of a polygon.
1659 ChangePolyClear (LayerType
*Layer
, PolygonType
*Polygon
)
1661 if (TEST_FLAG (LOCKFLAG
, Polygon
))
1663 AddObjectToClearPolyUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
, true);
1664 AddObjectToFlagUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
1665 TOGGLE_FLAG (CLEARPOLYFLAG
, Polygon
);
1666 InitClip (PCB
->Data
, Layer
, Polygon
);
1667 DrawPolygon (Layer
, Polygon
);
1672 * \brief Changes the side of all selected and visible elements.
1674 * \return True if anything has changed.
1677 ChangeSelectedElementSide (void)
1679 bool change
= false;
1681 /* setup identifiers */
1682 if (PCB
->PinOn
&& PCB
->ElementOn
)
1683 ELEMENT_LOOP (PCB
->Data
);
1685 if (TEST_FLAG (SELECTEDFLAG
, element
))
1687 change
|= ChangeElementSide (element
, 0);
1694 IncrementUndoSerialNumber ();
1700 * \brief Changes the thermals on all selected and visible pins and/or
1703 * \return True if anything has changed.
1706 ChangeSelectedThermals (int types
, int therm_style
)
1708 bool change
= false;
1710 Delta
= therm_style
;
1711 change
= SelectedOperation (&ChangeThermalFunctions
, false, types
);
1715 IncrementUndoSerialNumber ();
1721 * \brief Changes the size of all selected and visible object types.
1723 * \return True if anything has changed.
1726 ChangeSelectedSize (int types
, Coord Difference
, bool fixIt
)
1728 bool change
= false;
1730 /* setup identifiers */
1731 Absolute
= (fixIt
) ? Difference
: 0;
1734 change
= SelectedOperation (&ChangeSizeFunctions
, false, types
);
1738 IncrementUndoSerialNumber ();
1744 * \brief Changes the clearance size of all selected and visible objects.
1746 * \return True if anything has changed.
1749 ChangeSelectedClearSize (int types
, Coord Difference
, bool fixIt
)
1751 bool change
= false;
1753 /* setup identifiers */
1754 Absolute
= (fixIt
) ? Difference
: 0;
1756 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1757 change
= SelectedOperation (&ChangeMaskSizeFunctions
, false, types
);
1759 change
= SelectedOperation (&ChangeClearSizeFunctions
, false, types
);
1763 IncrementUndoSerialNumber ();
1769 * \brief Changes the 2nd size (drilling hole) of all selected and
1772 * \return True if anything has changed.
1775 ChangeSelected2ndSize (int types
, Coord Difference
, bool fixIt
)
1777 bool change
= false;
1779 /* setup identifiers */
1780 Absolute
= (fixIt
) ? Difference
: 0;
1782 change
= SelectedOperation (&Change2ndSizeFunctions
, false, types
);
1786 IncrementUndoSerialNumber ();
1792 * \brief Changes the clearance flag (join) of all selected and visible
1793 * lines and/or arcs.
1795 * \return True if anything has changed.
1798 ChangeSelectedJoin (int types
)
1800 bool change
= false;
1802 change
= SelectedOperation (&ChangeJoinFunctions
, false, types
);
1806 IncrementUndoSerialNumber ();
1812 * \brief Changes the clearance flag (join) of all selected and visible
1813 * lines and/or arcs.
1815 * \return True if anything has changed.
1818 SetSelectedJoin (int types
)
1820 bool change
= false;
1822 change
= SelectedOperation (&SetJoinFunctions
, false, types
);
1826 IncrementUndoSerialNumber ();
1832 * \brief Changes the clearance flag (join) of all selected and visible
1833 * lines and/or arcs.
1835 * \return True if anything has changed.
1838 ClrSelectedJoin (int types
)
1840 bool change
= false;
1842 change
= SelectedOperation (&ClrJoinFunctions
, false, types
);
1846 IncrementUndoSerialNumber ();
1852 * \brief Changes the square-flag of all selected and visible pins or
1855 * \return True if anything has changed.
1858 ChangeSelectedSquare (int types
)
1860 bool change
= false;
1862 change
= SelectedOperation (&ChangeSquareFunctions
, false, types
);
1866 IncrementUndoSerialNumber ();
1872 * \brief Sets the square-flag of all selected and visible pins or pads.
1874 * \return True if anything has changed.
1877 SetSelectedSquare (int types
)
1879 bool change
= false;
1881 change
= SelectedOperation (&SetSquareFunctions
, false, types
);
1885 IncrementUndoSerialNumber ();
1891 * \brief Clears the square-flag of all selected and visible pins or
1894 * \return True if anything has changed.
1897 ClrSelectedSquare (int types
)
1899 bool change
= false;
1901 change
= SelectedOperation (&ClrSquareFunctions
, false, types
);
1905 IncrementUndoSerialNumber ();
1911 * \brief Changes the octagon-flag of all selected and visible pins and
1914 * \return True if anything has changed.
1917 ChangeSelectedOctagon (int types
)
1919 bool change
= false;
1921 change
= SelectedOperation (&ChangeOctagonFunctions
, false, types
);
1925 IncrementUndoSerialNumber ();
1931 * \brief Sets the octagon-flag of all selected and visible pins and
1934 * \return True if anything has changed.
1937 SetSelectedOctagon (int types
)
1939 bool change
= false;
1941 change
= SelectedOperation (&SetOctagonFunctions
, false, types
);
1945 IncrementUndoSerialNumber ();
1951 * \brief Clears the octagon-flag of all selected and visible pins and
1954 * \return True if anything has changed.
1957 ClrSelectedOctagon (int types
)
1959 bool change
= false;
1961 change
= SelectedOperation (&ClrOctagonFunctions
, false, types
);
1965 IncrementUndoSerialNumber ();
1971 * \brief Changes the hole-flag of all selected and visible vias.
1973 * \return True if anything has changed.
1976 ChangeSelectedHole (void)
1978 bool change
= false;
1981 VIA_LOOP (PCB
->Data
);
1983 if (TEST_FLAG (SELECTEDFLAG
, via
))
1984 change
|= ChangeHole (via
);
1990 IncrementUndoSerialNumber ();
1996 * \brief Changes the no paste-flag of all selected and visible pads.
1998 * \return True if anything has changed.
2001 ChangeSelectedPaste (void)
2003 bool change
= false;
2005 ALLPAD_LOOP (PCB
->Data
);
2007 if (TEST_FLAG (SELECTEDFLAG
, pad
))
2008 change
|= ChangePaste (pad
);
2014 IncrementUndoSerialNumber ();
2021 * \brief Changes the size of the passed object.
2023 * \return True if anything is changed.
2026 ChangeObjectSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2027 Coord Difference
, bool fixIt
)
2031 /* setup identifier */
2032 Absolute
= (fixIt
) ? Difference
: 0;
2035 (ObjectOperation (&ChangeSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
);
2039 IncrementUndoSerialNumber ();
2045 * \brief Changes the clearance size of the passed object.
2047 * \return True if anything is changed.
2050 ChangeObjectClearSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2051 Coord Difference
, bool fixIt
)
2055 /* setup identifier */
2056 Absolute
= (fixIt
) ? Difference
: 0;
2058 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
2060 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2064 (ObjectOperation (&ChangeClearSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2069 IncrementUndoSerialNumber ();
2075 * \brief Changes the thermal of the passed object.
2077 * \return True if anything is changed.
2081 ChangeObjectThermal (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2086 Delta
= Absolute
= therm_type
;
2088 (ObjectOperation (&ChangeThermalFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2093 IncrementUndoSerialNumber ();
2099 * \brief Changes the 2nd size of the passed object.
2101 * \return True if anything is changed.
2104 ChangeObject2ndSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2105 Coord Difference
, bool fixIt
, bool incundo
)
2109 /* setup identifier */
2110 Absolute
= (fixIt
) ? Difference
: 0;
2113 (ObjectOperation (&Change2ndSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2119 IncrementUndoSerialNumber ();
2125 * \brief Changes the mask size of the passed object.
2127 * \return True if anything is changed.
2130 ChangeObjectMaskSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2131 Coord Difference
, bool fixIt
)
2135 /* setup identifier */
2136 Absolute
= (fixIt
) ? Difference
: 0;
2139 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2144 IncrementUndoSerialNumber ();
2150 * \brief Changes the name of the passed object.
2152 * \warning The allocated memory isn't freed because the old string is used
2153 * by the undo module.
2155 * \return The old name.
2158 ChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
, char *Name
)
2161 /* setup identifier */
2163 result
= ObjectOperation (&ChangeNameFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
);
2169 * \brief Changes the clearance-flag of the passed object.
2171 * \return True if anything is changed.
2174 ChangeObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2176 if (ObjectOperation (&ChangeJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2179 IncrementUndoSerialNumber ();
2186 * \brief Sets the clearance-flag of the passed object.
2188 * \return True if anything is changed.
2191 SetObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2193 if (ObjectOperation (&SetJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2196 IncrementUndoSerialNumber ();
2203 * \brief Clears the clearance-flag of the passed object.
2205 * \return True if anything is changed.
2208 ClrObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2210 if (ObjectOperation (&ClrJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2213 IncrementUndoSerialNumber ();
2220 * \brief Changes the square-flag of the passed object.
2222 * \return True if anything is changed.
2225 ChangeObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2227 if (ObjectOperation (&ChangeSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2231 IncrementUndoSerialNumber ();
2238 * \brief Sets the square-flag of the passed object.
2240 * \return True if anything is changed.
2243 SetObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2245 if (ObjectOperation (&SetSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2248 IncrementUndoSerialNumber ();
2255 * \brief Clears the square-flag of the passed object.
2257 * \return True if anything is changed.
2260 ClrObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2262 if (ObjectOperation (&ClrSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2265 IncrementUndoSerialNumber ();
2272 * \brief Changes the octagon-flag of the passed object.
2274 * \return True if anything is changed.
2277 ChangeObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2279 if (ObjectOperation (&ChangeOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2283 IncrementUndoSerialNumber ();
2290 * \brief Sets the octagon-flag of the passed object.
2292 * \return True if anything is changed.
2295 SetObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2297 if (ObjectOperation (&SetOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2300 IncrementUndoSerialNumber ();
2307 * \brief Clears the octagon-flag of the passed object.
2309 * \return True if anything is changed.
2312 ClrObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2314 if (ObjectOperation (&ClrOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2317 IncrementUndoSerialNumber ();
2324 * \bief Queries the user for a new object name and changes it.
2326 * \warning The allocated memory isn't freed because the old string is used
2327 * by the undo module.
2330 QueryInputAndChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2335 /* if passed an element name, make it an element reference instead */
2336 if (Type
== ELEMENTNAME_TYPE
)
2338 Type
= ELEMENT_TYPE
;
2345 name
= gui
->prompt_for (_("Linename:"),
2346 EMPTY (((LineType
*) Ptr2
)->Number
));
2350 name
= gui
->prompt_for (_("Vianame:"),
2351 EMPTY (((PinType
*) Ptr2
)->Name
));
2355 sprintf (msg
, _("%s Pin Name:"), EMPTY (((PinType
*) Ptr2
)->Number
));
2356 name
= gui
->prompt_for (msg
, EMPTY (((PinType
*) Ptr2
)->Name
));
2360 sprintf (msg
, _("%s Pad Name:"), EMPTY (((PadType
*) Ptr2
)->Number
));
2361 name
= gui
->prompt_for (msg
, EMPTY (((PadType
*) Ptr2
)->Name
));
2365 name
= gui
->prompt_for (_("Enter text:"),
2366 EMPTY (((TextType
*) Ptr2
)->TextString
));
2370 name
= gui
->prompt_for (_("Elementname:"),
2372 (PCB
, (ElementType
*) Ptr2
)));
2377 /* NB: ChangeObjectName takes ownership of the passed memory */
2378 char *old
= (char *)ChangeObjectName (Type
, Ptr1
, Ptr2
, Ptr3
, name
);
2379 if (old
!= (char *) -1)
2381 AddObjectToChangeNameUndoList (Type
, Ptr1
, Ptr2
, Ptr3
, old
);
2382 IncrementUndoSerialNumber ();
2391 * \brief Changes the maximum size of a layout, adjusts the scrollbars,
2392 * releases the saved pixmap if necessary and adjusts the cursor
2396 ChangePCBSize (Coord Width
, Coord Height
)
2398 PCB
->MaxWidth
= Width
;
2399 PCB
->MaxHeight
= Height
;
2401 /* crosshair range is different if pastebuffer-mode
2404 if (Settings
.Mode
== PASTEBUFFER_MODE
)
2405 SetCrosshairRange (PASTEBUFFER
->X
- PASTEBUFFER
->BoundingBox
.X1
,
2406 PASTEBUFFER
->Y
- PASTEBUFFER
->BoundingBox
.Y1
,
2408 Width
- (PASTEBUFFER
->BoundingBox
.X2
-
2409 PASTEBUFFER
->X
)), MAX (0,
2416 SetCrosshairRange (0, 0, Width
, Height
);
2417 hid_action ("PCBChanged");
2421 * \brief Changes the mask size of a pad.
2423 * \return TRUE if changed.
2426 ChangePadMaskSize (ElementType
*Element
, PadType
*Pad
)
2428 Coord value
= (Absolute
) ? Absolute
: Pad
->Mask
+ Delta
;
2430 value
= MAX (value
, 0);
2431 if (value
== Pad
->Mask
&& Absolute
== 0)
2432 value
= Pad
->Thickness
;
2433 if (value
!= Pad
->Mask
)
2435 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
2437 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
2439 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2447 * \brief Changes the mask size of a pin.
2449 * \return TRUE if changed.
2452 ChangePinMaskSize (ElementType
*Element
, PinType
*Pin
)
2454 Coord value
= (Absolute
) ? Absolute
: Pin
->Mask
+ Delta
;
2456 value
= MAX (value
, 0);
2457 if (value
== Pin
->Mask
&& Absolute
== 0)
2458 value
= Pin
->Thickness
;
2459 if (value
!= Pin
->Mask
)
2461 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
2463 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
2465 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2473 * \brief Changes the mask size of a via.
2475 * \return TRUE if changed.
2478 ChangeViaMaskSize (PinType
*Via
)
2482 value
= (Absolute
) ? Absolute
: Via
->Mask
+ Delta
;
2483 value
= MAX (value
, 0);
2484 if (value
!= Via
->Mask
)
2486 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
2488 r_delete_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
);
2490 SetPinBoundingBox (Via
);
2491 r_insert_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
, 0);