프로젝트

일반

사용자정보

개정판 2fdb56bf

ID2fdb56bf2b7cb3226338cc50eed8a4a926fec80c
상위 aeb576e0
하위 290b334c, ca7d0ada

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

dev issue #497 : Symbol의 SPPID Connector를 찾아 최대한 가까운 Connector좌표로 모델링하게 수정(정확도 향상)

Change-Id: I9fa45337c47f6839861644e01d357e647194852e

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
427 427
            if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId))
428 428
            {
429 429
                LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId);
430
                foreach (var connector in targetSymbol.CONNECTORS)
431
                {
432
                    Symbol connectedItemSymbol = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Symbol;
433
                    if (connectedItemSymbol != null && connectedItemSymbol == symbol)
434
                    {
435
                        GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y);
436
                        break;
437
                    }
438
                }
430
                Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, symbol.UID, targetSymbol);
431
                if (connector != null)
432
                    GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y);
433

  
439 434
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem);
440 435
                ReleaseCOMObjects(_TargetItem);
441 436
            }
......
480 475
        private void GetTargetSymbolConnectorPoint(Connector targetConnector, Symbol targetSymbol, ref double x, ref double y)
481 476
        {
482 477
            LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId);
483
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()];
484
            double x1 = 0;
485
            double x2 = 0;
486
            double y1 = 0;
487
            double y2 = 0;
488
            symbol2d.Range(out x1, out y1, out x2, out y2);
478

  
479
            double[] range = null;
489 480
            List<double[]> points = new List<double[]>();
490
            for (int i = 1; i < int.MaxValue; i++)
491
            {
492
                double connX = 0;
493
                double connY = 0;
494
                if (_placement.PIDConnectPointLocation(_TargetItem, i, ref connX, ref connY))
495
                    points.Add(new double[] { connX, connY });
496
                else
497
                    break;
498
            }
481
            GetSPPIDSymbolRangeAndConnectionPoints(targetSymbol, ref range, points);
482
            double x1 = range[0];
483
            double y1 = range[1];
484
            double x2 = range[2];
485
            double y2 = range[3];
499 486

  
500 487
            // Origin 기준 Connector의 위치차이
501 488
            double sceneX = 0;
......
531 518
                    y = point[1];
532 519
                }
533 520
            }
521

  
522
            ReleaseCOMObjects(_TargetItem);
523
        }
524

  
525
        /// <summary>
526
        /// SPPID Symbol의 Range를 구한다.
527
        /// </summary>
528
        /// <param name="symbol"></param>
529
        /// <param name="range"></param>
530
        private void GetSPPIDSymbolRangeAndConnectionPoints(Symbol symbol, ref double[] range, List<double[]> points)
531
        {
532
            LMSymbol _TargetItem = dataSource.GetSymbol(symbol.SPPID.RepresentationId);
533
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()];
534
            double x1 = 0;
535
            double y1 = 0;
536
            double x2 = 0;
537
            double y2 = 0;
538
            symbol2d.Range(out x1, out y1, out x2, out y2);
539
            range = new double[] { x1, y1, x2, y2 };
540

  
541
            for (int i = 1; i < int.MaxValue; i++)
542
            {
543
                double connX = 0;
544
                double connY = 0;
545
                if (_placement.PIDConnectPointLocation(_TargetItem, i, ref connX, ref connY))
546
                    points.Add(new double[] { connX, connY });
547
                else
548
                    break;
549
            }
550

  
551
            foreach (var childSymbol in symbol.ChildSymbols)
552
                GetSPPIDChildSymbolRange(childSymbol, ref range, points);
553

  
554
            ReleaseCOMObjects(_TargetItem);
555
        }
556

  
557
        /// <summary>
558
        /// Child Modeling 된 Symbol의 Range를 구한다.
559
        /// </summary>
560
        /// <param name="childSymbol"></param>
561
        /// <param name="range"></param>
