瀏覽代碼

Merge branch 'dev' into Release2.4

gsp 3 年之前
父節點
當前提交
1ddc16000b

+ 4 - 0
Bin/x64/Debug/Resources/XMLData/AppResource_EN.xml

@@ -852,6 +852,10 @@
 	  <Control name="str8" text="Copy Image" />
 	  <Control name="str9" text="Move SEM to current position" />
 	  <Control name="str10" text="Move SEM to particle view position" />
+	  <Control name="str11" text="Confirm split?" />
+	  <Control name="str12" text="Too many divisions!" />
+	  <Control name="str13" text="Split failed!" />
+	  <Control name="str14" text="No intersection!" />
 	  
 	  <Control name="MouseMove1" text="Particle SEM location:" />
 	  <Control name="MouseMove2" text="Grayscale#" />

+ 4 - 0
Bin/x64/Debug/Resources/XMLData/AppResource_ZH.xml

@@ -850,6 +850,10 @@
 	  <Control name="str8" text="复制当前屏幕图像" />
 	  <Control name="str9" text="移动SEM到当前位置" />
 	  <Control name="str10" text="移动SEM到颗粒视域位置" />
+	  <Control name="str11" text="确认分割?" />
+	  <Control name="str12" text="分割数量过多!" />
+	  <Control name="str13" text="分割失败!" />
+	  <Control name="str14" text="没有相交点!" />
 	  
 	  <Control name="MouseMove1" text="颗粒SEM位置:" />
 	  <Control name="MouseMove2" text="灰度#" />

+ 29 - 0
OTSIncAMeasureApp/0-OTSModel/Measure/4-ReMeasure/SmplMeasureReMeasure.cs

@@ -1,6 +1,7 @@
 using OTSCLRINTERFACE;
 using OTSCommon;
 using OTSCommon.Model;
+using OTSDataType;
 using OTSModelSharp;
 using OTSModelSharp.DTLBase;
 using OTSModelSharp.ServiceCenter;
@@ -11,6 +12,7 @@ using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Forms;
 using static OTSDataType.otsdataconst;
 
 namespace OTSMeasureApp._0_OTSModel.Measure._4_ReMeasure
@@ -21,6 +23,29 @@ namespace OTSMeasureApp._0_OTSModel.Measure._4_ReMeasure
         ScanController scan = ScanController.GetScanController();
         EDSController eds = EDSController.GetEDSController();
 
