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