Explorar el Código

refactor the OTSSamplespaceWindow's class structure.

gsp hace 1 año
padre
commit
25a8d5866c
Se han modificado 19 ficheros con 1099 adiciones y 970 borrados
  1. 3 3
      OTSCPP/OTSData/Domain.h
  2. 3 0
      OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs
  3. 1 1
      OTSIncAMeasureApp/0-OTSModel/OTSDataType/otsdataconst.cs
  4. 1 1
      OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSDisplaySampleGrid.cs
  5. 1 1
      OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSPropertyWindow.cs
  6. 8 7
      OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSSampleVisualPropertyInfo.cs
  7. 6 1
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSampleData.cs
  8. 224 177
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs
  9. 1 1
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/SEMDATAFieldManage.cs
  10. 102 575
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CDisplayGDIObject.cs
  11. 438 0
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CMeasureArea.cs
  12. 37 15
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CRingGDIObject.cs
  13. 72 0
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CVisualFieldGDIObject.cs
  14. 23 22
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CVisualSampleArea.cs
  15. 139 139
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CVisualStage.cs
  16. 30 15
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/sampleSpaceObject.cd
  17. 6 4
      OTSIncAMeasureApp/OTSIncAMeasureApp.csproj
  18. 3 7
      OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs
  19. 1 1
      OTSIncAMeasureApp/ResourceManage/ResourceData.cs

+ 3 - 3
OTSCPP/OTSData/Domain.h

@@ -7,10 +7,10 @@ namespace OTSDATA {
 	{
 		INVALID = -1,
 		MIN = 0,
-		ROUND = 0,
-		POLYGON = 15,
+		ROUND = 0,		
 		RECTANGLE = 1,
-		MAX = 1
+		POLYGON = 2,
+		MAX = 2
 	} DOMAIN_SHAPE;
 
 	__declspec(dllexport) const int DOMAIN_ITEM_NUMBER = 5;

+ 3 - 0
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -24,6 +24,7 @@ namespace OTSDataType
 
         int measureSequence;
 
+        private bool m_enable;
         // position (from field center manager) 
         protected System.Drawing.PointF m_otsPos;
 
@@ -56,6 +57,7 @@ namespace OTSDataType
         public int ImgHeight { get => imgheight; set => imgheight = value; }
         public int ImgWidth { get => imgwidth; set => imgwidth = value; }
         public COTSSample Sample { get => m_sample; set => m_sample = value; }
+        public bool Enable { get => m_enable; set => m_enable = value; }
 
         internal COTSRect GetOTSRect()
         {
@@ -157,6 +159,7 @@ namespace OTSDataType
             m_nID = -1;
             m_otsPos = new System.Drawing.Point(0, 0);
             m_listAllParticles.Clear();
+            m_enable = true;
         }
 
 

+ 1 - 1
OTSIncAMeasureApp/0-OTSModel/OTSDataType/otsdataconst.cs

@@ -224,7 +224,7 @@ namespace OTSDataType
           
             RECTANGLE = 1,
 
-            POLYGON=15
+            POLYGON=2
            
         }
         public enum OTS_MEASURE_FIELD_STOP_MODE

+ 1 - 1
OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSDisplaySampleGrid.cs

@@ -1019,7 +1019,7 @@ namespace OTSMeasureApp
                     }
                     break;
 
