[chronojump] JumpRjFatigue graph with combo for num or set



commit 6b929bd6419f2d25fcdda5f42f05ab67890b41fc
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Aug 7 13:56:55 2020 +0200

    JumpRjFatigue graph with combo for num or set

 glade/app1.glade               | 70 ++++++++++++++++++++++++++++++--------
 src/encoder.cs                 |  1 +
 src/gui/app1/chronojump.cs     |  8 +++--
 src/gui/app1/jumpsRjFatigue.cs | 76 +++++++++++++++++++++++++++++++++++++-----
 src/gui/chronojumpImporter.cs  |  1 +
 src/jumpsRjFatigue.cs          | 27 ++++++---------
 src/utilDate.cs                | 11 ++++++
 7 files changed, 152 insertions(+), 42 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index d4b67ea8..929b8989 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -20357,6 +20357,44 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHBox" id="hbox437">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">12</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label567">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Num</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_combo_select_jumps_rj_fatigue_num">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" id="hbox198">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -20452,7 +20490,7 @@ Concentric</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
@@ -24805,6 +24843,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -27670,6 +27711,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>
@@ -27706,18 +27759,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>
@@ -35722,6 +35763,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/encoder.cs b/src/encoder.cs
index 61826249..c5f063a9 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -957,6 +957,7 @@ public class EncoderSQL
        //used on encoder table
        public enum Eccons { ALL, ecS, ceS, c } 
 
+       //for new code on other parts, use static method: UtilDate.GetDatetimePrint (DateTime dt)
        public string GetDatetimeStr (bool pretty)
        {
                int pointPos = filename.LastIndexOf('.');
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index d4a788d6..c033890a 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -613,6 +613,7 @@ public partial class ChronoJumpWindow
                createComboSelectJumpsEvolution(true);
                createComboSelectJumpsRj(true);
                createComboSelectJumpsRjFatigue(true);
+               createComboSelectJumpsRjFatigueNum(true);
                createComboSelectRuns(true);
                createComboSelectRunsInterval(true);
                
@@ -1215,7 +1216,7 @@ public partial class ChronoJumpWindow
                                        (currentJumpRjType.HasWeight && 
extra_window_jumps_rj_radiobutton_weight.Active));
 
                        if(notebook_analyze.CurrentPage == 
Convert.ToInt32(notebook_analyze_pages.JUMPSRJFATIGUE))
-                               jumpsRjFatigueDo(true); //calculate data
+                               createComboSelectJumpsRjFatigue (false);
                }
                else if(current_menuitem_mode == Constants.Menuitem_modes.RUNSSIMPLE)
                        updateGraphRunsSimple();
@@ -6225,6 +6226,7 @@ LogB.Debug("mc finished 5");
                } else {
                        createComboSelectJumpsRj(false);
                        createComboSelectJumpsRjFatigue(false);
+                       //createComboSelectJumpsRjFatigueNum(false); do not need because will be updated by 
createComboSelectJumpsRjFatigue
                        
                        UtilGtk.ComboUpdate(combo_result_jumps_rj, 
                                        SqliteJumpType.SelectJumpRjTypes(Constants.AllJumpsNameStr(), true), 
""); //without filter, only select name
@@ -7076,7 +7078,7 @@ LogB.Debug("mc finished 5");
                                if(radio_mode_contacts_jumps_rj_fatigue.Active)
                                {
                                        notebook_analyze.CurrentPage = 
Convert.ToInt32(notebook_analyze_pages.JUMPSRJFATIGUE);
-                                       jumpsRjFatigueDo(true); //calculate data
+                                       createComboSelectJumpsRjFatigue (false);
                                }
                        }
                }
@@ -7132,7 +7134,7 @@ LogB.Debug("mc finished 5");
                if(radio_mode_contacts_jumps_rj_fatigue.Active)
                {
                        notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.JUMPSRJFATIGUE);
-                       jumpsRjFatigueDo(true);
+                       createComboSelectJumpsRjFatigue (false);
                }
        }
        private void on_radio_mode_contacts_sprint_toggled (object o, EventArgs args)
diff --git a/src/gui/app1/jumpsRjFatigue.cs b/src/gui/app1/jumpsRjFatigue.cs
index 788dffb8..59f84544 100644
--- a/src/gui/app1/jumpsRjFatigue.cs
+++ b/src/gui/app1/jumpsRjFatigue.cs
@@ -32,17 +32,23 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_jumps_rj_fatigue_save_image;
        [Widget] Gtk.Image image_jumps_rj_fatigue_save;
        [Widget] Gtk.Image image_jumps_rj_fatigue_image_save;
+
        [Widget] Gtk.HBox hbox_combo_select_jumps_rj_fatigue;
        [Widget] Gtk.ComboBox combo_select_jumps_rj_fatigue;
