[chronojump] jumps simple evolution graph can show only best in session



commit 63d198f5c1a264f96a7b96333ec33060f42bd63e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jul 14 17:52:41 2020 +0200

    jumps simple evolution graph can show only best in session

 glade/app1.glade               | 57 +++++++++++++++++++++++++++++++++---------
 src/gui/app1/jumpsEvolution.cs |  8 +++++-
 src/gui/usefulObjects.cs       |  3 ++-
 src/jumpsEvolution.cs          | 14 +++++++++--
 src/sqlite/jump.cs             |  4 ++-
 5 files changed, 69 insertions(+), 17 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 415d58e5..b30f70ed 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -19963,6 +19963,11 @@ Concentric</property>
                                                             <widget class="GtkHBox" id="hbox301">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
+                                                            <property name="spacing">20</property>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox432">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
                                                             <property name="spacing">12</property>
                                                             <child>
                                                             <widget class="GtkLabel" id="label417">
@@ -19998,6 +20003,28 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkCheckButton" 
id="check_jumps_evolution_only_best_in_session">
+                                                            <property name="label" translatable="yes">Only 
best jump each session</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_jumps_evolution_only_best_in_session_clicked" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" id="hbox321">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -24294,6 +24321,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -27135,18 +27165,6 @@ 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>
@@ -27183,6 +27201,18 @@ 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>
@@ -35142,6 +35172,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/jumpsEvolution.cs b/src/gui/app1/jumpsEvolution.cs
index b91abd59..003bfbf1 100644
--- a/src/gui/app1/jumpsEvolution.cs
+++ b/src/gui/app1/jumpsEvolution.cs
@@ -32,6 +32,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.HBox hbox_combo_select_jumps_evolution;
        [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;
 
        JumpsEvolution jumpsEvolution;
        JumpsEvolutionGraph jumpsEvolutionGraph;
@@ -61,6 +62,11 @@ public partial class ChronoJumpWindow
        }
        // combo (end)
 
+       private void on_check_jumps_evolution_only_best_in_session_clicked (object o, EventArgs args)
+       {
+               jumpsEvolutionDo(true);
+       }
+
        private void jumpsEvolutionDo (bool calculateData)
        {
                if(currentPerson == null || currentSession == null ||
@@ -78,7 +84,7 @@ public partial class ChronoJumpWindow
                string jumpType = comboSelectJumpsEvolution.GetSelectedNameEnglish();
 
                if(calculateData)
-                       jumpsEvolution.Calculate(currentPerson.UniqueID, jumpType);
+                       jumpsEvolution.Calculate(currentPerson.UniqueID, jumpType, 
check_jumps_evolution_only_best_in_session.Active);
 
                if(jumpsEvolution.Point_l.Count == 0)
                {
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 9bfc9ef7..c53cd92f 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -94,7 +94,8 @@ public class PrepareEventGraphJumpSimple
 
                jumpsAtSQL = SqliteJump.SelectJumps (sessionID, personIDTemp, type,
                                Sqlite.Orders_by.ID_DESC, limit,
-                               allPersons); //show names on comments only if "all persons"
+                               allPersons,     //show names on comments only if "all persons"
+                               false);         //! onlyBestInSession
 
                Sqlite.Open();
 
diff --git a/src/jumpsEvolution.cs b/src/jumpsEvolution.cs
index 9723f964..ada12cdd 100644
--- a/src/jumpsEvolution.cs
+++ b/src/jumpsEvolution.cs
@@ -33,15 +33,25 @@ public class JumpsEvolution
        {
        }
        
-       public void Calculate (int personID, string jumpType)
+       public void Calculate (int personID, string jumpType, bool onlyBestInSession)
        {
                //1 get data
-                List<Jump> jump_l = SqliteJump.SelectJumps (-1, personID, jumpType, 
Sqlite.Orders_by.DEFAULT, -1, false);
+                List<Jump> jump_l = SqliteJump.SelectJumps (-1, personID, jumpType, 
Sqlite.Orders_by.DEFAULT, -1, false, onlyBestInSession);
 
                //2 convert to list of PointF
                point_l = new List<PointF>();
+               int currentSession = -1;
                 foreach(Jump j in jump_l)
                {
+                       if(onlyBestInSession)
+                       {
+                               //at onlyBestInSession they return ordered by sessionID, jump.Tv DESC
+                               if(j.SessionID == currentSession)
+                                       continue;
+                               else
+                                       currentSession = j.SessionID;
+                       }
+
                        DateTime dt = UtilDate.FromFile(j.Datetime);
                        double dtDouble = UtilDate.DateTimeYearDayAsDouble(dt);
 
diff --git a/src/sqlite/jump.cs b/src/sqlite/jump.cs
index d08e828d..96e650a5 100644
--- a/src/sqlite/jump.cs
+++ b/src/sqlite/jump.cs
@@ -202,7 +202,7 @@ class SqliteJump : Sqlite
         * personNameInComment is used to be able to display names in graphs
         *   because event.PersonName makes individual SQL SELECTs
         */
-       public static List<Jump> SelectJumps (int sID, int pID, string jumpType, Orders_by order, int limit, 
bool personNameInComment)
+       public static List<Jump> SelectJumps (int sID, int pID, string jumpType, Orders_by order, int limit, 
bool personNameInComment, bool onlyBestInSession)
        {
          //jumps previous to DB 1.82 have no datetime on jump
          //find session datetime for that jumps
@@ -241,6 +241,8 @@ class SqliteJump : Sqlite
          string orderByString = " ORDER BY jump.uniqueID ";
          if(order == Orders_by.ID_DESC)
                  orderByString = " ORDER BY jump.uniqueID DESC ";
+         if(onlyBestInSession)
+                 orderByString = " ORDER BY jump.sessionID, jump.Tv DESC ";
 
          string limitString = "";
          if(limit != -1)


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