Salome HOME
Union of validator and filter functionalities.
[modules/shaper.git] / src / Model / Model_ResultGroup.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultGroup.cpp
4 // Created:     08 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_ResultGroup.h>
8 #include <ModelAPI_AttributeSelectionList.h>
9 #include <ModelAPI_AttributeIntArray.h>
10
11 #include <GeomAlgoAPI_CompoundBuilder.h>
12
13 #include <Config_PropManager.h>
14
15 Model_ResultGroup::Model_ResultGroup(std::shared_ptr<ModelAPI_Data> theOwnerData)
16 {
17   setIsConcealed(false);
18   myOwnerData = theOwnerData;
19 }
20
21 void Model_ResultGroup::initAttributes()
22 {
23   // append the color attribute. It is empty, the attribute will be filled by a request
24   DataPtr aData = data();
25   aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
26 }
27
28 void Model_ResultGroup::colorConfigInfo(std::string& theSection, std::string& theName,
29                                        std::string& theDefault)
30 {
31   theSection = "Visualization";
32   theName = "result_group_color";
33   theDefault = DEFAULT_COLOR();
34 }
35
36 std::shared_ptr<GeomAPI_Shape> Model_ResultGroup::shape()
37 {
38   std::shared_ptr<GeomAPI_Shape> aResult;
39   if (myOwnerData) {
40     AttributeSelectionListPtr aList = myOwnerData->selectionList("group_list");
41     if (aList) {
42       std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
43       for(int a = aList->size() - 1; a >= 0; a--) {
44         std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
45         if (aSelection && !aSelection->isNull()) {
46           aSubs.push_back(aSelection);
47         }
48       }
49       if (!aSubs.empty()) {
50         aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);
51       }
52     }
53   }
54   return aResult;
55 }