[chronojump] 4 analyze modes and code reorganization (85%. Read TODOs)



commit 676aaa1884289cb0478c46b0f4f4e208192d9e09
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 11 18:17:44 2016 +0200

    4 analyze modes and code reorganization (85%. Read TODOs)

 glade/chronojump.glade              |  451 ++++++++++++++++---
 po/POTFILES.in                      |    1 +
 src/Makefile.am                     |    7 +-
 src/constants.cs                    |    6 +-
 src/gui/chronojump.cs               |   12 +-
 src/gui/encoder.cs                  |  846 +++++++++++------------------------
 src/gui/encoderSelectRepetitions.cs |  618 +++++++++++++++++++++++++
 src/gui/encoderTreeviews.cs         |   30 +-
 src/gui/genericWindow.cs            |   51 ++-
 src/session.cs                      |    8 +
 src/sqlite/encoder.cs               |   14 +-
 src/utilEncoder.cs                  |   27 ++
 12 files changed, 1375 insertions(+), 696 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 8b0b3c3..3cc8eae 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -14363,50 +14363,106 @@ on current Chronojump version.</property>
                                                             <property name="height_request">30</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">12</property>
+                                                            <property name="spacing">20</property>
                                                             <child>
-                                                            <widget class="GtkCheckButton" 
id="check_encoder_analyze_signal_or_curves">
+                                                            <widget class="GtkHBox" id="hbox56">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">8</property>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="radio_encoder_analyze_individual_current_set">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
+                                                            <property name="tooltip" 
translatable="yes">Individual / current set</property>
                                                             <property name="active">True</property>
                                                             <property name="draw_indicator">False</property>
-                                                            <signal name="toggled" 
handler="on_check_encoder_analyze_signal_or_curves_toggled" swapped="no"/>
+                                                            <signal name="toggled" 
handler="on_radio_encoder_analyze_individual_current_set_toggled" swapped="no"/>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox72">
+                                                            <widget class="GtkImage" 
id="image_encoder_analyze_individual_current_set">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">4</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
                                                             <child>
-                                                            <widget class="GtkImage" 
id="image_encoder_analyze_current_signal">
-                                                            <property name="width_request">32</property>
-                                                            <property name="height_request">16</property>
+                                                            <widget class="GtkRadioButton" 
id="radio_encoder_analyze_individual_current_session">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="tooltip" 
translatable="yes">Individual / current session</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">False</property>
+                                                            <property 
name="group">radio_encoder_analyze_individual_current_set</property>
+                                                            <signal name="toggled" 
handler="on_radio_encoder_analyze_individual_current_session_toggled" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_encoder_analyze_individual_current_session">
                                                             <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">0</property>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkImage" 
id="image_encoder_analyze_saved_curves">
-                                                            <property name="width_request">32</property>
-                                                            <property name="height_request">16</property>
+                                                            <widget class="GtkRadioButton" 
id="radio_encoder_analyze_individual_all_sessions">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="tooltip" 
translatable="yes">Individual / all sessions</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">False</property>
+                                                            <property 
name="group">radio_encoder_analyze_individual_current_set</property>
+                                                            <signal name="toggled" 
handler="on_radio_encoder_analyze_individual_all_sessions_toggled" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_encoder_analyze_individual_all_sessions">
+                                                            <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">1</property>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="radio_encoder_analyze_groupal_current_session">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="tooltip" 
translatable="yes">Groupal / current set</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">False</property>
+                                                            <property 
name="group">radio_encoder_analyze_individual_current_set</property>
+                                                            <signal name="toggled" 
handler="on_radio_encoder_analyze_groupal_current_session_toggled" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_encoder_analyze_groupal_current_session">
+                                                            <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">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">3</property>
+                                                            </packing>
                                                             </child>
                                                             </widget>
                                                             <packing>
@@ -14419,7 +14475,7 @@ on current Chronojump version.</property>
                                                             <widget class="GtkHBox" 
id="hbox_encoder_analyze_current_signal">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">6</property>
+                                                            <property name="spacing">4</property>
                                                             <child>
                                                             <widget class="GtkLabel" 
id="label_encoder_analyze_current_signal">
                                                             <property name="visible">True</property>
@@ -14465,9 +14521,11 @@ on current Chronojump version.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_encoder_analyze_saved_curves">
+                                                            <widget class="GtkHBox" 
id="hbox_combo_encoder_exercise_analyze">
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Saved 
repetitions</property>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -14478,7 +14536,19 @@ on current Chronojump version.</property>
                                                             <child>
                                                             <widget class="GtkHBox" 
id="hbox_encoder_user_curves">
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">6</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="label_encoder_analyze_saved_curves">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Repetitions</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
                                                             <child>
                                                             <widget class="GtkHBox" 
id="hbox_encoder_user_curves_num">
                                                             <property name="visible">True</property>
@@ -14552,7 +14622,7 @@ on current Chronojump version.</property>
                                                             <packing>
                                                             <property name="expand">True</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">0</property>
+                                                            <property name="position">1</property>
                                                             </packing>
                                                             </child>
                                                             <child>
@@ -14565,38 +14635,10 @@ on current Chronojump version.</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkHBox" 
id="hbox_encoder_analyze_data_compare">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">6</property>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
                                                             <property name="fill">True</property>
                                                             <property name="position">2</property>
                                                             </packing>
                                                             </child>
-                                                            <child>
-                                                            <widget class="GtkButton" 
id="button_encoder_analyze_data_compare">
-                                                            <property name="label" 
translatable="yes">Compare to</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">True</property>
-                                                            <signal name="clicked" 
handler="on_button_encoder_analyze_data_compare_clicked" swapped="no"/>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">3</property>
-                                                            </packing>
-                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -14604,9 +14646,6 @@ on current Chronojump version.</property>
                                                             <property name="position">3</property>
                                                             </packing>
                                                             </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
                                                           </widget>
                                                           <packing>
                                                             <property name="left_attach">1</property>
@@ -15220,7 +15259,7 @@ on current Chronojump version.</property>
                                                             <property name="can_focus">False</property>
                                                             <child>
                                                             <widget class="GtkCheckButton" 
id="checkbutton_crossvalidate">
-                                                            <property name="label">crossvalidate</property>
+                                                            <property name="label">cv</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
@@ -16267,6 +16306,21 @@ on current Chronojump version.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -20896,6 +20950,21 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22006,6 +22075,21 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23608,6 +23692,21 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -24267,6 +24366,21 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -36895,6 +37009,96 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -39298,6 +39502,66 @@ 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>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -40601,21 +40865,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>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -41725,6 +41974,21 @@ 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>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -45721,6 +45985,21 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -46495,6 +46774,21 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -47284,6 +47578,21 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4c52538..bf3bbe1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -28,6 +28,7 @@ src/gui/convertWeight.cs
 src/gui/encoder.cs
 src/gui/encoderConfiguration.cs
 src/gui/encoderTreeviews.cs
+src/gui/encoderSelectRepetitions.cs
 src/gui/error.cs
 src/gui/evaluator.cs
 src/gui/event.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index d1956ea..0ac46a9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ SOURCES = \
        gui/encoder.cs\
        gui/encoderTreeviews.cs\
        gui/encoderConfiguration.cs\
+       gui/encoderSelectRepetitions.cs\
        gui/error.cs\
        gui/eventExecute.cs\
        gui/eventGraphConfigure.cs\
@@ -307,8 +308,10 @@ RESOURCES = \
        ../images/calendar.png,calendar.png \
        ../images/chronojump-logo-2013_320.png,chronojump-logo-2013_320.png \
        ../images/chronojump-logo-2013.png,chronojump-logo-2013.png \
-       ../images/encoder-analyze-current-signal.png,encoder-analyze-current-signal.png \
-       ../images/encoder-analyze-saved-curves.png,encoder-analyze-saved-curves.png \
+       ../images/encoder-analyze-individual-current-set.png,encoder-analyze-individual-current-set.png \
+       
../images/encoder-analyze-individual-current-session.png,encoder-analyze-individual-current-session.png \
+       ../images/encoder-analyze-individual-all-sessions.png,encoder-analyze-individual-all-sessions.png \
+       ../images/encoder-analyze-groupal-current-session.png,encoder-analyze-groupal-current-session.png \
        ../images/encoder-analyze-powerbars.png,encoder-analyze-powerbars.png \
        ../images/encoder-analyze-cross.png,encoder-analyze-cross.png \
        ../images/encoder-analyze-1RM.png,encoder-analyze-1RM.png \
diff --git a/src/constants.cs b/src/constants.cs
index 80f94d6..e7445c5 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -408,8 +408,10 @@ public class Constants
        public static string FileNameContactPlatformModular = "modular_platform_with_chronopic.jpg";
        public static string FileNameInfrared = "infrared.jpg";
        
-       public static string FileNameEncoderAnalyzeCurrentSignalIcon = "encoder-analyze-current-signal.png";
-       public static string FileNameEncoderAnalyzeSavedCurvesIcon = "encoder-analyze-saved-curves.png";
+       public static string FileNameEncoderAnalyzeIndividualCurrentSetIcon = 
"encoder-analyze-individual-current-set.png";
+       public static string FileNameEncoderAnalyzeIndividualCurrentSessionIcon = 
"encoder-analyze-individual-current-session.png";
+       public static string FileNameEncoderAnalyzeIndividualAllSessionsIcon = 
"encoder-analyze-individual-all-sessions.png";
+       public static string FileNameEncoderAnalyzeGroupalCurrentSessionIcon = 
"encoder-analyze-groupal-current-session.png";
 
        public static string FileNameEncoderAnalyzePowerbarsIcon = "encoder-analyze-powerbars.png";
        public static string FileNameEncoderAnalyzeCrossIcon = "encoder-analyze-cross.png";
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7596112..d969771 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -799,10 +799,14 @@ public partial class ChronoJumpWindow
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "spreadsheet.png");
                image_encoder_analyze_table_save.Pixbuf = pixbuf;
                
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeCurrentSignalIcon);
-               image_encoder_analyze_current_signal.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSavedCurvesIcon);
-               image_encoder_analyze_saved_curves.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualCurrentSetIcon);
+               image_encoder_analyze_individual_current_set.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualCurrentSessionIcon);
+               image_encoder_analyze_individual_current_session.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualAllSessionsIcon);
+               image_encoder_analyze_individual_all_sessions.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeGroupalCurrentSessionIcon);
+               image_encoder_analyze_groupal_current_session.Pixbuf = pixbuf;
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzePowerbarsIcon);
                image_encoder_analyze_powerbars.Pixbuf = pixbuf;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c2ee144..1c50db0 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -20,7 +20,6 @@
 
 using System;
 using System.IO; 
-//using System.IO.Ports;
 using Gtk;
 using Gdk;
 using Glade;
@@ -72,9 +71,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_encoder_capture;
        [Widget] Gtk.Image image_encoder_capture_open;
        [Widget] Gtk.ProgressBar encoder_pulsebar_capture;
-       //[Widget] Gtk.Entry entry_encoder_signal_comment;
-       //[Widget] Gtk.Entry entry_encoder_curve_comment;
-       //[Widget] Gtk.Button button_encoder_save_curve;
        [Widget] Gtk.Box vbox_encoder_signal_comment;
        [Widget] Gtk.TextView textview_encoder_signal_comment;
        [Widget] Gtk.Button button_encoder_signal_save_comment;
@@ -109,6 +105,9 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Box hbox_combo_encoder_laterality;
        [Widget] Gtk.ComboBox combo_encoder_laterality;
        [Widget] Gtk.Box hbox_encoder_capture_curves_save_all_none;
+       
+       [Widget] Gtk.Box hbox_combo_encoder_exercise_analyze;
+       [Widget] Gtk.ComboBox combo_encoder_exercise_analyze;
 
        [Widget] Gtk.Box hbox_combo_encoder_analyze_cross;
        [Widget] Gtk.ComboBox combo_encoder_analyze_cross;
@@ -133,9 +132,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Box hbox_encoder_user_curves;
        [Widget] Gtk.Label label_encoder_user_curves_active_num;
        [Widget] Gtk.Label label_encoder_user_curves_all_num;
-       [Widget] Gtk.Box hbox_encoder_analyze_data_compare;
-       [Widget] Gtk.ComboBox combo_encoder_analyze_data_compare;
-       [Widget] Gtk.Button button_encoder_analyze_data_compare;
 
        [Widget] Gtk.Table table_encoder_analyze_instant;
        [Widget] Gtk.HScale hscale_encoder_analyze_a;
@@ -179,11 +175,17 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_encoder_analyze_table_save;
        [Widget] Gtk.Button button_encoder_analyze_1RM_save;
 
