Browse Source

add animation effect while measuring.Check if the particles are in the measure area.

gsp 1 year ago
parent
commit
8c72977cb9
22 changed files with 570 additions and 325 deletions
  1. 8 4
      OTSCPP/OTSClrInterface/ClassificationClr/OTSClassifyEngineClr.cpp
  2. 1 1
      OTSCPP/OTSClrInterface/ClassificationClr/OTSClassifyEngineClr.h
  3. 5 0
      OTSCPP/OTSClrInterface/ImageProClr/FieldMgrClr.cpp
  4. 1 1
      OTSCPP/OTSClrInterface/ImageProClr/FieldMgrClr.h
  5. 36 1
      OTSCPP/OTSImagePro/FieldMgr.cpp
  6. 3 0
      OTSCPP/OTSImagePro/FieldMgr.h
  7. 35 2
      OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs
  8. 6 1
      OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSSample.cs
  9. 28 0
      OTSIncAMeasureApp/1-OTSMeasure/Measure/1-OTSInclution/SmplMeasureInclution.cs
  10. 25 3
      OTSIncAMeasureApp/1-OTSMeasure/Measure/2-OTSCleanliness/SmplMeasureCleanliness.cs
  11. 17 1
      OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CMeasureThreadWrapper.cs
  12. 7 34
      OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs
  13. 30 2
      OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/ST_MSTMsg.cs
  14. 20 35
      OTSIncAMeasureApp/1-OTSMeasure/OTSMeasureDisplayResult.cs
  15. 5 0
      OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CFieldPositionHelper.cs
  16. 49 29
      OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.Designer.cs
  17. 201 178
      OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs
  18. 2 2
      OTSIncAMeasureApp/ServiceCenter/CClassifyEngine.cs
  19. 79 4
      OTSIncAMeasureApp/ServiceCenter/CImageHandler.cs
  20. 1 1
      OTSIncAMeasureApp/ServiceCenter/IClassifyEngine.cs
  21. 1 24
      OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs
  22. 10 2
      OxfordExtenderWrapper/ExtenderWrapper.cs

+ 8 - 4
OTSCPP/OTSClrInterface/ClassificationClr/OTSClassifyEngineClr.cpp

@@ -97,13 +97,17 @@ namespace OTSCLRINTERFACE {
 
 
 
-	double COTSClassifyEngineClr::IfNeedMaxEDS(COTSParticleClr^ particle)
+	bool COTSClassifyEngineClr::IfNeedMaxEDS(COTSParticleClr^ particle,double% maxedstime)
 	{
 		auto part = particle->GetOTSParticlePtr();
 		auto xraydata = part->GetXrayInfo();
-		double MaxEDSTime;
-		 engine->IfNeedMaxEDS(part, xraydata, MaxEDSTime);
-		return MaxEDSTime;
+		double MaxEDSTime=0;
+		bool rst= engine->IfNeedMaxEDS(part, xraydata, MaxEDSTime);
+		if (rst)
+		{
+			maxedstime = MaxEDSTime;
+		}
+		return rst;
 	}
 	bool COTSClassifyEngineClr::ZeroElementProcess(COTSParticleClr^ particle)
 	{

+ 1 - 1
OTSCPP/OTSClrInterface/ClassificationClr/OTSClassifyEngineClr.h

@@ -33,7 +33,7 @@ namespace OTSCLRINTERFACE {
 
 		bool ClassifyIncA(COTSParticleClr^ particle, int SteelTech);//
 
-		double IfNeedMaxEDS(COTSParticleClr^ particle);
+		bool IfNeedMaxEDS(COTSParticleClr^ particle, double% maxedstime);
 
 		bool ZeroElementProcess(COTSParticleClr^ particle);             
 	private:

+ 5 - 0
OTSCPP/OTSClrInterface/ImageProClr/FieldMgrClr.cpp

@@ -136,6 +136,11 @@ namespace OTSCLRINTERFACE {
 		return Pts;
 	}
 
+	bool CFieldMgrClr::IsThisPointInMeasureArea(Point^ p)
+	{
+		return m_LpFieldMgr->get()->IsThisPointInMeasureArea(CPoint(p->X, p->Y));
+	}
+
 	
 
 	CDomainClr ^ CFieldMgrClr::GetMeasureArea()

+ 1 - 1
OTSCPP/OTSClrInterface/ImageProClr/FieldMgrClr.h

@@ -39,7 +39,7 @@ namespace OTSCLRINTERFACE {
 
 		// unmeasured field centre points list
 		SortedList<int,Point>^ GetUnmeasuredFieldCentrePoints(List<Point>^ a_listMeasuredFieldCentrePoints);
-	
+		bool IsThisPointInMeasureArea(Point^ p);
 
 		// measure area
 		CDomainClr^ GetMeasureArea();

+ 36 - 1
OTSCPP/OTSImagePro/FieldMgr.cpp

@@ -334,7 +334,7 @@ namespace OTSIMGPROC {
 					}
 				}
 				// 判断当前样品获取帧图信息的测量区域为多边形
-				if ((int)m_pMeasureArea->GetShape() > 1)
+				if (m_pMeasureArea->GetShape() == DOMAIN_SHAPE::POLYGON)
 				{
 					std::vector<CPoint> ptPolygon = m_pMeasureArea->GetPolygonPoint();
 					for (auto itr : mapCenterPoint)
@@ -362,6 +362,41 @@ namespace OTSIMGPROC {
 				
 		return m_listFieldCentrePoints;
 	}
+	BOOL CFieldMgr::IsThisPointInMeasureArea(CPoint a_position)
+	{
+		// 判断当前样品获取帧图信息的测量区域为多边形
+		if (m_pMeasureArea->GetShape() == DOMAIN_SHAPE::POLYGON)
+		{
+			std::vector<CPoint> ptPolygon = m_pMeasureArea->GetPolygonPoint();
+			
+				
+				if (PtInPolygon(a_position, ptPolygon))
+				{
+					// centre in the measure domain area, return TRUE 
+					return TRUE;
+				}
+				else
+				{
+					return FALSE;
+				}
+			
+		}
+		else
+		{
+			
+				if (m_pMeasureArea->PtInDomain(a_position))
+				{
+					// centre in the measure domain area, return TRUE 
+					return TRUE;
+				}
+				else
+				{
+					return FALSE;
+				}
+			
+		}
+	
+	}
 	// test if field is in or partly in the measure domain area
 	BOOL CFieldMgr::IsInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon)
 	{

+ 3 - 0
OTSCPP/OTSImagePro/FieldMgr.h

@@ -32,6 +32,7 @@ namespace OTSIMGPROC {
 		// field centre points list
 		std::vector<CPoint> GetFieldCentrePoints();
 
+		BOOL IsThisPointInMeasureArea(CPoint a_position);
 		
 		int GetTotalFields();
 		
@@ -74,6 +75,8 @@ namespace OTSIMGPROC {
 		// calculate field centre points list
 		std::vector<CPoint> CalculateFieldCentrePoints();
 
+		
+
 		// test if field is in or partly in the measure domain area
 		BOOL IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize);
 

+ 35 - 2
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -173,6 +173,22 @@ namespace OTSDataType
         {
             return m_pBSEImg;
         }
+        public Bitmap GetAnalysisParticleBlackColoredImage()
+        {
+            CImageHandler imghandler = new CImageHandler();
+            List<COTSParticleClr> Parts = GetListAnalysisParticles();
+            Bitmap img = new Bitmap(this.ImgWidth, this.ImgHeight);
+            imghandler.GetImageWithBlackColoredParts(Parts, ref img);
+            return img;
+        }
+        public Bitmap GetAnalysisParticleSTDColoredImage()
+        {
+            CImageHandler imghandler = new CImageHandler();
+            List<COTSParticleClr> Parts = GetListAnalysisParticles();
+            Bitmap img = new Bitmap(this.ImgWidth, this.ImgHeight);
+            imghandler.GetImageWithSTDColoredParts(Parts, ref img);
+            return img;
+        }
         public void SetBSEImage(CBSEImgClr a_pBSEImg)
         {
             if (a_pBSEImg == null)
@@ -246,8 +262,17 @@ namespace OTSDataType
                 
                 for (var i = 0; i < pXRayParam.GetXrayLimit(); i++)
                 {
+                    var part = m_listAllParticles[i];
+                    int l=0, r=0, t=0, b=0;
+                    part.GetOTSRect(ref l, ref t,ref r, ref b);
+                    COTSRect otsrec = new COTSRect(l, t, r, b);
+                    PointF p1 = otsrec.GetCenterPoint();
+
+                    if (m_sample.IsThisPointInMeasureArea(new Point((int)p1.X, (int)p1.Y)))
+                    {
+                        listXray1.Add(m_listAllParticles[i]);
+                    }
                    
-                    listXray1.Add(m_listAllParticles[i]);
                 }
 
             }
@@ -255,7 +280,15 @@ namespace OTSDataType
             {
                 foreach (var p in m_listAllParticles)
                 {
-                    listXray1.Add(p);
+                    var part = p;
+                    int l = 0, r = 0, t = 0, b = 0;
+                    part.GetOTSRect(ref l, ref t, ref r, ref b);
+                    COTSRect otsrec = new COTSRect(l, t, r, b);
+                    PointF p1 = otsrec.GetCenterPoint();
+                    if (m_sample.IsThisPointInMeasureArea(new Point((int)p1.X, (int)p1.Y)))
+                    {
+                        listXray1.Add(p);
+                    }
                 }
                
             }

+ 6 - 1
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSSample.cs

@@ -244,7 +244,12 @@ namespace OTSDataType
         //public MEMBRANE_TYPE GetMembraneType() { return m_membraneType; }
         //public void SetMembraneType(MEMBRANE_TYPE val) { m_membraneType = val; }
 
-       
+        public bool IsThisPointInMeasureArea(Point p)
+        {
+            return pFieldMgr.IsThisPointInMeasureArea(p);
+
+
+        }
        
         public double CalculatePixelSize()
         {

+ 28 - 0
OTSIncAMeasureApp/1-OTSMeasure/Measure/1-OTSInclution/SmplMeasureInclution.cs

@@ -2,6 +2,7 @@
 using OTSDataType;
 using OTSModelSharp.ServiceCenter;
 using System;
+using System.Collections.Generic;
 using System.Linq;
 using static OTSDataType.otsdataconst;
 
@@ -90,6 +91,33 @@ namespace OTSModelSharp
 
             return true;
         }
+        public override void CollectParticlesXrayData(COTSField curFldData)
+        {
+            base.CollectParticlesXrayData(curFldData);
+            var parts = curFldData.GetListAnalysisParticles();
+            string libname = m_Sample.GetMsrParams().GetSTDName();
+            //process the maxeds rules
+            if (libname != "NoSTDDB")
+            {
+                IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
+                double maxedstime = 0;
+                List<COTSParticleClr> maxedsparts = new List<COTSParticleClr>();
+                foreach (var p in parts)
+                {
+                    if (engine.IfNeedMaxEDS(p, ref maxedstime))
+                    {
+                        maxedsparts.Add(p);
+                    }
+                }
+                if (maxedsparts.Count > 0)
+                {
+                    log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode");
+
+                    m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true);
+                }
+            }
+
+        }
 
 
 

+ 25 - 3
OTSIncAMeasureApp/1-OTSMeasure/Measure/2-OTSCleanliness/SmplMeasureCleanliness.cs

@@ -102,10 +102,32 @@ namespace OTSModelSharp
 
             return true;
         }
+        public override void CollectParticlesXrayData(COTSField curFldData)
+        {
+            base.CollectParticlesXrayData(curFldData);
+            var parts = curFldData.GetListAnalysisParticles();
+            string libname = m_Sample.GetMsrParams().GetSTDName();
+            //process the maxeds rules
+            IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
+            double maxedstime=0;
+            List<COTSParticleClr> maxedsparts = new List<COTSParticleClr>();
+            foreach (var p in parts)
+            {
+                if (engine.IfNeedMaxEDS(p, ref maxedstime))
+                {
+                    maxedsparts.Add(p);
+                }
+            }
+            if (maxedsparts.Count > 0)
+            {
+                log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode");
 
+                m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true);
+            }
+            
+        }
 
 
 
-
-    }
-}
+        }
+    }

