BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LayerView.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/SampleDesigner/LayerView.cpp
6 //! @brief Implements class LayerView
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
21 #include <QPainter>
22 #include <QStyleOptionGraphicsItem>
23 
24 LayerView::LayerView(QGraphicsItem* parent) : ILayerView(parent)
25 {
26  setColor(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
27  setName("Layer");
29  setAcceptDrops(false);
31 }
32 
33 void LayerView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
34 {
35  Q_UNUSED(widget);
36 
37  painter->setPen(Qt::black);
38  if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) {
39  painter->setPen(Qt::DashLine);
40  }
42  painter->drawRect(getRectangle());
43 }
44 
45 void LayerView::addView(IView* childView, int /* row */)
46 {
47  ParticleLayoutView* layout = dynamic_cast<ParticleLayoutView*>(childView);
48  ASSERT(layout);
49  connectInputPort(layout, 0);
50 }
#define ASSERT(condition)
Definition: Assert.h:31
Defines class DesignerHelper.
Defines class LayerItem.
Defines class LayerView.
Defines class MultiLayerView.
Defines class ParticleLayoutView.
void connectInputPort(ConnectableView *other, int port_number)
connects input port with given index with output port of other view
virtual void setColor(const QColor &color)
virtual void setRectangle(QRectF rect)
virtual QRectF getRectangle() const
virtual NodeEditorPort * addPort(const QString &name, NodeEditorPort::EPortDirection direction, NodeEditorPort::EPortType port_type)
adds port to view
virtual void setName(const QString &name)
static QRectF getDefaultBoundingRect(const QString &name)
returns default bounding rectangle for given IvView name
static QGradient getLayerGradient(const QColor &color, const QRectF &rect)
Base class for LayerView and MultiLayerView Provides functionality for moving view on top of MultiLay...
Definition: ILayerView.h:25
parent class for graphic representation of all ISampleNode's
Definition: IView.h:25
LayerView(QGraphicsItem *parent=0)
Definition: LayerView.cpp:24
virtual void addView(IView *childView, int row=0)
Definition: LayerView.cpp:45
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: LayerView.cpp:33
Defines class ToolTipDataBase.