1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0030824: Visualization, PrsMgr_PresentableObject - A new flag to disable automatic selection of children

A new flag myToPropagateVisualState is introduced for PrsMgr_PresentableObject: by default it is true, it means that the visual state (display/erase/color) should be propagated to all children. If false, the visual state is not propagated.
The flag can be set via the method ToPropagateVisualState() or via Draw command: "vparent <parent> -ignoreVisu"
This commit is contained in:
asl 2019-07-03 11:29:47 +03:00 committed by apn
parent acc6542a1b
commit 0d56f7433b
6 changed files with 167 additions and 27 deletions

View File

@ -56,7 +56,8 @@ PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentat
//
myInfiniteState (Standard_False),
myIsMutable (Standard_False),
myHasOwnPresentations (Standard_True)
myHasOwnPresentations (Standard_True),
myToPropagateVisualState (Standard_True)
{
myDrawer->SetDisplayMode (-1);
}

View File

@ -528,6 +528,14 @@ public: //! @name deprecated methods
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
//! Get value of the flag "propagate visual state"
//! It means that the display/erase/color visual state is propagated automatically to all children;
//! by default, the flag is true
Standard_Boolean ToPropagateVisualState() const { return myToPropagateVisualState; }
//! Change the value of the flag "propagate visual state"
void SetPropagateVisualState(const Standard_Boolean theFlag) { myToPropagateVisualState = theFlag; }
protected:
//! Recomputes all presentations of the object.
@ -569,6 +577,7 @@ protected:
Standard_Boolean myIsMutable; //!< mutable flag
Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations
Standard_Boolean myToPropagateVisualState; //!< flag indicating if visual state (display/erase/color) should be propagated to all children
};
DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient)

View File

