return aValid;
}
+IMPLEMENT_STANDARD_RTTIEXT(PartSet_ResultGroupNameFilter, SelectMgr_Filter);
+
+void PartSet_ResultGroupNameFilter::setGroupNames(const std::set<std::string>& theGroupNames)
+{
+ myGroupNames = theGroupNames;
+}
+
+Standard_Boolean PartSet_ResultGroupNameFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+ std::shared_ptr<GeomAPI_AISObject> 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<ModelAPI_Result>(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
#include <ModuleBase_ViewerFilters.h>
+#include <set>
+#include <string>
/**
* \class PartSet_GlobalFilter
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<std::string>& 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<std::string> myGroupNames;
+};
/// \class PartSet_CirclePointFilter
/// \ingroup GUI
registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
+ Handle(PartSet_ResultGroupNameFilter) aCRFilter = new PartSet_ResultGroupNameFilter(myWorkshop);
+ std::set<std::string> aCRGroupNames;
+ aCRGroupNames.insert(ModelAPI_ResultConstruction::group());
+ aCRFilter->setGroupNames(aCRGroupNames);
+ registerSelectionFilter(SF_ResultGroupNameFilter, aCRFilter);
setDefaultConstraintShown();
void PartSet_Module::moduleSelectionModes(int theModesType, QIntList& theModes)
{
customSubShapesSelectionModes(theModes);
-
//theModes.append(XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes());
//myWorkshop->module()->activeSelectionModes(theModes);
}
SelectMgr_ListOfFilter& theSelectionFilters)
{
bool isSketchActive = mySketchMgr->activeSketch();
+ XGUI_ActiveControlSelector* anActiveSelector = getWorkshop()->activeControlMgr()->activeSelector();
+ bool isHideFacesActive = anActiveSelector &&
+ anActiveSelector->getType() == XGUI_FacesPanelSelector::Type();
std::map<PartSet_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
mySelectionFilters.begin();
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);
}
}
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
};
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);
break;
case FacesPanel: {
XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionFilters(aSelectionFilters);
+ myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters);
}
break;
default: break;