[chronojump] doing jump subtraction stats



commit 7e161190e0a7a33ce11a3bd87cfde7c11072acfc
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Feb 21 17:15:14 2011 +0100

    doing jump subtraction stats

 glade/chronojump.glade |   68 ++++++++++++++++++++++++++++++++++++++++++-
 src/constants.cs       |    1 +
 src/gui/stats.cs       |   75 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/statType.cs        |   32 +++++++++++---------
 src/stats/ieIub.cs     |   18 +-----------
 src/stats/main.cs      |   14 +++++++++
 6 files changed, 174 insertions(+), 34 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 65e9e19..e832f6d 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -3692,7 +3692,7 @@ options</property>
               <widget class="GtkTable" id="table44">
                 <property name="visible">True</property>
                 <property name="border_width">6</property>
-                <property name="n_rows">4</property>
+                <property name="n_rows">5</property>
                 <property name="n_columns">2</property>
                 <property name="column_spacing">10</property>
                 <property name="row_spacing">8</property>
@@ -3752,7 +3752,7 @@ options</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label162">
+                  <widget class="GtkLabel" id="label_apply_to">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">Apply to</property>
@@ -3830,6 +3830,70 @@ options</property>
                 <child>
                   <placeholder/>
                 </child>
+                <child>
+                  <widget class="GtkHBox" id="hbox_subtraction_between">
+                    <property name="visible">True</property>
+                    <child>
+                      <widget class="GtkHBox" id="hbox_subtraction_between_1">
+                        <property name="visible">True</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">and</property>
+                        <property name="use_markup">True</property>
+                      </widget>
+                      <packing>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkHBox" id="hbox_subtraction_between_2">
+                        <property name="visible">True</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_subtraction_between">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Subtraction between</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="tab_fill">False</property>
diff --git a/src/constants.cs b/src/constants.cs
index f68b380..ceedb0e 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -52,6 +52,7 @@ public class Constants
 	public const string FvIndexFormula = "F/V sj+(100%)/sj *100";
 	public const string IeIndexFormula = "IE (cmj-sj)/sj *100";
 	public const string IubIndexFormula = "IUB (abk-cmj)/cmj *100";
+	public const string SubtractionBetweenTests = "Subtraction between tests";
 
 	//tests types (dont' use character '-' will be used multimedia file names)
 	public enum TestTypes { JUMP, JUMP_RJ, RUN, RUN_I, RT, PULSE, MULTICHRONOPIC }
