[chronojump] CairoPaintBarsPreRunInterval done!



commit 6945dbd6f9f52d9f2962d9a019a86e18b293060f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 27 13:55:30 2021 +0200

    CairoPaintBarsPreRunInterval done!

 src/execute/event.cs       |   3 +-
 src/execute/run.cs         |  10 +-
 src/gui/app1/chronojump.cs |   5 +-
 src/gui/app1/run.cs        |  21 ++++-
 src/gui/eventExecute.cs    | 229 +++++++++++++++++++++++++++------------------
 src/gui/usefulObjects.cs   |  63 ++++++++++++-
 src/run.cs                 |  11 ++-
 src/sqlite/runInterval.cs  |  25 -----
 8 files changed, 233 insertions(+), 134 deletions(-)
---
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 08a9ef431..5a21707f3 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -70,8 +70,7 @@ public class EventExecute
        public PrepareEventGraphJumpSimple PrepareEventGraphJumpSimpleObject; 
        public PrepareEventGraphJumpReactiveRealtimeCapture 
PrepareEventGraphJumpReactiveRealtimeCaptureObject;
        public PrepareEventGraphRunSimple PrepareEventGraphRunSimpleObject;
-       public PrepareEventGraphRunInterval PrepareEventGraphRunIntervalObject;
-       public PrepareEventGraphRunInterval PrepareEventGraphRunIntervalRealtimeCaptureObject;
+       public PrepareEventGraphRunIntervalRealtimeCapture PrepareEventGraphRunIntervalRealtimeCaptureObject;
        public PrepareEventGraphPulse PrepareEventGraphPulseObject;
        public PrepareEventGraphReactionTime PrepareEventGraphReactionTimeObject;
        public PrepareEventGraphMultiChronopic PrepareEventGraphMultiChronopicObject;
diff --git a/src/execute/run.cs b/src/execute/run.cs
index c7c447c2f..7fd55d5bb 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -1111,10 +1111,7 @@ public class RunIntervalExecute : RunExecute
                distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);
 
                //update graph
-               PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-                               type, distanceIntervalFixed, trackTime, intervalTimesString,
-                               distanceTotal, distancesString, startIn, success);
-               PrepareEventGraphRunIntervalRealtimeCaptureObject = new PrepareEventGraphRunInterval(
+               PrepareEventGraphRunIntervalRealtimeCaptureObject = new 
PrepareEventGraphRunIntervalRealtimeCapture (
                                type, distanceIntervalFixed, trackTime, intervalTimesString,
                                distanceTotal, distancesString, startIn, success);
 
@@ -1354,10 +1351,7 @@ public class RunIntervalExecute : RunExecute
                                feedbackMessage = "";
                        needShowFeedbackMessage = true; 
 
-                       PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
-                                       type, distanceIntervalFixed, Util.GetLast(intervalTimesString),
-                                       intervalTimesString, distanceTotal, distancesString, startIn, true);
-                       PrepareEventGraphRunIntervalRealtimeCaptureObject = new PrepareEventGraphRunInterval(
+                       PrepareEventGraphRunIntervalRealtimeCaptureObject = new 
PrepareEventGraphRunIntervalRealtimeCapture (
                                        type, distanceIntervalFixed, trackTime, intervalTimesString,
                                        distanceTotal, distancesString, startIn, true);
 
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index ca0c4a562..62bdb6b42 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -3606,7 +3606,6 @@ public partial class ChronoJumpWindow
                        }
                        else
                        {
-                               event_execute_drawingarea.Visible = true;
                                button_inspect_last_test_run_intervallic.Visible = true;
                                notebooks_change(m);
                                button_contacts_bells.Sensitive = true;
@@ -3614,8 +3613,8 @@ public partial class ChronoJumpWindow
                                event_execute_drawingarea_realtime_capture_cairo.Visible = true;
                                vbox_event_execute_drawingarea_realtime_capture_cairo.Visible = true;
 
-                               event_graph_label_graph_test.Visible = true;
-                               vbox_contacts_simple_graph_controls.Visible = false;
+                               event_graph_label_graph_test.Visible = false;
+                               vbox_contacts_simple_graph_controls.Visible = true;
 
                                //align_check_vbox_contacts_graph_legend.Visible = false;
                                //vbox_contacts_graph_legend.Visible = false;
diff --git a/src/gui/app1/run.cs b/src/gui/app1/run.cs
index eb5341d93..f5b99a341 100644
--- a/src/gui/app1/run.cs
+++ b/src/gui/app1/run.cs
@@ -242,7 +242,26 @@ public partial class ChronoJumpWindow
                        currentRunIntervalType.Name
                        );
 
-               //TODO paint graph of num of intervallic runs
+               string typeTemp = currentEventType.Name;
+               if(radio_contacts_graph_allTests.Active)
+                       typeTemp = "";
+
+               PrepareEventGraphRunInterval eventGraph = new PrepareEventGraphRunInterval(
+                               currentSession.UniqueID, currentPerson.UniqueID,
+                               radio_contacts_graph_allPersons.Active,
+                               Convert.ToInt32(spin_contacts_graph_last_limit.Value),
+                               typeTemp);
+
+               string personStr = "";
+               if(! radio_contacts_graph_allPersons.Active)
+                       personStr = currentPerson.Name;
+
+               cairoPaintBarsPre = new CairoPaintBarsPreRunInterval (
+                               event_execute_drawingarea_cairo, preferences.fontType.ToString(), 
current_mode,
+                               personStr, typeTemp, preferences.digitsNumber);
+
+               cairoPaintBarsPre.StoreEventGraphRunsInterval (eventGraph);
+               PrepareRunIntervalGraph (cairoPaintBarsPre.eventGraphRunsIntervalStored, false);
        }
        
        private void extra_window_runs_interval_initialize(RunType myRunType) 
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index da69212f7..575ac96fa 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -548,12 +548,12 @@ public partial class ChronoJumpWindow
                                return;
 
                        PrepareRunIntervalRealtimeCaptureGraph(
-                                       currentEventExecute.PrepareEventGraphRunIntervalObject.distance,
-                                       currentEventExecute.PrepareEventGraphRunIntervalObject.lastTime,
-                                       currentEventExecute.PrepareEventGraphRunIntervalObject.timesString,
-                                       currentEventExecute.PrepareEventGraphRunIntervalObject.distanceTotal,
-                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distancesString,
-                                       currentEventExecute.PrepareEventGraphRunIntervalObject.type
+                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distance,
+                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.lastTime,
+                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.timesString,
+                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distanceTotal,
+                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distancesString,
+                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.type
                                        );
                }
        }
@@ -564,7 +564,8 @@ public partial class ChronoJumpWindow
                //right now only for jumps/runs simple
                if(current_mode != Constants.Modes.JUMPSSIMPLE &&
                                current_mode != Constants.Modes.JUMPSREACTIVE &&
-                               current_mode != Constants.Modes.RUNSSIMPLE)
+                               current_mode != Constants.Modes.RUNSSIMPLE &&
+                               current_mode != Constants.Modes.RUNSINTERVALLIC)
                        return;
 
                //if object not defined or not defined fo this mode, return
@@ -578,6 +579,8 @@ public partial class ChronoJumpWindow
                        PrepareJumpReactiveGraph (cairoPaintBarsPre.eventGraphJumpsRjStored, false);
                else if (current_mode == Constants.Modes.RUNSSIMPLE)
                        PrepareRunSimpleGraph (cairoPaintBarsPre.eventGraphRunsStored, false);
+               else if (current_mode == Constants.Modes.RUNSINTERVALLIC)
+                       PrepareRunIntervalGraph (cairoPaintBarsPre.eventGraphRunsIntervalStored, false);
        }
 
        
@@ -725,12 +728,12 @@ public partial class ChronoJumpWindow
                        return;
 
                PrepareRunIntervalRealtimeCaptureGraph(
-                               currentEventExecute.PrepareEventGraphRunIntervalObject.distance,
-                               currentEventExecute.PrepareEventGraphRunIntervalObject.lastTime,
-                               currentEventExecute.PrepareEventGraphRunIntervalObject.timesString,
-                               currentEventExecute.PrepareEventGraphRunIntervalObject.distanceTotal,
-                               currentEventExecute.PrepareEventGraphRunIntervalObject.distancesString,
-                               currentEventExecute.PrepareEventGraphRunIntervalObject.type
+                               
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distance,
+                               
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.lastTime,
+                               
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.timesString,
+                               
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distanceTotal,
+                               
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distancesString,
+                               currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.type
                                );
        }
 
