From: smh Date: Tue, 18 May 2004 11:38:33 +0000 (+0000) Subject: BUG 5885, Added a RemoveReference method as a pair to Addreference in SALOMEDS_StudyB... X-Git-Tag: Ecole_Ete_a6~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=89ac684983dc8222a8ae8b4889d7458f322f549e;p=modules%2Fkernel.git BUG 5885, Added a RemoveReference method as a pair to Addreference in SALOMEDS_StudyBuilder. Author: SRN --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 6184f8fb1..f019faf31 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -502,6 +502,14 @@ during each working session. void Addreference(in SObject anObject, in SObject theReferencedObject) ; + +/*! + Removes a reference from %anObject to another object. + \param anObject The %SObject which contains a reference +*/ + + void RemoveReference(in SObject anObject) ; + /*! Adds a directory in the %Study. \param theName String parameter defining the name of the directory. diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index df8bf416c..64eba6c88 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -671,6 +671,34 @@ SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); } +//============================================================================ +/*! Function : RemoveReference + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me) +{ + SALOMEDS::SObject_var theReferencedObject; + if(!me->ReferencedObject(theReferencedObject)) return; //No reference is found + + CheckLocked(); + TDF_Label Lab; + ASSERT(!CORBA::is_nil(me)); + CORBA::String_var meid = me->GetID(); + TDF_Tool::Label(_doc->GetData(),meid,Lab); + + Lab.ForgetAttribute(TDF_Reference::GetID()); + + TDF_Label RefLab; + ASSERT(!CORBA::is_nil(theReferencedObject)); + CORBA::String_var roid = theReferencedObject->GetID(); + TDF_Tool::Label(_doc->GetData(),roid,RefLab); + + RemoveAttribute(theReferencedObject, "AttributeTarget"); + //if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); +} + + //============================================================================ /*! Function : AddDirectory diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index 9b668f402..2b51ac838 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -122,6 +122,8 @@ public: virtual void Addreference(SALOMEDS::SObject_ptr me, SALOMEDS::SObject_ptr thereferencedObject); + virtual void RemoveReference(SALOMEDS::SObject_ptr me); + virtual void SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID); virtual bool IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID);