[chronojump] More precision to recent commits, using TwoListsOfDoubles
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] More precision to recent commits, using TwoListsOfDoubles
- Date: Fri, 4 Feb 2022 19:00:24 +0000 (UTC)
commit 3ddb3bcc68ab364799d479242717b9a59e9cbde1
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 4 20:00:05 2022 +0100
More precision to recent commits, using TwoListsOfDoubles
src/gui/app1/runEncoder.cs | 6 +++---
src/gui/cairo/raceAnalyzer.cs | 4 ++--
src/runEncoder.cs | 8 ++++----
src/utilMath.cs | 42 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 1322ce53c..fbc691fe6 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -2229,7 +2229,7 @@ public partial class ChronoJumpWindow
if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0) //TODO
check this with variable
verticalGridSeps = currentRunEncoderExercise.SegmentMeters;
- TwoListsOfInts verticalLinesUs_2l = new TwoListsOfInts("dist","time");
+ TwoListsOfDoubles verticalLinesUs_2l = new TwoListsOfDoubles();
if(currentRunEncoderExercise != null && //currentRunEncoderExercise.SegmentMeters > 0 &&
reCGSD.SegmentDistTime_2l != null)
verticalLinesUs_2l = reCGSD.SegmentDistTime_2l;
@@ -2244,7 +2244,7 @@ public partial class ChronoJumpWindow
}
private void updateRaceAnalyzerCaptureSpeedTime(bool forceRedraw)
{
- TwoListsOfInts verticalLinesUs_2l = new TwoListsOfInts("dist","time");
+ TwoListsOfDoubles verticalLinesUs_2l = new TwoListsOfDoubles();
if(currentRunEncoderExercise != null && //currentRunEncoderExercise.SegmentMeters > 0 &&
reCGSD.SegmentDistTime_2l != null)
verticalLinesUs_2l = reCGSD.SegmentDistTime_2l;
@@ -2262,7 +2262,7 @@ public partial class ChronoJumpWindow
if(radio_race_analyzer_capture_view_simple.Active)
return;
- TwoListsOfInts verticalLinesUs_2l = new TwoListsOfInts("dist","time");
+ TwoListsOfDoubles verticalLinesUs_2l = new TwoListsOfDoubles();
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 443921785..586492388 100644
--- a/src/gui/cairo/raceAnalyzer.cs
+++ b/src/gui/cairo/raceAnalyzer.cs
@@ -30,7 +30,7 @@ public class CairoGraphRaceAnalyzer : CairoXY
int points_list_painted;
private bool plotHorizArrowFromMaxY;
private int verticalGridSep;
- private TwoListsOfInts verticalLinesUs_2l;
+ private TwoListsOfDoubles verticalLinesUs_2l;
/*
//constructor when there are no points
@@ -56,7 +56,7 @@ public class CairoGraphRaceAnalyzer : CairoXY
string yVariable, string yUnits,
bool plotHorizArrowFromMaxY,
int verticalGridSep, //-1 if auto
- TwoListsOfInts verticalLinesUs_2l)
+ TwoListsOfDoubles verticalLinesUs_2l)
{
this.area = area;
this.title = title;
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index f50612af4..de24fc75e 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -274,7 +274,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
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 TwoListsOfDoubles segmentDistTime_2l;
private int encoderDisplacement;
private int time;
@@ -293,7 +293,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
this.segmentVariableCm = segmentVariableCm;
segmentVariableCmDistAccumulated = 0;
- segmentDistTime_2l = new TwoListsOfInts("dist","time");
+ segmentDistTime_2l = new TwoListsOfDoubles();
timePre = 0;
}
@@ -360,7 +360,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
if(runEncoderCaptureDistance >= distToBeat)
{
segmentVariableCmDistAccumulated += segmentVariableCm[segmentDistTime_2l.Count()];
- segmentDistTime_2l.Add(Convert.ToInt32(distToBeat), time);
+ segmentDistTime_2l.Add(distToBeat, time);
}
}
@@ -387,7 +387,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
public double RunEncoderCaptureDistance {
get { return runEncoderCaptureDistance; }
}
- public TwoListsOfInts SegmentDistTime_2l {
+ public TwoListsOfDoubles SegmentDistTime_2l {
get { return segmentDistTime_2l; }
}
}
diff --git a/src/utilMath.cs b/src/utilMath.cs
index fcac27708..fcd251619 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -168,6 +168,48 @@ public class TwoListsOfInts
}
+public class TwoListsOfDoubles
+{
+ private List<double> first_l;
+ private List<double> second_l;
+
+ public TwoListsOfDoubles ()
+ {
+ Reset();
+ }
+
+ public void Reset()
+ {
+ first_l = new List<double>();
+ second_l = new List<double>();
+ }
+
+ public bool HasData()
+ {
+ return (first_l != null && first_l.Count > 0);
+ }
+
+ public int Count()
+ {
+ return first_l.Count;
+ }
+
+ public void Add (double addToFirst, double addToSecond)
+ {
+ first_l.Add(addToFirst);
+ second_l.Add(addToSecond);
+ }
+
+ public double GetFromFirst(int pos)
+ {
+ return first_l[pos];
+ }
+ public double GetFromSecond(int pos)
+ {
+ return second_l[pos];
+ }
+}
+
//like Point but for having an xStart and xEnd
public class PointStartEnd
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]