void SALOMEDSImpl_Study::Init()
{
static int _id = 0;
- _name = "Study" + std::to_string(++_id);
+ std::stringstream sstrm;
+ sstrm << ++_id;
+ _name = "Study" + std::string(sstrm.str());
_doc = _appli->NewDocument("SALOME_STUDY");
- _Saved = false ;
+ _Saved = false;
_URL = "";
_autoFill = false;
_errorCode = "";
_builder = new SALOMEDSImpl_StudyBuilder(this);
_cb = new SALOMEDSImpl_Callback(_useCaseBuilder);
_notifier=0;
+ _genObjRegister=0;
//Put on the root label a StudyHandle attribute to store the address of this object
//It will be used to retrieve the study object by DF_Label that belongs to the study
SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this);
delete _builder;
delete _cb;
delete _useCaseBuilder;
+ URL("");
_appli->Close(_doc);
_doc = NULL;
_mapOfSO.clear();
//============================================================================
bool SALOMEDSImpl_Study::Open(const std::string& aUrl)
{
- Clear();
- Init();
// Set "C" locale temporarily to avoid possible localization problems
Kernel_Utils::Localizer loc;
* Purpose :
*/
//============================================================================
-std::string SALOMEDSImpl_Study::_GetNoteBookAccess(const std::string& theStudyVar)
+std::string SALOMEDSImpl_Study::_GetNoteBookAccess()
{
- std::string notebook = "import salome_notebook\n";
- notebook += _GetNoteBookAccessor() + " = salome_notebook.NoteBook(" + theStudyVar + ")" ;
- return notebook;
+ return std::string("import salome_notebook\n");
}
bool SALOMEDSImpl_Study::IsLocked()
sfp << "import sys" << std::endl;
sfp << "import " << aBatchModeScript << std::endl << std::endl;
- std::string aStudyVar = "salome.myStudy";
// initialization function
sfp << aBatchModeScript << ".salome_init()" << std::endl;
- if ( !isMultiFile ) {
- sfp << "theStudy = " << aStudyVar << std::endl << std::endl;
- aStudyVar = "theStudy";
- }
+
// notebook initialization
- sfp << _GetNoteBookAccess(aStudyVar) << std::endl;
+ sfp << _GetNoteBookAccess() << std::endl;
// extend sys.path with the directory where the script is being dumped to
sfp << "sys.path.insert( 0, r\'" << thePath << "\')" << std::endl << std::endl;
//Add to the main script a call to RebuildData of the generated by the component the Python script
sfp << "import " << aScriptName << std::endl;
- sfp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << std::endl;
+ sfp << aScriptName << ".RebuildData()" << std::endl;
}
else
sfp << sfp2.str();
sfp << std::endl;
sfp << "if salome.sg.hasDesktop():" << std::endl;
- sfp << "\tsalome.sg.updateObjBrowser(True)" << std::endl;
+ sfp << "\tsalome.sg.updateObjBrowser()" << std::endl;
if(isDumpVisuals) { //Output the call to Session's method restoreVisualState
sfp << "\tiparameters.getSession().restoreVisualState(1)" << std::endl;
_notifier=notifier;
}
+static SALOMEDSImpl_AbstractCallback* & getGenObjRegister( DF_Document* doc )
+{
+ static std::vector< SALOMEDSImpl_AbstractCallback* > _genObjRegVec;
+ if ( doc->GetDocumentID() >= (int)_genObjRegVec.size() )
+ _genObjRegVec.resize( doc->GetDocumentID() + 1, 0 );
+ return _genObjRegVec[ doc->GetDocumentID() ];
+}
+
+//================================================================================
+/*!
+ * \brief Stores theRegister
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister)
+{
+ getGenObjRegister( _doc ) = theRegister;
+}
+
+//================================================================================
+/*!
+ * \brief Indirectly invokes GenericObj_i::Register()
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::RegisterGenObj (const std::string& theIOR, DF_Label label)
+{
+ if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
+ goRegister->RegisterGenObj( theIOR );
+}
+
+//================================================================================
+/*!
+ * \brief Indirectly invokes GenericObj_i::UnRegister()
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::UnRegisterGenObj(const std::string& theIOR, DF_Label label)
+{
+ if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
+ goRegister->UnRegisterGenObj( theIOR );
+}
+
//#######################################################################################################
//# STATIC PRIVATE FUNCTIONS
//#######################################################################################################