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