프로젝트

일반

사용자정보

개정판 20dd244c

ID20dd244cc1a4ddaccf72f7b1bf45fb8aaf9c4a46
상위 a03e9271
하위 f25808d5

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

dev issue #1230 : edit thread, edit CoordinateCorrection

Change-Id: I9f2db1b78232cf092b129cf30a3427791a0f1645

차이점 보기:

DTI_PID/APIDConverter/AutoModeling.cs
112 112

  
113 113
                SetConvertRule();
114 114

  
115
                Zoom(0, 0, 10, 10);
115 116
                RunLineModeling();
117

  
118
                ZoomAll();
116 119
                RunOPCModeling();
117 120
                RunSymbolModeling();
118 121
                RunTextModeling();
......
132 135
            }
133 136
        }
134 137

  
138
        private void Zoom(double minX, double minY, double maxX, double maxY)
139
        {
140
            Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
141
            double[] lower = new double[3] { minX, minY, 0 };
142
            double[] upper = new double[3] { maxX, maxY, 0 };
143
            acadApplication.ZoomWindow(lower, upper);
144
            acadApplication.ActiveDocument.Activate();
145
        }
146
        private void ZoomAll()
147
        {
148
            Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
149
            acadApplication.ZoomAll();
150
            acadApplication.ActiveDocument.Activate();
151
        }
152

  
135 153
        #region Run Method
136 154
        private void RunLineModeling()
