Salome HOME
ViewerFilters transferred from XGUI to ModuleBase
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 17 Oct 2014 08:37:35 +0000 (12:37 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 17 Oct 2014 08:37:35 +0000 (12:37 +0400)
13 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_ViewerFilters.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_ViewerFilters.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_ViewerFilters.cpp [deleted file]
src/XGUI/XGUI_ViewerFilters.h [deleted file]

index 4a778cb41c93a7cd4a85b9c7cc9c29a6e8fac3d7..7641722e4312b0bad49b53cc8c32ce30f3cc9454 100644 (file)
@@ -32,6 +32,7 @@ SET(PROJECT_HEADERS
        ModuleBase_IViewer.h
        ModuleBase_WidgetLineEdit.h
        ModuleBase_WidgetMultiSelector.h
+       ModuleBase_ViewerFilters.h
 )
 
 SET(PROJECT_SOURCES
@@ -57,6 +58,7 @@ SET(PROJECT_SOURCES
        ModuleBase_DoubleSpinBox.cpp
     ModuleBase_WidgetLineEdit.cpp
        ModuleBase_WidgetMultiSelector.cpp
+       ModuleBase_ViewerFilters.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 700f2baecbaf66e5006740ec6f939b3f8684896f..d6d3c416b33aa6bce54ee4d12f0a456cb1e9a27b 100644 (file)
@@ -9,6 +9,7 @@
 #include "ModuleBase_Definitions.h"
 
 #include <ModelAPI_Object.h>
+#include <GeomAPI_AISObject.h>
 
 #include <QObject>
 
@@ -49,6 +50,12 @@ Q_OBJECT
   //! Returns currently active operation
   virtual ModuleBase_Operation* currentOperation() const = 0;
 
+  //! Returns AIS opbject by data object
+  virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0;
+
+  //! Returns data object by AIS
+  virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
+
 signals:
   void selectionChanged();
 
diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp
new file mode 100644 (file)
index 0000000..6626a16
--- /dev/null
@@ -0,0 +1,36 @@
+// File:        ModuleBase_ViewerFilters.cpp
+// Created:     07 Okt 2014
+// Author:      Vitaly SMETANNIKOV
+
+
+#include "ModuleBase_ViewerFilters.h"
+#include "ModuleBase_IWorkshop.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+
+#include <AIS_InteractiveObject.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
+
+
+//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
+Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  if (theOwner->HasSelectable()) {
+    Handle(AIS_InteractiveObject) aAisObj = 
+      Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+    if (!aAisObj.IsNull()) {
+      boost::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+      aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+      ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+      if (aObj) {
+        DocumentPtr aDoc = aObj->document();
+        SessionPtr aMgr = ModelAPI_Session::get();
+        return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
+      }
+    }
+  }
+  return Standard_False;
+}
\ No newline at end of file
diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.h b/src/ModuleBase/ModuleBase_ViewerFilters.h
new file mode 100644 (file)
index 0000000..55ad0b6
--- /dev/null
@@ -0,0 +1,31 @@
+// File:        ModuleBase_ViewerFilters.h
+// Created:     07 Okt 2014
+// Author:      Vitaly SMETANNIKOV
+
+
+#ifndef ModuleBase_ViewerFilters_H
+#define ModuleBase_ViewerFilters_H
+
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+class ModuleBase_IWorkshop;
+
+DEFINE_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
+
+class ModuleBase_ShapeDocumentFilter: public SelectMgr_Filter
+{
+public:
+  Standard_EXPORT ModuleBase_ShapeDocumentFilter(ModuleBase_IWorkshop* theWorkshop): SelectMgr_Filter(),
+    myWorkshop(theWorkshop) {}
+
+  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+  DEFINE_STANDARD_RTTI(ModuleBase_ShapeDocumentFilter)
+
+private:
+  ModuleBase_IWorkshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
index 84bf567a3c4f153e35e7770a1f265cbb16da05d7..d1b54dcc16f9280e216b543e9f2cf8b86ded07ed 100644 (file)
@@ -94,8 +94,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
           SLOT(onKeyRelease(QKeyEvent*)));
   connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
           SLOT(onMouseDoubleClick(QMouseEvent*)));
-
-  myDocumentShapeFilter = new XGUI_ShapeDocumentFilter(aXWshop->displayer());
 }
 
 PartSet_Module::~PartSet_Module()
@@ -165,9 +163,6 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
         aDisplayer->setSelectionModes(aModes);
       } 
     }
-  } else {
-    //TODO (VSV): We have to open Local context because at neutral point filters don't work (bug 25340)
-    aDisplayer->addSelectionFilter(myDocumentShapeFilter);
   }
 }
 
@@ -209,8 +204,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     //  aDisplayer->activate(*aIt);
     //}
 
-    // The document limitation selection has to be only during operation
-    aDisplayer->removeSelectionFilter(myDocumentShapeFilter);
+    
+    
   }
   // Clear selection done during operation
   aDisplayer->clearSelected();
index a91f679439004b9e13ceb390b999ccde5dd5b555..88f745776040b4eeaa5526e2f9652615e2b8eb5a 100644 (file)
@@ -6,7 +6,6 @@
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
 #include <XGUI_Command.h>
-#include <XGUI_ViewerFilters.h>
 #include <ModelAPI_Feature.h>
 #include <StdSelect_FaceFilter.hxx>
 
@@ -146,8 +145,6 @@ Q_OBJECT
 
   std::map<std::string, std::string> myFeaturesInFiles;
 
-  /// A filter which provides selection within a current document or whole PartSet
-  Handle(XGUI_ShapeDocumentFilter) myDocumentShapeFilter;
   Handle(StdSelect_FaceFilter) myPlaneFilter;
 };
 
