[chronojump] EncoderInertial EccOverload repCondWin, graph (also with text)



commit 0f2de1fa3f9ea24fe28cba2aeeb3823b20f1f755
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Feb 22 18:24:59 2020 +0100

    EncoderInertial EccOverload repCondWin, graph (also with text)

 glade/repetitive_conditions.glade | 44 +++++++++++++++++++++++++++++++++++++--
 src/gui/app1/chronojump.cs        |  6 ++++++
 src/gui/encoderGraphObjects.cs    | 29 ++++++++++++++++++++++++--
 src/gui/repetitiveConditions.cs   | 36 ++++++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+), 4 deletions(-)
---
diff --git a/glade/repetitive_conditions.glade b/glade/repetitive_conditions.glade
index 0a02053a..00ed291b 100644
--- a/glade/repetitive_conditions.glade
+++ b/glade/repetitive_conditions.glade
@@ -2136,7 +2136,7 @@
                       <widget class="GtkHBox" id="hbox48">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="spacing">30</property>
+                        <property name="spacing">20</property>
                         <child>
                           <widget class="GtkCheckButton" id="check_encoder_show_secondary_variable">
                             <property name="label" translatable="yes">Show secondary variable</property>
@@ -2173,6 +2173,46 @@
                         <property name="position">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <widget class="GtkHBox" id="hbox16">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">20</property>
+                        <child>
+                          <widget class="GtkCheckButton" id="check_encoder_inertial_ecc_overload">
+                            <property name="label" translatable="yes">Show eccentric overload on 
inertial</property>
+                            <property name="visible">True</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_inertial_ecc_overload_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="GtkCheckButton" id="check_encoder_inertial_ecc_overload_percent">
+                            <property name="label" translatable="yes">Show also percentage</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="draw_indicator">True</property>
+                          </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>
                     <child>
                       <widget class="GtkVBox" id="vbox_encoder_manual">
                         <property name="visible">True</property>
@@ -3633,7 +3673,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">3</property>
+                        <property name="position">4</property>
                       </packing>
                     </child>
                   </widget>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 336855ae..8ac92d6e 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -6994,6 +6994,12 @@ LogB.Debug("mc finished 5");
                        if(! secondaryVariableShow)
                                secondaryVariableStr = "";
 
+                       if(preferences.encoderCaptureInertialEccOverloadMode != 
repetitiveConditionsWin.GetEncoderCaptureEccOverloadMode) {
+                               
SqlitePreferences.Update(SqlitePreferences.EncoderCaptureInertialEccOverloadMode,
+                                               
repetitiveConditionsWin.GetEncoderCaptureEccOverloadMode.ToString(), true);
+                               preferences.encoderCaptureInertialEccOverloadMode = 
repetitiveConditionsWin.GetEncoderCaptureEccOverloadMode;
+                       }
+
                        preferences.encoderCaptureMainVariableThisSetOrHistorical = 
Preferences.PreferencesChange(
                                SqlitePreferences.EncoderCaptureMainVariableThisSetOrHistorical,
                                preferences.encoderCaptureMainVariableThisSetOrHistorical,
diff --git a/src/gui/encoderGraphObjects.cs b/src/gui/encoderGraphObjects.cs
index dfbef6c1..a650a883 100644
--- a/src/gui/encoderGraphObjects.cs
+++ b/src/gui/encoderGraphObjects.cs
@@ -644,20 +644,45 @@ public class EncoderGraphDoPlot
                        pixmap.DrawRectangle(pen_black_encoder_capture, false, rect);
 
                        //draw green arrow eccentric overload on inertial only if ecc > con
-                       if (hasInertia && (eccon == "ec" || eccon == "ecS"))
+                       if (hasInertia && preferences.encoderCaptureInertialEccOverloadMode !=
+                                       Preferences.encoderCaptureEccOverloadModes.NOT_SHOW &&
+                                       (eccon == "ec" || eccon == "ecS"))
                        {
                                bool isEven = Util.IsEven(count +1);
                                if(isEven) {
                                        concentricPreValue = dTop;
                                        concentricPreLeft = dLeft;
                                }
-                               else if(concentricPreLeft >= 0 && dTop < concentricPreValue) { //TODO: better 
use count //note dTop < because is related to pixels
+                               else if(concentricPreLeft >= 0 && dTop < concentricPreValue) { //note dTop < 
because is related to pixels
                                        pixmap.DrawLine(pen_green_bold_encoder_capture,
                                                        concentricPreLeft + dWidth/2, concentricPreValue, 
dLeft + dWidth/2, dTop);
                                        UtilGtk.DrawArrow(pixmap, pen_green_bold_encoder_capture,
                                                        dLeft + dWidth/2, concentricPreLeft + dWidth/2, 
//tipX, tailX
                                                        dTop, concentricPreValue,                       
//tipY, tailY
                                                        14);
+
+                                       if (preferences.encoderCaptureInertialEccOverloadMode ==
+                                                       
Preferences.encoderCaptureEccOverloadModes.SHOW_LINE_AND_PERCENT)
+                                       {
+                                               layout_encoder_capture_curves_bars.SetMarkup(
+                                                               Convert.ToInt32(100.0 * (dTop - dBottom) / 
(concentricPreValue - dBottom)) + "%");
+                                               textWidth = 1; textHeight = 1;
+                                               layout_encoder_capture_curves_bars.GetPixelSize(out 
textWidth, out textHeight);
+
+                                               /*
+                                               //at center-left of the line, difficult to see with other 
labels:
+                                               pixmap.DrawLayout (pen_green_bold_encoder_capture,
+                                                               (concentricPreLeft + dWidth/2 + dLeft + 
dWidth/2)/2 - textWidth, // x
+                                                               (concentricPreValue + dTop)/2 - textHeight,   
                  // y
+                                                               layout_encoder_capture_curves_bars);
+                                               */
+
+                                               //at top of the graph (lot more clear)
+                                               pixmap.DrawLayout (pen_green_bold_encoder_capture,
+                                                               (concentricPreLeft + dWidth/2 + dLeft + 
dWidth/2)/2 - textWidth/2, // x
+                                                               top_margin /2,                                
                  // y
+                                                               layout_encoder_capture_curves_bars);
+                                       }
                                }
                        }
 
diff --git a/src/gui/repetitiveConditions.cs b/src/gui/repetitiveConditions.cs
index 5c8b6e87..4d978f0e 100644
--- a/src/gui/repetitiveConditions.cs
+++ b/src/gui/repetitiveConditions.cs
@@ -85,6 +85,8 @@ public class RepetitiveConditionsWindow
        [Widget] Gtk.CheckButton check_encoder_show_secondary_variable;
        [Widget] Gtk.HBox hbox_combo_encoder_secondary_variable;
        [Widget] Gtk.ComboBox combo_encoder_secondary_variable;
+       [Widget] Gtk.CheckButton check_encoder_inertial_ecc_overload;
+       [Widget] Gtk.CheckButton check_encoder_inertial_ecc_overload_percent;
 
        [Widget] Gtk.VBox vbox_encoder_manual;
        [Widget] Gtk.CheckButton checkbutton_encoder_show_manual_feedback;
@@ -256,6 +258,7 @@ public class RepetitiveConditionsWindow
                RepetitiveConditionsWindowBox.showWidgets(bellMode,
                                preferences.encoderCaptureMainVariable, 
preferences.encoderCaptureSecondaryVariable,
                                preferences.encoderCaptureSecondaryVariableShow,
+                               preferences.encoderCaptureInertialEccOverloadMode,
                                preferences.encoderCaptureMainVariableThisSetOrHistorical,
                                preferences.encoderCaptureMainVariableGreaterActive,
                                preferences.encoderCaptureMainVariableGreaterValue,
@@ -275,6 +278,7 @@ public class RepetitiveConditionsWindow
                        Constants.EncoderVariablesCapture encoderMainVariable,
                        Constants.EncoderVariablesCapture encoderSecondaryVariable,
                        bool encoderSecondaryVariableShow,
+                       Preferences.encoderCaptureEccOverloadModes encoderCaptureEccOverloadMode,
                        bool encoderCaptureMainVariableThisSetOrHistorical,
                        bool encoderCaptureMainVariableGreaterActive,
                        int encoderCaptureMainVariableGreaterValue,
@@ -328,6 +332,20 @@ public class RepetitiveConditionsWindow
                        combo_encoder_secondary_variable.Active = 
UtilGtk.ComboMakeActive(combo_encoder_secondary_variable,
                                        Constants.GetEncoderVariablesCapture(encoderSecondaryVariable));
 
+                       if(encoderCaptureEccOverloadMode == 
Preferences.encoderCaptureEccOverloadModes.NOT_SHOW) {
+                               check_encoder_inertial_ecc_overload.Active = false;
+                               check_encoder_inertial_ecc_overload_percent.Active = false;
+                               check_encoder_inertial_ecc_overload_percent.Visible = false;
+                       } else if (encoderCaptureEccOverloadMode == 
Preferences.encoderCaptureEccOverloadModes.SHOW_LINE) {
+                               check_encoder_inertial_ecc_overload.Active = true;
+                               check_encoder_inertial_ecc_overload_percent.Active = false;
+                               check_encoder_inertial_ecc_overload_percent.Visible = true;
+                       } else { // (encoderCaptureEccOverloadMode == 
Preferences.encoderCaptureEccOverloadModes.SHOW_LINE_AND_PERCENT)
+                               check_encoder_inertial_ecc_overload.Active = true;
+                               check_encoder_inertial_ecc_overload_percent.Active = true;
+                               check_encoder_inertial_ecc_overload_percent.Visible = true;
+                       }
+
                        if(encoderSecondaryVariableShow)
                                check_encoder_show_secondary_variable.Active = true;
                        else
@@ -423,6 +441,13 @@ public class RepetitiveConditionsWindow
                hbox_combo_encoder_secondary_variable.Visible = check_encoder_show_secondary_variable.Active;
        }
 
+       private void on_check_encoder_inertial_ecc_overload_toggled (object o, EventArgs args)
+       {
+               check_encoder_inertial_ecc_overload_percent.Visible = 
check_encoder_inertial_ecc_overload.Active;
+               if(! check_encoder_inertial_ecc_overload.Active)
+                       check_encoder_inertial_ecc_overload_percent.Active = false;
+       }
+
        private void putNonStandardIcons() {
                Pixbuf pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_bell_green.png");
@@ -1014,6 +1039,17 @@ public class RepetitiveConditionsWindow
                get { return check_encoder_show_secondary_variable.Active; }
        }
 
+       public Preferences.encoderCaptureEccOverloadModes GetEncoderCaptureEccOverloadMode {
+               get {
+                       if(check_encoder_inertial_ecc_overload_percent.Active)
+                               return Preferences.encoderCaptureEccOverloadModes.SHOW_LINE_AND_PERCENT;
+                       else if (check_encoder_inertial_ecc_overload.Active)
+                               return Preferences.encoderCaptureEccOverloadModes.SHOW_LINE;
+                       else
+                               return Preferences.encoderCaptureEccOverloadModes.NOT_SHOW;
+               }
+       }
+
        public double GetMainVariableHigher(string mainVariable) 
        {
                if(mainVariable == Constants.MeanSpeed && EncoderMeanSpeedHigher)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]