Преглед на файлове

Scale scaling optimization

cxs преди 2 седмици
родител
ревизия
64bf42e9b0
променени са 1 файла, в които са добавени 24 реда и са изтрити 23 реда
  1. 24 23
      OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs

+ 24 - 23
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs

@@ -21,7 +21,7 @@ namespace OTSMeasureApp
 {
 
     public enum MeasureStateMenuType
-    {
+    {  
         //获取BSE图
         ReadBSEPic = 0,
         //设置可视化灰度
@@ -1562,22 +1562,30 @@ namespace OTSMeasureApp
                 ImgZoomRectangle.Height += Convert.ToInt32(ImgZoomRectangle.Height / m_ZoomRecord * zoomDelta);
                 ImgZoomRectangle.X = (refPoint.X - xShift);
                 ImgZoomRectangle.Y = (refPoint.Y - yShift);
-
             }
             m_ZoomRecord = newZoom;
             control_Ruler.RulerWidth = Convert.ToInt32(f_ruler_size * m_ZoomRecord);
             control_Ruler.Value = 100;
-            //放大过长时,这里将宽度与代表的实际宽度进行折半显示
-            while (control_Ruler.Width > 300)
+            double width = GetZoomedImageRect(picBox).Width;
+            int[] RulerVal = { 1, 2, 5, 10, 20, 50, 100, 200, 500 };
+            foreach (int i in RulerVal)
             {
-                control_Ruler.RulerWidth = Convert.ToInt32(control_Ruler.RulerWidth) / 2;
-                control_Ruler.Value = control_Ruler.Value * 2;
+                double obj = Convert.ToInt32(control_Ruler.RulerWidth * i / 100);
+                if (obj  > 75)
+                {
+                    control_Ruler.RulerWidth = (int)obj;
+                    control_Ruler.Value = i;
+                    break;
+                }
             }
             control_Ruler.SetValue(control_Ruler.RulerWidth, control_Ruler.Value.ToString("0") + "um");
             picBox.Invalidate();
 
+
             pictureBox2.Invalidate();
         }
+
+
         private void OTSMeasureStatusWindow_MouseClick(object sender, MouseEventArgs e)
         {
             if (e.Button == MouseButtons.Right && e.Clicks == 1)
@@ -1761,29 +1769,22 @@ namespace OTSMeasureApp
         #region 显示标尺
         public void RulerInit()
         {
-            //control_Ruler.ShowString = "100um";
-            int realwidth= m_MeasureAppForm.m_ProjRstData.GetWorkingSample().GetSEMDataMsr().GetScanFieldSize();
+            control_Ruler.Value = 100;
+            int realwidth = m_MeasureAppForm.m_ProjRstData.GetWorkingSample().GetSEMDataMsr().GetScanFieldSize();
             double width = GetZoomedImageRect(picBox).Width;
-            f_ruler_size = width /realwidth ;
-            double length = f_ruler_size;
-            for (int i=1;i<2000;i=i*2)
+            f_ruler_size = width * 100 / realwidth;
+            int[] RulerVal = { 1, 2, 5, 10, 20, 50, 100, 200, 500 };
+            foreach (int i in RulerVal)
             {
-                length = f_ruler_size * i;
-                if (length > width/15)
+                double obj = Convert.ToInt32(f_ruler_size * i / 100);
+                if (obj + 20 >75)
                 {
-                    if(i >1000)
-                    {
-                        control_Ruler.ShowString = (i/1000).ToString()+ "mm";
-                    }
-                    else
-                    {
-                        control_Ruler.ShowString = i.ToString() + "um";
-                    }
+                    control_Ruler.RulerWidth = (int)obj;
+                    control_Ruler.Value = i;
                     break;
                 }
             }
-            control_Ruler.Value= length;
-            control_Ruler.SetValue((int)length);
+            control_Ruler.SetValue(control_Ruler.RulerWidth, control_Ruler.Value.ToString()+ "um");
         }
         private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
         {