Browse Source

improve distribute image display method.

gsp 2 years ago
parent
commit
2593b2b4f8

+ 18 - 9
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -420,10 +420,21 @@ namespace OTSIncAReportGraph.Controls
                 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 = imageDisHelper.ConvertOTSCoordToScreenCoord(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);
+                DisplayField df;
+                try
+                {
+                     df = new DisplayField(fieldlist[i], fieldwidth, fieldheight, offset_point);
+                    m_list_allDfield.Add(df);
+                    m_list_allDPart.AddRange(df.List_DParticle);
+                }
+                catch (Exception ex)
+                {
+                    NLog.LogManager.GetCurrentClassLogger().Info(ex.Message.ToString());
+                }
+               
+               
 
             }
           
@@ -577,7 +588,7 @@ namespace OTSIncAReportGraph.Controls
         {
             if (OriginalBackground)
             {
-                GetPic(e);
+                DrawOriginalImageAsBackground(e);
             }
             else
             {
@@ -728,7 +739,7 @@ namespace OTSIncAReportGraph.Controls
         {
 
             float zoomDelta = newZoom - m_zoom_record;
-            if (zoomDelta == 0) return;
+            //if (zoomDelta == 0) return;
             m_backRect.Width +=  m_backRect.Width/m_zoom_record*zoomDelta;
             m_backRect.Height +=  m_backRect.Height / m_zoom_record*zoomDelta;
             //锚点缩放补差值计算,得出差值
@@ -754,8 +765,6 @@ namespace OTSIncAReportGraph.Controls
                     dp.SetPaintState(PaintState.NOPAINT);//the particles which are out of screen don't display.to speed up the display efficient.
 
                 }
-              
-
 
             }
             if (m_list_allDfield != null)
@@ -1955,9 +1964,9 @@ namespace OTSIncAReportGraph.Controls
         /// </summary>
         /// <param name="args"></param>
         /// <returns></returns>
-        private void GetPic(PaintEventArgs args)
+        private void DrawOriginalImageAsBackground(PaintEventArgs args)
         {
-            //outpic();
+          
             
             foreach (var f in m_list_allDfield)
             {

+ 17 - 17
OTSIncAReportApp/2-CommonFunction/CommonClass/DisplayField.cs

@@ -47,7 +47,7 @@ namespace OTSIncAReportGraph
             //先获取该Field中的所有Particle
             List<Particle> list_particle;
             list_particle = fld.ParticleList;
-
+           
             //然后将取出的数据,转换成Bitmap对象
             m_originalImage = DrawFunction.ReadImageFile(fld.FieldImage);
 
@@ -111,8 +111,8 @@ namespace OTSIncAReportGraph
         public void Move(SizeF xyShift)
         {
             m_Rect = new RectangleF(
-                           m_Rect.Left + Convert.ToSingle((xyShift.Width)),
-                          m_Rect.Top + Convert.ToSingle((xyShift.Height)),
+                           m_Rect.Left- Convert.ToSingle((xyShift.Width)),
+                          m_Rect.Top - Convert.ToSingle((xyShift.Height)),
                           m_Rect.Width,
                            m_Rect.Height);
            
@@ -182,23 +182,23 @@ namespace OTSIncAReportGraph
 
         public Bitmap OriginalImage { get => m_originalImage; set => m_originalImage = value; }
 
-        public  void OnPaint(PaintEventArgs e)
-        {
+        //public  void OnPaint(PaintEventArgs e)
+        //{
 
-            //开始向下传递并进行绘制
-            foreach (DisplayParticle dp in m_list_dparticle)
-            {
+        //    //开始向下传递并进行绘制
+        //    foreach (DisplayParticle dp in m_list_dparticle)
+        //    {
                
-                if (dp.IsDeleted==false)
-                {
-                    if (dp.GetPaintState() == PaintState.PAINT)
-                    {
-                        dp.OnPaint(e);
-                    }
+        //        if (dp.IsDeleted==false)
+        //        {
+        //            if (dp.GetPaintState() == PaintState.PAINT)
+        //            {
+        //                dp.OnPaint(e);
+        //            }
                    
 
-                }
-            }
-        }
+        //        }
+        //    }
+        //}
     }
 }

+ 10 - 9
OTSIncAReportApp/2-CommonFunction/CommonClass/DisplayParticle.cs

@@ -146,7 +146,7 @@ namespace OTSIncAReportGraph
             //创建颗粒分布图对应的类对象
             List<DisplaySegment> list_dsegment = new List<DisplaySegment>();
 
-
+          
             //再循环取出里面所有的segment
             foreach (Segment seg in list_seg)
             {
@@ -166,6 +166,7 @@ namespace OTSIncAReportGraph
                 #region //这里是在Field中,抠取出原BSE图像到DSegment中--------------------------------
 
                 //合成图像完成,开始抠取像素-----------------------------------------------------------------
+        
                 int f_length = seg.Length;
 
                 for (int m = 0; m < f_length; m++)
@@ -182,8 +183,6 @@ namespace OTSIncAReportGraph
 
 
 
-                   
-
                         fieldParticleImage.SetPixel(lsjs_x, lsjs_y, pixelColor);//ls_list_colors[m]
                     
 
@@ -200,7 +199,7 @@ namespace OTSIncAReportGraph
 
             SetDSegments(list_dsegment);
 
-
+        
             var currentRect = new RectangleF(m_rect.X - screenPos.X, m_rect.Y - screenPos.Y, m_rect.Width, m_rect.Height);
 
             
@@ -227,8 +226,10 @@ namespace OTSIncAReportGraph
 
             foreach (DisplaySegment e in in_list_segment)
             {
+                
                 m_listdsegment.Add(e.Clone() as DisplaySegment);
             }
+            this.m_image = in_particle.m_image;
 
             m_rect = GetRectFromDSegment();
             m_smallRect = GetSmallRectangleFromRect();
@@ -452,17 +453,17 @@ namespace OTSIncAReportGraph
         public void Zoom(float zoomDelta,PointF refPoint)
         {
 
-          
+            var segs = this.GetDSegments();
 
-            for (int y = 0; y < this.GetDSegments().Count(); y++)
+            for (int y = 0; y < segs.Count(); y++)
             {
-                //这里重新设置每条线的高度,和x,y坐标
-                DisplaySegment ds = this.GetDSegments()[y];             
+                
 
+                DisplaySegment ds = segs[y];
                 var rec = ds.GetShowRect();
             
 
-                rec.Width = (float)(rec.Width + Convert.ToDouble(rec.Width/m_CurrentZoomNum * zoomDelta));
+               rec.Width = (float)(rec.Width + Convert.ToDouble(rec.Width/m_CurrentZoomNum * zoomDelta));
                rec.Height = (float)(rec.Height + Convert.ToDouble(rec.Height/m_CurrentZoomNum * zoomDelta));