From f253eebfea4507a5b9b54f87dc2165beef0e5bce Mon Sep 17 00:00:00 2001 From: Zach Davis Date: Wed, 20 Sep 2023 14:46:28 -0500 Subject: [PATCH] Add "Steps" when drawing curves --- plotjuggler_app/plotwidget.cpp | 8 ++++++++ plotjuggler_app/plotwidget_editor.cpp | 12 ++++++++++++ plotjuggler_app/plotwidget_editor.h | 2 ++ plotjuggler_app/plotwidget_editor.ui | 7 +++++++ .../include/PlotJuggler/plotwidget_base.h | 3 ++- plotjuggler_base/src/plotwidget_base.cpp | 4 ++++ 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/plotjuggler_app/plotwidget.cpp b/plotjuggler_app/plotwidget.cpp index 856f29919..7a9311d4b 100644 --- a/plotjuggler_app/plotwidget.cpp +++ b/plotjuggler_app/plotwidget.cpp @@ -670,6 +670,10 @@ QDomElement PlotWidget::xmlSaveState(QDomDocument& doc) const { plot_el.setAttribute("style", "Sticks"); } + else if (curveStyle() == PlotWidgetBase::STEPS) + { + plot_el.setAttribute("style", "Steps"); + } for (auto& it : curveList()) { @@ -869,6 +873,10 @@ bool PlotWidget::xmlLoadState(QDomElement& plot_widget, bool autozoom) { changeCurvesStyle(PlotWidgetBase::STICKS); } + else if (style == "Steps") + { + changeCurvesStyle(PlotWidgetBase::STEPS); + } } QString bg_data = plot_widget.attribute("background_data"); diff --git a/plotjuggler_app/plotwidget_editor.cpp b/plotjuggler_app/plotwidget_editor.cpp index 0f4c262b7..f0971c35e 100644 --- a/plotjuggler_app/plotwidget_editor.cpp +++ b/plotjuggler_app/plotwidget_editor.cpp @@ -64,6 +64,10 @@ PlotwidgetEditor::PlotwidgetEditor(PlotWidget* plotwidget, QWidget* parent) { ui->radioSticks->setChecked(true); } + else if (_plotwidget->curveStyle() == PlotWidgetBase::STEPS) + { + ui->radioSteps->setChecked(true); + } else { ui->radioBoth->setChecked(true); @@ -308,6 +312,14 @@ void PlotwidgetEditor::on_radioSticks_toggled(bool checked) } } +void PlotwidgetEditor::on_radioSteps_toggled(bool checked) +{ + if (checked) + { + _plotwidget->changeCurvesStyle(PlotWidgetBase::STEPS); + } +} + 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 7f8ed6d90..a28104824 100644 --- a/plotjuggler_app/plotwidget_editor.h +++ b/plotjuggler_app/plotwidget_editor.h @@ -84,6 +84,8 @@ private slots: void on_radioSticks_toggled(bool checked); + void on_radioSteps_toggled(bool checked); + private: Ui::PlotWidgetEditor* ui; diff --git a/plotjuggler_app/plotwidget_editor.ui b/plotjuggler_app/plotwidget_editor.ui index 4d1959058..ad7860f30 100644 --- a/plotjuggler_app/plotwidget_editor.ui +++ b/plotjuggler_app/plotwidget_editor.ui @@ -341,6 +341,13 @@ + + + + Steps + + + diff --git a/plotjuggler_base/include/PlotJuggler/plotwidget_base.h b/plotjuggler_base/include/PlotJuggler/plotwidget_base.h index aef45f34c..4865ff17f 100644 --- a/plotjuggler_base/include/PlotJuggler/plotwidget_base.h +++ b/plotjuggler_base/include/PlotJuggler/plotwidget_base.h @@ -32,7 +32,8 @@ class PlotWidgetBase : public QWidget LINES, DOTS, LINES_AND_DOTS, - STICKS + STICKS, + STEPS }; struct CurveInfo diff --git a/plotjuggler_base/src/plotwidget_base.cpp b/plotjuggler_base/src/plotwidget_base.cpp index c22563bef..b5ed59dfb 100644 --- a/plotjuggler_base/src/plotwidget_base.cpp +++ b/plotjuggler_base/src/plotwidget_base.cpp @@ -720,6 +720,10 @@ void PlotWidgetBase::setStyle(QwtPlotCurve* curve, CurveStyle style) break; case STICKS: curve->setStyle(QwtPlotCurve::Sticks); + break; + case STEPS: + curve->setStyle(QwtPlotCurve::Steps); + break; } }