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

This is a View of ellipse mask (represented by EllipseItem) on GraphicsScene. More...

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

Public Member Functions

 EllipseView ()
 
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)
 

Protected Member Functions

bool blockOnProperty () const
 
void create_size_handle_elements ()
 
qreal fromSceneX (qreal value) const
 convert scene coordinates to ColorMap plot coordinates More...
 
qreal fromSceneY (qreal value) const
 
qreal height () const
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 Track if item selected/deselected and show/hide size handles. More...
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
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
 
virtual void update_bounding_rect ()
 updates view's bounding rectangle using item properties More...
 
void update_view ()
 update visual appearance of view (triggered by ISceneAdaptor) More...
 
qreal width () const
 returns width of the rectangle More...
 

Protected Attributes

SizeHandleElementm_activeHandleElement
 
const ISceneAdaptorm_adaptor
 
bool m_block_on_property_change
 
QRectF m_bounding_rect
 
SessionItemm_item
 
QRectF m_mask_rect
 mask rectangle in scene coordinates More...
 
QMap< SizeHandleElement::EHandleLocation, SizeHandleElement * > m_resize_handles
 coordinates of corner opposite to the grip corner at the moment it first clicked in scene coordinates More...
 
QPointF m_resize_opposite_origin
 

Private Slots

void onSizeHandleElementRequest (bool going_to_resize)
 triggered by SizeHandleElement More...
 

Private Member Functions

qreal bottom () const
 Returns the y-coordinate of the rectangle's bottom edge. More...
 
qreal left () const
 returns the x-coordinate of the rectangle's left edge More...
 
QRectF mask_rectangle ()
 
void onItemPropertyChange (const QString &propertyName)
 
qreal right () const
 returns the x-coordinate of the rectangle's right edge More...
 
qreal top () const
 Returns the y-coordinate of the rectangle's top edge. More...
 
void update_position ()
 updates position of view using item properties More...
 

Detailed Description

This is a View of ellipse mask (represented by EllipseItem) on GraphicsScene.

Given view follows standard QGraphicsScene notations: (x,y) is top left corner.

Definition at line 23 of file EllipseView.h.

Constructor & Destructor Documentation

◆ EllipseView()

EllipseView::EllipseView ( )
default

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.

◆ bottom()

qreal EllipseView::bottom ( ) const
privatevirtual

Returns the y-coordinate of the rectangle's bottom edge.

Implements RectangleBaseView.

Definition at line 153 of file EllipseView.cpp.

154 {
156 }
static const QString P_YRADIUS
Definition: MaskItems.h:92
static const QString P_YCENTER
Definition: MaskItems.h:90
qreal toSceneY(const QString &property_name) const
double par(const QString &property_name) const

References EllipseItem::P_YCENTER, EllipseItem::P_YRADIUS, IShape2DView::par(), and IShape2DView::toSceneY().

Here is the call graph for this function:

◆ 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.

◆ create_size_handle_elements()

void RectangleBaseView::create_size_handle_elements ( )
protectedinherited

Definition at line 100 of file RectangleBaseView.cpp.

