From baa03d24ce6660db066083e407219d54d6778a41 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 6 Mar 2012 11:19:42 +0000 Subject: [PATCH] PRECOS issue 0000966: External: Topology preview is too small --- src/GraphicsView/GraphicsView_ViewPort.cxx | 24 +++++++++++++++++++ src/GraphicsView/GraphicsView_ViewPort.h | 1 + .../GraphicsView_ViewTransformer.cxx | 4 ++++ src/GraphicsView/GraphicsView_Viewer.h | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) 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(); -- 2.39.2