[chronojump] JumpsAsymmetry graph in heights, title at right and other improvements



commit 8af2cdfd1059135d3f059823a032407af5ee27ea
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Sep 27 13:48:53 2022 +0200

    JumpsAsymmetry graph in heights, title at right and other improvements

 po/POTFILES.in                      |  1 +
 src/gui/app1/jumpsAsymmetry.cs      | 27 ++++++++++++++++++++++---
 src/gui/cairo/jumpsRunsEvolution.cs | 39 +++++++++++++++++++++++++------------
 src/jumpsAsymmetry.cs               | 11 +++++------
 src/util.cs                         |  5 +++++
 5 files changed, 62 insertions(+), 21 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0bb557c50..24c02e9ff 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -65,6 +65,7 @@ src/gui/app1/encoder.cs
 src/gui/app1/forceSensorAnalyze.cs
 src/gui/app1/forceSensor.cs
 src/gui/app1/jump.cs
+src/gui/app1/jumpsAsymmetry.cs
 src/gui/app1/jumpsDjOptimalFall.cs
 src/gui/app1/jumpsRunsEvolution.cs
 src/gui/app1/jumpsProfile.cs
diff --git a/src/gui/app1/jumpsAsymmetry.cs b/src/gui/app1/jumpsAsymmetry.cs
index c62938271..64ae71729 100644
--- a/src/gui/app1/jumpsAsymmetry.cs
+++ b/src/gui/app1/jumpsAsymmetry.cs
@@ -23,6 +23,7 @@ using System;
 using System.Collections.Generic; //List
 using Gtk;
 using Glade;
+using Mono.Unix;
 
 public partial class ChronoJumpWindow 
 {
@@ -138,6 +139,25 @@ public partial class ChronoJumpWindow
                                        UtilGtk.ComboGetActive (combo_select_jumps_asymmetry_2)
                                        );
 
+               string index = Catalog.GetString ("Bilateral deficit");
+               string formula = string.Format ("{0} - ({1} + {2})",
+                               UtilGtk.ComboGetActive (combo_select_jumps_asymmetry_bilateral),
+                               UtilGtk.ComboGetActive (combo_select_jumps_asymmetry_1),
+                               UtilGtk.ComboGetActive (combo_select_jumps_asymmetry_2));
+
+               if (radio_jumps_asymmetry_asymmetry.Active)
+               {
+                       index = Catalog.GetString ("Asymmetry");
+                       string higherTranslated = Catalog.GetString ("higher");
+                       string lowerTranslated = Catalog.GetString ("lower");
+                       formula = Catalog.GetString ("Find daily higher of jumps:") + "\n" +
+                               string.Format ("{0}, {1}",
+                                               UtilGtk.ComboGetActive (combo_select_jumps_asymmetry_1),
+                                               UtilGtk.ComboGetActive (combo_select_jumps_asymmetry_2)) + 
"\n" +
+                               string.Format ("100 * ({0} - {1}) / {0}",
+                                               higherTranslated, lowerTranslated);
+               }
+
                bool bars = false;
                if (jumpsAsymmetry.Jad_l.Count == 0)
                {
@@ -147,7 +167,7 @@ public partial class ChronoJumpWindow
                        } else {
                                new JumpsAsymmetryGraph (drawingarea_jumps_asymmetry, 
                                                //JumpsEvolutionGraph.Error.NEEDJUMP,
-                                               "el meu salt", preferences.fontType.ToString());
+                                               index, preferences.fontType.ToString());
                        }
 
                        button_jumps_asymmetry_save_image.Sensitive = false;
@@ -177,8 +197,9 @@ public partial class ChronoJumpWindow
                                                jumpsAsymmetry.Dates_l,
                                                0,
                                                0,
-                                               drawingarea_jumps_asymmetry, "title",
-                                               "el meu salt", currentSession.DateShort, false, true);
+                                               drawingarea_jumps_asymmetry,
+                                               currentPerson.Name, index, formula,
+                                               currentSession.DateShort, false, true);
                                jumpsAsymmetryGraph.Do (preferences.fontType.ToString());
                        }
 
diff --git a/src/gui/cairo/jumpsRunsEvolution.cs b/src/gui/cairo/jumpsRunsEvolution.cs
index b2bc2ac87..9ae9a0a87 100644
--- a/src/gui/cairo/jumpsRunsEvolution.cs
+++ b/src/gui/cairo/jumpsRunsEvolution.cs
@@ -244,16 +244,23 @@ public class RunsEvolutionGraph : EvolutionGraph
 
 public class JumpsAsymmetryGraph : EvolutionGraph //to inherit paintGridDatetime()
 {
+       private string personName;
+       private string index;
+       private string formula;
+
        //constructor when there are no points
-       public JumpsAsymmetryGraph (DrawingArea area, string jumpType, string font)
+       public JumpsAsymmetryGraph (DrawingArea area, string title, string font)
        {
                this.area = area;
+               this.title = "";
+               this.formula = "";
 
                initGraph(font, .8);
 
                g.SetFontSize(16);
                printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
-                               needToExecuteJumpsStr + " " + jumpType + ".", g, alignTypes.CENTER);
+                               needToExecuteJumpsStr //+ " " + jumpType + "."
+                               , g, alignTypes.CENTER);
 
                endGraphDisposing(g, surface, area.GdkWindow);
        }
@@ -262,18 +269,18 @@ public class JumpsAsymmetryGraph : EvolutionGraph //to inherit paintGridDatetime
        public JumpsAsymmetryGraph (
                        List<PointF> point_l, List<DateTime> dates_l,
                        double slope, double intercept,
-                       DrawingArea area, string title,
-                       string jumpType,
-                       string date,
-                       bool showTime, bool metersSecondsPreferred)
+                       DrawingArea area,
+                       string personName, string index, string formula,
+                       string date, bool showTime, bool metersSecondsPreferred)
        {
                this.point_l = point_l;
                this.dates_l = dates_l;
                this.slope = slope;
                this.intercept = intercept;
                this.area = area;
-               this.title = title;
-               this.jumpType = jumpType;
+               this.personName = personName;
+               this.index = index;
+               this.formula = formula;
                this.date = date;
                this.colorBackground = colorFromGdk(Config.ColorBackground); //but note if we are using 
system colors, this will not match
 
@@ -296,11 +303,19 @@ public class JumpsAsymmetryGraph : EvolutionGraph //to inherit paintGridDatetime
 
        protected override void writeTitle()
        {
-               int ypos = -6;
+               int ypos = -7;
+
+               writeTextAtRight(ypos++, personName, true);
+               writeTextAtRight(ypos++, index, false);
+               if (formula.Contains ("\n"))
+               {
+                       string [] strFull = formula.Split(new char[] {'\n'});
+                       foreach (string str in strFull)
+                               writeTextAtRight(ypos++, str, false);
+               } else
+                       writeTextAtRight(ypos++, formula, false);
 
-               //writeTextAtRight(ypos++, title, true);
-               //writeTextAtRight(ypos++, runTypeStr + " " + runType, false);
-               //writeTextAtRight(ypos++, date, false);
+               writeTextAtRight(ypos++, date, false);
        }
 
 }
diff --git a/src/jumpsAsymmetry.cs b/src/jumpsAsymmetry.cs
index ce440e96f..c9f2e6d6f 100644
--- a/src/jumpsAsymmetry.cs
+++ b/src/jumpsAsymmetry.cs
@@ -53,7 +53,7 @@ public class JumpsAsymmetry
 
                foreach (SqliteStruct.DateTypeResult sdtr in sdtr_l)
                {
-                       LogB.Information (string.Format ("-MMMM {0} {1} {2}", sdtr.date, sdtr.type, 
sdtr.result));
+                       LogB.Information (string.Format ("-MMMM {0} {1} {2}", sdtr.date, sdtr.type, 
Util.GetHeightInCm (sdtr.result)));
 
                        if (sdtr.date != currentDate)
                        {
@@ -75,11 +75,11 @@ public class JumpsAsymmetry
                        }
 
                        if (bilateral && sdtr.type == jumpBilateralStr)
-                               jad.AddBilateral (sdtr.type, sdtr.result);
+                               jad.AddBilateral (sdtr.type, Util.GetHeightInCm (sdtr.result));
                        else if (sdtr.type == j1Str)
-                               jad.AddAsymmetry1 (sdtr.type, sdtr.result);
+                               jad.AddAsymmetry1 (sdtr.type, Util.GetHeightInCm (sdtr.result));
                        else if (sdtr.type == j2Str)
-                               jad.AddAsymmetry2 (sdtr.type, sdtr.result);
+                               jad.AddAsymmetry2 (sdtr.type, Util.GetHeightInCm (sdtr.result));
 
                        currentDate = sdtr.date;
                }
@@ -175,8 +175,7 @@ public class JumpsAsymmetryDay
 
                return false;
        }
-       
-       //TODO: flight time or heights?
+
        public double GetIndex ()
        {
                if (bilateral) {
diff --git a/src/util.cs b/src/util.cs
index 24d22e7b1..b9236596d 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -555,6 +555,11 @@ public class Util
                // s = 100 * 4.9 * (tv/2)^2
                return 100 * 4.9 * Math.Pow( tv / 2.0 , 2 );
        }
+       //shorter
+       public static double GetHeightInCm (double tv) {
+               return GetHeightInCentimeters (tv);
+       }
+
        public static double GetHeightInMeters (double tv) {
                // s = 4.9 * (tv/2)^2
                return 4.9 * Math.Pow( tv / 2.0 , 2 );


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