From: asl Date: Thu, 18 Mar 2010 10:27:36 +0000 (+0000) Subject: enable state for transformation is implemented: now it is possible to disable some... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1e013ffd02053eeaeccc0c39c09d935b3cda3e7a;p=modules%2Fgui.git enable state for transformation is implemented: now it is possible to disable some transformations, for example, rotation --- diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 65f1bc061..0ae1fca27 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -468,8 +468,8 @@ void OCCViewer_ViewWindow::activateZoom() if ( myOperation != ZOOMVIEW ) { QPixmap zoomPixmap (imageZoomCursor); QCursor zoomCursor (zoomPixmap); - setTransformRequested ( ZOOMVIEW ); - myViewPort->setCursor( zoomCursor ); + if( setTransformRequested ( ZOOMVIEW ) ) + myViewPort->setCursor( zoomCursor ); } } @@ -486,8 +486,8 @@ void OCCViewer_ViewWindow::activatePanning() if ( myOperation != PANVIEW ) { QCursor panCursor (Qt::SizeAllCursor); - setTransformRequested ( PANVIEW ); - myViewPort->setCursor( panCursor ); + if( setTransformRequested ( PANVIEW ) ) + myViewPort->setCursor( panCursor ); } } @@ -504,8 +504,8 @@ void OCCViewer_ViewWindow::activateRotation() if ( myOperation != ROTATE ) { QPixmap rotatePixmap (imageRotateCursor); QCursor rotCursor (rotatePixmap); - setTransformRequested ( ROTATE ); - myViewPort->setCursor( rotCursor ); + if( setTransformRequested ( ROTATE ) ) + myViewPort->setCursor( rotCursor ); } } @@ -693,8 +693,8 @@ void OCCViewer_ViewWindow::activateGlobalPanning() aView3d->FitAll(0.01, false); myCursor = cursor(); // save old cursor myViewPort->fitAll(); // fits view before selecting a new scene center - setTransformRequested( PANGLOBAL ); - myViewPort->setCursor( glPanCursor ); + if( setTransformRequested( PANGLOBAL ) ) + myViewPort->setCursor( glPanCursor ); } } @@ -710,22 +710,25 @@ void OCCViewer_ViewWindow::activateWindowFit() if ( myOperation != WINDOWFIT ) { QCursor handCursor (Qt::PointingHandCursor); - setTransformRequested ( WINDOWFIT ); - myViewPort->setCursor ( handCursor ); - myCursorIsHand = true; + if( setTransformRequested ( WINDOWFIT ) ) + { + myViewPort->setCursor ( handCursor ); + myCursorIsHand = true; + } } } /*! \brief Start delayed viewer operation. */ -void OCCViewer_ViewWindow::setTransformRequested( OperationType op ) +bool OCCViewer_ViewWindow::setTransformRequested( OperationType op ) { - myOperation = op; - myViewPort->setMouseTracking( myOperation == NOTHING ); + bool ok = transformEnabled( op ); + myOperation = ok ? op : NOTHING; + myViewPort->setMouseTracking( myOperation == NOTHING ); + return ok; } - /*! \brief Handle mouse move event. \param theEvent mouse event @@ -1907,3 +1910,23 @@ void OCCViewer_ViewWindow::setTransformInProcess( bool bOn ) { myEventStarted = bOn; } + +/*! + Set enabled state of transformation (rotate, zoom, etc) +*/ +void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on ) +{ + if( id==NOTHING ) + return; + myStatus.insert( id, on ); +} + +/*! + \return enabled state of transformation (rotate, zoom, etc) +*/ +bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const +{ + if( myStatus.contains( id ) ) + return myStatus[ id ]; + return true; +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 15fd3b61a..182fadbfc 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -88,6 +88,9 @@ public: int interactionStyle() const; void setInteractionStyle( const int ); + void setTransformEnabled( const OperationType, const bool ); + bool transformEnabled( const OperationType ) const; + public slots: void onFrontView(); void onViewFitAll(); @@ -138,7 +141,7 @@ protected: /* Transformation selected but not started yet */ bool transformRequested() const; - void setTransformRequested ( OperationType ); + bool setTransformRequested ( OperationType ); /* Transformation is selected and already started */ bool transformInProcess() const; @@ -209,6 +212,9 @@ private: QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band int myInteractionStyle; + + typedef QMap MapOfTransformStatus; + MapOfTransformStatus myStatus; }; #ifdef WIN32