Salome HOME
Issue #1865 : initial implementation of fields results and high level API
[modules/shaper.git] / src / CollectionPlugin / CollectionPlugin_Field.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        CollectionPlugin_Field.cpp
4 // Created:     08 Oct 2014
5 // Author:      Sergey BELASH
6
7 #include "CollectionPlugin_Field.h"
8
9 #include <ModelAPI_Data.h>
10 #include <ModelAPI_Document.h>
11 #include <ModelAPI_AttributeInteger.h>
12 #include <ModelAPI_AttributeStringArray.h>
13 #include <ModelAPI_AttributeSelectionList.h>
14 #include <ModelAPI_AttributeIntArray.h>
15 #include <ModelAPI_AttributeTables.h>
16 #include <ModelAPI_ResultField.h>
17
18 CollectionPlugin_Field::CollectionPlugin_Field()
19 {
20 }
21
22 void CollectionPlugin_Field::initAttributes()
23 {
24   data()->addAttribute(SELECTED_ID(), ModelAPI_AttributeSelectionList::typeId());
25   data()->addAttribute(COMPONENTS_NB_ID(), ModelAPI_AttributeInteger::typeId());
26   data()->addAttribute(COMPONENTS_NAMES_ID(), ModelAPI_AttributeStringArray::typeId());
27   data()->addAttribute(VALUES_TYPE_ID(), ModelAPI_AttributeInteger::typeId());
28   data()->addAttribute(STEPS_NB_ID(), ModelAPI_AttributeInteger::typeId());
29   data()->addAttribute(STAMPS_ID(), ModelAPI_AttributeIntArray::typeId());
30   data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId());
31 }
32
33 void CollectionPlugin_Field::execute()
34 {
35   if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
36     ResultPtr aField = document()->createField(data());
37     setResult(aField);
38   }
39 }