[chronojump] Jumps profile shows a clear table with needed jumps



commit 31a16f61ab0939ff3fe2f10865083a6057a84461
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 5 00:03:27 2018 +0200

    Jumps profile shows a clear table with needed jumps

 glade/app1.glade        | 297 +++++++++++++++++++++++++++++++++++++++++++-----
 src/gui/chronojump.cs   |  33 +++++-
 src/gui/jumpsProfile.cs |  45 +++++++-
 src/jumpsProfile.cs     |  28 ++++-
 4 files changed, 369 insertions(+), 34 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 073ccf09..786e463f 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -423,7 +423,6 @@
                     </child>
                     <child>
                       <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_runs_encoder">
-                        <property name="visible">False</property>
                         <property name="can_focus">False</property>
                         <property name="label">Races with encoder</property>
                         <property name="use_underline">True</property>
@@ -1741,6 +1740,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -14631,6 +14633,267 @@ on current Chronojump version.</property>
                                                   <widget class="GtkVBox" id="vbox82">
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
+                                                    <child>
+                                                      <widget class="GtkHBox" 
id="hbox_jumps_profile_jumps_done">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                        <property name="border_width">10</property>
+                                                        <property name="spacing">20</property>
+                                                        <child>
+                                                          <widget class="GtkLabel" id="label373">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Jumps</property>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="padding">40</property>
+                                                            <property name="position">0</property>
+                                                          </packing>
+                                                        </child>
+                                                        <child>
+                                                          <widget class="GtkTable" id="table9">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="n_rows">2</property>
+                                                            <property name="n_columns">5</property>
+                                                            <property name="column_spacing">20</property>
+                                                            <property name="row_spacing">4</property>
+                                                            <property name="homogeneous">True</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label375">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">SJ</property>
+                                                            </widget>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label376">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">SJl (100%)</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">1</property>
+                                                            <property name="right_attach">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label377">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">CMJ</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">2</property>
+                                                            <property name="right_attach">3</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label378">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">ABK</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">3</property>
+                                                            <property name="right_attach">4</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label379">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">DJa</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">4</property>
+                                                            <property name="right_attach">5</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox292">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_profile_sj_yes">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-yes</property>
+                                                            </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_jumps_profile_sj_no">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-no</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox293">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_profile_sjl_yes">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-yes</property>
+                                                            </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_jumps_profile_sjl_no">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-no</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">1</property>
+                                                            <property name="right_attach">2</property>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox294">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_profile_cmj_yes">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-yes</property>
+                                                            </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_jumps_profile_cmj_no">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-no</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">2</property>
+                                                            <property name="right_attach">3</property>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox295">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_profile_abk_yes">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-yes</property>
+                                                            </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_jumps_profile_abk_no">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-no</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">3</property>
+                                                            <property name="right_attach">4</property>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox296">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jumps_profile_dja_yes">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-yes</property>
+                                                            </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_jumps_profile_dja_no">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-no</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="left_attach">4</property>
+                                                            <property name="right_attach">5</property>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            </packing>
+                                                            </child>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                          </packing>
+                                                        </child>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="expand">False</property>
+                                                        <property name="fill">False</property>
+                                                        <property name="position">0</property>
+                                                      </packing>
+                                                    </child>
                                                     <child>
                                                       <widget class="GtkHBox" id="hbox191">
                                                         <property name="visible">True</property>
@@ -14709,7 +14972,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>
@@ -14749,7 +15012,7 @@ on current Chronojump version.</property>
                                                       <packing>
                                                         <property name="expand">False</property>
                                                         <property name="fill">False</property>
-                                                        <property name="position">1</property>
+                                                        <property name="position">2</property>
                                                       </packing>
                                                     </child>
                                                     <child>
@@ -14984,7 +15247,7 @@ on current Chronojump version.</property>
                                                       <packing>
                                                         <property name="expand">False</property>
                                                         <property name="fill">False</property>
-                                                        <property name="position">2</property>
+                                                        <property name="position">3</property>
                                                       </packing>
                                                     </child>
                                                     <child>
@@ -15795,7 +16058,7 @@ Concentric</property>
                                                       <packing>
                                                         <property name="expand">False</property>
                                                         <property name="fill">True</property>
-                                                        <property name="position">3</property>
+                                                        <property name="position">4</property>
                                                       </packing>
                                                     </child>
                                                   </widget>
@@ -19324,27 +19587,6 @@ Concentric</property>
                                                             <placeholder/>
                                                             </child>
                                                             <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_force_sensor_ai_rfd_a">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -27727,6 +27969,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 8b415669..f4870bd6 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -236,8 +236,19 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.ScrolledWindow scrolledwindow_jumps_profile_training;
        [Widget] Gtk.Image image_tab_jumps_profile;
        [Widget] Gtk.Image image_jumps_profile_save;
-       
-       
+
+       [Widget] Gtk.HBox hbox_jumps_profile_jumps_done;
+       [Widget] Gtk.Image image_jumps_profile_sj_yes;
+       [Widget] Gtk.Image image_jumps_profile_sj_no;
+       [Widget] Gtk.Image image_jumps_profile_sjl_yes;
+       [Widget] Gtk.Image image_jumps_profile_sjl_no;
+       [Widget] Gtk.Image image_jumps_profile_cmj_yes;
+       [Widget] Gtk.Image image_jumps_profile_cmj_no;
+       [Widget] Gtk.Image image_jumps_profile_abk_yes;
+       [Widget] Gtk.Image image_jumps_profile_abk_no;
+       [Widget] Gtk.Image image_jumps_profile_dja_yes;
+       [Widget] Gtk.Image image_jumps_profile_dja_no;
+
        //runs
        [Widget] Gtk.Button button_edit_selected_run;
        [Widget] Gtk.Button button_video_play_selected_run;
@@ -7140,9 +7151,25 @@ LogB.Debug("X");
                }
 
                if(calculateData)
