프로젝트

일반

사용자정보

개정판 5dfb8a24

ID5dfb8a2413cadabd639a521b6ad56f0a6278b58d
상위 7ff11d34
하위 59acb38f, 3eb65a17, 1b261371

gaqhf 이(가) 약 6년 전에 추가함

dev issue #000 : ID2의 LineNumber 기준으로 모델링 초기 시작

Change-Id: I1aa4d167b19893ad7aadbe06363444a903a61590

차이점 보기:

DTI_PID/BaseModel/BaseModel.csproj
84 84
    <Compile Include="Model\Other\Connector.cs" />
85 85
    <Compile Include="Model\Other\LineNumberRun.cs" />
86 86
    <Compile Include="Model\Other\Property.cs" />
87
    <Compile Include="Model\SPPIDLineInfo.cs" />
88
    <Compile Include="Model\SPPIDSymbolInfo.cs" />
87
    <Compile Include="Model\SPPID\SPPIDLineInfo.cs" />
88
    <Compile Include="Model\SPPID\SPPIDSymbolInfo.cs" />
89 89
    <Compile Include="Project_DB.cs" />
90 90
    <Compile Include="Project_Info.cs" />
91 91
    <Compile Include="Model\Document.cs" />
DTI_PID/BaseModel/Model/Document.cs
320 320
            {
321 321
                string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
322 322
                string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
323
                List<Connector> childConnector = new List<Connector>();
323 324
                for (int i = 0; i < array.Length; i++)
324 325
                {
325 326
                    string[] arrConn = array[i].Split(new char[] { ',' });
326 327
                    int connIndex = Convert.ToInt32(arrConn[3]);
327 328
                    if (connIndex != 0)
329
                    {
328 330
                        childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
331
                        childConnector.Add(symbol.CONNECTORS[i]);
332
                    }
333
                }
334

  
335
                foreach (var connector in childConnector)
336
                {
337
                    symbol.CONNECTORS.Remove(connector);
329 338
                }
330 339
            }
331 340
        }
DTI_PID/SPPIDConverter/AutoModeling.cs
11 11
using Converter.SPPID.Util;
12 12
using Converter.SPPID.DB;
13 13

  
14
using System.Windows;
14 15
using System.Threading;
16
using System.Drawing;
15 17
using Microsoft.VisualBasic;
16 18
using Newtonsoft.Json;
17 19

  
......
19 21
{
20 22
    public class AutoModeling
21 23
    {
24
        Placement _placement = new Placement();
22 25
        SPPID_Document document;
23 26
        public AutoModeling(SPPID_Document document)
24 27
        {
......
27 30

  
28 31
        public void Run()
29 32
        {
30
            dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
31
            dynamic newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName);
32
            application.ActiveWindow.Fit();
33
            Thread.Sleep(100);
34
            application.ActiveWindow.Zoom = 60;
35
            Thread.Sleep(100);
33
            //dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
34
            //dynamic newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName);
35
            //application.ActiveWindow.Fit();
36
            //Thread.Sleep(100);
37
            //application.ActiveWindow.Zoom = 60;
38
            //Thread.Sleep(100);
39

  
40

  
41
            foreach (LineNumber lineNumber in document.LINENUMBERS)
42
            {
43
                foreach (LineNumberRun run in lineNumber.RUNS)
44
                {
45
                    // Run 별로 Modeling
46
                    Symbol prevSymbol = null;
47
                    object prevItem = null;
48
                    foreach (object item in run.RUNITEMS)
49
                    {
50
                        if (item.GetType() == typeof(Symbol))
51
                        {
52
                            Symbol symbol = item as Symbol;
53
                            SymbolModeling(symbol, prevSymbol);
54
                            //// 바로 전 아이템이 Symbol
55
                            //if (prevItem != null && prevItem.GetType() == typeof(Symbol))
56
                            //{
57

  
58
                            //}
59
                            //// 바로 전 아이템 Line 예전 Item 이 Symbol
60
                            //else if (prevItem != null && prevSymbol != null)
61
                            //{
62

  
63
                            //}
64
                            prevSymbol = symbol;
65
                        }
66
                        else if (item.GetType() == typeof(Line))
67
                        {
68
                            Line line = item as Line;
69
                            LineModeling(item as Line);
70
                        }
71

  
72
                        prevItem = item;
73
                    }
74

  
75

  
76

  
77
                }
78
            }
79

  
80

  
81
            ReleaseCOMObjects(_placement);
82
            System.Windows.Forms.MessageBox.Show("end");
83
        }
36 84

  
85
        private void TestSource()
86
        {
37 87

  
38 88
        }
39 89

  
40

  
41
        private void SymbolModeling(Symbol symbol)
90
        private void SymbolModeling(Symbol symbol, Symbol prevSymbol)
42 91
        {
43

  
92
            LMSymbol _LMSymbol = null;
93

  
94
            string mappingPath = symbol.SPPID.MAPPINGNAME;
95
            double x = symbol.SPPID.LOCATION_X;
96
            double y = symbol.SPPID.LOCATION_Y;
97
            int mirror = 0;
98
            double angle = symbol.ANGLE;
99
            LMSymbol _TargetItem = null;
100

  
101
            if (prevSymbol != null)
102
            {
103
                SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.LOCATION_X, symbol.SPPID.LOCATION_Y, prevSymbol.SPPID.LOCATION_X, prevSymbol.SPPID.LOCATION_Y);
104
                if (slopeType == SlopeType.HORIZONTAL)
105
                {
106

  
107
                }
108
                else if (slopeType == SlopeType.VERTICAL)
109
                {
110

  
111
                }
112
            }
113
            else
114
            {
115
                
116
            }
117

  
118
            if (_TargetItem == null)
119
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
120
            else
121
            {
122
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem);
123
                ReleaseCOMObjects(_TargetItem);
124
            }
125

  
126
            if (_LMSymbol != null)
127
            {
128

  
129
            }
130

  
131
            ReleaseCOMObjects(_LMSymbol);
44 132
        }
