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