diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 03d6429638..dc7ae26b75 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -523,7 +523,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO if (aStatus->IsHilighted()) { const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; - myMainPM->Highlight (theIObj, aHiMod); + myMainPM->Color (theIObj, aStatus->HilightColor(), aHiMod); } if (theSelectionMode != -1) { diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 1618da80cd..b18a84d52c 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -414,10 +414,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate anOwner->State (0); if (anOwner == anObject->GlobalSelOwner()) { - Handle(AIS_GlobalStatus) aStatus = myObjects (anObject); - aStatus->SetHilightStatus (Standard_False); - aStatus->SetHilightColor (Quantity_NOC_WHITE); - anObject->State (0); + myObjects.ChangeFind (anObject)->SetHilightStatus (Standard_False); } if (!anOwner->IsAutoHilight()) { @@ -762,7 +759,9 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); if (anOwner == anObj->GlobalSelOwner()) { - anObj->State (1); + Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj); + aState->SetHilightStatus (Standard_True); + aState->SetHilightColor (mySelectionColor); } anOwner->State (1); if (!anOwner->IsAutoHilight()) @@ -823,7 +822,7 @@ void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpda Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); if (anOwner == anObj->GlobalSelOwner()) { - anObj->State (0); + myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False); } anOwner->State (0); const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0; @@ -861,7 +860,7 @@ void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateVi Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); if (anOwner == anObj->GlobalSelOwner()) { - anObj->State (0); + myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False); } anOwner->State (0); if (!anOwner->IsAutoHilight()) @@ -923,7 +922,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t if (theObject->HasSelection (0)) return; - if (NbSelected() == 1 && theObject->State() == 1) + if (NbSelected() == 1 && myObjects (theObject)->IsHilighted()) { Quantity_NameOfColor aHiCol; Standard_Boolean hasHiCol = Standard_False; @@ -950,7 +949,10 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); Unhilight (aSelectable, Standard_False); anOwner->State (0); - aSelectable->State (0); + if (anOwner == aSelectable->GlobalSelOwner()) + { + myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False); + } } // added to avoid untimely viewer update... @@ -961,8 +963,13 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId()); AIS_Selection::ClearAndSelect (anOwner); - theObject->State (1); anOwner->State (1); + if (anOwner == theObject->GlobalSelOwner()) + { + Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject); + aState->SetHilightStatus (Standard_True); + aState->SetHilightColor (mySelectionColor); + } Quantity_NameOfColor aHiCol; Standard_Boolean hasHiCol = Standard_False; if (IsHilighted (theObject, hasHiCol, aHiCol)) @@ -1034,6 +1041,10 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t anObjToClear.Add (anInteractive); } anOwner->State (0); + if (theOwner == anObject->GlobalSelOwner()) + { + myObjects.ChangeFind (anObject)->SetHilightStatus (Standard_False); + } } while (!anObjToClear.IsEmpty()) { @@ -1050,6 +1061,13 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t highlightSelected (theOwner, mySelectionColor); } + if (theOwner == anObject->GlobalSelOwner()) + { + Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject); + aState->SetHilightStatus (Standard_True); + aState->SetHilightColor (mySelectionColor); + } + if (theToUpdateViewer) UpdateCurrentViewer(); } @@ -1130,9 +1148,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner; - if (isGlobal) - anObj->State (aState); - const Handle(AIS_GlobalStatus)& aStatus = myObjects (anObj); + Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj); const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; if (aState == 1) { @@ -1184,7 +1200,7 @@ Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_Interactiv if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated) return Standard_False; - return theObj->State() == 1; + return myObjects (theObj)->IsHilighted(); } //======================================================================= diff --git a/tests/bugs/vis/bug22016 b/tests/bugs/vis/bug22016 new file mode 100644 index 0000000000..3e350d2ac6 --- /dev/null +++ b/tests/bugs/vis/bug22016 @@ -0,0 +1,27 @@ +puts "========" +puts "OCC22016" +puts "========" +puts "" +######################################################################################### +# Incorrect selection color after displaying a selected object +######################################################################################### + +pload MODELING VISUALIZATION +box b1 0 0 0 1 2 3 +box b2 3 0 0 2 3 1 +vinit View1 +vclear +vaxo +vdisplay -noupdate b1 b2 +vaspects b1 b2 -setWidth 4 +vfit +vselect 0 0 500 500 +vdisplay b2 +set aColor1 [vreadpixel 104 32 rgb name] +set aColor2 [vreadpixel 255 350 rgb name] + +if {$aColor1 != "GRAY80" || $aColor2 != "GRAY80" } { + puts "ERROR: OCC22016 is reproduced. Incorrect selection color after displaying a selected object." +} + +vdump ${imagedir}/${casename}.png