[chronojump] jump graph update does not call SQL



commit 7ba5f9ce4d814b8f69e54bf15072f682f4189725
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Nov 10 21:37:11 2013 +0100

    jump graph update does not call SQL

 src/execute/jump.cs      |    9 ++++--
 src/gui/chronojump.cs    |    4 +-
 src/gui/eventExecute.cs  |   58 +++++++++++++++++----------------------------
 src/gui/usefulObjects.cs |   33 +++++++++++++++++++++++++-
 4 files changed, 62 insertions(+), 42 deletions(-)
---
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index 69848d7..e3be9f0 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -366,6 +366,7 @@ public class JumpExecute : EventExecute
                } else {
                        tc = 0;
                }
+
                
                /*      
                string myStringPush =   
@@ -380,8 +381,10 @@ public class JumpExecute : EventExecute
                else
                        feedbackMessage = "";
                needShowFeedbackMessage = true; 
+               
+               string table = Constants.JumpTable;
 
-               uniqueID = SqliteJump.Insert(false, Constants.JumpTable, "NULL", personID, sessionID, 
+               uniqueID = SqliteJump.Insert(false, table, "NULL", personID, sessionID, 
                                type, tv, tc, fall,  //type, tv, tc, fall
                                weight, description, angle, Util.BoolToNegativeInt(simulated));
 
@@ -391,8 +394,8 @@ public class JumpExecute : EventExecute
                
                //event will be raised, and managed in chronojump.cs
                fakeButtonFinished.Click();
-               
-               PrepareEventGraphJumpSimpleObject = new PrepareEventGraphJumpSimple(tv, tc);
+       
+               PrepareEventGraphJumpSimpleObject = new PrepareEventGraphJumpSimple(tv, tc, sessionID, 
personID, table, type);
                needUpdateGraphType = eventType.JUMP;
                needUpdateGraph = true;
                
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 0df4735..3c51282 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4341,8 +4341,8 @@ Console.WriteLine("X");
                try {
                        switch (currentEventType.Type) {
                                case EventType.Types.JUMP:
-                                       if(lastJumpIsSimple) 
-                                               PrepareJumpSimpleGraph(currentJump.Tv, currentJump.Tc);
+                                       if(lastJumpIsSimple)  
+                                               
PrepareJumpSimpleGraph(currentEventExecute.PrepareEventGraphJumpSimpleObject);
                                        else
                                                PrepareJumpReactiveGraph(
                                                                Util.GetLast(currentJumpRj.TvString), 
Util.GetLast(currentJumpRj.TcString),
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 59ea87f..4af6661 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -550,7 +550,7 @@ public partial class ChronoJumpWindow
        
 
        // simple and DJ jump   
-       public void PrepareJumpSimpleGraph(double tv, double tc) 
+       public void PrepareJumpSimpleGraph(PrepareEventGraphJumpSimple eventGraph)
        {
                //check graph properties window is not null (propably user has closed it with the DeleteEvent
                //then create it, but not show it
@@ -558,26 +558,6 @@ public partial class ChronoJumpWindow
                        eventGraphConfigureWin = EventGraphConfigureWindow.Show(false);
 
                
-               //obtain data
-               string []jumps = SqliteJump.SelectJumps(
-                               currentSession.UniqueID, event_execute_personID, "", event_execute_eventType);
-
-               double tvPersonAVG = SqliteSession.SelectAVGEventsOfAType(
-                               currentSession.UniqueID, event_execute_personID, 
-                               event_execute_tableName, event_execute_eventType, "TV");
-               double tvSessionAVG = SqliteSession.SelectAVGEventsOfAType(
-                               currentSession.UniqueID, -1, event_execute_tableName, 
event_execute_eventType, "TV");
-
-               double tcPersonAVG = 0; 
-               double tcSessionAVG = 0; 
-               if(tc > 0) {
-                       tcPersonAVG = SqliteSession.SelectAVGEventsOfAType(
-                                       currentSession.UniqueID, event_execute_personID, 
-                                       event_execute_tableName, event_execute_eventType, "TC");
-                       tcSessionAVG = SqliteSession.SelectAVGEventsOfAType(
-                                       currentSession.UniqueID, -1, event_execute_tableName, 
event_execute_eventType, "TC");
-               }
-               
                double maxValue = 0;
                double minValue = 0;
                int topMargin = 10; 
@@ -586,9 +566,11 @@ public partial class ChronoJumpWindow
                //if max value of graph is automatic
                if(eventGraphConfigureWin.Max == -1) {
                        maxValue = Util.GetMax(
-                                       tv.ToString() + "=" + tvPersonAVG.ToString() + "=" + 
tvSessionAVG.ToString() + "=" +
-                                       tc.ToString() + "=" + tcPersonAVG.ToString() + "=" + 
tcSessionAVG.ToString());
-                       foreach(string myStr in jumps) {
+                                       eventGraph.tv.ToString() + "=" + 
+                                       eventGraph.tvPersonAVGAtSQL.ToString() + "=" + 
eventGraph.tvSessionAVGAtSQL.ToString() + "=" +
+                                       eventGraph.tc.ToString() + "=" + 
+                                       eventGraph.tcPersonAVGAtSQL.ToString() + "=" + 
eventGraph.tcSessionAVGAtSQL.ToString());
+                       foreach(string myStr in eventGraph.jumpsAtSQL) {
                                string [] jump = myStr.Split(new char[] {':'});
                                if(Convert.ToDouble(jump[5]) > maxValue)
                                        maxValue = Convert.ToDouble(jump[5]); //tf
@@ -602,11 +584,13 @@ public partial class ChronoJumpWindow
                
                //if min value of graph is automatic
                if(eventGraphConfigureWin.Min == -1) {
-                       string myString = tv.ToString() + "=" + tvPersonAVG.ToString() + "=" + 
tvSessionAVG.ToString();
-                       if(tc > 0)
-                               myString = myString + "=" + tc.ToString() + "=" + tcPersonAVG.ToString() + 
"=" + tcSessionAVG.ToString();
+                       string myString = eventGraph.tv.ToString() + "=" + 
+                               eventGraph.tvPersonAVGAtSQL.ToString() + "=" + 
eventGraph.tvSessionAVGAtSQL.ToString();
+                       if(eventGraph.tc > 0)
+                               myString = myString + "=" + eventGraph.tc.ToString() + "=" + 
+                                       eventGraph.tcPersonAVGAtSQL.ToString() + "=" + 
eventGraph.tcSessionAVGAtSQL.ToString();
                        minValue = Util.GetMin(myString);
-                       foreach(string myStr in jumps) {
+                       foreach(string myStr in eventGraph.jumpsAtSQL) {
                                string [] jump = myStr.Split(new char[] {':'});
                                if(Convert.ToDouble(jump[5]) < minValue)
                                        minValue = Convert.ToDouble(jump[5]); //tf
@@ -619,11 +603,15 @@ public partial class ChronoJumpWindow
                }
                
                //paint graph
-               paintJumpSimple (event_execute_drawingarea, jumps, tv, tvPersonAVG, tvSessionAVG, 
-                               tc, tcPersonAVG, tcSessionAVG, maxValue, minValue, topMargin, bottomMargin);
+               paintJumpSimple (event_execute_drawingarea, eventGraph.jumpsAtSQL, 
+                               eventGraph.tv, eventGraph.tvPersonAVGAtSQL, eventGraph.tvSessionAVGAtSQL, 
+                               eventGraph.tc, eventGraph.tcPersonAVGAtSQL, eventGraph.tcSessionAVGAtSQL,
+                               maxValue, minValue, topMargin, bottomMargin);
 
                //printLabels
-               printLabelsJumpSimple (tv, tvPersonAVG, tvSessionAVG, tc, tcPersonAVG, tcSessionAVG);
+               printLabelsJumpSimple (
+                               eventGraph.tv, eventGraph.tvPersonAVGAtSQL, eventGraph.tvSessionAVGAtSQL, 
+                               eventGraph.tc, eventGraph.tcPersonAVGAtSQL, eventGraph.tcSessionAVGAtSQL);
                
                // -- refresh
                event_execute_drawingarea.QueueDraw();
@@ -1797,11 +1785,9 @@ Log.WriteLine("Preparing reactive A");
        private void on_event_execute_update_graph_in_progress_clicked(object o, EventArgs args) {
                switch (currentEventType.Type) {
                        case EventType.Types.JUMP:
-                               if(thisJumpIsSimple) {
-                                       PrepareJumpSimpleGraph(
-                                                       
currentEventExecute.PrepareEventGraphJumpSimpleObject.tv, 
-                                                       
currentEventExecute.PrepareEventGraphJumpSimpleObject.tc);
-                               } else {
+                               if(thisJumpIsSimple) 
+                                       
PrepareJumpSimpleGraph(currentEventExecute.PrepareEventGraphJumpSimpleObject);
+                               else {
                                        PrepareJumpReactiveGraph(
                                                        
currentEventExecute.PrepareEventGraphJumpReactiveObject.lastTv, 
                                                        
currentEventExecute.PrepareEventGraphJumpReactiveObject.lastTc,
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index e664460..cc20e0f 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -53,13 +53,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 tcPersonAVGAtSQL;
+       public double tcSessionAVGAtSQL;
+
+       //current data
        public double tv;
        public double tc;
 
        public PrepareEventGraphJumpSimple() {
        }
 
-       public PrepareEventGraphJumpSimple(double tv, double tc) {
+       public PrepareEventGraphJumpSimple(double tv, double tc, int sessionID, int personID, string table, 
string type) 
+       {
+               //select data from SQL to update graph  
+               jumpsAtSQL = SqliteJump.SelectJumps(
+                               sessionID, personID, "", type);
+
+               tvPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
+                               sessionID, personID, 
+                               table, type, "TV");
+               tvSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
+                               sessionID, -1, table, type, "TV");
+
+               tcPersonAVGAtSQL = 0; 
+               tcSessionAVGAtSQL = 0; 
+               if(tc > 0) {
+                       tcPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
+                                       sessionID, personID, 
+                                       table, type, "TC");
+                       tcSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(
+                                       sessionID, -1, table, type, "TC");
+               }
+
+               //end of select data from SQL to update graph   
+                       
                this.tv = tv;
                this.tc = tc;
        }


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