Pārlūkot izejas kodu

增加分布图中原图拼接导出,原图分类拼接导出功能

zhangjiaxin 3 gadi atpakaļ
vecāks
revīzija
1ae738fc8c

+ 4 - 4
Bin/x64/Debug/Config/ProData/ReportTemplateConfig.xml

@@ -1,17 +1,17 @@
 <XmlConfig>
   <M_SY>
-    <str_tb_ZBT>Inclusion Analysis </str_tb_ZBT>
-    <str_tb_FBT>马鞍山钢铁股份有限公司</str_tb_FBT>
+    <str_tb_ZBT>Cleanliness Analysis</str_tb_ZBT>
+    <str_tb_FBT>欧波同中国</str_tb_FBT>
     <str_tb_YPBH>0001</str_tb_YPBH>
     <str_tb_CKBZ>GB/T30834-2014</str_tb_CKBZ>
     <b_ck_ypsm>True</b_ck_ypsm>
     <b_ck_jggk>True</b_ck_jggk>
   </M_SY>
   <M_YMYJ>
-    <str_tb_ymwb>夹杂物分析报告</str_tb_ymwb>
+    <str_tb_ymwb>颗粒分析报告</str_tb_ymwb>
     <str_tb_KHH>Copi0000123012</str_tb_KHH>
     <b_ck_ym>True</b_ck_ym>
-    <str_tb_yjwb>夹杂物分析报告</str_tb_yjwb>
+    <str_tb_yjwb>颗粒分析报告</str_tb_yjwb>
   </M_YMYJ>
   <M_KLFXJG>
     <b_ck_klcc_xsmk>True</b_ck_klcc_xsmk>

+ 2 - 1
Bin/x64/Debug/Resources/XMLData/AppResource_ZH.xml

@@ -836,7 +836,8 @@
           <Control name="ToolStripMenuItem_delete" text="排除这些颗粒" />
 	  <Control name="另存选择颗粒ToolStripMenuItem" text="另存为" />
 	  <Control name="ToolStripMenuItem_movesempoint" text="移动SEM到当前位置" />
-	  <Control name="toolStripMenuItem_copyimage" text="复制图像" />
+	  <Control name="toolStripMenuItem_copyimage" text="导出原图拼接图" />
+	  <control name="ExportoriginalspliceToolStripMenuItem" text="导出原图拼接分类图"/>
 	  <Control name="str1" text="开始加载分布图信息" />
 	  <Control name="str2" text="已完成加载" />
 	  <Control name="str3" text="SEM位置:" />

+ 105 - 43
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -353,28 +353,21 @@ namespace OTSIncAReportGraph.Controls
             log.Info(str27);
             Application.DoEvents();
             ProgressBarUpdate(1, str27);
-
-
           
             List<Field> fieldlist = resultFile.List_OTSField;
 
             //防止有时底层返回的Field的List是0,直接返回
             if (fieldlist.Count == 0)
             {
-              
-
                 ProgressBarUpdate(100, "field number =0 !....");
                 return;
             }
 
-
             string str29 = "begin to composit field picture....";
             log.Info(str29);
             Application.DoEvents();
             ProgressBarUpdate(15, str29);
 
-         
-
             //第一次循环,用来计算单个Field的像素分辨率,和将所有的物理位置存放到List当中
             List<Point> list_point = new List<Point>();
             int fieldwidth = 0, fieldheight = 0;
@@ -394,14 +387,9 @@ namespace OTSIncAReportGraph.Controls
                 list_point.Add(ls_point);
             }
 
-         
-
-
             //计算出整个绘制图像总Rectagnle的大小
             m_backRect = ReportFun. ConvertAndGetMaxRect(list_point, fieldwidth, fieldheight);
            
-
-           
             ProgressBarUpdate(18, "calculate ruler....");
 
             #region //标尺相关------------------------------------------------------------------------------
@@ -410,74 +398,49 @@ namespace OTSIncAReportGraph.Controls
             double d_onepixel_scale = Convert.ToDouble(ls_jsblrect.Width) / Convert.ToDouble(fieldwidth);
             //再用该比例对标尺进行相应的赋值
             m_pixelSize = (float)d_onepixel_scale;
-
- 
             #endregion //---------------------------------------------------------------------------------------
 
-        
-
             ProgressBarUpdate(20, "composit whole picture....");
 
             //70的进度条给到下面的循环中,计算进度条各分类进度分配
             float ls_int_progresscalc = 0;
             if (fieldlist.Count > 0)
                 ls_int_progresscalc = (float)70 / (float)fieldlist.Count;
-
             string str32 = "finished ";
-     
             string str33 = "total ";
-         
             string str34 = "field...";
 
-
             var otsLeftBottomPoint = ReportFun.GetOTSCoordLeftBottomPoint(list_point);
     
             for (int i = 0; i < fieldlist.Count(); i++)
             {
-               
                 ProgressBarUpdate(20 + (int)(ls_int_progresscalc * (i + 1)), str32 + i.ToString() + str33 + resultFile.List_OTSField.Count.ToString() + str34);
-
-           
-
                 //取出该Field的物理坐标,将其转换成对应的屏幕像素坐标,屏幕左上角为原点(0,0)的偏移值,用于后面计算各Segment的位置使用
-               
                 Point thisfield_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };
-              
-                
                 Point offset_point = ReportFun.ConvertOTSCoordinateToScreenCoord(otsLeftBottomPoint, m_pixelSize, thisfield_point, m_backRect, new RectangleF(0,0,fieldwidth,fieldheight));//the ots coordinate is always the up right positive.
-               
                 DisplayField df = new DisplayField(fieldlist[i],fieldwidth,fieldheight, offset_point);
-        
                 m_list_allDfield.Add(df);
                 m_list_allDPart.AddRange(df.List_DParticle);
-              
-               
-
 
             }
-
-          
-
           
             ProgressBarUpdate(90, "convert solution...");
-
             //然后这里还需要计算出,各field的宽和高,帧图边框分别需要显示多少个框
             if (fieldwidth != 0 && fieldheight != 0)
             {
                 m_i_grid_showlinesnumber_width = Convert.ToInt32(BackRectF.Width / fieldwidth);
                 m_i_grid_showlinesnumber_height = Convert.ToInt32(BackRectF.Height / fieldheight);
             }
-        
 
             ProgressBarUpdate(95, "other work...");
-  
          
             //相关计数
             ReportFun.m_field_count = fieldlist.Count;
             ReportFun.m_particle_count = m_list_allDPart.Count;
         }
-  
-       
+
+    
+
         /// <summary>
         /// 分布图和BSE图中,从底层获取相关结果后,重新组织显示
         /// </summary>
@@ -1480,6 +1443,7 @@ namespace OTSIncAReportGraph.Controls
         //复制图像
         private void toolStripMenuItem_copyimage_Click(object sender, EventArgs e)
         {
+
             //outpic();
             if (outpic())
             {
@@ -1489,7 +1453,7 @@ namespace OTSIncAReportGraph.Controls
             {
                 MessageBox.Show("Picture export failed");
             }
-            
+
             //CopyImage();
         }
 
@@ -1949,8 +1913,12 @@ namespace OTSIncAReportGraph.Controls
 
         private bool outpic()
         {
+
+            
+
             SaveFileDialog sfd = new SaveFileDialog();
-            sfd.Filter = "BMP Files(*.bmp)|*.bmp|JPG Files(*.jpg)|*.jpg;*.jpeg|ALL Files(*.*)|*.*";
+            //|ALL Files(*.*)|*.*
+            sfd.Filter = "BMP Files(*.bmp)|*.bmp|JPG Files(*.jpg)|*.jpg;*.jpeg";
             if (sfd.ShowDialog() == DialogResult.OK)
             { 
                 try
@@ -1990,6 +1958,89 @@ namespace OTSIncAReportGraph.Controls
             return false;
 
         }
+        private bool outpic_Render()
+        {
+            SaveFileDialog sfd = new SaveFileDialog();
+            sfd.Filter = "BMP Files(*.bmp)|*.bmp|JPG Files(*.jpg)|*.jpg;*.jpeg|ALL Files(*.*)|*.*";
+            List<Field> fieldlist = resultFile.List_OTSField;
+
+            if (sfd.ShowDialog() == DialogResult.OK)
+            {
+                try
+                {
+                    double x_max ;
+                    double y_max ;
+                    DataTable picDatat = new DataTable();
+                    picDatat.Columns.Add("X", typeof(double));
+                    picDatat.Columns.Add("Y", typeof(double));
+                    picDatat.Columns.Add("pic_ID");
+                    foreach (var f in m_list_allDfield)
+                    {
+                        DataRow dr = picDatat.NewRow();
+                        dr["X"] = f.Rect.X;
+                        dr["Y"] = f.Rect.Y;
+                        dr["pic_ID"] = f.FieldID;
+                        picDatat.Rows.Add(dr);
+                    }
+                     x_max = Convert.ToDouble(picDatat.Compute("Max(X)", "true"));
+                     y_max = Convert.ToDouble(picDatat.Compute("Max(Y)", "true"));
+                    Bitmap pic_bitmap = new Bitmap((int)x_max, (int)y_max);
+                    Graphics graph = Graphics.FromImage(pic_bitmap);
+                    foreach (var f in m_list_allDfield)
+                    {
+                        Bitmap image = new Bitmap(f.OriginalImage.Width,f.OriginalImage.Height);
+                        Graphics g2= Graphics.FromImage(image);
+                        g2.DrawImage(f.OriginalImage,0,0, f.OriginalImage.Width, f.OriginalImage.Height);
+                        Graphics graph_2 = Graphics.FromImage(image);
+
+                        for (int i = 0; i < fieldlist.Count; i++)
+                        {
+                            if (fieldlist[i].FieldID.ToString() == f.FieldID.ToString())
+                            {
+                                //先获取该Field中的所有Particle
+                                List<Particle> list_particle;
+                                list_particle = fieldlist[i].ParticleList;
+                                //再循环计算所有的Particle对象
+                                foreach (Particle particle in list_particle)
+                                {
+                                    //创建DParticle颗粒
+                                    DisplayParticle dp = new DisplayParticle(particle);
+                                    List<Segment> list_seg;
+                                    list_seg = particle.SegmentList;
+                                    //创建颗粒分布图对应的类对象
+                                    List<DisplaySegment> list_dsegment = new List<DisplaySegment>();
+                                    //再循环取出里面所有的segment
+                                    foreach (Segment seg in list_seg)
+                                    {
+                                        #region 创建DSegment对象,并将STD分析出的化合物颜色保存到DSegment对象中
+                                        //对Particle里的Segment进行偏移的计算等,创建了DSegment的大小
+                                        Point on_p = new Point() { X = seg.Start, Y = seg.Height };
+                                        Point off_p = new Point() { X = seg.Start + seg.Length, Y = seg.Height };
+                                        Pen npen = new Pen(dp.Color);
+                                        graph_2.DrawLine(npen, on_p, off_p);
+                                        //graph_2.Dispose();
+                                        #endregion
+                                    }
+                                }
+
+                            }
+                        }
+                        graph.DrawImage(image, f.Rect.X, f.Rect.Y, f.Rect.Width, f.Rect.Height);
+                    }
+
+                    pic_bitmap.Save(sfd.FileName);
+                    pic_bitmap.Dispose();
+                    pic_bitmap.Dispose();
+                    return true;
+                }
+                catch
+                {
+                    return false;
+                }
+
+            }
+            return false;
+        }
         private static byte[] ImgtoByte(Image img)
         {
             MemoryStream ms = new MemoryStream();
@@ -2046,9 +2097,20 @@ namespace OTSIncAReportGraph.Controls
                 );
 #endif
         }
-        #endregion
 
 
+        #endregion
 
+        private void ExportoriginalspliceToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            if (outpic_Render())
+            {
+                MessageBox.Show("Picture export complete");
+            }
+            else
+            {
+                MessageBox.Show("Picture export failed");
+            }
+        }
     }
 }

