X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSVTK%2FSVTK_ViewModel.cxx;h=977da9440202d237548f10f5a280cbd83e265436;hb=e6caa123c65e3c4a3017364ec5bb4225fd898465;hp=d0e2556d1624648f56ca4a7ebdd1dbde58e52ab1;hpb=bb8609caf7881d966fbb88dec0a7822736da93f5;p=modules%2Fgui.git diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index d0e2556d1..977da9440 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +29,6 @@ #include //#include "SUIT_Session.h" -#include "SVTK_Selection.h" #include "SVTK_ViewModel.h" #include "SVTK_ViewWindow.h" #include "SVTK_View.h" @@ -87,7 +86,8 @@ SVTK_Viewer::SVTK_Viewer() myProjMode = 0; myStyle = 0; myZoomingStyle = 0; - myDynamicPreSelection = false; + mySelectionEnabled = true; + myPreSelectionMode = Standard_Preselection; mySpaceBtn[0] = 1; mySpaceBtn[1] = 2; mySpaceBtn[2] = 9; @@ -179,7 +179,8 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) aViewWindow->SetProjectionMode( projectionMode() ); aViewWindow->SetInteractionStyle( interactionStyle() ); aViewWindow->SetZoomingStyle( zoomingStyle() ); - aViewWindow->SetDynamicPreSelection( dynamicPreSelection() ); + aViewWindow->SetPreSelectionMode( preSelectionMode() ); + aViewWindow->SetSelectionEnabled( isSelectionEnabled() ); aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() ); aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) ); @@ -335,27 +336,27 @@ void SVTK_Viewer::setZoomingStyle( const int theStyle ) } /*! - \return dynamic preselection + \return current preselection mode */ -bool SVTK_Viewer::dynamicPreSelection() const +Preselection_Mode SVTK_Viewer::preSelectionMode() const { - return myDynamicPreSelection; + return myPreSelectionMode; } /*! - Sets dynamic preselection - \param theMode - new dynamic preselection mode + Sets preselection mode + \param theMode - new preselection mode */ -void SVTK_Viewer::setDynamicPreSelection( const bool theMode ) +void SVTK_Viewer::setPreSelectionMode( Preselection_Mode theMode ) { - myDynamicPreSelection = theMode; + myPreSelectionMode = theMode; if (SUIT_ViewManager* aViewManager = getViewManager()) { QVector aViews = aViewManager->getViews(); for ( uint i = 0; i < aViews.count(); i++ ) { if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) - aView->SetDynamicPreSelection( theMode ); + aView->SetPreSelectionMode( theMode ); } } } @@ -494,6 +495,32 @@ void SVTK_Viewer::enableSelection(bool isEnabled) { mySelectionEnabled = isEnabled; //!! To be done for view windows + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetSelectionEnabled( isEnabled ); + } + } + + if(!isEnabled) { + //clear current selection in the viewer + bool blocked = blockSignals( true ); + if ( SUIT_ViewManager* aViewMgr = getViewManager() ) { + if( SVTK_ViewWindow* aViewWindow = dynamic_cast( aViewMgr->getActiveView() ) ){ + if( SVTK_Selector* aSelector = aViewWindow->GetSelector() ) { + if(SVTK_View* aView = aViewWindow->getView()){ + aSelector->ClearIObjects(); + aView->onSelectionChanged(); + } + } + } + } + blockSignals( blocked ); + } + } /*! @@ -643,7 +670,7 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) Erase all presentations \param forced - removes all objects from view */ -void SVTK_Viewer::EraseAll( const bool forced ) +void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) { // Temporarily commented to avoid awful dependecy on SALOMEDS // TODO: better mechanism of storing display/erse status in a study @@ -666,10 +693,10 @@ void SVTK_Viewer::EraseAll( const bool forced ) //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); //if(!anObj.IsNull() && anObj->hasEntry() && aStudy) // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); - if(forced) + if(forced){ if(SVTK_Renderer* aRnd = aView->GetRenderer()) aRnd->RemoveActor(anAct); - else{ + }else{ // just erase actor anAct->SetVisibility( false ); // erase dependent actors @@ -684,6 +711,9 @@ void SVTK_Viewer::EraseAll( const bool forced ) } } } + + SALOME_View::EraseAll( d, forced ); + Repaint(); } @@ -693,7 +723,7 @@ void SVTK_Viewer::EraseAll( const bool forced ) */ SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry ) { - SVTK_Prs* prs = new SVTK_Prs(); + SVTK_Prs* prs = new SVTK_Prs( entry ); if ( entry ) { if(SVTK_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) if(SVTK_View* aView = aViewWindow->getView()){