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 <Events_InfoMessage.h>
11 #include <ModelAPI_AttributeInteger.h>
12 #include <ModelAPI_AttributeSelectionList.h>
14 //=================================================================================================
15 bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
16 const std::list<std::string>& theArguments,
17 Events_InfoMessage& theError) const
19 if(theArguments.size() != 3) {
20 theError = "Wrong number of arguments (expected 3).";
24 int anObjectsNb = 0, aToolsNb = 0;
25 int anOperationType = 0;
27 std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
29 std::shared_ptr<ModelAPI_AttributeSelectionList> anAttrSelList = theFeature->selectionList(*anIt);
31 anObjectsNb = anAttrSelList->size();
35 anAttrSelList = theFeature->selectionList(*anIt);
37 aToolsNb = anAttrSelList->size();
41 std::shared_ptr<ModelAPI_AttributeInteger> anAttrInt = theFeature->integer(*anIt);
43 anOperationType = anAttrInt->value();
46 if(anOperationType == 1 && (anObjectsNb + aToolsNb > 1)) {
48 } else if (anOperationType != 1 && anObjectsNb > 0 && aToolsNb > 0) {
52 theError = "Not enough arguments";
56 //=================================================================================================
57 bool GeomValidators_BooleanArguments::isNotObligatory(std::string theFeature,
58 std::string theAttribute)
60 if(theAttribute == "main_objects" || theAttribute == "tool_objects") {