index ace172c50ba2bf627bdc74de745c5b0437eab4fa..0a07539a44b075b2805d7a9701310ff92948d9a2 100644 (file)
@@ -33,7 +33,6 @@ SET(PROJECT_HEADERS
        XGUI_Preferences.h
        XGUI_IPrefMgr.h
        XGUI_QtEvents.h
-       XGUI_ViewerFilters.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -67,7 +66,6 @@ SET(PROJECT_SOURCES
        XGUI_Selection.cpp
        XGUI_Preferences.cpp
        XGUI_QtEvents.cpp
-       XGUI_ViewerFilters.cpp
 )
 
 SET(PROJECT_RESOURCES 
index 26469989924db36a6acae8f56539e062bf07f090..dbe635b33d2d5b25be75b94c51ec7731606fed9d 100644 (file)
@@ -47,18 +47,18 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
   if (isVisible(theObject)) {
     redisplay(theObject, isUpdateViewer);
   } else {
-    boost::shared_ptr<GeomAPI_AISObject> anAIS;
+    AISObjectPtr anAIS;
 
     GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
     bool isShading = false;
     if (aPrs) {
-      anAIS = aPrs->getAISObject(boost::shared_ptr<GeomAPI_AISObject>());
+      anAIS = aPrs->getAISObject(AISObjectPtr());
     } else {
       ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
       if (aResult) {
         boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
         if (aShapePtr) {
-          anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+          anAIS = AISObjectPtr(new GeomAPI_AISObject());
           anAIS->createShape(aShapePtr);
           isShading = true;
         }
@@ -69,7 +69,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
   }
 }
 
-void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS, 
+void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, 
                              bool isShading, bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -92,7 +92,7 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext.IsNull())
     return;
-  boost::shared_ptr<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theObject];
+  AISObjectPtr anObject = myResult2AISObjectMap[theObject];
   if (anObject) {
     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
     if (!anAIS.IsNull()) {
@@ -108,10 +108,10 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
     return;
 
   Handle(AIS_InteractiveObject) aAISIO;
-  boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+  AISObjectPtr aAISObj = getAISObject(theObject);
   GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
   if (aPrs) {
-    boost::shared_ptr<GeomAPI_AISObject> aAIS_Obj = aPrs->getAISObject(aAISObj);
+    AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
     if (aAISObj && !aAIS_Obj) {
       erase(theObject, isUpdateViewer);
       return;
@@ -149,7 +149,7 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject)
     if (aContext.IsNull())
       return;
 
-    boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+    AISObjectPtr anObj = myResult2AISObjectMap[theObject];
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     aContext->Deactivate(anAIS);
   }
@@ -162,7 +162,7 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
     if (aContext.IsNull())
       return;
 
-    boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+    AISObjectPtr anObj = myResult2AISObjectMap[theObject];
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     if (aContext->HasOpenedContext()) {
       aContext->Load(anAIS, -1, true);
@@ -184,7 +184,7 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const
   if (!isVisible(theObject))
     return false;
     
-  boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap.at(theObject);
+  AISObjectPtr anObj = myResult2AISObjectMap.at(theObject);
   Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
 
   TColStd_ListOfInteger aModes;
@@ -243,7 +243,7 @@ void XGUI_Displayer::setSelected(const QList<ObjectPtr>& theResults, const bool
     if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end())
       continue;
 
-    boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[aResult];
+    AISObjectPtr anObj = myResult2AISObjectMap[aResult];
     if (anObj) {
       Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
       if (!anAIS.IsNull())
@@ -271,7 +271,7 @@ void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
    ResultToAISMap::iterator aIt;
    for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
      // erase an object
-     boost::shared_ptr<GeomAPI_AISObject> aAISObj = (*aIt).second;
+     AISObjectPtr aAISObj = (*aIt).second;
      Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
      if (!anIO.IsNull())
       ic->Remove(anIO, false);
@@ -293,7 +293,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
   for (; aFIt != aFLast; aFIt++) {
     ObjectPtr aFeature = (*aFIt).first;
     if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
-      boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
+      AISObjectPtr anObj = (*aFIt).second;
       if (!anObj)
         continue;
       Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
@@ -332,21 +332,27 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
   closeAllContexts(true);
 }
 
-boost::shared_ptr<GeomAPI_AISObject> XGUI_Displayer::getAISObject(ObjectPtr theObject) const
+AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
 {
-  boost::shared_ptr<GeomAPI_AISObject> anIO;
+  AISObjectPtr anIO;
   if (myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end())
     anIO = (myResult2AISObjectMap.find(theObject))->second;
   return anIO;
 }
 
-ObjectPtr XGUI_Displayer::getObject(Handle(AIS_InteractiveObject) theIO) const
+ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
+{
+  Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
+  return getObject(aRefAIS);
+}
+
+ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
 {
   ObjectPtr aFeature;
   ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
       myResult2AISObjectMap.end();
   for (; aFIt != aFLast && !aFeature; aFIt++) {
-    boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
+    AISObjectPtr anObj = (*aFIt).second;
     if (!anObj)
       continue;
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
@@ -379,7 +385,7 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
   return myWorkshop->viewer()->AISContext();
 }
 
-void XGUI_Displayer::display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate)
+void XGUI_Displayer::display(AISObjectPtr theAIS, bool isUpdate)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
@@ -387,7 +393,7 @@ void XGUI_Displayer::display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool i
     aContext->Display(anAISIO, isUpdate);
 }
 
-void XGUI_Displayer::erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate)
+void XGUI_Displayer::erase(AISObjectPtr theAIS, const bool isUpdate)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
@@ -440,7 +446,7 @@ void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bo
   if (aContext.IsNull())
     return;
 
-  boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+  AISObjectPtr aAISObj = getAISObject(theObject);
   if (!aAISObj)
     return;
 
@@ -476,7 +482,7 @@ XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) con
   if (aContext.IsNull())
     return NoMode;
 
-  boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+  AISObjectPtr aAISObj = getAISObject(theObject);
   if (!aAISObj)
     return NoMode;
 
index e5a7405d0f2395dacb15bddd8b7303f1c6feb329..7f117fea5e0a586366f3423a7144b0cd4ba85f64 100644 (file)
@@ -56,7 +56,7 @@ class XGUI_EXPORT XGUI_Displayer
   void display(ObjectPtr theObject, bool isUpdateViewer = true);
 
   /// Display the given AIS object. To hide this object use corresponde erase method
-  void display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate = true);
+  void display(AISObjectPtr theAIS, bool isUpdate = true);
 
   /// Stop the current selection and color the given features to the selection color
   /// \param theFeatures a list of features to be disabled
@@ -82,7 +82,7 @@ class XGUI_EXPORT XGUI_Displayer
   void erase(ObjectPtr theObject, const bool isUpdateViewer = true);
 
   /// Erase the given AIS object displayed by corresponded display method
-  void erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate = true);
+  void erase(AISObjectPtr theAIS, const bool isUpdate = true);
 
   /// Erase all presentations
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
@@ -116,12 +116,13 @@ class XGUI_EXPORT XGUI_Displayer
   /// Searches the interactive object by feature
   /// \param theFeature the feature or NULL if it not visualized
   /// \return theIO an interactive object
