BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ILayerView.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/ILayerView.h
6 //! @brief Defines interface ILayerView
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_ILAYERVIEW_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_ILAYERVIEW_H
17 
19 
20 class MultiLayerView;
22 
23 //! Base class for LayerView and MultiLayerView
24 //! Provides functionality for moving view on top of MultiLayer.
25 class ILayerView : public ConnectableView {
26  Q_OBJECT
27 
28 public:
29  ILayerView(QGraphicsItem* parent = 0);
30 
31  int type() const { return ViewTypes::LAYER; }
32 
33  virtual QString getLabel() const { return ""; }
34 
35  void updateLabel();
36 
37 protected:
38  QVariant itemChange(GraphicsItemChange change, const QVariant& value);
39  void mousePressEvent(QGraphicsSceneMouseEvent* event);
40  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
41  void update_appearance();
42 
43 public slots:
44  void onPropertyChange(const QString& propertyName);
45 
46 private:
47  void updateHeight();
48  void updateColor();
49 
52 };
53 
54 //! Class to hold MultiLayer candidate for dropping LayerView.
56 public:
58  MultiLayerView* multilayer; //!< pointer to the candidate
59  int row; //!< requested row number to drop in
60  int distance; //!< distance from given ILayerView and drop area
61  bool operator<(const MultiLayerCandidate& cmp) const;
62  operator bool() const { return bool(multilayer); }
63  //! returns line representing interface of multilayer in scene coordinates
64  QLineF getInterfaceToScene();
65 };
66 
67 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_ILAYERVIEW_H
Defines class ConnectableView.
view of ISampleNode's with rectangular shape and node functionality
Base class for LayerView and MultiLayerView Provides functionality for moving view on top of MultiLay...
Definition: ILayerView.h:25
int type() const
Definition: ILayerView.h:31
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Detects movement of the ILayerView and sends possible drop areas to GraphicsScene for visualization.
Definition: ILayerView.cpp:122
ILayerView(QGraphicsItem *parent=0)
Definition: ILayerView.cpp:43
void updateColor()
Definition: ILayerView.cpp:74
QPointF m_drag_start_position
Definition: ILayerView.h:51
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Detects possible MultiLayerView's to drop given ILayerView and propagate request to SessionModel.
Definition: ILayerView.cpp:145
void updateLabel()
Definition: ILayerView.cpp:88
MultiLayerCandidate getMultiLayerCandidate()
Finds candidate (another MultiLayer) into which we will move our ILayerView.
Definition: ILayerView.cpp:222
virtual QString getLabel() const
Definition: ILayerView.h:33
void update_appearance()
updates visual appearance of the item (color, icons, size etc)
Definition: ILayerView.cpp:208
void onPropertyChange(const QString &propertyName)
Propagates change of 'Thickness' dynamic property to screen thickness of ILayerView.
Definition: ILayerView.cpp:51
void updateHeight()
Definition: ILayerView.cpp:63
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: ILayerView.cpp:135
Class to hold MultiLayer candidate for dropping LayerView.
Definition: ILayerView.h:55
bool operator<(const MultiLayerCandidate &cmp) const
Definition: ILayerView.cpp:38
QLineF getInterfaceToScene()
returns line representing interface of multilayer in scene coordinates
Definition: ILayerView.cpp:24
int row
requested row number to drop in
Definition: ILayerView.h:59
MultiLayerView * multilayer
pointer to the candidate
Definition: ILayerView.h:58
int distance
distance from given ILayerView and drop area
Definition: ILayerView.h:60
Class representing view of MultiLayer.