Skip to content

Commit

Permalink
Merge pull request #869 from zdavkeos/step_interpolation
Browse files Browse the repository at this point in the history
Add "Steps" when drawing curves
  • Loading branch information
facontidavide authored Sep 22, 2023
2 parents ab86956 + f253eeb commit 2a91af7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
8 changes: 8 additions & 0 deletions plotjuggler_app/plotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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");
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 @@ -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);
Expand Down Expand Up @@ -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);
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 @@ -84,6 +84,8 @@ private slots:

void on_radioSticks_toggled(bool checked);

void on_radioSteps_toggled(bool checked);

private:
Ui::PlotWidgetEditor* ui;

Expand Down
7 changes: 7 additions & 0 deletions plotjuggler_app/plotwidget_editor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSteps">
<property name="text">
<string>Steps</string>
</property>
</widget>
</item>
</layout>
</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 @@ -32,7 +32,8 @@ class PlotWidgetBase : public QWidget
LINES,
DOTS,
LINES_AND_DOTS,
STICKS
STICKS,
STEPS
};

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

Expand Down

0 comments on commit 2a91af7

Please sign in to comment.