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