Salome HOME
Task #2924 implementation : Ability to remove a result
authormpv <mpv@opencascade.com>
Mon, 20 May 2019 12:52:19 +0000 (15:52 +0300)
committervsv <vsv@opencascade.com>
Mon, 3 Jun 2019 10:32:07 +0000 (13:32 +0300)
30 files changed:
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_RemoveResults.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_RemoveResults.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_RemoveResults.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_RemoveResults.h [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRemoveResultsBody.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRemoveResultsConstruction.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRemoveResultsPart.py [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Data.cpp
src/Model/Model_Document.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultConstruction.h
src/ModelAPI/ModelAPI_Result.cpp
src/ModelAPI/ModelAPI_Result.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/PythonAPI/model/dump/DumpAssistant.py
src/PythonAPI/model/features/__init__.py
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index 23cdb1c47216e00e0cae92159d2ff9cd40c48877..9311f491d42cef0d6eabb07111bbfefbc0851865 100644 (file)
@@ -37,6 +37,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_Pipe.h
   FeaturesAPI_Placement.h
   FeaturesAPI_Recover.h
+  FeaturesAPI_RemoveResults.h
   FeaturesAPI_RemoveSubShapes.h
   FeaturesAPI_Revolution.h
   FeaturesAPI_RevolutionBoolean.h
@@ -65,6 +66,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_Pipe.cpp
   FeaturesAPI_Placement.cpp
   FeaturesAPI_Recover.cpp
+  FeaturesAPI_RemoveResults.cpp
   FeaturesAPI_RemoveSubShapes.cpp
   FeaturesAPI_Revolution.cpp
   FeaturesAPI_RevolutionBoolean.cpp
index d9082cc2598baeea6c4e15a6bd2a379a0c3df47e..35bdfcefcc62383ddad656957c4c2b174045629b 100644 (file)
@@ -66,6 +66,7 @@
 %shared_ptr(FeaturesAPI_Translation)
 %shared_ptr(FeaturesAPI_Union)
 %shared_ptr(FeaturesAPI_FusionFaces)
+%shared_ptr(FeaturesAPI_RemoveResults)
 
 // all supported interfaces
 %include "FeaturesAPI_BooleanCut.h"
@@ -93,3 +94,4 @@
 %include "FeaturesAPI_Translation.h"
 %include "FeaturesAPI_Union.h"
 %include "FeaturesAPI_FusionFaces.h"
+%include "FeaturesAPI_RemoveResults.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_RemoveResults.cpp b/src/FeaturesAPI/FeaturesAPI_RemoveResults.cpp
new file mode 100644 (file)
index 0000000..ba54478
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2014-2019  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
+//
+
+#include "FeaturesAPI_RemoveResults.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+
+//==================================================================================================
+FeaturesAPI_RemoveResults::FeaturesAPI_RemoveResults(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature)
+  : ModelHighAPI_Interface(theFeature)
+{}
+
+//==================================================================================================
+FeaturesAPI_RemoveResults::FeaturesAPI_RemoveResults(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theResults)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setRemoved(theResults);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_RemoveResults::~FeaturesAPI_RemoveResults()
+{}
+
+//==================================================================================================
+void FeaturesAPI_RemoveResults::setRemoved(
+  const std::list<ModelHighAPI_Selection>& theResults)
+{
+  fillAttribute(theResults, myremoved);
+}
+
+//==================================================================================================
+void FeaturesAPI_RemoveResults::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anAttrResults =
+    aBase->selectionList(FeaturesPlugin_RemoveResults::RESULTS_ID());
+
+  theDumper << aBase << " = model.addRemoveResults("
+            << aDocName << ", " << anAttrResults << ")" << std::endl;
+}
+
+//==================================================================================================
+RemoveResultsPtr addRemoveResults(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theResults)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesAPI_RemoveResults::ID());
+  return RemoveResultsPtr(new FeaturesAPI_RemoveResults(aFeature, theResults));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_RemoveResults.h b/src/FeaturesAPI/FeaturesAPI_RemoveResults.h
new file mode 100644 (file)
index 0000000..9267428
--- /dev/null
@@ -0,0 +1,73 @@
+// Copyright (C) 2014-2019  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
+//
+
+#ifndef FeaturesAPI_RemoveResults_H_
+#define FeaturesAPI_RemoveResults_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_RemoveResults.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_RemoveResults
+/// \ingroup CPPHighAPI
+/// \brief Interface for RemoveResults feature.
+class FeaturesAPI_RemoveResults: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_RemoveResults(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_RemoveResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                     const std::list<ModelHighAPI_Selection>& theResults);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+  virtual ~FeaturesAPI_RemoveResults();
+
+  INTERFACE_1(FeaturesPlugin_RemoveResults::ID(),
+              removed, FeaturesPlugin_RemoveResults::RESULTS_ID(),
+              ModelAPI_AttributeSelectionList, /** Results to remove */)
+
+  /// Modify removed results arguments.
+  FEATURESAPI_EXPORT
+  void setRemoved(const std::list<ModelHighAPI_Selection>& theResults);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on RemoveResults object.
+typedef std::shared_ptr<FeaturesAPI_RemoveResults> RemoveResultsPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create RemoveResults feature.
+FEATURESAPI_EXPORT
+RemoveResultsPtr addRemoveResults(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theResults);
+
+#endif // FeaturesAPI_RemoveResults_H_
index 6eeaf064b9a0ead0be1b325a4d644f4153b43bcb..f427c3f7da8f4c63d3632babaef77d7e5516f894 100644 (file)
@@ -48,5 +48,6 @@
   #include "FeaturesAPI_Translation.h"
   #include "FeaturesAPI_Union.h"
   #include "FeaturesAPI_FusionFaces.h"
