Browse Source

修改 多样品 bug

cxs 11 months ago
parent
commit
831fd91c35

+ 23 - 0
OTSCommon/ReportModel/ResultFile.cs

@@ -227,6 +227,29 @@ public    enum OTS_Y_AXIS_DIRECTION
            
             
         }
+        public double GetTotalArea()
+        {
+            try
+            {
+                double dTotalArea = -1;
+                Dictionary<string, object> valuePairs=(Dictionary<string, object>)ResultInfo["Sample"];
+                if (valuePairs.ContainsKey("TotalArea"))
+                {
+                    dTotalArea = Convert.ToDouble(valuePairs["TotalArea"]) *1000000 ;
+                    return dTotalArea;
+                }
+                else
+                {
+                    return -1;
+                }
+            }
+            catch
+            {
+               return -1; 
+            }
+
+        }
+
         public int GetIncASteeltech()
         {
             //--------the int number  meaning----------

+ 7 - 4
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -62,6 +62,9 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         {
  
             resultFile = result;
+            FieldData fieldData = new FieldData(result.FilePath);
+            List<Field> fieldlist1 = fieldData.GetFieldList();
+            resultFile.List_OTSField = fieldlist1;
             m_cfun = ServiceInterface.HardwareController.GetSemController();
             List<Field> fieldlist = resultFile.List_OTSField;
 
@@ -282,10 +285,10 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             if (resultFile.List_OTSField == null)
                 return;
             Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
-            if (particle == null)
-            {
-                return;
-            }
+            //if (particle == null)
+            //{
+            //    return;
+            //}
             var tmpPart = new ParticleData(resultFile.FilePath).GetParticleXrayDataByFidAndPid(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId));
             if (tmpPart != null)
             {

+ 11 - 11
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.Designer.cs

@@ -32,6 +32,7 @@ namespace OTSIncAReportGrids
         {
             this.components = new System.ComponentModel.Container();
             this.panel2 = new System.Windows.Forms.Panel();
+            this.btn_particletypesel = new System.Windows.Forms.Button();
             this.btn_showconfig = new System.Windows.Forms.Button();
             this.tB_FieldId = new System.Windows.Forms.TextBox();
             this.label7 = new System.Windows.Forms.Label();
@@ -76,7 +77,6 @@ namespace OTSIncAReportGrids
             this.ToolStripMenuItemDelete_Particle = new System.Windows.Forms.ToolStripMenuItem();
             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
             this.dgV_ParticlesDevidePage = new System.Windows.Forms.DataGridView();
-            this.btn_particletypesel = new System.Windows.Forms.Button();
             this.panel2.SuspendLayout();
             this.panel1.SuspendLayout();
             this.contextMenuStrip1.SuspendLayout();
@@ -110,6 +110,16 @@ namespace OTSIncAReportGrids
             this.panel2.Size = new System.Drawing.Size(1502, 37);
             this.panel2.TabIndex = 6;
             // 
+            // btn_particletypesel
+            // 
+            this.btn_particletypesel.Location = new System.Drawing.Point(715, 8);
+            this.btn_particletypesel.Name = "btn_particletypesel";
+            this.btn_particletypesel.Size = new System.Drawing.Size(107, 23);
+            this.btn_particletypesel.TabIndex = 41;
+            this.btn_particletypesel.Text = "颗粒类别选择";
+            this.btn_particletypesel.UseVisualStyleBackColor = true;
+            this.btn_particletypesel.Click += new System.EventHandler(this.btn_particletypesel_Click);
+            // 
             // btn_showconfig
             // 
             this.btn_showconfig.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -537,16 +547,6 @@ namespace OTSIncAReportGrids
             this.dgV_ParticlesDevidePage.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dgV_ParticlesDevidePage_MouseDown);
             this.dgV_ParticlesDevidePage.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgV_ParticlesDevidePage_MouseUp);
             // 
-            // btn_particletypesel
-            // 
-            this.btn_particletypesel.Location = new System.Drawing.Point(715, 8);
-            this.btn_particletypesel.Name = "btn_particletypesel";
-            this.btn_particletypesel.Size = new System.Drawing.Size(107, 23);
-            this.btn_particletypesel.TabIndex = 41;
-            this.btn_particletypesel.Text = "颗粒类别选择";
-            this.btn_particletypesel.UseVisualStyleBackColor = true;
-            this.btn_particletypesel.Click += new System.EventHandler(this.btn_particletypesel_Click);
-            // 
             // ParticlesGridDevidePage
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

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

@@ -162,26 +162,36 @@ namespace OTSIncAReportGrids
         #endregion
 
         frmReportApp m_ReportApp;
-        ResultFile resultFile = null;
+        //ResultFile resultFile = null;
         #endregion
 
         public ParticlesGridDevidePage(frmReportApp ReportApp)
         {
             m_ReportApp = ReportApp;
             m_condition = ReportApp.m_conditionChoose;
-            resultFile = ReportApp.m_rstDataMgr.CurResultFile;
-            ReportFun = new OTSImageDisHelp(resultFile);
+
+            
+
 
             string sou = m_condition.m_CurrentConditions[OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
             if (sou.Contains("+"))
             {
                 MessageBox.Show("This function does not support multiple samples!");
+
+                //m_ReportApp.m_CurrentConditions[OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE].itemVal = (int)IMAGE_DISPLAY_TYPE.DISTRIBUTION;
+                //var rstlist = m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE);
+                //prop.SetPropByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE, rstlist[(int)IMAGE_DISPLAY_TYPE.DISTRIBUTION]);
+                //m_ReportApp.MoreSource = "";
+                //m_condition.SetDefaultConditionValue();
+                //m_condition.DisCurrentPicProperty();
+
                 result = m_ReportApp.m_rstDataMgr.ResultFilesList[0];
             }
             else
             {
                 result = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE)];
             }
+            ReportFun = new OTSImageDisHelp(result);
 
 
             //设置窗体的双缓冲,以保证大数据时拖动不卡
@@ -229,6 +239,8 @@ namespace OTSIncAReportGrids
                 //m_frm_userprogress = new Frm_UserProgress();
                 fieldData = new FieldData(result.FilePath);
                 Particledata = new ParticleData(result.FilePath);
+                //List<Field> fieldlist = fieldData.GetFieldList();
+                //m_ReportApp.m_rstDataMgr.CurResultFile.List_OTSField = fieldlist;
                 var systype = m_ReportApp.m_RptConfigFile.Systype;
                 if (systype == OTSCommon.Model.OTS_SysType_ID.CleannessA)
                 {
@@ -380,21 +392,27 @@ namespace OTSIncAReportGrids
                 {
                     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)
                         {
-                            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];
+                                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;
                             }
-                            particlesAll.Rows[i]["XRayDataCount"] = xraycount;
                         }
 
                     }
