[chronojump] Run simple inspector double contacts graph with Cairo and on new tab



commit 8f835d3f68b765a70a7d5685c1929710dc2ad889
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Nov 3 11:34:22 2021 -0300

    Run simple inspector double contacts graph with Cairo and on new tab

 glade/app1.glade           | 157 ++++++++++++++++++++++++++-----
 src/Makefile.am            |   1 +
 src/gui/app1/chronojump.cs |  41 ++++++--
 src/gui/app1/icons.cs      |   2 +
 src/gui/app1/run.cs        |   6 ++
 src/gui/eventExecute.cs    | 227 ++++++++++++++-------------------------------
 6 files changed, 243 insertions(+), 191 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index bca4ed167..c229f1c09 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -7521,18 +7521,7 @@ EncoderInertialCapture</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
                                                             <child>
-                                                            <widget class="GtkDrawingArea" 
id="event_execute_drawingarea_run_simple_double_contacts">
-                                                            <property name="height_request">20</property>
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <signal name="expose_event" 
handler="on_event_execute_drawingarea_run_simple_double_contacts_expose_event" swapped="no"/>
-                                                            <signal name="configure_event" 
handler="on_event_execute_drawingarea_run_simple_double_contacts_configure_event" swapped="no"/>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
+                                                            <placeholder/>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkButton" 
id="button_inspect_last_test_run_simple">
@@ -15515,7 +15504,7 @@ Resisted race analyzer</property>
                                                           </packing>
                                                         </child>
                                                         <child>
-                                                          <widget class="GtkAlignment" id="alignment11">
+                                                          <widget class="GtkAlignment" 
id="alignment11_forceSensor_adjust">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="top_padding">4</property>
@@ -15944,6 +15933,106 @@ Resisted race analyzer</property>
                                                             <property name="type">tab</property>
                                                           </packing>
                                                         </child>
+                                                        <child>
+                                                          <widget class="GtkAlignment" 
id="alignment60_race_inspector">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="top_padding">4</property>
+                                                            <child>
+                                                            <widget class="GtkFrame" id="frame1">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label_xalign">0.5</property>
+                                                            <property name="shadow_type">out</property>
+                                                            <child>
+                                                            <widget class="GtkAlignment" id="alignment67">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="top_padding">24</property>
+                                                            <property name="left_padding">12</property>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox127">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkDrawingArea" 
id="event_execute_drawingarea_run_simple_double_contacts">
+                                                            <property name="height_request">20</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <signal name="expose_event" 
handler="on_event_execute_drawingarea_run_simple_double_contacts_expose_event" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_race_inspector_close">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_race_inspector_close_clicked" swapped="no"/>
+                                                            <accelerator key="Escape" signal="clicked"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox30">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_race_inspector_close">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label268">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Close</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="type">label_item</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="position">3</property>
+                                                          </packing>
+                                                        </child>
+                                                        <child>
+                                                          <widget class="GtkLabel" id="label267">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">raceInspector</property>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="position">3</property>
+                                                            <property name="tab_fill">False</property>
+                                                            <property name="type">tab</property>
+                                                          </packing>
+                                                        </child>
                                                       </widget>
                                                     </child>
                                                   </widget>
@@ -24718,6 +24807,15 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31075,18 +31173,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>
@@ -31123,6 +31209,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>
@@ -40474,6 +40572,15 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index 85bcd5a51..3bfa31706 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,6 +44,7 @@ SOURCES = \
        gui/cairo/jumpsWeightFVProfile.cs\
        gui/cairo/raceAnalyzer.cs\
        gui/cairo/radial.cs\
+       gui/cairo/runDoubleContacts.cs\
        gui/cairo/util.cs\
        gui/cairo/xy.cs\
        gui/chronojumpImporter.cs\
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index e69b0b734..4abd7fdd0 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -492,7 +492,7 @@ public partial class ChronoJumpWindow
        private string progName;
        private enum notebook_start_pages { PROGRAM, SENDLOG, EXITCONFIRM, SOCIALNETWORKPOLL }
        private enum notebook_sup_pages { START, CONTACTS, ENCODER, SESSION, NETWORKSPROBLEMS, HELP, NEWS }
