[chronojump] Stiffness on jumps, jumpsRj results



commit 2bf86afc7c81853ec01a17cc9152d0a7829cf798
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jan 8 01:07:02 2015 +0100

    Stiffness on jumps, jumpsRj results

 glade/chronojump.glade    |  340 ++++++++++++++++++++++++++++++++++++---------
 src/constants.cs          |   32 +++++
 src/gui/chronojump.cs     |   28 ++++-
 src/gui/preferences.cs    |   65 ++--------
 src/jump.cs               |   18 ++-
 src/sqlite/preferences.cs |    2 +
 src/treeViewJump.cs       |   33 +++++-
 src/util.cs               |   21 +++-
 8 files changed, 409 insertions(+), 130 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index b36b30f..f2ae2cc 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6372,6 +6372,9 @@ Second Chronopic to platforms.</property>
                                                         <child>
                                                           <placeholder/>
                                                         </child>
+                                                        <child>
+                                                          <placeholder/>
+                                                        </child>
                                                       </widget>
                                                       <packing>
                                                         <property name="expand">True</property>
@@ -7120,6 +7123,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -8120,6 +8126,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -8761,6 +8770,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -9153,7 +9165,6 @@ Second Chronopic to platforms.</property>
                                       <widget class="GtkNotebook" id="notebook_results">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="show_tabs">False</property>
                                         <property name="show_border">False</property>
                                         <property name="scrollable">True</property>
                                         <signal name="switch_page" handler="on_notebook_change_by_user" 
swapped="no"/>
@@ -9299,6 +9310,107 @@ Second Chronopic to platforms.</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox139">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_jumps_result_help_power">
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_jumps_jumpsRj_result_help_power_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox140">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkImage" id="image42">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-info</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label119">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Power</property>
+                                                            </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="expand">False</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_jumps_result_help_stiffness">
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_jumps_jumpsRj_result_help_stiffness_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox141">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkImage" id="image43">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-info</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label120">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Stiffness</property>
+                                                            </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="expand">False</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="pack_type">end</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                           </widget>
                                                           <packing>
                                                             <property name="expand">False</property>
@@ -9542,6 +9654,107 @@ Second Chronopic to platforms.</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox142">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_jumps_rj_result_help_power">
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_jumps_jumpsRj_result_help_power_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox143">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkImage" id="image53">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-info</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label121">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Power</property>
+                                                            </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="expand">False</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_jumps_rj_result_help_stiffness">
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_jumps_jumpsRj_result_help_stiffness_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox145">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkImage" id="image54">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-info</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label122">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Stiffness</property>
+                                                            </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="expand">False</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="pack_type">end</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                           </widget>
                                                           <packing>
                                                             <property name="expand">False</property>
@@ -18730,6 +18943,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -19279,6 +19495,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -20320,6 +20539,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -20418,6 +20640,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -29400,6 +29625,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -31329,6 +31572,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                 <child>
                                   <placeholder/>
                                 </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
                               </widget>
                             </child>
                           </widget>
@@ -31916,6 +32162,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -32325,79 +32574,23 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkHBox" id="hbox1">
+                                              <widget class="GtkCheckButton" id="checkbutton_power">
+                                                <property name="label" translatable="yes">Power</property>
                                                 <property name="visible">True</property>
-                                                <property name="can_focus">False</property>
-                                                <property name="spacing">12</property>
-                                                <child>
-                                                  <widget class="GtkCheckButton" id="checkbutton_power">
-                                                    <property name="label" 
translatable="yes">Power</property>
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">False</property>
-                                                    <property name="use_underline">True</property>
-                                                    <property name="draw_indicator">True</property>
-                                                    <signal name="clicked" 
handler="on_checkbutton_power_clicked" swapped="no"/>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">False</property>
-                                                    <property name="position">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <widget class="GtkButton" id="button_help_power">
-                                                    <property name="label">gtk-help</property>
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">True</property>
-                                                    <property name="use_stock">True</property>
-                                                    <signal name="clicked" 
handler="on_button_help_power_clicked" swapped="no"/>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">True</property>
-                                                    <property name="position">1</property>
-                                                  </packing>
-                                                </child>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="use_underline">True</property>
+                                                <property name="draw_indicator">True</property>
                                               </widget>
                                             </child>
                                             <child>
-                                              <widget class="GtkHBox" id="hbox13">
+                                              <widget class="GtkCheckButton" id="checkbutton_stiffness">
+                                                <property name="label" 
translatable="yes">Stiffness</property>
                                                 <property name="visible">True</property>
-                                                <property name="can_focus">False</property>
-                                                <property name="spacing">12</property>
-                                                <child>
-                                                  <widget class="GtkCheckButton" id="checkbutton_stiffness">
-                                                    <property name="label" 
translatable="yes">Stiffness</property>
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">False</property>
-                                                    <property name="use_underline">True</property>
-                                                    <property name="draw_indicator">True</property>
-                                                    <signal name="clicked" 
handler="on_checkbutton_stiffness_clicked" swapped="no"/>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">False</property>
-                                                    <property name="position">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <widget class="GtkButton" id="button_help_stiffness">
-                                                    <property name="label">gtk-help</property>
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">True</property>
-                                                    <property name="use_stock">True</property>
-                                                    <signal name="clicked" 
handler="on_button_help_stiffness_clicked" swapped="no"/>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">True</property>
-                                                    <property name="position">1</property>
-                                                  </packing>
-                                                </child>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="use_underline">True</property>
+                                                <property name="draw_indicator">True</property>
                                               </widget>
                                               <packing>
                                                 <property name="left_attach">1</property>
@@ -34525,6 +34718,9 @@ show elevation as:</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -34738,6 +34934,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -34966,6 +35165,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/constants.cs b/src/constants.cs
index f389e9b..5526130 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -618,6 +618,38 @@ public class Constants
                ENTRY, ENTRY2, ENTRY3, SPININT, SPININT2, SPININT3, SPINDOUBLE, HBOXSPINDOUBLE2, 
                HEIGHTMETRIC, COMBO, COMBOALLNONESELECTED, TEXTVIEW, TREEVIEW
        }
+
+
+       public static string HelpPower =
+               Catalog.GetString("On jumps results tab, power is calculated depending on jump type:") + 
+               "\n\n" +
+               //Catalog.GetString("Jumps with TC & TF: Bosco Relative Power (W/Kg)") + 
+               //"\n" +
+               //Catalog.GetString("P = 24.6 * (Total time + Flight time) / Contact time") + 
+               Catalog.GetString("Jumps with TC and TF:") + " " + Catalog.GetString("Developed by Chronojump 
team") + 
+               "\n" +
+               Catalog.GetString("Calcule the potential energies on fall and after the jump.") + "\n" + 
+               Catalog.GetString("Divide them by time during force is applied.") +
+               "\n\n" +
+               //P = mass * g * ( fallHeight + 1.226 * Math.Pow(tf,2) ) / (Double)tt;
+               "P = " + Catalog.GetString("mass") + " * g * ( " + 
+               Catalog.GetString("falling height") + " + 1.226 * " + Catalog.GetString("flight time") + " ^ 
2 ) / " + 
+               Catalog.GetString("total_time") +
+               "\n\n" +
+               Catalog.GetString("Jumps without TC: Lewis Peak Power 1974 (W)") + 
+               "\n\n" +
+               Catalog.GetString("P = SQRT(4.9) * 9.8 * (body weight+extra weight) * SQRT(jump height in 
meters)") + 
+               "\n\n" +
+               Catalog.GetString("If you want to use other formulas, go to Statistics.");
+       
+       public static string HelpStiffness =
+               "M: " + Catalog.GetString("Mass") + "\n" +
+               "Tc: " + Catalog.GetString("Contact Time") + "\n" +
+               "Tf: " + Catalog.GetString("Flight Time") + "\n\n" +
+               Catalog.GetString("See:") + "\n" +
+               "Dalleau, G; Belli, A; Viale, F; Lacour, JR; and Bourdin, M. (2004). " + 
+               "A simple method for field measurements of leg stiffness in hopping. " +
+               "Int J Sports Med 25: 170–176";
        
        public const string PrefVersionAvailable = "versionAvailable";
        
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 19dacbc..22f1671 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -170,6 +170,11 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_video_play_selected_jump_rj;
        [Widget] Gtk.Button button_delete_selected_jump_rj;
        [Widget] Gtk.Button button_repair_selected_jump_rj;
+
+       [Widget] Gtk.Button button_jumps_result_help_power;
+       [Widget] Gtk.Button button_jumps_result_help_stiffness;
+       [Widget] Gtk.Button button_jumps_rj_result_help_power;
+       [Widget] Gtk.Button button_jumps_rj_result_help_stiffness;
        
        //runs
        [Widget] Gtk.MenuItem menu_execute_simple_runs1;
@@ -845,7 +850,6 @@ public partial class ChronoJumpWindow
                
                changeVideoButtons(preferences.videoOn);
 
-
                //load preferences, update radios, but not update database
                update_sqlite_at_runs_speed_radios = false;
 
@@ -1427,6 +1431,10 @@ public partial class ChronoJumpWindow
 
                //the glade cursor_changed does not work on mono 1.2.5 windows
                tv.CursorChanged += on_treeview_jumps_cursor_changed; 
+       
+               //show or hide help_power and help_stiffness depending on preferences
+               button_jumps_result_help_power.Visible = preferences.showPower;
+               button_jumps_result_help_stiffness.Visible = preferences.showStiffness;
        }
 
        private void fillTreeView_jumps (string filter) {
@@ -1505,6 +1513,10 @@ public partial class ChronoJumpWindow
 
                //the glade cursor_changed does not work on mono 1.2.5 windows
                tv.CursorChanged += on_treeview_jumps_rj_cursor_changed; 
+       
+               //show or hide help_power and help_stiffness depending on preferences
+               button_jumps_rj_result_help_power.Visible = preferences.showPower;
+               button_jumps_rj_result_help_stiffness.Visible = preferences.showStiffness;
        }
 
        private void fillTreeView_jumps_rj (string filter) {
@@ -5624,6 +5636,20 @@ LogB.Debug("X");
                //notebooks_change(6); see "notebooks_change sqlite problem"
                LogB.Information("Repair selected multichronopic");
        }
