[chronojump] Encoder analyze single instant (95%)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder analyze single instant (95%)
- Date: Thu, 4 Feb 2016 13:48:38 +0000 (UTC)
commit 9598909181799d37aeeb7eff1f0f0bedcb006ea4
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Feb 4 14:39:39 2016 +0100
Encoder analyze single instant (95%)
encoder/graph.R | 28 +--
glade/chronojump.glade | 637 ++++++++++++++++++++++++++++++++++++++++--------
src/encoder.cs | 137 ++++++++++-
src/gui/chronojump.cs | 38 ---
src/gui/encoder.cs | 131 ++++++++--
5 files changed, 782 insertions(+), 189 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 5097ba4..154a837 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -674,29 +674,6 @@ canJump <- function(encoderConfigurationName)
}
-#find at what pixel (X) of final graph we have a millisecond
-#time is the time in ms where we search the pixel
-#this function will be moved to C# code
-calculatePixelXByTime <- function (time, width)
-{
- write("sending coordinates",stderr())
- write(c("usr",par("usr")),stderr())
- write(c("plt",par("plt")),stderr())
-
- #1) calculate the pixels in plot area
- pxPlotArea <- width * (par("plt")[2]-par("plt")[1])
-
- #2) calculate the ms in plot area
- msPlotArea <- par("usr")[2]-par("usr")[1]
-
- #3) rule of three
- px <- (time - par("usr")[1]) * pxPlotArea / msPlotArea
-
- #4) fix margin
- px <- px + par("plt")[1]*width
- write(c("px",px),stderr())
-}
-
paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose, highlight,
startX, startH, smoothingOneEC, smoothingOneC, massBody, massExtra,
encoderConfigurationName,diameter,diameterExt,anglePush,angleWeight,inertiaMomentum,gearedDown,
#encoderConfiguration stuff
@@ -2708,8 +2685,9 @@ doProcess <- function(options)
)
- #calculatePixelXByTime(100, width)
- write(c(op$Width, par("usr"), par("plt")), op$SpecialData)
+ write(op$Width, op$SpecialData)
+ write(par("usr"), op$SpecialData, append=TRUE)
+ write(par("plt"), op$SpecialData, append=TRUE)
#record array of data
write("going to create array of data", stderr())
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 190888a..20e7790 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -579,47 +579,6 @@
<property name="position">2</property>
</packing>
</child>
- <child>
- <widget class="GtkVBox" id="vbox63">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <widget class="GtkDrawingArea" id="drawingarea_cairo_prova">
- <property name="width_request">165</property>
- <property name="height_request">44</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <signal name="configure_event"
handler="on_drawingarea_cairo_prova_configure_event" swapped="no"/>
- <signal name="expose_event"
handler="on_drawingarea_cairo_prova_expose_event" swapped="no"/>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHScale" id="hscale_cairo_prova">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">1 1 165 1 10 0</property>
- <property name="round_digits">1</property>
- <property name="value_pos">bottom</property>
- <signal name="value_changed"
handler="on_hscale_cairo_prova_value_changed" swapped="no"/>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -7981,6 +7940,12 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -9455,6 +9420,12 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -10570,6 +10541,12 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -17983,46 +17960,124 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox68">
+ <widget class="GtkTable"
id="table_encoder_analyze_instant">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">2</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">6</property>
+ <property name="column_spacing">8</property>
+ <property name="row_spacing">4</property>
<child>
- <widget class="GtkHScale"
id="hscale_encoder_analyze_1">
+ <widget class="GtkLabel" id="label143">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">0 0 300 1 10
0</property>
- <property name="round_digits">0</property>
- <property name="digits">0</property>
- <signal name="value_changed"
handler="on_hscale_encoder_analyze_1_value_changed" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">Speed</property>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkHScale"
id="hscale_encoder_analyze_2">
+ <widget class="GtkLabel" id="label144">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="round_digits">0</property>
- <property name="digits">0</property>
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">Acceleration</property>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkTable" id="table1">
+ <widget class="GtkLabel" id="label145">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">3</property>
- <property name="n_columns">5</property>
- <property name="column_spacing">4</property>
- <property name="row_spacing">4</property>
+ <property name="label"
translatable="yes">Force</property>
+ </widget>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label146">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">Power</property>
+ </widget>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_speed_a">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_accel_a">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_force_a">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_power_a">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
<child>
<placeholder/>
</child>
@@ -18042,120 +18097,402 @@ on current Chronojump version.</property>
<placeholder/>
</child>
<child>
- <widget class="GtkLabel" id="label143">
+ <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>
- <property name="label"
translatable="yes">Speed</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_accel_b">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_force_b">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_power_b">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label149">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">Time</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label144">
+ <widget class="GtkLabel"
id="label_encoder_analyze_time_a">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label"
translatable="yes">Acceleration</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_time_b">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_average">
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">AVG</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_max">
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">MAX</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox194">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkLabel" id="label154">
+ <property name="width_request">30</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label152">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">A</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <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="round_digits">0</property>
+ <property name="digits">0</property>
+ <property name="draw_value">False</property>
+ <signal name="value_changed"
handler="on_hscale_encoder_analyze_a_value_changed" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox195">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkCheckButton"
id="checkbutton_encoder_analyze_b">
+ <property name="width_request">30</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">False</property>
+ <property name="xalign">1</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled"
handler="on_checkbutton_encoder_analyze_b_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label155">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">B</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <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="round_digits">0</property>
+ <property name="digits">0</property>
+ <property name="draw_value">False</property>
+ <signal name="value_changed"
handler="on_hscale_encoder_analyze_b_value_changed" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label_encoder_analyze_speed_average">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label145">
+ <widget class="GtkLabel"
id="label_encoder_analyze_accel_average">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label"
translatable="yes">Force</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label146">
+ <widget class="GtkLabel"
id="label_encoder_analyze_force_average">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label"
translatable="yes">Power</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label_encoder_analyze_speed_1">
+ <widget class="GtkLabel"
id="label_encoder_analyze_power_average">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label_encoder_analyze_accel_1">
+ <widget class="GtkLabel"
id="label_encoder_analyze_speed_max">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label_encoder_analyze_force_1">
+ <widget class="GtkLabel"
id="label_encoder_analyze_accel_max">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label_encoder_analyze_power_1">
+ <widget class="GtkLabel"
id="label_encoder_analyze_force_max">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="width_chars">8</property>
</widget>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options"/>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <placeholder/>
+ <widget class="GtkLabel"
id="label_encoder_analyze_power_max">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
</child>
<child>
- <placeholder/>
- </child>
+ <widget class="GtkLabel"
id="label_needed_to_not_shrink">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"/>
</packing>
</child>
<child>
- <placeholder/>
+ <widget class="GtkLabel"
id="label_needed_to_not_shrink_1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">8</property>
+ </widget>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options"/>
+ <property name="y_options"/>
+ </packing>
</child>
</widget>
<packing>
@@ -22587,6 +22924,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -23601,6 +23944,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -25107,6 +25456,12 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -25670,6 +26025,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -37656,6 +38017,42 @@ options</property>
<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>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -39675,6 +40072,30 @@ 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>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -40958,12 +41379,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>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel" id="label218">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -41977,6 +42392,12 @@ 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>
</widget>
</child>
</widget>
@@ -45763,6 +46184,12 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -46441,6 +46868,12 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -47134,6 +47567,12 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index 931d8c6..5576f09 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -1440,16 +1440,38 @@ public class EncoderAnalyzeInstant
public List<double> force;
public List<double> power;
+ public int graphWidth;
+
+ private Rx1y2 usr;
+ private Rx1y2 plt;
+
+ private double pxPlotArea;
+ private double msPlotArea;
+
+ //last calculated values on last range of msa and msb
+ public double speedAverageLast;
+ public double speedMaxLast;
+ public double accelAverageLast;
+ public double accelMaxLast;
+ public double forceAverageLast;
+ public double forceMaxLast;
+ public double powerAverageLast;
+ public double powerMaxLast;
+
public EncoderAnalyzeInstant() {
speed = new List<double>();
accel = new List<double>();
force = new List<double>();
power = new List<double>();
+
+ graphWidth = 0;
+ pxPlotArea = 0;
+ msPlotArea = 0;
}
//file has a first line with headers
//2nd.... full data
- public void ReadFile(string filename)
+ public void ReadArrayFile(string filename)
{
List<string> lines = Util.ReadFileAsStringList(filename);
if(lines == null)
@@ -1471,15 +1493,120 @@ public class EncoderAnalyzeInstant
power.Add(Convert.ToDouble(Util.ChangeDecimalSeparator(lsplit[4])));
}
}
+
+ public void ReadGraphParams(string filename)
+ {
+ List<string> lines = Util.ReadFileAsStringList(filename);
+ if(lines == null)
+ return;
+ if(lines.Count < 3)
+ return;
- public double GetSpeed(int ms) { return(speed[ms]); }
- public double GetAccel(int ms) { return(accel[ms]); }
- public double GetForce(int ms) { return(force[ms]); }
- public double GetPower(int ms) { return(power[ms]); }
+ graphWidth = Convert.ToInt32(lines[0]);
+ usr = new Rx1y2(lines[1]);
+ plt = new Rx1y2(lines[2]);
+
+ // calculate the pixels in plot area
+ pxPlotArea = graphWidth * (plt.x2 - plt.x1);
+
+ //calculate the ms in plot area
+ msPlotArea = usr.x2 - usr.x1;
+ }
+
+ //gets an instant value
+ public double GetParam(string param, int ms)
+ {
+ if(ms > speed.Count)
+ return -1;
+
+ else {
+ if(param == "speed")
+ return speed[ms];
+ else if(param == "accel")
+ return accel[ms];
+ else if(param == "force")
+ return force[ms];
+ else if(param == "power")
+ return power[ms];
+ else
+ return -2;
+ }
+ }
+
+ //calculates from a range
+ public bool CalculateRangeParams(int msa, int msb)
+ {
+ //if msb < msa invert them
+ if(msb < msa) {
+ int temp = msa;
+ msa = msb;
+ msb = temp;
+ }
+ if(msa > speed.Count || msb > speed.Count)
+ return false;
+
+ getAverageAndMax(speed, msa, msb, out speedAverageLast, out speedMaxLast);
+ getAverageAndMax(accel, msa, msb, out accelAverageLast, out accelMaxLast);
+ getAverageAndMax(force, msa, msb, out forceAverageLast, out forceMaxLast);
+ getAverageAndMax(power, msa, msb, out powerAverageLast, out powerMaxLast);
+
+ return true;
+ }
+ public void getAverageAndMax(List<double> dlist, int ini, int end, out double listAVG, out double
listMAX) {
+ if(ini == end) {
+ listAVG = dlist[ini];
+ listMAX = dlist[ini];
+ }
+
+ double sum = 0;
+ double max = - 1000000;
+ for(int i = ini; i <= end; i ++) {
+ sum += dlist[i];
+ if(dlist[i] > max)
+ max = dlist[i];
+ }
+
+ listAVG = sum / (end - ini + 1); //+1 because count starts at 0
+ listMAX = max;
+ }
+
+
+ public int GetVerticalLinePosition(int ms)
+ {
+ //this can be called on expose event before calculating needed parameters
+ if(graphWidth == 0 || pxPlotArea == 0 || msPlotArea == 0)
+ return 0;
+
+ // rule of three
+ double px = (ms - usr.x1) * pxPlotArea / msPlotArea;
+
+ // fix margin
+ px = px + plt.x1 * graphWidth;
+
+ return Convert.ToInt32(px);
+ }
+
public void PrintDebug() {
LogB.Information("Printing speed");
foreach(double s in speed)
LogB.Debug(s.ToString());
}
}
+
+//for objects coming from R that have "x1 x2 y1 y2" like usr or par
+public class Rx1y2
+{
+ public double x1;
+ public double x2;
+ public double y1;
+ public double y2;
+
+ public Rx1y2 (string s) {
+ string [] sFull = s.Split(new char[] {' '});
+ x1 = Convert.ToDouble(Util.ChangeDecimalSeparator(sFull[0]));
+ x2 = Convert.ToDouble(Util.ChangeDecimalSeparator(sFull[1]));
+ y1 = Convert.ToDouble(Util.ChangeDecimalSeparator(sFull[2]));
+ y2 = Convert.ToDouble(Util.ChangeDecimalSeparator(sFull[3]));
+ }
+}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 5144223..8b68221 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -65,9 +65,6 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_selector_start_runs;
[Widget] Gtk.Image image_selector_start_encoder;
- [Widget] Gtk.DrawingArea drawingarea_cairo_prova;
- [Widget] Gtk.HScale hscale_cairo_prova;
-
//gui for small screens
[Widget] Gtk.RadioButton radio_mode_jumps_small;
[Widget] Gtk.RadioButton radio_mode_jumps_reactive_small;
@@ -467,39 +464,6 @@ public partial class ChronoJumpWindow
//int chronopicCancelledTimes = 0;
- Pixbuf cairo_pixbuf;
- public void on_drawingarea_cairo_prova_expose_event(object o, ExposeEventArgs args)
- {
- DrawingArea area = (DrawingArea) o;
- using (Cairo.Context g = Gdk.CairoHelper.Create (area.GdkWindow))
- {
- //add image
- Gdk.CairoHelper.SetSourcePixbuf (g, cairo_pixbuf, 0, 0);
- g.Paint();
-
- //add rectangle
- g.SetSourceRGBA(1, 0, 0, 1); //red
-
- int xpos = Convert.ToInt32(hscale_cairo_prova.Value);
- g.MoveTo(xpos, 0);
- g.LineTo(xpos, cairo_pixbuf.Height);
-
- g.Stroke();
-
- g.GetTarget ().Dispose ();
- }
- }
- public void on_drawingarea_cairo_prova_configure_event(object o, ConfigureEventArgs args)
- {
- }
-
- public void on_hscale_cairo_prova_value_changed(object o, EventArgs args)
- {
- LogB.Information("changed!");
- LogB.Information(hscale_cairo_prova.Value.ToString());
- drawingarea_cairo_prova.QueueDraw(); //will fire ExposeEvent
- }
-
//only called the first time the software runs
//and only on windows
private void on_language_clicked(object o, EventArgs args) {
@@ -539,8 +503,6 @@ public partial class ChronoJumpWindow
this.progName = progName;
this.runningFileName = runningFileName;
- cairo_pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo);
-
Glade.XML gxml;
gxml = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", "app1",
"chronojump");
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index f8a9f35..271db60 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -134,12 +134,31 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box hbox_encoder_analyze_data_compare;
[Widget] Gtk.ComboBox combo_encoder_analyze_data_compare;
[Widget] Gtk.Button button_encoder_analyze_data_compare;
-
- [Widget] Gtk.HScale hscale_encoder_analyze_1;
- [Widget] Gtk.Label label_encoder_analyze_speed_1;
- [Widget] Gtk.Label label_encoder_analyze_accel_1;
- [Widget] Gtk.Label label_encoder_analyze_force_1;
- [Widget] Gtk.Label label_encoder_analyze_power_1;
+
+ [Widget] Gtk.Table table_encoder_analyze_instant;
+ [Widget] Gtk.HScale hscale_encoder_analyze_a;
+ [Widget] Gtk.CheckButton checkbutton_encoder_analyze_b;
+ [Widget] Gtk.HScale hscale_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;
+ [Widget] Gtk.Label label_encoder_analyze_force_a;
+ [Widget] Gtk.Label label_encoder_analyze_power_a;
+ [Widget] Gtk.Label label_encoder_analyze_time_b;
+ [Widget] Gtk.Label label_encoder_analyze_speed_b;
+ [Widget] Gtk.Label label_encoder_analyze_accel_b;
+ [Widget] Gtk.Label label_encoder_analyze_force_b;
+ [Widget] Gtk.Label label_encoder_analyze_power_b;
+ [Widget] Gtk.Label label_encoder_analyze_speed_average;
+ [Widget] Gtk.Label label_encoder_analyze_accel_average;
+ [Widget] Gtk.Label label_encoder_analyze_force_average;
+ [Widget] Gtk.Label label_encoder_analyze_power_average;
+ [Widget] Gtk.Label label_encoder_analyze_speed_max;
+ [Widget] Gtk.Label label_encoder_analyze_accel_max;
+ [Widget] Gtk.Label label_encoder_analyze_force_max;
+ [Widget] Gtk.Label label_encoder_analyze_power_max;
+ [Widget] Gtk.Label label_encoder_analyze_average;
+ [Widget] Gtk.Label label_encoder_analyze_max;
[Widget] Gtk.Button button_encoder_analyze_image_save;
[Widget] Gtk.Button button_encoder_analyze_table_save;
@@ -4885,14 +4904,13 @@ public partial class ChronoJumpWindow
encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
}
} else { //encoderActions.ANALYZE
- //the -3 is because image is inside (is smaller than) viewport
+
+ //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;
if(encoderAnalysis == "single") {
- image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_analyze)-5;
- image_encoder_height =
UtilGtk.WidgetHeight(viewport_image_encoder_analyze)/2; //to allow hslides and table
- //TODO: improve this
- } else {
- image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_analyze)-5;
- image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_analyze)-5;
+ Gdk.Rectangle allocation = table_encoder_analyze_instant.Allocation;
+ image_encoder_height -= allocation.Height; //to allow hslides and table
}
encoder_pulsebar_analyze.Text = Catalog.GetString("Please, wait.");
@@ -5366,18 +5384,77 @@ public partial class ChronoJumpWindow
Pixbuf drawingarea_encoder_analyze_cairo_pixbuf;
[Widget] Gtk.DrawingArea drawingarea_encoder_analyze_instant;
- void on_hscale_encoder_analyze_1_value_changed (object o, EventArgs args) {
+ void on_hscale_encoder_analyze_a_value_changed (object o, EventArgs args) {
+ if(eai != null) {
+ int ms = Convert.ToInt32(hscale_encoder_analyze_a.Value);
+ 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);
+
+ if(checkbutton_encoder_analyze_b.Active)
+ encoder_analyze_instant_calculate_params();
+
+ drawingarea_encoder_analyze_instant.QueueDraw(); //will fire ExposeEvent
+ }
+ }
+
+ void on_hscale_encoder_analyze_b_value_changed (object o, EventArgs args) {
if(eai != null) {
- int ms = Convert.ToInt32(hscale_encoder_analyze_1.Value);
- label_encoder_analyze_speed_1.Text = Util.TrimDecimals(eai.GetSpeed(ms), 2);
- label_encoder_analyze_accel_1.Text = Util.TrimDecimals(eai.GetAccel(ms), 2);
- label_encoder_analyze_force_1.Text = Util.TrimDecimals(eai.GetForce(ms), 2);
- label_encoder_analyze_power_1.Text = Util.TrimDecimals(eai.GetPower(ms), 2);
+ int msb = Convert.ToInt32(hscale_encoder_analyze_b.Value);
+ 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);
+
+ encoder_analyze_instant_calculate_params();
drawingarea_encoder_analyze_instant.QueueDraw(); //will fire ExposeEvent
}
}
+ void encoder_analyze_instant_calculate_params() {
+ int msa = Convert.ToInt32(hscale_encoder_analyze_a.Value);
+ int msb = Convert.ToInt32(hscale_encoder_analyze_b.Value);
+ bool success = eai.CalculateRangeParams(msa, msb);
+ 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_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);
+ }
+ }
+
+ void on_checkbutton_encoder_analyze_b_toggled (object o, EventArgs args) {
+ bool visible = checkbutton_encoder_analyze_b.Active;
+
+ hscale_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;
+ label_encoder_analyze_force_b.Visible = visible;
+ label_encoder_analyze_power_b.Visible = visible;
+ label_encoder_analyze_speed_average.Visible = visible;
+ label_encoder_analyze_accel_average.Visible = visible;
+ label_encoder_analyze_force_average.Visible = visible;
+ label_encoder_analyze_power_average.Visible = visible;
+ label_encoder_analyze_speed_max.Visible = visible;
+ label_encoder_analyze_accel_max.Visible = visible;
+ label_encoder_analyze_force_max.Visible = visible;
+ label_encoder_analyze_power_max.Visible = visible;
+ label_encoder_analyze_average.Visible = visible;
+ label_encoder_analyze_max.Visible = visible;
+
+ drawingarea_encoder_analyze_instant.QueueDraw(); //will fire ExposeEvent
+ }
+
public void on_drawingarea_encoder_analyze_instant_expose_event(object o, ExposeEventArgs args)
{
if(drawingarea_encoder_analyze_cairo_pixbuf == null)
@@ -5393,9 +5470,15 @@ public partial class ChronoJumpWindow
//add rectangle
g.SetSourceRGBA(0.906, 0.745, 0.098, 1); //Chronojump yellow
- int xpos = Convert.ToInt32(hscale_encoder_analyze_1.Value);
+ int xpos =
eai.GetVerticalLinePosition(Convert.ToInt32(hscale_encoder_analyze_a.Value));
g.MoveTo(xpos, 0);
g.LineTo(xpos, drawingarea_encoder_analyze_cairo_pixbuf.Height);
+
+ if(checkbutton_encoder_analyze_b.Active) {
+ xpos =
eai.GetVerticalLinePosition(Convert.ToInt32(hscale_encoder_analyze_b.Value));
+ g.MoveTo(xpos, 0);
+ g.LineTo(xpos, drawingarea_encoder_analyze_cairo_pixbuf.Height);
+ }
g.Stroke();
@@ -5687,8 +5770,12 @@ public partial class ChronoJumpWindow
if(encoderAnalysis == "single") {
eai = new EncoderAnalyzeInstant();
- eai.ReadFile(
- UtilEncoder.GetEncoderInstantDataTempFileName());
+ eai.ReadArrayFile(UtilEncoder.GetEncoderInstantDataTempFileName());
+ 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);
//eai.PrintDebug();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]