[chronojump] JumpsRjFatigue graph WIP (it actually draws the points)



commit bab4ee6aede938dae75f16aad4324a93be5bd499
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 6 12:20:55 2020 +0200

    JumpsRjFatigue graph WIP (it actually draws the points)

 glade/app1.glade                | 189 ++++++++++++++++++++++++++++++++++------
 src/Makefile.am                 |   2 +
 src/gui/app1/chronojump.cs      |  49 +++++++----
 src/gui/app1/jumpsEvolution.cs  |   2 +-
 src/gui/app1/jumpsRjFatigue.cs  | 106 ++++++++++++++++++++++
 src/gui/cairo/jumpsRjFatigue.cs |  99 +++++++++++++++++++++
 src/jumpsRjFatigue.cs           |  91 +++++++++++++++++++
 7 files changed, 495 insertions(+), 43 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index c84be1b7..89d16a17 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -16506,13 +16506,13 @@ Resisted race analyzer</property>
                                                           </packing>
                                                         </child>
                                                         <child>
-                                                          <widget class="GtkRadioButton" 
id="radio_mode_contacts_jump_rj">
+                                                          <widget class="GtkRadioButton" 
id="radio_mode_contacts_jumps_rj_fatigue">
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
                                                             <property name="relief">half</property>
                                                             <property name="draw_indicator">False</property>
                                                             <property 
name="group">radio_mode_contacts_advanced</property>
-                                                            <signal name="toggled" 
handler="on_radio_mode_contacts_jump_rj_toggled" swapped="no"/>
+                                                            <signal name="toggled" 
handler="on_radio_mode_contacts_jumps_rj_fatigue_toggled" swapped="no"/>
                                                             <child>
                                                             <widget class="GtkHBox" id="hbox435">
                                                             <property name="visible">True</property>
@@ -20304,23 +20304,30 @@ Concentric</property>
                                                           </packing>
                                                         </child>
                                                         <child>
-                                                          <widget class="GtkVBox" id="vbox233">
+                                                          <widget class="GtkAlignment" 
id="alignment_jumps_rj">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
+                                                            <property name="top_padding">6</property>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox3">
+                                                            <widget class="GtkVBox" id="vbox233_jumps_rj">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox48">
+                                                            <widget class="GtkHBox" id="hbox50">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">20</property>
                                                             <child>
-                                                            <widget class="GtkLabel" id="label560">
+                                                            <widget class="GtkHBox" id="hbox330">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label">jump_rj</property>
+                                                            <property name="spacing">12</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label563">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Jump 
type</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
@@ -20329,12 +20336,12 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" id="button3">
-                                                            <property name="label" 
translatable="yes">button</property>
+                                                            <widget class="GtkHBox" 
id="hbox_combo_select_jumps_rj_fatigue">
                                                             <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">True</property>
-                                                            <signal name="clicked" 
handler="on_jumps_rj_analyze_fatigue_clicked" swapped="no"/>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
@@ -20344,18 +20351,144 @@ Concentric</property>
                                                             </child>
                                                             </widget>
                                                             <packing>
-                                                            <property name="expand">True</property>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox198">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">12</property>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="radio_jumps_rj_fatigue_heights">
+                                                            <property name="label" translatable="yes">Show 
height</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="radio_jumps_rj_fatigue_tv-tc">
+                                                            <property name="label" translatable="yes">Show 
flight time / contact time</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <property 
name="group">radio_jumps_rj_fatigue_heights</property>
+                                                            </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">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="hbox3">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkDrawingArea" 
id="drawingarea_jumps_rj_fatigue">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <signal name="button_press_event" 
handler="on_drawingarea_jumps_rj_fatigue_button_press_event" swapped="no"/>
+                                                            <signal name="expose_event" 
handler="on_drawingarea_jumps_rj_fatigue_expose_event" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox233">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_jumps_rj_fatigue_save_image">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="tooltip" translatable="yes">Save 
image</property>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox236">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_rj_fatigue_save">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_rj_fatigue_image_save">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                            </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>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
                                                           </widget>
                                                           <packing>
                                                             <property name="position">5</property>
@@ -24613,6 +24746,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -27478,18 +27614,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>
@@ -27526,6 +27650,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>
@@ -35527,6 +35663,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a151f17..cb5a36ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,6 +36,7 @@ SOURCES = \
        gui/cairo/jumpsDjOptimalFall.cs\
        gui/cairo/jumpsEvolution.cs\
        gui/cairo/jumpsProfile.cs\
