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

Method updateMaximumZoomArea

pj_plotting/widget/src/PlotWidgetBase.cpp:641–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641void PlotWidgetBase::updateMaximumZoomArea() {
642 QRectF max_rect;
643 const Range<double> range_x = getVisualizationRangeX();
644 max_rect.setLeft(range_x.min);
645 max_rect.setRight(range_x.max);
646
647 const Range<double> range_y = getVisualizationRangeY(range_x);
648 max_rect.setBottom(range_y.min);
649 max_rect.setTop(range_y.max);
650
651 if (isXYPlot() && keep_aspect_ratio_) {
652 const QRectF canvas_rect = plot_->canvas()->contentsRect();
653 const double canvas_ratio = std::abs(canvas_rect.width() / canvas_rect.height());
654 const double data_ratio = std::abs(max_rect.width() / max_rect.height());
655 if (data_ratio < canvas_ratio) {
656 const double new_width = std::abs(max_rect.height() * canvas_ratio);
657 const double increment = new_width - max_rect.width();
658 max_rect.setWidth(new_width);
659 max_rect.moveLeft(max_rect.left() - 0.5 * increment);
660 } else {
661 const double new_height = -(max_rect.width() / canvas_ratio);
662 const double increment = std::abs(new_height - max_rect.height());
663 max_rect.setHeight(new_height);
664 max_rect.moveTop(max_rect.top() + 0.5 * increment);
665 }
666 }
667
668 magnifier()->setAxisLimits(QwtPlot::xBottom, max_rect.left(), max_rect.right());
669 magnifier()->setAxisLimits(QwtPlot::yLeft, max_rect.bottom(), max_rect.top());
670 zoomer()->keepAspectRatio(isXYPlot() && keep_aspect_ratio_);
671 max_zoom_rect_ = max_rect;
672}
673
674bool PlotWidgetBase::eventFilter(QObject* obj, QEvent* event) {
675 if (event->type() == QEvent::Destroy) {

Callers

nothing calls this directly

Calls 7

heightMethod · 0.80
setHeightMethod · 0.80
setAxisLimitsMethod · 0.80
keepAspectRatioMethod · 0.80
canvasMethod · 0.45
widthMethod · 0.45
setWidthMethod · 0.45

Tested by

no test coverage detected