Browse Source

Similarity search for adding spliced particles

cxs 1 month ago
parent
commit
ad82c3f70c

+ 2 - 2
Bin/x64/Debug/Config/SysData/OTSReportMgrParam.rpf

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <XMLData systype="TCCleannessA">
 <XMLData systype="TCCleannessA">
   <Member RegName="Scale" strValue="1000" />
   <Member RegName="Scale" strValue="1000" />
-  <Member RegName="DefaultComputedColName" strValue="ParticleCoordinate,Area,EquivalentCircleDiameter,MaxDiameter,MinDiameter,DiameterRatio,FerretDiameter,PERP,PERI,INSCR,MEAN,ELONG,ASPECT_ELONG,Orientation,XRayDataCount" />
-  <Member RegName="ElementsColName" strValue="C,O,Al,Fe,F,Ti,Na,Mn,Mg" />
+  <Member RegName="DefaultComputedColName" strValue="Area,MinDiameter,DiameterRatio,PERP,XRayDataCount" />
+  <Member RegName="ElementsColName" strValue="O,Mg,Si,Ti,Pm,N,Na,Cl,K,S,Ca,Al,Zr,P,Fe,Zn,Cu,F,Sn,Br,V,Ba,Ni,Mo,Cr" />
   <Member RegName="PartSizeFile" name="Li5-50.psf" />
   <Member RegName="PartSizeFile" name="Li5-50.psf" />
   <Member RegName="TRIO_CHART_TYPE" strValue="CaO.SiO₂.Al₂O₃" />
   <Member RegName="TRIO_CHART_TYPE" strValue="CaO.SiO₂.Al₂O₃" />
   <Member RegName="SIZE_CAL_METHOD_TYPE" strValue="DMAX" />
   <Member RegName="SIZE_CAL_METHOD_TYPE" strValue="DMAX" />

+ 99 - 131
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ListOfSimilarParticles.cs

@@ -28,7 +28,6 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
         DataTable particlesAll;
         DataTable particlesAll;
         DataTable particles;
         DataTable particles;
         Hashtable table;
         Hashtable table;
-        int _classifyid;
         List<string> _RenameInfo;
         List<string> _RenameInfo;
         private Thread m_mythread;
         private Thread m_mythread;
         //记录线程是否已经运行完成的状态
         //记录线程是否已经运行完成的状态
@@ -38,13 +37,12 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
         frmReportApp m_ReportApp;
         frmReportApp m_ReportApp;
 
 
 
 
