ソースを参照

optimize the loading speed of the BMP picture of each field.

gsp 11 ヶ月 前
コミット
b8013aa1b2

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

@@ -3,7 +3,7 @@
   <Member RegName="Scale" strValue="1000" />
   <Member RegName="DefaultComputedColName" strValue="Area,EquivalentCircleDiameter,MaxDiameter,MinDiameter,DiameterRatio,FerretDiameter,PERP,PERI,INSCR,MEAN,ELONG,ASPECT_ELONG,Orientation" />
   <Member RegName="ElementsColName" strValue="C,O,Al,Fe,F,Ti,Na,Mn,Mg" />
-  <Member RegName="PartSizeFile" name="lj2.psf" />
+  <Member RegName="PartSizeFile" name="lj.psf" />
   <Member RegName="TRIO_CHART_TYPE" strValue="CaO.SiO₂.Al₂O₃" />
   <Member RegName="SIZE_CAL_METHOD_TYPE" strValue="DMAX" />
 </XMLData>

+ 1 - 1
Bin/x64/Debug/Config/SysData/OTSStage.stg

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<XMLData Modify="true" PathName=".\Config\SysData\OTSStage.stg" WorkingStageId="3">
+<XMLData Modify="true" PathName=".\Config\SysData\OTSStage.stg" WorkingStageId="4">
   <Collection RegName="Stagelist">
     <Member strName="圆形九圆孔50mm">
       <Member RegName="boundary" PolygonPoint="" rectDomian="0,0,50000,0" shape="0:ROUND" />

