From: eap Date: Fri, 12 Dec 2014 11:19:02 +0000 (+0300) Subject: + string GetSubName(in long subID); X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b01a3250a98f1ba90f0de6da68b3354fb2f02edb;p=modules%2Fgeom.git + string GetSubName(in long subID); --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 83faa46bb..cf576c3e9 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -382,6 +382,17 @@ module GEOM */ shape_type GetMaxShapeType(); + /*! + * \brief Returns a name of a sub-shape if the sub-shape is published in the study + * \param subID - sub-shape ID + * \return string - the found name or an empty string if the sub-shape does not + * exits or is not published + * + * \note Only sub-shapes directly retirieved (using e.g. ExtractSubShapes() or + * via group creation) can be found. + */ + string GetSubName(in long subID); + /*! * \brief Set color of the object. * diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index 54e5c458d..1defacdf5 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -158,6 +159,47 @@ GEOM::shape_type GEOM_Object_i::GetMaxShapeType() return getMinMaxShapeType( _impl->GetValue(), false ); } +//================================================================================ +/*! + * GetSubName + */ +//================================================================================ + +char* GEOM_Object_i::GetSubName(CORBA::Long subID) +{ + CORBA::String_var name(""); + + Handle(GEOM_Function) aMainFun = _impl->GetLastFunction(); + if ( aMainFun.IsNull() ) return name._retn(); + + const TDataStd_ListOfExtendedString& aListEntries = aMainFun->GetSubShapeReferences(); + TDataStd_ListIteratorOfListOfExtendedString anIt( aListEntries ); + for (; anIt.More(); anIt.Next()) + { + TCollection_AsciiString anEntry = anIt.Value(); + Handle(GEOM_BaseObject) anObj = + GEOM_Engine::GetEngine()->GetObject( _impl->GetDocID(), anEntry.ToCString(), false ); + if ( anObj.IsNull() ) continue; + + TCollection_AsciiString aSubName = anObj->GetName(); + if ( aSubName.IsEmpty() ) continue; + + Handle(GEOM_Function) aFun = anObj->GetLastFunction(); + if ( aFun.IsNull() ) continue; + + GEOM_ISubShape ISS( aFun ); + Handle(TColStd_HArray1OfInteger) subIDs = ISS.GetIndices(); + if ( subIDs.IsNull() || subIDs->Length() != 1 ) continue; + + if ( subIDs->Value( subIDs->Lower() ) == subID ) + { + name = aSubName.ToCString(); + break; + } + } + return name._retn(); +} + //============================================================================= /*! * SetColor diff --git a/src/GEOM_I/GEOM_Object_i.hh b/src/GEOM_I/GEOM_Object_i.hh index da7f035ed..3aee7f0f4 100644 --- a/src/GEOM_I/GEOM_Object_i.hh +++ b/src/GEOM_I/GEOM_Object_i.hh @@ -47,6 +47,8 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual GEOM::shape_type GetMaxShapeType(); + virtual char* GetSubName(CORBA::Long subID); + virtual void SetColor(const SALOMEDS::Color& theColor); virtual SALOMEDS::Color GetColor();