From fe82b7b2c0fddb31f2fbd4a38b972fb176415f26 Mon Sep 17 00:00:00 2001 From: ouv Date: Mon, 26 Aug 2013 10:26:47 +0000 Subject: [PATCH] 1) Improved visibility management 2) Save/load visual state --- src/GraphicsView/GraphicsView_ViewFrame.cxx | 44 +++++++++++++++++++++ src/GraphicsView/GraphicsView_ViewFrame.h | 5 ++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/GraphicsView/GraphicsView_ViewFrame.cxx b/src/GraphicsView/GraphicsView_ViewFrame.cxx index 89f9e0b31..dcaa1cc5d 100644 --- a/src/GraphicsView/GraphicsView_ViewFrame.cxx +++ b/src/GraphicsView/GraphicsView_ViewFrame.cxx @@ -199,6 +199,50 @@ QImage GraphicsView_ViewFrame::dumpView() return myViewPort->dumpView(); } +//================================================================ +// Function : getVisualParameters +// Purpose : +//================================================================ +QString GraphicsView_ViewFrame::getVisualParameters() +{ + QTransform aTransform = myViewPort->transform(); + + QString aString; + aString.sprintf( "%.3f*%.3f*%.3f*%.3f*%.3f*%.3f*%.3f*%.3f*%.3f", + aTransform.m11(), aTransform.m12(), aTransform.m13(), + aTransform.m21(), aTransform.m22(), aTransform.m23(), + aTransform.m31(), aTransform.m32(), aTransform.m33() ); + return aString; +} + +//================================================================ +// Function : setVisualParameters +// Purpose : +//================================================================ +void GraphicsView_ViewFrame::setVisualParameters( const QString& theParameters ) +{ + QStringList aList = theParameters.split( '*' ); + if( aList.size() < 9 ) + return; + + bool anIsOk[9]; + QTransform aTransform( aList[0].toDouble( &anIsOk[0] ), + aList[1].toDouble( &anIsOk[1] ), + aList[2].toDouble( &anIsOk[2] ), + aList[3].toDouble( &anIsOk[3] ), + aList[4].toDouble( &anIsOk[4] ), + aList[5].toDouble( &anIsOk[5] ), + aList[6].toDouble( &anIsOk[6] ), + aList[7].toDouble( &anIsOk[7] ), + aList[8].toDouble( &anIsOk[8] ) ); + for( int i = 0; i < 9; i++ ) + if( !anIsOk[ i ] ) + return; + + myViewPort->setTransform( aTransform ); + myViewPort->applyTransform(); +} + //================================================================ // Function : expandToolBarActions // Purpose : diff --git a/src/GraphicsView/GraphicsView_ViewFrame.h b/src/GraphicsView/GraphicsView_ViewFrame.h index 8e3ffe60a..3ee05b692 100644 --- a/src/GraphicsView/GraphicsView_ViewFrame.h +++ b/src/GraphicsView/GraphicsView_ViewFrame.h @@ -59,9 +59,12 @@ public: virtual QImage dumpView(); + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& theParameters ); + void expandToolBarActions(); - protected slots: +protected slots: void onViewPan(); void onViewZoom(); void onViewFitAll(); -- 2.39.2