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