]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Hide faces panel: do not select result construction.
authornds <nds@opencascade.com>
Thu, 14 Dec 2017 09:19:06 +0000 (12:19 +0300)
committernds <nds@opencascade.com>
Thu, 14 Dec 2017 09:19:06 +0000 (12:19 +0300)
src/PartSet/PartSet_Filters.cpp
src/PartSet/PartSet_Filters.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SelectionFilterType.h
src/XGUI/XGUI_SelectionActivate.cpp

index afe4fbbda47d0090db276282818800f086cda5f5..e99265ee13683fc8c319e8539522812247b248f1 100644 (file)
@@ -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<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
index 5c24462388dff4de104997bc53610f7b9809e25d..2ceafe51793fcce958f7819096463e81b0a78a6d 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <ModuleBase_ViewerFilters.h>
 
+#include <set>
+#include <string>
 
 /**
 * \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<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
index 8951ac04b3e2f24f76ea6cd65da54ee37b90f90e..b6a259050fd300695dac1144703cefb0bbe2bbb0 100755 (executable)
@@ -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<std::string> 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<PartSet_SelectionFilterType, Handle(SelectMgr_Filter)>::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);
   }
 }
index 21ce8b131a5f414eff2170fc2d0cae5646ac179c..3fa61e1a937e30f9871a00408e96f32889958b78 100644 (file)
@@ -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
 };
index 09d1cef22c812f08f0bf5330594b9a0ee2481501..82faaa9fd469f9f13a0ea082ac049dfa155b3330 100644 (file)
@@ -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;