| 453 | } |
| 454 | |
| 455 | void PlotWidgetBase::setKeepRatioXY(bool active) { |
| 456 | keep_aspect_ratio_ = active; |
| 457 | plot_->zoomer->keepAspectRatio(isXYPlot() && active); |
| 458 | if (!isXYPlot()) { |
| 459 | return; |
| 460 | } |
| 461 | // Reshape current view; otherwise the toggle only takes effect on the next |
| 462 | // drag-zoom. OFF re-fits to data bounds (loses zoom by design). |
| 463 | if (active) { |
| 464 | applyRectKeepingRatio(currentBoundingRect()); |
| 465 | replot(); |
| 466 | } else { |
| 467 | // resetZoom() refreshes max bounds first: data may have changed since the |
| 468 | // last reset, so the cached max_zoom_rect_ could be stale. |
| 469 | resetZoom(); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | void PlotWidgetBase::applyRectKeepingRatio(QRectF rect) { |
| 474 | if (isXYPlot() && keep_aspect_ratio_) { |
no test coverage detected