Browse Source

the zoom function ,move function and add measure area function can work properly.

gsp 3 years ago
parent
commit
41c95ba1e4

+ 104 - 0
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSRect.cs

@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OTSMeasureApp._0_OTSModel.OTSDataType
+{
+	class COTSRect
+	{
+		private float m_left;
+		private float m_top;
+		private float m_right;
+		private float m_bottom;
+
+		public COTSRect()
+		{
+			m_left = 0;
+			m_top = 0;
+			m_right = 0;
+			m_bottom = 0;
+		}
+
+		public COTSRect(int left, int top, int right, int bottom)
+		{
+			m_left = left;
+			m_top = top;
+			m_right = right;
+			m_bottom = bottom;
+		}
+
+		COTSRect(PointF leftTop, PointF bottomRight)
+		{
+			m_left = leftTop.X;
+			m_top = leftTop.Y;
+			m_right = bottomRight.X;
+			m_bottom = bottomRight.Y;
+		}
+
+
+		void SetRectData(int left, int top, int right, int bottom)
+		{
+			m_left = left;
+			m_top = top;
+			m_right = right;
+			m_bottom = bottom;
+		}
+
+		bool PointInRect(PointF p)
+		{
+			if (p.X > m_left && p.X < m_right && p.X > m_bottom && p.X < m_top)
+			{
+				return true;
+			}
+			else
+			{
+				return false;
+			}
+		}
+		PointF GetTopLeft() { return new PointF(m_left, m_top); }
+		PointF GetBottomRight() { return new PointF(m_right, m_bottom); }
+		float GetWidth() { return (m_right - m_left); }
+		float GetHeight() { return (m_top - m_bottom); }
+		PointF GetCenterPoint() { double w = GetWidth(); double h = GetHeight(); PointF lt = GetTopLeft(); return new PointF((float)(lt.X  + w / 2), (float)(lt.Y - h / 2)); }
+
+		bool IntersectOtherRect(COTSRect r)
+		{
+			PointF leftTop = r.GetTopLeft();
+			PointF rightBottom = r.GetBottomRight();
+			PointF rightTop =new  PointF(rightBottom.X, leftTop.Y);
+			PointF leftBottom =new PointF(leftTop.X, rightBottom.Y);
+
+			if (PointInRect(leftTop))
+			{
+				return true;
+			}
+			else if (PointInRect(rightBottom))
+			{
+				return true;
+			}
+			else if (PointInRect(rightTop))
+			{
+				return true;
+			}
+			else if (PointInRect(leftBottom))
+			{
+				return true;
+			}
+			else if (r.PointInRect(new PointF(m_left, m_top)) || r.PointInRect(new PointF(m_right, m_bottom)))
+			{
+				return true;
+			}
+			else
+			{
+				return false;
+			}
+
+
+
+		}
+	}
+}
+  

+ 3 - 3
OTSIncAMeasureApp/2-OTSMeasureParamManage/COTSMeasureParam.cs

@@ -1252,7 +1252,7 @@ namespace OTSMeasureApp
         //获取工作样品的测量区域
         //int iShape :测量区域形状
         //Rectangle Srect: 测量区域大小
-        public bool GetWSampleMrsArea(ref int iShape, ref RectangleF Srect)
+        public bool GetWorkSampleMrsArea(ref int iShape, ref RectangleF Srect)
         {
             COTSSample WSample = GetResultData().GetWorkingSample();
             if (null == WSample)
@@ -1269,9 +1269,9 @@ namespace OTSMeasureApp
 
             iShape = (int)pMsrArea.GetShape();
 
-            //ValueType ValType = new RectangleF();
+        
             Srect = pMsrArea.GetRectDomain();
-            //Srect = (RectangleF)ValType;
+         
             return true;
         }
 

+ 5 - 3
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CVisualSampleArea.cs

@@ -20,11 +20,11 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         public CVisualSampleArea()
         {
-            m_SampleGDIObject = new CreateRectangle();
+            m_SampleGDIObject =  new CRectangleGDIObject();
 
 
             //测量区域
-            m_MeasureGDIObject = new CreateRectangle();
+            m_MeasureGDIObject =  new CRectangleGDIObject();
 
        
         }
@@ -75,7 +75,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         public void AddFieldGDIObject(CRectangleGDIObject gdi)
         {
-            
+            gdi.SetZoomNumber(m_MeasureGDIObject.GetZoomNumber());
+            gdi.SetDisplayRefPoint(m_MeasureGDIObject.GetDisplayRefPoint());
+           
             m_MeasureGDIObject.SubItems().Add(gdi);
 
 

+ 230 - 265
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CreateRectangle.cs

@@ -6,177 +6,13 @@ using System.Windows.Forms;
 
 namespace OTSMeasureApp
 {
-    public abstract class CRectangleGDIObject
-    {
-        #region 共同属性
-        /// <summary>
-        /// 所有图形共同属性 尺寸(int类型)
-        /// </summary>
-        public abstract RectangleF GetRegion { get;  }
-
-        /// <summary>
-        /// 所有图形共同属性 尺寸(float类型)
-        /// </summary>
-        public abstract RectangleF GetRegionF();
-
-        /// <summary>
-        /// 所有图形共同属性 尺寸(float类型)
-        /// </summary>
-        public abstract void SetRegionF(RectangleF value);
-
-        /// <summary>
-        /// 所有图形共同属性 绘制时与移动缩放时记录的位置与尺寸(float类型)
-        /// </summary>
-        public abstract RectangleF OrigionalDrawRegionF { get; }
-        /// <summary>
-        /// 多边形点集合对象 位置(int类型)
-        /// </summary>
-        public abstract List<Point> PolygonPointRegion { get; set; }
-        /// <summary>
-        /// 多边形点集合对象 位置(float类型)
-        /// </summary>
-        public abstract List<PointF> PolygonPointRegionF { get; set; }
-        /// <summary>
-        /// 多边形点集合对象 绘制时与移动缩放时记录的位置(float类型)
-        /// </summary>
-        public abstract List<PointF> DrawPolygonPointRegionF { get;  }
-        
-        /// <summary>
-        /// 编号
-        /// </summary>
-        public abstract string ID { get; set; }
-        /// <summary>
-        /// 样品孔名称
-        /// </summary>
-        public abstract string Name { get; set; }
-        /// <summary>
-        /// 所有图形共同属性 是否拖动
-        /// </summary>
-        public abstract bool IsDragging { get; set; }
-        /// <summary>
-        /// 创建类型 记录生成的图形类型
-        /// </summary>
-        public abstract CreateRectangleType CreateType { get; set; }
-        //0:圆形 1:矩形
-        public abstract ShapeType Shape { get; set; }
-        /// <summary>
-        /// 拖动到的位置 
-        /// </summary>
-        public abstract Point DraggingPoint { get; set; }
-        /// <summary>
-        /// 绘制事件
-        /// </summary>
-        /// <param name="e"></param>
-        public abstract void OnPaint(PaintEventArgs e);
-        #endregion
-        #region 样品台属性
-        /// <summary>
-        /// 记录样品台中的样品数量(样品台属性)
-        /// </summary>
-        public abstract int SampleCount { get; set; }
-
-        #endregion
-        #region 样品属性
-        /// <summary>
-        /// 样品名称
-        /// </summary>
-        public abstract string SampleName { get; set; }
-        /// <summary>
-        /// 是否选中 (测量区域与样品属性)
-        /// </summary>
-        public abstract bool IsSelect { get; set; }
-        /// <summary>
-        /// 是否为工作样品  (样品属性)
-        /// </summary>
-        public abstract bool IsWorkSample { get; set; }
-        #endregion
-        #region 测量区域属性
-
-        /// 图形的路径 (圆角矩形、测量区域)
-        /// </summary>
-        public abstract GraphicsPath GPath { get; set; }
-        #endregion
-        #region 帧图属性
-        /// <summary>
-        /// 创建新图形时的颜色 (样品、帧图、标样)
-        /// </summary>
-        public abstract Color SelColor { get; set; }
-        /// <summary>
-        /// 绘制直线的开始位置 (帧图绘制直线)
-        /// </summary>
-        public abstract PointF StartPoint { get; set; }
-        /// <summary>
-        /// 绘制直线的开始位置 (帧图绘制直线)
-        /// </summary>
-        public abstract PointF EndPoint { get; set; }
-        #endregion
-        #region 颗粒属性
-        /// <summary>
-        /// 创建新图形时的颜色 
-        /// </summary>
-        public abstract Color LineColor { get; set; }
-        /// <summary>
-        /// 创建颗粒直线长度
-        /// </summary>
-        public abstract float LineLength { get; set; }
-        /// <summary>
-        /// 创建颗粒直线长度
-        /// </summary>
-        public abstract PointF LineStartPoint { get; set; }
-        /// <summary>
-        /// SEM中心位置
-        /// </summary>
-        public abstract PointF SEMCenterPoint { get; set; }
-        #endregion
-        #region 测量区域
-        /// <summary>
-        /// OTS帧图X位置
-        /// </summary>
-        public abstract int OTSX { get; set; }
-        /// <summary>
-        /// OTS帧图Y位置
-        /// </summary>
-        public abstract int OTSY { get; set; }
-
-   
-        #endregion
-        #region 绘制样品孔BSE图像
-        public abstract Image BSEImage { get; set; }
-        //绘制样品孔BSE图像宽度
-        public abstract float BSEImageWitdh { get; set; }
-        //绘制样品孔BSE图像高度
-        public abstract float BSEImageHeight { get; set; }
-        //绘制样品孔BSE图像位置
-        public abstract PointF BSEImageLocation { get; set; }
-
-        public abstract Point GetCenterPoint();
-
-        public abstract bool IfContains(Point mousePoint);
-
-        public abstract List<CRectangleGDIObject> SubItems();
-
-
-        public abstract void SetScaleRegionF(RectangleF rec);
-
-        public abstract PointF GetDisplayRefPoint();
-        public abstract void SetDisplayRefPoint(PointF value);
-
-        public abstract float GetZoomNum();
-        public abstract void SetZoomNum(float value);
-
-        #endregion
-    }
+    
 
-    public class CreateRectangle : CRectangleGDIObject // 同样的方式可以从ADraggableGDIObject生成其它图形的继承角类,比如矩形,三形等等。。
+    public class CRectangleGDIObject /*: CRectangleGDIObject */// 同样的方式可以从ADraggableGDIObject生成其它图形的继承角类,比如矩形,三形等等。。
     {
-        public CreateRectangle()
+        public CRectangleGDIObject()
         {
-            //m_Region = new Rectangle((int)startx, (int)starty, (int)width, (int)height);
-            //m_RegionF = new RectangleF(startx, starty, width, height);
-            //m_DrawRegionF = new RectangleF(startx, starty, width, height);
-            //CreateType = cType;
-            //strContent = content;
-            //Name = name;
+       
             ID = System.Guid.NewGuid().ToString();
             OTSX = -1;
             OTSY = -1;
@@ -190,10 +26,11 @@ namespace OTSMeasureApp
         /// <param name="height">高度</param>
         /// <param name="cType">图形类型:createType=0 圆角矩形 createType=1 圆形 createType=2 文字</param>
         /// <param name="content">文字内容</param>
-        public CreateRectangle(float startx, float starty, float width, float height, CreateRectangleType cType, string content, string name)
+        public CRectangleGDIObject(float startx, float starty, float width, float height, CreateRectangleType cType, string content, string name)
         {
-            m_RegionF = new RectangleF(startx, starty, width, height);
-            m_OrigineRegionF = m_RegionF;
+            var rec = new RectangleF(startx, starty, width, height);
+            m_OrigineRegionF = rec;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             strContent = content;
             Name = name;
@@ -202,10 +39,11 @@ namespace OTSMeasureApp
             OTSY = -1;
         }
 
-        public CreateRectangle(RectangleF rect, CreateRectangleType cType)
+        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType)
         {
-            m_RegionF = rect;
+            //m_RegionF = rect;
             m_OrigineRegionF = rect;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             ID = System.Guid.NewGuid().ToString();
             startPoint = new PointF(rect.Left, rect.Top);
@@ -213,20 +51,22 @@ namespace OTSMeasureApp
             OTSX = -1;
             OTSY = -1;
         }
-        public CreateRectangle(RectangleF rect, CreateRectangleType cType, string name)
+        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, string name)
         {
-            m_RegionF = rect;
+            //m_RegionF = rect;
             m_OrigineRegionF = rect;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             Name = name;
             ID = System.Guid.NewGuid().ToString();
             OTSX = -1;
             OTSY = -1;
         }
-        public CreateRectangle(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name)
+        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name)
         {
-            m_RegionF = rect;
+            //m_RegionF = rect;
             m_OrigineRegionF = rect;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             Name = name;
             Shape = shape;
@@ -234,10 +74,11 @@ namespace OTSMeasureApp
             OTSX = -1;
             OTSY = -1;
         }
-        public CreateRectangle(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name, Color selColor)
+        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name, Color selColor)
         {
-            m_RegionF = rect;
+            //m_RegionF = rect;
             m_OrigineRegionF = rect;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             Name = name;
             Shape = shape;
@@ -246,10 +87,11 @@ namespace OTSMeasureApp
             OTSX = -1;
             OTSY = -1;
         }
-        public CreateRectangle(RectangleF rectMeasure,  CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
+        public CRectangleGDIObject(RectangleF rectMeasure,  CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
         {
-            m_RegionF = rectMeasure;
+            //m_RegionF = rectMeasure;
             m_OrigineRegionF = rectMeasure;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             Name = name;
             Shape = shape;
@@ -261,10 +103,11 @@ namespace OTSMeasureApp
             OTSY = -1;
         }
         //绘制帧图
-        public CreateRectangle(RectangleF rectSingle, CreateRectangleType cType, string name, string sampleName, Color selColor)
+        public CRectangleGDIObject(RectangleF rectSingle, CreateRectangleType cType, string name, string sampleName, Color selColor)
         {
-            m_RegionF = rectSingle;
+            //m_RegionF = rectSingle;
             m_OrigineRegionF = rectSingle;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             Name = name;
             Shape = 0;
@@ -275,10 +118,11 @@ namespace OTSMeasureApp
             OTSY = -1;
         }
         //绘制帧图
-        public CreateRectangle(RectangleF rectSingle, int OTSx, int OTSy, CreateRectangleType cType, string name, string sampleName, Color selColor)
+        public CRectangleGDIObject(RectangleF rectSingle, int OTSx, int OTSy, CreateRectangleType cType, string name, string sampleName, Color selColor)
         {
-            m_RegionF = rectSingle;
+            //m_RegionF = rectSingle;
             m_OrigineRegionF = rectSingle;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             Name = name;
             Shape = 0;
@@ -299,10 +143,11 @@ namespace OTSMeasureApp
         /// <param name="bseImageHeight">图像高度</param>
         /// <param name="drawImageLocation">图像开始位置</param>
         /// <param name="cType">绘制类型</param>
-        public CreateRectangle(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName, Image bseImage, float bseImageWitdh, float bseImageHeight, CreateRectangleType cType)
+        public CRectangleGDIObject(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName, Image bseImage, float bseImageWitdh, float bseImageHeight, CreateRectangleType cType)
         {
-            m_RegionF = rect;
+            //m_RegionF = rect;
             m_OrigineRegionF = rect;
+            SetInitRegionF(m_OrigineRegionF);
             Name = sampleHoleName;
             SampleName = sampleName;
             //生成编号
@@ -322,11 +167,12 @@ namespace OTSMeasureApp
         }
 
 
-        public CreateRectangle(RectangleF rect, Point ImgPoint, float m_Multiple, CreateRectangleType cType)
+        public CRectangleGDIObject(RectangleF rect, Point ImgPoint, float m_Multiple, CreateRectangleType cType)
         {
-            m_RegionF.X = rect.X - ImgPoint.X * m_Multiple;
-            m_RegionF.Y = rect.Y - ImgPoint.Y * m_Multiple;
-            m_OrigineRegionF = m_RegionF;
+            //m_RegionF.X = rect.X - ImgPoint.X * m_Multiple;
+            //m_RegionF.Y = rect.Y - ImgPoint.Y * m_Multiple;
+            m_OrigineRegionF = rect;
+            SetInitRegionF(m_OrigineRegionF);
             CreateType = cType;
             ID = System.Guid.NewGuid().ToString();
             startPoint = new PointF(rect.Left, rect.Top);
@@ -339,7 +185,7 @@ namespace OTSMeasureApp
         /// </summary>
         /// <param name="mPoint"></param>
         /// <param name="cType"></param>
-        public CreateRectangle(List<PointF> mPoint, CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
+        public CRectangleGDIObject(List<PointF> mPoint, CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
         {
             ID = System.Guid.NewGuid().ToString();
             List<Point> PointRegion = new List<Point>();
@@ -354,6 +200,7 @@ namespace OTSMeasureApp
             {
                 DrawPoint.Add(item);
             }
+           
             m_PolygonPointRegionF = DrawPoint;
             Name = name;
             SampleName = sampleName;
@@ -362,87 +209,87 @@ namespace OTSMeasureApp
             SelColor = selColor;
         }
         #region 变量重写
-        public override Image BSEImage
+        public  Image BSEImage
         {
             get { return bseImage; }
             set { bseImage = value; }
         }
-        public override float BSEImageWitdh
+        public  float BSEImageWitdh
         {
             get { return bseImageWidth; }
             set { bseImageWidth = value; }
         }
-        public override float BSEImageHeight
+        public  float BSEImageHeight
         {
             get { return bseImageHeight; }
             set { bseImageHeight = value; }
         }
-        public override PointF BSEImageLocation
+        public  PointF BSEImageLocation
         {
             get { return bseImageLocation; }
             set { bseImageLocation = value; }
         }
-        public override Color LineColor
+        public  Color LineColor
         {
             get { return lineColor; }
             set { lineColor = value; }
         }
-        public override float LineLength
+        public  float LineLength
         {
             get { return lineLength; }
             set { lineLength = value; }
         }
-        public override PointF LineStartPoint
+        public  PointF LineStartPoint
         {
             get { return lineStartPoint; }
             set { lineStartPoint = value; }
         }
-        public override PointF SEMCenterPoint
+        public  PointF SEMCenterPoint
         {
             get { return semCenterPoint; }
             set { semCenterPoint = value; }
         }
-        public override int OTSX
+        public  int OTSX
         {
             get { return otsX; }
             set { otsX = value; }
         }
-        public override int OTSY
+        public  int OTSY
         {
             get { return otsY; }
             set { otsY = value; }
         }
-        public override CreateRectangleType CreateType
+        public  CreateRectangleType CreateType
         {
             get { return createType; }
             set { createType = value; }
         }
-        public override ShapeType Shape
+        public  ShapeType Shape
         {
             get { return shape; }
             set { shape = value; }
         }
-        public override Color SelColor
+        public  Color SelColor
         {
             get { return selColor; }
             set { selColor = value; }
         }
-        public override string Name
+        public  string Name
         {
             get { return name; }
             set { name = value; }
         }
-        public override string ID
+        public  string ID
         {
             get { return id; }
             set { id = value; }
         }
-        public override string SampleName
+        public  string SampleName
         {
             get { return sampleName; }
             set { sampleName = value; }
         }
-        public override int SampleCount
+        public  int SampleCount
         {
             get { return sampleCount; }
             set { sampleCount = value; }
@@ -452,7 +299,7 @@ namespace OTSMeasureApp
             get { return strContent; }
             set { strContent = value; }
         }
-        public override RectangleF GetRegion
+        public  RectangleF GetZoomedRegion
         {
             
             get {
@@ -466,78 +313,106 @@ namespace OTSMeasureApp
            
         }
 
-        public override RectangleF GetRegionF()
-        { return m_RegionF; }
-        public override void SetRegionF(RectangleF value)
+        public  RectangleF GetZoomedRegionF()
         { 
-            m_RegionF = value;
-            m_OrigineRegionF = value;
-        
+            return m_RegionF; 
+        }
+        public  void SetInitRegionF(RectangleF OrigineRegionF)//not zoomed regine value
+        {
+            
+
+            float x1, y1;
+            x1 = OrigineRegionF.X * m_zoomNum + m_refPoint.X;
+            y1 = OrigineRegionF.Y * m_zoomNum + m_refPoint.Y;
+
+            float w1, h1;
+            w1 = OrigineRegionF.Width * m_zoomNum;
+            h1 = OrigineRegionF.Height * m_zoomNum;
+
+
+
+            m_OrigineRegionF = OrigineRegionF;
+
+            m_RegionF = new RectangleF(x1, y1, w1, h1);
+
+            CreateRectangleType shape = this.CreateType;
+            GraphicsPath MeasurePath = new GraphicsPath();
+            if (shape == CreateRectangleType.Rectangle)
+            {
+                MeasurePath.AddRectangle(m_RegionF);
+            }
+            else
+            {
+                MeasurePath.AddEllipse(m_RegionF);
+            }
+            this.g_Path = MeasurePath;
+
+
         }
-        public override RectangleF OrigionalDrawRegionF
+        public  RectangleF OrigionalDrawRegionF
         {
             get { return m_OrigineRegionF; }
           
         }
 
-        public override List<Point> PolygonPointRegion
+        public  List<Point> PolygonPointRegion
         {
             get { return m_PolygonPointRegion; }
             set { m_PolygonPointRegion = value; }
         }
 
-        public override List<PointF> PolygonPointRegionF
+        public  List<PointF> PolygonPointRegionF
         {
             get { return m_PolygonPointRegionF; }
             set { m_PolygonPointRegionF = value; }
         }
 
-        public override List<PointF> DrawPolygonPointRegionF
+        public  List<PointF> DrawPolygonPointRegionF
         {
             get { return m_DrawPolygonPointRegionF; }
             //set { m_DrawPolygonPointRegionF = value; }
         }
 
-        public override GraphicsPath GPath
+        public  GraphicsPath GPath
         {
             get { return g_Path; }
             set { g_Path = value; }
         }
-        public override PointF StartPoint
+        public  PointF StartPoint
         {
             get { return startPoint; }
             set { startPoint = value; }
         }
-        public override PointF EndPoint
+        public  PointF EndPoint
         {
             get { return endPoint; }
             set { endPoint = value; }
         }
   
 
-        public override Point GetCenterPoint()
+        public  Point GetZoomedCenterPoint()
         {
             Point pCenterPoint = new Point();
             //获取在工作窗口中X,Y位置
-            pCenterPoint.X = (int)(this.GetRegion.X + this.GetRegion.Width / 2);
-            pCenterPoint.Y = (int)(this.GetRegion.Y + this.GetRegion.Height / 2);
+            pCenterPoint.X = (int)(this.GetZoomedRegion.X + this.GetZoomedRegion.Width / 2);
+            pCenterPoint.Y = (int)(this.GetZoomedRegion.Y + this.GetZoomedRegion.Height / 2);
             return pCenterPoint;
         }
-        #endregion
 
-        public override void OnPaint(PaintEventArgs e)
+        public Point GetCenterPoint()
         {
-            //float curZoom = m_RegionF.Width / OrigionalDrawRegionF.Width;
-
-
-
-            //float X = (m_RegionF.X - refPoint.X) / curZoom * zoomNum;
-            //float Y = (m_RegionF.Y - refPoint.Y) / curZoom * zoomNum ;
-            //float Width = OrigionalDrawRegionF.Width * zoomNum;
-            //float Height = OrigionalDrawRegionF.Height * zoomNum;
+            Point pCenterPoint = new Point();
+            //获取在工作窗口中X,Y位置
+            pCenterPoint.X = (int)(this.OrigionalDrawRegionF.X + this.OrigionalDrawRegionF.Width / 2);
+            pCenterPoint.Y = (int)(this.OrigionalDrawRegionF.Y + this.OrigionalDrawRegionF.Height / 2);
+            return pCenterPoint;
+        }
+        #endregion
 
 
-           //m_RegionF=new RectangleF(X, Y, Width, Height);
+        public  void OnPaint(PaintEventArgs e)
+        {
+       
 
 
             //createType=0 圆角矩形 createType=1 圆形 createType=2 文字
@@ -885,50 +760,52 @@ namespace OTSMeasureApp
                 
             }
         }
-        public override bool IsDragging
+        public  bool IsDragging
         {
             get { return m_IsDragging; }
             set { m_IsDragging = value; }
         }
-        public override bool IsSelect
+        public  bool IsSelect
         {
             get { return m_IsSelect; }
             set { m_IsSelect = value; }
         }
         
-        public override bool IsWorkSample
+        public  bool IsWorkSample
         {
             get { return m_IsWorkSample; }
             set { m_IsWorkSample = value; }
         }
-        public override Point DraggingPoint
+        public  Point DraggingPoint
         {
             get { return m_DraggingPoint; }
             set { m_DraggingPoint = value; }
         }
 
-        public override PointF GetDisplayRefPoint()
-        {
-            return refPoint;
-                
-                
-                }
+        public PointF GetDisplayRefPoint()
+        { return m_refPoint; }
 
-        public override void SetDisplayRefPoint(PointF value)
-        {
-            refPoint = value;
+        public void SetDisplayRefPoint(PointF value)
+        { 
+            m_refPoint = value;
+            SetInitRegionF(m_OrigineRegionF);
         }
 
-        public override float GetZoomNum()
-        {
-            return zoomNum;
-        }
+        public float GetZoomNumber()
+        { return m_zoomNum; }
 
-        public override void SetZoomNum(float value)
-        {
-            zoomNum = value;
+
+        public void SetZoomNumber(float value)
+        { 
+            m_zoomNum = value;
+            SetInitRegionF(m_OrigineRegionF);
+        
         }
 
+
+
+
+
         #region 画圆角矩形
         internal static GraphicsPath CreateRoundedRectanglePath(RectangleF rect, int cornerRadius)
         {
@@ -945,11 +822,11 @@ namespace OTSMeasureApp
             return roundedRect;
         }
 
-        public override bool IfContains(Point mousePoint)
+        public  bool IfContains(Point mousePoint)
         {
-            if (mousePoint.X > OrigionalDrawRegionF.Left && mousePoint.X < OrigionalDrawRegionF.Left + OrigionalDrawRegionF.Width)
+            if (mousePoint.X > m_RegionF.Left && mousePoint.X < m_RegionF.Left + m_RegionF.Width)
             {
-                if (mousePoint.Y > OrigionalDrawRegionF.Top && mousePoint.Y < OrigionalDrawRegionF.Top + OrigionalDrawRegionF.Height)
+                if (mousePoint.Y > m_RegionF.Top && mousePoint.Y < m_RegionF.Top + m_RegionF.Height)
                 {
                     return true;
                 
@@ -960,15 +837,101 @@ namespace OTSMeasureApp
             return false;
         }
 
-        public override List<CRectangleGDIObject> SubItems()
+        public  List<CRectangleGDIObject> SubItems()
         {
             if (subItems == null) subItems = new List<CRectangleGDIObject>();
             return subItems;
         }
 
-        public override void SetScaleRegionF(RectangleF rec)
+   
+
+        public  void Zoom(PointF mousePoint, float zoomNum)
+        {
+            if (m_zoomNum == 1)
+            {
+                m_RegionF = OrigionalDrawRegionF;
+                m_refPoint = new PointF(0, 0);
+            } 
+            float curZoom = m_zoomNum;
+
+            float deltaZoom = zoomNum - curZoom;
+            float X1;
+            float Y1;
+           
+            X1 = (m_RegionF.X - mousePoint.X) / curZoom * deltaZoom + m_RegionF.X;
+            Y1 = (m_RegionF.Y - mousePoint.Y) / curZoom * deltaZoom + m_RegionF.Y;
+
+            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;
+
+            float Width = OrigionalDrawRegionF.Width * zoomNum;
+            float Height = OrigionalDrawRegionF.Height * zoomNum;
+            m_RegionF = new RectangleF(X1, Y1, Width, Height);
+            m_zoomNum = zoomNum;
+           
+
+
+            BSEImageWitdh = m_RegionF.Width;
+            BSEImageHeight = m_RegionF.Height;
+            BSEImageLocation = m_RegionF.Location;
+            SEMCenterPoint = m_RegionF.Location;
+
+        }
+
+
+
+        public  void Move(PointF location)
+        {
+            
+            PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
+            float X1;
+            float Y1;
+
+            X1 = (m_RegionF.X + offset.X);
+            Y1 = (m_RegionF.Y + offset.Y);
+
+            m_refPoint.X = m_refPoint.X + offset.X;
+            m_refPoint.Y = m_refPoint.Y + offset.Y;
+
+            m_RegionF = new RectangleF(X1, Y1, m_RegionF.Width, m_RegionF.Height);
+            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);
+       
+
+
+        }
+
+        public  CRectangleGDIObject Duplicate(CreateRectangleType newType)
+        {
+            CRectangleGDIObject r = new CRectangleGDIObject();
+            r.Name = this.name;
+            r.SampleName = this.SampleName;
+            r.m_OrigineRegionF = this.m_OrigineRegionF;
+        
+            r.IsWorkSample = this.IsWorkSample;
+            r.IsSelect = this.IsSelect;
+            r.m_RegionF = this.m_RegionF;
+       
+
+            r.m_refPoint = this.m_refPoint;
+            r.m_zoomNum = this.m_zoomNum;
+         
+            r.shape = this.shape;
+
+            r.createType = newType;
+            
+            return r;
+        }
+
+        public  void Reset()
         {
-            m_RegionF = rec;
+            m_RegionF = m_OrigineRegionF;
+            //Zoom(m_refPoint, 1);
         }
 
 
@@ -1023,8 +986,10 @@ namespace OTSMeasureApp
 
         private List<CRectangleGDIObject> subItems;
 
-        private PointF refPoint;
-        private float zoomNum;
+      
+        private float m_zoomNum=1;
+
+        private PointF m_refPoint=new PointF(0,0);
     }
 
     public enum SEMControlIndex

+ 109 - 107
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceGraphicsPanelFun.cs

@@ -19,17 +19,19 @@ namespace OTSMeasureApp
   
       
         #region 鼠标移动位置
-        public static CRectangleGDIObject GetMouseMoveLocation(CRectangleGDIObject item, MouseEventArgs e)
-        {
-            item.SetScaleRegionF(new RectangleF(
-                                       item.GetRegion.Left + e.X - item.DraggingPoint.X,
-                                       item.GetRegion.Top + e.Y - item.DraggingPoint.Y,
-                                       item.GetRegion.Width,
-                                       item.GetRegion.Height
-                                       ));
-            item.DraggingPoint = e.Location;
-            return item;
-        }
+        //public static CRectangleGDIObject GetMouseMoveLocation(CRectangleGDIObject item, MouseEventArgs e)
+        //{
+        //    //item.SetScaleRegionF(new RectangleF(
+        //    //                           item.GetZoomedRegion.Left + e.X - item.DraggingPoint.X,
+        //    //                           item.GetZoomedRegion.Top + e.Y - item.DraggingPoint.Y,
+        //    //                           item.GetZoomedRegion.Width,
+        //    //                           item.GetZoomedRegion.Height
+        //    //                           ));
+        //    //PointF p = new PointF(e.X - item.DraggingPoint.X, e.Y - item.DraggingPoint.Y);
+        //    item.Move(e.Location);
+        //    //item.DraggingPoint = e.Location;
+        //    return item;
+        //}
         #endregion
   
 
@@ -37,21 +39,21 @@ namespace OTSMeasureApp
 
         #region 鼠标方法操作
        
-        public static RectangleF MouseWheelFunctionF(RectangleF originalRect,RectangleF curRect,Point mousePoint, float deltaZoomNum)
-        {
+        //public static RectangleF MouseWheelFunctionF(RectangleF originalRect,RectangleF curRect,Point mousePoint, float deltaZoomNum)
+        //{
            
-            float curZoom = curRect.Width / originalRect.Width;
+        //    float curZoom = curRect.Width / originalRect.Width;
 
         
 
-            float X = (curRect.X - mousePoint.X)/curZoom * deltaZoomNum +curRect.X;
-            float Y = (curRect.Y - mousePoint.Y)/curZoom * deltaZoomNum + curRect.Y;
-            float Width = originalRect.Width * (deltaZoomNum+curZoom);
-            float Height = originalRect.Height * (deltaZoomNum + curZoom);
+        //    float X = (curRect.X - mousePoint.X)/curZoom * deltaZoomNum +curRect.X;
+        //    float Y = (curRect.Y - mousePoint.Y)/curZoom * deltaZoomNum + curRect.Y;
+        //    float Width = originalRect.Width * (deltaZoomNum+curZoom);
+        //    float Height = originalRect.Height * (deltaZoomNum + curZoom);
 
 
-            return new RectangleF(X, Y, Width, Height);
-        }
+        //    return new RectangleF(X, Y, Width, Height);
+        //}
 
         const int Band = 5;
        
@@ -91,97 +93,97 @@ namespace OTSMeasureApp
 
   
         #region 根据list中的帧图信息 获取中心位置
-        public static PointF GetSingleCenterLocation(List<CRectangleGDIObject> m_SingleGDIObjects)
-        {
-            float MinX = 0f;
-            float MinY = 0f;
-            float MaxX = 0f;
-            float MaxY = 0f;
-            float width = 0f;
-            float height = 0f;
-            //获取最小XY 与最大XY
-            MinX = m_SingleGDIObjects[0].GetRegionF().X;
-            MinY = m_SingleGDIObjects[0].GetRegionF().Y;
-            MaxX = m_SingleGDIObjects[0].GetRegionF().X;
-            MaxY = m_SingleGDIObjects[0].GetRegionF().Y;
-            width = m_SingleGDIObjects[0].GetRegionF().Width;
-            height = m_SingleGDIObjects[0].GetRegionF().Height;
-            for (int i = 0; i < m_SingleGDIObjects.Count; i++)
-            {
-                MinX = Math.Min(m_SingleGDIObjects[i].GetRegionF().X, MinX);
-                MinY = Math.Min(m_SingleGDIObjects[i].GetRegionF().Y, MinY);
-                MaxX = Math.Max(m_SingleGDIObjects[i].GetRegionF().X, MaxX);
-                MaxY = Math.Max(m_SingleGDIObjects[i].GetRegionF().Y, MaxY);
-            }
-            //获取帧图的外框矩形
-            RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX- MinX+ width, MaxY- MinY+ height);
-            //计算外框矩形的中心点
-            float PointFX = SingleRect.X + SingleRect.Width / 2;
-            float PointFY = SingleRect.Y + SingleRect.Height / 2;
-            PointF SingleCenterPoint = new PointF(PointFX, PointFY);
-            return SingleCenterPoint;
-        }
-        public static PointF GetSingleDrawCenterLocation(List<CRectangleGDIObject> m_SingleGDIObjects)
-        {
-            float MinX = 0f;
-            float MinY = 0f;
-            float MaxX = 0f;
-            float MaxY = 0f;
-            float width = 0f;
-            float height = 0f;
-            //获取最小XY 与最大XY
-            MinX = m_SingleGDIObjects[0].OrigionalDrawRegionF.X;
-            MinY = m_SingleGDIObjects[0].OrigionalDrawRegionF.Y;
-            MaxX = m_SingleGDIObjects[0].OrigionalDrawRegionF.X;
-            MaxY = m_SingleGDIObjects[0].OrigionalDrawRegionF.Y;
-            width = m_SingleGDIObjects[0].OrigionalDrawRegionF.Width;
-            height = m_SingleGDIObjects[0].OrigionalDrawRegionF.Height;
-            for (int i = 0; i < m_SingleGDIObjects.Count; i++)
-            {
-                MinX = Math.Min(m_SingleGDIObjects[i].OrigionalDrawRegionF.X, MinX);
-                MinY = Math.Min(m_SingleGDIObjects[i].OrigionalDrawRegionF.Y, MinY);
-                MaxX = Math.Max(m_SingleGDIObjects[i].OrigionalDrawRegionF.X, MaxX);
-                MaxY = Math.Max(m_SingleGDIObjects[i].OrigionalDrawRegionF.Y, MaxY);
-            }
-            //获取帧图的外框矩形
-            RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX - MinX + width, MaxY - MinY + height);
-            //计算外框矩形的中心点
-            float PointFX = SingleRect.X + SingleRect.Width / 2;
-            float PointFY = SingleRect.Y + SingleRect.Height / 2;
-            PointF SingleCenterPoint = new PointF(PointFX, PointFY);
-            return SingleCenterPoint;
-        }
+        //public static PointF GetSingleCenterLocation(List<CRectangleGDIObject> m_SingleGDIObjects)
+        //{
+        //    float MinX = 0f;
+        //    float MinY = 0f;
+        //    float MaxX = 0f;
+        //    float MaxY = 0f;
+        //    float width = 0f;
+        //    float height = 0f;
+        //    //获取最小XY 与最大XY
+        //    MinX = m_SingleGDIObjects[0].GetZoomedRegionF().X;
+        //    MinY = m_SingleGDIObjects[0].GetZoomedRegionF().Y;
+        //    MaxX = m_SingleGDIObjects[0].GetZoomedRegionF().X;
+        //    MaxY = m_SingleGDIObjects[0].GetZoomedRegionF().Y;
+        //    width = m_SingleGDIObjects[0].GetZoomedRegionF().Width;
+        //    height = m_SingleGDIObjects[0].GetZoomedRegionF().Height;
+        //    for (int i = 0; i < m_SingleGDIObjects.Count; i++)
+        //    {
+        //        MinX = Math.Min(m_SingleGDIObjects[i].GetZoomedRegionF().X, MinX);
+        //        MinY = Math.Min(m_SingleGDIObjects[i].GetZoomedRegionF().Y, MinY);
+        //        MaxX = Math.Max(m_SingleGDIObjects[i].GetZoomedRegionF().X, MaxX);
+        //        MaxY = Math.Max(m_SingleGDIObjects[i].GetZoomedRegionF().Y, MaxY);
+        //    }
+        //    //获取帧图的外框矩形
+        //    RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX- MinX+ width, MaxY- MinY+ height);
+        //    //计算外框矩形的中心点
+        //    float PointFX = SingleRect.X + SingleRect.Width / 2;
+        //    float PointFY = SingleRect.Y + SingleRect.Height / 2;
+        //    PointF SingleCenterPoint = new PointF(PointFX, PointFY);
+        //    return SingleCenterPoint;
+        //}
+        //public static PointF GetSingleDrawCenterLocation(List<CRectangleGDIObject> m_SingleGDIObjects)
+        //{
+        //    float MinX = 0f;
+        //    float MinY = 0f;
+        //    float MaxX = 0f;
+        //    float MaxY = 0f;
+        //    float width = 0f;
+        //    float height = 0f;
+        //    //获取最小XY 与最大XY
+        //    MinX = m_SingleGDIObjects[0].OrigionalDrawRegionF.X;
+        //    MinY = m_SingleGDIObjects[0].OrigionalDrawRegionF.Y;
+        //    MaxX = m_SingleGDIObjects[0].OrigionalDrawRegionF.X;
+        //    MaxY = m_SingleGDIObjects[0].OrigionalDrawRegionF.Y;
+        //    width = m_SingleGDIObjects[0].OrigionalDrawRegionF.Width;
+        //    height = m_SingleGDIObjects[0].OrigionalDrawRegionF.Height;
+        //    for (int i = 0; i < m_SingleGDIObjects.Count; i++)
+        //    {
+        //        MinX = Math.Min(m_SingleGDIObjects[i].OrigionalDrawRegionF.X, MinX);
+        //        MinY = Math.Min(m_SingleGDIObjects[i].OrigionalDrawRegionF.Y, MinY);
+        //        MaxX = Math.Max(m_SingleGDIObjects[i].OrigionalDrawRegionF.X, MaxX);
+        //        MaxY = Math.Max(m_SingleGDIObjects[i].OrigionalDrawRegionF.Y, MaxY);
+        //    }
+        //    //获取帧图的外框矩形
+        //    RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX - MinX + width, MaxY - MinY + height);
+        //    //计算外框矩形的中心点
+        //    float PointFX = SingleRect.X + SingleRect.Width / 2;
+        //    float PointFY = SingleRect.Y + SingleRect.Height / 2;
+        //    PointF SingleCenterPoint = new PointF(PointFX, PointFY);
+        //    return SingleCenterPoint;
+        //}
         #endregion
 
         #region 将所有帧图移植测量区域位置
-        public static void SetSingleLocationToMeasureLocation(List<CRectangleGDIObject> m_ObjectListGDIObjects, CRectangleGDIObject m_ObjectGDIObjects)
-        {
-            //获取帧图中心与测量区域中心
-            PointF singleCenterPoinF= GetSingleCenterLocation(m_ObjectListGDIObjects);
-            PointF singleDrawCenterPoinF = GetSingleDrawCenterLocation(m_ObjectListGDIObjects);
-            //测量区域 已改变为倍数的尺寸 中心点
-            PointF measureCenterPoin = m_ObjectGDIObjects. GetCenterPoint();
-            //测量区域 正常尺寸 中心点
-            PointF measureCenterPoinF = m_ObjectGDIObjects. GetCenterPoint();
-            //计算相差的XY距离
-            float moveX = measureCenterPoin.X - singleCenterPoinF.X;
-            float moveY = measureCenterPoin.Y - singleCenterPoinF.Y;
+        //public static void SetSingleLocationToMeasureLocation(List<CRectangleGDIObject> m_ObjectListGDIObjects, CRectangleGDIObject m_ObjectGDIObjects)
+        //{
+        //    //获取帧图中心与测量区域中心
+        //    PointF singleCenterPoinF = GetSingleCenterLocation(m_ObjectListGDIObjects);
+        //    PointF singleDrawCenterPoinF = GetSingleDrawCenterLocation(m_ObjectListGDIObjects);
+        //    //测量区域 已改变为倍数的尺寸 中心点
+        //    PointF measureCenterPoin = m_ObjectGDIObjects.GetCenterPoint();
+        //    //测量区域 正常尺寸 中心点
+        //    PointF measureCenterPoinF = m_ObjectGDIObjects.GetCenterPoint();
+        //    //计算相差的XY距离
+        //    float moveX = measureCenterPoin.X - singleCenterPoinF.X;
+        //    float moveY = measureCenterPoin.Y - singleCenterPoinF.Y;
 
-            float moveFX = measureCenterPoinF.X - singleDrawCenterPoinF.X;
-            float moveFY = measureCenterPoinF.Y - singleDrawCenterPoinF.Y;
-            //需要移动的位置
-            PointF movePoint = new PointF(moveX, moveY);
-            PointF movePointF = new PointF(moveFX, moveFY);
-            foreach (var ObjectItem in m_ObjectListGDIObjects)
-            {
-                //计算移动后的位置
-                float X = ObjectItem.GetRegionF().X + movePoint.X;
-                float Y = ObjectItem.GetRegionF().Y + movePoint.Y;
-                float Width = ObjectItem.GetRegionF().Width;
-                float Height = ObjectItem.GetRegionF().Height;
-                ObjectItem.SetRegionF(new RectangleF(X, Y, Width, Height));
-            }
-        }
+        //    float moveFX = measureCenterPoinF.X - singleDrawCenterPoinF.X;
+        //    float moveFY = measureCenterPoinF.Y - singleDrawCenterPoinF.Y;
+        //    //需要移动的位置
+        //    PointF movePoint = new PointF(moveX, moveY);
+        //    PointF movePointF = new PointF(moveFX, moveFY);
+        //    foreach (var ObjectItem in m_ObjectListGDIObjects)
+        //    {
+        //        //计算移动后的位置
+        //        float X = ObjectItem.GetZoomedRegionF().X + movePoint.X;
+        //        float Y = ObjectItem.GetZoomedRegionF().Y + movePoint.Y;
+        //        float Width = ObjectItem.GetZoomedRegionF().Width;
+        //        float Height = ObjectItem.GetZoomedRegionF().Height;
+        //        ObjectItem.SetInitRegionF(new RectangleF(X, Y, Width, Height));
+        //    }
+        //}
         #endregion
 
 

File diff suppressed because it is too large
+ 246 - 288
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs


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

@@ -255,14 +255,14 @@ namespace OTSMeasureApp
                 //循环single中所有对象 进行位置匹配
                 for (int i = 0; i < m_MeasureFieldGDIObjects.Count; i++)
                 {
-                    if (m_MeasureFieldGDIObjects[i].GetRegion.Contains(mousePoint))
+                    if (m_MeasureFieldGDIObjects[i].GetZoomedRegion.Contains(mousePoint))
                     {
                         //获取帧图左上坐标
-                        Point LT = new Point((int)m_MeasureFieldGDIObjects[i].GetRegionF().Left, (int)m_MeasureFieldGDIObjects[i].GetRegionF().Top);
+                        Point LT = new Point((int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Left, (int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Top);
                         PointF lTLocation = stage.GetMouseSEMLocation(LT);
                         lTLocation = m_ProjData.ConvertOTSToSemCoord(lTLocation);
                         //获取帧图右下坐标
-                        Point RB = new Point((int)m_MeasureFieldGDIObjects[i].GetRegionF().Right, (int)m_MeasureFieldGDIObjects[i].GetRegionF().Bottom);
+                        Point RB = new Point((int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Right, (int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Bottom);
                         PointF rbLocation = stage.GetMouseSEMLocation(RB);
                         rbLocation = m_ProjData.ConvertOTSToSemCoord(rbLocation);
 

+ 274 - 212
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualStage.cs

@@ -90,6 +90,8 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             return m_StageEdgeGDIObjects[0];
         }
+        public float GetZoomNum() { return m_StageEdgeGDIObjects[0].GetZoomNumber(); }
+        public PointF GetDisplayRefPoint() { return m_StageEdgeGDIObjects[0].GetDisplayRefPoint(); }
 
         public CRectangleGDIObject GetHoleGDIBySampleName(string name)
         {
@@ -216,7 +218,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
         public PointF GetCenterPointF()
         {
-            var item = m_StageEdgeGDIObjects[0].GetRegionF();
+            var item = m_StageEdgeGDIObjects[0].GetZoomedRegionF();
             //声明中心点变量
             PointF pCenterPoint = new Point();
             //获取在工作窗口中X,Y位置
@@ -257,15 +259,15 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
              
                 Bourary = GetCtrlCoordRectF(stageLeftTop, stageRightBottom);
 
-                CreateRectangle CreateBourary;
+                CRectangleGDIObject CreateBourary;
                 //0:圆角矩形 1:圆形 2:文字 3:矩形
                 if (SData.bStageShape == (ShapeType.RECTANGLE))
                 {
-                    CreateBourary = new CreateRectangle(Bourary, CreateRectangleType.SampleBackGround_Rectangle);
+                    CreateBourary =  new CRectangleGDIObject(Bourary, CreateRectangleType.SampleBackGround_Rectangle);
                 }
                 else
                 {
-                    CreateBourary = new CreateRectangle(Bourary, CreateRectangleType.Circle);
+                    CreateBourary =  new CRectangleGDIObject(Bourary, CreateRectangleType.Circle);
                 }
       
                 //添加样品台 对象
@@ -274,11 +276,11 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
                 if (StageShape == (int)CreateRectangleType.Circle)
                 {
-                    MeasurePath.AddEllipse(CreateBourary.GetRegion);
+                    MeasurePath.AddEllipse(CreateBourary.GetZoomedRegion);
                 }
                 else
                 {
-                    MeasurePath.AddRectangle(CreateBourary.GetRegion);
+                    MeasurePath.AddRectangle(CreateBourary.GetZoomedRegion);
                 }
                 CreateBourary.GPath = MeasurePath;
                 CreateBourary.Shape = StageShape;
@@ -306,39 +308,39 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                          float  heightHole = Math.Abs(yHole.Y - xHole.Y);
                         var RecF = GetCtrlCoordRectF(xHole, yHole);
                         //获取矩形
-                        CreateRectangle CreateHole = null;
+                        CRectangleGDIObject CreateHole = null;
                         //0:圆角矩形 1:圆形 2:文字 3:矩形
                         if (ChloeClrList[i].iSHoleShape == (int)CreateRectangleType.SampleBackGround_Rectangle)
                         {
-                            CreateHole = new CreateRectangle(RecF, CreateRectangleType.Rectangle);
+                            CreateHole =  new CRectangleGDIObject(RecF, CreateRectangleType.Rectangle);
 
                         }
                         else
                         {
-                            CreateHole = new CreateRectangle(RecF, CreateRectangleType.Circle);
+                            CreateHole =  new CRectangleGDIObject(RecF, CreateRectangleType.Circle);
                         }
                 
                         //绘制样品孔路径
-                        GraphicsPath HolePath = new GraphicsPath();
-                        if (ChloeClrList[i].iSHoleShape == (int)CreateRectangleType.Circle)
-                        {
-                            HolePath.AddEllipse(CreateHole.GetRegion);
-                        }
-                        else
-                        {
-                            HolePath.AddRectangle(CreateHole.GetRegion);
-                        }
-                        CreateHole.GPath = HolePath;
+                        //GraphicsPath HolePath = new GraphicsPath();
+                        //if (ChloeClrList[i].iSHoleShape == (int)CreateRectangleType.Circle)
+                        //{
+                        //    HolePath.AddEllipse(CreateHole.GetZoomedRegion);
+                        //}
+                        //else
+                        //{
+                        //    HolePath.AddRectangle(CreateHole.GetZoomedRegion);
+                        //}
+                        //CreateHole.GPath = HolePath;
                         CreateHole.Name= ChloeClrList[i].sSHoleName;
                         m_SampleHoleGDIObjects.Add(CreateHole);
 
                         //添加文字
 
 
-                        CreateRectangle CreateContent = GetCtrlCoordRect(xHole, yHole, CreateRectangleType.Rectangle, "", "");
+                        CRectangleGDIObject CreateContent = GetCtrlCoordRect(xHole, yHole, CreateRectangleType.Rectangle, "", "");
                         //类型 文字:2
                         CreateContent.CreateType = CreateRectangleType.Text;
-                        CreateContent.SetRegionF(CreateContent.GetRegionF());
+                        CreateContent.SetInitRegionF(CreateContent.GetZoomedRegionF());
                         CreateContent.strContent = ChloeClrList[i].sSHoleName;
                         CreateContent.Name = ChloeClrList[i].sSHoleName;
                         m_ContentGDIObjects.Add(CreateContent);
@@ -350,7 +352,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 stageRightBottom = new PointF(SData.SampleRect.Right, SData.SampleRect.Bottom);
 
                 //获取矩形
-                CreateRectangle CreateSTD;
+                CRectangleGDIObject CreateSTD;
                 if (StageShapes == (int)CreateRectangleType.Circle)
                 {
                     CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, CreateRectangleType.SpecimenCircle, "", "");
@@ -361,16 +363,16 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 }
         
                 //绘制标样路径
-                GraphicsPath STDPath = new GraphicsPath();
-                if (StageShapes == (int)CreateRectangleType.Circle)
-                {
-                    STDPath.AddEllipse(CreateSTD.GetRegion);
-                }
-                else
-                {
-                    STDPath.AddRectangle(CreateSTD.GetRegion);
-                }
-                CreateSTD.GPath = STDPath;
+                //GraphicsPath STDPath = new GraphicsPath();
+                //if (StageShapes == (int)CreateRectangleType.Circle)
+                //{
+                //    STDPath.AddEllipse(CreateSTD.GetZoomedRegion);
+                //}
+                //else
+                //{
+                //    STDPath.AddRectangle(CreateSTD.GetZoomedRegion);
+                //}
+                //CreateSTD.GPath = STDPath;
                 m_SpecimenGDIObjects.Add(CreateSTD);
                 return;
             }
@@ -380,17 +382,17 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 NLog.LogManager.GetCurrentClassLogger().Error( ex.ToString() );
             }
         }
-        public CreateRectangle GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, CreateRectangleType type, string content, string name)
+        public CRectangleGDIObject GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, CreateRectangleType type, string content, string name)
         {
             try
             {
                 //将微米信息 转换为 像素
                 PointF xPoints = new Point();
                 PointF yPoints = new Point();
-                xPoints.X = (int)MillimetersToPixelsWidth(OTSLeftTop.X );
-                xPoints.Y = (int)MillimetersToPixelsWidth( OTSLeftTop.Y );
-                yPoints.X = (int)MillimetersToPixelsWidth( OTSRightBottom.X );
-                yPoints.Y = (int)MillimetersToPixelsWidth(OTSRightBottom.Y);
+                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);
                 yPoints = CalculateLocationF(yPoints);
@@ -402,11 +404,11 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 float realEndY = Math.Max(xPoints.Y, yPoints.Y);
 
                 //创建矩形 并返回类型对象
-                return new CreateRectangle(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name);
+                return  new CRectangleGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name);
             }
             catch (Exception)
             {
-                return new CreateRectangle(new Rectangle(), 0, "");
+                return  new CRectangleGDIObject(new Rectangle(), 0, "");
             }
         }
         public RectangleF GetCtrlCoordRectF(PointF OTSLeftTop, PointF OTSRightBottom)
@@ -418,10 +420,10 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 //将微米信息 转换为 像素
                 PointF leftTop = new PointF();
                 PointF rightBottom = new PointF();
-                leftTop.X = (float)MillimetersToPixelsWidth( OTSLeftTop.X);
-                leftTop.Y = (float)MillimetersToPixelsWidth( OTSLeftTop.Y);
-                rightBottom.X = (float)MillimetersToPixelsWidth( OTSRightBottom.X);
-                rightBottom.Y = (float)MillimetersToPixelsWidth(OTSRightBottom.Y);
+                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 );
                 rightBottom = CalculateLocationF(rightBottom);
@@ -446,23 +448,103 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         public PointF CalculateLocationF(PointF point)
         {
             //获取窗体的高度与宽度
-            int screenWidth = m_totalCtrlWidth;
-            int screenHeight = m_totalCtrlHeight;
+            int ctrlWidth = m_totalCtrlWidth;
+            int ctrlHeight = m_totalCtrlHeight;
             //获取屏幕中心点
             PointF pointXY = new PointF();
-            PointF screenPoint = new PointF(screenWidth / 2, screenHeight / 2);
+            PointF screenPoint = new PointF(ctrlWidth / 2, ctrlHeight / 2);
             pointXY.X = screenPoint.X + point.X; 
-            pointXY.Y = screenPoint.Y - point.Y;
+            pointXY.Y = screenPoint.Y - point.Y;//using minus because the coordinate system defference of OTS system and control system.
             return pointXY;
         }
     
 
-        public double MillimetersToPixelsWidth( double PointVal)
+        public double MicronConvertToPixel(double PointVal)
         {
           
             var v = m_VisualStageEdgeLength;
             return PointVal / ((double)m_OTSCoordStageEdgeLength / v);
+
+
         }
+
+
+        //public PointF OTSCoordToCtrlCoord(PointF point)
+        //{
+        //    var x = MicronConvertToPixel(point.X);
+        //    var y = MicronConvertToPixel(point.Y);
+        //    return CalculateLocationF(new PointF((float)x, (float)y));
+        
+        //}
+
+
+        //public PointF CtrlCoordToOTSCoord(PointF point)
+        //{
+        //    var ctrlcenter = m_StageEdgeGDIObjects[0].GetCenterPoint();
+        //    var x = PixelConvertToMicron(point.X-ctrlcenter.X);
+        //    var y = PixelConvertToMicron(-(point.Y-ctrlcenter.Y));
+
+
+         
+
+
+        //}
+
+        public PointF CalculateOTSLocation(PointF p1)
+        {
+            float OTSWholeWidth = m_OTSCoordStageEdgeLength;
+            float OTSWholeHeight = m_OTSCoordStageEdgeLength;
+            //获取屏幕中心点
+            PointF pointXY = new PointF();
+            PointF centerPoint = new PointF(0, 0);
+            pointXY.X = centerPoint.X + p1.X;
+            pointXY.Y = centerPoint.Y + p1.Y;
+            return pointXY;
+
+
+        }
+
+        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 = CalculateOTSLocation(leftTop);
+                rightBottom = CalculateOTSLocation(rightBottom);
+
+                //获取OTS图形四个点
+                float realStartX = Math.Min(leftTop.X, rightBottom.X);
+                float realStartY = Math.Min(leftTop.Y, rightBottom.Y);
+                float realEndX = Math.Max(leftTop.X, rightBottom.X);
+                float realEndY = Math.Max(leftTop.Y, rightBottom.Y);
+
+                //创建矩形 并返回类型对象
+                return new RectangleF(realStartX, -realEndY, realEndX - realStartX, realEndY - realStartY);
+
+
+
+            }
+            catch (Exception)
+            {
+                return new RectangleF();
+            }
+        }
+
+        public float PixelConvertToMicron(float Pixel)
+        {
+            return (float)(Pixel * ((double)m_OTSCoordStageEdgeLength / m_VisualStageEdgeLength));
+        }
+
         internal void DecreaseSampleCount(string sampleName)
         {
             foreach (var hole in m_SampleHoleGDIObjects)
@@ -488,33 +570,12 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
 
         }
-        public bool AddSample(SampleMeasurePara SMeasurePara, float globalZoomNum, out CVisualSampleArea a_visualSample)
+        public bool GetVisualSampleArea(SampleMeasurePara SMeasurePara,  out CVisualSampleArea a_visualSample)
         {
-            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);
-
-
-
-            CRectangleGDIObject sampleGDIObject = GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)SMeasurePara.iShape, "", "");
-            sampleGDIObject.SetRegionF(SampleRectangleF);
-            //测量区域名称 样品名称
-            sampleGDIObject.SampleName = SMeasurePara.sSampleName;
-            //测量区域类型 
-            sampleGDIObject.CreateType = (CreateRectangleType)SMeasurePara.iShape;
-            string SampleHoleName = SMeasurePara.sampleHoleName; 
-            string SampleName = SMeasurePara.sSampleName;
-
-                CRectangleGDIObject measureGDIObject;
-
-
-
 
+         
             //设置样品选择状态为非工作样品
-
+            string SampleHoleName = SMeasurePara.sampleHoleName;
             var item = GetSampleHoleGdiobjByName(SampleHoleName);
 
             if (item != null)
@@ -522,49 +583,46 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 //设置颜色
                 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
                 Color selColor = ColorTranslator.FromHtml(ColorStr);
-                CreateRectangle NewSample = new CreateRectangle(item.OrigionalDrawRegionF, CreateRectangleType.SelectSample, item.Shape, item.Name, selColor);
+               
                 //累加样品数量
                 item.SampleCount += 1;
                 item.IsWorkSample = true;
-                NewSample.SampleName = SampleName;
-                NewSample.Name = item.Name;
-                //设置当前添加的样品为工作样品
-                NewSample.IsWorkSample = true;
-                // 获取样品孔的大小与初始大小
-             
-                NewSample.SetRegionF(item.OrigionalDrawRegionF);
-           
-                //绘制样品路径
-                GraphicsPath NewSamplePath = new GraphicsPath();
-                if (NewSample.Shape == (int)CreateRectangleType.Circle)
-                {
-                    NewSamplePath.AddEllipse(NewSample.GetRegion);
-                }
-                else
-                {
-                    NewSamplePath.AddRectangle(NewSample.GetRegion);
-                }
-                NewSample.GPath = NewSamplePath;
 