+ 14 - 3
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.designer.cs

@@ -33,6 +33,7 @@
             this.ToolStripMenuItem_selected = new System.Windows.Forms.ToolStripMenuItem();
             this.ToolStripMenuItem_movesempoint = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem_copyimage = new System.Windows.Forms.ToolStripMenuItem();
+            this.ExportoriginalspliceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.CMenuStrip.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -42,9 +43,10 @@
             this.CMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.ToolStripMenuItem_selected,
             this.ToolStripMenuItem_movesempoint,
-            this.toolStripMenuItem_copyimage});
+            this.toolStripMenuItem_copyimage,
+            this.ExportoriginalspliceToolStripMenuItem});
             this.CMenuStrip.Name = "contextMenuStrip1";
-            this.CMenuStrip.Size = new System.Drawing.Size(219, 116);
+            this.CMenuStrip.Size = new System.Drawing.Size(219, 146);
             // 
             // ToolStripMenuItem_selected
             // 
@@ -67,9 +69,17 @@
             this.toolStripMenuItem_copyimage.Image = global::OTSIncAReportApp.Properties.Resources.复制图像;
             this.toolStripMenuItem_copyimage.Name = "toolStripMenuItem_copyimage";
             this.toolStripMenuItem_copyimage.Size = new System.Drawing.Size(218, 30);
-            this.toolStripMenuItem_copyimage.Text = "导出图像到文件";
+            this.toolStripMenuItem_copyimage.Text = "导出原图拼接图";
             this.toolStripMenuItem_copyimage.Click += new System.EventHandler(this.toolStripMenuItem_copyimage_Click);
             // 
+            // ExportoriginalspliceToolStripMenuItem
+            // 
+            this.ExportoriginalspliceToolStripMenuItem.Image = global::OTSIncAReportApp.Properties.Resources.复制图像;
+            this.ExportoriginalspliceToolStripMenuItem.Name = "ExportoriginalspliceToolStripMenuItem";
+            this.ExportoriginalspliceToolStripMenuItem.Size = new System.Drawing.Size(218, 30);
+            this.ExportoriginalspliceToolStripMenuItem.Text = "导出原图拼接分类图";
+            this.ExportoriginalspliceToolStripMenuItem.Click += new System.EventHandler(this.ExportoriginalspliceToolStripMenuItem_Click);
+            // 
             // Control_DrawDistrbutionImageAndBSE
             // 
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -91,5 +101,6 @@
         private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_movesempoint;
         private Control_Ruler control_Ruler1;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_copyimage;
+        private System.Windows.Forms.ToolStripMenuItem ExportoriginalspliceToolStripMenuItem;
     }
 }