From: azv Date: Tue, 30 Jul 2019 08:50:46 +0000 (+0300) Subject: Task 2.5. Combination operations on Groups (issue #2935) X-Git-Tag: VEDF2019Lot4~59^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=91b664498fff007ffce9731f842f85f3f498bd75;p=modules%2Fshaper.git Task 2.5. Combination operations on Groups (issue #2935) Implementation of Group Addition operation from scratch. --- diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index 2e2ff961d..921596cdd 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -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 index 000000000..1c3795dc3 --- /dev/null +++ b/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp @@ -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 +#include +#include +#include +#include +#include + +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 index 000000000..4de080a6e --- /dev/null +++ b/src/CollectionPlugin/CollectionPlugin_GroupAddition.h @@ -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 diff --git a/src/CollectionPlugin/CollectionPlugin_Plugin.cpp b/src/CollectionPlugin/CollectionPlugin_Plugin.cpp index 7b0fc28e1..e55620606 100644 --- a/src/CollectionPlugin/CollectionPlugin_Plugin.cpp +++ b/src/CollectionPlugin/CollectionPlugin_Plugin.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -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 index 000000000..5eab220ac --- /dev/null +++ b/src/CollectionPlugin/group_addition_widget.xml @@ -0,0 +1,11 @@ + + + + + + + \ 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 index 000000000..3a1f83feb --- /dev/null +++ b/src/CollectionPlugin/group_intersection_widget.xml @@ -0,0 +1,15 @@ + + + + + + + \ 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 index 000000000..3a1f83feb --- /dev/null +++ b/src/CollectionPlugin/group_substraction_widget.xml @@ -0,0 +1,15 @@ + + + + + + + \ 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 index 000000000..6bc76e001 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 index 000000000..aba074c2e 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 index 000000000..7db75ec26 Binary files /dev/null and b/src/CollectionPlugin/icons/group_substraction.png differ diff --git a/src/CollectionPlugin/plugin-Collection.xml b/src/CollectionPlugin/plugin-Collection.xml index 27057f56f..9ec5c5dd6 100644 --- a/src/CollectionPlugin/plugin-Collection.xml +++ b/src/CollectionPlugin/plugin-Collection.xml @@ -21,6 +21,15 @@ + + + + diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index c3a387887..f5a45f605 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -18,6 +18,7 @@ // #include "FeaturesPlugin_Pipe.h" +#include "FeaturesPlugin_Tools.h" #include #include @@ -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); } diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index e9c92ad53..26b45f7c8 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -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(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(theContext); if (aFeatureContext.get()) { diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp index b7e5ccbb1..582161ace 100644 --- a/src/PartSet/PartSet_Filters.cpp +++ b/src/PartSet/PartSet_Filters.cpp @@ -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;