+// 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_Study.h"
#include "SalomeApp_Module.h"
#include "SalomeApp_DataObject.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Engine_i.hxx"
+#include "SalomeApp_VisualState.h"
#include "LightApp_RootObject.h"
#include <SUIT_ResourceMgr.h>
#include <qptrlist.h>
+#include <qapplication.h>
+#include <qdict.h>
#include "utilities.h"
-#include "string.h"
-#include "vector.h"
+#include <iostream.h>
+#include <string>
+#include <vector>
+
+#include <SUIT_Session.h>
#include "SALOMEDS_Tool.hxx"
+#include "SALOMEDS_IParameters.hxx"
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Exception)
+using namespace std;
+
/*!
Constructor.
*/
emit opened( this );
study->IsSaved(true);
+
+ bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
+ if ( restore ) {
+ std::vector<int> savePoints = getSavePoints();
+ if ( savePoints.size() > 0 )
+ SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] );
+ }
+
return res;
}
bool res = CAM_Study::openDocument( theStudyName );
emit opened( this );
+ bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
+ if ( restore ) {
+ std::vector<int> savePoints = getSavePoints();
+ if ( savePoints.size() > 0 )
+ SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] );
+ }
+
//SRN: BugID IPAL9021: End
return res;
//=======================================================================
bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
{
+ bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
+ if ( store )
+ SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
+
ModelList list; dataModels( list );
SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first();
return false;
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ),
- isAscii = resMgr->booleanValue( "Study", "ascii_file", true );
- isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile );
+ isAscii = resMgr->booleanValue( "Study", "ascii_file", false ),
+ res = isAscii ?
+ SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) :
+ SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile ) &&
+ CAM_Study::saveDocumentAs( theFileName ) && //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
+ saveStudyData(theFileName);
- bool res = CAM_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
- res = res && saveStudyData(theFileName);
if ( res )
emit saved( this );
//=======================================================================
bool SalomeApp_Study::saveDocument()
{
+ bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
+ if ( store )
+ SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
+
ModelList list; dataModels( list );
SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first();
for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) {
listOfFiles.clear();
aModel->save(listOfFiles);
- if ( !listOfFiles.isEmpty() )
+ if ( !listOfFiles.isEmpty() )
saveModuleData(aModel->module()->name(), listOfFiles);
}
return false;
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ),
- isAscii = resMgr->booleanValue( "Study", "ascii_file", true );
- isAscii ? SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile );
-
- bool res = CAM_Study::saveDocument();
+ isAscii = resMgr->booleanValue( "Study", "ascii_file", false ),
+ res = isAscii ?
+ SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) :
+ SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile ) && CAM_Study::saveDocument();
res = res && saveStudyData(studyName());
if ( res )
}
// Set default engine IOR
aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1());
- SalomeApp_DataModel::BuildTree( aComp, root(), this, /*skipExisitng=*/true );
+ //SalomeApp_DataModel::BuildTree( aComp, root(), this, /*skipExisitng=*/true );
+ SalomeApp_DataModel::synchronize( aComp, this );
}
}
}
comps.append( aComponent->ComponentDataType().c_str() );
}
}
+
+//================================================================
+// Function : getSavePoints
+/*! Purpose : returns a list of saved points' IDs
+*/
+//================================================================
+std::vector<int> SalomeApp_Study::getSavePoints()
+{
+ std::vector<int> v;
+
+ _PTR(SObject) so = studyDS()->FindComponent("Interface Applicative");
+ if(!so) return v;
+
+ _PTR(StudyBuilder) builder = studyDS()->NewBuilder();
+ _PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( so ) );
+ for(; anIter->More(); anIter->Next())
+ {
+ _PTR(SObject) val( anIter->Value() );
+ _PTR(GenericAttribute) genAttr;
+ if(builder->FindAttribute(val, genAttr, "AttributeParameter")) v.push_back(val->Tag());
+ }
+
+ return v;
+}
+
+//================================================================
+// Function :removeSavePoint
+/*! Purpose : remove a given save point
+*/
+//================================================================
+void SalomeApp_Study::removeSavePoint(int savePoint)
+{
+ if(savePoint <= 0) return;
+ _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint);
+ _PTR(SObject) so = AP->GetSObject();
+ _PTR(StudyBuilder) builder = studyDS()->NewBuilder();
+ builder->RemoveObjectWithChildren(so);
+}
+
+//================================================================
+// Function : getNameOfSavePoint
+/*! Purpose : returns a name of save point
+*/
+//================================================================
+QString SalomeApp_Study::getNameOfSavePoint(int savePoint)
+{
+ _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint);
+ SALOMEDS_IParameters ip(AP);
+ return ip.getProperty("AP_SAVEPOINT_NAME").c_str();
+}
+
+//================================================================
+// Function : setNameOfSavePoint
+/*! Purpose : sets a name of save point
+*/
+//================================================================
+void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint)
+{
+ _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint);
+ SALOMEDS_IParameters ip(AP);
+ ip.setProperty("AP_SAVEPOINT_NAME", nameOfSavePoint.latin1());
+}
+
+//================================================================
+// Function : getVisualComponentName
+/*! Purpose : returns a name of the component where visual
+ * parameters are stored
+*/
+//================================================================
+std::string SalomeApp_Study::getVisualComponentName()
+{
+ return "Interface Applicative";
+}
+
+//================================================================
+// Function : updateModelRoot
+/*! Purpose : slot called on change of a root of a data model. redefined from CAM_Study*/
+//================================================================
+void SalomeApp_Study::updateModelRoot( const CAM_DataModel* dm )
+{
+ LightApp_Study::updateModelRoot( dm );
+
+ // calling updateSavePointDataObjects in order to set correct order of "Gui states" object
+ // it must always be the last one.
+ ((SalomeApp_Application*)application())->updateSavePointDataObjects( this );
+}