[chronojump] On raceAnalyzer capture shown speed also shows max
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] On raceAnalyzer capture shown speed also shows max
- Date: Tue, 15 Dec 2020 17:10:37 +0000 (UTC)
commit 90a5010d51c2eede9018efad509fd6cb3d3e4afa
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Dec 15 18:10:08 2020 +0100
On raceAnalyzer capture shown speed also shows max
src/gui/app1/runEncoder.cs | 2 ++
src/gui/cairo/radial.cs | 45 ++++++++++++++++++++++++++++++---------------
2 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index c234ab22..63a95dd5 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -239,6 +239,8 @@ public partial class ChronoJumpWindow
runEncoderButtonsSensitive(false);
sensitiveLastTestButtons(false);
runEncoderCaptureSpeed = 0;
+ if(cairoRadial != null)
+ cairoRadial.ResetSpeedMax();
if(chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.ARDUINO_RUN_ENCODER) == 0)
{
diff --git a/src/gui/cairo/radial.cs b/src/gui/cairo/radial.cs
index fa2ca45d..8c8a36b1 100644
--- a/src/gui/cairo/radial.cs
+++ b/src/gui/cairo/radial.cs
@@ -34,8 +34,10 @@ public class CairoRadial
private string font;
private int graphWidth;
private int graphHeight;
+ private double minSide;
private Cairo.Color black;
private Cairo.Color red;
+ private Cairo.Color gray;
public CairoRadial (Gtk.DrawingArea area, string font)
{
@@ -66,19 +68,19 @@ public class CairoRadial
g.SetFontSize(textHeight);
black = colorFromRGB(0,0,0);
- //gray99 = colorFromRGB(99,99,99);
+ gray = colorFromRGB(99,99,99); //gray99
//white = colorFromRGB(255,255,255);
red = colorFromRGB(200,0,0);
//blue = colorFromRGB(178, 223, 238); //lightblue
//bluePlots = colorFromRGB(0, 0, 200);
g.Color = black;
- double minSide = graphWidth;
+ minSide = graphWidth;
if(graphHeight < minSide)
minSide = graphHeight;
for(int i = 0; i < 20; i ++)
{
- double iArc = (2*Math.PI / maxValue) * i;
+ double iArc = (2*Math.PI / maxPossibleValue) * i;
printText(Convert.ToInt32(margin + graphWidth/2 + (minSide/2) * 1 * Math.Cos(iArc -
Math.PI/2)),
Convert.ToInt32(margin + graphHeight/2 + (minSide/2) * 1 *
Math.Sin(iArc - Math.PI/2)),
0, textHeight, i.ToString(), g, alignTypes.CENTER);
@@ -87,27 +89,40 @@ public class CairoRadial
//TODO: currently max is 20
//TODO: make this go from bottom left to bottom right like a car
- int maxValue = 20;
+ int maxPossibleValue = 20;
+ double speedMax = 0;
+ public void ResetSpeedMax()
+ {
+ speedMax = 0;
+ }
+
public void GraphSpeed(double speed)
{
- initGraph();
+ if(speed > speedMax)
+ speedMax = speed;
- double speedArc = (2*Math.PI / maxValue) * speed;
+ initGraph();
//g.SetSourceRGB(0.5, 0.5, 0.5);
- g.MoveTo(margin + graphWidth/2, margin + graphHeight/2);
- double minSide = graphWidth;
- if(graphHeight < minSide)
- minSide = graphHeight;
+ graphLineFromCenter(speed, red);
+ if(speedMax > speed)
+ graphLineFromCenter(speedMax, gray);
+
+ endGraphDisposing();
+ }
+
+ private void graphLineFromCenter(double toValue, Cairo.Color color)
+ {
+ double arc = (2*Math.PI / maxPossibleValue) * toValue;
+ g.MoveTo(margin + graphWidth/2, margin + graphHeight/2);
//thanks to: http://ralph-glass.homepage.t-online.de/clock/readme.html
- g.LineTo(margin + graphWidth/2 + (minSide/2) * .9 * Math.Cos(speedArc - Math.PI/2),
- margin + graphHeight/2 + (minSide/2) * .9 * Math.Sin(speedArc - Math.PI/2));
- g.Color = red;
- g.Stroke();
+ g.LineTo(margin + graphWidth/2 + (minSide/2) * .9 * Math.Cos(arc - Math.PI/2),
+ margin + graphHeight/2 + (minSide/2) * .9 * Math.Sin(arc - Math.PI/2));
- endGraphDisposing();
+ g.Color = color;
+ g.Stroke();
}
//TODO: all this methods have to be shared with xy.cs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]