1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

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
This commit is contained in:
vpa 2016-03-18 14:26:07 +03:00 committed by bugmaster
parent 1511c7e90f
commit 7411850ad7
6 changed files with 64 additions and 19 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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();

32
tests/bugs/vis/bug27285 Normal file
View File

@ -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