// function : PrsMgr_PresentationManager
// purpose :
// =======================================================================
-PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager)
+PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Visual3d_ViewManager)& theStructureManager)
: myStructureManager (theStructureManager),
- myImmediateModeOn (0)
+ myImmediateModeOn (0),
+ mySelectionColor (Quantity_NOC_GRAY99)
{
//
}
{
if (thePrsObj->HasOwnPresentations())
{
- if (!HasPresentation (thePrsObj, theMode))
- {
- AddPresentation (thePrsObj, theMode);
- }
-
- Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
-
- if (aPrs.IsNull()) return;
-
+ Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True);
if (aPrs->MustBeUpdated())
{
Update (thePrsObj, theMode);
Erase (anIter.Value(), theMode);
}
- if (HasPresentation (thePrsObj, theMode))
+ PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
+ for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{
- Presentation (thePrsObj, theMode)->Erase();
- RemovePresentation (thePrsObj, theMode);
+ const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter);
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager();
+ if (theMode == aPrsList (aPrsIter).Mode()
+ && this == aPrsMgr)
+ {
+ if (!aModedPrs.Presentation().IsNull())
+ {
+ aModedPrs.Presentation()->Erase();
+ }
+ aPrsList.Remove (aPrsIter);
+ return;
+ }
}
}
Clear (anIter.Value(), theMode);
}
- if (HasPresentation (thePrsObj, theMode))
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ if (!aPrs.IsNull())
{
- Presentation (thePrsObj, theMode)->Clear();
+ aPrs->Clear();
}
}
return;
}
- if (!HasPresentation (thePrsObj, theMode))
- {
- AddPresentation (thePrsObj, theMode);
- }
-
- if (!HasPresentation (thePrsObj, theMode)) return;
-
- Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ 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();
+ aShadow->Highlight (Aspect_TOHM_COLOR, mySelectionColor);
AddToImmediateList (aShadow);
}
else
{
- aPrs->Highlight();
+ aPrs->Highlight (Aspect_TOHM_COLOR, mySelectionColor);
}
}
Unhighlight (anIter.Value(), theMode);
}
- if (HasPresentation (thePrsObj, theMode))
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ if (!aPrs.IsNull())
{
- Presentation (thePrsObj, theMode)->Unhighlight();
+ aPrs->Unhighlight();
}
}
SetDisplayPriority (anIter.Value(), theMode, theNewPrior);
}
- if (HasPresentation (thePrsObj, theMode))
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ if (!aPrs.IsNull())
{
- Presentation (thePrsObj, theMode)->SetDisplayPriority (theNewPrior);
+ aPrs->SetDisplayPriority (theNewPrior);
}
}
}
}
- return HasPresentation (thePrsObj, theMode)
- ? Presentation (thePrsObj, theMode)->DisplayPriority()
- : 0;
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ return !aPrs.IsNull()
+ ? aPrs->DisplayPriority()
+ : 0;
}
// =======================================================================
}
}
- return HasPresentation (thePrsObj, theMode)
- && Presentation (thePrsObj, theMode)->IsDisplayed();
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ return !aPrs.IsNull()
+ && aPrs->IsDisplayed();
}
// =======================================================================
}
}
- return HasPresentation (thePrsObj, theMode)
- && Presentation (thePrsObj, theMode)->IsHighlighted();
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ return !aPrs.IsNull()
+ && aPrs->IsHighlighted();
}
// =======================================================================
{
Update (anIter.Value(), theMode);
}
- if (!HasPresentation(thePrsObj, theMode))
- {
- return;
- }
Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (!aPrs.IsNull())
// purpose :
// =======================================================================
Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theMode) const
+ const Standard_Integer theMode,
+ const Standard_Boolean theToCreate) const
{
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
- if (aPrsList.IsEmpty())
- {
- return Handle(PrsMgr_Presentation)();
- }
-
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{
const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter);
}
}
- return Handle(PrsMgr_Presentation)();
-}
+ if (!theToCreate)
+ {
+ return Handle(PrsMgr_Presentation)();
+ }
-// =======================================================================
-// function : AddPresentation
-// purpose :
-// =======================================================================
-void PrsMgr_PresentationManager::AddPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theMode)
-{
Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj);
+ aPrs->SetZLayer (thePrsObj->ZLayer());
thePrsObj->Presentations().Append (PrsMgr_ModedPresentation (aPrs, theMode));
thePrsObj->Fill (this, aPrs, theMode);
// set layer index accordingly to object's presentations
- const Standard_Integer aZLayerId = GetZLayer (thePrsObj);
- if (aZLayerId >= 0)
- {
- aPrs->SetZLayer (aZLayerId);
- }
aPrs->SetUpdateStatus (Standard_False);
+ return aPrs;
}
// =======================================================================
// function : RemovePresentation
// purpose :
// =======================================================================
-void PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
- const Standard_Integer theMode)
+Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
+ const Standard_Integer theMode)
{
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{
- if (theMode == aPrsList (aPrsIter).Mode())
- // && this == aPrsMgr) ??
+ const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter);
+ const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager();
+ if (theMode == aPrsList (aPrsIter).Mode()
+ && this == aPrsMgr)
{
aPrsList.Remove (aPrsIter);
- break;
+ return Standard_True;
}
}
+ return Standard_False;
}
// =======================================================================
{
return;
}
- PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
- for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
- {
- Handle(PrsMgr_Presentation) aPrs = aPrsList.ChangeValue (aPrsIter).Presentation();
- if (aPrs->PresentationManager() == this)
- {
- aPrs->SetZLayer (theLayerId);
- }
- }
+
+ thePrsObj->SetZLayer (theLayerId);
}
// =======================================================================
// =======================================================================
Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const
{
- for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
- {
- Standard_Integer aLayer = GetZLayer (anIter.Value());
- if (aLayer != -1)
- {
- return aLayer;
- }
- }
- if (!thePrsObj->HasOwnPresentations())
- {
- return -1;
- }
- const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
- for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
- {
- Handle(PrsMgr_Presentation) aPrs = aPrsList.Value (aPrsIter).Presentation();
- if (aPrs->PresentationManager() == this)
- {
- return aPrs->GetZLayer();
- }
- }
- return -1;
+ return thePrsObj->ZLayer();
}
// =======================================================================
const Standard_Integer theMode,
const Standard_Integer theOtherMode)
{
- if (!HasPresentation (thePrsObject, theMode))
- {
- AddPresentation (thePrsObject, theMode);
- }
- if (!HasPresentation (theOtherObject, theOtherMode))
- {
- AddPresentation (theOtherObject, theOtherMode);
- }
- Presentation (thePrsObject, theMode)->Connect (Presentation (theOtherObject, theOtherMode));
+ Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObject, theMode, Standard_True);
+ Handle(PrsMgr_Presentation) aPrsOther = Presentation (theOtherObject, theOtherMode, Standard_True);
+ aPrs->Connect (aPrsOther);
}
// =======================================================================
return;
}
- if (!HasPresentation (thePrsObj, theMode))
- {
- AddPresentation (thePrsObj, theMode);
- }
-
- if (!HasPresentation (thePrsObj, theMode)) return;
-
- Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ 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->Color (theColor);
+ aShadow->Highlight (Aspect_TOHM_COLOR, theColor);
AddToImmediateList (aShadow);
}
else
{
- aPrs->Color (theColor);
+ aPrs->Highlight (Aspect_TOHM_COLOR, theColor);
}
}
// function : BoundBox
// purpose :
// =======================================================================
-void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObject,
+void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
- if (!HasPresentation (thePrsObject, theMode))
- {
- AddPresentation (thePrsObject, theMode);
- }
- else if (Presentation (thePrsObject, theMode)->MustBeUpdated())
+ Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True);
+ if (aPrs->MustBeUpdated())
{
- Update (thePrsObject, theMode);
+ Update (thePrsObj, theMode);
}
- Presentation (thePrsObject, theMode)->BoundBox();
+ aPrs->Highlight (Aspect_TOHM_BOUNDBOX, mySelectionColor);
}
// =======================================================================
// function : SetShadingAspect
// purpose :
// =======================================================================
-void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject,
+void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Handle(Prs3d_ShadingAspect)& theShadingAspect,
const Standard_Integer theMode)
{
- if (HasPresentation (thePrsObject, theMode))
+ const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
+ if (!aPrs.IsNull())
{
- Presentation (thePrsObject, theMode)->SetShadingAspect (theShadingAspect);
+ aPrs->SetShadingAspect (theShadingAspect);
}
}