浏览代码

stage operating code improve (fix bugs).

gsp 3 年之前
父节点
当前提交
0033398a41

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

@@ -13,8 +13,17 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
      
           CRectangleGDIObject m_SampleGDIObject;//
           CRectangleGDIObject m_MeasureGDIObject;//path
+     
       
         private List<Point> polygonPathPoints;
+        public float GetZoomNum()
+        {
+            return m_SampleGDIObject.GetZoomNumber();
+        }
+        public PointF GetDisplayRefPoint()
+        {
+            return m_SampleGDIObject.GetDisplayRefPoint();
+        }
       
         public CVisualSampleArea()
         {
@@ -23,12 +32,31 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
             //测量区域
             m_MeasureGDIObject =  new CRectangleGDIObject();
-
+           
        
         }
 
-        public CRectangleGDIObject SampleGDIObject { get => m_SampleGDIObject; set => m_SampleGDIObject = value; }
-        public CRectangleGDIObject MeasureGDIObject { get => m_MeasureGDIObject; set => m_MeasureGDIObject = value; }
+        public CRectangleGDIObject GetSampleGDIObject()
+        {
+            return m_SampleGDIObject;
+        }
+
+        public void SetSampleGDIObject(CRectangleGDIObject value)
+        {
+            m_SampleGDIObject = value;
+           
+        }
+
+        public CRectangleGDIObject GetMeasureGDIObject()
+        {
+            return m_MeasureGDIObject;
+        }
+
+        public void SetMeasureGDIObject(CRectangleGDIObject value)
+        {
+            m_MeasureGDIObject = value;
+           
+        }
 
         public string GetSampleName()
         {

+ 65 - 72
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -3,17 +3,12 @@ using System.Collections.Generic;
 using System.Drawing;
 using System.Windows.Forms;
 using OTS.WinFormsUI.Docking;
-using System.IO;
-using System.Drawing.Drawing2D;
 
 using System.Collections;
 using OTSDataType;
 using OTSModelSharp;
-using static OTSDataType.otsdataconst;
-
 using MyControls;
 using OTSModelSharp.ServiceInterface;
-using OTSModelSharp.ServiceCenter;
 using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel;
 
 namespace OTSMeasureApp
@@ -326,13 +321,13 @@ namespace OTSMeasureApp
                     if (m_visualSamples[x].GetSampleName() == sNewWSampleName)
                     {
                         string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
-                        m_visualSamples[x].SampleGDIObject.SelColor = ColorTranslator.FromHtml(ColorStr);
+                        m_visualSamples[x].GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
                         m_visualSamples[x].SetIsWorkSample(true);
                     }
                     else 
                     {
                         string SampleColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
-                        m_visualSamples[x].SampleGDIObject.SelColor = ColorTranslator.FromHtml(SampleColorStr);
+                        m_visualSamples[x].GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(SampleColorStr);
                         m_visualSamples[x].SetIsWorkSample(false);
 
                     }
@@ -396,7 +391,7 @@ namespace OTSMeasureApp
         {
             foreach (var items in m_visualSamples)
             {
-                items.MeasureGDIObject.SelColor = setColor;
+                items.GetMeasureGDIObject().SelColor = setColor;
             }
         }
         #endregion
@@ -406,15 +401,15 @@ namespace OTSMeasureApp
         {
             foreach (var items in m_visualSamples)
             {
-                if (items.SampleGDIObject.IsDragging)
+                if (items.GetSampleGDIObject().IsDragging)
                 {
                     //设置颜色
                     string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
-                    items.SampleGDIObject.SelColor = ColorTranslator.FromHtml(ColorStr);
+                    items.GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
                 }
                 else
                 {
-                    items.SampleGDIObject.SelColor = setColor;
+                    items.GetSampleGDIObject().SelColor = setColor;
                 }
             }
         }
@@ -462,11 +457,11 @@ namespace OTSMeasureApp
                
                     var sam = GetWorkingVisualSample();
 
-                    var itemMeasure = sam.MeasureGDIObject;
+                    var itemMeasure = sam.GetMeasureGDIObject();
                     itemMeasure.Shape = iShape;
                    
                            
-                            var sampleMeasurePara = m_visualStage. GetSampleMeasurePara(sam.MeasureGDIObject);
+                            var sampleMeasurePara = m_visualStage. GetSampleMeasurePara(sam.GetMeasureGDIObject());
                      
                             m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(sampleMeasurePara);
                            
@@ -501,7 +496,7 @@ namespace OTSMeasureApp
                 {
                     //设置颜色
                     string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
-                    itemSample.SampleGDIObject.SelColor = ColorTranslator.FromHtml(ColorStr);
+                    itemSample.GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
                     itemSample.SetIsWorkSample(false);
                 }
 
@@ -513,7 +508,7 @@ namespace OTSMeasureApp
 
                     m_SampleSelectName = SMeasurePara.sSampleName;
 
-                    var para = m_visualStage.GetSampleMeasurePara(sam.MeasureGDIObject);
+                    var para = m_visualStage.GetSampleMeasurePara(sam.GetMeasureGDIObject());
 
                     //var para = SMeasurePara;
                     m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
@@ -537,7 +532,7 @@ namespace OTSMeasureApp
             //设置样品选择状态为非工作样品
             foreach (var Sample in m_visualSamples)
             {
-                var itemSample = Sample.SampleGDIObject;
+                var itemSample = Sample.GetSampleGDIObject();
                 //设置颜色
                 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
                 itemSample.SelColor = ColorTranslator.FromHtml(ColorStr);
@@ -561,7 +556,7 @@ namespace OTSMeasureApp
       
 
                 var newSam = new CVisualSampleArea();
-                newSam.SampleGDIObject = sample;
+                newSam.SetSampleGDIObject(sample);
                 newSam.SetSampleName(sample.SampleName);
                 m_visualSamples.Add(newSam);
                 outsample = newSam;
@@ -786,8 +781,8 @@ namespace OTSMeasureApp
             List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
             foreach (var s in m_visualSamples)
             {
-                allobj.Add(s.SampleGDIObject);
-                allobj.Add(s.MeasureGDIObject);
+                allobj.Add(s.GetSampleGDIObject());
+                allobj.Add(s.GetMeasureGDIObject());
                 foreach (var f in s.GetMeasureFieldGDIObjects())
                 {
                     allobj.Add(f);
@@ -807,8 +802,8 @@ namespace OTSMeasureApp
             List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
             foreach (var s in m_visualSamples)
             {
-                allobj.Add(s.SampleGDIObject);
-                allobj.Add(s.MeasureGDIObject);
+                allobj.Add(s.GetSampleGDIObject());
+                allobj.Add(s.GetMeasureGDIObject());
                
 
 
@@ -924,8 +919,8 @@ namespace OTSMeasureApp
                             Point startPoint = new Point((int)(polygonPoints[0].X), (int)(polygonPoints[0].Y));//the last point is the first point too.we get the first point as the last point.
                             polygonPoints.Add(startPoint);
                             CRectangleGDIObject polygonGdi =new CRectangleGDIObject (polygonPoints, CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
-                           
-                              
+
+
                             polygonGdi.SetZoomNumber(m_visualStage.GetZoomNum());
                             polygonGdi.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
                             polygonGdi.SetPolygonPointFList(polygonPoints);
@@ -935,13 +930,13 @@ namespace OTSMeasureApp
 
                             var sam = GetVisualSampleByName(sampleName);
                                 
-                            sam.MeasureGDIObject= polygonGdi;
+                            sam.SetMeasureGDIObject(polygonGdi);
 
                             
                             m_DrawPolygonFinishGDIObject = null;
                             m_DrawMeasureGDIObject = null;
 
-                            var para = m_visualStage.GetSampleMeasurePara(sam.MeasureGDIObject);
+                            var para = m_visualStage.GetSampleMeasurePara(sam.GetMeasureGDIObject());
 
                             m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
 
@@ -978,17 +973,18 @@ namespace OTSMeasureApp
                 }
                 else if(m_DrawMeasureType == CreateRectangleType.CircleByThreePoints)
                 {
-                    var m_PolygonPoint = new List<PointF>();
-                    //添加多边形点信息
-                    m_MouseDownPoint = new Point((int)(m_MouseDownPoint.X), (int)(m_MouseDownPoint.Y));
+                    if (m_DrawMeasureGDIObject == null)
+                    {
+                         m_DrawMeasureGDIObject = new CRectangleGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
+                    }
+                    var m_PolygonPoint = m_DrawMeasureGDIObject.GetPolygonPointFList();
+                
                     m_PolygonPoint.Add(m_MouseDownPoint);
-                    CRectangleGDIObject createPoint =new CRectangleGDIObject (m_PolygonPoint, CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
-                  
-                    m_DrawMeasureGDIObject = createPoint;
-                    
+
+              
 
                     //显示绘制多边形完成标识
-                    if (m_PolygonPoint.Count == 3)
+                    if (m_PolygonPoint.Count == 3)//three point can make a circle .
                     {
                         //转为圆形这里
                         m_DrawMeasureType = (int)CreateRectangleType.Circle;
@@ -1013,13 +1009,16 @@ namespace OTSMeasureApp
                         //在鼠标点击时添加一个默认大小与位置的图形
 
                         m_DrawMeasureGDIObject=CRectangleGDI;
-
+                        m_DrawMeasureGDIObject.SetZoomNumber(m_visualStage.GetZoomNum());
+                        m_DrawMeasureGDIObject.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
 
 
                         var sam1 = GetVisualSampleByName(sampleName);
-                        sam1.MeasureGDIObject = m_DrawMeasureGDIObject;
+                        sam1.SetMeasureGDIObject(m_DrawMeasureGDIObject);
+                        sam1.GetMeasureGDIObject().SetZoomedRegionF(rectangleThree);
+                        m_DrawMeasureGDIObject = null;
 
-                        var para = m_visualStage.GetSampleMeasurePara(sam1.MeasureGDIObject);
+                        var para = m_visualStage.GetSampleMeasurePara(sam1.GetMeasureGDIObject());
                         m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
 
                         m_MeasureAppForm.m_RunType = MSR_THREAD_RunSTATUS.RUNMEASURE;
@@ -1116,17 +1115,17 @@ namespace OTSMeasureApp
                     foreach(var item in m_visualSamples)
                     { 
                                 bool isSelMeasure = false;
-                                if (item.MeasureGDIObject.CreateType == CreateRectangleType.Polygon)
+                                if (item.GetMeasureGDIObject().CreateType == CreateRectangleType.Polygon)
                                 {
                     
-                                     if(item.MeasureGDIObject.GPath.IsVisible(e.Location))
+                                     if(item.GetMeasureGDIObject().GPath.IsVisible(e.Location))
                                     {
                                         isSelMeasure = true;
                                     }
                                 }
                                 else
                                 {
-                                    if (item.MeasureGDIObject.IfZoomContains(e.Location) /*&& !item.MeasureGDIObject.SelColor.Name.Equals("Transparent")*/)
+                                    if (item.GetMeasureGDIObject().IfZoomContains(e.Location) /*&& !item.MeasureGDIObject.SelColor.Name.Equals("Transparent")*/)
                                     {
                                         isSelMeasure = true;
                                         int WH = 2;
@@ -1160,8 +1159,8 @@ namespace OTSMeasureApp
                                     this.CMStrip.Show(this, _Point);
 
                                    
-                                    m_SampleHoleSelectName = item.MeasureGDIObject.Name;
-                                    if (m_SampleSelectName != item.MeasureGDIObject.SampleName)
+                                    m_SampleHoleSelectName = item.GetMeasureGDIObject().Name;
+                                    if (m_SampleSelectName != item.GetMeasureGDIObject().SampleName)
                                     {
                                         m_SampleSelectName = item.GetSampleName();
                                         //item.IsSelect = true;
@@ -1190,7 +1189,7 @@ namespace OTSMeasureApp
                     //只点击样品上(测量区域被移动到其他地方)
                     for (int i = m_visualSamples.Count - 1; i >= 0; i--)
                     {
-                        if (m_visualSamples[i].SampleGDIObject.IfZoomContains(e.Location))
+                        if (m_visualSamples[i].GetSampleGDIObject().IfZoomContains(e.Location))
                         {
             
                           
@@ -1200,7 +1199,7 @@ namespace OTSMeasureApp
                             _Point = this.PointToClient(Cursor.Position);
                             bool flag = false;
                        
-                            if (m_visualSamples[i].MeasureGDIObject.IfZoomContains(e.Location))
+                            if (m_visualSamples[i].GetMeasureGDIObject().IfZoomContains(e.Location))
                             {
                                 //测量区域菜单
                                 _IsSelectType = ContextMenuType.MeasureMenu;
@@ -1215,7 +1214,7 @@ namespace OTSMeasureApp
                             if (m_SampleSelectName != m_visualSamples[i].GetSampleName())
                             {
                                 m_SampleSelectName = m_visualSamples[i].GetSampleName();
-                                m_SampleHoleSelectName = m_visualSamples[i].MeasureGDIObject.Name;
+                                m_SampleHoleSelectName = m_visualSamples[i].GetMeasureGDIObject().Name;
                                
                                 m_visualSamples[i].SetIsWorkSample(true);
                               
@@ -1286,7 +1285,7 @@ namespace OTSMeasureApp
                         var sam = GetWorkingVisualSample();
                         if (sam != null)
                         { 
-                            var item = sam.MeasureGDIObject;
+                            var item = sam.GetMeasureGDIObject();
                        
                            var selWSampleMeasureStatus = m_MeasureAppForm.m_ProjParam.GetWorkSampleMeasureStatus();
                             if (selWSampleMeasureStatus)
@@ -1378,10 +1377,10 @@ namespace OTSMeasureApp
                         var sam1 = m_visualSamples[i];
 
                       
-                            if (sam1.SampleGDIObject.IfZoomContains(e.Location))
+                            if (sam1.GetSampleGDIObject().IfZoomContains(e.Location))
                             {
-                                NLog.LogManager.GetCurrentClassLogger().Info(sam1.MeasureGDIObject.GetOrigionalDrawRegionF().ToString());
-                                var measureItem = sam1.MeasureGDIObject;
+                                NLog.LogManager.GetCurrentClassLogger().Info(sam1.GetMeasureGDIObject().GetOrigionalDrawRegionF().ToString());
+                                var measureItem = sam1.GetMeasureGDIObject();
 
 
                                 measureItem.SelColor = Color.Red;
@@ -1392,7 +1391,7 @@ namespace OTSMeasureApp
                               
                                 //获取颜色
                                 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
-                                sam1.SampleGDIObject.SelColor = ColorTranslator.FromHtml(ColorStr);
+                                sam1.GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
 
 
                                 m_SampleSelectName = sam1.GetSampleName();
@@ -1476,14 +1475,8 @@ namespace OTSMeasureApp
                 //圆形三点法
                 else if (m_DrawMeasureType == CreateRectangleType.CircleByThreePoints)
                 {
-                    //PointF startPoint = new PointF();
-                    //PointF endPoint = new PointF();
-                    //显示直线开始点与鼠标当前位置的直线
-                    //if (m_PolygonPoint.Count > 0)
-                    //{
-                    //    startPoint = m_PolygonPoint[0];
-                    //    endPoint = m_PolygonPoint[m_PolygonPoint.Count - 1];
-                    //}
+                    m_DrawMeasureGDIObject.PolygonDrawingEndPoint = this.m_MouseMovePoint;
+                   
                 }
                 else
                 {
@@ -1596,7 +1589,7 @@ namespace OTSMeasureApp
             {
 
                 var sam = GetWorkingVisualSample();
-                    var curMeasureGdi = sam.MeasureGDIObject;
+                    var curMeasureGdi = sam.GetMeasureGDIObject();
 
                       
                             if (curMeasureGdi.IsAltering)//click on the  edge or on the polygon point( vertex point of rectangle).
@@ -1788,12 +1781,12 @@ namespace OTSMeasureApp
                     var item = m_DrawMeasureGDIObject;
                     //获取样品孔名称与其他属性
                     var sam = GetVisualSampleByName(item.SampleName);
-                    item.Name = sam.MeasureGDIObject.Name;
+                    item.Name = sam.GetMeasureGDIObject().Name;
                              
-                    item.IsWorkSample = sam.MeasureGDIObject.IsWorkSample;
+                    item.IsWorkSample = sam.GetMeasureGDIObject().IsWorkSample;
                        
                     sam.GetMeasureFieldGDIObjects().Clear();
-                    sam.MeasureGDIObject = item;
+                    sam.SetMeasureGDIObject(item);
 
                     var para = m_visualStage.GetSampleMeasurePara(item);
 
@@ -1829,7 +1822,7 @@ namespace OTSMeasureApp
                 {
                     return;
                 }
-                var measureItem = sam.MeasureGDIObject;
+                var measureItem = sam.GetMeasureGDIObject();
 
                
 
@@ -2138,7 +2131,7 @@ namespace OTSMeasureApp
             //设置鼠标在样品测量区域上的样式
             foreach (var sam in m_visualSamples)
             {
-                var item = sam.MeasureGDIObject;
+                var item = sam.GetMeasureGDIObject();
              
           
                 if (item.GPath != null)
@@ -2231,7 +2224,7 @@ namespace OTSMeasureApp
             //设置鼠标在样品上的样式
             foreach (var sam in m_visualSamples)
             {
-                var item = sam.SampleGDIObject;
+                var item = sam.GetSampleGDIObject();
                 if (!item.SelColor.Name.Equals("Transparent"))
                 {
                     if (item.IfZoomContains(mousePoint))
@@ -2331,7 +2324,7 @@ namespace OTSMeasureApp
                                     CRectangleGDIObject createFinishPoint =new CRectangleGDIObject (ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueAreaList[i].iShape, SMeasrueAreaList[i].sampleHoleName, SMeasrueAreaList[i].sSampleName, Color.Red);
 
                                
-                                    sam.MeasureGDIObject = createFinishPoint;
+                                    sam.SetMeasureGDIObject(createFinishPoint);
                                     DrawMeasureField(sam);
                                    
                                 }
@@ -2347,7 +2340,7 @@ namespace OTSMeasureApp
                                     if (m_visualStage. GetMeasureGdiObjectFromSampleGdi( gdi,out measureGdi))
                                     {
                                 
-                                        sam.MeasureGDIObject= measureGdi;
+                                        sam.SetMeasureGDIObject(measureGdi);
                                         DrawMeasureField(sam);
                                      }
                                 }
@@ -2519,7 +2512,7 @@ namespace OTSMeasureApp
                
 
                     sampleName = sam.GetSampleName();
-                    sampleHoleName = sam.SampleGDIObject.Name;
+                    sampleHoleName = sam.GetSampleGDIObject().Name;
                     
 
                     CRectangleGDIObject createRect =new CRectangleGDIObject (visualRect, fieldRects[i].X, fieldRects[i].Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorTranslator.FromHtml(ColorStr));
@@ -2542,7 +2535,7 @@ namespace OTSMeasureApp
                 else if (m_MeasureAppForm.m_RunType == MSR_THREAD_RunSTATUS.RUNMEASURE)
                 {
                     m_MeasureAppForm.UpdatePropertyVal();
-                    sam.MeasureGDIObject.SubItems().Clear();
+                    sam.GetMeasureGDIObject().SubItems().Clear();
                     //添加帧图列表
                     foreach (var r in visualfieldRects)
                     {
@@ -2631,7 +2624,7 @@ namespace OTSMeasureApp
                    
            
                     var sam = GetWorkingVisualSample();
-                    var MeasureItem = sam.MeasureGDIObject;
+                    var MeasureItem = sam.GetMeasureGDIObject();
                  
 
                       var measurePos = m_visualStage.OTSCoordToCtrlCoord(OTSLocation);
@@ -2794,7 +2787,7 @@ namespace OTSMeasureApp
             CRectangleGDIObject itemWorkSample;
             var sam = GetWorkingVisualSample();
 
-            itemWorkSample = GetWorkingVisualSample().SampleGDIObject;
+            itemWorkSample = GetWorkingVisualSample().GetSampleGDIObject();
             //获取样品孔BSE图像
             Image bseImage ;
             int m_iWidth = width;
@@ -2993,8 +2986,8 @@ namespace OTSMeasureApp
             m_MeasureGDIObject.SetInitRegionF(SampleRectangleF);
      
             var sam = GetWorkingVisualSample();
-            var mea = sam.MeasureGDIObject;
-            CRectangleGDIObject m_ResetMeasureGDIobjects = ResetMeasure( sam.SampleGDIObject, m_MeasureGDIObject);
+            var mea = sam.GetMeasureGDIObject();
+            CRectangleGDIObject m_ResetMeasureGDIobjects = ResetMeasure( sam.GetSampleGDIObject(), m_MeasureGDIObject);
             mea.SetInitRegionF(m_ResetMeasureGDIobjects.GetOrigionalDrawRegionF());
             mea.Shape = m_ResetMeasureGDIobjects.Shape;
             Invalidate();

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

@@ -211,14 +211,7 @@ namespace OTSMeasureApp
                 Point OTSLocation = new Point();
               
                 //鼠标在样品台中移动获取坐标
-                OTSLocation = stage.GetMouseSEMLocation(mousePoint);
-
-                var offsetX = mousePoint.X - stage.GetDisplayRefPoint().X;
-                var offsetY = mousePoint.Y - stage.GetDisplayRefPoint().Y;
-                PointF ctrlPoint = new PointF(offsetX / stage.GetZoomNum(), offsetY / stage.GetZoomNum());
-
-                PointF otsPoint = stage.CtrlCoordToOTSCoord(ctrlPoint);
-
+                OTSLocation = stage.GetMouseOTSLocation(mousePoint);
 
                 PointF SEMPoint =m_ProjData.ConvertOTSToSemCoord(OTSLocation);
 
@@ -255,7 +248,7 @@ namespace OTSMeasureApp
                 Point OTSLocation = new Point();
              
                 //鼠标在样品台中移动获取坐标
-                OTSLocation = stage.GetMouseSEMLocation(mousePoint);
+                OTSLocation = stage.GetMouseOTSLocation(mousePoint);
                 PointF SEMPoint = m_ProjData.ConvertOTSToSemCoord(OTSLocation);
                 //循环single中所有对象 进行位置匹配
                 for (int i = 0; i < m_MeasureFieldGDIObjects.Count; i++)
@@ -264,11 +257,11 @@ namespace OTSMeasureApp
                     {
                         //获取帧图左上坐标
                         Point LT = new Point((int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Left, (int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Top);
-                        PointF lTLocation = stage.GetMouseSEMLocation(LT);
+                        PointF lTLocation = stage.GetMouseOTSLocation(LT);
                         lTLocation = m_ProjData.ConvertOTSToSemCoord(lTLocation);
                         //获取帧图右下坐标
                         Point RB = new Point((int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Right, (int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Bottom);
-                        PointF rbLocation = stage.GetMouseSEMLocation(RB);
+                        PointF rbLocation = stage.GetMouseOTSLocation(RB);
                         rbLocation = m_ProjData.ConvertOTSToSemCoord(rbLocation);
 
                         float  diffX = Math.Abs(rbLocation.X - lTLocation.X) / 2;

+ 10 - 34
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualStage.cs

@@ -555,8 +555,8 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
 
 
-                newsample.SampleGDIObject = sampleGDIObject;
-                newsample.MeasureGDIObject = newMeasureGDIObject;
+                newsample.SetSampleGDIObject(sampleGDIObject);
+                newsample.SetMeasureGDIObject(newMeasureGDIObject);
                 a_visualSample = newsample;
                 return true;
 
@@ -715,7 +715,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
 
             //鼠标在样品台中移动获取坐标
-            Point mousePoint = GetMouseSEMLocation(mPoint);
+            Point mousePoint = GetMouseOTSLocation(mPoint);
 
             PointF SEMPoint = new Point();
             m_SEMStageData.ConvertOTSToSEMCoord(mousePoint, ref SEMPoint);
@@ -729,42 +729,18 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             m_MeasureAppForm.ShowSemCoordvAL(STSemCoordinate);
 
         }
-        public Point GetMouseSEMLocation(Point mousePoint)
+        public Point GetMouseOTSLocation(Point mousePoint)
         {
 
-            var domain = GetOTSSampleStageData().StageDomain;
-            PointF rectLocation = m_StageEdgeGDIObjects[0].GetZoomedRegion.Location;
-            //样品台尺寸
-            SizeF rectSize = m_StageEdgeGDIObjects[0].GetZoomedRegion.Size;
-            //鼠标在工作区域中的位置
+            var offsetX = mousePoint.X - this.GetDisplayRefPoint().X;
+            var offsetY = mousePoint.Y - this.GetDisplayRefPoint().Y;
+            PointF ctrlPoint = new PointF(offsetX / this.GetZoomNum(), offsetY / this.GetZoomNum());
 
-            //OTS坐标中鼠标的位置
-            float  OTSX = -((rectLocation.X + rectSize.Width / 2) - mousePoint.X);
-            float  OTSY = -(mousePoint.Y - (rectLocation.Y + rectSize.Height / 2));
-            //OTS坐标中鼠标的尺寸位置
-            double OTSWidth = 0;
-            double OTSHeight = 0;
-
-            float  width = m_VisualStageEdgeLength;
-            float  height = m_VisualStageEdgeLength;
-
-
-            //获取样品台两个坐标点
-            var XDomain = new PointF(domain.Left, domain.Top);
-            var YDomain = new PointF(domain.Right, domain.Bottom);
-            //转换类型
-            PointF xDomain = (XDomain);
-            PointF yDomain = (YDomain);
-            //宽度
-            float widthDomain = Math.Abs((yDomain).X - (xDomain).X);
-            float  heightDomain = Math.Abs((yDomain).Y - (xDomain).Y);
-
-            //换算鼠标在OTS坐标中的位置
-            OTSWidth = (OTSX * ((double)widthDomain / width));
-            OTSHeight = (OTSY * ((double)widthDomain / height));
+            PointF otsPoint = this.CtrlCoordToOTSCoord(ctrlPoint);
 
+           
 
-            Point OTSMousePosition = new Point(Convert.ToInt32(Math.Round(OTSWidth, 0)), Convert.ToInt32(Math.Round(OTSHeight, 0)));
+            Point OTSMousePosition = new Point(Convert.ToInt32(Math.Round(otsPoint.X, 0)), Convert.ToInt32(Math.Round(otsPoint.Y, 0)));
 
             return OTSMousePosition;