[chronojump] slCMJ with jump angle



commit fe5880fbf66a8ecbfaab8bbd93e46f37531fe71d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jan 7 02:02:07 2013 +0100

    slCMJ with jump angle

 glade/chronojump.glade |  146 ++++++++++++++++++++++++++++++++++++------------
 src/gui/chronojump.cs  |   14 ++++-
 src/gui/jump.cs        |   62 ++++++++++++--------
 src/util.cs            |    8 +++
 4 files changed, 168 insertions(+), 62 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index a9ff307..40ddfff 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -16874,7 +16874,7 @@ by you</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">Angle</property>
+                <property name="label" translatable="yes">Knee angle</property>
               </widget>
               <packing>
                 <property name="top_attach">12</property>
@@ -18700,7 +18700,7 @@ comments</property>
               <widget class="GtkVBox" id="jumps_single_leg">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="spacing">6</property>
+                <property name="spacing">8</property>
                 <child>
                   <widget class="GtkVBox" id="vbox82">
                     <property name="visible">True</property>
@@ -18710,6 +18710,7 @@ comments</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
+                        <property name="xpad">12</property>
                         <property name="label" translatable="yes">Type</property>
                       </widget>
                       <packing>
@@ -18804,6 +18805,7 @@ comments</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
+                        <property name="xpad">12</property>
                         <property name="label" translatable="yes">Limb</property>
                       </widget>
                       <packing>
@@ -18881,6 +18883,7 @@ comments</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
+                        <property name="xpad">12</property>
                         <property name="label" translatable="yes">Dominance</property>
                       </widget>
                       <packing>
@@ -18976,6 +18979,7 @@ comments</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
+                        <property name="xpad">12</property>
                         <property name="label" translatable="yes">Fall</property>
                       </widget>
                       <packing>
@@ -19066,54 +19070,126 @@ comments</property>
                   <widget class="GtkHBox" id="hbox3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="spacing">8</property>
+                    <property name="spacing">10</property>
                     <child>
-                      <widget class="GtkLabel" id="label2">
+                      <widget class="GtkHBox" id="hbox5">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Distance</property>
+                        <property name="spacing">4</property>
+                        <child>
+                          <widget class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Distance</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkSpinButton" id="jumps_spinbutton_single_leg_distance">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                            <property name="primary_icon_sensitive">True</property>
+                            <property name="secondary_icon_sensitive">True</property>
+                            <property name="adjustment">0 0 200 1 1 0</property>
+                            <property name="climb_rate">1</property>
+                            <property name="snap_to_ticks">True</property>
+                            <property name="numeric">True</property>
+                            <property name="update_policy">if-valid</property>
+                            <signal name="value_changed" handler="on_spin_single_leg_changed" swapped="no"/>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="label3">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">cm</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
                       </widget>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="padding">12</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkSpinButton" id="jumps_spinbutton_single_leg_distance">
+                      <widget class="GtkHBox" id="hbox6">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="invisible_char">â</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="primary_icon_activatable">False</property>
-                        <property name="secondary_icon_activatable">False</property>
-                        <property name="primary_icon_sensitive">True</property>
-                        <property name="secondary_icon_sensitive">True</property>
-                        <property name="adjustment">0 0 200 1 1 0</property>
-                        <property name="climb_rate">1</property>
-                        <property name="snap_to_ticks">True</property>
-                        <property name="numeric">True</property>
-                        <property name="update_policy">if-valid</property>
-                        <signal name="value_changed" handler="on_spin_single_leg_changed" swapped="no"/>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">4</property>
+                        <child>
+                          <widget class="GtkLabel" id="label4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Jump angle</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkSpinButton" id="jumps_spinbutton_single_leg_jump_angle">
+                            <property name="visible">True</property>
+                            <property name="sensitive">False</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">â</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                            <property name="primary_icon_sensitive">True</property>
+                            <property name="secondary_icon_sensitive">True</property>
+                            <property name="adjustment">0 0 90 1 1 0</property>
+                            <property name="climb_rate">1</property>
+                            <property name="snap_to_ticks">True</property>
+                            <property name="numeric">True</property>
+                            <property name="update_policy">if-valid</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="label5">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">degrees</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
                       </widget>
                       <packing>