@@ -806,70 +809,22 @@ public partial class ChronoJumpWindow
                cairoPaintBarsPre.RunsShowTime = check_run_show_time.Active;
                cairoPaintBarsPre.Paint();
        }
-       
-       // run interval
-       // distanceTotal is passed because it can change in variable distances test
-       public void PrepareRunIntervalGraph(double distance, double lastTime, string timesString,
-                       double distanceTotal, string distancesString,
-                       bool startIn, bool finished,
-                       bool volumeOn, Preferences.GstreamerTypes gstreamer,
-                       RepetitiveConditionsWindow repetitiveConditionsWin, RunPhaseTimeList runPTL)
-       {
-               //check graph properties window is not null (propably user has closed it with the DeleteEvent
-               //then create it, but not show it
-               if(eventGraphConfigureWin == null)
-                       eventGraphConfigureWin = EventGraphConfigureWindow.Show(false);
-
-               //search MAX 
-               double maxValue = 0;
-               int topMargin = 20;
-               //if max value of graph is automatic
-               if(eventGraphConfigureWin.Max == -1) {
-                       if(distancesString == "")
-                               maxValue = distance / Util.GetMin(timesString); //getMin because is on the 
"denominador"
-                       else
-                               maxValue = Util.GetRunIVariableDistancesSpeeds(distancesString, timesString, 
true);
-               } else {
-                       maxValue = eventGraphConfigureWin.Max;
-                       topMargin = 0;
-               }
-                       
-               //search min
-               double minValue = 1000;
-               int bottomMargin = 20; 
-               //if min value of graph is automatic
-               if(eventGraphConfigureWin.Min == -1) { 
-                       if(startIn)
-                               minValue = 0;
-                       else if(distancesString == "")
-                               minValue = distance / Util.GetMax(timesString); //getMax because is in the 
"denominador"
-                       else
-                               minValue = Util.GetRunIVariableDistancesSpeeds(distancesString, timesString, 
false);
-               } else {
-                       minValue = eventGraphConfigureWin.Min;
-               }
-
-               int tracks = Util.GetNumberOfJumps(timesString, true); 
 
-               //paint graph
-               paintRunInterval (event_execute_drawingarea, distance, distanceTotal, distancesString,
-                               lastTime, timesString, Util.GetAverage(timesString), 
-                               maxValue, minValue, tracks, topMargin, bottomMargin,
-                               Util.GetPosMax(timesString), Util.GetPosMin(timesString), startIn, finished,
-                               volumeOn, gstreamer, repetitiveConditionsWin, runPTL);
-               
-               // -- refresh
-               event_execute_drawingarea.QueueDraw();
+       public void PrepareRunIntervalGraph(PrepareEventGraphRunInterval eventGraph, bool animate)
+       {
+               // Paint cairo graph
+               cairoPaintBarsPre.ShowPersonNames = radio_contacts_graph_allPersons.Active;
+               cairoPaintBarsPre.RunsShowTime = check_run_show_time.Active;
+               cairoPaintBarsPre.Paint();
        }
 
-       // Reactive jump
        public void PrepareRunIntervalRealtimeCaptureGraph (double distance, double lastTime, string 
timesString, double distanceTotal, string distancesString, string type)
        {
                if(currentPerson == null)
                        return;
 
                //discard RSA (at the moment)
-               if( currentEventExecute.PrepareEventGraphRunIntervalObject.distancesString.Contains("R") )
+               if( 
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distancesString.Contains("R") )
                        return;
 
                cairoPaintBarsPreRealTime = new CairoPaintBarsPreRunIntervalRealtimeCapture(
@@ -2192,6 +2147,8 @@ public partial class ChronoJumpWindow
                        updateGraphJumpsReactive ();
                else if(current_mode == Constants.Modes.RUNSSIMPLE)
                        updateGraphRunsSimple ();
+               else if(current_mode == Constants.Modes.RUNSINTERVALLIC)
+                       updateGraphRunsInterval ();
        }
 
        private void on_radio_contacts_graph_test_toggled (object o, EventArgs args)
@@ -2213,6 +2170,7 @@ public partial class ChronoJumpWindow
                }
                else if(current_mode == Constants.Modes.RUNSINTERVALLIC)
                {
+                       updateGraphRunsInterval ();
                        pre_fillTreeView_runs_interval(false);
                }
        }
@@ -2225,6 +2183,8 @@ public partial class ChronoJumpWindow
                        updateGraphJumpsReactive ();
                else if(current_mode == Constants.Modes.RUNSSIMPLE)
                        updateGraphRunsSimple ();
+               else if(current_mode == Constants.Modes.RUNSINTERVALLIC)
+                       updateGraphRunsInterval ();
        }
 
        private void on_check_run_show_time_toggled (object o, EventArgs args)
@@ -2268,27 +2228,13 @@ public partial class ChronoJumpWindow
                                        if(currentRunIntervalType.IsRSA)
                                                volumeOnHere = false;
 
-                                       PrepareRunIntervalGraph(
-                                                       //TODO: pass most of this as (including RunPTL)
-                                                       //new PrepareEventGraphRunIntervalObject(distance, 
lastTime, ...)
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distance,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.lastTime,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.timesString,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distanceTotal,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distancesString,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.startIn,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.finished,
-                                                       volumeOnHere, preferences.gstreamer, 
repetitiveConditionsWin,
-                                                       currentEventExecute.RunPTL
-                                                       );
-
                                        PrepareRunIntervalRealtimeCaptureGraph(
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distance, 
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.lastTime,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.timesString,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distanceTotal,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.distancesString,
-                                                       
currentEventExecute.PrepareEventGraphRunIntervalObject.type
+                                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distance,
+                                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.lastTime,
+                                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.timesString,
+                                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distanceTotal,
+                                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.distancesString,
+                                                       
currentEventExecute.PrepareEventGraphRunIntervalRealtimeCaptureObject.type
                                                        );
                                }
                                break;
@@ -2535,6 +2481,9 @@ public abstract class CairoPaintBarsPre
        public PrepareEventGraphRunSimple eventGraphRunsStored;
        public bool RunsShowTime;
 
+       //run interval
+       public PrepareEventGraphRunInterval eventGraphRunsIntervalStored;
+
        protected DrawingArea darea;
        protected string fontStr;
        protected Constants.Modes mode;
@@ -2564,9 +2513,9 @@ public abstract class CairoPaintBarsPre
        public virtual void StoreEventGraphRuns (PrepareEventGraphRunSimple eventGraph)
        {
        }
