[chronojump] encoder: secondaryVariable can be on/off at repetitiveConditionsWin
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoder: secondaryVariable can be on/off at repetitiveConditionsWin
- Date: Wed, 31 Jul 2019 15:45:54 +0000 (UTC)
commit 987bd067a6fd602f7d9e8a9500cec88106e682f8
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jul 31 17:43:35 2019 +0200
encoder: secondaryVariable can be on/off at repetitiveConditionsWin
glade/repetitive_conditions.glade | 13 ++++++-----
src/gui/encoder.cs | 14 ++++++++----
src/gui/encoderGraphObjects.cs | 46 +++++++++++++++++++++++----------------
src/gui/repetitiveConditions.cs | 25 ++++++++++++++++++---
4 files changed, 67 insertions(+), 31 deletions(-)
---
diff --git a/glade/repetitive_conditions.glade b/glade/repetitive_conditions.glade
index b5f6056f..ca2b6c40 100644
--- a/glade/repetitive_conditions.glade
+++ b/glade/repetitive_conditions.glade
@@ -2138,10 +2138,13 @@
<property name="can_focus">False</property>
<property name="spacing">30</property>
<child>
- <widget class="GtkLabel" id="label41">
+ <widget class="GtkCheckButton" id="check_encoder_show_secondary_variable">
+ <property name="label" translatable="yes">Show secondary variable</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Secondary variable</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled"
handler="on_check_encoder_show_secondary_variable_toggled" swapped="no"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -2158,8 +2161,8 @@
</child>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 3d9458d0..9f71be32 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -617,13 +617,13 @@ public partial class ChronoJumpWindow
if(current_menuitem_mode == Constants.Menuitem_modes.POWERGRAVITATORY)
repetitiveConditionsWin.View(Constants.BellModes.ENCODERGRAVITATORY,
preferences.volumeOn, preferences.gstreamer,
- preferences.encoderCaptureMainVariable,
preferences.encoderCaptureSecondaryVariable,
- encoderRhythm);
+ preferences.encoderCaptureMainVariable,
+ preferences.encoderCaptureSecondaryVariable,
preferences.encoderCaptureSecondaryVariableShow, encoderRhythm);
else
repetitiveConditionsWin.View(Constants.BellModes.ENCODERINERTIAL,
preferences.volumeOn, preferences.gstreamer,
- preferences.encoderCaptureMainVariable,
preferences.encoderCaptureSecondaryVariable,
- encoderRhythm);
+ preferences.encoderCaptureMainVariable,
+ preferences.encoderCaptureSecondaryVariable,
preferences.encoderCaptureSecondaryVariableShow, encoderRhythm);
}
/*
@@ -5129,6 +5129,8 @@ public partial class ChronoJumpWindow
{
string mainVariable =
Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable);
string secondaryVariable =
Constants.GetEncoderVariablesCapture(preferences.encoderCaptureSecondaryVariable);
+ if(! preferences.encoderCaptureSecondaryVariableShow)
+ secondaryVariable = "";
double mainVariableHigher =
repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
double mainVariableLower = repetitiveConditionsWin.GetMainVariableLower(mainVariable);
encoderGraphDoPlot.Start(
@@ -5899,6 +5901,8 @@ public partial class ChronoJumpWindow
double mainVariableHigher =
repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
double mainVariableLower =
repetitiveConditionsWin.GetMainVariableLower(mainVariable);
string secondaryVariable =
Constants.GetEncoderVariablesCapture(preferences.encoderCaptureSecondaryVariable);
+ if(! preferences.encoderCaptureSecondaryVariableShow)
+ secondaryVariable = "";
//TODO:
//captureCurvesBarsData.Add(new EncoderBarsData(meanSpeed, maxSpeed,
meanPower, peakPower));
//captureCurvesBarsData.Add(new EncoderBarsData(20, 39, 10, 40));
@@ -6392,6 +6396,8 @@ public partial class ChronoJumpWindow
double mainVariableHigher =
repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
double mainVariableLower =
repetitiveConditionsWin.GetMainVariableLower(mainVariable);
string secondaryVariable =
Constants.GetEncoderVariablesCapture(preferences.encoderCaptureSecondaryVariable);
+ if(! preferences.encoderCaptureSecondaryVariableShow)
+ secondaryVariable = "";
if(action == encoderActions.CURVES_AC && radio_encoder_capture_cont.Active &&
! captureContWithCurves)
{
diff --git a/src/gui/encoderGraphObjects.cs b/src/gui/encoderGraphObjects.cs
index db6e739b..cf9574ee 100644
--- a/src/gui/encoderGraphObjects.cs
+++ b/src/gui/encoderGraphObjects.cs
@@ -160,11 +160,11 @@ public class EncoderGraphDoPlot
graphWidth = drawingarea.Allocation.Width;
graphHeight = drawingarea.Allocation.Height;
- fillDataVaribles();
+ fillDataVariables();
plot();
}
- private void fillDataVaribles()
+ private void fillDataVariables()
{
data = new ArrayList (data7Variables.Count); //data is related to mainVariable (barplot)
dataSecondary = new ArrayList (data7Variables.Count); //dataSecondary is related to secondary
variable (by default range)
@@ -179,14 +179,16 @@ public class EncoderGraphDoPlot
if(showNRepetitions == -1 || ! capturing)
{
data.Add(ebd.GetValue(mainVariable));
- dataSecondary.Add(ebd.GetValue(secondaryVariable));
+ if(secondaryVariable != "")
+ dataSecondary.Add(ebd.GetValue(secondaryVariable));
}
else {
if(eccon == "c" && ( data7Variables.Count <= showNRepetitions ||
//total repetitions are less than show repetitions threshold ||
count >= data7Variables.Count - showNRepetitions ) )
//count is from the last group of reps (reps that have to be shown)
{
data.Add(ebd.GetValue(mainVariable));
- dataSecondary.Add(ebd.GetValue(secondaryVariable));
+ if(secondaryVariable != "")
+ dataSecondary.Add(ebd.GetValue(secondaryVariable));
}
else if(eccon != "c" && (
data7Variables.Count <= 2 * showNRepetitions ||
@@ -196,13 +198,15 @@ public class EncoderGraphDoPlot
{
LogB.Information("added ecc");
data.Add(ebd.GetValue(mainVariable));
- dataSecondary.Add(ebd.GetValue(secondaryVariable));
+ if(secondaryVariable != "")
+ dataSecondary.Add(ebd.GetValue(secondaryVariable));
lastIsEcc = true;
} else { //it is "par"
if(lastIsEcc)
{
data.Add(ebd.GetValue(mainVariable));
- dataSecondary.Add(ebd.GetValue(secondaryVariable));
+ if(secondaryVariable != "")
+
dataSecondary.Add(ebd.GetValue(secondaryVariable));
LogB.Information("added con");
lastIsEcc = false;
}
@@ -585,21 +589,25 @@ public class EncoderGraphDoPlot
pixmap.DrawRectangle(pen_black_encoder_capture, false, rect);
//paint secondary variable circle and lines
- double dSecondary = Convert.ToDouble(dataSecondary[count]);
- int dSecondaryHeight = Convert.ToInt32(graphHeightSafe * dSecondary /
maxAbsoluteSecondary * 1.0);
- int dSecondaryTop = dBottom - dSecondaryHeight;
- Gdk.Point dSecondaryCurrentPoint = new Gdk.Point(Convert.ToInt32(dLeft + (dWidth
/2)), dSecondaryTop);
- //LogB.Information(string.Format("dSecondaryHeight: {0}; dSecondaryTop: {1}",
dSecondaryHeight, dSecondaryTop));
-
- pixmap.DrawArc(pen_yellow_encoder_capture, true,
- dSecondaryCurrentPoint.X -6, dSecondaryCurrentPoint.Y -6,
- 12, 12, 90 * 64, 360 * 64);
-
- if(dSecondaryPreviousPoint.X != 0 && dSecondaryPreviousPoint.Y != 0)
- pixmap.DrawLine(pen_yellow_encoder_capture,
+ //but do not do it if user do not want to show it from repetitiveConditionsWindow
+ if(dataSecondary.Count > 0)
+ {
+ double dSecondary = Convert.ToDouble(dataSecondary[count]);
+ int dSecondaryHeight = Util.DivideSafeAndGetInt(graphHeightSafe * dSecondary,
maxAbsoluteSecondary * 1.0);
+ int dSecondaryTop = dBottom - dSecondaryHeight;
+ Gdk.Point dSecondaryCurrentPoint = new Gdk.Point(Convert.ToInt32(dLeft +
(dWidth /2)), dSecondaryTop);
+ //LogB.Information(string.Format("dSecondaryHeight: {0}; dSecondaryTop: {1}",
dSecondaryHeight, dSecondaryTop));
+
+ pixmap.DrawArc(pen_yellow_encoder_capture, true,
+ dSecondaryCurrentPoint.X -6, dSecondaryCurrentPoint.Y -6,
+ 12, 12, 90 * 64, 360 * 64);
+
+ if(dSecondaryPreviousPoint.X != 0 && dSecondaryPreviousPoint.Y != 0)
+ pixmap.DrawLine(pen_yellow_encoder_capture,
dSecondaryPreviousPoint.X, dSecondaryPreviousPoint.Y,
dSecondaryCurrentPoint.X, dSecondaryCurrentPoint.Y);
- dSecondaryPreviousPoint = dSecondaryCurrentPoint;
+ dSecondaryPreviousPoint = dSecondaryCurrentPoint;
+ }
//write the result
diff --git a/src/gui/repetitiveConditions.cs b/src/gui/repetitiveConditions.cs
index 6cc37c95..e79009e2 100644
--- a/src/gui/repetitiveConditions.cs
+++ b/src/gui/repetitiveConditions.cs
@@ -82,6 +82,7 @@ public class RepetitiveConditionsWindow
[Widget] Gtk.CheckButton checkbutton_encoder_automatic_lower;
[Widget] Gtk.SpinButton spinbutton_encoder_automatic_greater;
[Widget] Gtk.SpinButton spinbutton_encoder_automatic_lower;
+ [Widget] Gtk.CheckButton check_encoder_show_secondary_variable;
[Widget] Gtk.HBox hbox_combo_encoder_secondary_variable;
[Widget] Gtk.ComboBox combo_encoder_secondary_variable;
@@ -238,14 +239,16 @@ public class RepetitiveConditionsWindow
}
public void View (Constants.BellModes bellMode, bool volumeOn, Preferences.GstreamerTypes gstreamer,
- Constants.EncoderVariablesCapture encoderMainVariable,
Constants.EncoderVariablesCapture encoderSecondaryVariable,
+ Constants.EncoderVariablesCapture encoderMainVariable,
+ Constants.EncoderVariablesCapture encoderSecondaryVariable,
+ bool encoderSecondaryVariableShow,
EncoderRhythm encoderRhythm)
{
//when user "deleted_event" the window
if (RepetitiveConditionsWindowBox == null) {
RepetitiveConditionsWindowBox = new RepetitiveConditionsWindow ();
}
- RepetitiveConditionsWindowBox.showWidgets(bellMode, encoderMainVariable,
encoderSecondaryVariable, encoderRhythm);
+ RepetitiveConditionsWindowBox.showWidgets(bellMode, encoderMainVariable,
encoderSecondaryVariable, encoderSecondaryVariableShow, encoderRhythm);
RepetitiveConditionsWindowBox.repetitive_conditions.Show ();
RepetitiveConditionsWindowBox.volumeOn = volumeOn;
@@ -255,6 +258,7 @@ public class RepetitiveConditionsWindow
void showWidgets(Constants.BellModes bellMode,
Constants.EncoderVariablesCapture encoderMainVariable,
Constants.EncoderVariablesCapture encoderSecondaryVariable,
+ bool encoderSecondaryVariableShow,
EncoderRhythm encoderRhythm)
{
frame_best_and_worst.Hide();
@@ -295,6 +299,14 @@ public class RepetitiveConditionsWindow
combo_encoder_secondary_variable.Active =
UtilGtk.ComboMakeActive(combo_encoder_secondary_variable,
Constants.GetEncoderVariablesCapture(encoderSecondaryVariable));
+ if(encoderSecondaryVariableShow)
+ check_encoder_show_secondary_variable.Active = true;
+ else
+ check_encoder_show_secondary_variable.Active = false;
+
+ //need to do it "manually" at start
+ hbox_combo_encoder_secondary_variable.Visible =
check_encoder_show_secondary_variable.Active;
+
notebook_main.GetNthPage(RHYTHMPAGE).Show();
encoder_rhythm_set_values(encoderRhythm);
}
@@ -322,7 +334,6 @@ public class RepetitiveConditionsWindow
combo_encoder_secondary_variable.Sensitive = true;
//combo_encoder_secondary_variable.Changed += new EventHandler
(on_combo_encoder_secondary_variable_changed);
}
-
private void comboEncoderVariableFill(Gtk.ComboBox combo)
{
string [] values = { Constants.RangeAbsolute, Constants.MeanSpeed, Constants.MaxSpeed,
Constants.MeanForce, Constants.MaxForce, Constants.MeanPower, Constants.PeakPower };
@@ -341,6 +352,11 @@ public class RepetitiveConditionsWindow
label_main_variable_text.Text = mainVariable;
}
+ private void on_check_encoder_show_secondary_variable_toggled (object o, EventArgs args)
+ {
+ hbox_combo_encoder_secondary_variable.Visible = check_encoder_show_secondary_variable.Active;
+ }
+
private void putNonStandardIcons() {
Pixbuf pixbuf;
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_bell_green.png");
@@ -904,6 +920,9 @@ public class RepetitiveConditionsWindow
public string GetSecondaryVariable {
get { return UtilGtk.ComboGetActive(combo_encoder_secondary_variable); }
}
+ public bool GetSecondaryVariableShow {
+ get { return check_encoder_show_secondary_variable.Active; }
+ }
public double GetMainVariableHigher(string mainVariable)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]