MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / getVisualizationRangeY

Method getVisualizationRangeY

pj_plotting/widget/src/PlotWidgetBase.cpp:344–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344Range<double> PlotWidgetBase::getVisualizationRangeY(Range<double> range_x) const {
345 double bottom = std::numeric_limits<double>::max();
346 double top = std::numeric_limits<double>::lowest();
347
348 for (const auto& info : curveList()) {
349 if (info.curve == nullptr || !info.curve->isVisible() || info.curve->data() == nullptr) {
350 continue;
351 }
352
353 if (const auto* adapter = dynamic_cast<const DatastoreCurveAdapter*>(info.curve->data())) {
354 const auto y_range = adapter->visibleYRange(range_x);
355 if (y_range.has_value()) {
356 bottom = std::min(bottom, y_range->min);
357 top = std::max(top, y_range->max);
358 }
359 continue;
360 }
361
362 const QRectF rect = info.curve->data()->boundingRect();
363 if (!isUsableRect(rect)) {
364 continue;
365 }
366 bottom = std::min(bottom, rect.top());
367 top = std::max(top, rect.bottom());
368 }
369
370 if (bottom > top) {
371 bottom = -1.0;
372 top = 1.0;
373 }
374
375 const double margin = (top - bottom) * 0.025;
376 return Range<double>{.min = bottom - margin, .max = top + margin};
377}
378
379void PlotWidgetBase::setModeXY(bool enable) {
380 // XY (scatter) plots use the plot-level curve style like any other plot — the

Callers

nothing calls this directly

Calls 5

isUsableRectFunction · 0.85
isVisibleMethod · 0.45
dataMethod · 0.45
visibleYRangeMethod · 0.45
boundingRectMethod · 0.45

Tested by

no test coverage detected