]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.5. Combination operations on Groups (issue #2935)
authorazv <azv@opencascade.com>
Tue, 30 Jul 2019 08:50:46 +0000 (11:50 +0300)
committerazv <azv@opencascade.com>
Tue, 30 Jul 2019 08:50:46 +0000 (11:50 +0300)
Implementation of Group Addition operation from scratch.

14 files changed:
src/CollectionPlugin/CMakeLists.txt
src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp [new file with mode: 0644]
src/CollectionPlugin/CollectionPlugin_GroupAddition.h [new file with mode: 0644]
src/CollectionPlugin/CollectionPlugin_Plugin.cpp
src/CollectionPlugin/group_addition_widget.xml [new file with mode: 0644]
src/CollectionPlugin/group_intersection_widget.xml [new file with mode: 0644]
src/CollectionPlugin/group_substraction_widget.xml [new file with mode: 0644]
src/CollectionPlugin/icons/group_addition.png [new file with mode: 0644]
src/CollectionPlugin/icons/group_intersection.png [new file with mode: 0644]
src/CollectionPlugin/icons/group_substraction.png [new file with mode: 0644]
src/CollectionPlugin/plugin-Collection.xml
src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp
src/Model/Model_AttributeSelection.cpp
src/PartSet/PartSet_Filters.cpp

index 2e2ff961d3687bae504a1d0492e4bffebcc75bec..921596cdd3c7c4e41fe3848ba9103fa17139595e 100644 (file)
@@ -31,6 +31,7 @@ SET(PROJECT_HEADERS
     CollectionPlugin.h
     CollectionPlugin_Plugin.h
     CollectionPlugin_Group.h
+    CollectionPlugin_GroupAddition.h
     CollectionPlugin_Field.h
     CollectionPlugin_WidgetCreator.h
     CollectionPlugin_WidgetField.h
@@ -44,6 +45,7 @@ SET(PROJECT_MOC_HEADERS
 SET(PROJECT_SOURCES
     CollectionPlugin_Plugin.cpp
     CollectionPlugin_Group.cpp
+    CollectionPlugin_GroupAddition.cpp
     CollectionPlugin_Field.cpp
     CollectionPlugin_WidgetCreator.cpp
     CollectionPlugin_WidgetField.cpp
@@ -53,6 +55,9 @@ SET(PROJECT_SOURCES
 SET(XML_RESOURCES
   plugin-Collection.xml
   group_widget.xml
+  group_addition_widget.xml
+  group_intersection_widget.xml
+  group_substraction_widget.xml
 )
 
 SET(TEXT_RESOURCES
diff --git a/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp b/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp
new file mode 100644 (file)
index 0000000..1c3795d
--- /dev/null
@@ -0,0 +1,45 @@
+// 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 "CollectionPlugin_GroupAddition.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultGroup.h>
+
+CollectionPlugin_GroupAddition::CollectionPlugin_GroupAddition()
+{
+}
+
+void CollectionPlugin_GroupAddition::initAttributes()
+{
+  data()->addAttribute(CollectionPlugin_Group::LIST_ID(),
+                       ModelAPI_AttributeSelectionList::typeId());
+}
+
+void CollectionPlugin_GroupAddition::execute()
+{
+  if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
+    ResultPtr aGroup = document()->createGroup(data());
+    setResult(aGroup);
+  }
+}
diff --git a/src/CollectionPlugin/CollectionPlugin_GroupAddition.h b/src/CollectionPlugin/CollectionPlugin_GroupAddition.h
new file mode 100644 (file)
index 0000000..4de080a
--- /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 COLLECTIONPLUGIN_GROUPADDITION_H_
+#define COLLECTIONPLUGIN_GROUPADDITION_H_
+
+#include "CollectionPlugin.h"
+#include "CollectionPlugin_Group.h"
+
+/**\class CollectionPlugin_GroupAddition
+ * \ingroup Plugins
+ * \brief Merge several groups of same shape type into single group.
+ */
+class CollectionPlugin_GroupAddition : public CollectionPlugin_Group
+{
+ public:
+  /// Extrusion kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_GROUP_ID("GroupAddition");
+    return MY_GROUP_ID;
+  }
+  /// attribute name of selected entities list
+  inline static const std::string& LIST_ID()
+  {
+    static const std::string MY_GROUP_LIST_ID("group_list");
+    return MY_GROUP_LIST_ID;
+  }
+
+  /// Returns the kind of a feature
+  COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = CollectionPlugin_Group::ID();
+    return MY_KIND;
+  }
+
+  /// Creates a new group result if needed
+  COLLECTIONPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  COLLECTIONPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Result of groups is created on the fly and don't stored to the document
+  COLLECTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return true;}
+
+  /// Use plugin manager for features creation
+  CollectionPlugin_GroupAddition();
+
+};
+
+#endif
index 7b0fc28e1e4210a783f0c73411daa334484bb8d9..e5562060668ffb3efec5cb18dda3ed8d3bc2f3e2 100644 (file)
@@ -20,6 +20,7 @@
 #include <CollectionPlugin_Plugin.h>
 
 #include <CollectionPlugin_Group.h>
+#include <CollectionPlugin_GroupAddition.h>
 #include <CollectionPlugin_Field.h>
 #include <CollectionPlugin_Validators.h>
 #include <ModelAPI_Session.h>
@@ -56,6 +57,8 @@ FeaturePtr CollectionPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new CollectionPlugin_Group);
   } else if (theFeatureID == CollectionPlugin_Field::ID()) {
     return FeaturePtr(new CollectionPlugin_Field);
+  } else if (theFeatureID == CollectionPlugin_GroupAddition::ID()) {
+    return FeaturePtr(new CollectionPlugin_GroupAddition);
   }
 
   // feature of such kind is not found
diff --git a/src/CollectionPlugin/group_addition_widget.xml b/src/CollectionPlugin/group_addition_widget.xml
new file mode 100644 (file)
index 0000000..5eab220
--- /dev/null
@@ -0,0 +1,11 @@
+<source>
+  <namevalue id="name"
+             label="Name"
+             placeholder="Please input the group name">
+  </namevalue>
+  <multi_selector id="group_list"
+                  tooltip="Select a set of groups"
+                  type_choice="objects">
+<!--    <validator id="GeomValidators_BodyShapes"/>-->
+  </multi_selector>
+</source>
\ No newline at end of file
diff --git a/src/CollectionPlugin/group_intersection_widget.xml b/src/CollectionPlugin/group_intersection_widget.xml
new file mode 100644 (file)
index 0000000..3a1f83f
--- /dev/null
@@ -0,0 +1,15 @@
+<source>
+  <namevalue id="name"
+    label="Name"
+    placeholder="Please input the group name">
+  </namevalue>
+  <multi_selector id="group_list"
+    tooltip="Select a set of objects"
+    type_choice="Vertices Edges Faces Solids"
+    use_choice="true"
+    clear_in_neutral_point="false"
+    filter_points="false"
+    same_topology="true">
+    <validator id="GeomValidators_BodyShapes"/>
+  </multi_selector>
+</source>
\ No newline at end of file
diff --git a/src/CollectionPlugin/group_substraction_widget.xml b/src/CollectionPlugin/group_substraction_widget.xml
new file mode 100644 (file)
index 0000000..3a1f83f
--- /dev/null
@@ -0,0 +1,15 @@
+<source>
+  <namevalue id="name"
+    label="Name"
+    placeholder="Please input the group name">
+  </namevalue>
+  <multi_selector id="group_list"
+    tooltip="Select a set of objects"
+    type_choice="Vertices Edges Faces Solids"
+    use_choice="true"
+    clear_in_neutral_point="false"
+    filter_points="false"
+    same_topology="true">
+    <validator id="GeomValidators_BodyShapes"/>
+  </multi_selector>
+</source>
\ No newline at end of file
diff --git a/src/CollectionPlugin/icons/group_addition.png b/src/CollectionPlugin/icons/group_addition.png
new file mode 100644 (file)
index 0000000..6bc76e0
Binary files /dev/null and b/src/CollectionPlugin/icons/group_addition.png differ
diff --git a/src/CollectionPlugin/icons/group_intersection.png b/src/CollectionPlugin/icons/group_intersection.png
new file mode 100644 (file)
index 0000000..aba074c
Binary files /dev/null and b/src/CollectionPlugin/icons/group_intersection.png differ
diff --git a/src/CollectionPlugin/icons/group_substraction.png b/src/CollectionPlugin/icons/group_substraction.png
new file mode 100644 (file)
index 0000000..7db75ec
Binary files /dev/null and b/src/CollectionPlugin/icons/group_substraction.png differ
index 27057f56f81d62468e1d79f1235410329fe56840..9ec5c5dd6602e612d2b122c920c1a5b744babe4b 100644 (file)
         </field-panel>
         <validator id="CollectionPlugin_FieldValidator"/>
       </feature>
