[chronojump] TreeView for race analyzer results
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] TreeView for race analyzer results
- Date: Mon, 26 Oct 2020 10:42:40 +0000 (UTC)
commit 85ea52a289f2312473d82980adfedc4d29d1988a
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Oct 26 11:42:21 2020 +0100
TreeView for race analyzer results
glade/app1.glade | 74 ++++++++++++++++++++++++++++++--------
src/gui/app1/runEncoder.cs | 77 +++++++++++++++++++++++++++++++++++++++
src/runEncoder.cs | 90 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 227 insertions(+), 14 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index cb7a829e..ff10ba9a 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25038,6 +25038,9 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -25688,6 +25691,46 @@ Concentric</property>
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="hbox445">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkScrolledWindow"
id="scrolledwindow_raceAnalyzer">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="hscrollbar_policy">automatic</property>
+ <property
name="vscrollbar_policy">automatic</property>
+ <child>
+ <widget class="GtkTreeView"
id="treeview_raceAnalyzer">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label113">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Show
table</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkVBox" id="vbox165">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -25735,7 +25778,7 @@ Concentric</property>
</child>
</widget>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -25745,7 +25788,7 @@ Concentric</property>
<property name="label" translatable="yes">Show
triggers</property>
</widget>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -27894,18 +27937,6 @@ Concentric</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Tests
will be filmed</property>
- </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="GtkHBox"
id="hbox_video_encoder_capturing">
<property name="can_focus">False</property>
<property name="spacing">4</property>
@@ -27942,6 +27973,18 @@ Concentric</property>
</packing>
</child>
<child>
+ <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Tests
will be filmed</property>
+ </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="GtkHBox"
id="hbox_video_encoder_no_capturing">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -36039,6 +36082,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 5d0f99c3..a12d6f25 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -45,6 +45,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.ComboBox combo_race_analyzer_device;
[Widget] Gtk.Image image_run_encoder_graph;
[Widget] Gtk.Viewport viewport_run_encoder_graph;
+ [Widget] Gtk.TreeView treeview_raceAnalyzer;
int race_analyzer_distance;
int race_analyzer_temperature;
@@ -939,8 +940,10 @@ public partial class ChronoJumpWindow
private void raceEncoderCopyTempAndDoGraphs()
{
+ // 1) copy file
File.Copy(lastRunEncoderFullPath, RunEncoder.GetCSVFileName(), true); //can be overwritten
+ // 2) create and open graph
raceEncoderCaptureGraphDo();
Thread.Sleep (250); //Wait a bit to ensure is copied
@@ -949,6 +952,13 @@ public partial class ChronoJumpWindow
notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.RACEENCODER);
radio_mode_contacts_analyze.Active = true;
button_run_encoder_analyze_analyze.Sensitive = true;
+
+ // 3) display table
+ //treeviewRaceAnalyzerRemoveColumns();
+ treeview_raceAnalyzer = UtilGtk.RemoveColumns(treeview_raceAnalyzer);
+
+ string contents = Util.ReadFile(RunEncoder.GetCSVResultsFileName(), false);
+ createTreeViewRaceEncoder(contents);
}
private void raceEncoderCaptureGraphDo()
@@ -1026,6 +1036,73 @@ public partial class ChronoJumpWindow
}
}
+ private void createTreeViewRaceEncoder (string contents)
+ {
+ string [] columnsString = getTreeviewRaceAnalyzerHeaders();
+ int count = 0;
+ foreach(string column in columnsString)
+ treeview_raceAnalyzer.AppendColumn (column, new CellRendererText(), "text", count++);
+
+ TreeStore 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), typeof (string), typeof (string),
+ typeof (string), typeof (string), typeof (string),
+ typeof (string)
+ );
+
+ string line;
+ using (StringReader reader = new StringReader (contents))
+ {
+ line = reader.ReadLine (); //headers
+ //LogB.Information(line);
+ do {
+ line = reader.ReadLine ();
+ LogB.Information(line);
+ if (line == null)
+ break;
+
+ string [] cells = line.Split(new char[] {';'});
+
+ RunEncoderCSV recsv = new RunEncoderCSV(
+ Convert.ToDouble(cells[0]),
Convert.ToDouble(cells[1]), Convert.ToInt32(cells[2]),
+ Convert.ToDouble(cells[3]),
Convert.ToDouble(cells[4]), Convert.ToDouble(cells[5]),
+ Convert.ToDouble(cells[6]),
Convert.ToDouble(cells[7]), Convert.ToDouble(cells[8]),
+ Convert.ToDouble(cells[9]),
Convert.ToDouble(cells[10]), Convert.ToDouble(cells[11]),
+ Convert.ToDouble(cells[12]),
Convert.ToDouble(cells[13]), Convert.ToDouble(cells[14]),
+ Convert.ToDouble(cells[15]),
Convert.ToDouble(cells[16]), Convert.ToDouble(cells[17]),
+ Convert.ToDouble(cells[18]),
Convert.ToDouble(cells[19]), Convert.ToDouble(cells[20]),
+ Convert.ToDouble(cells[21])
+ );
+
+ store.AppendValues (recsv.ToTreeView());
+
+ } while(true);
+ }
+
+ treeview_raceAnalyzer.Model = store;
+ treeview_raceAnalyzer.Selection.Mode = SelectionMode.None;
+ treeview_raceAnalyzer.HeadersVisible=true;
+
+ }
+ private string [] getTreeviewRaceAnalyzerHeaders ()
+ {
+ string [] headers = {
+ "Mass\n\n(Kg)", "Height\n\n(m)", "Temperature\n\n(ÂșC)",
+ "V (wind)\n\n(m/s)", "Ka\n\n", "K\nfitted\n(s^-1)",
+ "Vmax\nfitted\n(m/s)", "Amax\nfitted\n(m/s^2)", "Fmax\nfitted\n(N)",
+ "Fmax\nrel fitted\n(N/Kg)", "Sfv\nfitted\n", "Sfv\nrel fitted\n",
+ "Sfv\nlm\n", "Sfv\nrel lm\n", "Pmax\nfitted\n(W)",
+ "Pmax\nrel fitted\n(W/Kg)", "Time to pmax\nfitted\n(s)", "F0\n\n(N)",
+ "F0\nrel\n(N/Kg)", "V0\n\n(m/s)", "Pmax\nlm\n(W)",
+ "Pmax\nrel lm\n(W/Kg)"
+ };
+ return headers;
+ }
+
private string readFromRunEncoderIfDataArrived()
{
string str = "";
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 6954c7b1..d61a6abf 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -172,9 +172,14 @@ public class RunEncoder
public static string GetScript() {
return System.IO.Path.Combine(UtilEncoder.GetSprintPath(), "sprintEncoder.R");
}
+ //this contains only Pulses;Time(useconds);Force(N)
public static string GetCSVFileName() {
return Path.Combine(Path.GetTempPath(), "cj_race_analyzer_data.csv");
}
+ //this contains: "Mass";"Height";"Temperature";"Vw";"Ka";"K.fitted";"Vmax.fitted"; ...
+ public static string GetCSVResultsFileName() {
+ return Path.Combine(Path.GetTempPath(), "sprintResults.csv");
+ }
public static string GetTempFileName() {
return Path.Combine(Path.GetTempPath(), "cj_race_analyzer_graph.png");
}
@@ -292,6 +297,91 @@ public class RunEncoderExercise
}
}
+//results coming from analyze (load) using R. To be published on exportable table
+public class RunEncoderCSV
+{
+ public double Mass;
+ public double Height;
+ public int Temperature;
+ public double Vw;
+ public double Ka;
+ public double K_fitted;
+ public double Vmax_fitted;
+ public double Amax_fitted;
+ public double Fmax_fitted;
+ public double Fmax_rel_fitted;
+ public double Sfv_fitted;
+ public double Sfv_rel_fitted;
+ public double Sfv_lm;
+ public double Sfv_rel_lm;
+ public double Pmax_fitted;
+ public double Pmax_rel_fitted;
+ public double Tpmax_fitted;
+ public double F0;
+ public double F0_rel;
+ public double V0;
+ public double Pmax_lm;
+ public double Pmax_rel_lm;
+
+ public RunEncoderCSV ()
+ {
+ }
+
+ public RunEncoderCSV (double mass, double height, int temperature, double vw, double ka, double
k_fitted, double vmax_fitted, double amax_fitted, double fmax_fitted, double fmax_rel_fitted, double
sfv_fitted, double sfv_rel_fitted, double sfv_lm, double sfv_rel_lm, double pmax_fitted, double
pmax_rel_fitted, double tpmax_fitted, double f0, double f0_rel, double v0, double pmax_lm, double pmax_rel_lm)
+ {
+ this.Mass = mass;
+ this.Height = height;
+ this.Temperature = temperature;
+ this.Vw = vw;
+ this.Ka = ka;
+ this.K_fitted = k_fitted;
+ this.Vmax_fitted = vmax_fitted;
+ this.Amax_fitted = amax_fitted;
+ this.Fmax_fitted = fmax_fitted;
+ this.Fmax_rel_fitted = fmax_rel_fitted;
+ this.Sfv_fitted = sfv_fitted;
+ this.Sfv_rel_fitted = sfv_rel_fitted;
+ this.Sfv_lm = sfv_lm;
+ this.Sfv_rel_lm = sfv_rel_lm;
+ this.Pmax_fitted = pmax_fitted;
+ this.Pmax_rel_fitted = pmax_rel_fitted;
+ this.Tpmax_fitted = tpmax_fitted;
+ this.F0 = f0;
+ this.F0_rel = f0_rel;
+ this.V0 = v0;
+ this.Pmax_lm = pmax_lm;
+ this.Pmax_rel_lm = pmax_rel_lm;
+ }
+
+ public string [] ToTreeView()
+ {
+ return new string [] {
+ Util.TrimDecimals(Mass, 1),
+ Util.TrimDecimals(Height, 1),
+ Temperature.ToString(),
+ Util.TrimDecimals(Vw, 3),
+ Util.TrimDecimals(Ka, 3),
+ Util.TrimDecimals(K_fitted, 3),
+ Util.TrimDecimals(Vmax_fitted, 3),
+ Util.TrimDecimals(Amax_fitted, 3),
+ Util.TrimDecimals(Fmax_fitted, 3),
+ Util.TrimDecimals(Fmax_rel_fitted, 3),
+ Util.TrimDecimals(Sfv_fitted, 3),
+ Util.TrimDecimals(Sfv_rel_fitted, 3),
+ Util.TrimDecimals(Sfv_lm, 3),
+ Util.TrimDecimals(Sfv_rel_lm, 3),
+ Util.TrimDecimals(Pmax_fitted, 3),
+ Util.TrimDecimals(Pmax_rel_fitted, 3),
+ Util.TrimDecimals(Tpmax_fitted, 3),
+ Util.TrimDecimals(F0, 3),
+ Util.TrimDecimals(F0_rel, 3),
+ Util.TrimDecimals(V0, 3),
+ Util.TrimDecimals(Pmax_lm, 3),
+ Util.TrimDecimals(Pmax_rel_lm, 3)
+ };
+ }
+}
+
public class RunEncoderGraph
{
private int testLength;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]