Kaynağa Gözat

三点法三点可画图,差sem读取数据和移动及界面缩放

CXS 3 yıl önce
ebeveyn
işleme
3a4295b6c7

+ 20 - 0
OTS.sln

@@ -47,6 +47,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OTSLog", "OTSCPP\OTSLog\OTS
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OTSCleanReportApp", "OTSCleanReportApp\OTSCleanReportApp.csproj", "{BFD11203-CDF9-47D8-B00B-0743A8BE1212}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OTSExtremum", "OTSExtremum\OTSExtremum.csproj", "{BBA845E8-27ED-4832-90FA-32F737E1FCA7}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -321,6 +323,24 @@ Global
 		{BFD11203-CDF9-47D8-B00B-0743A8BE1212}.Release|x64.Build.0 = Release|x64
 		{BFD11203-CDF9-47D8-B00B-0743A8BE1212}.Release|x86.ActiveCfg = Release|x86
 		{BFD11203-CDF9-47D8-B00B-0743A8BE1212}.Release|x86.Build.0 = Release|x86
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Debug|x64.Build.0 = Debug|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Debug|x86.Build.0 = Debug|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release_oxford50|Any CPU.ActiveCfg = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release_oxford50|Any CPU.Build.0 = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release_oxford50|x64.ActiveCfg = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release_oxford50|x64.Build.0 = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release_oxford50|x86.ActiveCfg = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release_oxford50|x86.Build.0 = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release|x64.ActiveCfg = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release|x64.Build.0 = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release|x86.ActiveCfg = Release|Any CPU
+		{BBA845E8-27ED-4832-90FA-32F737E1FCA7}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 9 - 28
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CreateRectangle.cs

@@ -820,37 +820,18 @@ namespace OTSMeasureApp
             //绘制多边形测量区域
             else if (createType == (int)CreateRectangleType.CircleByThreePoints)
             {
+                Color myColor = selColor;
+                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
+                Pen p = new Pen(myColor, 1);
                 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
                 e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
                 e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                Color myColor = selColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(myColor, 1);
-                if (PolygonPointRegionF.Count > 0)
-                {
-                    List<PointF> PolygonPointF = new List<PointF>();
-                    foreach (var item in PolygonPointRegionF)
-                    {
-                        PolygonPointF.Add(item);
-                    }
-                    if (EndPoint.X != 0 && EndPoint.Y != 0)
-                    {
-                        PolygonPointF.Add(EndPoint);
-                    }
-                    try
-                    {
-                        e.Graphics.DrawLines(pen, PolygonPointF.ToArray());
-                        //多边形的外接矩形
-                        //if (Region != null)
-                        //{
-                        //    e.Graphics.DrawRectangle(new Pen(Color.Green), Region);
-                        //}
-                    }
-                    catch (Exception ex)
-                    {
-                        //MessageBox.Show(ex.ToString());
-                    }
-                }
+                GraphicsPath MeasureAreaPath = new GraphicsPath();
+
+                
+                    MeasureAreaPath.AddEllipse(m_RegionF);
+                    e.Graphics.DrawEllipse(p, m_Region);
+                
             }
         }
         public override bool IsDragging

+ 36 - 20
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -921,23 +921,20 @@ namespace OTSMeasureApp
             }
         }
         #endregion
-        private void GetTriangleExcenterRadius(PointF A, PointF B, PointF C, out float R, out PointF center)
+        private void GetTriangleExcenterRadius(PointF px1, PointF px2, PointF px3, out float R, out PointF center)
         {
-            //same point
-            if (A == B && A == C)
-            {
-                R = 0;
-                //center = new Point((int)A.X,(int)A.Y);
-                center = A;
-                return;
-            }
-            double x1 = A.X, x2 = B.X, x3 = C.X, y1 = A.Y, y2 = B.Y, y3 = C.Y;
-            double C1 = Math.Pow(x1, 2) + Math.Pow(y1, 2) - Math.Pow(x2, 2) - Math.Pow(y2, 2);
-            double C2 = Math.Pow(x2, 2) + Math.Pow(y2, 2) - Math.Pow(x3, 2) - Math.Pow(y3, 2);
-            double centery = (C1 * (x2 - x3) - C2 * (x1 - x2)) / (2 * (y1 - y2) * (x2 - x3) - 2 * (y2 - y3) * (x1 - x2));
-            double centerx = (C1 - 2 * centery * (y1 - y2)) / (2 * (x1 - x2));
-            center = new Point((int)centerx, (int)centery);
-            R = GetDistance(A, center);
+            float x1, y1, x2, y2, x3, y3;
+            float a, b;
+            x1 = px1.X;
+            y1 = px1.Y;
+            x2 = px2.X;
+            y2 = px2.Y;
+            x3 = px3.X;
+            y3 = px3.Y;
+            a = ((y2 - y1) * (y3 * y3 - y1 * y1 + x3 * x3 - x1 * x1) - (y3 - y1) * (y2 * y2 - y1 * y1 + x2 * x2 - x1 * x1)) / (2 * ((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)));
+            b = ((x2 - x1) * (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) - (x3 - x1) * (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1)) / (2 * ((y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1)));
+            center = new PointF(a, b);
+            R = (float)Math.Sqrt((x1 - a) * (x1 - a) + (y1 - b) * (y1 - b));
         }
 
         private float GetDistance(PointF A, PointF B)
@@ -1143,13 +1140,26 @@ namespace OTSMeasureApp
                         float r = 0;
                         PointF Centerpoint = new PointF();
                         GetTriangleExcenterRadius(m_PolygonPoint[0], m_PolygonPoint[1], m_PolygonPoint[2], out r, out Centerpoint);
-                        RectangleF rectangleThree = new RectangleF(Centerpoint, new SizeF(r, r));
+                        RectangleF rectangleThree = new RectangleF(new PointF(Centerpoint.X-r, Centerpoint.Y-r), new SizeF(r*2, r*2));
+                        //在样品台内部缩放
+                        if (OTSSamplespaceGraphicsPanelFun.CheckMeasureAreaIsBeyondStageArea(new Rectangle(new Point((int)(Centerpoint.X - r), (int)(Centerpoint.Y - r)), new Size((int)r * 2, (int)r * 2)), m_RectangleGDIObjects[0].Region, m_DrawMeasureType))
+                        {
+                            m_IsDrawMeasure = true;
+                        }
+                        else
+                        {
+                            m_IsDrawMeasure = false;
+                            return;
+                        }
                         Color MeasureColor = Color.Red;
                         CreateRectangle createRectangle = new CreateRectangle(rectangleThree, m_PolygonPoint[0], (int)CreateRectangleType.MeasureArea, m_DrawMeasureType, sampleName, sampleName, MeasureColor);
                         //在鼠标点击时添加一个默认大小与位置的图形
                         createRectangle.RegionF = createRectangle.Region;
                         createRectangle.DrawRegionF = createRectangle.Region;
-                        m_DrawMeasureGDIObjects.Add(createRectangle);
+                        if (m_DrawMeasureGDIObjects.Count > 0)
+                        {
+                            m_DrawMeasureGDIObjects[0] = createRectangle;
+                        }
 
                         //清除当前的样品测量区域
                         for (int measureIndex = m_MeasureGDIObjects.Count - 1; measureIndex >= 0; measureIndex--)
@@ -1170,8 +1180,6 @@ namespace OTSMeasureApp
                         }
                         //设置手绘标识
                         m_IsDrawMeasureReady = false;
-                        m_IsDrawMeasure = false;
-                        m_IsDrawPolygonFinish = false;
                         this.Cursor = Cursors.Default;
                         return;
 
@@ -2494,6 +2502,14 @@ namespace OTSMeasureApp
             //SEM中心位置
             MouseUpFucntion(m_SEMCenterGDIObjects, e);
 
+            if (m_DrawMeasureType == (int)CreateRectangleType.CircleByThreePoints)
+            {
+                if (m_PolygonPoint.Count == 3)
+                {
+                    m_DrawMeasureType = (int)CreateRectangleType.Circle;
+                }
+            }
+
             //撤回原样品孔中
             if (IsContains == 0)
             {