562
        private void GetSPPIDChildSymbolRange(ChildSymbol childSymbol, ref double[] range, List<double[]> points)
563
        {
564
            LMSymbol _ChildSymbol = dataSource.GetSymbol(childSymbol.SPPID.RepresentationId);
565
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_ChildSymbol.get_GraphicOID().ToString()];
566
            double x1 = 0;
567
            double y1 = 0;
568
            double x2 = 0;
569
            double y2 = 0;
570
            symbol2d.Range(out x1, out y1, out x2, out y2);
571
            range[0] = Math.Min(range[0], x1);
572
            range[1] = Math.Min(range[1], y1);
573
            range[2] = Math.Max(range[2], x2);
574
            range[3] = Math.Max(range[3], y2);
575

  
576
            for (int i = 1; i < int.MaxValue; i++)
577
            {
578
                double connX = 0;
579
                double connY = 0;
580
                if (_placement.PIDConnectPointLocation(_ChildSymbol, i, ref connX, ref connY))
581
                    points.Add(new double[] { connX, connY });
582
                else
583
                    break;
584
            }
585

  
586
            foreach (var loopChildSymbol in childSymbol.ChildSymbols)
587
                GetSPPIDChildSymbolRange(loopChildSymbol, ref range, points);
588

  
589
            ReleaseCOMObjects(_ChildSymbol);
534 590
        }
535 591

  
536 592
        /// <summary>
......
814 870
                    object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[0].CONNECTEDITEM);
815 871
                    if (connItem != null && connItem.GetType() == typeof(Symbol))
816 872
                    {
817
                        _LMSymbol1 = GetTargetSymbol(connItem as Symbol, line);
873
                        Symbol symbol1 = connItem as Symbol;
874
                        _LMSymbol1 = GetTargetSymbol(symbol1, line);
818 875
                        if (_LMSymbol1 != null)
819
                            placeRunInputs.AddSymbolTarget(_LMSymbol1, line.SPPID.START_X, line.SPPID.START_Y);
876
                        {
877
                            double x = line.SPPID.START_X;
878
                            double y = line.SPPID.START_Y;
879
                            Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, line.UID, symbol1);
880
                            if (connector != null)
881
                            {
882
                                GetTargetSymbolConnectorPoint(connector, symbol1, ref x, ref y);
883
                                line.SPPID.START_X = x;
884
                                line.SPPID.START_Y = y;
885
                            }
886

  
887
                            placeRunInputs.AddSymbolTarget(_LMSymbol1, x, y);
888
                        }
820 889
                        else
821 890
                            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
822 891
                    }
......
836 905
                    else
837 906
                        placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
838 907
                }
839

  
840 908
                if (i + 1 == lines.Count)
841 909
                {
842 910
                    // 끝점에 연결된 Symbol 찾기
......
847 915

  
848 916
                    if (connItem != null && connItem.GetType() == typeof(Symbol))
849 917
                    {
918
                        Symbol symbol2 = connItem as Symbol;
850 919
                        _LMSymbol2 = GetTargetSymbol(connItem as Symbol, line);
851 920
                        if (_LMSymbol2 != null)
852
                            placeRunInputs.AddSymbolTarget(_LMSymbol2, line.SPPID.END_X, line.SPPID.END_Y);
921
                        {
922
                            double x = line.SPPID.END_X;
923
                            double y = line.SPPID.END_Y;
924
                            Connector connector = SPPIDUtil.FindSymbolConnectorByUID(document, line.UID, symbol2);
925
                            if (connector != null)
926
                            {
927
                                GetTargetSymbolConnectorPoint(connector, symbol2, ref x, ref y);
928
                                line.SPPID.END_X = x;
929
                                line.SPPID.END_Y = y;
930
                            }
931
                                
932

  
933
                            placeRunInputs.AddSymbolTarget(_LMSymbol2, x, y);
934
                        }
853 935
                        else
854 936
                            placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
855 937
                            

내보내기 Unified diff

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