Browse Source

stage operating code improve.

gsp 3 years ago
parent
commit
f1eeb5b858

+ 5 - 6
OTSIncAMeasureApp/0-OTSModel/Measure/3-MeasureFlow/CMeasure.cs

@@ -160,8 +160,7 @@ namespace OTSModelSharp
         }
         void ThreadOver()
         {
-            
-
+          
 
             DateTime timeEnd = m_ThreadStatus.GetEndTime();
 
@@ -181,7 +180,6 @@ namespace OTSModelSharp
         {
 
 
-
             DateTime timeEnd = m_ThreadStatus.GetEndTime();
 
             ST_MSTMsg MsrMsg = new ST_MSTMsg();
@@ -494,10 +492,10 @@ namespace OTSModelSharp
 
 
             COTSSample pSampleHole = CreateHoleSample(a_pMeasureArea);
-
+            var sample = m_pProjData.GetWorkingSample();
 
             // create a sample measure object for the sample
-            CSmplMeasure pSmplMeasure = new CSmplMeasureCleanliness(m_strWorkingFolder,pSampleHole);
+            CSmplMeasure pSmplMeasure = new CSmplMeasure(m_strWorkingFolder, sample);
 
           
             // set measure thread
@@ -505,7 +503,8 @@ namespace OTSModelSharp
 
             // update thread measure status class, let the main thread know that this sample measurement starts
             // set working folder string
-            pSmplMeasure.SetSample(pSampleHole);
+            pSmplMeasure.SetSample(sample);
+            pSmplMeasure.SetHolePreviewSample(pSampleHole);
             pSmplMeasure.SetWorkingFolder(m_strWorkingFolder);
 
             // do measure

+ 35 - 21
OTSIncAMeasureApp/0-OTSModel/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -29,6 +29,7 @@ namespace OTSModelSharp
         protected System.Threading.Thread m_thread_ptr;
    
         protected COTSSample m_Sample;
+        protected COTSSample m_HolePreviewSample;
         protected CMeasure m_pMsrThread;
         string m_strWorkingFolder;
 
@@ -81,6 +82,15 @@ namespace OTSModelSharp
         }
         public COTSSample GetSample() { return m_Sample; }
 
+
+        public void SetHolePreviewSample(COTSSample a_pSample)
+        {
+
+            m_HolePreviewSample = a_pSample;
+           
+        }
+        public COTSSample GetHolePreviewSample() { return m_HolePreviewSample; }
+
         public void SetMsrThread(CMeasure mt)
         {
             m_pMsrThread = mt;
@@ -88,9 +98,9 @@ namespace OTSModelSharp
            
         }
 
-        bool SetSEMDataMrs()
+        bool SetSEMDataMrs(COTSSample sample)
         {
-            var pSEMDataMsr = m_Sample.GetSEMDataMsr();
+            var pSEMDataMsr = sample.GetSEMDataMsr();
           
             double dMag = pSEMDataMsr.GetMagnification();
             double dWorkDis = pSEMDataMsr.GetWorkingDistance();
@@ -236,7 +246,7 @@ namespace OTSModelSharp
 
             return true;
         }
-        bool SetHoleBSEParam()
+        bool SetHoleBSEParam(COTSSample sample)
         {
 
 
@@ -248,7 +258,7 @@ namespace OTSModelSharp
 
 
             // scan parameters
-            var pMsrParam = m_Sample.GetMsrParams();
+            var pMsrParam = sample.GetMsrParams();
             var pImgScanParam = pMsrParam.GetImageScanParam();
 
             // get image size
@@ -310,14 +320,14 @@ namespace OTSModelSharp
 
             m_strWorkingFolder = a_strWorkingFolder + m_Sample.GetName() + "\\";
         }
-        bool CalculateUnMeasuredFieldsCenters(out List<System.Drawing.Point> a_allpieldcenter,out List<System.Drawing.Point> a_listUnMsrFieldCenter)
+        bool CalculateUnMeasuredFieldsCenters(COTSSample sample,out List<System.Drawing.Point> a_allpieldcenter,out List<System.Drawing.Point> a_listUnMsrFieldCenter)
         {       
 
             // sample measure parameters
-            CSampleParam pMsrParam = m_Sample.GetMsrParams();
+            CSampleParam pMsrParam = sample.GetMsrParams();
             COTSImgScanPrm  poImageScanParam = pMsrParam.GetImageScanParam();
-            CSEMDataMsr poSEMDataMsr = m_Sample.GetSEMDataMsr();
-            CMsrSampleStatus pStatus = m_Sample.GetMsrStatus();
+            CSEMDataMsr poSEMDataMsr = sample.GetSEMDataMsr();
+            CMsrSampleStatus pStatus = sample.GetMsrStatus();
 
             // measured field centers list
             List<System.Drawing.Point> listCompletedCenter = pStatus.GetCompletedFieldsCenter();
@@ -326,7 +336,7 @@ namespace OTSModelSharp
             CFieldPositionMgr pFieldMgr = new CFieldPositionMgr();
 
             // init field centers list manager
-            if (!pFieldMgr.Init(m_Sample.GetMsrArea(), poImageScanParam, poSEMDataMsr, listCompletedCenter))
+            if (!pFieldMgr.Init(sample.GetMsrArea(), poImageScanParam, poSEMDataMsr, listCompletedCenter))
             {
                 log.Error("CalculateFieldsCenters: failed to init field centres list manager.");
                 a_listUnMsrFieldCenter = new List<System.Drawing.Point>();
@@ -554,7 +564,11 @@ namespace OTSModelSharp
                 sm = s;
             }
 
-            public SEMStateObject SemState { get => semState; set => semState = value; }
+            public SEMStateObject SemState 
+            { 
+                get => semState; 
+                set => semState = value; 
+            }
 
             public void Dispose()
             {
@@ -591,7 +605,7 @@ namespace OTSModelSharp
 
                 log.Info(m_Sample.GetName() + " Measurement started!");
                 // get SEM controller to set magnification and working distance
-                if (!SetSEMDataMrs())
+                if (!SetSEMDataMrs(m_Sample))
                 {
                     log.Error("DoMeasure: fail to set SEM data.");
                     pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);                   
@@ -649,7 +663,7 @@ namespace OTSModelSharp
                 List<System.Drawing.Point> umMeasuredlistFieldCenter;
                 List<System.Drawing.Point> allFieldCenter;
 
-                if (!CalculateUnMeasuredFieldsCenters(out allFieldCenter, out umMeasuredlistFieldCenter))
+                if (!CalculateUnMeasuredFieldsCenters(m_Sample,out allFieldCenter, out umMeasuredlistFieldCenter))
                 {// failed to calculate field centers
                     log.Error("DoMeasure: failed to calculate field centers.");
                     pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
@@ -1154,11 +1168,8 @@ namespace OTSModelSharp
 
                 autoReset.SemState = semstate;
                 //-------------------------------------
-
-
-
                 // let the main thread to know that this sample measurement starts
-                CMsrSampleStatus pStatus = m_Sample.GetMsrStatus();
+                CMsrSampleStatus pStatus = m_HolePreviewSample.GetMsrStatus();
                 pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.INPROCESS);
 
                 // set current time to current time
@@ -1172,7 +1183,7 @@ namespace OTSModelSharp
 
 
                 // get SEM controller to set magnification and working distance
-                if (!SetSEMDataMrs())
+                if (!SetSEMDataMrs(m_HolePreviewSample))
                 {
                     log.Error("DoHolePreview: fail to set SEM data.");
                     pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
@@ -1184,7 +1195,7 @@ namespace OTSModelSharp
 
      
                 // set the BSE scan param
-                if (!SetHoleBSEParam())
+                if (!SetHoleBSEParam(m_HolePreviewSample))
                 {
                     log.Error("DoMeasure: fail to set BSE param.");
                     pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
@@ -1201,7 +1212,7 @@ namespace OTSModelSharp
                 List<System.Drawing.Point> listFieldCenter;
                 List<System.Drawing.Point> alllistFieldCenter ;
                 // listFieldCenter.clear();
-                if (!CalculateUnMeasuredFieldsCenters(out alllistFieldCenter,out listFieldCenter))
+                if (!CalculateUnMeasuredFieldsCenters(m_HolePreviewSample, out alllistFieldCenter,out listFieldCenter))
                 {// failed to calculate field centers
                     log.Error("DoHolePreview: failed to calculate field centers.");
                     pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
@@ -1554,8 +1565,11 @@ namespace OTSModelSharp
             {
 
                 Point fldOtsPos = new Point(curFldData.OTSPos.X, curFldData.OTSPos.Y);
-                PointF semPos = new Point();
-                pCSEMStageData.ConvertOTSToSEMCoord(fldOtsPos, ref semPos);
+                PointF semP = new PointF(); ;
+                Point semPos = new Point();
+                pCSEMStageData.ConvertOTSToSEMCoord(fldOtsPos, ref semP);
+                semPos.X = (int)semP.X;
+                semPos.Y = (int)semP.Y;
                 p.SetAbsolutPos(semPos);
             }
 

+ 3 - 3
OTSIncAMeasureApp/0-OTSModel/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -559,7 +559,7 @@ namespace OTSModelSharp
         public COTSSample GetSampleByName(String a_strSampleName)
         {
 
-            bool IsChanged = false;
+            bool Isfind = false;
             COTSSample pOTSSample = null;
             for (int itr = 0; itr < m_listSamples.Count; itr++)
             {
@@ -567,11 +567,11 @@ namespace OTSModelSharp
                 {
                     pOTSSample = m_listSamples[itr];
                     //m_listSamples.RemoveAt(itr);
-                    IsChanged = true;
+                    Isfind = true;
                 }
             }
 
-            if (IsChanged)
+            if (Isfind)
             {
                 return pOTSSample;
             }

+ 13 - 0
OTSIncAMeasureApp/0-OTSModel/OTSDataType/CDomain.cs

@@ -194,6 +194,19 @@ namespace OTSDataType
                     nHeight = Convert.ToInt32(rectDomain[3]);
                     m_rectangle = new Rectangle(0, 0, nWidth, nHeight);
                     OffsetDomain(new PointF(nCentreX - (nWidth / 2), nCentreY - (nHeight / 2)));
+                }
+                else 
+                {
+                    int left = Convert.ToInt32(rectDomain[0]);
+                    int top = Convert.ToInt32(rectDomain[1]);
+                  int  right = Convert.ToInt32(rectDomain[2]);
+                   int  bottom = Convert.ToInt32(rectDomain[3]);
+                    nWidth = right - left;
+                    nHeight = bottom - top;
+                    m_rectangle = new Rectangle(0, 0, nWidth, nHeight);
+                    OffsetDomain(new PointF(nCentreX - (nWidth / 2), nCentreY - (nHeight / 2)));
+               
+
                 }
                 if (m_PolygonPoint == null)
                 {

+ 5 - 6
OTSIncAMeasureApp/0-OTSModel/OTSDataType/otsdataconst.cs

@@ -171,17 +171,16 @@ namespace OTSDataType
         {
            
             ROUND = 0,
-            //ROUND = 0,
+          
             RECTANGLE = 1,
+
+            POLYGON=15
            
         }
         public enum OTS_MEASURE_FIELD_STOP_MODE
         {
-           
-            //MIN = 0,
-            //AreaPercentage = 0,
-            //Particles = 1,
-            //ParticlesPercentage = 2,
+          
+   
             ParticlesPercentage = 0,
             Particles = 1,
 

+ 34 - 33
OTSIncAMeasureApp/1-OTSMeasure/CMeasureThreadWrapper.cs

@@ -17,10 +17,12 @@ namespace OTSMeasureApp
         OTSIncAMeasureAppForm m_MeasureApp = null;
         OTSMeasureDisplayResult m_OTSMeasureResult = null;
         //测量线程类
-        public CMeasure m_MsrThread = null;
+        public CMeasure m_measure = null;
 
         //线程执行类型 1:测量 2:获取样品孔图片
         public static MSR_THREAD_RunSTATUS DoRunType = (MSR_THREAD_RunSTATUS)1;
+        private int holeIdForPreview;
+        //private CDomain domainForHolePreview;
   
         NLog.Logger log ;
         #endregion
@@ -42,14 +44,14 @@ namespace OTSMeasureApp
            
             m_OTSMeasureResult = new OTSMeasureDisplayResult(m_MeasureApp,m_bgWorker);
 
-            m_MsrThread = new CMeasure();
-            m_MsrThread.ProgressEvent += M_MsrThread_ProgressEvent;
+            m_measure = new CMeasure();
+            m_measure.ProgressEvent += M_MsrThread_ProgressEvent;
          
 
         }
         public bool IsHavingNotCompleteSamples()
         {
-            foreach(var s in m_MsrThread.GetListMeasurableSamples())
+            foreach(var s in m_measure.GetListMeasurableSamples())
             {
                 if (s.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
                 {
@@ -77,13 +79,12 @@ namespace OTSMeasureApp
         /// </summary>
         /// <param name="HoleID">样品孔编号的序号</param>
         /// <param name="DomainMessure">测量区域属性对象</param>
-        //public void SetHoleImagePreview(int HoleID)
-        //{
-        //    //样品孔编号的序号
-        //    m_HoleID = HoleID;
-        //    //测量区域属性对象
-        //    //c_DomainMessure = DomainMessure;
-        //}
+        public void SetHoleImagePreview(int HoleID)
+        {
+            //样品孔编号的序号
+            holeIdForPreview = HoleID;
+           
+        }
         #endregion
         #region 启动测量线程
         public void StartBGWorkThread()
@@ -108,7 +109,7 @@ namespace OTSMeasureApp
         }
         public bool BgWorkIsPaused()
         {
-            if (m_MsrThread.GetMsrThreadStatus().GetStatus() == OTS_MSR_THREAD_STATUS.PAUSED)
+            if (m_measure.GetMsrThreadStatus().GetStatus() == OTS_MSR_THREAD_STATUS.PAUSED)
             {
                 return true;
             }
@@ -154,8 +155,8 @@ namespace OTSMeasureApp
             {
                 InitMeasureThread(m_MeasureApp.m_ProjData);
 
-                m_MsrThread.SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS);
-                m_MsrThread.DoMeasure();
+                m_measure.SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS);
+                m_measure.DoMeasure();
               
             }
             else if (DoRunType == MSR_THREAD_RunSTATUS.RUNSampleHoleImage)
@@ -163,7 +164,7 @@ namespace OTSMeasureApp
                 InitMeasureThread(m_MeasureApp.m_ProjData);
 
                 SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS);
-                DoHolePreview();
+                DoHolePreview( );
             }
         }
 
@@ -172,7 +173,7 @@ namespace OTSMeasureApp
         {
           
                 m_ProjData = a_ProjData;
-                m_MsrThread.Init(m_ProjData);
+                m_measure.Init(m_ProjData);
               
           
 
@@ -275,7 +276,7 @@ namespace OTSMeasureApp
                     }
                     else if (MSTMsg.STMSampleRetData.iRetDataType == OTSModelSharp.MSAMPLE_RET.FIELD_DATA)
                     {
-                        GetFiledData(MSTMsg);
+                        UpdateMeasureState(MSTMsg);
                     }
 
                     else if (MSTMsg.STMSampleRetData.iRetDataType == OTSModelSharp.MSAMPLE_RET.START_MSR_FIELD)
@@ -343,7 +344,7 @@ namespace OTSMeasureApp
             m_OTSMeasureResult.RunMeasureState(SMsrData);
         }
 
-        private void GetFiledData(ST_MSTMsg SMsrData)
+        private void UpdateMeasureState(ST_MSTMsg SMsrData)
         {
 
             this.GetSMsrUsedTime(ref SMsrData.STMSampleRetData.SFieldData.TUsedTime);
@@ -391,7 +392,7 @@ namespace OTSMeasureApp
         public void InitMeasureSample()
         {
 
-            m_MsrThread.Init(m_ProjData);
+            m_measure.Init(m_ProjData);
           
 
           
@@ -399,15 +400,15 @@ namespace OTSMeasureApp
         }
         public void InitHolePreview()
         {
-            m_MsrThread.Init(m_ProjData);
+            m_measure.Init(m_ProjData);
           
-            m_MsrThread.ProgressEvent += M_MsrThread_ProgressEvent;
+            m_measure.ProgressEvent += M_MsrThread_ProgressEvent;
            
             return ;
         }
         public void DoHolePreview()
         {
-            m_MsrThread.DoHolePreview();
+            m_measure.DoHolePreview();
         }
         // 开始样品测量
        
@@ -415,7 +416,7 @@ namespace OTSMeasureApp
         public void SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS ThreadStatus)
         {
             //设置测量线程状态
-            m_MsrThread.SetMsrLoopStatus(ThreadStatus);
+            m_measure.SetMsrLoopStatus(ThreadStatus);
         }
 
 
@@ -423,11 +424,11 @@ namespace OTSMeasureApp
     
         public bool ConnectSEM()
         {
-           return m_MsrThread.GetSEMController().Connect();
+           return m_measure.GetSEMController().Connect();
         }
         public void DisconnectSEM()
         {
-            m_MsrThread.GetSEMController().DisConnect();
+            m_measure.GetSEMController().DisConnect();
         }
         public void StopXrayAcquisition()
         {
@@ -436,11 +437,11 @@ namespace OTSMeasureApp
             //{
             //    hw.StopXrayAcquisition();
             //}
-            m_MsrThread.GetSEMController().StopXrayAcquisition();
+            m_measure.GetSEMController().StopXrayAcquisition();
         }
         public bool IsSEMConnected()
         {
-            return m_MsrThread.GetSEMController().IsConnected();
+            return m_measure.GetSEMController().IsConnected();
         }
         public bool GetMsrRetData(ref SMSR_COMPLETE_DATA MsrCompleteData)
         {
@@ -456,20 +457,20 @@ namespace OTSMeasureApp
 
 
                 DateTime DTime = new DateTime();
-                if (m_MsrThread.GetMsrThreadStatus() == null)
+                if (m_measure.GetMsrThreadStatus() == null)
                 {
                     return false;
                 }
-                if (m_MsrThread.GetMsrThreadStatus().GetStartTime() == null)
+                if (m_measure.GetMsrThreadStatus().GetStartTime() == null)
                 {
                     return false;
                 }
-                DTime = (DateTime)m_MsrThread.GetMsrThreadStatus().GetStartTime();
+                DTime = (DateTime)m_measure.GetMsrThreadStatus().GetStartTime();
                 MsrCompleteData.csMsrStartTime = DTime.ToString("yyyy-MM-dd HH:mm:ss");
 
-                MsrCompleteData.MsrUsedTime = (TimeSpan)m_MsrThread.GetMsrThreadStatus().GetUsedTime();
+                MsrCompleteData.MsrUsedTime = (TimeSpan)m_measure.GetMsrThreadStatus().GetUsedTime();
 
-                DTime = (DateTime)m_MsrThread.GetMsrThreadStatus().GetEndTime();
+                DTime = (DateTime)m_measure.GetMsrThreadStatus().GetEndTime();
                 MsrCompleteData.csMsrEndTime = DTime.ToString("yyyy-MM-dd HH:mm:ss");
 
                 MsrCompleteData.iMsrCompleteSampleCount = MeasureCompleteSampleList.Count;
@@ -490,7 +491,7 @@ namespace OTSMeasureApp
             }
             catch (Exception ex)
             {
-             
+                log.Error(ex.Message.ToString());
                 return false;
             }
         }

+ 10 - 8
OTSIncAMeasureApp/1-OTSMeasure/OTSMeasureDisplayResult.cs

@@ -389,12 +389,12 @@ namespace OTSMeasureApp
                              
                                      
                                 }
-                                //判断信息来源  拍摄样品孔图片 或是 测量开始 
-                                if (m_MeasureApp.m_MessageStates == MessageState.ShotBSEPicture)
-                                {
-                                    //根据放大倍数、重新绘制帧图信息
-                                    //m_MeasureApp.m_SamplepaceWindow.DrawMeasureField();
-                                }
+                                ////判断信息来源  拍摄样品孔图片 或是 测量开始 
+                                //if (m_MeasureApp.m_RunType == MSR_THREAD_RunSTATUS.RUNSampleHoleImage)
+                                //{
+                                //    //根据放大倍数、重新绘制帧图信息
+                                //    m_MeasureApp.m_SamplepaceWindow.DrawMeasureField();
+                                //}
                                 break;
                             //测量状态已完成
                             case OTS_MSR_THREAD_STATUS.COMPLETED:
@@ -557,7 +557,8 @@ namespace OTSMeasureApp
                                     }
 
                                     MeasureStateProgressInfo(SMsrData.STMSampleRetData.SFieldData);
-                                    m_MeasureApp.m_SamplepaceWindow. ChangeDoneMeasureState(SMsrData.STMSampleRetData.SFieldData.FieldPos, Color.Green);
+                                    var sam = m_MeasureApp.m_SamplepaceWindow.GetWorkingVisualSample();
+                                    m_MeasureApp.m_SamplepaceWindow. ChangeDoneMeasureState(sam,SMsrData.STMSampleRetData.SFieldData.FieldPos, Color.Green);
                                     m_MeasureApp.m_SamplepaceWindow.Invalidate();
 
                                 }
@@ -566,7 +567,8 @@ namespace OTSMeasureApp
                                 //当前线程执行类型 1:测量
                                 if (runThreadType == MSR_THREAD_RunSTATUS.RUNMEASURE)
                                 {
-                                    m_MeasureApp.m_SamplepaceWindow.ChangeDoneMeasureState(SMsrData.STMSampleRetData.SMsrField.FieldPos, Color.Yellow);
+                                    var sam = m_MeasureApp.m_SamplepaceWindow.GetWorkingVisualSample();
+                                    m_MeasureApp.m_SamplepaceWindow.ChangeDoneMeasureState(sam,SMsrData.STMSampleRetData.SMsrField.FieldPos, Color.Yellow);
                                    
                                     m_MeasureApp.m_SamplepaceWindow.Invalidate();
                                 }

+ 5 - 6
OTSIncAMeasureApp/2-OTSMeasureParamManage/COTSMeasureParam.cs

@@ -522,8 +522,7 @@ namespace OTSMeasureApp
 
             RectangleF MsrRect = new RectangleF(ptLeftTop, ptSize);
             CDomain pMsrArea = new CDomain(nShape, MsrRect);
-
-            // return measurement area
+          
             return pMsrArea;
         }
         //设置工作样品的属性值
