1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_PartitionArguments.cpp
4 // Created: 17 September 2015
5 // Author: Dmitry Bobylev
7 #include <GeomValidators_PartitionArguments.h>
9 #include <Events_InfoMessage.h>
11 #include <ModelAPI_AttributeBoolean.h>
12 #include <ModelAPI_AttributeSelectionList.h>
14 //=================================================================================================
15 bool GeomValidators_PartitionArguments::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 bool isCombine = true;
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_AttributeBoolean> anAttrBool = theFeature->boolean(*anIt);
43 isCombine = anAttrBool->value();
46 if((anObjectsNb > 0 && aToolsNb > 0) ||
47 (isCombine && anObjectsNb != 0 && (anObjectsNb + aToolsNb > 1))) {
51 theError = "Not enough arguments";
55 //=================================================================================================
56 bool GeomValidators_PartitionArguments::isNotObligatory(std::string theFeature,
57 std::string theAttribute)
59 if(theAttribute == "tool_objects") {