From: vsr Date: Fri, 9 Oct 2015 12:15:18 +0000 (+0300) Subject: Allow explicitly enable / disable draw rect (rubber band) mode in OCC viewer X-Git-Tag: NewGEOM_1.4.0_a X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f2a8205ec61f43183fb9f7a333af895f1e5584b;p=modules%2Fgui.git Allow explicitly enable / disable draw rect (rubber band) mode in OCC viewer --- diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 70e253b63..e4c3ec904 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -708,3 +708,12 @@ void OCCViewer_ViewFrame::enablePreselection( bool isEnabled ) aView->enablePreselection(isEnabled); } } + +bool OCCViewer_ViewFrame::enableDrawMode( bool on ) +{ + bool prev = false; + foreach (OCCViewer_ViewWindow* aView, myViews) { + prev = prev || aView->enableDrawMode( on ); + } + return prev; +} diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 8c0481398..e7bb37726 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -107,6 +107,8 @@ public: virtual bool isPreselectionEnabled() const { return getView(MAIN_VIEW)->isPreselectionEnabled(); } virtual void enablePreselection( bool ); + virtual bool enableDrawMode( bool ); + virtual void setViewManager( SUIT_ViewManager* ); virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); } diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 1b2f96cbe..282cc5721 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -1544,3 +1544,22 @@ void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) { myClippingDlg = theDlg; } } + + +bool OCCViewer_Viewer::enableDrawMode( bool on ) +{ + //!! To be done for view windows + if ( !myViewManager ) + return false; + + bool prev = false; + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) { + prev = prev || win->enableDrawMode( on ); + } + } + return prev; +} diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 0115104bf..a8eba563e 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -179,6 +179,8 @@ public: void enableMultiselection(bool isEnable); bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } + bool enableDrawMode( bool on ); + void setClippingColor( const QColor& ); QColor clippingColor() const; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index fb65e7d33..a0e96792b 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -243,6 +243,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myModel = theModel; myRestoreFlag = 0; myEnableDrawMode = false; + myDrawRectEnabled = true; myDrawRect=false; updateEnabledDrawMode(); myScalingDlg = 0; @@ -420,13 +421,25 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) return SUIT_ViewWindow::eventFilter(watched, e); } +/*! + \brief Enable / disable draw rect (rubber band) mode +*/ +bool OCCViewer_ViewWindow::enableDrawMode( bool on ) +{ + bool prev = myDrawRectEnabled; + myDrawRectEnabled = on; + updateEnabledDrawMode(); + return prev; +} + /*! \brief Update state of enable draw mode state. */ void OCCViewer_ViewWindow::updateEnabledDrawMode() { + myEnableDrawMode = myDrawRectEnabled; if ( myModel ) - myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled(); + myEnableDrawMode = myEnableDrawMode && myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled(); } /*! diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index dff660d72..51f6b92b0 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -186,6 +186,8 @@ public: virtual void initLayout(); + virtual bool enableDrawMode( bool ); + virtual void updateEnabledDrawMode(); virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0, @@ -396,6 +398,7 @@ protected: bool myCursorIsHand; bool myDrawRect; // set when a rect is used for selection or magnify bool myEnableDrawMode; + bool myDrawRectEnabled; bool myPaintersRedrawing; // set to draw with external painters bool IsSketcherStyle; bool myIsKeyFree;