-  boost::shared_ptr<GeomAPI_AISObject> getAISObject(ObjectPtr theFeature) const;
+  AISObjectPtr getAISObject(ObjectPtr theFeature) const;
 
   /// Searches the feature by interactive object
   /// \param theIO an interactive object
   /// \return feature the feature or NULL if it not visualized
-  ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const;
+  ObjectPtr getObject(const AISObjectPtr& theIO) const;
+  ObjectPtr getObject(const Handle(AIS_InteractiveObject)& theIO) const;
 
   /// Deactivates the given object (not allow selection)
   void deactivate(ObjectPtr theFeature);
@@ -163,7 +164,7 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param theAIS AIS presentation
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// Returns true if the Feature succesfully displayed
-  void display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isShading,
+  void display(ObjectPtr theObject, AISObjectPtr theAIS, bool isShading,
                bool isUpdateViewer = true);
 
   /// Display the shape and activate selection of sub-shapes
@@ -172,7 +173,7 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the presentation is created
   //bool redisplay(ObjectPtr theObject,
-  //               boost::shared_ptr<GeomAPI_AISObject> theAIS, 
+  //               AISObjectPtr theAIS, 
   //               const bool isUpdateViewer = true);
 
   /** Redisplay the shape if it was displayed
@@ -184,7 +185,7 @@ class XGUI_EXPORT XGUI_Displayer
  protected:
   XGUI_Workshop* myWorkshop;
 
-  typedef std::map<ObjectPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
+  typedef std::map<ObjectPtr, AISObjectPtr> ResultToAISMap;
   ResultToAISMap myResult2AISObjectMap;
 };
 
index ce9ca36806ef450d1215e75cc810f00564de51e6..5bb4445fe695490c00a5d2208e28fd17533224e6 100644 (file)
@@ -10,6 +10,9 @@
 #include "XGUI_OperationMgr.h"
 #include "XGUI_Displayer.h"
 
+#include <AIS_Shape.hxx>
+
+
 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
     : ModuleBase_IWorkshop(theWorkshop),
       myWorkshop(theWorkshop)
@@ -23,10 +26,13 @@ XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
     this, SIGNAL(operationStarted(ModuleBase_Operation*)));
   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), 
     this, SIGNAL(operationStopped(ModuleBase_Operation*)));
+
+  myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
 }
 
 XGUI_ModuleConnector::~XGUI_ModuleConnector()
 {
+  myDocumentShapeFilter.Nullify();
 }
 
 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
@@ -54,13 +60,32 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
 {
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   aDisp->openLocalContext();
-  // Use empty list because we will use standard modes
-  aDisp->activateObjectsOutOfContext(QIntList());
-  aDisp->setSelectionModes(theTypes);
+  // Convert shape types to selection types
+  QIntList aModes;
+  foreach(int aType, theTypes) {
+    aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
+  }
+  aDisp->activateObjectsOutOfContext(aModes);
+  //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
+  aDisp->addSelectionFilter(myDocumentShapeFilter);
 }
 
 void XGUI_ModuleConnector::deactivateSubShapesSelection()
 {
   XGUI_Displayer* aDisp = myWorkshop->displayer();
+  // The document limitation selection has to be only during operation
+  aDisp->removeSelectionFilter(myDocumentShapeFilter);
   aDisp->closeLocalContexts(false);
 }
+
+AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
+{
+  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  return aDisp->getAISObject(theObject);
+}
+
+ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
+{
+  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  return aDisp->getObject(theAIS);
+}
\ No newline at end of file
index 054ad0872e5db2944c72c4c2cf2f89dd3873922b..f6d071f2ac375615cbca24a72b832d1d8e632a18 100644 (file)
@@ -8,6 +8,7 @@
 #include "XGUI.h"
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ViewerFilters.h>
 
 class Handle_AIS_InteractiveContext;
 class XGUI_Workshop;
@@ -43,10 +44,19 @@ Q_OBJECT
   //! Returns currently active operation
   virtual ModuleBase_Operation* currentOperation() const;
 
+  //! Returns AIS opbject by data object
+  virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
+
+  //! Returns data object by AIS
+  virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
+
   XGUI_Workshop* workshop() const { return myWorkshop; }
 
- private:
+private:
   XGUI_Workshop* myWorkshop;
+
+  /// A filter which provides selection within a current document or whole PartSet
+  Handle(ModuleBase_ShapeDocumentFilter) myDocumentShapeFilter;
 };
 
 #endif
diff --git a/src/XGUI/XGUI_ViewerFilters.cpp b/src/XGUI/XGUI_ViewerFilters.cpp
deleted file mode 100644 (file)
index 6efd914..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// File:        XGUI_ViewerFilters.cpp
-// Created:     07 Okt 2014
-// Author:      Vitaly SMETANNIKOV
-
-
-#include "XGUI_ViewerFilters.h"
-#include "XGUI_Displayer.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
-
-#include <AIS_InteractiveObject.hxx>
-
-IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
-IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
-
-
-//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
-Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
-{
-  if (theOwner->HasSelectable()) {
-    Handle(AIS_InteractiveObject) aAisObj = 
-      Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-    if (!aAisObj.IsNull()) {
-      ObjectPtr aObj = myDisplayer->getObject(aAisObj);
-      if (aObj) {
-        DocumentPtr aDoc = aObj->document();
-        SessionPtr aMgr = ModelAPI_Session::get();
-        return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
-      }
-    }
-  }
-  return Standard_False;
-}
\ No newline at end of file
diff --git a/src/XGUI/XGUI_ViewerFilters.h b/src/XGUI/XGUI_ViewerFilters.h
deleted file mode 100644 (file)
index f30f400..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// File:        XGUI_ViewerFilters.h
-// Created:     07 Okt 2014
-// Author:      Vitaly SMETANNIKOV
-
-
-#ifndef XGUI_ViewerFilters_H
-#define XGUI_ViewerFilters_H
-
-#include <SelectMgr_Filter.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-
-class XGUI_Displayer;
-
-DEFINE_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
-
-class XGUI_ShapeDocumentFilter: public SelectMgr_Filter
-{
-public:
-  Standard_EXPORT XGUI_ShapeDocumentFilter(XGUI_Displayer* myDisp): SelectMgr_Filter(),
-    myDisplayer(myDisp) {}
-
-  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
-
-  DEFINE_STANDARD_RTTI(XGUI_ShapeDocumentFilter)
-
-private:
-  XGUI_Displayer* myDisplayer;
-};
-
-#endif
\ No newline at end of file