프로젝트

일반

사용자정보

개정판 f1c9dbaa

IDf1c9dbaa013712d490f6dc2447174205610e4966
상위 7af9b30c
하위 33ed83c7, 809a7640

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #000 : ID2 Line Number 기준 모델링 및 Equipment, EndBreak 구별

Change-Id: Ifd40906e19bbee1579306fb7620cc739d4268916

차이점 보기:

DTI_PID/BaseModel/BaseModel.csproj
79 79
  </ItemGroup>
80 80
  <ItemGroup>
81 81
    <Compile Include="Model\ChildSymbol.cs" />
82
    <Compile Include="Model\Equipment.cs" />
82 83
    <Compile Include="Model\Other\Association.cs" />
83 84
    <Compile Include="Model\Other\Attribute.cs" />
84 85
    <Compile Include="Model\Other\Connector.cs" />
......
86 87
    <Compile Include="Model\Other\Property.cs" />
87 88
    <Compile Include="Model\SPPID\SPPIDLineInfo.cs" />
88 89
    <Compile Include="Model\SPPID\SPPIDSymbolInfo.cs" />
90
    <Compile Include="Model\EndBreak.cs" />
89 91
    <Compile Include="Project_DB.cs" />
90 92
    <Compile Include="Project_Info.cs" />
91 93
    <Compile Include="Model\Document.cs" />
DTI_PID/BaseModel/Model/Document.cs
20 20
        private List<Note> _NOTES = new List<Note>();
21 21
        private List<Line> _LINES = new List<Line>();
22 22
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
23
        private List<EndBreak> _EndBreaks = new List<EndBreak>();
24
        private List<Equipment> _Equipments = new List<Equipment>();
23 25
        private bool _Enable;
24 26

  
25 27
        public bool Enable { get { return _Enable; } }
......
29 31
        public List<Note> NOTES { get => _NOTES; set => _NOTES = value; }
30 32
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
31 33
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
34
        public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; }
35
        public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; }
32 36
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
33 37
        public string SIZE
34 38
        {
......
49 53
        }
50 54
        public double SIZE_WIDTH { get => _SIZE_WIDTH; }
51 55
        public double SIZE_HEIGHT { get => _SIZE_HEIGHT; }
56
        
52 57

  
53 58
        public Document(string xmlPath)
54 59
        {
......
78 83
        {
79 84
            foreach (XElement item in node.Elements("SYMBOL"))
80 85
            {
81
                Symbol symbol = new Symbol()
86
                string sType = item.Element("TYPE").Value;
87
                if (sType == "Segment Breaks")
82 88
                {
83
                    UID = item.Element("UID").Value,
84
                    DBUID = item.Element("DBUID").Value,
85
                    NAME = item.Element("NAME").Value,
86
                    TYPE = item.Element("TYPE").Value,
87
                    OWNER = item.Element("OWNER").Value,
88
                    ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
89
                    CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
90
                    LOCATION = item.Element("LOCATION").Value,
91
                    SIZE = item.Element("SIZE").Value,
92
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
93
                    PARENT = item.Element("PARENT").Value,
94
                    CHILD = item.Element("CHILD").Value,
95
                    HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
96
                    AREA = item.Element("AREA").Value,
97
                    FLIP = Convert.ToInt32(item.Element("FLIP").Value),
98
                    CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
99
                };
100
                SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
101
                SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
102
                SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
103
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
104
                SetChildSymbol(symbol);
89
                    continue;
90
                }
91
                else if (sType == "End Break")
92
                {
93
                    EndBreak endBreak = new EndBreak()
94
                    {
95
                        UID = item.Element("UID").Value,
96
                        DBUID = item.Element("DBUID").Value,
97
                        NAME = item.Element("NAME").Value,
98
                        TYPE = item.Element("TYPE").Value,
99
                        OWNER = item.Element("OWNER").Value,
100
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
101
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
102
                        LOCATION = item.Element("LOCATION").Value,
103
                        SIZE = item.Element("SIZE").Value,
104
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
105
                        PARENT = item.Element("PARENT").Value,
106
                        CHILD = item.Element("CHILD").Value,
107
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
108
                        AREA = item.Element("AREA").Value,
109
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
110
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
111
                    };
112
                    SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS);
113
                    SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT);
114
                    SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES);
