
Fri, 02/03/2012 - 17:42
Hello
I have a list of ~1000 TopoDS_Shapes i give to an AIS_InteractiveContext at the beginning of the program.
I want to hide/show specific shapes at the user's request.
however, this code for hiding a list of shapes will not work
Handle_TopTools_HSequenceOfShape shapes; //my shapes
Handle_AIS_Shape cur_shape = new AIS_Shape(TopoDS_Shape());
for(integer i = 1; i Length(); ++i)
{
cur_shape->Set(shapes->Value(i));
this->ais_context->Erase(cur_shape, Standard_False); //AIS_InteractiveContext::Erase()
}
this->ais_context->UpdateCurrentViewer();
I noticed that erasing shapes DOES work if Iretrieve already displayed objects via AIS_InteractiveContext::DisplayedObjects()
so i thought maybe i could compare the AIS_InteractiveObject, which i get from DisplayedObjects(), to the TopoDS_Shape.
i came up with this
AIS_ListOfInteractive object_list;
AIS_ListIteratorOfListOfInteractive list_iterator;
this->ais_context->DisplayedObjects(object_list);
//...iterate through the list
if(Handle_AIS_Shape::DownCast(list_iterator.Value())->Shape.IsSame(shapes->Value(i)))
{
this->ais_context->Erase(cur_shape, Standard_False);
}
but Erase() will never be called because isSame always returns false.
what can i do? Any suggestions/mistakes in my code?
Sun, 02/05/2012 - 22:47
Hi,
I'm use next for show or hide objects:
void DocumentCommon::UpdateFilter()
{
const TDF_Label &LabSat = myOCAFDoc->Main();
Handle_TPrsStd_AISPresentation prs;
Handle_TDataStd_Integer CurInt;
for (TDF_ChildIterator it(LabSat); it.More(); it.Next())
{
if (!it.Value().FindAttribute(TPrsStd_AISPresentation::GetID(),prs)) continue;
const TDF_Label &level0 = it.Value().FindChild(0,false);
if (level0.IsNull()) continue;
if (!level0.FindChild(20).FindAttribute(TDataStd_Integer::GetID(),CurInt)) continue;
const int FilterValue = CurInt->Get();
if (FilterValue<1 || FilterValue>21) continue;
if (viewFilters.at(FilterValue-1) == false)
prs->Erase(true);
else
prs->Display(true);
}
}
After objects that contains need filter displayed or hided and it's working cool with any version of OCC.