From 05f379b9d0e45d10e699da7985bcd177ea8b998b Mon Sep 17 00:00:00 2001 From: CHEMIN Sebastien Date: Fri, 19 Apr 2024 09:18:20 +0200 Subject: [PATCH] Fit All on visible objects --- src/QtViewer/QtViewer_ViewPort.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/QtViewer/QtViewer_ViewPort.cxx b/src/QtViewer/QtViewer_ViewPort.cxx index 56cac94ff..af62030ed 100644 --- a/src/QtViewer/QtViewer_ViewPort.cxx +++ b/src/QtViewer/QtViewer_ViewPort.cxx @@ -81,8 +81,14 @@ void QtViewer_ViewPort::addItem( QGraphicsItem* theItem ) void QtViewer_ViewPort::fitAll() { + QRectF aRect; + foreach (QGraphicsItem* item, scene()->items()) + { + if (item->isVisible()) + aRect = aRect.united(item->boundingRect()); + } + scene()->setSceneRect(scene()->itemsBoundingRect()); - QRectF aRect = scene()->sceneRect(); fitInView( aRect.adjusted(-myFitAllGap, -myFitAllGap, myFitAllGap, myFitAllGap), Qt::KeepAspectRatio); } -- 2.39.2