개정판 2eebe1a5
Feature: ID2와 연계하여 심볼을 줌하는 기능 추가
Change-Id: If8fba97b59861c2d10332bf66e63808e6865dba1
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 |
{ |
내보내기 Unified diff