프로젝트

일반

사용자정보

개정판 2eebe1a5

ID2eebe1a5b8c12b04340a3e6e69f5c829bc567933
상위 cdcde280
하위 fb8c9d6f

백흠경이(가) 9달 전에 추가함

Feature: ID2와 연계하여 심볼을 줌하는 기능 추가

Change-Id: If8fba97b59861c2d10332bf66e63808e6865dba1

차이점 보기:

ID2.Manager/ID2.Manager.Compare/App.config
43 43
      <setting name="ID2Port" serializeAs="String">
44 44
        <value>2549</value>
45 45
      </setting>
46
      <setting name="TcpServerPort" serializeAs="String">
47
        <value>3030</value>
48
      </setting>
46 49
    </ID2.Manager.Properties.Settings>
47 50
  </applicationSettings>
48 51
  <system.web>
ID2.Manager/ID2.Manager.Compare/Classes/TcpServer.cs
1
using devDept.Eyeshot;
2
using System;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Net;
6
using System.Net.Sockets;
7
using System.Text;
8
using System.Threading;
9
using System.Threading.Tasks;
10
using Telerik.WinControls;
11

  
12
namespace ID2.Manager.Classes
13
{
14
    public class TcpServer
15
    {
16
        private static readonly Lazy<TcpServer> lazy = new Lazy<TcpServer>(() => new TcpServer());
17
        public static TcpServer Instance
18
        {
19
            get { return lazy.Value; }
20
        }
21

  
22
        private readonly TcpListener tcp_Listener;  // TCP 통신 Listener 
23
        private Thread listenThread;                // Listener Thread 객체
24
        List<TcpClient> connectedClients = new List<TcpClient>();
25

  
26
        public delegate void ZoomEvent(string DwgName, double x, double y, double sizex, double sizey);
27
        public ZoomEvent OnZoomEvent;
28

  
29
        private TcpServer()
30
        {
31
            this.tcp_Listener = new TcpListener(IPAddress.Any, Properties.Settings.Default.TcpServerPort);                                   // TCP Listener Thread 정의
32
            this.listenThread = new Thread(new ThreadStart(ListenerThread)) { IsBackground = true };    // Listen Thread 생성(폼 종료시 쓰레드를 종료하기 위해 IsBackGround 속성을 true로 설정
33
            this.listenThread.Start();                                                                  // Thread 시작.
34
        }
35

  
36
        public void Close()
37
        {
38
            this.listenThread.Abort();
39

  
40
            foreach (TcpClient client in connectedClients)
41
            {
42
                client.Close();
43
                client.Dispose();
44
            }
45
            connectedClients.Clear();
46

  
47
            tcp_Listener.Stop();
48
        }
49

  
50
        /// <summary>
51
        /// // Listener Thread 정의
52
        /// </summary>
53
        private void ListenerThread()
54
        {
55
            try
56
            {
57
                tcp_Listener.Start(); // tcpListener 시작.
58
                while (true)
59
                {
60
                    TcpClient client = this.tcp_Listener.AcceptTcpClient();  /// 클라이언트 접속
61
                    connectedClients.Add(client);
62
                    {
63
                        Thread startClientThread = new Thread(new ParameterizedThreadStart(HandleClientComm)); // Client로 부터 접속
64
                        startClientThread.Start(client); // 시작.
65
                    }
66
                }
67

  
68
            }
69
            catch (Exception ex)
70
            {
71
                Console.WriteLine(ex.ToString());
72
            }
73
        }
74

  
75
        /// <summary>
76
        /// 클라이언트 요청 처리
77
        /// </summary>
78
        /// <param name="client"></param>
79
        private void HandleClientComm(object client)
80
        {
81
            try
82
            {
83
                TcpClient tcpClient = client as TcpClient;  // tcp Client 생성
84
                if (tcpClient == null) return;
85

  
86
                NetworkStream clientStream = tcpClient.GetStream();
87
                while (tcpClient.Connected)  // 클라이언트가 연결되어 있는 동안
88
                {
89
                    var reader = new System.IO.StreamReader(clientStream);  // 읽기 스트림 연결
90
                    string data = reader.ReadLine();
91

  
92
                    if (!string.IsNullOrEmpty(data))
93
                    {
94
                        var tokens = data.Split(',');
95
                        string UID = tokens[0];
96
                        double x = Convert.ToDouble(tokens[1]);
97
                        double y = Convert.ToDouble(tokens[2]);
98
                        double sizex = Convert.ToDouble(tokens[3]);
99
                        double sizey = Convert.ToDouble(tokens[4]);
100
                        string DwgName = tokens[5];
101

  
102
                        if (OnZoomEvent != null) OnZoomEvent(DwgName, x, y, sizex, sizey);
103
                    }
104
                }
105
            }
106
            catch (Exception ex)
107
            {
108
                Console.WriteLine(ex.ToString());
109
            }
110
        }
111
    }
112
}
ID2.Manager/ID2.Manager.Compare/Controls/Verification.cs
698 698
            return res;
699 699
        }
700 700

  
701
        /// <summary>
702
        /// 주어진 도면의 원본과 AVEVA를 비교한다.
703
        /// </summary>
