1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesPlugin_Validators.cpp
4 // Created: 22 March 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesPlugin_Validators.h"
9 #include <ModelAPI_Attribute.h>
10 #include <ModelAPI_AttributeSelectionList.h>
11 #include <ModelAPI_AttributeString.h>
13 //=================================================================================================
14 bool FeaturesPlugin_PipeLocationsValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
15 const std::list<std::string>& theArguments,
16 std::string& theError) const
18 static const std::string aCreationMethodID = "creation_method";
19 static const std::string aBaseObjectsID = "base_objects";
20 static const std::string aLocationsID = "locations_objects";
23 if(theFeature->getKind() != "Pipe") {
24 theError = "Feature \"" + theFeature->getKind() + "\" does not supported by this validator.";
28 AttributeStringPtr aCreationMethodAttr = theFeature->string(aCreationMethodID);
29 if(!aCreationMethodAttr.get()) {
30 theError = "Could not get \"" + aCreationMethodID + "\" attribute.";
34 if(aCreationMethodAttr->value() != "locations") {
38 AttributeSelectionListPtr aBaseObjectsSelectionList = theFeature->selectionList(aBaseObjectsID);
39 if(!aBaseObjectsSelectionList.get()) {
40 theError = "Could not get \"" + aBaseObjectsID + "\" attribute.";
44 AttributeSelectionListPtr aLocationsSelectionList = theFeature->selectionList(aLocationsID);
45 if(!aLocationsSelectionList.get()) {
46 theError = "Could not get \"" + aBaseObjectsID + "\" attribute.";
50 if(aLocationsSelectionList->size() > 0 && aLocationsSelectionList->size() != aBaseObjectsSelectionList->size()) {
51 theError = "Number of locations should be the same as base objects.";
58 //=================================================================================================
59 bool FeaturesPlugin_PipeLocationsValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
61 if(theFeature == "Pipe" && theAttribute == "locations") {