Tue, 01/27/2026 - 10:47
this is code in .\samples\OCCTOverview\code\OcafSamples.cxx in the repository
// Get the TPrsStd_AISPresentation of the new box TNaming_NamedShape
Handle(TPrsStd_AISPresentation) anAisPresentation = TPrsStd_AISPresentation::Set(aLabel, TNaming_NamedShape::GetID());
// Display it
anAisPresentation->Display(1);
anAisPresentation->SetSelectionMode(0);
// Attach an integer attribute to aLabel to memorize it's displayed
TDataStd_Integer::Set(aLabel, 1);
myContext->UpdateCurrentViewer();
i set the SetSelectionMode, but it doesn't work.
please help me
thanks
Attachments:
Tue, 01/27/2026 - 17:43
This is a bug in the sample.
TPrsStd_AISViewerdisplays the object within a dedicatedAIS_InteractiveContext, whileAIS_InteractiveContext::MoveTo()is done for anotherAIS_InteractiveContext(where you seeAIS_ViewCube).Managing two
AIS_InteractiveContextfor the sameV3d_Viewerrequires additional efforts at application level and is unlikely what normal application will do anyway.The simplest way to make object selectable in the sample is to assign already created
AIS_InteractiveContexttoTPrsStd_AISViewer(don't know if it has any side effects forTPrsStdlogic):This would, however, raise other errors/limitations in the sample like
OcafSamples::ModifyBoxOcafSample()not checking the type of iterated object type withinAIS_InteractiveContext.In general, I would rather NOT recommend to use
TPrsStdin a new application as this API breaks/complicates many aspects of a preferred/optimal way to useAISwithin modern applications by tightening up Data Model with 3D Viewer, which are better to be clearly separated. UseAIS_Shape,XCAFPrs_AISObjectdirectly for displaying shapes in 3D Viewer and explicitly manage persistence/synchronization of presentation aspects (if really needed).Wed, 01/28/2026 - 04:49
thank you