704
        private void CompareDrawing(Document doc, bool ResultOnly = false)
701
        /// AutoCAD P&ID 파일을 화면에 표시한다.
702
        private void ShowAutoCADFile(string FilePath, Design design, bool clear = true)
705 703
        {
706
            /// AutoCAD P&ID 파일을 화면에 표시한다.
707
            void ShowAutoCADFile(string FilePath, Design design, bool clear = true)
708
            {
709
                if (clear) design.Clear();
710
                var AddEntities = new List<Entity>();
704
            if (clear) design.Clear();
705
            var AddEntities = new List<Entity>();
711 706

  
712
                if (System.IO.File.Exists(FilePath))
707
            if (System.IO.File.Exists(FilePath))
708
            {
709
                try
713 710
                {
714
                    try
715
                    {
716
                        #region 다른 프로세스에서 파일을 열고 있는 경우 처리
717
                        using (var fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
718
                        #endregion
711
                    #region 다른 프로세스에서 파일을 열고 있는 경우 처리
712
                    using (var fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
713
                    #endregion
719 714

  
715
                    {
716
                        devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(fs);
717
                        ra.DoWork();
718
                        var min = ra.Min;
719
                        if (!ra.Layers.Contains(Verification.AutoCADLayer)) ra.Layers.Add(Verification.AutoCADLayer, Verification.AutoCADColor);
720
                        if (!ra.Layers.Contains(Verification.AutoCADDiffLayer)) ra.Layers.Add(Verification.AutoCADDiffLayer, Verification.DiffColor);
721
                        if (!ra.Layers.Contains(Verification.AutoCADExceptLayer)) ra.Layers.Add(Verification.AutoCADExceptLayer, Verification.AutoCADColor);
722
                        foreach (var ent in ra.Entities)
720 723
                        {
721
                            devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(fs);
722
                            ra.DoWork();
723
                            var min = ra.Min;
724
                            if (!ra.Layers.Contains(Verification.AutoCADLayer)) ra.Layers.Add(Verification.AutoCADLayer, Verification.AutoCADColor);
725
                            if (!ra.Layers.Contains(Verification.AutoCADDiffLayer)) ra.Layers.Add(Verification.AutoCADDiffLayer, Verification.DiffColor);
726
                            if (!ra.Layers.Contains(Verification.AutoCADExceptLayer)) ra.Layers.Add(Verification.AutoCADExceptLayer, Verification.AutoCADColor);
727
                            foreach (var ent in ra.Entities)
728
                            {
729
                                /// 도면을 원점으로 맞춘다.
730
                                if (min.X != 0 && min.Y != 0) ent.Translate(-min.X, -min.Y);
724
                            /// 도면을 원점으로 맞춘다.
725
                            if (min.X != 0 && min.Y != 0) ent.Translate(-min.X, -min.Y);
731 726

  
732
                                if (ent is BlockReference blkref)
733
                                {
734
                                    AddEntities.AddRange(ExplodeBlockReference(ra.Blocks, blkref, Verification.AutoCADLayer, Verification.AutoCADColor));
735
                                }
727
                            if (ent is BlockReference blkref)
728
                            {
729
                                AddEntities.AddRange(ExplodeBlockReference(ra.Blocks, blkref, Verification.AutoCADLayer, Verification.AutoCADColor));
736 730
                            }
737
                            ra.AddToScene(design);
738 731
                        }
732
                        ra.AddToScene(design);
733
                        (design as MyModel).FilePath = FilePath;
739 734
                    }
740
                    catch (Exception ex)
741
                    {
742
                        RadMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, RadMessageIcon.Error);
743
                        return;
744
                    }
735
                }
736
                catch (Exception ex)
737
                {
738
                    RadMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, RadMessageIcon.Error);
739
                    return;
740
                }
745 741

  
746
                    #region LinearPath를 Line으로 분할한다.
747
                    design.Entities.ForEach(x =>
742
                #region LinearPath를 Line으로 분할한다.
743
                design.Entities.ForEach(x =>
744
                {
745
                    if (x is LinearPath lp)
748 746
                    {
749
                        if (x is LinearPath lp)
747
                        #region 정점 수가 2이고 LineWeight이 0 초과이고 길이가 ArrowMaxLength보다 작을때 화살표를 그려준다.
748
                        if (lp.Vertices.Count() == 2 && lp.LineWeight > 0 && lp.Length() < Forms.ExceptLayer.ArrowMaxLength)
750 749
                        {
751
                            #region 정점 수가 2이고 LineWeight이 0 초과이고 길이가 ArrowMaxLength보다 작을때 화살표를 그려준다.
752
                            if (lp.Vertices.Count() == 2 && lp.LineWeight > 0 && lp.Length() < Forms.ExceptLayer.ArrowMaxLength)
750
                            double weight = lp.LineWeight;
751
                            var dir = new devDept.Geometry.Vector3D(lp.Vertices[0], lp.Vertices[1]);
752
                            dir.Normalize();
753
                            var cross = devDept.Geometry.Vector3D.Cross(devDept.Geometry.Vector3D.AxisZ, dir);
754
                            var pts = new devDept.Geometry.Point3D[]
753 755
                            {
754
                                double weight = lp.LineWeight;
755
                                var dir = new devDept.Geometry.Vector3D(lp.Vertices[0], lp.Vertices[1]);
756
                                dir.Normalize();
757
                                var cross = devDept.Geometry.Vector3D.Cross(devDept.Geometry.Vector3D.AxisZ, dir);
758
                                var pts = new devDept.Geometry.Point3D[]
759
                                {
760 756
                                    lp.Vertices[1] + cross * weight * 0.5,
761 757
                                    lp.Vertices[0],
762 758
                                    lp.Vertices[1] - cross * weight * 0.5
763
                                };
759
                            };
764 760

  
765
                                var hatch = new Hatch("SOLID", new List<ICurve>() { new LinearPath(pts) });
766
                                AddEntities.Add(hatch);
767
                            }
768
                            #endregion
769
                            else
761
                            var hatch = new Hatch("SOLID", new List<ICurve>() { new LinearPath(pts) });
762
                            AddEntities.Add(hatch);
763
                        }
764
                        #endregion
765
                        else
766
                        {
767
                            int count = Convert.ToInt32(lp.Vertices.Length);
768
                            for (int i = 0; i < count - 1; ++i)
770 769
                            {
771
                                int count = Convert.ToInt32(lp.Vertices.Length);
772
                                for (int i = 0; i < count - 1; ++i)
770
                                AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1])
773 771
                                {
774
                                    AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1])
775
                                    {
776
                                        LayerName = lp.LayerName,
777
                                        LineWeight = lp.LineWeight,
778
                                        LineTypeMethod = colorMethodType.byEntity
779
                                    });
780
                                }
772
                                    LayerName = lp.LayerName,
773
                                    LineWeight = lp.LineWeight,
774
                                    LineTypeMethod = colorMethodType.byEntity
775
                                });
781 776
                            }
782 777
                        }
783
                    });
784
                    design.Entities.RemoveAll(x => (x is LinearPath));
785
                    #endregion
778
                    }
779
                });
780
                design.Entities.RemoveAll(x => (x is LinearPath));
781
                #endregion
786 782

  
787
                    design.Entities.AddRange(AddEntities);
783
                design.Entities.AddRange(AddEntities);
788 784

  
789
                    #region 브랜치가 생성되는 부분에서 파이프 라인을 분할
790
                    var queue = design.Entities.Where(x => x is Line && 
791
                    Forms.ExceptLayer.LineLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper())).ToList();
792
                    while (queue.Any())
785
                #region 브랜치가 생성되는 부분에서 파이프 라인을 분할
786
                var queue = design.Entities.Where(x => x is Line &&
787
                Forms.ExceptLayer.LineLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper())).ToList();
788
                while (queue.Any())
789
                {
790
                    var line1 = queue.First() as Line;
791
                    var dir1 = line1.Direction;
792
                    dir1.Normalize();
793
                    queue.Remove(line1);
794
                    for (int i = 0; i < queue.Count; ++i)
793 795
                    {
794
                        var line1 = queue.First() as Line;
795
                        var dir1 = line1.Direction;
796
                        dir1.Normalize();
797
                        queue.Remove(line1);
798
                        for (int i = 0; i < queue.Count; ++i)
796
                        var line2 = queue.ElementAt(i) as Line;
797
                        var dir2 = line2.Direction;
798
                        dir2.Normalize();
799
                        if (devDept.Geometry.Vector3D.AreOrthogonal(dir1, dir2))
799 800
                        {
800
                            var line2 = queue.ElementAt(i) as Line;
801
                            var dir2 = line2.Direction;
802
                            dir2.Normalize();
803
                            if (devDept.Geometry.Vector3D.AreOrthogonal(dir1, dir2))
801
                            var intersects = line1.IntersectWith(line2);
802
                            if (intersects.Count() == 1)
804 803
                            {
805
                                var intersects = line1.IntersectWith(line2);
806
                                if (intersects.Count() == 1)
804
                                if (line1.StartPoint.DistanceTo(intersects[0]) > 0.1 && line1.EndPoint.DistanceTo(intersects[0]) > 0.1)
807 805
                                {
808
                                    if (line1.StartPoint.DistanceTo(intersects[0]) > 0.1 && line1.EndPoint.DistanceTo(intersects[0]) > 0.1)
806
                                    var split1 = new devDept.Eyeshot.Entities.Line(line1.StartPoint, intersects[0])
809 807
                                    {
810
                                        var split1 = new devDept.Eyeshot.Entities.Line(line1.StartPoint, intersects[0])
811
                                        {
812
                                            LayerName = line1.LayerName,
813
                                            LineWeight = line1.LineWeight,
814
                                            LineTypeMethod = colorMethodType.byEntity
815
                                        };
816
                                        var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line1.EndPoint)
817
                                        {
818
                                            LayerName = line1.LayerName,
819
                                            LineWeight = line1.LineWeight,
820
                                            LineTypeMethod = colorMethodType.byEntity
821
                                        };
822
                                        design.Entities.Add(split1);
823
                                        design.Entities.Add(split2);
824
                                        design.Entities.Remove(line1);
825

  
826
                                        queue.Add(split1);
827
                                        queue.Add(split2);
828

  
829
                                        break;
830
                                    }
808
                                        LayerName = line1.LayerName,
809
                                        LineWeight = line1.LineWeight,
810
                                        LineTypeMethod = colorMethodType.byEntity
811
                                    };
812
                                    var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line1.EndPoint)
813
                                    {
814
                                        LayerName = line1.LayerName,
815
                                        LineWeight = line1.LineWeight,
816
                                        LineTypeMethod = colorMethodType.byEntity
817
                                    };
818
                                    design.Entities.Add(split1);
819
                                    design.Entities.Add(split2);
820
                                    design.Entities.Remove(line1);
821

  
822
                                    queue.Add(split1);
823
                                    queue.Add(split2);
824

  
825
                                    break;
826
                                }
831 827

  
832
                                    if (line2.StartPoint.DistanceTo(intersects[0]) > 0.1 && line2.EndPoint.DistanceTo(intersects[0]) > 0.1)
828
                                if (line2.StartPoint.DistanceTo(intersects[0]) > 0.1 && line2.EndPoint.DistanceTo(intersects[0]) > 0.1)
829
                                {
830
                                    var split1 = new devDept.Eyeshot.Entities.Line(line2.StartPoint, intersects[0])
833 831
                                    {
834
                                        var split1 = new devDept.Eyeshot.Entities.Line(line2.StartPoint, intersects[0])
835
                                        {
836
                                            LayerName = line2.LayerName,
837
                                            LineWeight = line2.LineWeight,
838
                                            LineTypeMethod = colorMethodType.byEntity
839
                                        };
840
                                        var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line2.EndPoint)
841
                                        {
842
                                            LayerName = line2.LayerName,
843
                                            LineWeight = line2.LineWeight,
844
                                            LineTypeMethod = colorMethodType.byEntity
845
                                        };
846
                                        design.Entities.Add(split1);
847
                                        design.Entities.Add(split2);
848
                                        design.Entities.Remove(line2);
849

  
850
                                        queue.Remove(line2);
851
                                        queue.Add(split1);
852
                                        queue.Add(split2);
853
                                    }
832
                                        LayerName = line2.LayerName,
833
                                        LineWeight = line2.LineWeight,
834
                                        LineTypeMethod = colorMethodType.byEntity
835
                                    };
