[chronojump] improvements on jumpsWeightFVProfile slope and axis



commit 6a2f7f711544faaad06cedae40959f9f3ff8f722
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jul 21 14:04:49 2020 +0200

    improvements on jumpsWeightFVProfile slope and axis

 src/gui/cairo/jumpsDjOptimalFall.cs   |  2 +-
 src/gui/cairo/jumpsEvolution.cs       |  2 +-
 src/gui/cairo/jumpsWeightFVProfile.cs |  6 +++++-
 src/gui/cairo/xy.cs                   | 26 +++++++++++++++++++++-----
 4 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/gui/cairo/jumpsDjOptimalFall.cs b/src/gui/cairo/jumpsDjOptimalFall.cs
index b532f3a7..176cb300 100644
--- a/src/gui/cairo/jumpsDjOptimalFall.cs
+++ b/src/gui/cairo/jumpsDjOptimalFall.cs
@@ -78,7 +78,7 @@ public class JumpsDjOptimalFallGraph : CairoXY
 
                LogB.Information(string.Format("coef length:{0}", coefs.Length));
                if(coefs.Length == 3)
-                       plotPredictedLine(predictedLineTypes.PARABOLE);
+                       plotPredictedLine(predictedLineTypes.PARABOLE, predictedLineCrossMargins.TOUCH);
 
                plotRealPoints();
 
diff --git a/src/gui/cairo/jumpsEvolution.cs b/src/gui/cairo/jumpsEvolution.cs
index d48e7d66..cb597c49 100644
--- a/src/gui/cairo/jumpsEvolution.cs
+++ b/src/gui/cairo/jumpsEvolution.cs
@@ -70,7 +70,7 @@ public class JumpsEvolutionGraph : CairoXY
                paintAxisAndGrid(gridTypes.HORIZONTALLINES);
                paintGridDatetime();
 
-               plotPredictedLine(predictedLineTypes.STRAIGHT);
+               plotPredictedLine(predictedLineTypes.STRAIGHT, predictedLineCrossMargins.TOUCH);
                plotRealPoints();
 
                writeTitle();
diff --git a/src/gui/cairo/jumpsWeightFVProfile.cs b/src/gui/cairo/jumpsWeightFVProfile.cs
index 95b462e4..3f46790c 100644
--- a/src/gui/cairo/jumpsWeightFVProfile.cs
+++ b/src/gui/cairo/jumpsWeightFVProfile.cs
@@ -95,7 +95,11 @@ public class JumpsWeightFVProfileGraph : CairoXY
                //findAbsoluteMaximums();
                paintAxisAndGrid(gridTypes.BOTH);
 
-               plotPredictedLine(predictedLineTypes.STRAIGHT);
+               if(showFullGraph)
+                       plotPredictedLine(predictedLineTypes.STRAIGHT, predictedLineCrossMargins.CROSS);
+               else
+                       plotPredictedLine(predictedLineTypes.STRAIGHT, predictedLineCrossMargins.DONOTTOUCH);
+
                plotRealPoints();
 
                writeTitle();
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 30ad658a..4334eb31 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -72,6 +72,7 @@ public abstract class CairoXY
        //for all 4 sides
        protected int outerMargins = 40; //blank space outside the axis.
        protected int innerMargins = 30; //space between the axis and the real coordinates.
+       private int crossMargins = 10; //cross slope line with margins will have this length
        int totalMargins;
 
        public abstract void Do();
@@ -121,11 +122,16 @@ public abstract class CairoXY
                                maxY = p.Y;
                }
 
-               if (showFullGraph) {
+               if (showFullGraph)
+               {
                        minX = 0;
                        minY = 0;
                        maxX = v0;
                        maxY = f0;
+
+                       //have maxX and maxY a 2.5% bigger to have a nicer cut with the predicted line
+                       maxX += .025 * maxX;
+                       maxY += .025 * maxY;
                }
 
                //if there is only one point, or by any reason mins == maxs, have mins and maxs separated
@@ -200,7 +206,8 @@ public abstract class CairoXY
        }
 
        protected enum predictedLineTypes { STRAIGHT, PARABOLE }
-       protected void plotPredictedLine(predictedLineTypes plt)
+       protected enum predictedLineCrossMargins { TOUCH, CROSS, DONOTTOUCH }
+       protected void plotPredictedLine(predictedLineTypes plt, predictedLineCrossMargins crossMarginType)
        {
                bool firstValue = false;
                double range = absoluteMaxX - minX;
@@ -229,10 +236,18 @@ public abstract class CairoXY
                        else //(plt == predictedLineTypes.PARABOLE)
                                ygraph = calculatePaintY(coefs[0] + coefs[1]*x + coefs[2]*Math.Pow(x,2));
 
-                       //do not plot line outer the axis
+                       // ---- do not plot line outer the axis ---->
+                       int om = outerMargins;
+
+                       // have a bit more distance
+                       if(crossMarginType == predictedLineCrossMargins.CROSS)
+                               om -= crossMargins;
+                       else if(crossMarginType == predictedLineCrossMargins.DONOTTOUCH)
+                               om += crossMargins;
+
                        if(
-                                       xgraph < outerMargins || xgraph > graphWidth - outerMargins ||
-                                       ygraph < outerMargins || ygraph > graphHeight - outerMargins )
+                                       xgraph < om || xgraph > graphWidth - om ||
+                                       ygraph < om || ygraph > graphHeight - om )
                        {
                                wasOutOfMargins = true;
                                continue;
@@ -242,6 +257,7 @@ public abstract class CairoXY
 
                                wasOutOfMargins = false;
                        }
+                       // <---- end of do not plot line outer the axis ----
 
                        if(! firstValue)
                                g.LineTo(xgraph, ygraph);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]