1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-30 12:14:08 +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,11 +69,14 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode);
}
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Display(anIter.Value(), theMode);
}
}
}
// =======================================================================
// function : Erase
@ -81,11 +84,14 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
// =======================================================================
void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Erase(anIter.Value(), theMode);
}
}
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More();)
@ -123,11 +129,14 @@ void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)&
// =======================================================================
void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Clear(anIter.Value(), theMode);
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (!aPrs.IsNull())
@ -143,11 +152,14 @@ void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)&
void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode,
const Standard_Boolean theValue)
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetVisibility(anIter.Value(), theMode, theValue);
}
}
if (!thePrsObj->HasOwnPresentations())
{
return;
@ -165,11 +177,14 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj)
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Unhighlight(anIter.Value());
}
}
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
@ -191,11 +206,14 @@ void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObj
void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode,
const Standard_Integer theNewPrior) const
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetDisplayPriority(anIter.Value(), theMode, theNewPrior);
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (!aPrs.IsNull())
@ -210,6 +228,8 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
// =======================================================================
Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
@ -219,6 +239,7 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg
return aPriority;
}
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
return !aPrs.IsNull()
@ -232,6 +253,8 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg
// =======================================================================
Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
@ -240,6 +263,7 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr
return Standard_True;
}
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
return !aPrs.IsNull()
@ -252,6 +276,8 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr
// =======================================================================
Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
@ -260,6 +286,7 @@ Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_
return Standard_True;
}
}
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
return !aPrs.IsNull()
@ -522,11 +549,15 @@ Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(Pr
// =======================================================================
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Graphic3d_ZLayerId theLayerId)
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetZLayer(anIter.Value(), theLayerId);
}
}
if (!thePrsObj->HasOwnPresentations())
{
return;
@ -578,11 +609,14 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)&
const Standard_Integer theMode,
const Handle(PrsMgr_PresentableObject)& theSelObj,
const Standard_Integer theImmediateStructLayerId)
{
if (thePrsObj->ToPropagateVisualState())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Color(anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
}
}
if (!thePrsObj->HasOwnPresentations())
{
return;

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