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