Explorar o código

improve the distribute Image display method.

gsp %!s(int64=3) %!d(string=hai) anos
pai
achega
0d78f3f76e

+ 10 - 1
OTSCPP/OTSControl/Oxford/OxfordWrapper/OxfordControllerWrapper.cpp

@@ -254,8 +254,17 @@ void OxfordControllerWrapper::ControllerThreadFunction()
 
 					// <note>Accept pixel position to convert to oxford normalized beam position</note>
 					Point pos(pXrayData->m_nPosX * _oxfordControllerData.m_dPixelSize, pXrayData->m_nPosY * _oxfordControllerData.m_dPixelSize);
-					edsSettings->ScanSettings->AcquisitionRegion->CreatePointRegion(pos);
+
+			
+
+
+					edsSettings->EdSettings->AcquisitionMode = (EdAcquireMode)1;
 					edsSettings->EdSettings->AcquisitionTime = TimeSpan::FromMilliseconds(_oxfordControllerData.m_nAcTime);
+					edsSettings->EdSettings->ProcessTime = 5;
+					/*edsSettings->EdSettings->EnergyRange = 100;
+					edsSettings->EdSettings->NumberOfChannels = 1;*/
+
+					edsSettings->ScanSettings->AcquisitionRegion->CreatePointRegion(pos);
 
 					edsController->StartAcquisition(edsSettings);
 

+ 18 - 10
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -172,11 +172,15 @@ namespace OTSIMGPROC
 			
 
 			std::vector<CPoint> matrixPs;
-		
-			CPoint theFirst = CPoint(rect.left + xrayStep / 2, rect.top + xrayStep / 2);
 
 			int colnum = ceil((double)rect.Width() / xrayStep + 0.5);
+			if (colnum % 2 == 0) colnum += 1;//let the number to be an odd number.Then we can make the middle point in the center of the particle exactly.
 			int rownum = ceil((double)rect.Height() / xrayStep + 0.5);
+			if (rownum % 2 == 0) rownum += 1;
+		
+			CPoint theFirst = CPoint(rect.left-(colnum*xrayStep-rect.Width())/2  + xrayStep / 2, rect.top-(rownum*xrayStep-rect.Height())/2 + xrayStep / 2);
+
+			
 			for (int i = 0; i < rownum; i++)
 			{
 				for (int j = 0; j < colnum; j++)
@@ -184,7 +188,7 @@ namespace OTSIMGPROC
 					double x =(double) theFirst.x + (double)j * xrayStep;
 					double y = (double)theFirst.y + (double)i * xrayStep;
 					CPoint thePoint = CPoint(x, y);
-					Point cvP = Point(x, y);
+				
 				
 					matrixPs.push_back(thePoint);
 				
@@ -218,13 +222,14 @@ namespace OTSIMGPROC
 
 						if (segStart > rsegEnd || rsegStart > segEnd)//there's no intersection.is not a valid seg for this original segment.
 						{
+							
 							continue;
 						}
 
 						if (segStart>=rsegStart && segEnd <= rsegEnd)//contained in the original segment,is a valid seg.
 						{
 							segs.push_back(seg);
-							break;
+							continue;
 						}						
 						else if (segStart>= rsegStart&& segEnd >= rsegEnd)// intersect in the head end.Modify the end of the seg .
 						{
@@ -262,12 +267,15 @@ namespace OTSIMGPROC
 
 					
 				}
-
-				part->GetFeature()->SetSegmentsList(segs);
-				part->CalXRayPos();
-				part->SetFieldId(a_pOTSPart->GetFieldId());
-				part->SetAnalysisId(a_pOTSPart->GetAnalysisId());
-				matricsParts.push_back(part);
+				if (segs.size() > 0)
+				{
+					part->GetFeature()->SetSegmentsList(segs);
+					part->CalXRayPos();
+					part->SetFieldId(a_pOTSPart->GetFieldId());
+					part->SetAnalysisId(a_pOTSPart->GetAnalysisId());
+					matricsParts.push_back(part);
+				}
+				
 			}
 
 

+ 20 - 2
OTSIncAMeasureApp/0-OTSModel/Measure/5-OTSMining/SmplMeasureMining.cs

@@ -208,6 +208,7 @@ namespace OTSModelSharp
 
                         var mergedSegs = MergeSegments(segs);
                         firstPart.GetFeature().SetSegmentsList(mergedSegs, false);
+
                     }
                     firstPart.SetAnalysisId(finalParts.Count);
                     firstPart.SetParticleId(finalParts.Count);
@@ -239,11 +240,28 @@ namespace OTSModelSharp
                 else
                 {
                     var sortSegs = dicSegs[seg.GetHeight()];
+                    var start = seg.GetStart();
                     if (!sortSegs.ContainsKey(seg.GetStart()))
                     {
-                        dicSegs[seg.GetHeight()].Add(seg.GetStart(), seg);
+
+                        sortSegs.Add(seg.GetStart(), seg);
                     }
-                    
+                    else 
+                    {
+                        var equalStartSeg = sortSegs[start];
+
+                        var L1 = seg.GetLength();
+                        var L2 = equalStartSeg.GetLength();
+                        if (L1 > L2)
+                        {
+
+                            sortSegs.Remove(start);
+                            sortSegs.Add(start, seg);
+                        }
+
+
+                    }
+
                 }
             }
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 193 - 319
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs


+ 72 - 92
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionSortImage.cs

@@ -27,7 +27,7 @@ namespace OTSIncAReportGraph.Controls
         #region 变量定义
         private SelectTool m_SelectTool;
         //这里要做成控件,不要是窗体
-        public List<BaseObject> m_list_baseobject = null;
+        public List<DisplayParticle> m_list_baseobject = null;
 
         //多边形的分栏,list
         public List<SortParticleDistribution> m_list_sortparticledistribution = null;
@@ -137,11 +137,12 @@ namespace OTSIncAReportGraph.Controls
             resultFile = m_ReportApp.m_rstDataMgr.CurResultFile;
 
             //初始化数据操作类
-            m_ReportFun = m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.ReportFun;
-            m_list_baseobject = new List<BaseObject>();
-            for (int i=0;i< m_ReportFun.m_original_list_baseobject.Count;i++)
+            m_ReportFun = m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.imageDisHelper;
+            m_list_baseobject = new List<DisplayParticle>();
+            var allpart = m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.m_list_allDPart;
+            for (int i=0;i< allpart.Count;i++)
             {
-                m_list_baseobject.Add(m_ReportFun.m_original_list_baseobject[i]);
+                m_list_baseobject.Add(allpart[i]);
             }
             InitializeComponent();
             #region 国际化语言
@@ -325,8 +326,8 @@ namespace OTSIncAReportGraph.Controls
                     width = width - n;
                 }
 
-                ls_ds.Rect = new Rectangle(x, y + i, width, 1);//高度是1的线段 
-                ls_dp.DSegments.Add(ls_ds);
+                ls_ds.SetShowRect(new Rectangle(x, y + i, width, 1));//高度是1的线段 
+                ls_dp.GetDSegments().Add(ls_ds);
             }
 
             return ls_dp;