+        public byte[] SetReFldInfo(string sampleName, CBSEImgClr a_pBSEImg)
+        {
+            OTSIncAMeasureAppForm aMeasureAppForm = (OTSIncAMeasureAppForm)Application.OpenForms["OTSIncAMeasureAppForm"];
+            COTSSample sampleClr = aMeasureAppForm.m_ProjData.GetSampleByName(sampleName);
+            curFldData = new COTSFieldData(a_pBSEImg, sampleClr.CalculatePixelSize());
+            curFldData.SetId(0);
+            curFldData.SetBSEImage(a_pBSEImg);
+            SetSample(sampleClr);
+            return a_pBSEImg.GetImageDataPtr();
+        }
+
+        public bool FindNewPartInfo(Particle particle)
+        {
+            GetOriginalParticles();
+
+            foreach (COTSParticleClr item in curFldData.GetAllParticles())
+            {
+
+            }
+
+            return true;
+        }
+
         public bool ReMeasure(string samplePath, int width, int height, Dictionary<int, List<Particle>> keyValues, int IMGSCANSPEED_INDEX, int XRAYSCANMODE_INDEX, int NUD_SCANTIME_COUNT)
         {
             try
@@ -50,6 +75,10 @@ namespace OTSMeasureApp._0_OTSModel.Measure._4_ReMeasure
                 sQLiteHelper.GetDBConnection();
                 sQLiteHelper.BeginTransaction();
                 log.Info("Begin to process field count : " + keyValues.Count);
+
+                GetOriginalParticles();
+
+
                 //按帧图分析
                 for (int i = 0; i < keyValues.Count; i++)
                 {

+ 86 - 1
OTSIncAMeasureApp/ServiceCenter/DTLBase/SQliteHelper.cs

@@ -1,4 +1,5 @@
-using OTSModelSharp.DTLBase;
+using OTSCommon.Model;
+using OTSModelSharp.DTLBase;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -191,6 +192,90 @@ namespace OTSModelSharp.DTLBase
             return affectedRows;
         }
 
+        #region 颗粒分割部分
+        public int ExecuteNewPartIdForTransaction()
+        {
+            DataTable dt = ExecuteQuery("SELECT MAX(XrayId) FROM IncAData");
+            if (dt.Rows.Count == 0)
+            {
+                return 0;
+            }
+            return int.Parse(dt.Rows[0][0].ToString());
+        }
+        public bool ExecuteSegmentForTransaction(Particle particle1, Particle particle2, int SegmentId)
+        {
+            cmdForTrans.CommandText = "DELETE FROM Segment WHERE XRayId = " + particle1.SegmentList[0].XRayId + " AND FieldId = " + particle1.SegmentList[0].FieldId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            for (int i = 0; i < particle1.SegmentNum; i++)
+            {
+                cmdForTrans.CommandText = "INSERT INTO Segment(XrayID, FieldID, SegmentId, SegmentNum, Start, Height, Length, ParticleId) VALUES ('" 
+                    + particle1.SegmentList[0].XRayId + "','" + particle1.SegmentList[0].FieldId + "','" + i + "','" + particle1.SegmentList[0].SegmentNum + "','"
+                    + particle1.SegmentList[i].Start + "','" + particle1.SegmentList[i].Height + "','" + particle1.SegmentList[i].Length + "','" + particle1.SegmentList[i].ParticleId + "')";
+                if (cmdForTrans.ExecuteNonQuery() == 0)
+                {
+                    return false;
+                }
+            }
+
+            for (int i = 0; i < particle2.SegmentNum; i++)
+            {
+                cmdForTrans.CommandText = "INSERT INTO Segment(XrayID, FieldID, SegmentId, SegmentNum, Start, Height, Length, ParticleId) VALUES ('"
+                    + SegmentId + "','" + particle2.SegmentList[0].FieldId + "','" + i + "','" + particle2.SegmentList[0].SegmentNum + "','"
+                    + particle2.SegmentList[i].Start + "','" + particle2.SegmentList[i].Height + "','" + particle2.SegmentList[i].Length + "','" + SegmentId + "')";
+                if (cmdForTrans.ExecuteNonQuery() == 0)
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+        public bool ExecuteXrayForTransaction(Particle particle1, Particle particle2, int SegmentId)
+        {
+            //XRayData
+            cmdForTrans.CommandText = "INSERT INTO XRayData(XrayIndex, FieldId, XrayData) SELECT " + SegmentId + ", FieldId, XrayData FROM XRayData WHERE FieldId = "+ particle1.SegmentList[0].FieldId + " AND XrayIndex = "+ particle1.SegmentList[0].XRayId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            //PosXrayInfo
+            cmdForTrans.CommandText = "UPDATE PosXrayInfo SET PosX = "+ particle1.PosX + ", PosY = "+ particle1.PosY + " WHERE XrayIndex = " + particle1.SegmentList[0].XRayId + " AND FieldId = " + particle1.SegmentList[0].FieldId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            cmdForTrans.CommandText = "INSERT INTO PosXrayInfo(XrayIndex, PosX, PosY, FieldId, ParticleId, FeatureId, ElementNum) SELECT " + SegmentId + ", "+ particle2.PosX + ", "+ particle2.PosY + ", FieldId, ParticleId, FeatureId, ElementNum FROM PosXrayInfo WHERE FieldId = " + particle1.SegmentList[0].FieldId + " AND XrayIndex = " + particle1.SegmentList[0].XRayId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            //ElementChemistry
+            cmdForTrans.CommandText = "INSERT INTO ElementChemistry(XRayId, FieldId, ElementId, ElementNum, Name, Percentage) SELECT " + SegmentId + ", FieldId, ElementId, ElementNum, Name, Percentage FROM ElementChemistry WHERE FieldId = " + particle1.SegmentList[0].FieldId + " AND XRayId = " + particle1.SegmentList[0].XRayId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            return true;
+        }
+        public bool ExecuteIncAForTransaction(Particle particle1, Particle particle2, int SegmentId)
+        {
+            cmdForTrans.CommandText = "UPDATE IncAData SET AveGray = " + particle1.AveGray + ", RectLeft = " + particle1.RectLeft + ", RectTop = " + particle1.RectTop + ", RectWidth = " + particle1.RectWidth + ", RectHeight = " + particle1.RectHeight + ", Area = " + particle1.Area + ", PosX = " + particle1.PosX + ", PosY = " + particle1.PosY + ", DFERET = " + particle1.DFERET + ", SegmentNum = " + particle1.SegmentNum + ", ParticleId = " + particle1.ParticleId + ", DMAX = " + particle1.DMAX + ", DMIN = " + particle1.DMIN + ", DPERP = " + particle1.DPERP + ", PERIMETER = " + particle1.PERIMETER + ", ORIENTATION = " + particle1.ORIENTATION + ", DINSCR = " + particle1.DINSCR + ", DMEAN = " + particle1.DMEAN + ", DELONG = " + particle1.DELONG + " WHERE XrayId = " + particle1.SegmentList[0].XRayId + " AND FieldId = " + particle1.SegmentList[0].FieldId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            cmdForTrans.CommandText = "INSERT INTO IncAData(FieldId, XrayId, AveGray, RectLeft, RectTop, RectWidth, RectHeight, Area, PosX, PosY, DFERET, SegmentNum, FieldPosX, FieldPosY, ParticleId, DMAX, DMIN, DPERP, PERIMETER, ORIENTATION, DINSCR, DMEAN, DELONG, TypeId, TypeName, TypeColor, SEMPosX, SEMPosY, GroupId, GroupName, GroupColor) SELECT FieldId, " + SegmentId + ", " + particle2.AveGray + ", " + particle2.RectLeft + ", " + particle2.RectTop + ", " + particle2.RectWidth + ", " + particle2.RectHeight + ", " + particle2.Area + ", " + particle2.PosX + ", " + particle2.PosY + ", " + particle2.DFERET + ", " + particle2.SegmentNum + ", FieldPosX, FieldPosY," + SegmentId + ", " + particle2.DMAX + ", " + particle2.DMIN + ", " + particle2.DPERP + ", " + particle2.PERIMETER + ", " + particle2.ORIENTATION + ", " + particle2.DINSCR + ", " + particle2.DMEAN + ", " + particle2.DELONG + ", TypeId, TypeName, TypeColor, SEMPosX, SEMPosY, GroupId, GroupName, GroupColor FROM IncAData WHERE FieldId = " + particle1.SegmentList[0].FieldId + " AND XrayId = " + particle1.SegmentList[0].XRayId + "";
+            if (cmdForTrans.ExecuteNonQuery() == 0)
+            {
+                return false;
+            }
+            return true;
+        }
+        #endregion
+
         public bool BeginTransaction()
         {
             if (connForTrans.State != ConnectionState.Open)

+ 30 - 10
OTSIncAMeasureApp/ServiceCenter/IpcSEMController.cs

@@ -1,23 +1,18 @@
-using OTSCLRINTERFACE;
-using OTSCommon.Model;
-using OTSDataType;
+using OTSCommon.Model;
 using OTSMeasureApp._0_OTSModel.Measure._4_ReMeasure;
-using OTSModelSharp;
-using OTSModelSharp.ServiceCenter;
 using OTSModelSharp.ServiceInterface;
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace OTSMeasureApp.ServiceCenter
 {
      public   class IpcSEMController: MarshalByRefObject
     {
-        private SemController sem= SemController.GetSEMController();
+        private SemController sem = SemController.GetSEMController();
+        private ScanController scan = ScanController.GetScanController();
+        SmplMeasureReMeasure measureReMeasure = new SmplMeasureReMeasure();
+
         public bool MoveSEMToPoint(Point poi)
         {
             if (!sem.IsConnected())
@@ -35,6 +30,31 @@ namespace OTSMeasureApp.ServiceCenter
             return sem.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
         }
 
+        public bool SetMagnification(double a_dMagnification)
+        {
+            if (!sem.IsConnected())
+            {
+                return false;
+            }
+            return sem.SetMagnification(a_dMagnification);
+        }
+
+        public bool AcquireBSEImage(int width, int height, int dwellTime, ref byte[] ImageByte)
+        {
+            scan.SetDwellTime(dwellTime);
+            scan.SetImageSize(width, height);
+
+            ImageByte = measureReMeasure.SetReFldInfo("sample1", scan.AcquireBSEImage(0, 0, dwellTime));
+
+            return true;
+        }
+
+        public bool FindNewPartInfo(Particle particle)
+        {
+            measureReMeasure.FindNewPartInfo(particle);
+            return true;
+        }
+
         public bool ReMeasure(string samplePath, int width, int height, Dictionary<int, List<Particle>> keyValues, int IMGSCANSPEED_INDEX, int XRAYSCANMODE_INDEX, int NUD_SCANTIME_COUNT)
         {
             SmplMeasureReMeasure smplMeasure = new SmplMeasureReMeasure();

+ 140 - 23
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -40,6 +40,14 @@ namespace OTSIncAReportGraph.Controls
        public RectangleF Rect ;
 
     }
+    public struct ParticleSegmentation
+    {
+        public Point StartPoint;
+        public bool IsParticleSegmentation;
+        public Point EndPoint;
+        public Particle ParticleData;
+        public RectangleF Rectangle;
+    }
     public enum RightButtonMenu
     { 
        Include=0,
@@ -47,9 +55,8 @@ namespace OTSIncAReportGraph.Controls
        MoveSEMToParticle=1,
        CopyImage=2,
        OriginalSplicing= 3,
-       DeleteParticle=4,
-       //CopyDatabase=5,
-       ParticleSegmentation=5
+       DeleteParticle=4,       
+	   ParticleSegmentation=5
     }
     /// <summary>
     /// 选择导出的图片是原图还是颗粒渲染后的图片
@@ -73,8 +80,6 @@ namespace OTSIncAReportGraph.Controls
         //最小缩放倍数
         private  float m_f_zoom_mix = 0.05f;
 
-      
-
         //标尺原先大小的记录,参与计算
         private const float m_f_old_ruler_size = 100;
 
@@ -83,6 +88,10 @@ namespace OTSIncAReportGraph.Controls
         double ls_d_cz_height;
         #region 变量定义
         private SelectTool m_SelectTool;
+        private ParticleSegmentation m_ParticleSegmentation;
+        public bool isReView = false;
+        public int reViewFieldId = 0;
+        public int reViewParticleId = 0;
         //缩放的基数,临时变量
         private float m_Zoom_Base = 0;
 
@@ -103,8 +112,6 @@ namespace OTSIncAReportGraph.Controls
 
         //这里要做成控件,不要是窗体
         public List<BaseObject> m_list_allDPart = null;
- 
-
 
         //总背景矩形
         public RectangleF m_backRect = new RectangleF();
@@ -606,24 +613,32 @@ namespace OTSIncAReportGraph.Controls
             }
 
 
-
+            
 
 
             #region //计算并进行绘制部份------------------------------------
             //log.Info(" m_f_widthAndheight_js=" +m_Zoom_Base.ToString());
- 
-                foreach (BaseObject item in m_list_allDPart)
+
+            foreach (BaseObject item in m_list_allDPart)
+            {
+                DisplayParticle dp = (DisplayParticle)item;
+                if (isReView)
                 {
-                    DisplayParticle dp = (DisplayParticle)item;
-                    if (dp.GetPaintState() != PaintState.NOPAINT)
+                    if (dp.objParticleData.FieldId == reViewFieldId && dp.objParticleData.ParticleId == reViewParticleId)
                     {
-                        dp.OnPaint(e);
+                        dp.IsSelect = true;
                     }
-                    
-                  
                 }
 
-       
+                if (dp.GetPaintState() != PaintState.NOPAINT)
+                {
+                    dp.OnPaint(e);
+                }
+
+
+            }
+
+
 
             #endregion
 
@@ -659,6 +674,12 @@ namespace OTSIncAReportGraph.Controls
                 }
             }
             #endregion
+            #region //判断是否使用颗粒分割,是的话,那么这里就开始绘制------------------------
+            if (m_ParticleSegmentation.IsParticleSegmentation)
+            {
+                e.Graphics.DrawLine(new Pen(Color.Red), m_ParticleSegmentation.StartPoint.X, m_ParticleSegmentation.StartPoint.Y, m_ParticleSegmentation.EndPoint.X, m_ParticleSegmentation.EndPoint.Y);
+            }
+            #endregion
             #region 绘制网格线,帧图边框部份
             if (true == m_is_showgrid)
             {
@@ -861,12 +882,18 @@ namespace OTSIncAReportGraph.Controls
             if (e.Button == MouseButtons.Left)
             {
                 this.Cursor = Cursors.Hand;
-           
+
+                isReView = false;
+
                 if (m_SelectTool.IsSelecting)
                 {
                   
                     m_SelectTool.StartPoint = e.Location;
                 }
+                else if (m_ParticleSegmentation.IsParticleSegmentation)
+                {
+                    m_ParticleSegmentation.StartPoint= e.Location;
+                }
                 else
                 {
                     bool ifClickOnParticle=false;
@@ -950,7 +977,13 @@ namespace OTSIncAReportGraph.Controls
                     }
                 }
             }
-            
+            else if(m_ParticleSegmentation.IsParticleSegmentation)
+            {
+                if (e.Button == MouseButtons.Left)
+                {
+                    m_ParticleSegmentation.EndPoint = e.Location;
+                }
+            }
             else
             {
                 if (m_isDrag)
@@ -1021,14 +1054,36 @@ namespace OTSIncAReportGraph.Controls
                             {
                                 dp.IsMouseOver = true;
 
-
                                 //显示x-ray能谱图 
                                 if (control_XRayTable1.Visible == false)
                                     ShowXRay(dp);
 
-                                //m_sem_mouse_now_point = new Point(dp.SEMPosX, dp.SEMPosY);
-                                m_str_mouseshow_left = "颗粒SEM位置:" + dp.SEMPosX.ToString() + ":" + dp.SEMPosY.ToString();
-                                m_sem_mouse_now_point = new Point(dp.SEMPosX, dp.SEMPosY);
+                                Dictionary<string, object> SEMStageData = (Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"];
+                                string ScanFieldSize = SEMStageData["scanFieldSize"].ToString();
+                                string leftOrRight = SEMStageData["xAxisDir"].ToString().Split('_')[0];
+                                string downOrUp = SEMStageData["yAxisDir"].ToString().Split('_')[0];
+                                Point point = new Point();
+                                if (leftOrRight == "RIGHT")
+                                {
+                                    point.X = dp.SEMPosX - int.Parse(ScanFieldSize) / 2 + dp.objParticleData.PosX;
+                                }
+                                else
+                                {
+                                    point.X = dp.SEMPosX + int.Parse(ScanFieldSize) / 2 + dp.objParticleData.PosX;
+                                }
+                                if (downOrUp == "UP")
+                                {
+                                    point.Y = dp.SEMPosY + int.Parse(ScanFieldSize) / 2 + dp.objParticleData.PosY;
+                                }
+                                else
+                                {
+                                    point.Y = dp.SEMPosY - int.Parse(ScanFieldSize) / 2 + dp.objParticleData.PosY;
+                                }
+
+                                m_str_mouseshow_left = "颗粒SEM位置:" + point.X.ToString() + ":" + point.Y.ToString();
+                                m_sem_mouse_now_point = point;
+
+                                m_ParticleSegmentation.Rectangle = dp.Rect;
                             }
                             else
                             {
@@ -1133,6 +1188,48 @@ namespace OTSIncAReportGraph.Controls
                     m_SelectTool.IsSelecting = false;
 
                 }
+                else if(m_ParticleSegmentation.IsParticleSegmentation)
+                {
+                    m_ParticleSegmentation.EndPoint = e.Location;
+                    DialogResult res = MessageBox.Show(table["str11"].ToString());
+                    if (res == DialogResult.OK)
+                    {
+                        m_ReportFun.m_ParticleSegmentation = m_ParticleSegmentation;
+                        bool isTrue = m_ReportFun.isLineIntersectRectangle(m_ParticleSegmentation.StartPoint.X, m_ParticleSegmentation.StartPoint.Y, m_ParticleSegmentation.EndPoint.X, m_ParticleSegmentation.EndPoint.Y,
+                            m_ParticleSegmentation.Rectangle.Left, m_ParticleSegmentation.Rectangle.Top, m_ParticleSegmentation.Rectangle.Right, m_ParticleSegmentation.Rectangle.Bottom);
+
+                        if (isTrue)//判断绘制线段是否与颗粒外接矩形相交
+                        {
+                            List<Point> pointList = new List<Point>();
+                            if (m_ReportFun.GetInterBetweenLinesAndRect(m_ParticleSegmentation.StartPoint, m_ParticleSegmentation.EndPoint, m_ParticleSegmentation.Rectangle, ref pointList))
+                            {
+                                if (pointList.Count != 2)
+                                {
+                                    MessageBox.Show(table["str12"].ToString());
+                                }
+                                else
+                                {
+                                    if (!m_ReportFun.GetSplitPartFun(pointList[0], pointList[1]))
+                                    {
+                                        MessageBox.Show(table["str13"].ToString());
+                                    }
+                                    else
+                                    {
+                                        FieldData fieldData = new FieldData(resultFile.FilePath);
+                                        List<Field> fieldlist = fieldData.GetFieldList();
+                                        m_ReportApp.m_rstDataMgr.CurResultFile.List_OTSField = fieldlist;
+                                        m_ReportApp.rbRenewFun(true, m_ParticleSegmentation.ParticleData.FieldId, m_ParticleSegmentation.ParticleData.ParticleId);
+                                    }
+                                }
+                            }   
+                        }
+                        else
+                        {
+                            MessageBox.Show(table["str14"].ToString());
+                        }
+                    }
+                    m_ParticleSegmentation.IsParticleSegmentation = false;
+                }
                 else
                 {
                     if (m_isDrag)
@@ -1209,6 +1306,7 @@ namespace OTSIncAReportGraph.Controls
 
                         CMenuStrip.Items[(int)RightButtonMenu.ParticleSegmentation].Visible = true;
                         DisplayParticle dp = (DisplayParticle)item;
+                        m_ParticleSegmentation.ParticleData = dp.objParticleData;
                     }
                     if (((DisplayParticle)item).IsSelect)
                     {
@@ -1578,7 +1676,7 @@ namespace OTSIncAReportGraph.Controls
         /// 按框架传入的底层计算结果,重新对颗粒进行区分显示
         /// </summary>
         /// <param name="in_cgriddataclr"></param>
-        public void DrawDistrbutionImageAndBSE_ByQuery(OTSIncAReportApp.OTSSampleReportInfo.ReportCondition in_griddata)
+        public void DrawDistrbutionImageAndBSE_ByQuery(ReportCondition in_griddata)
         {
             FilterParticleByOtherCondition(in_griddata);
             Invalidate();
@@ -1766,6 +1864,15 @@ namespace OTSIncAReportGraph.Controls
         {
             control_Ruler1.Visible = b_show;
         }
+        /// <summary>
+        /// 颗粒分割
+        /// </summary>
+        public void Particle_Segmentation()
+        {
+            m_ParticleSegmentation.IsParticleSegmentation = true;
+            m_ParticleSegmentation.StartPoint = new Point();
+            m_ParticleSegmentation.EndPoint = new Point();
+        }
 
         /// <summary>
         /// 是否进行矩形多选操作
@@ -2078,5 +2185,15 @@ namespace OTSIncAReportGraph.Controls
             }
            
         }
+        int GetsIntersectionOfTheIntercepts(Point P1,Point P2,int y)
+        {
+            int x = (y - P1.Y * P2.X + P1.X * P2.Y) / (P2.Y - P1.Y);
+            return x;
+        }
+
+        private void ParticleSegmentation_Click(object sender, EventArgs e)
+        {
+            Particle_Segmentation();
+        }
     }
 }

+ 496 - 14
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -1,8 +1,12 @@
-using OTSCommon.Model;
+using OpenCvSharp;
+using OTSCLRINTERFACE;
+using OTSCommon.Model;
 using OTSIncAReportApp.DataOperation.DataAccess;
 using OTSIncAReportApp.SysMgrTools;
 using OTSIncAReportGraph.Class;
 using OTSIncAReportGraph.Controls;
+using OTSModelSharp.DTLBase;
+using OTSModelSharp.ServiceInterface;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -13,7 +17,8 @@ using System.Drawing;
 using System.Drawing.Drawing2D;
 using System.IO;
 using System.Linq;
-
+using System.Runtime.Serialization.Formatters.Binary;
+using Point = System.Drawing.Point;
 
 namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
 {
@@ -43,13 +48,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
 
         private ResultFile resultFile = null;
 
-
- 
-
-       
-
-
-       
+        public ParticleSegmentation m_ParticleSegmentation;
 
         //记录field列表的原值
         public List<DisplayField> m_original_list_dfield = null;
@@ -634,18 +633,501 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             }
         }
 
-   
 
+        #region 颗粒分割功能方法
+        /// <summary>
+        /// 获取线段与矩形的两个交点
+        /// </summary>
+        /// <param name="line1S"></param>
+        /// <param name="line1E"></param>
+        /// <param name="rectangle"></param>
+        /// <param name="pointList"></param>
+        /// <returns></returns>
+        public bool GetInterBetweenLinesAndRect(Point line1S, Point line1E, RectangleF rectangle, ref List<Point> pointList)
+        {
+            try
+            {
+                PointF pointF = new PointF(-1, -1);
+                Rect rect = new Rect();
+                rect.X = m_ParticleSegmentation.ParticleData.RectLeft;
+                rect.Y = m_ParticleSegmentation.ParticleData.RectTop;
+                rect.Width = m_ParticleSegmentation.ParticleData.RectWidth;
+                rect.Height = m_ParticleSegmentation.ParticleData.RectHeight;
+                float border = 0;
+
+                if (GetInterBetweenTwoLines(line1S, line1E, new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right, rectangle.Top), ref pointF))
+                {
+                    border = (pointF.X - rectangle.Left) / (rectangle.Right - rectangle.Left);
+                    pointList.Add(new Point((int)(rect.X + rect.Width * border), rect.Y));
+                }
 
-       
+                if (GetInterBetweenTwoLines(line1S, line1E,
+                    new PointF(rectangle.Left, rectangle.Bottom), new PointF(rectangle.Right, rectangle.Bottom), ref pointF))
+                {
+                    border = (pointF.X - rectangle.Left) / (rectangle.Right - rectangle.Left);
+                    pointList.Add(new Point((int)(rect.X + rect.Width * border), rect.Y + rect.Height));
+                }
 
+                if (GetInterBetweenTwoLines(line1S, line1E,
+                    new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Left, rectangle.Bottom), ref pointF))
+                {
+                    border = (pointF.Y - rectangle.Top) / (rectangle.Bottom - rectangle.Top);
+                    pointList.Add(new Point(rect.X, (int)(rect.Y + rect.Height * border)));
+                }
 
-       
+                if (GetInterBetweenTwoLines(line1S, line1E,
+                    new PointF(rectangle.Right, rectangle.Top), new PointF(rectangle.Right, rectangle.Bottom), ref pointF))
+                {
+                    border = (pointF.Y - rectangle.Top) / (rectangle.Bottom - rectangle.Top);
+                    pointList.Add(new Point(rect.X + rect.Width, (int)(rect.Y + rect.Height * border)));
+                }
 
-       
+                if (pointList.Count == 2)
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Trace("(GetSplitPartFun)" + ex);
+                return false;
+            }
+        }
+        public bool GetSplitPartFun(Point startPoint, Point endPoint)
+        {
+            try
+            {
+                Particle particle1 = (Particle)CloneObject(m_ParticleSegmentation.ParticleData);
+                Particle particle2 = (Particle)CloneObject(m_ParticleSegmentation.ParticleData);
+                Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
+                Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+                double d_scanFieldSize_width = Convert.ToDouble(((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["scanFieldSize"]);
+                string ImageResolution = imageScanParam["ImageResolution"].ToString();
+                int width = int.Parse(ImageResolution.Split('_')[1]);
+                int height = int.Parse(ImageResolution.Split('_')[2]);
+                double dPixelSize = d_scanFieldSize_width / width;
+                Mat mat = new Mat(height, width, MatType.CV_8UC1, Scalar.Black);//黑色底图
+                Mat matBse = new Mat(resultFile.List_OTSField[particle1.FieldId].FieldImage, ImreadModes.Grayscale);//原图
+                foreach (Segment segment in m_ParticleSegmentation.ParticleData.SegmentList)
+                {
+                    Cv2.Line(mat, new OpenCvSharp.Point(segment.Start, segment.Height), new OpenCvSharp.Point(segment.Start + segment.Length, segment.Height), Scalar.White, 1, LineTypes.AntiAlias);
+                }
+                Cv2.Line(mat, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, Scalar.Black, 2, LineTypes.AntiAlias);
+                Mat labelMat = new Mat();
+                Mat stats = new Mat();//点的信息
+                Mat centroids = new Mat();//质心的信息
+                int nonenum = Cv2.ConnectedComponentsWithStats(mat, labelMat, stats, centroids, PixelConnectivity.Connectivity8);
+                //暂时只分割成两个颗粒
+                if (nonenum != 3)
+                {
+                    log.Trace("(GetSplitPartFun) More than two particle");
+                    return false;
+                }
+                //寻找坐标点
+                List<Point> points1 = new List<Point>();
+                List<Point> points2 = new List<Point>();
+                List<int> aveGray1 = new List<int>();
+                List<int> aveGray2 = new List<int>();
+                for (int k = 0; k < labelMat.Height; k++)
+                {
+                    for (int j = 0; j < labelMat.Width; j++)
+                    {
+                        int no = labelMat.Get<int>(k, j);
+                        if (no == 1)
+                        {
+                            points1.Add(new Point(j, k));
+                            aveGray1.Add(matBse.Get<byte>(k, j));
+                        }
+                        else if (no == 2)
+                        {
+                            points2.Add(new Point(j, k));
+                            aveGray2.Add(matBse.Get<byte>(k, j));
+                        }
+                    }
+                }
+                mat.Dispose();
+                matBse.Dispose();
+                //处理Segment
+                List<COTSSegmentClr> SegmentClrList1 = new List<COTSSegmentClr>();
+                List<COTSSegmentClr> SegmentClrList2 = new List<COTSSegmentClr>();
+                List<Segment> SegmentList1 = new List<Segment>();
+                List<Segment> SegmentList2 = new List<Segment>();
+                GetSegment(points1, SegmentClrList1, ref SegmentList1);
+                GetSegment(points2, SegmentClrList2, ref SegmentList2);
+
+                CImageHandler m_ImagePro = new CImageHandler();
+                COTSParticleClr part1 = new COTSParticleClr();
+                part1.SetArea(stats.At<int>(1, 4) * dPixelSize * dPixelSize);
+                part1.SetParticleRect(new Rectangle(stats.At<int>(1, 0), stats.At<int>(1, 1), stats.At<int>(1, 2), stats.At<int>(1, 3)));
+                part1.GetFeature().SetSegmentsList(SegmentClrList1, false);
+                m_ImagePro.CalParticleImageProp(part1, dPixelSize);
+                COTSParticleClr part2 = new COTSParticleClr();
+                part2.SetArea(stats.At<int>(2, 4) * dPixelSize * dPixelSize);
+                part2.SetParticleRect(new Rectangle(stats.At<int>(2, 0), stats.At<int>(2, 1), stats.At<int>(2, 2), stats.At<int>(2, 3)));
+                part2.GetFeature().SetSegmentsList(SegmentClrList2, false);
+                m_ImagePro.CalParticleImageProp(part2, dPixelSize);
+
+                particle1.SegmentList = SegmentList1;
+                particle1.SegmentNum = SegmentList1.Count;
+                particle1.AveGray = (int)aveGray1.Average();
+                particle1.RectLeft = stats.At<int>(1, 0);
+                particle1.RectTop = stats.At<int>(1, 1);
+                particle1.RectWidth = stats.At<int>(1, 2);
+                particle1.RectHeight = stats.At<int>(1, 3);
+                particle1.Area = stats.At<int>(1, 4) * dPixelSize * dPixelSize;
+                particle1.PosX = (int)centroids.At<double>(1, 0);
+                particle1.PosY = (int)centroids.At<double>(1, 1);
+                particle1.DFERET = part1.GetFeretDiameter();
+                particle1.DMAX = part1.GetDMAX();
+                particle1.DMIN = part1.GetDMIN();
+                particle1.DPERP = part1.GetDMPERP();
+                particle1.PERIMETER = part1.GetDPRIMETER();
+                particle1.ORIENTATION = part1.GetORIENTATION();
+                particle1.DINSCR = part1.GetDINSCR();
+                particle1.DMEAN = part1.GetDMEAN();
+                particle1.DELONG = part1.GetDELONG();
+
+                particle2.SegmentList = SegmentList2;
+                particle2.SegmentNum = SegmentList2.Count;
+                particle2.AveGray = (int)aveGray2.Average();
+                particle2.RectLeft = stats.At<int>(2, 0);
+                particle2.RectTop = stats.At<int>(2, 1);
+                particle2.RectWidth = stats.At<int>(2, 2);
+                particle2.RectHeight = stats.At<int>(2, 3);
+                particle2.Area = stats.At<int>(2, 4) * dPixelSize * dPixelSize;
+                particle2.PosX = (int)centroids.At<double>(2, 0);
+                particle2.PosY = (int)centroids.At<double>(2, 1);
+                particle2.DFERET = part2.GetFeretDiameter();
+                particle2.DMAX = part2.GetDMAX();
+                particle2.DMIN = part2.GetDMIN();
+                particle2.DPERP = part2.GetDMPERP();
+                particle2.PERIMETER = part2.GetDPRIMETER();
+                particle2.ORIENTATION = part2.GetORIENTATION();
+                particle2.DINSCR = part2.GetDINSCR();
+                particle2.DMEAN = part2.GetDMEAN();
+                particle2.DELONG = part2.GetDELONG();
+
+                if (!SaveToDb(particle1, particle2))
+                {
+                    log.Trace("(GetSplitPartFun) SaveToDb Faild");
+                    return false;
+                }
 
-      
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Trace("(GetSplitPartFun)" + ex);
+                return false;
+            }
+        }
+        /// <summary>
+        /// 保存数据库
+        /// </summary>
+        /// <param name="particle1"></param>
+        /// <param name="particle2"></param>
+        /// <returns></returns>
+        public bool SaveToDb(Particle particle1, Particle particle2)
+        {
+            //初始化
+            SQLiteHelper sQLiteHelper = new SQLiteHelper(resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db");
+            sQLiteHelper.GetDBConnection();
+            sQLiteHelper.BeginTransaction();
 
+            //修改Segment表
+            if (particle1.SegmentList.Count == 0 || particle2.SegmentList.Count == 0)
+            {
+                return false;
+            }
+            int SegmentCount = sQLiteHelper.ExecuteNewPartIdForTransaction() + 1;
+            if (!sQLiteHelper.ExecuteSegmentForTransaction(particle1, particle2, SegmentCount))//修改Segment表
+            {
+                return false;
+            }
+            if (!sQLiteHelper.ExecuteXrayForTransaction(particle1, particle2, SegmentCount))//修改XRayData和PoxXrayInfo表
+            {
+                return false;
+            }
+            if (!sQLiteHelper.ExecuteIncAForTransaction(particle1, particle2, SegmentCount))//修改IncAData表
+            {
+                return false;
+            }
+            sQLiteHelper.CommitTransaction();
+            return true;
+        }
+        /// <summary>
+        /// 线段与矩形是否相交
+        /// </summary>
+        /// <param name="linePointX1"></param>
+        /// <param name="linePointY1"></param>
+        /// <param name="linePointX2"></param>
+        /// <param name="linePointY2"></param>
+        /// <param name="rectangleLeftTopX"></param>
+        /// <param name="rectangleLeftTopY"></param>
+        /// <param name="rectangleRightBottomX"></param>
+        /// <param name="rectangleRightBottomY"></param>
+        /// <returns></returns>
+        public bool isLineIntersectRectangle(float linePointX1,
+                                          float linePointY1,
+                                        float linePointX2,
+                                         float linePointY2,
+                                         float rectangleLeftTopX,
+                                          float rectangleLeftTopY,
+                                          float rectangleRightBottomX,
+                                          float rectangleRightBottomY)
+        {
+            float lineHeight = linePointY1 - linePointY2;
+            float lineWidth = linePointX2 - linePointX1;  // 计算叉乘 
+            float c = linePointX1 * linePointY2 - linePointX2 * linePointY1;
+            if ((lineHeight * rectangleLeftTopX + lineWidth * rectangleLeftTopY + c >= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleRightBottomY + c <= 0)
+                || (lineHeight * rectangleLeftTopX + lineWidth * rectangleLeftTopY + c <= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleRightBottomY + c >= 0)
+                || (lineHeight * rectangleLeftTopX + lineWidth * rectangleRightBottomY + c >= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleLeftTopY + c <= 0)
+                || (lineHeight * rectangleLeftTopX + lineWidth * rectangleRightBottomY + c <= 0 && lineHeight * rectangleRightBottomX + lineWidth * rectangleLeftTopY + c >= 0))
+            {
 
+                if (rectangleLeftTopX > rectangleRightBottomX)
+                {
+                    float temp = rectangleLeftTopX;
+                    rectangleLeftTopX = rectangleRightBottomX;
+                    rectangleRightBottomX = temp;
+                }
+                if (rectangleLeftTopY < rectangleRightBottomY)
+                {
+                    float temp1 = rectangleLeftTopY;
+                    rectangleLeftTopY = rectangleRightBottomY;
+                    rectangleRightBottomY = temp1;
+                }
+                if ((linePointX1 < rectangleLeftTopX && linePointX2 < rectangleLeftTopX)
+                    || (linePointX1 > rectangleRightBottomX && linePointX2 > rectangleRightBottomX)
+                    || (linePointY1 > rectangleLeftTopY && linePointY2 > rectangleLeftTopY)
+                    || (linePointY1 < rectangleRightBottomY && linePointY2 < rectangleRightBottomY))
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                return false;
+            }
+
+        }
+        /// <summary>
+        /// 求一个线段与另一个线段的交点
+        /// </summary>
+        /// <param name="line1S"></param>
+        /// <param name="line1E"></param>
+        /// <param name="line2S"></param>
+        /// <param name="line2E"></param>
+        /// <param name="interPoint"></param>
+        /// <returns>-1:不存在交点;1:存在一个交点;2:存在无穷多个交点(重合或部分重合)</returns>
+        public bool GetInterBetweenTwoLines(PointF line1S, PointF line1E,
+            PointF line2S, PointF line2E, ref PointF interPoint)
+        {
+            int status = -1;
+            // 判断两条直线各自的矩形包围盒的X与Y的值范围
+            float line1Xmin = line1S.X < line1E.X ? line1S.X : line1E.X,
+                line1Xmax = line1S.X > line1E.X ? line1S.X : line1E.X,
+                line1Ymin = line1S.Y < line1E.Y ? line1S.Y : line1E.Y,
+                line1Ymax = line1S.Y > line1E.Y ? line1S.Y : line1E.Y,
+                line2Xmin = line2S.X < line2E.X ? line2S.X : line2E.X,
+                line2Xmax = line2S.X > line2E.X ? line2S.X : line2E.X,
+                line2Ymin = line2S.Y < line2E.Y ? line2S.Y : line2E.Y,
+                line2Ymax = line2S.Y > line2E.Y ? line2S.Y : line2E.Y;
+            if (line1S.X - line1E.X == 0)
+            {
+                // 两条线都垂直于X轴
+                if (line2S.X - line2E.X == 0)
+                {
+                    if (line1S.X != line2S.X) status = -1;
+                    else if ((line1Ymin > line2Ymax) || (line1Ymax < line2Ymin)) status = -1;
+                    else if (line1Ymin == line2Ymax)
+                    {
+                        interPoint = new PointF(line1S.X, line1Ymin); status = 1;
+                    }
+                    else if (line1Ymax == line2Ymin)
+                    {
+                        interPoint = new PointF(line1S.X, line1Ymax); status = 1;
+                    }
+                    else status = 2;
+                }
+                // line1垂直于X轴,line2不垂直于X轴
+                else
+                {
+                    float slope = (line2S.Y - line2E.Y) / (line2S.X - line2E.X);
+                    float offset = line2S.Y - slope * line2S.X;
+                    float newX = line1S.X, newY = slope * newX + offset;
+                    if (newX >= line2Xmin && newX <= line2Xmax && newY >= line1Ymin && newY <= line1Ymax
+                        && newY >= line2Ymin && newY <= line2Ymax)
+                    {
+                        interPoint = new PointF(newX, newY); status = 1;
+                    }
+                }
+            }
+            else
+            {
+                // line1不垂直于X轴,line2垂直于X轴
+                if (line2S.X - line2E.X == 0)
+                {
+                    float slope = (line1S.Y - line1E.Y) / (line1S.X - line1E.X);
+                    float offset = line1S.Y - slope * line1S.X;
+                    float newX = line2S.X, newY = slope * newX + offset;
+                    if (newX >= line1Xmin && newX <= line1Xmax && newY >= line1Ymin && newY <= line1Ymax
+                        && newY >= line2Ymin && newY <= line2Ymax)
+                    {
+                        interPoint = new PointF(newX, newY); status = 1;
+                    }
+                }
+                // line1和line2都不垂直于X轴
+                else
+                {
+                    float slope1 = (line1S.Y - line1E.Y) / (line1S.X - line1E.X);
+                    float offset1 = line1S.Y - slope1 * line1S.X;
+                    float slope2 = (line2S.Y - line2E.Y) / (line2S.X - line2E.X);
+                    float offset2 = line2S.Y - slope2 * line2S.X;
+                    // 如果两条直线平行
+                    if (slope1 == slope2)
+                    {
+                        if (offset1 != offset2) status = -1;
+                        else if (line1Xmax == line2Xmin)
+                        {
+                            interPoint = new PointF(line1Xmax, line1Xmax * slope1 + offset1); status = 1;
+                        }
+                        else if (line1Xmin == line2Xmax)
+                        {
+                            interPoint = new PointF(line1Xmin, line1Xmin * slope1 + offset1); status = 1;
+                        }
+                        else if (line1Xmax < line2Xmin || line1Xmin > line2Xmax) status = -1;
+                        else status = 2;
+                    }
+                    else
+                    {
+                        float newX = (offset2 - offset1) / (slope1 - slope2), newY = newX * slope1 + offset1;
+                        if (newX >= line1Xmin && newX <= line1Xmax && newX >= line2Xmin && newX <= line2Xmax)
+                        {
+                            interPoint = new PointF(newX, newY); status = 1;
+                        }
+                    }
+                }
+            }
+
+            if (status == 1)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+        /// <summary>
+        /// 获取Segment信息
+        /// </summary>
+        /// <param name="points"></param>
+        /// <param name="SegmentClrList"></param>
+        /// <param name="SegmentList"></param>
+        public void GetSegment(List<Point> points, List<COTSSegmentClr> SegmentClrList, ref List<Segment> SegmentList)
+        {
+            List<int> segmentStart = new List<int>();
+            List<int> segmentHeight = new List<int>();
+            List<int> segmentLength = new List<int>();
+            FindSegment(points, ref segmentStart, ref segmentHeight, ref segmentLength);
+            for (int i = 0; i < segmentLength.Count; i++)
+            {
+                COTSSegmentClr seg = new COTSSegmentClr();
+                seg.SetStart(segmentStart[i]);
+                seg.SetHeight(segmentHeight[i]);
+                seg.SetLength(segmentLength[i]);
+                SegmentClrList.Add(seg);
+                Segment segment = new Segment();
+                segment.Start = segmentStart[i];
+                segment.Height = segmentHeight[i];
+                segment.Length = segmentLength[i];
+                segment.SegmentNum = segmentLength.Count;
+                segment.SegmentId = i;
+                segment.FieldId = m_ParticleSegmentation.ParticleData.FieldId;
+                segment.XRayId = m_ParticleSegmentation.ParticleData.XrayId;
+                segment.ParticleId = m_ParticleSegmentation.ParticleData.ParticleId;
+                SegmentList.Add(segment);
+            }
+        }
+
+        /// <summary>
+        /// 寻找segment方法
+        /// </summary>
+        public void FindSegment(List<Point> point_list_final, ref List<int> segmentStart, ref List<int> segmentHeight, ref List<int> segmentLength)
+        {
+            int flag = 0;
+            point_list_final.Sort(my_sort);//排序
+
+            for (int k = 0; k < point_list_final.Count(); k++)
+            {
+                if (k == 0 && k != point_list_final.Count() - 1)//第一个颗粒
+                {
+                    flag++;
+                    segmentStart.Add(point_list_final[k].X);
+                    segmentHeight.Add(point_list_final[k].Y);
+                }
+                else if (k == 0 && k == point_list_final.Count() - 1)//只有一个颗粒
+                {
+                    segmentStart.Add(point_list_final[k].X);
+                    segmentHeight.Add(point_list_final[k].Y);
+                    segmentLength.Add(1);
+                }
+                else if (k == point_list_final.Count() - 1)//最后一个颗粒
+                {
+                    flag++;
+                    segmentLength.Add(flag);
+                }
+                else if (point_list_final[k].Y == point_list_final[k - 1].Y && point_list_final[k].X == point_list_final[k - 1].X + 1)//同行连续
+                {
+                    flag++;
+                }
+                else if (point_list_final[k].Y == point_list_final[k - 1].Y && point_list_final[k].X != point_list_final[k - 1].X + 1)//同行隔断
+                {
+                    segmentLength.Add(flag);
+                    flag = 1;
+                    segmentStart.Add(point_list_final[k].X);
+                    segmentHeight.Add(point_list_final[k].Y);
+                }
+                else if (point_list_final[k].Y != point_list_final[k - 1].Y)//不同行
+                {
+                    segmentLength.Add(flag);
+                    flag = 1;
+                    segmentStart.Add(point_list_final[k].X);
+                    segmentHeight.Add(point_list_final[k].Y);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 排序方法
+        /// </summary>
+        /// <param name="p1"></param>
+        /// <param name="p2"></param>
+        /// <returns></returns>
+        private int my_sort(Point p1, Point p2)
+        {
+            return p1.Y == p2.Y ? p1.X.CompareTo(p2.X) : p1.Y.CompareTo(p2.Y); //升序排序
+        }
+        public object CloneObject(object obj)
+        {
+            using (MemoryStream stream = new MemoryStream())
+            {
+                BinaryFormatter formatter = new BinaryFormatter();
+                stream.Position = 0;
+                formatter.Serialize(stream, obj);
+                stream.Position = 0;
+                return formatter.Deserialize(stream);
+            }
+        }
+        #endregion
     }
 }

+ 33 - 5
OTSIncAReportApp/1-UI/Control_Grids/OTSIncAReportGridsFuncation/OTSReportGridsFun.cs

@@ -172,9 +172,9 @@ namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
         /// </summary>
         /// <param name="PositionX"></param>
         /// <param name="PositionY"></param>
-        public void MoveSemToPointXY_ForParticlesGrid(double in_PositionX, double in_PositionY)
+        public bool MoveSemToPointXY_ForParticlesGrid(double in_PositionX, double in_PositionY)
         {
-
+            bool isSuccess = false;
             //首先获取电镜当前的位置,并记录原R值
             double ls_PositionX = 0;
             double ls_PositionY = 0;
@@ -182,15 +182,43 @@ namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
 
             if (m_SEMConnectionState)
             {
-                m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
+                isSuccess = m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
             }
            
 
             if (m_SEMConnectionState)
             {
-                m_cfun.MoveSEMToPoint(new Point((int)in_PositionX, (int)in_PositionY), ls_PositionR);
+                isSuccess = m_cfun.MoveSEMToPoint(new Point((int)in_PositionX, (int)in_PositionY), ls_PositionR);
             }
-           
+
+            return isSuccess;
+        }
+
+        /// <summary>
+        /// 设置放大倍数
+        /// </summary>
+        /// <param name="a_dMagnification"></param>
+        /// <returns></returns>
+        public bool SetMagnification(double a_dMagnification)
+        {
+            bool isSuccess = false;
+            if (m_SEMConnectionState)
+            {
+                isSuccess = m_cfun.SetMagnification(a_dMagnification);
+            }
+
+            return isSuccess;
+        }
+
+        public bool AcquireBSEImage(int width, int height, int dwellTime, ref byte[] ImageByte)
+        {
+            bool isSuccess = false;
+            if (m_SEMConnectionState)
+            {
+                isSuccess = m_cfun.AcquireBSEImage(width, height, dwellTime, ref ImageByte);
+            }
+
+            return isSuccess;
         }
 
         /// <summary>

+ 14 - 0
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.Designer.cs

@@ -32,6 +32,7 @@
             this.panel2 = new System.Windows.Forms.Panel();
             this.label_Condition = new System.Windows.Forms.Label();
             this.tbx_Type = new System.Windows.Forms.TextBox();
+            this.btn_ReMeasure = new System.Windows.Forms.Button();
             this.btn_Sel = new System.Windows.Forms.Button();
             this.label_ParticleName = new System.Windows.Forms.Label();
             this.label_Dmax = new System.Windows.Forms.Label();
@@ -83,6 +84,7 @@
             // 
             this.panel2.Controls.Add(this.label_Condition);
             this.panel2.Controls.Add(this.tbx_Type);
+            this.panel2.Controls.Add(this.btn_ReMeasure);
             this.panel2.Controls.Add(this.btn_Sel);
             this.panel2.Controls.Add(this.label_ParticleName);
             this.panel2.Controls.Add(this.label_Dmax);
@@ -118,6 +120,17 @@
             this.tbx_Type.TabIndex = 34;
             this.tbx_Type.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
             // 
+            // btn_ReMeasure
+            // 
+            this.btn_ReMeasure.Location = new System.Drawing.Point(595, 7);
+            this.btn_ReMeasure.Name = "btn_ReMeasure";
+            this.btn_ReMeasure.Size = new System.Drawing.Size(80, 23);
+            this.btn_ReMeasure.TabIndex = 33;
+            this.btn_ReMeasure.Text = "二次采集";
+            this.btn_ReMeasure.UseVisualStyleBackColor = true;
+            this.btn_ReMeasure.Visible = false;
+            this.btn_ReMeasure.Click += new System.EventHandler(this.btn_ReMeasure_Click);
+            // 
             // btn_Sel
             // 
             this.btn_Sel.Location = new System.Drawing.Point(535, 8);
@@ -571,5 +584,6 @@
         private System.Windows.Forms.ToolStripMenuItem EXCELToolStripMenuItem;
         private System.Windows.Forms.DataGridView dgV_ParticlesDevidePage;
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItemDelete_Particle;
+        private System.Windows.Forms.Button btn_ReMeasure;
     }
 }

+ 4 - 68
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.cs

@@ -1134,66 +1134,6 @@ namespace OTSIncAReportGrids
             }
 
         }
-        /// <summary>
-        /// 二次测量线程函数
-        /// </summary>
-        private void Thread_ReMeasure(object particles)
-        {
-            if (m_mythread_state == false)
-            {
-                m_mythread_state = true;
-                //颗粒信息
-                List<Particle> ParticleList = (List<Particle>)particles;
-                Dictionary<int, List<Particle>> keyValues = new Dictionary<int, List<Particle>>();
-                Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["Sample"])["Members"]);
-                Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
-                string ImageResolution = imageScanParam["ImageResolution"].ToString();
-                double width = Convert.ToDouble(ImageResolution.Split('_')[1]);
-                double height = Convert.ToDouble(ImageResolution.Split('_')[2]);
-
-
-                ParticleList.OrderBy(a => a.FieldId).ToList();
-                for (int i = 0; i < ParticleList.Count; i++)
-                {
-                    if (keyValues.ContainsKey(ParticleList[i].FieldId))
-                    {
-                        List<Particle> Particles = keyValues[ParticleList[i].FieldId];
-                        Particles.Add(ParticleList[i]);
-                        keyValues[ParticleList[i].FieldId] = Particles;
-                    }
-                    else
-                    {
-                        List<Particle> Particles = new List<Particle>();
-                        Particles.Add(ParticleList[i]);
-                        keyValues.Add(ParticleList[i].FieldId, Particles);
-                    }
-                }
-
-                //第一步,连接电镜
-                m_OTSIncAReportGridsFun.Connection_ForParticlesGrid();
-
-                Thread.Sleep(500);
-
-                //第二步,移动到指定位置,先读取再设置
-                if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
-                {
-                    m_OTSIncAReportGridsFun.ReMeasure(result.FilePath + "\\FIELD_FILES\\", (int)width, (int)height, keyValues, frmReMeasure.IMGSCANSPEED_INDEX, frmReMeasure.XRAYSCANMODE_INDEX, frmReMeasure.NUD_SCANTIME_COUNT);
-                }
-
-                Thread.Sleep(1500);
-
-                //第三步,断开电镜连接
-                m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
-
-                //Thread.Sleep(500);
-
-                m_mythread_state = false;
-            }
-
-        }
-
-
-
         #endregion
 
         private void ToolStripMenuItem_exportzoomimagefile_Click(object sender, EventArgs e)
