*/
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.
*
#include <TCollection_AsciiString.hxx>
#include <TDF_Label.hxx>
#include <TDF_Tool.hxx>
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Iterator.hxx>
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