[chronojump] CairoBars parameters passed as Main_l and Secondary_ll, and can be selected order. Implemented for a



commit 7cd690f75daf675bde53c500000e2dca6ffc2b04
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Mar 17 13:25:17 2022 +0100

    CairoBars parameters passed as Main_l and Secondary_ll, and can be selected order. Implemented for all 
bar graphs.

 src/gui/cairo/bars.cs   | 57 +++++++++++++++++++------------------------------
 src/gui/eventExecute.cs | 45 +++++++++++++++++---------------------
 2 files changed, 41 insertions(+), 61 deletions(-)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index c395dbf4b..838274357 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Copyright (C) 2004-2021   Xavier de Blas <xaviblas gmail com>
+ *  Copyright (C) 2004-2022   Xavier de Blas <xaviblas gmail com>
  */
 
 using System;
@@ -82,11 +82,6 @@ public abstract class CairoBars : CairoGeneric
                this.cairoBarsGuideManage = cairoBarsGuideManage;
        }
 
-       //TODO: better do PassData1Serie for point_l and PassDataNSeries for point_l_l
-       public virtual void PassPointSecondaryList (List<List<PointF>> pointSecondary_l)
-       {
-       }
-
        protected void drawGuides (Cairo.Color color)
        {
                g.SetSourceColor(color);
@@ -252,8 +247,7 @@ public abstract class CairoBars : CairoGeneric
                g.LineWidth = 1;
        }
 
-       //TODO: do not pass pointA_l, pointB_l here. Use above PassData
-       public abstract void GraphDo (List<PointF> pointA_l, List<PointF> pointB_l,
+       public abstract void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool 
mainAtLeft,
                        List<string> names_l, int fontHeightForBottomNames, int marginForBottomNames, string 
title);
 
        protected void initGraph(string font, double widthPercent1)
@@ -742,11 +736,11 @@ LogB.Information(string.Format("y: {0}, alto: {1}", y, graphHeight -y - bottomMa
                }
        }
 
