used-defined interactive objects

Hi there

I'm just starting with opencascade and struggling to define my own interactive objects. Is it OK to derive them from AIS_shape class or not? Has anyone out there done it? Any advice and tip on this matter wuld be greatly appreciated!


Francois Lauzon's picture

Hello Raya,
it depends on what kind of interactive you want to have. Here we have implement new interactive as well as using existing one. Could you give me some examples?


fhchina's picture

Can you give us some examples about how to implement new interactive? Thanks a lot.


ekiroglu's picture

Hello Raya,
If your own interactive objects need to have TDF_Attribute, i can help you. Otherwise, samples are good enough: have a look at User_Cylinder.cxx file in SampleAISSelect.
But please be more specific.


David Jorge's picture

I'm creating my own interactive object and they need to have a TDF_Attribute. Can you help me?

ekiroglu's picture

Hello David,

I assume that you have managed to create your own interactive object. Now, you should create another class derived from TDF_Attribute, like the source file TDataStd_Axis.cxx, or like similar files in "TDataStd" directory. Then, another class is needed. This class will be derived from TPrsStd_Driver class and will have only a method called "Update( const TDF_Label& aLabel, Handle( AIS_InteractiveObject )& anAISObject ); Like TPrsStd_AxisDriver.cxx class in TPrsStd directory. This class is a critical one, here, your own interactive object (another words, display modes of your own interactive object) will be linked to the label you have created.

After you create these classes, the procedure goes like this :

TDF_Label LF = R.Root().FindChild( aNumber, Standard_True);
// Fill in the label with some data
TDataStd_Name::Set(LF, Name);


Handle( TPrsStd_AxisDriver ) Driver = new TPrsStd_AxisDriver();
Handle(TPrsStd_DriverTable) table = TPrsStd_DriverTable::Get();
Standard_GUID Guid = TDataStd_Axis::GetID();
table->AddDriver( Guid, Driver );

Handle( TPrsStd_AxisDriver ) aDriver;
TDataStd_Frame::Set( LF, parameters... ); // Insert your geometric or topological shape here as a parameter

if( table->FindDriver( TDataStd_Axis::GetID(), aDriver ) )
Handle(AIS_InteractiveObject) aisobject;
aDriver->Update( LF, aisobject); // linking your own interactive object with the label

Handle(TPrsStd_AISPresentation) Prs = TPrsStd_AISPresentation::Set( LF, TDataStd_Axis::GetID() );
Prs->Display( 1 );

I hope that this will be helpful
Best Regards,

ekiroglu's picture

An addition to the previous message,

TDataStd_Axis.cxx class carries geometric data
AIS_Axis.cxx is display modes of that geometric data
TPrsStd_AxisDriver.cxx is the linkage.


David Jorge's picture

Thank you erki for the tips.

ekiroglu's picture

A correction

Handle( TPrsStd_AxisDriver ) aDriver; // Not TDataStd_Frame, sorry.
TDataStd_Axis::Set( LF, parameters... ); // Insert your geometric or topological shape here as a parameter

Andy O.'s picture

Your code has been a lot of help, but I was wonder how can you retrieve the label from the selected context. I have this so far:
Handle(AIS_InteractiveObject) curAISObject = context->Current();
I think I need to use a downcast method, but I am not to sure how to.