tuchulcha  0.10.1
Graphical Workflow Configuration Editor
Node.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Jonathan Wuest
2 
3  This file is part of Tuchulcha.
4 
5  Tuchulcha is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Tuchulcha is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Tuchulcha. If not, see <http://www.gnu.org/licenses/>.
17 */
24 #ifndef NODE_H_
25 #define NODE_H_
26 
27 #include <QGraphicsItem>
28 #include <QRect>
29 #include <QGraphicsSceneWheelEvent>
30 #include <QGraphicsSceneMouseEvent>
31 #include <QVector>
32 #include <QMouseEvent>
33 #include "NodeProperty.h"
34 
36 class Node : public QGraphicsItem {
37 public:
39 
44  Node(const ParameterFileModel* pFile, QString title,
45  int xpos, int ypos);
46 
48  QRectF boundingRect() const;
49 
51  void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
52 
56  void addProperty(QString name, bool input);
57 
62  void addProperty(QString name,QString displayname, bool input);
63 
66  void setId(unsigned int id);
67 
69  void setActive(bool activeStatus);
70 
73  void setName(QString name);
74 
76  void paint(
77  QPainter* painter, const QStyleOptionGraphicsItem* option,
78  QWidget* widget = 0);
79 
81  int getWidth() const;
82 
84  int getHeight() const;
85 
87  NodeProperty* getProperty(QString propName) const;
88 
90  unsigned int getId() const;
91 
93  QString getInstanceName();
94 
97  void setClassName(QString modname);
98 
100  QString getClassName() const;
101 
104  void setSelectedNode(bool s);
105 
108  bool isSelectedNode();
109 
111  void changeConnectionLineColor(QColor lineColor);
112 
113 private:
115  void _checkWidth(int nChars=0);
116 
118  QMap<QString,NodeProperty*> _properties;
119 
121  QString _instanceName;
122 
124  QString _className;
125 
127  int _width;
128 
130  int _height;
131 
133  int _nProps;
134 
137 
139  bool _active;
140 
142  unsigned int _id;
143 
145  static unsigned int _idCount;
146 
149 };
150 
151 #endif /* NODE_H_ */
void setName(QString name)
resets the name of the node
Definition: Node.cpp:61
void setSelectedNode(bool s)
sets the node selected or not
Definition: Node.cpp:94
int getHeight() const
node height
Definition: Node.cpp:170
unsigned int _id
id of the node
Definition: Node.h:142
bool isSelectedNode()
state of node selections
Definition: Node.cpp:104
QGraphicsItem that contains nodeproperties and draws the node.
Definition: Node.h:36
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
paints the node
Definition: Node.cpp:137
void addProperty(QString name, bool input)
adds a property to the node
Definition: Node.cpp:70
void setClassName(QString modname)
set node class name
Definition: Node.cpp:183
void changeConnectionLineColor(QColor lineColor)
change color of connected line
Definition: Node.cpp:108
int _nProps
number of properties in node
Definition: Node.h:133
Declaration of class NodeProperty.
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
handles mouse move events
Definition: Node.cpp:117
QMap< QString, NodeProperty * > _properties
list of nodeproperties
Definition: Node.h:118
This model serves to provide a model frontend to access a ParameterFile instance. ...
QString getClassName() const
get class name
Definition: Node.cpp:188
NodeProperty * getProperty(QString propName) const
get node property
Definition: Node.cpp:179
int getWidth() const
node width
Definition: Node.cpp:166
static unsigned int _idCount
static id counter for id creation
Definition: Node.h:145
int _height
height of the node
Definition: Node.h:130
bool _selectedNode
state of node selection
Definition: Node.h:136
QRectF boundingRect() const
area where node is clickable
Definition: Node.cpp:88
unsigned int getId() const
get node id
Definition: Node.cpp:162
Property(/Parameter) of a node.
Definition: NodeProperty.h:35
void setActive(bool activeStatus)
changes the nodes activity
Definition: Node.cpp:57
QString getInstanceName()
get node name
Definition: Node.cpp:66
int _width
width of the node
Definition: Node.h:127
const ParameterFileModel * _pFile
link to parameter file
Definition: Node.h:148
QString _className
name of the module the node is representing
Definition: Node.h:124
void _checkWidth(int nChars=0)
checks the node width in reference to the node name
Definition: Node.cpp:174
QString _instanceName
name of the node
Definition: Node.h:121
void setId(unsigned int id)
sets the id of the node
Definition: Node.cpp:52
bool _active
state of activity
Definition: Node.h:139
Node(const ParameterFileModel *pFile, QString title, int xpos, int ypos)
default constructor
Definition: Node.cpp:35