@@ -2079,17 +2019,13 @@ namespace OTSIncAReportGrids
 
         private void btn_ReMeasure_Click(object sender, EventArgs e)
         {
+            //二次测量参数页面
+            frmReMeasure frmReMeasure = new frmReMeasure(m_OTSIncAReportGridsFun, m_ReportApp.GetSelectedParticles(), resultFile);
             frmReMeasure.TopMost = true;//设置置顶
-            DialogResult dialogResult = frmReMeasure.ShowDialog();
-            if (dialogResult == DialogResult.OK)
-            {
-                m_mythread = new Thread(Thread_ReMeasure);
+            frmReMeasure.ShowDialog();
+        }
 
-                //改为线程调用,先判断线程状态
-                m_mythread.Start(m_ReportApp.GetSelectedParticles());
             }
-        }
-    }
 
 
 

+ 263 - 52
OTSIncAReportApp/1-UI/frmReMeasure.Designer.cs

@@ -33,44 +33,70 @@ namespace OTSIncAReportApp._1_UI
             this.LB_IMGSCANSPEED = new System.Windows.Forms.Label();
             this.LB_XRAYSCANMODE = new System.Windows.Forms.Label();
             this.LB_SCANTIME = new System.Windows.Forms.Label();
-            this.BTN_NO = new System.Windows.Forms.Button();
-            this.BTN_YES = new System.Windows.Forms.Button();
             this.NUD_SCANTIME = new System.Windows.Forms.NumericUpDown();
             this.IDC_COMBO_IMGSCANSPEED = new System.Windows.Forms.ComboBox();
             this.IDC_COMBO_XRAYSCANMODE = new System.Windows.Forms.ComboBox();