45 133

  
46 134
        private void LineModeling(Line line)
47 135
        {
48

  
136
            object DrwingID = "0";
137
            _LMAItem _LMAItem = _placement.PIDCreateItem(line.SPPID.MAPPINGNAME, ref DrwingID);
138
            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
139
            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
140
            placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
141

  
142
            LMConnector lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
143
            lMConnector.Commit();
144

  
145
            ReleaseCOMObjects(lMConnector);
146
            ReleaseCOMObjects(placeRunInputs);
147
            ReleaseCOMObjects(_LMAItem);
49 148
        }
50 149

  
51 150
        private void LineNumberModeling(LineNumber lineNumber)
......
63 162

  
64 163
        }
65 164

  
165

  
166
        public void ReleaseCOMObjects(params object[] objVars)
167
        {
168
            int intNewRefCount = 0;
169
            foreach (object obj in objVars)
170
            {
171
                if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj))
172
                    intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj);
173
            }
174
        }
66 175
    }
67 176
}
DTI_PID/SPPIDConverter/ConverterForm.cs
424 424

  
425 425
        private void btnRun_Click(object sender, EventArgs e)
426 426
        {
427
            _Documents.Clear();
427
#if DEBUG
428
            SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml");
429
            document.SymbolMappings = symbolMappings;
430
            document.LineMappings = lineMappings;
431
            document.LineNumberMappings = lineNumberMappings;
432
            document.AssociationMappings = associationMappings;
433
            document.ETCSetting = ETCSetting.GetInstance();
434
            document.SetSPPIDInfo();
428 435

  
429
            foreach (int rowHandle in gridViewConverter.GetSelectedRows())
436
            if (document.SetSPPIDMapping())
430 437
            {
431
                string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
432
                string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
433
                string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
434
                string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
435
                string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
436
                SPPID_Document document = _DicDocuments[_FilePath];
437
                document.Unit = _Unit;
438
                document.Template = _Template;
439
                document.DrawingNumber = _DrawingNumber;
440
                document.DrawingName = _DrawingName;
441
                _Documents.Add(document);
438
                AutoModeling modeling = new AutoModeling(document);
439
                modeling.Run();
442 440
            }
443 441

  
442
            return;
443
#endif
444

  
445
            //_Documents.Clear();
446

  
447
            //foreach (int rowHandle in gridViewConverter.GetSelectedRows())
448
            //{
449
            //    string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
450
            //    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
451
            //    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
452
            //    string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
453
            //    string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
454
            //    SPPID_Document document = _DicDocuments[_FilePath];
455
            //    document.Unit = _Unit;
456
            //    document.Template = _Template;
457
            //    document.DrawingNumber = _DrawingNumber;
458
            //    document.DrawingName = _DrawingName;
459
            //    _Documents.Add(document);
460
            //}
461

  
444 462
            DialogResult = DialogResult.OK;
445 463
        }
446 464

  
DTI_PID/SPPIDConverter/Model/SPPID_Document.cs
24 24
        public List<AssociationMapping> AssociationMappings;
25 25
        public ETCSetting ETCSetting;
26 26

  
27
        private List<Group> GROUPS { get; set; }
28

  
27 29
        public string DrawingName { get; set; }
28 30
        public string DrawingNumber { get; set; }
29 31
        public string Unit { get; set; }
......
82 84

  
83 85
            return true;
84 86
        }
87

  
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
85 234
    }
86 235
}
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs
9 9
using Converter.BaseModel;
10 10
using System.Windows.Forms;
11 11
using Converter.SPPID.Model;
12
using System.Drawing;
12 13

  
13 14
namespace Converter.SPPID.Util
14 15
{
16
    public enum SlopeType
17
    {
18
        Slope,
19
        HORIZONTAL,
20
        VERTICAL
21
    }
15 22
    public class SPPIDUtil
16 23
    {
17 24
        public static bool ConvertToSPPIDInfo(string jsonString)
......
45 52
            }
46 53
            return true;
47 54
        }
55

  
48 56
        public static bool ConvertToETCSetting(string jsonString)
49 57
        {
50 58
            ETCSetting _ETCSetting = ETCSetting.GetInstance();
......
64 72
            return true;
65 73
        }
66 74

  
67
        public static string GetSPPIDMappingPath(SPPID_Document document, object itemObj)
68
        {
69

  
70
            return null;
71
        }
72

  
73 75
        public static bool ConvertPointBystring(string sPoint, ref double dX, ref double dY)
74 76
        {
75 77
            try
......
103 105
            dY = calcY;
104 106
        }
105 107

  
108
        public static SlopeType CalcSlope(double x1, double y1, double x2, double y2)
109
        {
110
            if (x1 - x2 == 0)
111
            {
112
                return SlopeType.VERTICAL;
113
            }
114
            else
115
            {
116
                double angle = Math.Atan(Math.Abs(y2 - y1) / Math.Abs(x2 - x1)) * 180 / Math.PI;
117
                if (angle < 20)
118
                    return SlopeType.HORIZONTAL;
119
                else if (angle > 70)
120
                    return SlopeType.VERTICAL;
121
                else
122
                    return SlopeType.Slope;
123
            }
124
        }
125

  
106 126
        #region
107 127
        public static bool IsBranchLine(string UID, Line connectedLine)
108 128
        {

내보내기 Unified diff

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