From 9fd32ae78ed5d55fc13e9c9e0e53fff12d1abd93 Mon Sep 17 00:00:00 2001 From: asv Date: Wed, 1 Mar 2006 13:05:31 +0000 Subject: [PATCH] store/restore visual parameters functionality was moved to SalomeApp_VisualState class. --- src/SalomeApp/Makefile.in | 6 +- src/SalomeApp/SalomeApp_Application.cxx | 3 +- src/SalomeApp/SalomeApp_Study.cxx | 260 ++------------------- src/SalomeApp/SalomeApp_Study.h | 2 - src/SalomeApp/SalomeApp_VisualState.cxx | 291 ++++++++++++++++++++++++ src/SalomeApp/SalomeApp_VisualState.h | 47 ++++ 6 files changed, 357 insertions(+), 252 deletions(-) create mode 100644 src/SalomeApp/SalomeApp_VisualState.cxx create mode 100644 src/SalomeApp/SalomeApp_VisualState.h diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index 308e5126b..cc8511597 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -25,7 +25,8 @@ EXPORT_HEADERS= SalomeApp.h \ SalomeApp_Filter.h \ SalomeApp_TypeFilter.h \ SalomeApp_StudyPropertiesDlg.h \ - SalomeApp_CheckFileDlg.h + SalomeApp_CheckFileDlg.h \ + SalomeApp_VisualState.h # .po files to transform in .qm PO_FILES = SalomeApp_images.po \ @@ -48,7 +49,8 @@ LIB_SRC= SalomeApp_Module.cxx \ SalomeApp_TypeFilter.cxx \ SalomeApp_StudyPropertiesDlg.cxx \ SalomeApp_ListView.cxx \ - SalomeApp_CheckFileDlg.cxx + SalomeApp_CheckFileDlg.cxx \ + SalomeApp_VisualState.cxx LIB_MOC = SalomeApp_Application.h \ SalomeApp_DataModel.h \ diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index a390e4913..3baab9935 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -11,6 +11,7 @@ #include "SalomeApp_DataModel.h" #include "SalomeApp_DataObject.h" #include "SalomeApp_EventFilter.h" +#include "SalomeApp_VisualState.h" #include "SalomeApp_StudyPropertiesDlg.h" @@ -516,7 +517,7 @@ void SalomeApp_Application::onDumpStudy( ) int savePoint; if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method SALOMEDS_IParameters::setDumpPython(appStudy->studyDS()); - savePoint = appStudy->storeState(); //SRN: create a temporary save point + savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point //prefix = SALOMEDS_IParameters::getStudyScript(appStudy->studyDS(), appStudy->getVisualComponentName(), savePoint); } diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 66c882284..667654e83 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -23,15 +23,12 @@ #include "SalomeApp_DataObject.h" #include "SalomeApp_Application.h" #include "SalomeApp_Engine_i.hxx" +#include "SalomeApp_VisualState.h" #include "LightApp_RootObject.h" #include -#include - -#include - #include #include @@ -144,8 +141,10 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) emit opened( this ); study->IsSaved(true); - vector savePoints = getSavePoints(); - if(savePoints.size() > 0) restoreState(savePoints[savePoints.size()-1]);//############### VISUAL PARAMETERS + std::vector savePoints = getSavePoints(); + if ( savePoints.size() > 0 ) //############### VISUAL PARAMETERS + SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] ); + return res; } @@ -195,8 +194,9 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) //======================================================================= bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { - storeState();//############### VISUAL PARAMETERS - + //############### VISUAL PARAMETERS + SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); + ModelList list; dataModels( list ); SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); @@ -233,7 +233,8 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) //======================================================================= bool SalomeApp_Study::saveDocument() { - storeState(); //############### VISUAL PARAMETERS + //############### VISUAL PARAMETERS + SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); ModelList list; dataModels( list ); @@ -656,9 +657,9 @@ void SalomeApp_Study::components( QStringList& comps ) const /*! Purpose : returns a list of saved points' IDs */ //================================================================ -vector SalomeApp_Study::getSavePoints() +std::vector SalomeApp_Study::getSavePoints() { - vector v; + std::vector v; _PTR(SObject) so = studyDS()->FindComponent("Interface Applicative"); if(!so) return v; @@ -719,243 +720,8 @@ void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSav * parameters are stored */ //================================================================ -string SalomeApp_Study::getVisualComponentName() +std::string SalomeApp_Study::getVisualComponentName() { return "Interface Applicative"; } -//================================================================ -// Function : nameViewWindows -/*! Purpose : set names of all view windows in given list. This is used -// in order to apply the same naming algorithm when saving and restoring -// view windows. Names of view windows must be the same before saving -// workstack (splitters) information, and before its restoring! -// Naming rule: ViewerType_IndexOfViewerOfThisType_IndexOfViewInThisViewer -// VTKViewer_0_0 -// OCCViewer_0_0 OCCViewer_0_1 OCCViewer_0_2 -// VTKViewer_1_0 -*/ -//================================================================ -void nameViewWindows( const ViewManagerList& lst ) -{ - QDict viewersCounter; // map viewerType - to - index_of_this_viewer_type - viewersCounter.setAutoDelete( true ); - for ( QPtrListIterator it(lst); it.current(); ++it) { - int view_count = it.current()->getViewsCount(); - QString vType = it.current()->getType(); - if ( !view_count ) - continue; //No views is opened in the viewer - - int* viewerID = viewersCounter[ vType ]; - if ( !viewerID ) { - viewerID = new int( 0 ); - viewersCounter.insert( vType, viewerID ); - } - else - ++(*viewerID); - - QPtrVector views = it.current()->getViews(); - for ( int i = 0; i < view_count; i++ ) { - QString vName = QString( "%1_%2_%3" ).arg( vType ).arg( *viewerID ).arg( i ); - views[i]->setName( vName ); - } - } -} - -//================================================================ -// Function : storeState -/*! Purpose : store the visual parameters of the viewers -*/ -//================================================================ -int SalomeApp_Study::storeState() -{ - int savePoint = 1; - vector savePoints = getSavePoints(); - //Calculate a new savePoint number = the last save point number + 1 - if(savePoints.size() > 0) savePoint = savePoints[savePoints.size()-1] + 1; - - _PTR(AttributeParameter) ap = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint); - SALOMEDS_IParameters ip(ap); - - int viewerID = 0; - SUIT_ViewManager* vm = 0; - ViewManagerList lst; - ((SalomeApp_Application*)application())->viewManagers(lst); - - // setting unique names for view windows in order to save this view inside - // workstack's structure (see below). On restore the views with the same names will - // be placed to the same place inside the workstack's splitters. - nameViewWindows( lst ); - - // store active window's name - if ( application()->desktop()->activeWindow() ) - ip.setProperty("AP_ACTIVE_VIEW", application()->desktop()->activeWindow()->name() ); - - for(QPtrListIterator it(lst); it.current(); ++it) { - vm = it.current(); - int view_count = vm->getViewsCount(); - if ( !view_count ) - continue; //No views is opened in the viewer - - std::string viewerEntry = QString( "%1_%2" ).arg( vm->getType() ).arg( ++viewerID ).latin1(); - ip.append("AP_VIEWERS_LIST", viewerEntry); - - QPtrVector views = vm->getViews(); - for(int i = 0; icaption() ); - ip.append( viewerEntry, views[i]->getVisualParameters().latin1() ); - } - } - - //Save information about split areas - if ( application()->desktop()->inherits( "STD_TabDesktop" ) ) { - QtxWorkstack* workstack = ((STD_TabDesktop*)application()->desktop())->workstack(); - QString workstackInfo; - (*workstack) >> workstackInfo; - ip.setProperty( "AP_WORKSTACK_INFO", workstackInfo.latin1() ); - } - - //Save a name of the active module - CAM_Module* activeModule = ((SalomeApp_Application*)application())->activeModule(); - QString moduleName = ""; - if(activeModule) { - moduleName = activeModule->moduleName(); - ip.setProperty("AP_ACTIVE_MODULE", moduleName.latin1()); - } - - //Store visual parameters of the modules - QPtrList list; - ((SalomeApp_Application*)application())->modules( list ); - for(SalomeApp_Module* module = (SalomeApp_Module*)list.first(); module; module = (SalomeApp_Module*)list.next()) { - ip.append("AP_MODULES_LIST", module->moduleName().latin1()); - module->storeVisualParameters(savePoint); - } - - return savePoint; -} - -//================================================================ -// Function : restoreState -/*! Purpose : restore the visual parameters of the viewers -*/ -//================================================================ -void SalomeApp_Study::restoreState(int savePoint) -{ - _PTR(AttributeParameter) ap = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint); - SALOMEDS_IParameters ip(ap); - - //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 and view windows - int nbViewers = ip.nbValues("AP_VIEWERS_LIST"); - SUIT_ViewWindow *viewWin = 0; - - for (int i = 0; i < nbViewers; i++) { - string viewerEntry = ip.getValue("AP_VIEWERS_LIST", i); - vector veiewerParams = ip.parseValue(viewerEntry,'_'); - string type = veiewerParams[0]; - string viewerID = veiewerParams[1]; - SUIT_ViewManager* vm = ((SalomeApp_Application*)application())->newViewManager(type.c_str()); - if (!vm) - continue; //Unknown viewer - - int nbViews = (ip.nbValues(viewerEntry))/2; - - //Create nbViews-1 view (-1 because 1 view is created by createViewManager) - for ( int i = 1; i< nbViews; i++ ) { - SUIT_ViewWindow* aView = vm->createViewWindow(); - aView->show(); - } - - int viewCount = vm->getViewsCount(); - if (viewCount != nbViews) { - cout << "Unknow error, Can't create a view!" << endl; - continue; - } - - //Resize the views, set their captions and apply visual parameters. - QPtrVector views = vm->getViews(); - for (int i = 0, j = 0; iisVisible() ) - qApp->processEvents(); - - viewWin->setCaption(ip.getValue(viewerEntry, j).c_str()); - viewWin->setVisualParameters(ip.getValue(viewerEntry, j+1).c_str()); - } - } - - // restore modules' visual parameters - vector v = ip.getValues("AP_MODULES_LIST"); - for (int i = 0; iactivateModule(v[i].c_str()); - SalomeApp_Module* module = (SalomeApp_Module*)(((SalomeApp_Application*)application())->activeModule()); - module->restoreVisualParameters(savePoint); - } - - // activate module that was active on save - QString activeModuleName(ip.getProperty("AP_ACTIVE_MODULE").c_str()); - if (activeModuleName != "") - ((SalomeApp_Application*)application())->activateModule(activeModuleName); - - // setting unique names for view windows in order to restore positions of view windows inside - // workstack's structure (see below). During save the same naming algorithm was used, - // so the same views will get the same names. - lst.clear(); - ((SalomeApp_Application*)application())->viewManagers(lst); - nameViewWindows( lst ); - - // work-around to bug of setting visual parameters of views: all view windows now have - // correct visual parameters, bug after restoring the workstack the visual parameters - // are messted, and must be re-set again. So here we store them in a map and set them - // later back again. why we don't store these parameters in a map on views creation? - // because 1) names of view windows are not set at that time 2) some view windows - // are created by modules' restoreVisualParameters (like Gauss Viewers), which is NOT here.. - QMap viewersParameters; - QPtrListIterator it( lst ); - for ( ; it.current(); ++it ) { - int view_count = it.current()->getViewsCount(); - QPtrVector views = it.current()->getViews(); - for ( int i = 0; i < view_count; i++ ) - viewersParameters[ views[i]->name() ] = views[i]->getVisualParameters(); - } - - // restore workstack parameters. should be done after module's restoreVisualParameters(), because - // some modules can create their own viewers (like VISU creates GaussViewers) - if ( application()->desktop()->inherits( "STD_TabDesktop" ) ) { - QtxWorkstack* workstack = ((STD_TabDesktop*)application()->desktop())->workstack(); - (*workstack) << ip.getProperty( "AP_WORKSTACK_INFO" ).c_str(); - } - - // restore visual parameters of view windows. it must be done AFTER restoring workstack. - for ( it.toFirst(); it.current(); ++it ) { - int view_count = it.current()->getViewsCount(); - QPtrVector views = it.current()->getViews(); - for ( int i = 0; i < view_count; i++ ) - views[i]->setVisualParameters( viewersParameters[ views[i]->name() ] ); - } - - // set focus to previously saved active view window - /* - string activeViewName = ip.getProperty("AP_ACTIVE_VIEW"); - for ( it.toFirst(); it.current(); ++it ) { - int view_count = it.current()->getViewsCount(); - QPtrVector views = it.current()->getViews(); - for ( int i = 0; i < view_count; i++ ) { - if ( activeViewName == views[i]->name() ) - views[i]->setFocus(); - } - } - */ -} diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index 5bf29864d..b3edd2564 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -71,8 +71,6 @@ public: void removeSavePoint(int savePoint); QString getNameOfSavePoint(int savePoint); void setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint); - virtual int storeState(); - virtual void restoreState(int savePoint); virtual std::string getVisualComponentName(); protected: diff --git a/src/SalomeApp/SalomeApp_VisualState.cxx b/src/SalomeApp/SalomeApp_VisualState.cxx new file mode 100644 index 000000000..937a3e98e --- /dev/null +++ b/src/SalomeApp/SalomeApp_VisualState.cxx @@ -0,0 +1,291 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// +#include "SalomeApp_VisualState.h" + +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" + +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +/*! + Constructor. +*/ +SalomeApp_VisualState::SalomeApp_VisualState( SalomeApp_Application* app ) + : myApp( app ) +{ +} + +/*! + Destructor. +*/ +SalomeApp_VisualState::~SalomeApp_VisualState() +{ +} + +//================================================================ +// Function : nameViewWindows +/*! Purpose : set names of all view windows in given list. This is used +// in order to apply the same naming algorithm when saving and restoring +// view windows. Names of view windows must be the same before saving +// workstack (splitters) information, and before its restoring! +// Naming rule: ViewerType_IndexOfViewerOfThisType_IndexOfViewInThisViewer +// VTKViewer_0_0 +// OCCViewer_0_0 OCCViewer_0_1 OCCViewer_0_2 +// VTKViewer_1_0 +*/ +//================================================================ +void nameViewWindows( const ViewManagerList& lst ) +{ + QDict viewersCounter; // map viewerType - to - index_of_this_viewer_type + viewersCounter.setAutoDelete( true ); + for ( QPtrListIterator it(lst); it.current(); ++it) { + int view_count = it.current()->getViewsCount(); + QString vType = it.current()->getType(); + if ( !view_count ) + continue; //No views is opened in the viewer + + int* viewerID = viewersCounter[ vType ]; + if ( !viewerID ) { + viewerID = new int( 0 ); + viewersCounter.insert( vType, viewerID ); + } + else + ++(*viewerID); + + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) { + QString vName = QString( "%1_%2_%3" ).arg( vType ).arg( *viewerID ).arg( i ); + views[i]->setName( vName ); + } + } +} + +//================================================================ +// Function : storeState +/*! Purpose : store the visual parameters of the viewers +*/ +//================================================================ +int SalomeApp_VisualState::storeState() +{ + SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + if ( !study ) + return -1; + + int savePoint = 1; + std::vector savePoints = study->getSavePoints(); + //Calculate a new savePoint number = the last save point number + 1 + if ( savePoints.size() > 0) + savePoint = savePoints[savePoints.size()-1] + 1; + + _PTR(AttributeParameter) ap = study->studyDS()->GetCommonParameters( study->getVisualComponentName(), savePoint ); + SALOMEDS_IParameters ip( ap ); + + ViewManagerList lst; + myApp->viewManagers( lst ); + + // setting unique names for view windows in order to save this view inside + // workstack's structure (see below). On restore the views with the same names will + // be placed to the same place inside the workstack's splitters. + nameViewWindows( lst ); + + // store active window's name + SUIT_ViewWindow* win = myApp->desktop()->activeWindow(); + if ( win ) + ip.setProperty("AP_ACTIVE_VIEW", win->name() ); + + int viewerID = 0; + SUIT_ViewManager* vm = 0; + for (QPtrListIterator it( lst ); it.current(); ++it ) { + vm = it.current(); + int view_count = vm->getViewsCount(); + if ( !view_count ) + continue; //No views is opened in the viewer + + std::string viewerEntry = QString( "%1_%2" ).arg( vm->getType() ).arg( ++viewerID ).latin1(); + ip.append("AP_VIEWERS_LIST", viewerEntry); + + QPtrVector views = vm->getViews(); + for(int i = 0; icaption() ); + ip.append( viewerEntry, views[i]->getVisualParameters().latin1() ); + } + } + + //Save information about split areas + if ( myApp->desktop()->inherits( "STD_TabDesktop" ) ) { + QtxWorkstack* workstack = ((STD_TabDesktop*)myApp->desktop())->workstack(); + QString workstackInfo; + (*workstack) >> workstackInfo; + ip.setProperty( "AP_WORKSTACK_INFO", workstackInfo.latin1() ); + } + + //Save a name of the active module + if ( CAM_Module* activeModule = myApp->activeModule() ) + ip.setProperty( "AP_ACTIVE_MODULE", activeModule->moduleName().latin1() ); + + //Store visual parameters of the modules + QPtrList mlist; + myApp->modules( mlist ); + CAM_Module* module = 0; + for ( module = mlist.first(); module; module = mlist.next() ) { + if ( SalomeApp_Module* sModule = dynamic_cast( module ) ) { + ip.append( "AP_MODULES_LIST", sModule->moduleName().latin1() ); + sModule->storeVisualParameters( savePoint ); + } + } + + return savePoint; +} + +//================================================================ +// Function : restoreState +/*! Purpose : restore the visual parameters of the viewers +*/ +//================================================================ +void SalomeApp_VisualState::restoreState(int savePoint) +{ + SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + if ( !study ) + return; + + _PTR(AttributeParameter) ap = study->studyDS()->GetCommonParameters( study->getVisualComponentName(), savePoint ); + SALOMEDS_IParameters ip(ap); + + //Remove all already existent veiwers and their views + ViewManagerList lst; + myApp->viewManagers( lst ); + for ( QPtrListIterator it(lst); it.current(); ++it ) + myApp->removeViewManager( it.current() ); + + //Restore the viewers and view windows + int nbViewers = ip.nbValues( "AP_VIEWERS_LIST" ); + SUIT_ViewWindow* viewWin = 0; + + for ( int i = 0; i < nbViewers; i++ ) { + std::string viewerEntry = ip.getValue( "AP_VIEWERS_LIST", i ); + std::vector veiewerParams = ip.parseValue(viewerEntry,'_'); + std::string type = veiewerParams[0]; + std::string viewerID = veiewerParams[1]; + SUIT_ViewManager* vm = myApp->newViewManager( type.c_str() ); + if ( !vm ) + continue; //Unknown viewer + + int nbViews = (ip.nbValues(viewerEntry))/2; + + //Create nbViews-1 view (-1 because 1 view is created by createViewManager) + for ( int i = 1; i< nbViews; i++ ) { + SUIT_ViewWindow* aView = vm->createViewWindow(); + aView->show(); + } + + int viewCount = vm->getViewsCount(); + if (viewCount != nbViews) { + printf( "\nRestore visual state: Unknow error, Can't create a view!\n" ); + continue; + } + + //Resize the views, set their captions and apply visual parameters. + QPtrVector views = vm->getViews(); + for (int i = 0, j = 0; iisVisible() ) + qApp->processEvents(); + + viewWin->setCaption(ip.getValue(viewerEntry, j).c_str()); + viewWin->setVisualParameters(ip.getValue(viewerEntry, j+1).c_str()); + } + } + + // restore modules' visual parameters + std::vector v = ip.getValues("AP_MODULES_LIST"); + for ( int i = 0; i < v.size(); i++ ) { + myApp->activateModule( v[i].c_str() ); + if ( SalomeApp_Module* module = dynamic_cast( myApp->activeModule() ) ) + module->restoreVisualParameters( savePoint ); + } + + // activate module that was active on save + QString activeModuleName( ip.getProperty("AP_ACTIVE_MODULE" ).c_str() ); + if ( !activeModuleName.isEmpty() ) + myApp->activateModule( activeModuleName ); + + // setting unique names for view windows in order to restore positions of view windows inside + // workstack's structure (see below). During save the same naming algorithm was used, + // so the same views will get the same names. + lst.clear(); + myApp->viewManagers(lst); + nameViewWindows( lst ); + + // work-around to bug of setting visual parameters of views: all view windows now have + // correct visual parameters, bug after restoring the workstack the visual parameters + // are messted, and must be re-set again. So here we store them in a map and set them + // later back again. why we don't store these parameters in a map on views creation? + // because 1) names of view windows are not set at that time 2) some view windows + // are created by modules' restoreVisualParameters (like Gauss Viewers), which is NOT here.. + QMap viewersParameters; + QPtrListIterator it( lst ); + for ( ; it.current(); ++it ) { + int view_count = it.current()->getViewsCount(); + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) + viewersParameters[ views[i]->name() ] = views[i]->getVisualParameters(); + } + + // restore workstack parameters. should be done after module's restoreVisualParameters(), because + // some modules can create their own viewers (like VISU creates GaussViewers) + if ( myApp->desktop()->inherits( "STD_TabDesktop" ) ) { + QtxWorkstack* workstack = ((STD_TabDesktop*)myApp->desktop())->workstack(); + (*workstack) << ip.getProperty( "AP_WORKSTACK_INFO" ).c_str(); + } + + // restore visual parameters of view windows. it must be done AFTER restoring workstack. + for ( it.toFirst(); it.current(); ++it ) { + int view_count = it.current()->getViewsCount(); + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) + views[i]->setVisualParameters( viewersParameters[ views[i]->name() ] ); + } + + // set focus to previously saved active view window + std::string activeViewName = ip.getProperty("AP_ACTIVE_VIEW"); + for ( it.toFirst(); it.current(); ++it ) { + int view_count = it.current()->getViewsCount(); + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) { + if ( activeViewName == views[i]->name() ) + views[i]->setFocus(); + } + } +} diff --git a/src/SalomeApp/SalomeApp_VisualState.h b/src/SalomeApp/SalomeApp_VisualState.h new file mode 100644 index 000000000..aa96a8383 --- /dev/null +++ b/src/SalomeApp/SalomeApp_VisualState.h @@ -0,0 +1,47 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// +#ifndef SALOMEAPP_VISUALSTATE_H +#define SALOMEAPP_VISUALSTATE_H + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +#include "SalomeApp.h" + +class SalomeApp_Application; + +class SALOMEAPP_EXPORT SalomeApp_VisualState +{ +public: + SalomeApp_VisualState( SalomeApp_Application* ); + virtual ~SalomeApp_VisualState(); + + virtual int storeState(); + virtual void restoreState( int savePoint ); + +protected: + SalomeApp_Application* myApp; +}; + +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif + +#endif -- 2.39.2