836
                                    var split2 = new devDept.Eyeshot.Entities.Line(intersects[0], line2.EndPoint)
837
                                    {
838
                                        LayerName = line2.LayerName,
839
                                        LineWeight = line2.LineWeight,
840
                                        LineTypeMethod = colorMethodType.byEntity
841
                                    };
842
                                    design.Entities.Add(split1);
843
                                    design.Entities.Add(split2);
844
                                    design.Entities.Remove(line2);
845

  
846
                                    queue.Remove(line2);
847
                                    queue.Add(split1);
848
                                    queue.Add(split2);
854 849
                                }
855 850
                            }
856 851
                        }
857 852
                    }
858
                    #endregion
853
                }
854
                #endregion
859 855

  
860
                    #region 레이어 변경
861
                    foreach (var ent in design.Entities)
856
                #region 레이어 변경
857
                foreach (var ent in design.Entities)
858
                {
859
                    ent.Color = Verification.AutoCADColor;
860
                    ent.ColorMethod = colorMethodType.byEntity;
861
                    if (!Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == ent.LayerName.ToUpper()))
862 862
                    {
863
                        ent.Color = Verification.AutoCADColor;
864
                        ent.ColorMethod = colorMethodType.byEntity;
865
                        if (!Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == ent.LayerName.ToUpper()))
866
                        {
867
                            ent.LayerName = Verification.AutoCADLayer;
868
                        }
869
                        else
870
                        {
871
                            ent.LayerName = Verification.AutoCADExceptLayer;
872
                        }
863
                        ent.LayerName = Verification.AutoCADLayer;
873 864
                    }
874
                    #endregion
865
                    else
866
                    {
867
                        ent.LayerName = Verification.AutoCADExceptLayer;
868
                    }
869
                }
870
                #endregion
875 871

  
876
                    #region 블럭이거나 제외 레이어에 속한 항목은 제거
877
                    design.Entities.RemoveAll(x => (x is BlockReference) || Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible));
878
                    #endregion
872
                #region 블럭이거나 제외 레이어에 속한 항목은 제거
873
                design.Entities.RemoveAll(x => (x is BlockReference) || Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible));
874
                #endregion
879 875

  
880
                    #region 눈에 보이지 않는 라인은 제거
881
                    design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001);
882
                    #endregion
876
                #region 눈에 보이지 않는 라인은 제거
877
                design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001);
878
                #endregion
883 879

  
884
                    ColorEntities(design, design.Entities, Verification.AutoCADColor);
880
                ColorEntities(design, design.Entities, Verification.AutoCADColor);
885 881

  
886
                    // Sets the view as Top
887
                    design.SetView(viewType.Top);
888
                    design.ZoomFit();
889
                    design.Invalidate();
890
                }
882
                // Sets the view as Top
883
                design.SetView(viewType.Top);
884
                design.ZoomFit();
885
                design.Invalidate();
891 886
            }
887
        }
892 888

  
893
            /// AVEVA P&ID 파일을 화면에 표시한다.
894
            void ShowAVEVAPIDFile(string FilePath, Design design, bool clear = true)
889
        /// AVEVA P&ID 파일을 화면에 표시한다.
890
        void ShowAVEVAPIDFile(string FilePath, Design design, bool clear = true)
891
        {
892
            if (clear) design.Clear();
893
            if (System.IO.File.Exists(FilePath))
895 894
            {
896
                if (clear) design.Clear();
897
                if (System.IO.File.Exists(FilePath))
898
                {
899
                    var AddEntities = new List<Entity>();
895
                var AddEntities = new List<Entity>();
900 896

  
901
                    #region 다른 프로세스에서 파일을 열고 있는 경우 처리
902
                    using (var fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
903
                    #endregion
897
                #region 다른 프로세스에서 파일을 열고 있는 경우 처리
898
                using (var fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
899
                #endregion
900
                {
901
                    devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(fs);
902
                    ra.DoWork();
903

  
904
                    if (!ra.Layers.Contains(Verification.AVEVALayer)) ra.Layers.Add(Verification.AVEVALayer, Verification.AVEVAColor);
905
                    if (!ra.Layers.Contains(Verification.AVEVADiffLayer)) ra.Layers.Add(Verification.AVEVADiffLayer, Verification.DiffColor);
906
                    if (!ra.Layers.Contains(Verification.AVEVAExceptLayer)) ra.Layers.Add(Verification.AVEVAExceptLayer, Verification.AVEVAColor);
907
                    var min = ra.Min;
908
                    foreach (var ent in ra.Entities)
904 909
                    {
905
                        devDept.Eyeshot.Translators.ReadAutodesk ra = new devDept.Eyeshot.Translators.ReadAutodesk(fs);
906
                        ra.DoWork();
910
                        /// 도면을 원점으로 맞춘다.
911
                        if (min.X != 0 && min.Y != 0) ent.Translate(-min.X, -min.Y);
907 912

  
908
                        if (!ra.Layers.Contains(Verification.AVEVALayer)) ra.Layers.Add(Verification.AVEVALayer, Verification.AVEVAColor);
909
                        if (!ra.Layers.Contains(Verification.AVEVADiffLayer)) ra.Layers.Add(Verification.AVEVADiffLayer, Verification.DiffColor);
910
                        if (!ra.Layers.Contains(Verification.AVEVAExceptLayer)) ra.Layers.Add(Verification.AVEVAExceptLayer, Verification.AVEVAColor);
911
                        var min = ra.Min;
912
                        foreach (var ent in ra.Entities)
913
                        #region 멀티 라인들을 분할하여 추가한다.
914
                        if (ent is Mesh mesh && (mesh.LayerName == "AS_PIPE" || mesh.LayerName == "AS_INST"))
913 915
                        {
914
                            /// 도면을 원점으로 맞춘다.
915
                            if (min.X != 0 && min.Y != 0) ent.Translate(-min.X, -min.Y);
916

  
917
                            #region 멀티 라인들을 분할하여 추가한다.
918
                            if (ent is Mesh mesh && (mesh.LayerName == "AS_PIPE" || mesh.LayerName == "AS_INST"))
916
                            int count = Convert.ToInt32(mesh.Vertices.Length * 0.5);
917
                            for (int i = 0; i < count - 1; ++i)
919 918
                            {
920
                                int count = Convert.ToInt32(mesh.Vertices.Length * 0.5);
921
                                for (int i = 0; i < count - 1; ++i)
919
                                AddEntities.Add(new devDept.Eyeshot.Entities.Line(mesh.Vertices[i], mesh.Vertices[i + 1])
922 920
                                {
923
                                    AddEntities.Add(new devDept.Eyeshot.Entities.Line(mesh.Vertices[i], mesh.Vertices[i + 1])
921
                                    LayerName = Verification.AVEVALayer,
922
                                    LineWeight = 3.0f,
923
                                    LineTypeMethod = colorMethodType.byEntity,
924
                                    Color = Verification.AVEVAColor,
925
                                    ColorMethod = colorMethodType.byEntity
926
                                });
927
                            }
928
                        }
929
                        else if (ent is TabulatedSurface tf && (tf.LayerName == "AS_PIPE" || tf.LayerName == "AS_INST"))
930
                        {
931
                            int count = Convert.ToInt32(tf.ControlPoints.Length * 0.5);
932
                            for (int i = 0; i < count - 1; ++i)
933
                            {
934
                                AddEntities.Add(
935
                                    new devDept.Eyeshot.Entities.Line(
936
                                    new devDept.Geometry.Point3D(tf.ControlPoints[i, 0].X, tf.ControlPoints[i, 0].Y, 0),
937
                                    new devDept.Geometry.Point3D(tf.ControlPoints[i + 1, 0].X, tf.ControlPoints[i + 1, 0].Y, 0))
924 938
                                    {
925 939
                                        LayerName = Verification.AVEVALayer,
926 940
                                        LineWeight = 3.0f,
927 941
                                        LineTypeMethod = colorMethodType.byEntity,
928 942
                                        Color = Verification.AVEVAColor,
929 943
                                        ColorMethod = colorMethodType.byEntity
930
                                    });
931
                                }
944
                                    }
945
                                );
932 946
                            }
933
                            else if (ent is TabulatedSurface tf && (tf.LayerName == "AS_PIPE" || tf.LayerName == "AS_INST"))
947
                        }
948
                        else if (ent is LinearPath lp)
949
                        {
950
                            string LayerName = Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == lp.LayerName.ToUpper()) ?
951
                                Verification.AVEVAExceptLayer : Verification.AVEVALayer;
952
                            int count = Convert.ToInt32(lp.Vertices.Length);
953
                            for (int i = 0; i < count - 1; ++i)
934 954
                            {
935
                                int count = Convert.ToInt32(tf.ControlPoints.Length * 0.5);
936
                                for (int i = 0; i < count - 1; ++i)
955
                                AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1])
937 956
                                {
938
                                    AddEntities.Add(
939
                                        new devDept.Eyeshot.Entities.Line(
940
                                        new devDept.Geometry.Point3D(tf.ControlPoints[i, 0].X, tf.ControlPoints[i, 0].Y, 0),
941
                                        new devDept.Geometry.Point3D(tf.ControlPoints[i + 1, 0].X, tf.ControlPoints[i + 1, 0].Y, 0))
942
                                        {
943
                                            LayerName = Verification.AVEVALayer,
944
                                            LineWeight = 3.0f,
945
                                            LineTypeMethod = colorMethodType.byEntity,
946
                                            Color = Verification.AVEVAColor,
947
                                            ColorMethod = colorMethodType.byEntity
948
                                        }
949
                                    );
950
                                }
957
                                    LayerName = LayerName,
958
                                    LineWeight = lp.LineWeight,
959
                                    Color = Verification.AVEVAColor,
960
                                    LineTypeMethod = colorMethodType.byEntity
961
                                });
951 962
                            }
952
                            else if (ent is LinearPath lp)
953
                            {
954
                                string LayerName = Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == lp.LayerName.ToUpper()) ?
955
                                    Verification.AVEVAExceptLayer : Verification.AVEVALayer;
956
                                int count = Convert.ToInt32(lp.Vertices.Length);
957
                                for (int i = 0; i < count - 1; ++i)
958
                                {
959
                                    AddEntities.Add(new devDept.Eyeshot.Entities.Line(lp.Vertices[i], lp.Vertices[i + 1])
960
                                    {
961
                                        LayerName = LayerName,
962
                                        LineWeight = lp.LineWeight,
963
                                        Color = Verification.AVEVAColor,
964
                                        LineTypeMethod = colorMethodType.byEntity
965
                                    });
966
                                }
967 963

  
968
                                #region 밑에서 제거하기 위해 레이어를 AVEVALayer로 바꿔준다.
969
                                lp.LayerName = Verification.AVEVALayer;
970
                                #endregion
971
                            }
964
                            #region 밑에서 제거하기 위해 레이어를 AVEVALayer로 바꿔준다.
965
                            lp.LayerName = Verification.AVEVALayer;
972 966
                            #endregion
973
                            else if (ent is BlockReference blkref)
967
                        }
968
                        #endregion
969
                        else if (ent is BlockReference blkref)
970
                        {
971
                            if (blkref.BlockName != "LBRK" && blkref.BlockName != "PSNODE" && blkref.BlockName != "PENODE")
974 972
                            {
975
                                if (blkref.BlockName != "LBRK" && blkref.BlockName != "PSNODE" && blkref.BlockName != "PENODE")
976
                                {
977
                                    AddEntities.AddRange(ExplodeBlockReference(ra.Blocks, blkref, Verification.AVEVALayer, Verification.AVEVAColor));
978
                                }
973
                                AddEntities.AddRange(ExplodeBlockReference(ra.Blocks, blkref, Verification.AVEVALayer, Verification.AVEVAColor));
979 974
                            }
975
                        }
980 976

  
981
                            ent.Color = Verification.AVEVAColor;
982
                            ent.ColorMethod = colorMethodType.byEntity;
983
                            if (!Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == ent.LayerName.ToUpper()))
984
                            {
985
                                ent.LayerName = Verification.AVEVALayer;
986
                            }
987
                            else
988
                            {
989
                                ent.LayerName = Verification.AVEVAExceptLayer;
990
                            }
977
                        ent.Color = Verification.AVEVAColor;
978
                        ent.ColorMethod = colorMethodType.byEntity;
979
                        if (!Forms.ExceptLayer.ExceptLayers.Exists(x => x.Name.ToUpper() == ent.LayerName.ToUpper()))
980
                        {
981
                            ent.LayerName = Verification.AVEVALayer;
982
                        }
983
                        else
984
                        {
985
                            ent.LayerName = Verification.AVEVAExceptLayer;
991 986
                        }
992
                        ra.AddToScene(design);
993 987
                    }
988
                    ra.AddToScene(design);
989
                }
994 990

  
995
                    #region 불필요한 블럭들은 제거
996
                    design.Entities.RemoveAll(x => x is BlockReference);
997
                    #endregion