@@ -381,14 +382,14 @@ namespace OTSIncAReportGraph.Controls
             foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
             {
                 //开始向下传递并进行绘制
-                foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
+                foreach (DisplayParticle dp in ls_sortparticledistribution.List_DParticle)
                 {
-                    DisplayParticle dp = (DisplayParticle)item;
+                    //DisplayParticle dp = (DisplayParticle)item;
                     if (dp.IsDeleted==false)
                     {
                         if (dp.GetPaintState() == PaintState.PAINT)
                         {
-                            item.OnPaint(e);
+                            dp.OnPaint(e);
                         }
                     }
                         
@@ -452,29 +453,29 @@ namespace OTSIncAReportGraph.Controls
 
                 foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
                 {
-                    foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
+                    foreach (DisplayParticle item in ls_sortparticledistribution.List_DParticle)
                     {
-                        DisplayParticle dp = (DisplayParticle)item;
+                        DisplayParticle dp = item;
 
 
 
-                        foreach (DisplaySegment ds in dp.DSegments)
+                        foreach (DisplaySegment ds in dp.GetDSegments())
                         {
-                            ds.Rect = new RectangleF(
-                            ds.Rect.X,  //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
-                            ds.Rect.Y + e.Delta / 2,
-                            ds.Rect.Width,
-                            ds.Rect.Height);
+                            ds.SetShowRect(new RectangleF(
+                            ds.GetShowRect().X,  //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
+                            ds.GetShowRect().Y + e.Delta / 2,
+                            ds.GetShowRect().Width,
+                            ds.GetShowRect().Height));
                             
                             
                         }
                       
 
                         //获取矩形的rectangle
-                        dp.Rect = dp.GetRectFromDSegment();
+                        //dp.SetRect(dp.GetRectFromDSegment());
 
                        
-                        if (dp.Rect.Left < -60 || dp.Rect.Right > this.Width +60|| dp.Rect.Top < -60 || dp.Rect.Bottom > this.Height+60)
+                        if (dp.GetShowRect().Left < -60 || dp.GetShowRect().Right > this.Width +60|| dp.GetShowRect().Top < -60 || dp.GetShowRect().Bottom > this.Height+60)
                         {
                             dp.SetPaintState(PaintState.NOPAINT);
                         }
@@ -583,7 +584,7 @@ namespace OTSIncAReportGraph.Controls
                                     PointF[] lspointf = ls_gpath.PathPoints;
                                     for (int i = 0; i < lspointf.Count(); i++)
                                     {
-                                        if (true == m_ReportFun.WhetherInRange(m_SelectTool.Rect,lspointf, new Point((int)dp.Rect.X,(int)dp.Rect.Y)))
+                                        if (true == m_ReportFun.WhetherInRange(m_SelectTool.Rect,lspointf, new Point((int)dp.GetShowRect().X,(int)dp.GetShowRect().Y)))
                                         {
                                             //选择到了该路径,那么就选取该图像
                                             dp.IsSelect = true;
@@ -609,7 +610,7 @@ namespace OTSIncAReportGraph.Controls
                 {
                     foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
                     {
-                        foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
+                        foreach (DisplayParticle item in ls_sortparticledistribution.List_DParticle)
                         {
                             if (true == item.IsDragging)
                             {
@@ -628,12 +629,12 @@ namespace OTSIncAReportGraph.Controls
                         {
                             foreach (DisplayParticle dp in ls_sortparticledistribution.List_DParticle)
                             {
-                                dp.GPath = dp.GetRegionFromDSegments();
-                                PointF[] lspointf = dp.GPath.PathPoints;
+                             
+                             
                                 if (true ==m_ReportFun. WhetherInRange(dp, new Point(e.X, e.Y)))
                                 {
                                     //选择到了该路径,那么就选取该图像b
-                                    dp.Operator_ShowXRay = ParticleShowXray.SELECTANDDISPLAYXRAY;
+                                    dp.Operator_ShowXRay = ParticleShowXray.DISPLAYXRAY;
                                 }
                                 else
                                 {
@@ -669,12 +670,12 @@ namespace OTSIncAReportGraph.Controls
                 //这个判断右键菜单加在这里,也不知道对不对
                 foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
                 {
-                    foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
+                    foreach (DisplayParticle item in ls_sortparticledistribution.List_DParticle)
                     {
-                        if (true == m_ReportFun.WhetherInRange((DisplayParticle)item, e.Location))
+                        if (true == m_ReportFun.WhetherInRange(item, e.Location))
                         {
 
-                            DisplayParticle dp = (DisplayParticle)item;
+                            DisplayParticle dp = item;
                             if (dp.GetPaintState() == PaintState.PAINT )
                             {
                                 CMenuStrip.Items[0].Enabled = true;
@@ -777,67 +778,44 @@ namespace OTSIncAReportGraph.Controls
                 {
                     foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
                     {
-                        foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
-                        {
-                            DisplayParticle dp = (DisplayParticle)item;
-
-                    
-                        if (dp.GetPaintState() == PaintState.PAINT)
-                        {
-                            if (true == m_ReportFun.WhetherInRange(dp, e.Location))
+                            foreach (DisplayParticle dp in ls_sortparticledistribution.List_DParticle)
                             {
+                             
+                    
+                                if (dp.GetPaintState() == PaintState.PAINT)
+                                {
+                                    if (true == m_ReportFun.WhetherInRange(dp, e.Location))
+                                    {
 
-                                dp.IsMouseOver = true;
-
-                                //显示xray图
-                                if (control_XRayTable1.Visible == false)
-                                    ShowXRay(dp);
-
+                                        dp.IsMouseOver = true;
 
-                            }
-                            else
-                            {
-                                dp.IsMouseOver = false;
 
-                                //移动在颗粒外面时,要判断,Operator_ShowXray不为选下显示XRAY时,才对XRay进行隐藏
-                                if (dp.Operator_ShowXRay != ParticleShowXray.SELECTANDDISPLAYXRAY)
-                                {
-                                    //隐藏x-ray能谱图
-                                    HideXRay(dp);
-                                }
-                            }
+                                        ShowXRay(dp);
 
-                        }
-                            
 
-                            if (true == item.IsDragging)
-                            {
-                                //再将里面的线也进行计算坐标
-                                foreach (DisplaySegment ds in dp.DSegments)
-                                {
-                                    ds.Rect = new RectangleF(
-                                    ds.Rect.X + e.X - item.DraggingPoint.X,  //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
-                                    ds.Rect.Y + e.Y - item.DraggingPoint.Y,
-                                    ds.Rect.Width,
-                                    ds.Rect.Height);
-                                    ds.DraggingPoint = e.Location;
-                                }
-                                item.DraggingPoint = e.Location;
+                                    }
+                                    else
+                                    {
+                                        dp.IsMouseOver = false;
 
-                                //获取矩形的rectangle
-                                dp.Rect = dp.GetRectFromDSegment();
 
-                                //通过line获取路径边缘
-                                dp.GPath = dp.GetRegionFromDSegments();
+                                        HideXRay(dp);
+                                    
+                                    }
 
-                                //重新计算小矩形边框
-                                dp.SmallRect = dp.GetSmallRectangleFromRect();
-                                if (dp.Rect.Left < 0 || dp.Rect.Right > this.Width || dp.Rect.Top < 0 || dp.Rect.Bottom > this.Height)
-                                {
-                                    dp.SetPaintState(PaintState.NOPAINT);
                                 }
+                            
+
+                                    if (true == dp.IsDragging)
+                                    {
+                                        dp.DraggingMove(e.Location);
+                                   
+                                        if (dp.GetShowRect().Left < 0 || dp.GetShowRect().Right > this.Width || dp.GetShowRect().Top < 0 || dp.GetShowRect().Bottom > this.Height)
+                                        {
+                                            dp.SetPaintState(PaintState.NOPAINT);
+                                        }
+                                    }
                             }
-                        }
                     }
 
                     //如果在拖动中
@@ -861,9 +839,9 @@ namespace OTSIncAReportGraph.Controls
             m_str_mouseshow_left = "无";
             foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
             {
-                foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
+                foreach (DisplayParticle item in ls_sortparticledistribution.List_DParticle)
                 {
-                    DisplayParticle dp = (DisplayParticle)item;
+                    DisplayParticle dp = item;
                     if (true == m_ReportFun.WhetherInRange(dp, e.Location))
                     {
                         if (dp.GetPaintState() == PaintState.PAINT)
@@ -1124,14 +1102,14 @@ namespace OTSIncAReportGraph.Controls
                     {
                         List<DisplayParticle> newParts = new List<DisplayParticle>();
                         var p = ls_dp.Clone() as DisplayParticle;
-                        p.Rect = p.GetRectFromDSegment();
+                        //p.SetRect(p.GetRectFromDSegment());
                         newParts.Add(p);
                         FLNameList.Add(ls_dp.TypeName, newParts);
                     }
                     else
                     {
                         var p = ls_dp.Clone() as DisplayParticle;
-                        p.Rect = p.GetRectFromDSegment();
+                        //p.SetRect(p.GetRectFromDSegment());
                         FLNameList[ls_dp.TypeName].Add(p);
 
                     }
@@ -1217,7 +1195,7 @@ namespace OTSIncAReportGraph.Controls
                         {
                             //将对应的颗粒添加到分栏grid中
                             DisplayParticle sort_dp = ls_dp.Clone() as DisplayParticle;
-                            sort_dp.Rect = sort_dp.GetRectFromDSegment();
+                            //sort_dp.SetRect(sort_dp.GetRectFromDSegment());
                             sort[i].List_DParticle.Add(sort_dp);
                             break;
                         }
@@ -1295,10 +1273,11 @@ namespace OTSIncAReportGraph.Controls
                 {
                     foreach (DisplayParticle ls_dp in item.List_DParticle)
                     {
-                        foreach (DisplaySegment ls_ds in ls_dp.DSegments)
-                        {
-                            ls_ds.ShowMode = SegmentShowMode.DRAWPOINT;
-                        }
+                        ls_dp.ShowMode = SegmentShowMode.DRAWPOINT;
+                        //foreach (DisplaySegment ls_ds in ls_dp.GetDSegments())
+                        //{
+                            
+                        //}
                     }
                 }
             }
@@ -1308,10 +1287,11 @@ namespace OTSIncAReportGraph.Controls
                 {
                     foreach (DisplayParticle ls_dp in item.List_DParticle)
                     {
-                        foreach (DisplaySegment ls_ds in ls_dp.DSegments)
-                        {
-                            ls_ds.ShowMode = SegmentShowMode.DRAWLINE;
-                        }
+                        ls_dp.ShowMode = SegmentShowMode.DRAWLINE;
+                        //foreach (DisplaySegment ls_ds in ls_dp.GetDSegments())
+                        //{
+                           
+                        //}
                     }
                 }
             }
@@ -1526,7 +1506,7 @@ namespace OTSIncAReportGraph.Controls
 
        
 
-            m_list_baseobject = new List<BaseObject>();
+            m_list_baseobject = new List<DisplayParticle>();
      
 
             m_list_sortparticledistribution = new List<SortParticleDistribution>();

+ 17 - 15
OTSIncAReportApp/1-UI/Control_Graph/Controls/OutPIC.cs

@@ -1,5 +1,6 @@
 using OTSCommon.Model;
 using OTSIncAReportGraph;
+using OTSIncAReportGraph.Class;
 using OTSIncAReportGraph.Controls;
 using System;
 using System.Collections.Generic;
@@ -33,8 +34,8 @@ namespace OTSIncAReportApp._3_ServiceCenter
             foreach (var f in m_list_allDfield)
             {
                 DataRow dr = picDatat.NewRow();
-                dr["X"] = f.Rect.X;
-                dr["Y"] = f.Rect.Y;
+                dr["X"] = f.GetShowRect().X;
+                dr["Y"] = f.GetShowRect().Y;
                 picDatat.Rows.Add(dr);
             }
             int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
@@ -62,7 +63,7 @@ namespace OTSIncAReportApp._3_ServiceCenter
                 for (int a = 0; a < total_dt_X.Rows.Count; a++)
                 {
                     DataRow dr2 = data.NewRow();
-                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].Rect.Width, (int)m_list_allDfield[0].Rect.Height);
+                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].GetShowRect().Width, (int)m_list_allDfield[0].GetShowRect().Height);
                     Graphics g = Graphics.FromImage(bitmap);
                     g.Clear(Color.White);
                     g.Dispose();
@@ -72,14 +73,14 @@ namespace OTSIncAReportApp._3_ServiceCenter
                 }
                 foreach (var f in m_list_allDfield)
                 {
-                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.Rect.Y.ToString())
+                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.GetShowRect().Y.ToString())
                     {
                         for (int c = 0; c < data.Rows.Count; c++)
                         {
-                            if (data.Rows[c]["X"].ToString() == f.Rect.X.ToString())
+                            if (data.Rows[c]["X"].ToString() == f.GetShowRect().X.ToString())
                             {
                                 data.Rows[c]["mat"] = f.OriginalImage;
-                                data.Rows[c]["X"] = f.Rect.X;
+                                data.Rows[c]["X"] = f.GetShowRect().X;
                             }
                         }
 
@@ -142,8 +143,8 @@ namespace OTSIncAReportApp._3_ServiceCenter
             foreach (var f in m_list_allDfield)
             {
                 DataRow dr = picDatat.NewRow();
-                dr["X"] = f.Rect.X;
-                dr["Y"] = f.Rect.Y;
+                dr["X"] = f.GetShowRect().X;
+                dr["Y"] = f.GetShowRect().Y;
                 picDatat.Rows.Add(dr);
             }
             int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
@@ -172,7 +173,7 @@ namespace OTSIncAReportApp._3_ServiceCenter
                 for (int a = 0; a < total_dt_X.Rows.Count; a++)
                 {
                     DataRow dr2 = data.NewRow();
-                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].Rect.Width, (int)m_list_allDfield[0].Rect.Height);
+                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].GetShowRect().Width, (int)m_list_allDfield[0].GetShowRect().Height);
                     Graphics g = Graphics.FromImage(bitmap);
                     g.Clear(Color.White);
                     g.Dispose();
@@ -182,11 +183,11 @@ namespace OTSIncAReportApp._3_ServiceCenter
                 }
                 foreach (var f in m_list_allDfield)
                 {
-                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.Rect.Y.ToString())
+                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.GetShowRect().Y.ToString())
                     {
                         for (int c = 0; c < data.Rows.Count; c++)
                         {
-                            if (data.Rows[c]["X"].ToString() == f.Rect.X.ToString())
+                            if (data.Rows[c]["X"].ToString() == f.GetShowRect().X.ToString())
                             {
                                 Bitmap image = new Bitmap(f.OriginalImage.Width, f.OriginalImage.Height);
                                 Graphics g2 = Graphics.FromImage(image);
@@ -203,8 +204,8 @@ namespace OTSIncAReportApp._3_ServiceCenter
                                         //再循环计算所有的Particle对象
                                         foreach (Particle particle in list_particle)
                                         {
-                                            //创建DParticle颗粒
-                                            DisplayParticle dp = new DisplayParticle(particle);
+                                          
+                                         
                                             List<Segment> list_seg;
                                             list_seg = particle.SegmentList;
                                             //创建颗粒分布图对应的类对象
@@ -216,7 +217,8 @@ namespace OTSIncAReportApp._3_ServiceCenter
 
                                                 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);
+                                                var color = DrawFunction.GetColorBySTDTypeIDForBSEAndSorImage(particle.TypeColor, particle.TypeId);
+                                                Pen npen = new Pen(color);
                                                 graph_2.DrawLine(npen, on_p, off_p);
 
                                                 #endregion
@@ -225,7 +227,7 @@ namespace OTSIncAReportApp._3_ServiceCenter
                                     }
                                 }
                                 data.Rows[c]["mat"] = image;
-                                data.Rows[c]["X"] = f.Rect.X;
+                                data.Rows[c]["X"] = f.GetShowRect().X;
                             }
                         }
                     }

+ 54 - 27
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -51,9 +51,9 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         public ParticleSegmentation m_ParticleSegmentation;
 
         //记录field列表的原值
-        public List<DisplayField> m_original_list_dfield = null;
+        //public List<DisplayField> m_original_list_dfield = null;
         //记录原值,颗粒和线段
-        public List<BaseObject> m_original_list_baseobject = null;
+        //public List<DisplayParticle> m_originalAllPart = null;
 
 
         NLog.Logger log;
@@ -74,8 +74,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         //电镜设置对象
         public  ServiceInterface.HardwareController m_cfun = null;
 
-        //是否已经连接到了电镜
-        //public bool m_SEMConnectionState = false;
+
 
         //连接到电镜的ID号
         public int m_SEM_ID = 0;
@@ -87,9 +86,9 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
      
         public OTSImageDisHelp( ResultFile result)
         {
-            m_original_list_dfield = new List<DisplayField>();
+            //m_original_list_dfield = new List<DisplayField>();
 
-            m_original_list_baseobject = new List<BaseObject>();
+            //m_originalAllPart = new List<DisplayParticle>();
             resultFile = result;
             m_cfun = ServiceInterface.HardwareController.GetSemController();
             log = NLog.LogManager.GetCurrentClassLogger();
@@ -122,7 +121,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             return new Point(i_offset_x, i_offset_y);
         }
      
-            public Point ConvertOTSCoordinateToScreenCoord(Point otsleftBottomPoint,double pixelSize, Point currenFldPos,RectangleF wholeImageRec,RectangleF singleImgRec)//
+            public Point ConvertOTSCoordToScreenCoord(Point otsleftBottomPoint,double pixelSize, Point currenFldPos,RectangleF wholeImageRec,RectangleF singleImgRec)//
         {
            
                var OTSPoint=new Point(currenFldPos.X - otsleftBottomPoint.X, currenFldPos.Y - otsleftBottomPoint.Y);
@@ -138,8 +137,8 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             //首先要能确定下来,单个物理坐标的宽和高--------------------------------
             int i_wl_width = 0;
             int i_wl_height = 0;
-
-            RectangleF ls_r = GetPhysicalFieldWidthAndHeight(inPoints,in_width,in_height);
+           
+            RectangleF ls_r = GetPhysicalFieldWidthAndHeight();
             i_wl_width = (int)ls_r.Width;
             i_wl_height = (int)ls_r.Height;
             //-----------------------------------------------------------------------------
@@ -174,12 +173,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             if (i_wl_width != 0) xPixel = (x_max / i_wl_width) * in_width;
             if (i_wl_height != 0) yPixel = (y_max / i_wl_height) * in_height; 
 
-            Rectangle ret_rectangle = new Rectangle(0, 0, 0, 0);
-           
-            if (inPoints.Count > 0)
-            {
-                ret_rectangle = new Rectangle(0, 0, (int)(xPixel), (int)(yPixel));
-            }
+            Rectangle ret_rectangle = new Rectangle(0, 0, (int)(xPixel), (int)(yPixel));
 
         
             return ret_rectangle;
@@ -188,7 +182,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         /// 计算单个field的物理大小 传入field的list,还有测量结果管理类对象,在无法计算出单field的物理大小的情况下,到这里取再计算得出
         /// </summary>
         /// <returns></returns>
-        public RectangleF GetPhysicalFieldWidthAndHeight(List<Point> points,int imageWidth,int imageHeight)
+        public RectangleF GetPhysicalFieldWidthAndHeight()
         {
    
 
@@ -200,20 +194,53 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
             Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
 
+            Dictionary<string, object> msrParams = (Dictionary<string, object>)sampleMembers["MsrParams"];
+
+            Dictionary<string, object> imgParam = (Dictionary<string, object>)msrParams["Members"];
+            Dictionary<string, object> scanParam = (Dictionary<string, object>)imgParam["ImageScanParam"];
+            string resolution = scanParam["ImageResolution"].ToString();
+
+           
+            int width =  Convert.ToInt32(resolution.Split('_')[1].ToString());
+            int height = Convert.ToInt32(resolution.Split('_')[2].ToString());
+            double retioOfHeightWidth =(double) height;
+            retioOfHeightWidth /= width;
             string scanfeldsize = SEMDataMsr["ScanFieldSize"].ToString();
             double d_scanFieldSize_width = Convert.ToDouble(scanfeldsize);
               
                 double d_scanFieldSize_height = 0;
-                if (d_scanFieldSize_width != 0)
-                    d_scanFieldSize_height = (d_scanFieldSize_width / Convert.ToDouble(imageWidth)) * imageHeight;
+            if (d_scanFieldSize_width != 0)
+                d_scanFieldSize_height = d_scanFieldSize_width * retioOfHeightWidth;
 
                 ret_rect.Width = (int)d_scanFieldSize_width;
                 ret_rect.Height = (int)d_scanFieldSize_height;
            
             return ret_rect;
         }
+        public Rectangle GetImageWidthAndHeight()
+        {
+
 
 
+            Rectangle ret_rect = new Rectangle(0, 0, 0, 0);
+
+
+
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
+            //Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+
+            Dictionary<string, object> msrParams= (Dictionary<string, object>)sampleMembers["MsrParams"];
+
+            Dictionary<string, object> imgParam = (Dictionary<string, object>)msrParams["Members"];
+            Dictionary<string, object> scanParam = (Dictionary<string, object>)imgParam["ImageScanParam"];
+            string resolution = scanParam["ImageResolution"].ToString();
+            int width = Convert.ToInt32(resolution.Split('_')[1].ToString());
+            int height = Convert.ToInt32(resolution.Split('_')[2].ToString());
+            ret_rect.Width = width;
+            ret_rect.Height = height;
+            return ret_rect;
+        }
+
 
         #endregion
 
@@ -431,15 +458,15 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         /// <param name="inPoints"></param>
         /// <param name="WhetherPoint"></param>
         /// <returns></returns>
-        public bool WhetherInRange(DisplayParticle Part,/*PointF[] inPoints,*/ Point WhetherPoint)
+        public bool WhetherInRange(DisplayParticle Part, Point WhetherPoint)
         {
-            var rect = Part.Rect;
+            var rect = Part.GetShowRect();
             if ((rect.Left < WhetherPoint.X && WhetherPoint.X < rect.Right) && (rect.Top < WhetherPoint.Y && WhetherPoint.Y < rect.Bottom))
             {
-                var itm = (BaseObject)Part;
-                itm.GPath = Part.GetRegionFromDSegments();
-                PointF[] inPoints = itm.GPath.PathPoints;
-                bool b_inrange = false;
+                var itm = /*(BaseObject)*/Part;
+                //itm.SetGPath(Part.GetRegionFromDSegments());
+                PointF[] inPoints = itm.GetGPath().PathPoints;
+                bool b_inrange;
                 GraphicsPath myGraphicsPath = new GraphicsPath();
                 Region myRegion = new Region();
                 myGraphicsPath.Reset();
@@ -493,11 +520,11 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         /// <returns></returns>
         public  bool WhetherInRange(DisplayParticle Part,/* PointF[] inPoints, */PointF WhetherPoint)
         {
-            var rect = Part.Rect;
+            var rect = Part.GetShowRect();
             if ((rect.Left < WhetherPoint.X && WhetherPoint.X < rect.Right) && (rect.Top < WhetherPoint.Y && WhetherPoint.Y < rect.Bottom))
             {
-                var itm = (BaseObject)Part;
-                PointF[] inPoints = itm.GPath.PathPoints;
+                var itm = Part;
+                PointF[] inPoints = itm.GetGPath().PathPoints;
                 bool b_inrange = false;
                 GraphicsPath myGraphicsPath = new GraphicsPath();
                 Region myRegion = new Region();

+ 25 - 25
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/SortParticleDistribution.cs

@@ -104,7 +104,7 @@ namespace OTSIncAReportGraph
             float f_all_dparticle_widthsum = 0;
             foreach (DisplayParticle dp in this.list_dparticle)
             {
-                f_all_dparticle_widthsum = f_all_dparticle_widthsum + dp.Rect.Width;
+                f_all_dparticle_widthsum = f_all_dparticle_widthsum + dp.GetShowRect().Width;
             }
 
             //然后除以自身的宽度+1,就是所有的行数了
@@ -128,15 +128,15 @@ namespace OTSIncAReportGraph
             foreach (DisplayParticle dp in this.list_dparticle)
             {
                 float ls_y = 0;//用来判断y坐标是否有变化,好用来计算长度
-                foreach (DisplaySegment ds in dp.DSegments)
+                foreach (DisplaySegment ds in dp.GetDSegments())
                 {
-                    if (ds.Rect.Y != ls_y)
+                    if (ds.GetShowRect().Y != ls_y)
                     {
                         //i_ls_height++;
-                        ls_y = ds.Rect.Y;
+                        ls_y = ds.GetShowRect().Y;
 
                         //如果需要考虑笔宽缩放的话,目前这样写,效果还没有出现问题
-                        i_ls_height = i_ls_height + ds.Rect.Height * ds.PenWidthAndHeight;
+                        i_ls_height = i_ls_height + ds.GetShowRect().Height;// * ds.PenWidthAndHeight;
                     }
                     if (i_heightmax < i_ls_height)
                     {
@@ -208,7 +208,7 @@ namespace OTSIncAReportGraph
                 list_dp1.Remove(ls_dp);
 
                 //再分别插入到原先的list,和old_list中
-                ls_dp.Rect = ls_dp.GetRectFromDSegment();
+                //ls_dp.SetRect(ls_dp.GetRectFromDSegment());
                 list_dparticle.Add(ls_dp);
             }
 
@@ -219,7 +219,7 @@ namespace OTSIncAReportGraph
                 {
                     if (ls_dp2.guid == ls_dp.guid)
                     {
-                        ls_dp2.Rect = ls_dp2.GetRectFromDSegment();
+                        //ls_dp2.SetRect(ls_dp2.GetRectFromDSegment());
                         old_list_dparticle.Add(ls_dp2);
                     }
                 }
@@ -304,25 +304,25 @@ namespace OTSIncAReportGraph
             float f_ls_y = this.m_rectf.Y + 3 * in_f_zoom_record;
             foreach (DisplayParticle dp in this.list_dparticle)
             {
-                dp.Rect = dp.GetRectFromDSegment();
+                //dp.SetRect(dp.GetRectFromDSegment());
 
-                if ((f_ls_x + dp.Rect.Width + 6) > this.m_rectf.Width + this.m_rectf.X)
+                if ((f_ls_x + dp.GetShowRect().Width + 6) > this.m_rectf.Width + this.m_rectf.X)
                 {
                     f_ls_x = this.m_rectf.X + 3 * in_f_zoom_record;
                     f_ls_y = f_ls_y + this.GetSortGridHeight() / this.GetDParticleRowNumber() - 5;
                 }
 
-                float f_cz_x = f_ls_x - dp.Rect.X;
-                float f_cz_y = f_ls_y - dp.Rect.Y;
-                foreach (DisplaySegment ds in dp.DSegments)
+                float f_cz_x = f_ls_x - dp.GetShowRect().X;
+                float f_cz_y = f_ls_y - dp.GetShowRect().Y;
+                foreach (DisplaySegment ds in dp.GetDSegments())
                 {
-                    ds.Rect = new RectangleF(ds.Rect.X + f_cz_x, ds.Rect.Y + f_cz_y, ds.Rect.Width, ds.Rect.Height);
+                    ds.SetShowRect(new RectangleF(ds.GetShowRect().X + f_cz_x, ds.GetShowRect().Y + f_cz_y, ds.GetShowRect().Width, ds.GetShowRect().Height));
                 }
-                f_ls_x = f_ls_x + dp.Rect.Width + 3 * in_f_zoom_record;
+                f_ls_x = f_ls_x + dp.GetShowRect().Width + 3 * in_f_zoom_record;
 
-                dp.Rect = dp.GetRectFromDSegment();
-                dp.GPath = dp.GetRegionFromDSegments();
-                dp.SmallRect = dp.GetSmallRectangleFromRect();
+                //dp.SetRect(dp.GetRectFromDSegment());
+                //dp.SetGPath(dp.GetRegionFromDSegments());
+                //dp.SetSmallRect(dp.GetSmallRectangleFromRect());
             }
         }
 
@@ -341,11 +341,11 @@ namespace OTSIncAReportGraph
                 if (dp.GetPaintState() != PaintState.NOPAINT)
                 {
                     //首先确定各多边形的矩形位置
-                    dp.Rect = dp.GetRectFromDSegment();
+                    //dp.SetRect(dp.GetRectFromDSegment());
 
                     //判断是否已经达到了x的边缘,是的话,那么y轴进行增长,判断x轴+颗粒的宽度+6的相当于边框宽度的差值补值,大于grid宽度时
                     //在增长前就判断宽度,防止部份多边形突出到分栏外
-                    if ((f_ls_x + dp.Rect.Width + 6) > this.m_rectf.Width + this.m_rectf.X)
+                    if ((f_ls_x + dp.GetShowRect().Width + 6) > this.m_rectf.Width + this.m_rectf.X)
                     {
                         //还原x到该分栏Grid的左边框+3的位置,并且将y轴定位到下一高度的y轴位置
                         f_ls_x = this.m_rectf.X + 3 ;
@@ -353,18 +353,18 @@ namespace OTSIncAReportGraph
                     }
 
                     //计算出与定位的Grid的差值,然后重新排序线,用分栏Grid-颗粒的外Rect,取到x,y的差值
-                    float f_cz_x = f_ls_x - dp.Rect.X;
-                    float f_cz_y = f_ls_y - dp.Rect.Y;
+                    float f_cz_x = f_ls_x - dp.GetShowRect().X;
+                    float f_cz_y = f_ls_y - dp.GetShowRect().Y;
                     //获取到差值后,再对该多边形下面的所有线进行调整
-                    foreach (DisplaySegment ds in dp.DSegments)
+                    foreach (DisplaySegment ds in dp.GetDSegments())
                     {
-                        ds.Rect = new RectangleF(ds.Rect.X + f_cz_x, ds.Rect.Y + f_cz_y, ds.Rect.Width, ds.Rect.Height);
+                        ds.SetShowRect(new RectangleF(ds.GetShowRect().X + f_cz_x, ds.GetShowRect().Y + f_cz_y, ds.GetShowRect().Width, ds.GetShowRect().Height));
                     }
                     //定位好该多边形后,对x轴进行增长,为下一个多边形定位好位置
-                    f_ls_x = f_ls_x + dp.Rect.Width + 3 ;
+                    f_ls_x = f_ls_x + dp.GetShowRect().Width + 3 ;
 
                     //重新计算sort_ap的
-                    dp.Rect = dp.GetRectFromDSegment();
+                    //dp.SetRect(dp.GetRectFromDSegment());
                     //通过line获取路径边缘
                     //dp.GPath = dp.GetRegionFromDSegments();
                     //重新计算小矩形边框

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

@@ -195,7 +195,7 @@ namespace OTSIncAReportApp
         {
             foreach (var p in im_Control_DrawDistrbutionImageAndBSE.m_list_allDPart)
             {
-                var dp = (p as DisplayParticle);
+                var dp = p;
                 foreach (var p2 in value)
                 {
                     if (dp.objParticleData.FieldId == p2.FieldId)

+ 0 - 56
OTSIncAReportApp/2-CommonFunction/CommonClass/Baseobject.cs

@@ -1,56 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace OTSIncAReportGraph
-{
-    #region 基类,抽像类
-    /// <summary>
-    /// 绘制的基本类,下面的画布,多边形,线都要从这里派生
-    /// </summary>
-    public abstract class BaseObject : ICloneable
-    {
-        //自动生成的ID
-        public abstract Guid guid { get; set; }
-
-        //画布的坐标
-        public abstract RectangleF Rect { get; set; }
-
-        //OTS的坐标
-        public abstract PointF OTSPointF { get; set; }
-
-        //画布是否被选择
-        public abstract bool IsSelect { get; set; }
-
-        //画布是否被拖动
-        public abstract bool IsDragging { get; set; }
-
-        //画布被拖动到的位置
-        public abstract PointF DraggingPoint { get; set; }
-
-        //线的颜色
-        public abstract Color Color { get; set; }
-
-        //画布的背景色
-        public abstract Color BackColor { get; set; }
-
-        //绘制函数
-        public abstract void OnPaint(PaintEventArgs e);
-
-        //多边形路径
-        public abstract GraphicsPath GPath { get; set; }
-
-
-        //克隆
-        public virtual object Clone()
-        {
-            return null;
-        }
-    }
-    #endregion
-}

+ 66 - 158
OTSIncAReportApp/2-CommonFunction/CommonClass/DisplayField.cs

@@ -11,29 +11,22 @@ using System.Windows.Forms;
 
 namespace OTSIncAReportGraph
 {
-    /// <summary>
-    /// 包含DParticle类的field类,目前只用于绘制背景色,按理说应该有更多的作用,比如做多线程分式运算
-    /// </summary>
-    public class DisplayField : BaseObject
+
+    public class DisplayField
     {
         Guid  m_id;
-        string m_tagid;
+       
         string m_fieldid;
         bool m_IsDragging;
-        Color m_backcolor;
+     
         List<DisplayParticle> m_list_dparticle;
-
-        List<DisplayParticle> m_list_Useparticle;
+        private float m_currentZoom=1;
+ 
         PointF m_ots_point;  //按底层设计结构,底层返回的物理坐标位置及大小,OTS坐标大小
-        RectangleF m_pix_rect; //与底层返回物理坐标及位置大小对应转换成,pixel像素分率下的坐标位置大小
-        RectangleF m_show_rect;//最后换算到在显示器上显示的坐标位置大小
-        RectangleF m_current_rect;//当前field在显示器上显示的坐标位置大小
+ 
+        RectangleF m_Rect;//最后换算到在显示器上显示的坐标位置大小    
         PointF m_dragingpoint;//鼠标拖动的位置
-        //private string m_GBContent;
-        private PointF m_OTSPointF;
-        private bool m_IsSelect;
-        private Color m_color;
-        private GraphicsPath m_GPath;
+ 
         private Bitmap m_originalImage;
         const int INVALIDPARTICLE= -1;
         /// <summary>
@@ -43,14 +36,12 @@ namespace OTSIncAReportGraph
         {
          
             m_list_dparticle = new List<DisplayParticle>();
-            m_list_Useparticle = new List<DisplayParticle>();
+       
             m_id = System.Guid.NewGuid();
             Point thisfield_point = new Point() { X = fld.FieldPosX, Y = fld.FieldPosY };
            
             FieldID = fld.FieldID.ToString();
-            Show_Rect = new Rectangle(screenPos, new Size(fldwidth, fldheight));
-
-            Current_Rect = new Rectangle(screenPos, new Size(fldwidth, fldheight));
+            SetShow_Rect(new Rectangle(screenPos, new Size(fldwidth, fldheight)));
 
             OTSCoordinatePos = new PointF(thisfield_point.X, thisfield_point.Y);
             //先获取该Field中的所有Particle
@@ -70,96 +61,11 @@ namespace OTSIncAReportGraph
                     continue;
                 }
                 //创建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的大小
-                    DisplaySegment ds = new DisplaySegment();
-                    ds.Rect = new Rectangle(seg.Start + screenPos.X,
-                     
-                        seg.Height + screenPos.Y,
-                        seg.Length,
-                        1);
-
-
-                    ds.Color = dp.Color;//将线的颜色对应到颗粒的颜色
-                    #endregion
-
-                    #region //这里是在Field中,抠取出原BSE图像到DSegment中--------------------------------
-                  
-                    //合成图像完成,开始抠取像素-----------------------------------------------------------------
-                    int f_length = seg.Length;
-                 
-                    for (int m = 0; m < f_length; m++)
-                    {
-                        //这里实现一下代码保护
-                        int lsjs_x = seg.Start + m;
-                     
-                        int lsjs_y = seg.Height;
-
-                    
-
-
-                        var pixelColor = m_originalImage.GetPixel(lsjs_x, lsjs_y);
-
-
-
-                        try
-                        {
-                           
-                            dpImage.SetPixel(lsjs_x, lsjs_y, pixelColor);//ls_list_colors[m]
-                        }
-                        catch (Exception ex)
-                        {
-                            NLog.LogManager.GetCurrentClassLogger().Error(ex.Message.ToString());
-                        }
-                        
-                    }
-                  
-                    #endregion //------------------------------------------------------------------------------
+                DisplayParticle dp = new DisplayParticle(particle,screenPos,m_originalImage,dpImage);
 
-                    list_dsegment.Add(ds);
-                   
-                }
-
-          
-                dp.SetPaintState(PaintState.PAINT);
-
-                dp.DSegments = list_dsegment;
-
-
-                dp.Rect = dp.GetRectFromDSegment();
-                dp.GPath = dp.GetRegionFromDSegments();
-                dp.SmallRect = dp.GetSmallRectangleFromRect();
-                var currentRect = new RectangleF(dp.Rect.X - screenPos.X, dp.Rect.Y - screenPos.Y, dp.Rect.Width, dp.Rect.Height);
-
-                try 
-                {
-                    var dpImg = dpImage.Clone(currentRect, dpImage.PixelFormat);
-                    dp.SetImage(dpImg);
-                } catch (Exception ex)
-                {
-                    NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
-                }
-             
-               
                
                 m_list_dparticle.Add(dp);
-                if (dp.XRayId > -1)
-                {
-                    m_list_Useparticle.Add(dp);
-                }
+          
 
             }
 
@@ -174,31 +80,58 @@ namespace OTSIncAReportGraph
             m_list_dparticle = in_list_dparticle;
         }
 
+        public void Zoom(float zoomDelta , PointF refPoint)
+        {
+            
+            m_Rect.Width += m_Rect.Width/ m_currentZoom * zoomDelta;
+            m_Rect.Height += m_Rect.Height/ m_currentZoom * zoomDelta;
+            //锚点缩放补差值计算,得出差值
+            float xShiftOld = m_Rect.X - refPoint.X;
+            float yShiftOld = m_Rect.Y - refPoint.Y;
+            float xShift = m_Rect.X - refPoint.X + xShiftOld/ m_currentZoom * zoomDelta;
+            float yShift = m_Rect.Y - refPoint.Y + yShiftOld/ m_currentZoom * zoomDelta;
 
 
-        public override Guid guid { get => m_id; set => m_id = value; }
+           
+            m_Rect.X = refPoint.X + xShift;
+            m_Rect.Y = refPoint.Y + yShift;
 
-        /// <summary>
-        /// 记录与底层对应的TagID
-        /// </summary>
-        public string TagID
+            m_currentZoom += zoomDelta;
+
+        }
+        public void DraggingMove(PointF mousePoint)
         {
-            get { return m_tagid; }
-            set { m_tagid = value; }
+            m_Rect = new RectangleF(
+                           m_Rect.Left + Convert.ToSingle((mousePoint.X - DraggingPoint.X)),
+                          m_Rect.Top + Convert.ToSingle((mousePoint.Y - DraggingPoint.Y)),
+                          m_Rect.Width,
+                           m_Rect.Height);
+            DraggingPoint = mousePoint;
         }
+        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.Width,
+                           m_Rect.Height);
+           
+        }
+        public  Guid guid { get => m_id; set => m_id = value; }
+
         /// <summary>
         /// 是否被拖动标识
         /// </summary>
 
 
-        public override bool IsDragging { get => m_IsDragging; set => m_IsDragging = value; }
+        public  bool IsDragging { get => m_IsDragging; set => m_IsDragging = value; }
 
         /// <summary>
         /// 被拖动到的位置坐标
         /// </summary>
 
 
-        public override PointF DraggingPoint { get => m_dragingpoint; set => m_dragingpoint = value; }
+        public  PointF DraggingPoint { get => m_dragingpoint; set => m_dragingpoint = value; }
 
         /// <summary>
         /// 与底层对应的ID,这里叫成FieldID
@@ -209,7 +142,7 @@ namespace OTSIncAReportGraph
             set { m_fieldid = value; }
         }
 
-        public override Color BackColor { get => m_backcolor; set => m_backcolor = value; }
+    
 
         /// <summary>
         /// 包含的Particle列表
@@ -219,11 +152,7 @@ namespace OTSIncAReportGraph
             get { return m_list_dparticle; }
             set { m_list_dparticle = value; }
         }
-        public List<DisplayParticle> List_Useparticle
-        {
-            get { return m_list_Useparticle; }
-            set { m_list_Useparticle = value; }
-        }
+       
         /// <summary>
         /// 该Field的OTS坐标及大小
         /// </summary>
@@ -233,61 +162,40 @@ namespace OTSIncAReportGraph
             set { m_ots_point = value; }
         }
 
-        /// <summary>
-        /// 该Field物理坐标大小转换出,对应的像素坐标及大小
-        /// </summary>
-        public RectangleF Pix_Rect
-        {
-            get { return m_pix_rect; }
-            set { m_pix_rect = value; }
-        }
 
         /// <summary>
         /// 该Field最后在屏幕上显示的坐标及大小
         /// </summary>
-        public RectangleF Show_Rect
-        {
-            get { return m_show_rect; }
-            set { m_show_rect = value; }
-        }
+        public  RectangleF GetShowRect()
+        { return m_Rect; }
 
         /// <summary>
-        /// Field当前在屏幕上显示的坐标及大小
+        /// 该Field最后在屏幕上显示的坐标及大小
         /// </summary>
-        public RectangleF Current_Rect
-        {
-            get { return m_current_rect; }
-            set { m_current_rect = value; }
-        }
+        public void SetShow_Rect(RectangleF value)
+        { m_Rect = value; }
+
+
+
+
+
 
-        public override RectangleF Rect { get => m_show_rect; set => m_show_rect = value; }
-        public override PointF OTSPointF { get => m_OTSPointF; set => m_OTSPointF = value; }
-        public override bool IsSelect { get => m_IsSelect; set => m_IsSelect = value; }
-        public override Color Color { get => m_color; set => m_color = value; }
-        public override GraphicsPath GPath { get => m_GPath; set => m_GPath = value; }
         public Bitmap OriginalImage { get => m_originalImage; set => m_originalImage = value; }
 
-        public override void OnPaint(PaintEventArgs e)
+        public  void OnPaint(PaintEventArgs e)
         {
 
             //开始向下传递并进行绘制
-            foreach (BaseObject item in m_list_dparticle)
+            foreach (DisplayParticle dp in m_list_dparticle)
             {
-                DisplayParticle dp = (DisplayParticle)item;
+               
                 if (dp.IsDeleted==false)
                 {
                     if (dp.GetPaintState() == PaintState.PAINT)
                     {
-                        item.OnPaint(e);
+                        dp.OnPaint(e);
                     }
-                    //获取矩形的rectangle
-                    //dp.Rect = dp.GetRectFromDSegment();
-
-                    //通过line获取路径边缘
-                    //dp.GPath = dp.GetRegionFromDSegments();
-
-                    //重新计算小矩形边框
-                    //dp.SmallRect = dp.GetSmallRectangleFromRect();
+                   
 
                 }
             }

+ 294 - 195
OTSIncAReportApp/2-CommonFunction/CommonClass/DisplayParticle.cs

@@ -37,7 +37,7 @@ namespace OTSIncAReportGraph
     /// </summary>
     public enum ParticleShowXray
     {
-        SELECTANDDISPLAYXRAY = 0,
+        DISPLAYXRAY = 0,
         NODISPLAY = 1,
     }
 
@@ -53,14 +53,14 @@ namespace OTSIncAReportGraph
     /// <summary>
     /// 颗粒类
     /// </summary>
-    public class DisplayParticle : BaseObject, ICloneable, IComparable<DisplayParticle>
+    public class DisplayParticle :  ICloneable
     {
-        private const float m_zoom_displaymultiplier = 0.5f;
+        private const float m_zoom_displayThreshold = 0.1f;
         public Particle objParticleData;
         private Guid m_id;
         private RectangleF m_rect;
         private PointF m_OTSPointF;
-        private RectangleF m_small_rect;
+        private RectangleF m_smallRect;
         private bool m_isSelected_smallrect;
         private bool m_showSmallx;
         private bool m_isSelected;
@@ -71,11 +71,11 @@ namespace OTSIncAReportGraph
         private bool m_isdragging;
         private PointF m_dragingpoint;
         private Color m_color;
-        private Color m_backcolor;
+    
         private GraphicsPath m_gpath;
         private List<DisplaySegment> m_listdsegment = new List<DisplaySegment>();
         private DisplayState m_displayState;
-
+        private SegmentShowMode show_mode = SegmentShowMode.DRAWPOINT;//绘线,绘点,默认绘点,意思为默认显示BSE原图像
         private Image m_image;
 
         private string m_sort_type = "从大到小";
@@ -84,7 +84,7 @@ namespace OTSIncAReportGraph
         private string m_str_klzl = "颗粒种类";
         private string m_str_klfl = "颗粒分类";
 
- 
+        private float m_CurrentZoomNum = 1;
 
         public int TypeId 
         {
@@ -132,12 +132,84 @@ namespace OTSIncAReportGraph
             m_id = System.Guid.NewGuid();
         }
 
-        public DisplayParticle(Particle part)
+        public DisplayParticle(Particle particle,Point screenPos,Bitmap originalFieldImage,Bitmap fieldParticleImage)
         {
+         
             m_id = System.Guid.NewGuid();
-            objParticleData = part;
-            this.Color = GetColorBySTDTypeIDForBSEAndSorImage(part.TypeColor, part.TypeId);
+            objParticleData = particle;
+            this.Color = DrawFunction.GetColorBySTDTypeIDForBSEAndSorImage(particle.TypeColor, particle.TypeId);
+
+
+            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的大小
+                DisplaySegment ds = new DisplaySegment();
+                ds.SetShowRect(new Rectangle(seg.Start + screenPos.X,
+
+                    seg.Height + screenPos.Y,
+                    seg.Length,
+                    1));
+
+
+                ds.Color = this.Color;//将线的颜色对应到颗粒的颜色
+                #endregion
+
+                #region //这里是在Field中,抠取出原BSE图像到DSegment中--------------------------------
+
+                //合成图像完成,开始抠取像素-----------------------------------------------------------------
+                int f_length = seg.Length;
+
+                for (int m = 0; m < f_length; m++)
+                {
+                    //这里实现一下代码保护
+                    int lsjs_x = seg.Start + m;
+
+                    int lsjs_y = seg.Height;
+
+
+
+
+                    var pixelColor = originalFieldImage.GetPixel(lsjs_x, lsjs_y);
+
+
+
+                   
+
+                        fieldParticleImage.SetPixel(lsjs_x, lsjs_y, pixelColor);//ls_list_colors[m]
+                    
+
+                }
+
+                #endregion //------------------------------------------------------------------------------
+
+                list_dsegment.Add(ds);
+
+            }
+
+
+           SetPaintState(PaintState.PAINT);
+
+            SetDSegments(list_dsegment);
+
+
+            var currentRect = new RectangleF(m_rect.X - screenPos.X, m_rect.Y - screenPos.Y, m_rect.Width, m_rect.Height);
+
+            
+                var dpImg = fieldParticleImage.Clone(currentRect, fieldParticleImage.PixelFormat);
+                SetImage(dpImg);
            
+
+
+
         }
 
         public DisplayParticle(List<DisplaySegment> in_list_segment, DisplayParticle in_particle)
@@ -157,132 +229,26 @@ namespace OTSIncAReportGraph
             {
                 m_listdsegment.Add(e.Clone() as DisplaySegment);
             }
+
+            m_rect = GetRectFromDSegment();
+            m_smallRect = GetSmallRectangleFromRect();
+            m_gpath = GetRegionFromDSegments();
         }
 
         /// <summary>
-        /// [目前也不使用该方法了,因为该方法每次排序都有不同的结果]多边形排序,按传入的sort_type的排序类型行排序,但需要两个list做一致性排序
+        /// 设置显示的方式,可以用,绘线显示查看标准库颜色的,也可以用绘点,查看BSE原图颗粒图色的
         /// </summary>
-        /// <param name="in_ap"></param>
-        /// <returns></returns>
-        public int CompareTo(DisplayParticle in_particle)
+        public SegmentShowMode ShowMode
         {
-            int r_b = 0;//排序返回值
-            switch (m_sort_type)
-            {
-                case "从大到小":
-                    r_b = in_particle.m_f_size.CompareTo(this.m_f_size);
-                    break;
-
-                case "从小到大":
-                    //与上面的从大到小正好相反即可
-                    r_b = in_particle.m_f_size.CompareTo(this.m_f_size);
-                    if (r_b == 1)
-                        r_b = -1;
-                    else
-                        r_b = 1;
-                    break;
-                default:
-                    break;
-            }
-
-            return r_b;
-        }
-        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;
+            get { return show_mode; }
+            set { show_mode = value; }
         }
 
         /// <summary>
         /// 克隆方法
         /// </summary>
         /// <returns></returns>
-        public override object Clone()
+        public  object Clone()
         {
             return new DisplayParticle(this.m_listdsegment, this);
         }
@@ -295,7 +261,7 @@ namespace OTSIncAReportGraph
         /// <summary>
         /// ID
         /// </summary>
-        public override Guid guid
+        public  Guid guid
         {
             get { return m_id; }
             set { m_id = value; }
@@ -304,16 +270,21 @@ namespace OTSIncAReportGraph
         /// <summary>
         /// 颗粒的外边框大小
         /// </summary>
-        public override RectangleF Rect
+        public  RectangleF GetShowRect()
         {
-            get { return m_rect; }
-            set { m_rect = value; }
+           
+               m_rect= this.GetRectFromDSegment();
+           
+            return m_rect; 
+        
         }
 
+  
+
         /// <summary>
         /// OTSPointF
         /// </summary>
-        public override PointF OTSPointF
+        public  PointF OTSPointF
         {
             get { return m_OTSPointF; }
             set { m_OTSPointF = value; }
@@ -322,16 +293,18 @@ namespace OTSIncAReportGraph
         /// <summary>
         /// 颗粒里+号位置的外边框大小
         /// </summary>
-        public RectangleF SmallRect
+        public RectangleF GetSmallRect()
         {
-            get { return m_small_rect; }
-            set { m_small_rect = value; }
+         
+                m_smallRect=this.GetSmallRectangleFromRect();
+
+          
+            return m_smallRect;
+        
         }
 
-        /// <summary>
-        /// 颗粒是否被选择
-        /// </summary>
-        public override bool IsSelect
+ 
+        public  bool IsSelect
         {
             get { return m_isSelected; }
             set { m_isSelected = value; }
@@ -356,7 +329,28 @@ namespace OTSIncAReportGraph
         /// 该颗粒是否被设置成,选中状态
         /// </summary>
         public void SetPaintState(PaintState value)
-        { m_paintState = value; }
+        {
+            if (value == PaintState.PAINT)
+            {
+                if (m_CurrentZoomNum >= m_zoom_displayThreshold)
+                {
+                    m_paintState = PaintState.PAINT;
+                }
+                else
+                {
+                    m_paintState = PaintState.CONCISEPAINT;
+                }
+
+            }
+            else 
+            {
+                m_paintState = value;
+            }
+           
+          
+        
+        
+        }
 
         /// <summary>
         /// 是否对该颗粒选定显示X-Ray能谱图
@@ -389,7 +383,7 @@ namespace OTSIncAReportGraph
         /// <summary>
         /// 是否在被拖动
         /// </summary>
-        public override bool IsDragging
+        public  bool IsDragging
         {
             get { return m_isdragging; }
             set { m_isdragging = value; }
@@ -398,58 +392,162 @@ namespace OTSIncAReportGraph
         /// <summary>
         /// 被拖动到的位置坐标
         /// </summary>
-        public override PointF DraggingPoint
+        public  PointF DraggingPoint
         {
             get { return m_dragingpoint; }
-            set { m_dragingpoint = value; }
+            set {
+                
+                m_dragingpoint = value;
+                
+            
+            }
         }
 
         /// <summary>
         /// 线的颜色
         /// </summary>
-        public override Color Color
+        public  Color Color
         {
             get { return m_color; }
             set { m_color = value; }
         }
 
+
         /// <summary>
-        /// 背景色
+        /// 多边形的图形路径边缘
         /// </summary>
-        public override Color BackColor
+        public  GraphicsPath GetGPath()
         {
-            get { return m_backcolor; }
-            set { m_backcolor = value; }
+        
+                m_gpath = this.GetRegionFromDSegments();
+
+            return m_gpath; 
+        
         }
 
+ 
+
         /// <summary>
-        /// 多边形的图形路径边缘
+        /// 里面包含的多个线的集合
         /// </summary>
-        public override GraphicsPath GPath
-        {
-            get { return m_gpath; }
-            set { m_gpath = value; }
-        }
+        public List<DisplaySegment> GetDSegments()
+        { return m_listdsegment; }
+
+   
 
         /// <summary>
         /// 里面包含的多个线的集合
         /// </summary>
-        public List<DisplaySegment> DSegments
+        public void SetDSegments(List<DisplaySegment> value)
+        { 
+            m_listdsegment = value;
+
+            m_rect=GetRectFromDSegment();
+            m_gpath=GetRegionFromDSegments();
+            m_smallRect=GetSmallRectangleFromRect();
+
+        }
+
+    
+        public void Zoom(float zoomDelta,PointF refPoint)
         {
-            get { return m_listdsegment; }
-            set { m_listdsegment = value; }
+
+          
+
+            for (int y = 0; y < this.GetDSegments().Count(); y++)
+            {
+                //这里重新设置每条线的高度,和x,y坐标
+                DisplaySegment ds = this.GetDSegments()[y];             
+
+                var rec = ds.GetShowRect();
+            
+
+                rec.Width = (float)(rec.Width + Convert.ToDouble(rec.Width/m_CurrentZoomNum * zoomDelta));
+               rec.Height = (float)(rec.Height + Convert.ToDouble(rec.Height/m_CurrentZoomNum * zoomDelta));
+
+              
+                //锚点缩放补差值计算,得出差值
+                float xShiftOld = rec.X - refPoint.X;
+                float yShiftOld = rec.Y - refPoint.Y;
+                float xShift = rec.X - refPoint.X + xShiftOld/m_CurrentZoomNum * zoomDelta;
+                float yShift = rec.Y - refPoint.Y + yShiftOld/m_CurrentZoomNum * zoomDelta;
+
+
+                //对背景矩形与所有的segment进行修补差值
+                rec.X = refPoint.X + xShift;
+                rec.Y = refPoint.Y + yShift; 
+
+
+
+                ds.SetShowRect(rec);
+
+
+            }
+         
+            m_rect=GetRectFromDSegment();
+
+
+
+            //重新计算小矩形边框
+            m_smallRect=GetSmallRectangleFromRect();
+            //设置缩放到多少倍时进行显示
+            if (m_CurrentZoomNum >= m_zoom_displayThreshold)
+            {
+                m_paintState = PaintState.PAINT;
+            }
+            else
+            {
+                m_paintState = PaintState.CONCISEPAINT;
+            }
+
+
+            m_CurrentZoomNum += zoomDelta;
+
+
         }
 
-        /// <summary>
-        /// 控制多边形在进行缩放到多少倍时进行显示
-        /// </summary>
-        public float Zoom_DisPlayThreshold
+        public void DraggingMove(PointF mousePoint)
         {
-            get { return m_zoom_displaymultiplier; }
-           
+            foreach (DisplaySegment ds in this.GetDSegments())
+            {
+                var rec = ds.GetShowRect();
+                rec.X = ds.GetShowRect().X + mousePoint.X - this.DraggingPoint.X; //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
+                rec.Y = ds.GetShowRect().Y + mousePoint.Y - this.DraggingPoint.Y;
+                ds.SetShowRect(rec);
+               
+            }
+            this.DraggingPoint = mousePoint;
+
+            //获取矩形的rectangle
+            m_rect = GetRectFromDSegment();
+
+
+            ////重新计算小矩形边框
+            m_smallRect = GetSmallRectangleFromRect();
+            
+
+
         }
+        public void Move(SizeF xyShift)
+        {
+            foreach (DisplaySegment ds in this.GetDSegments())
+            {
+                var rec = ds.GetShowRect();
+                rec.X = ds.GetShowRect().X -xyShift.Width; //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
+                rec.Y = ds.GetShowRect().Y - xyShift.Height ;
+                ds.SetShowRect(rec);
+
+            }
+
+
+            //获取矩形的rectangle
+            m_rect = GetRectFromDSegment();
+            //重新计算小矩形边框
+            m_smallRect = GetSmallRectangleFromRect();
 
 
+        }
+
 
         /// <summary>
         /// 设置排序的类型
@@ -547,7 +645,7 @@ namespace OTSIncAReportGraph
         /// 绘制函数
         /// </summary>
         /// <param name="e"></param>
-        public override void OnPaint(PaintEventArgs e)
+        public  void OnPaint(PaintEventArgs e)
         {
             Graphics g = e.Graphics;
             //绘制鼠标移动到颗粒上时的边框,需要判断当前鼠标在颗粒上,及颗粒的操作为正常显示
@@ -555,7 +653,7 @@ namespace OTSIncAReportGraph
             {
                 //如果有鼠标在该矩形上,那么进行描边
                 ControlPaint.DrawBorder(g,
-                                    Rectangle.Round(this.Rect),
+                                    Rectangle.Round(this.GetShowRect()),
                                     Color.Lime,
                                     1,
                                     ButtonBorderStyle.Solid,
@@ -575,18 +673,18 @@ namespace OTSIncAReportGraph
                 if (m_listdsegment.Count > 0)
                 {
 
-                    DisplaySegment ds = m_listdsegment[0];
-                    if (ds.ShowMode == SegmentShowMode.DRAWPOINT)
+                    //DisplaySegment ds = m_listdsegment[0];
+                    if (this.ShowMode == SegmentShowMode.DRAWPOINT)
                     {
-                        try
-                        {
+                        //try
+                        //{
                             e.Graphics.DrawImage(m_image, m_rect);
 
-                        }
-                        catch (Exception ex)
-                        {
-                            NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
-                        }
+                        //}
+                        //catch (Exception ex)
+                        //{
+                        //    NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
+                        //}
 
 
                     }
@@ -610,14 +708,14 @@ namespace OTSIncAReportGraph
             }
             if (GetPaintState() == PaintState.CONCISEPAINT)
             {
-                g.DrawString("+", new Font("黑体", 6), new SolidBrush(Color.DarkSlateBlue), new PointF(m_small_rect.X, m_small_rect.Y));
+                g.DrawString("+", new Font("黑体", 6), new SolidBrush(Color.DarkSlateBlue), new PointF(m_smallRect.X, m_smallRect.Y));
             }
 
             if (m_isSelected)
             {
                 //如果説该矩形被选择上了的话,那么也显示边框
                 ControlPaint.DrawBorder(g,
-                                    Rectangle.Round(this.Rect),
+                                    Rectangle.Round(this.GetShowRect()),
                                     Color.Blue,
                                     1,
                                     ButtonBorderStyle.Solid,
@@ -632,11 +730,11 @@ namespace OTSIncAReportGraph
                                     ButtonBorderStyle.Solid);
             }
             
-            if (ParticleShowXray.SELECTANDDISPLAYXRAY == m_operator_showxray && PaintState.NOPAINT != GetPaintState())
+            if (ParticleShowXray.DISPLAYXRAY == m_operator_showxray && PaintState.NOPAINT != GetPaintState())
             {
                 //当鼠标在该颗粒上进行点击,则对颗粒状态更改为选定状态,用来显示X-ray能谱表
                 ControlPaint.DrawBorder(g,
-                                    Rectangle.Round(this.Rect),
+                                    Rectangle.Round(this.GetShowRect()),
                                     Color.DeepSkyBlue,
                                     1,
                                     ButtonBorderStyle.Solid,
@@ -658,7 +756,7 @@ namespace OTSIncAReportGraph
         /// 从Line中获取矩形的边缘闭合路径
         /// </summary>
         /// <returns></returns>
-        public GraphicsPath GetRegionFromDSegments()
+        private GraphicsPath GetRegionFromDSegments()
         {
             GraphicsPath gpath = new GraphicsPath();
 
@@ -668,8 +766,8 @@ namespace OTSIncAReportGraph
             //从y循环,这里假设y轴会按lines集合来计算,然后将所有的左x,和右x取出排成两个队列
             foreach (DisplaySegment ds in this.m_listdsegment)
             {
-                list_leftpointf.Add(new PointF(ds.Rect.X, ds.Rect.Y));
-                list_rightpointf.Add(new PointF(ds.Rect.X + ds.Rect.Width, ds.Rect.Y));
+                list_leftpointf.Add(new PointF(ds.GetShowRect().X, ds.GetShowRect().Y));
+                list_rightpointf.Add(new PointF(ds.GetShowRect().X + ds.GetShowRect().Width, ds.GetShowRect().Y));
             }
 
             PointF[] lsp = new PointF[list_leftpointf.Count + list_rightpointf.Count];
@@ -695,7 +793,7 @@ namespace OTSIncAReportGraph
             else
             {
                 //有时居然有颗粒,有没有segment的时候,防止报错
-                if (this.DSegments.Count == 0)
+                if (this.GetDSegments().Count == 0)
                 {
                     lsp = new PointF[3] { new PointF(0, 0), new PointF(0, 0), new PointF(0, 0) };
                     gpath.AddPolygon(lsp);
@@ -728,8 +826,9 @@ namespace OTSIncAReportGraph
         /// 从已经确定的外边框来计算出里面的+号小框位置
         /// </summary>
         /// <returns></returns>
-        public RectangleF GetSmallRectangleFromRect()
+        private RectangleF GetSmallRectangleFromRect()
         {
+        
             RectangleF rect = new RectangleF();
 
             //用外边框的坐标,除2获得中心点,然后再分别+,- 4
@@ -755,7 +854,7 @@ namespace OTSIncAReportGraph
 
             foreach (DisplaySegment ls_ds in this.m_listdsegment)
             {
-                f_size_sum = f_size_sum + ls_ds.Rect.Width;
+                f_size_sum = f_size_sum + ls_ds.GetShowRect().Width;
             }
             return f_size_sum;
         }
@@ -764,7 +863,7 @@ namespace OTSIncAReportGraph
         /// 从基本线中获取整个矩形的Rectangle
         /// </summary>
         /// <returns></returns>
-        public RectangleF GetRectFromDSegment()
+        private RectangleF GetRectFromDSegment()
         {
             RectangleF rect = new RectangleF();
 
@@ -774,31 +873,31 @@ namespace OTSIncAReportGraph
             //先从自身中初始化x,y,和宽,高
             if (this.m_listdsegment.Count > 0)
             {
-                x1 = this.m_listdsegment[0].Rect.X;
-                y1 = this.m_listdsegment[0].Rect.Y;
-                i_width = x1 + this.m_listdsegment[0].Rect.Width;
-                i_height = this.m_listdsegment[0].Rect.Y;
+                x1 = this.m_listdsegment[0].GetShowRect().X;
+                y1 = this.m_listdsegment[0].GetShowRect().Y;
+                i_width = x1 + this.m_listdsegment[0].GetShowRect().Width;
+                i_height = this.m_listdsegment[0].GetShowRect().Y;
             }
 
             foreach (DisplaySegment ds in this.m_listdsegment)
             {
                 //分别取出,最小的x,y,
-                if (ds.Rect.X < x1)
+                if (ds.GetShowRect().X < x1)
                 {
-                    x1 = ds.Rect.X;
+                    x1 = ds.GetShowRect().X;
                 }
-                if (ds.Rect.Y < y1)
+                if (ds.GetShowRect().Y < y1)
                 {
-                    y1 = ds.Rect.Y;
+                    y1 = ds.GetShowRect().Y;
                 }
                 //最大的x,y
-                if (ds.Rect.X + ds.Rect.Width > i_width)
+                if (ds.GetShowRect().X + ds.GetShowRect().Width > i_width)
                 {
-                    i_width = ds.Rect.X + ds.Rect.Width;
+                    i_width = ds.GetShowRect().X + ds.GetShowRect().Width;
                 }
-                if (ds.Rect.Y > i_height)
+                if (ds.GetShowRect().Y > i_height)
                 {
-                    i_height = ds.Rect.Y;
+                    i_height = ds.GetShowRect().Y;
                 }
             }
 

+ 36 - 125
OTSIncAReportApp/2-CommonFunction/CommonClass/DisplaySegment.cs

@@ -1,11 +1,8 @@
-using OTSCommon.Model;
+
 using System;
-using System.Collections.Generic;
+
 using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+
 using System.Windows.Forms;
 
 namespace OTSIncAReportGraph
@@ -13,169 +10,83 @@ namespace OTSIncAReportGraph
     /// <summary>
     /// 基本线类
     /// </summary>
-    public class DisplaySegment : BaseObject, ICloneable
+    public class DisplaySegment :  ICloneable
     {
-        private Guid m_id;
-        private RectangleF m_region;
-        private PointF m_OTSPointF;
-        private bool m_isselect;
-        private bool m_isdragging;
-        private PointF m_dragingpoint;
+    
+        private RectangleF m_rect;
+  
+    
+     
         private Color m_color;
-        private Color m_backcolor;
-        private GraphicsPath m_gpath;
+    
         private float m_PenWidthAndHeight = 1;
-        private SegmentShowMode show_mode = SegmentShowMode.DRAWPOINT;//绘线,绘点,默认绘点,意思为默认显示BSE原图像
-        private List<Color> m_list_colors;
+      
+     
 
         /// <summary>
         /// 克隆基本线
         /// </summary>
         /// <returns></returns>
-        public override object Clone()
+        public object Clone()
         {
-            return MemberwiseClone();
+            var newSeg= new DisplaySegment();
+            newSeg.m_rect = this.m_rect;
+            newSeg.Color = this.Color;
+       
+            return newSeg;
+
         }
 
         public DisplaySegment()
         {
-            m_id = System.Guid.NewGuid();
+           
         }
 
-        /// <summary>
-        /// ID
-        /// </summary>
-        public override Guid guid
-        {
-            get { return m_id; }
-            set { m_id = value; }
-        }
+   
 
         /// <summary>
         /// 画面的大小
         /// </summary>
-        public override RectangleF Rect
-        {
-            get { return m_region; }
-            set { m_region = value; }
-        }
-        /// <summary>
-        /// OTSField
-        /// </summary>
-        public override PointF OTSPointF
-        {
-            get { return m_OTSPointF; }
-            set { m_OTSPointF = value; }
-        }
-        /// <summary>
-        /// 画布是否被选择
-        /// </summary>
-        public override bool IsSelect
-        {
-            get { return m_isselect; }
-            set { m_isselect = value; }
-        }
+        public  RectangleF GetShowRect()
+        { return m_rect; }
 
         /// <summary>
-        /// 是否在被拖动
+        /// 画面的大小
         /// </summary>
-        public override bool IsDragging
-        {
-            get { return m_isdragging; }
-            set { m_isdragging = value; }
-        }
+        public  void SetShowRect(RectangleF value)
+        { m_rect = value; }
+      
+  
 
-        /// <summary>
-        /// 被拖动到的位置坐标
-        /// </summary>
-        public override PointF DraggingPoint
-        {
-            get { return m_dragingpoint; }
-            set { m_dragingpoint = value; }
-        }
 
+   
         /// <summary>
         /// 线的颜色
         /// </summary>
-        public override Color Color
+        public  Color Color
         {
             get { return m_color; }
             set { m_color = value; }
         }
 
-        /// <summary>
-        /// 背景色
-        /// </summary>
-        public override Color BackColor
-        {
-            get { return m_backcolor; }
-            set { m_backcolor = value; }
-        }
 
-        /// <summary>
-        /// 多边形的图形路径边缘
-        /// </summary>
-        public override GraphicsPath GPath
-        {
-            get { return m_gpath; }
-            set { m_gpath = value; }
-        }
 
-        /// <summary>
-        /// 设置画笔的笔宽度
-        /// </summary>
-        public float PenWidthAndHeight
-        {
-            get { return m_PenWidthAndHeight; }
-            set { m_PenWidthAndHeight = value; }
-        }
+     
 
-        /// <summary>
-        /// 设置显示的方式,可以用,绘线显示查看标准库颜色的,也可以用绘点,查看BSE原图颗粒图色的
-        /// </summary>
-        public SegmentShowMode ShowMode
-        {
-            get { return show_mode; }
-            set { show_mode = value; }
-        }
 
-        /// <summary>
-        /// 保存BSE标准库文件的颗粒点的颜色信息
-        /// </summary>
-        public List<Color> List_Colors
-        {
-            get { return m_list_colors; }
-            set { m_list_colors = value; }
-        }
 
         /// <summary>
         /// 绘制函数
         /// </summary>
         /// <param name="e"></param>
-        public override void OnPaint(PaintEventArgs e)
+        public  void OnPaint(PaintEventArgs e)
         {
           
-            //两种绘制模式的选择,绘线还是缓点
-            if (show_mode == SegmentShowMode.DRAWLINE)
-            {
-                //表示显示的是带有标准库的图像
+         
                 Pen p = new Pen(m_color, m_PenWidthAndHeight + 1f);//这里加1f的宽度后,用线组成多边形不会分散,效果正常,原因不知,但目前没有遇到问题
-                e.Graphics.DrawLine(p, Rect.X, Rect.Y, Rect.X + Rect.Width, Rect.Y);
-            }
-            //else if (show_mode == SegmentShowMode.DRAWPOINT)
-            //{
-            //    //根据color的序列,显示绘制的原像素的图像。
-            //    for (int i = 0; i < m_list_colors.Count(); i++)
-            //    {
-                 
-            //        e.Graphics.FillRectangle(new SolidBrush(m_list_colors[i]),
-            //                                this.Rect.X + (i * m_PenWidthAndHeight) + 1f,
-            //                this.Rect.Y,
-            //                m_PenWidthAndHeight,
-            //                m_PenWidthAndHeight);
-                   
-            //    }
-            //}
+                e.Graphics.DrawLine(p, m_rect.X, m_rect.Y, m_rect.X + m_rect.Width, m_rect.Y);
+          
+
         }
     }
 

+ 89 - 0
OTSIncAReportApp/2-CommonFunction/CommonClass/DrawFunction.cs

@@ -328,7 +328,96 @@ namespace OTSIncAReportGraph.Class
 
             return ret_color;
         }
+        public static 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 static 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;
+        }
         /// <summary>
         /// 获取一个自绘模仿进度条的bitemap对象,传入进度的值,0-100之间
         /// </summary>

+ 0 - 1
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -460,7 +460,6 @@
     <Compile Include="ReportTemplate\OTS_DEVReport.Designer.cs">
       <DependentUpon>OTS_DEVReport.cs</DependentUpon>
     </Compile>
-    <Compile Include="2-CommonFunction\CommonClass\Baseobject.cs" />
     <Compile Include="2-CommonFunction\CommonClass\DisplayField.cs" />
     <Compile Include="2-CommonFunction\CommonClass\DisplayParticle.cs" />
     <Compile Include="2-CommonFunction\CommonClass\DisplaySegment.cs" />

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio