123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- using System;
- using System.Collections.Generic;
- using OTSCLRINTERFACE;
- using System.Drawing;
- using OTSDataType;
- using OTSModelSharp;
- using OTSModelSharp.ServiceCenter;
- using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel;
- namespace OTSMeasureApp
- {
- public class SEMDATAFieldManage
- {
- #region 全部变量声明
-
-
-
- //电镜设置对象
- ISemController cSemfun = null;
- IScanController cScanfun = null;
- //IEDSController cEDSfun = null;
- //主窗体对象
- COTSMeasureParam m_ProjData;
-
- NLog.Logger log ;
- #endregion
- #region 构造方法
-
- public SEMDATAFieldManage(COTSMeasureParam a_DataMgr)
- {
- log = NLog.LogManager.GetCurrentClassLogger();
- //获取主窗体对象
- if (m_ProjData == null)
- {
- m_ProjData = a_DataMgr;
- }
- }
- /// <summary>
- /// 初始化其他参数
- /// </summary>
- public bool InitAndConnection()
- {
- try
- {
- //控制类对象初始化
- if (cSemfun == null)
- {
- cSemfun = SemController.GetSEMController();
- }
- if (cScanfun == null)
- {
- cScanfun = ScanController.GetScanController();
- }
- //if (cEDSfun == null)
- //{
- // cEDSfun = EDSController.GetEDSController();
- //}
-
- return cSemfun.Connect();
- }
- catch (Exception ex)
- {
- log.Error(ex.ToString() );
- return false;
- }
- }
- #endregion
-
- #region 获取放大倍数
- private double GetGMagnification()
- {
- try
- {
- double a_dMagnification = 0;
- //获取放大倍数
- bool result = cSemfun.GetMagnification(ref a_dMagnification);
- if (result)
- {
- //赋值 显示
- return a_dMagnification;
- }
- else
- {
- //配置结果提示
- return 0;
- }
- }
- catch (Exception)
- {
- return 0;
- }
- }
- #endregion
- #region 获取工作距离
- private double GetSemWorkingDistance()
- {
- try
- {
- double a_WorkingDistance = 0;
- //获取工作距离
- bool result = cSemfun.GetWorkingDistance(ref a_WorkingDistance);
- if (result)
- {
- //赋值 显示
- return a_WorkingDistance;
- }
- else
- {
- //配置结果提示
- return 0;
- }
- }
- catch (Exception ex)
- {
- log.Error(ex.ToString() );
- return 0;
- }
- }
- #endregion
- #region 设置放大倍数
- public bool SetGMagnification(double a_dMagnification)
- {
- try
- {
- //获取放大倍数
- bool result = cSemfun.SetMagnification(a_dMagnification);
- return result;
- }
- catch (Exception ex)
- {
- log.Error( ex.ToString() );
- return false;
- }
- }
- #endregion
- #region 设置工作距离
- public bool SetSemWorkingDistance(double a_WorkingDistance)
- {
- try
- {
- bool result = cSemfun.SetWorkingDistance(a_WorkingDistance);
- return result;
- }
- catch (Exception ex)
- {
- log.Error(ex.ToString() );
- return false;
- }
- }
- #endregion
-
- #region 获取电镜参数 放大倍数与工作距离
- public List<double> GetSEMMagAndWDParameter()
- {
- List<double> semParameter = new List<double>();
- //放大倍数
- double magnification = GetGMagnification();
- //工作距离
- double semWorkingDistance = GetSemWorkingDistance();
- //添加 放大倍数、工作距离
- semParameter.Add(magnification);
- semParameter.Add(semWorkingDistance);
- return semParameter;
- }
- #endregion
-
- #region 驱动SEM到当前位置
- public bool SetSEMCurrentLocation( Point mousePoint, CVisualStage stage)
- {
- try
- {
-
- if (!stage.IfMouseInStage(mousePoint))
- {
- //获取在范围中的样品
- return false;
-
- }
-
- //判断是否鼠标在样品台范围中
- Point OTSLocation = new Point();
-
- //鼠标在样品台中移动获取坐标
- OTSLocation = stage.GetMouseOTSLocation(mousePoint);
-
- PointF SEMPoint =m_ProjData.ConvertOTSToSemCoord(OTSLocation);
-
- bool result = cSemfun.MoveSEMToPoint(SEMPoint.X, SEMPoint.Y);
-
- return result;
-
- }
- catch (Exception ex)
- {
- log.Error(ex.ToString());
- return false;
- }
- }
- #endregion
- #region 驱动SEM到中心位置
- public bool DriveSEMToLocation(Point mousePoint,CVisualStage stage, List<CRectangleGDIObject> m_MeasureFieldGDIObjects)
- {
- try
- {
-
-
- if (!stage.IfMouseInStage(mousePoint))
- {
- return false;
- }
-
- //判断是否鼠标在样品台范围中
- Point OTSLocation = new Point();
-
- //鼠标在样品台中移动获取坐标
- OTSLocation = stage.GetMouseOTSLocation(mousePoint);
- PointF SEMPoint = m_ProjData.ConvertOTSToSemCoord(OTSLocation);
- //循环single中所有对象 进行位置匹配
- for (int i = 0; i < m_MeasureFieldGDIObjects.Count; i++)
- {
- if (m_MeasureFieldGDIObjects[i].GetZoomedRegion.Contains(mousePoint))
- {
- //获取帧图左上坐标
- Point LT = new Point((int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Left, (int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Top);
- PointF lTLocation = stage.GetMouseOTSLocation(LT);
- lTLocation = m_ProjData.ConvertOTSToSemCoord(lTLocation);
- //获取帧图右下坐标
- Point RB = new Point((int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Right, (int)m_MeasureFieldGDIObjects[i].GetZoomedRegionF().Bottom);
- PointF rbLocation = stage.GetMouseOTSLocation(RB);
- rbLocation = m_ProjData.ConvertOTSToSemCoord(rbLocation);
- float diffX = Math.Abs(rbLocation.X - lTLocation.X) / 2;
- float diffY = Math.Abs(rbLocation.Y - lTLocation.Y) / 2;
- //移动至帧图中心位置
- float moveCenterX = lTLocation.X - diffX;
- float moveCenterY = lTLocation.Y + diffY;
- bool result = cSemfun.MoveSEMToPoint(moveCenterX, moveCenterY);
- if (result)
- {
- return result;
- }
- }
- }
-
- return false;
- }
- catch (Exception)
- {
- return false;
- }
- }
- #endregion
- #region 获取SEM位置
- public bool GetSemLocation(ref List<double> SemLocation)
- {
- //获取SEM位置 a_dPositionX:X轴 a_dPositionY:Z轴 a_dPositionR:角度
- double a_dPositionX = 0;
- double a_dPositionY = 0;
- double a_dPositionR = 0;
- if (cSemfun != null)
- {
- if (cSemfun.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR))
- {
- SemLocation.Add(a_dPositionX);
- SemLocation.Add(a_dPositionY);
- SemLocation.Add(a_dPositionR);
- return true;
- }
- }
- return false;
- }
- #endregion
- }
- }
|