BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IView Class Reference

parent class for graphic representation of all ISampleNode's More...

Inheritance diagram for IView:
[legend]
Collaboration diagram for IView:
[legend]

Public Slots

virtual void onChangedX ()
 
virtual void onChangedY ()
 

Signals

void aboutToBeDeleted ()
 

Public Member Functions

 IView (QGraphicsItem *parent=0)
 
virtual ~IView ()
 
virtual void addView (IView *childView, int row=0)
 
virtual SessionItemgetItem ()
 
virtual void setParameterizedItem (SessionItem *item)
 
int type () const
 

Protected Member Functions

virtual void onPropertyChange (const QString &propertyName)
 
virtual void onSiblingsChange ()
 
virtual void update_appearance ()
 updates visual appearance of the item (color, icons, size etc) More...
 

Protected Attributes

SessionItemm_item
 

Detailed Description

parent class for graphic representation of all ISampleNode's

Definition at line 25 of file IView.h.

Constructor & Destructor Documentation

◆ IView()

IView::IView ( QGraphicsItem *  parent = 0)

Definition at line 19 of file IView.cpp.

19  : QGraphicsObject(parent), m_item(0)
20 {
21  connect(this, &IView::xChanged, this, &IView::onChangedX);
22  connect(this, &IView::yChanged, this, &IView::onChangedY);
23 }
virtual void onChangedY()
Definition: IView.cpp:62
virtual void onChangedX()
Definition: IView.cpp:55
SessionItem * m_item
Definition: IView.h:51

References onChangedX(), and onChangedY().

Here is the call graph for this function:

◆ ~IView()

IView::~IView ( )
virtual

Definition at line 25 of file IView.cpp.

26 {
27  if (m_item)
28  m_item->mapper()->unsubscribe(this);
29 }
void unsubscribe(const void *caller)
Cancells all subscribtion of given caller.
Definition: ModelMapper.cpp:98
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.

References m_item, SessionItem::mapper(), and ModelMapper::unsubscribe().

Here is the call graph for this function:

Member Function Documentation

◆ aboutToBeDeleted

◆ addView()

void IView::addView ( IView childView,
int  row = 0 
)
virtual

◆ getItem()

◆ onChangedX

void IView::onChangedX ( )
virtualslot

Definition at line 55 of file IView.cpp.

56 {
57  if (!m_item)
58  return;
60 }
static const QString P_XPOS
void setItemValue(const QString &tag, const QVariant &variant)
Directly set value of item under given tag.

References m_item, SessionGraphicsItem::P_XPOS, and SessionItem::setItemValue().

Referenced by IView().

Here is the call graph for this function:

◆ onChangedY

void IView::onChangedY ( )
virtualslot

Definition at line 62 of file IView.cpp.

63 {
64  if (!m_item)
65  return;
67 }
static const QString P_YPOS

References m_item, SessionGraphicsItem::P_YPOS, and SessionItem::setItemValue().

Referenced by IView().

Here is the call graph for this function:

◆ onPropertyChange()

void IView::onPropertyChange ( const QString &  propertyName)
protectedvirtual

Reimplemented in ParticleView.

Definition at line 75 of file IView.cpp.

76 {
77  ASSERT(m_item);
78  if (propertyName == SessionGraphicsItem::P_XPOS) {
80  } else if (propertyName == SessionGraphicsItem::P_YPOS) {
82  }
83 }
#define ASSERT(condition)
Definition: Assert.h:31
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.

References ASSERT, SessionItem::getItemValue(), m_item, SessionGraphicsItem::P_XPOS, and SessionGraphicsItem::P_YPOS.

Referenced by ILayerView::onPropertyChange(), ParticleView::onPropertyChange(), and setParameterizedItem().

Here is the call graph for this function:

◆ onSiblingsChange()

void IView::onSiblingsChange ( )
protectedvirtual

Definition at line 85 of file IView.cpp.

86 {
88 }
virtual void update_appearance()
updates visual appearance of the item (color, icons, size etc)
Definition: IView.cpp:70

References update_appearance().

Referenced by setParameterizedItem().

Here is the call graph for this function:

◆ setParameterizedItem()

void IView::setParameterizedItem ( SessionItem item)
virtual

Definition at line 31 of file IView.cpp.

32 {
33  ASSERT(item);
34  ASSERT(m_item == nullptr);
35 
36  if (toolTip().isEmpty())
37  setToolTip(item->toolTip());
38 
39  m_item = item;
42 
43  m_item->mapper()->setOnPropertyChange([this](const QString& name) { onPropertyChange(name); },
44  this);
45 
46  m_item->mapper()->setOnSiblingsChange([this]() { onSiblingsChange(); }, this);
47 
48  m_item->mapper()->setOnItemDestroy([this](SessionItem*) { m_item = 0; }, this);
49 
51 }
virtual void onPropertyChange(const QString &propertyName)
Definition: IView.cpp:75
virtual void onSiblingsChange()
Definition: IView.cpp:85
void setOnItemDestroy(std::function< void(SessionItem *)> f, const void *caller=0)
Definition: ModelMapper.cpp:87
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=0)
Definition: ModelMapper.cpp:35
void setOnSiblingsChange(std::function< void(void)> f, const void *caller=0)
Definition: ModelMapper.cpp:73
QString toolTip() const
QString const & name(EShape k)
Definition: particles.cpp:21

References ASSERT, SessionItem::getItemValue(), m_item, SessionItem::mapper(), RealSpace::Particles::name(), onPropertyChange(), onSiblingsChange(), SessionGraphicsItem::P_XPOS, SessionGraphicsItem::P_YPOS, ModelMapper::setOnItemDestroy(), ModelMapper::setOnPropertyChange(), ModelMapper::setOnSiblingsChange(), SessionItem::toolTip(), and update_appearance().

Referenced by DesignerScene::addViewForItem().

Here is the call graph for this function:

◆ type()

int IView::type ( ) const
inline

Definition at line 54 of file IView.h.

55 {
56  return ViewTypes::IVIEW;
57 }

References ViewTypes::IVIEW.

Referenced by ParticleLayoutView::addView(), and ParticleView::addView().

◆ update_appearance()

void IView::update_appearance ( )
protectedvirtual

updates visual appearance of the item (color, icons, size etc)

Reimplemented in ParticleView, ILayerView, and ConnectableView.

Definition at line 70 of file IView.cpp.

71 {
72  update();
73 }

Referenced by onSiblingsChange(), setParameterizedItem(), and ConnectableView::update_appearance().

Member Data Documentation

◆ m_item


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