Salome HOME
Issue #1865 : initial implementation of fields results and high level API
[modules/shaper.git] / src / Model / Model_ResultField.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultField.cpp
4 // Created:     08 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_ResultField.h>
8 #include <ModelAPI_AttributeSelectionList.h>
9
10 #include <GeomAlgoAPI_CompoundBuilder.h>
11
12 #include <Config_PropManager.h>
13
14 Model_ResultField::Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData)
15 {
16   myOwnerData = theOwnerData;
17 }
18
19 void Model_ResultField::colorConfigInfo(std::string& theSection, std::string& theName,
20                                        std::string& theDefault)
21 {
22   theSection = "Visualization";
23   theName = "result_field_color";
24   theDefault = DEFAULT_COLOR();
25 }
26
27 std::shared_ptr<GeomAPI_Shape> Model_ResultField::shape()
28 {
29   std::shared_ptr<GeomAPI_Shape> aResult;
30   if (myOwnerData) {
31     AttributeSelectionListPtr aList = myOwnerData->selectionList("selected");
32     if (aList) {
33       std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
34       for(int a = aList->size() - 1; a >= 0; a--) {
35         std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
36         if (aSelection && !aSelection->isNull()) {
37           aSubs.push_back(aSelection);
38         }
39       }
40       if (!aSubs.empty()) {
41         aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);
42       }
43     }
44   }
45   return aResult;
46 }