[chronojump] gui code for sprint



commit 054fc195b4ba67c70274fc7960123146462df695
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 22 16:43:55 2017 +0100

    gui code for sprint

 chronojump.csproj     |    1 +
 glade/app1.glade      |   82 ++++++++++++++++++++++++++++++++++++++++++-----
 src/Makefile.am       |    3 +-
 src/gui/chronojump.cs |   15 ++++-----
 src/gui/sprint.cs     |   85 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/sprint.cs         |   21 ++++++++++++
 src/treeViewRun.cs    |    1 -
 7 files changed, 189 insertions(+), 19 deletions(-)
---
diff --git a/chronojump.csproj b/chronojump.csproj
index 1faf122..47bc461 100644
--- a/chronojump.csproj
+++ b/chronojump.csproj
@@ -1114,6 +1114,7 @@
     <Compile Include="src\gui\chronojumpIcons.cs" />
     <Compile Include="src\sprint.cs" />
     <Compile Include="src\gui\forceSensor.cs" />
+    <Compile Include="src\gui\sprint.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="src\" />
diff --git a/glade/app1.glade b/glade/app1.glade
index 7f0185d..da0630e 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -13676,24 +13676,82 @@ Concentric</property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkHButtonBox" id="hbuttonbox9">
+                                              <widget class="GtkVBox" id="vbox72">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
-                                                <property name="border_width">10</property>
                                                 <child>
-                                                  <widget class="GtkButton" id="button_sprint">
-                                                    <property name="label">Sprint</property>
+                                                  <widget class="GtkHBox" id="hbox76">
                                                     <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">True</property>
-                                                    <signal name="clicked" 
handler="on_button_sprint_clicked" swapped="no"/>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="spacing">12</property>
+                                                    <child>
+                                                      <widget class="GtkScrolledWindow" id="scrolledwindow3">
+                                                        <property name="width_request">250</property>
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">True</property>
+                                                        <property 
name="hscrollbar_policy">automatic</property>
+                                                        <property 
name="vscrollbar_policy">automatic</property>
+                                                        <child>
+                                                          <widget class="GtkTreeView" 
id="treeview_runs_interval_sprint">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="rules_hint">True</property>
+                                                            <property name="enable_search">False</property>
+                                                          </widget>
+                                                        </child>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="expand">False</property>
+                                                        <property name="fill">True</property>
+                                                        <property name="position">0</property>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkHButtonBox" id="hbuttonbox9">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                        <property name="border_width">10</property>
+                                                        <child>
+                                                          <widget class="GtkButton" id="button_sprint">
+                                                            <property name="label">Sprint</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_sprint_clicked" swapped="no"/>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</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="expand">True</property>
+                                                    <property name="fill">True</property>
                                                     <property name="position">0</property>
                                                   </packing>
                                                 </child>
+                                                <child>
+                                                  <widget class="GtkLabel" id="label41">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="label">result</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">1</property>
+                                                  </packing>
+                                                </child>
                                               </widget>
                                               <packing>
                                                 <property name="position">3</property>
@@ -19539,6 +19597,12 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index be4f808..3ce9a45 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,8 +47,9 @@ SOURCES = \
        gui/repetitiveConditions.cs\
        gui/convertWeight.cs\
        gui/genericWindow.cs\
-       gui/splash.cs\
        gui/server.cs\
+       gui/splash.cs\
+       gui/sprint.cs\
        gui/dialogServerStats.cs\
        gui/evaluator.cs\
        gui/networks.cs\
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 950eba6..8f5bd26 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -133,6 +133,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.TreeView treeview_jumps_rj;
        [Widget] Gtk.TreeView treeview_runs;
        [Widget] Gtk.TreeView treeview_runs_interval;
+       [Widget] Gtk.TreeView treeview_runs_interval_sprint;
        [Widget] Gtk.TreeView treeview_reaction_times;
        [Widget] Gtk.TreeView treeview_pulses;
        [Widget] Gtk.TreeView treeview_multi_chronopic;
@@ -553,6 +554,7 @@ public partial class ChronoJumpWindow
                createTreeView_jumps_rj (treeview_jumps_rj);
                createTreeView_runs (treeview_runs);
                createTreeView_runs_interval (treeview_runs_interval);
+               createTreeView_runs_interval_sprint (treeview_runs_interval_sprint);
                createTreeView_reaction_times (treeview_reaction_times);
                createTreeView_pulses (treeview_pulses);
                createTreeView_multi_chronopic (false, treeview_multi_chronopic);
@@ -975,10 +977,13 @@ public partial class ChronoJumpWindow
                else if(radio_menuitem_mode_runs_simple.Active)
                        updateGraphRunsSimple();
                else if(radio_menuitem_mode_runs_intervallic.Active)
+               {
                        updateGraphRunsInterval();
+                       createTreeView_runs_interval_sprint (treeview_runs_interval_sprint);
+               }
                else if(radio_menuitem_mode_other.Active && radio_mode_reaction_times_small.Active)
                        updateGraphReactionTimes();
-               
+
                //2) change on encoder
                encoderPersonChanged();
        }
@@ -2720,6 +2725,7 @@ public partial class ChronoJumpWindow
                        createTreeView_jumps_rj (treeview_jumps_rj);
                        createTreeView_runs (treeview_runs);
                        createTreeView_runs_interval (treeview_runs_interval);