137 155
        {
......
225 243
            List<Model.Line> groupLine = new List<Model.Line>();
226 244
            List<string> points = new List<string>();
227 245
            GetConnectedGroupLine(line, groupLine, false);
246
            CoordinateCorrection(groupLine);
228 247
            GetGroupLinePoints(groupLine, points);
229 248

  
230 249
            LineNumber lineNumber = null;
......
266 285
                bool bAngle = CheckAngle(symbolRow);
267 286
                bool bBalloon = CheckBalloon(symbol);
268 287

  
269
                long handle = InsertSymbol(symbol, symbolRow, bAngle, bBalloon);
288
                long handle = DrawSymbol(symbol, symbolRow, bAngle, bBalloon);
270 289
                if (handle != 0)
271 290
                {
272 291
                    symbol.Aveva.Handle = handle;
......
284 303
        }
285 304
        private void TextModeling(Text text)
286 305
        {
287
            if (text.TextAngle == TextAngle.None)
306
            if (text.TextAngle == TextAngle.None || text.ASSOCIATION)
288 307
                return;
289 308

  
290 309
            if (text.Aveva.LabelType == LabelType.SingleText)
......
493 512
            else
494 513
                return 0;
495 514
        }
496
        private long InsertSymbol(Symbol symbol, DataRow symbolRow, bool needAngle, bool needBalloon)
515
        private long DrawSymbol(Symbol symbol, DataRow symbolRow, bool needAngle, bool needBalloon)
497 516
        {
498 517
            long handle = 0;
499 518
            try
......
517 536

  
518 537
                // Check Insert Point
519 538
                if (needAngle)
520
                    commandParam.Add(symbol.ANGLE);
539
                {
540
                    double degree = RadianToDegree(symbol.ANGLE);
541
                    commandParam.Add(degree);
542
                }
543
                    
521 544

  
522 545
                // Check Balloon
523 546
                if (needBalloon)
......
770 793
                if (i == groupLine.Count - 1)
771 794
                {
772 795
                    object connObj = line.CONNECTORS[1].ConnectedObject;
773
                    if (connObj != null && connObj.GetType() == typeof(Symbol))
796
                    if (connObj != null)
774 797
                    {
775 798
                        string point = GetPointByConnectedItem(connObj, line, false);
776 799
                        if (string.IsNullOrEmpty(point))
......
783 806
                }
784 807
            }
785 808
        }
809
        private void CoordinateCorrection(List<Model.Line> groupLine)
810
        {
811
            for (int i = 0; i < groupLine.Count; i++)
812
            {
813
                Model.Line line = groupLine[i];
814
                Model.Line line2 = null;
815
                if (i + 1 < groupLine.Count)
816
                    line2 = groupLine[i + 1];
817

  
818
                if (line2 != null)
819
                {
820
                    if (APIDUtils.IsConnectedLine(line, line2))
821
                    {
822
                        #region ConnLine corrdinate
823
                        if (line.SlopeType == SlopeType.HORIZONTAL && line2.SlopeType == SlopeType.VERTICAL)
824
                        {
825
                            line2.Aveva.Start_X = line.Aveva.End_X;
826
                            line2.Aveva.End_X = line.Aveva.End_X;
827
                        }
828
                        else if (line.SlopeType == SlopeType.VERTICAL && line2.SlopeType == SlopeType.HORIZONTAL)
829
                        {
830
                            line2.Aveva.Start_Y = line.Aveva.End_Y;
831
                            line2.Aveva.End_Y = line.Aveva.End_Y;
832
                        }
833
                        else if (line.SlopeType == SlopeType.HORIZONTAL && line2.SlopeType == SlopeType.HORIZONTAL)
834
                        {
835
                            line2.Aveva.Start_Y = line.Aveva.End_Y;
836
                            line2.Aveva.End_Y = line.Aveva.End_Y;
837
                        }
838
                        else if (line.SlopeType == SlopeType.VERTICAL && line2.SlopeType == SlopeType.VERTICAL)
839
                        {
840
                            line2.Aveva.Start_X = line.Aveva.End_X;
841
                            line2.Aveva.End_X = line.Aveva.End_X;
842
                        }
843
                        #endregion
844
                    }
845
                    else
846
                    {
847
                        SlopeType slopeType = APIDUtils.CalcSlope(line.Aveva.End_X, line.Aveva.End_Y, line2.Aveva.Start_X, line2.Aveva.Start_Y);
848
                        #region corrdinate
849
                        if (slopeType == SlopeType.HORIZONTAL && line.SlopeType == SlopeType.HORIZONTAL && line2.SlopeType == SlopeType.HORIZONTAL)
850
                        {
851
                            line2.Aveva.Start_Y = line.Aveva.End_Y;
852
                            line2.Aveva.End_Y = line.Aveva.End_Y;
853
                        }
854
                        else if (slopeType == SlopeType.VERTICAL && line.SlopeType == SlopeType.VERTICAL && line2.SlopeType == SlopeType.VERTICAL)
855
                        {
856
                            line2.Aveva.Start_X = line.Aveva.End_X;
857
                            line2.Aveva.End_X = line.Aveva.End_X;
858
                        }
859
                        #endregion
860

  
861
                    }
862
                }
863

  
864
                if (line.SlopeType == SlopeType.HORIZONTAL || line.SlopeType == SlopeType.VERTICAL)
865
                {
866
                    foreach (var connector in line.CONNECTORS.FindAll(loop => loop.ConnectedObject != null))
867
                    {
868
                        double lineX = 0;
869
                        double lineY = 0;
870
                        int index = line.CONNECTORS.IndexOf(connector);
871
                        if (index == 0)
872
                        {
873
                            lineX = line.Aveva.End_X;
874
                            lineY = line.Aveva.End_Y;
875
                        }
876
                        else
877
                        {
878
                            lineX = line.Aveva.Start_X;
879
                            lineY = line.Aveva.Start_Y;
880
                        }
881
                        System.Type type = connector.ConnectedObject.GetType();
882
                        if (type == typeof(Model.Symbol))
883
                        {
884
                            Symbol item = connector.ConnectedObject as Symbol;
885
                            SlopeType slopeType = APIDUtils.CalcSlope(item.Aveva.X, item.Aveva.Y, lineX, lineY);
886
                            if (slopeType == line.SlopeType)
887
                            {
888
                                if (line.SlopeType == SlopeType.HORIZONTAL)
889
                                    item.Aveva.Y = line.Aveva.End_Y;
890
                                else if (line.SlopeType == SlopeType.VERTICAL)
891
                                    item.Aveva.X = line.Aveva.End_X;
892
                            }
893
                        }
894
                        else if (type == typeof(OPC))
895
                        {
896
                            OPC item = connector.ConnectedObject as OPC;
897
                            SlopeType slopeType = APIDUtils.CalcSlope(item.Aveva.X, item.Aveva.Y, lineX, lineY);
898
                            if (slopeType == line.SlopeType)
899
                            {
900
                                if (line.SlopeType == SlopeType.HORIZONTAL)
901
                                    item.Aveva.Y = line.Aveva.End_Y;
902
                                else if (line.SlopeType == SlopeType.VERTICAL)
903
                                    item.Aveva.X = line.Aveva.End_X;
904
                            }
905
                        }
906
                    }
907
                }
908
            }
909
        }
786 910
        private string GetPointByConnectedItem(object connObj, Model.Line line, bool isStart)
787 911
        {
788 912
            string result = string.Empty;
......
904 1028

  
905 1029
            return result;
906 1030
        }
1031
        private double RadianToDegree(double angle)
1032
        {
1033
            return angle * (180.0 / Math.PI);
1034
        }
907 1035
        #endregion
908 1036

  
909 1037
        #region Test Source

내보내기 Unified diff

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