[chronojump] Encoder analyze single instant (98%)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder analyze single instant (98%)
- Date: Thu, 4 Feb 2016 23:24:05 +0000 (UTC)
commit ec8e83d6c60965461f008342aa6bb270fff3c8cc
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 5 00:19:32 2016 +0100
Encoder analyze single instant (98%)
glade/chronojump.glade | 218 ++++++++++++++++++++++++++++++++++++++---------
src/encoder.cs | 7 ++-
src/gui/encoder.cs | 59 ++++++++-----
3 files changed, 219 insertions(+), 65 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 20e7790..27f4658 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7946,6 +7946,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -9426,6 +9429,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -10547,6 +10553,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -17907,7 +17916,7 @@ on current Chronojump version.</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
- <widget class="GtkScrolledWindow"
id="scrolledwindow4">
+ <widget class="GtkScrolledWindow"
id="scrolledwindow_image_encoder_analyze">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property
name="hscrollbar_policy">automatic</property>
@@ -18079,42 +18088,6 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel"
id="label_encoder_analyze_speed_b">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -18276,7 +18249,7 @@ on current Chronojump version.</property>
<widget class="GtkHScale"
id="hscale_encoder_analyze_a">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">0 0 300 1 10
0</property>
+ <property name="adjustment">1 1 300 1 10
0</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="draw_value">False</property>
@@ -18288,6 +18261,60 @@ on current Chronojump version.</property>
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkHBox" id="hbox196">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkButton"
id="button_hscale_encoder_analyze_a_pre">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_hscale_encoder_analyze_a_pre_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkImage" id="image41">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-go-back</property>
+ <property name="icon-size">1</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton"
id="button_hscale_encoder_analyze_a_post">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_hscale_encoder_analyze_a_post_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkImage" id="image67">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-go-forward</property>
+ <property name="icon-size">1</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="top_attach">1</property>
@@ -18331,7 +18358,7 @@ on current Chronojump version.</property>
<child>
<widget class="GtkHScale"
id="hscale_encoder_analyze_b">
<property name="can_focus">True</property>
- <property name="adjustment">0 0 300 1 10
0</property>
+ <property name="adjustment">1 1 300 1 10
0</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="draw_value">False</property>
@@ -18343,6 +18370,59 @@ on current Chronojump version.</property>
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkHBox"
id="hbox_buttons_scale_encoder_analyze_b">
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkButton"
id="button_hscale_encoder_analyze_b_pre">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_hscale_encoder_analyze_b_pre_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkImage" id="image66">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-go-back</property>
+ <property name="icon-size">1</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton"
id="button_hscale_encoder_analyze_b_post">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_hscale_encoder_analyze_b_post_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkImage" id="image68">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-go-forward</property>
+ <property name="icon-size">1</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="top_attach">2</property>
@@ -18494,6 +18574,9 @@ on current Chronojump version.</property>
<property name="y_options"/>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -22930,6 +23013,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -23950,6 +24036,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -25462,6 +25551,9 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -26031,6 +26123,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -38053,6 +38148,24 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -40096,6 +40209,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -41376,9 +41501,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel" id="label218">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -42398,6 +42520,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -46190,6 +46315,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -46874,6 +47002,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -47573,6 +47704,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index 5576f09..a3c9fc1 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -1516,6 +1516,8 @@ public class EncoderAnalyzeInstant
//gets an instant value
public double GetParam(string param, int ms)
{
+ ms --; //converts from starting at 1 (graph) to starting at 0 (data)
+
if(ms > speed.Count)
return -1;
@@ -1536,6 +1538,9 @@ public class EncoderAnalyzeInstant
//calculates from a range
public bool CalculateRangeParams(int msa, int msb)
{
+ msa --; //converts from starting at 1 (graph) to starting at 0 (data)
+ msb --; //converts from starting at 1 (graph) to starting at 0 (data)
+
//if msb < msa invert them
if(msb < msa) {
int temp = msa;
@@ -1553,7 +1558,7 @@ public class EncoderAnalyzeInstant
return true;
}
- public void getAverageAndMax(List<double> dlist, int ini, int end, out double listAVG, out double
listMAX) {
+ private void getAverageAndMax(List<double> dlist, int ini, int end, out double listAVG, out double
listMAX) {
if(ini == end) {
listAVG = dlist[ini];
listMAX = dlist[ini];
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 25d752d..955caa0 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -139,6 +139,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.HScale hscale_encoder_analyze_a;
[Widget] Gtk.CheckButton checkbutton_encoder_analyze_b;
[Widget] Gtk.HScale hscale_encoder_analyze_b;
+ [Widget] Gtk.HBox hbox_buttons_scale_encoder_analyze_b;
[Widget] Gtk.Label label_encoder_analyze_time_a;
[Widget] Gtk.Label label_encoder_analyze_speed_a;
[Widget] Gtk.Label label_encoder_analyze_accel_a;
@@ -207,8 +208,9 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Label label_encoder_analyze_side_max;
[Widget] Gtk.CheckButton check_encoder_analyze_mean_or_max;
-
- [Widget] Gtk.Viewport viewport_image_encoder_analyze;
+
+ [Widget] Gtk.ScrolledWindow scrolledwindow_image_encoder_analyze;
+// [Widget] Gtk.Viewport viewport_image_encoder_analyze;
[Widget] Gtk.Notebook notebook_encoder_analyze;
[Widget] Gtk.Image image_encoder_analyze;
[Widget] Gtk.ProgressBar encoder_pulsebar_analyze;
@@ -4906,11 +4908,10 @@ public partial class ChronoJumpWindow
} else { //encoderActions.ANALYZE
//the -5 is because image is inside (is smaller than) viewport
- image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_analyze)-5;
- image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_analyze)-5;
+ image_encoder_width = UtilGtk.WidgetWidth(scrolledwindow_image_encoder_analyze)-10;
+ image_encoder_height = UtilGtk.WidgetHeight(scrolledwindow_image_encoder_analyze)-10;
if(encoderAnalysis == "single") {
- Gdk.Rectangle allocation = table_encoder_analyze_instant.Allocation;
- image_encoder_height -= allocation.Height; //to allow hslides and table
+ image_encoder_height -= UtilGtk.WidgetHeight(table_encoder_analyze_instant);
//to allow hslides and table
}
encoder_pulsebar_analyze.Text = Catalog.GetString("Please, wait.");
@@ -5390,8 +5391,8 @@ public partial class ChronoJumpWindow
label_encoder_analyze_time_a.Text = ms.ToString();
label_encoder_analyze_speed_a.Text = Util.TrimDecimals(eai.GetParam("speed",ms), 2);
label_encoder_analyze_accel_a.Text = Util.TrimDecimals(eai.GetParam("accel",ms), 2);
- label_encoder_analyze_force_a.Text = Util.TrimDecimals(eai.GetParam("force",ms), 2);
- label_encoder_analyze_power_a.Text = Util.TrimDecimals(eai.GetParam("power",ms), 2);
+ label_encoder_analyze_force_a.Text = Util.TrimDecimals(eai.GetParam("force",ms), 1);
+ label_encoder_analyze_power_a.Text = Util.TrimDecimals(eai.GetParam("power",ms), 1);
if(checkbutton_encoder_analyze_b.Active)
encoder_analyze_instant_calculate_params();
@@ -5406,8 +5407,8 @@ public partial class ChronoJumpWindow
label_encoder_analyze_time_b.Text = msb.ToString();
label_encoder_analyze_speed_b.Text = Util.TrimDecimals(eai.GetParam("speed",msb), 2);
label_encoder_analyze_accel_b.Text = Util.TrimDecimals(eai.GetParam("accel",msb), 2);
- label_encoder_analyze_force_b.Text = Util.TrimDecimals(eai.GetParam("force",msb), 2);
- label_encoder_analyze_power_b.Text = Util.TrimDecimals(eai.GetParam("power",msb), 2);
+ label_encoder_analyze_force_b.Text = Util.TrimDecimals(eai.GetParam("force",msb), 1);
+ label_encoder_analyze_power_b.Text = Util.TrimDecimals(eai.GetParam("power",msb), 1);
encoder_analyze_instant_calculate_params();
@@ -5415,6 +5416,19 @@ public partial class ChronoJumpWindow
}
}
+ void on_button_hscale_encoder_analyze_a_pre_clicked(object o, EventArgs args) {
+ hscale_encoder_analyze_a.Value -= 1;
+ }
+ void on_button_hscale_encoder_analyze_a_post_clicked(object o, EventArgs args) {
+ hscale_encoder_analyze_a.Value += 1;
+ }
+ void on_button_hscale_encoder_analyze_b_pre_clicked(object o, EventArgs args) {
+ hscale_encoder_analyze_b.Value -= 1;
+ }
+ void on_button_hscale_encoder_analyze_b_post_clicked(object o, EventArgs args) {
+ hscale_encoder_analyze_b.Value += 1;
+ }
+
void encoder_analyze_instant_calculate_params() {
int msa = Convert.ToInt32(hscale_encoder_analyze_a.Value);
int msb = Convert.ToInt32(hscale_encoder_analyze_b.Value);
@@ -5422,13 +5436,13 @@ public partial class ChronoJumpWindow
if(success) {
label_encoder_analyze_speed_average.Text = Util.TrimDecimals(eai.speedAverageLast, 2);
label_encoder_analyze_accel_average.Text = Util.TrimDecimals(eai.accelAverageLast, 2);
- label_encoder_analyze_force_average.Text = Util.TrimDecimals(eai.forceAverageLast, 2);
- label_encoder_analyze_power_average.Text = Util.TrimDecimals(eai.powerAverageLast, 2);
+ label_encoder_analyze_force_average.Text = Util.TrimDecimals(eai.forceAverageLast, 1);
+ label_encoder_analyze_power_average.Text = Util.TrimDecimals(eai.powerAverageLast, 1);
label_encoder_analyze_speed_max.Text = Util.TrimDecimals(eai.speedMaxLast, 2);
label_encoder_analyze_accel_max.Text = Util.TrimDecimals(eai.accelMaxLast, 2);
- label_encoder_analyze_force_max.Text = Util.TrimDecimals(eai.forceMaxLast, 2);
- label_encoder_analyze_power_max.Text = Util.TrimDecimals(eai.powerMaxLast, 2);
+ label_encoder_analyze_force_max.Text = Util.TrimDecimals(eai.forceMaxLast, 1);
+ label_encoder_analyze_power_max.Text = Util.TrimDecimals(eai.powerMaxLast, 1);
}
}
@@ -5436,6 +5450,7 @@ public partial class ChronoJumpWindow
bool visible = checkbutton_encoder_analyze_b.Active;
hscale_encoder_analyze_b.Visible = visible;
+ hbox_buttons_scale_encoder_analyze_b.Visible = visible;
label_encoder_analyze_time_b.Visible = visible;
label_encoder_analyze_speed_b.Visible = visible;
label_encoder_analyze_accel_b.Visible = visible;
@@ -5476,12 +5491,12 @@ public partial class ChronoJumpWindow
if(checkbutton_encoder_analyze_b.Active) {
int xposb =
eai.GetVerticalLinePosition(Convert.ToInt32(hscale_encoder_analyze_b.Value));
- g.MoveTo(xposb, 0);
- g.LineTo(xposb, drawingarea_encoder_analyze_cairo_pixbuf.Height);
- g.SetSourceRGBA(0.945, 0.84, 0.518, .5); //lighter yellow, half transp
- g.Rectangle(xposa ,0, xposb-xposa,
drawingarea_encoder_analyze_cairo_pixbuf.Height);
- g.Fill();
+ if(xposb != xposa) {
+ g.SetSourceRGBA(0.945, 0.84, 0.518, .5); //lighter yellow, half transp
+ g.Rectangle(xposa ,0, xposb-xposa,
drawingarea_encoder_analyze_cairo_pixbuf.Height);
+ g.Fill();
+ }
}
g.Stroke();
@@ -5747,7 +5762,7 @@ public partial class ChronoJumpWindow
UtilEncoder.GetEncoderGraphTempFileName(),
drawingarea_encoder_analyze_cairo_pixbuf);
- //TODO: define properties ot the hscales
+ drawingarea_encoder_analyze_instant.QueueDraw(); //will fire
ExposeEvent
notebook_encoder_analyze.CurrentPage = 1;
} else {
@@ -5778,8 +5793,8 @@ public partial class ChronoJumpWindow
eai.ReadGraphParams(UtilEncoder.GetEncoderSpecialDataTempFileName());
//ranges should have max value the number of the lines of csv file
minus the header
- hscale_encoder_analyze_a.SetRange(0, eai.speed.Count -1);
- hscale_encoder_analyze_b.SetRange(0, eai.speed.Count -1);
+ hscale_encoder_analyze_a.SetRange(1, eai.speed.Count);
+ hscale_encoder_analyze_b.SetRange(1, eai.speed.Count);
//eai.PrintDebug();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]