[chronojump] ForceSensor analyze instant with AB Cairo transparent rectangle



commit d2d9af4b06091c1f5a405b395e9bca8e9cde0e01
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 14 18:36:49 2020 +0100

    ForceSensor analyze instant with AB Cairo transparent rectangle

 src/Makefile.am                    |   3 +-
 src/gui/app1/forceSensorAnalyze.cs |  18 ++++--
 src/gui/cairo/util.cs              | 111 +++++++++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 5 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3b70abd6..3d65ca6a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,11 +19,12 @@ SOURCES = \
        gui/app1/pulse.cs\
        gui/app1/reactionTime.cs\
        gui/app1/run.cs\
-       gui/cairo/xy.cs\
        gui/cairo/jumpsDjOptimalFall.cs\
        gui/cairo/jumpsEvolution.cs\
        gui/cairo/jumpsProfile.cs\
        gui/cairo/jumpsWeightFVProfile.cs\
+       gui/cairo/util.cs\
+       gui/cairo/xy.cs\
        gui/chronojumpImporter.cs\
        gui/chronojumpPersons.cs\
        gui/chronopic.cs\
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index 28f71379..3259edd3 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -877,18 +877,28 @@ public partial class ChronoJumpWindow
                        force_sensor_ai_sizeChanged = false;
                }
 
-               Gdk.Rectangle area = args.Event.Area;
+
+               Gdk.Rectangle rect_area = args.Event.Area;
 
                //sometimes this is called when paint is finished
                //don't let this erase win
+               //here is were actually is drawn
                if(force_sensor_ai_pixmap != null) {
                        args.Event.Window.DrawDrawable(force_sensor_ai_drawingarea.Style.WhiteGC, 
force_sensor_ai_pixmap,
-                               area.X, area.Y,
-                               area.X, area.Y,
-                               area.Width, area.Height);
+                               rect_area.X, rect_area.Y,
+                               rect_area.X, rect_area.Y,
+                               rect_area.Width, rect_area.Height);
                }
 
+               if(fsAI != null)
+                       CairoUtil.PaintVerticalLinesAndRectangle (
+                                       force_sensor_ai_drawingarea,
+                                       
fsAI.GetXFromSampleCount(Convert.ToInt32(hscale_force_sensor_ai_a.Value)),
+                                       
fsAI.GetXFromSampleCount(Convert.ToInt32(hscale_force_sensor_ai_b.Value)),
+                                       true); //paint the second line and rectangle (if a != b)
+
                force_sensor_ai_allocationXOld = allocation.Width;
+
                LogB.Information("EXPOSE END");
        }
 
diff --git a/src/gui/cairo/util.cs b/src/gui/cairo/util.cs
new file mode 100644
index 00000000..28b405c8
--- /dev/null
+++ b/src/gui/cairo/util.cs
@@ -0,0 +1,111 @@
+
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  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> 
+ */
+
+using System;
+using Cairo;
+using Gtk;
+using Gdk;
+
+public static class CairoUtil
+{
+       /*
+        * public methods
+        */
+
+       public static void PaintVerticalLinesAndRectangle (
+                       Gtk.DrawingArea darea, int xposA, int xposB, bool posBuse)
+       {
+               using (Cairo.Context g = Gdk.CairoHelper.Create (darea.GdkWindow)) 
+               {
+                       paintVerticalLinesAndRectangleDo (g, darea.Allocation.Height, xposA, xposB, posBuse);
+                       g.Stroke();
+                       g.GetTarget ().Dispose ();
+               }
+       }
+       public static void PaintVerticalLinesAndRectangleOnSurface (
+                       Gtk.DrawingArea darea, int xposA, int xposB, bool posBuse,
+                       Pixbuf pixbuf)
+       {
+               using (Cairo.Context g = Gdk.CairoHelper.Create (darea.GdkWindow)) 
+               {
+                       //add image
+                       Gdk.CairoHelper.SetSourcePixbuf (g, pixbuf, 0, 0);
+
+                       g.Paint();
+
+                       paintVerticalLinesAndRectangleDo (g, darea.Allocation.Height, xposA, xposB, posBuse);
+                       g.Stroke();
+                       g.GetTarget ().Dispose ();
+               }
+       }
+
+       /*
+        * private methods
+        */
+
+       private static void paintVerticalLinesAndRectangleDo (Cairo.Context g, int height, int xposA, int 
xposB, bool posBuse)
+       {
+               //add rectangle
+               g.SetSourceRGBA(0.906, 0.745, 0.098, 1); //Chronojump yellow
+
+               paintVerticalLine(g, xposA, height);
+
+               if(posBuse && xposA != xposB)
+               {
+                       paintVerticalLine(g, xposB, height);
+
+                       g.SetSourceRGBA(0.906, 0.745, 0.098, .5); //Chronojump yellow, half transp
+
+                       //create rectangle
+                       int min = Math.Min(xposA, xposB) +1;
+                       int max = Math.Max(xposA, xposB) -1;
+                       if(min < max)
+                       {
+                               g.Rectangle(min ,9 , max-min, height -18);
+                               g.Fill();
+                       }
+               }
+       }
+
+       private static void paintVerticalLine (Cairo.Context g, int x, int height)
+       {
+               //vertical line
+               g.MoveTo(x, 9);
+               //g.LineTo(x, drawingarea_encoder_analyze_cairo_pixbuf.Height);
+               g.LineTo(x, height);
+               g.Stroke();
+
+               //top triangle
+               g.MoveTo(x -4, 0);
+               g.LineTo(x   , 8);
+               g.LineTo(x +4, 0);
+               g.LineTo(x -4, 0);
+               g.Fill();
+
+               /*
+               //bottom triangle currently not drawn because bottom space changes and half of triangle is 
not shown
+               g.MoveTo(x -4, drawingarea_encoder_analyze_cairo_pixbuf.Height);
+               g.LineTo(x   , drawingarea_encoder_analyze_cairo_pixbuf.Height -8);
+               g.LineTo(x +4, drawingarea_encoder_analyze_cairo_pixbuf.Height);
+               */
+       }
+
+}


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