BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayerView.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/SampleDesigner/MultiLayerView.h
6 //! @brief Defines class MultiLayerView
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 
15 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_MULTILAYERVIEW_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_MULTILAYERVIEW_H
17 
19 
20 class DesignerMimeData;
21 class QGraphicsSceneDragDropEvent;
22 
23 //! Class representing view of MultiLayer.
24 //! Handles drop of other MultiLayer and Layer views on top of it
25 class MultiLayerView : public ILayerView {
26  Q_OBJECT
27 
28 public:
29  MultiLayerView(QGraphicsItem* parent = 0);
31 
32  int type() const override { return ViewTypes::MULTILAYER; }
33 
34  QRectF boundingRect() const override;
35 
36  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
37 
38  void addView(IView* childView, int row = 0) override;
39 
40  virtual void addNewLayer(ILayerView* layer, int row);
41  virtual void removeLayer(ILayerView* layer);
42 
43  int getDropArea(QPointF pos);
44  QRectF getDropAreaRectangle(int row);
45  QLineF getInterfaceLine(int row);
46 
47 public slots:
48  void updateGeometry();
49  void updateHeight();
50  void updateWidth();
52 
53 protected:
54  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
55  void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
56  const DesignerMimeData* checkDragEvent(QGraphicsSceneDragDropEvent* event);
57  QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
58 
59 private:
60  QList<ILayerView*> m_layers;
61  QList<QRectF> m_drop_areas;
62  QList<QLineF> m_interfaces;
63 };
64 
65 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_MULTILAYERVIEW_H
Defines interface ILayerView.
Mime data for use with SampleDesigner drag and drop operations.
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
Class representing view of MultiLayer.
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
void onLayerAboutToBeDeleted()
virtual void removeLayer(ILayerView *layer)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void updateGeometry()
Updates geometry of MultiLayerView from current childs geometries.
void addView(IView *childView, int row=0) override
int getDropArea(QPointF pos)
Returns index of drop area for given coordinate.
QRectF boundingRect() const override
const DesignerMimeData * checkDragEvent(QGraphicsSceneDragDropEvent *event)
int type() const override
void dropEvent(QGraphicsSceneDragDropEvent *event) override
void updateWidth()
Updates MultiLayerView width, sets x-positions of children.
QList< QLineF > m_interfaces
void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override
QList< QRectF > m_drop_areas
QList< ILayerView * > m_layers
MultiLayerView(QGraphicsItem *parent=0)
virtual void addNewLayer(ILayerView *layer, int row)
QRectF getDropAreaRectangle(int row)
Returns drop area rectangle corresponding to given row.
QLineF getInterfaceLine(int row)
Returns line representing interface.
void updateHeight()
Updates MultiLayer height, sets y-positions of children, defines new drop areas.
@ MULTILAYER
Definition: ViewTypes.h:29