1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_MinObjectsSelected.cpp
4 // Created: 30 June 2015
5 // Author: Dmitry Bobylev
7 #include <GeomValidators_MinObjectsSelected.h>
9 #include <Events_InfoMessage.h>
11 #include <ModelAPI_AttributeInteger.h>
12 #include <ModelAPI_AttributeSelectionList.h>
14 //=================================================================================================
15 bool GeomValidators_MinObjectsSelected::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
16 const std::list<std::string>& theArguments,
17 Events_InfoMessage& theError) const
19 if(theArguments.size() != 2) {
20 theError = "Error: Wrong number of arguments (expected 2): selection list id and min number of objects";
24 std::string aSelectionListId = theArguments.front();
25 AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(aSelectionListId);
26 if(!anAttrSelList.get()) {
27 theError = "Error: Could not get attribute \"" + aSelectionListId + "\".";
30 int anObjectsNb = anAttrSelList->size();
32 int aMinObjectsNb = atoi(theArguments.back().c_str());
34 if(anObjectsNb < aMinObjectsNb) {
35 theError = "Error: Attribute \"" + aSelectionListId + "\" should contain at least "
36 + theArguments.back() + " items.";
43 //=================================================================================================
44 bool GeomValidators_MinObjectsSelected::isNotObligatory(std::string theFeature, std::string theAttribute)