-       [Widget] Gtk.CheckButton check_encoder_analyze_signal_or_curves;
-       [Widget] Gtk.Image image_encoder_analyze_current_signal;
-       [Widget] Gtk.Image image_encoder_analyze_saved_curves;
+       [Widget] Gtk.RadioButton radio_encoder_analyze_individual_current_set;
+       [Widget] Gtk.RadioButton radio_encoder_analyze_individual_current_session;
+       [Widget] Gtk.RadioButton radio_encoder_analyze_individual_all_sessions;
+       [Widget] Gtk.RadioButton radio_encoder_analyze_groupal_current_session;
+
+       [Widget] Gtk.Image image_encoder_analyze_individual_current_set;
+       [Widget] Gtk.Image image_encoder_analyze_individual_current_session;
+       [Widget] Gtk.Image image_encoder_analyze_individual_all_sessions;
+       [Widget] Gtk.Image image_encoder_analyze_groupal_current_session;
+
        [Widget] Gtk.HBox hbox_encoder_analyze_current_signal;
-       [Widget] Gtk.Label label_encoder_analyze_saved_curves;
        
        [Widget] Gtk.RadioButton radiobutton_encoder_analyze_powerbars;
        [Widget] Gtk.RadioButton radiobutton_encoder_analyze_cross;
@@ -260,9 +262,6 @@ public partial class ChronoJumpWindow
 
        private ArrayList array1RM;
 
-       private ArrayList encoderCompareInterperson;    //personID:personName
-       private ArrayList encoderCompareIntersession;   //sessionID:sessionDate
-
        //private static double [] encoderReaded;               //data coming from encoder and converted (can 
be double)
        //private static int [] encoderReaded;          //data coming from encoder and converted
        //private static int encoderCaptureCountdown;
@@ -324,7 +323,7 @@ public partial class ChronoJumpWindow
         */
 
        enum encoderSensEnum { 
-               NOSESSION, NOPERSON, YESPERSON, PROCESSINGCAPTURE, PROCESSINGR, DONENOSIGNAL, DONEYESSIGNAL, 
SELECTEDCURVE }
+               NOSESSION, NOPERSON, YESPERSON, PROCESSINGCAPTURE, PROCESSINGR, DONENOSIGNAL, DONEYESSIGNAL }
        encoderSensEnum encoderSensEnumStored; //tracks how was sensitive before PROCESSINGCAPTURE or 
PROCESSINGR
        
        //for writing text
@@ -413,6 +412,8 @@ public partial class ChronoJumpWindow
                configInit();
        
                array1RM = new ArrayList();
+                       
+               encSelReps = new EncoderSelectRepetitions();
        }
 
 
@@ -619,6 +620,10 @@ public partial class ChronoJumpWindow
                        encoder_change_displaced_weight_and_1RM ();
                }
        }