-		public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, int classifyid, List<string> RenameInfo,frmReportApp ReportApp)
+		public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, List<string> RenameInfo,frmReportApp ReportApp)
         {
         {
             InitializeComponent();
             InitializeComponent();
             _particlesGridDevidePage = particlesGridDevidePage;
             _particlesGridDevidePage = particlesGridDevidePage;
             SelXrayclr.SetXrayData(SelXray);
             SelXrayclr.SetXrayData(SelXray);
             table = particlesGridDevidePage.table;
             table = particlesGridDevidePage.table;
-            _classifyid = classifyid;
             _RenameInfo = RenameInfo;
             _RenameInfo = RenameInfo;
             m_ReportApp = ReportApp;
             m_ReportApp = ReportApp;
 			m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
 			m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
@@ -85,7 +83,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             else
             else
             {
             {
                 this.Cursor = Cursors.WaitCursor;
                 this.Cursor = Cursors.WaitCursor;
-                particlesAll = ObtainSourceOfSimilarParticles(_classifyid);
+                particlesAll = ObtainSourceOfSimilarParticles();
 
 
 
 
 
 
@@ -104,11 +102,6 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     particlesAll.Rows[i]["Element"] = ConcatenatedString;
                     particlesAll.Rows[i]["Element"] = ConcatenatedString;
                 }
                 }
                 particlesAll.Columns.Add("SimilarRatio", typeof(double));
                 particlesAll.Columns.Add("SimilarRatio", typeof(double));
-                DataTable mergeParticles = _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_mergeParticles("");
-                if (mergeParticles != null && mergeParticles.Rows.Count > 0)
-                {
-                    _particlesGridDevidePage.Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
-                }
                 DataTable XRayData = _particlesGridDevidePage.Particledata.GetXRayData();
                 DataTable XRayData = _particlesGridDevidePage.Particledata.GetXRayData();
                 particlesAll.Columns.Add("XRayDataCount");
                 particlesAll.Columns.Add("XRayDataCount");
                 particles = particlesAll.Clone();
                 particles = particlesAll.Clone();
@@ -116,36 +109,53 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                 {
                 {
                     if (int.Parse(particlesAll.Rows[i]["particleId"].ToString()) > -1)
                     if (int.Parse(particlesAll.Rows[i]["particleId"].ToString()) > -1)
                     {
                     {
+                        string subt = particlesAll.Rows[i]["SubParticles"].ToString();
+                        uint[] Analysis_xray = new uint[2000];
                         particlesAll.Rows[i]["XRayDataCount"] = 0;
                         particlesAll.Rows[i]["XRayDataCount"] = 0;
-                        string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
-                        DataRow[] drs = XRayData.Select(str);
-                        uint xraycount = 0;
-                        if (drs != null)
+                        if (subt == "")
                         {
                         {
-                            if (drs.Length > 0)
+                            string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
+                            DataRow[] drs = XRayData.Select(str);
+                            uint xraycount = 0;
+                            if (drs != null)
                             {
                             {
-                                uint[] Analysis_xray = new uint[2000];
-                                for (int j = 0; j < 2000; j++)
-                                {
-                                    Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
-                                }
-                                for (int j = 0; j < 2000; j++)
+                                if (drs.Length > 0)
                                 {
                                 {
-                                    xraycount += Analysis_xray[j];
-                                }
-                                particlesAll.Rows[i]["XRayDataCount"] = xraycount;
-                                CPosXrayClr Xrayclr = new CPosXrayClr();
-                                Xrayclr.SetXrayData(Analysis_xray);
-                                particlesAll.Rows[i]["SimilarRatio"] = GetCosValue(SelXrayclr, Xrayclr);
-                                if ((double)particlesAll.Rows[i]["SimilarRatio"] >= val / 100)
-                                {
-                                    particles.ImportRow(particlesAll.Rows[i]);
+                                    for (int j = 0; j < 2000; j++)
+                                    {
+                                        Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
+                                    }
+                                    for (int j = 0; j < 2000; j++)
+                                    {
+                                        xraycount += Analysis_xray[j];
+                                    }
+                                    particlesAll.Rows[i]["XRayDataCount"] = xraycount;
                                 }
                                 }
                             }
                             }
                         }
                         }
+                        else
+                        {
+                            DataRow dgvr = particlesAll.Rows[i];
+                            uint[] Search_xray = new uint[2000];
+                            _particlesGridDevidePage.Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Search_xray, out Analysis_xray);
+                            uint xraycount = 0;
+                            for (int j = 0; j < 2000; j++)
+                            {
+                                xraycount += Analysis_xray[j];
+                            }
+                            particlesAll.Rows[i]["XRayDataCount"] = xraycount;
+                        }
+                        CPosXrayClr Xrayclr = new CPosXrayClr();
+                        Xrayclr.SetXrayData(Analysis_xray);
+                        particlesAll.Rows[i]["SimilarRatio"] = GetCosValue(SelXrayclr, Xrayclr);
+                        if ((double)particlesAll.Rows[i]["SimilarRatio"] >= val / 100)
+                        {
+                            particles.ImportRow(particlesAll.Rows[i]);
+                        }
                     }
                     }
                 }
                 }
 
 
+                
                 particles.DefaultView.Sort = "SimilarRatio DESC";
                 particles.DefaultView.Sort = "SimilarRatio DESC";
                 particles = particles.DefaultView.ToTable();
                 particles = particles.DefaultView.ToTable();
                 BindDataGridView();
                 BindDataGridView();
@@ -347,7 +357,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             for (int i = 0; i < particles.Rows.Count; i++)
             for (int i = 0; i < particles.Rows.Count; i++)
             {
             {
                 Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
                 Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
-
+                Dictionary<string, Bitmap> fieldpics = new Dictionary<string, Bitmap>();
                 int add_rowindex = dgV_SimilarParticles.Rows.Add();
                 int add_rowindex = dgV_SimilarParticles.Rows.Add();
                 for (int k = 0; k < keyValues.Count; k++)
                 for (int k = 0; k < keyValues.Count; k++)
                 {
                 {
@@ -355,50 +365,45 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     {
                     {
                         if (enl.Current.Key == "ParticleImage")
                         if (enl.Current.Key == "ParticleImage")
                         {
                         {
-                            if (particles.Columns.Contains("SubParticles"))
+                            string subt = particles.Rows[i]["SubParticles"].ToString();
+                            dgV_SimilarParticles.Rows[add_rowindex].Height = 150;
+
+
+                            dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
+
+                            Bitmap bmap = null;
+                            if (subt != null && subt != "" && subt != "IsSubParticle")
                             {
                             {
-                                string subt = particles.Rows[i]["SubParticles"].ToString();
-                                if (subt != null && subt != "")
+                                double ScanFieldSize = _particlesGridDevidePage.result.GetScanFieldSizeX();
+                                string filePatht = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
+                                string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
+                                Bitmap tempbit = _particlesGridDevidePage.Particledata.ReadImageFile(imagePatht);
+                                int pixw = tempbit.Width;
+                                double xs = pixw / ScanFieldSize;
+                                OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = _particlesGridDevidePage.result.GetXAxisDirEnum();
+                                OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = _particlesGridDevidePage.result.GetYAxisDirEnum();
+                                bmap = _particlesGridDevidePage.Particledata.GetBitmapForBig(subt, xs, _particlesGridDevidePage.result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
+                                if (bmap != null)
                                 {
                                 {
-                                    double ScanFieldSize = _particlesGridDevidePage.result.GetScanFieldSizeX();
-                                    string filePatht = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
-                                    string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
-                                    Bitmap tempbit = _particlesGridDevidePage.Particledata.ReadImageFile(imagePatht);
-                                    int pixw = tempbit.Width;
-                                    double xs = pixw / ScanFieldSize;
-                                    OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = _particlesGridDevidePage.result.GetXAxisDirEnum();
-                                    OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = _particlesGridDevidePage.result.GetYAxisDirEnum();
-                                    particleM = particleM + "," + subt;
-                                    Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapForBig(subt, xs, _particlesGridDevidePage.result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
-                                    if (bmap != null)
-                                    {
-                                        string[] str = subt.Split(',');
-                                        bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
-                                        dgV_SimilarParticles.Rows[add_rowindex].Height = 150;
-                                        dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = bmap;
-                                        dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
-                                        dgV_SimilarParticles.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
-                                    }
-                                    else
-                                    {
-                                        dgV_SimilarParticles.Rows[add_rowindex].Height = 150;
-                                        dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
-                                    }
+                                    string[] str = subt.Split(',');
+                                    bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1] };
                                 }
                                 }
                             }
                             }
-                            else
+                            else if (subt != "IsSubParticle")
                             {
                             {
-                                if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
+                                if (!fieldpics.Keys.Contains(particles.Rows[i]["fieldid"].ToString()))
                                 {
                                 {
                                     string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
                                     string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-                                    FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), _particlesGridDevidePage.Particledata.ReadImageFile(imagePath));
+
+
+                                    fieldpics.Add(particles.Rows[i]["fieldid"].ToString(), _particlesGridDevidePage.Particledata.ReadImageFile(imagePath));
                                 }
                                 }
                                 Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
                                 Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
-                                Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapByParticle(FieldImage.Value, rectangle);
-                                bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString(), particles.Rows[i]["XrayId"].ToString() };
-                                dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = bmap;
+                                bmap = _particlesGridDevidePage.Particledata.GetBitmapByParticle(fieldpics[particles.Rows[i]["fieldid"].ToString()], rectangle);
+                                bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString() };
                                 dgV_SimilarParticles.Rows[add_rowindex].Height = bmap.Height + 20;
                                 dgV_SimilarParticles.Rows[add_rowindex].Height = bmap.Height + 20;
                             }
                             }
+                            dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = bmap;
                         }
                         }
                         if (enl.Current.Key == "DiameterRatio")
                         if (enl.Current.Key == "DiameterRatio")
                         {
                         {
@@ -716,25 +721,9 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             dgV_SimilarParticles.Rows[0].Cells[0].Value = true;
             dgV_SimilarParticles.Rows[0].Cells[0].Value = true;
         }
         }
 
 
-        DataTable ObtainSourceOfSimilarParticles(int _classifyid)
+        DataTable ObtainSourceOfSimilarParticles()
         {
         {
-            if (_classifyid == -1)
-            {
-                return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_InvalidParticle("");
-            }
-            else if (_classifyid == 9)
-            {
-                return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_NotIdentifyParticle("");
-            }
-            else if (_classifyid != 4)
-            {
-                return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_analyticalParticle("");
-            }
-            else if (_classifyid == 4)
-            {
-                return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_LowCountsParticle("");
-            }
-            return null;
+            return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_allParticles("");
         }
         }
 
 
         private void btn_Cannnel_Click(object sender, EventArgs e)
         private void btn_Cannnel_Click(object sender, EventArgs e)
@@ -752,77 +741,46 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                 {
                 {
                     DataGridViewRow dgvr = SelectRows[0];
                     DataGridViewRow dgvr = SelectRows[0];
                     Bitmap ls_bp = (Bitmap)dgvr.Cells[3].Value;
                     Bitmap ls_bp = (Bitmap)dgvr.Cells[3].Value;
-                    List<string> list_str = (List<string>)ls_bp.Tag;
                     uint[] Search_xray = new uint[2000];
                     uint[] Search_xray = new uint[2000];
                     uint[] Analysis_xray = new uint[2000];
                     uint[] Analysis_xray = new uint[2000];
                     int i_xray_id = 0;
                     int i_xray_id = 0;
                     List<Element> list_celementchemistryclr = new List<Element>();
                     List<Element> list_celementchemistryclr = new List<Element>();
-                    _particlesGridDevidePage.ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
-
-                    List<OTSIncAReportGraph.Controls.ShowElementInfo> list_showelementinfo = new List<OTSIncAReportGraph.Controls.ShowElementInfo>();
-                    for (int i = 0; i < list_celementchemistryclr.Count; i++)
+                    Particle particle = new Particle();
+                    string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
+                    DataRow[] drs = particles.Select(str);
+                    DataRow row = drs[0];
+                    string subt = row["SubParticles"].ToString();
+                    if (subt != "" && subt != null)
                     {
                     {
-                        OTSIncAReportGraph.Controls.ShowElementInfo ls_sei = new OTSIncAReportGraph.Controls.ShowElementInfo();
-                        ls_sei.ElementName = list_celementchemistryclr[i].Name;
-                        ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
-                        ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
-                        double de_sx2 = 0;
-                        if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
-                        {
-                            de_sx2 = 0;
-                        }
-                        else
-                        {
-                            de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
-                        }
-                        ls_sei.dLF = de_sx2;
-                        list_showelementinfo.Add(ls_sei);
+                        particle = _particlesGridDevidePage.Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray);
+                        list_celementchemistryclr = particle.ElementList;
+                    }
+                    else
+                    {
+                        particle = _particlesGridDevidePage.ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
                     }
                     }
 
 
-
-                    list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
+                    List<OTSIncAReportGraph.Controls.ShowElementInfo> list_showelementinfo = _particlesGridDevidePage.Particledata.GetShowElementInfos_ForMergeParticle(list_celementchemistryclr);
                     string str_IncAName = "";
                     string str_IncAName = "";
                     str_IncAName = Convert.ToString(dgvr.Cells[2].Value);
                     str_IncAName = Convert.ToString(dgvr.Cells[2].Value);
-                    Particle particle = _particlesGridDevidePage.result.List_OTSField.Find(x => x.FieldID == Convert.ToInt32(dgvr.Cells["fieldid"].Value)).ParticleList.Find(x => x.ParticleId == Convert.ToInt32(dgvr.Cells["particleId"].Value));
                     if (particle == null)
                     if (particle == null)
                     {
                     {
                         return;
                         return;
                     }
                     }
                     control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + "  " + "DMAX:" + Math.Round(particle.DMAX, 2) + "  " + "DELONG:" + Math.Round(particle.DELONG, 2) + "  " + "DFERET:" + Math.Round(particle.DFERET, 2) + "  " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + "  " + "DMIN:" + Math.Round(particle.DMIN, 2) + "  " + "DPERP:" + Math.Round(particle.DPERP, 2) + "  " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + "  " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
                     control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + "  " + "DMAX:" + Math.Round(particle.DMAX, 2) + "  " + "DELONG:" + Math.Round(particle.DELONG, 2) + "  " + "DFERET:" + Math.Round(particle.DFERET, 2) + "  " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + "  " + "DMIN:" + Math.Round(particle.DMIN, 2) + "  " + "DPERP:" + Math.Round(particle.DPERP, 2) + "  " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + "  " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
-
                     control_XRayTable1.Visible = true;
                     control_XRayTable1.Visible = true;
                     control_XRayTable1.SetXRayShowLineValue(null, Analysis_xray, list_showelementinfo);
                     control_XRayTable1.SetXRayShowLineValue(null, Analysis_xray, list_showelementinfo);
-                    //颗粒国标信息
                     control_XRayTable1.GBInfoStr = "";
                     control_XRayTable1.GBInfoStr = "";
-                    control_XRayTable1.MaterialName = str_IncAName;//杂夹物
-
+                    control_XRayTable1.MaterialName = str_IncAName;
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
 
 
-                    string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
-                    DataRow[] drs = particles.Select(str);
-                    if (drs.Length > 0)
+                    if (subt == "" || subt == null)
                     {
                     {
                         Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particle.RectLeft), Y = Convert.ToInt32(particle.RectTop), Width = Convert.ToInt32(particle.RectWidth), Height = Convert.ToInt32(particle.RectHeight) };
                         Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particle.RectLeft), Y = Convert.ToInt32(particle.RectTop), Width = Convert.ToInt32(particle.RectWidth), Height = Convert.ToInt32(particle.RectHeight) };
-                        Bitmap dpImage = new Bitmap(_particlesGridDevidePage.result.GetImageWidth(), _particlesGridDevidePage.result.GetImageHeight());
-                        using (Graphics graphics = Graphics.FromImage(dpImage))
-                        {
-                            graphics.Clear(Color.White); // 清除位图背景为白色
-                        }
+                        Bitmap dpImage = _particlesGridDevidePage.ReportFun.GetBlackAndWhiteImage(particle);
                         string filePath = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
                         string filePath = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
                         string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
                         string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
                         Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
                         Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
-
-                        foreach (Segment seg in particle.SegmentList)
-                        {
-                            int f_length = seg.Length;
-                            for (int m = 0; m < f_length; m++)
-                            {
-                                int lsjs_x = seg.Start + m;
-                                int lsjs_y = seg.Height;
-                                var pixelColor = m_originalImage.GetPixel(lsjs_x, lsjs_y);
-                                dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
-                            }
-                        }
                         Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapByParticle(dpImage, rectangle);
                         Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapByParticle(dpImage, rectangle);
                         Bitmap bmap1 = _particlesGridDevidePage.Particledata.GetBitmapByParticle(m_originalImage, rectangle);
                         Bitmap bmap1 = _particlesGridDevidePage.Particledata.GetBitmapByParticle(m_originalImage, rectangle);
                         control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
                         control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
@@ -830,7 +788,18 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     }
                     }
                     else
                     else
                     {
                     {
-                        control_XRayTable1.Visible = false;
+                        double ScanFieldSize = _particlesGridDevidePage.result.GetScanFieldSizeX();
+                        string filePatht = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
+
+                        string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
+                        Bitmap tempbit = _particlesGridDevidePage.Particledata.ReadImageFile(imagePatht);
+                        int pixw = tempbit.Width;
+                        double xs = pixw / ScanFieldSize;
+                        OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = _particlesGridDevidePage.result.GetXAxisDirEnum();
+                        OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = _particlesGridDevidePage.result.GetYAxisDirEnum();
+                        Bitmap bp = _particlesGridDevidePage.Particledata.GetBitmapForBigBlackAndWhiteImage(subt, xs, _particlesGridDevidePage.result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
+                        control_XRayTable1.SetBitmapOfPictureBox(ls_bp, bp);
+                        Invalidate();
                     }
                     }
                 }
                 }
             }
             }
