[chronojump] Chronojump Profile ... more stuff



commit c0448afc496027e5d4bb10cbf18eb8833922d691
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Oct 31 00:45:58 2014 +0100

    Chronojump  Profile ... more stuff

 src/Makefile.am                |    1 +
 src/constants.cs               |    1 +
 src/genericObjects.cs          |   28 ++++++++
 src/gui/stats.cs               |   14 ++++
 src/sqlite/main.cs             |    1 -
 src/sqlite/stat.cs             |   47 ++++++++----
 src/statType.cs                |    8 ++
 src/stats/chronojumpProfile.cs |  148 ++++++++++++++++++++++++++++++++++++++++
 8 files changed, 231 insertions(+), 17 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c1f58d9..87a9b6e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,7 @@ SOURCES = \
        gui/usefulObjects.cs\
        statType.cs\
        stats/main.cs\
+       stats/chronojumpProfile.cs\
        stats/global.cs\
        stats/sjCmjAbk.cs\
        stats/sjCmjAbkPlus.cs\
diff --git a/src/constants.cs b/src/constants.cs
index f04e1b2..801017a 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -81,6 +81,7 @@ public class Constants
        public static string QIndexFormulaOnly = "tv/(tc*1.0)"; //*1.0 for having double division
        public static string DjPowerFormulaOnly = PersonSessionTable + ".weight * 9.81 * (fall/100.0 + 1.226 
* (tv*tv) ) / ((tc+tv)*1.0)";
        
+       public static string ChronojumpProfile = Catalog.GetString("Chronojump profile");
        public const string FvIndexFormula = "F/V sj+(100%)/sj *100";
        public const string IeIndexFormula = "IE (cmj-sj)/sj *100";
        public const string IRnaIndexFormula = "IRna (djna-cmj)/cmj *100";
diff --git a/src/genericObjects.cs b/src/genericObjects.cs
index c8d8b5b..45dedcd 100644
--- a/src/genericObjects.cs
+++ b/src/genericObjects.cs
@@ -157,5 +157,33 @@ public class IDNameIDDoubleListOfLists
                }
                return str;
        }
+       
+       public ArrayList GetArray() {
+               ArrayList array = new ArrayList();
+               int i = 0;
+               foreach(IDName iname in lname.l)
+                       //array.Add(iname.ToString());
+                       array.Add(iname.Name);
+
+               //read every list
+               foreach(IDDoubleList ldoublelist in ldoublelistoflists) {
+                       Log.WriteLine(ldoublelist.ToString());
+
+                       //find if exists a record on this list for the uniqueID on lname
+                       i = 0;
+                       foreach(IDName iname in lname.l) {
+                               double d = ldoublelist.FindDouble(iname.UniqueID);
+                               if(d == -1)
+                                       array[i++] += ":" + "-";
+                               else
+                                       array[i++] += ":" + d.ToString();
+                       }
+               }
+               Log.WriteLine("printing at GetArray()");
+               foreach(string str in array)
+                       Log.WriteLine(str);
+
+               return array;
+       }
 }
 
diff --git a/src/gui/stats.cs b/src/gui/stats.cs
index 6140ca6..a0a3c7f 100644
--- a/src/gui/stats.cs
+++ b/src/gui/stats.cs
@@ -188,6 +188,7 @@ public partial class ChronoJumpWindow {
        
        private static string [] comboStatsSubTypeSimpleOptions = {
                Catalog.GetString("No indexes"), 
+               Constants.ChronojumpProfile,
                Constants.FvIndexFormula,
                Constants.IeIndexFormula, 
                Constants.ArmsUseIndexFormula,
@@ -654,6 +655,10 @@ public partial class ChronoJumpWindow {
                                        SqliteJumpType.SelectJumpTypes(false, Constants.AllJumpsName, 
"nonTC", true), ""); //only select name
                                combo_stats_stat_apply_to.Sensitive = true;
                                combo_stats_stat_apply_to.Active = 0;
+                       } else if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == 
Constants.ChronojumpProfile) {
+                               UtilGtk.ComboUpdate(combo_stats_stat_apply_to, "SJ, SJl 100%, CMJ, ABK, DJa");
+                               combo_stats_stat_apply_to.Active = 0;
+                               combo_stats_stat_apply_to.Sensitive = false;
                        } else if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == 
