Browse Source

Fix the bugs caused by the structural adjustment

cxs 3 weeks ago
parent
commit
f196b6f637

+ 0 - 24
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -408,30 +408,6 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             }
 
         }
-        public Bitmap GetBlackAndWhiteImage(Particle particle)
-        {
-            Bitmap dpImage = new Bitmap(resultFile.GetImageWidth(), resultFile.GetImageHeight());
-
-            using (Graphics graphics = Graphics.FromImage(dpImage))
-            {
-                graphics.Clear(Color.White); // 清除位图背景为白色
-            }
-
-            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;
-                    dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
-                }
-            }
-            return dpImage;
-        }
-
-
-
         #region 颗粒分割功能方法
         /// <summary>
         /// 获取线段与矩形的两个交点

+ 66 - 52
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ListOfSimilarParticles.cs

@@ -2,6 +2,9 @@
 using OTSCommon;
 using OTSCommon.DBOperate;
 using OTSCommon.DBOperate.Model;
+using OTSIncAReportApp._2_CommonFunction.CommonClass;
+using OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess;
+using OTSIncAReportApp.DataOperation.DataAccess;
 using OTSIncAReportApp.OTSRstMgrFunction;
 using OTSIncAReportGraph.Class;
 using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
@@ -35,9 +38,17 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
         //底层操作类
         SEMAndEDSOperate m_OTSIncAReportGridsFun = null;
         frmReportApp m_ReportApp;