-                        <property name="expand">False</property>
+                        <property name="expand">True</property>
                         <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
-                    <child>
-                      <widget class="GtkLabel" id="label3">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">cm</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
@@ -24034,7 +24110,7 @@ If you want to use other formulas, go to Statistics.</property>
                 </child>
                 <child>
                   <widget class="GtkCheckButton" id="checkbutton_angle">
-                    <property name="label" translatable="yes">Show angle</property>
+                    <property name="label" translatable="yes">Show knee angle</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d6fb5f6..aed65ca 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3175,9 +3175,17 @@ Log.WriteLine("DDD");
 		
 			if(currentJumpType.Name == "slCMJ") {
 				if(extra_window_jumps_radiobutton_single_leg_mode_vertical.Active)
-					currentJump.Description += " 0";
-				else
-					currentJump.Description += " " + genericWin.SpinIntSelected.ToString();
+					currentJump.Description += " 0 90";
+				else {
+					int distance = Convert.ToInt32(genericWin.SpinIntSelected);
+					currentJump.Description += 
+						" " + distance.ToString() +
+						" " + Util.CalculateJumpAngle(
+								Convert.ToDouble(
+									Util.GetHeightInCentimeters(
+										currentJump.Tv.ToString()))
+								, distance ).ToString();
+				}
 				SqliteJump.UpdateDescription(Constants.JumpTable, 
 						currentJump.UniqueID, currentJump.Description);
 			}
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index 57fee6a..9a645bd 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -47,6 +47,7 @@ public class EditJumpWindow : EditEventWindow
 	[Widget] private Gtk.RadioButton jumps_radiobutton_single_leg_fall_opposite;
 	[Widget] private Gtk.RadioButton jumps_radiobutton_single_leg_fall_both;
 	[Widget] private Gtk.SpinButton jumps_spinbutton_single_leg_distance;
+	[Widget] private Gtk.SpinButton jumps_spinbutton_single_leg_jump_angle;
 
 	static EditJumpWindow EditJumpWindowBox;
 	protected double personWeight;
@@ -200,7 +201,7 @@ public class EditJumpWindow : EditEventWindow
 
 	private bool slCMJDescriptionIsValid(string description) {
 		string [] d = description.Split(new char[] {' '});
-		if(d.Length != 5)
+		if(d.Length != 6)
 			return false;
 		if(! Util.IsNumber(d[4], false))
 			return false;
@@ -216,7 +217,7 @@ public class EditJumpWindow : EditEventWindow
 		return true;
 	}
 	private string slCMJDescriptionDefault() {
-		string descDefault = "Vertical Right This This 0";
+		string descDefault = "Vertical Right This This 0 90";
 		entry_description.Text = descDefault;
 		return descDefault;
 	}