+  #include "FeaturesAPI_RemoveResults.h"
 
 #endif // FeaturesAPI_swig_H_
index 0ceae4e1c415e3f2d9cb32238db4d747f10ecf5c..26c65c2b2741cc5b4d407d2bc73b6d2258c889c2 100644 (file)
@@ -59,6 +59,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_Fillet.h
     FeaturesPlugin_Measurement.h
     FeaturesPlugin_FusionFaces.h
+    FeaturesPlugin_RemoveResults.h
 )
 
 SET(PROJECT_SOURCES
@@ -99,6 +100,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_Fillet.cpp
     FeaturesPlugin_Measurement.cpp
     FeaturesPlugin_FusionFaces.cpp
+    FeaturesPlugin_RemoveResults.cpp
 )
 
 SET(XML_RESOURCES
@@ -495,4 +497,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestUnion_MultiLevelCompound_v0.py
                TestUnion_MultiLevelCompound_v20190506.py
                TestUnionFaces_v20190506.py
+               TestRemoveResultsBody.py
+               TestRemoveResultsConstruction.py
+               TestRemoveResultsPart.py
 )
index 625381a19c89f2613becbf82e0b99595b1bdf9c4..9efa6c1fd47c59d9db731d9bc38dfcf1c96664ed 100644 (file)
@@ -46,6 +46,7 @@
 #include <FeaturesPlugin_Translation.h>
 #include <FeaturesPlugin_Union.h>
 #include <FeaturesPlugin_FusionFaces.h>
+#include <FeaturesPlugin_RemoveResults.h>
 #include <FeaturesPlugin_ValidatorTransform.h>
 #include <FeaturesPlugin_Validators.h>
 
@@ -171,6 +172,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_Fillet);
   } else if (theFeatureID == FeaturesPlugin_Measurement::ID()) {
     return FeaturePtr(new FeaturesPlugin_Measurement);
+  } else if (theFeatureID == FeaturesPlugin_RemoveResults::ID()) {
+    return FeaturePtr(new FeaturesPlugin_RemoveResults);
   }
 
   // feature of such kind is not found
diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveResults.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveResults.cpp
new file mode 100644 (file)
index 0000000..7c0b77d
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2014-2019  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
+//
+
+#include "FeaturesPlugin_RemoveResults.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+
+//==================================================================================================
+FeaturesPlugin_RemoveResults::FeaturesPlugin_RemoveResults()
+{
+}
+
+//==================================================================================================
+void FeaturesPlugin_RemoveResults::initAttributes()
+{
+  data()->addAttribute(RESULTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveResults.h b/src/FeaturesPlugin/FeaturesPlugin_RemoveResults.h
new file mode 100644 (file)
index 0000000..7d9faf3
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (C) 2014-2019  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
+//
+
+#ifndef FeaturesPlugin_RemoveResults_H_
+#define FeaturesPlugin_RemoveResults_H_
+
+#include "FeaturesPlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/// \class FeaturesPlugin_RemoveResults
+/// \ingroup Plugins
+/// \brief AN internal, hidden feature for results removal.
+class FeaturesPlugin_RemoveResults : public ModelAPI_Feature
+{
+public:
+  /// Use plugin manager for features creation
+  FeaturesPlugin_RemoveResults();
+
+  /// Feature kind.
+  inline static const std::string& ID()
+  {
+    static const std::string MY_ID("RemoveResults");
+    return MY_ID;
+  }
+
+  /// Attribute name of removed shapes selector.
+  inline static const std::string& RESULTS_ID()
+  {
+    static const std::string MY_BASE_SHAPE_ID("results");
+    return MY_BASE_SHAPE_ID;
+  }
+
+  /// \return the kind of a feature.
+  FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = FeaturesPlugin_RemoveResults::ID();
+    return MY_KIND;
+  }
+
+  /// Request for initialization of data model of the feature: adding all attributes.
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Does nothing, has no results.
+  FEATURESPLUGIN_EXPORT virtual void execute() {}
+
+  /// Hidden from the user.
+  FEATURESPLUGIN_EXPORT virtual bool isInHistory() {return false;}
+};
+
+#endif
diff --git a/src/FeaturesPlugin/Test/TestRemoveResultsBody.py b/src/FeaturesPlugin/Test/TestRemoveResultsBody.py
new file mode 100644 (file)
index 0000000..5ede10d
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (C) 2014-2019  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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 2)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+RemoveResults_1 = model.addRemoveResults(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")])
+model.end()
+
+# check the number of bodies = 0, number of construction = 1
+from ModelAPI import *
+assert(Part_1.document().size(ModelAPI_ResultConstruction.group()) == 1)
+assert(Part_1.document().size(ModelAPI_ResultBody.group()) == 0)
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRemoveResultsConstruction.py b/src/FeaturesPlugin/Test/TestRemoveResultsConstruction.py
new file mode 100644 (file)
index 0000000..ac81899
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (C) 2014-2019  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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 2)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+RemoveResults_1 = model.addRemoveResults(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")])
+model.end()
+
+# check the number of bodies = 1, number of construction = 0
+from ModelAPI import *
+assert(Part_1.document().size(ModelAPI_ResultConstruction.group()) == 0)
+assert(Part_1.document().size(ModelAPI_ResultBody.group()) == 1)
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestRemoveResultsPart.py b/src/FeaturesPlugin/Test/TestRemoveResultsPart.py
new file mode 100644 (file)
index 0000000..a8790d1
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright (C) 2014-2019  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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+model.do()
+RemoveResults_1 = model.addRemoveResults(partSet, [model.selection("SHAPE", "Part_1/")])
+model.end()
+
+# check the number of parts = 0
+from ModelAPI import *
+assert(Part_1.document().size(ModelAPI_ResultPart.group()) == 0)
index eb72aa4e43b4d51d7918277ab4f21d418e69671a..cec9dd59eb2e649e62b660fa9a38f15c078c09af 100644 (file)
@@ -97,6 +97,9 @@
         helpfile="recoverFeature.html">
         <source path="recover_widget.xml"/>
       </feature>
+      <feature id="RemoveResults" title="Remove results" tooltip="Internal feature for results removal" internal="1">
+        <multi_selector id="results" concealment="true"/>
+      </feature>
     </group>
     <group id="Fillet">
       <feature id="Fillet" title="Fillet" tooltip="Perform fillet on face or edge"
index 3d325a6880680b19462f8bdcbeb6838fa97e7ae2..8ae93763d5f4d51ea4c4b7c979102f24d4f0c023 100644 (file)
@@ -410,7 +410,8 @@ bool Model_AttributeSelection::isInitialized()
     std::shared_ptr<GeomAPI_Shape> aResult;
     if (myRef.isInitialized()) {
       TDF_Label aSelLab = selectionLabel();
-      if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // it is just reference to shape, not sub-shape
+      // it is just reference to shape, not sub-shape
+      if (aSelLab.IsAttribute(kSIMPLE_REF_ID) || aSelLab.IsAttribute(kPART_REF_ID)) {
         ResultPtr aContext = context();
         return aContext.get() != NULL;
       }
index 01315a892353102cef25427fddd2034533854c51..5f867fca1a508b003442d814c6726cbbaa9f50a5 100644 (file)
@@ -38,6 +38,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_ResultParameter.h>
+#include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
@@ -579,7 +580,7 @@ void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID,
     // be displayed and previewed; also for avoiding of quick show/hide on history
     // moving deep down
     if (aRes && !theFeature->isDisabled()) {
-      aRes->setIsConcealed(true);
+      aRes->setIsConcealed(true, theFeature->getKind() == "RemoveResults");
     }
   }
 }
@@ -604,8 +605,13 @@ void Model_Data::updateConcealmentFlag()
           std::shared_ptr<ModelAPI_Result> aRes =
             std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
           if (aRes.get()) {
-            aRes->setIsConcealed(true); // set concealed
-            return;
+            if (aRes->groupName() != ModelAPI_ResultConstruction::group()) {
+              aRes->setIsConcealed(true); // set concealed
+              return;
+            } else if (aFeature->getKind() == "RemoveResults") {
+              aRes->setIsConcealed(true, true);
+              return;
+            }
           }
         }
       }
index 26cb173d5f40d9755eb03ebb65deb3f7f6dc80b3..082a6c60fd51f13be8e96a2cacab2d9b536eac75 100644 (file)
@@ -1244,6 +1244,18 @@ void Model_Document::setCurrentFeature(
       }
     }
   }
+  if (theVisible) { // make RemoveResults feature be active even it is performed after the current
+    int anIndex = kUNDEFINED_FEATURE_INDEX;
+    FeaturePtr aNext =
+      theCurrent.get() ? myObjs->nextFeature(theCurrent, anIndex, false) : myObjs->firstFeature();
+    for (; aNext.get(); aNext = myObjs->nextFeature(theCurrent, anIndex, false)) {
+      if (aNext->isInHistory()) {
+        break; // next in history is not needed
+      } else if (aNext->getKind() == "RemoveResults"){
+        theCurrent = aNext;
+      }
+    }
+  }
   if (theCurrent.get()) {
     std::shared_ptr<Model_Data> aData = std::static_pointer_cast<Model_Data>(theCurrent->data());
     if (!aData.get() || !aData->isValid()) {
index 1be002979bd6cb54781fe94ece9bbb274e9b5292..c5bedb6bae96d0c57bbaea334ff4e774b974df0c 100644 (file)
@@ -157,10 +157,10 @@ bool Model_ResultBody::isConcealed()
   return myLastConcealed;
 }
 
-void Model_ResultBody::setIsConcealed(const bool theValue)
+void Model_ResultBody::setIsConcealed(const bool theValue, const bool theForced)
 {
   if (ModelAPI_ResultBody::isConcealed() != theValue) {
-    ModelAPI_ResultBody::setIsConcealed(theValue);
+    ModelAPI_ResultBody::setIsConcealed(theValue, theForced);
     updateConcealment();
   }
 }
index 8abd4408965588dccb07a882fdb07258f53156ca..663bf8cecf416c54e02ed6f4e8ace29f3f719672 100644 (file)
@@ -103,7 +103,7 @@ public:
   MODEL_EXPORT virtual bool isConcealed();
 
   /// Sets all subs as concealed in the data tree (referenced by other objects)
-  MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
+  MODEL_EXPORT virtual void setIsConcealed(const bool theValue, const bool theForced = false);
 
   /// Returns true is the topology is connected.
   MODEL_EXPORT virtual bool isConnectedTopology();
index 041e8f226d34a769e6e4ccf23110d04d99a55ace..9b5dd872929d5411888083f73e4f44f62b04ad84 100644 (file)
@@ -216,9 +216,12 @@ std::shared_ptr<GeomAPI_Face> Model_ResultConstruction::face(const int theIndex)
   return aResult;
 }
 