+ 17 - 1
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CMeasureThreadWrapper.cs

@@ -338,7 +338,23 @@ namespace OTSMeasureApp
 
                         if (iHeight > 0 && iWidth > 0)
                         {
-                            m_OTSMeasureResult.Field_BSE_DATA(MSTMsg);
+                            byte[] bsedata = MSTMsg.STMSampleRetData.BSEData.lpBSEData;
+                            m_OTSMeasureResult.Dis_Field_BSE_DATA(bsedata,iWidth,iHeight);
+                        }
+                        else
+                        {
+                            log.Error("(OTSGetMreRetThread) BSEDataHeight = " + iHeight.ToString() + "BSEDataWidth = " + iWidth.ToString() + " Failed");
+                        }
+                    }else 
+                    if (MSTMsg.STMSampleRetData.iRetDataType == MSAMPLE_RET.REMOVEBG_DATA)
+                    {
+                        int iHeight = MSTMsg.STMSampleRetData.BSEData.iBSEDataHeight;
+                        int iWidth = MSTMsg.STMSampleRetData.BSEData.iBSEDataWidth;
+
+                        if (iHeight > 0 && iWidth > 0)
+                        {
+                            Bitmap bsedata = MSTMsg.STMSampleRetData.BSEData.coloredImg;
+                            m_OTSMeasureResult.Dis_Field_BSE_REMOVEBG_DATA(bsedata);
                         }
                         else
                         {

+ 7 - 34
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -746,7 +746,9 @@ namespace OTSModelSharp
                     // image process
 
                     FieldImageProcess(curFld);
+                    MsgFieldBSE.InitFieldBSEAnalysisPartsDataMsg();
 
+                    m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
                     COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
 
                     if (pXRayParam.GetUsingXray() == true)
@@ -767,6 +769,10 @@ namespace OTSModelSharp
 
                     log.Info("Begin to classify particles! particle num:" + curFld.GetListAnalysisParticles().Count);
                     ClassifyFieldParticles(curFld);
+
+                    MsgFieldBSE.InitFieldSTDColoredPartsDataMsg();
+
+                    m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
                     //start db save
                     StartSaveFileThread(ref curFld);
 
@@ -1303,40 +1309,7 @@ namespace OTSModelSharp
                 }
             }
         }