+            
 
-               
+                CRectangleGDIObject sampleGDIObject = item.Duplicate(CreateRectangleType.SelectSample);
 
+                sampleGDIObject.sampleName = SMeasurePara.sSampleName;
 
-                //获取测量区域尺寸与位置
-                measureGDIObject = GetSampleMeasureInfo(NewSample, sampleGDIObject, globalZoomNum);
-                //设置样品孔名称
-                measureGDIObject.Name = item.Name;
-                //根据节点设置样品台窗口中所选择的样品名称
+                sampleGDIObject.SelColor = selColor;
+;
 
-                //添加测量区域
+                //GraphicsPath NewSamplePath = new GraphicsPath();
+                //if (sampleGDIObject.Shape == (int)CreateRectangleType.Circle)
+                //{
+                //    NewSamplePath.AddEllipse(sampleGDIObject.GetZoomedRegion);
+                //}
+                //else
+                //{
+                //    NewSamplePath.AddRectangle(sampleGDIObject.GetZoomedRegion);
+                //}
+                //sampleGDIObject.GPath = NewSamplePath;
+
+                //add the default measure area from config file.
 
                 CRectangleGDIObject newMeasureGDIObject;
-                AddMeasurePath(measureGDIObject, out 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, SampleRectangleF, out newMeasureGDIObject);
+
                 var newsample = new CVisualSampleArea();
 
 
 
