#include "SalomeApp_StudyPropertiesDlg.h"
-#include "SalomeApp_CheckFileDlg.h"
-
#include "LightApp_Application.h"
#include "LightApp_Preferences.h"
#include "LightApp_WidgetContainer.h"
#include <qcombobox.h>
#include <qlistbox.h>
#include <qregexp.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
#include "SALOMEDS_StudyManager.hxx"
#include "SALOMEDS_SObject.hxx"
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( )
{
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") );
}
}
QPtrVector<SUIT_ViewWindow> views = vm->getViews();
for(int i = 0; i<view_count; i++) {
- ip.append(viewerEntry, views[i]->caption());
+ ip.append( viewerEntry, views[i]->caption() );
ip.append( viewerEntry, views[i]->getVisualParameters().latin1() );
}
}
((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;
}
}
+ // restore modules' visual parameters
vector<string> v = ip.getValues("AP_MODULES_LIST");
for (int i = 0; i<v.size(); i++) {
((SalomeApp_Application*)application())->activateModule(v[i].c_str());
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,
((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<QString, QString> viewersParameters;
+ QPtrListIterator<SUIT_ViewManager> it( lst );
+ for ( ; it.current(); ++it ) {
+ int view_count = it.current()->getViewsCount();
+ QPtrVector<SUIT_ViewWindow> 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" ) ) {
(*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<SUIT_ViewWindow> 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<SUIT_ViewManager> it(lst); it.current(); ++it) {
+ for ( it.toFirst(); it.current(); ++it ) {
int view_count = it.current()->getViewsCount();
QPtrVector<SUIT_ViewWindow> views = it.current()->getViews();
for ( int i = 0; i < view_count; i++ ) {
views[i]->setFocus();
}
}
+ */
}
//=======================================================================================
+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"