[chronojump] Encoder capture options extra weight with two decimals
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder capture options extra weight with two decimals
- Date: Mon, 5 Mar 2018 12:56:09 +0000 (UTC)
commit a9513a0d4a081a192dac67769d35a216f4f450b3
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Mar 5 13:55:42 2018 +0100
Encoder capture options extra weight with two decimals
glade/app1.glade | 47 +++++++++++------------------------
src/gui/encoder.cs | 68 +++++++++++++++------------------------------------
src/gui/networks.cs | 3 +-
3 files changed, 36 insertions(+), 82 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 313b955..860b3b7 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1604,6 +1604,9 @@
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkLabel"
id="label_start_selector_jumps">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -18221,29 +18224,6 @@ Concentric</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <widget class="GtkSpinButton"
id="spin_encoder_extra_weight">
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="width_chars">3</property>
- <property
name="invisible_char_set">True</property>
- <property
name="primary_icon_activatable">False</property>
- <property
name="secondary_icon_activatable">False</property>
- <property
name="primary_icon_sensitive">True</property>
- <property
name="secondary_icon_sensitive">True</property>
- <property name="adjustment">10 0 300 1 10
0</property>
- <property name="climb_rate">1</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <property
name="update_policy">if-valid</property>
- <signal name="value_changed"
handler="on_spin_encoder_extra_weight_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="expand">False</property>
@@ -18255,7 +18235,7 @@ Concentric</property>
<widget class="GtkHBox"
id="hbox_encoder_capture_extra_mass_raspberry">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">8</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkButton"
id="button_encoder_raspberry_extra_weight_minus_10">
<property name="label">-10</property>
@@ -18298,22 +18278,22 @@ Concentric</property>
<property name="can_focus">False</property>
<property name="spacing">4</property>
<child>
- <widget class="GtkEntry"
id="entry_raspberry_extra_weight">
+ <widget class="GtkSpinButton"
id="spin_encoder_extra_weight">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="max_length">3</property>
- <property name="has_frame">False</property>
<property name="invisible_char">●</property>
- <property name="width_chars">3</property>
- <property name="text">10</property>
- <property name="xalign">1</property>
- <property name="shadow_type">none</property>
<property
name="invisible_char_set">True</property>
<property
name="primary_icon_activatable">False</property>
<property
name="secondary_icon_activatable">False</property>
<property
name="primary_icon_sensitive">True</property>
<property
name="secondary_icon_sensitive">True</property>
- <signal name="changed"
handler="on_entry_raspberry_extra_weight_changed" swapped="no"/>
+ <property name="adjustment">70 0 300 0.01 10
0</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">2</property>
+ <property name="snap_to_ticks">True</property>
+ <property name="numeric">True</property>
+ <property
name="update_policy">if-valid</property>
+ <signal name="value_changed"
handler="on_spin_encoder_extra_weight_value_changed" swapped="no"/>
</widget>
<packing>
<property name="expand">True</property>
@@ -23033,6 +23013,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 c9845ca..ec6cc1b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -658,9 +658,9 @@ public partial class ChronoJumpWindow
if(encGI == Constants.EncoderGI.GRAVITATORY)
{
//TODO: do a regression to find maxPower with a value of extraWeight unused
- int extraWeight = Convert.ToInt32(spin_encoder_extra_weight.Value);
+ double extraWeight = Convert.ToDouble(spin_encoder_extra_weight.Value);
foreach(EncoderSQL es in arrayTemp)
- if(Convert.ToInt32(es.extraWeight) == extraWeight &&
Convert.ToDouble(es.future1) > maxPower)
+ if(Convert.ToDouble(es.extraWeight) == extraWeight &&
Convert.ToDouble(es.future1) > maxPower)
maxPower = Convert.ToDouble(es.future1);
}
else if(encGI == Constants.EncoderGI.INERTIAL)
@@ -794,7 +794,7 @@ public partial class ChronoJumpWindow
//4 mass / weights
string mass = SqlitePreferences.Select(SqlitePreferences.EncoderMassGravitatory, true);
- entry_raspberry_extra_weight.Text = mass;
+ spin_encoder_extra_weight.Value = Convert.ToDouble(Util.ChangeDecimalSeparator(mass));
string weights = SqlitePreferences.Select(SqlitePreferences.EncoderWeightsInertial, true);
entry_encoder_im_weights_n.Text = weights;
@@ -974,29 +974,29 @@ public partial class ChronoJumpWindow
}
void on_button_encoder_raspberry_extra_weight_minus_10_clicked (object o, EventArgs args) {
- rapsberryChangeExtraWeight(-10);
+ encoderCaptureChangeExtraWeight(-10);
}
void on_button_encoder_raspberry_extra_weight_minus_1_clicked (object o, EventArgs args) {
- rapsberryChangeExtraWeight(-1);
+ encoderCaptureChangeExtraWeight(-1);
}
void on_button_encoder_raspberry_extra_weight_plus_10_clicked (object o, EventArgs args) {
- rapsberryChangeExtraWeight(+10);
+ encoderCaptureChangeExtraWeight(+10);
}
void on_button_encoder_raspberry_extra_weight_plus_1_clicked (object o, EventArgs args) {
- rapsberryChangeExtraWeight(+1);
+ encoderCaptureChangeExtraWeight(+1);
}
- void rapsberryChangeExtraWeight(int change) {
- /*
- * don't change spin to avoid circular problems
- * spin_encoder_extra_weight.Value += change;
- * change the entry
- * */
- int newValue = Convert.ToInt32(entry_raspberry_extra_weight.Text) + change;
+ void encoderCaptureChangeExtraWeight(int change)
+ {
+ double newValue = spin_encoder_extra_weight.Value + change;
double min, max;
spin_encoder_extra_weight.GetRange(out min, out max);
- if(newValue >= Convert.ToDouble(min) && newValue <= Convert.ToDouble(max))
- entry_raspberry_extra_weight.Text = newValue.ToString();
+ if(newValue < min)
+ spin_encoder_extra_weight.Value = min;
+ else if(newValue > max)
+ spin_encoder_extra_weight.Value = max;
+ else
+ spin_encoder_extra_weight.Value = newValue;
}
void on_spin_encoder_extra_weight_value_changed (object o, EventArgs args)
@@ -1006,42 +1006,14 @@ public partial class ChronoJumpWindow
//because then we will be calling SQL at each spinbutton increment
encoder_change_displaced_weight_and_1RM ();
- }
- void on_entry_raspberry_extra_weight_changed (object o, EventArgs args)
- {
- if(entry_raspberry_extra_weight.Text == "" || entry_raspberry_extra_weight.Text == "00")
- {
- //if introduced data is empty: leave empty
- entry_raspberry_extra_weight.Text = "0";
- }
- else if(! Util.IsNumber(entry_raspberry_extra_weight.Text, false)) //cannot be decimal
- {
- //if introduced data is not number: put old data
- entry_raspberry_extra_weight.Text = spin_encoder_extra_weight.Value.ToString();
- }
- else {
- //everything is ok: put new data
- //but if weight is out of range, use min or max
- int weight = Convert.ToInt32(entry_raspberry_extra_weight.Text);
- double min = 0;
- double max = 0;
- spin_encoder_extra_weight.GetRange(out min, out max);
- if(weight < min)
- entry_raspberry_extra_weight.Text = min.ToString();
- else if(weight > max)
- entry_raspberry_extra_weight.Text = max.ToString();
- else
- spin_encoder_extra_weight.Value = weight;
- }
- //update top label
- label_encoder_top_extra_mass.Text = entry_raspberry_extra_weight.Text + " Kg";
+ label_encoder_top_extra_mass.Text = Util.TrimDecimals(spin_encoder_extra_weight.Value, 2) + "
Kg";
}
void encoder_change_displaced_weight_and_1RM ()
{
//displaced weight
- label_encoder_displaced_weight.Text = (findMass(Constants.MassType.DISPLACED)).ToString();
+ label_encoder_displaced_weight.Text =
Util.TrimDecimals(findMass(Constants.MassType.DISPLACED),2);
double load1RM = 0;
if(array1RM.Count > 0)
@@ -1665,7 +1637,7 @@ public partial class ChronoJumpWindow
else //if(eSQL.laterality == Catalog.GetString("L"))
radio_encoder_laterality_l.Active = true;
- entry_raspberry_extra_weight.Text =
Convert.ToInt32(eSQL.extraWeight).ToString();
+ spin_encoder_extra_weight.Value =
Convert.ToDouble(Util.ChangeDecimalSeparator(eSQL.extraWeight));
preferences.EncoderChangeMinHeight(eSQL.encoderConfiguration.has_inertia,
eSQL.minHeight);
//TODO: show info to user in a dialog,
@@ -3613,7 +3585,7 @@ public partial class ChronoJumpWindow
setEcconPixbuf();
setLateralityPixbuf();
- label_encoder_top_extra_mass.Text = entry_raspberry_extra_weight.Text + " Kg";
+ label_encoder_top_extra_mass.Text = spin_encoder_extra_weight.Value + " Kg";
if(label_encoder_1RM_percent.Text == "")
label_encoder_top_1RM_percent.Text = "";
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index dfcea43..8240615 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -44,7 +44,6 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Label label_rfid_encoder;
//better raspberry controls
- [Widget] Gtk.Entry entry_raspberry_extra_weight;
[Widget] Gtk.Box hbox_encoder_capture_extra_mass_no_raspberry;
[Widget] Gtk.Box hbox_encoder_capture_extra_mass_raspberry;
[Widget] Gtk.HBox hbox_encoder_im_weights_n;
@@ -767,7 +766,7 @@ public partial class ChronoJumpWindow
Pixbuf pixbuf;
if(task.Load > 0)
- entry_raspberry_extra_weight.Text = Convert.ToInt32(task.Load).ToString();
+ spin_encoder_extra_weight.Value = Convert.ToDouble(task.Load);
if(task.Speed > 0) {
repetitiveConditionsWin.EncoderMeanSpeedHigherValue = task.Speed;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]