From: asv Date: Wed, 1 Mar 2006 11:33:01 +0000 (+0000) Subject: bugs in restoring workstack are fixed. Delayed size setting implemented, etc. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3be0b722a612871f7467749e66b10e126b61ca25;p=modules%2Fgui.git bugs in restoring workstack are fixed. Delayed size setting implemented, etc. --- diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index c5e8064c0..a390e4913 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -14,8 +14,6 @@ #include "SalomeApp_StudyPropertiesDlg.h" -#include "SalomeApp_CheckFileDlg.h" - #include "LightApp_Application.h" #include "LightApp_Preferences.h" #include "LightApp_WidgetContainer.h" @@ -48,6 +46,9 @@ #include #include #include +#include +#include +#include #include "SALOMEDS_StudyManager.hxx" #include "SALOMEDS_SObject.hxx" @@ -468,6 +469,27 @@ void SalomeApp_Application::updateCommandsStatus() onSelectionChanged(); } +/* + Class : DumpStudyFileDlg + Description : Private class used in Dump Study operation. Consists 2 check boxes: + "Publish in study" and "Save GUI parameters" +*/ +class DumpStudyFileDlg : public SUIT_FileDlg +{ +public: + DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true ) + { + QHBox* hB = new QHBox( this ); + myPublishChk = new QCheckBox( tr("PUBLISH_IN_STUDY"), hB ); + mySaveGUIChk = new QCheckBox( tr("SAVE_GUI_STATE"), hB ); + QPushButton* pb = new QPushButton(this); + addWidgets( new QLabel("", this), hB, pb ); + pb->hide(); + } + QCheckBox* myPublishChk; + QCheckBox* mySaveGUIChk; +}; + /*!Private SLOT. On dump study.*/ void SalomeApp_Application::onDumpStudy( ) { @@ -478,32 +500,34 @@ void SalomeApp_Application::onDumpStudy( ) QStringList aFilters; aFilters.append( tr( "PYTHON_FILES_FILTER" ) ); - SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true); + DumpStudyFileDlg* fd = new DumpStudyFileDlg( desktop() ); fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); fd->setFilters( aFilters ); - fd->SetChecked(true); + fd->myPublishChk->setChecked( true ); + fd->mySaveGUIChk->setChecked( true ); fd->exec(); QString aFileName = fd->selectedFile(); - bool toPublish = fd->IsChecked(); + bool toPublish = fd->myPublishChk->isChecked(); + bool toSaveGUI = fd->mySaveGUIChk->isChecked(); delete fd; - if(!aFileName.isEmpty()) { + if ( !aFileName.isEmpty() ) { QFileInfo aFileInfo(aFileName); - bool isDumpVisualParameters = true; int savePoint; - if(isDumpVisualParameters) { //SRN: Store a visual state of the study at the save point for DumpStudy method + 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 //prefix = SALOMEDS_IParameters::getStudyScript(appStudy->studyDS(), appStudy->getVisualComponentName(), savePoint); } bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish); - if(isDumpVisualParameters) appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point. + if ( toSaveGUI ) + appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point. if ( !res ) - SUIT_MessageBox::warn1 ( desktop(), - QObject::tr("WRN_WARNING"), - tr("WRN_DUMP_STUDY_FAILED"), - QObject::tr("BUT_OK") ); + SUIT_MessageBox::warn1 ( desktop(), + QObject::tr("WRN_WARNING"), + tr("WRN_DUMP_STUDY_FAILED"), + QObject::tr("BUT_OK") ); } } diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index a1b760957..66c882284 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -802,7 +802,7 @@ int SalomeApp_Study::storeState() QPtrVector views = vm->getViews(); for(int i = 0; icaption()); + ip.append( viewerEntry, views[i]->caption() ); ip.append( viewerEntry, views[i]->getVisualParameters().latin1() ); } } @@ -853,7 +853,7 @@ void SalomeApp_Study::restoreState(int savePoint) ((SalomeApp_Application*)application())->removeViewManager(vm); } - //Restore the viewers + //Restore the viewers and view windows int nbViewers = ip.nbValues("AP_VIEWERS_LIST"); SUIT_ViewWindow *viewWin = 0; @@ -896,6 +896,7 @@ void SalomeApp_Study::restoreState(int savePoint) } } + // restore modules' visual parameters vector v = ip.getValues("AP_MODULES_LIST"); for (int i = 0; iactivateModule(v[i].c_str()); @@ -903,9 +904,10 @@ void SalomeApp_Study::restoreState(int savePoint) 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); + ((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, @@ -914,6 +916,21 @@ void SalomeApp_Study::restoreState(int savePoint) ((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" ) ) { @@ -921,9 +938,18 @@ void SalomeApp_Study::restoreState(int savePoint) (*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 ( QPtrListIterator it(lst); it.current(); ++it) { + 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++ ) { @@ -931,4 +957,5 @@ void SalomeApp_Study::restoreState(int savePoint) views[i]->setFocus(); } } + */ } diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index a739779d2..9be7820a0 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -104,6 +104,14 @@ msgstr "Delete Invalid Reference" //======================================================================================= +msgid "PUBLISH_IN_STUDY" +msgstr "Publish in study" + +msgid "SAVE_GUI_STATE" +msgstr "Store current GUI state" + +//======================================================================================= + msgid "SalomeApp_Application::MEN_WINDOWS_NEW" msgstr "New window"