-void Model_ResultConstruction::setIsConcealed(const bool theValue)
+void Model_ResultConstruction::setIsConcealed(const bool theValue, const bool theForced)
 {
-  // do nothing: the construction element is never concealed
+  // the construction element may be concealed only by "delete" feature
+  if (!theValue || theForced) {
+    ModelAPI_ResultConstruction::setIsConcealed(theValue, theForced);
+  }
 }
 
 void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShape)
index 8f7670158072cf0c2917720eb3b979dd3d9d5b3c..a6913c4aeb91306cccc95eed11ba51daa5c78685 100644 (file)
@@ -63,8 +63,8 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction
   MODEL_EXPORT virtual bool isInfinite();
   /// Sets the flag that it is infinite
   MODEL_EXPORT virtual void setInfinite(const bool theInfinite);
-  /// The construction element is never concealed
-  MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
+  /// The construction element may be concealed only by "delete" feature
+  MODEL_EXPORT virtual void setIsConcealed(const bool theValue, const bool theForced = false);
 
   /// Updates the shape taking the current value from the data structure, returns true
   /// if update has been correctly done
index c92a8ea3ba59e72cb826373876de674093503b6d..9e38ffb46a4894d5498fd17a3e17843bc0d27652 100644 (file)
@@ -76,7 +76,7 @@ bool ModelAPI_Result::isConcealed()
   return myIsConcealed;
 }
 
-void ModelAPI_Result::setIsConcealed(const bool theValue)
+void ModelAPI_Result::setIsConcealed(const bool theValue, const bool theForced)
 {
   if (myIsConcealed != theValue) {
     myIsConcealed = theValue;
index aee93eed670997a353381b42c18358d56873d8dd..81709e749e22f35a65e570547bae02b8aeb16a87 100644 (file)
@@ -67,7 +67,7 @@ class ModelAPI_Result : public ModelAPI_Object
   MODELAPI_EXPORT virtual bool isConcealed();
 
   /// Sets the result as concealed in the data tree (referenced by other objects)
-  MODELAPI_EXPORT virtual void setIsConcealed(const bool theValue);
+  MODELAPI_EXPORT virtual void setIsConcealed(const bool theValue, const bool theForced = false);
 
   /// Enables/disables the result. The disabled result does not participate in any calculation
   /// and visualization: like it was removed. But it keeps the general parameters: colors,
index d09d215eb7729fcf8e80cf7c43d57c06be0530ee..c6b8a6f7257df6ba4933747cb038402399502a87 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_ResultPart.h>
@@ -760,4 +761,27 @@ std::set<FeaturePtr> getParents(const FeaturePtr& theFeature)
   return aParents;
 }
 
+void removeResults(const std::list<ResultPtr>& theResults)
+{
+  // collect all documents where the results must be removed
+  std::map<DocumentPtr, std::list<ResultPtr> > aDocs;
+
+  std::list<ResultPtr>::const_iterator aResIter = theResults.cbegin();
+  for(; aResIter != theResults.cend(); aResIter++) {
+    DocumentPtr aDoc = (*aResIter)->document();
+    if (!aDocs.count(aDoc))
+      aDocs[aDoc] = std::list<ResultPtr>();
+    aDocs[aDoc].push_back(*aResIter);
+  }
+  // create a "remove" feature in each doc
+  std::map<DocumentPtr, std::list<ResultPtr> >::iterator aDoc = aDocs.begin();
+  for(; aDoc != aDocs.end(); aDoc++) {
+    FeaturePtr aRemove = aDoc->first->addFeature("RemoveResults");
+    if (aRemove) {
+      for(aResIter = aDoc->second.cbegin(); aResIter != aDoc->second.cend(); aResIter++)
+        aRemove->selectionList("results")->append(*aResIter, GeomShapePtr());
+    }
+  }
+}
+
 } // namespace ModelAPI_Tools
