[chronojump] encoder: curves selection done
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoder: curves selection done
- Date: Fri, 13 Jul 2012 13:34:51 +0000 (UTC)
commit 7f3bb79545a95c23fe0a700be4f0abf337e5f0d3
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jul 13 15:32:18 2012 +0200
encoder: curves selection done
diagrams/sqlite/chronojump_sqlite.dia | Bin 13178 -> 13237 bytes
diagrams/sqlite/chronojump_sqlite.png | Bin 170838 -> 235719 bytes
glade/chronojump.glade | 33 +++++++++++-
src/encoder.cs | 2 +-
src/gui/encoder.cs | 89 +++++++++++++++++++++++++--------
src/gui/genericWindow.cs | 68 +++++++++++++++++++++----
src/sqlite/encoder.cs | 4 +-
src/utilGtk.cs | 3 +
8 files changed, 163 insertions(+), 36 deletions(-)
---
diff --git a/diagrams/sqlite/chronojump_sqlite.dia b/diagrams/sqlite/chronojump_sqlite.dia
index 4a723dc..e147e04 100644
Binary files a/diagrams/sqlite/chronojump_sqlite.dia and b/diagrams/sqlite/chronojump_sqlite.dia differ
diff --git a/diagrams/sqlite/chronojump_sqlite.png b/diagrams/sqlite/chronojump_sqlite.png
index f2dc533..6aa0dd8 100644
Binary files a/diagrams/sqlite/chronojump_sqlite.png and b/diagrams/sqlite/chronojump_sqlite.png differ
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 021ccf7..adbc5a4 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -12169,6 +12169,7 @@ Evaluator can use real name or nickname.</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
+ <property name="spacing">2</property>
<child>
<widget class="GtkLabel" id="label76">
<property name="visible">True</property>
@@ -12182,9 +12183,11 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label_encoder_user_curves_num">
+ <widget class="GtkLabel" id="label_encoder_user_curves_active_num">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip" translatable="yes">Active</property>
<property name="label" translatable="yes">0</property>
</widget>
<packing>
@@ -12194,6 +12197,32 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
+ <widget class="GtkLabel" id="label98">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">/</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_encoder_user_curves_all_num">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip" translatable="yes">All</property>
+ <property name="label" translatable="yes">0</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkLabel" id="label80">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -12202,7 +12231,7 @@ Evaluator can use real name or nickname.</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">4</property>
</packing>
</child>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index ece053d..c6f6ead 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -250,7 +250,7 @@ public class EncoderSQL
}
public string [] ToStringArray (int count) {
- string [] str = new String [7];
+ string [] str = new String [8];
str[0] = uniqueID;
str[1] = count.ToString();
str[2] = exerciseName;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 2469e60..c381d4f 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -66,7 +66,8 @@ public partial class ChronoJumpWindow
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_data_current_signal;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_data_user_curves;
[Widget] Gtk.Box hbox_encoder_user_curves_num;
- [Widget] Gtk.Label label_encoder_user_curves_num;
+ [Widget] Gtk.Label label_encoder_user_curves_active_num;
+ [Widget] Gtk.Label label_encoder_user_curves_all_num;
[Widget] Gtk.Button button_encoder_analyze_data_show_user_curves;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_powerbars;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_single;
@@ -116,21 +117,17 @@ public partial class ChronoJumpWindow
//TODO: solve the problem of connecting two different chronopics
//
//TODO:put zoom,unzoom (at side of delete curve) in capture curves (for every curve)
- //TODO: treeview on analyze
+ //TODO: treeview on analyze (doing in separated window)
//to analyze: user has to select: session, athlete, exercise,
//TODO: single curve, and side, checkbox to show1 param, 2 or three
//TODO: powerbars with checkbox to show1 param, 2 or three
//TODO: on capture (quasi-realtime), show powerbars or curves or both
//
- //TODO: Alert if signal captured is not saved. alert when:
- // - Change person, load another session, doing another capture, load another signal, closing the software.
- //
//TODO: if a signal is loaded, exercise has to be updated on combo. (use exerciseID in database)
//
//TODO: do the graphical capturing with pygame
//
- //TODO: allow gui/generic.cs to select rows on treeview. return an array of selected uniqueIDs or curveID
//TODO: allow gui/generic.cs to select rows on treeview to be deleted
//
//TODO: calling to R should give feedback during the process
@@ -146,6 +143,9 @@ public partial class ChronoJumpWindow
//TODO: on cross, spline and force speed and power speed should have a spar value higher, like 0.7. On the other hand, the other cross graphs, haveload(mass) in the X lot more discrete, there is good to put 0.5
//TODO: put also the Load as Load(mass) or viceversa, and put the units on the xlab, ylab
//TODO: put a save graph and a html report
+
+ //TODO: graphs should use only active curves (except single curve)
+
private void encoderInitializeStuff() {
@@ -307,10 +307,14 @@ public partial class ChronoJumpWindow
ArrayList data = SqliteEncoder.Select(false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve");
ArrayList dataPrint = new ArrayList();
- int count = 1;
- foreach(EncoderSQL es in data)
- dataPrint.Add(es.ToStringArray(count++));
-
+ string [] checkboxes = new string[data.Count]; //to store active or inactive status of curves
+ int count = 0;
+ foreach(EncoderSQL es in data) {
+ checkboxes[count++] = es.future1;
+ Log.WriteLine(checkboxes[count-1]);
+ dataPrint.Add(es.ToStringArray(count));
+ }
+
string [] columnsString = {
Catalog.GetString("ID"),
Catalog.GetString("Curve"),
@@ -332,20 +336,52 @@ public partial class ChronoJumpWindow
a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
bigArray.Add(a2);
- genericWin = GenericWindow.Show(
+ genericWin = GenericWindow.Show(false, //don't show now
string.Format(Catalog.GetString("Saved curves of athlete {0} on this session."),
currentPerson.Name), bigArray);
genericWin.SetTreeview(columnsString, true, dataPrint);
+ genericWin.MarkActiveCurves(checkboxes);
genericWin.ShowButtonCancel(false);
genericWin.SetButtonAcceptSensitive(true);
+ //manage selected, unselected curves
+ genericWin.Button_accept.Clicked += new EventHandler(on_encoder_show_curves_done);
//used when we don't need to read data,
//and we want to ensure next window will be created at needed size
- genericWin.DestroyOnAccept=true;
+ //genericWin.DestroyOnAccept=true;
+ //here is comented because we are going to read the checkboxes
genericWin.SetButtonAcceptLabel(Catalog.GetString("Close"));
+ genericWin.ShowNow();
+ }
+
+ protected void on_encoder_show_curves_done (object o, EventArgs args)
+ {
+ genericWin.Button_accept.Clicked -= new EventHandler(on_encoder_show_curves_done);
+
+ //get selected/deselected rows
+ string [] checkboxes = genericWin.GetCheckboxesStatus();
+ Log.WriteLine(Util.StringArrayToString(checkboxes,";"));
+
+ ArrayList data = SqliteEncoder.Select(false, -1,
+ currentPerson.UniqueID, currentSession.UniqueID, "curve");
+
+ //update on database the curves that have been selected/deselected
+ int count = 0;
+ foreach(EncoderSQL es in data) {
+ if(es.future1 != checkboxes[count]) {
+ es.future1 = checkboxes[count];
+ SqliteEncoder.Update(false, es);
+ }
+ count ++;
+ }
+
+ label_encoder_user_curves_active_num.Text = getActiveCurvesNum(data).ToString();
+
+ genericWin.HideAndNull();
}
+
void on_button_encoder_load_signal_clicked (object o, EventArgs args)
{
@@ -471,11 +507,21 @@ public partial class ChronoJumpWindow
ArrayList data = SqliteEncoder.Select(false, -1,
currentPerson.UniqueID, currentSession.UniqueID, "curve");
- label_encoder_user_curves_num.Text = data.Count.ToString();
+ label_encoder_user_curves_active_num.Text = getActiveCurvesNum(data).ToString();
+ label_encoder_user_curves_all_num.Text = data.Count.ToString();
spin_encoder_analyze_curve_num.SetRange(1, data.Count);
}
}
+ private int getActiveCurvesNum(ArrayList curvesArray) {
+ int countActiveCurves = 0;
+ foreach(EncoderSQL es in curvesArray)
+ if(es.future1 == "active")
+ countActiveCurves ++;
+
+ return countActiveCurves;
+ }
+
string encoderSaveSignalOrCurve (string mode, int selectedID)
{
//mode is different than type.
@@ -693,11 +739,11 @@ public partial class ChronoJumpWindow
spin_encoder_analyze_curve_num.SetRange(1, rows);
}
private void on_radiobutton_encoder_analyze_data_user_curves_toggled (object obj, EventArgs args) {
- button_encoder_analyze.Sensitive = (currentPerson != null && Convert.ToInt32(label_encoder_user_curves_num.Text) >0);
+ button_encoder_analyze.Sensitive = (currentPerson != null && Convert.ToInt32(label_encoder_user_curves_all_num.Text) >0);
button_encoder_analyze_data_show_user_curves.Sensitive = currentPerson != null;
hbox_encoder_user_curves_num.Sensitive = currentPerson != null;
- spin_encoder_analyze_curve_num.SetRange(1, Convert.ToInt32(label_encoder_user_curves_num.Text));
+ spin_encoder_analyze_curve_num.SetRange(1, Convert.ToInt32(label_encoder_user_curves_all_num.Text));
}
@@ -911,13 +957,14 @@ public partial class ChronoJumpWindow
a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(false); a4.Add(ex.description);
bigArray.Add(a4);
- genericWin = GenericWindow.Show(Catalog.GetString("Encoder exercise name:"), bigArray);
+ 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("Ressitance");
genericWin.LabelEntry3 = Catalog.GetString("Description");
genericWin.ShowButtonCancel(false);
genericWin.SetButtonAcceptLabel(Catalog.GetString("Close"));
+ genericWin.ShowNow();
}
void on_button_encoder_exercise_add_clicked (object o, EventArgs args)
@@ -942,7 +989,7 @@ public partial class ChronoJumpWindow
a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(true); a4.Add("");
bigArray.Add(a4);
- genericWin = GenericWindow.Show(
+ 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);
@@ -953,6 +1000,7 @@ public partial class ChronoJumpWindow
genericWin.HideOnAccept = false;
genericWin.Button_accept.Clicked += new EventHandler(on_button_encoder_exercise_add_accepted);
+ genericWin.ShowNow();
}
void on_button_encoder_exercise_add_accepted (object o, EventArgs args)
@@ -1366,16 +1414,15 @@ public partial class ChronoJumpWindow
//called when a person changes
private void encoderPersonChanged() {
-Log.WriteLine("A");
ArrayList data = SqliteEncoder.Select(false, -1, currentPerson.UniqueID, currentSession.UniqueID, "curve");
- label_encoder_user_curves_num.Text = data.Count.ToString();
+ label_encoder_user_curves_active_num.Text = getActiveCurvesNum(data).ToString();
+ label_encoder_user_curves_all_num.Text = data.Count.ToString();
spin_encoder_analyze_curve_num.SetRange(1, data.Count);
encoderButtonsSensitive(encoderSensEnum.YESPERSON);
treeviewEncoderRemoveColumns();
image_encoder_capture.Sensitive = false;
image_encoder_analyze.Sensitive = false;
-Log.WriteLine("B");
}
private void encoderButtonsSensitive(encoderSensEnum option) {
@@ -1450,7 +1497,7 @@ Log.WriteLine("B");
button_encoder_analyze.Sensitive =
(Util.IntToBool(table[5]) &&
(signal && UtilGtk.CountRows(encoderListStore) > 0 ||
- (! signal && Convert.ToInt32(label_encoder_user_curves_num.Text) >0)));
+ (! signal && Convert.ToInt32(label_encoder_user_curves_all_num.Text) >0)));
button_encoder_analyze_data_show_user_curves.Sensitive =
(Util.IntToBool(table[6]) && ! radiobutton_encoder_analyze_data_current_signal.Active);
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index afecbd5..a387a45 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -74,6 +74,11 @@ public class GenericWindow
//and we want to ensure next window will be created at needed size
public bool DestroyOnAccept;
+ //if someone use delete_event should be considered as an accept?
+ //useful when there's only a close button and after some stuff is processed,
+ //but user clicked on delete_event instead of close button
+ public bool DeleteMeansAccept = false;
+
public GenericWindow ()
{
Glade.XML gladeXML;
@@ -85,7 +90,7 @@ public class GenericWindow
}
//for some widgets
- static public GenericWindow Show (string textHeader, ArrayList array)
+ static public GenericWindow Show (bool showNow, string textHeader, ArrayList array)
{
if (GenericWindowBox == null) {
GenericWindowBox = new GenericWindow();
@@ -97,13 +102,16 @@ public class GenericWindow
GenericWindowBox.showWidgetsPowerful(widgetArray);
GenericWindowBox.label_header.Text = textHeader;
- GenericWindowBox.generic_window.Show ();
+ //maybe more things have to be done before showing
+ if(showNow)
+ GenericWindowBox.generic_window.Show ();
GenericWindowBox.HideOnAccept = true;
+ GenericWindowBox.DeleteMeansAccept = true;
GenericWindowBox.DestroyOnAccept = false;
return GenericWindowBox;
}
-
+
//for only one widget
static public GenericWindow Show (string textHeader, Constants.GenericWindowShow stuff)
{
@@ -122,6 +130,11 @@ public class GenericWindow
return GenericWindowBox;
}
+ public void ShowNow() {
+ generic_window.Show ();
+ }
+
+
void hideWidgets() {
hbox_error.Hide();
entry.Hide();
@@ -169,9 +182,7 @@ public class GenericWindow
else if(stuff == Constants.GenericWindowShow.COMBOALLNONESELECTED) {
createComboAllNoneSelected();
combo_all_none_selected.Active =
- UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, Catalog.GetString("All"));
- //markSelected(Catalog.GetString("All"));
- //on_combo_all_none_selected_changed(new object(), new EventArgs());
+ UtilGtk.ComboMakeActive(comboAllNoneSelectedOptions, Catalog.GetString("Selected"));
hbox_combo_all_none_selected.Show();
}
else if(stuff == Constants.GenericWindowShow.TEXTVIEW) {
@@ -180,6 +191,7 @@ public class GenericWindow
else { //if(stuff == Constants.GenericWindowShow.TREEVIEW)
scrolled_window_treeview.Show();
}
+
}
void showWidget(Constants.GenericWindowShow stuff) {
@@ -290,10 +302,23 @@ public class GenericWindow
foreach (string [] line in data)
store.AppendValues (line);
-
+
treeview.CursorChanged += on_treeview_cursor_changed;
}
+ public void MarkActiveCurves(string [] checkboxes)
+ {
+ int count = 0;
+ Gtk.TreeIter iter;
+ bool okIter = store.GetIterFirst(out iter);
+ if(okIter) {
+ do {
+ if(checkboxes[count++] == "active")
+ store.SetValue (iter, 0, true);
+ } while ( store.IterNext(ref iter) );
+ }
+ }
+
private TreeStore getStore (int columns, bool addCheckbox)
{
if(addCheckbox)
@@ -364,6 +389,24 @@ public class GenericWindow
column.Clickable = true;
tv.InsertColumn (column, 0);
}
+
+ public string [] GetCheckboxesStatus() {
+ string [] checkboxes = new string[UtilGtk.CountRows(store)]; //to store active or inactive status of curves
+
+ int count = 0;
+ Gtk.TreeIter iter;
+ bool okIter = store.GetIterFirst(out iter);
+ if(okIter) {
+ do {
+ if((bool) store.GetValue (iter, 0))
+ checkboxes[count++] = "active";
+ else
+ checkboxes[count++] = "inactive";
+
+ } while ( store.IterNext(ref iter) );
+ }
+ return checkboxes;
+ }
protected void ItemToggled(object o, ToggledArgs args) {
//Log.WriteLine("Toggled");
@@ -383,7 +426,7 @@ public class GenericWindow
//buttonRecuperateChangeSensitiveness();
}
}
-
+
public void SetButtonAcceptLabel(string str) {
button_accept.Label=str;
@@ -405,8 +448,13 @@ public class GenericWindow
protected void on_delete_event (object o, DeleteEventArgs args)
{
- GenericWindowBox.generic_window.Hide();
- GenericWindowBox = null;
+ if(DeleteMeansAccept) {
+ button_accept.Click();
+ }
+ else {
+ GenericWindowBox.generic_window.Hide();
+ GenericWindowBox = null;
+ }
}
protected void on_button_accept_clicked (object o, EventArgs args)
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index b316e1c..609f51f 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -54,7 +54,7 @@ class SqliteEncoder : Sqlite
"minHeight INT, " +
"smooth FLOAT, " +
"description TEXT, " +
- "future1 TEXT, " +
+ "future1 TEXT, " + //works as status: "active", "inactive"
"future2 TEXT, " +
"future3 TEXT )";
dbcmd.ExecuteNonQuery();
@@ -80,7 +80,7 @@ class SqliteEncoder : Sqlite
es.laterality + "', '" + es.extraWeight + "', '" +
es.signalOrCurve + "', '" + es.filename + "', '" +
es.url + "', " + es.time + ", " + es.minHeight + ", " +
- Util.ConvertToPoint(es.smooth) + ", '" + es.description + "', '', '', '')" ;
+ Util.ConvertToPoint(es.smooth) + ", '" + es.description + "'active'', '', '')" ;
Log.WriteLine(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 68b8984..73a3c8f 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -200,6 +200,9 @@ public class UtilGtk
public static int CountRows(Gtk.ListStore ls) {
return(ls.IterNChildren());
}
+ public static int CountRows(Gtk.TreeStore ts) {
+ return(ts.IterNChildren());
+ }
public static int IdColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2) {
int val1 = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]