프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (28.6 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 7e680366 gaqhf
        public SPPID_Document(string xmlPath, DataTable ID2SymbolTypeDT) : base(xmlPath, ID2SymbolTypeDT)
15 bca86986 gaqhf
        {
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 7e680366 gaqhf
        
26 4d2571ab gaqhf
        public DataTable SymbolTable { get; set; }
27 39a2a688 gaqhf
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 88bac50c gaqhf
        public string SPPID_DrawingNumber { get; set; }
35
        public string SPPID_DrawingName { get; set; }
36 4f0c0ed6 gaqhf
        public string BulkAttributeName { get; set; }
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 4b4dbca9 gaqhf
44
                foreach (var childSymbol in item.ChildSymbols)
45
                {
46
                    if (childSymbol.SPPID == null)
47
                        childSymbol.SPPID = new SPPIDSymbolInfo();
48
                    SetChildSymbolSPPIDInfo(childSymbol);
49
                }
50 39a2a688 gaqhf
            }
51
52
            foreach (var item in LINES)
53
            {
54
                if (item.SPPID == null)
55
                    item.SPPID = new SPPIDLineInfo();
56 1ba9c671 gaqhf
            }
57
58
            foreach (var item in Equipments)
59
            {
60
                if (item.SPPID == null)
61
                    item.SPPID = new SPPIDSymbolInfo();
62
            }
63
64
            foreach (var item in EndBreaks)
65
            {
66
                if (item.SPPID == null)
67
                    item.SPPID = new SPPIDSymbolInfo();
68
            }
69
70 53c81765 gaqhf
            foreach (var item in SpecBreaks)
71
            {
72
                if (item.SPPID == null)
73
                    item.SPPID = new SPPIDSymbolInfo();
74
            }
75
76 1ba9c671 gaqhf
            foreach (var item in LINENUMBERS)
77
            {
78
                if (item.SPPID == null)
79
                    item.SPPID = new SPPIDSymbolInfo();
80
            }
81
82
            foreach (var item in TEXTINFOS)
83
            {
84
                if (item.SPPID == null)
85
                    item.SPPID = new SPPIDSymbolInfo();
86
            }
87
88
            foreach (var item in NOTES)
89
            {
90
                if (item.SPPID == null)
91
                    item.SPPID = new SPPIDSymbolInfo();
92
            }
93 45af3335 Denny
94
            foreach (var item in Graphics)
95
            {
96
                if (item.SPPID == null)
97
                    item.SPPID = new SPPIDSymbolInfo();
98
            }
99 1ba9c671 gaqhf
        }
100
101
        public void SetSPPIDLocation(double SPPIDDocumentX, double SPPIDDocumentY)
