프로젝트

일반

사용자정보

개정판 b66a2996

IDb66a2996b29cbc6ce67eea79c84ed12a1143fba4
상위 51ae61b9
하위 def4a668

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

dev issue #497 : Snap Line Grid Fix

Change-Id: Iecca9e6942d9906ba109b43d40acccbb2a981ec6

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
101 101
                    SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true);
102 102
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStep, AllCount);
103 103
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText);
104
                    //Thread.Sleep(1000);
105
                    //SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd);
106
                    //Thread.Sleep(1000);
107 104

  
108 105
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Group Symbol Modeling");
109 106
                    List<List<Symbol>> symbolGroups = SPPIDUtil.GetThreeConnectedSymbolGroup(document);
......
200 197
            {
201 198
                application.ActiveWindow.Fit();
202 199

  
203
                if (newDrawing != null)
200
                if (radApp.ActiveDocument != null)
204 201
                {
205
                    radApp.ActiveDocument.SaveOnClose = false;
206
                    radApp.ActiveDocument.Save();
202
                    //radApp.ActiveDocument.Save();
203
                    //radApp.ActiveDocument.SaveOnClose = false;
204
                    //radApp.ActiveDocument.Close(false);
205

  
207 206
                    ReleaseCOMObjects(newDrawing);
208 207
                }
209 208

  
......
220 219
        /// </summary>
221 220
        private void CreateDocument()
222 221
        {
223
            newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName);
222
            string drawingName = document.DrawingName;
223
            string drawingNumber = document.DrawingNumber;
224

  
225
            GetDrawingNameAndNumber(ref drawingName, ref drawingNumber);
226

  
227
            newDrawing = application.Drawings.Add(document.Unit, document.Template, drawingNumber, drawingName);
224 228
            application.ActiveWindow.Fit();
225 229
            Thread.Sleep(1000);
226 230
            application.ActiveWindow.Zoom = 2000;
227 231
            Thread.Sleep(2000);
232

  
233
            
234
        }
235

  
236
        private void GetDrawingNameAndNumber(ref string drawingName, ref string drawingNumber)
237
        {
238
            LMDrawings drawings = new LMDrawings();
239
            drawings.Collect(dataSource);
240

  
241
            List<string> drawingNameList = new List<string>();
242
            List<string> drawingNumberList = new List<string>();
243

  
244
            foreach (LMDrawing item in drawings)
245
            {
246
                drawingNameList.Add(item.Attributes["Name"].get_Value().ToString());
247
                drawingNumberList.Add(item.Attributes["DrawingNumber"].get_Value().ToString());
248
            }
249

  
250
            int nameLength = drawingName.Length;
251
            while (drawingNameList.Contains(drawingName))
252
            {
253
                if (nameLength == drawingName.Length)
254
                    drawingName += "-1";
255
                else
256
                {
257
                    int index = Convert.ToInt32(drawingName.Remove(0, nameLength + 1));
258
                    drawingName = drawingName.Substring(0, nameLength + 1);
259
                    drawingName += ++index;
260
                }
261
            }
262

  
263
            int numberLength = drawingNumber.Length;
264
            while (drawingNameList.Contains(drawingNumber))
265
            {
266
                if (numberLength == drawingNumber.Length)
267
                    drawingNumber += "-1";
268
                else
269
                {
270
                    int index = Convert.ToInt32(drawingNumber.Remove(0, numberLength + 1));
271
                    drawingNumber = drawingNumber.Substring(0, numberLength + 1);
272
                    drawingNumber += ++index;
273
                }
274
            }
275

  
276
            ReleaseCOMObjects(drawings);
228 277
        }
229 278

  
230 279
        /// <summary>
......
963 1012
                SlopeType slopeType = SPPIDUtil.CalcSlope(line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y);
964 1013
                // Symbol일 경우 바로 Input Point
965 1014
                if (item.Item1 == "SYMBOL")
966
                {
967 1015
                    placeRunInputs.AddSymbolTarget(item.Item3 as LMSymbol, x, y);
968
                    prevX = x;
969
                    prevY = y;
970
                    prevSlopeType = slopeType;
971
                    continue;
972
                }
973

  
974
                SPPIDUtil.ConvertGridPoint(ref x, ref y);
975
                // i == 0은 그대로 사용
976
                if (i != 0)
1016
                else
