hytos / DTI_PID / SPPIDConverter / Model / SPPID_Document.cs @ 1a3a74a8
이력 | 보기 | 이력해설 | 다운로드 (10.7 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Data; |
7 |
using Converter.BaseModel; |
8 |
using Converter.SPPID.Util; |
9 |
|
10 |
namespace Converter.SPPID.Model |
11 |
{ |
12 |
public class SPPID_Document : Document |
13 |
{ |
14 |
public SPPID_Document(string xmlPath) : base(xmlPath) |
15 |
{ |
16 |
|
17 |
} |
18 |
|
19 |
private double testX = 0.855; |
20 |
private double testY = 0.55; |
21 |
|
22 |
public List<SymbolMapping> SymbolMappings; |
23 |
public List<ChildSymbolMapping> ChildSymbolMappings; |
24 |
public List<LineMapping> LineMappings; |
25 |
public List<LineNumberMapping> LineNumberMappings; |
26 |
public List<AttributeMapping> AttributeMappings; |
27 |
public ETCSetting ETCSetting; |
28 |
|
29 |
public List<Group> GROUPS = new List<Group>(); |
30 |
|
31 |
public string DrawingName { get; set; } |
32 |
public string DrawingNumber { get; set; } |
33 |
public string Unit { get; set; } |
34 |
public string Template { get; set; } |
35 |
|
36 |
|
37 |
public void SetSPPIDInfo() |
38 |
{ |
39 |
foreach (var item in SYMBOLS) |
40 |
{ |
41 |
if (item.SPPID == null) |
42 |
item.SPPID = new SPPIDSymbolInfo(); |
43 |
double x = double.NaN; |
44 |
double y = double.NaN; |
45 |
SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
46 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
47 |
item.SPPID.ORIGINAL_X = x; |
48 |
item.SPPID.ORIGINAL_Y = y; |
49 |
|
50 |
foreach (var childSymbol in item.ChildSymbols) |
51 |
{ |
52 |
if (childSymbol.SPPID == null) |
53 |
childSymbol.SPPID = new SPPIDSymbolInfo(); |
54 |
SetChildSymbolSPPIDInfo(childSymbol); |
55 |
} |
56 |
} |
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 |
|
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 |
|
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 |
|
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 |
|
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 |
} |
123 |
|
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 |
|
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 |
} |
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 |
|
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 |
} |
171 |
} |
172 |
|
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 |
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 |
|
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 |
} |
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 |
} |
208 |
|
209 |
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 |
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 |
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 |
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 |
|
248 |
return true; |
249 |
} |
250 |
|
251 |
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 |
} |
266 |
} |