+            this.LB_NEWMAG = new System.Windows.Forms.Label();
+            this.NUD_MAG = new System.Windows.Forms.NumericUpDown();
+            this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
+            this.BTN_YES = new System.Windows.Forms.Button();
+            this.BTN_NO = new System.Windows.Forms.Button();
+            this.LB_OLDMAG = new System.Windows.Forms.Label();
+            this.LB_OLDMAGVALUE = new System.Windows.Forms.Label();
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.pictureBox_part = new System.Windows.Forms.PictureBox();
+            this.bgw_process = new System.ComponentModel.BackgroundWorker();
+            this.progressBar_process = new System.Windows.Forms.ProgressBar();
+            this.label_process = new System.Windows.Forms.Label();
+            this.richTextBox_process = new System.Windows.Forms.RichTextBox();
+            this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
+            this.groupBox3 = new System.Windows.Forms.GroupBox();
             this.tableLayoutPanel1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.NUD_SCANTIME)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.NUD_MAG)).BeginInit();
+            this.tableLayoutPanel3.SuspendLayout();
+            this.groupBox1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_part)).BeginInit();
+            this.groupBox2.SuspendLayout();
+            this.tableLayoutPanel2.SuspendLayout();
+            this.groupBox3.SuspendLayout();
             this.SuspendLayout();
             // 
             // tableLayoutPanel1
             // 
             this.tableLayoutPanel1.ColumnCount = 2;