-                case OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE:                 //像素尺寸(微米)(正浮点数,不含0)
+                case OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE:                 //像素尺寸(微米)(正浮点数,不含0)
                     if (in_str.Trim() == "0") return false;
                     if (false == rg_fds_bhl.Match(in_str.Trim()).Success)
                     {

+ 1 - 1
OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSPropertyWindow.cs

@@ -224,7 +224,7 @@ namespace OTSMeasureApp
 
             if (
                    OTS_SAMPLE_PROP_GRID_ITEMS.MAGNIFICATION == SampleId
-                    || OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE == SampleId
+                    || OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE == SampleId
                    || OTS_SAMPLE_PROP_GRID_ITEMS.START_PHOTO_MODE == SampleId
                     || OTS_SAMPLE_PROP_GRID_ITEMS.XRAYSCAN_MODE == SampleId
                     )

+ 8 - 7
OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSSampleVisualPropertyInfo.cs

@@ -7,6 +7,7 @@ using static OTSDataType.otsdataconst;
 using OTSModelSharp.ResourceManage;
 using OTSModelSharp;
 using System.IO;
+using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects;
 
 namespace OTSMeasureApp
 {
@@ -497,7 +498,7 @@ namespace OTSMeasureApp
                     }
                     break;
 
-                case OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE:
+                case OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE:
                     {
                         if ((double)objVal < RESOLUTION_MIN || (double)objVal > RESOLUTION_MAX)
                         {
@@ -1153,7 +1154,7 @@ namespace OTSMeasureApp
 
                                 // pixel size
                                 poPropItem = new CPropItem();
-                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE;
+                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE;
                                 poPropItem.InitialSmplParameter(a_nId, nItemId, OTS_ITEM_TYPES.STRING, true, true);
                                 a_listPropItems.Add(poPropItem);
 
@@ -1185,7 +1186,7 @@ namespace OTSMeasureApp
 
                                 // pixel size
                                 poPropItem = new CPropItem();
-                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE;
+                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE;
                                 poPropItem.InitialSmplParameter(a_nId, nItemId, OTS_ITEM_TYPES.DOUBLE, false, true);
                                 a_listPropItems.Add(poPropItem);
 
@@ -1611,7 +1612,7 @@ namespace OTSMeasureApp
 
                                 // pixel size
                                 poPropItem = new CPropItem();
-                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE;
+                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE;
                                 poPropItem.InitialSmplParameter(a_nId, nItemId, OTS_ITEM_TYPES.STRING, true, true);
                                 a_listPropItems.Add(poPropItem);
 
@@ -1643,7 +1644,7 @@ namespace OTSMeasureApp
 
                                 // pixel size
                                 poPropItem = new CPropItem();
-                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE;
+                                nItemId = OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE;
                                 poPropItem.InitialSmplParameter(a_nId, nItemId, OTS_ITEM_TYPES.DOUBLE, false, true);
                                 a_listPropItems.Add(poPropItem);
 
@@ -1905,7 +1906,7 @@ namespace OTSMeasureApp
                     }
                     break;
 
-                case OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE:
+                case OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE:
                     {
                         a_dValue =m_Sample. CalculatePixelSize();
                     }
@@ -2009,7 +2010,7 @@ namespace OTSMeasureApp
                     }
                     break;
 
-                case OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE:
+                case OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE:
                     {
                         a_strValue = NOT_APPLIED;
                     }

+ 6 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSampleData.cs

@@ -10,7 +10,12 @@ using System.Threading.Tasks;
 
 namespace OTSMeasureApp
 {
-
+    public enum ShapeType
+    {
+        CIRCLE = 0,       //圆形
+        RECTANGLE = 1,     //矩形
+        POLYGON = 2
+    };
     enum OTS_X_AXIS_DIRECTION
     {
         LEFT_TOWARD = 0,

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 224 - 177
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs


+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/SEMDATAFieldManage.cs

@@ -232,7 +232,7 @@ namespace OTSMeasureApp
         #endregion
 
         #region 驱动SEM到中心位置
-        public bool DriveSEMToLocation(Point mousePoint,CVisualStage stage, List<CDisplayGDIObject> m_MeasureFieldGDIObjects)
+        public bool DriveSEMToLocation(Point mousePoint,CVisualStage stage, List<CVisualFieldGDIObject> m_MeasureFieldGDIObjects)
         {
             try
             {

+ 102 - 575
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CDisplayGDIObject.cs → OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CDisplayGDIObject.cs

@@ -29,12 +29,12 @@ namespace OTSMeasureApp
         /// <param name="height">高度</param>
         /// <param name="cType">图形类型:createType=0 圆角矩形 createType=1 圆形 createType=2 文字</param>
         /// <param name="content">文字内容</param>
-        public CDisplayGDIObject(float startx, float starty, float width, float height, CreateRectangleType cType, string content, string name)
+        public CDisplayGDIObject(float startx, float starty, float width, float height, GDIType cType, string content, string name)
         {
             var rec = new RectangleF(startx, starty, width, height);
             m_OrigineRegionF = rec;
             SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
+            GDIType = cType;
             strContent = content;
             NameOrHoleName = name;
             ID = System.Guid.NewGuid().ToString();
@@ -42,87 +42,59 @@ namespace OTSMeasureApp
             OTSY = -1;
         }
 
-        public CDisplayGDIObject(RectangleF rect, CreateRectangleType cType)
+        public CDisplayGDIObject(RectangleF rect, GDIType cType)
         {
        
             m_OrigineRegionF = rect;
             SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
+            GDIType = cType;
             ID = System.Guid.NewGuid().ToString();
        
             OTSX = -1;
             OTSY = -1;
         }
-        public CDisplayGDIObject(RectangleF rect, CreateRectangleType cType, string name)
+        public CDisplayGDIObject(RectangleF rect, GDIType cType, string name)
         {
      
             m_OrigineRegionF = rect;
             SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
+            GDIType = cType;
             NameOrHoleName = name;
             ID = System.Guid.NewGuid().ToString();
             OTSX = -1;
             OTSY = -1;
         }
  
-        public CDisplayGDIObject(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name, Color selColor)
+        public CDisplayGDIObject(RectangleF rect, GDIType cType, string name, Color selColor)
         {
           
             m_OrigineRegionF = rect;
             SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
+            GDIType = cType;
             NameOrHoleName = name;
-            Shape = shape;
+         
             SelColor = selColor;
             ID = System.Guid.NewGuid().ToString();
             OTSX = -1;
             OTSY = -1;
         }
-        public CDisplayGDIObject(RectangleF rectMeasure,  CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
-        {
-      
-            m_OrigineRegionF = rectMeasure;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            Shape = shape;
-            SelColor = selColor;
-          
-            SampleName = sampleName;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
-        //绘制帧图
-        public CDisplayGDIObject(RectangleF rectSingle, CreateRectangleType cType, string name, string sampleName, Color selColor)
+       
+        //绘制小矩形
+        public CDisplayGDIObject(RectangleF rectSingle, GDIType cType, string name, string sampleName, Color selColor)
         {
           
             m_OrigineRegionF = rectSingle;
             SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
+            GDIType = cType;
             NameOrHoleName = name;
-            Shape = 0;
+           
             SelColor = selColor;
             SampleName = sampleName;
             ID = System.Guid.NewGuid().ToString();
             OTSX = -1;
             OTSY = -1;
         }
-        //绘制帧图
-        public CDisplayGDIObject(RectangleF rectField, int OTSx, int OTSy, CreateRectangleType cType, string name, string sampleName, Color selColor)
-        {
-         
-            m_OrigineRegionF = rectField;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            Shape = 0;
-            SelColor = selColor;
-            SampleName = sampleName;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = OTSx;
-            OTSY = OTSy;
-        }
+  
 
         /// <summary>
         /// 获取样品孔中BSE图像
@@ -134,7 +106,7 @@ namespace OTSMeasureApp
         /// <param name="bseImageHeight">图像高度</param>
         /// <param name="drawImageLocation">图像开始位置</param>
         /// <param name="cType">绘制类型</param>
-        public CDisplayGDIObject(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName,  float bseImageWitdh, float bseImageHeight, CreateRectangleType cType)
+        public CDisplayGDIObject(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName,  float bseImageWitdh, float bseImageHeight, GDIType cType)
         {
          
             m_OrigineRegionF = rect;
@@ -143,8 +115,7 @@ namespace OTSMeasureApp
             SampleName = sampleName;
             //生成编号
             ID = System.Guid.NewGuid().ToString();
-            //图像信息
-            //BSEImage = bseImage;
+       
             //图像宽度
             BSEImageWitdh = bseImageWitdh;
             //图像高度
@@ -154,72 +125,26 @@ namespace OTSMeasureApp
             OTSX = OTSx;
             OTSY = OTSy;
             //绘制类型
-            CreateType = cType;
-        }
-
-
-        public CDisplayGDIObject(RectangleF rect, Point ImgPoint, float m_Multiple, CreateRectangleType cType)
-        {
-
-            m_OrigineRegionF = rect;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            ID = System.Guid.NewGuid().ToString();
-  
-            OTSX = -1;
-            OTSY = -1;
+            GDIType = cType;
         }
-        /// <summary>
-        /// 获取多边形点集合
-        /// </summary>
-        /// <param name="mPoint"></param>
-        /// <param name="cType"></param>
-        public CDisplayGDIObject(List<PointF> mPoint, CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
-        {
-            ID = System.Guid.NewGuid().ToString();
 
-            this.SetOriginalPolygonPointFList(mPoint);
-
-
-           
-            CreateType = cType;
-            Shape = shape;
-            SelColor = selColor;
-
-
-         
-
-
-        }
         #region 变量重写
         public virtual  void OnPaint(PaintEventArgs e) 
         {
-            if (createType == CreateRectangleType.SampleBackGround_Rectangle)
+            if (createType == GDIType.StageBoundary_RoundedRectangle)
             {
                 //获取颜色
                 Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.RoundRectangleColor);
                 
                 System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
                 GraphicsPath grPath = CreateRoundedRectanglePath(m_RegionF, 20);
-                //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
+             
                 e.Graphics.FillPath(sampleBrush, grPath);
                 e.Graphics.DrawPath(Pens.Black, grPath);
             }
-            //样品台-圆形
-            else if (createType == CreateRectangleType.SampleBackGround_Circle)
-            {
-                //获取颜色
-                Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleBackGroundColor);
-                
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                e.Graphics.FillEllipse(sampleBrush, m_RegionF);
-                e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
-            }
+        
             //圆形
-            else if (createType == CreateRectangleType.Circle)
+            else if (createType == GDIType.StageBoundary_Circle)
             {
                 System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
@@ -229,7 +154,7 @@ namespace OTSMeasureApp
                 e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
             }
             //文字
-            else if (createType == CreateRectangleType.Text)
+            else if (createType == GDIType.Text)
             {
                 //设置文字对齐方式               
                     StringFormat sf = new StringFormat();
@@ -258,7 +183,7 @@ namespace OTSMeasureApp
                 
             }
             //矩形
-            else if (createType == CreateRectangleType.Rectangle)
+            else if (createType == GDIType.Rectangle)
             {
                 Color myColor = System.Drawing.Color.White;
                 System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
@@ -272,61 +197,10 @@ namespace OTSMeasureApp
                 m_Region.Width = (int)m_RegionF.Width;
                 m_Region.Height = (int)m_RegionF.Height;
                 e.Graphics.DrawRectangle(Pens.Black, m_Region);
-            }
-            //选择样品台
-            else if (createType == CreateRectangleType.SelectSample)
-            {
-                Color myColor = selColor;
-
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-      
-                if (Shape == 0)
-                {
-
-                    e.Graphics.FillEllipse(sampleBrush, m_RegionF);
-                    e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
-                }
-                else
-                {
-                    e.Graphics.FillRectangle(sampleBrush, m_RegionF);
-                    var m_Region = new Rectangle();
-                    m_Region.X = (int)m_RegionF.X;
-                    m_Region.Y = (int)m_RegionF.Y;
-                    m_Region.Width = (int)m_RegionF.Width;
-                    m_Region.Height = (int)m_RegionF.Height;
-                    e.Graphics.DrawRectangle(Pens.Black, m_Region);
-                }
-            }
-            //测试区域
-            else if (createType == CreateRectangleType.MeasureArea)
-            {
-                Color myColor = selColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen p = new Pen(myColor, 1);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-
-
-                if (Shape == 0)
-                {
-
-                    e.Graphics.DrawEllipse(p, m_RegionF);
-                }
-                else
-                {
-                    var m_Region = new Rectangle();
-                    m_Region.X = (int)m_RegionF.X;
-                    m_Region.Y = (int)m_RegionF.Y;
-                    m_Region.Width = (int)m_RegionF.Width;
-                    m_Region.Height = (int)m_RegionF.Height;
-
-                    e.Graphics.DrawRectangle(p, m_Region);
-
-                }
-            }
+            }           
+            
             //绘制帧图 直线
-            else if (createType == CreateRectangleType.SingleLine)
+            else if (createType == GDIType.SingleLine)
             {
                 //设置颜色
                 Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FieldColor);
@@ -347,7 +221,7 @@ namespace OTSMeasureApp
 
             }
             //绘制标样
-            else if (createType == CreateRectangleType.SpecimenRectangle)
+            else if (createType == GDIType.SpecimenRectangle)
             {
                 Color myColor = System.Drawing.Color.Black;
                 System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
@@ -359,10 +233,10 @@ namespace OTSMeasureApp
                 m_Region.Width = (int)m_RegionF.Width;
                 m_Region.Height = (int)m_RegionF.Height;
                 e.Graphics.DrawRectangle(pen, m_Region);
-                e.Graphics.FillRectangle(sampleBrush, m_Region);
+                e.Graphics.FillRectangle(sampleBrush, m_RegionF);
             }
             //绘制标样
-            else if (createType == CreateRectangleType.SpecimenCircle)
+            else if (createType == GDIType.SpecimenCircle)
             {
                 Color myColor = System.Drawing.Color.Black;
                 System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
@@ -371,67 +245,10 @@ namespace OTSMeasureApp
                 e.Graphics.DrawEllipse(pen, m_RegionF);
                 e.Graphics.FillEllipse(sampleBrush, m_RegionF);
             }
-            //绘制帧图
-            else if (createType == CreateRectangleType.FieldRectangle)
-            {
-                Color myColor = SelColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.01f);
-                e.Graphics.SmoothingMode = SmoothingMode.Default;
-                //设置直线位置与尺寸
-                PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
-                PointF endPointF = new PointF(m_RegionF.Right, m_RegionF.Bottom);
-                if (m_RegionF.Height > 20)//won't display when it's too small,to speed up
-                {
-                    float fontSize = m_RegionF.Width / 4;
-                    Font font;
-                    if (fontSize == 0)
-                    {
-                        font = new Font("宋体", 5, FontStyle.Regular);
-                    }
-                    else
-                    {
-                        font = new Font("宋体", fontSize, FontStyle.Regular);
-                    }
-               
-                    StringFormat sf = new StringFormat();
-                    sf.Alignment = StringAlignment.Center;
-                    sf.LineAlignment = StringAlignment.Center;
-                
-                    e.Graphics.DrawString(m_sequenceNum.ToString(), font, sampleBrush, m_RegionF, sf);
-                }
-
-                //绘制帧图
-                e.Graphics.DrawRectangle(pen, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
-            }
-            //绘制颗粒
-            else if (createType == CreateRectangleType.ParticleLine)
-            {
-                Color myColor = LineColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.01f);
-                e.Graphics.SmoothingMode = SmoothingMode.Default;
-                //设置直线位置与长度
-                PointF startPointF = LineStartPoint;
-                float length = LineLength;
-                PointF endPointF = new PointF(startPointF.X + length, startPointF.Y);
-                e.Graphics.DrawLine(pen, startPointF, endPointF);
-            }
-            //矩形
-            else if (createType == CreateRectangleType.ParticleAreaRectangle)
-            {
-                Color myColor = System.Drawing.Color.White;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawRectangle(Pens.Black, m_Region);
-            }
+           
+           
             //绘制样品孔BSE图像
-            else if (createType == CreateRectangleType.DrawFrameOfHoleBSEImage)
+            else if (createType == GDIType.DrawFrameOfHoleBSEImage)
             {
               
 
@@ -446,62 +263,9 @@ namespace OTSMeasureApp
 
                 }
             }
-            else if (createType == CreateRectangleType.DrawSEMCenterPoint)
-            {
-                Color myColor = System.Drawing.Color.Red;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-            
-                //X轴线
-                PointF startPointX = semCenterPoint;
-                startPointX.X = startPointX.X - 3;
-                PointF endPointX = semCenterPoint;
-                endPointX.X = endPointX.X + 3;
-                //Y轴线
-                PointF startPointY = semCenterPoint;
-                startPointY.Y = startPointY.Y - 3;
-                PointF endPointY = semCenterPoint;
-                endPointY.Y = endPointY.Y + 3;
-                //绘制XY轴交叉线+ 
-                Pen pen = new Pen(sampleBrush, 0.0001f);
-                e.Graphics.DrawLine(pen, startPointX, endPointX);
-                e.Graphics.DrawLine(pen, startPointY, endPointY);
-            }
-            //绘制BSE标记
-            else if (createType == CreateRectangleType.DrawBSEElementSignPoint)
-            {
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
            
-                Pen pen = new Pen(sampleBrush, 2f);
-                int X = (int)m_OrigineRegionF.X;
-                int Y = (int)m_OrigineRegionF.Y;
-                e.Graphics.DrawLine(pen, new Point(X - 8, Y), new Point(X + 8, Y));
-                e.Graphics.DrawLine(pen, new Point(X, Y - 8), new Point(X, Y + 8));
-            }
-            //绘制多边形测量区域
-            else if (createType == CreateRectangleType.Polygon)
-            {
-        
-                Color myColor = selColor;
-                //System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(myColor, 1);
-                if (GetPolygonPointFList().Count > 0)
-                {
-                    List<PointF> PolygonPointF = new List<PointF>();
-                    foreach (var item in m_PolygonPoints)
-                    {
-                        PolygonPointF.Add(item);
-                    }
-                    if (PolygonDrawingEndPoint.X != 0 && PolygonDrawingEndPoint.Y != 0)
-                    {
-                        PolygonPointF.Add(PolygonDrawingEndPoint);
-                    }
-
-                    e.Graphics.DrawLines(pen, PolygonPointF.ToArray());
-                    
-
-                }
-            }//多边形测量区域完成标识
-            else if (createType == CreateRectangleType.DrawPolygonFinish)
+           
+            else if (createType == GDIType.DrawPolygonFinish)
             {
                 Color myColor = selColor;
 
@@ -513,22 +277,7 @@ namespace OTSMeasureApp
                 m_Region.Height = (int)m_RegionF.Height;
                 e.Graphics.DrawRectangle(pen, m_Region);
             }
-            //绘制多边形测量区域
-            else if (createType == CreateRectangleType.CircleByThreePoints)
-            {
-                Color myColor = selColor;
-
-                Pen p = new Pen(myColor, 1);
-
-
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawEllipse(p, m_Region);
-
-            }
+          
         }
        
         public  Image BSEImage
@@ -577,16 +326,12 @@ namespace OTSMeasureApp
             get { return otsY; }
             set { otsY = value; }
         }
-        public  CreateRectangleType CreateType
+        public  GDIType GDIType
         {
             get { return createType; }
             set { createType = value; }
         }
-        public  ShapeType Shape
-        {
-            get { return shape; }
-            set { shape = value; }
-        }
+       
         public  Color SelColor
         {
             get { return selColor; }
@@ -640,7 +385,16 @@ namespace OTSMeasureApp
             vertexPoint.Add(new PointF(region.X + region.Width, region.Y + region.Height));
             return vertexPoint;
         }
-
+        public List<PointF> GetOriginalRegionVertexPoints()
+        {
+            List<PointF> vertexPoint = new List<PointF>();
+            var region = this.GetOrigionalDrawRegionF();
+            vertexPoint.Add(region.Location);
+            vertexPoint.Add(new PointF(region.X, region.Y + region.Height));
+            vertexPoint.Add(new PointF(region.X + region.Width, region.Y));
+            vertexPoint.Add(new PointF(region.X + region.Width, region.Y + region.Height));
+            return vertexPoint;
+        }
         public  RectangleF GetZoomedRegionF()
         { 
             return m_RegionF; 
@@ -682,124 +436,23 @@ namespace OTSMeasureApp
             m_RegionF = scaleRectangleF;
 
         }
-        private  Rectangle GetMinRectangleOfPolygon(List<PointF> polygonPointList)
-        {
-            if (polygonPointList != null)
-            {
-                if (polygonPointList.Count > 0)
-                {
-                    int pCount = polygonPointList.Count;
-                    float minX = polygonPointList[0].X;
-                    float minY = polygonPointList[0].Y;
-                    float maxX = polygonPointList[0].X;
-                    float maxY = polygonPointList[0].Y;
-                    //获取最小X,Y 最大X,Y
-                    for (int i = 0; i < pCount; i++)
-                    {
-                        minX = Math.Min(minX, polygonPointList[i].X);
-                        minY = Math.Min(minY, polygonPointList[i].Y);
-                        maxX = Math.Max(maxX, polygonPointList[i].X);
-                        maxY = Math.Max(maxY, polygonPointList[i].Y);
-                    }
-
-                    //创建外接矩形
-                    Rectangle rect = new Rectangle();
-                    rect.Location = new Point((int)minX, (int)minY);
-                    rect.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
-                    return rect;
-                }
-            }
-            return new Rectangle();
-        }
+       
 
         public RectangleF GetOrigionalDrawRegionF()
         { return m_OrigineRegionF; }
 
 
-        public List<PointF> GetOriginalPolygonPointFList()
-        { return m_originalPolygonPoints; }
-        public void SetOriginalPolygonPointFList(List<PointF> value)
-        {
-            if (m_zoomNum != 1)
-            {
-                var ps = new List<PointF>();
-                foreach (var p in value)
-                {
-                    var p1 = new PointF();
-
-                    p1.X = p.X * m_zoomNum+m_refPoint.X;
-                    p1.Y = p.Y  *m_zoomNum+ m_refPoint.Y;
-                    ps.Add(p1);
-
-                }
-
-
-               
-                m_PolygonPoints = ps;
-                m_originalPolygonPoints = value;
-            }
-            else 
-            {
-                m_originalPolygonPoints = value;
-                m_PolygonPoints = value;
-            }
-           
-
-        }
-
-        public List<PointF> GetPolygonPointFList()
-        { return m_PolygonPoints; }
-        public void SetPolygonPointFList(List<PointF> value)
-        {
-            if (m_zoomNum != 1)
-            {
-                var ps = new List<PointF>();
-                foreach (var p in value)
-                {
-                    var p1 = new PointF();
-
-                    p1.X = (p.X - m_refPoint.X) / m_zoomNum;
-                    p1.Y = (p.Y - m_refPoint.Y) / m_zoomNum;
-                    ps.Add(p1);
-
-                }
-
-
-                m_originalPolygonPoints = ps;
-                m_PolygonPoints = value;
-            }
-            else
-            {
-                m_originalPolygonPoints = value;
-                m_PolygonPoints = value;
-            }
-
-
-            var region = GetMinRectangleOfPolygon(m_PolygonPoints);
-            SetZoomedRegionF(region);
-
-        }
+       
 
-        public GraphicsPath GetGPath()
+        public virtual GraphicsPath GetGPath()
         {
 
             var measureItem = this;
             //重新绘制测量区域路径
             GraphicsPath GPath = new GraphicsPath();
-        
-            if (measureItem.CreateType == CreateRectangleType.Polygon)
-            {
-                GraphicsPath PolygonMeasurePath = new GraphicsPath();
-                PolygonMeasurePath.AddPolygon(measureItem.GetPolygonPointFList().ToArray());
-                GPath = PolygonMeasurePath;
-            }
-            else if (measureItem.CreateType == CreateRectangleType.CircleByThreePoints)
-            {
-                GPath.AddEllipse(GetZoomedRegionF());
-            }
-            else
-            {
-                if (measureItem.Shape == (int)CreateRectangleType.Circle)
+
+           
+                if (measureItem.GDIType == GDIType.StageBoundary_Circle)
                 {
                     GPath.AddEllipse(GetZoomedRegionF());
                 }
@@ -807,17 +460,13 @@ namespace OTSMeasureApp
                 {
                     GPath.AddRectangle(GetZoomedRegionF());
                 }
-            }
+          
           
             return GPath;
 
         }
 
-        public  PointF PolygonDrawingEndPoint
-        {
-            get { return endPoint; }
-            set { endPoint = value; }
-        }
+        
   
 
         public  Point GetZoomedCenterPoint()
@@ -857,24 +506,17 @@ namespace OTSMeasureApp
             get { return m_IsWorkSample; }
             set { m_IsWorkSample = value; }
         }
