Salome HOME
Debug
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index a97fde5c20811085db7be0fb1da978ae87bf27ea..3fad1a3145d653dc38c48de68719e53024dbff53 100644 (file)
@@ -420,6 +420,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName
     myHypothesis_i =
       myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen);
     myHypothesis_i->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance
+    myHypothesis_i->SetNotebook(GetNotebook(GetCurrentStudyID()));
   }
   catch (SALOME_Exception& S_ex)
   {
@@ -456,7 +457,8 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh()
   // Get or create the GEOM_Client instance
   try {
     // create a new mesh object servant, store it in a map in study context
-    SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
+    SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID(),
+                                                  GetNotebook( GetCurrentStudyID() ) );
     // create a new mesh object
     meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
 
@@ -607,6 +609,20 @@ SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy()
   return SALOMEDS::Study::_duplicate( myCurrentStudy );
 }
 
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::GetStudyContext 
+ *
+ *  Get study context by study id
+ */
+//=============================================================================
+StudyContext* SMESH_Gen_i::GetStudyContext( int theStudyId )
+{
+  if ( myStudyContextMap.find( theStudyId ) != myStudyContextMap.end() )
+    return myStudyContextMap[ theStudyId ];
+  return 0;
+}
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::GetCurrentStudyContext 
@@ -616,11 +632,9 @@ SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy()
 //=============================================================================
 StudyContext* SMESH_Gen_i::GetCurrentStudyContext()
 {
-  if ( !CORBA::is_nil( myCurrentStudy ) &&
-      myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
-    return myStudyContextMap[ myCurrentStudy->StudyId() ];
-  else
-    return 0;
+  if ( !CORBA::is_nil( myCurrentStudy ) )
+    return GetStudyContext( GetCurrentStudyID() );
+  return 0;
 }
 
 //=============================================================================
@@ -4364,6 +4378,36 @@ SALOME::Notebook_ptr SMESH_Gen_i::GetNotebook( CORBA::Long theStudyID )
   return aNotebook._retn();
 }
 
+//=================================================================================
+// function : FindObjectByInternalEntry()
+// purpose  :
+//=================================================================================
+SALOME::GenericObj_ptr SMESH_Gen_i::FindObjectByInternalEntry( CORBA::Long theStudyID, const char* theEntry )
+{
+  map<int, StudyContext*>::iterator it = myStudyContextMap.find( theStudyID );
+  if ( it == myStudyContextMap.end() )
+    return NULL;
+
+  StudyContext* aStudyContext = it->second;
+  if ( !aStudyContext )
+    return NULL;
+
+  int id = atoi( theEntry );
+  string anIOR = aStudyContext->getIORbyId( id );
+  if ( !anIOR.empty() ) {
+    CORBA::Object_var anObject = GetORB()->string_to_object( anIOR.c_str() );
+    if ( !CORBA::is_nil( anObject ) ) {
+      SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+      if ( !aHyp->_is_nil() )
+        return aHyp._retn();
+      SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( anObject );
+      if ( !aMesh->_is_nil() )
+        return aMesh._retn();
+    }
+  }
+  return NULL;
+}
+
 //=============================================================================
 /*! 
  *  SMESHEngine_factory