From 716f7ba09656559d4059bb68a30c8d4ec2fcadad Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 7 Jul 2015 13:08:30 +0300 Subject: [PATCH] Issue #591 - Highlight of the first argument of constraints It was possible to select an extrusion result in OB for a new created extrusion. --- src/ModuleBase/ModuleBase_IViewer.h | 4 +++ src/ModuleBase/ModuleBase_WidgetValidated.cpp | 10 ++---- src/NewGeom/NewGeom_SalomeViewer.cpp | 17 +++++++++ src/NewGeom/NewGeom_SalomeViewer.h | 4 +++ src/XGUI/XGUI_Displayer.cpp | 36 ++++++++++++------- src/XGUI/XGUI_Displayer.h | 4 +++ src/XGUI/XGUI_ViewerProxy.cpp | 6 ++++ src/XGUI/XGUI_ViewerProxy.h | 4 +++ 8 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index 5c62cb5fa..3e557504a 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -70,6 +70,10 @@ Q_OBJECT /// \param theFilter a selection filter virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0; + /// Returns true if the selection filter is set to the viewer + /// \param theFilter a selection filter + virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0; + /// Remove all selection filters from the viewer virtual void clearSelectionFilters() = 0; diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 49734b621..a90eadac2 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -195,17 +195,11 @@ bool ModuleBase_WidgetValidated::isFilterActivated() const bool isActivated = false; Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter(); + ModuleBase_IViewer* aViewer = myWorkshop->viewer(); - const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters(); - SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); - for (; aIt.More(); aIt.Next()) { - if (aSelFilter.Access() == aIt.Value().Access()) - isActivated = true; - } - return isActivated; + return aViewer->hasSelectionFilter(aSelFilter); } - void ModuleBase_WidgetValidated::activateFilters(const bool toActivate) { ModuleBase_IViewer* aViewer = myWorkshop->viewer(); diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index a9b806519..41baca6a8 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -8,6 +8,8 @@ #include +#include + #include #include @@ -333,6 +335,21 @@ void NewGeom_SalomeViewer::removeSelectionFilter(const Handle(SelectMgr_Filter)& } } +//*************************************** +bool NewGeom_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) +{ + bool aFoundFilter = false; + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (!aContext.IsNull()) { + const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); + SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); + for (; aIt.More() && !aFoundFilter; aIt.Next()) { + aFoundFilter = theFilter.Access() == aIt.Value().Access(); + } + } + return aFoundFilter; +} + //*************************************** void NewGeom_SalomeViewer::clearSelectionFilters() { diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 8012c4a01..dcc9acee1 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -110,6 +110,10 @@ Q_OBJECT /// Remove selection filter from the viewer virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); + /// Returns true if the selection filter is set to the viewer + /// \param theFilter a selection filter + virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); + /// Remove all selection filters from the viewer virtual void clearSelectionFilters(); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 68d6ae9dc..8b055e502 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -729,20 +729,10 @@ XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) con void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) { Handle(AIS_InteractiveContext) aContext = AISContext(); - if (aContext.IsNull()) + if (aContext.IsNull() || hasSelectionFilter(theFilter)) return; - const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); - SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); - for (; aIt.More(); aIt.Next()) { - if (theFilter.Access() == aIt.Value().Access()) - return; - } + Handle(SelectMgr_CompositionFilter) aCompFilter = GetFilter(); - const SelectMgr_ListOfFilter& aStoredFilters = aCompFilter->StoredFilters(); - for (aIt.Initialize(aStoredFilters); aIt.More(); aIt.Next()) { - if (theFilter.Access() == aIt.Value().Access()) - return; - } aCompFilter->Add(theFilter); #ifdef DEBUG_SELECTION_FILTERS int aCount = GetFilter()->StoredFilters().Extent(); @@ -764,6 +754,28 @@ void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFi #endif } +bool XGUI_Displayer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) +{ + bool aFilterFound = false; + + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (aContext.IsNull()) + return aFilterFound; + const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); + SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); + for (; aIt.More() && !aFilterFound; aIt.Next()) { + if (theFilter.Access() == aIt.Value().Access()) + aFilterFound = true; + } + Handle(SelectMgr_CompositionFilter) aCompFilter = GetFilter(); + const SelectMgr_ListOfFilter& aStoredFilters = aCompFilter->StoredFilters(); + for (aIt.Initialize(aStoredFilters); aIt.More() && !aFilterFound; aIt.Next()) { + if (theFilter.Access() == aIt.Value().Access()) + aFilterFound = true; + } + return aFilterFound; +} + void XGUI_Displayer::removeFilters() { Handle(AIS_InteractiveContext) aContext = AISContext(); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 910dcc37b..c64bccb21 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -117,6 +117,10 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \param theFilter a filter instance void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); + /// Returns true if the selection filter is set to the viewer + /// \param theFilter a selection filter + virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); + /// Remove all selection filters void removeFilters(); diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 2f5ba0004..e19cb39b0 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -284,6 +284,12 @@ void XGUI_ViewerProxy::removeSelectionFilter(const Handle(SelectMgr_Filter)& the myWorkshop->displayer()->removeSelectionFilter(theFilter); } +//*************************************** +bool XGUI_ViewerProxy::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) +{ + return myWorkshop->displayer()->hasSelectionFilter(theFilter); +} + //*************************************** void XGUI_ViewerProxy::clearSelectionFilters() { diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index f7c40d4c1..5e8f75a63 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -62,6 +62,10 @@ Q_OBJECT /// Remove selection filter from the viewer virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); + /// Returns true if the selection filter is set to the viewer + /// \param theFilter a selection filter + virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter); + /// Remove all selection filters from the viewer virtual void clearSelectionFilters(); -- 2.39.2