+               {
                        jumpsProfile.Calculate(currentPerson.UniqueID, currentSession.UniqueID);
 
-               JumpsProfileGraph.Do(jumpsProfile.GetIndexes(), drawingarea_jumps_profile);
+                       if(jumpsProfile.AllJumpsDone)
+                               hbox_jumps_profile_jumps_done.Visible = false;
+                       else {
+                               hbox_jumps_profile_jumps_done.Visible = true;
+                               JumpsProfileGraph.ShowDoneJumps(jumpsProfile.JumpsDone,
+                                               image_jumps_profile_sj_yes, image_jumps_profile_sj_no,
+                                               image_jumps_profile_sjl_yes, image_jumps_profile_sjl_no,
+                                               image_jumps_profile_cmj_yes, image_jumps_profile_cmj_no,
+                                               image_jumps_profile_abk_yes, image_jumps_profile_abk_no,
+                                               image_jumps_profile_dja_yes, image_jumps_profile_dja_no
+                                               );
+                       }
+               }
+
+               JumpsProfileGraph.Do(jumpsProfile.GetIndexes(), drawingarea_jumps_profile,
+                               currentPerson.Name + "(" + currentSession.DateShort + ")");
        }
        private void on_drawingarea_jumps_profile_expose_event (object o, ExposeEventArgs args) 
        {
diff --git a/src/gui/jumpsProfile.cs b/src/gui/jumpsProfile.cs
index 09c01b7a..43a32422 100644
--- a/src/gui/jumpsProfile.cs
+++ b/src/gui/jumpsProfile.cs
@@ -1,3 +1,14 @@
+/*
+Que hi hagi caselles del que falta a dalt de la imatge de jumps profile
+aixi si guarden la imatge no sortira
+o que estiguin en la imatge si falten salts
+
+i a la part superior de la imatge que surti la persona i la data
+
+i canviar els fors al pintar
+posar un missatge si falten totes les dades
+i si hi ha dades que hi hagi un for per cada capacitat i que es cridi a una funcio que posi el text, la 
barra, missatge d'error si cal
+*/
 /*
  * This file is part of ChronoJump
  *
@@ -25,7 +36,34 @@ using Cairo;
 
 public static class JumpsProfileGraph
 {
-       public static void Do (List<JumpsProfileIndex> l_jpi, DrawingArea area) 
+       public static void ShowDoneJumps(List<JumpsProfile.YesNo> jumpsDone,
+                       Gtk.Image image_jumps_profile_sj_yes, Gtk.Image image_jumps_profile_sj_no,
+                       Gtk.Image image_jumps_profile_sjl_yes, Gtk.Image image_jumps_profile_sjl_no,
+                       Gtk.Image image_jumps_profile_cmj_yes, Gtk.Image image_jumps_profile_cmj_no,
+                       Gtk.Image image_jumps_profile_abk_yes, Gtk.Image image_jumps_profile_abk_no,
+                       Gtk.Image image_jumps_profile_dja_yes, Gtk.Image image_jumps_profile_dja_no
+                       )
+       {
+               showDoneJump(jumpsDone[0] == JumpsProfile.YesNo.YES, image_jumps_profile_sj_yes, 
image_jumps_profile_sj_no);
+               showDoneJump(jumpsDone[1] == JumpsProfile.YesNo.YES, image_jumps_profile_sjl_yes, 
image_jumps_profile_sjl_no);
+               showDoneJump(jumpsDone[2] == JumpsProfile.YesNo.YES, image_jumps_profile_cmj_yes, 
image_jumps_profile_cmj_no);
+               showDoneJump(jumpsDone[3] == JumpsProfile.YesNo.YES, image_jumps_profile_abk_yes, 
image_jumps_profile_abk_no);
+               showDoneJump(jumpsDone[4] == JumpsProfile.YesNo.YES, image_jumps_profile_dja_yes, 
image_jumps_profile_dja_no);
+       }
+
+       private static void showDoneJump(bool done, Gtk.Image image_yes, Gtk.Image image_no)
+       {
+               if(done) {
+                       image_yes.Visible = true;
+                       image_no.Visible = false;
+               }
+               else {
+                       image_yes.Visible = false;
+                       image_no.Visible = true;
+               }
+       }
+
+       public static void Do (List<JumpsProfileIndex> l_jpi, DrawingArea area, string title)
        {
                //1 create context
                Cairo.Context g = Gdk.CairoHelper.Create (area.GdkWindow);
@@ -47,9 +85,8 @@ public static class JumpsProfileGraph
 
                if(sum == 0)
                {
-                       //draw an "invisible" rectangle just to set the graphics context
-                       drawRoundedRectangle (0, 0, 0, 0, 0, g, new Cairo.Color(1, 1, 1));
-                       printText(100, 100, 24, textHeight, "TODO: Text about which jumps have to be done", 
g);
+                       g.SetSourceRGB(0,0,0);
+                       printText(100, 100, 24, textHeight, "Please, perform the needed jumps marked in red 
above.", g);
                        g.GetTarget().Dispose ();
                        g.Dispose ();
                        return;
diff --git a/src/jumpsProfile.cs b/src/jumpsProfile.cs
index cbd5b52c..54abda88 100644
--- a/src/jumpsProfile.cs
+++ b/src/jumpsProfile.cs
@@ -75,7 +75,7 @@ public class JumpsProfileIndex
                if(errorCode == ErrorCodes.NEEDJUMP)
                        ErrorMessage = Catalog.GetString("Need to execute jump/s"); //TODO: write which jumps
                else if(errorCode == ErrorCodes.NEGATIVE)
-                       ErrorMessage = string.Format(Catalog.GetString("Bad execution: {0} is higher than 
{1}"), jumpLowerName, jumpHigherName);
+                       ErrorMessage = string.Format(Catalog.GetString("Negative index: {0} is higher than 
{1}"), jumpLowerName, jumpHigherName);
        }
 
        private double calculateIndex (Types type, double higher, double lower, double dja) 
@@ -117,6 +117,10 @@ public class JumpsProfile
        private JumpsProfileIndex jpi3;
        private JumpsProfileIndex jpi4;
 
+       public enum YesNo { YES, NO }
+       public List<YesNo> JumpsDone;
+       public bool AllJumpsDone;
+
        public JumpsProfile() {
        }
 
@@ -135,6 +139,8 @@ public class JumpsProfile
                jpi2 = new JumpsProfileIndex(JumpsProfileIndex.Types.CELAST, "CMJ", "SJ", cmj, sj, dja);
                jpi3 = new JumpsProfileIndex(JumpsProfileIndex.Types.CARMS, "ABK", "CMJ", abk, cmj, dja);
                jpi4 = new JumpsProfileIndex(JumpsProfileIndex.Types.FREACT, "DJa", "ABK", dja, abk, dja);
+
+               fillListJumpsDone(sj, sjl, cmj, abk, dja);
        }
 
        public List<JumpsProfileIndex> GetIndexes()
@@ -147,4 +153,24 @@ public class JumpsProfile
                l.Add(jpi4);
                return l;
        }
+
+       private void fillListJumpsDone(double sj, double sjl, double cmj, double abk, double dja)
+       {
+               AllJumpsDone = true;
+               JumpsDone = new List<YesNo>();
+               JumpsDone.Add(fillJump(sj));
+               JumpsDone.Add(fillJump(sjl));
+               JumpsDone.Add(fillJump(cmj));
+               JumpsDone.Add(fillJump(abk));
+               JumpsDone.Add(fillJump(dja));
+       }
+
+       private YesNo fillJump(double j)
+       {
+               if(j > 0)
+                       return YesNo.YES;
+
+               AllJumpsDone = false;
+               return YesNo.NO;
+       }
 }


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