-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMassChangeTextRotation.pas
71 lines (60 loc) · 2.39 KB
/
MassChangeTextRotation.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{..............................................................................
Rotate all text strings on TopOverlay, Bottom Overlay, Mechanical5 and
Mechanical6 to face upwards for better readability
Date: December 17, 2018
Author: Yifeng Qiu @ Lumileds
..............................................................................}
Procedure MassChangeTextRotation;
Var
Board : IPCB_Board;
IText : IPCB_Text;
Iterator : IPCB_SpatialIterator;
OldCenterX, OldCenterY : TCoord;
NewCenterX, NewCenterY : TCoord;
Width, Height: TCoord;
Rotation : TReal;
BR : TCoordRect;
Begin
// Retrieve the current board
Board := PCBServer.GetCurrentPCBBoard;
If Board = Nil Then Exit;
BR := Board.BoardOutline.BoundingRectangle;
Iterator := Board.SpatialIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(eTextObject));
Iterator.AddFilter_LayerSet(MkSet(
eTopOverlay,
eBottomOverlay,
eMechanical5,
eMechanical6));
Iterator.AddFilter_Area(BR.Left, BR.Bottom, BR.Right, BR.Top);
IText := Iterator.FirstPCBObject;
While (IText <> Nil) Do
Begin
if (IText.Rotation < 90) or (IText.Rotation > 270) Then
Begin
IText := Iterator.NextPCBObject;
continue;
End;
IText.Selected := True;
Width := IText.X2Location - IText.X1Location;
Height := IText.Y2Location - IText.Y1Location;
Rotation := Degrees2Radians(IText.Rotation);
If IText.MirrorFlag = False Then
Begin
OldCenterX := IText.XLocation + 0.5*Width*cos(Rotation)-0.5*Height*sin(Rotation);
OldCenterY := IText.YLocation + 0.5*Width*sin(Rotation)+0.5*Height*cos(Rotation);
End
Else
Begin
OldCenterX := IText.XLocation - 0.5*Width*cos(Rotation)-0.5*Height*sin(Rotation);
OldCenterY := IText.YLocation - 0.5*Width*sin(Rotation)+0.5*Height*cos(Rotation);
End;
Pcbserver.PreProcess;
PCBServer.SendMessageToRobots(IText.I_ObjectAddress, c_Broadcast, PCBM_BeginModify, c_NoEventData);
IText.RotateAroundXY(OldCenterX, OldCenterY, 180);
PCBServer.SendMessageToRobots(IText.I_ObjectAddress, c_Broadcast, PCBM_EndModify, c_NoEventData);
Pcbserver.PostProcess;
IText := Iterator.NextPCBObject;
End;
Board.SpatialIterator_Destroy(Iterator);
End;