@@ -892,7 +910,7 @@ namespace OTSIncAReportGrids
                         }
                         if (enl.Current.Key == "AbPosX")
                         {
-                            Point point = CalculateParticleCenterPosition(resultFile, new Point(Convert.ToInt32(particles.Rows[i]["SEMPosX"]), Convert.ToInt32(particles.Rows[i]["SEMPosY"])), new Point(Convert.ToInt32(particles.Rows[i]["PosX"]), Convert.ToInt32(particles.Rows[i]["PosY"])));
+                            Point point = CalculateParticleCenterPosition(result, new Point(Convert.ToInt32(particles.Rows[i]["SEMPosX"]), Convert.ToInt32(particles.Rows[i]["SEMPosY"])), new Point(Convert.ToInt32(particles.Rows[i]["PosX"]), Convert.ToInt32(particles.Rows[i]["PosY"])));
                             dgV_ParticlesDevidePage.Rows[add_rowindex].Cells["AbPosX"].Value = point.X;
                             dgV_ParticlesDevidePage.Rows[add_rowindex].Cells["AbPosY"].Value = point.Y;
                         }
@@ -1261,7 +1279,7 @@ namespace OTSIncAReportGrids
             {
                 m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
             }
-            Point point = CalculateParticleCenterPosition(resultFile, new Point(particle.SEMPosX, particle.SEMPosY), new Point(particle.PosX, particle.PosY));
+            Point point = CalculateParticleCenterPosition(result, new Point(particle.SEMPosX, particle.SEMPosY), new Point(particle.PosX, particle.PosY));
             //改为线程调用,先判断线程状态
             m_mythread.Start(point);
 