index 1b239535179594aab68399328cba08be6c9c5709..6b4d31f8401cdd34a2c1e8403833400ab37e7f09 100644 (file)
@@ -205,6 +205,10 @@ MODELAPI_EXPORT std::pair<std::string, bool> getDefaultName(
  */
 MODELAPI_EXPORT std::set<std::shared_ptr<ModelAPI_Feature> >
     getParents(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+/*! Creates a remove result features with the given results
+*/
+MODELAPI_EXPORT void removeResults(const std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
 }
 
 #endif
index cdbd9202bdaa57fa9ac16ad4c33833e8a906fde6..e49a994ff0fac288f86a4cd4dce494658c162234 100644 (file)
@@ -992,6 +992,8 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
   aLast = theReferencesToDelete.end();
   for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = *anIt;
+    if (aFeature->getKind() == "RemoveResults")
+      continue; // skip the remove results feature mentioning: result will be removed anyway
     if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
       aPartFeatureNames.append(aFeature->name().c_str());
     else
index 40058999fe4cd01973ada4a18fbc7d5b1d25d213..4523b7d809106e23170060953120ac7bddf48a9e 100644 (file)
@@ -79,7 +79,7 @@ MODULEBASE_EXPORT void setFocus(QWidget* theWidget, const QString& theInfo = QSt
 
 /// Sets or removes the shadow effect to the widget
 /// \param theWidget a widget to be styled
-/// \param isSetEffect if true, the shadow effect is set, overwise cleared
+/// \param isSetEffect if true, the shadow effect is set, otherwise cleared
 /// \return resulting pixmap
 MODULEBASE_EXPORT void setShadowEffect(QWidget* theWidget, const bool isSetEffect);
 
@@ -193,7 +193,7 @@ MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasR
 
 /// Sets the default coeffient into the driver calculated accordingly the shape type.
 /// It provides 1.e-4 for results of construction type
-/// \param theResult a result object to define the deviation coeffient
+/// \param theResult a result object to define the deviation coefficient
 /// \param theDrawer a drawer
 //MODULEBASE_EXPORT void setDefaultDeviationCoefficient(
 //                           const std::shared_ptr<ModelAPI_Result>& theResult,
@@ -201,7 +201,7 @@ MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasR
 
 /// Sets the default coeffient into the driver calculated accordingly the shape type.
 /// It provides 1.e-4 for a shape withe Edge shape type
-/// \param theShape a shape to define the deviation coeffient,
+/// \param theShape a shape to define the deviation coefficient,
 /// \param theDrawer a drawer
 MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
                                                       const Handle(Prs3d_Drawer)& theDrawer);
@@ -300,7 +300,7 @@ void MODULEBASE_EXPORT refsToFeatureInFeatureDocument(const ObjectPtr& theObject
 
 
 /// Returns true if the object if a sub child of the feature. The feature is casted to the
-/// composite one. If it is possible, the sub object check happens. The method is applyed
+/// composite one. If it is possible, the sub object check happens. The method is applied
 /// recursively to the feature subs.
 /// \param theObject a candidate to be a sub object
 /// \param theFeature a candidate to be a composite feature
@@ -339,18 +339,18 @@ bool MODULEBASE_EXPORT askToDelete(const std::set<FeaturePtr> aFeatures,
                                    std::set<FeaturePtr>& theReferencesToDelete,
                                    const std::string& thePrefixInfo = "");
 
-/// Converts a list of objects to set of corresponded features. If object is result, it is ingored
-/// because the feauture only might be removed. But if result is in a parameter group, the feature
+/// Converts a list of objects to set of corresponded features. If object is result, it is ignored
+/// because the feature only might be removed. But if result is in a parameter group, the feature
 /// of this parameter is to be removed
 /// \param theObjects a list of objects
-/// \param theFeatures an out conteiner of features
+/// \param theFeatures an out container of features
 void MODULEBASE_EXPORT convertToFeatures(const QObjectPtrList& theObjects,
                                          std::set<FeaturePtr>& theFeatures);
 
 
 /// Converts a list of objects to set of folders.
 /// \param theObjects a list of objects
-/// \param theFeatures an out conteiner of features
+/// \param theFeatures an out container of features
 void MODULEBASE_EXPORT convertToFolders(const QObjectPtrList& theObjects,
                                          std::set<FolderPtr>& theFolders);
 
@@ -358,14 +358,14 @@ void MODULEBASE_EXPORT convertToFolders(const QObjectPtrList& theObjects,
 /// Returns translation from the given data.
 /// If translation is not exists then it returns a string
 /// from the info data without translation
-/// \param theMessage a message which dave to be translated
+/// \param theMessage a message which have to be translated
 QString MODULEBASE_EXPORT translate(const Events_InfoMessage& theMessage);
 
 /// Returns translation from the given data.
 /// If translation is not exists then it returns a string
 /// from the info data without translation
 /// \param theContext context of the message (Feature Id)
-/// \param theMessage a message which dave to be translated
+/// \param theMessage a message which have to be translated
 QString MODULEBASE_EXPORT translate(const std::string& theContext, const std::string& theMessage);
 
 /// Set Highlighting of points as a Ball shape
index 4e739a38278f19c6dd05099821034606ce74bb06..0b3eeb16745ef1f9f940a79467f389833bae1ce7 100644 (file)
@@ -60,9 +60,9 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
         aFeatureKind = theFeature.getKind()
         if aFeatureKind in self.myFeatures:
             # Dump only feature created by user (in history).
-            # Also dump Export features (hard-coded here in order not to change the data model).
+            # Also dump Export and RemoveResults features (hard-coded here in order not to change the data model).
             # For all other features, just keep their name.
-            if theForce or theFeature.isInHistory() or aFeatureKind=="Export":
+            if theForce or theFeature.isInHistory() or aFeatureKind=="Export" or aFeatureKind=="RemoveResults":
                 self.myFeatures[aFeatureKind](theFeature).dump(self)
             else:
                 self.name(theFeature)
@@ -98,4 +98,4 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
         return std_string()
 
 # Instance of dumper
-dumper = DumpAssistant
\ No newline at end of file
+dumper = DumpAssistant
index 3e1e6bdc65b25016c4418e7b5a83e7313bd4c041..19f7b2ed03a94e9394086f0a5632e3dd520ec49d 100644 (file)
@@ -30,3 +30,4 @@ from FeaturesAPI import addRecover
 from FeaturesAPI import addFillet
 from FeaturesAPI import addFusionFaces
 from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
+from FeaturesAPI import addRemoveResults
index 0df020d32709e1d064f06002f68f1d6cb67b3c3b..22ec2603ccb8165a3efd84d81c6535209b15dda3 100644 (file)
@@ -446,7 +446,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         break;
       }
     if (!hasCompositeOwner && allActive ) {
-      if (hasFeature || hasParameter)
+      if (hasResult || hasFeature || hasParameter) // #2924 results can be erased
         action("DELETE_CMD")->setEnabled(true);
     }
     if (!hasCompositeOwner && allActive && (hasFeature|| hasParameter))
@@ -622,6 +622,8 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   aList.append(action("TRANSPARENCY_CMD"));
 #endif
   aList.append(action("SHOW_FEATURE_CMD"));
+  aList.append(mySeparator2);
+  aList.append(action("DELETE_CMD"));
   myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
 
   //-------------------------------------
@@ -642,6 +644,8 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   aList.append(action("TRANSPARENCY_CMD"));
 #endif
   aList.append(action("SHOW_FEATURE_CMD"));
+  aList.append(mySeparator3);
+  aList.append(action("DELETE_CMD"));
   myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
   // Group menu
   myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
index a7caf5007ef90505085ac92aa5a47175e4e9ebf0..4586610e211837d9c1974608cfdb3c256214fb1a 100644 (file)
@@ -922,7 +922,6 @@ void XGUI_Workshop::onOpen()
   //save current file before close if modified
   SessionPtr aSession = ModelAPI_Session::get();
   if (aSession->isModified()) {
-    //TODO(sbh): re-launch the app?
     int anAnswer = QMessageBox::question(
         desktop(), tr("Save current file"),
         tr("The document is modified, save before opening another?"),
@@ -1528,7 +1527,7 @@ void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget)
   // the property panel is active window of the desktop, when it is
   // hidden, it is undefined which window becomes active. By this reason
   // it is defined to perform the desktop as the active window.
-  // in SALOME mode, workstack made the PyConsole the active window,
+  // in SALOME mode, work-stack made the PyConsole the active window,
   // set the focus on it. As a result, shortcuts of the application, like
   // are processed by this console. For example Undo actions.
   // It is possible that this code is to be moved to SHAPER package
@@ -1797,7 +1796,7 @@ void XGUI_Workshop::deleteObjects()
   bool hasFolder = false;
   ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner,
                                  hasResultInHistory, hasFolder);
-  if (!(hasFeature || hasParameter || hasFolder))
+  if (!(hasResult || hasFeature || hasParameter || hasFolder))
     return;
 
   // delete objects
@@ -1838,6 +1837,16 @@ void XGUI_Workshop::deleteObjects()
       }
     }
   }