+       gui/cairo/jumpsRjFatigue.cs\
        gui/cairo/jumpsWeightFVProfile.cs\
        gui/cairo/util.cs\
        gui/cairo/xy.cs\
@@ -203,6 +204,7 @@ SOURCES = \
        jumpsProfile.cs\
        jumpsDjOptimalFall.cs\
        jumpsEvolution.cs\
+       jumpsRjFatigue.cs\
        jumpsWeightFVProfile.cs\
        jumpType.cs\
        networks.cs\
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index f3c88abf..7810c70b 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -103,7 +103,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.RadioButton radio_mode_contacts_jumps_dj_optimal_fall;
        [Widget] Gtk.RadioButton radio_mode_contacts_jumps_weight_fv_profile;
        [Widget] Gtk.RadioButton radio_mode_contacts_jumps_evolution;
-       [Widget] Gtk.RadioButton radio_mode_contacts_jump_rj;
+       [Widget] Gtk.RadioButton radio_mode_contacts_jumps_rj_fatigue;
        [Widget] Gtk.RadioButton radio_mode_contacts_sprint;
        [Widget] Gtk.RadioButton radio_mode_contacts_advanced;
 
@@ -469,7 +469,7 @@ public partial class ChronoJumpWindow
        private string progName;
        private enum notebook_start_pages { PROGRAM, SENDLOG, EXITCONFIRM }
        private enum notebook_sup_pages { START, CONTACTS, ENCODER, SESSION, NETWORKSPROBLEMS, HELP }
-       private enum notebook_analyze_pages { STATISTICS, JUMPSPROFILE, JUMPSDJOPTIMALFALL, 
JUMPSWEIGHTFVPROFILE, JUMPSEVOLUTION, JUMP_RJ, SPRINT, FORCESENSOR, RACEENCODER }
+       private enum notebook_analyze_pages { STATISTICS, JUMPSPROFILE, JUMPSDJOPTIMALFALL, 
JUMPSWEIGHTFVPROFILE, JUMPSEVOLUTION, JUMPSRJFATIGUE, SPRINT, FORCESENSOR, RACEENCODER }
 
        private string runningFileName; //useful for knowing if there are two chronojump instances
 
@@ -1212,6 +1212,9 @@ public partial class ChronoJumpWindow
 
                        update_label_extra_window_jumps_rj_radiobutton_weight_percent_as_kg(
                                        (currentJumpRjType.HasWeight && 
extra_window_jumps_rj_radiobutton_weight.Active));
+
+                       if(notebook_analyze.CurrentPage == 
Convert.ToInt32(notebook_analyze_pages.JUMPSRJFATIGUE))
+                               jumpsRjFatigueDo(true); //calculate data
                }
                else if(current_menuitem_mode == Constants.Menuitem_modes.RUNSSIMPLE)
                        updateGraphRunsSimple();
@@ -2922,12 +2925,11 @@ public partial class ChronoJumpWindow
                        runEncoderProcessCancel = true;
                }
 
-
                button_contacts_bells.Sensitive = false;
                radio_mode_contacts_capture.Active = true;
                radio_mode_contacts_jumps_profile.Active = true;
                hbox_radio_mode_contacts_analyze_buttons.Visible = false;
-               radio_mode_contacts_jump_rj.Visible = false;
+               radio_mode_contacts_jumps_rj_fatigue.Visible = false;
                radio_mode_contacts_sprint.Visible = false;
                notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.STATISTICS);
                button_inspect_last_test_run_intervallic.Visible = false;
@@ -2994,14 +2996,16 @@ public partial class ChronoJumpWindow
                                vbox_contacts_graph_legend.Visible = false;
 
                                pixbufModeCurrent = new Pixbuf (null, Util.GetImagePath(false) + 
"image_jump_reactive.png");
+                       }
 
-                               if(radio_mode_contacts_jumps_profile.Active || 
radio_mode_contacts_jumps_dj_optimal_fall.Active ||
-                                               radio_mode_contacts_jumps_weight_fv_profile.Active || 
radio_mode_contacts_jumps_evolution.Active)
-                                       radio_mode_contacts_capture.Active = true;
+                       /*
+                       if(radio_mode_contacts_jumps_profile.Active || 
radio_mode_contacts_jumps_dj_optimal_fall.Active ||
+                                       radio_mode_contacts_jumps_weight_fv_profile.Active || 
radio_mode_contacts_jumps_evolution.Active)
+                               radio_mode_contacts_capture.Active = true;
+                               */
 
