[chronojump] DB: 1.78 EncoderAutoSaveCurveBestNValue on capture/gui/preferences/SQL



commit 42f8401676e1080473378b45ab37b072d721cf0e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Oct 28 20:17:33 2019 +0100

    DB: 1.78 EncoderAutoSaveCurveBestNValue on capture/gui/preferences/SQL

 glade/preferences_win.glade | 73 ++++++++++++++++++++++++++++++++++++++++++---
 src/gui/chronojump.cs       | 16 ++++++++--
 src/gui/encoder.cs          |  1 +
 src/gui/preferences.cs      | 21 +++++++++++++
 src/preferences.cs          |  1 +
 src/sqlite/main.cs          | 12 +++++++-
 src/sqlite/preferences.cs   |  5 ++++
 7 files changed, 121 insertions(+), 8 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index fcc9c7db..9955894e 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -2451,6 +2451,60 @@ It starts before and arrives there with some speed.</property>
                                             <property name="position">0</property>
                                           </packing>
                                         </child>
+                                        <child>
+                                          <widget class="GtkHBox" id="hbox48">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="spacing">8</property>
+                                            <child>
+                                              <widget class="GtkRadioButton" 
id="radio_encoder_auto_save_curve_best_n">
+                                                <property name="label" translatable="yes">Save the best n 
repetitions</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_encoder_auto_save_curve_best</property>
+                                                <signal name="toggled" 
handler="on_radio_encoder_auto_save_curve_best_n_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="GtkSpinButton" 
id="spin_encoder_auto_save_curve_best_n">
+                                                <property name="visible">True</property>
+                                                <property name="sensitive">False</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="has_tooltip">True</property>
+                                                <property name="tooltip" translatable="yes">Minimal 
height</property>
+                                                <property name="invisible_char">●</property>
+                                                <property name="width_chars">2</property>
+                                                <property name="invisible_char_set">True</property>
+                                                <property name="primary_icon_activatable">False</property>
+                                                <property name="secondary_icon_activatable">False</property>
+                                                <property name="primary_icon_sensitive">True</property>
+                                                <property name="secondary_icon_sensitive">True</property>
+                                                <property name="adjustment">3 1 10 1 10 0</property>
+                                                <property name="climb_rate">1</property>
+                                                <property name="snap_to_ticks">True</property>
+                                                <property name="numeric">True</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</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="GtkRadioButton" 
id="radio_encoder_auto_save_curve_all">
                                             <property name="label" translatable="yes">Save all</property>
@@ -2463,7 +2517,7 @@ It starts before and arrives there with some speed.</property>
                                           <packing>
                                             <property name="expand">True</property>
                                             <property name="fill">True</property>
-                                            <property name="position">1</property>
+                                            <property name="position">2</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -2543,7 +2597,7 @@ It starts before and arrives there with some speed.</property>
                                           <packing>
                                             <property name="expand">False</property>
                                             <property name="fill">False</property>
-                                            <property name="position">2</property>
+                                            <property name="position">3</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -2558,7 +2612,7 @@ It starts before and arrives there with some speed.</property>
                                           <packing>
                                             <property name="expand">True</property>
                                             <property name="fill">True</property>
-                                            <property name="position">3</property>
+                                            <property name="position">4</property>
                                           </packing>
                                         </child>
                                       </widget>
@@ -2568,6 +2622,17 @@ It starts before and arrives there with some speed.</property>
                                         <property name="position">0</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <widget class="GtkVSeparator" id="vseparator1">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
                                     <child>
                                       <widget class="GtkVBox" id="vbox21">
                                         <property name="visible">True</property>
@@ -2654,7 +2719,7 @@ It starts before and arrives there with some speed.</property>
                                       <packing>
                                         <property name="expand">False</property>
                                         <property name="fill">False</property>
-                                        <property name="position">1</property>
+                                        <property name="position">2</property>
                                       </packing>
                                     </child>
                                   </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d864254e..eae57ef2 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -842,6 +842,10 @@ public partial class ChronoJumpWindow
 
                configInitFromPreferences();
 
+               //---- encoder ----
+
+               spin_encoder_capture_curves_best_n.Value = preferences.encoderAutoSaveCurveBestNValue;
+
                encoderRhythm = new EncoderRhythm(
                                preferences.encoderRhythmActive, preferences.encoderRhythmRepsOrPhases,
                                preferences.encoderRhythmRepSeconds,
@@ -849,6 +853,7 @@ public partial class ChronoJumpWindow
                                preferences.encoderRhythmRestRepsSeconds, 
preferences.encoderRhythmRestAfterEcc,
                                preferences.encoderRhythmRepsCluster, 
preferences.encoderRhythmRestClustersSeconds);
 
+               //---- jumps ----
 
                checkbutton_allow_finish_rj_after_time.Active = preferences.allowFinishRjAfterTime;
 
@@ -3037,9 +3042,14 @@ public partial class ChronoJumpWindow
                        LogB.Information("catched at on_preferences_accepted ()");
                }
 
-               //forceSensor (pen has already been defined)
-               pen_black_force_capture.SetLineAttributes (preferences.forceSensorGraphsLineWidth, 
Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
-               pen_black_force_ai.SetLineAttributes (preferences.forceSensorGraphsLineWidth, 
Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
+               //encoder
+               spin_encoder_capture_curves_best_n.Value = preferences.encoderAutoSaveCurveBestNValue;
+
+               //forceSensor (check that pen has already been defined)
+               if(pen_black_force_capture != null)
+                       pen_black_force_capture.SetLineAttributes (preferences.forceSensorGraphsLineWidth, 
Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
+               if(pen_black_force_ai != null)
+                       pen_black_force_ai.SetLineAttributes (preferences.forceSensorGraphsLineWidth, 
Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
        }
 
 
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index a2c64174..b1edb1cf 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -6474,6 +6474,7 @@ public partial class ChronoJumpWindow
                                                        encoderSignalUniqueID == "-1" &&        //if we just 
captured
                                                        (preferences.encoderAutoSaveCurve == 
Constants.EncoderAutoSaveCurve.ALL ||
                                                        preferences.encoderAutoSaveCurve == 
Constants.EncoderAutoSaveCurve.BEST ||
+                                                       preferences.encoderAutoSaveCurve == 
Constants.EncoderAutoSaveCurve.BESTN ||
                                                        preferences.encoderAutoSaveCurve == 
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE) )
                                                needToAutoSaveCurve = true;
 
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index a9e1dd23..818edc20 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -122,6 +122,8 @@ public class PreferencesWindow
        [Widget] Gtk.RadioButton radio_encoder_capture_show_only_some_bars;
        [Widget] Gtk.SpinButton spin_encoder_capture_barplot_font_size;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_best;
+       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_best_n;
+       [Widget] Gtk.SpinButton spin_encoder_auto_save_curve_best_n;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_4top;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_all;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_none;
@@ -549,8 +551,16 @@ public class PreferencesWindow
                }
 
 
+               PreferencesWindowBox.spin_encoder_auto_save_curve_best_n.Value = 
preferences.encoderAutoSaveCurveBestNValue;
+               PreferencesWindowBox.spin_encoder_auto_save_curve_best_n.Sensitive = false;
+
                if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BEST)
                        PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active = true;
+               else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BESTN)
+               {
+                       PreferencesWindowBox.radio_encoder_auto_save_curve_best_n.Active = true;
+                       PreferencesWindowBox.spin_encoder_auto_save_curve_best_n.Sensitive = true;
+               }
                else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
                        PreferencesWindowBox.radio_encoder_auto_save_curve_4top.Active = true;
                else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.ALL)
@@ -633,6 +643,11 @@ public class PreferencesWindow
                spin_encoder_capture_show_only_some_bars.Sensitive = true;
        }
 
+       private void on_radio_encoder_auto_save_curve_best_n_toggled (object o, EventArgs args)
+       {
+               spin_encoder_auto_save_curve_best_n.Sensitive = radio_encoder_auto_save_curve_best_n.Active;
+       }
+
        private void on_check_encoder_capture_inactivity_end_time_clicked (object o, EventArgs args)
        {
                hbox_encoder_capture_inactivity_time.Sensitive = 
check_encoder_capture_inactivity_end_time.Active;
@@ -1859,6 +1874,12 @@ public class PreferencesWindow
                        SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.BEST.ToString(), true);
                        preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.BEST;
                }
+               else if(PreferencesWindowBox.radio_encoder_auto_save_curve_best_n.Active) {
+                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.BESTN.ToString(), true);
+                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.BESTN;
+                       SqlitePreferences.Update(SqlitePreferences.EncoderAutoSaveCurveBestNValue, 
spin_encoder_auto_save_curve_best_n.Value.ToString(), true);
+                       preferences.encoderAutoSaveCurveBestNValue = 
Convert.ToInt32(spin_encoder_auto_save_curve_best_n.Value);
+               }
                else if(PreferencesWindowBox.radio_encoder_auto_save_curve_4top.Active) {
                        SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE.ToString(), true);
                        preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE;
diff --git a/src/preferences.cs b/src/preferences.cs
index faa0eda4..3d2990f6 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -68,6 +68,7 @@ public class Preferences
        public bool encoderCaptureCheckFullyExtended;
        public int encoderCaptureCheckFullyExtendedValue;
        public Constants.EncoderAutoSaveCurve encoderAutoSaveCurve;
+       public int encoderAutoSaveCurveBestNValue;
        public int encoderCaptureBarplotFontSize;
        public bool encoderShowStartAndDuration;
        public enum TriggerTypes { NO_TRIGGERS, START_AT_CAPTURE, START_AT_FIRST_ON};
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 7543c7f5..ad9ac6df 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.77";
+       static string lastChronojumpDatabaseVersion = "1.78";
 
        public Sqlite() {
        }
@@ -2539,6 +2539,15 @@ class Sqlite
 
                                currentVersion = updateVersion("1.77");
                        }
+                       if(currentVersion == "1.77")
+                       {
+                               LogB.SQL("Inserted into preferences: encoderAutoSaveCurveBestNValue");
+
+                               SqlitePreferences.Insert (SqlitePreferences.EncoderAutoSaveCurveBestNValue, 
"3");
+
+                               currentVersion = updateVersion("1.78");
+                       }
+
 
 
                        // --- add more updates here
@@ -2733,6 +2742,7 @@ class Sqlite
                SqliteJson.createTableUploadExhibitionTestTemp ();
 
                //changes [from - to - desc]
+               //1.77 - 1.78 Converted DB to 1.78 Inserted into preferences: encoderAutoSaveCurveBestNValue
                //1.76 - 1.77 Converted DB to 1.77 Inserted into preferences: forceSensorGraphsLineWidth
                //1.75 - 1.76 Converted DB to 1.76 ALTER TABLE " + Constants.ForceSensorTable + " ADD COLUMN 
(stiffness float, stiffnessString string)
                //1.74 - 1.75 Converted DB to 1.75 Created table ForceSensorElasticBand
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 97bda6e5..108807e9 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -40,6 +40,8 @@ class SqlitePreferences : Sqlite
        public const string EncoderMassGravitatory = "encoderMassGravitatory";
        public const string EncoderWeightsInertial = "encoderWeightsInertial";
 
+       public const string EncoderAutoSaveCurveBestNValue = "encoderAutoSaveCurveBestNValue";
+
        public const string EncoderRhythmActiveStr = "encoderRhythmActive";
        public const string EncoderRhythmRepsOrPhasesStr = "encoderRhythmRepsOrPhases";
        public const string EncoderRhythmRepSecondsStr = "encoderRhythmRepSeconds";
@@ -198,6 +200,7 @@ class SqlitePreferences : Sqlite
                                Insert ("RGraphsTranslate", "True", dbcmdTr);
                                Insert ("useHeightsOnJumpIndexes", "True", dbcmdTr);
                                Insert ("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.BEST.ToString(), dbcmdTr); 
+                               Insert (EncoderAutoSaveCurveBestNValue, "3", dbcmdTr);
                                Insert ("email", "", dbcmdTr);
                                Insert ("muteLogs", "False", dbcmdTr);
                                Insert (ForceSensorTareDateTimeStr, "", dbcmdTr);
@@ -355,6 +358,8 @@ class SqlitePreferences : Sqlite
                        else if(reader[0].ToString() == "encoderAutoSaveCurve")
                                preferences.encoderAutoSaveCurve = (Constants.EncoderAutoSaveCurve) 
                                        Enum.Parse(typeof(Constants.EncoderAutoSaveCurve), 
reader[1].ToString()); 
+                       else if(reader[0].ToString() == EncoderAutoSaveCurveBestNValue)
+                               preferences.encoderAutoSaveCurveBestNValue = 
Convert.ToInt32(reader[1].ToString());
                        else if(reader[0].ToString() == "encoderCaptureBarplotFontSize")
                                preferences.encoderCaptureBarplotFontSize = 
Convert.ToInt32(reader[1].ToString());
                        else if(reader[0].ToString() == "encoderShowStartAndDuration")


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