[chronojump] Jumps simple graph dj jumps/heights by preferences djShowHeights



commit 364ce6b804aaba88c7ce92cf6b86c9a3d68a6924
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jul 29 17:39:33 2020 +0200

    Jumps simple graph dj jumps/heights by preferences djShowHeights

 src/gui/eventExecute.cs  | 65 +++++++++++++++++++++++++++---------------------
 src/gui/usefulObjects.cs | 30 +++++++++++-----------
 2 files changed, 53 insertions(+), 42 deletions(-)
---
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index c7fd0b9e..c295e26e 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -636,6 +636,20 @@ public partial class ChronoJumpWindow
                int topMargin = 30;
                int bottomMargin = 0;
 
+               /*
+                * if not dj show heights
+                * and it is a single jump type, and it has tc, tv (it is a dj or similar)
+                * then show tc, tf
+                */
+               bool useHeights = true;
+               if(! eventGraph.djShowHeights &&
+                               eventGraph.type != "" && //it is a concrete type, not all jumps
+                               eventGraph.jumpsAtSQL.Count > 0 &&
+                               eventGraph.jumpsAtSQL[0].Tc > 0 &&
+                               eventGraph.jumpsAtSQL[0].Tv > 0
+                               )
+                       useHeights = false;
+
                //if max value of graph is automatic
                if(eventGraphConfigureWin.Max == -1) {
                        maxValue = eventGraph.sessionMAXAtSQL;
@@ -646,10 +660,9 @@ public partial class ChronoJumpWindow
 
                        foreach(Jump jump in eventGraph.jumpsAtSQL)
                        {
-                               //always use fall (cm) to be able to do comparisons between different jump 
types
-                               //double valueToPlot = jump.Tc;
-                               //if(eventGraph.djShowHeights)
-                                       double valueToPlot = jump.Fall;
+                               double valueToPlot = jump.Fall;
+                               if(! useHeights)
+                                       valueToPlot = jump.Tc;
 
                                if(valueToPlot > maxValue)
                                        maxValue = valueToPlot;
@@ -682,7 +695,7 @@ public partial class ChronoJumpWindow
                
                //paint graph
                paintJumpSimple (event_execute_drawingarea, eventGraph, 
-                               maxValue, minValue, topMargin, bottomMargin, animate);
+                               maxValue, minValue, topMargin, bottomMargin, animate, useHeights);
 
                // -- refresh
                event_execute_drawingarea.QueueDraw();
@@ -1080,7 +1093,7 @@ public partial class ChronoJumpWindow
        }
        
        private void paintJumpSimple (Gtk.DrawingArea drawingarea, PrepareEventGraphJumpSimple eventGraph, 
-                       double maxValue, double minValue, int topMargin, int bottomMargin, bool animate)
+                       double maxValue, double minValue, int topMargin, int bottomMargin, bool animate, bool 
useHeights)
        {
                int ancho=drawingarea.Allocation.Width;
                int alto=drawingarea.Allocation.Height;
@@ -1144,7 +1157,10 @@ public partial class ChronoJumpWindow
 
                drawGuideOrAVG(pen_yellow_discont, eventGraph.personAVGAtSQL, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue, guideWidthEnum.FULL);
 
-               paintSimpleAxis(ancho, alto, topMargin, bottomMargin, layout, "cm");
+               if(useHeights)
+                       paintSimpleAxis(ancho, alto, topMargin, bottomMargin, layout, "cm");
+               else
+                       paintSimpleAxis(ancho, alto, topMargin, bottomMargin, layout, "s");
 
                //calculate separation between series and bar width
                int distanceBetweenCols = 
Convert.ToInt32((ancho-event_execute_rightMargin)*(1+.5)/countJumps) -
@@ -1158,12 +1174,6 @@ public partial class ChronoJumpWindow
                bool showBarB = false; //tv
                foreach(Jump jump in eventGraph.jumpsAtSQL)
                {
-                       /*
-                       always use fall (cm) to be able to do comparisons between different jump types
-                       if(
-                                       (eventGraph.djShowHeights && jump.Fall > 0) ||
-                                       (! eventGraph.djShowHeights && jump.Tc > 0) )
-                                       */
                        if(jump.Fall > 0)
                                showBarA = true;
                        if(jump.Tv > 0)
@@ -1190,18 +1200,12 @@ public partial class ChronoJumpWindow
                                if(eventGraph.tv >0)
                                        animateBar = false;
 
-                               /*
-                               always use heights to be able to do comparisons between different jump types
-                               double valueA = jump.Tc;
-                               double valueB = jump.Tv;
-                               if(eventGraph.djShowHeights)
-                               {
-                                       valueA = jump.Fall;
-                                       valueB = Util.GetHeightInCentimeters(jump.Tv); //jump height
-                               }
-                               */
                                double valueA = jump.Fall;
                                double valueB = Util.GetHeightInCentimeters(jump.Tv); //jump height
+                               if(! useHeights) {
+                                       valueA = jump.Tc;
+                                       valueB = jump.Tv;
+                               }
 
                                if(valueA > 0)
                                {
@@ -1232,11 +1236,16 @@ public partial class ChronoJumpWindow
                                if(jump.Tv > 0)
                                {
                                        x = 
Convert.ToInt32((ancho-event_execute_rightMargin)*(countToDraw-.5)/countJumps)-barDesplLeft;
-                                       y = calculatePaintHeight(Util.GetHeightInCentimeters(jump.Tv),
+
+                                       double valueB = Util.GetHeightInCentimeters(jump.Tv); //jump height
+                                       if(! useHeights)
+                                               valueB = jump.Tv;
+
+                                       y = calculatePaintHeight(valueB,
                                                        alto, maxValue, minValue, topMargin, bottomMargin);
 
                                        drawBar(x, y, barWidth, alto, bottomMargin, pen_background, 
countToDraw == countJumps,
-                                                       Util.GetHeightInCentimeters(jump.Tv), layout, 
animateBar);
+                                                       valueB, layout, animateBar);
                                }
                        }
 
@@ -1266,10 +1275,10 @@ public partial class ChronoJumpWindow
                //add legend box
                if(showBarA && showBarB)
                {
-                       //if(eventGraph.djShowHeights)
+                       if(useHeights)
                                addLegend (pen_background_shifted, Catalog.GetString("Falling height"), 
pen_background, Catalog.GetString("Jump height"), layoutSmallMid, ancho, topMargin, true);
-                       //else
-                       //      addLegend (pen_background_shifted, Catalog.GetString("Contact time"), 
pen_background, Catalog.GetString("Flight time"), layoutSmallMid, ancho, topMargin, true);
+                       else
+                               addLegend (pen_background_shifted, Catalog.GetString("Contact time"), 
pen_background, Catalog.GetString("Flight time"), layoutSmallMid, ancho, topMargin, true);
                }
 
                //paint reference guide black and green if needed
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index c53cd92f..487df83a 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -101,21 +101,23 @@ public class PrepareEventGraphJumpSimple
 
 
                string sqlSelect = "";
-               /*
-               if(tv > 0) {
-                       if(tc <= 0)
-                               sqlSelect = "100*4.9*(TV/2)*(TV/2)";
-                       else {
-                               if(djShowHeights)
+               //if it is a concrete jump type, then check if showHeights or times
+               if(type != "") {
+                       if(tv > 0) {
+                               if(tc <= 0)
                                        sqlSelect = "100*4.9*(TV/2)*(TV/2)";
-                               else
-                                       sqlSelect = "TV"; //if tc is higher than tv it will be fixed on 
PrepareJumpSimpleGraph
-                       }
-               } else
-                       sqlSelect = "TC";
-               */
-               //always use heights to be able to do comparisons between different jump types
-               sqlSelect = "100*4.9*(TV/2)*(TV/2)";
+                               else {
+                                       if(djShowHeights)
+                                               sqlSelect = "100*4.9*(TV/2)*(TV/2)";
+                                       else
+                                               sqlSelect = "TV"; //if tc is higher than tv it will be fixed 
on PrepareJumpSimpleGraph
+                               }
+                       } else
+                               sqlSelect = "TC";
+               } else {
+                       //if there are different types, always use heights to be able to do comparisons 
between different jump types
+                       sqlSelect = "100*4.9*(TV/2)*(TV/2)";
+               }
 
                personMAXAtSQLAllSessions = SqliteSession.SelectMAXEventsOfAType(true, -1, personID, table, 
type, sqlSelect);
                personMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, personID, table, type, 
sqlSelect);


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