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
43 #include "crosshair.h"
60 #ifdef HAVE_LIBDMALLOC
64 /* ---------------------------------------------------------------------------
65 * some local prototypes
67 static void *ChangePinSize (ElementType
*, PinType
*);
68 static void *ChangePinClearSize (ElementType
*, PinType
*);
69 static void *ChangePinMaskSize (ElementType
*, PinType
*);
70 static void *ChangePadSize (ElementType
*, PadType
*);
71 static void *ChangePadClearSize (ElementType
*, PadType
*);
72 static void *ChangePadMaskSize (ElementType
*, PadType
*);
73 static void *ChangePin2ndSize (ElementType
*, PinType
*);
74 static void *ChangeElement2ndSize (ElementType
*);
75 static void *ChangeViaSize (PinType
*);
76 static void *ChangeVia2ndSize (PinType
*);
77 static void *ChangeViaClearSize (PinType
*);
78 static void *ChangeViaMaskSize (PinType
*);
79 static void *ChangeLineSize (LayerType
*, LineType
*);
80 static void *ChangeLineClearSize (LayerType
*, LineType
*);
81 static void *ChangePolygonClearSize (LayerType
*, PolygonType
*);
82 static void *ChangeArcSize (LayerType
*, ArcType
*);
83 static void *ChangeArcClearSize (LayerType
*, ArcType
*);
84 static void *ChangeTextSize (LayerType
*, TextType
*);
85 static void *ChangeElementSize (ElementType
*);
86 static void *ChangeElementNameSize (ElementType
*);
87 static void *ChangePinName (ElementType
*, PinType
*);
88 static void *ChangePadName (ElementType
*, PadType
*);
89 static void *ChangeViaName (PinType
*);
90 static void *ChangeLineName (LayerType
*, LineType
*);
91 static void *ChangeElementName (ElementType
*);
92 static void *ChangeTextName (LayerType
*, TextType
*);
93 static void *ChangeElementSquare (ElementType
*);
94 static void *SetElementSquare (ElementType
*);
95 static void *ClrElementSquare (ElementType
*);
96 static void *ChangeElementOctagon (ElementType
*);
97 static void *SetElementOctagon (ElementType
*);
98 static void *ClrElementOctagon (ElementType
*);
99 static void *ChangePinSquare (ElementType
*, PinType
*);
100 static void *SetPinSquare (ElementType
*, PinType
*);
101 static void *ClrPinSquare (ElementType
*, PinType
*);
102 static void *ChangePinOctagon (ElementType
*, PinType
*);
103 static void *SetPinOctagon (ElementType
*, PinType
*);
104 static void *ClrPinOctagon (ElementType
*, PinType
*);
105 static void *ChangeViaOctagon (PinType
*);
106 static void *SetViaOctagon (PinType
*);
107 static void *ClrViaOctagon (PinType
*);
108 static void *ChangePadSquare (ElementType
*, PadType
*);
109 static void *SetPadSquare (ElementType
*, PadType
*);
110 static void *ClrPadSquare (ElementType
*, PadType
*);
111 static void *ChangeViaThermal (PinType
*);
112 static void *ChangePinThermal (ElementType
*, PinType
*);
113 static void *ChangeLineJoin (LayerType
*, LineType
*);
114 static void *SetLineJoin (LayerType
*, LineType
*);
115 static void *ClrLineJoin (LayerType
*, LineType
*);
116 static void *ChangeArcJoin (LayerType
*, ArcType
*);
117 static void *SetArcJoin (LayerType
*, ArcType
*);
118 static void *ClrArcJoin (LayerType
*, ArcType
*);
119 static void *ChangeTextJoin (LayerType
*, TextType
*);
120 static void *SetTextJoin (LayerType
*, TextType
*);
121 static void *ClrTextJoin (LayerType
*, TextType
*);
122 static void *ChangePolyClear (LayerType
*, PolygonType
*);
124 /* ---------------------------------------------------------------------------
125 * some local identifiers
127 static int Delta
; /* change of size */
128 static int Absolute
; /* Absolute size */
129 static char *NewName
; /* new name */
130 static ObjectFunctionType ChangeSizeFunctions
= {
135 ChangeElementSize
, /* changes silk screen line width */
136 ChangeElementNameSize
,
144 static ObjectFunctionType Change2ndSizeFunctions
= {
149 ChangeElement2ndSize
,
158 static ObjectFunctionType ChangeThermalFunctions
= {
172 static ObjectFunctionType ChangeClearSizeFunctions
= {
175 ChangePolygonClearSize
, /* just to tell the user not to :-) */
186 static ObjectFunctionType ChangeNameFunctions
= {
200 static ObjectFunctionType ChangeSquareFunctions
= {
214 static ObjectFunctionType ChangeJoinFunctions
= {
228 static ObjectFunctionType ChangeOctagonFunctions
= {
233 ChangeElementOctagon
,
242 static ObjectFunctionType ChangeMaskSizeFunctions
= {
248 ChangeElementMaskSize
,
260 static ObjectFunctionType SetSquareFunctions
= {
274 static ObjectFunctionType SetJoinFunctions
= {
288 static ObjectFunctionType SetOctagonFunctions
= {
302 static ObjectFunctionType ClrSquareFunctions
= {
316 static ObjectFunctionType ClrJoinFunctions
= {
330 static ObjectFunctionType ClrOctagonFunctions
= {
345 /* ---------------------------------------------------------------------------
346 * changes the thermal on a via
347 * returns TRUE if changed
350 ChangeViaThermal (PinType
*Via
)
352 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
353 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
354 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
355 if (!Delta
) /* remove the thermals */
356 CLEAR_THERM (INDEXOFCURRENT
, Via
);
358 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Via
);
359 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
360 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Via
);
365 /* ---------------------------------------------------------------------------
366 * changes the thermal on a pin
367 * returns TRUE if changed
370 ChangePinThermal (ElementType
*element
, PinType
*Pin
)
372 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, false);
373 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
374 AddObjectToFlagUndoList (PIN_TYPE
, element
, Pin
, Pin
);
375 if (!Delta
) /* remove the thermals */
376 CLEAR_THERM (INDEXOFCURRENT
, Pin
);
378 ASSIGN_THERM (INDEXOFCURRENT
, Delta
, Pin
);
379 AddObjectToClearPolyUndoList (PIN_TYPE
, element
, Pin
, Pin
, true);
380 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, CURRENT
, Pin
);
385 /* ---------------------------------------------------------------------------
386 * changes the size of a via
387 * returns TRUE if changed
390 ChangeViaSize (PinType
*Via
)
392 Coord value
= Absolute
? Absolute
: Via
->Thickness
+ Delta
;
394 if (TEST_FLAG (LOCKFLAG
, Via
))
396 if (!TEST_FLAG (HOLEFLAG
, Via
) && value
<= MAX_PINORVIASIZE
&&
397 value
>= MIN_PINORVIASIZE
&&
398 value
>= Via
->DrillingHole
+ MIN_PINORVIACOPPER
&&
399 value
!= Via
->Thickness
)
401 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
403 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
404 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Via
, Via
);
407 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
408 Via
->Mask
+= value
- Via
->Thickness
;
410 Via
->Thickness
= value
;
411 SetPinBoundingBox (Via
);
412 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
413 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
420 /* ---------------------------------------------------------------------------
421 * changes the drilling hole of a via
422 * returns TRUE if changed
425 ChangeVia2ndSize (PinType
*Via
)
427 Coord value
= (Absolute
) ? Absolute
: Via
->DrillingHole
+ Delta
;
429 if (TEST_FLAG (LOCKFLAG
, Via
))
431 if (value
<= MAX_PINORVIASIZE
&&
432 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Via
) ||
434 Via
->Thickness
- MIN_PINORVIACOPPER
)
435 && value
!= Via
->DrillingHole
)
437 AddObjectTo2ndSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
439 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
440 Via
->DrillingHole
= value
;
441 if (TEST_FLAG (HOLEFLAG
, Via
))
443 AddObjectToSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
444 Via
->Thickness
= value
;
446 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
453 /* ---------------------------------------------------------------------------
454 * changes the clearance size of a via
455 * returns TRUE if changed
458 ChangeViaClearSize (PinType
*Via
)
460 Coord value
= (Absolute
) ? Absolute
: Via
->Clearance
+ Delta
;
462 if (TEST_FLAG (LOCKFLAG
, Via
))
464 value
= MIN (MAX_LINESIZE
, value
);
467 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
469 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
470 value
= PCB
->Bloat
* 2 + 2;
471 if (Via
->Clearance
== value
)
473 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
474 AddObjectToClearSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
476 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
477 Via
->Clearance
= value
;
478 SetPinBoundingBox (Via
);
479 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
480 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
487 /* ---------------------------------------------------------------------------
488 * changes the size of a pin
489 * returns TRUE if changed
492 ChangePinSize (ElementType
*Element
, PinType
*Pin
)
494 Coord value
= (Absolute
) ? Absolute
: Pin
->Thickness
+ Delta
;
496 if (TEST_FLAG (LOCKFLAG
, Pin
))
498 if (!TEST_FLAG (HOLEFLAG
, Pin
) && value
<= MAX_PINORVIASIZE
&&
499 value
>= MIN_PINORVIASIZE
&&
500 value
>= Pin
->DrillingHole
+ MIN_PINORVIACOPPER
&&
501 value
!= Pin
->Thickness
)
503 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
504 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
506 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
507 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
508 Pin
->Mask
+= value
- Pin
->Thickness
;
509 Pin
->Thickness
= value
;
510 /* SetElementBB updates all associated rtrees */
511 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
512 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
519 /* ---------------------------------------------------------------------------
520 * changes the clearance size of a pin
521 * returns TRUE if changed
524 ChangePinClearSize (ElementType
*Element
, PinType
*Pin
)
526 Coord value
= (Absolute
) ? Absolute
: Pin
->Clearance
+ Delta
;
528 if (TEST_FLAG (LOCKFLAG
, Pin
))
530 value
= MIN (MAX_LINESIZE
, value
);
533 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
535 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
536 value
= PCB
->Bloat
* 2 + 2;
537 if (Pin
->Clearance
== value
)
539 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
540 AddObjectToClearSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
542 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
543 Pin
->Clearance
= value
;
544 /* SetElementBB updates all associated rtrees */
545 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
546 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
551 /* ---------------------------------------------------------------------------
552 * changes the size of a pad
553 * returns TRUE if changed
556 ChangePadSize (ElementType
*Element
, PadType
*Pad
)
558 Coord value
= (Absolute
) ? Absolute
: Pad
->Thickness
+ Delta
;
560 if (TEST_FLAG (LOCKFLAG
, Pad
))
562 if (value
<= MAX_PADSIZE
&& value
>= MIN_PADSIZE
&& value
!= Pad
->Thickness
)
564 AddObjectToSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
565 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
566 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
568 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
569 Pad
->Mask
+= value
- Pad
->Thickness
;
570 Pad
->Thickness
= value
;
571 /* SetElementBB updates all associated rtrees */
572 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
573 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
580 /* ---------------------------------------------------------------------------
581 * changes the clearance size of a pad
582 * returns TRUE if changed
585 ChangePadClearSize (ElementType
*Element
, PadType
*Pad
)
587 Coord value
= (Absolute
) ? Absolute
: Pad
->Clearance
+ Delta
;
589 if (TEST_FLAG (LOCKFLAG
, Pad
))
591 value
= MIN (MAX_LINESIZE
, value
);
594 if (Delta
< 0 && value
< PCB
->Bloat
* 2)
596 if ((Delta
> 0 || Absolute
) && value
< PCB
->Bloat
* 2)
597 value
= PCB
->Bloat
* 2 + 2;
598 if (value
== Pad
->Clearance
)
600 AddObjectToClearSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
601 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
603 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
604 Pad
->Clearance
= value
;
605 /* SetElementBB updates all associated rtrees */
606 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
607 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
612 /* ---------------------------------------------------------------------------
613 * changes the drilling hole of all pins of an element
614 * returns TRUE if changed
617 ChangeElement2ndSize (ElementType
*Element
)
619 bool changed
= false;
622 if (TEST_FLAG (LOCKFLAG
, Element
))
626 value
= (Absolute
) ? Absolute
: pin
->DrillingHole
+ Delta
;
627 if (value
<= MAX_PINORVIASIZE
&&
628 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, pin
) ||
632 && value
!= pin
->DrillingHole
)
635 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
637 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
638 pin
->DrillingHole
= value
;
639 if (TEST_FLAG (HOLEFLAG
, pin
))
641 AddObjectToSizeUndoList (PIN_TYPE
, Element
, pin
, pin
);
642 pin
->Thickness
= value
;
644 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, pin
);
655 /* ---------------------------------------------------------------------------
656 * changes the drilling hole of a pin
657 * returns TRUE if changed
660 ChangePin2ndSize (ElementType
*Element
, PinType
*Pin
)
662 Coord value
= (Absolute
) ? Absolute
: Pin
->DrillingHole
+ Delta
;
664 if (TEST_FLAG (LOCKFLAG
, Pin
))
666 if (value
<= MAX_PINORVIASIZE
&&
667 value
>= MIN_PINORVIAHOLE
&& (TEST_FLAG (HOLEFLAG
, Pin
) ||
669 Pin
->Thickness
- MIN_PINORVIACOPPER
)
670 && value
!= Pin
->DrillingHole
)
672 AddObjectTo2ndSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
674 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
675 Pin
->DrillingHole
= value
;
676 if (TEST_FLAG (HOLEFLAG
, Pin
))
678 AddObjectToSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
679 Pin
->Thickness
= value
;
681 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
688 /* ---------------------------------------------------------------------------
689 * changes the size of a line
690 * returns TRUE if changed
693 ChangeLineSize (LayerType
*Layer
, LineType
*Line
)
695 Coord value
= (Absolute
) ? Absolute
: Line
->Thickness
+ Delta
;
697 if (TEST_FLAG (LOCKFLAG
, Line
))
699 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
700 value
!= Line
->Thickness
)
702 AddObjectToSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
704 r_delete_entry (Layer
->line_tree
, (BoxType
*) Line
);
705 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
706 Line
->Thickness
= value
;
707 SetLineBoundingBox (Line
);
708 r_insert_entry (Layer
->line_tree
, (BoxType
*) Line
, 0);
709 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
710 DrawLine (Layer
, Line
);
716 /* ---------------------------------------------------------------------------
717 * changes the clearance size of a line
718 * returns TRUE if changed
721 ChangeLineClearSize (LayerType
*Layer
, LineType
*Line
)
723 Coord value
= (Absolute
) ? Absolute
: Line
->Clearance
+ Delta
;
725 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
727 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
728 if (value
!= Line
->Clearance
)
730 AddObjectToClearSizeUndoList (LINE_TYPE
, Layer
, Line
, Line
);
731 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
733 r_delete_entry (Layer
->line_tree
, (BoxType
*) Line
);
734 Line
->Clearance
= value
;
735 if (Line
->Clearance
== 0)
737 CLEAR_FLAG (CLEARLINEFLAG
, Line
);
738 Line
->Clearance
= MIL_TO_COORD(10);
740 SetLineBoundingBox (Line
);
741 r_insert_entry (Layer
->line_tree
, (BoxType
*) Line
, 0);
742 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
743 DrawLine (Layer
, Line
);
749 /* ---------------------------------------------------------------------------
750 * Handle attepts to change the clearance of a polygon.
753 ChangePolygonClearSize (LayerType
*Layer
, PolygonType
*poly
)
755 static int shown_this_message
= 0;
756 if (!shown_this_message
)
758 gui
->confirm_dialog (_("To change the clearance of objects in a polygon, "
759 "change the objects, not the polygon.\n"
760 "Hint: To set a minimum clearance for a group of objects, "
761 "select them all then :MinClearGap(Selected,=10,mil)"),
763 shown_this_message
= 1;
769 /* ---------------------------------------------------------------------------
770 * changes the size of an arc
771 * returns TRUE if changed
774 ChangeArcSize (LayerType
*Layer
, ArcType
*Arc
)
776 Coord value
= (Absolute
) ? Absolute
: Arc
->Thickness
+ Delta
;
778 if (TEST_FLAG (LOCKFLAG
, Arc
))
780 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
781 value
!= Arc
->Thickness
)
783 AddObjectToSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
785 r_delete_entry (Layer
->arc_tree
, (BoxType
*) Arc
);
786 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
787 Arc
->Thickness
= value
;
788 SetArcBoundingBox (Arc
);
789 r_insert_entry (Layer
->arc_tree
, (BoxType
*) Arc
, 0);
790 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
791 DrawArc (Layer
, Arc
);
797 /* ---------------------------------------------------------------------------
798 * changes the clearance size of an arc
799 * returns TRUE if changed
802 ChangeArcClearSize (LayerType
*Layer
, ArcType
*Arc
)
804 Coord value
= (Absolute
) ? Absolute
: Arc
->Clearance
+ Delta
;
806 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
808 value
= MIN (MAX_LINESIZE
, MAX (value
, PCB
->Bloat
* 2 + 2));
809 if (value
!= Arc
->Clearance
)
811 AddObjectToClearSizeUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
813 r_delete_entry (Layer
->arc_tree
, (BoxType
*) Arc
);
814 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
815 Arc
->Clearance
= value
;
816 if (Arc
->Clearance
== 0)
818 CLEAR_FLAG (CLEARLINEFLAG
, Arc
);
819 Arc
->Clearance
= MIL_TO_COORD(10);
821 SetArcBoundingBox (Arc
);
822 r_insert_entry (Layer
->arc_tree
, (BoxType
*) Arc
, 0);
823 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
824 DrawArc (Layer
, Arc
);
830 /* ---------------------------------------------------------------------------
831 * changes the scaling factor of a text object
832 * returns TRUE if changed
835 ChangeTextSize (LayerType
*Layer
, TextType
*Text
)
837 int value
= (Absolute
!= 0 ? 0 : Text
->Scale
) +
838 (double)(Absolute
!= 0 ? Absolute
: Delta
)
839 / (double)FONT_CAPHEIGHT
* 100.;
841 if (TEST_FLAG (LOCKFLAG
, Text
))
843 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
&&
844 value
!= Text
->Scale
)
846 AddObjectToSizeUndoList (TEXT_TYPE
, Layer
, Text
, Text
);
847 EraseText (Layer
, Text
);
848 r_delete_entry (Layer
->text_tree
, (BoxType
*) Text
);
849 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
851 SetTextBoundingBox (&PCB
->Font
, Text
);
852 r_insert_entry (Layer
->text_tree
, (BoxType
*) Text
, 0);
853 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
854 DrawText (Layer
, Text
);
860 /* ---------------------------------------------------------------------------
861 * changes the scaling factor of an element's outline
862 * returns TRUE if changed
865 ChangeElementSize (ElementType
*Element
)
868 bool changed
= false;
870 if (TEST_FLAG (LOCKFLAG
, Element
))
873 EraseElement (Element
);
874 ELEMENTLINE_LOOP (Element
);
876 value
= (Absolute
) ? Absolute
: line
->Thickness
+ Delta
;
877 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
878 value
!= line
->Thickness
)
880 AddObjectToSizeUndoList (ELEMENTLINE_TYPE
, Element
, line
, line
);
881 line
->Thickness
= value
;
888 value
= (Absolute
) ? Absolute
: arc
->Thickness
+ Delta
;
889 if (value
<= MAX_LINESIZE
&& value
>= MIN_LINESIZE
&&
890 value
!= arc
->Thickness
)
892 AddObjectToSizeUndoList (ELEMENTARC_TYPE
, Element
, arc
, arc
);
893 arc
->Thickness
= value
;
900 DrawElement (Element
);
907 /* ---------------------------------------------------------------------------
908 * changes the scaling factor of a elementname object
909 * returns TRUE if changed
912 ChangeElementNameSize (ElementType
*Element
)
914 int value
= (Absolute
!= 0 ? 0 : DESCRIPTION_TEXT (Element
).Scale
) +
915 (double)(Absolute
!= 0 ? Absolute
: Delta
)
916 / (double)FONT_CAPHEIGHT
* 100.;
918 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
920 if (value
<= MAX_TEXTSCALE
&& value
>= MIN_TEXTSCALE
)
922 EraseElementName (Element
);
923 ELEMENTTEXT_LOOP (Element
);
925 AddObjectToSizeUndoList (ELEMENTNAME_TYPE
, Element
, text
, text
);
926 r_delete_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
);
928 SetTextBoundingBox (&PCB
->Font
, text
);
929 r_insert_entry (PCB
->Data
->name_tree
[n
], (BoxType
*) text
, 0);
932 DrawElementName (Element
);
938 /* ---------------------------------------------------------------------------
939 * changes the name of a via
942 ChangeViaName (PinType
*Via
)
944 char *old
= Via
->Name
;
946 if (TEST_FLAG (DISPLAYNAMEFLAG
, Via
))
957 /* ---------------------------------------------------------------------------
958 * changes the name of a pin
961 ChangePinName (ElementType
*Element
, PinType
*Pin
)
963 char *old
= Pin
->Name
;
965 (void) Element
; /* get rid of 'unused...' warnings */
966 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pin
))
977 /* ---------------------------------------------------------------------------
978 * changes the name of a pad
981 ChangePadName (ElementType
*Element
, PadType
*Pad
)
983 char *old
= Pad
->Name
;
985 (void) Element
; /* get rid of 'unused...' warnings */
986 if (TEST_FLAG (DISPLAYNAMEFLAG
, Pad
))
997 /* ---------------------------------------------------------------------------
998 * changes the name of a line
1001 ChangeLineName (LayerType
*Layer
, LineType
*Line
)
1003 char *old
= Line
->Number
;
1006 Line
->Number
= NewName
;
1010 /* ---------------------------------------------------------------------------
1011 * changes the layout-name of an element
1015 ChangeElementText (PCBType
*pcb
, DataType
*data
, ElementType
*Element
, int which
, char *new_name
)
1017 char *old
= Element
->Name
[which
].TextString
;
1020 printf("In ChangeElementText, updating old TextString %s to %s\n", old
, new_name
);
1023 if (pcb
&& which
== NAME_INDEX (pcb
))
1024 EraseElementName (Element
);
1026 r_delete_entry (data
->name_tree
[which
],
1027 & Element
->Name
[which
].BoundingBox
);
1029 Element
->Name
[which
].TextString
= new_name
;
1030 SetTextBoundingBox (&PCB
->Font
, &Element
->Name
[which
]);
1032 r_insert_entry (data
->name_tree
[which
],
1033 & Element
->Name
[which
].BoundingBox
, 0);
1035 if (pcb
&& which
== NAME_INDEX (pcb
))
1036 DrawElementName (Element
);
1042 ChangeElementName (ElementType
*Element
)
1044 if (TEST_FLAG (LOCKFLAG
, &Element
->Name
[0]))
1046 if (NAME_INDEX (PCB
) == NAMEONPCB_INDEX
)
1048 if (TEST_FLAG (UNIQUENAMEFLAG
, PCB
) &&
1049 UniqueElementName (PCB
->Data
, NewName
) != NewName
)
1051 Message (_("Error: The name \"%s\" is not unique!\n"), NewName
);
1052 return ((char *) -1);
1056 return ChangeElementText (PCB
, PCB
->Data
, Element
, NAME_INDEX (PCB
), NewName
);
1059 /* ---------------------------------------------------------------------------
1060 * sets data of a text object and calculates bounding box
1061 * memory must have already been allocated
1062 * the one for the new string is allocated
1063 * returns true if the string has been changed
1066 ChangeTextName (LayerType
*Layer
, TextType
*Text
)
1068 char *old
= Text
->TextString
;
1070 if (TEST_FLAG (LOCKFLAG
, Text
))
1072 EraseText (Layer
, Text
);
1073 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1074 Text
->TextString
= NewName
;
1076 /* calculate size of the bounding box */
1077 SetTextBoundingBox (&PCB
->Font
, Text
);
1078 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1079 DrawText (Layer
, Text
);
1083 /* ---------------------------------------------------------------------------
1084 * changes the name of a layout; memory has to be already allocated
1087 ChangeLayoutName (char *Name
)
1091 hid_action ("PCBChanged");
1095 /* ---------------------------------------------------------------------------
1096 * changes the side of the board an element is on
1097 * returns TRUE if done
1100 ChangeElementSide (ElementType
*Element
, Coord yoff
)
1102 if (TEST_FLAG (LOCKFLAG
, Element
))
1104 EraseElement (Element
);
1105 AddObjectToMirrorUndoList (ELEMENT_TYPE
, Element
, Element
, Element
, yoff
);
1106 MirrorElementCoordinates (PCB
->Data
, Element
, yoff
);
1107 DrawElement (Element
);
1111 /* ---------------------------------------------------------------------------
1112 * changes the name of a layer; memory has to be already allocated
1115 ChangeLayerName (LayerType
*Layer
, char *Name
)
1117 free (CURRENT
->Name
);
1118 CURRENT
->Name
= Name
;
1119 hid_action ("LayersChanged");
1123 /* ---------------------------------------------------------------------------
1124 * changes the clearance flag of a line
1127 ChangeLineJoin (LayerType
*Layer
, LineType
*Line
)
1129 if (TEST_FLAG (LOCKFLAG
, Line
))
1132 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1134 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, false);
1135 RestoreToPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1137 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Line
, Line
);
1138 TOGGLE_FLAG (CLEARLINEFLAG
, Line
);
1139 if (TEST_FLAG(CLEARLINEFLAG
, Line
))
1141 AddObjectToClearPolyUndoList (LINE_TYPE
, Layer
, Line
, Line
, true);
1142 ClearFromPolygon (PCB
->Data
, LINE_TYPE
, Layer
, Line
);
1144 DrawLine (Layer
, Line
);
1148 /* ---------------------------------------------------------------------------
1149 * sets the clearance flag of a line
1152 SetLineJoin (LayerType
*Layer
, LineType
*Line
)
1154 if (TEST_FLAG (LOCKFLAG
, Line
) || TEST_FLAG (CLEARLINEFLAG
, Line
))
1156 return ChangeLineJoin (Layer
, Line
);
1159 /* ---------------------------------------------------------------------------
1160 * clears the clearance flag of a line
1163 ClrLineJoin (LayerType
*Layer
, LineType
*Line
)
1165 if (TEST_FLAG (LOCKFLAG
, Line
) || !TEST_FLAG (CLEARLINEFLAG
, Line
))
1167 return ChangeLineJoin (Layer
, Line
);
1170 /* ---------------------------------------------------------------------------
1171 * changes the clearance flag of an arc
1174 ChangeArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1176 if (TEST_FLAG (LOCKFLAG
, Arc
))
1179 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1181 RestoreToPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1182 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, false);
1184 AddObjectToFlagUndoList (ARC_TYPE
, Layer
, Arc
, Arc
);
1185 TOGGLE_FLAG (CLEARLINEFLAG
, Arc
);
1186 if (TEST_FLAG (CLEARLINEFLAG
, Arc
))
1188 ClearFromPolygon (PCB
->Data
, ARC_TYPE
, Layer
, Arc
);
1189 AddObjectToClearPolyUndoList (ARC_TYPE
, Layer
, Arc
, Arc
, true);
1191 DrawArc (Layer
, Arc
);
1195 /* ---------------------------------------------------------------------------
1196 * sets the clearance flag of an arc
1199 SetArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1201 if (TEST_FLAG (LOCKFLAG
, Arc
) || TEST_FLAG (CLEARLINEFLAG
, Arc
))
1203 return ChangeArcJoin (Layer
, Arc
);
1206 /* ---------------------------------------------------------------------------
1207 * clears the clearance flag of an arc
1210 ClrArcJoin (LayerType
*Layer
, ArcType
*Arc
)
1212 if (TEST_FLAG (LOCKFLAG
, Arc
) || !TEST_FLAG (CLEARLINEFLAG
, Arc
))
1214 return ChangeArcJoin (Layer
, Arc
);
1217 /* ---------------------------------------------------------------------------
1218 * changes the clearance flag of a text
1221 ChangeTextJoin (LayerType
*Layer
, TextType
*Text
)
1223 if (TEST_FLAG (LOCKFLAG
, Text
))
1225 EraseText (Layer
, Text
);
1226 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1228 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, false);
1229 RestoreToPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1231 AddObjectToFlagUndoList (LINE_TYPE
, Layer
, Text
, Text
);
1232 TOGGLE_FLAG (CLEARLINEFLAG
, Text
);
1233 if (TEST_FLAG(CLEARLINEFLAG
, Text
))
1235 AddObjectToClearPolyUndoList (TEXT_TYPE
, Layer
, Text
, Text
, true);
1236 ClearFromPolygon (PCB
->Data
, TEXT_TYPE
, Layer
, Text
);
1238 DrawText (Layer
, Text
);
1242 /* ---------------------------------------------------------------------------
1243 * sets the clearance flag of a text
1246 SetTextJoin (LayerType
*Layer
, TextType
*Text
)
1248 if (TEST_FLAG (LOCKFLAG
, Text
) || TEST_FLAG (CLEARLINEFLAG
, Text
))
1250 return ChangeTextJoin (Layer
, Text
);
1253 /* ---------------------------------------------------------------------------
1254 * clears the clearance flag of a text
1257 ClrTextJoin (LayerType
*Layer
, TextType
*Text
)
1259 if (TEST_FLAG (LOCKFLAG
, Text
) || !TEST_FLAG (CLEARLINEFLAG
, Text
))
1261 return ChangeTextJoin (Layer
, Text
);
1264 /* ---------------------------------------------------------------------------
1265 * changes the square flag of all pins on an element
1268 ChangeElementSquare (ElementType
*Element
)
1272 if (TEST_FLAG (LOCKFLAG
, Element
))
1276 ans
= ChangePinSquare (Element
, pin
);
1281 ans
= ChangePadSquare (Element
, pad
);
1287 /* ---------------------------------------------------------------------------
1288 * sets the square flag of all pins on an element
1291 SetElementSquare (ElementType
*Element
)
1295 if (TEST_FLAG (LOCKFLAG
, Element
))
1299 ans
= SetPinSquare (Element
, pin
);
1304 ans
= SetPadSquare (Element
, pad
);
1310 /* ---------------------------------------------------------------------------
1311 * clears the square flag of all pins on an element
1314 ClrElementSquare (ElementType
*Element
)
1318 if (TEST_FLAG (LOCKFLAG
, Element
))
1322 ans
= ClrPinSquare (Element
, pin
);
1327 ans
= ClrPadSquare (Element
, pad
);
1333 /* ---------------------------------------------------------------------------
1334 * changes the octagon flags of all pins of an element
1337 ChangeElementOctagon (ElementType
*Element
)
1339 void *result
= NULL
;
1341 if (TEST_FLAG (LOCKFLAG
, Element
))
1345 ChangePinOctagon (Element
, pin
);
1352 /* ---------------------------------------------------------------------------
1353 * sets the octagon flags of all pins of an element
1356 SetElementOctagon (ElementType
*Element
)
1358 void *result
= NULL
;
1360 if (TEST_FLAG (LOCKFLAG
, Element
))
1364 SetPinOctagon (Element
, pin
);
1371 /* ---------------------------------------------------------------------------
1372 * clears the octagon flags of all pins of an element
1375 ClrElementOctagon (ElementType
*Element
)
1377 void *result
= NULL
;
1379 if (TEST_FLAG (LOCKFLAG
, Element
))
1383 ClrPinOctagon (Element
, pin
);
1390 /* ---------------------------------------------------------------------------
1391 * changes the square flag of a pad
1394 ChangePadSquare (ElementType
*Element
, PadType
*Pad
)
1396 if (TEST_FLAG (LOCKFLAG
, Pad
))
1399 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, false);
1400 RestoreToPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1401 AddObjectToFlagUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
1402 TOGGLE_FLAG (SQUAREFLAG
, Pad
);
1403 AddObjectToClearPolyUndoList (PAD_TYPE
, Element
, Pad
, Pad
, true);
1404 ClearFromPolygon (PCB
->Data
, PAD_TYPE
, Element
, Pad
);
1409 /* ---------------------------------------------------------------------------
1410 * sets the square flag of a pad
1413 SetPadSquare (ElementType
*Element
, PadType
*Pad
)
1416 if (TEST_FLAG (LOCKFLAG
, Pad
) || TEST_FLAG (SQUAREFLAG
, Pad
))
1419 return (ChangePadSquare (Element
, Pad
));
1423 /* ---------------------------------------------------------------------------
1424 * clears the square flag of a pad
1427 ClrPadSquare (ElementType
*Element
, PadType
*Pad
)
1430 if (TEST_FLAG (LOCKFLAG
, Pad
) || !TEST_FLAG (SQUAREFLAG
, Pad
))
1433 return (ChangePadSquare (Element
, Pad
));
1437 /* ---------------------------------------------------------------------------
1438 * changes the square flag of a pin
1441 ChangePinSquare (ElementType
*Element
, PinType
*Pin
)
1443 if (TEST_FLAG (LOCKFLAG
, Pin
))
1446 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1447 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1448 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1449 TOGGLE_FLAG (SQUAREFLAG
, Pin
);
1450 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1451 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1456 /* ---------------------------------------------------------------------------
1457 * sets the square flag of a pin
1460 SetPinSquare (ElementType
*Element
, PinType
*Pin
)
1462 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (SQUAREFLAG
, Pin
))
1465 return (ChangePinSquare (Element
, Pin
));
1468 /* ---------------------------------------------------------------------------
1469 * clears the square flag of a pin
1472 ClrPinSquare (ElementType
*Element
, PinType
*Pin
)
1474 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (SQUAREFLAG
, Pin
))
1477 return (ChangePinSquare (Element
, Pin
));
1480 /* ---------------------------------------------------------------------------
1481 * changes the octagon flag of a via
1484 ChangeViaOctagon (PinType
*Via
)
1486 if (TEST_FLAG (LOCKFLAG
, Via
))
1489 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, false);
1490 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1491 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1492 TOGGLE_FLAG (OCTAGONFLAG
, Via
);
1493 AddObjectToClearPolyUndoList (VIA_TYPE
, Via
, Via
, Via
, true);
1494 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1499 /* ---------------------------------------------------------------------------
1500 * sets the octagon flag of a via
1503 SetViaOctagon (PinType
*Via
)
1505 if (TEST_FLAG (LOCKFLAG
, Via
) || TEST_FLAG (OCTAGONFLAG
, Via
))
1508 return (ChangeViaOctagon (Via
));
1511 /* ---------------------------------------------------------------------------
1512 * clears the octagon flag of a via
1515 ClrViaOctagon (PinType
*Via
)
1517 if (TEST_FLAG (LOCKFLAG
, Via
) || !TEST_FLAG (OCTAGONFLAG
, Via
))
1520 return (ChangeViaOctagon (Via
));
1523 /* ---------------------------------------------------------------------------
1524 * changes the octagon flag of a pin
1527 ChangePinOctagon (ElementType
*Element
, PinType
*Pin
)
1529 if (TEST_FLAG (LOCKFLAG
, Pin
))
1532 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, false);
1533 RestoreToPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1534 AddObjectToFlagUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
1535 TOGGLE_FLAG (OCTAGONFLAG
, Pin
);
1536 AddObjectToClearPolyUndoList (PIN_TYPE
, Element
, Pin
, Pin
, true);
1537 ClearFromPolygon (PCB
->Data
, PIN_TYPE
, Element
, Pin
);
1542 /* ---------------------------------------------------------------------------
1543 * sets the octagon flag of a pin
1546 SetPinOctagon (ElementType
*Element
, PinType
*Pin
)
1548 if (TEST_FLAG (LOCKFLAG
, Pin
) || TEST_FLAG (OCTAGONFLAG
, Pin
))
1551 return (ChangePinOctagon (Element
, Pin
));
1554 /* ---------------------------------------------------------------------------
1555 * clears the octagon flag of a pin
1558 ClrPinOctagon (ElementType
*Element
, PinType
*Pin
)
1560 if (TEST_FLAG (LOCKFLAG
, Pin
) || !TEST_FLAG (OCTAGONFLAG
, Pin
))
1563 return (ChangePinOctagon (Element
, Pin
));
1566 /* ---------------------------------------------------------------------------
1567 * changes the hole flag of a via
1570 ChangeHole (PinType
*Via
)
1572 if (TEST_FLAG (LOCKFLAG
, Via
))
1575 AddObjectToFlagUndoList (VIA_TYPE
, Via
, Via
, Via
);
1576 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
1577 r_delete_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
);
1578 RestoreToPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1579 TOGGLE_FLAG (HOLEFLAG
, Via
);
1581 if (TEST_FLAG (HOLEFLAG
, Via
))
1583 /* A tented via becomes an minimally untented hole. An untented
1584 via retains its mask clearance. */
1585 if (Via
->Mask
> Via
->Thickness
)
1587 Via
->Mask
= (Via
->DrillingHole
1588 + (Via
->Mask
- Via
->Thickness
));
1590 else if (Via
->Mask
< Via
->DrillingHole
)
1592 Via
->Mask
= Via
->DrillingHole
+ 2 * MASKFRAME
;
1597 Via
->Mask
= (Via
->Thickness
1598 + (Via
->Mask
- Via
->DrillingHole
));
1601 SetPinBoundingBox (Via
);
1602 r_insert_entry (PCB
->Data
->via_tree
, (BoxType
*) Via
, 0);
1603 ClearFromPolygon (PCB
->Data
, VIA_TYPE
, Via
, Via
);
1609 /* ---------------------------------------------------------------------------
1610 * changes the nopaste flag of a pad
1613 ChangePaste (PadType
*Pad
)
1615 if (TEST_FLAG (LOCKFLAG
, Pad
))
1618 AddObjectToFlagUndoList (PAD_TYPE
, Pad
, Pad
, Pad
);
1619 TOGGLE_FLAG (NOPASTEFLAG
, Pad
);
1625 /* ---------------------------------------------------------------------------
1626 * changes the CLEARPOLY flag of a polygon
1629 ChangePolyClear (LayerType
*Layer
, PolygonType
*Polygon
)
1631 if (TEST_FLAG (LOCKFLAG
, Polygon
))
1633 AddObjectToClearPolyUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
, true);
1634 AddObjectToFlagUndoList (POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
1635 TOGGLE_FLAG (CLEARPOLYFLAG
, Polygon
);
1636 InitClip (PCB
->Data
, Layer
, Polygon
);
1637 DrawPolygon (Layer
, Polygon
);
1641 /* ----------------------------------------------------------------------
1642 * changes the side of all selected and visible elements
1643 * returns true if anything has changed
1646 ChangeSelectedElementSide (void)
1648 bool change
= false;
1650 /* setup identifiers */
1651 if (PCB
->PinOn
&& PCB
->ElementOn
)
1652 ELEMENT_LOOP (PCB
->Data
);
1654 if (TEST_FLAG (SELECTEDFLAG
, element
))
1656 change
|= ChangeElementSide (element
, 0);
1663 IncrementUndoSerialNumber ();
1668 /* ----------------------------------------------------------------------
1669 * changes the thermals on all selected and visible pins
1670 * and/or vias. Returns true if anything has changed
1673 ChangeSelectedThermals (int types
, int therm_style
)
1675 bool change
= false;
1677 Delta
= therm_style
;
1678 change
= SelectedOperation (&ChangeThermalFunctions
, false, types
);
1682 IncrementUndoSerialNumber ();
1687 /* ----------------------------------------------------------------------
1688 * changes the size of all selected and visible object types
1689 * returns true if anything has changed
1692 ChangeSelectedSize (int types
, Coord Difference
, bool fixIt
)
1694 bool change
= false;
1696 /* setup identifiers */
1697 Absolute
= (fixIt
) ? Difference
: 0;
1700 change
= SelectedOperation (&ChangeSizeFunctions
, false, types
);
1704 IncrementUndoSerialNumber ();
1709 /* ----------------------------------------------------------------------
1710 * changes the clearance size of all selected and visible objects
1711 * returns true if anything has changed
1714 ChangeSelectedClearSize (int types
, Coord Difference
, bool fixIt
)
1716 bool change
= false;
1718 /* setup identifiers */
1719 Absolute
= (fixIt
) ? Difference
: 0;
1721 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
1722 change
= SelectedOperation (&ChangeMaskSizeFunctions
, false, types
);
1724 change
= SelectedOperation (&ChangeClearSizeFunctions
, false, types
);
1728 IncrementUndoSerialNumber ();
1733 /* --------------------------------------------------------------------------
1734 * changes the 2nd size (drilling hole) of all selected and visible objects
1735 * returns true if anything has changed
1738 ChangeSelected2ndSize (int types
, Coord Difference
, bool fixIt
)
1740 bool change
= false;
1742 /* setup identifiers */
1743 Absolute
= (fixIt
) ? Difference
: 0;
1745 change
= SelectedOperation (&Change2ndSizeFunctions
, false, types
);
1749 IncrementUndoSerialNumber ();
1754 /* ----------------------------------------------------------------------
1755 * changes the clearance flag (join) of all selected and visible lines
1756 * and/or arcs. Returns true if anything has changed
1759 ChangeSelectedJoin (int types
)
1761 bool change
= false;
1763 change
= SelectedOperation (&ChangeJoinFunctions
, false, types
);
1767 IncrementUndoSerialNumber ();
1772 /* ----------------------------------------------------------------------
1773 * changes the clearance flag (join) of all selected and visible lines
1774 * and/or arcs. Returns true if anything has changed
1777 SetSelectedJoin (int types
)
1779 bool change
= false;
1781 change
= SelectedOperation (&SetJoinFunctions
, false, types
);
1785 IncrementUndoSerialNumber ();
1790 /* ----------------------------------------------------------------------
1791 * changes the clearance flag (join) of all selected and visible lines
1792 * and/or arcs. Returns true if anything has changed
1795 ClrSelectedJoin (int types
)
1797 bool change
= false;
1799 change
= SelectedOperation (&ClrJoinFunctions
, false, types
);
1803 IncrementUndoSerialNumber ();
1808 /* ----------------------------------------------------------------------
1809 * changes the square-flag of all selected and visible pins or pads
1810 * returns true if anything has changed
1813 ChangeSelectedSquare (int types
)
1815 bool change
= false;
1817 change
= SelectedOperation (&ChangeSquareFunctions
, false, types
);
1821 IncrementUndoSerialNumber ();
1826 /* ----------------------------------------------------------------------
1827 * sets the square-flag of all selected and visible pins or pads
1828 * returns true if anything has changed
1831 SetSelectedSquare (int types
)
1833 bool change
= false;
1835 change
= SelectedOperation (&SetSquareFunctions
, false, types
);
1839 IncrementUndoSerialNumber ();
1844 /* ----------------------------------------------------------------------
1845 * clears the square-flag of all selected and visible pins or pads
1846 * returns true if anything has changed
1849 ClrSelectedSquare (int types
)
1851 bool change
= false;
1853 change
= SelectedOperation (&ClrSquareFunctions
, false, types
);
1857 IncrementUndoSerialNumber ();
1862 /* ----------------------------------------------------------------------
1863 * changes the octagon-flag of all selected and visible pins and vias
1864 * returns true if anything has changed
1867 ChangeSelectedOctagon (int types
)
1869 bool change
= false;
1871 change
= SelectedOperation (&ChangeOctagonFunctions
, false, types
);
1875 IncrementUndoSerialNumber ();
1880 /* ----------------------------------------------------------------------
1881 * sets the octagon-flag of all selected and visible pins and vias
1882 * returns true if anything has changed
1885 SetSelectedOctagon (int types
)
1887 bool change
= false;
1889 change
= SelectedOperation (&SetOctagonFunctions
, false, types
);
1893 IncrementUndoSerialNumber ();
1898 /* ----------------------------------------------------------------------
1899 * clears the octagon-flag of all selected and visible pins and vias
1900 * returns true if anything has changed
1903 ClrSelectedOctagon (int types
)
1905 bool change
= false;
1907 change
= SelectedOperation (&ClrOctagonFunctions
, false, types
);
1911 IncrementUndoSerialNumber ();
1916 /* ----------------------------------------------------------------------
1917 * changes the hole-flag of all selected and visible vias
1918 * returns true if anything has changed
1921 ChangeSelectedHole (void)
1923 bool change
= false;
1926 VIA_LOOP (PCB
->Data
);
1928 if (TEST_FLAG (SELECTEDFLAG
, via
))
1929 change
|= ChangeHole (via
);
1935 IncrementUndoSerialNumber ();
1940 /* ----------------------------------------------------------------------
1941 * changes the no paste-flag of all selected and visible pads
1942 * returns true if anything has changed
1945 ChangeSelectedPaste (void)
1947 bool change
= false;
1949 ALLPAD_LOOP (PCB
->Data
);
1951 if (TEST_FLAG (SELECTEDFLAG
, pad
))
1952 change
|= ChangePaste (pad
);
1958 IncrementUndoSerialNumber ();
1964 /* ---------------------------------------------------------------------------
1965 * changes the size of the passed object
1966 * Returns true if anything is changed
1969 ChangeObjectSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1970 Coord Difference
, bool fixIt
)
1974 /* setup identifier */
1975 Absolute
= (fixIt
) ? Difference
: 0;
1978 (ObjectOperation (&ChangeSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
);
1982 IncrementUndoSerialNumber ();
1987 /* ---------------------------------------------------------------------------
1988 * changes the clearance size of the passed object
1989 * Returns true if anything is changed
1992 ChangeObjectClearSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
1993 Coord Difference
, bool fixIt
)
1997 /* setup identifier */
1998 Absolute
= (fixIt
) ? Difference
: 0;
2000 if (TEST_FLAG (SHOWMASKFLAG
, PCB
))
2002 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2006 (ObjectOperation (&ChangeClearSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2011 IncrementUndoSerialNumber ();
2016 /* ---------------------------------------------------------------------------
2017 * changes the thermal of the passed object
2018 * Returns true if anything is changed
2022 ChangeObjectThermal (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2027 Delta
= Absolute
= therm_type
;
2029 (ObjectOperation (&ChangeThermalFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2034 IncrementUndoSerialNumber ();
2039 /* ---------------------------------------------------------------------------
2040 * changes the 2nd size of the passed object
2041 * Returns true if anything is changed
2044 ChangeObject2ndSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2045 Coord Difference
, bool fixIt
, bool incundo
)
2049 /* setup identifier */
2050 Absolute
= (fixIt
) ? Difference
: 0;
2053 (ObjectOperation (&Change2ndSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2059 IncrementUndoSerialNumber ();
2064 /* ---------------------------------------------------------------------------
2065 * changes the mask size of the passed object
2066 * Returns true if anything is changed
2069 ChangeObjectMaskSize (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
,
2070 Coord Difference
, bool fixIt
)
2074 /* setup identifier */
2075 Absolute
= (fixIt
) ? Difference
: 0;
2078 (ObjectOperation (&ChangeMaskSizeFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2083 IncrementUndoSerialNumber ();
2088 /* ---------------------------------------------------------------------------
2089 * changes the name of the passed object
2090 * returns the old name
2092 * The allocated memory isn't freed because the old string is used
2093 * by the undo module.
2096 ChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
, char *Name
)
2099 /* setup identifier */
2101 result
= ObjectOperation (&ChangeNameFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
);
2106 /* ---------------------------------------------------------------------------
2107 * changes the clearance-flag of the passed object
2108 * Returns true if anything is changed
2111 ChangeObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2113 if (ObjectOperation (&ChangeJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2116 IncrementUndoSerialNumber ();
2122 /* ---------------------------------------------------------------------------
2123 * sets the clearance-flag of the passed object
2124 * Returns true if anything is changed
2127 SetObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2129 if (ObjectOperation (&SetJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2132 IncrementUndoSerialNumber ();
2138 /* ---------------------------------------------------------------------------
2139 * clears the clearance-flag of the passed object
2140 * Returns true if anything is changed
2143 ClrObjectJoin (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2145 if (ObjectOperation (&ClrJoinFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2148 IncrementUndoSerialNumber ();
2154 /* ---------------------------------------------------------------------------
2155 * changes the square-flag of the passed object
2156 * Returns true if anything is changed
2159 ChangeObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2161 if (ObjectOperation (&ChangeSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2165 IncrementUndoSerialNumber ();
2171 /* ---------------------------------------------------------------------------
2172 * sets the square-flag of the passed object
2173 * Returns true if anything is changed
2176 SetObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2178 if (ObjectOperation (&SetSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2181 IncrementUndoSerialNumber ();
2187 /* ---------------------------------------------------------------------------
2188 * clears the square-flag of the passed object
2189 * Returns true if anything is changed
2192 ClrObjectSquare (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2194 if (ObjectOperation (&ClrSquareFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2197 IncrementUndoSerialNumber ();
2203 /* ---------------------------------------------------------------------------
2204 * changes the octagon-flag of the passed object
2205 * Returns true if anything is changed
2208 ChangeObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2210 if (ObjectOperation (&ChangeOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) !=
2214 IncrementUndoSerialNumber ();
2220 /* ---------------------------------------------------------------------------
2221 * sets the octagon-flag of the passed object
2222 * Returns true if anything is changed
2225 SetObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2227 if (ObjectOperation (&SetOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2230 IncrementUndoSerialNumber ();
2236 /* ---------------------------------------------------------------------------
2237 * clears the octagon-flag of the passed object
2238 * Returns true if anything is changed
2241 ClrObjectOctagon (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2243 if (ObjectOperation (&ClrOctagonFunctions
, Type
, Ptr1
, Ptr2
, Ptr3
) != NULL
)
2246 IncrementUndoSerialNumber ();
2252 /* ---------------------------------------------------------------------------
2253 * queries the user for a new object name and changes it
2255 * The allocated memory isn't freed because the old string is used
2256 * by the undo module.
2259 QueryInputAndChangeObjectName (int Type
, void *Ptr1
, void *Ptr2
, void *Ptr3
)
2264 /* if passed an element name, make it an element reference instead */
2265 if (Type
== ELEMENTNAME_TYPE
)
2267 Type
= ELEMENT_TYPE
;
2274 name
= gui
->prompt_for (_("Linename:"),
2275 EMPTY (((LineType
*) Ptr2
)->Number
));
2279 name
= gui
->prompt_for (_("Vianame:"),
2280 EMPTY (((PinType
*) Ptr2
)->Name
));
2284 sprintf (msg
, _("%s Pin Name:"), EMPTY (((PinType
*) Ptr2
)->Number
));
2285 name
= gui
->prompt_for (msg
, EMPTY (((PinType
*) Ptr2
)->Name
));
2289 sprintf (msg
, _("%s Pad Name:"), EMPTY (((PadType
*) Ptr2
)->Number
));
2290 name
= gui
->prompt_for (msg
, EMPTY (((PadType
*) Ptr2
)->Name
));
2294 name
= gui
->prompt_for (_("Enter text:"),
2295 EMPTY (((TextType
*) Ptr2
)->TextString
));
2299 name
= gui
->prompt_for (_("Elementname:"),
2301 (PCB
, (ElementType
*) Ptr2
)));
2306 /* NB: ChangeObjectName takes ownership of the passed memory */
2307 char *old
= (char *)ChangeObjectName (Type
, Ptr1
, Ptr2
, Ptr3
, name
);
2308 if (old
!= (char *) -1)
2310 AddObjectToChangeNameUndoList (Type
, Ptr1
, Ptr2
, Ptr3
, old
);
2311 IncrementUndoSerialNumber ();
2319 /* ---------------------------------------------------------------------------
2320 * changes the maximum size of a layout
2321 * adjusts the scrollbars
2322 * releases the saved pixmap if necessary
2323 * and adjusts the cursor confinement box
2326 ChangePCBSize (Coord Width
, Coord Height
)
2328 PCB
->MaxWidth
= Width
;
2329 PCB
->MaxHeight
= Height
;
2331 /* crosshair range is different if pastebuffer-mode
2334 if (Settings
.Mode
== PASTEBUFFER_MODE
)
2335 SetCrosshairRange (PASTEBUFFER
->X
- PASTEBUFFER
->BoundingBox
.X1
,
2336 PASTEBUFFER
->Y
- PASTEBUFFER
->BoundingBox
.Y1
,
2338 Width
- (PASTEBUFFER
->BoundingBox
.X2
-
2339 PASTEBUFFER
->X
)), MAX (0,
2346 SetCrosshairRange (0, 0, Width
, Height
);
2349 hid_action ("PCBChanged");
2352 /* ---------------------------------------------------------------------------
2353 * finds the maximum size of a layout
2354 * according to the outline layer,
2358 UpdateExtents (void)
2360 Coord minX
, minY
, maxX
, maxY
;
2362 minX
= minY
= COORD_MAX
;
2363 maxX
= maxY
= -COORD_MAX
- 1;
2365 LAYER_LOOP (PCB
->Data
, MAX_LAYER
);
2367 if (strcmp (layer
->Name
, "outline") == 0)
2371 if (line
->Point1
.X
< minX
)
2372 minX
= line
->Point1
.X
;
2373 if (line
->Point1
.Y
< minY
)
2374 minY
= line
->Point1
.Y
;
2375 if (line
->Point2
.X
< minX
)
2376 minX
= line
->Point2
.X
;
2377 if (line
->Point2
.Y
< minY
)
2378 minY
= line
->Point2
.Y
;
2379 if (line
->Point1
.X
> maxX
)
2380 maxX
= line
->Point1
.X
;
2381 if (line
->Point1
.Y
> maxY
)
2382 maxY
= line
->Point1
.Y
;
2383 if (line
->Point2
.X
> maxX
)
2384 maxX
= line
->Point2
.X
;
2385 if (line
->Point2
.Y
> maxY
)
2386 maxY
= line
->Point2
.Y
;
2393 if (minX
== COORD_MAX
|| minY
== COORD_MAX
||
2394 maxX
== -COORD_MAX
- 1 || maxY
== -COORD_MAX
- 1 ||
2395 maxX
- minX
== 0 || maxY
- minY
== 0)
2397 // no or insufficient outline layer
2398 PCB
->ExtentMinX
= 0;
2399 PCB
->ExtentMinY
= 0;
2400 PCB
->ExtentMaxX
= PCB
->MaxWidth
;
2401 PCB
->ExtentMaxY
= PCB
->MaxHeight
;
2405 PCB
->ExtentMinX
= minX
;
2406 PCB
->ExtentMinY
= minY
;
2407 PCB
->ExtentMaxX
= maxX
;
2408 PCB
->ExtentMaxY
= maxY
;
2412 /* ---------------------------------------------------------------------------
2413 * changes the mask size of a pad
2414 * returns TRUE if changed
2417 ChangePadMaskSize (ElementType
*Element
, PadType
*Pad
)
2419 Coord value
= (Absolute
) ? Absolute
: Pad
->Mask
+ Delta
;
2421 value
= MAX (value
, 0);
2422 if (value
== Pad
->Mask
&& Absolute
== 0)
2423 value
= Pad
->Thickness
;
2424 if (value
!= Pad
->Mask
)
2426 AddObjectToMaskSizeUndoList (PAD_TYPE
, Element
, Pad
, Pad
);
2428 r_delete_entry (PCB
->Data
->pad_tree
, &Pad
->BoundingBox
);
2430 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2437 /* ---------------------------------------------------------------------------
2438 * changes the mask size of a pin
2439 * returns TRUE if changed
2442 ChangePinMaskSize (ElementType
*Element
, PinType
*Pin
)
2444 Coord value
= (Absolute
) ? Absolute
: Pin
->Mask
+ Delta
;
2446 value
= MAX (value
, 0);
2447 if (value
== Pin
->Mask
&& Absolute
== 0)
2448 value
= Pin
->Thickness
;
2449 if (value
!= Pin
->Mask
)
2451 AddObjectToMaskSizeUndoList (PIN_TYPE
, Element
, Pin
, Pin
);
2453 r_delete_entry (PCB
->Data
->pin_tree
, &Pin
->BoundingBox
);
2455 SetElementBoundingBox (PCB
->Data
, Element
, &PCB
->Font
);
2462 /* ---------------------------------------------------------------------------
2463 * changes the mask size of a via
2464 * returns TRUE if changed
2467 ChangeViaMaskSize (PinType
*Via
)
2471 value
= (Absolute
) ? Absolute
: Via
->Mask
+ Delta
;
2472 value
= MAX (value
, 0);
2473 if (value
!= Via
->Mask
)
2475 AddObjectToMaskSizeUndoList (VIA_TYPE
, Via
, Via
, Via
);
2477 r_delete_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
);
2479 SetPinBoundingBox (Via
);
2480 r_insert_entry (PCB
->Data
->via_tree
, &Via
->BoundingBox
, 0);