tuchulcha  0.10.1
Graphical Workflow Configuration Editor
ConnectionLine.cpp
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 */
23 #include "ConnectionLine.h"
24 #include <QPainter>
25 #include <QPainterPath>
26 #include <QBrush>
27 #include <QRect>
28 #include "NodeProperty.h"
29 #include "Node.h"
30 
32  QGraphicsItem(),
33  _startProp(0),
34  _endProp(0)
35 {
36  setZValue(-1);
37  setZValue(-1);
38  _lColor = Qt::black;
39 }
40 
42  return QRectF(_startPoint,_endPoint);
43 }
44 
45 void ConnectionLine::setEndPoint(int xx, int yy) {
46  _endPoint.setX(xx);
47  _endPoint.setY(yy);
48 }
49 
50 void ConnectionLine::setStartPoint(int xx, int yy) {
51  _startPoint.setX(xx);
52  _startPoint.setY(yy);
53 }
54 
56  _startProp = start;
57  _endProp = end;
58 }
59 
61  _startPoint = p;
62 }
63 
64 void ConnectionLine::setEndPoint(QPointF p) {
65  _endPoint = p;
66 }
67 
68 QColor ConnectionLine::lineColor() const{
69  return _lColor;
70 }
71 
72 void ConnectionLine::setLineColor(const QColor &newColor){
73  _lColor = newColor;
74 }
75 
77  QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
78  QPainterPath path;
79  path.moveTo(_startPoint);
80  QPointF c0((_startPoint.x()+50),_startPoint.y());
81  QPointF c1(_endPoint.x()-50,_endPoint.y());
82  path.cubicTo(c0,c1,_endPoint);
83  painter->setBrush(Qt::NoBrush);
84 
85  QPen p(_lColor,2.f);
86  if (_startProp == 0 || _endProp == 0) {
87  p.setBrush(Qt::gray);
88  p.setStyle(Qt::DashLine);
89  }
90  painter->setPen(p);
91  painter->setOpacity(1);
92  painter->drawPath(path);
93 }
94 
96  return _endProp;
97 }
98 
100  return _startProp;
101 }
102 
104  _endProp = endProp;
105 }
106 
108  _startProp = startProp;
109 }
110 
111 void ConnectionLine::moveStartPoint(qreal dx,qreal dy) {
112  _startPoint += QPointF(dx,dy);
113 }
114 
115 void ConnectionLine::moveEndPoint(qreal dx,qreal dy) {
116  _endPoint += QPointF(dx,dy);
117 }
QPointF _startPoint
point where line starts
void setEndProp(NodeProperty *endProp)
sets end property
NodeProperty * getEndProp() const
get property at end of line
QColor _lColor
store color
Declaration of class Node.
NodeProperty * getStartProp() const
get property at start of line
NodeProperty * _endProp
property where line ends
void setLineColor(const QColor &newColor)
set color connected line
NodeProperty * _startProp
property where line starts
QPointF _endPoint
point where line ends
QRectF boundingRect() const
bounding Rect, always 0 to be not selectable
Declaration of class NodeProperty.
void setStartProp(NodeProperty *startProp)
sets start property
void setStartPoint(int x, int y)
sets start point (for drawing)
Declaration of class ConnectionLine.
void moveEndPoint(qreal dx, qreal dy)
moves end point
void moveStartPoint(qreal dx, qreal dy)
moves start point
Property(/Parameter) of a node.
Definition: NodeProperty.h:35
ConnectionLine()
Default constructor.
void setStartEndProp(NodeProperty *start, NodeProperty *end)
sets start and end property
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
paints the line
QColor lineColor() const
return line color
void setEndPoint(int x, int y)
sets end point (for drawing)