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

One-dimensional graph representation of Data1DItem. More...

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

Public Member Functions

 GraphItem (const std::string &model_type=Constants::GraphItemType)
 
template<typename T = PropertyItem>
T * addProperty (const std::string &name)
 Adds property item of given type. More...
 
PropertyItemaddProperty (const std::string &name, const char *value)
 Register char property. Special case to turn it into std::string. More...
 
template<typename V >
PropertyItemaddProperty (const std::string &name, const V &value)
 
std::vector< double > binCenters () const
 
std::vector< double > binErrors () const
 
std::vector< double > binValues () const
 
std::vector< SessionItem * > children () const
 Returns vector of children formed from all chidlren from all tags. More...
 
int childrenCount () const
 Returns total number of children in all tags. More...
 
std::string colorName () const
 Returns color name in #RRGGBB format. More...
 
template<typename T >
data (int role=ItemDataRole::DATA) const
 Returns data of given type T for given role. More...
 
Data1DItemdataItem () const
 Returns data item linked to the given GraphItem. More...
 
std::string displayName () const override
 Returns display name. More...
 
std::string editorType () const
 Returns editor type. More...
 
SessionItemgetItem (const std::string &tag, int row=0) const
 Returns item at given row of given tag. More...
 
std::vector< SessionItem * > getItems (const std::string &tag) const
 Returns all children stored at given tag. More...
 
bool hasData (int role=ItemDataRole::DATA) const
 Returns true if item has data on board with given role. More...
 
std::string identifier () const
 Returns unique identifier. More...
 
bool insertItem (SessionItem *item, const TagRow &tagrow)
 Insert item into given tag under the given row. More...
 
bool isEditable () const
 Returns true if this item has editable flag set. More...
 
bool isEnabled () const
 Returns true if this item has enabled flag set. More...
 
template<typename T >
T * item (const std::string &tag) const
 Returns first item under given tag casted to a specified type. More...
 
int itemCount (const std::string &tag) const
 Returns number of items in given tag. More...
 
SessionItemDataitemData ()
 Returns pointer to item's data container (non-const version). More...
 
const SessionItemDataitemData () const
 Returns pointer to item's data container (const version). More...
 
template<typename T = SessionItem>
std::vector< T * > items (const std::string &tag) const
 Returns all items under given tag casted to specific type. More...
 
SessionItemTagsitemTags ()
 Returns pointer to internal collection of tag-registered items (non-const version). More...
 
const SessionItemTagsitemTags () const
 Returns pointer to internal collection of tag-registered items (const version). More...
 
ItemMappermapper ()
 Returns item mapper. Allows subscribing to various events happening to the item. More...
 
SessionModelmodel () const
 Returns the model to which given item belongs to. More...
 
model_type modelType () const
 Returns item's model type. More...
 
SessionItemparent () const
 Returns parent item. Will return nullptr if item doesn't have a parent. More...
 
PenItempenItem () const
 
template<typename T >
property (const std::string &tag) const
 Returns data stored in property item. More...
 
void registerTag (const TagInfo &tagInfo, bool set_as_default=false)
 Registers tag to hold items under given name. More...
 
template<typename T >
bool setData (const T &value, int role=ItemDataRole::DATA, bool direct=false)
 Sets data for a given role. More...
 
void setDataItem (const Data1DItem *item)
 Sets link to the data item. More...
 
virtual SessionItemsetDisplayName (const std::string &name)
 Sets display name (fluent interface). More...
 
SessionItemsetEditable (bool value)
 Sets editable flag to given value (fluent interface). More...
 
SessionItemsetEditorType (const std::string &editor_type)
 Sets editor type (fluent interface). More...
 
SessionItemsetEnabled (bool value)
 Sets enabled flag to given value (fluent interface). More...
 
void setFromGraphItem (const GraphItem *graph_item)
 Update item from the content of given graph. More...
 
void setNamedColor (const std::string &named_color)
 Sets named color following schema from https://www.w3.org/TR/css-color-3/#svg-color. More...
 
void setProperty (const std::string &tag, const char *value)
 Sets value to property item (specialized for special "const char *" case). More...
 
template<typename T >
void setProperty (const std::string &tag, const T &value)
 Sets value to property item. More...
 
SessionItemsetToolTip (const std::string &tooltip)
 Sets item tooltip (fluent interface). More...
 
TagRow tagRow () const
 Returns TagRow of this item under which it is accessible through its parent. More...
 
TagRow tagRowOfItem (const SessionItem *item) const
 Returns pair of tag and row corresponding to given item. More...
 
SessionItemtakeItem (const TagRow &tagrow)
 Removes item from given row from given tag, returns it to the caller. More...
 
std::string toolTip () const
 Returns item tooltip, if exists. More...
 

Static Public Attributes

static const std::string P_DISPLAYED = "P_DISPLAYED"
 
static const std::string P_GRAPH_TITLE = "P_GRAPH_TITLE"
 
static const std::string P_LINK = "P_LINK"
 
static const std::string P_PEN = "P_PEN"
 

Private Member Functions

virtual void activate ()
 
Variant data_internal (int role) const
 Returns data for given role. More...
 
bool set_data_internal (const Variant &value, int role, bool direct)
 Sets the data for given role. Method invented to hide implementaiton details. More...
 
void setAppearanceFlag (int flag, bool value)
 
void setDataAndTags (std::unique_ptr< SessionItemData > data, std::unique_ptr< SessionItemTags > tags)
 