+       
+       void on_combo_encoder_exercise_analyze_changed (object o, EventArgs args) {
+               prepareAnalyzeRepetitions ();
+       }
 
        // ---- change extra weight start ----
        /*
@@ -973,192 +978,62 @@ public partial class ChronoJumpWindow
        }
        
 
-       void on_button_encoder_analyze_data_select_curves_clicked (object o, EventArgs args) 
-       {
-               ArrayList data = SqliteEncoder.Select(
-                               false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
-                               "curve", EncoderSQL.Eccons.ALL, 
-                               false, true);
-
-               ArrayList dataPrint = new ArrayList();
-               string [] checkboxes = new string[data.Count]; //to store active or inactive status of curves
-               int count = 0;
-               foreach(EncoderSQL es in data) {
-                       checkboxes[count++] = es.status;
-                       //LogB.Information(checkboxes[count-1]);
-                       dataPrint.Add(es.ToStringArray(count,true,false,true,true));
-               }
-       
-               string [] columnsString = {
-                       Catalog.GetString("ID"),
-                       Catalog.GetString("Active"),    //checkboxes
-                       Catalog.GetString("Repetition"),
-                       Catalog.GetString("Exercise"),
-                       "RL",
-                       Catalog.GetString("Extra weight"),
-                       Catalog.GetString("Mean Power"),
-                       Catalog.GetString("Encoder"),
-                       Catalog.GetString("Contraction"),
-                       Catalog.GetString("Date"),
-                       Catalog.GetString("Comment")
-               };
-
-               ArrayList bigArray = new ArrayList();
-               ArrayList a1 = new ArrayList();
-               ArrayList a2 = new ArrayList();
-               ArrayList a3 = new ArrayList();
-               
-               //0 is the widgget to show; 1 is the editable; 2 id default value
-               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
-               bigArray.Add(a1);
-               
-               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
-               bigArray.Add(a2);
-       
-               a3.Add(Constants.GenericWindowShow.COMBO); a3.Add(true); a3.Add("");
-               bigArray.Add(a3);
-       
-               //add exercises to the combo (only the exercises done, and only unique)
-               ArrayList encoderExercisesNames = new ArrayList();
-               foreach(EncoderSQL es in data) {
-                       encoderExercisesNames = Util.AddToArrayListIfNotExist(encoderExercisesNames, 
Catalog.GetString(es.exerciseName));
-               }
-               
-               genericWin = GenericWindow.Show(false,  //don't show now
-                               string.Format(Catalog.GetString("Saved repetitions of athlete {0} on this 
session."), 
-                                       currentPerson.Name) + "\n" + 
-                               Catalog.GetString("Activate the repetitions you want to use clicking on first 
column.") + "\n" +
-                               Catalog.GetString("If you want to edit or delete a row, right click on it.") 
+ "\n",
-                               bigArray);
-
-               genericWin.SetTreeview(columnsString, true, dataPrint, new ArrayList(), 
Constants.ContextMenu.EDITDELETE, false);
-               genericWin.AddOptionsToComboCheckBoxesOptions(encoderExercisesNames);
-               genericWin.CreateComboCheckBoxes();
-               genericWin.MarkActiveCurves(checkboxes);
-               
-               //find all persons in current session
-               ArrayList personsPre = SqlitePersonSession.SelectCurrentSessionPersons(
-                               currentSession.UniqueID,
-                               false); //means: do not returnPersonAndPSlist
-               
-               string [] persons = new String[personsPre.Count];
-               count = 0;
-               foreach (Person p in personsPre)
-                       persons[count++] = p.UniqueID.ToString() + ":" + p.Name;
-               genericWin.SetComboValues(persons, currentPerson.UniqueID + ":" + currentPerson.Name);
-               genericWin.SetComboLabel(Catalog.GetString("Change the owner of selected repetition") + 
-                               " (" + Catalog.GetString("code") + ":" + Catalog.GetString("name") + ")");
-               genericWin.ShowEditRow(false);
-               genericWin.CommentColumn = 10;
-               
-               genericWin.ShowButtonCancel(false);
-               genericWin.SetButtonAcceptSensitive(true);
-               genericWin.SetButtonCancelLabel(Catalog.GetString("Close"));
-               //manage selected, unselected curves
-               genericWin.Button_accept.Clicked += new EventHandler(on_encoder_show_curves_done);
-               genericWin.Button_row_edit.Clicked += new EventHandler(on_encoder_show_curves_row_edit);
-               genericWin.Button_row_edit_apply.Clicked += new 
EventHandler(on_encoder_show_curves_row_edit_apply);
-               genericWin.Button_row_delete.Clicked += new 
EventHandler(on_encoder_show_curves_row_delete_pre);
-
-               //used when we don't need to read data, 
-               //and we want to ensure next window will be created at needed size
-               //genericWin.DestroyOnAccept=true;
-               //here is comented because we are going to read the checkboxes
+       private EncoderSelectRepetitions encSelReps;
 
-               genericWin.ShowNow();
+       void on_button_encoder_analyze_data_select_curves_clicked (object o, EventArgs args) {
+               encSelReps.FakeButtonDone.Clicked += new EventHandler(on_analyze_repetitions_selected);
+               encSelReps.Show();
        }
        
-       protected void on_encoder_show_curves_done (object o, EventArgs args)
-       {
-               genericWin.Button_accept.Clicked -= new EventHandler(on_encoder_show_curves_done);
-
-               //get selected/deselected rows
-               string [] checkboxes = genericWin.GetCheckboxesStatus(1, false);
-
-               ArrayList data = SqliteEncoder.Select(
-                               false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
-                               "curve", EncoderSQL.Eccons.ALL, 
-                               false, true);
-
-               //update on database the curves that have been selected/deselected
-               //doing it as a transaction: FAST
-               int countActive = SqliteEncoder.UpdateTransaction(data, checkboxes);
-
-               int activeCurvesNum = getActiveCurvesNum(data);
-               label_encoder_user_curves_active_num.Text = activeCurvesNum.ToString();
-
-               string [] activeCurvesList = getActiveCheckboxesList(checkboxes, activeCurvesNum);
-               activeCurvesList = Util.AddArrayString(activeCurvesList, Catalog.GetString("All"), true); 
//Add "All" first
-               UtilGtk.ComboUpdate(combo_encoder_analyze_curve_num_combo, activeCurvesList, "");
-               combo_encoder_analyze_curve_num_combo.Active = 
-                       UtilGtk.ComboMakeActive(combo_encoder_analyze_curve_num_combo, activeCurvesList[1]);
+       void on_analyze_repetitions_selected (object o, EventArgs args) {
+               LogB.Information("on_analyze_repetitions_selected");
+               encSelReps.FakeButtonDone.Clicked -= new EventHandler(on_analyze_repetitions_selected);
 
-               genericWin.HideAndNull();
-               
-               //encoderButtonsSensitive(encoderSensEnumStored);
-               button_encoder_analyze.Sensitive = (countActive > 0);
+               label_encoder_user_curves_active_num.Text = encSelReps.RepsActive.ToString();
+               label_encoder_user_curves_all_num.Text = encSelReps.RepsAll.ToString();
        }
        
-       protected void on_encoder_show_curves_row_edit (object o, EventArgs args) {
-               LogB.Information("row edit at show curves");
-               LogB.Information(genericWin.TreeviewSelectedUniqueID.ToString());
-               genericWin.ShowEditRow(true);
-       }
-
-       protected void on_encoder_show_curves_row_edit_apply (object o, EventArgs args) {
-               LogB.Information("row edit apply at show curves");
-
-               int curveID = genericWin.TreeviewSelectedUniqueID;
-               EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
-                               false, curveID, 0, 0, -1,
-                               "", EncoderSQL.Eccons.ALL, 
-                               false, true)[0];
-
-               //if changed comment, update SQL, and update treeview
-               //first remove conflictive characters
-               string comment = Util.RemoveTildeAndColonAndDot(genericWin.EntryEditRow);
-               if(comment != eSQL.description) {
-                       eSQL.description = comment;
-                       SqliteEncoder.Update(false, eSQL);
+       //called on changing radio mode (! show), and on clicking button_encoder_analyze_data_select_curves 
(show)
+       //not called on current_set
+       void prepareAnalyzeRepetitions () 
+       {
+               if(radio_encoder_analyze_individual_current_session.Active) 
+               {
+                       if(encSelReps == null || encSelReps.Type != 
EncoderSelectRepetitions.Types.INDIVIDUAL_CURRENT_SESSION)
+                               encSelReps = new EncoderSelectRepetitionsIndividualCurrentSession();
 
-                       //update treeview
-                       genericWin.on_edit_selected_done_update_treeview();
+                       encSelReps.FakeButtonDeleteCurve.Clicked += new EventHandler(on_delete_encoder_curve);
                }
-
-               //if changed person, proceed
-               LogB.Information("new person: " + genericWin.GetComboSelected);
-               int newPersonID = Util.FetchID(genericWin.GetComboSelected);
-               if(newPersonID != currentPerson.UniqueID) {
-                       EncoderSQL eSQLChangedPerson = eSQL.ChangePerson(genericWin.GetComboSelected);
-                       SqliteEncoder.Update(false, eSQLChangedPerson);
-
-                       genericWin.RemoveSelectedRow();
+               else if(radio_encoder_analyze_individual_all_sessions.Active)
+               {
+                       if(encSelReps == null || encSelReps.Type != 
EncoderSelectRepetitions.Types.INDIVIDUAL_ALL_SESSIONS)
+                               encSelReps = new EncoderSelectRepetitionsIndividualAllSessions();
                }
+               else if(radio_encoder_analyze_groupal_current_session.Active)
+               {
+                       if(encSelReps == null || encSelReps.Type != 
EncoderSelectRepetitions.Types.GROUPAL_CURRENT_SESSION)
+                               encSelReps = new EncoderSelectRepetitionsGroupalCurrentSession();
+               }
+               else
+                       return; //error
 
-               genericWin.ShowEditRow(false);
-               updateUserCurvesLabelsAndCombo(false);
-       }
-       
-       protected void on_encoder_show_curves_row_delete_pre (object o, EventArgs args) {
-               if(preferences.askDeletion) {
-                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString(
-                                               "Are you sure you want to delete this repetition?"), "", "");
-                       confirmWin.Button_accept.Clicked += new 
EventHandler(on_encoder_show_curves_row_delete);
-               } else
-                       on_encoder_show_curves_row_delete (o, args);
-       }
-       
-       protected void on_encoder_show_curves_row_delete (object o, EventArgs args) {
-               LogB.Information("row delete at show curves");
-
-               int uniqueID = genericWin.TreeviewSelectedUniqueID;
+               encSelReps.PassVariables(currentPerson, currentSession, 
+                               genericWin, button_encoder_analyze, getExerciseIDFromComboAnalyze(),
+                               preferences.askDeletion);
 
-               delete_encoder_curve(false, uniqueID);
+               genericWin = encSelReps.Do();
 
-               genericWin.Delete_row_accepted();
+               label_encoder_user_curves_active_num.Text = encSelReps.RepsActive.ToString();
+               label_encoder_user_curves_all_num.Text = encSelReps.RepsAll.ToString();
        }
-
-       void delete_encoder_curve(bool dbconOpened, int uniqueID) {
+                       
+       void on_delete_encoder_curve (object o, EventArgs args)
+       {
+               encSelReps.FakeButtonDeleteCurve.Clicked -= new EventHandler(on_delete_encoder_curve);
+               delete_encoder_curve(false, encSelReps.DeleteCurveID);
+       }       
+       void delete_encoder_curve(bool dbconOpened, int uniqueID) 
+       {
                LogB.Information(uniqueID.ToString());
                bool eSQLfound = true;
 
@@ -1193,217 +1068,9 @@ public partial class ChronoJumpWindow
                                encoderCaptureSelectBySavedCurves(esc.msCentral, false);
                }
 
+               //TODO: change encSelReps and this will change labels
                updateUserCurvesLabelsAndCombo(dbconOpened);
        }
-       
-       
-       void on_button_encoder_analyze_data_compare_clicked (object o, EventArgs args) 
-       {
-               if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                       encoderDataCompareTranslation) == "Between persons")
-                       encoder_analyze_data_compare_interperson();
-               else if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                       encoderDataCompareTranslation) == "Between sessions")
-                       encoder_analyze_data_compare_intersession();
-       }
-
-       void encoder_analyze_data_compare_interperson () 
-       {
-               //find all persons except current person
-               ArrayList dataPre = SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID,
-                               false); //means: do not returnPersonAndPSlist
-
-               ArrayList data = new ArrayList();
-               ArrayList nonSensitiveRows = new ArrayList();
-               int i = 0;      //list of persons
-               int j = 0;      //list of added persons
-               foreach(Person p in dataPre) {
-                       if(p.UniqueID != currentPerson.UniqueID) {
-                               ArrayList eSQLarray = SqliteEncoder.Select(
-                                               false, -1, p.UniqueID, currentSession.UniqueID, -1, 
-                                               "curve", EncoderSQL.Eccons.ALL, 
-                                               false, true);
-                               string [] s = { p.UniqueID.ToString(), "", p.Name,
-                                       getActiveCurvesNum(eSQLarray).ToString(), eSQLarray.Count.ToString()
-                               };
-                               data.Add(s);
-                               if(getActiveCurvesNum(eSQLarray) == 0)
-                                       nonSensitiveRows.Add(j);
-                               j++;
-                       }
-                       i ++;
-               }
-       
-               //prepare checkboxes to be marked       
-               string [] checkboxes = new string[data.Count]; //to store active or inactive status
-               int count = 0;
-               foreach(string [] sPersons in data) {
-                       bool found = false;
-                       foreach(string s2 in encoderCompareInterperson)
-                               if(Util.FetchID(s2).ToString() == sPersons[0])
-                                       found = true;
-
-                       if(found)
-                               checkboxes[count++] = "active";
-                       else
-                               checkboxes[count++] = "inactive";
-               }                       
-                       
-               string [] columnsString = {
-                       Catalog.GetString("ID"),
-                       "",                             //checkboxes
-                       Catalog.GetString("Person name"),
-                       Catalog.GetString("Selected\nrepetitions"),
-                       Catalog.GetString("All\nrepetitions")
-               };
-
-               ArrayList bigArray = new ArrayList();
-               ArrayList a1 = new ArrayList();
-               ArrayList a2 = new ArrayList();
-               
-               //0 is the widgget to show; 1 is the editable; 2 id default value
-               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
-               bigArray.Add(a1);
-               
-               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
-               bigArray.Add(a2);
-               
-               genericWin = GenericWindow.Show(false,  //don't show now
-                               string.Format(Catalog.GetString("Select persons to compare to {0}."), 
-                                       currentPerson.Name), bigArray);
-
-               genericWin.SetTreeview(columnsString, true, data, nonSensitiveRows, 
Constants.ContextMenu.NONE, false);
-               genericWin.CreateComboCheckBoxes();
-               genericWin.MarkActiveCurves(checkboxes);
-               genericWin.ShowButtonCancel(false);
-               genericWin.SetButtonAcceptSensitive(true);
-               //manage selected, unselected curves
-               genericWin.Button_accept.Clicked += new EventHandler(
-                               on_encoder_analyze_data_compare_interperson_done);
-
-               //used when we don't need to read data, 
-               //and we want to ensure next window will be created at needed size
-               //genericWin.DestroyOnAccept=true;
-               //here is comented because we are going to read the checkboxes
-
-               genericWin.ShowNow();
-       }
-
-       void on_encoder_analyze_data_compare_interperson_done (object o, EventArgs args) {
-               genericWin.Button_accept.Clicked -= new EventHandler(
-                               on_encoder_analyze_data_compare_interperson_done);
-       
-               encoderCompareInterperson = new ArrayList ();
-               string [] selectedID = genericWin.GetCheckboxesStatus(0,true);
-               string [] selectedName = genericWin.GetCheckboxesStatus(2,true);
-
-               for (int i=0 ; i < selectedID.Length ; i ++)
-                       encoderCompareInterperson.Add(Convert.ToInt32(selectedID[i]) + ":" + selectedName[i]);
-
-               genericWin.HideAndNull();
-               
-               LogB.Information("done");
-       }
-       
-       void encoder_analyze_data_compare_intersession () 
-       {
-               //select all curves of this person on all sessions
-               ArrayList dataPre = SqliteEncoder.SelectCompareIntersession(
-                               false, currentPerson.UniqueID); 
-               
-               //..except on current session
-               ArrayList data = new ArrayList();
-               foreach(EncoderPersonCurvesInDB encPS in dataPre)
-                       if(encPS.sessionID != currentSession.UniqueID)
-                               data.Add(encPS);
-       
-               //prepare unsensitive rows      
-               ArrayList nonSensitiveRows = new ArrayList();
-               int count = 0;
-               foreach(EncoderPersonCurvesInDB encPS in data) {
-                       if(encPS.countActive == 0)
-                               nonSensitiveRows.Add(count);
-                       count ++;
-               }
-               
-               //prepare checkboxes to be marked       
-               string [] checkboxes = new string[data.Count]; //to store active or inactive status
-               count = 0;
-               foreach(EncoderPersonCurvesInDB encPS in data) {
-                       bool found = false;
-                       foreach(string s2 in encoderCompareIntersession)
-                               if(Util.FetchID(s2) == encPS.sessionID)
-                                       found = true;
-
-                       if(found)
-                               checkboxes[count++] = "active";
-                       else
-                               checkboxes[count++] = "inactive";
-               }                       
-                       
-               string [] columnsString = {
-                       Catalog.GetString("ID"),
-                       "",                             //checkboxes
-                       Catalog.GetString("Session name"),
-                       Catalog.GetString("Session date"),
-                       Catalog.GetString("Selected\nrepetitions"),
-                       Catalog.GetString("All\nrepetitions")
-               };
-
-               ArrayList bigArray = new ArrayList();
-               ArrayList a1 = new ArrayList();
-               ArrayList a2 = new ArrayList();
-               
-               //0 is the widgget to show; 1 is the editable; 2 id default value
-               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
-               bigArray.Add(a1);
-               
-               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
-               bigArray.Add(a2);
-               
-               genericWin = GenericWindow.Show(false,  //don't show now
-                               string.Format(Catalog.GetString("Compare repetitions of {0} from this session 
with the following sessions."), 
-                                       currentPerson.Name), bigArray);
-
-               //convert data from array of EncoderPersonCurvesInDB to array of strings []
-               ArrayList dataConverted = new ArrayList();
-               foreach(EncoderPersonCurvesInDB encPS in data) {
-                       dataConverted.Add(encPS.ToStringArray());
-               }
-
-               genericWin.SetTreeview(columnsString, true, dataConverted, nonSensitiveRows, 
Constants.ContextMenu.NONE, false);
-               genericWin.CreateComboCheckBoxes();
-               genericWin.MarkActiveCurves(checkboxes);
-               genericWin.ShowButtonCancel(false);
-               genericWin.SetButtonAcceptSensitive(true);
-               //manage selected, unselected curves
-               genericWin.Button_accept.Clicked += new EventHandler(
-                               on_encoder_analyze_data_compare_intersession_done);
-
-               //used when we don't need to read data, 
-               //and we want to ensure next window will be created at needed size
-               //genericWin.DestroyOnAccept=true;
-               //here is comented because we are going to read the checkboxes
-
-               genericWin.ShowNow();
-       }
-
-       void on_encoder_analyze_data_compare_intersession_done (object o, EventArgs args) {
-               genericWin.Button_accept.Clicked -= new EventHandler(
-                               on_encoder_analyze_data_compare_intersession_done);
-       
-               encoderCompareIntersession = new ArrayList ();
-               string [] selectedID = genericWin.GetCheckboxesStatus(0,true);
-               string [] selectedDate = genericWin.GetCheckboxesStatus(3,true);
-
-               for (int i=0 ; i < selectedID.Length ; i ++)
-                       encoderCompareIntersession.Add(Convert.ToInt32(selectedID[i]) + ":" + 
selectedDate[i]);
-
-               genericWin.HideAndNull();
-               
-               LogB.Information("done");
-       }
-       
 
        void on_button_encoder_load_signal_clicked (object o, EventArgs args) 
        {
@@ -1531,7 +1198,7 @@ public partial class ChronoJumpWindow
                        //force a recalculate but not save the curve (we are loading)
                        encoderCalculeCurves(encoderActions.LOAD);
                
-                       check_encoder_analyze_signal_or_curves.Active = true;
+                       radio_encoder_analyze_individual_current_set.Active = true;
 
                        encoderButtonsSensitive(encoderSensEnumStored);
                }
@@ -1937,46 +1604,29 @@ public partial class ChronoJumpWindow
        }
 
 
-       private int getActiveCurvesNum(ArrayList curvesArray) {
-               int countActiveCurves = 0;
-               foreach(EncoderSQL es in curvesArray) 
-                       if(es.status == "active")
-                               countActiveCurves ++;
-               
-               return countActiveCurves;
-       }
-
        private void updateUserCurvesLabelsAndCombo(bool dbconOpened) 
        {
-               ArrayList data = SqliteEncoder.Select(
-                               dbconOpened, -1, currentPerson.UniqueID, currentSession.UniqueID, -1, 
-                               "curve", EncoderSQL.Eccons.ALL, 
-                               false, true);
-               int activeCurvesNum = getActiveCurvesNum(data);
+               /* TODO
+               ArrayList data;
+               if(radio_encoder_analyze_individual_current_session.Active)
+                       data = SqliteEncoder.Select(
+                                       dbconOpened, -1, currentPerson.UniqueID, currentSession.UniqueID, -1, 
+                                       "curve", EncoderSQL.Eccons.ALL, 
+                                       false, true);
+               //else
+               //      read encSelReps public variables
+
+               int activeCurvesNum = UtilEncoder.GetActiveCurvesNum(data);
                label_encoder_user_curves_active_num.Text = activeCurvesNum.ToString();
                label_encoder_user_curves_all_num.Text = data.Count.ToString();
                
-               if(check_encoder_analyze_signal_or_curves.Active)
+               if(radio_encoder_analyze_individual_current_set.Active)
                        updateComboEncoderAnalyzeCurveNumFromCurrentSet ();
                else
                        updateComboEncoderAnalyzeCurveNumSavedReps(data, activeCurvesNum);      
        
                button_encoder_analyze_sensitiveness();
-       }
-       
-       private string [] getActiveCheckboxesList(string [] checkboxes, int activeCurvesNum) {
-               if(activeCurvesNum == 0)
-                       return Util.StringToStringArray("");
-
-               string [] activeCurvesList = new String[activeCurvesNum];
-               int i=0;
-               int j=0;
-               foreach(string cb in checkboxes) {
-                       if(cb == "active")
-                               activeCurvesList[j++] = (i+1).ToString();
-                       i++;
-               }
-               return activeCurvesList;
+               */
        }
        
        private void updateComboEncoderAnalyzeCurveNumFromCurrentSet () 
@@ -2010,7 +1660,7 @@ public partial class ChronoJumpWindow
                foreach(EncoderSQL eSQL in data) {
                        checkboxes[count++] = eSQL.status;
                }
-               string [] activeCurvesList = getActiveCheckboxesList(checkboxes, activeCurvesNum);
+               string [] activeCurvesList = UtilEncoder.GetActiveCheckboxesList(checkboxes, activeCurvesNum);
                UtilGtk.ComboUpdate(combo_encoder_analyze_curve_num_combo, activeCurvesList, "");
                combo_encoder_analyze_curve_num_combo.Active = 
                        UtilGtk.ComboMakeActive(combo_encoder_analyze_curve_num_combo, activeCurvesList[0]);
@@ -2195,12 +1845,10 @@ public partial class ChronoJumpWindow
        }
 
 
-       //TODO: garantir path windows   
        private void on_button_encoder_analyze_clicked (object o, EventArgs args) 
        {
                //if userCurves and no data, return
-               //TODO: fix this, because curves should be active except in the single curve mode
-               if( ! check_encoder_analyze_signal_or_curves.Active)    //saved curves
+               if( ! radio_encoder_analyze_individual_current_set.Active)
                {
                        ArrayList data = SqliteEncoder.Select(
                                        false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1, 
@@ -2219,15 +1867,15 @@ public partial class ChronoJumpWindow
                                string nameTemp = 
Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_cross),
                                                encoderAnalyzeCrossTranslation);
 
-                               
if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                                       encoderDataCompareTranslation) != "No compare" && 
+                               if( (radio_encoder_analyze_individual_all_sessions.Active ||
+                                               radio_encoder_analyze_groupal_current_session.Active) &&
                                                (
                                                 nameTemp == "Speed,Power / Load" || 
                                                 nameTemp == Catalog.GetString("Speed,Power / Load")
                                                )) {
                                        new DialogMessage(Constants.MessageTypes.WARNING, 
                                                        Catalog.GetString("Sorry, this graph is not supported 
yet.") +
-                                                       "\n\nSaved repetitions - compare - cross variables" +
+                                                       "\n\nIntersession or Interperson - cross variables" +
                                                        "\n- Speed,Power / Load"
                                                        );
 
@@ -2241,8 +1889,8 @@ public partial class ChronoJumpWindow
                                string nameTemp = 
Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM),
                                                encoderAnalyze1RMTranslation);
 
