hytos / DTI_PID / SPPIDConverter / AutoModeling.cs @ 8829d0c5
이력 | 보기 | 이력해설 | 다운로드 (165 KB)
1 | cfda1fed | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | 4d2571ab | gaqhf | using System.Data; |
7 | cfda1fed | gaqhf | using Llama; |
8 | using Plaice; |
||
9 | 8aa6f2db | gaqhf | using Ingr.RAD2D.Interop.RAD2D; |
10 | using Ingr.RAD2D.Internal; |
||
11 | using Ingr.RAD2D.Helper; |
||
12 | cfda1fed | gaqhf | using Converter.BaseModel; |
13 | using Converter.SPPID.Model; |
||
14 | using Converter.SPPID.Properties; |
||
15 | using Converter.SPPID.Util; |
||
16 | using Converter.SPPID.DB; |
||
17 | 5e6ecf05 | gaqhf | using Ingr.RAD2D.MacroControls.CmdCtrl; |
18 | using Ingr.RAD2D; |
||
19 | 5dfb8a24 | gaqhf | using System.Windows; |
20 | cfda1fed | gaqhf | using System.Threading; |
21 | 5dfb8a24 | gaqhf | using System.Drawing; |
22 | cfda1fed | gaqhf | using Microsoft.VisualBasic; |
23 | using Newtonsoft.Json; |
||
24 | |||
25 | ca214bc3 | gaqhf | using DevExpress.XtraSplashScreen; |
26 | cfda1fed | gaqhf | namespace Converter.SPPID |
27 | { |
||
28 | public class AutoModeling |
||
29 | { |
||
30 | 809a7640 | gaqhf | Placement _placement; |
31 | LMADataSource dataSource; |
||
32 | 1ba9c671 | gaqhf | dynamic newDrawing; |
33 | d19ae675 | gaqhf | dynamic application; |
34 | 5e6ecf05 | gaqhf | Ingr.RAD2D.Application radApp; |
35 | cfda1fed | gaqhf | SPPID_Document document; |
36 | b65a7e32 | gaqhf | ETCSetting _ETCSetting; |
37 | f1c9dbaa | gaqhf | |
38 | d5ec4d0f | gaqhf | public string DocumentLabelText { get; set; } |
39 | |||
40 | f31645b6 | gaqhf | int CurrentCount; |
41 | 69b7387a | gaqhf | List<Tuple<string, Line, Line>> BranchLines = new List<Tuple<string, Line, Line>>(); |
42 | 87f02fc0 | gaqhf | List<string> ZeroLengthModelItemID = new List<string>(); |
43 | 47ad9a46 | gaqhf | |
44 | d19ae675 | gaqhf | public AutoModeling(SPPID_Document document, dynamic application, Ingr.RAD2D.Application radApp) |
45 | cfda1fed | gaqhf | { |
46 | this.document = document; |
||
47 | d19ae675 | gaqhf | this.application = application; |
48 | 5e6ecf05 | gaqhf | this.radApp = radApp; |
49 | b65a7e32 | gaqhf | this._ETCSetting = ETCSetting.GetInstance(); |
50 | cfda1fed | gaqhf | } |
51 | |||
52 | 87f02fc0 | gaqhf | private int CalcProgressCount() |
53 | f31645b6 | gaqhf | { |
54 | b265df51 | gaqhf | int EquipCount = 0; |
55 | int SymbolCount = 0; |
||
56 | int LineCount = 0; |
||
57 | int NoteCount = 0; |
||
58 | int TextCount = 0; |
||
59 | int EndBreakCount = 0; |
||
60 | int LineNumberCount = 0; |
||
61 | |||
62 | f31645b6 | gaqhf | EquipCount = document.Equipments.Count; |
63 | SymbolCount = document.SYMBOLS.Count; |
||
64 | SymbolCount = SymbolCount * 3; |
||
65 | 7f00b26c | gaqhf | |
66 | f31645b6 | gaqhf | foreach (LineNumber lineNumber in document.LINENUMBERS) |
67 | foreach (LineRun run in lineNumber.RUNS) |
||
68 | foreach (var item in run.RUNITEMS) |
||
69 | if (item.GetType() == typeof(Line)) |
||
70 | LineCount++; |
||
71 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
72 | foreach (LineRun run in trimLine.RUNS) |
||
73 | foreach (var item in run.RUNITEMS) |
||
74 | if (item.GetType() == typeof(Line)) |
||
75 | LineCount++; |
||
76 | |||
77 | LineCount = LineCount * 2; |
||
78 | NoteCount = document.NOTES.Count; |
||
79 | TextCount = document.TEXTINFOS.Count; |
||
80 | EndBreakCount = document.EndBreaks.Count; |
||
81 | LineNumberCount = document.LINENUMBERS.Count; |
||
82 | LineNumberCount = LineNumberCount * 2; |
||
83 | |||
84 | b265df51 | gaqhf | return EquipCount + SymbolCount + LineCount + NoteCount + TextCount + EndBreakCount; |
85 | f31645b6 | gaqhf | } |
86 | |||
87 | 02480ac1 | gaqhf | private void SetSystemEditingCommand(bool value) |
88 | { |
||
89 | foreach (var item in radApp.Commands) |
||
90 | { |
||
91 | if (item.Argument == "SystemEditingCmd.SystemEditing") |
||
92 | { |
||
93 | if (item.Checked != value) |
||
94 | { |
||
95 | radApp.RunMacro("systemeditingcmd.dll"); |
||
96 | break; |
||
97 | } |
||
98 | |||
99 | } |
||
100 | } |
||
101 | } |
||
102 | |||
103 | 74752074 | gaqhf | /// <summary> |
104 | /// 도면 단위당 실행되는 메서드 |
||
105 | /// </summary> |
||
106 | 1ba9c671 | gaqhf | public void Run() |
107 | c2fef4ca | gaqhf | { |
108 | 224535bb | gaqhf | string drawingNumber = document.DrawingNumber; |
109 | string drawingName = document.DrawingName; |
||
110 | 1ba9c671 | gaqhf | try |
111 | c2fef4ca | gaqhf | { |
112 | 1ba9c671 | gaqhf | _placement = new Placement(); |
113 | dataSource = _placement.PIDDataSource; |
||
114 | |||
115 | 224535bb | gaqhf | CreateDocument(ref drawingNumber, ref drawingName); |
116 | 1ba9c671 | gaqhf | |
117 | 0e0edfad | gaqhf | if (DocumentCoordinateCorrection()) |
118 | 310aeb31 | gaqhf | { |
119 | 87f02fc0 | gaqhf | int AllCount = CalcProgressCount(); |
120 | 3734dcc5 | gaqhf | Log.Write("Start Modeling"); |
121 | 965eb728 | gaqhf | SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
122 | 9628f54b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd); |
123 | 20972c61 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStep, AllCount); |
124 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
||
125 | 7f00b26c | gaqhf | |
126 | 4d2571ab | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Priority Symbol Modeling"); |
127 | List<Symbol> prioritySymbols = GetPrioritySymbol(); |
||
128 | foreach (var item in prioritySymbols) |
||
129 | 3734dcc5 | gaqhf | { |
130 | try |
||
131 | { |
||
132 | SymbolModelingByPriority(item); |
||
133 | } |
||
134 | catch (Exception ex) |
||
135 | { |
||
136 | Log.Write("Error in SymbolModelingByPriority"); |
||
137 | Log.Write("UID : " + item.UID); |
||
138 | Log.Write(ex.Message); |
||
139 | Log.Write(ex.StackTrace); |
||
140 | } |
||
141 | } |
||
142 | d1eac84d | gaqhf | |
143 | 3939eebf | gaqhf | // Equipment Modeling |
144 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Equipments Modeling"); |
145 | 3939eebf | gaqhf | foreach (Equipment equipment in document.Equipments) |
146 | 3734dcc5 | gaqhf | { |
147 | try |
||
148 | { |
||
149 | EquipmentModeling(equipment); |
||
150 | } |
||
151 | catch (Exception ex) |
||
152 | { |
||
153 | Log.Write("Error in EquipmentModeling"); |
||
154 | Log.Write("UID : " + equipment.UID); |
||
155 | Log.Write(ex.Message); |
||
156 | Log.Write(ex.StackTrace); |
||
157 | } |
||
158 | } |
||
159 | 3939eebf | gaqhf | |
160 | // LineRun Symbol Modeling |
||
161 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Symbols Modeling"); |
162 | 3939eebf | gaqhf | foreach (LineNumber lineNumber in document.LINENUMBERS) |
163 | 3734dcc5 | gaqhf | try |
164 | { |
||
165 | foreach (LineRun run in lineNumber.RUNS) |
||
166 | SymbolModelingByRun(run); |
||
167 | } |
||
168 | catch (Exception ex) |
||
169 | { |
||
170 | Log.Write("Error in SymbolModelingByRun"); |
||
171 | Log.Write("UID : " + lineNumber.UID); |
||
172 | Log.Write(ex.Message); |
||
173 | Log.Write(ex.StackTrace); |
||
174 | } |
||
175 | 3939eebf | gaqhf | // TrimLineRun Symbol Modeling |
176 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
177 | 3734dcc5 | gaqhf | try |
178 | { |
||
179 | foreach (LineRun run in trimLine.RUNS) |
||
180 | SymbolModelingByRun(run); |
||
181 | } |
||
182 | catch (Exception ex) |
||
183 | { |
||
184 | Log.Write("Error in SymbolModelingByRun"); |
||
185 | Log.Write("UID : " + trimLine.UID); |
||
186 | Log.Write(ex.Message); |
||
187 | Log.Write(ex.StackTrace); |
||
188 | } |
||
189 | d9794a6c | gaqhf | |
190 | 3939eebf | gaqhf | |
191 | // LineRun Line Modeling |
||
192 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Lines Modeling"); |
193 | 3939eebf | gaqhf | foreach (LineNumber lineNumber in document.LINENUMBERS) |
194 | 3734dcc5 | gaqhf | try |
195 | { |
||
196 | foreach (LineRun run in lineNumber.RUNS) |
||
197 | LineModelingByRun(run); |
||
198 | } |
||
199 | catch (Exception ex) |
||
200 | { |
||
201 | Log.Write("Error in LineModelingByRun"); |
||
202 | Log.Write("UID : " + lineNumber.UID); |
||
203 | Log.Write(ex.Message); |
||
204 | Log.Write(ex.StackTrace); |
||
205 | } |
||
206 | 3939eebf | gaqhf | // TrimLineRun Line Modeling |
207 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
208 | 3734dcc5 | gaqhf | try |
209 | { |
||
210 | foreach (LineRun run in trimLine.RUNS) |
||
211 | LineModelingByRun(run); |
||
212 | } |
||
213 | catch (Exception ex) |
||
214 | { |
||
215 | Log.Write("Error in LineModelingByRun"); |
||
216 | Log.Write("UID : " + trimLine.UID); |
||
217 | Log.Write(ex.Message); |
||
218 | Log.Write(ex.StackTrace); |
||
219 | } |
||
220 | |||
221 | 3939eebf | gaqhf | |
222 | // Branch Line Modeling |
||
223 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Branch Lines Modeling"); |
224 | 3939eebf | gaqhf | foreach (var item in BranchLines) |
225 | 3734dcc5 | gaqhf | try |
226 | { |
||
227 | BranchLineModeling(item); |
||
228 | } |
||
229 | catch (Exception ex) |
||
230 | { |
||
231 | Log.Write("Error in BranchLineModeling"); |
||
232 | if (item.Item2 != null) |
||
233 | Log.Write("UID : " + item.Item2.UID); |
||
234 | if (item.Item3 != null) |
||
235 | Log.Write("UID : " + item.Item3.UID); |
||
236 | Log.Write(ex.Message); |
||
237 | Log.Write(ex.StackTrace); |
||
238 | } |
||
239 | |||
240 | 3939eebf | gaqhf | |
241 | // EndBreak Modeling |
||
242 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "EndBreaks Modeling"); |
243 | 3939eebf | gaqhf | foreach (var item in document.EndBreaks) |
244 | 3734dcc5 | gaqhf | try |
245 | { |
||
246 | EndBreakModeling(item); |
||
247 | } |
||
248 | catch (Exception ex) |
||
249 | { |
||
250 | Log.Write("Error in EndBreakModeling"); |
||
251 | Log.Write("UID : " + item.UID); |
||
252 | Log.Write(ex.Message); |
||
253 | Log.Write(ex.StackTrace); |
||
254 | } |
||
255 | |||
256 | 3939eebf | gaqhf | |
257 | 53c81765 | gaqhf | // SpecBreak Modeling |
258 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "SpecBreaks Modeling"); |
||
259 | foreach (var item in document.SpecBreaks) |
||
260 | 3734dcc5 | gaqhf | try |
261 | { |
||
262 | SpecBreakModeling(item); |
||
263 | } |
||
264 | catch (Exception ex) |
||
265 | { |
||
266 | Log.Write("Error in SpecBreakModeling"); |
||
267 | Log.Write("UID : " + item.UID); |
||
268 | Log.Write(ex.Message); |
||
269 | Log.Write(ex.StackTrace); |
||
270 | } |
||
271 | |||
272 | 53c81765 | gaqhf | |
273 | 3939eebf | gaqhf | // LineNumber Modeling |
274 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "LineNumbers Modeling"); |
275 | 3939eebf | gaqhf | foreach (var item in document.LINENUMBERS) |
276 | 3734dcc5 | gaqhf | try |
277 | { |
||
278 | LineNumberModeling(item); |
||
279 | } |
||
280 | catch (Exception ex) |
||
281 | { |
||
282 | Log.Write("Error in LineNumberModeling"); |
||
283 | Log.Write("UID : " + item.UID); |
||
284 | Log.Write(ex.Message); |
||
285 | Log.Write(ex.StackTrace); |
||
286 | } |
||
287 | |||
288 | 3939eebf | gaqhf | |
289 | 1ed39474 | gaqhf | // FlowMark Modeling |
290 | b2d1c1aa | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Flow Mark Modeling"); |
291 | foreach (var item in document.LINES) |
||
292 | 3734dcc5 | gaqhf | try |
293 | { |
||
294 | FlowMarkModeling(item); |
||
295 | } |
||
296 | catch (Exception ex) |
||
297 | { |
||
298 | Log.Write("Error in FlowMarkModeling"); |
||
299 | Log.Write("UID : " + item.UID); |
||
300 | Log.Write(ex.Message); |
||
301 | Log.Write(ex.StackTrace); |
||
302 | } |
||
303 | |||
304 | b2d1c1aa | gaqhf | |
305 | 340515a2 | gaqhf | // Note Symbol Modeling |
306 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Note Symbol Modeling"); |
||
307 | foreach (var item in document.SYMBOLS) |
||
308 | 3734dcc5 | gaqhf | try |
309 | { |
||
310 | NoteSymbolModeling(item); |
||
311 | } |
||
312 | catch (Exception ex) |
||
313 | { |
||
314 | Log.Write("Error in NoteSymbolModeling"); |
||
315 | Log.Write("UID : " + item.UID); |
||
316 | Log.Write(ex.Message); |
||
317 | Log.Write(ex.StackTrace); |
||
318 | } |
||
319 | |||
320 | 340515a2 | gaqhf | |
321 | 3939eebf | gaqhf | // Note Modeling |
322 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Notes Modeling"); |
323 | 3939eebf | gaqhf | foreach (var item in document.NOTES) |
324 | 3734dcc5 | gaqhf | try |
325 | { |
||
326 | NoteModeling(item); |
||
327 | } |
||
328 | catch (Exception ex) |
||
329 | { |
||
330 | Log.Write("Error in NoteModeling"); |
||
331 | Log.Write("UID : " + item.UID); |
||
332 | Log.Write(ex.Message); |
||
333 | Log.Write(ex.StackTrace); |
||
334 | } |
||
335 | |||
336 | 3939eebf | gaqhf | // Text Modeling |
337 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Texts Modeling"); |
338 | 3939eebf | gaqhf | foreach (var item in document.TEXTINFOS) |
339 | 3734dcc5 | gaqhf | try |
340 | { |
||
341 | TextModeling(item); |
||
342 | } |
||
343 | catch (Exception ex) |
||
344 | { |
||
345 | Log.Write("Error in TextModeling"); |
||
346 | Log.Write("UID : " + item.UID); |
||
347 | Log.Write(ex.Message); |
||
348 | Log.Write(ex.StackTrace); |
||
349 | } |
||
350 | |||
351 | 3939eebf | gaqhf | // Input LineNumber Attribute |
352 | 3ac248e3 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set LineNumbers Attribute"); |
353 | 3939eebf | gaqhf | foreach (var item in document.LINENUMBERS) |
354 | 3734dcc5 | gaqhf | try |
355 | { |
||
356 | InputLineNumberAttribute(item); |
||
357 | } |
||
358 | catch (Exception ex) |
||
359 | { |
||
360 | Log.Write("Error in InputLineNumberAttribute"); |
||
361 | Log.Write("UID : " + item.UID); |
||
362 | Log.Write(ex.Message); |
||
363 | Log.Write(ex.StackTrace); |
||
364 | } |
||
365 | |||
366 | 3939eebf | gaqhf | // Input Symbol Attribute |
367 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
368 | 3939eebf | gaqhf | foreach (var item in document.SYMBOLS) |
369 | 3734dcc5 | gaqhf | try |
370 | { |
||
371 | InputSymbolAttribute(item, item.ATTRIBUTES); |
||
372 | } |
||
373 | catch (Exception ex) |
||
374 | { |
||
375 | Log.Write("Error in InputSymbolAttribute"); |
||
376 | Log.Write("UID : " + item.UID); |
||
377 | Log.Write(ex.Message); |
||
378 | Log.Write(ex.StackTrace); |
||
379 | } |
||
380 | |||
381 | 16584d30 | gaqhf | // Input SpecBreak Attribute |
382 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
||
383 | foreach (var item in document.SpecBreaks) |
||
384 | 3734dcc5 | gaqhf | try |
385 | { |
||
386 | InputSpecBreakAttribute(item); |
||
387 | } |
||
388 | catch (Exception ex) |
||
389 | { |
||
390 | Log.Write("Error in InputSpecBreakAttribute"); |
||
391 | Log.Write("UID : " + item.UID); |
||
392 | Log.Write(ex.Message); |
||
393 | Log.Write(ex.StackTrace); |
||
394 | } |
||
395 | |||
396 | 16584d30 | gaqhf | // Label Symbol Modeling |
397 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Labels Modeling"); |
398 | 3939eebf | gaqhf | foreach (var item in document.SYMBOLS) |
399 | 3734dcc5 | gaqhf | try |
400 | { |
||
401 | LabelSymbolModeling(item); |
||
402 | } |
||
403 | catch (Exception ex) |
||
404 | { |
||
405 | Log.Write("Error in LabelSymbolModeling"); |
||
406 | Log.Write("UID : " + item.UID); |
||
407 | Log.Write(ex.Message); |
||
408 | Log.Write(ex.StackTrace); |
||
409 | } |
||
410 | |||
411 | 71ba1ca3 | gaqhf | // LineRun Line Join |
412 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Join LineRuns"); |
||
413 | foreach (LineNumber lineNumber in document.LINENUMBERS) |
||
414 | 3734dcc5 | gaqhf | try |
415 | { |
||
416 | foreach (LineRun run in lineNumber.RUNS) |
||
417 | JoinRunLine(run); |
||
418 | } |
||
419 | catch (Exception ex) |
||
420 | { |
||
421 | Log.Write("Error in JoinRunLine"); |
||
422 | Log.Write("UID : " + lineNumber.UID); |
||
423 | Log.Write(ex.Message); |
||
424 | Log.Write(ex.StackTrace); |
||
425 | } |
||
426 | |||
427 | 71ba1ca3 | gaqhf | // TrimLineRun Line Join |
428 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
429 | 3734dcc5 | gaqhf | try |
430 | { |
||
431 | foreach (LineRun run in trimLine.RUNS) |
||
432 | JoinRunLine(run); |
||
433 | } |
||
434 | catch (Exception ex) |
||
435 | { |
||
436 | Log.Write("Error in JoinRunLine"); |
||
437 | Log.Write("UID : " + trimLine.UID); |
||
438 | Log.Write(ex.Message); |
||
439 | Log.Write(ex.StackTrace); |
||
440 | } |
||
441 | 71ba1ca3 | gaqhf | |
442 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, AllCount); |
443 | 310aeb31 | gaqhf | } |
444 | 809a7640 | gaqhf | } |
445 | 5e6ecf05 | gaqhf | catch (Exception ex) |
446 | { |
||
447 | 9628f54b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.ClearParent, null); |
448 | SplashScreenManager.CloseForm(false); |
||
449 | 5e6ecf05 | gaqhf | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
450 | } |
||
451 | finally |
||
452 | { |
||
453 | 3734dcc5 | gaqhf | Log.Write("End Modeling"); |
454 | 1ba9c671 | gaqhf | application.ActiveWindow.Fit(); |
455 | b2d1c1aa | gaqhf | |
456 | b66a2996 | gaqhf | if (radApp.ActiveDocument != null) |
457 | 3939eebf | gaqhf | { |
458 | b66a2996 | gaqhf | //radApp.ActiveDocument.Save(); |
459 | //radApp.ActiveDocument.SaveOnClose = false; |
||
460 | //radApp.ActiveDocument.Close(false); |
||
461 | |||
462 | 1ba9c671 | gaqhf | ReleaseCOMObjects(newDrawing); |
463 | 3939eebf | gaqhf | } |
464 | 1ba9c671 | gaqhf | |
465 | 5e6ecf05 | gaqhf | ReleaseCOMObjects(dataSource); |
466 | ReleaseCOMObjects(_placement); |
||
467 | 965eb728 | gaqhf | |
468 | 224535bb | gaqhf | Project_DB.InsertDrawingInfo(document.PATH, drawingNumber, drawingName, document); |
469 | 9628f54b | gaqhf | if (SplashScreenManager.Default.IsSplashFormVisible) |
470 | { |
||
471 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.ClearParent, null); |
||
472 | SplashScreenManager.CloseForm(false); |
||
473 | 3734dcc5 | gaqhf | Log.Write("\r\n"); |
474 | 9628f54b | gaqhf | } |
475 | 5e6ecf05 | gaqhf | } |
476 | 65a1ed4b | gaqhf | } |
477 | |||
478 | 74752074 | gaqhf | /// <summary> |
479 | /// 도면 생성 메서드 |
||
480 | /// </summary> |
||
481 | 224535bb | gaqhf | private void CreateDocument(ref string drawingNumber, ref string drawingName) |
482 | 0e0edfad | gaqhf | { |
483 | 3734dcc5 | gaqhf | Log.Write("------------------ Start create document ------------------"); |
484 | 6d12a734 | gaqhf | GetDrawingNameAndNumber(ref drawingName, ref drawingNumber); |
485 | 3734dcc5 | gaqhf | Log.Write("Drawing name : " + drawingName); |
486 | Log.Write("Drawing number : " + drawingNumber); |
||
487 | b66a2996 | gaqhf | newDrawing = application.Drawings.Add(document.Unit, document.Template, drawingNumber, drawingName); |
488 | 88bac50c | gaqhf | document.SPPID_DrawingNumber = drawingNumber; |
489 | document.SPPID_DrawingName = drawingName; |
||
490 | 0e0edfad | gaqhf | application.ActiveWindow.Fit(); |
491 | Thread.Sleep(1000); |
||
492 | application.ActiveWindow.Zoom = 2000; |
||
493 | Thread.Sleep(2000); |
||
494 | b66a2996 | gaqhf | } |
495 | |||
496 | 02480ac1 | gaqhf | /// <summary> |
497 | /// DrawingName, DrawingNumber를 확인하여 중복이 있으면 _1을 붙이고 +1씩 한다. |
||
498 | /// </summary> |
||
499 | /// <param name="drawingName"></param> |
||
500 | /// <param name="drawingNumber"></param> |
||
501 | b66a2996 | gaqhf | private void GetDrawingNameAndNumber(ref string drawingName, ref string drawingNumber) |
502 | { |
||
503 | LMDrawings drawings = new LMDrawings(); |
||
504 | drawings.Collect(dataSource); |
||
505 | 7f00b26c | gaqhf | |
506 | b66a2996 | gaqhf | List<string> drawingNameList = new List<string>(); |
507 | List<string> drawingNumberList = new List<string>(); |
||
508 | |||
509 | foreach (LMDrawing item in drawings) |
||
510 | { |
||
511 | drawingNameList.Add(item.Attributes["Name"].get_Value().ToString()); |
||
512 | drawingNumberList.Add(item.Attributes["DrawingNumber"].get_Value().ToString()); |
||
513 | } |
||
514 | |||
515 | int nameLength = drawingName.Length; |
||
516 | while (drawingNameList.Contains(drawingName)) |
||
517 | { |
||
518 | if (nameLength == drawingName.Length) |
||
519 | drawingName += "-1"; |
||
520 | else |
||
521 | { |
||
522 | int index = Convert.ToInt32(drawingName.Remove(0, nameLength + 1)); |
||
523 | drawingName = drawingName.Substring(0, nameLength + 1); |
||
524 | drawingName += ++index; |
||
525 | } |
||
526 | } |
||
527 | |||
528 | int numberLength = drawingNumber.Length; |
||
529 | while (drawingNameList.Contains(drawingNumber)) |
||
530 | { |
||
531 | if (numberLength == drawingNumber.Length) |
||
532 | drawingNumber += "-1"; |
||
533 | else |
||
534 | { |
||
535 | int index = Convert.ToInt32(drawingNumber.Remove(0, numberLength + 1)); |
||
536 | drawingNumber = drawingNumber.Substring(0, numberLength + 1); |
||
537 | drawingNumber += ++index; |
||
538 | } |
||
539 | } |
||
540 | |||
541 | ReleaseCOMObjects(drawings); |
||
542 | 0e0edfad | gaqhf | } |
543 | |||
544 | 74752074 | gaqhf | /// <summary> |
545 | /// 도면 크기 구하는 메서드 |
||
546 | /// </summary> |
||
547 | /// <returns></returns> |
||
548 | 0e0edfad | gaqhf | private bool DocumentCoordinateCorrection() |
549 | { |
||
550 | 6a7573b0 | gaqhf | if (Settings.Default.DrawingX != 0 && Settings.Default.DrawingY != 0) |
551 | 0e0edfad | gaqhf | { |
552 | 3734dcc5 | gaqhf | Log.Write("Setting Drawing X, Drawing Y"); |
553 | 6a7573b0 | gaqhf | document.SetSPPIDLocation(Settings.Default.DrawingX, Settings.Default.DrawingY); |
554 | 3734dcc5 | gaqhf | Log.Write("Start coordinate correction"); |
555 | c01ce90b | gaqhf | document.CoordinateCorrection(); |
556 | 0e0edfad | gaqhf | return true; |
557 | } |
||
558 | else |
||
559 | 3734dcc5 | gaqhf | { |
560 | Log.Write("Need Drawing X, Y"); |
||
561 | 0e0edfad | gaqhf | return false; |
562 | 3734dcc5 | gaqhf | } |
563 | 0e0edfad | gaqhf | } |
564 | |||
565 | 74752074 | gaqhf | /// <summary> |
566 | /// 라인을 Run 단위로 모델링하는 진입 메서드 |
||
567 | /// </summary> |
||
568 | /// <param name="run"></param> |
||
569 | 8aa6f2db | gaqhf | private void LineModelingByRun(LineRun run) |
570 | 809a7640 | gaqhf | { |
571 | Line prevLine = null; |
||
572 | List<Line> lines = new List<Line>(); |
||
573 | foreach (var item in run.RUNITEMS) |
||
574 | { |
||
575 | // Line일 경우 |
||
576 | if (item.GetType() == typeof(Line)) |
||
577 | { |
||
578 | Line line = item as Line; |
||
579 | if (prevLine == null) |
||
580 | lines.Add(line); |
||
581 | else if (prevLine != null) |
||
582 | { |
||
583 | if (prevLine.SPPID.MAPPINGNAME == line.SPPID.MAPPINGNAME) |
||
584 | lines.Add(line); |
||
585 | else |
||
586 | f1c9dbaa | gaqhf | { |
587 | f2baa6a3 | gaqhf | if (lines.Count > 0) |
588 | { |
||
589 | LineModeling(lines); |
||
590 | lines.Clear(); |
||
591 | } |
||
592 | 809a7640 | gaqhf | lines.Add(line); |
593 | 5dfb8a24 | gaqhf | } |
594 | } |
||
595 | |||
596 | 809a7640 | gaqhf | prevLine = line; |
597 | f31645b6 | gaqhf | |
598 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
599 | 809a7640 | gaqhf | } |
600 | // Symbol 일 경우 |
||
601 | else if (item.GetType() == typeof(Symbol)) |
||
602 | { |
||
603 | f1c9dbaa | gaqhf | if (lines.Count > 0) |
604 | 809a7640 | gaqhf | { |
605 | f1c9dbaa | gaqhf | LineModeling(lines); |
606 | 809a7640 | gaqhf | lines.Clear(); |
607 | } |
||
608 | 5dfb8a24 | gaqhf | } |
609 | } |
||
610 | |||
611 | 809a7640 | gaqhf | if (lines.Count > 0) |
612 | LineModeling(lines); |
||
613 | } |
||
614 | 5dfb8a24 | gaqhf | |
615 | 74752074 | gaqhf | /// <summary> |
616 | /// 심볼을 Run 단위로 모델링하는 진입 메서드 |
||
617 | /// </summary> |
||
618 | /// <param name="run"></param> |
||
619 | 8aa6f2db | gaqhf | private void SymbolModelingByRun(LineRun run) |
620 | 809a7640 | gaqhf | { |
621 | // 양끝 Symbol 검사 후 Line이 나올때까지만 Symbol Modeling |
||
622 | if (run.RUNITEMS.Count > 0) |
||
623 | { |
||
624 | if (run.RUNITEMS[0].GetType() == typeof(Symbol)) |
||
625 | SymbolModelingByRunStart(run.RUNITEMS[0] as Symbol, run); |
||
626 | |||
627 | if (run.RUNITEMS[run.RUNITEMS.Count - 1].GetType() == typeof(Symbol)) |
||
628 | SymbolModelingByRunEnd(run.RUNITEMS[run.RUNITEMS.Count - 1] as Symbol, run); |
||
629 | } |
||
630 | |||
631 | Symbol targetSymbol = null; |
||
632 | foreach (var item in run.RUNITEMS) |
||
633 | { |
||
634 | if (item.GetType() == typeof(Symbol)) |
||
635 | { |
||
636 | Symbol symbol = item as Symbol; |
||
637 | b2d1c1aa | gaqhf | SymbolModeling(symbol, targetSymbol); |
638 | 809a7640 | gaqhf | targetSymbol = symbol; |
639 | } |
||
640 | else |
||
641 | { |
||
642 | targetSymbol = null; |
||
643 | } |
||
644 | } |
||
645 | } |
||
646 | |||
647 | 74752074 | gaqhf | /// <summary> |
648 | /// Run에 있는 심볼을 모델링하는데 기준이 Run의 시작점 |
||
649 | /// </summary> |
||
650 | /// <param name="symbol"></param> |
||
651 | /// <param name="run"></param> |
||
652 | 8aa6f2db | gaqhf | private void SymbolModelingByRunStart(Symbol symbol, LineRun run) |
653 | 809a7640 | gaqhf | { |
654 | foreach (var connector in symbol.CONNECTORS) |
||
655 | { |
||
656 | object targetItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
657 | if (targetItem != null && |
||
658 | (targetItem.GetType() == typeof(Symbol) || targetItem.GetType() == typeof(Equipment)) && |
||
659 | 74752074 | gaqhf | !IsSameLineRun(symbol, targetItem)) |
660 | 809a7640 | gaqhf | { |
661 | b2d1c1aa | gaqhf | SymbolModeling(symbol, targetItem as Symbol); |
662 | 809a7640 | gaqhf | for (int i = 1; i < run.RUNITEMS.Count; i++) |
663 | { |
||
664 | object item = run.RUNITEMS[i]; |
||
665 | if (item.GetType() == typeof(Symbol)) |
||
666 | b2d1c1aa | gaqhf | SymbolModeling(item as Symbol, run.RUNITEMS[i - 1] as Symbol); |
667 | 809a7640 | gaqhf | else |
668 | break; |
||
669 | } |
||
670 | break; |
||
671 | } |
||
672 | } |
||
673 | |||
674 | |||
675 | } |
||
676 | |||
677 | 74752074 | gaqhf | /// <summary> |
678 | /// Run에 있는 심볼을 모델링하는데 기준이 Run의 끝점 |
||
679 | /// </summary> |
||
680 | /// <param name="symbol"></param> |
||
681 | /// <param name="run"></param> |
||
682 | 8aa6f2db | gaqhf | private void SymbolModelingByRunEnd(Symbol symbol, LineRun run) |
683 | 809a7640 | gaqhf | { |
684 | foreach (var connector in symbol.CONNECTORS) |
||
685 | { |
||
686 | object targetItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
687 | if (targetItem != null && |
||
688 | (targetItem.GetType() == typeof(Symbol) || targetItem.GetType() == typeof(Equipment)) && |
||
689 | 74752074 | gaqhf | !IsSameLineRun(symbol, targetItem)) |
690 | 809a7640 | gaqhf | { |
691 | b2d1c1aa | gaqhf | SymbolModeling(symbol, targetItem as Symbol); |
692 | 809a7640 | gaqhf | for (int i = run.RUNITEMS.Count - 2; i >= 0; i--) |
693 | { |
||
694 | object item = run.RUNITEMS[i]; |
||
695 | if (item.GetType() == typeof(Symbol)) |
||
696 | b2d1c1aa | gaqhf | SymbolModeling(item as Symbol, run.RUNITEMS[i + 1] as Symbol); |
697 | 809a7640 | gaqhf | else |
698 | break; |
||
699 | } |
||
700 | break; |
||
701 | } |
||
702 | } |
||
703 | 5dfb8a24 | gaqhf | } |
704 | cfda1fed | gaqhf | |
705 | 74752074 | gaqhf | /// <summary> |
706 | /// 심볼을 실제로 Modeling 메서드 |
||
707 | /// </summary> |
||
708 | /// <param name="symbol"></param> |
||
709 | /// <param name="targetSymbol"></param> |
||
710 | /// <param name="prevSymbol"></param> |
||
711 | b2d1c1aa | gaqhf | private void SymbolModeling(Symbol symbol, Symbol targetSymbol) |
712 | 809a7640 | gaqhf | { |
713 | 7f00b26c | gaqhf | // OWNERSYMBOL Attribute, 값을 가지고 있을 경우 |
714 | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(attr => attr.ATTRIBUTE == "OWNERSYMBOL"); |
||
715 | if (itemAttribute != null && (string.IsNullOrEmpty(itemAttribute.VALUE) || itemAttribute.VALUE != "None")) |
||
716 | return; |
||
717 | // 이미 모델링 됐을 경우 |
||
718 | else if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
719 | return; |
||
720 | 6a7573b0 | gaqhf | |
721 | 7f00b26c | gaqhf | LMSymbol _LMSymbol = null; |
722 | 809a7640 | gaqhf | |
723 | 7f00b26c | gaqhf | string mappingPath = symbol.SPPID.MAPPINGNAME; |
724 | double x = symbol.SPPID.ORIGINAL_X; |
||
725 | double y = symbol.SPPID.ORIGINAL_Y; |
||
726 | int mirror = 0; |
||
727 | double angle = symbol.ANGLE; |
||
728 | 2fdb56bf | gaqhf | |
729 | 7f00b26c | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
730 | 1ab9a205 | gaqhf | |
731 | 7f00b26c | gaqhf | // OPC 일경우 180도 일때 Mirror |
732 | if (mappingPath.Contains("Piping OPC's") && angle == Math.PI) |
||
733 | mirror = 1; |
||
734 | 1ab9a205 | gaqhf | |
735 | 7f00b26c | gaqhf | // Mirror 계산 |
736 | if (symbol.FLIP == 1) |
||
737 | { |
||
738 | mirror = 1; |
||
739 | angle += Math.PI; |
||
740 | } |
||
741 | 1ab9a205 | gaqhf | |
742 | 7f00b26c | gaqhf | if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId)) |
743 | { |
||
744 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
745 | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, symbol.UID, targetSymbol); |
||
746 | if (connector != null) |
||
747 | GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y); |
||
748 | 809a7640 | gaqhf | |
749 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
750 | 809a7640 | gaqhf | |
751 | 7f00b26c | gaqhf | if (_LMSymbol != null && _TargetItem != null) |
752 | 6a7573b0 | gaqhf | { |
753 | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
754 | 7f00b26c | gaqhf | LMConnector reModelingConnector = FindBreakLineTarget(symbol, targetSymbol); |
755 | ac78b508 | gaqhf | |
756 | 7f00b26c | gaqhf | if (reModelingConnector != null) |
757 | ReModelingLMConnector(reModelingConnector); |
||
758 | 6a7573b0 | gaqhf | } |
759 | 809a7640 | gaqhf | |
760 | 7f00b26c | gaqhf | ReleaseCOMObjects(_TargetItem); |
761 | 4d2571ab | gaqhf | } |
762 | 7f00b26c | gaqhf | else |
763 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
764 | |||
765 | if (_LMSymbol != null) |
||
766 | 4d2571ab | gaqhf | { |
767 | 7f00b26c | gaqhf | _LMSymbol.Commit(); |
768 | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
769 | symbol.SPPID.ModelItemID = _LMSymbol.ModelItemID; |
||
770 | symbol.SPPID.GraphicOID = _LMSymbol.get_GraphicOID(); |
||
771 | |||
772 | foreach (var item in symbol.ChildSymbols) |
||
773 | CreateChildSymbol(item, _LMSymbol); |
||
774 | 3734dcc5 | gaqhf | |
775 | d9794a6c | gaqhf | symbol.SPPID.SPPID_X = _LMSymbol.get_XCoordinate(); |
776 | symbol.SPPID.SPPID_Y = _LMSymbol.get_YCoordinate(); |
||
777 | |||
778 | double[] range = null; |
||
779 | GetSPPIDSymbolRange(symbol, ref range); |
||
780 | symbol.SPPID.SPPID_Min_X = range[0]; |
||
781 | symbol.SPPID.SPPID_Min_Y = range[1]; |
||
782 | symbol.SPPID.SPPID_Max_X = range[2]; |
||
783 | symbol.SPPID.SPPID_Max_Y = range[3]; |
||
784 | |||
785 | foreach (var item in symbol.SPPID.CorrectionX_GroupSymbols) |
||
786 | item.SPPID.ORIGINAL_X = symbol.SPPID.SPPID_X; |
||
787 | foreach (var item in symbol.SPPID.CorrectionY_GroupSymbols) |
||
788 | item.SPPID.ORIGINAL_Y = symbol.SPPID.SPPID_Y; |
||
789 | |||
790 | 3734dcc5 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
791 | 4d2571ab | gaqhf | } |
792 | 7f00b26c | gaqhf | |
793 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
794 | 809a7640 | gaqhf | } |
795 | |||
796 | d9794a6c | gaqhf | private void RemoveSymbol(Symbol symbol) |
797 | { |
||
798 | if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
799 | { |
||
800 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
801 | if (_LMSymbol != null) |
||
802 | { |
||
803 | _placement.PIDRemovePlacement(_LMSymbol.AsLMRepresentation()); |
||
804 | ReleaseCOMObjects(_LMSymbol); |
||
805 | } |
||
806 | } |
||
807 | |||
808 | symbol.SPPID.RepresentationId = string.Empty; |
||
809 | symbol.SPPID.ModelItemID = string.Empty; |
||
810 | symbol.SPPID.SPPID_X = double.NaN; |
||
811 | symbol.SPPID.SPPID_Y = double.NaN; |
||
812 | symbol.SPPID.SPPID_Min_X = double.NaN; |
||
813 | symbol.SPPID.SPPID_Min_Y = double.NaN; |
||
814 | symbol.SPPID.SPPID_Max_X = double.NaN; |
||
815 | symbol.SPPID.SPPID_Max_Y = double.NaN; |
||
816 | } |
||
817 | |||
818 | private void RemoveSymbol(List<Symbol> symbols) |
||
819 | { |
||
820 | foreach (var symbol in symbols) |
||
821 | { |
||
822 | if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
823 | { |
||
824 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
825 | if (_LMSymbol != null) |
||
826 | { |
||
827 | _placement.PIDRemovePlacement(_LMSymbol.AsLMRepresentation()); |
||
828 | ReleaseCOMObjects(_LMSymbol); |
||
829 | } |
||
830 | } |
||
831 | |||
832 | symbol.SPPID.RepresentationId = string.Empty; |
||
833 | symbol.SPPID.ModelItemID = string.Empty; |
||
834 | symbol.SPPID.SPPID_X = double.NaN; |
||
835 | symbol.SPPID.SPPID_Y = double.NaN; |
||
836 | symbol.SPPID.SPPID_Min_X = double.NaN; |
||
837 | symbol.SPPID.SPPID_Min_Y = double.NaN; |
||
838 | symbol.SPPID.SPPID_Max_X = double.NaN; |
||
839 | symbol.SPPID.SPPID_Max_Y = double.NaN; |
||
840 | } |
||
841 | } |
||
842 | |||
843 | d1eac84d | gaqhf | /// <summary> |
844 | /// ID2의 Symbol Width와 Height를 비교해서 상대적인 SPPID Connector좌표를 가져온다. |
||
845 | /// </summary> |
||
846 | /// <param name="targetConnector"></param> |
||
847 | /// <param name="targetSymbol"></param> |
||
848 | /// <param name="x"></param> |
||
849 | /// <param name="y"></param> |
||
850 | private void GetTargetSymbolConnectorPoint(Connector targetConnector, Symbol targetSymbol, ref double x, ref double y) |
||
851 | { |
||
852 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
853 | 2fdb56bf | gaqhf | |
854 | double[] range = null; |
||
855 | d1eac84d | gaqhf | List<double[]> points = new List<double[]>(); |
856 | 2fdb56bf | gaqhf | GetSPPIDSymbolRangeAndConnectionPoints(targetSymbol, ref range, points); |
857 | double x1 = range[0]; |
||
858 | double y1 = range[1]; |
||
859 | double x2 = range[2]; |
||
860 | double y2 = range[3]; |
||
861 | d1eac84d | gaqhf | |
862 | // Origin 기준 Connector의 위치차이 |
||
863 | double sceneX = 0; |
||
864 | double sceneY = 0; |
||
865 | SPPIDUtil.ConvertPointBystring(targetConnector.SCENECONNECTPOINT, ref sceneX, ref sceneY); |
||
866 | double originX = 0; |
||
867 | double originY = 0; |
||
868 | SPPIDUtil.ConvertPointBystring(targetSymbol.ORIGINALPOINT, ref originX, ref originY); |
||
869 | double gapX = originX - sceneX; |
||
870 | double gapY = originY - sceneY; |
||
871 | |||
872 | // SPPID Symbol과 ID2 심볼의 크기 차이 |
||
873 | double sizeWidth = 0; |
||
874 | double sizeHeight = 0; |
||
875 | SPPIDUtil.ConvertPointBystring(targetSymbol.SIZE, ref sizeWidth, ref sizeHeight); |
||
876 | double percentX = (x2 - x1) / sizeWidth; |
||
877 | double percentY = (y2 - y1) / sizeHeight; |
||
878 | |||
879 | double SPPIDgapX = gapX * percentX; |
||
880 | double SPPIDgapY = gapY * percentY; |
||
881 | |||
882 | double[] SPPIDOriginPoint = new double[] { _TargetItem.get_XCoordinate() - SPPIDgapX, _TargetItem.get_YCoordinate() + SPPIDgapY }; |
||
883 | double distance = double.MaxValue; |
||
884 | double[] resultPoint; |
||
885 | foreach (var point in points) |
||
886 | { |
||
887 | double result = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], SPPIDOriginPoint[0], SPPIDOriginPoint[1]); |
||
888 | if (distance > result) |
||
889 | { |
||
890 | distance = result; |
||
891 | resultPoint = point; |
||
892 | x = point[0]; |
||
893 | y = point[1]; |
||
894 | } |
||
895 | } |
||
896 | 2fdb56bf | gaqhf | |
897 | ReleaseCOMObjects(_TargetItem); |
||
898 | } |
||
899 | |||
900 | /// <summary> |
||
901 | /// SPPID Symbol의 Range를 구한다. |
||
902 | /// </summary> |
||
903 | /// <param name="symbol"></param> |
||
904 | /// <param name="range"></param> |
||
905 | private void GetSPPIDSymbolRangeAndConnectionPoints(Symbol symbol, ref double[] range, List<double[]> points) |
||
906 | { |
||
907 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
908 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
909 | double x1 = 0; |
||
910 | double y1 = 0; |
||
911 | double x2 = 0; |
||
912 | double y2 = 0; |
||
913 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
914 | range = new double[] { x1, y1, x2, y2 }; |
||
915 | |||
916 | for (int i = 1; i < int.MaxValue; i++) |
||
917 | { |
||
918 | double connX = 0; |
||
919 | double connY = 0; |
||
920 | if (_placement.PIDConnectPointLocation(_TargetItem, i, ref connX, ref connY)) |
||
921 | points.Add(new double[] { connX, connY }); |
||
922 | else |
||
923 | break; |
||
924 | } |
||
925 | |||
926 | foreach (var childSymbol in symbol.ChildSymbols) |
||
927 | GetSPPIDChildSymbolRange(childSymbol, ref range, points); |
||
928 | |||
929 | ReleaseCOMObjects(_TargetItem); |
||
930 | } |
||
931 | |||
932 | d9794a6c | gaqhf | private void GetSPPIDSymbolRange(Symbol symbol, ref double[] range) |
933 | { |
||
934 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
935 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
936 | double x1 = 0; |
||
937 | double y1 = 0; |
||
938 | double x2 = 0; |
||
939 | double y2 = 0; |
||
940 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
941 | range = new double[] { x1, y1, x2, y2 }; |
||
942 | |||
943 | foreach (var childSymbol in symbol.ChildSymbols) |
||
944 | GetSPPIDChildSymbolRange(childSymbol, ref range); |
||
945 | |||
946 | ReleaseCOMObjects(_TargetItem); |
||
947 | } |
||
948 | |||
949 | private void GetSPPIDSymbolRange(List<Symbol> symbols, ref double[] range) |
||
950 | { |
||
951 | double[] tempRange = new double[] { double.MaxValue, double.MaxValue, double.MinValue, double.MinValue }; |
||
952 | foreach (var symbol in symbols) |
||
953 | { |
||
954 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
955 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
956 | double x1 = 0; |
||
957 | double y1 = 0; |
||
958 | double x2 = 0; |
||
959 | double y2 = 0; |
||
960 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
961 | |||
962 | tempRange[0] = Math.Min(tempRange[0], x1); |
||
963 | tempRange[1] = Math.Min(tempRange[1], y1); |
||
964 | tempRange[2] = Math.Max(tempRange[2], x2); |
||
965 | tempRange[3] = Math.Max(tempRange[3], y2); |
||
966 | |||
967 | foreach (var childSymbol in symbol.ChildSymbols) |
||
968 | GetSPPIDChildSymbolRange(childSymbol, ref range); |
||
969 | |||
970 | ReleaseCOMObjects(_TargetItem); |
||
971 | } |
||
972 | |||
973 | range = tempRange; |
||
974 | } |
||
975 | |||
976 | 2fdb56bf | gaqhf | /// <summary> |
977 | /// Child Modeling 된 Symbol의 Range를 구한다. |
||
978 | /// </summary> |
||
979 | /// <param name="childSymbol"></param> |
||
980 | /// <param name="range"></param> |
||
981 | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range, List<double[]> points) |
||
982 | { |
||
983 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
984 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
||
985 | double x1 = 0; |
||
986 | double y1 = 0; |
||
987 | double x2 = 0; |
||
988 | double y2 = 0; |
||
989 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
990 | range[0] = Math.Min(range[0], x1); |
||
991 | range[1] = Math.Min(range[1], y1); |
||
992 | range[2] = Math.Max(range[2], x2); |
||
993 | range[3] = Math.Max(range[3], y2); |
||
994 | |||
995 | for (int i = 1; i < int.MaxValue; i++) |
||
996 | { |
||
997 | double connX = 0; |
||
998 | double connY = 0; |
||
999 | if (_placement.PIDConnectPointLocation(_ChildSymbol, i, ref connX, ref connY)) |
||
1000 | points.Add(new double[] { connX, connY }); |
||
1001 | else |
||
1002 | break; |
||
1003 | } |
||
1004 | |||
1005 | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
||
1006 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range, points); |
||
1007 | |||
1008 | ReleaseCOMObjects(_ChildSymbol); |
||
1009 | d1eac84d | gaqhf | } |
1010 | |||
1011 | d9794a6c | gaqhf | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range) |
1012 | { |
||
1013 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
1014 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
||
1015 | double x1 = 0; |
||
1016 | double y1 = 0; |
||
1017 | double x2 = 0; |
||
1018 | double y2 = 0; |
||
1019 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1020 | range[0] = Math.Min(range[0], x1); |
||
1021 | range[1] = Math.Min(range[1], y1); |
||
1022 | range[2] = Math.Max(range[2], x2); |
||
1023 | range[3] = Math.Max(range[3], y2); |
||
1024 | |||
1025 | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
||
1026 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range); |
||
1027 | |||
1028 | ReleaseCOMObjects(_ChildSymbol); |
||
1029 | } |
||
1030 | |||
1031 | d1eac84d | gaqhf | /// <summary> |
1032 | /// Label Symbol Modeling |
||
1033 | /// </summary> |
||
1034 | /// <param name="symbol"></param> |
||
1035 | 73415441 | gaqhf | private void LabelSymbolModeling(Symbol symbol) |
1036 | { |
||
1037 | fb386b8c | gaqhf | if (string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
1038 | 73415441 | gaqhf | { |
1039 | fb386b8c | gaqhf | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
1040 | if (itemAttribute == null || string.IsNullOrEmpty(itemAttribute.VALUE) || itemAttribute.VALUE == "None") |
||
1041 | return; |
||
1042 | Array points = new double[] { 0, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y }; |
||
1043 | |||
1044 | string symbolUID = itemAttribute.VALUE; |
||
1045 | object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
||
1046 | if (targetItem != null && |
||
1047 | (targetItem.GetType() == typeof(Symbol) || |
||
1048 | targetItem.GetType() == typeof(Equipment))) |
||
1049 | 73415441 | gaqhf | { |
1050 | fb386b8c | gaqhf | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
1051 | string sRep = null; |
||
1052 | if (targetItem.GetType() == typeof(Symbol)) |
||
1053 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
1054 | else if (targetItem.GetType() == typeof(Equipment)) |
||
1055 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
1056 | if (!string.IsNullOrEmpty(sRep)) |
||
1057 | 73415441 | gaqhf | { |
1058 | fb386b8c | gaqhf | // LEADER Line 검사 |
1059 | bool leaderLine = false; |
||
1060 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
1061 | if (symbolMapping != null) |
||
1062 | leaderLine = symbolMapping.LEADERLINE; |
||
1063 | |||
1064 | // Target Symbol Item 가져오고 Label Modeling |
||
1065 | LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
||
1066 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
1067 | |||
1068 | //Leader 선 센터로 |
||
1069 | if (_LMLabelPresist != null) |
||
1070 | 73415441 | gaqhf | { |
1071 | fb386b8c | gaqhf | // Target Item에 Label의 Attribute Input |
1072 | InputSymbolAttribute(targetItem, symbol.ATTRIBUTES); |
||
1073 | |||
1074 | string OID = _LMLabelPresist.get_GraphicOID(); |
||
1075 | DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
||
1076 | if (dependency != null) |
||
1077 | 73415441 | gaqhf | { |
1078 | fb386b8c | gaqhf | bool result = false; |
1079 | foreach (var attributes in dependency.AttributeSets) |
||
1080 | 73415441 | gaqhf | { |
1081 | fb386b8c | gaqhf | foreach (var attribute in attributes) |
1082 | 73415441 | gaqhf | { |
1083 | fb386b8c | gaqhf | string name = attribute.Name; |
1084 | string value = attribute.GetValue().ToString(); |
||
1085 | if (name == "DrawingItemType" && value == "LabelPersist") |
||
1086 | 73415441 | gaqhf | { |
1087 | fb386b8c | gaqhf | foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
1088 | b2d1c1aa | gaqhf | { |
1089 | fb386b8c | gaqhf | if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
1090 | { |
||
1091 | Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
||
1092 | double prevX = _TargetItem.get_XCoordinate(); |
||
1093 | double prevY = _TargetItem.get_YCoordinate(); |
||
1094 | lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
||
1095 | lineString2D.RemoveVertex(lineString2D.VertexCount); |
||
1096 | result = true; |
||
1097 | break; |
||
1098 | } |
||
1099 | b2d1c1aa | gaqhf | } |
1100 | 73415441 | gaqhf | } |
1101 | fb386b8c | gaqhf | |
1102 | if (result) |
||
1103 | break; |
||
1104 | 73415441 | gaqhf | } |
1105 | b2d1c1aa | gaqhf | |
1106 | if (result) |
||
1107 | break; |
||
1108 | 73415441 | gaqhf | } |
1109 | } |
||
1110 | fb386b8c | gaqhf | |
1111 | _LMLabelPresist.Commit(); |
||
1112 | ReleaseCOMObjects(_LMLabelPresist); |
||
1113 | 73415441 | gaqhf | } |
1114 | |||
1115 | fb386b8c | gaqhf | ReleaseCOMObjects(_TargetItem); |
1116 | b2d1c1aa | gaqhf | } |
1117 | 73415441 | gaqhf | } |
1118 | fb386b8c | gaqhf | else if (targetItem != null && targetItem.GetType() == typeof(Line)) |
1119 | 0860c756 | gaqhf | { |
1120 | fb386b8c | gaqhf | Line targetLine = targetItem as Line; |
1121 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(targetLine.SPPID.ModelItemId); |
||
1122 | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y); |
||
1123 | if (connectedLMConnector != null) |
||
1124 | 0860c756 | gaqhf | { |
1125 | fb386b8c | gaqhf | // LEADER Line 검사 |
1126 | bool leaderLine = false; |
||
1127 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
1128 | if (symbolMapping != null) |
||
1129 | leaderLine = symbolMapping.LEADERLINE; |
||
1130 | |||
1131 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
1132 | if (_LMLabelPresist != null) |
||
1133 | { |
||
1134 | _LMLabelPresist.Commit(); |
||
1135 | ReleaseCOMObjects(_LMLabelPresist); |
||
1136 | } |
||
1137 | ReleaseCOMObjects(connectedLMConnector); |
||
1138 | 0860c756 | gaqhf | } |
1139 | |||
1140 | fb386b8c | gaqhf | foreach (var item in connectorVertices) |
1141 | if (item.Key != null) |
||
1142 | ReleaseCOMObjects(item.Key); |
||
1143 | } |
||
1144 | 0860c756 | gaqhf | } |
1145 | 73415441 | gaqhf | |
1146 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1147 | } |
||
1148 | |||
1149 | 74752074 | gaqhf | /// <summary> |
1150 | /// Equipment를 실제로 Modeling 메서드 |
||
1151 | /// </summary> |
||
1152 | /// <param name="equipment"></param> |
||
1153 | b9e9f4c8 | gaqhf | private void EquipmentModeling(Equipment equipment) |
1154 | { |
||
1155 | if (!string.IsNullOrEmpty(equipment.SPPID.RepresentationId)) |
||
1156 | return; |
||
1157 | |||
1158 | LMSymbol _LMSymbol = null; |
||
1159 | LMSymbol targetItem = null; |
||
1160 | string mappingPath = equipment.SPPID.MAPPINGNAME; |
||
1161 | double x = equipment.SPPID.ORIGINAL_X; |
||
1162 | double y = equipment.SPPID.ORIGINAL_Y; |
||
1163 | int mirror = 0; |
||
1164 | double angle = equipment.ANGLE; |
||
1165 | |||
1166 | 20972c61 | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
1167 | |||
1168 | b9e9f4c8 | gaqhf | Connector connector = equipment.CONNECTORS.Find(conn => !string.IsNullOrEmpty(conn.CONNECTEDITEM) && conn.CONNECTEDITEM != "None"); |
1169 | if (connector != null) |
||
1170 | { |
||
1171 | Equipment connEquipment = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Equipment; |
||
1172 | if (connEquipment != null) |
||
1173 | { |
||
1174 | if (string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
1175 | EquipmentModeling(connEquipment); |
||
1176 | |||
1177 | if (!string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
1178 | { |
||
1179 | targetItem = dataSource.GetSymbol(connEquipment.SPPID.RepresentationId); |
||
1180 | if (targetItem != null) |
||
1181 | { |
||
1182 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: targetItem); |
||
1183 | } |
||
1184 | else |
||
1185 | { |
||
1186 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1187 | } |
||
1188 | } |
||
1189 | else |
||
1190 | { |
||
1191 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1192 | } |
||
1193 | } |
||
1194 | else |
||
1195 | { |
||
1196 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1197 | } |
||
1198 | } |
||
1199 | else |
||
1200 | { |
||
1201 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1202 | } |
||
1203 | |||
1204 | if (_LMSymbol != null) |
||
1205 | { |
||
1206 | _LMSymbol.Commit(); |
||
1207 | equipment.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
1208 | 20972c61 | gaqhf | equipment.SPPID.GraphicOID = _LMSymbol.get_GraphicOID(); |
1209 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1210 | } |
||
1211 | |||
1212 | if (targetItem != null) |
||
1213 | { |
||
1214 | ReleaseCOMObjects(targetItem); |
||
1215 | } |
||
1216 | 7f00b26c | gaqhf | |
1217 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1218 | f31645b6 | gaqhf | |
1219 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1220 | b9e9f4c8 | gaqhf | } |
1221 | |||
1222 | 4d2571ab | gaqhf | private void SymbolModelingByPriority(Symbol symbol) |
1223 | d1eac84d | gaqhf | { |
1224 | 4d2571ab | gaqhf | // Angle, Center, 우선순위 모델링 |
1225 | d9794a6c | gaqhf | if (string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
1226 | { |
||
1227 | SymbolModeling(symbol, null); |
||
1228 | List<Symbol> group = new List<Symbol>() { symbol }; |
||
1229 | SPPIDUtil.FindConnectedSymbolGroup(document, symbol, group); |
||
1230 | List<Symbol> endModeling = new List<Symbol>() { symbol }; |
||
1231 | |||
1232 | while (endModeling.Count != group.Count) |
||
1233 | { |
||
1234 | foreach (var item in group) |
||
1235 | { |
||
1236 | if (!endModeling.Contains(item)) |
||
1237 | { |
||
1238 | bool result = false; |
||
1239 | foreach (var connector in item.CONNECTORS) |
||
1240 | { |
||
1241 | Symbol connSymbol = group.Find(x => x.UID == connector.CONNECTEDITEM); |
||
1242 | if (connSymbol == item) |
||
1243 | throw new Exception(""); |
||
1244 | 3734dcc5 | gaqhf | |
1245 | d9794a6c | gaqhf | if (connSymbol != null && endModeling.Contains(connSymbol)) |
1246 | { |
||
1247 | SymbolModeling(item, connSymbol); |
||
1248 | endModeling.Add(item); |
||
1249 | result = true; |
||
1250 | break; |
||
1251 | } |
||
1252 | } |
||
1253 | |||
1254 | if (result) |
||
1255 | break; |
||
1256 | } |
||
1257 | } |
||
1258 | } |
||
1259 | |||
1260 | SymbolModelingBySymbol(symbol); |
||
1261 | } |
||
1262 | } |
||
1263 | |||
1264 | /// <summary> |
||
1265 | /// 첫 진입점 |
||
1266 | /// </summary> |
||
1267 | /// <param name="symbol"></param> |
||
1268 | private void SymbolModelingBySymbol(Symbol symbol) |
||
1269 | { |
||
1270 | List<object> endObjects = new List<object>(); |
||
1271 | endObjects.Add(symbol); |
||
1272 | foreach (var connector in symbol.CONNECTORS) |
||
1273 | 4d2571ab | gaqhf | { |
1274 | d9794a6c | gaqhf | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
1275 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1276 | d1eac84d | gaqhf | { |
1277 | d9794a6c | gaqhf | endObjects.Add(connItem); |
1278 | if (connItem.GetType() == typeof(Symbol)) |
||
1279 | 4d2571ab | gaqhf | { |
1280 | d9794a6c | gaqhf | Symbol connSymbol = connItem as Symbol; |
1281 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1282 | 4d2571ab | gaqhf | { |
1283 | d9794a6c | gaqhf | SymbolModeling(connSymbol, symbol); |
1284 | } |
||
1285 | SymbolModelingByNeerPrioritySymbolLoop(connSymbol, endObjects); |
||
1286 | } |
||
1287 | else if (connItem.GetType() == typeof(Line)) |
||
1288 | { |
||
1289 | Line connLine = connItem as Line; |
||
1290 | SymbolModelingByNeerPriorityLineLoop(connLine, endObjects, symbol); |
||
1291 | } |
||
1292 | } |
||
1293 | } |
||
1294 | } |
||
1295 | 4d2571ab | gaqhf | |
1296 | d9794a6c | gaqhf | private void SymbolModelingByNeerPrioritySymbolLoop(Symbol symbol, List<object> endObjects) |
1297 | { |
||
1298 | foreach (var connector in symbol.CONNECTORS) |
||
1299 | { |
||
1300 | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
1301 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1302 | { |
||
1303 | if (!endObjects.Contains(connItem)) |
||
1304 | { |
||
1305 | endObjects.Add(connItem); |
||
1306 | if (connItem.GetType() == typeof(Symbol)) |
||
1307 | { |
||
1308 | Symbol connSymbol = connItem as Symbol; |
||
1309 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1310 | 4d2571ab | gaqhf | { |
1311 | d9794a6c | gaqhf | SymbolModeling(connSymbol, symbol); |
1312 | 4d2571ab | gaqhf | } |
1313 | d9794a6c | gaqhf | SymbolModelingByNeerPrioritySymbolLoop(connSymbol, endObjects); |
1314 | 4d2571ab | gaqhf | } |
1315 | d9794a6c | gaqhf | else if (connItem.GetType() == typeof(Line)) |
1316 | { |
||
1317 | Line connLine = connItem as Line; |
||
1318 | SymbolModelingByNeerPriorityLineLoop(connLine, endObjects, symbol); |
||
1319 | } |
||
1320 | } |
||
1321 | } |
||
1322 | } |
||
1323 | } |
||
1324 | 4d2571ab | gaqhf | |
1325 | d9794a6c | gaqhf | private void SymbolModelingByNeerPriorityLineLoop(Line line, List<object> endObjects, Symbol prevSymbol) |
1326 | { |
||
1327 | foreach (var connector in line.CONNECTORS) |
||
1328 | { |
||
1329 | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
1330 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1331 | { |
||
1332 | if (!endObjects.Contains(connItem)) |
||
1333 | { |
||
1334 | endObjects.Add(connItem); |
||
1335 | if (connItem.GetType() == typeof(Symbol)) |
||
1336 | { |
||
1337 | Symbol connSymbol = connItem as Symbol; |
||
1338 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1339 | { |
||
1340 | List<Symbol> group = new List<Symbol>(); |
||
1341 | SPPIDUtil.FindConnectedSymbolGroup(document, connSymbol, group); |
||
1342 | if (group.Count == 3) |
||
1343 | { |
||
1344 | Symbol symbol = SPPIDUtil.FindCenterAtThreeSymbols(document, group); |
||
1345 | SymbolModeling(symbol, null); |
||
1346 | foreach (var _temp in group) |
||
1347 | if (_temp != symbol && string.IsNullOrEmpty(_temp.SPPID.RepresentationId)) |
||
1348 | SymbolModeling(_temp, symbol); |
||
1349 | |||
1350 | // Range 겹치는지 확인해야함 |
||
1351 | double[] prevRange = null; |
||
1352 | GetSPPIDSymbolRange(prevSymbol, ref prevRange); |
||
1353 | double[] groupRange = null; |
||
1354 | GetSPPIDSymbolRange(group, ref groupRange); |
||
1355 | |||
1356 | double distanceX = 0; |
||
1357 | double distanceY = 0; |
||
1358 | 6d12a734 | gaqhf | bool overlapX = false; |
1359 | bool overlapY = false; |
||
1360 | SlopeType slopeType = SPPIDUtil.CalcSlope(prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y); |
||
1361 | SPPIDUtil.CalcOverlap(prevRange, groupRange, ref distanceX, ref distanceY, ref overlapX, ref overlapY); |
||
1362 | if ((slopeType == SlopeType.HORIZONTAL && overlapX) || |
||
1363 | (slopeType == SlopeType.VERTICAL && overlapY)) |
||
1364 | d9794a6c | gaqhf | { |
1365 | RemoveSymbol(group); |
||
1366 | foreach (var _temp in group) |
||
1367 | SPPIDUtil.CalcNewCoordinateForSymbol(_temp, prevSymbol, distanceX, distanceY); |
||
1368 | |||
1369 | SymbolModeling(symbol, null); |
||
1370 | foreach (var _temp in group) |
||
1371 | if (_temp != symbol && string.IsNullOrEmpty(_temp.SPPID.RepresentationId)) |
||
1372 | SymbolModeling(_temp, symbol); |
||
1373 | } |
||
1374 | } |
||
1375 | else |
||
1376 | { |
||
1377 | SymbolModeling(connSymbol, null); |
||
1378 | // Range 겹치는지 확인해야함 |
||
1379 | double[] prevRange = null; |
||
1380 | GetSPPIDSymbolRange(prevSymbol, ref prevRange); |
||
1381 | double[] connRange = null; |
||
1382 | GetSPPIDSymbolRange(connSymbol, ref connRange); |
||
1383 | |||
1384 | double distanceX = 0; |
||
1385 | double distanceY = 0; |
||
1386 | 6d12a734 | gaqhf | bool overlapX = false; |
1387 | bool overlapY = false; |
||
1388 | SlopeType slopeType = SPPIDUtil.CalcSlope(prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y); |
||
1389 | SPPIDUtil.CalcOverlap(prevRange, connRange, ref distanceX, ref distanceY, ref overlapX, ref overlapY); |
||
1390 | if ((slopeType == SlopeType.HORIZONTAL && overlapX) || |
||
1391 | (slopeType == SlopeType.VERTICAL && overlapY)) |
||
1392 | d9794a6c | gaqhf | { |
1393 | RemoveSymbol(connSymbol); |
||
1394 | SPPIDUtil.CalcNewCoordinateForSymbol(connSymbol, prevSymbol, distanceX, distanceY); |
||
1395 | |||
1396 | SymbolModeling(connSymbol, null); |
||
1397 | } |
||
1398 | } |
||
1399 | } |
||
1400 | SymbolModelingByNeerPrioritySymbolLoop(connSymbol, endObjects); |
||
1401 | } |
||
1402 | else if (connItem.GetType() == typeof(Line)) |
||
1403 | { |
||
1404 | Line connLine = connItem as Line; |
||
1405 | if (!SPPIDUtil.IsBranchLine(connLine, line)) |
||
1406 | SymbolModelingByNeerPriorityLineLoop(connLine, endObjects, prevSymbol); |
||
1407 | } |
||
1408 | 4d2571ab | gaqhf | } |
1409 | d1eac84d | gaqhf | } |
1410 | } |
||
1411 | } |
||
1412 | |||
1413 | d9794a6c | gaqhf | |
1414 | |||
1415 | d1eac84d | gaqhf | /// <summary> |
1416 | 74752074 | gaqhf | /// 심볼을 실제로 Modeling할때 ChildSymbol이 있다면 Modeling하는 메서드 |
1417 | /// </summary> |
||
1418 | /// <param name="childSymbol"></param> |
||
1419 | /// <param name="parentSymbol"></param> |
||
1420 | 4b4dbca9 | gaqhf | private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol) |
1421 | ac78b508 | gaqhf | { |
1422 | 4b4dbca9 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()]; |
1423 | double x1 = 0; |
||
1424 | double x2 = 0; |
||
1425 | double y1 = 0; |
||
1426 | double y2 = 0; |
||
1427 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1428 | |||
1429 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, (x1 + x2) / 2, (y1 + y2) / 2, TargetItem: parentSymbol); |
||
1430 | if (_LMSymbol != null) |
||
1431 | { |
||
1432 | childSymbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
1433 | foreach (var item in childSymbol.ChildSymbols) |
||
1434 | CreateChildSymbol(item, _LMSymbol); |
||
1435 | } |
||
1436 | 7f00b26c | gaqhf | |
1437 | ac78b508 | gaqhf | |
1438 | ReleaseCOMObjects(_LMSymbol); |
||
1439 | } |
||
1440 | |||
1441 | 74752074 | gaqhf | /// <summary> |
1442 | /// item이 TargetItem과 같은 LineRun에 있는지 검사 |
||
1443 | /// </summary> |
||
1444 | /// <param name="item"></param> |
||
1445 | /// <param name="targetItem"></param> |
||
1446 | /// <returns></returns> |
||
1447 | private bool IsSameLineRun(object item, object targetItem) |
||
1448 | 809a7640 | gaqhf | { |
1449 | foreach (var lineNumber in document.LINENUMBERS) |
||
1450 | { |
||
1451 | foreach (var run in lineNumber.RUNS) |
||
1452 | { |
||
1453 | foreach (var runItem in run.RUNITEMS) |
||
1454 | { |
||
1455 | if (runItem == item) |
||
1456 | { |
||
1457 | foreach (var findItem in run.RUNITEMS) |
||
1458 | { |
||
1459 | if (findItem == targetItem) |
||
1460 | { |
||
1461 | return true; |
||
1462 | } |
||
1463 | } |
||
1464 | |||
1465 | return false; |
||
1466 | |||
1467 | } |
||
1468 | } |
||
1469 | } |
||
1470 | } |
||
1471 | |||
1472 | return false; |
||
1473 | } |
||
1474 | |||
1475 | 74752074 | gaqhf | /// <summary> |
1476 | /// Line을 실제로 모델링하는 메서드 |
||
1477 | /// </summary> |
||
1478 | /// <param name="lines"></param> |
||
1479 | 1b261371 | gaqhf | private void LineModeling(List<Line> lines) |
1480 | { |
||
1481 | 7f00b26c | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
1482 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1483 | LMSymbol _LMSymbol1 = null; |
||
1484 | LMSymbol _LMSymbol2 = null; |
||
1485 | Dictionary<LMConnector, List<double[]>> connectorVertices1 = new Dictionary<LMConnector, List<double[]>>(); |
||
1486 | LMConnector targetConnector1 = null; |
||
1487 | Dictionary<LMConnector, List<double[]>> connectorVertices2 = new Dictionary<LMConnector, List<double[]>>(); |
||
1488 | LMConnector targetConnector2 = null; |
||
1489 | |||
1490 | Line startBranchLine = null; |
||
1491 | Line endBranchLine = null; |
||
1492 | |||
1493 | // Type, Line, TargetObjet, x, y |
||
1494 | List<Tuple<string, Line, object, double, double>> linePointInfo = new List<Tuple<string, Line, object, double, double>>(); |
||
1495 | // Point 정리 |
||
1496 | for (int i = 0; i < lines.Count; i++) |
||
1497 | { |
||
1498 | Line line = lines[i]; |
||
1499 | if (i == 0 || i + 1 != lines.Count) |
||
1500 | { |
||
1501 | // 시작점에 연결된 Symbol 찾기 |
||
1502 | object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[0].CONNECTEDITEM); |
||
1503 | if (connItem != null && connItem.GetType() == typeof(Symbol)) |
||
1504 | { |
||
1505 | Symbol symbol1 = connItem as Symbol; |
||
1506 | _LMSymbol1 = GetTargetSymbol(symbol1, line); |
||
1507 | if (_LMSymbol1 != null) |
||
1508 | 2fdb56bf | gaqhf | { |
1509 | 7f00b26c | gaqhf | double x = line.SPPID.START_X; |
1510 | double y = line.SPPID.START_Y; |
||
1511 | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, line.UID, symbol1); |
||
1512 | if (connector != null) |
||
1513 | 2fdb56bf | gaqhf | { |
1514 | 7f00b26c | gaqhf | GetTargetSymbolConnectorPoint(connector, symbol1, ref x, ref y); |
1515 | line.SPPID.START_X = x; |
||
1516 | line.SPPID.START_Y = y; |
||
1517 | 2fdb56bf | gaqhf | } |
1518 | |||
1519 | 7f00b26c | gaqhf | linePointInfo.Add(new Tuple<string, Line, object, double, double>("SYMBOL", line, _LMSymbol1, x, y)); |
1520 | 2fdb56bf | gaqhf | } |
1521 | f1c9dbaa | gaqhf | else |
1522 | 0bbd73b5 | gaqhf | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y)); |
1523 | f1c9dbaa | gaqhf | } |
1524 | 7f00b26c | gaqhf | else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
1525 | 5e6ecf05 | gaqhf | { |
1526 | 7f00b26c | gaqhf | connectorVertices1 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId); |
1527 | targetConnector1 = FindTargetLMConnector(connectorVertices1, line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
||
1528 | 5e6ecf05 | gaqhf | |
1529 | 7f00b26c | gaqhf | if (targetConnector1 != null) |
1530 | linePointInfo.Add(new Tuple<string, Line, object, double, double>("LINE", line, targetConnector1, line.SPPID.START_X, line.SPPID.START_Y)); |
||
1531 | else |
||
1532 | { |
||
1533 | startBranchLine = connItem as Line; |
||
1534 | 0bbd73b5 | gaqhf | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y)); |
1535 | 7f00b26c | gaqhf | } |
1536 | } |
||
1537 | else |
||
1538 | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y)); |
||
1539 | 5e6ecf05 | gaqhf | |
1540 | 7f00b26c | gaqhf | } |
1541 | if (i + 1 == lines.Count) |
||
1542 | { |
||
1543 | // 끝점에 연결된 Symbol 찾기 |
||
1544 | object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[1].CONNECTEDITEM); |
||
1545 | 2fdb56bf | gaqhf | |
1546 | 7f00b26c | gaqhf | if (i != 0) |
1547 | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y)); |
||
1548 | 5e6ecf05 | gaqhf | |
1549 | 7f00b26c | gaqhf | if (connItem != null && connItem.GetType() == typeof(Symbol)) |
1550 | { |
||
1551 | Symbol symbol2 = connItem as Symbol; |
||
1552 | _LMSymbol2 = GetTargetSymbol(connItem as Symbol, line); |
||
1553 | if (_LMSymbol2 != null) |
||
1554 | { |
||
1555 | double x = line.SPPID.END_X; |
||
1556 | double y = line.SPPID.END_Y; |
||
1557 | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, line.UID, symbol2); |
||
1558 | if (connector != null) |
||
1559 | c2ec33f5 | gaqhf | { |
1560 | 7f00b26c | gaqhf | GetTargetSymbolConnectorPoint(connector, symbol2, ref x, ref y); |
1561 | line.SPPID.END_X = x; |
||
1562 | line.SPPID.END_Y = y; |
||
1563 | c2ec33f5 | gaqhf | } |
1564 | 7f00b26c | gaqhf | |
1565 | linePointInfo.Add(new Tuple<string, Line, object, double, double>("SYMBOL", line, _LMSymbol2, x, y)); |
||
1566 | c2ec33f5 | gaqhf | } |
1567 | 5e6ecf05 | gaqhf | else |
1568 | 0bbd73b5 | gaqhf | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.END_X, line.SPPID.END_Y)); |
1569 | 5e6ecf05 | gaqhf | } |
1570 | 7f00b26c | gaqhf | else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
1571 | 0bbd73b5 | gaqhf | { |
1572 | 7f00b26c | gaqhf | connectorVertices2 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId); |
1573 | targetConnector2 = FindTargetLMConnector(connectorVertices2, line.SPPID.END_X, line.SPPID.END_Y, line.SPPID.START_X, line.SPPID.START_Y); |
||
1574 | |||
1575 | if (targetConnector2 != null) |
||
1576 | linePointInfo.Add(new Tuple<string, Line, object, double, double>("LINE", line, targetConnector2, line.SPPID.END_X, line.SPPID.END_Y)); |
||
1577 | else |
||
1578 | { |
||
1579 | endBranchLine = connItem as Line; |
||
1580 | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.END_X, line.SPPID.END_Y)); |
||
1581 | } |
||
1582 | c2ec33f5 | gaqhf | } |
1583 | else |
||
1584 | 7f00b26c | gaqhf | linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.END_X, line.SPPID.END_Y)); |
1585 | } |
||
1586 | } |
||
1587 | |||
1588 | double prevX = double.NaN; |
||
1589 | double prevY = double.NaN; |
||
1590 | SlopeType prevSlopeType = SlopeType.None; |
||
1591 | for (int i = 0; i < linePointInfo.Count; i++) |
||
1592 | { |
||
1593 | Tuple<string, Line, object, double, double> item = linePointInfo[i]; |
||
1594 | Line line = item.Item2; |
||
1595 | double x = item.Item4; |
||
1596 | double y = item.Item5; |
||
1597 | SlopeType slopeType = SPPIDUtil.CalcSlope(line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
||
1598 | // Symbol일 경우 바로 Input Point |
||
1599 | if (item.Item1 == "SYMBOL") |
||
1600 | { |
||
1601 | LMSymbol targetSymbol = item.Item3 as LMSymbol; |
||
1602 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(targetSymbol, x, y, true); |
1603 | 7f00b26c | gaqhf | } |
1604 | else |
||
1605 | { |
||
1606 | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
||
1607 | // i == 0은 그대로 사용 |
||
1608 | if (i != 0) |
||
1609 | c2ec33f5 | gaqhf | { |
1610 | 7f00b26c | gaqhf | Tuple<string, Line, object, double, double> prevItem = linePointInfo[i - 1]; |
1611 | // y 좌표가 같아야함 및 Symbol 좌표가 정확하지 않으므로 한번더 보정 |
||
1612 | if (prevSlopeType == SlopeType.HORIZONTAL) |
||
1613 | b66a2996 | gaqhf | { |
1614 | 7f00b26c | gaqhf | y = prevY; |
1615 | SPPIDUtil.ConvertGridPointOnlyOnePoint(ref y); |
||
1616 | } |
||
1617 | else if (prevSlopeType == SlopeType.VERTICAL) |
||
1618 | { |
||
1619 | x = prevX; |
||
1620 | SPPIDUtil.ConvertGridPointOnlyOnePoint(ref x); |
||
1621 | b66a2996 | gaqhf | } |
1622 | |||
1623 | 7f00b26c | gaqhf | // 마지막이 Symbol일 경우는 Symbol의 좌표를 따라감 |
1624 | if (i + 1 == linePointInfo.Count - 1 && linePointInfo[i + 1].Item1 == "SYMBOL") |
||
1625 | b66a2996 | gaqhf | { |
1626 | 7f00b26c | gaqhf | Line nextLine = linePointInfo[i + 1].Item2; |
1627 | SlopeType nextSlopeType = SPPIDUtil.CalcSlope(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y); |
||
1628 | if (slopeType == SlopeType.HORIZONTAL) |
||
1629 | y = linePointInfo[i + 1].Item5; |
||
1630 | else if (slopeType == SlopeType.VERTICAL) |
||
1631 | x = linePointInfo[i + 1].Item4; |
||
1632 | b66a2996 | gaqhf | } |
1633 | 0bbd73b5 | gaqhf | } |
1634 | |||
1635 | 7f00b26c | gaqhf | if (item.Item1 == "LINE") |
1636 | c2ec33f5 | gaqhf | { |
1637 | 7f00b26c | gaqhf | LMConnector targetConnector = item.Item3 as LMConnector; |
1638 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(targetConnector, x, y, true); |
1639 | c2ec33f5 | gaqhf | } |
1640 | ac82b020 | gaqhf | |
1641 | 7f00b26c | gaqhf | else |
1642 | placeRunInputs.AddPoint(x, y); |
||
1643 | 1ab9a205 | gaqhf | } |
1644 | ac82b020 | gaqhf | |
1645 | 7f00b26c | gaqhf | prevX = x; |
1646 | prevY = y; |
||
1647 | prevSlopeType = slopeType; |
||
1648 | c2ec33f5 | gaqhf | } |
1649 | 7f00b26c | gaqhf | |
1650 | LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
1651 | |||
1652 | if (_lMConnector != null) |
||
1653 | c2ec33f5 | gaqhf | { |
1654 | 7f00b26c | gaqhf | bool bStart = false; |
1655 | bool bEnd = false; |
||
1656 | |||
1657 | NeedReModeling(lines[0], _LMSymbol1, ref bStart); |
||
1658 | NeedReModeling(lines[lines.Count - 1], _LMSymbol2, ref bEnd); |
||
1659 | |||
1660 | if (bStart || bEnd) |
||
1661 | ReModelingLine(lines, _lMConnector, _LMSymbol1, _LMSymbol2, bStart, bEnd); |
||
1662 | else |
||
1663 | c2ec33f5 | gaqhf | { |
1664 | 7f00b26c | gaqhf | foreach (var line in lines) |
1665 | line.SPPID.ModelItemId = _lMConnector.ModelItemID; |
||
1666 | _lMConnector.Commit(); |
||
1667 | c2ec33f5 | gaqhf | } |
1668 | 7f00b26c | gaqhf | |
1669 | if (startBranchLine != null || endBranchLine != null) |
||
1670 | BranchLines.Add(new Tuple<string, Line, Line>(lines[0].SPPID.ModelItemId, startBranchLine, endBranchLine)); |
||
1671 | c2ec33f5 | gaqhf | } |
1672 | 7f00b26c | gaqhf | |
1673 | if (_LMSymbol1 != null) |
||
1674 | ReleaseCOMObjects(_LMSymbol1); |
||
1675 | if (_LMSymbol2 != null) |
||
1676 | ReleaseCOMObjects(_LMSymbol2); |
||
1677 | if (targetConnector1 != null) |
||
1678 | ReleaseCOMObjects(targetConnector1); |
||
1679 | if (targetConnector2 != null) |
||
1680 | ReleaseCOMObjects(targetConnector2); |
||
1681 | foreach (var item in connectorVertices1) |
||
1682 | ReleaseCOMObjects(item.Key); |
||
1683 | foreach (var item in connectorVertices2) |
||
1684 | ReleaseCOMObjects(item.Key); |
||
1685 | |||
1686 | ReleaseCOMObjects(_lMConnector); |
||
1687 | ReleaseCOMObjects(placeRunInputs); |
||
1688 | ReleaseCOMObjects(_LMAItem); |
||
1689 | 1b261371 | gaqhf | } |
1690 | |||
1691 | 0860c756 | gaqhf | private void NeedReModeling(Line line, LMSymbol symbol, ref bool result) |
1692 | ac82b020 | gaqhf | { |
1693 | 0860c756 | gaqhf | if (symbol != null) |
1694 | ac82b020 | gaqhf | { |
1695 | fb386b8c | gaqhf | string repID = symbol.AsLMRepresentation().Id; |
1696 | string symbolUID = SPPIDUtil.FindSymbolByRepresentationID(document, repID).UID; |
||
1697 | string lineUID = line.UID; |
||
1698 | ac82b020 | gaqhf | |
1699 | fb386b8c | gaqhf | SpecBreak startSpecBreak = document.SpecBreaks.Find(x => |
1700 | (x.DownStreamUID == symbolUID || x.UpStreamUID == symbolUID) && |
||
1701 | (x.DownStreamUID == lineUID || x.UpStreamUID == lineUID)); |
||
1702 | 71ba1ca3 | gaqhf | |
1703 | fb386b8c | gaqhf | EndBreak startEndBreak = document.EndBreaks.Find(x => |
1704 | (x.OWNER == symbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == symbolUID) && |
||
1705 | (x.OWNER == lineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == lineUID)); |
||
1706 | ac82b020 | gaqhf | |
1707 | fb386b8c | gaqhf | if (startSpecBreak != null || startEndBreak != null) |
1708 | result = true; |
||
1709 | ac82b020 | gaqhf | } |
1710 | } |
||
1711 | 7f00b26c | gaqhf | |
1712 | 74752074 | gaqhf | /// <summary> |
1713 | 1ab9a205 | gaqhf | /// Symbol에 붙을 경우 Line을 Remodeling 한다. |
1714 | /// </summary> |
||
1715 | /// <param name="lines"></param> |
||
1716 | /// <param name="prevLMConnector"></param> |
||
1717 | /// <param name="startSymbol"></param> |
||
1718 | /// <param name="endSymbol"></param> |
||
1719 | ac82b020 | gaqhf | private void ReModelingLine(List<Line> lines, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol, bool bStart, bool bEnd) |
1720 | 1ab9a205 | gaqhf | { |
1721 | string symbolPath = string.Empty; |
||
1722 | #region get symbol path |
||
1723 | LMModelItem modelItem = dataSource.GetModelItem(prevLMConnector.ModelItemID); |
||
1724 | foreach (LMRepresentation rep in modelItem.Representations) |
||
1725 | { |
||
1726 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
1727 | { |
||
1728 | symbolPath = rep.get_FileName(); |
||
1729 | break; |
||
1730 | } |
||
1731 | } |
||
1732 | #endregion |
||
1733 | _LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
1734 | LMConnector newConnector = null; |
||
1735 | dynamic OID = prevLMConnector.get_GraphicOID(); |
||
1736 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
1737 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1738 | int verticesCount = lineStringGeometry.VertexCount; |
||
1739 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1740 | 7f00b26c | gaqhf | |
1741 | 1ab9a205 | gaqhf | List<double[]> vertices = new List<double[]>(); |
1742 | for (int i = 1; i <= verticesCount; i++) |
||
1743 | { |
||
1744 | double x = 0; |
||
1745 | double y = 0; |
||
1746 | lineStringGeometry.GetVertex(i, ref x, ref y); |
||
1747 | vertices.Add(new double[] { x, y }); |
||
1748 | } |
||
1749 | |||
1750 | for (int i = 0; i < vertices.Count; i++) |
||
1751 | { |
||
1752 | double[] points = vertices[i]; |
||
1753 | // 시작 심볼이 있고 첫번째 좌표일 때 |
||
1754 | if (startSymbol != null && i == 0) |
||
1755 | { |
||
1756 | ac82b020 | gaqhf | if (bStart) |
1757 | { |
||
1758 | SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i + 1][0], vertices[i + 1][1]); |
||
1759 | if (slopeType == SlopeType.HORIZONTAL) |
||
1760 | placeRunInputs.AddPoint(points[0], -0.1); |
||
1761 | else if (slopeType == SlopeType.VERTICAL) |
||
1762 | placeRunInputs.AddPoint(-0.1, points[1]); |
||
1763 | else |
||
1764 | placeRunInputs.AddPoint(points[0], -0.1); |
||
1765 | 1ab9a205 | gaqhf | |
1766 | ac82b020 | gaqhf | placeRunInputs.AddPoint(points[0], points[1]); |
1767 | } |
||
1768 | else |
||
1769 | { |
||
1770 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(startSymbol, points[0], points[1], true); |
1771 | ac82b020 | gaqhf | } |
1772 | 1ab9a205 | gaqhf | } |
1773 | // 마지막 심볼이 있고 마지막 좌표일 때 |
||
1774 | else if (endSymbol != null && i == vertices.Count - 1) |
||
1775 | { |
||
1776 | ac82b020 | gaqhf | if (bEnd) |
1777 | { |
||
1778 | placeRunInputs.AddPoint(points[0], points[1]); |
||
1779 | 1ab9a205 | gaqhf | |
1780 | ac82b020 | gaqhf | SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i - 1][0], vertices[i - 1][1]); |
1781 | if (slopeType == SlopeType.HORIZONTAL) |
||
1782 | placeRunInputs.AddPoint(points[0], -0.1); |
||
1783 | else if (slopeType == SlopeType.VERTICAL) |
||
1784 | placeRunInputs.AddPoint(-0.1, points[1]); |
||
1785 | else |
||
1786 | placeRunInputs.AddPoint(points[0], -0.1); |
||
1787 | } |
||
1788 | 1ab9a205 | gaqhf | else |
1789 | ac82b020 | gaqhf | { |
1790 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(endSymbol, points[0], points[1], true); |
1791 | ac82b020 | gaqhf | } |
1792 | 1ab9a205 | gaqhf | } |
1793 | // 첫번째이며 시작 심볼이 아니고 Connecotr일 경우 |
||
1794 | else if (i == 0 && prevLMConnector.ConnectItem1SymbolObject != null) |
||
1795 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem1SymbolObject, points[0], points[1], true); |
1796 | 1ab9a205 | gaqhf | // 마지막이며 마지막 심볼이 아니고 Connecotr일 경우 |
1797 | else if (i == vertices.Count - 1 && prevLMConnector.ConnectItem2SymbolObject != null) |
||
1798 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem2SymbolObject, points[0], points[1], true); |
1799 | 1ab9a205 | gaqhf | else |
1800 | placeRunInputs.AddPoint(points[0], points[1]); |
||
1801 | } |
||
1802 | |||
1803 | _placement.PIDRemovePlacement(prevLMConnector.AsLMRepresentation()); |
||
1804 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
1805 | |||
1806 | ReleaseCOMObjects(placeRunInputs); |
||
1807 | ReleaseCOMObjects(_LMAItem); |
||
1808 | ReleaseCOMObjects(modelItem); |
||
1809 | |||
1810 | if (newConnector != null) |
||
1811 | { |
||
1812 | ac82b020 | gaqhf | if (startSymbol != null && bStart) |
1813 | 1ab9a205 | gaqhf | { |
1814 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
1815 | placeRunInputs = new PlaceRunInputs(); |
||
1816 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(startSymbol, vertices[0][0], vertices[0][1], true); |
1817 | placeRunInputs.AddConnectorTarget(newConnector, vertices[0][0], vertices[0][1], true); |
||
1818 | 1ab9a205 | gaqhf | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1819 | if (_LMConnector != null) |
||
1820 | { |
||
1821 | RemoveConnectorForReModelingLine(newConnector); |
||
1822 | 87f02fc0 | gaqhf | ZeroLengthModelItemID.Add(_LMConnector.ModelItemID); |
1823 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
1824 | } |
||
1825 | ReleaseCOMObjects(placeRunInputs); |
||
1826 | ReleaseCOMObjects(_LMAItem); |
||
1827 | } |
||
1828 | |||
1829 | ac82b020 | gaqhf | if (endSymbol != null && bEnd) |
1830 | 1ab9a205 | gaqhf | { |
1831 | if (startSymbol != null) |
||
1832 | { |
||
1833 | Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(newConnector.ModelItemID); |
||
1834 | newConnector = dicVertices.First().Key; |
||
1835 | } |
||
1836 | |||
1837 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
1838 | placeRunInputs = new PlaceRunInputs(); |
||
1839 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(endSymbol, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1], true); |
1840 | placeRunInputs.AddConnectorTarget(newConnector, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1], true); |
||
1841 | 1ab9a205 | gaqhf | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1842 | if (_LMConnector != null) |
||
1843 | { |
||
1844 | RemoveConnectorForReModelingLine(newConnector); |
||
1845 | 87f02fc0 | gaqhf | ZeroLengthModelItemID.Add(_LMConnector.ModelItemID); |
1846 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
1847 | } |
||
1848 | ReleaseCOMObjects(placeRunInputs); |
||
1849 | ReleaseCOMObjects(_LMAItem); |
||
1850 | } |
||
1851 | |||
1852 | foreach (var line in lines) |
||
1853 | line.SPPID.ModelItemId = newConnector.ModelItemID; |
||
1854 | ReleaseCOMObjects(newConnector); |
||
1855 | } |
||
1856 | |||
1857 | ReleaseCOMObjects(modelItem); |
||
1858 | } |
||
1859 | |||
1860 | /// <summary> |
||
1861 | /// Remodeling 과정에서 생긴 불필요한 Connector 제거 |
||
1862 | /// </summary> |
||
1863 | /// <param name="connector"></param> |
||
1864 | private void RemoveConnectorForReModelingLine(LMConnector connector) |
||
1865 | { |
||
1866 | Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(connector.ModelItemID); |
||
1867 | foreach (var item in dicVertices) |
||
1868 | { |
||
1869 | bool result = false; |
||
1870 | foreach (var point in item.Value) |
||
1871 | { |
||
1872 | if (point[0] < 0 || point[1] < 0) |
||
1873 | { |
||
1874 | result = true; |
||
1875 | _placement.PIDRemovePlacement(item.Key.AsLMRepresentation()); |
||
1876 | break; |
||
1877 | } |
||
1878 | } |
||
1879 | |||
1880 | if (result) |
||
1881 | break; |
||
1882 | } |
||
1883 | foreach (var item in dicVertices) |
||
1884 | ReleaseCOMObjects(item.Key); |
||
1885 | } |
||
1886 | |||
1887 | /// <summary> |
||
1888 | 74752074 | gaqhf | /// Symbol이 모델링된 SPPPID Symbol Object를 반환 - 연결된 Symbol이 ChildSymbol일 수도 있기때문에 메서드 개발 |
1889 | /// </summary> |
||
1890 | /// <param name="symbol"></param> |
||
1891 | /// <param name="line"></param> |
||
1892 | /// <returns></returns> |
||
1893 | f2baa6a3 | gaqhf | private LMSymbol GetTargetSymbol(Symbol symbol, Line line) |
1894 | { |
||
1895 | LMSymbol _LMSymbol = null; |
||
1896 | foreach (var connector in symbol.CONNECTORS) |
||
1897 | { |
||
1898 | if (connector.CONNECTEDITEM == line.UID) |
||
1899 | { |
||
1900 | if (connector.Index == 0) |
||
1901 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1902 | else |
||
1903 | { |
||
1904 | ChildSymbol child = null; |
||
1905 | foreach (var childSymbol in symbol.ChildSymbols) |
||
1906 | { |
||
1907 | if (childSymbol.Connectors.Contains(connector)) |
||
1908 | child = childSymbol; |
||
1909 | else |
||
1910 | child = GetChildSymbolByConnector(childSymbol, connector); |
||
1911 | |||
1912 | if (child != null) |
||
1913 | break; |
||
1914 | } |
||
1915 | |||
1916 | if (child != null) |
||
1917 | _LMSymbol = dataSource.GetSymbol(child.SPPID.RepresentationId); |
||
1918 | } |
||
1919 | |||
1920 | 7f00b26c | gaqhf | break; |
1921 | f2baa6a3 | gaqhf | } |
1922 | } |
||
1923 | |||
1924 | return _LMSymbol; |
||
1925 | } |
||
1926 | |||
1927 | 74752074 | gaqhf | /// <summary> |
1928 | /// Connector를 가지고 있는 ChildSymbol Object 반환 |
||
1929 | /// </summary> |
||
1930 | /// <param name="item"></param> |
||
1931 | /// <param name="connector"></param> |
||
1932 | /// <returns></returns> |
||
1933 | f2baa6a3 | gaqhf | private ChildSymbol GetChildSymbolByConnector(ChildSymbol item, Connector connector) |
1934 | { |
||
1935 | foreach (var childSymbol in item.ChildSymbols) |
||
1936 | { |
||
1937 | if (childSymbol.Connectors.Contains(connector)) |
||
1938 | return childSymbol; |
||
1939 | else |
||
1940 | return GetChildSymbolByConnector(childSymbol, connector); |
||
1941 | } |
||
1942 | |||
1943 | return null; |
||
1944 | } |
||
1945 | |||
1946 | 74752074 | gaqhf | /// <summary> |
1947 | /// Branch 라인을 다시 모델링하는 진입 메서드 |
||
1948 | /// </summary> |
||
1949 | /// <param name="branch"></param> |
||
1950 | 335b7a24 | gaqhf | private void BranchLineModeling(Tuple<string, Line, Line> branch) |
1951 | { |
||
1952 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
||
1953 | b66a2996 | gaqhf | |
1954 | 335b7a24 | gaqhf | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
1955 | 8b085570 | gaqhf | LMConnector _StartConnector = null; |
1956 | LMConnector _EndConnector = null; |
||
1957 | 335b7a24 | gaqhf | double lengthStart = double.MaxValue; |
1958 | double lengthEnd = double.MaxValue; |
||
1959 | List<double[]> startPoints = new List<double[]>(); |
||
1960 | List<double[]> endPoints = new List<double[]>(); |
||
1961 | |||
1962 | foreach (var item in connectorVertices) |
||
1963 | { |
||
1964 | foreach (var point in item.Value) |
||
1965 | { |
||
1966 | // Start Point가 Branch |
||
1967 | if (branch.Item2 != null) |
||
1968 | { |
||
1969 | Line targetLine = branch.Item2; |
||
1970 | double distance = SPPIDUtil.CalcLineToPointDistance(targetLine.SPPID.START_X, targetLine.SPPID.START_Y, targetLine.SPPID.END_X, targetLine.SPPID.END_Y, point[0], point[1]); |
||
1971 | if (lengthStart > distance) |
||
1972 | { |
||
1973 | 8b085570 | gaqhf | _StartConnector = item.Key; |
1974 | 335b7a24 | gaqhf | lengthStart = distance; |
1975 | startPoints = item.Value; |
||
1976 | } |
||
1977 | } |
||
1978 | // End Point가 Branch |
||
1979 | if (branch.Item3 != null) |
||
1980 | { |
||
1981 | Line targetLine = branch.Item3; |
||
1982 | double distance = SPPIDUtil.CalcLineToPointDistance(targetLine.SPPID.START_X, targetLine.SPPID.START_Y, targetLine.SPPID.END_X, targetLine.SPPID.END_Y, point[0], point[1]); |
||
1983 | if (lengthEnd > distance) |
||
1984 | { |
||
1985 | 8b085570 | gaqhf | _EndConnector = item.Key; |
1986 | 335b7a24 | gaqhf | lengthEnd = distance; |
1987 | endPoints = item.Value; |
||
1988 | } |
||
1989 | } |
||
1990 | } |
||
1991 | } |
||
1992 | #region Branch가 양쪽 전부일 때 |
||
1993 | 8b085570 | gaqhf | if (_StartConnector != null && _StartConnector == _EndConnector) |
1994 | 335b7a24 | gaqhf | { |
1995 | 8b085570 | gaqhf | _placement.PIDRemovePlacement(_StartConnector.AsLMRepresentation()); |
1996 | 335b7a24 | gaqhf | |
1997 | _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
||
1998 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1999 | |||
2000 | Dictionary<LMConnector, List<double[]>> startConnectorVertices = GetPipeRunVertices(branch.Item2.SPPID.ModelItemId); |
||
2001 | 8b085570 | gaqhf | LMConnector _StartTargetConnector = FindTargetLMConnector(startConnectorVertices, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]); |
2002 | 335b7a24 | gaqhf | Dictionary<LMConnector, List<double[]>> endConnectorVertices = GetPipeRunVertices(branch.Item3.SPPID.ModelItemId); |
2003 | 8b085570 | gaqhf | LMConnector _EndTargetConnector = FindTargetLMConnector(endConnectorVertices, |
2004 | 335b7a24 | gaqhf | startPoints[startPoints.Count - 1][0], |
2005 | startPoints[startPoints.Count - 1][1], |
||
2006 | startPoints[startPoints.Count - 2][0], |
||
2007 | startPoints[startPoints.Count - 2][1]); |
||
2008 | |||
2009 | for (int i = 0; i < startPoints.Count; i++) |
||
2010 | { |
||
2011 | double[] point = startPoints[i]; |
||
2012 | if (i == 0) |
||
2013 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(_StartTargetConnector, point[0], point[1], true); |
2014 | 335b7a24 | gaqhf | else if (i == startPoints.Count - 1) |
2015 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(_EndTargetConnector, point[0], point[1], true); |
2016 | 335b7a24 | gaqhf | else |
2017 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2018 | } |
||
2019 | |||
2020 | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2021 | if (_LMConnector != null) |
||
2022 | { |
||
2023 | _LMConnector.Commit(); |
||
2024 | foreach (var item in lines) |
||
2025 | item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
||
2026 | } |
||
2027 | |||
2028 | foreach (var item in startConnectorVertices) |
||
2029 | ReleaseCOMObjects(item.Key); |
||
2030 | foreach (var item in endConnectorVertices) |
||
2031 | ReleaseCOMObjects(item.Key); |
||
2032 | ReleaseCOMObjects(placeRunInputs); |
||
2033 | ReleaseCOMObjects(_LMAItem); |
||
2034 | ReleaseCOMObjects(_LMConnector); |
||
2035 | } |
||
2036 | #endregion |
||
2037 | 8b085570 | gaqhf | #region 양쪽이 다른 Branch |
2038 | 335b7a24 | gaqhf | else |
2039 | { |
||
2040 | // Branch 시작 Connector |
||
2041 | 8b085570 | gaqhf | if (_StartConnector != null) |
2042 | 6b298450 | gaqhf | BranchLineModelingByConnector(branch, _StartConnector, startPoints, true); |
2043 | // Branch 끝 Connector |
||
2044 | 0860c756 | gaqhf | else if (_EndConnector != null) |
2045 | 6b298450 | gaqhf | BranchLineModelingByConnector(branch, _EndConnector, endPoints, false); |
2046 | } |
||
2047 | #endregion |
||
2048 | 335b7a24 | gaqhf | |
2049 | 6b298450 | gaqhf | if (_StartConnector != null) |
2050 | ReleaseCOMObjects(_StartConnector); |
||
2051 | if (_EndConnector != null) |
||
2052 | ReleaseCOMObjects(_EndConnector); |
||
2053 | foreach (var item in connectorVertices) |
||
2054 | ReleaseCOMObjects(item.Key); |
||
2055 | } |
||
2056 | 335b7a24 | gaqhf | |
2057 | 74752074 | gaqhf | /// <summary> |
2058 | /// Branch 라인을 다시 실제로 모델링하는 메서드 |
||
2059 | /// </summary> |
||
2060 | /// <param name="branch"></param> |
||
2061 | /// <param name="_Connector"></param> |
||
2062 | /// <param name="points"></param> |
||
2063 | /// <param name="IsStart"></param> |
||
2064 | 6b298450 | gaqhf | private void BranchLineModelingByConnector(Tuple<string, Line, Line> branch, LMConnector _Connector, List<double[]> points, bool IsStart) |
2065 | { |
||
2066 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
||
2067 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
||
2068 | LMConnector _SameRunTargetConnector = null; |
||
2069 | 0860c756 | gaqhf | LMSymbol _SameRunTargetLMSymbol = null; |
2070 | Symbol _SameRunTargetSymbol = null; |
||
2071 | 6b298450 | gaqhf | Dictionary<LMConnector, List<double[]>> branchConnectorVertices = null; |
2072 | LMConnector _BranchTargetConnector = null; |
||
2073 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
2074 | 335b7a24 | gaqhf | |
2075 | 6b298450 | gaqhf | // 같은 Line Run의 Connector 찾기 |
2076 | foreach (var item in connectorVertices) |
||
2077 | { |
||
2078 | if (item.Key == _Connector) |
||
2079 | continue; |
||
2080 | 335b7a24 | gaqhf | |
2081 | 6b298450 | gaqhf | if (IsStart && |
2082 | !DBNull.Value.Equals(item.Key.ConnectItem1SymbolID) && |
||
2083 | 7f00b26c | gaqhf | !DBNull.Value.Equals(_Connector.ConnectItem2SymbolID) && |
2084 | 6b298450 | gaqhf | item.Key.ConnectItem1SymbolID == _Connector.ConnectItem2SymbolID) |
2085 | { |
||
2086 | _SameRunTargetConnector = item.Key; |
||
2087 | break; |
||
2088 | } |
||
2089 | else if (!IsStart && |
||
2090 | !DBNull.Value.Equals(item.Key.ConnectItem2SymbolID) && |
||
2091 | 7f00b26c | gaqhf | !DBNull.Value.Equals(_Connector.ConnectItem1SymbolID) && |
2092 | 6b298450 | gaqhf | item.Key.ConnectItem2SymbolID == _Connector.ConnectItem1SymbolID) |
2093 | { |
||
2094 | _SameRunTargetConnector = item.Key; |
||
2095 | break; |
||
2096 | } |
||
2097 | } |
||
2098 | |||
2099 | // Branch 반대편이 Symbol |
||
2100 | if (_SameRunTargetConnector == null) |
||
2101 | { |
||
2102 | foreach (var line in lines) |
||
2103 | { |
||
2104 | foreach (var connector in line.CONNECTORS) |
||
2105 | 335b7a24 | gaqhf | { |
2106 | 6b298450 | gaqhf | Symbol symbol = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Symbol; |
2107 | if (symbol != null) |
||
2108 | 335b7a24 | gaqhf | { |
2109 | 0860c756 | gaqhf | _SameRunTargetSymbol = symbol; |
2110 | _SameRunTargetLMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
2111 | 6b298450 | gaqhf | break; |
2112 | 335b7a24 | gaqhf | } |
2113 | } |
||
2114 | 6b298450 | gaqhf | } |
2115 | } |
||
2116 | 335b7a24 | gaqhf | |
2117 | 6b298450 | gaqhf | // 기존 Connector 제거 |
2118 | _placement.PIDRemovePlacement(_Connector.AsLMRepresentation()); |
||
2119 | 7f00b26c | gaqhf | |
2120 | 6b298450 | gaqhf | // 시작 Connector일 경우 첫 Point가 TargetConnector를 찾아야함 |
2121 | if (IsStart) |
||
2122 | { |
||
2123 | branchConnectorVertices = GetPipeRunVertices(branch.Item2.SPPID.ModelItemId); |
||
2124 | _BranchTargetConnector = FindTargetLMConnector(branchConnectorVertices, points[0][0], points[0][1], points[1][0], points[1][1]); |
||
2125 | } |
||
2126 | // 끝 Conenctor일 경우 마지막 Point가 TargetConnector를 찾아야함 |
||
2127 | else |
||
2128 | { |
||
2129 | branchConnectorVertices = GetPipeRunVertices(branch.Item3.SPPID.ModelItemId); |
||
2130 | _BranchTargetConnector = FindTargetLMConnector(branchConnectorVertices, |
||
2131 | points[points.Count - 1][0], |
||
2132 | points[points.Count - 1][1], |
||
2133 | points[points.Count - 2][0], |
||
2134 | points[points.Count - 2][1]); |
||
2135 | } |
||
2136 | 335b7a24 | gaqhf | |
2137 | 0860c756 | gaqhf | |
2138 | bool bNeedRemodeling = false; |
||
2139 | if (_SameRunTargetLMSymbol != null) |
||
2140 | { |
||
2141 | Line line = lines.Find(x => x.CONNECTORS.Find(y => y.CONNECTEDITEM == _SameRunTargetSymbol.UID) != null); |
||
2142 | NeedReModeling(line, _SameRunTargetLMSymbol, ref bNeedRemodeling); |
||
2143 | } |
||
2144 | |||
2145 | |||
2146 | |||
2147 | 6b298450 | gaqhf | for (int i = 0; i < points.Count; i++) |
2148 | { |
||
2149 | double[] point = points[i]; |
||
2150 | if (i == 0) |
||
2151 | 335b7a24 | gaqhf | { |
2152 | 6b298450 | gaqhf | if (IsStart) |
2153 | 335b7a24 | gaqhf | { |
2154 | b2d1c1aa | gaqhf | if (_BranchTargetConnector != null) |
2155 | { |
||
2156 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(_BranchTargetConnector, point[0], point[1], true); |
2157 | b2d1c1aa | gaqhf | } |
2158 | else |
||
2159 | { |
||
2160 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2161 | } |
||
2162 | 335b7a24 | gaqhf | } |
2163 | 6b298450 | gaqhf | else |
2164 | 335b7a24 | gaqhf | { |
2165 | 6b298450 | gaqhf | if (_SameRunTargetConnector != null) |
2166 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1], true); |
2167 | 0860c756 | gaqhf | else if (_SameRunTargetLMSymbol != null && bNeedRemodeling) |
2168 | { |
||
2169 | SlopeType slopeType = SPPIDUtil.CalcSlope(point[0], point[1], points[i + 1][0], points[i + 1][1]); |
||
2170 | if (slopeType == SlopeType.HORIZONTAL) |
||
2171 | placeRunInputs.AddPoint(point[0], -0.1); |
||
2172 | else if (slopeType == SlopeType.VERTICAL) |
||
2173 | placeRunInputs.AddPoint(-0.1, point[1]); |
||
2174 | else |
||
2175 | placeRunInputs.AddPoint(point[0], -0.1); |
||
2176 | |||
2177 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2178 | } |
||
2179 | else if (_SameRunTargetLMSymbol != null) |
||
2180 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(_SameRunTargetLMSymbol, point[0], point[1], true); |
2181 | 6b298450 | gaqhf | else |
2182 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2183 | 335b7a24 | gaqhf | } |
2184 | 6b298450 | gaqhf | } |
2185 | else if (i == points.Count - 1) |
||
2186 | { |
||
2187 | if (IsStart) |
||
2188 | 335b7a24 | gaqhf | { |
2189 | 6b298450 | gaqhf | if (_SameRunTargetConnector != null) |
2190 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1], true); |
2191 | 0860c756 | gaqhf | else if (_SameRunTargetLMSymbol != null && bNeedRemodeling) |
2192 | { |
||
2193 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2194 | |||
2195 | SlopeType slopeType = SPPIDUtil.CalcSlope(point[0], point[1], points[i - 1][0], points[i - 1][1]); |
||
2196 | if (slopeType == SlopeType.HORIZONTAL) |
||
2197 | placeRunInputs.AddPoint(point[0], -0.1); |
||
2198 | else if (slopeType == SlopeType.VERTICAL) |
||
2199 | placeRunInputs.AddPoint(-0.1, point[1]); |
||
2200 | else |
||
2201 | placeRunInputs.AddPoint(point[0], -0.1); |
||
2202 | } |
||
2203 | else if (_SameRunTargetLMSymbol != null) |
||
2204 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(_SameRunTargetLMSymbol, point[0], point[1], true); |
2205 | 335b7a24 | gaqhf | else |
2206 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2207 | } |
||
2208 | 6b298450 | gaqhf | else |
2209 | 335b7a24 | gaqhf | { |
2210 | f9125a54 | gaqhf | if (_BranchTargetConnector != null) |
2211 | { |
||
2212 | 3b2d7bd8 | gaqhf | placeRunInputs.AddConnectorTarget(_BranchTargetConnector, point[0], point[1], true); |
2213 | f9125a54 | gaqhf | } |
2214 | b2d1c1aa | gaqhf | else |
2215 | { |
||
2216 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2217 | } |
||
2218 | 335b7a24 | gaqhf | } |
2219 | 6b298450 | gaqhf | } |
2220 | else |
||
2221 | placeRunInputs.AddPoint(point[0], point[1]); |
||
2222 | } |
||
2223 | _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
||
2224 | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2225 | 335b7a24 | gaqhf | |
2226 | 6b298450 | gaqhf | if (_LMConnector != null) |
2227 | { |
||
2228 | if (_SameRunTargetConnector != null) |
||
2229 | { |
||
2230 | JoinPipeRun(_LMConnector.ModelItemID, _SameRunTargetConnector.ModelItemID); |
||
2231 | } |
||
2232 | else |
||
2233 | { |
||
2234 | 0860c756 | gaqhf | if (_SameRunTargetLMSymbol != null && bNeedRemodeling) |
2235 | { |
||
2236 | string symbolPath = string.Empty; |
||
2237 | #region get symbol path |
||
2238 | LMModelItem modelItem = dataSource.GetModelItem(_LMConnector.ModelItemID); |
||
2239 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2240 | { |
||
2241 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
2242 | { |
||
2243 | symbolPath = rep.get_FileName(); |
||
2244 | break; |
||
2245 | } |
||
2246 | } |
||
2247 | ReleaseCOMObjects(modelItem); |
||
2248 | #endregion |
||
2249 | |||
2250 | double[] point = null; |
||
2251 | if (IsStart) |
||
2252 | point = points[points.Count - 1]; |
||
2253 | else |
||
2254 | point = points[0]; |
||
2255 | |||
2256 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
2257 | placeRunInputs = new PlaceRunInputs(); |
||
2258 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(_SameRunTargetLMSymbol, point[0], point[1], true); |
2259 | placeRunInputs.AddConnectorTarget(_LMConnector, point[0], point[1], true); |
||
2260 | 0860c756 | gaqhf | LMConnector _ZeroLengthLMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
2261 | if (_ZeroLengthLMConnector != null) |
||
2262 | { |
||
2263 | RemoveConnectorForReModelingLine(_LMConnector); |
||
2264 | ZeroLengthModelItemID.Add(_ZeroLengthLMConnector.ModelItemID); |
||
2265 | ReleaseCOMObjects(_ZeroLengthLMConnector); |
||
2266 | } |
||
2267 | ReleaseCOMObjects(placeRunInputs); |
||
2268 | ReleaseCOMObjects(_LMAItem); |
||
2269 | } |
||
2270 | |||
2271 | 6b298450 | gaqhf | foreach (var item in lines) |
2272 | item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
||
2273 | 335b7a24 | gaqhf | } |
2274 | |||
2275 | 6b298450 | gaqhf | _LMConnector.Commit(); |
2276 | ReleaseCOMObjects(_LMConnector); |
||
2277 | 335b7a24 | gaqhf | } |
2278 | |||
2279 | 6b298450 | gaqhf | ReleaseCOMObjects(placeRunInputs); |
2280 | ReleaseCOMObjects(_LMAItem); |
||
2281 | if (_BranchTargetConnector != null) |
||
2282 | ReleaseCOMObjects(_BranchTargetConnector); |
||
2283 | if (_SameRunTargetConnector != null) |
||
2284 | ReleaseCOMObjects(_SameRunTargetConnector); |
||
2285 | 0860c756 | gaqhf | if (_SameRunTargetLMSymbol != null) |
2286 | ReleaseCOMObjects(_SameRunTargetLMSymbol); |
||
2287 | 335b7a24 | gaqhf | foreach (var item in connectorVertices) |
2288 | ReleaseCOMObjects(item.Key); |
||
2289 | 6b298450 | gaqhf | foreach (var item in branchConnectorVertices) |
2290 | ReleaseCOMObjects(item.Key); |
||
2291 | 335b7a24 | gaqhf | } |
2292 | |||
2293 | 74752074 | gaqhf | /// <summary> |
2294 | /// EndBreak 모델링 메서드 |
||
2295 | /// </summary> |
||
2296 | /// <param name="endBreak"></param> |
||
2297 | 3165c259 | gaqhf | private void EndBreakModeling(EndBreak endBreak) |
2298 | 335b7a24 | gaqhf | { |
2299 | 10c7195c | gaqhf | object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
2300 | 1ab9a205 | gaqhf | object connectedItem = SPPIDUtil.FindObjectByUID(document, endBreak.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE); |
2301 | LMConnector targetLMConnector = FindBreakLineTarget(ownerObj, connectedItem); |
||
2302 | 3165c259 | gaqhf | |
2303 | 1ab9a205 | gaqhf | if (targetLMConnector != null) |
2304 | 10c7195c | gaqhf | { |
2305 | 1ab9a205 | gaqhf | Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
2306 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
2307 | 2a4872ec | gaqhf | } |
2308 | 7f00b26c | gaqhf | |
2309 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
2310 | 2a4872ec | gaqhf | } |
2311 | b9e9f4c8 | gaqhf | |
2312 | 02480ac1 | gaqhf | private LMConnector ReModelingLMConnector(LMConnector connector) |
2313 | { |
||
2314 | de97eaaa | gaqhf | string symbolPath = string.Empty; |
2315 | #region get symbol path |
||
2316 | LMModelItem modelItem = dataSource.GetModelItem(connector.ModelItemID); |
||
2317 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2318 | { |
||
2319 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
2320 | { |
||
2321 | symbolPath = rep.get_FileName(); |
||
2322 | break; |
||
2323 | } |
||
2324 | } |
||
2325 | #endregion |
||
2326 | |||
2327 | 02480ac1 | gaqhf | LMConnector newConnector = null; |
2328 | dynamic OID = connector.get_GraphicOID(); |
||
2329 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
2330 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
2331 | int verticesCount = lineStringGeometry.VertexCount; |
||
2332 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
2333 | de97eaaa | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
2334 | 02480ac1 | gaqhf | |
2335 | if (Convert.ToBoolean(connector.get_IsZeroLength())) |
||
2336 | { |
||
2337 | double[] vertices = null; |
||
2338 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
2339 | double x = 0; |
||
2340 | double y = 0; |
||
2341 | lineStringGeometry.GetVertex(1, ref x, ref y); |
||
2342 | |||
2343 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, x, y, true); |
2344 | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, x, y, true); |
||
2345 | 02480ac1 | gaqhf | |
2346 | _placement.PIDRemovePlacement(connector.AsLMRepresentation()); |
||
2347 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2348 | } |
||
2349 | else |
||
2350 | { |
||
2351 | List<double[]> vertices = new List<double[]>(); |
||
2352 | for (int i = 1; i <= verticesCount; i++) |
||
2353 | { |
||
2354 | double x = 0; |
||
2355 | double y = 0; |
||
2356 | lineStringGeometry.GetVertex(i, ref x, ref y); |
||
2357 | vertices.Add(new double[] { x, y }); |
||
2358 | } |
||
2359 | |||
2360 | for (int i = 0; i < vertices.Count; i++) |
||
2361 | { |
||
2362 | double[] points = vertices[i]; |
||
2363 | if (i == 0) |
||
2364 | { |
||
2365 | if (connector.ConnectItem1SymbolObject != null) |
||
2366 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, points[0], points[1], true); |
2367 | 02480ac1 | gaqhf | else |
2368 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2369 | } |
||
2370 | else if (i == vertices.Count - 1) |
||
2371 | { |
||
2372 | if (connector.ConnectItem2SymbolObject != null) |
||
2373 | 3b2d7bd8 | gaqhf | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, points[0], points[1], true); |
2374 | 02480ac1 | gaqhf | else |
2375 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2376 | } |
||
2377 | else |
||
2378 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2379 | } |
||
2380 | |||
2381 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, connector.ModelItemID); |
||
2382 | |||
2383 | _placement.PIDRemovePlacement(connector.AsLMRepresentation()); |
||
2384 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2385 | |||
2386 | foreach (var line in lines) |
||
2387 | line.SPPID.ModelItemId = newConnector.ModelItemID; |
||
2388 | } |
||
2389 | |||
2390 | |||
2391 | return newConnector; |
||
2392 | } |
||
2393 | |||
2394 | 74752074 | gaqhf | /// <summary> |
2395 | 53c81765 | gaqhf | /// SpecBreak Modeling 메서드 |
2396 | /// </summary> |
||
2397 | /// <param name="specBreak"></param> |
||
2398 | private void SpecBreakModeling(SpecBreak specBreak) |
||
2399 | { |
||
2400 | object upStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.UpStreamUID); |
||
2401 | object downStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.DownStreamUID); |
||
2402 | |||
2403 | if (upStreamObj != null && |
||
2404 | downStreamObj != null) |
||
2405 | { |
||
2406 | 1ab9a205 | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
2407 | |||
2408 | if (targetLMConnector != null) |
||
2409 | 53c81765 | gaqhf | { |
2410 | 16584d30 | gaqhf | foreach (var attribute in specBreak.ATTRIBUTES) |
2411 | 53c81765 | gaqhf | { |
2412 | 16584d30 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID); |
2413 | if (mapping != null && !string.IsNullOrEmpty(mapping.SPPIDSYMBOLNAME) && mapping.SPPIDSYMBOLNAME != "None") |
||
2414 | { |
||
2415 | string MappingPath = mapping.SPPIDSYMBOLNAME; |
||
2416 | Array array = new double[] { 0, specBreak.SPPID.ORIGINAL_X, specBreak.SPPID.ORIGINAL_Y }; |
||
2417 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, Rotation: specBreak.ANGLE, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
||
2418 | 53c81765 | gaqhf | |
2419 | 16584d30 | gaqhf | if (_LmLabelPersist != null) |
2420 | { |
||
2421 | ReleaseCOMObjects(_LmLabelPersist); |
||
2422 | } |
||
2423 | } |
||
2424 | } |
||
2425 | 1ab9a205 | gaqhf | ReleaseCOMObjects(targetLMConnector); |
2426 | } |
||
2427 | } |
||
2428 | } |
||
2429 | 53c81765 | gaqhf | |
2430 | 1ab9a205 | gaqhf | private LMConnector FindBreakLineTarget(object targetObj, object connectedObj) |
2431 | { |
||
2432 | LMConnector targetConnector = null; |
||
2433 | Symbol targetSymbol = targetObj as Symbol; |
||
2434 | Symbol connectedSymbol = connectedObj as Symbol; |
||
2435 | Line targetLine = targetObj as Line; |
||
2436 | Line connectedLine = connectedObj as Line; |
||
2437 | if (targetSymbol != null && connectedSymbol != null) |
||
2438 | { |
||
2439 | LMSymbol targetLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
2440 | LMSymbol connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
||
2441 | |||
2442 | foreach (LMConnector connector in targetLMSymbol.Avoid1Connectors) |
||
2443 | { |
||
2444 | if (connector.get_ItemStatus() != "Active") |
||
2445 | continue; |
||
2446 | |||
2447 | if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
||
2448 | { |
||
2449 | targetConnector = connector; |
||
2450 | break; |
||
2451 | } |
||
2452 | else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
||
2453 | { |
||
2454 | targetConnector = connector; |
||
2455 | break; |
||
2456 | 53c81765 | gaqhf | } |
2457 | } |
||
2458 | 1ab9a205 | gaqhf | |
2459 | foreach (LMConnector connector in targetLMSymbol.Avoid2Connectors) |
||
2460 | 53c81765 | gaqhf | { |
2461 | 1ab9a205 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2462 | continue; |
||
2463 | 53c81765 | gaqhf | |
2464 | 1ab9a205 | gaqhf | if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
2465 | { |
||
2466 | targetConnector = connector; |
||
2467 | break; |
||
2468 | } |
||
2469 | else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
||
2470 | { |
||
2471 | targetConnector = connector; |
||
2472 | break; |
||
2473 | 53c81765 | gaqhf | } |
2474 | } |
||
2475 | 1ab9a205 | gaqhf | |
2476 | ReleaseCOMObjects(targetLMSymbol); |
||
2477 | ReleaseCOMObjects(connectedLMSymbol); |
||
2478 | } |
||
2479 | else if (targetLine != null && connectedLine != null) |
||
2480 | { |
||
2481 | LMModelItem targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
||
2482 | LMModelItem connectedModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
||
2483 | |||
2484 | if (targetModelItem != null && connectedModelItem != null) |
||
2485 | 53c81765 | gaqhf | { |
2486 | 1ab9a205 | gaqhf | foreach (LMRepresentation rep in targetModelItem.Representations) |
2487 | 53c81765 | gaqhf | { |
2488 | 1ab9a205 | gaqhf | if (targetConnector != null) |
2489 | break; |
||
2490 | 53c81765 | gaqhf | |
2491 | 1ab9a205 | gaqhf | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
2492 | 53c81765 | gaqhf | { |
2493 | 1ab9a205 | gaqhf | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
2494 | |||
2495 | if (IsConnected(_LMConnector, connectedModelItem)) |
||
2496 | targetConnector = _LMConnector; |
||
2497 | else |
||
2498 | ReleaseCOMObjects(_LMConnector); |
||
2499 | 53c81765 | gaqhf | } |
2500 | } |
||
2501 | 1ab9a205 | gaqhf | |
2502 | ReleaseCOMObjects(targetModelItem); |
||
2503 | 53c81765 | gaqhf | } |
2504 | 1ab9a205 | gaqhf | } |
2505 | else |
||
2506 | { |
||
2507 | 340515a2 | gaqhf | LMSymbol connectedLMSymbol = null; |
2508 | if (connectedSymbol != null) |
||
2509 | connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
||
2510 | else if (targetSymbol != null) |
||
2511 | connectedLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
2512 | else |
||
2513 | { |
||
2514 | |||
2515 | } |
||
2516 | LMModelItem targetModelItem = null; |
||
2517 | if (targetLine != null) |
||
2518 | targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
||
2519 | else if (connectedLine != null) |
||
2520 | targetModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
||
2521 | else |
||
2522 | { |
||
2523 | |||
2524 | } |
||
2525 | 1ab9a205 | gaqhf | if (connectedLMSymbol != null && targetModelItem != null) |
2526 | 53c81765 | gaqhf | { |
2527 | 1ab9a205 | gaqhf | foreach (LMConnector connector in connectedLMSymbol.Avoid1Connectors) |
2528 | { |
||
2529 | ac82b020 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2530 | continue; |
||
2531 | |||
2532 | 1ab9a205 | gaqhf | if (IsConnected(connector, targetModelItem)) |
2533 | { |
||
2534 | targetConnector = connector; |
||
2535 | break; |
||
2536 | } |
||
2537 | } |
||
2538 | 53c81765 | gaqhf | |
2539 | 1ab9a205 | gaqhf | if (targetConnector == null) |
2540 | 53c81765 | gaqhf | { |
2541 | 1ab9a205 | gaqhf | foreach (LMConnector connector in connectedLMSymbol.Avoid2Connectors) |
2542 | 53c81765 | gaqhf | { |
2543 | ac82b020 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2544 | continue; |
||
2545 | |||
2546 | 1ab9a205 | gaqhf | if (IsConnected(connector, targetModelItem)) |
2547 | 53c81765 | gaqhf | { |
2548 | 1ab9a205 | gaqhf | targetConnector = connector; |
2549 | break; |
||
2550 | 53c81765 | gaqhf | } |
2551 | } |
||
2552 | } |
||
2553 | } |
||
2554 | |||
2555 | 1ab9a205 | gaqhf | } |
2556 | 02480ac1 | gaqhf | |
2557 | 1ab9a205 | gaqhf | return targetConnector; |
2558 | } |
||
2559 | 53c81765 | gaqhf | |
2560 | 1ab9a205 | gaqhf | private bool IsConnected(LMConnector connector, LMModelItem modelItem) |
2561 | { |
||
2562 | bool result = false; |
||
2563 | |||
2564 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2565 | { |
||
2566 | if (result) |
||
2567 | break; |
||
2568 | |||
2569 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2570 | { |
||
2571 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2572 | |||
2573 | if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2574 | connector.ConnectItem1SymbolObject != null && |
||
2575 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2576 | 53c81765 | gaqhf | { |
2577 | 1ab9a205 | gaqhf | result = true; |
2578 | ReleaseCOMObjects(_LMConnector); |
||
2579 | break; |
||
2580 | } |
||
2581 | else if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2582 | connector.ConnectItem2SymbolObject != null && |
||
2583 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2584 | { |
||
2585 | result = true; |
||
2586 | ReleaseCOMObjects(_LMConnector); |
||
2587 | break; |
||
2588 | } |
||
2589 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2590 | connector.ConnectItem1SymbolObject != null && |
||
2591 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2592 | { |
||
2593 | result = true; |
||
2594 | ReleaseCOMObjects(_LMConnector); |
||
2595 | break; |
||
2596 | } |
||
2597 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2598 | connector.ConnectItem2SymbolObject != null && |
||
2599 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2600 | { |
||
2601 | result = true; |
||
2602 | ReleaseCOMObjects(_LMConnector); |
||
2603 | break; |
||
2604 | 53c81765 | gaqhf | } |
2605 | |||
2606 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2607 | } |
||
2608 | 53c81765 | gaqhf | } |
2609 | 1ab9a205 | gaqhf | |
2610 | |||
2611 | return result; |
||
2612 | 53c81765 | gaqhf | } |
2613 | |||
2614 | /// <summary> |
||
2615 | 74752074 | gaqhf | /// FromModelItem을 ToModelItem으로 PipeRunJoin하는 메서드 |
2616 | /// </summary> |
||
2617 | /// <param name="fromModelItemId"></param> |
||
2618 | /// <param name="toModelItemId"></param> |
||
2619 | 335b7a24 | gaqhf | private void JoinPipeRun(string fromModelItemId, string toModelItemId) |
2620 | { |
||
2621 | 310aeb31 | gaqhf | LMModelItem modelItem1 = dataSource.GetModelItem(toModelItemId); |
2622 | _LMAItem item1 = modelItem1.AsLMAItem(); |
||
2623 | LMModelItem modelItem2 = dataSource.GetModelItem(fromModelItemId); |
||
2624 | _LMAItem item2 = modelItem2.AsLMAItem(); |
||
2625 | 3939eebf | gaqhf | |
2626 | 7f00b26c | gaqhf | // item2가 item1으로 조인 |
2627 | _placement.PIDJoinRuns(ref item1, ref item2); |
||
2628 | item1.Commit(); |
||
2629 | item2.Commit(); |
||
2630 | |||
2631 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, fromModelItemId); |
||
2632 | foreach (var line in lines) |
||
2633 | line.SPPID.ModelItemId = toModelItemId; |
||
2634 | |||
2635 | ReleaseCOMObjects(modelItem1); |
||
2636 | ReleaseCOMObjects(item1); |
||
2637 | ReleaseCOMObjects(modelItem2); |
||
2638 | ReleaseCOMObjects(item2); |
||
2639 | 335b7a24 | gaqhf | } |
2640 | |||
2641 | 74752074 | gaqhf | /// <summary> |
2642 | /// PipeRun을 자동으로 Join하는 메서드 |
||
2643 | /// </summary> |
||
2644 | /// <param name="modelItemId"></param> |
||
2645 | 335b7a24 | gaqhf | private void AutoJoinPipeRun(string modelItemId) |
2646 | { |
||
2647 | 310aeb31 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
2648 | _LMAItem item = modelItem.AsLMAItem(); |
||
2649 | 7f00b26c | gaqhf | if (modelItem.get_ItemStatus() == "Active") |
2650 | 65a1ed4b | gaqhf | { |
2651 | 7f00b26c | gaqhf | string modelitemID = item.Id; |
2652 | _placement.PIDAutoJoin(item, AutoJoinEndConstants.autoJoin_Both, ref item); |
||
2653 | string afterModelItemID = item.Id; |
||
2654 | 87f02fc0 | gaqhf | |
2655 | 7f00b26c | gaqhf | if (modelitemID != afterModelItemID) |
2656 | { |
||
2657 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, modelitemID); |
||
2658 | foreach (var line in lines) |
||
2659 | line.SPPID.ModelItemId = afterModelItemID; |
||
2660 | 65a1ed4b | gaqhf | } |
2661 | 7f00b26c | gaqhf | item.Commit(); |
2662 | 65a1ed4b | gaqhf | } |
2663 | 7f00b26c | gaqhf | |
2664 | ReleaseCOMObjects(modelItem); |
||
2665 | ReleaseCOMObjects(item); |
||
2666 | 335b7a24 | gaqhf | } |
2667 | |||
2668 | 74752074 | gaqhf | /// <summary> |
2669 | /// LineRun에 있는 Line들을 Join하는 진입 메서드 |
||
2670 | /// </summary> |
||
2671 | /// <param name="run"></param> |
||
2672 | 335b7a24 | gaqhf | private void JoinRunLine(LineRun run) |
2673 | { |
||
2674 | string modelItemId = string.Empty; |
||
2675 | foreach (var item in run.RUNITEMS) |
||
2676 | { |
||
2677 | if (item.GetType() == typeof(Line)) |
||
2678 | { |
||
2679 | Line line = item as Line; |
||
2680 | 1ba9c671 | gaqhf | AutoJoinPipeRun(line.SPPID.ModelItemId); |
2681 | modelItemId = line.SPPID.ModelItemId; |
||
2682 | f31645b6 | gaqhf | |
2683 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
2684 | 335b7a24 | gaqhf | } |
2685 | } |
||
2686 | } |
||
2687 | |||
2688 | 74752074 | gaqhf | /// <summary> |
2689 | /// PipeRun의 좌표를 가져오는 메서드 |
||
2690 | /// </summary> |
||
2691 | /// <param name="modelId"></param> |
||
2692 | /// <returns></returns> |
||
2693 | 5e6ecf05 | gaqhf | private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId) |
2694 | { |
||
2695 | Dictionary<LMConnector, List<double[]>> connectorVertices = new Dictionary<LMConnector, List<double[]>>(); |
||
2696 | 310aeb31 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelId); |
2697 | |||
2698 | if (modelItem != null) |
||
2699 | 5e6ecf05 | gaqhf | { |
2700 | 310aeb31 | gaqhf | foreach (LMRepresentation rep in modelItem.Representations) |
2701 | 5e6ecf05 | gaqhf | { |
2702 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2703 | { |
||
2704 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2705 | connectorVertices.Add(_LMConnector, new List<double[]>()); |
||
2706 | dynamic OID = rep.get_GraphicOID(); |
||
2707 | 335b7a24 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
2708 | 5e6ecf05 | gaqhf | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
2709 | int verticesCount = lineStringGeometry.VertexCount; |
||
2710 | double[] vertices = null; |
||
2711 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
2712 | for (int i = 0; i < verticesCount; i++) |
||
2713 | { |
||
2714 | double x = 0; |
||
2715 | double y = 0; |
||
2716 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
2717 | 335b7a24 | gaqhf | connectorVertices[_LMConnector].Add(new double[] { Math.Round(x, 10), Math.Round(y, 10) }); |
2718 | 5e6ecf05 | gaqhf | } |
2719 | } |
||
2720 | } |
||
2721 | |||
2722 | 310aeb31 | gaqhf | ReleaseCOMObjects(modelItem); |
2723 | 5e6ecf05 | gaqhf | } |
2724 | |||
2725 | return connectorVertices; |
||
2726 | } |
||
2727 | |||
2728 | 7c7bcd10 | gaqhf | /// <summary> |
2729 | /// LMConnector들을 가져온다. |
||
2730 | /// </summary> |
||
2731 | /// <param name="modelId"></param> |
||
2732 | /// <returns></returns> |
||
2733 | 53c81765 | gaqhf | private List<LMConnector> GetConnectors(string modelId) |
2734 | { |
||
2735 | List<LMConnector> connectors = new List<LMConnector>(); |
||
2736 | LMModelItem modelItem = dataSource.GetModelItem(modelId); |
||
2737 | |||
2738 | if (modelItem != null) |
||
2739 | { |
||
2740 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2741 | { |
||
2742 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2743 | { |
||
2744 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2745 | connectors.Add(_LMConnector); |
||
2746 | } |
||
2747 | } |
||
2748 | |||
2749 | ReleaseCOMObjects(modelItem); |
||
2750 | } |
||
2751 | |||
2752 | return connectors; |
||
2753 | } |
||
2754 | |||
2755 | 74752074 | gaqhf | /// <summary> |
2756 | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 두점으로 라인의 교차점을 기준으로 구함 |
||
2757 | /// </summary> |
||
2758 | /// <param name="connectorVertices"></param> |
||
2759 | /// <param name="connX"></param> |
||
2760 | /// <param name="connY"></param> |
||
2761 | /// <param name="x2"></param> |
||
2762 | /// <param name="y2"></param> |
||
2763 | /// <returns></returns> |
||
2764 | 56bc67e1 | gaqhf | private LMConnector FindTargetLMConnector(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY, double x2, double y2) |
2765 | 5e6ecf05 | gaqhf | { |
2766 | double length = double.MaxValue; |
||
2767 | LMConnector targetConnector = null; |
||
2768 | foreach (var item in connectorVertices) |
||
2769 | { |
||
2770 | List<double[]> points = item.Value; |
||
2771 | for (int i = 0; i < points.Count - 1; i++) |
||
2772 | { |
||
2773 | double[] point1 = points[i]; |
||
2774 | double[] point2 = points[i + 1]; |
||
2775 | |||
2776 | 335b7a24 | gaqhf | double maxLineX = Math.Max(point1[0], point2[0]); |
2777 | double minLineX = Math.Min(point1[0], point2[0]); |
||
2778 | double maxLineY = Math.Max(point1[1], point2[1]); |
||
2779 | double minLineY = Math.Min(point1[1], point2[1]); |
||
2780 | |||
2781 | SlopeType slope = SPPIDUtil.CalcSlope(minLineX, minLineY, maxLineX, maxLineY); |
||
2782 | |||
2783 | 56bc67e1 | gaqhf | // 두직선의 교차점 |
2784 | double[] crossingPoint = SPPIDUtil.CalcLineCrossingPoint(connX, connY, x2, y2, point1[0], point1[1], point2[0], point2[1]); |
||
2785 | if (crossingPoint != null) |
||
2786 | 5e6ecf05 | gaqhf | { |
2787 | 30a9ffce | gaqhf | double distance = SPPIDUtil.CalcPointToPointdDistance(connX, connY, crossingPoint[0], crossingPoint[1]); |
2788 | 335b7a24 | gaqhf | if (length >= distance) |
2789 | 30a9ffce | gaqhf | { |
2790 | 335b7a24 | gaqhf | if (slope == SlopeType.Slope && |
2791 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0] && |
||
2792 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
2793 | { |
||
2794 | targetConnector = item.Key; |
||
2795 | length = distance; |
||
2796 | } |
||
2797 | else if (slope == SlopeType.HORIZONTAL && |
||
2798 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0]) |
||
2799 | { |
||
2800 | targetConnector = item.Key; |
||
2801 | length = distance; |
||
2802 | } |
||
2803 | else if (slope == SlopeType.VERTICAL && |
||
2804 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
2805 | { |
||
2806 | targetConnector = item.Key; |
||
2807 | length = distance; |
||
2808 | } |
||
2809 | 30a9ffce | gaqhf | } |
2810 | 5e6ecf05 | gaqhf | } |
2811 | } |
||
2812 | c3d2e266 | gaqhf | |
2813 | |||
2814 | } |
||
2815 | |||
2816 | if (targetConnector == null) |
||
2817 | { |
||
2818 | foreach (var item in connectorVertices) |
||
2819 | { |
||
2820 | List<double[]> points = item.Value; |
||
2821 | foreach (var point in points) |
||
2822 | { |
||
2823 | double distance = SPPIDUtil.CalcPointToPointdDistance(connX, connY, point[0], point[1]); |
||
2824 | if (length >= distance) |
||
2825 | { |
||
2826 | targetConnector = item.Key; |
||
2827 | length = distance; |
||
2828 | } |
||
2829 | } |
||
2830 | } |
||
2831 | |||
2832 | 5e6ecf05 | gaqhf | } |
2833 | |||
2834 | return targetConnector; |
||
2835 | } |
||
2836 | |||
2837 | 74752074 | gaqhf | /// <summary> |
2838 | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 한점으로 제일 가까운 기준으로 구함(단순) |
||
2839 | /// </summary> |
||
2840 | /// <param name="connectorVertices"></param> |
||
2841 | /// <param name="connX"></param> |
||
2842 | /// <param name="connY"></param> |
||
2843 | /// <returns></returns> |
||
2844 | ac78b508 | gaqhf | private LMConnector FindTargetLMConnectorByPoint(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
2845 | { |
||
2846 | double length = double.MaxValue; |
||
2847 | LMConnector targetConnector = null; |
||
2848 | foreach (var item in connectorVertices) |
||
2849 | { |
||
2850 | List<double[]> points = item.Value; |
||
2851 | |||
2852 | foreach (double[] point in points) |
||
2853 | { |
||
2854 | double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
||
2855 | if (length >= distance) |
||
2856 | { |
||
2857 | targetConnector = item.Key; |
||
2858 | length = distance; |
||
2859 | } |
||
2860 | } |
||
2861 | } |
||
2862 | |||
2863 | return targetConnector; |
||
2864 | } |
||
2865 | |||
2866 | 74752074 | gaqhf | /// <summary> |
2867 | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 조건에 안맞아서 못찾을시 제일 가까운 점으로 가져오는 방식 |
||
2868 | /// </summary> |
||
2869 | /// <param name="connectorVertices"></param> |
||
2870 | /// <param name="connX"></param> |
||
2871 | /// <param name="connY"></param> |
||
2872 | /// <returns></returns> |
||
2873 | 68464385 | gaqhf | private LMConnector FindTargetLMConnectorForLabel(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
2874 | { |
||
2875 | double length = double.MaxValue; |
||
2876 | LMConnector targetConnector = null; |
||
2877 | foreach (var item in connectorVertices) |
||
2878 | { |
||
2879 | List<double[]> points = item.Value; |
||
2880 | for (int i = 0; i < points.Count - 1; i++) |
||
2881 | { |
||
2882 | double[] point1 = points[i]; |
||
2883 | double[] point2 = points[i + 1]; |
||
2884 | double x1 = Math.Min(point1[0], point2[0]); |
||
2885 | double y1 = Math.Min(point1[1], point2[1]); |
||
2886 | double x2 = Math.Max(point1[0], point2[0]); |
||
2887 | double y2 = Math.Max(point1[1], point2[1]); |
||
2888 | |||
2889 | if ((x1 <= connX && x2 >= connX) || |
||
2890 | (y1 <= connY && y2 >= connY)) |
||
2891 | { |
||
2892 | double distance = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], connX, connY); |
||
2893 | if (length >= distance) |
||
2894 | { |
||
2895 | targetConnector = item.Key; |
||
2896 | length = distance; |
||
2897 | } |
||
2898 | |||
2899 | distance = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], connX, connY); |
||
2900 | if (length >= distance) |
||
2901 | { |
||
2902 | targetConnector = item.Key; |
||
2903 | length = distance; |
||
2904 | } |
||
2905 | } |
||
2906 | } |
||
2907 | } |
||
2908 | |||
2909 | // 못찾았을때. |
||
2910 | length = double.MaxValue; |
||
2911 | if (targetConnector == null) |
||
2912 | { |
||
2913 | foreach (var item in connectorVertices) |
||
2914 | { |
||
2915 | List<double[]> points = item.Value; |
||
2916 | |||
2917 | foreach (double[] point in points) |
||
2918 | { |
||
2919 | double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
||
2920 | if (length >= distance) |
||
2921 | { |
||
2922 | targetConnector = item.Key; |
||
2923 | length = distance; |
||
2924 | } |
||
2925 | } |
||
2926 | } |
||
2927 | } |
||
2928 | |||
2929 | return targetConnector; |
||
2930 | } |
||
2931 | |||
2932 | 74752074 | gaqhf | /// <summary> |
2933 | /// Line Number Symbol을 실제로 Modeling하는 메서드 |
||
2934 | /// </summary> |
||
2935 | /// <param name="lineNumber"></param> |
||
2936 | cfda1fed | gaqhf | private void LineNumberModeling(LineNumber lineNumber) |
2937 | { |
||
2938 | 340515a2 | gaqhf | object obj = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE); |
2939 | if (obj != null) |
||
2940 | 10872260 | gaqhf | { |
2941 | 340515a2 | gaqhf | Line line = obj as Line; |
2942 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
2943 | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y); |
||
2944 | if (connectedLMConnector != null) |
||
2945 | { |
||
2946 | double x = 0; |
||
2947 | double y = 0; |
||
2948 | CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
||
2949 | b65a7e32 | gaqhf | |
2950 | 340515a2 | gaqhf | Array points = new double[] { 0, x, y }; |
2951 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
||
2952 | cfda1fed | gaqhf | |
2953 | 340515a2 | gaqhf | foreach (var item in connectorVertices) |
2954 | ReleaseCOMObjects(item.Key); |
||
2955 | if (_LmLabelPresist != null) |
||
2956 | { |
||
2957 | _LmLabelPresist.Commit(); |
||
2958 | lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
||
2959 | ReleaseCOMObjects(_LmLabelPresist); |
||
2960 | } |
||
2961 | else |
||
2962 | { |
||
2963 | c3d2e266 | gaqhf | |
2964 | 340515a2 | gaqhf | } |
2965 | c3d2e266 | gaqhf | } |
2966 | 10872260 | gaqhf | } |
2967 | f31645b6 | gaqhf | |
2968 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
2969 | cfda1fed | gaqhf | } |
2970 | |||
2971 | 74752074 | gaqhf | /// <summary> |
2972 | b2d1c1aa | gaqhf | /// Flow Mark Modeling |
2973 | /// </summary> |
||
2974 | /// <param name="line"></param> |
||
2975 | private void FlowMarkModeling(Line line) |
||
2976 | { |
||
2977 | a0965e07 | gaqhf | if (line.FLOWMARK && !string.IsNullOrEmpty(line.SPPID.ModelItemId) && !string.IsNullOrEmpty(_ETCSetting.FlowMarkSymbolPath)) |
2978 | b2d1c1aa | gaqhf | { |
2979 | 47ad9a46 | gaqhf | SlopeType targetSlopeType = SPPIDUtil.CalcSlope(line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
2980 | b2d1c1aa | gaqhf | string mappingPath = _ETCSetting.FlowMarkSymbolPath; |
2981 | 47ad9a46 | gaqhf | double percent = line.FLOWMARK_PERCENT; |
2982 | b2d1c1aa | gaqhf | double tempX = 0; |
2983 | double tempY = 0; |
||
2984 | |||
2985 | 47ad9a46 | gaqhf | double gapX; |
2986 | double gapY; |
||
2987 | // ID2 기준의 Gap을 구함 |
||
2988 | if (percent == 0) |
||
2989 | { |
||
2990 | gapX = 0; |
||
2991 | gapY = 0; |
||
2992 | } |
||
2993 | else |
||
2994 | { |
||
2995 | gapX = Math.Abs(line.SPPID.START_X - line.SPPID.END_X) / 100 * percent; |
||
2996 | gapY = Math.Abs(line.SPPID.START_Y - line.SPPID.END_Y) / 100 * percent; |
||
2997 | } |
||
2998 | b2d1c1aa | gaqhf | |
2999 | 47ad9a46 | gaqhf | if (line.SPPID.START_X < line.SPPID.END_X) |
3000 | tempX = line.SPPID.START_X + gapX; |
||
3001 | else |
||
3002 | tempX = line.SPPID.START_X - gapX; |
||
3003 | b2d1c1aa | gaqhf | |
3004 | 47ad9a46 | gaqhf | if (line.SPPID.START_Y < line.SPPID.END_Y) |
3005 | tempY = line.SPPID.START_Y + gapY; |
||
3006 | else |
||
3007 | tempY = line.SPPID.START_Y - gapY; |
||
3008 | b2d1c1aa | gaqhf | |
3009 | 7f00b26c | gaqhf | |
3010 | |||
3011 | b2d1c1aa | gaqhf | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
3012 | LMConnector _TargetItem = null; |
||
3013 | double distance = double.MaxValue; |
||
3014 | 47ad9a46 | gaqhf | double[] startPoint = null; |
3015 | double[] endPoint = null; |
||
3016 | // ID2의 기준 Gap으로 제일 가까운 Line 찾음(Slope도 같은조건) |
||
3017 | b2d1c1aa | gaqhf | foreach (var item in connectorVertices) |
3018 | { |
||
3019 | for (int i = 0; i < item.Value.Count - 1; i++) |
||
3020 | { |
||
3021 | List<double[]> points = item.Value; |
||
3022 | double[] point1 = points[i]; |
||
3023 | double[] point2 = points[i + 1]; |
||
3024 | |||
3025 | SlopeType slopeType = SPPIDUtil.CalcSlope(point1[0], point1[1], point2[0], point2[1]); |
||
3026 | 47ad9a46 | gaqhf | if (slopeType == targetSlopeType) |
3027 | b2d1c1aa | gaqhf | { |
3028 | 47ad9a46 | gaqhf | double result = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], tempX, tempY); |
3029 | if (result < distance) |
||
3030 | b2d1c1aa | gaqhf | { |
3031 | 47ad9a46 | gaqhf | distance = result; |
3032 | _TargetItem = item.Key; |
||
3033 | |||
3034 | startPoint = point1; |
||
3035 | endPoint = point2; |
||
3036 | b2d1c1aa | gaqhf | } |
3037 | 47ad9a46 | gaqhf | |
3038 | result = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], tempX, tempY); |
||
3039 | if (result < distance) |
||
3040 | b2d1c1aa | gaqhf | { |
3041 | 47ad9a46 | gaqhf | distance = result; |
3042 | _TargetItem = item.Key; |
||
3043 | b2d1c1aa | gaqhf | |
3044 | 47ad9a46 | gaqhf | startPoint = point1; |
3045 | endPoint = point2; |
||
3046 | } |
||
3047 | b2d1c1aa | gaqhf | } |
3048 | } |
||
3049 | } |
||
3050 | |||
3051 | if (_TargetItem != null) |
||
3052 | { |
||
3053 | 47ad9a46 | gaqhf | double x = 0; |
3054 | double y = 0; |
||
3055 | double angle = 0; |
||
3056 | // SPPID 기준의 Gap으로 실 좌표를 구함 |
||
3057 | if (percent == 0) |
||
3058 | { |
||
3059 | gapX = 0; |
||
3060 | gapY = 0; |
||
3061 | } |
||
3062 | else |
||
3063 | { |
||
3064 | gapX = Math.Abs(startPoint[0] - endPoint[0]) / 100 * percent; |
||
3065 | gapY = Math.Abs(startPoint[1] - endPoint[1]) / 100 * percent; |
||
3066 | } |
||
3067 | b2d1c1aa | gaqhf | |
3068 | 47ad9a46 | gaqhf | if (startPoint[0] < endPoint[0]) |
3069 | x = startPoint[0] + gapX; |
||
3070 | else |
||
3071 | x = startPoint[0] - gapX; |
||
3072 | |||
3073 | if (startPoint[1] < endPoint[1]) |
||
3074 | y = startPoint[1] + gapY; |
||
3075 | else |
||
3076 | y = startPoint[1] - gapY; |
||
3077 | 7f00b26c | gaqhf | |
3078 | 47ad9a46 | gaqhf | if (targetSlopeType == SlopeType.HORIZONTAL) |
3079 | { |
||
3080 | if (startPoint[0] < endPoint[0]) |
||
3081 | angle = 0; |
||
3082 | else |
||
3083 | angle = Math.PI; |
||
3084 | } |
||
3085 | // 90 270 |
||
3086 | else if (targetSlopeType == SlopeType.VERTICAL) |
||
3087 | { |
||
3088 | if (startPoint[1] < endPoint[1]) |
||
3089 | angle = 90 * Math.PI / 180; |
||
3090 | else |
||
3091 | angle = 270 * Math.PI / 180; |
||
3092 | } |
||
3093 | |||
3094 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: 0, Rotation: angle, TargetItem: _TargetItem); |
||
3095 | 7f00b26c | gaqhf | |
3096 | b2d1c1aa | gaqhf | if (_LMSymbol != null) |
3097 | { |
||
3098 | ReleaseCOMObjects(_LMSymbol); |
||
3099 | } |
||
3100 | 7f00b26c | gaqhf | |
3101 | b2d1c1aa | gaqhf | } |
3102 | |||
3103 | foreach (var item in connectorVertices) |
||
3104 | ReleaseCOMObjects(item.Key); |
||
3105 | } |
||
3106 | } |
||
3107 | |||
3108 | /// <summary> |
||
3109 | 74752074 | gaqhf | /// Line Number 기준으로 모든 Item에 Line Number의 Attribute Input |
3110 | /// </summary> |
||
3111 | /// <param name="lineNumber"></param> |
||
3112 | a7e9beec | gaqhf | private void InputLineNumberAttribute(LineNumber lineNumber) |
3113 | { |
||
3114 | 8634af60 | gaqhf | foreach (LineRun run in lineNumber.RUNS) |
3115 | a7e9beec | gaqhf | { |
3116 | 8634af60 | gaqhf | foreach (var item in run.RUNITEMS) |
3117 | a7e9beec | gaqhf | { |
3118 | 8634af60 | gaqhf | if (item.GetType() == typeof(Symbol)) |
3119 | a7e9beec | gaqhf | { |
3120 | 8634af60 | gaqhf | Symbol symbol = item as Symbol; |
3121 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
3122 | 340515a2 | gaqhf | if (_LMSymbol != null) |
3123 | 8634af60 | gaqhf | { |
3124 | 340515a2 | gaqhf | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
3125 | |||
3126 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3127 | 8634af60 | gaqhf | { |
3128 | 340515a2 | gaqhf | foreach (var attribute in lineNumber.ATTRIBUTES) |
3129 | 8634af60 | gaqhf | { |
3130 | 340515a2 | gaqhf | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
3131 | if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3132 | 8634af60 | gaqhf | { |
3133 | 340515a2 | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
3134 | if (_LMAAttribute != null) |
||
3135 | { |
||
3136 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
3137 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3138 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
3139 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3140 | } |
||
3141 | 8634af60 | gaqhf | } |
3142 | } |
||
3143 | 340515a2 | gaqhf | _LMModelItem.Commit(); |
3144 | 8634af60 | gaqhf | } |
3145 | 340515a2 | gaqhf | if (_LMModelItem != null) |
3146 | ReleaseCOMObjects(_LMModelItem); |
||
3147 | 8634af60 | gaqhf | } |
3148 | if (_LMSymbol != null) |
||
3149 | ReleaseCOMObjects(_LMSymbol); |
||
3150 | } |
||
3151 | else if (item.GetType() == typeof(Line)) |
||
3152 | { |
||
3153 | Line line = item as Line; |
||
3154 | if (line != null) |
||
3155 | a7e9beec | gaqhf | { |
3156 | 8634af60 | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
3157 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3158 | a7e9beec | gaqhf | { |
3159 | 8634af60 | gaqhf | foreach (var attribute in lineNumber.ATTRIBUTES) |
3160 | { |
||
3161 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
3162 | b2d1c1aa | gaqhf | if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
3163 | 8634af60 | gaqhf | { |
3164 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
3165 | if (_LMAAttribute != null) |
||
3166 | { |
||
3167 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
3168 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3169 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
3170 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3171 | 7f00b26c | gaqhf | |
3172 | 8634af60 | gaqhf | } |
3173 | } |
||
3174 | } |
||
3175 | 68464385 | gaqhf | _LMModelItem.Commit(); |
3176 | a7e9beec | gaqhf | } |
3177 | 8634af60 | gaqhf | if (_LMModelItem != null) |
3178 | ReleaseCOMObjects(_LMModelItem); |
||
3179 | a7e9beec | gaqhf | } |
3180 | } |
||
3181 | } |
||
3182 | } |
||
3183 | f31645b6 | gaqhf | |
3184 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
3185 | a7e9beec | gaqhf | } |
3186 | |||
3187 | 74752074 | gaqhf | /// <summary> |
3188 | /// Symbol Attribute 입력 메서드 |
||
3189 | /// </summary> |
||
3190 | 73415441 | gaqhf | /// <param name="item"></param> |
3191 | private void InputSymbolAttribute(object targetItem, List<BaseModel.Attribute> targetAttributes) |
||
3192 | 1efc25a3 | gaqhf | { |
3193 | 7f00b26c | gaqhf | |
3194 | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
||
3195 | string sRep = null; |
||
3196 | if (targetItem.GetType() == typeof(Symbol)) |
||
3197 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
3198 | else if (targetItem.GetType() == typeof(Equipment)) |
||
3199 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
3200 | |||
3201 | if (!string.IsNullOrEmpty(sRep)) |
||
3202 | 1efc25a3 | gaqhf | { |
3203 | 7f00b26c | gaqhf | LMSymbol _LMSymbol = dataSource.GetSymbol(sRep); |
3204 | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
||
3205 | LMAAttributes _Attributes = _LMModelItem.Attributes; |
||
3206 | 402ef5b1 | gaqhf | |
3207 | 7f00b26c | gaqhf | foreach (var item in targetAttributes) |
3208 | { |
||
3209 | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
||
3210 | if (mapping != null && !string.IsNullOrEmpty(item.VALUE) && item.VALUE != "None") |
||
3211 | 65a1ed4b | gaqhf | { |
3212 | 7f00b26c | gaqhf | LMAAttribute _Attribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
3213 | if (_Attribute != null) |
||
3214 | _Attribute.set_Value(item.VALUE); |
||
3215 | 65a1ed4b | gaqhf | } |
3216 | ac78b508 | gaqhf | } |
3217 | 7f00b26c | gaqhf | _LMModelItem.Commit(); |
3218 | |||
3219 | ReleaseCOMObjects(_Attributes); |
||
3220 | ReleaseCOMObjects(_LMModelItem); |
||
3221 | ReleaseCOMObjects(_LMSymbol); |
||
3222 | 1efc25a3 | gaqhf | } |
3223 | f31645b6 | gaqhf | |
3224 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
3225 | 1efc25a3 | gaqhf | } |
3226 | |||
3227 | 74752074 | gaqhf | /// <summary> |
3228 | 16584d30 | gaqhf | /// Input SpecBreak Attribute |
3229 | /// </summary> |
||
3230 | /// <param name="specBreak"></param> |
||
3231 | private void InputSpecBreakAttribute(SpecBreak specBreak) |
||
3232 | { |
||
3233 | 7f00b26c | gaqhf | object upStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.UpStreamUID); |
3234 | object downStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.DownStreamUID); |
||
3235 | |||
3236 | if (upStreamObj != null && |
||
3237 | downStreamObj != null) |
||
3238 | 16584d30 | gaqhf | { |
3239 | 7f00b26c | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
3240 | 16584d30 | gaqhf | |
3241 | 7f00b26c | gaqhf | if (targetLMConnector != null) |
3242 | 16584d30 | gaqhf | { |
3243 | 7f00b26c | gaqhf | foreach (LMLabelPersist _LMLabelPersist in targetLMConnector.LabelPersists) |
3244 | 16584d30 | gaqhf | { |
3245 | 7f00b26c | gaqhf | string symbolPath = _LMLabelPersist.get_FileName(); |
3246 | AttributeMapping mapping = document.AttributeMappings.Find(x => x.SPPIDSYMBOLNAME == symbolPath); |
||
3247 | if (mapping != null) |
||
3248 | 16584d30 | gaqhf | { |
3249 | 7f00b26c | gaqhf | BaseModel.Attribute attribute = specBreak.ATTRIBUTES.Find(y => y.UID == mapping.UID); |
3250 | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3251 | 16584d30 | gaqhf | { |
3252 | 7f00b26c | gaqhf | string[] values = attribute.VALUE.Split(new char[] { ',' }); |
3253 | if (values.Length == 2) |
||
3254 | 16584d30 | gaqhf | { |
3255 | 7f00b26c | gaqhf | string upStreamValue = values[0]; |
3256 | string downStreamValue = values[1]; |
||
3257 | 16584d30 | gaqhf | |
3258 | 7f00b26c | gaqhf | InputAttributeForSpecBreak(upStreamObj, downStreamObj, upStreamValue, downStreamValue, mapping.SPPIDATTRIBUTENAME); |
3259 | 16584d30 | gaqhf | } |
3260 | } |
||
3261 | } |
||
3262 | } |
||
3263 | 7f00b26c | gaqhf | |
3264 | ReleaseCOMObjects(targetLMConnector); |
||
3265 | 16584d30 | gaqhf | } |
3266 | } |
||
3267 | 7f00b26c | gaqhf | |
3268 | 16584d30 | gaqhf | |
3269 | #region 내부에서만 쓰는 메서드 |
||
3270 | 7f00b26c | gaqhf | void InputAttributeForSpecBreak(object _upStreamObj, object _downStreamObj, string upStreamValue, string downStreamValue, string sppidAttributeName) |
3271 | 16584d30 | gaqhf | { |
3272 | 7f00b26c | gaqhf | Symbol upStreamSymbol = _upStreamObj as Symbol; |
3273 | Line upStreamLine = _upStreamObj as Line; |
||
3274 | Symbol downStreamSymbol = _downStreamObj as Symbol; |
||
3275 | Line downStreamLine = _downStreamObj as Line; |
||
3276 | // 둘다 Line일 경우 |
||
3277 | if (upStreamLine != null && downStreamLine != null) |
||
3278 | 16584d30 | gaqhf | { |
3279 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLine(upStreamLine, sppidAttributeName, upStreamValue); |
3280 | InputLineAttributeForSpecBreakLine(downStreamLine, sppidAttributeName, downStreamValue); |
||
3281 | } |
||
3282 | // 둘다 Symbol일 경우 |
||
3283 | else if (upStreamSymbol != null && downStreamSymbol != null) |
||
3284 | { |
||
3285 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamSymbol, downStreamSymbol); |
||
3286 | LMSymbol upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
||
3287 | LMSymbol downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
||
3288 | 16584d30 | gaqhf | |
3289 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
3290 | { |
||
3291 | if (connector.get_ItemStatus() != "Active") |
||
3292 | continue; |
||
3293 | 16584d30 | gaqhf | |
3294 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3295 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3296 | } |
||
3297 | 16584d30 | gaqhf | |
3298 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
3299 | { |
||
3300 | if (connector.get_ItemStatus() != "Active") |
||
3301 | continue; |
||
3302 | 16584d30 | gaqhf | |
3303 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3304 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3305 | } |
||
3306 | 16584d30 | gaqhf | |
3307 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors) |
3308 | { |
||
3309 | if (connector.get_ItemStatus() != "Active") |
||
3310 | continue; |
||
3311 | 16584d30 | gaqhf | |
3312 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3313 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3314 | } |
||
3315 | 16584d30 | gaqhf | |
3316 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
3317 | { |
||
3318 | if (connector.get_ItemStatus() != "Active") |
||
3319 | continue; |
||
3320 | 16584d30 | gaqhf | |
3321 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3322 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3323 | 16584d30 | gaqhf | } |
3324 | |||
3325 | 7f00b26c | gaqhf | ReleaseCOMObjects(zeroLenthConnector); |
3326 | ReleaseCOMObjects(upStreamLMSymbol); |
||
3327 | ReleaseCOMObjects(downStreamLMSymbol); |
||
3328 | } |
||
3329 | else if (upStreamSymbol != null && downStreamLine != null) |
||
3330 | { |
||
3331 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamSymbol, downStreamLine); |
||
3332 | InputLineAttributeForSpecBreakLine(downStreamLine, sppidAttributeName, downStreamValue); |
||
3333 | LMSymbol upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
||
3334 | 16584d30 | gaqhf | |
3335 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
3336 | { |
||
3337 | if (connector.get_ItemStatus() != "Active") |
||
3338 | continue; |
||
3339 | 16584d30 | gaqhf | |
3340 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3341 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3342 | } |
||
3343 | 16584d30 | gaqhf | |
3344 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
3345 | { |
||
3346 | if (connector.get_ItemStatus() != "Active") |
||
3347 | continue; |
||
3348 | 16584d30 | gaqhf | |
3349 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3350 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3351 | 16584d30 | gaqhf | } |
3352 | |||
3353 | 7f00b26c | gaqhf | ReleaseCOMObjects(zeroLenthConnector); |
3354 | ReleaseCOMObjects(upStreamLMSymbol); |
||
3355 | } |
||
3356 | else if (upStreamLine != null && downStreamSymbol != null) |
||
3357 | { |
||
3358 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamLine, downStreamSymbol); |
||
3359 | InputLineAttributeForSpecBreakLine(upStreamLine, sppidAttributeName, upStreamValue); |
||
3360 | LMSymbol downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
||
3361 | 16584d30 | gaqhf | |
3362 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors) |
3363 | { |
||
3364 | if (connector.get_ItemStatus() != "Active") |
||
3365 | continue; |
||
3366 | 16584d30 | gaqhf | |
3367 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3368 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3369 | } |
||
3370 | 16584d30 | gaqhf | |
3371 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
3372 | { |
||
3373 | if (connector.get_ItemStatus() != "Active") |
||
3374 | continue; |
||
3375 | 16584d30 | gaqhf | |
3376 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3377 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3378 | 16584d30 | gaqhf | } |
3379 | 7f00b26c | gaqhf | |
3380 | ReleaseCOMObjects(zeroLenthConnector); |
||
3381 | ReleaseCOMObjects(downStreamLMSymbol); |
||
3382 | 16584d30 | gaqhf | } |
3383 | } |
||
3384 | |||
3385 | void InputLineAttributeForSpecBreakLine(Line line, string attrName, string value) |
||
3386 | { |
||
3387 | 7f00b26c | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
3388 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3389 | 16584d30 | gaqhf | { |
3390 | 7f00b26c | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[attrName]; |
3391 | if (_LMAAttribute != null) |
||
3392 | 16584d30 | gaqhf | { |
3393 | 7f00b26c | gaqhf | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
3394 | _LMAAttribute.set_Value(value); |
||
3395 | else if (_LMAAttribute.get_Value() != value) |
||
3396 | _LMAAttribute.set_Value(value); |
||
3397 | 16584d30 | gaqhf | } |
3398 | 7f00b26c | gaqhf | |
3399 | _LMModelItem.Commit(); |
||
3400 | 16584d30 | gaqhf | } |
3401 | 7f00b26c | gaqhf | if (_LMModelItem != null) |
3402 | ReleaseCOMObjects(_LMModelItem); |
||
3403 | 16584d30 | gaqhf | } |
3404 | |||
3405 | void InputLineAttributeForSpecBreakLMConnector(LMConnector connector, string attrName, string value) |
||
3406 | { |
||
3407 | 7f00b26c | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(connector.ModelItemID); |
3408 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3409 | 16584d30 | gaqhf | { |
3410 | 7f00b26c | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[attrName]; |
3411 | if (_LMAAttribute != null) |
||
3412 | 16584d30 | gaqhf | { |
3413 | 7f00b26c | gaqhf | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
3414 | _LMAAttribute.set_Value(value); |
||
3415 | else if (_LMAAttribute.get_Value() != value) |
||
3416 | _LMAAttribute.set_Value(value); |
||
3417 | 16584d30 | gaqhf | } |
3418 | 7f00b26c | gaqhf | |
3419 | _LMModelItem.Commit(); |
||
3420 | 16584d30 | gaqhf | } |
3421 | 7f00b26c | gaqhf | if (_LMModelItem != null) |
3422 | ReleaseCOMObjects(_LMModelItem); |
||
3423 | 16584d30 | gaqhf | } |
3424 | #endregion |
||
3425 | } |
||
3426 | |||
3427 | /// <summary> |
||
3428 | 74752074 | gaqhf | /// Text Modeling - Association일 경우는 Text대신 해당 맵핑된 Symbol로 모델링 |
3429 | /// </summary> |
||
3430 | /// <param name="text"></param> |
||
3431 | cfda1fed | gaqhf | private void TextModeling(Text text) |
3432 | { |
||
3433 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
3434 | 0860c756 | gaqhf | LMConnector connectedLMConnector = null; |
3435 | 7f00b26c | gaqhf | //if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
3436 | if (text.ASSOCIATION) |
||
3437 | 6b298450 | gaqhf | { |
3438 | 7f00b26c | gaqhf | object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
3439 | if (owner.GetType() == typeof(Symbol)) |
||
3440 | ea80efaa | gaqhf | { |
3441 | 7f00b26c | gaqhf | Symbol symbol = owner as Symbol; |
3442 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
3443 | if (_LMSymbol != null) |
||
3444 | ea80efaa | gaqhf | { |
3445 | 7f00b26c | gaqhf | BaseModel.Attribute attribute = symbol.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
3446 | 3734dcc5 | gaqhf | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
3447 | 0860c756 | gaqhf | { |
3448 | 7f00b26c | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
3449 | 0860c756 | gaqhf | |
3450 | if (mapping != null) |
||
3451 | { |
||
3452 | double x = 0; |
||
3453 | double y = 0; |
||
3454 | |||
3455 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
||
3456 | Array array = new double[] { 0, x, y }; |
||
3457 | |||
3458 | 7f00b26c | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
3459 | 0860c756 | gaqhf | if (_LMLabelPersist != null) |
3460 | { |
||
3461 | _LMLabelPersist.Commit(); |
||
3462 | ReleaseCOMObjects(_LMLabelPersist); |
||
3463 | } |
||
3464 | } |
||
3465 | } |
||
3466 | ea80efaa | gaqhf | } |
3467 | } |
||
3468 | 7f00b26c | gaqhf | else if (owner.GetType() == typeof(Line)) |
3469 | ea80efaa | gaqhf | { |
3470 | 7f00b26c | gaqhf | Line line = owner as Line; |
3471 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
3472 | connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y); |
||
3473 | ea80efaa | gaqhf | |
3474 | 7f00b26c | gaqhf | if (connectedLMConnector != null) |
3475 | { |
||
3476 | 83c14a07 | gaqhf | BaseModel.Attribute attribute = line.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
3477 | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3478 | 7f00b26c | gaqhf | { |
3479 | 83c14a07 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
3480 | 7f00b26c | gaqhf | |
3481 | if (mapping != null) |
||
3482 | 83c14a07 | gaqhf | { |
3483 | double x = 0; |
||
3484 | double y = 0; |
||
3485 | b65a7e32 | gaqhf | |
3486 | 83c14a07 | gaqhf | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
3487 | Array array = new double[] { 0, x, y }; |
||
3488 | ea80efaa | gaqhf | |
3489 | 83c14a07 | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
3490 | if (_LMLabelPersist != null) |
||
3491 | { |
||
3492 | _LMLabelPersist.Commit(); |
||
3493 | ReleaseCOMObjects(_LMLabelPersist); |
||
3494 | } |
||
3495 | 7f00b26c | gaqhf | } |
3496 | } |
||
3497 | } |
||
3498 | ea80efaa | gaqhf | } |
3499 | 6b298450 | gaqhf | } |
3500 | 7f00b26c | gaqhf | else |
3501 | 6b298450 | gaqhf | { |
3502 | 7f00b26c | gaqhf | LMItemNote _LMItemNote = null; |
3503 | LMAAttribute _LMAAttribute = null; |
||
3504 | cfda1fed | gaqhf | |
3505 | 7f00b26c | gaqhf | double x = 0; |
3506 | double y = 0; |
||
3507 | double angle = text.ANGLE; |
||
3508 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
||
3509 | |||
3510 | _LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y, Rotation: angle); |
||
3511 | _LMSymbol.Commit(); |
||
3512 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
3513 | _LMItemNote.Commit(); |
||
3514 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
3515 | _LMAAttribute.set_Value(text.VALUE); |
||
3516 | _LMItemNote.Commit(); |
||
3517 | |||
3518 | if (_LMAAttribute != null) |
||
3519 | ReleaseCOMObjects(_LMAAttribute); |
||
3520 | if (_LMItemNote != null) |
||
3521 | ReleaseCOMObjects(_LMItemNote); |
||
3522 | 6b298450 | gaqhf | } |
3523 | 7f00b26c | gaqhf | if (_LMSymbol != null) |
3524 | ReleaseCOMObjects(_LMSymbol); |
||
3525 | f31645b6 | gaqhf | |
3526 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
3527 | cfda1fed | gaqhf | } |
3528 | |||
3529 | 74752074 | gaqhf | /// <summary> |
3530 | /// Note Modeling |
||
3531 | /// </summary> |
||
3532 | /// <param name="note"></param> |
||
3533 | cfda1fed | gaqhf | private void NoteModeling(Note note) |
3534 | { |
||
3535 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
3536 | LMItemNote _LMItemNote = null; |
||
3537 | LMAAttribute _LMAAttribute = null; |
||
3538 | |||
3539 | 7f00b26c | gaqhf | if (string.IsNullOrEmpty(note.OWNER) || note.OWNER == "None") |
3540 | 6b298450 | gaqhf | { |
3541 | 7f00b26c | gaqhf | double x = 0; |
3542 | double y = 0; |
||
3543 | fc0a8c33 | gaqhf | |
3544 | 7f00b26c | gaqhf | CalcLabelLocation(ref x, ref y, note.SPPID.ORIGINAL_X, note.SPPID.ORIGINAL_Y, note.SPPIDLabelLocation, _ETCSetting.NoteLocation); |
3545 | fc0a8c33 | gaqhf | |
3546 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(note.SPPID.MAPPINGNAME, x, y); |
3547 | _LMSymbol.Commit(); |
||
3548 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
3549 | _LMItemNote.Commit(); |
||
3550 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
3551 | _LMAAttribute.set_Value(note.VALUE); |
||
3552 | _LMItemNote.Commit(); |
||
3553 | 6b298450 | gaqhf | } |
3554 | cfda1fed | gaqhf | |
3555 | 7f00b26c | gaqhf | if (_LMAAttribute != null) |
3556 | ReleaseCOMObjects(_LMAAttribute); |
||
3557 | if (_LMItemNote != null) |
||
3558 | ReleaseCOMObjects(_LMItemNote); |
||
3559 | if (_LMSymbol != null) |
||
3560 | ReleaseCOMObjects(_LMSymbol); |
||
3561 | f31645b6 | gaqhf | |
3562 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
3563 | cfda1fed | gaqhf | } |
3564 | |||
3565 | d9794a6c | gaqhf | /// <summary> |
3566 | /// Note Symbol Modeling |
||
3567 | /// </summary> |
||
3568 | /// <param name="symbol"></param> |
||
3569 | 340515a2 | gaqhf | private void NoteSymbolModeling(Symbol symbol) |
3570 | { |
||
3571 | if (symbol.TYPE == "Notes") |
||
3572 | { |
||
3573 | string mappingPath = symbol.SPPID.MAPPINGNAME; |
||
3574 | double x = symbol.SPPID.ORIGINAL_X; |
||
3575 | double y = symbol.SPPID.ORIGINAL_Y; |
||
3576 | int mirror = 0; |
||
3577 | double angle = symbol.ANGLE; |
||
3578 | |||
3579 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
3580 | d0cc9328 | gaqhf | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
3581 | symbol.SPPID.ModelItemID = _LMSymbol.ModelItemID; |
||
3582 | 2fac2754 | gaqhf | |
3583 | 787066e4 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
3584 | |||
3585 | 2fac2754 | gaqhf | InputSymbolAttribute(symbol, symbol.ATTRIBUTES); |
3586 | 340515a2 | gaqhf | } |
3587 | } |
||
3588 | |||
3589 | 74752074 | gaqhf | /// <summary> |
3590 | /// Label의 좌표를 구하는 메서드(ID2 기준의 좌표 -> SPPID 좌표) |
||
3591 | /// </summary> |
||
3592 | /// <param name="x"></param> |
||
3593 | /// <param name="y"></param> |
||
3594 | /// <param name="originX"></param> |
||
3595 | /// <param name="originY"></param> |
||
3596 | /// <param name="SPPIDLabelLocation"></param> |
||
3597 | /// <param name="location"></param> |
||
3598 | b65a7e32 | gaqhf | private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDLabelLocationInfo SPPIDLabelLocation, Location location) |
3599 | { |
||
3600 | if (location == Location.None) |
||
3601 | { |
||
3602 | x = originX; |
||
3603 | y = originY; |
||
3604 | } |
||
3605 | else |
||
3606 | { |
||
3607 | if (location.HasFlag(Location.Center)) |
||
3608 | { |
||
3609 | x = (SPPIDLabelLocation.X1 + SPPIDLabelLocation.X2) / 2; |
||
3610 | y = (SPPIDLabelLocation.Y1 + SPPIDLabelLocation.Y2) / 2; |
||
3611 | } |
||
3612 | |||
3613 | if (location.HasFlag(Location.Left)) |
||
3614 | x = SPPIDLabelLocation.X1; |
||
3615 | else if (location.HasFlag(Location.Right)) |
||
3616 | x = SPPIDLabelLocation.X2; |
||
3617 | |||
3618 | if (location.HasFlag(Location.Down)) |
||
3619 | y = SPPIDLabelLocation.Y1; |
||
3620 | else if (location.HasFlag(Location.Up)) |
||
3621 | y = SPPIDLabelLocation.Y2; |
||
3622 | } |
||
3623 | } |
||
3624 | 5a4b8f32 | gaqhf | |
3625 | 74752074 | gaqhf | /// <summary> |
3626 | 4d2571ab | gaqhf | /// Symbol의 우선순위 Modeling 목록을 가져온다. |
3627 | /// 1. Angle Valve |
||
3628 | /// 2. 3개로 이루어진 Symbol Group |
||
3629 | /// </summary> |
||
3630 | /// <returns></returns> |
||
3631 | private List<Symbol> GetPrioritySymbol() |
||
3632 | { |
||
3633 | DataTable symbolTable = document.SymbolTable; |
||
3634 | // List에 순서대로 쌓는다. |
||
3635 | List<Symbol> symbols = new List<Symbol>(); |
||
3636 | 3734dcc5 | gaqhf | |
3637 | 4d2571ab | gaqhf | // Angle Valve 부터 |
3638 | d9794a6c | gaqhf | foreach (var symbol in document.SYMBOLS.FindAll(x => x.CONNECTORS.FindAll(y => y.Index == 0).Count == 2)) |
3639 | 4d2571ab | gaqhf | { |
3640 | if (!symbols.Contains(symbol)) |
||
3641 | { |
||
3642 | double originX = 0; |
||
3643 | double originY = 0; |
||
3644 | |||
3645 | // ID2 Table에서 Original Point 가져옴. |
||
3646 | 7f00b26c | gaqhf | string OriginalPoint = symbolTable.Select(string.Format("UID = {0}", symbol.DBUID))[0]["OriginalPoint"].ToString(); |
3647 | 4d2571ab | gaqhf | SPPIDUtil.ConvertPointBystring(OriginalPoint, ref originX, ref originY); |
3648 | |||
3649 | SlopeType slopeType1 = SlopeType.None; |
||
3650 | SlopeType slopeType2 = SlopeType.None; |
||
3651 | d9794a6c | gaqhf | foreach (Connector connector in symbol.CONNECTORS.FindAll(x => x.Index == 0)) |
3652 | 4d2571ab | gaqhf | { |
3653 | double connectorX = 0; |
||
3654 | double connectorY = 0; |
||
3655 | SPPIDUtil.ConvertPointBystring(connector.CONNECTPOINT, ref connectorX, ref connectorY); |
||
3656 | if (slopeType1 == SlopeType.None) |
||
3657 | slopeType1 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
||
3658 | else |
||
3659 | slopeType2 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
||
3660 | } |
||
3661 | |||
3662 | if ((slopeType1 == SlopeType.VERTICAL && slopeType2 == SlopeType.HORIZONTAL) || |
||
3663 | (slopeType2 == SlopeType.VERTICAL && slopeType1 == SlopeType.HORIZONTAL)) |
||
3664 | symbols.Add(symbol); |
||
3665 | } |
||
3666 | } |
||
3667 | |||
3668 | d9794a6c | gaqhf | List<string> endSymbolUIDs = new List<string>(); |
3669 | 4d2571ab | gaqhf | // 3개의 Symbol이 뭉쳐 있을 때 |
3670 | foreach (var item in document.SYMBOLS) |
||
3671 | { |
||
3672 | d9794a6c | gaqhf | if (!endSymbolUIDs.Contains(item.UID)) |
3673 | 4d2571ab | gaqhf | { |
3674 | d9794a6c | gaqhf | List<Symbol> group = new List<Symbol>(); |
3675 | SPPIDUtil.FindConnectedSymbolGroup(document, item, group); |
||
3676 | if (group.Count == 3) |
||
3677 | { |
||
3678 | Symbol symbol = SPPIDUtil.FindCenterAtThreeSymbols(document, group); |
||
3679 | if (!symbols.Contains(symbol)) |
||
3680 | symbols.Add(symbol); |
||
3681 | foreach (var groupItem in group) |
||
3682 | if (!endSymbolUIDs.Contains(groupItem.UID)) |
||
3683 | endSymbolUIDs.Add(groupItem.UID); |
||
3684 | } |
||
3685 | 4d2571ab | gaqhf | } |
3686 | } |
||
3687 | |||
3688 | // Connection Point가 3개 이상 |
||
3689 | foreach (var symbol in document.SYMBOLS) |
||
3690 | 3734dcc5 | gaqhf | { |
3691 | 4d2571ab | gaqhf | if (symbol.CONNECTORS.Count > 2 && !symbols.Contains(symbol)) |
3692 | symbols.Add(symbol); |
||
3693 | 3734dcc5 | gaqhf | } |
3694 | |||
3695 | d9794a6c | gaqhf | // 2개이상의 Symbol이 뭉쳐 있을 때 |
3696 | endSymbolUIDs.Clear(); |
||
3697 | foreach (var item in document.SYMBOLS) |
||
3698 | { |
||
3699 | if (!endSymbolUIDs.Contains(item.UID)) |
||
3700 | { |
||
3701 | List<Symbol> group = new List<Symbol>(); |
||
3702 | SPPIDUtil.FindConnectedSymbolGroup(document, item, group); |
||
3703 | if (group.Count != 3 && group.Count > 1) |
||
3704 | { |
||
3705 | if (!symbols.Contains(group[0])) |
||
3706 | symbols.Add(group[0]); |
||
3707 | foreach (var groupItem in group) |
||
3708 | if (!endSymbolUIDs.Contains(groupItem.UID)) |
||
3709 | endSymbolUIDs.Add(groupItem.UID); |
||
3710 | } |
||
3711 | } |
||
3712 | } |
||
3713 | |||
3714 | 4d2571ab | gaqhf | |
3715 | return symbols; |
||
3716 | } |
||
3717 | |||
3718 | /// <summary> |
||
3719 | b2d1c1aa | gaqhf | /// Graphic OID로 해당 Symbol의 크기를 구하여 Zoom |
3720 | /// </summary> |
||
3721 | /// <param name="graphicOID"></param> |
||
3722 | /// <param name="milliseconds"></param> |
||
3723 | private void ZoomObjectByGraphicOID(string graphicOID, int milliseconds = 150) |
||
3724 | { |
||
3725 | if (radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID] != null) |
||
3726 | { |
||
3727 | double minX = 0; |
||
3728 | double minY = 0; |
||
3729 | double maxX = 0; |
||
3730 | double maxY = 0; |
||
3731 | radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID].Range(out minX, out minY, out maxX, out maxY); |
||
3732 | radApp.ActiveWindow.ZoomArea2(minX - 0.007, minY - 0.007, maxX + 0.007, maxY + 0.007, null); |
||
3733 | |||
3734 | Thread.Sleep(milliseconds); |
||
3735 | } |
||
3736 | } |
||
3737 | |||
3738 | /// <summary> |
||
3739 | 74752074 | gaqhf | /// ComObject를 Release |
3740 | /// </summary> |
||
3741 | /// <param name="objVars"></param> |
||
3742 | 5a4b8f32 | gaqhf | public void ReleaseCOMObjects(params object[] objVars) |
3743 | { |
||
3744 | int intNewRefCount = 0; |
||
3745 | foreach (object obj in objVars) |
||
3746 | { |
||
3747 | if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
||
3748 | intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
||
3749 | } |
||
3750 | } |
||
3751 | cfda1fed | gaqhf | } |
3752 | } |