Commit 7d119075 authored by Xavier de Blas's avatar Xavier de Blas

New feature! force sensor manual analysis with zoom

parent d163e114
......@@ -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>
......@@ -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);
......
......@@ -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 ();
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment