[chronojump] New feature! force sensor manual analysis with zoom
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] New feature! force sensor manual analysis with zoom
- Date: Fri, 22 Mar 2019 20:23:05 +0000 (UTC)
commit 7d119075498211c909e7cd955e1150c0692e9e25
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Mar 22 21:22:33 2019 +0100
New feature! force sensor manual analysis with zoom
glade/app1.glade | 37 +++++++++++++++++++++++++++-------
src/forceSensor.cs | 20 ++++++++++++++----
src/gui/forceSensor.cs | 6 ++++++
src/gui/forceSensorAnalyze.cs | 47 +++++++++++++++++++++++++++++++++++++++++--
4 files changed, 97 insertions(+), 13 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 9db9a077..9ba15dd3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -19882,7 +19882,7 @@ Concentric</property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox270">
+ <widget class="GtkHBox"
id="hbox_force_general_analysis">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
@@ -19942,12 +19942,6 @@ Concentric</property>
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel"
id="label_force_sensor_ai_force_a">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -20660,6 +20654,35 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <widget class="GtkHBox" id="hbox270">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkButton"
id="button_force_sensor_ai_zoom">
+ <property name="label">Zoom [A-B]</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_force_sensor_ai_zoom_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options"/>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index befeb343..befe36b7 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -639,19 +639,19 @@ public class ForceSensorAnalyzeInstant
private int graphWidth;
private int graphHeight;
- public ForceSensorAnalyzeInstant(string file, int graphWidth, int graphHeight)
+ public ForceSensorAnalyzeInstant(string file, int graphWidth, int graphHeight, double start, double
end)
{
this.graphWidth = graphWidth;
this.graphHeight = graphHeight;
- readFile(file);
+ readFile(file, start, end);
//ensure points fit on display
if(fscAIPoints.OutsideGraph(forceSensorValues.TimeLast, forceSensorValues.ForceMax,
forceSensorValues.ForceMin))
fscAIPoints.Redo();
}
- private void readFile(string file)
+ private void readFile(string file, double start, double end)
{
fscAIPoints = new ForceSensorCapturePoints(graphWidth, graphHeight);
@@ -678,7 +678,19 @@ public class ForceSensorAnalyzeInstant
if(Util.IsNumber(strFull[0], false) && Util.IsNumber(strFull[1], true))
{
- int time = Convert.ToInt32(strFull[0]);
+ double timeD = Convert.ToDouble(strFull[0]);
+
+ //start can be -1 meaning that no zoom has to be applied
+ if(start != -1)
+ {
+ if(timeD < start || timeD > end)
+ continue;
+
+ //put time at 0
+ timeD -= Convert.ToInt32(start);
+ }
+
+ int time = Convert.ToInt32(timeD);
double force = Convert.ToDouble(strFull[1]);
fscAIPoints.Add(time, force);
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 81b35e3a..980d3fa8 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -851,7 +851,10 @@ LogB.Information(" re C ");
//if drawingarea has still not shown, don't paint graph because GC
screen is not defined
if(force_sensor_ai_drawingareaShown)
+ {
+ forceSensorZoomDefaultValues();
forceSensorDoGraphAI();
+ }
if( configChronojump.Exhibition &&
( configChronojump.ExhibitionStationType ==
ExhibitionTest.testTypes.FORCE_ROPE ||
@@ -1142,7 +1145,10 @@ LogB.Information(" re R ");
//if drawingarea has still not shown, don't paint graph because GC screen is not
defined
if(force_sensor_ai_drawingareaShown)
+ {
+ forceSensorZoomDefaultValues();
forceSensorDoGraphAI();
+ }
}
filechooser.Destroy ();
}
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index 596e81a8..48347bad 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -39,6 +39,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Button button_force_sensor_image_save_rfd_auto;
[Widget] Gtk.Button button_force_sensor_image_save_rfd_manual;
[Widget] Gtk.Button button_force_sensor_analyze_AB_save;
+ [Widget] Gtk.Button button_force_sensor_ai_zoom;
[Widget] Gtk.SpinButton spin_force_duration_seconds;
[Widget] Gtk.RadioButton radio_force_duration_seconds;
@@ -509,11 +510,33 @@ public partial class ChronoJumpWindow
if(lastForceSensorFullPath == null || lastForceSensorFullPath == "")
return;
+ double zoomA = -1;
+ double zoomB = -1;
+ if(forceSensorZoomApplied && checkbutton_force_sensor_ai_b.Active &&
+ Util.IsNumber(label_force_sensor_ai_time_a.Text, true) &&
+ Util.IsNumber(label_force_sensor_ai_time_b.Text, true))
+ {
+ zoomA = fsAI.GetTimeMS(Convert.ToInt32(hscale_force_sensor_ai_a.Value)) * 1000;
+ zoomB = fsAI.GetTimeMS(Convert.ToInt32(hscale_force_sensor_ai_b.Value)) * 1000;
+
+ //do not zoom if both are the same
+ if(zoomA == zoomB)
+ {
+ zoomA = -1;
+ zoomB = -1;
+ } else if(zoomA > zoomB) //invert if needed
+ {
+ double temp = zoomA;
+ zoomA = zoomB;
+ zoomB = temp;
+ }
+ }
+
fsAI = new ForceSensorAnalyzeInstant(
lastForceSensorFullPath,
force_sensor_ai_drawingarea.Allocation.Width,
- force_sensor_ai_drawingarea.Allocation.Height
- );
+ force_sensor_ai_drawingarea.Allocation.Height,
+ zoomA, zoomB);
/*
* position the hscales on the left to avoid loading a csv
@@ -681,6 +704,24 @@ public partial class ChronoJumpWindow
LogB.Information("EXPOSE END");
}
+
+ private bool forceSensorZoomApplied;
+ private void forceSensorZoomDefaultValues()
+ {
+ forceSensorZoomApplied = false;
+ }
+ private void on_button_force_sensor_ai_zoom_clicked (object o, EventArgs args)
+ {
+ forceSensorZoomApplied = ! forceSensorZoomApplied;
+
+ if(forceSensorZoomApplied)
+ button_force_sensor_ai_zoom.Label = "Unzoom [A-B]";
+ else
+ button_force_sensor_ai_zoom.Label = "Zoom [A-B]";
+
+ forceSensorDoGraphAI();
+ }
+
private void forceSensorAnalyzeManualGraphDo(Rectangle allocation)
{
if(fsAI.GetLength() == 0)
@@ -1002,6 +1043,8 @@ public partial class ChronoJumpWindow
label_force_sensor_ai_rfd_average.Visible = visible;
label_force_sensor_ai_rfd_max.Visible = visible;
+ button_force_sensor_ai_zoom.Visible = visible;
+
if(visible && canDoForceSensorAnalyzeAB())
button_force_sensor_analyze_AB_save.Visible = true;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]