@@ -634,10 +633,10 @@ namespace OTSMeasureApp
         }
 
         //移动工作样品到其他样品孔,样品孔名称和测量区域都要改变,重新设置工作样品参数
-        //SampleMeasurePara SMeasurePara:
+   
         public void SetWorkSampleHoleAndMeasureArea(SampleMeasurePara SMeasurePara)
         {
-            //SampleMeasurePara SMPara = new SampleMeasurePara();
+         
             COTSSample WSample = GetResultData().GetWorkingSample();
             if (null == WSample)
             {
@@ -673,7 +672,7 @@ namespace OTSMeasureApp
         //int iShape:  测量区域形状 0: 圆形; 1 :矩形
         public void SetMeasureAreaShape(ShapeType iShape)
         {
-            //  SampleMeasurePara SMPara = new SampleMeasurePara();
+           
             COTSSample WSample = GetResultData().GetWorkingSample();
             if (null == WSample)
             {
@@ -719,7 +718,7 @@ namespace OTSMeasureApp
         }
 
         //获取工作样品锁
-        //ref bool ParamLockFlag : 获取的工作样品参数锁
+   
         public bool GetWSampleParaLock(ref bool ParamLockFlag)
         {
             COTSSample WSample = GetResultData().GetWorkingSample();

+ 3 - 2
OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSPropertyWindow.cs

@@ -269,8 +269,9 @@ namespace OTSMeasureApp
                 if (OTS_SAMPLE_PROP_GRID_ITEMS.IMAGE_GRP_MAX == SampleId || OTS_SAMPLE_PROP_GRID_ITEMS.MAGNIFICATION == SampleId
                     || OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE == SampleId)
                 {
-                    m_MeasureAppForm.m_MessageStates = (int)MessageState.StartMeasure;
-                m_MeasureAppForm.m_SamplepaceWindow.DrawMeasureField();
+                m_MeasureAppForm.m_RunType = MSR_THREAD_RunSTATUS.RUNMEASURE;
+                var sam = m_MeasureAppForm.m_SamplepaceWindow.GetWorkingVisualSample();
+                m_MeasureAppForm.m_SamplepaceWindow.DrawMeasureField(sam);
             }
           
         }

+ 3 - 7
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CVisualSampleArea.cs

@@ -9,15 +9,13 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 {
   public  class CVisualSampleArea
     {
-     
-        private bool isSelect;
+   
      
           CRectangleGDIObject m_SampleGDIObject;//
           CRectangleGDIObject m_MeasureGDIObject;//path
       
         private List<Point> polygonPathPoints;
-        private bool isPolygon;
-
+      
         public CVisualSampleArea()
         {
             m_SampleGDIObject =  new CRectangleGDIObject();
@@ -70,14 +68,12 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             }
         }
 
-        public bool IsPolygon { get => isPolygon; set => isPolygon = value; }
-        public bool IsSelect { get => isSelect; set => isSelect = value; }
 
         public void AddFieldGDIObject(CRectangleGDIObject gdi)
         {
             gdi.SetZoomNumber(m_MeasureGDIObject.GetZoomNumber());
             gdi.SetDisplayRefPoint(m_MeasureGDIObject.GetDisplayRefPoint());
-           
+
             m_MeasureGDIObject.SubItems().Add(gdi);
 
 

+ 182 - 82
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CreateRectangle.cs

@@ -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;
        
 

+ 2 - 234
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceGraphicsPanelFun.cs

@@ -1,67 +1,10 @@
-using OTSCLRINTERFACE;
-using OTSDataType;
-using OTSCommon;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Windows.Forms;
-using OTSModelSharp.ServiceInterface;
-using OTSModelSharp.ServiceCenter;
-using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel;
+
 
 namespace OTSMeasureApp
 {
     public class OTSSamplespaceGraphicsPanelFun
     {
       
-  
-      
-        #region 鼠标移动位置
-        //public static CRectangleGDIObject GetMouseMoveLocation(CRectangleGDIObject item, MouseEventArgs e)
-        //{
-        //    //item.SetScaleRegionF(new RectangleF(
-        //    //                           item.GetZoomedRegion.Left + e.X - item.DraggingPoint.X,
-        //    //                           item.GetZoomedRegion.Top + e.Y - item.DraggingPoint.Y,
-        //    //                           item.GetZoomedRegion.Width,
-        //    //                           item.GetZoomedRegion.Height
-        //    //                           ));
-        //    //PointF p = new PointF(e.X - item.DraggingPoint.X, e.Y - item.DraggingPoint.Y);
-        //    item.Move(e.Location);
-        //    //item.DraggingPoint = e.Location;
-        //    return item;
-        //}
-        #endregion
-  
-
-     
-
-        #region 鼠标方法操作
-       
-        //public static RectangleF MouseWheelFunctionF(RectangleF originalRect,RectangleF curRect,Point mousePoint, float deltaZoomNum)
-        //{
-           
-        //    float curZoom = curRect.Width / originalRect.Width;
-
-        
-
-        //    float X = (curRect.X - mousePoint.X)/curZoom * deltaZoomNum +curRect.X;
-        //    float Y = (curRect.Y - mousePoint.Y)/curZoom * deltaZoomNum + curRect.Y;
-        //    float Width = originalRect.Width * (deltaZoomNum+curZoom);
-        //    float Height = originalRect.Height * (deltaZoomNum + curZoom);
-
-
-        //    return new RectangleF(X, Y, Width, Height);
-        //}
-
-        const int Band = 5;
-       
-      
-        #endregion
-
-     
- 
 
         #region 根据颜色枚举 获取颜色值
         public static string GetColorValue(ColorType ColorEnum)
@@ -89,181 +32,6 @@ namespace OTSMeasureApp
         }
         #endregion
 
-       
-
-  
-        #region 根据list中的帧图信息 获取中心位置
-        //public static PointF GetSingleCenterLocation(List<CRectangleGDIObject> m_SingleGDIObjects)
-        //{
-        //    float MinX = 0f;
-        //    float MinY = 0f;
-        //    float MaxX = 0f;
-        //    float MaxY = 0f;
-        //    float width = 0f;
-        //    float height = 0f;
-        //    //获取最小XY 与最大XY
-        //    MinX = m_SingleGDIObjects[0].GetZoomedRegionF().X;
-        //    MinY = m_SingleGDIObjects[0].GetZoomedRegionF().Y;
-        //    MaxX = m_SingleGDIObjects[0].GetZoomedRegionF().X;
-        //    MaxY = m_SingleGDIObjects[0].GetZoomedRegionF().Y;
-        //    width = m_SingleGDIObjects[0].GetZoomedRegionF().Width;
-        //    height = m_SingleGDIObjects[0].GetZoomedRegionF().Height;
-        //    for (int i = 0; i < m_SingleGDIObjects.Count; i++)
-        //    {
-        //        MinX = Math.Min(m_SingleGDIObjects[i].GetZoomedRegionF().X, MinX);
-        //        MinY = Math.Min(m_SingleGDIObjects[i].GetZoomedRegionF().Y, MinY);
-        //        MaxX = Math.Max(m_SingleGDIObjects[i].GetZoomedRegionF().X, MaxX);
-        //        MaxY = Math.Max(m_SingleGDIObjects[i].GetZoomedRegionF().Y, MaxY);
-        //    }
-        //    //获取帧图的外框矩形
-        //    RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX- MinX+ width, MaxY- MinY+ height);
-        //    //计算外框矩形的中心点
-        //    float PointFX = SingleRect.X + SingleRect.Width / 2;
-        //    float PointFY = SingleRect.Y + SingleRect.Height / 2;
-        //    PointF SingleCenterPoint = new PointF(PointFX, PointFY);
-        //    return SingleCenterPoint;
-        //}
-        //public static PointF GetSingleDrawCenterLocation(List<CRectangleGDIObject> m_SingleGDIObjects)
-        //{
-        //    float MinX = 0f;
-        //    float MinY = 0f;
-        //    float MaxX = 0f;
-        //    float MaxY = 0f;
-        //    float width = 0f;
-        //    float height = 0f;
-        //    //获取最小XY 与最大XY
-        //    MinX = m_SingleGDIObjects[0].OrigionalDrawRegionF.X;
-        //    MinY = m_SingleGDIObjects[0].OrigionalDrawRegionF.Y;
-        //    MaxX = m_SingleGDIObjects[0].OrigionalDrawRegionF.X;
-        //    MaxY = m_SingleGDIObjects[0].OrigionalDrawRegionF.Y;
-        //    width = m_SingleGDIObjects[0].OrigionalDrawRegionF.Width;
-        //    height = m_SingleGDIObjects[0].OrigionalDrawRegionF.Height;
-        //    for (int i = 0; i < m_SingleGDIObjects.Count; i++)
-        //    {
-        //        MinX = Math.Min(m_SingleGDIObjects[i].OrigionalDrawRegionF.X, MinX);
-        //        MinY = Math.Min(m_SingleGDIObjects[i].OrigionalDrawRegionF.Y, MinY);
-        //        MaxX = Math.Max(m_SingleGDIObjects[i].OrigionalDrawRegionF.X, MaxX);
-        //        MaxY = Math.Max(m_SingleGDIObjects[i].OrigionalDrawRegionF.Y, MaxY);
-        //    }
-        //    //获取帧图的外框矩形
-        //    RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX - MinX + width, MaxY - MinY + height);
-        //    //计算外框矩形的中心点
-        //    float PointFX = SingleRect.X + SingleRect.Width / 2;
-        //    float PointFY = SingleRect.Y + SingleRect.Height / 2;
-        //    PointF SingleCenterPoint = new PointF(PointFX, PointFY);
-        //    return SingleCenterPoint;
-        //}
-        #endregion
-
-        #region 将所有帧图移植测量区域位置
-        //public static void SetSingleLocationToMeasureLocation(List<CRectangleGDIObject> m_ObjectListGDIObjects, CRectangleGDIObject m_ObjectGDIObjects)
-        //{
-        //    //获取帧图中心与测量区域中心
-        //    PointF singleCenterPoinF = GetSingleCenterLocation(m_ObjectListGDIObjects);
-        //    PointF singleDrawCenterPoinF = GetSingleDrawCenterLocation(m_ObjectListGDIObjects);
-        //    //测量区域 已改变为倍数的尺寸 中心点
-        //    PointF measureCenterPoin = m_ObjectGDIObjects.GetCenterPoint();
-        //    //测量区域 正常尺寸 中心点
-        //    PointF measureCenterPoinF = m_ObjectGDIObjects.GetCenterPoint();
-        //    //计算相差的XY距离
-        //    float moveX = measureCenterPoin.X - singleCenterPoinF.X;
-        //    float moveY = measureCenterPoin.Y - singleCenterPoinF.Y;
-
-        //    float moveFX = measureCenterPoinF.X - singleDrawCenterPoinF.X;
-        //    float moveFY = measureCenterPoinF.Y - singleDrawCenterPoinF.Y;
-        //    //需要移动的位置
-        //    PointF movePoint = new PointF(moveX, moveY);
-        //    PointF movePointF = new PointF(moveFX, moveFY);
-        //    foreach (var ObjectItem in m_ObjectListGDIObjects)
-        //    {
-        //        //计算移动后的位置
-        //        float X = ObjectItem.GetZoomedRegionF().X + movePoint.X;
-        //        float Y = ObjectItem.GetZoomedRegionF().Y + movePoint.Y;
-        //        float Width = ObjectItem.GetZoomedRegionF().Width;
-        //        float Height = ObjectItem.GetZoomedRegionF().Height;
-        //        ObjectItem.SetInitRegionF(new RectangleF(X, Y, Width, Height));
-        //    }
-        //}
-        #endregion
-
-
-        #region 判断当前位置是否在不规则形状里面
-        /// <summary>
-        /// 判断当前位置是否在不规则形状里面
-        /// </summary>
-        /// <param name="PointList">不规则形状坐标集合</param>
-        /// <param name="currentMouseLocation">当前鼠标坐标</param>
-        /// <returns></returns>
-        public static bool PositionPnpoly(List<Point> polygonPointList, Point currentMouseLocation)
-        {
-            double testx = currentMouseLocation.X;
-            double testy = currentMouseLocation.Y;
-            int nvert = polygonPointList.Count;
-            List<double> vertx = new List<double>();
-            List<double> verty = new List<double>();
-            for (int pointIndex = 0; pointIndex < polygonPointList.Count; pointIndex++)
-            {
-                vertx.Add(polygonPointList[pointIndex].X);
-                verty.Add(polygonPointList[pointIndex].Y);
-            }
-            int i, j, c = 0;
-            for (i = 0, j = nvert - 1; i < nvert; j = i++)
-            {
-                if (((verty[i] > testy) != (verty[j] > testy)) && (testx < (vertx[j] - vertx[i]) * (testy - verty[i]) / (verty[j] - verty[i]) + vertx[i]))
-                {
-                    c = 1 + c; ;
-                }
-            }
-
-            if (c % 2 == 0)
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-        #endregion
-
-        #region 获取多边形最小外接矩形
-        /// <summary>
-        /// 获取多边形最小外接矩形
-        /// </summary>
-        /// <param name="polygonPointList">不规则形状坐标集合</param>
-        /// <returns></returns>
-        public static Rectangle GetMinRectangleOfPolygon(List<PointF> polygonPointList)
-        {
-            if (polygonPointList != null)
-            {
-                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;
-                }
-            }
-            return new Rectangle();
-        }
-        #endregion
-
-   
-
+      
     }
 }

+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.Designer.cs

@@ -204,7 +204,7 @@ namespace OTSMeasureApp
             this.Text = "OTSSamplespaceWindow";
             this.TopMost = true;
             this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
-            this.Activated += new System.EventHandler(this.OTSSamplespaceWindow_Activated);
+            //this.Activated += new System.EventHandler(this.OTSSamplespaceWindow_Activated);
             this.Load += new System.EventHandler(this.OTSSamplespaceWindow_Load);
             this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OTSSamplespaceWindow_KeyDown);
             this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OTSSamplespaceWindow_KeyUp);

File diff suppressed because it is too large
+ 277 - 283
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs


+ 7 - 2
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/SEMDATAFieldManage.cs

@@ -213,6 +213,13 @@ namespace OTSMeasureApp
                 //鼠标在样品台中移动获取坐标
                 OTSLocation = stage.GetMouseSEMLocation(mousePoint);
 
+                var offsetX = mousePoint.X - stage.GetDisplayRefPoint().X;
+                var offsetY = mousePoint.Y - stage.GetDisplayRefPoint().Y;
+                PointF ctrlPoint = new PointF(offsetX / stage.GetZoomNum(), offsetY / stage.GetZoomNum());
+
+                PointF otsPoint = stage.CtrlCoordToOTSCoord(ctrlPoint);
+
+
                 PointF SEMPoint =m_ProjData.ConvertOTSToSemCoord(OTSLocation);
 
                
@@ -241,8 +248,6 @@ namespace OTSMeasureApp
                
                 if (!stage.IfMouseInStage(mousePoint))
                 {
-                  
-                  
                     return false;
                 }
               

+ 31 - 165
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualStage.cs

@@ -123,7 +123,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             foreach (var g in m_SampleHoleGDIObjects)
             {
-                if (g.IfScaleContains(mousePoint))
+                if (g.IfZoomContains(mousePoint))
                 {
                     return g;
                 }
@@ -191,18 +191,12 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
 
 
-            string stageName = GetOTSSampleStageData().sStageName;
-        
-            //获取样品台
-            ShapeType StageShape = GetOTSSampleStageData().bStageShape;
             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);
-            float  heightDomain = Math.Abs(yDomain.Y - xDomain.Y);
-            //样品台转换在电镜位置的宽度与高度
-
+      
             //设置样品台宽度
             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.
@@ -250,8 +244,6 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 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);
 
@@ -270,19 +262,6 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                     CreateBourary =  new CRectangleGDIObject(Bourary, CreateRectangleType.Circle);
                 }
       
