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

0030717: Visualization, AIS_InteractiveContext::Erase() - selection presentation in a mode other than the default after hiding an object

AIS_InteractiveContext::EraseGlobal() now erases all object owners
(in the same way as AIS_InteractiveContext::ClearGlobal()).

Removed redundant fields AIS_InteractiveContext::myLastinMain and myWasLastMain.
This commit is contained in:
kgv 2019-05-19 09:46:59 +03:00 committed by bugmaster
parent 8cf3bf84ce
commit a9080ef924
4 changed files with 39 additions and 65 deletions

View File

@ -106,7 +106,6 @@ AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainVie
myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())),
myMainVwr(MainViewer),
myMainSel(new StdSelect_ViewerSelector3d()),
myWasLastMain(Standard_False),
myToHilightSelected(Standard_True),
mySelection(new AIS_Selection()),
myFilters(new SelectMgr_OrFilter()),
@ -1662,20 +1661,20 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI
setContextToObject (theIObj);
theIObj->SetWidth (theWidth);
theIObj->UpdatePresentations();
if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj))
if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj))
{
if (myLastinMain->IsAutoHilight())
if (myLastPicked->IsAutoHilight())
{
const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
myLastinMain->HilightWithColor (myMainPM,
myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain),
myLastPicked->HilightWithColor (myMainPM,
myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked),
aHiMode);
}
else
{
theIObj->HilightOwnerWithColor (myMainPM,
myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain),
myLastinMain);
myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked),
myLastPicked);
}
}
if (theToUpdateViewer)
@ -1937,42 +1936,18 @@ void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& t
void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateviewer)
{
Handle(AIS_GlobalStatus) aStatus;
if (theIObj.IsNull()
|| !myObjects.IsBound (theIObj))
|| !myObjects.Find (theIObj, aStatus)
|| aStatus->GraphicStatus() == AIS_DS_Erased)
{
return;
}
Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
if (aStatus->GraphicStatus() == AIS_DS_Erased)
{
return;
}
if (aStatus->IsHilighted())
{
Standard_DISABLE_DEPRECATION_WARNINGS
if (IsCurrent (theIObj))
{
AddOrRemoveCurrentObject (theIObj, Standard_False);
}
else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode()))
{
unhighlightGlobal (theIObj);
}
Standard_ENABLE_DEPRECATION_WARNINGS
}
unhighlightOwners (theIObj);
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
if (aStatus->IsHilighted()
&& theIObj->HasHilightMode())
{
unhighlightGlobal (theIObj);
}
if (!myLastPicked.IsNull()
&& myLastPicked->IsSameSelectable (theIObj))
{
@ -2028,8 +2003,9 @@ void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObje
void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateviewer)
{
Handle(AIS_GlobalStatus) aStatus;
if (theIObj.IsNull()
|| !myObjects.IsBound (theIObj))
|| !myObjects.Find (theIObj, aStatus))
{
// for cases when reference shape of connected interactives was not displayed
// but its selection primitives were calculated
@ -2038,7 +2014,6 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
return;
}
Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
unhighlightOwners (theIObj);
myMainPM->Erase (theIObj, -1);
@ -2087,13 +2062,11 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
}
if (!myLastinMain.IsNull())
if (!myLastPicked.IsNull())
{
if (myLastinMain->IsSameSelectable (theIObj)
|| myLastPicked->IsSameSelectable(theIObj))
if (myLastPicked->IsSameSelectable (theIObj))
{
clearDynamicHighlight();
myLastinMain.Nullify();
myLastPicked.Nullify();
}
}
@ -2147,15 +2120,12 @@ Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRe
myCurDetected = 0;
myCurHighlighted = 0;
myDetectedSeq.Clear();
myLastPicked = myLastinMain;
myWasLastMain = Standard_True;
Standard_Boolean toUpdate = Standard_False;
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
toUpdate = Standard_True;
clearDynamicHighlight();
}
myLastinMain.Nullify();
myLastPicked.Nullify();
myMainSel->ClearPicked();
if (toUpdate && theToRedrawImmediate)

View File

