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