[chronojump] EncoderExercise with speed1RM
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] EncoderExercise with speed1RM
- Date: Mon, 10 Jun 2013 13:37:09 +0000 (UTC)
commit d1283488f1fa7ec4432906d6d5ea7a2e66b24ca4
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Jun 10 15:36:48 2013 +0200
EncoderExercise with speed1RM
glade/chronojump.glade | 55 ++++++++++++++++++++++++++++++++++++++++++---
src/constants.cs | 2 +-
src/encoder.cs | 4 ++-
src/gui/encoder.cs | 45 ++++++++++++++++++++++++++++++++-----
src/gui/genericWindow.cs | 26 +++++++++++++++++++++
src/sqlite/encoder.cs | 26 ++++++++++++---------
src/sqlite/main.cs | 19 +++++++++++++--
7 files changed, 151 insertions(+), 26 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 8512132..2e8f834 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -22286,6 +22286,53 @@ comments</property>
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="hbox_spin_double2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label_spin_double2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">label</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="spin_double2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">5</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 2 0 0.10000000000000001 0</property>
+ <property name="digits">3</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">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox" id="hbox_all_none_selected">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -22320,7 +22367,7 @@ comments</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">6</property>
+ <property name="position">7</property>
</packing>
</child>
<child>
@@ -22338,7 +22385,7 @@ comments</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">7</property>
+ <property name="position">8</property>
</packing>
</child>
<child>
@@ -22356,7 +22403,7 @@ comments</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">8</property>
+ <property name="position">9</property>
</packing>
</child>
<child>
@@ -22408,7 +22455,7 @@ comments</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">9</property>
+ <property name="position">10</property>
</packing>
</child>
</widget>
diff --git a/src/constants.cs b/src/constants.cs
index 47b4263..bf50327 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -539,7 +539,7 @@ public class Constants
//heightmetric contains 2 spins
public enum GenericWindowShow {
- ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HEIGHTMETRIC, COMBO, COMBOALLNONESELECTED,
TEXTVIEW, TREEVIEW
+ ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HBOXSPINDOUBLE2, HEIGHTMETRIC, COMBO,
COMBOALLNONESELECTED, TEXTVIEW, TREEVIEW
}
public const string PrefVersionAvailable = "versionAvailable";
diff --git a/src/encoder.cs b/src/encoder.cs
index 5f22c50..139556b 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -445,6 +445,7 @@ public class EncoderExercise
public int percentBodyWeight;
public string ressistance;
public string description;
+ public double speed1RM;
public EncoderExercise() {
}
@@ -453,13 +454,14 @@ public class EncoderExercise
this.name = name;
}
- public EncoderExercise(int uniqueID, string name, int percentBodyWeight, string ressistance, string
description)
+ public EncoderExercise(int uniqueID, string name, int percentBodyWeight, string ressistance, string
description, double speed1RM)
{
this.uniqueID = uniqueID;
this.name = name;
this.percentBodyWeight = percentBodyWeight;
this.ressistance = ressistance;
this.description = description;
+ this.speed1RM = speed1RM;
}
~EncoderExercise() {}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index e42078f..01088e4 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2168,6 +2168,7 @@ Log.WriteLine(str);
ArrayList a2 = new ArrayList();
ArrayList a3 = new ArrayList();
ArrayList a4 = new ArrayList();
+ ArrayList a5 = new ArrayList();
//0 is the widgget to show; 1 is the editable; 2 id default value
a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(false); a1.Add(ex.name);
@@ -2182,12 +2183,20 @@ Log.WriteLine(str);
a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(false); a4.Add(ex.description);
bigArray.Add(a4);
+ a5.Add(Constants.GenericWindowShow.HBOXSPINDOUBLE2); a5.Add(true); a5.Add(""); //alowed to
change
+ bigArray.Add(a5);
+
genericWin = GenericWindow.Show(false, Catalog.GetString("Encoder exercise name:"), bigArray);
genericWin.LabelSpinInt = Catalog.GetString("Displaced body weight") + " (%)";
genericWin.SetSpinRange(ex.percentBodyWeight, ex.percentBodyWeight); //done this because
IsEditable does not affect the cursors
genericWin.LabelEntry2 = Catalog.GetString("Resistance");
genericWin.LabelEntry3 = Catalog.GetString("Description");
+ genericWin.LabelSpinDouble2 = Catalog.GetString("Speed at 1RM");
+ genericWin.SetSpinDouble2Value(ex.speed1RM);
+ genericWin.SetSpinDouble2Increments(0.001,0.1);
genericWin.ShowButtonCancel(false);
+
+ genericWin.Button_accept.Clicked += new
EventHandler(on_button_encoder_exercise_info_accepted);
genericWin.ShowNow();
}
@@ -2199,6 +2208,7 @@ Log.WriteLine(str);
ArrayList a2 = new ArrayList();
ArrayList a3 = new ArrayList();
ArrayList a4 = new ArrayList();
+ ArrayList a5 = new ArrayList();
//0 is the widgget to show; 1 is the editable; 2 id default value
a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(true); a1.Add("");
@@ -2213,12 +2223,17 @@ Log.WriteLine(str);
a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(true); a4.Add("");
bigArray.Add(a4);
+ a5.Add(Constants.GenericWindowShow.HBOXSPINDOUBLE2); a5.Add(true); a5.Add("");
+ bigArray.Add(a5);
+
genericWin = GenericWindow.Show(false, //don't show now
Catalog.GetString("Write the name of the encoder exercise:"), bigArray);
genericWin.LabelSpinInt = Catalog.GetString("Displaced body weight") + " (%)";
genericWin.SetSpinRange(0, 100);
genericWin.LabelEntry2 = Catalog.GetString("Ressitance");
genericWin.LabelEntry3 = Catalog.GetString("Description");
+ genericWin.LabelSpinDouble2 = Catalog.GetString("Speed at 1RM");
+ genericWin.SetSpinDouble2Increments(0.001,0.1);
genericWin.SetButtonAcceptLabel(Catalog.GetString("Add"));
genericWin.HideOnAccept = false;
@@ -2227,19 +2242,38 @@ Log.WriteLine(str);
genericWin.ShowNow();
}
- void on_button_encoder_exercise_add_accepted (object o, EventArgs args)
+ void on_button_encoder_exercise_info_accepted (object o, EventArgs args) {
+ encoder_exercise_edit(false);
+ genericWin.Button_accept.Clicked -= new
EventHandler(on_button_encoder_exercise_info_accepted);
+ }
+ void on_button_encoder_exercise_add_accepted (object o, EventArgs args) {
+ encoder_exercise_edit(true);
+ genericWin.Button_accept.Clicked -= new EventHandler(on_button_encoder_exercise_add_accepted);
+ }
+
+ void encoder_exercise_edit (bool adding)
{
string name = Util.RemoveTildeAndColonAndDot(genericWin.EntrySelected);
- Log.WriteLine("Trying to insert: " + name);
+ if(adding)
+ Log.WriteLine("Trying to insert: " + name);
+ else
+ Log.WriteLine("Trying to edit: " + name);
+
if(name == "")
genericWin.SetLabelError(Catalog.GetString("Error: Missing name of exercise."));
- else if (Sqlite.Exists(Constants.EncoderExerciseTable, name))
+ else if (adding && Sqlite.Exists(Constants.EncoderExerciseTable, name))
genericWin.SetLabelError(string.Format(Catalog.GetString(
"Error: An exercise named '{0}' already exists."),
name));
else {
- SqliteEncoder.InsertExercise(false, name, genericWin.SpinIntSelected,
- genericWin.Entry2Selected, genericWin.Entry3Selected);
+ if(adding)
+ SqliteEncoder.InsertExercise(false, name, genericWin.SpinIntSelected,
+ genericWin.Entry2Selected, genericWin.Entry3Selected,
+ Util.ConvertToPoint(genericWin.SpinDouble2Selected));
+ else
+ SqliteEncoder.UpdateExercise(false, name, genericWin.SpinIntSelected,
+ genericWin.Entry2Selected, genericWin.Entry3Selected,
+ Util.ConvertToPoint(genericWin.SpinDouble2Selected));
ArrayList encoderExercises = SqliteEncoder.SelectEncoderExercises(false,-1, false);
encoderExercisesTranslationAndBodyPWeight = new String [encoderExercises.Count];
@@ -2259,7 +2293,6 @@ Log.WriteLine(str);
UtilGtk.ComboUpdate(combo_encoder_exercise, exerciseNamesToCombo, "");
combo_encoder_exercise.Active = UtilGtk.ComboMakeActive(combo_encoder_exercise, name);
- genericWin.Button_accept.Clicked -= new
EventHandler(on_button_encoder_exercise_add_accepted);
genericWin.HideAndNull();
Log.WriteLine("done");
}
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index adaf238..5edb79a 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -73,6 +73,10 @@ public class GenericWindow
[Widget] Gtk.Box hbox_entry3;
[Widget] Gtk.Label label_entry3;
[Widget] Gtk.Entry entry3;
+
+ [Widget] Gtk.Box hbox_spin_double2;
+ [Widget] Gtk.Label label_spin_double2;
+ [Widget] Gtk.SpinButton spin_double2;
private ArrayList nonSensitiveRows;
@@ -151,6 +155,7 @@ public class GenericWindow
hbox_entry3.Hide();
hbox_spin_int.Hide();
spin_double.Hide();
+ hbox_spin_double2.Hide();
hbox_height_metric.Hide();
hbox_combo_full_line.Hide();
hbox_all_none_selected.Hide();
@@ -187,6 +192,11 @@ public class GenericWindow
spin_double.Show();
spin_double.IsEditable = editable;
}
+ else if(stuff == Constants.GenericWindowShow.HBOXSPINDOUBLE2) {
+ hbox_spin_double2.Show();
+ spin_double2.IsEditable = editable;
+ spin_double2.Sensitive = editable;
+ }
else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC) {
hbox_height_metric.Show();
}
@@ -223,6 +233,8 @@ public class GenericWindow
hbox_spin_int.Show();
else if(stuff == Constants.GenericWindowShow.SPINDOUBLE)
spin_double.Show();
+ else if(stuff == Constants.GenericWindowShow.HBOXSPINDOUBLE2)
+ hbox_spin_double2.Show();
else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC)
hbox_height_metric.Show();
else if(stuff == Constants.GenericWindowShow.COMBO) {
@@ -253,6 +265,13 @@ public class GenericWindow
spin_int.SetRange(min, max);
}
+ public void SetSpinDouble2Value(double num) {
+ spin_double2.Value = num;
+ }
+ public void SetSpinDouble2Increments(double min, double max) {
+ spin_double2.SetIncrements(min, max);
+ }
+
public void SetComboValues(string [] values, string current) {
combo = ComboBox.NewText ();
UtilGtk.ComboUpdate(combo, values, "");
@@ -686,6 +705,13 @@ Log.WriteLine((string) store.GetValue (iter, 3));
public double SpinDoubleSelected {
get { return (double) spin_double.Value; }
}
+
+ public string LabelSpinDouble2 {
+ set { label_spin_double2.Text = value; }
+ }
+ public double SpinDouble2Selected {
+ get { return (double) spin_double2.Value; }
+ }
public string TwoSpinSelected {
get { return ((int) spin_feet.Value).ToString() + ":" + ((int) spin_inches.Value).ToString();
}
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index a7ed594..1360b94 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -288,14 +288,14 @@ class SqliteEncoder : Sqlite
"percentBodyWeight INT, " +
"ressistance TEXT, " +
"description TEXT, " +
- "future1 TEXT, " +
+ "future1 TEXT, " + //speed1RM: speed in m/s at 1RM with decimal point separator
'.' ; 0 means undefined
"future2 TEXT, " +
"future3 TEXT )";
dbcmd.ExecuteNonQuery();
}
public static void InsertExercise(bool dbconOpened, string name, int percentBodyWeight,
- string ressistance, string description)
+ string ressistance, string description, string speed1RM) //speed1RM decimal point =
'.'
{
if(! dbconOpened)
dbcon.Open();
@@ -303,7 +303,7 @@ class SqliteEncoder : Sqlite
dbcmd.CommandText = "INSERT INTO " + Constants.EncoderExerciseTable +
" (uniqueID, name, percentBodyWeight, ressistance, description, future1,
future2, future3)" +
" VALUES (NULL, '" + name + "', " + percentBodyWeight + ", '" +
- ressistance + "', '" + description + "', '','','')";
+ ressistance + "', '" + description + "', '" + speed1RM + "','','')";
Log.WriteLine(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -317,21 +317,19 @@ class SqliteEncoder : Sqlite
protected internal static void initializeTableEncoderExercise()
{
string [] iniEncoderExercises = {
- //name:percentBodyWeight:ressistance:description
- "Bench press:0:weight bar:",
- "Squat:100:weight bar:",
- "Jump:100:none:",
- "Free:0::"
+ //name:percentBodyWeight:ressistance:description:speed1RM
+ "Bench press:0:weight bar::0.185", //González-Badillo, J. 2010. Movement velocity as
a measure of loading intensity in resistance training
+ "Squat:100:weight bar::0.31" //González-Badillo, JJ.2000b
http://foro.chronojump.org/showthread.php?tid=1288&page=3
};
foreach(string line in iniEncoderExercises) {
string [] parts = line.Split(new char[] {':'});
- InsertExercise(true, parts[0], Convert.ToInt32(parts[1]), parts[2], parts[3]);
+ InsertExercise(true, parts[0], Convert.ToInt32(parts[1]), parts[2], parts[3],
parts[4]);
}
}
public static void UpdateExercise(bool dbconOpened, string name, int percentBodyWeight,
- string ressistance, string description)
+ string ressistance, string description, string speed1RM)
{
if(! dbconOpened)
dbcon.Open();
@@ -340,6 +338,7 @@ class SqliteEncoder : Sqlite
" percentBodyWeight = " + percentBodyWeight +
", ressistance = '" + ressistance +
"', description = '" + description +
+ "', future1 = '" + speed1RM +
"' WHERE name = '" + name + "'" ;
Log.WriteLine(dbcmd.CommandText.ToString());
@@ -381,12 +380,17 @@ class SqliteEncoder : Sqlite
}
} else {
while(reader.Read()) {
+ double speed1RM = 0;
+ if(reader[5].ToString() != "")
+ speed1RM =
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString()));
+
ex = new EncoderExercise (
Convert.ToInt32(reader[0].ToString()), //uniqueID
reader[1].ToString(), //name
Convert.ToInt32(reader[2].ToString()), //percentBodyWeight
reader[3].ToString(), //ressistance
- reader[4].ToString() //description
+ reader[4].ToString(), //description
+ speed1RM
);
array.Add(ex);
}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 3747010..d86d2a0 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -72,7 +72,7 @@ class Sqlite
* Important, change this if there's any update to database
* Important2: if database version get numbers higher than 1, check if the comparisons with
currentVersion works ok
*/
- static string lastChronojumpDatabaseVersion = "0.92";
+ static string lastChronojumpDatabaseVersion = "0.93";
public Sqlite() {
}
@@ -1208,7 +1208,7 @@ class Sqlite
if(currentVersion == "0.88") {
dbcon.Open();
- SqliteEncoder.InsertExercise(true, "Free", 0, "", "");
+ SqliteEncoder.InsertExercise(true, "Free", 0, "", "", "");
Log.WriteLine("Added encoder exercise: Free");
SqlitePreferences.Update ("databaseVersion", "0.89", true);
@@ -1232,7 +1232,7 @@ class Sqlite
if(currentVersion == "0.90") {
dbcon.Open();
- SqliteEncoder.UpdateExercise(true, "Squat", 100, "weight bar", "");
+ SqliteEncoder.UpdateExercise(true, "Squat", 100, "weight bar", "", "");
Log.WriteLine("Encoder Squat 75% -> 100%");
SqlitePreferences.Update ("databaseVersion", "0.91", true);
@@ -1251,6 +1251,18 @@ class Sqlite
currentVersion = "0.92";
}
+ if(currentVersion == "0.92") {
+ dbcon.Open();
+
+ SqliteEncoder.UpdateExercise(true, "Bench press", 0, "weight bar",
"","0.185");
+ SqliteEncoder.UpdateExercise(true, "Squat", 100, "weight bar", "","0.31");
+ Log.WriteLine("Added speed1RM on encoder exercise");
+
+ SqlitePreferences.Update ("databaseVersion", "0.93", true);
+ dbcon.Close();
+
+ currentVersion = "0.93";
+ }
}
//if changes are made here, remember to change also in CreateTables()
@@ -1389,6 +1401,7 @@ class Sqlite
SqliteCountry.initialize();
//changes [from - to - desc]
+ //0.92 - 0.93 Converted DB to 0.93 Added speed1RM on encoder exercise
//0.91 - 0.92 Converted DB to 0.92 Added videoDevice to preferences
//0.90 - 0.91 Converted DB to 0.91 Encoder Squat 75% -> 100%
//0.89 - 0.90 Converted DB to 0.90 Preferences added propulsive and encoder smooth
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]