BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::PropertyItemsFlatStrategy Class Reference

Strategy to find children of given item: flat alignment. More...

Inheritance diagram for ModelView::PropertyItemsFlatStrategy:
[legend]
Collaboration diagram for ModelView::PropertyItemsFlatStrategy:
[legend]

Public Member Functions

std::vector< SessionItem * > children (const SessionItem *item) const override
 Returns vector of children of given item. More...
 

Detailed Description

Strategy to find children of given item: flat alignment.

Acts as PropertyItemStrategy, with the difference that active subproperties of GroupItem are moved to the same parent, as GroupItem itself. See example in code.

Definition at line 56 of file standardchildrenstrategies.h.

Member Function Documentation

◆ children()

std::vector< SessionItem * > PropertyItemsFlatStrategy::children ( const SessionItem item) const
overridevirtual

Returns vector of children of given item.

Implements ModelView::ChildrenStrategyInterface.

Definition at line 83 of file standardchildrenstrategies.cpp.

84 {
85  if (!item)
86  return std::vector<SessionItem*>();
87 
88  if (auto group = dynamic_cast<const GroupItem*>(item); group)
89  return Utils::SinglePropertyItems(*group->currentItem());
90 
91  std::vector<SessionItem*> result;
92  for (auto child : Utils::SinglePropertyItems(*item)) {
93  if (auto group_item = dynamic_cast<GroupItem*>(child); group_item) {
94  result.push_back(group_item);
95  for (auto sub_property : Utils::SinglePropertyItems(*group_item->currentItem()))
96  result.push_back(sub_property);
97  } else {
98  result.push_back(child);
99  }
100  }
101 
102  return result;
103 }
Group item holds collection of predefined items.
Definition: groupitem.h:26
MVVM_MODEL_EXPORT std::vector< SessionItem * > SinglePropertyItems(const SessionItem &item)
Returns vector of children representing property items.
Definition: itemutils.cpp:122

References ModelView::Utils::SinglePropertyItems().

Referenced by TEST_F().

Here is the call graph for this function:

The documentation for this class was generated from the following files: