[chronojump] ForceSensor path: red head previous to scroll and fixed memory leak previous to scroll
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor path: red head previous to scroll and fixed memory leak previous to scroll
- Date: Tue, 25 May 2021 12:05:45 +0000 (UTC)
commit a7f74d3ce43ace3dada32e822859464f0a0494e0
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue May 25 14:04:17 2021 +0200
ForceSensor path: red head previous to scroll and fixed memory leak previous to scroll
src/gui/app1/forceSensor.cs | 67 +++++++++++++++++++++++----------------------
src/utilGtk.cs | 2 ++
2 files changed, 36 insertions(+), 33 deletions(-)
---
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 7abbd63c0..bb7569a87 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -1070,6 +1070,9 @@ public partial class ChronoJumpWindow
setForceSensorTopAtOperationStart();
+ interpolatedPathAccuracyCountIn = 0;
+ interpolatedPathAccuracyCountOut = 0;
+
if(fscPoints.RealHeightG < forceSensorTopRectangleAtOperationStart)
fscPoints.RealHeightG = forceSensorTopRectangleAtOperationStart;
@@ -1624,6 +1627,9 @@ LogB.Information(" fs J ");
int numCaptured = fscPoints.NumCaptured;
int numPainted = fscPoints.NumPainted;
+ //used fto calculate the accuracy image just on the last captured points (previous to
scroll)
+ int toDrawStored = numCaptured - numPainted;
+
//if path: to show the full line when scroll has not started
if(interpolate_l != null && numPainted > 0 && preferences.forceSensorCaptureScroll &&
fscPoints.ScrollStartedAtCount < 0)
numPainted = 1;
@@ -1658,7 +1664,7 @@ LogB.Information(" fs J ");
if(preferences.forceSensorCaptureScroll && fscPoints.ScrollStartedAtCount > 0)
forceSensorCaptureDoRealtimeGraphScroll(numCaptured, toDraw, points);
else
- forceSensorCaptureDoRealtimeGraphNOScroll(numCaptured, numPainted,
toDraw, points);
+ forceSensorCaptureDoRealtimeGraphNOScroll(numCaptured, numPainted,
toDraw, toDrawStored, points);
force_capture_drawingarea.QueueDraw(); // -- refresh
}
@@ -1683,7 +1689,7 @@ LogB.Information(" fs R ");
double ratioInterpolatedVsSamples;
double ratioInterpolatedVsSamplesAtStart;
- private void forceSensorCaptureDoRealtimeGraphNOScroll(int numCaptured, int numPainted, int toDraw,
List<Gdk.Point> points)
+ private void forceSensorCaptureDoRealtimeGraphNOScroll(int numCaptured, int numPainted, int toDraw,
int toDrawStored, List<Gdk.Point> points)
{
LogB.Information("Graph NO Scroll start");
Gdk.Point [] paintPoints;
@@ -1713,35 +1719,27 @@ LogB.Information(" fs R ");
ratioInterpolatedVsSamplesAtStart = 0;
}
- int width = 0;
- int height = 0;
- force_capture_pixmap.GetSize(out width, out height);
- Gdk.Image image = force_capture_pixmap.GetImage(0, 0, width, height);
- interpolatedPathAccuracyCountIn = 0;
- interpolatedPathAccuracyCountOut = 0;
-
//i is related to what has been captured: points
//j is related to what is going to be painted: paintPoints
for(int j = jStart, i = iStart ; i < numCaptured ; i ++, j++)
- {
if(points.Count > i) //extra check to avoid going outside of arrays
- {
paintPoints[j] = points[i];
- if(interpolate_l != null) {
- uint px = image.GetPixel(points[i].X,points[i].Y);
- if(UtilGtk.IdentifyPixelColorIsInPath(px))
- interpolatedPathAccuracyCountIn ++;
- else
- interpolatedPathAccuracyCountOut ++;
- }
- }
- }
-
if(interpolate_l != null)
+ {
+ int storedCountOut = interpolatedPathAccuracyCountOut;
+ UtilGtk.GetPixelsInOutOfPath (paintPoints, paintPoints.Length -1 -toDrawStored,
force_capture_pixmap,
+ ref interpolatedPathAccuracyCountIn, ref
interpolatedPathAccuracyCountOut, true);
+
+ //show a "red head" if signal is out of path
+ if(interpolatedPathAccuracyCountOut > storedCountOut)
+ forceSensorPathPaintHead(paintPointsInterpolate,
+ Convert.ToInt32(paintPointsInterpolate.Count - (toDrawStored
* ratioInterpolatedVsSamples)));
+
interpolatedPathAccuracy = 100 * UtilAll.DivideSafe(
interpolatedPathAccuracyCountIn,
interpolatedPathAccuracyCountIn + interpolatedPathAccuracyCountOut);
+ }
force_capture_pixmap.DrawLines(pen_black_force_capture, paintPoints);
LogB.Information("Graph NO Scroll end");
@@ -1834,18 +1832,8 @@ LogB.Information(" fs R ");
//show a "red head" if signal is out of path
if(interpolatedPathAccuracyCountOut > storedCountOut)
- {
- List<Gdk.Point> paintPointsInterpolateEachSampleHead = new List<Gdk.Point>();
- int start = Convert.ToInt32(paintPointsInterpolateEachSample.Count - (toDraw
* ratioInterpolatedVsSamples));
- //precaution on resize screen
- if(start < 0)
- start = 0;
-
- for(int i = start; i < paintPointsInterpolateEachSample.Count; i ++)
-
paintPointsInterpolateEachSampleHead.Add(paintPointsInterpolateEachSample[i]);
-
-
force_capture_pixmap.DrawLines(pen_red_light_force_capture_interpolated_feedback,
paintPointsInterpolateEachSampleHead.ToArray());
- }
+ forceSensorPathPaintHead(paintPointsInterpolateEachSample,
+ Convert.ToInt32(paintPointsInterpolateEachSample.Count -
(toDraw * ratioInterpolatedVsSamples)));
interpolatedPathAccuracy = 100 * UtilAll.DivideSafe(
interpolatedPathAccuracyCountIn,
@@ -1855,6 +1843,19 @@ LogB.Information(" fs R ");
force_capture_pixmap.DrawLines(pen_black_force_capture, paintPoints);
}
+ private void forceSensorPathPaintHead (List <Gdk.Point> interpolatedPoints, int start)
+ {
+ List<Gdk.Point> headPoints = new List<Gdk.Point>();
+ if(start < 0) //precaution on resize screen
+ start = 0;
+
+ for(int i = start; i < interpolatedPoints.Count; i ++)
+ headPoints.Add(interpolatedPoints[i]);
+
+ force_capture_pixmap.DrawLines(pen_red_light_force_capture_interpolated_feedback,
headPoints.ToArray());
+ }
+
+
int force_capture_allocationXOld;
bool force_capture_sizeChanged;
public void on_force_capture_drawingarea_configure_event(object o, ConfigureEventArgs args)
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index d21a51ced..d505c08ca 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -800,6 +800,8 @@ public class UtilGtk
//if points are on an horiz line, eg minY == maxY == 346, height is 1 point
int width = (maxX - minX) + 1;
int height = (maxY - minY) + 1;
+ //LogB.Information(string.Format("ttt points.Length: {0}, start: {1}, width: {2}, height:
{3}",
+ // points.Length, start, width, height));
if(width <= 0 || height <= 0) //just a caution
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]