[chronojump] Capture tab jumps/runs simple cairo graph ok with an specific class
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Capture tab jumps/runs simple cairo graph ok with an specific class
- Date: Tue, 24 Aug 2021 08:36:15 +0000 (UTC)
commit c565bd72566ec3f35f63f07330c6239d86290065
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Aug 24 10:35:34 2021 +0200
Capture tab jumps/runs simple cairo graph ok with an specific class
src/gui/app1/jump.cs | 6 +-
src/gui/app1/run.cs | 6 +-
src/gui/cairo/bars.cs | 1 +
src/gui/eventExecute.cs | 222 +++++++++++++++++++++++++++++-------------------
4 files changed, 144 insertions(+), 91 deletions(-)
---
diff --git a/src/gui/app1/jump.cs b/src/gui/app1/jump.cs
index 5bf79828c..ef2813598 100644
--- a/src/gui/app1/jump.cs
+++ b/src/gui/app1/jump.cs
@@ -337,7 +337,11 @@ public partial class ChronoJumpWindow
Constants.JumpTable, typeTemp, preferences.heightPreferred);
//if(eventGraph.personMAXAtSQLAllSessions > 0 || eventGraph.jumpsAtSQL.Count > 0)
- PrepareJumpSimpleGraph(eventGraph, false); //don't animate
+ // PrepareJumpSimpleGraph(eventGraph, false); //don't animate
+ cairoPaintBarsPre = new CairoPaintBarsPre (
+ event_execute_drawingarea_cairo, preferences.fontType.ToString(),
current_mode, "title jumps");
+ cairoPaintBarsPre.StoreEventGraphJumps (eventGraph);
+ PrepareJumpSimpleGraph(cairoPaintBarsPre.eventGraphJumpsStored, false);
}
private void updateGraphJumpsReactive ()
{
diff --git a/src/gui/app1/run.cs b/src/gui/app1/run.cs
index 21510d7dc..88787efdf 100644
--- a/src/gui/app1/run.cs
+++ b/src/gui/app1/run.cs
@@ -205,7 +205,11 @@ public partial class ChronoJumpWindow
Constants.RunTable, typeTemp);
//if(eventGraph.personMAXAtSQLAllSessions > 0 || eventGraph.runsAtSQL.Count > 0)
- PrepareRunSimpleGraph(eventGraph, false); //don't animate
+ // PrepareRunSimpleGraph(eventGraph, false); //don't animate
+ cairoPaintBarsPre = new CairoPaintBarsPre (
+ event_execute_drawingarea_cairo, preferences.fontType.ToString(),
current_mode, "title runs");
+ cairoPaintBarsPre.StoreEventGraphRuns (eventGraph);
+ PrepareRunSimpleGraph(cairoPaintBarsPre.eventGraphRunsStored, false);
}
private void updateGraphRunsInterval ()
{
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index c84c00dd9..2d68ed70d 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -355,6 +355,7 @@ public class CairoBarsJustTesting : CairoBars
this.area = area;
LogB.Information("constructor without points, area is null:" + (area == null).ToString());
+ LogB.Information("constructor without points, area.GdkWindow is null:" + (area.GdkWindow ==
null).ToString());
initGraph(font, 1); //.8 to have title at right
endGraphDisposing(g);
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index eed0be2bd..a563fc31a 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -181,9 +181,10 @@ public partial class ChronoJumpWindow
//Cairo stuff (migrating to GTK3)
//TODO: make all inherit from a generic: PrepareEventGraphContacts
- PrepareEventGraphJumpSimple eventGraphJumpsCairoStored;
- PrepareEventGraphRunSimple eventGraphRunsCairoStored;
- string cairoTitleStored;
+ //PrepareEventGraphJumpSimple eventGraphJumpsCairoStored;
+ //PrepareEventGraphRunSimple eventGraphRunsCairoStored;
+ //string cairoTitleStored;
+ CairoPaintBarsPre cairoPaintBarsPre;
private void event_execute_initializeVariables (
@@ -544,6 +545,7 @@ public partial class ChronoJumpWindow
area.Width, area.Height);
}
+ //Note this does SQL calls at graph resize, eg. on_extra_window_jumps_test_changed:
PrepareEventGraphJumpSimple
if(sizeChanged)
{
//LogB.Information("caring for resize screen and correctly update
event_execute_drawingarea");
@@ -573,20 +575,19 @@ public partial class ChronoJumpWindow
public void on_event_execute_drawingarea_cairo_expose_event(object o, ExposeEventArgs args)
{
- if(current_mode == Constants.Modes.JUMPSSIMPLE)
- {
- if(eventGraphJumpsCairoStored == null)
- return;
+ //right now only for jumps/runs simple
+ if(current_mode != Constants.Modes.JUMPSSIMPLE && current_mode != Constants.Modes.RUNSSIMPLE)
+ return;
- PrepareJumpSimpleGraph(eventGraphJumpsCairoStored, false);
- }
- else if(current_mode == Constants.Modes.RUNSSIMPLE)
- {
- if(eventGraphRunsCairoStored == null)
- return;
+ //if object not defined or not defined fo this mode, return
+ if(cairoPaintBarsPre == null || ! cairoPaintBarsPre.ModeMatches (current_mode))
+ return;
- PrepareRunSimpleGraph(eventGraphRunsCairoStored, false);
- }
+ //cairoPaintBarsPre.Prepare();
+ if(current_mode == Constants.Modes.JUMPSSIMPLE)
+ PrepareJumpSimpleGraph(cairoPaintBarsPre.eventGraphJumpsStored, false);
+ else if (current_mode == Constants.Modes.RUNSSIMPLE)
+ PrepareRunSimpleGraph(cairoPaintBarsPre.eventGraphRunsStored, false);
}
@@ -725,9 +726,7 @@ public partial class ChronoJumpWindow
event_execute_drawingarea.QueueDraw();
// B) Paint cairo graph
- eventGraphJumpsCairoStored = eventGraph;
- cairoTitleStored = "jump title graph";
- paintJumpSimpleCairoTest();
+ cairoPaintBarsPre.Paint();
}
private void on_button_person_max_all_sessions_info_clicked(object o, EventArgs args)
@@ -911,9 +910,7 @@ public partial class ChronoJumpWindow
event_execute_drawingarea.QueueDraw();
// B) Paint cairo graph
- eventGraphRunsCairoStored = eventGraph;
- cairoTitleStored = "run title graph";
- paintRunSimpleCairoTest();
+ cairoPaintBarsPre.Paint();
}
// run interval
@@ -1129,40 +1126,6 @@ public partial class ChronoJumpWindow
}
}
- private void paintJumpSimpleCairoTest()
- {
- if(eventGraphJumpsCairoStored == null ||
- event_execute_drawingarea_cairo == null ||
- event_execute_drawingarea_cairo.GdkWindow == null) //at start program, this
can fail
- return;
-
- if(eventGraphJumpsCairoStored.jumpsAtSQL.Count == 0)
- {
- try {
- new CairoBarsJustTesting (event_execute_drawingarea_cairo,
preferences.fontType.ToString());
- } catch {
- LogB.Information("saved crash at with paintJumpSimpleCairoTest at astart");
- }
- return;
- }
-
- List<PointF> point_l = new List<PointF>();
- List<string> names_l = new List<string>();
-
- int countToDraw = eventGraphJumpsCairoStored.jumpsAtSQL.Count;
- foreach(Jump jump in eventGraphJumpsCairoStored.jumpsAtSQL)
- {
- point_l.Add(new PointF(countToDraw --, Util.GetHeightInCentimeters(jump.Tv)));
- names_l.Add(jump.Type);
- }
-
- CairoBarsJustTesting cbjt = new CairoBarsJustTesting (point_l, names_l,
event_execute_drawingarea_cairo, cairoTitleStored);
- cbjt.Do(preferences.fontType.ToString());
-
- return;
- // test ends ----
- }
-
private void paintJumpSimple (Gtk.DrawingArea drawingarea, PrepareEventGraphJumpSimple eventGraph,
double maxValue, double minValue, int topMargin, int bottomMargin, bool animate, bool
useHeights)
{
@@ -1757,40 +1720,6 @@ public partial class ChronoJumpWindow
event_execute_pixmap.DrawLayout (pen_black, marginLeft + marginOut + 2 * marginIn + boxSize,
2 * (marginOut + marginIn) + lHeight1, layout);
}
- private void paintRunSimpleCairoTest()
- {
- if(eventGraphRunsCairoStored == null ||
- event_execute_drawingarea_cairo == null ||
- event_execute_drawingarea_cairo.GdkWindow == null) //at start program, this
can fail
- return;
-
- if(eventGraphRunsCairoStored.runsAtSQL.Count == 0)
- {
- try {
- new CairoBarsJustTesting (event_execute_drawingarea_cairo,
preferences.fontType.ToString());
- } catch {
- LogB.Information("saved crash at with paintRunSimpleCairoTest at astart");
- }
- return;
- }
-
- List<PointF> point_l = new List<PointF>();
- List<string> names_l = new List<string>();
-
- int countToDraw = eventGraphRunsCairoStored.runsAtSQL.Count;
- foreach(Run run in eventGraphRunsCairoStored.runsAtSQL)
- {
- point_l.Add(new PointF(countToDraw --, run.Distance/run.Time));
- names_l.Add(run.Type);
- }
-
- CairoBarsJustTesting cbjt = new CairoBarsJustTesting (point_l, names_l,
event_execute_drawingarea_cairo, cairoTitleStored);
- cbjt.Do(preferences.fontType.ToString());
-
- return;
- // test ends ----
- }
-
private void paintRunSimple (Gtk.DrawingArea drawingarea, PrepareEventGraphRunSimple eventGraph,
double maxValue, double minValue, int topMargin, int bottomMargin, bool animate, bool
showTime,
RunPhaseTimeList runPTL)
@@ -3210,3 +3139,118 @@ public partial class ChronoJumpWindow
}
}
+
+//to prepare data before calling cairo method
+//TODO: do this with inheritance (being top class abstract)
+public class CairoPaintBarsPre
+{
+ private DrawingArea darea;
+ private string fontStr;
+ private Constants.Modes mode;
+ private string title;
+
+ //TODO: tnis should be private, move prepare to this class
+ public PrepareEventGraphJumpSimple eventGraphJumpsStored;
+ public PrepareEventGraphRunSimple eventGraphRunsStored;
+
+ public CairoPaintBarsPre (DrawingArea darea, string fontStr, Constants.Modes mode, string title)
+ {
+ this.darea = darea;
+ this.fontStr = fontStr;
+ this.mode = mode;
+ this.title = title;
+ }
+
+ public bool ModeMatches (Constants.Modes mode)
+ {
+ return (this.mode == mode);
+ }
+
+ public void StoreEventGraphJumps (PrepareEventGraphJumpSimple eventGraph)
+ {
+ this.eventGraphJumpsStored = eventGraph;
+ }
+ public void StoreEventGraphRuns (PrepareEventGraphRunSimple eventGraph)
+ {
+ this.eventGraphRunsStored = eventGraph;
+ }
+
+ /*
+ public void Prepare ()
+ {
+ if(mode == Constants.Modes.JUMPSSIMPLE)
+ PrepareJumpSimpleGraph(eventGraphJumpsStored, false);
+ else if(current_mode == Constants.Modes.RUNSSIMPLE)
+ PrepareRunSimpleGraph(eventGraphRunsStored, false);
+ }
+ */
+
+ public void Paint ()
+ {
+ if(darea == null || darea.GdkWindow == null) //at start program, this can fail
+ return;
+
+ if(mode == Constants.Modes.JUMPSSIMPLE)
+ paintJumpSimple ();
+ else if(mode == Constants.Modes.RUNSSIMPLE)
+ paintRunSimple ();
+ }
+
+ public void paintJumpSimple ()
+ {
+ if(eventGraphJumpsStored == null)
+ return;
+
+ if(eventGraphJumpsStored.jumpsAtSQL.Count == 0)
+ {
+ try {
+ new CairoBarsJustTesting (darea, fontStr);
+ } catch {
+ LogB.Information("saved crash at with paintJumpSimpleCairoTest at start");
+ }
+ return;
+ }
+
+ List<PointF> point_l = new List<PointF>();
+ List<string> names_l = new List<string>();
+
+ int countToDraw = eventGraphJumpsStored.jumpsAtSQL.Count;
+ foreach(Jump jump in eventGraphJumpsStored.jumpsAtSQL)
+ {
+ point_l.Add(new PointF(countToDraw --, Util.GetHeightInCentimeters(jump.Tv)));
+ names_l.Add(jump.Type);
+ }
+
+ CairoBarsJustTesting cbjt = new CairoBarsJustTesting (point_l, names_l, darea, title);
+ cbjt.Do(fontStr);
+ }
+
+ public void paintRunSimple ()
+ {
+ if(eventGraphRunsStored == null)
+ return;
+
+ if(eventGraphRunsStored.runsAtSQL.Count == 0)
+ {
+ try {
+ new CairoBarsJustTesting (darea, fontStr);
+ } catch {
+ LogB.Information("saved crash at with paintRunSimpleCairoTest at start");
+ }
+ return;
+ }
+
+ List<PointF> point_l = new List<PointF>();
+ List<string> names_l = new List<string>();
+
+ int countToDraw = eventGraphRunsStored.runsAtSQL.Count;
+ foreach(Run run in eventGraphRunsStored.runsAtSQL)
+ {
+ point_l.Add(new PointF(countToDraw --, run.Distance/run.Time));
+ names_l.Add(run.Type);
+ }
+
+ CairoBarsJustTesting cbjt = new CairoBarsJustTesting (point_l, names_l, darea, title);
+ cbjt.Do(fontStr);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]