6 * PCB, interactive printed circuit board design
7 * Copyright (C) 1994,1995,1996, 2005 Thomas Nau
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Contact addresses for paper mail and Email:
24 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
25 * Thomas.Nau@rz.uni-ulm.de
29 /* functions used to change object properties
45 #include "crosshair.h"
62 #ifdef HAVE_LIBDMALLOC
68 /* ---------------------------------------------------------------------------
69 * some local prototypes
71 static void *ChangePinSize (ElementTypePtr
, PinTypePtr
);
72 static void *ChangePinClearSize (ElementTypePtr
, PinTypePtr
);
73 static void *ChangePinMaskSize (ElementTypePtr
, PinTypePtr
);
74 static void *ChangePadSize (ElementTypePtr
, PadTypePtr
);
75 static void *ChangePadClearSize (ElementTypePtr
, PadTypePtr
);
76 static void *ChangePadMaskSize (ElementTypePtr
, PadTypePtr
);
77 static void *ChangePin2ndSize (ElementTypePtr
, PinTypePtr
);
78 static void *ChangeElement2ndSize (ElementTypePtr
);
79 static void *ChangeViaSize (PinTypePtr
);
80 static void *ChangeVia2ndSize (PinTypePtr
);
81 static void *ChangeViaClearSize (PinTypePtr
);
82 static void *ChangeViaMaskSize (PinTypePtr
);
83 static void *ChangeLineSize (LayerTypePtr
, LineTypePtr
);
84 static void *ChangeLineClearSize (LayerTypePtr
, LineTypePtr
);
85 static void *ChangeArcSize (LayerTypePtr
, ArcTypePtr
);
86 static void *ChangeArcClearSize (LayerTypePtr
, ArcTypePtr
);
87 static void *ChangeTextSize (LayerTypePtr
, TextTypePtr
);
88 static void *ChangeElementSize (ElementTypePtr
);
89 static void *ChangeElementNameSize (ElementTypePtr
);
90 static void *ChangePinName (ElementTypePtr
, PinTypePtr
);
91 static void *ChangePadName (ElementTypePtr
, PadTypePtr
);
92 static void *ChangeViaName (PinTypePtr
);
93 static void *ChangeLineName (LayerTypePtr
, LineTypePtr
);
94 static void *ChangeElementName (ElementTypePtr
);
95 static void *ChangeTextName (LayerTypePtr
, TextTypePtr
);
96 static void *ChangeElementSquare (ElementTypePtr
);
97 static void *SetElementSquare (ElementTypePtr
);
98 static void *ClrElementSquare (ElementTypePtr
);
99 static void *ChangeElementOctagon (ElementTypePtr
);
100 static void *SetElementOctagon (ElementTypePtr
);
101 static void *ClrElementOctagon (ElementTypePtr
);
102 static void *ChangePinSquare (ElementTypePtr
, PinTypePtr
);
103 static void *SetPinSquare (ElementTypePtr
, PinTypePtr
);
104 static void *ClrPinSquare (ElementTypePtr
, PinTypePtr
);
105 static void *ChangePinOctagon (ElementTypePtr
, PinTypePtr
);
106 static void *SetPinOctagon (ElementTypePtr
, PinTypePtr
);
107 static void *ClrPinOctagon (ElementTypePtr
, PinTypePtr
);
108 static void *ChangeViaOctagon (PinTypePtr
);
109 static void *SetViaOctagon (PinTypePtr
);
110 static void *ClrViaOctagon (PinTypePtr
);
111 static void *ChangePadSquare (ElementTypePtr
, PadTypePtr
);
112 static void *SetPadSquare (ElementTypePtr
, PadTypePtr
);
113 static void *ClrPadSquare (ElementTypePtr
, PadTypePtr
);
114 static void *ChangeViaThermal (PinTypePtr
);
115 static void *ChangePinThermal (ElementTypePtr
, PinTypePtr
);
116 static void *ChangeLineJoin (LayerTypePtr
, LineTypePtr
);
117 static void *SetLineJoin (LayerTypePtr
, LineTypePtr
);
118 static void *ClrLineJoin (LayerTypePtr
, LineTypePtr
);
119 static void *ChangeArcJoin (LayerTypePtr
, ArcTypePtr
);
120 static void *SetArcJoin (LayerTypePtr
, ArcTypePtr
);
121 static void *ClrArcJoin (LayerTypePtr
, ArcTypePtr
);
122 static void *ChangeTextJoin (LayerTypePtr
, TextTypePtr
);
123 static void *SetTextJoin (LayerTypePtr
, TextTypePtr
);
124 static void *ClrTextJoin (LayerTypePtr
, TextTypePtr
);
125 static void *ChangePolyClear (LayerTypePtr
, PolygonTypePtr
);
127 /* ---------------------------------------------------------------------------
128 * some local identifiers
130 static int Delta
; /* change of size */
131 static int Absolute
; /* Absolute size */
132 static char *NewName
; /* new name */
133 static ObjectFunctionType ChangeSizeFunctions
= {
138 ChangeElementSize
, /* changes silk screen line width */
139 ChangeElementNameSize
,
147 static ObjectFunctionType Change2ndSizeFunctions
= {
152 ChangeElement2ndSize
,
161 static ObjectFunctionType ChangeThermalFunctions
= {
175 static ObjectFunctionType ChangeClearSizeFunctions
= {
189 static ObjectFunctionType ChangeNameFunctions
= {
203 static ObjectFunctionType ChangeSquareFunctions
= {
217 static ObjectFunctionType ChangeJoinFunctions
= {
231 static ObjectFunctionType ChangeOctagonFunctions
= {
236 ChangeElementOctagon
,
245 static ObjectFunctionType ChangeMaskSizeFunctions
= {
251 ChangeElementMaskSize
,
263 static ObjectFunctionType SetSquareFunctions
= {
277 static ObjectFunctionType SetJoinFunctions
= {
291 static ObjectFunctionType SetOctagonFunctions
= {
305 static ObjectFunctionType ClrSquareFunctions
= {
319 static ObjectFunctionType ClrJoinFunctions
= {
333 static ObjectFunctionType ClrOctagonFunctions
= {
348 /* ---------------------------------------------------------------------------
349 * changes the thermal on a via
350 * returns TRUE if changed
353 ChangeViaThermal (PinTypePtr Via
)
355 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, False
);
356 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
357 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
358 if (!Delta
) /* remove the thermals */
359 CLEAR_THERM (INDEXOFCURRENT
, Via
);
361 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Via
);
362 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, True
);
363 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
368 /* ---------------------------------------------------------------------------
369 * changes the thermal on a pin
370 * returns TRUE if changed
373 ChangePinThermal (ElementTypePtr element
, PinTypePtr 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
);
388 /* ---------------------------------------------------------------------------
389 * changes the size of a via
390 * returns TRUE if changed
393 ChangeViaSize (PinTypePtr Via
)
395 BDimension value
= Absolute
? Absolute
: Via
->Thickness
+ Delta
;
397 if (TEST_FLAG (LOCKFLAG
, Via
))
399 if (!TEST_FLAG (HOLEFLAG
, Via
) && value
<= MAX_PINORVIASIZE
&&
400 value
>= MIN_PINORVIASIZE
&&
401 value
>= Via
->DrillingHole
+ MIN_PINORVIACOPPER
&&
402 value
!= Via
->Thickness
)
404 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
406 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
407 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Via
, Via
);
410 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
411 Via
->Mask
+= value
- Via
->Thickness
;
413 Via
->Thickness
= value
;
414 SetPinBoundingBox (Via
);
415 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
416 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
423 /* ---------------------------------------------------------------------------
424 * changes the drilling hole of a via
425 * returns TRUE if changed
428 ChangeVia2ndSize (PinTypePtr Via
)
430 BDimension value
= (Absolute
) ? Absolute
: Via
->DrillingHole
+ Delta
;
432 if (TEST_FLAG (LOCKFLAG
, Via
))
434 if (value
<= MAX_PINORVIASIZE
&&
435 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Via
) ||
437 Via
->Thickness
- MIN_PINORVIACOPPER
)
438 && value
!= Via
->DrillingHole
)
440 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
442 Via
->DrillingHole
= value
;
443 if (TEST_FLAG (HOLEFLAG
, Via
))
445 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
446 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
447 Via
->Thickness
= value
;
448 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
457 /* ---------------------------------------------------------------------------
458 * changes the clearance size of a via
459 * returns TRUE if changed
462 ChangeViaClearSize (PinTypePtr Via
)
464 BDimension value
= (Absolute
) ? Absolute
: Via
->Clearance
+ Delta
;
466 if (TEST_FLAG (LOCKFLAG
, Via
))
468 value
= MIN (MAX_LINESIZE
, value
);
471 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
473 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
474 value
= PCB
->Bloat
* 2 + 2;
475 if (Via
->Clearance
== value
)
477 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
478 AddObjectToClearSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
480 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
481 Via
->Clearance
= value
;
482 SetPinBoundingBox (Via
);
483 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
484 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
491 /* ---------------------------------------------------------------------------
492 * changes the size of a pin
493 * returns TRUE if changed
496 ChangePinSize (ElementTypePtr Element
, PinTypePtr Pin
)
498 BDimension value
= (Absolute
) ? Absolute
: Pin
->Thickness
+ Delta
;
500 if (TEST_FLAG (LOCKFLAG
, Pin
))
502 if (!TEST_FLAG (HOLEFLAG
, Pin
) && value
<= MAX_PINORVIASIZE
&&
503 value
>= MIN_PINORVIASIZE
&&
504 value
>= Pin
->DrillingHole
+ MIN_PINORVIACOPPER
&&
505 value
!= Pin
->Thickness
)
507 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
508 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
510 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
511 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
512 Pin
->Mask
+= value
- Pin
->Thickness
;
513 Pin
->Thickness
= value
;
514 /* SetElementBB updates all associated rtrees */
515 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
516 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
523 /* ---------------------------------------------------------------------------
524 * changes the clearance size of a pin
525 * returns TRUE if changed
528 ChangePinClearSize (ElementTypePtr Element
, PinTypePtr Pin
)
530 BDimension value
= (Absolute
) ? Absolute
: Pin
->Clearance
+ Delta
;
532 if (TEST_FLAG (LOCKFLAG
, Pin
))
534 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
535 if (Pin
->Clearance
== value
)
537 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
538 AddObjectToClearSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
540 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
541 Pin
->Clearance
= value
;
542 /* SetElementBB updates all associated rtrees */
543 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
544 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
549 /* ---------------------------------------------------------------------------
550 * changes the size of a pad
551 * returns TRUE if changed
554 ChangePadSize (ElementTypePtr Element
, PadTypePtr Pad
)
556 BDimension value
= (Absolute
) ? Absolute
: Pad
->Thickness
+ Delta
;
558 if (TEST_FLAG (LOCKFLAG
, Pad
))
560 if (value
<= MAX_PADSIZE
&& value
>= MIN_PADSIZE
&& value
!= Pad
->Thickness
)
562 AddObjectToSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
563 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
564 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
566 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
567 Pad
->Mask
+= value
- Pad
->Thickness
;
568 Pad
->Thickness
= value
;
569 /* SetElementBB updates all associated rtrees */
570 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
571 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
578 /* ---------------------------------------------------------------------------
579 * changes the clearance size of a pad
580 * returns TRUE if changed
583 ChangePadClearSize (ElementTypePtr Element
, PadTypePtr Pad
)
585 BDimension value
= (Absolute
) ? Absolute
: Pad
->Clearance
+ Delta
;
587 if (TEST_FLAG (LOCKFLAG
, Pad
))
589 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
590 if (value
<= MAX_PADSIZE
&& value
>= MIN_PADSIZE
&& value
!= Pad
->Clearance
)
592 AddObjectToClearSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
593 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
595 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
596 Pad
->Clearance
= value
;
597 /* SetElementBB updates all associated rtrees */
598 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
599 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
606 /* ---------------------------------------------------------------------------
607 * changes the drilling hole of all pins of an element
608 * returns TRUE if changed
611 ChangeElement2ndSize (ElementTypePtr Element
)
613 Boolean changed
= False
;
616 if (TEST_FLAG (LOCKFLAG
, Element
))
620 value
= (Absolute
) ? Absolute
: pin
->DrillingHole
+ Delta
;
621 if (value
<= MAX_PINORVIASIZE
&&
622 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, pin
) ||
626 && value
!= pin
->DrillingHole
)
629 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
631 pin
->DrillingHole
= value
;
633 if (TEST_FLAG (HOLEFLAG
, pin
))
635 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
636 AddObjectToSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
637 pin
->Thickness
= value
;
638 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
649 /* ---------------------------------------------------------------------------
650 * changes the drilling hole of a pin
651 * returns TRUE if changed
654 ChangePin2ndSize (ElementTypePtr Element
, PinTypePtr Pin
)
656 BDimension value
= (Absolute
) ? Absolute
: Pin
->DrillingHole
+ Delta
;
658 if (TEST_FLAG (LOCKFLAG
, Pin
))
660 if (value
<= MAX_PINORVIASIZE
&&
661 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Pin
) ||
663 Pin
->Thickness
- MIN_PINORVIACOPPER
)
664 && value
!= Pin
->DrillingHole
)
666 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
668 Pin
->DrillingHole
= value
;
670 if (TEST_FLAG (HOLEFLAG
, Pin
))
672 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
673 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
674 Pin
->Thickness
= value
;
675 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
682 /* ---------------------------------------------------------------------------
683 * changes the size of a line
684 * returns TRUE if changed
687 ChangeLineSize (LayerTypePtr Layer
, LineTypePtr Line
)
689 BDimension value
= (Absolute
) ? Absolute
: Line
->Thickness
+ Delta
;
691 if (TEST_FLAG (LOCKFLAG
, Line
))
693 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
694 value
!= Line
->Thickness
)
696 AddObjectToSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
698 r_delete_entry (Layer
->line_tree
, (BoxTypePtr
) Line
);
699 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
700 Line
->Thickness
= value
;
701 SetLineBoundingBox (Line
);
702 r_insert_entry (Layer
->line_tree
, (BoxTypePtr
) Line
, 0);
703 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
704 DrawLine (Layer
, Line
, 0);
710 /* ---------------------------------------------------------------------------
711 * changes the clearance size of a line
712 * returns TRUE if changed
715 ChangeLineClearSize (LayerTypePtr Layer
, LineTypePtr Line
)
717 BDimension value
= (Absolute
) ? Absolute
: Line
->Clearance
+ Delta
;
719 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
721 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
722 if (value
!= Line
->Clearance
)
724 AddObjectToClearSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
725 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
727 r_delete_entry (Layer
->line_tree
, (BoxTypePtr
) Line
);
728 Line
->Clearance
= value
;
729 if (Line
->Clearance
== 0)
731 CLEAR_FLAG (CLEARLINEFLAG
, Line
);
732 Line
->Clearance
= 1000;
734 SetLineBoundingBox (Line
);
735 r_insert_entry (Layer
->line_tree
, (BoxTypePtr
) Line
, 0);
736 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
737 DrawLine (Layer
, Line
, 0);
743 /* ---------------------------------------------------------------------------
744 * changes the size of an arc
745 * returns TRUE if changed
748 ChangeArcSize (LayerTypePtr Layer
, ArcTypePtr Arc
)
750 BDimension value
= (Absolute
) ? Absolute
: Arc
->Thickness
+ Delta
;
752 if (TEST_FLAG (LOCKFLAG
, Arc
))
754 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
755 value
!= Arc
->Thickness
)
757 AddObjectToSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
759 r_delete_entry (Layer
->arc_tree
, (BoxTypePtr
) Arc
);
760 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
761 Arc
->Thickness
= value
;
762 SetArcBoundingBox (Arc
);
763 r_insert_entry (Layer
->arc_tree
, (BoxTypePtr
) Arc
, 0);
764 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
765 DrawArc (Layer
, Arc
, 0);
771 /* ---------------------------------------------------------------------------
772 * changes the clearance size of an arc
773 * returns TRUE if changed
776 ChangeArcClearSize (LayerTypePtr Layer
, ArcTypePtr Arc
)
778 BDimension value
= (Absolute
) ? Absolute
: Arc
->Clearance
+ Delta
;
780 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
782 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
783 if (value
!= Arc
->Clearance
)
785 AddObjectToClearSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
787 r_delete_entry (Layer
->arc_tree
, (BoxTypePtr
) Arc
);
788 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
789 Arc
->Clearance
= value
;
790 if (Arc
->Clearance
== 0)
792 CLEAR_FLAG (CLEARLINEFLAG
, Arc
);
793 Arc
->Clearance
= 1000;
795 SetArcBoundingBox (Arc
);
796 r_insert_entry (Layer
->arc_tree
, (BoxTypePtr
) Arc
, 0);
797 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
798 DrawArc (Layer
, Arc
, 0);
804 /* ---------------------------------------------------------------------------
805 * changes the scaling factor of a text object
806 * returns TRUE if changed
809 ChangeTextSize (LayerTypePtr Layer
, TextTypePtr Text
)
811 BDimension value
= (Absolute
) ? Absolute
/ 45 : Text
->Scale
+ Delta
/ 45;
813 if (TEST_FLAG (LOCKFLAG
, Text
))
815 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
&&
816 value
!= Text
->Scale
)
818 AddObjectToSizeUndoList (TEXT_TYPE
, Layer
, Text
, Text
);
819 EraseText (Layer
, Text
);
820 r_delete_entry (Layer
->text_tree
, (BoxTypePtr
) Text
);
821 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
823 SetTextBoundingBox (&PCB
->Font
, Text
);
824 r_insert_entry (Layer
->text_tree
, (BoxTypePtr
) Text
, 0);
825 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
826 DrawText (Layer
, Text
, 0);
832 /* ---------------------------------------------------------------------------
833 * changes the scaling factor of an element's outline
834 * returns TRUE if changed
837 ChangeElementSize (ElementTypePtr Element
)
840 Boolean changed
= False
;
842 if (TEST_FLAG (LOCKFLAG
, Element
))
845 EraseElement (Element
);
846 ELEMENTLINE_LOOP (Element
);
848 value
= (Absolute
) ? Absolute
: line
->Thickness
+ Delta
;
849 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
850 value
!= line
->Thickness
)
852 AddObjectToSizeUndoList (ELEMENTLINE_TYPE
, Element
, line
, line
);
853 line
->Thickness
= value
;
860 value
= (Absolute
) ? Absolute
: arc
->Thickness
+ Delta
;
861 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
862 value
!= arc
->Thickness
)
864 AddObjectToSizeUndoList (ELEMENTARC_TYPE
, Element
, arc
, arc
);
865 arc
->Thickness
= value
;
872 DrawElement (Element
, 0);
879 /* ---------------------------------------------------------------------------
880 * changes the scaling factor of a elementname object
881 * returns TRUE if changed
884 ChangeElementNameSize (ElementTypePtr Element
)
887 (Absolute
) ? Absolute
/ 45 : DESCRIPTION_TEXT (Element
).Scale
+
890 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
892 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
)
894 EraseElementName (Element
);
895 ELEMENTTEXT_LOOP (Element
);
897 AddObjectToSizeUndoList (ELEMENTNAME_TYPE
, Element
, text
, text
);
898 r_delete_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
);
900 SetTextBoundingBox (&PCB
->Font
, text
);
901 r_insert_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
, 0);
904 DrawElementName (Element
, 0);
910 /* ---------------------------------------------------------------------------
911 * changes the name of a via
914 ChangeViaName (PinTypePtr Via
)
916 char *old
= Via
->Name
;
918 if (TEST_FLAG (DISPLAYNAMEFLAG
, Via
))
922 DrawPinName (Via
, 0);
929 /* ---------------------------------------------------------------------------
930 * changes the name of a pin
933 ChangePinName (ElementTypePtr Element
, PinTypePtr Pin
)
935 char *old
= Pin
->Name
;
937 Element
= Element
; /* get rid of 'unused...' warnings */
938 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pin
))
942 DrawPinName (Pin
, 0);
949 /* ---------------------------------------------------------------------------
950 * changes the name of a pad
953 ChangePadName (ElementTypePtr Element
, PadTypePtr Pad
)
955 char *old
= Pad
->Name
;
957 Element
= Element
; /* get rid of 'unused...' warnings */
958 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pad
))
962 DrawPadName (Pad
, 0);
969 /* ---------------------------------------------------------------------------
970 * changes the name of a line
973 ChangeLineName (LayerTypePtr Layer
, LineTypePtr Line
)
975 char *old
= Line
->Number
;
978 Line
->Number
= NewName
;
982 /* ---------------------------------------------------------------------------
983 * changes the layout-name of an element
986 ChangeElementName (ElementTypePtr Element
)
988 char *old
= ELEMENT_NAME (PCB
, Element
);
990 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
992 if (NAME_INDEX (PCB
) == NAMEONPCB_INDEX
)
994 if (TEST_FLAG (UNIQUENAMEFLAG
, PCB
) &&
995 UniqueElementName (PCB
->Data
, NewName
) != NewName
)
997 Message (_("Error: The name \"%s\" is not unique!\n"), NewName
);
998 return ((char *) -1);
1001 EraseElementName (Element
);
1002 r_delete_entry (PCB
->Data
->name_tree
[NAME_INDEX (PCB
)],
1003 (BoxType
*) & ELEMENT_TEXT (PCB
, Element
));
1004 ELEMENT_NAME (PCB
, Element
) = NewName
;
1005 SetTextBoundingBox (&PCB
->Font
, &ELEMENT_TEXT (PCB
, Element
));
1006 r_insert_entry (PCB
->Data
->name_tree
[NAME_INDEX (PCB
)],
1007 (BoxType
*) & ELEMENT_TEXT (PCB
, Element
), 0);
1008 DrawElementName (Element
, 0);
1012 /* ---------------------------------------------------------------------------
1013 * sets data of a text object and calculates bounding box
1014 * memory must have already been allocated
1015 * the one for the new string is allocated
1016 * returns True if the string has been changed
1019 ChangeTextName (LayerTypePtr Layer
, TextTypePtr Text
)
1021 char *old
= Text
->TextString
;
1023 if (TEST_FLAG (LOCKFLAG
, Text
))
1025 EraseText (Layer
, Text
);
1026 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1027 Text
->TextString
= NewName
;
1029 /* calculate size of the bounding box */
1030 SetTextBoundingBox (&PCB
->Font
, Text
);
1031 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1032 DrawText (Layer
, Text
, 0);
1036 /* ---------------------------------------------------------------------------
1037 * changes the name of a layout; memory has to be already allocated
1040 ChangeLayoutName (char *Name
)
1043 hid_action ("PCBChanged");
1047 /* ---------------------------------------------------------------------------
1048 * changes the side of the board an element is on
1049 * returns TRUE if done
1052 ChangeElementSide (ElementTypePtr Element
, LocationType yoff
)
1054 if (TEST_FLAG (LOCKFLAG
, Element
))
1056 EraseElement (Element
);
1057 AddObjectToMirrorUndoList (ELEMENT_TYPE
, Element
, Element
, Element
, yoff
);
1058 MirrorElementCoordinates (PCB
->Data
, Element
, yoff
);
1059 DrawElement (Element
, 0);
1063 /* ---------------------------------------------------------------------------
1064 * changes the name of a layer; memory has to be already allocated
1067 ChangeLayerName (LayerTypePtr Layer
, char *Name
)
1069 CURRENT
->Name
= Name
;
1070 hid_action ("LayersChanged");
1074 /* ---------------------------------------------------------------------------
1075 * changes the clearance flag of a line
1078 ChangeLineJoin (LayerTypePtr Layer
, LineTypePtr Line
)
1080 if (TEST_FLAG (LOCKFLAG
, Line
))
1083 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1085 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, False
);
1086 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1088 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Line
, Line
);
1089 TOGGLE_FLAG (CLEARLINEFLAG
, Line
);
1090 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1092 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, True
);
1093 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1095 DrawLine (Layer
, Line
, 0);
1099 /* ---------------------------------------------------------------------------
1100 * sets the clearance flag of a line
1103 SetLineJoin (LayerTypePtr Layer
, LineTypePtr Line
)
1105 if (TEST_FLAG (LOCKFLAG
, Line
) || TEST_FLAG (CLEARLINEFLAG
, Line
))
1107 return ChangeLineJoin (Layer
, Line
);
1110 /* ---------------------------------------------------------------------------
1111 * clears the clearance flag of a line
1114 ClrLineJoin (LayerTypePtr Layer
, LineTypePtr Line
)
1116 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
1118 return ChangeLineJoin (Layer
, Line
);
1121 /* ---------------------------------------------------------------------------
1122 * changes the clearance flag of an arc
1125 ChangeArcJoin (LayerTypePtr Layer
, ArcTypePtr Arc
)
1127 if (TEST_FLAG (LOCKFLAG
, Arc
))
1130 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1132 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1133 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, False
);
1135 AddObjectToFlagUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
1136 TOGGLE_FLAG (CLEARLINEFLAG
, Arc
);
1137 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1139 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1140 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, True
);
1142 DrawArc (Layer
, Arc
, 0);
1146 /* ---------------------------------------------------------------------------
1147 * sets the clearance flag of an arc
1150 SetArcJoin (LayerTypePtr Layer
, ArcTypePtr Arc
)
1152 if (TEST_FLAG (LOCKFLAG
, Arc
) || TEST_FLAG (CLEARLINEFLAG
, Arc
))
1154 return ChangeArcJoin (Layer
, Arc
);
1157 /* ---------------------------------------------------------------------------
1158 * clears the clearance flag of an arc
1161 ClrArcJoin (LayerTypePtr Layer
, ArcTypePtr Arc
)
1163 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
1165 return ChangeArcJoin (Layer
, Arc
);
1168 /* ---------------------------------------------------------------------------
1169 * changes the clearance flag of a text
1172 ChangeTextJoin (LayerTypePtr Layer
, TextTypePtr Text
)
1174 if (TEST_FLAG (LOCKFLAG
, Text
))
1176 EraseText (Layer
, Text
);
1177 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1179 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, False
);
1180 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1182 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Text
, Text
);
1183 TOGGLE_FLAG (CLEARLINEFLAG
, Text
);
1184 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1186 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, True
);
1187 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1189 DrawText (Layer
, Text
, 0);
1193 /* ---------------------------------------------------------------------------
1194 * sets the clearance flag of a text
1197 SetTextJoin (LayerTypePtr Layer
, TextTypePtr Text
)
1199 if (TEST_FLAG (LOCKFLAG
, Text
) || TEST_FLAG (CLEARLINEFLAG
, Text
))
1201 return ChangeTextJoin (Layer
, Text
);
1204 /* ---------------------------------------------------------------------------
1205 * clears the clearance flag of a text
1208 ClrTextJoin (LayerTypePtr Layer
, TextTypePtr Text
)
1210 if (TEST_FLAG (LOCKFLAG
, Text
) || !TEST_FLAG (CLEARLINEFLAG
, Text
))
1212 return ChangeTextJoin (Layer
, Text
);
1215 /* ---------------------------------------------------------------------------
1216 * changes the square flag of all pins on an element
1219 ChangeElementSquare (ElementTypePtr Element
)
1223 if (TEST_FLAG (LOCKFLAG
, Element
))
1227 ans
= ChangePinSquare (Element
, pin
);
1232 ans
= ChangePadSquare (Element
, pad
);
1238 /* ---------------------------------------------------------------------------
1239 * sets the square flag of all pins on an element
1242 SetElementSquare (ElementTypePtr Element
)
1246 if (TEST_FLAG (LOCKFLAG
, Element
))
1250 ans
= SetPinSquare (Element
, pin
);
1255 ans
= SetPadSquare (Element
, pad
);
1261 /* ---------------------------------------------------------------------------
1262 * clears the square flag of all pins on an element
1265 ClrElementSquare (ElementTypePtr Element
)
1269 if (TEST_FLAG (LOCKFLAG
, Element
))
1273 ans
= ClrPinSquare (Element
, pin
);
1278 ans
= ClrPadSquare (Element
, pad
);
1284 /* ---------------------------------------------------------------------------
1285 * changes the octagon flags of all pins of an element
1288 ChangeElementOctagon (ElementTypePtr Element
)
1290 void *result
= NULL
;
1292 if (TEST_FLAG (LOCKFLAG
, Element
))
1296 ChangePinOctagon (Element
, pin
);
1303 /* ---------------------------------------------------------------------------
1304 * sets the octagon flags of all pins of an element
1307 SetElementOctagon (ElementTypePtr Element
)
1309 void *result
= NULL
;
1311 if (TEST_FLAG (LOCKFLAG
, Element
))
1315 SetPinOctagon (Element
, pin
);
1322 /* ---------------------------------------------------------------------------
1323 * clears the octagon flags of all pins of an element
1326 ClrElementOctagon (ElementTypePtr Element
)
1328 void *result
= NULL
;
1330 if (TEST_FLAG (LOCKFLAG
, Element
))
1334 ClrPinOctagon (Element
, pin
);
1341 /* ---------------------------------------------------------------------------
1342 * changes the square flag of a pad
1345 ChangePadSquare (ElementTypePtr Element
, PadTypePtr Pad
)
1347 if (TEST_FLAG (LOCKFLAG
, Pad
))
1350 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, False
);
1351 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1352 AddObjectToFlagUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
1353 TOGGLE_FLAG (SQUAREFLAG
, Pad
);
1354 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, True
);
1355 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1360 /* ---------------------------------------------------------------------------
1361 * sets the square flag of a pad
1364 SetPadSquare (ElementTypePtr Element
, PadTypePtr Pad
)
1367 if (TEST_FLAG (LOCKFLAG
, Pad
) || TEST_FLAG (SQUAREFLAG
, Pad
))
1370 return (ChangePadSquare (Element
, Pad
));
1374 /* ---------------------------------------------------------------------------
1375 * clears the square flag of a pad
1378 ClrPadSquare (ElementTypePtr Element
, PadTypePtr Pad
)
1381 if (TEST_FLAG (LOCKFLAG
, Pad
) || !TEST_FLAG (SQUAREFLAG
, Pad
))
1384 return (ChangePadSquare (Element
, Pad
));
1388 /* ---------------------------------------------------------------------------
1389 * changes the square flag of a pin
1392 ChangePinSquare (ElementTypePtr Element
, PinTypePtr Pin
)
1394 if (TEST_FLAG (LOCKFLAG
, Pin
))
1397 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, False
);
1398 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1399 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1400 TOGGLE_FLAG (SQUAREFLAG
, Pin
);
1401 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, True
);
1402 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1407 /* ---------------------------------------------------------------------------
1408 * sets the square flag of a pin
1411 SetPinSquare (ElementTypePtr Element
, PinTypePtr Pin
)
1413 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (SQUAREFLAG
, Pin
))
1416 return (ChangePinSquare (Element
, Pin
));
1419 /* ---------------------------------------------------------------------------
1420 * clears the square flag of a pin
1423 ClrPinSquare (ElementTypePtr Element
, PinTypePtr Pin
)
1425 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (SQUAREFLAG
, Pin
))
1428 return (ChangePinSquare (Element
, Pin
));
1431 /* ---------------------------------------------------------------------------
1432 * changes the octagon flag of a via
1435 ChangeViaOctagon (PinTypePtr Via
)
1437 if (TEST_FLAG (LOCKFLAG
, Via
))
1440 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, False
);
1441 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1442 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1443 TOGGLE_FLAG (OCTAGONFLAG
, Via
);
1444 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, True
);
1445 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1450 /* ---------------------------------------------------------------------------
1451 * sets the octagon flag of a via
1454 SetViaOctagon (PinTypePtr Via
)
1456 if (TEST_FLAG (LOCKFLAG
, Via
) || TEST_FLAG (OCTAGONFLAG
, Via
))
1459 return (ChangeViaOctagon (Via
));
1462 /* ---------------------------------------------------------------------------
1463 * clears the octagon flag of a via
1466 ClrViaOctagon (PinTypePtr Via
)
1468 if (TEST_FLAG (LOCKFLAG
, Via
) || !TEST_FLAG (OCTAGONFLAG
, Via
))
1471 return (ChangeViaOctagon (Via
));
1474 /* ---------------------------------------------------------------------------
1475 * changes the octagon flag of a pin
1478 ChangePinOctagon (ElementTypePtr Element
, PinTypePtr Pin
)
1480 if (TEST_FLAG (LOCKFLAG
, Pin
))
1483 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, False
);
1484 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1485 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1486 TOGGLE_FLAG (OCTAGONFLAG
, Pin
);
1487 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, True
);
1488 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1493 /* ---------------------------------------------------------------------------
1494 * sets the octagon flag of a pin
1497 SetPinOctagon (ElementTypePtr Element
, PinTypePtr Pin
)
1499 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (OCTAGONFLAG
, Pin
))
1502 return (ChangePinOctagon (Element
, Pin
));
1505 /* ---------------------------------------------------------------------------
1506 * clears the octagon flag of a pin
1509 ClrPinOctagon (ElementTypePtr Element
, PinTypePtr Pin
)
1511 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (OCTAGONFLAG
, Pin
))
1514 return (ChangePinOctagon (Element
, Pin
));
1517 /* ---------------------------------------------------------------------------
1518 * changes the hole flag of a via
1521 ChangeHole (PinTypePtr Via
)
1523 if (TEST_FLAG (LOCKFLAG
, Via
))
1526 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1527 TOGGLE_FLAG (HOLEFLAG
, Via
);
1528 if (TEST_FLAG (HOLEFLAG
, Via
))
1530 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1531 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1532 Via
->Thickness
= Via
->Mask
= Via
->DrillingHole
;
1533 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1537 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1538 Via
->DrillingHole
= Via
->Thickness
- MIN_PINORVIACOPPER
;
1545 /* ---------------------------------------------------------------------------
1546 * changes the nopaste flag of a pad
1549 ChangePaste (PadTypePtr Pad
)
1551 if (TEST_FLAG (LOCKFLAG
, Pad
))
1554 AddObjectToFlagUndoList (PAD_TYPE
, Pad
, Pad
, Pad
);
1555 TOGGLE_FLAG (NOPASTEFLAG
, Pad
);
1561 /* ---------------------------------------------------------------------------
1562 * changes the CLEARPOLY flag of a polygon
1565 ChangePolyClear (LayerTypePtr Layer
, PolygonTypePtr Polygon
)
1567 if (TEST_FLAG (LOCKFLAG
, Polygon
))
1569 AddObjectToClearPolyUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
, True
);
1570 AddObjectToFlagUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
1571 TOGGLE_FLAG (CLEARPOLYFLAG
, Polygon
);
1572 InitClip (PCB
->Data
, Layer
, Polygon
);
1573 DrawPolygon (Layer
, Polygon
, 0);
1577 /* ----------------------------------------------------------------------
1578 * changes the side of all selected and visible elements
1579 * returns True if anything has changed
1582 ChangeSelectedElementSide (void)
1584 Boolean change
= False
;
1586 /* setup identifiers */
1587 if (PCB
->PinOn
&& PCB
->ElementOn
)
1588 ELEMENT_LOOP (PCB
->Data
);
1590 if (TEST_FLAG (SELECTEDFLAG
, element
))
1592 change
|= ChangeElementSide (element
, 0);
1599 IncrementUndoSerialNumber ();
1604 /* ----------------------------------------------------------------------
1605 * changes the thermals on all selected and visible pins
1606 * and/or vias. Returns True if anything has changed
1609 ChangeSelectedThermals (int types
, int therm_style
)
1611 Boolean change
= False
;
1613 Delta
= therm_style
;
1614 change
= SelectedOperation (&ChangeThermalFunctions
, False
, types
);
1618 IncrementUndoSerialNumber ();
1623 /* ----------------------------------------------------------------------
1624 * changes the size of all selected and visible object types
1625 * returns True if anything has changed
1628 ChangeSelectedSize (int types
, LocationType Difference
, Boolean fixIt
)
1630 Boolean change
= False
;
1632 /* setup identifiers */
1633 Absolute
= (fixIt
) ? Difference
: 0;
1636 change
= SelectedOperation (&ChangeSizeFunctions
, False
, types
);
1640 IncrementUndoSerialNumber ();
1645 /* ----------------------------------------------------------------------
1646 * changes the clearance size of all selected and visible objects
1647 * returns True if anything has changed
1650 ChangeSelectedClearSize (int types
, LocationType Difference
, Boolean fixIt
)
1652 Boolean change
= False
;
1654 /* setup identifiers */
1655 Absolute
= (fixIt
) ? Difference
: 0;
1657 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1658 change
= SelectedOperation (&ChangeMaskSizeFunctions
, False
, types
);
1660 change
= SelectedOperation (&ChangeClearSizeFunctions
, False
, types
);
1664 IncrementUndoSerialNumber ();
1669 /* --------------------------------------------------------------------------
1670 * changes the 2nd size (drilling hole) of all selected and visible objects
1671 * returns True if anything has changed
1674 ChangeSelected2ndSize (int types
, LocationType Difference
, Boolean fixIt
)
1676 Boolean change
= False
;
1678 /* setup identifiers */
1679 Absolute
= (fixIt
) ? Difference
: 0;
1681 change
= SelectedOperation (&Change2ndSizeFunctions
, False
, types
);
1685 IncrementUndoSerialNumber ();
1690 /* ----------------------------------------------------------------------
1691 * changes the clearance flag (join) of all selected and visible lines
1692 * and/or arcs. Returns True if anything has changed
1695 ChangeSelectedJoin (int types
)
1697 Boolean change
= False
;
1699 change
= SelectedOperation (&ChangeJoinFunctions
, False
, types
);
1703 IncrementUndoSerialNumber ();
1708 /* ----------------------------------------------------------------------
1709 * changes the clearance flag (join) of all selected and visible lines
1710 * and/or arcs. Returns True if anything has changed
1713 SetSelectedJoin (int types
)
1715 Boolean change
= False
;
1717 change
= SelectedOperation (&SetJoinFunctions
, False
, types
);
1721 IncrementUndoSerialNumber ();
1726 /* ----------------------------------------------------------------------
1727 * changes the clearance flag (join) of all selected and visible lines
1728 * and/or arcs. Returns True if anything has changed
1731 ClrSelectedJoin (int types
)
1733 Boolean change
= False
;
1735 change
= SelectedOperation (&ClrJoinFunctions
, False
, types
);
1739 IncrementUndoSerialNumber ();
1744 /* ----------------------------------------------------------------------
1745 * changes the square-flag of all selected and visible pins or pads
1746 * returns True if anything has changed
1749 ChangeSelectedSquare (int types
)
1751 Boolean change
= False
;
1753 change
= SelectedOperation (&ChangeSquareFunctions
, False
, types
);
1757 IncrementUndoSerialNumber ();
1762 /* ----------------------------------------------------------------------
1763 * sets the square-flag of all selected and visible pins or pads
1764 * returns True if anything has changed
1767 SetSelectedSquare (int types
)
1769 Boolean change
= False
;
1771 change
= SelectedOperation (&SetSquareFunctions
, False
, types
);
1775 IncrementUndoSerialNumber ();
1780 /* ----------------------------------------------------------------------
1781 * clears the square-flag of all selected and visible pins or pads
1782 * returns True if anything has changed
1785 ClrSelectedSquare (int types
)
1787 Boolean change
= False
;
1789 change
= SelectedOperation (&ClrSquareFunctions
, False
, types
);
1793 IncrementUndoSerialNumber ();
1798 /* ----------------------------------------------------------------------
1799 * changes the octagon-flag of all selected and visible pins and vias
1800 * returns True if anything has changed
1803 ChangeSelectedOctagon (int types
)
1805 Boolean change
= False
;
1807 change
= SelectedOperation (&ChangeOctagonFunctions
, False
, types
);
1811 IncrementUndoSerialNumber ();
1816 /* ----------------------------------------------------------------------
1817 * sets the octagon-flag of all selected and visible pins and vias
1818 * returns True if anything has changed
1821 SetSelectedOctagon (int types
)
1823 Boolean change
= False
;
1825 change
= SelectedOperation (&SetOctagonFunctions
, False
, types
);
1829 IncrementUndoSerialNumber ();
1834 /* ----------------------------------------------------------------------
1835 * clears the octagon-flag of all selected and visible pins and vias
1836 * returns True if anything has changed
1839 ClrSelectedOctagon (int types
)
1841 Boolean change
= False
;
1843 change
= SelectedOperation (&ClrOctagonFunctions
, False
, types
);
1847 IncrementUndoSerialNumber ();
1852 /* ----------------------------------------------------------------------
1853 * changes the hole-flag of all selected and visible vias
1854 * returns True if anything has changed
1857 ChangeSelectedHole (void)
1859 Boolean change
= False
;
1862 VIA_LOOP (PCB
->Data
);
1864 if (TEST_FLAG (SELECTEDFLAG
, via
))
1865 change
|= ChangeHole (via
);
1871 IncrementUndoSerialNumber ();
1876 /* ----------------------------------------------------------------------
1877 * changes the no paste-flag of all selected and visible pads
1878 * returns True if anything has changed
1881 ChangeSelectedPaste (void)
1883 Boolean change
= False
;
1885 ALLPAD_LOOP (PCB
->Data
);
1887 if (TEST_FLAG (SELECTEDFLAG
, pad
))
1888 change
|= ChangePaste (pad
);
1894 IncrementUndoSerialNumber ();
1900 /* ---------------------------------------------------------------------------
1901 * changes the size of the passed object
1902 * Returns True if anything is changed
1905 ChangeObjectSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1906 LocationType Difference
, Boolean fixIt
)
1910 /* setup identifier */
1911 Absolute
= (fixIt
) ? Difference
: 0;
1914 (ObjectOperation (&ChangeSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
);
1918 IncrementUndoSerialNumber ();
1923 /* ---------------------------------------------------------------------------
1924 * changes the clearance size of the passed object
1925 * Returns True if anything is changed
1928 ChangeObjectClearSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1929 LocationType Difference
, Boolean fixIt
)
1933 /* setup identifier */
1934 Absolute
= (fixIt
) ? Difference
: 0;
1936 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1938 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
1942 (ObjectOperation (&ChangeClearSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
1947 IncrementUndoSerialNumber ();
1952 /* ---------------------------------------------------------------------------
1953 * changes the thermal of the passed object
1954 * Returns True if anything is changed
1958 ChangeObjectThermal (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1963 Delta
= Absolute
= therm_type
;
1965 (ObjectOperation (&ChangeThermalFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
1970 IncrementUndoSerialNumber ();
1975 /* ---------------------------------------------------------------------------
1976 * changes the 2nd size of the passed object
1977 * Returns True if anything is changed
1980 ChangeObject2ndSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1981 LocationType Difference
, Boolean fixIt
, Boolean incundo
)
1985 /* setup identifier */
1986 Absolute
= (fixIt
) ? Difference
: 0;
1989 (ObjectOperation (&Change2ndSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
1995 IncrementUndoSerialNumber ();
2000 /* ---------------------------------------------------------------------------
2001 * changes the mask size of the passed object
2002 * Returns True if anything is changed
2005 ChangeObjectMaskSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2006 LocationType Difference
, Boolean fixIt
)
2010 /* setup identifier */
2011 Absolute
= (fixIt
) ? Difference
: 0;
2014 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2019 IncrementUndoSerialNumber ();
2024 /* ---------------------------------------------------------------------------
2025 * changes the name of the passed object
2026 * returns the old name
2028 * The allocated memory isn't freed because the old string is used
2029 * by the undo module.
2032 ChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
, char *Name
)
2035 /* setup identifier */
2038 ObjectOperation (&ChangeNameFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
)));
2043 /* ---------------------------------------------------------------------------
2044 * changes the clearance-flag of the passed object
2045 * Returns True if anything is changed
2048 ChangeObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2050 if (ObjectOperation (&ChangeJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2053 IncrementUndoSerialNumber ();
2059 /* ---------------------------------------------------------------------------
2060 * sets the clearance-flag of the passed object
2061 * Returns True if anything is changed
2064 SetObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2066 if (ObjectOperation (&SetJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2069 IncrementUndoSerialNumber ();
2075 /* ---------------------------------------------------------------------------
2076 * clears the clearance-flag of the passed object
2077 * Returns True if anything is changed
2080 ClrObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2082 if (ObjectOperation (&ClrJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2085 IncrementUndoSerialNumber ();
2091 /* ---------------------------------------------------------------------------
2092 * changes the square-flag of the passed object
2093 * Returns True if anything is changed
2096 ChangeObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2098 if (ObjectOperation (&ChangeSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2102 IncrementUndoSerialNumber ();
2108 /* ---------------------------------------------------------------------------
2109 * sets the square-flag of the passed object
2110 * Returns True if anything is changed
2113 SetObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2115 if (ObjectOperation (&SetSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2118 IncrementUndoSerialNumber ();
2124 /* ---------------------------------------------------------------------------
2125 * clears the square-flag of the passed object
2126 * Returns True if anything is changed
2129 ClrObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2131 if (ObjectOperation (&ClrSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2134 IncrementUndoSerialNumber ();
2140 /* ---------------------------------------------------------------------------
2141 * changes the octagon-flag of the passed object
2142 * Returns True if anything is changed
2145 ChangeObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2147 if (ObjectOperation (&ChangeOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2151 IncrementUndoSerialNumber ();
2157 /* ---------------------------------------------------------------------------
2158 * sets the octagon-flag of the passed object
2159 * Returns True if anything is changed
2162 SetObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2164 if (ObjectOperation (&SetOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2167 IncrementUndoSerialNumber ();
2173 /* ---------------------------------------------------------------------------
2174 * clears the octagon-flag of the passed object
2175 * Returns True if anything is changed
2178 ClrObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2180 if (ObjectOperation (&ClrOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2183 IncrementUndoSerialNumber ();
2189 /* ---------------------------------------------------------------------------
2190 * queries the user for a new object name and changes it
2192 * The allocated memory isn't freed because the old string is used
2193 * by the undo module.
2196 QueryInputAndChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2201 /* if passed an element name, make it an element reference instead */
2202 if (Type
== ELEMENTNAME_TYPE
)
2204 Type
= ELEMENT_TYPE
;
2211 name
= gui
->prompt_for (_("Linename:"),
2212 EMPTY (((LineTypePtr
) Ptr2
)->Number
));
2216 name
= gui
->prompt_for (_("Vianame:"),
2217 EMPTY (((PinTypePtr
) Ptr2
)->Name
));
2221 sprintf (msg
, _("%s Pin Name:"), EMPTY (((PinTypePtr
) Ptr2
)->Number
));
2222 name
= gui
->prompt_for (msg
, EMPTY (((PinTypePtr
) Ptr2
)->Name
));
2226 sprintf (msg
, _("%s Pad Name:"), EMPTY (((PadTypePtr
) Ptr2
)->Number
));
2227 name
= gui
->prompt_for (msg
, EMPTY (((PadTypePtr
) Ptr2
)->Name
));
2231 name
= gui
->prompt_for (_("Enter text:"),
2232 EMPTY (((TextTypePtr
) Ptr2
)->TextString
));
2236 name
= gui
->prompt_for (_("Elementname:"),
2238 (PCB
, (ElementTypePtr
) Ptr2
)));
2243 /* XXX Memory leak!! */
2244 char *old
= ChangeObjectName (Type
, Ptr1
, Ptr2
, Ptr3
, name
);
2245 if (old
!= (char *) -1)
2247 AddObjectToChangeNameUndoList (Type
, Ptr1
, Ptr2
, Ptr3
, old
);
2248 IncrementUndoSerialNumber ();
2256 /* ---------------------------------------------------------------------------
2257 * changes the maximum size of a layout
2258 * adjusts the scrollbars
2259 * releases the saved pixmap if necessary
2260 * and adjusts the cursor confinement box
2263 ChangePCBSize (BDimension Width
, BDimension Height
)
2265 PCB
->MaxWidth
= Width
;
2266 PCB
->MaxHeight
= Height
;
2268 /* crosshair range is different if pastebuffer-mode
2271 if (Settings
.Mode
== PASTEBUFFER_MODE
)
2272 SetCrosshairRange (PASTEBUFFER
->X
- PASTEBUFFER
->BoundingBox
.X1
,
2273 PASTEBUFFER
->Y
- PASTEBUFFER
->BoundingBox
.Y1
,
2275 Width
- (PASTEBUFFER
->BoundingBox
.X2
-
2276 PASTEBUFFER
->X
)), MAX (0,
2283 SetCrosshairRange (0, 0, (LocationType
) Width
, (LocationType
) Height
);
2284 hid_action ("PCBChanged");
2287 /* ---------------------------------------------------------------------------
2288 * changes the mask size of a pad
2289 * returns TRUE if changed
2292 ChangePadMaskSize (ElementTypePtr Element
, PadTypePtr Pad
)
2294 BDimension value
= (Absolute
) ? Absolute
: Pad
->Mask
+ Delta
;
2296 value
= MAX (value
, 0);
2297 if (value
== Pad
->Mask
&& Absolute
== 0)
2298 value
= Pad
->Thickness
;
2299 if (value
!= Pad
->Mask
)
2301 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
2303 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
2305 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2312 /* ---------------------------------------------------------------------------
2313 * changes the mask size of a pin
2314 * returns TRUE if changed
2317 ChangePinMaskSize (ElementTypePtr Element
, PinTypePtr Pin
)
2319 BDimension value
= (Absolute
) ? Absolute
: Pin
->Mask
+ Delta
;
2321 value
= MAX (value
, 0);
2322 if (value
== Pin
->Mask
&& Absolute
== 0)
2323 value
= Pin
->Thickness
;
2324 if (value
!= Pin
->Mask
)
2326 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
2328 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
2330 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2337 /* ---------------------------------------------------------------------------
2338 * changes the mask size of a via
2339 * returns TRUE if changed
2342 ChangeViaMaskSize (PinTypePtr Via
)
2346 value
= (Absolute
) ? Absolute
: Via
->Mask
+ Delta
;
2347 value
= MAX (value
, 0);
2348 if (value
!= Via
->Mask
)
2350 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
2352 r_delete_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
);
2354 SetPinBoundingBox (Via
);
2355 r_insert_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
, 0);