Salome HOME
Issue #614: Set Property panel as a tab over the object browser
[modules/shaper.git] / src / GeomValidators / GeomValidators_BooleanArguments.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomValidators_BooleanArguments.h
4 // Created:     30 June 2015
5 // Author:      Dmitry Bobylev
6
7 #include <GeomValidators_BooleanArguments.h>
8
9 #include <ModelAPI_AttributeInteger.h>
10 #include <ModelAPI_AttributeSelectionList.h>
11
12 //=================================================================================================
13 bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
14                                               const std::list<std::string>& theArguments) const
15 {
16   if(theArguments.size() != 3) {
17     return false;
18   }
19
20   int anObjectsNb = 0, aToolsNb = 0;
21   int anOperationType = 0;
22
23   std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
24
25   std::shared_ptr<ModelAPI_AttributeSelectionList> anAttrSelList = theFeature->selectionList(*anIt);
26   if(anAttrSelList) {
27     anObjectsNb = anAttrSelList->size();
28   }
29   anIt++;
30
31   anAttrSelList = theFeature->selectionList(*anIt);
32   if(anAttrSelList) {
33     aToolsNb = anAttrSelList->size();
34   }
35   anIt++;
36
37   std::shared_ptr<ModelAPI_AttributeInteger> anAttrInt = theFeature->integer(*anIt);
38   if(anAttrInt) {
39     anOperationType = anAttrInt->value();
40   }
41
42   if(anOperationType == 1 && (anObjectsNb + aToolsNb > 1)) {
43     return true;
44   } else if (anOperationType != 1 && anObjectsNb > 0 && aToolsNb > 0) {
45     return true;
46   }
47
48   return false;
49 }
50
51 //=================================================================================================
52 bool GeomValidators_BooleanArguments::isNotObligatory(std::string theFeature, std::string theAttribute)
53 {
54   if(theAttribute == "main_objects" || theAttribute == "tool_objects") {
55     return true;
56   }
57
58   return false;
59 }