BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
roughnesselementview.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/sldeditor/roughnesselementview.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 
18 #include <QPainter>
19 #include <QStyleOption>
20 
21 namespace gui2 {
22 
23 //! The constructor
25  : ElementView()
26  , m_left_path(QPainterPath())
27  , m_right_path(QPainterPath())
28  , m_brush(QBrush())
29  , m_pen(QPen())
30 {
31  setZValue(0);
32 }
33 
34 //! The overriden paint method
35 void RoughnessElementView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
36 {
37  painter->setClipRect(sceneAdapter()->viewportRectangle());
38  painter->setPen(m_pen);
39  painter->setBrush(m_brush);
40  painter->drawPath(displayPath(m_left_path));
41  painter->drawPath(displayPath(m_right_path));
42 }
43 
44 //! The shape
45 QPainterPath RoughnessElementView::shape() const
46 {
47  QPainterPath path;
48  path.addPath(displayPath(m_left_path));
49  path.addPath(displayPath(m_right_path));
50  return path;
51 }
52 
53 //! The bounding rectangle of the handle
55 {
56  QPainterPath path;
57  path.addPath(displayPath(m_left_path));
58  path.addPath(displayPath(m_right_path));
59  return path.boundingRect();
60 }
61 
62 //! Set the draw path for the left side
63 void RoughnessElementView::setLeftPath(QPainterPath left_path)
64 {
65  prepareGeometryChange();
66  m_left_path = left_path;
67 }
68 
69 //! Set the draw path for the right side
70 void RoughnessElementView::setRightPath(QPainterPath right_path)
71 {
72  prepareGeometryChange();
73  m_right_path = right_path;
74 }
75 
76 //! Set the brush
78 {
79  m_brush = brush;
80 }
81 
82 //! Set the pen
84 {
85  m_pen = pen;
86 }
87 
88 } // namespace gui2
The interface of any QGraphicsViewItem on GraphicsScene to the Sceneadapter.
Definition: elementview.h:26
QPainterPath displayPath(QPainterPath real_path) const
modify the path for display according to the scene adapter
ModelView::SceneAdapterInterface * sceneAdapter() const
Get the conversion axes.
Definition: elementview.cpp:34
void setRightPath(QPainterPath right_path)
Set the draw path for the right side.
QRectF boundingRect() const override
The bounding rectangle of the handle.
void setBrush(QBrush brush)
Set the brush.
QPainterPath shape() const override
The shape.
void setPen(QPen pen)
Set the pen.
RoughnessElementView()
The constructor.
void setLeftPath(QPainterPath left_path)
Set the draw path for the left side.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
The overriden paint method.
Defines class CLASS?
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Defines class CLASS?