|
@@ -131,6 +131,8 @@ namespace OTSMeasureApp
|
|
|
bool m_IsDrawPolygonFinish = false;
|
|
|
//手动绘制测量区域的形状类型
|
|
|
int m_DrawMeasureType = 1;
|
|
|
+ //是否为3点发画圆形
|
|
|
+ bool IsCirCleByThree = false;
|
|
|
//是否手绘标识准备
|
|
|
public bool m_IsDrawMeasureReady = false;
|
|
|
//是否手绘标识
|
|
@@ -257,12 +259,10 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 三点画圆形测试区域 事件
|
|
|
+ /// 三点画圆形测试区域 事件 先多边形后圆形
|
|
|
/// </summary>
|
|
|
public void Rev_DDrawCircleMeasureByThreePoints_MeasureAppToSampleWindow_Event()
|
|
|
{
|
|
|
- //多边形测量区域完成标识
|
|
|
- m_DrawPolygonFinishGDIObjects = new List<ARectangleGDIObject>();
|
|
|
//手绘测量区域类型为圆形
|
|
|
m_DrawMeasureType = (int)CreateRectangleType.CircleByThreePoints;
|
|
|
m_IsDrawMeasureReady = true;
|
|
@@ -921,7 +921,29 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+ private void GetTriangleExcenterRadius(PointF A, PointF B, PointF C, 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);
|
|
|
+ }
|
|
|
|
|
|
+ private float GetDistance(PointF A, PointF B)
|
|
|
+ {
|
|
|
+ return (float)Math.Sqrt(Math.Pow((A.X - B.X), 2) + Math.Pow((A.Y - B.Y), 2));
|
|
|
+ }
|
|
|
#region 窗体事件
|
|
|
private void OTSSamplespaceWindow_Load(object sender, EventArgs e)
|
|
|
{
|
|
@@ -1099,41 +1121,11 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
else if(m_DrawMeasureType == (int)CreateRectangleType.CircleByThreePoints)
|
|
|
{
|
|
|
- //显示绘制多边形完成标识
|
|
|
- if (m_PolygonPoint.Count == 3)
|
|
|
- {
|
|
|
- Point startPoint = new Point((int)(m_PolygonPoint[0].X), (int)(m_PolygonPoint[0].Y));
|
|
|
-
|
|
|
- //清除当前的样品测量区域
|
|
|
- for (int measureIndex = m_MeasureGDIObjects.Count - 1; measureIndex >= 0; measureIndex--)
|
|
|
- {
|
|
|
- if (m_MeasureGDIObjects[measureIndex].SampleName == sampleName)
|
|
|
- {
|
|
|
- m_MeasureGDIObjects.RemoveAt(measureIndex);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //删除存在的帧图
|
|
|
- for (int singleIndex = m_SingleGDIObjects.Count - 1; singleIndex >= 0; singleIndex--)
|
|
|
- {
|
|
|
- if (m_SingleGDIObjects[singleIndex].SampleName == sampleName)
|
|
|
- {
|
|
|
- m_SingleGDIObjects.RemoveAt(singleIndex);
|
|
|
- }
|
|
|
- }
|
|
|
- //设置手绘标识
|
|
|
- m_IsDrawMeasureReady = false;
|
|
|
- m_IsDrawMeasure = false;
|
|
|
- m_IsDrawPolygonFinish = false;
|
|
|
- this.Cursor = Cursors.Default;
|
|
|
- return;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
//添加多边形点信息
|
|
|
m_MouseDownPoint = new Point((int)(m_MouseDownPoint.X), (int)(m_MouseDownPoint.Y));
|
|
|
m_PolygonPoint.Add(m_MouseDownPoint);
|
|
|
- CreateRectangle createPoint = new CreateRectangle(m_PolygonPoint, (int)CreateRectangleType.CircleByThreePoints, m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
|
|
|
+ CreateRectangle createPoint = new CreateRectangle(m_PolygonPoint, (int)CreateRectangleType.Polygon, m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
|
|
|
if (m_DrawMeasureGDIObjects.Count > 0)
|
|
|
{
|
|
|
m_DrawMeasureGDIObjects[0] = createPoint;
|
|
@@ -1141,8 +1133,48 @@ namespace OTSMeasureApp
|
|
|
else
|
|
|
{
|
|
|
m_DrawMeasureGDIObjects.Add(createPoint);
|
|
|
- System.Threading.Thread.Sleep(1);
|
|
|
- //MessageBox.Show("a");
|
|
|
+ }
|
|
|
+
|
|
|
+ //显示绘制多边形完成标识
|
|
|
+ if (m_PolygonPoint.Count == 3)
|
|
|
+ {
|
|
|
+ //转为圆形这里
|
|
|
+ m_DrawMeasureType = (int)CreateRectangleType.Circle;
|
|
|
+ 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));
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //清除当前的样品测量区域
|
|
|
+ for (int measureIndex = m_MeasureGDIObjects.Count - 1; measureIndex >= 0; measureIndex--)
|
|
|
+ {
|
|
|
+ if (m_MeasureGDIObjects[measureIndex].SampleName == sampleName)
|
|
|
+ {
|
|
|
+ m_MeasureGDIObjects.RemoveAt(measureIndex);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //删除存在的帧图
|
|
|
+ for (int singleIndex = m_SingleGDIObjects.Count - 1; singleIndex >= 0; singleIndex--)
|
|
|
+ {
|
|
|
+ if (m_SingleGDIObjects[singleIndex].SampleName == sampleName)
|
|
|
+ {
|
|
|
+ m_SingleGDIObjects.RemoveAt(singleIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置手绘标识
|
|
|
+ m_IsDrawMeasureReady = false;
|
|
|
+ m_IsDrawMeasure = false;
|
|
|
+ m_IsDrawPolygonFinish = false;
|
|
|
+ this.Cursor = Cursors.Default;
|
|
|
+ return;
|
|
|
+
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -2170,7 +2202,7 @@ namespace OTSMeasureApp
|
|
|
//获取当前的鼠标点击位置
|
|
|
this.m_MouseUpPoint = new Point(e.X, e.Y);
|
|
|
//绘制多边形
|
|
|
- if (m_DrawMeasureType != (int)CreateRectangleType.Polygon)
|
|
|
+ if (m_DrawMeasureType != (int)CreateRectangleType.Polygon && m_DrawMeasureType != (int)CreateRectangleType.CircleByThreePoints)
|
|
|
{
|
|
|
foreach (var item in m_DrawMeasureGDIObjects)
|
|
|
{
|
|
@@ -2334,7 +2366,7 @@ namespace OTSMeasureApp
|
|
|
//减少样品数量
|
|
|
sampleHoleCountItem.SampleCount -= 1;
|
|
|
}
|
|
|
-
|
|
|
+yy
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2626,6 +2658,7 @@ namespace OTSMeasureApp
|
|
|
if (m_DrawMeasureGDIObjects[i] != null)
|
|
|
{
|
|
|
m_DrawMeasureGDIObjects[i].EndPoint = this.m_MouseMovePoint;
|
|
|
+ log.Trace("aaa");
|
|
|
m_DrawMeasureGDIObjects[i].OnPaint(e);
|
|
|
}
|
|
|
}
|