프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / SPPIDConverter / SPPIDModel / SPPID_Document.cs @ cf924377

이력 | 보기 | 이력해설 | 다운로드 (12.5 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
        public List<SymbolMapping> SymbolMappings;
20 4b4dbca9 gaqhf
        public List<ChildSymbolMapping> ChildSymbolMappings;
21 39a2a688 gaqhf
        public List<LineMapping> LineMappings;
22
        public List<LineNumberMapping> LineNumberMappings;
23 1efc25a3 gaqhf
        public List<AttributeMapping> AttributeMappings;
24 39a2a688 gaqhf
        public ETCSetting ETCSetting;
25
26 f1c9dbaa gaqhf
        public List<Group> GROUPS = new List<Group>();
27 5dfb8a24 gaqhf
28 bca86986 gaqhf
        public string DrawingName { get; set; }
29
        public string DrawingNumber { get; set; }
30
        public string Unit { get; set; }
31 4314b3f3 gaqhf
        public string Template { get; set; }
32 f947c634 gaqhf
33
        public void SetSPPIDInfo()
34
        {
35
            foreach (var item in SYMBOLS)
36
            {
37 39a2a688 gaqhf
                if (item.SPPID == null)
38
                    item.SPPID = new SPPIDSymbolInfo();
39 4b4dbca9 gaqhf
40
                foreach (var childSymbol in item.ChildSymbols)
41
                {
42
                    if (childSymbol.SPPID == null)
43
                        childSymbol.SPPID = new SPPIDSymbolInfo();
44
                    SetChildSymbolSPPIDInfo(childSymbol);
45
                }
46 39a2a688 gaqhf
            }
47
48
            foreach (var item in LINES)
49
            {
50
                if (item.SPPID == null)
51
                    item.SPPID = new SPPIDLineInfo();
52 1ba9c671 gaqhf
            }
53
54
            foreach (var item in Equipments)
55
            {
56
                if (item.SPPID == null)
57
                    item.SPPID = new SPPIDSymbolInfo();
58
            }
59
60
            foreach (var item in EndBreaks)
61
            {
62
                if (item.SPPID == null)
63
                    item.SPPID = new SPPIDSymbolInfo();
64
            }
65
66
            foreach (var item in LINENUMBERS)
67
            {
68
                if (item.SPPID == null)
69
                    item.SPPID = new SPPIDSymbolInfo();
70
            }
71
72
            foreach (var item in TEXTINFOS)
73
            {
74
                if (item.SPPID == null)
75
                    item.SPPID = new SPPIDSymbolInfo();
76
            }
77
78
            foreach (var item in NOTES)
79
            {
80
                if (item.SPPID == null)
81
                    item.SPPID = new SPPIDSymbolInfo();
82
            }
83
        }
84
85
        public void SetSPPIDLocation(double SPPIDDocumentX, double SPPIDDocumentY)
86
        {
87
            foreach (var item in SYMBOLS)
88
            {
89
                double x = double.NaN;
90
                double y = double.NaN;
91
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
92
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
93
                item.SPPID.ORIGINAL_X = x;
94
                item.SPPID.ORIGINAL_Y = y;
95
            }
96
97
            foreach (var item in LINES)
98
            {
99 39a2a688 gaqhf
                double x = double.NaN;
100
                double y = double.NaN;
101
102
                SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref x, ref y);
103 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
104 39a2a688 gaqhf
                item.SPPID.START_X = x;
105
                item.SPPID.START_Y = y;
106
107
                SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref x, ref y);
108 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
109 39a2a688 gaqhf
                item.SPPID.END_X = x;
110
                item.SPPID.END_Y = y;
111
            }
112 809a7640 gaqhf
113
            foreach (var item in Equipments)
114
            {
115
                double x = double.NaN;
116
                double y = double.NaN;
117
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
118 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
119 809a7640 gaqhf
                item.SPPID.ORIGINAL_X = x;
120
                item.SPPID.ORIGINAL_Y = y;
121
            }
122 3165c259 gaqhf
123
            foreach (var item in EndBreaks)
124
            {
125
                double x = double.NaN;
126
                double y = double.NaN;
127
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
128 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
129 3165c259 gaqhf
                item.SPPID.ORIGINAL_X = x;
130
                item.SPPID.ORIGINAL_Y = y;
131
            }
132 10872260 gaqhf
133
            foreach (var item in LINENUMBERS)
134
            {
135
                double x = double.NaN;
136
                double y = double.NaN;
137
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
138 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
139 10872260 gaqhf
                item.SPPID.ORIGINAL_X = x;
140
                item.SPPID.ORIGINAL_Y = y;
141 1a3a74a8 gaqhf
142
                item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
143
                double x1 = item.X1;
144
                double y1 = item.Y1;
145
                double x2 = item.X2;
146
                double y2 = item.Y2;
147 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
148
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
149 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
150
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
151
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
152
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
153 10872260 gaqhf
            }
154 6b298450 gaqhf
155
            foreach (var item in TEXTINFOS)