+
+       [Widget] Gtk.HBox hbox_combo_select_jumps_rj_fatigue_num;
+       [Widget] Gtk.ComboBox combo_select_jumps_rj_fatigue_num;
+
        [Widget] Gtk.RadioButton radio_jumps_rj_fatigue_heights;
        [Widget] Gtk.RadioButton radio_jumps_rj_fatigue_tv_tc;
 
        JumpsRjFatigue jumpsRjFatigue;
        JumpsRjFatigueGraph jumpsRjFatigueGraph;
        CjComboSelectJumpsRj comboSelectJumpsRjFatigue;
+       CjComboGeneric comboSelectJumpsRjFatigueNum; //it has num and date
 
-       // combo (start)
-       private void createComboSelectJumpsRjFatigue(bool create)
+       // combo comboSelectJumpsRjFatigue (start)
+       private void createComboSelectJumpsRjFatigue (bool create)
        {
                if(create)
                {
@@ -55,7 +61,35 @@ public partial class ChronoJumpWindow
                }
                combo_select_jumps_rj_fatigue.Sensitive = true;
        }
-       private void on_combo_select_jumps_rj_fatigue_changed(object o, EventArgs args)
+       private void on_combo_select_jumps_rj_fatigue_changed (object o, EventArgs args)
+       {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+
+               //Update the combo with hidden jumpRj uniqueID, viewed and num, datetime
+               createComboSelectJumpsRjFatigueNum (false);
+       }
+       // combo comboSelectJumpsRjFatigue (end)
+
+       // combo comboSelectJumpsRjFatigueNum (start)
+       private void createComboSelectJumpsRjFatigueNum (bool create)
+       {
+               if(create)
+               {
+                       comboSelectJumpsRjFatigueNum = new CjComboGeneric (
+                                       combo_select_jumps_rj_fatigue_num, 
hbox_combo_select_jumps_rj_fatigue_num);
+                       combo_select_jumps_rj_fatigue_num = comboSelectJumpsRjFatigueNum.Combo;
+                       combo_select_jumps_rj_fatigue_num.Changed += new EventHandler (
+                                       on_combo_select_jumps_rj_fatigue_num_changed);
+               } else {
+                       comboSelectJumpsRjFatigueNum.L_types = jumpsRjFatigueSelectJumpsOfType ();
+                       comboSelectJumpsRjFatigueNum.Fill();
+                       combo_select_jumps_rj_fatigue_num = comboSelectJumpsRjFatigueNum.Combo;
+               }
+               combo_select_jumps_rj_fatigue_num.Sensitive = true;
+       }
+       private void on_combo_select_jumps_rj_fatigue_num_changed (object o, EventArgs args)
        {
                ComboBox combo = o as ComboBox;
                if (o == null)
@@ -63,7 +97,8 @@ public partial class ChronoJumpWindow
 
                jumpsRjFatigueDo(true);
        }
-       // combo (end)
+
+       // combo comboSelectJumpsRjFatigueNum (end)
 
        private void on_radio_jumps_rj_fatigue_heights_toggled (object o, EventArgs args)
        {
@@ -76,10 +111,32 @@ public partial class ChronoJumpWindow
                        jumpsRjFatigueDo(true);
        }
 
