[chronojump] force sensor capture paints without gaps and resizes X/Y correctly
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] force sensor capture paints without gaps and resizes X/Y correctly
- Date: Tue, 24 Oct 2017 14:47:29 +0000 (UTC)
commit 3a2921316236c3b4432ce33754e9d795adbc2e8d
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Oct 24 16:46:45 2017 +0200
force sensor capture paints without gaps and resizes X/Y correctly
src/forceSensor.cs | 7 +++++--
src/gui/forceSensor.cs | 36 ++++++++++++++++++++++++------------
2 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index a2b1e42..855b807 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -57,7 +57,6 @@ public class ForceSensorCapturePoints
this.widthG = widthG;
this.heightG = heightG;
}
-// int xCount = 10; //just for debugging!!
public void Add(double time, double force)
{
@@ -82,7 +81,7 @@ public class ForceSensorCapturePoints
RealWidthG *= 2;
return true;
}
- if(p.Y > heightG /2)
+ if(p.Y < 0)
{
RealHeightG *= 2;
return true;
@@ -94,10 +93,14 @@ public class ForceSensorCapturePoints
public void Redo()
{
for(int i=0; i < NumCaptured; i ++)
+ {
+ //LogB.Information("RedoPRE X: " + Points[i].X.ToString() + "; Y: " +
Points[i].Y.ToString());
Points[i] = new Gdk.Point(
Convert.ToInt32(widthG * times[i] / RealWidthG),
Convert.ToInt32( (heightG/2) - ( forces[i] * heightG / RealHeightG) )
);
+ //LogB.Information("RedoPOST X: " + Points[i].X.ToString() + "; Y: " +
Points[i].Y.ToString());
+ }
}
}
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 03286fc..39c8b7a 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -64,6 +64,7 @@ public partial class ChronoJumpWindow
*/
enum forceStatus { STOP, STARTING, CAPTURING, COPIED_TO_TMP }
static forceStatus capturingForce = forceStatus.STOP;
+ static bool redoingPoints; //don't draw while redoing points (adjusting screen)
static bool forceCaptureStartMark; //Just needed to display "Capturing message"
static double forceSensorLast; //Needed to display value and move vscale
@@ -432,11 +433,13 @@ public partial class ChronoJumpWindow
forceSensorLast = force;
fscPoints.Add(time, force);
- fscPoints.NumCaptured = count ++;
+ fscPoints.NumCaptured = ++ count;
if(fscPoints.OutsideGraph())
{
+ redoingPoints = true;
fscPoints.Redo();
fscPoints.NumPainted = -1;
+ redoingPoints = false;
}
//changeSlideIfNeeded(time, force);
@@ -536,7 +539,7 @@ public partial class ChronoJumpWindow
//------------------- realtime graph -----------------
- if(fscPoints.Points == null || force_capture_drawingarea == null)
+ if(redoingPoints || fscPoints.Points == null || force_capture_drawingarea == null)
return true;
//mark meaning screen should be erased
@@ -545,36 +548,45 @@ public partial class ChronoJumpWindow
fscPoints.NumPainted = 0;
}
- int last = fscPoints.NumCaptured;
- int toDraw = fscPoints.NumCaptured - fscPoints.NumPainted;
+ //use this integer and this List to not have errors by updating data on the other
thread
+ int numCaptured = fscPoints.NumCaptured;
+ List<Gdk.Point> points = fscPoints.Points;
+
+ int toDraw = numCaptured - fscPoints.NumPainted;
+
+ LogB.Information("fscPointsCount: " + points.Count +
+ "; NumCaptured: " + numCaptured + "; NumPainted: "
+fscPoints.NumPainted +
+ "; toDraw: " + toDraw.ToString() );
- //LogB.Information("toDraw: " + toDraw.ToString());
//fixes crash at the end
if(toDraw == 0)
return true;
Gdk.Point [] paintPoints;
- if(fscPoints.NumPainted > 1)
+ if(fscPoints.NumPainted > 0)
paintPoints = new Gdk.Point[toDraw +1]; // if something has been painted,
connected first point with previous points
else
paintPoints = new Gdk.Point[toDraw];
int jStart = 0;
- if(fscPoints.NumPainted > 1)
+ int iStart = 0;
+ if(fscPoints.NumPainted > 0)
{
// if something has been painted, connected first point with previous points
- paintPoints[0] = fscPoints.Points[fscPoints.NumPainted];
+ paintPoints[0] = points[fscPoints.NumPainted -1];
jStart = 1;
+ iStart = fscPoints.NumPainted;
+ //LogB.Information("X: " + paintPoints[0].X.ToString() + "; Y: " +
paintPoints[0].Y.ToString());
}
- for(int j=jStart, i = fscPoints.NumPainted +1 ; i <= last ; i ++, j++)
+ for(int j=jStart, i = iStart ; i < numCaptured ; i ++, j++)
{
- paintPoints[j] = fscPoints.Points[i];
- LogB.Information("X: " + paintPoints[j].X.ToString() + "; Y: " +
paintPoints[j].Y.ToString());
+ paintPoints[j] = points[i];
+ //LogB.Information("X: " + paintPoints[j].X.ToString() + "; Y: " +
paintPoints[j].Y.ToString());
}
force_capture_pixmap.DrawLines(pen_black_force_capture, paintPoints);
force_capture_drawingarea.QueueDraw(); // -- refresh
- fscPoints.NumPainted = fscPoints.NumCaptured;
+ fscPoints.NumPainted = numCaptured;
}
Thread.Sleep (25);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]