[chronojump] RaceAnalyzer vertical grid lines working for variable segments
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] RaceAnalyzer vertical grid lines working for variable segments
- Date: Fri, 4 Feb 2022 18:49:40 +0000 (UTC)
commit 44d48984dd710df53601da825115c8367f73637e
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 4 19:49:13 2022 +0100
RaceAnalyzer vertical grid lines working for variable segments
src/gui/app1/runEncoder.cs | 15 ++++++++-------
src/gui/cairo/raceAnalyzer.cs | 4 +++-
src/runEncoder.cs | 30 +++++++++++++++++++++++++-----
3 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 5034b874c..1322ce53c 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -571,7 +571,8 @@ public partial class ChronoJumpWindow
cairoGraphRaceAnalyzerPoints_at_l = new List<PointF>();
//RunEncoderCaptureGetSpeedAndDisplacement reCGSD = new
RunEncoderCaptureGetSpeedAndDisplacement();
- reCGSD = new
RunEncoderCaptureGetSpeedAndDisplacement(currentRunEncoderExercise.SegmentMeters);
+ reCGSD = new RunEncoderCaptureGetSpeedAndDisplacement(
+ currentRunEncoderExercise.SegmentMeters,
currentRunEncoderExercise.SegmentVariableCm);
runEncoderShouldShowCaptureGraphsWithData = true;
runEncoderCaptureThread = new Thread(new ThreadStart(runEncoderCaptureDo));
@@ -1039,7 +1040,8 @@ public partial class ChronoJumpWindow
// ---- capture tab graphs start ---->
int count = 0;
- reCGSD = new
RunEncoderCaptureGetSpeedAndDisplacement(currentRunEncoderExercise.SegmentMeters);
+ reCGSD = new RunEncoderCaptureGetSpeedAndDisplacement(
+ currentRunEncoderExercise.SegmentMeters,
currentRunEncoderExercise.SegmentVariableCm);
runEncoderShouldShowCaptureGraphsWithData = true;
cairoGraphRaceAnalyzer_dt = null;
@@ -2224,15 +2226,14 @@ public partial class ChronoJumpWindow
return;
int verticalGridSeps = -1;
- if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0)
+ if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0) //TODO
check this with variable
verticalGridSeps = currentRunEncoderExercise.SegmentMeters;
TwoListsOfInts verticalLinesUs_2l = new TwoListsOfInts("dist","time");
- if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0 &&
+ if(currentRunEncoderExercise != null && //currentRunEncoderExercise.SegmentMeters > 0 &&
reCGSD.SegmentDistTime_2l != null)
verticalLinesUs_2l = reCGSD.SegmentDistTime_2l;
-
if(cairoGraphRaceAnalyzer_dt == null)
cairoGraphRaceAnalyzer_dt = new CairoGraphRaceAnalyzer(
drawingarea_race_analyzer_capture_position_time, "title",
@@ -2244,7 +2245,7 @@ public partial class ChronoJumpWindow
private void updateRaceAnalyzerCaptureSpeedTime(bool forceRedraw)
{
TwoListsOfInts verticalLinesUs_2l = new TwoListsOfInts("dist","time");
- if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0 &&
+ if(currentRunEncoderExercise != null && //currentRunEncoderExercise.SegmentMeters > 0 &&
reCGSD.SegmentDistTime_2l != null)
verticalLinesUs_2l = reCGSD.SegmentDistTime_2l;
@@ -2262,7 +2263,7 @@ public partial class ChronoJumpWindow
return;
TwoListsOfInts verticalLinesUs_2l = new TwoListsOfInts("dist","time");
- if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0 &&
+ if(currentRunEncoderExercise != null && //currentRunEncoderExercise.SegmentMeters > 0 &&
reCGSD.SegmentDistTime_2l != null)
verticalLinesUs_2l = reCGSD.SegmentDistTime_2l;
diff --git a/src/gui/cairo/raceAnalyzer.cs b/src/gui/cairo/raceAnalyzer.cs
index 95b13a001..443921785 100644
--- a/src/gui/cairo/raceAnalyzer.cs
+++ b/src/gui/cairo/raceAnalyzer.cs
@@ -119,7 +119,9 @@ public class CairoGraphRaceAnalyzer : CairoXY
else {
for(int i = 0 ; i < verticalLinesUs_2l.Count() ; i ++)
{
- string xTextTop =
verticalLinesUs_2l.GetFromFirst(i).ToString() + " m";
+ string xTextTop =
verticalLinesUs_2l.GetFromFirst(i).ToString() + "m";
+
+ //seconds
string xTextBottom =
Util.TrimDecimals(verticalLinesUs_2l.GetFromSecond(i)/1000000.0, 1).ToString();
double xGraph =
calculatePaintX(verticalLinesUs_2l.GetFromSecond(i)/1000000.0);
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 14a7e13ae..f50612af4 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -271,7 +271,9 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
{
//to calcule the vertical lines on pos/time, speed/time, accel/time
//it is calculated once and used on all
- private int segmentMeters;
+ private int segmentMeters; //note (m)
+ private List<int> segmentVariableCm; //if segmentMeters == -1 then this is used //note (cm)
+ private int segmentVariableCmDistAccumulated;
private TwoListsOfInts segmentDistTime_2l;
private int encoderDisplacement;
@@ -283,11 +285,13 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
private double runEncoderCaptureSpeed;
private double runEncoderCaptureSpeedMax;
- private double runEncoderCaptureDistance;
+ private double runEncoderCaptureDistance; //m
- public RunEncoderCaptureGetSpeedAndDisplacement(int segmentMeters)
+ public RunEncoderCaptureGetSpeedAndDisplacement(int segmentMeters, List<int> segmentVariableCm)
{
this.segmentMeters = segmentMeters;
+ this.segmentVariableCm = segmentVariableCm;
+ segmentVariableCmDistAccumulated = 0;
segmentDistTime_2l = new TwoListsOfInts("dist","time");
timePre = 0;
@@ -330,7 +334,9 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
runEncoderCaptureDistance += runEncoderCaptureDistanceAtThisSample;
if(segmentMeters > 0)
- updateSegmentDistTime ();
+ updateSegmentDistTimeFixed ();
+ else if(segmentVariableCm.Count > 0)
+ updateSegmentDistTimeVariable ();
hasCalculed = true;
}
@@ -338,10 +344,24 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
}
return hasCalculed;
}
- private void updateSegmentDistTime () //TODO: implement also for variable segmentMeters
+ private void updateSegmentDistTimeFixed () //m
{
if(runEncoderCaptureDistance >= segmentMeters * (segmentDistTime_2l.Count() +1))
segmentDistTime_2l.Add(segmentMeters * (segmentDistTime_2l.Count() +1), time);
+ //note this is not very precise because time can be a bit later than the selected dist
+ }
+ private void updateSegmentDistTimeVariable () //cm
+ {
+ //care of overflow
+ if(segmentDistTime_2l.Count() >= segmentVariableCm.Count)
+ return;
+
+ double distToBeat = (segmentVariableCm[segmentDistTime_2l.Count()] +
segmentVariableCmDistAccumulated) / 100.0; //cm -> m
+ if(runEncoderCaptureDistance >= distToBeat)
+ {
+ segmentVariableCmDistAccumulated += segmentVariableCm[segmentDistTime_2l.Count()];
+ segmentDistTime_2l.Add(Convert.ToInt32(distToBeat), time);
+ }
}
public int EncoderDisplacement {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]