diff --git a/src/gui/stats.cs b/src/gui/stats.cs
index d44dc25..8910e30 100644
--- a/src/gui/stats.cs
+++ b/src/gui/stats.cs
@@ -42,6 +42,7 @@ public class StatsWindow {
 	[Widget] Gtk.ComboBox combo_stats_stat_type;
 	[Widget] Gtk.ComboBox combo_stats_stat_subtype;
 	[Widget] Gtk.ComboBox combo_stats_stat_apply_to;
+	[Widget] Gtk.Label label_apply_to;
 	[Widget] Gtk.CheckButton checkbutton_stats_sex;
 	[Widget] Gtk.CheckButton checkbutton_stats_always;
 	[Widget] Gtk.Button button_stats;
@@ -65,6 +66,13 @@ public class StatsWindow {
 	[Widget] Gtk.Box hbox_mark_consecutives;
 	[Widget] Gtk.CheckButton checkbutton_mark_consecutives;
 	[Widget] Gtk.SpinButton spinbutton_mark_consecutives;
+		
+	[Widget] Gtk.Label label_subtraction_between;
+	[Widget] Gtk.Box hbox_subtraction_between;
+	[Widget] Gtk.Box hbox_subtraction_between_1;
+	[Widget] Gtk.Box hbox_subtraction_between_2;
+	[Widget] Gtk.ComboBox combo_subtraction_between_1;
+	[Widget] Gtk.ComboBox combo_subtraction_between_2;
 	
 	[Widget] Gtk.Box hbox_combo_select_checkboxes;
 	[Widget] Gtk.ComboBox combo_select_checkboxes;
@@ -149,6 +157,7 @@ public class StatsWindow {
 		Constants.FvIndexFormula,
 		Constants.IeIndexFormula, 
 		Constants.IubIndexFormula,
+		Catalog.GetString(Constants.SubtractionBetweenTests),
 		Constants.PotencyLewisFormula,
 		Constants.PotencyHarmanFormula,
 		Constants.PotencySayersSJFormula,
@@ -234,6 +243,7 @@ public class StatsWindow {
 		createComboStatsType();
 		createComboStatsSubType();
 		createComboStatsApplyTo();
+		createComboStatsSubtractionBetweenTests();
 	
 		createComboGraphType();
 		
@@ -346,6 +356,20 @@ public class StatsWindow {
 		hbox_combo_stats_stat_apply_to.ShowAll();
 		combo_stats_stat_apply_to.Sensitive = true;
 	}
+	
+	private void createComboStatsSubtractionBetweenTests() {
+		combo_subtraction_between_1 = ComboBox.NewText ();
+		combo_subtraction_between_1.Changed += new EventHandler (on_combo_subtraction_between_1_changed);
+		hbox_subtraction_between_1.PackStart(combo_subtraction_between_1, true, true, 0);
+		hbox_subtraction_between_1.ShowAll();
+		combo_subtraction_between_1.Sensitive = true;
+		
+		combo_subtraction_between_2 = ComboBox.NewText ();
+		combo_subtraction_between_2.Changed += new EventHandler (on_combo_subtraction_between_2_changed);
+		hbox_subtraction_between_2.PackStart(combo_subtraction_between_2, true, true, 0);
+		hbox_subtraction_between_2.ShowAll();
+		combo_subtraction_between_2.Sensitive = true;
+	}
 
 	private void createComboSelectCheckboxes() {
 		combo_select_checkboxes = ComboBox.NewText ();
@@ -595,6 +619,7 @@ public class StatsWindow {
 	}
 
 	private void updateComboStatsSubType() {
+		subtraction_between_tests_show(false);
 		if (UtilGtk.ComboGetActive(combo_stats_stat_type) == Constants.TypeJumpsSimple ) 
 		{
 			if(UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Catalog.GetString("No indexes")) {
@@ -615,6 +640,14 @@ public class StatsWindow {
 				UtilGtk.ComboUpdate(combo_stats_stat_apply_to, "SJl(100%), SJ");
 				combo_stats_stat_apply_to.Active = 0;
 				combo_stats_stat_apply_to.Sensitive = false;
+			} else if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Catalog.GetString(Constants.SubtractionBetweenTests)) {
+				UtilGtk.ComboUpdate(combo_subtraction_between_1, 
+					SqliteJumpType.SelectJumpTypes("", "", true), ""); //only select name
+				UtilGtk.ComboUpdate(combo_subtraction_between_2, 
+					SqliteJumpType.SelectJumpTypes("", "", true), ""); //only select name
+				subtraction_between_tests_show(true);
+				combo_stats_stat_apply_to.Active = 0;
+				combo_stats_stat_apply_to.Sensitive = true;
 			} else if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == Constants.PotencySayersSJFormula) {
 				combo_stats_stat_apply_to.Active = 
 					UtilGtk.ComboUpdate(combo_stats_stat_apply_to, 
@@ -713,6 +746,11 @@ public class StatsWindow {
 		string statisticType = UtilGtk.ComboGetActive(combo_stats_stat_type);
 		string statisticSubType = UtilGtk.ComboGetActive(combo_stats_stat_subtype);
 		string statisticApplyTo = UtilGtk.ComboGetActive(combo_stats_stat_apply_to);
+			
+		if (UtilGtk.ComboGetActive(combo_stats_stat_subtype) == 
+				Catalog.GetString(Constants.SubtractionBetweenTests))
+			statisticApplyTo = UtilGtk.ComboGetActive(combo_subtraction_between_1) + 
+				":" + UtilGtk.ComboGetActive(combo_subtraction_between_2);
 
 		if(statsColumnsToRemove && !graph) {
 			statsRemoveColumns();
@@ -942,7 +980,27 @@ public class StatsWindow {
 		//button_stats.Sensitive = true;
 		button_stats.Visible = true;
 	}
-
+				
+	private void subtraction_between_tests_show(bool show) {
+		if(show) {
+			label_subtraction_between.Show();
+			hbox_subtraction_between.Show();
+			hbox_subtraction_between_1.Show();
+			hbox_subtraction_between_2.Show();
+
+			//subtraction doesn't uses the combo: apply to
+			label_apply_to.Hide();
+			hbox_combo_stats_stat_apply_to.Hide();
+		} else {
+			label_subtraction_between.Hide();
+			hbox_subtraction_between.Hide();
+			hbox_subtraction_between_1.Hide();
+			hbox_subtraction_between_2.Hide();
+	
+			label_apply_to.Show();
+			hbox_combo_stats_stat_apply_to.Show();
+		}
+	}
 
 	private void on_checkbutton_show_enunciate_clicked(object o, EventArgs args) {
 		if (checkbutton_show_enunciate.Active) {
@@ -1104,6 +1162,21 @@ public class StatsWindow {
 		}
 	}
 	
+	private void on_combo_subtraction_between_1_changed(object o, EventArgs args) {
+		Log.WriteLine(UtilGtk.ComboGetActive(combo_subtraction_between_1));
+		string myText = UtilGtk.ComboGetActive(combo_subtraction_between_1);
+		string myText2 = UtilGtk.ComboGetActive(combo_subtraction_between_2);
+		if (myText != "" && (myText2 != "") ) 
+			fillTreeView_stats(false);
+	}
+	private void on_combo_subtraction_between_2_changed(object o, EventArgs args) {
+		Log.WriteLine(UtilGtk.ComboGetActive(combo_subtraction_between_2));
+		string myText = UtilGtk.ComboGetActive(combo_subtraction_between_1);
+		string myText2 = UtilGtk.ComboGetActive(combo_subtraction_between_2);
+		if (myText != "" && (myText2 != "") ) 
+			fillTreeView_stats(false);
+	}
+	
 	private void on_radiobuttons_stat_session_toggled (object o, EventArgs args)
 	{
 		if(o == (object) radiobutton_current_session) 
diff --git a/src/statType.cs b/src/statType.cs
index 4bb69cc..0047c23 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -234,13 +234,15 @@ public class StatType {
 			if(statisticSubType != Catalog.GetString("No indexes")) 
 			{
 				string indexType = "";
-				if(statisticSubType == Constants.IeIndexFormula) {
+				if(statisticSubType == Catalog.GetString(Constants.SubtractionBetweenTests))
+					indexType = "subtraction";
+				else if(statisticSubType == Constants.IeIndexFormula) 
 					indexType = "IE";
-				} else if(statisticSubType == Constants.IubIndexFormula) {
+				else if(statisticSubType == Constants.IubIndexFormula) {
 					indexType = "IUB";
-				} else if(statisticSubType == Constants.FvIndexFormula) {
+				else if(statisticSubType == Constants.FvIndexFormula) {
 					indexType = "F/V";
-				} else if(
+				else if(
 						statisticSubType == Constants.PotencyLewisFormula ||
 						statisticSubType == Constants.PotencyHarmanFormula ||
 						statisticSubType == Constants.PotencySayersSJFormula ||
@@ -257,25 +259,27 @@ public class StatType {
 					indexType = statisticSubType;
 				}
 			
-				if(indexType == "IE" || indexType == "IUB") {
-					if(graph) {
+				if(indexType == "subtraction") {
+					if(graph) 
+//						myStat = new GraphStatJumpSimpleSubtraction (myStatTypeStruct);
+					else 
+						myStat = new StatJumpSimpleSubtraction(myStatTypeStruct, treeview_stats); 
+				} else if(indexType == "IE" || indexType == "IUB") {
+					if(graph) 
 						myStat = new GraphIeIub (myStatTypeStruct, indexType);
-					} else {
+					else 
 						myStat = new StatIeIub(myStatTypeStruct, treeview_stats, indexType); 
-					}
 				} else if(indexType == "F/V") {
-					if(graph) {
+					if(graph) 
 						myStat = new GraphFv (myStatTypeStruct, indexType);
-					} else {
+					else 
 						myStat = new StatFv(myStatTypeStruct, treeview_stats, indexType); 
-					}
 				} else {
 					//indexType = (Potency sayers or lewis);
-					if(graph) {
+					if(graph) 
 						myStat = new GraphPotency(myStatTypeStruct, indexType); 
-					} else {
+					else 
 						myStat = new StatPotency(myStatTypeStruct, treeview_stats, indexType); 
-					}
 				}
 			}
 			else {
diff --git a/src/stats/ieIub.cs b/src/stats/ieIub.cs
index 0c69965..0ddcf1e 100644
--- a/src/stats/ieIub.cs
+++ b/src/stats/ieIub.cs
@@ -74,25 +74,9 @@ public class StatIeIub : Stat
 		}
 	}
 	
-	//session string must be different for indexes
-	protected string obtainSessionSqlStringIndexes(ArrayList sessions)
-	{
-		string newStr = "WHERE (";
-		for (int i=0; i < sessions.Count; i++) {
-			string [] stringFullResults = sessions[i].ToString().Split(new char[] {':'});
-			newStr = newStr + " (j1.sessionID == " + stringFullResults[0] + 
-				" AND j2.sessionID == " + stringFullResults[0] + ")";
-			if (i+1 < sessions.Count) {
-				newStr = newStr + " OR ";
-			}
-		}
-		newStr = newStr + ") ";
-		return newStr;		
-	}
-	
 	public override void PrepareData() 
 	{
-		string sessionString = obtainSessionSqlStringIndexes(sessions);
+		string sessionString = obtainSessionSqlStringTwoTests(sessions);
 		bool multisession = false;
 		if(sessions.Count > 1) {
 			multisession = true;
diff --git a/src/stats/main.cs b/src/stats/main.cs
index b7fdcbc..fdee9c7 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -424,6 +424,20 @@ public class Stat
 		return newStr;		
 	}
 	
+	protected string obtainSessionSqlStringTwoTests(ArrayList sessions, string tableName)
+	{
+		string newStr = "WHERE (";
+		for (int i=0; i < sessions.Count; i++) {
+			string [] stringFullResults = sessions[i].ToString().Split(new char[] {':'});
+			newStr = newStr + " " + tableName + ".sessionID == " + stringFullResults[0];
+			if (i+1 < sessions.Count) {
+				newStr = newStr + " OR ";
+			}
+		}
+		newStr = newStr + ") ";
+		return newStr;		
+	}
+	
 	public virtual void PrepareData () {
 	}
 



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