-       private enum notebook_contacts_execute_or_pages { EXECUTE, INSTRUCTIONS, FORCESENSORADJUST }
+       private enum notebook_contacts_execute_or_pages { EXECUTE, INSTRUCTIONS, FORCESENSORADJUST, 
RACEINSPECTOR }
        private enum notebook_analyze_pages { STATISTICS, JUMPSPROFILE, JUMPSDJOPTIMALFALL, 
JUMPSWEIGHTFVPROFILE, JUMPSEVOLUTION, JUMPSRJFATIGUE,
                RUNSEVOLUTION, SPRINT, FORCESENSOR, RACEENCODER }
 
@@ -5271,9 +5271,6 @@ public partial class ChronoJumpWindow
                        currentRunType.Name 
                        );
 
-               UtilGtk.ClearDrawingArea(event_execute_drawingarea_run_simple_double_contacts,
-                               event_execute_run_simple_double_contacts_pixmap);
-
                event_execute_button_cancel.Sensitive = true;
 
                ExecutingGraphData egd = event_execute_prepareForTest ();
@@ -6496,10 +6493,38 @@ LogB.Debug("mc finished 5");
 
        private void on_button_inspect_last_test_clicked (object o, EventArgs args)
        {
-               if(currentEventExecute != null)
-                       new DialogMessage("Chronojump " + Catalog.GetString("Inspector"),
-                                       Constants.MessageTypes.INSPECT, 
currentEventExecute.GetInspectorMessages(),
-                                       true); //show scrolledwindow vertical bar
+               if(currentEventExecute == null)
+                       return;
+
+               /*
+               new DialogMessage("Chronojump " + Catalog.GetString("Inspector"),
+                               Constants.MessageTypes.INSPECT, currentEventExecute.GetInspectorMessages(),
+                               true); //show scrolledwindow vertical bar
+               */
+
+               //sensitivize gui
+               menus_and_mode_sensitive(false);
+               hbox_contacts_capture_top.Sensitive = false;
+               //button_inspect_last_test.Sensitive = false; //unneeded because it will be on 
hbox_contacts_capture_top
+               hbox_contacts_sup_capture_analyze_two_buttons.Sensitive = false;
+               hbox_top_person.Sensitive = false;
+
+               if(currentEventExecute == null)
+                       return;
+
+               notebook_contacts_execute_or.CurrentPage = 
Convert.ToInt32(notebook_contacts_execute_or_pages.RACEINSPECTOR);
+       }
+
+       private void on_button_race_inspector_close_clicked (object o, EventArgs args)
+       {
+               //unsensitivize gui
+               menus_and_mode_sensitive(true);
+               hbox_contacts_capture_top.Sensitive = true;
+               //button_inspect_last_test.Sensitive = true; //unneeded because it will be on 
hbox_contacts_capture_top
+               hbox_contacts_sup_capture_analyze_two_buttons.Sensitive = true;
+               hbox_top_person.Sensitive = true;
+
+               notebook_contacts_execute_or.CurrentPage = 
Convert.ToInt32(notebook_contacts_execute_or_pages.EXECUTE);
        }
 
        private void deleted_last_test_update_widgets() {
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index 4f2092fcc..4534efb39 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -133,6 +133,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_sprint_analyze_table_save;
        [Widget] Gtk.Image image_sprint_analyze_table_save_1;
        [Widget] Gtk.Image image_sprint_export_cancel;
+       [Widget] Gtk.Image image_race_inspector_close;
 
        //encoder images
        [Widget] Gtk.Image image_top_eccon;
@@ -536,6 +537,7 @@ public partial class ChronoJumpWindow
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_close.png");
                image_contacts_exercise_close.Pixbuf = pixbuf;
+               image_race_inspector_close.Pixbuf = pixbuf;
                image_encoder_exercise_close.Pixbuf = pixbuf;
                image_force_sensor_analyze_options_close.Pixbuf = pixbuf;
                image_force_sensor_analyze_options_close1.Pixbuf = pixbuf;
diff --git a/src/gui/app1/run.cs b/src/gui/app1/run.cs
index 09bdb35ea..d2138d7a5 100644
--- a/src/gui/app1/run.cs
+++ b/src/gui/app1/run.cs
@@ -211,12 +211,18 @@ public partial class ChronoJumpWindow
                if(! radio_contacts_graph_allPersons.Active)
                        personStr = currentPerson.Name;
 
+               LogB.Information("event_execute_drawingarea_cairo == null: ",
+                       (event_execute_drawingarea_cairo == null).ToString());
+
                cairoPaintBarsPre = new CairoPaintBarsPreRunSimple (
                                event_execute_drawingarea_cairo, preferences.fontType.ToString(), 
current_mode,
                                personStr, typeTemp, preferences.digitsNumber);
 
                cairoPaintBarsPre.StoreEventGraphRuns (eventGraph);
                PrepareRunSimpleGraph(cairoPaintBarsPre.eventGraphRunsStored, false);
+
+               cairoManageRunDoubleContacts = new CairoManageRunDoubleContacts (
+                               event_execute_drawingarea_run_simple_double_contacts, 
preferences.fontType.ToString() );
        }
        private void updateGraphRunsInterval ()
        {
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 46f7778d5..661f99a6c 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -158,6 +158,7 @@ public partial class ChronoJumpWindow
        //we need both working to be able to correctly expose_event on jumpRj, runI
        CairoPaintBarsPre cairoPaintBarsPre;
        CairoPaintBarsPre cairoPaintBarsPreRealTime;
+       CairoManageRunDoubleContacts cairoManageRunDoubleContacts;
 
 
        private void event_execute_initializeVariables (
@@ -228,9 +229,6 @@ public partial class ChronoJumpWindow
                layoutBig = new Pango.Layout (event_execute_drawingarea.PangoContext);
                layoutBig.FontDescription = Pango.FontDescription.FromString 
(preferences.GetFontTypeWithSize(14));
                //layoutBig.Alignment = Pango.Alignment.Center; //doesn't work, see GetPixelSize below
-
-               layoutMid_run_simple = new Pango.Layout 
(event_execute_drawingarea_run_simple_double_contacts.PangoContext);
-               layoutMid_run_simple.FontDescription = Pango.FontDescription.FromString 
(preferences.GetFontTypeWithSize(9));
        }
        private ExecutingGraphData event_execute_prepareForTest () 
        {
@@ -541,60 +539,20 @@ public partial class ChronoJumpWindow
                        PrepareRunIntervalGraph (cairoPaintBarsPre.eventGraphRunsIntervalStored, false);
        }
 
-       
-       int allocationXOld_run_simple;
-       int allocationYOld_run_simple;
-       bool sizeChanged_run_simple;
-       public void on_event_execute_drawingarea_run_simple_double_contacts_expose_event(object o, 
ExposeEventArgs args)
-       {
-               /* in some mono installations, configure_event is not called, but expose_event yes.
-                * Do here the initialization
-                */
-
-               Gdk.Rectangle allocation = event_execute_drawingarea_run_simple_double_contacts.Allocation;
-               if(event_execute_run_simple_double_contacts_pixmap == null || sizeChanged_run_simple ||
-                               allocation.Width != allocationXOld_run_simple || allocation.Height != 
allocationYOld_run_simple)
-               {
-                       event_execute_run_simple_double_contacts_pixmap = new Gdk.Pixmap 
(event_execute_drawingarea_run_simple_double_contacts.GdkWindow, allocation.Width, allocation.Height, -1);
-                       UtilGtk.ErasePaint(event_execute_drawingarea_run_simple_double_contacts, 
event_execute_run_simple_double_contacts_pixmap);
-
-                       sizeChanged_run_simple = false;
-               }
-
-               Gdk.Rectangle area = args.Event.Area;
-
-               //sometimes this is called when paint is finished
-               //don't let this erase win
-               if(event_execute_run_simple_double_contacts_pixmap != null) {
-                       
args.Event.Window.DrawDrawable(event_execute_drawingarea_run_simple_double_contacts.Style.WhiteGC, 
event_execute_run_simple_double_contacts_pixmap,
-                               area.X, area.Y,
-                               area.X, area.Y,
-                               area.Width, area.Height);
-               }
-
-               allocationXOld_run_simple = allocation.Width;
-               allocationYOld_run_simple = allocation.Height;
-       }
-
-       public void on_event_execute_drawingarea_run_simple_double_contacts_configure_event(object o, 
ConfigureEventArgs args)
+       public void on_event_execute_drawingarea_run_simple_double_contacts_expose_event (object o, 
ExposeEventArgs args)
        {
-               Gdk.EventConfigure ev = args.Event;
-               Gdk.Window window = ev.Window;
-
-               Gdk.Rectangle allocation = event_execute_drawingarea_run_simple_double_contacts.Allocation;
-
-               if(event_execute_run_simple_double_contacts_pixmap == null || sizeChanged_run_simple ||
-                               allocation.Width != allocationXOld_run_simple || allocation.Height != 
allocationYOld_run_simple)
-               {
-                       event_execute_run_simple_double_contacts_pixmap = new Gdk.Pixmap (window, 
allocation.Width, allocation.Height, -1);
-
-                       UtilGtk.ErasePaint(event_execute_drawingarea_run_simple_double_contacts, 
event_execute_run_simple_double_contacts_pixmap);
+               if(current_mode != Constants.Modes.RUNSSIMPLE)// &&
+                               //current_mode != Constants.Modes.RUNSINTERVALLIC)
+                       return;
 
-                       sizeChanged_run_simple = false;
-               }
+               //if object not defined or not defined fo this mode, return
+               if(cairoManageRunDoubleContacts == null)
+                       return;
 
-               allocationXOld_run_simple = allocation.Width;
-               allocationYOld_run_simple = allocation.Height;
+               if (current_mode == Constants.Modes.RUNSSIMPLE)
+                       PrepareRunSimpleDoubleContactsGraph ();
+               //else if (current_mode == Constants.Modes.RUNSINTERVALLIC)
+               //      PrepareRunIntervalDoubleContactsGraph 
(cairoManageRunDoubleContacts.eventGraphRunsIntervalStored, false);
        }
 
        // simple and DJ jump   
@@ -756,44 +714,54 @@ public partial class ChronoJumpWindow
        }
                        
 
+       /*
        // run simple
        // called from srg/gui/run updateGraphRunsSimple ()
        public void PrepareRunSimpleGraph(PrepareEventGraphRunSimple eventGraph, bool animate)
        {
                PrepareRunSimpleGraph(eventGraph, animate, null);
        }
+       */
 
        //standard call
-       public void PrepareRunSimpleGraph(PrepareEventGraphRunSimple eventGraph, bool animate, 
RunPhaseTimeList runPTL)
+       public void PrepareRunSimpleGraph(PrepareEventGraphRunSimple eventGraph, bool animate)
        {
-               double timeTotal = eventGraph.time;
-               // start of contact chunks
-               LogB.Information(string.Format("runPTL is null: {0}", (runPTL == null)));
+               LogB.Information("cairoPaintBarsPre == null: ", (cairoPaintBarsPre == null).ToString());
 
-               if(runPTL != null && runPTL.UseDoubleContacts())
-               {
-                       UtilGtk.ClearDrawingArea(event_execute_drawingarea_run_simple_double_contacts,
-                                       event_execute_run_simple_double_contacts_pixmap);
+               // Paint cairo graph
+               cairoPaintBarsPre.ShowPersonNames = radio_contacts_graph_allPersons.Active;
+               cairoPaintBarsPre.RunsShowTime = check_run_show_time.Active;
+               cairoPaintBarsPre.Paint();
+       }
+       public void PrepareRunSimpleDoubleContactsGraph()
+       {
+               LogB.Information("cairoManageRunDoubleContacts == null: ", (cairoManageRunDoubleContacts == 
null).ToString());
 
-                       List<RunPhaseTimeListObject> runPTLInListForPainting = runPTL.InListForPainting();
+               // prepare runPTL stuff
 
-                       double negativePTLTime = getRunSRunINegativePTLTime(runPTLInListForPainting);
-                       double timeTotalWithExtraPTL = getRunSRunITimeTotalWithExtraPTLTime (timeTotal, 
runPTLInListForPainting, negativePTLTime);
+               RunPhaseTimeList runPTL = currentEventExecute.RunPTL;
+               //LogB.Information(string.Format("runPTL is null: {0}", (runPTL == null)));
 
-                       LogB.Information(string.Format("timeTotal: {0}, negativePTLTime: {1}, 
timeTotalWithExtraPTL: {2}",
-                                               timeTotal, negativePTLTime, timeTotalWithExtraPTL));
+               if(runPTL == null || ! runPTL.UseDoubleContacts())
+                       return;
 
+               if(currentEventExecute == null || currentEventExecute.PrepareEventGraphRunSimpleObject == 
null)
+                       return;
 
-                       int ancho2 = event_execute_drawingarea_run_simple_double_contacts.Allocation.Width;
-                       paintRunSRunIContactChunks(event_execute_run_simple_double_contacts_pixmap, 20, 
ancho2, 0,
-                                       runPTLInListForPainting, timeTotal, timeTotalWithExtraPTL, 
negativePTLTime, true, true);
-               }
-               // end of contact chunks
+               // start of contact chunks
+               double timeTotal = currentEventExecute.PrepareEventGraphRunSimpleObject.time; //TODO: check 
problems on deleting last test, or changing mode
+
+               List<RunPhaseTimeListObject> runPTLInListForPainting = runPTL.InListForPainting();
+
+               double negativePTLTime = getRunSRunINegativePTLTime(runPTLInListForPainting);
+               double timeTotalWithExtraPTL = getRunSRunITimeTotalWithExtraPTLTime (timeTotal, 
runPTLInListForPainting, negativePTLTime);
+
+               LogB.Information(string.Format("timeTotal: {0}, negativePTLTime: {1}, timeTotalWithExtraPTL: 
{2}",
+                                       timeTotal, negativePTLTime, timeTotalWithExtraPTL));
 
                // Paint cairo graph
-               cairoPaintBarsPre.ShowPersonNames = radio_contacts_graph_allPersons.Active;
-               cairoPaintBarsPre.RunsShowTime = check_run_show_time.Active;
-               cairoPaintBarsPre.Paint();
+               cairoManageRunDoubleContacts.Paint(runPTLInListForPainting,
+                               timeTotal, timeTotalWithExtraPTL, negativePTLTime, true, true);
        }
 
        public void PrepareRunIntervalGraph(PrepareEventGraphRunInterval eventGraph, bool animate)
