[chronojump] Jump/Run simple contacts graph with Cairo (testing it at side of non-cairo)



commit 5b02654d9c7d830852a7b0386c790b75443072ff
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Aug 23 13:17:58 2021 +0200

    Jump/Run simple contacts graph with Cairo (testing it at side of non-cairo)

 glade/app1.glade        |  51 +++++++++++++--------
 src/gui/app1/jump.cs    |   2 +-
 src/gui/app1/run.cs     |   2 +-
 src/gui/eventExecute.cs | 117 ++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 143 insertions(+), 29 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 26faf2fe3..cb869695f 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -7766,13 +7766,10 @@ EncoderInertialCapture</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <child>
-                                                            <widget class="GtkFrame" id="frame5">
+                                                            <widget class="GtkHBox" id="hbox6">
                                                             <property name="width_request">150</property>
                                                             <property name="visible">True</property>
-                                                            <property name="sensitive">False</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label_xalign">0</property>
-                                                            <property name="shadow_type">none</property>
                                                             <child>
                                                             <widget class="GtkDrawingArea" 
id="event_execute_drawingarea">
                                                             <property name="visible">True</property>
@@ -7781,11 +7778,23 @@ EncoderInertialCapture</property>
                                                             <signal name="expose_event" 
handler="on_event_execute_drawingarea_expose_event" swapped="no"/>
                                                             <signal name="configure_event" 
handler="on_event_execute_drawingarea_configure_event" swapped="no"/>
                                                             </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
                                                             </child>
                                                             <child>
-                                                            <placeholder/>
+                                                            <widget class="GtkDrawingArea" 
id="event_execute_drawingarea_cairo">
+                                                            <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
+                                                            <property name="can_focus">False</property>
+                                                            <signal name="expose_event" 
handler="on_event_execute_drawingarea_cairo_expose_event" swapped="no"/>
+                                                            </widget>
                                                             <packing>
-                                                            <property name="type">label_item</property>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
@@ -25672,6 +25681,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31983,18 +31995,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -32031,6 +32031,18 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -41329,6 +41341,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/app1/jump.cs b/src/gui/app1/jump.cs
index 2089cf69d..5bf79828c 100644
--- a/src/gui/app1/jump.cs
+++ b/src/gui/app1/jump.cs
@@ -336,7 +336,7 @@ public partial class ChronoJumpWindow
                                Convert.ToInt32(spin_contacts_graph_last_limit.Value),
                                Constants.JumpTable, typeTemp, preferences.heightPreferred);
                
-               if(eventGraph.personMAXAtSQLAllSessions > 0 || eventGraph.jumpsAtSQL.Count > 0)
+               //if(eventGraph.personMAXAtSQLAllSessions > 0 || eventGraph.jumpsAtSQL.Count > 0)
                        PrepareJumpSimpleGraph(eventGraph, false); //don't animate
        }
        private void updateGraphJumpsReactive ()
diff --git a/src/gui/app1/run.cs b/src/gui/app1/run.cs
index 8bf9c8bb8..21510d7dc 100644
--- a/src/gui/app1/run.cs
+++ b/src/gui/app1/run.cs
@@ -204,7 +204,7 @@ public partial class ChronoJumpWindow
                                Convert.ToInt32(spin_contacts_graph_last_limit.Value),
                                Constants.RunTable, typeTemp);
                
-               if(eventGraph.personMAXAtSQLAllSessions > 0 || eventGraph.runsAtSQL.Count > 0)
+               //if(eventGraph.personMAXAtSQLAllSessions > 0 || eventGraph.runsAtSQL.Count > 0)
                        PrepareRunSimpleGraph(eventGraph, false); //don't animate
        }
        private void updateGraphRunsInterval ()
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 396fa7c59..3e6a71d78 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2020   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2021   Xavier de Blas <xaviblas gmail com>
  */
 
 using System;
@@ -123,6 +123,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Notebook notebook_results_data;
        
        [Widget] Gtk.DrawingArea event_execute_drawingarea;
+       [Widget] Gtk.DrawingArea event_execute_drawingarea_cairo;
        [Widget] Gtk.Frame frame_run_simple_double_contacts;
        [Widget] Gtk.DrawingArea event_execute_drawingarea_run_simple_double_contacts;
        /*
@@ -177,7 +178,13 @@ public partial class ChronoJumpWindow
                "100", "200", "300", "400", "500"
        };
        */
-       
+
+       //Cairo stuff (migrating to GTK3)
+       //TODO: make all inherit from a generic: PrepareEventGraphContacts
+       PrepareEventGraphJumpSimple eventGraphJumpsCairoStored;
+       PrepareEventGraphRunSimple eventGraphRunsCairoStored;
+       string cairoTitleStored;
+
 
        private void event_execute_initializeVariables (
                        bool simulated,
@@ -564,6 +571,24 @@ public partial class ChronoJumpWindow
                //LogB.Information("EXPOSE END");
        }
 
+       public void on_event_execute_drawingarea_cairo_expose_event(object o, ExposeEventArgs args)
+       {
+               if(current_mode == Constants.Modes.JUMPSSIMPLE)
+               {
+                       if(eventGraphJumpsCairoStored == null)
+                               return;
+
+                       PrepareJumpSimpleGraph(eventGraphJumpsCairoStored, false);
+               }
+               else if(current_mode == Constants.Modes.RUNSSIMPLE)
+               {
+                       if(eventGraphRunsCairoStored == null)
+                               return;
+
+                       PrepareRunSimpleGraph(eventGraphRunsCairoStored, false);
+               }
+       }
+
        
        int allocationXOld_run_simple;
        int allocationYOld_run_simple;
@@ -620,8 +645,6 @@ public partial class ChronoJumpWindow
                allocationYOld_run_simple = allocation.Height;
        }
 
-
-
        // simple and DJ jump   
        public void PrepareJumpSimpleGraph(PrepareEventGraphJumpSimple eventGraph, bool animate)
        {
@@ -692,13 +715,19 @@ public partial class ChronoJumpWindow
                */
                        minValue = eventGraphConfigureWin.Min;
                //}
-               
-               //paint graph
+
+               // A) Paint not cairo graph
+               //      paint graph
                paintJumpSimple (event_execute_drawingarea, eventGraph, 
                                maxValue, minValue, topMargin, bottomMargin, animate, useHeights);
 
-               // -- refresh
+               //      refresh
                event_execute_drawingarea.QueueDraw();
+
+               // B) Paint cairo graph
+               eventGraphJumpsCairoStored = eventGraph;
+               cairoTitleStored = "jump title graph";
+               paintJumpSimpleCairoTest();
        }
 
        private void on_button_person_max_all_sessions_info_clicked(object o, EventArgs args) 
@@ -871,14 +900,20 @@ public partial class ChronoJumpWindow
                        UtilGtk.ClearDrawingArea(event_execute_drawingarea_run_simple_double_contacts,
                                        event_execute_run_simple_double_contacts_pixmap);
 
+               // A) Paint not cairo graph
                        paintRunSimple (event_execute_drawingarea, eventGraph,
                                        maxValue, minValue, topMargin, bottomMargin, animate,
                                        check_run_simple_show_time.Active,
                                        runPTL);
                
                
-               // -- refresh
+               //      refresh
                event_execute_drawingarea.QueueDraw();
+
+               // B) Paint cairo graph
+               eventGraphRunsCairoStored = eventGraph;
+               cairoTitleStored = "run title graph";
+               paintRunSimpleCairoTest();
        }
        
        // run interval
@@ -1093,7 +1128,39 @@ public partial class ChronoJumpWindow
                                        layoutBig);
                }
        }
-       
+
+       private void paintJumpSimpleCairoTest()
+       {
+               if(eventGraphJumpsCairoStored == null || event_execute_drawingarea_cairo == null)
+                       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)
        {
@@ -1688,6 +1755,38 @@ 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)
+                       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)


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