[chronojump] Improving runs execute graph



commit e538d801c8b7ff29f87a5d400e953b23e39e1a5b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Apr 21 22:31:49 2016 +0200

    Improving runs execute graph

 glade/chronojump.glade         |  289 +++++++++++++++++++++++---------
 src/exportSession.cs           |    4 +-
 src/gui/chronojump.cs          |    4 +-
 src/gui/eventExecute.cs        |  363 ++++++++++++----------------------------
 src/gui/eventGraphConfigure.cs |    8 -
 src/gui/person.cs              |    4 +-
 src/gui/run.cs                 |    3 +-
 src/gui/usefulObjects.cs       |   30 ++--
 src/report.cs                  |    3 +-
 src/server.cs                  |    4 +-
 src/sqlite/run.cs              |   16 ++-
 11 files changed, 367 insertions(+), 361 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 7aa247f..3a1937f 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -3688,7 +3688,7 @@
                                                   <widget class="GtkVBox" id="vbox_execute_test">
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
-                                                    <property name="spacing">16</property>
+                                                    <property name="spacing">10</property>
                                                     <child>
                                                       <widget class="GtkHBox" id="hbox183">
                                                         <property name="visible">True</property>
@@ -6551,11 +6551,11 @@ after time</property>
                                                       <widget class="GtkVBox" id="vbox16">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
+                                                        <property name="spacing">6</property>
                                                         <child>
                                                           <widget class="GtkLabel" 
id="event_execute_label_message">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="xalign">0</property>
                                                             <property name="use_markup">True</property>
                                                             <property name="ellipsize">end</property>
                                                             <property name="single_line_mode">True</property>
@@ -6602,7 +6602,6 @@ after time</property>
                                                             <widget class="GtkHBox" id="hbox88">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">12</property>
                                                             <child>
                                                             <widget class="GtkLabel" 
id="event_graph_label_graph_person">
                                                             <property name="visible">True</property>
@@ -6639,7 +6638,7 @@ after time</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="right_padding">25</property>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox105">
+                                                            <widget class="GtkHBox" id="hbox_results_legend">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">12</property>
@@ -6664,7 +6663,7 @@ after time</property>
                                                             <widget class="GtkLabel" id="label161">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" 
translatable="yes">Session max</property>
+                                                            <property name="label" 
translatable="yes">Session best</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -6736,7 +6735,7 @@ after time</property>
                                                             <widget class="GtkLabel" id="label163">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Person 
max</property>
+                                                            <property name="label" translatable="yes">Person 
best</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -8082,6 +8081,15 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -9634,6 +9642,15 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -10827,6 +10844,15 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -19214,6 +19240,15 @@ on current Chronojump version.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -23825,6 +23860,15 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -24917,6 +24961,15 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -26501,6 +26554,15 @@ by you</property>
               <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>
@@ -27142,6 +27204,15 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -32611,8 +32682,8 @@ Eg. value = 2, means person does twice force at half speed.</property>
                         </child>
                       </widget>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
@@ -32633,8 +32704,8 @@ Eg. value = 2, means person does twice force at half speed.</property>
             </child>
           </widget>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
             <property name="position">0</property>
           </packing>
         </child>
@@ -32799,64 +32870,6 @@ Eg. value = 2, means person does twice force at half speed.</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
-                    <child>
-                      <widget class="GtkLabel" id="label320">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Runs</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkHBox" id="hbox140">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">8</property>
-                        <child>
-                          <widget class="GtkRadioButton" id="radiobutton_time">
-                            <property name="label" translatable="yes">Show time</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="draw_indicator">True</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="padding">12</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <widget class="GtkRadioButton" id="radiobutton_speed">
-                            <property name="label" translatable="yes">Show speed</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="draw_indicator">True</property>
-                            <property name="group">radiobutton_time</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">3</property>
-                      </packing>
-                    </child>
                   </widget>
                 </child>
               </widget>
@@ -32874,8 +32887,8 @@ Eg. value = 2, means person does twice force at half speed.</property>
             </child>
           </widget>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
             <property name="position">2</property>
           </packing>
         </child>
@@ -32906,6 +32919,7 @@ Eg. value = 2, means person does twice force at half speed.</property>
             <property name="expand">False</property>
             <property name="fill">False</property>
             <property name="padding">8</property>
+            <property name="pack_type">end</property>
             <property name="position">3</property>
           </packing>
         </child>
@@ -39719,6 +39733,60 @@ 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>
                           </widget>
                         </child>
                       </widget>
@@ -42050,6 +42118,42 @@ 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>
                   </widget>
                 </child>
               </widget>
@@ -43377,15 +43481,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>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -44477,6 +44572,15 @@ 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>
                                   </widget>
                                 </child>
                               </widget>
@@ -48455,6 +48559,15 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -49211,6 +49324,15 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -49982,6 +50104,15 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/exportSession.cs b/src/exportSession.cs
index cdde8d2..20e2c2c 100644
--- a/src/exportSession.cs
+++ b/src/exportSession.cs
@@ -158,7 +158,9 @@ public class ExportSession
                                Sqlite.Orders_by.DEFAULT, -1);
 
                myJumpsRj = SqliteJumpRj.SelectJumps(true, mySession.UniqueID, -1, "", "");