-                newsample.SampleGDIObject = NewSample;
+                newsample.SampleGDIObject = sampleGDIObject;
                 newsample.MeasureGDIObject = newMeasureGDIObject;
                 a_visualSample = newsample;
                 return true;
@@ -584,45 +642,86 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
            
         }
         #region 根据样品位置 获取测量区域位置
-        public CRectangleGDIObject GetSampleMeasureInfo(CRectangleGDIObject NewSample, CRectangleGDIObject m_MeasureGDIObjects, float globalZoomNum)
+
+        public SampleMeasurePara GetSampleMeasurePara(CRectangleGDIObject MeasureItem)
         {
-            //根据样品位置 获取测量区域位置
-      
 
-            float MeasureFPointX = (float)(NewSample.OrigionalDrawRegionF.Location.X + (NewSample.OrigionalDrawRegionF.Size.Width - m_MeasureGDIObjects.OrigionalDrawRegionF.Width*globalZoomNum) / 2);
-            float MeasureFPointY = (float)(NewSample.OrigionalDrawRegionF.Location.Y + (NewSample.OrigionalDrawRegionF.Size.Height - m_MeasureGDIObjects.OrigionalDrawRegionF.Height * globalZoomNum) / 2);
-            float MeasureFWidth = Convert.ToSingle(m_MeasureGDIObjects.OrigionalDrawRegionF.Width * globalZoomNum);
-            float MeasureFHeight = Convert.ToSingle(m_MeasureGDIObjects.OrigionalDrawRegionF.Height * globalZoomNum);
 
 
-            m_MeasureGDIObjects.SetRegionF(NewSample.OrigionalDrawRegionF);
+            //获取测量区域的OTS位置与尺寸
+            //SampleMeasurePara sampleMeasurePara = GetMeasureInfo(MeasureItem);
+            var item = MeasureItem;
+
+            SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();
+
+            //设置测量区域位置与尺寸
+            float left = 0;
+            float Top = 0;
+            float Right = 0;
+            float Bottom = 0;
+            float Widths = 0;
+            float Height = 0;
+            //设置测量区域位置与尺寸
+            //left = PixelConvertToMicron(item.OrigionalDrawRegionF.X);
+            //Top = PixelConvertToMicron(item.OrigionalDrawRegionF.Y);
+            //var p = CtrlCoordToOTSCoord(item.OrigionalDrawRegionF.Location);
+            //Right = PixelConvertToMicron(item.OrigionalDrawRegionF.Right);
+            //Bottom = PixelConvertToMicron(item.OrigionalDrawRegionF.Bottom);
+            //Widths = PixelConvertToMicron(item.OrigionalDrawRegionF.Width);
+            //Height = PixelConvertToMicron(item.OrigionalDrawRegionF.Height);
+
+            var region = this.GetOTSCoordRegionF(item.OrigionalDrawRegionF.Location, new PointF(item.OrigionalDrawRegionF.Right, item.OrigionalDrawRegionF.Bottom));
+            //保存原位置
+            RectangleF polygonRectPara = item.OrigionalDrawRegionF;
+            if (item.CreateType == CreateRectangleType.Polygon)
+            {
+                polygonRectPara = OTSSamplespaceGraphicsPanelFun.GetPolygonToMinRectangle(item.DrawPolygonPointRegionF);
+                //设置测量区域位置与尺寸
+                left = PixelConvertToMicron(polygonRectPara.X);
+                Top = PixelConvertToMicron(polygonRectPara.Y);
+                Right = PixelConvertToMicron(polygonRectPara.Right);
+                Bottom = PixelConvertToMicron(polygonRectPara.Bottom);
+                Widths = PixelConvertToMicron(polygonRectPara.Width);
+                Height = PixelConvertToMicron(polygonRectPara.Height);
+            }
+            //设置测量区域
+            //PointF startPoint = p;
+            //SizeF MeasureSize = new SizeF(Widths, Height);
+
+            sampleMeasurePara.MeasureRect = region;
+
+            //sampleMeasurePara.MeasureRect = new Rectangle(new Point((int)startPoint.X, (int)startPoint.Y), new Size((int)MeasureSize.Width, (int)MeasureSize.Height));
+            //设置样品孔名称
+            sampleMeasurePara.sampleHoleName = item.Name;
+            //设置样品名称
+            sampleMeasurePara.sSampleName = item.SampleName;
+            //设置测量区域形状
+            sampleMeasurePara.iShape = item.Shape;
+            //设置多边形点集合
+            sampleMeasurePara.PolygonPointRegion = PointFConvertPoint(ConvertPolygonPointToOTSPoint(item.PolygonPointRegionF));
+            sampleMeasurePara.PolygonPointRegionF = ConvertPolygonPointToOTSPoint(item.PolygonPointRegionF);
+            sampleMeasurePara.DrawPolygonPointRegionF = ConvertPolygonPointToOTSPoint(item.DrawPolygonPointRegionF);
+
+
+
+
 
 
-            m_MeasureGDIObjects.SetScaleRegionF(new RectangleF(new PointF(MeasureFPointX, MeasureFPointY), new SizeF(MeasureFWidth, MeasureFHeight)));
-       
-            return m_MeasureGDIObjects;
-        }
-        public SampleMeasurePara GetSampleMeasurePara(CRectangleGDIObject MeasureItem)
-        {
-       
-           
 
-            //获取测量区域的OTS位置与尺寸
-            SampleMeasurePara sampleMeasurePara = GetMeasureInfo(MeasureItem);
 
             //获取样品台 中心点
             PointF RectanglePointCenter = GetCenterPointF();
 
-            //获取样品台中心点
-            float CenterX = PixelConvertToMicron((int)RectanglePointCenter.X );
+            ////获取样品台中心点
+            float CenterX = PixelConvertToMicron((int)RectanglePointCenter.X);
             float CenterY = PixelConvertToMicron((int)RectanglePointCenter.Y);
-            RectangleF sampleMeasureRect = new Rectangle();
+            //RectangleF sampleMeasureRect = new Rectangle();
 
-            //根据样品台中心点获取开始点位置
-            sampleMeasureRect.X = -(CenterX - sampleMeasurePara.MeasureRect.X);
-            sampleMeasureRect.Y = CenterY - sampleMeasurePara.MeasureRect.Bottom;
-            sampleMeasurePara.MeasureRect.X = sampleMeasureRect.X;
-            sampleMeasurePara.MeasureRect.Y = sampleMeasureRect.Y;
+            ////根据样品台中心点获取开始点位置
+            //sampleMeasureRect.X = -(CenterX - sampleMeasurePara.MeasureRect.X);
+            //sampleMeasureRect.Y = CenterY - sampleMeasurePara.MeasureRect.Bottom;
+            //sampleMeasurePara.MeasureRect.X = sampleMeasureRect.X;
+            //sampleMeasurePara.MeasureRect.Y = sampleMeasureRect.Y;
 
             for (int i = 0; i < sampleMeasurePara.DrawPolygonPointRegionF.Count; i++)
             {
@@ -636,54 +735,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             sampleMeasurePara.sampleHoleName =MeasureItem.Name;
             return sampleMeasurePara;
         }
-        public SampleMeasurePara GetMeasureInfo(CRectangleGDIObject item)
-        {
-            SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();
-       
-                    //设置测量区域位置与尺寸
-                    float left = 0;
-                    float Top = 0;
-                    float Right = 0;
-                    float Bottom = 0;
-                    float Widths = 0;
-                    float Height = 0;
-                    //设置测量区域位置与尺寸
-                    left = PixelConvertToMicron((int)item.OrigionalDrawRegionF.X);
-                    Top = PixelConvertToMicron((int)item.OrigionalDrawRegionF.Y);
-                    Right = PixelConvertToMicron((int)item.OrigionalDrawRegionF.Right);
-                    Bottom = PixelConvertToMicron((int)item.OrigionalDrawRegionF.Bottom);
-                    Widths = PixelConvertToMicron((int)item.OrigionalDrawRegionF.Width);
-                    Height = PixelConvertToMicron((int)item.OrigionalDrawRegionF.Height);
-                    //保存原位置
-                    RectangleF polygonRectPara = item.OrigionalDrawRegionF;
-                    if (item.CreateType == CreateRectangleType.Polygon)
-                    {
-                        polygonRectPara = OTSSamplespaceGraphicsPanelFun.GetPolygonToMinRectangle(item.DrawPolygonPointRegionF);
-                        //设置测量区域位置与尺寸
-                        left = PixelConvertToMicron((int)polygonRectPara.X);
-                        Top = PixelConvertToMicron((int)polygonRectPara.Y);
-                        Right = PixelConvertToMicron((int)polygonRectPara.Right);
-                        Bottom = PixelConvertToMicron((int)polygonRectPara.Bottom);
-                        Widths = PixelConvertToMicron((int)polygonRectPara.Width);
-                        Height = PixelConvertToMicron((int)polygonRectPara.Height);
-                    }
-                    //设置测量区域
-                    PointF startPoint = new PointF(left, Top);
-                    SizeF MeasureSize = new SizeF(Widths, Height);
-                    sampleMeasurePara.MeasureRect = new Rectangle(new Point((int)startPoint.X, (int)startPoint.Y), new Size((int)MeasureSize.Width, (int)MeasureSize.Height));
-                    //设置样品孔名称
-                    sampleMeasurePara.sampleHoleName = item.Name;
-                    //设置样品名称
-                    sampleMeasurePara.sSampleName = item.SampleName;
-                    //设置测量区域形状
-                    sampleMeasurePara.iShape = item.Shape;
-                    //设置多边形点集合
-                    sampleMeasurePara.PolygonPointRegion = PointFConvertPoint(ConvertPolygonPointToOTSPoint(item.PolygonPointRegionF));
-                    sampleMeasurePara.PolygonPointRegionF = ConvertPolygonPointToOTSPoint(item.PolygonPointRegionF);
-                    sampleMeasurePara.DrawPolygonPointRegionF = ConvertPolygonPointToOTSPoint(item.DrawPolygonPointRegionF);
-           
-            return sampleMeasurePara;
-        }
+      
         public  List<PointF> ConvertPolygonPointToOTSPoint(List<PointF> polygonPointList)
         {
             List<PointF> OTSPoint = new List<PointF>();
@@ -700,10 +752,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             }
             return OTSPoint;
         }
-        public float PixelConvertToMicron(int Pixel)
-        {
-            return (float)(Pixel * ((double)m_OTSCoordStageEdgeLength / m_VisualStageEdgeLength));
-        }
+      
         public  List<Point> PointFConvertPoint(List<PointF> Points)
         {
             List<Point> PointFs = new List<Point>();
@@ -748,41 +797,54 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         /// <param name="IsIsDragging">是否选择样品 0:未选择 1:选择</param>
         /// <param name="sampleName">样品名称</param>
         /// <returns>是否成功</returns>
-        public bool AddMeasurePath( CRectangleGDIObject MeasureGDIObject,out CRectangleGDIObject outMeasureRect)
+        public bool GetMeasureGdiObject( CRectangleGDIObject sampleGDIObject,RectangleF newRegion, out CRectangleGDIObject outMeasureRect)
         {
             
                 //添加测量区域
-                CreateRectangleType shape = MeasureGDIObject.CreateType;
-                GraphicsPath MeasurePath = new GraphicsPath();
-                if (shape == CreateRectangleType.Rectangle)
-                {
-                    MeasurePath.AddRectangle(MeasureGDIObject.GetRegion);
-                }
-                else
-                {
-                    MeasurePath.AddEllipse(MeasureGDIObject.GetRegion);
-                }
-                //缩小与样品的尺寸
-                RectangleF rectMeasure = MeasureGDIObject.GetRegion;
+           
+              
                 Color MeasureColor = Color.Red;
-                CreateRectangle MeasureRect = new CreateRectangle(rectMeasure, CreateRectangleType.MeasureArea, MeasureGDIObject.Shape, MeasureGDIObject.Name, MeasureGDIObject.SampleName, MeasureColor);
-                MeasureRect.GPath = MeasurePath;
-                MeasureRect.sampleName = MeasureGDIObject.SampleName;
-                MeasureRect.Name = MeasureGDIObject.Name;
-                //获取缩放前尺寸与位置
-                MeasureRect.SetRegionF(MeasureGDIObject.OrigionalDrawRegionF);
-            MeasureRect.SetScaleRegionF(MeasureGDIObject.GetRegionF ());
+                var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea);
+                 MeasureRect.SetInitRegionF(newRegion);
+            
+                MeasureRect.SelColor = MeasureColor;
+             
 
 
             outMeasureRect = MeasureRect;
                 return true;
             
+        }
+        public bool GetMeasureGdiObject(CRectangleGDIObject sampleGDIObject,  out CRectangleGDIObject outMeasureRect)
+        {
+
+            //添加测量区域
+            CreateRectangleType shape = sampleGDIObject.CreateType;
+            GraphicsPath MeasurePath = new GraphicsPath();
+            if (shape == CreateRectangleType.Rectangle)
+            {
+                MeasurePath.AddRectangle(sampleGDIObject.GetZoomedRegion);
+            }
+            else
+            {
+                MeasurePath.AddEllipse(sampleGDIObject.GetZoomedRegion);
+            }
+         
+            Color MeasureColor = Color.Red;
+            var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea);
+            MeasureRect.GPath = MeasurePath;
+            MeasureRect.SelColor = MeasureColor;
+           
+
+            outMeasureRect = MeasureRect;
+            return true;
+
         }
         #endregion
         public bool CheckMeasureAreaIsBeyondStageArea(RectangleF RMeasureArea)
         {
             otsdataconst.DOMAIN_SHAPE iShape = (otsdataconst.DOMAIN_SHAPE)m_StageEdgeGDIObjects[0].CreateType;
-            RectangleF pStageArea = m_StageEdgeGDIObjects[0].GetRegion;
+            RectangleF pStageArea = m_StageEdgeGDIObjects[0].GetZoomedRegion;
             Rectangle pMeasureArea = new Rectangle((int)RMeasureArea.Left, (int)RMeasureArea.Top, (int)RMeasureArea.Width, (int)RMeasureArea.Height);
         
 
@@ -815,9 +877,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
 
             var domain = GetOTSSampleStageData().StageDomain;
-            PointF rectLocation = m_StageEdgeGDIObjects[0].GetRegion.Location;
+            PointF rectLocation = m_StageEdgeGDIObjects[0].GetZoomedRegion.Location;
             //样品台尺寸
-            SizeF rectSize = m_StageEdgeGDIObjects[0].GetRegion.Size;
+            SizeF rectSize = m_StageEdgeGDIObjects[0].GetZoomedRegion.Size;
             //鼠标在工作区域中的位置
 
             //OTS坐标中鼠标的位置
@@ -995,7 +1057,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                     diffNewY = (int)(moveToSEMLocation.Y * m_GlobalZoomNum);
                     //根据鼠标_更改测量区域的位置
                     //item.Region = new Rectangle(new Point(item.Region.X + m_StageCenterDiffX + diffNewX, item.Region.Y + m_StageCenterDiffY - diffNewY), new Size(item.Region.Width, item.Region.Height));
-                    item.SetRegionF(new RectangleF(new PointF(item.GetRegionF().X + (m_StageCenterDiffX + diffNewX), item.GetRegionF().Y + (m_StageCenterDiffY - diffNewY)), new SizeF(item.GetRegionF().Width, item.GetRegionF().Height)));
+                    item.SetInitRegionF(new RectangleF(new PointF(item.GetZoomedRegionF().X + (m_StageCenterDiffX + diffNewX), item.GetZoomedRegionF().Y + (m_StageCenterDiffY - diffNewY)), new SizeF(item.GetZoomedRegionF().Width, item.GetZoomedRegionF().Height)));
                     //item.DrawRegionF = new RectangleF(new PointF(item.DrawRegionF.X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.DrawRegionF.Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum), new SizeF(item.DrawRegionF.Width, item.DrawRegionF.Height));
                 }
             }
