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