[chronojump/michrolab] ForceSensorExercise elastic as type managed on forceSensorExercise window



commit 7f1723d54ca4a91e5f0f8b6c7930b3e76627ae01
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jul 14 19:29:49 2022 +0200

    ForceSensorExercise elastic as type managed on forceSensorExercise window

 glade/app1.glade                  |  18 ++++++
 glade/force_sensor_exercise.glade | 117 ++++++++++++++++++++++++++++++++++----
 src/gui/forceSensorExercise.cs    |  83 +++++++++++++++++----------
 3 files changed, 179 insertions(+), 39 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index fdae27160..acf999cba 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -26037,6 +26037,12 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -42305,6 +42311,12 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -50357,6 +50369,12 @@ Since Chronojump 2.1.3, backups contain the complete data.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             </widget>
diff --git a/glade/force_sensor_exercise.glade b/glade/force_sensor_exercise.glade
index 3fcd47ca6..2f0ea2423 100644
--- a/glade/force_sensor_exercise.glade
+++ b/glade/force_sensor_exercise.glade
@@ -100,6 +100,99 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="show_tabs">False</property>
+                <child>
+                  <widget class="GtkVBox" id="vbox_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="border_width">8</property>
+                    <property name="spacing">20</property>
+                    <child>
+                      <widget class="GtkLabel" id="label_type">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Chronojump 2.2.2 split force sensor mode 
into isometric and elastic modes.
+During the conversion, this exercise has been assigned to both modes.
+Do you want to have it in only one mode?</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkVBox" id="vbox1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">12</property>
+                        <child>
+                          <widget class="GtkRadioButton" id="radio_type_both">
+                            <property name="label" translatable="yes">Continue in both modes</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>
+                          </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_type_isometric">
+                            <property name="label" translatable="yes">Only for isometric mode</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_type_both</property>
+                          </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_type_elastic">
+                            <property name="label" translatable="yes">Only for elastic mode</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="relief">none</property>
+                            <property name="draw_indicator">True</property>
+                            <property name="group">radio_type_both</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label13">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label">type: iso/elastic</property>
+                  </widget>
+                  <packing>
+                    <property name="tab_fill">False</property>
+                    <property name="type">tab</property>
+                  </packing>
+                </child>
                 <child>
                   <widget class="GtkVBox" id="vbox_force">
                     <property name="visible">True</property>
@@ -211,6 +304,9 @@
                       </packing>
                     </child>
                   </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
                 <child>
                   <widget class="GtkLabel" id="label3">
@@ -219,6 +315,7 @@
                     <property name="label">force</property>
                   </widget>
                   <packing>
+                    <property name="position">1</property>
                     <property name="tab_fill">False</property>
                     <property name="type">tab</property>
                   </packing>
@@ -303,7 +400,7 @@
                     </child>
                   </widget>
                   <packing>
-                    <property name="position">1</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
                 <child>
@@ -313,7 +410,7 @@
                     <property name="label">fixation</property>
                   </widget>
                   <packing>
-                    <property name="position">1</property>
+                    <property name="position">2</property>
                     <property name="tab_fill">False</property>
                     <property name="type">tab</property>
                   </packing>
@@ -472,7 +569,7 @@
                     </child>
                   </widget>
                   <packing>
-                    <property name="position">2</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
                 <child>
@@ -482,7 +579,7 @@
                     <property name="label">mass</property>
                   </widget>
                   <packing>
-                    <property name="position">2</property>
+                    <property name="position">3</property>
                     <property name="tab_fill">False</property>
                     <property name="type">tab</property>
                   </packing>
@@ -1044,7 +1141,7 @@
                     </child>
                   </widget>
                   <packing>
-                    <property name="position">3</property>
+                    <property name="position">4</property>
                   </packing>
                 </child>
                 <child>
@@ -1054,7 +1151,7 @@
                     <property name="label">repetitionsDetect</property>
                   </widget>
                   <packing>
-                    <property name="position">3</property>
+                    <property name="position">4</property>
                     <property name="tab_fill">False</property>
                     <property name="type">tab</property>
                   </packing>
@@ -1184,7 +1281,7 @@
                     </child>
                   </widget>
                   <packing>