void setModel (SessionModel *model)
 
void setParent (SessionItem *parent)
 

Private Attributes

std::unique_ptr< SessionItemImpl > p_impl
 

Detailed Description

One-dimensional graph representation of Data1DItem.

Contains plot properties (i.e. color, line type etc) and link to Data1DItem, which will provide actual data to plot. GraphItem is intended for plotting only via GraphViewportItem.

Definition at line 29 of file graphitem.h.

Constructor & Destructor Documentation

◆ GraphItem()

GraphItem::GraphItem ( const std::string &  model_type = Constants::GraphItemType)

Definition at line 24 of file graphitem.cpp.

25 {
26  addProperty<LinkedItem>(P_LINK)->setDisplayName("Link");
27  addProperty<TextItem>(P_GRAPH_TITLE)->setDisplayName("Graph title");
28  addProperty<PenItem>(P_PEN)->setDisplayName("Pen");
29  addProperty(P_DISPLAYED, true)->setDisplayName("Displayed");
30 }
T * addProperty(const std::string &name)
Adds property item of given type.
Definition: compounditem.h:43
CompoundItem(const std::string &modelType=Constants::CompoundItemType)
static const std::string P_DISPLAYED
Definition: graphitem.h:34
static const std::string P_GRAPH_TITLE
Definition: graphitem.h:32
static const std::string P_PEN
Definition: graphitem.h:33
static const std::string P_LINK
Definition: graphitem.h:31
std::string model_type
Definition: types.h:23

References ModelView::CompoundItem::addProperty(), P_DISPLAYED, P_GRAPH_TITLE, P_LINK, P_PEN, and ModelView::SessionItem::setDisplayName().

Here is the call graph for this function:

Member Function Documentation

◆ activate()

virtual void ModelView::SessionItem::activate ( )
inlineprivatevirtualinherited

Reimplemented in ToyItems::LatticeItem, ModelView::VectorItem, and gui2::MultiLayerItem.

Definition at line 123 of file sessionitem.h.

123 {}

Referenced by ModelView::SessionModel::registerInPool().

◆ addProperty() [1/3]

template<typename T >
T * ModelView::CompoundItem::addProperty ( const std::string &  name)
inherited

Adds property item of given type.

Definition at line 43 of file compounditem.h.

44 {
45  T* property = new T;
47  property->setDisplayName(name);
48  insertItem(property, {name, 0});
49  return property;
50 }
void registerTag(const TagInfo &tagInfo, bool set_as_default=false)
Registers tag to hold items under given name.
T property(const std::string &tag) const
Returns data stored in property item.
Definition: sessionitem.h:181
bool insertItem(SessionItem *item, const TagRow &tagrow)
Insert item into given tag under the given row.
static TagInfo propertyTag(std::string name, std::string model_type)
Constructs tag intended for single property.
Definition: taginfo.cpp:40
QString const & name(EShape k)
Definition: particles.cpp:21

References ModelView::SessionItem::insertItem(), RealSpace::Particles::name(), ModelView::SessionItem::property(), ModelView::TagInfo::propertyTag(), and ModelView::SessionItem::registerTag().

Referenced by ToyItems::AnysoPyramidItem::AnysoPyramidItem(), ModelView::ColorMapItem::ColorMapItem(), ToyItems::CylinderItem::CylinderItem(), ModelView::Data1DItem::Data1DItem(), gui2::ExperimentalScanItem::ExperimentalScanItem(), ModelView::FixedBinAxisItem::FixedBinAxisItem(), GraphItem(), ToyItems::LatticeItem::LatticeItem(), gui2::LayerElementItem::LayerElementItem(), gui2::LayerItem::LayerItem(), ToyItems::LayerItem::LayerItem(), gui2::MaterialBaseItem::MaterialBaseItem(), gui2::MultiLayerItem::MultiLayerItem(), ModelView::PenItem::PenItem(), gui2::QSpecScanItem::QSpecScanItem(), gui2::RoughnessItem::RoughnessItem(), gui2::SLDMaterialItem::SLDMaterialItem(), gui2::SpecularBeamItem::SpecularBeamItem(), ToyItems::SphereItem::SphereItem(), ModelView::TextItem::TextItem(), ModelView::VectorItem::VectorItem(), ModelView::ViewportAxisItem::ViewportAxisItem(), ModelView::CompoundItem::addProperty(), gui2::MaterialBaseItem::init_magnetic_field(), ModelView::BasicAxisItem::register_min_max(), TEST(), and TEST_F().

Here is the call graph for this function:

◆ addProperty() [2/3]

PropertyItem * ModelView::CompoundItem::addProperty ( const std::string &  name,
const char *  value 
)
inlineinherited

Register char property. Special case to turn it into std::string.

Definition at line 52 of file compounditem.h.

53 {
54  return addProperty(name, std::string(value));
55 }

References ModelView::CompoundItem::addProperty(), and RealSpace::Particles::name().

Here is the call graph for this function:

◆ addProperty() [3/3]

template<typename V >
PropertyItem * ModelView::CompoundItem::addProperty ( const std::string &  name,
const V &  value 
)
inherited

Definition at line 58 of file compounditem.h.

