4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996, 2005 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
27 /* functions used to change object properties
42 #include "crosshair.h"
59 #ifdef HAVE_LIBDMALLOC
63 /* ---------------------------------------------------------------------------
64 * some local prototypes
66 static void *ChangePinSize (ElementType
*, PinType
*);
67 static void *ChangePinClearSize (ElementType
*, PinType
*);
68 static void *ChangePinMaskSize (ElementType
*, PinType
*);
69 static void *ChangePadSize (ElementType
*, PadType
*);
70 static void *ChangePadClearSize (ElementType
*, PadType
*);
71 static void *ChangePadMaskSize (ElementType
*, PadType
*);
72 static void *ChangePin2ndSize (ElementType
*, PinType
*);
73 static void *ChangeElement2ndSize (ElementType
*);
74 static void *ChangeViaSize (PinType
*);
75 static void *ChangeVia2ndSize (PinType
*);
76 static void *ChangeViaClearSize (PinType
*);
77 static void *ChangeViaMaskSize (PinType
*);
78 static void *ChangeLineSize (LayerType
*, LineType
*);
79 static void *ChangeLineClearSize (LayerType
*, LineType
*);
80 static void *ChangePolygonClearSize (LayerType
*, PolygonType
*);
81 static void *ChangeArcSize (LayerType
*, ArcType
*);
82 static void *ChangeArcClearSize (LayerType
*, ArcType
*);
83 static void *ChangeTextSize (LayerType
*, TextType
*);
84 static void *ChangeElementSize (ElementType
*);
85 static void *ChangeElementNameSize (ElementType
*);
86 static void *ChangePinName (ElementType
*, PinType
*);
87 static void *ChangePadName (ElementType
*, PadType
*);
88 static void *ChangeViaName (PinType
*);
89 static void *ChangeLineName (LayerType
*, LineType
*);
90 static void *ChangeElementName (ElementType
*);
91 static void *ChangeTextName (LayerType
*, TextType
*);
92 static void *ChangeElementSquare (ElementType
*);
93 static void *SetElementSquare (ElementType
*);
94 static void *ClrElementSquare (ElementType
*);
95 static void *ChangeElementOctagon (ElementType
*);
96 static void *SetElementOctagon (ElementType
*);
97 static void *ClrElementOctagon (ElementType
*);
98 static void *ChangePinSquare (ElementType
*, PinType
*);
99 static void *SetPinSquare (ElementType
*, PinType
*);
100 static void *ClrPinSquare (ElementType
*, PinType
*);
101 static void *ChangePinOctagon (ElementType
*, PinType
*);
102 static void *SetPinOctagon (ElementType
*, PinType
*);
103 static void *ClrPinOctagon (ElementType
*, PinType
*);
104 static void *ChangeViaOctagon (PinType
*);
105 static void *SetViaOctagon (PinType
*);
106 static void *ClrViaOctagon (PinType
*);
107 static void *ChangePadSquare (ElementType
*, PadType
*);
108 static void *SetPadSquare (ElementType
*, PadType
*);
109 static void *ClrPadSquare (ElementType
*, PadType
*);
110 static void *ChangeViaThermal (PinType
*);
111 static void *ChangePinThermal (ElementType
*, PinType
*);
112 static void *ChangeLineJoin (LayerType
*, LineType
*);
113 static void *SetLineJoin (LayerType
*, LineType
*);
114 static void *ClrLineJoin (LayerType
*, LineType
*);
115 static void *ChangeArcJoin (LayerType
*, ArcType
*);
116 static void *SetArcJoin (LayerType
*, ArcType
*);
117 static void *ClrArcJoin (LayerType
*, ArcType
*);
118 static void *ChangeTextJoin (LayerType
*, TextType
*);
119 static void *SetTextJoin (LayerType
*, TextType
*);
120 static void *ClrTextJoin (LayerType
*, TextType
*);
121 static void *ChangePolyClear (LayerType
*, PolygonType
*);
123 /* ---------------------------------------------------------------------------
124 * some local identifiers
126 static int Delta
; /* change of size */
127 static int Absolute
; /* Absolute size */
128 static char *NewName
; /* new name */
129 static ObjectFunctionType ChangeSizeFunctions
= {
134 ChangeElementSize
, /* changes silk screen line width */
135 ChangeElementNameSize
,
143 static ObjectFunctionType Change2ndSizeFunctions
= {
148 ChangeElement2ndSize
,
157 static ObjectFunctionType ChangeThermalFunctions
= {
171 static ObjectFunctionType ChangeClearSizeFunctions
= {
174 ChangePolygonClearSize
, /* just to tell the user not to :-) */
185 static ObjectFunctionType ChangeNameFunctions
= {
199 static ObjectFunctionType ChangeSquareFunctions
= {
213 static ObjectFunctionType ChangeJoinFunctions
= {
227 static ObjectFunctionType ChangeOctagonFunctions
= {
232 ChangeElementOctagon
,
241 static ObjectFunctionType ChangeMaskSizeFunctions
= {
247 ChangeElementMaskSize
,
259 static ObjectFunctionType SetSquareFunctions
= {
273 static ObjectFunctionType SetJoinFunctions
= {
287 static ObjectFunctionType SetOctagonFunctions
= {
301 static ObjectFunctionType ClrSquareFunctions
= {
315 static ObjectFunctionType ClrJoinFunctions
= {
329 static ObjectFunctionType ClrOctagonFunctions
= {
344 /* ---------------------------------------------------------------------------
345 * changes the thermal on a via
346 * returns TRUE if changed
349 ChangeViaThermal (PinType
*Via
)
351 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
352 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
353 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
354 if (!Delta
) /* remove the thermals */
355 CLEAR_THERM (INDEXOFCURRENT
, Via
);
357 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Via
);
358 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
359 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
364 /* ---------------------------------------------------------------------------
365 * changes the thermal on a pin
366 * returns TRUE if changed
369 ChangePinThermal (ElementType
*element
, PinType
*Pin
)
371 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, false);
372 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
373 AddObjectToFlagUndoList (PIN_TYPE
, element
, Pin
, Pin
);
374 if (!Delta
) /* remove the thermals */
375 CLEAR_THERM (INDEXOFCURRENT
, Pin
);
377 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Pin
);
378 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, true);
379 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
384 /* ---------------------------------------------------------------------------
385 * changes the size of a via
386 * returns TRUE if changed
389 ChangeViaSize (PinType
*Via
)
391 Coord value
= Absolute
? Absolute
: Via
->Thickness
+ Delta
;
393 if (TEST_FLAG (LOCKFLAG
, Via
))
395 if (!TEST_FLAG (HOLEFLAG
, Via
) && value
<= MAX_PINORVIASIZE
&&
396 value
>= MIN_PINORVIASIZE
&&
397 value
>= Via
->DrillingHole
+ MIN_PINORVIACOPPER
&&
398 value
!= Via
->Thickness
)
400 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
402 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
403 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Via
, Via
);
406 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
407 Via
->Mask
+= value
- Via
->Thickness
;
409 Via
->Thickness
= value
;
410 SetPinBoundingBox (Via
);
411 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
412 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
419 /* ---------------------------------------------------------------------------
420 * changes the drilling hole of a via
421 * returns TRUE if changed
424 ChangeVia2ndSize (PinType
*Via
)
426 Coord value
= (Absolute
) ? Absolute
: Via
->DrillingHole
+ Delta
;
428 if (TEST_FLAG (LOCKFLAG
, Via
))
430 if (value
<= MAX_PINORVIASIZE
&&
431 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Via
) ||
433 Via
->Thickness
- MIN_PINORVIACOPPER
)
434 && value
!= Via
->DrillingHole
)
436 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
438 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
439 Via
->DrillingHole
= value
;
440 if (TEST_FLAG (HOLEFLAG
, Via
))
442 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
443 Via
->Thickness
= value
;
445 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
452 /* ---------------------------------------------------------------------------
453 * changes the clearance size of a via
454 * returns TRUE if changed
457 ChangeViaClearSize (PinType
*Via
)
459 Coord value
= (Absolute
) ? Absolute
: Via
->Clearance
+ Delta
;
461 if (TEST_FLAG (LOCKFLAG
, Via
))
463 value
= MIN (MAX_LINESIZE
, value
);
466 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
468 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
469 value
= PCB
->Bloat
* 2 + 2;
470 if (Via
->Clearance
== value
)
472 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
473 AddObjectToClearSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
475 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
476 Via
->Clearance
= value
;
477 SetPinBoundingBox (Via
);
478 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
479 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
486 /* ---------------------------------------------------------------------------
487 * changes the size of a pin
488 * returns TRUE if changed
491 ChangePinSize (ElementType
*Element
, PinType
*Pin
)
493 Coord value
= (Absolute
) ? Absolute
: Pin
->Thickness
+ Delta
;
495 if (TEST_FLAG (LOCKFLAG
, Pin
))
497 if (!TEST_FLAG (HOLEFLAG
, Pin
) && value
<= MAX_PINORVIASIZE
&&
498 value
>= MIN_PINORVIASIZE
&&
499 value
>= Pin
->DrillingHole
+ MIN_PINORVIACOPPER
&&
500 value
!= Pin
->Thickness
)
502 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
503 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
505 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
506 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
507 Pin
->Mask
+= value
- Pin
->Thickness
;
508 Pin
->Thickness
= value
;
509 /* SetElementBB updates all associated rtrees */
510 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
511 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
518 /* ---------------------------------------------------------------------------
519 * changes the clearance size of a pin
520 * returns TRUE if changed
523 ChangePinClearSize (ElementType
*Element
, PinType
*Pin
)
525 Coord value
= (Absolute
) ? Absolute
: Pin
->Clearance
+ Delta
;
527 if (TEST_FLAG (LOCKFLAG
, Pin
))
529 value
= MIN (MAX_LINESIZE
, value
);
532 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
534 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
535 value
= PCB
->Bloat
* 2 + 2;
536 if (Pin
->Clearance
== value
)
538 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
539 AddObjectToClearSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
541 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
542 Pin
->Clearance
= value
;
543 /* SetElementBB updates all associated rtrees */
544 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
545 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
550 /* ---------------------------------------------------------------------------
551 * changes the size of a pad
552 * returns TRUE if changed
555 ChangePadSize (ElementType
*Element
, PadType
*Pad
)
557 Coord value
= (Absolute
) ? Absolute
: Pad
->Thickness
+ Delta
;
559 if (TEST_FLAG (LOCKFLAG
, Pad
))
561 if (value
<= MAX_PADSIZE
&& value
>= MIN_PADSIZE
&& value
!= Pad
->Thickness
)
563 AddObjectToSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
564 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
565 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
567 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
568 Pad
->Mask
+= value
- Pad
->Thickness
;
569 Pad
->Thickness
= value
;
570 /* SetElementBB updates all associated rtrees */
571 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
572 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
579 /* ---------------------------------------------------------------------------
580 * changes the clearance size of a pad
581 * returns TRUE if changed
584 ChangePadClearSize (ElementType
*Element
, PadType
*Pad
)
586 Coord value
= (Absolute
) ? Absolute
: Pad
->Clearance
+ Delta
;
588 if (TEST_FLAG (LOCKFLAG
, Pad
))
590 value
= MIN (MAX_LINESIZE
, value
);
593 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
595 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
596 value
= PCB
->Bloat
* 2 + 2;
597 if (value
== Pad
->Clearance
)
599 AddObjectToClearSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
600 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
602 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
603 Pad
->Clearance
= value
;
604 /* SetElementBB updates all associated rtrees */
605 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
606 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
611 /* ---------------------------------------------------------------------------
612 * changes the drilling hole of all pins of an element
613 * returns TRUE if changed
616 ChangeElement2ndSize (ElementType
*Element
)
618 bool changed
= false;
621 if (TEST_FLAG (LOCKFLAG
, Element
))
625 value
= (Absolute
) ? Absolute
: pin
->DrillingHole
+ Delta
;
626 if (value
<= MAX_PINORVIASIZE
&&
627 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, pin
) ||
631 && value
!= pin
->DrillingHole
)
634 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
636 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
637 pin
->DrillingHole
= value
;
638 if (TEST_FLAG (HOLEFLAG
, pin
))
640 AddObjectToSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
641 pin
->Thickness
= value
;
643 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
654 /* ---------------------------------------------------------------------------
655 * changes the drilling hole of a pin
656 * returns TRUE if changed
659 ChangePin2ndSize (ElementType
*Element
, PinType
*Pin
)
661 Coord value
= (Absolute
) ? Absolute
: Pin
->DrillingHole
+ Delta
;
663 if (TEST_FLAG (LOCKFLAG
, Pin
))
665 if (value
<= MAX_PINORVIASIZE
&&
666 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Pin
) ||
668 Pin
->Thickness
- MIN_PINORVIACOPPER
)
669 && value
!= Pin
->DrillingHole
)
671 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
673 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
674 Pin
->DrillingHole
= value
;
675 if (TEST_FLAG (HOLEFLAG
, Pin
))
677 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
678 Pin
->Thickness
= value
;
680 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
687 /* ---------------------------------------------------------------------------
688 * changes the size of a line
689 * returns TRUE if changed
692 ChangeLineSize (LayerType
*Layer
, LineType
*Line
)
694 Coord value
= (Absolute
) ? Absolute
: Line
->Thickness
+ Delta
;
696 if (TEST_FLAG (LOCKFLAG
, Line
))
698 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
699 value
!= Line
->Thickness
)
701 AddObjectToSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
703 r_delete_entry (Layer
->line_tree
, (BoxType
*) Line
);
704 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
705 Line
->Thickness
= value
;
706 SetLineBoundingBox (Line
);
707 r_insert_entry (Layer
->line_tree
, (BoxType
*) Line
, 0);
708 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
709 DrawLine (Layer
, Line
);
715 /* ---------------------------------------------------------------------------
716 * changes the clearance size of a line
717 * returns TRUE if changed
720 ChangeLineClearSize (LayerType
*Layer
, LineType
*Line
)
722 Coord value
= (Absolute
) ? Absolute
: Line
->Clearance
+ Delta
;
724 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
726 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
727 if (value
!= Line
->Clearance
)
729 AddObjectToClearSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
730 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
732 r_delete_entry (Layer
->line_tree
, (BoxType
*) Line
);
733 Line
->Clearance
= value
;
734 if (Line
->Clearance
== 0)
736 CLEAR_FLAG (CLEARLINEFLAG
, Line
);
737 Line
->Clearance
= MIL_TO_COORD(10);
739 SetLineBoundingBox (Line
);
740 r_insert_entry (Layer
->line_tree
, (BoxType
*) Line
, 0);
741 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
742 DrawLine (Layer
, Line
);
748 /* ---------------------------------------------------------------------------
749 * Handle attepts to change the clearance of a polygon.
752 ChangePolygonClearSize (LayerType
*Layer
, PolygonType
*poly
)
754 static int shown_this_message
= 0;
755 if (!shown_this_message
)
757 gui
->confirm_dialog (_("To change the clearance of objects in a polygon, "
758 "change the objects, not the polygon.\n"
759 "Hint: To set a minimum clearance for a group of objects, "
760 "select them all then :MinClearGap(Selected,=10,mil)"),
762 shown_this_message
= 1;
768 /* ---------------------------------------------------------------------------
769 * changes the size of an arc
770 * returns TRUE if changed
773 ChangeArcSize (LayerType
*Layer
, ArcType
*Arc
)
775 Coord value
= (Absolute
) ? Absolute
: Arc
->Thickness
+ Delta
;
777 if (TEST_FLAG (LOCKFLAG
, Arc
))
779 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
780 value
!= Arc
->Thickness
)
782 AddObjectToSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
784 r_delete_entry (Layer
->arc_tree
, (BoxType
*) Arc
);
785 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
786 Arc
->Thickness
= value
;
787 SetArcBoundingBox (Arc
);
788 r_insert_entry (Layer
->arc_tree
, (BoxType
*) Arc
, 0);
789 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
790 DrawArc (Layer
, Arc
);
796 /* ---------------------------------------------------------------------------
797 * changes the clearance size of an arc
798 * returns TRUE if changed
801 ChangeArcClearSize (LayerType
*Layer
, ArcType
*Arc
)
803 Coord value
= (Absolute
) ? Absolute
: Arc
->Clearance
+ Delta
;
805 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
807 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
808 if (value
!= Arc
->Clearance
)
810 AddObjectToClearSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
812 r_delete_entry (Layer
->arc_tree
, (BoxType
*) Arc
);
813 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
814 Arc
->Clearance
= value
;
815 if (Arc
->Clearance
== 0)
817 CLEAR_FLAG (CLEARLINEFLAG
, Arc
);
818 Arc
->Clearance
= MIL_TO_COORD(10);
820 SetArcBoundingBox (Arc
);
821 r_insert_entry (Layer
->arc_tree
, (BoxType
*) Arc
, 0);
822 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
823 DrawArc (Layer
, Arc
);
829 /* ---------------------------------------------------------------------------
830 * changes the scaling factor of a text object
831 * returns TRUE if changed
834 ChangeTextSize (LayerType
*Layer
, TextType
*Text
)
836 int value
= (Absolute
!= 0 ? 0 : Text
->Scale
) +
837 (double)(Absolute
!= 0 ? Absolute
: Delta
)
838 / (double)FONT_CAPHEIGHT
* 100.;
840 if (TEST_FLAG (LOCKFLAG
, Text
))
842 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
&&
843 value
!= Text
->Scale
)
845 AddObjectToSizeUndoList (TEXT_TYPE
, Layer
, Text
, Text
);
846 EraseText (Layer
, Text
);
847 r_delete_entry (Layer
->text_tree
, (BoxType
*) Text
);
848 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
850 SetTextBoundingBox (&PCB
->Font
, Text
);
851 r_insert_entry (Layer
->text_tree
, (BoxType
*) Text
, 0);
852 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
853 DrawText (Layer
, Text
);
859 /* ---------------------------------------------------------------------------
860 * changes the scaling factor of an element's outline
861 * returns TRUE if changed
864 ChangeElementSize (ElementType
*Element
)
867 bool changed
= false;
869 if (TEST_FLAG (LOCKFLAG
, Element
))
872 EraseElement (Element
);
873 ELEMENTLINE_LOOP (Element
);
875 value
= (Absolute
) ? Absolute
: line
->Thickness
+ Delta
;
876 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
877 value
!= line
->Thickness
)
879 AddObjectToSizeUndoList (ELEMENTLINE_TYPE
, Element
, line
, line
);
880 line
->Thickness
= value
;
887 value
= (Absolute
) ? Absolute
: arc
->Thickness
+ Delta
;
888 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
889 value
!= arc
->Thickness
)
891 AddObjectToSizeUndoList (ELEMENTARC_TYPE
, Element
, arc
, arc
);
892 arc
->Thickness
= value
;
899 DrawElement (Element
);
906 /* ---------------------------------------------------------------------------
907 * changes the scaling factor of a elementname object
908 * returns TRUE if changed
911 ChangeElementNameSize (ElementType
*Element
)
913 int value
= (Absolute
!= 0 ? 0 : DESCRIPTION_TEXT (Element
).Scale
) +
914 (double)(Absolute
!= 0 ? Absolute
: Delta
)
915 / (double)FONT_CAPHEIGHT
* 100.;
917 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
919 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
)
921 EraseElementName (Element
);
922 ELEMENTTEXT_LOOP (Element
);
924 AddObjectToSizeUndoList (ELEMENTNAME_TYPE
, Element
, text
, text
);
925 r_delete_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
);
927 SetTextBoundingBox (&PCB
->Font
, text
);
928 r_insert_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
, 0);
931 DrawElementName (Element
);
937 /* ---------------------------------------------------------------------------
938 * changes the name of a via
941 ChangeViaName (PinType
*Via
)
943 char *old
= Via
->Name
;
945 if (TEST_FLAG (DISPLAYNAMEFLAG
, Via
))
956 /* ---------------------------------------------------------------------------
957 * changes the name of a pin
960 ChangePinName (ElementType
*Element
, PinType
*Pin
)
962 char *old
= Pin
->Name
;
964 (void) Element
; /* get rid of 'unused...' warnings */
965 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pin
))
976 /* ---------------------------------------------------------------------------
977 * changes the name of a pad
980 ChangePadName (ElementType
*Element
, PadType
*Pad
)
982 char *old
= Pad
->Name
;
984 (void) Element
; /* get rid of 'unused...' warnings */
985 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pad
))
996 /* ---------------------------------------------------------------------------
997 * changes the name of a line
1000 ChangeLineName (LayerType
*Layer
, LineType
*Line
)
1002 char *old
= Line
->Number
;
1005 Line
->Number
= NewName
;
1009 /* ---------------------------------------------------------------------------
1010 * changes the layout-name of an element
1014 ChangeElementText (PCBType
*pcb
, DataType
*data
, ElementType
*Element
, int which
, char *new_name
)
1016 char *old
= Element
->Name
[which
].TextString
;
1019 printf("In ChangeElementText, updating old TextString %s to %s\n", old
, new_name
);
1022 if (pcb
&& which
== NAME_INDEX (pcb
))
1023 EraseElementName (Element
);
1025 r_delete_entry (data
->name_tree
[which
],
1026 & Element
->Name
[which
].BoundingBox
);
1028 Element
->Name
[which
].TextString
= new_name
;
1029 SetTextBoundingBox (&PCB
->Font
, &Element
->Name
[which
]);
1031 r_insert_entry (data
->name_tree
[which
],
1032 & Element
->Name
[which
].BoundingBox
, 0);
1034 if (pcb
&& which
== NAME_INDEX (pcb
))
1035 DrawElementName (Element
);
1041 ChangeElementName (ElementType
*Element
)
1043 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
1045 if (NAME_INDEX (PCB
) == NAMEONPCB_INDEX
)
1047 if (TEST_FLAG (UNIQUENAMEFLAG
, PCB
) &&
1048 UniqueElementName (PCB
->Data
, NewName
) != NewName
)
1050 Message (_("Error: The name \"%s\" is not unique!\n"), NewName
);
1051 return ((char *) -1);
1055 return ChangeElementText (PCB
, PCB
->Data
, Element
, NAME_INDEX (PCB
), NewName
);
1058 /* ---------------------------------------------------------------------------
1059 * sets data of a text object and calculates bounding box
1060 * memory must have already been allocated
1061 * the one for the new string is allocated
1062 * returns true if the string has been changed
1065 ChangeTextName (LayerType
*Layer
, TextType
*Text
)
1067 char *old
= Text
->TextString
;
1069 if (TEST_FLAG (LOCKFLAG
, Text
))
1071 EraseText (Layer
, Text
);
1072 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1073 Text
->TextString
= NewName
;
1075 /* calculate size of the bounding box */
1076 SetTextBoundingBox (&PCB
->Font
, Text
);
1077 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1078 DrawText (Layer
, Text
);
1082 /* ---------------------------------------------------------------------------
1083 * changes the name of a layout; memory has to be already allocated
1086 ChangeLayoutName (char *Name
)
1090 hid_action ("PCBChanged");
1094 /* ---------------------------------------------------------------------------
1095 * changes the side of the board an element is on
1096 * returns TRUE if done
1099 ChangeElementSide (ElementType
*Element
, Coord yoff
)
1101 if (TEST_FLAG (LOCKFLAG
, Element
))
1103 EraseElement (Element
);
1104 AddObjectToMirrorUndoList (ELEMENT_TYPE
, Element
, Element
, Element
, yoff
);
1105 MirrorElementCoordinates (PCB
->Data
, Element
, yoff
);
1106 DrawElement (Element
);
1110 /* ---------------------------------------------------------------------------
1111 * changes the name of a layer; memory has to be already allocated
1114 ChangeLayerName (LayerType
*Layer
, char *Name
)
1116 free (CURRENT
->Name
);
1117 CURRENT
->Name
= Name
;
1118 hid_action ("LayersChanged");
1122 /* ---------------------------------------------------------------------------
1123 * changes the clearance flag of a line
1126 ChangeLineJoin (LayerType
*Layer
, LineType
*Line
)
1128 if (TEST_FLAG (LOCKFLAG
, Line
))
1131 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1133 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, false);
1134 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1136 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Line
, Line
);
1137 TOGGLE_FLAG (CLEARLINEFLAG
, Line
);
1138 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1140 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, true);
1141 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1143 DrawLine (Layer
, Line
);
1147 /* ---------------------------------------------------------------------------
1148 * sets the clearance flag of a line
1151 SetLineJoin (LayerType
*Layer
, LineType
*Line
)
1153 if (TEST_FLAG (LOCKFLAG
, Line
) || TEST_FLAG (CLEARLINEFLAG
, Line
))
1155 return ChangeLineJoin (Layer
, Line
);
1158 /* ---------------------------------------------------------------------------
1159 * clears the clearance flag of a line
1162 ClrLineJoin (LayerType
*Layer
, LineType
*Line
)
1164 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
1166 return ChangeLineJoin (Layer
, Line
);
1169 /* ---------------------------------------------------------------------------
1170 * changes the clearance flag of an arc
1173 ChangeArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1175 if (TEST_FLAG (LOCKFLAG
, Arc
))
1178 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1180 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1181 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, false);
1183 AddObjectToFlagUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
1184 TOGGLE_FLAG (CLEARLINEFLAG
, Arc
);
1185 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1187 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1188 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, true);
1190 DrawArc (Layer
, Arc
);
1194 /* ---------------------------------------------------------------------------
1195 * sets the clearance flag of an arc
1198 SetArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1200 if (TEST_FLAG (LOCKFLAG
, Arc
) || TEST_FLAG (CLEARLINEFLAG
, Arc
))
1202 return ChangeArcJoin (Layer
, Arc
);
1205 /* ---------------------------------------------------------------------------
1206 * clears the clearance flag of an arc
1209 ClrArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1211 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
1213 return ChangeArcJoin (Layer
, Arc
);
1216 /* ---------------------------------------------------------------------------
1217 * changes the clearance flag of a text
1220 ChangeTextJoin (LayerType
*Layer
, TextType
*Text
)
1222 if (TEST_FLAG (LOCKFLAG
, Text
))
1224 EraseText (Layer
, Text
);
1225 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1227 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, false);
1228 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1230 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Text
, Text
);
1231 TOGGLE_FLAG (CLEARLINEFLAG
, Text
);
1232 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1234 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, true);
1235 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1237 DrawText (Layer
, Text
);
1241 /* ---------------------------------------------------------------------------
1242 * sets the clearance flag of a text
1245 SetTextJoin (LayerType
*Layer
, TextType
*Text
)
1247 if (TEST_FLAG (LOCKFLAG
, Text
) || TEST_FLAG (CLEARLINEFLAG
, Text
))
1249 return ChangeTextJoin (Layer
, Text
);
1252 /* ---------------------------------------------------------------------------
1253 * clears the clearance flag of a text
1256 ClrTextJoin (LayerType
*Layer
, TextType
*Text
)
1258 if (TEST_FLAG (LOCKFLAG
, Text
) || !TEST_FLAG (CLEARLINEFLAG
, Text
))
1260 return ChangeTextJoin (Layer
, Text
);
1263 /* ---------------------------------------------------------------------------
1264 * changes the square flag of all pins on an element
1267 ChangeElementSquare (ElementType
*Element
)
1271 if (TEST_FLAG (LOCKFLAG
, Element
))
1275 ans
= ChangePinSquare (Element
, pin
);
1280 ans
= ChangePadSquare (Element
, pad
);
1286 /* ---------------------------------------------------------------------------
1287 * sets the square flag of all pins on an element
1290 SetElementSquare (ElementType
*Element
)
1294 if (TEST_FLAG (LOCKFLAG
, Element
))
1298 ans
= SetPinSquare (Element
, pin
);
1303 ans
= SetPadSquare (Element
, pad
);
1309 /* ---------------------------------------------------------------------------
1310 * clears the square flag of all pins on an element
1313 ClrElementSquare (ElementType
*Element
)
1317 if (TEST_FLAG (LOCKFLAG
, Element
))
1321 ans
= ClrPinSquare (Element
, pin
);
1326 ans
= ClrPadSquare (Element
, pad
);
1332 /* ---------------------------------------------------------------------------
1333 * changes the octagon flags of all pins of an element
1336 ChangeElementOctagon (ElementType
*Element
)
1338 void *result
= NULL
;
1340 if (TEST_FLAG (LOCKFLAG
, Element
))
1344 ChangePinOctagon (Element
, pin
);
1351 /* ---------------------------------------------------------------------------
1352 * sets the octagon flags of all pins of an element
1355 SetElementOctagon (ElementType
*Element
)
1357 void *result
= NULL
;
1359 if (TEST_FLAG (LOCKFLAG
, Element
))
1363 SetPinOctagon (Element
, pin
);
1370 /* ---------------------------------------------------------------------------
1371 * clears the octagon flags of all pins of an element
1374 ClrElementOctagon (ElementType
*Element
)
1376 void *result
= NULL
;
1378 if (TEST_FLAG (LOCKFLAG
, Element
))
1382 ClrPinOctagon (Element
, pin
);
1389 /* ---------------------------------------------------------------------------
1390 * changes the square flag of a pad
1393 ChangePadSquare (ElementType
*Element
, PadType
*Pad
)
1395 if (TEST_FLAG (LOCKFLAG
, Pad
))
1398 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, false);
1399 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1400 AddObjectToFlagUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
1401 TOGGLE_FLAG (SQUAREFLAG
, Pad
);
1402 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, true);
1403 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1408 /* ---------------------------------------------------------------------------
1409 * sets the square flag of a pad
1412 SetPadSquare (ElementType
*Element
, PadType
*Pad
)
1415 if (TEST_FLAG (LOCKFLAG
, Pad
) || TEST_FLAG (SQUAREFLAG
, Pad
))
1418 return (ChangePadSquare (Element
, Pad
));
1422 /* ---------------------------------------------------------------------------
1423 * clears the square flag of a pad
1426 ClrPadSquare (ElementType
*Element
, PadType
*Pad
)
1429 if (TEST_FLAG (LOCKFLAG
, Pad
) || !TEST_FLAG (SQUAREFLAG
, Pad
))
1432 return (ChangePadSquare (Element
, Pad
));
1436 /* ---------------------------------------------------------------------------
1437 * changes the square flag of a pin
1440 ChangePinSquare (ElementType
*Element
, PinType
*Pin
)
1442 if (TEST_FLAG (LOCKFLAG
, Pin
))
1445 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1446 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1447 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1448 TOGGLE_FLAG (SQUAREFLAG
, Pin
);
1449 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1450 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1455 /* ---------------------------------------------------------------------------
1456 * sets the square flag of a pin
1459 SetPinSquare (ElementType
*Element
, PinType
*Pin
)
1461 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (SQUAREFLAG
, Pin
))
1464 return (ChangePinSquare (Element
, Pin
));
1467 /* ---------------------------------------------------------------------------
1468 * clears the square flag of a pin
1471 ClrPinSquare (ElementType
*Element
, PinType
*Pin
)
1473 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (SQUAREFLAG
, Pin
))
1476 return (ChangePinSquare (Element
, Pin
));
1479 /* ---------------------------------------------------------------------------
1480 * changes the octagon flag of a via
1483 ChangeViaOctagon (PinType
*Via
)
1485 if (TEST_FLAG (LOCKFLAG
, Via
))
1488 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
1489 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1490 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1491 TOGGLE_FLAG (OCTAGONFLAG
, Via
);
1492 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
1493 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1498 /* ---------------------------------------------------------------------------
1499 * sets the octagon flag of a via
1502 SetViaOctagon (PinType
*Via
)
1504 if (TEST_FLAG (LOCKFLAG
, Via
) || TEST_FLAG (OCTAGONFLAG
, Via
))
1507 return (ChangeViaOctagon (Via
));
1510 /* ---------------------------------------------------------------------------
1511 * clears the octagon flag of a via
1514 ClrViaOctagon (PinType
*Via
)
1516 if (TEST_FLAG (LOCKFLAG
, Via
) || !TEST_FLAG (OCTAGONFLAG
, Via
))
1519 return (ChangeViaOctagon (Via
));
1522 /* ---------------------------------------------------------------------------
1523 * changes the octagon flag of a pin
1526 ChangePinOctagon (ElementType
*Element
, PinType
*Pin
)
1528 if (TEST_FLAG (LOCKFLAG
, Pin
))
1531 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1532 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1533 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1534 TOGGLE_FLAG (OCTAGONFLAG
, Pin
);
1535 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1536 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1541 /* ---------------------------------------------------------------------------
1542 * sets the octagon flag of a pin
1545 SetPinOctagon (ElementType
*Element
, PinType
*Pin
)
1547 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (OCTAGONFLAG
, Pin
))
1550 return (ChangePinOctagon (Element
, Pin
));
1553 /* ---------------------------------------------------------------------------
1554 * clears the octagon flag of a pin
1557 ClrPinOctagon (ElementType
*Element
, PinType
*Pin
)
1559 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (OCTAGONFLAG
, Pin
))
1562 return (ChangePinOctagon (Element
, Pin
));
1565 /* ---------------------------------------------------------------------------
1566 * changes the hole flag of a via
1569 ChangeHole (PinType
*Via
)
1571 if (TEST_FLAG (LOCKFLAG
, Via
))
1574 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1575 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1576 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
1577 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1578 TOGGLE_FLAG (HOLEFLAG
, Via
);
1580 if (TEST_FLAG (HOLEFLAG
, Via
))
1582 /* A tented via becomes an minimally untented hole. An untented
1583 via retains its mask clearance. */
1584 if (Via
->Mask
> Via
->Thickness
)
1586 Via
->Mask
= (Via
->DrillingHole
1587 + (Via
->Mask
- Via
->Thickness
));
1589 else if (Via
->Mask
< Via
->DrillingHole
)
1591 Via
->Mask
= Via
->DrillingHole
+ 2 * MASKFRAME
;
1596 Via
->Mask
= (Via
->Thickness
1597 + (Via
->Mask
- Via
->DrillingHole
));
1600 SetPinBoundingBox (Via
);
1601 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
1602 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1608 /* ---------------------------------------------------------------------------
1609 * changes the nopaste flag of a pad
1612 ChangePaste (PadType
*Pad
)
1614 if (TEST_FLAG (LOCKFLAG
, Pad
))
1617 AddObjectToFlagUndoList (PAD_TYPE
, Pad
, Pad
, Pad
);
1618 TOGGLE_FLAG (NOPASTEFLAG
, Pad
);
1624 /* ---------------------------------------------------------------------------
1625 * changes the CLEARPOLY flag of a polygon
1628 ChangePolyClear (LayerType
*Layer
, PolygonType
*Polygon
)
1630 if (TEST_FLAG (LOCKFLAG
, Polygon
))
1632 AddObjectToClearPolyUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
, true);
1633 AddObjectToFlagUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
1634 TOGGLE_FLAG (CLEARPOLYFLAG
, Polygon
);
1635 InitClip (PCB
->Data
, Layer
, Polygon
);
1636 DrawPolygon (Layer
, Polygon
);
1640 /* ----------------------------------------------------------------------
1641 * changes the side of all selected and visible elements
1642 * returns true if anything has changed
1645 ChangeSelectedElementSide (void)
1647 bool change
= false;
1649 /* setup identifiers */
1650 if (PCB
->PinOn
&& PCB
->ElementOn
)
1651 ELEMENT_LOOP (PCB
->Data
);
1653 if (TEST_FLAG (SELECTEDFLAG
, element
))
1655 change
|= ChangeElementSide (element
, 0);
1662 IncrementUndoSerialNumber ();
1667 /* ----------------------------------------------------------------------
1668 * changes the thermals on all selected and visible pins
1669 * and/or vias. Returns true if anything has changed
1672 ChangeSelectedThermals (int types
, int therm_style
)
1674 bool change
= false;
1676 Delta
= therm_style
;
1677 change
= SelectedOperation (&ChangeThermalFunctions
, false, types
);
1681 IncrementUndoSerialNumber ();
1686 /* ----------------------------------------------------------------------
1687 * changes the size of all selected and visible object types
1688 * returns true if anything has changed
1691 ChangeSelectedSize (int types
, Coord Difference
, bool fixIt
)
1693 bool change
= false;
1695 /* setup identifiers */
1696 Absolute
= (fixIt
) ? Difference
: 0;
1699 change
= SelectedOperation (&ChangeSizeFunctions
, false, types
);
1703 IncrementUndoSerialNumber ();
1708 /* ----------------------------------------------------------------------
1709 * changes the clearance size of all selected and visible objects
1710 * returns true if anything has changed
1713 ChangeSelectedClearSize (int types
, Coord Difference
, bool fixIt
)
1715 bool change
= false;
1717 /* setup identifiers */
1718 Absolute
= (fixIt
) ? Difference
: 0;
1720 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1721 change
= SelectedOperation (&ChangeMaskSizeFunctions
, false, types
);
1723 change
= SelectedOperation (&ChangeClearSizeFunctions
, false, types
);
1727 IncrementUndoSerialNumber ();
1732 /* --------------------------------------------------------------------------
1733 * changes the 2nd size (drilling hole) of all selected and visible objects
1734 * returns true if anything has changed
1737 ChangeSelected2ndSize (int types
, Coord Difference
, bool fixIt
)
1739 bool change
= false;
1741 /* setup identifiers */
1742 Absolute
= (fixIt
) ? Difference
: 0;
1744 change
= SelectedOperation (&Change2ndSizeFunctions
, false, types
);
1748 IncrementUndoSerialNumber ();
1753 /* ----------------------------------------------------------------------
1754 * changes the clearance flag (join) of all selected and visible lines
1755 * and/or arcs. Returns true if anything has changed
1758 ChangeSelectedJoin (int types
)
1760 bool change
= false;
1762 change
= SelectedOperation (&ChangeJoinFunctions
, false, types
);
1766 IncrementUndoSerialNumber ();
1771 /* ----------------------------------------------------------------------
1772 * changes the clearance flag (join) of all selected and visible lines
1773 * and/or arcs. Returns true if anything has changed
1776 SetSelectedJoin (int types
)
1778 bool change
= false;
1780 change
= SelectedOperation (&SetJoinFunctions
, false, types
);
1784 IncrementUndoSerialNumber ();
1789 /* ----------------------------------------------------------------------
1790 * changes the clearance flag (join) of all selected and visible lines
1791 * and/or arcs. Returns true if anything has changed
1794 ClrSelectedJoin (int types
)
1796 bool change
= false;
1798 change
= SelectedOperation (&ClrJoinFunctions
, false, types
);
1802 IncrementUndoSerialNumber ();
1807 /* ----------------------------------------------------------------------
1808 * changes the square-flag of all selected and visible pins or pads
1809 * returns true if anything has changed
1812 ChangeSelectedSquare (int types
)
1814 bool change
= false;
1816 change
= SelectedOperation (&ChangeSquareFunctions
, false, types
);
1820 IncrementUndoSerialNumber ();
1825 /* ----------------------------------------------------------------------
1826 * sets the square-flag of all selected and visible pins or pads
1827 * returns true if anything has changed
1830 SetSelectedSquare (int types
)
1832 bool change
= false;
1834 change
= SelectedOperation (&SetSquareFunctions
, false, types
);
1838 IncrementUndoSerialNumber ();
1843 /* ----------------------------------------------------------------------
1844 * clears the square-flag of all selected and visible pins or pads
1845 * returns true if anything has changed
1848 ClrSelectedSquare (int types
)
1850 bool change
= false;
1852 change
= SelectedOperation (&ClrSquareFunctions
, false, types
);
1856 IncrementUndoSerialNumber ();
1861 /* ----------------------------------------------------------------------
1862 * changes the octagon-flag of all selected and visible pins and vias
1863 * returns true if anything has changed
1866 ChangeSelectedOctagon (int types
)
1868 bool change
= false;
1870 change
= SelectedOperation (&ChangeOctagonFunctions
, false, types
);
1874 IncrementUndoSerialNumber ();
1879 /* ----------------------------------------------------------------------
1880 * sets the octagon-flag of all selected and visible pins and vias
1881 * returns true if anything has changed
1884 SetSelectedOctagon (int types
)
1886 bool change
= false;
1888 change
= SelectedOperation (&SetOctagonFunctions
, false, types
);
1892 IncrementUndoSerialNumber ();
1897 /* ----------------------------------------------------------------------
1898 * clears the octagon-flag of all selected and visible pins and vias
1899 * returns true if anything has changed
1902 ClrSelectedOctagon (int types
)
1904 bool change
= false;
1906 change
= SelectedOperation (&ClrOctagonFunctions
, false, types
);
1910 IncrementUndoSerialNumber ();
1915 /* ----------------------------------------------------------------------
1916 * changes the hole-flag of all selected and visible vias
1917 * returns true if anything has changed
1920 ChangeSelectedHole (void)
1922 bool change
= false;
1925 VIA_LOOP (PCB
->Data
);
1927 if (TEST_FLAG (SELECTEDFLAG
, via
))
1928 change
|= ChangeHole (via
);
1934 IncrementUndoSerialNumber ();
1939 /* ----------------------------------------------------------------------
1940 * changes the no paste-flag of all selected and visible pads
1941 * returns true if anything has changed
1944 ChangeSelectedPaste (void)
1946 bool change
= false;
1948 ALLPAD_LOOP (PCB
->Data
);
1950 if (TEST_FLAG (SELECTEDFLAG
, pad
))
1951 change
|= ChangePaste (pad
);
1957 IncrementUndoSerialNumber ();
1963 /* ---------------------------------------------------------------------------
1964 * changes the size of the passed object
1965 * Returns true if anything is changed
1968 ChangeObjectSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1969 Coord Difference
, bool fixIt
)
1973 /* setup identifier */
1974 Absolute
= (fixIt
) ? Difference
: 0;
1977 (ObjectOperation (&ChangeSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
);
1981 IncrementUndoSerialNumber ();
1986 /* ---------------------------------------------------------------------------
1987 * changes the clearance size of the passed object
1988 * Returns true if anything is changed
1991 ChangeObjectClearSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1992 Coord Difference
, bool fixIt
)
1996 /* setup identifier */
1997 Absolute
= (fixIt
) ? Difference
: 0;
1999 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
2001 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2005 (ObjectOperation (&ChangeClearSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2010 IncrementUndoSerialNumber ();
2015 /* ---------------------------------------------------------------------------
2016 * changes the thermal of the passed object
2017 * Returns true if anything is changed
2021 ChangeObjectThermal (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2026 Delta
= Absolute
= therm_type
;
2028 (ObjectOperation (&ChangeThermalFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2033 IncrementUndoSerialNumber ();
2038 /* ---------------------------------------------------------------------------
2039 * changes the 2nd size of the passed object
2040 * Returns true if anything is changed
2043 ChangeObject2ndSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2044 Coord Difference
, bool fixIt
, bool incundo
)
2048 /* setup identifier */
2049 Absolute
= (fixIt
) ? Difference
: 0;
2052 (ObjectOperation (&Change2ndSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2058 IncrementUndoSerialNumber ();
2063 /* ---------------------------------------------------------------------------
2064 * changes the mask size of the passed object
2065 * Returns true if anything is changed
2068 ChangeObjectMaskSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2069 Coord Difference
, bool fixIt
)
2073 /* setup identifier */
2074 Absolute
= (fixIt
) ? Difference
: 0;
2077 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2082 IncrementUndoSerialNumber ();
2087 /* ---------------------------------------------------------------------------
2088 * changes the name of the passed object
2089 * returns the old name
2091 * The allocated memory isn't freed because the old string is used
2092 * by the undo module.
2095 ChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
, char *Name
)
2098 /* setup identifier */
2100 result
= ObjectOperation (&ChangeNameFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
);
2105 /* ---------------------------------------------------------------------------
2106 * changes the clearance-flag of the passed object
2107 * Returns true if anything is changed
2110 ChangeObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2112 if (ObjectOperation (&ChangeJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2115 IncrementUndoSerialNumber ();
2121 /* ---------------------------------------------------------------------------
2122 * sets the clearance-flag of the passed object
2123 * Returns true if anything is changed
2126 SetObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2128 if (ObjectOperation (&SetJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2131 IncrementUndoSerialNumber ();
2137 /* ---------------------------------------------------------------------------
2138 * clears the clearance-flag of the passed object
2139 * Returns true if anything is changed
2142 ClrObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2144 if (ObjectOperation (&ClrJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2147 IncrementUndoSerialNumber ();
2153 /* ---------------------------------------------------------------------------
2154 * changes the square-flag of the passed object
2155 * Returns true if anything is changed
2158 ChangeObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2160 if (ObjectOperation (&ChangeSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2164 IncrementUndoSerialNumber ();
2170 /* ---------------------------------------------------------------------------
2171 * sets the square-flag of the passed object
2172 * Returns true if anything is changed
2175 SetObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2177 if (ObjectOperation (&SetSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2180 IncrementUndoSerialNumber ();
2186 /* ---------------------------------------------------------------------------
2187 * clears the square-flag of the passed object
2188 * Returns true if anything is changed
2191 ClrObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2193 if (ObjectOperation (&ClrSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2196 IncrementUndoSerialNumber ();
2202 /* ---------------------------------------------------------------------------
2203 * changes the octagon-flag of the passed object
2204 * Returns true if anything is changed
2207 ChangeObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2209 if (ObjectOperation (&ChangeOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2213 IncrementUndoSerialNumber ();
2219 /* ---------------------------------------------------------------------------
2220 * sets the octagon-flag of the passed object
2221 * Returns true if anything is changed
2224 SetObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2226 if (ObjectOperation (&SetOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2229 IncrementUndoSerialNumber ();
2235 /* ---------------------------------------------------------------------------
2236 * clears the octagon-flag of the passed object
2237 * Returns true if anything is changed
2240 ClrObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2242 if (ObjectOperation (&ClrOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2245 IncrementUndoSerialNumber ();
2251 /* ---------------------------------------------------------------------------
2252 * queries the user for a new object name and changes it
2254 * The allocated memory isn't freed because the old string is used
2255 * by the undo module.
2258 QueryInputAndChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2263 /* if passed an element name, make it an element reference instead */
2264 if (Type
== ELEMENTNAME_TYPE
)
2266 Type
= ELEMENT_TYPE
;
2273 name
= gui
->prompt_for (_("Linename:"),
2274 EMPTY (((LineType
*) Ptr2
)->Number
));
2278 name
= gui
->prompt_for (_("Vianame:"),
2279 EMPTY (((PinType
*) Ptr2
)->Name
));
2283 sprintf (msg
, _("%s Pin Name:"), EMPTY (((PinType
*) Ptr2
)->Number
));
2284 name
= gui
->prompt_for (msg
, EMPTY (((PinType
*) Ptr2
)->Name
));
2288 sprintf (msg
, _("%s Pad Name:"), EMPTY (((PadType
*) Ptr2
)->Number
));
2289 name
= gui
->prompt_for (msg
, EMPTY (((PadType
*) Ptr2
)->Name
));
2293 name
= gui
->prompt_for (_("Enter text:"),
2294 EMPTY (((TextType
*) Ptr2
)->TextString
));
2298 name
= gui
->prompt_for (_("Elementname:"),
2300 (PCB
, (ElementType
*) Ptr2
)));
2305 /* NB: ChangeObjectName takes ownership of the passed memory */
2306 char *old
= (char *)ChangeObjectName (Type
, Ptr1
, Ptr2
, Ptr3
, name
);
2307 if (old
!= (char *) -1)
2309 AddObjectToChangeNameUndoList (Type
, Ptr1
, Ptr2
, Ptr3
, old
);
2310 IncrementUndoSerialNumber ();
2318 /* ---------------------------------------------------------------------------
2319 * changes the maximum size of a layout
2320 * adjusts the scrollbars
2321 * releases the saved pixmap if necessary
2322 * and adjusts the cursor confinement box
2325 ChangePCBSize (Coord Width
, Coord Height
)
2327 PCB
->MaxWidth
= Width
;
2328 PCB
->MaxHeight
= Height
;
2330 /* crosshair range is different if pastebuffer-mode
2333 if (Settings
.Mode
== PASTEBUFFER_MODE
)
2334 SetCrosshairRange (PASTEBUFFER
->X
- PASTEBUFFER
->BoundingBox
.X1
,
2335 PASTEBUFFER
->Y
- PASTEBUFFER
->BoundingBox
.Y1
,
2337 Width
- (PASTEBUFFER
->BoundingBox
.X2
-
2338 PASTEBUFFER
->X
)), MAX (0,
2345 SetCrosshairRange (0, 0, Width
, Height
);
2346 hid_action ("PCBChanged");
2349 /* ---------------------------------------------------------------------------
2350 * changes the mask size of a pad
2351 * returns TRUE if changed
2354 ChangePadMaskSize (ElementType
*Element
, PadType
*Pad
)
2356 Coord value
= (Absolute
) ? Absolute
: Pad
->Mask
+ Delta
;
2358 value
= MAX (value
, 0);
2359 if (value
== Pad
->Mask
&& Absolute
== 0)
2360 value
= Pad
->Thickness
;
2361 if (value
!= Pad
->Mask
)
2363 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
2365 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
2367 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2374 /* ---------------------------------------------------------------------------
2375 * changes the mask size of a pin
2376 * returns TRUE if changed
2379 ChangePinMaskSize (ElementType
*Element
, PinType
*Pin
)
2381 Coord value
= (Absolute
) ? Absolute
: Pin
->Mask
+ Delta
;
2383 value
= MAX (value
, 0);
2384 if (value
== Pin
->Mask
&& Absolute
== 0)
2385 value
= Pin
->Thickness
;
2386 if (value
!= Pin
->Mask
)
2388 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
2390 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
2392 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2399 /* ---------------------------------------------------------------------------
2400 * changes the mask size of a via
2401 * returns TRUE if changed
2404 ChangeViaMaskSize (PinType
*Via
)
2408 value
= (Absolute
) ? Absolute
: Via
->Mask
+ Delta
;
2409 value
= MAX (value
, 0);
2410 if (value
!= Via
->Mask
)
2412 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
2414 r_delete_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
);
2416 SetPinBoundingBox (Via
);
2417 r_insert_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
, 0);