-            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
-            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 61.76471F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 38.23529F));
             this.tableLayoutPanel1.Controls.Add(this.LB_IMGSCANSPEED, 0, 0);
-            this.tableLayoutPanel1.Controls.Add(this.LB_XRAYSCANMODE, 0, 1);
-            this.tableLayoutPanel1.Controls.Add(this.LB_SCANTIME, 0, 2);
-            this.tableLayoutPanel1.Controls.Add(this.BTN_NO, 0, 3);
-            this.tableLayoutPanel1.Controls.Add(this.BTN_YES, 1, 3);
-            this.tableLayoutPanel1.Controls.Add(this.NUD_SCANTIME, 1, 2);
+            this.tableLayoutPanel1.Controls.Add(this.LB_XRAYSCANMODE, 0, 3);
+            this.tableLayoutPanel1.Controls.Add(this.LB_SCANTIME, 0, 4);
+            this.tableLayoutPanel1.Controls.Add(this.NUD_SCANTIME, 1, 4);
             this.tableLayoutPanel1.Controls.Add(this.IDC_COMBO_IMGSCANSPEED, 1, 0);
-            this.tableLayoutPanel1.Controls.Add(this.IDC_COMBO_XRAYSCANMODE, 1, 1);
+            this.tableLayoutPanel1.Controls.Add(this.IDC_COMBO_XRAYSCANMODE, 1, 3);
+            this.tableLayoutPanel1.Controls.Add(this.LB_NEWMAG, 0, 2);
+            this.tableLayoutPanel1.Controls.Add(this.NUD_MAG, 1, 2);
+            this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 5);
+            this.tableLayoutPanel1.Controls.Add(this.LB_OLDMAG, 0, 1);
+            this.tableLayoutPanel1.Controls.Add(this.LB_OLDMAGVALUE, 1, 1);
             this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 17);
             this.tableLayoutPanel1.Name = "tableLayoutPanel1";