-        public  PointF DraggingPoint
+       virtual public  PointF DraggingPoint
         {
             get { return m_DraggingPoint; }
             set {
                 
                     m_DraggingPoint = value;
-                    if (subItems.Count != 0)
-                    {
-                        foreach (var item in subItems)
-                        {
-                            item.DraggingPoint = m_DraggingPoint;
-                        }
-                
-                    }
+                    
                 }
         }
 
-        public int SequenceNum { get => m_sequenceNum; set => m_sequenceNum = value; }
+       
         public bool IsMoving { get => m_IsMoving; set => m_IsMoving = value; }
 
         public PointF GetDisplayRefPoint()
@@ -884,24 +526,18 @@ namespace OTSMeasureApp
         { 
             m_refPoint = value;
             SetInitRegionF(m_OrigineRegionF);
-            if (m_originalPolygonPoints.Count != 0)
-            {
-                this.SetPolygonPointFList(m_originalPolygonPoints);
-            }
+            
         }
 
         public float GetZoomNumber()
         { return m_zoomNum; }
 
 
-        public void SetZoomNumber(float value)
+       virtual public void SetZoomNumber(float value)
         { 
             m_zoomNum = value;
             SetInitRegionF(m_OrigineRegionF);
-            if (m_originalPolygonPoints.Count != 0)
-            {
-                this.SetPolygonPointFList(m_originalPolygonPoints);
-            }
+           
         }
 
 
@@ -953,22 +589,9 @@ namespace OTSMeasureApp
             return false;
         }
 
-        public  List<CDisplayGDIObject> SubItems()
-        {
-            if (subItems == null) subItems = new List<CDisplayGDIObject>();
-            return subItems;
-        }
-        public void AddSubItems(CDisplayGDIObject item)
-        {
-            if (subItems == null) subItems = new List<CDisplayGDIObject>();
-            subItems.Add(item);
-        }
-        public void ClearSubItems()
-        {
-            subItems.Clear();
-        }
+       
 
-        public  void Zoom(PointF mousePoint, float zoomNum)
+     virtual   public  void Zoom(PointF mousePoint, float zoomNum)
 
         {
             float X1;
@@ -980,7 +603,7 @@ namespace OTSMeasureApp
                 m_zoomNum = 1;
                 m_RegionF = m_OrigineRegionF;
                 m_refPoint = new PointF(0, 0);
-                m_PolygonPoints = m_originalPolygonPoints;
+               
             }
             else 
             {
@@ -1008,33 +631,11 @@ namespace OTSMeasureApp
             BSEImageLocation = m_RegionF.Location;
           
 
-            var scalePs = new List<PointF>();
-            foreach (var p in m_PolygonPoints)
-            {
-                float x, y;
-                x = (p.X - mousePoint.X) / curZoom * deltaZoom + p.X;
-                y = (p.Y - mousePoint.Y) / curZoom * deltaZoom + p.Y;
-              
-                scalePs.Add(new PointF(x, y));
-
-
-            }
-            m_PolygonPoints = scalePs;
-
-        
-            if (this.subItems.Count != 0)
-            {
-                foreach (var g in subItems)
-                {
-                    g.Zoom(mousePoint,zoomNum);
-                }
-
-
-            }
+           
         }
         
 
-        public  void Move(PointF location)
+     virtual   public  void Move(PointF location)
         {
             
             PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
@@ -1054,35 +655,14 @@ namespace OTSMeasureApp
             BSEImageWitdh = m_RegionF.Width;
             BSEImageHeight = m_RegionF.Height;
             BSEImageLocation = m_RegionF.Location;
-            //SEMCenterPoint = m_RegionF.Location;
+         
             LineStartPoint = m_RegionF.Location;
 
             m_DraggingPoint = new Point((int)location.X,(int)location.Y);
 
-            var scalePs = new List<PointF>();
-            foreach (var p in m_PolygonPoints)
-            {
-                float x, y;
-                x = (p.X + offset.X);
-                y = (p.Y + offset.Y);
-
-                scalePs.Add(new PointF(x, y));
-
-
-            }
-            m_PolygonPoints = scalePs;
           
-            if (this.subItems.Count != 0)
-            {
-                foreach (var g in subItems)
-                {
-                    g.Move(location);
-                }
-            
-            
-            }
         }
-        public void PositionAltering(PointF location,bool ifZoomCoord)
+        virtual public void PositionAltering(PointF location,bool ifZoomCoord)
         {
 
             PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
@@ -1109,44 +689,12 @@ namespace OTSMeasureApp
           
             LineStartPoint = m_RegionF.Location;
 
-            
-
-            var scalePs = new List<PointF>();
-            var OriginalPs = new List<PointF>();
-            foreach (var p in m_PolygonPoints)
-            {
-                float x, y;
-                x = (p.X + offset.X);
-                y = (p.Y + offset.Y);
-                scalePs.Add(new PointF(x, y));
-             
-
-
-            }
-            m_PolygonPoints = scalePs;
-
-            foreach (var p in m_originalPolygonPoints)
-            {
-             
-                OriginalPs.Add(new PointF(p.X + realShift.X, p.Y + realShift.Y));
-
-            }
-            m_originalPolygonPoints = OriginalPs;
-
             m_DraggingPoint = new Point((int)location.X, (int)location.Y);
 
-            if (this.subItems.Count != 0)
-            {
-                foreach (var g in subItems)
-                {
-                    g.PositionAltering(location,ifZoomCoord);
-                }
-
-
-            }
+            
         }
 
-        public  CDisplayGDIObject Duplicate(CreateRectangleType newType)
+        public  CDisplayGDIObject Duplicate()
         {
             CDisplayGDIObject r = new CDisplayGDIObject();
             r.NameOrHoleName = this.nameOrHoleName;
@@ -1160,16 +708,13 @@ namespace OTSMeasureApp
             r.m_refPoint = this.m_refPoint;
             r.m_zoomNum = this.m_zoomNum;
          
-            r.shape = this.shape;
+          
 
-            r.createType = newType;
+            r.createType = this.createType;
             
             return r;
         }
-       virtual public bool ifRectangleIntersect(CDisplayGDIObject othergdi)
-        {
-            return true;
-        }
+      
 
         #endregion
         //是否设置为选择样品
@@ -1182,25 +727,24 @@ namespace OTSMeasureApp
         private bool m_IsMoving;
         //是否为工作样品
         private bool m_IsWorkSample;
-        private CreateRectangleType createType;
-        private ShapeType shape;
+        private GDIType createType;
+      
         private string id;
         protected string nameOrHoleName="";
         public string sampleName="";
         //样品孔中样品的数量
         public int sampleCount = 0;
         public string strContent;
-        private Color selColor;
-        private PointF m_DraggingPoint;
+       
+        protected PointF m_DraggingPoint;
 
-        private int m_sequenceNum;
-     
+
+        protected Color selColor;
         protected RectangleF m_RegionF;
         //绘制时与移动缩放时记录的位置与尺寸
         protected RectangleF m_OrigineRegionF;
        
-        private PointF startPoint;
-        private PointF endPoint;
+      
     
         //绘制颗粒图
         private Color lineColor;
@@ -1216,20 +760,18 @@ namespace OTSMeasureApp
         private float bseImageHeight;
         //绘制样品孔BSE图像位置
         private PointF bseImageLocation;
-        //绘制SEM中心位置
-        private PointF semCenterPoint;
-     
-   
-        private List<PointF> m_PolygonPoints=new List<PointF>();
-        //绘制时与移动缩放时记录的位置
-        private List<PointF> m_originalPolygonPoints = new List<PointF>();
 
-        private List<CDisplayGDIObject> subItems=new List<CDisplayGDIObject>();
+
+        private PointF startPoint;
+        private PointF endPoint;
+
+
+     
 
       
         protected float m_zoomNum=1;
 
-        private PointF m_refPoint=new PointF(0,0);
+        protected PointF m_refPoint=new PointF(0,0);
 
         
     }
@@ -1241,50 +783,35 @@ namespace OTSMeasureApp
         Y = 1
     }
    
-    public enum CreateRectangleType
+    public enum GDIType
     {
-        //样品台-圆形
-        SampleBackGround_Circle = -1,
+      
         //圆形
-        Circle = 0,
+        StageBoundary_Circle = 0,
         //圆角矩形
-        SampleBackGround_Rectangle = 1,
+        StageBoundary_RoundedRectangle = 1,
         //样品孔中的文字
         Text = 2,
         //矩形
         Rectangle = 3,
-        //选择的样品
-        SelectSample = 4,
-        //测量区域
-        MeasureArea = 5,
+        //样品孔背景
+        CorrelateSampleHoleBackGround = 4,//every sample area has a sample hole correlation.
+       
         //帧图-直线绘制方式
         SingleLine = 6,
         //表样-矩形
         SpecimenRectangle = 7,
         //表样-圆形
         SpecimenCircle = 8,
-        //帧图-矩形绘制
-        FieldRectangle = 9,
-        //颗粒直线图
-        ParticleLine = 10,
-        //颗粒分布图 鼠标
-        ParticleAreaRectangle = 11,
-        //绘制拍摄样品孔BSE照片
-        DrawFrameOfHoleBSEImage = 12,
-        //绘制sem中心点+
-        DrawSEMCenterPoint=13,
-        //绘制BSE采集标记
-        DrawBSEElementSignPoint = 14,
-        //多边形
-        Polygon = 15,
+     
+        DrawFrameOfHoleBSEImage = 9,
+        
+      
         //多边形完成标识
-        DrawPolygonFinish = 16,
-        //圆形三点法
-        CircleByThreePoints=17,
-
-        RingShape=18,
+        DrawPolygonFinish = 11,
+       
 
-        SampleHoleImageBuffer=19
+        SampleHoleImageBuffer=12
     }
   
 

+ 438 - 0
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CMeasureArea.cs

@@ -0,0 +1,438 @@
+
+using NLog.Fluent;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+using System.Windows.Forms;
+using Point = System.Drawing.Point;
+using Rectangle = System.Drawing.Rectangle;
+
+namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects
+{
+
+    public class CMeasureArea : CDisplayGDIObject
+    {
+        private ShapeType myshape;
+        private List<PointF> m_PolygonPoints = new List<PointF>();
+        //绘制时与移动缩放时记录的位置
+        private List<PointF> m_originalPolygonPoints = new List<PointF>();
+
+        private PointF startPoint;
+        private PointF endPoint;
+        protected List<CVisualFieldGDIObject> subItems = new List<CVisualFieldGDIObject>();
+        public CMeasureArea()
+        {
+        }
+        public CMeasureArea(RectangleF rectMeasure, ShapeType shape, string name, string sampleName, Color selColor)
+        {
+
+            m_OrigineRegionF = rectMeasure;
+            SetInitRegionF(m_OrigineRegionF);
+
+            NameOrHoleName = name;
+            myshape = shape;
+            SelColor = selColor;
+
+            SampleName = sampleName;
+            ID = System.Guid.NewGuid().ToString();
+            OTSX = -1;
+            OTSY = -1;
+        }
+        public CMeasureArea(List<PointF> mPoint, ShapeType shape, string name, string sampleName, Color selColor)
+        {
+            ID = System.Guid.NewGuid().ToString();
+
+            this.SetOriginalPolygonPointFList(mPoint);
+
+            myshape = shape;
+            SelColor = selColor;
+
+        }
+        public List<CVisualFieldGDIObject> SubItems()
+        {
+            if (subItems == null) subItems = new List<CVisualFieldGDIObject>();
+            return subItems;
+        }
+        virtual public void AddSubItems(CVisualFieldGDIObject item)
+        {
+            if (subItems == null) subItems = new List<CVisualFieldGDIObject>();
+
+            item.SequenceNum = subItems.Count ;
+            subItems.Add(item);
+        }
+        public void ClearSubItems()
+        {
+            subItems.Clear();
+        }
+        public override void OnPaint(PaintEventArgs e)
+        {
+            Color myColor = selColor;
+            System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
+            Pen p = new Pen(myColor, 1);
+            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
+            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
+            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
+
+
+            switch (myshape)
+            {
+                case ShapeType.CIRCLE:
+                    e.Graphics.DrawEllipse(p, m_RegionF);
+                    break;
+                case ShapeType.RECTANGLE:
+
+                    var m_Region = new System.Drawing.Rectangle();
+                    m_Region.X = (int)m_RegionF.X;
+                    m_Region.Y = (int)m_RegionF.Y;
+                    m_Region.Width = (int)m_RegionF.Width;
+                    m_Region.Height = (int)m_RegionF.Height;
+
+                    e.Graphics.DrawRectangle(p, m_Region);
+                    break;
+
+                case ShapeType.POLYGON:
+                    myColor = selColor;                 
+                    Pen pen = new Pen(myColor, 1);
+                    if (GetPolygonPointFList().Count > 0)
+                    {
+                        List<PointF> PolygonPointF = new List<PointF>();
+                        foreach (var item in m_PolygonPoints)
+                        {
+                            PolygonPointF.Add(item);
+                        }
+                        if (PolygonDrawingEndPoint.X != 0 && PolygonDrawingEndPoint.Y != 0)
+                        {
+                            PolygonPointF.Add(PolygonDrawingEndPoint);
+                        }
+                        if (PolygonPointF.Count > 1)
+                        {
+                            e.Graphics.DrawLines(pen, PolygonPointF.ToArray());
+                        }
+                       
+
+
+                    }
+
+                    break;
+            }
+            if (subItems.Count != 0)
+            {
+                foreach (var item in subItems)
+                {
+                    item.OnPaint(e);
+                }
+
+            }
+
+
+        }
+        override public PointF DraggingPoint
+        {
+            get { return m_DraggingPoint; }
+            set
+            {
+
+                m_DraggingPoint = value;
+                if (subItems.Count != 0)
+                {
+                    foreach (var item in subItems)
+                    {
+                        item.DraggingPoint = m_DraggingPoint;
+                    }
+
+                }
+            }
+        }
+        override public void PositionAltering(PointF location, bool ifZoomCoord)
+        {
+            if (myshape == ShapeType.POLYGON)
+            {
+
+                PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
+
+                PointF realShift;
+                if (ifZoomCoord)
+                {
+                    realShift = new PointF(offset.X / m_zoomNum, offset.Y / m_zoomNum);
+                }
+                else
+                {
+                    realShift = new PointF(offset.X, offset.Y);
+                }
+                m_OrigineRegionF = new RectangleF(m_OrigineRegionF.X + realShift.X, m_OrigineRegionF.Y + realShift.Y, m_OrigineRegionF.Width, m_OrigineRegionF.Height);
+
+                SetInitRegionF(m_OrigineRegionF);
+
+                var scalePs = new List<PointF>();
+                var OriginalPs = new List<PointF>();
+                foreach (var p in m_PolygonPoints)
+                {
+                    float x, y;
+                    x = (p.X + offset.X);
+                    y = (p.Y + offset.Y);
+                    scalePs.Add(new PointF(x, y));
+
+
+
+                }
+                m_PolygonPoints = scalePs;
+
+                foreach (var p in m_originalPolygonPoints)
+                {
+
+                    OriginalPs.Add(new PointF(p.X + realShift.X, p.Y + realShift.Y));
+
+                }
+                m_originalPolygonPoints = OriginalPs;
+
+                m_DraggingPoint = new Point((int)location.X, (int)location.Y);
+                
+            }
+            else
+            {
+                base.PositionAltering(location, ifZoomCoord);
+            }
+
+            if (subItems.Count != 0)
+            {
+                NLog.LogManager.GetCurrentClassLogger().Warn(subItems.Count);
+                foreach (var g in subItems)
+                {
+                    g.PositionAltering(location, ifZoomCoord);
+                }
+
+
+            }
+
+
+
+        }
+        override public void Move(PointF location)
+        {
+
+            if (myshape == ShapeType.POLYGON)
+            {
+                PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
+
+
+                var scalePs = new List<PointF>();
+                foreach (var p in m_PolygonPoints)
+                {
+                    float x, y;
+                    x = (p.X + offset.X);
+                    y = (p.Y + offset.Y);
+
+                    scalePs.Add(new PointF(x, y));
+
+
+                }
+                m_PolygonPoints = scalePs;
+               
+                m_DraggingPoint = new Point((int)location.X, (int)location.Y);
+            }
+            else
+            {
+                base.Move(location);
+
+            }
+            if (this.subItems.Count != 0)
+            {
+                foreach (var g in subItems)
+                {
+                    g.Move(location);
+                }
+
+
+            }
+
+        }
+        override public void Zoom(PointF mousePoint, float zoomNum)
+        {
+
+            if (myshape == ShapeType.POLYGON)
+            {
+                float curZoom = m_zoomNum;
+                float deltaZoom = zoomNum - curZoom;
+
+                if (zoomNum == 1)
+                {
+                    m_zoomNum = 1;
+                    m_RegionF = m_OrigineRegionF;
+                    m_refPoint = new PointF(0, 0);
+                    m_PolygonPoints = m_originalPolygonPoints;
+                  
+                }
+                else
+                {
+                    m_refPoint.X = (m_refPoint.X - mousePoint.X) / curZoom * deltaZoom + m_refPoint.X;
+                    m_refPoint.Y = (m_refPoint.Y - mousePoint.Y) / curZoom * deltaZoom + m_refPoint.Y;
+                    var scalePs = new List<PointF>();
+                    foreach (var p in m_PolygonPoints)
+                    {
+                        float x, y;
+                        x = (p.X - mousePoint.X) / curZoom * deltaZoom + p.X;
+                        y = (p.Y - mousePoint.Y) / curZoom * deltaZoom + p.Y;
+
+                        scalePs.Add(new PointF(x, y));
+
+
+                    }
+                    m_PolygonPoints = scalePs;
+                    m_zoomNum = zoomNum;
+                }
+
+
+
+            }
+            else
+            {
+                base.Zoom(mousePoint, zoomNum);
+
+            }
+            if (this.subItems.Count != 0)
+            {
+                foreach (var g in subItems)
+                {
+                    g.Zoom(mousePoint, zoomNum);
+                }
+
+
+            }
+
+
+
+        }
+        override public void SetZoomNumber(float value)
+        {
+            base.SetZoomNumber(value);
+
+            if (m_originalPolygonPoints.Count != 0)
+            {
+                this.SetPolygonPointFList(m_originalPolygonPoints);
+            }
+        }
+        public override GraphicsPath GetGPath()
+        {
+
+            
+            //重新绘制测量区域路径
+            GraphicsPath GPath ;
+
+            if (myshape == ShapeType.POLYGON)
+            {
+                GraphicsPath PolygonMeasurePath = new GraphicsPath();
+                PolygonMeasurePath.AddPolygon(this.GetPolygonPointFList().ToArray());
+                GPath = PolygonMeasurePath;
+            }
+            else
+            {
+                GPath= base.GetGPath();
+            }
+
+            return GPath;
+
+        }
+
+        public List<PointF> GetOriginalPolygonPointFList()
+        { return m_originalPolygonPoints; }
+        public void SetOriginalPolygonPointFList(List<PointF> value)
+        {
+            if (m_zoomNum != 1)
+            {
+                var ps = new List<PointF>();
+                foreach (var p in value)
+                {
+                    var p1 = new PointF();
+
+                    p1.X = p.X * m_zoomNum + m_refPoint.X;
+                    p1.Y = p.Y * m_zoomNum + m_refPoint.Y;
+                    ps.Add(p1);
+
+                }
+
+
+
+                m_PolygonPoints = ps;
+                m_originalPolygonPoints = value;
+            }
+            else
+            {
+                m_originalPolygonPoints = value;
+                m_PolygonPoints = value;
+            }
+
+
+        }
+
+        public List<PointF> GetPolygonPointFList()
+        { return m_PolygonPoints; }
+        public void SetPolygonPointFList(List<PointF> value)
+        {
+            if (m_zoomNum != 1)
+            {
+                var ps = new List<PointF>();
+                foreach (var p in value)
+                {
+                    var p1 = new PointF();
+
+                    p1.X = (p.X - m_refPoint.X) / m_zoomNum;
+                    p1.Y = (p.Y - m_refPoint.Y) / m_zoomNum;
+                    ps.Add(p1);
+
+                }
+
+
+                m_originalPolygonPoints = ps;
+                m_PolygonPoints = value;
+            }
+            else
+            {
+                m_originalPolygonPoints = value;
+                m_PolygonPoints = value;
+            }
+
+
+            var region = GetMinRectangleOfPolygon(m_PolygonPoints);
+            SetZoomedRegionF(region);
+
+        }
+        private Rectangle GetMinRectangleOfPolygon(List<PointF> polygonPointList)
+        {
+            if (polygonPointList != null)
+            {
+                if (polygonPointList.Count > 0)
+                {
+                    int pCount = polygonPointList.Count;
+                    float minX = polygonPointList[0].X;
+                    float minY = polygonPointList[0].Y;
+                    float maxX = polygonPointList[0].X;
+                    float maxY = polygonPointList[0].Y;
+                    //获取最小X,Y 最大X,Y
+                    for (int i = 0; i < pCount; i++)
+                    {
+                        minX = Math.Min(minX, polygonPointList[i].X);
+                        minY = Math.Min(minY, polygonPointList[i].Y);
+                        maxX = Math.Max(maxX, polygonPointList[i].X);
+                        maxY = Math.Max(maxY, polygonPointList[i].Y);
+                    }
+
+                    //创建外接矩形
+                    Rectangle rect = new Rectangle();
+                    rect.Location = new Point((int)minX, (int)minY);
+                    rect.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
+                    return rect;
+                }
+            }
+            return new Rectangle();
+        }
+        public PointF PolygonDrawingEndPoint
+        {
+            get { return endPoint; }
+            set { endPoint = value; }
+        }
+
+        public ShapeType Myshape { get => myshape; set => myshape = value; }
+    }
+}

