프로젝트

일반

사용자정보

개정판 c01ce90b

IDc01ce90b32aa320ad42d2a0eecc115ade72631f7
상위 def4a668
하위 19631de4

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

dev issue #1146 : 좌표 보정 개발

Change-Id: Ie195c993ca1439ac08183a79f98500b54a1bfdd1

차이점 보기:

DTI_PID/SPPIDConverter/SPPIDModel/SPPID_Document.cs
199 199
            }
200 200
        }
201 201

  
202
        /// <summary>
203
        /// 좌표 보정
204
        /// </summary>
205
        public void CoordinateCorrection()
206
        {
207
            foreach (Symbol symbol in SYMBOLS)
208
            {
209
                if (!symbol.SPPID.IsCorrectionX)
210
                {
211
                    List<object> group = new List<object>();
212
                    group.Add(symbol);
213
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.VERTICAL);
214

  
215
                    List<Symbol> groupSymbols = (from sym in @group
216
                                                 where sym.GetType() == typeof(Symbol)
217
                                                 select sym as Symbol).ToList();
218

  
219
                    // X 좌표만 보정
220
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionX);
221
                    double value = symbol.SPPID.ORIGINAL_X;
222
                    if (correctionSymbol == null)
223
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
224
                    else
225
                        value = correctionSymbol.SPPID.ORIGINAL_X;
226

  
227
                    foreach (var item in groupSymbols)
228
                    {
229
                        item.SPPID.IsCorrectionX = true;
230
                        item.SPPID.ORIGINAL_X = value;
231
                    }
232
                }
233

  
234
                if (!symbol.SPPID.IsCorrectionY)
235
                {
236
                    List<object> group = new List<object>();
237
                    group.Add(symbol);
238
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.HORIZONTAL);
239

  
240
                    List<Symbol> groupSymbols = (from sym in @group
241
                                                 where sym.GetType() == typeof(Symbol)
242
                                                 select sym as Symbol).ToList();
243

  
244
                    // Y 좌표만 보정
245
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionY);
246
                    double value = symbol.SPPID.ORIGINAL_Y;
247
                    if (correctionSymbol == null)
248
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
249
                    else
250
                        value = correctionSymbol.SPPID.ORIGINAL_Y;
251

  
252
                    foreach (var item in groupSymbols)
253
                    {
254
                        item.SPPID.IsCorrectionY = true;
255
                        item.SPPID.ORIGINAL_Y = value;
256
                    }
257
                }
258
            }
259
        }
260

  
261
        private void FindGroupBySymbolAndSlopeType(Symbol symbol, List<object> group, SlopeType searchType)
262
        {
263
            foreach (var connector in symbol.CONNECTORS)
264
            {
265
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
266
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
267
                {
268
                    Symbol connSymbol = connectedItem as Symbol;
269
                    SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y);
270
                    if (slopeType == searchType)
271
                    {
272
                        if (!group.Contains(connSymbol))
273
                        {
274
                            group.Add(connSymbol);
275
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
276
                        }
277
                    }
278
                }
279
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
280
                {
281
                    Line connLine = connectedItem as Line;
282
                    SlopeType slopeType = SPPIDUtil.CalcSlope(connLine.SPPID.START_X, connLine.SPPID.START_Y, connLine.SPPID.END_X, connLine.SPPID.END_Y);
283
                    if (slopeType == searchType)
284
                    {
285
                        if (!group.Contains(connLine))
286
                        {
287
                            group.Add(connLine);
288
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
289
                        }
290
                    }
291
                }
292
            }
293
        }
294

  
295
        private void FindGroupByLineAndSlopeType(Line Line, List<object> group, SlopeType searchType)
296
        {
297
            foreach (var connector in Line.CONNECTORS)
298
            {
299
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
300
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
301
                {
302
                    Symbol connSymbol = connectedItem as Symbol;
303
                    double lineX = double.NaN;
304
                    double lineY = double.NaN;
305
                    SPPIDUtil.ConvertPointBystring(connector.SCENECONNECTPOINT, ref lineX, ref lineY);
306
                    double symbolX = double.NaN;
307
                    double symbolY = double.NaN;
308
                    SPPIDUtil.ConvertPointBystring(connSymbol.ORIGINALPOINT, ref symbolX, ref symbolY);
309

  
310
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
311
                    if (slopeType == searchType)
312
                    {
313
                        if (!group.Contains(connSymbol))
314
                        {
315
                            group.Add(connSymbol);
316
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
317
                        }
318
                    }
319
                }
320
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
321
                {
322
                    Line connLine = connectedItem as Line;
323
                    SlopeType slopeType = SPPIDUtil.CalcSlope(connLine.SPPID.START_X, connLine.SPPID.START_Y, connLine.SPPID.END_X, connLine.SPPID.END_Y);
324
                    if (slopeType == searchType)
325
                    {
326
                        if (!group.Contains(connLine))
327
                        {
328
                            group.Add(connLine);
329
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
330
                        }
331
                    }
332
                }
333
            }
334
        }
335

  
202 336
        private void SetChildSymbolSPPIDInfo(ChildSymbol item)
203 337
        {
204 338
            foreach (var childSymbol in item.ChildSymbols)
......
277 411
            return true;
278 412
        }
279 413

  
280
        public void ConvertSPPIDPoint(ref double dX, ref double dY, double dDwgX, double dDwgY, double SPPID_Width, double SPPID_Height)
281
        {
282
            decimal calcX = 0;
283
            decimal calcY = 0;
284
            decimal tempX = Convert.ToDecimal(dX);
285
            decimal tempY = Convert.ToDecimal(dY);
286
            decimal tempWidth = Convert.ToDecimal(SPPID_Width);
287
            decimal tempHeight = Convert.ToDecimal(SPPID_Height);
288
            decimal tempDwgX = Convert.ToDecimal(dDwgX);
289
            decimal tempDwgY = Convert.ToDecimal(dDwgY);
290

  
291
            //calcX = (tempX * tempWidth) / tempDwgX;
292
            //calcX = Math.Truncate(calcX * 1000) / 1000;
293
            //calcY = tempHeight - ((tempY * tempHeight) / tempDwgY);
294
            //calcY = Math.Truncate(calcY * 1000) / 1000;
295
            //dX = Math.Round(Convert.ToDouble(calcX), 10);
296
            //dY = Math.Round(Convert.ToDouble(calcY), 10);
297

  
298
            calcX = (tempX * tempWidth) / tempDwgX;
299
            calcY = tempHeight - ((tempY * tempHeight) / tempDwgY);
300
            dX = Convert.ToDouble(calcX);
301
            dY = Convert.ToDouble(calcY);
302
        }
303

  
304 414
        private bool SetChildSymbolMapping(ChildSymbol item)
305 415
        {
306 416
            foreach (var childSymbol in item.ChildSymbols)

내보내기 Unified diff

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