102
        {
103
            foreach (var item in SYMBOLS)
104
            {
105
                double x = double.NaN;
106
                double y = double.NaN;
107
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
108
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
109 06b40010 gaqhf
110 1ba9c671 gaqhf
                item.SPPID.ORIGINAL_X = x;
111
                item.SPPID.ORIGINAL_Y = y;
112
            }
113
114
            foreach (var item in LINES)
115
            {
116 a0e3dca4 gaqhf
                double startX = double.NaN;
117
                double startY = double.NaN;
118 39a2a688 gaqhf
119 a0e3dca4 gaqhf
                SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref startX, ref startY);
120
                SPPIDUtil.ConvertSPPIDPoint(ref startX, ref startY, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
121
                item.SPPID.START_X = startX;
122
                item.SPPID.START_Y = startY;
123 39a2a688 gaqhf
124 a0e3dca4 gaqhf
                double endX = double.NaN;
125
                double endY = double.NaN;
126
127
                SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref endX, ref endY);
128
                SPPIDUtil.ConvertSPPIDPoint(ref endX, ref endY, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
129
                item.SPPID.END_X = endX;
130
                item.SPPID.END_Y = endY;
131
132
                item.SlopeType = SPPIDUtil.CalcSlope(startX, startY, endX, endY);
133 39a2a688 gaqhf
            }
134 809a7640 gaqhf
135
            foreach (var item in Equipments)
136
            {
137
                double x = double.NaN;
138
                double y = double.NaN;
139
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
140 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
141 06b40010 gaqhf
142 809a7640 gaqhf
                item.SPPID.ORIGINAL_X = x;
143
                item.SPPID.ORIGINAL_Y = y;
144
            }
145 3165c259 gaqhf
146
            foreach (var item in EndBreaks)
147
            {
148
                double x = double.NaN;
149
                double y = double.NaN;
150
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
151 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
152 3165c259 gaqhf
                item.SPPID.ORIGINAL_X = x;
153
                item.SPPID.ORIGINAL_Y = y;
154
            }
155 10872260 gaqhf
156 53c81765 gaqhf
            foreach (var item in SpecBreaks)
157
            {
158
                double x = double.NaN;
159
                double y = double.NaN;
160
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
161
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
162
163
                item.SPPID.ORIGINAL_X = x;
164
                item.SPPID.ORIGINAL_Y = y;
165
            }
166
167 10872260 gaqhf
            foreach (var item in LINENUMBERS)
168
            {
169
                double x = double.NaN;
170
                double y = double.NaN;
171
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
172 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
173 10872260 gaqhf
                item.SPPID.ORIGINAL_X = x;
174
                item.SPPID.ORIGINAL_Y = y;
175 1a3a74a8 gaqhf
176 45af3335 Denny
                item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
177 1a3a74a8 gaqhf
                double x1 = item.X1;
178
                double y1 = item.Y1;
179
                double x2 = item.X2;
180
                double y2 = item.Y2;
181 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
182
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
183 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
184
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
185
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
186
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
187 10872260 gaqhf
            }
188 6b298450 gaqhf
189
            foreach (var item in TEXTINFOS)
190
            {
191
                double x = double.NaN;
192
                double y = double.NaN;
193
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
194 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
195 6b298450 gaqhf
                item.SPPID.ORIGINAL_X = x;
196
                item.SPPID.ORIGINAL_Y = y;
197 1a3a74a8 gaqhf
198 45af3335 Denny
                item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
199 1a3a74a8 gaqhf
                double x1 = item.X1;
200
                double y1 = item.Y1;
201
                double x2 = item.X2;
202
                double y2 = item.Y2;
203 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
204
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
205 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
206
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
207
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
208
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
209 6b298450 gaqhf
            }
210
211
            foreach (var item in NOTES)
212
            {
213
                double x = double.NaN;
214
                double y = double.NaN;
215
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
216 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
217 6b298450 gaqhf
                item.SPPID.ORIGINAL_X = x;
218
                item.SPPID.ORIGINAL_Y = y;
219 1a3a74a8 gaqhf
220 45af3335 Denny
                item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
221 1a3a74a8 gaqhf
                double x1 = item.X1;
222
                double y1 = item.Y1;
223
                double x2 = item.X2;
224
                double y2 = item.Y2;
225 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
226
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
227 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
228
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
229
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
230
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
231 6b298450 gaqhf
            }
232 fb2d9638 gaqhf
233
            foreach (var item in VendorPackages)
234
            {
235
                double x = item.CenterPoint[0];
236
                double y = item.CenterPoint[1];
237
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
238
                item.SPPID.ORIGINAL_X = x;
239
                item.SPPID.ORIGINAL_Y = y;
240
            }
241 45af3335 Denny
242
            foreach (var item in Graphics)
243
            {
244
                item.SPPIDGraphicLocation = new SPPIDEtcLocationInfo();
245
                double x1 = item.X1;
246
                double y1 = item.Y1;
247
                double x2 = item.X2;
248
                double y2 = item.Y2;
249
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
250
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
251
                item.SPPIDGraphicLocation.X1 = Math.Min(x1, x2);
252
                item.SPPIDGraphicLocation.Y1 = Math.Min(y1, y2);
253
                item.SPPIDGraphicLocation.X2 = Math.Max(x1, x2);
254
                item.SPPIDGraphicLocation.Y2 = Math.Max(y1, y2);
255
            }
256 39a2a688 gaqhf
        }
257 4b4dbca9 gaqhf
258 c01ce90b gaqhf
        /// <summary>
259
        /// 좌표 보정
260
        /// </summary>
261
        public void CoordinateCorrection()