115
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES);
116

  
117
                    EndBreaks.Add(endBreak);
118
                }
119
                else if (sType == "Black Box System" ||
120
                    sType == "GGO_Equipment" ||
121
                    sType == "Heat Transfer Equipment" ||
122
                    sType == "Labels - Equipment" ||
123
                    sType == "Mechanical" ||
124
                    sType == "Other Equipment" ||
125
                    sType == "Vessels")
126
                {
127
                    Equipment equipment = new Equipment()
128
                    {
129
                        UID = item.Element("UID").Value,
130
                        DBUID = item.Element("DBUID").Value,
131
                        NAME = item.Element("NAME").Value,
132
                        TYPE = item.Element("TYPE").Value,
133
                        OWNER = item.Element("OWNER").Value,
134
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
135
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
136
                        LOCATION = item.Element("LOCATION").Value,
137
                        SIZE = item.Element("SIZE").Value,
138
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
139
                        PARENT = item.Element("PARENT").Value,
140
                        CHILD = item.Element("CHILD").Value,
141
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
142
                        AREA = item.Element("AREA").Value,
143
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
144
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
145
                    };
146
                    SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS);
147
                    SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT);
148
                    SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES);
149
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES);
105 150

  
106
                SYMBOLS.Add(symbol);
151
                    Equipments.Add(equipment);
152
                }
153
                else
154
                {
155
                    Symbol symbol = new Symbol()
156
                    {
157
                        UID = item.Element("UID").Value,
158
                        DBUID = item.Element("DBUID").Value,
159
                        NAME = item.Element("NAME").Value,
160
                        TYPE = item.Element("TYPE").Value,
161
                        OWNER = item.Element("OWNER").Value,
162
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
163
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
164
                        LOCATION = item.Element("LOCATION").Value,
165
                        SIZE = item.Element("SIZE").Value,
166
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
167
                        PARENT = item.Element("PARENT").Value,
168
                        CHILD = item.Element("CHILD").Value,
169
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
170
                        AREA = item.Element("AREA").Value,
171
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
172
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
173
                    };
174
                    SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
175
                    SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
176
                    SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
177
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
178
                    SetChildSymbol(symbol);
179

  
180
                    SYMBOLS.Add(symbol);
181
                }
107 182
            }
108 183
        }
109 184

  
......
318 393
            }
319 394
            if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None")
320 395
            {
396
                // 현재 부모 Symbol에 자식 Connector까지 들어가 있음
321 397
                string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
322 398
                string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
323
                List<Connector> childConnector = new List<Connector>();
324 399
                for (int i = 0; i < array.Length; i++)
325 400
                {
326 401
                    string[] arrConn = array[i].Split(new char[] { ',' });
......
328 403
                    if (connIndex != 0)
329 404
                    {
330 405
                        childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
331
                        childConnector.Add(symbol.CONNECTORS[i]);
406
                        symbol.CONNECTORS[i].Index = connIndex;
332 407
                    }
333 408
                }
334

  
335
                foreach (var connector in childConnector)
336
                {
337
                    symbol.CONNECTORS.Remove(connector);
338
                }
339 409
            }
340 410
        }
341 411
        #endregion
DTI_PID/BaseModel/Model/EndBreak.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace Converter.BaseModel
8
{
9
    public class EndBreak : Symbol
10
    {
11
        
12
    }
13
}
DTI_PID/BaseModel/Model/Equipment.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace Converter.BaseModel
8
{
9
    public class Equipment : Symbol
10
    {
11
        
12
    }
13
}
DTI_PID/BaseModel/Model/Other/Connector.cs
19 19
        public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; }
20 20
        public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; }
21 21
        public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; }
22

  
23
        public int Index { get; set; }
22 24
    }
23 25
}
DTI_PID/BaseModel/Model/SPPID/SPPIDLineInfo.cs
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6 6

  
7

  
7 8
namespace Converter.BaseModel
8 9
{
9 10
    public class SPPIDLineInfo
......
13 14
        public double START_Y { get; set; }
14 15
        public double END_X { get; set; }
15 16
        public double END_Y { get; set; }
16
        public string SP_ID { get; set; }
17
        public string RepresentationId { get; set; }
18
        public bool IsGroup { get; set; }
17 19
    }