-        public void ParticleSpecialTreatment(ref COTSField fld)
-        {
-            //we adopt such a strategy here:if some particles satisfy the predefined condition then we go through the second collecting with max EDS time,so that we got a more acurate result.
-            Dictionary<COTSParticleClr, int> mapPartXray = new Dictionary<COTSParticleClr, int>();   
-            double edsTime = 0; //to store the EDSTime returned from the engine.
-            var bigparts = fld.GetListXrayParticles();
-            var m_ClassifyEngine = new CClassifyEngine();
-            for (int i = 0; i < bigparts.Count(); i++)
-            {
-                var engine = m_ClassifyEngine.GetExpressionClassifyEngine(m_Sample.GetMsrParams().GetSTDName());
-                var p = bigparts[i];
-
-                // there will be very less particle satisfied the condition ,so we use only one MaxEDS time,though we set MaxEDSTime for every rule separately .Here we store the last one.
-                //if the particle satisfied the MaxEDS condition then we go through the second colleting.Here we record the particle and the EDSTime and the corresponding xray position.
-                edsTime = engine.IfNeedMaxEDS(p);
-                if (edsTime > 0)
-                {
-                    mapPartXray[p] = i;
-                }
-            }
-            List<COTSParticleClr> partsMax = new List<COTSParticleClr>();
-            if (mapPartXray.Count() > 0)
-            {
-                foreach (var p in mapPartXray)
-                {
-                    partsMax.Add(p.Key);
-                }
-                List<CPosXrayClr> maxEDSXrays = new List<CPosXrayClr>();
-                m_EDSController.GetXRayByFeatures(partsMax, edsTime, true);
-
-
-
-            }
-        }
+       
        
 
     }

+ 30 - 2
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/ST_MSTMsg.cs

@@ -20,8 +20,9 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
     public enum MSAMPLE_RET
     {
         BSE_DATA = 0,
-        FIELD_DATA = 1,
-        START_MSR_FIELD = 2
+        REMOVEBG_DATA=1,
+        FIELD_DATA = 2,
+        START_MSR_FIELD = 3
 
     };
 
@@ -65,6 +66,7 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
             public int iBSEDataHeight;
             public int iBSEDataWidth;
             public byte[] lpBSEData;
+            public Bitmap coloredImg;
         };
 
         public struct SAMPLEFIELDDATA
@@ -212,6 +214,32 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
             byte[] pImgData = pBSEImg.GetImageDataPtr();
             this.STMSampleRetData.BSEData.lpBSEData = pImgData;
         }
+        internal void InitFieldBSEAnalysisPartsDataMsg()
+        {
+            var poiFieldCentre = m_curFld.GetOTSPosition();
+            var pImg = m_curFld.GetAnalysisParticleBlackColoredImage();
+            this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
+            this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
+            this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
+            this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
+            this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
+            this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
+            //byte[] pImgData = pBSEImg.GetImageDataPtr();
+            this.STMSampleRetData.BSEData.coloredImg = pImg;
+        }
+        internal void InitFieldSTDColoredPartsDataMsg()
+        {
+            var poiFieldCentre = m_curFld.GetOTSPosition();
+            var pImg = m_curFld.GetAnalysisParticleSTDColoredImage();
+            this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
+            this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
+            this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
+            this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
+            this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
+            this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
+            //byte[] pImgData = pBSEImg.GetImageDataPtr();
+            this.STMSampleRetData.BSEData.coloredImg = pImg;
+        }
 
         internal void InitFieldDataMsg()
         {

+ 20 - 35
OTSIncAMeasureApp/1-OTSMeasure/OTSMeasureDisplayResult.cs

@@ -11,6 +11,7 @@ using System.Windows.Forms;
 using static OTSDataType.otsdataconst;
 
 using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
+using OTSModelSharp.ServiceCenter;
 
 namespace OTSMeasureApp
 {
@@ -152,27 +153,7 @@ namespace OTSMeasureApp
         #endregion
 
         #region 显示BSE图片
-        public void OTSMeasureStatusWindowFun(int width, int height, byte[] ImageData, OTSIncAMeasureAppForm m_MeasureApps)
-        {
-            //设置图像数据与状态
-            OTSMeasureStatusWindow.bfResult = true;
-            m_MeasureApps.m_MessureStatuWindow.originalBseData = ImageData;
-            //获取灰度图数据
-            double[] dGrayLevelData = new double[255];
-            dGrayLevelData = GetStaticGaryData(ImageData, dGrayLevelData);
-            m_MeasureApps.m_MessureStatuWindow.dGrayLevelData = dGrayLevelData;
-            if (m_MeasureApps.m_MessureStatuWindow.panelXray.Visible)
-            {
-                m_MeasureApps.m_MessureStatuWindow.panelXray.Visible = false;
-            }
-            //删除点标记
-            m_MeasureApps.m_MessureStatuWindow.DelElementPointGDIObjects();
-            //显示BSE图
-            m_MeasureApps.m_MessureStatuWindow.picBox.Show();
-  
-            //显示BSE图
-            m_MeasureApps.m_MessureStatuWindow.ShowImage(width, height, ImageData);
-        }
+        
         public double[] GetStaticGaryData(byte[] Imagedata, double[] GrayLevelData)
         {
             try
@@ -302,21 +283,25 @@ namespace OTSMeasureApp
             m_MeasureApp.m_SamplepaceWindow.Invalidate();
         }
 
-        public void Field_BSE_DATA(ST_MSTMsg SMsrData)
+        public void Dis_Field_BSE_DATA(byte[] ImageData,int width,int height)
         {
-            //获取显示BSE的图片数据
-            byte[] ImageData = SMsrData.STMSampleRetData.BSEData.lpBSEData;
-            //图片宽度
-            int width = SMsrData.STMSampleRetData.BSEData.iBSEDataWidth;
-            //图片高度
-            int height = SMsrData.STMSampleRetData.BSEData.iBSEDataHeight;
-            //显示状态中的BSE图像控件
-            if (!m_MeasureApp.m_MessureStatuWindow.picBox.Visible)
-            {
-                m_MeasureApp.m_MessureStatuWindow.picBox.Visible = true;
-            }
-            //调用测量状态TAB中窗体 显示BSE图片
-            OTSMeasureStatusWindowFun(width, height, ImageData, m_MeasureApp);
+          
+            //设置图像数据与状态
+            OTSMeasureStatusWindow.bfResult = true;
+            m_MeasureApp.m_MessureStatuWindow.originalBseData = ImageData;
+          
+            //删除点标记
+            m_MeasureApp.m_MessureStatuWindow.DelElementPointGDIObjects();
+          
+            Bitmap bitmap = CImageHandler.ToGrayBitmap(ImageData, width, height);
+            //显示BSE图
+            m_MeasureApp.m_MessureStatuWindow.ShowDoubleImage(bitmap, null);
+        }
+        public void Dis_Field_BSE_REMOVEBG_DATA(Bitmap ImageData)
+        {
+            
+            
+            m_MeasureApp.m_MessureStatuWindow.ShowDoubleImage(null, ImageData);
         }
 
         public void SampleStart(ST_MSTMsg SMsrData)

+ 5 - 0
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CFieldPositionHelper.cs

@@ -175,6 +175,11 @@ namespace OTSModelSharp
             }
 
         }
+       public bool IsThisPointInMeasureArea(Point p)
+        {
+          return  fieldmgrclr.IsThisPointInMeasureArea(p);
+        
+        }
 
 
 

+ 49 - 29
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.Designer.cs

@@ -29,10 +29,10 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
-            System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
-            System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.Title title4 = new System.Windows.Forms.DataVisualization.Charting.Title();
             this.picBox = new System.Windows.Forms.PictureBox();
             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
             this.SampleParaLock = new System.Windows.Forms.ToolStripMenuItem();
@@ -52,9 +52,11 @@
             this.panelXray = new System.Windows.Forms.Panel();
             this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
             this.timer1 = new System.Windows.Forms.Timer(this.components);
+            this.pictureBox2 = new System.Windows.Forms.PictureBox();
             ((System.ComponentModel.ISupportInitialize)(this.picBox)).BeginInit();
             this.contextMenuStrip1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.myChart)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
             this.SuspendLayout();
             // 
             // picBox