156
            {
157
                double x = double.NaN;
158
                double y = double.NaN;
159
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
160 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
161 6b298450 gaqhf
                item.SPPID.ORIGINAL_X = x;
162
                item.SPPID.ORIGINAL_Y = y;
163 1a3a74a8 gaqhf
164
                item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
165
                double x1 = item.X1;
166
                double y1 = item.Y1;
167
                double x2 = item.X2;
168
                double y2 = item.Y2;
169 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
170
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
171 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
172
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
173
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
174
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
175 6b298450 gaqhf
            }
176
177
            foreach (var item in NOTES)
178
            {
179
                double x = double.NaN;
180
                double y = double.NaN;
181
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
182 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
183 6b298450 gaqhf
                item.SPPID.ORIGINAL_X = x;
184
                item.SPPID.ORIGINAL_Y = y;
185 1a3a74a8 gaqhf
186
                item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
187
                double x1 = item.X1;
188
                double y1 = item.Y1;
189
                double x2 = item.X2;
190
                double y2 = item.Y2;
191 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
192
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
193 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
194
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
195
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
196
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
197 6b298450 gaqhf
            }
198 39a2a688 gaqhf
        }
199 4b4dbca9 gaqhf
200
        private void SetChildSymbolSPPIDInfo(ChildSymbol item)
201
        {
202
            foreach (var childSymbol in item.ChildSymbols)
203
            {
204
                if (childSymbol.SPPID == null)
205
                    childSymbol.SPPID = new SPPIDSymbolInfo();
206
                SetChildSymbolSPPIDInfo(childSymbol);
207
            }
208
        }
209
      
210 39a2a688 gaqhf
        public bool SetSPPIDMapping()
211
        {
212
            foreach (var item in SYMBOLS)
213
            {
214
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
215
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
216
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
217
                    return false;
218 4b4dbca9 gaqhf
219
                foreach (var childSymbol in item.ChildSymbols)
220
                {
221
                    ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
222
                    childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
223
                    if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol))
224
                        return false;
225
                }
226 39a2a688 gaqhf
            }
227
228
            foreach (var item in LINES)
229
            {
230
                LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID);
231
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
232
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
233
                    return false;
234 f947c634 gaqhf
            }
235
236 809a7640 gaqhf
            foreach (var item in Equipments)
237
            {
238
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
239
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
240
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
241
                    return false;
242
            }
243
244 3165c259 gaqhf
            foreach (var item in EndBreaks)
245
            {
246
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
247
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
248
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
249
                    return false;
250
            }
251
252 10872260 gaqhf
            foreach (var item in LINENUMBERS)
253
            {
254
                if (LineNumberMappings.Count > 0)
255
                    item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME;
256
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
257
                    return false;
258
            }
259
260 6b298450 gaqhf
            ETCSetting etc = ETCSetting.GetInstance();
261
            foreach (var item in NOTES)
262
            {
263
                item.SPPID.MAPPINGNAME = etc.NoteSymbolPath;
264
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
265
                    return false;
266
            }
267
268
            foreach (var item in TEXTINFOS)
269
            {
270
                item.SPPID.MAPPINGNAME = etc.TextSymbolPath;
271
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
272
                    return false;
273
            }
274 4b4dbca9 gaqhf
275 39a2a688 gaqhf
            return true;
276 f947c634 gaqhf
        }
277 5dfb8a24 gaqhf
278 1ba9c671 gaqhf
        public void ConvertSPPIDPoint(ref double dX, ref double dY, double dDwgX, double dDwgY, double SPPID_Width, double SPPID_Height)
279
        {
280
            decimal calcX = 0;
281
            decimal calcY = 0;
282
            decimal tempX = Convert.ToDecimal(dX);
283
            decimal tempY = Convert.ToDecimal(dY);
284
            decimal tempWidth = Convert.ToDecimal(SPPID_Width);
285
            decimal tempHeight = Convert.ToDecimal(SPPID_Height);
286
            decimal tempDwgX = Convert.ToDecimal(dDwgX);
287
            decimal tempDwgY = Convert.ToDecimal(dDwgY);
288
289
            //calcX = (tempX * tempWidth) / tempDwgX;
290
            //calcX = Math.Truncate(calcX * 1000) / 1000;
291
            //calcY = tempHeight - ((tempY * tempHeight) / tempDwgY);
292
            //calcY = Math.Truncate(calcY * 1000) / 1000;
293
            //dX = Math.Round(Convert.ToDouble(calcX), 10);
294
            //dY = Math.Round(Convert.ToDouble(calcY), 10);
295
296
            calcX = (tempX * tempWidth) / tempDwgX;
297
            calcY = tempHeight - ((tempY * tempHeight) / tempDwgY);
298
            dX = Convert.ToDouble(calcX);
299
            dY = Convert.ToDouble(calcY);
300
        }
301
302 4b4dbca9 gaqhf
        private bool SetChildSymbolMapping(ChildSymbol item)
303
        {
304
            foreach (var childSymbol in item.ChildSymbols)
305
            {
306
                ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
307
                childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
308
                if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME))
309
                    return false;
310
                else
311
                    return SetChildSymbolMapping(childSymbol);
312
            }
313
314
            return true;
315
        }
316 bca86986 gaqhf
    }
317
}
클립보드 이미지 추가 (최대 크기: 500 MB)