Commit abd71456 authored by Xavier de Blas's avatar Xavier de Blas

from stats/reactive/evolution it's possible to find the best subjump or the...

from stats/reactive/evolution it's possible to find the best subjump or the 'n' best consecutives subjumps.
Done for stats and report (currently not possible to implement in graphs) (closes task 295)
parent 03c71ee1
CHANGELOG:
22 set 2005
from stats/reactive/evolution it's possible to find the best subjump
or the 'n' best consecutives subjumps. Done for stats and report (currently not possible to implement in
graphs) (closes task 295)
21 set 2005
finished presentation of stats, closed task 295
......
No preview for this file type
......@@ -7979,6 +7979,63 @@ best's</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox_mark_consecutives">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkCheckButton" id="checkbutton_mark_consecutives">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">mark best 'n' consecutives</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">mark consecutives</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="clicked" handler="on_checkbutton_mark_consecutives_clicked" last_modification_time="Thu, 22 Sep 2005 17:46:29 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton_mark_consecutives">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">True</property>
<property name="wrap">False</property>
<property name="adjustment">5 1 100 1 10 10</property>
<signal name="changed" handler="on_spinbutton_mark_consecutives_changed" last_modification_time="Thu, 22 Sep 2005 17:49:32 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</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>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
</child>
</widget>
......@@ -8123,7 +8180,7 @@ best's</property>
<child>
<widget class="GtkButton" id="button_add_to_report">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">currently does not do nothing</property>
<property name="tooltip" translatable="yes">Add this statistic and its graph to report window</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
......@@ -8216,6 +8273,7 @@ best's</property>
<child>
<widget class="GtkButton" id="button_graph">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Graph this statistic</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
......
......@@ -147,11 +147,9 @@ public class ReportWindow {
string sessionsAsAString = "";
for (int i=0; i < sendSelectedSessions.Count ; i++) {
if(i>0) {
//sessionsAsAString += "\n";
sessionsAsAString += ":";
}
string [] myStrFull = sendSelectedSessions[i].ToString().Split(new char[] {':'});
//sessionsAsAString += myStrFull[0] + ":" + myStrFull[1] + ":" + myStrFull[2]; //id, name, date
sessionsAsAString += myStrFull[0];
}
......
......@@ -60,6 +60,10 @@ public class StatsWindow {
[Widget] Gtk.TextView textview_enunciate;
[Widget] Gtk.ScrolledWindow scrolledwindow_enunciate;
[Widget] Gtk.CheckButton checkbutton_show_enunciate;
[Widget] Gtk.Box hbox_mark_consecutives;
[Widget] Gtk.CheckButton checkbutton_mark_consecutives;
[Widget] Gtk.SpinButton spinbutton_mark_consecutives;
int prefsDigitsNumber;
bool heightPreferred;
......@@ -141,6 +145,9 @@ public class StatsWindow {
//textview_enunciate.Hide();
//scrolledwindow_enunciate.Hide();
spinbutton_mark_consecutives.Sensitive = false;
hbox_mark_consecutives.Hide();
}
......@@ -287,6 +294,12 @@ public class StatsWindow {
combo_stats_stat_apply_to.Sensitive = false;
}
}
if (combo_stats_stat_subtype.Entry.Text == Catalog.GetString("Evolution") ) {
hbox_mark_consecutives.Show();
} else {
hbox_mark_consecutives.Hide();
}
}
//way of accessing from chronojump.cs
......@@ -337,6 +350,10 @@ public class StatsWindow {
sendSelectedSessions = selectedSessions;
}
int rj_evolution_mark_consecutives = -1;
if(checkbutton_mark_consecutives.Active) {
rj_evolution_mark_consecutives = Convert.ToInt32 ( spinbutton_mark_consecutives.Value );
}
StatType myStatType = new StatType(
statisticType,
......@@ -350,6 +367,7 @@ public class StatsWindow {
limit,
heightPreferred,
weightStatsPercent,
rj_evolution_mark_consecutives,
graph,
toReport
);
......@@ -424,6 +442,26 @@ public class StatsWindow {
}
}
private void on_checkbutton_mark_consecutives_clicked(object o, EventArgs args) {
if(checkbutton_mark_consecutives.Active) {
spinbutton_mark_consecutives.Sensitive = true;
} else {
spinbutton_mark_consecutives.Sensitive = false;
}
if (statsAutomatic) {
fillTreeView_stats(false);
}
}
void on_spinbutton_mark_consecutives_changed (object o, EventArgs args) {
if (statsAutomatic) {
fillTreeView_stats(false);
}
}
private void update_stats_widgets_sensitiveness() {
string statisticType = combo_stats_stat_type.Entry.Text;
string statisticSubType = combo_stats_stat_subtype.Entry.Text;
......@@ -601,6 +639,10 @@ public class StatsWindow {
//in the first the value of Entry.Text is "";
return;
} else {
if(checkbutton_mark_consecutives.Active) {
statisticSubType += "." + ( spinbutton_mark_consecutives.Value ).ToString();
}
string statisticApplyTo = combo_stats_stat_apply_to.Entry.Text;
if(statisticApplyTo.Length == 0) {
statisticApplyTo = "-";
......
......@@ -297,14 +297,15 @@ public class Report : ExportSession
statsJumpsType = 3;
}
/*
myHeaderStat += strJumpsType[0];
if(limit != -1) {
myHeaderStat += " (" + limit.ToString() + ")";
//obtain marked jumps of rj evolution if needed
int rj_evolution_mark_consecutives = -1;
if(strFull[1].StartsWith(Catalog.GetString("Evolution."))) {
string [] strEvo = strFull[1].Split(new char[] {'.'});
strFull[1] = strEvo[0];
rj_evolution_mark_consecutives = Convert.ToInt32(strEvo[1]);
}
*/
//myHeaderStat += "\n<p><TABLE cellpadding=2 cellspacing=2 class=\"empty\"><tr><td>\n";
myHeaderStat += "\n<p><TABLE cellpadding=2 cellspacing=2><tr><td>\n";
writer.WriteLine(myHeaderStat);
......@@ -312,6 +313,7 @@ public class Report : ExportSession
bool allFine;
//report of stat
myStatType = new StatType(
strFull[0], //statisticType
strFull[1], //statisticSubType
......@@ -323,6 +325,7 @@ public class Report : ExportSession
limit,
heightPreferred,
weightStatsPercent,
rj_evolution_mark_consecutives,
false, //graph
toReport,
writer,
......@@ -330,6 +333,8 @@ public class Report : ExportSession
);
allFine = myStatType.ChooseStat();
string myEnunciate ="<tr><td colspan=\"2\">" + myStatType.Enunciate + "</td></tr>";
writer.WriteLine("</td><td>");
......@@ -345,6 +350,7 @@ public class Report : ExportSession
limit,
heightPreferred,
weightStatsPercent,
rj_evolution_mark_consecutives,
true, //graph
toReport,
writer,
......@@ -353,7 +359,10 @@ public class Report : ExportSession
allFine = myStatType.ChooseStat();
writer.WriteLine("<tr><td colspan=\"2\">" + myStatType.Enunciate + "</td></tr>");
//enunciate is prented here and not before
//because myStatType of a graph doesn't know the numContinuous value
//needed for enunciate in rj evolution statistic
writer.WriteLine(myEnunciate);
writer.WriteLine("</table>");
}
}
......
......@@ -67,7 +67,8 @@ public class StatType {
int statsJumpsType;
int limit;
bool heightPreferred;
bool weightStatsPercent;
bool weightStatsPercent;
int rj_evolution_mark_consecutives;
bool graph;
bool toReport;
TextWriter writer;
......@@ -91,7 +92,7 @@ public class StatType {
public StatType (string statisticType, string statisticSubType, string statisticApplyTo, Gtk.TreeView treeview_stats,
ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
bool graph, bool toReport)
int rj_evolution_mark_consecutives, bool graph, bool toReport)
{
//some of this will disappear when we use myStatTypeStruct in all classes:
this.statisticType = statisticType;
......@@ -105,6 +106,7 @@ public class StatType {
this.limit = limit;
this.heightPreferred = heightPreferred;
this.weightStatsPercent = weightStatsPercent;
this.rj_evolution_mark_consecutives = rj_evolution_mark_consecutives;
this.graph = graph;
this.toReport = toReport;
......@@ -121,6 +123,7 @@ public class StatType {
public StatType (string statisticType, string statisticSubType, string statisticApplyTo,
ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
int rj_evolution_mark_consecutives,
bool graph, bool toReport, TextWriter writer, string fileName)
{
this.statisticType = statisticType;
......@@ -133,6 +136,7 @@ public class StatType {
this.limit = limit;
this.heightPreferred = heightPreferred;
this.weightStatsPercent = weightStatsPercent;
this.rj_evolution_mark_consecutives = rj_evolution_mark_consecutives;
this.graph = graph;
this.toReport = toReport;
this.writer = writer;
......@@ -280,9 +284,10 @@ public class StatType {
else if(statisticSubType == Catalog.GetString("Evolution"))
{
if(graph) {
//myStat = new GraphRjEvolution (myStatTypeStruct, rj_evolution_mark_consecutives);
myStat = new GraphRjEvolution (myStatTypeStruct);
} else {
myStat = new StatRjEvolution(myStatTypeStruct, treeview_stats);
myStat = new StatRjEvolution(myStatTypeStruct, rj_evolution_mark_consecutives, treeview_stats);
}
}
}
......
......@@ -35,9 +35,16 @@ public class GraphRjEvolution : StatRjEvolution
protected string operation;
private Random myRand = new Random();
/*
* if one day i found the way of plotting different (single plots) i will use it for the numContinuous
*/
//public GraphRjEvolution (StatTypeStruct myStatTypeStruct, int numContinuous)
public GraphRjEvolution (StatTypeStruct myStatTypeStruct)
{
completeConstruction (myStatTypeStruct, treeview);
//this.numContinuous = numContinuous;
string sessionString = obtainSessionSqlString(sessions);
//we need to know the reactive with more jumps for prepare columns
......@@ -74,6 +81,15 @@ public class GraphRjEvolution : StatRjEvolution
protected override void printData (string [] statValues)
{
/*
if(numContinuous != -1) {
int bestPos = findBestContinuous(statValues, numContinuous);
if(bestPos != -1) {
statValues = markBestContinuous(statValues, numContinuous, bestPos);
}
}
*/
GraphSerie serieTc = new GraphSerie();
GraphSerie serieTv = new GraphSerie();
......
......@@ -75,6 +75,8 @@ public class Stat
protected string allValuesString = "All values";
protected string avgValuesString = "Avg values of each jumper";
protected int numContinuous; //for stats rj evolution
//if this is not present i have problems like (No overload for method `xxx' takes `0' arguments) with some inherited classes
public Stat ()
......
......@@ -38,9 +38,11 @@ public class StatRjEvolution : Stat
this.limit = 0;
}
public StatRjEvolution (StatTypeStruct myStatTypeStruct, Gtk.TreeView treeview)
public StatRjEvolution (StatTypeStruct myStatTypeStruct, int numContinuous, Gtk.TreeView treeview)
{
completeConstruction (myStatTypeStruct, treeview);
this.numContinuous = numContinuous;
string sessionString = obtainSessionSqlString(sessions);
......@@ -68,6 +70,86 @@ public class StatRjEvolution : Stat
prepareHeaders(columnsString);
}
}
protected int findBestContinuous(string [] statValues, int numContinuous)
{
//if numContinuous is 3, we check the best consecutive three tc,tv values
int bestPos=-1; //position where the three best pair values start
//will return -1 if less tha three jumps
double bestCount=-10000; //best value found of 3 pairs
//read all values in pairs tc,tv
//start in pos 2 because first is name, second is index
//end in Length-numContinuous*2 because we should not count only the last tc,tv pair or the last two, only the last three
//end in -1 because last value is fall
for ( int i=2; i < statValues.Length -numContinuous*2 -1 ; i=i+2 )
{
double myCount = 0;
bool jumpFinished = false;
//read the n consecutive values
for (int j=i; j < i + numContinuous*2 ; j=j+2 )
{
if( statValues[j] == "-" || statValues[j+1] == "-" ) {
jumpFinished = true;
break;
}
double tc = Convert.ToDouble(statValues[i]);
double tv = Convert.ToDouble(statValues[i+1]);
myCount += (tv * 100) / tc;
}
//Console.WriteLine("i{0}, myCount{1}, bestCount{2}", i, myCount, bestCount);
//if found a max, record it
if(myCount > bestCount && !jumpFinished) {
bestCount = myCount;
bestPos = i;
//Console.WriteLine("best i{0}", i);
}
}
return bestPos;
}
protected string [] markBestContinuous(string [] statValues, int numContinuous, int bestPos) {
if(toReport) {
for ( int i=0; i < statValues.Length ; i=i+2 ) {
if(i >= bestPos && i < bestPos+numContinuous*2) {
//Console.WriteLine("i{0}, bp{1}, svi{2}, svi+1{3}", i, bestPos, statValues[i], statValues[i+1]);
statValues[i] = "<font color=\"red\">" + statValues[i] + "</font>";
statValues[i+1] = "<font color=\"red\">" + statValues[i+1] + "</font>";
}
}
} else {
// this marks the first and the last with '[' and ']'
statValues[bestPos] = "[" + statValues[bestPos];
statValues[bestPos + (numContinuous*2) -1] = statValues[bestPos + (numContinuous*2) -1] + "]";
}
return statValues;
}
protected override void printData (string [] statValues)
{
if(numContinuous != -1) {
int bestPos = findBestContinuous(statValues, numContinuous);
if(bestPos != -1) {
statValues = markBestContinuous(statValues, numContinuous, bestPos);
}
}
if(toReport) {
reportString += "<TR>";
for (int i=0; i < statValues.Length ; i++) {
reportString += "<TD>" + statValues[i] + "</TD>";
}
reportString += "</TR>\n";
} else {
iter = store.AppendValues (statValues);
}
}
public override void PrepareData()
{
......@@ -76,24 +158,16 @@ public class StatRjEvolution : Stat
bool multisession = false;
//we send maxJumps for make all the results of same length (fill it with '-'s)
if(statsJumpsType == 3) { //avg of each jumper
string operation = "AVG";
processDataSimpleSession ( cleanDontWanted (
SqliteStat.RjEvolution(sessionString, multisession,
//"AVG(", ")", showSex, maxJumps),
operation, jumpType, showSex, maxJumps),
statsJumpsType, limit),
false, dataColumns); //don't print AVG and SD at end of row (has no sense)
} else {
string operation = ""; //no need of "MAX", there's an order by (index) desc
//and clenaDontWanted will do his work
processDataSimpleSession ( cleanDontWanted (
SqliteStat.RjEvolution(sessionString, multisession,
//"", "", showSex, maxJumps),
//
// cannot be avg in this statistic
string operation = ""; //no need of "MAX", there's an order by (index) desc
//and clenaDontWanted will do his work
processDataSimpleSession ( cleanDontWanted (
SqliteStat.RjEvolution(sessionString, multisession,
operation, jumpType, showSex, maxJumps),
statsJumpsType, limit),
false, dataColumns); //don't print AVG and SD at end of row (has no sense)
}
statsJumpsType, limit),
false, dataColumns); //don't print AVG and SD at end of row (has no sense)
}
public override string ToString ()
......@@ -121,8 +195,13 @@ public class StatRjEvolution : Stat
mySessionString = Catalog.GetString (" session ") +
strFull[0] + "(" + strFull[2] + ")";
}
string bestResalted = "";
if(numContinuous != -1) {
bestResalted = string.Format(Catalog.GetString(" (best {0} consecutive jumps marked using [tv/tc *100])"), numContinuous);
}
return string.Format(Catalog.GetString("{0} in Rj Evolution applied to {1} on {2}"), selectedValuesString, jumpType, mySessionString);
return string.Format(Catalog.GetString("{0} in Rj Evolution applied to {1} on {2}{3}"), selectedValuesString, jumpType, mySessionString, bestResalted);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment