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 <ModelAPI_AttributeBoolean.h>
10 #include <ModelAPI_AttributeSelectionList.h>
12 //=================================================================================================
13 bool GeomValidators_PartitionArguments::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 bool isCombine = true;
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_AttributeBoolean> anAttrBool = theFeature->boolean(*anIt);
41 isCombine = anAttrBool->value();
44 if((anObjectsNb > 0 && aToolsNb > 0) || (isCombine && anObjectsNb != 0 && (anObjectsNb + aToolsNb > 1))) {
48 theError = "Not enough arguments";
52 //=================================================================================================
53 bool GeomValidators_PartitionArguments::isNotObligatory(std::string theFeature, std::string theAttribute)
55 if(theAttribute == "tool_objects") {