+
+      <feature id="GroupAddition"
+        title="Group Addition"
+        tooltip="Join several groups to single group"
+        icon="icons/Collection/group_addition.png"
+        apply_continue="true"
+        helpfile="groupAdditionFeature.html">
+        <source path="group_addition_widget.xml"/>
+      </feature>
     </group>
   </workbench>
 </plugin>
index c3a38788782385f5fa00772b093daaa95fefc2fb..f5a45f605278f7a795aa3da5ff0615a5644554d5 100644 (file)
@@ -18,6 +18,7 @@
 //
 
 #include "FeaturesPlugin_Pipe.h"
+#include "FeaturesPlugin_Tools.h"
 
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
@@ -373,11 +374,12 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes,
     aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE);
 
   // Store from shapes.
-  storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_");
+  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, thePipeAlgo->fromShapes(), ListOfShape(),
+                                           thePipeAlgo, thePipeAlgo->shape(), "From");
 
   // Store to shapes.
-  storeShapes(aResultBody, theBaseShapes.back()->shapeType(), thePipeAlgo->toShapes(), "To_");
-
+  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, thePipeAlgo->toShapes(), ListOfShape(),
+                                           thePipeAlgo, thePipeAlgo->shape(), "To");
 
   setResult(aResultBody, theResultIndex);
 }
index e9c92ad53de831ba8267f4c58d38c73214489675..26b45f7c865a732f41d8577397ca6a54cb805dd1 100644 (file)
@@ -29,6 +29,7 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Tools.h>
@@ -180,6 +181,9 @@ bool Model_AttributeSelection::setValue(const ObjectPtr& theContext,
     aSelLab.ForgetAllAttributes(true);
     TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID);
     selectPart(std::dynamic_pointer_cast<ModelAPI_Result>(theContext), theSubShape);
+  } else if (theContext->groupName() == ModelAPI_ResultGroup::group()) {
+    aSelLab.ForgetAllAttributes(true);
+    TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
   } else { // check the feature context: parent-Part of this feature should not be used
     FeaturePtr aFeatureContext = std::dynamic_pointer_cast<ModelAPI_Feature>(theContext);
     if (aFeatureContext.get()) {
index b7e5ccbb1e62e2d116921ed8220e201ff44e65af..582161acee01d363bff427842edf2005bd48d2e5 100644 (file)
@@ -63,8 +63,7 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
           if (aResultGroupName == ModelAPI_ResultPart::group()) {
             SessionPtr aMgr = ModelAPI_Session::get();
             aValid = aMgr->activeDocument() == aMgr->moduleDocument();
-          } else if (aResultGroupName == ModelAPI_ResultGroup::group() ||
-                     aResultGroupName == ModelAPI_ResultField::group()) {
+          } else if (aResultGroupName == ModelAPI_ResultField::group()) {
             aValid = Standard_False;
           } else
             aValid = Standard_True;