#include "utilities.h"
+/*!
+ Constructor.
+*/
SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
: CAM_Study( app )
{
}
+/*!
+ Destructor.
+*/
SalomeApp_Study::~SalomeApp_Study()
{
}
+/*!
+ Gets study id.
+*/
int SalomeApp_Study::id() const
{
int id = -1;
return id;
}
+/*!
+ Gets studyDS pointer.
+*/
_PTR(Study) SalomeApp_Study::studyDS() const
{
return myStudyDS;
}
+/*!
+ Create document.
+*/
void SalomeApp_Study::createDocument()
{
MESSAGE( "openDocument" );
//=======================================================================
// name : openDocument
-// Purpose : Open document
+/*! Purpose : Open document*/
//=======================================================================
bool SalomeApp_Study::openDocument( const QString& theFileName )
{
//=======================================================================
// name : loadDocument
-// Purpose : Connects GUI study to SALOMEDS one already loaded into StudyManager
+/*! Purpose : Connects GUI study to SALOMEDS one already loaded into StudyManager*/
//=======================================================================
bool SalomeApp_Study::loadDocument( const QString& theStudyName )
{
setStudyDS( study );
- // build a SUIT_DataObject-s tree under myRoot member field
- // 1. create myRoot
- setRoot( new SalomeApp_RootObject( this ) );
- // 2. iterate through all components and create corresponding sub-trees under them
- _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() );
- for ( ; it->More(); it->Next() ) {
- // don't use shared_ptr here, for Data Object will take
- // ownership of this pointer
- _PTR(SComponent) aComponent ( it->Value() );
+ setRoot( new SalomeApp_RootObject( this ) ); // create myRoot
- if ( aComponent->ComponentDataType() == "Interface Applicative" )
- continue; // skip the magic "Interface Applicative" component
+ //SRN: BugID IPAL9021, put there the same code as in a method openDocument
- SalomeApp_DataModel::BuildTree( aComponent, root(), this );
- }
+ // update loaded data models: call open() and update() on them.
+ ModelList dm_s;
+ dataModels( dm_s );
+ for ( ModelListIterator it( dm_s ); it.current(); ++it )
+ openDataModel( studyName(), it.current() );
+
+ // this will build a SUIT_DataObject-s tree under myRoot member field
+ // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((SalomeApp_Application*)application())->updateObjectBrowser( false );
- // TODO: potentially unsafe call, since base study's openDocument() might try to access the file directly - to be improved
- //bool res = true;
bool res = CAM_Study::openDocument( theStudyName );
+ emit opened( this );
- //emit opened( this );
+ //SRN: BugID IPAL9021: End
return res;
}
//=======================================================================
// name : saveDocumentAs
-// Purpose : Save document
+/*! Purpose : Save document */
//=======================================================================
bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
{
aModel->saveAs( theFileName, this );
// save SALOMEDS document
- bool isMultiFile = false, isAscii = false;// TODO: This information should be taken from preferences afterwards!
- /* bool res = */isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile );
+ SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+ if( !resMgr )
+ 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 );
bool res = CAM_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
//=======================================================================
// name : saveDocument
-// Purpose : Save document
+/*! Purpose : Save document */
//=======================================================================
void SalomeApp_Study::saveDocument()
{
CAM_Study::saveDocument();
// save SALOMEDS document
- bool isMultiFile = false, isAscii = false;// TODO: This information should be taken from preferences afterwards!
+ SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+ if( !resMgr )
+ return;
+
+ 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 );
//================================================================
// Function : closeDocument
-// Purpose :
+/*! Purpose : Close document */
//================================================================
void SalomeApp_Study::closeDocument(bool permanently)
{
//================================================================
// Function : isModified
-// Purpose :
+/*! Purpose : Check data model on modifications.*/
//================================================================
bool SalomeApp_Study::isModified() const
{
//================================================================
// Function : isSaved
-// Purpose :
+/*! Purpose : Check: data model is saved?*/
//================================================================
bool SalomeApp_Study::isSaved() const
{
return isAllSaved;
}
+/*!
+ Set studyDS.
+*/
void SalomeApp_Study::setStudyDS( const _PTR(Study)& s )
{
myStudyDS = s;
}
+/*!
+ Insert data model.
+*/
void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm)
{
MESSAGE("SalomeApp_Study::dataModelInserted() : module name() = " << dm->module()->name());
}
}
+/*!
+ Open data model
+*/
bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm )
{
if (!dm)
return false;
}
+/*!
+ Create new study name.
+*/
QString SalomeApp_Study::newStudyName() const
{
std::vector<std::string> studies = SalomeApp_Application::studyMgr()->GetOpenStudies();