File: edge.h

package info (click to toggle)
socnetv 0.90-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,028 kB
  • sloc: cpp: 12,953; makefile: 75
file content (106 lines) | stat: -rwxr-xr-x 3,326 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
 SocNetV: Social Networks Visualizer 
 version: 0.90
 Written in Qt 4.4
 
                         edge.h  -  description
                             -------------------
    copyright            : (C) 2005-2010 by Dimitris B. Kalamaras
    email                : dimitris.kalamaras@gmail.com
 ***************************************************************************/

/*******************************************************************************
*     This program is free software: you can redistribute it and/or modify     *
*     it under the terms of the GNU General Public License as published by     *
*     the Free Software Foundation, either version 3 of the License, or        *
*     (at your option) any later version.                                      *
*                                                                              *
*     This program is distributed in the hope that it will be useful,          *
*     but WITHOUT ANY WARRANTY; without even the implied warranty of           *
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
*     GNU General Public License for more details.                             *
*                                                                              *
*     You should have received a copy of the GNU General Public License        *
*     along with this program.  If not, see <http://www.gnu.org/licenses/>.    *
********************************************************************************/

#ifndef EDGE_H
#define EDGE_H

using namespace std;

#include <QGraphicsItem>
#include <QObject>
#include <utility> //declares pair construct


class GraphicsWidget;
class QGraphicsSceneMouseEvent;
class Node;
class EdgeWeight;


static const int TypeEdge= QGraphicsItem::UserType+2;


class Edge : public QObject, public QGraphicsItem {
	Q_OBJECT
	Q_INTERFACES (QGraphicsItem)

public:
	Edge(GraphicsWidget *, Node*, Node*, float, int, QString, bool, bool, bool);

	enum { Type = UserType + 2 };
	int type() const { return Type; }
	Node *sourceNode() const;
	void setSourceNode(Node *node);

	Node *targetNode() const;
	void setTargetNode(Node *node);
	
	void setStartOffset(int );
	void setEndOffset(int );
	void removeRefs();

	int sourceNodeNumber();
	int targetNodeNumber();
	void setWeight( float  w) ;
	float weight();
	void setColor( QString str) ;
	QString color() ;
	void addWeight (EdgeWeight* canvasWeight  ) ;
	void clearWeightList();
	float width(); 
	void showArrows(bool);
	void toggleAntialiasing(bool);

	void makeReciprocal();
	void unmakeReciprocal();

	QPainterPath shape() const;

public slots:
	void adjust ();
	void remove();
protected:
	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void mousePressEvent(QGraphicsSceneMouseEvent *event);


private:
	GraphicsWidget *graphicsWidget;
	Node *source, *target;
	QPointF sourcePoint, targetPoint;
	qreal m_arrowSize, m_startOffset, m_endOffset;
	list<EdgeWeight*> weightList;
	QString m_color;
	int eFrom, eTo;
	float m_weight;
	int tox1, tox2, toy1, toy2, size;
	double rad, theta, theta1, theta2;
	qreal angle, line_length, line_dx, line_dy;
	bool m_Bezier, m_drawArrows, m_reciprocal;
};

#endif