-                               if(radio_mode_contacts_analyze.Active)
-                                       radio_mode_contacts_analyze_buttons_visible (m);
-                       }
+                       if(radio_mode_contacts_analyze.Active)
+                               radio_mode_contacts_analyze_buttons_visible (m);
 
                        pixbufModeGrid = new Pixbuf (null, Util.GetImagePath(false) + "image_modes_jump.png");
                }
@@ -3338,23 +3342,23 @@ public partial class ChronoJumpWindow
                {
                        hbox_radio_mode_contacts_analyze_buttons.Visible = true;
                        hbox_radio_mode_contacts_analyze_jump_simple_buttons.Visible = true;
-                       radio_mode_contacts_jump_rj.Visible = false;
+                       radio_mode_contacts_jumps_rj_fatigue.Visible = false;
                        radio_mode_contacts_sprint.Visible = false;
                }
                else if(m == Constants.Menuitem_modes.JUMPSREACTIVE)
                {
                        hbox_radio_mode_contacts_analyze_buttons.Visible = true;
                        hbox_radio_mode_contacts_analyze_jump_simple_buttons.Visible = false;
-                       radio_mode_contacts_jump_rj.Visible = true;
+                       radio_mode_contacts_jumps_rj_fatigue.Visible = true;
                        radio_mode_contacts_sprint.Visible = false;
 
-                       radio_mode_contacts_jump_rj.Active = true;
+                       radio_mode_contacts_jumps_rj_fatigue.Active = true;
                }
                else if(m == Constants.Menuitem_modes.RUNSINTERVALLIC)
                {
                        hbox_radio_mode_contacts_analyze_buttons.Visible = true;
                        hbox_radio_mode_contacts_analyze_jump_simple_buttons.Visible = false;
-                       radio_mode_contacts_jump_rj.Visible = false;
+                       radio_mode_contacts_jumps_rj_fatigue.Visible = false;
                        radio_mode_contacts_sprint.Visible = true;
 
                        radio_mode_contacts_sprint.Active = true;
@@ -7065,6 +7069,14 @@ LogB.Debug("mc finished 5");
                                        jumpsEvolutionDo(true);
                                }
                        }
+                       else if (current_menuitem_mode == Constants.Menuitem_modes.JUMPSREACTIVE)
+                       {
+                               if(radio_mode_contacts_jumps_rj_fatigue.Active)
+                               {
+                                       notebook_analyze.CurrentPage = 
Convert.ToInt32(notebook_analyze_pages.JUMPSRJFATIGUE);
+                                       jumpsRjFatigueDo(true); //calculate data
+                               }
+                       }
                }
                else if(current_menuitem_mode == Constants.Menuitem_modes.FORCESENSOR)
                        notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.FORCESENSOR);
@@ -7113,10 +7125,13 @@ LogB.Debug("mc finished 5");
                if(radio_mode_contacts_advanced.Active)
                        notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.STATISTICS);
        }