-                //添加样品台 对象
-                //设置路径
-                //GraphicsPath MeasurePath = new GraphicsPath();
-
-                //if (StageShape == (int)CreateRectangleType.Circle)
-                //{
-                //    MeasurePath.AddEllipse(CreateBourary.GetZoomedRegion);
-                //}
-                //else
-                //{
-                //    MeasurePath.AddRectangle(CreateBourary.GetZoomedRegion);
-                //}
-                //CreateBourary.GPath = MeasurePath;
                 CreateBourary.Shape = StageShape;
                 m_StageEdgeGDIObjects.Add(CreateBourary);
                 //绘制后的样品台中心位置
@@ -424,7 +403,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 return new RectangleF();
             }
         }
-        public PointF CalculateLocationF(PointF point)
+        private PointF CalculateLocationF(PointF point)
         {
             //获取窗体的高度与宽度
             int ctrlWidth = m_totalCtrlWidth;
@@ -438,7 +417,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
     
 
-        public double MicronConvertToPixel(double PointVal)
+        private double MicronConvertToPixel(double PointVal)
         {
           
             var v = m_VisualStageEdgeLength;
@@ -485,9 +464,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 leftTop.Y = (float)PixelConvertToMicron((ctrlLeftTop.Y-ctrlcenter.Y));
                 rightBottom.X = (float)PixelConvertToMicron(ctrlRightBottom.X-ctrlcenter.X);
                 rightBottom.Y = (float)PixelConvertToMicron((ctrlRightBottom.Y-ctrlcenter.Y));
-                //计算位置
-                //leftTop = CalculateOTSLocation(leftTop);
-                //rightBottom = CalculateOTSLocation(rightBottom);
+       
 
                 //获取OTS图形四个点
                 float realStartX = Math.Min(leftTop.X, rightBottom.X);
@@ -507,7 +484,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             }
         }
 
