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