1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeValidator.cpp
4 // Created: 29 July 2015
5 // Author: Sergey POKHODENKO
7 #include "Model_AttributeValidator.h"
8 #include <ModelAPI_AttributeDouble.h>
9 #include <GeomDataAPI_Point.h>
10 #include <GeomDataAPI_Point2D.h>
12 bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute,
13 const std::list<std::string>& theArguments,
14 std::string& theError) const
16 if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) {
17 AttributeDoublePtr anAttribue =
18 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
19 if (!anAttribue->expressionError().empty()) {
20 theError = anAttribue->expressionError();
24 if (theAttribute->attributeType() == GeomDataAPI_Point::typeId()) {
25 AttributePointPtr anAttribue =
26 std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttribute);
28 const char* aComponent[] = {"X", "Y", "Z"};
29 std::string anErrorMessage;
30 for (int i = 0; i < 3; ++i) {
31 if (!anAttribue->expressionError(i).empty())
32 anErrorMessage.append("\n").append(aComponent[i]).append(": ").append(anAttribue->expressionError(i));
34 if (!anErrorMessage.empty()) {
35 theError = anErrorMessage;
39 if (theAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
40 AttributePoint2DPtr anAttribue =
41 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
43 const char* aComponent[] = {"X", "Y"};
44 std::string anErrorMessage;
45 for (int i = 0; i < 2; ++i) {
46 if (!anAttribue->expressionError(i).empty())
47 anErrorMessage.append("\n").append(aComponent[i]).append(": ").append(anAttribue->expressionError(i));
49 if (!anErrorMessage.empty()) {
50 theError = anErrorMessage;