1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0028047: Visualization - support objects with customized highlighting in AIS_InteractiveContext

- SelectMgr_SelectableObject::ClearHighlighted method is added to remove dynamic highlight data;
- interactive context will pass processing of dynamic highlight erase to the object if the owner returns false in SelectMgr_EntityOwner::IsAutoHilight;
- if owner returns true in SelectMgr_EntityOwner::IsForcedHilight, selection presentation will be re-highlighted at each ::Select call;
- redundant logic related to old object-oriented highlight mechanism was removed from AIS_InteractiveContext::MoveTo.
This commit is contained in:
vpa 2016-12-28 15:52:31 +03:00 committed by apn
parent a8232603a0
commit 731c9b5bc0
5 changed files with 45 additions and 34 deletions

View File

@ -2353,7 +2353,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
if (!myLastPicked.IsNull()
&& myLastPicked->IsSameSelectable (theIObj))
{
myMainPM->ClearImmediateDraw();
clearDynamicHighlight();
}
if (IsSelected (theIObj)
@ -2447,8 +2447,8 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
if (myLastinMain->IsSameSelectable (theIObj)
|| myLastPicked->IsSameSelectable(theIObj))
{
clearDynamicHighlight();
myLastinMain.Nullify();
myMainPM->ClearImmediateDraw();
}
}

View File

@ -1730,6 +1730,22 @@ protected:
return myDefaultDrawer->DisplayMode();
}
//! Removes dynamic highlight draw
void clearDynamicHighlight() const
{
if (myLastinMain.IsNull())
return;
if (myLastinMain->IsAutoHilight())
{
myMainPM->ClearImmediateDraw();
}
else
{
myLastinMain->Selectable()->ClearDynamicHighlight (myMainPM);
}
}
protected:
AIS_DataMapOfIOStatus myObjects;

View File

@ -373,17 +373,8 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
// method call. As result it is necessary to rehighligt it with mySelectionColor.
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
myMainPM->ClearImmediateDraw();
if (!myLastPicked->IsSelected())
{
myLastPicked->Unhilight (myMainPM);
toUpdateViewer = Standard_True;
}
else if (myToHilightSelected)
{
highlightSelected (aNewPickedOwner);
toUpdateViewer = Standard_True;
}
clearDynamicHighlight();
toUpdateViewer = Standard_True;
}
// initialize myLastPicked field with currently detected object
@ -411,20 +402,8 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
aStatus = AIS_SOD_Nothing;
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
myMainPM->ClearImmediateDraw();
if (!myLastPicked->IsSelected())
{
if (myLastPicked->IsAutoHilight())
{
myLastPicked->Unhilight (myMainPM);
}
toUpdateViewer = Standard_True;
}
else if (myToHilightSelected)
{
highlightSelected (myLastPicked);
toUpdateViewer = Standard_True;
}
clearDynamicHighlight();
toUpdateViewer = Standard_True;
}
myLastinMain.Nullify();
@ -577,10 +556,10 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
}
}
myMainPM->ClearImmediateDraw();
clearDynamicHighlight();
if (myWasLastMain && !myLastinMain.IsNull())
{
if(!myLastinMain->IsSelected())
if (!myLastinMain->IsSelected() || myLastinMain->IsForcedHilight())
{
SetSelected (myLastinMain, Standard_False);
if(toUpdateViewer)
@ -630,7 +609,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toU
}
}
myMainPM->ClearImmediateDraw();
clearDynamicHighlight();
if (myWasLastMain && !myLastinMain.IsNull())
{
AddOrRemoveSelected (myLastinMain, toUpdateViewer);
@ -896,7 +875,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
}
// In case of selection without using local context
myMainPM->ClearImmediateDraw();
clearDynamicHighlight();
AIS_MapOfObjSelectedOwners anObjOwnerMap;
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
@ -988,7 +967,7 @@ void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateVi
unhighlightSelected();
mySelection->Clear();
myMainPM->ClearImmediateDraw();
clearDynamicHighlight();
if (theToUpdateViewer)
UpdateCurrentViewer();
@ -1103,7 +1082,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t
const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
if (NbSelected() == 1 && theOwner->IsSelected())
if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
{
Handle(Prs3d_Drawer) aCustomStyle;
if (HighlightStyle (theOwner, aCustomStyle))

View File

@ -309,6 +309,15 @@ void SelectMgr_SelectableObject::ClearSelected ()
mySelectionPrs->Clear();
}
//=======================================================================
//function : ClearDynamicHighlight
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
theMgr->ClearImmediateDraw();
}
//=======================================================================
//function : HilightOwnerWithColor
//purpose :

View File

@ -140,7 +140,14 @@ public:
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void ClearSelected();
//! Method that needs to be implemented when the object
//! manages selection and dynamic highlighting on its own.
//! Clears or invalidates dynamic highlight presentation.
//! By default it clears immediate draw of given presentation
//! manager.
Standard_EXPORT virtual void ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr);
//! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,