-// Copyright (C) 2014-2017 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
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_ValidatorTransform.h"
#include <Events_InfoMessage.h>
-#include "ModelAPI_AttributeSelectionList.h"
-#include "ModelAPI_ResultPart.h"
-#include "ModelAPI_ResultBody.h"
-#include "ModelAPI_Session.h"
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultPart.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
+ const std::list<std::string>& /*theArguments*/,
Events_InfoMessage& theError) const
{
bool aValid = true;
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++) {
}
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) {
- ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(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)