@@ -953,13 +922,12 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                 }
                 }
             }
             }
         }
         }
-        public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, int classifyid, frmReportApp ReportApp)
+        public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, frmReportApp ReportApp)
         {
         {
             InitializeComponent();
             InitializeComponent();
             _particlesGridDevidePage = particlesGridDevidePage;
             _particlesGridDevidePage = particlesGridDevidePage;
             SelXrayclr.SetXrayData(SelXray);
             SelXrayclr.SetXrayData(SelXray);
             table = particlesGridDevidePage.table;
             table = particlesGridDevidePage.table;
-            _classifyid = classifyid;
 			m_ReportApp = ReportApp;
 			m_ReportApp = ReportApp;
 			m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
 			m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
 
 

+ 48 - 55
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -371,48 +371,41 @@ namespace OTSIncAReportGrids
                 particlesAll.Rows[i]["Element"] = ConcatenatedString;
                 particlesAll.Rows[i]["Element"] = ConcatenatedString;
             }
             }
             particlesAll.Columns.Add("XRayDataCount");
             particlesAll.Columns.Add("XRayDataCount");
-            if (sel != (int)SelItem.MergeParticles)
+            DataTable XRayData = Particledata.GetXRayData();
+            for (int i = 0; i < particlesAll.Rows.Count; i++)
             {
             {
-                DataTable XRayData = Particledata.GetXRayData();
-                for (int i = 0; i < particlesAll.Rows.Count; i++)
+                string subt = particlesAll.Rows[i]["SubParticles"].ToString();
+                if (subt =="")
                 {
                 {
-                    if (int.Parse(particlesAll.Rows[i]["particleId"].ToString()) > -1)
+                    particlesAll.Rows[i]["XRayDataCount"] = 0;
+                    string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
+                    DataRow[] drs = XRayData.Select(str);
+                    uint xraycount = 0;
+                    if (drs != null)
                     {
                     {
-                        particlesAll.Rows[i]["XRayDataCount"] = 0;
-                        string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
-                        DataRow[] drs = XRayData.Select(str);
-                        
-                        
-                        uint xraycount = 0;
-                        if (drs != null)
+                        if (drs.Length > 0)
                         {
                         {
-                            if (drs.Length > 0)
+                            uint[] Analysis_xray = new uint[2000];
+                            for (int j = 0; j < 2000; j++)
                             {
                             {
-                                uint[] Analysis_xray = new uint[2000];
-                                for (int j = 0; j < 2000; j++)
-                                {
-                                    Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
-                                }
-                                for (int j = 0; j < 2000; j++)
-                                {
-                                    xraycount += Analysis_xray[j];
-                                }
-                                particlesAll.Rows[i]["XRayDataCount"] = xraycount;
+                                Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
                             }
                             }
+                            for (int j = 0; j < 2000; j++)
+                            {
+                                xraycount += Analysis_xray[j];
+                            }
+                            particlesAll.Rows[i]["XRayDataCount"] = xraycount;
                         }
                         }
                     }
                     }
                 }
                 }
-            }
-            else
-            {
-                for (int i = 0; i < particlesAll.Rows.Count; i++)
+                else
                 {
                 {
+
                     particlesAll.Rows[i]["XRayDataCount"] = 0;
                     particlesAll.Rows[i]["XRayDataCount"] = 0;
                     DataRow dgvr = particlesAll.Rows[i];
                     DataRow dgvr = particlesAll.Rows[i];
-                    var tPt = new ParticleData(ReportFun.resultFile.FilePath);
                     uint[] Search_xray = new uint[2000];
                     uint[] Search_xray = new uint[2000];
                     uint[] Analysis_xray = new uint[2000];
                     uint[] Analysis_xray = new uint[2000];
-                    tPt.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Search_xray, out Analysis_xray);
+                    Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Search_xray, out Analysis_xray);
                     uint xraycount = 0;
                     uint xraycount = 0;
                     for (int j = 0; j < 2000; j++)
                     for (int j = 0; j < 2000; j++)
                     {
                     {
@@ -538,7 +531,6 @@ namespace OTSIncAReportGrids
                                     string[] str = subt.Split(',');
                                     string[] str = subt.Split(',');
                                     bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1] };
                                     bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1] };
                                 }
                                 }
-                                bmap.Save("C:\\Users\\yunyunyun\\Desktop\\9-9-1\\aa.bmp");
                             }
                             }
                             else if (subt != "IsSubParticle")
                             else if (subt != "IsSubParticle")
                             {
                             {
@@ -1802,7 +1794,6 @@ namespace OTSIncAReportGrids
                         }
                         }
                         var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
                         var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
                         uint[] Search_xray = new uint[2000];
                         uint[] Search_xray = new uint[2000];
-                        int classifyid = -1;
                         if (SelectRows.Count != 0)
                         if (SelectRows.Count != 0)
                         {
                         {
                             if (SelectRows.Count == 1)
                             if (SelectRows.Count == 1)
@@ -1810,14 +1801,13 @@ namespace OTSIncAReportGrids
                                 DataGridViewRow dgvr = SelectRows[0];
                                 DataGridViewRow dgvr = SelectRows[0];
                                 Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
                                 Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
                                 List<string> list_str = (List<string>)ls_bp.Tag;
                                 List<string> list_str = (List<string>)ls_bp.Tag;
-                                classifyid = Convert.ToInt32(list_str[2]);
                                 uint[] Analysis_xray = new uint[2000];
                                 uint[] Analysis_xray = new uint[2000];
                                 int i_xray_id = 0;
                                 int i_xray_id = 0;
                                 List<Element> list_celementchemistryclr = new List<Element>();
                                 List<Element> list_celementchemistryclr = new List<Element>();
                                 ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
                                 ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
                             }
                             }
                         }
                         }
