BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
NodeEditorPort.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/NodeEditorPort.h
6 //! @brief Defines class NodeEditorPort
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_NODEEDITORPORT_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_NODEEDITORPORT_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 #include <QString>
27 
29 class IView;
30 
31 class NodeEditorPort : public QGraphicsPathItem {
32 public:
33  //! type of ports, same type can be connected together
35 
36  //! port direction
38 
39  NodeEditorPort(QGraphicsItem* parent = 0, const QString& name = "unnamed",
40  EPortDirection direction = INPUT, EPortType port_type = DEFAULT);
41 
42  virtual ~NodeEditorPort();
43 
44  bool isOutput();
45  bool isInput();
46 
47  void remove(NodeEditorConnection* connection);
48  void append(NodeEditorConnection* connection);
49 
50  const QString& portName() const;
51 
52  virtual int type() const;
53 
55 
56  bool isConnected();
57 
58  EPortType getPortType() const;
59 
60  static QColor getPortTypeColor(NodeEditorPort::EPortType port_type);
61 
62  void setLabel(QString name);
63 
64 protected:
65  QVariant itemChange(GraphicsItemChange change, const QVariant& value);
66 
67 private:
68  QString m_name;
71  QColor m_color;
72  int m_radius;
73  int m_margin;
74  QVector<NodeEditorConnection*> m_connections;
75  QGraphicsTextItem* m_label;
76 };
77 
78 inline const QString& NodeEditorPort::portName() const
79 {
80  return m_name;
81 }
82 
83 inline int NodeEditorPort::type() const
84 {
86 }
87 
89 {
90  return m_connections.size();
91 }
92 
94 {
95  return m_port_type;
96 }
97 
98 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_NODEEDITORPORT_H
Defines namespace ViewTypes with enum EWidgetTypes (nothing to implement)
parent class for graphic representation of all ISampleNode's
Definition: IView.h:25
void append(NodeEditorConnection *connection)
virtual ~NodeEditorPort()
NodeEditorPort(QGraphicsItem *parent=0, const QString &name="unnamed", EPortDirection direction=INPUT, EPortType port_type=DEFAULT)
void remove(NodeEditorConnection *connection)
EPortType
type of ports, same type can be connected together
EPortType m_port_type
QVector< NodeEditorConnection * > m_connections
EPortDirection m_direction
static QColor getPortTypeColor(NodeEditorPort::EPortType port_type)
const QString & portName() const
virtual int type() const
EPortDirection
port direction
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
void setLabel(QString name)
QGraphicsTextItem * m_label
EPortType getPortType() const
QString const & name(EShape k)
Definition: particles.cpp:21
@ NODE_EDITOR_PORT
Definition: ViewTypes.h:27