From 4d901cde7ceb1bafaf684c15f4ee005a62bc74bb Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 26 Jan 2017 17:16:09 +0300 Subject: [PATCH] 0028365: Visualization, AIS_InteractiveContext - apply selection filter in AddOrRemoveSelected at Neutral point --- src/AIS/AIS_InteractiveContext_1.cxx | 3 ++ src/ViewerTest/ViewerTest.cxx | 63 ++++++++++++++++++++++++++++ tests/bugs/vis/bug28365 | 21 ++++++++++ 3 files changed, 87 insertions(+) create mode 100644 tests/bugs/vis/bug28365 diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 8cfcb6e1d1..0c181b46b5 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -1183,6 +1183,9 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO if (theOwner.IsNull() || !theOwner->HasSelectable()) return; + if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected()) + return; + AIS_SelectStatus aSelStat = mySelection->Select (theOwner); theOwner->SetSelected (aSelStat == AIS_SS_Added); const Handle(AIS_InteractiveObject) anObj = diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index bdb5c6fe27..58ec6a6c94 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -4947,6 +4947,62 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** return 0; } +//======================================================================= +//function : VSetFilter +//purpose : +//======================================================================= +static int VSetFilter(Draw_Interpretor& theDi, Standard_Integer theArgc, + const char** theArgv) +{ + if (theArgc != 2) + { + theDi << theArgv[0] << " error : wrong number of parameters.\n"; + return 1; + } + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + std::cout << "Error: AIS context is not available.\n"; + return 1; + } + + TCollection_AsciiString anArg(theArgv[1]); + if (anArg.IsEqual("-clear")) { + aContext->RemoveFilters(); + } + else { + TCollection_AsciiString aPName, aPValue; + if (!ViewerTest::SplitParameter (anArg, aPName, aPValue)) { + std::cout << "Error: wrong command attribute name" << std::endl; + return 1; + } + + TopAbs_ShapeEnum aType = TopAbs_COMPOUND; + if(aPValue.IsEqual("VERTEX")) aType = TopAbs_VERTEX; + else if (aPValue.IsEqual("EDGE")) aType = TopAbs_EDGE; + else if (aPValue.IsEqual("WIRE")) aType = TopAbs_WIRE; + else if (aPValue.IsEqual("FACE")) aType = TopAbs_FACE; + else if(aPValue.IsEqual("SHAPE")) aType = TopAbs_SHAPE; + else if (aPValue.IsEqual("SHELL")) aType = TopAbs_SHELL; + else if (aPValue.IsEqual("SOLID")) aType = TopAbs_SOLID; + else { + std::cout << "Error: wrong command attribute value" << std::endl; + return 1; + } + + if(aType==TopAbs_SHAPE){ + Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter(AIS_KOI_Shape); + aContext->AddFilter(aFilter); + } + else{ + Handle(StdSelect_ShapeTypeFilter) aFilter = new StdSelect_ShapeTypeFilter(aType); + aContext->AddFilter(aFilter); + } + } + return 0; +} + //======================================================================= //function : VPickSelected //purpose : @@ -5839,6 +5895,13 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: Reads shape from BREP-format file and displays it in the viewer. ", __FILE__,vr, group); + theCommands.Add("vsetfilter", + "vsetfilter [-type={VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] [-clear]" + "\nSets selection shape type filter in context or remove all filters." + "\n : Option -type set type of selection filter. Filters are applyed with Or combination." + "\n : Option -clear remove all filters in context", + __FILE__,VSetFilter,group); + theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.", __FILE__, VPickSelected, group); diff --git a/tests/bugs/vis/bug28365 b/tests/bugs/vis/bug28365 new file mode 100644 index 0000000000..b9cc399030 --- /dev/null +++ b/tests/bugs/vis/bug28365 @@ -0,0 +1,21 @@ +puts "===========" +puts "OCC28365" +puts "===========" +puts "" +########################################################################## +# Visualization, AIS_InteractiveContext - apply selection filter in +# AddOrRemoveSelected at Neutral point +########################################################################## + +pload ALL +vinit +box b 10 10 10 +vdisplay b +vfit +vsetfilter -type=VERTEX +vchangeselected b + +set NbSelected1 [vnbselected] +if { ${NbSelected1} != 0 } { + puts "Error : Vertex filter was not applyed" +}