Salome HOME
Fix of unstable behavior of results creation events on Linux
[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   myIsDisabled = true; // by default it is not initialized and false to be after created
18   setIsConcealed(false);
19   myOwnerData = theOwnerData;
20 }
21
22 void Model_ResultGroup::initAttributes()
23 {
24   // append the color attribute. It is empty, the attribute will be filled by a request
25   DataPtr aData = data();
26   aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
27 }
28
29 void Model_ResultGroup::colorConfigInfo(std::string& theSection, std::string& theName,
30                                        std::string& theDefault)
31 {
32   theSection = "Visualization";
33   theName = "result_group_color";
34   theDefault = DEFAULT_COLOR();
35 }
36
37 std::shared_ptr<GeomAPI_Shape> Model_ResultGroup::shape()
38 {
39   std::shared_ptr<GeomAPI_Shape> aResult;
40   if (myOwnerData) {
41     AttributeSelectionListPtr aList = myOwnerData->selectionList("group_list");
42     if (aList) {
43       std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
44       for(int a = aList->size() - 1; a >= 0; a--) {
45         std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
46         if (aSelection && !aSelection->isNull()) {
47           aSubs.push_back(aSelection);
48         }
49       }
50       if (!aSubs.empty()) {
51         aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);
52       }
53     }
54   }
55   return aResult;
56 }