Browse Source

加入原图为背景功能,

zhangjiaxin 4 năm trước cách đây
mục cha
commit
5936474a74

+ 98 - 7
OTSIncAReportApp/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -8,6 +8,7 @@ using OTSPeriodicTable;
 
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Drawing;
 using System.Drawing.Drawing2D;
 using System.Linq;
@@ -157,6 +158,12 @@ namespace OTSIncAReportGraph.Controls
 
         private Color m_ColorNotContent = Color.SkyBlue;
 
+        //读取背景原图的名称和图片
+        private List<Image> originalImages = new List<Image>();
+        private List<string> originalImageNames = new List<string>();
+        //背景使用原图
+        private bool OriginalBackground = false;
+ 
         /// <summary>
         /// 当前正在显示的数据源名称,用来与框架调用条件判断使用
         /// </summary>
@@ -328,10 +335,21 @@ namespace OTSIncAReportGraph.Controls
         #region 绘制函数
         protected override void OnPaint(PaintEventArgs e)//处理重绘情况
         {
-            #region //填充个背景色矩形-----------------------------------------------
-            SolidBrush b = new SolidBrush(m_backrangecolor);
-            e.Graphics.FillRectangle(b, m_backrectf);
-            #endregion
+            if (OriginalBackground)
+            {
+                GetPic(e);
+            }
+            else
+            {
+                #region //填充个背景色矩形-----------------------------------------------
+                SolidBrush b = new SolidBrush(m_backrangecolor);
+                e.Graphics.FillRectangle(b, m_backrectf);
+                #endregion
+            }
+
+
+
+
 
             #region //计算并进行绘制部份------------------------------------
             //绘制完缩放的图形后,将基数变回,否则会一直刷新无限变大变小
@@ -1778,11 +1796,12 @@ namespace OTSIncAReportGraph.Controls
         /// <summary>
         /// 设置显示BSE原图,还是显示分布图带有标准库的
         /// </summary>
-        /// <param name="in_b">false为显示原bse图像,true为显示带有标准库代表色的图像</param>
-        public void ShowMode(bool in_b)
+        /// <param name="a_type">false为显示原bse图像,true为显示带有标准库代表色的图像</param>
+        public void ShowMode(string a_type)
         {
-            if (in_b == false)
+            if (a_type == "去背景显示")
             {
+                OriginalBackground = false;
                 //bse图时,显示背景图为白色
                 m_backrangecolor = Color.White;
                 foreach (DParticle ls_dp in m_list_baseobject)
@@ -1793,8 +1812,32 @@ namespace OTSIncAReportGraph.Controls
                     }
                 }
             }
+            else if (a_type== "原图显示")
+            {
+                OriginalBackground = true;
+                foreach (DParticle ls_dp in m_list_baseobject)
+                {
+                    foreach (DSegment ls_ds in ls_dp.DSegments)
+                    {
+                        ls_ds.ShowMode = SegmentShowMode.DRAWPOINT;
+                    }
+                }
+            }
+            else if(a_type== "原图颗粒分布")
+            {
+                OriginalBackground = true;
+                foreach (DParticle ls_dp in m_list_baseobject)
+                {
+                    foreach (DSegment ls_ds in ls_dp.DSegments)
+                    {
+                        ls_ds.ShowMode = SegmentShowMode.DRAWLINE;
+                    }
+                }
+            }
+
             else
             {
+                OriginalBackground = false;
                 m_backrangecolor = Color.Gainsboro;
                 foreach (DParticle ls_dp in m_list_baseobject)
                 {
@@ -1826,6 +1869,54 @@ namespace OTSIncAReportGraph.Controls
             return icount;
         }
 
+        /// <summary>
+        /// 获取所有原图
+        /// </summary>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        private void GetPic(PaintEventArgs args)
+        {
+            //将原图读取到内存中
+            if (originalImages.Count == 0)
+            {
+                string path = resultFile.FilePath;
+                System.IO.DirectoryInfo theFolder = new System.IO.DirectoryInfo(path + "\\FIELD_FILES");
+                foreach (System.IO.FileInfo nextifile in theFolder.GetFiles())
+                {
+                    if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
+                    {
+                        Image image = Image.FromFile(path + "\\FIELD_FILES\\" + nextifile.Name);
+                        originalImageNames.Add(nextifile.Name);
+                        originalImages.Add(image);
+                    }
+                }
+            }
+            //绘制原图的大小和位置
+            if (m_list_dfield.Count > 0)
+            {
+                if (originalImageNames.Count > 0)
+                {
+                    for (int i = 0; i < originalImageNames.Count; i++)
+                    {
+                        Size size = new Size();
+                        string ImageName = originalImageNames[i].ToString();
+                        Image Image = originalImages[i];
+
+                        string result = System.Text.RegularExpressions.Regex.Replace(ImageName, @"[^0-9]+", "");
+                        size.Height = (int)m_list_dfield[Convert.ToInt32(result)].Current_Rect.Height;
+                        size.Width = (int)m_list_dfield[Convert.ToInt32(result)].Current_Rect.Width;
+                        Bitmap bitmap = new Bitmap(Image, size);
+
+
+                        PointF pointF = new PointF();
+                        pointF.X = m_list_dfield[Convert.ToInt32(result)].Current_Rect.X;
+                        pointF.Y = m_list_dfield[Convert.ToInt32(result)].Current_Rect.Y;
+                        args.Graphics.DrawImage(bitmap, pointF);
+                    }
+                }
+            }
+
+        }
         #endregion
 
         #region Debug下执行的辅助测试代码

+ 2 - 2
OTSIncAReportApp/FunctionClass/OTSDataMgrFunction/DataMgrFun.cs

@@ -212,8 +212,8 @@ namespace OTSIncAReportApp.OTSDataMgrFunction
                 sampleData1.iItemValType = OTS_ITEM_TYPES.COMBO;
                 sampleData1.bReadOnly = false;
                 sampleData1.sDescriptionInfo = "Survey Chart Type";
-                sampleData1.itemVal = "BSE";
-                sampleData1.comboDownList = new List<string>() { "BSE", sSCaptionName13 };//bse,颗粒分类图
+                sampleData1.itemVal = "去背景显示";
+                sampleData1.comboDownList = new List<string>() { "去背景显示", sSCaptionName13,"原图显示","原图颗粒分布" };//bse,颗粒分类图
                 list.Add(sampleData1);
 
                 //测量图类型

+ 3 - 8
OTSIncAReportApp/FunctionClass/OTSDisplaySGridData/SampleGrid.cs

@@ -493,14 +493,9 @@ namespace OTSIncAReportApp.OTSDataMgrFunction
                             idx = m_RstProp.m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_RstProp.m_ReportApp.SourceGridData.SampleDataList, OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.IMAGE_TYPE);
                             string ImageType = prop.SampleDataList[idx].itemVal.ToString();
                             //切换BSE和分类,两种影像的显示方式
-                            if (ImageType == "BSE") //sc.strBSEType == "BSE"
-                            {
-                                m_RstProp.m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.ShowMode(false);
-                            }
-                            else
-                            {
-                                m_RstProp.m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.ShowMode(true);
-                            }
+                            
+                             m_RstProp.m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.ShowMode(ImageType);
+                           
 
 
                         }