@@ -233,21 +234,24 @@ public class EditJumpWindow : EditEventWindow
 		toggleRaisesSignal = false;
 		
 		switch(d[0]) {
-			case "Vertical": 
-					jumps_radiobutton_single_leg_mode_vertical.Active = true; 
-					jumps_spinbutton_single_leg_distance.Sensitive = false;
-					jumps_spinbutton_single_leg_distance.Value = 0;
-					break;
-			case "Horizontal": 
-					jumps_radiobutton_single_leg_mode_horizontal.Active = true; 
-					jumps_spinbutton_single_leg_distance.Sensitive = true;
-					jumps_spinbutton_single_leg_distance.Value = Convert.ToInt32(d[4]);
-					break;
-			case "Lateral": 
-					jumps_radiobutton_single_leg_mode_lateral.Active = true; 
-					jumps_spinbutton_single_leg_distance.Sensitive = true;
-					jumps_spinbutton_single_leg_distance.Value = Convert.ToInt32(d[4]);
-					break;
+			case "Vertical":
+				jumps_radiobutton_single_leg_mode_vertical.Active = true;
+				jumps_spinbutton_single_leg_distance.Sensitive = false;
+				jumps_spinbutton_single_leg_distance.Value = 0;
+				jumps_spinbutton_single_leg_jump_angle.Value = 90;
+				break;
+			case "Horizontal":
+				jumps_radiobutton_single_leg_mode_horizontal.Active = true;
+				jumps_spinbutton_single_leg_distance.Sensitive = true;
+				jumps_spinbutton_single_leg_distance.Value = Convert.ToInt32(d[4]);
+				jumps_spinbutton_single_leg_jump_angle.Value = Convert.ToInt32(d[5]);
+				break;
+			case "Lateral":
+				jumps_radiobutton_single_leg_mode_lateral.Active = true;
+				jumps_spinbutton_single_leg_distance.Sensitive = true;
+				jumps_spinbutton_single_leg_distance.Value = Convert.ToInt32(d[4]);
+				jumps_spinbutton_single_leg_jump_angle.Value = Convert.ToInt32(d[5]);
+				break;
 		}
 		switch(d[1]) {
 			case "Right": jumps_radiobutton_single_leg_right.Active = true; break;
@@ -263,7 +267,7 @@ public class EditJumpWindow : EditEventWindow
 			case "Opposite": jumps_radiobutton_single_leg_fall_opposite.Active = true; break;
 			case "Both": jumps_radiobutton_single_leg_fall_both.Active = true; break;
 		}
-			
+
 		toggleRaisesSignal = true;
 	}
 	
@@ -283,7 +287,8 @@ public class EditJumpWindow : EditEventWindow
 			else
 				d[0] = "Lateral";
 			
-			entry_description.Text = d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4];
+			entry_description.Text = 
+				d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4] + " " + d[5];
 			fillSingleLeg(entry_description.Text);
 		}
 	}
@@ -300,7 +305,8 @@ public class EditJumpWindow : EditEventWindow
 			else
 				d[1] = "Left";
 
-			entry_description.Text = d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4];
+			entry_description.Text = 
+				d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4] + " " + d[5];
 			fillSingleLeg(entry_description.Text);
 		}
 	}
@@ -319,7 +325,8 @@ public class EditJumpWindow : EditEventWindow
 			else
 				d[2] = "Unknown";
 
-			entry_description.Text = d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4];
+			entry_description.Text = 
+				d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4] + " " + d[5];
 			fillSingleLeg(entry_description.Text);
 		}
 	}
@@ -338,7 +345,8 @@ public class EditJumpWindow : EditEventWindow
 			else
 				d[3] = "Both";
 
-			entry_description.Text = d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4];
+			entry_description.Text = 
+				d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4] + " " + d[5];
 			fillSingleLeg(entry_description.Text);
 		}
 	}
@@ -350,9 +358,15 @@ public class EditJumpWindow : EditEventWindow
 				description = slCMJDescriptionDefault();
 			string [] d = description.Split(new char[] {' '});
 
-			d[4] = jumps_spinbutton_single_leg_distance.Value.ToString();
+			int distance = Convert.ToInt32(jumps_spinbutton_single_leg_distance.Value);
+			d[4] = distance.ToString();
+			
+			d[5] = Util.CalculateJumpAngle(
+					Convert.ToDouble(Util.GetHeightInCentimeters(entryTv)), 
+					distance ).ToString();
 
-			entry_description.Text = d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4];
+			entry_description.Text = 
+				d[0] + " " + d[1] + " " + d[2] + " " + d[3] + " " + d[4] + " " + d[5];
 			fillSingleLeg(entry_description.Text);
 		}
 	}
diff --git a/src/util.cs b/src/util.cs
index ea4a395..b4e1089 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -222,6 +222,14 @@ public class Util
 			return -1;
 		}
 	}
+
+	public static int CalculateJumpAngle(double height, int distance) {
+		if(distance == 0)
+			return 90;
+		else
+			return Convert.ToInt32(System.Math.Atan(height / (distance * 1.0)) 
+				* 180 / System.Math.PI);;
+	}
 	
 	//useful for jumpType and jumpRjType, because the third value is the same
 	public static bool HasWeight(string [] jumpTypes, string myType) {



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