+        public ParticleData Particledata;
+        public UserSTDDbAccess userSTDDb;
+        public FieldImage fldImgAccess;
+        public ResultFile _result = null;
 
 
-		public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, List<string> RenameInfo,frmReportApp ReportApp)
+
+
+
+
+        public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, List<string> RenameInfo,frmReportApp ReportApp)
         {
             InitializeComponent();
             _particlesGridDevidePage = particlesGridDevidePage;
@@ -46,8 +57,9 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             _RenameInfo = RenameInfo;
             m_ReportApp = ReportApp;
 			m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
-
-
+            _result= particlesGridDevidePage.result;
+            fldImgAccess = new FieldImage(_result.FilePath);
+            Particledata = new ParticleData(_result.FilePath);
             //设置窗体的双缓冲,以保证大数据时拖动不卡
             this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
             this.UpdateStyles();
@@ -84,12 +96,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             {
                 this.Cursor = Cursors.WaitCursor;
                 particlesAll = ObtainSourceOfSimilarParticles();
-
-
-
-
-
-                DataTable elementchemistry = _particlesGridDevidePage.Particledata.GetElementChemistry();
+                DataTable elementchemistry = Particledata.GetElementChemistry();
                 for (int i = 0; i < particlesAll.Rows.Count; i++)
                 {
                     string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
@@ -102,7 +109,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     particlesAll.Rows[i]["Element"] = ConcatenatedString;
                 }
                 particlesAll.Columns.Add("SimilarRatio", typeof(double));
-                DataTable XRayData = _particlesGridDevidePage.Particledata.GetXRayData();
+                DataTable XRayData = Particledata.GetXRayData();
                 particlesAll.Columns.Add("XRayDataCount");
                 particles = particlesAll.Clone();
                 for (int i = 0; i < particlesAll.Rows.Count; i++)
@@ -137,7 +144,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                         {
                             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);
+                            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++)
                             {
@@ -216,7 +223,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             dgV_SimilarParticles.Rows.Clear();
             dgV_SimilarParticles.Columns.Clear();
             string str_DefaultComputedColName = "", str_ElementsColName = "";
-            DataSet ds = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
+            DataSet ds = OTSCommon.XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
             DataTable dt = ds.Tables["Member"];
             foreach (DataRow element in dt.Rows)
             {
@@ -374,14 +381,12 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                             Bitmap bmap = null;
                             if (subt != null && subt != "" && subt != "IsSubParticle")
                             {
-                                double xs = _particlesGridDevidePage.result.GetPixelSize();
-                                int width = _particlesGridDevidePage.result.GetImageWidth();
-                                int height = _particlesGridDevidePage.result.GetImageHeight();
-
-
+                                double xs = 1/_result.GetPixelSize();
+                                int width = _result.GetImageWidth();
+                                int height = _result.GetImageHeight();
                                 string vs = "," + subt.Replace(':', '-') + ",";
-                                DataTable dataTable = _particlesGridDevidePage.Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
-                                bmap = _particlesGridDevidePage.fldImgAccess.GetBitmapForMergedParticle(subt, xs, _particlesGridDevidePage.result.FilePath, height, width, dataTable);
+                                DataTable dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
+                                bmap = fldImgAccess.GetBitmapForMergedParticle(subt, xs, height, width, dataTable);
                                 if (bmap != null)
                                 {
                                     string[] str = subt.Split(',');
@@ -392,13 +397,11 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                             {
                                 if (!fieldpics.Keys.Contains(particles.Rows[i]["fieldid"].ToString()))
                                 {
-                                    string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-
-
-                                    fieldpics.Add(particles.Rows[i]["fieldid"].ToString(), _particlesGridDevidePage.fldImgAccess.ReadImageFile(imagePath));
+                                    string imagePath =  "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
+                                    fieldpics.Add(particles.Rows[i]["fieldid"].ToString(), fldImgAccess.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"]) };
-                                bmap = _particlesGridDevidePage.fldImgAccess.GetBitmapByParticle(fieldpics[particles.Rows[i]["fieldid"].ToString()], rectangle);
+                                bmap = fldImgAccess.CapturePic(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;
                             }
@@ -427,9 +430,10 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                                 {
                                     dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 5);
                                 }
-                                else 
-                                { 
-                                    dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 2);}
+                                else
+                                {
+                                    dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 2);
+                                }
                             }
                             else if (enl.Current.Key == "Element")
                             {
@@ -598,11 +602,11 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     ints.Add(i_ls_fieldid);
                     ints.Add(i_ls_particleid);
 
-                    var cmd = _particlesGridDevidePage.Particledata.GetUpdataAIncACmd(ints, _RenameInfo);
+                    var cmd = Particledata.GetUpdataAIncACmd(ints, _RenameInfo);
                     cmdlist.Add(cmd);
                 }
             }
-            _particlesGridDevidePage.Particledata.ExecuteNonQueryBatch(cmdlist);
+            Particledata.ExecuteNonQueryBatch(cmdlist);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
@@ -643,7 +647,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                 dt_ClassifySTD.Columns.Add("GroupName");
                 dt_ClassifySTD.Columns.Add("GroupColor");
 
-                DataTable da = _particlesGridDevidePage.Particledata.GetParticleListForParticlSizeID("area", "");
+                DataTable da = Particledata.GetParticleListForParticlSizeID("area", "");
                 for (int i = 0; i < da.Rows.Count; i++)
                 {
                     if (Convert.ToInt64(da.Rows[i]["TypeId"]) > 9)
@@ -722,7 +726,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
 
         DataTable ObtainSourceOfSimilarParticles()
         {
-            return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_allParticles("");
+            return Particledata.GetInfoForPartucleDevidePage_allParticles("");
         }
 
         private void btn_Cannnel_Click(object sender, EventArgs e)
@@ -751,7 +755,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     string subt = row["SubParticles"].ToString();
                     if (subt != "" && subt != null)
                     {
-                        particle = _particlesGridDevidePage.Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray);
+                        particle = 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
@@ -759,7 +763,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                         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<OTSIncAReportGraph.Controls.ShowElementInfo> list_showelementinfo = _particlesGridDevidePage.Particledata.GetShowElementInfos_ForMergeParticle(list_celementchemistryclr);
+                    List<OTSIncAReportGraph.Controls.ShowElementInfo> list_showelementinfo = Particledata.GetShowElementInfos_ForMergeParticle(list_celementchemistryclr);
                     string str_IncAName = "";
                     str_IncAName = Convert.ToString(dgvr.Cells[2].Value);
                     if (particle == null)
@@ -773,32 +777,39 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
                     control_XRayTable1.MaterialName = str_IncAName;
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
 
+                    DataTable dataTable = new DataTable();
+                    double xs = 1 / _result.GetPixelSize();
+                    int width = _result.GetImageWidth();
+                    int height = _result.GetImageHeight();
+                    Dictionary<string, List<Segment>> segsData = new Dictionary<string, List<Segment>>();
+
                     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) };
-                        Bitmap dpImage = _particlesGridDevidePage.ReportFun.GetBlackAndWhiteImage(particle);
-                        string filePath = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
-                        string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
-                        Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
-                        Bitmap bmap = _particlesGridDevidePage.fldImgAccess.GetBitmapByParticle(dpImage, rectangle);
-                        Bitmap bmap1 = _particlesGridDevidePage.fldImgAccess.GetBitmapByParticle(m_originalImage, rectangle);
-                        control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
-                        Invalidate();
+                        int fldid = Convert.ToInt32(dgvr.Cells["fieldid"].Value);
+                        int partid = Convert.ToInt32(dgvr.Cells["particleId"].Value);
+                        var listseg = Particledata.GetSegmentData(fldid, partid);
+                        string key = fldid.ToString() + "_" + partid.ToString();
+                        segsData.Add(key, listseg);
+                        dataTable = particles.Clone();
+                        dataTable.ImportRow(row);
                     }
                     else
                     {
-                        double xs = _particlesGridDevidePage.result.GetPixelSize();
-                        int width = _particlesGridDevidePage.result.GetImageWidth();
-                        int height = _particlesGridDevidePage.result.GetImageHeight();
-                        int fldid = Convert.ToInt32(dgvr.Cells["fieldid"].Value);
-                        int partid = Convert.ToInt32(dgvr.Cells["particleId"].Value);
-                        var listseg = _particlesGridDevidePage.Particledata.GetSegmentData(fldid, partid);
                         string vs = "," + subt.Replace(':', '-') + ",";
-                        DataTable dataTable = _particlesGridDevidePage.Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
-                        Bitmap bp = _particlesGridDevidePage.fldImgAccess.GetBitmapForBigBlackAndWhiteImage(subt, xs, _particlesGridDevidePage.result.FilePath, height, width,dataTable,listseg);
-                        control_XRayTable1.SetBitmapOfPictureBox(ls_bp, bp);
-                        Invalidate();
+                        dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
+                        foreach (DataRow dow in dataTable.Rows)
+                        {
+                            int fldid = Convert.ToInt32(dow["fieldid"]);
+                            int partid = Convert.ToInt32(dow["particleId"]);
+                            var listseg = Particledata.GetSegmentData(fldid, partid);
+                            string key = dow["fieldid"].ToString() + "_" + dow["particleid"].ToString();
+                            segsData.Add(key, listseg);
+                        }
                     }
+                    Bitmap bmap = fldImgAccess.GetBitmapForParticleAll(subt, dataTable, xs, height, width);
+                    Bitmap bmap1 = fldImgAccess.GetBitmapForParticleAllWithBlackAndWhite(subt, dataTable, segsData, xs, height, width);
+                    control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
+                    Invalidate();
                 }
             }
         }
