hytos / DTI_PID / SPPIDConverter / Model / SPPID_Document.cs @ 1a3a74a8
이력 | 보기 | 이력해설 | 다운로드 (10.7 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 | 4b4dbca9 | gaqhf | public List<ChildSymbolMapping> ChildSymbolMappings; |
24 | 39a2a688 | gaqhf | public List<LineMapping> LineMappings; |
25 | public List<LineNumberMapping> LineNumberMappings; |
||
26 | 1efc25a3 | gaqhf | public List<AttributeMapping> AttributeMappings; |
27 | 39a2a688 | gaqhf | public ETCSetting ETCSetting; |
28 | |||
29 | f1c9dbaa | gaqhf | public List<Group> GROUPS = new List<Group>(); |
30 | 5dfb8a24 | gaqhf | |
31 | bca86986 | gaqhf | public string DrawingName { get; set; } |
32 | public string DrawingNumber { get; set; } |
||
33 | public string Unit { get; set; } |
||
34 | 4314b3f3 | gaqhf | public string Template { get; set; } |
35 | f947c634 | gaqhf | |
36 | 4b4dbca9 | gaqhf | |
37 | f947c634 | gaqhf | public void SetSPPIDInfo() |
38 | { |
||
39 | foreach (var item in SYMBOLS) |
||
40 | { |
||
41 | 39a2a688 | gaqhf | if (item.SPPID == null) |
42 | item.SPPID = new SPPIDSymbolInfo(); |
||
43 | double x = double.NaN; |
||
44 | double y = double.NaN; |
||
45 | 1b261371 | gaqhf | SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
46 | 39a2a688 | gaqhf | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
47 | 1b261371 | gaqhf | item.SPPID.ORIGINAL_X = x; |
48 | item.SPPID.ORIGINAL_Y = y; |
||
49 | 4b4dbca9 | gaqhf | |
50 | foreach (var childSymbol in item.ChildSymbols) |
||
51 | { |
||
52 | if (childSymbol.SPPID == null) |
||
53 | childSymbol.SPPID = new SPPIDSymbolInfo(); |
||
54 | SetChildSymbolSPPIDInfo(childSymbol); |
||
55 | } |
||
56 | 39a2a688 | gaqhf | } |
57 | |||
58 | foreach (var item in LINES) |
||
59 | { |
||
60 | if (item.SPPID == null) |
||
61 | item.SPPID = new SPPIDLineInfo(); |
||
62 | double x = double.NaN; |
||
63 | double y = double.NaN; |
||
64 | |||
65 | SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref x, ref y); |
||
66 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
67 | item.SPPID.START_X = x; |
||
68 | item.SPPID.START_Y = y; |
||
69 | |||
70 | SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref x, ref y); |
||
71 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
72 | item.SPPID.END_X = x; |
||
73 | item.SPPID.END_Y = y; |
||
74 | } |
||
75 | 809a7640 | gaqhf | |
76 | foreach (var item in Equipments) |
||
77 | { |
||
78 | if (item.SPPID == null) |
||
79 | item.SPPID = new SPPIDSymbolInfo(); |
||
80 | double x = double.NaN; |
||
81 | double y = double.NaN; |
||
82 | SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
||
83 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
84 | item.SPPID.ORIGINAL_X = x; |
||
85 | item.SPPID.ORIGINAL_Y = y; |
||
86 | } |
||
87 | 3165c259 | gaqhf | |
88 | foreach (var item in EndBreaks) |
||
89 | { |
||
90 | if (item.SPPID == null) |
||
91 | item.SPPID = new SPPIDSymbolInfo(); |
||
92 | double x = double.NaN; |
||
93 | double y = double.NaN; |
||
94 | SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
||
95 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
96 | item.SPPID.ORIGINAL_X = x; |
||
97 | item.SPPID.ORIGINAL_Y = y; |
||
98 | } |
||
99 | 10872260 | gaqhf | |
100 | foreach (var item in LINENUMBERS) |
||
101 | { |
||
102 | if (item.SPPID == null) |
||
103 | item.SPPID = new SPPIDSymbolInfo(); |
||
104 | double x = double.NaN; |
||
105 | double y = double.NaN; |
||
106 | SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
||
107 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
108 | item.SPPID.ORIGINAL_X = x; |
||
109 | item.SPPID.ORIGINAL_Y = y; |
||
110 | 1a3a74a8 | gaqhf | |
111 | item.SPPIDLabelLocation = new SPPIDLabelLocationInfo(); |
||
112 | double x1 = item.X1; |
||
113 | double y1 = item.Y1; |
||
114 | double x2 = item.X2; |
||
115 | double y2 = item.Y2; |
||
116 | SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
117 | SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
118 | item.SPPIDLabelLocation.X1 = Math.Min(x1, x2); |
||
119 | item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2); |
||
120 | item.SPPIDLabelLocation.X2 = Math.Max(x1, x2); |
||
121 | item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2); |
||
122 | 10872260 | gaqhf | } |
123 | 6b298450 | gaqhf | |
124 | foreach (var item in TEXTINFOS) |
||
125 | { |
||
126 | if (item.SPPID == null) |
||
127 | item.SPPID = new SPPIDSymbolInfo(); |
||
128 | double x = double.NaN; |
||
129 | double y = double.NaN; |
||
130 | SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
||
131 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
132 | item.SPPID.ORIGINAL_X = x; |
||
133 | item.SPPID.ORIGINAL_Y = y; |
||
134 | 1a3a74a8 | gaqhf | |
135 | item.SPPIDLabelLocation = new SPPIDLabelLocationInfo(); |
||
136 | double x1 = item.X1; |
||
137 | double y1 = item.Y1; |
||
138 | double x2 = item.X2; |
||
139 | double y2 = item.Y2; |
||
140 | SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
141 | SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
142 | item.SPPIDLabelLocation.X1 = Math.Min(x1, x2); |
||
143 | item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2); |
||
144 | item.SPPIDLabelLocation.X2 = Math.Max(x1, x2); |
||
145 | item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2); |
||
146 | 6b298450 | gaqhf | } |
147 | |||
148 | foreach (var item in NOTES) |
||
149 | { |
||
150 | if (item.SPPID == null) |
||
151 | item.SPPID = new SPPIDSymbolInfo(); |
||
152 | double x = double.NaN; |
||
153 | double y = double.NaN; |
||
154 | SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
||
155 | SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
156 | item.SPPID.ORIGINAL_X = x; |
||
157 | item.SPPID.ORIGINAL_Y = y; |
||
158 | 1a3a74a8 | gaqhf | |
159 | item.SPPIDLabelLocation = new SPPIDLabelLocationInfo(); |
||
160 | double x1 = item.X1; |
||
161 | double y1 = item.Y1; |
||
162 | double x2 = item.X2; |
||
163 | double y2 = item.Y2; |
||
164 | SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
165 | SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
||
166 | item.SPPIDLabelLocation.X1 = Math.Min(x1, x2); |
||
167 | item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2); |
||
168 | item.SPPIDLabelLocation.X2 = Math.Max(x1, x2); |
||
169 | item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2); |
||
170 | 6b298450 | gaqhf | } |
171 | 39a2a688 | gaqhf | } |
172 | 4b4dbca9 | gaqhf | |
173 | private void SetChildSymbolSPPIDInfo(ChildSymbol item) |
||
174 | { |
||
175 | foreach (var childSymbol in item.ChildSymbols) |
||
176 | { |
||
177 | if (childSymbol.SPPID == null) |
||
178 | childSymbol.SPPID = new SPPIDSymbolInfo(); |
||
179 | SetChildSymbolSPPIDInfo(childSymbol); |
||
180 | } |
||
181 | } |
||
182 | |||
183 | 39a2a688 | gaqhf | public bool SetSPPIDMapping() |
184 | { |
||
185 | foreach (var item in SYMBOLS) |
||
186 | { |
||
187 | SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
||
188 | item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
||
189 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
190 | return false; |
||
191 | 4b4dbca9 | gaqhf | |
192 | foreach (var childSymbol in item.ChildSymbols) |
||
193 | { |
||
194 | ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME); |
||
195 | childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null; |
||
196 | if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol)) |
||
197 | return false; |
||
198 | } |
||
199 | 39a2a688 | gaqhf | } |
200 | |||
201 | foreach (var item in LINES) |
||
202 | { |
||
203 | LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID); |
||
204 | item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
||
205 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
206 | return false; |
||
207 | f947c634 | gaqhf | } |
208 | |||
209 | 809a7640 | gaqhf | foreach (var item in Equipments) |
210 | { |
||
211 | SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
||
212 | item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
||
213 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
214 | return false; |
||
215 | } |
||
216 | |||
217 | 3165c259 | gaqhf | foreach (var item in EndBreaks) |
218 | { |
||
219 | SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
||
220 | item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
||
221 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
222 | return false; |
||
223 | } |
||
224 | |||
225 | 10872260 | gaqhf | foreach (var item in LINENUMBERS) |
226 | { |
||
227 | if (LineNumberMappings.Count > 0) |
||
228 | item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME; |
||
229 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
230 | return false; |
||
231 | } |
||
232 | |||
233 | 6b298450 | gaqhf | ETCSetting etc = ETCSetting.GetInstance(); |
234 | foreach (var item in NOTES) |
||
235 | { |
||
236 | item.SPPID.MAPPINGNAME = etc.NoteSymbolPath; |
||
237 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
238 | return false; |
||
239 | } |
||
240 | |||
241 | foreach (var item in TEXTINFOS) |
||
242 | { |
||
243 | item.SPPID.MAPPINGNAME = etc.TextSymbolPath; |
||
244 | if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
||
245 | return false; |
||
246 | } |
||
247 | 4b4dbca9 | gaqhf | |
248 | 39a2a688 | gaqhf | return true; |
249 | f947c634 | gaqhf | } |
250 | 5dfb8a24 | gaqhf | |
251 | 4b4dbca9 | gaqhf | private bool SetChildSymbolMapping(ChildSymbol item) |
252 | { |
||
253 | foreach (var childSymbol in item.ChildSymbols) |
||
254 | { |
||
255 | ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME); |
||
256 | childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null; |
||
257 | if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME)) |
||
258 | return false; |
||
259 | else |
||
260 | return SetChildSymbolMapping(childSymbol); |
||
261 | } |
||
262 | |||
263 | return true; |
||
264 | } |
||
265 | bca86986 | gaqhf | } |
266 | } |