[chronojump/michrolab] RaceAnalyzer analyze current set, shows date/time columns on treeview and can export them
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/michrolab] RaceAnalyzer analyze current set, shows date/time columns on treeview and can export them
- Date: Fri, 5 Aug 2022 09:19:43 +0000 (UTC)
commit 7dca3983f13ddde465b24de553e5fb6f61db4a85
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jul 29 13:21:05 2022 +0200
RaceAnalyzer analyze current set, shows date/time columns on treeview and can export them
src/gui/app1/runEncoder.cs | 64 ++++++++++++++++++++++++++++++++++------------
src/runEncoder.cs | 17 +++++++++---
src/util.cs | 18 +++++++++++--
3 files changed, 78 insertions(+), 21 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index cd2b5488d..30c563e5a 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -1510,33 +1510,56 @@ public partial class ChronoJumpWindow
private void createTreeViewRaceEncoder (string contents)
{
- string [] columnsString = getTreeviewRaceAnalyzerHeaders();
+ // 1) read the contents of the CSV
+ RunEncoderCSV recsv = readRunEncoderCSVContents (contents);
+
+ // 2) Add the columns to the treeview
+ string [] columnsString = getTreeviewRaceAnalyzerHeaders(contents);
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),
- typeof (string), typeof (string), typeof (string), typeof (string) //raw
(vmax, amax, fmax, pmax)
- );
+ // 3) Add the TreeStore
+ Type [] types = new Type [columnsString.Length];
+ for (int i=0; i < columnsString.Length; i++) {
+ types[i] = typeof (string);
+ }
+ TreeStore store = new TreeStore(types);
- RunEncoderCSV recsv = readRunEncoderCSVContents (contents);
store.AppendValues (recsv.ToTreeView());
+ // 4) Assing model to store and other tweaks
treeview_raceAnalyzer.Model = store;
treeview_raceAnalyzer.Selection.Mode = SelectionMode.None;
treeview_raceAnalyzer.HeadersVisible=true;
}
- private string [] getTreeviewRaceAnalyzerHeaders ()
+ private string [] getTreeviewRaceAnalyzerHeaders (string contents)
{
+ // 1) check how many dist columns we should add
+ List<string> dist_l = new List<string> ();
+ using (StringReader reader = new StringReader (contents))
+ {
+ string line = reader.ReadLine (); //headers
+ LogB.Information(line);
+ if (line != null)
+ {
+ string [] cells = line.Split(new char[] {';'});
+ dist_l = new List<string> ();
+ for (int i = 26; i < cells.Length; i ++) //Attention!: take care with this 26
if in the future add more columns before dist/times
+ {
+ //each string comes as "X25.5m" convert to Time\n25.5\n(m) or
Time\n25,5\n(m)
+ string temp = Util.RemoveChar (cells[i], '"', false);
+ temp = Util.RemoveChar (temp, 'X', false);
+ temp = Util.ChangeChars (temp, "m", "\n(m)");
+ temp = Util.ChangeDecimalSeparator (temp);
+ temp = Catalog.GetString ("Time") + "\n" + temp;
+ dist_l.Add (temp);
+ }
+ }
+ }
+
+ // 2) prepare the headers
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)",
@@ -1548,6 +1571,10 @@ public partial class ChronoJumpWindow
"Pmax\nrel lm\n(W/Kg)",
"Vmax\nraw\n(m/s)", "Amax\nraw\n(m/s^2)", "Fmax\nraw\n(N)", "Pmax\nraw\n(W)"
};
+
+ // 3) add the dists to the headers
+ headers = Util.AddToArrayString (headers, dist_l);
+
return headers;
}
@@ -1559,7 +1586,6 @@ public partial class ChronoJumpWindow
using (StringReader reader = new StringReader (contents))
{
line = reader.ReadLine (); //headers
- //LogB.Information(line);
do {
line = reader.ReadLine ();
LogB.Information(line);
@@ -1568,6 +1594,11 @@ public partial class ChronoJumpWindow
string [] cells = line.Split(new char[] {';'});
+ // get the times (total columns can be different each time)
+ List<double> time_l = new List<double> ();
+ for (int i = 26; i < cells.Length; i ++) //Attention! take care with this 26
if in the future add more columns before dist/times
+ time_l.Add (Convert.ToDouble (cells[i]));
+
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]),
@@ -1578,7 +1609,8 @@ public partial class ChronoJumpWindow
Convert.ToDouble(cells[18]), Convert.ToDouble(cells[19]),
Convert.ToDouble(cells[20]),
Convert.ToDouble(cells[21]),
Convert.ToDouble(cells[22]), Convert.ToDouble(cells[23]),
//vmax raw, amax raw
- Convert.ToDouble(cells[24]), Convert.ToDouble(cells[25])
//fmax raw, pmax raw
+ Convert.ToDouble(cells[24]), Convert.ToDouble(cells[25]),
//fmax raw, pmax raw
+ time_l
);
} while(true);
}
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 4f33d4673..afad804dc 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -842,13 +842,15 @@ public class RunEncoderCSV
public double Amax_raw;
public double Fmax_raw;
public double Pmax_raw;
+ public List<double> time_l;
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,
- double vmax_raw, double amax_raw, double fmax_raw, double pmax_raw)
+ double vmax_raw, double amax_raw, double fmax_raw, double pmax_raw,
+ List<double> time_l)
{
this.Mass = mass;
this.Height = height;
@@ -876,11 +878,12 @@ public class RunEncoderCSV
this.Amax_raw = amax_raw;
this.Fmax_raw = fmax_raw;
this.Pmax_raw = pmax_raw;
+ this.time_l = time_l;
}
public string [] ToTreeView()
{
- return new string [] {
+ string [] strArray = new string [] {
Util.TrimDecimals(Mass, 1),
Util.TrimDecimals(Height, 1),
Temperature.ToString(),
@@ -906,8 +909,16 @@ public class RunEncoderCSV
Util.TrimDecimals(Vmax_raw, 3),
Util.TrimDecimals(Amax_raw, 3),
Util.TrimDecimals(Fmax_raw, 3),
- Util.TrimDecimals(Pmax_raw, 3),
+ Util.TrimDecimals(Pmax_raw, 3)
};
+
+ //convert time_l to strings to add them to strArray
+ List<string> timeStr_l = new List<string> ();
+ foreach (double time in time_l)
+ timeStr_l.Add (Util.TrimDecimals (time, 3));
+ strArray = Util.AddToArrayString (strArray, timeStr_l);
+
+ return strArray;
}
public string ToCSV(string decimalSeparator)
diff --git a/src/util.cs b/src/util.cs
index eaadb1e52..5b8a145a3 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1953,7 +1953,20 @@ public class Util
return TrimDecimals(myLimitedWithoutLetter, pDN) + myLimitedLetter;
}
- public static string [] AddArrayString(string [] initialString, string [] addString) {
+ public static string [] AddToArrayString(string [] initialString, List<string> add_l)
+ {
+ string [] returnString = new string[initialString.Length + add_l.Count];
+ int i, j;
+ for (i=0 ; i < initialString.Length; i ++)
+ returnString[i] = initialString[i];
+ for (j=0 ; j < add_l.Count; j ++)
+ returnString[i+j] = add_l[j];
+
+ return returnString;
+ }
+
+ public static string [] AddArrayString(string [] initialString, string [] addString)
+ {
string [] returnString = new string[initialString.Length + addString.Length];
int i;
int j;
@@ -1966,7 +1979,8 @@ public class Util
}
//bool firstOrLast: true means first
- public static string [] AddArrayString(string [] initialString, string addString, bool firstOrLast) {
+ public static string [] AddArrayString(string [] initialString, string addString, bool firstOrLast)
+ {
string [] returnString = new string[initialString.Length + 1];
int i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]