991
                #region 불필요한 블럭들은 제거
992
                design.Entities.RemoveAll(x => x is BlockReference);
993
                #endregion
998 994

  
999
                    #region 블럭을 깸
1000
                    design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList().ForEach(x =>
995
                #region 블럭을 깸
996
                design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList().ForEach(x =>
997
                {
998
                    if (x is BlockReference blkref)
1001 999
                    {
1002
                        if(x is BlockReference blkref)
1003
                        {
1004
                            AddEntities.AddRange(ExplodeBlockReference(design.Blocks, blkref, Verification.AVEVALayer, Verification.AVEVAColor));
1005
                        }
1006
                    });
1007
                    design.Entities.RemoveAll(x =>
1008
                    ((x is Mesh || x is TabulatedSurface) && (x.LayerName == Verification.AVEVALayer)) ||
1009
                    (x is LinearPath && x.LayerName == Verification.AVEVALayer) || (x is BlockReference) ||
1010
                    Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible));
1011
                    design.Entities.AddRange(AddEntities);
1012
                    #endregion
1000
                        AddEntities.AddRange(ExplodeBlockReference(design.Blocks, blkref, Verification.AVEVALayer, Verification.AVEVAColor));
1001
                    }
1002
                });
1003
                design.Entities.RemoveAll(x =>
1004
                ((x is Mesh || x is TabulatedSurface) && (x.LayerName == Verification.AVEVALayer)) ||
1005
                (x is LinearPath && x.LayerName == Verification.AVEVALayer) || (x is BlockReference) ||
1006
                Forms.ExceptLayer.ExceptLayers.Exists(y => y.Name.ToUpper() == x.LayerName.ToUpper() && !y.Visible));
1007
                design.Entities.AddRange(AddEntities);
1008
                #endregion
1013 1009

  
1014
                    #region 눈에 보이지 않는 라인은 제거
1015
                    design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001);
1016
                    #endregion
1010
                #region 눈에 보이지 않는 라인은 제거
1011
                design.Entities.RemoveAll(x => x is Line line && line.Length() < 0.001);
1012
                #endregion
1017 1013

  
1018
                    ColorEntities(design, design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList(), Verification.AVEVAColor);
1014
                ColorEntities(design, design.Entities.Where(x => x.LayerName == Verification.AVEVALayer).ToList(), Verification.AVEVAColor);
1019 1015

  
1020
                    design.SetView(viewType.Top);
1021
                    design.ZoomFit();
1022
                    design.Invalidate();
1023
                }
1016
                design.SetView(viewType.Top);
1017
                design.ZoomFit();
1018
                design.Invalidate();
1024 1019
            }
1020
        }
1025 1021

  
1022
        /// <summary>
1023
        /// 주어진 도면의 원본과 AVEVA를 비교한다.
1024
        /// </summary>
1025
        private void CompareDrawing(Document doc, bool ResultOnly = false)
1026
        {
1026 1027
            string dwgExtension = ".dwg";
1027 1028
            string ID2DrawingFolder = Program.AutoCADFolder;
1028 1029
            string dwgFilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{doc.DocumentNo}{dwgExtension}");
......
1101 1102
            return false;
1102 1103
        }
1103 1104

  
1105
        /// <summary>
1106
        /// BoxMin, BoxMax로 ZoomFit합니다.
1107
        /// </summary>
1108
        /// <param name="BoxMin"></param>
1109
        /// <param name="BoxMax"></param>
1110
        private void CustomZoomFit(Workspace workspace, devDept.Geometry.Point3D BoxMin, devDept.Geometry.Point3D BoxMax)
1111
        {
1112
            #region point must be added to desgin
1113
            var EntMin = new devDept.Eyeshot.Entities.Point(BoxMin);
1114
            workspace.Entities.Add(EntMin);
1115
            var EntMax = new devDept.Eyeshot.Entities.Point(BoxMax);
1116
            workspace.Entities.Add(EntMax);
1117
            #endregion
1118
            List<Entity> entList = new List<Entity>() { EntMin, EntMax };
1119
            workspace.ZoomFit(entList, false);
1120
            #region delete points
1121
            workspace.Entities.Remove(EntMin);
1122
            workspace.Entities.Remove(EntMax);
1123
            #endregion
1124
        }
1125

  
1126
        /// <summary>
1127
        /// ID2에서 넘어온 영역을 Zoom한다.
1128
        /// </summary>
1129
        /// <param name="list"></param>
1130
        public void ZoomEventHandler(string DwgName, double x, double y, double sizex, double sizey)
