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