101 {
102  QList<SizeHandleElement::EHandleLocation> points;
107 
108  for (SizeHandleElement::EHandleLocation point_type : points) {
109  SizeHandleElement* el = new SizeHandleElement(point_type, this);
110  connect(el, &SizeHandleElement::resize_request, this,
112  el->setVisible(false);
113  m_resize_handles[point_type] = el;
114  }
115 }
void onSizeHandleElementRequest(bool going_to_resize)
triggered by SizeHandleElement
QMap< SizeHandleElement::EHandleLocation, SizeHandleElement * > m_resize_handles
coordinates of corner opposite to the grip corner at the moment it first clicked in scene coordinates
Size handle on top of RectangleView represented as small circle or small rectangle.
void resize_request(bool going_to_resize)

References SizeHandleElement::BOTTOMLEFT, SizeHandleElement::BOTTOMMIDLE, SizeHandleElement::BOTTOMRIGHT, RectangleBaseView::m_resize_handles, SizeHandleElement::MIDDLELEFT, SizeHandleElement::MIDDLERIGHT, RectangleBaseView::onSizeHandleElementRequest(), SizeHandleElement::resize_request(), SizeHandleElement::TOPLEFT, SizeHandleElement::TOPMIDDLE, and SizeHandleElement::TOPRIGHT.

Referenced by RectangleBaseView::RectangleBaseView().

Here is the call graph for this function:

◆ 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 mouseMoveEvent(), RectangleView::mouseMoveEvent(), onChangedX(), VerticalLineView::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 mouseMoveEvent(), RectangleView::mouseMoveEvent(), onChangedY(), HorizontalLineView::onChangedY(), RectangleView::onChangedY(), and PolygonPointView::updateParameterizedItem().

Here is the call graph for this function:

◆ height()

qreal RectangleBaseView::height ( ) const
protectedinherited

Definition at line 95 of file RectangleBaseView.cpp.

96 {
97  return bottom() - top();
98 }
virtual qreal top() const =0
virtual qreal bottom() const =0

References RectangleBaseView::bottom(), and RectangleBaseView::top().

Referenced by mask_rectangle(), RectangleView::mask_rectangle(), and mouseMoveEvent().

Here is the call graph for this function:

◆ itemChange()

QVariant RectangleBaseView::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
protectedinherited

Track if item selected/deselected and show/hide size handles.

Definition at line 48 of file RectangleBaseView.cpp.

50 {
51  if (change == QGraphicsItem::ItemSelectedChange) {
52  for (auto it = m_resize_handles.begin(); it != m_resize_handles.end(); ++it) {
53  it.value()->setVisible(!this->isSelected());
54  }
55  }
56  return value;
57 }

References RectangleBaseView::m_resize_handles.

◆ left()

qreal EllipseView::left ( ) const
privatevirtual

returns the x-coordinate of the rectangle's left edge

Implements RectangleBaseView.

Definition at line 132 of file EllipseView.cpp.

133 {
135 }
static const QString P_XRADIUS
Definition: MaskItems.h:91
static const QString P_XCENTER
Definition: MaskItems.h:89
qreal toSceneX(const QString &property_name) const

References EllipseItem::P_XCENTER, EllipseItem::P_XRADIUS, IShape2DView::par(), and IShape2DView::toSceneX().

Here is the call graph for this function:

◆ mask_rectangle()

QRectF EllipseView::mask_rectangle ( )
privatevirtual

Implements RectangleBaseView.

Definition at line 125 of file EllipseView.cpp.

126 {
127  return QRectF(-width() / 2., -height() / 2., width(), height());
128 }
qreal width() const
returns width of the rectangle

References RectangleBaseView::height(), and RectangleBaseView::width().

Here is the call graph for this function:

◆ mouseMoveEvent()

void EllipseView::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 58 of file EllipseView.cpp.

59 {
61  QPointF opposPos = mapFromScene(m_resize_opposite_origin);
62  qreal xmin = std::min(event->pos().x(), opposPos.x());
63  qreal xmax = std::max(event->pos().x(), opposPos.x());
64  qreal ymin = std::min(event->pos().y(), opposPos.y());
65  qreal ymax = std::max(event->pos().y(), opposPos.y());
66  qreal width = xmax - xmin;
67  qreal height = ymax - ymin;
68 
69  qreal xcenter = xmin + (xmax - xmin) / 2.;
70  qreal ycenter = ymin + (ymax - ymin) / 2.;
71 
72  QPointF center(xcenter, ycenter);
73  QPointF centerInScene = mapToScene(center);
74 
78 
80  (fromSceneX(centerInScene.x() + width / 2.)
81  - fromSceneX(centerInScene.x() - width / 2.))
82  / 2.);
84  (fromSceneY(centerInScene.y() - height / 2.)
85  - fromSceneY(centerInScene.y() + height / 2.))
86  / 2.);
87 
91  (fromSceneY(centerInScene.y() - height / 2.)
92  - fromSceneY(centerInScene.y() + height / 2.))
93  / 2.);
94 
98  (fromSceneX(centerInScene.x() + width / 2.)
99  - fromSceneX(centerInScene.x() - width / 2.))
100  / 2.);
101  }
102 
103  } else {
104  IShape2DView::mouseMoveEvent(event);
105  }
106 }
SessionItem * m_item
Definition: IShape2DView.h:65
qreal fromSceneY(qreal value) const
qreal fromSceneX(qreal value) const
convert scene coordinates to ColorMap plot coordinates
SizeHandleElement * m_activeHandleElement
QPointF m_resize_opposite_origin
void setItemValue(const QString &tag, const QVariant &variant)
Directly set value of item under given tag.
EHandleType getHandleType() const

References IShape2DView::fromSceneX(), IShape2DView::fromSceneY(), SizeHandleElement::getHandleType(), RectangleBaseView::height(), RectangleBaseView::m_activeHandleElement, IShape2DView::m_item, RectangleBaseView::m_resize_opposite_origin, EllipseItem::P_XCENTER, EllipseItem::P_XRADIUS, EllipseItem::P_YCENTER, EllipseItem::P_YRADIUS, SizeHandleElement::RESIZE, SizeHandleElement::RESIZE_HEIGHT, SizeHandleElement::RESIZE_WIDTH, SessionItem::setItemValue(), and RectangleBaseView::width().

Here is the call graph for this function:

◆ mouseReleaseEvent()

void RectangleBaseView::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
protectedinherited

Definition at line 59 of file RectangleBaseView.cpp.

60 {
62  IShape2DView::mouseReleaseEvent(event);
63 }

References RectangleBaseView::onSizeHandleElementRequest().

Here is the call graph for this function:

◆ onChangedX

void EllipseView::onChangedX ( )
protectedvirtualslot

Definition at line 22 of file EllipseView.cpp.

23 {
24  setBlockOnProperty(true);
26  setBlockOnProperty(false);
27 }
void setBlockOnProperty(bool value)

References IShape2DView::fromSceneX(), IShape2DView::m_item, EllipseItem::P_XCENTER, IShape2DView::setBlockOnProperty(), and SessionItem::setItemValue().

Referenced by update_position().

Here is the call graph for this function:

◆ onChangedY

void EllipseView::onChangedY ( )
protectedvirtualslot

Definition at line 29 of file EllipseView.cpp.

30 {
31  setBlockOnProperty(true);
33  setBlockOnProperty(false);
34 }

References IShape2DView::fromSceneY(), IShape2DView::m_item, EllipseItem::P_YCENTER, IShape2DView::setBlockOnProperty(), and SessionItem::setItemValue().

Referenced by update_position().

Here is the call graph for this function:

◆ 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 EllipseView::onPropertyChange ( const QString &  propertyName)
protectedvirtualslot

Definition at line 36 of file EllipseView.cpp.

37 {
38  if (propertyName == EllipseItem::P_XRADIUS || propertyName == EllipseItem::P_YRADIUS) {
39  update_view();
40  } else if (propertyName == EllipseItem::P_XCENTER) {
42  } else if (propertyName == EllipseItem::P_YCENTER) {
44  } else if (propertyName == EllipseItem::P_ANGLE) {
45  setTransform(QTransform().rotate(-1.0 * par(EllipseItem::P_ANGLE)));
46  }
47 }
static const QString P_ANGLE
Definition: MaskItems.h:93
void update_view()
update visual appearance of view (triggered by ISceneAdaptor)

References EllipseItem::P_ANGLE, EllipseItem::P_XCENTER, EllipseItem::P_XRADIUS, EllipseItem::P_YCENTER, EllipseItem::P_YRADIUS, IShape2DView::par(), IShape2DView::toSceneX(), IShape2DView::toSceneY(), and RectangleBaseView::update_view().

Here is the call graph for this function:

◆ onSizeHandleElementRequest