-                               
if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                                       encoderDataCompareTranslation) != "No compare" && 
+                               if((radio_encoder_analyze_individual_all_sessions.Active ||
+                                               radio_encoder_analyze_groupal_current_session.Active) &&
                                                (
                                                 nameTemp == "1RM Any exercise" || 
                                                 nameTemp == Catalog.GetString("1RM Any exercise") ||
@@ -2252,6 +1900,7 @@ public partial class ChronoJumpWindow
                                                )) {
                                        new DialogMessage(Constants.MessageTypes.WARNING, 
                                                        Catalog.GetString("Sorry, this graph is not supported 
yet.") +
+                                                       "\n\nIntersession or Interperson" +
                                                        "\n- 1RM Any exercise" +
                                                        "\n- 1RM Bench Press"
                                                        //no 1RM Indirect because cannot be done with saved 
curves
@@ -2420,7 +2069,7 @@ public partial class ChronoJumpWindow
                if(sendAnalysis == "powerBars" || sendAnalysis == "single" || sendAnalysis == "side")
                        analysisVariables = getAnalysisVariables(sendAnalysis);
 
-               if( ! check_encoder_analyze_signal_or_curves.Active)    //saved curves
+               if( ! radio_encoder_analyze_individual_current_set.Active) //not current set
                {
                        string myEccon = "ec";
                        if(! check_encoder_analyze_eccon_together.Active)
@@ -2452,17 +2101,16 @@ public partial class ChronoJumpWindow
                                "curve", ecconSelect, 
                                false, true);
 
-                       //neuromuscularProfile cannot be inerperson or intersession
+                       //neuromuscularProfile cannot be interperson or intersession
                        if(encoderAnalysis != "neuromuscularProfile") 
                        {       
                                //if compare persons, select curves for other persons and add
-                               
if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                                       encoderDataCompareTranslation) == "Between persons") {
+                               if(radio_encoder_analyze_groupal_current_session.Active) {
                                        ArrayList dataPre = new ArrayList();
-                                       for (int i=0 ; i < encoderCompareInterperson.Count ; i ++) {
+                                       for (int i=0 ; i < encSelReps.EncoderCompareInter.Count ; i ++) {
                                                dataPre = SqliteEncoder.Select(
                                                                false, -1, 
-                                                               
Util.FetchID(encoderCompareInterperson[i].ToString()),
+                                                               
Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()),
                                                                currentSession.UniqueID, 
                                                                -1,
                                                                "curve", EncoderSQL.Eccons.ALL, 
@@ -2471,14 +2119,13 @@ public partial class ChronoJumpWindow
                                                foreach(EncoderSQL eSQL in dataPre) 
                                                        data.Add(eSQL);
                                        }
-                               } else 
if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                                       encoderDataCompareTranslation) == "Between sessions") 
{
+                               } else if(radio_encoder_analyze_individual_all_sessions.Active) {
                                        ArrayList dataPre = new ArrayList();
-                                       for (int i=0 ; i < encoderCompareIntersession.Count ; i ++) {
+                                       for (int i=0 ; i < encSelReps.EncoderCompareInter.Count ; i ++) {
                                                dataPre = SqliteEncoder.Select(
                                                                false, -1,
                                                                currentPerson.UniqueID, 
-                                                               
Util.FetchID(encoderCompareIntersession[i].ToString()),
+                                                               
Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()),
                                                                -1,
                                                                "curve", EncoderSQL.Eccons.ALL,
                                                                true, true);
@@ -2567,22 +2214,20 @@ public partial class ChronoJumpWindow
 
                                //seriesName
                                string seriesName = "";
-                               if(Util.FindOnArray(':',1,0,
-                                                       
UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                               encoderDataCompareTranslation) == "Between persons") 
+                               if(radio_encoder_analyze_groupal_current_session.Active)
                                {
-                                       foreach(string str in encoderCompareInterperson)
+                                       foreach(string str in encSelReps.EncoderCompareInter)
                                                if(Util.FetchID(str) == eSQL.personID)
                                                        seriesName = Util.FetchName(str);
-                               } else if(Util.FindOnArray(':',1,0,
-                                                       
UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                               encoderDataCompareTranslation) == "Between sessions") 
+                               } else if(radio_encoder_analyze_individual_all_sessions.Active)
                                {
-                                       foreach(string str in encoderCompareIntersession) {
+                                       foreach(string str in encSelReps.EncoderCompareInter) {
                                                LogB.Information(str);
                                                if(Util.FetchID(str) == eSQL.sessionID)
                                                        seriesName = Util.FetchName(str);
                                        }
+                                       if(seriesName == "")
+                                               seriesName = currentSession.DateShortAsSQL;
                                }
                                if(seriesName == "")
                                        seriesName = currentPerson.Name;
@@ -2627,7 +2272,7 @@ public partial class ChronoJumpWindow
                        LogB.Debug(" AT ANALYZE 2 ");
                        Sqlite.Close(); 
 
-               } else {        //current signal
+               } else {        //current set
                        if(encoderAnalysis == "1RM") {
                                if(my1RMName == "1RM Any exercise") {
                                        //get speed1RM (from combo)
@@ -2677,10 +2322,6 @@ public partial class ChronoJumpWindow
                                UtilEncoder.GetEncoderTempPathWithoutLastSep(),
                                ep);
 
-               //show mass in title except if it's curves because then can be different mass
-               //string massString = "-(" + Util.ConvertToPoint(findMass(true)) + "Kg)";
-               //if( ! check_encoder_analyze_signal_or_curves.Active)  //saved curves
-               //      massString = "";
 
                string titleStr = Util.ChangeSpaceAndMinusForUnderscore(currentPerson.Name);
        
@@ -2688,7 +2329,7 @@ public partial class ChronoJumpWindow
                        titleStr = "Neuromuscular Profile" + "-" + titleStr;
                else {
                        //on signal show encoder exercise, but not in curves because every curve can be of a 
different exercise
-                       if(check_encoder_analyze_signal_or_curves.Active)       //current signal
+                       if(radio_encoder_analyze_individual_current_set.Active) //current set
                                titleStr += "-" + 
Util.ChangeSpaceAndMinusForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise));
                }
 
@@ -2713,7 +2354,7 @@ public partial class ChronoJumpWindow
                        check_encoder_analyze_eccon_together.Active = false;
                }
                else if( 
-                               ( check_encoder_analyze_signal_or_curves.Active && findEccon(false) == "c" ) 
|| // 2)
+                               ( radio_encoder_analyze_individual_current_set.Active && findEccon(false) == 
"c" ) || // 2)
                                radiobutton_encoder_analyze_single.Active || 
radiobutton_encoder_analyze_side.Active // 3)
                  ) {
                        //together, mandatory
@@ -2721,46 +2362,117 @@ public partial class ChronoJumpWindow
                        check_encoder_analyze_eccon_together.Active = true;
                }
        }
+       
+       private void on_radio_encoder_analyze_individual_current_set_toggled (object obj, EventArgs args) 
+       {
+               if(! radio_encoder_analyze_individual_current_set.Active)
+                       return;
+               
+               //not called here
+               //prepareAnalyzeRepetitions();
+               
 
-       private void on_check_encoder_analyze_signal_or_curves_toggled (object obj, EventArgs args) {
-               bool signal = check_encoder_analyze_signal_or_curves.Active;
-                               
-               if(signal) {
-                       updateComboEncoderAnalyzeCurveNumFromCurrentSet ();
+               updateComboEncoderAnalyzeCurveNumFromCurrentSet ();
 
-                       hbox_encoder_user_curves.Visible = false;
-                       radiobutton_encoder_analyze_powerbars.Sensitive = true;
-                       radiobutton_encoder_analyze_single.Sensitive = true;
-                       radiobutton_encoder_analyze_side.Sensitive = true;
-               } 
-               else {
-                       if(currentPerson != null) {
-                               ArrayList data = SqliteEncoder.Select(
-                                               false, -1, currentPerson.UniqueID, currentSession.UniqueID, 
-1,
-                                               "curve", EncoderSQL.Eccons.ALL,
-                                               false, true);
-                               int activeCurvesNum = getActiveCurvesNum(data);
-                               updateComboEncoderAnalyzeCurveNumSavedReps(data, activeCurvesNum);      
-                       }
+               hbox_encoder_user_curves.Visible = false;
+               hbox_combo_encoder_exercise_analyze.Visible = false;
+               
+               //this analysis only when not comparing
+               radiobutton_encoder_analyze_powerbars.Visible = true;
+               radiobutton_encoder_analyze_1RM.Visible = true;
+               radiobutton_encoder_analyze_single.Visible = true;
+               radiobutton_encoder_analyze_side.Visible = true;
+               radiobutton_encoder_analyze_neuromuscular_profile.Visible = true;
 
-                       hbox_encoder_user_curves.Visible = currentPerson != null;
+               check_encoder_analyze_eccon_together.Sensitive = true;
+               block_check_encoder_analyze_eccon_together_if_needed();
+                       
+               button_encoder_analyze_sensitiveness();
+       
+               hbox_encoder_analyze_current_signal.Visible = true;
+       }
+       
+       private void on_radio_encoder_analyze_individual_current_session_toggled (object obj, EventArgs args) 
+       {
+               if(! radio_encoder_analyze_individual_current_session.Active)
+                       return;
+               
+               prepareAnalyzeRepetitions();
 
-                       radiobutton_encoder_analyze_powerbars.Sensitive = true;
-                       radiobutton_encoder_analyze_single.Sensitive = true;
-                       radiobutton_encoder_analyze_side.Sensitive = true;
+               if(currentPerson != null) {
+                       ArrayList data = SqliteEncoder.Select(
+                                       false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
+                                       "curve", EncoderSQL.Eccons.ALL,
+                                       false, true);
+                       int activeCurvesNum = UtilEncoder.GetActiveCurvesNum(data);
+                       updateComboEncoderAnalyzeCurveNumSavedReps(data, activeCurvesNum);      
                }
-                       
+
+               hbox_encoder_user_curves.Visible = currentPerson != null;
+               hbox_combo_encoder_exercise_analyze.Visible = false;
+
+               //this analysis only when not comparing
+               radiobutton_encoder_analyze_powerbars.Visible = true;
+               radiobutton_encoder_analyze_1RM.Visible = true;
+               radiobutton_encoder_analyze_single.Visible = true;
+               radiobutton_encoder_analyze_side.Visible = true;
+               radiobutton_encoder_analyze_neuromuscular_profile.Visible = true;
+
                check_encoder_analyze_eccon_together.Sensitive = true;
                block_check_encoder_analyze_eccon_together_if_needed();
                        
                button_encoder_analyze_sensitiveness();
+       
+               hbox_encoder_analyze_current_signal.Visible = false;
+       }
+       
+       private void on_radio_encoder_analyze_individual_all_sessions_toggled (object obj, EventArgs args) 
+       {
+               if(! radio_encoder_analyze_individual_all_sessions.Active)
+                       return;
+               
+               prepareAnalyzeRepetitions();
+       
+               hbox_encoder_analyze_current_signal.Visible = false;
+               
+               hbox_encoder_user_curves.Visible = currentPerson != null;
+               hbox_combo_encoder_exercise_analyze.Visible = true;
+               
+               //active cross. The only available for comparing        
+               radiobutton_encoder_analyze_cross.Active = true;
+               
+               //this analysis only when not comparing
+               radiobutton_encoder_analyze_powerbars.Visible = false;
+               radiobutton_encoder_analyze_1RM.Visible = false;
+               radiobutton_encoder_analyze_single.Visible = false;
+               radiobutton_encoder_analyze_side.Visible = false;
+               radiobutton_encoder_analyze_neuromuscular_profile.Visible = false;
+       }
+
+       private void on_radio_encoder_analyze_groupal_current_session_toggled (object obj, EventArgs args) 
+       {
+               if(! radio_encoder_analyze_groupal_current_session.Active)
+                       return;
+       
+               prepareAnalyzeRepetitions();
 
-               image_encoder_analyze_current_signal.Visible    = signal;
-               hbox_encoder_analyze_current_signal.Visible     = signal;
-               image_encoder_analyze_saved_curves.Visible      = ! signal;
-               label_encoder_analyze_saved_curves.Visible      = ! signal;
+               hbox_encoder_analyze_current_signal.Visible = false;
+               
+               hbox_encoder_user_curves.Visible = currentPerson != null;
+               hbox_combo_encoder_exercise_analyze.Visible = true;
+               
+               //active cross. The only available for comparing        
+               radiobutton_encoder_analyze_cross.Active = true;
+               
+               //this analysis only when not comparing
+               radiobutton_encoder_analyze_powerbars.Visible = false;
+               radiobutton_encoder_analyze_1RM.Visible = false;
+               radiobutton_encoder_analyze_single.Visible = false;
+               radiobutton_encoder_analyze_side.Visible = false;
+               radiobutton_encoder_analyze_neuromuscular_profile.Visible = false;
        }
 
+
        private string getAnalysisVariables(string encoderAnalysis) 
        {
                string analysisVariables = "none"; //cannot be blank
@@ -3004,20 +2716,36 @@ public partial class ChronoJumpWindow
        }
 
 
+       //side compare works only in two modes (current_set and individual_current_session)
        private bool curvesNumOkToSideCompare() {
-               if(check_encoder_analyze_signal_or_curves.Active &&     //current signal
-                               (
-                                       (ecconLast == "c" && UtilGtk.CountRows(encoderCaptureListStore) <= 
12) ||
-                                       (ecconLast != "c" && UtilGtk.CountRows(encoderCaptureListStore) <= 24)
-                               ) )
-                       return true;
-               else if( ! check_encoder_analyze_signal_or_curves.Active &&     //saved curves
-                               Convert.ToInt32(label_encoder_user_curves_active_num.Text) <= 12)
+               if( (radio_encoder_analyze_individual_current_set.Active || 
radio_encoder_analyze_individual_current_session.Active)
+                               && getActiveRepetitions() <= 12 )
                        return true;
 
                return false;
        }
 
+       private int getActiveRepetitions() 
+       {
+               if(radio_encoder_analyze_individual_current_set.Active) 
+               {       //current set
+                       int rowsAtCapture = UtilGtk.CountRows(encoderCaptureListStore);
+               
+                       if (ecconLast == "c")
+                               return rowsAtCapture;
+                       else {
+                               if(rowsAtCapture == 0)
+                                       return 0;
+                               else
+                                       return rowsAtCapture / 2;
+                       }
+               } else if(radio_encoder_analyze_individual_current_session.Active)
+               {
+                       return encSelReps.RepsActive;
+               }
+               return 0;
+       }
+
 
        //BODY and EXTRA are at EncoderParams and sent to graph.R       
        private double findMass(Constants.MassType massType) 
@@ -3075,7 +2803,6 @@ public partial class ChronoJumpWindow
        string [] encoderExercisesTranslationAndBodyPWeight;
        string [] encoderEcconTranslation;
        string [] encoderLateralityTranslation;
-       string [] encoderDataCompareTranslation;
        string [] encoderAnalyzeCrossTranslation;
        string [] encoderAnalyze1RMTranslation;
        
@@ -3083,8 +2810,12 @@ public partial class ChronoJumpWindow
        {
                //create combo exercises
                combo_encoder_exercise = ComboBox.NewText ();
-               createEncoderComboExercise();
+               combo_encoder_exercise_analyze = ComboBox.NewText ();
+               
+               createEncoderComboExerciseAndAnalyze();
+               
                combo_encoder_exercise.Changed += new EventHandler (on_combo_encoder_exercise_changed);
+               combo_encoder_exercise_analyze.Changed += new EventHandler 
(on_combo_encoder_exercise_analyze_changed);
                
                /* ConcentricEccentric
                 * unavailable until find while concentric data on concentric is the same than in ecc-con,
@@ -3129,27 +2860,6 @@ public partial class ChronoJumpWindow
                        new EventHandler(on_combo_encoder_anchorage_changed );
 
 
-               //create combo analyze data compare (variables)
-               string [] comboDataCompareOptions = { 
-                       "No compare", "Between persons", "Between sessions"};
-               string [] comboDataCompareOptionsTranslated = { 
-                       Catalog.GetString("No compare"),
-                       Catalog.GetString("Between persons"),
-                       Catalog.GetString("Between sessions")
-               };
-               encoderDataCompareTranslation = new String [comboDataCompareOptions.Length];
-               for(int j=0; j < 3 ; j++)
-                       encoderDataCompareTranslation[j] = 
-                               comboDataCompareOptions[j] + ":" + comboDataCompareOptionsTranslated[j];
-               combo_encoder_analyze_data_compare = ComboBox.NewText ();
-               UtilGtk.ComboUpdate(combo_encoder_analyze_data_compare, comboDataCompareOptionsTranslated, 
"");
-               combo_encoder_analyze_data_compare.Active = UtilGtk.ComboMakeActive(
-                               combo_encoder_analyze_data_compare, 
-                               Catalog.GetString(comboDataCompareOptions[0]));
-               combo_encoder_analyze_data_compare.Changed += 
-                       new EventHandler(on_combo_encoder_analyze_data_compare_changed );
-
-               
                //create combo analyze cross (variables)
                string [] comboAnalyzeCrossOptions = { 
                        "Power / Load", "Speed / Load", "Force / Load", "Speed,Power / Load", "Force / 
Speed", "Power / Speed"
@@ -3198,6 +2908,11 @@ public partial class ChronoJumpWindow
                hbox_combo_encoder_exercise.PackStart(combo_encoder_exercise, true, true, 0);
                hbox_combo_encoder_exercise.ShowAll();
                combo_encoder_exercise.Sensitive = true;
+               
+               hbox_combo_encoder_exercise_analyze.PackStart(combo_encoder_exercise_analyze, true, true, 0);
+               //hbox_combo_encoder_exercise_analyze.ShowAll(); //hbox will be shown only on intersession & 
interperson
+               combo_encoder_exercise_analyze.ShowAll();
+               combo_encoder_exercise_analyze.Sensitive = true;
 
                hbox_combo_encoder_eccon.PackStart(combo_encoder_eccon, true, true, 0);
                hbox_combo_encoder_eccon.ShowAll();
@@ -3211,10 +2926,6 @@ public partial class ChronoJumpWindow
                hbox_combo_encoder_anchorage.ShowAll();
                combo_encoder_anchorage.Sensitive = true;
 
-               hbox_encoder_analyze_data_compare.PackStart(combo_encoder_analyze_data_compare, true, true, 
0);
-               hbox_encoder_analyze_data_compare.ShowAll();
-               combo_encoder_analyze_data_compare.Sensitive = true;
-       
                hbox_combo_encoder_analyze_cross.PackStart(combo_encoder_analyze_cross, true, true, 0);
                hbox_combo_encoder_analyze_cross.ShowAll(); 
                combo_encoder_analyze_cross.Sensitive = true;
@@ -3232,7 +2943,7 @@ public partial class ChronoJumpWindow
        }
        
        //this is called also when an exercise is deleted to update the combo and the string []
-       protected void createEncoderComboExercise() {
+       protected void createEncoderComboExerciseAndAnalyze() {
                ArrayList encoderExercises = SqliteEncoder.SelectEncoderExercises(false, -1, false);
                encoderExercisesTranslationAndBodyPWeight = new String [encoderExercises.Count];
                string [] exerciseNamesToCombo = new String [encoderExercises.Count];
@@ -3244,9 +2955,14 @@ public partial class ChronoJumpWindow
                        exerciseNamesToCombo[i] = Catalog.GetString(ex.name);
                        i++;
                }
+               
                UtilGtk.ComboUpdate(combo_encoder_exercise, exerciseNamesToCombo, "");
                combo_encoder_exercise.Active = UtilGtk.ComboMakeActive(combo_encoder_exercise, 
                                Catalog.GetString(((EncoderExercise) encoderExercises[0]).name));
+               
+               UtilGtk.ComboUpdate(combo_encoder_exercise_analyze, exerciseNamesToCombo, "");
+               combo_encoder_exercise_analyze.Active = 
UtilGtk.ComboMakeActive(combo_encoder_exercise_analyze, 
+                               Catalog.GetString(((EncoderExercise) encoderExercises[0]).name));
        }
 
        void on_combo_encoder_eccon_changed (object o, EventArgs args) 
@@ -3269,36 +2985,6 @@ public partial class ChronoJumpWindow
                encoderCaptureSaveCurvesAllNoneBest(Constants.EncoderAutoSaveCurve.NONE, 
encoderCaptureOptionsWin.GetMainVariable());
        }
 
-       void on_combo_encoder_analyze_data_compare_changed (object o, EventArgs args)
-       {
-               bool compare = 
Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_data_compare),
-                                       encoderDataCompareTranslation) != "No compare";
-               
-               //this analysis can be done always. It's always sensitive (don't need to change), but is 
active if compare
-               if(compare)
-                       radiobutton_encoder_analyze_cross.Active = true;
-
-               //this analysis only when not comparing
-               radiobutton_encoder_analyze_powerbars.Sensitive = ! compare;
-               radiobutton_encoder_analyze_1RM.Sensitive = ! compare;
-               radiobutton_encoder_analyze_single.Sensitive = ! compare;
-               radiobutton_encoder_analyze_side.Sensitive = ! compare;
-               radiobutton_encoder_analyze_neuromuscular_profile.Sensitive = ! compare;
-
-               //compare button only visible when comparing
-               button_encoder_analyze_data_compare.Visible = compare;
-
-               if(compare)
-                       encoderCompareInitialize(); //put some data just in case user doesn't click on 
compare button
-       }
-
-       //put some data just in case user doesn't click on compare button
-       private void encoderCompareInitialize() {
-               if(encoderCompareInterperson == null)
-                       encoderCompareInterperson = new ArrayList ();
-               if(encoderCompareIntersession == null)
-                       encoderCompareIntersession = new ArrayList ();
-       }
 
        void on_combo_encoder_analyze_cross_changed (object o, EventArgs args)
        {
@@ -3325,7 +3011,7 @@ public partial class ChronoJumpWindow
                //1RM Indirect can only be used with current signal     
                if(Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM),
                                        encoderAnalyze1RMTranslation) == "1RM Indirect" &&
-                               ! check_encoder_analyze_signal_or_curves.Active) {      //saved curves 
+                               ! radio_encoder_analyze_individual_current_set.Active) {        //not current 
set
                        button_encoder_analyze.Sensitive = false;
                        new DialogMessage(Constants.MessageTypes.WARNING, 
                                        "1RM Indirect prediction can only be done with current set.");
@@ -3469,6 +3155,9 @@ public partial class ChronoJumpWindow
        int getExerciseIDFromCombo () {
                return getExerciseIDFromName (UtilGtk.ComboGetActive(combo_encoder_exercise));
        }
+       int getExerciseIDFromComboAnalyze () {
+               return getExerciseIDFromName (UtilGtk.ComboGetActive(combo_encoder_exercise_analyze));
+       }
        int getExerciseIDFromTable () {
                return getExerciseIDFromName (getExerciseNameFromTable());
        }
@@ -3729,7 +3418,7 @@ public partial class ChronoJumpWindow
 
                        genericWin.HideAndNull();
                                
-                       createEncoderComboExercise();
+                       createEncoderComboExerciseAndAnalyze();
                        combo_encoder_exercise.Active = 0;
 
                        new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Exercise 
deleted."));
@@ -3747,24 +3436,31 @@ public partial class ChronoJumpWindow
                        
        //called when a person changes
        private void encoderPersonChanged() {
+               //TODO
+               /*
                ArrayList data = SqliteEncoder.Select(
                                false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
                                "curve", EncoderSQL.Eccons.ALL, 
                                false, true);
                
-               int activeCurvesNum = getActiveCurvesNum(data);
+               int activeCurvesNum = UtilEncoder.GetActiveCurvesNum(data);
                label_encoder_user_curves_active_num.Text = activeCurvesNum.ToString();
                
                label_encoder_user_curves_all_num.Text = data.Count.ToString();
-       
-               if(check_encoder_analyze_signal_or_curves.Active)       //current set (signal)
+               */
+
+       /*      
+               if(radio_encoder_analyze_individual_current_set.Active)         //current set
                {
                        //when person changes, current signal is not loaded, 
                        //then combo_encoder_analyze_curve_num_combo has to be empty
                        UtilGtk.ComboUpdate(combo_encoder_analyze_curve_num_combo, new string [] {}, "");
-               } else {        //saved repetitions
+               } else if(radio_encoder_analyze_individual_current_session.Active) {
                        updateComboEncoderAnalyzeCurveNumSavedReps(data, activeCurvesNum);      
-               }
+//
+//                     getActiveRepetitions() DOING THIS
+               } //rest of modes don't use this combo
+               */
        
                encoderButtonsSensitive(encoderSensEnum.YESPERSON);
                
@@ -3783,9 +3479,6 @@ public partial class ChronoJumpWindow
                button_encoder_analyze_table_save.Sensitive = false;
                button_encoder_analyze_1RM_save.Visible = false;
 
-               //put some data just in case user doesn't click on compare button
-               encoderCompareInitialize();
-               
                array1RMUpdate(false);
                encoder_change_displaced_weight_and_1RM ();
        }
@@ -3811,8 +3504,8 @@ public partial class ChronoJumpWindow
                //other dependencies
                //c5 True needs 
                //      (signal && treeviewEncoder has rows) || 
-               //      (! check_encoder_analyze_signal_or_curves.Active && user has curves))
-               //c6 True needs ! check_encoder_analyze_signal_or_curves.Active
+               //      (! radio_encoder_analyze_individual_current_set.Active && user has curves))
+               //c6 True needs ! radio_encoder_analyze_individual_current_set.Active
 
                if(option != encoderSensEnum.PROCESSINGCAPTURE && option != encoderSensEnum.PROCESSINGR)
                        encoderSensEnumStored = option;
@@ -3825,7 +3518,6 @@ public partial class ChronoJumpWindow
                int [] processingR =            {0, 0, 0, 0, 0, 0, 1, 0, 0};
                int [] doneNoSignal =           {1, 1, 1, 0, 0, 1, 1, 0, 0};
                int [] doneYesSignal =          {1, 1, 1, 1, 0, 1, 1, 0, 0};
-               int [] selectedCurve =          {1, 1, 1, 1, 1, 1, 1, 0, 0};
                int [] table = new int[7];
 
                switch(option) {
@@ -3850,9 +3542,6 @@ public partial class ChronoJumpWindow
                        case encoderSensEnum.DONEYESSIGNAL:
                                table = doneYesSignal;
                                break;
-                       case encoderSensEnum.SELECTEDCURVE:
-                               table = selectedCurve;
-                               break;
                }
 
                button_encoder_capture.Sensitive = Util.IntToBool(table[0]);
@@ -3879,10 +3568,10 @@ public partial class ChronoJumpWindow
                        (
                         Util.IntToBool(table[5]) && 
                         (
-                         (check_encoder_analyze_signal_or_curves.Active &&
+                         (radio_encoder_analyze_individual_current_set.Active &&
                           UtilGtk.CountRows(encoderCaptureListStore) > 0) 
                          ||
-                         ( ! check_encoder_analyze_signal_or_curves.Active &&
+                         ( ! radio_encoder_analyze_individual_current_set.Active &&
                           Convert.ToInt32(label_encoder_user_curves_all_num.Text) >0)
                          )
                         );
@@ -3896,7 +3585,7 @@ public partial class ChronoJumpWindow
                button_encoder_analyze.Sensitive = analyze_sensitive;
 
                hbox_encoder_user_curves.Visible = 
-                       (Util.IntToBool(table[6]) && ! check_encoder_analyze_signal_or_curves.Active);
+                       (Util.IntToBool(table[6]) && ! radio_encoder_analyze_individual_current_set.Active);
                
                button_encoder_capture_cancel.Sensitive = Util.IntToBool(table[7]);
                button_encoder_analyze_cancel.Sensitive = Util.IntToBool(table[7]);
@@ -3906,8 +3595,7 @@ public partial class ChronoJumpWindow
        
        private void button_encoder_analyze_sensitiveness() {
                bool analyze_sensitive = false;
-               bool signal = check_encoder_analyze_signal_or_curves.Active;
-               if(signal) {
+               if(radio_encoder_analyze_individual_current_set.Active) {
                        int rows = UtilGtk.CountRows(encoderCaptureListStore);
                        
                        //button_encoder_analyze.Sensitive = encoderTimeStamp != null;
@@ -5424,8 +5112,10 @@ public partial class ChronoJumpWindow
                                                        }
                                                }
                                        }
-                                       if(deletedUserCurves)
+                                       if(deletedUserCurves) {
+                                               //TODO: change encSelReps and this will change labels
                                                updateUserCurvesLabelsAndCombo(true);   // (2)
+                                       }
 
                                        // (3) update meanPower on SQL encoder
                                        findAndMarkSavedCurves(true, true); //SQL opened; update curve SQL 
records (like future1: meanPower)
diff --git a/src/gui/encoderSelectRepetitions.cs b/src/gui/encoderSelectRepetitions.cs
new file mode 100644
index 0000000..7833747
--- /dev/null
+++ b/src/gui/encoderSelectRepetitions.cs
@@ -0,0 +1,618 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.IO; 
+using Gtk;
+using Gdk;
+using Glade;
+using System.Collections;
+using System.Collections.Generic; //List<T>
+using Mono.Unix;
+using LongoMatch.Gui;
+
+
+
+public class EncoderSelectRepetitions
+{
+       //passed variables
+       
+       protected Person currentPerson;
+       protected Session currentSession;
+       protected GenericWindow genericWin;
+//     protected Gtk.ComboBox combo_encoder_analyze_curve_num_combo;
+       protected Gtk.Button button_encoder_analyze;
+       protected int exerciseID;
+       protected bool askDeletion;
+
+       //calculated variables here
+       
+       protected string [] columnsString;
+       //protected var columnsString; //www.dotnetperls.com/array  var arr3 = new string[] { "one", "two", 
"three" };
+       protected ArrayList data;
+       protected ArrayList bigArray;
+       protected string [] checkboxes;
+       protected ArrayList nonSensitiveRows;
+       
+       //public variables accessed mainly from gui/encoder.cs  
+       
+       public Gtk.Button FakeButtonDeleteCurve;
+       public Gtk.Button FakeButtonDone;
+       public int DeleteCurveID;
+       public enum Types { UNDEFINED, INDIVIDUAL_CURRENT_SESSION, INDIVIDUAL_ALL_SESSIONS, 
GROUPAL_CURRENT_SESSION }
+       public Types Type;
+       
+       //could be Interperson or Intersession
+       //personID:personName
+       //sessionID:sessionDate
+       public ArrayList EncoderCompareInter;
+       public int RepsActive;
+       public int RepsAll;
+
+       
+       public EncoderSelectRepetitions() {
+               Type = Types.UNDEFINED;
+       }
+
+       public void PassVariables(Person currentP, Session currentS, 
+                       GenericWindow gw, //Gtk.ComboBox combo_curves, 
+                       Gtk.Button button_e_a, int exID,
+                       bool askDel) 
+       {
+               RepsActive = 0;
+               RepsAll = 0;
+               FakeButtonDone = new Gtk.Button();
+
+               currentPerson = currentP;
+               currentSession = currentS;
+
+               genericWin = gw;
+               //combo_encoder_analyze_curve_num_combo = combo_curves;
+               button_encoder_analyze = button_e_a;
+               exerciseID = exID;
+               askDeletion = askDel;
+       }
+       
+       //public GenericWindow Do() {
+       public GenericWindow Do() {
+               getData();
+               createBigArray();
+               createGenericWindow();
+
+               return genericWin;
+       }
+
+       //used when click on "Select" button
+       public void Show() {
+               RepsActive = 0;
+               RepsAll = 0;
+
+               activateCallbacks();
+               
+               genericWin.ShowNow();
+       }
+
+       protected virtual void getData() {
+       }
+       protected virtual void createBigArray() {
+       }
+       protected virtual void createGenericWindow() {
+       }
+
+       protected virtual void activateCallbacks() {
+               //manage selected, unselected curves
+               genericWin.Button_accept.Clicked += new EventHandler(on_show_repetitions_done);
+       }
+       
+       protected virtual void on_show_repetitions_done (object o, EventArgs args) {
+       }
+                
+}
+
+public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRepetitions
+{
+       ArrayList dataPrint;
+
+       public EncoderSelectRepetitionsIndividualCurrentSession() {
+               Type = Types.INDIVIDUAL_CURRENT_SESSION;
+
+               FakeButtonDeleteCurve = new Gtk.Button();
+       }
+
+       protected override void getData() 
+       {
+               data = SqliteEncoder.Select(
+                               false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
+                               "curve", EncoderSQL.Eccons.ALL, 
+                               false, true);
+       }
+
+       protected override void createBigArray() 
+       {
+               dataPrint = new ArrayList();
+               checkboxes = new string[data.Count]; //to store active or inactive status of curves
+               int count = 0;
+               foreach(EncoderSQL es in data) {
+                       checkboxes[count++] = es.status;
+                       dataPrint.Add(es.ToStringArray(count,true,false,true,true));
+
+                       if(es.status == "active")
+                               RepsActive ++;
+                       
+                       RepsAll ++;
+               }
+
+               columnsString = new string[] {
+                       Catalog.GetString("ID"),
+                       Catalog.GetString("Active"),    //checkboxes
+                       Catalog.GetString("Repetition"),
+                       Catalog.GetString("Exercise"),
+                       "RL",
+                       Catalog.GetString("Extra weight"),
+                       Catalog.GetString("Mean Power"),
+                       Catalog.GetString("Encoder"),
+                       Catalog.GetString("Contraction"),
+                       Catalog.GetString("Date"),
+                       Catalog.GetString("Comment")
+               };
+
+               bigArray = new ArrayList();
+               ArrayList a1 = new ArrayList();
+               ArrayList a2 = new ArrayList();
+               ArrayList a3 = new ArrayList();
+
+               //0 is the widgget to show; 1 is the editable; 2 id default value
+               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
+               bigArray.Add(a1);
+
+               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
+               bigArray.Add(a2);
+
+               a3.Add(Constants.GenericWindowShow.COMBO); a3.Add(true); a3.Add("");
+               bigArray.Add(a3);
+       }
+       
+       protected override void createGenericWindow() 
+       {
+               //add exercises to the combo (only the exercises done, and only unique)
+               ArrayList encoderExercisesNames = new ArrayList();
+               foreach(EncoderSQL es in data) {
+                       encoderExercisesNames = Util.AddToArrayListIfNotExist(encoderExercisesNames, 
Catalog.GetString(es.exerciseName));
+               }
+               
+               genericWin = GenericWindow.Show(false,  //don't show now
+                               string.Format(Catalog.GetString("Saved repetitions of athlete {0} on this 
session."), 
+                                       currentPerson.Name) + "\n" + 
+                               Catalog.GetString("Activate the repetitions you want to use clicking on first 
column.") + "\n" +
+                               Catalog.GetString("If you want to edit or delete a row, right click on it.") 
+ "\n",
+                               bigArray);
+
+               genericWin.SetTreeview(columnsString, true, dataPrint, new ArrayList(), 
Constants.ContextMenu.EDITDELETE, false);
+
+               genericWin.ResetComboCheckBoxesOptions();
+               genericWin.AddOptionsToComboCheckBoxesOptions(encoderExercisesNames);
+               genericWin.CreateComboCheckBoxes();
+
+               genericWin.MarkActiveCurves(checkboxes);
+               
+               //find all persons in current session
+               ArrayList personsPre = SqlitePersonSession.SelectCurrentSessionPersons(
+                               currentSession.UniqueID,
+                               false); //means: do not returnPersonAndPSlist
+               
+               string [] persons = new String[personsPre.Count];
+               int count = 0;
+               foreach (Person p in personsPre)
+                       persons[count++] = p.UniqueID.ToString() + ":" + p.Name;
+               genericWin.SetComboValues(persons, currentPerson.UniqueID + ":" + currentPerson.Name);
+               genericWin.SetComboLabel(Catalog.GetString("Change the owner of selected repetition") + 
+                               " (" + Catalog.GetString("code") + ":" + Catalog.GetString("name") + ")");
+               genericWin.ShowEditRow(false);
+               genericWin.CommentColumn = 10;
+               
+               genericWin.ShowButtonCancel(false);
+               genericWin.SetButtonAcceptSensitive(true);
+               genericWin.SetButtonCancelLabel(Catalog.GetString("Close"));
+
+               //used when we don't need to read data, 
+               //and we want to ensure next window will be created at needed size
+               //genericWin.DestroyOnAccept=true;
+               //here is comented because we are going to read the checkboxes
+       }
+       
+       protected override void activateCallbacks() {
+               //manage selected, unselected curves
+               genericWin.Button_accept.Clicked += new EventHandler(on_show_repetitions_done);
+               
+               genericWin.Button_row_edit.Clicked += new EventHandler(on_show_repetitions_row_edit);
+               genericWin.Button_row_edit_apply.Clicked += new 
EventHandler(on_show_repetitions_row_edit_apply);
+               genericWin.Button_row_delete.Clicked += new EventHandler(on_show_repetitions_row_delete_pre);
+       }
+       
+       
+       protected override void on_show_repetitions_done (object o, EventArgs args)
+       {
+               //don't stop calling here in order to arrive when encSelReps.Show() is called and accept is 
clicked
+               genericWin.Button_accept.Clicked -= new EventHandler(on_show_repetitions_done);
+
+               //get selected/deselected rows
+               checkboxes = genericWin.GetColumn(1, false);
+
+               ArrayList data = SqliteEncoder.Select(
+                               false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
+                               "curve", EncoderSQL.Eccons.ALL, 
+                               false, true);
+
+               //update on database the curves that have been selected/deselected
+               //doing it as a transaction: FAST
+               RepsActive = SqliteEncoder.UpdateTransaction(data, checkboxes);
+               RepsAll = data.Count;
+
+               FakeButtonDone.Click();         
+       }
+
+
+       // --------------- edit curves start ---------------
+       
+       protected void on_show_repetitions_row_edit (object o, EventArgs args) {
+               LogB.Information("row edit at show curves");
+               LogB.Information(genericWin.TreeviewSelectedUniqueID.ToString());
+               genericWin.ShowEditRow(true);
+       }
+
+       protected void on_show_repetitions_row_edit_apply (object o, EventArgs args) {
+               LogB.Information("row edit apply at show curves");
+
+               int curveID = genericWin.TreeviewSelectedUniqueID;
+               EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
+                               false, curveID, 0, 0, -1,
+                               "", EncoderSQL.Eccons.ALL, 
+                               false, true)[0];
+
+               //if changed comment, update SQL, and update treeview
+               //first remove conflictive characters
+               string comment = Util.RemoveTildeAndColonAndDot(genericWin.EntryEditRow);
+               if(comment != eSQL.description) {
+                       eSQL.description = comment;
+                       SqliteEncoder.Update(false, eSQL);
+
+                       //update treeview
+                       genericWin.on_edit_selected_done_update_treeview();
+               }
+
+               //if changed person, proceed
+               LogB.Information("new person: " + genericWin.GetComboSelected);
+               int newPersonID = Util.FetchID(genericWin.GetComboSelected);
+               if(newPersonID != currentPerson.UniqueID) {
+                       EncoderSQL eSQLChangedPerson = eSQL.ChangePerson(genericWin.GetComboSelected);
+                       SqliteEncoder.Update(false, eSQLChangedPerson);
+
+                       genericWin.RemoveSelectedRow();
+               }
+
+               genericWin.ShowEditRow(false);
+       }
+       
+       // --------------- edit curves end ---------------
+       
+       
+       // --------------- delete curves start ---------------
+       
+       protected void on_show_repetitions_row_delete_pre (object o, EventArgs args) {
+               if(askDeletion) {
+                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString(
+                                               "Are you sure you want to delete this repetition?"), "", "");
+                       confirmWin.Button_accept.Clicked += new EventHandler(on_show_repetitions_row_delete);
+               } else
+                       on_show_repetitions_row_delete (o, args);
+       }
+       
+       protected void on_show_repetitions_row_delete (object o, EventArgs args) {
+               LogB.Information("row delete at show curves");
+
+               int uniqueID = genericWin.TreeviewSelectedUniqueID;
+               string status = genericWin.GetCheckboxStatus(uniqueID);
+
+               DeleteCurveID = uniqueID;
+               FakeButtonDeleteCurve.Click();
+
+               if(status == "active")
+                       RepsActive --;
+               RepsAll --;
+
+               genericWin.Delete_row_accepted();
+               FakeButtonDone.Click();         
+       }
+
+       
+       // --------------- delete curves end ---------------
+       
+}
+
+
+public class EncoderSelectRepetitionsIndividualAllSessions : EncoderSelectRepetitions
+{
+       public EncoderSelectRepetitionsIndividualAllSessions() {
+               Type = Types.INDIVIDUAL_ALL_SESSIONS;
+
+               if(EncoderCompareInter == null)
+                       EncoderCompareInter = new ArrayList ();
+       }
+
+       protected override void getData() 
+       {
+               data = SqliteEncoder.SelectCompareIntersession(false, exerciseID, currentPerson.UniqueID); 
+       }
+       
+       protected override void createBigArray() 
+       {
+               nonSensitiveRows = new ArrayList();
+               int i = 0;
+               //prepare checkboxes to be marked       
+               checkboxes = new string[data.Count]; //to store active or inactive status
+               int count = 0;
+               foreach(EncoderPersonCurvesInDB encPS in data) 
+               {
+                       bool found = false;
+               
+                       if(encPS.countActive == 0)
+                               nonSensitiveRows.Add(count);
+                       else {
+                               foreach(string s2 in EncoderCompareInter)
+                                       if(Util.FetchID(s2) == encPS.sessionID)
+                                               found = true;
+
+                               //if EncoderCompareInter is empty, then add currentSession
+                               //if is not empty, then don't add it because maybe user doesn't want to 
compare with this session
+                               if(EncoderCompareInter.Count == 0 && encPS.sessionID == 
currentSession.UniqueID)
+                                       found = true;
+                       }
+
+                       if(found) {
+                               checkboxes[count++] = "active";
+                               RepsActive += encPS.countActive;
+                       } else
+                               checkboxes[count++] = "inactive";
+                       
+                       RepsAll += encPS.countAll;
+                       i ++;
+               }                       
+                       
+               columnsString = new string[] {
+                       Catalog.GetString("ID"),
+                       "",                             //checkboxes
+                       Catalog.GetString("Session name"),
+                       Catalog.GetString("Session date"),
+                       Catalog.GetString("Selected\nrepetitions"),
+                       Catalog.GetString("All\nrepetitions")
+               };
+
+               bigArray = new ArrayList();
+               ArrayList a1 = new ArrayList();
+               ArrayList a2 = new ArrayList();
+               
+               //0 is the widgget to show; 1 is the editable; 2 id default value
+               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
+               bigArray.Add(a1);
+               
+               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
+               bigArray.Add(a2);
+       }
+       
+       protected override void createGenericWindow() 
+       {
+               genericWin = GenericWindow.Show(false,  //don't show now        //TODO: change message
+                               string.Format(Catalog.GetString("Compare repetitions between the following 
sessions"),
+                                       currentPerson.Name), bigArray);
+
+               //convert data from array of EncoderPersonCurvesInDB to array of strings []
+               ArrayList dataConverted = new ArrayList();
+               foreach(EncoderPersonCurvesInDB encPS in data) {
+                       dataConverted.Add(encPS.ToStringArray());
+               }
+
+               genericWin.SetTreeview(columnsString, true, dataConverted, nonSensitiveRows, 
Constants.ContextMenu.NONE, false);
+
+               genericWin.ResetComboCheckBoxesOptions();
+               genericWin.CreateComboCheckBoxes();
+               
+               genericWin.MarkActiveCurves(checkboxes);
+               genericWin.ShowButtonCancel(false);
+               genericWin.SetButtonAcceptSensitive(true);
+
+               //used when we don't need to read data, 
+               //and we want to ensure next window will be created at needed size
+               //genericWin.DestroyOnAccept=true;
+               //here is comented because we are going to read the checkboxes
+       }
+       
+       protected override void on_show_repetitions_done (object o, EventArgs args) 
+       {
+               //don't stop calling here in order to arrive when encSelReps.Show() is called and accept is 
clicked
+               genericWin.Button_accept.Clicked -= new EventHandler(on_show_repetitions_done);
+       
+               EncoderCompareInter = new ArrayList ();
+               string [] selectedID = genericWin.GetColumn(0,true); //only active
+               string [] selectedDate = genericWin.GetColumn(3,true);
+
+               for (int i=0 ; i < selectedID.Length ; i ++) {
+                       int uniqueID = Convert.ToInt32(selectedID[i]);
+                       EncoderCompareInter.Add(uniqueID + ":" + selectedDate[i]);
+
+                       RepsActive += genericWin.GetCell(uniqueID, 4); //col 4 (Active reps)
+               }
+               
+               string [] allID = genericWin.GetColumn(0,false);
+               for (int i=0 ; i < allID.Length ; i ++) {
+                       RepsAll += genericWin.GetCell(Convert.ToInt32(allID[i]), 5); //col 5 (All reps)
+               }
+
+               FakeButtonDone.Click();         
+               LogB.Information("done");
+       }
+       
+}
+
+public class EncoderSelectRepetitionsGroupalCurrentSession : EncoderSelectRepetitions
+{
+       public EncoderSelectRepetitionsGroupalCurrentSession() {
+               Type = Types.GROUPAL_CURRENT_SESSION;
+
+               if(EncoderCompareInter == null)
+                       EncoderCompareInter = new ArrayList ();
+       }
+
+       protected override void getData() 
+       {
+               ArrayList dataPre = SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID,
+                               false); //means: do not returnPersonAndPSlist
+               data = new ArrayList();
+               
+               nonSensitiveRows = new ArrayList();
+               int i = 0;      //list of persons
+               int j = 0;      //list of added persons
+               foreach(Person p in dataPre) {
+                       //if(p.UniqueID != currentPerson.UniqueID) {
+                               ArrayList eSQLarray = SqliteEncoder.Select(
+                                               false, -1, p.UniqueID, currentSession.UniqueID, exerciseID, 
+                                               "curve", EncoderSQL.Eccons.ALL, 
+                                               false, true);
+
+                               int activeCurves = UtilEncoder.GetActiveCurvesNum(eSQLarray);
+                               int allCurves = eSQLarray.Count;
+
+                               string [] s = { p.UniqueID.ToString(), "", p.Name,
+                                       activeCurves.ToString(), allCurves.ToString()
+                               };
+                               data.Add(s);
+                               if(activeCurves == 0)
+                                       nonSensitiveRows.Add(j);
+
+                               j++;
+                       //}
+                       i ++;
+               }
+       }
+       
+       protected override void createBigArray() 
+       {
+               //prepare checkboxes to be marked       
+               checkboxes = new string[data.Count]; //to store active or inactive status
+               int i = 0;
+               int count = 0;
+               foreach(string [] sPersons in data) {
+                       bool found = false;
+                       bool nonSensitive = false;
+                       
+                       foreach(int nsr in nonSensitiveRows)
+                               if(nsr == i)
+                                       nonSensitive = true;
+
+                       if(nonSensitive == false) {
+                               foreach(string s2 in EncoderCompareInter)
+                                       if(Util.FetchID(s2).ToString() == sPersons[0])
+                                               found = true;
+
+                               //if EncoderCompareInter is empty, then add currentPerson
+                               //if is not empty, then don't add it because maybe user doesn't want to 
compare with this person
+                               if(EncoderCompareInter.Count == 0 && sPersons[0] == 
currentPerson.UniqueID.ToString())
+                                       found = true;
+                       }
+
+                       if(found) {
+                               checkboxes[count++] = "active";
+                               RepsActive += Convert.ToInt32(sPersons[3]);
+                       } else
+                               checkboxes[count++] = "inactive";
+                               
+                       RepsAll += Convert.ToInt32(sPersons[4]);
+                       i ++;
+               }                       
+                       
+               columnsString = new string [] {
+                       Catalog.GetString("ID"),
+                       "",                             //checkboxes
+                       Catalog.GetString("Person name"),
+                       Catalog.GetString("Selected\nrepetitions"),
+                       Catalog.GetString("All\nrepetitions")
+               };
+
+               bigArray = new ArrayList();
+               ArrayList a1 = new ArrayList();
+               ArrayList a2 = new ArrayList();
+               
+               //0 is the widgget to show; 1 is the editable; 2 id default value
+               a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
+               bigArray.Add(a1);
+               
+               a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
+               bigArray.Add(a2);
+       }
+       
+       protected override void createGenericWindow() 
+       {
+               genericWin = GenericWindow.Show(false,  //don't show now
+                               Catalog.GetString("Select persons to compare"), bigArray);
+
+               genericWin.SetTreeview(columnsString, true, data, nonSensitiveRows, 
Constants.ContextMenu.NONE, false);
+
+               //select this person row
+               genericWin.SelectRowWithID(0, currentPerson.UniqueID);
+
+               genericWin.ResetComboCheckBoxesOptions();
+               genericWin.CreateComboCheckBoxes();
+               
+               genericWin.MarkActiveCurves(checkboxes);
+               genericWin.ShowButtonCancel(false);
+               genericWin.SetButtonAcceptSensitive(true);
+
+               //used when we don't need to read data, 
+               //and we want to ensure next window will be created at needed size
+               //genericWin.DestroyOnAccept=true;
+               //here is comented because we are going to read the checkboxes
+       }
+       
+       protected override void on_show_repetitions_done (object o, EventArgs args) 
+       {
+               //don't stop calling here in order to arrive when encSelReps.Show() is called and accept is 
clicked
+               genericWin.Button_accept.Clicked -= new EventHandler(on_show_repetitions_done);
+               LogB.Information(" GROUPAL ");
+       
+               EncoderCompareInter = new ArrayList ();
+               string [] selectedID = genericWin.GetColumn(0,true);
+               string [] selectedName = genericWin.GetColumn(2,true);
+
+               for (int i=0 ; i < selectedID.Length ; i ++) {
+                       int uniqueID = Convert.ToInt32(selectedID[i]);
+                       EncoderCompareInter.Add(uniqueID + ":" + selectedName[i]);
+
+                       RepsActive += genericWin.GetCell(uniqueID, 3); //col 3 (Active reps)
+               }
+               
+               string [] allID = genericWin.GetColumn(0,false);
+               for (int i=0 ; i < allID.Length ; i ++) {
+                       RepsAll += genericWin.GetCell(Convert.ToInt32(allID[i]), 4); //col 4 (All reps)
+               }
+
+               FakeButtonDone.Click();         
+               LogB.Information("done");
+       }
+       
+}
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index f0de421..7b47b1b 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -466,29 +466,10 @@ public partial class ChronoJumpWindow
 
                        iterOk = encoderCaptureListStore.IterNext (ref iter);
                }
-               //combo_encoder_capture_show_save_curve_button();
                        
                callPlotCurvesGraphDoPlot();
        }
 
-       /*      
-       void combo_encoder_capture_show_save_curve_button () {
-               label_encoder_curve_action.Text = "";
-
-               TreeIter iter;
-               bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
-               while(iterOk) {
-                       if(((EncoderCurve) encoderCaptureListStore.GetValue (iter, 0)).Record) {
-                               encoderButtonsSensitive(encoderSensEnum.SELECTEDCURVE);
-                               return;
-                       }
-                       iterOk = encoderCaptureListStore.IterNext (ref iter);
-               }
-               encoderButtonsSensitive(encoderSensEnum.DONEYESSIGNAL);
-       }
-       */
-
-
 
        string [] treeviewEncoderAnalyzeHeaders = {
                Catalog.GetString("Repetition") + "\n",
@@ -524,10 +505,11 @@ public partial class ChronoJumpWindow
                ArrayList curvesData = new ArrayList();
                string exerciseName = "";
                double totalMass = 0; 
-               if(check_encoder_analyze_signal_or_curves.Active) {     //current signal
+               if(radio_encoder_analyze_individual_current_set.Active) {       //current set
                        exerciseName = UtilGtk.ComboGetActive(combo_encoder_exercise);
                        totalMass = findMass(Constants.MassType.DISPLACED);
-               } else {                                                //user curves
+               } else {                                                //not current set
+                       //TODO:
                        curvesData = SqliteEncoder.Select(
                                        false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
                                        "curve", EncoderSQL.Eccons.ALL, 
@@ -551,7 +533,7 @@ public partial class ChronoJumpWindow
                                cells = fixDecimals(false, cells);
                                
                                
-                               if(! check_encoder_analyze_signal_or_curves.Active) {   //user curves
+                               if(! radio_encoder_analyze_individual_current_set.Active) {     //not current 
set
                                        /*
                                         * better don't do this to avoid calling SQL in both treads
                                        EncoderSQL eSQL = (EncoderSQL) curvesData[curvesCount];
@@ -906,7 +888,7 @@ public partial class ChronoJumpWindow
                        return;
                }
                
-               if(check_encoder_analyze_signal_or_curves.Active && findEccon(false) == "ecS") 
+               if(radio_encoder_analyze_individual_current_set.Active && findEccon(false) == "ecS") 
                {
                        string phase = "e";
                        bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
@@ -916,7 +898,7 @@ public partial class ChronoJumpWindow
                        (cell as Gtk.CellRendererText).Text = 
                                decimal.Truncate((Convert.ToInt32(curve.N) +1) /2).ToString() + phase;
                }
-               else if(check_encoder_analyze_signal_or_curves.Active && findEccon(false) == "ceS") 
+               else if(radio_encoder_analyze_individual_current_set.Active && findEccon(false) == "ceS") 
                {
                        string phase = "c";
                        bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index 1908729..f1ef641 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -356,21 +356,29 @@ public class GenericWindow
        }
 
        
-       private string [] comboCheckBoxesOptions = {
+       private static string [] comboCheckBoxesOptionsDefault = {
                Catalog.GetString("All"),
                Catalog.GetString("None"),
                Catalog.GetString("Invert"),
                Catalog.GetString("Selected"),
        };
+       private string [] comboCheckBoxesOptions = comboCheckBoxesOptionsDefault;
+
+       public void ResetComboCheckBoxesOptions() {
+               comboCheckBoxesOptions = comboCheckBoxesOptionsDefault;
+       }
        
        //this search in first column
-       //private string [] addOptionsToComboCheckBoxesOptions(string [] newOptions) {
        public void AddOptionsToComboCheckBoxesOptions(ArrayList newOptions) {
                comboCheckBoxesOptions = Util.AddArrayString( comboCheckBoxesOptions, 
                                Util.ArrayListToString(newOptions) );
        }
 
-       public void CreateComboCheckBoxes() {
+       public void CreateComboCheckBoxes() 
+       {
+               if(hbox_combo_all_none_selected.Children.Length > 0)
+                       hbox_combo_all_none_selected.Remove(combo_all_none_selected);
+
                combo_all_none_selected = ComboBox.NewText ();
                UtilGtk.ComboUpdate(combo_all_none_selected, comboCheckBoxesOptions, "");
                
@@ -581,8 +589,38 @@ public class GenericWindow
                
        }
        
+       public int GetCell(int uniqueID, int column) 
+       {
+               LogB.Information(" GetCell " + uniqueID.ToString() + " " + column.ToString());
+               Gtk.TreeIter iter;
+               bool okIter = store.GetIterFirst(out iter);
+               if(okIter) {
+                       do {
+                               LogB.Information("_0_ " + (string) store.GetValue (iter, 0));
+                               LogB.Information("_column_ " + column.ToString() + " " + (string) 
store.GetValue (iter, column));
+                               if( ((string) store.GetValue (iter, 0)) == uniqueID.ToString()) {
+                                       return Convert.ToInt32( (string) store.GetValue (iter, column) );
+                               }
+                       } while ( store.IterNext(ref iter) );
+               }
+
+               return 0;
+       }
+       public string GetCheckboxStatus(int uniqueID) {
+               Gtk.TreeIter iter;
+               bool okIter = store.GetIterFirst(out iter);
+               if(okIter) {
+                       do {
+                               if( ((string) store.GetValue (iter, 0)) == uniqueID.ToString())
+                                       return store.GetValue (iter, 1).ToString();
+                       } while ( store.IterNext(ref iter) );
+               }
+               //if error, return
+               return "inactive";
+       }
        //if column == 1 returns checkboxes column. If is 2 returns column 2...
-       public string [] GetCheckboxesStatus(int column, bool onlyActive) 
+       //Attention: Used on checkboxes treeviews
+       public string [] GetColumn(int column, bool onlyActive) 
        {
                //to store active or inactive status of curves
                string [] checkboxes = new string[UtilGtk.CountRows(store)];
@@ -633,6 +671,11 @@ public class GenericWindow
 
                                //check if there are rows checked for having sensitive or not
                                //buttonRecuperateChangeSensitiveness();
+                               
+                               hbox_error.Hide();
+                       } else {
+                               label_error.Text = "Cannot select rows without active repetitions";
+                               hbox_error.Show();
                        }
                }
        }
diff --git a/src/session.cs b/src/session.cs
index a31e051..146642f 100644
--- a/src/session.cs
+++ b/src/session.cs
@@ -187,9 +187,17 @@ public partial class Session {
                get { return date.ToLongDateString(); }
        }
        
+       //latin: 20/11/2016
        public string DateShort {
                get { return date.ToShortDateString(); }
        }
+
+       //latin: 2016-11-20
+       public string DateShortAsSQL {
+               get { return date.Year.ToString() + "-" + 
+                               date.Month.ToString() + "-" + 
+                               date.Day.ToString(); }
+       }
        
        
        ~Session() {}
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index b9fe8b4..bed95d0 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -315,27 +315,19 @@ class SqliteEncoder : Sqlite
        }
        
 
-       public static ArrayList SelectCompareIntersession (bool dbconOpened, int personID)
+       public static ArrayList SelectCompareIntersession (bool dbconOpened, int exerciseID, int personID)
        {
                if(! dbconOpened)
                        Sqlite.Open();
 
-               /* OLD, returns a row for active and a row for inactive at each session 
-               dbcmd.CommandText = 
-                       "SELECT count(*), encoder.sessionID, session.name, session.date, encoder.status " +
-                       " FROM encoder, session, person77 " +
-                       " WHERE encoder.personID == " + personID + " AND signalOrCurve == 'curve' AND " + 
-                       " encoder.personID == person77.uniqueID AND encoder.sessionID == session.uniqueID " + 
-                       " GROUP BY encoder.sessionID, encoder.status ORDER BY encoder.sessionID, 
encoder.status";
-                       */
-
                //returns a row for each session where there are active or inactive
                dbcmd.CommandText = 
                        "SELECT encoder.sessionID, session.name, session.date, " +
                        " SUM(CASE WHEN encoder.status = \"active\" THEN 1 END) as active, " +
                        " SUM(CASE WHEN encoder.status = \"inactive\" THEN 1 END) as inactive " + 
                        " FROM encoder, session, person77 " +
-                       " WHERE encoder.personID == " + personID + " AND signalOrCurve == \"curve\" AND " +
+                       " WHERE encoder.exerciseID == " + exerciseID + " AND " +
+                       " encoder.personID == " + personID + " AND signalOrCurve == \"curve\" AND " +
                        " encoder.personID == person77.uniqueID AND encoder.sessionID == session.uniqueID " +
                        " GROUP BY encoder.sessionID ORDER BY encoder.sessionID, encoder.status";
        
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index b822460..0287e13 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -803,6 +803,33 @@ public class UtilEncoder
 
                return econf.inertiaMachine + im_weights;
        }
+
+       public static int GetActiveCurvesNum(ArrayList curvesArray) {
+               int countActiveCurves = 0;
+               foreach(EncoderSQL es in curvesArray) 
+                       if(es.status == "active")
+                               countActiveCurves ++;
+               
+               return countActiveCurves;
+       }
+       
+       public static string [] GetActiveCheckboxesList(string [] checkboxes, int activeCurvesNum) {
+               if(activeCurvesNum == 0)
+                       return Util.StringToStringArray("");
+
+               string [] activeCurvesList = new String[activeCurvesNum];
+               int i=0;
+               int j=0;
+               foreach(string cb in checkboxes) {
+                       if(cb == "active")
+                               activeCurvesList[j++] = (i+1).ToString();
+                       i++;
+               }
+               return activeCurvesList;
+       }
+       
+
+
                
 
 }


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