tuchulcha  0.10.1
Graphical Workflow Configuration Editor
NodeProperty.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 NODEPROPERTY_H_
25 #define NODEPROPERTY_H_
26 
27 #include <QGraphicsItem>
28 #include <QList>
29 
30 class ConnectionLine;
31 class Node;
32 class ParameterFileModel;
33 
35 class NodeProperty : public QGraphicsItem {
36 public:
38 
46  Node* parentNode, QString name,
47  int propNr, bool input,
48  const ParameterFileModel* pFile);
50 
59  Node* parentNode, QString name,QString displayname,
60  int propNr, bool input,
61  const ParameterFileModel* pFile);
62 
64  virtual QRectF boundingRect() const;
65 
69  void moveBy(qreal dx,qreal dy);
70 
73  void addConnection(ConnectionLine *cl);
74 
77  bool isInput() const;
78 
80  QString getFullName() const;
81 
83  QString getType() const;
84 
88  bool canConnect(NodeProperty* prop);
89 
91  QPointF getSocketCenter() const;
92 
94  void paint(
95  QPainter* painter,
96  const QStyleOptionGraphicsItem* option,
97  QWidget* widget = 0);
98 
101  void changeConnectionLineColor(QColor lineColor, bool isHover=true);
102 
104  void setColor(QColor socketColor);
105 
106 protected:
108  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
109 
111  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
112 
113 private:
115  unsigned int _propNr;
116 
118  QString _name;
119 
121  QString _displayname;
122 
124  QList<ConnectionLine *> _connectionList;
125 
127  bool _isInput;
128 
131 
134 
136  QRectF _getSocketRect() const;
137 
139  static QColor _getSocketColor(QString typeName);
140 
142  QColor _color;
143 };
144 
145 #endif /* NODEPROPERTY_H_ */
QString _name
name of the property
Definition: NodeProperty.h:118
QString _displayname
name of the property
Definition: NodeProperty.h:121
QGraphicsItem that contains nodeproperties and draws the node.
Definition: Node.h:36
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
update tool tip
bool _isInput
pointer to PropType of the property
Definition: NodeProperty.h:127
bool canConnect(NodeProperty *prop)
checks if connection is possible
QPointF getSocketCenter() const
socket center including node position
void addConnection(ConnectionLine *cl)
add a connectionline to the property
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
draws the property
bool isInput() const
returns the PropType of the property
This model serves to provide a model frontend to access a ParameterFile instance. ...
QString getFullName() const
property name including node instance name
QList< ConnectionLine * > _connectionList
list of all connectionlines
Definition: NodeProperty.h:124
static QColor _getSocketColor(QString typeName)
get color from type
void moveBy(qreal dx, qreal dy)
moves the property and if connected all connectionlines
Line that connects two slots of two different nodes.
QColor _color
Socket color.
Definition: NodeProperty.h:142
unsigned int _propNr
number of property
Definition: NodeProperty.h:115
Property(/Parameter) of a node.
Definition: NodeProperty.h:35
virtual QRectF boundingRect() const
area for hover event
QRectF _getSocketRect() const
center of the socket, used to draw end and start of connectionline
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
clear color of connected line when leave hoverevent
void setColor(QColor socketColor)
Set the color of the socket.
const ParameterFileModel * _pFile
link to parameter file
Definition: NodeProperty.h:133
QString getType() const
get property type
void changeConnectionLineColor(QColor lineColor, bool isHover=true)
change color all connected line of hovering property isHover set to true when the property was hovere...
Node * _node
pointer to parent node
Definition: NodeProperty.h:130
NodeProperty(Node *parentNode, QString name, int propNr, bool input, const ParameterFileModel *pFile)
default constructor