1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: Model_ResultValidators.cpp
4 // Created: 27 Feb 2015
5 // Author: Natalia ERMOLAEVA
7 #include "SketchPlugin_ShapeValidator.h"
8 #include "SketchPlugin_Feature.h"
10 #include <ModelAPI_Session.h>
11 #include <ModelAPI_Result.h>
12 #include <ModelAPI_Tools.h>
13 #include <ModelAPI_AttributeRefAttr.h>
14 #include <ModelAPI_ResultValidator.h>
16 bool SketchPlugin_ShapeValidator::isValid(const FeaturePtr& theFeature,
17 const std::list<std::string>& theArguments,
18 const ObjectPtr& theObject,
19 const AttributePtr& theAttribute,
20 const GeomShapePtr& theShape) const
22 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
23 std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
25 // if the shapes are equal, that means that the given shape is a result.
26 // if the result is selected, the
27 if (aShape->isEqual(theShape))
30 // found a non-external argument on the feature
31 std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
32 bool aHasNullParam = false;
33 bool aHasNonExternalParams = false;
34 for (; anIt != aLast; anIt++) {
35 std::string aParamA = *anIt;
36 std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
37 ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(aParamA));
39 FeaturePtr anOtherFeature = ModelAPI_Feature::feature(anAttr->object());
40 if (anOtherFeature.get() != NULL) {
41 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
42 std::dynamic_pointer_cast<SketchPlugin_Feature>(anOtherFeature);
44 aHasNonExternalParams = !aSketchFeature->isExternal();
51 if (aHasNullParam || aHasNonExternalParams)