@@ -928,6 +939,9 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
             table = particlesGridDevidePage.table;
 			m_ReportApp = ReportApp;
 			m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
+            _result = particlesGridDevidePage.result;
+            fldImgAccess = new FieldImage(_result.FilePath);
+            Particledata = new ParticleData(_result.FilePath);
 
 
             //设置窗体的双缓冲,以保证大数据时拖动不卡

+ 35 - 31
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -1,4 +1,4 @@
-using NPOI.SS.Formula.Functions;
+using DevExpress.XtraPrinting.Native;
 using NPOI.SS.UserModel;
 using NPOI.SS.UserModel.Charts;
 using NPOI.SS.Util;
@@ -80,8 +80,8 @@ namespace OTSIncAReportGrids
         DataTable particlesAll;
         DataTable particles;
         public ParticleData Particledata;
-       public UserSTDDbAccess userSTDDb;
-       public FieldImage fldImgAccess;
+        public UserSTDDbAccess userSTDDb;
+        public FieldImage fldImgAccess;
         DataTable userSTDDbData;
         NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
 
@@ -268,7 +268,6 @@ namespace OTSIncAReportGrids
             {
                 return;
             }
-
             cbB_PageSize.Items.Add("20");
             cbB_PageSize.Items.Add("100");
             cbB_PageSize.Items.Add("500");
