Salome HOME
Issue #2278 Cannot validate a Sketch. Feature should be stored in cache, not result...
[modules/shaper.git] / src / PartSet / PartSet_Filters.cpp
index 8d66327f8cf6549617ba16f5968839c958efc4a8..afe4fbbda47d0090db276282818800f086cda5f5 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_Filters.cpp
-// Created:     08 Nov 2014
-// Author:      Vitaly SMETANNIKOV
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include "PartSet_Filters.h"
 
@@ -12,6 +26,7 @@
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_Session.h>
 
 #include <AIS_InteractiveObject.hxx>
@@ -19,7 +34,6 @@
 #include <StdSelect_BRepOwner.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
@@ -44,11 +58,17 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
         ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
         // 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() && aResult->groupName() == ModelAPI_ResultPart::group()) {
-          SessionPtr aMgr = ModelAPI_Session::get();
-          aValid = aMgr->activeDocument() == aMgr->moduleDocument();
+        if (aResult.get()) {
+          if (aResult->groupName() == ModelAPI_ResultPart::group()) {
+            SessionPtr aMgr = ModelAPI_Session::get();
+            aValid = aMgr->activeDocument() == aMgr->moduleDocument();
+          } else if (aResult->groupName() == ModelAPI_ResultGroup::group()) {
+            aValid = Standard_False;
+          } else
+            aValid = Standard_True;
         }
-        else {
+        else { // possibly this code is obsolete, as a feature object can be selected in recovery
+          // only and there can not be Group feature
           FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
           if (aFeature) {
             aValid = aFeature->getKind() != "Group";
@@ -66,7 +86,6 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
   return aValid;
 }
 
-IMPLEMENT_STANDARD_HANDLE(PartSet_CirclePointFilter, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(PartSet_CirclePointFilter, SelectMgr_Filter);
 
 Standard_Boolean