mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030728: Visualization - using one implementation of highlight/unhighlight in context
This commit is contained in:
parent
611684187d
commit
741c4f3ecc
@ -1968,7 +1968,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
|
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
|
||||||
unhighlightOwners (theIObj);
|
unselectOwners (theIObj);
|
||||||
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
|
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
|
||||||
|
|
||||||
if (!myLastPicked.IsNull()
|
if (!myLastPicked.IsNull()
|
||||||
@ -2000,10 +2000,10 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
|
|||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : unhighlightOwners
|
//function : unselectOwners
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject)
|
void AIS_InteractiveContext::unselectOwners (const Handle(AIS_InteractiveObject)& theObject)
|
||||||
{
|
{
|
||||||
SelectMgr_SequenceOfOwner aSeq;
|
SelectMgr_SequenceOfOwner aSeq;
|
||||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||||
@ -2037,7 +2037,7 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unhighlightOwners (theIObj);
|
unselectOwners (theIObj);
|
||||||
|
|
||||||
myMainPM->Erase (theIObj, -1);
|
myMainPM->Erase (theIObj, -1);
|
||||||
theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased
|
theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased
|
||||||
|
@ -1235,7 +1235,7 @@ protected: //! @name internal methods
|
|||||||
Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
|
Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
|
||||||
|
|
||||||
//! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
|
//! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
|
||||||
Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
|
Standard_EXPORT void unselectOwners (const Handle(AIS_InteractiveObject)& theObject);
|
||||||
|
|
||||||
//! Helper function that highlights the owner given with <theStyle> without
|
//! Helper function that highlights the owner given with <theStyle> without
|
||||||
//! performing AutoHighlight checks, e.g. is used for dynamic highlight.
|
//! performing AutoHighlight checks, e.g. is used for dynamic highlight.
|
||||||
@ -1246,12 +1246,16 @@ protected: //! @name internal methods
|
|||||||
//! for AutoHighlight, e.g. is used for selection.
|
//! for AutoHighlight, e.g. is used for selection.
|
||||||
Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
|
Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
|
||||||
|
|
||||||
|
//! Helper function that highlights the owners with check
|
||||||
|
//! for AutoHighlight, e.g. is used for selection.
|
||||||
|
Standard_EXPORT void highlightOwners (const AIS_NListOfEntityOwner& theOwners);
|
||||||
|
|
||||||
//! Helper function that highlights global owner of the object given with <theStyle> with check
|
//! Helper function that highlights global owner of the object given with <theStyle> with check
|
||||||
//! for AutoHighlight, e.g. is used for selection.
|
//! for AutoHighlight, e.g. is used for selection.
|
||||||
//! If global owner is null, it simply highlights the whole object
|
//! If global owner is null, it simply highlights the whole object
|
||||||
Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
|
Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
|
||||||
const Handle(Prs3d_Drawer)& theStyle,
|
const Handle(Prs3d_Drawer)& theStyle,
|
||||||
const Standard_Integer theDispMode) const;
|
const Standard_Integer theDispMode);
|
||||||
|
|
||||||
//! Helper function that unhighlights all owners that are stored in current AIS_Selection.
|
//! Helper function that unhighlights all owners that are stored in current AIS_Selection.
|
||||||
//! The function updates global status and selection state of owner and interactive object.
|
//! The function updates global status and selection state of owner and interactive object.
|
||||||
@ -1259,9 +1263,14 @@ protected: //! @name internal methods
|
|||||||
//! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
|
//! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
|
||||||
Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
|
Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
|
||||||
|
|
||||||
|
//! Helper function that unhighlights the owners with check
|
||||||
|
//! for AutoHighlight, e.g. is used for selection.
|
||||||
|
Standard_EXPORT void unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
|
||||||
|
const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
|
||||||
|
|
||||||
//! Helper function that unhighlights global selection owner of given interactive.
|
//! Helper function that unhighlights global selection owner of given interactive.
|
||||||
//! The function does not perform any updates of global or owner status
|
//! The function does not perform any updates of global or owner status
|
||||||
Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const;
|
Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj);
|
||||||
|
|
||||||
//! Helper function that turns on sub-intensity in global status and highlights
|
//! Helper function that turns on sub-intensity in global status and highlights
|
||||||
//! given objects with sub-intensity color
|
//! given objects with sub-intensity color
|
||||||
|
@ -85,6 +85,7 @@ void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOw
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
|
void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
|
||||||
{
|
{
|
||||||
|
AIS_NListOfEntityOwner anOwners;
|
||||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
||||||
if (anObj.IsNull())
|
if (anObj.IsNull())
|
||||||
{
|
{
|
||||||
@ -98,17 +99,15 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn
|
|||||||
{
|
{
|
||||||
if (aSelIter.Value()->IsSameSelectable (anObj))
|
if (aSelIter.Value()->IsSameSelectable (anObj))
|
||||||
{
|
{
|
||||||
aSeq.Append (aSelIter.Value());
|
anOwners.Append (aSelIter.Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anObj->HilightSelected (myMainPM, aSeq);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
|
anOwners.Append (theOwner);
|
||||||
const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
|
|
||||||
theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
|
|
||||||
}
|
}
|
||||||
|
highlightOwners (anOwners);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -117,7 +116,7 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
|
void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
|
||||||
const Handle(Prs3d_Drawer)& theStyle,
|
const Handle(Prs3d_Drawer)& theStyle,
|
||||||
const Standard_Integer theDispMode) const
|
const Standard_Integer theDispMode)
|
||||||
{
|
{
|
||||||
if (theObj.IsNull())
|
if (theObj.IsNull())
|
||||||
{
|
{
|
||||||
@ -133,6 +132,7 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AIS_NListOfEntityOwner anOwners;
|
||||||
if (!aGlobOwner->IsAutoHilight())
|
if (!aGlobOwner->IsAutoHilight())
|
||||||
{
|
{
|
||||||
SelectMgr_SequenceOfOwner aSeq;
|
SelectMgr_SequenceOfOwner aSeq;
|
||||||
@ -140,15 +140,15 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
|
|||||||
{
|
{
|
||||||
if (aSelIter.Value()->IsSameSelectable (theObj))
|
if (aSelIter.Value()->IsSameSelectable (theObj))
|
||||||
{
|
{
|
||||||
aSeq.Append (aSelIter.Value());
|
anOwners.Append (aSelIter.Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
theObj->HilightSelected (myMainPM, aSeq);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode);
|
anOwners.Append (aGlobOwner);
|
||||||
}
|
}
|
||||||
|
highlightOwners (anOwners);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -156,9 +156,19 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
|
void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
|
||||||
|
{
|
||||||
|
unhighlightOwners (mySelection->Objects(), theIsToHilightSubIntensity);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : unhighlightOwners
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
|
||||||
|
const Standard_Boolean theIsToHilightSubIntensity)
|
||||||
{
|
{
|
||||||
NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
|
NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
|
||||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
|
||||||
{
|
{
|
||||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
||||||
const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||||
@ -186,7 +196,7 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo
|
|||||||
}
|
}
|
||||||
if (anOwner == anInteractive->GlobalSelOwner())
|
if (anOwner == anInteractive->GlobalSelOwner())
|
||||||
{
|
{
|
||||||
myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
|
aStatus->SetHilightStatus (Standard_False);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
|
for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
|
||||||
@ -201,7 +211,7 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo
|
|||||||
//function : unhighlightGlobal
|
//function : unhighlightGlobal
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const
|
void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj)
|
||||||
{
|
{
|
||||||
if (theObj.IsNull())
|
if (theObj.IsNull())
|
||||||
{
|
{
|
||||||
@ -215,15 +225,9 @@ void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObje
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aGlobOwner->IsAutoHilight())
|
AIS_NListOfEntityOwner anOwners;
|
||||||
{
|
anOwners.Append (aGlobOwner);
|
||||||
aGlobOwner->Unhilight (myMainPM);
|
unhighlightOwners (anOwners);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myMainPM->Unhighlight (theObj);
|
|
||||||
theObj->ClearSelected();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -720,11 +724,27 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
|||||||
{
|
{
|
||||||
// In case of selection without using local context
|
// In case of selection without using local context
|
||||||
clearDynamicHighlight();
|
clearDynamicHighlight();
|
||||||
|
|
||||||
|
highlightOwners (mySelection->Objects());
|
||||||
|
|
||||||
|
if (theToUpdateViewer)
|
||||||
|
UpdateCurrentViewer();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : highlightOwners
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners)
|
||||||
|
{
|
||||||
AIS_MapOfObjSelectedOwners anObjOwnerMap;
|
AIS_MapOfObjSelectedOwners anObjOwnerMap;
|
||||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
|
||||||
{
|
{
|
||||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
||||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||||
|
if (anObj.IsNull())
|
||||||
|
continue;
|
||||||
|
|
||||||
const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
|
const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
|
||||||
Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
|
Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
|
||||||
if (anOwner == anObj->GlobalSelOwner())
|
if (anOwner == anObj->GlobalSelOwner())
|
||||||
@ -761,9 +781,6 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
|||||||
}
|
}
|
||||||
anObjOwnerMap.Clear();
|
anObjOwnerMap.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theToUpdateViewer)
|
|
||||||
UpdateCurrentViewer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -772,17 +789,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
|
void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
|
||||||
{
|
{
|
||||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
unhighlightSelected();
|
||||||
{
|
|
||||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
|
||||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
|
||||||
if (anOwner == anObj->GlobalSelOwner())
|
|
||||||
{
|
|
||||||
myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
|
|
||||||
}
|
|
||||||
|
|
||||||
anOwner->Unhilight (myMainPM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theToUpdateViewer)
|
if (theToUpdateViewer)
|
||||||
UpdateCurrentViewer();
|
UpdateCurrentViewer();
|
||||||
@ -937,13 +944,6 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAutoHilight && theOwner == anObject->GlobalSelOwner())
|
|
||||||
{
|
|
||||||
Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
|
|
||||||
aState->SetHilightStatus (Standard_True);
|
|
||||||
aState->SetHilightStyle (anObjSelStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theToUpdateViewer)
|
if (theToUpdateViewer)
|
||||||
UpdateCurrentViewer();
|
UpdateCurrentViewer();
|
||||||
}
|
}
|
||||||
@ -990,28 +990,17 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
|
|||||||
if (myAutoHilight)
|
if (myAutoHilight)
|
||||||
{
|
{
|
||||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
||||||
const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
|
|
||||||
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
|
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
|
||||||
if (theOwner->IsSelected())
|
if (theOwner->IsSelected())
|
||||||
{
|
{
|
||||||
highlightSelected (theOwner);
|
highlightSelected (theOwner);
|
||||||
if (isGlobal)
|
|
||||||
{
|
|
||||||
aStatus->SetHilightStatus (Standard_True);
|
|
||||||
aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (theOwner->IsAutoHilight())
|
AIS_NListOfEntityOwner anOwners;
|
||||||
{
|
anOwners.Append (theOwner);
|
||||||
theOwner->Unhilight (myMainPM);
|
unhighlightOwners (anOwners);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
anObj->ClearSelected();
|
|
||||||
}
|
|
||||||
aStatus->SetHilightStatus (Standard_False);
|
|
||||||
aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
|
aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user