From: vsr Date: Fri, 9 Aug 2013 06:11:48 +0000 (+0000) Subject: 0021883 [CEA 674] Deactivate pre-selection in OCC and VTK viewer X-Git-Tag: BR_hydro_v_0_3_1~88 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a774d4fbdaea509f44006ad9061057e2423d7cdc;p=modules%2Fgui.git 0021883 [CEA 674] Deactivate pre-selection in OCC and VTK viewer 0022174 [CEA 793] De-activate entirely selection in order to have a fast view usage --- diff --git a/doc/salome/gui/images/occviewer_toolbar.png b/doc/salome/gui/images/occviewer_toolbar.png index 3d8a91992..5a16df176 100644 Binary files a/doc/salome/gui/images/occviewer_toolbar.png and b/doc/salome/gui/images/occviewer_toolbar.png differ diff --git a/doc/salome/gui/input/occ_3d_viewer.doc b/doc/salome/gui/input/occ_3d_viewer.doc index 4eb31fce6..783adee96 100644 --- a/doc/salome/gui/input/occ_3d_viewer.doc +++ b/doc/salome/gui/input/occ_3d_viewer.doc @@ -37,6 +37,16 @@ current cursor position) zooming styles. Show/Hide Trihedron - shows or hides coordinate axes.
+\image html occ_view_preselection.png + +Enable/Disable preselection - enables or disables preselection in the view. +
+ +\image html occ_view_selection.png + +Enable/Disable selection - enables or disables selection in the view. +
+ \image html occ_view_fitall.png Fit all - allows to select a point to be the center of a scene diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 6e7667829..dae1db07e 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -513,3 +513,17 @@ void OCCViewer_ViewFrame::updateWindowTitle(OCCViewer_ViewWindow* theView) if ( !title.isEmpty() ) theView->setWindowTitle( windowTitle() + " - " + title ); } + +void OCCViewer_ViewFrame::enableSelection( bool isEnabled ) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->enableSelection(isEnabled); + } +} + +void OCCViewer_ViewFrame::enablePreselection( bool isEnabled ) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->enablePreselection(isEnabled); + } +} diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 99cfdb064..35935b630 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -72,6 +72,12 @@ public: virtual int zoomingStyle() const { return getView(MAIN_VIEW)->zoomingStyle(); } virtual void setZoomingStyle( const int ); + virtual bool isSelectionEnabled() const { return getView(MAIN_VIEW)->isSelectionEnabled(); } + virtual void enableSelection( bool ); + + virtual bool isPreselectionEnabled() const { return getView(MAIN_VIEW)->isPreselectionEnabled(); } + virtual void enablePreselection( 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 71f94cbe4..b728482f1 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -154,6 +154,9 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) // set zooming style to standard myZoomingStyle = 0; + // preselection + myPreselectionEnabled = true; + // selection mySelectionEnabled = true; myMultiSelectionEnabled = true; @@ -220,6 +223,8 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) view->initSketchers(); view->setInteractionStyle( interactionStyle() ); view->setZoomingStyle( zoomingStyle() ); + view->enablePreselection( isPreselectionEnabled() ); + view->enableSelection( isSelectionEnabled() ); OCCViewer_ViewPort3d* vp3d = view->getViewPort(); if ( vp3d ) @@ -288,7 +293,9 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; - if ( isSelectionEnabled() ) { + myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y()); + + if ( isSelectionEnabled() && isPreselectionEnabled() ) { if (aView->getViewPort()->isBusy()) { QCoreApplication::processEvents(); return; // Check that the ViewPort initialization completed @@ -323,6 +330,13 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t if (myStartPnt == myEndPnt) { + if ( !isPreselectionEnabled() ) { + Handle(V3d_View) aView3d = aView->getViewPort()->getView(); + if ( !aView3d.IsNull() ) { + myAISContext->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d); + } + } + if (aHasShift && myMultiSelectionEnabled) myAISContext->ShiftSelect(); else @@ -370,6 +384,14 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven return; emit deselection(); + + if ( !isPreselectionEnabled() ) { + Handle(V3d_View) aView3d = aView->getViewPort()->getView(); + if ( !aView3d.IsNull() ) { + myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d); + } + } + myAISContext->Select(); emit selectionChanged(); @@ -453,12 +475,50 @@ void OCCViewer_Viewer::setZoomingStyle( const int theStyle ) } /*! - Sets selection enabled status + \return true if preselection is enabled +*/ +bool OCCViewer_Viewer::isPreselectionEnabled() const +{ + return myPreselectionEnabled; +} + +/*! + Enables/disables preselection + \param isEnabled - new status +*/ +void OCCViewer_Viewer::enablePreselection(bool isEnabled) +{ + myPreselectionEnabled = isEnabled; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) { + win->enablePreselection( isEnabled ); + } + } +} + +/*! + \return true if selection is enabled +*/ +bool OCCViewer_Viewer::isSelectionEnabled() const +{ + return mySelectionEnabled; +} + +/*! + Enables/disables selection \param isEnabled - new status */ void OCCViewer_Viewer::enableSelection(bool isEnabled) { mySelectionEnabled = isEnabled; + //!! To be done for view windows if ( !myViewManager ) return; @@ -467,8 +527,10 @@ void OCCViewer_Viewer::enableSelection(bool isEnabled) for ( int i = 0; i < (int)wins.count(); i++ ) { OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); - if ( win ) + if ( win ) { win->updateEnabledDrawMode(); + win->enableSelection( isEnabled ); + } } } @@ -627,12 +689,22 @@ bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj, Unhilights all objects in viewer \param updateviewer - update current viewer */ -bool OCCViewer_Viewer::unHighlightAll( bool updateviewer ) +bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect ) { - if ( myAISContext->HasOpenedContext() ) - myAISContext->ClearSelected( updateviewer ); - else - myAISContext->ClearCurrents( updateviewer ); + if ( myAISContext->HasOpenedContext() ) { + if ( unselect ) { + myAISContext->ClearSelected( updateviewer ); + } else { + myAISContext->UnhilightSelected( updateviewer ); + } + } else { + if ( unselect ) { + myAISContext->ClearCurrents( updateviewer ); + } else { + myAISContext->UnhilightCurrents( updateviewer ); + } + } + return false; } @@ -924,3 +996,14 @@ void OCCViewer_Viewer::updateTrihedron() { myTrihedron->SetSize(myTrihedronSize); } } + +/*! + Set number of isolines + \param u - u-isolines (first parametric co-ordinate) + \param v - v-isolines (second parametric co-ordinate) +*/ +void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled ) +{ + myPreselectionEnabled = isPreselectionEnabled; + mySelectionEnabled = isSelectionEnabled; +} diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 456ddfcbf..1ad1ddd4f 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -129,8 +129,13 @@ public: int zoomingStyle() const; void setZoomingStyle( const int ); + void enablePreselection(bool isEnabled); + bool isPreselectionEnabled() const; + void enableSelection(bool isEnabled); - bool isSelectionEnabled() const { return mySelectionEnabled; } + bool isSelectionEnabled() const; + + void setSelectionOptions( bool, bool ); void enableMultiselection(bool isEnable); bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } @@ -142,7 +147,7 @@ public: /* Selection management */ bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); - bool unHighlightAll( bool=true ); + bool unHighlightAll( bool=true, bool=true ); bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false ); bool isVisible( const Handle(AIS_InteractiveObject)& ); @@ -178,6 +183,7 @@ protected: int myInteractionStyle; int myZoomingStyle; + bool myPreselectionEnabled; bool mySelectionEnabled; bool myMultiSelectionEnabled; bool myIsRelative; @@ -185,7 +191,7 @@ protected: int myTopLayerId; //QColor myBgColor; - QPoint myStartPnt, myEndPnt; + QPoint myStartPnt, myEndPnt, myCurPnt; bool myShowStaticTrihedron; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 8b3340dbd..9fb1b2619 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -237,6 +237,9 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, my2dMode = No2dMode; myInteractionStyle = SUIT_ViewModel::STANDARD; + myPreselectionEnabled = true; + mySelectionEnabled = true; + clearViewAspects(); @@ -1236,6 +1239,22 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale())); toolMgr()->registerAction( aAction, AxialScaleId ); + // Enable/disable preselection + aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ), + tr( "MNU_ENABLE_PRESELECTION" ), 0, this); + aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION")); + aAction->setCheckable(true); + connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool))); + toolMgr()->registerAction( aAction, SwitchPreselectionId ); + + // Enable/disable selection + aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ), + tr( "MNU_ENABLE_SELECTION" ), 0, this); + aAction->setStatusTip(tr("DSC_ENABLE_SELECTION")); + aAction->setCheckable(true); + connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool))); + toolMgr()->registerAction( aAction, SwitchSelectionId ); + // Graduated axes aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ), tr( "MNU_GRADUATED_AXES" ), 0, this); @@ -1304,6 +1323,8 @@ void OCCViewer_ViewWindow::createToolBar() #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version toolMgr()->append( SwitchZoomingStyleId, tid ); #endif + toolMgr()->append( SwitchPreselectionId, tid ); + toolMgr()->append( SwitchSelectionId, tid ); if( myModel->trihedronActivated() ) toolMgr()->append( TrihedronShowId, tid ); @@ -1719,6 +1740,49 @@ void OCCViewer_ViewWindow::onTrihedronShow() myModel->toggleTrihedron(); } +/*! + \brief Toggles preselection (highlighting) on/off +*/ +void OCCViewer_ViewWindow::onSwitchPreselection( bool on ) +{ + myPreselectionEnabled = on; + myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() ); + + // unhighlight all highlighted objects + /*if ( !on ) { + myModel->unHighlightAll( true, false ); + }*/ + + // update action state if method is called outside + QtxAction* a = dynamic_cast( toolMgr()->action( SwitchPreselectionId ) ); + if ( a && a->isChecked() != on ) { + a->setChecked( on ); + } +} + +/*! + \brief Toggles selection on/off +*/ +void OCCViewer_ViewWindow::onSwitchSelection( bool on ) +{ + mySelectionEnabled = on; + myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() ); + + // update action state if method is called outside + + // preselection + QtxAction* a = dynamic_cast( toolMgr()->action( SwitchPreselectionId ) ); + if ( a ) { + a->setEnabled( on ); + } + + // selection + a = dynamic_cast( toolMgr()->action( SwitchSelectionId ) ); + if ( a && a->isChecked() != on ) { + a->setChecked( on ); + } +} + /*! \brief Switches "keyboard free" interaction style on/off */ @@ -2693,3 +2757,39 @@ void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView ) blockSignals( blocked ); } + +/*! + \brief Indicates whether preselection is enabled + \return true if preselection is enabled +*/ +bool OCCViewer_ViewWindow::isPreselectionEnabled() const +{ + return myPreselectionEnabled; +} + +/*! + \brief Enables/disables preselection + \param theIsToEnable if true - preselection will be enabled +*/ +void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable ) +{ + onSwitchPreselection( theIsToEnable ); +} + +/*! + \brief Indicates whether selection is enabled + \return true if selection is enabled +*/ +bool OCCViewer_ViewWindow::isSelectionEnabled() const +{ + return mySelectionEnabled; +} + +/*! + \brief Enables/disables selection + \param theIsToEnable if true - selection will be enabled +*/ +void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable ) +{ + onSwitchSelection( theIsToEnable ); +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index a445b5a86..a203a2bf2 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -121,7 +121,10 @@ public: FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId, CloneId, ClippingId, MemId, RestoreId, TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId, - SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId }; + SwitchInteractionStyleId, SwitchZoomingStyleId, + SwitchPreselectionId, SwitchSelectionId, + MaximizedId, SynchronizeId, + UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, @@ -170,6 +173,11 @@ public: virtual int zoomingStyle() const; virtual void setZoomingStyle( const int ); + + virtual bool isPreselectionEnabled() const; + virtual void enablePreselection( bool ); + virtual bool isSelectionEnabled() const; + virtual void enableSelection( bool ); void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; @@ -226,6 +234,8 @@ public slots: virtual void setRestoreFlag(); virtual void onSwitchInteractionStyle( bool on ); virtual void onSwitchZoomingStyle( bool on ); + virtual void onSwitchPreselection( bool on ); + virtual void onSwitchSelection( bool on ); virtual void activateSetRotationGravity(); virtual void activateSetRotationSelected( double theX, double theY, double theZ ); @@ -332,6 +342,8 @@ private: QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band + bool mySelectionEnabled; + bool myPreselectionEnabled; int myInteractionStyle; typedef QMap MapOfTransformStatus; diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index 40bb07511..98804e2c7 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -123,5 +123,13 @@ ICON_OCCVIEWER_MINIMIZE occ_view_minimized.png + + ICON_OCCVIEWER_PRESELECTION + occ_view_preselection.png + + + ICON_OCCVIEWER_SELECTION + occ_view_selection.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index e505ec1ab..d9d1f0d99 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -267,6 +267,22 @@ MNU_ZOOMING_STYLE_SWITCH Zooming style switch + + DSC_ENABLE_PRESELECTION + Enable/disable preselection + + + MNU_ENABLE_PRESELECTION + Enable/disable preselection + + + DSC_ENABLE_SELECTION + Enable/disable selection + + + MNU_ENABLE_SELECTION + Enable/disable selection + OCC_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps) diff --git a/src/OCCViewer/resources/OCCViewer_msg_fr.ts b/src/OCCViewer/resources/OCCViewer_msg_fr.ts index 74b9bfeb3..0f09189f0 100755 --- a/src/OCCViewer/resources/OCCViewer_msg_fr.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_fr.ts @@ -267,6 +267,22 @@ MNU_ZOOMING_STYLE_SWITCH Changer le style de zoom + + DSC_ENABLE_PRESELECTION + Enable/disable preselection + + + MNU_ENABLE_PRESELECTION + Enable/disable preselection + + + DSC_ENABLE_SELECTION + Enable/disable selection + + + MNU_ENABLE_SELECTION + Enable/disable selection + OCC_IMAGE_FILES Fichiers images (*.bmp *.png *.jpg *.jpeg *.eps *.ps) diff --git a/src/OCCViewer/resources/occ_view_preselection.png b/src/OCCViewer/resources/occ_view_preselection.png new file mode 100755 index 000000000..cd5baec98 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_preselection.png differ diff --git a/src/OCCViewer/resources/occ_view_selection.png b/src/OCCViewer/resources/occ_view_selection.png new file mode 100644 index 000000000..21d18e901 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_selection.png differ