262
        {
263 20f9fa83 Denny
            List<Symbol> symbols = SYMBOLS;
264
            symbols.Sort(SPPIDUtil.SortSymbolPriority);
265
            foreach (Symbol symbol in symbols)
266 c01ce90b gaqhf
            {
267
                if (!symbol.SPPID.IsCorrectionX)
268
                {
269
                    List<object> group = new List<object>();
270
                    group.Add(symbol);
271
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.VERTICAL);
272
273
                    List<Symbol> groupSymbols = (from sym in @group
274
                                                 where sym.GetType() == typeof(Symbol)
275 20f9fa83 Denny
                                                 select sym as Symbol).OrderBy(o => o.SPPID.ORIGINAL_Y).ToList();
276 c01ce90b gaqhf
277
                    // X 좌표만 보정
278
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionX);
279
                    double value = symbol.SPPID.ORIGINAL_X;
280
                    if (correctionSymbol == null)
281
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
282
                    else
283
                        value = correctionSymbol.SPPID.ORIGINAL_X;
284
285 20f9fa83 Denny
                    for (int i = 0; i < groupSymbols.Count; i++)
286 c01ce90b gaqhf
                    {
287 20f9fa83 Denny
                        var item = groupSymbols[i];
288
                    
289 c01ce90b gaqhf
                        item.SPPID.IsCorrectionX = true;
290
                        item.SPPID.ORIGINAL_X = value;
291 20f9fa83 Denny
                        item.SPPID.CorrectionX_GroupSymbols = groupSymbols;                    
292
293
                        if (i > 1)
294
                        {
295
                            double pGap = groupSymbols[i - 2].SPPID.ORIGINAL_Y - groupSymbols[i - 1].SPPID.ORIGINAL_Y;
296
                            double cGap = groupSymbols[i - 1].SPPID.ORIGINAL_Y - groupSymbols[i].SPPID.ORIGINAL_Y;
297
                            if (SPPIDUtil.EqualSpacing(pGap, cGap))
298
                                item.SPPID.IsEqualSpacingY = true;
299
                        }
300 c01ce90b gaqhf
                    }
301
                }
302
303
                if (!symbol.SPPID.IsCorrectionY)
304
                {
305
                    List<object> group = new List<object>();
306
                    group.Add(symbol);
307
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.HORIZONTAL);
308
309
                    List<Symbol> groupSymbols = (from sym in @group
310
                                                 where sym.GetType() == typeof(Symbol)
311 20f9fa83 Denny
                                                 select sym as Symbol).OrderBy(o => o.SPPID.ORIGINAL_X).ToList();
312 c01ce90b gaqhf
313
                    // Y 좌표만 보정
314
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionY);
315
                    double value = symbol.SPPID.ORIGINAL_Y;
316
                    if (correctionSymbol == null)
317
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
318
                    else
319
                        value = correctionSymbol.SPPID.ORIGINAL_Y;
320
321 20f9fa83 Denny
                    for (int i = 0; i < groupSymbols.Count; i++)
322 c01ce90b gaqhf
                    {
323 20f9fa83 Denny
                        var item = groupSymbols[i];
324
                    
325 c01ce90b gaqhf
                        item.SPPID.IsCorrectionY = true;
326
                        item.SPPID.ORIGINAL_Y = value;
327 d9794a6c gaqhf
                        item.SPPID.CorrectionY_GroupSymbols = groupSymbols;
328 20f9fa83 Denny
329
                        if (i > 1)
330
                        {
331
                            double pGap = groupSymbols[i - 2].SPPID.ORIGINAL_X - groupSymbols[i - 1].SPPID.ORIGINAL_X;
332
                            double cGap = groupSymbols[i - 1].SPPID.ORIGINAL_X - groupSymbols[i].SPPID.ORIGINAL_X;
333
                            if (SPPIDUtil.EqualSpacing(pGap, cGap))
334
                                item.SPPID.IsEqualSpacingX = true;
335
                        }
336 c01ce90b gaqhf
                    }
337
                }
338
            }
339 a0e3dca4 gaqhf
340
            foreach (Line line in LINES)
341
            {
342
                double tempX = line.SPPID.START_X;
343
                double tempY = line.SPPID.START_Y;
344
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
345
                line.SPPID.START_X = tempX;
346
                line.SPPID.START_Y = tempY;
347
348
                tempX = line.SPPID.END_X;
349
                tempY = line.SPPID.END_Y;
350
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
351
                line.SPPID.END_X = tempX;
352
                line.SPPID.END_Y = tempY;
353
354
                if (line.SlopeType == SlopeType.HORIZONTAL)
355
                    line.SPPID.END_Y = line.SPPID.START_Y;
356
                else if (line.SlopeType == SlopeType.VERTICAL)
357
                    line.SPPID.END_X = line.SPPID.START_X;
358
            }
359 c01ce90b gaqhf
        }
360
361
        private void FindGroupBySymbolAndSlopeType(Symbol symbol, List<object> group, SlopeType searchType)
362
        {
363
            foreach (var connector in symbol.CONNECTORS)
364
            {
365
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
366
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
367
                {
368
                    Symbol connSymbol = connectedItem as Symbol;
369
                    SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y);
370
                    if (slopeType == searchType)
371
                    {
372
                        if (!group.Contains(connSymbol))
373
                        {
374
                            group.Add(connSymbol);
375
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
376
                        }
377
                    }
378
                }
379
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
380
                {
381
                    Line connLine = connectedItem as Line;
382 02480ac1 gaqhf
383 1ed39474 gaqhf
                    Connector otherConnector = connLine.CONNECTORS.Find(x => x.CONNECTEDITEM != symbol.UID);
384 f1a7faf9 gaqhf
                    int connectorIndex = connLine.CONNECTORS.IndexOf(otherConnector);
385 02480ac1 gaqhf
                    double lineX = double.NaN;
386
                    double lineY = double.NaN;
387
                    // Symbol의 Connector ScenePoint
388 f1a7faf9 gaqhf
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? connLine.STARTPOINT : connLine.ENDPOINT, ref lineX, ref lineY);
389 02480ac1 gaqhf
                    double symbolX = double.NaN;
390
                    double symbolY = double.NaN;
391
                    SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref symbolX, ref symbolY);
392
393
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
394 c01ce90b gaqhf
                    if (slopeType == searchType)
395
                    {
396
                        if (!group.Contains(connLine))
397
                        {
398
                            group.Add(connLine);
399
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
400
                        }
401
                    }
402
                }
403
            }
404
        }
405
406 f1a7faf9 gaqhf
        private void FindGroupByLineAndSlopeType(Line line, List<object> group, SlopeType searchType)
407 c01ce90b gaqhf
        {
408 f1a7faf9 gaqhf
            foreach (var connector in line.CONNECTORS)
409 c01ce90b gaqhf
            {
410
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
411
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
412
                {
413
                    Symbol connSymbol = connectedItem as Symbol;
414 02480ac1 gaqhf
415 f1a7faf9 gaqhf
                    Connector otherConnector = line.CONNECTORS.Find(x => x.CONNECTEDITEM != connSymbol.UID);
416
                    int connectorIndex = line.CONNECTORS.IndexOf(otherConnector);
417 c01ce90b gaqhf
                    double lineX = double.NaN;
418
                    double lineY = double.NaN;
419 02480ac1 gaqhf
                    // Line의 Connector ScenePoint
420 f1a7faf9 gaqhf
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? line.STARTPOINT : line.ENDPOINT, ref lineX, ref lineY);
421 c01ce90b gaqhf
                    double symbolX = double.NaN;
422
                    double symbolY = double.NaN;
423
                    SPPIDUtil.ConvertPointBystring(connSymbol.ORIGINALPOINT, ref symbolX, ref symbolY);
424
425
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
426
                    if (slopeType == searchType)
427
                    {
428
                        if (!group.Contains(connSymbol))
429
                        {
430
                            group.Add(connSymbol);
431
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
432
                        }
433
                    }
434
                }
435
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
436
                {
437
                    Line connLine = connectedItem as Line;
438
                    SlopeType slopeType = SPPIDUtil.CalcSlope(connLine.SPPID.START_X, connLine.SPPID.START_Y, connLine.SPPID.END_X, connLine.SPPID.END_Y);
439
                    if (slopeType == searchType)
440
                    {
441
                        if (!group.Contains(connLine))
442
                        {
443
                            group.Add(connLine);
444
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
445
                        }
446
                    }
447
                }
448
            }
449
        }
450
451 4b4dbca9 gaqhf
        private void SetChildSymbolSPPIDInfo(ChildSymbol item)
452
        {
453
            foreach (var childSymbol in item.ChildSymbols)
454
            {
455
                if (childSymbol.SPPID == null)
456
                    childSymbol.SPPID = new SPPIDSymbolInfo();
457
                SetChildSymbolSPPIDInfo(childSymbol);
458
            }
459
        }
460
      
461 39a2a688 gaqhf
        public bool SetSPPIDMapping()
462
        {
463 68e9394a gaqhf
            bool result = true;
464
            StringBuilder sb = new StringBuilder();
465 39a2a688 gaqhf
            foreach (var item in SYMBOLS)
466
            {
467
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
468
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
469
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
470 68e9394a gaqhf
                {
471
                    result = false;
472
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
473
                }
474
                    
475 4b4dbca9 gaqhf
476
                foreach (var childSymbol in item.ChildSymbols)
477
                {
478
                    ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
479
                    childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
480
                    if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol))
481 68e9394a gaqhf
                    {
482
                        result = false;
483
                        sb.AppendLine("Need Mapping Symbol Name : " + childSymbol.NAME);
484
                    }
485 4b4dbca9 gaqhf
                }
486 39a2a688 gaqhf
            }
487
488
            foreach (var item in LINES)
489
            {
490
                LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID);
491
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
492
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
493 68e9394a gaqhf
                {
494
                    result = false;
495
                    sb.AppendLine("Need Mapping Line Type : " + item.TYPE);
496
                }
497 f947c634 gaqhf
            }
498
499 809a7640 gaqhf
            foreach (var item in Equipments)
500
            {
501
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
502
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
503
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
504 68e9394a gaqhf
                {
505
                    result = false;
506
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
507
                }
508 809a7640 gaqhf
            }
509
510 3165c259 gaqhf
            foreach (var item in EndBreaks)
511
            {
512
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
513
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
514
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
515 68e9394a gaqhf
                {
516
                    result = false;
517
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
518
                }
519 3165c259 gaqhf
            }
520
521 10872260 gaqhf
            foreach (var item in LINENUMBERS)
522
            {
523
                if (LineNumberMappings.Count > 0)
524
                    item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME;
525
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
526 68e9394a gaqhf
                {
527
                    result = false;
528
                    sb.AppendLine("Need Mapping LineNumber Mapping");
529
                }
530 10872260 gaqhf
            }
531
532 6b298450 gaqhf
            ETCSetting etc = ETCSetting.GetInstance();
533
            foreach (var item in NOTES)
534
            {
535
                item.SPPID.MAPPINGNAME = etc.NoteSymbolPath;
536
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
537 68e9394a gaqhf
                {
538
                    result = false;
539
                    sb.AppendLine("Need Mapping Note Mapping");
540
                }
541 6b298450 gaqhf
            }
542
543
            foreach (var item in TEXTINFOS)
544
            {
545
                item.SPPID.MAPPINGNAME = etc.TextSymbolPath;
546
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
547 68e9394a gaqhf
                {
548
                    result = false;
549
                    sb.AppendLine("Need Mapping Text Mapping");
550
                }
551 6b298450 gaqhf
            }
552 4b4dbca9 gaqhf
553 68e9394a gaqhf
            if (!result)
554
                ValidationMessage += sb.ToString();
555 5673a69f gaqhf
            else
556
                MappingValidation = true;
557 68e9394a gaqhf
558
            return result;
559 f947c634 gaqhf
        }
560 5dfb8a24 gaqhf
561 4b4dbca9 gaqhf
        private bool SetChildSymbolMapping(ChildSymbol item)
562
        {
563 6eea0b00 esham21
            bool res = true;
564
565 4b4dbca9 gaqhf
            foreach (var childSymbol in item.ChildSymbols)
566
            {
567
                ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
568
                childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
569
                if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME))
570
                    return false;
571
                else
572 6eea0b00 esham21
                {
573
                    res = SetChildSymbolMapping(childSymbol);
574
                    if (!res)
575
                        return false;
576
                }                    
577 4b4dbca9 gaqhf
            }
578
579 6eea0b00 esham21
            return res;
580 4b4dbca9 gaqhf
        }
581 30ba9ae0 gaqhf
582
        public void CheckModelingResult()
