[chronojump] Load session: encoder, and select visible columns
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Load session: encoder, and select visible columns
- Date: Fri, 12 Apr 2013 19:28:45 +0000 (UTC)
commit 0b03d8decd8ae670985f6a422a8ff62e8806bd53
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Apr 12 21:27:48 2013 +0200
Load session: encoder, and select visible columns
glade/chronojump.glade | 55 +++++++++++++++-
src/gui/session.cs | 168 ++++++++++++++++++++++++++++++++++++++---------
src/sqlite/session.cs | 52 +++++++++++++++
src/utilGtk.cs | 7 ++
4 files changed, 246 insertions(+), 36 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 31a8036..9380944 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -31326,8 +31326,8 @@ suitable for agility tests and RSA)</property>
</child>
</widget>
<widget class="GtkWindow" id="session_load">
- <property name="width_request">600</property>
- <property name="height_request">350</property>
+ <property name="width_request">650</property>
+ <property name="height_request">400</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
@@ -31341,6 +31341,52 @@ suitable for agility tests and RSA)</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
<child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkCheckButton" id="checkbutton_show_data_encoder">
+ <property name="label" translatable="yes">Show data of encoder tests</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_checkbutton_show_data_encoder_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="checkbutton_show_data_jump_run">
+ <property name="label" translatable="yes">Show data of jump and run tests</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_checkbutton_show_data_jump_run_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -31348,6 +31394,7 @@ suitable for agility tests and RSA)</property>
<widget class="GtkTreeView" id="treeview_session_load">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
<property name="enable_search">False</property>
<signal name="row_activated" handler="on_row_double_clicked" swapped="no"/>
</widget>
@@ -31356,7 +31403,7 @@ suitable for agility tests and RSA)</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -31402,7 +31449,7 @@ suitable for agility tests and RSA)</property>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</widget>
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 2b4396b..365ebe5 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -641,6 +641,8 @@ public class SessionLoadWindow {
private string selected;
[Widget] Gtk.TreeView treeview_session_load;
[Widget] Gtk.Button button_accept;
+ [Widget] Gtk.CheckButton checkbutton_show_data_jump_run;
+ [Widget] Gtk.CheckButton checkbutton_show_data_encoder;
static SessionLoadWindow SessionLoadWindowBox;
Gtk.Window parent;
@@ -656,18 +658,51 @@ public class SessionLoadWindow {
//put an icon to window
UtilGtk.IconWindow(session_load);
- createTreeView(treeview_session_load);
- store = new TreeStore(typeof (string), typeof (string), typeof (string), typeof (string),
- typeof (string), typeof (string), typeof (string), typeof (string),
typeof(string),
- typeof (string), typeof (string), typeof (string),
- typeof (string), typeof (string), typeof (string), typeof(string) );
+ createTreeView(treeview_session_load, false, false);
+ store = getStore(false, false);
treeview_session_load.Model = store;
- fillTreeView(treeview_session_load,store);
+ fillTreeView(treeview_session_load, store, false, false);
button_accept.Sensitive = false;
treeview_session_load.Selection.Changed += onSelectionEntry;
}
+
+ private TreeStore getStore(bool showContacts, bool showEncoder) {
+ TreeStore s;
+ if(showContacts && showEncoder)
+ s = new TreeStore(
+ typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
+ typeof (string), typeof (string), typeof (string), typeof(string), //jumps
s,r, runs s, i,
+ typeof (string), typeof (string), typeof (string), //rt, pulses, mc
+ typeof (string), typeof (string), //encoder s, c
+ typeof (string) //comments
+ );
+ else if(showContacts && ! showEncoder)
+ s = new TreeStore(
+ typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
+ typeof (string), typeof (string), typeof (string), typeof(string), //jumps
s,r, runs s, i,
+ typeof (string), typeof (string), typeof (string), //rt, pulses, mc
+ typeof (string) //comments
+ );
+ else if(! showContacts && showEncoder)
+ s = new TreeStore(
+ typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
+ typeof (string), typeof (string), //encoder s, c
+ typeof (string) //comments
+ );
+ else // ! showContacts && ! showEncoder
+ s = new TreeStore(
+ typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
+ typeof (string) //comments
+ );
+ return s;
+ }
+
static public SessionLoadWindow Show (Gtk.Window parent)
{
@@ -679,7 +714,7 @@ public class SessionLoadWindow {
return SessionLoadWindowBox;
}
- private void createTreeView (Gtk.TreeView tv) {
+ private void createTreeView (Gtk.TreeView tv, bool showContacts, bool showEncoder) {
tv.HeadersVisible=true;
int count = 0;
@@ -691,17 +726,44 @@ public class SessionLoadWindow {
tv.AppendColumn ( Catalog.GetString ("Sport"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Speciallity"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Level"), new CellRendererText(), "text", count++);
- tv.AppendColumn ( Catalog.GetString ("Jumps simple"), new CellRendererText(), "text",
count++);
- tv.AppendColumn ( Catalog.GetString ("Jumps reactive"), new CellRendererText(), "text",
count++);
- tv.AppendColumn ( Catalog.GetString ("Runs simple"), new CellRendererText(), "text", count++);
- tv.AppendColumn ( Catalog.GetString ("Runs interval"), new CellRendererText(), "text",
count++);
- tv.AppendColumn ( Catalog.GetString ("Reaction time"), new CellRendererText(), "text",
count++);
- tv.AppendColumn ( Catalog.GetString ("Pulses"), new CellRendererText(), "text", count++);
- tv.AppendColumn ( Catalog.GetString ("MultiChronopic"), new CellRendererText(), "text",
count++);
+ if(showContacts) {
+ tv.AppendColumn ( Catalog.GetString ("Jumps simple"), new CellRendererText(), "text",
count++);
+ tv.AppendColumn ( Catalog.GetString ("Jumps reactive"), new CellRendererText(),
"text", count++);
+ tv.AppendColumn ( Catalog.GetString ("Runs simple"), new CellRendererText(), "text",
count++);
+ tv.AppendColumn ( Catalog.GetString ("Runs interval"), new CellRendererText(),
"text", count++);
+ tv.AppendColumn ( Catalog.GetString ("Reaction time"), new CellRendererText(),
"text", count++);
+ tv.AppendColumn ( Catalog.GetString ("Pulses"), new CellRendererText(), "text",
count++);
+ tv.AppendColumn ( Catalog.GetString ("MultiChronopic"), new CellRendererText(),
"text", count++);
+ }
+ if(showEncoder) {
+ tv.AppendColumn ( Catalog.GetString ("Encoder signals"), new CellRendererText(),
"text", count++);
+ tv.AppendColumn ( Catalog.GetString ("Encoder curves"), new CellRendererText(),
"text", count++);
+ }
tv.AppendColumn ( Catalog.GetString ("Comments"), new CellRendererText(), "text", count++);
}
- private void fillTreeView (Gtk.TreeView tv, TreeStore store)
+ void on_checkbutton_show_data_jump_run_toggled (object o, EventArgs args) {
+ Log.WriteLine("jump run " + checkbutton_show_data_jump_run.Active.ToString());
+ recreateTreeView();
+ }
+ void on_checkbutton_show_data_encoder_toggled (object o, EventArgs args) {
+ Log.WriteLine("encoder " + checkbutton_show_data_encoder.Active.ToString());
+ recreateTreeView();
+ }
+
+ void recreateTreeView() {
+ UtilGtk.RemoveColumns(treeview_session_load);
+
+ createTreeView(treeview_session_load,
+ checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+ store = getStore(
+ checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+ treeview_session_load.Model = store;
+ fillTreeView(treeview_session_load, store,
+ checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+ }
+
+ private void fillTreeView (Gtk.TreeView tv, TreeStore store, bool showContacts, bool showEncoder)
{
string [] mySessions = SqliteSession.SelectAllSessions(); //returns a string of values
separated by ':'
foreach (string session in mySessions) {
@@ -720,22 +782,64 @@ public class SessionLoadWindow {
if (myStringFull[6] != Catalog.GetString(Constants.LevelUndefined))
myLevel = Catalog.GetString(myStringFull[6]);
- store.AppendValues (myStringFull[0], myStringFull[1],
- myStringFull[2],
- myStringFull[3], //session date
- myStringFull[8], //number of jumpers x session
- mySport, //personsSport
- mySpeciallity, //personsSpeciallity
- myLevel, //personsLevel
- myStringFull[9], //number of jumps x session
- myStringFull[10], //number of jumpsRj x session
- myStringFull[11], //number of runs x session
- myStringFull[12], //number of runsInterval x session
- myStringFull[13], //number of reaction times x session
- myStringFull[14], //number of pulses x session
- myStringFull[15], //number of multiChronopics x session
- myStringFull[7] //description of session
- );
+ if(showContacts && showEncoder)
+ store.AppendValues (myStringFull[0], myStringFull[1],
+ myStringFull[2],
+ myStringFull[3], //session date
+ myStringFull[8], //number of jumpers x session
+ mySport, //personsSport
+ mySpeciallity, //personsSpeciallity
+ myLevel, //personsLevel
+ myStringFull[9], //number of jumps x session
+ myStringFull[10], //number of jumpsRj x session
+ myStringFull[11], //number of runs x session
+ myStringFull[12], //number of runsInterval x session
+ myStringFull[13], //number of reaction times x session
+ myStringFull[14], //number of pulses x session
+ myStringFull[15], //number of multiChronopics x session
+ myStringFull[16], //number of encoder signal x session
+ myStringFull[17], //number of encoder curve x session
+ myStringFull[7] //description of session
+ );
+ else if(showContacts && ! showEncoder)
+ store.AppendValues (myStringFull[0], myStringFull[1],
+ myStringFull[2],
+ myStringFull[3], //session date
+ myStringFull[8], //number of jumpers x session
+ mySport, //personsSport
+ mySpeciallity, //personsSpeciallity
+ myLevel, //personsLevel
+ myStringFull[9], //number of jumps x session
+ myStringFull[10], //number of jumpsRj x session
+ myStringFull[11], //number of runs x session
+ myStringFull[12], //number of runsInterval x session
+ myStringFull[13], //number of reaction times x session
+ myStringFull[14], //number of pulses x session
+ myStringFull[15], //number of multiChronopics x session
+ myStringFull[7] //description of session
+ );
+ else if(! showContacts && showEncoder)
+ store.AppendValues (myStringFull[0], myStringFull[1],
+ myStringFull[2],
+ myStringFull[3], //session date
+ myStringFull[8], //number of jumpers x session
+ mySport, //personsSport
+ mySpeciallity, //personsSpeciallity
+ myLevel, //personsLevel
+ myStringFull[16], //number of encoder signal x session
+ myStringFull[17], //number of encoder curve x session
+ myStringFull[7] //description of session
+ );
+ else // ! showContacts && ! showEncoder
+ store.AppendValues (myStringFull[0], myStringFull[1],
+ myStringFull[2],
+ myStringFull[3], //session date
+ myStringFull[8], //number of jumpers x session
+ mySport, //personsSport
+ mySpeciallity, //personsSpeciallity
+ myLevel, //personsLevel
+ myStringFull[7] //description of session
+ );
}
}
@@ -767,7 +871,7 @@ public class SessionLoadWindow {
button_accept.Activate();
}
}
-
+
void on_button_accept_clicked (object o, EventArgs args)
{
if(selected != "-1") {
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 20e8245..afe5714 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -372,6 +372,36 @@ class SqliteSession : Sqlite
}
reader_mcs.Close();
+ //select encoder signal of each session
+ dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.EncoderTable +
+ " WHERE signalOrCurve == 'signal' GROUP BY sessionID ORDER BY sessionID";
+ Log.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader_enc_s;
+ reader_enc_s = dbcmd.ExecuteReader();
+ ArrayList myArray_enc_s = new ArrayList(2);
+
+ while(reader_enc_s.Read()) {
+ myArray_enc_s.Add (reader_enc_s[0].ToString() + ":" + reader_enc_s[1].ToString() +
":" );
+ }
+ reader_enc_s.Close();
+
+ //select encoder curve of each session
+ dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.EncoderTable +
+ " WHERE signalOrCurve == 'curve' GROUP BY sessionID ORDER BY sessionID";
+ Log.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader_enc_c;
+ reader_enc_c = dbcmd.ExecuteReader();
+ ArrayList myArray_enc_c = new ArrayList(2);
+
+ while(reader_enc_c.Read()) {
+ myArray_enc_c.Add (reader_enc_c[0].ToString() + ":" + reader_enc_c[1].ToString() +
":" );
+ }
+ reader_enc_c.Close();
+
//close database connection
dbcon.Close();
@@ -475,6 +505,28 @@ class SqliteSession : Sqlite
}
if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; }
+ //add encoder signal for each session
+ found = false;
+ foreach (string line_enc_s in myArray_enc_s) {
+ string [] myStringFull = line_enc_s.Split(new char[] {':'});
+ if(myStringFull[0] == mixingSessionID) {
+ lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1];
+ found = true;
+ }
+ }
+ if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; }
+
+ //add encoder curve for each session
+ found = false;
+ foreach (string line_enc_c in myArray_enc_c) {
+ string [] myStringFull = line_enc_c.Split(new char[] {':'});
+ if(myStringFull[0] == mixingSessionID) {
+ lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1];
+ found = true;
+ }
+ }
+ if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; }
+
mySessions [count++] = lineNotReadOnly;
}
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 15c732b..90cbb47 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -209,6 +209,13 @@ public class UtilGtk
return store;
}
+ public static Gtk.TreeView RemoveColumns(Gtk.TreeView tv) {
+ Gtk.TreeViewColumn [] myColumns = tv.Columns;
+ foreach (Gtk.TreeViewColumn column in myColumns) {
+ tv.RemoveColumn (column);
+ }
+ return tv;
+ }
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]