+ 37 - 15
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CRingGDIObject.cs → OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CRingGDIObject.cs

@@ -1,4 +1,5 @@
-using System;
+using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects;
+using System;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Drawing.Drawing2D;
@@ -9,13 +10,13 @@ using System.Windows.Forms;
 
 namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 {
-    class CRingGDIObject: CDisplayGDIObject
+    class CRingGDIObject : CMeasureArea
     {
-        private float ringWidth=10;//the distance between outline circle and inside circle.
+        private float ringWidth = 10;//the distance between outline circle and inside circle.
 
         public float GetRingWidth()
         {
-            return ringWidth*m_zoomNum;
+            return ringWidth * m_zoomNum;
         }
 
         public void SetRingWidth(float value)
@@ -23,25 +24,25 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             ringWidth = value;
         }
 
-        public CRingGDIObject(RectangleF rect, CreateRectangleType cType,string holename,string name, Color selColor)
+        public CRingGDIObject(RectangleF rect, string holename, string name, Color selColor)
         {
 
             m_OrigineRegionF = rect;
             SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
+
             sampleName = name;
             nameOrHoleName = holename;
             SelColor = selColor;
             ID = System.Guid.NewGuid().ToString();
-          
+
         }
         public override void OnPaint(PaintEventArgs e)
         {
-         
+
             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
             e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-       
+
             e.Graphics.DrawEllipse(Pens.Red, m_RegionF);
             RectangleF insideRegine = new RectangleF();
 
@@ -50,12 +51,19 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             insideRegine.Width = m_RegionF.Width - GetRingWidth() * 2;
             insideRegine.Height = m_RegionF.Height - GetRingWidth() * 2;
 
-        
+
             e.Graphics.DrawEllipse(Pens.Red, insideRegine);
-         
 
+            if (subItems.Count != 0)
+            {
+                foreach (var item in subItems)
+                {
+                    item.OnPaint(e);
+                }
+
+            }
         }
-  
+
         private GraphicsPath GetInsideCirclePath()
         {
             RectangleF insideRegine = new RectangleF();
@@ -69,10 +77,10 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
 
 
-        override public bool ifRectangleIntersect(CDisplayGDIObject otherUnZoomgdi)
+        private bool ifRectangleIntersect(CDisplayGDIObject otherUnZoomgdi)
         {
             var path = GetInsideCirclePath();//the inside circle is the blank area that there's no field rect.
-            var vertexPoints = otherUnZoomgdi.GetVertexPoints();
+            var vertexPoints = otherUnZoomgdi.GetOriginalRegionVertexPoints();
             foreach (var p in vertexPoints)
             {
                 if (!path.IsVisible(p))
@@ -83,6 +91,20 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             }
             return false;
         }
-    }
+       
 
+        override public void AddSubItems(CVisualFieldGDIObject item)
+        {
+            if (subItems == null) subItems = new List<CVisualFieldGDIObject>();
+            if (ifRectangleIntersect(item))
+            {
+                var r = item;
+                r.SequenceNum = subItems.Count ;
+                subItems.Add(item);
+            }
+
+
+        }
+
+    }
 }

+ 72 - 0
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CVisualFieldGDIObject.cs