583
        {
584
            StringBuilder sb = new StringBuilder();
585
            sb.AppendLine("Modeling Result");
586 c24d977b gaqhf
            int failSymbolCnt = 0;
587
            int failLineCnt = 0;
588 8fbc78be gaqhf
            int failTextCnt = 0;
589 45af3335 Denny
            int failGraphicCnt = 0;
590 30ba9ae0 gaqhf
            foreach (var item in Equipments)
591
            {
592
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
593 c24d977b gaqhf
                {
594 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Equipment Modeling UID : " + item.UID);
595 c24d977b gaqhf
                    failSymbolCnt++;
596
                }
597 30ba9ae0 gaqhf
            }
598
            foreach (var item in SYMBOLS)
599
            {
600
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
601 c24d977b gaqhf
                {
602 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Symbol Modeling UID : " + item.UID);
603 c24d977b gaqhf
                    failSymbolCnt++;
604
                }
605 30ba9ae0 gaqhf
                foreach (var child in item.ChildSymbols)
606
                {
607
                    if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
608
                    {
609
                        sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
610
                        sb.AppendLine("Fail Child Symbol Name : " + child.NAME);
611
                    }
612
                    loop(child, item, sb);
613
                }
614
            }
615
            foreach (var item in LINES)
616
            {
617
                if (string.IsNullOrEmpty(item.SPPID.ModelItemId))
618 c24d977b gaqhf
                {
619 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Line Modeling UID : " + item.UID);
620 c24d977b gaqhf
                    failLineCnt++;
621
                }
622 30ba9ae0 gaqhf
            }
623
            foreach (var item in LINENUMBERS)
624
            {
625
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
626
                    sb.AppendLine("Fail Line Number Modeling UID : " + item.UID);
627
            }
628
            foreach (var item in NOTES)
629
            {
630
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
631 8fbc78be gaqhf
                {
632 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Note Text Modeling UID : " + item.UID);
633 8fbc78be gaqhf
                    failTextCnt++;
634
                }
635 30ba9ae0 gaqhf
            }
636
            foreach (var item in TEXTINFOS)
637
            {
638
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
639 8fbc78be gaqhf
                {
640 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Text Modeling UID : " + item.UID);
641 8fbc78be gaqhf
                    failTextCnt++;
642
                }
643 30ba9ae0 gaqhf
            }
644
            foreach (var item in EndBreaks)
645
            {
646
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
647 c24d977b gaqhf
                {
648 30ba9ae0 gaqhf
                    sb.AppendLine("Fail End Break Modeling UID : " + item.UID);
649 c24d977b gaqhf
                    failSymbolCnt++;
650
                }
651 30ba9ae0 gaqhf
            }
652
            foreach (var item in SpecBreaks)
653
            {
654
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
655 c24d977b gaqhf
                {
656 30ba9ae0 gaqhf
                    sb.AppendLine("Fail SpecBreak Modeling UID : " + item.UID);
657 c24d977b gaqhf
                    failSymbolCnt++;
658
                }
659 30ba9ae0 gaqhf
            }
660 45af3335 Denny
            foreach (var item in Graphics)
661
            {
662
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
663
                {
664
                    sb.AppendLine("Fail Grphic Modeling UID : " + item.UID);
665
                    failGraphicCnt++;
666
                }
667
            }
668 30ba9ae0 gaqhf
            sb.AppendLine("End Modeling Result");
669 fa24d104 gaqhf
            Log.Write(sb.ToString());
670 c24d977b gaqhf
671 45af3335 Denny
            int allSymbol = Equipments.Count + SYMBOLS.Count + EndBreaks.Count + SpecBreaks.Count + Graphics.Count;
672 97a6ee26 gaqhf
673
            Log.Write("Success Symbol Modeling : " + (allSymbol - failSymbolCnt));
674
            Log.Write("Fail Symbol Modeling : " + failSymbolCnt);
675
            Log.Write("Success Line Modeling : " + (LINES.Count - failLineCnt));
676
            Log.Write("Fail Line Modeling : " + failLineCnt);
677 8fbc78be gaqhf
            Log.Write("Success Text/Note Modeling : " + (TEXTINFOS.Count + NOTES.Count - failTextCnt));
678
            Log.Write("Fail Text/Note Modeling : " + failTextCnt);
679 45af3335 Denny
            Log.Write("Success Graphic Modeling : " + (Graphics.Count - failGraphicCnt));
680
            Log.Write("Fail Graphic Modeling : " + failGraphicCnt);
681 30ba9ae0 gaqhf
        }
682
683
        private void loop(ChildSymbol childLoop, Symbol item, StringBuilder sb)
684
        {
685
            foreach (var childLoopLoop in childLoop.ChildSymbols)
686
            {
687
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
688
                {
689
                    sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
690
                    sb.AppendLine("Fail Child Symbol Name : " + childLoopLoop.NAME);
691
                }
692 3c8e40a5 gaqhf
                loop(childLoopLoop, item, sb);
693 30ba9ae0 gaqhf
            }
694
        }
695 bca86986 gaqhf
    }
696
}
클립보드 이미지 추가 (최대 크기: 500 MB)