@@ -521,14 +520,12 @@ namespace OTSIncAReportGrids
                             Bitmap bmap = null;
                             if (subt != null && subt != "" && subt != "IsSubParticle")
                             {
-                                double xs = result.GetPixelSize();
+                                double xs = 1 / result.GetPixelSize();
                                 int width = result.GetImageWidth(); 
                                 int height = result.GetImageHeight();
-                            
-                               
                                 string vs = "," + subt.Replace(':', '-') + ",";
                                 DataTable dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
-                                bmap = fldImgAccess.GetBitmapForMergedParticle(subt, xs, result.FilePath, height, width, dataTable);
+                                bmap = fldImgAccess.GetBitmapForMergedParticle(subt, xs, height, width, dataTable);
                                 if (bmap != null)
                                 {
                                     string[] str = subt.Split(',');
@@ -539,13 +536,11 @@ namespace OTSIncAReportGrids
                             {
                                 if (!fieldpics.Keys.Contains(particles.Rows[i]["fieldid"].ToString()))
                                 {
-                                    string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-
-                                    
+                                    string imagePath = "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
                                     fieldpics.Add(particles.Rows[i]["fieldid"].ToString(), fldImgAccess.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"]) };
-                                bmap = fldImgAccess.GetBitmapByParticle(fieldpics[particles.Rows[i]["fieldid"].ToString()], rectangle);
+                                bmap = fldImgAccess.CapturePic(fieldpics[particles.Rows[i]["fieldid"].ToString()], rectangle);
                                 bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString()};
                                 dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
                             }
@@ -2493,32 +2488,41 @@ namespace OTSIncAReportGrids
                     control_XRayTable1.MaterialName = str_IncAName;
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
 
+
+
+                    DataTable dataTable=new DataTable();
+                    double xs = 1/result.GetPixelSize();
+                    int width = result.GetImageWidth();
+                    int height = result.GetImageHeight();
+                    Dictionary<string, List<Segment>> segsData = new Dictionary<string, List<Segment>>();
+
                     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) };
-                        Bitmap dpImage = ReportFun.GetBlackAndWhiteImage(particle);
-                        string filePath = result.FilePath + "\\FIELD_FILES\\";
-                        string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
-                        Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
-                        Bitmap bmap = fldImgAccess.GetBitmapByParticle(dpImage, rectangle);
-                        Bitmap bmap1 = fldImgAccess.GetBitmapByParticle(m_originalImage, rectangle);
-                        control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
-                        Invalidate();
+                        int fldid = Convert.ToInt32(dgvr.Cells["fieldid"].Value);
+                        int partid = Convert.ToInt32(dgvr.Cells["particleId"].Value);
+                        var listseg = Particledata.GetSegmentData(fldid, partid);
+                        string key = fldid.ToString() + "_" + partid.ToString();
+                        segsData.Add(key, listseg);
+                        dataTable= particles.Clone();
+                        dataTable.ImportRow(row);
                     }
                     else
                     {
-                        double xs = result.GetPixelSize();
-                        int width = result.GetImageWidth();
-                        int height = result.GetImageHeight();
-                        int fldid= Convert.ToInt32(dgvr.Cells["fieldid"].Value);
-                        int partid= Convert.ToInt32(dgvr.Cells["particleId"].Value);
-                        var listseg = Particledata.GetSegmentData(fldid, partid);
                         string vs = "," + subt.Replace(':', '-') + ",";
-                        DataTable dataTable = Particledata. GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
-                        Bitmap bp = fldImgAccess.GetBitmapForBigBlackAndWhiteImage(subt, xs, result.FilePath, height, width,dataTable,listseg );
-                        control_XRayTable1.SetBitmapOfPictureBox(ls_bp,bp);
-                        Invalidate();
+                        dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
+                        foreach (DataRow dow in dataTable.Rows)
+                        {
+                            int fldid = Convert.ToInt32(dow["fieldid"]);
+                            int partid = Convert.ToInt32(dow["particleId"]);
+                            var listseg = Particledata.GetSegmentData(fldid, partid);
+                            string key = dow["fieldid"].ToString() + "_" + dow["particleid"].ToString();
+                            segsData.Add(key, listseg);
+                        }
                     }
