[chronojump] First implementation of encoder Cairo bars (all eccons) work at realtime capture, load, resize, reca
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] First implementation of encoder Cairo bars (all eccons) work at realtime capture, load, resize, reca
- Date: Thu, 17 Mar 2022 08:57:53 +0000 (UTC)
commit 2d4fd24b8b726714834cab2e2e605d6971fbc165
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Mar 17 09:56:31 2022 +0100
First implementation of encoder Cairo bars (all eccons) work at realtime capture, load, resize,
recalculate, after feedback window.
glade/app1.glade | 28 ++++++++-
src/gui/app1/chronojump.cs | 16 +++++
src/gui/app1/encoder.cs | 80 +++++++++++++++++++++++-
src/gui/cairo/bars.cs | 12 +++-
src/gui/eventExecute.cs | 147 ++++++++++++++++++++++++++++++++++++++++++++-
src/gui/usefulObjects.cs | 54 ++++++++++++++++-
6 files changed, 328 insertions(+), 9 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 509f49b3a..f42e221f7 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -26258,6 +26258,12 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -33721,6 +33727,18 @@ Concentric</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
+ <widget class="GtkDrawingArea"
id="encoder_capture_curves_bars_drawingarea_cairo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="expose_event"
handler="on_encoder_capture_curves_bars_drawingarea_cairo_expose_event" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox" id="hbox156">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -33743,7 +33761,7 @@ Concentric</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -33842,7 +33860,7 @@ Concentric</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</widget>
@@ -42357,6 +42375,12 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index f5ec8ce7f..4bef3ec11 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -7807,6 +7807,22 @@ LogB.Debug("mc finished 5");
preferences.encoderCaptureMainVariableThisSetOrHistorical,
sendMaxPowerSpeedForceIntersession(mainVariable),
sendMaxPowerSpeedForceIntersessionDate(mainVariable));
+
+ //Cairo
+ prepareEventGraphBarplotEncoder = new
PrepareEventGraphBarplotEncoder (
+ mainVariableStr, mainVariableHigher,
mainVariableLower,
+ secondaryVariableStr,
preferences.encoderCaptureShowLoss,
+ false, //not capturing
+ findEccon(true),
+ repetitiveConditionsWin,
+ encoderConfigurationCurrent.has_inertia,
+ configChronojump.PlaySoundsFromFile,
+ captureCurvesBarsData,
+ encoderCaptureListStore,
+
preferences.encoderCaptureMainVariableThisSetOrHistorical,
+
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
+
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+ prepareEncoderBarplotCairo ();
}
} else
UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea,
encoder_capture_curves_bars_pixmap);
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index ea7f5f6a0..9c560108a 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -343,6 +343,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.DrawingArea encoder_capture_signal_drawingarea_cairo;
[Widget] Gtk.DrawingArea encoder_capture_curves_bars_drawingarea;
+ [Widget] Gtk.DrawingArea encoder_capture_curves_bars_drawingarea_cairo;
Gdk.Pixmap encoder_capture_curves_bars_pixmap = null;
ArrayList encoderCaptureCurves;
@@ -446,6 +447,8 @@ public partial class ChronoJumpWindow
static List<PointF> cairoGraphEncoderSignalPoints_l;
static List<PointF> cairoGraphEncoderSignalInertialPoints_l;
+ PrepareEventGraphBarplotEncoder prepareEventGraphBarplotEncoder;
+
enum encoderSensEnum {
NOSESSION, NOPERSON, YESPERSON, PROCESSINGCAPTURE, PROCESSINGR, DONENOSIGNAL, DONEYESSIGNAL }
encoderSensEnum encoderSensEnumStored; //tracks how was sensitive before PROCESSINGCAPTURE or
PROCESSINGR
@@ -5891,6 +5894,22 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureMainVariableThisSetOrHistorical,
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+
+ //Cairo
+ prepareEventGraphBarplotEncoder = new PrepareEventGraphBarplotEncoder (
+ mainVariable, mainVariableHigher, mainVariableLower,
+ secondaryVariable, preferences.encoderCaptureShowLoss,
+ false, //not capturing
+ findEccon(true),
+ repetitiveConditionsWin,
+ encoderConfigurationCurrent.has_inertia,
+ configChronojump.PlaySoundsFromFile,
+ captureCurvesBarsData,
+ encoderCaptureListStore,
+ preferences.encoderCaptureMainVariableThisSetOrHistorical,
+
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
+
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+ prepareEncoderBarplotCairo ();
}
}
@@ -5976,7 +5995,34 @@ public partial class ChronoJumpWindow
}
}
}
-
+
+ public void on_encoder_capture_curves_bars_drawingarea_cairo_expose_event (object o, ExposeEventArgs
args)
+ {
+ LogB.Information("on_encoder_capture_curves_bars_drawingarea_cairo_expose_event A");
+ //if object not defined or not defined fo this mode, return
+//TODO: is fist check really needed?
+// if(cairoPaintBarsPre == null || ! cairoPaintBarsPre.ModeMatches (current_mode))
+// return;
+
+ LogB.Information("on_encoder_capture_curves_bars_drawingarea_cairo_expose_event B");
+ if(prepareEventGraphBarplotEncoder != null)
+ prepareEncoderBarplotCairo ();
+ }
+
+ private void prepareEncoderBarplotCairo ()
+ {
+ LogB.Information("prepareEncoderBarplotCairo");
+ if(currentPerson == null)
+ return;
+
+ cairoPaintBarsPre = new CairoPaintBarplotPreEncoder (
+ encoder_capture_curves_bars_drawingarea_cairo,
preferences.fontType.ToString(),
+ currentPerson.Name, "", 3,
+ prepareEventGraphBarplotEncoder);
+
+ cairoPaintBarsPre.Paint();
+ }
+
public void on_encoder_capture_signal_drawingarea_cairo_expose_event (object o, ExposeEventArgs args)
{
updateEncoderCaptureSignalCairo (current_mode == Constants.Modes.POWERINERTIAL, true);
@@ -6716,6 +6762,22 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureMainVariableThisSetOrHistorical,
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+
+ //Cairo
+ prepareEventGraphBarplotEncoder = new PrepareEventGraphBarplotEncoder
(
+ mainVariable, mainVariableHigher, mainVariableLower,
+ secondaryVariable, preferences.encoderCaptureShowLoss,
+ true, //capturing
+ findEccon(true),
+ repetitiveConditionsWin,
+ encoderConfigurationCurrent.has_inertia,
+ configChronojump.PlaySoundsFromFile,
+ captureCurvesBarsData,
+ encoderCaptureListStore,
+
preferences.encoderCaptureMainVariableThisSetOrHistorical,
+
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
+
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+ prepareEncoderBarplotCairo ();
}
//}
@@ -7299,6 +7361,22 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureMainVariableThisSetOrHistorical,
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+
+ //Cairo
+ prepareEventGraphBarplotEncoder = new PrepareEventGraphBarplotEncoder
(
+ mainVariable, mainVariableHigher, mainVariableLower,
+ secondaryVariable, preferences.encoderCaptureShowLoss,
+ false, //not capturing
+ findEccon(true),
+ repetitiveConditionsWin,
+ encoderConfigurationCurrent.has_inertia,
+ configChronojump.PlaySoundsFromFile,
+ captureCurvesBarsData,
+ encoderCaptureListStore,
+
preferences.encoderCaptureMainVariableThisSetOrHistorical,
+
sendMaxPowerSpeedForceIntersession(preferences.encoderCaptureMainVariable),
+
sendMaxPowerSpeedForceIntersessionDate(preferences.encoderCaptureMainVariable));
+ prepareEncoderBarplotCairo ();
}
button_encoder_signal_save_comment.Label = Catalog.GetString("Save comment");
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index fb16e2e51..5b24db37b 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -650,7 +650,7 @@ public abstract class CairoBars : CairoGeneric
set { yUnits = value; }
}
- //for CairoBars2HSeries (legend)
+ //for CairoBarsNHSeries (legend)
public string VariableSerieA {
set { variableSerieA = value; }
}
@@ -940,6 +940,13 @@ public class CairoBarsNHSeries : CairoBars
//note pointA_l and pointB_l have same length
protected override void plotBars ()
{
+ /* debug stuff
+ LogB.Information("plotBars NH pointB_l.Count: " + pointB_l.Count.ToString());
+ LogB.Information("plotBars NH pointSecondary_l.Count: " + pointSecondary_l.Count.ToString());
+ LogB.Information("plotBars NH pointSecondary_l[0].Count: " +
pointSecondary_l[0].Count.ToString());
+ LogB.Information("plotBars NH names_l.Count: " + names_l.Count.ToString());
+ */
+
//calculate separation between series and bar width
double distanceBetweenCols = (graphWidth - (leftMargin+rightMargin))/maxX;
@@ -1017,7 +1024,7 @@ public class CairoBarsNHSeries : CairoBars
//public override void GraphDo (List<List<PointF>> pointSecondary_l, List<PointF> pointB_l,
List<string> names_l, int fontHeightForBottomNames, int marginForBottomNames, string
title)
{
- LogB.Information("at CairoBars2HSeries.GraphDo");
+ //LogB.Information("at CairoBarsNHSeries.GraphDo");
//this.pointA_l = pointA_l;
//this.pointSecondary_l = pointSecondary_l;
this.pointB_l = pointB_l;
@@ -1028,6 +1035,7 @@ public class CairoBarsNHSeries : CairoBars
bottomMargin += marginForBottomNames;
+ //LogB.Information(string.Format("NH GraphDo: pointA_l.Count: {0}, pointB_l.Count: {1}",
pointA_l.Count, pointB_l.Count));
findMaximums();
g.SetFontSize(textHeight);
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 4cdeae5a0..b16a065a8 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -20,7 +20,7 @@ curses trams graph de sessiĆ³ podria ser 2H (totaltime, maxSpeed)
* 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) 2004-2021 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2022 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -156,8 +156,8 @@ public partial class ChronoJumpWindow
//string cairoTitleStored;
//we need both working to be able to correctly expose_event on jumpRj, runI
- CairoPaintBarsPre cairoPaintBarsPre;
- CairoPaintBarsPre cairoPaintBarsPreRealTime;
+ CairoPaintBarsPre cairoPaintBarsPre; //used for contacts test (no realtime), and also encoder
+ CairoPaintBarsPre cairoPaintBarsPreRealTime; //contacts time realtime: jumpRj/runI capture
CairoManageRunDoubleContacts cairoManageRunDoubleContacts;
@@ -419,6 +419,7 @@ public partial class ChronoJumpWindow
LogB.Information("CONFIGURE END");
}
+ //this will disappear (non cairo) right now is only used for reaction time, pulses, multichronopic
public void on_event_execute_drawingarea_expose_event(object o, ExposeEventArgs args)
{
//LogB.Information("EXPOSE START");
@@ -2133,6 +2134,9 @@ public abstract class CairoPaintBarsPre
//run interval
public PrepareEventGraphRunInterval eventGraphRunsIntervalStored;
+ //encoder
+ public PrepareEventGraphBarplotEncoder eventGraphEncoderBarplotStored;
+
protected DrawingArea darea;
protected string fontStr;
protected Constants.Modes mode;
@@ -2169,6 +2173,9 @@ public abstract class CairoPaintBarsPre
public virtual void StoreEventGraphRunsInterval (PrepareEventGraphRunInterval eventGraph)
{
}
+ public virtual void StoreEventGraphBarplotEncoder (PrepareEventGraphBarplotEncoder eventGraph)
+ {
+ }
/*
public void Prepare ()
@@ -3344,3 +3351,137 @@ public class CairoManageRunDoubleContacts
return timeTotalWithExtraPTL + negativePTLTime;
}
}
+
+public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
+{
+ private PrepareEventGraphBarplotEncoder pegbe;
+
+ //private ArrayList data; //data is related to mainVariable (barplot)
+ private List<PointF> dataA_l; //data is related to mainVariable (barplot)
+ private List<PointF> dataB_l; //data is related to mainVariable (barplot)
+ private ArrayList dataSecondary; //dataSecondary is related to secondary variable (by default range)
+ private ArrayList dataRangeOfMovement; //ROM, need it to discard last rep for loss. Is not the same
as dataSecondary because maybe user selected another variable as secondary. only checks con.
+ private ArrayList dataWorkJ;
+ private ArrayList dataImpulse;
+
+ private List<string> names_l;
+
+ //just blank the screen
+ public CairoPaintBarplotPreEncoder (DrawingArea darea, string fontStr)
+ {
+ blankScreen(darea, fontStr);
+ }
+
+ //isLastCaptured: if what we are showing is currentJumpRj then true, if is a selection from treeview
and id != currentJumpRj then is false (meaning selected)
+
+ public CairoPaintBarplotPreEncoder (DrawingArea darea, string fontStr,
+ string personName, string testName, int pDN,
+ PrepareEventGraphBarplotEncoder pegbe)
+ {
+ this.pegbe = pegbe;
+
+ initialize (darea, fontStr, mode, personName, testName, pDN);
+ }
+
+ protected override bool storeCreated ()
+ {
+ //return (eventGraphEncoderBarplotStored != null);
+ return (pegbe.data9Variables.Count > 0);
+ }
+
+ protected override bool haveDataToPlot()
+ {
+ return (pegbe.data9Variables.Count > 0);
+ }
+
+ protected override void paintSpecific()
+ {
+ fillDataVariables ();
+ paintSpecificDo ();
+ }
+
+ private void fillDataVariables ()
+ {
+ //data = new ArrayList (pegbe.data9Variables.Count); //data is related to mainVariable
(barplot)
+ dataA_l = new List<PointF>(); //data is related to mainVariable (barplot)
+ dataB_l = new List<PointF>(); //data is related to mainVariable (barplot)
+ dataSecondary = new ArrayList (pegbe.data9Variables.Count); //dataSecondary is related to
secondary variable (by default range)
+ dataRangeOfMovement = new ArrayList (pegbe.data9Variables.Count);
+ dataWorkJ = new ArrayList (pegbe.data9Variables.Count);
+ dataImpulse = new ArrayList (pegbe.data9Variables.Count);
+ bool lastIsEcc = false;
+ //int count = 0;
+
+ string units = "";
+ int decimals;
+
+ if(pegbe.mainVariable == Constants.MeanSpeed || pegbe.mainVariable == Constants.MaxSpeed) {
+ units = "m/s";
+ decimals = 2;
+ } else if(pegbe.mainVariable == Constants.MeanForce || pegbe.mainVariable ==
Constants.MaxForce) {
+ units = "N";
+ decimals = 1;
+ }
+ else { //powers
+ units = "W";
+ decimals = 1;
+ }
+
+ names_l = new List<string>();
+
+ //discard repetitions according to showNRepetitions
+ //int countToDraw = pegbe.data9Variables.Count;
+ //foreach(EncoderBarsData ebd in pegbe.data9Variables)
+ //for (int count = 0; count < pegbe.data9Variables.Count; count ++)
+// int countNames = 0;
+ for (int count = (pegbe.data9Variables.Count -1); count >= 0; count --)
+ {
+ EncoderBarsData ebd = (EncoderBarsData) pegbe.data9Variables[count];
+
+ if(pegbe.eccon == "c")
+ {
+ dataA_l.Add(new PointF(count +1, ebd.GetValue(pegbe.mainVariable)));
+ names_l.Add((count +1).ToString());
+ } else
+ {
+ if(! Util.IsEven(count +1)) //if it is "impar"
+ {
+ dataA_l.Add(new PointF(UtilAll.DivideSafe(count+1,2),
ebd.GetValue(pegbe.mainVariable)));
+ names_l.Add((UtilAll.DivideSafe(count,2) +1).ToString());
+ } else // "par"
+ dataB_l.Add(new PointF(UtilAll.DivideSafe(count+1,2),
ebd.GetValue(pegbe.mainVariable)));
+ }
+
+ //TODO: copy stuff from /gui/encoderGraphObjects fillDataVariables()
+ }
+ }
+
+ private void paintSpecificDo ()
+ {
+ CairoBars cb;
+
+ if(pegbe.eccon == "c")
+ cb = new CairoBars1Series (darea);
+ else
+ cb = new CairoBarsNHSeries (darea);
+
+ //LogB.Information("data_l.Count: " + data_l.Count.ToString());
+ //cb.GraphInit(fontStr, true, false); //usePersonGuides, useGroupGuides
+ cb.GraphInit(fontStr, false, false); //usePersonGuides, useGroupGuides
+
+ if(pegbe.eccon == "c")
+ cb.GraphDo (dataA_l, new List<PointF>(), names_l,
+ 14, 8, "my title");
+ else
+ {
+ //TODO: why we need secondary? seems a list of many points
+ List<List<PointF>> pointSecondary_l = new List<List<PointF>>();
+ pointSecondary_l.Add(dataA_l);
+ cb.PassPointSecondaryList(pointSecondary_l);
+
+ cb.GraphDo (dataA_l, dataB_l, names_l,
+ 14, 8, "my title");
+ }
+ }
+}
+
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 96c419f0c..240272ba7 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -15,7 +15,7 @@
* 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) 2004-2021 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2022 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -385,6 +385,58 @@ public class PrepareEventGraphRunIntervalRealtimeCapture
~PrepareEventGraphRunIntervalRealtimeCapture() {}
}
+public class PrepareEventGraphBarplotEncoder
+{
+ public string mainVariable;
+ public double mainVariableHigher;
+ public double mainVariableLower;
+ public string secondaryVariable;
+ public bool showLoss;
+ public bool capturing;
+ public string eccon;
+ public RepetitiveConditionsWindow repetitiveConditionsWin;
+ public bool hasInertia;
+ public bool playSoundsFromFile;
+ public ArrayList data9Variables;
+ public Gtk.ListStore encoderCaptureListStore;
+ public bool relativeToSet;
+ public double maxPowerSpeedForceIntersession; //it will be one of these 3
+ public string maxPowerSpeedForceIntersessionDate;
+
+ public PrepareEventGraphBarplotEncoder () {
+ }
+
+ public PrepareEventGraphBarplotEncoder (
+ string mainVariable, double mainVariableHigher, double mainVariableLower,
+ string secondaryVariable, bool showLoss,
+ bool capturing, string eccon,
+ RepetitiveConditionsWindow repetitiveConditionsWin,
+ bool hasInertia, bool playSoundsFromFile,
+ ArrayList data9Variables, Gtk.ListStore encoderCaptureListStore,
+ bool relativeToSet,
+ double maxPowerSpeedForceIntersession, string maxPowerSpeedForceIntersessionDate)
+ {
+ this.mainVariable = mainVariable;
+ this.mainVariableHigher = mainVariableHigher;
+ this.mainVariableLower = mainVariableLower;
+ this.secondaryVariable = secondaryVariable;
+ this.showLoss = showLoss;
+ this.capturing = capturing;
+ this.eccon = eccon;
+ this.repetitiveConditionsWin = repetitiveConditionsWin;
+ this.hasInertia = hasInertia;
+ this.playSoundsFromFile = playSoundsFromFile;
+ this.data9Variables = data9Variables;
+ this.encoderCaptureListStore = encoderCaptureListStore;
+ this.relativeToSet = relativeToSet;
+ this.maxPowerSpeedForceIntersession = maxPowerSpeedForceIntersession;
+ this.maxPowerSpeedForceIntersessionDate = maxPowerSpeedForceIntersessionDate;
+ }
+
+ ~PrepareEventGraphBarplotEncoder () {}
+}
+
+
public class PrepareEventGraphPulse {
public double lastTime;
public string timesString;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]