[chronojump] New Encoder overview mode to see at a glance powers on session
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] New Encoder overview mode to see at a glance powers on session
- Date: Mon, 21 Nov 2016 18:17:05 +0000 (UTC)
commit d54da2b6db7300f136d831ed5443e88851f3b1ae
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Nov 21 19:14:51 2016 +0100
New Encoder overview mode to see at a glance powers on session
chronojump.csproj | 1 +
glade/encoder_overview.glade | 122 ++++++++++++++++++++++++++++++++
src/Makefile.am | 2 +
src/gui/chronojump.cs | 3 +-
src/gui/encoder.cs | 49 +-------------
src/gui/encoderOverview.cs | 157 ++++++++++++++++++++++++++++++++++++++++++
src/sqlite/encoder.cs | 87 ++++++++++++++++++++---
7 files changed, 361 insertions(+), 60 deletions(-)
---
diff --git a/chronojump.csproj b/chronojump.csproj
index 5dd4d15..6403b20 100644
--- a/chronojump.csproj
+++ b/chronojump.csproj
@@ -1004,6 +1004,7 @@
<Compile Include="src\sqlite\usefulObjects.cs" />
<Compile Include="src\buildInfo.cs" />
<Compile Include="src\restTime.cs" />
+ <Compile Include="src\gui\encoderOverview.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="src\" />
diff --git a/glade/encoder_overview.glade b/glade/encoder_overview.glade
new file mode 100644
index 0000000..dfa2c0f
--- /dev/null
+++ b/glade/encoder_overview.glade
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<glade-interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <widget class="GtkWindow" id="encoder_overview_win">
+ <property name="width_request">650</property>
+ <property name="height_request">400</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">10</property>
+ <property name="title" translatable="yes">Encoder overview</property>
+ <property name="modal">True</property>
+ <property name="type_hint">dialog</property>
+ <signal name="delete_event" handler="on_delete_event" swapped="no"/>
+ <child>
+ <widget class="GtkVBox" id="vbox_win">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <widget class="GtkScrolledWindow" id="scr_treeview_sets">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">4</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview_sets">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">Sets</property>
+ </widget>
+ <packing>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scr_treeview_reps">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">4</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview_reps">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">Repetitions</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">12</property>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkButton" id="button_close">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_button_close_clicked" swapped="no"/>
+ <accelerator key="Escape" signal="clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 5282505..eb198dd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,7 @@ SOURCES = \
gui/encoderTreeviews.cs\
gui/encoderConfiguration.cs\
gui/encoderSelectRepetitions.cs\
+ gui/encoderOverview.cs\
gui/error.cs\
gui/eventExecute.cs\
gui/eventGraphConfigure.cs\
@@ -208,6 +209,7 @@ RESOURCES = \
../glade/dialog_server_stats.glade \
../glade/edit_event.glade \
../glade/encoder_configuration.glade \
+ ../glade/encoder_overview.glade \
../glade/error_window.glade \
../glade/evaluator_window.glade \
../glade/event_graph_configure.glade \
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7671de5..fcfbcc5 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -439,7 +439,8 @@ public partial class ChronoJumpWindow
GenericWindow genericWin;
ExecuteAutoWindow executeAutoWin;
-
+ EncoderOverviewWindow encoderOverviewWindow;
+
//ChronopicWindow chronopicWin;
//ChronopicWizardWindow chronopicWizardWin;
//string wizardPortContacts;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index a2b29eb..cdcab6c 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1462,56 +1462,11 @@ public partial class ChronoJumpWindow
checkFile(Constants.EncoderCheckFileOp.CAPTURE_EXPORT_ALL);
}
- /*
- * encoder session overview
- */
+ // encoder session overview
void on_menuitem_encoder_session_overview_activate (object o, EventArgs args)
{
- ArrayList dataPrint = SqliteEncoder.SelectSessionOverview(false, currentEncoderGI,
currentSession.UniqueID);
-
- string title = "";
- string [] columnsString;
- if(currentEncoderGI == Constants.EncoderGI.GRAVITATORY) {
- title = Catalog.GetString("Gravitory sets captured on this session");
-
- columnsString = new string [] {
- "Unused count",
- Catalog.GetString("Person"),
- Catalog.GetString("Exercise"),
- Catalog.GetString("Displaced mass"),
- Catalog.GetString("Sets")
- };
- } else {
- title = Catalog.GetString("Inertial sets captured on this session");
-
- columnsString = new string [] {
- "Unused count",
- Catalog.GetString("Person"),
- Catalog.GetString("Exercise"),
- Catalog.GetString("Sets")
- };
- }
-
- ArrayList bigArray = new ArrayList();
- ArrayList a1 = new ArrayList();
-
- //0 is the widgget to show; 1 is the editable; 2 id default value
- a1.Add(Constants.GenericWindowShow.TREEVIEW); a1.Add(true); a1.Add("");
- bigArray.Add(a1);
-
- genericWin = GenericWindow.Show(false, //don't show now
- title, bigArray);
-
- ArrayList nonSensitiveRows = new ArrayList();
- for(int i=0; i < dataPrint.Count; i ++)
- nonSensitiveRows.Add(i);
-
- genericWin.SetTreeview(columnsString, false, dataPrint, nonSensitiveRows,
Constants.ContextMenu.NONE, false);
- genericWin.ShowButtonCancel(false);
- genericWin.SetButtonAcceptSensitive(true);
- genericWin.ShowNow();
- genericWin.SetButtonAcceptSensitive(true);
+ encoderOverviewWindow = EncoderOverviewWindow.Show (app1, currentEncoderGI,
currentSession.UniqueID);
}
void on_button_encoder_export_all_curves_file_selected (string selectedFileName)
diff --git a/src/gui/encoderOverview.cs b/src/gui/encoderOverview.cs
new file mode 100644
index 0000000..4d520c8
--- /dev/null
+++ b/src/gui/encoderOverview.cs
@@ -0,0 +1,157 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2016 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.Collections; //ArrayList
+//using System.Collections.Generic; //List<T>
+using Gdk;
+using Glade;
+using Gtk;
+using Mono.Unix;
+
+
+public class EncoderOverviewWindow
+{
+ static EncoderOverviewWindow EncoderOverviewWindowBox;
+
+ [Widget] Gtk.Window encoder_overview_win;
+ [Widget] Gtk.TreeView treeview_sets;
+ [Widget] Gtk.TreeView treeview_reps;
+
+ private enum treeviewType { SETS, REPS }
+
+
+ public EncoderOverviewWindow(Gtk.Window parent, Constants.EncoderGI encoderGI, int sessionID)
+ {
+ Glade.XML gladeXML;
+ gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "encoder_overview.glade",
"encoder_overview_win", null);
+
+ gladeXML.Autoconnect(this);
+ encoder_overview_win.Parent = parent;
+
+ encoder_overview_win.Title = Catalog.GetString("Encoder Overview");
+
+ //put an icon to window
+ UtilGtk.IconWindow(encoder_overview_win);
+
+ createAndFillTreeView(treeview_sets, treeviewType.SETS, encoderGI,
+ SqliteEncoder.SelectSessionOverviewSets(false, encoderGI, sessionID));
+ createAndFillTreeView(treeview_reps, treeviewType.REPS, encoderGI,
+ SqliteEncoder.SelectSessionOverviewReps(false, encoderGI, sessionID));
+
+ /*
+ createTreeView(treeview_sets, treeviewType.SETS, encoderGI);
+ TreeStore storeSets = getStore(treeviewType.SETS, encoderGI);
+ treeview_sets.Model = storeSets;
+ ArrayList dataSets = SqliteEncoder.SelectSessionOverviewSets(false, encoderGI, sessionID);
+
+ foreach (string [] line in dataSets)
+ storeSets.AppendValues (line);
+
+ createTreeView(treeview_reps, treeviewType.REPS, encoderGI);
+ TreeStore storeReps = getStore(treeviewType.REPS, encoderGI);
+ treeview_reps.Model = storeReps;
+ ArrayList dataReps = SqliteEncoder.SelectSessionOverviewReps(false, encoderGI, sessionID);
+
+ foreach (string [] line in dataReps)
+ storeReps.AppendValues (line);
+ */
+ }
+
+ private void createAndFillTreeView(Gtk.TreeView tv, treeviewType tvType, Constants.EncoderGI
encoderGI, ArrayList array)
+ {
+ createTreeView(tv, tvType, encoderGI);
+ TreeStore store = getStore(tvType, encoderGI);
+ tv.Model = store;
+
+ foreach (string [] line in array)
+ store.AppendValues (line);
+ }
+
+ static public EncoderOverviewWindow Show (Gtk.Window parent, Constants.EncoderGI encoderGI, int
sessionID)
+ {
+ if (EncoderOverviewWindowBox == null)
+ EncoderOverviewWindowBox = new EncoderOverviewWindow (parent, encoderGI, sessionID);
+
+ EncoderOverviewWindowBox.encoder_overview_win.Show ();
+
+ return EncoderOverviewWindowBox;
+ }
+
+
+ private void createTreeView(
+ Gtk.TreeView tv, treeviewType type, Constants.EncoderGI encoderGI)
+ {
+ tv.HeadersVisible=true;
+ int count = 0;
+
+ if(type == treeviewType.SETS)
+ {
+ tv.AppendColumn (Catalog.GetString ("Person"), new CellRendererText(), "text",
count++);
+ tv.AppendColumn (Catalog.GetString ("Sex"), new CellRendererText(), "text", count++);
+ tv.AppendColumn (Catalog.GetString ("Exercise"), new CellRendererText(), "text",
count++);
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY)
+ tv.AppendColumn (Catalog.GetString ("Displaced mass"), new
CellRendererText(), "text", count++);
+
+ tv.AppendColumn (Catalog.GetString ("Sets"), new CellRendererText(), "text", count++);
+ } else {
+ tv.AppendColumn (Catalog.GetString ("Person"), new CellRendererText(), "text",
count++);
+ tv.AppendColumn (Catalog.GetString ("Sex"), new CellRendererText(), "text", count++);
+ tv.AppendColumn (Catalog.GetString ("Exercise"), new CellRendererText(), "text",
count++);
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY)
+ tv.AppendColumn (Catalog.GetString ("Extra mass"), new CellRendererText(),
"text", count++);
+
+ tv.AppendColumn (Catalog.GetString ("Power"), new CellRendererText(), "text",
count++);
+ }
+ }
+
+ private TreeStore getStore(treeviewType type, Constants.EncoderGI encoderGI)
+ {
+ TreeStore s;
+ if(type == treeviewType.SETS)
+ {
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY)
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof(string)); //person, sex, exercise, displaced mass, sets
+ else
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string)); //person, sex, exercise, sets
+ } else {
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY)
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof(string)); //person, sex, exercise, extra mass, power
+ else
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string)); //person, sex, exercise, power
+ }
+
+ return s;
+ }
+
+ void on_button_close_clicked (object o, EventArgs args)
+ {
+ EncoderOverviewWindowBox.encoder_overview_win.Hide();
+ EncoderOverviewWindowBox = null;
+ }
+
+ void on_delete_event (object o, DeleteEventArgs args)
+ {
+ EncoderOverviewWindowBox.encoder_overview_win.Hide();
+ EncoderOverviewWindowBox = null;
+ }
+
+}
+
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 5dc1dde..c107955 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -461,13 +461,13 @@ class SqliteEncoder : Sqlite
return array;
}
- public static ArrayList SelectSessionOverview (bool dbconOpened, Constants.EncoderGI encoderGI, int
sessionID)
+ public static ArrayList SelectSessionOverviewSets (bool dbconOpened, Constants.EncoderGI encoderGI,
int sessionID)
{
if(! dbconOpened)
Sqlite.Open();
dbcmd.CommandText =
- "SELECT person77.name, encoder.encoderConfiguration, encoderExercise.name,
(personSession77.weight * encoderExercise.percentBodyWeight/100) + encoder.extraWeight, COUNT(*)" +
+ "SELECT person77.name, person77.sex, encoder.encoderConfiguration,
encoderExercise.name, (personSession77.weight * encoderExercise.percentBodyWeight/100) + encoder.extraWeight,
COUNT(*)" +
" FROM person77, personSession77, encoderExercise, encoder" +
" WHERE person77.uniqueID == encoder.personID AND personSession77.personID ==
encoder.personID AND personSession77.sessionID == encoder.sessionID AND
encoderExercise.uniqueID==encoder.exerciseID AND signalOrCurve == \"signal\" AND encoder.sessionID == " +
sessionID +
" GROUP BY encoder.personID, exerciseID, extraWeight" +
@@ -479,10 +479,10 @@ class SqliteEncoder : Sqlite
reader = dbcmd.ExecuteReader();
ArrayList array = new ArrayList();
- int count = 0;
- while(reader.Read()) {
+ while(reader.Read())
+ {
//discard if != encoderGI
- string [] strFull = reader[1].ToString().Split(new char[] {':'});
+ string [] strFull = reader[2].ToString().Split(new char[] {':'});
EncoderConfiguration econf = new EncoderConfiguration(
(Constants.EncoderConfigurationNames)
Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
@@ -493,20 +493,21 @@ class SqliteEncoder : Sqlite
else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia)
continue;
- if(encoderGI == Constants.EncoderGI.GRAVITATORY) {
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY)
+ {
string [] s = {
- (count++).ToString(), //not displayed but needed on
genericWin.SetTreeView
reader[0].ToString(), //person name
- reader[2].ToString(), //encoder exercise name
- reader[3].ToString(), //displaced mass (includes percentBodyeight)
- reader[4].ToString() //sets count
+ reader[1].ToString(), //person sex
+ reader[3].ToString(), //encoder exercise name
+ reader[4].ToString(), //displaced mass (includes percentBodyeight)
+ reader[5].ToString() //sets count
};
array.Add (s);
} else {
string [] s = {
- (count++).ToString(), //not displayed but needed on
genericWin.SetTreeView
reader[0].ToString(), //person name
- reader[2].ToString(), //encoder exercise name
+ reader[1].ToString(), //person sex
+ reader[3].ToString(), //encoder exercise name
reader[4].ToString() //sets count
};
array.Add (s);
@@ -520,6 +521,68 @@ class SqliteEncoder : Sqlite
return array;
}
+ public static ArrayList SelectSessionOverviewReps (bool dbconOpened, Constants.EncoderGI encoderGI,
int sessionID)
+ {
+ if(! dbconOpened)
+ Sqlite.Open();
+
+ dbcmd.CommandText =
+ "SELECT person77.name, person77.sex, encoder.encoderConfiguration,
encoderExercise.name, encoder.extraWeight, encoder.future1 " +
+ "FROM person77, encoderExercise, encoder " +
+ "WHERE sessionID = " + sessionID.ToString() +
+ " AND signalOrCurve = \"curve\" " +
+ " AND person77.uniqueID = encoder.personID " +
+ " AND encoderExercise.uniqueID = encoder.exerciseID " +
+ " ORDER BY person77.name";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ ArrayList array = new ArrayList();
+ while(reader.Read())
+ {
+ //discard if != encoderGI
+ string [] strFull = reader[2].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;
+
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY)
+ {
+ string [] s = {
+ reader[0].ToString(), //person name
+ reader[1].ToString(), //person sex
+ reader[3].ToString(), //encoder exercise name
+ reader[4].ToString(), //extra mass
+ reader[5].ToString() //power
+ };
+ array.Add (s);
+ } else {
+ string [] s = {
+ reader[0].ToString(), //person name
+ reader[1].ToString(), //person sex
+ reader[3].ToString(), //encoder exercise name
+ reader[5].ToString() //power
+ };
+ array.Add (s);
+ }
+ }
+
+ reader.Close();
+ if(! dbconOpened)
+ Sqlite.Close();
+
+ return array;
+ }
+
/*
* EncoderSignalCurve
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]