[chronojump] Improving jumps execute graph (2)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Improving jumps execute graph (2)
- Date: Sun, 17 Apr 2016 10:22:37 +0000 (UTC)
commit d2ab5162fae78c65ae64d5ff5a324ebb69ccf62b
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Apr 17 11:27:01 2016 +0200
Improving jumps execute graph (2)
src/gui/eventExecute.cs | 171 +++++++++++++++++++++++++++++----------------
src/gui/usefulObjects.cs | 54 ++++++---------
src/sqlite/session.cs | 12 +++-
src/utilEncoder.cs | 2 +-
4 files changed, 143 insertions(+), 96 deletions(-)
---
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index e139259..00b202f 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -193,6 +193,7 @@ public partial class ChronoJumpWindow
//for writing text
Pango.Layout layout;
+ Pango.Layout layoutMid;
Pango.Layout layoutBig;
static EventGraphConfigureWindow eventGraphConfigureWin;
@@ -276,6 +277,9 @@ public partial class ChronoJumpWindow
layout = new Pango.Layout (event_execute_drawingarea.PangoContext);
layout.FontDescription = Pango.FontDescription.FromString ("Courier 7");
+
+ layoutMid = new Pango.Layout (event_execute_drawingarea.PangoContext);
+ layoutMid.FontDescription = Pango.FontDescription.FromString ("Courier 11");
layoutBig = new Pango.Layout (event_execute_drawingarea.PangoContext);
layoutBig.FontDescription = Pango.FontDescription.FromString ("Courier 14");
@@ -578,6 +582,7 @@ public partial class ChronoJumpWindow
//if max value of graph is automatic
if(eventGraphConfigureWin.Max == -1) {
+ /*
maxValue = Util.GetMax(
eventGraph.tv.ToString() + "=" +
eventGraph.tvPersonAVGAtSQL.ToString() + "=" +
eventGraph.tvSessionAVGAtSQL.ToString() + "=" +
@@ -590,12 +595,16 @@ public partial class ChronoJumpWindow
if(Convert.ToDouble(jump[6]) > maxValue)
maxValue = Convert.ToDouble(jump[6]); //tc
}
+ */
+
+ maxValue = eventGraph.sessionMAXAtSQL;
} else {
maxValue = eventGraphConfigureWin.Max;
topMargin = 0;
}
//if min value of graph is automatic
+ /*
if(eventGraphConfigureWin.Min == -1) {
string myString = eventGraph.tv.ToString() + "=" +
eventGraph.tvPersonAVGAtSQL.ToString() + "=" +
eventGraph.tvSessionAVGAtSQL.ToString();
@@ -611,21 +620,22 @@ public partial class ChronoJumpWindow
minValue = Convert.ToDouble(jump[6]); //tc
}
} else {
+ */
minValue = eventGraphConfigureWin.Min;
bottomMargin = 0;
- }
+ //}
//paint graph
- paintJumpSimple (event_execute_drawingarea, eventGraph.jumpsAtSQL,
- eventGraph.tv, eventGraph.tvPersonAVGAtSQL, eventGraph.tvSessionAVGAtSQL,
- eventGraph.tc, eventGraph.tcPersonAVGAtSQL, eventGraph.tcSessionAVGAtSQL,
+ paintJumpSimple (event_execute_drawingarea, eventGraph,
maxValue, minValue, topMargin, bottomMargin);
//printLabels
+ /*
printLabelsJumpSimple (
eventGraph.tv, eventGraph.tvPersonAVGAtSQL, eventGraph.tvSessionAVGAtSQL,
eventGraph.heightPersonAVGAtSQL, eventGraph.heightSessionAVGAtSQL,
eventGraph.tc, eventGraph.tcPersonAVGAtSQL, eventGraph.tcSessionAVGAtSQL);
+ */
// -- refresh
event_execute_drawingarea.QueueDraw();
@@ -944,9 +954,13 @@ public partial class ChronoJumpWindow
}
//paint graph (use simple jump method)
- paintJumpSimple (event_execute_drawingarea, eventGraph.rtsAtSQL,
+ /*
+ paintJumpSimple (event_execute_drawingarea,
+ eventGraph.rtsAtSQL,
eventGraph.time, eventGraph.timePersonAVGAtSQL,
eventGraph.timeSessionAVGAtSQL,
0, 0, 0, maxValue, minValue, topMargin, bottomMargin);
+TODO: use specific method
+ */
printLabelsReactionTime (eventGraph.time, eventGraph.timePersonAVGAtSQL,
eventGraph.timeSessionAVGAtSQL);
@@ -1071,7 +1085,9 @@ public partial class ChronoJumpWindow
layoutBig.GetPixelSize(out lWidth, out lHeight);
event_execute_pixmap.DrawLayout (pen_negro,
Convert.ToInt32(x - lWidth/2),
- Convert.ToInt32(alto/2 - lHeight/2),
+ //Convert.ToInt32(alto/2 - lHeight/2),
+ //10,
+ alto - lHeight,
layoutBig);
}
}
@@ -1088,10 +1104,21 @@ public partial class ChronoJumpWindow
layoutBig);
}
}
+
+ private void plotResultOnBar(int x, int y, int alto, double result) {
+ layoutMid.SetMarkup(Util.TrimDecimals(result,2));
+ int lWidth = 1;
+ int lHeight = 1;
+ layoutMid.GetPixelSize(out lWidth, out lHeight);
+ event_execute_pixmap.DrawLayout (pen_negro,
+ //Convert.ToInt32(x - lWidth/2),
+ //x,
+ Convert.ToInt32(x - lWidth/2),
+ Convert.ToInt32((y+alto)/2),
+ layoutMid);
+ }
- private void paintJumpSimple (Gtk.DrawingArea drawingarea, string [] jumps,
- double tvNow, double tvPerson, double tvSession,
- double tcNow, double tcPerson, double tcSession,
+ private void paintJumpSimple (Gtk.DrawingArea drawingarea, PrepareEventGraphJumpSimple eventGraph,
double maxValue, double minValue, int topMargin, int bottomMargin)
{
int ancho=drawingarea.Allocation.Width;
@@ -1099,83 +1126,105 @@ public partial class ChronoJumpWindow
int count;
UtilGtk.ErasePaint(event_execute_drawingarea, event_execute_pixmap);
- writeMarginsText(maxValue, minValue, alto);
-
+ writeMarginsText(eventGraph.sessionMAXAtSQL, minValue, alto);
+
//check now here that we will have not division by zero problems
- if(maxValue - minValue > 0) {
- //calculate separation between series and bar width
- int tctfSep = 0; //separation between tc and tf
- int distanceBetweenCols =
Convert.ToInt32((ancho-event_execute_rightMargin)*(1+.5)/jumps.Length) -
-
Convert.ToInt32((ancho-event_execute_rightMargin)*(0+.5)/jumps.Length);
- if(tcNow > 0)
- tctfSep = Convert.ToInt32(.3*distanceBetweenCols);
- int barWidth = Convert.ToInt32(.3*distanceBetweenCols);
- int barDesplLeft = Convert.ToInt32(.5*barWidth);
+ if(maxValue - minValue <= 0)
+ return;
- //paint first the average horizontal guides in order to be behind the bars
- if(tcNow > 0) {
- drawGuideOrAVG(pen_rojo, tcPerson, alto, ancho, topMargin, bottomMargin,
maxValue, minValue);
- drawGuideOrAVG(pen_rojo_discont, tcSession, alto, ancho, topMargin,
bottomMargin, maxValue, minValue);
- }
- if(tvNow > 0) {
- drawGuideOrAVG(pen_azul_claro, tvPerson, alto, ancho, topMargin,
bottomMargin, maxValue, minValue);
- drawGuideOrAVG(pen_azul_claro_discont, tvSession, alto, ancho, topMargin,
bottomMargin, maxValue, minValue);
- }
+ //calculate separation between series and bar width
+ int tctfSep = 0; //separation between tc and tf
+ int distanceBetweenCols =
Convert.ToInt32((ancho-event_execute_rightMargin)*(1+.5)/eventGraph.jumpsAtSQL.Length) -
+
Convert.ToInt32((ancho-event_execute_rightMargin)*(0+.5)/eventGraph.jumpsAtSQL.Length);
+ if(eventGraph.tc > 0)
+ tctfSep = Convert.ToInt32(.3*distanceBetweenCols);
+ int barWidth = Convert.ToInt32(.3*distanceBetweenCols);
+ int barDesplLeft = Convert.ToInt32(.5*barWidth);
+
+ //paint first the average horizontal guides in order to be behind the bars
+ drawGuideOrAVG(pen_negro, eventGraph.personMAXAtSQL, alto, ancho, topMargin, bottomMargin,
maxValue, minValue);
+ drawGuideOrAVG(pen_gris, eventGraph.sessionMAXAtSQL, alto, ancho, topMargin, bottomMargin,
maxValue, minValue);
+ drawGuideOrAVG(pen_azul_claro, eventGraph.personAVGAtSQL, alto, ancho, topMargin,
bottomMargin, maxValue, minValue);
+ drawGuideOrAVG(pen_azul_claro_discont, eventGraph.sessionAVGAtSQL, alto, ancho, topMargin,
bottomMargin, maxValue, minValue);
+
+ //red for TC
+ count = eventGraph.jumpsAtSQL.Length;
+ if(eventGraph.tc > 0) {
+ foreach(string myStr in eventGraph.jumpsAtSQL) {
+ string [] jump = myStr.Split(new char[] {':'});
+ Rectangle rect = new Rectangle(
+
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/eventGraph.jumpsAtSQL.Length)-barDesplLeft,
+ calculatePaintHeight(Convert.ToDouble(jump[6]), alto,
maxValue, minValue,
+ topMargin, bottomMargin),
+ barWidth, alto
+ );
+ event_execute_pixmap.DrawRectangle(pen_rojo, true, rect);
+ if(count == eventGraph.jumpsAtSQL.Length)
+ event_execute_pixmap.DrawRectangle(pen_yellow, false, rect);
+ else
+ event_execute_pixmap.DrawRectangle(pen_negro, false, rect);
+
+ count --;
- //red for TC
- count = jumps.Length;
- if(tcNow > 0) {
- foreach(string myStr in jumps) {
+ }
+
+ //blue for TF
+ //check it's not a take off
+ count = eventGraph.jumpsAtSQL.Length;
+ if(eventGraph.tv > 0) {
+ foreach(string myStr in eventGraph.jumpsAtSQL) {
string [] jump = myStr.Split(new char[] {':'});
+ //jump[5] is ok fo jump.tv and for reactionTime.time
Rectangle rect = new Rectangle(
-
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/jumps.Length)-barDesplLeft,
- calculatePaintHeight(Convert.ToDouble(jump[6]), alto,
maxValue, minValue,
+
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/eventGraph.jumpsAtSQL.Length)-barDesplLeft
+tctfSep,
+ calculatePaintHeight(Convert.ToDouble(jump[5]), alto,
maxValue, minValue,
topMargin, bottomMargin),
barWidth, alto
);
- event_execute_pixmap.DrawRectangle(pen_rojo, true, rect);
- if(count == jumps.Length)
+ event_execute_pixmap.DrawRectangle(pen_azul_claro, true, rect);
+ if(count == eventGraph.jumpsAtSQL.Length)
event_execute_pixmap.DrawRectangle(pen_yellow, false, rect);
else
event_execute_pixmap.DrawRectangle(pen_negro, false, rect);
-
- count --;
+ count --;
}
}
-
- //blue for TF
- //check it's not a take off
- count = jumps.Length;
- if(tvNow > 0) {
- foreach(string myStr in jumps) {
+ } else { //if only tv show height
+ count = eventGraph.jumpsAtSQL.Length;
+ if(eventGraph.tv > 0) {
+ foreach(string myStr in eventGraph.jumpsAtSQL) {
string [] jump = myStr.Split(new char[] {':'});
//jump[5] is ok fo jump.tv and for reactionTime.time
+ int x =
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/eventGraph.jumpsAtSQL.Length)-barDesplLeft
+tctfSep;
+ int y =
calculatePaintHeight(Convert.ToDouble(Util.GetHeightInCentimeters(jump[5])),
+ alto, maxValue, minValue, topMargin, bottomMargin);
Rectangle rect = new Rectangle(
-
Convert.ToInt32((ancho-event_execute_rightMargin)*(count-.5)/jumps.Length)-barDesplLeft +tctfSep,
- calculatePaintHeight(Convert.ToDouble(jump[5]), alto,
maxValue, minValue,
- topMargin, bottomMargin),
+ x, y,
barWidth, alto
);
event_execute_pixmap.DrawRectangle(pen_azul_claro, true, rect);
- if(count == jumps.Length)
+ if(count == eventGraph.jumpsAtSQL.Length)
event_execute_pixmap.DrawRectangle(pen_yellow, false, rect);
else
event_execute_pixmap.DrawRectangle(pen_negro, false, rect);
-
- count --;
+
+ plotResultOnBar(x + barWidth/2, y, alto,
Convert.ToDouble(Util.GetHeightInCentimeters(jump[5])));
+ count --;
}
-
- plotSimulatedMessageIfNeededAtLast(
-
Convert.ToInt32((ancho-event_execute_rightMargin)*(jumps.Length-.5)/jumps.Length)-barDesplLeft + tctfSep
- + barWidth/2,
- alto);
-
- //paint reference guide black and green if needed
- drawGuideOrAVG(pen_negro_discont, eventGraphConfigureWin.BlackGuide, alto, ancho,
topMargin, bottomMargin, maxValue, minValue);
- drawGuideOrAVG(pen_green_discont, eventGraphConfigureWin.GreenGuide, alto, ancho,
topMargin, bottomMargin, maxValue, minValue);
+ }
}
+
+
+ plotSimulatedMessageIfNeededAtLast(
+
Convert.ToInt32((ancho-event_execute_rightMargin)*(eventGraph.jumpsAtSQL.Length-.5)/
+ eventGraph.jumpsAtSQL.Length)-barDesplLeft + tctfSep + barWidth/2,
+ alto);
+
+ //paint reference guide black and green if needed
+ //drawGuideOrAVG(pen_negro_discont, eventGraphConfigureWin.BlackGuide, alto, ancho,
topMargin, bottomMargin, maxValue, minValue);
+ //drawGuideOrAVG(pen_green_discont, eventGraphConfigureWin.GreenGuide, alto, ancho,
topMargin, bottomMargin, maxValue, minValue);
}
private void paintRunSimple (Gtk.DrawingArea drawingarea, Gdk.GC myPen, string [] runs,
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index aa8adf2..09a2095 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -56,56 +56,44 @@ public class ExecutingGraphData
public class PrepareEventGraphJumpSimple {
//sql data of previous jumps to plot graph and show stats at bottom
public string [] jumpsAtSQL;
- public double tvPersonAVGAtSQL;
- public double tvSessionAVGAtSQL;
- public double heightPersonAVGAtSQL;
- public double heightSessionAVGAtSQL;
- public double tcPersonAVGAtSQL;
- public double tcSessionAVGAtSQL;
+
+ public double personMAXAtSQL;
+ public double sessionMAXAtSQL;
+ public double personAVGAtSQL;
+ public double sessionAVGAtSQL;
//current data
public double tv;
public double tc;
+
+ private enum jumpVariables { HEIGHT, TVTC, TC }
public PrepareEventGraphJumpSimple() {
}
public PrepareEventGraphJumpSimple(double tv, double tc, int sessionID, int personID, string table,
string type)
{
-
Sqlite.Open();
//select data from SQL to update graph
jumpsAtSQL = SqliteJump.SelectJumps(true, sessionID, personID, "", type,
Sqlite.Orders_by.ID_DESC, 10); //select only last 10 jumps
- tvPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
- true, sessionID, personID,
- table, type, "TV");
- tvSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
- true, sessionID, -1, table, type, "TV");
-
- //need to calculate height also, because:
- //it's different to have mean of tv and then calculate height of that mean
- //than have every height and then calculate the mean
-
- heightPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
- true, sessionID, personID,
- table, type, "100*4.9*(TV/2)*(TV/2)");
- heightSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
- true, sessionID, -1, table, type, "100*4.9*(TV/2)*(TV/2)");
-
-
- tcPersonAVGAtSQL = 0;
- tcSessionAVGAtSQL = 0;
- if(tc > 0) {
- tcPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
- true, sessionID, personID,
- table, type, "TC");
- tcSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
- true, sessionID, -1, table, type, "TC");
- }
+ string sqlSelect = "";
+ if(tv > 0) {
+ if(tc <= 0)
+ sqlSelect = "100*4.9*(TV/2)*(TV/2)";
+ else
+ sqlSelect = "TV";
+ } else
+ sqlSelect = "TC";
+
+ personMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, personID, table, type,
sqlSelect);
+ sessionMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, -1, table, type,
sqlSelect);
+ personAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, type,
sqlSelect);
+ sessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type,
sqlSelect);
+
//end of select data from SQL to update graph
this.tv = tv;
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 0286109..a4fb37e 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -553,10 +553,20 @@ class SqliteSession : Sqlite
}
+
//called from gui/event.cs for doing the graph
//we need to know the avg of events of a type (SJ, CMJ, free (pulse).. of a person, or of all persons
on the session
public static double SelectAVGEventsOfAType(bool dbconOpened, int sessionID, int personID, string
table, string type, string valueToSelect)
{
+ return selectEventsOfAType(dbconOpened, sessionID, personID, table, type, valueToSelect,
"AVG");
+ }
+ public static double SelectMAXEventsOfAType(bool dbconOpened, int sessionID, int personID, string
table, string type, string valueToSelect)
+ {
+ return selectEventsOfAType(dbconOpened, sessionID, personID, table, type, valueToSelect,
"MAX");
+ }
+ public static double selectEventsOfAType(bool dbconOpened, int sessionID, int personID,
+ string table, string type, string valueToSelect, string statistic)
+ {
if(!dbconOpened)
Sqlite.Open();
@@ -567,7 +577,7 @@ class SqliteSession : Sqlite
personIDString = " AND personID == " + personID;
- dbcmd.CommandText = "SELECT AVG(" + valueToSelect + ")" +
+ dbcmd.CommandText = "SELECT " + statistic + "(" + valueToSelect + ")" +
" FROM " + table +
" WHERE sessionID == " + sessionID +
" AND type == \"" + type + "\" " +
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 7c71c02..bdb5589 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -295,7 +295,7 @@ public class UtilEncoder
}
*/
- public static EncoderGraphROptions PrepareEncoderGraphOptions(string title, EncoderStruct es, bool
neuromuscularProfileDo, bool translate, bool debug)
+ public static EncoderGraphROptions PrepareEncoderGraphOptions(string title, EncoderStruct es, bool
neuromuscularProfileDo, bool translate, bool debug, bool crossValidate)
{
string operatingSystem = "Linux";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]