From: ouv Date: Tue, 6 Mar 2012 11:19:42 +0000 (+0000) Subject: PRECOS issue 0000966: External: Topology preview is too small X-Git-Tag: CTH_1_7_3~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=baa03d24ce6660db066083e407219d54d6778a41;p=modules%2Fgui.git PRECOS issue 0000966: External: Topology preview is too small --- diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index ac08bd0e1..be6e03b84 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -829,6 +829,30 @@ void GraphicsView_ViewPort::fitAll( bool theKeepScale ) myIsTransforming = false; } +//================================================================ +// Function : fitWidth +// Purpose : +//================================================================ +void GraphicsView_ViewPort::fitWidth() +{ + myIsTransforming = true; + + double aGap = myFitAllGap; + QRectF aRect = objectsBoundingRect( true ); + + double aTop = aRect.top(); + double aLeft = aRect.left(); + double aMargin = 10; + + aRect.setY( aRect.center().y() ); + aRect.setHeight( aMargin ); + + fitInView( aRect.adjusted( -aGap, -aGap, aGap, aGap ), Qt::KeepAspectRatio ); + ensureVisible( aLeft, aTop, aMargin, aMargin, 0, aGap ); + + myIsTransforming = false; +} + //================================================================ // Function : currentBlock // Purpose : diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index c94154bf1..93b606d8a 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -144,6 +144,7 @@ public: void fitRect( const QRectF& theRect ); void fitSelect(); void fitAll( bool theKeepScale = false ); + void fitWidth(); bool isTransforming() const { return myIsTransforming; } diff --git a/src/GraphicsView/GraphicsView_ViewTransformer.cxx b/src/GraphicsView/GraphicsView_ViewTransformer.cxx index 0f86a85fa..06e794a2f 100644 --- a/src/GraphicsView/GraphicsView_ViewTransformer.cxx +++ b/src/GraphicsView/GraphicsView_ViewTransformer.cxx @@ -138,6 +138,10 @@ void GraphicsView_ViewTransformer::exec() aViewPort->fitSelect(); onTransform( Finished ); break; + case GraphicsView_Viewer::FitWidth: + aViewPort->fitWidth(); + onTransform( Finished ); + break; default: break; } } diff --git a/src/GraphicsView/GraphicsView_Viewer.h b/src/GraphicsView/GraphicsView_Viewer.h index 100882000..477d40c50 100644 --- a/src/GraphicsView/GraphicsView_Viewer.h +++ b/src/GraphicsView/GraphicsView_Viewer.h @@ -51,7 +51,7 @@ class GRAPHICSVIEW_API GraphicsView_Viewer: public SUIT_ViewModel public: enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect, - Zoom, PanGlobal, Pan, UserTransform = 100 }; + Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 }; public: GraphicsView_Viewer( const QString& title ); ~GraphicsView_Viewer();