-            this.tableLayoutPanel1.RowCount = 4;
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
-            this.tableLayoutPanel1.Size = new System.Drawing.Size(449, 308);
+            this.tableLayoutPanel1.RowCount = 6;
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(238, 395);
             this.tableLayoutPanel1.TabIndex = 0;
             // 
             // LB_IMGSCANSPEED
             // 
             this.LB_IMGSCANSPEED.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.LB_IMGSCANSPEED.AutoSize = true;
-            this.LB_IMGSCANSPEED.Location = new System.Drawing.Point(67, 32);
+            this.LB_IMGSCANSPEED.Location = new System.Drawing.Point(29, 26);
             this.LB_IMGSCANSPEED.Name = "LB_IMGSCANSPEED";
             this.LB_IMGSCANSPEED.Size = new System.Drawing.Size(89, 12);
             this.LB_IMGSCANSPEED.TabIndex = 0;
@@ -80,7 +106,7 @@ namespace OTSIncAReportApp._1_UI
             // 
             this.LB_XRAYSCANMODE.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.LB_XRAYSCANMODE.AutoSize = true;
-            this.LB_XRAYSCANMODE.Location = new System.Drawing.Point(67, 109);
+            this.LB_XRAYSCANMODE.Location = new System.Drawing.Point(29, 221);
             this.LB_XRAYSCANMODE.Name = "LB_XRAYSCANMODE";
             this.LB_XRAYSCANMODE.Size = new System.Drawing.Size(89, 12);
             this.LB_XRAYSCANMODE.TabIndex = 0;
@@ -90,38 +116,16 @@ namespace OTSIncAReportApp._1_UI
             // 
             this.LB_SCANTIME.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.LB_SCANTIME.AutoSize = true;
-            this.LB_SCANTIME.Location = new System.Drawing.Point(43, 186);
+            this.LB_SCANTIME.Location = new System.Drawing.Point(5, 286);
             this.LB_SCANTIME.Name = "LB_SCANTIME";
             this.LB_SCANTIME.Size = new System.Drawing.Size(137, 12);
             this.LB_SCANTIME.TabIndex = 0;
             this.LB_SCANTIME.Text = "颗粒扫描时间(毫秒):";
             // 
-            // BTN_NO
-            // 
-            this.BTN_NO.Anchor = System.Windows.Forms.AnchorStyles.None;
-            this.BTN_NO.Location = new System.Drawing.Point(69, 254);
-            this.BTN_NO.Name = "BTN_NO";
-            this.BTN_NO.Size = new System.Drawing.Size(85, 31);
-            this.BTN_NO.TabIndex = 1;
-            this.BTN_NO.Text = "取消";
-            this.BTN_NO.UseVisualStyleBackColor = true;
-            this.BTN_NO.Click += new System.EventHandler(this.BTN_NO_Click);
-            // 
-            // BTN_YES
-            // 
-            this.BTN_YES.Anchor = System.Windows.Forms.AnchorStyles.None;
-            this.BTN_YES.Location = new System.Drawing.Point(294, 254);
-            this.BTN_YES.Name = "BTN_YES";
-            this.BTN_YES.Size = new System.Drawing.Size(85, 31);
-            this.BTN_YES.TabIndex = 1;
-            this.BTN_YES.Text = "确定";
-            this.BTN_YES.UseVisualStyleBackColor = true;
-            this.BTN_YES.Click += new System.EventHandler(this.BTN_YES_Click);
-            // 
             // NUD_SCANTIME
             // 
             this.NUD_SCANTIME.Anchor = System.Windows.Forms.AnchorStyles.None;
-            this.NUD_SCANTIME.Location = new System.Drawing.Point(276, 182);
+            this.NUD_SCANTIME.Location = new System.Drawing.Point(150, 282);
             this.NUD_SCANTIME.Maximum = new decimal(new int[] {
             1000000,
             0,
@@ -133,7 +137,7 @@ namespace OTSIncAReportApp._1_UI
             0,
             0});
             this.NUD_SCANTIME.Name = "NUD_SCANTIME";
