From: CHEMIN Sebastien Date: Fri, 19 Apr 2024 07:18:20 +0000 (+0200) Subject: Fit All on visible objects X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=05f379b9d0e45d10e699da7985bcd177ea8b998b;p=modules%2Fgui.git Fit All on visible objects --- 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); }