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