From f64cb187ce9ab2190d8eff7c9be7dcfffc4242a0 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 20 May 2019 10:36:40 +0300 Subject: [PATCH] Task 3.3. Recovering Compsolids and Compounds --- src/FeaturesAPI/FeaturesAPI_Recover.cpp | 20 ++++-- src/FeaturesAPI/FeaturesAPI_Recover.h | 4 +- src/FeaturesPlugin/CMakeLists.txt | 3 + src/FeaturesPlugin/FeaturesPlugin_Recover.cpp | 9 +++ src/FeaturesPlugin/FeaturesPlugin_Recover.h | 24 +++++++ .../Test/TestRecover_Compound.py | 52 ++++++++++++++ .../Test/TestRecover_Compsolid1.py | 65 ++++++++++++++++++ .../Test/TestRecover_Compsolid2.py | 45 ++++++++++++ .../icons/recover_compound_32x32.png | Bin 0 -> 761 bytes .../icons/recover_default_32x32.png | Bin 0 -> 789 bytes src/FeaturesPlugin/recover_widget.xml | 16 ++++- .../ModuleBase_WidgetConcealedObjects.cpp | 20 ++++++ .../ModuleBase_WidgetConcealedObjects.h | 1 + 13 files changed, 250 insertions(+), 9 deletions(-) create mode 100644 src/FeaturesPlugin/Test/TestRecover_Compound.py create mode 100644 src/FeaturesPlugin/Test/TestRecover_Compsolid1.py create mode 100644 src/FeaturesPlugin/Test/TestRecover_Compsolid2.py create mode 100644 src/FeaturesPlugin/icons/recover_compound_32x32.png create mode 100644 src/FeaturesPlugin/icons/recover_default_32x32.png diff --git a/src/FeaturesAPI/FeaturesAPI_Recover.cpp b/src/FeaturesAPI/FeaturesAPI_Recover.cpp index 3699e131e..6a99ac3bb 100644 --- a/src/FeaturesAPI/FeaturesAPI_Recover.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Recover.cpp @@ -33,10 +33,15 @@ FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr //================================================================================================= FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr& theFeature, const ModelHighAPI_Reference& theBaseFeature, - const std::list& theRecoveredList, const bool thePersistent) + const std::list& theRecoveredList, + const bool theRecoverCompound) : ModelHighAPI_Interface(theFeature) { if(initialize()) { + std::string aMethod = theRecoverCompound ? FeaturesPlugin_Recover::METHOD_COMPOUND() + : FeaturesPlugin_Recover::METHOD_DEFAULT(); + fillAttribute(aMethod, theFeature->string(FeaturesPlugin_Recover::METHOD())); + setBaseFeature(theBaseFeature); setRecoveredList(theRecoveredList); } @@ -75,15 +80,22 @@ void FeaturesAPI_Recover::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aFeature = ModelAPI_Feature::feature(anAttrBaseFeature->value()); theDumper << aBase << " = model.addRecover(" << aDocName << ", " - << aFeature << ", " << anAttrRecoveredEntities << ")" << std::endl; + << aFeature << ", " << anAttrRecoveredEntities; + + AttributeStringPtr aMethod = aBase->string(FeaturesPlugin_Recover::METHOD()); + if (aMethod && aMethod->isInitialized() && + aMethod->value() != FeaturesPlugin_Recover::METHOD_DEFAULT()) + theDumper << ", " << true; + + theDumper << ")" << std::endl; } //================================================================================================= RecoverPtr addRecover(const std::shared_ptr& thePart, const ModelHighAPI_Reference& theBaseFeature, - const std::list& theRecoveredList, const bool thePersistent) + const std::list& theRecoveredList, const bool theRecoverCompound) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Recover::ID()); return RecoverPtr(new FeaturesAPI_Recover( - aFeature, theBaseFeature, theRecoveredList, thePersistent)); + aFeature, theBaseFeature, theRecoveredList, theRecoverCompound)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Recover.h b/src/FeaturesAPI/FeaturesAPI_Recover.h index 95335fb29..b4b16578e 100644 --- a/src/FeaturesAPI/FeaturesAPI_Recover.h +++ b/src/FeaturesAPI/FeaturesAPI_Recover.h @@ -45,7 +45,7 @@ public: FeaturesAPI_Recover(const std::shared_ptr& theFeature, const ModelHighAPI_Reference& theBaseFeature, const std::list& theRecoveredList, - const bool thePersistent = false); + const bool theRecoverCompound = false); /// Destructor. FEATURESAPI_EXPORT @@ -79,6 +79,6 @@ FEATURESAPI_EXPORT RecoverPtr addRecover(const std::shared_ptr& thePart, const ModelHighAPI_Reference& theBaseFeature, const std::list& theRecoveredList, - const bool thePersistent = false); + const bool theRecoverCompound = false); #endif // FeaturesAPI_Recover_H_ diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 1b383d545..5317c2a3c 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -263,6 +263,9 @@ ADD_UNIT_TESTS(TestExtrusion.py TestPipe_Compound.py TestPipe_ErrorMsg.py TestRecover.py + TestRecover_Compound.py + TestRecover_Compsolid1.py + TestRecover_Compsolid2.py TestRecover1798.py TestSplitEdgeVertex.py TestSplitEdgeEdge.py diff --git a/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp b/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp index 4cebf871b..1721e05b6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,8 @@ void FeaturesPlugin_Recover::initAttributes() data()->addAttribute(BASE_FEATURE(), ModelAPI_AttributeReference::typeId()); data()->addAttribute(RECOVERED_ENTITIES(), ModelAPI_AttributeRefList::typeId()); + data()->addAttribute(METHOD(), ModelAPI_AttributeString::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), METHOD()); } void FeaturesPlugin_Recover::execute() @@ -81,3 +84,9 @@ void FeaturesPlugin_Recover::execute() removeResults(aResultIndex); } + +void FeaturesPlugin_Recover::attributeChanged(const std::string& theID) +{ + if (theID == METHOD()) + reflist(RECOVERED_ENTITIES())->clear(); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Recover.h b/src/FeaturesPlugin/FeaturesPlugin_Recover.h index de1937a15..ac2de898c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Recover.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Recover.h @@ -59,6 +59,26 @@ class FeaturesPlugin_Recover : public ModelAPI_Feature return MY_RECOVERED_ENTITIES_ID; } + /// Attribute name of the type of recover. + inline static const std::string& METHOD() + { + static const std::string MY_METHOD_ID("method"); + return MY_METHOD_ID; + } + + /// Value of default method, recovering concealed objects only. + inline static const std::string& METHOD_DEFAULT() + { + static const std::string MY_METHOD_ID("default"); + return MY_METHOD_ID; + } + /// Value of method, recovering parent compounds of concealed objects. + inline static const std::string& METHOD_COMPOUND() + { + static const std::string MY_METHOD_ID("compound"); + return MY_METHOD_ID; + } + /// Returns the kind of a feature FEATURESPLUGIN_EXPORT virtual const std::string& getKind() { @@ -72,6 +92,10 @@ class FeaturesPlugin_Recover : public ModelAPI_Feature /// Request for initialization of data model of the feature: adding all attributes FEATURESPLUGIN_EXPORT virtual void initAttributes(); + /// Called on change of any argument-attribute of this object + /// \param theID identifier of changed attribute + FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); + /// Use plugin manager for features creation FeaturesPlugin_Recover(); diff --git a/src/FeaturesPlugin/Test/TestRecover_Compound.py b/src/FeaturesPlugin/Test/TestRecover_Compound.py new file mode 100644 index 000000000..19703b4f7 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRecover_Compound.py @@ -0,0 +1,52 @@ +# 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() +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 50) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 50, 2) +LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 50, 3) +Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "([LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_1][LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_2])([LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_1][LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_3])"), False) +SketchLine_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(50, 25, 5) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5) +SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchCircle_1.center(), SketchLine_1.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 100, 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_2_2")], [model.selection("SOLID", "Extrusion_1_1")], 20190506) +Recover_1 = model.addRecover(Part_1_doc, Cut_1, [LinearCopy_2.result()], True) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Part_1, 1) +model.testNbSubResults(Part_1, [0]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [12]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [37]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [82]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [164]) +model.testResultsVolumes(Part_1, [186975.51922585917]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestRecover_Compsolid1.py b/src/FeaturesPlugin/Test/TestRecover_Compsolid1.py new file mode 100644 index 000000000..7106ac642 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRecover_Compsolid1.py @@ -0,0 +1,65 @@ +# 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("XOY")) +SketchLine_1 = Sketch_1.addLine(31.9410018961801, -31.48668563219184, -26.28238891138439, -31.48668563219184) +SketchLine_2 = Sketch_1.addLine(-26.28238891138439, -31.48668563219184, -26.28238891138439, 32.16845339608692) +SketchLine_3 = Sketch_1.addLine(-26.28238891138439, 32.16845339608692, 31.9410018961801, 32.16845339608692) +SketchLine_4 = Sketch_1.addLine(31.9410018961801, 32.16845339608692, 31.9410018961801, -31.48668563219184) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +SketchLine_5 = Sketch_1.addLine(-26.28238891138439, -12.06888707668976, 31.9410018961801, 21.15910771625288) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_2.result()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_4.result()) +SketchLine_6 = Sketch_1.addLine(-0.02931756086478185, 2.913698204490415, 1.128717663020605, -31.48668563219184) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_5.result()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_1.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_4")) +SketchCircle_1 = Sketch_2.addCircle(-4.420087352215441, 24.04732854606771, 12.87676926472621) +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2r_wire")], model.selection(), 20, 80) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("SOLID", "Extrusion_2_1")], 20190506) +Recover_1 = model.addRecover(Part_1_doc, Cut_1, [Extrusion_1.result()], True) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Part_1, 1) +model.testNbSubResults(Part_1, [0]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [6]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [41]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [182]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [364]) +model.testResultsVolumes(Part_1, [354429.714290673]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestRecover_Compsolid2.py b/src/FeaturesPlugin/Test/TestRecover_Compsolid2.py new file mode 100644 index 000000000..25b379941 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRecover_Compsolid2.py @@ -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 +# + +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, 100, 100, 100) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], -50, -50, -50) +Partition_1_objects = [model.selection("SOLID", "Translation_1_1"), model.selection("FACE", "PartSet/XOY"), model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects, 20190506) +CompSolid_1_objects = [model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_5"), model.selection("SOLID", "Partition_1_1_6"), model.selection("SOLID", "Partition_1_1_8")] +CompSolid_1 = model.addCompSolid(Part_1_doc, CompSolid_1_objects) +Recover_1 = model.addRecover(Part_1_doc, CompSolid_1, [Partition_1.result()], True) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Part_1, 1) +model.testNbSubResults(Part_1, [0]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [12]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [72]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [288]) +model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [576]) +model.testResultsVolumes(Part_1, [1500000]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/icons/recover_compound_32x32.png b/src/FeaturesPlugin/icons/recover_compound_32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..88b4752d1f61b144ed4acf43ac37d0e9c5244f65 GIT binary patch literal 761 zcmV`~0O0eI ztem-bMj+Y748a~oLF4wyh_1XpjGvLkJe{Z<13RnRL z)|O$@iS8jnNZ)?{FXnM%#M@)LD>fXD`Pkd9b>ad454P2r2*LPm*>Zk-yXYFMIaM~&J$}3V?dQ&-Vd1E;{t$4`9QZgRS z>|j{Co2H%xv6PJS_uDBg2>IfeX#z#Kk{4Ebf(i8*m?BULAMT%UaW^6};M|RI~4!|qD+}J{6JpgFIs}hLD8}>%y4Tket@Tvr^9DhI6cQDbWmm8c4L~lj* zv}?hu5|D&K!R^TD=4>J>R2q+^WDHFQD1b%4qKzn>m6oX>o-$RS6s|x#y7c(L2h#+2 za8m@d;HC&@!GV%h@O<9q0WiU9l+B3*K*zKBCU>qNa&znbyo~^$1qT4a7=teqegvS) rz=Zy{GE@*-d2m(0%Ch|D)N+A;U(sa0JF4wX00000NkvXXu0mjf#Licw literal 0 HcmV?d00001 diff --git a/src/FeaturesPlugin/icons/recover_default_32x32.png b/src/FeaturesPlugin/icons/recover_default_32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..caf03179b3382b1c5e9164f957c28eb72eea194c GIT binary patch literal 789 zcmV+w1M2*VP)f$VgekN_JQ!_S## z-cD74il&w>0@9uXe64j3#g?NC0AFAkj`kx54$;$X9+8*3)7wp-zVL}>>cX_6d4!t- zfFHAR?BuP+MVcf0mvX5TQ|8hH^nh1y`ja-V z2p9neR<>c~VfS4^$f@e8?M$*tqW95*tPQ_>9bv)Ikho{dZ&qTBi#G;#a^drTEwm@F zEp8SW7p@2}LOcKv8XF~{u~D@}5davTw3FdUyIKwaL;#ZaLO6|HF#bEqREt$tdeF<5Y5SK<5M%!@D27+0ONqpFQTcL zXML-P>r0jxEp96LPuXv4?Vv7Vo z!^gmoEfJ^O+*-e(asW_+0{~%+!O_(67(jCl3;N%RQbDZc!4&}`%kZC5!v+2UBe!ct TV_u;n00000NkvXXu0mjfo!?o! literal 0 HcmV?d00001 diff --git a/src/FeaturesPlugin/recover_widget.xml b/src/FeaturesPlugin/recover_widget.xml index 0e2f865f6..e1f9f957e 100644 --- a/src/FeaturesPlugin/recover_widget.xml +++ b/src/FeaturesPlugin/recover_widget.xml @@ -4,7 +4,17 @@ tooltip="Select a feature that conceals results."> - + + + + + + + + diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp index 5154ea04a..811c7167c 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,8 @@ #include #include +#include + const int DEFAULT_NAME_COLUMN_WIDTH = 200; ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent, @@ -44,6 +47,10 @@ ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* th : ModuleBase_ModelWidget(theParent, theData) { myBaseShapeAttribute = theData->getProperty("base_shape_attribute"); + std::string aPickParents = theData->getProperty("pick_concealed_parents"); + std::transform(aPickParents.begin(), aPickParents.end(), aPickParents.begin(), std::tolower); + myPickConcealedParents = aPickParents == "1" || aPickParents == "true" || aPickParents == "yes"; + QGridLayout* aMainLay = new QGridLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); @@ -92,11 +99,24 @@ bool ModuleBase_WidgetConcealedObjects::restoreValueCustom() myBaseFeature = aBaseFeature; if (myBaseFeature.get()) { std::list > aResults; + std::set aParents; ModelAPI_Tools::getConcealedResults(myBaseFeature, aResults); std::list >::const_iterator anIt = aResults.begin(), aLast = aResults.end(); for (; anIt != aLast; anIt++) { ResultPtr aResult = *anIt; + if (myPickConcealedParents) { + // pick the parent result of the concealed object + ResultBodyPtr aRootParent = ModelAPI_Tools::bodyOwner(aResult, true); + if (aRootParent) { + if (aParents.find(aRootParent) == aParents.end()) { + aResult = aRootParent; + aParents.insert(aRootParent); + } + else // do not add parent compound once again + continue; + } + } int aRowId = myView->rowCount(); addViewRow(aResult); diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h index 9d38d836a..f785dada9 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h @@ -73,6 +73,7 @@ private slots: private: std::string myBaseShapeAttribute; ///< attribute of the base object + bool myPickConcealedParents; ///< select parent compsolid/compounds of concealed objects QTableWidget* myView; ///< table view of visibility states std::shared_ptr myBaseFeature; ///< backup of feature of filling the table view -- 2.39.2