@@ -0,0 +1,72 @@
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
+{
+    public class CVisualFieldGDIObject : CDisplayGDIObject
+    {
+        private int m_sequenceNum;
+        private bool m_enable;
+        public CVisualFieldGDIObject(RectangleF rectField, int OTSx, int OTSy, string name, string sampleName, Color selColor)
+        {
+
+            m_OrigineRegionF = rectField;
+            SetInitRegionF(m_OrigineRegionF);
+
+            NameOrHoleName = name;          
+            SelColor = selColor;
+            SampleName = sampleName;
+            ID = System.Guid.NewGuid().ToString();
+            OTSX = OTSx;
+            OTSY = OTSy;
+        }
+        public int SequenceNum { get => m_sequenceNum; set => m_sequenceNum = value; }
+        public bool Enable { get => m_enable; set => m_enable = value; }
+
+        public override void OnPaint(PaintEventArgs e)
+        {
+
+            Color myColor = SelColor;
+            System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
+            Pen pen;
+            if (m_enable)
+            {
+                pen = new Pen(sampleBrush, 0.01f);
+            }
+            else
+            {
+                pen = new Pen(new SolidBrush(Color.Gray), 0.01f);
+            }
+
+            e.Graphics.SmoothingMode = SmoothingMode.Default;
+            //设置直线位置与尺寸
+            PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
+            PointF endPointF = new PointF(m_RegionF.Right, m_RegionF.Bottom);
+            if (m_RegionF.Height > 20)//won't display when it's too small,to speed up
+            {
+                float fontSize = m_RegionF.Width / 4;
+                Font font;
+                if (fontSize == 0)
+                {
+                    font = new Font("宋体", 5, FontStyle.Regular);
+                }
+                else
+                {
+                    font = new Font("宋体", fontSize, FontStyle.Regular);
+                }
+
+                StringFormat sf = new StringFormat();
+                sf.Alignment = StringAlignment.Center;
+                sf.LineAlignment = StringAlignment.Center;
+
+                e.Graphics.DrawString(m_sequenceNum.ToString(), font, sampleBrush, m_RegionF, sf);
+            }
+
+            //绘制帧图
+            e.Graphics.DrawRectangle(pen, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
+
+
+        }
+    }
+}

+ 23 - 22
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CVisualSampleArea.cs → OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CVisualSampleArea.cs

@@ -1,4 +1,5 @@
-using System;
+using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects;
+using System;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Linq;
@@ -11,53 +12,53 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
     {
    
      
-          CDisplayGDIObject m_SampleGDIObject;//
-          CDisplayGDIObject m_MeasureGDIObject;//path
+          CDisplayGDIObject m_SampleHoleGDIObject;//
+          CMeasureArea m_MeasureGDIObject;//path
        
    
 
-        private List<Point> polygonPathPoints;
+        //private List<Point> polygonPathPoints;
         public float GetZoomNum()
         {
-            return m_SampleGDIObject.GetZoomNumber();
+            return m_SampleHoleGDIObject.GetZoomNumber();
         }
         public PointF GetDisplayRefPoint()
         {
-            return m_SampleGDIObject.GetDisplayRefPoint();
+            return m_SampleHoleGDIObject.GetDisplayRefPoint();
         }
       
         public CVisualSampleArea()
         {
-            m_SampleGDIObject =  new CDisplayGDIObject();
+            m_SampleHoleGDIObject =  new CDisplayGDIObject();
 
 
             //测量区域
-            m_MeasureGDIObject =  new CDisplayGDIObject();
+            m_MeasureGDIObject = new CMeasureArea();
+
+
 
 
-           
-        
 
 
         }
 
         public CDisplayGDIObject GetSampleGDIObject()
         {
-            return m_SampleGDIObject;
+            return m_SampleHoleGDIObject;
         }
 
         public void SetSampleGDIObject(CDisplayGDIObject value)
         {
-            m_SampleGDIObject = value;
+            m_SampleHoleGDIObject = value;
            
         }
 
-        public CDisplayGDIObject GetMeasureGDIObject()
+        public CMeasureArea GetMeasureGDIObject()
         {
             return m_MeasureGDIObject;
         }
 
-        public void SetMeasureGDIObject(CDisplayGDIObject value)
+        public void SetMeasureGDIObject(CMeasureArea value)
         {
             m_MeasureGDIObject = value;
            
@@ -65,34 +66,34 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         public string GetSampleName()
         {
-            return m_SampleGDIObject.SampleName;
+            return m_SampleHoleGDIObject.SampleName;
         }
 
         public void SetSampleName(string value)
         {
-            m_SampleGDIObject.SampleName = value;
+            m_SampleHoleGDIObject.SampleName = value;
         }
 
-        public List<Point> PolygonPathPoints { get => polygonPathPoints; set => polygonPathPoints = value; }
+        //public List<Point> PolygonPathPoints { get => polygonPathPoints; set => polygonPathPoints = value; }
 
 
         public bool IsWorkSample()
         {
 
-            return m_SampleGDIObject.IsWorkSample;
+            return m_SampleHoleGDIObject.IsWorkSample;
         }
 
         public void SetIsWorkSample(bool value)
         {
-            m_SampleGDIObject.IsWorkSample = value;
+            m_SampleHoleGDIObject.IsWorkSample = value;
         }
 
-        public List<CDisplayGDIObject> GetMeasureFieldGDIObjects()
+        public List<CVisualFieldGDIObject> GetMeasureFieldGDIObjects()
         {
             return m_MeasureGDIObject.SubItems();
         }
 
-        public void SetMeasureFieldGDIObjects(List<CDisplayGDIObject> value)
+        public void SetMeasureFieldGDIObjects(List<CVisualFieldGDIObject> value)
         {
             m_MeasureGDIObject.ClearSubItems();
             foreach (var gdi in value)
@@ -103,7 +104,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
 
 
-        public void AddFieldGDIObject(CDisplayGDIObject gdi)
+        public void AddFieldGDIObject(  CVisualFieldGDIObject gdi)
         {
             gdi.SetZoomNumber(m_MeasureGDIObject.GetZoomNumber());
             gdi.SetDisplayRefPoint(m_MeasureGDIObject.GetDisplayRefPoint());

+ 139 - 139
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualStage.cs → OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualGDIObjects/CVisualStage.cs

@@ -1,11 +1,8 @@
 using OTSDataType;
+using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
@@ -21,23 +18,23 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         PointF StageLTPointToSEMLocation = new Point(0, 0);
         PointF StageRBPointToSEMLocation = new Point(0, 0);
-      
-        float  m_VisualStageEdgeLength;
 
-        float  m_OTSCoordStageEdgeLength = 0;
+        float m_VisualStageEdgeLength;
+
+        float m_OTSCoordStageEdgeLength = 0;
 
         int m_totalCtrlWidth;
         int m_totalCtrlHeight;
 
 
 
-     
+
 
 
         //记录绘制样品台时的中心位置
         PointF m_RegionStartCenterPoint = new PointF(0, 0);
 
-  
+
 
         //样品台存在的List集合 the rectangle on the edge of  stage ,usually one.
         private List<CDisplayGDIObject> m_StageEdgeGDIObjects;
@@ -49,8 +46,8 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         private List<CDisplayGDIObject> frameOfHoleGDIObjects;// record all the position of the sampleHole image
         public List<CDisplayGDIObject> FrameOfHoleGDIObjects { get => frameOfHoleGDIObjects; set => frameOfHoleGDIObjects = value; }
-      
-      
+
+
         public StageDrawingData GetOTSSampleStageData()
         {
             return m_OTSSampleStageData;
@@ -75,8 +72,8 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             m_OTSSampleStageData = oTSSampleStageData;
 
             frameOfHoleGDIObjects = new List<CDisplayGDIObject>();
-         
-           
+
+
         }
 
         public CVisualStage()
@@ -117,10 +114,10 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 {
                     return g;
                 }
-            
+
             }
             return null;
-        
+
         }
         public CDisplayGDIObject GetHoleGDIByHoleName(string name)
         {
@@ -135,7 +132,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             return null;
 
         }
-        public CDisplayGDIObject GetHoleGDIByMousePoint(Point  mousePoint)
+        public CDisplayGDIObject GetHoleGDIByMousePoint(Point mousePoint)
         {
             foreach (var g in m_SampleHoleGDIObjects)
             {
@@ -188,7 +185,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 SampleHolePara SHoleInfo = new SampleHolePara();
                 //获取样品口的名称,形状,坐标
                 SHoleInfo.sHoleName = d.GetName();
-                SHoleInfo.iShape =(ShapeType) d.GetShape();
+                SHoleInfo.iShape = (ShapeType)d.GetShape();
 
                 RectangleF r = d.GetRectDomain();
 
@@ -211,8 +208,8 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             PointF yDomain = new PointF(GetOTSSampleStageData().StageDomain.Right, GetOTSSampleStageData().StageDomain.Bottom);
 
             //OTS宽度高度差值
-            float  widthDomain = Math.Abs(yDomain.X - xDomain.X);
-      
+            float widthDomain = Math.Abs(yDomain.X - xDomain.X);
+
             //设置样品台宽度
             m_OTSCoordStageEdgeLength = widthDomain;//the stage must be a square.So we can only memorize an edge length.this is millimeter usually.
             m_VisualStageEdgeLength = ctrlHeight > ctrlWidth ? ctrlWidth : ctrlHeight;//the stage must be a square.So we can  memorize an edge length only.
@@ -240,9 +237,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             return m_StageEdgeGDIObjects[0].GetCenterPoint();
             //声明中心点变量
-           
+
         }
-       
+
         public void DrawSampleStage()
         {
             StageDrawingData SData = GetOTSSampleStageData();
@@ -254,7 +251,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                     return;
                 }
                 string stageName = SData.sStageName;
-              
+
                 //获取样品台
                 ShapeType StageShape = SData.bStageShape;
                 PointF stageLeftTop = new PointF(SData.StageDomain.Left, SData.StageDomain.Top);
@@ -264,22 +261,22 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 m_SEMStageData.ConvertSEMToOTSCoord(stageRightBottom, ref StageRBPointToSEMLocation);
 
                 RectangleF Bourary;
-             
+
                 Bourary = GetCtrlCoordRectF(stageLeftTop, stageRightBottom);
-               
+
                 //sampleHoleImageBuffer = new Bitmap((int)Bourary.Width, (int)Bourary.Height);
                 CDisplayGDIObject CreateBourary;
                 //0:圆角矩形 1:圆形 2:文字 3:矩形
                 if (SData.bStageShape == (ShapeType.RECTANGLE))
                 {
-                    CreateBourary =  new CDisplayGDIObject(Bourary, CreateRectangleType.SampleBackGround_Rectangle);
+                    CreateBourary = new CDisplayGDIObject(Bourary, GDIType.StageBoundary_RoundedRectangle);
                 }
                 else
                 {
-                    CreateBourary =  new CDisplayGDIObject(Bourary, CreateRectangleType.Circle);
+                    CreateBourary = new CDisplayGDIObject(Bourary, GDIType.StageBoundary_Circle);
                 }
-      
-                CreateBourary.Shape = StageShape;
+
+                //CreateBourary.Shape = StageShape;
                 m_StageEdgeGDIObjects.Add(CreateBourary);
                 //绘制后的样品台中心位置
                 PointF m_Region = GetCenterPoint();
@@ -288,7 +285,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 {
                     m_RegionStartCenterPoint = m_Region;
                 }
-        
+
                 //获取样品孔
                 System.Collections.Generic.List<SampleHolePara> ChloeClrList = SData.sSHoleInfoList;
                 if (ChloeClrList.Count > 0)
@@ -300,32 +297,32 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                         var yHole = new PointF(ChloeClrList[i].SampleHoleRect.Right, ChloeClrList[i].SampleHoleRect.Bottom);
                         //将微米转换为像素
 
-                        float  widthHole = Math.Abs(yHole.X - xHole.X);
-                        float  heightHole = Math.Abs(yHole.Y - xHole.Y);
+                        float widthHole = Math.Abs(yHole.X - xHole.X);
+                        float heightHole = Math.Abs(yHole.Y - xHole.Y);
                         var RecF = GetCtrlCoordRectF(xHole, yHole);
                         //获取矩形
                         CDisplayGDIObject CreateHole = null;
                         //0:圆角矩形 1:圆形 2:文字 3:矩形
-                        if (ChloeClrList[i].iShape == (ShapeType)CreateRectangleType.SampleBackGround_Rectangle)
+                        if (ChloeClrList[i].iShape == ShapeType.RECTANGLE)
                         {
-                            CreateHole =  new CDisplayGDIObject(RecF, CreateRectangleType.Rectangle);
+                            CreateHole = new CDisplayGDIObject(RecF, GDIType.Rectangle);
 
                         }
                         else
                         {
-                            CreateHole =  new CDisplayGDIObject(RecF, CreateRectangleType.Circle);
+                            CreateHole = new CDisplayGDIObject(RecF, GDIType.StageBoundary_Circle);
                         }
-                
-               
-                        CreateHole.NameOrHoleName= ChloeClrList[i].sHoleName;
+
+
+                        CreateHole.NameOrHoleName = ChloeClrList[i].sHoleName;
                         m_SampleHoleGDIObjects.Add(CreateHole);
 
                         //添加文字
 
 
-                        CDisplayGDIObject CreateContent = GetCtrlCoordRect(xHole, yHole, CreateRectangleType.Rectangle, "", "");
+                        CDisplayGDIObject CreateContent = GetCtrlCoordRect(xHole, yHole, GDIType.Rectangle, "", "");
                         //类型 文字:2
-                        CreateContent.CreateType = CreateRectangleType.Text;
+                        CreateContent.GDIType = GDIType.Text;
                         CreateContent.SetInitRegionF(CreateContent.GetZoomedRegionF());
                         CreateContent.strContent = ChloeClrList[i].sHoleName;
                         CreateContent.NameOrHoleName = ChloeClrList[i].sHoleName;
@@ -339,39 +336,39 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
                 //获取矩形
                 CDisplayGDIObject CreateSTD;
-                if (StageShapes == (int)CreateRectangleType.Circle)
+                if (StageShapes == (int)GDIType.StageBoundary_Circle)
                 {
-                    CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, CreateRectangleType.SpecimenCircle, "", "");
+                    CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, GDIType.SpecimenCircle, "", "");
                 }
                 else
                 {
-                    CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, CreateRectangleType.SpecimenRectangle, "", "");
+                    CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, GDIType.SpecimenRectangle, "", "");
                 }
-        
-         
+
+
                 m_SpecimenGDIObjects.Add(CreateSTD);
 
-             
+
                 return;
             }
             catch (Exception ex)
             {
 
-                NLog.LogManager.GetCurrentClassLogger().Error( ex.ToString() );
+                NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
             }
         }
-       
-       
-        public CDisplayGDIObject GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, CreateRectangleType type, string content, string name)
+
+
+        public CDisplayGDIObject GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, GDIType type, string content, string name)
         {
             try
             {
                 //将微米信息 转换为 像素
                 PointF xPoints = new Point();
                 PointF yPoints = new Point();
-                xPoints.X =(float) MicronConvertToPixel(OTSLeftTop.X );
-                xPoints.Y = (float)MicronConvertToPixel( OTSLeftTop.Y );
-                yPoints.X = (float)MicronConvertToPixel( OTSRightBottom.X );
+                xPoints.X = (float)MicronConvertToPixel(OTSLeftTop.X);
+                xPoints.Y = (float)MicronConvertToPixel(OTSLeftTop.Y);
+                yPoints.X = (float)MicronConvertToPixel(OTSRightBottom.X);
                 yPoints.Y = (float)MicronConvertToPixel(OTSRightBottom.Y);
                 //计算位置
                 xPoints = (PointF)CalculateLocationF(xPoints);
@@ -384,11 +381,11 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 float realEndY = Math.Max(xPoints.Y, yPoints.Y);
 
                 //创建矩形 并返回类型对象
-                return  new CDisplayGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name);
+                return new CDisplayGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name);
             }
             catch (Exception)
             {
-                return  new CDisplayGDIObject(new Rectangle(), 0, "");
+                return new CDisplayGDIObject(new Rectangle(), 0, "");
             }
         }
         public RectangleF GetCtrlCoordRectF(PointF OTSLeftTop, PointF OTSRightBottom)
@@ -399,12 +396,12 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 //将微米信息 转换为 像素
                 PointF leftTop = new PointF();
                 PointF rightBottom = new PointF();
-                leftTop.X = (float)MicronConvertToPixel( OTSLeftTop.X);
-                leftTop.Y = (float)MicronConvertToPixel( OTSLeftTop.Y);
-                rightBottom.X = (float)MicronConvertToPixel( OTSRightBottom.X);
+                leftTop.X = (float)MicronConvertToPixel(OTSLeftTop.X);
+                leftTop.Y = (float)MicronConvertToPixel(OTSLeftTop.Y);
+                rightBottom.X = (float)MicronConvertToPixel(OTSRightBottom.X);
                 rightBottom.Y = (float)MicronConvertToPixel(OTSRightBottom.Y);
                 //计算位置
-                leftTop = CalculateLocationF(leftTop );
+                leftTop = CalculateLocationF(leftTop);
                 rightBottom = CalculateLocationF(rightBottom);
 
                 //获取图形四个点
@@ -416,7 +413,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 //创建矩形 并返回类型对象
                 return new RectangleF(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY));
 
-           
+
 
             }
             catch (Exception)
@@ -432,15 +429,15 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             //获取屏幕中心点
             PointF pointXY = new PointF();
             PointF screenPoint = new PointF(ctrlWidth / 2, ctrlHeight / 2);
-            pointXY.X = screenPoint.X + point.X; 
+            pointXY.X = screenPoint.X + point.X;
             pointXY.Y = screenPoint.Y - point.Y;//using minus because the coordinate system defference of OTS system and control system.
             return pointXY;
         }
-    
+
 
         public double MicronConvertToPixel(double PointVal)
         {
-          
+
             var v = m_VisualStageEdgeLength;
             return PointVal / ((double)m_OTSCoordStageEdgeLength / v);
 
@@ -469,23 +466,23 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         }
 
-       
+
 
         public RectangleF GetOTSCoordRegionF(PointF ctrlLeftTop, PointF ctrlRightBottom)
         {
             try
             {
                 var ctrlcenter = m_StageEdgeGDIObjects[0].GetCenterPoint();
-           
+
 
                 //将微米信息 转换为 像素
                 PointF leftTop = new PointF();
                 PointF rightBottom = new PointF();
-                leftTop.X = (float)PixelConvertToMicron(ctrlLeftTop.X-ctrlcenter.X);
-                leftTop.Y = (float)PixelConvertToMicron((ctrlLeftTop.Y-ctrlcenter.Y));
-                rightBottom.X = (float)PixelConvertToMicron(ctrlRightBottom.X-ctrlcenter.X);
-                rightBottom.Y = (float)PixelConvertToMicron((ctrlRightBottom.Y-ctrlcenter.Y));
-       
+                leftTop.X = (float)PixelConvertToMicron(ctrlLeftTop.X - ctrlcenter.X);
+                leftTop.Y = (float)PixelConvertToMicron((ctrlLeftTop.Y - ctrlcenter.Y));
+                rightBottom.X = (float)PixelConvertToMicron(ctrlRightBottom.X - ctrlcenter.X);
+                rightBottom.Y = (float)PixelConvertToMicron((ctrlRightBottom.Y - ctrlcenter.Y));
+
 
                 //获取OTS图形四个点
                 float realStartX = Math.Min(leftTop.X, rightBottom.X);
@@ -535,10 +532,10 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
 
         }
-        public bool GetVisualSampleArea(SampleMeasurePara SMeasurePara,  out CVisualSampleArea a_visualSample)
+        public bool GetVisualSampleArea(SampleMeasurePara SMeasurePara, out CVisualSampleArea a_visualSample)
         {
 
-         
+
             //设置样品选择状态为非工作样品
             string SampleHoleName = SMeasurePara.sampleHoleName;
             var item = GetSampleHoleGdiobjByName(SampleHoleName);
@@ -547,15 +544,15 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             {
                 //设置颜色
                 Color selColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
-               
-               
+
+
                 //累加样品数量
                 item.SampleCount += 1;
                 item.IsWorkSample = true;
 
-            
 
-                CDisplayGDIObject sampleGDIObject = item.Duplicate(CreateRectangleType.SelectSample);
+
+                CDisplayGDIObject sampleGDIObject = item.Duplicate();
 
                 sampleGDIObject.sampleName = SMeasurePara.sSampleName;
 
@@ -564,13 +561,13 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
                 //add the default measure area from config file.
 
-                CDisplayGDIObject newMeasureGDIObject;
+                CMeasureArea newMeasureGDIObject;
                 PointF xHole = new PointF(SMeasurePara.MeasureRect.Left, SMeasurePara.MeasureRect.Top);
                 PointF yHole = new PointF(SMeasurePara.MeasureRect.Right, SMeasurePara.MeasureRect.Bottom);
 
                 RectangleF SampleRectangleF = GetCtrlCoordRectF(xHole, yHole);
 
-                GetMeasureGdiObject(sampleGDIObject,SMeasurePara.iShape,  SampleRectangleF, out newMeasureGDIObject);
+                GetMeasureGdiObject(sampleGDIObject, SMeasurePara.iShape, SampleRectangleF, out newMeasureGDIObject);
 
                 var newsample = new CVisualSampleArea();
 
@@ -583,66 +580,66 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
             }
 
-                          
-                   
+
+
             a_visualSample = null;
-                  
+
             return false;
-                
 
 
 
 
-           
+
+
         }
         #region 根据样品位置 获取测量区域位置
 
-        public SampleMeasurePara GetSampleMeasurePara(CDisplayGDIObject MeasureItem)
+        public SampleMeasurePara GetSampleMeasurePara(CMeasureArea MeasureItem)
         {
 
             var item = MeasureItem;
 
             SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();
 
-           
+
 
             var region = this.GetOTSCoordRegionF(item.GetOrigionalDrawRegionF().Location, new PointF(item.GetOrigionalDrawRegionF().Right, item.GetOrigionalDrawRegionF().Bottom));
-           
+
 
             sampleMeasurePara.MeasureRect = region;
 
-         
+
             //设置样品孔名称
             sampleMeasurePara.sampleHoleName = item.NameOrHoleName;
             //设置样品名称
             sampleMeasurePara.sSampleName = item.SampleName;
             //设置测量区域形状
-            sampleMeasurePara.iShape = item.Shape;
-            
+            sampleMeasurePara.iShape = item.Myshape;
+
             sampleMeasurePara.DrawPolygonPointList = ConvertPolygonPointToOTSPoint(item.GetOriginalPolygonPointFList());
 
 
-            sampleMeasurePara.sSampleName = MeasureItem.SampleName ;
-            sampleMeasurePara.sampleHoleName =MeasureItem.NameOrHoleName;
+            sampleMeasurePara.sSampleName = MeasureItem.SampleName;
+            sampleMeasurePara.sampleHoleName = MeasureItem.NameOrHoleName;
             return sampleMeasurePara;
         }
-      
-        public  List<PointF> ConvertPolygonPointToOTSPoint(List<PointF> polygonPointList)
+
+        public List<PointF> ConvertPolygonPointToOTSPoint(List<PointF> polygonPointList)
         {
             List<PointF> OTSPoint = new List<PointF>();
-   
+
             if (polygonPointList != null)
             {
                 foreach (var item in polygonPointList)
                 {
-         
+
                     OTSPoint.Add(CtrlCoordToOTSCoord(item));
                 }
             }
             return OTSPoint;
         }
-      
-        public  List<Point> PointFConvertPoint(List<PointF> Points)
+
+        public List<Point> PointFConvertPoint(List<PointF> Points)
         {
             List<Point> PointFs = new List<Point>();
             if (Points != null)
@@ -654,7 +651,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             }
             return PointFs;
         }
-        public  PointF[] PointConvertPointF(Point[] Points)
+        public PointF[] PointConvertPointF(Point[] Points)
         {
             PointF[] PointFs = new PointF[Points.Length];
             if (Points != null)
@@ -666,7 +663,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             }
             return PointFs;
         }
-        public  List<PointF> PointConvertPointF(List<Point> Points)
+        public List<PointF> PointConvertPointF(List<Point> Points)
         {
             List<PointF> PointFs = new List<PointF>();
             if (Points != null)
@@ -680,57 +677,60 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
         #endregion
         #region 添加测量
-        /// <summary>
-        /// 添加测量
-        /// </summary>
-        /// <param name="IsIsDragging">是否选择样品 0:未选择 1:选择</param>
-        /// <param name="sampleName">样品名称</param>
-        /// <returns>是否成功</returns>
-        public bool GetMeasureGdiObject( CDisplayGDIObject sampleGDIObject,ShapeType newShape, RectangleF newRegion, out CDisplayGDIObject outMeasureRect)
-        {
-            
-                var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea);
-                 MeasureRect.SetInitRegionF(newRegion);
-            
-                MeasureRect.SelColor = Color.Red;
-                MeasureRect.Shape = newShape;
-
-
-               outMeasureRect = MeasureRect;
-                return true;
-            
+     
+        public bool GetMeasureGdiObject(CDisplayGDIObject sampleGDIObject, ShapeType newShape, RectangleF newRegion, out CMeasureArea outMeasureRect)
+        {
+            CMeasureArea r = new CMeasureArea();
+            r.NameOrHoleName = sampleGDIObject.NameOrHoleName;
+            r.SampleName = sampleGDIObject.SampleName;
+            r.SetInitRegionF(sampleGDIObject.GetOrigionalDrawRegionF());
+
+            r.IsWorkSample = sampleGDIObject.IsWorkSample;
+            r.SetZoomedRegionF(sampleGDIObject.GetZoomedRegionF());
+
+
+            r.SetDisplayRefPoint(this.GetDisplayRefPoint());
+            r.SetZoomNumber(sampleGDIObject.GetZoomNumber());
+
+            r.SetInitRegionF(newRegion);
+            r.Myshape = newShape;
+            r.SelColor = Color.Red;
+
+            outMeasureRect = r;
+            return true;
+
         }
-        public bool GetMeasureGdiObjectFromSampleGdi(CDisplayGDIObject sampleGDIObject,  out CDisplayGDIObject outMeasureRect)
+        public bool GetMeasureGdiObjectFromSampleGdi(CDisplayGDIObject sampleGDIObject, out CMeasureArea outMeasureRect)
         {
 
             //添加测量区域
-            CreateRectangleType shape = sampleGDIObject.CreateType;
-     
-         
-         
-            var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea);
+            GDIType shape = sampleGDIObject.GDIType;
+
+
+
+            var Measuregdi = sampleGDIObject.Duplicate();
             //MeasureRect.GPath = MeasurePath;
-            MeasureRect.SelColor = Color.Red;
-           
+            Measuregdi.SelColor = Color.Red;
 
-            outMeasureRect = MeasureRect;
+
+            outMeasureRect = (CMeasureArea)Measuregdi;
             return true;
 
         }
         #endregion
         public bool CheckMeasureAreaIsBeyondStageArea(RectangleF RMeasureArea)
         {
-            otsdataconst.DOMAIN_SHAPE iShape = (otsdataconst.DOMAIN_SHAPE)m_StageEdgeGDIObjects[0].CreateType;
+            otsdataconst.DOMAIN_SHAPE iShape = (otsdataconst.DOMAIN_SHAPE)m_StageEdgeGDIObjects[0].GDIType;
             RectangleF pStageArea = m_StageEdgeGDIObjects[0].GetZoomedRegion;
             Rectangle pMeasureArea = new Rectangle((int)RMeasureArea.Left, (int)RMeasureArea.Top, (int)RMeasureArea.Width, (int)RMeasureArea.Height);
-        
+
 
 
             CDomain a_DomainMeasureArea = new CDomain((otsdataconst.DOMAIN_SHAPE)iShape, pMeasureArea);
             CDomain a_DomainStageArea = new CDomain((otsdataconst.DOMAIN_SHAPE)iShape, pStageArea);
             return a_DomainStageArea.DomainInDomain(a_DomainMeasureArea);
         }