@@ -1482,82 +1450,6 @@ public partial class ChronoJumpWindow
                return timeTotalWithExtraPTL + negativePTLTime;
        }
 
-       void paintRunSRunIContactChunks(Gdk.Pixmap pixmap, int alto, int ancho, int bottomMargin,
-                       List<RunPhaseTimeListObject> runPTLInListForPainting,
-                       double timeTotal, double timeTotalWithExtraPTL, double negativePTLTime,
-                       bool drawStart, bool drawEnd)
-       {
-               int lastChunkStart = 0;
-               int chunkMargins = 4;
-
-               LogB.Information("CONTACT CHUNKS");
-               foreach (RunPhaseTimeListObject inPTL in runPTLInListForPainting)
-               {
-                       LogB.Information("inPTL: " + inPTL.ToString());
-                       int xStart = event_execute_rightMargin + Convert.ToInt32((ancho - 
2*event_execute_rightMargin) *
-                                       (inPTL.tcStart + negativePTLTime) / timeTotalWithExtraPTL);
-
-                       int xEnd = event_execute_rightMargin + Convert.ToInt32((ancho - 
2*event_execute_rightMargin) *
-                                       (inPTL.tcEnd + negativePTLTime) / timeTotalWithExtraPTL);
-
-                       pixmap.DrawRectangle(pen_double_contacts, true,
-                                       new Rectangle (xStart, alto-bottomMargin-4, xEnd-xStart, 4));
-
-                       //manage chunks indications
-                       if(inPTL.phase == RunPhaseTimeListObject.Phases.START)
-                       {
-                               //draw the vertical start line
-                               pixmap.DrawLine(pen_double_contacts,
-                                               xStart - chunkMargins, alto-bottomMargin -4,
-                                               xStart - chunkMargins, alto-bottomMargin -(4 + chunkMargins));
-                               lastChunkStart = xStart;
-                               LogB.Information("runPTL draw start");
-                       }
-                       else if(inPTL.phase == RunPhaseTimeListObject.Phases.END)
-                       {
-                               //draw the vertical end line
-                               pixmap.DrawLine(pen_double_contacts,
-                                               xEnd + chunkMargins, alto-bottomMargin -4,
-                                               xEnd + chunkMargins, alto-bottomMargin -(4 + chunkMargins));
-
-                               //draw the horizontal start-end line
-                               pixmap.DrawLine(pen_double_contacts,
-                                               lastChunkStart - chunkMargins, alto-bottomMargin -(4 + 
chunkMargins),
-                                               xEnd + chunkMargins, alto-bottomMargin -(4 + chunkMargins));
-                               LogB.Information("runPTL draw end");
-                       }
-
-               }
-
-               int lWidth = 1;
-               int lHeight = 1;
-               if(drawStart)
-               {
-                       //paint start vertical line
-                       int xStart2 = event_execute_rightMargin + Convert.ToInt32((ancho - 
2*event_execute_rightMargin) *
-                                       (negativePTLTime) / timeTotalWithExtraPTL) -1;
-                       pixmap.DrawLine(pen_double_contacts, xStart2 +1, 10, xStart2 +1, alto-bottomMargin-4);
-
-                       layoutMid_run_simple.SetMarkup("Start");
-                       layoutMid_run_simple.GetPixelSize(out lWidth, out lHeight);
-                       pixmap.DrawLayout (pen_double_contacts,
-                                       xStart2 -lWidth/2, 0, layoutMid_run_simple);
-               }
-
-               if(drawEnd)
-               {
-                       //paint end vertical line
-                       int xEnd2 = event_execute_rightMargin + Convert.ToInt32((ancho - 
2*event_execute_rightMargin) *
-                                       (timeTotal + negativePTLTime) / timeTotalWithExtraPTL);
-                       pixmap.DrawLine(pen_double_contacts, xEnd2, 10, xEnd2, alto-bottomMargin-4);
-
-                       layoutMid_run_simple.SetMarkup("End");
-                       layoutMid_run_simple.GetPixelSize(out lWidth, out lHeight);
-                       pixmap.DrawLayout (pen_double_contacts,
-                                       xEnd2 -lWidth/2, 0, layoutMid_run_simple);
-               }
-       }
-
        private void paintPulse (Gtk.DrawingArea drawingarea, double lastTime, string timesString, double 
avgTime, int pulses, 
                        double maxValue, double minValue, int topMargin, int bottomMargin)
        {
@@ -1988,9 +1880,7 @@ public partial class ChronoJumpWindow
                                break;
                        case EventType.Types.RUN:
                                if(thisRunIsSimple)
-                                       
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject, animate,
-                                                       currentEventExecute.RunPTL
-                                                       );
+                                       
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject, animate);
                                else {
                                        bool volumeOnHere = preferences.volumeOn;
                                        //do not play good or bad sounds at RSA because we need to hear the 
GO sound
@@ -2063,7 +1953,6 @@ public partial class ChronoJumpWindow
        Gdk.GC pen_rojo; //tc, also time; jump avg personTc
        //Gdk.GC pen_azul_claro; //tf, also speed and pulse; jump avg personTv. This for bars
        Gdk.GC pen_azul; //tf, also speed and pulse; jump avg personTv. This for lines
-       Gdk.GC pen_double_contacts;
        Gdk.GC pen_rojo_discont; //avg tc in reactive; jump avg sessionTc 
        //Gdk.GC pen_azul_claro_discont; //avg tf in reactive; jump avg sessionTv
        Gdk.GC pen_azul_discont; //avg tf in reactive; jump avg sessionTv
@@ -2147,8 +2036,6 @@ public partial class ChronoJumpWindow
                pen_background = new Gdk.GC(event_execute_drawingarea.GdkWindow);
                pen_background_shifted = new Gdk.GC(event_execute_drawingarea.GdkWindow);
 
-               pen_double_contacts = new 
Gdk.GC(event_execute_drawingarea_run_simple_double_contacts.GdkWindow);
-               
                pen_rojo.Foreground = UtilGtk.RED_PLOTS;
                //pen_azul_claro.Foreground = UtilGtk.LIGHT_BLUE_PLOTS;
                pen_azul.Foreground = UtilGtk.BLUE_PLOTS;
@@ -2190,7 +2077,6 @@ public partial class ChronoJumpWindow
 
                pen_background.Foreground = colorBackground;
                pen_background_shifted.Foreground = colorBackgroundShifted;
-               pen_double_contacts.Foreground = colorBackground;
        }
        void on_event_execute_button_cancel_clicked (object o, EventArgs args)
        {
@@ -3368,3 +3254,28 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
                                14, 22, title); //22 because there are two rows
        }
 }
+
+//TODO: here we will have the methods: getRunSRunINegativePTLTime, getRunSRunITimeTotalWithExtraPTLTime, ...
+public class CairoManageRunDoubleContacts
+{
+       private DrawingArea darea;
+       private string fontStr;
+
+       public CairoManageRunDoubleContacts (DrawingArea darea, string fontStr)
+       {
+               this.darea = darea;
+               this.fontStr = fontStr;
+       }
+
+       public void Paint (List<RunPhaseTimeListObject> runPTLInListForPainting,
+                        double timeTotal, double timeTotalWithEXtraPTL, double negativePTLTime,
+                       bool drawStart, bool drawEnd)
+       {
+               if(darea == null || darea.GdkWindow == null) //at start program, this can fail
+                       return;
+
+               CairoRunDoubleContacts crdc = new CairoRunDoubleContacts (darea, fontStr);
+               crdc.GraphDo (runPTLInListForPainting,
+                               timeTotal, timeTotalWithEXtraPTL, negativePTLTime, true, true);
+       }
+}


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