]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #310: Do not select Groups for operations
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 8 Dec 2014 11:37:57 +0000 (14:37 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 8 Dec 2014 11:37:57 +0000 (14:37 +0300)
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Filters.cpp [new file with mode: 0644]
src/PartSet/PartSet_Filters.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h

index c313a6ec9ab9434d2136ba1ad98fa809dd09a90e..55370797f266c8a9c070d49a2a95d70e3422fb29 100644 (file)
@@ -14,6 +14,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetPoint2dDistance.h
        PartSet_WidgetShapeSelector.h
        PartSet_OperationSketch.h
+       PartSet_Filters.h
 )
 
 SET(PROJECT_SOURCES
@@ -26,6 +27,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetShapeSelector.cpp
        PartSet_OperationSketch.cpp
+       PartSet_Filters.cpp
 )
 
 SET(PROJECT_RESOURCES 
@@ -70,6 +72,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
                     ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
                     ${CMAKE_SOURCE_DIR}/src/SketchPlugin
+                    ${CMAKE_SOURCE_DIR}/src/FeaturesPlugin
                     ${CMAKE_SOURCE_DIR}/src/GeomAPI
                     ${CAS_INCLUDE_DIRS}
                                        ${SUIT_INCLUDE}
diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp
new file mode 100644 (file)
index 0000000..04ea88b
--- /dev/null
@@ -0,0 +1,42 @@
+// File:        PartSet_Filters.cpp
+// Created:     08 Nov 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "PartSet_Filters.h"
+
+#include <ModuleBase_IWorkshop.h>
+
+#include <ModelAPI_Feature.h>
+#include <FeaturesPlugin_Group.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+
+
+IMPLEMENT_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
+IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
+
+Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
+    if (theOwner->HasSelectable()) {
+      Handle(AIS_InteractiveObject) aAisObj = 
+        Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+      if (!aAisObj.IsNull()) {
+        std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+        aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+        ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+        if (aObj) {
+          FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+          if (aFeature) {
+            return aFeature->getKind() != FeaturesPlugin_Group::ID();
+          } else 
+            return Standard_True;
+        } else
+          // This is not object controlled by the filter
+          return Standard_True;
+      }
+    }
+  }
+  return Standard_False;
+}
diff --git a/src/PartSet/PartSet_Filters.h b/src/PartSet/PartSet_Filters.h
new file mode 100644 (file)
index 0000000..5671506
--- /dev/null
@@ -0,0 +1,26 @@
+// File:        PartSet_Filters.h
+// Created:     08 Nov 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef PartSet_Filters_H
+#define PartSet_Filters_H
+
+#include <ModuleBase_ViewerFilters.h>
+
+
+/**
+* A class which filters groups object in addition to documents (see issue #310)
+*/
+DEFINE_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
+class PartSet_GlobalFilter: public ModuleBase_ShapeDocumentFilter
+{
+public:
+  PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop)
+    : ModuleBase_ShapeDocumentFilter(theWorkshop) {}
+
+  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+  DEFINE_STANDARD_RTTI(PartSet_GlobalFilter)
+};
+
+#endif
\ No newline at end of file
index 2c055ffd6ccde652922c808d6135edd44103ead9..16eac8958984125d816af4303b3e603452ed1d67 100644 (file)
@@ -203,7 +203,7 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
     }
   }
   if (myDocumentShapeFilter.IsNull())
-    myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(myWorkshop);
+    myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
   myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
 }
 
index 1d9fc45df8b5486bba4c272d17ce92989193bcb6..42619830db193a82ed69f8d5d594378e6e89e354 100644 (file)
@@ -2,10 +2,10 @@
 #define PartSet_Module_H
 
 #include "PartSet.h"
+#include <PartSet_Filters.h>
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
-#include <ModuleBase_ViewerFilters.h>
 #include <XGUI_Command.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Attribute.h>
@@ -133,7 +133,7 @@ protected slots:
 
    Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
   /// A filter which provides selection within a current document or whole PartSet
-  Handle(ModuleBase_ShapeDocumentFilter) myDocumentShapeFilter;
+  Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
 };
 
 #endif