@@ -63,7 +65,7 @@
             this.picBox.Location = new System.Drawing.Point(0, 0);
             this.picBox.Margin = new System.Windows.Forms.Padding(2);
             this.picBox.Name = "picBox";
-            this.picBox.Size = new System.Drawing.Size(781, 300);
+            this.picBox.Size = new System.Drawing.Size(382, 300);
             this.picBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.picBox.TabIndex = 0;
             this.picBox.TabStop = false;
@@ -183,42 +185,42 @@
             // 
             // myChart
             // 
-            chartArea1.AlignmentStyle = System.Windows.Forms.DataVisualization.Charting.AreaAlignmentStyles.None;
-            chartArea1.Area3DStyle.Enable3D = true;
-            chartArea1.Area3DStyle.Inclination = 5;
-            chartArea1.Area3DStyle.IsClustered = true;
-            chartArea1.Area3DStyle.IsRightAngleAxes = false;
-            chartArea1.Area3DStyle.Perspective = 5;
-            chartArea1.Area3DStyle.WallWidth = 10;
-            chartArea1.Name = "ChartArea1";
-            this.myChart.ChartAreas.Add(chartArea1);
+            chartArea4.AlignmentStyle = System.Windows.Forms.DataVisualization.Charting.AreaAlignmentStyles.None;
+            chartArea4.Area3DStyle.Enable3D = true;
+            chartArea4.Area3DStyle.Inclination = 5;
+            chartArea4.Area3DStyle.IsClustered = true;
+            chartArea4.Area3DStyle.IsRightAngleAxes = false;
+            chartArea4.Area3DStyle.Perspective = 5;
+            chartArea4.Area3DStyle.WallWidth = 10;
+            chartArea4.Name = "ChartArea1";
+            this.myChart.ChartAreas.Add(chartArea4);
             this.myChart.Dock = System.Windows.Forms.DockStyle.Fill;
-            legend1.Name = "Legend1";
-            this.myChart.Legends.Add(legend1);
+            legend4.Name = "Legend1";
+            this.myChart.Legends.Add(legend4);
             this.myChart.Location = new System.Drawing.Point(0, 0);
             this.myChart.Margin = new System.Windows.Forms.Padding(2);
             this.myChart.Name = "myChart";
-            series1.ChartArea = "ChartArea1";
-            series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series1.Legend = "Legend1";
-            series1.Name = "Series1";
-            this.myChart.Series.Add(series1);
-            this.myChart.Size = new System.Drawing.Size(781, 453);
+            series4.ChartArea = "ChartArea1";
+            series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series4.Legend = "Legend1";
+            series4.Name = "Series1";
+            this.myChart.Series.Add(series4);
+            this.myChart.Size = new System.Drawing.Size(782, 469);
             this.myChart.TabIndex = 5;
             this.myChart.Text = "chart1";
             this.myChart.TextAntiAliasingQuality = System.Windows.Forms.DataVisualization.Charting.TextAntiAliasingQuality.Normal;
-            title1.Name = "Title1";
-            title1.Text = "---";
-            this.myChart.Titles.Add(title1);
+            title4.Name = "Title1";
+            title4.Text = "---";
+            this.myChart.Titles.Add(title4);
             this.myChart.Visible = false;
             // 
             // panelXray
             // 
             this.panelXray.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panelXray.Location = new System.Drawing.Point(0, 284);
+            this.panelXray.Location = new System.Drawing.Point(0, 300);
             this.panelXray.Margin = new System.Windows.Forms.Padding(2);
             this.panelXray.Name = "panelXray";
-            this.panelXray.Size = new System.Drawing.Size(781, 169);
+            this.panelXray.Size = new System.Drawing.Size(782, 169);
             this.panelXray.TabIndex = 0;
             // 
             // backgroundWorker1
@@ -227,18 +229,34 @@
             // 
             // timer1
             // 
-            this.timer1.Interval = 3000;
+            this.timer1.Interval = 4000;
             this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
             // 
+            // pictureBox2
+            // 
+            this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
+            this.pictureBox2.Location = new System.Drawing.Point(386, 0);
+            this.pictureBox2.Margin = new System.Windows.Forms.Padding(2);
+            this.pictureBox2.Name = "pictureBox2";
+            this.pictureBox2.Size = new System.Drawing.Size(394, 300);
+            this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+            this.pictureBox2.TabIndex = 0;
+            this.pictureBox2.TabStop = false;
+            //this.pictureBox2.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
+            //this.pictureBox2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick);
+            //this.pictureBox2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
+            //this.pictureBox2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
+            // 
             // OTSMeasureStatusWindow
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.AutoSize = true;
-            this.ClientSize = new System.Drawing.Size(781, 453);
+            this.ClientSize = new System.Drawing.Size(782, 469);
             this.CloseButton = false;
             this.CloseButtonVisible = false;
             this.Controls.Add(this.panelXray);
+            this.Controls.Add(this.pictureBox2);
             this.Controls.Add(this.picBox);
             this.Controls.Add(this.myChart);
             this.DockAreas = ((OTS.WinFormsUI.Docking.DockAreas)((OTS.WinFormsUI.Docking.DockAreas.DockTop | OTS.WinFormsUI.Docking.DockAreas.Document)));
@@ -251,6 +269,7 @@
             ((System.ComponentModel.ISupportInitialize)(this.picBox)).EndInit();
             this.contextMenuStrip1.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.myChart)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -276,5 +295,6 @@
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
         private System.ComponentModel.BackgroundWorker backgroundWorker1;
         private System.Windows.Forms.Timer timer1;
+        public System.Windows.Forms.PictureBox pictureBox2;
     }
 }

+ 201 - 178
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs

@@ -11,7 +11,6 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
-using System.Drawing.Imaging;
 using System.IO;
 using System.Reflection;
 using System.Windows.Forms;
@@ -131,7 +130,7 @@ namespace OTSMeasureApp
             //显示灰度曲线图
             GrayLevelChart = 2,
             //线扫描曲线
-            GrayLevelLine = 3,
+            GrayLevelLineScan = 3,
             //显示去背景BSE图灰度曲线
             GrayAbandonLevelChart = 4,
             //
@@ -140,10 +139,10 @@ namespace OTSMeasureApp
         //图bfResult
         public static bool bfResult = false;
         //当前是否显示线扫描
-        public static bool IsShowGrayLevelLine = false;
+        //public static bool IsShowGrayLevelLine = false;
         //当前默认值
         ImageType m_imagetype = ImageType.BSEImage;
-        ImageType m_IsShowImageType = ImageType.BSEImage;
+        //ImageType m_IsShowImageType = ImageType.BSEImage;
 
 
         public OTSMeasureStatusWindow(OTSIncAMeasureAppForm MeasureApp)
@@ -159,6 +158,14 @@ namespace OTSMeasureApp
             //国际化
             lan = new OTSCommon.Language(this);
             table = lan.GetNameTable(this.Name);
+            if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
+            {
+                contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
+            }
+            else
+            {
+                contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
+            }
         }
         /// <summary>
         /// 在控件中显示BSE图像
@@ -166,12 +173,12 @@ namespace OTSMeasureApp
         /// <param name="m_iWidth"></param>
         /// <param name="m_iHeigh"></param>
         /// <param name="bBseData"></param>
