hytos / DTI_PID / SPPIDConverter / Model / SPPID_Document.cs @ f1c9dbaa
이력 | 보기 | 이력해설 | 다운로드 (7.46 KB)
1 | bca86986 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | f1c9dbaa | gaqhf | using System.Data; |
7 | bca86986 | gaqhf | using Converter.BaseModel; |
8 | bca81f4c | gaqhf | using Converter.SPPID.Util; |
9 | bca86986 | gaqhf | |
10 | b8e2644e | gaqhf | namespace Converter.SPPID.Model |
11 | bca86986 | gaqhf | { |
12 | public class SPPID_Document : Document |
||
13 | { |
||
14 | public SPPID_Document(string xmlPath) : base(xmlPath) |
||
15 | { |
||
16 | f1c9dbaa | gaqhf | |
17 | bca86986 | gaqhf | } |
18 | 88365b05 | gaqhf | |
19 | 39a2a688 | gaqhf | private double testX = 0.855; |
20 | private double testY = 0.55; |
||
21 | |||
22 | public List<SymbolMapping> SymbolMappings; |
||
23 | public List<LineMapping> LineMappings; |
||
24 | public List<LineNumberMapping> LineNumberMappings; |
||
25 | public List<AssociationMapping> AssociationMappings; |
||
26 | public ETCSetting ETCSetting; |
||
27 | |||
28 | f1c9dbaa | gaqhf | public List<Group> GROUPS = new List<Group>(); |
29 | 5dfb8a24 | gaqhf | |
30 | bca86986 | gaqhf | public string DrawingName { get; set; } |
31 | public string DrawingNumber { get; set; } |
||
32 | public string Unit { get; set; } |
||
33 | 4314b3f3 | gaqhf | public string Template { get; set; } |
34 | f947c634 | gaqhf | |
35 | public void SetSPPIDInfo() |
||
36 | { |
||
37 | foreach (var item in SYMBOLS) |
||
38 | { |
||
39 | 39a2a688 | gaqhf | if (item.SPPID == null) |
40 | item.SPPID = new SPPIDSymbolInfo(); |
||
41 | double x = double.NaN; |
||
42 | double y = double.NaN; |
||
43 | 1b261371 | gaqhf | SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
44 | 39a2a688 | gaqhf | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
45 | 1b261371 | gaqhf | item.SPPID.ORIGINAL_X = x; |
46 | item.SPPID.ORIGINAL_Y = y; |
||
47 | 39a2a688 | gaqhf | } |
48 | |||
49 | foreach (var item in LINES) |
||
50 | { |
||
51 | if (item.SPPID == null) |
||
52 | item.SPPID = new SPPIDLineInfo(); |
||
53 | double x = double.NaN; |
||
54 | double y = double.NaN; |
||
55 | |||
56 | SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref x, ref y); |
||
57 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
58 | item.SPPID.START_X = x; |
||
59 | item.SPPID.START_Y = y; |
||
60 | |||
61 | SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref x, ref y); |
||
62 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
63 | item.SPPID.END_X = x; |
||
64 | item.SPPID.END_Y = y; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | public bool SetSPPIDMapping() |
||
69 | { |
||
70 | foreach (var item in SYMBOLS) |
||
71 | { |
||
72 | SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
||
73 | item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
||
74 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
75 | return false; |
||
76 | } |
||
77 | |||
78 | foreach (var item in LINES) |
||
79 | { |
||
80 | LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID); |
||
81 | item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
||
82 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
83 | return false; |
||
84 | f947c634 | gaqhf | } |
85 | |||
86 | 39a2a688 | gaqhf | return true; |
87 | f947c634 | gaqhf | } |
88 | 5dfb8a24 | gaqhf | |
89 | f1c9dbaa | gaqhf | #region Grouping Source |
90 | private bool SetGrouping() |
||
91 | { |
||
92 | try |
||
93 | { |
||
94 | // Line 기준으로 묶음 |
||
95 | foreach (Line item in LINES) |
||
96 | if (!item.SPPID.IsGroup) |
||
97 | SetGroupingByItem(item); |
||
98 | // End |
||
99 | |||
100 | // Symbol 기준으로 묶음 |
||
101 | foreach (Symbol item in SYMBOLS) |
||
102 | if (!item.SPPID.IsGroup) |
||
103 | SetGroupingByItem(item); |
||
104 | // End |
||
105 | } |
||
106 | catch (Exception ex) |
||
107 | { |
||
108 | return false; |
||
109 | } |
||
110 | return true; |
||
111 | } |
||
112 | |||
113 | private void SetGroupingByItem(object item) |
||
114 | { |
||
115 | Group group = new Group(); |
||
116 | group.Items.Add(item); |
||
117 | bool forward = true; |
||
118 | SetGroupingByConnectedItem(item, group.Items, ref forward); |
||
119 | |||
120 | GROUPS.Add(group); |
||
121 | } |
||
122 | |||
123 | private void SetGroupingByConnectedItem(object item, List<object> list, ref bool IsForward) |
||
124 | { |
||
125 | if (typeof(Line) == item.GetType()) |
||
126 | { |
||
127 | Line line = item as Line; |
||
128 | line.SPPID.IsGroup = true; |
||
129 | SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS); |
||
130 | } |
||
131 | else if (typeof(Symbol) == item.GetType()) |
||
132 | { |
||
133 | Symbol symbol = item as Symbol; |
||
134 | symbol.SPPID.IsGroup = true; |
||
135 | // Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료 |
||
136 | int baseSymbolCount = 0; |
||
137 | if (symbol.CONNECTORS.Count > 0) |
||
138 | { |
||
139 | foreach (Connector symbolConnector in symbol.CONNECTORS) |
||
140 | if (symbolConnector.Index == 0) |
||
141 | baseSymbolCount++; |
||
142 | |||
143 | if (baseSymbolCount <= 2) |
||
144 | SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS); |
||
145 | } |
||
146 | } |
||
147 | IsForward = false; |
||
148 | } |
||
149 | |||
150 | private void SetGroupingByConnectedItem_ConnectorsLogic(object item, List<object> list, ref bool IsForward, List<Connector> connectors) |
||
151 | { |
||
152 | foreach (Connector connector in connectors) |
||
153 | { |
||
154 | object connItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
155 | if (connItem != null) |
||
156 | { |
||
157 | bool result = false; |
||
158 | if (typeof(Line) == connItem.GetType()) |
||
159 | { |
||
160 | Line connLine = connItem as Line; |
||
161 | // 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인 |
||
162 | if (item.GetType() == connLine.GetType()) |
||
163 | { |
||
164 | Line line = item as Line; |
||
165 | if (SPPIDUtil.IsBranchLine(line.UID, connLine) || line.SPPID.MAPPINGNAME != connLine.SPPID.MAPPINGNAME) |
||
166 | continue; |
||
167 | } |
||
168 | |||
169 | result = true; |
||
170 | } |
||
171 | else if (typeof(Symbol) == connItem.GetType()) |
||
172 | { |
||
173 | Symbol connSymbol = connItem as Symbol; |
||
174 | // 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false |
||
175 | foreach (Connector symbolConnector in connSymbol.CONNECTORS) |
||
176 | { |
||
177 | string itemUID = item as Symbol != null ? ((Symbol)item).UID : ((Line)item).UID; |
||
178 | |||
179 | if (symbolConnector.CONNECTEDITEM == itemUID) |
||
180 | { |
||
181 | if (symbolConnector.Index == 0) |
||
182 | result = true; |
||
183 | else |
||
184 | result = false; |
||
185 | break; |
||
186 | } |
||
187 | } |
||
188 | } |
||
189 | |||
190 | if (!(connItem as Symbol != null ? ((Symbol)connItem).SPPID.IsGroup : ((Line)connItem).SPPID.IsGroup) && result) |
||
191 | { |
||
192 | if (IsForward) |
||
193 | list.Add(connItem); |
||
194 | else |
||
195 | list.Insert(0, connItem); |
||
196 | SetGroupingByConnectedItem(connItem, list, ref IsForward); |
||
197 | } |
||
198 | } |
||
199 | } |
||
200 | } |
||
201 | #endregion |
||
202 | bca86986 | gaqhf | } |
203 | } |