@@ -2169,7 +2187,7 @@ namespace OTSIncAReportGrids
             bool DoesItExist = false;
             for (int i = 1; i < 201; i++)
             {
-                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
+                if (System.IO.Directory.Exists(result.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
                 {
                     DoesItExist = true;
                     break;
@@ -2183,10 +2201,10 @@ namespace OTSIncAReportGrids
             DoesItExist = false;
 
             //防止为空校验判断
-            if (resultFile.List_OTSField == null)
+            if (result.List_OTSField == null)
                 return false;
-            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
-            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
+            Particle particle = result.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
+            if (new ParticleData(result.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
             {
 
                 return true;
@@ -2200,9 +2218,9 @@ namespace OTSIncAReportGrids
         private bool BackupDatabase()
         {
             //创建备份数据库文件夹
-            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourcePath = result.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
             string sourceName = "Inclusion.db";//源文件名称
-            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string folderPath = result.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
             string Fields = "";
             for (int i = 1; i < 201; i++)
             {
@@ -2698,7 +2716,7 @@ namespace OTSIncAReportGrids
                     list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
                     string str_IncAName = "";
                     str_IncAName = Convert.ToString(dgvr.Cells[1].Value);
-                    Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == Convert.ToInt32(dgvr.Cells["fieldid"].Value)).ParticleList.Find(x => x.ParticleId == Convert.ToInt32(dgvr.Cells["particleId"].Value));
+                    Particle particle = 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)
                     {
                         return;
@@ -2714,16 +2732,16 @@ namespace OTSIncAReportGrids
 
                     control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
 
-
-                    string filePath = result.FilePath + "\\FIELD_FILES\\";
-                    string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
-                    Bitmap originalFieldImage=Particledata.ReadImageFile(imagePath);
                     string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
                     DataRow[] drs = particles.Select(str);
                     if (drs.Length > 0)
                     {
-                        Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(drs[0]["RectLeft"]), Y = Convert.ToInt32(drs[0]["RectTop"]), Width = Convert.ToInt32(drs[0]["RectWidth"]), Height = Convert.ToInt32(drs[0]["RectHeight"]) };
-                        Bitmap dpImage = new Bitmap(originalFieldImage.Width, originalFieldImage.Height);
+                        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(result.GetImageWidth(), result.GetImageHeight());
+                        using (Graphics graphics = Graphics.FromImage(dpImage))
+                        {
+                            graphics.Clear(Color.White); // 清除位图背景为白色
+                        }
                         foreach (Segment seg in particle.SegmentList)
                         {
                             int f_length = seg.Length;
@@ -2731,38 +2749,11 @@ namespace OTSIncAReportGrids
                             {
                                 int lsjs_x = seg.Start + m;
                                 int lsjs_y = seg.Height;
-                                var pixelColor = originalFieldImage.GetPixel(lsjs_x, lsjs_y);
-                                dpImage.SetPixel(lsjs_x, lsjs_y, pixelColor);
+                                dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
                             }
                         }
-
-
                         Bitmap bmap = Particledata.GetBitmapByParticle(dpImage, rectangle);
-                        Bitmap binarizedBmp = new Bitmap(bmap.Width, bmap.Height);
-                        for (int x = 0; x < bmap.Width; x++)
-                        {
-                            for (int y = 0; y < bmap.Height; y++)
-                            {
-                                Color color = bmap.GetPixel(x, y);
-                                if (color.A == 255&&color.B==0 && color.G == 0 && color.R == 0)
-                                {
-                                    binarizedBmp.SetPixel(x, y, Color.White);
-                                }
-                                else
-                                {
-                                    int grayValue = (color.R + color.G + color.B) / 3;
-                                    if(grayValue>0)
-                                    {
-                                        binarizedBmp.SetPixel(x, y, Color.Black);
-                                    }
-                                    else
-                                    {
-                                        binarizedBmp.SetPixel(x, y, Color.White);
-                                    }
-                                }
-                            }
-                        }
-                        control_XRayTable1.SetBitmapOfPictureBox(ls_bp, binarizedBmp);
+                        control_XRayTable1.SetBitmapOfPictureBox(ls_bp, bmap);
                         Invalidate();
                     }
                     else

+ 6 - 2
OTSIncAReportApp/1-UI/Control_Grids/ResultGrid.cs

@@ -131,8 +131,12 @@ namespace OTSIncAReportGrids
             double scanFieldSize = resfile.GetScanFieldSizeX();
             double wide = resfile.GetImageWidth();
             double high = resfile.GetImageHeight();
-           
-            double filedsArea = scanFieldSize * (scanFieldSize * high / wide) * filedCount;
+
+            double filedsArea= resfile.GetTotalArea();
+            if (filedsArea == -1)
+            {
+                filedsArea = scanFieldSize * (scanFieldSize * high / wide) * filedCount;
+            }
             double particleArea = fielddata.GetparticleArea();
 
      

+ 7 - 0
OTSIncAReportApp/1-UI/OTSDisplaySourceGridData/frmReportConditionChoose.cs

@@ -646,6 +646,13 @@ namespace OTSIncAReportApp
                             {
                                 //如果已经不是原先的数据源,则需要重新加载,设定为空,后面重新加载
                                 m_ReportApp.im_Control_DrawDistrbutionSortImage = null;
+                                m_CurrentConditions[OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE].itemVal = (int)IMAGE_DISPLAY_TYPE.DISTRIBUTION;
+                                var rstlist = m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE);
+                                prop.SetPropByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.IMAGE_DISPLAY_TYPE, rstlist[(int)IMAGE_DISPLAY_TYPE.DISTRIBUTION]);
+                                GetWorkingPictureConditionVal();
+                                DisCurrentPicProperty();
+                                ShowDataDiagram(tabIndex);
+                                return;
                             }
                         }
 

+ 1 - 1
OTSIncAReportApp/1-UI/frmMeasureRstMgr.cs

@@ -568,7 +568,6 @@ namespace OTSIncAReportApp
 
                 imgpro.CalcuParticleImagePropertes(part, pixelSize);
             }
-
        
             string libname = resultfile.GetSTDName();
 
@@ -585,6 +584,7 @@ namespace OTSIncAReportApp
             MessageBox.Show("边界颗粒合成完成!");
             this.Cursor = System.Windows.Forms.Cursors.Default;
         }
+
         public bool MergeBigBoundaryParticles(List<OTSCommon.Model.Field> allFields, double pixelSize, int scanFieldSize, System.Drawing.Size ResolutionSize, ref List<COTSParticleClr> mergedParts)
         {
             List<COTSFieldDataClr> fldclrs = new List<COTSFieldDataClr>();