hytos / ID2.Manager / ID2.Manager.Compare / Controls / Verification.cs @ 1018a498
이력 | 보기 | 이력해설 | 다운로드 (82.7 KB)
1 | 13a36357 | humkyung | using devDept.Eyeshot; |
---|---|---|---|
2 | using devDept.Eyeshot.Entities; |
||
3 | using devDept.Eyeshot.Translators; |
||
4 | using devDept.Geometry.Entities; |
||
5 | using System; |
||
6 | using System.Collections.Generic; |
||
7 | using System.ComponentModel; |
||
8 | using System.Data; |
||
9 | using System.Drawing; |
||
10 | using System.IO; |
||
11 | using System.Linq; |
||
12 | using System.Runtime.InteropServices; |
||
13 | using System.Text; |
||
14 | using System.Threading.Tasks; |
||
15 | using System.Windows.Forms; |
||
16 | using Telerik.WinControls; |
||
17 | using Telerik.WinControls.UI; |
||
18 | using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf; |
||
19 | using Telerik.Windows.Documents.Fixed.Model; |
||
20 | using Telerik.Windows.Documents.Fixed.Model.Editing; |
||
21 | |||
22 | namespace ID2.Manager.Controls |
||
23 | { |
||
24 | public partial class Verification : UserControl |
||
25 | { |
||
26 | readonly string IniFilePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), |
||
27 | Application.ProductName, $"{Application.ProductName}.ini"); |
||
28 | |||
29 | #region 기본값 |
||
30 | private static string AutoCADLayer { get; } = "AutoCAD"; |
||
31 | 288a94c5 | humkyung | private static string AutoCADDiffLayer { get; } = "AutoCAD_Diff"; |
32 | private static string AutoCADExceptLayer { get; } = "AutoCAD_Except"; |
||
33 | 13a36357 | humkyung | private static Color AutoCADColor = Color.FromArgb(44, 44, 44); |
34 | private static string AVEVALayer { get; } = "AVEVA"; |
||
35 | 288a94c5 | humkyung | private static string AVEVADiffLayer { get; } = "AVEVA_Diff"; |
36 | private static string AVEVAExceptLayer { get; } = "AVEVA_Except"; |
||
37 | 13a36357 | humkyung | private static Color AVEVAColor = Color.FromArgb(44, 44, 44); |
38 | 288ed615 | humkyung | private static string RevCloudLayer { get; } = "RevCloud"; |
39 | 13a36357 | humkyung | private static Color RevCloudColor = Color.Magenta; |
40 | 288ed615 | humkyung | private static Color DiffColor = Color.Yellow; |
41 | |||
42 | 13a36357 | humkyung | private static double Tolerance = 0; |
43 | c4ba621d | humkyung | private static double LengthToleranceRatio { get; set; } = 0.1; |
44 | 13a36357 | humkyung | #endregion |
45 | |||
46 | private RadProgressBarElement _progressBar = null; |
||
47 | |||
48 | public Verification(RadProgressBarElement progressBar) |
||
49 | { |
||
50 | InitializeComponent(); |
||
51 | |||
52 | this.Load += Verification_Load; |
||
53 | this.radSpinEditorTolerance.ValueChanged += RadSpinEditorTolerance_ValueChanged; |
||
54 | this.radColorBoxAutoCADColor.ValueChanged += RadColorBoxAutoCADColor_ValueChanged; |
||
55 | this.radColorBoxAVEVAColor.ValueChanged += RadColorBoxAVEVAColor_ValueChanged; |
||
56 | this.radColorBoxDiffColor.ValueChanged += RadColorBoxDiffColor_ValueChanged; |
||
57 | this.radColorBoxRevCloudColor.ValueChanged += RadColorBoxRevCloudColor_ValueChanged; |
||
58 | |||
59 | this.designAutoCAD.ActionMode = actionType.SelectVisibleByPickDynamic; |
||
60 | this.designAutoCAD.ActiveViewport.CoordinateSystemIcon.Visible = false; |
||
61 | this.designAutoCAD.Selection.ColorDynamic = Color.FromArgb(80, Color.OrangeRed); |
||
62 | this.designAutoCAD.Selection.HaloInnerColor = Color.FromArgb(255, Color.OrangeRed); |
||
63 | this.designAutoCAD.Selection.HaloOuterColor = Color.FromArgb(64, Color.OrangeRed); |
||
64 | this.designAutoCAD.Selection.HaloWidthPolygons = 4; |
||
65 | this.designAutoCAD.Selection.HaloWidthWires = 2; |
||
66 | 288ed615 | humkyung | this.designAutoCAD.ActiveViewport.OriginSymbol.Visible = false; |
67 | b08da970 | humkyung | this.designAutoCAD.SetView(viewType.Trimetric); |
68 | 13a36357 | humkyung | |
69 | this.designAVEVA.ActionMode = actionType.SelectVisibleByPickDynamic; |
||
70 | this.designAVEVA.ActiveViewport.CoordinateSystemIcon.Visible = false; |
||
71 | 288ed615 | humkyung | this.designAVEVA.ActiveViewport.OriginSymbol.Visible = false; |
72 | 13a36357 | humkyung | this.designCompare.ActionMode = actionType.SelectVisibleByPickDynamic; |
73 | this.designCompare.ActiveViewport.CoordinateSystemIcon.Visible = false; |
||
74 | 288ed615 | humkyung | this.designCompare.ActiveViewport.OriginSymbol.Visible = false; |
75 | |||
76 | 288a94c5 | humkyung | this.radCheckedDropDownListAutoCAD.ItemCheckedChanged += RadCheckedDropDownListAutoCAD_ItemCheckedChanged; |
77 | this.radCheckedDropDownListAVEVA.ItemCheckedChanged += RadCheckedDropDownListAVEVA_ItemCheckedChanged; |
||
78 | 288ed615 | humkyung | this.radCheckBoxRevCloud.CheckStateChanged += RadCheckBoxRevCloud_CheckStateChanged; |
79 | 13a36357 | humkyung | |
80 | _progressBar = progressBar; |
||
81 | |||
82 | #region Camera Sync |
||
83 | this.designAutoCAD.ActiveViewport.Rotate.Enabled = false; |
||
84 | this.designAVEVA.ActiveViewport.Rotate.Enabled = false; |
||
85 | this.designCompare.ActiveViewport.Rotate.Enabled = false; |
||
86 | |||
87 | this.designAutoCAD.ActiveViewport.ViewCubeIcon.Visible = false; |
||
88 | this.designAVEVA.ActiveViewport.ViewCubeIcon.Visible = false; |
||
89 | this.designCompare.ActiveViewport.ViewCubeIcon.Visible = false; |
||
90 | |||
91 | this.designAutoCAD.AnimateCamera = false; |
||
92 | this.designAVEVA.AnimateCamera = false; |
||
93 | this.designCompare.AnimateCamera = false; |
||
94 | |||
95 | this.designAutoCAD.CameraChangedFrequency = 200; |
||
96 | this.designAVEVA.CameraChangedFrequency = 200; |
||
97 | this.designCompare.CameraChangedFrequency = 200; |
||
98 | |||
99 | this.designAutoCAD.CameraChanged += CameraChanged; |
||
100 | this.designAVEVA.CameraChanged += CameraChanged; |
||
101 | this.designCompare.CameraChanged += CameraChanged; |
||
102 | #endregion |
||
103 | } |
||
104 | |||
105 | 288a94c5 | humkyung | private void RadCheckedDropDownListAVEVA_ItemCheckedChanged(object sender, RadCheckedListDataItemEventArgs e) |
106 | 288ed615 | humkyung | { |
107 | 288a94c5 | humkyung | var layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == e.Item.Text.ToUpper()); |
108 | if (layer != null) layer.Visible = e.Item.Checked; |
||
109 | 288ed615 | humkyung | this.designCompare.Invalidate(); |
110 | 288a94c5 | humkyung | |
111 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", e.Item.Text, e.Item.Checked.ToString()); |
||
112 | 288ed615 | humkyung | } |
113 | |||
114 | 288a94c5 | humkyung | private void RadCheckedDropDownListAutoCAD_ItemCheckedChanged(object sender, RadCheckedListDataItemEventArgs e) |
115 | 288ed615 | humkyung | { |
116 | 288a94c5 | humkyung | var layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == e.Item.Text.ToUpper()); |
117 | if (layer != null) layer.Visible = e.Item.Checked; |
||
118 | this.designCompare.Invalidate(); |
||
119 | |||
120 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", e.Item.Text, e.Item.Checked.ToString()); |
||
121 | } |
||
122 | |||
123 | private void RadCheckBoxRevCloud_CheckStateChanged(object sender, EventArgs e) |
||
124 | { |
||
125 | var layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.RevCloudLayer.ToUpper()); |
||
126 | 288ed615 | humkyung | if (layer != null) layer.Visible = (sender as RadCheckBox).Checked; |
127 | this.designCompare.Invalidate(); |
||
128 | } |
||
129 | |||
130 | 288a94c5 | humkyung | private void RadCheckBoxAVEVA_CheckStateChanged(object sender, EventArgs e) |
131 | 288ed615 | humkyung | { |
132 | 288a94c5 | humkyung | var layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.AVEVALayer.ToUpper()); |
133 | 288ed615 | humkyung | if (layer != null) layer.Visible = (sender as RadCheckBox).Checked; |
134 | this.designCompare.Invalidate(); |
||
135 | } |
||
136 | |||
137 | 13a36357 | humkyung | /// <summary> |
138 | /// Cloud Mark의 색상을 설정한다. |
||
139 | /// </summary> |
||
140 | /// <param name="sender"></param> |
||
141 | /// <param name="e"></param> |
||
142 | private void RadColorBoxRevCloudColor_ValueChanged(object sender, EventArgs e) |
||
143 | { |
||
144 | Verification.RevCloudColor = this.radColorBoxRevCloudColor.Value; |
||
145 | string color = $"{Verification.RevCloudColor.R},{Verification.RevCloudColor.G},{Verification.RevCloudColor.B}"; |
||
146 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "RevCloudColor", color); |
||
147 | } |
||
148 | |||
149 | /// <summary> |
||
150 | /// 두 도면을 비교하여 결과를 PDF로 출력한다. |
||
151 | /// </summary> |
||
152 | /// <param name="sender"></param> |
||
153 | /// <param name="e"></param> |
||
154 | public void CompareDrawings(IList<Document> docs, bool Save = false) |
||
155 | { |
||
156 | string FileFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), |
||
157 | Application.ProductName, "Compare"); |
||
158 | if (!System.IO.Directory.Exists(FileFolder)) System.IO.Directory.CreateDirectory(FileFolder); |
||
159 | |||
160 | try |
||
161 | { |
||
162 | Size? size = new Size(); |
||
163 | RadFixedDocument FixedDoc = null; |
||
164 | if (Save) |
||
165 | { |
||
166 | size = new Size(1920 * 2, 1080 * 2); |
||
167 | FixedDoc = new RadFixedDocument(); |
||
168 | 288ed615 | humkyung | |
169 | designCompare.ActiveViewport.Background.BottomColor = Color.White; |
||
170 | designCompare.ActiveViewport.Background.TopColor = Color.White; |
||
171 | 13a36357 | humkyung | } |
172 | |||
173 | _progressBar.Maximum = docs.Count(); |
||
174 | _progressBar.Value1 = 0; |
||
175 | foreach (var doc in docs) |
||
176 | { |
||
177 | _progressBar.Text = doc.DocumentNo; |
||
178 | CompareDrawing(doc, Save); |
||
179 | |||
180 | if (Save) |
||
181 | { |
||
182 | using (var bmp = this.designCompare.RenderToBitmap(size.Value)) |
||
183 | { |
||
184 | string FilePath = System.IO.Path.Combine(FileFolder, $"{doc.DocumentNo}.jpg"); |
||
185 | bmp.Save(FilePath, System.Drawing.Imaging.ImageFormat.Jpeg); |
||
186 | |||
187 | var page = FixedDoc.Pages.AddPage(); |
||
188 | page.Size = new Telerik.Documents.Primitives.Size(size.Value.Width, size.Value.Height); |
||
189 | var editor = new FixedContentEditor(page); |
||
190 | using (FileStream fs = new FileStream(FilePath, FileMode.Open)) |
||
191 | { |
||
192 | editor.DrawImage(fs); |
||
193 | } |
||
194 | } |
||
195 | } |
||
196 | |||
197 | _progressBar.Value1 += 1; |
||
198 | Application.DoEvents(); |
||
199 | } |
||
200 | |||
201 | if (Save) |
||
202 | { |
||
203 | RadSaveFileDialog saveFileDialog = new RadSaveFileDialog() |
||
204 | { |
||
205 | Filter = "PDF files (*.pdf)|*.pdf", |
||
206 | RestoreDirectory = true |
||
207 | }; |
||
208 | if (System.Windows.Forms.DialogResult.OK == saveFileDialog.ShowDialog()) |
||
209 | { |
||
210 | string selectedFileName = saveFileDialog.FileName; |
||
211 | |||
212 | // If you are working in a .NET Core application, you will need to also provide an image resolver. You can use the default implementation provided in Telerik.Documents.ImageUtils: |
||
213 | Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver(); |
||
214 | Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver; |
||
215 | |||
216 | var provider = new PdfFormatProvider(); |
||
217 | File.WriteAllBytes(selectedFileName, provider.Export(FixedDoc)); |
||
218 | |||
219 | RadMessageBox.Show("Comparing document is done"); |
||
220 | } |
||
221 | } |
||
222 | } |
||
223 | catch(Exception ex) |
||
224 | { |
||
225 | RadMessageBox.Show(ex.Message); |
||
226 | } |
||
227 | 288ed615 | humkyung | finally |
228 | { |
||
229 | designCompare.ActiveViewport.Background.BottomColor = Color.Black; |
||
230 | designCompare.ActiveViewport.Background.TopColor = Color.Black; |
||
231 | } |
||
232 | 13a36357 | humkyung | } |
233 | |||
234 | /// <summary> |
||
235 | /// 서로 다른 엔터티의 색상을 설정한다. |
||
236 | /// </summary> |
||
237 | /// <param name="sender"></param> |
||
238 | /// <param name="e"></param> |
||
239 | private void RadColorBoxDiffColor_ValueChanged(object sender, EventArgs e) |
||
240 | { |
||
241 | Verification.DiffColor = this.radColorBoxDiffColor.Value; |
||
242 | string color = $"{Verification.DiffColor.R},{Verification.DiffColor.G},{Verification.DiffColor.B}"; |
||
243 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "DiffColor", color); |
||
244 | } |
||
245 | |||
246 | /// <summary> |
||
247 | /// AutoCAD 엔터티의 색상을 설정한다. |
||
248 | /// </summary> |
||
249 | /// <param name="sender"></param> |
||
250 | /// <param name="e"></param> |
||
251 | private void RadColorBoxAutoCADColor_ValueChanged(object sender, EventArgs e) |
||
252 | { |
||
253 | Verification.AutoCADColor = this.radColorBoxAutoCADColor.Value; |
||
254 | string color = $"{Verification.AutoCADColor.R},{Verification.AutoCADColor.G},{Verification.AutoCADColor.B}"; |
||
255 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "AutoCADColor", color); |
||
256 | } |
||
257 | |||
258 | /// <summary> |
||
259 | /// AVEVA 엔터티의 색상을 설정한다. |
||
260 | /// </summary> |
||
261 | /// <param name="sender"></param> |
||
262 | /// <param name="e"></param> |
||
263 | private void RadColorBoxAVEVAColor_ValueChanged(object sender, EventArgs e) |
||
264 | { |
||
265 | Verification.AVEVAColor = this.radColorBoxAVEVAColor.Value; |
||
266 | string color = $"{Verification.AVEVAColor.R},{Verification.AVEVAColor.G},{Verification.AVEVAColor.B}"; |
||
267 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "AVEVAColor", color); |
||
268 | } |
||
269 | |||
270 | /// <summary> |
||
271 | /// 수정한 Tolerance를 시스템에 반영한다. |
||
272 | /// </summary> |
||
273 | /// <param name="sender"></param> |
||
274 | /// <param name="e"></param> |
||
275 | private void RadSpinEditorTolerance_ValueChanged(object sender, EventArgs e) |
||
276 | { |
||
277 | double toler = Convert.ToDouble(this.radSpinEditorTolerance.Value); |
||
278 | Classes.ID2Helper.IniWriteValue(IniFilePath, "Verification", "Tolerance", toler.ToString()); |
||
279 | Verification.Tolerance = toler; |
||
280 | } |
||
281 | |||
282 | private void Verification_Load(object sender, EventArgs e) |
||
283 | { |
||
284 | string Toler = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Tolerance"); |
||
285 | if (!string.IsNullOrEmpty(Toler)) |
||
286 | { |
||
287 | this.radSpinEditorTolerance.Value = Convert.ToDecimal(Toler); |
||
288 | Verification.Tolerance = Convert.ToDouble(this.radSpinEditorTolerance.Value); |
||
289 | } |
||
290 | |||
291 | 288a94c5 | humkyung | string _AutoCADLayer = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", Verification.AutoCADLayer); |
292 | if (!string.IsNullOrEmpty(_AutoCADLayer)) |
||
293 | { |
||
294 | bool Checked = Convert.ToBoolean(_AutoCADLayer); |
||
295 | var item = this.radCheckedDropDownListAutoCAD.Items.FirstOrDefault(x => x.Text == Verification.AutoCADLayer); |
||
296 | if (item is RadCheckedListDataItem CheckedItem) CheckedItem.Checked = Checked; |
||
297 | } |
||
298 | |||
299 | string _AutoCADDiffLayer = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", Verification.AutoCADDiffLayer); |
||
300 | if (!string.IsNullOrEmpty(_AutoCADDiffLayer)) |
||
301 | { |
||
302 | bool Checked = Convert.ToBoolean(_AutoCADDiffLayer); |
||
303 | var item = this.radCheckedDropDownListAutoCAD.Items.FirstOrDefault(x => x.Text == Verification.AutoCADDiffLayer); |
||
304 | if (item is RadCheckedListDataItem CheckedItem) CheckedItem.Checked = Checked; |
||
305 | } |
||
306 | |||
307 | 13a36357 | humkyung | string _AutoCADColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "AutoCADColor"); |
308 | if (!string.IsNullOrEmpty(_AutoCADColor)) |
||
309 | { |
||
310 | var tokens = _AutoCADColor.Split(','); |
||
311 | if (tokens.Length == 3) |
||
312 | { |
||
313 | this.radColorBoxAutoCADColor.Value = |
||
314 | Color.FromArgb(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), Convert.ToInt32(tokens[2])); |
||
315 | } |
||
316 | } |
||
317 | |||
318 | 288a94c5 | humkyung | string _AVEVALayer = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", Verification.AVEVALayer); |
319 | if (!string.IsNullOrEmpty(_AutoCADLayer)) |
||
320 | { |
||
321 | bool Checked = Convert.ToBoolean(_AVEVALayer); |
||
322 | var item = this.radCheckedDropDownListAVEVA.Items.FirstOrDefault(x => x.Text == Verification.AVEVALayer); |
||
323 | if (item is RadCheckedListDataItem CheckedItem) CheckedItem.Checked = Checked; |
||
324 | } |
||
325 | |||
326 | string _AVEVADiffLayer = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", Verification.AVEVADiffLayer); |
||
327 | if (!string.IsNullOrEmpty(_AVEVADiffLayer)) |
||
328 | { |
||
329 | bool Checked = Convert.ToBoolean(_AVEVADiffLayer); |
||
330 | var item = this.radCheckedDropDownListAVEVA.Items.FirstOrDefault(x => x.Text == Verification.AVEVADiffLayer); |
||
331 | if (item is RadCheckedListDataItem CheckedItem) CheckedItem.Checked = Checked; |
||
332 | } |
||
333 | |||
334 | 13a36357 | humkyung | string _AVEVAColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "AVEVAColor"); |
335 | if (!string.IsNullOrEmpty(_AVEVAColor)) |
||
336 | { |
||
337 | var tokens = _AVEVAColor.Split(','); |
||
338 | if (tokens.Length == 3) |
||
339 | { |
||
340 | this.radColorBoxAVEVAColor.Value = |
||
341 | Color.FromArgb(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), Convert.ToInt32(tokens[2])); |
||
342 | } |
||
343 | } |
||
344 | |||
345 | string _DiffColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "DiffColor"); |
||
346 | if (!string.IsNullOrEmpty(_DiffColor)) |
||
347 | { |
||
348 | var tokens = _DiffColor.Split(','); |
||
349 | if (tokens.Length == 3) |
||
350 | { |
||
351 | this.radColorBoxDiffColor.Value = |
||
352 | Color.FromArgb(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), Convert.ToInt32(tokens[2])); |
||
353 | } |
||
354 | } |
||
355 | |||
356 | string _RevCloudColor = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "RevCloudColor"); |
||
357 | if (!string.IsNullOrEmpty(_RevCloudColor)) |
||
358 | { |
||
359 | var tokens = _RevCloudColor.Split(','); |
||
360 | if (tokens.Length == 3) |
||
361 | { |
||
362 | this.radColorBoxRevCloudColor.Value = |
||
363 | Color.FromArgb(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), Convert.ToInt32(tokens[2])); |
||
364 | } |
||
365 | } |
||
366 | |||
367 | c4ba621d | humkyung | string _LengthToleranceRatio = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Length Tolerance Ratio"); |
368 | if (!string.IsNullOrEmpty(_LengthToleranceRatio)) |
||
369 | { |
||
370 | LengthToleranceRatio = Convert.ToDouble(_LengthToleranceRatio); |
||
371 | } |
||
372 | |||
373 | 51b9a24a | humkyung | string _ArrowMaxLength = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Arrow Max Length"); |
374 | if (!string.IsNullOrEmpty(_ArrowMaxLength)) |
||
375 | { |
||
376 | Forms.ExceptLayer.ArrowMaxLength = Convert.ToDouble(_ArrowMaxLength); |
||
377 | } |
||
378 | |||
379 | 13a36357 | humkyung | #region Except Layer를 로딩한다. |
380 | 4b369ce1 | humkyung | LoadLayerSettings(); |
381 | #endregion |
||
382 | } |
||
383 | |||
384 | /// <summary> |
||
385 | /// 레이어 설정을 읽는다. |
||
386 | /// </summary> |
||
387 | public void LoadLayerSettings() |
||
388 | { |
||
389 | Forms.ExceptLayer.ExceptLayers.Clear(); |
||
390 | 288ed615 | humkyung | Forms.ExceptLayer.LineLayers.Clear(); |
391 | 4b369ce1 | humkyung | |
392 | 13a36357 | humkyung | string _ExceptLayers = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Except Layers"); |
393 | if (!string.IsNullOrEmpty(_ExceptLayers)) |
||
394 | { |
||
395 | Forms.ExceptLayer.ExceptLayers.AddRange(_ExceptLayers.Split(',').ToList().ConvertAll(x => new Forms.ExceptLayer.Layer(x))); |
||
396 | |||
397 | string _ExceptLayersVisible = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Except Layers Visible"); |
||
398 | if (!string.IsNullOrEmpty(_ExceptLayersVisible)) |
||
399 | { |
||
400 | var tokens = _ExceptLayersVisible.Split(',').ToList().ConvertAll(x => Convert.ToBoolean(x)); |
||
401 | for (int i = 0; i < Forms.ExceptLayer.ExceptLayers.Count; ++i) |
||
402 | { |
||
403 | if (i < tokens.Count) |
||
404 | { |
||
405 | Forms.ExceptLayer.ExceptLayers[i].Visible = tokens[i]; |
||
406 | } |
||
407 | } |
||
408 | } |
||
409 | } |
||
410 | 288ed615 | humkyung | |
411 | string _LineLayers = Classes.ID2Helper.IniReadValue(IniFilePath, "Verification", "Line Layers"); |
||
412 | if (!string.IsNullOrEmpty(_LineLayers)) |
||
413 | { |
||
414 | Forms.ExceptLayer.LineLayers.AddRange(_LineLayers.Split(',').ToList().ConvertAll(x => new Forms.ExceptLayer.Layer(x))); |
||
415 | } |
||
416 | 13a36357 | humkyung | } |
417 | |||
418 | /// <summary> |
||
419 | /// 엔터티들의 색상을 바꾼다. |
||
420 | /// </summary> |
||
421 | /// <param name="design"></param> |
||
422 | /// <param name="list"></param> |
||
423 | public void ColorEntities(Design design, IList<Entity> list, Color color, colorMethodType colorMethod=colorMethodType.byEntity, bool ChangeBlkColor=true) |
||
424 | { |
||
425 | foreach (Entity ent in list) |
||
426 | { |
||
427 | ColorEntity(design, ent, color, colorMethod, ChangeBlkColor); |
||
428 | } |
||
429 | } |
||
430 | |||
431 | /// <summary> |
||
432 | /// 엔터티의 색상을 변경한다. |
||
433 | /// </summary> |
||
434 | /// <param name="design"></param> |
||
435 | /// <param name="entity"></param> |
||
436 | /// <param name="color"></param> |
||
437 | private void ColorEntity(Design design, Entity entity, Color color, colorMethodType colorMethod = colorMethodType.byEntity, |
||
438 | bool ChangeBlkColor = true) |
||
439 | { |
||
440 | if (entity is BlockReference blkref) |
||
441 | { |
||
442 | blkref.Color = color; |
||
443 | blkref.ColorMethod = colorMethod; |
||
444 | |||
445 | if (ChangeBlkColor) |
||
446 | { |
||
447 | var blk = design.Blocks.FirstOrDefault(x => x.Name == blkref.BlockName); |
||
448 | if (blk != null) |
||
449 | { |
||
450 | ColorEntities(design, blk.Entities, color, colorMethodType.byParent); |
||
451 | foreach (var attr in blkref.Attributes.Values) |
||
452 | { |
||
453 | attr.Color = color; |
||
454 | attr.ColorMethod = colorMethodType.byParent; |
||
455 | } |
||
456 | } |
||
457 | } |
||
458 | } |
||
459 | else |
||
460 | { |
||
461 | entity.Color = color; |
||
462 | entity.ColorMethod = colorMethod; |
||
463 | } |
||
464 | } |
||
465 | |||
466 | 3f59180e | humkyung | /// <summary> |
467 | /// 블럭 참조를 깨어 블럭의 구성 요소들을 리트스트 리턴한다. |
||
468 | /// </summary> |
||
469 | /// <param name="design"></param> |
||
470 | /// <param name="blkref"></param> |
||
471 | /// <param name="LayerName"></param> |
||
472 | /// <param name="color"></param> |
||
473 | /// <returns></returns> |
||
474 | private List<Entity> ExplodeBlockReference(BlockKeyedCollection Blocks, BlockReference blkref, string LayerName, Color color) |
||
475 | c4ba621d | humkyung | { |
476 | var res = new List<Entity>(); |
||
477 | |||
478 | 3f59180e | humkyung | var entities = blkref.Explode(Blocks); |
479 | c4ba621d | humkyung | entities.ToList().ForEach(y => |
480 | { |
||
481 | b08da970 | humkyung | #region 블럭 이름이 ARROW로 시작되는 경우 Hatch로 화살표를 그려준다. |
482 | if (y is LinearPath arrow && arrow.Vertices.Length == 2 && blkref.BlockName.StartsWith("ARROW")) |
||
483 | { |
||
484 | double weight = arrow.LineWeight * blkref.GetScaleFactorY(); |
||
485 | var dir = new devDept.Geometry.Vector3D(arrow.Vertices[0], arrow.Vertices[1]); |
||
486 | dir.Normalize(); |
||
487 | var cross = devDept.Geometry.Vector3D.Cross(devDept.Geometry.Vector3D.AxisZ, dir); |
||
488 | var pts = new devDept.Geometry.Point3D[] |
||
489 | { |
||
490 | arrow.Vertices[1] + cross * weight * 0.5, |
||
491 | arrow.Vertices[0], |
||
492 | arrow.Vertices[1] - cross * weight * 0.5 |
||
493 | }; |
||
494 | |||
495 | var hatch = new Hatch("SOLID", new List<ICurve>() { new LinearPath(pts)}); |
||
496 | res.Add(hatch); |
||
497 | } |
||
498 | #endregion |
||
499 | else if (y is LinearPath lp) |
||
500 | c4ba621d | humkyung | { |
501 | int count = Convert.ToInt32(lp.Vertices.Length); |
||
502 | for (int i = 0; i < count - 1; ++i) |
||
503 | { |
||
504 | var line = new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1]) |
||
505 | { |
||
506 | LayerName = lp.LayerName, |
||
507 | LineWeight = lp.LineWeight, |
||
508 | LineTypeMethod = colorMethodType.byEntity, |
||
509 | 1f75c4f0 | humkyung | Color = lp.Color, |
510 | c4ba621d | humkyung | ColorMethod = colorMethodType.byEntity |
511 | }; |
||
512 | res.Add(line); |
||
513 | } |
||
514 | } |
||
515 | a8e46eba | humkyung | /// PORT, ARROW로 시작하는 블럭은 제외 |
516 | b08da970 | humkyung | else if(y is BlockReference subblkref && subblkref.BlockName != "PORT") |
517 | c4ba621d | humkyung | { |
518 | 3f59180e | humkyung | res.AddRange(ExplodeBlockReference(Blocks, subblkref, LayerName, color)); |
519 | c4ba621d | humkyung | } |
520 | }); |
||
521 | |||
522 | var attributes = blkref.Attributes; |
||
523 | 1f75c4f0 | humkyung | foreach (var ent in entities.Where(y => y is devDept.Eyeshot.Entities.Attribute attr && !attr.Invisible)) |
524 | c4ba621d | humkyung | { |
525 | var txt = ent as devDept.Eyeshot.Entities.Attribute; |
||
526 | 1f75c4f0 | humkyung | #region 텍스트가 뒤집어지는 것을 방지하기 위해 평면을 교체 |
527 | af504a98 | humkyung | if (txt.Plane.AxisX.Equals(devDept.Geometry.Vector3D.AxisMinusX) && txt.Plane.AxisY.Equals(devDept.Geometry.Vector3D.AxisY)) |
528 | { |
||
529 | txt.Plane = new devDept.Geometry.Plane(txt.Plane.Origin, devDept.Geometry.Vector3D.AxisX, devDept.Geometry.Vector3D.AxisY); |
||
530 | } |
||
531 | 1f75c4f0 | humkyung | #endregion |
532 | c4ba621d | humkyung | txt.LayerName = LayerName; |
533 | txt.Color = color; |
||
534 | txt.ColorMethod = colorMethodType.byEntity; |
||
535 | KeyValuePair<string, AttributeReference>? kp = attributes.FirstOrDefault(z => z.Key == txt.TextString); |
||
536 | if (kp.HasValue) txt.TextString = (kp.Value.Value) != null ? kp.Value.Value.Value : string.Empty; |
||
537 | } |
||
538 | |||
539 | res.AddRange(entities.Where(y => |
||
540 | { |
||
541 | 1f75c4f0 | humkyung | if (y is devDept.Eyeshot.Entities.Attribute attr && (string.IsNullOrEmpty(attr.TextString) || attr.Invisible)) return false; |
542 | c4ba621d | humkyung | if (y is devDept.Eyeshot.Entities.Text text && string.IsNullOrEmpty(text.TextString)) return false; |
543 | a8e46eba | humkyung | if (y is devDept.Eyeshot.Entities.Point) return false; |
544 | b08da970 | humkyung | if (y is BlockReference subblkref) return false; |
545 | c4ba621d | humkyung | if (y is LinearPath) return false; |
546 | 3f59180e | humkyung | if (y.LayerName.ToUpper() == "AS_PORT") return false; |
547 | c4ba621d | humkyung | return true; |
548 | })); |
||
549 | |||
550 | 3f59180e | humkyung | #region 제외 레이어에 속한 항목은 포함하지 않는다. |
551 | res.RemoveAll(x => |
||
552 | { |
||
553 | return Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible); |
||
554 | }); |
||
555 | #endregion |
||
556 | foreach (var ent in res) ent.LayerName = LayerName; |
||
557 | |||
558 | c4ba621d | humkyung | blkref.Attributes.Clear(); |
559 | 3f59180e | humkyung | ///blkref.UpdateBoundingBox(new TraversalParams(design)); |
560 | c4ba621d | humkyung | |
561 | return res; |
||
562 | } |
||
563 | |||
564 | 13a36357 | humkyung | /// <summary> |
565 | /// 주어진 도면의 원본과 AVEVA를 비교한다. |
||
566 | /// </summary> |
||
567 | private void CompareDrawing(Document doc, bool ResultOnly = false) |
||
568 | { |
||
569 | /// AutoCAD P&ID 파일을 화면에 표시한다. |
||
570 | void ShowAutoCADFile(string FilePath, Design design, bool clear = true) |
||
571 | { |
||
572 | if (clear) design.Clear(); |
||
573 | 3f59180e | humkyung | var AddEntities = new List<Entity>(); |
574 | |||
575 | 13a36357 | humkyung | if (System.IO.File.Exists(FilePath)) |
576 | { |
||
577 | try |
||
578 | { |
||
579 | 3f59180e | humkyung | #region 다른 프로세스에서 파일을 열고 있는 경우 처리 |
580 | using (var fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) |
||
581 | #endregion |
||
582 | |||
583 | 13a36357 | humkyung | { |
584 | 3f59180e | humkyung | devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(fs); |
585 | ra.DoWork(); |
||
586 | var min = ra.Min; |
||
587 | if (!ra.Layers.Contains(Verification.AutoCADLayer)) ra.Layers.Add(Verification.AutoCADLayer, Verification.AutoCADColor); |
||
588 | 288a94c5 | humkyung | if (!ra.Layers.Contains(Verification.AutoCADDiffLayer)) ra.Layers.Add(Verification.AutoCADDiffLayer, Verification.DiffColor); |
589 | if (!ra.Layers.Contains(Verification.AutoCADExceptLayer)) ra.Layers.Add(Verification.AutoCADExceptLayer, Verification.AutoCADColor); |
||
590 | 3f59180e | humkyung | foreach (var ent in ra.Entities) |
591 | { |
||
592 | /// 도면을 원점으로 맞춘다. |
||
593 | if (min.X != 0 && min.Y != 0) ent.Translate(-min.X, -min.Y); |
||
594 | |||
595 | b08da970 | humkyung | if (ent is BlockReference blkref) |
596 | 3f59180e | humkyung | { |
597 | AddEntities.AddRange(ExplodeBlockReference(ra.Blocks, blkref, Verification.AutoCADLayer, Verification.AutoCADColor)); |
||
598 | } |
||
599 | } |
||
600 | ra.AddToScene(design); |
||
601 | 13a36357 | humkyung | } |
602 | } |
||
603 | catch (Exception ex) |
||
604 | { |
||
605 | RadMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, RadMessageIcon.Error); |
||
606 | return; |
||
607 | } |
||
608 | |||
609 | 288ed615 | humkyung | #region LinearPath를 Line으로 분할한다. |
610 | design.Entities.ForEach(x => |
||
611 | 13a36357 | humkyung | { |
612 | if (x is LinearPath lp) |
||
613 | { |
||
614 | 51b9a24a | humkyung | #region 정점 수가 2이고 LineWeight이 0 초과이고 길이가 ArrowMaxLength보다 작을때 화살표를 그려준다. |
615 | if (lp.Vertices.Count() == 2 && lp.LineWeight > 0 && lp.Length() < Forms.ExceptLayer.ArrowMaxLength) |
||
616 | 13a36357 | humkyung | { |
617 | 51b9a24a | humkyung | double weight = lp.LineWeight; |
618 | var dir = new devDept.Geometry.Vector3D(lp.Vertices[0], lp.Vertices[1]); |
||
619 | dir.Normalize(); |
||
620 | var cross = devDept.Geometry.Vector3D.Cross(devDept.Geometry.Vector3D.AxisZ, dir); |
||
621 | var pts = new devDept.Geometry.Point3D[] |
||
622 | 13a36357 | humkyung | { |
623 | 51b9a24a | humkyung | lp.Vertices[1] + cross * weight * 0.5, |
624 | lp.Vertices[0], |
||
625 | lp.Vertices[1] - cross * weight * 0.5 |
||
626 | }; |
||
627 | |||
628 | var hatch = new Hatch("SOLID", new List<ICurve>() { new LinearPath(pts) }); |
||
629 | AddEntities.Add(hatch); |
||
630 | } |
||
631 | #endregion |
||
632 | else |
||
633 | { |
||
634 | int count = Convert.ToInt32(lp.Vertices.Length); |
||
635 | for (int i = 0; i < count - 1; ++i) |
||
636 | { |
||
637 | AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1]) |
||
638 | { |
||
639 | LayerName = lp.LayerName, |
||
640 | LineWeight = lp.LineWeight, |
||
641 | LineTypeMethod = colorMethodType.byEntity |
||
642 | }); |
||
643 | } |
||
644 | 13a36357 | humkyung | } |
645 | } |
||
646 | }); |
||
647 | 288ed615 | humkyung | design.Entities.RemoveAll(x => (x is LinearPath)); |
648 | #endregion |
||
649 | 13a36357 | humkyung | |
650 | 1f75c4f0 | humkyung | design.Entities.AddRange(AddEntities); |
651 | |||
652 | 288ed615 | humkyung | #region 브랜치가 생성되는 부분에서 파이프 라인을 분할 |
653 | var queue = design.Entities.Where(x => x is Line && |
||
654 | Forms.ExceptLayer.LineLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper())).ToList(); |
||
655 | 13a36357 | humkyung | while (queue.Any()) |
656 | { |
||
657 | var line1 = queue.First() as Line; |
||
658 | var dir1 = line1.Direction; |
||
659 | dir1.Normalize(); |
||
660 | queue.Remove(line1); |
||
661 | for (int i = 0; i < queue.Count; ++i) |
||
662 | { |
||
663 | var line2 = queue.ElementAt(i) as Line; |
||
664 | var dir2 = line2.Direction; |
||
665 | dir2.Normalize(); |
||
666 | if (devDept.Geometry.Vector3D.AreOrthogonal(dir1, dir2)) |
||
667 | { |
||
668 | var intersects = line1.IntersectWith(line2); |
||
669 | if (intersects.Count() == 1) |
||
670 | { |
||
671 | if (line1.StartPoint.DistanceTo(intersects[0]) > 0.1 && line1.EndPoint.DistanceTo(intersects[0]) > 0.1) |
||
672 | { |
||
673 | var split1 = new devDept.Eyeshot.Entities.Line(line1.StartPoint, intersects[0]) |
||
674 | { |
||
675 | LayerName = line1.LayerName, |
||
676 | LineWeight = line1.LineWeight, |
||
677 | LineTypeMethod = colorMethodType.byEntity |
||
678 | }; |
||
679 | var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line1.EndPoint) |
||
680 | { |
||
681 | LayerName = line1.LayerName, |
||
682 | LineWeight = line1.LineWeight, |
||
683 | LineTypeMethod = colorMethodType.byEntity |
||
684 | }; |
||
685 | design.Entities.Add(split1); |
||
686 | design.Entities.Add(split2); |
||
687 | design.Entities.Remove(line1); |
||
688 | |||
689 | queue.Add(split1); |
||
690 | queue.Add(split2); |
||
691 | |||
692 | break; |
||
693 | } |
||
694 | |||
695 | if (line2.StartPoint.DistanceTo(intersects[0]) > 0.1 && line2.EndPoint.DistanceTo(intersects[0]) > 0.1) |
||
696 | { |
||
697 | var split1 = new devDept.Eyeshot.Entities.Line(line2.StartPoint, intersects[0]) |
||
698 | { |
||
699 | LayerName = line2.LayerName, |
||
700 | LineWeight = line2.LineWeight, |
||
701 | LineTypeMethod = colorMethodType.byEntity |
||
702 | }; |
||
703 | var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line2.EndPoint) |
||
704 | { |
||
705 | LayerName = line2.LayerName, |
||
706 | LineWeight = line2.LineWeight, |
||
707 | LineTypeMethod = colorMethodType.byEntity |
||
708 | }; |
||
709 | design.Entities.Add(split1); |
||
710 | design.Entities.Add(split2); |
||
711 | design.Entities.Remove(line2); |
||
712 | |||
713 | queue.Remove(line2); |
||
714 | queue.Add(split1); |
||
715 | queue.Add(split2); |
||
716 | } |
||
717 | } |
||
718 | } |
||
719 | } |
||
720 | } |
||
721 | #endregion |
||
722 | |||
723 | 288ed615 | humkyung | #region 레이어 변경 |
724 | foreach (var ent in design.Entities) |
||
725 | { |
||
726 | ent.Color = Verification.AutoCADColor; |
||
727 | ent.ColorMethod = colorMethodType.byEntity; |
||
728 | if (!Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == ent.LayerName.ToUpper())) |
||
729 | { |
||
730 | ent.LayerName = Verification.AutoCADLayer; |
||
731 | } |
||
732 | 288a94c5 | humkyung | else |
733 | { |
||
734 | ent.LayerName = Verification.AutoCADExceptLayer; |
||
735 | } |
||
736 | 288ed615 | humkyung | } |
737 | #endregion |
||
738 | |||
739 | 3f59180e | humkyung | #region 블럭이거나 제외 레이어에 속한 항목은 제거 |
740 | 288ed615 | humkyung | design.Entities.RemoveAll(x => (x is BlockReference) || Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible)); |
741 | 3f59180e | humkyung | #endregion |
742 | c4ba621d | humkyung | |
743 | #region 눈에 보이지 않는 라인은 제거 |
||
744 | design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001); |
||
745 | #endregion |
||
746 | 288ed615 | humkyung | |
747 | 13a36357 | humkyung | ColorEntities(design, design.Entities, Verification.AutoCADColor); |
748 | |||
749 | // Sets the view as Top |
||
750 | design.SetView(viewType.Top); |
||
751 | design.ZoomFit(); |
||
752 | design.Invalidate(); |
||
753 | } |
||
754 | } |
||
755 | |||
756 | /// AVEVA P&ID 파일을 화면에 표시한다. |
||
757 | void ShowAVEVAPIDFile(string FilePath, Design design, bool clear = true) |
||
758 | { |
||
759 | if (clear) design.Clear(); |
||
760 | if (System.IO.File.Exists(FilePath)) |
||
761 | { |
||
762 | 288ed615 | humkyung | var AddEntities = new List<Entity>(); |
763 | |||
764 | 3f59180e | humkyung | #region 다른 프로세스에서 파일을 열고 있는 경우 처리 |
765 | using (var fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) |
||
766 | #endregion |
||
767 | 13a36357 | humkyung | { |
768 | 3f59180e | humkyung | devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(fs); |
769 | ra.DoWork(); |
||
770 | 13a36357 | humkyung | |
771 | 3f59180e | humkyung | if (!ra.Layers.Contains(Verification.AVEVALayer)) ra.Layers.Add(Verification.AVEVALayer, Verification.AVEVAColor); |
772 | 288a94c5 | humkyung | if (!ra.Layers.Contains(Verification.AVEVADiffLayer)) ra.Layers.Add(Verification.AVEVADiffLayer, Verification.DiffColor); |
773 | if (!ra.Layers.Contains(Verification.AVEVAExceptLayer)) ra.Layers.Add(Verification.AVEVAExceptLayer, Verification.AVEVAColor); |
||
774 | 3f59180e | humkyung | var min = ra.Min; |
775 | foreach (var ent in ra.Entities) |
||
776 | 13a36357 | humkyung | { |
777 | 3f59180e | humkyung | /// 도면을 원점으로 맞춘다. |
778 | if (min.X != 0 && min.Y != 0) ent.Translate(-min.X, -min.Y); |
||
779 | |||
780 | #region 멀티 라인들을 분할하여 추가한다. |
||
781 | if (ent is Mesh mesh && (mesh.LayerName == "AS_PIPE" || mesh.LayerName == "AS_INST")) |
||
782 | 13a36357 | humkyung | { |
783 | 3f59180e | humkyung | int count = Convert.ToInt32(mesh.Vertices.Length * 0.5); |
784 | for (int i = 0; i < count - 1; ++i) |
||
785 | 13a36357 | humkyung | { |
786 | 3f59180e | humkyung | AddEntities.Add(new devDept.Eyeshot.Entities.Line(mesh.Vertices[i], mesh.Vertices[i + 1]) |
787 | 13a36357 | humkyung | { |
788 | 288ed615 | humkyung | LayerName = Verification.AVEVALayer, |
789 | 13a36357 | humkyung | LineWeight = 3.0f, |
790 | LineTypeMethod = colorMethodType.byEntity, |
||
791 | Color = Verification.AVEVAColor, |
||
792 | ColorMethod = colorMethodType.byEntity |
||
793 | 3f59180e | humkyung | }); |
794 | } |
||
795 | 13a36357 | humkyung | } |
796 | 3f59180e | humkyung | else if (ent is TabulatedSurface tf && (tf.LayerName == "AS_PIPE" || tf.LayerName == "AS_INST")) |
797 | 13a36357 | humkyung | { |
798 | 3f59180e | humkyung | int count = Convert.ToInt32(tf.ControlPoints.Length * 0.5); |
799 | for (int i = 0; i < count - 1; ++i) |
||
800 | 13a36357 | humkyung | { |
801 | 3f59180e | humkyung | AddEntities.Add( |
802 | new devDept.Eyeshot.Entities.Line( |
||
803 | new devDept.Geometry.Point3D(tf.ControlPoints[i, 0].X, tf.ControlPoints[i, 0].Y, 0), |
||
804 | new devDept.Geometry.Point3D(tf.ControlPoints[i + 1, 0].X, tf.ControlPoints[i + 1, 0].Y, 0)) |
||
805 | { |
||
806 | LayerName = Verification.AVEVALayer, |
||
807 | LineWeight = 3.0f, |
||
808 | LineTypeMethod = colorMethodType.byEntity, |
||
809 | Color = Verification.AVEVAColor, |
||
810 | ColorMethod = colorMethodType.byEntity |
||
811 | } |
||
812 | ); |
||
813 | } |
||
814 | } |
||
815 | else if (ent is LinearPath lp) |
||
816 | { |
||
817 | 288a94c5 | humkyung | string LayerName = Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == lp.LayerName.ToUpper()) ? |
818 | Verification.AVEVAExceptLayer : Verification.AVEVALayer; |
||
819 | 3f59180e | humkyung | int count = Convert.ToInt32(lp.Vertices.Length); |
820 | for (int i = 0; i < count - 1; ++i) |
||
821 | { |
||
822 | AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1]) |
||
823 | { |
||
824 | 288a94c5 | humkyung | LayerName = LayerName, |
825 | 3f59180e | humkyung | LineWeight = lp.LineWeight, |
826 | Color = Verification.AVEVAColor, |
||
827 | LineTypeMethod = colorMethodType.byEntity |
||
828 | }); |
||
829 | } |
||
830 | b08da970 | humkyung | |
831 | #region 밑에서 제거하기 위해 레이어를 AVEVALayer로 바꿔준다. |
||
832 | lp.LayerName = Verification.AVEVALayer; |
||
833 | #endregion |
||
834 | 3f59180e | humkyung | } |
835 | #endregion |
||
836 | else if (ent is BlockReference blkref) |
||
837 | { |
||
838 | b08da970 | humkyung | if (blkref.BlockName != "LBRK" && blkref.BlockName != "PSNODE" && blkref.BlockName != "PENODE") |
839 | 3f59180e | humkyung | { |
840 | AddEntities.AddRange(ExplodeBlockReference(ra.Blocks, blkref, Verification.AVEVALayer, Verification.AVEVAColor)); |
||
841 | } |
||
842 | 13a36357 | humkyung | } |
843 | 288ed615 | humkyung | |
844 | 3f59180e | humkyung | ent.Color = Verification.AVEVAColor; |
845 | ent.ColorMethod = colorMethodType.byEntity; |
||
846 | if (!Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == ent.LayerName.ToUpper())) |
||
847 | { |
||
848 | ent.LayerName = Verification.AVEVALayer; |
||
849 | } |
||
850 | 288a94c5 | humkyung | else |
851 | { |
||
852 | ent.LayerName = Verification.AVEVAExceptLayer; |
||
853 | } |
||
854 | 288ed615 | humkyung | } |
855 | 3f59180e | humkyung | ra.AddToScene(design); |
856 | 288ed615 | humkyung | } |
857 | |||
858 | c4ba621d | humkyung | #region 불필요한 블럭들은 제거 |
859 | 3f59180e | humkyung | design.Entities.RemoveAll(x => x is BlockReference); |
860 | c4ba621d | humkyung | #endregion |
861 | |||
862 | 288ed615 | humkyung | #region 블럭을 깸 |
863 | design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList().ForEach(x => |
||
864 | { |
||
865 | if(x is BlockReference blkref) |
||
866 | 13a36357 | humkyung | { |
867 | 3f59180e | humkyung | AddEntities.AddRange(ExplodeBlockReference(design.Blocks, blkref, Verification.AVEVALayer, Verification.AVEVAColor)); |
868 | 13a36357 | humkyung | } |
869 | }); |
||
870 | design.Entities.RemoveAll(x => |
||
871 | 288ed615 | humkyung | ((x is Mesh || x is TabulatedSurface) && (x.LayerName == Verification.AVEVALayer)) || |
872 | (x is LinearPath && x.LayerName == Verification.AVEVALayer) || (x is BlockReference) || |
||
873 | 13a36357 | humkyung | Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible)); |
874 | design.Entities.AddRange(AddEntities); |
||
875 | #endregion |
||
876 | |||
877 | c4ba621d | humkyung | #region 눈에 보이지 않는 라인은 제거 |
878 | design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001); |
||
879 | 13a36357 | humkyung | #endregion |
880 | |||
881 | c4ba621d | humkyung | ColorEntities(design, design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList(), Verification.AVEVAColor); |
882 | |||
883 | 13a36357 | humkyung | design.SetView(viewType.Top); |
884 | design.ZoomFit(); |
||
885 | design.Invalidate(); |
||
886 | } |
||
887 | } |
||
888 | |||
889 | string dwgExtension = ".dwg"; |
||
890 | string ID2DrawingFolder = Program.AutoCADFolder; |
||
891 | string dwgFilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{doc.DocumentNo}{dwgExtension}"); |
||
892 | if (!ResultOnly) ShowAutoCADFile(dwgFilePath, this.designAutoCAD); |
||
893 | ShowAutoCADFile(dwgFilePath, this.designCompare); |
||
894 | |||
895 | string AVEVAPIDFolder = Program.AVEVAPIDFolder; |
||
896 | string AVEVAPIDFilePath = string.Empty; |
||
897 | if (AVEVAPIDFolder != null) |
||
898 | { |
||
899 | AVEVAPIDFilePath = System.IO.Path.Combine(AVEVAPIDFolder, $"{doc.DocumentNo}{dwgExtension}"); |
||
900 | if (!ResultOnly) ShowAVEVAPIDFile(AVEVAPIDFilePath, this.designAVEVA); |
||
901 | ShowAVEVAPIDFile(AVEVAPIDFilePath, this.designCompare, false); |
||
902 | } |
||
903 | |||
904 | if (System.IO.File.Exists(dwgFilePath) && System.IO.File.Exists(AVEVAPIDFilePath)) |
||
905 | { |
||
906 | var AutoCADEntities = this.designCompare.Entities.Where(x => x.LayerName == Verification.AutoCADLayer).ToList(); |
||
907 | var AVEVAtities = this.designCompare.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList(); |
||
908 | CompareAndMark(this.designCompare, AutoCADEntities, this.designCompare, AVEVAtities); |
||
909 | } |
||
910 | 51b9a24a | humkyung | |
911 | 288a94c5 | humkyung | var others = this.designCompare.Entities.Where(x => |
912 | { |
||
913 | return (x.LayerName != Verification.AVEVALayer && x.LayerName != Verification.AVEVADiffLayer && |
||
914 | x.LayerName != Verification.AutoCADLayer && x.LayerName != Verification.AutoCADDiffLayer && |
||
915 | x.LayerName != Verification.RevCloudLayer); |
||
916 | }).ToList(); |
||
917 | |||
918 | others.ForEach(x => |
||
919 | { |
||
920 | if (x.LayerName == Verification.AutoCADExceptLayer) |
||
921 | x.LayerName = Verification.AutoCADLayer; |
||
922 | else if (x.LayerName == Verification.AVEVAExceptLayer) |
||
923 | x.LayerName = Verification.AVEVALayer; |
||
924 | }); |
||
925 | |||
926 | 51b9a24a | humkyung | #region 레이어 설정 적용 |
927 | var layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.RevCloudLayer.ToUpper()); |
||
928 | if (layer != null) layer.Visible = this.radCheckBoxRevCloud.Checked; |
||
929 | |||
930 | layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.AVEVALayer.ToUpper()); |
||
931 | 288a94c5 | humkyung | if (layer != null) |
932 | { |
||
933 | var item = this.radCheckedDropDownListAVEVA.Items.FirstOrDefault(x => x.Text.ToUpper() == Verification.AVEVALayer.ToUpper()); |
||
934 | if (item is RadCheckedListDataItem CheckedItem) layer.Visible = CheckedItem.Checked; |
||
935 | } |
||
936 | |||
937 | layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.AVEVADiffLayer.ToUpper()); |
||
938 | if (layer != null) |
||
939 | { |
||
940 | var item = this.radCheckedDropDownListAVEVA.Items.FirstOrDefault(x => x.Text.ToUpper() == Verification.AVEVADiffLayer.ToUpper()); |
||
941 | if (item is RadCheckedListDataItem CheckedItem) layer.Visible = CheckedItem.Checked; |
||
942 | } |
||
943 | 51b9a24a | humkyung | |
944 | layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.AutoCADLayer.ToUpper()); |
||
945 | 288a94c5 | humkyung | if (layer != null) |
946 | { |
||
947 | var item = this.radCheckedDropDownListAutoCAD.Items.FirstOrDefault(x => x.Text.ToUpper() == Verification.AutoCADLayer.ToUpper()); |
||
948 | if(item is RadCheckedListDataItem CheckedItem) layer.Visible = CheckedItem.Checked; |
||
949 | } |
||
950 | |||
951 | layer = this.designCompare.Layers.FirstOrDefault(x => x.Name.ToUpper() == Verification.AutoCADDiffLayer.ToUpper()); |
||
952 | if (layer != null) |
||
953 | { |
||
954 | var item = this.radCheckedDropDownListAutoCAD.Items.FirstOrDefault(x => x.Text.ToUpper() == Verification.AutoCADDiffLayer.ToUpper()); |
||
955 | if(item is RadCheckedListDataItem CheckedItem) layer.Visible = CheckedItem.Checked; |
||
956 | } |
||
957 | 51b9a24a | humkyung | |
958 | this.designCompare.Invalidate(); |
||
959 | #endregion |
||
960 | 13a36357 | humkyung | } |
961 | |||
962 | /// <summary> |
||
963 | /// 주어진 두 엔터티 리스트를 비교하여 틀린 엔터티의 색상을 설정한 색상으로 변경한다. |
||
964 | /// </summary> |
||
965 | /// <param name="entList1"></param> |
||
966 | /// <param name="entList2"></param> |
||
967 | private void CompareAndMark(Design design1, IList<Entity> AutoCADEntities, Design design2, IList<Entity> AVEVAEntities) |
||
968 | { |
||
969 | var DiffRegions = new List<devDept.Eyeshot.OrientedBoundingRect>(); |
||
970 | |||
971 | bool[] equalEntitiesInV2 = new bool[AVEVAEntities.Count]; |
||
972 | 3f59180e | humkyung | var EqualIndices = new List<int>(); |
973 | 13a36357 | humkyung | |
974 | /// 서로 검사 가능한 타입인지 확인한다. |
||
975 | bool CheckType(Entity ent1, Entity ent2) |
||
976 | { |
||
977 | return ent1.GetType() == ent2.GetType() || |
||
978 | (ent1.GetType() == typeof(devDept.Eyeshot.Entities.Text) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.MultilineText)) || |
||
979 | (ent1.GetType() == typeof(devDept.Eyeshot.Entities.MultilineText) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.Text)) || |
||
980 | (ent1.GetType() == typeof(devDept.Eyeshot.Entities.Line) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.TabulatedSurface)) || |
||
981 | (ent1.GetType() == typeof(devDept.Eyeshot.Entities.Attribute) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.Text)) || |
||
982 | (ent1.GetType() == typeof(devDept.Eyeshot.Entities.Attribute) && ent2.GetType() == typeof(devDept.Eyeshot.Entities.MultilineText)); |
||
983 | } |
||
984 | |||
985 | try |
||
986 | { |
||
987 | for (int i = 0; i < AutoCADEntities.Count(); i++) |
||
988 | { |
||
989 | Entity entVp1 = AutoCADEntities[i]; |
||
990 | 3f59180e | humkyung | EqualIndices.Clear(); |
991 | 13a36357 | humkyung | |
992 | for (int j = 0; j < AVEVAEntities.Count(); j++) |
||
993 | { |
||
994 | Entity entVp2 = AVEVAEntities[j]; |
||
995 | |||
996 | if (entVp2 is BlockReference blkref && (blkref.BlockName == "PSNODE" || blkref.BlockName == "PENODE")) continue; |
||
997 | if (!equalEntitiesInV2[j] && CheckType(entVp1, entVp2) && |
||
998 | CompareIfEqual(design1, entVp1, design2, entVp2)) |
||
999 | { |
||
1000 | 3f59180e | humkyung | EqualIndices.Add(j); |
1001 | 13a36357 | humkyung | } |
1002 | } |
||
1003 | 3f59180e | humkyung | |
1004 | #region 임계값 안에 들어오는 항목이 여러개 있을 경우 가장 가까운 항목을 유사 항목으로 선택한다. |
||
1005 | if (EqualIndices.Any()) |
||
1006 | { |
||
1007 | var ordered = EqualIndices.ConvertAll(x => AVEVAEntities[x]).OrderBy(x => |
||
1008 | { |
||
1009 | return x.BoxMin.DistanceTo(entVp1.BoxMin); |
||
1010 | }); |
||
1011 | |||
1012 | int idx = AVEVAEntities.ToList().FindIndex(x => x == ordered.First()); |
||
1013 | equalEntitiesInV2[idx] = true; |
||
1014 | } |
||
1015 | #endregion |
||
1016 | |||
1017 | if (!EqualIndices.Any()) |
||
1018 | 13a36357 | humkyung | { |
1019 | 288a94c5 | humkyung | AutoCADEntities[i].LayerName = Verification.AutoCADDiffLayer; |
1020 | 13a36357 | humkyung | ColorEntity(design1, AutoCADEntities[i], Verification.DiffColor, colorMethodType.byEntity, false); |
1021 | |||
1022 | #region 틀린 엔터티의 BoundingBox를 구함 |
||
1023 | var origin = new devDept.Geometry.Point2D(entVp1.BoxMin.X - 1, entVp1.BoxMin.Y - 1); |
||
1024 | double width = entVp1.BoxMax.X - entVp1.BoxMin.X; |
||
1025 | double height = entVp1.BoxMax.Y - entVp1.BoxMin.Y; |
||
1026 | c4ba621d | humkyung | if (Math.Abs(width) != double.PositiveInfinity && Math.Abs(height) != double.PositiveInfinity) |
1027 | { |
||
1028 | var rect = new devDept.Eyeshot.OrientedBoundingRect(origin, width + 2, height + 2); |
||
1029 | DiffRegions.Add(rect); |
||
1030 | } |
||
1031 | 13a36357 | humkyung | #endregion |
1032 | } |
||
1033 | } |
||
1034 | |||
1035 | for (int j = 0; j < AVEVAEntities.Count; j++) |
||
1036 | { |
||
1037 | if (!equalEntitiesInV2[j]) |
||
1038 | { |
||
1039 | 288a94c5 | humkyung | AVEVAEntities[j].LayerName = Verification.AVEVADiffLayer; |
1040 | 13a36357 | humkyung | ColorEntity(design2, AVEVAEntities[j], Verification.DiffColor, colorMethodType.byEntity, false); |
1041 | |||
1042 | #region 틀린 엔터티의 BoundingBox를 구함 |
||
1043 | var origin = new devDept.Geometry.Point2D(AVEVAEntities[j].BoxMin.X - 1, AVEVAEntities[j].BoxMin.Y - 1); |
||
1044 | double width = AVEVAEntities[j].BoxMax.X - AVEVAEntities[j].BoxMin.X; |
||
1045 | double height = AVEVAEntities[j].BoxMax.Y - AVEVAEntities[j].BoxMin.Y; |
||
1046 | c4ba621d | humkyung | if (Math.Abs(width) != double.PositiveInfinity && Math.Abs(height) != double.PositiveInfinity) |
1047 | { |
||
1048 | var rect = new devDept.Eyeshot.OrientedBoundingRect(origin, width + 2, height + 2); |
||
1049 | DiffRegions.Add(rect); |
||
1050 | } |
||
1051 | 13a36357 | humkyung | #endregion |
1052 | } |
||
1053 | } |
||
1054 | |||
1055 | #region 인접한 영역을 하나로 합친다. |
||
1056 | var queue = new List<devDept.Eyeshot.OrientedBoundingRect>(DiffRegions); |
||
1057 | DiffRegions.Clear(); |
||
1058 | while (queue.Any()) |
||
1059 | { |
||
1060 | var first = queue[0]; |
||
1061 | var FirstMin = first.GetOrigin(); |
||
1062 | var FirstMax = FirstMin + first.GetAxis()[0] * first.Size.X + first.GetAxis()[1] * first.Size.Y; |
||
1063 | |||
1064 | queue.Remove(first); |
||
1065 | bool overlap = false; |
||
1066 | for (int i = 0; i < queue.Count; ++i) |
||
1067 | { |
||
1068 | var second = queue[i]; |
||
1069 | overlap = devDept.Eyeshot.OrientedBoundingRect.DoOverlapOrTouch(first, second); |
||
1070 | if (overlap) |
||
1071 | { |
||
1072 | var SecondMin = second.GetOrigin(); |
||
1073 | var SecondMax = SecondMin + second.GetAxis()[0] * second.Size.X + second.GetAxis()[1] * second.Size.Y; |
||
1074 | |||
1075 | var min = new devDept.Geometry.Point2D(Math.Min(FirstMin.X, SecondMin.X), Math.Min(FirstMin.Y, SecondMin.Y)); |
||
1076 | var max = new devDept.Geometry.Point2D(Math.Max(FirstMax.X, SecondMax.X), Math.Max(FirstMax.Y, SecondMax.Y)); |
||
1077 | double width = max.X - min.X; |
||
1078 | double height = max.Y - min.Y; |
||
1079 | |||
1080 | #region 두 영역을 합친다.(작업 완료된 영역도 다시 queue에 넣는다.) |
||
1081 | var rect = new devDept.Eyeshot.OrientedBoundingRect(min, width, height); |
||
1082 | queue.Add(rect); |
||
1083 | queue.AddRange(DiffRegions); |
||
1084 | DiffRegions.Clear(); |
||
1085 | queue.Remove(second); |
||
1086 | #endregion |
||
1087 | break; |
||
1088 | } |
||
1089 | } |
||
1090 | |||
1091 | if (!overlap) DiffRegions.Add(first); |
||
1092 | } |
||
1093 | #endregion |
||
1094 | |||
1095 | 288ed615 | humkyung | if (!design2.Layers.Contains(Verification.RevCloudLayer)) |
1096 | design2.Layers.Add(Verification.RevCloudLayer.ToUpper(), Verification.RevCloudColor); |
||
1097 | 13a36357 | humkyung | DiffRegions.ForEach(x => DrawRevCloud(design2, x)); |
1098 | } |
||
1099 | catch(Exception ex) |
||
1100 | { |
||
1101 | Console.Write($"Error : {ex.Message}"); |
||
1102 | } |
||
1103 | } |
||
1104 | |||
1105 | /// <summary> |
||
1106 | /// Revision mark를 그린다. |
||
1107 | /// </summary> |
||
1108 | /// <param name="design"></param> |
||
1109 | /// <param name="obr"></param> |
||
1110 | private void DrawRevCloud(Design design, devDept.Eyeshot.OrientedBoundingRect obr) |
||
1111 | { |
||
1112 | IList<IGCurve> DrawRevCloudLine(devDept.Geometry.Point2D start, devDept.Geometry.Point2D end) |
||
1113 | { |
||
1114 | var res = new List<IGCurve>(); |
||
1115 | |||
1116 | var AxisX = new devDept.Geometry.Vector3D(end.X - start.X, end.Y - start.Y); |
||
1117 | AxisX.Normalize(); |
||
1118 | var AxisY = devDept.Geometry.Vector3D.Cross(devDept.Geometry.Vector3D.AxisZ, AxisX); |
||
1119 | |||
1120 | double step = 10; |
||
1121 | double dist = start.DistanceTo(end); |
||
1122 | int count = Convert.ToInt32(dist / step); |
||
1123 | if (count == 0 && dist > 0) |
||
1124 | { |
||
1125 | var tmp = (start + end) * 0.5; |
||
1126 | |||
1127 | var center = new devDept.Geometry.Point3D(tmp.X, tmp.Y, 0); |
||
1128 | var plane = new devDept.Geometry.Plane(center, AxisX, AxisY); |
||
1129 | GArc arc = new GArc(plane, center, start.DistanceTo(end) * 0.5, Math.PI, Math.PI * 2); |
||
1130 | res.Add(arc); |
||
1131 | } |
||
1132 | else |
||
1133 | { |
||
1134 | for (int i = 0; i < count; ++i) |
||
1135 | { |
||
1136 | var _start = (start + AxisX * i * step); |
||
1137 | var _end = (start + AxisX * (i + 1) * step); |
||
1138 | if (i == count - 1) _end = end; |
||
1139 | var tmp = (_start + _end) * 0.5; |
||
1140 | |||
1141 | var center = new devDept.Geometry.Point3D(tmp.X, tmp.Y, 0); |
||
1142 | var plane = new devDept.Geometry.Plane(center, AxisX, AxisY); |
||
1143 | GArc arc = new GArc(plane, center, _start.DistanceTo(_end) * 0.5, Math.PI, Math.PI * 2); |
||
1144 | res.Add(arc); |
||
1145 | } |
||
1146 | } |
||
1147 | |||
1148 | return res; |
||
1149 | } |
||
1150 | |||
1151 | GCompositeCurve profile = new GCompositeCurve(); |
||
1152 | |||
1153 | var vertices = obr.GetVertices(); |
||
1154 | for(int i = 0;i < vertices.Length;++i) |
||
1155 | { |
||
1156 | var curves = DrawRevCloudLine(vertices[i], vertices[(i + 1) % vertices.Length]); |
||
1157 | profile.CurveList.AddRange(curves); |
||
1158 | } |
||
1159 | |||
1160 | var revcloud = new devDept.Eyeshot.Entities.CompositeCurve(profile); |
||
1161 | 288ed615 | humkyung | revcloud.LayerName = Verification.RevCloudLayer; |
1162 | 13a36357 | humkyung | revcloud.Color = Verification.RevCloudColor; |
1163 | revcloud.ColorMethod = colorMethodType.byEntity; |
||
1164 | 1f75c4f0 | humkyung | revcloud.LineWeight = 3; |
1165 | c4ba621d | humkyung | revcloud.LineWeightMethod = colorMethodType.byEntity; |
1166 | 13a36357 | humkyung | design.Entities.Add(revcloud); |
1167 | } |
||
1168 | |||
1169 | /// <summary> |
||
1170 | /// 주어진 두 엔터티를 비교한다. |
||
1171 | /// </summary> |
||
1172 | /// <param name="entVp1"></param> |
||
1173 | /// <param name="entVp2"></param> |
||
1174 | /// <returns></returns> |
||
1175 | private bool CompareIfEqual(Design design1, Entity entVp1, Design design2, Entity entVp2) |
||
1176 | { |
||
1177 | return AreEqual(design1, entVp1, design2, entVp2); |
||
1178 | } |
||
1179 | |||
1180 | private bool CompareGEntityIfEqual(GEntity entVp1, GEntity entVp2) |
||
1181 | { |
||
1182 | return AreGEntityEqual(entVp1, entVp2); |
||
1183 | } |
||
1184 | |||
1185 | /// <summary> |
||
1186 | /// 그래픽적으로 두 엔터티가 유사한지 검사한다. |
||
1187 | /// </summary> |
||
1188 | /// <param name="design1"></param> |
||
1189 | /// <param name="ent1"></param> |
||
1190 | /// <param name="design2"></param> |
||
1191 | /// <param name="ent2"></param> |
||
1192 | /// <returns></returns> |
||
1193 | private bool AreEqual(Design design1, Entity ent1, Design design2, Entity ent2) |
||
1194 | { |
||
1195 | if (ent1 is CompositeCurve cc1 && ent2 is CompositeCurve cc2) |
||
1196 | { |
||
1197 | if (cc1.CurveList.Count == cc2.CurveList.Count) |
||
1198 | { |
||
1199 | int equalCurvesInListCount = 0; |
||
1200 | foreach (var entC in cc1.CurveList) |
||
1201 | { |
||
1202 | foreach (var entC2 in cc2.CurveList) |
||
1203 | { |
||
1204 | if (entC.GetType() == entC2.GetType()) |
||
1205 | { |
||
1206 | if (entC is Entity && entC2 is Entity && CompareIfEqual(design1, entC as Entity, design2, entC2 as Entity)) |
||
1207 | { |
||
1208 | equalCurvesInListCount++; |
||
1209 | break; |
||
1210 | } |
||
1211 | else if (entC is GEntity && entC2 is GEntity && CompareGEntityIfEqual(entC as GEntity, entC2 as GEntity)) |
||
1212 | { |
||
1213 | equalCurvesInListCount++; |
||
1214 | break; |
||
1215 | } |
||
1216 | } |
||
1217 | } |
||
1218 | } |
||
1219 | |||
1220 | if (cc1.CurveList.Count == equalCurvesInListCount) |
||
1221 | { |
||
1222 | return true; |
||
1223 | } |
||
1224 | } |
||
1225 | } |
||
1226 | else if (ent1 is LinearPath lp1 && ent2 is LinearPath lp2) |
||
1227 | { |
||
1228 | if (lp1.Vertices.Length == lp2.Vertices.Length) |
||
1229 | { |
||
1230 | for (int i = 0; i < lp1.Vertices.Length; i++) |
||
1231 | { |
||
1232 | if (lp1.Vertices[i].DistanceTo(lp2.Vertices[i]) > Verification.Tolerance) |
||
1233 | return false; |
||
1234 | } |
||
1235 | |||
1236 | return true; |
||
1237 | } |
||
1238 | } |
||
1239 | c4ba621d | humkyung | else if (ent1 is PlanarEntity && ent2 is PlanarEntity) |
1240 | 13a36357 | humkyung | { |
1241 | if (ent1 is Arc arc1 && ent2 is Arc arc2) |
||
1242 | { |
||
1243 | if ( |
||
1244 | arc1.Center.DistanceTo(arc2.Center) <= Verification.Tolerance && |
||
1245 | Math.Abs(arc1.Radius - arc2.Radius) <= Verification.Tolerance && |
||
1246 | Math.Abs(arc1.Domain.Min - arc2.Domain.Min) <= Verification.Tolerance && |
||
1247 | Math.Abs(arc1.Domain.Max - arc2.Domain.Max) <= Verification.Tolerance |
||
1248 | ) |
||
1249 | { |
||
1250 | return true; |
||
1251 | } |
||
1252 | } |
||
1253 | else if (ent1 is Circle c1 && ent2 is Circle c2) |
||
1254 | { |
||
1255 | if ( |
||
1256 | c1.Center.DistanceTo(c2.Center) <= Verification.Tolerance && |
||
1257 | Math.Abs(c1.Radius - c2.Radius) <= Verification.Tolerance |
||
1258 | ) |
||
1259 | { |
||
1260 | return true; |
||
1261 | } |
||
1262 | } |
||
1263 | else if (ent1 is EllipticalArc e1 && ent2 is EllipticalArc e2) |
||
1264 | { |
||
1265 | if ( |
||
1266 | e1.Center.DistanceTo(e2.Center) <= Verification.Tolerance && |
||
1267 | Math.Abs(e1.RadiusX - e2.RadiusX) <= Verification.Tolerance && |
||
1268 | Math.Abs(e1.RadiusY - e2.RadiusY) <= Verification.Tolerance && |
||
1269 | Math.Abs(e1.Domain.Low - e2.Domain.Low) <= Verification.Tolerance && |
||
1270 | Math.Abs(e1.Domain.High - e2.Domain.High) <= Verification.Tolerance |
||
1271 | ) |
||
1272 | { |
||
1273 | return true; |
||
1274 | } |
||
1275 | } |
||
1276 | else if (ent1 is Ellipse el1 && ent2 is Ellipse el2) |
||
1277 | { |
||
1278 | if ( |
||
1279 | el1.Center.DistanceTo(el2.Center) <= Verification.Tolerance && |
||
1280 | Math.Abs(el1.RadiusX - el2.RadiusX) <= Verification.Tolerance && |
||
1281 | Math.Abs(el1.RadiusY - el2.RadiusY) <= Verification.Tolerance |
||
1282 | ) |
||
1283 | { |
||
1284 | return true; |
||
1285 | } |
||
1286 | } |
||
1287 | c4ba621d | humkyung | #region 해치는 중점만 비교 |
1288 | 13a36357 | humkyung | else if (ent1 is Hatch hatch1 && ent2 is Hatch hatch2) |
1289 | { |
||
1290 | 288ed615 | humkyung | var center1 = (hatch1.BoxMin + hatch1.BoxMax) * 0.5; |
1291 | center1.Z = 0; |
||
1292 | var center2 = (hatch2.BoxMin + hatch2.BoxMax) * 0.5; |
||
1293 | center2.Z = 0; |
||
1294 | return center1.DistanceTo(center2) < Verification.Tolerance; |
||
1295 | 13a36357 | humkyung | } |
1296 | #endregion |
||
1297 | else if (ent1 is Text) |
||
1298 | { |
||
1299 | if (ent1 is Dimension dim1 && ent2 is Dimension dim2) |
||
1300 | { |
||
1301 | if ( |
||
1302 | dim1.InsertionPoint.DistanceTo(dim2.InsertionPoint) <= Verification.Tolerance && |
||
1303 | dim1.DimLinePosition.DistanceTo(dim2.DimLinePosition) <= Verification.Tolerance |
||
1304 | ) |
||
1305 | { |
||
1306 | if (ent1 is AngularDim ad1 && ent2 is AngularDim ad2) |
||
1307 | { |
||
1308 | if ( |
||
1309 | ad1.ExtLine1.DistanceTo(ad2.ExtLine1) <= Verification.Tolerance && |
||
1310 | ad1.ExtLine2.DistanceTo(ad2.ExtLine2) <= Verification.Tolerance && |
||
1311 | Math.Abs(ad1.StartAngle - ad2.StartAngle) <= Verification.Tolerance && |
||
1312 | Math.Abs(ad1.EndAngle - ad2.EndAngle) <= Verification.Tolerance && |
||
1313 | Math.Abs(ad1.Radius - ad2.Radius) <= Verification.Tolerance |
||
1314 | ) |
||
1315 | { |
||
1316 | return true; |
||
1317 | } |
||
1318 | } |
||
1319 | else if (ent1 is LinearDim ld1 && ent2 is LinearDim ld2) |
||
1320 | { |
||
1321 | if ( |
||
1322 | ld1.ExtLine1.DistanceTo(ld2.ExtLine1) <= Verification.Tolerance && |
||
1323 | ld1.ExtLine2.DistanceTo(ld2.ExtLine2) <= Verification.Tolerance |
||
1324 | ) |
||
1325 | { |
||
1326 | return true; |
||
1327 | } |
||
1328 | } |
||
1329 | else if (ent1 is DiametricDim dd1 && ent2 is DiametricDim dd2) |
||
1330 | { |
||
1331 | if ( |
||
1332 | Math.Abs(dd1.Distance - dd2.Distance) <= Verification.Tolerance && |
||
1333 | Math.Abs(dd1.Radius - dd2.Radius) <= Verification.Tolerance && |
||
1334 | Math.Abs(dd1.CenterMarkSize - dd2.CenterMarkSize) <= Verification.Tolerance |
||
1335 | ) |
||
1336 | { |
||
1337 | return true; |
||
1338 | } |
||
1339 | } |
||
1340 | else if (ent1 is RadialDim rd1 && ent2 is RadialDim rd2) |
||
1341 | { |
||
1342 | if ( |
||
1343 | Math.Abs(rd1.Radius - rd2.Radius) <= Verification.Tolerance && |
||
1344 | Math.Abs(rd1.CenterMarkSize - rd2.CenterMarkSize) <= Verification.Tolerance |
||
1345 | ) |
||
1346 | { |
||
1347 | return true; |
||
1348 | } |
||
1349 | } |
||
1350 | else if (ent1 is OrdinateDim od1 && ent2 is OrdinateDim od2) |
||
1351 | { |
||
1352 | if ( |
||
1353 | od1.DefiningPoint.DistanceTo(od2.DefiningPoint) <= Verification.Tolerance && |
||
1354 | od1.Origin.DistanceTo(od2.Origin) <= Verification.Tolerance && |
||
1355 | od1.LeaderEndPoint.DistanceTo(od2.LeaderEndPoint) <= Verification.Tolerance |
||
1356 | ) |
||
1357 | { |
||
1358 | return true; |
||
1359 | } |
||
1360 | } |
||
1361 | else |
||
1362 | { |
||
1363 | Console.Write("Type " + ent1.GetType() + " not implemented."); |
||
1364 | return true; |
||
1365 | } |
||
1366 | } |
||
1367 | } |
||
1368 | |||
1369 | else if (ent1 is devDept.Eyeshot.Entities.Attribute att1 && ent2 is devDept.Eyeshot.Entities.Attribute att2) |
||
1370 | { |
||
1371 | if ( |
||
1372 | att1.Value == att2.Value && |
||
1373 | att1.InsertionPoint.DistanceTo(att2.InsertionPoint) <= Verification.Tolerance |
||
1374 | ) |
||
1375 | { |
||
1376 | return true; |
||
1377 | } |
||
1378 | } |
||
1379 | else |
||
1380 | { |
||
1381 | Text tx1 = (Text)ent1; |
||
1382 | Text tx2 = (Text)ent2; |
||
1383 | |||
1384 | #region 대소문자, 공백을 무시하여 비교 |
||
1385 | string string1 = tx1.TextString.Trim().ToUpper(); |
||
1386 | string string2 = tx2.TextString.Trim().ToUpper(); |
||
1387 | string1 = System.Text.RegularExpressions.Regex.Replace(string1, @"\s+", ""); |
||
1388 | string2 = System.Text.RegularExpressions.Regex.Replace(string2, @"\s+", ""); |
||
1389 | if ( |
||
1390 | tx1.BoxMin.DistanceTo(tx2.BoxMin) <= Verification.Tolerance && |
||
1391 | string1 == string2 && |
||
1392 | Math.Abs(tx1.WidthFactor - tx2.WidthFactor) <= Verification.Tolerance && |
||
1393 | Math.Abs(tx1.Height - tx2.Height) <= Verification.Tolerance |
||
1394 | ) |
||
1395 | { |
||
1396 | return true; |
||
1397 | } |
||
1398 | #endregion |
||
1399 | } |
||
1400 | } |
||
1401 | } |
||
1402 | else if (ent1 is Line line1 && ent2 is Line line2) |
||
1403 | { |
||
1404 | var dir1 = line1.Direction; |
||
1405 | dir1.Normalize(); |
||
1406 | var dir2 = line2.Direction; |
||
1407 | dir2.Normalize(); |
||
1408 | if (devDept.Geometry.Vector3D.AreParallel(dir1, dir2, 0.1) && |
||
1409 | c4ba621d | humkyung | Math.Abs(line1.Length() - line2.Length()) <= line1.Length() * LengthToleranceRatio && |
1410 | 13a36357 | humkyung | line1.MidPoint.DistanceTo(line2.MidPoint) <= Verification.Tolerance |
1411 | ) |
||
1412 | { |
||
1413 | return true; |
||
1414 | } |
||
1415 | } |
||
1416 | else if (ent1 is Line && ent2 is devDept.Eyeshot.Entities.TabulatedSurface lwpolyline && lwpolyline.ControlPoints.Length == 4) |
||
1417 | { |
||
1418 | line1 = ent1 as Line; |
||
1419 | var start = new devDept.Geometry.Point3D(lwpolyline.ControlPoints[0, 0].X, lwpolyline.ControlPoints[0, 0].Y, 0); |
||
1420 | var end = new devDept.Geometry.Point3D(lwpolyline.ControlPoints[1, 0].X, lwpolyline.ControlPoints[1, 0].Y, 0); |
||
1421 | var vec = new devDept.Geometry.Vector3D(start, end); |
||
1422 | vec.Normalize(); |
||
1423 | var dir = line1.Direction.Clone() as devDept.Geometry.Vector3D; |
||
1424 | dir.Normalize(); |
||
1425 | |||
1426 | if ( |
||
1427 | devDept.Geometry.Vector3D.AreParallel(dir, vec) && |
||
1428 | line1.StartPoint.DistanceTo(start) <= Verification.Tolerance && |
||
1429 | line1.EndPoint.DistanceTo(end) <= Verification.Tolerance |
||
1430 | ) |
||
1431 | { |
||
1432 | return true; |
||
1433 | } |
||
1434 | } |
||
1435 | else if (ent1 is devDept.Eyeshot.Entities.Point point1 && ent2 is devDept.Eyeshot.Entities.Point point2) |
||
1436 | { |
||
1437 | if (point1.Position.DistanceTo(point2.Position) <= Verification.Tolerance) |
||
1438 | { |
||
1439 | return true; |
||
1440 | } |
||
1441 | } |
||
1442 | else if (ent1 is Curve cu1 && ent2 is Curve cu2) |
||
1443 | { |
||
1444 | if ( |
||
1445 | cu1.ControlPoints.Length == cu2.ControlPoints.Length && |
||
1446 | cu1.KnotVector.Length == cu2.KnotVector.Length && |
||
1447 | cu1.Degree == cu2.Degree |
||
1448 | ) |
||
1449 | { |
||
1450 | for (int k = 0; k < cu1.ControlPoints.Length; k++) |
||
1451 | { |
||
1452 | if (cu1.ControlPoints[k].DistanceTo(cu2.ControlPoints[k]) > Verification.Tolerance) |
||
1453 | { |
||
1454 | return false; |
||
1455 | } |
||
1456 | } |
||
1457 | |||
1458 | for (int k = 0; k < cu1.KnotVector.Length; k++) |
||
1459 | { |
||
1460 | if (cu1.KnotVector[k] != cu2.KnotVector[k]) |
||
1461 | { |
||
1462 | return false; |
||
1463 | } |
||
1464 | } |
||
1465 | |||
1466 | return true; |
||
1467 | } |
||
1468 | } |
||
1469 | else if (ent1 is Mesh m1 && ent2 is Mesh m2 && m1.Vertices.Count() == m2.Vertices.Count()) |
||
1470 | { |
||
1471 | for (int i = 0; i < m1.Vertices.Count(); ++i) |
||
1472 | { |
||
1473 | if (m1.Vertices[i].DistanceTo(m2.Vertices[i]) > Verification.Tolerance) return false; |
||
1474 | } |
||
1475 | |||
1476 | return true; |
||
1477 | } |
||
1478 | else if (ent1 is BlockReference blkref1 && ent2 is BlockReference blkref2) |
||
1479 | { |
||
1480 | int equalCurvesInEntityList = 0; |
||
1481 | |||
1482 | #region Point, Attribute, Text 제거 및 LinePath를 라인으로 분리 |
||
1483 | var entities1 = blkref1.Explode(design1.Blocks).Where(x => x.LayerName != "AS_PORT" && !(x is devDept.Eyeshot.Entities.Point) && |
||
1484 | !(x is devDept.Eyeshot.Entities.Attribute) && !(x is devDept.Eyeshot.Entities.Text)).ToList(); |
||
1485 | var coll1 = new List<Entity>(); |
||
1486 | entities1.ForEach(x => |
||
1487 | { |
||
1488 | if (x is LinearPath lp) |
||
1489 | { |
||
1490 | for (int i = 0; i < lp.Vertices.Length - 1; ++i) |
||
1491 | { |
||
1492 | if (lp.Vertices[i].DistanceTo(lp.Vertices[i + 1]) < 0.1) continue; |
||
1493 | coll1.Add(new Line(lp.Vertices[i], lp.Vertices[i + 1])); |
||
1494 | } |
||
1495 | } |
||
1496 | else |
||
1497 | { |
||
1498 | coll1.Add(x); |
||
1499 | } |
||
1500 | }); |
||
1501 | #endregion |
||
1502 | |||
1503 | #region Point 및 Nesting Block 제거 및 LinePath를 라인으로 분리 |
||
1504 | var entities2 = blkref2.Explode(design2.Blocks).Where(x => |
||
1505 | !(x is devDept.Eyeshot.Entities.BlockReference blkref && blkref.BlockName == "PORT") && !(x is devDept.Eyeshot.Entities.Point)).ToList(); |
||
1506 | var coll2 = new List<Entity>(); |
||
1507 | entities2.ForEach(x => |
||
1508 | { |
||
1509 | if (x is LinearPath lp) |
||
1510 | { |
||
1511 | for (int i = 0; i < lp.Vertices.Length - 1; ++i) |
||
1512 | { |
||
1513 | if (lp.Vertices[i].DistanceTo(lp.Vertices[i + 1]) < 0.1) continue; |
||
1514 | coll2.Add(new Line(lp.Vertices[i], lp.Vertices[i + 1])); |
||
1515 | } |
||
1516 | } |
||
1517 | else if (x is devDept.Eyeshot.Entities.Attribute attr) |
||
1518 | { |
||
1519 | if (!attr.Invisible) coll2.Add(attr); |
||
1520 | } |
||
1521 | else if (x.GetType().Name == "AttributeReferenceData") |
||
1522 | { |
||
1523 | } |
||
1524 | else |
||
1525 | { |
||
1526 | coll2.Add(x); |
||
1527 | } |
||
1528 | }); |
||
1529 | #endregion |
||
1530 | |||
1531 | if (coll1.Count != coll2.Count) return false; |
||
1532 | |||
1533 | foreach (var entC in coll1) |
||
1534 | { |
||
1535 | foreach (var entC2 in coll2) |
||
1536 | { |
||
1537 | if (entC.GetType() == entC2.GetType()) |
||
1538 | { |
||
1539 | if (entC is Entity && entC2 is Entity && CompareIfEqual(design1, entC as Entity, design2, entC2 as Entity)) |
||
1540 | { |
||
1541 | equalCurvesInEntityList++; |
||
1542 | break; |
||
1543 | } |
||
1544 | } |
||
1545 | } |
||
1546 | } |
||
1547 | |||
1548 | if (coll1.Count == equalCurvesInEntityList) |
||
1549 | { |
||
1550 | return true; |
||
1551 | } |
||
1552 | } |
||
1553 | else |
||
1554 | { |
||
1555 | Console.Write("Type " + ent1.GetType() + " not implemented."); |
||
1556 | return false; |
||
1557 | } |
||
1558 | |||
1559 | return false; |
||
1560 | } |
||
1561 | |||
1562 | private bool AreGEntityEqual(GEntity ent1, GEntity ent2) |
||
1563 | { |
||
1564 | if (ent1 is GCompositeCurve cc1 && ent2 is GCompositeCurve cc2) |
||
1565 | { |
||
1566 | if (cc1.CurveList.Count == cc2.CurveList.Count) |
||
1567 | { |
||
1568 | int equalCurvesInListCount = 0; |
||
1569 | foreach (var entC in cc1.CurveList) |
||
1570 | { |
||
1571 | foreach (var entC2 in cc2.CurveList) |
||
1572 | { |
||
1573 | if (entC.GetType() == entC2.GetType()) |
||
1574 | { |
||
1575 | if (entC is GEntity && entC2 is GEntity && CompareGEntityIfEqual(entC as GEntity, entC2 as GEntity)) |
||
1576 | { |
||
1577 | equalCurvesInListCount++; |
||
1578 | break; |
||
1579 | } |
||
1580 | } |
||
1581 | } |
||
1582 | } |
||
1583 | |||
1584 | if (cc1.CurveList.Count == equalCurvesInListCount) |
||
1585 | { |
||
1586 | return true; |
||
1587 | } |
||
1588 | } |
||
1589 | } |
||
1590 | else if (ent1 is GLinearPath lp1 && ent2 is GLinearPath lp2) |
||
1591 | { |
||
1592 | if (lp1.Vertices.Length == lp2.Vertices.Length) |
||
1593 | { |
||
1594 | for (int i = 0; i < lp1.Vertices.Length; i++) |
||
1595 | { |
||
1596 | if (lp1.Vertices[i].DistanceTo(lp2.Vertices[i]) > Verification.Tolerance) |
||
1597 | return false; |
||
1598 | } |
||
1599 | return true; |
||
1600 | } |
||
1601 | } |
||
1602 | |||
1603 | else if (ent1 is GPlanarEntity pe1 && ent2 is GPlanarEntity pe2) |
||
1604 | { |
||
1605 | if ( |
||
1606 | pe1.Plane.AxisZ == pe2.Plane.AxisZ && |
||
1607 | pe1.Plane.AxisX == pe2.Plane.AxisX |
||
1608 | ) |
||
1609 | { |
||
1610 | if (ent1 is GArc arc1 && ent2 is GArc arc2) |
||
1611 | { |
||
1612 | if ( |
||
1613 | arc1.Center.DistanceTo(arc2.Center) <= Verification.Tolerance && |
||
1614 | Math.Abs(arc1.Radius - arc2.Radius) <= Verification.Tolerance && |
||
1615 | Math.Abs(arc1.Domain.Min - arc2.Domain.Min) <= Verification.Tolerance && |
||
1616 | Math.Abs(arc1.Domain.Max - arc2.Domain.Max) <= Verification.Tolerance |
||
1617 | ) |
||
1618 | { |
||
1619 | return true; |
||
1620 | } |
||
1621 | } |
||
1622 | else if (ent1 is GCircle c1 && ent2 is GCircle c2) |
||
1623 | { |
||
1624 | if (c1.Center.DistanceTo(c2.Center) <= Verification.Tolerance && |
||
1625 | Math.Abs(c1.Radius - c2.Radius) <= Verification.Tolerance) |
||
1626 | { |
||
1627 | return true; |
||
1628 | } |
||
1629 | } |
||
1630 | else if (ent1 is GEllipticalArc e1 && ent2 is GEllipticalArc e2) |
||
1631 | { |
||
1632 | if ( |
||
1633 | e1.Center.DistanceTo(e2.Center) <= Verification.Tolerance && |
||
1634 | Math.Abs(e1.RadiusX - e2.RadiusX) <= Verification.Tolerance && |
||
1635 | Math.Abs(e1.RadiusY - e2.RadiusY) <= Verification.Tolerance && |
||
1636 | Math.Abs(e1.Domain.Low - e2.Domain.Low) <= Verification.Tolerance && |
||
1637 | Math.Abs(e1.Domain.High - e2.Domain.High) <= Verification.Tolerance |
||
1638 | ) |
||
1639 | { |
||
1640 | return true; |
||
1641 | } |
||
1642 | } |
||
1643 | else if (ent1 is GEllipse el1 && ent2 is GEllipse el2) |
||
1644 | { |
||
1645 | if ( |
||
1646 | el1.Center.DistanceTo(el2.Center) <= Verification.Tolerance && |
||
1647 | Math.Abs(el1.RadiusX - el2.RadiusX) <= Verification.Tolerance && |
||
1648 | Math.Abs(el1.RadiusY - el2.RadiusY) <= Verification.Tolerance |
||
1649 | ) |
||
1650 | { |
||
1651 | return true; |
||
1652 | } |
||
1653 | } |
||
1654 | else |
||
1655 | { |
||
1656 | Console.Write("Type " + ent1.GetType() + " not implemented."); |
||
1657 | return true; |
||
1658 | } |
||
1659 | } |
||
1660 | } |
||
1661 | |||
1662 | else if (ent1 is GLine line1 && ent2 is GLine line2) |
||
1663 | { |
||
1664 | if (line1.StartPoint.DistanceTo(line2.StartPoint) <= Verification.Tolerance && |
||
1665 | line1.EndPoint.DistanceTo(line2.EndPoint) <= Verification.Tolerance |
||
1666 | ) |
||
1667 | { |
||
1668 | return true; |
||
1669 | } |
||
1670 | } |
||
1671 | #if NURBS |
||
1672 | else if (ent1 is Curve) |
||
1673 | { |
||
1674 | Curve cu1 = (Curve)ent1; |
||
1675 | Curve cu2 = (Curve)ent2; |
||
1676 | |||
1677 | if ( |
||
1678 | cu1.ControlPoints.Length == cu2.ControlPoints.Length && |
||
1679 | cu1.KnotVector.Length == cu2.KnotVector.Length && |
||
1680 | cu1.Degree == cu2.Degree |
||
1681 | ) |
||
1682 | { |
||
1683 | for (int k = 0; k < cu1.ControlPoints.Length; k++) |
||
1684 | { |
||
1685 | if (cu1.ControlPoints[k] != cu2.ControlPoints[k]) |
||
1686 | { |
||
1687 | return false; |
||
1688 | } |
||
1689 | } |
||
1690 | |||
1691 | for (int k = 0; k < cu1.KnotVector.Length; k++) |
||
1692 | { |
||
1693 | if (cu1.KnotVector[k] != cu2.KnotVector[k]) |
||
1694 | { |
||
1695 | return false; |
||
1696 | } |
||
1697 | } |
||
1698 | |||
1699 | return true; |
||
1700 | } |
||
1701 | } |
||
1702 | #endif |
||
1703 | |||
1704 | else |
||
1705 | { |
||
1706 | Console.Write("Type " + ent1.GetType() + " not implemented."); |
||
1707 | return true; |
||
1708 | } |
||
1709 | return false; |
||
1710 | } |
||
1711 | |||
1712 | #region Camera Sync |
||
1713 | private void CameraChanged(object sender, devDept.Eyeshot.Workspace.CameraMoveEventArgs e) |
||
1714 | { |
||
1715 | if (sender == this.designAutoCAD) |
||
1716 | { |
||
1717 | SyncCamera(this.designAutoCAD, this.designAVEVA); |
||
1718 | SyncCamera(this.designAutoCAD, this.designCompare); |
||
1719 | } |
||
1720 | else if (sender == this.designAVEVA) |
||
1721 | { |
||
1722 | SyncCamera(this.designAVEVA, this.designAutoCAD); |
||
1723 | SyncCamera(this.designAVEVA, this.designCompare); |
||
1724 | } |
||
1725 | else |
||
1726 | { |
||
1727 | SyncCamera(this.designCompare, this.designAutoCAD); |
||
1728 | SyncCamera(this.designCompare, this.designAVEVA); |
||
1729 | } |
||
1730 | } |
||
1731 | |||
1732 | private void SyncCamera(Design designMovedCamera, Design designCameraToMove) |
||
1733 | { |
||
1734 | Camera savedCamera; |
||
1735 | designMovedCamera.SaveView(out savedCamera); |
||
1736 | |||
1737 | // restores the camera to the other model |
||
1738 | designCameraToMove.RestoreView(savedCamera); |
||
1739 | designCameraToMove.AdjustNearAndFarPlanes(); |
||
1740 | designCameraToMove.Invalidate(); |
||
1741 | } |
||
1742 | #endregion |
||
1743 | } |
||
1744 | } |