|
@@ -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)
|
|
|
{
|