Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plotjuggler_app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,10 @@ void MainWindow::onPlotZoomChanged(PlotWidget* modified_plot, QRectF new_range)
plot->on_zoomOutVertical_triggered(false);
plot->replot();
}
if (!modified_plot->isXYPlot() && plot->isXYPlot())
{
plot->setXYTimeFilter(Range({ new_range.left(), new_range.right() }));
}
};
this->forEachWidget(visitor);
}
Expand Down
56 changes: 56 additions & 0 deletions plotjuggler_app/plotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ PlotWidget::PlotWidget(PlotDataMapRef& datamap, QWidget* parent)
, _time_offset(0.0)
, _transform_select_dialog(nullptr)
, _context_menu_enabled(true)
, _xy_time_filtered(false)
, _xy_time_filter(
{ -std::numeric_limits<double>::max(), std::numeric_limits<double>::max() })
{
connect(this, &PlotWidget::curveListChanged, this,
[this]() { this->updateMaximumZoomArea(); });
Expand Down Expand Up @@ -714,6 +717,11 @@ QDomElement PlotWidget::xmlSaveState(QDomDocument& doc) const
}
}

if (isXYPlot())
{
plot_el.setAttribute("xy_time_filtered", isXYTimeFiltered() ? "true" : "false");
}

plot_el.setAttribute("mode", isXYPlot() ? "XYPlot" : "TimeSeries");

plot_el.setAttribute("flip_x", isXYPlot() && _flip_x->isChecked() ? "true" : "false");
Expand Down Expand Up @@ -924,6 +932,11 @@ bool PlotWidget::xmlLoadState(QDomElement& plot_widget, bool autozoom)
}
}

if (isXYPlot())
{
setXYTimeFiltered(plot_widget.attribute("xy_time_filtered") == "true");
}

if (autozoom)
{
updateMaximumZoomArea();
Expand Down Expand Up @@ -1751,3 +1764,46 @@ QwtSeriesWrapper* PlotWidget::createTimeSeries(const PlotData* data,
output->updateCache(true);
return output;
}

bool PlotWidget::isXYTimeFiltered() const
{
return _xy_time_filtered;
}

void PlotWidget::setXYTimeFiltered(bool filtered)
{
_xy_time_filtered = filtered;
updateXYTimeFilter();
}

void PlotWidget::updateXYTimeFilter()
{
for (auto& it : curveList())
{
if (auto pointSeries = dynamic_cast<PointSeriesXY*>(it.curve->data()))
{
pointSeries->setTimeFilter(_xy_time_filtered ?
_xy_time_filter :
Range({ -std::numeric_limits<double>::max(),
std::numeric_limits<double>::max() }));
}
}
updateMaximumZoomArea();
rescaleEqualAxisScaling();
replot();
}

void PlotWidget::setXYTimeFilter(Range filter)
{
if (_xy_time_filter == filter)
{
return;
}
_xy_time_filter = filter;
updateXYTimeFilter();
}

Range PlotWidget::xyTimeFilter() const
{
return _xy_time_filter;
}
11 changes: 11 additions & 0 deletions plotjuggler_app/plotwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class PlotWidget : public PlotWidgetBase

void updateStatistics(bool forceUpdate = false);

bool isXYTimeFiltered() const;

void setXYTimeFiltered(bool filtered);
void setXYTimeFilter(Range filter);
Range xyTimeFilter() const;

protected:
PlotDataMapRef& _mapped_data;

Expand Down Expand Up @@ -227,6 +233,11 @@ private slots:

bool _context_menu_enabled;

bool _xy_time_filtered;
Range _xy_time_filter;

void updateXYTimeFilter();

// void updateMaximumZoomArea();
void rescaleEqualAxisScaling();
void overrideCursonMove();
Expand Down
9 changes: 9 additions & 0 deletions plotjuggler_app/plotwidget_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PlotwidgetEditor::PlotwidgetEditor(PlotWidget* plotwidget, QWidget* parent)
_plotwidget->xmlLoadState(saved_state);
_plotwidget->on_changeTimeOffset(plotwidget->timeOffset());
_plotwidget->setContextMenuEnabled(false);
_plotwidget->setXYTimeFilter(plotwidget->xyTimeFilter());

_bounding_rect_original = _plotwidget_origin->currentBoundingRect();

Expand Down Expand Up @@ -111,6 +112,9 @@ PlotwidgetEditor::PlotwidgetEditor(PlotWidget* plotwidget, QWidget* parent)
{
ui->listWidget->item(0)->setSelected(true);
}

ui->checkBoxXYTimeFiltered->setChecked(plotwidget->isXYTimeFiltered());
ui->checkBoxXYTimeFiltered->setVisible(plotwidget->isXYPlot());
}

PlotwidgetEditor::~PlotwidgetEditor()
Expand Down Expand Up @@ -332,6 +336,11 @@ void PlotwidgetEditor::on_radioStepsInv_toggled(bool checked)
}
}

void PlotwidgetEditor::on_checkBoxXYTimeFiltered_toggled(bool checked)
{
_plotwidget->setXYTimeFiltered(checked);
}

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 @@ -88,6 +88,8 @@ private slots:

void on_radioStepsInv_toggled(bool checked);

void on_checkBoxXYTimeFiltered_toggled(bool checked);

private:
Ui::PlotWidgetEditor* ui;

Expand Down
10 changes: 10 additions & 0 deletions plotjuggler_app/plotwidget_editor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxXYTimeFiltered">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>X/Y time filter</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down
19 changes: 17 additions & 2 deletions plotjuggler_app/point_series_xy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ PointSeriesXY::PointSeriesXY(const PlotData* x_axis, const PlotData* y_axis)
, _x_axis(x_axis)
, _y_axis(y_axis)
, _cached_curve("", x_axis->group())
, _time_filter(
{ -std::numeric_limits<double>::max(), std::numeric_limits<double>::max() })
{
updateCache(true);
}
Expand Down Expand Up @@ -68,12 +70,25 @@ void PointSeriesXY::updateCache(bool reset_old_data)
throw std::runtime_error("X and Y axis don't share the same time axis");
}

const QPointF p(_x_axis->at(i).y, _y_axis->at(i).y);
_cached_curve.pushBack({ p.x(), p.y() });
if (_x_axis->at(i).x >= _time_filter.min && _x_axis->at(i).x <= _time_filter.max)
{
const QPointF p(_x_axis->at(i).y, _y_axis->at(i).y);
_cached_curve.pushBack({ p.x(), p.y() });
}
}
}

RangeOpt PointSeriesXY::getVisualizationRangeX()
{
return _cached_curve.rangeX();
}

void PointSeriesXY::setTimeFilter(Range filter)
{
if (_time_filter == filter)
{
return;
}
_time_filter = filter;
updateCache(true);
}
3 changes: 3 additions & 0 deletions plotjuggler_app/point_series_xy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ class PointSeriesXY : public QwtTimeseries
return &_cached_curve;
}

void setTimeFilter(Range filter);

protected:
const PlotData* _x_axis;
const PlotData* _y_axis;
PlotDataXY _cached_curve;
Range _time_filter;
};

#endif // POINT_SERIES_H
4 changes: 4 additions & 0 deletions plotjuggler_base/include/PlotJuggler/plotdatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ struct Range
{
double min;
double max;
bool operator==(const Range& other) const
{
return min == other.min && max == other.max;
}
};

#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
Expand Down
Loading