+                       createTreeView_runs_interval_sprint (treeview_runs_interval_sprint);
                        createTreeView_pulses(treeview_pulses);
                        createTreeView_reaction_times(treeview_reaction_times);
                        createTreeView_multi_chronopic(false, treeview_multi_chronopic);
@@ -6315,13 +6321,6 @@ LogB.Debug("X");
                scrolledwindow_jumps_profile_training.Visible = ! 
scrolledwindow_jumps_profile_training.Visible;
        }
 
-
-       private void on_button_sprint_clicked (object o, EventArgs args)
-       {
-               //test calling sprint.R file
-               new Sprint();
-       }
-
        /* ---------------------------------------------------------
         * ----------------  SENSITIVE GUI METHODS-------------------
         *  --------------------------------------------------------
diff --git a/src/gui/sprint.cs b/src/gui/sprint.cs
new file mode 100644
index 0000000..c0f4d51
--- /dev/null
+++ b/src/gui/sprint.cs
@@ -0,0 +1,85 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2017   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using Gtk;
+using Glade;
+using System.Text; //StringBuilder
+using System.Collections; //ArrayList
+
+
+public partial class ChronoJumpWindow
+{
+       [Widget] Gtk.Button button_sprint;
+
+       private void createTreeView_runs_interval_sprint (Gtk.TreeView tv)
+       {
+               UtilGtk.RemoveColumns(tv);
+               button_sprint.Sensitive = false;
+
+               tv.HeadersVisible=true;
+
+               int count = 0;
+               //tv.AppendColumn (Catalog.GetString ("Type"), new CellRendererText(), "text", count++);
+               //tv.AppendColumn (Catalog.GetString ("ID"), new CellRendererText(), "text", count++);
+               //tv.AppendColumn (Catalog.GetString ("Total time"), new CellRendererText(), "text", count++);
+               tv.AppendColumn ("Type", new CellRendererText(), "text", count++);
+               tv.AppendColumn ("ID", new CellRendererText(), "text", count++);
+               tv.AppendColumn ("Total time", new CellRendererText(), "text", count++);
+
+               TreeStore store = new TreeStore(typeof (string), typeof (string), typeof (string));
+               tv.Model = store;
+
+               if (currentSession == null || currentPerson == null)
+                     return;
+               
+               tv.Selection.Changed -= onTreeviewSprintSelectionEntry;
+               tv.Selection.Changed += onTreeviewSprintSelectionEntry;
+
+               string [] array = SqliteRunInterval.SelectRuns(false, currentSession.UniqueID, 
currentPerson.UniqueID, "");
+               foreach (string line in array)
+               {
+                       string [] lineSplit = line.Split(new char[] {':'});
+                       string [] lineParams = { 
+                               lineSplit[4],
+                               lineSplit[1], 
+                               Util.TrimDecimals(lineSplit[6], preferences.digitsNumber)
+                       };
+                       store.AppendValues (lineParams);
+               }
+       }
+
+       private void onTreeviewSprintSelectionEntry (object o, EventArgs args)
+       {
+               TreeModel model;
+               TreeIter iter;
+
+               // you get the iter and the model if something is selected
+               if (((TreeSelection)o).GetSelected(out model, out iter)) {
+                       button_sprint.Sensitive = true;
+               }
+       }
+
+       private void on_button_sprint_clicked (object o, EventArgs args)
+       {
+               //test calling sprint.R file
+               new Sprint();
+       }
+}
diff --git a/src/sprint.cs b/src/sprint.cs
index 9b3dd26..83782db 100644
--- a/src/sprint.cs
+++ b/src/sprint.cs
@@ -19,6 +19,7 @@
  */
 
 using System;
+using System.IO;               //for detect OS
 using System.Collections.Generic; //List<T>
 
 public class Sprint
@@ -29,6 +30,8 @@ public class Sprint
                List<string> parameters = new List<string>();
                parameters.Insert(0, "\"" + UtilEncoder.GetScriptSprint() + "\"");
 
+               writeOptionsFile();
+
                LogB.Information("\nCalling sprint.R ----->");
 
                //ExecuteProcess.Result execute_result = ExecuteProcess.run (executable, parameters);
@@ -37,4 +40,22 @@ public class Sprint
 
                LogB.Information("\n<------ Done calling sprint.R.");
        }
+
+       private void writeOptionsFile()
+       {
+               string optionsFile = Path.GetTempPath() + "Roptions.txt";
+
+               string scriptOptions =
+                       "#positions\n" +        "0;20;40;70" + "\n" +
+                       "#splitTimes\n" +       "0;2.73;4.49;6.95" + "\n" +
+                       "#personMass\n" +       "75" + "\n" +
+                       "#personHeight\n" +     "1.65" + "\n" +
+                       "#tempC\n" +            "25" + "\n";
+
+               TextWriter writer = File.CreateText(optionsFile);
+               writer.Write(scriptOptions);
+               writer.Flush();
+               writer.Close();
+               ((IDisposable)writer).Dispose();
+       }
 }
diff --git a/src/treeViewRun.cs b/src/treeViewRun.cs
index 6662490..02db774 100644
--- a/src/treeViewRun.cs
+++ b/src/treeViewRun.cs
@@ -305,5 +305,4 @@ public class TreeViewRunsInterval : TreeViewRuns
                
                return myData;
        }
-       
 }


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