59 {
60  auto property = new PropertyItem;
62  property->setDisplayName(name);
63  property->setData(value);
64 
65  if constexpr (std::is_floating_point_v<V>)
66  property->setData(RealLimits::limitless(), ItemDataRole::LIMITS);
67 
68  insertItem(property, {name, 0});
69  return property;
70 }
static RealLimits limitless()
Creates an object withoud bounds (default)
Definition: reallimits.cpp:66
const int LIMITS
possibly limits on item's data
Definition: mvvm_types.h:33

References ModelView::SessionItem::insertItem(), ModelView::RealLimits::limitless(), ModelView::ItemDataRole::LIMITS, RealSpace::Particles::name(), ModelView::SessionItem::property(), ModelView::TagInfo::propertyTag(), and ModelView::SessionItem::registerTag().

Here is the call graph for this function:

◆ binCenters()

std::vector< double > GraphItem::binCenters ( ) const

Definition at line 59 of file graphitem.cpp.

60 {
61  return dataItem() ? dataItem()->binCenters() : std::vector<double>();
62 }
std::vector< double > binCenters() const
Sets axis. Bin content will be set to zero.
Definition: data1ditem.cpp:57
Data1DItem * dataItem() const
Returns data item linked to the given GraphItem.
Definition: graphitem.cpp:54

References ModelView::Data1DItem::binCenters(), and dataItem().

Referenced by ModelView::GraphViewportItem::data_xaxis_range(), gui2::ExperimentalScanItem::qScanValues(), and TEST_F().

Here is the call graph for this function:

◆ binErrors()

std::vector< double > GraphItem::binErrors ( ) const

Definition at line 69 of file graphitem.cpp.

70 {
71  return dataItem() ? dataItem()->binErrors() : std::vector<double>();
72 }
std::vector< double > binErrors() const
Returns value errors stored in bins.
Definition: data1ditem.cpp:93

References ModelView::Data1DItem::binErrors(), and dataItem().

Referenced by TEST_F().

Here is the call graph for this function:

◆ binValues()

std::vector< double > GraphItem::binValues ( ) const

Definition at line 64 of file graphitem.cpp.

65 {
66  return dataItem() ? dataItem()->binValues() : std::vector<double>();
67 }
std::vector< double > binValues() const
Returns values stored in bins.
Definition: data1ditem.cpp:76

References ModelView::Data1DItem::binValues(), and dataItem().

Referenced by ModelView::GraphViewportItem::data_yaxis_range(), and TEST_F().

Here is the call graph for this function:

◆ children()

◆ childrenCount()

int SessionItem::childrenCount ( ) const
inherited

Returns total number of children in all tags.

Definition at line 152 of file sessionitem.cpp.

153 {
154  return static_cast<int>(children().size());
155 }
std::vector< SessionItem * > children() const
Returns vector of children formed from all chidlren from all tags.

References ModelView::SessionItem::children().

Referenced by gui2::SLDElementController::buildSLD(), ModelView::ContainerItem::empty(), gui2::SLDElementController::getIdentifierVector(), ModelView::ContainerItem::size(), and TEST_F().

Here is the call graph for this function:

◆ colorName()

std::string GraphItem::colorName ( ) const

Returns color name in #RRGGBB format.

Definition at line 76 of file graphitem.cpp.

77 {
78  return penItem()->colorName();
79 }
PenItem * penItem() const
Definition: graphitem.cpp:89
std::string colorName() const
Returns color name in #RRGGBB format.

References ModelView::PenItem::colorName(), and penItem().

Referenced by gui2::Utils::CreateProperty(), and TEST_F().

Here is the call graph for this function:

◆ data()

template<typename T >
T SessionItem::data ( int  role = ItemDataRole::DATA) const
inlineinherited

Returns data of given type T for given role.

Definition at line 148 of file sessionitem.h.

149 {
150  return data_internal(role).value<T>();
151 }
Variant data_internal(int role) const
Returns data for given role.

References ModelView::SessionItem::data_internal().

Referenced by ModelView::Utils::CheckStateRole(), ModelView::PointwiseAxisItem::create(), ModelView::ViewItem::ViewItemImpl::data(), ModelView::SessionModel::data(), ModelView::Utils::DecorationRole(), ModelView::SessionItem::property(), ModelView::PointwiseAxisItem::range(), ModelView::Data2DItem::setContent(), ModelView::SessionItem::setDataAndTags(), ModelView::PointwiseAxisItem::setParameters(), ModelView::Data1DItem::setValues(), and TEST_F().

Here is the call graph for this function:

◆ data_internal()

Variant SessionItem::data_internal ( int  role) const
privateinherited

Returns data for given role.

Method invented to hide implementaiton details and avoid placing sessionitemdata.h into 'sessionitem.h' header.

Definition at line 343 of file sessionitem.cpp.

344 {
345  return p_impl->m_data->data(role);
346 }

References ModelView::SessionItem::p_impl.

Referenced by ModelView::SessionItem::data().

◆ dataItem()

Data1DItem * GraphItem::dataItem ( ) const

Returns data item linked to the given GraphItem.

Definition at line 54 of file graphitem.cpp.

55 {
56  return item<LinkedItem>(P_LINK)->get<Data1DItem>();
57 }
Represents one-dimensional data (axis and values).
Definition: data1ditem.h:30

References P_LINK.

Referenced by binCenters(), binErrors(), binValues(), gui2::ExperimentalDataModel::removeGraph(), setFromGraphItem(), and TEST_F().

◆ displayName()

std::string CompoundItem::displayName ( ) const
overridevirtualinherited

Returns display name.

Reimplemented from ModelView::SessionItem.

Definition at line 29 of file compounditem.cpp.