-//     public virtual void StoreEventGraphJumpReactiveCapture (PrepareEventGraphJumpReactiveRealtimeCapture 
eventGraph)
-//     {
-//     }
+       public virtual void StoreEventGraphRunsInterval (PrepareEventGraphRunInterval eventGraph)
+       {
+       }
 
        /*
        public void Prepare ()
@@ -3225,6 +3174,104 @@ public class CairoPaintBarsPreRunSimple : CairoPaintBarsPre
        }
 }
 
+public class CairoPaintBarsPreRunInterval : CairoPaintBarsPre
+{
+       public CairoPaintBarsPreRunInterval (DrawingArea darea, string fontStr, Constants.Modes mode, string 
personName, string testName, int pDN)
+       {
+               initialize (darea, fontStr, mode, generateTitle(personName, testName), pDN);
+       }
+
+       public override void StoreEventGraphRunsInterval (PrepareEventGraphRunInterval eventGraph)
+       {
+               this.eventGraphRunsIntervalStored = eventGraph;
+       }
+
+       protected override bool storeCreated ()
+       {
+               return (eventGraphRunsIntervalStored != null);
+       }
+
+       protected override bool haveDataToPlot()
+       {
+               return (eventGraphRunsIntervalStored.runsAtSQL.Count > 0);
+       }
+
+       protected override void paintSpecific()
+       {
+               CairoBars1Series cb = new CairoBars1Series (darea);
+
+               cb.YVariable = Catalog.GetString("Speed");
+               cb.YUnits = "m/s";
+
+               cb.GraphInit(fontStr, ! ShowPersonNames, true); //usePersonGuides, useGroupGuides
+
+               List<Event> events = RunInterval.RunIntervalListToEventList 
(eventGraphRunsIntervalStored.runsAtSQL);
+
+               //find if there is a simulated
+               bool thereIsASimulated = false;
+               for(int i=0 ; i < eventGraphRunsIntervalStored.runsAtSQL.Count; i++)
+               {
+                       if(eventGraphRunsIntervalStored.runsAtSQL[i].Simulated == -1)
+                               thereIsASimulated = true;
+
+                       if(! ShowPersonNames)
+                               eventGraphRunsIntervalStored.runsAtSQL[i].Description = ""; //to avoid 
showing description
+               }
+
+               //manage bottom text font/spacing of rows
+               string longestWord = findLongestWordCairo (events,
+                               eventGraphRunsIntervalStored.type == "",
+                               "",
+                               "(" + Catalog.GetString("Simulated") + ")"); // condition for "all runs"
+               int fontHeightForBottomNames = cb.GetFontForBottomNames (events, longestWord);
+
+               int maxRowsForText = calculateMaxRowsForTextCairo (events, longestWord.Length,
+                               eventGraphRunsIntervalStored.type == "", thereIsASimulated, RunsShowTime);
+               int bottomMargin = cb.GetBottomMarginForText (maxRowsForText, fontHeightForBottomNames);
+
+               //LogB.Information(string.Format("fontHeightForBottomNames: {0}, bottomMargin: {1}", 
fontHeightForBottomNames, bottomMargin));
+
+               List<PointF> point_l = new List<PointF>();
+               List<string> names_l = new List<string>();
+
+               int countToDraw = eventGraphRunsIntervalStored.runsAtSQL.Count;
+               foreach(RunInterval runI in eventGraphRunsIntervalStored.runsAtSQL)
+               {
+                       // 1) Add data
+                       point_l.Add(new PointF(countToDraw --, runI.Speed));
+
+                       // 2) Add bottom names
+                       string typeRowString = "";
+                       if (eventGraphRunsIntervalStored.type == "") //if "all runs" show run.Type
+                               typeRowString = runI.Type;
+
+                       string timeString = "";
+                       if(RunsShowTime)
+                               timeString = string.Format("{0} s", Util.TrimDecimals(runI.TimeTotal, pDN));
+
+                       names_l.Add(createTextBelowBar(
+                                               timeString,
+                                               typeRowString,
+                                               runI.Description,
+                                               thereIsASimulated, (runI.Simulated == -1),
+                                               longestWord.Length, maxRowsForText));
+               }
+
+               cb.PassGuidesData (new CairoBarsGuideManage(
+                                       ! ShowPersonNames, true, //usePersonGuides, useGroupGuides
+                                       eventGraphRunsIntervalStored.sessionMAXAtSQL,
+                                       eventGraphRunsIntervalStored.sessionAVGAtSQL,
+                                       eventGraphRunsIntervalStored.sessionMINAtSQL,
+                                       0,
+                                       eventGraphRunsIntervalStored.personMAXAtSQL,
+                                       eventGraphRunsIntervalStored.personAVGAtSQL,
+                                       eventGraphRunsIntervalStored.personMINAtSQL));
+
+               cb.GraphDo(point_l, new List<PointF>(), names_l,
+                               fontHeightForBottomNames, bottomMargin, title);
+       }
+}
+
 //realtime jump reactive capture
 public class CairoPaintBarsPreJumpReactiveRealtimeCapture : CairoPaintBarsPre
 {
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 6a6082f4a..04e274cec 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -295,6 +295,63 @@ public class PrepareEventGraphRunSimple {
 }
 
 public class PrepareEventGraphRunInterval
+{
+       //sql data of previous jumps to plot graph and show stats at bottom
+       public List<RunInterval> runsAtSQL;
+       public string type; //jumpType (useful to know if "all jumps" (type == "")
+
+       public double personMAXAtSQL;
+       public double sessionMAXAtSQL;
+
+       public double personAVGAtSQL;
+       public double sessionAVGAtSQL;
+
+       public double personMINAtSQL;
+       public double sessionMINAtSQL;
+
+       public PrepareEventGraphRunInterval () {
+       }
+
+       //allPersons is for searching the jumps of current of allpersons
+       //personID we need to the personsMAX/AVG sql calls
+       //type can be "" for all jumps, then write it under bar
+       public PrepareEventGraphRunInterval (
+                       int sessionID, int personID, bool allPersons, int limit, string type)
+       {
+               // 1) assign variables
+               this.type = type;
+
+               Sqlite.Open(); // ----------------->
+
+               int personIDTemp = personID;
+               if(allPersons)
+                       personIDTemp = -1;
+
+               runsAtSQL = SqliteRunInterval.SelectRuns (true, sessionID, personIDTemp, type,
+                               Sqlite.Orders_by.ID_DESC, limit, allPersons);   //show names on comments only 
if "all persons"
+
+               string sqlSelect = "distanceTotal/timeTotal";
+               string table = Constants.RunIntervalTable;
+
+               List<double> personStats = SqliteSession.Select_MAX_AVG_MIN_EventsOfAType(
+                               true, sessionID, personID, table, type, sqlSelect);
+               personMAXAtSQL = personStats[0];
+               personAVGAtSQL = personStats[1];
+               personMINAtSQL = personStats[2];
+
+               List<double> sessionStats = SqliteSession.Select_MAX_AVG_MIN_EventsOfAType(
+                               true, sessionID, -1, table, type, sqlSelect);
+               sessionMAXAtSQL = sessionStats[0];
+               sessionAVGAtSQL = sessionStats[1];
+               sessionMINAtSQL = sessionStats[2];
+
+               Sqlite.Close(); // < -----------------
+       }
+
+       ~PrepareEventGraphRunInterval () {}
+}
+
+public class PrepareEventGraphRunIntervalRealtimeCapture
 {
        public string type;
        public double distance;
@@ -305,10 +362,10 @@ public class PrepareEventGraphRunInterval
        public bool startIn;
        public bool finished;
 
-       public PrepareEventGraphRunInterval() {
+       public PrepareEventGraphRunIntervalRealtimeCapture() {
        }
 
-       public PrepareEventGraphRunInterval(string type, double distance, double lastTime, string timesString,
+       public PrepareEventGraphRunIntervalRealtimeCapture (string type, double distance, double lastTime, 
string timesString,
                        double distanceTotal, string distancesString, bool startIn, bool finished)
        {
                this.type = type;
@@ -321,7 +378,7 @@ public class PrepareEventGraphRunInterval
                this.finished = finished;
        }
 
-       ~PrepareEventGraphRunInterval() {}
+       ~PrepareEventGraphRunIntervalRealtimeCapture() {}
 }
 
 public class PrepareEventGraphPulse {
diff --git a/src/run.cs b/src/run.cs
index 670ae8ae0..bd6220217 100644
--- a/src/run.cs
+++ b/src/run.cs
@@ -198,7 +198,16 @@ public class RunInterval : Run
                this.initialSpeed = Util.IntToBool(Convert.ToInt32(eventString[12]));
                this.datetime = eventString[13];
        }
-       
+
+       public static List<Event> RunIntervalListToEventList(List<RunInterval> runsI)
+       {
+               List<Event> events = new List<Event>();
+               foreach(RunInterval runI in runsI)
+                       events.Add((Event) runI);
+
+               return events;
+       }
+
 
        public override int InsertAtDB (bool dbconOpened, string tableName) {
                return SqliteRunInterval.Insert(dbconOpened, tableName, 
diff --git a/src/sqlite/runInterval.cs b/src/sqlite/runInterval.cs
index da62b7c54..b5e64742b 100644
--- a/src/sqlite/runInterval.cs
+++ b/src/sqlite/runInterval.cs
@@ -92,31 +92,6 @@ class SqliteRunInterval : SqliteRun
                return myLast;
        }
 
-       private static string selectRunsIntervalCreateSelection (int sessionID, int personID, string 
filterType)
-       {
-               string tp = Constants.PersonTable;
-
-               string filterSessionString = "";
-               if(sessionID != -1)
-                       filterSessionString = " AND runInterval.sessionID == " + sessionID;
-
-               string filterPersonString = "";
-               if(personID != -1)
-                       filterPersonString = " AND " + tp + ".uniqueID == " + personID;
-
-               string filterTypeString = "";
-               if(filterType != "")
-                       filterTypeString = " AND runInterval.type == \"" + filterType + "\" " ;
-
-               return "SELECT " + tp + ".name, runInterval.* " +
-                       " FROM " + tp + ", runInterval " +
-                       " WHERE " + tp + ".uniqueID == runInterval.personID" +
-                       filterSessionString +
-                       filterPersonString +
-                       filterTypeString +
-                       " ORDER BY upper(" + tp + ".name), runInterval.uniqueID";
-       }
-
         //like SelectRunsSA below method but much better: return list of RunInterval
        public static List<RunInterval> SelectRuns (bool dbconOpened, int sessionID, int personID, string 
runType,
                        Orders_by order, int limit, bool personNameInComment)


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