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