-        public float PixelConvertToMicron(float Pixel)
+        private float PixelConvertToMicron(float Pixel)
         {
             return (float)(Pixel * ((double)m_OTSCoordStageEdgeLength / m_VisualStageEdgeLength));
         }
@@ -523,7 +500,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 }
             }
         }
-        private CRectangleGDIObject GetSampleHoleGdiobjByName(string holeName)
+        public CRectangleGDIObject GetSampleHoleGdiobjByName(string holeName)
         {
             foreach (var hole in m_SampleHoleGDIObjects)
             {
@@ -602,9 +579,6 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         public SampleMeasurePara GetSampleMeasurePara(CRectangleGDIObject MeasureItem)
         {
 
-
-
-       
             var item = MeasureItem;
 
             SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();
@@ -624,7 +598,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             //设置测量区域形状
             sampleMeasurePara.iShape = item.Shape;
             
-            sampleMeasurePara.DrawPolygonPointList = ConvertPolygonPointToOTSPoint(item.OriginalPolygonPointFList);
+            sampleMeasurePara.DrawPolygonPointList = ConvertPolygonPointToOTSPoint(item.GetOriginalPolygonPointFList());
 
 
             sampleMeasurePara.sSampleName = MeasureItem.SampleName ;
@@ -694,10 +668,6 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         public bool GetMeasureGdiObject( CRectangleGDIObject sampleGDIObject,RectangleF newRegion, out CRectangleGDIObject outMeasureRect)
         {
             
-                //添加测量区域
-           
-              
-               
                 var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea);
                  MeasureRect.SetInitRegionF(newRegion);
             
@@ -709,7 +679,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 return true;
             
         }
-        public bool GetMeasureGdiObject(CRectangleGDIObject sampleGDIObject,  out CRectangleGDIObject outMeasureRect)
+        public bool GetMeasureGdiObjectFromSampleGdi(CRectangleGDIObject sampleGDIObject,  out CRectangleGDIObject outMeasureRect)
         {
 
             //添加测量区域
@@ -804,7 +774,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects)
             {
-                if (item.IfScaleContains(mousePoint))
+                if (item.IfZoomContains(mousePoint))
                 {
                     gdiItem = item;
                     return true; ;
@@ -818,7 +788,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects)
             {
-                if (item.IfScaleContains(mousePoint))
+                if (item.IfZoomContains(mousePoint))
                 {
                     gdiobj = item;
                     return true;
@@ -832,7 +802,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects)
             {
-                if (item.IfScaleContains(mousePoint))
+                if (item.IfZoomContains(mousePoint))
                 {
                   
                     return true;
@@ -843,32 +813,6 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         }
 
-        //public void OnMouseMove(CRectangleGDIObject item,MouseEventArgs e)
-        //{
-        //    foreach (CRectangleGDIObject sampleHoleItem in m_SampleHoleGDIObjects)
-        //    {
-        //        //获取样品孔中心点 
-        //        Point sampleHoleCenterPoint = sampleHoleItem.GetCenterPoint();
-        //        if (item.IfScaleContains(sampleHoleCenterPoint))
-        //        {
-        //            if (item.Name != sampleHoleItem.Name)
-        //            {
-        //                //获取颜色
-        //                string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
-        //                item.SelColor = ColorTranslator.FromHtml(ColorStr);
-        //                break;
-        //            }
-        //        }
-        //        else
-        //        {
-        //            //获取颜色
-        //            string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
-        //            item.SelColor = ColorTranslator.FromHtml(ColorStr);
-        //        }
-        //    }
-
-
-        //}
         public void OnMouseMove( MouseEventArgs e)
         {
             foreach (CRectangleGDIObject item in m_ContentGDIObjects)
@@ -913,103 +857,28 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
             return allobj;
         }
-        public  bool NewLocationDrawSingleInfo(  Point moveToSEMLocation, List<CRectangleGDIObject> UpdateLocationGDIObject, CRectangleGDIObject WorkMeasure)
+        public List<CRectangleGDIObject> GetAllGDIObjectWithoutHoleNameStr()
         {
-            //样品台中心点位置
-            Point m_StageCenterPoint = GetCenterPoint();
-            //当前与中心点相差距离
-            int m_StageCenterDiffX ;
-            int m_StageCenterDiffY;
-            Point m_WorkMeasureCenterPoint ;
-            if (UpdateLocationGDIObject == null)
+            var allobj = new List<CRectangleGDIObject>();
+            foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects)
             {
-                return false;
+                allobj.Add(item);
             }
 
-            int diffNewX ;
-            int diffNewY ;
-            bool IsOK = true;
-            //diffNewX = moveToSEMLocation.X;
-            //diffNewY = moveToSEMLocation.Y;
-
-            if (IsOK)
+            foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects)
             {
-                foreach (var item in UpdateLocationGDIObject)
-                {
-                    m_WorkMeasureCenterPoint = WorkMeasure.GetCenterPoint();
-                    m_StageCenterDiffX = m_StageCenterPoint.X - m_WorkMeasureCenterPoint.X;//(int)((m_StageCenterPoint.X - m_WorkMeasureCenterPoint.X) * m_GlobalZoomNum);
-                    m_StageCenterDiffY = m_StageCenterPoint.Y - m_WorkMeasureCenterPoint.Y;// (int)((m_StageCenterPoint.Y - m_WorkMeasureCenterPoint.Y) * m_GlobalZoomNum);
-                    diffNewX = (int)(moveToSEMLocation.X * GetZoomNum());
-                    diffNewY = (int)(moveToSEMLocation.Y * GetZoomNum());
-                    //根据鼠标_更改测量区域的位置
-                    //item.Region = new Rectangle(new Point(item.Region.X + m_StageCenterDiffX + diffNewX, item.Region.Y + m_StageCenterDiffY - diffNewY), new Size(item.Region.Width, item.Region.Height));
-                    item.SetInitRegionF(new RectangleF(new PointF(item.GetZoomedRegionF().X + (m_StageCenterDiffX + diffNewX), item.GetZoomedRegionF().Y + (m_StageCenterDiffY - diffNewY)), new SizeF(item.GetZoomedRegionF().Width, item.GetZoomedRegionF().Height)));
-                    //item.DrawRegionF = new RectangleF(new PointF(item.DrawRegionF.X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.DrawRegionF.Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum), new SizeF(item.DrawRegionF.Width, item.DrawRegionF.Height));
-                }
+                allobj.Add(item);
             }
-            return IsOK;
-        }
-        public  void NewLocationDrawMeasureInfo( Point moveToSEMLocation, CRectangleGDIObject UpdateLocationGDIObject)
-        {
-            //样品台中心点位置
-            Point m_StageCenterPoint = GetCenterPoint();
-            //当前与中心点相差距离
-            int m_StageCenterDiffX ;
-            int m_StageCenterDiffY ;
-            int diffNewX ;
-            int diffNewY ;
-            Point m_UpdateCenterPoint ;
-            var m_GlobalZoomNum = GetZoomNum();
-            var item = UpdateLocationGDIObject;
-          
-            m_UpdateCenterPoint = item.GetCenterPoint();
-                    m_StageCenterDiffX = (int)((m_StageCenterPoint.X - m_UpdateCenterPoint.X) * 1);
-                    m_StageCenterDiffY = (int)((m_StageCenterPoint.Y - m_UpdateCenterPoint.Y) * 1);
-
-                    diffNewX = (int)(moveToSEMLocation.X * m_GlobalZoomNum);
-                    diffNewY = (int)(moveToSEMLocation.Y * m_GlobalZoomNum);
-                    //根据鼠标_更改测量区域的位置
-                    //item.Region = new Rectangle(new Point(item.Region.X + m_StageCenterDiffX + diffNewX, item.Region.Y + m_StageCenterDiffY - diffNewY), new Size(item.Region.Width, item.Region.Height));
-                    item.SetInitRegionF(new RectangleF(new PointF(item.GetZoomedRegionF().X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.GetZoomedRegionF().Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum), new SizeF(item.GetZoomedRegionF().Width, item.GetZoomedRegionF().Height)));
-                    //item.DrawRegionF = item.GetRegionF();
-                    //修改多边形的绘制点集合
-                    if (item.CreateType == CreateRectangleType.Polygon)
-                    {
-                        for (int i = 0; i < item.PolygonPointRegion.Count; i++)
-                        {
-                            item.PolygonPointRegion[i] = new Point(item.PolygonPointRegion[i].X + m_StageCenterDiffX + diffNewX, item.PolygonPointRegion[i].Y + m_StageCenterDiffY - diffNewY);
-                            item.PolygonPointFList[i] = new PointF(item.PolygonPointFList[i].X + (m_StageCenterDiffX + diffNewX), item.PolygonPointFList[i].Y + (m_StageCenterDiffY - diffNewY));
-                            item.PolygonPointFList[i] = new PointF(item.PolygonPointFList[i].X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.PolygonPointFList[i].Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum);
-                        }
-                    }
-            
-        }
-        public  SampleHolePara GetSampleHolePara(CRectangleGDIObject sampleHoleItem)
-        {
-            //int w = (IsWidth == 0 ? Width : Height);
-            SampleHolePara sampleHoleParas ;
-            //获取样品孔的OTS位置与尺寸
-            sampleHoleParas = GetSampleHoleInfo(sampleHoleItem);
-            //获取工作区域位置与尺寸
-            //Rectangle WorkAreaRect = new Rectangle(0, 0, m_totalCtrlWidth, m_totalCtrlHeight);
-            //获取工作区域 中心点
-            //Point ScreenPointCenter = GetCenterPoint(WorkAreaRect);
-            //获取样品台 中心点
-            PointF RectanglePointCenter =GetCenterPoint();
-            //获取屏幕中心点
-            //float WorkAreaCenterPointX = PixelConvertToMicron(ScreenPointCenter.X);
-            //float WorkAreaCenterPointY = PixelConvertToMicron(ScreenPointCenter.Y);
-            //获取样品台中心点
-            float CenterX = PixelConvertToMicron((int)RectanglePointCenter.X);
-            float CenterY = PixelConvertToMicron((int)RectanglePointCenter.Y);
-            RectangleF sampleHoleRect = new RectangleF();
-            //根据样品台中心点获取开始点位置
-            sampleHoleRect.X = -(CenterX - sampleHoleParas.SampleHoleRect.X);
-            sampleHoleRect.Y = CenterY - sampleHoleParas.SampleHoleRect.Bottom;
-            sampleHoleParas.SampleHoleRect.X = sampleHoleRect.X;
-            sampleHoleParas.SampleHoleRect.Y = sampleHoleRect.Y;
-            return sampleHoleParas;
+            foreach (CRectangleGDIObject item in m_SpecimenGDIObjects)
+            {
+                allobj.Add(item);
+            }
+       
+
+
+            return allobj;
         }
+
         public  PointF GetCenterPoint(RectangleF rect)
         {
             //声明
@@ -1023,20 +892,17 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         {
             SampleHolePara sampleHolePara = new SampleHolePara();
          
-            //保存原位置
-            RectangleF rectPara = item.GetZoomedRegion;
+       
             //设置测量区域
             sampleHolePara.SampleHoleRect = item.GetZoomedRegion;
             //设置测量区域位置与尺寸
             float left = PixelConvertToMicron(item.GetZoomedRegionF().X);
-            float Top = PixelConvertToMicron(item.GetZoomedRegionF().Y);
-            float Right = PixelConvertToMicron(item.GetZoomedRegionF().Right);
-            float Bottom = PixelConvertToMicron(item.GetZoomedRegionF().Bottom);
-            float Widths = PixelConvertToMicron(item.GetZoomedRegionF().Width);
+            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(Widths, Height);
+            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.Name;

+ 25 - 51
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -27,12 +27,7 @@ using OTSMeasureApp.ServiceCenter;
 
 namespace OTSMeasureApp 
 {
-  public  enum MessageState
-    {
-        StartMeasure = 0,       //开始测量
-        ShotBSEPicture = 1,      //拍摄样品孔图片
-        //MeasureBSEPicture = 2     //拍摄测量区域图片
-    };
+
    public enum ShapeType
     {
         CIRCUL = 0,       //圆形
@@ -61,7 +56,7 @@ namespace OTSMeasureApp
         public  OTSRibbonFun m_RibbonFun = null;
 
         //判断信息来源  拍摄样品孔图片 或是 测量开始
-        public MessageState m_MessageStates = MessageState.StartMeasure;
+        public MSR_THREAD_RunSTATUS m_RunType = MSR_THREAD_RunSTATUS.RUNMEASURE;
 
 
 
@@ -161,7 +156,7 @@ namespace OTSMeasureApp
         {
             try
             {
-  
+
 
                 ArrangWorkspaceWindow();
 
@@ -192,6 +187,8 @@ namespace OTSMeasureApp
                     {
                         log.Error(" InitResultData() failed");
                     }
+
+                  
                 }
                 else
                 {
@@ -239,11 +236,12 @@ namespace OTSMeasureApp
            m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
             //Show 测量过程中Log显示窗口
            m_OTSMeasureOutputNlog.Show(dockPanel, DockState.DockRight);
+
            dockPanel.DockRightPortion = 365;
 
            m_SPropertyWindows.Show(dockPanel);
 
-            m_SamplepaceWindow.Activate();
+           m_SamplepaceWindow.Activate();
 
 
         }
@@ -292,14 +290,14 @@ namespace OTSMeasureApp
 
 
             //设置获取帧图状态
-            m_MessageStates = MessageState.StartMeasure;
+            m_RunType = MSR_THREAD_RunSTATUS.RUNMEASURE;
             m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
             //发送新的样品名给Treeview
             m_SolutionWindows.SwitchSample(sNewWorkSampleName);
             //发送想你的样品名给Sample
             m_SamplepaceWindow.SwitchWorkSample(sNewWorkSampleName);
             //根据节点设置样品台窗口中所选择的样品名称
-            //m_SamplepaceWindow.m_SampleSelectName = sNewWorkSampleName;
+         
 
 
         }
@@ -367,15 +365,6 @@ namespace OTSMeasureApp
 
 
 
-        //移动工作样品到其他样品孔,样品孔名称和测量区域都要改变,重新设置工作样品参数
-        //SampleMeasurePara SMeasurePara:
-        public void SetWorkSamplHoleAndMeasureArea(SampleMeasurePara SMeasurePara)
-        {
-
-             m_ProjParam.SetWorkSampleHoleAndMeasureArea(SMeasurePara);
-
-        }
-
         //当 SampleMeasurePara SetWorkSamplHoleAndMeasureArea(SampleMeasurePara SMeasurePara) 移动成功之后,需要调用此函数更新Grid的显示
         public void UpdateTreeSampleAndGridSampleVal()
         {
@@ -552,7 +541,6 @@ namespace OTSMeasureApp
          
 
 
-            //获取工作样品
             OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
             if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetResultData().GetWorkingSample(), ref SMInfo))
             {
@@ -560,10 +548,8 @@ namespace OTSMeasureApp
                 return false;
             }
 
-            // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
             m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
 
-            // MeasureApp 给 OTSSolutionWindow 发送打开已保存的工作样品文件
             m_SolutionWindows.OpenExistSampleFile(TSampleParamList, SMInfo.TSampleParam);
 
          
@@ -574,12 +560,11 @@ namespace OTSMeasureApp
                 return false;
             }
 
-            //打开已保存的样品后,将所有样品发送给样品台
             string sWSampleName = m_ProjParam.GetWorkSampleName();
            
             if ("" == sWSampleName)
             {
-                log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile)  m_DataMgrFun.GetWorkSampleName() = null Failed !");
+                log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile)  m_DataMgrFun.GetWorkSampleName() = null !");
                 return false;
             }
          
@@ -606,7 +591,6 @@ namespace OTSMeasureApp
                 //样品测量区域
                 SampleMeasureArea.MeasureRect =(m_ProjData.GetSampleList())[i].GetMsrArea().GetRectDomain();
                 //多边形点集合
-                //SampleMeasureArea.PolygonPointRegion = (m_ProjData.GetSampleList())[i].GetMsrArea().GetPolygonPoint();
                 List<PointF> PointRegionF = new List<PointF>();
                 List<Point> PolygonPoint = m_ProjData.GetSampleList()[i].GetMsrArea().GetPolygonPoint();
                 if (PolygonPoint != null)
@@ -616,7 +600,6 @@ namespace OTSMeasureApp
                         PointRegionF.Add(new PointF(item.X, item.Y));
                     }
                 }
-                //SampleMeasureArea.PolygonPointRegionF = PointRegionF;
                 SampleMeasureArea.DrawPolygonPointList = PointRegionF;
                 SampleMeasureAreaList.Add(SampleMeasureArea);
             }
