[chronojump] CairoPaintBarsPreRunIntervalRealtimeCapture shows dist, time abs or relative



commit c75b2a1f9a98b55638cf68eb2a9c545aaaf3a371
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Sep 14 00:29:14 2021 +0200

    CairoPaintBarsPreRunIntervalRealtimeCapture shows dist, time abs or relative

 glade/app1.glade           | 74 ++++++++++++++++++++++++++++++++++++++--------
 src/Makefile.am            |  2 ++
 src/gui/app1/chronojump.cs |  2 ++
 src/gui/app1/icons.cs      |  2 ++
 src/gui/eventExecute.cs    | 51 ++++++++++++++++++++++++++++++--
 5 files changed, 117 insertions(+), 14 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 28b60cc28..4332f2c0c 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -7712,12 +7712,56 @@ EncoderInertialCapture</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <child>
+                                                            <widget class="GtkHBox" id="hbox7">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
                                                             <widget class="GtkDrawingArea" 
id="event_execute_drawingarea_realtime_capture_cairo">
                                                             <property name="height_request">125</property>
                                                             <property name="can_focus">False</property>
                                                             <signal name="expose_event" 
handler="on_event_execute_drawingarea_realtime_capture_cairo_expose_event" swapped="no"/>
                                                             </widget>
                                                             <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkVBox" 
id="vbox_event_execute_drawingarea_realtime_capture_cairo">
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkCheckButton" 
id="check_runI_realtime_rel_abs">
+                                                            <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">False</property>
+                                                            <signal name="toggled" 
handler="on_check_runI_realtime_rel_abs_toggled" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_check_runI_realtime_rel_abs">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="resize">True</property>
                                                             <property name="shrink">False</property>
                                                             </packing>
@@ -24995,6 +25039,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31306,18 +31353,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -31354,6 +31389,18 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -40670,6 +40717,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index 960177a31..86304aac6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -601,6 +601,8 @@ RESOURCES = \
        ../images/reaction_time_menu.png,reaction_time_menu.png \
        ../images/pulse_menu.png,pulse_menu.png \
        ../images/multichronopic_menu.png,multichronopic_menu.png \
+       ../images/bar_relative.png,bar_relative.png \
+       ../images/bar_absolute.png,bar_absolute.png \
        ../images/force_sensor_menu.png,force_sensor_menu.png \
        ../images/force_sensor_icon.png,force_sensor_icon.png \
        ../images/force_sensor_icon_yellow.png,force_sensor_icon_yellow.png \
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 595910668..06a6ec546 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -3485,6 +3485,7 @@ public partial class ChronoJumpWindow
                event_execute_label_message.Text = "";
                event_execute_drawingarea.Visible = false;
                event_execute_drawingarea_realtime_capture_cairo.Visible = false;
+               vbox_event_execute_drawingarea_realtime_capture_cairo.Visible = false;
 
                //blank exercise options: useful for changing from jumps or runs to forceSensor, runEncoder, 
reaction time, other
                label_contacts_exercise_selected_name.Visible = true; //will not be visible when all the 
contacts_top combo is implemented
@@ -3612,6 +3613,7 @@ public partial class ChronoJumpWindow
                                button_contacts_bells.Sensitive = true;
                                on_extra_window_runs_interval_test_changed(new object(), new EventArgs());
                                event_execute_drawingarea_realtime_capture_cairo.Visible = true;
+                               vbox_event_execute_drawingarea_realtime_capture_cairo.Visible = true;
 
                                event_graph_label_graph_test.Visible = true;
                                vbox_contacts_simple_graph_controls.Visible = false;
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index b720e8aec..f71cd9c11 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -682,6 +682,8 @@ public partial class ChronoJumpWindow
                label_start_selector_races.UseMarkup = true;
                label_start_selector_encoder.UseMarkup = true;
 
+               image_check_runI_realtime_rel_abs.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
"bar_relative.png");
+
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsFallCalculate);
                extra_windows_jumps_image_dj_fall_calculate.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsFallPredefined);
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index fab99928e..c77e5621e 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -105,6 +105,9 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.DrawingArea event_execute_drawingarea;
        [Widget] Gtk.DrawingArea event_execute_drawingarea_realtime_capture_cairo;
        [Widget] Gtk.DrawingArea event_execute_drawingarea_cairo;
+       [Widget] Gtk.VBox vbox_event_execute_drawingarea_realtime_capture_cairo;
+       [Widget] Gtk.CheckButton check_runI_realtime_rel_abs;
+       [Widget] Gtk.Image image_check_runI_realtime_rel_abs;
        [Widget] Gtk.Frame frame_run_simple_double_contacts;
        [Widget] Gtk.DrawingArea event_execute_drawingarea_run_simple_double_contacts;
        /*
@@ -708,6 +711,28 @@ public partial class ChronoJumpWindow
                cairoPaintBarsPre.Paint();
        }
 
+       private void on_check_runI_realtime_rel_abs_toggled (object o, EventArgs args)
+       {
+               // 1) change icon
+               if(check_runI_realtime_rel_abs.Active)
+                       image_check_runI_realtime_rel_abs.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) 
+ "bar_relative.png");
+               else
+                       image_check_runI_realtime_rel_abs.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) 
+ "bar_absolute.png");
+
+               // 2) redo graph if possible
+               if(currentEventExecute == null || 
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject == null)
+                       return;
+
+               PrepareRunIntervalRealtimeCaptureGraph(
+                               currentEventExecute.PrepareEventGraphRunIntervalObject.distance,
+                               currentEventExecute.PrepareEventGraphRunIntervalObject.lastTime,
+                               currentEventExecute.PrepareEventGraphRunIntervalObject.timesString,
+                               currentEventExecute.PrepareEventGraphRunIntervalObject.distanceTotal,
+                               currentEventExecute.PrepareEventGraphRunIntervalObject.distancesString,
+                               currentEventExecute.PrepareEventGraphRunIntervalObject.type
+                               );
+       }
+
        // Reactive jump 
        public void PrepareJumpReactiveRealtimeCaptureGraph (double lastTv, double lastTc, string tvString, 
string tcString, string type,
                        bool volumeOn, Preferences.GstreamerTypes gstreamer, RepetitiveConditionsWindow 
repetitiveConditionsWin)
@@ -3311,6 +3336,7 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
 {
        private double lastDistance;
        private double lastTime;
+       private bool isRelative; //related to names: distance and time
 
        private List<double> distance_l;
        private List<double> time_l;
@@ -3318,12 +3344,14 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
 
        public CairoPaintBarsPreRunIntervalRealtimeCapture (DrawingArea darea, string fontStr,
                        Constants.Modes mode, string personName, string testName, int pDN,// bool 
heightPreferred,
+                       bool isRelative,
                        double lastDistance, double lastTime, string timesString, string distancesString)
        {
                initialize (darea, fontStr, mode, Catalog.GetString("Last test:") + " " + 
generateTitle(personName, testName), pDN);
 
                this.lastDistance = lastDistance;
                this.lastTime = lastTime;
+               this.isRelative = isRelative;
 
                distance_l = new List<double>();
                time_l = new List<double>();
@@ -3402,14 +3430,33 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
                double sum = 0; //for speed_l avg
                double min = 1000;
 
+               //for absolute data. Absolute is from the beginning.
+               double distanceTotal = 0;
+               double timeTotal = 0;
+               for(int i = 0; i < time_l.Count; i ++)
+               {
+                       distanceTotal += distance_l[i];
+                       timeTotal += time_l[i];
+               }
+               double distanceAccumulated = distanceTotal;
+               double timeAccumulated = timeTotal;
+
                for(int i = time_l.Count -1; i >= 0; i --)
                {
                        double time = Convert.ToDouble(time_l[i]);
                        double speed = Convert.ToDouble(speed_l[i]);
 
                        point_l.Add(new PointF(i+1, speed));
-                       names_l.Add(string.Format("{0} m\n{1} s",
-                                               distance_l[i], Util.TrimDecimals(time,2)));
+
+                       if(isRelative)
+                               names_l.Add(string.Format("{0} m\n{1} s",
+                                                       distance_l[i], Util.TrimDecimals(time,2)));
+                       else {
+                               names_l.Add(string.Format("{0} m\n{1} s",
+                                                       distanceAccumulated, 
Util.TrimDecimals(timeAccumulated,2)));
+                               distanceAccumulated -= distance_l[i];
+                               timeAccumulated -= time_l[i];
+                       }
 
                        if(speed > max)         //get max
                                max = speed;


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