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

This is a view of VerticalLineItem mask. More...

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

Public Member Functions

 VerticalLineView ()
 
virtual void addView (IShape2DView *childView, int row=0)
 
QRectF boundingRect () const
 
virtual SessionItemparameterizedItem ()
 
virtual void setParameterizedItem (SessionItem *item)
 
void setSceneAdaptor (const ISceneAdaptor *adaptor)
 
int type () const
 

Protected Slots

virtual void onChangedX ()
 
virtual void onChangedY ()
 
virtual void onPropertyChange (const QString &propertyName)
 
virtual void update_view ()
 

Protected Member Functions

bool blockOnProperty () const
 
qreal fromSceneX (qreal value) const
 convert scene coordinates to ColorMap plot coordinates More...
 
qreal fromSceneY (qreal value) const
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 Allows item movement along x, prevent movement along y. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
 
double par (const QString &property_name) const
 
void setBlockOnProperty (bool value)
 
qreal toSceneX (const QString &property_name) const
 
qreal toSceneX (qreal value) const
 
qreal toSceneY (const QString &property_name) const
 
qreal toSceneY (qreal value) const
 

Protected Attributes

const ISceneAdaptorm_adaptor
 
bool m_block_on_property_change
 
QRectF m_bounding_rect
 
SessionItemm_item
 

Private Member Functions

void onItemPropertyChange (const QString &propertyName)
 

Detailed Description

This is a view of VerticalLineItem mask.

Definition at line 22 of file LineViews.h.

Constructor & Destructor Documentation

◆ VerticalLineView()

VerticalLineView::VerticalLineView ( )

Definition at line 27 of file LineViews.cpp.

28 {
29  setFlag(QGraphicsItem::ItemIsSelectable);
30  setFlag(QGraphicsItem::ItemIsMovable);
31  setFlag(QGraphicsItem::ItemSendsGeometryChanges);
32  setCursor(Qt::SizeHorCursor);
33 }

Member Function Documentation

◆ addView()

void IShape2DView::addView ( IShape2DView childView,
int  row = 0 
)
virtualinherited

Reimplemented in PolygonView.

Definition at line 116 of file IShape2DView.cpp.

117 {
118  if (!childItems().contains(childView))
119  childView->setParentItem(this);
120 }

Referenced by MaskGraphicsScene::updateViews().

◆ blockOnProperty()

bool IShape2DView::blockOnProperty ( ) const
protectedinherited

Definition at line 127 of file IShape2DView.cpp.

128 {
130 }
bool m_block_on_property_change
Definition: IShape2DView.h:68

References IShape2DView::m_block_on_property_change.

◆ boundingRect()

QRectF IShape2DView::boundingRect ( ) const
inherited

Definition at line 36 of file IShape2DView.cpp.

37 {
38  return m_bounding_rect;
39 }
QRectF m_bounding_rect
Definition: IShape2DView.h:67

References IShape2DView::m_bounding_rect.

◆ fromSceneX()

qreal IShape2DView::fromSceneX ( qreal  value) const
protectedinherited

convert scene coordinates to ColorMap plot coordinates

Definition at line 106 of file IShape2DView.cpp.

107 {
108  return m_adaptor ? m_adaptor->fromSceneX(value) : value;
109 }
virtual qreal fromSceneX(qreal) const =0
convert scene x-coordinate to native mask coordinate
const ISceneAdaptor * m_adaptor
Definition: IShape2DView.h:66

References ISceneAdaptor::fromSceneX(), and IShape2DView::m_adaptor.

Referenced by EllipseView::mouseMoveEvent(), RectangleView::mouseMoveEvent(), EllipseView::onChangedX(), onChangedX(), RectangleView::onChangedX(), and PolygonPointView::updateParameterizedItem().

Here is the call graph for this function:

◆ fromSceneY()

qreal IShape2DView::fromSceneY ( qreal  value) const
protectedinherited

