Hi!
You can use the AddUser function of AIS_InteractiveObect to add some
information to displayed objects. AddUser only accepts variables of type
Standard_Transient, so you must first derive a class from Standard_Transient.
A simple class derived from Standard_Transient looks like this:
shapeinfo.hpp:
#include
#include
#include
#include
DEFINE_STANDARD_HANDLE (ShapeInfo, Standard_Transient)
class ShapeInfo : public Standard_Transient
{
public:
ShapeInfo();
virtual ~ShapeInfo();
DEFINE_STANDARD_RTTI(ShapeInfo)
public:
std::string m_name;
};
shapeinfo.cpp:
#include "shapeinfo.hpp"
IMPLEMENT_STANDARD_HANDLE (ShapeInfo, Standard_Transient)
IMPLEMENT_STANDARD_RTTI(ShapeInfo, Standard_Transient)
IMPLEMENT_STANDARD_TYPE (ShapeInfo)
IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
IMPLEMENT_STANDARD_TYPE_END (ShapeInfo)
ShapeInfo::ShapeInfo() : Standard_Transient()
{
}
ShapeInfo::~ShapeInfo()
{
}
You can then use
Handle_ShapeInfo si = new ShapeInfo();
intobj->AddUser( si );
for an AIS_InteractiveObject intobj.
To access the ShapeInfo just write
Handle_ShapeInfo si = Handle_ShapeInfo::DownCast( intobj->Users().First() );
Of course you should only do this if you know that the first object attached
to the AIS_InteractiveObject intobj has the type Handle_ShapeInfo.
Alternatively you can use a map with a key of type TopoDS_Shape or
Handle_AIS_InteractiveObject.
Commenter-1