Skip to content

Commit

Permalink
#879 Inverted option for STEPS style (#880)
Browse files Browse the repository at this point in the history
* #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 <davide.faconti@gmail.com>

---------

Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
  • Loading branch information
zdavkeos and facontidavide authored Jan 9, 2024
1 parent c6b3af1 commit 7450c6a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
8 changes: 8 additions & 0 deletions plotjuggler_app/plotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 12 additions & 0 deletions plotjuggler_app/plotwidget_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions plotjuggler_app/plotwidget_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ private slots:

void on_radioSteps_toggled(bool checked);

void on_radioStepsInv_toggled(bool checked);

private:
Ui::PlotWidgetEditor* ui;

Expand Down
9 changes: 8 additions & 1 deletion plotjuggler_app/plotwidget_editor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@
<item>
<widget class="QRadioButton" name="radioSteps">
<property name="text">
<string>Steps</string>
<string>Steps (pre)</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioStepsInv">
<property name="text">
<string>Step (post)</string>
</property>
</widget>
</item>
Expand Down
3 changes: 2 additions & 1 deletion plotjuggler_base/include/PlotJuggler/plotwidget_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class PlotWidgetBase : public QWidget
DOTS,
LINES_AND_DOTS,
STICKS,
STEPS
STEPS,
STEPSINV
};

struct CurveInfo
Expand Down
5 changes: 5 additions & 0 deletions plotjuggler_base/src/plotwidget_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 7450c6a

Please sign in to comment.