+ 2 - 3
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -811,12 +811,11 @@ namespace OTSDataType
         }
         public void CalculateParticleAbsolutPos(CSEMStageData pCSEMStageData)
         {
-            //double dPixelSize = m_Sample.CalculatePixelSize();
-            //CSEMStageData pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
+       
             foreach (var p in GetListAnalysisParticles())
             {
 
-                //Point fldOtsPos = new Point((curFldData.OTSPos.X, curFldData.OTSPos.Y);
+               
                 PointF semP = new PointF(); ;
                 Point semPos = new Point();
                 pCSEMStageData.ConvertOTSToSEMCoord(GetOTSPosition(), ref semP);

+ 3 - 0
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSSample.cs

@@ -378,6 +378,7 @@ namespace OTSDataType
             xString xstrHoleName = new xString();
             xBool xParamLock = new xBool();
             xBool xSwitch = new xBool();
+            xDouble xTotalArea = new xDouble();
          
             Collection<COTSField> fielddata = new Collection<COTSField>();
             Slo slo = new Slo();
@@ -389,6 +390,7 @@ namespace OTSDataType
             slo.Register("MsrArea", m_poMsrArea);
             slo.Register("MsrParams", m_poMsrParams);
             slo.Register("SEMDataMsr", m_poSEMDataMsr);
+            slo.Register("TotalArea", xTotalArea);
             slo.Register("AllFields", fielddata);
             if (isStoring)
             {
@@ -396,6 +398,7 @@ namespace OTSDataType
                 xstrHoleName.AssignValue(m_strHoleName);
                 xParamLock.AssignValue(m_bParamLock);
                 xSwitch.AssignValue(m_bSwitch);
+                xTotalArea.AssignValue(this.GetTotalToMeasureArea());
                 foreach (var f in m_listFieldData)
                 {
                     fielddata.addItem(f);

+ 39 - 39
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionSortImage.cs

@@ -315,15 +315,15 @@ namespace OTSIncAReportGraph.Controls
         /// 获取随机的颜色
         /// </summary>
         /// <returns></returns>
-        public Color GetRandomColor()
-        {
-            int R = new Random((int)DateTime.Now.Ticks).Next(255);
-            int G = new Random((int)DateTime.Now.Ticks).Next(255);
-            int B = new Random((int)DateTime.Now.Ticks).Next(255);
-            B = (R + G > 400) ? R + G - 400 : B;//0 : 380 - R - G;
-            B = (B > 255) ? 255 : B;
-            return Color.FromArgb(R, G, B);
-        }
+        //public Color GetRandomColor()
+        //{
+        //    int R = new Random((int)DateTime.Now.Ticks).Next(255);
+        //    int G = new Random((int)DateTime.Now.Ticks).Next(255);
+        //    int B = new Random((int)DateTime.Now.Ticks).Next(255);
+        //    B = (R + G > 400) ? R + G - 400 : B;//0 : 380 - R - G;
+        //    B = (B > 255) ? 255 : B;
+        //    return Color.FromArgb(R, G, B);
+        //}
 
         /// <summary>
         /// 随机获取一个多边形
@@ -333,36 +333,36 @@ namespace OTSIncAReportGraph.Controls
         /// <param name="width"></param>
         /// <param name="height"></param>
         /// <returns></returns>
-        public DisplayParticle GetRondemDParticle(int x, int y, int width, int height, int r)
-        {
-            DisplayParticle ls_dp = new DisplayParticle();
-
-            for (int i = 0; i < height; i++)
-            {
-                DisplaySegment ls_ds = new DisplaySegment();
-                ls_ds.Color = GetRandomColor();
-                //随机生成x坐标偏移,和宽度
-                Random rd = new Random((int)DateTime.Now.Ticks);
-                int a = rd.Next(1);
-                if (a == 0)
-                {
-                    int n = rd.Next(r);
-                    x = x + n;
-                    width = width + n;
-                }
-                else
-                {
-                    int n = rd.Next(r);
-                    x = -+n;
-                    width = width - n;
-                }
-
-                ls_ds.SetShowRect(new Rectangle(x, y + i, width, 1));//高度是1的线段 
-                ls_dp.GetDSegments().Add(ls_ds);
-            }
-
-            return ls_dp;
-        }
+        //public DisplayParticle GetRondemDParticle(int x, int y, int width, int height, int r)
+        //{
+        //    DisplayParticle ls_dp = new DisplayParticle();
+
+        //    for (int i = 0; i < height; i++)
+        //    {
+        //        DisplaySegment ls_ds = new DisplaySegment();
+        //        ls_ds.Color = GetRandomColor();
+        //        //随机生成x坐标偏移,和宽度
+        //        Random rd = new Random((int)DateTime.Now.Ticks);
+        //        int a = rd.Next(1);
+        //        if (a == 0)
+        //        {
+        //            int n = rd.Next(r);
+        //            x = x + n;
+        //            width = width + n;
+        //        }
+        //        else
+        //        {
+        //            int n = rd.Next(r);
+        //            x = -+n;
+        //            width = width - n;
+        //        }
+
+        //        ls_ds.SetShowRect(new Rectangle(x, y + i, width, 1));//高度是1的线段 
+        //        ls_dp.GetDSegments().Add(ls_ds);
+        //    }
+
+        //    return ls_dp;
+        //}
         #endregion
 
         #region 设置双缓冲

+ 3 - 91
OTSIncAReportApp/2-CommonFunction/CommonClass/DisplayParticle.cs

@@ -138,7 +138,7 @@ namespace OTSIncAReportGraph
         {
             m_id = System.Guid.NewGuid();
             objParticleData = part;
-            this.Color = GetColorBySTDTypeIDForBSEAndSorImage(part.TypeColor, part.TypeId);
+            this.Color = DrawFunction.GetColorBySTDTypeIDForBSEAndSorImage(part.TypeColor, part.TypeId);
 
         }
         public DisplayParticle(Particle particle,PointF FieldLeftTop,Bitmap originalFieldImage,Bitmap fieldParticleImage)
@@ -920,95 +920,7 @@ namespace OTSIncAReportGraph
 
             return rect;
         }
-        public Color GetColorBySTDTypeIDForBSEAndSorImage(string in_partcolor, int in_stdtypeid)
-        {
-            Color ret_c = new Color();
-
-
-            if (in_stdtypeid < 1000)
-            {
-
-                ret_c = GetColorByEnum(in_stdtypeid);
-            }
-            else if (in_stdtypeid >= 1000)
-            {
-                //大于等于1000,并且小于10000时,使用用户标准库来分析夹杂物名称
-                if (!in_partcolor.Contains("#"))
-                {
-                    ret_c = DrawFunction.colorHx16toRGB("#" + in_partcolor);//接收必须是#000000的格式
-                }
-                else
-                {
-                    ret_c = DrawFunction.colorHx16toRGB(in_partcolor);//接收必须是#000000的格式
-                }
-            }
-            return ret_c;
-        }
-        public Color GetColorByEnum(int STDID)
-        {
-            Color ret_c = new Color();
-            switch (STDID)
-            {
-                case -1:
-                    //INVALID = -1,
-                    //stdName = "无效颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 0:
-                    //small = 0;
-                    //stdName = "过小颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 1:
-                    //OVERSIZE = 1,
-                    //stdName = "过大颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 2:
-                    //AVE_GRAY_NOT_INRANRE = 2, 
-                    //stdName = "亮度不在分析范围内的颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 3:
-                    //SEARCH_X_RAY = 3,
-                    //stdName = "不进行搜索x-ray分析的颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 4:
-                    //LOW_COUNT = 4, 
-                    //stdName = "低x-ray计数颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 5:
-                    //NO_INTEREST_ELEMENTS = 5,
-                    //stdName = "不含分析元素的颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 6:
-                    //ALAYSIS_X_RAY = 6,
-                    //stdName = "不进行x-ray分析的颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 7:
-                    //NOT_IDENTIFIED = 7,
-                    //stdName = "未识别颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 8:
-                    //NOT_IDENTIFIED = 8,
-                    //stdName = "未识别颗粒";
-                    ret_c = Color.Black;
-                    break;
-                case 9:
-                    //NOT_IDENTIFIED = 9,
-                    //stdName = "未识别颗粒";
-                    ret_c = Color.Black;
-                    break;
-                default:
-                    ret_c = Color.Black;
-                    break;
-            }
-            return ret_c;
-        }
+     
+       
     }
 }

+ 32 - 11
OTSIncAReportApp/2-CommonFunction/CommonClass/DrawFunction.cs

@@ -328,6 +328,7 @@ namespace OTSIncAReportGraph.Class
 
             return ret_color;
         }