30 {
31  if (has_custom_display_name(this))
32  return SessionItem::displayName();
33 
34  int copy_number = Utils::CopyNumber(this);
35  return copy_number != -1 ? SessionItem::displayName() + std::to_string(copy_number)
37 }
std::string displayName() const override
Returns display name.
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
virtual std::string displayName() const
Returns display name.
Definition: sessionitem.cpp:94
MVVM_MODEL_EXPORT int CopyNumber(const SessionItem *item)
Returns copy number of given item in it's parent hierarchy.
Definition: itemutils.cpp:49

References ModelView::Utils::CopyNumber(), and ModelView::SessionItem::displayName().

Referenced by gui2::Utils::CreateProperty(), and TEST_F().

Here is the call graph for this function:

◆ editorType()

std::string SessionItem::editorType ( ) const
inherited

Returns editor type.

Definition at line 314 of file sessionitem.cpp.

315 {
316  return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE)
317  : std::string();
318 }
bool hasData(int role=ItemDataRole::DATA) const
Returns true if item has data on board with given role.
const int EDITORTYPE
type of custom editor for the data role
Definition: mvvm_types.h:35
Definition: filesystem.h:81

References ModelView::ItemDataRole::EDITORTYPE, and ModelView::SessionItem::hasData().

Referenced by ModelView::RoleDependentEditorFactory::createItemEditor(), and TEST_F().

Here is the call graph for this function:

◆ getItem()

◆ getItems()

std::vector< SessionItem * > SessionItem::getItems ( const std::string &  tag) const
inherited

Returns all children stored at given tag.

Definition at line 180 of file sessionitem.cpp.

181 {
182  return p_impl->m_tags->getItems(tag);
183 }

References ModelView::SessionItem::p_impl.

Referenced by ModelView::SessionItem::items(), and TEST_F().

◆ hasData()

bool SessionItem::hasData ( int  role = ItemDataRole::DATA) const
inherited

Returns true if item has data on board with given role.

Definition at line 131 of file sessionitem.cpp.

132 {
133  return p_impl->m_data->hasData(role);
134 }

References ModelView::SessionItem::p_impl.

Referenced by ModelView::SessionItem::editorType(), TEST_F(), ModelView::SessionItem::toolTip(), and ModelView::Utils::ToolTipRole().

◆ identifier()

std::string SessionItem::identifier ( ) const
inherited

Returns unique identifier.

Definition at line 87 of file sessionitem.cpp.

88 {
89  return data<std::string>(ItemDataRole::IDENTIFIER);
90 }
const int IDENTIFIER
unique identifier
Definition: mvvm_types.h:29

References ModelView::ItemDataRole::IDENTIFIER.

Referenced by gui2::Utils::CreateProperty(), gui2::MaterialBaseItem::external_property(), gui2::ExperimentalScanItem::graphItem(), ModelView::ItemManager::registerInPool(), and TEST_F().

◆ insertItem()

bool SessionItem::insertItem ( SessionItem item,
const TagRow tagrow 
)
inherited

Insert item into given tag under the given row.

Definition at line 216 of file sessionitem.cpp.

217 {
218  // think of passing unique_ptr directly
219 
220  if (!item)
221  throw std::runtime_error("SessionItem::insertItem() -> Invalid item.");
222 
223  if (item->parent())
224  throw std::runtime_error("SessionItem::insertItem() -> Existing parent.");
225 
226  if (item->model())
227  throw std::runtime_error("SessionItem::insertItem() -> Existing model.");
228 
229  auto result = p_impl->m_tags->insertItem(item, tagrow);
230  if (result) {
231  item->setParent(this);
232  item->setModel(model());
233 
234  if (p_impl->m_model) {
235  // FIXME think of actual_tagrow removal if input tag,row will be always valid
236  auto actual_tagrow = tagRowOfItem(item);
237  p_impl->m_model->mapper()->callOnItemInserted(this, actual_tagrow);
238  }
239  }
240 
241  return result;
242 }
TagRow tagRowOfItem(const SessionItem *item) const
Returns pair of tag and row corresponding to given item.
SessionModel * model() const
Returns the model to which given item belongs to.
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
Definition: sessionitem.h:156

References ModelView::SessionItem::item(), ModelView::SessionItem::model(), ModelView::SessionItem::p_impl, and ModelView::SessionItem::tagRowOfItem().

Referenced by ModelView::CompoundItem::addProperty(), ModelView::GroupItem::init_group(), ModelView::Data2DItem::insert_axis(), ModelView::Data1DItem::setAxis(), and TEST_F().

Here is the call graph for this function:

◆ isEditable()

bool SessionItem::isEditable ( ) const
inherited

Returns true if this item has editable flag set.

The data value of an editable item normally can be changed when it appears in trees and tables.

Definition at line 267 of file sessionitem.cpp.

268 {
269  return appearance(*this) & Appearance::EDITABLE;
270 }

References ModelView::EDITABLE.

Referenced by TEST_F().

◆ isEnabled()

bool SessionItem::isEnabled ( ) const
inherited

Returns true if this item has enabled flag set.

Enabled items appear in normal color, disabled items are grayed out.

Definition at line 283 of file sessionitem.cpp.

284 {
285  return appearance(*this) & Appearance::ENABLED;
286 }

References ModelView::ENABLED.

Referenced by ModelView::PropertyFlatView::PropertyFlatViewImpl::create_label(), TEST_F(), and ModelView::Utils::TextColorRole().

◆ item()

template<typename T >
T * SessionItem::item ( const std::string &  tag) const
inlineinherited

Returns first item under given tag casted to a specified type.

Returns nullptr, if item doesn't exist. If item exists but can't be casted will throw.

Definition at line 156 of file sessionitem.h.

157 {
158  if (auto item = getItem(tag); item) {
159  T* tag_item = dynamic_cast<T*>(item);
160  if (!tag_item)
161  throw std::runtime_error("Can't cast an item to given type");
162  return tag_item;
163  }
164  return nullptr;
165 }
SessionItem * getItem(const std::string &tag, int row=0) const
Returns item at given row of given tag.

References ModelView::SessionItem::getItem().

Referenced by ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::init_axis(), ModelView::SessionItem::insertItem(), ModelView::SessionItem::items(), gui2::Utils::SetDifference(), setFromGraphItem(), ModelView::LinkedItem::setLink(), ModelView::ColorMapViewportPlotController::ColorMapViewportPlotControllerImpl::setup_components(), ModelView::SessionItem::tagRowOfItem(), TEST_F(), gui2::SLDElementController::updateRoughnessFromView(), and gui2::JobModel::updateSpecularData().

Here is the call graph for this function:

◆ itemCount()

int SessionItem::itemCount ( const std::string &  tag) const
inherited

Returns number of items in given tag.

Definition at line 166 of file sessionitem.cpp.

167 {
168  return p_impl->m_tags->itemCount(tag);
169 }

References ModelView::SessionItem::p_impl.

Referenced by ModelView::MoveItemCommand::MoveItemCommand(), ModelView::CommandService::copyItem(), ModelView::CommandService::insertNewItem(), ModelView::Utils::MoveDown(), and ModelView::CommandService::moveItem().

◆ itemData() [1/2]

SessionItemData * SessionItem::itemData ( )
inherited

Returns pointer to item's data container (non-const version).

Definition at line 145 of file sessionitem.cpp.

146 {
147  return const_cast<SessionItemData*>(static_cast<const SessionItem*>(this)->itemData());
148 }
Handles data roles for SessionItem.
SessionItemData * itemData()
Returns pointer to item's data container (non-const version).

Referenced by ModelView::JsonItemConverter::JsonItemConverterImpl::item_to_json(), ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item(), and TEST_F().

◆ itemData() [2/2]

const SessionItemData * SessionItem::itemData ( ) const
inherited

Returns pointer to item's data container (const version).

Definition at line 138 of file sessionitem.cpp.

139 {
140  return p_impl->m_data.get();
141 }

References ModelView::SessionItem::p_impl.

◆ items()

template<typename T >
std::vector< T * > SessionItem::items ( const std::string &  tag) const
inherited

Returns all items under given tag casted to specific type.

Definition at line 169 of file sessionitem.h.

170 {
171  std::vector<T*> result;
172  for (auto item : getItems(tag))
173  if (auto casted = dynamic_cast<T*>(item); casted)
174  result.push_back(casted);
175  return result;
176 }
std::vector< SessionItem * > getItems(const std::string &tag) const
Returns all children stored at given tag.

References ModelView::SessionItem::getItems(), and ModelView::SessionItem::item().

Referenced by TEST_F().

Here is the call graph for this function:

◆ itemTags() [1/2]

SessionItemTags * SessionItem::itemTags ( )
inherited

Returns pointer to internal collection of tag-registered items (non-const version).

Definition at line 209 of file sessionitem.cpp.

210 {
211  return const_cast<SessionItemTags*>(static_cast<const SessionItem*>(this)->itemTags());
212 }
Collection of SessionItem's containers according to their tags.
SessionItemTags * itemTags()
Returns pointer to internal collection of tag-registered items (non-const version).

Referenced by ModelView::Utils::HasTag(), ModelView::Utils::IsSinglePropertyTag(), ModelView::JsonItemConverter::JsonItemConverterImpl::item_to_json(), ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item(), ModelView::Utils::RegisteredTags(), TEST(), and TEST_F().

◆ itemTags() [2/2]

const SessionItemTags * SessionItem::itemTags ( ) const
inherited

Returns pointer to internal collection of tag-registered items (const version).

Definition at line 195 of file sessionitem.cpp.

196 {
197  return p_impl->m_tags.get();
198 }

References ModelView::SessionItem::p_impl.

◆ mapper()

ItemMapper * SessionItem::mapper ( )
inherited

Returns item mapper. Allows subscribing to various events happening to the item.

Definition at line 383 of file sessionitem.cpp.

384 {
385  if (!p_impl->m_mapper)
386  p_impl->m_mapper = std::make_unique<ItemMapper>(this);
387  return p_impl->m_mapper.get();
388 }

References ModelView::SessionItem::p_impl.

Referenced by MockWidgetForItem::~MockWidgetForItem(), gui2::MultiLayerItem::activate(), ModelView::VectorItem::activate(), ToyItems::LatticeItem::activate(), gui2::LayerElementController::connectToModel(), gui2::LayerElementController::disconnectFormModel(), and MockWidgetForItem::setItem().

◆ model()

◆ modelType()

◆ parent()

◆ penItem()

PenItem * GraphItem::penItem ( ) const

Definition at line 89 of file graphitem.cpp.

90 {
91  return item<PenItem>(P_PEN);
92 }

References P_PEN.

Referenced by colorName(), setNamedColor(), and TEST_F().

