[chronojump] compare intersession, select by weights 100% done



commit 54e17b2b423a4860bd4f3ad182ce59e6e125b038
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 25 20:58:31 2016 +0200

    compare intersession, select by weights 100% done

 glade/chronojump.glade              |   86 +++++++++++++++++++++++++++++++++-
 src/gui/encoder.cs                  |   52 +++++++++++++++++++---
 src/gui/encoderSelectRepetitions.cs |   15 +++++-
 src/util.cs                         |   16 +++++++
 4 files changed, 157 insertions(+), 12 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 8c74412..ad5ef4c 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -15003,14 +15003,40 @@ on current Chronojump version.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHBox" 
id="hbox_encoder_analyze_intersession">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">8</property>
+                                                            <child>
                                                             <widget class="GtkCheckButton" 
id="check_encoder_intersession_x_is_date">
                                                             <property name="label" translatable="yes">Date 
on X</property>
+                                                            <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
                                                             <property name="draw_indicator">True</property>
                                                             <signal name="toggled" 
handler="on_check_encoder_intersession_x_is_date_toggled" swapped="no"/>
                                                             </widget>
                                                             <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_combo_encoder_analyze_weights">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            </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">4</property>
@@ -16378,6 +16404,9 @@ on current Chronojump version.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -21043,6 +21072,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22189,6 +22221,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23827,6 +23862,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -24522,6 +24560,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -37366,6 +37407,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -39913,6 +39972,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -41192,9 +41263,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -42340,6 +42408,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -46372,6 +46443,9 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -47182,6 +47256,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -48007,6 +48084,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 43db628..6116be6 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -199,7 +199,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_encoder_analyze_side;
        [Widget] Gtk.Image image_encoder_analyze_single;
        [Widget] Gtk.Image image_encoder_analyze_nmp;
+       [Widget] Gtk.HBox hbox_encoder_analyze_intersession;
        [Widget] Gtk.CheckButton check_encoder_intersession_x_is_date;
+       [Widget] Gtk.HBox hbox_combo_encoder_analyze_weights;
+       [Widget] Gtk.ComboBox combo_encoder_analyze_weights;
        
        [Widget] Gtk.Button button_encoder_analyze_help;
 
@@ -370,6 +373,8 @@ public partial class ChronoJumpWindow
                encoderConfigurationCurrent = SqliteEncoder.LoadEncoderConfiguration();
                
                encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
+               
+               encSelReps = new EncoderSelectRepetitions();
 
                //the glade cursor_changed does not work on mono 1.2.5 windows
                //treeview_encoder_capture_curves.CursorChanged += 
on_treeview_encoder_capture_curves_cursor_changed;
@@ -408,8 +413,6 @@ public partial class ChronoJumpWindow
                configInit();
        
                array1RM = new ArrayList();
-                       
-               encSelReps = new EncoderSelectRepetitions();
        }
 
 
@@ -1623,6 +1626,8 @@ public partial class ChronoJumpWindow
                        LogB.Information("EncoderInterSessionDateOnXWeights");
                        foreach (double d in encSelReps.EncoderInterSessionDateOnXWeights)
                                LogB.Information(d.ToString());
+               
+                       createComboEncoderAnalyzeWeights(false);
                }
        
                button_encoder_analyze_sensitiveness();
@@ -2150,6 +2155,12 @@ public partial class ChronoJumpWindow
                                                        false, //onlyActive=false. Means: all saved 
repetitions
                                                        true);
                                        foreach(EncoderSQL eSQL in dataPre) {
+                                               string comboWeightsValue = 
UtilGtk.ComboGetActive(combo_encoder_analyze_weights);
+                                               if(check_encoder_intersession_x_is_date.Active &&
+                                                               comboWeightsValue != Catalog.GetString("All 
weights") &&
+                                                               comboWeightsValue != 
Util.ChangeDecimalSeparator(eSQL.extraWeight))
+                                                       continue;
+                                                       
                                                eSQL.status = "active"; //force all to be active on 
intersession
                                                data.Add(eSQL);
                                        }
@@ -2396,6 +2407,8 @@ public partial class ChronoJumpWindow
                
        
                createComboAnalyzeCross(false, false); //first creation: false, dateOnX: false
+               createComboEncoderAnalyzeWeights(false); //first creation: false
+
                updateComboEncoderAnalyzeCurveNumFromCurrentSet ();
 
                hbox_encoder_user_curves.Visible = false;
@@ -2410,7 +2423,7 @@ public partial class ChronoJumpWindow
 
                check_encoder_analyze_eccon_together.Sensitive = true;
                block_check_encoder_analyze_eccon_together_if_needed();
-               check_encoder_intersession_x_is_date.Visible = false;
+               hbox_encoder_analyze_intersession.Visible = false;
                        
                button_encoder_analyze_sensitiveness();
        
@@ -2450,7 +2463,7 @@ public partial class ChronoJumpWindow
 
                check_encoder_analyze_eccon_together.Sensitive = true;
                block_check_encoder_analyze_eccon_together_if_needed();
-               check_encoder_intersession_x_is_date.Visible = false;
+               hbox_encoder_analyze_intersession.Visible = false;
                        
                button_encoder_analyze_sensitiveness();
        
@@ -2467,6 +2480,7 @@ public partial class ChronoJumpWindow
                hbox_encoder_analyze_current_signal.Visible = false;
                
                createComboAnalyzeCross(false, check_encoder_intersession_x_is_date.Active);
+               combo_encoder_analyze_weights.Visible = check_encoder_intersession_x_is_date.Active;
 
                hbox_encoder_user_curves.Visible = currentPerson != null;
                
@@ -2474,7 +2488,7 @@ public partial class ChronoJumpWindow
                
                //active cross. The only available for comparing        
                radiobutton_encoder_analyze_cross.Active = true;
-               check_encoder_intersession_x_is_date.Visible = true;
+               hbox_encoder_analyze_intersession.Visible = true;
                
                //this analysis only when not comparing
                radiobutton_encoder_analyze_powerbars.Visible = false;
@@ -2501,7 +2515,7 @@ public partial class ChronoJumpWindow
                
                //active cross. The only available for comparing        
                radiobutton_encoder_analyze_cross.Active = true;
-               check_encoder_intersession_x_is_date.Visible = false;
+               hbox_encoder_analyze_intersession.Visible = false;
                
                //this analysis only when not comparing
                radiobutton_encoder_analyze_powerbars.Visible = false;
@@ -2900,6 +2914,7 @@ public partial class ChronoJumpWindow
 
                //create combo analyze cross
                createComboAnalyzeCross(true, false);   //first creation, without "dateOnX"
+               createComboEncoderAnalyzeWeights(true); //first creation
 
                //create combo analyze 1RM
                string [] comboAnalyze1RMOptions = { "1RM Any exercise", "1RM Bench Press", "1RM Indirect" };
@@ -3040,9 +3055,34 @@ public partial class ChronoJumpWindow
                        hbox_combo_encoder_analyze_cross.Visible = false; //do not show hbox at start
                }
        }
+               
+       private void createComboEncoderAnalyzeWeights(bool firstCreation) 
+       {
+               if(firstCreation)
+                       combo_encoder_analyze_weights = ComboBox.NewText ();
+       
+               string lastActive = UtilGtk.ComboGetActive(combo_encoder_analyze_weights);
+
+               if(encSelReps.EncoderInterSessionDateOnXWeights != null &&
+                       encSelReps.EncoderInterSessionDateOnXWeights.Count > 0) {
+                       UtilGtk.ComboUpdate(combo_encoder_analyze_weights, 
encSelReps.GetEncoderInterSessionDateOnXWeightsForCombo());
+                       combo_encoder_analyze_weights.Active = 
UtilGtk.ComboMakeActive(combo_encoder_analyze_weights, lastActive);
+               }
+
+               if(firstCreation) {
+                       hbox_combo_encoder_analyze_weights.PackStart(combo_encoder_analyze_weights, true, 
true, 0);
+                       hbox_combo_encoder_analyze_weights.ShowAll(); 
+               }
+       }
 
        void on_check_encoder_intersession_x_is_date_toggled (object o, EventArgs args) {
                createComboAnalyzeCross(false, check_encoder_intersession_x_is_date.Active);
+               
+               if(check_encoder_intersession_x_is_date.Active) {
+                       createComboEncoderAnalyzeWeights(false);
+                       combo_encoder_analyze_weights.Visible = true;
+               } else
+                       combo_encoder_analyze_weights.Visible = false;
        }       
 
 