+        private static Dictionary<string, Color> colordic = new Dictionary<string, Color>();
         public static Color GetColorBySTDTypeIDForBSEAndSorImage(string in_partcolor, int in_stdtypeid)
         {
             Color ret_c = new Color();
@@ -343,11 +344,29 @@ namespace OTSIncAReportGraph.Class
                 //大于等于1000,并且小于10000时,使用用户标准库来分析夹杂物名称
                 if (!in_partcolor.Contains("#"))
                 {
-                    ret_c = DrawFunction.colorHx16toRGB("#" + in_partcolor);//接收必须是#000000的格式
+                    in_partcolor = "#" + in_partcolor;
+                    if (colordic.ContainsKey(in_partcolor))//using dictionary to speed up.
+                    {
+                        ret_c = colordic[ in_partcolor];
+                    }
+                    else 
+                    {
+                        ret_c = DrawFunction.colorHx16toRGB(in_partcolor);//接收必须是#000000的格式
+                        colordic.Add(in_partcolor, ret_c);
+                    }
+                   
                 }
                 else
                 {
-                    ret_c = DrawFunction.colorHx16toRGB(in_partcolor);//接收必须是#000000的格式
+                    if (colordic.ContainsKey(in_partcolor))//using dictionary to speed up.
+                    {
+                        ret_c = colordic[in_partcolor];
+                    }
+                    else
+                    {
+                        ret_c = DrawFunction.colorHx16toRGB(in_partcolor);//接收必须是#000000的格式
+                        colordic.Add(in_partcolor, ret_c);
+                    }
                 }
             }
             return ret_c;
@@ -507,15 +526,17 @@ namespace OTSIncAReportGraph.Class
             {
                 return null;//文件不存在
             }
-            FileStream fs = File.OpenRead(path); //OpenRead
-            int filelength = 0;
-            filelength = (int)fs.Length; //获得文件长度 
-            Byte[] image = new Byte[filelength]; //建立一个字节数组 
-            fs.Read(image, 0, filelength); //按字节流读取 
-            System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
-            fs.Close();
-            Bitmap bit = new Bitmap(result);
-            return bit;
+            //FileStream fs = File.OpenRead(path); //OpenRead
+            //int filelength = 0;
+            //filelength = (int)fs.Length; //获得文件长度 
+            //Byte[] image = new Byte[filelength]; //建立一个字节数组 
+            //fs.Read(image, 0, filelength); //按字节流读取 
+            //System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
+            //fs.Close();
+            //Bitmap bit = new Bitmap(result);
+            //return bit;
+            var bit = Bitmap.FromFile(path);
+            return (Bitmap)bit;
         }
         //图片转成二进制        
         public static byte[] GetPictureData(string imagepath)