[chronojump] cairo graph of races/datetime cares about m/s or km/h



commit c06bf7767aef92cf49f7cda730ed032f1d4383cb
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Apr 28 14:08:46 2021 +0200

    cairo graph of races/datetime cares about m/s or km/h

 src/gui/app1/jumpsRunsEvolution.cs  |  6 +++++-
 src/gui/cairo/jumpsRunsEvolution.cs | 10 ++++++++--
 src/jumpsRunsEvolution.cs           |  4 ++++
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/app1/jumpsRunsEvolution.cs b/src/gui/app1/jumpsRunsEvolution.cs
index 80ecfcf4..e2420ed6 100644
--- a/src/gui/app1/jumpsRunsEvolution.cs
+++ b/src/gui/app1/jumpsRunsEvolution.cs
@@ -231,7 +231,10 @@ public partial class ChronoJumpWindow
                string runType = comboSelectRunsEvolution.GetSelectedNameEnglish();
 
                if(calculateData)
+               {
+                       runsEvolution.metersSecondsPreferred = preferences.metersSecondsPreferred;
                        runsEvolution.Calculate(currentPerson.UniqueID, runType, 
check_runs_evolution_only_best_in_session.Active);
+               }
 
                if(runsEvolution.Point_l.Count == 0)
                {
@@ -247,7 +250,8 @@ public partial class ChronoJumpWindow
                                        runsEvolution.Slope,
                                        runsEvolution.Intercept,
                                        drawingarea_runs_evolution,
-                                       currentPerson.Name, runType, currentSession.DateShort);
+                                       currentPerson.Name, runType, currentSession.DateShort,
+                                       preferences.metersSecondsPreferred);
                        runsEvolutionGraph.Do(preferences.fontType.ToString());
 
                        button_runs_evolution_save_image.Sensitive = true;
diff --git a/src/gui/cairo/jumpsRunsEvolution.cs b/src/gui/cairo/jumpsRunsEvolution.cs
index 3deffbee..c06573b3 100644
--- a/src/gui/cairo/jumpsRunsEvolution.cs
+++ b/src/gui/cairo/jumpsRunsEvolution.cs
@@ -160,6 +160,8 @@ public class JumpsEvolutionGraph : EvolutionGraph
 
 public class RunsEvolutionGraph : EvolutionGraph
 {
+       private bool metersSecondsPreferred;
+
        //constructor when there are no points
        public RunsEvolutionGraph (DrawingArea area, string runType, string font)//, string title, string 
runType, string date)
        {
@@ -177,7 +179,7 @@ public class RunsEvolutionGraph : EvolutionGraph
        //regular constructor
        public RunsEvolutionGraph (
                        List<PointF> point_l, double slope, double intercept,
-                       DrawingArea area, string title, string runType, string date)
+                       DrawingArea area, string title, string runType, string date, bool 
metersSecondsPreferred)
        {
                this.point_l = point_l;
                this.slope = slope;
@@ -186,12 +188,16 @@ public class RunsEvolutionGraph : EvolutionGraph
                this.title = title;
                this.runType = runType;
                this.date = date;
+               this.metersSecondsPreferred = metersSecondsPreferred;
                this.colorBackground = colorFromGdk(Config.ColorBackground); //but note if we are using 
system colors, this will not match
 
                xVariable = dateStr;
                yVariable = speedStr;
                xUnits = "";
-               yUnits = "m/s"; //TODO: can be km/h depending on preferences
+               if(metersSecondsPreferred)
+                       yUnits = "m/s";
+               else
+                       yUnits = "km/h";
        }
 
        protected override void writeTitle()
diff --git a/src/jumpsRunsEvolution.cs b/src/jumpsRunsEvolution.cs
index 3e29a104..ee554c25 100644
--- a/src/jumpsRunsEvolution.cs
+++ b/src/jumpsRunsEvolution.cs
@@ -106,6 +106,8 @@ public class JumpsEvolution : JumpsRunsEvolution
 
 public class RunsEvolution : JumpsRunsEvolution
 {
+       public bool metersSecondsPreferred; //pass this
+
        //constructor
        public RunsEvolution()
        {
@@ -122,6 +124,8 @@ public class RunsEvolution : JumpsRunsEvolution
                int currentSession = -1;
                 foreach(Run r in run_l)
                {
+                       r.MetersSecondsPreferred = metersSecondsPreferred;
+
                        if(onlyBestInSession)
                        {
                                //at onlyBestInSession they return ordered by sessionID, 
run.distance/run.time DESC


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