-       private void on_radio_mode_contacts_jump_rj_toggled (object o, EventArgs args)
+       private void on_radio_mode_contacts_jumps_rj_fatigue_toggled (object o, EventArgs args)
        {
-               if(radio_mode_contacts_jump_rj.Active)
-                       notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.JUMP_RJ);
+               if(radio_mode_contacts_jumps_rj_fatigue.Active)
+               {
+                       notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.JUMPSRJFATIGUE);
+                       jumpsRjFatigueDo(true);
+               }
        }
        private void on_radio_mode_contacts_sprint_toggled (object o, EventArgs args)
        {
diff --git a/src/gui/app1/jumpsEvolution.cs b/src/gui/app1/jumpsEvolution.cs
index b37626d2..f510d835 100644
--- a/src/gui/app1/jumpsEvolution.cs
+++ b/src/gui/app1/jumpsEvolution.cs
@@ -112,7 +112,7 @@ public partial class ChronoJumpWindow
        }
        private void on_drawingarea_jumps_evolution_expose_event (object o, ExposeEventArgs args) 
        {
-               //needed to have mouse clicks at: on_drawingarea_jumps_weight_fv_profile_button_press_event ()
+               //needed to have mouse clicks at: on_drawingarea_jumps_evolution_button_press_event ()
                drawingarea_jumps_evolution.AddEvents((int) (Gdk.EventMask.ButtonPressMask | 
Gdk.EventMask.ButtonReleaseMask));
 
                jumpsEvolutionDo(false); //do not calculate data
diff --git a/src/gui/app1/jumpsRjFatigue.cs b/src/gui/app1/jumpsRjFatigue.cs
index e4817899..373e4b3a 100644
--- a/src/gui/app1/jumpsRjFatigue.cs
+++ b/src/gui/app1/jumpsRjFatigue.cs
@@ -28,7 +28,18 @@ using System.Collections.Generic; //List<T>
 
 public partial class ChronoJumpWindow 
 {
+       [Widget] Gtk.DrawingArea drawingarea_jumps_rj_fatigue;
+       [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;
 
+       JumpsRjFatigue jumpsRjFatigue;
+       JumpsRjFatigueGraph jumpsRjFatigueGraph;
+       CjComboSelectJumpsRj comboSelectJumpsRjFatigue;
+
+       /* OLD, first test
        private void on_jumps_rj_analyze_fatigue_clicked (object o, EventArgs args)
        {
                if(currentPerson == null || currentSession == null)
@@ -40,4 +51,99 @@ public partial class ChronoJumpWindow
                foreach(JumpRj jrj in l)
                        LogB.Information(jrj.ToString());
        }
+       */
+
+       // combo (start)
+       private void createComboSelectJumpsRjFatigue(bool create)
+       {
+               if(create)
+               {
+                       comboSelectJumpsRjFatigue = new CjComboSelectJumpsRj(combo_select_jumps_rj_fatigue, 
hbox_combo_select_jumps_rj_fatigue);
+                       combo_select_jumps_rj_fatigue = comboSelectJumpsRjFatigue.Combo;
+                       combo_select_jumps_rj_fatigue.Changed += new EventHandler 
(on_combo_select_jumps_rj_fatigue_changed);
+               } else {
+                       comboSelectJumpsRjFatigue.Fill();
+                       combo_select_jumps_rj_fatigue = comboSelectJumpsRjFatigue.Combo;
+               }
+               combo_select_jumps_rj_fatigue.Sensitive = true;
+       }
+       private void on_combo_select_jumps_rj_fatigue_changed(object o, EventArgs args)
+       {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+
+               jumpsRjFatigueDo(true);
+       }
+       // combo (end)
+
+       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
+               {
+                       button_jumps_rj_fatigue_save_image.Sensitive = false;
+                       return;
+               }
+
+               if(jumpsRjFatigue == null) {
+                       jumpsRjFatigue = new JumpsRjFatigue();
+                       calculateData = true;
+               }
+
+//             string jumpType = comboSelectJumpsRjFatigue.GetSelectedNameEnglish();
+               string jumpType = "";
+
+               if(calculateData)
+                       jumpsRjFatigue.Calculate(currentSession.UniqueID, currentPerson.UniqueID, jumpType);
+
+               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;
+
+               } else {
+                       //regular constructor
+                       jumpsRjFatigueGraph = new JumpsRjFatigueGraph(
+                                       jumpsRjFatigue.Point_l,
+                                       jumpsRjFatigue.Slope,
+                                       jumpsRjFatigue.Intercept,
+                                       drawingarea_jumps_rj_fatigue,
+                                       currentPerson.Name, jumpType, currentSession.DateShort);
+                       jumpsRjFatigueGraph.Do();
+
+                       button_jumps_rj_fatigue_save_image.Sensitive = true;
+               }
+       }
+
+       private void on_drawingarea_jumps_rj_fatigue_expose_event (object o, ExposeEventArgs args)
+       {
+               //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
+               //data is calculated on switch page (at notebook_capture_analyze) or on change person
+       }
+
+       private void on_drawingarea_jumps_rj_fatigue_button_press_event (object o, ButtonPressEventArgs args)
+       {
+               /*
+               //if there is no data and nothing to show, nothing to press, and also this is null
+               if(jumpsRjFatigueGraph == null)
+                       return;
+
+               LogB.Information("Button press done!");
+
+               //redo the graph to delete previous rectangles of previous mouse clicks
+               jumpsRjFatigueGraph.Do();
+               LogB.Information(string.Format("Mouse X: {0}; Mouse Y: {1}", args.Event.X, args.Event.Y));
+               jumpsRjFatigueGraph.CalculateAndWriteRealXY(args.Event.X, args.Event.Y);
+               */
+       }
+
+
+
 }
