hytos / DTI_PID / SPPIDConverter / AutoModeling.cs @ 2fdb56bf
이력 | 보기 | 이력해설 | 다운로드 (93.5 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 | using Llama; |
||
7 | using Plaice; |
||
8 | 8aa6f2db | gaqhf | using Ingr.RAD2D.Interop.RAD2D; |
9 | using Ingr.RAD2D.Internal; |
||
10 | using Ingr.RAD2D.Helper; |
||
11 | cfda1fed | gaqhf | using Converter.BaseModel; |
12 | using Converter.SPPID.Model; |
||
13 | using Converter.SPPID.Properties; |
||
14 | using Converter.SPPID.Util; |
||
15 | using Converter.SPPID.DB; |
||
16 | 5e6ecf05 | gaqhf | using Ingr.RAD2D.MacroControls.CmdCtrl; |
17 | using Ingr.RAD2D; |
||
18 | 5dfb8a24 | gaqhf | using System.Windows; |
19 | cfda1fed | gaqhf | using System.Threading; |
20 | 5dfb8a24 | gaqhf | using System.Drawing; |
21 | cfda1fed | gaqhf | using Microsoft.VisualBasic; |
22 | using Newtonsoft.Json; |
||
23 | |||
24 | ca214bc3 | gaqhf | using DevExpress.XtraSplashScreen; |
25 | cfda1fed | gaqhf | namespace Converter.SPPID |
26 | { |
||
27 | public class AutoModeling |
||
28 | { |
||
29 | 809a7640 | gaqhf | Placement _placement; |
30 | LMADataSource dataSource; |
||
31 | 1ba9c671 | gaqhf | dynamic newDrawing; |
32 | d19ae675 | gaqhf | dynamic application; |
33 | 5e6ecf05 | gaqhf | Ingr.RAD2D.Application radApp; |
34 | cfda1fed | gaqhf | SPPID_Document document; |
35 | b65a7e32 | gaqhf | ETCSetting _ETCSetting; |
36 | f1c9dbaa | gaqhf | |
37 | d5ec4d0f | gaqhf | public string DocumentLabelText { get; set; } |
38 | |||
39 | f31645b6 | gaqhf | int CurrentCount; |
40 | |||
41 | List <Tuple<string, Line, Line>> BranchLines = new List<Tuple<string, Line, Line>>(); |
||
42 | d19ae675 | gaqhf | public AutoModeling(SPPID_Document document, dynamic application, Ingr.RAD2D.Application radApp) |
43 | cfda1fed | gaqhf | { |
44 | this.document = document; |
||
45 | d19ae675 | gaqhf | this.application = application; |
46 | 5e6ecf05 | gaqhf | this.radApp = radApp; |
47 | b65a7e32 | gaqhf | this._ETCSetting = ETCSetting.GetInstance(); |
48 | cfda1fed | gaqhf | } |
49 | |||
50 | b265df51 | gaqhf | private int ClacProgressCount() |
51 | f31645b6 | gaqhf | { |
52 | b265df51 | gaqhf | int EquipCount = 0; |
53 | int SymbolCount = 0; |
||
54 | int LineCount = 0; |
||
55 | int NoteCount = 0; |
||
56 | int TextCount = 0; |
||
57 | int EndBreakCount = 0; |
||
58 | int LineNumberCount = 0; |
||
59 | |||
60 | f31645b6 | gaqhf | EquipCount = document.Equipments.Count; |
61 | SymbolCount = document.SYMBOLS.Count; |
||
62 | SymbolCount = SymbolCount * 3; |
||
63 | |||
64 | foreach (LineNumber lineNumber in document.LINENUMBERS) |
||
65 | foreach (LineRun run in lineNumber.RUNS) |
||
66 | foreach (var item in run.RUNITEMS) |
||
67 | if (item.GetType() == typeof(Line)) |
||
68 | LineCount++; |
||
69 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
70 | foreach (LineRun run in trimLine.RUNS) |
||
71 | foreach (var item in run.RUNITEMS) |
||
72 | if (item.GetType() == typeof(Line)) |
||
73 | LineCount++; |
||
74 | |||
75 | LineCount = LineCount * 2; |
||
76 | NoteCount = document.NOTES.Count; |
||
77 | TextCount = document.TEXTINFOS.Count; |
||
78 | EndBreakCount = document.EndBreaks.Count; |
||
79 | LineNumberCount = document.LINENUMBERS.Count; |
||
80 | LineNumberCount = LineNumberCount * 2; |
||
81 | |||
82 | b265df51 | gaqhf | return EquipCount + SymbolCount + LineCount + NoteCount + TextCount + EndBreakCount; |
83 | f31645b6 | gaqhf | } |
84 | |||
85 | 74752074 | gaqhf | /// <summary> |
86 | /// 도면 단위당 실행되는 메서드 |
||
87 | /// </summary> |
||
88 | 1ba9c671 | gaqhf | public void Run() |
89 | c2fef4ca | gaqhf | { |
90 | 1ba9c671 | gaqhf | try |
91 | c2fef4ca | gaqhf | { |
92 | 1ba9c671 | gaqhf | _placement = new Placement(); |
93 | dataSource = _placement.PIDDataSource; |
||
94 | |||
95 | 0e0edfad | gaqhf | CreateDocument(); |
96 | 1ba9c671 | gaqhf | |
97 | 0e0edfad | gaqhf | if (DocumentCoordinateCorrection()) |
98 | 310aeb31 | gaqhf | { |
99 | b265df51 | gaqhf | int AllCount = ClacProgressCount(); |
100 | 3939eebf | gaqhf | |
101 | 965eb728 | gaqhf | SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
102 | 20972c61 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStep, AllCount); |
103 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
||
104 | 0e0edfad | gaqhf | Thread.Sleep(1000); |
105 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd); |
106 | 0e0edfad | gaqhf | Thread.Sleep(1000); |
107 | 965eb728 | gaqhf | |
108 | d1eac84d | gaqhf | List<List<Symbol>> symbolGroups = SPPIDUtil.GetThreeConnectedSymbolGroup(document); |
109 | foreach (List<Symbol> symbolGroup in symbolGroups) |
||
110 | SymbolModelingByThreeSymbolGroup(symbolGroup); |
||
111 | |||
112 | 3939eebf | gaqhf | // Equipment Modeling |
113 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Equipments Modeling"); |
114 | 3939eebf | gaqhf | foreach (Equipment equipment in document.Equipments) |
115 | EquipmentModeling(equipment); |
||
116 | |||
117 | // LineRun Symbol Modeling |
||
118 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Symbols Modeling"); |
119 | 3939eebf | gaqhf | foreach (LineNumber lineNumber in document.LINENUMBERS) |
120 | foreach (LineRun run in lineNumber.RUNS) |
||
121 | SymbolModelingByRun(run); |
||
122 | // TrimLineRun Symbol Modeling |
||
123 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
124 | foreach (LineRun run in trimLine.RUNS) |
||
125 | SymbolModelingByRun(run); |
||
126 | |||
127 | // LineRun Line Modeling |
||
128 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Lines Modeling"); |
129 | 3939eebf | gaqhf | foreach (LineNumber lineNumber in document.LINENUMBERS) |
130 | foreach (LineRun run in lineNumber.RUNS) |
||
131 | LineModelingByRun(run); |
||
132 | // TrimLineRun Line Modeling |
||
133 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
134 | foreach (LineRun run in trimLine.RUNS) |
||
135 | LineModelingByRun(run); |
||
136 | |||
137 | // Branch Line Modeling |
||
138 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Branch Lines Modeling"); |
139 | 3939eebf | gaqhf | foreach (var item in BranchLines) |
140 | BranchLineModeling(item); |
||
141 | |||
142 | // EndBreak Modeling |
||
143 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "EndBreaks Modeling"); |
144 | 3939eebf | gaqhf | foreach (var item in document.EndBreaks) |
145 | EndBreakModeling(item); |
||
146 | |||
147 | // LineNumber Modeling |
||
148 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "LineNumbers Modeling"); |
149 | 3939eebf | gaqhf | foreach (var item in document.LINENUMBERS) |
150 | LineNumberModeling(item); |
||
151 | |||
152 | // Note Modeling |
||
153 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Notes Modeling"); |
154 | 3939eebf | gaqhf | foreach (var item in document.NOTES) |
155 | NoteModeling(item); |
||
156 | |||
157 | // Text Modeling |
||
158 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Texts Modeling"); |
159 | 3939eebf | gaqhf | foreach (var item in document.TEXTINFOS) |
160 | TextModeling(item); |
||
161 | |||
162 | // LineRun Line Join |
||
163 | 73415441 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Join LineRuns"); |
164 | 3939eebf | gaqhf | foreach (LineNumber lineNumber in document.LINENUMBERS) |
165 | foreach (LineRun run in lineNumber.RUNS) |
||
166 | JoinRunLine(run); |
||
167 | // TrimLineRun Line Join |
||
168 | foreach (TrimLine trimLine in document.TRIMLINES) |
||
169 | foreach (LineRun run in trimLine.RUNS) |
||
170 | JoinRunLine(run); |
||
171 | |||
172 | // Input LineNumber Attribute |
||
173 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Lines Attribute"); |
174 | 3939eebf | gaqhf | foreach (var item in document.LINENUMBERS) |
175 | InputLineNumberAttribute(item); |
||
176 | |||
177 | // Input Symbol Attribute |
||
178 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
179 | 3939eebf | gaqhf | foreach (var item in document.SYMBOLS) |
180 | 73415441 | gaqhf | InputSymbolAttribute(item, item.ATTRIBUTES); |
181 | 3939eebf | gaqhf | |
182 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Labels Modeling"); |
183 | 3939eebf | gaqhf | foreach (var item in document.SYMBOLS) |
184 | 73415441 | gaqhf | LabelSymbolModeling(item); |
185 | f31645b6 | gaqhf | |
186 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, AllCount); |
||
187 | 310aeb31 | gaqhf | } |
188 | 809a7640 | gaqhf | } |
189 | 5e6ecf05 | gaqhf | catch (Exception ex) |
190 | { |
||
191 | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
192 | } |
||
193 | finally |
||
194 | { |
||
195 | 1ba9c671 | gaqhf | application.ActiveWindow.Fit(); |
196 | 3939eebf | gaqhf | |
197 | 1ba9c671 | gaqhf | if (newDrawing != null) |
198 | 3939eebf | gaqhf | { |
199 | radApp.ActiveDocument.SaveOnClose = false; |
||
200 | radApp.ActiveDocument.Save(); |
||
201 | 1ba9c671 | gaqhf | ReleaseCOMObjects(newDrawing); |
202 | 3939eebf | gaqhf | } |
203 | 1ba9c671 | gaqhf | |
204 | 5e6ecf05 | gaqhf | ReleaseCOMObjects(dataSource); |
205 | ReleaseCOMObjects(_placement); |
||
206 | 965eb728 | gaqhf | |
207 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.ClearParent, null); |
208 | 965eb728 | gaqhf | SplashScreenManager.CloseForm(false); |
209 | 5e6ecf05 | gaqhf | } |
210 | 65a1ed4b | gaqhf | } |
211 | |||
212 | 74752074 | gaqhf | /// <summary> |
213 | /// 도면 생성 메서드 |
||
214 | /// </summary> |
||
215 | 0e0edfad | gaqhf | private void CreateDocument() |
216 | { |
||
217 | newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName); |
||
218 | application.ActiveWindow.Fit(); |
||
219 | Thread.Sleep(1000); |
||
220 | application.ActiveWindow.Zoom = 2000; |
||
221 | Thread.Sleep(2000); |
||
222 | } |
||
223 | |||
224 | 74752074 | gaqhf | /// <summary> |
225 | /// 도면 크기 구하는 메서드 |
||
226 | /// </summary> |
||
227 | /// <returns></returns> |
||
228 | 0e0edfad | gaqhf | private bool DocumentCoordinateCorrection() |
229 | { |
||
230 | double maxX = 0; |
||
231 | double maxY = 0; |
||
232 | foreach (object drawingObj in radApp.ActiveDocument.ActiveSheet.DrawingObjects) |
||
233 | { |
||
234 | Ingr.RAD2D.SmartFrame2d smartFrame2d = drawingObj as Ingr.RAD2D.SmartFrame2d; |
||
235 | if (smartFrame2d != null) |
||
236 | { |
||
237 | double x1 = 0; |
||
238 | double x2 = 0; |
||
239 | double y1 = 0; |
||
240 | double y2 = 0; |
||
241 | smartFrame2d.Range(out x1, out y1, out x2, out y2); |
||
242 | maxX = Math.Max(x2, maxX); |
||
243 | maxY = Math.Max(y2, maxY); |
||
244 | } |
||
245 | } |
||
246 | if (maxX != 0 && maxY != 0) |
||
247 | { |
||
248 | document.SetSPPIDLocation(maxX, maxY); |
||
249 | return true; |
||
250 | } |
||
251 | else |
||
252 | return false; |
||
253 | } |
||
254 | |||
255 | 74752074 | gaqhf | /// <summary> |
256 | /// 라인을 Run 단위로 모델링하는 진입 메서드 |
||
257 | /// </summary> |
||
258 | /// <param name="run"></param> |
||
259 | 8aa6f2db | gaqhf | private void LineModelingByRun(LineRun run) |
260 | 809a7640 | gaqhf | { |
261 | Line prevLine = null; |
||
262 | List<Line> lines = new List<Line>(); |
||
263 | foreach (var item in run.RUNITEMS) |
||
264 | { |
||
265 | // Line일 경우 |
||
266 | if (item.GetType() == typeof(Line)) |
||
267 | { |
||
268 | Line line = item as Line; |
||
269 | if (prevLine == null) |
||
270 | lines.Add(line); |
||
271 | else if (prevLine != null) |
||
272 | { |
||
273 | if (prevLine.SPPID.MAPPINGNAME == line.SPPID.MAPPINGNAME) |
||
274 | lines.Add(line); |
||
275 | else |
||
276 | f1c9dbaa | gaqhf | { |
277 | f2baa6a3 | gaqhf | if (lines.Count > 0) |
278 | { |
||
279 | LineModeling(lines); |
||
280 | lines.Clear(); |
||
281 | } |
||
282 | 809a7640 | gaqhf | lines.Add(line); |
283 | 5dfb8a24 | gaqhf | } |
284 | } |
||
285 | |||
286 | 809a7640 | gaqhf | prevLine = line; |
287 | f31645b6 | gaqhf | |
288 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
289 | 809a7640 | gaqhf | } |
290 | // Symbol 일 경우 |
||
291 | else if (item.GetType() == typeof(Symbol)) |
||
292 | { |
||
293 | f1c9dbaa | gaqhf | if (lines.Count > 0) |
294 | 809a7640 | gaqhf | { |
295 | f1c9dbaa | gaqhf | LineModeling(lines); |
296 | 809a7640 | gaqhf | lines.Clear(); |
297 | } |
||
298 | 5dfb8a24 | gaqhf | } |
299 | } |
||
300 | |||
301 | 809a7640 | gaqhf | if (lines.Count > 0) |
302 | LineModeling(lines); |
||
303 | } |
||
304 | 5dfb8a24 | gaqhf | |
305 | 74752074 | gaqhf | /// <summary> |
306 | /// 심볼을 Run 단위로 모델링하는 진입 메서드 |
||
307 | /// </summary> |
||
308 | /// <param name="run"></param> |
||
309 | 8aa6f2db | gaqhf | private void SymbolModelingByRun(LineRun run) |
310 | 809a7640 | gaqhf | { |
311 | // 양끝 Symbol 검사 후 Line이 나올때까지만 Symbol Modeling |
||
312 | if (run.RUNITEMS.Count > 0) |
||
313 | { |
||
314 | if (run.RUNITEMS[0].GetType() == typeof(Symbol)) |
||
315 | SymbolModelingByRunStart(run.RUNITEMS[0] as Symbol, run); |
||
316 | |||
317 | if (run.RUNITEMS[run.RUNITEMS.Count - 1].GetType() == typeof(Symbol)) |
||
318 | SymbolModelingByRunEnd(run.RUNITEMS[run.RUNITEMS.Count - 1] as Symbol, run); |
||
319 | } |
||
320 | |||
321 | Symbol prevSymbol = null; |
||
322 | Symbol targetSymbol = null; |
||
323 | foreach (var item in run.RUNITEMS) |
||
324 | { |
||
325 | if (item.GetType() == typeof(Symbol)) |
||
326 | { |
||
327 | Symbol symbol = item as Symbol; |
||
328 | SymbolModeling(symbol, targetSymbol, prevSymbol); |
||
329 | prevSymbol = symbol; |
||
330 | targetSymbol = symbol; |
||
331 | } |
||
332 | else |
||
333 | { |
||
334 | targetSymbol = null; |
||
335 | } |
||
336 | } |
||
337 | } |
||
338 | |||
339 | 74752074 | gaqhf | /// <summary> |
340 | /// Run에 있는 심볼을 모델링하는데 기준이 Run의 시작점 |
||
341 | /// </summary> |
||
342 | /// <param name="symbol"></param> |
||
343 | /// <param name="run"></param> |
||
344 | 8aa6f2db | gaqhf | private void SymbolModelingByRunStart(Symbol symbol, LineRun run) |
345 | 809a7640 | gaqhf | { |
346 | foreach (var connector in symbol.CONNECTORS) |
||
347 | { |
||
348 | object targetItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
349 | if (targetItem != null && |
||
350 | (targetItem.GetType() == typeof(Symbol) || targetItem.GetType() == typeof(Equipment)) && |
||
351 | 74752074 | gaqhf | !IsSameLineRun(symbol, targetItem)) |
352 | 809a7640 | gaqhf | { |
353 | SymbolModeling(symbol, targetItem as Symbol, null); |
||
354 | for (int i = 1; i < run.RUNITEMS.Count; i++) |
||
355 | { |
||
356 | object item = run.RUNITEMS[i]; |
||
357 | if (item.GetType() == typeof(Symbol)) |
||
358 | SymbolModeling(item as Symbol, run.RUNITEMS[i - 1] as Symbol, null); |
||
359 | else |
||
360 | break; |
||
361 | } |
||
362 | break; |
||
363 | } |
||
364 | } |
||
365 | |||
366 | |||
367 | } |
||
368 | |||
369 | 74752074 | gaqhf | /// <summary> |
370 | /// Run에 있는 심볼을 모델링하는데 기준이 Run의 끝점 |
||
371 | /// </summary> |
||
372 | /// <param name="symbol"></param> |
||
373 | /// <param name="run"></param> |
||
374 | 8aa6f2db | gaqhf | private void SymbolModelingByRunEnd(Symbol symbol, LineRun run) |
375 | 809a7640 | gaqhf | { |
376 | foreach (var connector in symbol.CONNECTORS) |
||
377 | { |
||
378 | object targetItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
379 | if (targetItem != null && |
||
380 | (targetItem.GetType() == typeof(Symbol) || targetItem.GetType() == typeof(Equipment)) && |
||
381 | 74752074 | gaqhf | !IsSameLineRun(symbol, targetItem)) |
382 | 809a7640 | gaqhf | { |
383 | SymbolModeling(symbol, targetItem as Symbol, null); |
||
384 | for (int i = run.RUNITEMS.Count - 2; i >= 0; i--) |
||
385 | { |
||
386 | object item = run.RUNITEMS[i]; |
||
387 | if (item.GetType() == typeof(Symbol)) |
||
388 | SymbolModeling(item as Symbol, run.RUNITEMS[i + 1] as Symbol, null); |
||
389 | else |
||
390 | break; |
||
391 | } |
||
392 | break; |
||
393 | } |
||
394 | } |
||
395 | 5dfb8a24 | gaqhf | } |
396 | cfda1fed | gaqhf | |
397 | 74752074 | gaqhf | /// <summary> |
398 | /// 심볼을 실제로 Modeling 메서드 |
||
399 | /// </summary> |
||
400 | /// <param name="symbol"></param> |
||
401 | /// <param name="targetSymbol"></param> |
||
402 | /// <param name="prevSymbol"></param> |
||
403 | 809a7640 | gaqhf | private void SymbolModeling(Symbol symbol, Symbol targetSymbol, Symbol prevSymbol) |
404 | { |
||
405 | 73415441 | gaqhf | // OWNERSYMBOL Attribute, 값을 가지고 있을 경우 |
406 | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(attr => attr.ATTRIBUTE == "OWNERSYMBOL"); |
||
407 | if (itemAttribute != null && string.IsNullOrEmpty(itemAttribute.VALUE) && itemAttribute.VALUE != "None") |
||
408 | c3d2e266 | gaqhf | return; |
409 | 73415441 | gaqhf | // 이미 모델링 됐을 경우 |
410 | else if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
411 | 809a7640 | gaqhf | return; |
412 | |||
413 | LMSymbol _LMSymbol = null; |
||
414 | |||
415 | string mappingPath = symbol.SPPID.MAPPINGNAME; |
||
416 | double x = symbol.SPPID.ORIGINAL_X; |
||
417 | double y = symbol.SPPID.ORIGINAL_Y; |
||
418 | int mirror = 0; |
||
419 | double angle = symbol.ANGLE; |
||
420 | 20972c61 | gaqhf | |
421 | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
||
422 | |||
423 | 73415441 | gaqhf | // OPC 일경우 180도 일때 Mirror |
424 | c2fef4ca | gaqhf | if (mappingPath.Contains("Piping OPC's") && angle == Math.PI) |
425 | mirror = 1; |
||
426 | 809a7640 | gaqhf | |
427 | if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId)) |
||
428 | { |
||
429 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
430 | 2fdb56bf | gaqhf | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, symbol.UID, targetSymbol); |
431 | if (connector != null) |
||
432 | GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y); |
||
433 | |||
434 | 809a7640 | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
435 | ReleaseCOMObjects(_TargetItem); |
||
436 | } |
||
437 | else if (prevSymbol != null) |
||
438 | { |
||
439 | LMSymbol _PrevSymbol = dataSource.GetSymbol(prevSymbol.SPPID.RepresentationId); |
||
440 | SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y); |
||
441 | double prevX = _PrevSymbol.get_XCoordinate(); |
||
442 | double prevY = _PrevSymbol.get_YCoordinate(); |
||
443 | 06b40010 | gaqhf | //if (slopeType == SlopeType.HORIZONTAL) |
444 | // y = prevY; |
||
445 | //else if (slopeType == SlopeType.VERTICAL) |
||
446 | // x = prevX; |
||
447 | ReleaseCOMObjects(_PrevSymbol); |
||
448 | 809a7640 | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
449 | } |
||
450 | else |
||
451 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
452 | |||
453 | |||
454 | if (_LMSymbol != null) |
||
455 | { |
||
456 | _LMSymbol.Commit(); |
||
457 | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
458 | 20972c61 | gaqhf | symbol.SPPID.GraphicOID = _LMSymbol.get_GraphicOID(); |
459 | ac78b508 | gaqhf | |
460 | 4b4dbca9 | gaqhf | foreach (var item in symbol.ChildSymbols) |
461 | CreateChildSymbol(item, _LMSymbol); |
||
462 | 809a7640 | gaqhf | } |
463 | |||
464 | ReleaseCOMObjects(_LMSymbol); |
||
465 | f31645b6 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
466 | 809a7640 | gaqhf | } |
467 | |||
468 | d1eac84d | gaqhf | /// <summary> |
469 | /// ID2의 Symbol Width와 Height를 비교해서 상대적인 SPPID Connector좌표를 가져온다. |
||
470 | /// </summary> |
||
471 | /// <param name="targetConnector"></param> |
||
472 | /// <param name="targetSymbol"></param> |
||
473 | /// <param name="x"></param> |
||
474 | /// <param name="y"></param> |
||
475 | private void GetTargetSymbolConnectorPoint(Connector targetConnector, Symbol targetSymbol, ref double x, ref double y) |
||
476 | { |
||
477 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
478 | 2fdb56bf | gaqhf | |
479 | double[] range = null; |
||
480 | d1eac84d | gaqhf | List<double[]> points = new List<double[]>(); |
481 | 2fdb56bf | gaqhf | GetSPPIDSymbolRangeAndConnectionPoints(targetSymbol, ref range, points); |
482 | double x1 = range[0]; |
||
483 | double y1 = range[1]; |
||
484 | double x2 = range[2]; |
||
485 | double y2 = range[3]; |
||
486 | d1eac84d | gaqhf | |
487 | // Origin 기준 Connector의 위치차이 |
||
488 | double sceneX = 0; |
||
489 | double sceneY = 0; |
||
490 | SPPIDUtil.ConvertPointBystring(targetConnector.SCENECONNECTPOINT, ref sceneX, ref sceneY); |
||
491 | double originX = 0; |
||
492 | double originY = 0; |
||
493 | SPPIDUtil.ConvertPointBystring(targetSymbol.ORIGINALPOINT, ref originX, ref originY); |
||
494 | double gapX = originX - sceneX; |
||
495 | double gapY = originY - sceneY; |
||
496 | |||
497 | // SPPID Symbol과 ID2 심볼의 크기 차이 |
||
498 | double sizeWidth = 0; |
||
499 | double sizeHeight = 0; |
||
500 | SPPIDUtil.ConvertPointBystring(targetSymbol.SIZE, ref sizeWidth, ref sizeHeight); |
||
501 | double percentX = (x2 - x1) / sizeWidth; |
||
502 | double percentY = (y2 - y1) / sizeHeight; |
||
503 | |||
504 | double SPPIDgapX = gapX * percentX; |
||
505 | double SPPIDgapY = gapY * percentY; |
||
506 | |||
507 | double[] SPPIDOriginPoint = new double[] { _TargetItem.get_XCoordinate() - SPPIDgapX, _TargetItem.get_YCoordinate() + SPPIDgapY }; |
||
508 | double distance = double.MaxValue; |
||
509 | double[] resultPoint; |
||
510 | foreach (var point in points) |
||
511 | { |
||
512 | double result = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], SPPIDOriginPoint[0], SPPIDOriginPoint[1]); |
||
513 | if (distance > result) |
||
514 | { |
||
515 | distance = result; |
||
516 | resultPoint = point; |
||
517 | x = point[0]; |
||
518 | y = point[1]; |
||
519 | } |
||
520 | } |
||
521 | 2fdb56bf | gaqhf | |
522 | ReleaseCOMObjects(_TargetItem); |
||
523 | } |
||
524 | |||
525 | /// <summary> |
||
526 | /// SPPID Symbol의 Range를 구한다. |
||
527 | /// </summary> |
||
528 | /// <param name="symbol"></param> |
||
529 | /// <param name="range"></param> |
||
530 | private void GetSPPIDSymbolRangeAndConnectionPoints(Symbol symbol, ref double[] range, List<double[]> points) |
||
531 | { |
||
532 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
533 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
534 | double x1 = 0; |
||
535 | double y1 = 0; |
||
536 | double x2 = 0; |
||
537 | double y2 = 0; |
||
538 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
539 | range = new double[] { x1, y1, x2, y2 }; |
||
540 | |||
541 | for (int i = 1; i < int.MaxValue; i++) |
||
542 | { |
||
543 | double connX = 0; |
||
544 | double connY = 0; |
||
545 | if (_placement.PIDConnectPointLocation(_TargetItem, i, ref connX, ref connY)) |
||
546 | points.Add(new double[] { connX, connY }); |
||
547 | else |
||
548 | break; |
||
549 | } |
||
550 | |||
551 | foreach (var childSymbol in symbol.ChildSymbols) |
||
552 | GetSPPIDChildSymbolRange(childSymbol, ref range, points); |
||
553 | |||
554 | ReleaseCOMObjects(_TargetItem); |
||
555 | } |
||
556 | |||
557 | /// <summary> |
||
558 | /// Child Modeling 된 Symbol의 Range를 구한다. |
||
559 | /// </summary> |
||
560 | /// <param name="childSymbol"></param> |
||
561 | /// <param name="range"></param> |
||
562 | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range, List<double[]> points) |
||
563 | { |
||
564 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
565 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
||
566 | double x1 = 0; |
||
567 | double y1 = 0; |
||
568 | double x2 = 0; |
||
569 | double y2 = 0; |
||
570 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
571 | range[0] = Math.Min(range[0], x1); |
||
572 | range[1] = Math.Min(range[1], y1); |
||
573 | range[2] = Math.Max(range[2], x2); |
||
574 | range[3] = Math.Max(range[3], y2); |
||
575 | |||
576 | for (int i = 1; i < int.MaxValue; i++) |
||
577 | { |
||
578 | double connX = 0; |
||
579 | double connY = 0; |
||
580 | if (_placement.PIDConnectPointLocation(_ChildSymbol, i, ref connX, ref connY)) |
||
581 | points.Add(new double[] { connX, connY }); |
||
582 | else |
||
583 | break; |
||
584 | } |
||
585 | |||
586 | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
||
587 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range, points); |
||
588 | |||
589 | ReleaseCOMObjects(_ChildSymbol); |
||
590 | d1eac84d | gaqhf | } |
591 | |||
592 | /// <summary> |
||
593 | /// Label Symbol Modeling |
||
594 | /// </summary> |
||
595 | /// <param name="symbol"></param> |
||
596 | 73415441 | gaqhf | private void LabelSymbolModeling(Symbol symbol) |
597 | { |
||
598 | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
||
599 | if (itemAttribute == null || string.IsNullOrEmpty(itemAttribute.VALUE)) |
||
600 | return; |
||
601 | |||
602 | Array points = new double[] { 0, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y }; |
||
603 | |||
604 | string symbolUID = itemAttribute.VALUE; |
||
605 | object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
||
606 | if (targetItem != null) |
||
607 | { |
||
608 | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
||
609 | string sRep = null; |
||
610 | if (targetItem.GetType() == typeof(Symbol)) |
||
611 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
612 | else if (targetItem.GetType() == typeof(Equipment)) |
||
613 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
614 | |||
615 | if (!string.IsNullOrEmpty(sRep)) |
||
616 | { |
||
617 | // LEADER Line 검사 |
||
618 | bool leaderLine = false; |
||
619 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
620 | if (symbolMapping != null) |
||
621 | leaderLine = symbolMapping.LEADERLINE; |
||
622 | |||
623 | // Target Symbol Item 가져오고 Label Modeling |
||
624 | LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
||
625 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
626 | |||
627 | // Target Item에 Label의 Attribute Input |
||
628 | InputSymbolAttribute(targetItem, symbol.ATTRIBUTES); |
||
629 | |||
630 | //Leader 선 센터로 |
||
631 | string OID = _LMLabelPresist.get_GraphicOID(); |
||
632 | DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
||
633 | if (dependency != null) |
||
634 | { |
||
635 | bool result = false; |
||
636 | foreach (var attributes in dependency.AttributeSets) |
||
637 | { |
||
638 | foreach (var attribute in attributes) |
||
639 | { |
||
640 | string name = attribute.Name; |
||
641 | string value = attribute.GetValue().ToString(); |
||
642 | if (name == "DrawingItemType" && value == "LabelPersist") |
||
643 | { |
||
644 | foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
||
645 | { |
||
646 | if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
||
647 | { |
||
648 | Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
||
649 | double prevX = _TargetItem.get_XCoordinate(); |
||
650 | double prevY = _TargetItem.get_YCoordinate(); |
||
651 | lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
||
652 | lineString2D.RemoveVertex(lineString2D.VertexCount); |
||
653 | result = true; |
||
654 | break; |
||
655 | } |
||
656 | } |
||
657 | } |
||
658 | |||
659 | if (result) |
||
660 | break; |
||
661 | } |
||
662 | |||
663 | if (result) |
||
664 | break; |
||
665 | } |
||
666 | } |
||
667 | |||
668 | _LMLabelPresist.Commit(); |
||
669 | ReleaseCOMObjects(_TargetItem); |
||
670 | ReleaseCOMObjects(_LMLabelPresist); |
||
671 | } |
||
672 | } |
||
673 | |||
674 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
675 | } |
||
676 | |||
677 | 74752074 | gaqhf | /// <summary> |
678 | /// Equipment를 실제로 Modeling 메서드 |
||
679 | /// </summary> |
||
680 | /// <param name="equipment"></param> |
||
681 | b9e9f4c8 | gaqhf | private void EquipmentModeling(Equipment equipment) |
682 | { |
||
683 | if (!string.IsNullOrEmpty(equipment.SPPID.RepresentationId)) |
||
684 | return; |
||
685 | |||
686 | LMSymbol _LMSymbol = null; |
||
687 | LMSymbol targetItem = null; |
||
688 | string mappingPath = equipment.SPPID.MAPPINGNAME; |
||
689 | double x = equipment.SPPID.ORIGINAL_X; |
||
690 | double y = equipment.SPPID.ORIGINAL_Y; |
||
691 | int mirror = 0; |
||
692 | double angle = equipment.ANGLE; |
||
693 | |||
694 | 20972c61 | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
695 | |||
696 | b9e9f4c8 | gaqhf | Connector connector = equipment.CONNECTORS.Find(conn => !string.IsNullOrEmpty(conn.CONNECTEDITEM) && conn.CONNECTEDITEM != "None"); |
697 | if (connector != null) |
||
698 | { |
||
699 | Equipment connEquipment = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Equipment; |
||
700 | if (connEquipment != null) |
||
701 | { |
||
702 | if (string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
703 | EquipmentModeling(connEquipment); |
||
704 | |||
705 | if (!string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
706 | { |
||
707 | targetItem = dataSource.GetSymbol(connEquipment.SPPID.RepresentationId); |
||
708 | if (targetItem != null) |
||
709 | { |
||
710 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: targetItem); |
||
711 | } |
||
712 | else |
||
713 | { |
||
714 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
715 | } |
||
716 | } |
||
717 | else |
||
718 | { |
||
719 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
720 | } |
||
721 | } |
||
722 | else |
||
723 | { |
||
724 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
725 | } |
||
726 | } |
||
727 | else |
||
728 | { |
||
729 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
730 | } |
||
731 | |||
732 | if (_LMSymbol != null) |
||
733 | { |
||
734 | _LMSymbol.Commit(); |
||
735 | equipment.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
736 | 20972c61 | gaqhf | equipment.SPPID.GraphicOID = _LMSymbol.get_GraphicOID(); |
737 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
738 | } |
||
739 | |||
740 | if (targetItem != null) |
||
741 | { |
||
742 | ReleaseCOMObjects(targetItem); |
||
743 | } |
||
744 | |||
745 | ReleaseCOMObjects(_LMSymbol); |
||
746 | f31645b6 | gaqhf | |
747 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
748 | b9e9f4c8 | gaqhf | } |
749 | |||
750 | 74752074 | gaqhf | /// <summary> |
751 | d1eac84d | gaqhf | /// 3개의 Symbol이 붙어있을경우 CenterSymbol을 Grid기준으로 맞추기 위해서 모델링 |
752 | /// </summary> |
||
753 | /// <param name="group"></param> |
||
754 | private void SymbolModelingByThreeSymbolGroup(List<Symbol> group) |
||
755 | { |
||
756 | // Group의 가운데 찾기 |
||
757 | Symbol symbol1 = null; |
||
758 | Symbol symbol2 = null; |
||
759 | Symbol centerSymbol = null; |
||
760 | foreach (var symbol in group) |
||
761 | { |
||
762 | int count = 0; |
||
763 | foreach (var connector in symbol.CONNECTORS) |
||
764 | { |
||
765 | object item = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
766 | if (item != null && item.GetType() == typeof(Symbol)) |
||
767 | count++; |
||
768 | } |
||
769 | |||
770 | // Center Symbol |
||
771 | if (count == 2) |
||
772 | { |
||
773 | SymbolModeling(symbol, null, null); |
||
774 | centerSymbol = symbol; |
||
775 | } |
||
776 | else if (symbol1 == null) |
||
777 | symbol1 = symbol; |
||
778 | else |
||
779 | symbol2 = symbol; |
||
780 | } |
||
781 | |||
782 | SymbolModeling(symbol1, centerSymbol, null); |
||
783 | SymbolModeling(symbol2, centerSymbol, null); |
||
784 | } |
||
785 | |||
786 | /// <summary> |
||
787 | 74752074 | gaqhf | /// 심볼을 실제로 Modeling할때 ChildSymbol이 있다면 Modeling하는 메서드 |
788 | /// </summary> |
||
789 | /// <param name="childSymbol"></param> |
||
790 | /// <param name="parentSymbol"></param> |
||
791 | 4b4dbca9 | gaqhf | private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol) |
792 | ac78b508 | gaqhf | { |
793 | 4b4dbca9 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()]; |
794 | double x1 = 0; |
||
795 | double x2 = 0; |
||
796 | double y1 = 0; |
||
797 | double y2 = 0; |
||
798 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
799 | |||
800 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, (x1 + x2) / 2, (y1 + y2) / 2, TargetItem: parentSymbol); |
||
801 | if (_LMSymbol != null) |
||
802 | { |
||
803 | childSymbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
804 | foreach (var item in childSymbol.ChildSymbols) |
||
805 | CreateChildSymbol(item, _LMSymbol); |
||
806 | } |
||
807 | |||
808 | ac78b508 | gaqhf | |
809 | ReleaseCOMObjects(_LMSymbol); |
||
810 | } |
||
811 | |||
812 | 74752074 | gaqhf | /// <summary> |
813 | /// item이 TargetItem과 같은 LineRun에 있는지 검사 |
||
814 | /// </summary> |
||
815 | /// <param name="item"></param> |
||
816 | /// <param name="targetItem"></param> |
||
817 | /// <returns></returns> |
||
818 | private bool IsSameLineRun(object item, object targetItem) |
||
819 | 809a7640 | gaqhf | { |
820 | foreach (var lineNumber in document.LINENUMBERS) |
||
821 | { |
||
822 | foreach (var run in lineNumber.RUNS) |
||
823 | { |
||
824 | foreach (var runItem in run.RUNITEMS) |
||
825 | { |
||
826 | if (runItem == item) |
||
827 | { |
||
828 | foreach (var findItem in run.RUNITEMS) |
||
829 | { |
||
830 | if (findItem == targetItem) |
||
831 | { |
||
832 | return true; |
||
833 | } |
||
834 | } |
||
835 | |||
836 | return false; |
||
837 | |||
838 | } |
||
839 | } |
||
840 | } |
||
841 | } |
||
842 | |||
843 | return false; |
||
844 | } |
||
845 | |||
846 | 74752074 | gaqhf | /// <summary> |
847 | /// Line을 실제로 모델링하는 메서드 |
||
848 | /// </summary> |
||
849 | /// <param name="lines"></param> |
||
850 | 1b261371 | gaqhf | private void LineModeling(List<Line> lines) |
851 | { |
||
852 | 335b7a24 | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
853 | 1b261371 | gaqhf | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
854 | f1c9dbaa | gaqhf | LMSymbol _LMSymbol1 = null; |
855 | LMSymbol _LMSymbol2 = null; |
||
856 | 5e6ecf05 | gaqhf | Dictionary<LMConnector, List<double[]>> connectorVertices1 = new Dictionary<LMConnector, List<double[]>>(); |
857 | LMConnector targetConnector1 = null; |
||
858 | Dictionary<LMConnector, List<double[]>> connectorVertices2 = new Dictionary<LMConnector, List<double[]>>(); |
||
859 | LMConnector targetConnector2 = null; |
||
860 | 335b7a24 | gaqhf | |
861 | Line startBranchLine = null; |
||
862 | Line endBranchLine = null; |
||
863 | |||
864 | 1b261371 | gaqhf | for (int i = 0; i < lines.Count; i++) |
865 | { |
||
866 | Line line = lines[i]; |
||
867 | f1c9dbaa | gaqhf | if (i == 0 || i + 1 != lines.Count) |
868 | { |
||
869 | 809a7640 | gaqhf | // 시작점에 연결된 Symbol 찾기 |
870 | f1c9dbaa | gaqhf | object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[0].CONNECTEDITEM); |
871 | if (connItem != null && connItem.GetType() == typeof(Symbol)) |
||
872 | { |
||
873 | 2fdb56bf | gaqhf | Symbol symbol1 = connItem as Symbol; |
874 | _LMSymbol1 = GetTargetSymbol(symbol1, line); |
||
875 | f1c9dbaa | gaqhf | if (_LMSymbol1 != null) |
876 | 2fdb56bf | gaqhf | { |
877 | double x = line.SPPID.START_X; |
||
878 | double y = line.SPPID.START_Y; |
||
879 | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, line.UID, symbol1); |
||
880 | if (connector != null) |
||
881 | { |
||
882 | GetTargetSymbolConnectorPoint(connector, symbol1, ref x, ref y); |
||
883 | line.SPPID.START_X = x; |
||
884 | line.SPPID.START_Y = y; |
||
885 | } |
||
886 | |||
887 | placeRunInputs.AddSymbolTarget(_LMSymbol1, x, y); |
||
888 | } |
||
889 | f1c9dbaa | gaqhf | else |
890 | placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
||
891 | } |
||
892 | 335b7a24 | gaqhf | else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
893 | 5e6ecf05 | gaqhf | { |
894 | connectorVertices1 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId); |
||
895 | 56bc67e1 | gaqhf | targetConnector1 = FindTargetLMConnector(connectorVertices1, line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
896 | 5e6ecf05 | gaqhf | |
897 | if (targetConnector1 != null) |
||
898 | placeRunInputs.AddConnectorTarget(targetConnector1, line.SPPID.START_X, line.SPPID.START_Y); |
||
899 | else |
||
900 | 335b7a24 | gaqhf | { |
901 | startBranchLine = connItem as Line; |
||
902 | 5e6ecf05 | gaqhf | placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
903 | 335b7a24 | gaqhf | } |
904 | 5e6ecf05 | gaqhf | } |
905 | f1c9dbaa | gaqhf | else |
906 | placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
||
907 | } |
||
908 | if (i + 1 == lines.Count) |
||
909 | { |
||
910 | 809a7640 | gaqhf | // 끝점에 연결된 Symbol 찾기 |
911 | f1c9dbaa | gaqhf | object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[1].CONNECTEDITEM); |
912 | 5e6ecf05 | gaqhf | |
913 | if (i != 0) |
||
914 | placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
||
915 | |||
916 | f1c9dbaa | gaqhf | if (connItem != null && connItem.GetType() == typeof(Symbol)) |
917 | { |
||
918 | 2fdb56bf | gaqhf | Symbol symbol2 = connItem as Symbol; |
919 | f2baa6a3 | gaqhf | _LMSymbol2 = GetTargetSymbol(connItem as Symbol, line); |
920 | f1c9dbaa | gaqhf | if (_LMSymbol2 != null) |
921 | 2fdb56bf | gaqhf | { |
922 | double x = line.SPPID.END_X; |
||
923 | double y = line.SPPID.END_Y; |
||
924 | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, line.UID, symbol2); |
||
925 | if (connector != null) |
||
926 | { |
||
927 | GetTargetSymbolConnectorPoint(connector, symbol2, ref x, ref y); |
||
928 | line.SPPID.END_X = x; |
||
929 | line.SPPID.END_Y = y; |
||
930 | } |
||
931 | |||
932 | |||
933 | placeRunInputs.AddSymbolTarget(_LMSymbol2, x, y); |
||
934 | } |
||
935 | f1c9dbaa | gaqhf | else |
936 | placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
||
937 | |||
938 | } |
||
939 | 335b7a24 | gaqhf | else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
940 | 5e6ecf05 | gaqhf | { |
941 | connectorVertices2 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId); |
||
942 | 56bc67e1 | gaqhf | targetConnector2 = FindTargetLMConnector(connectorVertices2, line.SPPID.END_X, line.SPPID.END_Y, line.SPPID.START_X, line.SPPID.START_Y); |
943 | 5e6ecf05 | gaqhf | |
944 | if (targetConnector2 != null) |
||
945 | placeRunInputs.AddConnectorTarget(targetConnector2, line.SPPID.END_X, line.SPPID.END_Y); |
||
946 | else |
||
947 | 335b7a24 | gaqhf | { |
948 | endBranchLine = connItem as Line; |
||
949 | 5e6ecf05 | gaqhf | placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
950 | 335b7a24 | gaqhf | } |
951 | 5e6ecf05 | gaqhf | } |
952 | f1c9dbaa | gaqhf | else |
953 | { |
||
954 | placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
||
955 | } |
||
956 | } |
||
957 | } |
||
958 | |||
959 | LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
960 | 335b7a24 | gaqhf | |
961 | f1c9dbaa | gaqhf | if (_lMConnector != null) |
962 | { |
||
963 | foreach (var line in lines) |
||
964 | 5e6ecf05 | gaqhf | line.SPPID.ModelItemId = _lMConnector.ModelItemID; |
965 | f1c9dbaa | gaqhf | _lMConnector.Commit(); |
966 | 335b7a24 | gaqhf | if (startBranchLine != null || endBranchLine != null) |
967 | { |
||
968 | 3165c259 | gaqhf | BranchLines.Add(new Tuple<string, Line, Line>(_lMConnector.ModelItemID, startBranchLine, endBranchLine)); |
969 | 335b7a24 | gaqhf | } |
970 | 1b261371 | gaqhf | } |
971 | 5e6ecf05 | gaqhf | |
972 | 1b261371 | gaqhf | |
973 | f1c9dbaa | gaqhf | if (_LMSymbol1 != null) |
974 | ReleaseCOMObjects(_LMSymbol1); |
||
975 | if (_LMSymbol2 != null) |
||
976 | ReleaseCOMObjects(_LMSymbol2); |
||
977 | 5e6ecf05 | gaqhf | if (targetConnector1 != null) |
978 | ReleaseCOMObjects(targetConnector1); |
||
979 | if (targetConnector2 != null) |
||
980 | ReleaseCOMObjects(targetConnector2); |
||
981 | foreach (var item in connectorVertices1) |
||
982 | ReleaseCOMObjects(item.Key); |
||
983 | foreach (var item in connectorVertices2) |
||
984 | ReleaseCOMObjects(item.Key); |
||
985 | 1b261371 | gaqhf | |
986 | f1c9dbaa | gaqhf | ReleaseCOMObjects(_lMConnector); |
987 | 1b261371 | gaqhf | ReleaseCOMObjects(placeRunInputs); |
988 | ReleaseCOMObjects(_LMAItem); |
||
989 | } |
||
990 | |||
991 | 74752074 | gaqhf | /// <summary> |
992 | /// Symbol이 모델링된 SPPPID Symbol Object를 반환 - 연결된 Symbol이 ChildSymbol일 수도 있기때문에 메서드 개발 |
||
993 | /// </summary> |
||
994 | /// <param name="symbol"></param> |
||
995 | /// <param name="line"></param> |
||
996 | /// <returns></returns> |
||
997 | f2baa6a3 | gaqhf | private LMSymbol GetTargetSymbol(Symbol symbol, Line line) |
998 | { |
||
999 | LMSymbol _LMSymbol = null; |
||
1000 | foreach (var connector in symbol.CONNECTORS) |
||
1001 | { |
||
1002 | if (connector.CONNECTEDITEM == line.UID) |
||
1003 | { |
||
1004 | if (connector.Index == 0) |
||
1005 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1006 | else |
||
1007 | { |
||
1008 | ChildSymbol child = null; |
||
1009 | foreach (var childSymbol in symbol.ChildSymbols) |
||
1010 | { |
||
1011 | if (childSymbol.Connectors.Contains(connector)) |
||
1012 | child = childSymbol; |
||
1013 | else |
||
1014 | child = GetChildSymbolByConnector(childSymbol, connector); |
||
1015 | |||
1016 | if (child != null) |
||
1017 | break; |
||
1018 | } |
||
1019 | |||
1020 | if (child != null) |
||
1021 | _LMSymbol = dataSource.GetSymbol(child.SPPID.RepresentationId); |
||
1022 | } |
||
1023 | |||
1024 | break; |
||
1025 | } |
||
1026 | } |
||
1027 | |||
1028 | return _LMSymbol; |
||
1029 | } |
||
1030 | |||
1031 | 74752074 | gaqhf | /// <summary> |
1032 | /// Connector를 가지고 있는 ChildSymbol Object 반환 |
||
1033 | /// </summary> |
||
1034 | /// <param name="item"></param> |
||
1035 | /// <param name="connector"></param> |
||
1036 | /// <returns></returns> |
||
1037 | f2baa6a3 | gaqhf | private ChildSymbol GetChildSymbolByConnector(ChildSymbol item, Connector connector) |
1038 | { |
||
1039 | foreach (var childSymbol in item.ChildSymbols) |
||
1040 | { |
||
1041 | if (childSymbol.Connectors.Contains(connector)) |
||
1042 | return childSymbol; |
||
1043 | else |
||
1044 | return GetChildSymbolByConnector(childSymbol, connector); |
||
1045 | } |
||
1046 | |||
1047 | return null; |
||
1048 | } |
||
1049 | |||
1050 | 74752074 | gaqhf | /// <summary> |
1051 | /// Branch 라인을 다시 모델링하는 진입 메서드 |
||
1052 | /// </summary> |
||
1053 | /// <param name="branch"></param> |
||
1054 | 335b7a24 | gaqhf | private void BranchLineModeling(Tuple<string, Line, Line> branch) |
1055 | { |
||
1056 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
||
1057 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
||
1058 | |||
1059 | 8b085570 | gaqhf | LMConnector _StartConnector = null; |
1060 | LMConnector _EndConnector = null; |
||
1061 | 335b7a24 | gaqhf | double lengthStart = double.MaxValue; |
1062 | double lengthEnd = double.MaxValue; |
||
1063 | List<double[]> startPoints = new List<double[]>(); |
||
1064 | List<double[]> endPoints = new List<double[]>(); |
||
1065 | |||
1066 | foreach (var item in connectorVertices) |
||
1067 | { |
||
1068 | foreach (var point in item.Value) |
||
1069 | { |
||
1070 | // Start Point가 Branch |
||
1071 | if (branch.Item2 != null) |
||
1072 | { |
||
1073 | Line targetLine = branch.Item2; |
||
1074 | double distance = SPPIDUtil.CalcLineToPointDistance(targetLine.SPPID.START_X, targetLine.SPPID.START_Y, targetLine.SPPID.END_X, targetLine.SPPID.END_Y, point[0], point[1]); |
||
1075 | if (lengthStart > distance) |
||
1076 | { |
||
1077 | 8b085570 | gaqhf | _StartConnector = item.Key; |
1078 | 335b7a24 | gaqhf | lengthStart = distance; |
1079 | startPoints = item.Value; |
||
1080 | } |
||
1081 | } |
||
1082 | // End Point가 Branch |
||
1083 | if (branch.Item3 != null) |
||
1084 | { |
||
1085 | Line targetLine = branch.Item3; |
||
1086 | double distance = SPPIDUtil.CalcLineToPointDistance(targetLine.SPPID.START_X, targetLine.SPPID.START_Y, targetLine.SPPID.END_X, targetLine.SPPID.END_Y, point[0], point[1]); |
||
1087 | if (lengthEnd > distance) |
||
1088 | { |
||
1089 | 8b085570 | gaqhf | _EndConnector = item.Key; |
1090 | 335b7a24 | gaqhf | lengthEnd = distance; |
1091 | endPoints = item.Value; |
||
1092 | } |
||
1093 | } |
||
1094 | } |
||
1095 | } |
||
1096 | #region Branch가 양쪽 전부일 때 |
||
1097 | 8b085570 | gaqhf | if (_StartConnector != null && _StartConnector == _EndConnector) |
1098 | 335b7a24 | gaqhf | { |
1099 | 8b085570 | gaqhf | _placement.PIDRemovePlacement(_StartConnector.AsLMRepresentation()); |
1100 | 335b7a24 | gaqhf | |
1101 | _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
||
1102 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1103 | |||
1104 | Dictionary<LMConnector, List<double[]>> startConnectorVertices = GetPipeRunVertices(branch.Item2.SPPID.ModelItemId); |
||
1105 | 8b085570 | gaqhf | LMConnector _StartTargetConnector = FindTargetLMConnector(startConnectorVertices, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]); |
1106 | 335b7a24 | gaqhf | Dictionary<LMConnector, List<double[]>> endConnectorVertices = GetPipeRunVertices(branch.Item3.SPPID.ModelItemId); |
1107 | 8b085570 | gaqhf | LMConnector _EndTargetConnector = FindTargetLMConnector(endConnectorVertices, |
1108 | 335b7a24 | gaqhf | startPoints[startPoints.Count - 1][0], |
1109 | startPoints[startPoints.Count - 1][1], |
||
1110 | startPoints[startPoints.Count - 2][0], |
||
1111 | startPoints[startPoints.Count - 2][1]); |
||
1112 | |||
1113 | for (int i = 0; i < startPoints.Count; i++) |
||
1114 | { |
||
1115 | double[] point = startPoints[i]; |
||
1116 | if (i == 0) |
||
1117 | 8b085570 | gaqhf | placeRunInputs.AddConnectorTarget(_StartTargetConnector, point[0], point[1]); |
1118 | 335b7a24 | gaqhf | else if (i == startPoints.Count - 1) |
1119 | 8b085570 | gaqhf | placeRunInputs.AddConnectorTarget(_EndTargetConnector, point[0], point[1]); |
1120 | 335b7a24 | gaqhf | else |
1121 | placeRunInputs.AddPoint(point[0], point[1]); |
||
1122 | } |
||
1123 | |||
1124 | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
1125 | if (_LMConnector != null) |
||
1126 | { |
||
1127 | _LMConnector.Commit(); |
||
1128 | foreach (var item in lines) |
||
1129 | item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
||
1130 | } |
||
1131 | |||
1132 | foreach (var item in startConnectorVertices) |
||
1133 | ReleaseCOMObjects(item.Key); |
||
1134 | foreach (var item in endConnectorVertices) |
||
1135 | ReleaseCOMObjects(item.Key); |
||
1136 | ReleaseCOMObjects(placeRunInputs); |
||
1137 | ReleaseCOMObjects(_LMAItem); |
||
1138 | ReleaseCOMObjects(_LMConnector); |
||
1139 | } |
||
1140 | #endregion |
||
1141 | 8b085570 | gaqhf | #region 양쪽이 다른 Branch |
1142 | 335b7a24 | gaqhf | else |
1143 | { |
||
1144 | // Branch 시작 Connector |
||
1145 | 8b085570 | gaqhf | if (_StartConnector != null) |
1146 | 6b298450 | gaqhf | BranchLineModelingByConnector(branch, _StartConnector, startPoints, true); |
1147 | 335b7a24 | gaqhf | |
1148 | 6b298450 | gaqhf | // Branch 끝 Connector |
1149 | if (_EndConnector != null) |
||
1150 | BranchLineModelingByConnector(branch, _EndConnector, endPoints, false); |
||
1151 | } |
||
1152 | #endregion |
||
1153 | 335b7a24 | gaqhf | |
1154 | 6b298450 | gaqhf | if (_StartConnector != null) |
1155 | ReleaseCOMObjects(_StartConnector); |
||
1156 | if (_EndConnector != null) |
||
1157 | ReleaseCOMObjects(_EndConnector); |
||
1158 | foreach (var item in connectorVertices) |
||
1159 | ReleaseCOMObjects(item.Key); |
||
1160 | } |
||
1161 | 335b7a24 | gaqhf | |
1162 | 74752074 | gaqhf | /// <summary> |
1163 | /// Branch 라인을 다시 실제로 모델링하는 메서드 |
||
1164 | /// </summary> |
||
1165 | /// <param name="branch"></param> |
||
1166 | /// <param name="_Connector"></param> |
||
1167 | /// <param name="points"></param> |
||
1168 | /// <param name="IsStart"></param> |
||
1169 | 6b298450 | gaqhf | private void BranchLineModelingByConnector(Tuple<string, Line, Line> branch, LMConnector _Connector, List<double[]> points, bool IsStart) |
1170 | { |
||
1171 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
||
1172 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
||
1173 | LMConnector _SameRunTargetConnector = null; |
||
1174 | LMSymbol _SameRunTargetSymbol = null; |
||
1175 | Dictionary<LMConnector, List<double[]>> branchConnectorVertices = null; |
||
1176 | LMConnector _BranchTargetConnector = null; |
||
1177 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1178 | 335b7a24 | gaqhf | |
1179 | 6b298450 | gaqhf | // 같은 Line Run의 Connector 찾기 |
1180 | foreach (var item in connectorVertices) |
||
1181 | { |
||
1182 | if (item.Key == _Connector) |
||
1183 | continue; |
||
1184 | 335b7a24 | gaqhf | |
1185 | 6b298450 | gaqhf | if (IsStart && |
1186 | !DBNull.Value.Equals(item.Key.ConnectItem1SymbolID) && |
||
1187 | !DBNull.Value.Equals(_Connector.ConnectItem2SymbolID)&& |
||
1188 | item.Key.ConnectItem1SymbolID == _Connector.ConnectItem2SymbolID) |
||
1189 | { |
||
1190 | _SameRunTargetConnector = item.Key; |
||
1191 | break; |
||
1192 | } |
||
1193 | else if (!IsStart && |
||
1194 | !DBNull.Value.Equals(item.Key.ConnectItem2SymbolID) && |
||
1195 | !DBNull.Value.Equals(_Connector.ConnectItem1SymbolID) && |
||
1196 | item.Key.ConnectItem2SymbolID == _Connector.ConnectItem1SymbolID) |
||
1197 | { |
||
1198 | _SameRunTargetConnector = item.Key; |
||
1199 | break; |
||
1200 | } |
||
1201 | } |
||
1202 | |||
1203 | // Branch 반대편이 Symbol |
||
1204 | if (_SameRunTargetConnector == null) |
||
1205 | { |
||
1206 | foreach (var line in lines) |
||
1207 | { |
||
1208 | foreach (var connector in line.CONNECTORS) |
||
1209 | 335b7a24 | gaqhf | { |
1210 | 6b298450 | gaqhf | Symbol symbol = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Symbol; |
1211 | if (symbol != null) |
||
1212 | 335b7a24 | gaqhf | { |
1213 | 6b298450 | gaqhf | _SameRunTargetSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
1214 | break; |
||
1215 | 335b7a24 | gaqhf | } |
1216 | } |
||
1217 | 6b298450 | gaqhf | } |
1218 | } |
||
1219 | 335b7a24 | gaqhf | |
1220 | 6b298450 | gaqhf | // 기존 Connector 제거 |
1221 | _placement.PIDRemovePlacement(_Connector.AsLMRepresentation()); |
||
1222 | |||
1223 | // 시작 Connector일 경우 첫 Point가 TargetConnector를 찾아야함 |
||
1224 | if (IsStart) |
||
1225 | { |
||
1226 | branchConnectorVertices = GetPipeRunVertices(branch.Item2.SPPID.ModelItemId); |
||
1227 | _BranchTargetConnector = FindTargetLMConnector(branchConnectorVertices, points[0][0], points[0][1], points[1][0], points[1][1]); |
||
1228 | } |
||
1229 | // 끝 Conenctor일 경우 마지막 Point가 TargetConnector를 찾아야함 |
||
1230 | else |
||
1231 | { |
||
1232 | branchConnectorVertices = GetPipeRunVertices(branch.Item3.SPPID.ModelItemId); |
||
1233 | _BranchTargetConnector = FindTargetLMConnector(branchConnectorVertices, |
||
1234 | points[points.Count - 1][0], |
||
1235 | points[points.Count - 1][1], |
||
1236 | points[points.Count - 2][0], |
||
1237 | points[points.Count - 2][1]); |
||
1238 | } |
||
1239 | 335b7a24 | gaqhf | |
1240 | 6b298450 | gaqhf | for (int i = 0; i < points.Count; i++) |
1241 | { |
||
1242 | double[] point = points[i]; |
||
1243 | if (i == 0) |
||
1244 | 335b7a24 | gaqhf | { |
1245 | 6b298450 | gaqhf | if (IsStart) |
1246 | 335b7a24 | gaqhf | { |
1247 | 6b298450 | gaqhf | placeRunInputs.AddConnectorTarget(_BranchTargetConnector, point[0], point[1]); |
1248 | 335b7a24 | gaqhf | } |
1249 | 6b298450 | gaqhf | else |
1250 | 335b7a24 | gaqhf | { |
1251 | 6b298450 | gaqhf | if (_SameRunTargetConnector != null) |
1252 | placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1]); |
||
1253 | 65a1ed4b | gaqhf | else if (_SameRunTargetSymbol != null) |
1254 | 6b298450 | gaqhf | placeRunInputs.AddSymbolTarget(_SameRunTargetSymbol, point[0], point[1]); |
1255 | else |
||
1256 | placeRunInputs.AddPoint(point[0], point[1]); |
||
1257 | 335b7a24 | gaqhf | } |
1258 | 6b298450 | gaqhf | } |
1259 | else if (i == points.Count - 1) |
||
1260 | { |
||
1261 | if (IsStart) |
||
1262 | 335b7a24 | gaqhf | { |
1263 | 6b298450 | gaqhf | if (_SameRunTargetConnector != null) |
1264 | placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1]); |
||
1265 | else if (_SameRunTargetSymbol != null) |
||
1266 | placeRunInputs.AddSymbolTarget(_SameRunTargetSymbol, point[0], point[1]); |
||
1267 | 335b7a24 | gaqhf | else |
1268 | placeRunInputs.AddPoint(point[0], point[1]); |
||
1269 | } |
||
1270 | 6b298450 | gaqhf | else |
1271 | 335b7a24 | gaqhf | { |
1272 | f9125a54 | gaqhf | if (_BranchTargetConnector != null) |
1273 | { |
||
1274 | placeRunInputs.AddConnectorTarget(_BranchTargetConnector, point[0], point[1]); |
||
1275 | } |
||
1276 | 335b7a24 | gaqhf | } |
1277 | 6b298450 | gaqhf | } |
1278 | else |
||
1279 | placeRunInputs.AddPoint(point[0], point[1]); |
||
1280 | } |
||
1281 | _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
||
1282 | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
1283 | 335b7a24 | gaqhf | |
1284 | 6b298450 | gaqhf | if (_LMConnector != null) |
1285 | { |
||
1286 | if (_SameRunTargetConnector != null) |
||
1287 | { |
||
1288 | JoinPipeRun(_LMConnector.ModelItemID, _SameRunTargetConnector.ModelItemID); |
||
1289 | } |
||
1290 | else |
||
1291 | { |
||
1292 | foreach (var item in lines) |
||
1293 | item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
||
1294 | 335b7a24 | gaqhf | } |
1295 | |||
1296 | 6b298450 | gaqhf | _LMConnector.Commit(); |
1297 | ReleaseCOMObjects(_LMConnector); |
||
1298 | 335b7a24 | gaqhf | } |
1299 | |||
1300 | 6b298450 | gaqhf | ReleaseCOMObjects(placeRunInputs); |
1301 | ReleaseCOMObjects(_LMAItem); |
||
1302 | if (_BranchTargetConnector != null) |
||
1303 | ReleaseCOMObjects(_BranchTargetConnector); |
||
1304 | if (_SameRunTargetConnector != null) |
||
1305 | ReleaseCOMObjects(_SameRunTargetConnector); |
||
1306 | if (_SameRunTargetSymbol != null) |
||
1307 | ReleaseCOMObjects(_SameRunTargetSymbol); |
||
1308 | 335b7a24 | gaqhf | foreach (var item in connectorVertices) |
1309 | ReleaseCOMObjects(item.Key); |
||
1310 | 6b298450 | gaqhf | foreach (var item in branchConnectorVertices) |
1311 | ReleaseCOMObjects(item.Key); |
||
1312 | 335b7a24 | gaqhf | } |
1313 | |||
1314 | 74752074 | gaqhf | /// <summary> |
1315 | /// EndBreak 모델링 메서드 |
||
1316 | /// </summary> |
||
1317 | /// <param name="endBreak"></param> |
||
1318 | 3165c259 | gaqhf | private void EndBreakModeling(EndBreak endBreak) |
1319 | 335b7a24 | gaqhf | { |
1320 | 10c7195c | gaqhf | object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
1321 | 2a4872ec | gaqhf | LMConnector targetLMConnector = null; |
1322 | 10c7195c | gaqhf | if (ownerObj !=null && ownerObj.GetType() == typeof(Line)) |
1323 | 335b7a24 | gaqhf | { |
1324 | 10c7195c | gaqhf | Line ownerLine = ownerObj as Line; |
1325 | 3165c259 | gaqhf | LMLabelPersist _LmLabelPersist = null; |
1326 | ac78b508 | gaqhf | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(ownerLine.SPPID.ModelItemId); |
1327 | 3165c259 | gaqhf | |
1328 | 2a4872ec | gaqhf | targetLMConnector = FindTargetLMConnectorByPoint(connectorVertices, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
1329 | b9e9f4c8 | gaqhf | |
1330 | 2a4872ec | gaqhf | if (targetLMConnector != null) |
1331 | 335b7a24 | gaqhf | { |
1332 | ac78b508 | gaqhf | Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
1333 | 2a4872ec | gaqhf | _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
1334 | ac78b508 | gaqhf | } |
1335 | 3165c259 | gaqhf | |
1336 | ac78b508 | gaqhf | if (_LmLabelPersist != null) |
1337 | { |
||
1338 | _LmLabelPersist.Commit(); |
||
1339 | ReleaseCOMObjects(_LmLabelPersist); |
||
1340 | 335b7a24 | gaqhf | } |
1341 | b9e9f4c8 | gaqhf | else |
1342 | 2a4872ec | gaqhf | RetryEndBreakModeling(endBreak, targetLMConnector); |
1343 | b9e9f4c8 | gaqhf | |
1344 | ac78b508 | gaqhf | foreach (var item in connectorVertices) |
1345 | ReleaseCOMObjects(item.Key); |
||
1346 | 2a4872ec | gaqhf | |
1347 | 335b7a24 | gaqhf | } |
1348 | 10c7195c | gaqhf | else if (ownerObj != null && ownerObj.GetType() == typeof(Symbol)) |
1349 | { |
||
1350 | Symbol ownerSymbol = ownerObj as Symbol; |
||
1351 | LMSymbol _LMSymbol = dataSource.GetSymbol(ownerSymbol.SPPID.RepresentationId); |
||
1352 | |||
1353 | 2a4872ec | gaqhf | targetLMConnector = null; |
1354 | 10c7195c | gaqhf | double distance = double.MaxValue; |
1355 | b9e9f4c8 | gaqhf | |
1356 | 10c7195c | gaqhf | foreach (LMConnector connector in _LMSymbol.Avoid1Connectors) |
1357 | { |
||
1358 | 26c6f818 | gaqhf | if (connector.get_ItemStatus() == "Active") |
1359 | 10c7195c | gaqhf | { |
1360 | 26c6f818 | gaqhf | dynamic OID = connector.get_GraphicOID(); |
1361 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
1362 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1363 | int verticesCount = lineStringGeometry.VertexCount; |
||
1364 | double[] vertices = null; |
||
1365 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
1366 | for (int i = 0; i < verticesCount; i++) |
||
1367 | 10c7195c | gaqhf | { |
1368 | 26c6f818 | gaqhf | double x = 0; |
1369 | double y = 0; |
||
1370 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
1371 | |||
1372 | b9e9f4c8 | gaqhf | double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
1373 | 26c6f818 | gaqhf | if (result < distance) |
1374 | { |
||
1375 | targetLMConnector = connector; |
||
1376 | distance = result; |
||
1377 | } |
||
1378 | 10c7195c | gaqhf | } |
1379 | } |
||
1380 | } |
||
1381 | |||
1382 | foreach (LMConnector connector in _LMSymbol.Avoid2Connectors) |
||
1383 | { |
||
1384 | b9e9f4c8 | gaqhf | if (connector.get_ItemStatus() == "Active") |
1385 | 10c7195c | gaqhf | { |
1386 | b9e9f4c8 | gaqhf | dynamic OID = connector.get_GraphicOID(); |
1387 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
1388 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1389 | int verticesCount = lineStringGeometry.VertexCount; |
||
1390 | double[] vertices = null; |
||
1391 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
1392 | for (int i = 0; i < verticesCount; i++) |
||
1393 | 10c7195c | gaqhf | { |
1394 | b9e9f4c8 | gaqhf | double x = 0; |
1395 | double y = 0; |
||
1396 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
1397 | |||
1398 | double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
||
1399 | if (result < distance) |
||
1400 | { |
||
1401 | targetLMConnector = connector; |
||
1402 | distance = result; |
||
1403 | } |
||
1404 | 10c7195c | gaqhf | } |
1405 | } |
||
1406 | } |
||
1407 | |||
1408 | if (targetLMConnector != null) |
||
1409 | { |
||
1410 | LMLabelPersist _LmLabelPersist = null; |
||
1411 | Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
||
1412 | _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
1413 | if (_LmLabelPersist != null) |
||
1414 | { |
||
1415 | _LmLabelPersist.Commit(); |
||
1416 | ReleaseCOMObjects(_LmLabelPersist); |
||
1417 | } |
||
1418 | b9e9f4c8 | gaqhf | else |
1419 | 2a4872ec | gaqhf | RetryEndBreakModeling(endBreak, targetLMConnector); |
1420 | } |
||
1421 | |||
1422 | ReleaseCOMObjects(_LMSymbol); |
||
1423 | } |
||
1424 | f31645b6 | gaqhf | |
1425 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1426 | 2a4872ec | gaqhf | } |
1427 | b9e9f4c8 | gaqhf | |
1428 | 74752074 | gaqhf | /// <summary> |
1429 | /// EndBreak 모델링이 실패시 다시 시도하는 메서드 |
||
1430 | /// </summary> |
||
1431 | /// <param name="endBreak"></param> |
||
1432 | /// <param name="targetLMConnector"></param> |
||
1433 | 2a4872ec | gaqhf | private void RetryEndBreakModeling(EndBreak endBreak, LMConnector targetLMConnector) |
1434 | { |
||
1435 | bool isZeroLength = Convert.ToBoolean(targetLMConnector.get_IsZeroLength()); |
||
1436 | Array array = null; |
||
1437 | LMLabelPersist _LMLabelPersist = null; |
||
1438 | LMConnector _LMConnector = null; |
||
1439 | dynamic OID = targetLMConnector.get_GraphicOID(); |
||
1440 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
1441 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1442 | int verticesCount = lineStringGeometry.VertexCount; |
||
1443 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1444 | _LMAItem _LMAItem = _placement.PIDCreateItem(@"\Piping\Routing\Process Lines\Primary Piping.sym"); |
||
1445 | b9e9f4c8 | gaqhf | |
1446 | 2a4872ec | gaqhf | if (isZeroLength) |
1447 | { |
||
1448 | double[] vertices = null; |
||
1449 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
1450 | double x = 0; |
||
1451 | double y = 0; |
||
1452 | lineStringGeometry.GetVertex(1, ref x, ref y); |
||
1453 | b9e9f4c8 | gaqhf | |
1454 | 2a4872ec | gaqhf | placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, x, y); |
1455 | placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, x, y); |
||
1456 | b9e9f4c8 | gaqhf | |
1457 | 2a4872ec | gaqhf | _placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
1458 | _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
1459 | |||
1460 | array = new double[] { 0, x, y }; |
||
1461 | _LMLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _LMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
1462 | 5a83fda2 | gaqhf | |
1463 | AutoJoinPipeRun(_LMConnector.ModelItemID); |
||
1464 | 2a4872ec | gaqhf | } |
1465 | else |
||
1466 | { |
||
1467 | List<double[]> vertices = new List<double[]>(); |
||
1468 | for (int i = 1; i <= verticesCount; i++) |
||
1469 | { |
||
1470 | double x = 0; |
||
1471 | double y = 0; |
||
1472 | lineStringGeometry.GetVertex(i, ref x, ref y); |
||
1473 | vertices.Add(new double[] { x, y }); |
||
1474 | } |
||
1475 | |||
1476 | for (int i = 0; i < vertices.Count; i++) |
||
1477 | { |
||
1478 | double[] points = vertices[i]; |
||
1479 | if (i == 0) |
||
1480 | { |
||
1481 | if (targetLMConnector.ConnectItem1SymbolObject != null) |
||
1482 | placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, points[0], points[1]); |
||
1483 | else |
||
1484 | placeRunInputs.AddPoint(points[0], points[1]); |
||
1485 | b9e9f4c8 | gaqhf | } |
1486 | 2a4872ec | gaqhf | else if (i == vertices.Count - 1) |
1487 | { |
||
1488 | if (targetLMConnector.ConnectItem2SymbolObject != null) |
||
1489 | placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, points[0], points[1]); |
||
1490 | else |
||
1491 | placeRunInputs.AddPoint(points[0], points[1]); |
||
1492 | } |
||
1493 | else |
||
1494 | placeRunInputs.AddPoint(points[0], points[1]); |
||
1495 | 10c7195c | gaqhf | } |
1496 | 2a4872ec | gaqhf | |
1497 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, targetLMConnector.ModelItemID); |
||
1498 | b9e9f4c8 | gaqhf | |
1499 | 2a4872ec | gaqhf | _placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
1500 | _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
1501 | |||
1502 | array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
||
1503 | _LMLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _LMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
1504 | 3939eebf | gaqhf | |
1505 | AutoJoinPipeRun(_LMConnector.ModelItemID); |
||
1506 | foreach (var line in lines) |
||
1507 | line.SPPID.ModelItemId = _LMConnector.ModelItemID; |
||
1508 | 10c7195c | gaqhf | } |
1509 | 2a4872ec | gaqhf | |
1510 | |||
1511 | if (_LMLabelPersist != null) |
||
1512 | { |
||
1513 | _LMLabelPersist.Commit(); |
||
1514 | ReleaseCOMObjects(_LMLabelPersist); |
||
1515 | } |
||
1516 | else |
||
1517 | { |
||
1518 | |||
1519 | } |
||
1520 | |||
1521 | ReleaseCOMObjects(_LMConnector); |
||
1522 | ReleaseCOMObjects(placeRunInputs); |
||
1523 | ReleaseCOMObjects(_LMAItem); |
||
1524 | 3165c259 | gaqhf | } |
1525 | 10872260 | gaqhf | |
1526 | 74752074 | gaqhf | /// <summary> |
1527 | /// FromModelItem을 ToModelItem으로 PipeRunJoin하는 메서드 |
||
1528 | /// </summary> |
||
1529 | /// <param name="fromModelItemId"></param> |
||
1530 | /// <param name="toModelItemId"></param> |
||
1531 | 335b7a24 | gaqhf | private void JoinPipeRun(string fromModelItemId, string toModelItemId) |
1532 | { |
||
1533 | 310aeb31 | gaqhf | LMModelItem modelItem1 = dataSource.GetModelItem(toModelItemId); |
1534 | _LMAItem item1 = modelItem1.AsLMAItem(); |
||
1535 | LMModelItem modelItem2 = dataSource.GetModelItem(fromModelItemId); |
||
1536 | _LMAItem item2 = modelItem2.AsLMAItem(); |
||
1537 | |||
1538 | 335b7a24 | gaqhf | // item2가 item1으로 조인 |
1539 | try |
||
1540 | { |
||
1541 | _placement.PIDJoinRuns(ref item1, ref item2); |
||
1542 | 65a1ed4b | gaqhf | item1.Commit(); |
1543 | item2.Commit(); |
||
1544 | 3939eebf | gaqhf | |
1545 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, fromModelItemId); |
||
1546 | foreach (var line in lines) |
||
1547 | line.SPPID.ModelItemId = toModelItemId; |
||
1548 | 335b7a24 | gaqhf | } |
1549 | catch (Exception ex) |
||
1550 | { |
||
1551 | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
1552 | } |
||
1553 | finally |
||
1554 | { |
||
1555 | 310aeb31 | gaqhf | ReleaseCOMObjects(modelItem1); |
1556 | ReleaseCOMObjects(item1); |
||
1557 | ReleaseCOMObjects(modelItem2); |
||
1558 | ReleaseCOMObjects(item2); |
||
1559 | 335b7a24 | gaqhf | } |
1560 | } |
||
1561 | |||
1562 | 74752074 | gaqhf | /// <summary> |
1563 | /// PipeRun을 자동으로 Join하는 메서드 |
||
1564 | /// </summary> |
||
1565 | /// <param name="modelItemId"></param> |
||
1566 | 335b7a24 | gaqhf | private void AutoJoinPipeRun(string modelItemId) |
1567 | { |
||
1568 | 310aeb31 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
1569 | _LMAItem item = modelItem.AsLMAItem(); |
||
1570 | 65a1ed4b | gaqhf | try |
1571 | { |
||
1572 | string modelitemID = item.Id; |
||
1573 | _placement.PIDAutoJoin(item, AutoJoinEndConstants.autoJoin_Both, ref item); |
||
1574 | string afterModelItemID = item.Id; |
||
1575 | 5a83fda2 | gaqhf | |
1576 | 65a1ed4b | gaqhf | if (modelitemID != afterModelItemID) |
1577 | { |
||
1578 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, modelitemID); |
||
1579 | foreach (var line in lines) |
||
1580 | line.SPPID.ModelItemId = afterModelItemID; |
||
1581 | } |
||
1582 | item.Commit(); |
||
1583 | } |
||
1584 | catch (Exception ex) |
||
1585 | { |
||
1586 | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
1587 | } |
||
1588 | finally |
||
1589 | { |
||
1590 | 310aeb31 | gaqhf | ReleaseCOMObjects(modelItem); |
1591 | ReleaseCOMObjects(item); |
||
1592 | 65a1ed4b | gaqhf | } |
1593 | 335b7a24 | gaqhf | } |
1594 | |||
1595 | 74752074 | gaqhf | /// <summary> |
1596 | /// LineRun에 있는 Line들을 Join하는 진입 메서드 |
||
1597 | /// </summary> |
||
1598 | /// <param name="run"></param> |
||
1599 | 335b7a24 | gaqhf | private void JoinRunLine(LineRun run) |
1600 | { |
||
1601 | string modelItemId = string.Empty; |
||
1602 | foreach (var item in run.RUNITEMS) |
||
1603 | { |
||
1604 | if (item.GetType() == typeof(Line)) |
||
1605 | { |
||
1606 | Line line = item as Line; |
||
1607 | 1ba9c671 | gaqhf | AutoJoinPipeRun(line.SPPID.ModelItemId); |
1608 | modelItemId = line.SPPID.ModelItemId; |
||
1609 | f31645b6 | gaqhf | |
1610 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1611 | 335b7a24 | gaqhf | } |
1612 | } |
||
1613 | } |
||
1614 | |||
1615 | 74752074 | gaqhf | /// <summary> |
1616 | /// PipeRun의 좌표를 가져오는 메서드 |
||
1617 | /// </summary> |
||
1618 | /// <param name="modelId"></param> |
||
1619 | /// <returns></returns> |
||
1620 | 5e6ecf05 | gaqhf | private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId) |
1621 | { |
||
1622 | Dictionary<LMConnector, List<double[]>> connectorVertices = new Dictionary<LMConnector, List<double[]>>(); |
||
1623 | 310aeb31 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelId); |
1624 | |||
1625 | if (modelItem != null) |
||
1626 | 5e6ecf05 | gaqhf | { |
1627 | 310aeb31 | gaqhf | foreach (LMRepresentation rep in modelItem.Representations) |
1628 | 5e6ecf05 | gaqhf | { |
1629 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
1630 | { |
||
1631 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
1632 | connectorVertices.Add(_LMConnector, new List<double[]>()); |
||
1633 | dynamic OID = rep.get_GraphicOID(); |
||
1634 | 335b7a24 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1635 | 5e6ecf05 | gaqhf | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
1636 | int verticesCount = lineStringGeometry.VertexCount; |
||
1637 | double[] vertices = null; |
||
1638 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
1639 | for (int i = 0; i < verticesCount; i++) |
||
1640 | { |
||
1641 | double x = 0; |
||
1642 | double y = 0; |
||
1643 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
1644 | 335b7a24 | gaqhf | connectorVertices[_LMConnector].Add(new double[] { Math.Round(x, 10), Math.Round(y, 10) }); |
1645 | 5e6ecf05 | gaqhf | } |
1646 | } |
||
1647 | } |
||
1648 | |||
1649 | 310aeb31 | gaqhf | ReleaseCOMObjects(modelItem); |
1650 | 5e6ecf05 | gaqhf | } |
1651 | |||
1652 | return connectorVertices; |
||
1653 | } |
||
1654 | |||
1655 | 74752074 | gaqhf | /// <summary> |
1656 | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 두점으로 라인의 교차점을 기준으로 구함 |
||
1657 | /// </summary> |
||
1658 | /// <param name="connectorVertices"></param> |
||
1659 | /// <param name="connX"></param> |
||
1660 | /// <param name="connY"></param> |
||
1661 | /// <param name="x2"></param> |
||
1662 | /// <param name="y2"></param> |
||
1663 | /// <returns></returns> |
||
1664 | 56bc67e1 | gaqhf | private LMConnector FindTargetLMConnector(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY, double x2, double y2) |
1665 | 5e6ecf05 | gaqhf | { |
1666 | double length = double.MaxValue; |
||
1667 | LMConnector targetConnector = null; |
||
1668 | foreach (var item in connectorVertices) |
||
1669 | { |
||
1670 | List<double[]> points = item.Value; |
||
1671 | for (int i = 0; i < points.Count - 1; i++) |
||
1672 | { |
||
1673 | double[] point1 = points[i]; |
||
1674 | double[] point2 = points[i + 1]; |
||
1675 | |||
1676 | 335b7a24 | gaqhf | double maxLineX = Math.Max(point1[0], point2[0]); |
1677 | double minLineX = Math.Min(point1[0], point2[0]); |
||
1678 | double maxLineY = Math.Max(point1[1], point2[1]); |
||
1679 | double minLineY = Math.Min(point1[1], point2[1]); |
||
1680 | |||
1681 | SlopeType slope = SPPIDUtil.CalcSlope(minLineX, minLineY, maxLineX, maxLineY); |
||
1682 | |||
1683 | 56bc67e1 | gaqhf | // 두직선의 교차점 |
1684 | double[] crossingPoint = SPPIDUtil.CalcLineCrossingPoint(connX, connY, x2, y2, point1[0], point1[1], point2[0], point2[1]); |
||
1685 | if (crossingPoint != null) |
||
1686 | 5e6ecf05 | gaqhf | { |
1687 | 30a9ffce | gaqhf | double distance = SPPIDUtil.CalcPointToPointdDistance(connX, connY, crossingPoint[0], crossingPoint[1]); |
1688 | 335b7a24 | gaqhf | if (length >= distance) |
1689 | 30a9ffce | gaqhf | { |
1690 | 335b7a24 | gaqhf | if (slope == SlopeType.Slope && |
1691 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0] && |
||
1692 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
1693 | { |
||
1694 | targetConnector = item.Key; |
||
1695 | length = distance; |
||
1696 | } |
||
1697 | else if (slope == SlopeType.HORIZONTAL && |
||
1698 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0]) |
||
1699 | { |
||
1700 | targetConnector = item.Key; |
||
1701 | length = distance; |
||
1702 | } |
||
1703 | else if (slope == SlopeType.VERTICAL && |
||
1704 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
1705 | { |
||
1706 | targetConnector = item.Key; |
||
1707 | length = distance; |
||
1708 | } |
||
1709 | 30a9ffce | gaqhf | } |
1710 | 5e6ecf05 | gaqhf | } |
1711 | } |
||
1712 | c3d2e266 | gaqhf | |
1713 | |||
1714 | } |
||
1715 | |||
1716 | if (targetConnector == null) |
||
1717 | { |
||
1718 | foreach (var item in connectorVertices) |
||
1719 | { |
||
1720 | List<double[]> points = item.Value; |
||
1721 | foreach (var point in points) |
||
1722 | { |
||
1723 | double distance = SPPIDUtil.CalcPointToPointdDistance(connX, connY, point[0], point[1]); |
||
1724 | if (length >= distance) |
||
1725 | { |
||
1726 | targetConnector = item.Key; |
||
1727 | length = distance; |
||
1728 | } |
||
1729 | } |
||
1730 | } |
||
1731 | |||
1732 | 5e6ecf05 | gaqhf | } |
1733 | |||
1734 | return targetConnector; |
||
1735 | } |
||
1736 | |||
1737 | 74752074 | gaqhf | /// <summary> |
1738 | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 한점으로 제일 가까운 기준으로 구함(단순) |
||
1739 | /// </summary> |
||
1740 | /// <param name="connectorVertices"></param> |
||
1741 | /// <param name="connX"></param> |
||
1742 | /// <param name="connY"></param> |
||
1743 | /// <returns></returns> |
||
1744 | ac78b508 | gaqhf | private LMConnector FindTargetLMConnectorByPoint(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
1745 | { |
||
1746 | double length = double.MaxValue; |
||
1747 | LMConnector targetConnector = null; |
||
1748 | foreach (var item in connectorVertices) |
||
1749 | { |
||
1750 | List<double[]> points = item.Value; |
||
1751 | |||
1752 | foreach (double[] point in points) |
||
1753 | { |
||
1754 | double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
||
1755 | if (length >= distance) |
||
1756 | { |
||
1757 | targetConnector = item.Key; |
||
1758 | length = distance; |
||
1759 | } |
||
1760 | } |
||
1761 | } |
||
1762 | |||
1763 | return targetConnector; |
||
1764 | } |
||
1765 | |||
1766 | 74752074 | gaqhf | /// <summary> |
1767 | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 조건에 안맞아서 못찾을시 제일 가까운 점으로 가져오는 방식 |
||
1768 | /// </summary> |
||
1769 | /// <param name="connectorVertices"></param> |
||
1770 | /// <param name="connX"></param> |
||
1771 | /// <param name="connY"></param> |
||
1772 | /// <returns></returns> |
||
1773 | 68464385 | gaqhf | private LMConnector FindTargetLMConnectorForLabel(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
1774 | { |
||
1775 | double length = double.MaxValue; |
||
1776 | LMConnector targetConnector = null; |
||
1777 | foreach (var item in connectorVertices) |
||
1778 | { |
||
1779 | List<double[]> points = item.Value; |
||
1780 | for (int i = 0; i < points.Count - 1; i++) |
||
1781 | { |
||
1782 | double[] point1 = points[i]; |
||
1783 | double[] point2 = points[i + 1]; |
||
1784 | double x1 = Math.Min(point1[0], point2[0]); |
||
1785 | double y1 = Math.Min(point1[1], point2[1]); |
||
1786 | double x2 = Math.Max(point1[0], point2[0]); |
||
1787 | double y2 = Math.Max(point1[1], point2[1]); |
||
1788 | |||
1789 | if ((x1 <= connX && x2 >= connX) || |
||
1790 | (y1 <= connY && y2 >= connY)) |
||
1791 | { |
||
1792 | double distance = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], connX, connY); |
||
1793 | if (length >= distance) |
||
1794 | { |
||
1795 | targetConnector = item.Key; |
||
1796 | length = distance; |
||
1797 | } |
||
1798 | |||
1799 | distance = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], connX, connY); |
||
1800 | if (length >= distance) |
||
1801 | { |
||
1802 | targetConnector = item.Key; |
||
1803 | length = distance; |
||
1804 | } |
||
1805 | } |
||
1806 | } |
||
1807 | } |
||
1808 | |||
1809 | // 못찾았을때. |
||
1810 | length = double.MaxValue; |
||
1811 | if (targetConnector == null) |
||
1812 | { |
||
1813 | foreach (var item in connectorVertices) |
||
1814 | { |
||
1815 | List<double[]> points = item.Value; |
||
1816 | |||
1817 | foreach (double[] point in points) |
||
1818 | { |
||
1819 | double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
||
1820 | if (length >= distance) |
||
1821 | { |
||
1822 | targetConnector = item.Key; |
||
1823 | length = distance; |
||
1824 | } |
||
1825 | } |
||
1826 | } |
||
1827 | } |
||
1828 | |||
1829 | return targetConnector; |
||
1830 | } |
||
1831 | |||
1832 | 74752074 | gaqhf | /// <summary> |
1833 | /// Line Number Symbol을 실제로 Modeling하는 메서드 |
||
1834 | /// </summary> |
||
1835 | /// <param name="lineNumber"></param> |
||
1836 | cfda1fed | gaqhf | private void LineNumberModeling(LineNumber lineNumber) |
1837 | { |
||
1838 | f4880c6a | gaqhf | Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line; |
1839 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
1840 | 68464385 | gaqhf | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y); |
1841 | f4880c6a | gaqhf | if (connectedLMConnector != null) |
1842 | 10872260 | gaqhf | { |
1843 | b65a7e32 | gaqhf | double x = 0; |
1844 | double y = 0; |
||
1845 | CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
||
1846 | |||
1847 | Array points = new double[] { 0, x, y }; |
||
1848 | f4880c6a | gaqhf | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
1849 | cfda1fed | gaqhf | |
1850 | f4880c6a | gaqhf | foreach (var item in connectorVertices) |
1851 | ReleaseCOMObjects(item.Key); |
||
1852 | if (_LmLabelPresist != null) |
||
1853 | { |
||
1854 | c3d2e266 | gaqhf | _LmLabelPresist.Commit(); |
1855 | f4880c6a | gaqhf | lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
1856 | ReleaseCOMObjects(_LmLabelPresist); |
||
1857 | 10872260 | gaqhf | } |
1858 | c3d2e266 | gaqhf | else |
1859 | { |
||
1860 | |||
1861 | } |
||
1862 | 10872260 | gaqhf | } |
1863 | f31645b6 | gaqhf | |
1864 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1865 | cfda1fed | gaqhf | } |
1866 | |||
1867 | 74752074 | gaqhf | /// <summary> |
1868 | /// Line Number 기준으로 모든 Item에 Line Number의 Attribute Input |
||
1869 | /// </summary> |
||
1870 | /// <param name="lineNumber"></param> |
||
1871 | a7e9beec | gaqhf | private void InputLineNumberAttribute(LineNumber lineNumber) |
1872 | { |
||
1873 | 8634af60 | gaqhf | foreach (LineRun run in lineNumber.RUNS) |
1874 | a7e9beec | gaqhf | { |
1875 | 8634af60 | gaqhf | foreach (var item in run.RUNITEMS) |
1876 | a7e9beec | gaqhf | { |
1877 | 8634af60 | gaqhf | if (item.GetType() == typeof(Symbol)) |
1878 | a7e9beec | gaqhf | { |
1879 | 8634af60 | gaqhf | Symbol symbol = item as Symbol; |
1880 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1881 | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
||
1882 | |||
1883 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
1884 | { |
||
1885 | foreach (var attribute in lineNumber.ATTRIBUTES) |
||
1886 | { |
||
1887 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
1888 | if (mapping != null) |
||
1889 | { |
||
1890 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
1891 | if (_LMAAttribute != null) |
||
1892 | { |
||
1893 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
1894 | _LMAAttribute.set_Value(attribute.VALUE); |
||
1895 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
1896 | _LMAAttribute.set_Value(attribute.VALUE); |
||
1897 | } |
||
1898 | } |
||
1899 | } |
||
1900 | _LMModelItem.Commit(); |
||
1901 | } |
||
1902 | if (_LMModelItem != null) |
||
1903 | ReleaseCOMObjects(_LMModelItem); |
||
1904 | if (_LMSymbol != null) |
||
1905 | ReleaseCOMObjects(_LMSymbol); |
||
1906 | } |
||
1907 | else if (item.GetType() == typeof(Line)) |
||
1908 | { |
||
1909 | Line line = item as Line; |
||
1910 | if (line != null) |
||
1911 | a7e9beec | gaqhf | { |
1912 | 8634af60 | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
1913 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
1914 | a7e9beec | gaqhf | { |
1915 | 8634af60 | gaqhf | foreach (var attribute in lineNumber.ATTRIBUTES) |
1916 | { |
||
1917 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
1918 | if (mapping != null) |
||
1919 | { |
||
1920 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
1921 | if (_LMAAttribute != null) |
||
1922 | { |
||
1923 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
1924 | _LMAAttribute.set_Value(attribute.VALUE); |
||
1925 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
1926 | _LMAAttribute.set_Value(attribute.VALUE); |
||
1927 | |||
1928 | } |
||
1929 | } |
||
1930 | } |
||
1931 | 68464385 | gaqhf | _LMModelItem.Commit(); |
1932 | a7e9beec | gaqhf | } |
1933 | 8634af60 | gaqhf | if (_LMModelItem != null) |
1934 | ReleaseCOMObjects(_LMModelItem); |
||
1935 | a7e9beec | gaqhf | } |
1936 | } |
||
1937 | } |
||
1938 | } |
||
1939 | f31645b6 | gaqhf | |
1940 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1941 | a7e9beec | gaqhf | } |
1942 | |||
1943 | 74752074 | gaqhf | /// <summary> |
1944 | /// Symbol Attribute 입력 메서드 |
||
1945 | /// </summary> |
||
1946 | 73415441 | gaqhf | /// <param name="item"></param> |
1947 | private void InputSymbolAttribute(object targetItem, List<BaseModel.Attribute> targetAttributes) |
||
1948 | 1efc25a3 | gaqhf | { |
1949 | ac78b508 | gaqhf | try |
1950 | 1efc25a3 | gaqhf | { |
1951 | 73415441 | gaqhf | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
1952 | string sRep = null; |
||
1953 | if (targetItem.GetType() == typeof(Symbol)) |
||
1954 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
1955 | else if (targetItem.GetType() == typeof(Equipment)) |
||
1956 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
1957 | |||
1958 | if (!string.IsNullOrEmpty(sRep)) |
||
1959 | 402ef5b1 | gaqhf | { |
1960 | 73415441 | gaqhf | LMSymbol _LMSymbol = dataSource.GetSymbol(sRep); |
1961 | 310aeb31 | gaqhf | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
1962 | ea80efaa | gaqhf | LMAAttributes _Attributes = _LMModelItem.Attributes; |
1963 | 402ef5b1 | gaqhf | |
1964 | 73415441 | gaqhf | foreach (var item in targetAttributes) |
1965 | 65a1ed4b | gaqhf | { |
1966 | ac78b508 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
1967 | 26c6f818 | gaqhf | if (mapping != null && !string.IsNullOrEmpty(item.VALUE) && item.VALUE != "None") |
1968 | ac78b508 | gaqhf | { |
1969 | LMAAttribute _Attribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
1970 | if (_Attribute != null) |
||
1971 | 73415441 | gaqhf | _Attribute.set_Value(item.VALUE); |
1972 | ac78b508 | gaqhf | } |
1973 | 65a1ed4b | gaqhf | } |
1974 | 73415441 | gaqhf | _LMModelItem.Commit(); |
1975 | |||
1976 | ea80efaa | gaqhf | ReleaseCOMObjects(_Attributes); |
1977 | ReleaseCOMObjects(_LMModelItem); |
||
1978 | 73415441 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1979 | ac78b508 | gaqhf | } |
1980 | } |
||
1981 | catch (Exception ex) |
||
1982 | { |
||
1983 | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
1984 | 1efc25a3 | gaqhf | } |
1985 | f31645b6 | gaqhf | |
1986 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
1987 | 1efc25a3 | gaqhf | } |
1988 | |||
1989 | 74752074 | gaqhf | /// <summary> |
1990 | /// Text Modeling - Association일 경우는 Text대신 해당 맵핑된 Symbol로 모델링 |
||
1991 | /// </summary> |
||
1992 | /// <param name="text"></param> |
||
1993 | cfda1fed | gaqhf | private void TextModeling(Text text) |
1994 | { |
||
1995 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
1996 | try |
||
1997 | { |
||
1998 | 8b069d9f | gaqhf | //if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
1999 | if (text.ASSOCIATION) |
||
2000 | ea80efaa | gaqhf | { |
2001 | object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
||
2002 | if (owner.GetType() == typeof(Symbol)) |
||
2003 | { |
||
2004 | Symbol symbol = owner as Symbol; |
||
2005 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
2006 | if (_LMSymbol != null) |
||
2007 | { |
||
2008 | Association association = symbol.ASSOCIATIONS.Find(x => x.VALUE == text.UID); |
||
2009 | List<BaseModel.Attribute> attributes = symbol.ATTRIBUTES.FindAll(x => x.ATTRIBUTETYPE == association.TYPE); |
||
2010 | AttributeMapping mapping = null; |
||
2011 | foreach (var attribute in attributes) |
||
2012 | { |
||
2013 | 26c6f818 | gaqhf | if (string.IsNullOrEmpty(attribute.VALUE) || attribute.VALUE == "None") |
2014 | continue; |
||
2015 | |||
2016 | ea80efaa | gaqhf | mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
2017 | if (mapping != null) |
||
2018 | break; |
||
2019 | } |
||
2020 | |||
2021 | if (mapping != null) |
||
2022 | { |
||
2023 | 1a3a74a8 | gaqhf | double x = 0; |
2024 | double y = 0; |
||
2025 | |||
2026 | b65a7e32 | gaqhf | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
2027 | Array array = new double[] { 0, x, y }; |
||
2028 | 1a3a74a8 | gaqhf | |
2029 | 1ba9c671 | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
2030 | ea80efaa | gaqhf | if (_LMLabelPersist!=null) |
2031 | { |
||
2032 | f9125a54 | gaqhf | _LMLabelPersist.Commit(); |
2033 | ea80efaa | gaqhf | ReleaseCOMObjects(_LMLabelPersist); |
2034 | } |
||
2035 | } |
||
2036 | } |
||
2037 | } |
||
2038 | else if (owner.GetType() == typeof(Line)) |
||
2039 | { |
||
2040 | |||
2041 | } |
||
2042 | } |
||
2043 | else |
||
2044 | { |
||
2045 | LMItemNote _LMItemNote = null; |
||
2046 | LMAAttribute _LMAAttribute = null; |
||
2047 | |||
2048 | b65a7e32 | gaqhf | double x = 0; |
2049 | double y = 0; |
||
2050 | |||
2051 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
||
2052 | |||
2053 | _LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y); |
||
2054 | ea80efaa | gaqhf | _LMSymbol.Commit(); |
2055 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
2056 | _LMItemNote.Commit(); |
||
2057 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
2058 | _LMAAttribute.set_Value(text.VALUE); |
||
2059 | _LMItemNote.Commit(); |
||
2060 | |||
2061 | if (_LMAAttribute != null) |
||
2062 | ReleaseCOMObjects(_LMAAttribute); |
||
2063 | if (_LMItemNote != null) |
||
2064 | ReleaseCOMObjects(_LMItemNote); |
||
2065 | } |
||
2066 | 6b298450 | gaqhf | } |
2067 | catch (Exception ex) |
||
2068 | { |
||
2069 | cfda1fed | gaqhf | |
2070 | 6b298450 | gaqhf | } |
2071 | finally |
||
2072 | { |
||
2073 | if (_LMSymbol != null) |
||
2074 | ReleaseCOMObjects(_LMSymbol); |
||
2075 | } |
||
2076 | f31645b6 | gaqhf | |
2077 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
2078 | cfda1fed | gaqhf | } |
2079 | |||
2080 | 74752074 | gaqhf | /// <summary> |
2081 | /// Note Modeling |
||
2082 | /// </summary> |
||
2083 | /// <param name="note"></param> |
||
2084 | cfda1fed | gaqhf | private void NoteModeling(Note note) |
2085 | { |
||
2086 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
2087 | LMItemNote _LMItemNote = null; |
||
2088 | LMAAttribute _LMAAttribute = null; |
||
2089 | |||
2090 | try |
||
2091 | { |
||
2092 | b65a7e32 | gaqhf | double x = 0; |
2093 | double y = 0; |
||
2094 | |||
2095 | CalcLabelLocation(ref x, ref y, note.SPPID.ORIGINAL_X, note.SPPID.ORIGINAL_Y, note.SPPIDLabelLocation, _ETCSetting.NoteLocation); |
||
2096 | |||
2097 | _LMSymbol = _placement.PIDPlaceSymbol(note.SPPID.MAPPINGNAME, x, y); |
||
2098 | 6b298450 | gaqhf | _LMSymbol.Commit(); |
2099 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
2100 | _LMItemNote.Commit(); |
||
2101 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
2102 | _LMAAttribute.set_Value(note.VALUE); |
||
2103 | _LMItemNote.Commit(); |
||
2104 | } |
||
2105 | catch (Exception ex) |
||
2106 | { |
||
2107 | cfda1fed | gaqhf | |
2108 | 6b298450 | gaqhf | } |
2109 | finally |
||
2110 | { |
||
2111 | if (_LMAAttribute != null) |
||
2112 | ReleaseCOMObjects(_LMAAttribute); |
||
2113 | if (_LMItemNote != null) |
||
2114 | ReleaseCOMObjects(_LMItemNote); |
||
2115 | if (_LMSymbol != null) |
||
2116 | ReleaseCOMObjects(_LMSymbol); |
||
2117 | } |
||
2118 | f31645b6 | gaqhf | |
2119 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
||
2120 | cfda1fed | gaqhf | } |
2121 | |||
2122 | 74752074 | gaqhf | /// <summary> |
2123 | /// Label의 좌표를 구하는 메서드(ID2 기준의 좌표 -> SPPID 좌표) |
||
2124 | /// </summary> |
||
2125 | /// <param name="x"></param> |
||
2126 | /// <param name="y"></param> |
||
2127 | /// <param name="originX"></param> |
||
2128 | /// <param name="originY"></param> |
||
2129 | /// <param name="SPPIDLabelLocation"></param> |
||
2130 | /// <param name="location"></param> |
||
2131 | b65a7e32 | gaqhf | private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDLabelLocationInfo SPPIDLabelLocation, Location location) |
2132 | { |
||
2133 | if (location == Location.None) |
||
2134 | { |
||
2135 | x = originX; |
||
2136 | y = originY; |
||
2137 | } |
||
2138 | else |
||
2139 | { |
||
2140 | if (location.HasFlag(Location.Center)) |
||
2141 | { |
||
2142 | x = (SPPIDLabelLocation.X1 + SPPIDLabelLocation.X2) / 2; |
||
2143 | y = (SPPIDLabelLocation.Y1 + SPPIDLabelLocation.Y2) / 2; |
||
2144 | } |
||
2145 | |||
2146 | if (location.HasFlag(Location.Left)) |
||
2147 | x = SPPIDLabelLocation.X1; |
||
2148 | else if (location.HasFlag(Location.Right)) |
||
2149 | x = SPPIDLabelLocation.X2; |
||
2150 | |||
2151 | if (location.HasFlag(Location.Down)) |
||
2152 | y = SPPIDLabelLocation.Y1; |
||
2153 | else if (location.HasFlag(Location.Up)) |
||
2154 | y = SPPIDLabelLocation.Y2; |
||
2155 | } |
||
2156 | } |
||
2157 | 5a4b8f32 | gaqhf | |
2158 | 74752074 | gaqhf | /// <summary> |
2159 | /// ComObject를 Release |
||
2160 | /// </summary> |
||
2161 | /// <param name="objVars"></param> |
||
2162 | 5a4b8f32 | gaqhf | public void ReleaseCOMObjects(params object[] objVars) |
2163 | { |
||
2164 | int intNewRefCount = 0; |
||
2165 | foreach (object obj in objVars) |
||
2166 | { |
||
2167 | if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
||
2168 | intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
||
2169 | } |
||
2170 | } |
||
2171 | cfda1fed | gaqhf | } |
2172 | } |