-       public override void GraphDo (List<PointF> pointA_l, List<PointF> pointB_l,
+       public override void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool 
mainAtLeft,
                        List<string> names_l, int fontHeightForBottomNames, int marginForBottomNames, string 
title)
        {
                LogB.Information("at CairoBars1Series.Do");
-               this.point_l = pointA_l;
+               this.point_l = pointMain_l;
                //this.pointB_l = pointB_l; unused here
                this.names_l = names_l;
                this.fontHeightForBottomNames = fontHeightForBottomNames;
@@ -778,8 +772,8 @@ LogB.Information(string.Format("y: {0}, alto: {1}", y, graphHeight -y - bottomMa
 //N series in horizontal, like jump Dj tc/tf, jumpRj (maybe with a "number of jumps" column)
 public class CairoBarsNHSeries : CairoBars
 {
-       private List<List<PointF>> pointSecondary_l;
-       private List<PointF> pointB_l;
+       private List<List<PointF>> pointSecondary_ll;
+       private List<PointF> pointMain_l;
        private List<string> names_l;
 
        private Cairo.Color colorSerieB;
@@ -922,12 +916,12 @@ public class CairoBarsNHSeries : CairoBars
 
        protected override void findMaximums()
        {
-               foreach(List<PointF> p_l in pointSecondary_l)
+               foreach(List<PointF> p_l in pointSecondary_ll)
                        foreach(PointF p in p_l)
                                if(p.Y > maxY)
                                        maxY = p.Y;
 
-               foreach(PointF p in pointB_l)
+               foreach(PointF p in pointMain_l)
                        if(p.Y > maxY)
                                maxY = p.Y;
 
@@ -936,8 +930,8 @@ public class CairoBarsNHSeries : CairoBars
 
                //points X start at 1
                minX = 0;
-               //maxX = pointB_l.Count + .5; //all point_l lists have same length
-               maxX = pointB_l.Count + 1;
+               //maxX = pointMain_l.Count + .5; //all point_l lists have same length
+               maxX = pointMain_l.Count + 1;
 
                //bars Y have 0 at bottom
                minY = 0;
@@ -947,9 +941,9 @@ public class CairoBarsNHSeries : CairoBars
        protected override void plotBars ()
        {
                /* debug stuff
-               LogB.Information("plotBars NH pointB_l.Count: " + pointB_l.Count.ToString());
-               LogB.Information("plotBars NH pointSecondary_l.Count: " + pointSecondary_l.Count.ToString());
-               LogB.Information("plotBars NH pointSecondary_l[0].Count: " + 
pointSecondary_l[0].Count.ToString());
+               LogB.Information("plotBars NH pointMain_l.Count: " + pointMain_l.Count.ToString());
+               LogB.Information("plotBars NH pointSecondary_ll.Count: " + 
pointSecondary_ll.Count.ToString());
+               LogB.Information("plotBars NH pointSecondary_ll[0].Count: " + 
pointSecondary_ll[0].Count.ToString());
                LogB.Information("plotBars NH names_l.Count: " + names_l.Count.ToString());
                */
 
@@ -957,13 +951,13 @@ public class CairoBarsNHSeries : CairoBars
                 double distanceBetweenCols = (graphWidth - (leftMargin+rightMargin))/maxX;
 
                 double barWidth = .4*distanceBetweenCols; //two bars will be .8
-               if(pointSecondary_l.Count == 2) //TODO: fix this for more columns
+               if(pointSecondary_ll.Count == 2) //TODO: fix this for more columns
                        barWidth = .8*distanceBetweenCols/3; //three bars will be .8
                 double barDesplLeft = .5*barWidth;
                int resultFontHeight = getBarsResultFontHeight (barWidth*1.5);
                List<Point3F> resultOnBars_l = new List<Point3F>();
 
-               for(int i = 0; i < pointB_l.Count; i ++)
+               for(int i = 0; i < pointMain_l.Count; i ++)
                {
                        /*
                           need this to sort correctly, because tests are plotted from last to first (right 
to left),
@@ -973,14 +967,14 @@ public class CairoBarsNHSeries : CairoBars
 
                        //PointF pA = pointA_l[i];
                        bool secondaryHasData = false;
-                       PointF pB = pointB_l[i];
+                       PointF pB = pointMain_l[i];
 
                        double x = (graphWidth - (leftMargin+rightMargin)) * pB.X/maxX + leftMargin;
-                       double adjustX = -barDesplLeft * (pointSecondary_l.Count +1);
+                       double adjustX = -barDesplLeft * (pointSecondary_ll.Count +1);
 
-                       for(int j = 0; j < pointSecondary_l.Count; j ++)
+                       for(int j = 0; j < pointSecondary_ll.Count; j ++)
                        {
-                               PointF pS = pointSecondary_l[j][i];
+                               PointF pS = pointSecondary_ll[j][i];
                                if(pS.Y > 0)
                                {
                                        double y = calculatePaintY(pS.Y);
@@ -1022,18 +1016,11 @@ public class CairoBarsNHSeries : CairoBars
                        pAyStart = plotResultOnBar(p.X, p.Y, graphHeight -bottomMargin, p.Z, 
resultFontHeight, barWidth, pAyStart);
        }
 
-       public override void PassPointSecondaryList (List<List<PointF>> pointSecondary_l)
-       {
-               this.pointSecondary_l = pointSecondary_l;
-       }
-       public override void GraphDo (List<PointF> pointA_l, List<PointF> pointB_l,
-       //public override void GraphDo (List<List<PointF>> pointSecondary_l, List<PointF> pointB_l,
+       public override void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool 
mainAtLeft,
                        List<string> names_l, int fontHeightForBottomNames, int marginForBottomNames, string 
title)
        {
-               //LogB.Information("at CairoBarsNHSeries.GraphDo");
-               //this.pointA_l = pointA_l;
-               //this.pointSecondary_l = pointSecondary_l;
-               this.pointB_l = pointB_l;
+               this.pointSecondary_ll = pointSecondary_ll;
+               this.pointMain_l = pointMain_l;
                this.names_l = names_l;
                this.fontHeightForBottomNames = fontHeightForBottomNames;
                this.marginForBottomNames = marginForBottomNames;
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index f4d945012..714a7fc28 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -2629,17 +2629,16 @@ public class CairoPaintBarsPreJumpSimple : CairoPaintBarsPre
 
                if(showBarA && showBarB) //Dja, Djna
                {
-                       List<List<PointF>> pointSecondary_l = new List<List<PointF>>();
-                       pointSecondary_l.Add(pointA_l);
-                       cb.PassPointSecondaryList(pointSecondary_l);
+                       List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
+                       pointSecondary_ll.Add(pointA_l);
 
-                       cb.GraphDo (pointA_l, pointB_l, names_l,
+                       cb.GraphDo (pointB_l, pointSecondary_ll, false, names_l,
                                        fontHeightForBottomNames, bottomMargin, title);
                } else if (showBarA) //takeOff, takeOffWeight
-                       cb.GraphDo (pointA_l, new List<PointF>(), names_l,
+                       cb.GraphDo (pointA_l, new List<List<PointF>>(), false, names_l,
                                        fontHeightForBottomNames, bottomMargin, title);
                else //rest of the jumps: sj, cmj, ..
-                       cb.GraphDo (pointB_l, new List<PointF>(), names_l,
+                       cb.GraphDo (pointB_l, new List<List<PointF>>(), false, names_l,
                                        fontHeightForBottomNames, bottomMargin, title);
        }
 }
@@ -2763,12 +2762,10 @@ public class CairoPaintBarsPreJumpReactive : CairoPaintBarsPre
                                        eventGraphJumpsRjStored.personMINAtSQL
                                        ));
 
-               List<List<PointF>> pointSecondary_l = new List<List<PointF>>();
-               //pointSecondary_l.Add(pointA0_l);
-               pointSecondary_l.Add(pointA1_l);
-               cb.PassPointSecondaryList(pointSecondary_l);
+               List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
+               pointSecondary_ll.Add(pointA1_l);
 
-               cb.GraphDo (pointA1_l, pointB_l, names_l,
+               cb.GraphDo (pointB_l, pointSecondary_ll, false, names_l,
                                fontHeightForBottomNames, bottomMargin, title);
        }
 }
@@ -2867,7 +2864,7 @@ public class CairoPaintBarsPreRunSimple : CairoPaintBarsPre
                                        eventGraphRunsStored.personAVGAtSQL,
                                        eventGraphRunsStored.personMINAtSQL));
 
-               cb.GraphDo(point_l, new List<PointF>(), names_l,
+               cb.GraphDo (point_l, new List<List<PointF>>(), false, names_l,
                                fontHeightForBottomNames, bottomMargin, title);
        }
 }
@@ -2976,7 +2973,7 @@ public class CairoPaintBarsPreRunInterval : CairoPaintBarsPre
                                        eventGraphRunsIntervalStored.personAVGAtSQL,
                                        eventGraphRunsIntervalStored.personMINAtSQL));
 
-               cb.GraphDo(point_l, new List<PointF>(), names_l,
+               cb.GraphDo (point_l, new List<List<PointF>>(), false, names_l,
                                fontHeightForBottomNames, bottomMargin, title);
        }
 }
@@ -3100,11 +3097,10 @@ public class CairoPaintBarsPreJumpReactiveRealtimeCapture : CairoPaintBarsPre
                                        sum / tv_l.Count,
                                        min));
 
-               List<List<PointF>> pointSecondary_l = new List<List<PointF>>();
-               pointSecondary_l.Add(pointA_l);
-               cb.PassPointSecondaryList(pointSecondary_l);
+               List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
+               pointSecondary_ll.Add(pointA_l);
 
-               cb.GraphDo (pointA_l, pointB_l, names_l,
+               cb.GraphDo (pointB_l, pointSecondary_ll, false, names_l,
                                14, 8, title);
        }
 }
@@ -3274,7 +3270,7 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
                                        sum / speed_l.Count,
                                        min));
 
-               cb.GraphDo (point_l, new List<PointF>(), names_l,
+               cb.GraphDo (point_l, new List<List<PointF>>(), false, names_l,
                                14, 22, title); //22 because there are two rows
        }
 }
@@ -3470,16 +3466,13 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
                cb.Decs = decs;
 
                if(pegbe.eccon == "c")
-                       cb.GraphDo (dataA_l, new List<PointF>(), names_l,
+                       cb.GraphDo (dataA_l, new List<List<PointF>>(), false, names_l,
                                        14, 8, "my title");
-               else
-               {
-                       //TODO: why we need secondary? seems a list of many points
-                       List<List<PointF>> pointSecondary_l = new List<List<PointF>>();
-                       pointSecondary_l.Add(dataA_l);
-                       cb.PassPointSecondaryList(pointSecondary_l);
+               else {
+                       List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
+                       pointSecondary_ll.Add(dataA_l);
 
-                       cb.GraphDo (dataA_l, dataB_l, names_l,
+                       cb.GraphDo (dataB_l, pointSecondary_ll, false, names_l,
                                        14, 8, "my title");
                }
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]