using OTSDataType; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel { public class CVisualStage { //original data CStage m_SStage; CSEMStageData m_SEMStageData; //interchange object StageDrawingData m_OTSSampleStageData; PointF StageLTPointToSEMLocation = new Point(0, 0); PointF StageRBPointToSEMLocation = new Point(0, 0); float m_VisualStageEdgeLength; float m_OTSCoordStageEdgeLength = 0; int m_totalCtrlWidth; int m_totalCtrlHeight; //记录绘制样品台时的中心位置 PointF m_RegionStartCenterPoint = new PointF(0, 0); //样品台存在的List集合 the rectangle on the edge of stage ,usually one. private List m_StageEdgeGDIObjects; //标样存在的List集合 usually it is a samll circle. private List m_SpecimenGDIObjects; private List m_SampleHoleGDIObjects;// the hole gdi of the stage //文字内容 private List m_ContentGDIObjects;//the text that will display in the hole. public StageDrawingData GetOTSSampleStageData() { return m_OTSSampleStageData; } public void SetOTSSampleStageData(StageDrawingData value) { m_OTSSampleStageData = value; } public CVisualStage(StageDrawingData oTSSampleStageData) { //样品台 m_StageEdgeGDIObjects = new List(); //标样 m_SpecimenGDIObjects = new List(); //样品孔 m_SampleHoleGDIObjects = new List(); //样品孔文字内容 m_ContentGDIObjects = new List(); m_OTSSampleStageData = new StageDrawingData(); SetOTSSampleStageData(oTSSampleStageData ?? throw new ArgumentNullException(nameof(oTSSampleStageData))); } public CVisualStage() { //样品台 m_StageEdgeGDIObjects = new List(); //标样 m_SpecimenGDIObjects = new List(); //样品孔 m_SampleHoleGDIObjects = new List(); //样品孔文字内容 m_ContentGDIObjects = new List(); m_OTSSampleStageData = new StageDrawingData(); } public void clear() { m_StageEdgeGDIObjects.Clear(); m_SpecimenGDIObjects.Clear(); m_SampleHoleGDIObjects.Clear(); m_ContentGDIObjects.Clear(); } public CRectangleGDIObject GetEdgeGDIObj() { return m_StageEdgeGDIObjects[0]; } public float GetZoomNum() { return m_StageEdgeGDIObjects[0].GetZoomNumber(); } public PointF GetDisplayRefPoint() { return m_StageEdgeGDIObjects[0].GetDisplayRefPoint(); } public CRectangleGDIObject GetHoleGDIBySampleName(string name) { foreach (var g in m_SampleHoleGDIObjects) { if (g.SampleName == name) { return g; } } return null; } public CRectangleGDIObject GetHoleGDIByHoleName(string name) { foreach (var g in m_SampleHoleGDIObjects) { if (g.NameOrHoleName == name) { return g; } } return null; } public CRectangleGDIObject GetHoleGDIByMousePoint(Point mousePoint) { foreach (var g in m_SampleHoleGDIObjects) { if (g.IfZoomContains(mousePoint)) { return g; } } return null; } public void cleargdiobj() { m_StageEdgeGDIObjects.Clear(); m_SpecimenGDIObjects.Clear(); m_SampleHoleGDIObjects.Clear(); m_ContentGDIObjects.Clear(); } public void InitSampleStageData(CStage SStage, CSEMStageData SEMStageData, int ctrlWidth, int ctrlHeight) { //获取样品台信息 if (null == SStage) { return; } m_SStage = SStage; m_SEMStageData = SEMStageData; //获得样品台数据 GetOTSSampleStageData().sStageName = SStage.GetName(); GetOTSSampleStageData().bStageShape = (ShapeType)SStage.GetBoundary().GetShape(); GetOTSSampleStageData().StageDomain = SStage.GetBoundary().GetRectDomain(); GetOTSSampleStageData().bSampleShape = (ShapeType)SStage.GetSTD().GetShape(); GetOTSSampleStageData().SampleRect = SStage.GetSTD().GetRectDomain(); int iSHoleCount = SStage.GetHoleList().Count; //样品孔个数 if (GetOTSSampleStageData().sSHoleInfoList.Count > 0) { GetOTSSampleStageData().sSHoleInfoList.Clear(); } var holeLst = SStage.GetHoleList(); for (int i = 0; i < iSHoleCount; i++) { CHole d = holeLst[i]; OTSSampleHoleInfo SHoleInfo = new OTSSampleHoleInfo(); //获取样品口的名称,形状,坐标 SHoleInfo.sSHoleName = d.GetName(); SHoleInfo.iSHoleShape = (int)d.GetShape(); RectangleF r = d.GetRectDomain(); SHoleInfo.HoleRect = r; GetOTSSampleStageData().sSHoleInfoList.Add(SHoleInfo); } //获取SEMData 绘制样品 GetOTSSampleStageData().iScanFieldSize100 = SEMStageData.GetScanFieldSize100(); //放大倍数为100倍时的屏幕尺寸 GetOTSSampleStageData().iXAxisDir = (int)SEMStageData.GetXAxisDir(); GetOTSSampleStageData().iYAxisDir = (int)SEMStageData.GetYAxisDir(); GetOTSSampleStageData().iXAxisStartVal = SEMStageData.GetXAxis().GetStart(); GetOTSSampleStageData().iXAxisEndVal = SEMStageData.GetXAxis().GetEnd(); GetOTSSampleStageData().iYAxisStartVal = SEMStageData.GetYAxis().GetStart(); GetOTSSampleStageData().iYAxisEndVal = SEMStageData.GetYAxis().GetEnd(); PointF xDomain = new PointF(GetOTSSampleStageData().StageDomain.Left, GetOTSSampleStageData().StageDomain.Top); PointF yDomain = new PointF(GetOTSSampleStageData().StageDomain.Right, GetOTSSampleStageData().StageDomain.Bottom); //OTS宽度高度差值 float widthDomain = Math.Abs(yDomain.X - xDomain.X); //设置样品台宽度 m_OTSCoordStageEdgeLength = widthDomain;//the stage must be a square.So we can only memorize an edge length.this is millimeter usually. m_VisualStageEdgeLength = ctrlHeight > ctrlWidth ? ctrlWidth : ctrlHeight;//the stage must be a square.So we can memorize an edge length only. //记录添加帧图的尺寸 鼠标滚动时使用的原值 m_totalCtrlWidth = ctrlWidth; m_totalCtrlHeight = ctrlHeight; return; } public PointF GetCenterPointF() { var item = m_StageEdgeGDIObjects[0].GetZoomedRegionF(); //声明中心点变量 PointF pCenterPoint = new Point(); //获取在工作窗口中X,Y位置 pCenterPoint.X = item.X + item.Width / 2; pCenterPoint.Y = item.Y + item.Height / 2; return pCenterPoint; } public PointF GetCenterPoint() { return m_StageEdgeGDIObjects[0].GetCenterPoint(); //声明中心点变量 } public void DrawSampleStage() { StageDrawingData SData = GetOTSSampleStageData(); try { if (SData.StageDomain.X == 0 && SData.StageDomain.Y == 0) { return; } string stageName = SData.sStageName; //获取样品台 ShapeType StageShape = SData.bStageShape; PointF stageLeftTop = new PointF(SData.StageDomain.Left, SData.StageDomain.Top); PointF stageRightBottom = new PointF(SData.StageDomain.Right, SData.StageDomain.Bottom); m_SEMStageData.ConvertSEMToOTSCoord(stageLeftTop, ref StageLTPointToSEMLocation); m_SEMStageData.ConvertSEMToOTSCoord(stageRightBottom, ref StageRBPointToSEMLocation); RectangleF Bourary; Bourary = GetCtrlCoordRectF(stageLeftTop, stageRightBottom); CRectangleGDIObject CreateBourary; //0:圆角矩形 1:圆形 2:文字 3:矩形 if (SData.bStageShape == (ShapeType.RECTANGLE)) { CreateBourary = new CRectangleGDIObject(Bourary, CreateRectangleType.SampleBackGround_Rectangle); } else { CreateBourary = new CRectangleGDIObject(Bourary, CreateRectangleType.Circle); } CreateBourary.Shape = StageShape; m_StageEdgeGDIObjects.Add(CreateBourary); //绘制后的样品台中心位置 PointF m_Region = GetCenterPoint(); //获取绘制后的样品台中心位置 if (m_RegionStartCenterPoint.X != m_Region.X || m_RegionStartCenterPoint.Y != m_Region.Y) { m_RegionStartCenterPoint = m_Region; } //获取样品孔 System.Collections.Generic.List ChloeClrList = SData.sSHoleInfoList; if (ChloeClrList.Count > 0) { for (int i = 0; i < ChloeClrList.Count; i++) { //获取微米信息 var xHole = new PointF(ChloeClrList[i].HoleRect.Left, ChloeClrList[i].HoleRect.Top); var yHole = new PointF(ChloeClrList[i].HoleRect.Right, ChloeClrList[i].HoleRect.Bottom); //将微米转换为像素 float widthHole = Math.Abs(yHole.X - xHole.X); float heightHole = Math.Abs(yHole.Y - xHole.Y); var RecF = GetCtrlCoordRectF(xHole, yHole); //获取矩形 CRectangleGDIObject CreateHole = null; //0:圆角矩形 1:圆形 2:文字 3:矩形 if (ChloeClrList[i].iSHoleShape == (int)CreateRectangleType.SampleBackGround_Rectangle) { CreateHole = new CRectangleGDIObject(RecF, CreateRectangleType.Rectangle); } else { CreateHole = new CRectangleGDIObject(RecF, CreateRectangleType.Circle); } CreateHole.NameOrHoleName= ChloeClrList[i].sSHoleName; m_SampleHoleGDIObjects.Add(CreateHole); //添加文字 CRectangleGDIObject CreateContent = GetCtrlCoordRect(xHole, yHole, CreateRectangleType.Rectangle, "", ""); //类型 文字:2 CreateContent.CreateType = CreateRectangleType.Text; CreateContent.SetInitRegionF(CreateContent.GetZoomedRegionF()); CreateContent.strContent = ChloeClrList[i].sSHoleName; CreateContent.NameOrHoleName = ChloeClrList[i].sSHoleName; m_ContentGDIObjects.Add(CreateContent); } } //获取标样 ShapeType StageShapes = SData.bStageShape; stageLeftTop = new PointF(SData.SampleRect.Left, SData.SampleRect.Top); stageRightBottom = new PointF(SData.SampleRect.Right, SData.SampleRect.Bottom); //获取矩形 CRectangleGDIObject CreateSTD; if (StageShapes == (int)CreateRectangleType.Circle) { CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, CreateRectangleType.SpecimenCircle, "", ""); } else { CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, CreateRectangleType.SpecimenRectangle, "", ""); } m_SpecimenGDIObjects.Add(CreateSTD); return; } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error( ex.ToString() ); } } public CRectangleGDIObject GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, CreateRectangleType type, string content, string name) { try { //将微米信息 转换为 像素 PointF xPoints = new Point(); PointF yPoints = new Point(); xPoints.X =(float) MicronConvertToPixel(OTSLeftTop.X ); xPoints.Y = (float)MicronConvertToPixel( OTSLeftTop.Y ); yPoints.X = (float)MicronConvertToPixel( OTSRightBottom.X ); yPoints.Y = (float)MicronConvertToPixel(OTSRightBottom.Y); //计算位置 xPoints = (PointF)CalculateLocationF(xPoints); yPoints = CalculateLocationF(yPoints); //获取图形四个点 float realStartX = Math.Min(xPoints.X, yPoints.X); float realStartY = Math.Min(xPoints.Y, yPoints.Y); float realEndX = Math.Max(xPoints.X, yPoints.X); float realEndY = Math.Max(xPoints.Y, yPoints.Y); //创建矩形 并返回类型对象 return new CRectangleGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name); } catch (Exception) { return new CRectangleGDIObject(new Rectangle(), 0, ""); } } public RectangleF GetCtrlCoordRectF(PointF OTSLeftTop, PointF OTSRightBottom) { try { //将微米信息 转换为 像素 PointF leftTop = new PointF(); PointF rightBottom = new PointF(); leftTop.X = (float)MicronConvertToPixel( OTSLeftTop.X); leftTop.Y = (float)MicronConvertToPixel( OTSLeftTop.Y); rightBottom.X = (float)MicronConvertToPixel( OTSRightBottom.X); rightBottom.Y = (float)MicronConvertToPixel(OTSRightBottom.Y); //计算位置 leftTop = CalculateLocationF(leftTop ); rightBottom = CalculateLocationF(rightBottom); //获取图形四个点 float realStartX = Math.Min(leftTop.X, rightBottom.X); float realStartY = Math.Min(leftTop.Y, rightBottom.Y); float realEndX = Math.Max(leftTop.X, rightBottom.X); float realEndY = Math.Max(leftTop.Y, rightBottom.Y); //创建矩形 并返回类型对象 return new RectangleF(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY)); } catch (Exception) { return new RectangleF(); } } private PointF CalculateLocationF(PointF point) { //获取窗体的高度与宽度 float ctrlWidth = m_totalCtrlWidth; float ctrlHeight = m_totalCtrlHeight; //获取屏幕中心点 PointF pointXY = new PointF(); PointF screenPoint = new PointF(ctrlWidth / 2, ctrlHeight / 2); pointXY.X = screenPoint.X + point.X; pointXY.Y = screenPoint.Y - point.Y;//using minus because the coordinate system defference of OTS system and control system. return pointXY; } public double MicronConvertToPixel(double PointVal) { var v = m_VisualStageEdgeLength; return PointVal / ((double)m_OTSCoordStageEdgeLength / v); } public PointF OTSCoordToCtrlCoord(PointF point) { var x = MicronConvertToPixel(point.X); var y = MicronConvertToPixel(point.Y); return CalculateLocationF(new PointF((float)x, (float)y)); } public PointF CtrlCoordToOTSCoord(PointF point) { var ctrlcenter = m_StageEdgeGDIObjects[0].GetCenterPoint(); var x = PixelConvertToMicron(point.X - ctrlcenter.X); var y = PixelConvertToMicron(-(point.Y - ctrlcenter.Y)); return new PointF(x, y); } public RectangleF GetOTSCoordRegionF(PointF ctrlLeftTop, PointF ctrlRightBottom) { try { var ctrlcenter = m_StageEdgeGDIObjects[0].GetCenterPoint(); //将微米信息 转换为 像素 PointF leftTop = new PointF(); PointF rightBottom = new PointF(); leftTop.X = (float)PixelConvertToMicron(ctrlLeftTop.X-ctrlcenter.X); leftTop.Y = (float)PixelConvertToMicron((ctrlLeftTop.Y-ctrlcenter.Y)); rightBottom.X = (float)PixelConvertToMicron(ctrlRightBottom.X-ctrlcenter.X); rightBottom.Y = (float)PixelConvertToMicron((ctrlRightBottom.Y-ctrlcenter.Y)); //获取OTS图形四个点 float realStartX = Math.Min(leftTop.X, rightBottom.X); float realStartY = Math.Min(leftTop.Y, rightBottom.Y); float realEndX = Math.Max(leftTop.X, rightBottom.X); float realEndY = Math.Max(leftTop.Y, rightBottom.Y); //创建矩形 并返回类型对象 return new RectangleF(realStartX, -realEndY, realEndX - realStartX, realEndY - realStartY); } catch (Exception) { return new RectangleF(); } } public float PixelConvertToMicron(float Pixel) { return (float)(Pixel * ((double)m_OTSCoordStageEdgeLength / m_VisualStageEdgeLength)); } internal void DecreaseSampleCount(string sampleName) { foreach (var hole in m_SampleHoleGDIObjects) { if (hole.SampleName == sampleName) { hole.SampleCount -= 1; } } } public CRectangleGDIObject GetSampleHoleGdiobjByName(string holeName) { foreach (var hole in m_SampleHoleGDIObjects) { if (hole.NameOrHoleName == holeName) { return hole; } } return null; } public bool GetVisualSampleArea(SampleMeasurePara SMeasurePara, out CVisualSampleArea a_visualSample) { //设置样品选择状态为非工作样品 string SampleHoleName = SMeasurePara.sampleHoleName; var item = GetSampleHoleGdiobjByName(SampleHoleName); if (item != null) { //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); Color selColor = ColorTranslator.FromHtml(ColorStr); //累加样品数量 item.SampleCount += 1; item.IsWorkSample = true; CRectangleGDIObject sampleGDIObject = item.Duplicate(CreateRectangleType.SelectSample); sampleGDIObject.sampleName = SMeasurePara.sSampleName; sampleGDIObject.SelColor = selColor; ; //add the default measure area from config file. CRectangleGDIObject newMeasureGDIObject; PointF xHole = new PointF(SMeasurePara.MeasureRect.Left, SMeasurePara.MeasureRect.Top); PointF yHole = new PointF(SMeasurePara.MeasureRect.Right, SMeasurePara.MeasureRect.Bottom); RectangleF SampleRectangleF = GetCtrlCoordRectF(xHole, yHole); GetMeasureGdiObject(sampleGDIObject,SMeasurePara.iShape, SampleRectangleF, out newMeasureGDIObject); var newsample = new CVisualSampleArea(); newsample.SetSampleGDIObject(sampleGDIObject); newsample.SetMeasureGDIObject(newMeasureGDIObject); a_visualSample = newsample; return true; } a_visualSample = null; return false; } #region 根据样品位置 获取测量区域位置 public SampleMeasurePara GetSampleMeasurePara(CRectangleGDIObject MeasureItem) { var item = MeasureItem; SampleMeasurePara sampleMeasurePara = new SampleMeasurePara(); var region = this.GetOTSCoordRegionF(item.GetOrigionalDrawRegionF().Location, new PointF(item.GetOrigionalDrawRegionF().Right, item.GetOrigionalDrawRegionF().Bottom)); sampleMeasurePara.MeasureRect = region; //设置样品孔名称 sampleMeasurePara.sampleHoleName = item.NameOrHoleName; //设置样品名称 sampleMeasurePara.sSampleName = item.SampleName; //设置测量区域形状 sampleMeasurePara.iShape = item.Shape; sampleMeasurePara.DrawPolygonPointList = ConvertPolygonPointToOTSPoint(item.GetOriginalPolygonPointFList()); sampleMeasurePara.sSampleName = MeasureItem.SampleName ; sampleMeasurePara.sampleHoleName =MeasureItem.NameOrHoleName; return sampleMeasurePara; } public List ConvertPolygonPointToOTSPoint(List polygonPointList) { List OTSPoint = new List(); if (polygonPointList != null) { foreach (var item in polygonPointList) { OTSPoint.Add(CtrlCoordToOTSCoord(item)); } } return OTSPoint; } public List PointFConvertPoint(List Points) { List PointFs = new List(); if (Points != null) { foreach (var itemPoint in Points) { PointFs.Add(new Point((int)itemPoint.X, (int)itemPoint.Y)); } } return PointFs; } public PointF[] PointConvertPointF(Point[] Points) { PointF[] PointFs = new PointF[Points.Length]; if (Points != null) { for (int i = 0; i < Points.Length; i++) { PointFs[i] = Points[i]; } } return PointFs; } public List PointConvertPointF(List Points) { List PointFs = new List(); if (Points != null) { foreach (var itemPoint in Points) { PointFs.Add(itemPoint); } } return PointFs; } #endregion #region 添加测量 /// /// 添加测量 /// /// 是否选择样品 0:未选择 1:选择 /// 样品名称 /// 是否成功 public bool GetMeasureGdiObject( CRectangleGDIObject sampleGDIObject,ShapeType newShape, RectangleF newRegion, out CRectangleGDIObject outMeasureRect) { var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea); MeasureRect.SetInitRegionF(newRegion); MeasureRect.SelColor = Color.Red; MeasureRect.Shape = newShape; outMeasureRect = MeasureRect; return true; } public bool GetMeasureGdiObjectFromSampleGdi(CRectangleGDIObject sampleGDIObject, out CRectangleGDIObject outMeasureRect) { //添加测量区域 CreateRectangleType shape = sampleGDIObject.CreateType; var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea); //MeasureRect.GPath = MeasurePath; MeasureRect.SelColor = Color.Red; outMeasureRect = MeasureRect; return true; } #endregion public bool CheckMeasureAreaIsBeyondStageArea(RectangleF RMeasureArea) { otsdataconst.DOMAIN_SHAPE iShape = (otsdataconst.DOMAIN_SHAPE)m_StageEdgeGDIObjects[0].CreateType; RectangleF pStageArea = m_StageEdgeGDIObjects[0].GetZoomedRegion; Rectangle pMeasureArea = new Rectangle((int)RMeasureArea.Left, (int)RMeasureArea.Top, (int)RMeasureArea.Width, (int)RMeasureArea.Height); CDomain a_DomainMeasureArea = new CDomain((otsdataconst.DOMAIN_SHAPE)iShape, pMeasureArea); CDomain a_DomainStageArea = new CDomain((otsdataconst.DOMAIN_SHAPE)iShape, pStageArea); return a_DomainStageArea.DomainInDomain(a_DomainMeasureArea); } public void ShowSemCoordvAL(Point mPoint, OTSIncAMeasureAppForm m_MeasureAppForm) { //鼠标在样品台中移动获取坐标 Point mousePoint = GetMouseOTSLocation(mPoint); PointF SEMPoint = new Point(); m_SEMStageData.ConvertOTSToSEMCoord(mousePoint, ref SEMPoint); //将微米转换为毫米 float mousePointX = Convert.ToSingle((SEMPoint.X / 1000).ToString("F2")); float mousePointY = Convert.ToSingle((SEMPoint.Y / 1000).ToString("F2")); //将样品台坐标转换为Sem 坐标 //编辑显示内容 string STSemCoordinate = "X:" + mousePointX + "|Y:" + mousePointY + ""; //显示XY轴 m_MeasureAppForm.ShowSemCoordvAL(STSemCoordinate); } public Point GetMouseOTSLocation(Point mousePoint) { var offsetX = mousePoint.X - this.GetDisplayRefPoint().X; var offsetY = mousePoint.Y - this.GetDisplayRefPoint().Y; PointF ctrlPoint = new PointF(offsetX / this.GetZoomNum(), offsetY / this.GetZoomNum()); PointF otsPoint = this.CtrlCoordToOTSCoord(ctrlPoint); Point OTSMousePosition = new Point(Convert.ToInt32(Math.Round(otsPoint.X, 0)), Convert.ToInt32(Math.Round(otsPoint.Y, 0))); return OTSMousePosition; } public bool IfMouseInSampleHole(Point mousePoint,out CRectangleGDIObject gdiItem) { foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects) { if (item.IfZoomContains(mousePoint)) { gdiItem = item; return true; ; } } gdiItem = null; return false; } public bool IfMouseInStage(Point mousePoint,out CRectangleGDIObject gdiobj) { foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects) { if (item.IfZoomContains(mousePoint)) { gdiobj = item; return true; } } gdiobj = null; return false; } public bool IfMouseInStage(Point mousePoint ) { foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects) { if (item.IfZoomContains(mousePoint)) { return true; } } return false; } public void OnMouseMove( MouseEventArgs e) { foreach (CRectangleGDIObject item in m_ContentGDIObjects) { item.IsDragging = true; item.DraggingPoint = e.Location; } foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects) { item.IsDragging = true; item.DraggingPoint = e.Location; } foreach (CRectangleGDIObject item in m_SpecimenGDIObjects) { item.IsDragging = true; item.DraggingPoint = e.Location; } } public List GetAllGDIObject() { var allobj = new List(); foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects) { allobj.Add(item); } foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects) { allobj.Add(item); } foreach (CRectangleGDIObject item in m_SpecimenGDIObjects) { allobj.Add(item); } foreach (CRectangleGDIObject item in m_ContentGDIObjects) { allobj.Add(item); } return allobj; } public List GetAllGDIObjectWithoutHoleNameStr() { var allobj = new List(); foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects) { allobj.Add(item); } foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects) { allobj.Add(item); } foreach (CRectangleGDIObject item in m_SpecimenGDIObjects) { allobj.Add(item); } return allobj; } public PointF GetCenterPoint(RectangleF rect) { //声明 PointF centerPoint = new PointF(); //设置X,Y坐标 centerPoint.X = rect.X + rect.Width / 2; centerPoint.Y = rect.Y + rect.Height / 2; return centerPoint; } public SampleHolePara GetSampleHoleInfo(CRectangleGDIObject item) { SampleHolePara sampleHolePara = new SampleHolePara(); //设置测量区域 sampleHolePara.SampleHoleRect = item.GetZoomedRegion; //设置测量区域位置与尺寸 float left = PixelConvertToMicron(item.GetZoomedRegionF().X); float Top = PixelConvertToMicron(item.GetZoomedRegionF().Y); float Width = PixelConvertToMicron(item.GetZoomedRegionF().Width); float Height = PixelConvertToMicron(item.GetZoomedRegionF().Height); PointF startPoint = new PointF(left, Top); SizeF sampleHoleSize = new SizeF(Width, Height); sampleHolePara.SampleHoleRect = new Rectangle(new Point((int)startPoint.X, (int)startPoint.Y), new Size((int)sampleHoleSize.Width, (int)sampleHoleSize.Height)); //设置样品孔名称 sampleHolePara.sHoleName = item.NameOrHoleName; //设置测量区域形状 sampleHolePara.iShape = item.Shape; return sampleHolePara; } } }