void RectangleBaseView::onSizeHandleElementRequest ( bool  going_to_resize)
privateslotinherited

triggered by SizeHandleElement

Definition at line 32 of file RectangleBaseView.cpp.

33 {
34  if (going_to_resize) {
35  setFlag(QGraphicsItem::ItemIsMovable, false);
36  m_activeHandleElement = qobject_cast<SizeHandleElement*>(sender());
38  SizeHandleElement::EHandleLocation oposite_corner =
40  m_resize_opposite_origin = m_resize_handles[oposite_corner]->scenePos();
41  } else {
42  setFlag(QGraphicsItem::ItemIsMovable, true);
44  }
45 }
#define ASSERT(condition)
Definition: Assert.h:31
EHandleLocation getOppositeHandleLocation() const

References ASSERT, SizeHandleElement::getOppositeHandleLocation(), RectangleBaseView::m_activeHandleElement, RectangleBaseView::m_resize_handles, and RectangleBaseView::m_resize_opposite_origin.

Referenced by RectangleBaseView::create_size_handle_elements(), and RectangleBaseView::mouseReleaseEvent().

Here is the call graph for this function:

◆ paint()

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

Definition at line 49 of file EllipseView.cpp.

50 {
51  painter->setRenderHints(QPainter::Antialiasing);
52  bool mask_value = m_item->getItemValue(MaskItem::P_MASK_VALUE).toBool();
53  painter->setBrush(MaskEditorHelper::getMaskBrush(mask_value));
54  painter->setPen(MaskEditorHelper::getMaskPen(mask_value));
55  painter->drawEllipse(m_mask_rect);
56 }
static QBrush getMaskBrush(bool mask_value)
static QPen getMaskPen(bool mask_value)
QRectF m_mask_rect
mask rectangle in scene coordinates
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.

References SessionItem::getItemValue(), MaskEditorHelper::getMaskBrush(), MaskEditorHelper::getMaskPen(), IShape2DView::m_item, RectangleBaseView::m_mask_rect, 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 bottom(), RectangleView::bottom(), left(), RectangleView::left(), onPropertyChange(), right(), RectangleView::right(), top(), RectangleView::top(), and 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().

◆ right()

qreal EllipseView::right ( ) const
privatevirtual

returns the x-coordinate of the rectangle's right edge

Implements RectangleBaseView.

Definition at line 139 of file EllipseView.cpp.

140 {
142 }

References EllipseItem::P_XCENTER, EllipseItem::P_XRADIUS, IShape2DView::par(), and IShape2DView::toSceneX().

Here is the call graph for this function:

◆ 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 }
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:

◆ top()

qreal EllipseView::top ( ) const
privatevirtual

Returns the y-coordinate of the rectangle's top edge.

Implements RectangleBaseView.

Definition at line 146 of file EllipseView.cpp.

147 {
149 }

References EllipseItem::P_YCENTER, EllipseItem::P_YRADIUS, IShape2DView::par(), and IShape2DView::toSceneY().

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 left(), RectangleView::left(), onPropertyChange(), VerticalLineView::onPropertyChange(), right(), RectangleView::right(), PolygonView::update_polygon(), update_position(), RectangleView::update_position(), and VerticalLineView::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 }

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

Referenced by bottom(), RectangleView::bottom(), onPropertyChange(), HorizontalLineView::onPropertyChange(), top(), RectangleView::top(), PolygonView::update_polygon(), 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 EllipseView::type ( ) const
inlinevirtual

Reimplemented from IShape2DView.

Definition at line 27 of file EllipseView.h.

References MaskEditorHelper::ELLIPSE.

◆ update_bounding_rect()

void RectangleBaseView::update_bounding_rect ( )
protectedvirtualinherited

updates view's bounding rectangle using item properties

Definition at line 74 of file RectangleBaseView.cpp.

