mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0027757: Visualization - handle child objects in selection manager regardless of HasOwnPresentations() flag
- all methods of SelectMgr_SelectionManager now processes children first, then check HasOwnPresentations() flag; - test case for issue #27757 Small correction of test case for issue CR27757
This commit is contained in:
parent
c885cfda24
commit
520cde8769
@ -5242,6 +5242,35 @@ static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//function : OCC27757
|
||||||
|
//purpose : Creates a box that has a sphere as child object and displays it
|
||||||
|
//========================================================================
|
||||||
|
static Standard_Integer OCC27757 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
|
||||||
|
{
|
||||||
|
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
|
||||||
|
if (aCtx.IsNull())
|
||||||
|
{
|
||||||
|
std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
|
||||||
|
TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere (10.0).Shape();
|
||||||
|
gp_Trsf aTrsf;
|
||||||
|
aTrsf.SetTranslationPart (gp_Vec (20.0, 20.0, 0.0));
|
||||||
|
aSphere.Located (TopLoc_Location (aTrsf));
|
||||||
|
|
||||||
|
|
||||||
|
Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
|
||||||
|
Handle(AIS_Shape) aSphereObj = new AIS_Shape (aSphere);
|
||||||
|
aBoxObj->AddChild (aSphereObj);
|
||||||
|
aCtx->Display (aBoxObj, 1, 0, Standard_False);
|
||||||
|
aCtx->UpdateCurrentViewer();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
//function : Commands_19
|
//function : Commands_19
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -5369,5 +5398,8 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
|
|||||||
theCommands.Add ("OCC27700",
|
theCommands.Add ("OCC27700",
|
||||||
"OCC27700: Checks drawing text after setting interior style",
|
"OCC27700: Checks drawing text after setting interior style",
|
||||||
__FILE__, OCC27700, group);
|
__FILE__, OCC27700, group);
|
||||||
|
theCommands.Add ("OCC27757",
|
||||||
|
"OCC27757: Creates a box that has a sphere as child object and displays it",
|
||||||
|
__FILE__, OCC27757, group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,19 +165,16 @@ void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)&
|
|||||||
{
|
{
|
||||||
if (!myGlobal.Contains (theObject))
|
if (!myGlobal.Contains (theObject))
|
||||||
{
|
{
|
||||||
if (theObject->HasOwnPresentations())
|
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
||||||
{
|
{
|
||||||
SelectMgr_SequenceOfSelector aSelectors;
|
Load (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector, theMode);
|
||||||
aSelectors.Append (theSelector);
|
|
||||||
myLocal.Bind (theObject, aSelectors);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
|
||||||
{
|
|
||||||
Load (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector, theMode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!theObject->HasOwnPresentations())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SelectMgr_SequenceOfSelector aSelectors;
|
||||||
|
aSelectors.Append (theSelector);
|
||||||
|
myLocal.Bind (theObject, aSelectors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,6 +186,14 @@ void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)&
|
|||||||
//==================================================
|
//==================================================
|
||||||
void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject)& theObject)
|
void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject)& theObject)
|
||||||
{
|
{
|
||||||
|
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
||||||
|
{
|
||||||
|
Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!theObject->HasOwnPresentations())
|
||||||
|
return;
|
||||||
|
|
||||||
if (myGlobal.Contains (theObject))
|
if (myGlobal.Contains (theObject))
|
||||||
{
|
{
|
||||||
for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
|
for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
|
||||||
@ -228,13 +233,6 @@ void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject
|
|||||||
|
|
||||||
myLocal.UnBind (theObject);
|
myLocal.UnBind (theObject);
|
||||||
}
|
}
|
||||||
else if (!theObject->HasOwnPresentations())
|
|
||||||
{
|
|
||||||
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
|
||||||
{
|
|
||||||
Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
theObject->ClearSelections();
|
theObject->ClearSelections();
|
||||||
}
|
}
|
||||||
@ -298,16 +296,14 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
|
|||||||
if (!theSelector.IsNull() && !mySelectors.Contains (theSelector))
|
if (!theSelector.IsNull() && !mySelectors.Contains (theSelector))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!theObject->HasOwnPresentations())
|
for (PrsMgr_ListOfPresentableObjectsIter anChildIter (theObject->Children()); anChildIter.More(); anChildIter.Next())
|
||||||
{
|
{
|
||||||
for (PrsMgr_ListOfPresentableObjectsIter anChildIter (theObject->Children()); anChildIter.More(); anChildIter.Next())
|
Activate (Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value()), theMode, theSelector);
|
||||||
{
|
|
||||||
Activate (Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value()), theMode, theSelector);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!theObject->HasOwnPresentations())
|
||||||
|
return;
|
||||||
|
|
||||||
Standard_Boolean isComputed = Standard_False;
|
Standard_Boolean isComputed = Standard_False;
|
||||||
if (theObject->HasSelection (theMode))
|
if (theObject->HasSelection (theMode))
|
||||||
{
|
{
|
||||||
@ -399,16 +395,13 @@ void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableOb
|
|||||||
const Standard_Integer theMode,
|
const Standard_Integer theMode,
|
||||||
const Handle(SelectMgr_ViewerSelector)& theSelector)
|
const Handle(SelectMgr_ViewerSelector)& theSelector)
|
||||||
{
|
{
|
||||||
|
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
||||||
|
{
|
||||||
|
Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
|
||||||
|
}
|
||||||
|
|
||||||
if (!theObject->HasOwnPresentations())
|
if (!theObject->HasOwnPresentations())
|
||||||
{
|
|
||||||
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
|
||||||
{
|
|
||||||
Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean isInGlobal = myGlobal.Contains (theObject);
|
Standard_Boolean isInGlobal = myGlobal.Contains (theObject);
|
||||||
Standard_Boolean hasSelection = theMode == -1 ? Standard_True : theObject->HasSelection (theMode);
|
Standard_Boolean hasSelection = theMode == -1 ? Standard_True : theObject->HasSelection (theMode);
|
||||||
@ -459,17 +452,15 @@ Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr
|
|||||||
const Standard_Integer theMode,
|
const Standard_Integer theMode,
|
||||||
const Handle(SelectMgr_ViewerSelector)& theSelector) const
|
const Handle(SelectMgr_ViewerSelector)& theSelector) const
|
||||||
{
|
{
|
||||||
if (!theObject->HasOwnPresentations())
|
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
||||||
{
|
{
|
||||||
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
|
if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector))
|
||||||
{
|
return Standard_True;
|
||||||
if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector))
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Standard_False;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!theObject->HasOwnPresentations())
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
|
if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
|
26
tests/bugs/vis/bug27757
Normal file
26
tests/bugs/vis/bug27757
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "CR27757"
|
||||||
|
puts "Visualization - handle child objects in selection manager regardless of HasOwnPresentations() flag"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload VISUALIZATION QAcommands
|
||||||
|
|
||||||
|
vinit
|
||||||
|
|
||||||
|
# create box object that has sphere as a child object
|
||||||
|
OCC27757
|
||||||
|
vfit
|
||||||
|
|
||||||
|
# check if the sphere was activated in selection manager
|
||||||
|
# and is selectable
|
||||||
|
vselect 120 245
|
||||||
|
|
||||||
|
if {[vnbselected] != "1"} {
|
||||||
|
puts "Error: no object was selected; the sphere must be selected!"
|
||||||
|
}
|
||||||
|
if {[vreadpixel 145 285 name] != "GRAY80 1"} {
|
||||||
|
puts "Error: the sphere is not highlighted with selection color!"
|
||||||
|
}
|
||||||
|
|
||||||
|
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
Loading…
x
Reference in New Issue
Block a user