[chronojump] WIP encoder bars mouse button press will allow select/deselect reps
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] WIP encoder bars mouse button press will allow select/deselect reps
- Date: Thu, 23 Jan 2020 17:10:13 +0000 (UTC)
commit 831c39aab6ffc58b43203fc402410edc8900c36c
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Jan 23 17:08:41 2020 +0000
WIP encoder bars mouse button press will allow select/deselect reps
glade/app1.glade | 31 +++++++++++++++++++------------
src/gui/encoder.cs | 20 ++++++++++++++++++++
src/gui/encoderGraphObjects.cs | 38 ++++++++++++++++++++++++++++++++++++++
src/utilMath.cs | 31 +++++++++++++++++++++++++++++++
4 files changed, 108 insertions(+), 12 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index dc23d1b7..a6aeacf3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -22806,6 +22806,9 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -25053,18 +25056,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>
@@ -25101,6 +25092,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>
@@ -25273,6 +25276,7 @@ Concentric</property>
<widget class="GtkDrawingArea"
id="encoder_capture_curves_bars_drawingarea">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <signal name="button_press_event"
handler="on_encoder_capture_curves_bars_drawingarea_button_press_event" swapped="no"/>
<signal name="expose_event"
handler="on_encoder_capture_curves_bars_drawingarea_expose_event" swapped="no"/>
</widget>
<packing>
@@ -32351,6 +32355,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 72124c1b..6058eb4c 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5319,6 +5319,9 @@ public partial class ChronoJumpWindow
LogB.Debug("EXPOSE");
bool encoderGraphDoPlotJustCreated = false;
+ //needed to have mouse clicks button_press_event ()
+ encoder_capture_curves_bars_drawingarea.AddEvents((int) (Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask));
+
Gdk.Rectangle allocation = encoder_capture_curves_bars_drawingarea.Allocation;
if(encoder_capture_curves_bars_pixmap == null || encoder_capture_curves_sizeChanged ||
allocation.Width != encoder_capture_curves_allocationXOld ||
@@ -5361,6 +5364,23 @@ public partial class ChronoJumpWindow
encoder_capture_curves_allocationYOld = allocation.Height;
}
+ public void on_encoder_capture_curves_bars_drawingarea_button_press_event (object o,
ButtonPressEventArgs args)
+ {
+ LogB.Information(string.Format("Mouse X: {0}; Mouse Y: {1}", args.Event.X, args.Event.Y));
+
+ //if list exists, select the repetition
+ if(encoderGraphDoPlot != null)
+ {
+ int repetition = encoderGraphDoPlot.FindBarInPixel(args.Event.X);
+ LogB.Information("Repetition: " + repetition.ToString());
+ if(repetition > 0)
+ {
+ //continue like: gui/encoderTreeview EncoderCaptureItemToggled
+ //that manages if repetition should be discarded
+ //also see if that method shold be divided on 2 depending on who calls it
+ }
+ }
+ }
int encoder_capture_signal_allocationXOld;
bool encoder_capture_signal_sizeChanged;
diff --git a/src/gui/encoderGraphObjects.cs b/src/gui/encoderGraphObjects.cs
index bc2dc2f3..73c87398 100644
--- a/src/gui/encoderGraphObjects.cs
+++ b/src/gui/encoderGraphObjects.cs
@@ -54,6 +54,8 @@ public class EncoderGraphDoPlot
private ArrayList data; //data is related to mainVariable (barplot)
private ArrayList dataSecondary; //dataSecondary is related to secondary variable (by default range)
+ private EncoderBarsLimits encoderBarsLimits;
+
Pango.Layout layout_encoder_capture_curves_bars;
Pango.Layout layout_encoder_capture_curves_bars_text; //e, c
Pango.Layout layout_encoder_capture_curves_bars_superbig; //PlaySounds wewillrockyou
@@ -154,6 +156,7 @@ public class EncoderGraphDoPlot
graphWidth = drawingarea.Allocation.Width;
graphHeight = drawingarea.Allocation.Height;
+ encoderBarsLimits = new EncoderBarsLimits();
fillDataVariables();
plot();
@@ -562,6 +565,8 @@ public class EncoderGraphDoPlot
rect = new Rectangle(dLeft, dTop, dWidth, dHeight);
pixmap.DrawRectangle(my_pen, true, rect);
+ encoderBarsLimits.Add(count +1, dLeft, dLeft + dWidth); //first rep is 1
+
//paint diagonal line to distinguish eccentric-concentric
//line is painted before the black outline to fix graphical problems
if (eccon == "ec" || eccon == "ecS") {
@@ -779,7 +784,40 @@ public class EncoderGraphDoPlot
pixmap.DrawLayout (pen_black_encoder_capture, xStart, yStart, layout_message);
}
+ public int FindBarInPixel (double pixel)
+ {
+ return encoderBarsLimits.FindBarInPixel(pixel);
+ }
+
public bool GraphPrepared {
get { return graphPrepared; }
}
}
+
+//to store the xStart and xEnd of every encoder capture reptition
+//in order to be saved or not on clicking screen
+//note every rep will be c or ec
+public class EncoderBarsLimits
+{
+ private List<PointStartEnd> list;
+
+ public EncoderBarsLimits()
+ {
+ list = new List<PointStartEnd>();
+ }
+
+ public void Add (int id, double start, double end)
+ {
+ PointStartEnd p = new PointStartEnd(id, start, end);
+ list.Add(p);
+ }
+
+ public int FindBarInPixel (double pixel)
+ {
+ foreach(PointStartEnd p in list)
+ if(pixel >= p.Start && pixel <= p.End)
+ return p.Id;
+
+ return -1;
+ }
+}
diff --git a/src/utilMath.cs b/src/utilMath.cs
index 5b2b06a1..edacf592 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -48,6 +48,37 @@ public class Point
}
+//like Point but for having an xStart and xEnd
+public class PointStartEnd
+{
+ private int id;
+ private double start;
+ private double end;
+
+ public PointStartEnd (int id, double start, double end)
+ {
+ this.id = id;
+ this.start = start;
+ this.end = end;
+ }
+
+ public int Id {
+ get { return id; }
+ }
+ public double Start {
+ get { return start; }
+ }
+ public double End {
+ get { return end; }
+ }
+
+ public override string ToString()
+ {
+ return string.Format("Id:{0}; Start:{1}; End:{2}", id, start, end);
+ }
+
+}
+
public class LeastSquaresLine
{
//public double [] Coef; //indep, x
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]