From 7450c6ab8a1cc0b5929dd418c78cb8a062db91dc Mon Sep 17 00:00:00 2001 From: Zach Davis Date: Tue, 9 Jan 2024 04:53:48 -0600 Subject: [PATCH] #879 Inverted option for STEPS style (#880) * #879 Inverted option for STEPS style New line style like STEPS but drawn the opposite way * Better steps nomenclature * Fix steps naming Co-authored-by: Davide Faconti --------- Co-authored-by: Davide Faconti --- plotjuggler_app/plotwidget.cpp | 8 ++++++++ plotjuggler_app/plotwidget_editor.cpp | 12 ++++++++++++ plotjuggler_app/plotwidget_editor.h | 2 ++ plotjuggler_app/plotwidget_editor.ui | 9 ++++++++- .../include/PlotJuggler/plotwidget_base.h | 3 ++- plotjuggler_base/src/plotwidget_base.cpp | 5 +++++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/plotjuggler_app/plotwidget.cpp b/plotjuggler_app/plotwidget.cpp index 7a9311d4b..9eea88646 100644 --- a/plotjuggler_app/plotwidget.cpp +++ b/plotjuggler_app/plotwidget.cpp @@ -674,6 +674,10 @@ QDomElement PlotWidget::xmlSaveState(QDomDocument& doc) const { plot_el.setAttribute("style", "Steps"); } + else if (curveStyle() == PlotWidgetBase::STEPSINV) + { + plot_el.setAttribute("style", "StepsInv"); + } for (auto& it : curveList()) { @@ -877,6 +881,10 @@ bool PlotWidget::xmlLoadState(QDomElement& plot_widget, bool autozoom) { changeCurvesStyle(PlotWidgetBase::STEPS); } + else if (style == "StepsInv") + { + changeCurvesStyle(PlotWidgetBase::STEPSINV); + } } QString bg_data = plot_widget.attribute("background_data"); diff --git a/plotjuggler_app/plotwidget_editor.cpp b/plotjuggler_app/plotwidget_editor.cpp index f0971c35e..9358befd9 100644 --- a/plotjuggler_app/plotwidget_editor.cpp +++ b/plotjuggler_app/plotwidget_editor.cpp @@ -68,6 +68,10 @@ PlotwidgetEditor::PlotwidgetEditor(PlotWidget* plotwidget, QWidget* parent) { ui->radioSteps->setChecked(true); } + else if (_plotwidget->curveStyle() == PlotWidgetBase::STEPSINV) + { + ui->radioSteps->setChecked(true); + } else { ui->radioBoth->setChecked(true); @@ -320,6 +324,14 @@ void PlotwidgetEditor::on_radioSteps_toggled(bool checked) } } +void PlotwidgetEditor::on_radioStepsInv_toggled(bool checked) +{ + if (checked) + { + _plotwidget->changeCurvesStyle(PlotWidgetBase::STEPSINV); + } +} + void PlotwidgetEditor::on_checkBoxMax_toggled(bool checked) { ui->lineLimitMax->setEnabled(checked); diff --git a/plotjuggler_app/plotwidget_editor.h b/plotjuggler_app/plotwidget_editor.h index a28104824..6c1ac7cf2 100644 --- a/plotjuggler_app/plotwidget_editor.h +++ b/plotjuggler_app/plotwidget_editor.h @@ -86,6 +86,8 @@ private slots: void on_radioSteps_toggled(bool checked); + void on_radioStepsInv_toggled(bool checked); + private: Ui::PlotWidgetEditor* ui; diff --git a/plotjuggler_app/plotwidget_editor.ui b/plotjuggler_app/plotwidget_editor.ui index ad7860f30..cc49f2c34 100644 --- a/plotjuggler_app/plotwidget_editor.ui +++ b/plotjuggler_app/plotwidget_editor.ui @@ -344,7 +344,14 @@ - Steps + Steps (pre) + + + + + + + Step (post) diff --git a/plotjuggler_base/include/PlotJuggler/plotwidget_base.h b/plotjuggler_base/include/PlotJuggler/plotwidget_base.h index 4865ff17f..8b5b3fd88 100644 --- a/plotjuggler_base/include/PlotJuggler/plotwidget_base.h +++ b/plotjuggler_base/include/PlotJuggler/plotwidget_base.h @@ -33,7 +33,8 @@ class PlotWidgetBase : public QWidget DOTS, LINES_AND_DOTS, STICKS, - STEPS + STEPS, + STEPSINV }; struct CurveInfo diff --git a/plotjuggler_base/src/plotwidget_base.cpp b/plotjuggler_base/src/plotwidget_base.cpp index b5ed59dfb..b5969d8b9 100644 --- a/plotjuggler_base/src/plotwidget_base.cpp +++ b/plotjuggler_base/src/plotwidget_base.cpp @@ -723,6 +723,11 @@ void PlotWidgetBase::setStyle(QwtPlotCurve* curve, CurveStyle style) break; case STEPS: curve->setStyle(QwtPlotCurve::Steps); + curve->setCurveAttribute(QwtPlotCurve::Inverted, false); + break; + case STEPSINV: + curve->setStyle(QwtPlotCurve::Steps); + curve->setCurveAttribute(QwtPlotCurve::Inverted, true); break; } }