hytos / DTI_PID / SPPIDConverter / AutoModeling.cs @ c993d55a
이력 | 보기 | 이력해설 | 다운로드 (182 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 | public class AutoModeling |
||
28 | { |
||
29 | 809a7640 | gaqhf | Placement _placement; |
30 | LMADataSource dataSource; |
||
31 | 7aee331b | gaqhf | LMDrawing currentDrawing; |
32 | 1ba9c671 | gaqhf | dynamic newDrawing; |
33 | d19ae675 | gaqhf | dynamic application; |
34 | 5e6ecf05 | gaqhf | Ingr.RAD2D.Application radApp; |
35 | cfda1fed | gaqhf | SPPID_Document document; |
36 | b65a7e32 | gaqhf | ETCSetting _ETCSetting; |
37 | f1c9dbaa | gaqhf | |
38 | d5ec4d0f | gaqhf | public string DocumentLabelText { get; set; } |
39 | |||
40 | f3e2693f | gaqhf | List<Line> BranchLines = new List<Line>(); |
41 | 644f40b3 | gaqhf | List<string> ZeroLengthSymbolToSymbolModelItemID = new List<string>(); |
42 | 87f02fc0 | gaqhf | List<string> ZeroLengthModelItemID = new List<string>(); |
43 | 1ff0105e | gaqhf | List<string> ZeroLengthModelItemIDReverse = new List<string>(); |
44 | f1a7faf9 | gaqhf | List<Symbol> prioritySymbols; |
45 | 47ad9a46 | gaqhf | |
46 | d19ae675 | gaqhf | public AutoModeling(SPPID_Document document, dynamic application, Ingr.RAD2D.Application radApp) |
47 | cfda1fed | gaqhf | { |
48 | this.document = document; |
||
49 | d19ae675 | gaqhf | this.application = application; |
50 | 5e6ecf05 | gaqhf | this.radApp = radApp; |
51 | b65a7e32 | gaqhf | this._ETCSetting = ETCSetting.GetInstance(); |
52 | cfda1fed | gaqhf | } |
53 | |||
54 | 02480ac1 | gaqhf | private void SetSystemEditingCommand(bool value) |
55 | { |
||
56 | foreach (var item in radApp.Commands) |
||
57 | { |
||
58 | if (item.Argument == "SystemEditingCmd.SystemEditing") |
||
59 | { |
||
60 | if (item.Checked != value) |
||
61 | { |
||
62 | radApp.RunMacro("systemeditingcmd.dll"); |
||
63 | break; |
||
64 | } |
||
65 | |||
66 | } |
||
67 | } |
||
68 | } |
||
69 | |||
70 | 74752074 | gaqhf | /// <summary> |
71 | /// 도면 단위당 실행되는 메서드 |
||
72 | /// </summary> |
||
73 | 1ba9c671 | gaqhf | public void Run() |
74 | c2fef4ca | gaqhf | { |
75 | 224535bb | gaqhf | string drawingNumber = document.DrawingNumber; |
76 | string drawingName = document.DrawingName; |
||
77 | 1ba9c671 | gaqhf | try |
78 | c2fef4ca | gaqhf | { |
79 | 1ba9c671 | gaqhf | _placement = new Placement(); |
80 | dataSource = _placement.PIDDataSource; |
||
81 | |||
82 | 224535bb | gaqhf | CreateDocument(ref drawingNumber, ref drawingName); |
83 | 1ba9c671 | gaqhf | |
84 | 0e0edfad | gaqhf | if (DocumentCoordinateCorrection()) |
85 | 310aeb31 | gaqhf | { |
86 | 3734dcc5 | gaqhf | Log.Write("Start Modeling"); |
87 | 965eb728 | gaqhf | SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
88 | 9628f54b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd); |
89 | dec9ecfd | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 17); |
90 | 20972c61 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
91 | f9cc5190 | gaqhf | |
92 | 6db30942 | gaqhf | // Equipment Modeling |
93 | b01e7456 | gaqhf | RunEquipmentModeling(); |
94 | // Symbol Modeling |
||
95 | RunSymbolModeling(); |
||
96 | 3939eebf | gaqhf | // LineRun Line Modeling |
97 | b01e7456 | gaqhf | RunLineModeling(); |
98 | // Branch Line Modeling |
||
99 | RunBranchLineModeling(); |
||
100 | // Clear Attribute |
||
101 | 1ff0105e | gaqhf | RunClearValueInconsistancy(); |
102 | b01e7456 | gaqhf | // EndBreak Modeling |
103 | RunEndBreakModeling(); |
||
104 | // SpecBreak Modeling |
||
105 | RunSpecBreakModeling(); |
||
106 | d23fe61b | gaqhf | // Join SameConnector |
107 | dfac4553 | gaqhf | RunJoinRunForSameConnector(); |
108 | d23fe61b | gaqhf | // Check FlowDirection |
109 | 1ff0105e | gaqhf | RunFlowDirection(); |
110 | d77973b3 | gaqhf | // Join Run |
111 | RunJoinRun(); |
||
112 | 8701de36 | gaqhf | //Line Number Modeling |
113 | RunLineNumberModeling(); |
||
114 | 32205389 | gaqhf | // Note Modeling |
115 | RunNoteModeling(); |
||
116 | // Text Modeling |
||
117 | RunTextModeling(); |
||
118 | // Input LineNumber Attribute |
||
119 | RunInputLineNumberAttribute(); |
||
120 | // Input Symbol Attribute |
||
121 | RunInputSymbolAttribute(); |
||
122 | // Input SpecBreak Attribute |
||
123 | RunInputSpecBreakAttribute(); |
||
124 | // Label Symbol Modeling |
||
125 | RunLabelSymbolModeling(); |
||
126 | 4ba01591 | gaqhf | |
127 | 30ba9ae0 | gaqhf | // Result Logging |
128 | document.CheckModelingResult(); |
||
129 | 310aeb31 | gaqhf | } |
130 | 809a7640 | gaqhf | } |
131 | 5e6ecf05 | gaqhf | catch (Exception ex) |
132 | { |
||
133 | 9628f54b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.ClearParent, null); |
134 | SplashScreenManager.CloseForm(false); |
||
135 | 5e6ecf05 | gaqhf | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
136 | } |
||
137 | finally |
||
138 | { |
||
139 | 3734dcc5 | gaqhf | Log.Write("End Modeling"); |
140 | 1ba9c671 | gaqhf | application.ActiveWindow.Fit(); |
141 | b2d1c1aa | gaqhf | |
142 | 7aee331b | gaqhf | if (currentDrawing != null) |
143 | ReleaseCOMObjects(currentDrawing); |
||
144 | |||
145 | b66a2996 | gaqhf | if (radApp.ActiveDocument != null) |
146 | 3939eebf | gaqhf | { |
147 | 1805d3b7 | gaqhf | radApp.ActiveDocument.Save(); |
148 | 1ba9c671 | gaqhf | ReleaseCOMObjects(newDrawing); |
149 | 3939eebf | gaqhf | } |
150 | 1ba9c671 | gaqhf | |
151 | 5e6ecf05 | gaqhf | ReleaseCOMObjects(dataSource); |
152 | ReleaseCOMObjects(_placement); |
||
153 | 965eb728 | gaqhf | |
154 | 224535bb | gaqhf | Project_DB.InsertDrawingInfo(document.PATH, drawingNumber, drawingName, document); |
155 | 9628f54b | gaqhf | if (SplashScreenManager.Default.IsSplashFormVisible) |
156 | { |
||
157 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.ClearParent, null); |
||
158 | SplashScreenManager.CloseForm(false); |
||
159 | 3734dcc5 | gaqhf | Log.Write("\r\n"); |
160 | 9628f54b | gaqhf | } |
161 | 5e6ecf05 | gaqhf | } |
162 | 65a1ed4b | gaqhf | } |
163 | b01e7456 | gaqhf | private void RunEquipmentModeling() |
164 | { |
||
165 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.Equipments.Count); |
||
166 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Equipments Modeling"); |
167 | b01e7456 | gaqhf | foreach (Equipment item in document.Equipments) |
168 | { |
||
169 | try |
||
170 | { |
||
171 | EquipmentModeling(item); |
||
172 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.Equipments.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
||
173 | } |
||
174 | catch (Exception ex) |
||
175 | { |
||
176 | Log.Write("Error in EquipmentModeling"); |
||
177 | Log.Write("UID : " + item.UID); |
||
178 | Log.Write(ex.Message); |
||
179 | Log.Write(ex.StackTrace); |
||
180 | } |
||
181 | } |
||
182 | } |
||
183 | private void RunSymbolModeling() |
||
184 | { |
||
185 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count); |
||
186 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Symbol Modeling"); |
187 | b01e7456 | gaqhf | prioritySymbols = GetPrioritySymbol(); |
188 | foreach (var item in prioritySymbols) |
||
189 | { |
||
190 | try |
||
191 | { |
||
192 | SymbolModelingBySymbol(item); |
||
193 | } |
||
194 | catch (Exception ex) |
||
195 | { |
||
196 | Log.Write("Error in SymbolModelingByPriority"); |
||
197 | Log.Write("UID : " + item.UID); |
||
198 | Log.Write(ex.Message); |
||
199 | Log.Write(ex.StackTrace); |
||
200 | } |
||
201 | } |
||
202 | } |
||
203 | private void RunLineModeling() |
||
204 | { |
||
205 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count); |
||
206 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Lines Modeling"); |
207 | SetPriorityLine(); |
||
208 | b01e7456 | gaqhf | foreach (var item in document.LINES) |
209 | { |
||
210 | try |
||
211 | { |
||
212 | NewLineModeling(item); |
||
213 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
214 | } |
||
215 | catch (Exception ex) |
||
216 | { |
||
217 | Log.Write("Error in NewLineModeling"); |
||
218 | Log.Write("UID : " + item.UID); |
||
219 | Log.Write(ex.Message); |
||
220 | Log.Write(ex.StackTrace); |
||
221 | } |
||
222 | } |
||
223 | } |
||
224 | private void RunBranchLineModeling() |
||
225 | { |
||
226 | f3e2693f | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, BranchLines.Count); |
227 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Branch Lines Modeling"); |
228 | f3e2693f | gaqhf | int branchCount = BranchLines.Count; |
229 | while (BranchLines.Count > 0) |
||
230 | b01e7456 | gaqhf | { |
231 | try |
||
232 | { |
||
233 | SortBranchLines(); |
||
234 | f3e2693f | gaqhf | Line item = BranchLines[0]; |
235 | a31a512e | gaqhf | if (EnableBranchModeling(item)) |
236 | { |
||
237 | NewLineModeling(item, true); |
||
238 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
239 | } |
||
240 | else |
||
241 | 6924abc6 | gaqhf | throw new Exception("Fail Branch Modeling"); |
242 | b01e7456 | gaqhf | } |
243 | catch (Exception ex) |
||
244 | { |
||
245 | Log.Write("Error in NewLineModeling"); |
||
246 | f3e2693f | gaqhf | Log.Write("UID : " + BranchLines[0].UID); |
247 | b01e7456 | gaqhf | Log.Write(ex.Message); |
248 | Log.Write(ex.StackTrace); |
||
249 | a31a512e | gaqhf | break; |
250 | b01e7456 | gaqhf | } |
251 | } |
||
252 | a31a512e | gaqhf | |
253 | bool EnableBranchModeling(Line line) |
||
254 | { |
||
255 | bool result = true; |
||
256 | if (line.CONNECTORS.FindAll(x => x.ConnectedObject != null && |
||
257 | x.ConnectedObject.GetType() == typeof(Line) && |
||
258 | string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)).Count > 0) |
||
259 | result = false; |
||
260 | |||
261 | return result; |
||
262 | } |
||
263 | b01e7456 | gaqhf | } |
264 | 1ff0105e | gaqhf | private void RunClearValueInconsistancy() |
265 | b01e7456 | gaqhf | { |
266 | 32205389 | gaqhf | int count = 1; |
267 | 63fbf592 | gaqhf | bool loop = true; |
268 | while (loop) |
||
269 | b01e7456 | gaqhf | { |
270 | 63fbf592 | gaqhf | loop = false; |
271 | LMAFilter filter = new LMAFilter(); |
||
272 | LMACriterion criterion = new LMACriterion(); |
||
273 | filter.ItemType = "Relationship"; |
||
274 | criterion.SourceAttributeName = "SP_DRAWINGID"; |
||
275 | criterion.Operator = "="; |
||
276 | criterion.set_ValueAttribute(currentDrawing.Id); |
||
277 | filter.get_Criteria().Add(criterion); |
||
278 | |||
279 | LMRelationships relationships = new LMRelationships(); |
||
280 | relationships.Collect(dataSource, Filter: filter); |
||
281 | |||
282 | d23fe61b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, relationships.Count); |
283 | f9cc5190 | gaqhf | if (count > 1) |
284 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStepMinus, null); |
||
285 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Clear Inconsistent Property Value - " + count); |
286 | 63fbf592 | gaqhf | foreach (LMRelationship relationship in relationships) |
287 | b01e7456 | gaqhf | { |
288 | 63fbf592 | gaqhf | foreach (LMInconsistency inconsistency in relationship.Inconsistencies) |
289 | b01e7456 | gaqhf | { |
290 | 63fbf592 | gaqhf | if (inconsistency.get_InconsistencyTypeIndex() == 1) |
291 | { |
||
292 | LMModelItem modelItem1 = relationship.Item1RepresentationObject == null ? null : relationship.Item1RepresentationObject.ModelItemObject; |
||
293 | LMModelItem modelItem2 = relationship.Item2RepresentationObject == null ? null : relationship.Item2RepresentationObject.ModelItemObject; |
||
294 | string[] array = inconsistency.get_Name().ToString().Split(new char[] { '=' }); |
||
295 | if (modelItem1 != null) |
||
296 | { |
||
297 | string attrName = array[0]; |
||
298 | if (attrName.Contains("PipingPoint")) |
||
299 | { |
||
300 | string originalAttr = attrName.Split(new char[] { '.' })[1]; |
||
301 | d23fe61b | gaqhf | int index = Convert.ToInt32(relationship.get_Item1Location()); |
302 | LMAAttribute attribute1 = modelItem1.Attributes["PipingPoint" + index + "." + originalAttr]; |
||
303 | if (attribute1 != null && !DBNull.Value.Equals(attribute1.get_Value())) |
||
304 | 63fbf592 | gaqhf | { |
305 | d23fe61b | gaqhf | loop = true; |
306 | attribute1.set_Value(DBNull.Value); |
||
307 | 63fbf592 | gaqhf | } |
308 | } |
||
309 | else |
||
310 | { |
||
311 | LMAAttribute attribute1 = modelItem1.Attributes[attrName]; |
||
312 | if (attribute1 != null && !DBNull.Value.Equals(attribute1.get_Value())) |
||
313 | { |
||
314 | loop = true; |
||
315 | attribute1.set_Value(DBNull.Value); |
||
316 | } |
||
317 | } |
||
318 | modelItem1.Commit(); |
||
319 | } |
||
320 | if (modelItem2 != null) |
||
321 | { |
||
322 | string attrName = array[1]; |
||
323 | if (attrName.Contains("PipingPoint")) |
||
324 | { |
||
325 | string originalAttr = attrName.Split(new char[] { '.' })[1]; |
||
326 | d23fe61b | gaqhf | int index = Convert.ToInt32(relationship.get_Item2Location()); |
327 | LMAAttribute attribute2 = modelItem2.Attributes["PipingPoint" + index + "." + originalAttr]; |
||
328 | if (attribute2 != null && !DBNull.Value.Equals(attribute2.get_Value())) |
||
329 | 63fbf592 | gaqhf | { |
330 | d23fe61b | gaqhf | attribute2.set_Value(DBNull.Value); |
331 | loop = true; |
||
332 | 63fbf592 | gaqhf | } |
333 | } |
||
334 | else |
||
335 | { |
||
336 | LMAAttribute attribute2 = modelItem2.Attributes[attrName]; |
||
337 | if (attribute2 != null && !DBNull.Value.Equals(attribute2.get_Value())) |
||
338 | { |
||
339 | attribute2.set_Value(DBNull.Value); |
||
340 | loop = true; |
||
341 | } |
||
342 | } |
||
343 | modelItem2.Commit(); |
||
344 | } |
||
345 | if (modelItem1 != null) |
||
346 | ReleaseCOMObjects(modelItem1); |
||
347 | if (modelItem2 != null) |
||
348 | ReleaseCOMObjects(modelItem2); |
||
349 | inconsistency.Commit(); |
||
350 | } |
||
351 | b01e7456 | gaqhf | } |
352 | 63fbf592 | gaqhf | relationship.Commit(); |
353 | d23fe61b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
354 | b01e7456 | gaqhf | } |
355 | 63fbf592 | gaqhf | ReleaseCOMObjects(filter); |
356 | ReleaseCOMObjects(criterion); |
||
357 | ReleaseCOMObjects(relationships); |
||
358 | 32205389 | gaqhf | count++; |
359 | b01e7456 | gaqhf | } |
360 | } |
||
361 | private void RunEndBreakModeling() |
||
362 | { |
||
363 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.EndBreaks.Count); |
||
364 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "EndBreaks Modeling"); |
||
365 | foreach (var item in document.EndBreaks) |
||
366 | try |
||
367 | { |
||
368 | EndBreakModeling(item); |
||
369 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
370 | } |
||
371 | catch (Exception ex) |
||
372 | { |
||
373 | Log.Write("Error in EndBreakModeling"); |
||
374 | Log.Write("UID : " + item.UID); |
||
375 | Log.Write(ex.Message); |
||
376 | Log.Write(ex.StackTrace); |
||
377 | } |
||
378 | } |
||
379 | private void RunSpecBreakModeling() |
||
380 | { |
||
381 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SpecBreaks.Count); |
||
382 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "SpecBreaks Modeling"); |
||
383 | foreach (var item in document.SpecBreaks) |
||
384 | try |
||
385 | { |
||
386 | SpecBreakModeling(item); |
||
387 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
388 | } |
||
389 | catch (Exception ex) |
||
390 | { |
||
391 | Log.Write("Error in SpecBreakModeling"); |
||
392 | Log.Write("UID : " + item.UID); |
||
393 | 9bcb092b | gaqhf | Log.Write(ex.Message); |
394 | Log.Write(ex.StackTrace); |
||
395 | } |
||
396 | } |
||
397 | dfac4553 | gaqhf | private void RunJoinRunForSameConnector() |
398 | { |
||
399 | d23fe61b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count); |
400 | ca6e0f51 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "PipeRun Join - 1"); |
401 | dfac4553 | gaqhf | foreach (var line in document.LINES) |
402 | { |
||
403 | if (!SPPIDUtil.IsSegmentLine(document, line)) |
||
404 | { |
||
405 | foreach (var connector in line.CONNECTORS) |
||
406 | { |
||
407 | if (connector.ConnectedObject != null && |
||
408 | connector.ConnectedObject.GetType() == typeof(Line) && |
||
409 | ca6e0f51 | gaqhf | !SPPIDUtil.IsBranchLine(line, connector.ConnectedObject as Line)) |
410 | dfac4553 | gaqhf | { |
411 | Line connLine = connector.ConnectedObject as Line; |
||
412 | 7e4a64a3 | gaqhf | if (line.SPPID.ModelItemId != connLine.SPPID.ModelItemId && !string.IsNullOrEmpty(line.SPPID.ModelItemId) && !string.IsNullOrEmpty(connLine.SPPID.ModelItemId)) |
413 | a31a512e | gaqhf | { |
414 | string survivorId = string.Empty; |
||
415 | JoinRun(connLine.SPPID.ModelItemId, line.SPPID.ModelItemId, ref survivorId); |
||
416 | } |
||
417 | |||
418 | dfac4553 | gaqhf | } |
419 | } |
||
420 | } |
||
421 | d23fe61b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
422 | } |
||
423 | } |
||
424 | ca6e0f51 | gaqhf | private void RunJoinRun() |
425 | { |
||
426 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count); |
||
427 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "PipeRun Join - 2"); |
||
428 | a31a512e | gaqhf | List<string> endModelID = new List<string>(); |
429 | ca6e0f51 | gaqhf | foreach (var line in document.LINES) |
430 | { |
||
431 | a31a512e | gaqhf | if (!endModelID.Contains(line.SPPID.ModelItemId)) |
432 | { |
||
433 | while (!endModelID.Contains(line.SPPID.ModelItemId)) |
||
434 | { |
||
435 | string survivorId = string.Empty; |
||
436 | JoinRunBySameType(line.SPPID.ModelItemId, ref survivorId); |
||
437 | if (string.IsNullOrEmpty(survivorId)) |
||
438 | { |
||
439 | endModelID.Add(line.SPPID.ModelItemId); |
||
440 | } |
||
441 | } |
||
442 | } |
||
443 | ca6e0f51 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
444 | } |
||
445 | } |
||
446 | 8701de36 | gaqhf | private void RunLineNumberModeling() |
447 | { |
||
448 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINENUMBERS.Count); |
||
449 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Line Number Modeling"); |
||
450 | foreach (var item in document.LINENUMBERS) |
||
451 | { |
||
452 | LMLabelPersist label = dataSource.GetLabelPersist(item.SPPID.RepresentationId); |
||
453 | if (label == null || (label != null && label.get_ItemStatus() != "Active")) |
||
454 | { |
||
455 | ReleaseCOMObjects(label); |
||
456 | item.SPPID.RepresentationId = null; |
||
457 | LineNumberModeling(item); |
||
458 | } |
||
459 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
460 | } |
||
461 | } |
||
462 | d23fe61b | gaqhf | private void RunFlowDirection() |
463 | { |
||
464 | 644f40b3 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, |
465 | document.LINES.Count + ZeroLengthModelItemID.Count + ZeroLengthModelItemIDReverse.Count + ZeroLengthSymbolToSymbolModelItemID.Count); |
||
466 | d23fe61b | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Check Flow Direction"); |
467 | foreach (var line in document.LINES) |
||
468 | { |
||
469 | 1ff0105e | gaqhf | if (!string.IsNullOrEmpty(line.SPPID.ModelItemId)) |
470 | { |
||
471 | LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
||
472 | 644f40b3 | gaqhf | if (modelItem != null && modelItem.get_ItemStatus() == "Active") |
473 | 1ff0105e | gaqhf | { |
474 | LMAAttribute attribute = modelItem.Attributes["FlowDirection"]; |
||
475 | if (attribute != null) |
||
476 | { |
||
477 | attribute.set_Value("End 1 is upstream (Inlet)"); |
||
478 | modelItem.Commit(); |
||
479 | } |
||
480 | d23fe61b | gaqhf | |
481 | 1ff0105e | gaqhf | SetFlowDirectionByLine(line.SPPID.ModelItemId); |
482 | |||
483 | ReleaseCOMObjects(modelItem); |
||
484 | } |
||
485 | } |
||
486 | d23fe61b | gaqhf | |
487 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
488 | dfac4553 | gaqhf | } |
489 | 1ff0105e | gaqhf | foreach (var modelId in ZeroLengthModelItemID) |
490 | { |
||
491 | LMModelItem zeroLengthModelItem = dataSource.GetModelItem(modelId); |
||
492 | LMAAttribute attribute = zeroLengthModelItem.Attributes["FlowDirection"]; |
||
493 | 644f40b3 | gaqhf | if (attribute != null && zeroLengthModelItem.get_ItemStatus() == "Active") |
494 | 1ff0105e | gaqhf | { |
495 | attribute.set_Value("End 1 is upstream (Inlet)"); |
||
496 | zeroLengthModelItem.Commit(); |
||
497 | } |
||
498 | |||
499 | SetFlowDirectionByLine(modelId); |
||
500 | |||
501 | ReleaseCOMObjects(zeroLengthModelItem); |
||
502 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
503 | } |
||
504 | foreach (var modelId in ZeroLengthModelItemIDReverse) |
||
505 | { |
||
506 | LMModelItem zeroLengthModelItem = dataSource.GetModelItem(modelId); |
||
507 | LMAAttribute attribute = zeroLengthModelItem.Attributes["FlowDirection"]; |
||
508 | 644f40b3 | gaqhf | if (attribute != null && zeroLengthModelItem.get_ItemStatus() == "Active") |
509 | 1ff0105e | gaqhf | { |
510 | attribute.set_Value("End 1 is downstream (Outlet)"); |
||
511 | zeroLengthModelItem.Commit(); |
||
512 | } |
||
513 | |||
514 | SetFlowDirectionByLine(modelId); |
||
515 | |||
516 | ReleaseCOMObjects(zeroLengthModelItem); |
||
517 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
518 | } |
||
519 | 644f40b3 | gaqhf | foreach (var modelId in ZeroLengthSymbolToSymbolModelItemID) |
520 | { |
||
521 | SetFlowDirectionByLine(modelId); |
||
522 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
523 | } |
||
524 | 1ff0105e | gaqhf | |
525 | 32205389 | gaqhf | void SetFlowDirectionByLine(string lineModelItemID) |
526 | 1ff0105e | gaqhf | { |
527 | 32205389 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(lineModelItemID); |
528 | if (modelItem != null && modelItem.get_ItemStatus() == "Active") |
||
529 | 1ff0105e | gaqhf | { |
530 | 32205389 | gaqhf | LMAAttribute attribute = modelItem.Attributes["FlowDirection"]; |
531 | if (attribute != null && !DBNull.Value.Equals(attribute.get_Value())) |
||
532 | 1ff0105e | gaqhf | { |
533 | 32205389 | gaqhf | string sFlowDirection = attribute.get_Value().ToString(); |
534 | foreach (LMRepresentation rep in modelItem.Representations) |
||
535 | 1ff0105e | gaqhf | { |
536 | 32205389 | gaqhf | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
537 | { |
||
538 | LMConnector connector = dataSource.GetConnector(rep.Id); |
||
539 | 1ff0105e | gaqhf | |
540 | 32205389 | gaqhf | foreach (LMRelationship relationship in connector.Relation1Relationships) |
541 | SetSymbolFlowDirectionByRelationShip(relationship, connector, sFlowDirection); |
||
542 | foreach (LMRelationship relationship in connector.Relation2Relationships) |
||
543 | SetSymbolFlowDirectionByRelationShip(relationship, connector, sFlowDirection); |
||
544 | 1ff0105e | gaqhf | |
545 | 32205389 | gaqhf | ReleaseCOMObjects(connector); |
546 | } |
||
547 | 1ff0105e | gaqhf | } |
548 | } |
||
549 | 32205389 | gaqhf | ReleaseCOMObjects(modelItem); |
550 | 1ff0105e | gaqhf | } |
551 | |||
552 | 32205389 | gaqhf | void SetSymbolFlowDirectionByRelationShip(LMRelationship relationship, LMConnector connector, string sFlowDirection) |
553 | 1ff0105e | gaqhf | { |
554 | 32205389 | gaqhf | // Item2가 Symbol |
555 | if (!DBNull.Value.Equals(relationship.Item1RepresentationID) && relationship.Item1RepresentationID == connector.Id && |
||
556 | relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.get_RepresentationType() == "Symbol") |
||
557 | { |
||
558 | int symbolIndex = Convert.ToInt32(relationship.get_Item2Location()); |
||
559 | int lineIndex = Convert.ToInt32(relationship.get_Item1Location()); |
||
560 | LMModelItem symbolModelItem = relationship.Item2RepresentationObject.ModelItemObject; |
||
561 | 1ff0105e | gaqhf | |
562 | 32205389 | gaqhf | SetSymbolFlowDirection(lineIndex, symbolIndex, sFlowDirection, symbolModelItem); |
563 | 1ff0105e | gaqhf | |
564 | 32205389 | gaqhf | symbolModelItem.Commit(); |
565 | ReleaseCOMObjects(symbolModelItem); |
||
566 | } |
||
567 | // Item1이 Symbol |
||
568 | else if (!DBNull.Value.Equals(relationship.Item2RepresentationID) && relationship.Item2RepresentationID == connector.Id && |
||
569 | relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.get_RepresentationType() == "Symbol") |
||
570 | { |
||
571 | int symbolIndex = Convert.ToInt32(relationship.get_Item1Location()); |
||
572 | int lineIndex = Convert.ToInt32(relationship.get_Item2Location()); |
||
573 | LMModelItem symbolModelItem = relationship.Item1RepresentationObject.ModelItemObject; |
||
574 | 1ff0105e | gaqhf | |
575 | 32205389 | gaqhf | SetSymbolFlowDirection(lineIndex, symbolIndex, sFlowDirection, symbolModelItem); |
576 | 1ff0105e | gaqhf | |
577 | 32205389 | gaqhf | symbolModelItem.Commit(); |
578 | ReleaseCOMObjects(symbolModelItem); |
||
579 | } |
||
580 | 1ff0105e | gaqhf | } |
581 | |||
582 | 32205389 | gaqhf | void SetSymbolFlowDirection(int lineIndex, int symbolIndex, string sFlowDirection, LMModelItem symbolModelItem) |
583 | 1ff0105e | gaqhf | { |
584 | 32205389 | gaqhf | string attrName = "PipingPoint" + symbolIndex + ".FlowDirection"; |
585 | LMAAttribute attribute = symbolModelItem.Attributes[attrName]; |
||
586 | if (attribute != null) |
||
587 | { |
||
588 | if (lineIndex == 0 && sFlowDirection == "End 1 is upstream (Inlet)") |
||
589 | attribute.set_Value("End 1 is downstream (Outlet)"); |
||
590 | else if (lineIndex == 0 && sFlowDirection == "End 1 is downstream (Outlet)") |
||
591 | attribute.set_Value("End 1 is upstream (Inlet)"); |
||
592 | else if (lineIndex == 1 && sFlowDirection == "End 1 is upstream (Inlet)") |
||
593 | attribute.set_Value("End 1 is upstream (Inlet)"); |
||
594 | else if (lineIndex == 1 && sFlowDirection == "End 1 is downstream (Outlet)") |
||
595 | attribute.set_Value("End 1 is downstream (Outlet)"); |
||
596 | } |
||
597 | 1ff0105e | gaqhf | } |
598 | } |
||
599 | dfac4553 | gaqhf | } |
600 | 32205389 | gaqhf | private void RunNoteModeling() |
601 | { |
||
602 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count); |
||
603 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Notes Modeling"); |
||
604 | foreach (var item in document.NOTES) |
||
605 | try |
||
606 | { |
||
607 | NoteModeling(item); |
||
608 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
609 | } |
||
610 | catch (Exception ex) |
||
611 | { |
||
612 | Log.Write("Error in NoteModeling"); |
||
613 | Log.Write("UID : " + item.UID); |
||
614 | Log.Write(ex.Message); |
||
615 | Log.Write(ex.StackTrace); |
||
616 | } |
||
617 | } |
||
618 | private void RunTextModeling() |
||
619 | 9bcb092b | gaqhf | { |
620 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.TEXTINFOS.Count); |
621 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Texts Modeling"); |
||
622 | foreach (var item in document.TEXTINFOS) |
||
623 | try |
||
624 | { |
||
625 | TextModeling(item); |
||
626 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
627 | } |
||
628 | catch (Exception ex) |
||
629 | { |
||
630 | Log.Write("Error in TextModeling"); |
||
631 | Log.Write("UID : " + item.UID); |
||
632 | Log.Write(ex.Message); |
||
633 | Log.Write(ex.StackTrace); |
||
634 | } |
||
635 | } |
||
636 | private void RunInputLineNumberAttribute() |
||
637 | { |
||
638 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINENUMBERS.Count); |
||
639 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set LineNumbers Attribute"); |
||
640 | 82d6e5ea | gaqhf | List<string> endLine = new List<string>(); |
641 | 9bcb092b | gaqhf | foreach (var item in document.LINENUMBERS) |
642 | try |
||
643 | { |
||
644 | 82d6e5ea | gaqhf | InputLineNumberAttribute(item, endLine); |
645 | 32205389 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
646 | 9bcb092b | gaqhf | } |
647 | catch (Exception ex) |
||
648 | { |
||
649 | 32205389 | gaqhf | Log.Write("Error in InputLineNumberAttribute"); |
650 | Log.Write("UID : " + item.UID); |
||
651 | Log.Write(ex.Message); |
||
652 | Log.Write(ex.StackTrace); |
||
653 | } |
||
654 | } |
||
655 | private void RunInputSymbolAttribute() |
||
656 | { |
||
657 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count); |
||
658 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
||
659 | foreach (var item in document.SYMBOLS) |
||
660 | try |
||
661 | { |
||
662 | InputSymbolAttribute(item, item.ATTRIBUTES); |
||
663 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
664 | } |
||
665 | catch (Exception ex) |
||
666 | { |
||
667 | Log.Write("Error in InputSymbolAttribute"); |
||
668 | Log.Write("UID : " + item.UID); |
||
669 | Log.Write(ex.Message); |
||
670 | Log.Write(ex.StackTrace); |
||
671 | } |
||
672 | } |
||
673 | private void RunInputSpecBreakAttribute() |
||
674 | { |
||
675 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count); |
||
676 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
||
677 | foreach (var item in document.SpecBreaks) |
||
678 | try |
||
679 | { |
||
680 | InputSpecBreakAttribute(item); |
||
681 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
682 | } |
||
683 | catch (Exception ex) |
||
684 | { |
||
685 | Log.Write("Error in InputSpecBreakAttribute"); |
||
686 | Log.Write("UID : " + item.UID); |
||
687 | Log.Write(ex.Message); |
||
688 | Log.Write(ex.StackTrace); |
||
689 | } |
||
690 | } |
||
691 | private void RunLabelSymbolModeling() |
||
692 | { |
||
693 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count); |
||
694 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Labels Modeling"); |
||
695 | foreach (var item in document.SYMBOLS) |
||
696 | try |
||
697 | { |
||
698 | LabelSymbolModeling(item); |
||
699 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
||
700 | } |
||
701 | catch (Exception ex) |
||
702 | { |
||
703 | Log.Write("Error in LabelSymbolModeling"); |
||
704 | 9bcb092b | gaqhf | Log.Write("UID : " + item.UID); |
705 | b01e7456 | gaqhf | Log.Write(ex.Message); |
706 | Log.Write(ex.StackTrace); |
||
707 | } |
||
708 | } |
||
709 | 30ba9ae0 | gaqhf | |
710 | 74752074 | gaqhf | /// <summary> |
711 | /// 도면 생성 메서드 |
||
712 | /// </summary> |
||
713 | 224535bb | gaqhf | private void CreateDocument(ref string drawingNumber, ref string drawingName) |
714 | 0e0edfad | gaqhf | { |
715 | 3734dcc5 | gaqhf | Log.Write("------------------ Start create document ------------------"); |
716 | 6d12a734 | gaqhf | GetDrawingNameAndNumber(ref drawingName, ref drawingNumber); |
717 | 3734dcc5 | gaqhf | Log.Write("Drawing name : " + drawingName); |
718 | Log.Write("Drawing number : " + drawingNumber); |
||
719 | b66a2996 | gaqhf | newDrawing = application.Drawings.Add(document.Unit, document.Template, drawingNumber, drawingName); |
720 | 88bac50c | gaqhf | document.SPPID_DrawingNumber = drawingNumber; |
721 | document.SPPID_DrawingName = drawingName; |
||
722 | 0e0edfad | gaqhf | application.ActiveWindow.Fit(); |
723 | Thread.Sleep(1000); |
||
724 | application.ActiveWindow.Zoom = 2000; |
||
725 | Thread.Sleep(2000); |
||
726 | 7aee331b | gaqhf | |
727 | //current LMDrawing 가져오기 |
||
728 | LMAFilter filter = new LMAFilter(); |
||
729 | LMACriterion criterion = new LMACriterion(); |
||
730 | filter.ItemType = "Drawing"; |
||
731 | criterion.SourceAttributeName = "Name"; |
||
732 | criterion.Operator = "="; |
||
733 | criterion.set_ValueAttribute(drawingName); |
||
734 | filter.get_Criteria().Add(criterion); |
||
735 | |||
736 | LMDrawings drawings = new LMDrawings(); |
||
737 | drawings.Collect(dataSource, Filter: filter); |
||
738 | |||
739 | currentDrawing = ((dynamic)drawings).Nth(1); |
||
740 | b66a2996 | gaqhf | } |
741 | |||
742 | 02480ac1 | gaqhf | /// <summary> |
743 | /// DrawingName, DrawingNumber를 확인하여 중복이 있으면 _1을 붙이고 +1씩 한다. |
||
744 | /// </summary> |
||
745 | /// <param name="drawingName"></param> |
||
746 | /// <param name="drawingNumber"></param> |
||
747 | b66a2996 | gaqhf | private void GetDrawingNameAndNumber(ref string drawingName, ref string drawingNumber) |
748 | { |
||
749 | LMDrawings drawings = new LMDrawings(); |
||
750 | drawings.Collect(dataSource); |
||
751 | 7f00b26c | gaqhf | |
752 | b66a2996 | gaqhf | List<string> drawingNameList = new List<string>(); |
753 | List<string> drawingNumberList = new List<string>(); |
||
754 | |||
755 | foreach (LMDrawing item in drawings) |
||
756 | { |
||
757 | drawingNameList.Add(item.Attributes["Name"].get_Value().ToString()); |
||
758 | drawingNumberList.Add(item.Attributes["DrawingNumber"].get_Value().ToString()); |
||
759 | } |
||
760 | |||
761 | int nameLength = drawingName.Length; |
||
762 | while (drawingNameList.Contains(drawingName)) |
||
763 | { |
||
764 | if (nameLength == drawingName.Length) |
||
765 | drawingName += "-1"; |
||
766 | else |
||
767 | { |
||
768 | int index = Convert.ToInt32(drawingName.Remove(0, nameLength + 1)); |
||
769 | drawingName = drawingName.Substring(0, nameLength + 1); |
||
770 | drawingName += ++index; |
||
771 | } |
||
772 | } |
||
773 | |||
774 | int numberLength = drawingNumber.Length; |
||
775 | while (drawingNameList.Contains(drawingNumber)) |
||
776 | { |
||
777 | if (numberLength == drawingNumber.Length) |
||
778 | drawingNumber += "-1"; |
||
779 | else |
||
780 | { |
||
781 | int index = Convert.ToInt32(drawingNumber.Remove(0, numberLength + 1)); |
||
782 | drawingNumber = drawingNumber.Substring(0, numberLength + 1); |
||
783 | drawingNumber += ++index; |
||
784 | } |
||
785 | } |
||
786 | |||
787 | ReleaseCOMObjects(drawings); |
||
788 | 0e0edfad | gaqhf | } |
789 | |||
790 | 74752074 | gaqhf | /// <summary> |
791 | /// 도면 크기 구하는 메서드 |
||
792 | /// </summary> |
||
793 | /// <returns></returns> |
||
794 | 0e0edfad | gaqhf | private bool DocumentCoordinateCorrection() |
795 | { |
||
796 | 6a7573b0 | gaqhf | if (Settings.Default.DrawingX != 0 && Settings.Default.DrawingY != 0) |
797 | 0e0edfad | gaqhf | { |
798 | 3734dcc5 | gaqhf | Log.Write("Setting Drawing X, Drawing Y"); |
799 | 6a7573b0 | gaqhf | document.SetSPPIDLocation(Settings.Default.DrawingX, Settings.Default.DrawingY); |
800 | 3734dcc5 | gaqhf | Log.Write("Start coordinate correction"); |
801 | c01ce90b | gaqhf | document.CoordinateCorrection(); |
802 | 0e0edfad | gaqhf | return true; |
803 | } |
||
804 | else |
||
805 | 3734dcc5 | gaqhf | { |
806 | Log.Write("Need Drawing X, Y"); |
||
807 | 0e0edfad | gaqhf | return false; |
808 | 3734dcc5 | gaqhf | } |
809 | 0e0edfad | gaqhf | } |
810 | |||
811 | 74752074 | gaqhf | /// <summary> |
812 | /// 심볼을 실제로 Modeling 메서드 |
||
813 | /// </summary> |
||
814 | /// <param name="symbol"></param> |
||
815 | /// <param name="targetSymbol"></param> |
||
816 | /// <param name="prevSymbol"></param> |
||
817 | b2d1c1aa | gaqhf | private void SymbolModeling(Symbol symbol, Symbol targetSymbol) |
818 | 809a7640 | gaqhf | { |
819 | 7f00b26c | gaqhf | // OWNERSYMBOL Attribute, 값을 가지고 있을 경우 |
820 | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(attr => attr.ATTRIBUTE == "OWNERSYMBOL"); |
||
821 | if (itemAttribute != null && (string.IsNullOrEmpty(itemAttribute.VALUE) || itemAttribute.VALUE != "None")) |
||
822 | return; |
||
823 | // 이미 모델링 됐을 경우 |
||
824 | else if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
825 | return; |
||
826 | 6a7573b0 | gaqhf | |
827 | 7f00b26c | gaqhf | LMSymbol _LMSymbol = null; |
828 | 809a7640 | gaqhf | |
829 | 7f00b26c | gaqhf | string mappingPath = symbol.SPPID.MAPPINGNAME; |
830 | double x = symbol.SPPID.ORIGINAL_X; |
||
831 | double y = symbol.SPPID.ORIGINAL_Y; |
||
832 | int mirror = 0; |
||
833 | double angle = symbol.ANGLE; |
||
834 | 2fdb56bf | gaqhf | |
835 | 7f00b26c | gaqhf | // OPC 일경우 180도 일때 Mirror |
836 | if (mappingPath.Contains("Piping OPC's") && angle == Math.PI) |
||
837 | mirror = 1; |
||
838 | 1ab9a205 | gaqhf | |
839 | 7f00b26c | gaqhf | // Mirror 계산 |
840 | if (symbol.FLIP == 1) |
||
841 | { |
||
842 | mirror = 1; |
||
843 | angle += Math.PI; |
||
844 | } |
||
845 | 1ab9a205 | gaqhf | |
846 | 7f00b26c | gaqhf | if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId)) |
847 | { |
||
848 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
849 | Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, symbol.UID, targetSymbol); |
||
850 | if (connector != null) |
||
851 | GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y); |
||
852 | 809a7640 | gaqhf | |
853 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
854 | 809a7640 | gaqhf | |
855 | 7f00b26c | gaqhf | if (_LMSymbol != null && _TargetItem != null) |
856 | 6a7573b0 | gaqhf | { |
857 | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
858 | ac78b508 | gaqhf | |
859 | 32205389 | gaqhf | if (SPPIDUtil.IsSegmentLine(document, symbol, targetSymbol)) |
860 | { |
||
861 | LMConnector reModelingConnector = FindBreakLineTarget(symbol, targetSymbol); |
||
862 | if (reModelingConnector != null) |
||
863 | ReModelingLMConnector(reModelingConnector); |
||
864 | } |
||
865 | 6a7573b0 | gaqhf | } |
866 | 809a7640 | gaqhf | |
867 | 7f00b26c | gaqhf | ReleaseCOMObjects(_TargetItem); |
868 | 4d2571ab | gaqhf | } |
869 | 7f00b26c | gaqhf | else |
870 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
871 | |||
872 | if (_LMSymbol != null) |
||
873 | 4d2571ab | gaqhf | { |
874 | 7f00b26c | gaqhf | _LMSymbol.Commit(); |
875 | symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
876 | symbol.SPPID.ModelItemID = _LMSymbol.ModelItemID; |
||
877 | 32205389 | gaqhf | symbol.SPPID.GraphicOID = _LMSymbol.get_GraphicOID().ToString(); |
878 | 7f00b26c | gaqhf | |
879 | foreach (var item in symbol.ChildSymbols) |
||
880 | 7e4a64a3 | gaqhf | CreateChildSymbol(item, _LMSymbol, symbol); |
881 | 3734dcc5 | gaqhf | |
882 | d9794a6c | gaqhf | symbol.SPPID.SPPID_X = _LMSymbol.get_XCoordinate(); |
883 | symbol.SPPID.SPPID_Y = _LMSymbol.get_YCoordinate(); |
||
884 | |||
885 | double[] range = null; |
||
886 | GetSPPIDSymbolRange(symbol, ref range); |
||
887 | symbol.SPPID.SPPID_Min_X = range[0]; |
||
888 | symbol.SPPID.SPPID_Min_Y = range[1]; |
||
889 | symbol.SPPID.SPPID_Max_X = range[2]; |
||
890 | symbol.SPPID.SPPID_Max_Y = range[3]; |
||
891 | |||
892 | foreach (var item in symbol.SPPID.CorrectionX_GroupSymbols) |
||
893 | item.SPPID.ORIGINAL_X = symbol.SPPID.SPPID_X; |
||
894 | foreach (var item in symbol.SPPID.CorrectionY_GroupSymbols) |
||
895 | item.SPPID.ORIGINAL_Y = symbol.SPPID.SPPID_Y; |
||
896 | |||
897 | 3734dcc5 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
898 | 4d2571ab | gaqhf | } |
899 | 809a7640 | gaqhf | } |
900 | |||
901 | d9794a6c | gaqhf | private void RemoveSymbol(Symbol symbol) |
902 | { |
||
903 | if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
904 | { |
||
905 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
906 | if (_LMSymbol != null) |
||
907 | { |
||
908 | _placement.PIDRemovePlacement(_LMSymbol.AsLMRepresentation()); |
||
909 | ReleaseCOMObjects(_LMSymbol); |
||
910 | } |
||
911 | } |
||
912 | |||
913 | symbol.SPPID.RepresentationId = string.Empty; |
||
914 | symbol.SPPID.ModelItemID = string.Empty; |
||
915 | symbol.SPPID.SPPID_X = double.NaN; |
||
916 | symbol.SPPID.SPPID_Y = double.NaN; |
||
917 | symbol.SPPID.SPPID_Min_X = double.NaN; |
||
918 | symbol.SPPID.SPPID_Min_Y = double.NaN; |
||
919 | symbol.SPPID.SPPID_Max_X = double.NaN; |
||
920 | symbol.SPPID.SPPID_Max_Y = double.NaN; |
||
921 | } |
||
922 | |||
923 | private void RemoveSymbol(List<Symbol> symbols) |
||
924 | { |
||
925 | foreach (var symbol in symbols) |
||
926 | { |
||
927 | if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
||
928 | { |
||
929 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
930 | if (_LMSymbol != null) |
||
931 | { |
||
932 | _placement.PIDRemovePlacement(_LMSymbol.AsLMRepresentation()); |
||
933 | ReleaseCOMObjects(_LMSymbol); |
||
934 | } |
||
935 | } |
||
936 | |||
937 | symbol.SPPID.RepresentationId = string.Empty; |
||
938 | symbol.SPPID.ModelItemID = string.Empty; |
||
939 | symbol.SPPID.SPPID_X = double.NaN; |
||
940 | symbol.SPPID.SPPID_Y = double.NaN; |
||
941 | symbol.SPPID.SPPID_Min_X = double.NaN; |
||
942 | symbol.SPPID.SPPID_Min_Y = double.NaN; |
||
943 | symbol.SPPID.SPPID_Max_X = double.NaN; |
||
944 | symbol.SPPID.SPPID_Max_Y = double.NaN; |
||
945 | } |
||
946 | } |
||
947 | |||
948 | d1eac84d | gaqhf | /// <summary> |
949 | /// ID2의 Symbol Width와 Height를 비교해서 상대적인 SPPID Connector좌표를 가져온다. |
||
950 | /// </summary> |
||
951 | /// <param name="targetConnector"></param> |
||
952 | /// <param name="targetSymbol"></param> |
||
953 | /// <param name="x"></param> |
||
954 | /// <param name="y"></param> |
||
955 | private void GetTargetSymbolConnectorPoint(Connector targetConnector, Symbol targetSymbol, ref double x, ref double y) |
||
956 | { |
||
957 | LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
958 | 2fdb56bf | gaqhf | |
959 | double[] range = null; |
||
960 | d1eac84d | gaqhf | List<double[]> points = new List<double[]>(); |
961 | 2fdb56bf | gaqhf | GetSPPIDSymbolRangeAndConnectionPoints(targetSymbol, ref range, points); |
962 | double x1 = range[0]; |
||
963 | double y1 = range[1]; |
||
964 | double x2 = range[2]; |
||
965 | double y2 = range[3]; |
||
966 | d1eac84d | gaqhf | |
967 | // Origin 기준 Connector의 위치차이 |
||
968 | double sceneX = 0; |
||
969 | double sceneY = 0; |
||
970 | SPPIDUtil.ConvertPointBystring(targetConnector.SCENECONNECTPOINT, ref sceneX, ref sceneY); |
||
971 | double originX = 0; |
||
972 | double originY = 0; |
||
973 | SPPIDUtil.ConvertPointBystring(targetSymbol.ORIGINALPOINT, ref originX, ref originY); |
||
974 | double gapX = originX - sceneX; |
||
975 | double gapY = originY - sceneY; |
||
976 | |||
977 | // SPPID Symbol과 ID2 심볼의 크기 차이 |
||
978 | 026f394f | gaqhf | double sizeWidth = 0; |
979 | double sizeHeight = 0; |
||
980 | SPPIDUtil.ConvertPointBystring(targetSymbol.SIZE, ref sizeWidth, ref sizeHeight); |
||
981 | if (sizeWidth == 0 || sizeHeight == 0) |
||
982 | throw new Exception("Check symbol size! \r\nUID : " + targetSymbol.UID); |
||
983 | |||
984 | d1eac84d | gaqhf | double percentX = (x2 - x1) / sizeWidth; |
985 | double percentY = (y2 - y1) / sizeHeight; |
||
986 | |||
987 | double SPPIDgapX = gapX * percentX; |
||
988 | double SPPIDgapY = gapY * percentY; |
||
989 | |||
990 | double[] SPPIDOriginPoint = new double[] { _TargetItem.get_XCoordinate() - SPPIDgapX, _TargetItem.get_YCoordinate() + SPPIDgapY }; |
||
991 | double distance = double.MaxValue; |
||
992 | double[] resultPoint; |
||
993 | foreach (var point in points) |
||
994 | { |
||
995 | double result = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], SPPIDOriginPoint[0], SPPIDOriginPoint[1]); |
||
996 | if (distance > result) |
||
997 | { |
||
998 | distance = result; |
||
999 | resultPoint = point; |
||
1000 | x = point[0]; |
||
1001 | y = point[1]; |
||
1002 | } |
||
1003 | } |
||
1004 | 2fdb56bf | gaqhf | |
1005 | ReleaseCOMObjects(_TargetItem); |
||
1006 | } |
||
1007 | |||
1008 | a0e3dca4 | gaqhf | private void GetTargetLineConnectorPoint(Connector targetConnector, Line targetLine, ref double x, ref double y) |
1009 | { |
||
1010 | int index = targetLine.CONNECTORS.IndexOf(targetConnector); |
||
1011 | if (index == 0) |
||
1012 | { |
||
1013 | x = targetLine.SPPID.START_X; |
||
1014 | y = targetLine.SPPID.START_Y; |
||
1015 | } |
||
1016 | else |
||
1017 | { |
||
1018 | x = targetLine.SPPID.END_X; |
||
1019 | y = targetLine.SPPID.END_Y; |
||
1020 | } |
||
1021 | } |
||
1022 | |||
1023 | 2fdb56bf | gaqhf | /// <summary> |
1024 | /// SPPID Symbol의 Range를 구한다. |
||
1025 | /// </summary> |
||
1026 | /// <param name="symbol"></param> |
||
1027 | /// <param name="range"></param> |
||
1028 | private void GetSPPIDSymbolRangeAndConnectionPoints(Symbol symbol, ref double[] range, List<double[]> points) |
||
1029 | { |
||
1030 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1031 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
1032 | double x1 = 0; |
||
1033 | double y1 = 0; |
||
1034 | double x2 = 0; |
||
1035 | double y2 = 0; |
||
1036 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1037 | range = new double[] { x1, y1, x2, y2 }; |
||
1038 | |||
1039 | for (int i = 1; i < int.MaxValue; i++) |
||
1040 | { |
||
1041 | double connX = 0; |
||
1042 | double connY = 0; |
||
1043 | if (_placement.PIDConnectPointLocation(_TargetItem, i, ref connX, ref connY)) |
||
1044 | points.Add(new double[] { connX, connY }); |
||
1045 | else |
||
1046 | break; |
||
1047 | } |
||
1048 | |||
1049 | foreach (var childSymbol in symbol.ChildSymbols) |
||
1050 | GetSPPIDChildSymbolRange(childSymbol, ref range, points); |
||
1051 | |||
1052 | ReleaseCOMObjects(_TargetItem); |
||
1053 | } |
||
1054 | |||
1055 | d9794a6c | gaqhf | private void GetSPPIDSymbolRange(Symbol symbol, ref double[] range) |
1056 | { |
||
1057 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1058 | 7e4a64a3 | gaqhf | if (_TargetItem != null) |
1059 | { |
||
1060 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
1061 | double x1 = 0; |
||
1062 | double y1 = 0; |
||
1063 | double x2 = 0; |
||
1064 | double y2 = 0; |
||
1065 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1066 | range = new double[] { x1, y1, x2, y2 }; |
||
1067 | d9794a6c | gaqhf | |
1068 | 7e4a64a3 | gaqhf | foreach (var childSymbol in symbol.ChildSymbols) |
1069 | GetSPPIDChildSymbolRange(childSymbol, ref range); |
||
1070 | d9794a6c | gaqhf | |
1071 | 7e4a64a3 | gaqhf | ReleaseCOMObjects(_TargetItem); |
1072 | } |
||
1073 | d9794a6c | gaqhf | } |
1074 | |||
1075 | private void GetSPPIDSymbolRange(List<Symbol> symbols, ref double[] range) |
||
1076 | { |
||
1077 | double[] tempRange = new double[] { double.MaxValue, double.MaxValue, double.MinValue, double.MinValue }; |
||
1078 | foreach (var symbol in symbols) |
||
1079 | { |
||
1080 | LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
1081 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
||
1082 | double x1 = 0; |
||
1083 | double y1 = 0; |
||
1084 | double x2 = 0; |
||
1085 | double y2 = 0; |
||
1086 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1087 | |||
1088 | tempRange[0] = Math.Min(tempRange[0], x1); |
||
1089 | tempRange[1] = Math.Min(tempRange[1], y1); |
||
1090 | tempRange[2] = Math.Max(tempRange[2], x2); |
||
1091 | tempRange[3] = Math.Max(tempRange[3], y2); |
||
1092 | |||
1093 | foreach (var childSymbol in symbol.ChildSymbols) |
||
1094 | f1a7faf9 | gaqhf | GetSPPIDChildSymbolRange(childSymbol, ref tempRange); |
1095 | d9794a6c | gaqhf | |
1096 | ReleaseCOMObjects(_TargetItem); |
||
1097 | } |
||
1098 | |||
1099 | range = tempRange; |
||
1100 | } |
||
1101 | |||
1102 | 2fdb56bf | gaqhf | /// <summary> |
1103 | /// Child Modeling 된 Symbol의 Range를 구한다. |
||
1104 | /// </summary> |
||
1105 | /// <param name="childSymbol"></param> |
||
1106 | /// <param name="range"></param> |
||
1107 | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range, List<double[]> points) |
||
1108 | { |
||
1109 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
1110 | 3783c494 | gaqhf | if (_ChildSymbol != null) |
1111 | 2fdb56bf | gaqhf | { |
1112 | 3783c494 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
1113 | double x1 = 0; |
||
1114 | double y1 = 0; |
||
1115 | double x2 = 0; |
||
1116 | double y2 = 0; |
||
1117 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1118 | range[0] = Math.Min(range[0], x1); |
||
1119 | range[1] = Math.Min(range[1], y1); |
||
1120 | range[2] = Math.Max(range[2], x2); |
||
1121 | range[3] = Math.Max(range[3], y2); |
||
1122 | |||
1123 | for (int i = 1; i < int.MaxValue; i++) |
||
1124 | { |
||
1125 | double connX = 0; |
||
1126 | double connY = 0; |
||
1127 | if (_placement.PIDConnectPointLocation(_ChildSymbol, i, ref connX, ref connY)) |
||
1128 | points.Add(new double[] { connX, connY }); |
||
1129 | else |
||
1130 | break; |
||
1131 | } |
||
1132 | 2fdb56bf | gaqhf | |
1133 | 3783c494 | gaqhf | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
1134 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range, points); |
||
1135 | 2fdb56bf | gaqhf | |
1136 | 3783c494 | gaqhf | ReleaseCOMObjects(_ChildSymbol); |
1137 | } |
||
1138 | d1eac84d | gaqhf | } |
1139 | |||
1140 | d9794a6c | gaqhf | private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range) |
1141 | { |
||
1142 | LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId); |
||
1143 | 7e4a64a3 | gaqhf | if (_ChildSymbol != null) |
1144 | { |
||
1145 | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()]; |
||
1146 | double x1 = 0; |
||
1147 | double y1 = 0; |
||
1148 | double x2 = 0; |
||
1149 | double y2 = 0; |
||
1150 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1151 | range[0] = Math.Min(range[0], x1); |
||
1152 | range[1] = Math.Min(range[1], y1); |
||
1153 | range[2] = Math.Max(range[2], x2); |
||
1154 | range[3] = Math.Max(range[3], y2); |
||
1155 | d9794a6c | gaqhf | |
1156 | 7e4a64a3 | gaqhf | foreach (var loopChildSymbol in childSymbol.ChildSymbols) |
1157 | GetSPPIDChildSymbolRange(loopChildSymbol, ref range); |
||
1158 | ReleaseCOMObjects(_ChildSymbol); |
||
1159 | } |
||
1160 | d9794a6c | gaqhf | } |
1161 | |||
1162 | d1eac84d | gaqhf | /// <summary> |
1163 | /// Label Symbol Modeling |
||
1164 | /// </summary> |
||
1165 | /// <param name="symbol"></param> |
||
1166 | 73415441 | gaqhf | private void LabelSymbolModeling(Symbol symbol) |
1167 | { |
||
1168 | fb386b8c | gaqhf | if (string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
1169 | 73415441 | gaqhf | { |
1170 | fb386b8c | gaqhf | BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
1171 | if (itemAttribute == null || string.IsNullOrEmpty(itemAttribute.VALUE) || itemAttribute.VALUE == "None") |
||
1172 | return; |
||
1173 | Array points = new double[] { 0, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y }; |
||
1174 | |||
1175 | string symbolUID = itemAttribute.VALUE; |
||
1176 | object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
||
1177 | if (targetItem != null && |
||
1178 | (targetItem.GetType() == typeof(Symbol) || |
||
1179 | targetItem.GetType() == typeof(Equipment))) |
||
1180 | 73415441 | gaqhf | { |
1181 | fb386b8c | gaqhf | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
1182 | string sRep = null; |
||
1183 | if (targetItem.GetType() == typeof(Symbol)) |
||
1184 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
1185 | else if (targetItem.GetType() == typeof(Equipment)) |
||
1186 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
1187 | if (!string.IsNullOrEmpty(sRep)) |
||
1188 | 73415441 | gaqhf | { |
1189 | fb386b8c | gaqhf | // LEADER Line 검사 |
1190 | bool leaderLine = false; |
||
1191 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
1192 | if (symbolMapping != null) |
||
1193 | leaderLine = symbolMapping.LEADERLINE; |
||
1194 | |||
1195 | // Target Symbol Item 가져오고 Label Modeling |
||
1196 | LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
||
1197 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
1198 | |||
1199 | //Leader 선 센터로 |
||
1200 | if (_LMLabelPresist != null) |
||
1201 | 73415441 | gaqhf | { |
1202 | fb386b8c | gaqhf | // Target Item에 Label의 Attribute Input |
1203 | InputSymbolAttribute(targetItem, symbol.ATTRIBUTES); |
||
1204 | |||
1205 | 32205389 | gaqhf | string OID = _LMLabelPresist.get_GraphicOID().ToString(); |
1206 | fb386b8c | gaqhf | DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
1207 | if (dependency != null) |
||
1208 | 73415441 | gaqhf | { |
1209 | fb386b8c | gaqhf | bool result = false; |
1210 | foreach (var attributes in dependency.AttributeSets) |
||
1211 | 73415441 | gaqhf | { |
1212 | fb386b8c | gaqhf | foreach (var attribute in attributes) |
1213 | 73415441 | gaqhf | { |
1214 | fb386b8c | gaqhf | string name = attribute.Name; |
1215 | string value = attribute.GetValue().ToString(); |
||
1216 | if (name == "DrawingItemType" && value == "LabelPersist") |
||
1217 | 73415441 | gaqhf | { |
1218 | fb386b8c | gaqhf | foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
1219 | b2d1c1aa | gaqhf | { |
1220 | fb386b8c | gaqhf | if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
1221 | { |
||
1222 | Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
||
1223 | double prevX = _TargetItem.get_XCoordinate(); |
||
1224 | double prevY = _TargetItem.get_YCoordinate(); |
||
1225 | lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
||
1226 | lineString2D.RemoveVertex(lineString2D.VertexCount); |
||
1227 | result = true; |
||
1228 | break; |
||
1229 | } |
||
1230 | b2d1c1aa | gaqhf | } |
1231 | 73415441 | gaqhf | } |
1232 | fb386b8c | gaqhf | |
1233 | if (result) |
||
1234 | break; |
||
1235 | 73415441 | gaqhf | } |
1236 | b2d1c1aa | gaqhf | |
1237 | if (result) |
||
1238 | break; |
||
1239 | 73415441 | gaqhf | } |
1240 | } |
||
1241 | fb386b8c | gaqhf | |
1242 | 30ba9ae0 | gaqhf | symbol.SPPID.RepresentationId = _LMLabelPresist.AsLMRepresentation().Id; |
1243 | fb386b8c | gaqhf | _LMLabelPresist.Commit(); |
1244 | ReleaseCOMObjects(_LMLabelPresist); |
||
1245 | 73415441 | gaqhf | } |
1246 | |||
1247 | fb386b8c | gaqhf | ReleaseCOMObjects(_TargetItem); |
1248 | b2d1c1aa | gaqhf | } |
1249 | 73415441 | gaqhf | } |
1250 | fb386b8c | gaqhf | else if (targetItem != null && targetItem.GetType() == typeof(Line)) |
1251 | 0860c756 | gaqhf | { |
1252 | fb386b8c | gaqhf | Line targetLine = targetItem as Line; |
1253 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(targetLine.SPPID.ModelItemId); |
||
1254 | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y); |
||
1255 | if (connectedLMConnector != null) |
||
1256 | 0860c756 | gaqhf | { |
1257 | fb386b8c | gaqhf | // LEADER Line 검사 |
1258 | bool leaderLine = false; |
||
1259 | SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
||
1260 | if (symbolMapping != null) |
||
1261 | leaderLine = symbolMapping.LEADERLINE; |
||
1262 | |||
1263 | LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
||
1264 | if (_LMLabelPresist != null) |
||
1265 | { |
||
1266 | _LMLabelPresist.Commit(); |
||
1267 | ReleaseCOMObjects(_LMLabelPresist); |
||
1268 | } |
||
1269 | ReleaseCOMObjects(connectedLMConnector); |
||
1270 | 0860c756 | gaqhf | } |
1271 | |||
1272 | fb386b8c | gaqhf | foreach (var item in connectorVertices) |
1273 | if (item.Key != null) |
||
1274 | ReleaseCOMObjects(item.Key); |
||
1275 | } |
||
1276 | 0860c756 | gaqhf | } |
1277 | 73415441 | gaqhf | } |
1278 | |||
1279 | 74752074 | gaqhf | /// <summary> |
1280 | /// Equipment를 실제로 Modeling 메서드 |
||
1281 | /// </summary> |
||
1282 | /// <param name="equipment"></param> |
||
1283 | b9e9f4c8 | gaqhf | private void EquipmentModeling(Equipment equipment) |
1284 | { |
||
1285 | if (!string.IsNullOrEmpty(equipment.SPPID.RepresentationId)) |
||
1286 | return; |
||
1287 | |||
1288 | LMSymbol _LMSymbol = null; |
||
1289 | LMSymbol targetItem = null; |
||
1290 | string mappingPath = equipment.SPPID.MAPPINGNAME; |
||
1291 | double x = equipment.SPPID.ORIGINAL_X; |
||
1292 | double y = equipment.SPPID.ORIGINAL_Y; |
||
1293 | int mirror = 0; |
||
1294 | double angle = equipment.ANGLE; |
||
1295 | |||
1296 | 20972c61 | gaqhf | SPPIDUtil.ConvertGridPoint(ref x, ref y); |
1297 | |||
1298 | b9e9f4c8 | gaqhf | Connector connector = equipment.CONNECTORS.Find(conn => !string.IsNullOrEmpty(conn.CONNECTEDITEM) && conn.CONNECTEDITEM != "None"); |
1299 | if (connector != null) |
||
1300 | { |
||
1301 | Equipment connEquipment = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Equipment; |
||
1302 | if (connEquipment != null) |
||
1303 | { |
||
1304 | if (string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
1305 | EquipmentModeling(connEquipment); |
||
1306 | |||
1307 | if (!string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
||
1308 | { |
||
1309 | targetItem = dataSource.GetSymbol(connEquipment.SPPID.RepresentationId); |
||
1310 | if (targetItem != null) |
||
1311 | { |
||
1312 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: targetItem); |
||
1313 | } |
||
1314 | else |
||
1315 | { |
||
1316 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1317 | } |
||
1318 | } |
||
1319 | else |
||
1320 | { |
||
1321 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1322 | } |
||
1323 | } |
||
1324 | else |
||
1325 | { |
||
1326 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1327 | } |
||
1328 | } |
||
1329 | else |
||
1330 | { |
||
1331 | _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
||
1332 | } |
||
1333 | |||
1334 | if (_LMSymbol != null) |
||
1335 | { |
||
1336 | _LMSymbol.Commit(); |
||
1337 | equipment.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
1338 | 32205389 | gaqhf | equipment.SPPID.GraphicOID = _LMSymbol.get_GraphicOID().ToString(); |
1339 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1340 | } |
||
1341 | |||
1342 | if (targetItem != null) |
||
1343 | { |
||
1344 | ReleaseCOMObjects(targetItem); |
||
1345 | } |
||
1346 | 7f00b26c | gaqhf | |
1347 | b9e9f4c8 | gaqhf | ReleaseCOMObjects(_LMSymbol); |
1348 | } |
||
1349 | |||
1350 | d9794a6c | gaqhf | /// <summary> |
1351 | /// 첫 진입점 |
||
1352 | /// </summary> |
||
1353 | /// <param name="symbol"></param> |
||
1354 | private void SymbolModelingBySymbol(Symbol symbol) |
||
1355 | { |
||
1356 | f1a7faf9 | gaqhf | SymbolModeling(symbol, null); |
1357 | d9794a6c | gaqhf | List<object> endObjects = new List<object>(); |
1358 | endObjects.Add(symbol); |
||
1359 | f1a7faf9 | gaqhf | |
1360 | d9794a6c | gaqhf | foreach (var connector in symbol.CONNECTORS) |
1361 | 4d2571ab | gaqhf | { |
1362 | d9794a6c | gaqhf | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
1363 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1364 | d1eac84d | gaqhf | { |
1365 | d9794a6c | gaqhf | endObjects.Add(connItem); |
1366 | if (connItem.GetType() == typeof(Symbol)) |
||
1367 | 4d2571ab | gaqhf | { |
1368 | d9794a6c | gaqhf | Symbol connSymbol = connItem as Symbol; |
1369 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1370 | 4d2571ab | gaqhf | { |
1371 | d9794a6c | gaqhf | SymbolModeling(connSymbol, symbol); |
1372 | } |
||
1373 | 6db30942 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
1374 | f1a7faf9 | gaqhf | SymbolModelingByNeerSymbolLoop(connSymbol, endObjects); |
1375 | d9794a6c | gaqhf | } |
1376 | else if (connItem.GetType() == typeof(Line)) |
||
1377 | { |
||
1378 | Line connLine = connItem as Line; |
||
1379 | f1a7faf9 | gaqhf | SymbolModelingByNeerLineLoop(connLine, endObjects, symbol); |
1380 | d9794a6c | gaqhf | } |
1381 | } |
||
1382 | } |
||
1383 | } |
||
1384 | 4d2571ab | gaqhf | |
1385 | f1a7faf9 | gaqhf | private void SymbolModelingByNeerSymbolLoop(Symbol symbol, List<object> endObjects) |
1386 | d9794a6c | gaqhf | { |
1387 | foreach (var connector in symbol.CONNECTORS) |
||
1388 | { |
||
1389 | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
1390 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1391 | { |
||
1392 | if (!endObjects.Contains(connItem)) |
||
1393 | { |
||
1394 | endObjects.Add(connItem); |
||
1395 | if (connItem.GetType() == typeof(Symbol)) |
||
1396 | { |
||
1397 | Symbol connSymbol = connItem as Symbol; |
||
1398 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1399 | 4d2571ab | gaqhf | { |
1400 | d9794a6c | gaqhf | SymbolModeling(connSymbol, symbol); |
1401 | 4d2571ab | gaqhf | } |
1402 | 6db30942 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
1403 | f1a7faf9 | gaqhf | SymbolModelingByNeerSymbolLoop(connSymbol, endObjects); |
1404 | 4d2571ab | gaqhf | } |
1405 | d9794a6c | gaqhf | else if (connItem.GetType() == typeof(Line)) |
1406 | { |
||
1407 | Line connLine = connItem as Line; |
||
1408 | f1a7faf9 | gaqhf | SymbolModelingByNeerLineLoop(connLine, endObjects, symbol); |
1409 | d9794a6c | gaqhf | } |
1410 | } |
||
1411 | } |
||
1412 | } |
||
1413 | } |
||
1414 | 4d2571ab | gaqhf | |
1415 | f1a7faf9 | gaqhf | private void SymbolModelingByNeerLineLoop(Line line, List<object> endObjects, Symbol prevSymbol) |
1416 | d9794a6c | gaqhf | { |
1417 | foreach (var connector in line.CONNECTORS) |
||
1418 | { |
||
1419 | object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
||
1420 | if (connItem != null && connItem.GetType() != typeof(Equipment)) |
||
1421 | { |
||
1422 | if (!endObjects.Contains(connItem)) |
||
1423 | { |
||
1424 | endObjects.Add(connItem); |
||
1425 | if (connItem.GetType() == typeof(Symbol)) |
||
1426 | { |
||
1427 | Symbol connSymbol = connItem as Symbol; |
||
1428 | if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId)) |
||
1429 | { |
||
1430 | List<Symbol> group = new List<Symbol>(); |
||
1431 | SPPIDUtil.FindConnectedSymbolGroup(document, connSymbol, group); |
||
1432 | f1a7faf9 | gaqhf | Symbol priority = prioritySymbols.Find(x => group.Contains(x)); |
1433 | List<Symbol> endModelingGroup = new List<Symbol>(); |
||
1434 | if (priority != null) |
||
1435 | d9794a6c | gaqhf | { |
1436 | f1a7faf9 | gaqhf | SymbolGroupModeling(priority, group); |
1437 | d9794a6c | gaqhf | |
1438 | // Range 겹치는지 확인해야함 |
||
1439 | double[] prevRange = null; |
||
1440 | GetSPPIDSymbolRange(prevSymbol, ref prevRange); |
||
1441 | double[] groupRange = null; |
||
1442 | GetSPPIDSymbolRange(group, ref groupRange); |
||
1443 | |||
1444 | double distanceX = 0; |
||
1445 | double distanceY = 0; |
||
1446 | 6d12a734 | gaqhf | bool overlapX = false; |
1447 | bool overlapY = false; |
||
1448 | SlopeType slopeType = SPPIDUtil.CalcSlope(prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y); |
||
1449 | SPPIDUtil.CalcOverlap(prevRange, groupRange, ref distanceX, ref distanceY, ref overlapX, ref overlapY); |
||
1450 | if ((slopeType == SlopeType.HORIZONTAL && overlapX) || |
||
1451 | (slopeType == SlopeType.VERTICAL && overlapY)) |
||
1452 | d9794a6c | gaqhf | { |
1453 | RemoveSymbol(group); |
||
1454 | foreach (var _temp in group) |
||
1455 | SPPIDUtil.CalcNewCoordinateForSymbol(_temp, prevSymbol, distanceX, distanceY); |
||
1456 | |||
1457 | f1a7faf9 | gaqhf | SymbolGroupModeling(priority, group); |
1458 | d9794a6c | gaqhf | } |
1459 | } |
||
1460 | else |
||
1461 | { |
||
1462 | SymbolModeling(connSymbol, null); |
||
1463 | // Range 겹치는지 확인해야함 |
||
1464 | double[] prevRange = null; |
||
1465 | GetSPPIDSymbolRange(prevSymbol, ref prevRange); |
||
1466 | double[] connRange = null; |
||
1467 | GetSPPIDSymbolRange(connSymbol, ref connRange); |
||
1468 | |||
1469 | double distanceX = 0; |
||
1470 | double distanceY = 0; |
||
1471 | 6d12a734 | gaqhf | bool overlapX = false; |
1472 | bool overlapY = false; |
||
1473 | SlopeType slopeType = SPPIDUtil.CalcSlope(prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y); |
||
1474 | SPPIDUtil.CalcOverlap(prevRange, connRange, ref distanceX, ref distanceY, ref overlapX, ref overlapY); |
||
1475 | if ((slopeType == SlopeType.HORIZONTAL && overlapX) || |
||
1476 | (slopeType == SlopeType.VERTICAL && overlapY)) |
||
1477 | d9794a6c | gaqhf | { |
1478 | RemoveSymbol(connSymbol); |
||
1479 | SPPIDUtil.CalcNewCoordinateForSymbol(connSymbol, prevSymbol, distanceX, distanceY); |
||
1480 | |||
1481 | SymbolModeling(connSymbol, null); |
||
1482 | } |
||
1483 | } |
||
1484 | } |
||
1485 | 6db30942 | gaqhf | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count); |
1486 | f1a7faf9 | gaqhf | SymbolModelingByNeerSymbolLoop(connSymbol, endObjects); |
1487 | d9794a6c | gaqhf | } |
1488 | else if (connItem.GetType() == typeof(Line)) |
||
1489 | { |
||
1490 | Line connLine = connItem as Line; |
||
1491 | if (!SPPIDUtil.IsBranchLine(connLine, line)) |
||
1492 | f1a7faf9 | gaqhf | SymbolModelingByNeerLineLoop(connLine, endObjects, prevSymbol); |
1493 | d9794a6c | gaqhf | } |
1494 | 4d2571ab | gaqhf | } |
1495 | d1eac84d | gaqhf | } |
1496 | } |
||
1497 | } |
||
1498 | |||
1499 | f1a7faf9 | gaqhf | private void SymbolGroupModeling(Symbol firstSymbol, List<Symbol> group) |
1500 | { |
||
1501 | List<Symbol> endModelingGroup = new List<Symbol>(); |
||
1502 | SymbolModeling(firstSymbol, null); |
||
1503 | endModelingGroup.Add(firstSymbol); |
||
1504 | while (endModelingGroup.Count != group.Count) |
||
1505 | { |
||
1506 | foreach (var _symbol in group) |
||
1507 | { |
||
1508 | if (!endModelingGroup.Contains(_symbol)) |
||
1509 | { |
||
1510 | foreach (var _connector in _symbol.CONNECTORS) |
||
1511 | { |
||
1512 | Symbol _connSymbol = SPPIDUtil.FindObjectByUID(document, _connector.CONNECTEDITEM) as Symbol; |
||
1513 | if (_connSymbol != null && endModelingGroup.Contains(_connSymbol)) |
||
1514 | { |
||
1515 | SymbolModeling(_symbol, _connSymbol); |
||
1516 | endModelingGroup.Add(_symbol); |
||
1517 | break; |
||
1518 | } |
||
1519 | } |
||
1520 | } |
||
1521 | } |
||
1522 | } |
||
1523 | } |
||
1524 | d9794a6c | gaqhf | |
1525 | d1eac84d | gaqhf | /// <summary> |
1526 | 74752074 | gaqhf | /// 심볼을 실제로 Modeling할때 ChildSymbol이 있다면 Modeling하는 메서드 |
1527 | /// </summary> |
||
1528 | /// <param name="childSymbol"></param> |
||
1529 | /// <param name="parentSymbol"></param> |
||
1530 | 7e4a64a3 | gaqhf | private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol, Symbol parent) |
1531 | ac78b508 | gaqhf | { |
1532 | 4b4dbca9 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()]; |
1533 | double x1 = 0; |
||
1534 | double x2 = 0; |
||
1535 | double y1 = 0; |
||
1536 | double y2 = 0; |
||
1537 | symbol2d.Range(out x1, out y1, out x2, out y2); |
||
1538 | |||
1539 | LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, (x1 + x2) / 2, (y1 + y2) / 2, TargetItem: parentSymbol); |
||
1540 | if (_LMSymbol != null) |
||
1541 | { |
||
1542 | childSymbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
1543 | foreach (var item in childSymbol.ChildSymbols) |
||
1544 | 7e4a64a3 | gaqhf | CreateChildSymbol(item, _LMSymbol, parent); |
1545 | 4b4dbca9 | gaqhf | } |
1546 | 7f00b26c | gaqhf | |
1547 | ac78b508 | gaqhf | |
1548 | ReleaseCOMObjects(_LMSymbol); |
||
1549 | } |
||
1550 | dec9ecfd | gaqhf | double index = 0; |
1551 | 32205389 | gaqhf | private void NewLineModeling(Line line, bool isBranchModeling = false) |
1552 | 809a7640 | gaqhf | { |
1553 | f3e2693f | gaqhf | if (!string.IsNullOrEmpty(line.SPPID.ModelItemId) || (BranchLines.Contains(line) && !isBranchModeling)) |
1554 | a0e3dca4 | gaqhf | return; |
1555 | |||
1556 | List<Line> group = new List<Line>(); |
||
1557 | GetConnectedLineGroup(line, group); |
||
1558 | LineCoordinateCorrection(group); |
||
1559 | |||
1560 | foreach (var groupLine in group) |
||
1561 | 809a7640 | gaqhf | { |
1562 | e283d483 | gaqhf | if (!isBranchModeling && SPPIDUtil.IsBranchLine(groupLine)) |
1563 | 5173ba5d | gaqhf | { |
1564 | f3e2693f | gaqhf | BranchLines.Add(groupLine); |
1565 | 5173ba5d | gaqhf | continue; |
1566 | } |
||
1567 | f9cc5190 | gaqhf | |
1568 | 24b5276c | gaqhf | bool diagonal = false; |
1569 | if (groupLine.SlopeType != SlopeType.HORIZONTAL && groupLine.SlopeType != SlopeType.VERTICAL) |
||
1570 | diagonal = true; |
||
1571 | 5173ba5d | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(groupLine.SPPID.MAPPINGNAME); |
1572 | LMSymbol _LMSymbolStart = null; |
||
1573 | LMSymbol _LMSymbolEnd = null; |
||
1574 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1575 | foreach (var connector in groupLine.CONNECTORS) |
||
1576 | 809a7640 | gaqhf | { |
1577 | 5173ba5d | gaqhf | double x = 0; |
1578 | double y = 0; |
||
1579 | GetTargetLineConnectorPoint(connector, groupLine, ref x, ref y); |
||
1580 | if (connector.ConnectedObject == null) |
||
1581 | 809a7640 | gaqhf | { |
1582 | 5173ba5d | gaqhf | placeRunInputs.AddPoint(x, y); |
1583 | a0e3dca4 | gaqhf | } |
1584 | 5173ba5d | gaqhf | else if (connector.ConnectedObject.GetType() == typeof(Symbol)) |
1585 | a0e3dca4 | gaqhf | { |
1586 | 5173ba5d | gaqhf | Symbol targetSymbol = connector.ConnectedObject as Symbol; |
1587 | f9cc5190 | gaqhf | GetTargetSymbolConnectorPoint(targetSymbol.CONNECTORS.Find(z => z.ConnectedObject == groupLine), targetSymbol, ref x, ref y); |
1588 | 5173ba5d | gaqhf | if (groupLine.CONNECTORS.IndexOf(connector) == 0) |
1589 | a0e3dca4 | gaqhf | { |
1590 | 5173ba5d | gaqhf | _LMSymbolStart = GetTargetSymbol(targetSymbol, groupLine); |
1591 | 3783c494 | gaqhf | if (_LMSymbolStart != null) |
1592 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(_LMSymbolStart, x, y, diagonal); |
1593 | 3783c494 | gaqhf | else |
1594 | placeRunInputs.AddPoint(x, y); |
||
1595 | 5173ba5d | gaqhf | } |
1596 | else |
||
1597 | { |
||
1598 | _LMSymbolEnd = GetTargetSymbol(targetSymbol, groupLine); |
||
1599 | 3783c494 | gaqhf | if (_LMSymbolEnd != null) |
1600 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(_LMSymbolEnd, x, y, diagonal); |
1601 | 3783c494 | gaqhf | else |
1602 | placeRunInputs.AddPoint(x, y); |
||
1603 | a0e3dca4 | gaqhf | } |
1604 | 5173ba5d | gaqhf | } |
1605 | else if (connector.ConnectedObject.GetType() == typeof(Line)) |
||
1606 | { |
||
1607 | Line targetLine = connector.ConnectedObject as Line; |
||
1608 | if (!string.IsNullOrEmpty(targetLine.SPPID.ModelItemId)) |
||
1609 | a0e3dca4 | gaqhf | { |
1610 | 5173ba5d | gaqhf | LMConnector targetConnector = FindTargetLMConnectorForBranch(line, targetLine, ref x, ref y); |
1611 | 1c944b34 | gaqhf | if (targetConnector != null) |
1612 | 0ff6e67f | gaqhf | { |
1613 | placeRunInputs.AddConnectorTarget(targetConnector, x, y, diagonal); |
||
1614 | ChangeLineSPPIDCoordinateByConnector(groupLine, targetLine, x, y, false); |
||
1615 | } |
||
1616 | else |
||
1617 | { |
||
1618 | placeRunInputs.AddPoint( x, y); |
||
1619 | ChangeLineSPPIDCoordinateByConnector(groupLine, targetLine, x, y, false); |
||
1620 | } |
||
1621 | a0e3dca4 | gaqhf | } |
1622 | 5173ba5d | gaqhf | else |
1623 | 809a7640 | gaqhf | { |
1624 | 5173ba5d | gaqhf | if (groupLine.CONNECTORS.IndexOf(connector) == 0) |
1625 | a0e3dca4 | gaqhf | { |
1626 | dec9ecfd | gaqhf | index += 0.01; |
1627 | 5173ba5d | gaqhf | if (groupLine.SlopeType == SlopeType.HORIZONTAL) |
1628 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(x, -0.1 - index); |
1629 | 5173ba5d | gaqhf | else if (groupLine.SlopeType == SlopeType.VERTICAL) |
1630 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1631 | 5173ba5d | gaqhf | else |
1632 | ca6e0f51 | gaqhf | { |
1633 | if (SPPIDUtil.CalcAngle(groupLine.SPPID.START_X, groupLine.SPPID.START_Y, groupLine.SPPID.END_X, groupLine.SPPID.END_Y) < 45) |
||
1634 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(x, -0.1 - index); |
1635 | ca6e0f51 | gaqhf | else |
1636 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1637 | ca6e0f51 | gaqhf | } |
1638 | a0e3dca4 | gaqhf | } |
1639 | 809a7640 | gaqhf | |
1640 | 5173ba5d | gaqhf | placeRunInputs.AddPoint(x, y); |
1641 | 809a7640 | gaqhf | |
1642 | 5173ba5d | gaqhf | if (groupLine.CONNECTORS.IndexOf(connector) == 1) |
1643 | { |
||
1644 | dec9ecfd | gaqhf | index += 0.01; |
1645 | 5173ba5d | gaqhf | if (groupLine.SlopeType == SlopeType.HORIZONTAL) |
1646 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(x, -0.1 - index); |
1647 | 5173ba5d | gaqhf | else if (groupLine.SlopeType == SlopeType.VERTICAL) |
1648 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1649 | 5173ba5d | gaqhf | else |
1650 | ca6e0f51 | gaqhf | { |
1651 | if (SPPIDUtil.CalcAngle(groupLine.SPPID.START_X, groupLine.SPPID.START_Y, groupLine.SPPID.END_X, groupLine.SPPID.END_Y) < 45) |
||
1652 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(x, -0.1 - index); |
1653 | ca6e0f51 | gaqhf | else |
1654 | dec9ecfd | gaqhf | placeRunInputs.AddPoint(-0.1 - index, y); |
1655 | ca6e0f51 | gaqhf | } |
1656 | a0e3dca4 | gaqhf | } |
1657 | 809a7640 | gaqhf | } |
1658 | } |
||
1659 | 5173ba5d | gaqhf | } |
1660 | 809a7640 | gaqhf | |
1661 | 5173ba5d | gaqhf | LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1662 | if (_lMConnector != null) |
||
1663 | { |
||
1664 | groupLine.SPPID.ModelItemId = _lMConnector.ModelItemID; |
||
1665 | bool bRemodelingStart = false; |
||
1666 | if (_LMSymbolStart != null) |
||
1667 | NeedReModeling(groupLine, _LMSymbolStart, ref bRemodelingStart); |
||
1668 | bool bRemodelingEnd = false; |
||
1669 | if (_LMSymbolEnd != null) |
||
1670 | NeedReModeling(groupLine, _LMSymbolEnd, ref bRemodelingEnd); |
||
1671 | |||
1672 | if (bRemodelingStart || bRemodelingEnd) |
||
1673 | ReModelingLine(groupLine, _lMConnector, _LMSymbolStart, _LMSymbolEnd, bRemodelingStart, bRemodelingEnd); |
||
1674 | 32205389 | gaqhf | |
1675 | FlowMarkModeling(groupLine); |
||
1676 | 8701de36 | gaqhf | LineNumberModelingOnlyOne(groupLine); |
1677 | 32205389 | gaqhf | |
1678 | 5173ba5d | gaqhf | ReleaseCOMObjects(_lMConnector); |
1679 | } |
||
1680 | dec9ecfd | gaqhf | else if (!isBranchModeling) |
1681 | { |
||
1682 | Log.Write("Main Line Modeling : " + groupLine.UID); |
||
1683 | } |
||
1684 | 809a7640 | gaqhf | |
1685 | 5173ba5d | gaqhf | List<object> removeLines = groupLine.CONNECTORS.FindAll(x => |
1686 | x.ConnectedObject != null && |
||
1687 | x.ConnectedObject.GetType() == typeof(Line) && |
||
1688 | !string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)) |
||
1689 | .Select(x => x.ConnectedObject) |
||
1690 | .ToList(); |
||
1691 | 2fdb56bf | gaqhf | |
1692 | 5173ba5d | gaqhf | foreach (var item in removeLines) |
1693 | RemoveLineForModeling(item as Line); |
||
1694 | 5e6ecf05 | gaqhf | |
1695 | 5173ba5d | gaqhf | if (_LMAItem != null) |
1696 | ReleaseCOMObjects(_LMAItem); |
||
1697 | if (placeRunInputs != null) |
||
1698 | ReleaseCOMObjects(placeRunInputs); |
||
1699 | if (_LMSymbolStart != null) |
||
1700 | ReleaseCOMObjects(_LMSymbolStart); |
||
1701 | if (_LMSymbolEnd != null) |
||
1702 | ReleaseCOMObjects(_LMSymbolEnd); |
||
1703 | 5e6ecf05 | gaqhf | |
1704 | f3e2693f | gaqhf | if (isBranchModeling && BranchLines.Contains(groupLine)) |
1705 | BranchLines.Remove(groupLine); |
||
1706 | a0e3dca4 | gaqhf | } |
1707 | } |
||
1708 | 5e6ecf05 | gaqhf | |
1709 | a0e3dca4 | gaqhf | private void RemoveLineForModeling(Line line) |
1710 | { |
||
1711 | LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
||
1712 | if (modelItem != null) |
||
1713 | { |
||
1714 | foreach (LMRepresentation rep in modelItem.Representations) |
||
1715 | { |
||
1716 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
1717 | 7f00b26c | gaqhf | { |
1718 | a0e3dca4 | gaqhf | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
1719 | 32205389 | gaqhf | dynamic OID = rep.get_GraphicOID().ToString(); |
1720 | a0e3dca4 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1721 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1722 | int verticesCount = lineStringGeometry.VertexCount; |
||
1723 | double[] vertices = null; |
||
1724 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
1725 | for (int i = 0; i < verticesCount; i++) |
||
1726 | 7f00b26c | gaqhf | { |
1727 | a0e3dca4 | gaqhf | double x = 0; |
1728 | double y = 0; |
||
1729 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
1730 | 6924abc6 | gaqhf | if (verticesCount == 2 && (x < 0 || y < 0)) |
1731 | a0e3dca4 | gaqhf | _placement.PIDRemovePlacement(rep); |
1732 | c2ec33f5 | gaqhf | } |
1733 | a0e3dca4 | gaqhf | ReleaseCOMObjects(_LMConnector); |
1734 | 5e6ecf05 | gaqhf | } |
1735 | a0e3dca4 | gaqhf | } |
1736 | 7f00b26c | gaqhf | |
1737 | a0e3dca4 | gaqhf | ReleaseCOMObjects(modelItem); |
1738 | } |
||
1739 | } |
||
1740 | |||
1741 | private void GetConnectedLineGroup(Line line, List<Line> group) |
||
1742 | { |
||
1743 | if (!group.Contains(line)) |
||
1744 | group.Add(line); |
||
1745 | foreach (var connector in line.CONNECTORS) |
||
1746 | { |
||
1747 | if (connector.ConnectedObject != null && |
||
1748 | connector.ConnectedObject.GetType() == typeof(Line) && |
||
1749 | !group.Contains(connector.ConnectedObject) && |
||
1750 | string.IsNullOrEmpty(((Line)connector.ConnectedObject).SPPID.ModelItemId)) |
||
1751 | { |
||
1752 | Line connLine = connector.ConnectedObject as Line; |
||
1753 | if (!SPPIDUtil.IsBranchLine(connLine, line)) |
||
1754 | 24515a3a | gaqhf | { |
1755 | if (line.CONNECTORS.IndexOf(connector) == 0) |
||
1756 | group.Insert(0, connLine); |
||
1757 | else |
||
1758 | group.Add(connLine); |
||
1759 | a0e3dca4 | gaqhf | GetConnectedLineGroup(connLine, group); |
1760 | 24515a3a | gaqhf | } |
1761 | 7f00b26c | gaqhf | } |
1762 | } |
||
1763 | a0e3dca4 | gaqhf | } |
1764 | 7f00b26c | gaqhf | |
1765 | a0e3dca4 | gaqhf | private void LineCoordinateCorrection(List<Line> group) |
1766 | { |
||
1767 | // 순서대로 전 Item 기준 정렬 |
||
1768 | LineCoordinateCorrectionByStart(group); |
||
1769 | |||
1770 | // 역으로 심볼이 있을 경우 좌표 보정 |
||
1771 | LineCoordinateCorrectionForLastLine(group); |
||
1772 | } |
||
1773 | |||
1774 | private void LineCoordinateCorrectionByStart(List<Line> group) |
||
1775 | { |
||
1776 | for (int i = 0; i < group.Count; i++) |
||
1777 | 7f00b26c | gaqhf | { |
1778 | a0e3dca4 | gaqhf | Line line = group[i]; |
1779 | if (i == 0) |
||
1780 | 7f00b26c | gaqhf | { |
1781 | a0e3dca4 | gaqhf | Connector symbolConnector = line.CONNECTORS.Find(x => x.ConnectedObject != null && x.ConnectedObject.GetType() == typeof(Symbol)); |
1782 | if (symbolConnector != null) |
||
1783 | LineCoordinateCorrectionByConnItem(line, symbolConnector.ConnectedObject); |
||
1784 | 7f00b26c | gaqhf | } |
1785 | a0e3dca4 | gaqhf | else if (i != 0) |
1786 | 7f00b26c | gaqhf | { |
1787 | a0e3dca4 | gaqhf | LineCoordinateCorrectionByConnItem(line, group[i - 1]); |
1788 | } |
||
1789 | } |
||
1790 | } |
||
1791 | b66a2996 | gaqhf | |
1792 | a0e3dca4 | gaqhf | private void LineCoordinateCorrectionForLastLine(List<Line> group) |
1793 | { |
||
1794 | Line checkLine = group[group.Count - 1]; |
||
1795 | Connector lastSymbolConnector = checkLine.CONNECTORS.Find(x => x.ConnectedObject != null && x.ConnectedObject.GetType() == typeof(Symbol)); |
||
1796 | if (lastSymbolConnector != null) |
||
1797 | { |
||
1798 | LineCoordinateCorrectionByConnItem(checkLine, lastSymbolConnector.ConnectedObject); |
||
1799 | for (int i = group.Count - 2; i >= 0; i--) |
||
1800 | { |
||
1801 | Line line = group[i + 1]; |
||
1802 | Line prevLine = group[i]; |
||
1803 | 0bbd73b5 | gaqhf | |
1804 | a0e3dca4 | gaqhf | // 같으면 보정 |
1805 | if (line.SlopeType == prevLine.SlopeType) |
||
1806 | LineCoordinateCorrectionByConnItem(prevLine, line); |
||
1807 | else |
||
1808 | c2ec33f5 | gaqhf | { |
1809 | a0e3dca4 | gaqhf | if (line.SlopeType == SlopeType.HORIZONTAL) |
1810 | d63050d6 | gaqhf | { |
1811 | a0e3dca4 | gaqhf | double prevX = 0; |
1812 | double prevY = 0; |
||
1813 | GetTargetLineConnectorPoint(prevLine.CONNECTORS.Find(z => z.ConnectedObject == line), prevLine, ref prevX, ref prevY); |
||
1814 | ChangeLineSPPIDCoordinateByConnectorOnlyX(line, prevLine, prevX); |
||
1815 | d63050d6 | gaqhf | |
1816 | a0e3dca4 | gaqhf | double x = 0; |
1817 | double y = 0; |
||
1818 | GetTargetLineConnectorPoint(line.CONNECTORS.Find(z => z.ConnectedObject == prevLine), line, ref x, ref y); |
||
1819 | ChangeLineSPPIDCoordinateByConnectorOnlyY(prevLine, line, y); |
||
1820 | d63050d6 | gaqhf | } |
1821 | a0e3dca4 | gaqhf | else if (line.SlopeType == SlopeType.VERTICAL) |
1822 | d63050d6 | gaqhf | { |
1823 | a0e3dca4 | gaqhf | double prevX = 0; |
1824 | double prevY = 0; |
||
1825 | GetTargetLineConnectorPoint(prevLine.CONNECTORS.Find(z => z.ConnectedObject == line), prevLine, ref prevX, ref prevY); |
||
1826 | ChangeLineSPPIDCoordinateByConnectorOnlyY(line, prevLine, prevY); |
||
1827 | d63050d6 | gaqhf | |
1828 | a0e3dca4 | gaqhf | double x = 0; |
1829 | double y = 0; |
||
1830 | GetTargetLineConnectorPoint(line.CONNECTORS.Find(z => z.ConnectedObject == prevLine), line, ref x, ref y); |
||
1831 | ChangeLineSPPIDCoordinateByConnectorOnlyX(prevLine, line, x); |
||
1832 | d63050d6 | gaqhf | } |
1833 | a0e3dca4 | gaqhf | break; |
1834 | c2ec33f5 | gaqhf | } |
1835 | 1ab9a205 | gaqhf | } |
1836 | c2ec33f5 | gaqhf | } |
1837 | a0e3dca4 | gaqhf | } |
1838 | 7f00b26c | gaqhf | |
1839 | a0e3dca4 | gaqhf | private void LineCoordinateCorrectionByConnItem(Line line, object connItem) |
1840 | { |
||
1841 | double x = 0; |
||
1842 | double y = 0; |
||
1843 | if (connItem.GetType() == typeof(Symbol)) |
||
1844 | { |
||
1845 | Symbol targetSymbol = connItem as Symbol; |
||
1846 | Connector targetConnector = targetSymbol.CONNECTORS.Find(z => z.ConnectedObject == line); |
||
1847 | if (targetConnector != null) |
||
1848 | GetTargetSymbolConnectorPoint(targetConnector, targetSymbol, ref x, ref y); |
||
1849 | else |
||
1850 | throw new Exception("Target symbol UID : " + targetSymbol.UID + "\r\nLine UID : " + line.UID); |
||
1851 | } |
||
1852 | else if (connItem.GetType() == typeof(Line)) |
||
1853 | c2ec33f5 | gaqhf | { |
1854 | a0e3dca4 | gaqhf | Line targetLine = connItem as Line; |
1855 | GetTargetLineConnectorPoint(targetLine.CONNECTORS.Find(z => z.ConnectedObject == line), targetLine, ref x, ref y); |
||
1856 | } |
||
1857 | 7f00b26c | gaqhf | |
1858 | a0e3dca4 | gaqhf | ChangeLineSPPIDCoordinateByConnector(line, connItem, x, y); |
1859 | } |
||
1860 | 7f00b26c | gaqhf | |
1861 | a0e3dca4 | gaqhf | private void ChangeLineSPPIDCoordinateByConnector(Line line, object connItem, double x, double y, bool changeOtherCoordinate = true) |
1862 | { |
||
1863 | Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem); |
||
1864 | int index = line.CONNECTORS.IndexOf(connector); |
||
1865 | if (index == 0) |
||
1866 | { |
||
1867 | line.SPPID.START_X = x; |
||
1868 | line.SPPID.START_Y = y; |
||
1869 | if (line.SlopeType == SlopeType.HORIZONTAL && changeOtherCoordinate) |
||
1870 | line.SPPID.END_Y = y; |
||
1871 | else if (line.SlopeType == SlopeType.VERTICAL && changeOtherCoordinate) |
||
1872 | line.SPPID.END_X = x; |
||
1873 | } |
||
1874 | else |
||
1875 | { |
||
1876 | line.SPPID.END_X = x; |
||
1877 | line.SPPID.END_Y = y; |
||
1878 | if (line.SlopeType == SlopeType.HORIZONTAL && changeOtherCoordinate) |
||
1879 | line.SPPID.START_Y = y; |
||
1880 | else if (line.SlopeType == SlopeType.VERTICAL && changeOtherCoordinate) |
||
1881 | line.SPPID.START_X = x; |
||
1882 | c2ec33f5 | gaqhf | } |
1883 | a0e3dca4 | gaqhf | } |
1884 | 7f00b26c | gaqhf | |
1885 | a0e3dca4 | gaqhf | private void ChangeLineSPPIDCoordinateByConnectorOnlyX(Line line, object connItem, double x) |
1886 | { |
||
1887 | Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem); |
||
1888 | int index = line.CONNECTORS.IndexOf(connector); |
||
1889 | if (index == 0) |
||
1890 | { |
||
1891 | line.SPPID.START_X = x; |
||
1892 | if (line.SlopeType == SlopeType.VERTICAL) |
||
1893 | line.SPPID.END_X = x; |
||
1894 | } |
||
1895 | else |
||
1896 | { |
||
1897 | line.SPPID.END_X = x; |
||
1898 | if (line.SlopeType == SlopeType.VERTICAL) |
||
1899 | line.SPPID.START_X = x; |
||
1900 | } |
||
1901 | } |
||
1902 | 7f00b26c | gaqhf | |
1903 | a0e3dca4 | gaqhf | private void ChangeLineSPPIDCoordinateByConnectorOnlyY(Line line, object connItem, double y) |
1904 | { |
||
1905 | Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem); |
||
1906 | int index = line.CONNECTORS.IndexOf(connector); |
||
1907 | if (index == 0) |
||
1908 | { |
||
1909 | line.SPPID.START_Y = y; |
||
1910 | if (line.SlopeType == SlopeType.HORIZONTAL) |
||
1911 | line.SPPID.END_Y = y; |
||
1912 | } |
||
1913 | else |
||
1914 | { |
||
1915 | line.SPPID.END_Y = y; |
||
1916 | if (line.SlopeType == SlopeType.HORIZONTAL) |
||
1917 | line.SPPID.START_Y = y; |
||
1918 | } |
||
1919 | 1b261371 | gaqhf | } |
1920 | |||
1921 | 0860c756 | gaqhf | private void NeedReModeling(Line line, LMSymbol symbol, ref bool result) |
1922 | ac82b020 | gaqhf | { |
1923 | 0860c756 | gaqhf | if (symbol != null) |
1924 | ac82b020 | gaqhf | { |
1925 | fb386b8c | gaqhf | string repID = symbol.AsLMRepresentation().Id; |
1926 | string symbolUID = SPPIDUtil.FindSymbolByRepresentationID(document, repID).UID; |
||
1927 | string lineUID = line.UID; |
||
1928 | ac82b020 | gaqhf | |
1929 | fb386b8c | gaqhf | SpecBreak startSpecBreak = document.SpecBreaks.Find(x => |
1930 | (x.DownStreamUID == symbolUID || x.UpStreamUID == symbolUID) && |
||
1931 | (x.DownStreamUID == lineUID || x.UpStreamUID == lineUID)); |
||
1932 | 71ba1ca3 | gaqhf | |
1933 | fb386b8c | gaqhf | EndBreak startEndBreak = document.EndBreaks.Find(x => |
1934 | (x.OWNER == symbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == symbolUID) && |
||
1935 | (x.OWNER == lineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == lineUID)); |
||
1936 | ac82b020 | gaqhf | |
1937 | fb386b8c | gaqhf | if (startSpecBreak != null || startEndBreak != null) |
1938 | result = true; |
||
1939 | ac82b020 | gaqhf | } |
1940 | } |
||
1941 | 7f00b26c | gaqhf | |
1942 | 74752074 | gaqhf | /// <summary> |
1943 | 1ab9a205 | gaqhf | /// Symbol에 붙을 경우 Line을 Remodeling 한다. |
1944 | /// </summary> |
||
1945 | /// <param name="lines"></param> |
||
1946 | /// <param name="prevLMConnector"></param> |
||
1947 | /// <param name="startSymbol"></param> |
||
1948 | /// <param name="endSymbol"></param> |
||
1949 | 5173ba5d | gaqhf | private void ReModelingLine(Line line, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol, bool bStart, bool bEnd) |
1950 | 1ab9a205 | gaqhf | { |
1951 | string symbolPath = string.Empty; |
||
1952 | #region get symbol path |
||
1953 | LMModelItem modelItem = dataSource.GetModelItem(prevLMConnector.ModelItemID); |
||
1954 | a31a512e | gaqhf | symbolPath = GetSPPIDFileName(modelItem); |
1955 | d77973b3 | gaqhf | ReleaseCOMObjects(modelItem); |
1956 | 1ab9a205 | gaqhf | #endregion |
1957 | 24b5276c | gaqhf | bool diagonal = false; |
1958 | if (line.SlopeType != SlopeType.HORIZONTAL && line.SlopeType != SlopeType.VERTICAL) |
||
1959 | diagonal = true; |
||
1960 | 1ab9a205 | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
1961 | LMConnector newConnector = null; |
||
1962 | 32205389 | gaqhf | dynamic OID = prevLMConnector.get_GraphicOID().ToString(); |
1963 | 1ab9a205 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1964 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
1965 | int verticesCount = lineStringGeometry.VertexCount; |
||
1966 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
1967 | 7f00b26c | gaqhf | |
1968 | 1ab9a205 | gaqhf | List<double[]> vertices = new List<double[]>(); |
1969 | for (int i = 1; i <= verticesCount; i++) |
||
1970 | { |
||
1971 | double x = 0; |
||
1972 | double y = 0; |
||
1973 | lineStringGeometry.GetVertex(i, ref x, ref y); |
||
1974 | vertices.Add(new double[] { x, y }); |
||
1975 | } |
||
1976 | |||
1977 | for (int i = 0; i < vertices.Count; i++) |
||
1978 | { |
||
1979 | double[] points = vertices[i]; |
||
1980 | // 시작 심볼이 있고 첫번째 좌표일 때 |
||
1981 | if (startSymbol != null && i == 0) |
||
1982 | { |
||
1983 | ac82b020 | gaqhf | if (bStart) |
1984 | { |
||
1985 | SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i + 1][0], vertices[i + 1][1]); |
||
1986 | if (slopeType == SlopeType.HORIZONTAL) |
||
1987 | placeRunInputs.AddPoint(points[0], -0.1); |
||
1988 | else if (slopeType == SlopeType.VERTICAL) |
||
1989 | placeRunInputs.AddPoint(-0.1, points[1]); |
||
1990 | else |
||
1991 | placeRunInputs.AddPoint(points[0], -0.1); |
||
1992 | 1ab9a205 | gaqhf | |
1993 | ac82b020 | gaqhf | placeRunInputs.AddPoint(points[0], points[1]); |
1994 | } |
||
1995 | else |
||
1996 | { |
||
1997 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(startSymbol, points[0], points[1], diagonal); |
1998 | ac82b020 | gaqhf | } |
1999 | 1ab9a205 | gaqhf | } |
2000 | // 마지막 심볼이 있고 마지막 좌표일 때 |
||
2001 | else if (endSymbol != null && i == vertices.Count - 1) |
||
2002 | { |
||
2003 | ac82b020 | gaqhf | if (bEnd) |
2004 | { |
||
2005 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2006 | 1ab9a205 | gaqhf | |
2007 | ac82b020 | gaqhf | SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i - 1][0], vertices[i - 1][1]); |
2008 | if (slopeType == SlopeType.HORIZONTAL) |
||
2009 | placeRunInputs.AddPoint(points[0], -0.1); |
||
2010 | else if (slopeType == SlopeType.VERTICAL) |
||
2011 | placeRunInputs.AddPoint(-0.1, points[1]); |
||
2012 | else |
||
2013 | placeRunInputs.AddPoint(points[0], -0.1); |
||
2014 | } |
||
2015 | 1ab9a205 | gaqhf | else |
2016 | ac82b020 | gaqhf | { |
2017 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(endSymbol, points[0], points[1], diagonal); |
2018 | ac82b020 | gaqhf | } |
2019 | 1ab9a205 | gaqhf | } |
2020 | // 첫번째이며 시작 심볼이 아니고 Connecotr일 경우 |
||
2021 | else if (i == 0 && prevLMConnector.ConnectItem1SymbolObject != null) |
||
2022 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem1SymbolObject, points[0], points[1], diagonal); |
2023 | 1ab9a205 | gaqhf | // 마지막이며 마지막 심볼이 아니고 Connecotr일 경우 |
2024 | else if (i == vertices.Count - 1 && prevLMConnector.ConnectItem2SymbolObject != null) |
||
2025 | 24b5276c | gaqhf | placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem2SymbolObject, points[0], points[1], diagonal); |
2026 | 1ab9a205 | gaqhf | else |
2027 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2028 | } |
||
2029 | |||
2030 | _placement.PIDRemovePlacement(prevLMConnector.AsLMRepresentation()); |
||
2031 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2032 | |||
2033 | ReleaseCOMObjects(placeRunInputs); |
||
2034 | ReleaseCOMObjects(_LMAItem); |
||
2035 | ReleaseCOMObjects(modelItem); |
||
2036 | |||
2037 | if (newConnector != null) |
||
2038 | { |
||
2039 | ac82b020 | gaqhf | if (startSymbol != null && bStart) |
2040 | 1ab9a205 | gaqhf | { |
2041 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
2042 | placeRunInputs = new PlaceRunInputs(); |
||
2043 | f1a7faf9 | gaqhf | placeRunInputs.AddSymbolTarget(startSymbol, vertices[0][0], vertices[0][1]); |
2044 | placeRunInputs.AddConnectorTarget(newConnector, vertices[0][0], vertices[0][1]); |
||
2045 | 1ab9a205 | gaqhf | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
2046 | if (_LMConnector != null) |
||
2047 | { |
||
2048 | RemoveConnectorForReModelingLine(newConnector); |
||
2049 | 87f02fc0 | gaqhf | ZeroLengthModelItemID.Add(_LMConnector.ModelItemID); |
2050 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2051 | } |
||
2052 | ReleaseCOMObjects(placeRunInputs); |
||
2053 | ReleaseCOMObjects(_LMAItem); |
||
2054 | } |
||
2055 | |||
2056 | ac82b020 | gaqhf | if (endSymbol != null && bEnd) |
2057 | 1ab9a205 | gaqhf | { |
2058 | if (startSymbol != null) |
||
2059 | { |
||
2060 | Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(newConnector.ModelItemID); |
||
2061 | newConnector = dicVertices.First().Key; |
||
2062 | } |
||
2063 | |||
2064 | _LMAItem = _placement.PIDCreateItem(symbolPath); |
||
2065 | placeRunInputs = new PlaceRunInputs(); |
||
2066 | f1a7faf9 | gaqhf | placeRunInputs.AddSymbolTarget(endSymbol, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1]); |
2067 | placeRunInputs.AddConnectorTarget(newConnector, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1]); |
||
2068 | 1ab9a205 | gaqhf | LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
2069 | if (_LMConnector != null) |
||
2070 | { |
||
2071 | RemoveConnectorForReModelingLine(newConnector); |
||
2072 | 1ff0105e | gaqhf | ZeroLengthModelItemIDReverse.Add(_LMConnector.ModelItemID); |
2073 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2074 | } |
||
2075 | ReleaseCOMObjects(placeRunInputs); |
||
2076 | ReleaseCOMObjects(_LMAItem); |
||
2077 | } |
||
2078 | |||
2079 | 5173ba5d | gaqhf | line.SPPID.ModelItemId = newConnector.ModelItemID; |
2080 | 1ab9a205 | gaqhf | ReleaseCOMObjects(newConnector); |
2081 | } |
||
2082 | |||
2083 | ReleaseCOMObjects(modelItem); |
||
2084 | } |
||
2085 | |||
2086 | /// <summary> |
||
2087 | /// Remodeling 과정에서 생긴 불필요한 Connector 제거 |
||
2088 | /// </summary> |
||
2089 | /// <param name="connector"></param> |
||
2090 | private void RemoveConnectorForReModelingLine(LMConnector connector) |
||
2091 | { |
||
2092 | Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(connector.ModelItemID); |
||
2093 | foreach (var item in dicVertices) |
||
2094 | { |
||
2095 | 1805d3b7 | gaqhf | if (item.Value.Count == 2) |
2096 | 1ab9a205 | gaqhf | { |
2097 | 1805d3b7 | gaqhf | bool result = false; |
2098 | foreach (var point in item.Value) |
||
2099 | 1ab9a205 | gaqhf | { |
2100 | 1805d3b7 | gaqhf | if (point[0] < 0 || point[1] < 0) |
2101 | { |
||
2102 | result = true; |
||
2103 | _placement.PIDRemovePlacement(item.Key.AsLMRepresentation()); |
||
2104 | break; |
||
2105 | } |
||
2106 | 1ab9a205 | gaqhf | } |
2107 | |||
2108 | 1805d3b7 | gaqhf | if (result) |
2109 | break; |
||
2110 | } |
||
2111 | 1ab9a205 | gaqhf | } |
2112 | foreach (var item in dicVertices) |
||
2113 | ReleaseCOMObjects(item.Key); |
||
2114 | } |
||
2115 | |||
2116 | /// <summary> |
||
2117 | 74752074 | gaqhf | /// Symbol이 모델링된 SPPPID Symbol Object를 반환 - 연결된 Symbol이 ChildSymbol일 수도 있기때문에 메서드 개발 |
2118 | /// </summary> |
||
2119 | /// <param name="symbol"></param> |
||
2120 | /// <param name="line"></param> |
||
2121 | /// <returns></returns> |
||
2122 | f2baa6a3 | gaqhf | private LMSymbol GetTargetSymbol(Symbol symbol, Line line) |
2123 | { |
||
2124 | LMSymbol _LMSymbol = null; |
||
2125 | foreach (var connector in symbol.CONNECTORS) |
||
2126 | { |
||
2127 | a0e3dca4 | gaqhf | if (connector.CONNECTEDITEM == line.UID) |
2128 | 6b298450 | gaqhf | { |
2129 | a0e3dca4 | gaqhf | if (connector.Index == 0) |
2130 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
2131 | else |
||
2132 | 0860c756 | gaqhf | { |
2133 | a0e3dca4 | gaqhf | ChildSymbol child = null; |
2134 | foreach (var childSymbol in symbol.ChildSymbols) |
||
2135 | 0860c756 | gaqhf | { |
2136 | a0e3dca4 | gaqhf | if (childSymbol.Connectors.Contains(connector)) |
2137 | child = childSymbol; |
||
2138 | else |
||
2139 | child = GetChildSymbolByConnector(childSymbol, connector); |
||
2140 | |||
2141 | if (child != null) |
||
2142 | 0860c756 | gaqhf | break; |
2143 | } |
||
2144 | |||
2145 | a0e3dca4 | gaqhf | if (child != null) |
2146 | _LMSymbol = dataSource.GetSymbol(child.SPPID.RepresentationId); |
||
2147 | 0860c756 | gaqhf | } |
2148 | |||
2149 | a0e3dca4 | gaqhf | break; |
2150 | 335b7a24 | gaqhf | } |
2151 | a0e3dca4 | gaqhf | } |
2152 | 335b7a24 | gaqhf | |
2153 | a0e3dca4 | gaqhf | return _LMSymbol; |
2154 | } |
||
2155 | |||
2156 | /// <summary> |
||
2157 | /// Connector를 가지고 있는 ChildSymbol Object 반환 |
||
2158 | /// </summary> |
||
2159 | /// <param name="item"></param> |
||
2160 | /// <param name="connector"></param> |
||
2161 | /// <returns></returns> |
||
2162 | private ChildSymbol GetChildSymbolByConnector(ChildSymbol item, Connector connector) |
||
2163 | { |
||
2164 | foreach (var childSymbol in item.ChildSymbols) |
||
2165 | { |
||
2166 | if (childSymbol.Connectors.Contains(connector)) |
||
2167 | return childSymbol; |
||
2168 | else |
||
2169 | return GetChildSymbolByConnector(childSymbol, connector); |
||
2170 | 335b7a24 | gaqhf | } |
2171 | |||
2172 | a0e3dca4 | gaqhf | return null; |
2173 | 335b7a24 | gaqhf | } |
2174 | |||
2175 | 74752074 | gaqhf | /// <summary> |
2176 | /// EndBreak 모델링 메서드 |
||
2177 | /// </summary> |
||
2178 | /// <param name="endBreak"></param> |
||
2179 | 3165c259 | gaqhf | private void EndBreakModeling(EndBreak endBreak) |
2180 | 335b7a24 | gaqhf | { |
2181 | 10c7195c | gaqhf | object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
2182 | 1ab9a205 | gaqhf | object connectedItem = SPPIDUtil.FindObjectByUID(document, endBreak.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE); |
2183 | LMConnector targetLMConnector = FindBreakLineTarget(ownerObj, connectedItem); |
||
2184 | 3165c259 | gaqhf | |
2185 | 1ab9a205 | gaqhf | if (targetLMConnector != null) |
2186 | 10c7195c | gaqhf | { |
2187 | 1ab9a205 | gaqhf | Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
2188 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
2189 | 5173ba5d | gaqhf | if (_LmLabelPersist != null) |
2190 | { |
||
2191 | endBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id; |
||
2192 | d23fe61b | gaqhf | if (_LmLabelPersist.ModelItemObject != null) |
2193 | endBreak.SPPID.ModelItemID = _LmLabelPersist.ModelItemID; |
||
2194 | 32205389 | gaqhf | endBreak.SPPID.GraphicOID = _LmLabelPersist.get_GraphicOID().ToString(); |
2195 | 5173ba5d | gaqhf | ReleaseCOMObjects(_LmLabelPersist); |
2196 | } |
||
2197 | ReleaseCOMObjects(targetLMConnector); |
||
2198 | 2a4872ec | gaqhf | } |
2199 | } |
||
2200 | b9e9f4c8 | gaqhf | |
2201 | d77973b3 | gaqhf | private LMConnector ReModelingLMConnector(LMConnector connector, string changeSymbolPath = null) |
2202 | 02480ac1 | gaqhf | { |
2203 | de97eaaa | gaqhf | string symbolPath = string.Empty; |
2204 | #region get symbol path |
||
2205 | d77973b3 | gaqhf | if (string.IsNullOrEmpty(changeSymbolPath)) |
2206 | { |
||
2207 | LMModelItem modelItem = dataSource.GetModelItem(connector.ModelItemID); |
||
2208 | symbolPath = GetSPPIDFileName(modelItem); |
||
2209 | ReleaseCOMObjects(modelItem); |
||
2210 | } |
||
2211 | else |
||
2212 | symbolPath = changeSymbolPath; |
||
2213 | |||
2214 | de97eaaa | gaqhf | #endregion |
2215 | |||
2216 | 02480ac1 | gaqhf | LMConnector newConnector = null; |
2217 | 32205389 | gaqhf | dynamic OID = connector.get_GraphicOID().ToString(); |
2218 | 02480ac1 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
2219 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
2220 | int verticesCount = lineStringGeometry.VertexCount; |
||
2221 | PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
||
2222 | de97eaaa | gaqhf | _LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
2223 | 02480ac1 | gaqhf | |
2224 | if (Convert.ToBoolean(connector.get_IsZeroLength())) |
||
2225 | { |
||
2226 | double[] vertices = null; |
||
2227 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
2228 | double x = 0; |
||
2229 | double y = 0; |
||
2230 | lineStringGeometry.GetVertex(1, ref x, ref y); |
||
2231 | |||
2232 | 32205389 | gaqhf | string flowDirection = string.Empty; |
2233 | LMAAttribute flowAttribute = connector.ModelItemObject.Attributes["FlowDirection"]; |
||
2234 | if (flowAttribute != null && !DBNull.Value.Equals(flowAttribute.get_Value())) |
||
2235 | flowDirection = flowAttribute.get_Value().ToString(); |
||
2236 | |||
2237 | 3fdf052a | gaqhf | if (flowDirection == "End 1 is downstream (Outlet)") |
2238 | { |
||
2239 | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, x, y); |
||
2240 | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, x, y); |
||
2241 | flowDirection = "End 1 is upstream (Inlet)"; |
||
2242 | } |
||
2243 | else |
||
2244 | { |
||
2245 | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, x, y); |
||
2246 | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, x, y); |
||
2247 | } |
||
2248 | |||
2249 | 02480ac1 | gaqhf | _placement.PIDRemovePlacement(connector.AsLMRepresentation()); |
2250 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2251 | 644f40b3 | gaqhf | ZeroLengthSymbolToSymbolModelItemID.Add(newConnector.ModelItemID); |
2252 | 32205389 | gaqhf | if (!string.IsNullOrEmpty(flowDirection)) |
2253 | newConnector.ModelItemObject.Attributes["FlowDirection"].set_Value(flowDirection); |
||
2254 | 02480ac1 | gaqhf | } |
2255 | else |
||
2256 | { |
||
2257 | List<double[]> vertices = new List<double[]>(); |
||
2258 | for (int i = 1; i <= verticesCount; i++) |
||
2259 | { |
||
2260 | double x = 0; |
||
2261 | double y = 0; |
||
2262 | lineStringGeometry.GetVertex(i, ref x, ref y); |
||
2263 | vertices.Add(new double[] { x, y }); |
||
2264 | } |
||
2265 | |||
2266 | for (int i = 0; i < vertices.Count; i++) |
||
2267 | { |
||
2268 | double[] points = vertices[i]; |
||
2269 | if (i == 0) |
||
2270 | { |
||
2271 | if (connector.ConnectItem1SymbolObject != null) |
||
2272 | f1a7faf9 | gaqhf | placeRunInputs.AddSymbolTarget(connector.ConnectItem1SymbolObject, points[0], points[1]); |
2273 | 02480ac1 | gaqhf | else |
2274 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2275 | } |
||
2276 | else if (i == vertices.Count - 1) |
||
2277 | { |
||
2278 | if (connector.ConnectItem2SymbolObject != null) |
||
2279 | f1a7faf9 | gaqhf | placeRunInputs.AddSymbolTarget(connector.ConnectItem2SymbolObject, points[0], points[1]); |
2280 | 02480ac1 | gaqhf | else |
2281 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2282 | } |
||
2283 | else |
||
2284 | placeRunInputs.AddPoint(points[0], points[1]); |
||
2285 | } |
||
2286 | |||
2287 | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, connector.ModelItemID); |
||
2288 | |||
2289 | _placement.PIDRemovePlacement(connector.AsLMRepresentation()); |
||
2290 | newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
||
2291 | |||
2292 | foreach (var line in lines) |
||
2293 | line.SPPID.ModelItemId = newConnector.ModelItemID; |
||
2294 | } |
||
2295 | |||
2296 | |||
2297 | return newConnector; |
||
2298 | } |
||
2299 | |||
2300 | 74752074 | gaqhf | /// <summary> |
2301 | 53c81765 | gaqhf | /// SpecBreak Modeling 메서드 |
2302 | /// </summary> |
||
2303 | /// <param name="specBreak"></param> |
||
2304 | private void SpecBreakModeling(SpecBreak specBreak) |
||
2305 | { |
||
2306 | object upStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.UpStreamUID); |
||
2307 | object downStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.DownStreamUID); |
||
2308 | |||
2309 | if (upStreamObj != null && |
||
2310 | downStreamObj != null) |
||
2311 | { |
||
2312 | 1ab9a205 | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
2313 | |||
2314 | if (targetLMConnector != null) |
||
2315 | 53c81765 | gaqhf | { |
2316 | 16584d30 | gaqhf | foreach (var attribute in specBreak.ATTRIBUTES) |
2317 | 53c81765 | gaqhf | { |
2318 | 16584d30 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID); |
2319 | if (mapping != null && !string.IsNullOrEmpty(mapping.SPPIDSYMBOLNAME) && mapping.SPPIDSYMBOLNAME != "None") |
||
2320 | { |
||
2321 | string MappingPath = mapping.SPPIDSYMBOLNAME; |
||
2322 | Array array = new double[] { 0, specBreak.SPPID.ORIGINAL_X, specBreak.SPPID.ORIGINAL_Y }; |
||
2323 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, Rotation: specBreak.ANGLE, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
||
2324 | 53c81765 | gaqhf | |
2325 | 16584d30 | gaqhf | if (_LmLabelPersist != null) |
2326 | { |
||
2327 | 5173ba5d | gaqhf | specBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id; |
2328 | d23fe61b | gaqhf | if (_LmLabelPersist.ModelItemObject != null) |
2329 | specBreak.SPPID.ModelItemID = _LmLabelPersist.ModelItemID; |
||
2330 | 32205389 | gaqhf | specBreak.SPPID.GraphicOID = _LmLabelPersist.get_GraphicOID().ToString(); |
2331 | 16584d30 | gaqhf | ReleaseCOMObjects(_LmLabelPersist); |
2332 | } |
||
2333 | } |
||
2334 | } |
||
2335 | 1ab9a205 | gaqhf | ReleaseCOMObjects(targetLMConnector); |
2336 | } |
||
2337 | } |
||
2338 | } |
||
2339 | 53c81765 | gaqhf | |
2340 | 1ab9a205 | gaqhf | private LMConnector FindBreakLineTarget(object targetObj, object connectedObj) |
2341 | { |
||
2342 | LMConnector targetConnector = null; |
||
2343 | Symbol targetSymbol = targetObj as Symbol; |
||
2344 | Symbol connectedSymbol = connectedObj as Symbol; |
||
2345 | Line targetLine = targetObj as Line; |
||
2346 | Line connectedLine = connectedObj as Line; |
||
2347 | if (targetSymbol != null && connectedSymbol != null) |
||
2348 | { |
||
2349 | LMSymbol targetLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
2350 | LMSymbol connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
||
2351 | |||
2352 | foreach (LMConnector connector in targetLMSymbol.Avoid1Connectors) |
||
2353 | { |
||
2354 | if (connector.get_ItemStatus() != "Active") |
||
2355 | continue; |
||
2356 | |||
2357 | if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
||
2358 | { |
||
2359 | targetConnector = connector; |
||
2360 | break; |
||
2361 | } |
||
2362 | else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
||
2363 | { |
||
2364 | targetConnector = connector; |
||
2365 | break; |
||
2366 | 53c81765 | gaqhf | } |
2367 | } |
||
2368 | 1ab9a205 | gaqhf | |
2369 | foreach (LMConnector connector in targetLMSymbol.Avoid2Connectors) |
||
2370 | 53c81765 | gaqhf | { |
2371 | 1ab9a205 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2372 | continue; |
||
2373 | 53c81765 | gaqhf | |
2374 | 1ab9a205 | gaqhf | if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
2375 | { |
||
2376 | targetConnector = connector; |
||
2377 | break; |
||
2378 | } |
||
2379 | else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
||
2380 | { |
||
2381 | targetConnector = connector; |
||
2382 | break; |
||
2383 | 53c81765 | gaqhf | } |
2384 | } |
||
2385 | 1ab9a205 | gaqhf | |
2386 | ReleaseCOMObjects(targetLMSymbol); |
||
2387 | ReleaseCOMObjects(connectedLMSymbol); |
||
2388 | } |
||
2389 | else if (targetLine != null && connectedLine != null) |
||
2390 | { |
||
2391 | LMModelItem targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
||
2392 | LMModelItem connectedModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
||
2393 | |||
2394 | d77973b3 | gaqhf | if (targetModelItem != null && targetModelItem.get_ItemStatus() == "Active" && connectedModelItem != null && connectedModelItem.get_ItemStatus() == "Active") |
2395 | 53c81765 | gaqhf | { |
2396 | 1ab9a205 | gaqhf | foreach (LMRepresentation rep in targetModelItem.Representations) |
2397 | 53c81765 | gaqhf | { |
2398 | 1ab9a205 | gaqhf | if (targetConnector != null) |
2399 | break; |
||
2400 | 53c81765 | gaqhf | |
2401 | 1ab9a205 | gaqhf | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
2402 | 53c81765 | gaqhf | { |
2403 | 1ab9a205 | gaqhf | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
2404 | |||
2405 | if (IsConnected(_LMConnector, connectedModelItem)) |
||
2406 | targetConnector = _LMConnector; |
||
2407 | else |
||
2408 | ReleaseCOMObjects(_LMConnector); |
||
2409 | 53c81765 | gaqhf | } |
2410 | } |
||
2411 | 1ab9a205 | gaqhf | |
2412 | ReleaseCOMObjects(targetModelItem); |
||
2413 | 53c81765 | gaqhf | } |
2414 | 1ab9a205 | gaqhf | } |
2415 | else |
||
2416 | { |
||
2417 | 340515a2 | gaqhf | LMSymbol connectedLMSymbol = null; |
2418 | if (connectedSymbol != null) |
||
2419 | connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
||
2420 | else if (targetSymbol != null) |
||
2421 | connectedLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
||
2422 | else |
||
2423 | { |
||
2424 | |||
2425 | } |
||
2426 | LMModelItem targetModelItem = null; |
||
2427 | if (targetLine != null) |
||
2428 | targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
||
2429 | else if (connectedLine != null) |
||
2430 | targetModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
||
2431 | else |
||
2432 | { |
||
2433 | |||
2434 | } |
||
2435 | 1ab9a205 | gaqhf | if (connectedLMSymbol != null && targetModelItem != null) |
2436 | 53c81765 | gaqhf | { |
2437 | 1ab9a205 | gaqhf | foreach (LMConnector connector in connectedLMSymbol.Avoid1Connectors) |
2438 | { |
||
2439 | ac82b020 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2440 | continue; |
||
2441 | |||
2442 | 1ab9a205 | gaqhf | if (IsConnected(connector, targetModelItem)) |
2443 | { |
||
2444 | targetConnector = connector; |
||
2445 | break; |
||
2446 | } |
||
2447 | } |
||
2448 | 53c81765 | gaqhf | |
2449 | 1ab9a205 | gaqhf | if (targetConnector == null) |
2450 | 53c81765 | gaqhf | { |
2451 | 1ab9a205 | gaqhf | foreach (LMConnector connector in connectedLMSymbol.Avoid2Connectors) |
2452 | 53c81765 | gaqhf | { |
2453 | ac82b020 | gaqhf | if (connector.get_ItemStatus() != "Active") |
2454 | continue; |
||
2455 | |||
2456 | 1ab9a205 | gaqhf | if (IsConnected(connector, targetModelItem)) |
2457 | 53c81765 | gaqhf | { |
2458 | 1ab9a205 | gaqhf | targetConnector = connector; |
2459 | break; |
||
2460 | 53c81765 | gaqhf | } |
2461 | } |
||
2462 | } |
||
2463 | } |
||
2464 | |||
2465 | 1ab9a205 | gaqhf | } |
2466 | 02480ac1 | gaqhf | |
2467 | 1ab9a205 | gaqhf | return targetConnector; |
2468 | } |
||
2469 | 53c81765 | gaqhf | |
2470 | 1ab9a205 | gaqhf | private bool IsConnected(LMConnector connector, LMModelItem modelItem) |
2471 | { |
||
2472 | bool result = false; |
||
2473 | |||
2474 | foreach (LMRepresentation rep in modelItem.Representations) |
||
2475 | { |
||
2476 | if (result) |
||
2477 | break; |
||
2478 | |||
2479 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2480 | { |
||
2481 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2482 | |||
2483 | if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2484 | connector.ConnectItem1SymbolObject != null && |
||
2485 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2486 | 53c81765 | gaqhf | { |
2487 | 1ab9a205 | gaqhf | result = true; |
2488 | ReleaseCOMObjects(_LMConnector); |
||
2489 | break; |
||
2490 | } |
||
2491 | else if (_LMConnector.ConnectItem1SymbolObject != null && |
||
2492 | connector.ConnectItem2SymbolObject != null && |
||
2493 | _LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2494 | { |
||
2495 | result = true; |
||
2496 | ReleaseCOMObjects(_LMConnector); |
||
2497 | break; |
||
2498 | } |
||
2499 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2500 | connector.ConnectItem1SymbolObject != null && |
||
2501 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
||
2502 | { |
||
2503 | result = true; |
||
2504 | ReleaseCOMObjects(_LMConnector); |
||
2505 | break; |
||
2506 | } |
||
2507 | else if (_LMConnector.ConnectItem2SymbolObject != null && |
||
2508 | connector.ConnectItem2SymbolObject != null && |
||
2509 | _LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
||
2510 | { |
||
2511 | result = true; |
||
2512 | ReleaseCOMObjects(_LMConnector); |
||
2513 | break; |
||
2514 | 53c81765 | gaqhf | } |
2515 | |||
2516 | 1ab9a205 | gaqhf | ReleaseCOMObjects(_LMConnector); |
2517 | } |
||
2518 | 53c81765 | gaqhf | } |
2519 | 1ab9a205 | gaqhf | |
2520 | |||
2521 | return result; |
||
2522 | 53c81765 | gaqhf | } |
2523 | |||
2524 | /// <summary> |
||
2525 | 74752074 | gaqhf | /// FromModelItem을 ToModelItem으로 PipeRunJoin하는 메서드 |
2526 | /// </summary> |
||
2527 | 644f40b3 | gaqhf | /// <param name="modelItemID1"></param> |
2528 | /// <param name="modelItemID2"></param> |
||
2529 | a31a512e | gaqhf | private void JoinRun(string modelId1, string modelId2, ref string survivorId) |
2530 | 335b7a24 | gaqhf | { |
2531 | ca6e0f51 | gaqhf | try |
2532 | 644f40b3 | gaqhf | { |
2533 | a31a512e | gaqhf | LMModelItem modelItem1 = dataSource.GetModelItem(modelId1); |
2534 | ca6e0f51 | gaqhf | _LMAItem item1 = modelItem1.AsLMAItem(); |
2535 | a31a512e | gaqhf | LMModelItem modelItem2 = dataSource.GetModelItem(modelId2); |
2536 | ca6e0f51 | gaqhf | _LMAItem item2 = modelItem2.AsLMAItem(); |
2537 | 644f40b3 | gaqhf | |
2538 | ca6e0f51 | gaqhf | // item2가 item1으로 조인 |
2539 | _placement.PIDJoinRuns(ref item1, ref item2); |
||
2540 | item1.Commit(); |
||
2541 | item2.Commit(); |
||
2542 | 7f00b26c | gaqhf | |
2543 | ca6e0f51 | gaqhf | string beforeID = string.Empty; |
2544 | string afterID = string.Empty; |
||
2545 | 335b7a24 | gaqhf | |
2546 | ca6e0f51 | gaqhf | if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() != "Active") |
2547 | { |
||
2548 | beforeID = modelItem2.Id; |
||
2549 | afterID = modelItem1.Id; |
||
2550 | a31a512e | gaqhf | survivorId = afterID; |
2551 | ca6e0f51 | gaqhf | } |
2552 | else if (modelItem1.get_ItemStatus() != "Active" && modelItem2.get_ItemStatus() == "Active") |
||
2553 | { |
||
2554 | beforeID = modelItem1.Id; |
||
2555 | afterID = modelItem2.Id; |
||
2556 | a31a512e | gaqhf | survivorId = afterID; |
2557 | ca6e0f51 | gaqhf | } |
2558 | a31a512e | gaqhf | else if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() == "Active") |
2559 | survivorId = null; |
||
2560 | ca6e0f51 | gaqhf | else |
2561 | { |
||
2562 | a31a512e | gaqhf | Log.Write("잘못된 경우"); |
2563 | survivorId = null; |
||
2564 | ca6e0f51 | gaqhf | } |
2565 | 87f02fc0 | gaqhf | |
2566 | a31a512e | gaqhf | |
2567 | ca6e0f51 | gaqhf | if (!string.IsNullOrEmpty(beforeID) && !string.IsNullOrEmpty(afterID)) |
2568 | 7f00b26c | gaqhf | { |
2569 | ca6e0f51 | gaqhf | List<Line> lines = SPPIDUtil.FindLinesByModelId(document, beforeID); |
2570 | 7f00b26c | gaqhf | foreach (var line in lines) |
2571 | ca6e0f51 | gaqhf | line.SPPID.ModelItemId = afterID; |
2572 | 65a1ed4b | gaqhf | } |
2573 | 7f00b26c | gaqhf | |
2574 | ca6e0f51 | gaqhf | ReleaseCOMObjects(modelItem1); |
2575 | ReleaseCOMObjects(item1); |
||
2576 | ReleaseCOMObjects(modelItem2); |
||
2577 | ReleaseCOMObjects(item2); |
||
2578 | } |
||
2579 | catch (Exception ex) |
||
2580 | 335b7a24 | gaqhf | { |
2581 | ca6e0f51 | gaqhf | Log.Write("Join Error"); |
2582 | Log.Write(ex.Message); |
||
2583 | 335b7a24 | gaqhf | } |
2584 | } |
||
2585 | |||
2586 | a31a512e | gaqhf | private List<string> FindOtherModelItemBySymbolWhereTypePipeRun(LMSymbol symbol, string modelId) |
2587 | { |
||
2588 | List<string> modelItemIDs = new List<string>(); |
||
2589 | 48fd75e2 | gaqhf | foreach (LMConnector connector in symbol.Avoid1Connectors) |
2590 | a31a512e | gaqhf | { |
2591 | LMModelItem modelItem = connector.ModelItemObject; |
||
2592 | if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId) |
||
2593 | modelItemIDs.Add(modelItem.Id); |
||
2594 | ReleaseCOMObjects(modelItem); |
||
2595 | ReleaseCOMObjects(connector); |
||
2596 | } |
||
2597 | |||
2598 | 48fd75e2 | gaqhf | foreach (LMConnector connector in symbol.Avoid2Connectors) |
2599 | a31a512e | gaqhf | { |
2600 | LMModelItem modelItem = connector.ModelItemObject; |
||
2601 | if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId) |
||
2602 | modelItemIDs.Add(modelItem.Id); |
||
2603 | ReleaseCOMObjects(modelItem); |
||
2604 | ReleaseCOMObjects(connector); |
||
2605 | } |
||
2606 | |||
2607 | 48fd75e2 | gaqhf | |
2608 | 82d6e5ea | gaqhf | List<string> result = new List<string>(); |
2609 | modelItemIDs = modelItemIDs.Distinct().ToList(); |
||
2610 | string originalName = GetSPPIDFileName(modelId); |
||
2611 | foreach (var item in modelItemIDs) |
||
2612 | { |
||
2613 | string fileName = GetSPPIDFileName(item); |
||
2614 | if (originalName == fileName) |
||
2615 | result.Add(item); |
||
2616 | else |
||
2617 | { |
||
2618 | LMConnector connector = GetLMConnectorOnlyOne(item); |
||
2619 | if (connector != null && Convert.ToBoolean(connector.get_IsZeroLength())) |
||
2620 | { |
||
2621 | result.Add(item); |
||
2622 | ReleaseCOMObjects(connector); |
||
2623 | } |
||
2624 | } |
||
2625 | } |
||
2626 | |||
2627 | return result; |
||
2628 | a31a512e | gaqhf | } |
2629 | |||
2630 | 74752074 | gaqhf | /// <summary> |
2631 | /// PipeRun의 좌표를 가져오는 메서드 |
||
2632 | /// </summary> |
||
2633 | /// <param name="modelId"></param> |
||
2634 | /// <returns></returns> |
||
2635 | 5e6ecf05 | gaqhf | private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId) |
2636 | { |
||
2637 | Dictionary<LMConnector, List<double[]>> connectorVertices = new Dictionary<LMConnector, List<double[]>>(); |
||
2638 | 310aeb31 | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelId); |
2639 | |||
2640 | if (modelItem != null) |
||
2641 | 5e6ecf05 | gaqhf | { |
2642 | 310aeb31 | gaqhf | foreach (LMRepresentation rep in modelItem.Representations) |
2643 | 5e6ecf05 | gaqhf | { |
2644 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
2645 | { |
||
2646 | LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
||
2647 | connectorVertices.Add(_LMConnector, new List<double[]>()); |
||
2648 | 32205389 | gaqhf | dynamic OID = rep.get_GraphicOID().ToString(); |
2649 | 335b7a24 | gaqhf | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
2650 | 5e6ecf05 | gaqhf | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
2651 | int verticesCount = lineStringGeometry.VertexCount; |
||
2652 | double[] vertices = null; |
||
2653 | lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
||
2654 | for (int i = 0; i < verticesCount; i++) |
||
2655 | { |
||
2656 | double x = 0; |
||
2657 | double y = 0; |
||
2658 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
2659 | 32205389 | gaqhf | connectorVertices[_LMConnector].Add(new double[] { x, y }); |
2660 | 5e6ecf05 | gaqhf | } |
2661 | } |
||
2662 | } |
||
2663 | |||
2664 | 310aeb31 | gaqhf | ReleaseCOMObjects(modelItem); |
2665 | 5e6ecf05 | gaqhf | } |
2666 | |||
2667 | return connectorVertices; |
||
2668 | } |
||
2669 | |||
2670 | 32205389 | gaqhf | private List<double[]> GetConnectorVertices(LMConnector connector) |
2671 | { |
||
2672 | List<double[]> vertices = new List<double[]>(); |
||
2673 | dynamic OID = connector.get_GraphicOID().ToString(); |
||
2674 | DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
||
2675 | Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
||
2676 | int verticesCount = lineStringGeometry.VertexCount; |
||
2677 | double[] value = null; |
||
2678 | lineStringGeometry.GetVertices(ref verticesCount, ref value); |
||
2679 | for (int i = 0; i < verticesCount; i++) |
||
2680 | { |
||
2681 | double x = 0; |
||
2682 | double y = 0; |
||
2683 | lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
||
2684 | vertices.Add(new double[] { x, y }); |
||
2685 | } |
||
2686 | return vertices; |
||
2687 | } |
||
2688 | |||
2689 | 7c7bcd10 | gaqhf | /// <summary> |
2690 | a0e3dca4 | gaqhf | /// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 조건에 안맞아서 못찾을시 제일 가까운 점으로 가져오는 방식 |
2691 | 74752074 | gaqhf | /// </summary> |
2692 | /// <param name="connectorVertices"></param> |
||
2693 | /// <param name="connX"></param> |
||
2694 | /// <param name="connY"></param> |
||
2695 | /// <returns></returns> |
||
2696 | a0e3dca4 | gaqhf | private LMConnector FindTargetLMConnectorForLabel(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
2697 | 5e6ecf05 | gaqhf | { |
2698 | double length = double.MaxValue; |
||
2699 | LMConnector targetConnector = null; |
||
2700 | foreach (var item in connectorVertices) |
||
2701 | { |
||
2702 | List<double[]> points = item.Value; |
||
2703 | for (int i = 0; i < points.Count - 1; i++) |
||
2704 | { |
||
2705 | double[] point1 = points[i]; |
||
2706 | double[] point2 = points[i + 1]; |
||
2707 | a0e3dca4 | gaqhf | double x1 = Math.Min(point1[0], point2[0]); |
2708 | double y1 = Math.Min(point1[1], point2[1]); |
||
2709 | double x2 = Math.Max(point1[0], point2[0]); |
||
2710 | double y2 = Math.Max(point1[1], point2[1]); |
||
2711 | 5e6ecf05 | gaqhf | |
2712 | a0e3dca4 | gaqhf | if ((x1 <= connX && x2 >= connX) || |
2713 | (y1 <= connY && y2 >= connY)) |
||
2714 | 5e6ecf05 | gaqhf | { |
2715 | a0e3dca4 | gaqhf | double distance = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], connX, connY); |
2716 | 335b7a24 | gaqhf | if (length >= distance) |
2717 | 30a9ffce | gaqhf | { |
2718 | a0e3dca4 | gaqhf | targetConnector = item.Key; |
2719 | length = distance; |
||
2720 | } |
||
2721 | |||
2722 | distance = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], connX, connY); |
||
2723 | if (length >= distance) |
||
2724 | { |
||
2725 | targetConnector = item.Key; |
||
2726 | length = distance; |
||
2727 | 30a9ffce | gaqhf | } |
2728 | 5e6ecf05 | gaqhf | } |
2729 | } |
||
2730 | c3d2e266 | gaqhf | } |
2731 | |||
2732 | a0e3dca4 | gaqhf | // 못찾았을때. |
2733 | length = double.MaxValue; |
||
2734 | c3d2e266 | gaqhf | if (targetConnector == null) |
2735 | { |
||
2736 | foreach (var item in connectorVertices) |
||
2737 | { |
||
2738 | List<double[]> points = item.Value; |
||
2739 | a0e3dca4 | gaqhf | |
2740 | foreach (double[] point in points) |
||
2741 | c3d2e266 | gaqhf | { |
2742 | a0e3dca4 | gaqhf | double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
2743 | c3d2e266 | gaqhf | if (length >= distance) |
2744 | { |
||
2745 | targetConnector = item.Key; |
||
2746 | length = distance; |
||
2747 | } |
||
2748 | } |
||
2749 | } |
||
2750 | 5e6ecf05 | gaqhf | } |
2751 | |||
2752 | return targetConnector; |
||
2753 | } |
||
2754 | |||
2755 | a0e3dca4 | gaqhf | private LMConnector FindTargetLMConnectorForBranch(Line line, Line targetLine, ref double x, ref double y) |
2756 | ac78b508 | gaqhf | { |
2757 | a0e3dca4 | gaqhf | Dictionary<LMConnector, List<double[]>> vertices = GetPipeRunVertices(targetLine.SPPID.ModelItemId); |
2758 | 0ff6e67f | gaqhf | if (vertices.Count == 0) |
2759 | return null; |
||
2760 | a0e3dca4 | gaqhf | |
2761 | ac78b508 | gaqhf | double length = double.MaxValue; |
2762 | LMConnector targetConnector = null; |
||
2763 | a0e3dca4 | gaqhf | double[] resultPoint = null; |
2764 | List<double[]> targetVertices = null; |
||
2765 | |||
2766 | // Vertices 포인트에 제일 가까운곳 |
||
2767 | foreach (var item in vertices) |
||
2768 | ac78b508 | gaqhf | { |
2769 | List<double[]> points = item.Value; |
||
2770 | a0e3dca4 | gaqhf | for (int i = 0; i < points.Count; i++) |
2771 | ac78b508 | gaqhf | { |
2772 | a0e3dca4 | gaqhf | double[] point = points[i]; |
2773 | double tempX = point[0]; |
||
2774 | double tempY = point[1]; |
||
2775 | |||
2776 | double distance = SPPIDUtil.CalcPointToPointdDistance(tempX, tempY, x, y); |
||
2777 | ac78b508 | gaqhf | if (length >= distance) |
2778 | { |
||
2779 | targetConnector = item.Key; |
||
2780 | length = distance; |
||
2781 | a0e3dca4 | gaqhf | resultPoint = point; |
2782 | targetVertices = item.Value; |
||
2783 | ac78b508 | gaqhf | } |
2784 | } |
||
2785 | } |
||
2786 | |||
2787 | a0e3dca4 | gaqhf | // Vertices Cross에 제일 가까운곳 |
2788 | foreach (var item in vertices) |
||
2789 | 68464385 | gaqhf | { |
2790 | List<double[]> points = item.Value; |
||
2791 | for (int i = 0; i < points.Count - 1; i++) |
||
2792 | { |
||
2793 | double[] point1 = points[i]; |
||
2794 | double[] point2 = points[i + 1]; |
||
2795 | |||
2796 | a0e3dca4 | gaqhf | double maxLineX = Math.Max(point1[0], point2[0]); |
2797 | double minLineX = Math.Min(point1[0], point2[0]); |
||
2798 | double maxLineY = Math.Max(point1[1], point2[1]); |
||
2799 | double minLineY = Math.Min(point1[1], point2[1]); |
||
2800 | 68464385 | gaqhf | |
2801 | a0e3dca4 | gaqhf | SlopeType slope = SPPIDUtil.CalcSlope(minLineX, minLineY, maxLineX, maxLineY); |
2802 | |||
2803 | 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]); |
||
2804 | if (crossingPoint != null) |
||
2805 | { |
||
2806 | double distance = SPPIDUtil.CalcPointToPointdDistance(crossingPoint[0], crossingPoint[1], x, y); |
||
2807 | 68464385 | gaqhf | if (length >= distance) |
2808 | { |
||
2809 | a0e3dca4 | gaqhf | if (slope == SlopeType.Slope && |
2810 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0] && |
||
2811 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
2812 | { |
||
2813 | targetConnector = item.Key; |
||
2814 | length = distance; |
||
2815 | resultPoint = crossingPoint; |
||
2816 | targetVertices = item.Value; |
||
2817 | } |
||
2818 | else if (slope == SlopeType.HORIZONTAL && |
||
2819 | minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0]) |
||
2820 | { |
||
2821 | targetConnector = item.Key; |
||
2822 | length = distance; |
||
2823 | resultPoint = crossingPoint; |
||
2824 | targetVertices = item.Value; |
||
2825 | } |
||
2826 | else if (slope == SlopeType.VERTICAL && |
||
2827 | minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
||
2828 | { |
||
2829 | targetConnector = item.Key; |
||
2830 | length = distance; |
||
2831 | resultPoint = crossingPoint; |
||
2832 | targetVertices = item.Value; |
||
2833 | } |
||
2834 | 68464385 | gaqhf | } |
2835 | } |
||
2836 | } |
||
2837 | } |
||
2838 | |||
2839 | a0e3dca4 | gaqhf | foreach (var item in vertices) |
2840 | if (item.Key != null && item.Key != targetConnector) |
||
2841 | ReleaseCOMObjects(item.Key); |
||
2842 | |||
2843 | if (SPPIDUtil.IsBranchLine(line, targetLine)) |
||
2844 | 68464385 | gaqhf | { |
2845 | a0e3dca4 | gaqhf | double tempResultX = resultPoint[0]; |
2846 | double tempResultY = resultPoint[1]; |
||
2847 | SPPIDUtil.ConvertGridPoint(ref tempResultX, ref tempResultY); |
||
2848 | 68464385 | gaqhf | |
2849 | a0e3dca4 | gaqhf | GridSetting gridSetting = GridSetting.GetInstance(); |
2850 | |||
2851 | for (int i = 0; i < targetVertices.Count; i++) |
||
2852 | { |
||
2853 | double[] point = targetVertices[i]; |
||
2854 | double tempX = targetVertices[i][0]; |
||
2855 | double tempY = targetVertices[i][1]; |
||
2856 | SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY); |
||
2857 | if (tempX == tempResultX && tempY == tempResultY) |
||
2858 | 68464385 | gaqhf | { |
2859 | a0e3dca4 | gaqhf | if (i == 0) |
2860 | 68464385 | gaqhf | { |
2861 | a0e3dca4 | gaqhf | LMSymbol connSymbol = targetConnector.ConnectItem1SymbolObject; |
2862 | b01e7456 | gaqhf | bool containZeroLength = false; |
2863 | if (connSymbol != null) |
||
2864 | a0e3dca4 | gaqhf | { |
2865 | 1805d3b7 | gaqhf | foreach (LMConnector connector in connSymbol.Connect1Connectors) |
2866 | { |
||
2867 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
2868 | 1805d3b7 | gaqhf | containZeroLength = true; |
2869 | } |
||
2870 | foreach (LMConnector connector in connSymbol.Connect2Connectors) |
||
2871 | a0e3dca4 | gaqhf | { |
2872 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
2873 | 1805d3b7 | gaqhf | containZeroLength = true; |
2874 | a0e3dca4 | gaqhf | } |
2875 | b01e7456 | gaqhf | } |
2876 | |||
2877 | if (connSymbol == null || |
||
2878 | (connSymbol != null && connSymbol.get_ItemStatus() == "Active" && connSymbol.get_RepresentationType() != "Branch") || |
||
2879 | containZeroLength) |
||
2880 | { |
||
2881 | bool bCalcX = false; |
||
2882 | bool bCalcY = false; |
||
2883 | if (targetLine.SlopeType == SlopeType.HORIZONTAL) |
||
2884 | bCalcX = true; |
||
2885 | else if (targetLine.SlopeType == SlopeType.VERTICAL) |
||
2886 | bCalcY = true; |
||
2887 | else |
||
2888 | { |
||
2889 | bCalcX = true; |
||
2890 | bCalcY = true; |
||
2891 | } |
||
2892 | a0e3dca4 | gaqhf | |
2893 | b01e7456 | gaqhf | if (bCalcX) |
2894 | a0e3dca4 | gaqhf | { |
2895 | b01e7456 | gaqhf | double nextX = targetVertices[i + 1][0]; |
2896 | double newX = 0; |
||
2897 | if (nextX > tempX) |
||
2898 | { |
||
2899 | newX = tempX + gridSetting.Length; |
||
2900 | if (newX > nextX) |
||
2901 | newX = (point[0] + nextX) / 2; |
||
2902 | } |
||
2903 | a0e3dca4 | gaqhf | else |
2904 | { |
||
2905 | b01e7456 | gaqhf | newX = tempX - gridSetting.Length; |
2906 | if (newX < nextX) |
||
2907 | newX = (point[0] + nextX) / 2; |
||
2908 | a0e3dca4 | gaqhf | } |
2909 | b01e7456 | gaqhf | resultPoint = new double[] { newX, resultPoint[1] }; |
2910 | } |
||
2911 | a0e3dca4 | gaqhf | |
2912 | b01e7456 | gaqhf | if (bCalcY) |
2913 | { |
||
2914 | double nextY = targetVertices[i + 1][1]; |
||
2915 | double newY = 0; |
||
2916 | if (nextY > tempY) |
||
2917 | a0e3dca4 | gaqhf | { |
2918 | b01e7456 | gaqhf | newY = tempY + gridSetting.Length; |
2919 | if (newY > nextY) |
||
2920 | newY = (point[1] + nextY) / 2; |
||
2921 | a0e3dca4 | gaqhf | } |
2922 | b01e7456 | gaqhf | else |
2923 | a0e3dca4 | gaqhf | { |
2924 | b01e7456 | gaqhf | newY = tempY - gridSetting.Length; |
2925 | if (newY < nextY) |
||
2926 | newY = (point[1] + nextY) / 2; |
||
2927 | a0e3dca4 | gaqhf | } |
2928 | b01e7456 | gaqhf | resultPoint = new double[] { resultPoint[0], newY }; |
2929 | a0e3dca4 | gaqhf | } |
2930 | } |
||
2931 | } |
||
2932 | else if (i == targetVertices.Count - 1) |
||
2933 | { |
||
2934 | LMSymbol connSymbol = targetConnector.ConnectItem2SymbolObject; |
||
2935 | b01e7456 | gaqhf | bool containZeroLength = false; |
2936 | if (connSymbol != null) |
||
2937 | a0e3dca4 | gaqhf | { |
2938 | 1805d3b7 | gaqhf | foreach (LMConnector connector in connSymbol.Connect1Connectors) |
2939 | { |
||
2940 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
2941 | 1805d3b7 | gaqhf | containZeroLength = true; |
2942 | } |
||
2943 | foreach (LMConnector connector in connSymbol.Connect2Connectors) |
||
2944 | a0e3dca4 | gaqhf | { |
2945 | b01e7456 | gaqhf | if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()) == true) |
2946 | 1805d3b7 | gaqhf | containZeroLength = true; |
2947 | a0e3dca4 | gaqhf | } |
2948 | b01e7456 | gaqhf | } |
2949 | |||
2950 | if (connSymbol == null || |
||
2951 | (connSymbol != null && connSymbol.get_ItemStatus() == "Active" && connSymbol.get_RepresentationType() != "Branch") || |
||
2952 | containZeroLength) |
||
2953 | { |
||
2954 | bool bCalcX = false; |
||
2955 | bool bCalcY = false; |
||
2956 | if (targetLine.SlopeType == SlopeType.HORIZONTAL) |
||
2957 | bCalcX = true; |
||
2958 | else if (targetLine.SlopeType == SlopeType.VERTICAL) |
||
2959 | bCalcY = true; |
||
2960 | else |
||
2961 | { |
||
2962 | bCalcX = true; |
||
2963 | bCalcY = true; |
||
2964 | } |
||
2965 | a0e3dca4 | gaqhf | |
2966 | b01e7456 | gaqhf | if (bCalcX) |
2967 | a0e3dca4 | gaqhf | { |
2968 | b01e7456 | gaqhf | double nextX = targetVertices[i - 1][0]; |
2969 | double newX = 0; |
||
2970 | if (nextX > tempX) |
||
2971 | { |
||
2972 | newX = tempX + gridSetting.Length; |
||
2973 | if (newX > nextX) |
||
2974 | newX = (point[0] + nextX) / 2; |
||
2975 | } |
||
2976 | a0e3dca4 | gaqhf | else |
2977 | { |
||
2978 | b01e7456 | gaqhf | newX = tempX - gridSetting.Length; |
2979 | if (newX < nextX) |
||
2980 | newX = (point[0] + nextX) / 2; |
||
2981 | a0e3dca4 | gaqhf | } |
2982 | b01e7456 | gaqhf | resultPoint = new double[] { newX, resultPoint[1] }; |
2983 | } |
||
2984 | a0e3dca4 | gaqhf | |
2985 | b01e7456 | gaqhf | if (bCalcY) |
2986 | { |
||
2987 | double nextY = targetVertices[i - 1][1]; |
||
2988 | double newY = 0; |
||
2989 | if (nextY > tempY) |
||
2990 | a0e3dca4 | gaqhf | { |
2991 | b01e7456 | gaqhf | newY = tempY + gridSetting.Length; |
2992 | if (newY > nextY) |
||
2993 | newY = (point[1] + nextY) / 2; |
||
2994 | a0e3dca4 | gaqhf | } |
2995 | b01e7456 | gaqhf | else |
2996 | a0e3dca4 | gaqhf | { |
2997 | b01e7456 | gaqhf | newY = tempY - gridSetting.Length; |
2998 | if (newY < nextY) |
||
2999 | newY = (point[1] + nextY) / 2; |
||
3000 | a0e3dca4 | gaqhf | } |
3001 | b01e7456 | gaqhf | resultPoint = new double[] { resultPoint[0], newY }; |
3002 | a0e3dca4 | gaqhf | } |
3003 | } |
||
3004 | 68464385 | gaqhf | } |
3005 | a0e3dca4 | gaqhf | break; |
3006 | 68464385 | gaqhf | } |
3007 | } |
||
3008 | } |
||
3009 | |||
3010 | a0e3dca4 | gaqhf | x = resultPoint[0]; |
3011 | y = resultPoint[1]; |
||
3012 | |||
3013 | 68464385 | gaqhf | return targetConnector; |
3014 | } |
||
3015 | |||
3016 | 1ff0105e | gaqhf | private LMConnector GetLMConnectorOnlyOne(string modelItemID) |
3017 | { |
||
3018 | LMConnector result = null; |
||
3019 | List<LMConnector> connectors = new List<LMConnector>(); |
||
3020 | LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
||
3021 | |||
3022 | if (modelItem != null) |
||
3023 | { |
||
3024 | foreach (LMRepresentation rep in modelItem.Representations) |
||
3025 | { |
||
3026 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
3027 | connectors.Add(dataSource.GetConnector(rep.Id)); |
||
3028 | } |
||
3029 | |||
3030 | ReleaseCOMObjects(modelItem); |
||
3031 | } |
||
3032 | |||
3033 | if (connectors.Count == 1) |
||
3034 | result = connectors[0]; |
||
3035 | else |
||
3036 | foreach (var item in connectors) |
||
3037 | ReleaseCOMObjects(item); |
||
3038 | |||
3039 | return result; |
||
3040 | } |
||
3041 | |||
3042 | 74752074 | gaqhf | /// <summary> |
3043 | /// Line Number Symbol을 실제로 Modeling하는 메서드 |
||
3044 | /// </summary> |
||
3045 | /// <param name="lineNumber"></param> |
||
3046 | 8701de36 | gaqhf | private void LineNumberModelingOnlyOne(Line line) |
3047 | cfda1fed | gaqhf | { |
3048 | 32205389 | gaqhf | LineNumber lineNumber = document.LINENUMBERS.Find(x => x.CONNLINE == line.UID); |
3049 | if (lineNumber != null) |
||
3050 | 10872260 | gaqhf | { |
3051 | 32205389 | gaqhf | LMConnector connectedLMConnector = GetLMConnectorOnlyOne(line.SPPID.ModelItemId); |
3052 | 340515a2 | gaqhf | if (connectedLMConnector != null) |
3053 | { |
||
3054 | double x = 0; |
||
3055 | double y = 0; |
||
3056 | CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
||
3057 | b65a7e32 | gaqhf | |
3058 | 340515a2 | gaqhf | Array points = new double[] { 0, x, y }; |
3059 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
||
3060 | cfda1fed | gaqhf | |
3061 | 340515a2 | gaqhf | if (_LmLabelPresist != null) |
3062 | { |
||
3063 | _LmLabelPresist.Commit(); |
||
3064 | lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
||
3065 | ReleaseCOMObjects(_LmLabelPresist); |
||
3066 | } |
||
3067 | c3d2e266 | gaqhf | } |
3068 | 10872260 | gaqhf | } |
3069 | cfda1fed | gaqhf | } |
3070 | 8701de36 | gaqhf | private void LineNumberModeling(LineNumber lineNumber) |
3071 | { |
||
3072 | Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line; |
||
3073 | if (line != null) |
||
3074 | { |
||
3075 | double x = 0; |
||
3076 | double y = 0; |
||
3077 | CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
||
3078 | |||
3079 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
3080 | LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, x, y); |
||
3081 | if (connectedLMConnector != null) |
||
3082 | { |
||
3083 | Array points = new double[] { 0, x, y }; |
||
3084 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
||
3085 | ca6e0f51 | gaqhf | |
3086 | 8701de36 | gaqhf | if (_LmLabelPresist != null) |
3087 | { |
||
3088 | _LmLabelPresist.Commit(); |
||
3089 | lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
||
3090 | ReleaseCOMObjects(_LmLabelPresist); |
||
3091 | } |
||
3092 | } |
||
3093 | |||
3094 | foreach (var item in connectorVertices) |
||
3095 | ReleaseCOMObjects(item.Key); |
||
3096 | } |
||
3097 | } |
||
3098 | 74752074 | gaqhf | /// <summary> |
3099 | b2d1c1aa | gaqhf | /// Flow Mark Modeling |
3100 | /// </summary> |
||
3101 | /// <param name="line"></param> |
||
3102 | private void FlowMarkModeling(Line line) |
||
3103 | { |
||
3104 | a0965e07 | gaqhf | if (line.FLOWMARK && !string.IsNullOrEmpty(line.SPPID.ModelItemId) && !string.IsNullOrEmpty(_ETCSetting.FlowMarkSymbolPath)) |
3105 | b2d1c1aa | gaqhf | { |
3106 | 32205389 | gaqhf | LMConnector connector = GetLMConnectorOnlyOne(line.SPPID.ModelItemId); |
3107 | if (connector != null) |
||
3108 | b2d1c1aa | gaqhf | { |
3109 | 32205389 | gaqhf | string mappingPath = _ETCSetting.FlowMarkSymbolPath; |
3110 | List<double[]> vertices = GetConnectorVertices(connector); |
||
3111 | vertices = vertices.FindAll(x => x[0] > 0 && x[1] > 0); |
||
3112 | double[] point = vertices[vertices.Count - 1]; |
||
3113 | Array array = new double[] { 0, point[0], point[1] }; |
||
3114 | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mappingPath, ref array, LabeledItem: connector.AsLMRepresentation()); |
||
3115 | if (_LMLabelPersist != null) |
||
3116 | ReleaseCOMObjects(_LMLabelPersist); |
||
3117 | b2d1c1aa | gaqhf | } |
3118 | } |
||
3119 | } |
||
3120 | |||
3121 | /// <summary> |
||
3122 | 74752074 | gaqhf | /// Line Number 기준으로 모든 Item에 Line Number의 Attribute Input |
3123 | /// </summary> |
||
3124 | /// <param name="lineNumber"></param> |
||
3125 | 82d6e5ea | gaqhf | private void InputLineNumberAttribute(LineNumber lineNumber, List<string> endLine) |
3126 | a7e9beec | gaqhf | { |
3127 | 8634af60 | gaqhf | foreach (LineRun run in lineNumber.RUNS) |
3128 | a7e9beec | gaqhf | { |
3129 | 8634af60 | gaqhf | foreach (var item in run.RUNITEMS) |
3130 | a7e9beec | gaqhf | { |
3131 | 48fd75e2 | gaqhf | if (item.GetType() == typeof(Symbol)) |
3132 | { |
||
3133 | Symbol symbol = item as Symbol; |
||
3134 | LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
3135 | if (_LMSymbol != null) |
||
3136 | { |
||
3137 | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
||
3138 | |||
3139 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3140 | { |
||
3141 | foreach (var attribute in lineNumber.ATTRIBUTES) |
||
3142 | { |
||
3143 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
3144 | if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3145 | { |
||
3146 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
3147 | if (_LMAAttribute != null) |
||
3148 | { |
||
3149 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
3150 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3151 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
3152 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3153 | } |
||
3154 | } |
||
3155 | } |
||
3156 | _LMModelItem.Commit(); |
||
3157 | } |
||
3158 | if (_LMModelItem != null) |
||
3159 | ReleaseCOMObjects(_LMModelItem); |
||
3160 | } |
||
3161 | if (_LMSymbol != null) |
||
3162 | ReleaseCOMObjects(_LMSymbol); |
||
3163 | } |
||
3164 | else if (item.GetType() == typeof(Line)) |
||
3165 | 8634af60 | gaqhf | { |
3166 | Line line = item as Line; |
||
3167 | 82d6e5ea | gaqhf | if (line != null && !endLine.Contains(line.SPPID.ModelItemId)) |
3168 | a7e9beec | gaqhf | { |
3169 | 8634af60 | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
3170 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3171 | a7e9beec | gaqhf | { |
3172 | 8634af60 | gaqhf | foreach (var attribute in lineNumber.ATTRIBUTES) |
3173 | { |
||
3174 | LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
||
3175 | b2d1c1aa | gaqhf | if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
3176 | 8634af60 | gaqhf | { |
3177 | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
||
3178 | if (_LMAAttribute != null) |
||
3179 | { |
||
3180 | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
||
3181 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3182 | else if (_LMAAttribute.get_Value() != attribute.VALUE) |
||
3183 | _LMAAttribute.set_Value(attribute.VALUE); |
||
3184 | 7f00b26c | gaqhf | |
3185 | 8634af60 | gaqhf | } |
3186 | } |
||
3187 | } |
||
3188 | 68464385 | gaqhf | _LMModelItem.Commit(); |
3189 | a7e9beec | gaqhf | } |
3190 | 8634af60 | gaqhf | if (_LMModelItem != null) |
3191 | ReleaseCOMObjects(_LMModelItem); |
||
3192 | 82d6e5ea | gaqhf | endLine.Add(line.SPPID.ModelItemId); |
3193 | a7e9beec | gaqhf | } |
3194 | } |
||
3195 | } |
||
3196 | } |
||
3197 | } |
||
3198 | |||
3199 | 74752074 | gaqhf | /// <summary> |
3200 | /// Symbol Attribute 입력 메서드 |
||
3201 | /// </summary> |
||
3202 | 73415441 | gaqhf | /// <param name="item"></param> |
3203 | private void InputSymbolAttribute(object targetItem, List<BaseModel.Attribute> targetAttributes) |
||
3204 | 1efc25a3 | gaqhf | { |
3205 | 7f00b26c | gaqhf | // Object 아이템이 Symbol일 경우 Equipment일 경우 |
3206 | string sRep = null; |
||
3207 | if (targetItem.GetType() == typeof(Symbol)) |
||
3208 | sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
||
3209 | else if (targetItem.GetType() == typeof(Equipment)) |
||
3210 | sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
||
3211 | |||
3212 | if (!string.IsNullOrEmpty(sRep)) |
||
3213 | 1efc25a3 | gaqhf | { |
3214 | 7f00b26c | gaqhf | LMSymbol _LMSymbol = dataSource.GetSymbol(sRep); |
3215 | LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
||
3216 | LMAAttributes _Attributes = _LMModelItem.Attributes; |
||
3217 | ca6e0f51 | gaqhf | |
3218 | 7f00b26c | gaqhf | foreach (var item in targetAttributes) |
3219 | { |
||
3220 | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
||
3221 | if (mapping != null && !string.IsNullOrEmpty(item.VALUE) && item.VALUE != "None") |
||
3222 | 65a1ed4b | gaqhf | { |
3223 | 7f00b26c | gaqhf | LMAAttribute _Attribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
3224 | if (_Attribute != null) |
||
3225 | 30ba9ae0 | gaqhf | { |
3226 | object associItem = SPPIDUtil.FindObjectByUID(document, item.ASSOCITEM); |
||
3227 | if (associItem != null) |
||
3228 | { |
||
3229 | if (associItem.GetType() == typeof(Text)) |
||
3230 | { |
||
3231 | Text text = associItem as Text; |
||
3232 | text.SPPID.RepresentationId = "Attribute"; |
||
3233 | } |
||
3234 | else if (associItem.GetType() == typeof(Note)) |
||
3235 | { |
||
3236 | Note note = associItem as Note; |
||
3237 | note.SPPID.RepresentationId = "Attribute"; |
||
3238 | } |
||
3239 | } |
||
3240 | 7f00b26c | gaqhf | _Attribute.set_Value(item.VALUE); |
3241 | 30ba9ae0 | gaqhf | } |
3242 | |||
3243 | 65a1ed4b | gaqhf | } |
3244 | ac78b508 | gaqhf | } |
3245 | 7f00b26c | gaqhf | _LMModelItem.Commit(); |
3246 | |||
3247 | ReleaseCOMObjects(_Attributes); |
||
3248 | ReleaseCOMObjects(_LMModelItem); |
||
3249 | ReleaseCOMObjects(_LMSymbol); |
||
3250 | 1efc25a3 | gaqhf | } |
3251 | } |
||
3252 | |||
3253 | 74752074 | gaqhf | /// <summary> |
3254 | 16584d30 | gaqhf | /// Input SpecBreak Attribute |
3255 | /// </summary> |
||
3256 | /// <param name="specBreak"></param> |
||
3257 | private void InputSpecBreakAttribute(SpecBreak specBreak) |
||
3258 | { |
||
3259 | 7f00b26c | gaqhf | object upStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.UpStreamUID); |
3260 | object downStreamObj = SPPIDUtil.FindObjectByUID(document, specBreak.DownStreamUID); |
||
3261 | |||
3262 | if (upStreamObj != null && |
||
3263 | downStreamObj != null) |
||
3264 | 16584d30 | gaqhf | { |
3265 | 7f00b26c | gaqhf | LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
3266 | 16584d30 | gaqhf | |
3267 | 7f00b26c | gaqhf | if (targetLMConnector != null) |
3268 | 16584d30 | gaqhf | { |
3269 | 7f00b26c | gaqhf | foreach (LMLabelPersist _LMLabelPersist in targetLMConnector.LabelPersists) |
3270 | 16584d30 | gaqhf | { |
3271 | 7f00b26c | gaqhf | string symbolPath = _LMLabelPersist.get_FileName(); |
3272 | AttributeMapping mapping = document.AttributeMappings.Find(x => x.SPPIDSYMBOLNAME == symbolPath); |
||
3273 | if (mapping != null) |
||
3274 | 16584d30 | gaqhf | { |
3275 | 7f00b26c | gaqhf | BaseModel.Attribute attribute = specBreak.ATTRIBUTES.Find(y => y.UID == mapping.UID); |
3276 | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3277 | 16584d30 | gaqhf | { |
3278 | 7f00b26c | gaqhf | string[] values = attribute.VALUE.Split(new char[] { ',' }); |
3279 | if (values.Length == 2) |
||
3280 | 16584d30 | gaqhf | { |
3281 | 7f00b26c | gaqhf | string upStreamValue = values[0]; |
3282 | string downStreamValue = values[1]; |
||
3283 | 16584d30 | gaqhf | |
3284 | 7f00b26c | gaqhf | InputAttributeForSpecBreak(upStreamObj, downStreamObj, upStreamValue, downStreamValue, mapping.SPPIDATTRIBUTENAME); |
3285 | 16584d30 | gaqhf | } |
3286 | } |
||
3287 | } |
||
3288 | } |
||
3289 | 7f00b26c | gaqhf | |
3290 | ReleaseCOMObjects(targetLMConnector); |
||
3291 | 16584d30 | gaqhf | } |
3292 | } |
||
3293 | 7f00b26c | gaqhf | |
3294 | 16584d30 | gaqhf | |
3295 | #region 내부에서만 쓰는 메서드 |
||
3296 | 7f00b26c | gaqhf | void InputAttributeForSpecBreak(object _upStreamObj, object _downStreamObj, string upStreamValue, string downStreamValue, string sppidAttributeName) |
3297 | 16584d30 | gaqhf | { |
3298 | 7f00b26c | gaqhf | Symbol upStreamSymbol = _upStreamObj as Symbol; |
3299 | Line upStreamLine = _upStreamObj as Line; |
||
3300 | Symbol downStreamSymbol = _downStreamObj as Symbol; |
||
3301 | Line downStreamLine = _downStreamObj as Line; |
||
3302 | // 둘다 Line일 경우 |
||
3303 | if (upStreamLine != null && downStreamLine != null) |
||
3304 | 16584d30 | gaqhf | { |
3305 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLine(upStreamLine, sppidAttributeName, upStreamValue); |
3306 | InputLineAttributeForSpecBreakLine(downStreamLine, sppidAttributeName, downStreamValue); |
||
3307 | } |
||
3308 | // 둘다 Symbol일 경우 |
||
3309 | else if (upStreamSymbol != null && downStreamSymbol != null) |
||
3310 | { |
||
3311 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamSymbol, downStreamSymbol); |
||
3312 | LMSymbol upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
||
3313 | LMSymbol downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
||
3314 | 16584d30 | gaqhf | |
3315 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
3316 | { |
||
3317 | if (connector.get_ItemStatus() != "Active") |
||
3318 | continue; |
||
3319 | 16584d30 | gaqhf | |
3320 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3321 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3322 | } |
||
3323 | 16584d30 | gaqhf | |
3324 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
3325 | { |
||
3326 | if (connector.get_ItemStatus() != "Active") |
||
3327 | continue; |
||
3328 | 16584d30 | gaqhf | |
3329 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3330 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
||
3331 | } |
||
3332 | 16584d30 | gaqhf | |
3333 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors) |
3334 | { |
||
3335 | if (connector.get_ItemStatus() != "Active") |
||
3336 | continue; |
||
3337 | 16584d30 | gaqhf | |
3338 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3339 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3340 | } |
||
3341 | 16584d30 | gaqhf | |
3342 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
3343 | { |
||
3344 | if (connector.get_ItemStatus() != "Active") |
||
3345 | continue; |
||
3346 | 16584d30 | gaqhf | |
3347 | 7f00b26c | gaqhf | if (connector.Id != zeroLenthConnector.Id) |
3348 | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
||
3349 | 16584d30 | gaqhf | } |
3350 | |||
3351 | 7f00b26c | gaqhf | ReleaseCOMObjects(zeroLenthConnector); |
3352 | ReleaseCOMObjects(upStreamLMSymbol); |
||
3353 | ReleaseCOMObjects(downStreamLMSymbol); |
||
3354 | } |
||
3355 | else if (upStreamSymbol != null && downStreamLine != null) |
||
3356 | { |
||
3357 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamSymbol, downStreamLine); |
||
3358 | InputLineAttributeForSpecBreakLine(downStreamLine, sppidAttributeName, downStreamValue); |
||
3359 | LMSymbol upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
||
3360 | 16584d30 | gaqhf | |
3361 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
3362 | { |
||
3363 | if (connector.get_ItemStatus() != "Active") |
||
3364 | continue; |
||
3365 | 16584d30 | gaqhf | |
3366 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3367 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
3368 | } |
||
3369 | 16584d30 | gaqhf | |
3370 | 7f00b26c | gaqhf | foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
3371 | { |
||
3372 | if (connector.get_ItemStatus() != "Active") |
||
3373 | continue; |
||
3374 | 16584d30 | gaqhf | |
3375 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3376 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, upStreamValue); |
3377 | 16584d30 | gaqhf | } |
3378 | |||
3379 | 7f00b26c | gaqhf | ReleaseCOMObjects(zeroLenthConnector); |
3380 | ReleaseCOMObjects(upStreamLMSymbol); |
||
3381 | } |
||
3382 | else if (upStreamLine != null && downStreamSymbol != null) |
||
3383 | { |
||
3384 | LMConnector zeroLenthConnector = FindBreakLineTarget(upStreamLine, downStreamSymbol); |
||
3385 | InputLineAttributeForSpecBreakLine(upStreamLine, sppidAttributeName, upStreamValue); |
||
3386 | LMSymbol downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
||
3387 | 16584d30 | gaqhf | |
3388 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors) |
3389 | { |
||
3390 | if (connector.get_ItemStatus() != "Active") |
||
3391 | continue; |
||
3392 | 16584d30 | gaqhf | |
3393 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3394 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
3395 | } |
||
3396 | 16584d30 | gaqhf | |
3397 | 7f00b26c | gaqhf | foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
3398 | { |
||
3399 | if (connector.get_ItemStatus() != "Active") |
||
3400 | continue; |
||
3401 | 16584d30 | gaqhf | |
3402 | c993d55a | gaqhf | if (connector.Id == zeroLenthConnector.Id) |
3403 | 7f00b26c | gaqhf | InputLineAttributeForSpecBreakLMConnector(connector, sppidAttributeName, downStreamValue); |
3404 | 16584d30 | gaqhf | } |
3405 | 7f00b26c | gaqhf | |
3406 | ReleaseCOMObjects(zeroLenthConnector); |
||
3407 | ReleaseCOMObjects(downStreamLMSymbol); |
||
3408 | 16584d30 | gaqhf | } |
3409 | } |
||
3410 | |||
3411 | void InputLineAttributeForSpecBreakLine(Line line, string attrName, string value) |
||
3412 | { |
||
3413 | 7f00b26c | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
3414 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3415 | 16584d30 | gaqhf | { |
3416 | 7f00b26c | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[attrName]; |
3417 | if (_LMAAttribute != null) |
||
3418 | 16584d30 | gaqhf | { |
3419 | 7f00b26c | gaqhf | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
3420 | _LMAAttribute.set_Value(value); |
||
3421 | else if (_LMAAttribute.get_Value() != value) |
||
3422 | _LMAAttribute.set_Value(value); |
||
3423 | 16584d30 | gaqhf | } |
3424 | 7f00b26c | gaqhf | |
3425 | _LMModelItem.Commit(); |
||
3426 | 16584d30 | gaqhf | } |
3427 | 7f00b26c | gaqhf | if (_LMModelItem != null) |
3428 | ReleaseCOMObjects(_LMModelItem); |
||
3429 | 16584d30 | gaqhf | } |
3430 | |||
3431 | void InputLineAttributeForSpecBreakLMConnector(LMConnector connector, string attrName, string value) |
||
3432 | { |
||
3433 | 7f00b26c | gaqhf | LMModelItem _LMModelItem = dataSource.GetModelItem(connector.ModelItemID); |
3434 | if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
||
3435 | 16584d30 | gaqhf | { |
3436 | 7f00b26c | gaqhf | LMAAttribute _LMAAttribute = _LMModelItem.Attributes[attrName]; |
3437 | if (_LMAAttribute != null) |
||
3438 | 16584d30 | gaqhf | { |
3439 | 7f00b26c | gaqhf | if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
3440 | _LMAAttribute.set_Value(value); |
||
3441 | else if (_LMAAttribute.get_Value() != value) |
||
3442 | _LMAAttribute.set_Value(value); |
||
3443 | 16584d30 | gaqhf | } |
3444 | 7f00b26c | gaqhf | |
3445 | _LMModelItem.Commit(); |
||
3446 | 16584d30 | gaqhf | } |
3447 | 7f00b26c | gaqhf | if (_LMModelItem != null) |
3448 | ReleaseCOMObjects(_LMModelItem); |
||
3449 | 16584d30 | gaqhf | } |
3450 | #endregion |
||
3451 | } |
||
3452 | |||
3453 | /// <summary> |
||
3454 | 74752074 | gaqhf | /// Text Modeling - Association일 경우는 Text대신 해당 맵핑된 Symbol로 모델링 |
3455 | /// </summary> |
||
3456 | /// <param name="text"></param> |
||
3457 | cfda1fed | gaqhf | private void TextModeling(Text text) |
3458 | { |
||
3459 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
3460 | 0860c756 | gaqhf | LMConnector connectedLMConnector = null; |
3461 | 7f00b26c | gaqhf | //if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
3462 | if (text.ASSOCIATION) |
||
3463 | 6b298450 | gaqhf | { |
3464 | 7f00b26c | gaqhf | object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
3465 | 3783c494 | gaqhf | if (owner != null && owner.GetType() == typeof(Symbol)) |
3466 | ea80efaa | gaqhf | { |
3467 | 7f00b26c | gaqhf | Symbol symbol = owner as Symbol; |
3468 | _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
||
3469 | if (_LMSymbol != null) |
||
3470 | ea80efaa | gaqhf | { |
3471 | 7f00b26c | gaqhf | BaseModel.Attribute attribute = symbol.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
3472 | 3734dcc5 | gaqhf | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
3473 | 0860c756 | gaqhf | { |
3474 | 7f00b26c | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
3475 | 0860c756 | gaqhf | |
3476 | if (mapping != null) |
||
3477 | { |
||
3478 | double x = 0; |
||
3479 | double y = 0; |
||
3480 | |||
3481 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
||
3482 | Array array = new double[] { 0, x, y }; |
||
3483 | |||
3484 | 7f00b26c | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
3485 | 0860c756 | gaqhf | if (_LMLabelPersist != null) |
3486 | { |
||
3487 | 30ba9ae0 | gaqhf | text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
3488 | 0860c756 | gaqhf | _LMLabelPersist.Commit(); |
3489 | ReleaseCOMObjects(_LMLabelPersist); |
||
3490 | } |
||
3491 | } |
||
3492 | } |
||
3493 | ea80efaa | gaqhf | } |
3494 | } |
||
3495 | 3783c494 | gaqhf | else if (owner != null && owner.GetType() == typeof(Line)) |
3496 | ea80efaa | gaqhf | { |
3497 | 7f00b26c | gaqhf | Line line = owner as Line; |
3498 | Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
||
3499 | connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y); |
||
3500 | ea80efaa | gaqhf | |
3501 | 7f00b26c | gaqhf | if (connectedLMConnector != null) |
3502 | { |
||
3503 | 83c14a07 | gaqhf | BaseModel.Attribute attribute = line.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
3504 | if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
||
3505 | 7f00b26c | gaqhf | { |
3506 | 83c14a07 | gaqhf | AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
3507 | 7f00b26c | gaqhf | |
3508 | if (mapping != null) |
||
3509 | 83c14a07 | gaqhf | { |
3510 | double x = 0; |
||
3511 | double y = 0; |
||
3512 | b65a7e32 | gaqhf | |
3513 | 83c14a07 | gaqhf | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
3514 | Array array = new double[] { 0, x, y }; |
||
3515 | ea80efaa | gaqhf | |
3516 | 83c14a07 | gaqhf | LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
3517 | if (_LMLabelPersist != null) |
||
3518 | { |
||
3519 | 30ba9ae0 | gaqhf | text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
3520 | 83c14a07 | gaqhf | _LMLabelPersist.Commit(); |
3521 | ReleaseCOMObjects(_LMLabelPersist); |
||
3522 | } |
||
3523 | 7f00b26c | gaqhf | } |
3524 | } |
||
3525 | } |
||
3526 | ea80efaa | gaqhf | } |
3527 | 6b298450 | gaqhf | } |
3528 | 7f00b26c | gaqhf | else |
3529 | 6b298450 | gaqhf | { |
3530 | 7f00b26c | gaqhf | LMItemNote _LMItemNote = null; |
3531 | LMAAttribute _LMAAttribute = null; |
||
3532 | cfda1fed | gaqhf | |
3533 | 7f00b26c | gaqhf | double x = 0; |
3534 | double y = 0; |
||
3535 | double angle = text.ANGLE; |
||
3536 | CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
||
3537 | |||
3538 | _LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y, Rotation: angle); |
||
3539 | 30ba9ae0 | gaqhf | if (_LMSymbol != null) |
3540 | { |
||
3541 | _LMSymbol.Commit(); |
||
3542 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
3543 | if (_LMItemNote != null) |
||
3544 | { |
||
3545 | _LMItemNote.Commit(); |
||
3546 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
3547 | if (_LMAAttribute != null) |
||
3548 | { |
||
3549 | _LMAAttribute.set_Value(text.VALUE); |
||
3550 | text.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
3551 | _LMItemNote.Commit(); |
||
3552 | |||
3553 | if (_LMAAttribute != null) |
||
3554 | ReleaseCOMObjects(_LMAAttribute); |
||
3555 | if (_LMItemNote != null) |
||
3556 | ReleaseCOMObjects(_LMItemNote); |
||
3557 | } |
||
3558 | } |
||
3559 | } |
||
3560 | 6b298450 | gaqhf | } |
3561 | 7f00b26c | gaqhf | if (_LMSymbol != null) |
3562 | ReleaseCOMObjects(_LMSymbol); |
||
3563 | cfda1fed | gaqhf | } |
3564 | |||
3565 | 74752074 | gaqhf | /// <summary> |
3566 | /// Note Modeling |
||
3567 | /// </summary> |
||
3568 | /// <param name="note"></param> |
||
3569 | cfda1fed | gaqhf | private void NoteModeling(Note note) |
3570 | { |
||
3571 | 6b298450 | gaqhf | LMSymbol _LMSymbol = null; |
3572 | LMItemNote _LMItemNote = null; |
||
3573 | LMAAttribute _LMAAttribute = null; |
||
3574 | |||
3575 | 7f00b26c | gaqhf | if (string.IsNullOrEmpty(note.OWNER) || note.OWNER == "None") |
3576 | 6b298450 | gaqhf | { |
3577 | 7f00b26c | gaqhf | double x = 0; |
3578 | double y = 0; |
||
3579 | fc0a8c33 | gaqhf | |
3580 | 7f00b26c | gaqhf | CalcLabelLocation(ref x, ref y, note.SPPID.ORIGINAL_X, note.SPPID.ORIGINAL_Y, note.SPPIDLabelLocation, _ETCSetting.NoteLocation); |
3581 | fc0a8c33 | gaqhf | |
3582 | 7f00b26c | gaqhf | _LMSymbol = _placement.PIDPlaceSymbol(note.SPPID.MAPPINGNAME, x, y); |
3583 | 30ba9ae0 | gaqhf | if (_LMSymbol != null) |
3584 | { |
||
3585 | _LMSymbol.Commit(); |
||
3586 | _LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
||
3587 | if (_LMItemNote != null) |
||
3588 | { |
||
3589 | _LMItemNote.Commit(); |
||
3590 | _LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
||
3591 | if (_LMAAttribute != null) |
||
3592 | { |
||
3593 | _LMAAttribute.set_Value(note.VALUE); |
||
3594 | note.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
||
3595 | _LMItemNote.Commit(); |
||
3596 | } |
||
3597 | } |
||
3598 | } |
||
3599 | 6b298450 | gaqhf | } |
3600 | cfda1fed | gaqhf | |
3601 | 7f00b26c | gaqhf | if (_LMAAttribute != null) |
3602 | ReleaseCOMObjects(_LMAAttribute); |
||
3603 | if (_LMItemNote != null) |
||
3604 | ReleaseCOMObjects(_LMItemNote); |
||
3605 | if (_LMSymbol != null) |
||
3606 | ReleaseCOMObjects(_LMSymbol); |
||
3607 | cfda1fed | gaqhf | } |
3608 | |||
3609 | a31a512e | gaqhf | private void JoinRunBySameType(string modelItemId, ref string survivorId) |
3610 | ca6e0f51 | gaqhf | { |
3611 | a31a512e | gaqhf | LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
3612 | if (modelItem != null) |
||
3613 | ca6e0f51 | gaqhf | { |
3614 | a31a512e | gaqhf | foreach (LMRepresentation rep in modelItem.Representations) |
3615 | { |
||
3616 | if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
||
3617 | { |
||
3618 | LMConnector connector = dataSource.GetConnector(rep.Id); |
||
3619 | if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch") |
||
3620 | { |
||
3621 | LMSymbol symbol = connector.ConnectItem1SymbolObject; |
||
3622 | List<string> modelItemIds = FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id); |
||
3623 | if (modelItemIds.Count == 1) |
||
3624 | { |
||
3625 | d77973b3 | gaqhf | string joinModelItemId = modelItemIds[0]; |
3626 | CheckZeroLengthAndLabel(ref joinModelItemId); |
||
3627 | JoinRun(joinModelItemId, modelItemId, ref survivorId); |
||
3628 | a31a512e | gaqhf | if (survivorId != null) |
3629 | break; |
||
3630 | } |
||
3631 | } |
||
3632 | if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch") |
||
3633 | { |
||
3634 | LMSymbol symbol = connector.ConnectItem2SymbolObject; |
||
3635 | List<string> modelItemIds = FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id); |
||
3636 | if (modelItemIds.Count == 1) |
||
3637 | { |
||
3638 | d77973b3 | gaqhf | string joinModelItemId = modelItemIds[0]; |
3639 | CheckZeroLengthAndLabel(ref joinModelItemId); |
||
3640 | JoinRun(joinModelItemId, modelItemId, ref survivorId); |
||
3641 | a31a512e | gaqhf | if (survivorId != null) |
3642 | break; |
||
3643 | } |
||
3644 | } |
||
3645 | } |
||
3646 | } |
||
3647 | ca6e0f51 | gaqhf | } |
3648 | dec9ecfd | gaqhf | |
3649 | d77973b3 | gaqhf | void CheckZeroLengthAndLabel(ref string _modelItemId) |
3650 | { |
||
3651 | LMConnector connector = GetLMConnectorOnlyOne(_modelItemId); |
||
3652 | if (connector != null && Convert.ToBoolean(connector.get_IsZeroLength()) && connector.LabelPersists.Count == 0) |
||
3653 | { |
||
3654 | string symbolPath = GetSPPIDFileName(modelItem); |
||
3655 | LMConnector newConnector = ReModelingLMConnector(connector, symbolPath); |
||
3656 | ReleaseCOMObjects(connector); |
||
3657 | _modelItemId = newConnector.ModelItemID; |
||
3658 | ReleaseCOMObjects(newConnector); |
||
3659 | } |
||
3660 | } |
||
3661 | dec9ecfd | gaqhf | } |
3662 | |||
3663 | d9794a6c | gaqhf | /// <summary> |
3664 | 74752074 | gaqhf | /// Label의 좌표를 구하는 메서드(ID2 기준의 좌표 -> SPPID 좌표) |
3665 | /// </summary> |
||
3666 | /// <param name="x"></param> |
||
3667 | /// <param name="y"></param> |
||
3668 | /// <param name="originX"></param> |
||
3669 | /// <param name="originY"></param> |
||
3670 | /// <param name="SPPIDLabelLocation"></param> |
||
3671 | /// <param name="location"></param> |
||
3672 | b65a7e32 | gaqhf | private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDLabelLocationInfo SPPIDLabelLocation, Location location) |
3673 | { |
||
3674 | if (location == Location.None) |
||
3675 | { |
||
3676 | x = originX; |
||
3677 | y = originY; |
||
3678 | } |
||
3679 | else |
||
3680 | { |
||
3681 | if (location.HasFlag(Location.Center)) |
||
3682 | { |
||
3683 | x = (SPPIDLabelLocation.X1 + SPPIDLabelLocation.X2) / 2; |
||
3684 | y = (SPPIDLabelLocation.Y1 + SPPIDLabelLocation.Y2) / 2; |
||
3685 | } |
||
3686 | |||
3687 | if (location.HasFlag(Location.Left)) |
||
3688 | x = SPPIDLabelLocation.X1; |
||
3689 | else if (location.HasFlag(Location.Right)) |
||
3690 | x = SPPIDLabelLocation.X2; |
||
3691 | |||
3692 | if (location.HasFlag(Location.Down)) |
||
3693 | y = SPPIDLabelLocation.Y1; |
||
3694 | else if (location.HasFlag(Location.Up)) |
||
3695 | y = SPPIDLabelLocation.Y2; |
||
3696 | } |
||
3697 | } |
||
3698 | 5a4b8f32 | gaqhf | |
3699 | 74752074 | gaqhf | /// <summary> |
3700 | 4d2571ab | gaqhf | /// Symbol의 우선순위 Modeling 목록을 가져온다. |
3701 | /// 1. Angle Valve |
||
3702 | /// 2. 3개로 이루어진 Symbol Group |
||
3703 | /// </summary> |
||
3704 | /// <returns></returns> |
||
3705 | private List<Symbol> GetPrioritySymbol() |
||
3706 | { |
||
3707 | DataTable symbolTable = document.SymbolTable; |
||
3708 | // List에 순서대로 쌓는다. |
||
3709 | List<Symbol> symbols = new List<Symbol>(); |
||
3710 | 3734dcc5 | gaqhf | |
3711 | 4d2571ab | gaqhf | // Angle Valve 부터 |
3712 | d9794a6c | gaqhf | foreach (var symbol in document.SYMBOLS.FindAll(x => x.CONNECTORS.FindAll(y => y.Index == 0).Count == 2)) |
3713 | 4d2571ab | gaqhf | { |
3714 | if (!symbols.Contains(symbol)) |
||
3715 | { |
||
3716 | double originX = 0; |
||
3717 | double originY = 0; |
||
3718 | |||
3719 | // ID2 Table에서 Original Point 가져옴. |
||
3720 | 7f00b26c | gaqhf | string OriginalPoint = symbolTable.Select(string.Format("UID = {0}", symbol.DBUID))[0]["OriginalPoint"].ToString(); |
3721 | 4d2571ab | gaqhf | SPPIDUtil.ConvertPointBystring(OriginalPoint, ref originX, ref originY); |
3722 | |||
3723 | SlopeType slopeType1 = SlopeType.None; |
||
3724 | SlopeType slopeType2 = SlopeType.None; |
||
3725 | d9794a6c | gaqhf | foreach (Connector connector in symbol.CONNECTORS.FindAll(x => x.Index == 0)) |
3726 | 4d2571ab | gaqhf | { |
3727 | double connectorX = 0; |
||
3728 | double connectorY = 0; |
||
3729 | SPPIDUtil.ConvertPointBystring(connector.CONNECTPOINT, ref connectorX, ref connectorY); |
||
3730 | if (slopeType1 == SlopeType.None) |
||
3731 | slopeType1 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
||
3732 | else |
||
3733 | slopeType2 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
||
3734 | } |
||
3735 | |||
3736 | if ((slopeType1 == SlopeType.VERTICAL && slopeType2 == SlopeType.HORIZONTAL) || |
||
3737 | (slopeType2 == SlopeType.VERTICAL && slopeType1 == SlopeType.HORIZONTAL)) |
||
3738 | symbols.Add(symbol); |
||
3739 | } |
||
3740 | } |
||
3741 | |||
3742 | f1a7faf9 | gaqhf | List<Symbol> tempSymbols = new List<Symbol>(); |
3743 | // Conn 갯수 기준 |
||
3744 | d9794a6c | gaqhf | foreach (var item in document.SYMBOLS) |
3745 | { |
||
3746 | f1a7faf9 | gaqhf | if (!symbols.Contains(item)) |
3747 | tempSymbols.Add(item); |
||
3748 | d9794a6c | gaqhf | } |
3749 | f1a7faf9 | gaqhf | tempSymbols.Sort(SortSymbolPriority); |
3750 | symbols.AddRange(tempSymbols); |
||
3751 | 4d2571ab | gaqhf | |
3752 | return symbols; |
||
3753 | } |
||
3754 | |||
3755 | d63050d6 | gaqhf | private void SetPriorityLine() |
3756 | { |
||
3757 | document.LINES.Sort(SortLinePriority); |
||
3758 | |||
3759 | int SortLinePriority(Line a, Line b) |
||
3760 | { |
||
3761 | // Branch 없는것부터 |
||
3762 | int branchRetval = CompareBranchLine(a, b); |
||
3763 | if (branchRetval != 0) |
||
3764 | { |
||
3765 | return branchRetval; |
||
3766 | } |
||
3767 | else |
||
3768 | { |
||
3769 | // Symbol 연결 갯수 |
||
3770 | int connSymbolRetval = CompareConnSymbol(a, b); |
||
3771 | if (connSymbolRetval != 0) |
||
3772 | { |
||
3773 | return connSymbolRetval; |
||
3774 | } |
||
3775 | else |
||
3776 | { |
||
3777 | 24515a3a | gaqhf | // 아이템 연결 갯수(심볼, Line이면서 Not Branch) |
3778 | int connItemRetval = CompareConnItem(a, b); |
||
3779 | if (connItemRetval != 0) |
||
3780 | d63050d6 | gaqhf | { |
3781 | 24515a3a | gaqhf | return connItemRetval; |
3782 | d63050d6 | gaqhf | } |
3783 | else |
||
3784 | { |
||
3785 | 24515a3a | gaqhf | // ConnectedItem이 없는것 |
3786 | int noneConnRetval = CompareNoneConn(a, b); |
||
3787 | if (noneConnRetval != 0) |
||
3788 | d63050d6 | gaqhf | { |
3789 | 24515a3a | gaqhf | return noneConnRetval; |
3790 | d63050d6 | gaqhf | } |
3791 | else |
||
3792 | { |
||
3793 | |||
3794 | } |
||
3795 | } |
||
3796 | } |
||
3797 | } |
||
3798 | |||
3799 | return 0; |
||
3800 | } |
||
3801 | |||
3802 | e283d483 | gaqhf | int CompareNotSegmentLine(Line a, Line b) |
3803 | { |
||
3804 | List<Connector> connectorsA = a.CONNECTORS |
||
3805 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
3806 | .ToList(); |
||
3807 | |||
3808 | List<Connector> connectorsB = b.CONNECTORS |
||
3809 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
3810 | .ToList(); |
||
3811 | |||
3812 | // 오름차순 |
||
3813 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
3814 | } |
||
3815 | |||
3816 | d63050d6 | gaqhf | int CompareConnSymbol(Line a, Line b) |
3817 | { |
||
3818 | List<Connector> connectorsA = a.CONNECTORS |
||
3819 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
3820 | .ToList(); |
||
3821 | |||
3822 | List<Connector> connectorsB = b.CONNECTORS |
||
3823 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Symbol)) |
||
3824 | .ToList(); |
||
3825 | |||
3826 | // 오름차순 |
||
3827 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
3828 | } |
||
3829 | |||
3830 | int CompareConnItem(Line a, Line b) |
||
3831 | { |
||
3832 | List<Connector> connectorsA = a.CONNECTORS |
||
3833 | .Where(conn => conn.ConnectedObject != null && |
||
3834 | (conn.ConnectedObject.GetType() == typeof(Symbol) || |
||
3835 | (conn.ConnectedObject.GetType() == typeof(Line) && !SPPIDUtil.IsBranchLine((Line)conn.ConnectedObject, a)))) |
||
3836 | .ToList(); |
||
3837 | |||
3838 | List<Connector> connectorsB = b.CONNECTORS |
||
3839 | .Where(conn => conn.ConnectedObject != null && |
||
3840 | (conn.ConnectedObject.GetType() == typeof(Symbol) || |
||
3841 | (conn.ConnectedObject.GetType() == typeof(Line) && !SPPIDUtil.IsBranchLine((Line)conn.ConnectedObject, b)))) |
||
3842 | .ToList(); |
||
3843 | |||
3844 | // 오름차순 |
||
3845 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
3846 | } |
||
3847 | |||
3848 | int CompareBranchLine(Line a, Line b) |
||
3849 | { |
||
3850 | List<Connector> connectorsA = a.CONNECTORS |
||
3851 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Line) && SPPIDUtil.IsBranchLine(a, conn.ConnectedObject as Line)) |
||
3852 | .ToList(); |
||
3853 | List<Connector> connectorsB = b.CONNECTORS |
||
3854 | .Where(conn => conn.ConnectedObject != null && conn.ConnectedObject.GetType() == typeof(Line) && SPPIDUtil.IsBranchLine(b, conn.ConnectedObject as Line)) |
||
3855 | .ToList(); |
||
3856 | |||
3857 | // 내림차순 |
||
3858 | return connectorsA.Count.CompareTo(connectorsB.Count); |
||
3859 | } |
||
3860 | |||
3861 | int CompareNoneConn(Line a, Line b) |
||
3862 | { |
||
3863 | List<Connector> connectorsA = a.CONNECTORS |
||
3864 | .Where(conn => conn.ConnectedObject == null) |
||
3865 | .ToList(); |
||
3866 | |||
3867 | List<Connector> connectorsB = b.CONNECTORS |
||
3868 | .Where(conn => conn.ConnectedObject == null) |
||
3869 | .ToList(); |
||
3870 | |||
3871 | // 오름차순 |
||
3872 | return connectorsB.Count.CompareTo(connectorsA.Count); |
||
3873 | } |
||
3874 | } |
||
3875 | |||
3876 | a0e3dca4 | gaqhf | private void SortBranchLines() |
3877 | { |
||
3878 | f3e2693f | gaqhf | BranchLines.Sort(SortBranchLine); |
3879 | a0e3dca4 | gaqhf | int SortBranchLine(Line a, Line b) |
3880 | { |
||
3881 | int countA = a.CONNECTORS.FindAll(x => x.ConnectedObject != null && |
||
3882 | x.ConnectedObject.GetType() == typeof(Line) && |
||
3883 | SPPIDUtil.IsBranchLine(x.ConnectedObject as Line, a) && |
||
3884 | string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)).Count; |
||
3885 | |||
3886 | int countB = b.CONNECTORS.FindAll(x => x.ConnectedObject != null && |
||
3887 | x.ConnectedObject.GetType() == typeof(Line) && |
||
3888 | SPPIDUtil.IsBranchLine(x.ConnectedObject as Line, b) && |
||
3889 | string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId)).Count; |
||
3890 | |||
3891 | // 내림차순 |
||
3892 | return countA.CompareTo(countB); |
||
3893 | } |
||
3894 | } |
||
3895 | |||
3896 | f1a7faf9 | gaqhf | private static int SortSymbolPriority(Symbol a, Symbol b) |
3897 | { |
||
3898 | int countA = a.CONNECTORS.FindAll(x => !string.IsNullOrEmpty(x.CONNECTEDITEM) && x.CONNECTEDITEM != "None").Count; |
||
3899 | int countB = b.CONNECTORS.FindAll(x => !string.IsNullOrEmpty(x.CONNECTEDITEM) && x.CONNECTEDITEM != "None").Count; |
||
3900 | int retval = countB.CompareTo(countA); |
||
3901 | if (retval != 0) |
||
3902 | return retval; |
||
3903 | else |
||
3904 | return a.SPPID.ORIGINAL_X.CompareTo(b.SPPID.ORIGINAL_X); |
||
3905 | } |
||
3906 | |||
3907 | a31a512e | gaqhf | private string GetSPPIDFileName(LMModelItem modelItem) |
3908 | { |
||
3909 | string symbolPath = null; |
||
3910 | foreach (LMRepresentation rep in modelItem.Representations) |
||
3911 | { |
||
3912 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
3913 | { |
||
3914 | symbolPath = rep.get_FileName(); |
||
3915 | break; |
||
3916 | } |
||
3917 | } |
||
3918 | return symbolPath; |
||
3919 | } |
||
3920 | |||
3921 | 82d6e5ea | gaqhf | private string GetSPPIDFileName(string modelItemId) |
3922 | { |
||
3923 | LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
||
3924 | string symbolPath = null; |
||
3925 | foreach (LMRepresentation rep in modelItem.Representations) |
||
3926 | { |
||
3927 | if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
||
3928 | { |
||
3929 | symbolPath = rep.get_FileName(); |
||
3930 | break; |
||
3931 | } |
||
3932 | } |
||
3933 | ReleaseCOMObjects(modelItem); |
||
3934 | return symbolPath; |
||
3935 | } |
||
3936 | |||
3937 | 4d2571ab | gaqhf | /// <summary> |
3938 | b2d1c1aa | gaqhf | /// Graphic OID로 해당 Symbol의 크기를 구하여 Zoom |
3939 | /// </summary> |
||
3940 | /// <param name="graphicOID"></param> |
||
3941 | /// <param name="milliseconds"></param> |
||
3942 | private void ZoomObjectByGraphicOID(string graphicOID, int milliseconds = 150) |
||
3943 | { |
||
3944 | if (radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID] != null) |
||
3945 | { |
||
3946 | double minX = 0; |
||
3947 | double minY = 0; |
||
3948 | double maxX = 0; |
||
3949 | double maxY = 0; |
||
3950 | radApp.ActiveDocument.ActiveSheet.DrawingObjects[graphicOID].Range(out minX, out minY, out maxX, out maxY); |
||
3951 | radApp.ActiveWindow.ZoomArea2(minX - 0.007, minY - 0.007, maxX + 0.007, maxY + 0.007, null); |
||
3952 | |||
3953 | Thread.Sleep(milliseconds); |
||
3954 | } |
||
3955 | } |
||
3956 | |||
3957 | /// <summary> |
||
3958 | 74752074 | gaqhf | /// ComObject를 Release |
3959 | /// </summary> |
||
3960 | /// <param name="objVars"></param> |
||
3961 | 5a4b8f32 | gaqhf | public void ReleaseCOMObjects(params object[] objVars) |
3962 | { |
||
3963 | int intNewRefCount = 0; |
||
3964 | foreach (object obj in objVars) |
||
3965 | { |
||
3966 | if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
||
3967 | intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
||
3968 | } |
||
3969 | } |
||
3970 | cfda1fed | gaqhf | } |
3971 | } |