diff --git a/src/gui/cairo/jumpsRjFatigue.cs b/src/gui/cairo/jumpsRjFatigue.cs
new file mode 100644
index 00000000..5391d48d
--- /dev/null
+++ b/src/gui/cairo/jumpsRjFatigue.cs
@@ -0,0 +1,99 @@
+
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Copyright (C) 2020   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.Collections.Generic; //List
+using Gtk;
+using Cairo;
+
+
+public class JumpsRjFatigueGraph : CairoXY
+{
+       //constructor when there are no points
+       public JumpsRjFatigueGraph (DrawingArea area, string jumpType)//, string title, string jumpType, 
string date)
+       {
+               this.area = area;
+
+               initGraph();
+
+               g.SetFontSize(16);
+               //printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
+               //              string.Format("Need to execute jumps: {0}.", jumpType), g, true);
+
+               endGraph();
+       }
+
+       //regular constructor
+       public JumpsRjFatigueGraph (
+                       List<PointF> point_l, double slope, double intercept,
+                       DrawingArea area, string title, string jumpType, string date)
+       {
+               this.point_l = point_l;
+               this.slope = slope;
+               this.intercept = intercept;
+               this.area = area;
+               this.title = title;
+               this.jumpType = jumpType;
+               this.date = date;
+
+               xVariable = "Count";
+               yVariable = "Height";
+               xUnits = "";
+               yUnits = "cm";
+       }
+
+       public override void Do()
+       {
+               LogB.Information("at JumpsRjFatigueGraph.Do");
+               initGraph();
+
+                findPointMaximums(false);
+                //findAbsoluteMaximums();
+               paintAxisAndGrid(gridTypes.HORIZONTALLINES);
+
+               plotPredictedLine(predictedLineTypes.STRAIGHT, predictedLineCrossMargins.TOUCH);
+               plotRealPoints();
+
+               writeTitle();
+
+               endGraph();
+       }
+
+       //here X is year, add/subtract third of a year
+       protected override void separateMinXMaxXIfNeeded()
+       {
+               if(minX == maxX || maxX - minX < .1) //<.1 means that maybe we will not see any vertical bar 
on grid, enlarge it
+               {
+                       minX -= .1;
+                       maxX += .1;
+               }
+       }
+
+       protected override void writeTitle()
+       {
+               int ypos = -6;
+
+               writeTextAtRight(ypos++, title, true);
+               writeTextAtRight(ypos++, "Jumptype: " + jumpType, false);
+               writeTextAtRight(ypos++, date, false);
+       }
+
+}
diff --git a/src/jumpsRjFatigue.cs b/src/jumpsRjFatigue.cs
new file mode 100644
index 00000000..c9bceedc
--- /dev/null
+++ b/src/jumpsRjFatigue.cs
@@ -0,0 +1,91 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Copyright (C) 2020   Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.Collections.Generic; //List
+
+//TODO: very similar to JumpsDjOptimalFall, jumpsEvolution, refactorize if needed
+
+public class JumpsRjFatigue
+{
+       private List<PointF> point_l;
+       LeastSquaresLine ls;
+
+       //constructor
+       public JumpsRjFatigue()
+       {
+       }
+       
+       public void Calculate (int sessionID, int personID, string jumpType)
+       {
+               //1 get data
+                List<JumpRj> jrj_l = SqliteJumpRj.SelectJumps (false, sessionID, personID, jumpType);
+
+               //2 convert to list of PointF
+               point_l = new List<PointF>();
+               int currentSession = -1;
+                foreach(JumpRj j in jrj_l)
+               {
+                       List<double> y_l = j.HeightList;
+                       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
+               }
+
+               //3 get LeastSquaresLine (straight line)
+               ls = new LeastSquaresLine();
+               ls.Calculate(point_l);
+
+               //4 print data
+               LogB.Information(string.Format("slope = {0}; intercept = {1}", ls.Slope, ls.Intercept));
+       }
+
+       public double GetMaxValue()
+       {
+               double maxValue = 0;
+                foreach(PointF p in point_l)
+               {
+                       if(p.X > maxValue)
+                               maxValue = p.X;
+                       if(p.Y > maxValue)
+                               maxValue = p.Y;
+               }
+
+               return maxValue;
+       }
+
+       public List<PointF> Point_l
+       {
+               get { return point_l; }
+       }
+
+       public double Slope
+       {
+               get { return ls.Slope; }
+       }
+
+       public double Intercept
+       {
+               get { return ls.Intercept; }
+       }
+}



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