977 1017
                {
978
                    Tuple<string, Line, object, double, double> prevItem = linePointInfo[i - 1];
979
                    // y 좌표가 같아야함
980
                    if (prevSlopeType == SlopeType.HORIZONTAL)
981
                        y = prevY;
982
                    else if (prevSlopeType == SlopeType.VERTICAL)
983
                        x = prevX;
984

  
985
                    if (i + 1 == linePointInfo.Count - 1 && linePointInfo[i + 1].Item1 == "SYMBOL")
1018
                    SPPIDUtil.ConvertGridPoint(ref x, ref y);
1019
                    // i == 0은 그대로 사용
1020
                    if (i != 0)
986 1021
                    {
987
                        Line nextLine = linePointInfo[i + 1].Item2;
988
                        SlopeType nextSlopeType = SPPIDUtil.CalcSlope(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y);
989
                        if (slopeType == SlopeType.HORIZONTAL)
990
                            y = linePointInfo[i + 1].Item5;
991
                        else if (slopeType == SlopeType.VERTICAL)
992
                            x = linePointInfo[i + 1].Item4;
1022
                        Tuple<string, Line, object, double, double> prevItem = linePointInfo[i - 1];
1023
                        // y 좌표가 같아야함 및 Symbol 좌표가 정확하지 않으므로 한번더 보정
1024
                        if (prevSlopeType == SlopeType.HORIZONTAL)
1025
                        {
1026
                            y = prevY;
1027
                            SPPIDUtil.ConvertGridPointOnlyOnePoint(ref y);
1028
                        }
1029
                        else if (prevSlopeType == SlopeType.VERTICAL)
1030
                        {
1031
                            x = prevX;
1032
                            SPPIDUtil.ConvertGridPointOnlyOnePoint(ref x);
1033
                        }
1034

  
1035
                        // 마지막이 Symbol일 경우는 Symbol의 좌표를 따라감
1036
                        if (i + 1 == linePointInfo.Count - 1 && linePointInfo[i + 1].Item1 == "SYMBOL")
1037
                        {
1038
                            Line nextLine = linePointInfo[i + 1].Item2;
1039
                            SlopeType nextSlopeType = SPPIDUtil.CalcSlope(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y);
1040
                            if (slopeType == SlopeType.HORIZONTAL)
1041
                                y = linePointInfo[i + 1].Item5;
1042
                            else if (slopeType == SlopeType.VERTICAL)
1043
                                x = linePointInfo[i + 1].Item4;
1044
                        }
993 1045
                    }
994
                }
995 1046

  
996
                if (item.Item1 == "LINE")
997
                    placeRunInputs.AddConnectorTarget(item.Item3 as LMConnector, x, y);
998
                else
999
                    placeRunInputs.AddPoint(x, y);
1047
                    if (item.Item1 == "LINE")
1048
                        placeRunInputs.AddConnectorTarget(item.Item3 as LMConnector, x, y);
1049
                    else
1050
                        placeRunInputs.AddPoint(x, y);
1051
                }
1000 1052

  
1001 1053
                prevX = x;
1002 1054
                prevY = y;
......
1101 1153
        private void BranchLineModeling(Tuple<string, Line, Line> branch)
1102 1154
        {
1103 1155
            List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1);
1156

  
1104 1157
            Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1);
1105 1158

  
1106 1159
            LMConnector _StartConnector = null;
DTI_PID/SPPIDConverter/ConverterDocking.cs
86 86
        private void simpleButton1_Click(object sender, EventArgs e)
87 87
        {
88 88
            Placement placement = new Placement();
89
            LMADataSource dataSource = placement.PIDDataSource;
90

  
91
            StringBuilder sb = new StringBuilder();
92
            sb.AppendLine(dataSource.ProjectNumber);
93
            sb.AppendLine(radApp.DisplayAlerts.ToString());
94
           
95

  
96
            MessageBox.Show(sb.ToString());
97

  
98
            return;
99

  
89
            LMADataSource dataSource = new LMADataSource();//placement.PIDDataSource;
100 90
            
101 91
            
102 92
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d;
103 93
            if (symbol2d != null)
104 94
            {
95

  
96
                
97

  
105 98
                double minX;
106 99
                double minY;
107 100
                double maxX;
......
124 117
                                {
125 118
                                    LMSymbol symbol = dataSource.GetSymbol(rep.Id);
126 119

  
120
                                    List<double[]> points = new List<double[]>();
121
                                    StringBuilder sb = new StringBuilder();
122
                                    for (int i = 1; i < int.MaxValue; i++)
123
                                    {
124
                                        double connX = 0;
125
                                        double connY = 0;
126
                                        if (placement.PIDConnectPointLocation(symbol, i, ref connX, ref connY))
127
                                        {
128
                                            points.Add(new double[] { connX, connY });
129
                                            sb.AppendLine(i + " / " + connX + " / " + connY);
130
                                        }
131
                                        else
132
                                            break;
133
                                    }
134

  
127 135
                                    double prevX = symbol.get_XCoordinate();
128 136
                                    double prevY = symbol.get_YCoordinate();
129 137

  
130

  
138
                                    MessageBox.Show(sb.ToString());
131 139
                                }
132 140
                            }
133 141
                        }
DTI_PID/SPPIDConverter/Form/SPPIDSplashScreen.cs
20 20
        }
21 21
        private void SPPIDSplashScreen_Load(object sender, EventArgs e)
22 22
        {
23
            TopMost = true;
24
            //StartPosition = FormStartPosition.Manual;
25
            //Location = new Point(0, 0);
23

  
26 24
        }
27 25

  
28 26
        #region Overrides
......
75 73
            SetParent,
76 74
            ClearParent
77 75
        }
78

  
79
        
80 76
    }
81 77
}
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs
154 154
                }
155 155
            }
156 156
        }
157
        public static void ConvertGridPointOnlyOnePoint(ref double value)
158
        {
159
            GridSetting _GridSetting = GridSetting.GetInstance();
160
            if (_GridSetting.UseSnapGrid)
161
            {
162
                if (_GridSetting.Unit == GridUnit.Inch)
163
                {
164
                    double length = _GridSetting.Density * 0.0254;
165
                    double temp = value;
166
                    value = Math.Round(value / length) * length;
167
                }
168
            }
169
        }
157 170

  
158 171
        public static SlopeType CalcSlope(double x1, double y1, double x2, double y2)
159 172
        {

내보내기 Unified diff

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