+
+       /* ---------------------------------------------------------
+        * ----------------  Info on power and stiffness -----------
+        *  --------------------------------------------------------
+        */
+
+
+       private void on_button_jumps_jumpsRj_result_help_power_clicked (object o, EventArgs args) {
+               new DialogMessage(Constants.MessageTypes.INFO, Constants.HelpPower);
+       }
+       private void on_button_jumps_jumpsRj_result_help_stiffness_clicked (object o, EventArgs args) {
+               new DialogMessage(Constants.MessageTypes.INFO, Constants.HelpStiffness, 
"hbox_stiffness_formula");
+       }
+
        
        /* ---------------------------------------------------------
         * ----------------  AUTO MODE -----------------------------
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index ffadc04..c2bbd41 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -56,9 +56,6 @@ public class PreferencesWindow {
        [Widget] Gtk.CheckButton checkbutton_initial_speed;
        [Widget] Gtk.CheckButton checkbutton_angle;
        
-       [Widget] Gtk.Button button_help_power;
-       [Widget] Gtk.Button button_help_stiffness;
-       
        [Widget] Gtk.CheckButton checkbutton_show_tv_tc_index;
        [Widget] Gtk.Box hbox_indexes;
        [Widget] Gtk.RadioButton radiobutton_show_q_index;
@@ -152,21 +149,15 @@ public class PreferencesWindow {
                PreferencesWindowBox.combo_decimals.Active = UtilGtk.ComboMakeActive(
                                decs, preferences.digitsNumber.ToString());
 
-               if(preferences.showPower) {
+               if(preferences.showPower)
                        PreferencesWindowBox.checkbutton_power.Active = true; 
-                       PreferencesWindowBox.button_help_power.Sensitive = true;
-               } else {
+               else
                        PreferencesWindowBox.checkbutton_power.Active = false; 
-                       PreferencesWindowBox.button_help_power.Sensitive = false;
-               }
                
-               if(preferences.showStiffness) {
+               if(preferences.showStiffness)
                        PreferencesWindowBox.checkbutton_stiffness.Active = true; 
-                       PreferencesWindowBox.button_help_stiffness.Sensitive = true;
-               } else {
+               else
                        PreferencesWindowBox.checkbutton_stiffness.Active = false; 
-                       PreferencesWindowBox.button_help_stiffness.Sensitive = false;
-               }
                
                if(preferences.showInitialSpeed)  
                        PreferencesWindowBox.checkbutton_initial_speed.Active = true; 
@@ -316,49 +307,6 @@ public class PreferencesWindow {
                        hbox_indexes.Hide();
        }
                
-       private void on_checkbutton_power_clicked (object o, EventArgs args) {
-               button_help_power.Sensitive = checkbutton_power.Active;
-       }
-       private void on_button_help_power_clicked (object o, EventArgs args) {
-               new DialogMessage(Constants.MessageTypes.INFO, 
-                               Catalog.GetString("On jumps results tab, power is calculated depending on 
jump type:") + 
-                               "\n\n" +
-                               //Catalog.GetString("Jumps with TC & TF: Bosco Relative Power (W/Kg)") + 
-                               //"\n" +
-                               //Catalog.GetString("P = 24.6 * (Total time + Flight time) / Contact time") + 
-                               Catalog.GetString("Jumps with TC and TF:") + " " + 
Catalog.GetString("Developed by Chronojump team") + 
-                               "\n" +
-                               Catalog.GetString("Calcule the potential energies on fall and after the 
jump.") + "\n" + 
-                               Catalog.GetString("Divide them by time during force is applied.") +
-                               "\n\n" +
-                               //P = mass * g * ( fallHeight + 1.226 * Math.Pow(tf,2) ) / (Double)tt;
-                               "P = " + Catalog.GetString("mass") + " * g * ( " + 
-                               Catalog.GetString("falling height") + " + 1.226 * " + 
Catalog.GetString("flight time") + " ^ 2 ) / " + 
-                               Catalog.GetString("total_time") +
-                               "\n\n" +
-                               Catalog.GetString("Jumps without TC: Lewis Peak Power 1974 (W)") + 
-                               "\n\n" +
-                               Catalog.GetString("P = SQRT(4.9) * 9.8 * (body weight+extra weight) * 
SQRT(jump height in meters)") + 
-                               "\n\n" +
-                               Catalog.GetString("If you want to use other formulas, go to Statistics."));
-       }
-       
-       private void on_checkbutton_stiffness_clicked (object o, EventArgs args) {
-               button_help_stiffness.Sensitive = checkbutton_stiffness.Active;
-       }
-       private void on_button_help_stiffness_clicked (object o, EventArgs args) {
-               new DialogMessage(Constants.MessageTypes.INFO, 
-                               "M: " + Catalog.GetString("Mass") + "\n" +
-                               "Tc: " + Catalog.GetString("Contact Time") + "\n" +
-                               "Tf: " + Catalog.GetString("Flight Time") + "\n\n" +
-                               Catalog.GetString("See:") + "\n" +
-                               "Dalleau, G; Belli, A; Viale, F; Lacour, JR; and Bourdin, M. (2004). " + 
-                               "A simple method for field measurements of leg stiffness in hopping. " +
-                               "Int J Sports Med 25: 170–176"
-                               ,
-                               "hbox_stiffness_formula");
-       }
-       
        void on_button_cancel_clicked (object o, EventArgs args)
        {
                PreferencesWindowBox.preferences_win.Hide();
@@ -599,6 +547,11 @@ public class PreferencesWindow {
                        preferences.showPower = PreferencesWindowBox.checkbutton_power.Active;
                }
                
+               if( preferences.showStiffness != PreferencesWindowBox.checkbutton_stiffness.Active ) {
+                       SqlitePreferences.Update("showStiffness", 
PreferencesWindowBox.checkbutton_stiffness.Active.ToString(), true);
+                       preferences.showStiffness = PreferencesWindowBox.checkbutton_stiffness.Active;
+               }
+               
                if( preferences.showInitialSpeed != PreferencesWindowBox.checkbutton_initial_speed.Active ) {
                        SqlitePreferences.Update("showInitialSpeed", 
PreferencesWindowBox.checkbutton_initial_speed.Active.ToString(), true);
                        preferences.showInitialSpeed = PreferencesWindowBox.checkbutton_initial_speed.Active;
diff --git a/src/jump.cs b/src/jump.cs
index f4c24e2..a4cfd7f 100644
--- a/src/jump.cs
+++ b/src/jump.cs
@@ -15,7 +15,7 @@
  *  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) 2004-2009   Xavier de Blas <xaviblas gmail com> 
+ *  Copyright (C) 2004-2015   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -80,6 +80,12 @@ public class Jump : Event
                                weight, description, 
                                angle, simulated);
        }
+       
+       public virtual double Stiffness(double personMassInKg, double extraMass) 
+       {
+               return Util.GetStiffness(personMassInKg, extraMass, tv, tc);
+       }       
+       
 
        public override string ToString() {
                return uniqueID + ":" + personID + ":" + sessionID + ":" + type + ":" + tv + ":" + tc; //...
@@ -92,7 +98,7 @@ public class Jump : Event
        public virtual bool TypeHasFall {
                get { return SqliteJumpType.HasFall("jumpType", type); } //jumpType is the table name
        }
-       
+
        public double Tv {
                get { return tv; }
                set { tv = value; }
@@ -196,6 +202,13 @@ public class JumpRj : Jump
                                angleString, simulated);
        }
 
+
+       public override double Stiffness(double personMassInKg, double extraMass) 
+       {
+               return Util.GetStiffness(personMassInKg, extraMass, TvAvg, TcAvg);
+       }
+       
+
        public string Limited
        {
                get { return limited; }
@@ -232,6 +245,7 @@ public class JumpRj : Jump
                get { return Util.GetAverage (tcString); }
        }
        
+               
        public string TvString
        {
                get { return tvString; }
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 8048eb7..8a2c8bb 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -149,6 +149,8 @@ class SqlitePreferences : Sqlite
                                preferences.digitsNumber = Convert.ToInt32(reader[1].ToString());
                        else if(reader[0].ToString() == "showPower")
                                preferences.showPower = reader[1].ToString() == "True";
+                       else if(reader[0].ToString() == "showStiffness")
+                               preferences.showStiffness = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "showInitialSpeed")
                                preferences.showInitialSpeed = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "showAngle")
diff --git a/src/treeViewJump.cs b/src/treeViewJump.cs
index 629ce67..724c6a4 100644
--- a/src/treeViewJump.cs
+++ b/src/treeViewJump.cs
@@ -31,7 +31,8 @@ public class TreeViewJumps : TreeViewEvent
        protected string weightName = Catalog.GetString("Extra weight");
        protected string fallName = Catalog.GetString("Fall") + "\n(cm)";
        protected string heightName = Catalog.GetString("Height") + "\n(cm)";
-       protected string powerName = Catalog.GetString("Power") + "\n(" + Catalog.GetString("see 
Preferences") +")";
+       protected string powerName = Catalog.GetString("Power");
+       protected string stiffnessName = Catalog.GetString("Stiffness");
        protected string initialSpeedName = Catalog.GetString("Initial Speed");
        protected string angleName = Catalog.GetString("Angle");
 
@@ -89,6 +90,8 @@ public class TreeViewJumps : TreeViewEvent
                
                if (preferences.showPower)  
                        i ++;
+               if (preferences.showStiffness)  
+                       i ++;
                if (preferences.showInitialSpeed) 
                        i ++;
                if (preferences.showAngle) 
@@ -105,6 +108,8 @@ public class TreeViewJumps : TreeViewEvent
                
                if (preferences.showPower)  
                        i ++;
+               if (preferences.showStiffness)  
+                       i ++;
                if (preferences.showInitialSpeed) 
                        i ++;
                if (preferences.showAngle) 
@@ -128,6 +133,8 @@ public class TreeViewJumps : TreeViewEvent
                
                if (preferences.showPower)  
                        columnsString[i++] = powerName;
+               if (preferences.showStiffness)  
+                       columnsString[i++] = stiffnessName;
                if (preferences.showInitialSpeed) 
                        columnsString[i++] = initialSpeedName;
                if (preferences.showAngle) 
@@ -211,6 +218,8 @@ public class TreeViewJumps : TreeViewEvent
                        } else
                                myData[count++] = "0";
                }
+               if (preferences.showStiffness)
+                       myData[count++] = Util.TrimDecimals(newJump.Stiffness(personWeight, 
weightInKg).ToString(), pDN);
                if (preferences.showInitialSpeed) 
                        myData[count++] = Util.TrimDecimals(Util.GetInitialSpeed(newJump.Tv.ToString(), 
preferences.metersSecondsPreferred), pDN);
                if (preferences.showAngle) 
@@ -320,6 +329,8 @@ public class TreeViewJumpsRj : TreeViewJumps
                myData[count++] = ""; //height
                if (preferences.showPower)
                        myData[count++] = "";
+               if (preferences.showStiffness)
+                       myData[count++] = "";
                if (preferences.showInitialSpeed) 
                        myData[count++] = "";
                if (preferences.showQIndex)
@@ -370,6 +381,12 @@ public class TreeViewJumpsRj : TreeViewJumps
                                        Util.GetDjPower(Convert.ToDouble(thisTc), Convert.ToDouble(thisTv), 
                                                (personWeight + weightInKg), myFall).ToString(), pDN);
                }
+               if (preferences.showStiffness) {
+                       //use directly Util.GetStiffness because we want to get from this specific subjump, 
not all the reactive jump.
+                       myData[count++] = Util.TrimDecimals(
+                                       Util.GetStiffness(personWeight, weightInKg, Convert.ToDouble(thisTv), 
Convert.ToDouble(thisTc)).ToString(), 
+                                       pDN);
+               }
                if (preferences.showInitialSpeed) 
                        myData[count++] = Util.TrimDecimals(Util.GetInitialSpeed(
                                                thisTv, preferences.metersSecondsPreferred), pDN);
@@ -403,6 +420,8 @@ public class TreeViewJumpsRj : TreeViewJumps
                myData[count++] = ""; //height
                if (preferences.showPower)
                        myData[count++] = "";
+               if (preferences.showStiffness)
+                       myData[count++] = "";
                if (preferences.showInitialSpeed) 
                        myData[count++] = ""; 
                if (preferences.showQIndex || preferences.showDjIndex) 
@@ -457,6 +476,16 @@ public class TreeViewJumpsRj : TreeViewJumps
                         * in order to calculate the total, AVG, SD using that data
                         */
                }
