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);
};
};
#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.
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);
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();
}
//=================================================================================
-// 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();
}
{
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 //
//-----------------------------------------------------------------------//
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);
//-----------------------------------------------------------------------//
GEOM::ListOfGO_var aResList);
private:
+ static PortableServer::POA_var myPoa; // POA reference
::GEOMImpl_Gen* _impl;
SALOME_NamingService * name_service;
// 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"
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);
}
#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>
aFunc->SetParam( i+1, TCollection_AsciiString( aParam.c_str() ) );
_parameters.push_back( aParam );
}
+
+ UpdateStringAttribute();
}
SALOME::StringArray* GEOM_Object_i::GetParameters()
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();
+}
virtual void Update( SALOME::Notebook_ptr theNotebook );
+ virtual void UpdateStringAttribute();
+
Handle(GEOM_Object) GetImpl() { return _impl; }
private: