[chronojump] Signal graph is displayed real time on cont mode
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Signal graph is displayed real time on cont mode
- Date: Fri, 2 Jun 2017 15:03:50 +0000 (UTC)
commit 40a6952de3954612fabd62ec9311f5da0a9e70b6
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jun 2 17:03:04 2017 +0200
Signal graph is displayed real time on cont mode
src/encoderCapture.cs | 105 +++++++++++++++++++++++++++++--------------------
src/gui/encoder.cs | 73 +++++++++++++---------------------
2 files changed, 90 insertions(+), 88 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index 579169e..087995a 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -340,7 +340,7 @@ public abstract class EncoderCapture
EncoderCapturePoints = new List<Gdk.Point>();
EncoderCapturePointsInertialDisc = new
List<Gdk.Point>();
EncoderCapturePointsCaptured = 0;
- EncoderCapturePointsPainted = 0; //-1 means
delete screen
+ EncoderCapturePointsPainted = -1; //-1 means
delete screen
}
i = -1; //will be 0 on next loop start
@@ -674,8 +674,6 @@ public abstract class EncoderCapture
protected virtual void assignEncoderCapturePoints()
{
int xWidth = recordingTime;
- if(cont)
- xWidth = recordedTimeCont;
EncoderCapturePoints.Add(new Gdk.Point(
Convert.ToInt32(widthG * i / xWidth),
@@ -688,25 +686,33 @@ public abstract class EncoderCapture
{
//adaptative displayed height
//if points go outside the graph, duplicate size of graph
- if(EncoderCapturePoints[i].Y > heightG || EncoderCapturePoints[i].Y < 0)
+ bool needToChangeGraph = false;
+ if(EncoderCapturePoints[i].Y > heightG || EncoderCapturePoints[i].Y < 0)
{
realHeightG *= 2;
+ needToChangeGraph = true;
+ }
+ if(cont && i >= recordingTime)
+ {
+ recordingTime *= 2;
+ needToChangeGraph = true;
+ }
- int xWidth = recordingTime;
- if(cont)
- xWidth = recordedTimeCont;
-
- double sum2=0;
- for(int j=0; j <= i; j ++) {
- sum2 += encoderReaded[j];
- EncoderCapturePoints[j] = new Gdk.Point(
- Convert.ToInt32(widthG * j / xWidth),
- Convert.ToInt32( (heightG/2) - ( sum2 * heightG /
realHeightG) )
- );
- }
- EncoderCapturePointsCaptured = i;
- EncoderCapturePointsPainted = -1; //mark meaning screen should be erased
+ if(! needToChangeGraph)
+ return;
+
+ int xWidth = recordingTime;
+
+ double sum2=0;
+ for(int j=0; j <= i; j ++) {
+ sum2 += encoderReaded[j];
+ EncoderCapturePoints[j] = new Gdk.Point(
+ Convert.ToInt32(widthG * j / xWidth),
+ Convert.ToInt32( (heightG/2) - ( sum2 * heightG / realHeightG) )
+ );
}
+ EncoderCapturePointsCaptured = i;
+ EncoderCapturePointsPainted = -1; //mark meaning screen should be erased
}
/*
@@ -940,8 +946,8 @@ public class EncoderCaptureInertial : EncoderCapture
protected override void assignEncoderCapturePoints()
{
int xWidth = recordingTime;
- if(cont)
- xWidth = recordedTimeCont;
+// if(cont)
+// xWidth = recordedTimeCont;
EncoderCapturePoints.Add(new Gdk.Point(
Convert.ToInt32(widthG * i / xWidth),
@@ -957,33 +963,46 @@ public class EncoderCaptureInertial : EncoderCapture
{
//adaptative displayed height
//if points go outside the graph, duplicate size of graph
+ bool needToChangeGraph = false;
if(
- EncoderCapturePoints[i].Y > heightG || EncoderCapturePoints[i].Y < 0 ||
- EncoderCapturePointsInertialDisc[i].Y > heightG ||
- EncoderCapturePointsInertialDisc[i].Y < 0 ) {
+ EncoderCapturePoints[i].Y > heightG ||
+ EncoderCapturePoints[i].Y < 0 ||
+ EncoderCapturePointsInertialDisc[i].Y > heightG ||
+ EncoderCapturePointsInertialDisc[i].Y < 0)
+ {
realHeightG *= 2;
+ needToChangeGraph = true;
+ }
+ if(cont && i >= recordingTime)
+ {
+ recordingTime *= 2;
+ needToChangeGraph = true;
+ }
- int xWidth = recordingTime;
- if(cont)
- xWidth = recordedTimeCont;
-
- double sum2 = 0;
- double sum2InertialDisc = 0;
- for(int j=0; j <= i; j ++) {
- sum2 += encoderReaded[j];
- sum2InertialDisc += encoderReadedInertialDisc[j];
- EncoderCapturePoints[j] = new Gdk.Point(
- Convert.ToInt32(widthG * j / xWidth),
- Convert.ToInt32( (heightG/2) - ( sum2 * heightG /
realHeightG) )
- );
- EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
- Convert.ToInt32(widthG * j / xWidth),
- Convert.ToInt32( (heightG/2) - ( sum2InertialDisc * heightG /
realHeightG) )
- );
- }
- EncoderCapturePointsCaptured = i;
- EncoderCapturePointsPainted = -1; //mark meaning screen should be erased and start
painting from the beginning
+ if(! needToChangeGraph)
+ return;
+
+ int xWidth = recordingTime;
+ //if(cont)
+ // xWidth = recordedTimeCont;
+
+ double sum2 = 0;
+ double sum2InertialDisc = 0;
+ for(int j=0; j <= i; j ++)
+ {
+ sum2 += encoderReaded[j];
+ sum2InertialDisc += encoderReadedInertialDisc[j];
+ EncoderCapturePoints[j] = new Gdk.Point(
+ Convert.ToInt32(widthG * j / xWidth),
+ Convert.ToInt32( (heightG/2) - ( sum2 * heightG / realHeightG) )
+ );
+ EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
+ Convert.ToInt32(widthG * j / xWidth),
+ Convert.ToInt32( (heightG/2) - ( sum2InertialDisc * heightG /
realHeightG) )
+ );
}
+ EncoderCapturePointsCaptured = i;
+ EncoderCapturePointsPainted = -1; //mark meaning screen should be erased and start painting
from the beginning
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 08a8c62..c653e62 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4321,55 +4321,40 @@ public partial class ChronoJumpWindow
Gdk.Point [] paintPoints = new Gdk.Point[toDraw];
Gdk.Point [] paintPointsInertial = new Gdk.Point[toDraw];
- //currently disabled points painting on continuous mode
- if(radio_encoder_capture_cont.Active) {
- int graphWidth = encoder_capture_signal_drawingarea.Allocation.Width;
- int graphHeight = encoder_capture_signal_drawingarea.Allocation.Height;
-
- layout_encoder_capture_signal.SetMarkup("Graph currently disabled\non continuous
mode");
- int textWidth = 1;
- int textHeight = 1;
- layout_encoder_capture_signal.GetPixelSize(out textWidth, out textHeight);
-
- encoder_capture_signal_pixmap.DrawLayout(pen_blue_encoder_capture,
- graphWidth/2 - textWidth/2, graphHeight/2 - textHeight/2,
layout_encoder_capture_signal);
- }
- else {
- for(int j=0, i = eCapture.EncoderCapturePointsPainted +1 ; i <= last ; i ++, j++)
- {
- paintPoints[j] = eCapture.EncoderCapturePoints[i];
-
- if(refreshAreaOnly) {
- if(eCapture.EncoderCapturePoints[i].Y > maxY)
- maxY = eCapture.EncoderCapturePoints[i].Y;
- if(eCapture.EncoderCapturePoints[i].Y < minY)
- minY = eCapture.EncoderCapturePoints[i].Y;
- }
+ for(int j=0, i = eCapture.EncoderCapturePointsPainted +1 ; i <= last ; i ++, j++)
+ {
+ paintPoints[j] = eCapture.EncoderCapturePoints[i];
+ if(refreshAreaOnly) {
+ if(eCapture.EncoderCapturePoints[i].Y > maxY)
+ maxY = eCapture.EncoderCapturePoints[i].Y;
+ if(eCapture.EncoderCapturePoints[i].Y < minY)
+ minY = eCapture.EncoderCapturePoints[i].Y;
}
- if(mode == UpdateEncoderPaintModes.INERTIAL) {
- for(int j=0, i = eCapture.EncoderCapturePointsPainted +1 ; i <= last ; i ++,
j ++)
- {
- //only assign the points if they are different than paintPoints
- if(eCapture.EncoderCapturePointsInertialDisc[i] !=
eCapture.EncoderCapturePoints[i] &&
- (i % 800) <= 520 //dashed accepting 520 points and
discarding 280
- ) {
- paintPointsInertial[j] =
eCapture.EncoderCapturePointsInertialDisc[i];
-
- if(refreshAreaOnly) {
- if(eCapture.EncoderCapturePointsInertialDisc[i].Y >
maxY)
- maxY =
eCapture.EncoderCapturePointsInertialDisc[i].Y;
- if(eCapture.EncoderCapturePointsInertialDisc[i].Y <
minY)
- minY =
eCapture.EncoderCapturePointsInertialDisc[i].Y;
- }
+ }
+
+ if(mode == UpdateEncoderPaintModes.INERTIAL) {
+ for(int j=0, i = eCapture.EncoderCapturePointsPainted +1 ; i <= last ; i ++, j ++)
+ {
+ //only assign the points if they are different than paintPoints
+ if(eCapture.EncoderCapturePointsInertialDisc[i] !=
eCapture.EncoderCapturePoints[i] &&
+ (i % 800) <= 520 //dashed accepting 520 points and discarding
280
+ ) {
+ paintPointsInertial[j] = eCapture.EncoderCapturePointsInertialDisc[i];
+
+ if(refreshAreaOnly) {
+ if(eCapture.EncoderCapturePointsInertialDisc[i].Y > maxY)
+ maxY = eCapture.EncoderCapturePointsInertialDisc[i].Y;
+ if(eCapture.EncoderCapturePointsInertialDisc[i].Y < minY)
+ minY = eCapture.EncoderCapturePointsInertialDisc[i].Y;
}
}
- encoder_capture_signal_pixmap.DrawPoints(pen_gray, paintPointsInertial);
}
- //paint this after the inertial because this should mask the other
- encoder_capture_signal_pixmap.DrawPoints(pen_black_encoder_capture, paintPoints);
+ encoder_capture_signal_pixmap.DrawPoints(pen_gray, paintPointsInertial);
}
+ //paint this after the inertial because this should mask the other
+ encoder_capture_signal_pixmap.DrawPoints(pen_black_encoder_capture, paintPoints);
//write title
@@ -4995,10 +4980,8 @@ public partial class ChronoJumpWindow
eCapture = new EncoderCaptureGravitatory();
int recordingTime = preferences.encoderCaptureTime;
- if(radio_encoder_capture_cont.Active) {
- recordingTime = 0;
+ if(radio_encoder_capture_cont.Active)
encoderProcessFinishContMode = false; //will be true when finish
button is pressed
- }
string portName = "";
if( ! (currentSession.Name == Constants.SessionSimulatedName && testsActive))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]