-        public void ShowImage(int m_iWidth, int m_iHeigh, byte[] bBseData)
+        public void ShowImage(int iWidth, int iHeight, byte[] bBseData)
         {
             try
             {
-                Bitmap bitmap = CImageHandler.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
-                ShowBitmap(m_iWidth, m_iHeigh, bitmap);
+                Bitmap bitmap = CImageHandler.ToGrayBitmap(bBseData, iWidth, iHeight);
+                ShowBitmapInPicbox1(bitmap);
             }
             catch (Exception e)
             {
@@ -180,11 +187,12 @@ namespace OTSMeasureApp
 
 
         }
-        public void ShowBitmap(int m_iWidth, int m_iHeigh, Bitmap coloredImage)
+
+        public void ShowBitmapInPicbox1(Bitmap bmpImage)
         {
 
 
-            picBox.Image = coloredImage;
+            picBox.Image = bmpImage;
             //设置Pictrue显示位置
             picBox.Height = this.RestoreBounds.Height;
             picBox.Width = this.RestoreBounds.Height * 4 / 3;
@@ -199,6 +207,44 @@ namespace OTSMeasureApp
             picBox.Top = 0;
             picBox.Show();
 
+            pictureBox2.Visible = false;
+
+
+
+
+        }
+        public void ShowDoubleImage(Bitmap image1, Bitmap image2)
+        {
+
+            if (image1 != null)
+            {
+                picBox.Image = image1;
+            }
+
+            //设置Pictrue显示位置
+            picBox.Height = this.RestoreBounds.Height;
+            picBox.Width = this.RestoreBounds.Height * 2 / 3;
+            //获取黄线坐标位置
+            Rectangle rectangle = GetPictureBoxZoomSize(picBox);
+            m_GetBSEImageInitPoint = rectangle.Location;
+            pointStart.X = rectangle.X;
+            pointEnd.X = rectangle.X + rectangle.Width;
+            pointStart.Y = rectangle.Y + (rectangle.Height) / 2;
+            pointEnd.Y = rectangle.Y + (rectangle.Height) / 2;
+            picBox.Left = 0;
+            picBox.Top = 0;
+            picBox.Show();
+            if (image2 != null)
+            {
+                pictureBox2.Image = image2;
+            }
+
+            pictureBox2.Height = this.RestoreBounds.Height;
+            pictureBox2.Width = this.RestoreBounds.Height * 2 / 3;
+            pictureBox2.Left = this.RestoreBounds.Width / 2;
+            pictureBox2.Top = 0;
+            pictureBox2.Show();
+
         }
 
         /// <summary>
@@ -264,7 +310,7 @@ namespace OTSMeasureApp
             }
             //设置右键菜单中的项 是否可编辑
             SetContextMenuEnabled(true);
-           bool rst= AcquireBSEImage();
+            bool rst = AcquireBSEImage();
 
             //取图不成功就返回
             if (rst)
@@ -287,13 +333,11 @@ namespace OTSMeasureApp
                 //显示单点扫描元素信息菜单
                 contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = true;
             }
-            m_IsShowImageType = ImageType.BSEImage;
+            //m_IsShowImageType = ImageType.BSEImage;
             m_imagetype = ImageType.BSEImage;
-            
-            ShowImage(m_iWidth, m_iHeight, originalBseData);
+            Bitmap bitmap = CImageHandler.ToGrayBitmap(originalBseData, m_iWidth, m_iHeight);
+            ShowBitmapInPicbox1(bitmap);
 
-            IsShowGrayLevelLine = false;
-            //获取默认Y轴
 
 
             myChart.Visible = false;
@@ -357,13 +401,15 @@ namespace OTSMeasureApp
 
 
             return rst;
-          
-           
+
+
 
         }
         private void UpdateImageAndLineScanChart()
         {
-            ShowImage(m_iWidth, m_iHeight, originalBseData);
+            Bitmap bitmap = CImageHandler.ToGrayBitmap(originalBseData, m_iWidth, m_iHeight);
+            ShowBitmapInPicbox1(bitmap);
+
             //获取灰度图数据
             dGrayLevelData = new double[(int)GrayLevel.Max];
             dGrayLevelData = GetGaryData(originalBseData, dGrayLevelData);
@@ -384,9 +430,9 @@ namespace OTSMeasureApp
             {
                 YData[i] = (int)dGrayLevelData[i];
             }
-            chartData(XData, YData);
+            DisChartData(XData, YData, ImageType.GrayLevelLineScan);
             picBox.Refresh();
-          
+
 
         }
         public double[] GetGaryData(byte[] Imagedata, double[] GrayLevelData)
@@ -411,7 +457,7 @@ namespace OTSMeasureApp
             IScanController cfun = ScanController.GetScanController();
             ISemController sem = SemController.GetSEMController();
 
-            //int GetImgCount = 0;
+           
             try
             {
                 //连接电镜
@@ -445,7 +491,7 @@ namespace OTSMeasureApp
         }
         #endregion
 
-       
+
 
 
         //显示去背景图 = AUTO
@@ -454,6 +500,7 @@ namespace OTSMeasureApp
         {
             //设置右键菜单中的项 是否可编辑
             SetContextMenuEnabled(true);
+            m_imagetype = ImageType.RemoveBGImage;
             ShowRemoveBGImage();
             m_CurrentMultiple = 0;
             panelXray.Visible = false;
@@ -478,18 +525,9 @@ namespace OTSMeasureApp
             var imageHandle = new CImageHandler();
 
             bfResult = imageHandle.GetBSEImage(imageProcessParam, pixelSize, originalBseData, m_iWidth, m_iHeight, ref removeBGBseData);
-            m_IsShowImageType = ImageType.RemoveBGImage;
 
-            //获取去背景灰度图数据
-            dGrayAbandonLevelData = new double[(int)GrayLevel.Max];
-            dGrayAbandonLevelData = GetGrayAbandonData(removeBGBseData, dGrayAbandonLevelData);
 
-            //计算灰度去背景最大值
-            dGrayAbandonLevelMax = dGrayAbandonLevelData[0];
-            for (int i = 1; i < (int)GrayLevel.Max; i++)
-            {
-                dGrayAbandonLevelMax = Math.Max(dGrayAbandonLevelMax, dGrayAbandonLevelData[i]);
-            }
+
 
 
 
@@ -499,11 +537,10 @@ namespace OTSMeasureApp
 
 
 
+            Bitmap bitmap = CImageHandler.ToGrayBitmap(removeBGBseData, m_iWidth, m_iHeight);
+            ShowDoubleImage((Bitmap)picBox.Image, bitmap);
 
-
-            ShowImage(m_iWidth, m_iHeight, removeBGBseData);
-
-            IsShowGrayLevelLine = false;
+          
 
             myChart.Visible = false;
 
@@ -555,23 +592,16 @@ namespace OTSMeasureApp
 
 
 
-            ShowBitmap(m_iWidth, m_iHeight, coloredParticleImage);
+            ShowDoubleImage((Bitmap)picBox.Image, coloredParticleImage);
 
-            IsShowGrayLevelLine = false;
+          
 
 
             myChart.Visible = false;
             picBox.Show();
             //切换显示至BSE图
             contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
-            if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
-            {
-                contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
-            }
-            else
-            {
-                contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
-            }
+
 
         }
 
@@ -583,29 +613,19 @@ namespace OTSMeasureApp
             //设置右键菜单中的项 是否可编辑
             SetContextMenuEnabled(false);
             ShowGrayLevelImage();