@ -69,9 +69,12 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode);
}
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Display (anIter.Value(), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Display(anIter.Value(), theMode);
}
}
}
@ -82,9 +85,12 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Erase (anIter.Value(), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Erase(anIter.Value(), theMode);
}
}
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
@ -124,9 +130,12 @@ void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)&
void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Clear (anIter.Value(), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Clear(anIter.Value(), theMode);
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
@ -144,9 +153,12 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
const Standard_Integer theMode,
const Standard_Boolean theValue)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
SetVisibility (anIter.Value(), theMode, theValue);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetVisibility(anIter.Value(), theMode, theValue);
}
}
if (!thePrsObj->HasOwnPresentations())
{
@ -166,9 +178,12 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
// =======================================================================
void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Unhighlight (anIter.Value());
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Unhighlight(anIter.Value());
}
}
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
@ -192,9 +207,12 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
const Standard_Integer theMode,
const Standard_Integer theNewPrior) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
SetDisplayPriority (anIter.Value(), theMode, theNewPrior);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetDisplayPriority(anIter.Value(), theMode, theNewPrior);
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
@ -211,12 +229,15 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Standard_Integer aPriority = DisplayPriority (anIter.Value(), theMode);
if (aPriority != 0)
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
return aPriority;
Standard_Integer aPriority = DisplayPriority(anIter.Value(), theMode);
if (aPriority != 0)
{
return aPriority;
}
}
}
@ -233,11 +254,14 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg
Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
if (IsDisplayed (anIter.Value(), theMode))
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
return Standard_True;
if (IsDisplayed(anIter.Value(), theMode))
{
return Standard_True;
}
}
}
@ -253,11 +277,14 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr
Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
if (IsHighlighted (anIter.Value(), theMode))
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
return Standard_True;
if (IsHighlighted(anIter.Value(), theMode))
{
return Standard_True;
}
}
}
@ -523,10 +550,14 @@ Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(Pr
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Graphic3d_ZLayerId theLayerId)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
SetZLayer (anIter.Value(), theLayerId);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetZLayer(anIter.Value(), theLayerId);
}
}
if (!thePrsObj->HasOwnPresentations())
{
return;
@ -579,9 +610,12 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)&
const Handle(PrsMgr_PresentableObject)& theSelObj,
const Standard_Integer theImmediateStructLayerId)
{
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
if (thePrsObj->ToPropagateVisualState())
{
Color (anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Color(anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
}
}
if (!thePrsObj->HasOwnPresentations())
{

View File

@ -4771,6 +4771,46 @@ static Standard_Integer VChild (Draw_Interpretor& ,
return 0;
}
//=======================================================================
//function : VParent
//purpose :
//=======================================================================
static Standard_Integer VParent(Draw_Interpretor&,
Standard_Integer theNbArgs,
const char** theArgVec)
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext.IsNull())
{
std::cout << "Error: no active view\n";
return 1;
}
if (theNbArgs < 2 )
{
std::cout << theArgVec[0] << " error: expect at least 2 arguments\n";
return 1;
}
TCollection_AsciiString aName(theArgVec[1]);
Handle(AIS_InteractiveObject) aParent;
if (!GetMapOfAIS().Find2(theArgVec[1], aParent))
{
std::cout << "Syntax error: object '" << theArgVec[1] << "' is not found\n";
return 1;
}
ViewerTest_AutoUpdater anUpdateTool(aContext, ViewerTest::CurrentView());
for (Standard_Integer anArgIter = 2; anArgIter < theNbArgs; ++anArgIter)
{
TCollection_AsciiString anArg(theArgVec[anArgIter]);
anArg.LowerCase();
if (anArg == "-ignorevisu")
aParent->SetPropagateVisualState(Standard_False);
}
return 0;
}
//===============================================================================================
//function : VSetSelectionMode
//purpose : vselmode
@ -6508,6 +6548,12 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"\n\t\t: Command for testing low-level presentation connections."
"\n\t\t: vconnect command should be used instead.",
__FILE__, VChild, group);
theCommands.Add("vparent",
"vparent parent [-ignoreVisu]"
"\n\t\t: Command for testing object properties as parent in the hierarchy."
"\n\t\t: Arguments:"
"\n\t\t: -ignoreVisu do not propagate the visual state (display/erase/color) to children objects",
__FILE__, VParent, group);
theCommands.Add ("vcomputehlr",
"vcomputehlr shapeInput hlrResult [-algoType {algo|polyAlgo}=polyAlgo]"
"\n\t\t: [eyeX eyeY eyeZ dirX dirY dirZ upX upY upZ]"

25
tests/bugs/vis/bug30823 Normal file
View File

@ -0,0 +1,25 @@
puts "============="
puts "0030823: Visualization, PrsMgr_PresentableObject - A new flag to disable automatic display/erase of children"
puts "============="
pload MODELING VISUALIZATION
vclear
vinit View1
psphere parent 3
vdisplay -dispMode 1 parent
box child1 1 1 1
box child2 1 1 1
vdisplay child1 -dispMode 1
vdisplay child2 -dispMode 1
vlocation child1 -setLocation 10 0 0
vlocation child2 -setLocation 20 0 0
vparent parent -ignoreVisu
vchild parent -ignoreParentTrsf -add child1
vchild parent -ignoreParentTrsf -add child2
vfit
verase parent
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

25
tests/bugs/vis/bug30824 Normal file
View File

@ -0,0 +1,25 @@
puts "============="
puts "0030824: Visualization, PrsMgr_PresentableObject - A new flag to disable automatic selection of children"
puts "============="
pload MODELING VISUALIZATION
vclear
vinit View1
psphere parent 3
vdisplay -dispMode 1 parent
box child1 1 1 1
box child2 1 1 1
vdisplay child1 -dispMode 1
vdisplay child2 -dispMode 1
vlocation child1 -setLocation 10 0 0
vlocation child2 -setLocation 20 0 0
vparent parent -ignoreVisu
vchild parent -ignoreParentTrsf -add child1
vchild parent -ignoreParentTrsf -add child2
vfit
vselect 0 0 200 200
checkview -screenshot -3d -path ${imagedir}/${test_image}.png