Constants.IeIndexFormula) {
                                UtilGtk.ComboUpdate(combo_stats_stat_apply_to, "CMJ, SJ");
                                combo_stats_stat_apply_to.Active = 0;
@@ -1081,6 +1086,15 @@ public partial class ChronoJumpWindow {
                        radiobutton_stats_jumps_person_bests.Sensitive = false;
                        radiobutton_stats_jumps_person_average.Sensitive = false;
                }
+               else if(statisticType == Constants.TypeJumpsSimple && statisticSubType == 
Constants.ChronojumpProfile) {
+                       //on Chronojump profile only best jumps are used
+                       radiobutton_stats_jumps_person_bests.Active = true;
+                       //make no sensitive
+                       spin_stats_jumps_person_bests.Sensitive = false;
+                       radiobutton_stats_jumps_all.Sensitive = false;
+                       radiobutton_stats_jumps_limit.Sensitive = false;
+                       radiobutton_stats_jumps_person_average.Sensitive = false;
+               }
                else if(statisticType == Constants.TypeSessionSummary || 
                                statisticType == Constants.TypeJumperSummary || 
                                ( statisticType == Constants.TypeJumpsSimple && 
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index f3f8e35..0e6ab7d 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -453,7 +453,6 @@ class Sqlite
 
        public static bool ConvertToLastChronojumpDBVersion() {
                Log.WriteLine("SelectChronojumpProfile ()");
-               SqliteStat.SelectChronojumpProfile ();
 
                //if(checkIfIsSqlite2())
                //      convertSqlite2To3();
diff --git a/src/sqlite/stat.cs b/src/sqlite/stat.cs
index e97e823..720cdb5 100644
--- a/src/sqlite/stat.cs
+++ b/src/sqlite/stat.cs
@@ -1379,15 +1379,16 @@ Log.WriteLine(intervalSpeeds);
        }
        
        /*
+        * TODO: Al this have to be in % then need all the data to do it
        maximum values of each jump!!!!
        all with heights
        SJ100           F Max
        SJ-SJ100        F Expl
        CMJ-SJ          Cap. Elastica (hability)
        ABK-CMJ         Cap. Braços (hability)
-       DJ              F Reactiu-reflexa
+       DJa             F Reactiu-reflexa
        */
-       public static void SelectChronojumpProfile (string sessionID)
+       public static ArrayList SelectChronojumpProfile (string sessionID)
        {
                dbcon.Open();
                
@@ -1400,26 +1401,38 @@ Log.WriteLine(intervalSpeeds);
 
                //select personID and each index (using IDDoubleLists)
                IDDoubleList listFMax = fillIDDoubleList( 
-                               "SELECT personID, MAX(jump.tv * jump.tv * 1.226) FROM jump WHERE type=='SJl' 
AND jump.weight=100 " +
+                               "SELECT personID, MAX(jump.tv * jump.tv * 1.226) " +
+                               " FROM jump " +
+                               " WHERE type == 'SJl' AND jump.weight == 100 " +
                                " AND sessionID == " + sessionID + " GROUP BY personID");
        
-               IDDoubleList listFEXpl = fillIDDoubleList( 
-                               "SELECT personID, MAX(j1.tv * j1.tv * 1.226) - MAX(j2.tv * j2.tv * 1.226) AS 
myIndex " +
-                               "FROM jump WHERE j1.type == 'SJ' AND j2.type == 'SJl' AND j2.weight=100 " +
-                               " AND sessionID == " + sessionID + " GROUP BY personID");
+               IDDoubleList listFExpl = fillIDDoubleList( 
+                               "SELECT j1.personID, MAX(j1.tv * j1.tv * 1.226) - MAX(j2.tv * j2.tv * 1.226) 
AS myIndex " +
+                               " FROM jump AS j1, jump AS j2 " +
+                               " WHERE j1.type == 'SJ' AND j2.type == 'SJl' AND j2.weight=100 " +
+                               " AND j1.personID == j2.personID " +
+                               " AND j1.sessionID == " + sessionID + " AND j2.sessionID == " + sessionID + 
+                               " GROUP BY j1.personID");
 
                IDDoubleList listCElast = fillIDDoubleList( 
-                               "SELECT personID, MAX(j1.tv * j1.tv * 1.226) - MAX(j2.tv * j2.tv * 1.226) AS 
myIndex " +
-                               "FROM jump WHERE j1.type == 'CMJ' AND j2.type == 'SJ' " +
-                               " AND sessionID == " + sessionID + " GROUP BY personID");
+                               "SELECT j1.personID, MAX(j1.tv * j1.tv * 1.226) - MAX(j2.tv * j2.tv * 1.226) 
AS myIndex " +
+                               " FROM jump AS j1, jump AS j2 " +
+                               " WHERE j1.type == 'CMJ' AND j2.type == 'SJ' " +
+                               " AND j1.personID == j2.personID " +
+                               " AND j1.sessionID == " + sessionID + " AND j2.sessionID == " + sessionID + 
+                               " GROUP BY j1.personID");
        
-               IDDoubleList listCElast = fillIDDoubleList( 
-                               "SELECT personID, MAX(j1.tv * j1.tv * 1.226) - MAX(j2.tv * j2.tv * 1.226) AS 
myIndex " +
-                               "FROM jump WHERE j1.type == 'ABK' AND j2.type == 'CMJ' " +
-                               " AND sessionID == " + sessionID + " GROUP BY personID");
+               IDDoubleList listCArms = fillIDDoubleList( 
+                               "SELECT j1.personID, MAX(j1.tv * j1.tv * 1.226) - MAX(j2.tv * j2.tv * 1.226) 
AS myIndex " +
+                               " FROM jump AS j1, jump AS j2 " +
+                               " WHERE j1.type == 'ABK' AND j2.type == 'CMJ' " +
+                               " AND j1.personID == j2.personID " +
+                               " AND j1.sessionID == " + sessionID + " AND j2.sessionID == " + sessionID + 
+                               " GROUP BY j1.personID");
 
                IDDoubleList listFReact = fillIDDoubleList( 
-                               "SELECT personID, MAX(jump.tv * jump.tv * 1.226) FROM jump WHERE type=='DJa' 
" +
+                               "SELECT personID, MAX(jump.tv * jump.tv * 1.226) " +
+                               " FROM jump WHERE type == 'DJa' " +
                                " AND sessionID == " + sessionID + " GROUP BY personID");
        
                
@@ -1427,16 +1440,18 @@ Log.WriteLine(intervalSpeeds);
                array.Add(listFMax);
                array.Add(listFExpl);
                array.Add(listCElast);
-               array.Add(listCElast);
+               array.Add(listCArms);
                array.Add(listFReact);
 
                //print all     
                IDNameIDDoubleListOfLists superlist = new IDNameIDDoubleListOfLists(idNameList, array);
                Log.WriteLine("superlist");
                Log.WriteLine( Util.StringArrayToString(superlist.GetStringArray(),"\n") );
+               ArrayList arrayReturn = superlist.GetArray();
                Log.WriteLine("end of superlist");
                
                dbcon.Close();
+               return arrayReturn;
        }
 
 }
diff --git a/src/statType.cs b/src/statType.cs
index e6be07f..df165e8 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -231,6 +231,8 @@ public class StatType {
                                string indexType = "";
                                if(statisticSubType == Catalog.GetString(Constants.SubtractionBetweenTests))
                                        indexType = "subtraction";
+                               else if(statisticSubType == Constants.ChronojumpProfile) 
+                                       indexType = "ChronojumpProfile";
                                else if(statisticSubType == Constants.IeIndexFormula) 
                                        indexType = "IE";
                                else if(statisticSubType == Constants.ArmsUseIndexFormula) 
@@ -263,6 +265,12 @@ public class StatType {
                                                myStat = new GraphJumpSimpleSubtraction(myStatTypeStruct); 
                                        else 
                                                myStat = new StatJumpSimpleSubtraction(myStatTypeStruct, 
treeview_stats); 
+                               } if(indexType == "ChronojumpProfile") {
+                                       if(graph) 
+                                               //myStat = new GraphChronojumpProfile(myStatTypeStruct); 
+                                               Log.WriteLine("TODO");
+                                       else 
+                                               myStat = new StatChronojumpProfile(myStatTypeStruct, 
treeview_stats); 
                                } else if(indexType == "IE" || indexType == Constants.ArmsUseIndexName || 
                                                indexType == "IRna" || indexType == "IRa") {
                                        if(graph) 
diff --git a/src/stats/chronojumpProfile.cs b/src/stats/chronojumpProfile.cs
new file mode 100644
index 0000000..5068079
--- /dev/null
+++ b/src/stats/chronojumpProfile.cs
@@ -0,0 +1,148 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2014   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.Data;
+using Gtk;
+using System.Collections; //ArrayList
+using Mono.Unix;
+
+
+public class StatChronojumpProfile : Stat
+{
+       protected string [] columnsString = { 
+               Catalog.GetString("Jumper"), 
+               Catalog.GetString("F max"), 
+               Catalog.GetString("F explossive"), 
+               Catalog.GetString("Cap. Elast"),
+               Catalog.GetString("Cap. Arms"), 
+               Catalog.GetString("F reactive") };
+       
+       //if this is not present i have problems like (No overload for method `xxx' takes `0' arguments) with 
some inherited classes
+       public StatChronojumpProfile () 
+       {
+               this.showSex = false;
+               this.statsJumpsType = 0;
+               this.limit = 0;
+       }
+
+       public StatChronojumpProfile (StatTypeStruct myStatTypeStruct, Gtk.TreeView treeview) 
+       {
+               completeConstruction (myStatTypeStruct, treeview);
+               
+               this.dataColumns = 5;   //for simplesession
+               
+               //if(sessions.Count > 1) {
+               //      store = getStore(sessions.Count +3); //+3 (for jumper, the AVG horizontal and SD 
horizontal)
+               //} else {
+                       store = getStore(dataColumns +1); //5 data columns + jumper name
+               //}
+               
+               if(toReport) {
+                       reportString = prepareHeadersReport(columnsString);
+               } else {
+                       treeview.Model = store;
+                       prepareHeaders(columnsString);
+               }
+       }
+       
+       public override void PrepareData() 
+       {
+               string sessionString = obtainSessionSqlString(sessions, "jump");
+               bool multisession = false;
+               //if(sessions.Count > 1) {
+               //      multisession = true;
+               //}
+
+               string indexType = "ChronojumpProfile";
+               /*
+               if(statsJumpsType == 3) { //avg of each jumper
+                       if(multisession) {
+                               string operation = "AVG";
+                               processDataMultiSession ( 
+                                               SqliteStat.DjIndexes(indexType, sessionString, multisession, 
+                                                       operation, jumpType, showSex), 
+                                               true, sessions.Count);
+                       } else {
+                               string operation = "AVG";
+                               processDataSimpleSession ( cleanDontWanted (
+                                                       SqliteStat.DjIndexes(indexType, sessionString, 
multisession, 
+                                                               operation, jumpType, showSex), 
+                                                       statsJumpsType, limit),
+                                               true, dataColumns);
+                       }
+               } else {
+               */
+                       //if more than on session, show only the avg or max of each jump/jumper
+                       /*
+                       if(multisession) {
+                               string operation = "MAX";
+                               processDataMultiSession ( SqliteStat.DjIndexes(indexType, sessionString, 
multisession, 
+                                                       operation, jumpType, showSex),  
+                                               true, sessions.Count);
+                       } else {
+                       */
+                               //string operation = ""; //no need of "MAX", there's an order by jump.tv desc
+                                                       //and clenaDontWanted will do his work
+                               //processDataSimpleSession ( cleanDontWanted (
+                               //                      SqliteStat.DjIndexes(indexType, sessionString, 
multisession, 
+                               //                              operation, jumpType, showSex), 
+                               //                      statsJumpsType, limit),
+                               //              true, dataColumns);
+
+                               string [] sessionFull = sessions[0].ToString().Split(new char[] {':'});
+                               //SqliteStat.SelectChronojumpProfile(sessionFull[0]);
+                               processDataSimpleSession (SqliteStat.SelectChronojumpProfile(sessionFull[0]), 
true, dataColumns);
+                       //}
+               //}
+       }
+               
+       public override string ToString () 
+       {
+               /*
+               string selectedValuesString = "";
+               if(statsJumpsType == 0) { //all jumps
+                       selectedValuesString = allValuesString; 
+               } else if(statsJumpsType == 1) { //limit
+                       selectedValuesString = string.Format(Catalog.GetPluralString(
+                                               "First value", "First {0} values", limit), limit);
+               } else if(statsJumpsType == 2) { //best of each jumper
+                       selectedValuesString = string.Format(Catalog.GetPluralString(
+                                               "Max value of each person", "Max {0} values of each person", 
limit), limit);
+               } else if(statsJumpsType == 3) { //avg of each jumper
+                       selectedValuesString = avgValuesString; 
+               }  
+
+               string mySessionString = "";
+               if(sessions.Count > 1) {
+                       mySessionString =  Catalog.GetString (" various sessions "); 
+               } else {
+                       string [] strFull = sessions[0].ToString().Split(new char[] {':'});
+                       mySessionString =  Catalog.GetString (" session ") + 
+                               strFull[0] + "(" + strFull[2] + ")";
+               }
+
+               return string.Format(Catalog.GetString("{0} in Q Index [tf/tc] applied to {1} on {2}"), 
selectedValuesString, jumpType, mySessionString);
+               */
+               return "";
+       }
+}
+
+


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