[chronojump] RaceAnalyzer capture tab graphs grids ok now



commit f7ed582daa4f5c8a3bf24d2a6c4c6fa1240781ee
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 11 11:00:36 2022 +0100

    RaceAnalyzer capture tab graphs grids ok now

 src/gui/app1/runEncoder.cs    | 10 +++-------
 src/gui/cairo/raceAnalyzer.cs | 38 +++++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index fbc691fe6..603a527f6 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -2225,10 +2225,6 @@ public partial class ChronoJumpWindow
                if(radio_race_analyzer_capture_view_simple.Active)
                        return;
 
-               int verticalGridSeps = -1;
-               if(currentRunEncoderExercise != null && currentRunEncoderExercise.SegmentMeters > 0) //TODO 
check this with variable
-                       verticalGridSeps = currentRunEncoderExercise.SegmentMeters;
-
                TwoListsOfDoubles verticalLinesUs_2l = new TwoListsOfDoubles();
                if(currentRunEncoderExercise != null && //currentRunEncoderExercise.SegmentMeters > 0 &&
                                reCGSD.SegmentDistTime_2l != null)
@@ -2237,7 +2233,7 @@ public partial class ChronoJumpWindow
                if(cairoGraphRaceAnalyzer_dt == null)
                        cairoGraphRaceAnalyzer_dt = new CairoGraphRaceAnalyzer(
                                        drawingarea_race_analyzer_capture_position_time, "title",
-                                       Catalog.GetString("Distance"), "m", false, verticalGridSeps, 
verticalLinesUs_2l);
+                                       Catalog.GetString("Distance"), "m", false, verticalLinesUs_2l, true);
 
                cairoGraphRaceAnalyzer_dt.DoSendingList (preferences.fontType.ToString(),
                                cairoGraphRaceAnalyzerPoints_dt_l, forceRedraw, CairoXY.PlotTypes.LINES);
@@ -2252,7 +2248,7 @@ public partial class ChronoJumpWindow
                if(cairoGraphRaceAnalyzer_st == null)
                        cairoGraphRaceAnalyzer_st = new CairoGraphRaceAnalyzer(
                                        drawingarea_race_analyzer_capture_speed_time, "title",
-                                       Catalog.GetString("Speed"), "m/s", true, -1, verticalLinesUs_2l);
+                                       Catalog.GetString("Speed"), "m/s", true, verticalLinesUs_2l, false);
 
                cairoGraphRaceAnalyzer_st.DoSendingList (preferences.fontType.ToString(),
                                cairoGraphRaceAnalyzerPoints_st_l, forceRedraw, CairoXY.PlotTypes.LINES);
@@ -2270,7 +2266,7 @@ public partial class ChronoJumpWindow
                if(cairoGraphRaceAnalyzer_at == null)
                        cairoGraphRaceAnalyzer_at = new CairoGraphRaceAnalyzer(
                                        drawingarea_race_analyzer_capture_accel_time, "title",
-                                       Catalog.GetString("Accel"), "m/s^2", false, -1, verticalLinesUs_2l);
+                                       Catalog.GetString("Accel"), "m/s^2", false, verticalLinesUs_2l, 
false);
 
                cairoGraphRaceAnalyzer_at.DoSendingList (preferences.fontType.ToString(),
                                cairoGraphRaceAnalyzerPoints_at_l, forceRedraw, CairoXY.PlotTypes.LINES);
diff --git a/src/gui/cairo/raceAnalyzer.cs b/src/gui/cairo/raceAnalyzer.cs
index 5d00f08f1..83007f275 100644
--- a/src/gui/cairo/raceAnalyzer.cs
+++ b/src/gui/cairo/raceAnalyzer.cs
@@ -29,8 +29,8 @@ public class CairoGraphRaceAnalyzer : CairoXY
 {
        int points_list_painted;
        private bool plotHorizArrowFromMaxY;
-       private int verticalGridSep;
        private TwoListsOfDoubles verticalLinesUs_2l;
+       private bool useListOfDoublesOnY;
 
        /*
        //constructor when there are no points
@@ -55,8 +55,8 @@ public class CairoGraphRaceAnalyzer : CairoXY
                        DrawingArea area, string title,
                        string yVariable, string yUnits,
                        bool plotHorizArrowFromMaxY,
-                       int verticalGridSep, //-1 if auto
-                       TwoListsOfDoubles verticalLinesUs_2l)
+                       TwoListsOfDoubles verticalLinesUs_2l,
+                       bool useListOfDoublesOnY) //for pos/time graph
        {
                this.area = area;
                this.title = title;
@@ -67,8 +67,8 @@ public class CairoGraphRaceAnalyzer : CairoXY
                xUnits = "s";
                this.yUnits = yUnits;
                this.plotHorizArrowFromMaxY = plotHorizArrowFromMaxY;
-               this.verticalGridSep = verticalGridSep;
                this.verticalLinesUs_2l = verticalLinesUs_2l;
+               this.useListOfDoublesOnY = useListOfDoublesOnY;
                
 //             doing = false;
                points_list_painted = 0;
@@ -104,19 +104,28 @@ public class CairoGraphRaceAnalyzer : CairoXY
 
                if(maxValuesChanged || forceRedraw)
                {
-                       if(verticalGridSep < 0 && verticalLinesUs_2l.Count() == 0)
+                       if(verticalLinesUs_2l.Count() == 0)
                                paintGrid(gridTypes.BOTH, true);
                        else {
                                //horizontal
-                               if(verticalGridSep <= 0)
+                               if(verticalLinesUs_2l.Count() > 0 && useListOfDoublesOnY)
+                               {
+                                       for(int i = 0 ; i < verticalLinesUs_2l.Count() ; i ++)
+                                       {
+                                               double yGraph = 
calculatePaintY(verticalLinesUs_2l.GetFromFirst(i));
+
+                                               g.Save();
+                                               g.SetDash(new double[]{1, 2}, 0);
+                                               paintHorizontalGridLine(g, Convert.ToInt32(yGraph), 
verticalLinesUs_2l.GetFromFirst(i).ToString(), textHeight -3);
+                                               g.Stroke ();
+                                               g.Restore();
+                                       }
+                               } else //maybe we have not arrived to any segment
                                        paintGrid(gridTypes.HORIZONTALLINES, true);
-                               else
-                                       paintGridInt (g, minX, absoluteMaxX, minY, absoluteMaxY, 
verticalGridSep, gridTypes.HORIZONTALLINES, textHeight);
 
                                //vertical
-                               if(verticalLinesUs_2l.Count() == 0)
-                                       paintGridNiceAutoValues (g, minX, absoluteMaxX, minY, absoluteMaxY, 
5, gridTypes.VERTICALLINES, textHeight);
-                               else {
+                               if(verticalLinesUs_2l.Count() > 0)
+                               {
                                        for(int i = 0 ; i < verticalLinesUs_2l.Count() ; i ++)
                                        {
                                                string xTextTop = 
verticalLinesUs_2l.GetFromFirst(i).ToString();
@@ -127,15 +136,18 @@ public class CairoGraphRaceAnalyzer : CairoXY
 
                                                g.Save();
                                                g.SetDash(new double[]{1, 2}, 0);
-                                               if(verticalGridSep > 0)
+                                               if(useListOfDoublesOnY)
                                                        paintVerticalGridLine(g, Convert.ToInt32(xGraph), 
xTextBottom, textHeight-3);
                                                else
                                                        paintVerticalGridLineTopBottom (g, 
Convert.ToInt32(xGraph), xTextTop, xTextBottom, textHeight-3);
                                                g.Stroke ();
                                                g.Restore();
                                        }
+                                       if(! useListOfDoublesOnY)
+                                               printXAxisTopText();
                                }
-                               printXAxisTopText();
+                               else //maybe we have not arrived to any segment
+                                       paintGridNiceAutoValues (g, minX, absoluteMaxX, minY, absoluteMaxY, 
5, gridTypes.VERTICALLINES, textHeight-3);
                        }
 
                        paintAxis();


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