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

0029425: Visualization - AIS_InteractiveContext::SetAutomaticHilight() has no affect

AIS_InteractiveContext::MoveTo() and ::Select() now do not highlight entities
when ::AutomaticHilight() option is turned off.

vselprops command has been extended with new arguments -autoHighlight and -highlightSelected
(vhighlightselected command is now deprecated).
This commit is contained in:
kgv 2018-06-21 12:19:08 +03:00 committed by bugmaster
parent df6f165a2b
commit be3d8cbc02
3 changed files with 99 additions and 95 deletions

View File

@ -491,12 +491,32 @@ public: //! @name Selection management
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView);
//! Return value specified whether selected object must be hilighted when mouse cursor is moved above it
//! @sa MoveTo()
Standard_Boolean ToHilightSelected() const { return myToHilightSelected; }
//! Specify whether selected object must be hilighted when mouse cursor is moved above it (in MoveTo method).
//! By default this value is false and selected object is not hilighted in this case.
//! @sa MoveTo()
void SetToHilightSelected (const Standard_Boolean toHilight) { myToHilightSelected = toHilight; }
//! Return value specified whether selected object must be hilighted when mouse cursor is moved above it
Standard_Boolean ToHilightSelected() const { return myToHilightSelected; }
//! Returns true if the automatic highlight mode is active; TRUE by default.
//! @sa MoveTo(), Select(), HilightWithColor(), Unhilight()
Standard_Boolean AutomaticHilight() const { return myAutoHilight; }
//! Sets the highlighting status of detected and selected entities.
//! This function allows you to disconnect the automatic mode.
//!
//! MoveTo() will fill the list of detected entities
//! and Select() will set selected state to detected objects regardless of this flag,
//! but with disabled AutomaticHiligh() their highlighting state will be left unaffected,
//! so that application will be able performing custom highlighting in a different way, if needed.
//!
//! This API should be distinguished from SelectMgr_SelectableObject::SetAutoHilight()
//! that is used to implement custom highlighting logic for a specific interactive object class.
//!
//! @sa MoveTo(), Select(), HilightWithColor(), Unhilight()
void SetAutomaticHilight (Standard_Boolean theStatus) { myAutoHilight = theStatus; }
//! Unhighlights previously selected owners and marks them as not selected.
//! Marks owner given as selected and highlights it.
@ -1039,15 +1059,6 @@ public: //! @name iso-line display attributes
//! Returns true if drawing isolines on triangulation algorithm is enabled.
Standard_EXPORT Standard_Boolean IsoOnTriangulation() const;
public: //! @name Local Context management (deprecated)
//! Sets the highlighting status of detected and selected entities.
//! This function allows you to disconnect the automatic mode.
void SetAutomaticHilight (Standard_Boolean theStatus) { myAutoHilight = theStatus; }
//! Returns true if the automatic highlight mode is active.
Standard_Boolean AutomaticHilight() const { return myAutoHilight; }
public:
//! Updates the view of the current object in open context.

View File

@ -383,7 +383,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
// highlight detected object if it is not selected or myToHilightSelected flag is true
if (myLastPicked->HasSelectable())
{
if (!myLastPicked->IsSelected() || myToHilightSelected)
if (myAutoHilight
&& (!myLastPicked->IsSelected()
|| myToHilightSelected))
{
highlightWithColor (myLastPicked, theView->Viewer());
toUpdateViewer = Standard_True;
@ -399,7 +401,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
// previously detected object is unhilighted if it is not selected or hilighted
// with selection color if it is selected
aStatus = AIS_SOD_Nothing;
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
if (myAutoHilight
&& !myLastPicked.IsNull()
&& myLastPicked->HasSelectable())
{
clearDynamicHighlight();
toUpdateViewer = Standard_True;
@ -523,12 +527,12 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
{
if (myWasLastMain && !myLastinMain.IsNull())
{
if (myAutoHilight)
{
clearDynamicHighlight();
}
if (myWasLastMain && !myLastinMain.IsNull())
{
if (!myLastinMain->IsSelected()
|| myLastinMain->IsForcedHilight()
|| NbSelected() > 1)
@ -542,16 +546,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
}
else
{
if (myAutoHilight)
{
unhighlightSelected (Standard_True);
}
mySelection->Clear();
if (toUpdateViewer && myWasLastMain)
{
UpdateCurrentViewer();
}
ClearSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
@ -761,6 +756,13 @@ void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateVi
{
unhighlightSelected();
}
else
{
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
aSelIter.Value()->SetSelected (Standard_False);
}
}
mySelection->Clear();
if (myAutoHilight)

View File

@ -11074,70 +11074,6 @@ static int VFrustumCulling (Draw_Interpretor& theDI,
return 0;
}
//=======================================================================
//function : VHighlightSelected
//purpose :
//=======================================================================
static int VHighlightSelected (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
if (ViewerTest::GetAISContext().IsNull())
{
std::cout << theArgVec[0] << " error : Context is not created. Please call vinit before.\n";
return 1;
}
const Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (theArgNb < 2)
{
theDI << (aContext->ToHilightSelected() ? "on" : "off");
return 0;
}
if (theArgNb != 2)
{
std::cout << theArgVec[0] << " error : wrong number of parameters."
<< "Type 'help" << theArgVec[0] << "' for more information.";
return 1;
}
// Parse parameter
TCollection_AsciiString aMode (theArgVec[1]);
aMode.LowerCase();
Standard_Boolean toEnable = Standard_False;
if (aMode.IsEqual ("on"))
{
toEnable = Standard_True;
}
else if (aMode.IsEqual ("off"))
{
toEnable = Standard_False;
}
else
{
toEnable = Draw::Atoi (theArgVec[1]) != 0;
}
if (toEnable != aContext->ToHilightSelected())
{
aContext->SetToHilightSelected (toEnable);
// Move cursor to null position and back to process updating of detection
// and highlighting of selected object immediatly.
Standard_Integer aPixX = 0;
Standard_Integer aPixY = 0;
const Handle(ViewerTest_EventManager)& anEventManager = ViewerTest::CurrentEventManager();
anEventManager->GetCurrentPosition (aPixX, aPixY);
anEventManager->MoveTo (0, 0);
anEventManager->MoveTo (aPixX, aPixY);
}
return 0;
}
//=======================================================================
//function : VXRotate
//purpose :
@ -11489,6 +11425,29 @@ static int VSelectionProperties (Draw_Interpretor& theDi,
return 1;
}
if (TCollection_AsciiString (theArgVec[0]) == "vhighlightselected")
{
// handle obsolete alias
bool toEnable = true;
if (theArgsNb < 2)
{
theDi << (aCtx->ToHilightSelected() ? "on" : "off");
return 0;
}
else if (theArgsNb != 2
|| !ViewerTest::ParseOnOff (theArgVec[1], toEnable))
{
std::cout << "Syntax error: wrong number of parameters.";
return 1;
}
if (toEnable != aCtx->ToHilightSelected())
{
aCtx->ClearDetected();
aCtx->SetToHilightSelected (toEnable);
}
return 0;
}
Standard_Boolean toPrint = theArgsNb == 1;
Standard_Boolean toRedraw = Standard_False;
Standard_Integer anArgIter = 1;
@ -11554,6 +11513,35 @@ static int VSelectionProperties (Draw_Interpretor& theDi,
}
aCtx->SetAutoActivateSelection (toEnable);
}
else if (anArg == "-automatichighlight"
|| anArg == "-automatichilight"
|| anArg == "-autohighlight"
|| anArg == "-autohilight")
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgsNb
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
aCtx->ClearSelected (false);
aCtx->ClearDetected();
aCtx->SetAutomaticHilight (toEnable);
toRedraw = true;
}
else if (anArg == "-highlightselected"
|| anArg == "-hilightselected")
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgsNb
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
aCtx->ClearDetected();
aCtx->SetToHilightSelected (toEnable);
toRedraw = true;
}
else if (anArg == "-pickstrategy"
|| anArg == "-pickingstrategy")
{
@ -11731,6 +11719,8 @@ static int VSelectionProperties (Draw_Interpretor& theDi,
const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle();
const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle();
theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n";
theDi << "Auto-highlight : " << (aCtx->AutomaticHilight() ? "On" : "Off") << "\n";
theDi << "Highlight selected : " << (aCtx->ToHilightSelected() ? "On" : "Off") << "\n";
theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n";
theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n";
theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n";
@ -12513,10 +12503,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
theCommands.Add("vfrustumculling",
"vfrustumculling [toEnable]: enables/disables objects clipping",
__FILE__,VFrustumCulling,group);
theCommands.Add("vhighlightselected",
"vhighlightselected [0|1] or vhighlightselected [on|off]: enables/disables highlighting of selected objects.\n"
"Without arguments it shows if highlighting of selected objects is enabled now.",
__FILE__,VHighlightSelected,group);
theCommands.Add ("vplace",
"vplace dx dy"
"\n\t\t: Places the point (in pixels) at the center of the window",
@ -12554,6 +12540,8 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]"
"\n Customizes selection and dynamic highlight parameters for the whole interactive context:"
"\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode"
"\n -autoHighlight {0|1} : disables|enables automatic highlighting in 3D Viewer"
"\n -highlightSelected {0|1}: disables|enables highlighting of detected object in selected state"
"\n -pickStrategy {first|topmost} : defines picking strategy"
"\n 'first' to pick first acceptable (default)"
"\n 'topmost' to pick only topmost (and nothing, if topmost is rejected by filters)"
@ -12565,6 +12553,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n -material material : sets highlight material"
"\n -print : prints current state of all mentioned parameters",
__FILE__, VSelectionProperties, group);
theCommands.Add ("vhighlightselected",
"vhighlightselected [0|1]: alias for vselprops -highlightSelected.\n",
__FILE__, VSelectionProperties, group);
theCommands.Add ("vseldump",
"vseldump file -type {depth|unnormDepth|object|owner|selMode|entity}=depth -pickedIndex Index=1"