From bf4d9c71e6d395e4fbc8c0c5dee78e76b27ff0ee Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 28 Sep 2005 08:20:00 +0000 Subject: [PATCH] *** empty log message *** --- src/SalomeApp/SalomeApp_Application.cxx | 38 +++- src/SalomeApp/SalomeApp_Application.h | 5 +- src/SalomeApp/SalomeApp_DataModel.cxx | 31 ++-- src/SalomeApp/SalomeApp_DataModel.h | 2 +- src/SalomeApp/SalomeApp_DataObject.cxx | 15 +- src/SalomeApp/SalomeApp_DataObject.h | 2 + src/SalomeApp/SalomeApp_Module.h | 3 +- src/SalomeApp/SalomeApp_Study.cxx | 232 +++++++++++++++++++----- src/SalomeApp/SalomeApp_Study.h | 21 ++- src/SalomeApp/resources/SalomeApp.ini | 1 + src/SalomeApp/resources/SalomeApp.xml | 9 +- 11 files changed, 272 insertions(+), 87 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index ceb036777..326e9426d 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -66,9 +66,10 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() /* Class : SalomeApp_Application - Description : Application containing SalomeApp module + Description : Application containing SalomeApp module or LightApp module */ +/*!Constructor.*/ SalomeApp_Application::SalomeApp_Application() : LightApp_Application() { @@ -184,6 +185,12 @@ void SalomeApp_Application::onLoadDoc() } } +/*!SLOT. Load document with \a aName.*/ +bool SalomeApp_Application::onLoadDoc( const QString& str ) +{ + return LightApp_Application::onLoadDoc(str); +} + /*!SLOT. Copy objects to study maneger from selection maneger..*/ void SalomeApp_Application::onCopy() { @@ -532,6 +539,7 @@ SALOME_LifeCycleCORBA* SalomeApp_Application::lcc() return _lcc; } +/*!Return default engine IOR for light modules*/ QString SalomeApp_Application::defaultEngineIOR() { /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence) @@ -563,7 +571,7 @@ void SalomeApp_Application::onProperties() updateDesktopTitle(); } -/*!*/ +/*!Insert items in popup, which necessary for current application*/ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title ) { LightApp_Application::contextMenuPopup( type, thePopup, title ); @@ -623,9 +631,15 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) ); } -/*!Update obect browser*/ +/*!Update obect browser: + 1.if 'updateModels' true, update existing data models; + 2. update "non-existing" (not loaded yet) data models; + 3. update object browser if it existing */ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) { + // update existing data models (already loaded SComponents) + LightApp_Application::updateObjectBrowser(updateModels); + // update "non-existing" (not loaded yet) data models SalomeApp_Study* study = dynamic_cast(activeStudy()); if ( study ) @@ -639,12 +653,24 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) if ( aComponent->ComponentDataType() == "Interface Applicative" ) continue; // skip the magic "Interface Applicative" component - - SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true ); + + SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true ); } } } - LightApp_Application::updateObjectBrowser(updateModels); + if ( objectBrowser() ) + { + objectBrowser()->updateGeometry(); + objectBrowser()->updateTree(); + } +} + +/*!Gets file filter. + *\retval QString "(*.hdf)" + */ +QString SalomeApp_Application::getFileFilter() const +{ + return "(*.hdf)"; } /*!Display Catalog Genenerator dialog */ diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 567b59668..43bbbafd9 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -35,7 +35,7 @@ class SALOME_LifeCycleCORBA; #endif /*! - Description : Application containing SalomeApp module + Description : Application containing SalomeApp module or LightApp module */ class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application @@ -53,6 +53,8 @@ public: virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); virtual void updateObjectBrowser( const bool = true ); + virtual QString getFileFilter() const; + SUIT_ViewManager* getViewManager( const QString&, const bool ); virtual void start(); @@ -65,6 +67,7 @@ public: public slots: virtual void onLoadDoc(); + virtual bool onLoadDoc( const QString& ); virtual void onCopy(); virtual void onPaste(); diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 3c63e644b..6830085ed 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -63,7 +63,7 @@ SUIT_DataObject* SalomeApp_DataModel::BuildTree( const _PTR(SObject)& obj, componentObj->removeChild(itc.current()); // delete DataObject itself and re-create it and all its sub-objects - delete componentObj; + delete componentObj; // don't do anything here, because iterator may be corrupted (deleted object inside it) break; // proceed to build_a_data_object code below } @@ -108,7 +108,7 @@ SalomeApp_DataModel::~SalomeApp_DataModel() // Function : open /*! Purpose : Open data model*/ //================================================================ -bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study ) +bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study, QStringList ) { SalomeApp_Study* aDoc = dynamic_cast( study ); if ( !aDoc ) @@ -123,7 +123,8 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study ) if ( aSComp ) buildTree( aSComp, 0, aDoc ); - LightApp_DataModel::open(name, study); + QStringList listOfFiles; + LightApp_DataModel::open(name, study, listOfFiles); return true; } @@ -133,36 +134,30 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study ) //================================================================ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) { - SalomeApp_Study* aSStudy = 0; + SalomeApp_Study* aSStudy = dynamic_cast(study); LightApp_RootObject* studyRoot = 0; _PTR(SObject) sobj; SalomeApp_DataObject* modelRoot = dynamic_cast( root() ); if ( !modelRoot ){ // not yet connected to a study -> try using argument - aSStudy = dynamic_cast( study ); if ( !aSStudy ) aSStudy = dynamic_cast( getModule()->getApp()->activeStudy() ); if ( aSStudy ){ studyRoot = dynamic_cast( aSStudy->root() ); - if ( studyRoot ) { - QString anId = getRootEntry( aSStudy ); - if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing - _PTR(Study) aStudy ( aSStudy->studyDS() ); - sobj = aStudy->FindComponentID( std::string( anId.latin1() ) ); - } + QString anId = getRootEntry( aSStudy ); + if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing + _PTR(Study) aStudy ( aSStudy->studyDS() ); + sobj = aStudy->FindComponentID( std::string( anId.latin1() ) ); } } } else{ studyRoot = dynamic_cast( modelRoot->root() ); if ( studyRoot ) { - aSStudy = dynamic_cast( study ); + aSStudy = dynamic_cast( studyRoot->study() ); // value should not change here theoretically, but just to make sure if ( aSStudy ) { - aSStudy = dynamic_cast( studyRoot->study() ); // value should not change here theoretically, but just to make sure - if ( aSStudy ) { - _PTR(Study) aStudy ( aSStudy->studyDS() ); - // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon - sobj = aStudy->FindComponentID( std::string( modelRoot->entry().latin1() ) ); - } + _PTR(Study) aStudy ( aSStudy->studyDS() ); + // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon + sobj = aStudy->FindComponentID( std::string( modelRoot->entry().latin1() ) ); } } } diff --git a/src/SalomeApp/SalomeApp_DataModel.h b/src/SalomeApp/SalomeApp_DataModel.h index 7ef34b088..4dab54d9b 100644 --- a/src/SalomeApp/SalomeApp_DataModel.h +++ b/src/SalomeApp/SalomeApp_DataModel.h @@ -34,7 +34,7 @@ public: SalomeApp_DataModel ( CAM_Module* theModule ); virtual ~SalomeApp_DataModel(); - virtual bool open( const QString&, CAM_Study* ); + virtual bool open( const QString&, CAM_Study*, QStringList ); virtual void update( LightApp_DataObject* = 0, LightApp_Study* = 0 ); QString getRootEntry( SalomeApp_Study* ) const; diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 62cb0add7..7b0944129 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -309,7 +309,7 @@ QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const /*!Constructor.Initialize by \a parent.*/ SalomeApp_ModuleObject::SalomeApp_ModuleObject( SUIT_DataObject* parent ) -: SalomeApp_DataObject( parent ), +: SalomeApp_DataObject( parent ), CAM_RootObject( parent ), CAM_DataObject( parent ) { @@ -317,7 +317,7 @@ SalomeApp_ModuleObject::SalomeApp_ModuleObject( SUIT_DataObject* parent ) /*!Constructor.Initialize by \a parent and SObject.*/ SalomeApp_ModuleObject::SalomeApp_ModuleObject( const _PTR(SObject)& sobj, SUIT_DataObject* parent ) -: SalomeApp_DataObject( sobj, parent ), +: SalomeApp_DataObject( sobj, parent ), CAM_RootObject( 0, parent ), CAM_DataObject( parent ) { @@ -325,9 +325,9 @@ SalomeApp_ModuleObject::SalomeApp_ModuleObject( const _PTR(SObject)& sobj, SUIT_ /*!Constructor.Initialize by \a parent and CAM_DataModel.*/ SalomeApp_ModuleObject::SalomeApp_ModuleObject( CAM_DataModel* dm, const _PTR(SObject)& sobj, SUIT_DataObject* parent ) -: SalomeApp_DataObject( sobj, parent ), +: SalomeApp_DataObject( sobj, parent ), CAM_RootObject( dm, parent ), - CAM_DataObject( parent ) + CAM_DataObject( parent ) { } @@ -335,3 +335,10 @@ SalomeApp_ModuleObject::SalomeApp_ModuleObject( CAM_DataModel* dm, const _PTR(SO SalomeApp_ModuleObject::~SalomeApp_ModuleObject() { } + +/*!Returns module name */ +QString SalomeApp_ModuleObject::name() const +{ + return SalomeApp_DataObject::name(); +} + diff --git a/src/SalomeApp/SalomeApp_DataObject.h b/src/SalomeApp/SalomeApp_DataObject.h index 34042162d..cf9c154ed 100644 --- a/src/SalomeApp/SalomeApp_DataObject.h +++ b/src/SalomeApp/SalomeApp_DataObject.h @@ -61,6 +61,8 @@ public: SalomeApp_ModuleObject( const _PTR(SObject)&, SUIT_DataObject* = 0 ); SalomeApp_ModuleObject( CAM_DataModel*, const _PTR(SObject)&, SUIT_DataObject* = 0 ); virtual ~SalomeApp_ModuleObject(); + + virtual QString name() const; }; #endif diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index 67bc25ed0..5dd9d4729 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -30,8 +30,7 @@ public: /*! engineIOR() should be a pure virtual method, to avoid logical errors!\n * Implementation in derived classes can return the following values:\n * module`s engine IOR - means that this is a standard SALOME module with a CORBA engine - * \li "" (empty string) - means that this is a light module, default engine should be used for interaction with SALOMEDS persistence - * \li "-1" - means that this is a light module, SALOMEDS persistence is not used at all\n + * \li "" (empty string) - means that this not correct SALOME module */ virtual QString engineIOR() const = 0; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 97be8db88..c7107f14c 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -2,11 +2,12 @@ #include "SalomeApp_Module.h" #include "SalomeApp_DataModel.h" -#include "LightApp_RootObject.h" #include "SalomeApp_DataObject.h" #include "SalomeApp_Application.h" #include "SalomeApp_Engine_i.hxx" +#include "LightApp_RootObject.h" + #include #include @@ -72,7 +73,11 @@ void SalomeApp_Study::createDocument() setStudyDS( study ); setStudyName( aName ); - LightApp_Study::createDocument(); + // create myRoot + setRoot( new LightApp_RootObject( this ) ); + + CAM_Study::createDocument(); + emit created( this ); } //======================================================================= @@ -90,8 +95,22 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) setStudyDS( study ); - bool res = LightApp_Study::openDocument( theFileName ); - + setRoot( new LightApp_RootObject( this ) ); // create myRoot + + // 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 ); + + bool res = CAM_Study::openDocument( theFileName ); + emit opened( this ); + return res; } @@ -110,7 +129,26 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) setStudyDS( study ); - bool res = LightApp_Study::loadDocument( theStudyName ); + setRoot( new LightApp_RootObject( this ) ); // create myRoot + + //SRN: BugID IPAL9021, put there the same code as in a method openDocument + + // 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 ); + + bool res = CAM_Study::openDocument( theStudyName ); + emit opened( this ); + + //SRN: BugID IPAL9021: End return res; } @@ -121,17 +159,32 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) //======================================================================= bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { + ModelList list; dataModels( list ); + + SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + QStringList listOfFiles; + for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) { + listOfFiles.clear(); + aModel->saveAs( theFileName, this, listOfFiles ); + if ( !listOfFiles.isEmpty() ) + saveModuleData(aModel->module()->name(), listOfFiles); + } + // save SALOMEDS document SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) return false; - bool res = LightApp_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable 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 = res && saveStudyData(theFileName); + if ( res ) + emit saved( this ); + return res; } @@ -139,18 +192,36 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) // name : saveDocument /*! Purpose : Save document*/ //======================================================================= -void SalomeApp_Study::saveDocument() +bool SalomeApp_Study::saveDocument() { + ModelList list; dataModels( list ); + + SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + QStringList listOfFiles; + for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) { + listOfFiles.clear(); + aModel->save(listOfFiles); + if ( !listOfFiles.isEmpty() ) + saveModuleData(aModel->module()->name(), listOfFiles); + } + // save SALOMEDS document SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) - return; - LightApp_Study::saveDocument(); - + 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(); + + res = res && saveStudyData(studyName()); + if ( res ) + emit saved( this ); + + return res; } //================================================================ @@ -197,6 +268,69 @@ bool SalomeApp_Study::isSaved() const return isAllSaved; } +//======================================================================= +// name : saveModuleData +/*! Purpose : save list file for module 'theModuleName' */ +//======================================================================= +void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theListOfFiles ) +{ + int aNb = theListOfFiles.count(); + if ( aNb == 0 ) + return; + + std::vector aListOfFiles ( aNb ); + int anIndex = 0; + for ( QStringList::Iterator it = theListOfFiles.begin(); it != theListOfFiles.end(); ++it ) { + if ( (*it).isEmpty() ) + continue; + aListOfFiles[anIndex] = (*it).latin1(); + anIndex++; + } + SetListOfFiles(theModuleName, aListOfFiles); +} + +//======================================================================= +// name : openModuleData +/*! Purpose : gets list of file for module 'theModuleNam' */ +//======================================================================= +void SalomeApp_Study::openModuleData( QString theModuleName, QStringList& theListOfFiles ) +{ + std::vector aListOfFiles = GetListOfFiles( theModuleName ); + + int i, aLength = aListOfFiles.size() - 1; + if ( aLength < 0 ) + return; + + //Get a temporary directory for saved a file + theListOfFiles.append(aListOfFiles[0].c_str()); + + for(i = 0; i < aLength; i++) + theListOfFiles.append(aListOfFiles[i+1].c_str()); +} + +//======================================================================= +// name : saveStudyData +/*! Purpose : save data from study */ +//======================================================================= +bool SalomeApp_Study::saveStudyData( const QString& theFileName ) +{ + ModelList list; dataModels( list ); + SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); + std::vector listOfFiles(0); + for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) + SetListOfFiles(aModel->module()->name(), listOfFiles); + return true; +} + +//======================================================================= +// name : openStudyData +/*! Purpose : open data for study */ +//======================================================================= +bool SalomeApp_Study::openStudyData( const QString& theFileName ) +{ + return true; +} + /*! Set studyDS. */ @@ -214,12 +348,17 @@ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) CAM_Study::dataModelInserted(dm); - // Create SComponent for module, using default engine (CORBAless) - // SalomeApp_Module* aModule = (SalomeApp_Module*)(dm->module()); + // addComponent(dm); +} + +/*! + Create SComponent for module, using default engine (CORBAless) +*/ +void SalomeApp_Study::addComponent(const CAM_DataModel* dm) +{ SalomeApp_Module* aModule = dynamic_cast( dm->module() ); // 1. aModule == 0 means that this is a light module (no CORBA enigine) - // 2. engineIOR == "" means this is a full module but without CORBA engine - if (!aModule || aModule->engineIOR().isEmpty()) { + if (!aModule) { // Check SComponent existance _PTR(Study) aStudy = studyDS(); if (!aStudy) @@ -227,11 +366,18 @@ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) _PTR(SComponent) aComp = aStudy->FindComponent(dm->module()->name()); if (!aComp) { // Create SComponent - _PTR(StudyBuilder) aBuilder = studyDS()->NewBuilder(); + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); aComp = aBuilder->NewComponent(dm->module()->name()); - + aBuilder->SetName(aComp, dm->module()->moduleName()); + QString anIconName = dm->module()->iconName(); + if (!anIconName.isEmpty()) { + _PTR(AttributePixMap) anAttr = aBuilder->FindOrCreateAttribute(aComp, "AttributePixMap"); + if (anAttr) + anAttr->SetPixMap(anIconName); + } // Set default engine IOR aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1()); + SalomeApp_DataModel::BuildTree( aComp, root(), this, /*skipExisitng=*/true ); } } } @@ -250,8 +396,7 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm _PTR(SComponent) aSComp; QString anEngine; // 1. aModule == 0 means that this is a light module (no CORBA enigine) - // 2. engineIOR == "" means this is a full module but without CORBA engine - if (!aModule || aModule->engineIOR().isEmpty()) { + if (!aModule) { anEngine = SalomeApp_Application::defaultEngineIOR(); aSComp = aStudy->FindComponent(dm->module()->name()); } @@ -261,20 +406,9 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm QString anId = aDM->getRootEntry( this ); if ( anId.isEmpty() ) return true; // Probably nothing to load - - if ( aDM ) { - anEngine = aDM->getModule()->engineIOR(); - if ( anEngine == "-1" ) { - // Module doesn't have a CORBA engine and doesn't use - // a default one -> SALOMEDS persistence cannot be used - return false; - } - } - if ( anEngine.isEmpty() ) { - // Module use a default engine - //TODO: deside, if the below code has to be copyed in a light data model to avoid bulding of data tree twice - anEngine = SalomeApp_Application::defaultEngineIOR(); - } + anEngine = aDM->getModule()->engineIOR(); + if ( anEngine.isEmpty() ) + return false; aSComp = aStudy->FindComponentID( std::string( anId.latin1() ) ); } } @@ -289,13 +423,21 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm return false; } // Something has been read -> create data model tree + //SalomeApp_DataModel* aDM = dynamic_cast( dm ); // aDM->buildTree( aSComp, 0, this ); } } else { // Don't return false here, for there might be no data // for a given component in the study yet } - if (dm && dm->open(studyName, this)) { + QStringList listOfFiles; + openModuleData(dm->module()->name(), listOfFiles); + if (dm && dm->open(studyName, this, listOfFiles)) { + // Remove the files and temporary directory, created + // for this module by LightApp_Engine_i::Load() + bool isMultiFile = false; // TODO: decide, how to access this parameter + RemoveTemporaryFiles( dm->module()->name(), isMultiFile ); + // Something has been read -> create data model tree LightApp_DataModel* aDM = dynamic_cast( dm ); if ( aDM ) @@ -331,13 +473,11 @@ QString SalomeApp_Study::newStudyName() const // Function : GetListOfFiles /*! Purpose : to be used by CORBAless modules*/ //================================================================ -std::vector SalomeApp_Study::GetListOfFiles() const +std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleName ) const { SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance(); - if (aDefaultEngine) { - const char* aName = ((CAM_Application*)application())->activeModule()->name(); - return aDefaultEngine->GetListOfFiles(id(), aName); - } + if (aDefaultEngine) + return aDefaultEngine->GetListOfFiles(id(), theModuleName); std::vector aListOfFiles; return aListOfFiles; @@ -347,21 +487,19 @@ std::vector SalomeApp_Study::GetListOfFiles() const // Function : SetListOfFiles /*! Purpose : to be used by CORBAless modules*/ //================================================================ -void SalomeApp_Study::SetListOfFiles (const std::vector theListOfFiles) +void SalomeApp_Study::SetListOfFiles ( const char* theModuleName, + const std::vector theListOfFiles ) { SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance(); - if (aDefaultEngine) { - const char* aName = ((CAM_Application*)application())->activeModule()->name(); - aDefaultEngine->SetListOfFiles(theListOfFiles, id(), aName); - } + if (aDefaultEngine) + aDefaultEngine->SetListOfFiles(theListOfFiles, id(), theModuleName); } //================================================================ // Function : GetTmpDir /*! Purpose : to be used by CORBAless modules*/ //================================================================ -std::string SalomeApp_Study::GetTmpDir (const char* theURL, - const bool isMultiFile) +std::string SalomeApp_Study::GetTmpDir ( const char* theURL, const bool isMultiFile ) { std::string anURLDir = SALOMEDS_Tool::GetDirFromPath(theURL); std::string aTmpDir = isMultiFile ? anURLDir : SALOMEDS_Tool::GetTmpDir(); @@ -372,12 +510,12 @@ std::string SalomeApp_Study::GetTmpDir (const char* theURL, // Function : RemoveTemporaryFiles /*! Purpose : to be used by CORBAless modules*/ //================================================================ -void SalomeApp_Study::RemoveTemporaryFiles (const bool isMultiFile) const +void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const { if (isMultiFile) return; - std::vector aListOfFiles = GetListOfFiles(); + std::vector aListOfFiles = GetListOfFiles( theModuleName ); if (aListOfFiles.size() > 0) { std::string aTmpDir = aListOfFiles[0]; diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index b75dd4f08..79593ca52 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -25,7 +25,7 @@ public: virtual bool openDocument( const QString& ); virtual bool loadDocument( const QString& ); - virtual void saveDocument(); + virtual bool saveDocument(); virtual bool saveDocumentAs( const QString& ); virtual void closeDocument(bool permanently = true); @@ -33,17 +33,26 @@ public: virtual bool isSaved() const; virtual bool isModified() const; + virtual void addComponent ( const CAM_DataModel* dm); + _PTR(Study) studyDS() const; - virtual std::vector GetListOfFiles () const; - virtual void SetListOfFiles (const std::vector theListOfFiles); - virtual std::string GetTmpDir (const char* theURL, - const bool isMultiFile); - virtual void RemoveTemporaryFiles (const bool isMultiFile) const; + virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile); // to delete all references to object, whose have the same component void deleteReferencesTo( _PTR( SObject ) ); +protected: + virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); + virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); + virtual bool saveStudyData ( const QString& theFileName ); + virtual bool openStudyData ( const QString& theFileName ); + + virtual std::vector GetListOfFiles ( const char* theModuleName ) const; + virtual void SetListOfFiles ( const char* theModuleName, + const std::vector theListOfFiles); + virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile) const; + protected: virtual void dataModelInserted( const CAM_DataModel* ); virtual bool openDataModel( const QString&, CAM_DataModel* ); diff --git a/src/SalomeApp/resources/SalomeApp.ini b/src/SalomeApp/resources/SalomeApp.ini index 2dae6406e..5203919d1 100644 --- a/src/SalomeApp/resources/SalomeApp.ini +++ b/src/SalomeApp/resources/SalomeApp.ini @@ -11,6 +11,7 @@ Plot2d = $(SUITRoot)/resources GLViewer = $(SUITRoot)/resources OCCViewer = $(SUITRoot)/resources VTKViewer = $(SUITRoot)/resources +LightApp = $(SUITRoot)/resources SalomeApp = $(SUITRoot)/resources GEOM = $(GEOM_ROOT_DIR)/share/salome/resources SMESH = $(SMESH_ROOT_DIR)/share/salome/resources diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index cd868f107..5617a7352 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -16,7 +16,7 @@ - + @@ -33,10 +33,10 @@ + - @@ -45,6 +45,7 @@ + @@ -73,6 +74,10 @@ +
+ + +
-- 2.39.2