diff --git a/src/gui/encoderSelectRepetitions.cs b/src/gui/encoderSelectRepetitions.cs
index 8521976..e1f11c5 100644
--- a/src/gui/encoderSelectRepetitions.cs
+++ b/src/gui/encoderSelectRepetitions.cs
@@ -69,7 +69,7 @@ public class EncoderSelectRepetitions
        public ArrayList EncoderCompareInter;
        public int RepsActive;
        public int RepsAll;
-       public ArrayList EncoderInterSessionDateOnXWeights;
+       public List<double> EncoderInterSessionDateOnXWeights;
 
        
        public EncoderSelectRepetitions() {
@@ -149,6 +149,15 @@ public class EncoderSelectRepetitions
                        RepsAll += genericWin.GetCell(id, allRepsColumn);
                }
        }
+       
+       public ArrayList GetEncoderInterSessionDateOnXWeightsForCombo() {
+               ArrayList a = new ArrayList();
+               a.Add(Catalog.GetString("All weights"));
+               foreach(double d in EncoderInterSessionDateOnXWeights)
+                       a.Add(d.ToString());
+
+               return a;
+       }
 }
 
 public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRepetitions
@@ -485,7 +494,7 @@ public class EncoderSelectRepetitionsIndividualAllSessions : EncoderSelectRepeti
                
        private void updateEncoderInterSessionDateOnXWeights() 
        {
-               EncoderInterSessionDateOnXWeights = new ArrayList();
+               EncoderInterSessionDateOnXWeights = new List<double>();
                
                string [] selectedID = genericWin.GetColumn(0,true); //only active
                string [] selectedRepsByWeights = genericWin.GetColumn(repsByWeightsColumn,true); //only 
active
@@ -496,7 +505,7 @@ public class EncoderSelectRepetitionsIndividualAllSessions : EncoderSelectRepeti
                        foreach(string repByWeight in repsByWeights) {
                                string [] chunks = repByWeight.Split(new char[] {'*'});
                                if(Util.IsNumber(chunks[1], true))
-                                       EncoderInterSessionDateOnXWeights = Util.AddToArrayListIfNotExist(
+                                       EncoderInterSessionDateOnXWeights = Util.AddToListDoubleIfNotExist(
                                                        EncoderInterSessionDateOnXWeights, 
Convert.ToDouble(chunks[1]));
                        }
                }
diff --git a/src/util.cs b/src/util.cs
index e064326..89ab698 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1384,6 +1384,14 @@ public class Util
 
                return myArrayList;
        }
+       
+       public static List<double> AddToListDoubleIfNotExist(List<double> l, double d) {
+               bool found = FoundInListDouble(l, d);
+               if(!found)
+                       l.Add(d);
+       
+               return l;
+       }
 
        public static bool FoundInArrayList(ArrayList a, string str) {
                foreach (string str2 in a)
@@ -1417,6 +1425,14 @@ public class Util
                return false;
        }
 
+       public static bool FoundInListDouble(List<double>l, double d) {
+               foreach (double d2 in l)
+                       if(d2 == d)
+                               return true;
+
+               return false;
+       }
+
        public static ArrayList RemoveLastArrayElement(ArrayList a) {
                if(a.Count > 0)
                        a.RemoveAt(a.Count - 1);


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