+  // remove results selected
+  std::list<ResultPtr> aResults;
+  for(QObjectPtrList::const_iterator anIt = anObjects.begin(); anIt != anObjects.end(); anIt++) {
+    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(*anIt);
+    if (aRes.get() && aRes->data()->isValid() && !aRes->data()->isDeleted())
+      aResults.push_back(aRes);
+  }
+  if (!aResults.empty()) {
+    ModelAPI_Tools::removeResults(aResults);
+  }
 
   if (aDone)
     operationMgr()->commitOperation();
@@ -1892,11 +1901,11 @@ void XGUI_Workshop::cleanHistory()
   ModelAPI_Tools::findAllReferences(aFeatures, aReferences, true, false);
   // find for each object whether all reference values are in the map as key, that means that there
   // is no other reference in the model to this object, so it might be removed by cleaning history
-  // sk_1(ext_1, vertex_1) + (sk_3, bool_1) - cann't be deleted, dependency to bool_1
-  // ext_1(bool_1, sk_3)  - cann't be deleted, dependency to bool_1
+  // sk_1(ext_1, vertex_1) + (sk_3, bool_1) - can't be deleted, dependency to bool_1
+  // ext_1(bool_1, sk_3)  - can't be deleted, dependency to bool_1
   // vertex_1()
-  // sk_2(ext_2) + (bool_1)  - cann't be deleted, dependency to bool_1
-  // ext_2(bool_1)  - cann't be deleted, dependency to bool_1
+  // sk_2(ext_2) + (bool_1)  - can't be deleted, dependency to bool_1
+  // ext_2(bool_1)  - can't be deleted, dependency to bool_1
   // sk_3()
   // Information: bool_1 is not selected
   std::set<FeaturePtr> anUnusedObjects;