@ -1340,16 +1340,16 @@ protected: //! @name internal methods
//! Removes dynamic highlight draw
void clearDynamicHighlight() const
{
if (myLastinMain.IsNull())
if (myLastPicked.IsNull())
return;
if (myLastinMain->IsAutoHilight())
if (myLastPicked->IsAutoHilight())
{
myMainPM->ClearImmediateDraw();
}
else
{
myLastinMain->Selectable()->ClearDynamicHighlight (myMainPM);
myLastPicked->Selectable()->ClearDynamicHighlight (myMainPM);
}
}
@ -1361,8 +1361,6 @@ protected: //! @name internal fields
Handle(V3d_Viewer) myMainVwr;
Handle(StdSelect_ViewerSelector3d) myMainSel;
Handle(SelectMgr_EntityOwner) myLastPicked;
Handle(SelectMgr_EntityOwner) myLastinMain;
Standard_Boolean myWasLastMain;
Standard_Boolean myToHilightSelected;
Handle(AIS_Selection) mySelection;
Handle(SelectMgr_OrFilter) myFilters;

View File

@ -328,8 +328,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
myDetectedSeq.Clear();
// preliminaires
myLastPicked = myLastinMain;
myWasLastMain = Standard_True;
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
Standard_Boolean toUpdateViewer = Standard_False;
@ -399,7 +397,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
// initialize myLastPicked field with currently detected object
myLastPicked = aNewPickedOwner;
myLastinMain = myLastPicked;
// highlight detected object if it is not selected or myToHilightSelected flag is true
if (myLastPicked->HasSelectable())
@ -440,7 +437,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
toUpdateViewer = Standard_True;
}
myLastinMain.Nullify();
myLastPicked.Nullify();
}
@ -500,7 +496,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
ClearSelected (Standard_False);
myWasLastMain = Standard_True;
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
@ -541,7 +536,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
ClearSelected (Standard_False);
myWasLastMain = Standard_True;
myMainSel->Pick (thePolyline, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
@ -572,17 +566,17 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
{
if (myWasLastMain && !myLastinMain.IsNull())
if (!myLastPicked.IsNull())
{
if (myAutoHilight)
{
clearDynamicHighlight();
}
if (!myLastinMain->IsSelected()
|| myLastinMain->IsForcedHilight()
if (!myLastPicked->IsSelected()
|| myLastPicked->IsForcedHilight()
|| NbSelected() > 1)
{
SetSelected (myLastinMain, Standard_False);
SetSelected (myLastPicked, Standard_False);
if(toUpdateViewer)
{
UpdateCurrentViewer();
@ -611,9 +605,9 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toU
{
clearDynamicHighlight();
}
if (myWasLastMain && !myLastinMain.IsNull())
if (!myLastPicked.IsNull())
{
AddOrRemoveSelected (myLastinMain, toUpdateViewer);
AddOrRemoveSelected (myLastPicked, toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
@ -643,7 +637,6 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
{
UnhilightSelected (Standard_False);
}
myWasLastMain = Standard_True;
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
@ -685,7 +678,6 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
{
UnhilightSelected (Standard_False);
}
myWasLastMain = Standard_True;
myMainSel->Pick (thePolyline, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
@ -1201,7 +1193,6 @@ Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_V
highlightWithColor (anOwner, theView->Viewer());
myLastPicked = anOwner;
myLastinMain = myLastPicked;
if (theToRedrawImmediate)
{
@ -1237,7 +1228,6 @@ Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V
highlightWithColor (anOwner, theView->Viewer());
myLastPicked = anOwner;
myLastinMain = myLastPicked;
if (theToRedrawImmediate)
{

16
tests/bugs/vis/bug30717 Normal file
View File

@ -0,0 +1,16 @@
puts "============="
puts "0030717: Visualization, AIS_InteractiveContext::Erase() - selection presentation in a mode other than the default after hiding an object"
puts "============="
pload MODELING VISUALIZATION
box b 10 10 10
vclear
vinit View1
vdisplay -dispMode 1 -highMode 1 b
vaxo
vfit
vselmode b Face on
vmoveto 250 250
vselect 250 250
verase b
if { [vreadpixel 300 300 rgb name] != "BLACK" } { puts "Error: hidden face is highlighted" }