From 41ce7f10d66940b02b4d2dd579747f1f2c27c3ea Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 14 Dec 2017 12:19:06 +0300 Subject: [PATCH] Hide faces panel: do not select result construction. --- src/PartSet/PartSet_Filters.cpp | 35 +++++++++++++++++++++++ src/PartSet/PartSet_Filters.h | 27 +++++++++++++++++ src/PartSet/PartSet_Module.cpp | 13 ++++++++- src/PartSet/PartSet_SelectionFilterType.h | 1 + src/XGUI/XGUI_SelectionActivate.cpp | 7 +++-- 5 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp index afe4fbbda..e99265ee1 100644 --- a/src/PartSet/PartSet_Filters.cpp +++ b/src/PartSet/PartSet_Filters.cpp @@ -86,6 +86,41 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& return aValid; } +IMPLEMENT_STANDARD_RTTIEXT(PartSet_ResultGroupNameFilter, SelectMgr_Filter); + +void PartSet_ResultGroupNameFilter::setGroupNames(const std::set& theGroupNames) +{ + myGroupNames = theGroupNames; +} + +Standard_Boolean PartSet_ResultGroupNameFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const +{ + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + if (theOwner->HasSelectable()) { + Handle(AIS_InteractiveObject) aAisObj = + Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); + if (!aAisObj.IsNull()) { + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); + } + } + ObjectPtr anObject = myWorkshop->findPresentedObject(aAISObj); + if (!anObject.get()) + return true; + + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + // result of parts belongs to PartSet document and can be selected only when PartSet + // is active in order to do not select the result of the active part. + if (!aResult.get()) + return true; + + std::string aGroupName = aResult->groupName();// == ModelAPI_ResultPart::group()) { + if (myGroupNames.find(aGroupName) != myGroupNames.end()) + return false; // the object of the filtered type is found + + return true; +} + + IMPLEMENT_STANDARD_RTTIEXT(PartSet_CirclePointFilter, SelectMgr_Filter); Standard_Boolean diff --git a/src/PartSet/PartSet_Filters.h b/src/PartSet/PartSet_Filters.h index 5c2446238..2ceafe517 100644 --- a/src/PartSet/PartSet_Filters.h +++ b/src/PartSet/PartSet_Filters.h @@ -23,6 +23,8 @@ #include +#include +#include /** * \class PartSet_GlobalFilter @@ -46,6 +48,31 @@ public: DEFINE_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter) }; +/// \class PartSet_ResultGroupNameFilter +/// \ingroup Modules +/// A class which filters results with groupName() result in filter parameters +DEFINE_STANDARD_HANDLE(PartSet_ResultGroupNameFilter, SelectMgr_Filter); +class PartSet_ResultGroupNameFilter: public SelectMgr_Filter +{ +public: + /// Constructor + /// \param theWorkshop a pointer to workshop + PartSet_ResultGroupNameFilter(ModuleBase_IWorkshop* theWorkshop) + : SelectMgr_Filter(), myWorkshop(theWorkshop) {} + + void setGroupNames(const std::set& theGroupNames); + + /// Returns True if selected presentation can be selected + /// \param theOwner an owner of the persentation + Standard_EXPORT virtual Standard_Boolean + IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const; + + DEFINE_STANDARD_RTTIEXT(PartSet_ResultGroupNameFilter, SelectMgr_Filter) + +private: + ModuleBase_IWorkshop* myWorkshop; + std::set myGroupNames; +}; /// \class PartSet_CirclePointFilter /// \ingroup GUI diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 8951ac04b..b6a259050 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -175,6 +175,11 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop)); registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop)); + Handle(PartSet_ResultGroupNameFilter) aCRFilter = new PartSet_ResultGroupNameFilter(myWorkshop); + std::set aCRGroupNames; + aCRGroupNames.insert(ModelAPI_ResultConstruction::group()); + aCRFilter->setGroupNames(aCRGroupNames); + registerSelectionFilter(SF_ResultGroupNameFilter, aCRFilter); setDefaultConstraintShown(); @@ -608,7 +613,6 @@ void PartSet_Module::activeSelectionModes(QIntList& theModes) void PartSet_Module::moduleSelectionModes(int theModesType, QIntList& theModes) { customSubShapesSelectionModes(theModes); - //theModes.append(XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes()); //myWorkshop->module()->activeSelectionModes(theModes); } @@ -618,6 +622,9 @@ 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 = mySelectionFilters.begin(); @@ -632,6 +639,10 @@ void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes, mySketchMgr->sketchSelectionFilter((PartSet_SelectionFilterType)aFilterType)) continue; + // using filtering of construction results only when faces panel is active + if (aFilterType == SF_ResultGroupNameFilter && !isHideFacesActive) + continue; + theSelectionFilters.Append(aFiltersIt->second); } } diff --git a/src/PartSet/PartSet_SelectionFilterType.h b/src/PartSet/PartSet_SelectionFilterType.h index 21ce8b131..3fa61e1a9 100644 --- a/src/PartSet/PartSet_SelectionFilterType.h +++ b/src/PartSet/PartSet_SelectionFilterType.h @@ -25,6 +25,7 @@ enum PartSet_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 SF_SketchCirclePointFilter, /// filter for selection circle points on current sketch SF_SketchPlaneFilter /// filter for selection in the current sketch plane only }; diff --git a/src/XGUI/XGUI_SelectionActivate.cpp b/src/XGUI/XGUI_SelectionActivate.cpp index 09d1cef22..82faaa9fd 100644 --- a/src/XGUI/XGUI_SelectionActivate.cpp +++ b/src/XGUI/XGUI_SelectionActivate.cpp @@ -101,14 +101,14 @@ void XGUI_SelectionActivate::updateSelectionModes() void XGUI_SelectionActivate::updateSelectionFilters() { SelectMgr_ListOfFilter aSelectionFilters; + QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); switch (activeSelectionPlace()) { case Workshop: - myWorkshop->module()->moduleSelectionFilters(myWorkshop->module()->selectionFilters(), - aSelectionFilters); + myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters); + break; case PropertyPanel: { ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget(); - QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); if (anActiveWidget) anActiveWidget->selectionFilters(aModuleSelectionFilters, aSelectionFilters); myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters); @@ -116,6 +116,7 @@ void XGUI_SelectionActivate::updateSelectionFilters() break; case FacesPanel: { XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionFilters(aSelectionFilters); + myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters); } break; default: break; -- 2.39.2