[chronojump] JumpsWeightProfile can have axis at (0,0) (v0,f0)



commit b374e6f5195b2cadda7d0d1c939bbf1c5daa994b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jul 21 13:17:34 2020 +0200

    JumpsWeightProfile can have axis at (0,0) (v0,f0)

 glade/app1.glade                      | 47 ++++++++++++++++++++++++++++++++++-
 src/gui/app1/jumpsWeightFVProfile.cs  | 16 +++++++++++-
 src/gui/cairo/jumpsDjOptimalFall.cs   |  2 +-
 src/gui/cairo/jumpsEvolution.cs       |  2 +-
 src/gui/cairo/jumpsWeightFVProfile.cs | 21 +++++++++++-----
 src/gui/cairo/xy.cs                   | 13 +++++++++-
 6 files changed, 90 insertions(+), 11 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index db3448e0..c8bc00e3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -19892,6 +19892,51 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHBox" id="hbox434">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">12</property>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="radio_jumps_weight_fv_profile_show_full_graph">
+                                                            <property name="label" translatable="yes">Show 
full graph</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <signal name="toggled" 
handler="on_radio_jumps_weight_fv_profile_show_full_graph_toggled" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="radio_jumps_weight_fv_profile_zoom_to_points">
+                                                            <property name="label" translatable="yes">Zoom 
to points</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <property 
name="group">radio_jumps_weight_fv_profile_show_full_graph</property>
+                                                            <signal name="toggled" 
handler="on_radio_jumps_weight_fv_profile_zoom_to_points_toggled" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" id="hbox237">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -19970,7 +20015,7 @@ Concentric</property>
                                                             <packing>
                                                             <property name="expand">True</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                             </packing>
                                                             </child>
                                                           </widget>
diff --git a/src/gui/app1/jumpsWeightFVProfile.cs b/src/gui/app1/jumpsWeightFVProfile.cs
index ccf0ed3a..cf651f2c 100644
--- a/src/gui/app1/jumpsWeightFVProfile.cs
+++ b/src/gui/app1/jumpsWeightFVProfile.cs
@@ -32,6 +32,8 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.HBox hbox_combo_select_jumps_weight_fv_profile;
        [Widget] Gtk.ComboBox combo_select_jumps_weight_fv_profile;
        [Widget] Gtk.Button button_jumps_weight_fv_profile_save_image;
+       [Widget] Gtk.RadioButton radio_jumps_weight_fv_profile_show_full_graph;
+       [Widget] Gtk.RadioButton radio_jumps_weight_fv_profile_zoom_to_points;
 
        JumpsWeightFVProfile jumpsWeightFVProfile;
        JumpsWeightFVProfileGraph jumpsWeightFVProfileGraph;
@@ -116,7 +118,8 @@ public partial class ChronoJumpWindow
                                        jumpsWeightFVProfile.Intercept,
                                        drawingarea_jumps_weight_fv_profile,
                                        currentPerson.Name, //jumpType,
-                                       currentSession.DateShort);
+                                       currentSession.DateShort,
+                                       radio_jumps_weight_fv_profile_show_full_graph.Active);
                        jumpsWeightFVProfileGraph.Do();
 
                        button_jumps_weight_fv_profile_save_image.Sensitive = true;
@@ -131,6 +134,17 @@ public partial class ChronoJumpWindow
                //data is calculated on switch page (at notebook_capture_analyze) or on change person
        }
 
+       private void on_radio_jumps_weight_fv_profile_show_full_graph_toggled (object o, EventArgs args)
+       {
+               if(radio_jumps_weight_fv_profile_show_full_graph.Active)
+                       jumpsWeightFVProfileDo (false);
+       }
+       private void on_radio_jumps_weight_fv_profile_zoom_to_points_toggled (object o, EventArgs args)
+       {
+               if(radio_jumps_weight_fv_profile_zoom_to_points.Active)
+                       jumpsWeightFVProfileDo (false);
+       }
+
        private void on_drawingarea_jumps_weight_fv_profile_button_press_event (object o, 
ButtonPressEventArgs args)
        {
                //if there is no data and nothing to show, nothing to press, and also this is null
diff --git a/src/gui/cairo/jumpsDjOptimalFall.cs b/src/gui/cairo/jumpsDjOptimalFall.cs
index 99c879fd..b532f3a7 100644
--- a/src/gui/cairo/jumpsDjOptimalFall.cs
+++ b/src/gui/cairo/jumpsDjOptimalFall.cs
@@ -72,7 +72,7 @@ public class JumpsDjOptimalFallGraph : CairoXY
                LogB.Information("at JumpsDjOptimalFallGraph.Do");
                initGraph();
 
-                findPointMaximums();
+                findPointMaximums(false);
                 findAbsoluteMaximums();
                paintAxisAndGrid(gridTypes.BOTH);
 
diff --git a/src/gui/cairo/jumpsEvolution.cs b/src/gui/cairo/jumpsEvolution.cs
index 6210a0e0..d48e7d66 100644
--- a/src/gui/cairo/jumpsEvolution.cs
+++ b/src/gui/cairo/jumpsEvolution.cs
@@ -65,7 +65,7 @@ public class JumpsEvolutionGraph : CairoXY
                LogB.Information("at JumpsEvolutionGraph.Do");
                initGraph();
 
-                findPointMaximums();
+                findPointMaximums(false);
                 //findAbsoluteMaximums();
                paintAxisAndGrid(gridTypes.HORIZONTALLINES);
                paintGridDatetime();
diff --git a/src/gui/cairo/jumpsWeightFVProfile.cs b/src/gui/cairo/jumpsWeightFVProfile.cs
index 5a20e353..95b462e4 100644
--- a/src/gui/cairo/jumpsWeightFVProfile.cs
+++ b/src/gui/cairo/jumpsWeightFVProfile.cs
@@ -29,6 +29,8 @@ using Cairo;
 public class JumpsWeightFVProfileGraph : CairoXY
 {
        public enum ErrorAtStart { NEEDLEGPARAMS, BADLEGPARAMS, NEEDJUMPS }
+       private double pmax;
+       private bool showFullGraph;
 
        //constructor when there are no points
        public JumpsWeightFVProfileGraph (DrawingArea area, ErrorAtStart error)//, string title, string 
jumpType, string date)
@@ -55,7 +57,7 @@ public class JumpsWeightFVProfileGraph : CairoXY
        public JumpsWeightFVProfileGraph (
                        List<PointF> point_l, double slope, double intercept,
                        DrawingArea area, string title, //string jumpType,
-                       string date)
+                       string date, bool showFullGraph)
        {
                this.point_l = point_l;
                this.slope = slope;
@@ -64,13 +66,20 @@ public class JumpsWeightFVProfileGraph : CairoXY
                this.title = title;
                //this.jumpType = jumpType;
                this.date = date;
+               this.showFullGraph = showFullGraph;
 
                outerMargins = 50; //blank space outside the axis
+               if(showFullGraph)
+                       innerMargins = 0;
 
                xVariable = "Speed";
                yVariable = "Force";
                xUnits = "m/s";
                yUnits = "N";
+
+               f0 = intercept;
+               v0 = -f0 / slope;
+               pmax = (f0 * v0) /4;
        }
 
        public override void Do()
@@ -78,7 +87,11 @@ public class JumpsWeightFVProfileGraph : CairoXY
                LogB.Information("at JumpsWeightFVProfileGraph.Do");
                initGraph();
 
-               findPointMaximums();
+               if(showFullGraph)
+                       findPointMaximums(true);
+               else
+                       findPointMaximums(false);
+
                //findAbsoluteMaximums();
                paintAxisAndGrid(gridTypes.BOTH);
 
@@ -98,10 +111,6 @@ public class JumpsWeightFVProfileGraph : CairoXY
                writeTextAtRight(ypos++, "FV Profile", false);
                writeTextAtRight(ypos++, date, false);
 
-               double f0 = intercept;
-               double v0 = -f0 / slope;
-               double pmax = (f0 * v0) /4;
-
                ypos++;
                writeTextAtRight(ypos++, string.Format("F0: {0} N", Math.Round(f0,2)), false);
                writeTextAtRight(ypos++, string.Format("V0: {0} m/s", Math.Round(v0,2)), false);
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 02c5057d..30ad658a 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -33,6 +33,8 @@ public abstract class CairoXY
        //regression line straight
        protected double slope;
        protected double intercept;
+       protected double f0;
+       protected double v0;
 
        //regression line parabole
        protected double[] coefs;
@@ -103,7 +105,9 @@ public abstract class CairoXY
                predictedPointDone = false;
        }
 
-       protected void findPointMaximums()
+       //showFullGraph means that has to plot both axis at 0 and maximums have to be f0,v0
+       //used by default on jumpsWeightFVProfile
+       protected void findPointMaximums(bool showFullGraph)
        {
                foreach(PointF p in point_l)
                {
@@ -117,6 +121,13 @@ public abstract class CairoXY
                                maxY = p.Y;
                }
 
+               if (showFullGraph) {
+                       minX = 0;
+                       minY = 0;
+                       maxX = v0;
+                       maxY = f0;
+               }
+
                //if there is only one point, or by any reason mins == maxs, have mins and maxs separated
                separateMinXMaxXIfNeeded();
                separateMinYMaxYIfNeeded();


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