Definition at line 111 of file IShape2DView.cpp.

112 {
113  return m_adaptor ? m_adaptor->fromSceneY(value) : value;
114 }
virtual qreal fromSceneY(qreal) const =0
convert scene y-coordinate to native mask coordinate

References ISceneAdaptor::fromSceneY(), and IShape2DView::m_adaptor.

Referenced by EllipseView::mouseMoveEvent(), RectangleView::mouseMoveEvent(), EllipseView::onChangedY(), HorizontalLineView::onChangedY(), RectangleView::onChangedY(), and PolygonPointView::updateParameterizedItem().

Here is the call graph for this function:

◆ itemChange()

QVariant VerticalLineView::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
protected

Allows item movement along x, prevent movement along y.

Definition at line 78 of file LineViews.cpp.

80 {
81  if (isSelected() && change == ItemPositionChange && scene()) {
82  QPointF newPos = value.toPointF();
83  newPos.setY(y());
84  return newPos;
85  }
86  return QGraphicsItem::itemChange(change, value);
87 }

◆ onChangedX

void VerticalLineView::onChangedX ( )
protectedvirtualslot

Definition at line 35 of file LineViews.cpp.

36 {
37  setBlockOnProperty(true);
39  setBlockOnProperty(false);
40 }
SessionItem * m_item
Definition: IShape2DView.h:65
void setBlockOnProperty(bool value)
qreal fromSceneX(qreal value) const
convert scene coordinates to ColorMap plot coordinates
void setItemValue(const QString &tag, const QVariant &variant)
Directly set value of item under given tag.
static const QString P_POSX
Definition: MaskItems.h:73

References IShape2DView::fromSceneX(), IShape2DView::m_item, VerticalLineItem::P_POSX, IShape2DView::setBlockOnProperty(), and SessionItem::setItemValue().

Here is the call graph for this function:

◆ onChangedY

virtual void IShape2DView::onChangedY ( )
inlineprotectedvirtualslotinherited

Definition at line 49 of file IShape2DView.h.

49 {}

Referenced by IShape2DView::IShape2DView().

◆ onItemPropertyChange()

void IShape2DView::onItemPropertyChange ( const QString &  propertyName)
privateinherited

Definition at line 132 of file IShape2DView.cpp.

133 {
135  return;
136 
138 
139  bool schedule_update = false;
140  if (propertyName == MaskItem::P_MASK_VALUE) {
141  schedule_update = true;
142  } else if (propertyName == MaskItem::P_IS_VISIBLE) {
143  this->setVisible(parameterizedItem()->getItemValue(MaskItem::P_IS_VISIBLE).toBool());
144  schedule_update = true;
145  }
146 
147  onPropertyChange(propertyName);
148 
149  if (schedule_update)
150  update();
151 
153 }
virtual void onPropertyChange(const QString &)
Definition: IShape2DView.h:50
virtual SessionItem * parameterizedItem()
static const QString P_IS_VISIBLE
Definition: MaskItems.h:34
static const QString P_MASK_VALUE
Definition: MaskItems.h:33

References IShape2DView::m_block_on_property_change, IShape2DView::onPropertyChange(), MaskItem::P_IS_VISIBLE, MaskItem::P_MASK_VALUE, and IShape2DView::parameterizedItem().

Referenced by IShape2DView::setParameterizedItem().

Here is the call graph for this function:

◆ onPropertyChange

void VerticalLineView::onPropertyChange ( const QString &  propertyName)
protectedvirtualslot

Definition at line 42 of file LineViews.cpp.

43 {
44  if (propertyName == VerticalLineItem::P_POSX)
46 }
qreal toSceneX(const QString &property_name) const

References VerticalLineItem::P_POSX, and IShape2DView::toSceneX().

Here is the call graph for this function:

◆ paint()

void VerticalLineView::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  ,
QWidget *   
)
protected

Definition at line 59 of file LineViews.cpp.

60 {
61  bool mask_value = m_item->getItemValue(MaskItem::P_MASK_VALUE).toBool();
62  painter->setBrush(MaskEditorHelper::getMaskBrush(mask_value));
63  painter->setPen(MaskEditorHelper::getMaskPen(mask_value));
64  painter->drawRect(
65  QRectF(-mask_visible_width / 2., 0.0, mask_visible_width, m_bounding_rect.height()));
66 
67  if (isSelected()) {
68  QPen pen;
69  pen.setStyle(Qt::DashLine);
70  painter->setPen(pen);
71  painter->setBrush(Qt::NoBrush);
72  painter->drawRect(
73  QRectF(-mask_visible_width / 2., 0.0, mask_visible_width, m_bounding_rect.height()));
74  }
75 }
static QBrush getMaskBrush(bool mask_value)
static QPen getMaskPen(bool mask_value)
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.

References SessionItem::getItemValue(), MaskEditorHelper::getMaskBrush(), MaskEditorHelper::getMaskPen(), IShape2DView::m_bounding_rect, IShape2DView::m_item, and MaskItem::P_MASK_VALUE.

Here is the call graph for this function:

◆ par()

double IShape2DView::par ( const QString &  property_name) const
protectedinherited

Definition at line 81 of file IShape2DView.cpp.

82 {
83  return m_item->getItemValue(property_name).toReal();
84 }

References SessionItem::getItemValue(), and IShape2DView::m_item.

Referenced by EllipseView::bottom(), RectangleView::bottom(), EllipseView::left(), RectangleView::left(), EllipseView::onPropertyChange(), EllipseView::right(), RectangleView::right(), EllipseView::top(), RectangleView::top(), and EllipseView::update_position().

Here is the call graph for this function:

◆ parameterizedItem()

SessionItem * IShape2DView::parameterizedItem ( )
virtualinherited

Definition at line 61 of file IShape2DView.cpp.

62 {
63  return m_item;
64 }

References IShape2DView::m_item.

Referenced by IShape2DView::onItemPropertyChange().

◆ setBlockOnProperty()

void IShape2DView::setBlockOnProperty ( bool  value)
protectedinherited

◆ setParameterizedItem()

void IShape2DView::setParameterizedItem ( SessionItem item)
virtualinherited

Definition at line 41 of file IShape2DView.cpp.

42 {
43  if (m_item == item) {
44  return;
45 
46  } else {
47  if (m_item)
48  m_item->mapper()->unsubscribe(this);
49 
50  m_item = item;
51  if (!m_item)
52  return;
53 
55  [this](const QString& name) { onItemPropertyChange(name); }, this);
56 
57  m_item->mapper()->setOnItemDestroy([this](SessionItem*) { m_item = 0; }, this);
58  }
59 }
void onItemPropertyChange(const QString &propertyName)
void unsubscribe(const void *caller)
Cancells all subscribtion of given caller.
Definition: ModelMapper.cpp:98
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
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
QString const & name(EShape k)
Definition: particles.cpp:21

References IShape2DView::m_item, SessionItem::mapper(), RealSpace::Particles::name(), IShape2DView::onItemPropertyChange(), ModelMapper::setOnItemDestroy(), ModelMapper::setOnPropertyChange(), and ModelMapper::unsubscribe().

Referenced by MaskViewFactory::createMaskView().

Here is the call graph for this function:

◆ setSceneAdaptor()

void IShape2DView::setSceneAdaptor ( const ISceneAdaptor adaptor)
inherited

Definition at line 66 of file IShape2DView.cpp.

67 {
68  ASSERT(adaptor);
69 
70  if (m_adaptor != adaptor) {
71  if (m_adaptor)
73 
74  m_adaptor = adaptor;
76  Qt::UniqueConnection);
77  update_view();
78  }
79 }
#define ASSERT(condition)
Definition: Assert.h:31
void update_request()
virtual void update_view()=0
update visual appearance of view (triggered by ISceneAdaptor)

References ASSERT, IShape2DView::m_adaptor, ISceneAdaptor::update_request(), and IShape2DView::update_view().

Referenced by MaskViewFactory::createMaskView().

Here is the call graph for this function:

◆ toSceneX() [1/2]

qreal IShape2DView::toSceneX ( const QString &  property_name) const
protectedinherited

Definition at line 86 of file IShape2DView.cpp.

87 {
88  return toSceneX(m_item->getItemValue(property_name).toReal());
89 }

References SessionItem::getItemValue(), and IShape2DView::m_item.

Referenced by EllipseView::left(), RectangleView::left(), EllipseView::onPropertyChange(), onPropertyChange(), EllipseView::right(), RectangleView::right(), PolygonView::update_polygon(), EllipseView::update_position(), RectangleView::update_position(), and update_view().

Here is the call graph for this function:

◆ toSceneX() [2/2]

qreal IShape2DView::toSceneX ( qreal  value) const
protectedinherited

Definition at line 91 of file IShape2DView.cpp.

92 {
93  return m_adaptor ? m_adaptor->toSceneX(value) : value;
94 }
virtual qreal toSceneX(qreal) const =0
convert native mask x-coordinate to scene coordinate

References IShape2DView::m_adaptor, and ISceneAdaptor::toSceneX().

Here is the call graph for this function:

◆ toSceneY() [1/2]

qreal IShape2DView::toSceneY ( const QString &  property_name) const
protectedinherited

Definition at line 96 of file IShape2DView.cpp.

97 {
98  return toSceneY(m_item->getItemValue(property_name).toReal());
99 }
qreal toSceneY(const QString &property_name) const

References SessionItem::getItemValue(), and IShape2DView::m_item.

Referenced by EllipseView::bottom(), RectangleView::bottom(), EllipseView::onPropertyChange(), HorizontalLineView::onPropertyChange(), EllipseView::top(), RectangleView::top(), PolygonView::update_polygon(), EllipseView::update_position(), RectangleView::update_position(), and HorizontalLineView::update_view().

Here is the call graph for this function:

◆ toSceneY() [2/2]

qreal IShape2DView::toSceneY ( qreal  value) const
protectedinherited

Definition at line 101 of file IShape2DView.cpp.

102 {
103  return m_adaptor ? m_adaptor->toSceneY(value) : value;
104 }
virtual qreal toSceneY(qreal) const =0
convert native mask y-coordinate to scene coordinate

References IShape2DView::m_adaptor, and ISceneAdaptor::toSceneY().

Here is the call graph for this function:

◆ type()

int VerticalLineView::type ( ) const
inlinevirtual

Reimplemented from IShape2DView.

Definition at line 26 of file LineViews.h.

References MaskEditorHelper::VERTICALLINE.

◆ update_view

void VerticalLineView::update_view ( )
protectedvirtualslot

Definition at line 48 of file LineViews.cpp.

49 {
50  QRectF plot_scene_rectangle = m_adaptor->viewportRectangle();
51 
53  setY(plot_scene_rectangle.top());
54 
55  m_bounding_rect = QRectF(-mask_width / 2., 0.0, mask_width, plot_scene_rectangle.height());
56  update();
57 }
virtual const QRectF & viewportRectangle() const
returns viewport rectangle in scene coordinates
Definition: ISceneAdaptor.h:39

References IShape2DView::m_adaptor, IShape2DView::m_bounding_rect, VerticalLineItem::P_POSX, IShape2DView::toSceneX(), and ISceneAdaptor::viewportRectangle().

Here is the call graph for this function:

Member Data Documentation

◆ m_adaptor

◆ m_block_on_property_change

bool IShape2DView::m_block_on_property_change
protectedinherited

◆ m_bounding_rect

◆ m_item


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