-               myRuns= SqliteRun.SelectRuns(true, mySession.UniqueID, -1, "");
+               myRuns= SqliteRun.SelectRuns(true, mySession.UniqueID, -1, "",
+                               Sqlite.Orders_by.DEFAULT, -1);
+
                myRunsInterval = SqliteRunInterval.SelectRuns(true, mySession.UniqueID, -1, "");
                myReactionTimes = SqliteReactionTime.SelectReactionTimes(true, mySession.UniqueID, -1);
                myPulses = SqlitePulse.SelectPulses(true, mySession.UniqueID, -1);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index a411bca..64374c2 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -1674,7 +1674,9 @@ public partial class ChronoJumpWindow
                fillTreeView_runs (filter, false);
        }
        private void fillTreeView_runs (string filter, bool dbconOpened) {
-               string [] myRuns = SqliteRun.SelectRuns(dbconOpened, currentSession.UniqueID, -1, "");
+               string [] myRuns = SqliteRun.SelectRuns(dbconOpened, currentSession.UniqueID, -1, "",
+                               Sqlite.Orders_by.DEFAULT, -1);
+
                myTreeViewRuns.Fill(myRuns, filter);
 
                expandOrMinimizeTreeView((TreeViewEvent) myTreeViewRuns, treeview_runs);
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index e61f050..efdf234 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -62,22 +62,18 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button event_execute_button_update;
        
        
-       [Widget] Gtk.Table event_execute_table_jump_simple;
        [Widget] Gtk.Table event_execute_table_jump_reactive;
-       [Widget] Gtk.Table event_execute_table_run_simple;
        [Widget] Gtk.Table event_execute_table_run_interval;
        [Widget] Gtk.Table event_execute_table_pulse;
        [Widget] Gtk.Table event_execute_table_reaction_time;
        
-       [Widget] Gtk.Table event_execute_table_jump_simple_values;
        [Widget] Gtk.Table event_execute_table_jump_reactive_values;
-       [Widget] Gtk.Table event_execute_table_run_simple_values;
        [Widget] Gtk.Table event_execute_table_run_interval_values;
        [Widget] Gtk.Table event_execute_table_pulse_values;
        [Widget] Gtk.Table event_execute_table_reaction_time_values;
+       
+       [Widget] Gtk.HBox hbox_results_legend;
 
-       [Widget] Gtk.HBox event_execute_hbox_jump_simple_titles;
-       [Widget] Gtk.HBox event_execute_hbox_run_simple_titles;
        [Widget] Gtk.HBox event_execute_hbox_reaction_time_titles;
 
        //for the color change in the background of the cell label
@@ -87,24 +83,11 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.EventBox event_execute_eventbox_jump_reactive_tc;
        [Widget] Gtk.EventBox event_execute_eventbox_jump_reactive_tf;
        //[Widget] Gtk.EventBox event_execute_eventbox_jump_reactive_tf_tc;
-       [Widget] Gtk.EventBox event_execute_eventbox_run_simple_time;
-       [Widget] Gtk.EventBox event_execute_eventbox_run_simple_speed;
        [Widget] Gtk.EventBox event_execute_eventbox_run_interval_time;
        [Widget] Gtk.EventBox event_execute_eventbox_run_interval_speed;
        [Widget] Gtk.EventBox event_execute_eventbox_pulse_time;
        [Widget] Gtk.EventBox event_execute_eventbox_reaction_time_time;
 
-       
-       [Widget] Gtk.Label event_execute_label_jump_simple_tc_now;
-       [Widget] Gtk.Label event_execute_label_jump_simple_tc_person;
-       [Widget] Gtk.Label event_execute_label_jump_simple_tc_session;
-       [Widget] Gtk.Label event_execute_label_jump_simple_tf_now;
-       [Widget] Gtk.Label event_execute_label_jump_simple_tf_person;
-       [Widget] Gtk.Label event_execute_label_jump_simple_tf_session;
-       [Widget] Gtk.Label event_execute_label_jump_simple_height_now;
-       [Widget] Gtk.Label event_execute_label_jump_simple_height_person;
-       [Widget] Gtk.Label event_execute_label_jump_simple_height_session;
-
        [Widget] Gtk.Label event_execute_label_jump_reactive_height_now;
        [Widget] Gtk.Label event_execute_label_jump_reactive_height_avg;
        [Widget] Gtk.Label event_execute_label_jump_reactive_tf_now;
@@ -114,13 +97,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Label event_execute_label_jump_reactive_tf_tc_now;
        [Widget] Gtk.Label event_execute_label_jump_reactive_tf_tc_avg;
 
-       [Widget] Gtk.Label event_execute_label_run_simple_time_now;
-       [Widget] Gtk.Label event_execute_label_run_simple_time_person;
-       [Widget] Gtk.Label event_execute_label_run_simple_time_session;
-       [Widget] Gtk.Label event_execute_label_run_simple_speed_now;
-       [Widget] Gtk.Label event_execute_label_run_simple_speed_person;
-       [Widget] Gtk.Label event_execute_label_run_simple_speed_session;
-
        [Widget] Gtk.Label event_execute_label_run_interval_time_now;
        [Widget] Gtk.Label event_execute_label_run_interval_time_avg;
        [Widget] Gtk.Label event_execute_label_run_interval_speed_now;
@@ -226,8 +202,9 @@ public partial class ChronoJumpWindow
                if(simulated) 
                        event_execute_label_simulated = Catalog.GetString("Simulated");
 
-               event_graph_label_graph_person.Text = personName;
-               event_graph_label_graph_test.Text = "( " + event_execute_eventType + " )";
+               event_graph_label_graph_person.Text = "<b>" + personName + "</b>";
+               event_graph_label_graph_person.UseMarkup = true; 
+               event_graph_label_graph_test.Text = " - " + event_execute_eventType;
                                
                event_execute_label_message.Text = "";
 
@@ -269,8 +246,6 @@ public partial class ChronoJumpWindow
                //event_execute_eventbox_jump_reactive_height.ModifyBg(Gtk.StateType.Normal, 
UtilGtk.RED_PLOTS);
                event_execute_eventbox_jump_reactive_tc.ModifyBg(Gtk.StateType.Normal, UtilGtk.RED_PLOTS);
                event_execute_eventbox_jump_reactive_tf.ModifyBg(Gtk.StateType.Normal, UtilGtk.BLUE_PLOTS);