18 20
}
DTI_PID/BaseModel/Model/SPPID/SPPIDSymbolInfo.cs
11 11
        public string MAPPINGNAME { get; set; }
12 12
        public double ORIGINAL_X { get; set; }
13 13
        public double ORIGINAL_Y { get; set; }
14
        public object ITEMOBJECT { get; set; }
14
        public object RepresentationId { get; set; }
15
        public bool IsGroup { get; set; }
15 16
    }
16 17
}
DTI_PID/SPPIDConverter/AutoModeling.cs
22 22
    public class AutoModeling
23 23
    {
24 24
        Placement _placement = new Placement();
25

  
25 26
        SPPID_Document document;
27

  
28

  
26 29
        public AutoModeling(SPPID_Document document)
27 30
        {
28 31
            this.document = document;
29 32
        }
30 33

  
34

  
35

  
31 36
        public void Run()
32 37
        {
33 38
            //dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
......
44 49
                {
45 50
                    // Run 별로 Modeling
46 51
                    Symbol prevSymbol = null;
52
                    object prevItem = null;
47 53
                    // Symbol 먼저
48 54
                    foreach (var item in run.RUNITEMS)
49 55
                    {
50 56
                        if (item.GetType() == typeof(Symbol))
51 57
                        {
52 58
                            Symbol symbol = item as Symbol;
53
                            SymbolModeling(symbol, prevSymbol);
59
                            SymbolModeling(symbol, prevSymbol, prevItem);
54 60
                            prevSymbol = symbol;
55 61
                        }
62
                        prevItem = item;
56 63
                    }
57 64

  
58
                    object prevItem = null;
65

  
66
                    Line prevLine = null;
59 67
                    prevSymbol = null;
68
                    prevItem = null;
69
                    List<Line> lines = new List<Line>();
60 70
                    foreach (var item in run.RUNITEMS)
61 71
                    {
72
                        // Line일 경우
62 73
                        if (item.GetType() == typeof(Line))
63 74
                        {
64
                            
75
                            Line line = item as Line;
76
                            if (prevLine == null)
77
                                lines.Add(line);
78
                            else if (prevLine != null)
79
                            {
80
                                if (prevLine.SPPID.MAPPINGNAME == line.SPPID.MAPPINGNAME)
81
                                    lines.Add(line);
82
                                else
83
                                {
84
                                    LineModeling(lines);
85
                                    lines.Clear();
86
                                    lines.Add(line);
87
                                }
88
                            }
89

  
90
                            prevLine = line;
91
                        }
92
                        // Symbol 일 경우
93
                        else if (item.GetType() == typeof(Symbol))
94
                        {
95
                            if (lines.Count > 0)
96
                            {
97
                                LineModeling(lines);
98
                                lines.Clear();
99
                            }
65 100
                        }
66 101

  
67 102
                        prevItem = item;
68 103
                    }
69 104

  
70

  
105
                    if (lines.Count > 0)
106
                        LineModeling(lines);
71 107
                }
72 108
            }
73 109

  
......
82 118

  
83 119
        }
84 120

  
85
        private void SymbolModeling(Symbol symbol, Symbol prevSymbol)
121
        private void SymbolModeling(Symbol symbol, Symbol prevSymbol, object prevItem)
86 122
        {
87 123
            LMSymbol _LMSymbol = null;
124
            LMADataSource dataSource = _placement.PIDDataSource;
88 125

  
89 126
            string mappingPath = symbol.SPPID.MAPPINGNAME;
90 127
            double x = symbol.SPPID.ORIGINAL_X;
......
93 130
            double angle = symbol.ANGLE;
94 131
            LMSymbol _TargetItem = null;
95 132

  
133
            if (prevItem != null && prevItem.GetType() == typeof(Symbol))
134
                _TargetItem = dataSource.GetSymbol(((Symbol)prevItem).SPPID.RepresentationId);
135

  
96 136
            if (prevSymbol != null)
97 137
            {
98 138
                SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y);
99
                LMADataSource dataSource = _placement.PIDDataSource;
100
                LMSymbol prevLMSymbol = dataSource.GetSymbol(prevSymbol.SPPID.ITEMOBJECT);
139
                LMSymbol prevLMSymbol = dataSource.GetSymbol(prevSymbol.SPPID.RepresentationId);
101 140
                double prevX = prevLMSymbol.get_XCoordinate();
102 141
                double prevY = prevLMSymbol.get_YCoordinate();
103 142
                if (slopeType == SlopeType.HORIZONTAL)
......
105 144
                else if (slopeType == SlopeType.VERTICAL)
106 145
                    x = prevX;
107 146

  
108
            }
