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