OCAF Framework presentation or manual management of the display item

karim

CAD community veteran
I am at the point where I want to add my items to the display. Two options come to mind. using the OCAF framework display or enumerating ocaf document and adding items to display manually (like occqt sample code).

Which way is better ? (i want to select and add properties to items later on).
 

JSlyadne

Administrator
Staff member
Hey! Could you elaborate a bit more on where we are and what you're trying to achieve? What items do you mean? Where are they to be displayed - UI forms or 3D scene?
 

Quaoar

Administrator
Staff member
I am at the point where I want to add my items to the display. Two options come to mind. using the OCAF framework display or enumerating ocaf document and adding items to display manually (like occqt sample code).

Which way is better ? (i want to select and add properties to items later on).
I would recommend avoiding using any OCAF attributes related to the presentation and building your own presentations. That's because OCAF is a "backend" thing that should not basically deal with UI within itself.
 

karim

CAD community veteran
How to enumerate and add named shapes to the context ? is there a tool for that or should I do it manually ?
 

JSlyadne

Administrator
Staff member
For the shapes to be displayed you have to create a presentable object - the instance of AIS_InteractiveObject class, and pass it to the visualization context (AIS_InteractiveContext class). Maybe, the capabilities of AIS_Shape class will be enough for your needs, take a look.

And yup, there is no tool that would feed the visualization context out of OCAF tree. This stuff closely depends on the application requirements and specificity.
 

karim

CAD community veteran
I came up with this code. Nothing new in it. later on i will use specific labels to enumerate the objects, but for the time being I enumerate all the labels for named shapes. Any improvements ?

TDF_Label root = doc->Main();

for (TDF_ChildIterator it (root, Standard_True); it.More(); it.Next())
{
auto label = it.Value(); // get the label.
Handle(TNaming_NamedShape) namedshape;
if(label.FindAttribute(TNaming_NamedShape::GetID(), namedshape))
{
TopoDS_Shape shape = TNaming_Tool::GetShape(namedshape);
auto ais_shape = new AIS_Shape(shape);
myOccView->getContext()->Display(ais_shape, Standard_True);
}

}
 
Top