emit opened( this );
study->IsSaved(true);
- restoreState(1);//############### VISUAL PARAMETERS
+ vector<int> savePoints = getSavePoints();
+ if(savePoints.size() > 0) restoreState(savePoints[savePoints.size()-1]);//############### VISUAL PARAMETERS
return res;
}
//=======================================================================
bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
{
- storeState(1);//############### VISUAL PARAMETERS
+ storeState();//############### VISUAL PARAMETERS
ModelList list; dataModels( list );
//=======================================================================
bool SalomeApp_Study::saveDocument()
{
- storeState(1); //############### VISUAL PARAMETERS
+ storeState(); //############### VISUAL PARAMETERS
ModelList list; dataModels( list );
}
//================================================================
-// Function : getNbSavePoints
-/*! Purpose : returns a number of saved points
+// Function : getSavePoints
+/*! Purpose : returns a list of saved points' IDs
*/
//================================================================
-int SalomeApp_Study::getNbSavePoints()
+vector<int> SalomeApp_Study::getSavePoints()
{
- int nbSavePoints = 0;
+ vector<int> v;
_PTR(SObject) so = studyDS()->FindComponent("Interface Applicative");
- if(!so) return 0;
+ if(!so) return v;
_PTR(StudyBuilder) builder = studyDS()->NewBuilder();
_PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( so ) );
{
_PTR(SObject) val( anIter->Value() );
_PTR(GenericAttribute) genAttr;
- if(builder->FindAttribute(val, genAttr, "AttributeParameter")) nbSavePoints++;
+ if(builder->FindAttribute(val, genAttr, "AttributeParameter")) v.push_back(val->Tag());
}
- return nbSavePoints;
+ return v;
}
//================================================================
/*! Purpose : store the visual parameters of the viewers
*/
//================================================================
-void SalomeApp_Study::storeState(int savePoint)
+int SalomeApp_Study::storeState()
{
- SUIT_ViewWindow* activeWindow = application()->desktop()->activeWindow();
+ SUIT_ViewWindow* activeWindow = 0;
+ if(application()->desktop()) activeWindow = application()->desktop()->activeWindow();
+
+ int savePoint = 1;
+ vector<int> savePoints = getSavePoints();
+ //Calculate a new savePoint number = the last save point number + 1
+ if(savePoints.size() > 0) savePoint = savePoints[savePoints.size()-1] + 1;
//Remove the previous content of the attribute
ViewerContainer container(savePoint);
container.addModule(module->moduleName());
module->storeVisualParameters(savePoint);
}
+
+ return savePoint;
}
//================================================================
}
//================================================================
-// Function : getViewerParameters
-/*! Purpose : Return an attribute that stores the viewers'
- * parameters
+// Function : getStateParameters
+/*! Purpose : Return an attribute that stores the saved state parameters
*/
//================================================================
-_PTR(AttributeParameter) SalomeApp_Study::getViewerParameters(int savePoint)
+_PTR(AttributeParameter) SalomeApp_Study::getStateParameters(int savePoint)
{
_PTR(StudyBuilder) builder = studyDS()->NewBuilder();
_PTR(SObject) so = studyDS()->FindComponent("Interface Applicative");
virtual void children( const QString&, QStringList& ) const;
virtual void components( QStringList& ) const;
- int getNbSavePoints();
+ std::vector<int> getSavePoints();
QString getNameOfSavePoint(int savePoint);
void setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint);
- void storeState(int savePoint);
+ int storeState();
void restoreState(int savePoint);
- _PTR(AttributeParameter) getViewerParameters(int savePoint);
+ _PTR(AttributeParameter) getStateParameters(int savePoint);
protected:
virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );
/*!
Constructor
*/
-SalomeApp_VisualParameters::SalomeApp_VisualParameters(const _PTR(SComponent)& sco, const int savePoint)
+SalomeApp_VisualParameters::SalomeApp_VisualParameters(const string& moduleName, const int savePoint)
{
+ /*
if(!sco) return;
_PTR(Study) study = sco->GetStudy();
_PTR(StudyBuilder) builder = study->NewBuilder();
_PTR(SObject) so = builder->NewObjectToTag(sco, savePoint);
_ap = builder->FindOrCreateAttribute(so, "AttributeParameter");
+ */
}
/*!
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if( !study ) return;
- _ap = study->getViewerParameters(savePoint);
+ _ap = study->getStateParameters(savePoint);
}
int ViewerContainer::getNbViewers()