FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Edge.h
1 /*
2  * Copyright 2011, 2012 Lukas Jirkovsky
3  *
4  * This file is part of FotoSHOCK.
5  *
6  * FotoSHOCK is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * FotoSHOCK 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 General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FotoSHOCK. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef EDGE_H
20 #define EDGE_H
21 
22 #include <QtGui/qgraphicsitem.h>
23 
24 class Connector;
25 
26 class Edge : public QGraphicsItem {
27  public:
28  Edge();
29  Edge(Connector* source, Connector* dest);
30 
31  void setSourceNode(Connector* node);
32  void setDestNode(Connector* node);
33  Connector* sourceNode() const;
34  Connector* destNode() const;
35  // use only when the edge is not conneted to anything
36  void setSourcePos(QPointF pos);
37  void setDestPos(QPointF pos);
38 
39  virtual void paint (QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
40  virtual QRectF boundingRect() const;
41 
42  // updates the position according to its endpoints and updates it.
43  void updatePos();
44  private:
45  Connector* m_source;
46  Connector* m_dest;
47 
48  QPointF m_sourcePos;
49  QPointF m_destPos;
50 };
51 
52 #endif // EDGE_H