-                    <property name="position">4</property>
+                    <property name="position">5</property>
                   </packing>
                 </child>
                 <child>
@@ -1194,7 +1291,7 @@
                     <property name="label">repetitionsShow</property>
                   </widget>
                   <packing>
-                    <property name="position">4</property>
+                    <property name="position">5</property>
                     <property name="tab_fill">False</property>
                     <property name="type">tab</property>
                   </packing>
@@ -1343,7 +1440,7 @@
                     </child>
                   </widget>
                   <packing>
-                    <property name="position">5</property>
+                    <property name="position">6</property>
                   </packing>
                 </child>
                 <child>
@@ -1353,7 +1450,7 @@
                     <property name="label">other</property>
                   </widget>
                   <packing>
-                    <property name="position">5</property>
+                    <property name="position">6</property>
                     <property name="tab_fill">False</property>
                     <property name="type">tab</property>
                   </packing>
diff --git a/src/gui/forceSensorExercise.cs b/src/gui/forceSensorExercise.cs
index 63b95fbdb..0a4f9ce14 100644
--- a/src/gui/forceSensorExercise.cs
+++ b/src/gui/forceSensorExercise.cs
@@ -52,6 +52,11 @@ public class ForceSensorExerciseWindow
        [Widget] Gtk.Image image_next;
        [Widget] Gtk.Image image_cancel;
 
+       //type tab
+       [Widget] Gtk.RadioButton radio_type_both;
+       [Widget] Gtk.RadioButton radio_type_isometric;
+       [Widget] Gtk.RadioButton radio_type_elastic;
+
        //force tab
        [Widget] Gtk.Label label_force;
        [Widget] Gtk.TextView textview_force_explanation;
@@ -63,8 +68,9 @@ public class ForceSensorExerciseWindow
        //fixation tab
        [Widget] Gtk.Label label_fixation;
        [Widget] Gtk.TextView textview_fixation_explanation;
-       [Widget] Gtk.RadioButton radio_fixation_elastic;
-       [Widget] Gtk.RadioButton radio_fixation_not_elastic;
+       // disabled, using the "type" variable
+       //[Widget] Gtk.RadioButton radio_fixation_elastic;
+       //[Widget] Gtk.RadioButton radio_fixation_not_elastic;
 
        //mass tab
        [Widget] Gtk.Label label_mass;
@@ -109,7 +115,9 @@ public class ForceSensorExerciseWindow
        [Widget] Gtk.Button fakeButtonReadValues;
 
        public bool Success;
+       private bool adding;
        private Constants.Modes chronojumpMode;
+       private ForceSensorExercise.Types type;
        private ForceSensorExercise exercise;
 
        //values on preferences, useful to show them unsensitive if the 
radio_detect_repetitions_from_prefs.Active
@@ -121,7 +129,7 @@ public class ForceSensorExerciseWindow
 
        private enum modesEnum { EDIT, ADD }
        private modesEnum modeEnum;
-       private enum Pages { FORCE, FIXATION, MASS, REPSDETECT, REPSSHOW, OTHER }
+       private enum Pages { TYPE, FORCE, FIXATION, MASS, REPSDETECT, REPSSHOW, OTHER }
        private enum Options { FORCE_SENSOR, FORCE_RESULTANT, FIXATION_ELASTIC, FIXATION_NOT_ELASTIC,
                MASS_ADD, MASS_SUBTRACT, MASS_NOTHING,
                REPETITIONS_PREFS, REPETITIONS_NO_PREFS, REPETITIONS_SHOW, OTHER }
@@ -176,7 +184,9 @@ public class ForceSensorExerciseWindow
                        ForceSensorExerciseWindowBox.label_header.Text = textHeader;
                }
 
+               ForceSensorExerciseWindowBox.adding = false;
                ForceSensorExerciseWindowBox.chronojumpMode = chronojumpMode;
+               ForceSensorExerciseWindowBox.type = exercise.Type; //do not change the type here, if it's 
both will continue being both
                ForceSensorExerciseWindowBox.Success = false;
                ForceSensorExerciseWindowBox.modeEnum = modesEnum.EDIT;
                ForceSensorExerciseWindowBox.exercise = exercise;
@@ -228,7 +238,7 @@ public class ForceSensorExerciseWindow
                                        Convert.ToInt32(em), Convert.ToInt32(cm));
                }
 
-               ForceSensorExerciseWindowBox.initializeGuiAtShow(false);
+               ForceSensorExerciseWindowBox.initializeGuiAtShow ();
                ForceSensorExerciseWindowBox.force_sensor_exercise.Show ();
 
                return ForceSensorExerciseWindowBox;
@@ -246,11 +256,12 @@ public class ForceSensorExerciseWindow
                        ForceSensorExerciseWindowBox.label_header.Text = textHeader;
                }
 
+               ForceSensorExerciseWindowBox.adding = true;
                ForceSensorExerciseWindowBox.chronojumpMode = chronojumpMode;
                if(chronojumpMode == Constants.Modes.FORCESENSORISOMETRIC)
-                       ForceSensorExerciseWindowBox.radio_fixation_not_elastic.Active = true;
+                       ForceSensorExerciseWindowBox.type = ForceSensorExercise.Types.ISOMETRIC;
                else //if(chronojumpMode == Constants.Modes.FORCESENSORELASTIC)
-                       ForceSensorExerciseWindowBox.radio_fixation_elastic.Active = true;
+                       ForceSensorExerciseWindowBox.type = ForceSensorExercise.Types.ELASTIC;
 
                ForceSensorExerciseWindowBox.Success = false;
                ForceSensorExerciseWindowBox.modeEnum = modesEnum.ADD;
@@ -266,7 +277,7 @@ public class ForceSensorExerciseWindow
                                prefsForceSensorElasticEccMinDispl, prefsForceSensorElasticConMinDispl,
                                prefsForceSensorNotElasticEccMinForce, prefsForceSensorNotElasticConMinForce);
 
-               ForceSensorExerciseWindowBox.initializeGuiAtShow(true);
+               ForceSensorExerciseWindowBox.initializeGuiAtShow ();
                ForceSensorExerciseWindowBox.force_sensor_exercise.Show ();
 
                return ForceSensorExerciseWindowBox;
@@ -306,10 +317,17 @@ public class ForceSensorExerciseWindow
                image_force_exerted_help.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
"image_info.png");
        }
 
-       private void initializeGuiAtShow (bool adding)
+       private void initializeGuiAtShow ()
        {
-               managePage(Pages.FORCE);
-               ForceSensorExerciseWindowBox.notebook_main.CurrentPage = Convert.ToInt32(Pages.FORCE);
+               Pages p = Pages.FORCE;
+               if (! adding && exercise.Type == ForceSensorExercise.Types.BOTH)
+               {
+                       p = Pages.TYPE;
+                       radio_type_both.Active = true;
+               }
+
+               managePage (p);
+               ForceSensorExerciseWindowBox.notebook_main.CurrentPage = Convert.ToInt32 (p);
 
                //on edit spin_body_mass_add.Value is set at exerciseToGUI(), but on adding, set at 100
                if(adding)
@@ -329,11 +347,6 @@ public class ForceSensorExerciseWindow
                        button_force_exerted_help.Sensitive = false;
                }
 
-               if(exercise.Elastic)
-                       radio_fixation_elastic.Active = true;
-               else
-                       radio_fixation_not_elastic.Active = true;
-
                if(exercise.PercentBodyWeight > 0 && ! exercise.TareBeforeCapture)
                        radio_mass_add.Active = true;
 
@@ -522,9 +535,16 @@ public class ForceSensorExerciseWindow
                radio_desc_examples_examples.Show();
                notebook_desc_examples.GetNthPage(1).Show();
 
