+
+/*!
+ Note that this method does not create or activate SalomeApp_Engine_i instance,
+ therefore it can be called safely for any kind of module, but for full
+ modules it returns an empty list.
+ \return list of files used by module: to be used by CORBAless modules
+ \param theModuleName - name of module
+*/
+std::vector<std::string> SalomeApp_Study::GetListOfFiles( const char* theModuleName ) const
+{
+ // Issue 21377 - using separate engine for each type of light module
+ SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false );
+ if (aDefaultEngine)
+ return aDefaultEngine->GetListOfFiles(id());
+
+ std::vector<std::string> aListOfFiles;
+ return aListOfFiles;
+}
+
+/*!
+ Sets list of files used by module: to be used by CORBAless modules.
+ Note that this method does not create or activate SalomeApp_Engine_i instance,
+ therefore it can be called safely for any kind of module, but for full
+ modules it simply does nothing.
+ \param theModuleName - name of module
+ \param theListOfFiles - list of files
+*/
+void SalomeApp_Study::SetListOfFiles ( const char* theModuleName,
+ const std::vector<std::string> theListOfFiles )
+{
+ // Issue 21377 - using separate engine for each type of light module
+ SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false );
+ if (aDefaultEngine)
+ aDefaultEngine->SetListOfFiles(theListOfFiles, id());
+}
+
+/*!
+ \return temporary directory for saving files of modules
+*/
+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();
+ return aTmpDir;
+}
+
+/*!
+ Removes temporary files
+*/
+void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const
+{
+ if (isMultiFile)
+ return;
+
+ std::vector<std::string> aListOfFiles = GetListOfFiles( theModuleName );
+ if (aListOfFiles.size() > 0) {
+ std::string aTmpDir = aListOfFiles[0];
+
+ const int n = aListOfFiles.size() - 1;
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(n);
+ for (int i = 0; i < n; i++)
+ aSeq[i] = CORBA::string_dup(aListOfFiles[i + 1].c_str());
+
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
+ }
+}
+
+#ifndef DISABLE_PYCONSOLE
+/*!
+ Mark the study as saved in the file
+ \param theFileName - the name of file
+*/
+void SalomeApp_Study::updateFromNotebook( const QString& theFileName, bool isSaved )
+{
+ setStudyName(theFileName);
+ studyDS()->Name(theFileName.toStdString());
+ setIsSaved( isSaved );
+}
+#endif
+
+LightApp_DataObject* SalomeApp_Study::findObjectByEntry( const QString& theEntry )
+{
+ LightApp_DataObject* o = 0;
+ if ( myObserver ) {
+ o = dynamic_cast<LightApp_DataObject*>( myObserver->findObject( theEntry.toLatin1().constData() ) );
+ }
+ if ( !o ) {
+ o = LightApp_Study::findObjectByEntry( theEntry );
+ }
+ return o;
+}
+
+/*!
+ Deletes all references to object
+ \param obj - object
+*/
+void SalomeApp_Study::deleteReferencesTo( _PTR( SObject ) obj )
+{
+ _PTR(StudyBuilder) sb = studyDS()->NewBuilder();
+ std::vector<_PTR(SObject)> aRefs = studyDS()->FindDependances( obj );
+ for( int i=0, n=aRefs.size(); i<n; i++ )
+ {
+ _PTR( SObject ) o = aRefs[i];
+ if( o->GetFatherComponent()->ComponentDataType()==obj->GetFatherComponent()->ComponentDataType() )
+ {
+ sb->RemoveReference( o );
+ sb->RemoveObjectWithChildren( o );
+ }
+ }
+}
+
+/*!
+ \return real entry by entry of reference
+ \param entry - entry of reference object
+*/
+QString SalomeApp_Study::referencedToEntry( const QString& entry ) const
+{
+ _PTR(SObject) obj = studyDS()->FindObjectID( entry.toStdString() );
+ _PTR(SObject) refobj;
+
+ if( obj && obj->ReferencedObject( refobj ) )
+ return refobj->GetID().c_str();
+ return LightApp_Study::referencedToEntry( entry );
+}
+
+/*!
+ \return component data type for entry
+*/
+QString SalomeApp_Study::componentDataType( const QString& entry ) const
+{
+ _PTR(SObject) obj( studyDS()->FindObjectID( entry.toStdString() ) );
+ if ( !obj )
+ return LightApp_Study::componentDataType( entry );
+ return obj->GetFatherComponent()->ComponentDataType().c_str();
+}
+
+/*!
+ \return true if entry corresponds to component
+*/
+bool SalomeApp_Study::isComponent( const QString& entry ) const
+{
+ _PTR(SObject) obj( studyDS()->FindObjectID( entry.toStdString() ) );
+ return obj && QString( obj->GetID().c_str() ) == obj->GetFatherComponent()->GetID().c_str();
+}
+
+/*!
+ \return entries of object children
+*/
+void SalomeApp_Study::children( const QString& entry, QStringList& child_entries ) const
+{
+ _PTR(SObject) SO = studyDS()->FindObjectID( entry.toStdString() );
+ _PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( SO ) );
+ anIter->InitEx( true );
+ while( anIter->More() )
+ {
+ _PTR(SObject) val( anIter->Value() );
+ child_entries.append( val->GetID().c_str() );
+ anIter->Next();
+ }
+}
+
+/*!
+ Fills list with components names
+ \param comp - list to be filled
+*/
+void SalomeApp_Study::components( QStringList& comps ) const
+{
+ for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More(); it->Next() )
+ {
+ _PTR(SComponent) aComponent ( it->Value() );
+ // skip the magic "Interface Applicative" component
+ if ( aComponent && aComponent->ComponentDataType() != getVisualComponentName().toLatin1().constData() )
+ comps.append( aComponent->ComponentDataType().c_str() );
+ }
+}
+
+/*!
+ Get the entry for the given module
+ \param comp - list to be filled
+ \return module root's entry
+*/
+QString SalomeApp_Study::centry( const QString& comp ) const
+{
+ QString e;
+ for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More() && e.isEmpty(); it->Next() )
+ {
+ _PTR(SComponent) aComponent ( it->Value() );
+ if ( aComponent && comp == aComponent->ComponentDataType().c_str() )
+ e = aComponent->GetID().c_str();
+ }
+ return e;
+}
+
+/*!
+ \return a list of saved points' IDs
+*/
+std::vector<int> SalomeApp_Study::getSavePoints()
+{
+ std::vector<int> v;
+
+ _PTR(SObject) so = studyDS()->FindComponent( getVisualComponentName().toLatin1().constData() );
+ 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;
+}
+
+/*!
+ Removes a given save point
+*/
+void SalomeApp_Study::removeSavePoint(int savePoint)
+{
+ if(savePoint <= 0) return;
+ _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName().toLatin1().constData(), savePoint);
+ _PTR(SObject) so = AP->GetSObject();
+ _PTR(StudyBuilder) builder = studyDS()->NewBuilder();
+ builder->RemoveObjectWithChildren(so);
+}
+
+/*!
+ \return a name of save point
+*/
+QString SalomeApp_Study::getNameOfSavePoint(int savePoint)
+{
+ _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName().toLatin1().constData(), savePoint);
+ _PTR(IParameters) ip = ClientFactory::getIParameters(AP);
+ return ip->getProperty("AP_SAVEPOINT_NAME").c_str();
+}
+
+/*!
+ Sets a name of save point
+*/
+void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint)
+{
+ _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName().toLatin1().constData(), savePoint);
+ _PTR(IParameters) ip = ClientFactory::getIParameters(AP);
+ ip->setProperty("AP_SAVEPOINT_NAME", nameOfSavePoint.toStdString());
+}
+
+/*!
+ * \brief Restores the study state
+ */
+void SalomeApp_Study::restoreState(int savePoint)
+{
+ SalomeApp_VisualState((SalomeApp_Application*)application()).restoreState(savePoint);
+}
+
+
+/*!
+ 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 );
+}