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