mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0028416: Visualization - SelectMgr_SelectionManager::Activate() should not implicitly deactivate Global Selection Mode
Implicit deactivation of global selection mode has been removed from SelectMgr_SelectionManager::Activate(). Added new method AIS_InteractiveContext::SetSelectionModeActive() as replacement of AIS_InteractiveContext::Activate() / ::Deactivate(). New method takes an argument AIS_SelectionModesConcurrency which defines what to do with already activated selection modes in 3 ways: - AIS_SelectionModesConcurrency_Single, only one selection mode can be activated at the same moment - previously activated should be deactivated - AIS_SelectionModesConcurrency_GlobalOrLocal, either Global (AIS_InteractiveObject::GlobalSelectionMode() or Local (multiple) selection modes can be active at the same moment - AIS_SelectionModesConcurrency_Multiple, any combination of selection modes can be activated.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <AIS_KindOfInteractive.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_Selection.hxx>
|
||||
#include <AIS_SelectionModesConcurrency.hxx>
|
||||
#include <AIS_StatusOfDetection.hxx>
|
||||
#include <AIS_StatusOfPick.hxx>
|
||||
#include <AIS_TypeOfIso.hxx>
|
||||
@@ -596,18 +597,48 @@ public: //! @name immediate mode rendering
|
||||
|
||||
public: //! @name management of active Selection Modes
|
||||
|
||||
//! Activates or deactivates the selection mode for specified object.
|
||||
//! Has no effect if selection mode was already active/deactivated.
|
||||
//! @param theObj object to activate/deactivate selection mode
|
||||
//! @param theMode selection mode to activate/deactivate;
|
||||
//! deactivation of -1 selection mode will effectively deactivate all selection modes;
|
||||
//! activation of -1 selection mode with AIS_SelectionModesConcurrency_Single
|
||||
//! will deactivate all selection modes, and will has no effect otherwise
|
||||
//! @param theToActivate activation/deactivation flag
|
||||
//! @param theConcurrency specifies how to handle already activated selection modes;
|
||||
//! default value (AIS_SelectionModesConcurrency_Multiple) means active selection modes should be left as is,
|
||||
//! AIS_SelectionModesConcurrency_Single can be used if only one selection mode is expected to be active
|
||||
//! and AIS_SelectionModesConcurrency_GlobalOrLocal can be used if either AIS_InteractiveObject::GlobalSelectionMode()
|
||||
//! or any combination of Local selection modes is acceptable;
|
||||
//! this value is considered only if theToActivate set to TRUE
|
||||
//! @param theIsForce when set to TRUE, the display status will be ignored while activating selection mode
|
||||
Standard_EXPORT void SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Standard_Integer theMode,
|
||||
const Standard_Boolean theToActivate,
|
||||
const AIS_SelectionModesConcurrency theConcurrency = AIS_SelectionModesConcurrency_Multiple,
|
||||
const Standard_Boolean theIsForce = Standard_False);
|
||||
|
||||
//! Activates the selection mode aMode whose index is given, for the given interactive entity anIobj.
|
||||
Standard_EXPORT void Activate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode = 0, const Standard_Boolean theIsForce = Standard_False);
|
||||
void Activate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0, const Standard_Boolean theIsForce = Standard_False)
|
||||
{
|
||||
SetSelectionModeActive (theObj, theMode, Standard_True, AIS_SelectionModesConcurrency_GlobalOrLocal, theIsForce);
|
||||
}
|
||||
|
||||
//! Activates the given selection mode for the all displayed objects.
|
||||
Standard_EXPORT void Activate (const Standard_Integer theMode,
|
||||
const Standard_Boolean theIsForce = Standard_False);
|
||||
|
||||
//! Deactivates all the activated selection modes of an object.
|
||||
Standard_EXPORT void Deactivate (const Handle(AIS_InteractiveObject)& anIObj);
|
||||
void Deactivate (const Handle(AIS_InteractiveObject)& theObj)
|
||||
{
|
||||
SetSelectionModeActive (theObj, -1, Standard_False, AIS_SelectionModesConcurrency_Single);
|
||||
}
|
||||
|
||||
//! Deactivates all the activated selection modes of the interactive object anIobj with a given selection mode aMode.
|
||||
Standard_EXPORT void Deactivate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode);
|
||||
void Deactivate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode)
|
||||
{
|
||||
SetSelectionModeActive (theObj, theMode, Standard_False);
|
||||
}
|
||||
|
||||
//! Deactivates the given selection mode for all displayed objects.
|
||||
Standard_EXPORT void Deactivate (const Standard_Integer theMode);
|
||||
|
@@ -216,27 +216,121 @@ Standard_Integer AIS_InteractiveContext::HighestIndex() const
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Activate
|
||||
//purpose :
|
||||
//function : SetSelectionModeActive
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_InteractiveContext::
|
||||
Activate(const Handle(AIS_InteractiveObject)& anIObj,
|
||||
const Standard_Integer aMode,
|
||||
const Standard_Boolean theIsForce)
|
||||
void AIS_InteractiveContext::SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Standard_Integer theMode,
|
||||
const Standard_Boolean theIsActive,
|
||||
const AIS_SelectionModesConcurrency theActiveFilter,
|
||||
const Standard_Boolean theIsForce)
|
||||
{
|
||||
if(!HasOpenedContext()){
|
||||
if(!myObjects.IsBound(anIObj)) return;
|
||||
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
|
||||
if(STAT->GraphicStatus()==AIS_DS_Displayed || theIsForce)
|
||||
mgrSelector->Activate(anIObj,aMode,myMainSel);
|
||||
STAT ->AddSelectionMode(aMode);
|
||||
if (theObj.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else{
|
||||
myLocalContexts(myCurLocalIndex)->ActivateMode(anIObj,aMode);
|
||||
else if (HasOpenedContext())
|
||||
{
|
||||
myLocalContexts (myCurLocalIndex)->SetSelectionModeActive (theObj, theMode, theIsActive, theActiveFilter);
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(AIS_GlobalStatus)* aStat = myObjects.Seek (theObj);
|
||||
if (aStat == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theIsActive
|
||||
|| (theMode == -1
|
||||
&& theActiveFilter == AIS_SelectionModesConcurrency_Single))
|
||||
{
|
||||
if ((*aStat)->GraphicStatus() == AIS_DS_Displayed
|
||||
|| theIsForce)
|
||||
{
|
||||
if (theMode == -1)
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
mgrSelector->Deactivate (theObj, aModeIter.Value(), myMainSel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mgrSelector->Deactivate (theObj, theMode, myMainSel);
|
||||
}
|
||||
}
|
||||
|
||||
if (theMode == -1)
|
||||
{
|
||||
(*aStat)->ClearSelectionModes();
|
||||
}
|
||||
else
|
||||
{
|
||||
(*aStat)->RemoveSelectionMode (theMode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (theMode == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((*aStat)->SelectionModes().Size() == 1
|
||||
&& (*aStat)->SelectionModes().First() == theMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((*aStat)->GraphicStatus() == AIS_DS_Displayed
|
||||
|| theIsForce)
|
||||
{
|
||||
switch (theActiveFilter)
|
||||
{
|
||||
case AIS_SelectionModesConcurrency_Single:
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
mgrSelector->Deactivate (theObj, aModeIter.Value(), myMainSel);
|
||||
}
|
||||
(*aStat)->ClearSelectionModes();
|
||||
break;
|
||||
}
|
||||
case AIS_SelectionModesConcurrency_GlobalOrLocal:
|
||||
{
|
||||
const Standard_Integer aGlobSelMode = theObj->GlobalSelectionMode();
|
||||
TColStd_ListOfInteger aRemovedModes;
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
if ((theMode == aGlobSelMode && aModeIter.Value() != aGlobSelMode)
|
||||
|| (theMode != aGlobSelMode && aModeIter.Value() == aGlobSelMode))
|
||||
{
|
||||
mgrSelector->Deactivate (theObj, aModeIter.Value(), myMainSel);
|
||||
aRemovedModes.Append (aModeIter.Value());
|
||||
}
|
||||
}
|
||||
if (aRemovedModes.Size() == (*aStat)->SelectionModes().Size())
|
||||
{
|
||||
(*aStat)->ClearSelectionModes();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter (aRemovedModes); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
(*aStat)->RemoveSelectionMode (aModeIter.Value());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AIS_SelectionModesConcurrency_Multiple:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
mgrSelector->Activate (theObj, theMode, myMainSel);
|
||||
}
|
||||
(*aStat)->AddSelectionMode (theMode);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -269,52 +363,6 @@ Handle( StdSelect_ViewerSelector3d ) AIS_InteractiveContext::LocalSelector() con
|
||||
return myLocalContexts( myCurLocalIndex )->MainSelector();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DeActivate
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::
|
||||
Deactivate(const Handle(AIS_InteractiveObject)& anIObj)
|
||||
{
|
||||
if(!HasOpenedContext()){
|
||||
if(!myObjects.IsBound(anIObj)) return;
|
||||
TColStd_ListIteratorOfListOfInteger ItL;
|
||||
for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
|
||||
ItL.More();
|
||||
ItL.Next()){
|
||||
if(myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
|
||||
mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
|
||||
}
|
||||
myObjects(anIObj)->ClearSelectionModes();
|
||||
}
|
||||
else{
|
||||
const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
|
||||
LC->Deactivate(anIObj);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Deactivate
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_InteractiveContext::Deactivate(const Handle(AIS_InteractiveObject)& anIObj,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
if(!HasOpenedContext()){
|
||||
if(!myObjects.IsBound(anIObj)) return;
|
||||
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
|
||||
|
||||
if(STAT->GraphicStatus() == AIS_DS_Displayed)
|
||||
mgrSelector->Deactivate(anIObj,aMode,myMainSel);
|
||||
STAT->RemoveSelectionMode(aMode);
|
||||
}
|
||||
else{
|
||||
myLocalContexts(myCurLocalIndex)->DeactivateMode(anIObj,aMode);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// function : Deactivate
|
||||
// purpose :
|
||||
|
@@ -376,48 +376,95 @@ void AIS_LocalContext::Clear(const AIS_ClearMode aType)
|
||||
ClearDetected();
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ActivateMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelectable,
|
||||
const Standard_Integer aMode)
|
||||
//=======================================================================
|
||||
//function : SetSelectionModeActive
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_LocalContext::SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Standard_Integer theMode,
|
||||
const Standard_Boolean theIsActive,
|
||||
const AIS_SelectionModesConcurrency theActiveFilter)
|
||||
{
|
||||
if(!myActiveObjects.IsBound(aSelectable)) return;
|
||||
// if(myActiveObjects(aSelectable)->SelectionMode()!=aMode)
|
||||
// mySM->Deactivate(aSelectable,aMode,myMainVS);
|
||||
if(aMode != -1){
|
||||
myActiveObjects(aSelectable)->AddSelectionMode(aMode);
|
||||
mySM->Activate(aSelectable,aMode,myMainVS);
|
||||
const Handle(AIS_LocalStatus)* aStat = myActiveObjects.Seek (theObj);
|
||||
if (aStat == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ActivateMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_LocalContext::DeactivateMode(const Handle(AIS_InteractiveObject)& aSelectable,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
if(!myActiveObjects.IsBound(aSelectable)) return;
|
||||
|
||||
if(aMode==-1) return;
|
||||
|
||||
myActiveObjects(aSelectable)->RemoveSelectionMode(aMode);
|
||||
mySM->Deactivate(aSelectable,aMode,myMainVS);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ActivateMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
if (!theIsActive
|
||||
|| (theMode == -1
|
||||
&& theActiveFilter == AIS_SelectionModesConcurrency_Single))
|
||||
{
|
||||
if (theMode == -1)
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
mySM->Deactivate (theObj, aModeIter.Value(), myMainVS);
|
||||
}
|
||||
(*aStat)->ClearSelectionModes();
|
||||
}
|
||||
else
|
||||
{
|
||||
mySM->Deactivate (theObj, theMode, myMainVS);
|
||||
(*aStat)->RemoveSelectionMode (theMode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (theMode == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ((*aStat)->SelectionModes().Size() == 1
|
||||
&& (*aStat)->SelectionModes().First() == theMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectable)
|
||||
{
|
||||
if(!myActiveObjects.IsBound(aSelectable)) return;
|
||||
|
||||
mySM->Deactivate(aSelectable, -1, myMainVS);
|
||||
myActiveObjects(aSelectable)->ClearSelectionModes();
|
||||
switch (theActiveFilter)
|
||||
{
|
||||
case AIS_SelectionModesConcurrency_Single:
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
mySM->Deactivate (theObj, aModeIter.Value(), myMainVS);
|
||||
}
|
||||
(*aStat)->ClearSelectionModes();
|
||||
break;
|
||||
}
|
||||
case AIS_SelectionModesConcurrency_GlobalOrLocal:
|
||||
{
|
||||
const Standard_Integer aGlobSelMode = theObj->GlobalSelectionMode();
|
||||
TColStd_ListOfInteger aRemovedModes;
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
if ((theMode == aGlobSelMode && aModeIter.Value() != aGlobSelMode)
|
||||
|| (theMode != aGlobSelMode && aModeIter.Value() == aGlobSelMode))
|
||||
{
|
||||
mySM->Deactivate (theObj, aModeIter.Value(), myMainVS);
|
||||
aRemovedModes.Append (aModeIter.Value());
|
||||
}
|
||||
}
|
||||
if (aRemovedModes.Size() == (*aStat)->SelectionModes().Size())
|
||||
{
|
||||
(*aStat)->ClearSelectionModes();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter (aRemovedModes); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
(*aStat)->RemoveSelectionMode (aModeIter.Value());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AIS_SelectionModesConcurrency_Multiple:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
mySM->Activate (theObj, theMode, myMainVS);
|
||||
(*aStat)->AddSelectionMode (theMode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <AIS_SequenceOfInteractive.hxx>
|
||||
#include <AIS_SelectionModesConcurrency.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <AIS_ClearMode.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
@@ -120,12 +121,26 @@ public:
|
||||
//! the selector (filters, modeof activation, objects...)
|
||||
Standard_EXPORT void Clear (const AIS_ClearMode atype = AIS_CM_All);
|
||||
|
||||
Standard_EXPORT void SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Standard_Integer theMode,
|
||||
const Standard_Boolean theIsActive,
|
||||
const AIS_SelectionModesConcurrency theActiveFilter);
|
||||
|
||||
//! optional : activation of a mode which is not 0 for a selectable...
|
||||
Standard_EXPORT void ActivateMode (const Handle(AIS_InteractiveObject)& aSelectable, const Standard_Integer aMode);
|
||||
|
||||
Standard_EXPORT void DeactivateMode (const Handle(AIS_InteractiveObject)& aSelectable, const Standard_Integer aMode);
|
||||
|
||||
Standard_EXPORT void Deactivate (const Handle(AIS_InteractiveObject)& aSelectable);
|
||||
void ActivateMode (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode)
|
||||
{
|
||||
SetSelectionModeActive (theObj, theMode, Standard_True, AIS_SelectionModesConcurrency_GlobalOrLocal);
|
||||
}
|
||||
|
||||
void DeactivateMode (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode)
|
||||
{
|
||||
SetSelectionModeActive (theObj, theMode, Standard_False, AIS_SelectionModesConcurrency_GlobalOrLocal);
|
||||
}
|
||||
|
||||
void Deactivate (const Handle(AIS_InteractiveObject)& theObj)
|
||||
{
|
||||
SetSelectionModeActive (theObj, -1, Standard_False, AIS_SelectionModesConcurrency_Single);
|
||||
}
|
||||
|
||||
//! decomposition of shapes into <aType>
|
||||
Standard_EXPORT void ActivateStandardMode (const TopAbs_ShapeEnum aType);
|
||||
|
25
src/AIS/AIS_SelectionModesConcurrency.hxx
Normal file
25
src/AIS/AIS_SelectionModesConcurrency.hxx
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _AIS_SelectionModesConcurrency_HeaderFile
|
||||
#define _AIS_SelectionModesConcurrency_HeaderFile
|
||||
|
||||
//! The mode specifying how multiple active Selection Modes should be treated during activation of new one.
|
||||
enum AIS_SelectionModesConcurrency
|
||||
{
|
||||
AIS_SelectionModesConcurrency_Single, //!< only one selection mode can be activated at the same moment - previously activated should be deactivated
|
||||
AIS_SelectionModesConcurrency_GlobalOrLocal, //!< either Global (AIS_InteractiveObject::GlobalSelectionMode() or Local (multiple) selection modes can be active at the same moment
|
||||
AIS_SelectionModesConcurrency_Multiple, //!< any combination of selection modes can be activated
|
||||
};
|
||||
|
||||
#endif // _AIS_SelectionModesConcurrency_HeaderFile
|
@@ -146,6 +146,7 @@ AIS_RubberBand.cxx
|
||||
AIS_Selection.cxx
|
||||
AIS_Selection.hxx
|
||||
AIS_SelectStatus.hxx
|
||||
AIS_SelectionModesConcurrency.hxx
|
||||
AIS_SequenceOfDimension.hxx
|
||||
AIS_SequenceOfInteractive.hxx
|
||||
AIS_Shape.cxx
|
||||
|
Reference in New Issue
Block a user