@@ -1022,7 +1084,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                     diffNewY = (int)(moveToSEMLocation.Y * m_GlobalZoomNum);
                     //根据鼠标_更改测量区域的位置
                     //item.Region = new Rectangle(new Point(item.Region.X + m_StageCenterDiffX + diffNewX, item.Region.Y + m_StageCenterDiffY - diffNewY), new Size(item.Region.Width, item.Region.Height));
-                    item.SetRegionF(new RectangleF(new PointF(item.GetRegionF().X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.GetRegionF().Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum), new SizeF(item.GetRegionF().Width, item.GetRegionF().Height)));
+                    item.SetInitRegionF(new RectangleF(new PointF(item.GetZoomedRegionF().X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.GetZoomedRegionF().Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum), new SizeF(item.GetZoomedRegionF().Width, item.GetZoomedRegionF().Height)));
                     //item.DrawRegionF = item.GetRegionF();
                     //修改多边形的绘制点集合
                     if (item.CreateType == CreateRectangleType.Polygon)
@@ -1076,16 +1138,16 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             SampleHolePara sampleHolePara = new SampleHolePara();
          
             //保存原位置
-            RectangleF rectPara = item.GetRegion;
+            RectangleF rectPara = item.GetZoomedRegion;
             //设置测量区域
-            sampleHolePara.SampleHoleRect = item.GetRegion;
+            sampleHolePara.SampleHoleRect = item.GetZoomedRegion;
             //设置测量区域位置与尺寸