-               event_execute_eventbox_run_simple_time.ModifyBg(Gtk.StateType.Normal, UtilGtk.RED_PLOTS);
-               event_execute_eventbox_run_simple_speed.ModifyBg(Gtk.StateType.Normal, UtilGtk.BLUE_PLOTS);
                event_execute_eventbox_run_interval_time.ModifyBg(Gtk.StateType.Normal, UtilGtk.RED_PLOTS);
                event_execute_eventbox_run_interval_speed.ModifyBg(Gtk.StateType.Normal, UtilGtk.BLUE_PLOTS);
                event_execute_eventbox_pulse_time.ModifyBg(Gtk.StateType.Normal, UtilGtk.BLUE_PLOTS); //only 
one serie in pulse, leave blue
@@ -333,21 +308,12 @@ public partial class ChronoJumpWindow
                event_execute_image_run_interval_time_bad.Hide();
        }
 
-       private void eventExecuteHideAllTables() {
-               //hide simple jump info
-               event_execute_hbox_jump_simple_titles.Hide();
-               event_execute_table_jump_simple.Hide();
-               event_execute_table_jump_simple_values.Hide();
-               
+       private void eventExecuteHideAllTables() 
+       {
                //hide reactive info
                event_execute_table_jump_reactive.Hide();
                event_execute_table_jump_reactive_values.Hide();
                
-               //hide run simple info
-               event_execute_hbox_run_simple_titles.Hide();
-               event_execute_table_run_simple.Hide();
-               event_execute_table_run_simple_values.Hide();
-               
                //hide run interval info
                event_execute_table_run_interval.Hide();
                event_execute_table_run_interval_values.Hide();
@@ -362,31 +328,19 @@ public partial class ChronoJumpWindow
                event_execute_table_reaction_time_values.Hide();
        }
        
-       private void showJumpSimpleLabels() {
-               /*
-               //show simple jump info
-               event_execute_hbox_jump_simple_titles.Show();
-               event_execute_table_jump_simple.Show();
-               event_execute_table_jump_simple_values.Show();
-
-               //initializeLabels
-               event_execute_label_jump_simple_tc_now.Text = "";
-               event_execute_label_jump_simple_tc_person.Text = "";
-               event_execute_label_jump_simple_tc_session.Text = "";
-               event_execute_label_jump_simple_tf_now.Text = "";
-               event_execute_label_jump_simple_tf_person.Text = "";
-               event_execute_label_jump_simple_tf_session.Text = "";
-               event_execute_label_jump_simple_height_now.Text = "";
-               event_execute_label_jump_simple_height_person.Text = "";
-               event_execute_label_jump_simple_height_session.Text = "";
-               */
+       private void showJumpSimpleLabels() 
+       {
+               hbox_results_legend.Visible = true;
 
                notebook_results_data.Visible = false;
                //notebook_results_data.CurrentPage = 0;
        }
        
        
-       private void showJumpReactiveLabels() {
+       private void showJumpReactiveLabels() 
+       {
+               hbox_results_legend.Visible = false;
+
                //show reactive info
                event_execute_table_jump_reactive.Show();
                event_execute_table_jump_reactive_values.Show();
@@ -405,24 +359,18 @@ public partial class ChronoJumpWindow
                notebook_results_data.CurrentPage = 1;
        }
        
-       private void showRunSimpleLabels() {
-               //show run simple info
-               event_execute_hbox_run_simple_titles.Show();
-               event_execute_table_run_simple.Show();
-               event_execute_table_run_simple_values.Show();
-               
-               //initializeLabels
-               event_execute_label_run_simple_time_now.Text = "";
-               event_execute_label_run_simple_time_person.Text = "";
-               event_execute_label_run_simple_time_session.Text = "";
-               event_execute_label_run_simple_speed_now.Text = "";
-               event_execute_label_run_simple_speed_person.Text = "";
-               event_execute_label_run_simple_speed_session.Text = "";
-
-               notebook_results_data.CurrentPage = 2;
+       private void showRunSimpleLabels() 
+       {
+               hbox_results_legend.Visible = true;
+
+               notebook_results_data.Visible = false;
+               //notebook_results_data.CurrentPage = 2;
        }
                
-       private void showRunIntervalLabels() {
+       private void showRunIntervalLabels() 
+       {
+               hbox_results_legend.Visible = false;
+
                //show run interval info
                event_execute_table_run_interval.Show();
                event_execute_table_run_interval_values.Show();
@@ -589,21 +537,6 @@ public partial class ChronoJumpWindow
 
                //if max value of graph is automatic
                if(eventGraphConfigureWin.Max == -1) {
-                       /*
-                       maxValue = Util.GetMax(
-                                       eventGraph.tv.ToString() + "=" + 
-                                       eventGraph.tvPersonAVGAtSQL.ToString() + "=" + 
eventGraph.tvSessionAVGAtSQL.ToString() + "=" +
-                                       eventGraph.tc.ToString() + "=" + 
-                                       eventGraph.tcPersonAVGAtSQL.ToString() + "=" + 
eventGraph.tcSessionAVGAtSQL.ToString());
-                       foreach(string myStr in eventGraph.jumpsAtSQL) {
-                               string [] jump = myStr.Split(new char[] {':'});
-                               if(Convert.ToDouble(jump[5]) > maxValue)
-                                       maxValue = Convert.ToDouble(jump[5]); //tf
-                               if(Convert.ToDouble(jump[6]) > maxValue)
-                                       maxValue = Convert.ToDouble(jump[6]); //tc
-                       }
-                       */
-                       
                        maxValue = eventGraph.sessionMAXAtSQL;
 
                        //fix if there's a max tc that's higher than max tv
@@ -734,82 +667,39 @@ public partial class ChronoJumpWindow
                if(eventGraphConfigureWin == null)
                        eventGraphConfigureWin = EventGraphConfigureWindow.Show(false);
 
-               
-               bool paintTime = false; //paint speed
-               if(eventGraphConfigureWin.RunsTimeActive) 
-                       paintTime = true;
-               
-
+       
                double maxValue = 0;
                double minValue = 0;
-               int topMargin = 10; 
+               int topMargin = 20; 
                int bottomMargin = 0; 
 
                //if max value of graph is automatic
-               if(eventGraphConfigureWin.Max == -1) {
-                       if(paintTime) {
-                               maxValue = Util.GetMax(eventGraph.time.ToString() + "=" + 
-                                               eventGraph.timePersonAVGAtSQL.ToString() + "=" + 
eventGraph.timeSessionAVGAtSQL.ToString());
-                               foreach(string myStr in eventGraph.runsAtSQL) {
-                                       string [] run = myStr.Split(new char[] {':'});
-                                       if(Convert.ToDouble(run[6]) > maxValue)
-                                               maxValue = Convert.ToDouble(run[6]); 
-                               }
-                       }
-                       else {                                          //paint speed
-                               maxValue = Util.GetMax(eventGraph.speed.ToString() + "=" + 
-                                               eventGraph.speedPersonAVGAtSQL.ToString() + "=" + 
eventGraph.speedSessionAVGAtSQL.ToString());
-                               foreach(string myStr in eventGraph.runsAtSQL) {
-                                       string [] run = myStr.Split(new char[] {':'});
-                                       double mySpeed = Convert.ToDouble(Util.GetSpeed(run[5], run[6], 
true));
-                                       if(mySpeed > maxValue)
-                                               maxValue = mySpeed;
-                               }
-                       }
-               } else {
+               if(eventGraphConfigureWin.Max == -1)
+                       maxValue = eventGraph.sessionMAXAtSQL;
+               else {
                        maxValue = eventGraphConfigureWin.Max;
                        topMargin = 0;
                }
                        
                //if min value of graph is automatic
+               /*
                if(eventGraphConfigureWin.Min == -1) {
-                       if(paintTime) {
-                               minValue = Util.GetMin(eventGraph.time.ToString() + "=" + 
-                                               eventGraph.timePersonAVGAtSQL.ToString() + "=" + 
eventGraph.timeSessionAVGAtSQL.ToString());
-                               foreach(string myStr in eventGraph.runsAtSQL) {
-                                       string [] run = myStr.Split(new char[] {':'});
-                                       if(Convert.ToDouble(run[6]) < minValue)
-                                               minValue = Convert.ToDouble(run[6]); 
-                               }
-                       }
-                       else {
-                               minValue = Util.GetMin(eventGraph.speed.ToString() + "=" + 
-                                               eventGraph.speedPersonAVGAtSQL.ToString() + "=" + 
eventGraph.speedSessionAVGAtSQL.ToString());
-                               foreach(string myStr in eventGraph.runsAtSQL) {
-                                       string [] run = myStr.Split(new char[] {':'});
-                                       double mySpeed = Convert.ToDouble(Util.GetSpeed(run[5], run[6], 
true));
-                                       if(mySpeed < minValue)
-                                               minValue = mySpeed;
-                               }
+                       minValue = Util.GetMin(eventGraph.speed.ToString() + "=" + 
+                                       eventGraph.speedPersonAVGAtSQL.ToString() + "=" + 
eventGraph.speedSessionAVGAtSQL.ToString());
+                       foreach(string myStr in eventGraph.runsAtSQL) {
+                               string [] run = myStr.Split(new char[] {':'});
+                               double mySpeed = Convert.ToDouble(Util.GetSpeed(run[5], run[6], true));
+                               if(mySpeed < minValue)
+                                       minValue = mySpeed;
                        }
                } else {
+               */
                        minValue = eventGraphConfigureWin.Min;
-               }
+               //}
                        
-               
-               //paint graph
-               if(paintTime)
-                       paintRunSimple (event_execute_drawingarea, pen_rojo, eventGraph.runsAtSQL, 
-                                       eventGraph.time, eventGraph.timePersonAVGAtSQL, 
eventGraph.timeSessionAVGAtSQL, 
-                                       maxValue, minValue, topMargin, bottomMargin);
-               else                                            //paint speed
-                       paintRunSimple (event_execute_drawingarea, pen_azul_claro, eventGraph.runsAtSQL, 
-                                       eventGraph.speed, eventGraph.speedPersonAVGAtSQL, 
eventGraph.speedSessionAVGAtSQL, 
+                       paintRunSimple (event_execute_drawingarea, eventGraph,
                                        maxValue, minValue, topMargin, bottomMargin);
                
-               //printLabels
-               printLabelsRunSimple (eventGraph.time, eventGraph.timePersonAVGAtSQL, 
eventGraph.timeSessionAVGAtSQL, 
-                               eventGraph.speed, eventGraph.speedPersonAVGAtSQL, 
eventGraph.speedSessionAVGAtSQL);
                
                // -- refresh
                event_execute_drawingarea.QueueDraw();
@@ -824,23 +714,15 @@ public partial class ChronoJumpWindow
                if(eventGraphConfigureWin == null)
                        eventGraphConfigureWin = EventGraphConfigureWindow.Show(false);
 
-               bool paintTime = false; //paint speed
-               if(eventGraphConfigureWin.RunsTimeActive) 
-                       paintTime = true;
-
                //search MAX 
                double maxValue = 0;
-               int topMargin = 10;
+               int topMargin = 20;
                //if max value of graph is automatic
                if(eventGraphConfigureWin.Max == -1) {
-                       if(paintTime)
-                               maxValue = Util.GetMax(timesString);
-                       else {
-                               if(distancesString == "")
-                                       maxValue = distance / Util.GetMin(timesString); //getMin because is 
on the "denominador"
-                               else
-                                       maxValue = Util.GetRunIVariableDistancesSpeeds(distancesString, 
timesString, true);
-                       }
+                       if(distancesString == "")
+                               maxValue = distance / Util.GetMin(timesString); //getMin because is on the 
"denominador"
+                       else
+                               maxValue = Util.GetRunIVariableDistancesSpeeds(distancesString, timesString, 
true);
                } else {
                        maxValue = eventGraphConfigureWin.Max;
                        topMargin = 0;
@@ -851,14 +733,10 @@ public partial class ChronoJumpWindow
                int bottomMargin = 0; 
                //if min value of graph is automatic
                if(eventGraphConfigureWin.Min == -1) { 
-                       if(paintTime)
-                               minValue = Util.GetMin(timesString);
-                       else {
-                               if(distancesString == "")
-                                       minValue = distance / Util.GetMax(timesString); //getMax because is 
in the "denominador"
-                               else
-                                       minValue = Util.GetRunIVariableDistancesSpeeds(distancesString, 
timesString, false);
-                       }
+                       if(distancesString == "")
+                               minValue = distance / Util.GetMax(timesString); //getMax because is in the 
"denominador"
+                       else
+                               minValue = Util.GetRunIVariableDistancesSpeeds(distancesString, timesString, 
false);
                } else {
                        minValue = eventGraphConfigureWin.Min;
                }               
@@ -866,7 +744,7 @@ public partial class ChronoJumpWindow
                int tracks = Util.GetNumberOfJumps(timesString, true); 
 
                //paint graph
-               paintRunInterval (event_execute_drawingarea, paintTime, distance, distanceTotal, 
distancesString,
+               paintRunInterval (event_execute_drawingarea, distance, distanceTotal, distancesString,
                                lastTime, timesString, Util.GetAverage(timesString), 
                                maxValue, minValue, tracks, topMargin, bottomMargin,
                                Util.GetPosMax(timesString), Util.GetPosMin(timesString),
@@ -886,7 +764,7 @@ public partial class ChronoJumpWindow
 
                //search MAX 
                double maxValue = 0;
-               int topMargin = 10;
+               int topMargin = 20;
                //if max value of graph is automatic
                if(eventGraphConfigureWin.Max == -1) 
                        maxValue = Util.GetMax(timesString);
@@ -925,7 +803,7 @@ public partial class ChronoJumpWindow
 
                double maxValue = 0;
                double minValue = 0;
-               int topMargin = 10; 
+               int topMargin = 20; 
                int bottomMargin = 0; 
 
                //if max value of graph is automatic
@@ -981,7 +859,7 @@ TODO: use specific method
 
                //search MAX 
                double maxValue = 0;
-               int topMargin = 10;
+               int topMargin = 20;
                //if max value of graph is automatic
                /*
                if(eventGraphConfigureWin.Max == -1) 
@@ -1021,20 +899,6 @@ TODO: use specific method
        }
        
        
-       private void printLabelsRunSimple (double timeNow, double timePerson, double timeSession, double 
speedNow, double speedPerson, double speedSession) {
-               event_execute_label_run_simple_time_now.Text = "<b>" + Util.TrimDecimals(timeNow.ToString(), 
preferences.digitsNumber) + "</b>";
-               event_execute_label_run_simple_time_now.UseMarkup = true; 
-               
-               event_execute_label_run_simple_time_person.Text = Util.TrimDecimals(timePerson.ToString(), 
preferences.digitsNumber);
-               event_execute_label_run_simple_time_session.Text = Util.TrimDecimals(timeSession.ToString(), 
preferences.digitsNumber);
-               
-               event_execute_label_run_simple_speed_now.Text = "<b>" + 
Util.TrimDecimals(speedNow.ToString(), preferences.digitsNumber) + "</b>";
-               event_execute_label_run_simple_speed_now.UseMarkup = true; 
-               
-               event_execute_label_run_simple_speed_person.Text = Util.TrimDecimals(speedPerson.ToString(), 
preferences.digitsNumber);
-               event_execute_label_run_simple_speed_session.Text = 
Util.TrimDecimals(speedSession.ToString(), preferences.digitsNumber);
-       }
-       
        private void printLabelsReactionTime (double timeNow, double timePerson, double timeSession) {
                event_execute_label_reaction_time_now.Text =  "<b>" + Util.TrimDecimals(timeNow.ToString(), 
preferences.digitsNumber) + "</b>";
                event_execute_label_reaction_time_now.UseMarkup = true; 
@@ -1138,6 +1002,10 @@ TODO: use specific method
                        count --;
                }
 
+               if(eventGraph.tc > 0)
+                       addUnitsToLabel("s");
+               else
+                       addUnitsToLabel("cm");
 
                //paint reference guide black and green if needed
                //drawGuideOrAVG(pen_black_discont, eventGraphConfigureWin.BlackGuide, alto, ancho, 
topMargin, bottomMargin, maxValue, minValue);
@@ -1187,63 +1055,60 @@ TODO: use specific method
                                layout);
        }
 
+       private void addUnitsToLabel(string unit) {
+               event_graph_label_graph_test.Text = event_graph_label_graph_test.Text + " (" + unit + ")";
+       }
 
-       private void paintRunSimple (Gtk.DrawingArea drawingarea, Gdk.GC myPen, string [] runs, 
-                       double now, double person, double session,
+       private void paintRunSimple (Gtk.DrawingArea drawingarea, PrepareEventGraphRunSimple eventGraph,
                        double maxValue, double minValue, int topMargin, int bottomMargin)
        {
                int ancho=drawingarea.Allocation.Width;
                int alto=drawingarea.Allocation.Height;
-               int count;
                
                UtilGtk.ErasePaint(event_execute_drawingarea, event_execute_pixmap);
-               writeMarginsText(maxValue, minValue, alto);
+               //writeMarginsText(maxValue, minValue, alto);
                
                //check now here that we will have not division by zero problems
-               if(maxValue - minValue > 0) {
-                       //calculate bar width
-                       int distanceBetweenCols = 
Convert.ToInt32((ancho-event_execute_rightMargin)*(1+.5)/runs.Length) -
-                                       Convert.ToInt32((ancho-event_execute_rightMargin)*(0+.5)/runs.Length);
-                       int barWidth = Convert.ToInt32(.3*distanceBetweenCols);
-                       int barDesplLeft = Convert.ToInt32(.5*barWidth);
+               if(maxValue - minValue <= 0)
+                       return;
+               
+               //calculate bar width
+               int distanceBetweenCols = 
Convert.ToInt32((ancho-event_execute_rightMargin)*(1+.5)/eventGraph.runsAtSQL.Length) -
+                       Convert.ToInt32((ancho-event_execute_rightMargin)*(0+.5)/eventGraph.runsAtSQL.Length);
+               int barWidth = Convert.ToInt32(.3*distanceBetweenCols);
+               int barDesplLeft = Convert.ToInt32(.5*barWidth);
+
+               /*
+               //paint reference guide black and green if needed
+               drawGuideOrAVG(pen_black_discont, eventGraphConfigureWin.BlackGuide, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
+               drawGuideOrAVG(pen_green_discont, eventGraphConfigureWin.GreenGuide, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
+               */
+
+               //blue for TF
                        
-                       //paint reference guide black and green if needed
-                       drawGuideOrAVG(pen_black_discont, eventGraphConfigureWin.BlackGuide, alto, ancho, 
topMargin, bottomMargin, maxValue, minValue);
-                       drawGuideOrAVG(pen_green_discont, eventGraphConfigureWin.GreenGuide, alto, ancho, 
topMargin, bottomMargin, maxValue, minValue);
+               drawGuideOrAVG(pen_black_90, eventGraph.sessionMAXAtSQL, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
+               drawGuideOrAVG(pen_black_discont, eventGraph.sessionAVGAtSQL, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
+               drawGuideOrAVG(pen_yellow, eventGraph.personMAXAtSQL, alto, ancho, topMargin, bottomMargin, 
maxValue, minValue);
+               drawGuideOrAVG(pen_yellow_discont, eventGraph.personAVGAtSQL, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
 
-                       //blue for TF
-                       count = 0;
-                       if(now > 0) {
-                               //blue tf average discountinuos line    
-                               drawGuideOrAVG(pen_azul_claro,  person, alto, ancho, topMargin, bottomMargin, 
maxValue, minValue);
-                               drawGuideOrAVG(pen_azul_claro_discont, session, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
-               
-                               foreach(string myStr in runs) {
-                                       string [] run = myStr.Split(new char[] {':'});
-                                       Rectangle rect = new Rectangle(
-                                                       
Convert.ToInt32((ancho-event_execute_rightMargin)*(count+.5)/runs.Length)-barDesplLeft, 
-                                                       calculatePaintHeight(Convert.ToDouble(run[6]), alto, 
maxValue, minValue, 
-                                                               topMargin, bottomMargin),
-                                                       barWidth, alto
-                                                       );
-                                       //TODO: do speed related
-                                       event_execute_pixmap.DrawRectangle(pen_azul_claro, true, rect);
-                                       event_execute_pixmap.DrawRectangle(pen_black, false, rect);
-                                       count ++;
-                               }
-                               
-                               //write "last" to show last jump
-                               layoutSmall.SetMarkup(Catalog.GetString("Last"));
-                               event_execute_pixmap.DrawLayout (pen_gris, 
-                                               
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/runs.Length)-barDesplLeft, 
-                                               0, layoutSmall);
+               int x = 0;
+               int y = 0;
+               int count = eventGraph.runsAtSQL.Length;
+               foreach(string myStr in eventGraph.runsAtSQL) {
+                       string [] run = myStr.Split(new char[] {':'});
+                       if(Convert.ToDouble(run[5]) > 0 && Convert.ToDouble(run[6]) > 0) {
+                               x = 
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/eventGraph.runsAtSQL.Length)-barDesplLeft;
+                               y = calculatePaintHeight(Convert.ToDouble(run[5])/Convert.ToDouble(run[6]), 
alto, maxValue, minValue, 
+                                               topMargin, bottomMargin);
+
+                               drawBar(x, y, barWidth, alto, pen_azul_claro, count == 
eventGraph.runsAtSQL.Length,
+                                               run[8] == "-1", 
Convert.ToDouble(run[5])/Convert.ToDouble(run[6]), layoutMid);
                        }
-                       
-                       plotSimulatedMessageIfNeededAtLast(
-                                       
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/runs.Length)-barDesplLeft 
-                                       + barWidth/2,
-                                       alto);
+
+                       count --;
                }
+                       
+               addUnitsToLabel("m/s");
        }
 
        
@@ -1442,7 +1307,7 @@ TODO: use specific method
                        event_execute_label_jump_reactive_tf_tc_avg.Text = "0";
        }
 
-       private void paintRunInterval (Gtk.DrawingArea drawingarea, bool paintTime, double distance, double 
distanceTotal, string distancesString, double lastTime, 
+       private void paintRunInterval (Gtk.DrawingArea drawingarea, double distance, double distanceTotal, 
string distancesString, double lastTime, 
                        string timesString, double avgTime, double maxValue, double minValue, int tracks, int 
topMargin, int bottomMargin, 
                        int hightValuePosition, int lowValuePosition,
                        bool volumeOn, RepetitiveConditionsWindow repetitiveConditionsWin)
@@ -1460,12 +1325,8 @@ TODO: use specific method
                if(maxValue - minValue > 0) {
 
                        if(tracks > 1) {
-                               if(paintTime) 
-                                       //red time average discountinuos line   
-                                       drawGuideOrAVG(pen_rojo_discont, avgTime, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
-                               else 
-                                       //blue speed average discountinuos line 
-                                       drawGuideOrAVG(pen_azul_discont, distance/avgTime, alto, ancho, 
topMargin, bottomMargin, maxValue, minValue);
+                               //blue speed average discountinuos line 
+                               drawGuideOrAVG(pen_azul_discont, distance/avgTime, alto, ancho, topMargin, 
bottomMargin, maxValue, minValue);
                        }
 
                        //paint reference guide black and green if needed
@@ -1486,20 +1347,14 @@ TODO: use specific method
                                if(myTimeDouble < 0)
                                        myTimeDouble = 0;
 
-                               if(paintTime) {
-                                       //red time evolution
-                                       myPen = pen_rojo;
-                                       myValue = myTimeDouble;
-                               } else {
-                                       //blue speed evolution  
-                                       myPen = pen_azul;
-
-                                       //if distances are variable
-                                       if(distancesString == "") 
-                                               myValue = distance / myTimeDouble;
-                                       else
-                                               myValue = 
Util.GetRunIVariableDistancesStringRow(distancesString, count) / myTimeDouble;
-                               }
+                               //blue speed evolution  
+                               myPen = pen_azul;
+
+                               //if distances are variable
+                               if(distancesString == "") 
+                                       myValue = distance / myTimeDouble;
+                               else
+                                       myValue = Util.GetRunIVariableDistancesStringRow(distancesString, 
count) / myTimeDouble;
 
                                if (count > 0) {
                                        event_execute_pixmap.DrawLine(myPen,
diff --git a/src/gui/eventGraphConfigure.cs b/src/gui/eventGraphConfigure.cs
index 36e49cb..733b956 100644
--- a/src/gui/eventGraphConfigure.cs
+++ b/src/gui/eventGraphConfigure.cs
@@ -50,7 +50,6 @@ public class EventGraphConfigureWindow
        
        [Widget] Gtk.CheckButton checkbutton_paint_circle;
        [Widget] Gtk.CheckButton checkbutton_show_vertical_grid;
-       [Widget] Gtk.RadioButton radiobutton_time;
        [Widget] Gtk.RadioButton radiobutton_speed;
 
        
@@ -183,13 +182,6 @@ public class EventGraphConfigureWindow
                }
        }
        
-       //check if it's active from eventExecuteWindow
-       public bool RunsTimeActive {
-               get {
-                       return (radiobutton_time.Active);
-               }
-       }
-       
        public bool PaintCircle {
                get {
                        return (checkbutton_paint_circle.Active);
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 2f6894f..c1fdd48 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -1591,7 +1591,9 @@ public class PersonAddModifyWindow
                double weight = (double) spinbutton_weight.Value;
 
                //convert margarias (it's power is calculated using weight and it's written on description)
-               string [] myMargarias = SqliteRun.SelectRuns(false, currentSession.UniqueID, 
currentPerson.UniqueID, "Margaria");
+               string [] myMargarias = SqliteRun.SelectRuns(false, currentSession.UniqueID, 
currentPerson.UniqueID, "Margaria",
+                               Sqlite.Orders_by.DEFAULT, -1);
+
                foreach(string myStr in myMargarias) {
                        string [] margaria = myStr.Split(new char[] {':'});
                        Run mRun = SqliteRun.SelectRunData(Convert.ToInt32(margaria[1]), false);
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 2a37d8c..20b372d 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -1259,7 +1259,8 @@ public class RunsMoreWindow : EventMoreWindow
        }
 
        protected override string [] findTestTypesInSessions() {
-               return SqliteRun.SelectRuns(false, -1, -1, selectedEventName); 
+               return SqliteRun.SelectRuns(false, -1, -1, selectedEventName,
+                               Sqlite.Orders_by.DEFAULT, -1);
        }
 
        void on_button_cancel_clicked (object o, EventArgs args)
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 4eb5aa9..df78932 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -59,6 +59,7 @@ public class PrepareEventGraphJumpSimple {
        
        public double personMAXAtSQL;
        public double sessionMAXAtSQL;
+
        public double personAVGAtSQL;
        public double sessionAVGAtSQL;
 
@@ -77,7 +78,7 @@ public class PrepareEventGraphJumpSimple {
 
                //select data from SQL to update graph  
                jumpsAtSQL = SqliteJump.SelectJumps(true, sessionID, personID, "", type,
-                               Sqlite.Orders_by.ID_DESC, 10); //select only last 10 jumps
+                               Sqlite.Orders_by.ID_DESC, 10); //select only last 10
 
                string sqlSelect = "";
                if(tv > 0) {
@@ -127,10 +128,12 @@ public class PrepareEventGraphJumpReactive {
 public class PrepareEventGraphRunSimple {
        //sql data of previous runs to plot graph and show stats at bottom
        public string [] runsAtSQL;
-       public double timePersonAVGAtSQL;
-       public double timeSessionAVGAtSQL;
-       public double speedPersonAVGAtSQL;
-       public double speedSessionAVGAtSQL;
+       
+       public double personMAXAtSQL;
+       public double sessionMAXAtSQL;
+
+       public double personAVGAtSQL;
+       public double sessionAVGAtSQL;
        
        public double time;
        public double speed;
@@ -143,11 +146,15 @@ public class PrepareEventGraphRunSimple {
                Sqlite.Open();
                
                //obtain data
-               runsAtSQL = SqliteRun.SelectRuns(true, sessionID, personID, type);
-
-               timePersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, 
type, "time");
-               timeSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type, 
"time");
+               runsAtSQL = SqliteRun.SelectRuns(true, sessionID, personID, type,
+                               Sqlite.Orders_by.ID_DESC, 10); //select only last 10
 
+               
+               string sqlSelect = "distance/time";
+               
+               personMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, personID, table, type, 
sqlSelect);
+               sessionMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, -1, table, type, 
sqlSelect);
+               
                //distancePersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, 
table, type, "distance");
                //distanceSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, 
type, "distance");
                //better to know speed like:
@@ -155,9 +162,8 @@ public class PrepareEventGraphRunSimple {
                //SELECT AVG(distance) / SELECT AVG(time) 
                //first is ok, because is the speed AVG
                //2nd is not good because it tries to do an AVG of all distances and times
-               speedPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, 
type, "distance/time");
-               speedSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type, 
"distance/time");
-               
+               personAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, type, 
sqlSelect);
+               sessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type, 
sqlSelect);
                
                this.time = time;
                this.speed = speed;
diff --git a/src/report.cs b/src/report.cs
index bf01b52..9de46be 100644
--- a/src/report.cs
+++ b/src/report.cs
@@ -110,7 +110,8 @@ public class Report : ExportSession
                        myJumpsRj = SqliteJumpRj.SelectJumps(true, sessionID, -1, "", "");
                }
                if(ShowSimpleRuns) {
-                       myRuns= SqliteRun.SelectRuns(true, sessionID, -1, "");
+                       myRuns= SqliteRun.SelectRuns(true, sessionID, -1, "",
+                                       Sqlite.Orders_by.DEFAULT, -1);
                }
                if (ShowIntervalRuns) {
                        myRunsInterval = SqliteRunInterval.SelectRuns(true, sessionID, -1, "");
diff --git a/src/server.cs b/src/server.cs
index 79ea13b..edc0dbb 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -368,7 +368,9 @@ public class Server
                                countE = 0;                                     
                                countS = 0;                                     
 
-                               string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID, 
person.UniqueID, "");
+                               string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID, 
person.UniqueID, "",
+                                               Sqlite.Orders_by.DEFAULT, -1);
+
                                Sqlite.Open();
                                foreach(string myRun in runs) {
                                        string [] js = myRun.Split(new char[] {':'});
diff --git a/src/sqlite/run.cs b/src/sqlite/run.cs
index f3de94d..b99f047 100644
--- a/src/sqlite/run.cs
+++ b/src/sqlite/run.cs
@@ -89,7 +89,9 @@ class SqliteRun : Sqlite
        //if all sessions, put -1 in sessionID
        //if all persons, put -1 in personID
        //if all types, put "" in filterType
-       public static string[] SelectRuns(bool dbconOpened, int sessionID, int personID, string filterType) 
+       //unlimited put -1 in limit
+       public static string[] SelectRuns(bool dbconOpened, int sessionID, int personID, string filterType,
+                       Orders_by order, int limit) 
        {
                if(!dbconOpened)
                        Sqlite.Open();
@@ -108,13 +110,23 @@ class SqliteRun : Sqlite
                if(filterType != "")
                        filterTypeString = " AND run.type == \"" + filterType + "\" " ;
 
+               string orderByString = " ORDER BY upper(" + tp + ".name), run.uniqueID ";
+               if(order == Orders_by.ID_DESC)
+                       orderByString = " ORDER BY run.uniqueID DESC ";
+               
+               string limitString = "";
+               if(limit != -1)
+                       limitString = " LIMIT " + limit;
+
+
                dbcmd.CommandText = "SELECT " + tp + ".name, run.* " +
                        " FROM " + tp + ", run " +
                        " WHERE " + tp + ".uniqueID == run.personID" + 
                        filterSessionString +
                        filterPersonString +
                        filterTypeString +
-                       " ORDER BY upper(" + tp + ".name), run.uniqueID";
+                       orderByString +
+                       limitString;
                
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();


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