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

View File

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

View File

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