@@ -669,9 +652,9 @@ namespace OTSMeasureApp
         //返回删除的工作样品名
         public void DeleteSample(string sDeleteWSampleName = "")
         {
-            if (m_MsrThreadWrapper.m_MsrThread.mapSmplMsr.ContainsKey(sDeleteWSampleName))
+            if (m_MsrThreadWrapper.m_measure.mapSmplMsr.ContainsKey(sDeleteWSampleName))
             {
-                m_MsrThreadWrapper.m_MsrThread.mapSmplMsr.Remove(sDeleteWSampleName);
+                m_MsrThreadWrapper.m_measure.mapSmplMsr.Remove(sDeleteWSampleName);
             }
            
 
@@ -769,7 +752,7 @@ namespace OTSMeasureApp
             //设置 删除,复位,圆形,矩形 按钮状态
             m_RibbonFun.SetSampleRibbonButnStatus();
             //清空帧图信息
-            m_MessageStates = MessageState.StartMeasure;
+            m_RunType = MSR_THREAD_RunSTATUS.RUNMEASURE;
             //m_SamplepaceWindow.ClearImageAndFieldGDIObjects();
             //m_SamplepaceWindow.Invalidate();
         }
@@ -931,20 +914,6 @@ namespace OTSMeasureApp
         }
 
 
-        /// <summary>
-        /// 执行样品孔中照片后台线程
-        /// </summary>
-        private void StartSampleHoleImageBGWorkThread()
-        {
-      
-            if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
-            {
-                m_MessageStates = MessageState.ShotBSEPicture;
-                m_MsrThreadWrapper.SetDoRunType(MSR_THREAD_RunSTATUS.RUNSampleHoleImage);
-                m_MsrThreadWrapper.StartBGWorkThread();
-                m_RibbonFun.SetMeasureRibbonButnStatu();
-            }
-        }
  
         private void rbStart_Click(object sender, EventArgs e)
         {
@@ -954,8 +923,8 @@ namespace OTSMeasureApp
             }
             if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
             {
-                //设置消息类型 拍摄样品孔
-                m_MessageStates = (int)MessageState.StartMeasure;
+               
+                m_RunType = MSR_THREAD_RunSTATUS.RUNMEASURE;
                 m_MsrThreadWrapper.SetDoRunType(MSR_THREAD_RunSTATUS.RUNMEASURE);
                 m_MsrThreadWrapper.StartBGWorkThread();
                 m_RibbonFun.SetMeasureRibbonButnStatu();
@@ -991,9 +960,9 @@ namespace OTSMeasureApp
                 //停止测量线程    
                 m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
             }
