[chronojump/FS-TFT-Menu] Encoder cairo barplot draws loss arrow



commit 281be53bfc8b549532211a81fc3430c843d7850e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Mar 25 14:10:09 2022 +0100

    Encoder cairo barplot draws loss arrow

 src/gui/cairo/bars.cs   | 29 +++++++++++++++++++++++++++++
 src/gui/eventExecute.cs | 12 ++++++++++++
 2 files changed, 41 insertions(+)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index c4dbff51a..3e2c183db 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -44,6 +44,7 @@ public abstract class CairoBars : CairoGeneric
        protected CairoBarsGuideManage cairoBarsGuideManage;
        protected bool usePersonGuides;
        protected bool useGroupGuides;
+       protected CairoBarsArrow cairoBarsArrow;
 
        protected Cairo.Context g;
        protected int lineWidthDefault = 1; //was 2;
@@ -59,6 +60,7 @@ public abstract class CairoBars : CairoGeneric
 
        protected Cairo.Color black;
        protected Cairo.Color gray99;
+       protected Cairo.Color gray153; //light
        protected Cairo.Color white;
        protected Cairo.Color red;
        protected Cairo.Color blue;
@@ -149,6 +151,11 @@ public abstract class CairoBars : CairoGeneric
                }
        }
 
+       public void PassArrowData (CairoBarsArrow cairoBarsArrow)
+       {
+               this.cairoBarsArrow = cairoBarsArrow;
+       }
+
        protected enum textTickPos { ABOVETICK, BELOWTICK, ABSOLUTEBOTTOM }
 
        protected textTickPos drawGuidesFindYAvg (
@@ -320,6 +327,7 @@ public abstract class CairoBars : CairoGeneric
 
                black = colorFromRGB(0,0,0);
                gray99 = colorFromRGB(99,99,99);
+               gray153 = colorFromRGB(153,153,153);
                white = colorFromRGB(255,255,255);
                red = colorFromRGB(200,0,0);
                blue = colorFromRGB(178, 223, 238); //lightblue
@@ -488,6 +496,21 @@ public abstract class CairoBars : CairoGeneric
 
        protected abstract void plotBars ();
 
+       protected void plotArrow ()
+       {
+               //caution
+               if(cairoBarsArrow == null || barsXCenter_l == null ||
+                               cairoBarsArrow.x0pos >= barsXCenter_l.Count ||
+                               cairoBarsArrow.x1pos >= barsXCenter_l.Count)
+                       return;
+
+               plotArrowFree (g, gray153, 5, 20,
+                               cairoBarsArrow.GetX0Graph (barsXCenter_l),
+                               calculatePaintY(cairoBarsArrow.y0),
+                               cairoBarsArrow.GetX1Graph (barsXCenter_l),
+                               calculatePaintY(cairoBarsArrow.y1));
+       }
+
        protected void plotAlternativeLine (List<double> dataSecondary_l)
        {
                //be safe
@@ -937,6 +960,9 @@ public class CairoBars1Series : CairoBars
                g.SetSourceColor(black);
                plotBars ();
 
+               if(cairoBarsArrow != null)
+                       plotArrow();
+
                if(dataSecondary_l != null && dataSecondary_l.Count > 0)
                        plotAlternativeLine(dataSecondary_l);
 
@@ -1316,6 +1342,9 @@ public class CairoBarsNHSeries : CairoBars
                g.SetSourceColor(black);
                plotBars();
 
+               if(cairoBarsArrow != null)
+                       plotArrow();
+
                if(dataSecondary_l != null && dataSecondary_l.Count > 0)
                        plotAlternativeLine(dataSecondary_l);
 
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 9bdc089f6..f0dc183f2 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -3385,6 +3385,7 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
        private ArrayList dataRangeOfMovement; //ROM, need it to discard last rep for loss. Is not the same 
as dataSecondary_l because maybe user selected another variable as secondary. only checks con.
        private ArrayList dataWorkJ;
        private ArrayList dataImpulse;
+       private CairoBarsArrow cairoBarsArrow;
 
        private List<PointF> dataA_l; //data is related to mainVariable (barplot)
        private List<PointF> dataB_l; //data is related to mainVariable (barplot)
@@ -3763,6 +3764,14 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
 
                        //TODO: copy more stuff from /gui/encoderGraphObjects fillDataVariables()
                }
+
+               cairoBarsArrow = null;
+               if(pegbe.showLoss && (pegbe.eccon == "c" || preferences.encoderCaptureFeedbackEccon != 
Preferences.EncoderPhasesEnum.ECC) )
+               {
+                       if(maxThisSetValidAndCon > 0 && maxThisSetValidAndConPos < minThisSetValidAndConPos)
+                               cairoBarsArrow = new CairoBarsArrow(maxThisSetValidAndConPos, 
maxThisSetValidAndCon,
+                                               minThisSetValidAndConPos, minThisSetValidAndCon);
+               }
        }
 
        private void paintSpecificDo ()
@@ -3791,6 +3800,9 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
                }
                cb.Decs = decs;
 
+               if(cairoBarsArrow != null)
+                       cb.PassArrowData (cairoBarsArrow);
+
                if(dataSecondary_l.Count > 0)
                        cb.PassDataSecondary (dataSecondary_l);
 


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