-                        ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Search_xray, classifyid, strings, m_ReportApp);
+                        ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Search_xray, strings, m_ReportApp);
                         DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
                         DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
                         if (result3 == DialogResult.OK)
                         if (result3 == DialogResult.OK)
                         {
                         {
@@ -1891,6 +1881,9 @@ namespace OTSIncAReportGrids
                 lnkFirst_Click(null, null);
                 lnkFirst_Click(null, null);
                 SetDataGridViewStyle();
                 SetDataGridViewStyle();
                 DataTable table = GetClassificationOfAllParticles();
                 DataTable table = GetClassificationOfAllParticles();
+
+
+
                 if (table != null)
                 if (table != null)
                 {
                 {
                     if (table.Rows.Count > 0)
                     if (table.Rows.Count > 0)
@@ -2521,7 +2514,6 @@ namespace OTSIncAReportGrids
                         OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
                         OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
                         OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
                         OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
                         Bitmap bp= Particledata.GetBitmapForBigBlackAndWhiteImage(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
                         Bitmap bp= Particledata.GetBitmapForBigBlackAndWhiteImage(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
-                        bp.Save("C:\\Users\\yunyunyun\\Desktop\\9-9-1\\aa.bmp");
                         control_XRayTable1.SetBitmapOfPictureBox(ls_bp,bp);
                         control_XRayTable1.SetBitmapOfPictureBox(ls_bp,bp);
                         Invalidate();
                         Invalidate();
                     }
                     }
@@ -2628,33 +2620,34 @@ namespace OTSIncAReportGrids
         private void 根据相似度批量修改ToolStripMenuItem_Click(object sender, EventArgs e)
         private void 根据相似度批量修改ToolStripMenuItem_Click(object sender, EventArgs e)
         {
         {
             //如果没有选中颗粒退出
             //如果没有选中颗粒退出
-            if (dgV_ParticlesDevidePage.SelectedRows.Count == 0)
-            {
-                return;
-            }
-            int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
-            if (sel == (int)SelItem.MergeParticles)
+            if (dgV_ParticlesDevidePage.SelectedRows.Count != 1)
             {
             {
+                MessageBox.Show("Please select one row!");
                 return;
                 return;
             }
             }
             var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
             var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
             uint[] Search_xray = new uint[2000];
             uint[] Search_xray = new uint[2000];
-            int classifyid = -1;
-            if (SelectRows.Count != 0)
+
+            DataGridViewRow dgvr = SelectRows[0];
+            Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
+            List<string> list_str = (List<string>)ls_bp.Tag;
+            uint[] Analysis_xray = new uint[2000];
+            int i_xray_id = 0;
+            List<Element> list_celementchemistryclr = new List<Element>();
+
+            string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
+            DataRow[] drs = particles.Select(str);
+            DataRow row = drs[0];
+            string subt = row["SubParticles"].ToString();
+            if (subt != "" && subt != null)
             {
             {
-                if (SelectRows.Count == 1)
-                {
-                    DataGridViewRow dgvr = SelectRows[0];
-                    Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
-                    List<string> list_str = (List<string>)ls_bp.Tag;
-                    classifyid = Convert.ToInt32(list_str[2]);
-                    uint[] Analysis_xray = new uint[2000];
-                    int i_xray_id = 0;
-                    List<Element> list_celementchemistryclr = new List<Element>();
-                    ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
-                }
+                Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray);
             }
             }
-            ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Search_xray, classifyid, m_ReportApp);
+            else
+            {
+                ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
+            }
+            ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Search_xray, m_ReportApp);
             DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
             DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
             if (result3 == DialogResult.OK)
             if (result3 == DialogResult.OK)
             {
             {
@@ -2666,9 +2659,9 @@ namespace OTSIncAReportGrids
                 {
                 {
                     if (table.Rows.Count > 0)
                     if (table.Rows.Count > 0)
                     {
                     {
-                        foreach (DataRow row in table.Rows)
+                        foreach (DataRow rw in table.Rows)
                         {
                         {
-                            tbx_Type.Text += row["TypeName"].ToString() + '$';
+                            tbx_Type.Text += rw["TypeName"].ToString() + '$';
                         }
                         }
                     }
                     }
                     if (tbx_Type.Text != "")
                     if (tbx_Type.Text != "")

+ 4 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/ParticleData.cs

@@ -804,6 +804,10 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return DT1;
             return DT1;
         }
         }
 
 
+
+
+
+
         public DataTable GetInfoForPartucleDevidePage_allParticles(string condition)
         public DataTable GetInfoForPartucleDevidePage_allParticles(string condition)
         {
         {
             string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData  where xrayid > -1 and SubParticles is not 'IsSubParticle' " +
             string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData  where xrayid > -1 and SubParticles is not 'IsSubParticle' " +