1131
        {
1132
            string dwgExtension = ".dwg";
1133
            string ID2DrawingFolder = Program.AutoCADFolder;
1134
            string dwgFilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{DwgName}{dwgExtension}");
1135
            this.Invoke(new Action(() =>
1136
            {
1137
                var ID2DefaultSize = new Size(9600, 6787);
1138
                double margin = 5;
1139

  
1140
                if (!dwgFilePath.Equals(this.designCompare.FilePath)) ShowAutoCADFile(dwgFilePath, this.designCompare);
1141
                
1142
                double ScaleX = this.designCompare.Entities.BoxSize.X / ID2DefaultSize.Width;
1143
                double ScaleY = this.designCompare.Entities.BoxSize.Y / ID2DefaultSize.Height;
1144
                x *= ScaleX;
1145
                y *= ScaleY;
1146
                y = this.designCompare.Entities.BoxSize.Y - y;
1147
                sizex *= ScaleX;
1148
                sizey *= ScaleY;
1149
                x -= sizex * 0.5;
1150
                y -= sizey * 0.5;
1151
                var ItemRect = new OrientedBoundingRect(new devDept.Geometry.Point2D(x, y), sizex, sizey);
1152

  
1153
                CustomZoomFit(this.designCompare, 
1154
                    new devDept.Geometry.Point3D(x - sizex * margin, y - sizey * margin), 
1155
                    new devDept.Geometry.Point3D(x + sizex * margin * 2, y + sizey * margin * 2));
1156
                this.designCompare.Entities.ClearSelection();
1157
                this.designCompare.Entities.ForEach(param => 
1158
                {
1159
                    var obr = new OrientedBoundingRect(param.BoxMin, param.BoxSize.X, param.BoxSize.Y);
1160
                    if(OrientedBoundingRect.DoOverlap(ItemRect, obr)) param.Selected = true;
1161
                });
1162
                this.designCompare.Invalidate();
1163
            }));
1164
        }
1165

  
1104 1166
        #region Camera Sync
1105 1167
        private void CameraChanged(object sender, devDept.Eyeshot.Workspace.CameraMoveEventArgs e)
1106 1168
        {
ID2.Manager/ID2.Manager.Compare/ID2.Manager.Compare.csproj
104 104
    <Compile Include="Classes\CompareModelWorkUnit.cs" />
105 105
    <Compile Include="Classes\ID2Helper.cs" />
106 106
    <Compile Include="Classes\LinqExtension.cs" />
107
    <Compile Include="Classes\TcpServer.cs" />
107 108
    <Compile Include="Controls\DetailGridViewTemplate.cs">
108 109
      <SubType>Component</SubType>
109 110
    </Compile>
ID2.Manager/ID2.Manager.Compare/Main.cs
25 25
{
26 26
    public partial class Main : RadRibbonForm
27 27
    {
28
        private TcpServer _TcpServer { get; } = TcpServer.Instance;
29

  
28 30
        protected override CreateParams CreateParams
29 31
        {
30 32
            get
......
129 131
        private void Initialize()
130 132
        {
131 133
            this.ID2ManagerRadRibbonBar.Expanded = false;
134
            this.FormClosing += Main_FormClosing;
135
        }
136

  
137
        /// <summary>
138
        /// TcpServer를 종료한다.
139
        /// </summary>
140
        /// <param name="sender"></param>
141
        /// <param name="e"></param>
142
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
143
        {
144
            this._TcpServer.Close();
132 145
        }
133 146

  
134 147
        protected override void OnLoad(EventArgs e)
......
174 187
                Program.logger.Error($"An exception occurred from {MethodBase.GetCurrentMethod().Name}", ex);
175 188
                RadMessageBox.Show("Failed to load project.", Application.ProductName, MessageBoxButtons.OK, RadMessageIcon.Error);
176 189
            }
190
            finally
191
            {
192
                var verification = this.LayoutValidation.Controls[0] as Controls.Verification;
193
                _TcpServer.OnZoomEvent += verification.ZoomEventHandler;
194
            }
177 195

  
178 196
            base.OnLoad(e);
179 197
        }
ID2.Manager/ID2.Manager.Compare/Properties/AssemblyInfo.cs
16 16
[assembly: Guid("226ce2a3-dd88-4c99-a8e6-fac5a4d78c71")]
17 17

  
18 18
// [assembly: AssemblyVersion("1.0.*")]
19
[assembly: AssemblyVersion("20.24.3.21")]
20
[assembly: AssemblyFileVersion("20.24.3.21")]
19
[assembly: AssemblyVersion("20.24.5.2")]
20
[assembly: AssemblyFileVersion("20.24.5.2")]
21 21
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log.config", Watch = true)]
ID2.Manager/ID2.Manager.Compare/Properties/Settings.Designer.cs
12 12
    
13 13
    
14 14
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
15
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
16 16
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 17
        
18 18
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......
80 80
                this["MarkusService"] = value;
81 81
            }
82 82
        }
83
        
84
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
85
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
86
        [global::System.Configuration.DefaultSettingValueAttribute("3030")]
87
        public int TcpServerPort {
88
            get {
89
                return ((int)(this["TcpServerPort"]));
90
            }
91
        }
83 92
    }
84 93
}
ID2.Manager/ID2.Manager.Compare/Properties/Settings.settings
17 17
    <Setting Name="MarkusService" Type="System.String" Scope="User">
18 18
      <Value Profile="(Default)">http://192.168.0.147:9991/Markusapi/MarkusImageCreateAPI</Value>
19 19
    </Setting>
20
    <Setting Name="TcpServerPort" Type="System.Int32" Scope="Application">
21
      <Value Profile="(Default)">3030</Value>
22
    </Setting>
20 23
  </Settings>
21 24
</SettingsFile>

내보내기 Unified diff

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