◆ property()

template<typename T >
T SessionItem::property ( const std::string &  tag) const
inlineinherited

Returns data stored in property item.

Property is single item registered under certain tag via CompoundItem::addProperty method.

Definition at line 181 of file sessionitem.h.

182 {
183  return getItem(tag)->data<T>();
184 }
T data(int role=ItemDataRole::DATA) const
Returns data of given type T for given role.
Definition: sessionitem.h:148

References ModelView::SessionItem::data(), and ModelView::SessionItem::getItem().

Referenced by ToyItems::LatticeItem::activate(), ModelView::CompoundItem::addProperty(), gui2::LayerElementController::firstSegmentHandleRect(), gui2::LayerElementController::leftHandleMoved(), gui2::LayerElementController::leftRoughnessHandleRect(), gui2::LayerElementController::leftRoughnessPath(), gui2::LayerElementController::rightHandleMoved(), gui2::LayerElementController::rightRoughnessHandleRect(), gui2::LayerElementController::rightRoughnessPath(), gui2::LayerElementController::secondSegmentHandleRect(), gui2::LayerElementController::setLayerAbove(), gui2::LayerElementController::setRoughnessInLimits(), gui2::LayerElementController::sideSegmentMoved(), gui2::LayerElementController::sideSegmentRect(), TEST_F(), gui2::LayerElementController::topSegmentRect(), ModelView::ColorMapPlotController::ColorMapPlotControllerImpl::update_gradient(), ModelView::PenController::PenControllerImpl::update_graph_from_item(), ModelView::ColorMapPlotController::ColorMapPlotControllerImpl::update_interpolation(), ModelView::AxisTitleController::AxisTitleControllerImpl::updateAxisFromItem(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateLowerRange(), gui2::LayerElementController::updateRoughness(), gui2::SLDElementController::updateToView(), and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateUpperRange().

Here is the call graph for this function:

◆ registerTag()

◆ set_data_internal()

bool SessionItem::set_data_internal ( const Variant value,
int  role,
bool  direct 
)
privateinherited

Sets the data for given role. Method invented to hide implementaiton details.

Definition at line 331 of file sessionitem.cpp.

332 {
333  // If model is present, and undo stack is enabled, will forward request to the model
334  // (unless user explicitely asks for direct processing via direct=true flag).
335  const bool act_through_model = !direct && model() && model()->undoStack();
336  return act_through_model ? model()->setData(this, value, role)
337  : p_impl->do_setData(value, role);
338 }
bool setData(SessionItem *item, const Variant &value, int role)
Sets the data for given item.
UndoStackInterface * undoStack() const
Returns command stack to perform undo/redo.

References ModelView::SessionItem::model(), ModelView::SessionItem::p_impl, ModelView::SessionModel::setData(), and ModelView::SessionModel::undoStack().

Referenced by ModelView::SessionItem::setData().

Here is the call graph for this function:

◆ setAppearanceFlag()

void SessionItem::setAppearanceFlag ( int  flag,
bool  value 
)
privateinherited

Definition at line 367 of file sessionitem.cpp.

368 {
369  int flags = appearance(*this);
370  if (value)
371  flags |= flag;
372  else
373  flags &= ~flag;
374 
375  // By setting data with internal method we are bypassing the model, and so undo/redo.
376  // So current convention is to not invoke undo when changing appearance properties.
377  // Shall we change it?
378  p_impl->do_setData(flags, ItemDataRole::APPEARANCE);
379 }
const int APPEARANCE
appearance flag
Definition: mvvm_types.h:32

References ModelView::ItemDataRole::APPEARANCE, and ModelView::SessionItem::p_impl.

Referenced by ModelView::SessionItem::setEditable(), and ModelView::SessionItem::setEnabled().

◆ setData()

template<typename T >
bool SessionItem::setData ( const T &  value,
int  role = ItemDataRole::DATA,
bool  direct = false 
)
inlineinherited

Sets data for a given role.

When extra parameter direct is false (default case), will act through the model to register command in undo/redo framework (if enabled) and so allow later undo.

Definition at line 141 of file sessionitem.h.

142 {
143  return set_data_internal(Variant::fromValue(value), role, direct);
144 }
bool set_data_internal(const Variant &value, int role, bool direct)
Sets the data for given role. Method invented to hide implementaiton details.

References ModelView::SessionItem::set_data_internal().

Referenced by gui2::CanvasItem::CanvasItem(), ModelView::GroupItem::GroupItem(), ModelView::LinkedItem::LinkedItem(), ModelView::PointwiseAxisItem::PointwiseAxisItem(), ModelView::SessionItem::SessionItem(), ModelView::GroupItem::init_group(), ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item(), ModelView::Data2DItem::setContent(), ModelView::GroupItem::setCurrentIndex(), ModelView::SessionItem::setDisplayName(), ModelView::SessionItem::setEditorType(), ModelView::PropertyItem::setLimits(), ModelView::LinkedItem::setLink(), ModelView::PointwiseAxisItem::setParameters(), ModelView::SessionItem::setProperty(), ModelView::SessionItem::setToolTip(), TEST_F(), and ModelView::VectorItem::update_label().

Here is the call graph for this function:

◆ setDataAndTags()

void SessionItem::setDataAndTags ( std::unique_ptr< SessionItemData data,
std::unique_ptr< SessionItemTags tags 
)
privateinherited

Definition at line 390 of file sessionitem.cpp.

392 {
393  p_impl->m_data = std::move(data);
394  p_impl->m_tags = std::move(tags);
395 }

References ModelView::SessionItem::data(), and ModelView::SessionItem::p_impl.

Referenced by ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item().

Here is the call graph for this function:

◆ setDataItem()

void GraphItem::setDataItem ( const Data1DItem item)

Sets link to the data item.

Definition at line 34 of file graphitem.cpp.

35 {
36  item<LinkedItem>(P_LINK)->setLink(data_item);
37 }

References P_LINK.

Referenced by setFromGraphItem(), gui2::JobItem::setupDifferenceGraphFrom(), and TEST_F().

◆ setDisplayName()

SessionItem * SessionItem::setDisplayName ( const std::string &  name)
virtualinherited

Sets display name (fluent interface).

Reimplemented in ModelView::PropertyItem.

Definition at line 101 of file sessionitem.cpp.

102 {
104  return this;
105 }
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
Definition: sessionitem.h:141
const int DISPLAY
display name
Definition: mvvm_types.h:31

References ModelView::ItemDataRole::DISPLAY, RealSpace::Particles::name(), and ModelView::SessionItem::setData().

Referenced by ModelView::ColorMapItem::ColorMapItem(), GraphItem(), ModelView::ViewportAxisItem::ViewportAxisItem(), ModelView::PropertyItem::setDisplayName(), and TEST_F().

Here is the call graph for this function:

◆ setEditable()

SessionItem * SessionItem::setEditable ( bool  value)
inherited

Sets editable flag to given value (fluent interface).

Definition at line 274 of file sessionitem.cpp.

275 {
277  return this;
278 }
void setAppearanceFlag(int flag, bool value)

References ModelView::EDITABLE, and ModelView::SessionItem::setAppearanceFlag().

Referenced by ModelView::LinkedItem::LinkedItem(), ModelView::PointwiseAxisItem::PointwiseAxisItem(), ModelView::VectorItem::VectorItem(), and TEST_F().

Here is the call graph for this function:

◆ setEditorType()

SessionItem * SessionItem::setEditorType ( const std::string &  editor_type)
inherited

Sets editor type (fluent interface).

Allows creating custom editors in the cells of Qt trees and tables.

Definition at line 323 of file sessionitem.cpp.

324 {
325  setData(editor_type, ItemDataRole::EDITORTYPE);
326  return this;
327 }

References ModelView::ItemDataRole::EDITORTYPE, and ModelView::SessionItem::setData().

Referenced by TEST_F().

Here is the call graph for this function:

◆ setEnabled()

SessionItem * SessionItem::setEnabled ( bool  value)
inherited

Sets enabled flag to given value (fluent interface).

Definition at line 290 of file sessionitem.cpp.

291 {
293  return this;
294 }

References ModelView::ENABLED, and ModelView::SessionItem::setAppearanceFlag().

Referenced by TEST_F().

Here is the call graph for this function:

◆ setFromGraphItem()

void GraphItem::setFromGraphItem ( const GraphItem graph_item)

Update item from the content of given graph.

Link to the data will be set as in given item, other properties copied.

Definition at line 42 of file graphitem.cpp.

43 {
44  setDataItem(graph_item->dataItem());
45  auto pen = item<PenItem>(P_PEN);
46  auto source_pen = graph_item->item<PenItem>(P_PEN);
47  pen->setProperty(PenItem::P_COLOR, source_pen->property<QColor>(PenItem::P_COLOR));
48  pen->setProperty(PenItem::P_STYLE, source_pen->property<ComboProperty>(PenItem::P_STYLE));
49  pen->setProperty(PenItem::P_WIDTH, source_pen->property<int>(PenItem::P_WIDTH));
50 }
Custom property to define list of string values with multiple selections.
Definition: comboproperty.h:27
void setDataItem(const Data1DItem *item)
Sets link to the data item.
Definition: graphitem.cpp:34
Represents basics settings of QPen.
static const std::string P_STYLE
static const std::string P_COLOR
static const std::string P_WIDTH
void setProperty(const std::string &tag, const T &value)
Sets value to property item.
Definition: sessionitem.h:190

References dataItem(), ModelView::SessionItem::item(), ModelView::PenItem::P_COLOR, P_PEN, ModelView::PenItem::P_STYLE, ModelView::PenItem::P_WIDTH, setDataItem(), and ModelView::SessionItem::setProperty().

Referenced by TEST_F().

Here is the call graph for this function:

◆ setModel()

void SessionItem::setModel ( SessionModel model)
privateinherited

Definition at line 353 of file sessionitem.cpp.

354 {
355  if (p_impl->m_model)
356  p_impl->m_model->unregisterFromPool(this);
357 
358  p_impl->m_model = model;
359 
360  if (p_impl->m_model)
361  p_impl->m_model->registerInPool(this);
362 
363  for (auto child : children())
364  child->setModel(model);
365 }

References ModelView::SessionItem::children(), ModelView::SessionItem::model(), and ModelView::SessionItem::p_impl.

Here is the call graph for this function:

◆ setNamedColor()

void GraphItem::setNamedColor ( const std::string &  named_color)

Sets named color following schema from https://www.w3.org/TR/css-color-3/#svg-color.

e.g. "mediumaquamarine"

Definition at line 84 of file graphitem.cpp.

85 {
86  penItem()->setNamedColor(named_color);
87 }
void setNamedColor(const std::string &named_color)
Sets named color following schema from https://www.w3.org/TR/css-color-3/#svg-color.

References penItem(), and ModelView::PenItem::setNamedColor().

Referenced by TEST_F().

Here is the call graph for this function:

◆ setParent()

void SessionItem::setParent ( SessionItem parent)
privateinherited

Definition at line 348 of file sessionitem.cpp.

349 {
350  p_impl->m_parent = parent;
351 }
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.

References ModelView::SessionItem::p_impl, and ModelView::SessionItem::parent().

Here is the call graph for this function:

◆ setProperty() [1/2]

void SessionItem::setProperty ( const std::string &  tag,
const char *  value 
)
inlineinherited

Sets value to property item (specialized for special "const char *" case).

Property is single item registered under certain tag via CompoundItem::addProperty method, the value will be assigned to it's data role.

Definition at line 199 of file sessionitem.h.

200 {
201  setProperty(tag, std::string(value));
202 }

References ModelView::SessionItem::setProperty().

Here is the call graph for this function:

◆ setProperty() [2/2]

◆ setToolTip()

SessionItem * SessionItem::setToolTip ( const std::string &  tooltip)
inherited

Sets item tooltip (fluent interface).

Definition at line 306 of file sessionitem.cpp.

307 {
308  setData(tooltip, ItemDataRole::TOOLTIP);
309  return this;
310 }
const int TOOLTIP
tooltip for item's data
Definition: mvvm_types.h:34

References ModelView::SessionItem::setData(), and ModelView::ItemDataRole::TOOLTIP.

Referenced by TEST_F().

Here is the call graph for this function:

◆ tagRow()

TagRow SessionItem::tagRow ( ) const
inherited

Returns TagRow of this item under which it is accessible through its parent.

Definition at line 124 of file sessionitem.cpp.

125 {
126  return parent() ? parent()->tagRowOfItem(this) : TagRow();
127 }
Aggregate to hold (tag, row) information for SessionModel.
Definition: tagrow.h:25

References ModelView::SessionItem::parent(), and ModelView::SessionItem::tagRowOfItem().

Referenced by ModelView::MoveItemCommand::MoveItemCommand(), gui2::MaterialModel::cloneMaterial(), ModelView::Utils::DeleteItemFromModel(), ModelView::Utils::FindNextSibling(), gui2::ExperimentalDataModel::mergeCanvases(), ModelView::Utils::MoveDown(), ModelView::Utils::MoveUp(), gui2::ExperimentalDataModel::removeCanvas(), gui2::ExperimentalDataModel::removeGraph(), and TEST_F().

Here is the call graph for this function:

◆ tagRowOfItem()

TagRow SessionItem::tagRowOfItem ( const SessionItem item) const
inherited

Returns pair of tag and row corresponding to given item.

Returns {"", -1} if given item doesn't belong to children.

Definition at line 188 of file sessionitem.cpp.

189 {
190  return p_impl->m_tags->tagRowOfItem(item);
191 }

References ModelView::SessionItem::item(), and ModelView::SessionItem::p_impl.

Referenced by ModelView::Utils::FindPreviousSibling(), ModelView::SessionItem::insertItem(), ModelView::ItemMapper::ItemMapperImpl::processDataChange(), ModelView::Utils::SinglePropertyItems(), ModelView::SessionItem::tagRow(), TEST_F(), and ModelView::Utils::TopLevelItems().

Here is the call graph for this function:

◆ takeItem()

SessionItem * SessionItem::takeItem ( const TagRow tagrow)
inherited

Removes item from given row from given tag, returns it to the caller.

Definition at line 246 of file sessionitem.cpp.

247 {
248  if (!p_impl->m_tags->canTakeItem(tagrow))
249  return nullptr;
250 
251  if (p_impl->m_model)
252  p_impl->m_model->mapper()->callOnItemAboutToBeRemoved(this, tagrow);
253 
254  auto result = p_impl->m_tags->takeItem(tagrow);
255  result->setParent(nullptr);
256  result->setModel(nullptr);
257  // FIXME remaining problem is that ItemMapper still looking to the model
258  if (p_impl->m_model)
259  p_impl->m_model->mapper()->callOnItemRemoved(this, tagrow);
260 
261  return result;
262 }

References ModelView::SessionItem::p_impl.

Referenced by ModelView::Data2DItem::insert_axis(), and TEST_F().

◆ toolTip()

std::string SessionItem::toolTip ( ) const
inherited

Returns item tooltip, if exists.

Definition at line 298 of file sessionitem.cpp.

299 {
300  return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP)
301  : std::string();
302 }

References ModelView::SessionItem::hasData(), and ModelView::ItemDataRole::TOOLTIP.

Referenced by TEST_F(), and ModelView::Utils::ToolTipRole().

Here is the call graph for this function:

Member Data Documentation

◆ P_DISPLAYED

◆ P_GRAPH_TITLE

const std::string ModelView::GraphItem::P_GRAPH_TITLE = "P_GRAPH_TITLE"
inlinestatic

Definition at line 32 of file graphitem.h.

Referenced by GraphItem().

◆ p_impl

◆ P_LINK

const std::string ModelView::GraphItem::P_LINK = "P_LINK"
inlinestatic

◆ P_PEN

const std::string ModelView::GraphItem::P_PEN = "P_PEN"
inlinestatic

Definition at line 33 of file graphitem.h.

Referenced by GraphItem(), penItem(), and setFromGraphItem().


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