[chronojump] Added lewis power on jump treeview
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Added lewis power on jump treeview
- Date: Fri, 5 Mar 2010 09:48:44 +0000 (UTC)
commit 7ea930eadccdeed796acb29eda2beeb17c759c11
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Mar 5 17:47:35 2010 +0800
Added lewis power on jump treeview
glade/chronojump.glade | 34 ++++++++++++++++++++++++++++------
src/gui/preferences.cs | 14 ++++++++++++--
src/treeViewJump.cs | 44 ++++++++++++++++++++++++++++++++++----------
src/util.cs | 12 ++++++++++++
4 files changed, 86 insertions(+), 18 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index acb371c..dfb7c2f 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -1747,12 +1747,13 @@
</child>
<child>
<widget class="GtkCheckButton" id="checkbutton_power">
- <property name="label" translatable="yes">Show power on Drop Jump</property>
+ <property name="label" translatable="yes">Show 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"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -1761,6 +1762,27 @@
</packing>
</child>
<child>
+ <widget class="GtkTextView" id="textview_power">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="pixels_below_lines">2</property>
+ <property name="editable">False</property>
+ <property name="wrap_mode">word</property>
+ <property name="cursor_visible">False</property>
+ <property name="text" translatable="yes">On main window, power is calculated depending on jump type:
+-Jumps with TC & TF: Bosco Relative Power (W/Kg)
+ P = 24.6 * (Total time + Flight time) / Contact time
+-Jumps without TC: Lewis Peak Power 1974 (W)
+ P = SQRT(4.9) * 9.8 * (body weight+extra weight) *
+ SQRT(jump height in meters)
+If you want to use other formulas, go to Tools / Statistics.</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkCheckButton" id="checkbutton_initial_speed">
<property name="label" translatable="yes">Show initial speed</property>
<property name="visible">True</property>
@@ -1772,7 +1794,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -1787,7 +1809,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -1803,7 +1825,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -1845,7 +1867,7 @@
</widget>
<packing>
<property name="expand">False</property>
- <property name="position">5</property>
+ <property name="position">6</property>
</packing>
</child>
<child>
@@ -2002,7 +2024,7 @@ show elevation as:</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">2</property>
- <property name="position">6</property>
+ <property name="position">7</property>
</packing>
</child>
</widget>
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index b413dab..07823ee 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -56,6 +56,7 @@ public class PreferencesWindow {
[Widget] Gtk.RadioButton radio_speed_km;
[Widget] Gtk.RadioButton radio_weight_percent;
[Widget] Gtk.RadioButton radio_weight_kg;
+ [Widget] Gtk.TextView textview_power;
// [Widget] Gtk.Box hbox_language_row;
@@ -117,10 +118,13 @@ public class PreferencesWindow {
else
PreferencesWindowBox.checkbutton_height.Active = false;
- if(showPower)
+ if(showPower) {
PreferencesWindowBox.checkbutton_power.Active = true;
- else
+ PreferencesWindowBox.textview_power.Show();
+ } else {
PreferencesWindowBox.checkbutton_power.Active = false;
+ PreferencesWindowBox.textview_power.Hide();
+ }
if(showInitialSpeed)
@@ -217,6 +221,12 @@ public class PreferencesWindow {
hbox_indexes.Hide();
}
+ private void on_checkbutton_power_clicked (object o, EventArgs args) {
+ if(checkbutton_power.Active)
+ textview_power.Show();
+ else
+ textview_power.Hide();
+ }
void on_button_cancel_clicked (object o, EventArgs args)
{
diff --git a/src/treeViewJump.cs b/src/treeViewJump.cs
index e02cbe2..e082b97 100644
--- a/src/treeViewJump.cs
+++ b/src/treeViewJump.cs
@@ -38,7 +38,7 @@ public class TreeViewJumps : TreeViewEvent
protected string weightName = Catalog.GetString("Weight");
protected string fallName = Catalog.GetString("Fall") + "\n(cm)";
protected string heightName = Catalog.GetString("Height") + "\n(cm)";
- protected string powerName = Catalog.GetString("Power") + "\n(W/Kg)";
+ protected string powerName = Catalog.GetString("Power") + "\n(" + Catalog.GetString("see Preferences") +")";
protected string initialSpeedName = Catalog.GetString("Initial Speed");
protected string angleName = Catalog.GetString("Angle");
@@ -46,9 +46,12 @@ public class TreeViewJumps : TreeViewEvent
protected string qIndexName = "Q Index" + "\n(%)";
protected string djIndexName = "Dj Index" + "\n(%)";
- protected double personWeight;
protected bool metersSecondsPreferred;
+ //to calculate potency
+ protected double personWeight;
+ protected double weightInKg;
+
public TreeViewJumps ()
{
}
@@ -168,13 +171,18 @@ public class TreeViewJumps : TreeViewEvent
myJump.Description = myStringOfData[9].ToString();
myJump.Simulated = Convert.ToInt32(myStringOfData[11].ToString());
+ //to calculate potency
+ personWeight = Convert.ToDouble(myStringOfData[12]);
+ weightInKg = Util.WeightFromPercentToKg(
+ Convert.ToDouble(myStringOfData[8]),
+ personWeight);
+
//we create the jump with a weight of percent or kk
if(weightPercentPreferred)
myJump.Weight = Convert.ToDouble(myStringOfData[8].ToString());
else
- myJump.Weight = Util.WeightFromPercentToKg(
- Convert.ToDouble(myStringOfData[8]),
- Convert.ToDouble(myStringOfData[12]));
+ myJump.Weight = weightInKg;
+
return myJump;
}
@@ -199,12 +207,28 @@ public class TreeViewJumps : TreeViewEvent
myData[count++] = Util.TrimDecimals(newJump.Fall.ToString(), pDN);
if (showHeight)
myData[count++] = Util.TrimDecimals(Util.GetHeightInCentimeters(newJump.Tv.ToString()), pDN);
+
+
+
+
+
if (showPower) {
- //if is Dj (has tc, but is not a takeoff (only has tc))
- if(newJump.Tc > 0 && newJump.Tv > 0)
- myData[count++] = Util.TrimDecimals(Util.GetDjPower(newJump.Tc, newJump.Tv).ToString(), pDN);
- else
- myData[count++] = "-";
+
+ //takeoff has no tv. power should not be calculated
+ //calculate jumps with tf
+ if(newJump.Tv > 0) {
+ if(newJump.Tc > 0) //if it's Dj (has tf, and tc)
+ myData[count++] = Util.TrimDecimals(Util.GetDjPower(newJump.Tc, newJump.Tv).ToString(), pDN);
+ else { //it's a normal jump without tc
+ //we calculate weightInKg again because can be changed in edit jump, and then treeview is no re-done
+ //but we do not calculate again person weight, because if it changes treeview is created again
+ weightInKg = Util.WeightFromPercentToKg(
+ Convert.ToDouble(newJump.Weight.ToString()),
+ personWeight);
+ myData[count++] = Util.TrimDecimals(
+ Util.GetPower(newJump.Tv, personWeight, weightInKg).ToString(), pDN);
+ }
+ }
}
if (showInitialSpeed)
myData[count++] = Util.TrimDecimals(Util.GetInitialSpeed(newJump.Tv.ToString(), metersSecondsPreferred), pDN);
diff --git a/src/util.cs b/src/util.cs
index 922f50a..d9a0f29 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -527,6 +527,18 @@ public class Util
return 24.06 * ( tt * tf ) / (Double)tc;
}
+
+ //only Lewis now
+ public static double GetPower (double tf, double bodyWeight, double extraWeightKg)
+ {
+ //Log.WriteLine("tf: " + tf + ", bodyWeight: " + bodyWeight + ", extra: " + extraWeightKg);
+ double pw = System.Math.Sqrt ( 4.9 ) * 9.8 * (bodyWeight + extraWeightKg) *
+ System.Math.Sqrt(
+ Convert.ToDouble(GetHeightInCentimeters(tf.ToString()))/100);
+ //Log.WriteLine("pw: " + pw);
+ return pw;
+
+ }
public static double GetQIndex (double tv, double tc)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]