개정판 f71d5768
dev issue #1229 : ID2 Drawing -> Aveva Drawing 좌표 변환
Change-Id: If758fe416e28f2b1aca8ab2bd51a4ead3ff6a028
DTI_PID/APIDConverter/APIDConverterExplorer.Designer.cs | ||
---|---|---|
38 | 38 |
this.layoutControlGroup1 = new DevExpress.XtraLayout.LayoutControlGroup(); |
39 | 39 |
this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); |
40 | 40 |
this.defaultLookAndFeel = new DevExpress.LookAndFeel.DefaultLookAndFeel(this.components); |
41 |
this.textDrawingX = new DevExpress.XtraEditors.TextEdit(); |
|
42 |
this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem(); |
|
43 |
this.layoutControlGroup2 = new DevExpress.XtraLayout.LayoutControlGroup(); |
|
44 |
this.btnDrawingSize = new DevExpress.XtraEditors.SimpleButton(); |
|
45 |
this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem(); |
|
46 |
this.textDrawingY = new DevExpress.XtraEditors.TextEdit(); |
|
47 |
this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem(); |
|
41 | 48 |
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit(); |
42 | 49 |
this.layoutControl1.SuspendLayout(); |
43 | 50 |
((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit(); |
44 | 51 |
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit(); |
45 | 52 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).BeginInit(); |
46 | 53 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); |
54 |
((System.ComponentModel.ISupportInitialize)(this.textDrawingX.Properties)).BeginInit(); |
|
55 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit(); |
|
56 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).BeginInit(); |
|
57 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit(); |
|
58 |
((System.ComponentModel.ISupportInitialize)(this.textDrawingY.Properties)).BeginInit(); |
|
59 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit(); |
|
47 | 60 |
this.SuspendLayout(); |
48 | 61 |
// |
49 | 62 |
// splashScreenManager |
... | ... | |
52 | 65 |
// |
53 | 66 |
// layoutControl1 |
54 | 67 |
// |
68 |
this.layoutControl1.Controls.Add(this.textDrawingY); |
|
69 |
this.layoutControl1.Controls.Add(this.btnDrawingSize); |
|
70 |
this.layoutControl1.Controls.Add(this.textDrawingX); |
|
55 | 71 |
this.layoutControl1.Controls.Add(this.btnOpenConverter); |
56 | 72 |
this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill; |
57 | 73 |
this.layoutControl1.Location = new System.Drawing.Point(0, 0); |
... | ... | |
78 | 94 |
this.Root.GroupBordersVisible = false; |
79 | 95 |
this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] { |
80 | 96 |
this.emptySpaceItem1, |
81 |
this.layoutControlGroup1}); |
|
97 |
this.layoutControlGroup1, |
|
98 |
this.layoutControlGroup2}); |
|
82 | 99 |
this.Root.Name = "Root"; |
83 | 100 |
this.Root.Size = new System.Drawing.Size(232, 560); |
84 | 101 |
this.Root.TextVisible = false; |
... | ... | |
86 | 103 |
// emptySpaceItem1 |
87 | 104 |
// |
88 | 105 |
this.emptySpaceItem1.AllowHotTrack = false; |
89 |
this.emptySpaceItem1.Location = new System.Drawing.Point(0, 85);
|
|
106 |
this.emptySpaceItem1.Location = new System.Drawing.Point(0, 204);
|
|
90 | 107 |
this.emptySpaceItem1.Name = "emptySpaceItem1"; |
91 |
this.emptySpaceItem1.Size = new System.Drawing.Size(212, 455);
|
|
108 |
this.emptySpaceItem1.Size = new System.Drawing.Size(212, 336);
|
|
92 | 109 |
this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0); |
93 | 110 |
// |
94 | 111 |
// layoutControlGroup1 |
... | ... | |
114 | 131 |
// |
115 | 132 |
this.defaultLookAndFeel.LookAndFeel.SkinName = "Office 2019 Colorful"; |
116 | 133 |
// |
134 |
// textDrawingX |
|
135 |
// |
|
136 |
this.textDrawingX.Location = new System.Drawing.Point(35, 156); |
|
137 |
this.textDrawingX.Name = "textDrawingX"; |
|
138 |
this.textDrawingX.Size = new System.Drawing.Size(173, 20); |
|
139 |
this.textDrawingX.StyleController = this.layoutControl1; |
|
140 |
this.textDrawingX.TabIndex = 5; |
|
141 |
// |
|
142 |
// layoutControlItem2 |
|
143 |
// |
|
144 |
this.layoutControlItem2.Control = this.textDrawingX; |
|
145 |
this.layoutControlItem2.Location = new System.Drawing.Point(0, 26); |
|
146 |
this.layoutControlItem2.Name = "layoutControlItem2"; |
|
147 |
this.layoutControlItem2.Size = new System.Drawing.Size(188, 24); |
|
148 |
this.layoutControlItem2.Text = "X"; |
|
149 |
this.layoutControlItem2.TextSize = new System.Drawing.Size(8, 14); |
|
150 |
// |
|
151 |
// layoutControlGroup2 |
|
152 |
// |
|
153 |
this.layoutControlGroup2.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] { |
|
154 |
this.layoutControlItem2, |
|
155 |
this.layoutControlItem3, |
|
156 |
this.layoutControlItem4}); |
|
157 |
this.layoutControlGroup2.Location = new System.Drawing.Point(0, 85); |
|
158 |
this.layoutControlGroup2.Name = "layoutControlGroup2"; |
|
159 |
this.layoutControlGroup2.Size = new System.Drawing.Size(212, 119); |
|
160 |
// |
|
161 |
// btnDrawingSize |
|
162 |
// |
|
163 |
this.btnDrawingSize.Location = new System.Drawing.Point(24, 130); |
|
164 |
this.btnDrawingSize.Name = "btnDrawingSize"; |
|
165 |
this.btnDrawingSize.Size = new System.Drawing.Size(184, 22); |
|
166 |
this.btnDrawingSize.StyleController = this.layoutControl1; |
|
167 |
this.btnDrawingSize.TabIndex = 6; |
|
168 |
this.btnDrawingSize.Text = "Get Drawing Size"; |
|
169 |
this.btnDrawingSize.Click += new System.EventHandler(this.btnDrawingSize_Click); |
|
170 |
// |
|
171 |
// layoutControlItem3 |
|
172 |
// |
|
173 |
this.layoutControlItem3.Control = this.btnDrawingSize; |
|
174 |
this.layoutControlItem3.Location = new System.Drawing.Point(0, 0); |
|
175 |
this.layoutControlItem3.Name = "layoutControlItem3"; |
|
176 |
this.layoutControlItem3.Size = new System.Drawing.Size(188, 26); |
|
177 |
this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0); |
|
178 |
this.layoutControlItem3.TextVisible = false; |
|
179 |
// |
|
180 |
// textDrawingY |
|
181 |
// |
|
182 |
this.textDrawingY.Location = new System.Drawing.Point(35, 180); |
|
183 |
this.textDrawingY.Name = "textDrawingY"; |
|
184 |
this.textDrawingY.Size = new System.Drawing.Size(173, 20); |
|
185 |
this.textDrawingY.StyleController = this.layoutControl1; |
|
186 |
this.textDrawingY.TabIndex = 7; |
|
187 |
// |
|
188 |
// layoutControlItem4 |
|
189 |
// |
|
190 |
this.layoutControlItem4.Control = this.textDrawingY; |
|
191 |
this.layoutControlItem4.Location = new System.Drawing.Point(0, 50); |
|
192 |
this.layoutControlItem4.Name = "layoutControlItem4"; |
|
193 |
this.layoutControlItem4.Size = new System.Drawing.Size(188, 24); |
|
194 |
this.layoutControlItem4.Text = "Y"; |
|
195 |
this.layoutControlItem4.TextSize = new System.Drawing.Size(8, 14); |
|
196 |
// |
|
117 | 197 |
// APIDConverterExplorer |
118 | 198 |
// |
119 | 199 |
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); |
... | ... | |
127 | 207 |
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit(); |
128 | 208 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).EndInit(); |
129 | 209 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); |
210 |
((System.ComponentModel.ISupportInitialize)(this.textDrawingX.Properties)).EndInit(); |
|
211 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit(); |
|
212 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).EndInit(); |
|
213 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit(); |
|
214 |
((System.ComponentModel.ISupportInitialize)(this.textDrawingY.Properties)).EndInit(); |
|
215 |
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit(); |
|
130 | 216 |
this.ResumeLayout(false); |
131 | 217 |
|
132 | 218 |
} |
... | ... | |
140 | 226 |
private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup1; |
141 | 227 |
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1; |
142 | 228 |
private DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeel; |
229 |
private DevExpress.XtraEditors.TextEdit textDrawingY; |
|
230 |
private DevExpress.XtraEditors.SimpleButton btnDrawingSize; |
|
231 |
private DevExpress.XtraEditors.TextEdit textDrawingX; |
|
232 |
private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup2; |
|
233 |
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2; |
|
234 |
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3; |
|
235 |
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4; |
|
143 | 236 |
} |
144 | 237 |
} |
DTI_PID/APIDConverter/APIDConverterExplorer.cs | ||
---|---|---|
9 | 9 |
using System.Windows.Forms; |
10 | 10 |
|
11 | 11 |
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; |
12 |
|
|
13 |
using Autodesk.AutoCAD.ApplicationServices; |
|
14 |
using Autodesk.AutoCAD.ApplicationServices.Core; |
|
15 |
using Autodesk.AutoCAD.DatabaseServices; |
|
16 |
using Autodesk.AutoCAD.EditorInput; |
|
17 |
|
|
12 | 18 |
using AVEVA.PID.CustomizationUtility.DB; |
13 | 19 |
using AVEVA.PID.CustomizationUtility.Model; |
14 | 20 |
using AVEVA.PID.CustomizationUtility.Properties; |
... | ... | |
20 | 26 |
public APIDConverterExplorer() |
21 | 27 |
{ |
22 | 28 |
InitializeComponent(); |
29 |
|
|
30 |
textDrawingX.Text = Settings.Default.DrawingX.ToString(); |
|
31 |
textDrawingY.Text = Settings.Default.DrawingY.ToString(); |
|
23 | 32 |
} |
24 | 33 |
|
25 | 34 |
private void btnOpenConverter_Click(object sender, EventArgs e) |
... | ... | |
27 | 36 |
APIDConverter form = new APIDConverter(); |
28 | 37 |
if (AcadApp.ShowModalDialog(form) == DialogResult.OK) |
29 | 38 |
{ |
30 |
DataTable avevaSymbolTable = Project_DB.SelectSymbolTable(); |
|
39 |
System.Data.DataTable avevaSymbolTable = Project_DB.SelectSymbolTable();
|
|
31 | 40 |
|
32 | 41 |
foreach (var item in form.Documents) |
33 | 42 |
{ |
... | ... | |
38 | 47 |
MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
39 | 48 |
} |
40 | 49 |
} |
50 |
|
|
51 |
private void btnDrawingSize_Click(object sender, EventArgs e) |
|
52 |
{ |
|
53 |
// Get the current document and database, and start a transaction |
|
54 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
55 |
Database acCurDb = acDoc.Database; |
|
56 |
Editor acDocEd = acDoc.Editor; |
|
57 |
|
|
58 |
// Request for objects to be selected in the drawing area |
|
59 |
PromptSelectionResult acSSPrompt = acDocEd.GetSelection(); |
|
60 |
|
|
61 |
// If the prompt status is OK, objects were selected |
|
62 |
if (acSSPrompt.Status == PromptStatus.OK) |
|
63 |
{ |
|
64 |
ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds(); |
|
65 |
// Get the last selected entity |
|
66 |
|
|
67 |
if (selectedObjectIds.Length > 0) |
|
68 |
{ |
|
69 |
ObjectId objectId = selectedObjectIds[0]; |
|
70 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
|
71 |
{ |
|
72 |
Entity entity = acTrans.GetObject(objectId, OpenMode.ForRead, true) as Entity; |
|
73 |
if (entity != null) |
|
74 |
{ |
|
75 |
Extents3d extents = entity.GeometricExtents; |
|
76 |
double width = extents.MaxPoint.X - extents.MinPoint.X; |
|
77 |
double height = extents.MaxPoint.Y - extents.MinPoint.Y; |
|
78 |
|
|
79 |
if (width == 0 || height == 0) |
|
80 |
{ |
|
81 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
|
82 |
return; |
|
83 |
} |
|
84 |
|
|
85 |
Settings.Default.DrawingX = width; |
|
86 |
Settings.Default.DrawingY = height; |
|
87 |
Settings.Default.Save(); |
|
88 |
textDrawingX.Text = Settings.Default.DrawingX.ToString(); |
|
89 |
textDrawingY.Text = Settings.Default.DrawingY.ToString(); |
|
90 |
|
|
91 |
MessageBox.Show("End Drawing Size Setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
92 |
} |
|
93 |
else |
|
94 |
{ |
|
95 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
|
96 |
} |
|
97 |
acTrans.Commit(); |
|
98 |
} |
|
99 |
} |
|
100 |
else |
|
101 |
{ |
|
102 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
41 | 106 |
} |
42 | 107 |
} |
DTI_PID/APIDConverter/Model/PlantItem/Document.cs | ||
---|---|---|
540 | 540 |
{ |
541 | 541 |
item.Aveva = new AvevaLineInfo(); |
542 | 542 |
item.Aveva.Name = (string)rows[0]["APID_SYMBOL"]; |
543 |
item.Aveva.Start_X = item.Start_X; |
|
544 |
item.Aveva.Start_Y = SIZE_HEIGHT - item.Start_Y; |
|
545 |
item.Aveva.End_X = item.End_X; |
|
546 |
item.Aveva.End_Y = SIZE_HEIGHT - item.End_Y; |
|
543 |
double startX = item.Start_X; |
|
544 |
double startY = SIZE_HEIGHT - item.Start_Y; |
|
545 |
double endX = item.End_X; |
|
546 |
double endY = SIZE_HEIGHT - item.End_Y; |
|
547 |
|
|
548 |
ConvertAvevaPoint(ref startX, ref startY); |
|
549 |
ConvertAvevaPoint(ref endX, ref endY); |
|
550 |
|
|
551 |
item.Aveva.Start_X = startX; |
|
552 |
item.Aveva.Start_Y = startY; |
|
553 |
item.Aveva.End_X = endX; |
|
554 |
item.Aveva.End_Y = endY; |
|
547 | 555 |
|
548 | 556 |
if (!DBNull.Value.Equals(rows[0]["DATA1"])) |
549 | 557 |
{ |
... | ... | |
563 | 571 |
if (rows.Length == 1 && !DBNull.Value.Equals(rows[0]["APID_SYMBOL"]) && !string.IsNullOrEmpty((string)rows[0]["APID_SYMBOL"])) |
564 | 572 |
{ |
565 | 573 |
item.Aveva = new AvevaSymbolInfo(); |
566 |
item.Aveva.X = item.X; |
|
567 |
item.Aveva.Y = SIZE_HEIGHT - item.Y; |
|
574 |
double x = item.X; |
|
575 |
double y = SIZE_HEIGHT - item.Y; |
|
576 |
|
|
577 |
ConvertAvevaPoint(ref x, ref y); |
|
578 |
|
|
579 |
item.Aveva.X = x; |
|
580 |
item.Aveva.Y = y; |
|
581 |
|
|
568 | 582 |
item.Aveva.FullName = (string)rows[0]["APID_SYMBOL"]; |
569 | 583 |
string[] split = item.Aveva.FullName.Split(new char[] { '\\' }); |
570 | 584 |
item.Aveva.Name = split[split.Length - 1]; |
... | ... | |
576 | 590 |
return result; |
577 | 591 |
} |
578 | 592 |
|
593 |
private void ConvertAvevaPoint(ref double x, ref double y) |
|
594 |
{ |
|
595 |
decimal drawingSizeWidth = Convert.ToDecimal(Properties.Settings.Default.DrawingX); |
|
596 |
decimal drawingSizeHeight = Convert.ToDecimal(Properties.Settings.Default.DrawingY); |
|
597 |
decimal id2Width = Convert.ToDecimal(SIZE_WIDTH); |
|
598 |
decimal id2Height = Convert.ToDecimal(SIZE_HEIGHT); |
|
599 |
|
|
600 |
x = Convert.ToDouble(drawingSizeWidth / id2Width * Convert.ToDecimal(x)); |
|
601 |
y = Convert.ToDouble(drawingSizeHeight / id2Height * Convert.ToDecimal(y)); |
|
602 |
} |
|
603 |
|
|
579 | 604 |
#endregion |
580 | 605 |
} |
581 | 606 |
} |
내보내기 Unified diff