hytos / DTI_PID / SPPIDConverter / AutoModeling.cs @ bd1985ec
이력 | 보기 | 이력해설 | 다운로드 (219 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 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
1063 | 809a7640 | gaqhf | |
1064 | 7f00b26c | gaqhf | if (_LMSymbol != null && _TargetItem != null) |
1065 | 6a7573b0 | gaqhf | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
1066 | ac78b508 | gaqhf | |
1067 | 7f00b26c | gaqhf | ReleaseCOMObjects(_TargetItem); |
1068 | 4d2571ab | gaqhf | } |
1069 | 7f00b26c | gaqhf | else |
1070 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1071 | |||
1072 | if (_LMSymbol != null) |
||
1073 | 4d2571ab | gaqhf | { |
1074 | 7f00b26c | gaqhf | _LMSymbol.Commit(); |
1075 | 60f4405d | gaqhf | |
1076 | // ConnCheck |
||
1077 | List<string> ids = new List<string>(); |
||
1078 | foreach (LMConnector item in _LMSymbol.Connect1Connectors) |
||
1079 | { |
||
1080 | if (item.get_ItemStatus() == "Active" && !ids.Contains(item.Id)) |
||
1081 | ids.Add(item.Id); |
||
1082 | ReleaseCOMObjects(item); |
||
1083 | } |
||
1084 | foreach (LMConnector item in _LMSymbol.Connect2Connectors) |
||
1085 | { |
||
1086 | if (item.get_ItemStatus() == "Active" && !ids.Contains(item.Id)) |
||
1087 | ids.Add(item.Id); |
||
1088 | ReleaseCOMObjects(item); |
||
1089 | } |
||
1090 | |||
1091 | int createdSymbolCount = document.SYMBOLS.FindAll(i => i.CONNECTORS.Find(j => j.CONNECTEDITEM == symbol.UID) != null && !string.IsNullOrEmpty(i.SPPID.RepresentationId)).Count; |
||
1092 | if (targetSymbol == null && ids.Count != createdSymbolCount) |
||
1093 | { |
||
1094 | double currentX = _LMSymbol.get_XCoordinate(); |
||
1095 | double currentY = _LMSymbol.get_YCoordinate(); |
||
1096 | |||
1097 | |||
1098 | } |
||
1099 | |||
1100 | 7f00b26c | gaqhf | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
1101 | symbol.SPPID.ModelItemID = _LMSymbol.ModelItemID; |
||
1102 | 32205389 | gaqhf | symbol.SPPID.GraphicOID = _LMSymbol.get_GraphicOID().ToString(); |
1103 | 7f00b26c | gaqhf | |
1104 | foreach (var item in symbol.ChildSymbols) |
||
1105 | 7e4a64a3 | gaqhf | CreateChildSymbol(item, _LMSymbol, symbol); |
1106 | 3734dcc5 | gaqhf | |
1107 | d9794a6c | gaqhf | symbol.SPPID.SPPID_X = _LMSymbol.get_XCoordinate(); |
1108 | symbol.SPPID.SPPID_Y = _LMSymbol.get_YCoordinate(); |
||
1109 | |||
1110 | double[] range = null; |
||
1111 | GetSPPIDSymbolRange(symbol, ref range); |
||
1112 | symbol.SPPID.SPPID_Min_X = range[0]; |
||
1113 | symbol.SPPID.SPPID_Min_Y = range[1]; |
||
1114 | symbol.SPPID.SPPID_Max_X = range[2]; |
||
1115 | symbol.SPPID.SPPID_Max_Y = range[3]; |
||
1116 | |||
1117 | foreach (var item in symbol.SPPID.CorrectionX_GroupSymbols) |
||
1118 | item.SPPID.ORIGINAL_X = symbol.SPPID.SPPID_X; |
||
1119 | foreach (var item in symbol.SPPID.CorrectionY_GroupSymbols) |
||
1120 | item.SPPID.ORIGINAL_Y = symbol.SPPID.SPPID_Y; |
||
1121 | |||
1122 | 3734dcc5 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1123 | 4d2571ab | gaqhf | } |
1124 | 809a7640 | gaqhf | } |
1125 | |||
1126 | d9794a6c | gaqhf | private void RemoveSymbol(Symbol symbol) |
1127 | { |
||
1128 | if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
1129 | { |
||
1130 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1131 | if (_LMSymbol != null) |
||
1132 | { |
||
1133 | _placement.PIDRemovePlacement(_LMSymbol.AsLMRepresentation()); |
||
1134 | ReleaseCOMObjects(_LMSymbol); |
||
1135 | } |
||
1136 | } |
||
1137 | |||
1138 | symbol.SPPID.RepresentationId = string.Empty; |
||
1139 | symbol.SPPID.ModelItemID = string.Empty; |
||
1140 | symbol.SPPID.SPPID_X = double.NaN; |
||
1141 | symbol.SPPID.SPPID_Y = double.NaN; |
||
1142 | symbol.SPPID.SPPID_Min_X = double.NaN; |
||
1143 | symbol.SPPID.SPPID_Min_Y = double.NaN; |
||
1144 | symbol.SPPID.SPPID_Max_X = double.NaN; |
||
1145 | symbol.SPPID.SPPID_Max_Y = double.NaN; |
||
1146 | } |
||
1147 | |||
1148 | private void RemoveSymbol(List<Symbol> symbols) |
||
1149 | { |
||
1150 | foreach (var symbol in symbols) |
||
1151 | { |
||
1152 | if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
1153 | { |
||
1154 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1155 | if (_LMSymbol != null) |
||
1156 | { |
||
1157 | _placement.PIDRemovePlacement(_LMSymbol.AsLMRepresentation()); |
||
1158 | ReleaseCOMObjects(_LMSymbol); |
||
1159 | } |
||
1160 | } |
||
1161 | |||
1162 | symbol.SPPID.RepresentationId = string.Empty; |
||
1163 | symbol.SPPID.ModelItemID = string.Empty; |
||
1164 | symbol.SPPID.SPPID_X = double.NaN; |
||
1165 | symbol.SPPID.SPPID_Y = double.NaN; |
||
1166 | symbol.SPPID.SPPID_Min_X = double.NaN; |
||
1167 | symbol.SPPID.SPPID_Min_Y = double.NaN; |
||
1168 | symbol.SPPID.SPPID_Max_X = double.NaN; |
||
1169 | symbol.SPPID.SPPID_Max_Y = double.NaN; |
||
1170 | } |
||
1171 | } |
||
1172 | |||
1173 | d1eac84d | gaqhf | /// <summary> |
1174 | /// ID2의 Symbol Width와 Height를 비교해서 상대적인 SPPID Connector좌표를 가져온다. |
||
1175 | /// </summary> |
||
1176 | /// <param name="targetConnector"></param> |
||
1177 | /// <param name="targetSymbol"></param> |
||
1178 | /// <param name="x"></param> |
||
1179 | /// <param name="y"></param> |
||
1180 | private void GetTargetSymbolConnectorPoint(Connector targetConnector, Symbol targetSymbol, ref double x, ref double y) |
||
1181 | { |
||
1182 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
1183 | 2fdb56bf | gaqhf | |
1184 | double[] range = null; |
||
1185 | d1eac84d | gaqhf | List<double[]> points = new List<double[]>(); |
1186 | 2fdb56bf | gaqhf | GetSPPIDSymbolRangeAndConnectionPoints(targetSymbol, ref range, points); |
1187 | double x1 = range[0]; |
||
1188 | double y1 = range[1]; |
||
1189 | double x2 = range[2]; |
||
1190 | double y2 = range[3]; |
||
1191 | d1eac84d | gaqhf | |
1192 | // Origin 기준 Connector의 위치차이 |
||
1193 | double sceneX = 0; |
||
1194 | double sceneY = 0; |
||
1195 | SPPIDUtil.ConvertPointBystring(targetConnector.SCENECONNECTPOINT, ref sceneX, ref sceneY); |
||
1196 | double originX = 0; |
||
1197 | double originY = 0; |
||
1198 | SPPIDUtil.ConvertPointBystring(targetSymbol.ORIGINALPOINT, ref originX, ref originY); |
||
1199 | double gapX = originX - sceneX; |
||
1200 | double gapY = originY - sceneY; |
||
1201 | |||
1202 | // SPPID Symbol과 ID2 심볼의 크기 차이 |
||
1203 | 026f394f | gaqhf | double sizeWidth = 0; |
1204 | double sizeHeight = 0; |
||
1205 | SPPIDUtil.ConvertPointBystring(targetSymbol.SIZE, ref sizeWidth, ref sizeHeight); |
||
1206 | if (sizeWidth == 0 || sizeHeight == 0) |
||
1207 | throw new Exception("Check symbol size! \r\nUID : " + targetSymbol.UID); |
||
1208 | |||
1209 | d1eac84d | gaqhf | double percentX = (x2 - x1) / sizeWidth; |
1210 | double percentY = (y2 - y1) / sizeHeight; |
||
1211 | |||
1212 | double SPPIDgapX = gapX * percentX; |
||
1213 | double SPPIDgapY = gapY * percentY; |
||
1214 | |||
1215 | double[] SPPIDOriginPoint = new double[] { _TargetItem.get_XCoordinate() - SPPIDgapX, _TargetItem.get_YCoordinate() + SPPIDgapY }; |
||
1216 | double distance = double.MaxValue; |
||
1217 | double[] resultPoint; |
||
1218 | foreach (var point in points) |
||
1219 | { |
||
1220 | double result = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], SPPIDOriginPoint[0], SPPIDOriginPoint[1]); |
||
1221 | if (distance > result) |
||
1222 | { |
||
1223 | distance = result; |
||
1224 | resultPoint = point; |
||
1225 | x = point[0]; |
||
1226 | y = point[1]; |
||
1227 | } |
||
1228 | } |
||
1229 | 2fdb56bf | gaqhf | |
1230 | ReleaseCOMObjects(_TargetItem); |
||
1231 | } |
||
1232 | |||
1233 | a0e3dca4 | gaqhf | private void GetTargetLineConnectorPoint(Connector targetConnector, Line targetLine, ref double x, ref double y) |
1234 | { |
||
1235 | int index = targetLine.CONNECTORS.IndexOf(targetConnector); |
||
1236 | if (index == 0) |
||
1237 | { |
||
1238 | x = targetLine.SPPID.START_X; |
||
1239 | y = targetLine.SPPID.START_Y; |
||
1240 | } |
||
1241 | else |
||
1242 | { |
||
1243 | x = targetLine.SPPID.END_X; |
||
1244 | y = targetLine.SPPID.END_Y; |
||
1245 | } |
||
1246 | } |
||
1247 | |||
1248 | 2fdb56bf | gaqhf | /// <summary> |
1249 | /// SPPID Symbol의 Range를 구한다. |
||
1250 | /// </summary> |
||
1251 | /// <param name="symbol"></param> |
||
1252 | /// <param name="range"></param> |
||
1253 | private void GetSPPIDSymbolRangeAndConnectionPoints(Symbol symbol, ref double[] range, List<double[]> points) |
||
1254 | { |
||
1255 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1256 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
1257 | double x1 = 0; |
||
1258 | double y1 = 0; |
||
1259 | double x2 = 0; |
||
1260 | double y2 = 0; |
||
1261 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1262 | range = new double[] { x1, y1, x2, y2 }; |
||
1263 | |||
1264 | for (int i = 1; i < int.MaxValue; i++) |
||
1265 | { |
||
1266 | double connX = 0; |
||
1267 | double connY = 0; |
||
1268 | if (_placement.PIDConnectPointLocation(_TargetItem, i, ref connX, ref connY)) |
||
1269 | points.Add(new double[] { connX, connY }); |
||
1270 | else |
||
1271 | break; |
||
1272 | } |
||
1273 | |||
1274 | foreach (var childSymbol in symbol.ChildSymbols) |
||
1275 | GetSPPIDChildSymbolRange(childSymbol, ref range, points); |
||
1276 | |||
1277 | ReleaseCOMObjects(_TargetItem); |
||
1278 | } |
||
1279 | |||
1280 | d9794a6c | gaqhf | private void GetSPPIDSymbolRange(Symbol symbol, ref double[] range) |
1281 | { |
||
1282 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1283 | 7e4a64a3 | gaqhf | if (_TargetItem != null) |
1284 | { |
||
1285 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
1286 | double x1 = 0; |
||
1287 | double y1 = 0; |
||
1288 | double x2 = 0; |
||
1289 | double y2 = 0; |
||
1290 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1291 | range = new double[] { x1, y1, x2, y2 }; |
||
1292 | d9794a6c | gaqhf | |
1293 | 7e4a64a3 | gaqhf | foreach (var childSymbol in symbol.ChildSymbols) |
1294 | GetSPPIDChildSymbolRange(childSymbol, ref range); |
||
1295 | d9794a6c | gaqhf | |
1296 | 7e4a64a3 | gaqhf | ReleaseCOMObjects(_TargetItem); |
1297 | } |
||
1298 | d9794a6c | gaqhf | } |
1299 | |||
1300 | 1299077b | gaqhf | private void GetSPPIDSymbolRange(LMLabelPersist labelPersist, ref double[] range) |
1301 | { |
||
1302 | if (labelPersist != null) |
||
1303 | { |
||
1304 | Ingr.RAD2D.DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[labelPersist.get_GraphicOID().ToString()] as DependencyObject; |
||
1305 | if (dependency != null) |
||
1306 | { |
||
1307 | double x1 = 0; |
||
1308 | double y1 = 0; |
||
1309 | double x2 = 0; |
||
1310 | double y2 = 0; |
||
1311 | dependency.Range(out x1, out y1, out x2, out y2); |
||
1312 | range = new double[] { x1, y1, x2, y2 }; |
||
1313 | } |
||
1314 | } |
||
1315 | } |
||
1316 | |||
1317 | d9794a6c | gaqhf | private void GetSPPIDSymbolRange(List<Symbol> symbols, ref double[] range) |
1318 | { |
||
1319 | double[] tempRange = new double[] { double.MaxValue, double.MaxValue, double.MinValue, double.MinValue }; |
||
1320 | foreach (var symbol in symbols) |
||
1321 | { |
||
1322 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1323 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
1324 | double x1 = 0; |
||
1325 | double y1 = 0; |
||
1326 | double x2 = 0; |
||
1327 | double y2 = 0; |
||
1328 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1329 | |||
1330 | tempRange[0] = Math.Min(tempRange[0], x1); |
||
1331 | tempRange[1] = Math.Min(tempRange[1], y1); |
||
1332 | tempRange[2] = Math.Max(tempRange[2], x2); |
||
1333 | tempRange[3] = Math.Max(tempRange[3], y2); |
||
1334 | |||
1335 | foreach (var childSymbol in symbol.ChildSymbols) |
||
1336 | f1a7faf9 | gaqhf | GetSPPIDChildSymbolRange(childSymbol, ref tempRange); |
1337 | d9794a6c | gaqhf | |
1338 | ReleaseCOMObjects(_TargetItem); |
||
1339 | } |
||
1340 | |||
1341 | range = tempRange; |
||
1342 | } |
||
1343 | |||
1344 | 2fdb56bf | gaqhf | /// <summary> |
1345 | /// Child Modeling 된 Symbol의 Range를 구한다. |
||
1346 | /// </summary> |
||
1347 | /// <param name="childSymbol"></param> |
||
1348 | /// <param name="range"></param> |
||
1349 | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range, List<double[]> points) |
||
1350 | { |
||
1351 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
1352 | 3783c494 | gaqhf | if (_ChildSymbol != null) |
1353 | 2fdb56bf | gaqhf | { |
1354 | 3783c494 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
1355 | double x1 = 0; |
||
1356 | double y1 = 0; |
||
1357 | double x2 = 0; |
||
1358 | double y2 = 0; |
||
1359 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1360 | range[0] = Math.Min(range[0], x1); |
||
1361 | range[1] = Math.Min(range[1], y1); |
||
1362 | range[2] = Math.Max(range[2], x2); |
||
1363 | range[3] = Math.Max(range[3], y2); |
||
1364 | |||
1365 | for (int i = 1; i < int.MaxValue; i++) |
||
1366 | { |
||
1367 | double connX = 0; |
||
1368 | double connY = 0; |
||
1369 | if (_placement.PIDConnectPointLocation(_ChildSymbol, i, ref connX, ref connY)) |
||
1370 | points.Add(new double[] { connX, connY }); |
||
1371 | else |
||
1372 | break; |
||
1373 | } |
||
1374 | 2fdb56bf | gaqhf | |
1375 | 3783c494 | gaqhf | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
1376 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range, points); |
||
1377 | 2fdb56bf | gaqhf | |
1378 | 3783c494 | gaqhf | ReleaseCOMObjects(_ChildSymbol); |
1379 | } |
||
1380 | d1eac84d | gaqhf | } |
1381 | |||
1382 | d9794a6c | gaqhf | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range) |
1383 | { |
||
1384 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
1385 | 7e4a64a3 | gaqhf | if (_ChildSymbol != null) |
1386 | { |
||
1387 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
||
1388 | double x1 = 0; |
||
1389 | double y1 = 0; |
||
1390 | double x2 = 0; |
||
1391 | double y2 = 0; |
||
1392 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1393 | range[0] = Math.Min(range[0], x1); |
||
1394 | range[1] = Math.Min(range[1], y1); |
||
1395 | range[2] = Math.Max(range[2], x2); |
||
1396 | range[3] = Math.Max(range[3], y2); |
||
1397 | d9794a6c | gaqhf | |
1398 | 7e4a64a3 | gaqhf | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
1399 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range); |
||
1400 | ReleaseCOMObjects(_ChildSymbol); |
||
1401 | } |
||
1402 | d9794a6c | gaqhf | } |
1403 | |||
1404 | d1eac84d | gaqhf | /// <summary> |
1405 | /// Label Symbol Modeling |
||
1406 | /// </summary> |
||
1407 | /// <param name="symbol"></param> |
||
1408 | 73415441 | gaqhf | private void LabelSymbolModeling(Symbol symbol) |
1409 | { |
||
1410 | fb386b8c | gaqhf | if (string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
1411 | 73415441 | gaqhf | { |
1412 | fb386b8c | gaqhf | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
1413 | if (itemAttribute == null || string.IsNullOrEmpty(itemAttribute.VALUE) || itemAttribute.VALUE == "None") |
||
1414 | return; |
||
1415 | Array points = new double[] { 0, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y }; |
||
1416 | |||
1417 | string symbolUID = itemAttribute.VALUE; |
||
1418 | object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
||
1419 | if (targetItem != null && |
||
1420 | (targetItem.GetType() == typeof(Symbol) || |
||
1421 | targetItem.GetType() == typeof(Equipment))) |
||
1422 | 73415441 | gaqhf | { |
1423 | fb386b8c | gaqhf | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
1424 | string sRep = null; |
||
1425 | if (targetItem.GetType() == typeof(Symbol)) |
||
1426 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
1427 | else if (targetItem.GetType() == typeof(Equipment)) |
||
1428 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
1429 | if (!string.IsNullOrEmpty(sRep)) |
||
1430 | 73415441 | gaqhf | { |
1431 | fb386b8c | gaqhf | // LEADER Line 검사 |
1432 | bool leaderLine = false; |
||
1433 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
1434 | if (symbolMapping != null) |
||
1435 | leaderLine = symbolMapping.LEADERLINE; |
||
1436 | |||
1437 | // Target Symbol Item 가져오고 Label Modeling |
||
1438 | LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
||
1439 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
1440 | |||
1441 | //Leader 선 센터로 |
||
1442 | if (_LMLabelPresist != null) |
||
1443 | 73415441 | gaqhf | { |
1444 | fb386b8c | gaqhf | // Target Item에 Label의 Attribute Input |
1445 | InputSymbolAttribute(targetItem, symbol.ATTRIBUTES); |
||
1446 | |||
1447 | 32205389 | gaqhf | string OID = _LMLabelPresist.get_GraphicOID().ToString(); |
1448 | fb386b8c | gaqhf | DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
1449 | if (dependency != null) |
||
1450 | 73415441 | gaqhf | { |
1451 | fb386b8c | gaqhf | bool result = false; |
1452 | foreach (var attributes in dependency.AttributeSets) |
||
1453 | 73415441 | gaqhf | { |
1454 | fb386b8c | gaqhf | foreach (var attribute in attributes) |
1455 | 73415441 | gaqhf | { |
1456 | fb386b8c | gaqhf | string name = attribute.Name; |
1457 | string value = attribute.GetValue().ToString(); |
||
1458 | if (name == "DrawingItemType" && value == "LabelPersist") |
||
1459 | 73415441 | gaqhf | { |
1460 | fb386b8c | gaqhf | foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
1461 | b2d1c1aa | gaqhf | { |
1462 | fb386b8c | gaqhf | if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
1463 | { |
||
1464 | Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
||
1465 | double prevX = _TargetItem.get_XCoordinate(); |
||
1466 | double prevY = _TargetItem.get_YCoordinate(); |
||
1467 | lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
||
1468 | lineString2D.RemoveVertex(lineString2D.VertexCount); |
||
1469 | result = true; |
||
1470 | break; |
||
1471 | } |
||
1472 | b2d1c1aa | gaqhf | } |
1473 | 73415441 | gaqhf | } |
1474 | fb386b8c | gaqhf | |
1475 | if (result) |
||
1476 | break; |
||
1477 | 73415441 | gaqhf | } |
1478 | b2d1c1aa | gaqhf | |
1479 | if (result) |
||
1480 | break; |
||
1481 | 73415441 | gaqhf | } |
1482 | } |
||
1483 | fb386b8c | gaqhf | |
1484 | 30ba9ae0 | gaqhf | symbol.SPPID.RepresentationId = _LMLabelPresist.AsLMRepresentation().Id; |
1485 | fb386b8c | gaqhf | _LMLabelPresist.Commit(); |
1486 | ReleaseCOMObjects(_LMLabelPresist); |
||
1487 | 73415441 | gaqhf | } |
1488 | |||
1489 | fb386b8c | gaqhf | ReleaseCOMObjects(_TargetItem); |
1490 | b2d1c1aa | gaqhf | } |
1491 | 73415441 | gaqhf | } |
1492 | fb386b8c | gaqhf | else if (targetItem != null && targetItem.GetType() == typeof(Line)) |
1493 | 0860c756 | gaqhf | { |
1494 | fb386b8c | gaqhf | Line targetLine = targetItem as Line; |
1495 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(targetLine.SPPID.ModelItemId); |
||
1496 | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y); |
||
1497 | if (connectedLMConnector != null) |
||
1498 | 0860c756 | gaqhf | { |
1499 | fb386b8c | gaqhf | // LEADER Line 검사 |
1500 | bool leaderLine = false; |
||
1501 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
1502 | if (symbolMapping != null) |
||
1503 | leaderLine = symbolMapping.LEADERLINE; |
||
1504 | |||
1505 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
1506 | if (_LMLabelPresist != null) |
||
1507 | { |
||
1508 | 6db0e733 | gaqhf | symbol.SPPID.RepresentationId = _LMLabelPresist.AsLMRepresentation().Id; |
1509 | fb386b8c | gaqhf | _LMLabelPresist.Commit(); |
1510 | ReleaseCOMObjects(_LMLabelPresist); |
||
1511 | } |
||
1512 | ReleaseCOMObjects(connectedLMConnector); |
||
1513 | 0860c756 | gaqhf | } |
1514 | |||
1515 | fb386b8c | gaqhf | foreach (var item in connectorVertices) |
1516 | if (item.Key != null) |
||
1517 | ReleaseCOMObjects(item.Key); |
||
1518 | } |
||
1519 | 0860c756 | gaqhf | } |
1520 | 73415441 | gaqhf | } |
1521 | |||
1522 | 74752074 | gaqhf | /// <summary> |
1523 | /// Equipment를 실제로 Modeling 메서드 |
||
1524 | /// </summary> |
||
1525 | /// <param name="equipment"></param> |
||
1526 | b9e9f4c8 | gaqhf | private void EquipmentModeling(Equipment equipment) |
1527 | { |
||
1528 | if (!string.IsNullOrEmpty(equipment.SPPID.RepresentationId)) |
||
1529 | return; |
||
1530 | |||
1531 | LMSymbol _LMSymbol = null; |
||
1532 | LMSymbol targetItem = null; |
||
1533 | string mappingPath = equipment.SPPID.MAPPINGNAME; |
||
1534 | double x = equipment.SPPID.ORIGINAL_X; |
||
1535 | double y = equipment.SPPID.ORIGINAL_Y; |
||
1536 | int mirror = 0; |
||
1537 | double angle = equipment.ANGLE; |
||
1538 | |||
1539 | 20972c61 | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
1540 | |||
1541 | b9e9f4c8 | gaqhf | Connector connector = equipment.CONNECTORS.Find(conn => !string.IsNullOrEmpty(conn.CONNECTEDITEM) && conn.CONNECTEDITEM != "None"); |
1542 | if (connector != null) |
||
1543 | { |
||
1544 | Equipment connEquipment = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Equipment; |
||
1545 | if (connEquipment != null) |
||
1546 | { |
||
1547 | if (string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
1548 | EquipmentModeling(connEquipment); |
||
1549 | |||
1550 | if (!string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
1551 | { |
||
1552 | targetItem = dataSource.GetSymbol(connEquipment.SPPID.RepresentationId); |
||
1553 | if (targetItem != null) |
||
1554 | { |
||
1555 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: targetItem); |
||
1556 | } |
||
1557 | else |
||
1558 | { |
||
1559 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1560 | } |
||
1561 | } |
||
1562 | else |
||
1563 | { |
||
1564 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1565 | } |
||
1566 | } |
||
1567 | else |
||
1568 | { |
||
1569 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1570 | } |
||
1571 | } |
||
1572 | else |
||
1573 | { |
||
1574 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1575 | } |
||
1576 | |||
1577 | if (_LMSymbol != null) |
||
1578 | { |
||
1579 | _LMSymbol.Commit(); |
||
1580 | equipment.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
1581 | 32205389 | gaqhf | equipment.SPPID.GraphicOID = _LMSymbol.get_GraphicOID().ToString(); |
1582 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1583 | } |
||
1584 | |||
1585 | if (targetItem != null) |
||
1586 | { |
||
1587 | ReleaseCOMObjects(targetItem); |
||
1588 | } |
||
1589 | 7f00b26c | gaqhf | |
1590 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1591 | } |
||
1592 | |||
1593 | d9794a6c | gaqhf | /// <summary> |
1594 | /// 첫 진입점 |
||
1595 | /// </summary> |
||
1596 | /// <param name="symbol"></param> |
||
1597 | private void SymbolModelingBySymbol(Symbol symbol) |
||
1598 | { |
||
1599 | 5a9396ae | humkyung | SymbolModeling(symbol, null); /// 심볼을 생성한다 |
1600 | d9794a6c | gaqhf | List<object> endObjects = new List<object>(); |
1601 | endObjects.Add(symbol); |
||
1602 | f1a7faf9 | gaqhf | |
1603 | 5a9396ae | humkyung | /// 심볼에 연결되어 있는 항목들을 모델링한다 |
1604 | d9794a6c | gaqhf | foreach (var connector in symbol.CONNECTORS) |
1605 | 4d2571ab | gaqhf | { |
1606 | d9794a6c | gaqhf | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
1607 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1608 | d1eac84d | gaqhf | { |
1609 | d9794a6c | gaqhf | endObjects.Add(connItem); |
1610 | if (connItem.GetType() == typeof(Symbol)) |
||
1611 | 4d2571ab | gaqhf | { |
1612 | d9794a6c | gaqhf | Symbol connSymbol = connItem as Symbol; |
1613 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1614 | 4d2571ab | gaqhf | { |
1615 | d9794a6c | gaqhf | SymbolModeling(connSymbol, symbol); |
1616 | } |
||
1617 | 6db30942 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
1618 | f1a7faf9 | gaqhf | SymbolModelingByNeerSymbolLoop(connSymbol, endObjects); |
1619 | d9794a6c | gaqhf | } |
1620 | else if (connItem.GetType() == typeof(Line)) |
||
1621 | { |
||
1622 | Line connLine = connItem as Line; |
||
1623 | f1a7faf9 | gaqhf | SymbolModelingByNeerLineLoop(connLine, endObjects, symbol); |
1624 | d9794a6c | gaqhf | } |
1625 | } |
||
1626 | } |
||
1627 | } |
||
1628 | 4d2571ab | gaqhf | |
1629 | f1a7faf9 | gaqhf | private void SymbolModelingByNeerSymbolLoop(Symbol symbol, List<object> endObjects) |
1630 | d9794a6c | gaqhf | { |
1631 | foreach (var connector in symbol.CONNECTORS) |
||
1632 | { |
||
1633 | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
1634 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1635 | { |
||
1636 | if (!endObjects.Contains(connItem)) |
||
1637 | { |
||
1638 | endObjects.Add(connItem); |
||
1639 | if (connItem.GetType() == typeof(Symbol)) |
||
1640 | { |
||
1641 | Symbol connSymbol = connItem as Symbol; |
||
1642 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1643 | 4d2571ab | gaqhf | { |
1644 | d9794a6c | gaqhf | SymbolModeling(connSymbol, symbol); |
1645 | 4d2571ab | gaqhf | } |
1646 | 6db30942 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
1647 | f1a7faf9 | gaqhf | SymbolModelingByNeerSymbolLoop(connSymbol, endObjects); |
1648 | 4d2571ab | gaqhf | } |
1649 | d9794a6c | gaqhf | else if (connItem.GetType() == typeof(Line)) |
1650 | { |
||
1651 | Line connLine = connItem as Line; |
||
1652 | f1a7faf9 | gaqhf | SymbolModelingByNeerLineLoop(connLine, endObjects, symbol); |
1653 | d9794a6c | gaqhf | } |
1654 | } |
||
1655 | } |
||
1656 | } |
||
1657 | } |
||
1658 | 4d2571ab | gaqhf | |
1659 | f1a7faf9 | gaqhf | private void SymbolModelingByNeerLineLoop(Line line, List<object> endObjects, Symbol prevSymbol) |
1660 | d9794a6c | gaqhf | { |
1661 | foreach (var connector in line.CONNECTORS) |
||
1662 | { |
||
1663 | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
1664 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1665 | { |
||
1666 | if (!endObjects.Contains(connItem)) |
||
1667 | { |
||
1668 | endObjects.Add(connItem); |
||
1669 | if (connItem.GetType() == typeof(Symbol)) |
||
1670 | { |
||
1671 | Symbol connSymbol = connItem as Symbol; |
||
1672 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1673 | { |
||
1674 | List<Symbol> group = new List<Symbol>(); |
||
1675 | SPPIDUtil.FindConnectedSymbolGroup(document, connSymbol, group); |
||
1676 | f1a7faf9 | gaqhf | Symbol priority = prioritySymbols.Find(x => group.Contains(x)); |
1677 | List<Symbol> endModelingGroup = new List<Symbol>(); |
||
1678 | if (priority != null) |
||
1679 | d9794a6c | gaqhf | { |
1680 | f1a7faf9 | gaqhf | SymbolGroupModeling(priority, group); |
1681 | d9794a6c | gaqhf | |
1682 | // Range 겹치는지 확인해야함 |
||
1683 | double[] prevRange = null; |
||
1684 | GetSPPIDSymbolRange(prevSymbol, ref prevRange); |
||
1685 | double[] groupRange = null; |
||
1686 | GetSPPIDSymbolRange(group, ref groupRange); |
||
1687 | |||
1688 | double distanceX = 0; |
||
1689 | double distanceY = 0; |
||
1690 | 6d12a734 | gaqhf | bool overlapX = false; |
1691 | bool overlapY = false; |
||
1692 | SlopeType slopeType = SPPIDUtil.CalcSlope(prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y); |
||
1693 | SPPIDUtil.CalcOverlap(prevRange, groupRange, ref distanceX, ref distanceY, ref overlapX, ref overlapY); |
||
1694 | if ((slopeType == SlopeType.HORIZONTAL && overlapX) || |
||
1695 | (slopeType == SlopeType.VERTICAL && overlapY)) |
||
1696 | d9794a6c | gaqhf | { |
1697 | RemoveSymbol(group); |
||
1698 | foreach (var _temp in group) |
||
1699 | SPPIDUtil.CalcNewCoordinateForSymbol(_temp, prevSymbol, distanceX, distanceY); |
||
1700 | |||
1701 | f1a7faf9 | gaqhf | SymbolGroupModeling(priority, group); |
1702 | d9794a6c | gaqhf | } |
1703 | } |
||
1704 | else |
||
1705 | { |
||
1706 | SymbolModeling(connSymbol, null); |
||
1707 | // Range 겹치는지 확인해야함 |
||
1708 | double[] prevRange = null; |
||
1709 | GetSPPIDSymbolRange(prevSymbol, ref prevRange); |
||
1710 | double[] connRange = null; |
||
1711 | GetSPPIDSymbolRange(connSymbol, ref connRange); |
||
1712 | |||
1713 | double distanceX = 0; |
||
1714 | double distanceY = 0; |
||
1715 | 6d12a734 | gaqhf | bool overlapX = false; |
1716 | bool overlapY = false; |
||
1717 | SlopeType slopeType = SPPIDUtil.CalcSlope(prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y); |
||
1718 | SPPIDUtil.CalcOverlap(prevRange, connRange, ref distanceX, ref distanceY, ref overlapX, ref overlapY); |
||
1719 | if ((slopeType == SlopeType.HORIZONTAL && overlapX) || |
||
1720 | (slopeType == SlopeType.VERTICAL && overlapY)) |
||
1721 | d9794a6c | gaqhf | { |
1722 | RemoveSymbol(connSymbol); |
||
1723 | SPPIDUtil.CalcNewCoordinateForSymbol(connSymbol, prevSymbol, distanceX, distanceY); |
||
1724 | |||
1725 | SymbolModeling(connSymbol, null); |
||
1726 | } |
||
1727 | } |
||
1728 | } |
||
1729 | 6db30942 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
1730 | f1a7faf9 | gaqhf | SymbolModelingByNeerSymbolLoop(connSymbol, endObjects); |
1731 | d9794a6c | gaqhf | } |
1732 | else if (connItem.GetType() == typeof(Line)) |
||
1733 | { |
||
1734 | Line connLine = connItem as Line; |
||
1735 | if (!SPPIDUtil.IsBranchLine(connLine, line)) |
||
1736 | f1a7faf9 | gaqhf | SymbolModelingByNeerLineLoop(connLine, endObjects, prevSymbol); |
1737 | d9794a6c | gaqhf | } |
1738 | 4d2571ab | gaqhf | } |
1739 | d1eac84d | gaqhf | } |
1740 | } |
||
1741 | } |
||
1742 | |||
1743 | f1a7faf9 | gaqhf | private void SymbolGroupModeling(Symbol firstSymbol, List<Symbol> group) |
1744 | { |
||
1745 | List<Symbol> endModelingGroup = new List<Symbol>(); |
||
1746 | SymbolModeling(firstSymbol, null); |
||
1747 | endModelingGroup.Add(firstSymbol); |
||
1748 | while (endModelingGroup.Count != group.Count) |
||
1749 | { |
||
1750 | foreach (var _symbol in group) |
||
1751 | { |
||
1752 | if (!endModelingGroup.Contains(_symbol)) |
||
1753 | { |
||
1754 | foreach (var _connector in _symbol.CONNECTORS) |
||
1755 | { |
||
1756 | Symbol _connSymbol = SPPIDUtil.FindObjectByUID(document, _connector.CONNECTEDITEM) as Symbol; |
||
1757 | if (_connSymbol != null && endModelingGroup.Contains(_connSymbol)) |
||
1758 | { |
||
1759 | SymbolModeling(_symbol, _connSymbol); |
||
1760 | endModelingGroup.Add(_symbol); |
||
1761 | break; |
||
1762 | } |
||
1763 | } |
||
1764 | } |
||
1765 | } |
||
1766 | } |
||
1767 | } |
||
1768 | d9794a6c | gaqhf | |
1769 | d1eac84d | gaqhf | /// <summary> |
1770 | 74752074 | gaqhf | /// 심볼을 실제로 Modeling할때 ChildSymbol이 있다면 Modeling하는 메서드 |
1771 | /// </summary> |
||
1772 | /// <param name="childSymbol"></param> |
||
1773 | /// <param name="parentSymbol"></param> |
||
1774 | 7e4a64a3 | gaqhf | private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol, Symbol parent) |
1775 | ac78b508 | gaqhf | { |
1776 | 4b4dbca9 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()]; |
1777 | double x1 = 0; |
||
1778 | double x2 = 0; |
||
1779 | double y1 = 0; |
||
1780 | double y2 = 0; |
||
1781 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1782 | |||
1783 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, (x1 + x2) / 2, (y1 + y2) / 2, TargetItem: parentSymbol); |
||
1784 | if (_LMSymbol != null) |
||
1785 | { |
||
1786 | 04fcadf1 | gaqhf | _LMSymbol.Commit(); |
1787 | 4b4dbca9 | gaqhf | childSymbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
1788 | foreach (var item in childSymbol.ChildSymbols) |
||
1789 | 7e4a64a3 | gaqhf | CreateChildSymbol(item, _LMSymbol, parent); |
1790 | 4b4dbca9 | gaqhf | } |
1791 | 7f00b26c | gaqhf | |
1792 | ac78b508 | gaqhf | |
1793 | ReleaseCOMObjects(_LMSymbol); |
||
1794 | } |
||
1795 | dec9ecfd | gaqhf | double index = 0; |
1796 | 32205389 | gaqhf | private void NewLineModeling(Line line, bool isBranchModeling = false) |
1797 | 809a7640 | gaqhf | { |
1798 | f3e2693f | gaqhf | if (!string.IsNullOrEmpty(line.SPPID.ModelItemId) || (BranchLines.Contains(line) && !isBranchModeling)) |
1799 | a0e3dca4 | gaqhf | return; |
1800 | |||
1801 | List<Line> group = new List<Line>(); |
||
1802 | GetConnectedLineGroup(line, group); |
||
1803 | LineCoordinateCorrection(group); |
||
1804 | |||
1805 | foreach (var groupLine in group) |
||
1806 | 809a7640 | gaqhf | { |
1807 | e283d483 | gaqhf | if (!isBranchModeling && SPPIDUtil.IsBranchLine(groupLine)) |
1808 | 5173ba5d | gaqhf | { |
1809 | f3e2693f | gaqhf | BranchLines.Add(groupLine); |
1810 | 5173ba5d | gaqhf | continue; |
1811 | } |
||
1812 | f9cc5190 | gaqhf | |
1813 | 24b5276c | gaqhf | bool diagonal = false; |
1814 | if (groupLine.SlopeType != SlopeType.HORIZONTAL && groupLine.SlopeType != SlopeType.VERTICAL) |
||
1815 | diagonal = true; |
||
1816 | 5173ba5d | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(groupLine.SPPID.MAPPINGNAME); |
1817 | LMSymbol _LMSymbolStart = null; |
||
1818 | LMSymbol _LMSymbolEnd = null; |
||
1819 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1820 | foreach (var connector in groupLine.CONNECTORS) |
||
1821 | 809a7640 | gaqhf | { |
1822 | 5173ba5d | gaqhf | double x = 0; |
1823 | double y = 0; |
||
1824 | GetTargetLineConnectorPoint(connector, groupLine, ref x, ref y); |
||
1825 | if (connector.ConnectedObject == null) |
||
1826 | 809a7640 | gaqhf | { |
1827 | 5173ba5d | gaqhf | placeRunInputs.AddPoint(x, y); |
1828 | a0e3dca4 | gaqhf | } |
1829 | 5173ba5d | gaqhf | else if (connector.ConnectedObject.GetType() == typeof(Symbol)) |
1830 | a0e3dca4 | gaqhf | { |
1831 | 5173ba5d | gaqhf | Symbol targetSymbol = connector.ConnectedObject as Symbol; |
1832 | f9cc5190 | gaqhf | GetTargetSymbolConnectorPoint(targetSymbol.CONNECTORS.Find(z => z.ConnectedObject == groupLine), targetSymbol, ref x, ref y); |
1833 | 5173ba5d | gaqhf | if (groupLine.CONNECTORS.IndexOf(connector) == 0) |
1834 | a0e3dca4 | gaqhf | { |
1835 | 5173ba5d | gaqhf | _LMSymbolStart = GetTargetSymbol(targetSymbol, groupLine); |
1836 | 3783c494 | gaqhf | if (_LMSymbolStart != null) |
1837 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(_LMSymbolStart, x, y, diagonal); |
1838 | 3783c494 | gaqhf | else |
1839 | placeRunInputs.AddPoint(x, y); |
||
1840 | 5173ba5d | gaqhf | } |
1841 | else |
||
1842 | { |
||
1843 | _LMSymbolEnd = GetTargetSymbol(targetSymbol, groupLine); |
||
1844 | 3783c494 | gaqhf | if (_LMSymbolEnd != null) |
1845 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(_LMSymbolEnd, x, y, diagonal); |
1846 | 3783c494 | gaqhf | else |
1847 | placeRunInputs.AddPoint(x, y); |
||
1848 | a0e3dca4 | gaqhf | } |
1849 | 5173ba5d | gaqhf | } |
1850 | else if (connector.ConnectedObject.GetType() == typeof(Line)) |
||
1851 | { |
||
1852 | Line targetLine = connector.ConnectedObject as Line; |
||
1853 | if (!string.IsNullOrEmpty(targetLine.SPPID.ModelItemId)) |
||
1854 | a0e3dca4 | gaqhf | { |
1855 | 5173ba5d | gaqhf | LMConnector targetConnector = FindTargetLMConnectorForBranch(line, targetLine, ref x, ref y); |
1856 | 1c944b34 | gaqhf | if (targetConnector != null) |
1857 | 0ff6e67f | gaqhf | { |
1858 | placeRunInputs.AddConnectorTarget(targetConnector, x, y, diagonal); |
||
1859 | ChangeLineSPPIDCoordinateByConnector(groupLine, targetLine, x, y, false); |
||
1860 | } |
||
1861 | else |
||
1862 | { |
||
1863 | placeRunInputs.AddPoint( x, y); |
||
1864 | ChangeLineSPPIDCoordinateByConnector(groupLine, targetLine, x, y, false); |
||
1865 | } |
||
1866 | a0e3dca4 | gaqhf | } |
1867 | 5173ba5d | gaqhf | else |
1868 | 809a7640 | gaqhf | { |
1869 | 5173ba5d | gaqhf | if (groupLine.CONNECTORS.IndexOf(connector) == 0) |
1870 | a0e3dca4 | gaqhf | { |
1871 | dec9ecfd | gaqhf | index += 0.01; |
1872 | 5173ba5d | gaqhf | if (groupLine.SlopeType == SlopeType.HORIZONTAL) |
1873 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(x, -0.1 - index); |
1874 | 5173ba5d | gaqhf | else if (groupLine.SlopeType == SlopeType.VERTICAL) |
1875 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1876 | 5173ba5d | gaqhf | else |
1877 | ca6e0f51 | gaqhf | { |
1878 | 60f4405d | gaqhf | Line nextLine = groupLine.CONNECTORS[0].ConnectedObject as Line; |
1879 | if (SPPIDUtil.CalcAngle(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y) < 45) |
||
1880 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1881 | 60f4405d | gaqhf | else |
1882 | placeRunInputs.AddPoint(x, -0.1 - index); |
||
1883 | ca6e0f51 | gaqhf | } |
1884 | a0e3dca4 | gaqhf | } |
1885 | 809a7640 | gaqhf | |
1886 | 5173ba5d | gaqhf | placeRunInputs.AddPoint(x, y); |
1887 | 809a7640 | gaqhf | |
1888 | 5173ba5d | gaqhf | if (groupLine.CONNECTORS.IndexOf(connector) == 1) |
1889 | { |
||
1890 | dec9ecfd | gaqhf | index += 0.01; |
1891 | 5173ba5d | gaqhf | if (groupLine.SlopeType == SlopeType.HORIZONTAL) |
1892 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(x, -0.1 - index); |
1893 | 5173ba5d | gaqhf | else if (groupLine.SlopeType == SlopeType.VERTICAL) |
1894 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1895 | 5173ba5d | gaqhf | else |
1896 | ca6e0f51 | gaqhf | { |
1897 | 60f4405d | gaqhf | Line nextLine = groupLine.CONNECTORS[1].ConnectedObject as Line; |
1898 | if (SPPIDUtil.CalcAngle(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y) < 45) |
||
1899 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1900 | 60f4405d | gaqhf | else |
1901 | placeRunInputs.AddPoint(x, -0.1 - index); |
||
1902 | ca6e0f51 | gaqhf | } |
1903 | a0e3dca4 | gaqhf | } |
1904 | 809a7640 | gaqhf | } |
1905 | } |
||
1906 | 5173ba5d | gaqhf | } |
1907 | 809a7640 | gaqhf | |
1908 | 5173ba5d | gaqhf | LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1909 | if (_lMConnector != null) |
||
1910 | { |
||
1911 | 04fcadf1 | gaqhf | _lMConnector.Commit(); |
1912 | 5173ba5d | gaqhf | groupLine.SPPID.ModelItemId = _lMConnector.ModelItemID; |
1913 | fae4f386 | gaqhf | |
1914 | 5173ba5d | gaqhf | bool bRemodelingStart = false; |
1915 | if (_LMSymbolStart != null) |
||
1916 | NeedReModeling(groupLine, _LMSymbolStart, ref bRemodelingStart); |
||
1917 | bool bRemodelingEnd = false; |
||
1918 | if (_LMSymbolEnd != null) |
||
1919 | NeedReModeling(groupLine, _LMSymbolEnd, ref bRemodelingEnd); |
||
1920 | |||
1921 | if (bRemodelingStart || bRemodelingEnd) |
||
1922 | ReModelingLine(groupLine, _lMConnector, _LMSymbolStart, _LMSymbolEnd, bRemodelingStart, bRemodelingEnd); |
||
1923 | 32205389 | gaqhf | |
1924 | FlowMarkModeling(groupLine); |
||
1925 | 8701de36 | gaqhf | LineNumberModelingOnlyOne(groupLine); |
1926 | 32205389 | gaqhf | |
1927 | 5173ba5d | gaqhf | ReleaseCOMObjects(_lMConnector); |
1928 | } |
||
1929 | dec9ecfd | gaqhf | else if (!isBranchModeling) |
1930 | { |
||
1931 | Log.Write("Main Line Modeling : " + groupLine.UID); |
||
1932 | } |
||
1933 | 809a7640 | gaqhf | |
1934 | 5173ba5d | gaqhf | List<object> removeLines = groupLine.CONNECTORS.FindAll(x => |
1935 | x.ConnectedObject != null && |
||
1936 | x.ConnectedObject.GetType() == typeof(Line) && |
||
1937 | !string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)) |
||
1938 | .Select(x => x.ConnectedObject) |
||
1939 | .ToList(); |
||
1940 | 2fdb56bf | gaqhf | |
1941 | 5173ba5d | gaqhf | foreach (var item in removeLines) |
1942 | RemoveLineForModeling(item as Line); |
||
1943 | 5e6ecf05 | gaqhf | |
1944 | 5173ba5d | gaqhf | if (_LMAItem != null) |
1945 | ReleaseCOMObjects(_LMAItem); |
||
1946 | if (placeRunInputs != null) |
||
1947 | ReleaseCOMObjects(placeRunInputs); |
||
1948 | if (_LMSymbolStart != null) |
||
1949 | ReleaseCOMObjects(_LMSymbolStart); |
||
1950 | if (_LMSymbolEnd != null) |
||
1951 | ReleaseCOMObjects(_LMSymbolEnd); |
||
1952 | 5e6ecf05 | gaqhf | |
1953 | f3e2693f | gaqhf | if (isBranchModeling && BranchLines.Contains(groupLine)) |
1954 | BranchLines.Remove(groupLine); |
||
1955 | a0e3dca4 | gaqhf | } |
1956 | } |
||
1957 | 5e6ecf05 | gaqhf | |
1958 | a0e3dca4 | gaqhf | private void RemoveLineForModeling(Line line) |
1959 | { |
||
1960 | LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
||
1961 | if (modelItem != null) |
||
1962 | { |
||
1963 | foreach (LMRepresentation rep in modelItem.Representations) |
||
1964 | { |
||
1965 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
1966 | 7f00b26c | gaqhf | { |
1967 | a0e3dca4 | gaqhf | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
1968 | 32205389 | gaqhf | dynamic OID = rep.get_GraphicOID().ToString(); |
1969 | a0e3dca4 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1970 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1971 | int verticesCount = lineStringGeometry.VertexCount; |
||
1972 | double[] vertices = null; |
||
1973 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
1974 | for (int i = 0; i < verticesCount; i++) |
||
1975 | 7f00b26c | gaqhf | { |
1976 | a0e3dca4 | gaqhf | double x = 0; |
1977 | double y = 0; |
||
1978 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
1979 | 6924abc6 | gaqhf | if (verticesCount == 2 && (x < 0 || y < 0)) |
1980 | a0e3dca4 | gaqhf | _placement.PIDRemovePlacement(rep); |
1981 | c2ec33f5 | gaqhf | } |
1982 | a0e3dca4 | gaqhf | ReleaseCOMObjects(_LMConnector); |
1983 | 5e6ecf05 | gaqhf | } |
1984 | a0e3dca4 | gaqhf | } |
1985 | 7f00b26c | gaqhf | |
1986 | a0e3dca4 | gaqhf | ReleaseCOMObjects(modelItem); |
1987 | } |
||
1988 | } |
||
1989 | |||
1990 | private void GetConnectedLineGroup(Line line, List<Line> group) |
||
1991 | { |
||
1992 | if (!group.Contains(line)) |
||
1993 | group.Add(line); |
||
1994 | foreach (var connector in line.CONNECTORS) |
||
1995 | { |
||
1996 | if (connector.ConnectedObject != null && |
||
1997 | connector.ConnectedObject.GetType() == typeof(Line) && |
||
1998 | !group.Contains(connector.ConnectedObject) && |
||
1999 | string.IsNullOrEmpty(((Line)connector.ConnectedObject).SPPID.ModelItemId)) |
||
2000 | { |
||
2001 | Line connLine = connector.ConnectedObject as Line; |
||
2002 | if (!SPPIDUtil.IsBranchLine(connLine, line)) |
||
2003 | 24515a3a | gaqhf | { |
2004 | if (line.CONNECTORS.IndexOf(connector) == 0) |
||
2005 | group.Insert(0, connLine); |
||
2006 | else |
||
2007 | group.Add(connLine); |
||
2008 | a0e3dca4 | gaqhf | GetConnectedLineGroup(connLine, group); |
2009 | 24515a3a | gaqhf | } |
2010 | 7f00b26c | gaqhf | } |
2011 | } |
||
2012 | a0e3dca4 | gaqhf | } |
2013 | 7f00b26c | gaqhf | |
2014 | a0e3dca4 | gaqhf | private void LineCoordinateCorrection(List<Line> group) |
2015 | { |
||
2016 | // 순서대로 전 Item 기준 정렬 |
||
2017 | LineCoordinateCorrectionByStart(group); |
||
2018 | |||
2019 | // 역으로 심볼이 있을 경우 좌표 보정 |
||
2020 | LineCoordinateCorrectionForLastLine(group); |
||
2021 | } |
||
2022 | |||
2023 | private void LineCoordinateCorrectionByStart(List<Line> group) |
||
2024 | { |
||
2025 | for (int i = 0; i < group.Count; i++) |
||
2026 | 7f00b26c | gaqhf | { |
2027 | a0e3dca4 | gaqhf | Line line = group[i]; |
2028 | if (i == 0) |
||
2029 | 7f00b26c | gaqhf | { |
2030 | a0e3dca4 | gaqhf | Connector symbolConnector = line.CONNECTORS.Find(x => x.ConnectedObject != null && x.ConnectedObject.GetType() == typeof(Symbol)); |
2031 | if (symbolConnector != null) |
||
2032 | LineCoordinateCorrectionByConnItem(line, symbolConnector.ConnectedObject); |
||
2033 | 7f00b26c | gaqhf | } |
2034 | a0e3dca4 | gaqhf | else if (i != 0) |
2035 | 7f00b26c | gaqhf | { |
2036 | a0e3dca4 | gaqhf | LineCoordinateCorrectionByConnItem(line, group[i - 1]); |
2037 | } |
||
2038 | } |
||
2039 | } |
||
2040 | b66a2996 | gaqhf | |
2041 | a0e3dca4 | gaqhf | private void LineCoordinateCorrectionForLastLine(List<Line> group) |
2042 | { |
||
2043 | Line checkLine = group[group.Count - 1]; |
||
2044 | Connector lastSymbolConnector = checkLine.CONNECTORS.Find(x => x.ConnectedObject != null && x.ConnectedObject.GetType() == typeof(Symbol)); |
||
2045 | if (lastSymbolConnector != null) |
||
2046 | { |
||
2047 | LineCoordinateCorrectionByConnItem(checkLine, lastSymbolConnector.ConnectedObject); |
||
2048 | for (int i = group.Count - 2; i >= 0; i--) |
||
2049 | { |
||
2050 | Line line = group[i + 1]; |
||
2051 | Line prevLine = group[i]; |
||
2052 | 0bbd73b5 | gaqhf | |
2053 | a0e3dca4 | gaqhf | // 같으면 보정 |
2054 | if (line.SlopeType == prevLine.SlopeType) |
||
2055 | LineCoordinateCorrectionByConnItem(prevLine, line); |
||
2056 | else |
||
2057 | c2ec33f5 | gaqhf | { |
2058 | a0e3dca4 | gaqhf | if (line.SlopeType == SlopeType.HORIZONTAL) |
2059 | d63050d6 | gaqhf | { |
2060 | a0e3dca4 | gaqhf | double prevX = 0; |
2061 | double prevY = 0; |
||
2062 | GetTargetLineConnectorPoint(prevLine.CONNECTORS.Find(z => z.ConnectedObject == line), prevLine, ref prevX, ref prevY); |
||
2063 | ChangeLineSPPIDCoordinateByConnectorOnlyX(line, prevLine, prevX); |
||
2064 | d63050d6 | gaqhf | |
2065 | a0e3dca4 | gaqhf | double x = 0; |
2066 | double y = 0; |
||
2067 | GetTargetLineConnectorPoint(line.CONNECTORS.Find(z => z.ConnectedObject == prevLine), line, ref x, ref y); |
||
2068 | ChangeLineSPPIDCoordinateByConnectorOnlyY(prevLine, line, y); |
||
2069 | d63050d6 | gaqhf | } |
2070 | a0e3dca4 | gaqhf | else if (line.SlopeType == SlopeType.VERTICAL) |
2071 | d63050d6 | gaqhf | { |
2072 | a0e3dca4 | gaqhf | double prevX = 0; |
2073 | double prevY = 0; |
||
2074 | GetTargetLineConnectorPoint(prevLine.CONNECTORS.Find(z => z.ConnectedObject == line), prevLine, ref prevX, ref prevY); |
||
2075 | ChangeLineSPPIDCoordinateByConnectorOnlyY(line, prevLine, prevY); |
||
2076 | d63050d6 | gaqhf | |
2077 | a0e3dca4 | gaqhf | double x = 0; |
2078 | double y = 0; |
||
2079 | GetTargetLineConnectorPoint(line.CONNECTORS.Find(z => z.ConnectedObject == prevLine), line, ref x, ref y); |
||
2080 | ChangeLineSPPIDCoordinateByConnectorOnlyX(prevLine, line, x); |
||
2081 | d63050d6 | gaqhf | } |
2082 | a0e3dca4 | gaqhf | break; |
2083 | c2ec33f5 | gaqhf | } |
2084 | 1ab9a205 | gaqhf | } |
2085 | c2ec33f5 | gaqhf | } |
2086 | a0e3dca4 | gaqhf | } |
2087 | 7f00b26c | gaqhf | |
2088 | a0e3dca4 | gaqhf | private void LineCoordinateCorrectionByConnItem(Line line, object connItem) |
2089 | { |
||
2090 | double x = 0; |
||
2091 | double y = 0; |
||
2092 | if (connItem.GetType() == typeof(Symbol)) |
||
2093 | { |
||
2094 | Symbol targetSymbol = connItem as Symbol; |
||
2095 | Connector targetConnector = targetSymbol.CONNECTORS.Find(z => z.ConnectedObject == line); |
||
2096 | if (targetConnector != null) |
||
2097 | GetTargetSymbolConnectorPoint(targetConnector, targetSymbol, ref x, ref y); |
||
2098 | else |
||
2099 | throw new Exception("Target symbol UID : " + targetSymbol.UID + "\r\nLine UID : " + line.UID); |
||
2100 | } |
||
2101 | else if (connItem.GetType() == typeof(Line)) |
||
2102 | c2ec33f5 | gaqhf | { |
2103 | a0e3dca4 | gaqhf | Line targetLine = connItem as Line; |
2104 | GetTargetLineConnectorPoint(targetLine.CONNECTORS.Find(z => z.ConnectedObject == line), targetLine, ref x, ref y); |
||
2105 | } |
||
2106 | 7f00b26c | gaqhf | |
2107 | a0e3dca4 | gaqhf | ChangeLineSPPIDCoordinateByConnector(line, connItem, x, y); |
2108 | } |
||
2109 | 7f00b26c | gaqhf | |
2110 | a0e3dca4 | gaqhf | private void ChangeLineSPPIDCoordinateByConnector(Line line, object connItem, double x, double y, bool changeOtherCoordinate = true) |
2111 | { |
||
2112 | Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem); |
||
2113 | int index = line.CONNECTORS.IndexOf(connector); |
||
2114 | if (index == 0) |
||
2115 | { |
||
2116 | line.SPPID.START_X = x; |
||
2117 | line.SPPID.START_Y = y; |
||
2118 | if (line.SlopeType == SlopeType.HORIZONTAL && changeOtherCoordinate) |
||
2119 | line.SPPID.END_Y = y; |
||
2120 | else if (line.SlopeType == SlopeType.VERTICAL && changeOtherCoordinate) |
||
2121 | line.SPPID.END_X = x; |
||
2122 | } |
||
2123 | else |
||
2124 | { |
||
2125 | line.SPPID.END_X = x; |
||
2126 | line.SPPID.END_Y = y; |
||
2127 | if (line.SlopeType == SlopeType.HORIZONTAL && changeOtherCoordinate) |
||
2128 | line.SPPID.START_Y = y; |
||
2129 | else if (line.SlopeType == SlopeType.VERTICAL && changeOtherCoordinate) |
||
2130 | line.SPPID.START_X = x; |
||
2131 | c2ec33f5 | gaqhf | } |
2132 | a0e3dca4 | gaqhf | } |
2133 | 7f00b26c | gaqhf | |
2134 | a0e3dca4 | gaqhf | private void ChangeLineSPPIDCoordinateByConnectorOnlyX(Line line, object connItem, double x) |
2135 | { |
||
2136 | Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem); |
||
2137 | int index = line.CONNECTORS.IndexOf(connector); |
||
2138 | if (index == 0) |
||
2139 | { |
||
2140 | line.SPPID.START_X = x; |
||
2141 | if (line.SlopeType == SlopeType.VERTICAL) |
||
2142 | line.SPPID.END_X = x; |
||
2143 | } |
||
2144 | else |
||
2145 | { |
||
2146 | line.SPPID.END_X = x; |
||
2147 | if (line.SlopeType == SlopeType.VERTICAL) |
||
2148 | line.SPPID.START_X = x; |
||
2149 | } |
||
2150 | } |
||
2151 | 7f00b26c | gaqhf | |
2152 | a0e3dca4 | gaqhf | private void ChangeLineSPPIDCoordinateByConnectorOnlyY(Line line, object connItem, double y) |
2153 | { |
||
2154 | Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem); |
||
2155 | int index = line.CONNECTORS.IndexOf(connector); |
||
2156 | if (index == 0) |
||
2157 | { |
||
2158 | line.SPPID.START_Y = y; |
||
2159 | if (line.SlopeType == SlopeType.HORIZONTAL) |
||
2160 | line.SPPID.END_Y = y; |
||
2161 | } |
||
2162 | else |
||
2163 | { |
||
2164 | line.SPPID.END_Y = y; |
||
2165 | if (line.SlopeType == SlopeType.HORIZONTAL) |
||
2166 | line.SPPID.START_Y = y; |
||
2167 | } |
||
2168 | 1b261371 | gaqhf | } |
2169 | |||
2170 | 0860c756 | gaqhf | private void NeedReModeling(Line line, LMSymbol symbol, ref bool result) |
2171 | ac82b020 | gaqhf | { |
2172 | 0860c756 | gaqhf | if (symbol != null) |
2173 | ac82b020 | gaqhf | { |
2174 | fb386b8c | gaqhf | string repID = symbol.AsLMRepresentation().Id; |
2175 | string symbolUID = SPPIDUtil.FindSymbolByRepresentationID(document, repID).UID; |
||
2176 | string lineUID = line.UID; |
||
2177 | ac82b020 | gaqhf | |
2178 | fb386b8c | gaqhf | SpecBreak startSpecBreak = document.SpecBreaks.Find(x => |
2179 | (x.DownStreamUID == symbolUID || x.UpStreamUID == symbolUID) && |
||
2180 | (x.DownStreamUID == lineUID || x.UpStreamUID == lineUID)); |
||
2181 | 71ba1ca3 | gaqhf | |
2182 | fb386b8c | gaqhf | EndBreak startEndBreak = document.EndBreaks.Find(x => |
2183 | (x.OWNER == symbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == symbolUID) && |
||
2184 | (x.OWNER == lineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == lineUID)); |
||
2185 | ac82b020 | gaqhf | |
2186 | fb386b8c | gaqhf | if (startSpecBreak != null || startEndBreak != null) |
2187 | result = true; |
||
2188 | ac82b020 | gaqhf | } |
2189 | } |
||
2190 | 7f00b26c | gaqhf | |
2191 | 74752074 | gaqhf | /// <summary> |
2192 | 1ab9a205 | gaqhf | /// Symbol에 붙을 경우 Line을 Remodeling 한다. |
2193 | /// </summary> |
||
2194 | /// <param name="lines"></param> |
||
2195 | /// <param name="prevLMConnector"></param> |
||
2196 | /// <param name="startSymbol"></param> |
||
2197 | /// <param name="endSymbol"></param> |
||
2198 | 5173ba5d | gaqhf | private void ReModelingLine(Line line, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol, bool bStart, bool bEnd) |
2199 | 1ab9a205 | gaqhf | { |
2200 | string symbolPath = string.Empty; |
||
2201 | #region get symbol path |
||
2202 | LMModelItem modelItem = dataSource.GetModelItem(prevLMConnector.ModelItemID); |
||
2203 | a31a512e | gaqhf | symbolPath = GetSPPIDFileName(modelItem); |
2204 | d77973b3 | gaqhf | ReleaseCOMObjects(modelItem); |
2205 | 1ab9a205 | gaqhf | #endregion |
2206 | 24b5276c | gaqhf | bool diagonal = false; |
2207 | if (line.SlopeType != SlopeType.HORIZONTAL && line.SlopeType != SlopeType.VERTICAL) |
||
2208 | diagonal = true; |
||
2209 | 1ab9a205 | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
2210 | LMConnector newConnector = null; |
||
2211 | 32205389 | gaqhf | dynamic OID = prevLMConnector.get_GraphicOID().ToString(); |
2212 | 1ab9a205 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
2213 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
2214 | int verticesCount = lineStringGeometry.VertexCount; |
||
2215 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
2216 | 7f00b26c | gaqhf | |
2217 | 1ab9a205 | gaqhf | List<double[]> vertices = new List<double[]>(); |
2218 | for (int i = 1; i <= verticesCount; i++) |
||
2219 | { |
||
2220 | double x = 0; |
||
2221 | double y = 0; |
||
2222 | lineStringGeometry.GetVertex(i, ref x, ref y); |
||
2223 | vertices.Add(new double[] { x, y }); |
||
2224 | } |
||
2225 | |||
2226 | for (int i = 0; i < vertices.Count; i++) |
||
2227 | { |
||
2228 | double[] points = vertices[i]; |
||
2229 | // 시작 심볼이 있고 첫번째 좌표일 때 |
||
2230 | if (startSymbol != null && i == 0) |
||
2231 | { |
||
2232 | ac82b020 | gaqhf | if (bStart) |
2233 | { |
||
2234 | SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i + 1][0], vertices[i + 1][1]); |
||
2235 | if (slopeType == SlopeType.HORIZONTAL) |
||
2236 | placeRunInputs.AddPoint(points[0], -0.1); |
||
2237 | else if (slopeType == SlopeType.VERTICAL) |
||
2238 | placeRunInputs.AddPoint(-0.1, points[1]); |
||
2239 | else |
||
2240 | placeRunInputs.AddPoint(points[0], -0.1); |
||
2241 | 1ab9a205 | gaqhf | |
2242 | ac82b020 | gaqhf | placeRunInputs.AddPoint(points[0], points[1]); |
2243 | } |
||
2244 | else |
||
2245 | { |
||
2246 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(startSymbol, points[0], points[1], diagonal); |
2247 | ac82b020 | gaqhf | } |
2248 | 1ab9a205 | gaqhf | } |
2249 | // 마지막 심볼이 있고 마지막 좌표일 때 |
||
2250 | else if (endSymbol != null && i == vertices.Count - 1) |
||
2251 | { |
||
2252 | ac82b020 | gaqhf | if (bEnd) |
2253 | { |
||
2254 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2255 | 1ab9a205 | gaqhf | |
2256 | ac82b020 | gaqhf | SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i - 1][0], vertices[i - 1][1]); |
2257 | if (slopeType == SlopeType.HORIZONTAL) |
||
2258 | placeRunInputs.AddPoint(points[0], -0.1); |
||
2259 | else if (slopeType == SlopeType.VERTICAL) |
||
2260 | placeRunInputs.AddPoint(-0.1, points[1]); |
||
2261 | else |
||
2262 | placeRunInputs.AddPoint(points[0], -0.1); |
||
2263 | } |
||
2264 | 1ab9a205 | gaqhf | else |
2265 | ac82b020 | gaqhf | { |
2266 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(endSymbol, points[0], points[1], diagonal); |
2267 | ac82b020 | gaqhf | } |
2268 | 1ab9a205 | gaqhf | } |
2269 | // 첫번째이며 시작 심볼이 아니고 Connecotr일 경우 |
||
2270 | else if (i == 0 && prevLMConnector.ConnectItem1SymbolObject != null) |
||
2271 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem1SymbolObject, points[0], points[1], diagonal); |
2272 | 1ab9a205 | gaqhf | // 마지막이며 마지막 심볼이 아니고 Connecotr일 경우 |
2273 | else if (i == vertices.Count - 1 && prevLMConnector.ConnectItem2SymbolObject != null) |
||
2274 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem2SymbolObject, points[0], points[1], diagonal); |
2275 | 1ab9a205 | gaqhf | else |
2276 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2277 | } |
||
2278 | |||
2279 | _placement.PIDRemovePlacement(prevLMConnector.AsLMRepresentation()); |
||
2280 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2281 | |||
2282 | ReleaseCOMObjects(placeRunInputs); |
||
2283 | ReleaseCOMObjects(_LMAItem); |
||
2284 | ReleaseCOMObjects(modelItem); |
||
2285 | |||
2286 | if (newConnector != null) |
||
2287 | { |
||
2288 | 04fcadf1 | gaqhf | newConnector.Commit(); |
2289 | ac82b020 | gaqhf | if (startSymbol != null && bStart) |
2290 | 1ab9a205 | gaqhf | { |
2291 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
2292 | placeRunInputs = new PlaceRunInputs(); |
||
2293 | f1a7faf9 | gaqhf | placeRunInputs.AddSymbolTarget(startSymbol, vertices[0][0], vertices[0][1]); |
2294 | placeRunInputs.AddConnectorTarget(newConnector, vertices[0][0], vertices[0][1]); |
||
2295 | 1ab9a205 | gaqhf | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
2296 | if (_LMConnector != null) |
||
2297 | { |
||
2298 | 04fcadf1 | gaqhf | _LMConnector.Commit(); |
2299 | 1ab9a205 | gaqhf | RemoveConnectorForReModelingLine(newConnector); |
2300 | 87f02fc0 | gaqhf | ZeroLengthModelItemID.Add(_LMConnector.ModelItemID); |
2301 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2302 | } |
||
2303 | ReleaseCOMObjects(placeRunInputs); |
||
2304 | ReleaseCOMObjects(_LMAItem); |
||
2305 | } |
||
2306 | |||
2307 | ac82b020 | gaqhf | if (endSymbol != null && bEnd) |
2308 | 1ab9a205 | gaqhf | { |
2309 | if (startSymbol != null) |
||
2310 | { |
||
2311 | Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(newConnector.ModelItemID); |
||
2312 | newConnector = dicVertices.First().Key; |
||
2313 | } |
||
2314 | |||
2315 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
2316 | placeRunInputs = new PlaceRunInputs(); |
||
2317 | f1a7faf9 | gaqhf | placeRunInputs.AddSymbolTarget(endSymbol, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1]); |
2318 | placeRunInputs.AddConnectorTarget(newConnector, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1]); |
||
2319 | 1ab9a205 | gaqhf | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
2320 | if (_LMConnector != null) |
||
2321 | { |
||
2322 | 04fcadf1 | gaqhf | _LMConnector.Commit(); |
2323 | 1ab9a205 | gaqhf | RemoveConnectorForReModelingLine(newConnector); |
2324 | 1ff0105e | gaqhf | ZeroLengthModelItemIDReverse.Add(_LMConnector.ModelItemID); |
2325 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2326 | } |
||
2327 | ReleaseCOMObjects(placeRunInputs); |
||
2328 | ReleaseCOMObjects(_LMAItem); |
||
2329 | } |
||
2330 | |||
2331 | 5173ba5d | gaqhf | line.SPPID.ModelItemId = newConnector.ModelItemID; |
2332 | 1ab9a205 | gaqhf | ReleaseCOMObjects(newConnector); |
2333 | } |
||
2334 | |||
2335 | ReleaseCOMObjects(modelItem); |
||
2336 | } |
||
2337 | |||
2338 | /// <summary> |
||
2339 | /// Remodeling 과정에서 생긴 불필요한 Connector 제거 |
||
2340 | /// </summary> |
||
2341 | /// <param name="connector"></param> |
||
2342 | private void RemoveConnectorForReModelingLine(LMConnector connector) |
||
2343 | { |
||
2344 | Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(connector.ModelItemID); |
||
2345 | foreach (var item in dicVertices) |
||
2346 | { |
||
2347 | 1805d3b7 | gaqhf | if (item.Value.Count == 2) |
2348 | 1ab9a205 | gaqhf | { |
2349 | 1805d3b7 | gaqhf | bool result = false; |
2350 | foreach (var point in item.Value) |
||
2351 | 1ab9a205 | gaqhf | { |
2352 | 1805d3b7 | gaqhf | if (point[0] < 0 || point[1] < 0) |
2353 | { |
||
2354 | result = true; |
||
2355 | _placement.PIDRemovePlacement(item.Key.AsLMRepresentation()); |
||
2356 | break; |
||
2357 | } |
||
2358 | 1ab9a205 | gaqhf | } |
2359 | |||
2360 | 1805d3b7 | gaqhf | if (result) |
2361 | break; |
||
2362 | } |
||
2363 | 1ab9a205 | gaqhf | } |
2364 | foreach (var item in dicVertices) |
||
2365 | ReleaseCOMObjects(item.Key); |
||
2366 | } |
||
2367 | |||
2368 | /// <summary> |
||
2369 | 74752074 | gaqhf | /// Symbol이 모델링된 SPPPID Symbol Object를 반환 - 연결된 Symbol이 ChildSymbol일 수도 있기때문에 메서드 개발 |
2370 | /// </summary> |
||
2371 | /// <param name="symbol"></param> |
||
2372 | /// <param name="line"></param> |
||
2373 | /// <returns></returns> |
||
2374 | f2baa6a3 | gaqhf | private LMSymbol GetTargetSymbol(Symbol symbol, Line line) |
2375 | { |
||
2376 | LMSymbol _LMSymbol = null; |
||
2377 | foreach (var connector in symbol.CONNECTORS) |
||
2378 | { |
||
2379 | a0e3dca4 | gaqhf | if (connector.CONNECTEDITEM == line.UID) |
2380 | 6b298450 | gaqhf | { |
2381 | a0e3dca4 | gaqhf | if (connector.Index == 0) |
2382 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
2383 | else |
||
2384 | 0860c756 | gaqhf | { |
2385 | a0e3dca4 | gaqhf | ChildSymbol child = null; |
2386 | foreach (var childSymbol in symbol.ChildSymbols) |
||
2387 | 0860c756 | gaqhf | { |
2388 | a0e3dca4 | gaqhf | if (childSymbol.Connectors.Contains(connector)) |
2389 | child = childSymbol; |
||
2390 | else |
||
2391 | child = GetChildSymbolByConnector(childSymbol, connector); |
||
2392 | |||
2393 | if (child != null) |
||
2394 | 0860c756 | gaqhf | break; |
2395 | } |
||
2396 | |||
2397 | a0e3dca4 | gaqhf | if (child != null) |
2398 | _LMSymbol = dataSource.GetSymbol(child.SPPID.RepresentationId); |
||
2399 | 0860c756 | gaqhf | } |
2400 | |||
2401 | a0e3dca4 | gaqhf | break; |
2402 | 335b7a24 | gaqhf | } |
2403 | a0e3dca4 | gaqhf | } |
2404 | 335b7a24 | gaqhf | |
2405 | a0e3dca4 | gaqhf | return _LMSymbol; |
2406 | } |
||
2407 | |||
2408 | /// <summary> |
||
2409 | /// Connector를 가지고 있는 ChildSymbol Object 반환 |
||
2410 | /// </summary> |
||
2411 | /// <param name="item"></param> |
||
2412 | /// <param name="connector"></param> |
||
2413 | /// <returns></returns> |
||
2414 | private ChildSymbol GetChildSymbolByConnector(ChildSymbol item, Connector connector) |
||
2415 | { |
||
2416 | foreach (var childSymbol in item.ChildSymbols) |
||
2417 | { |
||
2418 | if (childSymbol.Connectors.Contains(connector)) |
||
2419 | return childSymbol; |
||
2420 | else |
||
2421 | return GetChildSymbolByConnector(childSymbol, connector); |
||
2422 | 335b7a24 | gaqhf | } |
2423 | |||
2424 | a0e3dca4 | gaqhf | return null; |
2425 | 335b7a24 | gaqhf | } |
2426 | |||
2427 | 74752074 | gaqhf | /// <summary> |
2428 | /// EndBreak 모델링 메서드 |
||
2429 | /// </summary> |
||
2430 | /// <param name="endBreak"></param> |
||
2431 | 3165c259 | gaqhf | private void EndBreakModeling(EndBreak endBreak) |
2432 | 335b7a24 | gaqhf | { |
2433 | 10c7195c | gaqhf | object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
2434 | 1ab9a205 | gaqhf | object connectedItem = SPPIDUtil.FindObjectByUID(document, endBreak.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE); |
2435 | fae4f386 | gaqhf | |
2436 | 1ab9a205 | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(ownerObj, connectedItem); |
2437 | fae4f386 | gaqhf | if (ownerObj.GetType() == typeof(Symbol) && connectedItem.GetType() == typeof(Symbol) && targetLMConnector != null) |
2438 | targetLMConnector = ReModelingZeroLengthLMConnectorForSegment(targetLMConnector); |
||
2439 | 3165c259 | gaqhf | |
2440 | 1ab9a205 | gaqhf | if (targetLMConnector != null) |
2441 | 10c7195c | gaqhf | { |
2442 | 02a45794 | gaqhf | double[] point = GetSegmentPoint(ownerObj, connectedItem, targetLMConnector); |
2443 | Array array = null; |
||
2444 | if (point != null) |
||
2445 | array = new double[] { 0, point[0], point[1] }; |
||
2446 | else |
||
2447 | array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
||
2448 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
2449 | 5173ba5d | gaqhf | if (_LmLabelPersist != null) |
2450 | { |
||
2451 | 04fcadf1 | gaqhf | _LmLabelPersist.Commit(); |
2452 | 5173ba5d | gaqhf | endBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id; |
2453 | d23fe61b | gaqhf | if (_LmLabelPersist.ModelItemObject != null) |
2454 | endBreak.SPPID.ModelItemID = _LmLabelPersist.ModelItemID; |
||
2455 | 32205389 | gaqhf | endBreak.SPPID.GraphicOID = _LmLabelPersist.get_GraphicOID().ToString(); |
2456 | 5173ba5d | gaqhf | ReleaseCOMObjects(_LmLabelPersist); |
2457 | } |
||
2458 | ReleaseCOMObjects(targetLMConnector); |
||
2459 | 2a4872ec | gaqhf | } |
2460 | f9eba687 | gaqhf | else |
2461 | { |
||
2462 | Log.Write("End Break UID : " + endBreak.UID); |
||
2463 | Log.Write("Can't find targetLMConnector"); |
||
2464 | } |
||
2465 | 2a4872ec | gaqhf | } |
2466 | b9e9f4c8 | gaqhf | |
2467 | fae4f386 | gaqhf | private LMConnector ReModelingZeroLengthLMConnectorForSegment(LMConnector connector, string changeSymbolPath = null) |
2468 | 02480ac1 | gaqhf | { |
2469 | de97eaaa | gaqhf | string symbolPath = string.Empty; |
2470 | #region get symbol path |
||
2471 | d77973b3 | gaqhf | if (string.IsNullOrEmpty(changeSymbolPath)) |
2472 | { |
||
2473 | LMModelItem modelItem = dataSource.GetModelItem(connector.ModelItemID); |
||
2474 | symbolPath = GetSPPIDFileName(modelItem); |
||
2475 | ReleaseCOMObjects(modelItem); |
||
2476 | } |
||
2477 | else |
||
2478 | symbolPath = changeSymbolPath; |
||
2479 | |||
2480 | de97eaaa | gaqhf | #endregion |
2481 | |||
2482 | 02480ac1 | gaqhf | LMConnector newConnector = null; |
2483 | 32205389 | gaqhf | dynamic OID = connector.get_GraphicOID().ToString(); |
2484 | 02480ac1 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
2485 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
2486 | int verticesCount = lineStringGeometry.VertexCount; |
||
2487 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
2488 | de97eaaa | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
2489 | 02480ac1 | gaqhf | |
2490 | if (Convert.ToBoolean(connector.get_IsZeroLength())) |
||
2491 | { |
||
2492 | double[] vertices = null; |
||
2493 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
2494 | double x = 0; |
||
2495 | double y = 0; |
||
2496 | lineStringGeometry.GetVertex(1, ref x, ref y); |
||
2497 | |||
2498 | 32205389 | gaqhf | string flowDirection = string.Empty; |
2499 | LMAAttribute flowAttribute = connector.ModelItemObject.Attributes["FlowDirection"]; |
||
2500 | if (flowAttribute != null && !DBNull.Value.Equals(flowAttribute.get_Value())) |
||
2501 | flowDirection = flowAttribute.get_Value().ToString(); |
||
2502 | |||
2503 | 3fdf052a | gaqhf | if (flowDirection == "End 1 is downstream (Outlet)") |
2504 | { |
||
2505 | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, x, y); |
||
2506 | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, x, y); |
||
2507 | flowDirection = "End 1 is upstream (Inlet)"; |
||
2508 | } |
||
2509 | else |
||
2510 | { |
||
2511 | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, x, y); |
||
2512 | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, x, y); |
||
2513 | } |
||
2514 | fae4f386 | gaqhf | string oldModelItemId = connector.ModelItemID; |
2515 | 02480ac1 | gaqhf | _placement.PIDRemovePlacement(connector.AsLMRepresentation()); |
2516 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2517 | 04fcadf1 | gaqhf | newConnector.Commit(); |
2518 | 644f40b3 | gaqhf | ZeroLengthSymbolToSymbolModelItemID.Add(newConnector.ModelItemID); |
2519 | 32205389 | gaqhf | if (!string.IsNullOrEmpty(flowDirection)) |
2520 | newConnector.ModelItemObject.Attributes["FlowDirection"].set_Value(flowDirection); |
||
2521 | fae4f386 | gaqhf | ReleaseCOMObjects(connector); |
2522 | 02480ac1 | gaqhf | |
2523 | fae4f386 | gaqhf | foreach (var line in document.LINES.FindAll(z => z.SPPID.ModelItemId == oldModelItemId)) |
2524 | 02480ac1 | gaqhf | { |
2525 | fae4f386 | gaqhf | foreach (var repId in line.SPPID.Representations) |
2526 | 02480ac1 | gaqhf | { |
2527 | fae4f386 | gaqhf | LMConnector _connector = dataSource.GetConnector(repId); |
2528 | if (_connector != null && _connector.get_ItemStatus() == "Active") |
||
2529 | { |
||
2530 | if (line.SPPID.ModelItemId != _connector.ModelItemID) |
||
2531 | { |
||
2532 | line.SPPID.ModelItemId = _connector.ModelItemID; |
||
2533 | line.SPPID.Representations = GetRepresentations(line.SPPID.ModelItemId); |
||
2534 | } |
||
2535 | } |
||
2536 | ReleaseCOMObjects(_connector); |
||
2537 | _connector = null; |
||
2538 | 02480ac1 | gaqhf | } |
2539 | } |
||
2540 | } |
||
2541 | |||
2542 | return newConnector; |
||
2543 | } |
||
2544 | |||
2545 | 74752074 | gaqhf | /// <summary> |
2546 | 53c81765 | gaqhf | /// SpecBreak Modeling 메서드 |
2547 | /// </summary> |
||
2548 | /// <param name="specBreak"></param> |
||
2549 | private void SpecBreakModeling(SpecBreak specBreak) |
||
2550 | { |
||
2551 | object upStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.UpStreamUID); |
||
2552 | object downStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.DownStreamUID); |
||
2553 | |||
2554 | if (upStreamObj != null && |
||
2555 | downStreamObj != null) |
||
2556 | { |
||
2557 | 1ab9a205 | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
2558 | fae4f386 | gaqhf | if (upStreamObj.GetType() == typeof(Symbol) && downStreamObj.GetType() == typeof(Symbol) && targetLMConnector != null) |
2559 | targetLMConnector = ReModelingZeroLengthLMConnectorForSegment(targetLMConnector); |
||
2560 | |||
2561 | 1ab9a205 | gaqhf | if (targetLMConnector != null) |
2562 | 53c81765 | gaqhf | { |
2563 | 16584d30 | gaqhf | foreach (var attribute in specBreak.ATTRIBUTES) |
2564 | 53c81765 | gaqhf | { |
2565 | 16584d30 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID); |
2566 | if (mapping != null && !string.IsNullOrEmpty(mapping.SPPIDSYMBOLNAME) && mapping.SPPIDSYMBOLNAME != "None") |
||
2567 | { |
||
2568 | string MappingPath = mapping.SPPIDSYMBOLNAME; |
||
2569 | 02a45794 | gaqhf | double[] point = GetSegmentPoint(upStreamObj, downStreamObj, targetLMConnector); |
2570 | Array array = null; |
||
2571 | if (point != null) |
||
2572 | array = new double[] { 0, point[0], point[1] }; |
||
2573 | else |
||
2574 | array = new double[] { 0, specBreak.SPPID.ORIGINAL_X, specBreak.SPPID.ORIGINAL_Y }; |
||
2575 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
||
2576 | 53c81765 | gaqhf | |
2577 | 16584d30 | gaqhf | if (_LmLabelPersist != null) |
2578 | { |
||
2579 | 04fcadf1 | gaqhf | _LmLabelPersist.Commit(); |
2580 | 5173ba5d | gaqhf | specBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id; |
2581 | d23fe61b | gaqhf | if (_LmLabelPersist.ModelItemObject != null) |
2582 | specBreak.SPPID.ModelItemID = _LmLabelPersist.ModelItemID; |
||
2583 | 32205389 | gaqhf | specBreak.SPPID.GraphicOID = _LmLabelPersist.get_GraphicOID().ToString(); |
2584 | 16584d30 | gaqhf | ReleaseCOMObjects(_LmLabelPersist); |
2585 | } |
||
2586 | } |
||
2587 | } |
||
2588 | 1ab9a205 | gaqhf | ReleaseCOMObjects(targetLMConnector); |
2589 | } |
||
2590 | f9eba687 | gaqhf | else |
2591 | { |
||
2592 | Log.Write("Spec Break UID : " + specBreak.UID); |
||
2593 | Log.Write("Can't find targetLMConnector"); |
||
2594 | } |
||
2595 | 1ab9a205 | gaqhf | } |
2596 | } |
||
2597 | 53c81765 | gaqhf | |
2598 | 1ab9a205 | gaqhf | private LMConnector FindBreakLineTarget(object targetObj, object connectedObj) |
2599 | { |
||
2600 | LMConnector targetConnector = null; |
||
2601 | Symbol targetSymbol = targetObj as Symbol; |
||
2602 | Symbol connectedSymbol = connectedObj as Symbol; |
||
2603 | Line targetLine = targetObj as Line; |
||
2604 | Line connectedLine = connectedObj as Line; |
||
2605 | if (targetSymbol != null && connectedSymbol != null) |
||
2606 | { |
||
2607 | LMSymbol targetLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
2608 | LMSymbol connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
||
2609 | |||
2610 | foreach (LMConnector connector in targetLMSymbol.Avoid1Connectors) |
||
2611 | { |
||
2612 | if (connector.get_ItemStatus() != "Active") |
||
2613 | continue; |
||
2614 | |||
2615 | if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
||
2616 | { |
||
2617 | targetConnector = connector; |
||
2618 | break; |
||
2619 | } |
||
2620 | else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
||
2621 | { |
||
2622 | targetConnector = connector; |
||
2623 | break; |
||
2624 | 53c81765 | gaqhf | } |
2625 | } |
||
2626 | 1ab9a205 | gaqhf | |
2627 | foreach (LMConnector connector in targetLMSymbol.Avoid2Connectors) |
||
2628 | 53c81765 | gaqhf | { |
2629 | 1ab9a205 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2630 | continue; |
||
2631 | 53c81765 | gaqhf | |
2632 | 1ab9a205 | gaqhf | if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
2633 | { |
||
2634 | targetConnector = connector; |
||
2635 | break; |
||
2636 | } |
||
2637 | else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
||
2638 | { |
||
2639 | targetConnector = connector; |
||
2640 | break; |
||
2641 | 53c81765 | gaqhf | } |
2642 | } |
||
2643 | 1ab9a205 | gaqhf | |
2644 | ReleaseCOMObjects(targetLMSymbol); |
||
2645 | ReleaseCOMObjects(connectedLMSymbol); |
||
2646 | } |
||
2647 | else if (targetLine != null && connectedLine != null) |
||
2648 | { |
||
2649 | LMModelItem targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
||
2650 | LMModelItem connectedModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
||
2651 | |||
2652 | d77973b3 | gaqhf | if (targetModelItem != null && targetModelItem.get_ItemStatus() == "Active" && connectedModelItem != null && connectedModelItem.get_ItemStatus() == "Active") |
2653 | 53c81765 | gaqhf | { |
2654 | 1ab9a205 | gaqhf | foreach (LMRepresentation rep in targetModelItem.Representations) |
2655 | 53c81765 | gaqhf | { |
2656 | 1ab9a205 | gaqhf | if (targetConnector != null) |
2657 | break; |
||
2658 | 53c81765 | gaqhf | |
2659 | 1ab9a205 | gaqhf | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
2660 | 53c81765 | gaqhf | { |
2661 | 1ab9a205 | gaqhf | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
2662 | |||
2663 | if (IsConnected(_LMConnector, connectedModelItem)) |
||
2664 | targetConnector = _LMConnector; |
||
2665 | else |
||
2666 | ReleaseCOMObjects(_LMConnector); |
||
2667 | 53c81765 | gaqhf | } |
2668 | } |
||
2669 | 1ab9a205 | gaqhf | |
2670 | ReleaseCOMObjects(targetModelItem); |
||
2671 | 53c81765 | gaqhf | } |
2672 | 1ab9a205 | gaqhf | } |
2673 | else |
||
2674 | { |
||
2675 | 340515a2 | gaqhf | LMSymbol connectedLMSymbol = null; |
2676 | if (connectedSymbol != null) |
||
2677 | connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
||
2678 | else if (targetSymbol != null) |
||
2679 | connectedLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
2680 | else |
||
2681 | { |
||
2682 | |||
2683 | } |
||
2684 | LMModelItem targetModelItem = null; |
||
2685 | if (targetLine != null) |
||
2686 | targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
||
2687 | else if (connectedLine != null) |
||
2688 | targetModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
||
2689 | else |
||
2690 | { |
||
2691 | |||
2692 | } |
||
2693 | 1ab9a205 | gaqhf | if (connectedLMSymbol != null && targetModelItem != null) |
2694 | 53c81765 | gaqhf | { |
2695 | 1ab9a205 | gaqhf | foreach (LMConnector connector in connectedLMSymbol.Avoid1Connectors) |
2696 | { |
||
2697 | ac82b020 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2698 | continue; |
||
2699 | |||
2700 | 1ab9a205 | gaqhf | if (IsConnected(connector, targetModelItem)) |
2701 | { |
||
2702 | targetConnector = connector; |
||
2703 | break; |
||
2704 | } |
||
2705 | } |
||
2706 | 53c81765 | gaqhf | |
2707 | 1ab9a205 | gaqhf | if (targetConnector == null) |
2708 | 53c81765 | gaqhf | { |
2709 | 1ab9a205 | gaqhf | foreach (LMConnector connector in connectedLMSymbol.Avoid2Connectors) |
2710 | 53c81765 | gaqhf | { |
2711 | ac82b020 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2712 | continue; |
||
2713 | |||
2714 | 1ab9a205 | gaqhf | if (IsConnected(connector, targetModelItem)) |
2715 | 53c81765 | gaqhf | { |
2716 | 1ab9a205 | gaqhf | targetConnector = connector; |
2717 | break; |
||
2718 | 53c81765 | gaqhf | } |
2719 | } |
||
2720 | } |
||
2721 | } |
||
2722 | |||
2723 | 1ab9a205 | gaqhf | } |
2724 | 02480ac1 | gaqhf | |
2725 | 1ab9a205 | gaqhf | return targetConnector; |
2726 | } |
||
2727 | 53c81765 | gaqhf | |
2728 | 02a45794 | gaqhf | private double[] GetSegmentPoint(object targetObj, object connObj, LMConnector targetConnector) |
2729 | { |
||
2730 | double[] result = null; |
||
2731 | 28d05cc2 | gaqhf | Line targetLine = targetObj as Line; |
2732 | Symbol targetSymbol = targetObj as Symbol; |
||
2733 | Line connLine = connObj as Line; |
||
2734 | Symbol connSymbol = connObj as Symbol; |
||
2735 | |||
2736 | f9eba687 | gaqhf | double zeroLengthMove = GridSetting.GetInstance().Length * 3; |
2737 | double lineMove = GridSetting.GetInstance().Length * 3; |
||
2738 | 02a45794 | gaqhf | if (Convert.ToBoolean(targetConnector.get_IsZeroLength())) |
2739 | { |
||
2740 | 28d05cc2 | gaqhf | result = GetConnectorVertices(targetConnector)[0]; |
2741 | if (targetSymbol != null && connSymbol != null) |
||
2742 | { |
||
2743 | SlopeType slopeType = SPPIDUtil.CalcSlope(targetSymbol.SPPID.SPPID_X, targetSymbol.SPPID.SPPID_Y, connSymbol.SPPID.SPPID_X, connSymbol.SPPID.SPPID_Y); |
||
2744 | if (slopeType == SlopeType.HORIZONTAL) |
||
2745 | 9157c1b8 | gaqhf | result = new double[] { result[0], result[1] - zeroLengthMove }; |
2746 | 28d05cc2 | gaqhf | else if (slopeType == SlopeType.VERTICAL) |
2747 | 9157c1b8 | gaqhf | result = new double[] { result[0] - zeroLengthMove, result[1] }; |
2748 | 28d05cc2 | gaqhf | } |
2749 | else if (targetLine != null) |
||
2750 | { |
||
2751 | if (targetLine.SlopeType == SlopeType.HORIZONTAL) |
||
2752 | 9157c1b8 | gaqhf | result = new double[] { result[0], result[1] - zeroLengthMove }; |
2753 | 28d05cc2 | gaqhf | else if (targetLine.SlopeType == SlopeType.VERTICAL) |
2754 | 9157c1b8 | gaqhf | result = new double[] { result[0] - zeroLengthMove, result[1] }; |
2755 | 28d05cc2 | gaqhf | } |
2756 | else if (connLine != null) |
||
2757 | { |
||
2758 | if (connLine.SlopeType == SlopeType.HORIZONTAL) |
||
2759 | 9157c1b8 | gaqhf | result = new double[] { result[0], result[1] - zeroLengthMove }; |
2760 | 28d05cc2 | gaqhf | else if (connLine.SlopeType == SlopeType.VERTICAL) |
2761 | 9157c1b8 | gaqhf | result = new double[] { result[0] - zeroLengthMove, result[1] }; |
2762 | 28d05cc2 | gaqhf | } |
2763 | 02a45794 | gaqhf | } |
2764 | else |
||
2765 | { |
||
2766 | if (targetObj.GetType() == typeof(Line) && connObj.GetType() == typeof(Line)) |
||
2767 | { |
||
2768 | Line line = connObj as Line; |
||
2769 | LMConnector connectedConnector = null; |
||
2770 | int connIndex = 0; |
||
2771 | LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
||
2772 | FindConnectedConnector(targetConnector, modelItem, ref connectedConnector, ref connIndex); |
||
2773 | |||
2774 | List<double[]> vertices = GetConnectorVertices(targetConnector); |
||
2775 | |||
2776 | ReleaseCOMObjects(modelItem); |
||
2777 | ReleaseCOMObjects(connectedConnector); |
||
2778 | |||
2779 | if (vertices.Count > 0) |
||
2780 | { |
||
2781 | if (connIndex == 1) |
||
2782 | 28d05cc2 | gaqhf | result = vertices[0]; |
2783 | 02a45794 | gaqhf | else if (connIndex == 2) |
2784 | 28d05cc2 | gaqhf | result = vertices[vertices.Count - 1]; |
2785 | |||
2786 | if (targetLine.SlopeType == SlopeType.HORIZONTAL) |
||
2787 | { |
||
2788 | 9157c1b8 | gaqhf | result = new double[] { result[0], result[1] - lineMove }; |
2789 | 28d05cc2 | gaqhf | if (targetLine.CONNECTORS[0].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_X < targetLine.SPPID.END_X) |
2790 | { |
||
2791 | 783f8357 | gaqhf | result = new double[] { result[0] - lineMove, result[1] }; |
2792 | 28d05cc2 | gaqhf | } |
2793 | else if (targetLine.CONNECTORS[0].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_X > targetLine.SPPID.END_X) |
||
2794 | { |
||
2795 | 783f8357 | gaqhf | result = new double[] { result[0] + lineMove, result[1] }; |
2796 | 28d05cc2 | gaqhf | } |
2797 | else if (targetLine.CONNECTORS[1].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_X < targetLine.SPPID.END_X) |
||
2798 | { |
||
2799 | 783f8357 | gaqhf | result = new double[] { result[0] + lineMove, result[1] }; |
2800 | 28d05cc2 | gaqhf | } |
2801 | else if (targetLine.CONNECTORS[1].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_X > targetLine.SPPID.END_X) |
||
2802 | { |
||
2803 | 783f8357 | gaqhf | result = new double[] { result[0] - lineMove, result[1] }; |
2804 | 28d05cc2 | gaqhf | } |
2805 | } |
||
2806 | else if (targetLine.SlopeType == SlopeType.VERTICAL) |
||
2807 | { |
||
2808 | 9157c1b8 | gaqhf | result = new double[] { result[0] - lineMove, result[1] }; |
2809 | 28d05cc2 | gaqhf | if (targetLine.CONNECTORS[0].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_Y < targetLine.SPPID.END_Y) |
2810 | { |
||
2811 | 783f8357 | gaqhf | result = new double[] { result[0], result[1] - lineMove }; |
2812 | 28d05cc2 | gaqhf | } |
2813 | else if (targetLine.CONNECTORS[0].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_Y > targetLine.SPPID.END_Y) |
||
2814 | { |
||
2815 | 783f8357 | gaqhf | result = new double[] { result[0], result[1] + lineMove }; |
2816 | 28d05cc2 | gaqhf | } |
2817 | else if (targetLine.CONNECTORS[1].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_Y < targetLine.SPPID.END_Y) |
||
2818 | { |
||
2819 | 783f8357 | gaqhf | result = new double[] { result[0], result[1] + lineMove }; |
2820 | 28d05cc2 | gaqhf | } |
2821 | else if (targetLine.CONNECTORS[1].CONNECTEDITEM == connLine.UID && targetLine.SPPID.START_Y > targetLine.SPPID.END_Y) |
||
2822 | { |
||
2823 | 783f8357 | gaqhf | result = new double[] { result[0], result[1] - lineMove }; |
2824 | 28d05cc2 | gaqhf | } |
2825 | } |
||
2826 | |||
2827 | 02a45794 | gaqhf | } |
2828 | } |
||
2829 | else |
||
2830 | { |
||
2831 | Log.Write("error in GetSegemtPoint"); |
||
2832 | } |
||
2833 | } |
||
2834 | |||
2835 | return result; |
||
2836 | } |
||
2837 | |||
2838 | 1ab9a205 | gaqhf | private bool IsConnected(LMConnector connector, LMModelItem modelItem) |
2839 | { |
||
2840 | bool result = false; |
||
2841 | |||
2842 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2843 | { |
||
2844 | if (result) |
||
2845 | break; |
||
2846 | |||
2847 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2848 | { |
||
2849 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2850 | |||
2851 | if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2852 | connector.ConnectItem1SymbolObject != null && |
||
2853 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2854 | 53c81765 | gaqhf | { |
2855 | 1ab9a205 | gaqhf | result = true; |
2856 | ReleaseCOMObjects(_LMConnector); |
||
2857 | break; |
||
2858 | } |
||
2859 | else if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2860 | connector.ConnectItem2SymbolObject != null && |
||
2861 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2862 | { |
||
2863 | result = true; |
||
2864 | ReleaseCOMObjects(_LMConnector); |
||
2865 | break; |
||
2866 | } |
||
2867 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2868 | connector.ConnectItem1SymbolObject != null && |
||
2869 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2870 | { |
||
2871 | result = true; |
||
2872 | ReleaseCOMObjects(_LMConnector); |
||
2873 | break; |
||
2874 | } |
||
2875 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2876 | connector.ConnectItem2SymbolObject != null && |
||
2877 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2878 | { |
||
2879 | result = true; |
||
2880 | ReleaseCOMObjects(_LMConnector); |
||
2881 | break; |
||
2882 | 53c81765 | gaqhf | } |
2883 | |||
2884 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2885 | } |
||
2886 | 53c81765 | gaqhf | } |
2887 | 1ab9a205 | gaqhf | |
2888 | |||
2889 | return result; |
||
2890 | 53c81765 | gaqhf | } |
2891 | |||
2892 | 02a45794 | gaqhf | private void FindConnectedConnector(LMConnector connector, LMModelItem modelItem, ref LMConnector connectedConnector, ref int connectorIndex) |
2893 | { |
||
2894 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2895 | { |
||
2896 | if (connectedConnector != null) |
||
2897 | break; |
||
2898 | |||
2899 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2900 | { |
||
2901 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2902 | |||
2903 | if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2904 | connector.ConnectItem1SymbolObject != null && |
||
2905 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2906 | { |
||
2907 | connectedConnector = _LMConnector; |
||
2908 | connectorIndex = 1; |
||
2909 | break; |
||
2910 | } |
||
2911 | else if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2912 | connector.ConnectItem2SymbolObject != null && |
||
2913 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2914 | { |
||
2915 | connectedConnector = _LMConnector; |
||
2916 | connectorIndex = 2; |
||
2917 | break; |
||
2918 | } |
||
2919 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2920 | connector.ConnectItem1SymbolObject != null && |
||
2921 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2922 | { |
||
2923 | connectedConnector = _LMConnector; |
||
2924 | connectorIndex = 1; |
||
2925 | break; |
||
2926 | } |
||
2927 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2928 | connector.ConnectItem2SymbolObject != null && |
||
2929 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2930 | { |
||
2931 | connectedConnector = _LMConnector; |
||
2932 | connectorIndex = 2; |
||
2933 | break; |
||
2934 | } |
||
2935 | |||
2936 | if (connectedConnector == null) |
||
2937 | ReleaseCOMObjects(_LMConnector); |
||
2938 | } |
||
2939 | } |
||
2940 | } |
||
2941 | |||
2942 | 53c81765 | gaqhf | /// <summary> |
2943 | 74752074 | gaqhf | /// FromModelItem을 ToModelItem으로 PipeRunJoin하는 메서드 |
2944 | /// </summary> |
||
2945 | 644f40b3 | gaqhf | /// <param name="modelItemID1"></param> |
2946 | /// <param name="modelItemID2"></param> |
||
2947 | a31a512e | gaqhf | private void JoinRun(string modelId1, string modelId2, ref string survivorId) |
2948 | 335b7a24 | gaqhf | { |
2949 | ca6e0f51 | gaqhf | try |
2950 | 644f40b3 | gaqhf | { |
2951 | a31a512e | gaqhf | LMModelItem modelItem1 = dataSource.GetModelItem(modelId1); |
2952 | ca6e0f51 | gaqhf | _LMAItem item1 = modelItem1.AsLMAItem(); |
2953 | a31a512e | gaqhf | LMModelItem modelItem2 = dataSource.GetModelItem(modelId2); |
2954 | ca6e0f51 | gaqhf | _LMAItem item2 = modelItem2.AsLMAItem(); |
2955 | 644f40b3 | gaqhf | |
2956 | ca6e0f51 | gaqhf | // item2가 item1으로 조인 |
2957 | _placement.PIDJoinRuns(ref item1, ref item2); |
||
2958 | item1.Commit(); |
||
2959 | item2.Commit(); |
||
2960 | 7f00b26c | gaqhf | |
2961 | ca6e0f51 | gaqhf | string beforeID = string.Empty; |
2962 | string afterID = string.Empty; |
||
2963 | 335b7a24 | gaqhf | |
2964 | ca6e0f51 | gaqhf | if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() != "Active") |
2965 | { |
||
2966 | beforeID = modelItem2.Id; |
||
2967 | afterID = modelItem1.Id; |
||
2968 | a31a512e | gaqhf | survivorId = afterID; |
2969 | be7159c9 | gaqhf | LMAAttribute attribute = modelItem1.Attributes["FlowDirection"]; |
2970 | if (attribute != null) |
||
2971 | attribute.set_Value("End 1 is upstream (Inlet)"); |
||
2972 | ca6e0f51 | gaqhf | } |
2973 | else if (modelItem1.get_ItemStatus() != "Active" && modelItem2.get_ItemStatus() == "Active") |
||
2974 | { |
||
2975 | beforeID = modelItem1.Id; |
||
2976 | afterID = modelItem2.Id; |
||
2977 | a31a512e | gaqhf | survivorId = afterID; |
2978 | be7159c9 | gaqhf | LMAAttribute attribute = modelItem2.Attributes["FlowDirection"]; |
2979 | if (attribute != null) |
||
2980 | attribute.set_Value("End 1 is upstream (Inlet)"); |
||
2981 | ca6e0f51 | gaqhf | } |
2982 | a31a512e | gaqhf | else if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() == "Active") |
2983 | survivorId = null; |
||
2984 | ca6e0f51 | gaqhf | else |
2985 | { |
||
2986 | a31a512e | gaqhf | Log.Write("잘못된 경우"); |
2987 | survivorId = null; |
||
2988 | ca6e0f51 | gaqhf | } |
2989 | 87f02fc0 | gaqhf | |
2990 | ca6e0f51 | gaqhf | if (!string.IsNullOrEmpty(beforeID) && !string.IsNullOrEmpty(afterID)) |
2991 | 7f00b26c | gaqhf | { |
2992 | ca6e0f51 | gaqhf | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, beforeID); |
2993 | 7f00b26c | gaqhf | foreach (var line in lines) |
2994 | ca6e0f51 | gaqhf | line.SPPID.ModelItemId = afterID; |
2995 | 65a1ed4b | gaqhf | } |
2996 | 7f00b26c | gaqhf | |
2997 | ca6e0f51 | gaqhf | ReleaseCOMObjects(modelItem1); |
2998 | ReleaseCOMObjects(item1); |
||
2999 | ReleaseCOMObjects(modelItem2); |
||
3000 | ReleaseCOMObjects(item2); |
||
3001 | } |
||
3002 | catch (Exception ex) |
||
3003 | 335b7a24 | gaqhf | { |
3004 | ca6e0f51 | gaqhf | Log.Write("Join Error"); |
3005 | Log.Write(ex.Message); |
||
3006 | 335b7a24 | gaqhf | } |
3007 | } |
||
3008 | |||
3009 | a31a512e | gaqhf | private List<string> FindOtherModelItemBySymbolWhereTypePipeRun(LMSymbol symbol, string modelId) |
3010 | { |
||
3011 | fae4f386 | gaqhf | List<string> temp = new List<string>(); |
3012 | List<LMConnector> connectors = new List<LMConnector>(); |
||
3013 | 48fd75e2 | gaqhf | foreach (LMConnector connector in symbol.Avoid1Connectors) |
3014 | a31a512e | gaqhf | { |
3015 | fae4f386 | gaqhf | if (connector.get_ItemStatus() != "Active") |
3016 | continue; |
||
3017 | |||
3018 | a31a512e | gaqhf | LMModelItem modelItem = connector.ModelItemObject; |
3019 | fae4f386 | gaqhf | LMSymbol connOtherSymbol = FindOtherConnectedSymbol(connector); |
3020 | if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId && !temp.Contains(modelItem.Id)) |
||
3021 | temp.Add(modelItem.Id); |
||
3022 | |||
3023 | if (temp.Contains(modelItem.Id) && |
||
3024 | connOtherSymbol != null && |
||
3025 | connOtherSymbol.get_RepresentationType() == "Branch" && |
||
3026 | Convert.ToBoolean(connector.get_IsZeroLength())) |
||
3027 | temp.Remove(modelItem.Id); |
||
3028 | |||
3029 | |||
3030 | if (temp.Contains(modelItem.Id)) |
||
3031 | connectors.Add(connector); |
||
3032 | ReleaseCOMObjects(connOtherSymbol); |
||
3033 | connOtherSymbol = null; |
||
3034 | a31a512e | gaqhf | ReleaseCOMObjects(modelItem); |
3035 | fae4f386 | gaqhf | modelItem = null; |
3036 | a31a512e | gaqhf | } |
3037 | |||
3038 | 48fd75e2 | gaqhf | foreach (LMConnector connector in symbol.Avoid2Connectors) |
3039 | a31a512e | gaqhf | { |
3040 | fae4f386 | gaqhf | if (connector.get_ItemStatus() != "Active") |
3041 | continue; |
||
3042 | |||
3043 | a31a512e | gaqhf | LMModelItem modelItem = connector.ModelItemObject; |
3044 | fae4f386 | gaqhf | LMSymbol connOtherSymbol = FindOtherConnectedSymbol(connector); |
3045 | if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId && !temp.Contains(modelItem.Id)) |
||
3046 | temp.Add(modelItem.Id); |
||
3047 | |||
3048 | if (temp.Contains(modelItem.Id) && |
||
3049 | connOtherSymbol != null && |
||
3050 | connOtherSymbol.get_RepresentationType() == "Branch" && |
||
3051 | Convert.ToBoolean(connector.get_IsZeroLength())) |
||
3052 | temp.Remove(modelItem.Id); |
||
3053 | |||
3054 | if (temp.Contains(modelItem.Id)) |
||
3055 | connectors.Add(connector); |
||
3056 | ReleaseCOMObjects(connOtherSymbol); |
||
3057 | connOtherSymbol = null; |
||
3058 | a31a512e | gaqhf | ReleaseCOMObjects(modelItem); |
3059 | fae4f386 | gaqhf | modelItem = null; |
3060 | a31a512e | gaqhf | } |
3061 | |||
3062 | 48fd75e2 | gaqhf | |
3063 | 82d6e5ea | gaqhf | List<string> result = new List<string>(); |
3064 | string originalName = GetSPPIDFileName(modelId); |
||
3065 | fae4f386 | gaqhf | foreach (var connector in connectors) |
3066 | 82d6e5ea | gaqhf | { |
3067 | fae4f386 | gaqhf | string fileName = GetSPPIDFileName(connector.ModelItemID); |
3068 | 82d6e5ea | gaqhf | if (originalName == fileName) |
3069 | fae4f386 | gaqhf | result.Add(connector.ModelItemID); |
3070 | 82d6e5ea | gaqhf | else |
3071 | { |
||
3072 | fae4f386 | gaqhf | if (document.LINES.Find(x => x.SPPID.ModelItemId == connector.ModelItemID) == null && Convert.ToBoolean(connector.get_IsZeroLength())) |
3073 | result.Add(connector.ModelItemID); |
||
3074 | else |
||
3075 | 82d6e5ea | gaqhf | { |
3076 | fae4f386 | gaqhf | Line line1 = document.LINES.Find(x => x.SPPID.ModelItemId == modelId); |
3077 | Line line2 = document.LINES.Find(x => x.SPPID.ModelItemId == connector.ModelItemID.ToString()); |
||
3078 | if (line1 != null && line2 != null && line1.TYPE == line2.TYPE) |
||
3079 | result.Add(connector.ModelItemID); |
||
3080 | 82d6e5ea | gaqhf | } |
3081 | } |
||
3082 | } |
||
3083 | 154d8f43 | gaqhf | |
3084 | fae4f386 | gaqhf | foreach (var connector in connectors) |
3085 | 154d8f43 | gaqhf | ReleaseCOMObjects(connector); |
3086 | 82d6e5ea | gaqhf | |
3087 | return result; |
||
3088 | fae4f386 | gaqhf | |
3089 | |||
3090 | LMSymbol FindOtherConnectedSymbol(LMConnector connector) |
||
3091 | { |
||
3092 | LMSymbol findResult = null; |
||
3093 | if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.Id != symbol.Id && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active") |
||
3094 | findResult = connector.ConnectItem1SymbolObject; |
||
3095 | else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.Id != symbol.Id && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active") |
||
3096 | findResult = connector.ConnectItem2SymbolObject; |
||
3097 | |||
3098 | return findResult; |
||
3099 | } |
||
3100 | a31a512e | gaqhf | } |
3101 | |||
3102 | 74752074 | gaqhf | /// <summary> |
3103 | /// PipeRun의 좌표를 가져오는 메서드 |
||
3104 | /// </summary> |
||
3105 | /// <param name="modelId"></param> |
||
3106 | /// <returns></returns> |
||
3107 | 5e6ecf05 | gaqhf | private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId) |
3108 | { |
||
3109 | Dictionary<LMConnector, List<double[]>> connectorVertices = new Dictionary<LMConnector, List<double[]>>(); |
||
3110 | 310aeb31 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelId); |
3111 | |||
3112 | if (modelItem != null) |
||
3113 | 5e6ecf05 | gaqhf | { |
3114 | 310aeb31 | gaqhf | foreach (LMRepresentation rep in modelItem.Representations) |
3115 | 5e6ecf05 | gaqhf | { |
3116 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
3117 | { |
||
3118 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
3119 | connectorVertices.Add(_LMConnector, new List<double[]>()); |
||
3120 | 32205389 | gaqhf | dynamic OID = rep.get_GraphicOID().ToString(); |
3121 | 335b7a24 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
3122 | 5e6ecf05 | gaqhf | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
3123 | int verticesCount = lineStringGeometry.VertexCount; |
||
3124 | double[] vertices = null; |
||
3125 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
3126 | for (int i = 0; i < verticesCount; i++) |
||
3127 | { |
||
3128 | double x = 0; |
||
3129 | double y = 0; |
||
3130 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
3131 | 32205389 | gaqhf | connectorVertices[_LMConnector].Add(new double[] { x, y }); |
3132 | 5e6ecf05 | gaqhf | } |
3133 | } |
||
3134 | } |
||
3135 | |||
3136 | 310aeb31 | gaqhf | ReleaseCOMObjects(modelItem); |
3137 | 5e6ecf05 | gaqhf | } |
3138 | |||
3139 | return connectorVertices; |
||
3140 | } |
||
3141 | |||
3142 | 32205389 | gaqhf | private List<double[]> GetConnectorVertices(LMConnector connector) |
3143 | { |
||
3144 | List<double[]> vertices = new List<double[]>(); |
||
3145 | 02a45794 | gaqhf | if (connector != null) |
3146 | 32205389 | gaqhf | { |
3147 | 02a45794 | gaqhf | dynamic OID = connector.get_GraphicOID().ToString(); |
3148 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
3149 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
3150 | int verticesCount = lineStringGeometry.VertexCount; |
||
3151 | double[] value = null; |
||
3152 | lineStringGeometry.GetVertices(ref verticesCount, ref value); |
||
3153 | for (int i = 0; i < verticesCount; i++) |
||
3154 | { |
||
3155 | double x = 0; |
||
3156 | double y = 0; |
||
3157 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
3158 | vertices.Add(new double[] { x, y }); |
||
3159 | } |
||
3160 | 32205389 | gaqhf | } |
3161 | return vertices; |
||
3162 | } |
||
3163 | |||
3164 | 7c7bcd10 | gaqhf | /// <summary> |
3165 | a0e3dca4 | gaqhf | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 조건에 안맞아서 못찾을시 제일 가까운 점으로 가져오는 방식 |
3166 | 74752074 | gaqhf | /// </summary> |
3167 | /// <param name="connectorVertices"></param> |
||
3168 | /// <param name="connX"></param> |
||
3169 | /// <param name="connY"></param> |
||
3170 | /// <returns></returns> |
||
3171 | a0e3dca4 | gaqhf | private LMConnector FindTargetLMConnectorForLabel(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
3172 | 5e6ecf05 | gaqhf | { |
3173 | double length = double.MaxValue; |
||
3174 | LMConnector targetConnector = null; |
||
3175 | foreach (var item in connectorVertices) |
||
3176 | { |
||
3177 | List<double[]> points = item.Value; |
||
3178 | for (int i = 0; i < points.Count - 1; i++) |
||
3179 | { |
||
3180 | double[] point1 = points[i]; |
||
3181 | double[] point2 = points[i + 1]; |
||
3182 | a0e3dca4 | gaqhf | double x1 = Math.Min(point1[0], point2[0]); |
3183 | double y1 = Math.Min(point1[1], point2[1]); |
||
3184 | double x2 = Math.Max(point1[0], point2[0]); |
||
3185 | double y2 = Math.Max(point1[1], point2[1]); |
||
3186 | 5e6ecf05 | gaqhf | |
3187 | a0e3dca4 | gaqhf | if ((x1 <= connX && x2 >= connX) || |
3188 | (y1 <= connY && y2 >= connY)) |
||
3189 | 5e6ecf05 | gaqhf | { |
3190 | a0e3dca4 | gaqhf | double distance = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], connX, connY); |
3191 | 335b7a24 | gaqhf | if (length >= distance) |
3192 | 30a9ffce | gaqhf | { |
3193 | a0e3dca4 | gaqhf | targetConnector = item.Key; |
3194 | length = distance; |
||
3195 | } |
||
3196 | |||
3197 | distance = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], connX, connY); |
||
3198 | if (length >= distance) |
||
3199 | { |
||
3200 | targetConnector = item.Key; |
||
3201 | length = distance; |
||
3202 | 30a9ffce | gaqhf | } |
3203 | 5e6ecf05 | gaqhf | } |
3204 | } |
||
3205 | c3d2e266 | gaqhf | } |
3206 | |||
3207 | a0e3dca4 | gaqhf | // 못찾았을때. |
3208 | length = double.MaxValue; |
||
3209 | c3d2e266 | gaqhf | if (targetConnector == null) |
3210 | { |
||
3211 | foreach (var item in connectorVertices) |
||
3212 | { |
||
3213 | List<double[]> points = item.Value; |
||
3214 | a0e3dca4 | gaqhf | |
3215 | foreach (double[] point in points) |
||
3216 | c3d2e266 | gaqhf | { |
3217 | a0e3dca4 | gaqhf | double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
3218 | c3d2e266 | gaqhf | if (length >= distance) |
3219 | { |
||
3220 | targetConnector = item.Key; |
||
3221 | length = distance; |
||
3222 | } |
||
3223 | } |
||
3224 | } |
||
3225 | 5e6ecf05 | gaqhf | } |
3226 | |||
3227 | return targetConnector; |
||
3228 | } |
||
3229 | |||
3230 | a0e3dca4 | gaqhf | private LMConnector FindTargetLMConnectorForBranch(Line line, Line targetLine, ref double x, ref double y) |
3231 | ac78b508 | gaqhf | { |
3232 | a0e3dca4 | gaqhf | Dictionary<LMConnector, List<double[]>> vertices = GetPipeRunVertices(targetLine.SPPID.ModelItemId); |
3233 | 0ff6e67f | gaqhf | if (vertices.Count == 0) |
3234 | return null; |
||
3235 | a0e3dca4 | gaqhf | |
3236 | ac78b508 | gaqhf | double length = double.MaxValue; |
3237 | LMConnector targetConnector = null; |
||
3238 | a0e3dca4 | gaqhf | double[] resultPoint = null; |
3239 | List<double[]> targetVertices = null; |
||
3240 | |||
3241 | // Vertices 포인트에 제일 가까운곳 |
||
3242 | foreach (var item in vertices) |
||
3243 | ac78b508 | gaqhf | { |
3244 | List<double[]> points = item.Value; |
||
3245 | a0e3dca4 | gaqhf | for (int i = 0; i < points.Count; i++) |
3246 | ac78b508 | gaqhf | { |
3247 | a0e3dca4 | gaqhf | double[] point = points[i]; |
3248 | double tempX = point[0]; |
||
3249 | double tempY = point[1]; |
||
3250 | |||
3251 | double distance = SPPIDUtil.CalcPointToPointdDistance(tempX, tempY, x, y); |
||
3252 | ac78b508 | gaqhf | if (length >= distance) |
3253 | { |
||
3254 | targetConnector = item.Key; |
||
3255 | length = distance; |
||
3256 | a0e3dca4 | gaqhf | resultPoint = point; |
3257 | targetVertices = item.Value; |
||
3258 | ac78b508 | gaqhf | } |
3259 | } |
||
3260 | } |
||
3261 | |||
3262 | a0e3dca4 | gaqhf | // Vertices Cross에 제일 가까운곳 |
3263 | foreach (var item in vertices) |
||
3264 | 68464385 | gaqhf | { |
3265 | List<double[]> points = item.Value; |
||
3266 | for (int i = 0; i < points.Count - 1; i++) |
||
3267 | { |
||
3268 | double[] point1 = points[i]; |
||
3269 | double[] point2 = points[i + 1]; |
||
3270 | |||
3271 | a0e3dca4 | gaqhf | double maxLineX = Math.Max(point1[0], point2[0]); |
3272 | double minLineX = Math.Min(point1[0], point2[0]); |
||
3273 | double maxLineY = Math.Max(point1[1], point2[1]); |
||
3274 | double minLineY = Math.Min(point1[1], point2[1]); |
||
3275 | 68464385 | gaqhf | |
3276 | a0e3dca4 | gaqhf | SlopeType slope = SPPIDUtil.CalcSlope(minLineX, minLineY, maxLineX, maxLineY); |
3277 | |||
3278 | 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]); |
||
3279 | if (crossingPoint != null) |
||
3280 | { |
||
3281 | double distance = SPPIDUtil.CalcPointToPointdDistance(crossingPoint[0], crossingPoint[1], x, y); |
||
3282 | 68464385 | gaqhf | if (length >= distance) |
3283 | { |
||
3284 | a0e3dca4 | gaqhf | if (slope == SlopeType.Slope && |
3285 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0] && |
||
3286 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
3287 | { |
||
3288 | targetConnector = item.Key; |
||
3289 | length = distance; |
||
3290 | resultPoint = crossingPoint; |
||
3291 | targetVertices = item.Value; |
||
3292 | } |
||
3293 | else if (slope == SlopeType.HORIZONTAL && |
||
3294 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0]) |
||
3295 | { |
||
3296 | targetConnector = item.Key; |
||
3297 | length = distance; |
||
3298 | resultPoint = crossingPoint; |
||
3299 | targetVertices = item.Value; |
||
3300 | } |
||
3301 | else if (slope == SlopeType.VERTICAL && |
||
3302 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
3303 | { |
||
3304 | targetConnector = item.Key; |
||
3305 | length = distance; |
||
3306 | resultPoint = crossingPoint; |
||
3307 | targetVertices = item.Value; |
||
3308 | } |
||
3309 | 68464385 | gaqhf | } |
3310 | } |
||
3311 | } |
||
3312 | } |
||
3313 | |||
3314 | a0e3dca4 | gaqhf | foreach (var item in vertices) |
3315 | if (item.Key != null && item.Key != targetConnector) |
||
3316 | ReleaseCOMObjects(item.Key); |
||
3317 | |||
3318 | if (SPPIDUtil.IsBranchLine(line, targetLine)) |
||
3319 | 68464385 | gaqhf | { |
3320 | a0e3dca4 | gaqhf | double tempResultX = resultPoint[0]; |
3321 | double tempResultY = resultPoint[1]; |
||
3322 | SPPIDUtil.ConvertGridPoint(ref tempResultX, ref tempResultY); |
||
3323 | 68464385 | gaqhf | |
3324 | a0e3dca4 | gaqhf | GridSetting gridSetting = GridSetting.GetInstance(); |
3325 | |||
3326 | for (int i = 0; i < targetVertices.Count; i++) |
||
3327 | { |
||
3328 | double[] point = targetVertices[i]; |
||
3329 | double tempX = targetVertices[i][0]; |
||
3330 | double tempY = targetVertices[i][1]; |
||
3331 | SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY); |
||
3332 | if (tempX == tempResultX && tempY == tempResultY) |
||
3333 | 68464385 | gaqhf | { |
3334 | a0e3dca4 | gaqhf | if (i == 0) |
3335 | 68464385 | gaqhf | { |
3336 | a0e3dca4 | gaqhf | LMSymbol connSymbol = targetConnector.ConnectItem1SymbolObject; |
3337 | b01e7456 | gaqhf | bool containZeroLength = false; |
3338 | if (connSymbol != null) |
||
3339 | a0e3dca4 | gaqhf | { |
3340 | 1805d3b7 | gaqhf | foreach (LMConnector connector in connSymbol.Connect1Connectors) |
3341 | { |
||
3342 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
3343 | 1805d3b7 | gaqhf | containZeroLength = true; |
3344 | } |
||
3345 | foreach (LMConnector connector in connSymbol.Connect2Connectors) |
||
3346 | a0e3dca4 | gaqhf | { |
3347 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
3348 | 1805d3b7 | gaqhf | containZeroLength = true; |
3349 | a0e3dca4 | gaqhf | } |
3350 | b01e7456 | gaqhf | } |
3351 | |||
3352 | if (connSymbol == null || |
||
3353 | (connSymbol != null && connSymbol.get_ItemStatus() == "Active" && connSymbol.get_RepresentationType() != "Branch") || |
||
3354 | containZeroLength) |
||
3355 | { |
||
3356 | bool bCalcX = false; |
||
3357 | bool bCalcY = false; |
||
3358 | if (targetLine.SlopeType == SlopeType.HORIZONTAL) |
||
3359 | bCalcX = true; |
||
3360 | else if (targetLine.SlopeType == SlopeType.VERTICAL) |
||
3361 | bCalcY = true; |
||
3362 | else |
||
3363 | { |
||
3364 | bCalcX = true; |
||
3365 | bCalcY = true; |
||
3366 | } |
||
3367 | a0e3dca4 | gaqhf | |
3368 | b01e7456 | gaqhf | if (bCalcX) |
3369 | a0e3dca4 | gaqhf | { |
3370 | b01e7456 | gaqhf | double nextX = targetVertices[i + 1][0]; |
3371 | double newX = 0; |
||
3372 | if (nextX > tempX) |
||
3373 | { |
||
3374 | newX = tempX + gridSetting.Length; |
||
3375 | if (newX > nextX) |
||
3376 | newX = (point[0] + nextX) / 2; |
||
3377 | } |
||
3378 | a0e3dca4 | gaqhf | else |
3379 | { |
||
3380 | b01e7456 | gaqhf | newX = tempX - gridSetting.Length; |
3381 | if (newX < nextX) |
||
3382 | newX = (point[0] + nextX) / 2; |
||
3383 | a0e3dca4 | gaqhf | } |
3384 | b01e7456 | gaqhf | resultPoint = new double[] { newX, resultPoint[1] }; |
3385 | } |
||
3386 | a0e3dca4 | gaqhf | |
3387 | b01e7456 | gaqhf | if (bCalcY) |
3388 | { |
||
3389 | double nextY = targetVertices[i + 1][1]; |
||
3390 | double newY = 0; |
||
3391 | if (nextY > tempY) |
||
3392 | a0e3dca4 | gaqhf | { |
3393 | b01e7456 | gaqhf | newY = tempY + gridSetting.Length; |
3394 | if (newY > nextY) |
||
3395 | newY = (point[1] + nextY) / 2; |
||
3396 | a0e3dca4 | gaqhf | } |
3397 | b01e7456 | gaqhf | else |
3398 | a0e3dca4 | gaqhf | { |
3399 | b01e7456 | gaqhf | newY = tempY - gridSetting.Length; |
3400 | if (newY < nextY) |
||
3401 | newY = (point[1] + nextY) / 2; |
||
3402 | a0e3dca4 | gaqhf | } |
3403 | b01e7456 | gaqhf | resultPoint = new double[] { resultPoint[0], newY }; |
3404 | a0e3dca4 | gaqhf | } |
3405 | } |
||
3406 | } |
||
3407 | else if (i == targetVertices.Count - 1) |
||
3408 | { |
||
3409 | LMSymbol connSymbol = targetConnector.ConnectItem2SymbolObject; |
||
3410 | b01e7456 | gaqhf | bool containZeroLength = false; |
3411 | if (connSymbol != null) |
||
3412 | a0e3dca4 | gaqhf | { |
3413 | 1805d3b7 | gaqhf | foreach (LMConnector connector in connSymbol.Connect1Connectors) |
3414 | { |
||
3415 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
3416 | 1805d3b7 | gaqhf | containZeroLength = true; |
3417 | } |
||
3418 | foreach (LMConnector connector in connSymbol.Connect2Connectors) |
||
3419 | a0e3dca4 | gaqhf | { |
3420 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
3421 | 1805d3b7 | gaqhf | containZeroLength = true; |
3422 | a0e3dca4 | gaqhf | } |
3423 | b01e7456 | gaqhf | } |
3424 | |||
3425 | if (connSymbol == null || |
||
3426 | (connSymbol != null && connSymbol.get_ItemStatus() == "Active" && connSymbol.get_RepresentationType() != "Branch") || |
||
3427 | containZeroLength) |
||
3428 | { |
||
3429 | bool bCalcX = false; |
||
3430 | bool bCalcY = false; |
||
3431 | if (targetLine.SlopeType == SlopeType.HORIZONTAL) |
||
3432 | bCalcX = true; |
||
3433 | else if (targetLine.SlopeType == SlopeType.VERTICAL) |
||
3434 | bCalcY = true; |
||
3435 | else |
||
3436 | { |
||
3437 | bCalcX = true; |
||
3438 | bCalcY = true; |
||
3439 | } |
||
3440 | a0e3dca4 | gaqhf | |
3441 | b01e7456 | gaqhf | if (bCalcX) |
3442 | a0e3dca4 | gaqhf | { |
3443 | b01e7456 | gaqhf | double nextX = targetVertices[i - 1][0]; |
3444 | double newX = 0; |
||
3445 | if (nextX > tempX) |
||
3446 | { |
||
3447 | newX = tempX + gridSetting.Length; |
||
3448 | if (newX > nextX) |
||
3449 | newX = (point[0] + nextX) / 2; |
||
3450 | } |
||
3451 | a0e3dca4 | gaqhf | else |
3452 | { |
||
3453 | b01e7456 | gaqhf | newX = tempX - gridSetting.Length; |
3454 | if (newX < nextX) |
||
3455 | newX = (point[0] + nextX) / 2; |
||
3456 | a0e3dca4 | gaqhf | } |
3457 | b01e7456 | gaqhf | resultPoint = new double[] { newX, resultPoint[1] }; |
3458 | } |
||
3459 | a0e3dca4 | gaqhf | |
3460 | b01e7456 | gaqhf | if (bCalcY) |
3461 | { |
||
3462 | double nextY = targetVertices[i - 1][1]; |
||
3463 | double newY = 0; |
||
3464 | if (nextY > tempY) |
||
3465 | a0e3dca4 | gaqhf | { |
3466 | b01e7456 | gaqhf | newY = tempY + gridSetting.Length; |
3467 | if (newY > nextY) |
||
3468 | newY = (point[1] + nextY) / 2; |
||
3469 | a0e3dca4 | gaqhf | } |
3470 | b01e7456 | gaqhf | else |
3471 | a0e3dca4 | gaqhf | { |
3472 | b01e7456 | gaqhf | newY = tempY - gridSetting.Length; |
3473 | if (newY < nextY) |
||
3474 | newY = (point[1] + nextY) / 2; |
||
3475 | a0e3dca4 | gaqhf | } |
3476 | b01e7456 | gaqhf | resultPoint = new double[] { resultPoint[0], newY }; |
3477 | a0e3dca4 | gaqhf | } |
3478 | } |
||
3479 | 68464385 | gaqhf | } |
3480 | a0e3dca4 | gaqhf | break; |
3481 | 68464385 | gaqhf | } |
3482 | } |
||
3483 | } |
||
3484 | |||
3485 | a0e3dca4 | gaqhf | x = resultPoint[0]; |
3486 | y = resultPoint[1]; |
||
3487 | |||
3488 | 68464385 | gaqhf | return targetConnector; |
3489 | } |
||
3490 | |||
3491 | 1ff0105e | gaqhf | private LMConnector GetLMConnectorOnlyOne(string modelItemID) |
3492 | { |
||
3493 | LMConnector result = null; |
||
3494 | List<LMConnector> connectors = new List<LMConnector>(); |
||
3495 | LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
||
3496 | |||
3497 | if (modelItem != null) |
||
3498 | { |
||
3499 | foreach (LMRepresentation rep in modelItem.Representations) |
||
3500 | { |
||
3501 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
3502 | connectors.Add(dataSource.GetConnector(rep.Id)); |
||
3503 | } |
||
3504 | |||
3505 | ReleaseCOMObjects(modelItem); |
||
3506 | } |
||
3507 | |||
3508 | if (connectors.Count == 1) |
||
3509 | result = connectors[0]; |
||
3510 | else |
||
3511 | foreach (var item in connectors) |
||
3512 | ReleaseCOMObjects(item); |
||
3513 | |||
3514 | return result; |
||
3515 | } |
||
3516 | |||
3517 | fae4f386 | gaqhf | public List<string> GetRepresentations(string modelItemID) |
3518 | { |
||
3519 | List<string> result = new List<string>(); ; |
||
3520 | LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
||
3521 | if (modelItem != null) |
||
3522 | { |
||
3523 | foreach (LMRepresentation rep in modelItem.Representations) |
||
3524 | { |
||
3525 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
3526 | result.Add(rep.Id); |
||
3527 | } |
||
3528 | ReleaseCOMObjects(modelItem); |
||
3529 | } |
||
3530 | |||
3531 | return result; |
||
3532 | } |
||
3533 | |||
3534 | 74752074 | gaqhf | /// <summary> |
3535 | /// Line Number Symbol을 실제로 Modeling하는 메서드 |
||
3536 | /// </summary> |
||
3537 | /// <param name="lineNumber"></param> |
||
3538 | 8701de36 | gaqhf | private void LineNumberModelingOnlyOne(Line line) |
3539 | cfda1fed | gaqhf | { |
3540 | 32205389 | gaqhf | LineNumber lineNumber = document.LINENUMBERS.Find(x => x.CONNLINE == line.UID); |
3541 | if (lineNumber != null) |
||
3542 | 10872260 | gaqhf | { |
3543 | 32205389 | gaqhf | LMConnector connectedLMConnector = GetLMConnectorOnlyOne(line.SPPID.ModelItemId); |
3544 | 340515a2 | gaqhf | if (connectedLMConnector != null) |
3545 | { |
||
3546 | double x = 0; |
||
3547 | double y = 0; |
||
3548 | CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
||
3549 | b65a7e32 | gaqhf | |
3550 | 340515a2 | gaqhf | Array points = new double[] { 0, x, y }; |
3551 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
||
3552 | cfda1fed | gaqhf | |
3553 | 340515a2 | gaqhf | if (_LmLabelPresist != null) |
3554 | { |
||
3555 | _LmLabelPresist.Commit(); |
||
3556 | lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
||
3557 | ReleaseCOMObjects(_LmLabelPresist); |
||
3558 | } |
||
3559 | c3d2e266 | gaqhf | } |
3560 | 10872260 | gaqhf | } |
3561 | cfda1fed | gaqhf | } |
3562 | 02a45794 | gaqhf | |
3563 | 8701de36 | gaqhf | private void LineNumberModeling(LineNumber lineNumber) |
3564 | { |
||
3565 | Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line; |
||
3566 | if (line != null) |
||
3567 | { |
||
3568 | double x = 0; |
||
3569 | double y = 0; |
||
3570 | CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
||
3571 | |||
3572 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
3573 | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, x, y); |
||
3574 | if (connectedLMConnector != null) |
||
3575 | { |
||
3576 | Array points = new double[] { 0, x, y }; |
||
3577 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
||
3578 | ca6e0f51 | gaqhf | |
3579 | 8701de36 | gaqhf | if (_LmLabelPresist != null) |
3580 | { |
||
3581 | _LmLabelPresist.Commit(); |
||
3582 | lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
||
3583 | ReleaseCOMObjects(_LmLabelPresist); |
||
3584 | } |
||
3585 | } |
||
3586 | |||
3587 | foreach (var item in connectorVertices) |
||
3588 | ReleaseCOMObjects(item.Key); |
||
3589 | } |
||
3590 | } |
||
3591 | 74752074 | gaqhf | /// <summary> |
3592 | b2d1c1aa | gaqhf | /// Flow Mark Modeling |
3593 | /// </summary> |
||
3594 | /// <param name="line"></param> |
||
3595 | private void FlowMarkModeling(Line line) |
||
3596 | { |
||
3597 | a0965e07 | gaqhf | if (line.FLOWMARK && !string.IsNullOrEmpty(line.SPPID.ModelItemId) && !string.IsNullOrEmpty(_ETCSetting.FlowMarkSymbolPath)) |
3598 | b2d1c1aa | gaqhf | { |
3599 | 32205389 | gaqhf | LMConnector connector = GetLMConnectorOnlyOne(line.SPPID.ModelItemId); |
3600 | if (connector != null) |
||
3601 | b2d1c1aa | gaqhf | { |
3602 | 32205389 | gaqhf | string mappingPath = _ETCSetting.FlowMarkSymbolPath; |
3603 | List<double[]> vertices = GetConnectorVertices(connector); |
||
3604 | vertices = vertices.FindAll(x => x[0] > 0 && x[1] > 0); |
||
3605 | double[] point = vertices[vertices.Count - 1]; |
||
3606 | Array array = new double[] { 0, point[0], point[1] }; |
||
3607 | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mappingPath, ref array, LabeledItem: connector.AsLMRepresentation()); |
||
3608 | if (_LMLabelPersist != null) |
||
3609 | 04fcadf1 | gaqhf | { |
3610 | _LMLabelPersist.Commit(); |
||
3611 | 32205389 | gaqhf | ReleaseCOMObjects(_LMLabelPersist); |
3612 | 04fcadf1 | gaqhf | } |
3613 | |||
3614 | b2d1c1aa | gaqhf | } |
3615 | } |
||
3616 | } |
||
3617 | |||
3618 | /// <summary> |
||
3619 | 74752074 | gaqhf | /// Line Number 기준으로 모든 Item에 Line Number의 Attribute Input |
3620 | /// </summary> |
||
3621 | /// <param name="lineNumber"></param> |
||
3622 | 82d6e5ea | gaqhf | private void InputLineNumberAttribute(LineNumber lineNumber, List<string> endLine) |
3623 | a7e9beec | gaqhf | { |
3624 | 8634af60 | gaqhf | foreach (LineRun run in lineNumber.RUNS) |
3625 | a7e9beec | gaqhf | { |
3626 | 8634af60 | gaqhf | foreach (var item in run.RUNITEMS) |
3627 | a7e9beec | gaqhf | { |
3628 | 48fd75e2 | gaqhf | if (item.GetType() == typeof(Symbol)) |
3629 | { |
||
3630 | Symbol symbol = item as Symbol; |
||
3631 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
3632 | if (_LMSymbol != null) |
||
3633 | { |
||
3634 | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
||
3635 | |||
3636 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3637 | { |
||
3638 | foreach (var attribute in lineNumber.ATTRIBUTES) |
||
3639 | { |
||
3640 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
3641 | if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3642 | { |
||
3643 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
3644 | if (_LMAAttribute != null) |
||
3645 | { |
||
3646 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
3647 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3648 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
3649 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3650 | } |
||
3651 | } |
||
3652 | } |
||
3653 | _LMModelItem.Commit(); |
||
3654 | } |
||
3655 | if (_LMModelItem != null) |
||
3656 | ReleaseCOMObjects(_LMModelItem); |
||
3657 | } |
||
3658 | if (_LMSymbol != null) |
||
3659 | ReleaseCOMObjects(_LMSymbol); |
||
3660 | } |
||
3661 | else if (item.GetType() == typeof(Line)) |
||
3662 | 8634af60 | gaqhf | { |
3663 | Line line = item as Line; |
||
3664 | 82d6e5ea | gaqhf | if (line != null && !endLine.Contains(line.SPPID.ModelItemId)) |
3665 | a7e9beec | gaqhf | { |
3666 | 8634af60 | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
3667 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3668 | a7e9beec | gaqhf | { |
3669 | 8634af60 | gaqhf | foreach (var attribute in lineNumber.ATTRIBUTES) |
3670 | { |
||
3671 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
3672 | b2d1c1aa | gaqhf | if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
3673 | 8634af60 | gaqhf | { |
3674 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
3675 | if (_LMAAttribute != null) |
||
3676 | { |
||
3677 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
3678 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3679 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
3680 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3681 | 7f00b26c | gaqhf | |
3682 | 8634af60 | gaqhf | } |
3683 | } |
||
3684 | } |
||
3685 | 68464385 | gaqhf | _LMModelItem.Commit(); |
3686 | a7e9beec | gaqhf | } |
3687 | 8634af60 | gaqhf | if (_LMModelItem != null) |
3688 | ReleaseCOMObjects(_LMModelItem); |
||
3689 | 82d6e5ea | gaqhf | endLine.Add(line.SPPID.ModelItemId); |
3690 | a7e9beec | gaqhf | } |
3691 | } |
||
3692 | } |
||
3693 | } |
||
3694 | } |
||
3695 | |||
3696 | 74752074 | gaqhf | /// <summary> |
3697 | /// Symbol Attribute 입력 메서드 |
||
3698 | /// </summary> |
||
3699 | 73415441 | gaqhf | /// <param name="item"></param> |
3700 | private void InputSymbolAttribute(object targetItem, List<BaseModel.Attribute> targetAttributes) |
||
3701 | 1efc25a3 | gaqhf | { |
3702 | 7f00b26c | gaqhf | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
3703 | string sRep = null; |
||
3704 | if (targetItem.GetType() == typeof(Symbol)) |
||
3705 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
3706 | else if (targetItem.GetType() == typeof(Equipment)) |
||
3707 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
3708 | |||
3709 | if (!string.IsNullOrEmpty(sRep)) |
||
3710 | 1efc25a3 | gaqhf | { |
3711 | 7f00b26c | gaqhf | LMSymbol _LMSymbol = dataSource.GetSymbol(sRep); |
3712 | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
||
3713 | LMAAttributes _Attributes = _LMModelItem.Attributes; |
||
3714 | ca6e0f51 | gaqhf | |
3715 | 7f00b26c | gaqhf | foreach (var item in targetAttributes) |
3716 | { |
||
3717 | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
||
3718 | if (mapping != null && !string.IsNullOrEmpty(item.VALUE) && item.VALUE != "None") |
||
3719 | 65a1ed4b | gaqhf | { |
3720 | 7f00b26c | gaqhf | LMAAttribute _Attribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
3721 | if (_Attribute != null) |
||
3722 | 30ba9ae0 | gaqhf | { |
3723 | object associItem = SPPIDUtil.FindObjectByUID(document, item.ASSOCITEM); |
||
3724 | if (associItem != null) |
||
3725 | { |
||
3726 | if (associItem.GetType() == typeof(Text)) |
||
3727 | { |
||
3728 | Text text = associItem as Text; |
||
3729 | text.SPPID.RepresentationId = "Attribute"; |
||
3730 | } |
||
3731 | else if (associItem.GetType() == typeof(Note)) |
||
3732 | { |
||
3733 | Note note = associItem as Note; |
||
3734 | note.SPPID.RepresentationId = "Attribute"; |
||
3735 | } |
||
3736 | } |
||
3737 | 7f00b26c | gaqhf | _Attribute.set_Value(item.VALUE); |
3738 | b7a29053 | gaqhf | // OPC 일경우 Attribute 저장 |
3739 | if (targetItem.GetType() == typeof(Symbol)) |
||
3740 | { |
||
3741 | Symbol symbol = targetItem as Symbol; |
||
3742 | if (symbol.TYPE == "Piping OPC's" || symbol.TYPE == "Instrument OPC's") |
||
3743 | symbol.SPPID.Attributes.Add(new string[] { mapping.SPPIDATTRIBUTENAME, item.VALUE }); |
||
3744 | } |
||
3745 | 30ba9ae0 | gaqhf | } |
3746 | 65a1ed4b | gaqhf | } |
3747 | ac78b508 | gaqhf | } |
3748 | 7f00b26c | gaqhf | _LMModelItem.Commit(); |
3749 | |||
3750 | ReleaseCOMObjects(_Attributes); |
||
3751 | ReleaseCOMObjects(_LMModelItem); |
||
3752 | ReleaseCOMObjects(_LMSymbol); |
||
3753 | 1efc25a3 | gaqhf | } |
3754 | } |
||
3755 | |||
3756 | 74752074 | gaqhf | /// <summary> |
3757 | 16584d30 | gaqhf | /// Input SpecBreak Attribute |
3758 | /// </summary> |
||
3759 | /// <param name="specBreak"></param> |
||
3760 | private void InputSpecBreakAttribute(SpecBreak specBreak) |
||
3761 | { |
||
3762 | 7f00b26c | gaqhf | object upStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.UpStreamUID); |
3763 | object downStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.DownStreamUID); |
||
3764 | |||
3765 | if (upStreamObj != null && |
||
3766 | downStreamObj != null) |
||
3767 | 16584d30 | gaqhf | { |
3768 | 7f00b26c | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
3769 | 16584d30 | gaqhf | |
3770 | 7f00b26c | gaqhf | if (targetLMConnector != null) |
3771 | 16584d30 | gaqhf | { |
3772 | 7f00b26c | gaqhf | foreach (LMLabelPersist _LMLabelPersist in targetLMConnector.LabelPersists) |
3773 | 16584d30 | gaqhf | { |
3774 | 7f00b26c | gaqhf | string symbolPath = _LMLabelPersist.get_FileName(); |
3775 | AttributeMapping mapping = document.AttributeMappings.Find(x => x.SPPIDSYMBOLNAME == symbolPath); |
||
3776 | if (mapping != null) |
||
3777 | 16584d30 | gaqhf | { |
3778 | 7f00b26c | gaqhf | BaseModel.Attribute attribute = specBreak.ATTRIBUTES.Find(y => y.UID == mapping.UID); |
3779 | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3780 | 16584d30 | gaqhf | { |
3781 | 7f00b26c | gaqhf | string[] values = attribute.VALUE.Split(new char[] { ',' }); |
3782 | if (values.Length == 2) |
||
3783 | 16584d30 | gaqhf | { |
3784 | 7f00b26c | gaqhf | string upStreamValue = values[0]; |
3785 | string downStreamValue = values[1]; |
||
3786 | 16584d30 | gaqhf | |
3787 | 7f00b26c | gaqhf | InputAttributeForSpecBreak(upStreamObj, downStreamObj, upStreamValue, downStreamValue, mapping.SPPIDATTRIBUTENAME); |
3788 | 16584d30 | gaqhf | } |
3789 | } |
||
3790 | } |
||
3791 | } |
||
3792 | 7f00b26c | gaqhf | |
3793 | ReleaseCOMObjects(targetLMConnector); |
||
3794 | 16584d30 | gaqhf | } |
3795 | } |
||
3796 | 7f00b26c | gaqhf | |
3797 | 16584d30 | gaqhf | |
3798 | #region 내부에서만 쓰는 메서드 |
||
3799 | 7f00b26c | gaqhf | void InputAttributeForSpecBreak(object _upStreamObj, object _downStreamObj, string upStreamValue, string downStreamValue, string sppidAttributeName) |
3800 | 16584d30 | gaqhf | { |
3801 | 7f00b26c | gaqhf | Symbol upStreamSymbol = _upStreamObj as Symbol; |
3802 | Line upStreamLine = _upStreamObj as Line; |
||
3803 | Symbol downStreamSymbol = _downStreamObj as Symbol; |
||
3804 | Line downStreamLine = _downStreamObj as Line; |
||
3805 | // 둘다 Line일 경우 |
||
3806 | if (upStreamLine != null && downStreamLine != null) |
||
3807 | 16584d30 | gaqhf | { |
3808 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLine(upStreamLine, sppidAttributeName, upStreamValue); |
3809 | InputLineAttributeForSpecBreakLine(downStreamLine, sppidAttributeName, downStreamValue); |
||
3810 | } |
||
3811 | // 둘다 Symbol일 경우 |
||
3812 | else if (upStreamSymbol != null && downStreamSymbol != null) |
||
3813 | { |
||
3814 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamSymbol, downStreamSymbol); |
||
3815 | LMSymbol upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
||
3816 | LMSymbol downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
||
3817 | 16584d30 | gaqhf | |
3818 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
3819 | { |
||
3820 | if (connector.get_ItemStatus() != "Active") |
||
3821 | continue; |
||
3822 | 16584d30 | gaqhf | |
3823 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3824 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3825 | } |
||
3826 | 16584d30 | gaqhf | |
3827 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
3828 | { |
||
3829 | if (connector.get_ItemStatus() != "Active") |
||
3830 | continue; |
||
3831 | 16584d30 | gaqhf | |
3832 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3833 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3834 | } |
||
3835 | 16584d30 | gaqhf | |
3836 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors) |
3837 | { |
||
3838 | if (connector.get_ItemStatus() != "Active") |
||
3839 | continue; |
||
3840 | 16584d30 | gaqhf | |
3841 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3842 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3843 | } |
||
3844 | 16584d30 | gaqhf | |
3845 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
3846 | { |
||
3847 | if (connector.get_ItemStatus() != "Active") |
||
3848 | continue; |
||
3849 | 16584d30 | gaqhf | |
3850 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3851 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3852 | 16584d30 | gaqhf | } |
3853 | |||
3854 | 7f00b26c | gaqhf | ReleaseCOMObjects(zeroLenthConnector); |
3855 | ReleaseCOMObjects(upStreamLMSymbol); |
||
3856 | ReleaseCOMObjects(downStreamLMSymbol); |
||
3857 | } |
||
3858 | else if (upStreamSymbol != null && downStreamLine != null) |
||
3859 | { |
||
3860 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamSymbol, downStreamLine); |
||
3861 | InputLineAttributeForSpecBreakLine(downStreamLine, sppidAttributeName, downStreamValue); |
||
3862 | LMSymbol upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
||
3863 | 16584d30 | gaqhf | |
3864 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
3865 | { |
||
3866 | if (connector.get_ItemStatus() != "Active") |
||
3867 | continue; |
||
3868 | 16584d30 | gaqhf | |
3869 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3870 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
3871 | } |
||
3872 | 16584d30 | gaqhf | |
3873 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
3874 | { |
||
3875 | if (connector.get_ItemStatus() != "Active") |
||
3876 | continue; |
||
3877 | 16584d30 | gaqhf | |
3878 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3879 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
3880 | 16584d30 | gaqhf | } |
3881 | |||
3882 | 7f00b26c | gaqhf | ReleaseCOMObjects(zeroLenthConnector); |
3883 | ReleaseCOMObjects(upStreamLMSymbol); |
||
3884 | } |
||
3885 | else if (upStreamLine != null && downStreamSymbol != null) |
||
3886 | { |
||
3887 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamLine, downStreamSymbol); |
||
3888 | InputLineAttributeForSpecBreakLine(upStreamLine, sppidAttributeName, upStreamValue); |
||
3889 | LMSymbol downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
||
3890 | 16584d30 | gaqhf | |
3891 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors) |
3892 | { |
||
3893 | if (connector.get_ItemStatus() != "Active") |
||
3894 | continue; |
||
3895 | 16584d30 | gaqhf | |
3896 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3897 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
3898 | } |
||
3899 | 16584d30 | gaqhf | |
3900 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
3901 | { |
||
3902 | if (connector.get_ItemStatus() != "Active") |
||
3903 | continue; |
||
3904 | 16584d30 | gaqhf | |
3905 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3906 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
3907 | 16584d30 | gaqhf | } |
3908 | 7f00b26c | gaqhf | |
3909 | ReleaseCOMObjects(zeroLenthConnector); |
||
3910 | ReleaseCOMObjects(downStreamLMSymbol); |
||
3911 | 16584d30 | gaqhf | } |
3912 | } |
||
3913 | |||
3914 | void InputLineAttributeForSpecBreakLine(Line line, string attrName, string value) |
||
3915 | { |
||
3916 | 7f00b26c | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
3917 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3918 | 16584d30 | gaqhf | { |
3919 | 7f00b26c | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[attrName]; |
3920 | if (_LMAAttribute != null) |
||
3921 | 16584d30 | gaqhf | { |
3922 | 7f00b26c | gaqhf | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
3923 | _LMAAttribute.set_Value(value); |
||
3924 | else if (_LMAAttribute.get_Value() != value) |
||
3925 | _LMAAttribute.set_Value(value); |
||
3926 | 16584d30 | gaqhf | } |
3927 | 7f00b26c | gaqhf | |
3928 | _LMModelItem.Commit(); |
||
3929 | 16584d30 | gaqhf | } |
3930 | 7f00b26c | gaqhf | if (_LMModelItem != null) |
3931 | ReleaseCOMObjects(_LMModelItem); |
||
3932 | 16584d30 | gaqhf | } |
3933 | |||
3934 | void InputLineAttributeForSpecBreakLMConnector(LMConnector connector, string attrName, string value) |
||
3935 | { |
||
3936 | 7f00b26c | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(connector.ModelItemID); |
3937 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3938 | 16584d30 | gaqhf | { |
3939 | 7f00b26c | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[attrName]; |
3940 | if (_LMAAttribute != null) |
||
3941 | 16584d30 | gaqhf | { |
3942 | 7f00b26c | gaqhf | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
3943 | _LMAAttribute.set_Value(value); |
||
3944 | else if (_LMAAttribute.get_Value() != value) |
||
3945 | _LMAAttribute.set_Value(value); |
||
3946 | 16584d30 | gaqhf | } |
3947 | 7f00b26c | gaqhf | |
3948 | _LMModelItem.Commit(); |
||
3949 | 16584d30 | gaqhf | } |
3950 | 7f00b26c | gaqhf | if (_LMModelItem != null) |
3951 | ReleaseCOMObjects(_LMModelItem); |
||
3952 | 16584d30 | gaqhf | } |
3953 | #endregion |
||
3954 | } |
||
3955 | |||
3956 | /// <summary> |
||
3957 | 74752074 | gaqhf | /// Text Modeling - Association일 경우는 Text대신 해당 맵핑된 Symbol로 모델링 |
3958 | /// </summary> |
||
3959 | /// <param name="text"></param> |
||
3960 | 1299077b | gaqhf | private void TextModeling(Text text, List<Text> correctList) |
3961 | cfda1fed | gaqhf | { |
3962 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
3963 | 0860c756 | gaqhf | LMConnector connectedLMConnector = null; |
3964 | 7f00b26c | gaqhf | //if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
3965 | if (text.ASSOCIATION) |
||
3966 | 6b298450 | gaqhf | { |
3967 | 7f00b26c | gaqhf | object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
3968 | 3783c494 | gaqhf | if (owner != null && owner.GetType() == typeof(Symbol)) |
3969 | ea80efaa | gaqhf | { |
3970 | 7f00b26c | gaqhf | Symbol symbol = owner as Symbol; |
3971 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
3972 | if (_LMSymbol != null) |
||
3973 | ea80efaa | gaqhf | { |
3974 | 7f00b26c | gaqhf | BaseModel.Attribute attribute = symbol.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
3975 | 3734dcc5 | gaqhf | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
3976 | 0860c756 | gaqhf | { |
3977 | 7f00b26c | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
3978 | 0860c756 | gaqhf | |
3979 | if (mapping != null) |
||
3980 | { |
||
3981 | double x = 0; |
||
3982 | double y = 0; |
||
3983 | |||
3984 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
||
3985 | 1299077b | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
3986 | 0860c756 | gaqhf | Array array = new double[] { 0, x, y }; |
3987 | 7f00b26c | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
3988 | 0860c756 | gaqhf | if (_LMLabelPersist != null) |
3989 | { |
||
3990 | 30ba9ae0 | gaqhf | text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
3991 | 0860c756 | gaqhf | _LMLabelPersist.Commit(); |
3992 | ReleaseCOMObjects(_LMLabelPersist); |
||
3993 | } |
||
3994 | } |
||
3995 | } |
||
3996 | ea80efaa | gaqhf | } |
3997 | } |
||
3998 | 3783c494 | gaqhf | else if (owner != null && owner.GetType() == typeof(Line)) |
3999 | ea80efaa | gaqhf | { |
4000 | 7f00b26c | gaqhf | Line line = owner as Line; |
4001 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
4002 | connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y); |
||
4003 | ea80efaa | gaqhf | |
4004 | 7f00b26c | gaqhf | if (connectedLMConnector != null) |
4005 | { |
||
4006 | 83c14a07 | gaqhf | BaseModel.Attribute attribute = line.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
4007 | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
4008 | 7f00b26c | gaqhf | { |
4009 | 83c14a07 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
4010 | 7f00b26c | gaqhf | |
4011 | if (mapping != null) |
||
4012 | 83c14a07 | gaqhf | { |
4013 | double x = 0; |
||
4014 | double y = 0; |
||
4015 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
||
4016 | 1299077b | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
4017 | 83c14a07 | gaqhf | Array array = new double[] { 0, x, y }; |
4018 | ea80efaa | gaqhf | |
4019 | 83c14a07 | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
4020 | if (_LMLabelPersist != null) |
||
4021 | { |
||
4022 | 30ba9ae0 | gaqhf | text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
4023 | 83c14a07 | gaqhf | _LMLabelPersist.Commit(); |
4024 | ReleaseCOMObjects(_LMLabelPersist); |
||
4025 | } |
||
4026 | 7f00b26c | gaqhf | } |
4027 | } |
||
4028 | } |
||
4029 | ea80efaa | gaqhf | } |
4030 | 6b298450 | gaqhf | } |
4031 | 7f00b26c | gaqhf | else |
4032 | 6b298450 | gaqhf | { |
4033 | 7f00b26c | gaqhf | LMItemNote _LMItemNote = null; |
4034 | LMAAttribute _LMAAttribute = null; |
||
4035 | cfda1fed | gaqhf | |
4036 | 7f00b26c | gaqhf | double x = 0; |
4037 | double y = 0; |
||
4038 | double angle = text.ANGLE; |
||
4039 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
||
4040 | |||
4041 | 1299077b | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
4042 | text.SPPID.SPPID_X = x; |
||
4043 | text.SPPID.SPPID_Y = y; |
||
4044 | |||
4045 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y, Rotation: angle); |
4046 | 30ba9ae0 | gaqhf | if (_LMSymbol != null) |
4047 | { |
||
4048 | _LMSymbol.Commit(); |
||
4049 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
4050 | if (_LMItemNote != null) |
||
4051 | { |
||
4052 | _LMItemNote.Commit(); |
||
4053 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
4054 | if (_LMAAttribute != null) |
||
4055 | { |
||
4056 | _LMAAttribute.set_Value(text.VALUE); |
||
4057 | text.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
4058 | _LMItemNote.Commit(); |
||
4059 | |||
4060 | 1299077b | gaqhf | |
4061 | double[] range = null; |
||
4062 | foreach (LMLabelPersist labelPersist in _LMSymbol.LabelPersists) |
||
4063 | { |
||
4064 | double[] temp = null; |
||
4065 | GetSPPIDSymbolRange(labelPersist, ref temp); |
||
4066 | if (temp != null) |
||
4067 | { |
||
4068 | if (range == null) |
||
4069 | range = temp; |
||
4070 | else |
||
4071 | { |
||
4072 | range = new double[] { |
||
4073 | Math.Min(range[0], temp[0]), |
||
4074 | Math.Min(range[1], temp[1]), |
||
4075 | Math.Max(range[2], temp[2]), |
||
4076 | Math.Max(range[3], temp[3]) |
||
4077 | }; |
||
4078 | } |
||
4079 | } |
||
4080 | } |
||
4081 | if (range != null) |
||
4082 | correctList.Add(text); |
||
4083 | text.SPPID.Range = range; |
||
4084 | |||
4085 | |||
4086 | 30ba9ae0 | gaqhf | if (_LMAAttribute != null) |
4087 | ReleaseCOMObjects(_LMAAttribute); |
||
4088 | if (_LMItemNote != null) |
||
4089 | ReleaseCOMObjects(_LMItemNote); |
||
4090 | } |
||
4091 | } |
||
4092 | } |
||
4093 | 6b298450 | gaqhf | } |
4094 | 7f00b26c | gaqhf | if (_LMSymbol != null) |
4095 | ReleaseCOMObjects(_LMSymbol); |
||
4096 | cfda1fed | gaqhf | } |
4097 | |||
4098 | 1299077b | gaqhf | private void TextCorrectModeling(Text text, List<Text> endList) |
4099 | { |
||
4100 | bool needRemodeling = false; |
||
4101 | bool loop = true; |
||
4102 | GridSetting gridSetting = GridSetting.GetInstance(); |
||
4103 | while (loop) |
||
4104 | { |
||
4105 | loop = false; |
||
4106 | foreach (var overlapText in endList) |
||
4107 | { |
||
4108 | if (SPPIDUtil.IsOverlap(overlapText.SPPID.Range, text.SPPID.Range)) |
||
4109 | { |
||
4110 | double tempX = 0; |
||
4111 | double tempY = 0; |
||
4112 | bool overlapX = false; |
||
4113 | bool overlapY = false; |
||
4114 | SPPIDUtil.CalcOverlap(text.SPPID.Range, overlapText.SPPID.Range, ref tempX, ref tempY, ref overlapX, ref overlapY); |
||
4115 | double angle = SPPIDUtil.CalcAngle(text.LOCATION_X, text.LOCATION_Y, overlapText.LOCATION_X, overlapText.LOCATION_Y); |
||
4116 | if (overlapY && angle >= 45) |
||
4117 | { |
||
4118 | int count = Convert.ToInt32(tempY / gridSetting.Length) + 1; |
||
4119 | double move = gridSetting.Length * count; |
||
4120 | text.SPPID.SPPID_Y = text.SPPID.SPPID_Y - move; |
||
4121 | text.SPPID.Range = new double[] { text.SPPID.Range[0], text.SPPID.Range[1] - move, text.SPPID.Range[2], text.SPPID.Range[3] - move }; |
||
4122 | needRemodeling = true; |
||
4123 | loop = true; |
||
4124 | } |
||
4125 | if (overlapX && angle <= 45) |
||
4126 | { |
||
4127 | int count = Convert.ToInt32(tempX / gridSetting.Length) + 1; |
||
4128 | double move = gridSetting.Length * count; |
||
4129 | text.SPPID.SPPID_X = text.SPPID.SPPID_X + move; |
||
4130 | text.SPPID.Range = new double[] { text.SPPID.Range[0] + move, text.SPPID.Range[1], text.SPPID.Range[2] + move, text.SPPID.Range[3] }; |
||
4131 | needRemodeling = true; |
||
4132 | loop = true; |
||
4133 | } |
||
4134 | } |
||
4135 | } |
||
4136 | } |
||
4137 | |||
4138 | |||
4139 | if (needRemodeling) |
||
4140 | { |
||
4141 | LMSymbol symbol = dataSource.GetSymbol(text.SPPID.RepresentationId); |
||
4142 | _placement.PIDRemovePlacement(symbol.AsLMRepresentation()); |
||
4143 | text.SPPID.RepresentationId = null; |
||
4144 | |||
4145 | LMItemNote _LMItemNote = null; |
||
4146 | LMAAttribute _LMAAttribute = null; |
||
4147 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, text.SPPID.SPPID_X, text.SPPID.SPPID_Y, Rotation: text.ANGLE); |
||
4148 | if (_LMSymbol != null) |
||
4149 | { |
||
4150 | _LMSymbol.Commit(); |
||
4151 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
4152 | if (_LMItemNote != null) |
||
4153 | { |
||
4154 | _LMItemNote.Commit(); |
||
4155 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
4156 | if (_LMAAttribute != null) |
||
4157 | { |
||
4158 | _LMAAttribute.set_Value(text.VALUE); |
||
4159 | text.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
4160 | _LMItemNote.Commit(); |
||
4161 | |||
4162 | ReleaseCOMObjects(_LMAAttribute); |
||
4163 | ReleaseCOMObjects(_LMItemNote); |
||
4164 | } |
||
4165 | } |
||
4166 | } |
||
4167 | |||
4168 | ReleaseCOMObjects(symbol); |
||
4169 | symbol = null; |
||
4170 | ReleaseCOMObjects(_LMItemNote); |
||
4171 | _LMItemNote = null; |
||
4172 | ReleaseCOMObjects(_LMAAttribute); |
||
4173 | _LMAAttribute = null; |
||
4174 | ReleaseCOMObjects(_LMSymbol); |
||
4175 | _LMSymbol = null; |
||
4176 | } |
||
4177 | |||
4178 | endList.Add(text); |
||
4179 | } |
||
4180 | |||
4181 | 74752074 | gaqhf | /// <summary> |
4182 | /// Note Modeling |
||
4183 | /// </summary> |
||
4184 | /// <param name="note"></param> |
||
4185 | 1299077b | gaqhf | private void NoteModeling(Note note, List<Note> correctList) |
4186 | cfda1fed | gaqhf | { |
4187 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
4188 | LMItemNote _LMItemNote = null; |
||
4189 | LMAAttribute _LMAAttribute = null; |
||
4190 | |||
4191 | 7f00b26c | gaqhf | if (string.IsNullOrEmpty(note.OWNER) || note.OWNER == "None") |
4192 | 6b298450 | gaqhf | { |
4193 | 7f00b26c | gaqhf | double x = 0; |
4194 | double y = 0; |
||
4195 | fc0a8c33 | gaqhf | |
4196 | 7f00b26c | gaqhf | CalcLabelLocation(ref x, ref y, note.SPPID.ORIGINAL_X, note.SPPID.ORIGINAL_Y, note.SPPIDLabelLocation, _ETCSetting.NoteLocation); |
4197 | 1299077b | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
4198 | note.SPPID.SPPID_X = x; |
||
4199 | note.SPPID.SPPID_Y = y; |
||
4200 | fc0a8c33 | gaqhf | |
4201 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(note.SPPID.MAPPINGNAME, x, y); |
4202 | 30ba9ae0 | gaqhf | if (_LMSymbol != null) |
4203 | { |
||
4204 | _LMSymbol.Commit(); |
||
4205 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
4206 | if (_LMItemNote != null) |
||
4207 | { |
||
4208 | _LMItemNote.Commit(); |
||
4209 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
4210 | if (_LMAAttribute != null) |
||
4211 | { |
||
4212 | _LMAAttribute.set_Value(note.VALUE); |
||
4213 | note.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
4214 | 1299077b | gaqhf | |
4215 | double[] range = null; |
||
4216 | foreach (LMLabelPersist labelPersist in _LMSymbol.LabelPersists) |
||
4217 | { |
||
4218 | double[] temp = null; |
||
4219 | GetSPPIDSymbolRange(labelPersist, ref temp); |
||
4220 | if (temp != null) |
||
4221 | { |
||
4222 | if (range == null) |
||
4223 | range = temp; |
||
4224 | else |
||
4225 | { |
||
4226 | range = new double[] { |
||
4227 | Math.Min(range[0], temp[0]), |
||
4228 | Math.Min(range[1], temp[1]), |
||
4229 | Math.Max(range[2], temp[2]), |
||
4230 | Math.Max(range[3], temp[3]) |
||
4231 | }; |
||
4232 | } |
||
4233 | } |
||
4234 | } |
||
4235 | if (range != null) |
||
4236 | correctList.Add(note); |
||
4237 | note.SPPID.Range = range; |
||
4238 | |||
4239 | |||
4240 | 30ba9ae0 | gaqhf | _LMItemNote.Commit(); |
4241 | } |
||
4242 | } |
||
4243 | } |
||
4244 | 6b298450 | gaqhf | } |
4245 | cfda1fed | gaqhf | |
4246 | 7f00b26c | gaqhf | if (_LMAAttribute != null) |
4247 | ReleaseCOMObjects(_LMAAttribute); |
||
4248 | if (_LMItemNote != null) |
||
4249 | ReleaseCOMObjects(_LMItemNote); |
||
4250 | if (_LMSymbol != null) |
||
4251 | ReleaseCOMObjects(_LMSymbol); |
||
4252 | cfda1fed | gaqhf | } |
4253 | |||
4254 | 1299077b | gaqhf | private void NoteCorrectModeling(Note note, List<Note> endList) |
4255 | { |
||
4256 | bool needRemodeling = false; |
||
4257 | bool loop = true; |
||
4258 | GridSetting gridSetting = GridSetting.GetInstance(); |
||
4259 | while (loop) |
||
4260 | { |
||
4261 | loop = false; |
||
4262 | foreach (var overlap in endList) |
||
4263 | { |
||
4264 | ba25c427 | gaqhf | if (SPPIDUtil.IsOverlap(overlap.SPPID.Range, note.SPPID.Range)) |
4265 | 1299077b | gaqhf | { |
4266 | ba25c427 | gaqhf | double tempX = 0; |
4267 | double tempY = 0; |
||
4268 | bool overlapX = false; |
||
4269 | bool overlapY = false; |
||
4270 | SPPIDUtil.CalcOverlap(note.SPPID.Range, overlap.SPPID.Range, ref tempX, ref tempY, ref overlapX, ref overlapY); |
||
4271 | double angle = SPPIDUtil.CalcAngle(note.LOCATION_X, note.LOCATION_Y, overlap.LOCATION_X, overlap.LOCATION_Y); |
||
4272 | if (overlapY && angle >= 45) |
||
4273 | 1299077b | gaqhf | { |
4274 | ba25c427 | gaqhf | int count = Convert.ToInt32(tempY / gridSetting.Length) + 1; |
4275 | double move = gridSetting.Length * count; |
||
4276 | note.SPPID.SPPID_Y = note.SPPID.SPPID_Y - move; |
||
4277 | note.SPPID.Range = new double[] { note.SPPID.Range[0], note.SPPID.Range[1] - move, note.SPPID.Range[2], note.SPPID.Range[3] - move }; |
||
4278 | needRemodeling = true; |
||
4279 | loop = true; |
||
4280 | } |
||
4281 | if (overlapX && angle <= 45) |
||
4282 | { |
||
4283 | int count = Convert.ToInt32(tempX / gridSetting.Length) + 1; |
||
4284 | double move = gridSetting.Length * count; |
||
4285 | note.SPPID.SPPID_X = note.SPPID.SPPID_X + move; |
||
4286 | note.SPPID.Range = new double[] { note.SPPID.Range[0] + move, note.SPPID.Range[1], note.SPPID.Range[2] + move, note.SPPID.Range[3] }; |
||
4287 | needRemodeling = true; |
||
4288 | loop = true; |
||
4289 | 1299077b | gaqhf | } |
4290 | } |
||
4291 | } |
||
4292 | } |
||
4293 | |||
4294 | |||
4295 | if (needRemodeling) |
||
4296 | { |
||
4297 | LMSymbol symbol = dataSource.GetSymbol(note.SPPID.RepresentationId); |
||
4298 | _placement.PIDRemovePlacement(symbol.AsLMRepresentation()); |
||
4299 | note.SPPID.RepresentationId = null; |
||
4300 | |||
4301 | LMItemNote _LMItemNote = null; |
||
4302 | LMAAttribute _LMAAttribute = null; |
||
4303 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(note.SPPID.MAPPINGNAME, note.SPPID.SPPID_X, note.SPPID.SPPID_Y, Rotation: note.ANGLE); |
||
4304 | if (_LMSymbol != null) |
||
4305 | { |
||
4306 | _LMSymbol.Commit(); |
||
4307 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
4308 | if (_LMItemNote != null) |
||
4309 | { |
||
4310 | _LMItemNote.Commit(); |
||
4311 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
4312 | if (_LMAAttribute != null) |
||
4313 | { |
||
4314 | _LMAAttribute.set_Value(note.VALUE); |
||
4315 | note.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
4316 | _LMItemNote.Commit(); |
||
4317 | |||
4318 | ReleaseCOMObjects(_LMAAttribute); |
||
4319 | ReleaseCOMObjects(_LMItemNote); |
||
4320 | } |
||
4321 | } |
||
4322 | } |
||
4323 | |||
4324 | ReleaseCOMObjects(symbol); |
||
4325 | symbol = null; |
||
4326 | ReleaseCOMObjects(_LMItemNote); |
||
4327 | _LMItemNote = null; |
||
4328 | ReleaseCOMObjects(_LMAAttribute); |
||
4329 | _LMAAttribute = null; |
||
4330 | ReleaseCOMObjects(_LMSymbol); |
||
4331 | _LMSymbol = null; |
||
4332 | } |
||
4333 | |||
4334 | endList.Add(note); |
||
4335 | } |
||
4336 | |||
4337 | a31a512e | gaqhf | private void JoinRunBySameType(string modelItemId, ref string survivorId) |
4338 | ca6e0f51 | gaqhf | { |
4339 | a31a512e | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
4340 | if (modelItem != null) |
||
4341 | ca6e0f51 | gaqhf | { |
4342 | a31a512e | gaqhf | foreach (LMRepresentation rep in modelItem.Representations) |
4343 | { |
||
4344 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
4345 | { |
||
4346 | LMConnector connector = dataSource.GetConnector(rep.Id); |
||
4347 | if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch") |
||
4348 | { |
||
4349 | LMSymbol symbol = connector.ConnectItem1SymbolObject; |
||
4350 | List<string> modelItemIds = FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id); |
||
4351 | if (modelItemIds.Count == 1) |
||
4352 | { |
||
4353 | d77973b3 | gaqhf | string joinModelItemId = modelItemIds[0]; |
4354 | JoinRun(joinModelItemId, modelItemId, ref survivorId); |
||
4355 | a31a512e | gaqhf | if (survivorId != null) |
4356 | break; |
||
4357 | } |
||
4358 | } |
||
4359 | if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch") |
||
4360 | { |
||
4361 | LMSymbol symbol = connector.ConnectItem2SymbolObject; |
||
4362 | List<string> modelItemIds = FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id); |
||
4363 | if (modelItemIds.Count == 1) |
||
4364 | { |
||
4365 | d77973b3 | gaqhf | string joinModelItemId = modelItemIds[0]; |
4366 | JoinRun(joinModelItemId, modelItemId, ref survivorId); |
||
4367 | a31a512e | gaqhf | if (survivorId != null) |
4368 | break; |
||
4369 | } |
||
4370 | } |
||
4371 | } |
||
4372 | } |
||
4373 | ca6e0f51 | gaqhf | } |
4374 | dec9ecfd | gaqhf | } |
4375 | |||
4376 | d9794a6c | gaqhf | /// <summary> |
4377 | 74752074 | gaqhf | /// Label의 좌표를 구하는 메서드(ID2 기준의 좌표 -> SPPID 좌표) |
4378 | /// </summary> |
||
4379 | /// <param name="x"></param> |
||
4380 | /// <param name="y"></param> |
||
4381 | /// <param name="originX"></param> |
||
4382 | /// <param name="originY"></param> |
||
4383 | /// <param name="SPPIDLabelLocation"></param> |
||
4384 | /// <param name="location"></param> |
||
4385 | b65a7e32 | gaqhf | private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDLabelLocationInfo SPPIDLabelLocation, Location location) |
4386 | { |
||
4387 | if (location == Location.None) |
||
4388 | { |
||
4389 | x = originX; |
||
4390 | y = originY; |
||
4391 | } |
||
4392 | else |
||
4393 | { |
||
4394 | if (location.HasFlag(Location.Center)) |
||
4395 | { |
||
4396 | x = (SPPIDLabelLocation.X1 + SPPIDLabelLocation.X2) / 2; |
||
4397 | y = (SPPIDLabelLocation.Y1 + SPPIDLabelLocation.Y2) / 2; |
||
4398 | } |
||
4399 | |||
4400 | if (location.HasFlag(Location.Left)) |
||
4401 | x = SPPIDLabelLocation.X1; |
||
4402 | else if (location.HasFlag(Location.Right)) |
||
4403 | x = SPPIDLabelLocation.X2; |
||
4404 | |||
4405 | if (location.HasFlag(Location.Down)) |
||
4406 | y = SPPIDLabelLocation.Y1; |
||
4407 | else if (location.HasFlag(Location.Up)) |
||
4408 | y = SPPIDLabelLocation.Y2; |
||
4409 | } |
||
4410 | } |
||
4411 | 5a4b8f32 | gaqhf | |
4412 | 74752074 | gaqhf | /// <summary> |
4413 | 4d2571ab | gaqhf | /// Symbol의 우선순위 Modeling 목록을 가져온다. |
4414 | /// 1. Angle Valve |
||
4415 | /// 2. 3개로 이루어진 Symbol Group |
||
4416 | /// </summary> |
||
4417 | /// <returns></returns> |
||
4418 | private List<Symbol> GetPrioritySymbol() |
||
4419 | { |
||
4420 | DataTable symbolTable = document.SymbolTable; |
||
4421 | // List에 순서대로 쌓는다. |
||
4422 | List<Symbol> symbols = new List<Symbol>(); |
||
4423 | 3734dcc5 | gaqhf | |
4424 | 4d2571ab | gaqhf | // Angle Valve 부터 |
4425 | d9794a6c | gaqhf | foreach (var symbol in document.SYMBOLS.FindAll(x => x.CONNECTORS.FindAll(y => y.Index == 0).Count == 2)) |
4426 | 4d2571ab | gaqhf | { |
4427 | if (!symbols.Contains(symbol)) |
||
4428 | { |
||
4429 | double originX = 0; |
||
4430 | double originY = 0; |
||
4431 | |||
4432 | // ID2 Table에서 Original Point 가져옴. |
||
4433 | 7f00b26c | gaqhf | string OriginalPoint = symbolTable.Select(string.Format("UID = {0}", symbol.DBUID))[0]["OriginalPoint"].ToString(); |
4434 | 4d2571ab | gaqhf | SPPIDUtil.ConvertPointBystring(OriginalPoint, ref originX, ref originY); |
4435 | |||
4436 | SlopeType slopeType1 = SlopeType.None; |
||
4437 | SlopeType slopeType2 = SlopeType.None; |
||
4438 | d9794a6c | gaqhf | foreach (Connector connector in symbol.CONNECTORS.FindAll(x => x.Index == 0)) |
4439 | 4d2571ab | gaqhf | { |
4440 | double connectorX = 0; |
||
4441 | double connectorY = 0; |
||
4442 | SPPIDUtil.ConvertPointBystring(connector.CONNECTPOINT, ref connectorX, ref connectorY); |
||
4443 | if (slopeType1 == SlopeType.None) |
||
4444 | slopeType1 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
||
4445 | else |
||
4446 | slopeType2 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
||
4447 | } |
||
4448 | |||
4449 | if ((slopeType1 == SlopeType.VERTICAL && slopeType2 == SlopeType.HORIZONTAL) || |
||
4450 | (slopeType2 == SlopeType.VERTICAL && slopeType1 == SlopeType.HORIZONTAL)) |
||
4451 | symbols.Add(symbol); |
||
4452 | } |
||
4453 | } |
||
4454 | |||
4455 | f1a7faf9 | gaqhf | List<Symbol> tempSymbols = new List<Symbol>(); |
4456 | // Conn 갯수 기준 |
||
4457 | d9794a6c | gaqhf | foreach (var item in document.SYMBOLS) |
4458 | { |
||
4459 | f1a7faf9 | gaqhf | if (!symbols.Contains(item)) |
4460 | tempSymbols.Add(item); |
||
4461 | d9794a6c | gaqhf | } |
4462 | f1a7faf9 | gaqhf | tempSymbols.Sort(SortSymbolPriority); |
4463 | symbols.AddRange(tempSymbols); |
||
4464 | 4d2571ab | gaqhf | |
4465 | return symbols; |
||
4466 | } |
||
4467 | |||
4468 | cf210438 | gaqhf | private void SetPriorityLine(List<Line> lines) |
4469 | d63050d6 | gaqhf | { |
4470 | cf210438 | gaqhf | lines.Sort(SortLinePriority); |
4471 | d63050d6 | gaqhf | |
4472 | int SortLinePriority(Line a, Line b) |
||
4473 | { |
||
4474 | // Branch 없는것부터 |
||
4475 | int branchRetval = CompareBranchLine(a, b); |
||
4476 | if (branchRetval != 0) |
||
4477 | { |
||
4478 | return branchRetval; |
||
4479 | } |
||
4480 | else |
||
4481 | { |
||
4482 | // Symbol 연결 갯수 |
||
4483 | int connSymbolRetval = CompareConnSymbol(a, b); |
||
4484 | if (connSymbolRetval != 0) |
||
4485 | { |
||
4486 | return connSymbolRetval; |
||
4487 | } |
||
4488 | else |
||
4489 | { |
||
4490 | 24515a3a | gaqhf | // 아이템 연결 갯수(심볼, Line이면서 Not Branch) |
4491 | int connItemRetval = CompareConnItem(a, b); |
||
4492 | if (connItemRetval != 0) |
||
4493 | d63050d6 | gaqhf | { |
4494 | 24515a3a | gaqhf | return connItemRetval; |
4495 | d63050d6 | gaqhf | } |
4496 | else |
||
4497 | { |
||
4498 | 24515a3a | gaqhf | // ConnectedItem이 없는것 |
4499 | int noneConnRetval = CompareNoneConn(a, b); |
||
4500 | if (noneConnRetval != 0) |
||
4501 | d63050d6 | gaqhf | { |
4502 | 24515a3a | gaqhf | return noneConnRetval; |
4503 | d63050d6 | gaqhf | } |
4504 | else |
||
4505 | { |
||
4506 | |||
4507 | } |
||
4508 | } |
||
4509 | } |
||
4510 | } |
||
4511 | |||
4512 | return 0; |
||
4513 | } |
||
4514 | |||
4515 | e283d483 | gaqhf | int CompareNotSegmentLine(Line a, Line b) |
4516 | { |
||
4517 | List<Connector> connectorsA = a.CONNECTORS |
||
4518 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
4519 | .ToList(); |
||
4520 | |||
4521 | List<Connector> connectorsB = b.CONNECTORS |
||
4522 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
4523 | .ToList(); |
||
4524 | |||
4525 | // 오름차순 |
||
4526 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
4527 | } |
||
4528 | |||
4529 | d63050d6 | gaqhf | int CompareConnSymbol(Line a, Line b) |
4530 | { |
||
4531 | List<Connector> connectorsA = a.CONNECTORS |
||
4532 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
4533 | .ToList(); |
||
4534 | |||
4535 | List<Connector> connectorsB = b.CONNECTORS |
||
4536 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
4537 | .ToList(); |
||
4538 | |||
4539 | // 오름차순 |
||
4540 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
4541 | } |
||
4542 | |||
4543 | int CompareConnItem(Line a, Line b) |
||
4544 | { |
||
4545 | List<Connector> connectorsA = a.CONNECTORS |
||
4546 | .Where(conn => conn.ConnectedObject != null && |
||
4547 | (conn.ConnectedObject.GetType() == typeof(Symbol) || |
||
4548 | (conn.ConnectedObject.GetType() == typeof(Line) && !SPPIDUtil.IsBranchLine((Line)conn.ConnectedObject, a)))) |
||
4549 | .ToList(); |
||
4550 | |||
4551 | List<Connector> connectorsB = b.CONNECTORS |
||
4552 | .Where(conn => conn.ConnectedObject != null && |
||
4553 | (conn.ConnectedObject.GetType() == typeof(Symbol) || |
||
4554 | (conn.ConnectedObject.GetType() == typeof(Line) && !SPPIDUtil.IsBranchLine((Line)conn.ConnectedObject, b)))) |
||
4555 | .ToList(); |
||
4556 | |||
4557 | // 오름차순 |
||
4558 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
4559 | } |
||
4560 | |||
4561 | int CompareBranchLine(Line a, Line b) |
||
4562 | { |
||
4563 | List<Connector> connectorsA = a.CONNECTORS |
||
4564 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Line) && SPPIDUtil.IsBranchLine(a, conn.ConnectedObject as Line)) |
||
4565 | .ToList(); |
||
4566 | List<Connector> connectorsB = b.CONNECTORS |
||
4567 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Line) && SPPIDUtil.IsBranchLine(b, conn.ConnectedObject as Line)) |
||
4568 | .ToList(); |
||
4569 | |||
4570 | // 내림차순 |
||
4571 | return connectorsA.Count.CompareTo(connectorsB.Count); |
||
4572 | } |
||
4573 | |||
4574 | int CompareNoneConn(Line a, Line b) |
||
4575 | { |
||
4576 | List<Connector> connectorsA = a.CONNECTORS |
||
4577 | .Where(conn => conn.ConnectedObject == null) |
||
4578 | .ToList(); |
||
4579 | |||
4580 | List<Connector> connectorsB = b.CONNECTORS |
||
4581 | .Where(conn => conn.ConnectedObject == null) |
||
4582 | .ToList(); |
||
4583 | |||
4584 | // 오름차순 |
||
4585 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
4586 | } |
||
4587 | } |
||
4588 | |||
4589 | 1299077b | gaqhf | private void SortText(List<Text> texts) |
4590 | { |
||
4591 | texts.Sort(Sort); |
||
4592 | |||
4593 | int Sort(Text a, Text b) |
||
4594 | { |
||
4595 | int yRetval = CompareY(a, b); |
||
4596 | if (yRetval != 0) |
||
4597 | { |
||
4598 | return yRetval; |
||
4599 | } |
||
4600 | else |
||
4601 | { |
||
4602 | return CompareX(a, b); |
||
4603 | } |
||
4604 | } |
||
4605 | |||
4606 | int CompareY(Text a, Text b) |
||
4607 | { |
||
4608 | return a.LOCATION_Y.CompareTo(b.LOCATION_Y); |
||
4609 | } |
||
4610 | |||
4611 | int CompareX(Text a, Text b) |
||
4612 | { |
||
4613 | return a.LOCATION_X.CompareTo(b.LOCATION_X); |
||
4614 | } |
||
4615 | } |
||
4616 | private void SortNote(List<Note> notes) |
||
4617 | { |
||
4618 | notes.Sort(Sort); |
||
4619 | |||
4620 | int Sort(Note a, Note b) |
||
4621 | { |
||
4622 | int yRetval = CompareY(a, b); |
||
4623 | if (yRetval != 0) |
||
4624 | { |
||
4625 | return yRetval; |
||
4626 | } |
||
4627 | else |
||
4628 | { |
||
4629 | return CompareX(a, b); |
||
4630 | } |
||
4631 | } |
||
4632 | |||
4633 | int CompareY(Note a, Note b) |
||
4634 | { |
||
4635 | return a.LOCATION_Y.CompareTo(b.LOCATION_Y); |
||
4636 | } |
||
4637 | |||
4638 | int CompareX(Note a, Note b) |
||
4639 | { |
||
4640 | return a.LOCATION_X.CompareTo(b.LOCATION_X); |
||
4641 | } |
||
4642 | } |
||
4643 | |||
4644 | a0e3dca4 | gaqhf | private void SortBranchLines() |
4645 | { |
||
4646 | f3e2693f | gaqhf | BranchLines.Sort(SortBranchLine); |
4647 | a0e3dca4 | gaqhf | int SortBranchLine(Line a, Line b) |
4648 | { |
||
4649 | int countA = a.CONNECTORS.FindAll(x => x.ConnectedObject != null && |
||
4650 | x.ConnectedObject.GetType() == typeof(Line) && |
||
4651 | SPPIDUtil.IsBranchLine(x.ConnectedObject as Line, a) && |
||
4652 | string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)).Count; |
||
4653 | |||
4654 | int countB = b.CONNECTORS.FindAll(x => x.ConnectedObject != null && |
||
4655 | x.ConnectedObject.GetType() == typeof(Line) && |
||
4656 | SPPIDUtil.IsBranchLine(x.ConnectedObject as Line, b) && |
||
4657 | string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)).Count; |
||
4658 | |||
4659 | // 내림차순 |
||
4660 | return countA.CompareTo(countB); |
||
4661 | } |
||
4662 | } |
||
4663 | |||
4664 | f1a7faf9 | gaqhf | private static int SortSymbolPriority(Symbol a, Symbol b) |
4665 | { |
||
4666 | int countA = a.CONNECTORS.FindAll(x => !string.IsNullOrEmpty(x.CONNECTEDITEM) && x.CONNECTEDITEM != "None").Count; |
||
4667 | int countB = b.CONNECTORS.FindAll(x => !string.IsNullOrEmpty(x.CONNECTEDITEM) && x.CONNECTEDITEM != "None").Count; |
||
4668 | int retval = countB.CompareTo(countA); |
||
4669 | if (retval != 0) |
||
4670 | return retval; |
||
4671 | else |
||
4672 | return a.SPPID.ORIGINAL_X.CompareTo(b.SPPID.ORIGINAL_X); |
||
4673 | } |
||
4674 | |||
4675 | a31a512e | gaqhf | private string GetSPPIDFileName(LMModelItem modelItem) |
4676 | { |
||
4677 | string symbolPath = null; |
||
4678 | foreach (LMRepresentation rep in modelItem.Representations) |
||
4679 | { |
||
4680 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
4681 | { |
||
4682 | symbolPath = rep.get_FileName(); |
||
4683 | break; |
||
4684 | } |
||
4685 | } |
||
4686 | return symbolPath; |
||
4687 | } |
||
4688 | |||
4689 | 82d6e5ea | gaqhf | private string GetSPPIDFileName(string modelItemId) |
4690 | { |
||
4691 | LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
||
4692 | string symbolPath = null; |
||
4693 | foreach (LMRepresentation rep in modelItem.Representations) |
||
4694 | { |
||
4695 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
4696 | { |
||
4697 | symbolPath = rep.get_FileName(); |
||
4698 | break; |
||
4699 | } |
||
4700 | } |
||
4701 | ReleaseCOMObjects(modelItem); |
||
4702 | return symbolPath; |
||
4703 | } |
||
4704 | |||
4705 | 4d2571ab | gaqhf | /// <summary> |
4706 | b2d1c1aa | gaqhf | /// Graphic OID로 해당 Symbol의 크기를 구하여 Zoom |
4707 | /// </summary> |
||
4708 | /// <param name="graphicOID"></param> |
||
4709 | /// <param name="milliseconds"></param> |
||
4710 | private void ZoomObjectByGraphicOID(string graphicOID, int milliseconds = 150) |
||
4711 | { |
||
4712 | if (radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID] != null) |
||
4713 | { |
||
4714 | double minX = 0; |
||
4715 | double minY = 0; |
||
4716 | double maxX = 0; |
||
4717 | double maxY = 0; |
||
4718 | radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID].Range(out minX, out minY, out maxX, out maxY); |
||
4719 | radApp.ActiveWindow.ZoomArea2(minX - 0.007, minY - 0.007, maxX + 0.007, maxY + 0.007, null); |
||
4720 | |||
4721 | Thread.Sleep(milliseconds); |
||
4722 | } |
||
4723 | } |
||
4724 | |||
4725 | /// <summary> |
||
4726 | 74752074 | gaqhf | /// ComObject를 Release |
4727 | /// </summary> |
||
4728 | /// <param name="objVars"></param> |
||
4729 | 5a4b8f32 | gaqhf | public void ReleaseCOMObjects(params object[] objVars) |
4730 | { |
||
4731 | 02a45794 | gaqhf | if (objVars != null) |
4732 | 5a4b8f32 | gaqhf | { |
4733 | 02a45794 | gaqhf | int intNewRefCount = 0; |
4734 | foreach (object obj in objVars) |
||
4735 | { |
||
4736 | if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
||
4737 | intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
||
4738 | } |
||
4739 | 5a4b8f32 | gaqhf | } |
4740 | } |
||
4741 | 5a9396ae | humkyung | |
4742 | /// IDisposable 구현 |
||
4743 | ~AutoModeling() |
||
4744 | { |
||
4745 | this.Dispose(false); |
||
4746 | } |
||
4747 | |||
4748 | private bool disposed; |
||
4749 | public void Dispose() |
||
4750 | { |
||
4751 | this.Dispose(true); |
||
4752 | GC.SuppressFinalize(this); |
||
4753 | } |
||
4754 | |||
4755 | protected virtual void Dispose(bool disposing) |
||
4756 | { |
||
4757 | if (this.disposed) return; |
||
4758 | if (disposing) |
||
4759 | { |
||
4760 | // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
||
4761 | } |
||
4762 | // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
||
4763 | this.disposed = true; |
||
4764 | } |
||
4765 | cfda1fed | gaqhf | } |
4766 | } |