[chronojump] RaceAnalyzer: recalculate and fixed top notebook glitch



commit a45b5746a07326682617b1df938bfd84b08eed6b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 11 16:49:59 2019 +0200

    RaceAnalyzer: recalculate and fixed top notebook glitch

 glade/app1.glade           | 38 +++++++++++++++++++-
 src/gui/chronojumpIcons.cs |  2 ++
 src/gui/runEncoder.cs      | 88 ++++++++++++++++++++++++++++------------------
 3 files changed, 92 insertions(+), 36 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index ef3b42ca..b74cd903 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1926,6 +1926,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -9682,7 +9685,7 @@ EncoderInertialCapture</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox288">
+                                                            <widget class="GtkHBox" id="hbox288_run_encoder">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">30</property>
@@ -9800,6 +9803,33 @@ EncoderInertialCapture</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_run_encoder_recalculate">
+                                                            <property name="width_request">60</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="can_default">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="has_tooltip">True</property>
+                                                            <property name="tooltip" 
translatable="yes">Recalculate set with changed parameters</property>
+                                                            <property name="relief">half</property>
+                                                            <property name="use_underline">True</property>
+                                                            <signal name="clicked" 
handler="on_button_run_encoder_recalculate_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_force_sensor_capture_recalculate">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">8</property>
@@ -20951,6 +20981,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -29661,6 +29694,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index 3b582e87..d1436f20 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -140,6 +140,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_force_sensor_capture_adjust_close;
        [Widget] Gtk.Image image_force_sensor_analyze_options;
        [Widget] Gtk.Image image_force_sensor_analyze_options_close;
+       [Widget] Gtk.Image image_force_sensor_capture_recalculate;
        [Widget] Gtk.Image image_force_sensor_analyze_recalculate;
        [Widget] Gtk.Image image_force_sensor_exercise_edit;
        [Widget] Gtk.Image image_force_sensor_laterality_both;
@@ -290,6 +291,7 @@ public partial class ChronoJumpWindow
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_recalculate.png");
                image_recalculate.Pixbuf = pixbuf;
+               image_force_sensor_capture_recalculate.Pixbuf = pixbuf;
                image_force_sensor_analyze_recalculate.Pixbuf = pixbuf;
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_build_24.png");
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index f8f8936a..be69dfbf 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -387,43 +387,61 @@ public partial class ChronoJumpWindow
                        File.Copy(fileName, UtilEncoder.GetRaceAnalyzerCSVFileName(), true); //can be 
overwritten
                        lastRunEncoderFullPath = fileName;
 
+                       forceSensorCaptureGraphDo();
+
+                       capturingRunEncoder = arduinoCaptureStatus.COPIED_TO_TMP;
+               }
+       }
+
+       private void on_button_run_encoder_recalculate_clicked (object o, EventArgs args)
+       {
                race_analyzer_distance = Convert.ToInt32(race_analyzer_spinbutton_distance.Value);
                race_analyzer_temperature = Convert.ToInt32(race_analyzer_spinbutton_temperature.Value);
-                       //create graph
-                       RunEncoderGraph reg = new RunEncoderGraph(
-                                        race_analyzer_distance,
-                                        currentPersonSession.Weight,   //TODO: can be more if extra weight
-                                        currentPersonSession.Height,
-                                        race_analyzer_temperature);
-                       reg.CallR(1699, 768);                           //TODO: hardcoded
-
-                       DateTime runEncoderGraphStarted = DateTime.Now;
-                       //TODO: check better if png is saved and have a cancel button
-
-                       while(! File.Exists(UtilEncoder.GetSprintEncoderImage()) && 
DateTime.Now.Subtract(runEncoderGraphStarted).TotalSeconds < 5)
-                               Thread.Sleep(500);
-
-                       captureEndedMessage = "Data on raceAnalyzer folder";
-                       if(File.Exists(UtilEncoder.GetSprintEncoderImage()))
-                       {
-                               LogB.Information("File exists on png, trying to copy");
-                               try {
-                                       File.Copy(UtilEncoder.GetSprintEncoderImage(),
-                                                       
Util.GetRaceAnalyzerSessionDir(currentSession.UniqueID) + Path.DirectorySeparatorChar +
-                                                       lastRunEncoderFile +    //nameDate
-                                                       ".png",
-                                                       true); //can be overwritten
-                                       captureEndedMessage += " (png too)";
-                               } catch {
-                                       LogB.Information("Couldn't copy the file");
-                                       captureEndedMessage += " (Created png but only on tmp folder, could 
not copy file)";
-                               }
-                       } else {
-                               LogB.Information("File does not exist on png (after 5 seconds)");
-                               captureEndedMessage += " (png not created, problem doing the graph)";
-                       }
 
-                       capturingRunEncoder = arduinoCaptureStatus.COPIED_TO_TMP;
+               forceSensorCaptureGraphDo();
+
+               event_execute_label_message.Text = "Recalculated.";
+               Thread.Sleep (250); //Wait a bit to ensure is copied
+
+               runEncoderAnalyzeOpenImage();
+               notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.RACEENCODER);
+               radio_mode_contacts_analyze.Active = true;
+       }
+
+       private void forceSensorCaptureGraphDo()
+       {
+               //create graph
+               RunEncoderGraph reg = new RunEncoderGraph(
+                               race_analyzer_distance,
+                               currentPersonSession.Weight,    //TODO: can be more if extra weight
+                               currentPersonSession.Height,
+                               race_analyzer_temperature);
+               reg.CallR(1699, 768);                           //TODO: hardcoded
+
+               DateTime runEncoderGraphStarted = DateTime.Now;
+               //TODO: check better if png is saved and have a cancel button
+
+               while(! File.Exists(UtilEncoder.GetSprintEncoderImage()) && 
DateTime.Now.Subtract(runEncoderGraphStarted).TotalSeconds < 5)
+                       Thread.Sleep(500);
+
+               captureEndedMessage = "Data on raceAnalyzer folder";
+               if(File.Exists(UtilEncoder.GetSprintEncoderImage()))
+               {
+                       LogB.Information("File exists on png, trying to copy");
+                       try {
+                               File.Copy(UtilEncoder.GetSprintEncoderImage(),
+                                               Util.GetRaceAnalyzerSessionDir(currentSession.UniqueID) + 
Path.DirectorySeparatorChar +
+                                               lastRunEncoderFile +    //nameDate
+                                               ".png",
+                                               true); //can be overwritten
+                               captureEndedMessage += " (png too)";
+                       } catch {
+                               LogB.Information("Couldn't copy the file");
+                               captureEndedMessage += " (Created png but only on tmp folder, could not copy 
file)";
+                       }
+               } else {
+                       LogB.Information("File does not exist on png (after 5 seconds)");
+                       captureEndedMessage += " (png not created, problem doing the graph)";
                }
        }
 
@@ -466,7 +484,7 @@ LogB.Information(" fc C finish");
 
                                        runEncoderAnalyzeOpenImage();
                                        notebook_analyze.CurrentPage = 
Convert.ToInt32(notebook_analyze_pages.RACEENCODER);
-                                       notebook_capture_analyze.CurrentPage = 1;
+                                       radio_mode_contacts_analyze.Active = true;
 
                                        /*
                                        fscPoints.InitRealWidthHeight();


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