Salome HOME
Debug PHASE_17_Part1_V3
authorouv <ouv@opencascade.com>
Fri, 11 Dec 2009 09:35:20 +0000 (09:35 +0000)
committerouv <ouv@opencascade.com>
Fri, 11 Dec 2009 09:35:20 +0000 (09:35 +0000)
idl/GEOM_Gen.idl
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I/GEOM_Gen_i.hh
src/GEOM_I/GEOM_IOperations_i.cc
src/GEOM_I/GEOM_Object_i.cc
src/GEOM_I/GEOM_Object_i.hh

index 1951cbe02ecf8ece703d895a18d40395d9b7a9f2..a2aac3e4d9a71e2be4b0312f60f08f6e3e33f462 100644 (file)
@@ -3201,12 +3201,6 @@ module GEOM
     ListOfGO PublishNamedShapesInStudy(in SALOMEDS::Study theStudy,
                                             //in SObject theSObject,
                                             in Object theObject);
-
-    /*!
-     *  Returns a pointer to SALOME Notebook interface.
-     *  \param theStudyID is a SALOMEDS Study ID
-     */
-    SALOME::Notebook GetNotebook(in long theStudyID);
   };
 };
 
index bff850673e108cb302670ac5f1e388db9678d837..adb3180e10e81589979061eab05c63f39f3b5912 100644 (file)
 
 #include "SALOMEDS_Tool.hxx"
 
+// Static variables definition
+PortableServer::POA_var GEOM_Gen_i::myPoa;
+
+//=============================================================================
+// function : GetServant()
+// purpose  : Get servant of the CORBA object
+//=============================================================================
+PortableServer::ServantBase_var GEOM_Gen_i::GetServant( CORBA::Object_ptr theObject )
+{
+  if( CORBA::is_nil( theObject ) || CORBA::is_nil( GetPOA() ) )
+    return NULL;
+  try {
+    PortableServer::Servant aServant = GetPOA()->reference_to_servant( theObject );
+    return aServant;
+  } 
+  catch (...) {
+    INFOS( "GetServant - Unknown exception was caught!!!" ); 
+    return NULL;
+  }
+}
+
 //============================================================================
 // function : GEOM_Gen_i()
 // purpose  : constructor to be called for servant creation.
@@ -73,6 +94,8 @@ GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb,
                       const char *interfaceName) :
   Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
 {
+  myPoa = PortableServer::POA::_duplicate(poa);
+
   _thisObj = this;
   _id = _poa->activate_object(_thisObj);
   name_service = new SALOME_NamingService(_orb);
@@ -321,27 +344,8 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
   aNameAttrib->Destroy();
 
   //Set NoteBook variables used in the object creation
-  /*ASL: temporary commented
-  TCollection_AsciiString aVars;
-  CORBA::String_var aString=aShape->GetParameters();
-  SALOMEDS::ListOfListOfStrings_var aSections = theStudy->ParseVariables(aString);
-  for(int i = 0, n = aSections->length(); i < n; i++) {
-    SALOMEDS::ListOfStrings aListOfVars = aSections[i];
-    for(int j = 0, m = aListOfVars.length(); j < m; j++) {
-      if(theStudy->IsVariable(aListOfVars[j].in()))
-       aVars += TCollection_AsciiString(aListOfVars[j].in());
-      if(j != m-1)
-       aVars += ":";
-    }
-    if(i != n-1)
-      aVars += "|";
-  }
-
-  anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString");
-  SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow(anAttr);
-  aStringAttrib->SetValue(aVars.ToCString());
-  aStringAttrib->Destroy();
-  */
+  if( GEOM_Object_i* aServant = dynamic_cast<GEOM_Object_i*>( GetServant( aShape ).in() ) )
+    aServant->UpdateStringAttribute();
 
   aFather->Destroy();
 
@@ -1816,14 +1820,24 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
 }
 
 //=================================================================================
-// function : GetNotebook()
-// purpose  : Returns a pointer to SALOME Notebook object by an id of the study
+// function : GetStudy()
+// purpose  : Returns a pointer to SALOMEDS Study object by its id
 //=================================================================================
-SALOME::Notebook_ptr GEOM_Gen_i::GetNotebook( CORBA::Long theStudyID )
+SALOMEDS::Study_ptr GEOM_Gen_i::GetStudy(CORBA::Long theStudyID)
 {
   CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" );
   SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
   SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( theStudyID );
+  return aStudy._retn();
+}
+
+//=================================================================================
+// function : GetNotebook()
+// purpose  : Returns a pointer to SALOME Notebook object by an id of the study
+//=================================================================================
+SALOME::Notebook_ptr GEOM_Gen_i::GetNotebook( CORBA::Long theStudyID )
+{
+  SALOMEDS::Study_ptr aStudy = GetStudy( theStudyID );
   SALOME::Notebook_var aNotebook = aStudy->GetNotebook();
   return aNotebook._retn();
 }
index 967cd9ca5b6e71cc05cd94cd880d39b3d29c2a70..a28e6bc02c38112cf56f230513493b0a63289ede 100644 (file)
@@ -62,6 +62,15 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
 {
  public:
 
+  //-----------------------------------------------------------------------//
+  // Static methods                                                        //
+  //-----------------------------------------------------------------------//
+
+  // Get SMESH module's POA object
+  static PortableServer::POA_var GetPOA() { return myPoa;}
+  // Get object of the CORBA reference
+  static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
+
   //-----------------------------------------------------------------------//
   // Constructor / Destructor                                              //
   //-----------------------------------------------------------------------//
@@ -242,6 +251,7 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   virtual bool hasObjectInfo();
   virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
   
+  SALOMEDS::Study_ptr GetStudy(CORBA::Long theStudyID);
   SALOME::Notebook_ptr GetNotebook(CORBA::Long theStudyID);
   
   //-----------------------------------------------------------------------//
@@ -276,6 +286,7 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
                             GEOM::ListOfGO_var aResList);
 
  private:
+  static PortableServer::POA_var myPoa; // POA reference
 
    ::GEOMImpl_Gen* _impl;
    SALOME_NamingService * name_service;
index 5116b98cf65056e6c190de05c44684f18bbaaa7e..81086012eda10f710980b185be2e7ea0218fd32f 100644 (file)
@@ -20,6 +20,7 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 #include "GEOM_IOperations_i.hh"
+#include "GEOM_Gen_i.hh"
 
 #include "GEOM_Engine.hxx"
 
@@ -139,7 +140,8 @@ GEOM::GEOM_Object_ptr GEOM_IOperations_i::GetObject(Handle(GEOM_Object) theObjec
   GO = _engine->GetObject(theObject->GetDocID(), anEntry.ToCString());
   GEOM::GEOM_Object_ptr aResult = GO._retn();
   if (theIsDependent && !CORBA::is_nil(aResult)) {
-    SALOME::Notebook_ptr aNotebook = _engine->GetNotebook(aResult->GetStudyID());
+    GEOM_Gen_i* aGEOMGen = dynamic_cast<GEOM_Gen_i*>(GEOM_Gen_i::GetServant(_engine).in());
+    SALOME::Notebook_ptr aNotebook = aGEOMGen->GetNotebook(aResult->GetStudyID());
     if (!CORBA::is_nil(aNotebook))
       aResult->StoreDependencies(aNotebook);
   }
index 2e9b99946cd047c5211c2b4d61b90395ff844919..83e536debb16c5c678c50f4ea4707a4deacb3770 100644 (file)
@@ -22,6 +22,7 @@
 #include <Standard_OStream.hxx>
 
 #include <GEOM_Object_i.hh>
+#include <GEOM_Gen_i.hh>
 #include <GEOM_ISubShape.hxx>
 #include <GEOM_Engine.hxx>
 #include <GEOMImpl_Types.hxx>
@@ -446,6 +447,8 @@ void GEOM_Object_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOM
     aFunc->SetParam( i+1, TCollection_AsciiString( aParam.c_str() ) );
     _parameters.push_back( aParam );
   }
+
+  UpdateStringAttribute();
 }
 
 SALOME::StringArray* GEOM_Object_i::GetParameters()
@@ -529,3 +532,37 @@ void GEOM_Object_i::StoreDependencies( SALOME::Notebook_ptr theNotebook )
     theNotebook->AddDependency( _this(), obj._retn() );
   }
 }
+
+void GEOM_Object_i::UpdateStringAttribute()
+{
+  GEOM_Gen_i* aGEOMGen = dynamic_cast<GEOM_Gen_i*>( GEOM_Gen_i::GetServant( _engine ).in() );
+
+  SALOME::Notebook_ptr aNotebook = aGEOMGen->GetNotebook( GetStudyID() );
+
+  SALOME::StringArray* anObjectParameters = aNotebook->GetObjectParameters( GetComponent(), GetEntry() );
+  int aParametersLength = anObjectParameters ? anObjectParameters->length() : 0;
+  if( aParametersLength == 0 )
+    return;
+
+  SALOMEDS::Study_ptr aStudy = aGEOMGen->GetStudy( GetStudyID() );
+  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+  SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( GetStudyEntry() );
+  if( CORBA::is_nil( aSObject ) )
+    return;
+
+  SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute( aSObject, "AttributeString" );
+  SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow( anAttr );
+
+  std::string aString;
+  for( int i = 0, n = anObjectParameters->length(); i < n; i++ ) {
+    std::string aParameter = anObjectParameters->operator[](i).in();
+    if( aParameter != "" )
+    {
+      if( aString != "" )
+        aString += ", ";
+      aString += aParameter;
+    }
+  }
+  aStringAttrib->SetValue( aString.c_str() );
+  aStringAttrib->Destroy();
+}
index d3e40bad09d007e7816fad28194c8d862df97c1c..97545edddbbc11117deecf0f2458fd6712e7e701 100644 (file)
@@ -104,6 +104,8 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public
 
   virtual void Update( SALOME::Notebook_ptr theNotebook );
 
+  virtual void UpdateStringAttribute();
+
   Handle(GEOM_Object) GetImpl() { return _impl; }
 
 private: