[chronojump] ForceSensorAI: Better cut of selected repetition



commit de0408a54c3fb3e34c7f41ee2aef8af9097870db
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Feb 12 13:10:33 2020 +0100

    ForceSensorAI: Better cut of selected repetition

 src/forceSensorDynamics.cs         | 16 ++++++++--------
 src/gui/app1/forceSensorAnalyze.cs | 15 ++++++++++-----
 2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/forceSensorDynamics.cs b/src/forceSensorDynamics.cs
index 90fb659e..2840b62d 100644
--- a/src/forceSensorDynamics.cs
+++ b/src/forceSensorDynamics.cs
@@ -450,28 +450,28 @@ public class ForceSensorDynamicsElastic : ForceSensorDynamics
 
 public class ForceSensorRepetition
 {
-       public int posX; //of sample
+       public int sample; // this is sample, not graph in pixels.
        public double meanSpeed;
        public double RFD;
 
        //not elastic
-       public ForceSensorRepetition(int posX)
+       public ForceSensorRepetition(int sample)
        {
-               this.posX = posX;
+               this.sample = sample;
                this.meanSpeed = 0;
                this.RFD = 0;
        }
        //elastic
-       public ForceSensorRepetition(int posX, double meanSpeed, double RFD)
+       public ForceSensorRepetition(int sample, double meanSpeed, double RFD)
        {
-               this.posX = posX;
+               this.sample = sample;
                this.meanSpeed = meanSpeed;
                this.RFD = RFD;
        }
 
        public override string ToString()
        {
-               return string.Format("posx:{0}; meanSpeed:{1}; RFD:{2}", posX, meanSpeed, RFD);
+               return string.Format("sample:{0}; meanSpeed:{1}; RFD:{2}", sample, meanSpeed, RFD);
        }
 
        //gets repetition num form a list
@@ -480,9 +480,9 @@ public class ForceSensorRepetition
                int rep = 0;
                foreach(ForceSensorRepetition fsr in l)
                {
-                       if(sample <= fsr.posX)
+                       if(sample <= fsr.sample)
                        {
-                               LogB.Information(string.Format("sample: {0}: fsr.posX: {1}; rep: {2}", 
sample, fsr.posX, rep));
+                               LogB.Information(string.Format("sample: {0}: fsr.sample: {1}; rep: {2}", 
sample, fsr.sample, rep));
                                return rep;
                        }
 
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index 72708af9..21bd4943 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -900,8 +900,12 @@ public partial class ChronoJumpWindow
                        LogB.Information("Repetition: " + repetition.ToString());
                        if(repetition >= 0)
                        {
-                               double start = fsAIRepetitionMouseLimits.GetStartOfARep(repetition);
-                               double end = fsAIRepetitionMouseLimits.GetEndOfARep(repetition);
+                               double start = fsAIRepetitionMouseLimits.GetStartOfARep(repetition) -1;
+                               if(start < 0)
+                                       start = 0; //just a precaution
+                               double end = fsAIRepetitionMouseLimits.GetEndOfARep(repetition) + 1;
+                               if(end >= fsAI.GetLength() -1)
+                                       end -= 1; //just a precaution
                                //LogB.Information(string.Format("start: {0}, end: {1}", start, end));
 
                                //find the hscale value for this x
@@ -1071,13 +1075,13 @@ public partial class ChronoJumpWindow
                int j = 0;
                for(j = 0; j < reps_l.Count; j ++)
                {
-                       int sample = reps_l[j].posX;
+                       int sample = reps_l[j].sample;
                        if(forceSensorZoomApplied)
                        {
                                sample -= hscale_force_sensor_ai_a_BeforeZoom;
                                if(sample < 0)
                                        continue;
-                               else if(reps_l[j].posX >= hscale_force_sensor_ai_b_BeforeZoom)
+                               else if(reps_l[j].sample >= hscale_force_sensor_ai_b_BeforeZoom)
                                        break;
                        }
 
@@ -1103,7 +1107,8 @@ public partial class ChronoJumpWindow
                        xposRepPrevious = xposRep;
                }
                //show the number of last repetition (when obviously no new rep will make writting it)
-               if(j > 0) // write last repetition count
+               //but only if zoomed and that repetition exists (has an end)
+               if(forceSensorZoomApplied && j > 0 && j < reps_l.Count) // write last repetition count
                {
                        layout_force_ai_text.SetMarkup(j.ToString());
                        textWidth = 1; textHeight = 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]