-      
+
 
         public void ShowSemCoordvAL(Point mPoint, OTSIncAMeasureAppForm m_MeasureAppForm)
         {
@@ -759,7 +759,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
             PointF otsPoint = this.CtrlCoordToOTSCoord(ctrlPoint);
 
-           
+
 
             Point OTSMousePosition = new Point(Convert.ToInt32(Math.Round(otsPoint.X, 0)), Convert.ToInt32(Math.Round(otsPoint.Y, 0)));
 
@@ -767,7 +767,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         }
 
-        public bool IfMouseInSampleHole(Point mousePoint,out CDisplayGDIObject gdiItem)
+        public bool IfMouseInSampleHole(Point mousePoint, out CDisplayGDIObject gdiItem)
         {
             foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects)
             {
@@ -781,7 +781,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             return false;
 
         }
-        public bool IfMouseInStage(Point mousePoint,out CDisplayGDIObject gdiobj)
+        public bool IfMouseInStage(Point mousePoint, out CDisplayGDIObject gdiobj)
         {
             foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects)
             {
@@ -795,22 +795,22 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             return false;
 
         }
-        public bool IfMouseInStage(Point mousePoint )
+        public bool IfMouseInStage(Point mousePoint)
         {
             foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects)
             {
                 if (item.IfZoomContains(mousePoint))
                 {
-                  
+
                     return true;
                 }
             }
-           
+
             return false;
 
         }
 
-        public void OnMouseMove( MouseEventArgs e)
+        public void OnMouseMove(MouseEventArgs e)
         {
             foreach (CDisplayGDIObject item in m_ContentGDIObjects)
             {
@@ -854,9 +854,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
             return allobj;
         }
-       
 
-        public  PointF GetCenterPoint(RectangleF rect)
+
+        public PointF GetCenterPoint(RectangleF rect)
         {
             //声明
             PointF centerPoint = new PointF();
@@ -865,7 +865,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             centerPoint.Y = rect.Y + rect.Height / 2;
             return centerPoint;
         }
-        
+
 
 
     }

+ 30 - 15
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/sampleSpaceObject.cd

@@ -6,17 +6,17 @@
   <Comment CommentText="PrepareMeasureField---&gt;&#xD;&#xA;SaveFieldPositionInfoToSample">
     <Position X="12.883" Y="2.333" Height="0.65" Width="2.583" />
   </Comment>
-  <Class Name="OTSMeasureApp.CRectangleGDIObject" Collapsed="true">
-    <Position X="3.25" Y="0.5" Width="2.75" />
+  <Class Name="OTSMeasureApp.CDisplayGDIObject" Collapsed="true">
+    <Position X="2.5" Y="0.5" Width="2.75" />
     <TypeIdentifier>
-      <HashCode>oeCGDKMgQIMho8CYMHEAA8MiSDDCJJEQiAgigAMJBhA=</HashCode>
-      <FileName>4-OTSSamplespaceGraphicsPanel\CreateRectangle.cs</FileName>
+      <HashCode>oeCGDKMgQIMhouAIMHEAA8MgCBDCJJEQAAgigAMJAhA=</HashCode>
+      <FileName>4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CDisplayGDIObject.cs</FileName>
     </TypeIdentifier>
   </Class>
-  <Class Name="OTSMeasureApp.OTSSamplespaceWindow">
-    <Position X="6" Y="1.75" Width="2.75" />
+  <Class Name="OTSMeasureApp.OTSSamplespaceWindow" Collapsed="true">
+    <Position X="6" Y="2.75" Width="2.75" />
     <TypeIdentifier>
-      <HashCode>A7TY6hkUBKXhzgHlJCiCeIv3QHqDgJnV80iECQATUAA=</HashCode>
+      <HashCode>Q5TYqhkVBCHhzgDkJCiGeKt3QHoLgpjV80iECABbUAA=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\OTSSamplespaceWindow.cs</FileName>
     </TypeIdentifier>
     <ShowAsAssociation>
@@ -27,25 +27,40 @@
     </ShowAsCollectionAssociation>
   </Class>
   <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.CVisualStage" Collapsed="true">
-    <Position X="8.75" Y="0.5" Width="3" />
+    <Position X="7.25" Y="0.5" Width="3" />
     <TypeIdentifier>
-      <HashCode>iWAKYhCAAIgCEAAWAAQECSAAIJMwApJAhBAIUASAARg=</HashCode>
-      <FileName>4-OTSSamplespaceGraphicsPanel\VisualStage.cs</FileName>
+      <HashCode>iWAKYhCAgIgCEAAWAAQECSAAoJMwApIAhBAIEASAARg=</HashCode>
+      <FileName>4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CVisualStage.cs</FileName>
     </TypeIdentifier>
+    <ShowAsCollectionAssociation>
+      <Field Name="m_ContentGDIObjects" />
+      <Field Name="m_SampleHoleGDIObjects" />
+    </ShowAsCollectionAssociation>
   </Class>
-  <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.CVisualSampleArea">
-    <Position X="1.25" Y="2" Width="2.75" />
+  <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.CVisualSampleArea" Collapsed="true">
+    <Position X="1" Y="2.75" Width="2.75" />
     <TypeIdentifier>
-      <HashCode>CCECAABAgACAAAAAAAAAIAEgggBAAACEAAgAAQAAEAA=</HashCode>
-      <FileName>4-OTSSamplespaceGraphicsPanel\CVisualSampleArea.cs</FileName>
+      <HashCode>CCECAABAAAAAAAAAAAAAIAEgAgBAAACEAAgAAQBAEAA=</HashCode>
+      <FileName>4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CVisualSampleArea.cs</FileName>
     </TypeIdentifier>
+    <ShowAsAssociation>
+      <Field Name="m_MeasureGDIObject" />
+      <Field Name="m_SampleHoleGDIObject" />
+    </ShowAsAssociation>
   </Class>
   <Class Name="OTSModelSharp.CFieldPositionHelper">
     <Position X="11" Y="4" Width="3.25" />
     <TypeIdentifier>
-      <HashCode>AAAAAQAAQQAAQBAAAAABAAgAAAQAAAAAAQACIgAACAA=</HashCode>
+      <HashCode>AAAAAQAAQQAAABAAAAgBAAgAAAQAAAAAAQACIgACCAA=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\CFieldPositionHelper.cs</FileName>
     </TypeIdentifier>
   </Class>
+  <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects.CMeasureArea" Collapsed="true">
+    <Position X="3.25" Y="1.5" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>AASCCAAEAIAAAgCQEEEAAAAACCAAIAAAiAAgAAAAAAA=</HashCode>
+      <FileName>4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CMeasureArea.cs</FileName>
+    </TypeIdentifier>
+  </Class>
   <Font Name="Microsoft YaHei UI" Size="9" />
 </ClassDiagram>

+ 6 - 4
OTSIncAMeasureApp/OTSIncAMeasureApp.csproj

@@ -378,8 +378,10 @@
       <DependentUpon>MeasureStopMode.cs</DependentUpon>
     </Compile>
     <Compile Include="3-OTSDisplaySourceGridData\OTSSampleVisualPropertyInfo.cs" />
-    <Compile Include="4-OTSSamplespaceGraphicsPanel\CRingGDIObject.cs" />
-    <Compile Include="4-OTSSamplespaceGraphicsPanel\CVisualSampleArea.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CMeasureArea.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CRingGDIObject.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CVisualFieldGDIObject.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CVisualSampleArea.cs" />
     <Compile Include="4-OTSSamplespaceGraphicsPanel\frmInitializeStartInput.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -392,7 +394,7 @@
     <Compile Include="4-OTSSamplespaceGraphicsPanel\RingGdiDataInput.Designer.cs">
       <DependentUpon>RingGdiDataInput.cs</DependentUpon>
     </Compile>
-    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualStage.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CVisualStage.cs" />
     <Compile Include="5-OTSMeasureStatuImageFun\frmSpecialGrayParticle.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -542,7 +544,7 @@
       <DependentUpon>ProgMgrInfoForm.cs</DependentUpon>
     </Compile>
     <Compile Include="9-OTSRibbon\OTSRibbonFun.cs" />
-    <Compile Include="4-OTSSamplespaceGraphicsPanel\CDisplayGDIObject.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\VisualGDIObjects\CDisplayGDIObject.cs" />
     <Compile Include="6-OTSDisplayTreeViewData\OTSDisplayTreeBase.cs" />
     <Compile Include="OTSIncAMeasureAppForm.cs">
       <SubType>Form</SubType>

+ 3 - 7
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -28,11 +28,7 @@ using System.Threading;
 namespace OTSMeasureApp 
 {
 
-   public enum ShapeType
-    {
-        CIRCUL = 0,       //圆形
-        RECTANGLE = 1      //矩形
-    };
+ 
        
     enum MessageBoxRev
     {
@@ -1139,9 +1135,9 @@ namespace OTSMeasureApp
 
         private void rbMeasureCircle_Click(object sender, EventArgs e)
         {
-            m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCUL);
+            m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCLE);
             //修改工作样品的测量区域为圆形
-            m_SamplepaceWindow.changeShape(ShapeType.CIRCUL);
+            m_SamplepaceWindow.changeShape(ShapeType.CIRCLE);
         }
 
         private void rbMeasureRectangle_Click(object sender, EventArgs e)

+ 1 - 1
OTSIncAMeasureApp/ResourceManage/ResourceData.cs

@@ -63,7 +63,7 @@ namespace OTSModelSharp.ResourceManage
         XrayLimit=20039,
        
         MAGNIFICATION = 20040,
-        IMAGERESOLUTION_SIZE = 20041,
+        PIXEL_SIZE = 20041,
         WORKING_DISTANCE = 20042,
         TOTAL_FIELDS = 20043,
         TOTAL_TO_MEASURE_AREA = 20044,

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio