X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_ValidatorTransform.cpp;h=0cf12f037d901c3fee0057414ac6d0459e559b04;hb=05e2e4a31fa248d71445c40e35eeafa44f5d3b1b;hp=570d1fb6ffb385fd3a2b4d2f5034e0b4e7b0d4f3;hpb=23898b690da4986d891bde5b124bbcec7e8144f1;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp b/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp old mode 100755 new mode 100644 index 570d1fb6f..0cf12f037 --- a/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp @@ -1,42 +1,82 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 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 "FeaturesPlugin_ValidatorTransform.h" -#include "ModelAPI_AttributeSelectionList.h" -#include "ModelAPI_ResultPart.h" -#include "ModelAPI_ResultBody.h" -#include "ModelAPI_ResultCompSolid.h" -#include "ModelAPI_Session.h" +#include + +#include +#include +#include +#include +#include bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute, - const std::list& theArguments, - std::string& theError) const + const std::list& /*theArguments*/, + Events_InfoMessage& theError) const { bool aValid = true; std::string anAttributeType = theAttribute->attributeType(); if (anAttributeType != ModelAPI_AttributeSelectionList::typeId()) { - theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; +// LCOV_EXCL_START + theError = "The attribute with the %1 type is not processed"; + theError.arg(theAttribute->attributeType()); return false; +// LCOV_EXCL_STOP } - std::shared_ptr aCurSelList = + std::shared_ptr aCurSelList = std::dynamic_pointer_cast(theAttribute); DocumentPtr aDocument = theAttribute->owner()->document(); SessionPtr aMgr = ModelAPI_Session::get(); bool isPartSetDocument = aDocument == aMgr->moduleDocument(); + bool isCheckCompsolid = !theAttribute->owner()->data()->version().empty(); std::string anErrorGroupName; for(int i = 0; i < aCurSelList->size() && aValid; i++) { std::shared_ptr aSelAttribute = aCurSelList->value(i); ResultPtr aResult = aSelAttribute->context(); + if (!aResult) { + // this could be a whole feature selected + FeaturePtr aFeature = aSelAttribute->contextFeature(); + if (aFeature.get() && aFeature->results().size() > 0) { + if (aFeature->firstResult()->groupName() != ModelAPI_ResultBody::group()) { + anErrorGroupName = aFeature->firstResult()->groupName(); + aValid = false; + break; + } + continue; + } + theError = "Invalid selection."; + return false; + } if (isPartSetDocument) // PartSet document: Result Part is valid aValid = aResult->groupName() == ModelAPI_ResultPart::group(); - else { // Part document: Result CompSolid is valid + else { // Part document: Result CompSolid is valid, but the solid in compsolid is forbidden aValid = aResult->groupName() == ModelAPI_ResultBody::group(); - if (aValid) { - ResultCompSolidPtr aComp = std::dynamic_pointer_cast(aResult); - aValid = aComp.get() != NULL; + if (aValid && isCheckCompsolid) { + ResultBodyPtr aComp = ModelAPI_Tools::bodyOwner(aResult); + if (aComp && aComp->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) { + theError = "Selecting a part of compsolid is forbidden."; + return false; + } } } if (!aValid) @@ -45,10 +85,9 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute if (!aValid) { std::string aResultGroupName = isPartSetDocument ? ModelAPI_ResultPart::group() : ModelAPI_ResultBody::group(); - theError = "Objects from the " + aResultGroupName + - " group can be selected in the " + aDocument->kind() + - "document, but an objects from the " + anErrorGroupName + - " group is selected."; + theError = "Objects from the %1 group can be selected in the %2 document, " + "but an objects from the %3 group is selected."; + theError.arg(aResultGroupName).arg(aDocument->kind()).arg(anErrorGroupName); } return aValid; }