109
            else
110
            {
111
                
147
                ReleaseCOMObjects(prevLMSymbol);
112 148
            }
113 149

  
114 150
            if (_TargetItem == null)
115 151
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
116 152
            else
117
            {
118 153
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem);
119
                ReleaseCOMObjects(_TargetItem);
120
            }
121 154

  
122 155
            if (_LMSymbol != null)
123 156
            {
124
                symbol.SPPID.ITEMOBJECT = _LMSymbol.AsLMRepresentation().Id;
157
                _LMSymbol.Commit();
158
                symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id;
125 159
            }
126 160

  
127
            ReleaseCOMObjects(_LMSymbol);
128
        }
129

  
130
        private void LineModeling(Line line)
131
        {
132
            object DrwingID = "0";
133
            _LMAItem _LMAItem = _placement.PIDCreateItem(line.SPPID.MAPPINGNAME, ref DrwingID);
134
            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
135
            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
136
            placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
137

  
138
            LMConnector lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
139
            lMConnector.Commit();
140 161

  
141
            ReleaseCOMObjects(lMConnector);
142
            ReleaseCOMObjects(placeRunInputs);
143
            ReleaseCOMObjects(_LMAItem);
162
            if (_TargetItem != null)
163
                ReleaseCOMObjects(_TargetItem);
164
            ReleaseCOMObjects(dataSource);
165
            ReleaseCOMObjects(_LMSymbol);
144 166
        }
145 167

  
146 168
        private void LineModeling(List<Line> lines)
147 169
        {
148 170
            object DrwingID = "0";
171
            LMADataSource dataSource = _placement.PIDDataSource;
149 172
            _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME, ref DrwingID);
150 173
            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
174
            LMSymbol _LMSymbol1 = null;
175
            LMSymbol _LMSymbol2 = null;
151 176
            for (int i = 0; i < lines.Count; i++)
152 177
            {
153 178
                Line line = lines[i];
154
                placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
155
                placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
179
                if (i == 0 || i + 1 != lines.Count)
180
                {
181
                    object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[0].CONNECTEDITEM);
182
                    if (connItem != null && connItem.GetType() == typeof(Symbol))
183
                    {
184
                        _LMSymbol1 = dataSource.GetSymbol(((Symbol)connItem).SPPID.RepresentationId);
185
                        if (_LMSymbol1 != null)
186
                            placeRunInputs.AddSymbolTarget(_LMSymbol1, line.SPPID.START_X, line.SPPID.START_Y);
187
                        else
188
                            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
189
                    }
190
                    else
191
                        placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
192
                }
193

  
194
                if (i + 1 == lines.Count)
195
                {
196
                    object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[1].CONNECTEDITEM);
197
                    if (connItem != null && connItem.GetType() == typeof(Symbol))
198
                    {
199
                        _LMSymbol2 = dataSource.GetSymbol(((Symbol)connItem).SPPID.RepresentationId);
200
                        if (_LMSymbol2 != null)
201
                        {
202
                            if (i != 0)
203
                                placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
204

  
205
                            placeRunInputs.AddSymbolTarget(_LMSymbol2, line.SPPID.END_X, line.SPPID.END_Y);
206
                        }
207
                        else
208
                        {
209
                            if (i != 0)
210
                                placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
211
                            placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
212
                        }
213
                            
214
                    }
215
                    else
216
                    {
217
                        if (i != 0)
218
                            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
219
                        placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
220
                    }
221
                }
