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