-            this.NUD_SCANTIME.Size = new System.Drawing.Size(120, 21);
+            this.NUD_SCANTIME.Size = new System.Drawing.Size(85, 21);
             this.NUD_SCANTIME.TabIndex = 2;
             this.NUD_SCANTIME.Value = new decimal(new int[] {
             1000,
@@ -146,9 +150,9 @@ namespace OTSIncAReportApp._1_UI
             this.IDC_COMBO_IMGSCANSPEED.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.IDC_COMBO_IMGSCANSPEED.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.IDC_COMBO_IMGSCANSPEED.FormattingEnabled = true;
-            this.IDC_COMBO_IMGSCANSPEED.Location = new System.Drawing.Point(276, 28);
+            this.IDC_COMBO_IMGSCANSPEED.Location = new System.Drawing.Point(150, 22);
             this.IDC_COMBO_IMGSCANSPEED.Name = "IDC_COMBO_IMGSCANSPEED";
-            this.IDC_COMBO_IMGSCANSPEED.Size = new System.Drawing.Size(121, 20);
+            this.IDC_COMBO_IMGSCANSPEED.Size = new System.Drawing.Size(85, 20);
             this.IDC_COMBO_IMGSCANSPEED.TabIndex = 3;
             // 
             // IDC_COMBO_XRAYSCANMODE
@@ -156,21 +160,206 @@ namespace OTSIncAReportApp._1_UI
             this.IDC_COMBO_XRAYSCANMODE.Anchor = System.Windows.Forms.AnchorStyles.None;
             this.IDC_COMBO_XRAYSCANMODE.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.IDC_COMBO_XRAYSCANMODE.FormattingEnabled = true;
-            this.IDC_COMBO_XRAYSCANMODE.Location = new System.Drawing.Point(276, 105);
+            this.IDC_COMBO_XRAYSCANMODE.Location = new System.Drawing.Point(150, 217);
             this.IDC_COMBO_XRAYSCANMODE.Name = "IDC_COMBO_XRAYSCANMODE";
-            this.IDC_COMBO_XRAYSCANMODE.Size = new System.Drawing.Size(121, 20);
+            this.IDC_COMBO_XRAYSCANMODE.Size = new System.Drawing.Size(85, 20);
             this.IDC_COMBO_XRAYSCANMODE.TabIndex = 3;
             // 
+            // LB_NEWMAG
+            // 
+            this.LB_NEWMAG.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.LB_NEWMAG.AutoSize = true;
+            this.LB_NEWMAG.Location = new System.Drawing.Point(35, 156);
+            this.LB_NEWMAG.Name = "LB_NEWMAG";
+            this.LB_NEWMAG.Size = new System.Drawing.Size(77, 12);
+            this.LB_NEWMAG.TabIndex = 0;
+            this.LB_NEWMAG.Text = "新放大倍数:";
+            // 
+            // NUD_MAG
+            // 
+            this.NUD_MAG.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.NUD_MAG.DecimalPlaces = 2;
+            this.NUD_MAG.Location = new System.Drawing.Point(150, 152);
+            this.NUD_MAG.Maximum = new decimal(new int[] {
+            1000000,
+            0,
+            0,
+            0});
+            this.NUD_MAG.Minimum = new decimal(new int[] {
+            100,
+            0,
+            0,
+            0});
+            this.NUD_MAG.Name = "NUD_MAG";
+            this.NUD_MAG.Size = new System.Drawing.Size(85, 21);
+            this.NUD_MAG.TabIndex = 2;
+            this.NUD_MAG.Value = new decimal(new int[] {
+            200,
+            0,
+            0,
+            0});
+            // 
+            // tableLayoutPanel3
+            // 
+            this.tableLayoutPanel3.ColumnCount = 2;
+            this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel3, 2);
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+            this.tableLayoutPanel3.Controls.Add(this.BTN_YES, 1, 0);
+            this.tableLayoutPanel3.Controls.Add(this.BTN_NO, 0, 0);
+            this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 328);
+            this.tableLayoutPanel3.Name = "tableLayoutPanel3";
+            this.tableLayoutPanel3.RowCount = 1;
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 64F));
+            this.tableLayoutPanel3.Size = new System.Drawing.Size(232, 64);
+            this.tableLayoutPanel3.TabIndex = 4;
+            // 
+            // BTN_YES
+            // 
+            this.BTN_YES.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.BTN_YES.Location = new System.Drawing.Point(131, 16);
+            this.BTN_YES.Name = "BTN_YES";
+            this.BTN_YES.Size = new System.Drawing.Size(85, 31);
+            this.BTN_YES.TabIndex = 1;
+            this.BTN_YES.Text = "开始采集";
+            this.BTN_YES.UseVisualStyleBackColor = true;
+            this.BTN_YES.Click += new System.EventHandler(this.BTN_YES_Click);
+            // 
+            // BTN_NO
+            // 
+            this.BTN_NO.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.BTN_NO.Location = new System.Drawing.Point(15, 16);
+            this.BTN_NO.Name = "BTN_NO";
+            this.BTN_NO.Size = new System.Drawing.Size(85, 31);
+            this.BTN_NO.TabIndex = 1;
+            this.BTN_NO.Text = "返回";
+            this.BTN_NO.UseVisualStyleBackColor = true;
+            this.BTN_NO.Click += new System.EventHandler(this.BTN_NO_Click);
+            // 
+            // LB_OLDMAG
+            // 
+            this.LB_OLDMAG.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.LB_OLDMAG.AutoSize = true;
+            this.LB_OLDMAG.Location = new System.Drawing.Point(35, 91);
+            this.LB_OLDMAG.Name = "LB_OLDMAG";
+            this.LB_OLDMAG.Size = new System.Drawing.Size(77, 12);
+            this.LB_OLDMAG.TabIndex = 0;
+            this.LB_OLDMAG.Text = "原放大倍数:";
+            // 
+            // LB_OLDMAGVALUE
+            // 
+            this.LB_OLDMAGVALUE.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.LB_OLDMAGVALUE.AutoSize = true;
+            this.LB_OLDMAGVALUE.Location = new System.Drawing.Point(181, 91);
+            this.LB_OLDMAGVALUE.Name = "LB_OLDMAGVALUE";
+            this.LB_OLDMAGVALUE.Size = new System.Drawing.Size(23, 12);
+            this.LB_OLDMAGVALUE.TabIndex = 5;
+            this.LB_OLDMAGVALUE.Text = "100";
+            // 
+            // groupBox1
+            // 
+            this.groupBox1.Controls.Add(this.pictureBox_part);
+            this.groupBox1.Location = new System.Drawing.Point(12, 12);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(468, 415);
+            this.groupBox1.TabIndex = 1;
+            this.groupBox1.TabStop = false;
+            this.groupBox1.Text = "颗粒图片";
+            // 
+            // pictureBox_part
+            // 
+            this.pictureBox_part.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.pictureBox_part.Location = new System.Drawing.Point(3, 17);
+            this.pictureBox_part.Name = "pictureBox_part";
+            this.pictureBox_part.Size = new System.Drawing.Size(462, 395);
+            this.pictureBox_part.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+            this.pictureBox_part.TabIndex = 0;
+            this.pictureBox_part.TabStop = false;
+            // 
+            // bgw_process
+            // 
+            this.bgw_process.WorkerReportsProgress = true;
+            this.bgw_process.WorkerSupportsCancellation = true;
+            this.bgw_process.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bgw_process_DoWork);
+            this.bgw_process.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bgw_process_ProgressChanged);
+            // 
+            // progressBar_process
+            // 
+            this.progressBar_process.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.progressBar_process.Location = new System.Drawing.Point(87, 7);
+            this.progressBar_process.Name = "progressBar_process";
+            this.progressBar_process.Size = new System.Drawing.Size(152, 23);
+            this.progressBar_process.TabIndex = 2;
+            // 
+            // label_process
+            // 
+            this.label_process.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.label_process.AutoSize = true;
+            this.label_process.Location = new System.Drawing.Point(36, 12);
+            this.label_process.Name = "label_process";
+            this.label_process.Size = new System.Drawing.Size(11, 12);
+            this.label_process.TabIndex = 3;
+            this.label_process.Text = "-";
+            // 
+            // richTextBox_process
+            // 
+            this.tableLayoutPanel2.SetColumnSpan(this.richTextBox_process, 2);
+            this.richTextBox_process.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.richTextBox_process.Location = new System.Drawing.Point(3, 40);
+            this.richTextBox_process.Name = "richTextBox_process";
+            this.richTextBox_process.Size = new System.Drawing.Size(236, 352);
+            this.richTextBox_process.TabIndex = 4;
+            this.richTextBox_process.Text = "";
+            // 
+            // groupBox2
+            // 
+            this.groupBox2.Controls.Add(this.tableLayoutPanel2);
+            this.groupBox2.Location = new System.Drawing.Point(486, 12);
+            this.groupBox2.Name = "groupBox2";
+            this.groupBox2.Size = new System.Drawing.Size(248, 415);
+            this.groupBox2.TabIndex = 5;
+            this.groupBox2.TabStop = false;
+            this.groupBox2.Text = "测量状态";
+            // 
+            // tableLayoutPanel2
+            // 
+            this.tableLayoutPanel2.ColumnCount = 2;
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34.84848F));
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 65.15151F));
+            this.tableLayoutPanel2.Controls.Add(this.label_process, 0, 0);
+            this.tableLayoutPanel2.Controls.Add(this.richTextBox_process, 0, 1);
+            this.tableLayoutPanel2.Controls.Add(this.progressBar_process, 1, 0);
+            this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 17);
+            this.tableLayoutPanel2.Name = "tableLayoutPanel2";
+            this.tableLayoutPanel2.RowCount = 2;
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.620254F));
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 90.37975F));
+            this.tableLayoutPanel2.Size = new System.Drawing.Size(242, 395);
+            this.tableLayoutPanel2.TabIndex = 0;
+            // 
+            // groupBox3
+            // 
+            this.groupBox3.Controls.Add(this.tableLayoutPanel1);
+            this.groupBox3.Location = new System.Drawing.Point(737, 12);
+            this.groupBox3.Name = "groupBox3";
+            this.groupBox3.Size = new System.Drawing.Size(244, 415);
+            this.groupBox3.TabIndex = 6;
+            this.groupBox3.TabStop = false;
+            this.groupBox3.Text = "测量参数";
+            // 
             // frmReMeasure
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(449, 308);
-            this.Controls.Add(this.tableLayoutPanel1);
+            this.ClientSize = new System.Drawing.Size(993, 439);
+            this.Controls.Add(this.groupBox3);
+            this.Controls.Add(this.groupBox2);
+            this.Controls.Add(this.groupBox1);
             this.MaximizeBox = false;
-            this.MaximumSize = new System.Drawing.Size(465, 347);
             this.MinimizeBox = false;
-            this.MinimumSize = new System.Drawing.Size(465, 347);
             this.Name = "frmReMeasure";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "二次采集";
@@ -178,6 +367,14 @@ namespace OTSIncAReportApp._1_UI
             this.tableLayoutPanel1.ResumeLayout(false);
             this.tableLayoutPanel1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.NUD_SCANTIME)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.NUD_MAG)).EndInit();
+            this.tableLayoutPanel3.ResumeLayout(false);
+            this.groupBox1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_part)).EndInit();
+            this.groupBox2.ResumeLayout(false);
+            this.tableLayoutPanel2.ResumeLayout(false);
+            this.tableLayoutPanel2.PerformLayout();
+            this.groupBox3.ResumeLayout(false);
             this.ResumeLayout(false);
 
         }
@@ -193,5 +390,19 @@ namespace OTSIncAReportApp._1_UI
         private System.Windows.Forms.ComboBox IDC_COMBO_IMGSCANSPEED;
         private System.Windows.Forms.NumericUpDown NUD_SCANTIME;
         private System.Windows.Forms.ComboBox IDC_COMBO_XRAYSCANMODE;
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.Label LB_NEWMAG;
+        private System.Windows.Forms.NumericUpDown NUD_MAG;
+        private System.ComponentModel.BackgroundWorker bgw_process;
+        private System.Windows.Forms.ProgressBar progressBar_process;
+        private System.Windows.Forms.Label label_process;
+        private System.Windows.Forms.RichTextBox richTextBox_process;
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
+        private System.Windows.Forms.GroupBox groupBox2;
+        private System.Windows.Forms.GroupBox groupBox3;
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
+        private System.Windows.Forms.PictureBox pictureBox_part;
+        private System.Windows.Forms.Label LB_OLDMAG;
+        private System.Windows.Forms.Label LB_OLDMAGVALUE;
     }
 }

+ 190 - 10
OTSIncAReportApp/1-UI/frmReMeasure.cs

@@ -11,18 +11,64 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
+using System.Threading;
+using static OTSDataType.otsdataconst;
+using OTSModelSharp.ServiceInterface;
 
 namespace OTSIncAReportApp._1_UI
 {
     public partial class frmReMeasure : Form
     {
-        public static int IMGSCANSPEED_INDEX = -1;
-        public static int XRAYSCANMODE_INDEX = -1;
-        public static int NUD_SCANTIME_COUNT = 1;
+        OTSReportGridsFun m_OTSIncAReportGridsFun;
+        List<Particle> SelectedParticles;
+        ResultFile resultFile;
+        int nBrukerDwellTime = 0;
+        private delegate void DelSetPro(string txt, RichTextBox richTextBox);//设置进度条进度的委托方法
 
-        public frmReMeasure()
+        /// <summary>
+        /// 设置进度。
+        /// </summary>
+        /// <param name="pro"></param>
+        /// <param name="proBar"></param>
+        private void SetProgressMessage(string txt, RichTextBox richTextBox)
+        {
+            //如果当前调用方不是创建控件的一方,则需要使用this.Invoke()
+            //在这里,ProgressBar控件是由主线程创建的,所以子线程要对该控件进行操作
+            //必须执行this.InvokeRequired进行判断。
+            if (this.InvokeRequired)
+            {
+                DelSetPro setPro = new DelSetPro(SetProgressMessage);
+                this.Invoke(setPro, new object[] { txt, richTextBox });
+            }
+            else
+            {
+                WriteRictBox(txt);
+            }
+        }
+
+        #region 将文本追加到RictBox的尾部上
+        /// <summary>
+        /// 将文本追加到RictBox的尾部上
+        /// </summary>
+        public void WriteRictBox(string in_str)
+        {
+            //追加到rictbox尾部
+            richTextBox_process.AppendText("[" + DateTime.Now.Hour.ToString() + ":"
+                + DateTime.Now.Minute.ToString() + ":"
+                + DateTime.Now.Second.ToString() + "]"
+                + in_str + Environment.NewLine);
+            richTextBox_process.ScrollToCaret();
+        }
+        #endregion
+
+        public frmReMeasure(OTSReportGridsFun m_OTSIncAReportGridsFun, List<Particle> SelectedParticles, ResultFile resultFile)
         {
             InitializeComponent();
+
+            this.m_OTSIncAReportGridsFun = m_OTSIncAReportGridsFun;
+            this.SelectedParticles = SelectedParticles;
+            this.resultFile = resultFile;
         }
 
         private void frmReMeasure_Load(object sender, EventArgs e)
@@ -47,6 +93,15 @@ namespace OTSIncAReportApp._1_UI
                 IDC_COMBO_XRAYSCANMODE.Items.Add(cbi);
             }
             IDC_COMBO_XRAYSCANMODE.SelectedIndex = (int)otsdataconst.OTS_X_RAY_SCAN_MODE.PointMode;
+            //旧放大倍数
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["SEMDataMsr"]);
+            double ScanFieldSize = double.Parse(SEMDataMsr["ScanFieldSize"].ToString());
+            double ScanFieldSize100 = double.Parse(SEMDataMsr["ScanFieldSize100"].ToString());
+            double oldMag = Math.Round((ScanFieldSize100 / ScanFieldSize) * 100, 2);
+            LB_OLDMAGVALUE.Text = oldMag.ToString();
+            NUD_MAG.Minimum = (decimal)oldMag;
+            NUD_MAG.Value = (decimal)(oldMag * 2);
         }
 
         public string GetScanSpeedString(otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS a_nScanSpeed)
