mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0031221: Visualization - selection filter in context
(cherry picked from commit 7f8014f280f940a7fdeceaf8a612769dc43eaa79)
This commit is contained in:
@@ -39,6 +39,8 @@
|
|||||||
#include <Prs3d_ShadingAspect.hxx>
|
#include <Prs3d_ShadingAspect.hxx>
|
||||||
#include <PrsMgr_PresentableObject.hxx>
|
#include <PrsMgr_PresentableObject.hxx>
|
||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
|
#include <SelectMgr_AndFilter.hxx>
|
||||||
|
#include <SelectMgr_DisabledObjectsFilter.hxx>
|
||||||
#include <SelectMgr_EntityOwner.hxx>
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
#include <SelectMgr_Filter.hxx>
|
#include <SelectMgr_Filter.hxx>
|
||||||
#include <SelectMgr_OrFilter.hxx>
|
#include <SelectMgr_OrFilter.hxx>
|
||||||
@@ -108,7 +110,7 @@ myMainVwr(MainViewer),
|
|||||||
myMainSel(new StdSelect_ViewerSelector3d()),
|
myMainSel(new StdSelect_ViewerSelector3d()),
|
||||||
myToHilightSelected(Standard_True),
|
myToHilightSelected(Standard_True),
|
||||||
mySelection(new AIS_Selection()),
|
mySelection(new AIS_Selection()),
|
||||||
myFilters(new SelectMgr_OrFilter()),
|
myFilters(new SelectMgr_AndFilter()),
|
||||||
myDefaultDrawer(new Prs3d_Drawer()),
|
myDefaultDrawer(new Prs3d_Drawer()),
|
||||||
myCurDetected(0),
|
myCurDetected(0),
|
||||||
myCurHighlighted(0),
|
myCurHighlighted(0),
|
||||||
@@ -116,6 +118,8 @@ myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable),
|
|||||||
myAutoHilight(Standard_True),
|
myAutoHilight(Standard_True),
|
||||||
myIsAutoActivateSelMode(Standard_True)
|
myIsAutoActivateSelMode(Standard_True)
|
||||||
{
|
{
|
||||||
|
myFilters->Add (new SelectMgr_DisabledObjectsFilter());
|
||||||
|
|
||||||
mgrSelector = new SelectMgr_SelectionManager (myMainSel);
|
mgrSelector = new SelectMgr_SelectionManager (myMainSel);
|
||||||
|
|
||||||
myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
|
myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
class SelectMgr_SelectionManager;
|
class SelectMgr_SelectionManager;
|
||||||
class V3d_Viewer;
|
class V3d_Viewer;
|
||||||
class SelectMgr_OrFilter;
|
class SelectMgr_AndFilter;
|
||||||
class V3d_View;
|
class V3d_View;
|
||||||
class TopLoc_Location;
|
class TopLoc_Location;
|
||||||
class TCollection_ExtendedString;
|
class TCollection_ExtendedString;
|
||||||
@@ -767,13 +767,20 @@ public: //! @name management of active Selection Modes
|
|||||||
|
|
||||||
public: //! @name Selection Filters management
|
public: //! @name Selection Filters management
|
||||||
|
|
||||||
//! Returns the list of filters active in a local context.
|
//! Allows you to set the filter.
|
||||||
Standard_EXPORT const SelectMgr_ListOfFilter& Filters() const;
|
Standard_EXPORT void SetFilter (const Handle(SelectMgr_Filter)& theFilter);
|
||||||
|
|
||||||
//! Allows you to add the filter.
|
//! Returns the filter. Use with global is in false to get the filter, that is set with SetFilter.
|
||||||
|
//! If global filter is true, it returns whole filter used in the context (with an internal default filter)
|
||||||
|
Standard_EXPORT Handle(SelectMgr_Filter) Filter (const Standard_Boolean isGlobalFilter = Standard_False) const;
|
||||||
|
|
||||||
|
//! Returns the list of filters active in a local context.
|
||||||
|
Standard_EXPORT SelectMgr_ListOfFilter Filters() const;
|
||||||
|
|
||||||
|
//! Allows you to add the filter. Default filter here is Or filter.
|
||||||
Standard_EXPORT void AddFilter (const Handle(SelectMgr_Filter)& theFilter);
|
Standard_EXPORT void AddFilter (const Handle(SelectMgr_Filter)& theFilter);
|
||||||
|
|
||||||
//! Removes a filter from context.
|
//! Removes a filter from context. Default filter here is Or filter
|
||||||
Standard_EXPORT void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter);
|
Standard_EXPORT void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter);
|
||||||
|
|
||||||
//! Remove all filters from context.
|
//! Remove all filters from context.
|
||||||
@@ -1437,7 +1444,7 @@ protected: //! @name internal fields
|
|||||||
Handle(SelectMgr_EntityOwner) myLastPicked;
|
Handle(SelectMgr_EntityOwner) myLastPicked;
|
||||||
Standard_Boolean myToHilightSelected;
|
Standard_Boolean myToHilightSelected;
|
||||||
Handle(AIS_Selection) mySelection;
|
Handle(AIS_Selection) mySelection;
|
||||||
Handle(SelectMgr_OrFilter) myFilters;
|
Handle(SelectMgr_AndFilter) myFilters;
|
||||||
Handle(Prs3d_Drawer) myDefaultDrawer;
|
Handle(Prs3d_Drawer) myDefaultDrawer;
|
||||||
Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB];
|
Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB];
|
||||||
TColStd_SequenceOfInteger myDetectedSeq;
|
TColStd_SequenceOfInteger myDetectedSeq;
|
||||||
|
@@ -31,8 +31,11 @@
|
|||||||
#include <Prs3d_Presentation.hxx>
|
#include <Prs3d_Presentation.hxx>
|
||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
#include <Select3D_SensitiveEntity.hxx>
|
#include <Select3D_SensitiveEntity.hxx>
|
||||||
|
#include <SelectMgr_AndFilter.hxx>
|
||||||
|
#include <SelectMgr_DisabledObjectsFilter.hxx>
|
||||||
#include <SelectMgr_EntityOwner.hxx>
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
#include <SelectMgr_Filter.hxx>
|
#include <SelectMgr_Filter.hxx>
|
||||||
|
#include <SelectMgr_FilterReaction.hxx>
|
||||||
#include <SelectMgr_OrFilter.hxx>
|
#include <SelectMgr_OrFilter.hxx>
|
||||||
#include <SelectMgr_Selection.hxx>
|
#include <SelectMgr_Selection.hxx>
|
||||||
#include <SelectMgr_SelectionManager.hxx>
|
#include <SelectMgr_SelectionManager.hxx>
|
||||||
@@ -336,7 +339,8 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
|||||||
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
|
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
|
||||||
Standard_Boolean toUpdateViewer = Standard_False;
|
Standard_Boolean toUpdateViewer = Standard_False;
|
||||||
|
|
||||||
myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
|
Handle(SelectMgr_DisabledObjectsFilter) anObjectsFilter = Handle(SelectMgr_DisabledObjectsFilter)::DownCast (myFilters->StoredFilters().First());
|
||||||
|
anObjectsFilter->SetDisabledObjects (theView->View()->HiddenObjects());
|
||||||
myMainSel->Pick (theXPix, theYPix, theView);
|
myMainSel->Pick (theXPix, theYPix, theView);
|
||||||
|
|
||||||
// filling of myAISDetectedSeq sequence storing information about detected AIS objects
|
// filling of myAISDetectedSeq sequence storing information about detected AIS objects
|
||||||
@@ -348,7 +352,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
|||||||
{
|
{
|
||||||
Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
|
Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
|
||||||
if (anOwner.IsNull()
|
if (anOwner.IsNull()
|
||||||
|| !myFilters->IsOk (anOwner))
|
|| !myFilters->IsOk (anOwner, SelectMgr_FilterReaction_Highlight))
|
||||||
{
|
{
|
||||||
if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
|
if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
|
||||||
{
|
{
|
||||||
@@ -834,7 +838,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
|
|||||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||||
{
|
{
|
||||||
const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
|
const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
|
||||||
if (!myFilters->IsOk (aSelOwner))
|
if (!myFilters->IsOk (aSelOwner, SelectMgr_FilterReaction_Select))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -882,7 +886,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
|
|||||||
void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
|
void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||||
const Standard_Boolean theToUpdateViewer)
|
const Standard_Boolean theToUpdateViewer)
|
||||||
{
|
{
|
||||||
if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
|
if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner, SelectMgr_FilterReaction_Select))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
||||||
@@ -958,7 +962,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
|
|||||||
if (theOwner.IsNull() || !theOwner->HasSelectable())
|
if (theOwner.IsNull() || !theOwner->HasSelectable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
|
if (!myFilters->IsOk(theOwner, SelectMgr_FilterReaction_Select) && !theOwner->IsSelected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mySelection->Select (theOwner);
|
mySelection->Select (theOwner);
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include <SelectMgr_EntityOwner.hxx>
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
#include <SelectMgr_Filter.hxx>
|
#include <SelectMgr_Filter.hxx>
|
||||||
#include <SelectMgr_OrFilter.hxx>
|
#include <SelectMgr_OrFilter.hxx>
|
||||||
|
#include <SelectMgr_AndFilter.hxx>
|
||||||
#include <SelectMgr_SelectionManager.hxx>
|
#include <SelectMgr_SelectionManager.hxx>
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
#include <StdSelect_ViewerSelector3d.hxx>
|
#include <StdSelect_ViewerSelector3d.hxx>
|
||||||
@@ -264,22 +265,74 @@ void AIS_InteractiveContext::SubIntensityOff (const Handle(AIS_InteractiveObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetFilter
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_InteractiveContext::SetFilter (const Handle(SelectMgr_Filter)& theFilter)
|
||||||
|
{
|
||||||
|
Handle(SelectMgr_Filter) aDefFilter = myFilters->StoredFilters().First();
|
||||||
|
if (myFilters->StoredFilters().Size() < 2)
|
||||||
|
{
|
||||||
|
myFilters->Clear();
|
||||||
|
myFilters->Add (aDefFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
myFilters->Add (theFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Filter
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Handle(SelectMgr_Filter) AIS_InteractiveContext::Filter (const Standard_Boolean isGlobalFilter) const
|
||||||
|
{
|
||||||
|
if (isGlobalFilter)
|
||||||
|
return myFilters;
|
||||||
|
|
||||||
|
if (myFilters->StoredFilters().Size() < 2)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
SelectMgr_ListIteratorOfListOfFilter anIterator (myFilters->StoredFilters());
|
||||||
|
anIterator.Next();
|
||||||
|
return anIterator.Value();
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AddFilter
|
//function : AddFilter
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter)
|
void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& theFilter)
|
||||||
{
|
{
|
||||||
myFilters->Add(aFilter);
|
Handle(SelectMgr_Filter) aFilter = Filter();
|
||||||
|
if (aFilter.IsNull())
|
||||||
|
SetFilter (new SelectMgr_OrFilter());
|
||||||
|
|
||||||
|
Handle (SelectMgr_CompositionFilter) aCompositeFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aFilter);
|
||||||
|
if (aCompositeFilter.IsNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (aCompositeFilter->IsIn (theFilter))
|
||||||
|
return;
|
||||||
|
|
||||||
|
aCompositeFilter->Add (theFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : RemoveFilter
|
//function : RemoveFilter
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
|
void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& theFilter)
|
||||||
{
|
{
|
||||||
myFilters->Remove(aFilter);
|
Handle(SelectMgr_Filter) aFilter = Filter();
|
||||||
|
if (aFilter.IsNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Handle (SelectMgr_CompositionFilter) aCompositeFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aFilter);
|
||||||
|
if (aCompositeFilter.IsNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
aCompositeFilter->Remove (theFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -289,16 +342,24 @@ void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilte
|
|||||||
|
|
||||||
void AIS_InteractiveContext::RemoveFilters()
|
void AIS_InteractiveContext::RemoveFilters()
|
||||||
{
|
{
|
||||||
myFilters->Clear();
|
SetFilter (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Filters
|
//function : Filters
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const
|
SelectMgr_ListOfFilter AIS_InteractiveContext::Filters() const
|
||||||
{
|
{
|
||||||
return myFilters->StoredFilters();
|
Handle(SelectMgr_Filter) aFilter = Filter();
|
||||||
|
if (aFilter.IsNull())
|
||||||
|
return SelectMgr_ListOfFilter();
|
||||||
|
|
||||||
|
Handle (SelectMgr_CompositionFilter) aCompositeFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aFilter);
|
||||||
|
if (aCompositeFilter.IsNull())
|
||||||
|
return SelectMgr_ListOfFilter();
|
||||||
|
|
||||||
|
return aCompositeFilter->StoredFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
#include <SelectMgr_EntityOwner.hxx>
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
#include <SelectMgr_Filter.hxx>
|
#include <SelectMgr_Filter.hxx>
|
||||||
#include <SelectMgr_OrFilter.hxx>
|
#include <SelectMgr_AndFilter.hxx>
|
||||||
#include <SelectMgr_SelectionManager.hxx>
|
#include <SelectMgr_SelectionManager.hxx>
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
@@ -180,7 +180,7 @@ AIS_SelectStatus AIS_Selection::selectOwner (const Handle(SelectMgr_EntityOwner)
|
|||||||
const int theSelScheme,
|
const int theSelScheme,
|
||||||
const Handle(SelectMgr_Filter)& theFilter)
|
const Handle(SelectMgr_Filter)& theFilter)
|
||||||
{
|
{
|
||||||
if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner))
|
if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner, SelectMgr_FilterReaction_Select))
|
||||||
return AIS_SS_NotDone;
|
return AIS_SS_NotDone;
|
||||||
|
|
||||||
if (theSelScheme & AIS_SelectionScheme_Add)
|
if (theSelScheme & AIS_SelectionScheme_Add)
|
||||||
|
@@ -5,10 +5,13 @@ SelectMgr_BaseFrustum.hxx
|
|||||||
SelectMgr_CompositionFilter.cxx
|
SelectMgr_CompositionFilter.cxx
|
||||||
SelectMgr_CompositionFilter.hxx
|
SelectMgr_CompositionFilter.hxx
|
||||||
SelectMgr_CompositionFilter.lxx
|
SelectMgr_CompositionFilter.lxx
|
||||||
|
SelectMgr_DisabledObjectsFilter.cxx
|
||||||
|
SelectMgr_DisabledObjectsFilter.hxx
|
||||||
SelectMgr_EntityOwner.cxx
|
SelectMgr_EntityOwner.cxx
|
||||||
SelectMgr_EntityOwner.hxx
|
SelectMgr_EntityOwner.hxx
|
||||||
SelectMgr_Filter.cxx
|
SelectMgr_Filter.cxx
|
||||||
SelectMgr_Filter.hxx
|
SelectMgr_Filter.hxx
|
||||||
|
SelectMgr_FilterReaction.hxx
|
||||||
SelectMgr_Frustum.hxx
|
SelectMgr_Frustum.hxx
|
||||||
SelectMgr_Frustum.lxx
|
SelectMgr_Frustum.lxx
|
||||||
SelectMgr_FrustumBuilder.cxx
|
SelectMgr_FrustumBuilder.cxx
|
||||||
|
@@ -24,11 +24,12 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
|
|||||||
SelectMgr_AndFilter::SelectMgr_AndFilter()
|
SelectMgr_AndFilter::SelectMgr_AndFilter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
|
Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theObj,
|
||||||
|
const SelectMgr_FilterReaction& theReaction) const
|
||||||
{
|
{
|
||||||
SelectMgr_ListIteratorOfListOfFilter it(myFilters);
|
SelectMgr_ListIteratorOfListOfFilter it(myFilters);
|
||||||
for ( ; it.More();it.Next())
|
for ( ; it.More();it.Next())
|
||||||
if(!it.Value()->IsOk(anobj))
|
if(!it.Value()->IsOk(theObj, theReaction))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
@@ -40,9 +40,11 @@ public:
|
|||||||
//! more types of entity.
|
//! more types of entity.
|
||||||
Standard_EXPORT SelectMgr_AndFilter();
|
Standard_EXPORT SelectMgr_AndFilter();
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const Standard_OVERRIDE
|
||||||
|
{ (void)theObj; return Standard_False; }
|
||||||
|
|
||||||
|
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& theObj,
|
||||||
|
const SelectMgr_FilterReaction& theReaction) const Standard_OVERRIDE;
|
||||||
|
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
|
DEFINE_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
|
||||||
|
53
src/SelectMgr/SelectMgr_DisabledObjectsFilter.cxx
Normal file
53
src/SelectMgr/SelectMgr_DisabledObjectsFilter.cxx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
|
#include <SelectMgr_Filter.hxx>
|
||||||
|
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
|
||||||
|
#include <SelectMgr_DisabledObjectsFilter.hxx>
|
||||||
|
#include <SelectMgr_SelectableObject.hxx>
|
||||||
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_DisabledObjectsFilter, SelectMgr_Filter)
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//function : SelectMgr_DisabledObjectsFilter
|
||||||
|
//purpose :
|
||||||
|
//=============================================================================
|
||||||
|
SelectMgr_DisabledObjectsFilter::SelectMgr_DisabledObjectsFilter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//function : SetDisabledObjects
|
||||||
|
//purpose :
|
||||||
|
//=============================================================================
|
||||||
|
void SelectMgr_DisabledObjectsFilter::SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects)
|
||||||
|
{
|
||||||
|
myDisabledObjects = theObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//function : IsOk
|
||||||
|
//purpose :
|
||||||
|
//=============================================================================
|
||||||
|
Standard_Boolean SelectMgr_DisabledObjectsFilter::IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const
|
||||||
|
{
|
||||||
|
const SelectMgr_SelectableObject* aSelectable = theObj->Selectable().operator->();
|
||||||
|
if (!myDisabledObjects.IsNull()
|
||||||
|
&& myDisabledObjects->Contains (aSelectable))
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
59
src/SelectMgr/SelectMgr_DisabledObjectsFilter.hxx
Normal file
59
src/SelectMgr/SelectMgr_DisabledObjectsFilter.hxx
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
//
|
||||||
|
// 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 _SelectMgr_DisabledObjectsFilter_HeaderFile
|
||||||
|
#define _SelectMgr_DisabledObjectsFilter_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
|
#include <Graphic3d_NMapOfTransient.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
|
||||||
|
class SelectMgr_EntityOwner;
|
||||||
|
|
||||||
|
|
||||||
|
class SelectMgr_DisabledObjectsFilter;
|
||||||
|
DEFINE_STANDARD_HANDLE(SelectMgr_DisabledObjectsFilter, SelectMgr_Filter)
|
||||||
|
|
||||||
|
//! A framework to define an or selection filter.
|
||||||
|
//! This selects one or another type of sensitive entity.
|
||||||
|
class SelectMgr_DisabledObjectsFilter : public SelectMgr_Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructs an empty or selection filter.
|
||||||
|
Standard_EXPORT SelectMgr_DisabledObjectsFilter();
|
||||||
|
|
||||||
|
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
||||||
|
|
||||||
|
//! Disable selection of specified objects.
|
||||||
|
Standard_EXPORT void SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects);
|
||||||
|
|
||||||
|
|
||||||
|
DEFINE_STANDARD_RTTIEXT(SelectMgr_DisabledObjectsFilter, SelectMgr_Filter)
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Handle(Graphic3d_NMapOfTransient) myDisabledObjects;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _SelectMgr_DisabledObjectsFilter_HeaderFile
|
@@ -20,6 +20,7 @@
|
|||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
|
#include <SelectMgr_FilterReaction.hxx>
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
#include <Standard_Boolean.hxx>
|
||||||
#include <TopAbs_ShapeEnum.hxx>
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
@@ -60,6 +61,24 @@ public:
|
|||||||
//! virtual function ActsOn.
|
//! virtual function ActsOn.
|
||||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const = 0;
|
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const = 0;
|
||||||
|
|
||||||
|
//! Indicates that the selected Interactive Object
|
||||||
|
//! passes the filter. The owner, anObj, can be either
|
||||||
|
//! direct or user. A direct owner is the corresponding
|
||||||
|
//! construction element, whereas a user is the
|
||||||
|
//! compound shape of which the entity forms a part.
|
||||||
|
//! When an object is detected by the mouse - in AIS,
|
||||||
|
//! this is done through a context selector - its owner
|
||||||
|
//! is passed to the filter as an argument.
|
||||||
|
//! If the object returns Standard_True, it is kept; if
|
||||||
|
//! not, it is rejected.
|
||||||
|
//! If you are creating a filter class inheriting this
|
||||||
|
//! framework, and the daughter class is to be used in
|
||||||
|
//! an AIS local context, you will need to implement the
|
||||||
|
//! virtual function ActsOn.
|
||||||
|
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& theObj,
|
||||||
|
const SelectMgr_FilterReaction& theReaction) const
|
||||||
|
{ (void)theReaction; return IsOk (theObj); }
|
||||||
|
|
||||||
//! Returns true in an AIS local context, if this filter
|
//! Returns true in an AIS local context, if this filter
|
||||||
//! operates on a type of subshape defined in a filter
|
//! operates on a type of subshape defined in a filter
|
||||||
//! class inheriting this framework.
|
//! class inheriting this framework.
|
||||||
|
26
src/SelectMgr/SelectMgr_FilterReaction.hxx
Normal file
26
src/SelectMgr/SelectMgr_FilterReaction.hxx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2019 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 _SelectMgr_FilterReaction_HeaderFile
|
||||||
|
#define _SelectMgr_FilterReaction_HeaderFile
|
||||||
|
|
||||||
|
//! Enumeration defines picking reaction - which action causes the filter check
|
||||||
|
enum SelectMgr_FilterReaction
|
||||||
|
{
|
||||||
|
SelectMgr_FilterReaction_Empty = 0x0000, //!< do nothing
|
||||||
|
SelectMgr_FilterReaction_Highlight = 0x0001, //!< the reaction to highlght presentation (MoveTo)
|
||||||
|
SelectMgr_FilterReaction_Select = 0x0002, //!< the reaction to highlght presentation (Select)
|
||||||
|
SelectMgr_FilterReaction_SelectAndHighlight = SelectMgr_FilterReaction_Highlight | SelectMgr_FilterReaction_Select
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _SelectMgr_FilterReaction_HeaderFile
|
@@ -15,9 +15,7 @@
|
|||||||
|
|
||||||
#include <SelectMgr_EntityOwner.hxx>
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
#include <SelectMgr_Filter.hxx>
|
#include <SelectMgr_Filter.hxx>
|
||||||
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
|
|
||||||
#include <SelectMgr_OrFilter.hxx>
|
#include <SelectMgr_OrFilter.hxx>
|
||||||
#include <SelectMgr_SelectableObject.hxx>
|
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_OrFilter,SelectMgr_CompositionFilter)
|
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_OrFilter,SelectMgr_CompositionFilter)
|
||||||
@@ -30,28 +28,13 @@ SelectMgr_OrFilter::SelectMgr_OrFilter()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : SetDisabledObjects
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
void SelectMgr_OrFilter::SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects)
|
|
||||||
{
|
|
||||||
myDisabledObjects = theObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//function : IsOk
|
//function : IsOk
|
||||||
//purpose :
|
//purpose :
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
Standard_Boolean SelectMgr_OrFilter::IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const
|
Standard_Boolean SelectMgr_OrFilter::IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const
|
||||||
{
|
{
|
||||||
const SelectMgr_SelectableObject* aSelectable = theObj->Selectable().operator->();
|
if (myFilters.IsEmpty())
|
||||||
if (!myDisabledObjects.IsNull()
|
|
||||||
&& myDisabledObjects->Contains (aSelectable))
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
else if (myFilters.IsEmpty())
|
|
||||||
{
|
{
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
#include <Graphic3d_NMapOfTransient.hxx>
|
|
||||||
#include <SelectMgr_CompositionFilter.hxx>
|
#include <SelectMgr_CompositionFilter.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
#include <Standard_Boolean.hxx>
|
||||||
class SelectMgr_EntityOwner;
|
class SelectMgr_EntityOwner;
|
||||||
@@ -41,26 +40,11 @@ public:
|
|||||||
Standard_EXPORT SelectMgr_OrFilter();
|
Standard_EXPORT SelectMgr_OrFilter();
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
||||||
|
|
||||||
//! Disable selection of specified objects.
|
|
||||||
Standard_EXPORT void SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(SelectMgr_OrFilter,SelectMgr_CompositionFilter)
|
DEFINE_STANDARD_RTTIEXT(SelectMgr_OrFilter,SelectMgr_CompositionFilter)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
Handle(Graphic3d_NMapOfTransient) myDisabledObjects;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user