//! 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.
//! 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.
// 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;
// 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;
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
{
- if (myAutoHilight)
- {
- clearDynamicHighlight();
- }
if (myWasLastMain && !myLastinMain.IsNull())
{
+ if (myAutoHilight)
+ {
+ clearDynamicHighlight();
+ }
if (!myLastinMain->IsSelected()
|| myLastinMain->IsForcedHilight()
|| NbSelected() > 1)
}
else
{
- if (myAutoHilight)
- {
- unhighlightSelected (Standard_True);
- }
-
- mySelection->Clear();
- if (toUpdateViewer && myWasLastMain)
- {
- UpdateCurrentViewer();
- }
+ ClearSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
{
unhighlightSelected();
}
+ else
+ {
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ aSelIter.Value()->SetSelected (Standard_False);
+ }
+ }
mySelection->Clear();
if (myAutoHilight)
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 :
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;
}
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")
{
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";
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",
"\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)"
"\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"