BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
NodeEditorConnection.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/NodeEditorConnection.h
6 //! @brief Defines class NodeEditorConnection
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_NODEEDITORCONNECTION_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_NODEEDITORCONNECTION_H
17 
18 /*
19  * Node editor: original code is taken from
20  * http://algoholic.eu/qnodeseditor-qt-nodesports-based-data-processing-flow-editor/
21  * Copyright (c) 2012, STANISLAW ADASZEWSKI
22  */
23 
25 #include <QGraphicsPathItem>
26 
27 class NodeEditorPort;
28 class ConnectableView;
29 
30 class NodeEditorConnection : public QGraphicsPathItem {
31 public:
32  NodeEditorConnection(QGraphicsItem* parent = 0, QGraphicsScene* scene = 0);
33  virtual ~NodeEditorConnection();
34 
35  void setPos1(const QPointF& p);
36  void setPos2(const QPointF& p);
37  void setPort1(NodeEditorPort* p);
38  void setPort2(NodeEditorPort* p);
39  void updatePosFromPorts();
40  void updatePath();
41 
42  NodeEditorPort* port1() const;
43  NodeEditorPort* port2() const;
44 
47 
48  int type() const { return ViewTypes::NODE_EDITOR_CONNECTION; }
49 
50  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
51 
52  //! returns parent view, i.e. the view which owns input port of given connection
54 
55  //! returns child view, i.e. the view which owns output port of given connection
57 
58 private:
59  QPointF pos1;
60  QPointF pos2;
63 };
64 
65 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_NODEEDITORCONNECTION_H
Defines namespace ViewTypes with enum EWidgetTypes (nothing to implement)
view of ISampleNode's with rectangular shape and node functionality
void setPort2(NodeEditorPort *p)
ConnectableView * getChildView()
returns child view, i.e. the view which owns output port of given connection
NodeEditorPort * m_port2
NodeEditorPort * inputPort()
NodeEditorPort * m_port1
NodeEditorPort * port2() const
NodeEditorPort * outputPort()
void setPos1(const QPointF &p)
void setPort1(NodeEditorPort *p)
ConnectableView * getParentView()
returns parent view, i.e. the view which owns input port of given connection
NodeEditorConnection(QGraphicsItem *parent=0, QGraphicsScene *scene=0)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void setPos2(const QPointF &p)
NodeEditorPort * port1() const
@ NODE_EDITOR_CONNECTION
Definition: ViewTypes.h:28