|
|
@@ -174,8 +174,7 @@ namespace OTSMeasureApp
|
|
|
SetInitRegionF(m_OrigineRegionF);
|
|
|
CreateType = cType;
|
|
|
ID = System.Guid.NewGuid().ToString();
|
|
|
- //startPoint = new PointF(rect.Left, rect.Top);
|
|
|
- //EndPoint = new PointF(rect.Right, rect.Bottom);
|
|
|
+
|
|
|
OTSX = -1;
|
|
|
OTSY = -1;
|
|
|
}
|
|
|
@@ -188,7 +187,7 @@ namespace OTSMeasureApp
|
|
|
{
|
|
|
ID = System.Guid.NewGuid().ToString();
|
|
|
|
|
|
- this.PolygonPointFList = mPoint;
|
|
|
+ this.SetOriginalPolygonPointFList(mPoint);
|
|
|
|
|
|
|
|
|
Name = name;
|
|
|
@@ -197,10 +196,7 @@ namespace OTSMeasureApp
|
|
|
Shape = shape;
|
|
|
SelColor = selColor;
|
|
|
|
|
|
-
|
|
|
- //if(mPoint.Count>2)
|
|
|
-
|
|
|
- //GPath.AddPolygon(PolygonPointFList.ToArray());
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -494,7 +490,7 @@ namespace OTSMeasureApp
|
|
|
Color myColor = selColor;
|
|
|
System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
|
|
|
Pen pen = new Pen(myColor, 1);
|
|
|
- if (PolygonPointFList.Count > 1)
|
|
|
+ if (GetPolygonPointFList().Count > 0)
|
|
|
{
|
|
|
List<PointF> PolygonPointF = new List<PointF>();
|
|
|
foreach (var item in m_PolygonPoints)
|
|
|
@@ -526,11 +522,6 @@ namespace OTSMeasureApp
|
|
|
m_Region.Height = (int)m_RegionF.Height;
|
|
|
e.Graphics.DrawRectangle(pen, m_Region);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//绘制多边形测量区域
|
|
|
else if (createType == CreateRectangleType.CircleByThreePoints)
|
|
|
{
|
|
|
@@ -653,6 +644,16 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ public List<PointF> GetVertexPoints()
|
|
|
+ {
|
|
|
+ List<PointF> vertexPoint = new List<PointF>();
|
|
|
+ var region = this.GetZoomedRegionF();
|
|
|
+ vertexPoint.Add(region.Location);
|
|
|
+ vertexPoint.Add(new PointF(region.X, region.Y + region.Height));
|
|
|
+ vertexPoint.Add(new PointF(region.X + region.Width, region.Y));
|
|
|
+ vertexPoint.Add(new PointF(region.X + region.Width, region.Y + region.Height));
|
|
|
+ return vertexPoint;
|
|
|
+ }
|
|
|
|
|
|
public RectangleF GetZoomedRegionF()
|
|
|
{
|
|
|
@@ -676,21 +677,10 @@ namespace OTSMeasureApp
|
|
|
|
|
|
m_RegionF = new RectangleF(x1, y1, w1, h1);
|
|
|
|
|
|
- CreateRectangleType shape = this.CreateType;
|
|
|
- GraphicsPath MeasurePath = new GraphicsPath();
|
|
|
- if (shape == CreateRectangleType.Rectangle)
|
|
|
- {
|
|
|
- MeasurePath.AddRectangle(m_RegionF);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MeasurePath.AddEllipse(m_RegionF);
|
|
|
- }
|
|
|
- this.g_Path = MeasurePath;
|
|
|
|
|
|
|
|
|
}
|
|
|
- internal void SetScaleRegionF(RectangleF scaleRectangleF)
|
|
|
+ internal void SetZoomedRegionF(RectangleF scaleRectangleF)
|
|
|
{
|
|
|
float x1, y1;
|
|
|
x1 = (scaleRectangleF.X-m_refPoint.X) / m_zoomNum ;
|
|
|
@@ -701,78 +691,110 @@ namespace OTSMeasureApp
|
|
|
h1 = scaleRectangleF.Height / m_zoomNum;
|
|
|
|
|
|
|
|
|
-
|
|
|
m_OrigineRegionF = new RectangleF(x1, y1, w1, h1);
|
|
|
|
|
|
m_RegionF = scaleRectangleF;
|
|
|
|
|
|
- CreateRectangleType shape = this.CreateType;
|
|
|
- GraphicsPath MeasurePath = new GraphicsPath();
|
|
|
- if (shape == CreateRectangleType.Rectangle)
|
|
|
- {
|
|
|
- MeasurePath.AddRectangle(m_RegionF);
|
|
|
- }
|
|
|
- else
|
|
|
+ }
|
|
|
+ private Rectangle GetMinRectangleOfPolygon(List<PointF> polygonPointList)
|
|
|
+ {
|
|
|
+ if (polygonPointList != null)
|
|
|
{
|
|
|
- MeasurePath.AddEllipse(m_RegionF);
|
|
|
+ if (polygonPointList.Count > 0)
|
|
|
+ {
|
|
|
+ int pCount = polygonPointList.Count;
|
|
|
+ float minX = polygonPointList[0].X;
|
|
|
+ float minY = polygonPointList[0].Y;
|
|
|
+ float maxX = polygonPointList[0].X;
|
|
|
+ float maxY = polygonPointList[0].Y;
|
|
|
+ //获取最小X,Y 最大X,Y
|
|
|
+ for (int i = 0; i < pCount; i++)
|
|
|
+ {
|
|
|
+ minX = Math.Min(minX, polygonPointList[i].X);
|
|
|
+ minY = Math.Min(minY, polygonPointList[i].Y);
|
|
|
+ maxX = Math.Max(maxX, polygonPointList[i].X);
|
|
|
+ maxY = Math.Max(maxY, polygonPointList[i].Y);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建外接矩形
|
|
|
+ Rectangle rect = new Rectangle();
|
|
|
+ rect.Location = new Point((int)minX, (int)minY);
|
|
|
+ rect.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
|
|
|
+ return rect;
|
|
|
+ }
|
|
|
}
|
|
|
- this.g_Path = MeasurePath;
|
|
|
+ return new Rectangle();
|
|
|
}
|
|
|
|
|
|
public RectangleF GetOrigionalDrawRegionF()
|
|
|
{ return m_OrigineRegionF; }
|
|
|
|
|
|
- public List<Point> PolygonPointRegion
|
|
|
+
|
|
|
+ public List<PointF> GetOriginalPolygonPointFList()
|
|
|
+ { return m_originalPolygonPoints; }
|
|
|
+ public void SetOriginalPolygonPointFList(List<PointF> value)
|
|
|
{
|
|
|
- get {
|
|
|
- var m_PolygonPointRegion = new List<Point>();
|
|
|
- foreach (var p in m_PolygonPoints)
|
|
|
+ if (m_zoomNum != 1)
|
|
|
+ {
|
|
|
+ var ps = new List<PointF>();
|
|
|
+ foreach (var p in value)
|
|
|
{
|
|
|
- m_PolygonPointRegion.Add(new Point((int)(p.X), (int)(p.Y)));
|
|
|
+ var p1 = new PointF();
|
|
|
|
|
|
+ p1.X = p.X * m_zoomNum+m_refPoint.X;
|
|
|
+ p1.Y = p.Y *m_zoomNum+ m_refPoint.Y;
|
|
|
+ ps.Add(p1);
|
|
|
|
|
|
}
|
|
|
- return m_PolygonPointRegion;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ m_PolygonPoints = ps;
|
|
|
+ m_originalPolygonPoints = value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_originalPolygonPoints = value;
|
|
|
+ m_PolygonPoints = value;
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- public List<PointF> OriginalPolygonPointFList
|
|
|
- {
|
|
|
- get { return m_originalPolygonPoints; }
|
|
|
|
|
|
}
|
|
|
- public List<PointF> PolygonPointFList
|
|
|
+
|
|
|
+ public List<PointF> GetPolygonPointFList()
|
|
|
+ { return m_PolygonPoints; }
|
|
|
+ public void SetPolygonPointFList(List<PointF> value)
|
|
|
{
|
|
|
- get { return m_PolygonPoints; }
|
|
|
- set {
|
|
|
- if (m_zoomNum != 1)
|
|
|
+ if (m_zoomNum != 1)
|
|
|
+ {
|
|
|
+ var ps = new List<PointF>();
|
|
|
+ foreach (var p in value)
|
|
|
{
|
|
|
- var ps = new List<PointF>();
|
|
|
- foreach (var p in value)
|
|
|
- {
|
|
|
- var p1 = new PointF();
|
|
|
- //x1 = (scaleRectangleF.X - m_refPoint.X) / m_zoomNum;
|
|
|
- //y1 = (scaleRectangleF.Y - m_refPoint.Y) / m_zoomNum;
|
|
|
- p1.X = (p.X -m_refPoint.X) / m_zoomNum;
|
|
|
- p1.Y = (p.Y - m_refPoint.Y) / m_zoomNum;
|
|
|
- ps.Add(p1);
|
|
|
-
|
|
|
- }
|
|
|
+ var p1 = new PointF();
|
|
|
|
|
|
+ p1.X = (p.X - m_refPoint.X) / m_zoomNum;
|
|
|
+ p1.Y = (p.Y - m_refPoint.Y) / m_zoomNum;
|
|
|
+ ps.Add(p1);
|
|
|
|
|
|
- m_originalPolygonPoints = ps;
|
|
|
- m_PolygonPoints = value;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- m_originalPolygonPoints = value;
|
|
|
- m_PolygonPoints = value;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ m_originalPolygonPoints = ps;
|
|
|
+ m_PolygonPoints = value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_originalPolygonPoints = value;
|
|
|
+ m_PolygonPoints = value;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ var region = GetMinRectangleOfPolygon(m_PolygonPoints);
|
|
|
+ SetZoomedRegionF(region);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public GraphicsPath GPath
|
|
|
{
|
|
|
@@ -784,7 +806,7 @@ namespace OTSMeasureApp
|
|
|
if (measureItem.CreateType == CreateRectangleType.Polygon)
|
|
|
{
|
|
|
GraphicsPath PolygonMeasurePath = new GraphicsPath();
|
|
|
- PolygonMeasurePath.AddPolygon(measureItem.PolygonPointFList.ToArray());
|
|
|
+ PolygonMeasurePath.AddPolygon(measureItem.GetPolygonPointFList().ToArray());
|
|
|
GPath = PolygonMeasurePath;
|
|
|
}
|
|
|
else if (measureItem.CreateType == CreateRectangleType.CircleByThreePoints)
|
|
|
@@ -842,12 +864,12 @@ namespace OTSMeasureApp
|
|
|
get { return m_IsDragging; }
|
|
|
set { m_IsDragging = value; }
|
|
|
}
|
|
|
- public bool IsAltering// moving position or changing the size by gui operating.
|
|
|
+ public bool IsAltering// changing the size by gui operating.
|
|
|
{
|
|
|
get { return m_IsAlter; }
|
|
|
set { m_IsAlter = value; }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public bool IsWorkSample
|
|
|
{
|
|
|
get { return m_IsWorkSample; }
|
|
|
@@ -856,7 +878,18 @@ namespace OTSMeasureApp
|
|
|
public Point DraggingPoint
|
|
|
{
|
|
|
get { return m_DraggingPoint; }
|
|
|
- set { m_DraggingPoint = value; }
|
|
|
+ set {
|
|
|
+
|
|
|
+ m_DraggingPoint = value;
|
|
|
+ if (subItems.Count != 0)
|
|
|
+ {
|
|
|
+ foreach (var item in subItems)
|
|
|
+ {
|
|
|
+ item.DraggingPoint = m_DraggingPoint;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public PointF GetDisplayRefPoint()
|
|
|
@@ -868,7 +901,7 @@ namespace OTSMeasureApp
|
|
|
SetInitRegionF(m_OrigineRegionF);
|
|
|
if (m_originalPolygonPoints.Count != 0)
|
|
|
{
|
|
|
- this.PolygonPointFList = m_originalPolygonPoints;
|
|
|
+ this.SetPolygonPointFList(m_originalPolygonPoints);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -882,7 +915,7 @@ namespace OTSMeasureApp
|
|
|
SetInitRegionF(m_OrigineRegionF);
|
|
|
if (m_originalPolygonPoints.Count != 0)
|
|
|
{
|
|
|
- this.PolygonPointFList = m_originalPolygonPoints;
|
|
|
+ this.SetPolygonPointFList(m_originalPolygonPoints);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -906,7 +939,7 @@ namespace OTSMeasureApp
|
|
|
return roundedRect;
|
|
|
}
|
|
|
|
|
|
- public bool IfScaleContains(Point mousePoint)
|
|
|
+ public bool IfZoomContains(Point mousePoint)
|
|
|
{
|
|
|
if (mousePoint.X > m_RegionF.Left && mousePoint.X < m_RegionF.Left + m_RegionF.Width)
|
|
|
{
|
|
|
@@ -920,7 +953,7 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- public bool IfContains(Point thePoint)
|
|
|
+ public bool IfContains(PointF thePoint)
|
|
|
{
|
|
|
if (thePoint.X > m_OrigineRegionF.Left && thePoint.X < m_OrigineRegionF.Left + m_OrigineRegionF.Width)
|
|
|
{
|
|
|
@@ -940,10 +973,10 @@ namespace OTSMeasureApp
|
|
|
if (subItems == null) subItems = new List<CRectangleGDIObject>();
|
|
|
return subItems;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
|
|
|
public void Zoom(PointF mousePoint, float zoomNum)
|
|
|
+
|
|
|
{
|
|
|
if (m_zoomNum == 1)
|
|
|
{
|
|
|
@@ -951,10 +984,10 @@ namespace OTSMeasureApp
|
|
|
m_refPoint = new PointF(0, 0);
|
|
|
m_PolygonPoints = m_originalPolygonPoints;
|
|
|
}
|
|
|
+ float X1;
|
|
|
float curZoom = m_zoomNum;
|
|
|
|
|
|
float deltaZoom = zoomNum - curZoom;
|
|
|
- float X1;
|
|
|
float Y1;
|
|
|
|
|
|
X1 = (m_RegionF.X - mousePoint.X) / curZoom * deltaZoom + m_RegionF.X;
|
|
|
@@ -1011,10 +1044,15 @@ namespace OTSMeasureApp
|
|
|
X1 = (m_RegionF.X + offset.X);
|
|
|
Y1 = (m_RegionF.Y + offset.Y);
|
|
|
|
|
|
+
|
|
|
+ m_RegionF = new RectangleF(X1, Y1, m_RegionF.Width, m_RegionF.Height);
|
|
|
+ SetZoomedRegionF(m_RegionF);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
m_refPoint.X = m_refPoint.X + offset.X;
|
|
|
m_refPoint.Y = m_refPoint.Y + offset.Y;
|
|
|
|
|
|
- m_RegionF = new RectangleF(X1, Y1, m_RegionF.Width, m_RegionF.Height);
|
|
|
BSEImageWitdh = m_RegionF.Width;
|
|
|
BSEImageHeight = m_RegionF.Height;
|
|
|
BSEImageLocation = m_RegionF.Location;
|
|
|
@@ -1044,6 +1082,69 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void PositionAltering(PointF location,bool ifZoomCoord)
|
|
|
+ {
|
|
|
+
|
|
|
+ PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
|
|
|
+
|
|
|
+ PointF realShift;
|
|
|
+ if (ifZoomCoord)
|
|
|
+ {
|
|
|
+ realShift = new PointF(offset.X / m_zoomNum, offset.Y / m_zoomNum);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ realShift = new PointF(offset.X , offset.Y );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ m_OrigineRegionF = new RectangleF(m_OrigineRegionF.X+realShift.X, m_OrigineRegionF.Y+realShift.Y, m_OrigineRegionF.Width, m_OrigineRegionF.Height);
|
|
|
+
|
|
|
+ SetInitRegionF(m_OrigineRegionF);
|
|
|
+
|
|
|
+ BSEImageWitdh = m_RegionF.Width;
|
|
|
+ BSEImageHeight = m_RegionF.Height;
|
|
|
+ BSEImageLocation = m_RegionF.Location;
|
|
|
+ SEMCenterPoint = m_RegionF.Location;
|
|
|
+ LineStartPoint = m_RegionF.Location;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var scalePs = new List<PointF>();
|
|
|
+ var OriginalPs = new List<PointF>();
|
|
|
+ foreach (var p in m_PolygonPoints)
|
|
|
+ {
|
|
|
+ float x, y;
|
|
|
+ x = (p.X + offset.X);
|
|
|
+ y = (p.Y + offset.Y);
|
|
|
+ scalePs.Add(new PointF(x, y));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ m_PolygonPoints = scalePs;
|
|
|
+
|
|
|
+ foreach (var p in m_originalPolygonPoints)
|
|
|
+ {
|
|
|
+
|
|
|
+ OriginalPs.Add(new PointF(p.X + realShift.X, p.Y + realShift.Y));
|
|
|
+
|
|
|
+ }
|
|
|
+ m_originalPolygonPoints = OriginalPs;
|
|
|
+
|
|
|
+ m_DraggingPoint = new Point((int)location.X, (int)location.Y);
|
|
|
+
|
|
|
+ if (this.subItems.Count != 0)
|
|
|
+ {
|
|
|
+ foreach (var g in subItems)
|
|
|
+ {
|
|
|
+ g.PositionAltering(location,ifZoomCoord);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
public void Show(PointF location)
|
|
|
@@ -1058,8 +1159,7 @@ namespace OTSMeasureApp
|
|
|
r.SampleName = this.SampleName;
|
|
|
r.m_OrigineRegionF = this.m_OrigineRegionF;
|
|
|
|
|
|
- r.IsWorkSample = this.IsWorkSample;
|
|
|
- //r.IsAltering = this.IsAltering;
|
|
|
+ r.IsWorkSample = this.IsWorkSample;
|
|
|
r.m_RegionF = this.m_RegionF;
|
|
|
|
|
|
|