From 424c919fb1637e2f26d32ffba6ff6dc513a779b5 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 14 Dec 2017 13:30:55 +0300 Subject: [PATCH] FacePanel does not uses the workshop filters(avoid Sketch filters using) --- src/ModuleBase/ModuleBase_IModule.h | 5 ++++ src/PartSet/CMakeLists.txt | 1 - src/PartSet/PartSet_Module.cpp | 27 +++++++++---------- src/PartSet/PartSet_Module.h | 10 +++---- src/PartSet/PartSet_SketcherMgr.cpp | 4 +-- src/PartSet/PartSet_SketcherMgr.h | 8 +++--- src/XGUI/CMakeLists.txt | 1 + src/XGUI/XGUI_ActiveControlMgr.cpp | 1 + src/XGUI/XGUI_FacesPanel.cpp | 19 ++++++++++++- src/XGUI/XGUI_FacesPanel.h | 2 +- src/XGUI/XGUI_SelectionActivate.cpp | 11 +++++--- .../XGUI_SelectionFilterType.h} | 8 +++--- 12 files changed, 61 insertions(+), 36 deletions(-) rename src/{PartSet/PartSet_SelectionFilterType.h => XGUI/XGUI_SelectionFilterType.h} (91%) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 65d6088a1..058fe4761 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -245,6 +245,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theSelectionFilters [out] container of type value virtual QIntList selectionFilters() { return QIntList(); } + /// Returns selection filter + /// \param theType selection filter type + /// \param theFilter instance of filter + virtual Handle(SelectMgr_Filter) selectionFilter(const int theType) = 0; + /// Return true if the custom presentation is activated /// \param theFlag a flag of level of customization, which means that only part of sub-elements /// \return boolean value diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 36a107106..8bb95e123 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -43,7 +43,6 @@ SET(PROJECT_HEADERS PartSet_PreviewPlanes.h PartSet_PreviewSketchPlane.h PartSet_ResultSketchPrs.h - PartSet_SelectionFilterType.h PartSet_SketcherMgr.h PartSet_SketcherReentrantMgr.h PartSet_Tools.h diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index cd241315e..6d3684ec2 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -208,7 +208,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) //****************************************************** PartSet_Module::~PartSet_Module() { - std::map::const_iterator aFiltersIt = + std::map::const_iterator aFiltersIt = mySelectionFilters.begin(); for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) { Handle(SelectMgr_Filter) aFilter = aFiltersIt->second; @@ -622,12 +622,8 @@ void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes, SelectMgr_ListOfFilter& theSelectionFilters) { bool isSketchActive = mySketchMgr->activeSketch(); - XGUI_ActiveControlSelector* anActiveSelector = - getWorkshop()->activeControlMgr()->activeSelector(); - bool isHideFacesActive = anActiveSelector && - anActiveSelector->getType() == XGUI_FacesPanelSelector::Type(); - std::map::const_iterator aFiltersIt = + std::map::const_iterator aFiltersIt = mySelectionFilters.begin(); for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) { int aFilterType = aFiltersIt->first; @@ -637,11 +633,11 @@ void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes, // using sketch filters only if sketch operation is active if (!isSketchActive && - mySketchMgr->sketchSelectionFilter((PartSet_SelectionFilterType)aFilterType)) + mySketchMgr->sketchSelectionFilter((XGUI_SelectionFilterType)aFilterType)) continue; - // using filtering of construction results only when faces panel is active - if (aFilterType == SF_ResultGroupNameFilter && !isHideFacesActive) + // using filtering of construction results only from faces panel + if (aFilterType == SF_ResultGroupNameFilter) continue; theSelectionFilters.Append(aFiltersIt->second); @@ -653,7 +649,7 @@ QIntList PartSet_Module::selectionFilters() { QIntList aTypes; - std::map::const_iterator aFiltersIt = + std::map::const_iterator aFiltersIt = mySelectionFilters.begin(); for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) aTypes.append(aFiltersIt->first); @@ -662,18 +658,19 @@ QIntList PartSet_Module::selectionFilters() } //****************************************************** -void PartSet_Module::registerSelectionFilter(const PartSet_SelectionFilterType theFilterType, +void PartSet_Module::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter) { mySelectionFilters[theFilterType] = theFilter; } //****************************************************** -Handle(SelectMgr_Filter) PartSet_Module::selectionFilter( - const PartSet_SelectionFilterType theFilterType) +Handle(SelectMgr_Filter) PartSet_Module::selectionFilter(const int theType) { - if (mySelectionFilters.find(theFilterType) != mySelectionFilters.end()) - return mySelectionFilters[theFilterType]; + XGUI_SelectionFilterType aType = (XGUI_SelectionFilterType)theType; + + if (mySelectionFilters.find(aType) != mySelectionFilters.end()) + return mySelectionFilters[aType]; else return Handle(SelectMgr_Filter)(); } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 153c715c7..70de7236d 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -24,7 +24,7 @@ #include "PartSet.h" #include "PartSet_Tools.h" #include "PartSet_OverconstraintListener.h" -#include "PartSet_SelectionFilterType.h" +#include "XGUI_SelectionFilterType.h" #include "PartSet_SketcherMgr.h" #include @@ -237,13 +237,13 @@ public: /// Append selection filter into the module and type of the filter in internal container /// \param theFilterType selection filter type /// \param theFilter added filter - void registerSelectionFilter(const PartSet_SelectionFilterType theFilterType, + void registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter); /// Returns selection filter - /// \param theFilterType selection filter type + /// \param theType selection filter type /// \param theFilter instance of filter - Handle(SelectMgr_Filter) selectionFilter(const PartSet_SelectionFilterType theFilterType); + virtual Handle(SelectMgr_Filter) selectionFilter(const int theType); /// Returns whether the mouse enter the viewer's window /// \return true if items are added and there is no necessity to provide standard menu @@ -473,7 +473,7 @@ protected: private: bool myIsOperationIsLaunched; /// state of application between launch and stop operation - std::map mySelectionFilters; + std::map mySelectionFilters; PartSet_SketcherMgr* mySketchMgr; PartSet_SketcherReentrantMgr* mySketchReentrantMgr; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 68045ed3e..e34587a07 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1161,12 +1161,12 @@ void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation) } } -bool PartSet_SketcherMgr::sketchSelectionFilter(const PartSet_SelectionFilterType theFilterType) +bool PartSet_SketcherMgr::sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType) { return mySelectionFilterTypes.find(theFilterType) != mySelectionFilterTypes.end(); } -void PartSet_SketcherMgr::registerSelectionFilter(const PartSet_SelectionFilterType theFilterType, +void PartSet_SketcherMgr::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter) { mySelectionFilterTypes.insert(theFilterType); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 578ada7b0..634916b78 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -24,7 +24,7 @@ #include "PartSet.h" #include "PartSet_PreviewSketchPlane.h" -#include "PartSet_SelectionFilterType.h" +#include "XGUI_SelectionFilterType.h" #include "PartSet_Tools.h" #include @@ -201,12 +201,12 @@ public: /// Returns true if the filter is created by the sketch manager /// \param theFilterType a checked type /// \return boolean value - bool sketchSelectionFilter(const PartSet_SelectionFilterType theFilterType); + bool sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType); /// Append selection filter into the module and type of the filter in internal container /// \param theFilterType selection filter type /// \param theFilter added filter - void registerSelectionFilter(const PartSet_SelectionFilterType theFilterType, + void registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter); /// Commit the operation if it is possible. If the operation is dimention constraint, @@ -445,7 +445,7 @@ private: CompositeFeaturePtr myCurrentSketch; - std::set mySelectionFilterTypes; + std::set mySelectionFilterTypes; FeatureToSelectionMap myCurrentSelection; bool myPreviousUpdateViewerEnabled; diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 3a6285882..72be73b8f 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -55,6 +55,7 @@ SET(PROJECT_HEADERS XGUI_SalomeConnector.h XGUI_Selection.h XGUI_SelectionActivate.h + XGUI_SelectionFilterType.h XGUI_SelectionMgr.h XGUI_Tools.h XGUI_TransparencyWidget.h diff --git a/src/XGUI/XGUI_ActiveControlMgr.cpp b/src/XGUI/XGUI_ActiveControlMgr.cpp index 83d1b04c9..7176e061e 100644 --- a/src/XGUI/XGUI_ActiveControlMgr.cpp +++ b/src/XGUI/XGUI_ActiveControlMgr.cpp @@ -21,6 +21,7 @@ #include "XGUI_ActiveControlMgr.h" #include "XGUI_ActiveControlSelector.h" #include "XGUI_SelectionActivate.h" +#include "XGUI_SelectionMgr.h" #include "XGUI_Tools.h" #include "XGUI_Workshop.h" diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index f8dde4f9a..6c1e40370 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -26,6 +26,7 @@ #include +#include #include #include "ModuleBase_IWorkshop.h" #include "ModuleBase_ListView.h" @@ -33,6 +34,8 @@ #include "ModuleBase_Tools.h" #include "ModuleBase_ViewerPrs.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_SelectionFilterType.h" #include "XGUI_Tools.h" #include "XGUI_Workshop.h" @@ -99,6 +102,17 @@ void XGUI_FacesPanel::selectionModes(QIntList& theModes) theModes.append(TopAbs_FACE); } +//******************************************************************** +void XGUI_FacesPanel::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) +{ + ModuleBase_IModule* aModule = myWorkshop->module(); + QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); + + theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter)); + theSelectionFilters.Append(aModule->selectionFilter(SF_FilterInfinite)); + theSelectionFilters.Append(aModule->selectionFilter(SF_ResultGroupNameFilter)); +} + //******************************************************************** bool XGUI_FacesPanel::eventFilter(QObject* theObject, QEvent *theEvent) { @@ -121,8 +135,11 @@ void XGUI_FacesPanel::setActivePanel(const bool theIsActive) ModuleBase_Tools::setShadowEffect(myListView->getControl(), theIsActive); myIsActive = theIsActive; - if (myIsActive) + if (myIsActive) { + // the selection is cleared by activating selection control + XGUI_Tools::workshop(myWorkshop)->selector()->clearSelection(); emit activated(); + } else emit deactivated(); } diff --git a/src/XGUI/XGUI_FacesPanel.h b/src/XGUI/XGUI_FacesPanel.h index 3f46acc50..fdb08cc51 100644 --- a/src/XGUI/XGUI_FacesPanel.h +++ b/src/XGUI/XGUI_FacesPanel.h @@ -83,7 +83,7 @@ public: /// Appends into container of workshop selection filters /// \param [out] selection filters - void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) {} + void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters); /// Returns whether the panel is active or not bool isActivePanel() const { return myIsActive; } diff --git a/src/XGUI/XGUI_SelectionActivate.cpp b/src/XGUI/XGUI_SelectionActivate.cpp index 82faaa9fd..f8a1aaa88 100644 --- a/src/XGUI/XGUI_SelectionActivate.cpp +++ b/src/XGUI/XGUI_SelectionActivate.cpp @@ -101,13 +101,15 @@ void XGUI_SelectionActivate::updateSelectionModes() void XGUI_SelectionActivate::updateSelectionFilters() { SelectMgr_ListOfFilter aSelectionFilters; - QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); switch (activeSelectionPlace()) { - case Workshop: + case Workshop: { + QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters); - + } break; case PropertyPanel: { + QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); + ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget(); if (anActiveWidget) anActiveWidget->selectionFilters(aModuleSelectionFilters, aSelectionFilters); @@ -116,7 +118,8 @@ void XGUI_SelectionActivate::updateSelectionFilters() break; case FacesPanel: { XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionFilters(aSelectionFilters); - myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters); + //QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); + //myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters); } break; default: break; diff --git a/src/PartSet/PartSet_SelectionFilterType.h b/src/XGUI/XGUI_SelectionFilterType.h similarity index 91% rename from src/PartSet/PartSet_SelectionFilterType.h rename to src/XGUI/XGUI_SelectionFilterType.h index 3fa61e1a9..17a7ad6a1 100644 --- a/src/PartSet/PartSet_SelectionFilterType.h +++ b/src/XGUI/XGUI_SelectionFilterType.h @@ -18,11 +18,13 @@ // email : webmaster.salome@opencascade.com // -#ifndef PartSet_SelectionFilterType_H -#define PartSet_SelectionFilterType_H +#ifndef XGUI_SelectionFilterType_H +#define XGUI_SelectionFilterType_H + +#include "XGUI.h" /// Enumeration to specify module selection filters -enum PartSet_SelectionFilterType { +enum XGUI_EXPORT XGUI_SelectionFilterType { SF_GlobalFilter, /// filter for different documents, group results SF_FilterInfinite, /// filter for infinite construction results SF_ResultGroupNameFilter, /// filter for selection some kind of results -- 2.39.2