From 7411850ad7eb514cfb57668d35d6366e3241fe38 Mon Sep 17 00:00:00 2001 From: vpa Date: Fri, 18 Mar 2016 14:26:07 +0300 Subject: [PATCH] 0027285: Visualization - selection of AIS_MultipleConnectedInteractive is broken - method SelectMgr_SelectableObject::HasSelection became virtual, unnecessary variable was removed; - redefined HasSelection method for multiple connected interactives; - AIS_InteractiveContext::AddOrRemoveSelected was corrected to use global selection owner; - test case for issue #27285 --- src/AIS/AIS_InteractiveContext_1.cxx | 9 +----- src/AIS/AIS_MultipleConnectedInteractive.cxx | 19 ++++++++++++ src/AIS/AIS_MultipleConnectedInteractive.hxx | 3 ++ src/SelectMgr/SelectMgr_SelectableObject.cxx | 16 +++++----- src/SelectMgr/SelectMgr_SelectableObject.hxx | 4 +-- tests/bugs/vis/bug27285 | 32 ++++++++++++++++++++ 6 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 tests/bugs/vis/bug27285 diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 9b80e596f6..eaa9d9fd0b 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -1035,14 +1035,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveOb if (!theObject->HasInteractiveContext()) theObject->SetContext (this); - const Handle(SelectMgr_Selection)& aSel = theObject->Selection (aGlobalSelMode); - - if (aSel->IsEmpty()) - return; - - aSel->Init(); - const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId()); + const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); if (anOwner.IsNull() || !anOwner->HasSelectable()) return; diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 64da42d126..ed5cc6f377 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -402,3 +402,22 @@ Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() { return myAssemblyOwner; } + +//======================================================================= +//function : HasSelection +//purpose : +//======================================================================= +Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_Integer theMode) const +{ + for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) + { + Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); + if (aChild.IsNull()) + continue; + + if (!aChild->HasSelection (theMode)) + return Standard_False; + } + + return Standard_True; +} diff --git a/src/AIS/AIS_MultipleConnectedInteractive.hxx b/src/AIS/AIS_MultipleConnectedInteractive.hxx index 137010c8f2..c22b5bd774 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.hxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.hxx @@ -99,6 +99,9 @@ public: //! Returns the owner of mode for selection of object as a whole Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE; + //! Returns true if a selection corresponding to the selection mode theMode was computed for all + //! children of multiple connected interactive object. + Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const Standard_OVERRIDE; DEFINE_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject) diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index ab29dbe6e9..6a96a331bb 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -71,18 +71,16 @@ SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPrese //================================================== -// Function: +// Function: HasSelection // Purpose : //================================================== - -Standard_Boolean SelectMgr_SelectableObject -::HasSelection(const Standard_Integer aMode) const +Standard_Boolean SelectMgr_SelectableObject::HasSelection (const Standard_Integer theMode) const { - Standard_Boolean Found=Standard_False; - for (Standard_Integer I=1;I<= myselections.Length() && !Found;I++) - { if(((myselections.Value(I))->Mode())==aMode) - return Standard_True; - } + for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx) + { + if (((myselections.Value (aSelIdx))->Mode()) == theMode) + return Standard_True; + } return Standard_False; } diff --git a/src/SelectMgr/SelectMgr_SelectableObject.hxx b/src/SelectMgr/SelectMgr_SelectableObject.hxx index 78d20d253f..f7b8e7e740 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.hxx @@ -95,8 +95,8 @@ public: Standard_EXPORT const Handle(SelectMgr_Selection)& Selection (const Standard_Integer aMode) const; //! Returns true if a selection corresponding to the - //! selection mode aMode is present in this framework. - Standard_EXPORT Standard_Boolean HasSelection (const Standard_Integer aMode) const; + //! selection mode theMode was computed for this object. + Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const; //! Begins the iteration scanning for sensitive primitives. void Init(); diff --git a/tests/bugs/vis/bug27285 b/tests/bugs/vis/bug27285 new file mode 100644 index 0000000000..6e4477ff10 --- /dev/null +++ b/tests/bugs/vis/bug27285 @@ -0,0 +1,32 @@ +puts "========" +puts "OCC27285" +puts "========" +puts "" +################################################################## +puts "Visualization - selection of AIS_MultipleConnectedInteractive is broken" +################################################################## + +pload VISUALIZATION MODELING + +vinit +vsetdispmode 1 + +box b 100 100 100 +vdisplay b + +vconnect bc 0 0 300 b + +vfit + +vchangeselected b +vchangeselected bc + +if {[vnbselected] != "2"} { + puts "ERROR: only one object is selected" +} + +if {[string match *Selected* [vstate bc]] != "1"} { + puts "ERROR: multiple connected interactive object is not selected" +} + +set only_screen 1