+                    Bitmap bmap = fldImgAccess.GetBitmapForParticleAll(subt, dataTable, xs, height, width);
+                    Bitmap bmap1 = fldImgAccess.GetBitmapForParticleAllWithBlackAndWhite(subt, dataTable, segsData, xs, height, width);
+                    control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
+                    Invalidate();
                     ToolStripMenuItem_SimilarityReclassification.Enabled = true;
                 }
                 //SaveParticleslist_select();

+ 11 - 22
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/ParticleList.cs

@@ -181,10 +181,11 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
 								continue;
 							if (serialNumber > m_mbszclass.M_KLLBXX.list_int_kllb_number)
 								continue;
-							Rectangle rectangle = new Rectangle()
-							{ X = Convert.ToInt32(p1Data.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(p1Data.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(p1Data.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(p1Data.Rows[i_row]["RectHeight"]) };
-							Bitmap bp_field = imgAcc.ReadImageFile(str_imagePath);
-							Bitmap bp_particle = imgAcc.GetBitmapByParticle(bp_field, rectangle);
+                            DataTable table1=p1Data.Clone();
+                            table1.ImportRow(p1Data.Rows[i_row]);
+
+
+                            Bitmap bp_particle = imgAcc.GetBitmapByParticle(table1);
 							bp_particle = imageProcessor.ResizeImageWithPadding(bp_particle, 120, 120, System.Drawing.Color.White);
 							bp_particle.Tag = new List<string>() { p1Data.Rows[i_row]["FieldId"].ToString(), p1Data.Rows[i_row]["ParticleId"].ToString(), p1Data.Rows[i_row]["TypeId"].ToString() };
 							//获取该颗粒的xray能谱图像
@@ -316,14 +317,9 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
 			string filePath = result.FilePath + "\\FIELD_FILES\\";
 			for (int i = 0; i < particles.Rows.Count; i++)
             {
-				KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
-				if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
-				{
-					string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-					FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), imgAcc.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"]) };
-				Bitmap bmap = imgAcc.GetBitmapByParticle(FieldImage.Value, rectangle);
+				DataTable table1 = particles.Clone();
+                table1.ImportRow(particles.Rows[i]);
+                Bitmap bmap = imgAcc.GetBitmapByParticle(table1);
 				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() };
                 DataRow row = SplicingParticlesData.NewRow();
                 row["image"] = bmap;
@@ -770,16 +766,9 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
                 {
                     //获取原始颗粒图像
                     Bitmap bp_particle = new Bitmap(1, 1);
-                    Bitmap bp_field = new Bitmap(1, 1);
-                    Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt.Rows[i_row]["RectHeight"]) };
-                    for (int i = 0; i < DT_field_dt.Rows.Count; i++)
-                    {
-                        if (dt.Rows[i_row]["FieldId"].ToString() == DT_field_dt.Rows[i]["id"].ToString())
-                        {
-                            bp_field = new Bitmap(DT_field_dt.Rows[i]["fieldFullName"].ToString());
-                        }
-                    }
-                    bp_particle = imgAcc.GetBitmapByParticle(bp_field, rectangle);
+                    DataTable table1 = dt.Clone();
+                    table1.ImportRow(dt.Rows[i_row]);
+                    bp_particle = imgAcc.GetBitmapByParticle(table1);
                     bp_particle.Tag = new List<string>() { dt.Rows[i_row]["FieldId"].ToString(), dt.Rows[i_row]["ParticleId"].ToString(), dt.Rows[i_row]["TypeId"].ToString() };
                     DataRow dr = FrameGraphSubTable.NewRow();
                     dr["pic"] = bp_particle;

+ 1 - 76
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/ParticleData.cs

@@ -1,15 +1,11 @@
-using OTSCommon.DBOperate;
-using OTSCommon.DBOperate.Model;
-using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
+using OTSCommon.DBOperate.Model;
 using OTSIncAReportGraph.Controls;
 using OTSPeriodicTable;
 using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SQLite;
-using System.IO;
 using System.Linq;
-using static OTSDataType.otsdataconst;
 using static OTSIncAReportApp.OTSReport_Export;
 
 namespace OTSIncAReportApp.DataOperation.DataAccess
@@ -610,25 +606,6 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return flist;
         }
 
-
-        public enum PARTCLE_TYPE
-        {
-            SMALL = 0,//过小颗粒
-            OVERSIZE = 1,//过大颗粒
-            AVE_GRAY_NOT_INRANRE = 2,//亮度不在分析范围内的颗粒
-            SEARCH_X_RAY = 3,
-            LOW_COUNT = 4,//低计数率颗粒
-            NO_INTEREST_ELEMENTS = 5,
-            NO_ANALYSIS_X_RAY = 6,//不含分析元素
-            NOT_IDENTIFIED_SIC = 7,//非夹杂物颗粒SiC
-            NOT_IDENTIFIED_FEO = 8,//非夹杂物颗粒FeO
-            NOT_IDENTIFIED = 9,//未识别颗粒
-            IDENTIFIED = 10,//分析颗粒,当为可识别类型时,可以被进一步识别为用户类型(1000以上),系统预定义类型(10000以上),所以最终颗粒类型不会为8,但可能为7
-
-            USER_DEFINED_MIN = 1000,
-            SYS_DEFINED_MIN = 10000
-        }
-
         #region 分页添加读取数据库函数
         /// <summary>
         /// 获取分页查询所需信息
@@ -997,17 +974,6 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             }
             dataTable_Particle.AcceptChanges();
         }
