[chronojump] Encoder analyze combo exercises shows exercices with repetitions
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder analyze combo exercises shows exercices with repetitions
- Date: Mon, 17 Sep 2018 11:41:01 +0000 (UTC)
commit 9ef0b7d1c7110ad9d35669a09a8c25e0555a0b3d
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Sep 17 13:25:53 2018 +0200
Encoder analyze combo exercises shows exercices with repetitions
src/gui/encoder.cs | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/sqlite/encoder.cs | 51 +++++++++++++++++++++++++++++++++++
src/utilGtk.cs | 5 ++++
3 files changed, 131 insertions(+)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 080e9bdf..beea8b16 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2207,6 +2207,7 @@ public partial class ChronoJumpWindow
encoderSignalUniqueID = "-1";
image_encoder_capture.Sensitive = false;
treeviewEncoderCaptureRemoveColumns();
+ updateEncoderAnalyzeExercisesPre();
UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea,
encoder_capture_curves_bars_pixmap);
encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
@@ -2218,9 +2219,78 @@ public partial class ChronoJumpWindow
encoder_capture_curves_bars_drawingarea.Visible = false;
}
+ /*
+ * called on:
+ * radio_encoder_analyze_ (when changes)
+ * on captured set
+ * on delete set
+ * on change exercise of set
+ * on change player
+ * on change session
+ */
+ private void updateEncoderAnalyzeExercisesPre()
+ {
+ string selected = UtilGtk.ComboGetActive(combo_encoder_exercise_analyze);
+
+ createEncoderComboExerciseAndAnalyze();
+
+ if(radio_encoder_analyze_individual_current_session.Active)
+ updateEncoderAnalyzeExercises(false, currentPerson.UniqueID, currentSession.UniqueID,
selected);
+ else if(radio_encoder_analyze_individual_all_sessions.Active)
+ updateEncoderAnalyzeExercises(false, currentPerson.UniqueID, -1, selected);
+ else if(radio_encoder_analyze_groupal_current_session.Active)
+ updateEncoderAnalyzeExercises(false, -1, currentSession.UniqueID, selected);
+ }
+ private void updateEncoderAnalyzeExercises(bool dbconOpened, int personID, int sessionID, string
selectedPreviously)
+ {
+ LogB.Information("updateEncoderAnalyzeExercises()");
+ List<int> listFound = SqliteEncoder.SelectAnalyzeExercisesInCurves (dbconOpened, personID,
sessionID, currentEncoderGI);
+ foreach(int i in listFound)
+ LogB.Information(i.ToString());
+
+ List<int> rowsToRemove = new List<int>();
+ TreeIter iter;
+ if(! combo_encoder_exercise_analyze.Model.GetIterFirst(out iter))
+ return;
+
+ int count = 0;
+ do {
+ string str = (string) combo_encoder_exercise_analyze.Model.GetValue (iter, 0);
+ if(count == 0)
+ {
+ //at the moment don't delete All exercises,
+ //but in the future do it if there's less than 2
+ count ++;
+ continue;
+ }
+
+ int exID = getExerciseIDFromName (str);
+
+ if(listFound.IndexOf(exID) == -1)
+ rowsToRemove.Add(count);
+
+ count ++;
+ } while (combo_encoder_exercise_analyze.Model.IterNext (ref iter));
+
+ //remove them starting at end to have the indexes ok
+ if(rowsToRemove.Count == 0)
+ return;
+
+ for (int i = rowsToRemove.Count - 1; i >= 0; i--)
+ {
+ //LogB.Information("Deleting row: " + rowsToRemove[i]);
+ UtilGtk.ComboDelByPosition(combo_encoder_exercise_analyze, rowsToRemove[i]);
+ }
+
+ combo_encoder_exercise_analyze.Active = UtilGtk.ComboMakeActive(
+ combo_encoder_exercise_analyze, selectedPreviously);
+ }
private void updateUserCurvesLabelsAndCombo(bool dbconOpened)
{
+
+ LogB.Information("updateUserCurvesLabelsAndCombo()");
+
label_encoder_user_curves_active_num.Text = encSelReps.RepsActive.ToString();
label_encoder_user_curves_all_num.Text = encSelReps.RepsAll.ToString();
@@ -3146,6 +3216,7 @@ public partial class ChronoJumpWindow
if(! radio_encoder_analyze_individual_current_session.Active)
return;
+ updateEncoderAnalyzeExercisesPre();
prepareAnalyzeRepetitions();
/*
@@ -3196,6 +3267,7 @@ public partial class ChronoJumpWindow
if(! radio_encoder_analyze_individual_all_sessions.Active)
return;
+ updateEncoderAnalyzeExercisesPre();
prepareAnalyzeRepetitions();
hbox_encoder_analyze_current_signal.Visible = false;
@@ -3228,6 +3300,7 @@ public partial class ChronoJumpWindow
if(! radio_encoder_analyze_groupal_current_session.Active)
return;
+ updateEncoderAnalyzeExercisesPre();
prepareAnalyzeRepetitions();
hbox_encoder_analyze_current_signal.Visible = false;
@@ -4567,6 +4640,7 @@ public partial class ChronoJumpWindow
encoder_change_displaced_weight_and_1RM ();
blankEncoderInterface();
+ updateEncoderAnalyzeExercisesPre();
}
/* called on:
@@ -6638,6 +6712,7 @@ public partial class ChronoJumpWindow
else if(action == encoderActions.CAPTURE && encoderProcessFinish)
{
encoder_pulsebar_capture.Text = Catalog.GetString("Finished");
+ updateEncoderAnalyzeExercisesPre();
}
else if(action == encoderActions.CURVES || action == encoderActions.CURVES_AC ||
action == encoderActions.LOAD)
{
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 357e5640..4ef4394f 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -884,6 +884,57 @@ class SqliteEncoder : Sqlite
return array;
}
+ //gets a list of the exercises in curves to show them on encoder analyze tab
+ //-1 if all sessions or all persons
+ public static List<int> SelectAnalyzeExercisesInCurves (bool dbconOpened, int personID, int
sessionID, Constants.EncoderGI encoderGI)
+ {
+ if(! dbconOpened)
+ Sqlite.Open();
+
+ string whereStr = " WHERE signalOrCurve = 'curve' ";
+
+ if(personID != -1)
+ whereStr += " AND " + Constants.EncoderTable + ".personID = " + personID;
+
+ if(sessionID != -1)
+ whereStr += " AND " + Constants.EncoderTable + ".sessionID = " + sessionID;
+
+ dbcmd.CommandText = "SELECT exerciseID, encoderConfiguration FROM " + Constants.EncoderTable
+ whereStr +
+ " ORDER BY exerciseID";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+ List<int> l = new List<int>();
+
+ while(reader.Read())
+ {
+ //discard if != encoderGI
+ string [] strFull = reader[1].ToString().Split(new char[] {':'});
+ EncoderConfiguration econf = new EncoderConfiguration(
+ (Constants.EncoderConfigurationNames)
+ Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
+
+ //if encoderGI != ALL discard non wanted repetitions
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia)
+ continue;
+ else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia)
+ continue;
+
+ int exID = Convert.ToInt32(reader[0].ToString());
+ //Add to list l if not exists
+ if(l.IndexOf(exID) == -1)
+ l.Add(exID);
+ }
+
+ reader.Close();
+ if(! dbconOpened)
+ Sqlite.Close();
+
+ return l;
+ }
public static ArrayList SelectEncoderRowsOfAnExercise(bool dbconOpened, int exerciseID)
{
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 72d57305..4b76fe22 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -136,6 +136,11 @@ public class UtilGtk
}
}
+ public static void ComboDelByPosition(ComboBox myCombo, int pos)
+ {
+ myCombo.RemoveText(pos);
+ }
+
public static void ComboDelThisValue(ComboBox myCombo, string toRemove) {
int i=0;
TreeIter iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]