@@ -75,17 +130,142 @@ namespace OTSIncAReportApp._1_UI
 
         private void BTN_NO_Click(object sender, EventArgs e)
         {
-            this.DialogResult = DialogResult.Cancel;
             this.Close();
         }
 
         private void BTN_YES_Click(object sender, EventArgs e)
         {
-            IMGSCANSPEED_INDEX = IDC_COMBO_IMGSCANSPEED.SelectedIndex;
-            XRAYSCANMODE_INDEX = IDC_COMBO_XRAYSCANMODE.SelectedIndex;
-            NUD_SCANTIME_COUNT = (int)NUD_SCANTIME.Value;
-            this.DialogResult = DialogResult.OK;
-            this.Close();
+            //参数定义
+            int nBrukerDwellTimeId = 3;
+            switch (IDC_COMBO_IMGSCANSPEED.SelectedIndex)
+            {
+                case (int)OTS_IMAGE_SCANSPEED_OPTIONS.low:
+                    nBrukerDwellTimeId = 3;
+                    break;
+                case (int)OTS_IMAGE_SCANSPEED_OPTIONS.meddium:
+                    nBrukerDwellTimeId = 4;
+                    break;
+                case (int)OTS_IMAGE_SCANSPEED_OPTIONS.high:
+                    nBrukerDwellTimeId = 5;
+                    break;
+                default:
+                    nBrukerDwellTimeId = 3;
+                    break;
+            }
+            nBrukerDwellTime = DWELLTIME_BRUKER_VALUES[nBrukerDwellTimeId];
+
+            bgw_process.RunWorkerAsync();
+        }
+
+        private Point GetPartPoint(string leftOrRight, string downOrUp, string ScanFieldSize, Particle particle)
+        {
+            Point point = new Point();
+            if (leftOrRight == "RIGHT")
+            {
+                point.X = particle.SEMPosX - int.Parse(ScanFieldSize) / 2 + particle.PosX;
+            }
+            else
+            {
+                point.X = particle.SEMPosX + int.Parse(ScanFieldSize) / 2 + particle.PosX;
+            }
+            if (downOrUp == "UP")
+            {
+                point.Y = particle.SEMPosY + int.Parse(ScanFieldSize) / 2 + particle.PosY;
+            }
+            else
+            {
+                point.Y = particle.SEMPosY - int.Parse(ScanFieldSize) / 2 + particle.PosY;
+            }
+
+            return point;
+        }
+
+        private void bgw_process_DoWork(object sender, DoWorkEventArgs e)
+        {
+            //颗粒信息
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+            string ImageResolution = imageScanParam["ImageResolution"].ToString();
+            int width = int.Parse(ImageResolution.Split('_')[1]);
+            int height = int.Parse(ImageResolution.Split('_')[2]);
+            Dictionary<string, object> SEMStageData = (Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"];
+            string ScanFieldSize = SEMStageData["scanFieldSize"].ToString();
+            string leftOrRight = SEMStageData["xAxisDir"].ToString().Split('_')[0];
+            string downOrUp = SEMStageData["yAxisDir"].ToString().Split('_')[0];
+
+            #region 按帧图分类
+            //Dictionary<int, List<Particle>> keyValues = new Dictionary<int, List<Particle>>();
+            //ParticleList.OrderBy(a => a.FieldId).ToList();
+            //for (int i = 0; i < ParticleList.Count; i++)
+            //{
+            //    if (keyValues.ContainsKey(ParticleList[i].FieldId))
+            //    {
+            //        List<Particle> Particles = keyValues[ParticleList[i].FieldId];
+            //        Particles.Add(ParticleList[i]);
+            //        keyValues[ParticleList[i].FieldId] = Particles;
+            //    }
+            //    else
+            //    {
+            //        List<Particle> Particles = new List<Particle>();
+            //        Particles.Add(ParticleList[i]);
+            //        keyValues.Add(ParticleList[i].FieldId, Particles);
+            //    }
+            //}
+            #endregion
+
+            //第一步,连接电镜
+            m_OTSIncAReportGridsFun.Connection_ForParticlesGrid();
+
+            Thread.Sleep(500);
+
+            SetProgressMessage("设置放大倍数", richTextBox_process);
+            if (!m_OTSIncAReportGridsFun.SetMagnification((double)NUD_MAG.Value))
+            {
+                SetProgressMessage("设置放大倍数失败", richTextBox_process);
+            }
+
+            for (int i = 0; i < SelectedParticles.Count; i++)
+            {
+                SetProgressMessage("开始处理颗粒:" + (i + 1), richTextBox_process);
+                if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
+                {
+                    Point point = GetPartPoint(leftOrRight, downOrUp, ScanFieldSize, SelectedParticles[i]);
+                    SetProgressMessage("移动到颗粒中心位置", richTextBox_process);
+                    if (!m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(point.X, point.Y))
+                    {
+                        SetProgressMessage("移动到颗粒中心位置失败", richTextBox_process);
+                    }
+                    SetProgressMessage("拍图", richTextBox_process);
+                    byte[] ImageByte = new byte[width * height];
+                    if (!m_OTSIncAReportGridsFun.AcquireBSEImage(width, height, nBrukerDwellTime, ref ImageByte))
+                    {
+                        SetProgressMessage("拍图失败", richTextBox_process);
+                    }
+                    bgw_process.ReportProgress(0, CImageHandler.ToGrayBitmap(ImageByte, width, height));
+                    SetProgressMessage("寻找新位置颗粒信息", richTextBox_process);
+                    if (!m_OTSIncAReportGridsFun.AcquireBSEImage(width, height, nBrukerDwellTime, ref ImageByte))
+                    {
+                        SetProgressMessage("拍图失败", richTextBox_process);
+                    }
+                }
+            }
+
+            Thread.Sleep(500);
+
+            //第三步,断开电镜连接
+            m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
+
+            //Thread.Sleep(500);
+        }
+
+        private void bgw_process_ProgressChanged(object sender, ProgressChangedEventArgs e)
+        {
+            switch (e.ProgressPercentage)
+            {
+                case 0: pictureBox_part.Image = (Bitmap)e.UserState; break;
+                default:
+                    break;
+            }
         }
     }
 }

+ 3 - 0
OTSIncAReportApp/1-UI/frmReMeasure.resx

@@ -117,4 +117,7 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="bgw_process.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
 </root>

+ 14 - 0
OTSIncAReportApp/1-UI/frmReportApp.cs

@@ -626,6 +626,11 @@ namespace OTSIncAReportApp
         /// <param name="sender"></param>
         /// <param name="e"></param>
         private void rbRenew_Click(object sender, EventArgs e)
+        {
+            rbRenewFun(false, 0, 0);
+        }
+
+        public void rbRenewFun(bool isReview, int FieldId, int ParticleId)
         {
             int tabIndex = (int)m_conditionChoose.tabIndex;
             //int idx = m_DataMgrFun.GetPropIndexByPropItemName(SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE);
@@ -645,12 +650,21 @@ namespace OTSIncAReportApp
 
                             m_SImageWindow.Controls.Clear();
                             im_Control_DrawDistrbutionImageAndBSE = new OTSIncAReportGraph.Controls.Control_DrawDistrbutionImageAndBSE(this);
+                            im_Control_DrawDistrbutionImageAndBSE.isReView = isReview;
+                            im_Control_DrawDistrbutionImageAndBSE.reViewFieldId = FieldId;
+                            im_Control_DrawDistrbutionImageAndBSE.reViewParticleId = ParticleId;
                             im_Control_DrawDistrbutionImageAndBSE.Dock = DockStyle.Fill;
                             m_SImageWindow.Controls.Add(im_Control_DrawDistrbutionImageAndBSE);
                             m_SImageWindow.Activate();
                             im_Control_DrawDistrbutionImageAndBSE.ShowSourceName = "";
                             im_Control_DrawDistrbutionImageAndBSE.DrawDistrbutionImageAndBSE_ByQuery(m_conditionChoose.m_SourceGridData);
                             im_Control_DrawDistrbutionImageAndBSE.SetSelectParticle(GetSelectedParticles());
+
+                            ConditionItem imgType = m_conditionChoose.m_CurrentConditions[OTS_REPORT_PROP_GRID_ITEMS.IMAGE_TYPE];
+                            //切换分布图显示方式
+                            IMAGE_TYPE t = (IMAGE_TYPE)imgType.itemVal;
+                            im_Control_DrawDistrbutionImageAndBSE.ShowMode(t);
+
                             //并删除排列图
                             im_Control_DrawDistrbutionSortImage = null;
                         }

+ 39 - 0
OTSIncAReportApp/3-ServiceCenter/HardwareController.cs

@@ -60,11 +60,50 @@ namespace ServiceInterface
         public bool DisConnect()
         {
             //remoteObj = null;
+            ifConnect = false;
 
             return true;
         }
 
+        public bool SetMagnification(double a_dMagnification)
+        {
+            //Connect();
+            if (remoteObj == null)
+            {
+                return false;
+
+            }
+            try
+            {
+                return remoteObj.SetMagnification(a_dMagnification);
+            }
+            catch (Exception e)
+            {
+                NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
+
+            }
+            return false;
+        }
 
+        public bool AcquireBSEImage(int width, int height, int dwellTime, ref byte[] ImageByte)
+        {
+            //Connect();
+            if (remoteObj == null)
+            {
+                return false;
+
+            }
+            try
+            {
+                return remoteObj.AcquireBSEImage(width, height, dwellTime, ref ImageByte);
+            }
+            catch (Exception e)
+            {
+                NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
+
+            }
+            return false;
+        }
 
 
         public bool MoveSEMToPoint(Point poi, double rotation)

+ 0 - 1
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -1260,7 +1260,6 @@
     <EmbeddedResource Include="Help.resx">
       <DependentUpon>Help.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Properties\licenses.licx" />
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>PublicResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>