-
-     
-
-
-       
-
-
-      
-
-      
-
         public void InsertUpdate(List<int> particleID, List<string> particleData)
         {
             List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
@@ -1083,48 +1049,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return list_showelementinfo;
         }
         
-        //public Bitmap GetParticlescreenshot(string subt, ResultFile result)
-        //{
-        //    Bitmap bmap = null;
-        //    KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
-        //    if (subt != null && subt != "" && subt != "IsSubParticle")
-        //    {
-        //        double ScanFieldSize = result.GetScanFieldSizeX();
-        //        string filePatht = result.FilePath + "\\FIELD_FILES\\";
-        //        string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
-        //        Bitmap tempbit = ReadImageFile(imagePatht);
-        //        int pixw = tempbit.Width;
-        //        double xs = pixw / ScanFieldSize;
-        //        OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
-        //        OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
-                
-
-        //        bmap = GetBitmapForBig(subt, xs, 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]};
-        //        }
-        //    }
-        //    else if (subt != "IsSubParticle")
-        //    {
-        //        if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
-        //        {
-        //            string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-        //            FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), 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"]) };
-        //        Bitmap bmap = 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_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
-        //        dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
-        //    }
-        //    return bmap;
-        //}
         #endregion
-
-
-
        
         public ParticleData()
         { 

+ 132 - 17
OTSIncAReportApp/3-ServiceCenter/DataOperation/ImageAccess/FieldImage.cs

@@ -1,6 +1,5 @@
 using OTSCommon.DBOperate.Model;
-using OTSIncAReportApp.DataOperation.DataAccess;
-using OTSIncAReportApp.OTSRstMgrFunction;
+using OTSIncAReportGraph.Class;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -15,7 +14,7 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
         string imagePath;
         public FieldImage(string rstpath) 
         { 
-        imagePath= rstpath + @"FIELD_FILES\";
+         imagePath= rstpath + @"\FIELD_FILES\";
         }
         /// <summary>
         /// 拼接颗粒黑白图
@@ -25,8 +24,9 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
         /// <param name="path">报告文件路径</param>
         /// <param name="picHeight">图像高</param>
         /// <param name="picWidth">帧图宽</param>
+        ///  <param name="segsData">KEY为FidANDpID</param> 
         /// <returns></returns>
-        public Bitmap GetBitmapForBigBlackAndWhiteImage(string sub, double xs, string path, int picHeight, int picWidth,DataTable PartdataTable,List<Segment> segsData)
+        public Bitmap GetBlackAndWhiteBitmapForMergedParticle(string sub, double xs, int picHeight, int picWidth,DataTable PartdataTable,Dictionary<string,List<Segment>> segsData)
         {
             string vs = "," + sub.Replace(':', '-') + ",";
             
@@ -74,12 +74,9 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
             Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
             Graphics graph = Graphics.FromImage(tableChartImage);
             graph.Clear(Color.White);
-            //初始化这个大图
             graph.DrawImage(tableChartImage, 0, 0);
             foreach (DataRow item in PartdataTable.Rows)
             {
-               
-               
                 int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
                 int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
                 //颗粒外接矩形
@@ -101,7 +98,8 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
                 {
                     min_Y = lrfttopY;
                 }
-                foreach (Segment seg in segsData)
+                string key = item["fieldid"].ToString() + "_" + item["particleid"].ToString();
+                foreach (Segment seg in segsData[key])
                 {
                     int f_length = seg.Length;
                     for (int m = 0; m < f_length; m++)
@@ -117,7 +115,10 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
             int X = Convert.ToInt32(min_X);
             int Y = Convert.ToInt32(min_Y);
             Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
-            Bitmap bmap = GetBitmapByParticle(tableChartImage, rectangle);
+            
+            
+            Bitmap bmap = CapturePic(tableChartImage, rectangle);
+
             return bmap;
         }
 
@@ -145,10 +146,8 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
         /// <param name="path">报告文件路径</param>
         /// <param name="picHeight">图像高</param>
         /// <param name="picWidth">帧图宽</param>
-        /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
-        /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
         /// <returns></returns>
-        public Bitmap GetBitmapForMergedParticle(string sub, double xs, string path, int picHeight, int picWidth,DataTable dataTable)
+        public Bitmap GetBitmapForMergedParticle(string sub, double xs, int picHeight, int picWidth,DataTable dataTable)
         {
             string vs = "," + sub.Replace(':', '-') + ",";
 
@@ -199,10 +198,9 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
             graph.DrawImage(tableChartImage, 0, 0);
             foreach (DataRow item in dataTable.Rows)
             {
-                string filePath = path + "\\FIELD_FILES\\";
-                string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
+                string  path1=  "Field" + item["fieldid"].ToString() + ".bmp";
                 //然后将取出的数据,转换成Bitmap对象
-                Bitmap ls_bt = ReadImageFile(imagePath);
+                Bitmap ls_bt = ReadImageFile(path1);
                 int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
                 int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
 
@@ -234,7 +232,6 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
             Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
             Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
             graph.DrawImage(tableChartImage, 0, 0);
-
             return bmap;
         }
         /// <summary>
@@ -242,8 +239,13 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
         /// </summary>
         /// <param name="in_cotsparticleclr"></param>
         /// <returns></returns>
-        public Bitmap GetBitmapByParticle(Bitmap ls_bt, Rectangle offset_rect)
+        public Bitmap GetBitmapByParticle(DataTable dataTable)
         {
+            string path1 = "Field" + dataTable.Rows[0]["fieldid"].ToString() + ".bmp";
+            //然后将取出的数据,转换成Bitmap对象
+            Bitmap ls_bt = ReadImageFile(path1); 
+            Rectangle offset_rect = new Rectangle() { X = Convert.ToInt32(dataTable.Rows[0]["RectLeft"]), Y = Convert.ToInt32(dataTable.Rows[0]["RectTop"]), Width = Convert.ToInt32(dataTable.Rows[0]["RectWidth"]), Height = Convert.ToInt32(dataTable.Rows[0]["RectHeight"]) };
+            
             //为了能把整个颗粒显示完整
             offset_rect.X = offset_rect.X - 20;
             offset_rect.Y = offset_rect.Y - 20;
@@ -280,5 +282,118 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
             return new_ret_bp;
         }
 
+
+
+
+
+
+
+        /// <summary>
+        /// 获取全部颗粒图
+        /// </summary>
+        /// <param name="sub">拼接颗粒连接字符串</param>
+        /// <param name="dataTable">颗粒表</param>
+        /// <param name="xs">pixel</param>
+        /// <param name="picHeight">帧图高</param>
+        /// <param name="picWidth">帧图宽</param>
+        /// <returns></returns>
+        public Bitmap GetBitmapForParticleAll(string sub, DataTable dataTable, double xs=0, int picHeight=0, int picWidth=0)
+        {
+            Bitmap bmap;
+            if(sub != "")
+            {
+                bmap = GetBitmapForMergedParticle(sub, xs, picHeight, picWidth,dataTable);
+            }
+            else
+            {
+                bmap=GetBitmapByParticle(dataTable);
+            }
+            return bmap;
+        }
+        /// <summary>
+        /// 获取全部颗粒图
+        /// </summary>
+        /// <param name="sub">拼接颗粒连接字符串</param>
+        /// <param name="dataTable">颗粒表</param>
+        /// <param name="xs">pixel</param>
+        /// <param name="picHeight">帧图高</param>
+        /// <param name="picWidth">帧图宽</param>
+        /// <returns></returns>
+        public Bitmap GetBitmapForParticleAllWithBlackAndWhite(string sub, DataTable dataTable, Dictionary<string, List<Segment>> segsData, double xs = 0, int picHeight = 0, int picWidth = 0)
+        {
+            Bitmap bmap;
+            if (sub != "")
+            {
+                bmap = GetBlackAndWhiteBitmapForMergedParticle(sub, xs, picHeight, picWidth, dataTable, segsData);
+            }
+            else
+            {
+                List<Segment> liseg=segsData[dataTable.Rows[0]["fieldid"].ToString() + "_" + dataTable.Rows[0]["particleid"].ToString()];
+                bmap = GetBlackAndWhiteImage(dataTable, picHeight, picWidth,liseg);
+            }
+            return bmap;
+        }
+
+
+        public Bitmap CapturePic(Bitmap ls_bt, Rectangle offset_rect)
+        {
+            //为了能把整个颗粒显示完整
+            offset_rect.X = offset_rect.X - 20;
+            offset_rect.Y = offset_rect.Y - 20;
+            offset_rect.Width = offset_rect.Width + 40;
+            offset_rect.Height = offset_rect.Height + 40;
+
+            //防止计算偏差后,有坐标溢出现象
+            if (offset_rect.X < 0)
+                offset_rect.X = 0;
+            if (offset_rect.Y < 0)
+                offset_rect.Y = 0;
+            if (offset_rect.X + offset_rect.Width > ls_bt.Width)
+            {
+                offset_rect.Width = ls_bt.Width - offset_rect.X;
+            }
+            if (offset_rect.Y + offset_rect.Height > ls_bt.Height)
+            {
+                offset_rect.Height = ls_bt.Height - offset_rect.Y;
+            }
+
+            Bitmap new_ret_bp;
+            //防止为0后面计算出错
+            if (offset_rect.Width > 0 && offset_rect.Height > 0)
+            {
+                //最后通过list_showsegment组建成新的图片,进行返回
+                new_ret_bp = ls_bt.Clone(offset_rect, ls_bt.PixelFormat);
+            }
+            else
+            {
+
+                new_ret_bp = new Bitmap(offset_rect.Width, offset_rect.Height);
+            }
+
+            return new_ret_bp;
+        }
+
+        public Bitmap GetBlackAndWhiteImage(DataTable particle,int picHeight, int picWidth, List<Segment> segsData)
+        {
+            Bitmap dpImage=new Bitmap(picWidth, picHeight);
+            using (Graphics graphics = Graphics.FromImage(dpImage))
+            {
+                graphics.Clear(Color.White); // 清除位图背景为白色
+            }
+            foreach (Segment seg in segsData)
+            {
+                int f_length = seg.Length;
+                for (int m = 0; m < f_length; m++)
+                {
+                    int lsjs_x = seg.Start + m;
+                    int lsjs_y = seg.Height;
+                    dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
+                }
+            }
+            DataRow row = particle.Rows[0];
+            Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(row["RectLeft"]), Y = Convert.ToInt32(row["RectTop"]), Width = Convert.ToInt32(row["RectWidth"]), Height = Convert.ToInt32(row["RectHeight"]) };      
+            Bitmap bmap = CapturePic(dpImage, rectangle);
+            return bmap;
+        }
     }
 }