From 29f6a6e3b38ac9d0dc417715c26d3a1c5fd99d3d Mon Sep 17 00:00:00 2001 From: srn Date: Thu, 26 Jan 2006 08:55:31 +0000 Subject: [PATCH] Added support of savePoints --- src/LightApp/LightApp_Module.cxx | 6 ++-- src/LightApp/LightApp_Module.h | 4 +-- src/SalomeApp/SalomeApp_Module.cxx | 4 +-- src/SalomeApp/SalomeApp_Module.h | 4 +-- src/SalomeApp/SalomeApp_Study.cxx | 58 +++++++++++++++++++++++++----- src/SalomeApp/SalomeApp_Study.h | 9 +++-- 6 files changed, 63 insertions(+), 22 deletions(-) diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index f6c316fc5..4d09dca2f 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -430,9 +430,7 @@ LightApp_Displayer* LightApp_Module::displayer() * This method is called just before the study document is saved, so the module has a possibility * to store visual parameters in AttributeParameter attribue(s) */ -void LightApp_Module::storeVisualParameters() { - cout << "LightApp_Module::storeVisualParameters" << endl; -} +void LightApp_Module::storeVisualParameters(int savePoint) {} /*! * \brief Virtual public @@ -440,7 +438,7 @@ void LightApp_Module::storeVisualParameters() { * This method is called after the study document is opened, so the module has a possibility to restore * visual parameters */ -void LightApp_Module::restoreVisualParameters() {} +void LightApp_Module::restoreVisualParameters(int savePoint) {} void LightApp_Module::onShowHide() diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 40785fd15..87c051a0f 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -66,8 +66,8 @@ public: virtual LightApp_Displayer* displayer(); - virtual void storeVisualParameters(); - virtual void restoreVisualParameters(); + virtual void storeVisualParameters(int savePoint); + virtual void restoreVisualParameters(int savePoint); public slots: virtual bool activateModule( SUIT_Study* ); diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 45e8c8c83..da70d2ea3 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -104,7 +104,7 @@ void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_Li * This method is called just before the study document is saved, so the module has a possibility * to store visual parameters in AttributeParameter attribue(s) */ -void SalomeApp_Module::storeVisualParameters() +void SalomeApp_Module::storeVisualParameters(int savePoint) { cout << "SalomeApp_Module::storeVisualParameters" << endl; } @@ -115,7 +115,7 @@ void SalomeApp_Module::storeVisualParameters() * This method is called after the study document is opened, so the module has a possibility to restore * visual parameters */ -void SalomeApp_Module::restoreVisualParameters() +void SalomeApp_Module::restoreVisualParameters(int savePoint) { cout << "SalomeApp_Module::restoreVisualParameters" << endl; } diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index e7bf899ff..7346e8537 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -39,8 +39,8 @@ public: SalomeApp_Application* getApp() const; - virtual void storeVisualParameters(); - virtual void restoreVisualParameters(); + virtual void storeVisualParameters(int savePoint); + virtual void restoreVisualParameters(int savePoint); protected: virtual CAM_DataModel* createDataModel(); diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index de4604621..5b772ce77 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -181,7 +181,7 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) emit opened( this ); study->IsSaved(true); - restoreViewers();//############### VISUAL PARAMETERS + restoreViewers(1);//############### VISUAL PARAMETERS return res; } @@ -231,7 +231,7 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) //======================================================================= bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { - storeViewers();//############### VISUAL PARAMETERS + storeViewers(1);//############### VISUAL PARAMETERS ModelList list; dataModels( list ); @@ -268,7 +268,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) //======================================================================= bool SalomeApp_Study::saveDocument() { - storeViewers(); //############### VISUAL PARAMETERS + storeViewers(1); //############### VISUAL PARAMETERS ModelList list; dataModels( list ); @@ -685,12 +685,42 @@ void SalomeApp_Study::components( QStringList& comps ) const } } +//================================================================ +// Function : getNbSavePoints +/*! Purpose : returns a number of saved points +*/ +//================================================================ +int SalomeApp_Study::getNbSavePoints() +{ + return 1; +} + +//================================================================ +// Function : getNameOfSavePoint +/*! Purpose : returns a name of save point +*/ +//================================================================ +QString SalomeApp_Study::getNameOfSavePoint(int savePoint) +{ + return "Default save point"; +} + +//================================================================ +// Function : setNameOfSavePoint +/*! Purpose : sets a name of save point +*/ +//================================================================ +void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint) +{ + +} + //================================================================ // Function : storeViewers /*! Purpose : store the visual parameters of the viewers */ //================================================================ -void SalomeApp_Study::storeViewers() +void SalomeApp_Study::storeViewers(int savePoint) { SUIT_ViewWindow* activeWindow = application()->desktop()->activeWindow(); @@ -734,7 +764,7 @@ void SalomeApp_Study::storeViewers() ((SalomeApp_Application*)application())->modules( list ); for(SalomeApp_Module* module = (SalomeApp_Module*)list.first(); module; module = (SalomeApp_Module*)list.next()) { container.addModule(module->moduleName()); - module->storeVisualParameters(); + module->storeVisualParameters(savePoint); } } @@ -743,9 +773,19 @@ void SalomeApp_Study::storeViewers() /*! Purpose : restore the visual parameters of the viewers */ //================================================================ -void SalomeApp_Study::restoreViewers() +void SalomeApp_Study::restoreViewers(int savePoint) { ViewerContainer container; + + //Remove all already existent veiwers and their views + ViewManagerList lst; + ((SalomeApp_Application*)application())->viewManagers(lst); + for(QPtrListIterator it(lst); it.current(); ++it) { + SUIT_ViewManager* vm = it.current(); + if(vm) ((SalomeApp_Application*)application())->removeViewManager(vm); + } + + //Restore the viewers int nbViewers = container.getNbViewers(); int activeViewID = container.getActiveViewID(); SUIT_ViewWindow *viewWin = 0, *activeView = 0; @@ -793,7 +833,7 @@ void SalomeApp_Study::restoreViewers() for(int i = 0; iactivateModule(v[i].c_str()); SalomeApp_Module* module = (SalomeApp_Module*)(((SalomeApp_Application*)application())->activeModule()); - module->restoreVisualParameters(); + module->restoreVisualParameters(savePoint); } QString activeModuleName = container.getActiveModule(); @@ -807,7 +847,7 @@ void SalomeApp_Study::restoreViewers() * parameters */ //================================================================ -_PTR(AttributeParameter) SalomeApp_Study::getViewerParameters() +_PTR(AttributeParameter) SalomeApp_Study::getViewerParameters(int savePoint) { _PTR(StudyBuilder) builder = studyDS()->NewBuilder(); _PTR(SObject) so = studyDS()->FindComponent("Interface Applicative"); @@ -841,7 +881,7 @@ ViewerContainer::ViewerContainer() SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if( !study ) return; - _ap = study->getViewerParameters(); + _ap = study->getViewerParameters(0); } int ViewerContainer::getNbViewers() diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index aca727f1d..1f27cbfa5 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -66,9 +66,12 @@ public: virtual void children( const QString&, QStringList& ) const; virtual void components( QStringList& ) const; - void storeViewers(); - void restoreViewers(); - _PTR(AttributeParameter) getViewerParameters(); + int getNbSavePoints(); + QString getNameOfSavePoint(int savePoint); + void setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint); + void storeViewers(int savePoint); + void restoreViewers(int savePoint); + _PTR(AttributeParameter) getViewerParameters(int savePoint); protected: virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); -- 2.39.2