From 09d6d81389f6a3a46c974ea1536e9e57f20a7cf3 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 8 Nov 2005 12:23:44 +0000 Subject: [PATCH] Adjust to LightApp architecture --- src/LightApp/LightApp_VTKSelector.cxx | 25 +-- src/LightApp/LightApp_VTKSelector.h | 8 +- src/SVTK/Makefile.in | 7 - src/SVTK/SVTK_ViewModel.cxx | 96 ++++++------ src/SVTK/SVTK_ViewModel.h | 3 +- src/SalomeApp/SalomeApp_VTKSelector.cxx | 199 ------------------------ src/SalomeApp/SalomeApp_VTKSelector.h | 78 ---------- src/SalomeApp/resources/SalomeApp.xml | 15 ++ 8 files changed, 84 insertions(+), 347 deletions(-) delete mode 100644 src/SalomeApp/SalomeApp_VTKSelector.cxx delete mode 100644 src/SalomeApp/SalomeApp_VTKSelector.h diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index c31cc4341..caf33ff5e 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -1,7 +1,7 @@ #include "LightApp_VTKSelector.h" #include "LightApp_DataOwner.h" -#include "SVTK_ViewModel.h" +#include "SVTK_ViewModelBase.h" #include "SVTK_Selector.h" #include "SVTK_ViewWindow.h" #include "SVTK_Functor.h" @@ -18,9 +18,9 @@ */ LightApp_SVTKDataOwner ::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_IndexedMapOfInteger& theIds, - Selection_Mode theMode, - SALOME_Actor* theActor): + const TColStd_IndexedMapOfInteger& theIds, + Selection_Mode theMode, + SALOME_Actor* theActor): LightApp_DataOwner( theIO ), mySelectionMode(theMode), myActor(theActor) @@ -50,8 +50,8 @@ LightApp_SVTKDataOwner Constructor. */ LightApp_VTKSelector -::LightApp_VTKSelector( SVTK_Viewer* viewer, - SUIT_SelectionMgr* mgr ): +::LightApp_VTKSelector( SVTK_ViewModelBase* viewer, + SUIT_SelectionMgr* mgr ): SUIT_Selector( mgr, viewer ), myViewer( viewer ) { @@ -70,7 +70,7 @@ LightApp_VTKSelector /*! Gets viewer. */ -SVTK_Viewer* +SVTK_ViewModelBase* LightApp_VTKSelector ::viewer() const { @@ -78,13 +78,13 @@ LightApp_VTKSelector } /*! - Gets type of vtk viewer. + Gets type of salome vtk viewer. */ QString LightApp_VTKSelector ::type() const { - return SVTK_Viewer::Type(); + return myViewer->getType(); } /*! @@ -117,9 +117,10 @@ LightApp_VTKSelector TColStd_IndexedMapOfInteger anIds; aSelector->GetIndex(anIO,anIds); SALOME_Actor* anActor = aSelector->GetActor(anIO); - if( !anActor ) - anActor = VTK::Find(aView->getRenderer()->GetActors(),VTK::TIsSameIObject(anIO)); - + if( !anActor ){ + using namespace SVTK; + anActor = Find(aView->getRenderer()->GetActors(),TIsSameIObject(anIO)); + } aList.append(new LightApp_SVTKDataOwner(anIO,anIds,aMode,anActor)); } } diff --git a/src/LightApp/LightApp_VTKSelector.h b/src/LightApp/LightApp_VTKSelector.h index 25c4ac44e..5e3073db2 100644 --- a/src/LightApp/LightApp_VTKSelector.h +++ b/src/LightApp/LightApp_VTKSelector.h @@ -14,7 +14,7 @@ #include "SALOME_InteractiveObject.hxx" class SALOME_Actor; -class SVTK_Viewer; +class SVTK_ViewModelBase; /*! Provide salome vtk data owner list. @@ -57,10 +57,10 @@ class LIGHTAPP_EXPORT LightApp_VTKSelector : public SUIT_Selector Q_OBJECT; public: - LightApp_VTKSelector( SVTK_Viewer*, SUIT_SelectionMgr* ); + LightApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* ); virtual ~LightApp_VTKSelector(); - SVTK_Viewer* viewer() const; + SVTK_ViewModelBase* viewer() const; virtual QString type() const; @@ -72,7 +72,7 @@ protected: virtual void setSelection( const SUIT_DataOwnerPtrList& ); private: - SVTK_Viewer* myViewer; + SVTK_ViewModelBase* myViewer; }; #endif diff --git a/src/SVTK/Makefile.in b/src/SVTK/Makefile.in index 56b9df040..73ac9bfe4 100755 --- a/src/SVTK/Makefile.in +++ b/src/SVTK/Makefile.in @@ -73,13 +73,6 @@ LIB_MOC = \ SVTK_ViewModel.h \ SVTK_View.h -LIB_CLIENT_IDL = \ - SALOMEDS.idl \ - SALOMEDS_Attributes.idl \ - SALOME_Exception.idl \ - SALOME_ModuleCatalog.idl \ - SALOME_GenericObj.idl - BIN = SVTK CPPFLAGS+= \ diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 888e3ac63..4b1d593e7 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -14,51 +14,39 @@ #include "SVTK_MainWindow.h" #include "SVTK_Prs.h" -#include "VTKViewer_ViewModel.h" - -#include "ToolsGUI.h" - #include "SALOME_Actor.h" #include "SALOME_InteractiveObject.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" -#include "SALOME_ModuleCatalog_impl.hxx" -#include "SALOME_NamingService.hxx" - -#include "SALOMEDSClient.hxx" -#include "SALOMEDS_StudyManager.hxx" - // in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from // SALOMEDS::StudyManager - no linkage with SalomeApp. -static _PTR(Study) getStudyDS() -{ - SALOMEDSClient_Study* aStudy = NULL; - _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); - +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//static _PTR(Study) getStudyDS() +//{ +// SALOMEDSClient_Study* aStudy = NULL; +// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); // get id of SUIT_Study, if it's a SalomeApp_Study, it will return // id of its underlying SALOMEDS::Study - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if ( !app ) return _PTR(Study)(aStudy); - SUIT_Study* stud = app->activeStudy(); - if ( !stud ) return _PTR(Study)(aStudy); - const int id = stud->id(); // virtual method, must return SALOMEDS_Study id +// SUIT_Application* app = SUIT_Session::session()->activeApplication(); +// if ( !app ) return _PTR(Study)(aStudy); +// SUIT_Study* stud = app->activeStudy(); +// if ( !stud ) return _PTR(Study)(aStudy); +// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id // get SALOMEDS_Study with this id from StudyMgr - return aMgr->GetStudyByID( id ); -} +// return aMgr->GetStudyByID( id ); +//} //========================================================== -SVTK_Viewer -::SVTK_Viewer() +SVTK_Viewer::SVTK_Viewer() { myTrihedronSize = 105; } //========================================================== -SVTK_Viewer -::~SVTK_Viewer() +SVTK_Viewer::~SVTK_Viewer() { } @@ -150,14 +138,14 @@ void SVTK_Viewer ::contextMenuPopup( QPopupMenu* thePopup ) { - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); + thePopup->insertItem( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); + thePopup->insertItem( tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); thePopup->insertSeparator(); if(TViewWindow* aView = dynamic_cast(myViewManager->getActiveView())){ if ( !aView->getView()->GetMainWindow()->getToolBar()->isVisible() ){ - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); + thePopup->insertItem( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); } } } @@ -241,15 +229,21 @@ SVTK_Viewer return; if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ // get SALOMEDS Study - _PTR(Study) aStudy(getStudyDS()); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) aStudy(getStudyDS()); anActorCollection->InitTraversal(); while(vtkActor* anActor = anActorCollection->GetNextActor()){ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ // Set visibility flag - Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); - } + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ + // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); + //} // just display the object QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ @@ -280,15 +274,21 @@ SVTK_Viewer return; if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ // get SALOMEDS Study - _PTR(Study) aStudy(getStudyDS()); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //_PTR(Study) aStudy(getStudyDS()); anActorCollection->InitTraversal(); while(vtkActor* anActor = anActorCollection->GetNextActor()) if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ // Set visibility flag - Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); - } + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ + // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + //} // just display the object QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ @@ -309,7 +309,10 @@ void SVTK_Viewer ::EraseAll( const bool forced ) { - _PTR(Study) aStudy(getStudyDS()); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //_PTR(Study) aStudy(getStudyDS()); QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) @@ -320,9 +323,12 @@ SVTK_Viewer while(vtkActor* anActor = anActorCollection->GetNextActor()){ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ // Set visibility flag - Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - if(!anObj.IsNull() && anObj->hasEntry() && aStudy) - ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + //if(!anObj.IsNull() && anObj->hasEntry() && aStudy) + // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); if(forced) aRenderer->RemoveActor(anAct); else{ diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index cc2f67b76..03a593f51 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -2,10 +2,9 @@ #define SVTK_VIEWMODEL_H #include "SVTK.h" +#include "SUIT_ViewModel.h" #include "SVTK_ViewModelBase.h" -#include "VTKViewer_ViewModel.h" - #include "SALOME_Prs.h" #include "SALOME_InteractiveObject.hxx" diff --git a/src/SalomeApp/SalomeApp_VTKSelector.cxx b/src/SalomeApp/SalomeApp_VTKSelector.cxx deleted file mode 100644 index 7f19aa1ee..000000000 --- a/src/SalomeApp/SalomeApp_VTKSelector.cxx +++ /dev/null @@ -1,199 +0,0 @@ -#include "SalomeApp_VTKSelector.h" -#include "SalomeApp_DataOwner.h" - -#include "SVTK_ViewModelBase.h" -#include "SVTK_Selector.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_Functor.h" - -#include "SALOME_Actor.h" -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "VTKViewer_Algorithm.h" - -#include - -#include "utilities.h" - -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif - -/*! - Constructor. -*/ -SalomeApp_SVTKDataOwner -::SalomeApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_IndexedMapOfInteger& theIds, - Selection_Mode theMode, - SALOME_Actor* theActor): - SalomeApp_DataOwner( theIO ), - mySelectionMode(theMode), - myActor(theActor) -{ - myIds = theIds; // workaround - there is no constructor copy for the container -} - -/*! - Destuctor. -*/ -SalomeApp_SVTKDataOwner -::~SalomeApp_SVTKDataOwner() -{ -} - -/*! - Gets actor pointer. -*/ -SALOME_Actor* -SalomeApp_SVTKDataOwner -::GetActor() const -{ - return myActor.GetPointer(); -} - -/*! - Constructor. -*/ -SalomeApp_VTKSelector -::SalomeApp_VTKSelector( SVTK_ViewModelBase* viewer, - SUIT_SelectionMgr* mgr ): - SUIT_Selector( mgr, viewer ), - myViewer( viewer ) -{ - if ( myViewer ) - connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); -} - -/*! - Destructor. -*/ -SalomeApp_VTKSelector -::~SalomeApp_VTKSelector() -{ -} - -/*! - Gets viewer. -*/ -SVTK_ViewModelBase* -SalomeApp_VTKSelector -::viewer() const -{ - return myViewer; -} - -/*! - Gets type of salome vtk viewer. -*/ -QString -SalomeApp_VTKSelector -::type() const -{ - return myViewer->getType(); -} - -/*! - On selection changed. -*/ -void -SalomeApp_VTKSelector -::onSelectionChanged() -{ - selectionChanged(); -} - -/*! - Gets list of selected data owners.(output \a aList). -*/ -void -SalomeApp_VTKSelector -::getSelection( SUIT_DataOwnerPtrList& aList ) const -{ - using namespace SVTK; - if(myViewer){ - if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){ - if(SVTK_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())){ - if(SVTK_Selector* aSelector = aView->GetSelector()){ - Selection_Mode aMode = aSelector->SelectionMode(); - const SALOME_ListIO& aListIO = aSelector->StoredIObjects(); - SALOME_ListIteratorOfListIO anIter(aListIO); - for(; anIter.More(); anIter.Next()){ - Handle(SALOME_InteractiveObject) anIO = anIter.Value(); - if(anIO->hasEntry()){ - TColStd_IndexedMapOfInteger anIds; - aSelector->GetIndex(anIO,anIds); - SALOME_Actor* anActor = aSelector->GetActor(anIO); - if( !anActor ) - anActor = Find(aView->getRenderer()->GetActors(),TIsSameIObject(anIO)); - - aList.append(new SalomeApp_SVTKDataOwner(anIO,anIds,aMode,anActor)); - if(MYDEBUG) MESSAGE("VTKSelector::getSelection - "<getEntry()); - } - } - } - } - } - } -} - -/*! - Sets selection to selector from data owner list \a theList. -*/ -void -SalomeApp_VTKSelector -::setSelection( const SUIT_DataOwnerPtrList& theList ) -{ - if(myViewer){ - if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){ - if(SVTK_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())){ - if(SVTK_Selector* aSelector = aView->GetSelector()){ - SALOME_ListIO anAppendList; - const SALOME_ListIO& aStoredList = aSelector->StoredIObjects(); - SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin(); - for(; anIter != theList.end(); ++anIter){ - const SUIT_DataOwner* aDataOwner = (*anIter).get(); - if(const SalomeApp_SVTKDataOwner* anOwner = dynamic_cast(aDataOwner)){ - aSelector->SetSelectionMode(anOwner->GetMode()); - Handle(SALOME_InteractiveObject) anIO = anOwner->IO(); - - if( anOwner->GetActor() ) - aSelector->AddIObject( anOwner->GetActor() ); - else - aSelector->AddIObject(anIO); - - anAppendList.Append(anIO); - aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false); - if(MYDEBUG) MESSAGE("VTKSelector::setSelection - SVTKDataOwner - "<getEntry()); - }else if(const SalomeApp_DataOwner* anOwner = dynamic_cast(aDataOwner)){ - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(anOwner->entry().latin1(),""); - aSelector->AddIObject(anIO); - anAppendList.Append(anIO); - if(MYDEBUG) MESSAGE("VTKSelector::setSelection - DataOwner - "<getEntry()); - } - } - // To remove IOs, which is not selected. - QMap< QString, Handle( SALOME_InteractiveObject )> toRemove; - SALOME_ListIteratorOfListIO anIt( aStoredList ); - for( ; anIt.More(); anIt.Next() ) - if( !anIt.Value().IsNull() ) - toRemove[ anIt.Value()->getEntry() ] = anIt.Value(); - - anIt = SALOME_ListIteratorOfListIO(anAppendList); - for( ; anIt.More(); anIt.Next() ) - toRemove.remove( anIt.Value()->getEntry() ); - - QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(), - REnd = toRemove.end(); - for( ; RIt!=REnd; RIt++ ) - aSelector->RemoveIObject( RIt.data() ); - - aView->onSelectionChanged(); - } - } - } - } -} diff --git a/src/SalomeApp/SalomeApp_VTKSelector.h b/src/SalomeApp/SalomeApp_VTKSelector.h deleted file mode 100644 index bb3123a8f..000000000 --- a/src/SalomeApp/SalomeApp_VTKSelector.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef SALOMEAPP_VTKSELECTOR_H -#define SALOMEAPP_VTKSELECTOR_H - -#include - -#include - -#include "SUIT_Selector.h" - -#include "SalomeApp.h" -#include "SalomeApp_DataOwner.h" - -#include "SVTK_Selection.h" -#include "SALOME_InteractiveObject.hxx" - -class SALOME_Actor; -class SVTK_ViewModelBase; - -/*! - Provide salome vtk data owner list. -*/ -class SalomeApp_SVTKDataOwner : public SalomeApp_DataOwner -{ - public: - SalomeApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_IndexedMapOfInteger& theIds, - Selection_Mode theMode = ActorSelection, - SALOME_Actor* theActor = NULL); - virtual ~SalomeApp_SVTKDataOwner(); - - /*!Gets dataowners ids list.*/ - const TColStd_IndexedMapOfInteger& GetIds() const - { - return myIds; - } - - /*!Gets selection mode.*/ - Selection_Mode GetMode() const - { - return mySelectionMode; - } - - SALOME_Actor* GetActor() const; - - protected: - TColStd_IndexedMapOfInteger myIds; - Selection_Mode mySelectionMode; - vtkSmartPointer myActor; -}; - - -/*! - Provide salome vtk selection of data owners. -*/ -class SALOMEAPP_EXPORT SalomeApp_VTKSelector : public SUIT_Selector -{ - Q_OBJECT; - -public: - SalomeApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* ); - virtual ~SalomeApp_VTKSelector(); - - SVTK_ViewModelBase* viewer() const; - - virtual QString type() const; - -private slots: - void onSelectionChanged(); - -protected: - virtual void getSelection( SUIT_DataOwnerPtrList& ) const; - virtual void setSelection( const SUIT_DataOwnerPtrList& ); - -private: - SVTK_ViewModelBase* myViewer; -}; - -#endif diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 43d993948..364b2fd5e 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -34,16 +34,19 @@ + + + @@ -52,6 +55,10 @@ +
+ + +
@@ -68,6 +75,10 @@
+
+ + +
@@ -100,6 +111,10 @@
+
+ + +
-- 2.39.2