[chronojump] cairo graph of races/datetime can show time(s)/date



commit 0060917b279c9d51b68b11dfdc9acd056a138e8f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Apr 28 14:34:59 2021 +0200

    cairo graph of races/datetime can show time(s)/date

 glade/app1.glade                    | 45 +++++++++++++++++++++++++++----------
 src/gui/app1/jumpsRunsEvolution.cs  |  8 ++++++-
 src/gui/cairo/jumpsRunsEvolution.cs | 18 ++++++++-------
 src/jumpsRunsEvolution.cs           | 17 +++++++++++---
 4 files changed, 64 insertions(+), 24 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index f48e65a8..53147410 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -21458,6 +21458,21 @@ Concentric</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkCheckButton" 
id="check_runs_evolution_show_time">
+                                                            <property name="label" translatable="yes">Show 
time</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <signal name="clicked" 
handler="on_check_runs_evolution_show_time_clicked" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -25321,6 +25336,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31488,6 +31506,18 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -31524,18 +31554,6 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -40573,6 +40591,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/app1/jumpsRunsEvolution.cs b/src/gui/app1/jumpsRunsEvolution.cs
index e2420ed6..854e687b 100644
--- a/src/gui/app1/jumpsRunsEvolution.cs
+++ b/src/gui/app1/jumpsRunsEvolution.cs
@@ -37,6 +37,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.ComboBox combo_select_jumps_evolution;
        [Widget] Gtk.Button button_jumps_evolution_save_image;
        [Widget] Gtk.CheckButton check_jumps_evolution_only_best_in_session;
+       [Widget] Gtk.CheckButton check_runs_evolution_show_time;
 
        JumpsEvolution jumpsEvolution;
        JumpsEvolutionGraph jumpsEvolutionGraph;
@@ -213,6 +214,10 @@ public partial class ChronoJumpWindow
                SqlitePreferences.Update(SqlitePreferences.RunsEvolutionOnlyBestInSession,
                                check_runs_evolution_only_best_in_session.Active, false);
        }
+       private void on_check_runs_evolution_show_time_clicked (object o, EventArgs args)
+       {
+               runsEvolutionDo(true);
+       }
 
        private void runsEvolutionDo (bool calculateData)
        {
@@ -232,7 +237,7 @@ public partial class ChronoJumpWindow
 
                if(calculateData)
                {
-                       runsEvolution.metersSecondsPreferred = preferences.metersSecondsPreferred;
+                       runsEvolution.PassParameters(check_runs_evolution_show_time.Active, 
preferences.metersSecondsPreferred);
                        runsEvolution.Calculate(currentPerson.UniqueID, runType, 
check_runs_evolution_only_best_in_session.Active);
                }
 
@@ -251,6 +256,7 @@ public partial class ChronoJumpWindow
                                        runsEvolution.Intercept,
                                        drawingarea_runs_evolution,
                                        currentPerson.Name, runType, currentSession.DateShort,
+                                       check_runs_evolution_show_time.Active,
                                        preferences.metersSecondsPreferred);
                        runsEvolutionGraph.Do(preferences.fontType.ToString());
 
diff --git a/src/gui/cairo/jumpsRunsEvolution.cs b/src/gui/cairo/jumpsRunsEvolution.cs
index c06573b3..eb1db5a6 100644
--- a/src/gui/cairo/jumpsRunsEvolution.cs
+++ b/src/gui/cairo/jumpsRunsEvolution.cs
@@ -160,8 +160,6 @@ 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)
        {
@@ -179,7 +177,8 @@ public class RunsEvolutionGraph : EvolutionGraph
        //regular constructor
        public RunsEvolutionGraph (
                        List<PointF> point_l, double slope, double intercept,
-                       DrawingArea area, string title, string runType, string date, bool 
metersSecondsPreferred)
+                       DrawingArea area, string title, string runType, string date,
+                       bool showTime, bool metersSecondsPreferred)
        {
                this.point_l = point_l;
                this.slope = slope;
@@ -188,16 +187,19 @@ 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 = "";
-               if(metersSecondsPreferred)
-                       yUnits = "m/s";
-               else
-                       yUnits = "km/h";
+               if(showTime)
+                       yUnits = "s";
+               else {
+                       if(metersSecondsPreferred)
+                               yUnits = "m/s";
+                       else
+                               yUnits = "km/h";
+               }
        }
 
        protected override void writeTitle()
diff --git a/src/jumpsRunsEvolution.cs b/src/jumpsRunsEvolution.cs
index ee554c25..3169b65f 100644
--- a/src/jumpsRunsEvolution.cs
+++ b/src/jumpsRunsEvolution.cs
@@ -106,13 +106,20 @@ public class JumpsEvolution : JumpsRunsEvolution
 
 public class RunsEvolution : JumpsRunsEvolution
 {
-       public bool metersSecondsPreferred; //pass this
+       private bool showTime;
+       private bool metersSecondsPreferred;
 
        //constructor
        public RunsEvolution()
        {
        }
 
+       public void PassParameters(bool showTime, bool metersSecondsPreferred)
+       {
+               this.showTime = showTime;
+               this.metersSecondsPreferred = metersSecondsPreferred;
+       }
+
        public override void Calculate (int personID, string runType, bool onlyBestInSession)
        {
                //1 get data
@@ -124,7 +131,6 @@ public class RunsEvolution : JumpsRunsEvolution
                int currentSession = -1;
                 foreach(Run r in run_l)
                {
-                       r.MetersSecondsPreferred = metersSecondsPreferred;
 
                        if(onlyBestInSession)
                        {
@@ -138,7 +144,12 @@ public class RunsEvolution : JumpsRunsEvolution
                        DateTime dt = UtilDate.FromFile(r.Datetime);
                        double dtDouble = UtilDate.DateTimeYearDayAsDouble(dt);
 
-                       point_l.Add(new PointF(dtDouble, r.Speed));
+                       if(showTime)
+                               point_l.Add(new PointF(dtDouble, r.Time));
+                       else {
+                               r.MetersSecondsPreferred = metersSecondsPreferred;
+                               point_l.Add(new PointF(dtDouble, r.Speed));
+                       }
                }
 
                getLeastSquaresLine ();


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