222
            }
223
            
224

  
225
            LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
226
            if (_lMConnector != null)
227
            {
228
                foreach (var line in lines)
229
                    line.SPPID.RepresentationId = _lMConnector.AsLMRepresentation().Id;
230
                _lMConnector.Commit();
156 231
            }
157 232
            
158 233

  
159
            LMConnector lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
160
            lMConnector.Commit();
234
            if (_LMSymbol1 != null)
235
                ReleaseCOMObjects(_LMSymbol1);
236
            if (_LMSymbol2 != null)
237
                ReleaseCOMObjects(_LMSymbol2);
161 238

  
162
            ReleaseCOMObjects(lMConnector);
239
            ReleaseCOMObjects(dataSource);
240
            ReleaseCOMObjects(_lMConnector);
163 241
            ReleaseCOMObjects(placeRunInputs);
164 242
            ReleaseCOMObjects(_LMAItem);
165 243
        }
DTI_PID/SPPIDConverter/ConverterForm.cs
38 38
        private DataTable _ID2LineDT = new DataTable();
39 39
        private DataTable _ID2AssociationDT = new DataTable();
40 40
        private DataTable _ID2LinePropertyDT = new DataTable();
41
        private DataTable _ID2SymbolTypeDT = new DataTable();
42

  
41 43

  
42 44
        private List<SymbolMapping> symbolMappings = new List<SymbolMapping>();
43 45
        private List<LineMapping> lineMappings = new List<LineMapping>();
......
110 112
            gridViewConverter.BestFitColumns();
111 113
            #endregion
112 114
        }
115

  
113 116
        private void templateComboBox_EditValueChanged(object sender, EventArgs e)
114 117
        {
115 118
            gridViewConverter.CloseEditor();
......
431 434
            document.LineNumberMappings = lineNumberMappings;
432 435
            document.AssociationMappings = associationMappings;
433 436
            document.ETCSetting = ETCSetting.GetInstance();
437

  
434 438
            document.SetSPPIDInfo();
435 439

  
436 440
            if (document.SetSPPIDMapping())
......
471 475

  
472 476
        private void btnItemMapping_Click(object sender, EventArgs e)
473 477
        {
474
#if DEBUG
475
            SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml");
476
            document.SymbolMappings = symbolMappings;
477
            document.LineMappings = lineMappings;
478
            document.LineNumberMappings = lineNumberMappings;
479
            document.AssociationMappings = associationMappings;
480
            document.ETCSetting = ETCSetting.GetInstance();
481
            document.SetSPPIDInfo();
482

  
483
            if (document.SetSPPIDMapping())
484
            {
485
                AutoModeling modeling = new AutoModeling(document);
486
                modeling.Run();
487
            }
488
            
489
            return;
490
#endif
491

  
492 478
            Project_Info _ProjectInfo = Project_Info.GetInstance();
493 479
            if (!_ProjectInfo.Enable)
494 480
            {
DTI_PID/SPPIDConverter/Model/SPPID_Document.cs
3 3
using System.Linq;
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6
using System.Data;
6 7
using Converter.BaseModel;
7 8
using Converter.SPPID.Util;
8 9

  
......
12 13
    {
13 14
        public SPPID_Document(string xmlPath) : base(xmlPath)
14 15
        {
15

  
16
            
16 17
        }
17 18

  
18 19
        private double testX = 0.855;
......
24 25
        public List<AssociationMapping> AssociationMappings;
25 26
        public ETCSetting ETCSetting;
26 27

  
27
        private List<Group> GROUPS { get; set; }
28
        public List<Group> GROUPS = new List<Group>();
28 29

  
29 30
        public string DrawingName { get; set; }
30 31
        public string DrawingNumber { get; set; }
......
85 86
            return true;
86 87
        }
87 88

  
88
        //#region Grouping Source
89
        //private void SetGrouping()
90
        //{
91
        //    try
92
        //    {
93
        //        // Line 기준으로 묶음
94
        //        foreach (Line item in LINES)
95
        //            if (!item.SPPID.IsGroup)
96
        //                SetGroupingByItem(item);
97
        //        // End
98

  
99
        //        // Symbol 기준으로 묶음
100
        //        foreach (Symbol item in SYMBOLS)
101
        //            if (!item.SPPID.IsGroup)
102
        //                SetGroupingByItem(item);
103
        //        // End
104
        //    }
105
        //    catch (Exception ex)
106
        //    {
107
                
108
        //    }
109
        //}
110

  
111
        //private void SetGroupingByItem(object item)
112
        //{
113
        //    try
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
        //    catch (Exception ex)
123
        //    {
124
                
125
        //    }
126
        //}
127

  
128
        //private void SetGroupingByConnectedItem(object item, List<object> list, ref bool IsForward)
129
        //{
130
        //    try
131
        //    {
132
        //        if (typeof(Line) == item.GetType())
133
        //        {
134
        //            Line line = item as Line;
135
        //            line.SPPID.IsGroup = true;
136
        //            SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS);
137
        //        }
138
        //        else if (typeof(Symbol) == item.GetType())
139
        //        {
140
        //            Symbol symbol = item as Symbol;
141
        //            symbol.SPPID.IsGroup = true;
142
        //            // Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료
143
        //            if (symbol.CONNECTORS.Count <= 2)
144
        //            {
145
        //                SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS);
146
        //            }
147
        //        }
148
        //        IsForward = false;
149
        //    }
150
        //    catch (Exception ex)
151
        //    {
152
                
153
        //    }
154
        //}
155

  
156
        //private int GetChildConnectorCount(Symbol symbol)
157
        //{
158
        //    int count = 0;
159
        //    foreach (var childSymbol in symbol.ChildSymbols)
160
        //    {
161
        //        GetChildConnectorCountLoop(childSymbol, ref count);
162
        //    }
163

  
164
        //    return count;
165
        //}
166

  
167
        //private void GetChildConnectorCountLoop(ChildSymbol childSymbol, ref int count)
168
        //{
169
        //    count = count + childSymbol.Connectors.Count;
170

  
171
        //    foreach (var child in childSymbol.ChildSymbols)
172
        //    {
173
        //        GetChildConnectorCountLoop(child, ref count);
174
        //    }
175
        //}
176

  
177
        //private void SetGroupingByConnectedItem_ConnectorsLogic(object item, List<object> list, ref bool IsForward, List<Connector> connectors)
178
        //{
179
        //    foreach (Connector connector in connectors)
180
        //    {
181
        //        object connItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
182
        //        if (connItem != null)
183
        //        {
184
        //            bool result = false;
185
        //            if (typeof(Line) == connItem.GetType())
186
        //            {
187
        //                Line connLine = connItem as Line;
188
        //                // 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인
189
        //                if (item.GetType() == connLine.GetType() &&
190
        //                    (SPPIDUtil.IsBranchLine(((Line)item).UID, connLine) || item.SPPIDMAPPINGNAME != connLine.SPPIDMAPPINGNAME))
191
        //                    continue;
192

  
193
        //                result = true;
194
        //            }
195
        //            else if (typeof(Symbol) == connItem.GetType())
196
        //            {
197
        //                Symbol connSymbol = connItem as Symbol;
198
        //                // 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false
199
        //                foreach (Connector symbolConnector in connSymbol.CONNECTORS)
200
        //                {
201
        //                    if (symbolConnector.CONNECTEDITEM == item.UID)
202
        //                    {
203
        //                        if (symbolConnector.INDEX == 0)
204
        //                            result = true;
205
        //                        else
206
        //                            result = false;
207
        //                        break;
208
        //                    }
209
        //                }
210
        //            }
211

  
212
        //            if (!connItem.GROUPING && result)
213
        //            {
214
        //                if (IsForward)
215
        //                    list.Add(connItem);
216
        //                else
217
        //                    list.Insert(0, connItem);
218
        //                SetGroupingByConnectedItem(connItem, list, ref IsForward);
219
        //            }
220
        //        }
221
        //    }
222
        //}
223

  
224
        //private bool IsChildConnector(Symbol symol, Connector connector)
225
        //{
226
        //    bool result = false;
227

  
228

  
229

  
230

  
231
        //    return result;
232
        //}
233
        //#endregion
89
        #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
234 202
    }
235 203
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)