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