// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <PrsMgr_PresentationManager.hxx>
-#include <Geom_Transformation.hxx>
+#include <TopLoc_Datum3D.hxx>
#include <Graphic3d_GraphicDriver.hxx>
+#include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_PresentationShadow.hxx>
-#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentableObject.hxx>
#include <PrsMgr_Presentation.hxx>
-#include <PrsMgr_PresentationManager.hxx>
#include <PrsMgr_Presentations.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_Type.hxx>
#include <TColStd_ListIteratorOfListOfTransient.hxx>
#include <V3d_View.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentationManager,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient)
// =======================================================================
// function : PrsMgr_PresentationManager
// =======================================================================
PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager)
: myStructureManager (theStructureManager),
- myImmediateModeOn (0),
- mySelectionColor (Quantity_NOC_GRAY99)
+ myImmediateModeOn (0)
{
//
}
if (myImmediateModeOn > 0)
{
- AddToImmediateList (aPrs->Presentation());
+ AddToImmediateList (aPrs);
}
else
{
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);
+ }
}
}
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();
- for (PrsMgr_Presentations::Iterator anIt (aPrsList); anIt.More();)
+ for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More();)
{
- const PrsMgr_ModedPresentation& aModedPrs = anIt.Value();
- if (aModedPrs.Presentation().IsNull())
+ const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
+ if (aPrs.IsNull())
{
- anIt.Next();
+ aPrsIter.Next();
continue;
}
- const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager();
- if ((theMode == aModedPrs.Mode() || theMode == -1)
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
+ if ((theMode == aPrs->Mode() || theMode == -1)
&& (this == aPrsMgr))
{
- aModedPrs.Presentation()->Erase();
+ aPrs->Erase();
- aPrsList.Remove (anIt);
+ aPrsList.Remove (aPrsIter);
if (theMode != -1)
{
}
else
{
- anIt.Next();
+ aPrsIter.Next();
}
}
}
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);
const Standard_Integer theMode,
const Standard_Boolean theValue)
{
- for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
- {
- SetVisibility (anIter.Value(), theMode, theValue);
- }
- if (!thePrsObj->HasOwnPresentations())
+ if (thePrsObj->ToPropagateVisualState())
{
- return;
- }
-
- Presentation (thePrsObj, theMode)->SetVisible (theValue);
-}
-
-// =======================================================================
-// function : Highlight
-// purpose :
-// =======================================================================
-void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theMode)
-{
- for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
- {
- Highlight (anIter.Value(), theMode);
+ for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
+ {
+ SetVisibility(anIter.Value(), theMode, theValue);
+ }
}
if (!thePrsObj->HasOwnPresentations())
{
return;
}
- Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True);
- if (aPrs->MustBeUpdated())
- {
- Update (thePrsObj, theMode);
- }
-
- if (myImmediateModeOn > 0)
- {
- Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation());
- aShadow->Highlight (Aspect_TOHM_COLOR, mySelectionColor);
- AddToImmediateList (aShadow);
- }
- else
+ Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ if (!aPrs.IsNull())
{
- aPrs->Highlight (Aspect_TOHM_COLOR, mySelectionColor);
+ aPrs->SetVisible (theValue);
}
}
// function : Unhighlight
// purpose :
// =======================================================================
-void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theMode)
+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(), theMode);
+ for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
+ {
+ Unhighlight(anIter.Value());
+ }
}
- const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
- if (!aPrs.IsNull())
+ const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
+ for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
{
- aPrs->Unhighlight();
+ const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
+ if (this == aPrsMgr
+ && aPrs->IsHighlighted())
+ {
+ aPrs->Unhighlight();
+ }
}
}
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);
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;
+ }
}
}
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;
+ }
}
}
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;
+ }
}
}
// =======================================================================
void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& theViewer)
{
- for (theViewer->InitActiveViews(); theViewer->MoreActiveViews(); theViewer->NextActiveViews())
+ for (V3d_ListOfViewIterator anActiveViewIter (theViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
- const Handle(Graphic3d_CView)& aView = theViewer->ActiveView()->View();
+ const Handle(Graphic3d_CView)& aView = anActiveViewIter.Value()->View();
for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
{
const Handle(Prs3d_Presentation)& aPrs = anIter.Value();
Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs);
if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs))
{
+ const Graphic3d_ZLayerId aZLayer = aShadowPrs->GetZLayer();
aShadowPrs.Nullify();
- aShadowPrs = new Prs3d_PresentationShadow (myStructureManager,
- Handle(Prs3d_Presentation)::DownCast (aViewDepPrs));
- aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer());
+
+ aShadowPrs = new Prs3d_PresentationShadow (myStructureManager, aViewDepPrs);
+ aShadowPrs->SetZLayer (aZLayer);
aShadowPrs->SetClipPlanes (aViewDepPrs->ClipPlanes());
aShadowPrs->CStructure()->IsForHighlight = 1;
- aShadowPrs->Highlight (Aspect_TOHM_COLOR, aPrs->HighlightColor());
+ aShadowPrs->Highlight (aPrs->HighlightStyle());
myViewDependentImmediateList.Append (aShadowPrs);
}
// handles custom highlight presentations which were defined in overridden
return Standard_False;
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
- for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
+ for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
{
- const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter);
- const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager();
- if (theMode == aModedPrs.Mode()
+ const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
+ if (theMode == aPrs->Mode()
&& this == aPrsMgr)
{
return Standard_True;
const Handle(PrsMgr_PresentableObject)& theSelObj) const
{
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
- for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
+ for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
{
- const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter);
- const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager();
- if (theMode == aModedPrs.Mode()
+ const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
+ if (theMode == aPrs->Mode()
&& this == aPrsMgr)
{
- return aModedPrs.Presentation();
+ return aPrs;
}
}
return Handle(PrsMgr_Presentation)();
}
- Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj);
+ Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj, theMode);
aPrs->SetZLayer (thePrsObj->ZLayer());
- aPrs->Presentation()->CStructure()->ViewAffinity = myStructureManager->ObjectAffinity (!theSelObj.IsNull() ? theSelObj : thePrsObj);
- thePrsObj->Presentations().Append (PrsMgr_ModedPresentation (aPrs, theMode));
+ aPrs->CStructure()->ViewAffinity = myStructureManager->ObjectAffinity (!theSelObj.IsNull() ? theSelObj : thePrsObj);
+ thePrsObj->Presentations().Append (aPrs);
thePrsObj->Fill (this, aPrs, theMode);
// set layer index accordingly to object's presentations
const Standard_Integer theMode)
{
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
- for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
+ for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
{
- const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter);
- const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager();
- if (theMode == aPrsList (aPrsIter).Mode()
+ const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
+ if (theMode == aPrs->Mode()
&& this == aPrsMgr)
{
aPrsList.Remove (aPrsIter);
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theLayerId)
+ 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;
// function : GetZLayer
// purpose :
// =======================================================================
-Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const
+Graphic3d_ZLayerId PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const
{
return thePrsObj->ZLayer();
}
{
Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObject, theMode, Standard_True);
Handle(PrsMgr_Presentation) aPrsOther = Presentation (theOtherObject, theOtherMode, Standard_True);
- aPrs->Connect (aPrsOther);
+ aPrs->Connect (aPrsOther.get(), Graphic3d_TOC_DESCENDANT);
}
// =======================================================================
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Handle(Geom_Transformation)& theTransformation,
- const Standard_Integer theMode)
+ const Handle(TopLoc_Datum3D)& theTransformation,
+ const Standard_Integer theMode)
{
Presentation (thePrsObj, theMode)->SetTransformation (theTransformation);
}
-
// =======================================================================
// function : Color
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Quantity_NameOfColor theColor,
+ const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode,
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(), theColor, theMode, NULL, theImmediateStructLayerId);
+ for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
+ {
+ Color(anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
+ }
}
if (!thePrsObj->HasOwnPresentations())
{
if (myImmediateModeOn > 0)
{
- Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation());
+ Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs);
aShadow->SetZLayer (theImmediateStructLayerId);
- aShadow->SetClipPlanes (aPrs->Presentation()->ClipPlanes());
+ aShadow->SetClipPlanes (aPrs->ClipPlanes());
aShadow->CStructure()->IsForHighlight = 1;
- aShadow->Highlight (Aspect_TOHM_COLOR, theColor);
+ aShadow->Highlight (theStyle);
AddToImmediateList (aShadow);
}
else
{
- aPrs->Highlight (Aspect_TOHM_COLOR, theColor);
+ aPrs->Highlight (theStyle);
}
}
-// =======================================================================
-// function : BoundBox
-// purpose :
-// =======================================================================
-void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theMode)
-{
- Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True);
- if (aPrs->MustBeUpdated())
- {
- Update (thePrsObj, theMode);
- }
- aPrs->Highlight (Aspect_TOHM_BOUNDBOX, mySelectionColor);
-}
-
namespace
{
- // =======================================================================
- // function : updatePrsTransformation
- // purpose : Internal function that scans thePrsList for shadow presentations
- // and applies transformation theTrsf to them in case if parent ID
- // of shadow presentation is equal to theRefId
- // =======================================================================
- void updatePrsTransformation (const PrsMgr_ListOfPresentations& thePrsList,
- const Standard_Integer theRefId,
- const Handle(Geom_Transformation)& theTrsf)
+ //! Internal function that scans thePrsList for shadow presentations
+ //! and applies transformation theTrsf to them in case if parent ID
+ //! of shadow presentation is equal to theRefId
+ static void updatePrsTransformation (const PrsMgr_ListOfPresentations& thePrsList,
+ const Standard_Integer theRefId,
+ const Handle(TopLoc_Datum3D)& theTrsf)
{
for (PrsMgr_ListOfPresentations::Iterator anIter (thePrsList); anIter.More(); anIter.Next())
{
if (theObj.IsNull())
return;
- const Handle(Prs3d_Presentation)& aBasePrs = Presentation (theObj, theMode, Standard_False)->Presentation();
- const Handle(Prs3d_Presentation)& aParentPrs = theSelObj.IsNull() ?
- aBasePrs : Presentation (theSelObj, theMode, Standard_False)->Presentation();
- const Standard_Integer aParentId = aParentPrs->CStructure()->Id;
+ Handle(PrsMgr_Presentation) aPrs = Presentation (!theSelObj.IsNull() ? theSelObj : theObj, theMode, Standard_False);
+ if (aPrs.IsNull())
+ {
+ return;
+ }
- updatePrsTransformation (myImmediateList, aParentId, aBasePrs->CStructure()->Transformation());
+ Handle(TopLoc_Datum3D) aTrsf = theObj->LocalTransformationGeom();
+ const Standard_Integer aParentId = aPrs->CStructure()->Id;
+ updatePrsTransformation (myImmediateList, aParentId, aTrsf);
if (!myViewDependentImmediateList.IsEmpty())
{
- for (theViewer->InitActiveViews(); theViewer->MoreActiveViews(); theViewer->NextActiveViews())
+ for (V3d_ListOfViewIterator anActiveViewIter (theViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
- const Handle(Graphic3d_CView)& aView = theViewer->ActiveView()->View();
+ const Handle(Graphic3d_CView)& aView = anActiveViewIter.Value()->View();
Handle(Graphic3d_Structure) aViewDepParentPrs;
if (aView->IsComputed (aParentId, aViewDepParentPrs))
{
updatePrsTransformation (myViewDependentImmediateList,
aViewDepParentPrs->CStructure()->Id,
- aBasePrs->CStructure()->Transformation());
+ aTrsf);
}
}
}