Set correct selection type for the operations on groups.
CollectionPlugin_Group.h
CollectionPlugin_GroupAddition.h
CollectionPlugin_GroupIntersection.h
+ CollectionPlugin_GroupOperation.h
CollectionPlugin_GroupSubstraction.h
CollectionPlugin_Field.h
CollectionPlugin_WidgetCreator.h
CollectionPlugin_Group.cpp
CollectionPlugin_GroupAddition.cpp
CollectionPlugin_GroupIntersection.cpp
+ CollectionPlugin_GroupOperation.cpp
CollectionPlugin_GroupSubstraction.cpp
CollectionPlugin_Field.cpp
CollectionPlugin_WidgetCreator.cpp
TestGroupSubstraction.py
TestGroupSubstraction_Error1.py
TestGroupSubstraction_Error2.py
+ Test2977.py
)
aCompound = aSubs.empty() ? GeomShapePtr() : GeomAlgoAPI_CompoundBuilder::compound(aSubs);
aGroup->store(aCompound);
+ // update the type of selection
+ updateGroupType(LIST_ID());
+
setResult(aGroup);
}
#define COLLECTIONPLUGIN_GROUPADDITION_H_
#include "CollectionPlugin.h"
-#include "CollectionPlugin_Group.h"
+#include "CollectionPlugin_GroupOperation.h"
/**\class CollectionPlugin_GroupAddition
* \ingroup Plugins
* \brief Merge several groups of same shape type into single group.
*/
-class CollectionPlugin_GroupAddition : public CollectionPlugin_Group
+class CollectionPlugin_GroupAddition : public CollectionPlugin_GroupOperation
{
- public:
+public:
/// Extrusion kind
inline static const std::string& ID()
{
/// 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();
removeResults(0);
}
else {
+ // update the type of selection
+ updateGroupType(LIST_ID());
+
GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aCommon);
aGroup->store(aCompound);
setResult(aGroup);
#define COLLECTIONPLUGIN_GROUPINTERSECTION_H_
#include "CollectionPlugin.h"
-#include "CollectionPlugin_Group.h"
+#include "CollectionPlugin_GroupOperation.h"
/**\class CollectionPlugin_GroupIntersection
* \ingroup Plugins
* \brief Merge several groups of same shape type into single group.
*/
-class CollectionPlugin_GroupIntersection : public CollectionPlugin_Group
+class CollectionPlugin_GroupIntersection : public CollectionPlugin_GroupOperation
{
- public:
+public:
/// Extrusion kind
inline static const std::string& ID()
{
/// 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_GroupIntersection();
--- /dev/null
+// 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_GroupOperation.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+
+void CollectionPlugin_GroupOperation::updateGroupType(const std::string& theAttributeName)
+{
+ AttributeSelectionListPtr aSelected = selectionList(theAttributeName);
+ if (aSelected->size()) {
+ FeaturePtr aFirstGroup = ModelAPI_Feature::feature(aSelected->value(0)->context());
+ if (aFirstGroup) {
+ AttributeSelectionListPtr aFirstGroupShapes =
+ aFirstGroup->selectionList(CollectionPlugin_Group::LIST_ID());
+ if (aFirstGroupShapes)
+ aSelected->setSelectionType(aFirstGroupShapes->selectionType());
+ }
+ }
+}
--- /dev/null
+// 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_GROUPOPERATION_H_
+#define COLLECTIONPLUGIN_GROUPOPERATION_H_
+
+#include "CollectionPlugin.h"
+#include "CollectionPlugin_Group.h"
+
+/**\class CollectionPlugin_GroupOperation
+ * \ingroup Plugins
+ * \brief Base class for operations on groups.
+ */
+class CollectionPlugin_GroupOperation : public CollectionPlugin_Group
+{
+public:
+ /// Result of groups is created on the fly and don't stored to the document
+ COLLECTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return true;}
+
+protected:
+ /// Updates the type of selection list based on types of selected groups
+ void updateGroupType(const std::string& theAttributeName);
+};
+
+#endif
removeResults(0);
}
else {
+ // update the type of selection
+ updateGroupType(LIST_ID());
+
GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aCut);
aGroup->store(aCompound);
setResult(aGroup);
#define COLLECTIONPLUGIN_GROUPSUBSTRACTION_H_
#include "CollectionPlugin.h"
-#include "CollectionPlugin_Group.h"
+#include "CollectionPlugin_GroupOperation.h"
/**\class CollectionPlugin_GroupSubstraction
* \ingroup Plugins
* \brief Remove all elements in "objects" groups which contain in "tools" groups.
*/
-class CollectionPlugin_GroupSubstraction : public CollectionPlugin_Group
+class CollectionPlugin_GroupSubstraction : public CollectionPlugin_GroupOperation
{
- public:
+public:
/// Extrusion kind
inline static const std::string& ID()
{
/// 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_GroupSubstraction();
--- /dev/null
+# Copyright (C) 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()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Top")])
+Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Top")])
+Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Top")])
+GroupAddition_1 = model.addGroupAddition(Part_1_doc, [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")])
+GroupSubstraction_1 = model.addGroupSubstraction(Part_1_doc, [model.selection("COMPOUND", "GroupAddition_1")], [model.selection("COMPOUND", "Group_3")])
+model.end()
+
+from GeomAPI import *
+
+model.testNbResults(GroupSubstraction_1, 1)
+model.testNbSubResults(GroupSubstraction_1, [0])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.FACE, [2])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.EDGE, [8])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.VERTEX, [16])
+model.testResultsVolumes(GroupSubstraction_1, [200])
+
+assert(model.checkPythonDump())