1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_BooleanArguments.cpp
4 // Created: 30 June 2015
5 // Author: Dmitry Bobylev
7 #include <GeomValidators_BooleanArguments.h>
9 #include <ModelAPI_AttributeInteger.h>
10 #include <ModelAPI_AttributeSelectionList.h>
12 //=================================================================================================
13 bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
14 const std::list<std::string>& theArguments,
15 std::string& theError) const
17 if(theArguments.size() != 3) {
18 theError = "Wrong number of arguments (expected 3).";
22 int anObjectsNb = 0, aToolsNb = 0;
23 int anOperationType = 0;
25 std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
27 std::shared_ptr<ModelAPI_AttributeSelectionList> anAttrSelList = theFeature->selectionList(*anIt);
29 anObjectsNb = anAttrSelList->size();
33 anAttrSelList = theFeature->selectionList(*anIt);
35 aToolsNb = anAttrSelList->size();
39 std::shared_ptr<ModelAPI_AttributeInteger> anAttrInt = theFeature->integer(*anIt);
41 anOperationType = anAttrInt->value();
44 if(anOperationType == 1 && (anObjectsNb + aToolsNb > 1)) {
46 } else if (anOperationType != 1 && anObjectsNb > 0 && aToolsNb > 0) {
50 theError = "Not enough arguments";
54 //=================================================================================================
55 bool GeomValidators_BooleanArguments::isNotObligatory(std::string theFeature, std::string theAttribute)
57 if(theAttribute == "main_objects" || theAttribute == "tool_objects") {