[chronojump/FS-TFT-Menu] CairoBarsEncoder on ec at capturing if last is ecc, a con is send as null (in order to draw last ecc



commit b93fd7b0d410325d41588064195f515391fd9297
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Mar 29 11:38:26 2022 +0200

    CairoBarsEncoder on ec at capturing if last is ecc, a con is send as null (in order to draw last ecc 
correctly)

 src/gui/cairo/bars.cs   | 28 ++++++++++++++++++++++++++--
 src/gui/eventExecute.cs |  8 ++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index 47e2c3c1a..c3c1a8e08 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -1231,7 +1231,7 @@ public class CairoBarsNHSeries : CairoBars
                                        maxY = p.Y;
 
                foreach(PointF p in barMain_l)
-                       if(p.Y > maxY)
+                       if(p != null && p.Y > maxY) //on ec at capturing if last is ecc, a con is send as null
                                maxY = p.Y;
 
                if(cairoBarsGuideManage != null  && cairoBarsGuideManage.GetMax() > maxY)
@@ -1242,6 +1242,10 @@ public class CairoBarsNHSeries : CairoBars
                //maxX = barMain_l.Count + .5; //all barMain_l lists have same length
                maxX = barMain_l.Count + 1;
 
+               //while capturing ecc-con, if last rep don is an ecc, it have to be drawn
+               if(barSecondary_ll.Count == 1 && barSecondary_ll[0].Count > barMain_l.Count)
+                       maxX ++;
+
                //bars Y have 0 at bottom
                minY = 0;
        }
@@ -1273,6 +1277,18 @@ public class CairoBarsNHSeries : CairoBars
                int mouseLimitsPos1stBar = barMain_l.Count *2 -2;
                int mouseLimitsPos2ndBar = barMain_l.Count *2 -1;
 
+               //debug
+               LogB.Information("barMain_l:");
+               for(int j = 0; j < barMain_l.Count; j ++)
+                       if(barMain_l[j] != null) //at ec capture, if last is ecc, a con is send as null
+                               LogB.Information(barMain_l[j].ToString());
+               if(barSecondary_ll.Count == 1)
+               {
+                       LogB.Information("barSecondary_ll[0]:");
+                       for(int j = 0; j < barSecondary_ll[0].Count; j ++)
+                               LogB.Information(barSecondary_ll[0][j].ToString());
+               }
+
                for(int i = 0; i < barMain_l.Count; i ++)
                {
                        /*
@@ -1282,7 +1298,15 @@ public class CairoBarsNHSeries : CairoBars
                        List<Point3F> resultOnBarsThisIteration_l = new List<Point3F>();
 
                        bool secondaryHasData = false;
-                       PointF pB = barMain_l[i];
+
+                       PointF pB = new PointF(0,0);
+                       if(barMain_l[i] == null) //on ec if we send a final ecc, con will be null
+                       {
+                               if(i < barSecondary_ll[0].Count && barSecondary_ll[0][i] != null)
+                                       pB = new PointF(barSecondary_ll[0][i].X + .5, 0);
+                       }
+                       else
+                               pB = barMain_l[i];
 
                        double x = (graphWidth - (leftMargin+rightMargin)) * pB.X/maxX + leftMargin;
                        double adjustX = -barDesplLeft * (barSecondary_ll.Count +1);
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index c0dde3664..e7ae1a4c4 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -3685,6 +3685,14 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
                //foreach(EncoderBarsData ebd in pegbe.data9Variables)
                //for (int count = 0; count < pegbe.data9Variables.Count; count ++)
 //             int countNames = 0;
+
+               //if !c && is "impar" (uneven), add a null to B
+               if (pegbe.eccon != "c" && ! Util.IsEven(pegbe.data9Variables.Count))
+               {
+                       barB_l.Add(null);
+                       colorMain_l.Add(CairoGeneric.colorFromGdk(UtilGtk.GRAY)); //this color will not be 
shown is just to match barB_l with colorMain_l
+               }
+
                for (count = (pegbe.data9Variables.Count -1); count >= 0; count --)
                {
                        EncoderBarsData ebd = (EncoderBarsData) pegbe.data9Variables[count];


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