+       private List<object> jumpsRjFatigueSelectJumpsOfType ()
+       {
+               List<object> types = new List<object>();
+               if(currentPerson == null || currentSession == null ||
+                               comboSelectJumpsRjFatigue == null && comboSelectJumpsRjFatigue.Count == 0)
+                       return types;
+
+               List <JumpRj> jrj_l = SqliteJumpRj.SelectJumps (false, currentSession.UniqueID, 
currentPerson.UniqueID,
+                               comboSelectJumpsRjFatigue.GetSelectedNameEnglish());
+
+               int count = 1;
+               foreach(JumpRj jrj in jrj_l)
+               {
+                       string name = string.Format("{0} {1}", count++,
+                                       UtilDate.GetDatetimePrint (UtilDate.FromFile(jrj.Datetime)));
+                       types.Add(new SelectTypes(jrj.UniqueID, name, name)); //is not translated
+               }
+
+               return types;
+       }
+
        private void jumpsRjFatigueDo (bool calculateData)
        {
                if(currentPerson == null || currentSession == null ||
-                               drawingarea_jumps_rj_fatigue == null || 
drawingarea_jumps_rj_fatigue.GdkWindow == null) //it happens at start on click on analyze
+                               drawingarea_jumps_rj_fatigue == null || 
drawingarea_jumps_rj_fatigue.GdkWindow == null || //it happens at start on click on analyze
+                               comboSelectJumpsRjFatigueNum.GetSelectedId() < 0)
                {
                        button_jumps_rj_fatigue_save_image.Sensitive = false;
                        return;
@@ -93,14 +150,13 @@ public partial class ChronoJumpWindow
                string jumpType = comboSelectJumpsRjFatigue.GetSelectedNameEnglish();
 
                if(calculateData)
-                       jumpsRjFatigue.Calculate(currentSession.UniqueID, currentPerson.UniqueID,
-                                       jumpType, radio_jumps_rj_fatigue_heights.Active);
+                       jumpsRjFatigue.Calculate(comboSelectJumpsRjFatigueNum.GetSelectedId(),
+                                       radio_jumps_rj_fatigue_heights.Active);
 
                if(jumpsRjFatigue.Point_l.Count == 0)
                {
                        //constructor for showing blank screen with a message
                        new JumpsRjFatigueGraph(drawingarea_jumps_rj_fatigue, jumpType);
-                                       //currentPerson.Name, jumpType, currentSession.DateShort);
 
                        button_jumps_rj_fatigue_save_image.Sensitive = false;
 
@@ -123,10 +179,12 @@ public partial class ChronoJumpWindow
                //needed to have mouse clicks at: on_drawingarea_jumps_rj_fatigue_button_press_event ()
                drawingarea_jumps_rj_fatigue.AddEvents((int) (Gdk.EventMask.ButtonPressMask | 
Gdk.EventMask.ButtonReleaseMask));
 
-               jumpsRjFatigueDo(false); //do not calculate data
+               createComboSelectJumpsRjFatigueNum (false); //TODO: seguir canviant lo de dalt per aixo
+
                //data is calculated on switch page (at notebook_capture_analyze) or on change person
        }
 
+       //TODO:
        private void on_drawingarea_jumps_rj_fatigue_button_press_event (object o, ButtonPressEventArgs args)
        {
                /*
diff --git a/src/gui/chronojumpImporter.cs b/src/gui/chronojumpImporter.cs
index 87c6873b..779b6a62 100644
--- a/src/gui/chronojumpImporter.cs
+++ b/src/gui/chronojumpImporter.cs
@@ -167,6 +167,7 @@ public partial class ChronoJumpWindow
                        createComboSelectJumpsWeightFVProfile(false);
                        createComboSelectJumpsEvolution(false);
                        createComboSelectJumpsRjFatigue(false);
+                       //createComboSelectJumpsRjFatigueNum(false); do not need because will be updated by 
createComboSelectJumpsRjFatigue
 
                        //2) reactive jump
                        createComboSelectJumpsRj(false);
diff --git a/src/jumpsRjFatigue.cs b/src/jumpsRjFatigue.cs
index 4d590159..e252af5e 100644
--- a/src/jumpsRjFatigue.cs
+++ b/src/jumpsRjFatigue.cs
@@ -33,29 +33,22 @@ public class JumpsRjFatigue
        {
        }
        
-       public void Calculate (int sessionID, int personID, string jumpType, bool useHeights)
+       public void Calculate (int uniqueID, bool useHeights)
        {
                //1 get data
-                List<JumpRj> jrj_l = SqliteJumpRj.SelectJumps (false, sessionID, personID, jumpType);
+               JumpRj jumpRj = SqliteJumpRj.SelectJumpData (Constants.JumpRjTable, uniqueID, false);
 
                //2 convert to list of PointF
+               List<double> y_l;
+               if(useHeights)
+                       y_l = jumpRj.HeightList;
+               else
+                       y_l = jumpRj.TvTcList;
+
                point_l = new List<PointF>();
-               int currentSession = -1;
-                foreach(JumpRj j in jrj_l)
-               {
-                       List<double> y_l;
-                       if(useHeights)
-                               y_l = j.HeightList;
-                       else
-                               y_l = j.TvTcList;
 
-                       for(int i = 0; i < y_l.Count ; i ++)
-                               point_l.Add(new PointF(
-                                                       i+1,
-                                                       y_l[i]
-                                                     ));
-                       break; //at the moment only do it for one jump
-               }
+               for(int i = 0; i < y_l.Count ; i ++)
+                       point_l.Add(new PointF(i+1, y_l[i]));
 
                //3 get LeastSquaresLine (straight line)
                ls = new LeastSquaresLine();
diff --git a/src/utilDate.cs b/src/utilDate.cs
index 8ea1f2dc..17829635 100644
--- a/src/utilDate.cs
+++ b/src/utilDate.cs
@@ -52,6 +52,17 @@ public class UtilDate
                        UtilAll.DigitsCreate(dt.Second,2);
        }
 
+       //returns YYYY-MM-DD hh:mm:ss
+       public static string GetDatetimePrint (DateTime dt)
+       {
+               return UtilAll.DigitsCreate(dt.Year,4) + "-" +
+                       UtilAll.DigitsCreate(dt.Month,2) + "-" +
+                       UtilAll.DigitsCreate(dt.Day,2) + " " +
+                       UtilAll.DigitsCreate(dt.Hour,2) + ":" +
+                       UtilAll.DigitsCreate(dt.Minute,2) + ":" +
+                       UtilAll.DigitsCreate(dt.Second,2);
+       }
+
        //records date & time, useful to backup database without having strange chars on filename
        //used also on SQL when time wants to be stored also
        public static DateTime FromFile (string s)


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