[chronojump] jumpsWeightFVProfile.cs with arrow to show what to develop, ...
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] jumpsWeightFVProfile.cs with arrow to show what to develop, ...
- Date: Wed, 29 Jul 2020 11:20:26 +0000 (UTC)
commit 4592a4906caf64b8a8ae39d40fbc6b2c2b9ca3cc
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jul 29 13:19:40 2020 +0200
jumpsWeightFVProfile.cs with arrow to show what to develop, ...
src/gui/cairo/jumpsWeightFVProfile.cs | 41 ++++++++++++++++++---------
src/gui/cairo/xy.cs | 53 ++++++++++++++++++++++++++++++++++-
2 files changed, 80 insertions(+), 14 deletions(-)
---
diff --git a/src/gui/cairo/jumpsWeightFVProfile.cs b/src/gui/cairo/jumpsWeightFVProfile.cs
index 41407f12..be3fcddf 100644
--- a/src/gui/cairo/jumpsWeightFVProfile.cs
+++ b/src/gui/cairo/jumpsWeightFVProfile.cs
@@ -37,13 +37,14 @@ public class JumpsWeightFVProfileGraph : CairoXY
private ErrorAtStart errorMessage;
//constructor when there are no points
- public JumpsWeightFVProfileGraph (DrawingArea area, ErrorAtStart error)//, string title, string
jumpType, string date)
+ public JumpsWeightFVProfileGraph (DrawingArea area, ErrorAtStart errorMessage)//, string title,
string jumpType, string date)
{
this.area = area;
+ this.errorMessage = errorMessage;
initGraph();
- plotError(error);
+ plotError();
endGraph();
}
@@ -98,22 +99,22 @@ public class JumpsWeightFVProfileGraph : CairoXY
LogB.Information(string.Format("Imbalance: {0}", imbalance));
}
- private void plotError(ErrorAtStart error)
+ private void plotError()
{
string message = "";
- if(error == ErrorAtStart.NEEDLEGPARAMS)
+ if(errorMessage == ErrorAtStart.NEEDLEGPARAMS)
message = "Need to fill person's leg parameters.";
- else if(error == ErrorAtStart.BADLEGPARAMS)
+ else if(errorMessage == ErrorAtStart.BADLEGPARAMS)
message = "Person's leg parameters are incorrect.";
- else if(error == ErrorAtStart.NEEDJUMPS)
+ else if(errorMessage == ErrorAtStart.NEEDJUMPS)
message = "Need to execute jumps SJl and/or SJ.";
- else if(error == ErrorAtStart.NEEDJUMPSX)
+ else if(errorMessage == ErrorAtStart.NEEDJUMPSX)
message = "Need to execute jumps with different weights.";
- else if(error == ErrorAtStart.F0ANDV0NOTPOSITIVE)
+ else if(errorMessage == ErrorAtStart.F0ANDV0NOTPOSITIVE)
message = "F0 and V0 are not > 0.";
- else if(error == ErrorAtStart.F0NOTPOSITIVE)
+ else if(errorMessage == ErrorAtStart.F0NOTPOSITIVE)
message = "F0 is not > 0.";
- else if(error == ErrorAtStart.V0NOTPOSITIVE)
+ else if(errorMessage == ErrorAtStart.V0NOTPOSITIVE)
message = "V0 is not > 0.";
g.SetFontSize(16);
@@ -138,14 +139,25 @@ public class JumpsWeightFVProfileGraph : CairoXY
else
plotPredictedLine(predictedLineTypes.STRAIGHT, predictedLineCrossMargins.DONOTTOUCH);
- plotAlternativeLineWithRealPoints (0, f0Opt, v0Opt, 0, showFullGraph);
+ if(errorMessage == ErrorAtStart.ALLOK)
+ {
+ plotAlternativeLineWithRealPoints (0, f0Opt, v0Opt, 0, showFullGraph);
+
+ if(showFullGraph)
+ {
+ if(f0Opt > f0Rel)
+ plotArrow (0, f0Rel, 0, f0Opt, false, 12);
+ if(v0Opt > v0)
+ plotArrow (v0, 0, v0Opt, 0, true, 12);
+ }
+ }
plotRealPoints();
writeTitle();
if(errorMessage != ErrorAtStart.ALLOK)
- plotError(errorMessage);
+ plotError();
endGraph();
}
@@ -165,11 +177,14 @@ public class JumpsWeightFVProfileGraph : CairoXY
writeTextAtRight(ypos++, "Samozino & col. 2008-13:", false);
writeTextAtRight(ypos++, string.Format("- Profile (90ยบ): {0} %", Math.Round(fvprofile90,0)),
false);
+ writeTextAtRight(ypos++, string.Format("- Imbalance: {0} %", imbalance), false);
+
+ g.Color = red;
if(needDevelopForce)
writeTextAtRight(ypos++, "- Need to develop force", false);
else
writeTextAtRight(ypos++, "- Need to develop speed", false);
- writeTextAtRight(ypos++, string.Format("- Imbalance: {0} %", imbalance), false);
+ g.SetSourceRGB(0, 0, 0);
}
protected override void writeSelectedValues(int line, PointF pClosest)
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 449bf6e2..5324c2ac 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -70,7 +70,7 @@ public abstract class CairoXY
Cairo.Color black;
Cairo.Color white;
- Cairo.Color red;
+ protected Cairo.Color red;
Cairo.Color blue;
protected Cairo.Color bluePlots;
@@ -173,6 +173,57 @@ public abstract class CairoXY
g.SetSourceRGB(0,0,0);
}
+ //horiz or vertical to manage spacement of arrow points and tip draw
+ protected void plotArrow (double ax, double ay, double bx, double by, bool horiz, int spacement)
+ {
+ // 1) convert to graph coordinates
+ ax = calculatePaintX(ax);
+ ay = calculatePaintY(ay);
+ bx = calculatePaintX(bx);
+ by = calculatePaintY(by);
+
+ // 2) have spacements
+ if(horiz) {
+ ax += spacement;
+ bx -= spacement;
+ } else {
+ ay -= spacement;
+ by += spacement;
+ }
+ g.SetSourceRGB(255,0,0);
+
+ // 3) write line (if it fits)
+ if(horiz && bx > ax || ! horiz && ay > by)
+ {
+ g.MoveTo(ax, ay);
+ g.LineTo(bx, by);
+ } else {
+ //if it does not fit, move bx or by to have the arrow at the middle
+ if(horiz)
+ bx = Convert.ToInt32((ax + bx) / 2);
+ else
+ by = Convert.ToInt32((ay + by) / 2);
+ g.MoveTo(bx, by);
+ }
+
+ // 4) write arrow tip
+
+ int tip = 5;
+ if(horiz) {
+ g.LineTo(bx - tip, by - tip);
+ g.MoveTo(bx, by);
+ g.LineTo(bx - tip, by + tip);
+ } else {
+ g.LineTo(bx - tip, by + tip);
+ g.MoveTo(bx, by);
+ g.LineTo(bx + tip, by + tip);
+ }
+
+ // 5) end
+ g.Stroke ();
+ g.SetSourceRGB(0,0,0);
+ }
+
protected virtual void separateMinXMaxXIfNeeded()
{
if(minX == maxX)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]