+               if (preferences.showStiffness) {
+                       myData[count++] = "";
+
+                       /* TODO:
+                        * it can be done using AVG values like the other AVG statistics,
+                        * but result will not be the same than making the avg of the different power values 
for each row
+                        * for this reason is best to first calculate the different values of each column and 
store separately
+                        * in order to calculate the total, AVG, SD using that data
+                        */
+               }
                if (preferences.showInitialSpeed) 
                        myData[count++] = Util.TrimDecimals(
                                        Util.GetInitialSpeed(
@@ -511,6 +540,8 @@ public class TreeViewJumpsRj : TreeViewJumps
                myData[count++] = ""; //height
                if (preferences.showPower)
                        myData[count++] = "";
+               if (preferences.showStiffness)
+                       myData[count++] = "";
                if (preferences.showInitialSpeed) 
                        myData[count++] = "";
                if (preferences.showQIndex || preferences.showDjIndex) 
diff --git a/src/util.cs b/src/util.cs
index 0ee396b..07b8395 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -15,7 +15,7 @@
  *  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) 2004-2014   Xavier de Blas <xaviblas gmail com> 
+ *  Copyright (C) 2004-2015   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -587,6 +587,25 @@ public class Util
                return text.Substring(i);
        }
 
+       public static double GetStiffness(double personMassInKg, double extraMass, double tv, double tc) 
+       {
+               double totalMass = personMassInKg + extraMass;
+               
+               //return if mass is zero or there's no contact time
+               if( totalMass == 0 || tv == 0 || tc == 0)
+                       return 0;
+
+               double stiffness;
+               try {
+                       stiffness = totalMass * Math.PI * ( tv + tc ) / ( Math.Pow(tc,2) * ( (tv+tc)/Math.PI 
- tc/4 ) );
+               } catch { 
+                       return 0;
+               }
+
+               return stiffness;
+       }
+       
+
        public static string GetInitialSpeed (string time, bool metersSecondsPreferred) 
        {
                double height = Convert.ToDouble( GetHeightInCentimeters(time) );


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