-            myChart.Visible = true;
-            panelXray.Visible = false;
-            IsShowGrayLevelLine = false;
+
         }
         protected void ShowGrayLevelImage()
         {
 
-            m_imagetype = ImageType.GrayLevelChart;
-
-            picBox.Hide();
 
             //切换显示至BSE图
             contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
             contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
-            if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
-            {
-                contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
-            }
-            else
-            {
-                contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
-            }
-          
+
+            //获取灰度图数据
+            dGrayLevelData = new double[(int)GrayLevel.Max];
+            dGrayLevelData = GetGaryData(originalBseData, dGrayLevelData);
 
             int[] XData = new int[(int)GrayLevel.Max];
             for (int i = 0; i < (int)GrayLevel.Max; i++)
@@ -617,7 +637,7 @@ namespace OTSMeasureApp
             {
                 YData[i] = (int)dGrayLevelData[i];
             }
-            chartData(XData, YData);
+            DisChartData(XData, YData, ImageType.GrayLevelChart);
 
 
 
@@ -628,25 +648,17 @@ namespace OTSMeasureApp
         #region  显示线扫描曲线
         private void ShowLineScanChart_Click(object sender, EventArgs e)
         {
+            ShowBitmapInPicbox1((Bitmap)picBox.Image);
             if (MenuItemLineScan.Checked)
             {
-                IsShowGrayLevelLine = true;
+                m_imagetype = ImageType.GrayLevelLineScan;
+                timer1.Enabled = true;
 
             }
-            else
-            {
-                IsShowGrayLevelLine = false;
-            }
 
-            panelXray.Visible = false;
-
-            picBox.Refresh();
-            if (IsShowGrayLevelLine)
-            {
-                timer1.Enabled = true;
-            }
-            else 
+            else
             {
+                m_imagetype = ImageType.BSEImage;
                 timer1.Enabled = false;
             }
 
@@ -709,7 +721,7 @@ namespace OTSMeasureApp
         {
             if (e.Button != MouseButtons.Right)
             {
-                if (!IsShowGrayLevelLine)
+                if (m_imagetype != ImageType.GrayLevelLineScan)
                 {
                     if (m_ElementPointGDIObjects != null)
                     {
@@ -754,7 +766,7 @@ namespace OTSMeasureApp
             PointScanElementMenuItem.Enabled = isEnabled;
             bool showExprot = m_ElementPointGDIObjects.Count > 0 ? true : false;
             ExportScanInfoMenuItem.Enabled = showExprot;
-            IsShowGrayLevelLine = false;
+            //IsShowGrayLevelLine = false;
             VisualAdjustingMenu.Enabled = isEnabled;
             toolStripMenuItem1.Enabled = true;
             this.Cursor = Cursors.Default;
@@ -769,14 +781,14 @@ namespace OTSMeasureApp
 
 
             Stream stream = null;
-            if (m_IsShowImageType == ImageType.BSEImage)
-            {
-                stream = new MemoryStream(originalBseData);
-            }
-            else if (m_IsShowImageType == ImageType.RemoveBGImage)
-            {
-                stream = new MemoryStream(removeBGBseData);
-            }
+            //if (m_imagetype == ImageType.BSEImage)
+            //{
+            stream = new MemoryStream(originalBseData);
+            //}
+            //else if (m_imagetype == ImageType.RemoveBGImage)
+            //{
+            //    stream = new MemoryStream(removeBGBseData);
+            //}
             if (iHeight >= 0)
             {
                 stream.Seek(iHeight * iWidth, SeekOrigin.Begin);
@@ -876,66 +888,67 @@ namespace OTSMeasureApp
         {
 
 
-            if (bfResult)
+            if (!bfResult)
+            {
+                return;
+            }
+            if (m_imagetype == ImageType.GrayLevelLineScan)
             {
-                if (IsShowGrayLevelLine)
-                {
 
-                    Rectangle rectangle = GetPictureBoxZoomSize(picBox);
-                    if (pointStart.Equals(pointEnd))
-                    {
-                        return;
-                    }
-                    Point start = new Point(100, pointStart.Y);
-                    Point end = new Point(500, pointEnd.Y);
+                Rectangle rectangle = GetPictureBoxZoomSize(picBox);
+                if (pointStart.Equals(pointEnd))
+                {
+                    return;
+                }
+                Point start = new Point(100, pointStart.Y);
+                Point end = new Point(500, pointEnd.Y);
 
-                    double rate = (double)picBox.Image.Height / (double)rectangle.Height;
-                    int YSize = Convert.ToInt32((rate * (double)pointStart.Y));
-                    //显示线扫描 黄色线的曲线数据
+                double rate = (double)picBox.Image.Height / (double)rectangle.Height;
+                int YSize = Convert.ToInt32((rate * (double)pointStart.Y));
+                //显示线扫描 黄色线的曲线数据
 
-                    var Imagedata = new byte[m_iWidth];
-                    GetYSize();
+                var Imagedata = new byte[m_iWidth];
+             
+                YSize = Convert.ToInt32((rate * (double)pointStart.Y));
 
-                    GetLineImage(YSize, m_iWidth, ref Imagedata);
+                GetLineImage(YSize, m_iWidth, ref Imagedata);
 
 
 
-                    DrawCurve(Imagedata, e);
+                DrawCurve(Imagedata, e);
 
-                    e.Graphics.DrawLine(new Pen(Color.Red), new Point(rectangle.X, rectangle.Y + (rectangle.Height) / 4), new Point(rectangle.X + rectangle.Width, rectangle.Y + (rectangle.Height) / 4));
-                    e.Graphics.DrawLine(new Pen(Color.Red), new Point(rectangle.X, rectangle.Y + rectangle.Height * 3 / 4), new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height * 3 / 4));
-                    e.Graphics.DrawLine(new Pen(Color.Blue), new Point(rectangle.X, pointStart.Y), new Point(rectangle.X + rectangle.Width, pointEnd.Y));
+                e.Graphics.DrawLine(new Pen(Color.Red), new Point(rectangle.X, rectangle.Y + (rectangle.Height) / 4), new Point(rectangle.X + rectangle.Width, rectangle.Y + (rectangle.Height) / 4));
+                e.Graphics.DrawLine(new Pen(Color.Red), new Point(rectangle.X, rectangle.Y + rectangle.Height * 3 / 4), new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height * 3 / 4));
+                e.Graphics.DrawLine(new Pen(Color.Blue), new Point(rectangle.X, pointStart.Y), new Point(rectangle.X + rectangle.Width, pointEnd.Y));
 
-                    #region 绘制刻度条
-                    float offHeight = (rectangle.Y + (rectangle.Height) / 4) - (rectangle.Y + rectangle.Height * 3 / 4);
-                    float grayValue = Math.Abs(offHeight / 255);
-                    //设置文字对齐方式
-                    StringFormat sf = new StringFormat();
-                    sf.Alignment = StringAlignment.Center;
-                    sf.LineAlignment = StringAlignment.Center;
-                    SolidBrush solidBrush = new SolidBrush(Color.FromArgb(100, Color.Red));
-                    //字体大小 根据样品孔Rectangle大小
-                    float fontSize = 15;
-                    Font font = new Font("黑体", fontSize, FontStyle.Bold);
+                #region 绘制刻度条
+                float offHeight = (rectangle.Y + (rectangle.Height) / 4) - (rectangle.Y + rectangle.Height * 3 / 4);
+                float grayValue = Math.Abs(offHeight / 255);
+                //设置文字对齐方式
+                StringFormat sf = new StringFormat();
+                sf.Alignment = StringAlignment.Center;
+                sf.LineAlignment = StringAlignment.Center;
+                SolidBrush solidBrush = new SolidBrush(Color.FromArgb(100, Color.Red));
+                //字体大小 根据样品孔Rectangle大小
+                float fontSize = 15;
+                Font font = new Font("黑体", fontSize, FontStyle.Bold);
 
-                    Pen pen = new Pen(Color.Red, 1);
-                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
-                    pen.DashPattern = new float[] { 5, 5 };
-                    int fontOffWidth = 50;
-                    int fontOffHeight = 10;
+                Pen pen = new Pen(Color.Red, 1);
+                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
+                pen.DashPattern = new float[] { 5, 5 };
+                int fontOffWidth = 50;
+                int fontOffHeight = 10;
 
-                    int scaleLine = 0;
-                    for (int i = 25; i <= 225; i += 25)
-                    {
-                        scaleLine = (int)(grayValue * i);
-                        e.Graphics.DrawLine(pen, new Point(rectangle.X, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine), new Point(rectangle.X + fontOffWidth, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine));
-                        e.Graphics.DrawString(i.ToString(), font, solidBrush, rectangle.X + 20, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine - fontOffHeight, sf);
-                    }
-                    #endregion
+                int scaleLine = 0;
+                for (int i = 25; i <= 225; i += 25)
+                {
+                    scaleLine = (int)(grayValue * i);
+                    e.Graphics.DrawLine(pen, new Point(rectangle.X, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine), new Point(rectangle.X + fontOffWidth, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine));
+                    e.Graphics.DrawString(i.ToString(), font, solidBrush, rectangle.X + 20, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine - fontOffHeight, sf);
                 }
-
+                #endregion
             }
-            if (!MenuItemLineScan.Checked)
+            else          
             {
                 if (m_ElementPointGDIObjects != null)
                 {
@@ -1011,25 +1024,15 @@ namespace OTSMeasureApp
                     if (imageY > 1)
                     {
                         startimageX = startimageX + (startimageY * m_iWidth);
-                        if (m_IsShowImageType == ImageType.BSEImage)
-                        {
-                            grayValue = originalBseData[startimageX];
-                        }
-                        else
-                        {
-                            grayValue = removeBGBseData[startimageX];
-                        }
+                        
+                        grayValue = originalBseData[startimageX];
+                        
                     }
                     else if (startimageY == 1)
                     {
-                        if (m_IsShowImageType == ImageType.BSEImage)
-                        {
-                            grayValue = originalBseData[startimageX];
-                        }
-                        else
-                        {
-                            grayValue = removeBGBseData[startimageX];
-                        }
+                       
+                        grayValue = originalBseData[startimageX];
+                       
                     }
                 }
                 else
@@ -1070,7 +1073,7 @@ namespace OTSMeasureApp
             }
             //此处调接口显示灰度值
             m_MeasureAppForm.ShowGrayVal(strGrayValue.ToString());
-            if (!IsShowGrayLevelLine)
+            if (m_imagetype != ImageType.GrayLevelLineScan)
             {
                 if (m_ElementPointGDIObjects != null)
                 {
@@ -1122,9 +1125,7 @@ namespace OTSMeasureApp
             //设置右键菜单中的项 是否可编辑
             SetContextMenuEnabled(false);
             ShowAbandonGrayLevelImage();
-            myChart.Visible = true;
-            panelXray.Visible = false;
-            IsShowGrayLevelLine = false;
+
         }
         private double[] GetGrayAbandonData(byte[] Imagedata, double[] GrayAbandonLevelData)
         {
@@ -1150,7 +1151,11 @@ namespace OTSMeasureApp
 
 
             var imageHandle = new CImageHandler();
-            bfResult = imageHandle.GetBSEImage(WSample.GetMsrParams().GetImageProcessParam(), pixelSize, originalBseData, m_iWidth, m_iHeight, ref removeBGBseData);
+            if (removeBGBseData == null)
+            {
+                bfResult = imageHandle.GetBSEImage(WSample.GetMsrParams().GetImageProcessParam(), pixelSize, originalBseData, m_iWidth, m_iHeight, ref removeBGBseData);
+            }
+
             if (bfResult)
             {
                 dGrayAbandonLevelData = new double[(int)GrayLevel.Max];
@@ -1165,7 +1170,7 @@ namespace OTSMeasureApp
                 }
             }
 
-            picBox.Hide();
+            //picBox.Hide();
 
 
             int[] XData = new int[(int)GrayLevel.Max];
@@ -1178,7 +1183,7 @@ namespace OTSMeasureApp
             {
                 YData[i] = (int)dGrayAbandonLevelData[i];
             }
-            chartData(XData, YData);
+            DisChartData(XData, YData, ImageType.GrayAbandonLevelChart);
 
 
         }
@@ -1215,11 +1220,13 @@ namespace OTSMeasureApp
             if (originalBseData != null)
             {
                 //用于线扫描曲线
-                m_IsShowImageType = ImageType.BSEImage;
+
                 m_imagetype = ImageType.BSEImage;
                 //在控件中显示图像
-                ShowImage(m_iWidth, m_iHeight, originalBseData);
-                picBox.Show();
+                Bitmap bitmap = CImageHandler.ToGrayBitmap(originalBseData, m_iWidth, m_iHeight);
+                ShowBitmapInPicbox1(bitmap);
+
+
 
             }
 
@@ -1395,17 +1402,11 @@ namespace OTSMeasureApp
 
         }
         #endregion
-        #region 获取线扫描初始位置
-        public void GetYSize()
-        {
-            Rectangle rectangle = GetPictureBoxZoomSize(picBox);
-            double rate = (double)picBox.Image.Height / (double)rectangle.Height;
-            YSize = Convert.ToInt32((rate * (double)pointStart.Y));
-        }
-        #endregion
 
-        public void chartData(int[] XData, int[] YData)
+
+        public void DisChartData(int[] XData, int[] YData, ImageType imgtype)
         {
+            m_imagetype = imgtype;
             //添加数据
             myChart.Series[0].Points.DataBindXY(XData, YData);
             myChart.Series[0].Label = "";
@@ -1414,22 +1415,35 @@ namespace OTSMeasureApp
             myChart.Series[0].Name = "Graph";
 
             myChart.Series[0].IsVisibleInLegend = false;
-            switch (m_imagetype)
+            switch (imgtype)
             {
                 case ImageType.GrayLevelChart:
 
                     myChart.Titles[0].Text = "B-GrayCurve";
-
+                    picBox.Hide();
+                    pictureBox2.Hide();
+                    myChart.Visible = true;
                     break;
                 case ImageType.GrayAbandonLevelChart:
 
                     myChart.Titles[0].Text = "Remove Background Gray-scaleCurve";
+                    picBox.Hide();
+                    pictureBox2.Hide();
+                    myChart.Visible = true;
+                    break;
+                case ImageType.GrayLevelLineScan:
 
+                    pictureBox2.Hide();
+                    myChart.Visible = true;
                     break;
                 default:
                     myChart.Titles[0].Text = "";
                     break;
             }
+
+
+          
+            panelXray.Visible = false;
         }
 
         private void PointScanElementMenuItem_Click(object sender, EventArgs e)
@@ -1785,6 +1799,10 @@ namespace OTSMeasureApp
         //在picturebox鼠标缩放
         private void pbBSEImage_MouseWheel(object sender, MouseEventArgs e)
         {
+            if (m_imagetype != ImageType.BSEImage)
+            {
+                return;
+            }
             //鼠标滚动缩放 BSE图
             if (e.Delta > 0)
             {
@@ -1850,7 +1868,7 @@ namespace OTSMeasureApp
             }
         }
 
-        
+
 
         private void OTSMeasureStatusWindow_MouseClick(object sender, MouseEventArgs e)
         {
@@ -1946,6 +1964,7 @@ namespace OTSMeasureApp
         {
             //设置右键菜单中的项 是否可编辑
             SetContextMenuEnabled(true);
+            m_imagetype = ImageType.RemoveBGImage;
             ShowColoredRemoveBGImage();
             m_CurrentMultiple = 0;
             panelXray.Visible = false;
@@ -1953,30 +1972,34 @@ namespace OTSMeasureApp
 
         private void timer1_Tick(object sender, EventArgs e)
         {
-            log.Info("begin to acquire image");
-            bool rst = AcquireBSEImage();
-            if (rst)
+
+            if (!backgroundWorker1.IsBusy)
             {
                 backgroundWorker1.RunWorkerAsync();
             }
-           
+
+
+
         }
 
         private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
         {
-            
-          
-           
 
             //更新当前的图
+            log.Info("begin to acquire image");
            
+            bool rst = AcquireBSEImage();
+            if (m_imagetype == ImageType.GrayLevelLineScan)
+            {
                 log.Info("begin to show image");
                 UpdateImageAndLineScanChart();
-
+            }
            
+
+
         }
 
-      
+
     }
 }
 

+ 2 - 2
OTSIncAMeasureApp/ServiceCenter/CClassifyEngine.cs

@@ -54,9 +54,9 @@ namespace OTSModelSharp.ServiceCenter
             return this;
         }
 
-        public double IfNeedMaxEDS(COTSParticleClr particle)
+        public bool  IfNeedMaxEDS(COTSParticleClr particle,ref double maxeds)
         {
-           return myEng.IfNeedMaxEDS(particle);
+           return myEng.IfNeedMaxEDS(particle,ref maxeds);
         }
 
         public bool ClassifyBySpectrum(COTSParticleClr particle)

+ 79 - 4
OTSIncAMeasureApp/ServiceCenter/CImageHandler.cs

@@ -413,7 +413,83 @@ namespace OTSModelSharp.ServiceCenter
 
             return;
         }
-       
+        public void GetImageWithBlackColoredParts(List<COTSParticleClr> analysitParts, ref Bitmap a_pBmpOut)
+        {
+
+
+          
+
+
+            for (int i = 0; i < a_pBmpOut.Width; i++)
+            {
+                for (int j = 0; j < a_pBmpOut.Height; j++)
+                {
+                    a_pBmpOut.SetPixel(i, j, Color.White);
+                }
+
+            }
+            //Random c = new Random();
+           
+
+
+            foreach (var p in analysitParts)
+            {
+
+                Color cValue = Color.Black;
+                foreach (var s in p.GetFeature().GetSegmentsList())
+                {
+
+                    for (int i = s.GetStart(); i < s.GetStart() + s.GetLength(); i++)
+                    {
+
+                        a_pBmpOut.SetPixel(i, s.GetHeight(), cValue);
+                    }
+                }
+
+            }
+
+        
+            return;
+        }
+        public void GetImageWithSTDColoredParts(List<COTSParticleClr> analysitParts, ref Bitmap a_pBmpOut)
+        {
+
+
+
+
+
+            for (int i = 0; i < a_pBmpOut.Width; i++)
+            {
+                for (int j = 0; j < a_pBmpOut.Height; j++)
+                {
+                    a_pBmpOut.SetPixel(i, j, Color.White);
+                }
+
+            }
+            //Random c = new Random();
+
+
+
+            foreach (var p in analysitParts)
+            {
+
+                Color cValue = ColorTranslator.FromHtml(p.GetTypeColor()) ;
+                foreach (var s in p.GetFeature().GetSegmentsList())
+                {
+
+                    for (int i = s.GetStart(); i < s.GetStart() + s.GetLength(); i++)
+                    {
+
+                        a_pBmpOut.SetPixel(i, s.GetHeight(), cValue);
+                    }
+                }
+
+            }
+
+
+            return;
+        }
+
         public Color GetRandomColor30(Random r)
         {
            
@@ -557,7 +633,6 @@ namespace OTSModelSharp.ServiceCenter
             
             parts = flddataclr.GetParticleList();
             
-            //currentField.FilterParticles(m_Sample.GetMsrParams().GetXRayParam());//filter according to the xraylimit
            
             currentField.SetListAnalysisParticles(parts);
           
@@ -588,7 +663,7 @@ namespace OTSModelSharp.ServiceCenter
             prmclr.SetParticleGray(r3);
             prmclr.SetBGRemoveType((int)a_oSource.GetBGRemoveType());
             prmclr.SetAutoBGRemoveType((int)a_oSource.GetAutoBGRemoveType());
-            //prmclr.SetErrodDilateParam(a_oSource.GetErrodDilateParam());
+          
             prmclr.SetOverlapParam(a_oSource.GetOverlapParam());
 
             return prmclr;
@@ -612,7 +687,7 @@ namespace OTSModelSharp.ServiceCenter
                 }
                 fldclrs.Add(fldclr);
             }
-            //ImageProForClr imgpro = new ImageProForClr();
+           
 
             imgProEngine.MergeBigBoundaryParticles(fldclrs, pixelSize, scanFieldSize, ResolutionSize, mergedParts);
             return true;

+ 1 - 1
OTSIncAMeasureApp/ServiceCenter/IClassifyEngine.cs

@@ -11,7 +11,7 @@ namespace OTSModelSharp.ServiceCenter
     public interface IClassifyEngine
     {
         IClassifyEngine GetExpressionClassifyEngine(string libName);
-        double IfNeedMaxEDS(COTSParticleClr particle);//belong to expressengine
+        bool IfNeedMaxEDS(COTSParticleClr particle,ref double maxeds);//belong to expressengine
         IClassifyEngine GetSpectrumCompareEngine(string libName);
         IClassifyEngine GetIncClassifyEngine();
 

+ 1 - 24
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -2406,30 +2406,7 @@ namespace OTSIncAReportGraph.Controls
         private void 全部ToolStripMenuItem_Click(object sender, EventArgs e)
         {
             Cursor = Cursors.WaitCursor;
-            ////m_CurGBFields.Clear();
-            //var tbl = GetAllPartsOfCurrentGBField();
-            //if (tbl.Rows.Count > 0)
-            //{
-            //    foreach (DataRow r in tbl.Rows)
-            //    {
-            //        int fid = Convert.ToInt32(r["fieldId"]);
-            //        int pid = Convert.ToInt32(r["particleId"]);
-            //        foreach (DisplayRectangle a_field in m_list_allDfield)
-            //        {
-            //            if (int.Parse(a_field.FieldID) == fid)
-            //            {
-            //                foreach (var p in a_field.List_DParticle)
-            //                {
-            //                    if (p.objParticleData.ParticleId == pid)
-            //                    {
-            //                        p.IsSelect = true;
-            //                        break;
-            //                    }
-            //                }
-            //            }
-            //        }
-            //    }
-            //}
+            
             DisplayGBParticles("A");
             DisplayGBParticles("B");
             DisplayGBParticles("C");

+ 10 - 2
OxfordExtenderWrapper/ExtenderWrapper.cs

@@ -692,10 +692,18 @@ namespace OxfordExtenderWrapper
             {
                 prm.b_quant = a_bElementInfo;
                 List<Chord> Chords = new List<Chord>();
-
+                Chord chord;
                 foreach (Segment seg in prm.a_listChord)
                 {
-                    Chord chord = new Chord(seg.X, seg.Y, seg.Length);
+                    if (seg.Length >= 3)
+                    {
+                         chord = new Chord(seg.X+1, seg.Y, seg.Length-2);//get the middle part
+                    }
+                    else 
+                    {
+                         chord = new Chord(seg.X, seg.Y, seg.Length);
+                    }
+                    
                     Chords.Add(chord);
                 }
                 var chordsList = new ChordList(Chords, m_dImagePixelsize);