-            float left = PixelConvertToMicron((int)item.GetRegionF().X);
-            float Top = PixelConvertToMicron((int)item.GetRegionF().Y);
-            float Right = PixelConvertToMicron((int)item.GetRegionF().Right);
-            float Bottom = PixelConvertToMicron((int)item.GetRegionF().Bottom);
-            float Widths = PixelConvertToMicron((int)item.GetRegionF().Width);
-            float Height = PixelConvertToMicron((int)item.GetRegionF().Height);
+            float left = PixelConvertToMicron(item.GetZoomedRegionF().X);
+            float Top = PixelConvertToMicron(item.GetZoomedRegionF().Y);
+            float Right = PixelConvertToMicron(item.GetZoomedRegionF().Right);
+            float Bottom = PixelConvertToMicron(item.GetZoomedRegionF().Bottom);
+            float Widths = PixelConvertToMicron(item.GetZoomedRegionF().Width);
+            float Height = PixelConvertToMicron(item.GetZoomedRegionF().Height);
 
             PointF startPoint = new PointF(left, Top);
             SizeF sampleHoleSize = new SizeF(Widths, Height);

+ 17 - 26
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs

@@ -1565,7 +1565,7 @@ namespace OTSMeasureApp
                         //4-2 根据位置绘制标记
                         Point ImgPoint = new Point((int)dMouseImgX, (int)dMouseImgY);
                         Rectangle rect = new Rectangle(p_mouseCurrentTempPoint, new Size(1, 1));
-                        CreateRectangle createRect = new CreateRectangle(rect, ImgPoint, m_CurrentMultiple, CreateRectangleType.DrawBSEElementSignPoint);
+                        CRectangleGDIObject createRect =  new CRectangleGDIObject(rect, ImgPoint, m_CurrentMultiple, CreateRectangleType.DrawBSEElementSignPoint);
                         m_ElementPointGDIObjects.Add(createRect);
                         //5.获取成功后弹出对话框
                         //计数率
@@ -1610,17 +1610,7 @@ namespace OTSMeasureApp
                 }
 
 
-                //try
-                //{
-                //    //cfun.DisconnectSem();
-                //    //cfun.FreeHardware();
-
-
-                //    log.Trace("-------释放controller对象------");
-                //}
-                //catch (Exception)
-                //{
-                //}
+               
             }
         }
 
@@ -1804,7 +1794,7 @@ namespace OTSMeasureApp
                     m_CurrentMultiple += Convert.ToSingle(m_Multiple.ToString("f2"));
                     pbBSEImage.Width += Convert.ToInt32(m_iWidth * m_Multiple);
                     pbBSEImage.Height += Convert.ToInt32(m_iHeight * m_Multiple);
-                    WheelElementPointGDIObjects(m_CurrentMultiple);
+                    WheelElementPointGDIObjects(e.Location,m_CurrentMultiple);
                 }
             }
             else
@@ -1834,36 +1824,37 @@ namespace OTSMeasureApp
                             {
                                 int sizeChangeX = sizeChangePoint.X - m_GetBSEImageInitPoint.X;
                                 int sizeChangeY = sizeChangePoint.Y - m_GetBSEImageInitPoint.Y;
-                                RectangleF sizeChangeRectF = m_ElementPointGDIObjects[0].GetRegionF();
-                                sizeChangeRectF.X = m_ElementPointGDIObjects[0].GetRegionF().X + sizeChangeX;
-                                m_ElementPointGDIObjects[0].SetRegionF(sizeChangeRectF);
+                                RectangleF sizeChangeRectF = m_ElementPointGDIObjects[0].GetZoomedRegionF();
+                                sizeChangeRectF.X = m_ElementPointGDIObjects[0].GetZoomedRegionF().X + sizeChangeX;
+                                m_ElementPointGDIObjects[0].SetInitRegionF(sizeChangeRectF);
                                 //m_ElementPointGDIObjects[0].DrawRegionF = sizeChangeRectF;
                                 m_GetBSEImageInitPoint = sizeChangePoint;
                             }
                         }
                     }
                 }
-                WheelElementPointGDIObjects(m_CurrentMultiple);
+                WheelElementPointGDIObjects(e.Location,m_CurrentMultiple);
             }
         }
         /// <summary>
         /// 缩放时改变 单点标识位置
         /// </summary>
         /// <param name="m_CurrentMultiple"></param>
-        public void WheelElementPointGDIObjects(float m_CurrentMultiple)
+        public void WheelElementPointGDIObjects(Point refPoint,float CurrentMultiple)
         {
             if (m_ElementPointGDIObjects.Count > 0)
             {
                 foreach (CRectangleGDIObject item in m_ElementPointGDIObjects)
                 {
-                    RectangleF rectF = new RectangleF();
-                    rectF.X = item.GetRegionF().X + Convert.ToSingle(dMouseImgX) * m_CurrentMultiple;
-                    rectF.Y = item.GetRegionF().Y + Convert.ToSingle(dMouseImgY) * m_CurrentMultiple;
-                    //改变位置
-                    RectangleF elementPointRctF = new RectangleF();
-                    elementPointRctF.X = rectF.X;
-                    elementPointRctF.Y = rectF.Y;
-                    item.SetScaleRegionF(elementPointRctF);
+                    //RectangleF rectF = new RectangleF();
+                    //rectF.X = item.GetZoomedRegionF().X + Convert.ToSingle(dMouseImgX) * m_CurrentMultiple;
+                    //rectF.Y = item.GetZoomedRegionF().Y + Convert.ToSingle(dMouseImgY) * m_CurrentMultiple;
+                    ////改变位置
+                    //RectangleF elementPointRctF = new RectangleF();
+                    //elementPointRctF.X = rectF.X;
+                    //elementPointRctF.Y = rectF.Y;
+                    //item.SetScaleRegionF(elementPointRctF);
+                    item.Zoom(refPoint, CurrentMultiple);
                 }
             }
         }

+ 1 - 0
OTSIncAMeasureApp/OTSIncAMeasureApp.csproj

@@ -269,6 +269,7 @@
     <Compile Include="0-OTSModel\OTSDataType\CHole.cs" />
     <Compile Include="0-OTSModel\OTSDataType\CHoleBSEImg.cs" />
     <Compile Include="0-OTSModel\OTSDataType\CIntRange.cs" />
+    <Compile Include="0-OTSModel\OTSDataType\COTSRect.cs" />
     <Compile Include="0-OTSModel\OTSDataType\CPropItemGrp.cs" />
     <Compile Include="0-OTSModel\OTSDataType\CMsrSampleStatus.cs" />
     <Compile Include="0-OTSModel\OTSDataType\COTSImageProcParam.cs" />

+ 2 - 2
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -759,7 +759,7 @@ namespace OTSMeasureApp
             m_SPropertyWindows.TSLoad.Enabled = true;
             //给SampleWindow 发送样品信息
            
-            m_SamplepaceWindow.AddOneSampleArea(SMInfo.SMeasurePara);
+            m_SamplepaceWindow.AddSampleArea(SMInfo.SMeasurePara);
             //给PropWindow 发送工作样品属性信息
             m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
             //给SoluWindow 发送样品显示信息
@@ -771,7 +771,7 @@ namespace OTSMeasureApp
             //清空帧图信息
             m_MessageStates = MessageState.StartMeasure;
             //m_SamplepaceWindow.ClearImageAndFieldGDIObjects();
-            m_SamplepaceWindow.Invalidate();
+            //m_SamplepaceWindow.Invalidate();
         }
 
       

Some files were not shown because too many files changed in this diff