-               if(p == Pages.FORCE)
+               if(p == Pages.TYPE)
                {
+                       desc = "";
+                       ex = "";
                        button_back.Sensitive = false;
+               }
+               else if(p == Pages.FORCE)
+               {
+                       if (adding || exercise.Type != ForceSensorExercise.Types.BOTH)
+                               button_back.Sensitive = false;
 
                        if(radio_force_sensor_raw.Active) {
                                desc = getDescription(Options.FORCE_SENSOR);
@@ -540,15 +560,8 @@ public class ForceSensorExerciseWindow
                }
                else if(p == Pages.FIXATION)
                {
-                       if(radio_fixation_elastic.Active) {
-                               desc = getDescription(Options.FIXATION_ELASTIC);
-                               ex = getExample(Options.FIXATION_ELASTIC);
-                               set_notebook_desc_example_labels(Options.FIXATION_ELASTIC);
-                       } else {
-                               desc = getDescription(Options.FIXATION_NOT_ELASTIC);
-                               ex = getExample(Options.FIXATION_NOT_ELASTIC);
-                               set_notebook_desc_example_labels(Options.FIXATION_NOT_ELASTIC);
-                       }
+                       desc = "";
+                       ex = "";
                }
                else if(p == Pages.MASS)
                {
@@ -569,7 +582,7 @@ public class ForceSensorExerciseWindow
                }
                else if(p == Pages.REPSDETECT)
                {
-                       if(radio_force_sensor_raw.Active || ! radio_fixation_elastic.Active)
+                       if(radio_force_sensor_raw.Active || chronojumpMode == 
Constants.Modes.FORCESENSORISOMETRIC)
                        {
                                label_repetitions_prefs_ecc_value.Text = 
prefsForceSensorNotElasticEccMinForce.ToString();
                                label_repetitions_prefs_con_value.Text = 
prefsForceSensorNotElasticConMinForce.ToString();
@@ -584,7 +597,7 @@ public class ForceSensorExerciseWindow
 
 
                        //visibilities
-                       if(radio_force_sensor_raw.Active || ! radio_fixation_elastic.Active)
+                       if(radio_force_sensor_raw.Active || chronojumpMode == 
Constants.Modes.FORCESENSORISOMETRIC)
                        {
                                hbox_detect_repetitions_not_elastic.Visible = true;
                                hbox_detect_repetitions_elastic.Visible = false;
@@ -691,6 +704,9 @@ public class ForceSensorExerciseWindow
                        notebook_main.CurrentPage = Convert.ToInt32 (Pages.FORCE);
                else if (notebook_main.CurrentPage > Convert.ToInt32 (Pages.FORCE))
                        notebook_main.CurrentPage --;
+               else if (notebook_main.CurrentPage == Convert.ToInt32 (Pages.FORCE) &&
+                               ! adding && exercise.Type == ForceSensorExercise.Types.BOTH)
+                       notebook_main.CurrentPage --;
                else
                        return;
 
@@ -790,7 +806,7 @@ public class ForceSensorExerciseWindow
                double conMin = -1;
                if(! radio_detect_repetitions_from_prefs.Active)
                {
-                       if(radio_force_sensor_raw.Active || ! radio_fixation_elastic.Active) {
+                       if (radio_force_sensor_raw.Active || chronojumpMode == 
Constants.Modes.FORCESENSORISOMETRIC) {
                                eccMin = spin_force_sensor_not_elastic_ecc_min_force.Value;
                                conMin = spin_force_sensor_not_elastic_con_min_force.Value;
                        } else {
@@ -818,6 +834,15 @@ public class ForceSensorExerciseWindow
                else //if(radio_reps_show_both.Active && radio_reps_show_both_separated.Active)
                        repetitionsShow = ForceSensorExercise.RepetitionsShowTypes.BOTHSEPARATED;
 
+               ForceSensorExercise.Types typeNew = type;
+               if (! adding && exercise.Type == ForceSensorExercise.Types.BOTH)
+               {
+                       if (radio_type_isometric.Active)
+                               typeNew = ForceSensorExercise.Types.ISOMETRIC;
+                       else if (radio_type_elastic.Active)
+                               typeNew = ForceSensorExercise.Types.ELASTIC;
+               }
+
                ForceSensorExercise exerciseTemp = new ForceSensorExercise(
                                myID, entry_name.Text,
                                percentBodyWeight,
@@ -826,7 +851,7 @@ public class ForceSensorExerciseWindow
                                entry_description.Text,
                                radio_mass_subtract.Active,     //tareBeforeCapture
                                radio_force_resultant.Active,
-                               radio_fixation_elastic.Active,
+                               typeNew,
                                repetitionsShow, eccMin, conMin);
 
                if(modeEnum == modesEnum.ADD)


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