75 {
76  if (m_item) {
78  m_bounding_rect = m_mask_rect.marginsAdded(
79  QMarginsF(bbox_margins, bbox_margins, bbox_margins, bbox_margins));
80  }
81  for (QMap<SizeHandleElement::EHandleLocation, SizeHandleElement*>::iterator it =
82  m_resize_handles.begin();
83  it != m_resize_handles.end(); ++it) {
84  it.value()->updateHandleElementPosition(m_mask_rect);
85  }
86 }
virtual QRectF mask_rectangle()=0

References IShape2DView::m_bounding_rect, IShape2DView::m_item, RectangleBaseView::m_mask_rect, RectangleBaseView::m_resize_handles, and RectangleBaseView::mask_rectangle().

Referenced by RectangleBaseView::update_view().

Here is the call graph for this function:

◆ update_position()

void EllipseView::update_position ( )
privatevirtual

updates position of view using item properties

Implements RectangleBaseView.

Definition at line 110 of file EllipseView.cpp.

111 {
112  disconnect(this, &EllipseView::xChanged, this, &EllipseView::onChangedX);
113  disconnect(this, &EllipseView::yChanged, this, &EllipseView::onChangedY);
114 
117 
118  connect(this, &EllipseView::xChanged, this, &EllipseView::onChangedX);
119  connect(this, &EllipseView::yChanged, this, &EllipseView::onChangedY);
120 
121  if (par(EllipseItem::P_ANGLE) != 0.0)
122  setTransform(QTransform().rotate(-1.0 * par(EllipseItem::P_ANGLE)));
123 }
virtual void onChangedY()
Definition: EllipseView.cpp:29
virtual void onChangedX()
Definition: EllipseView.cpp:22

References onChangedX(), onChangedY(), EllipseItem::P_ANGLE, EllipseItem::P_XCENTER, EllipseItem::P_YCENTER, IShape2DView::par(), IShape2DView::toSceneX(), and IShape2DView::toSceneY().

Here is the call graph for this function:

◆ update_view()

void RectangleBaseView::update_view ( )
protectedvirtualinherited

update visual appearance of view (triggered by ISceneAdaptor)

Implements IShape2DView.

Definition at line 65 of file RectangleBaseView.cpp.

66 {
67  prepareGeometryChange();
70 }
virtual void update_position()=0
virtual void update_bounding_rect()
updates view's bounding rectangle using item properties

References RectangleBaseView::update_bounding_rect(), and RectangleBaseView::update_position().

Referenced by RectangleView::mouseMoveEvent(), onPropertyChange(), and RectangleView::onPropertyChange().

Here is the call graph for this function:

◆ width()

qreal RectangleBaseView::width ( ) const
protectedinherited

returns width of the rectangle

Definition at line 90 of file RectangleBaseView.cpp.

91 {
92  return right() - left();
93 }
virtual qreal right() const =0
virtual qreal left() const =0

References RectangleBaseView::left(), and RectangleBaseView::right().

Referenced by mask_rectangle(), RectangleView::mask_rectangle(), and mouseMoveEvent().

Here is the call graph for this function:

Member Data Documentation

◆ m_activeHandleElement

SizeHandleElement* RectangleBaseView::m_activeHandleElement
protectedinherited

◆ m_adaptor

◆ m_block_on_property_change

bool IShape2DView::m_block_on_property_change
protectedinherited

◆ m_bounding_rect

◆ m_item

◆ m_mask_rect

QRectF RectangleBaseView::m_mask_rect
protectedinherited

◆ m_resize_handles

QMap<SizeHandleElement::EHandleLocation, SizeHandleElement*> RectangleBaseView::m_resize_handles
protectedinherited

coordinates of corner opposite to the grip corner at the moment it first clicked in scene coordinates

Definition at line 53 of file RectangleBaseView.h.

Referenced by RectangleBaseView::create_size_handle_elements(), RectangleBaseView::itemChange(), RectangleBaseView::onSizeHandleElementRequest(), and RectangleBaseView::update_bounding_rect().

◆ m_resize_opposite_origin

QPointF RectangleBaseView::m_resize_opposite_origin
protectedinherited

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