-            else if (m_MsrThreadWrapper.m_MsrThread.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
+            else if (m_MsrThreadWrapper.m_measure.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
             {
-                foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_MsrThread.mapSmplMsr)
+                foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_measure.mapSmplMsr)
                 {
                     if (smpl.Value.GetSample().GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
                     {
@@ -1099,14 +1068,19 @@ namespace OTSMeasureApp
         /// <param name="doRunType"></param>
         /// <param name="HoleID"></param>
         /// <param name="c_DomainMessure"></param>
-        public void StartSampleHoleBSEImage(MSR_THREAD_RunSTATUS doRunType)
+        public void StartSampleHoleBSEImage(MSR_THREAD_RunSTATUS doRunType,int HoleID)
         {
             //线程执行类型 1:测量类型 2:获取样品孔图片类型
             m_MsrThreadWrapper.SetDoRunType(doRunType);
             //设置获取样品孔中照片所需的参数
-            //m_MsrThreadWrapper.SetHoleImagePreview(HoleID, c_DomainMessure);
+            m_MsrThreadWrapper.SetHoleImagePreview(HoleID);
 
-            StartSampleHoleImageBGWorkThread();
+            if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
+            {
+     
+                m_MsrThreadWrapper.StartBGWorkThread();
+                m_RibbonFun.SetMeasureRibbonButnStatu();
+            }
         }
         #endregion
 

Some files were not shown because too many files changed in this diff