X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModuleBase%2FModuleBase_WidgetConcealedObjects.cpp;h=d3d2a45b8ad74cc2542e69770623dd8900462ea9;hb=087067417a2a33926c02748a8b75192210ad1438;hp=1b14529e43d96882fb47f4e02dba508e4b43d8bd;hpb=423f6b0a08a86d5e47115b87603cddeae4468b49;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp index 1b14529e4..d3d2a45b8 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp @@ -1,13 +1,27 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetConcealedObjects.cpp -// Created: 29 Jul 2016 -// Author: Natalia ERMOLAEVA +// 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 #include #include +#include #include #include #include @@ -24,6 +38,8 @@ #include #include +#include + const int DEFAULT_NAME_COLUMN_WIDTH = 200; ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent, @@ -31,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(), ::tolower); + myPickConcealedParents = aPickParents == "1" || aPickParents == "true" || aPickParents == "yes"; + QGridLayout* aMainLay = new QGridLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); @@ -55,7 +75,8 @@ bool ModuleBase_WidgetConcealedObjects::storeValueCustom() anAttributeList->clear(); int aSize1 = anAttributeList->size(false); for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) { - QCheckBox* aButton = dynamic_cast(myView->cellWidget(i, 0)->findChild()); + QCheckBox* aButton = + dynamic_cast(myView->cellWidget(i, 0)->findChild()); if (aButton->isChecked()) anAttributeList->append(myConcealedResults[i]); } @@ -78,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); @@ -96,7 +130,8 @@ bool ModuleBase_WidgetConcealedObjects::restoreValueCustom() int aSize = anAttributeList->size(); for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) { ResultPtr aResult = myConcealedResults[i]; - QCheckBox* aButton = dynamic_cast(myView->cellWidget(i, 0)->findChild()); + QCheckBox* aButton = + dynamic_cast(myView->cellWidget(i, 0)->findChild()); bool isChecked = anAttributeList->isInList(aResult); bool aBlocked = aButton->blockSignals(true);