File: graphicswidget.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 (148 lines) | stat: -rwxr-xr-x 4,822 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/***************************************************************************
 SocNetV: Social Networks Visualizer
 version: 0.90
 Written in Qt 4.4
 
                         graphicswidget.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 GRAPHICSWIDGET_H
#define GRAPHICSWIDGET_H


#include <QtGui/QGraphicsView>
#include "graph.h"
#include <QGraphicsScene>
#include <QMap>

class MainWindow;
//class QGraphicsSceneMouseEvent;
class Node;
class Edge;
class NodeNumber;
class NodeLabel;
class BackgrCircle;
class EdgeWeight;

typedef QMap<QString, Edge*> StringToEdgeMap;
typedef QHash <long int, Node*> hash_in;

class GraphicsWidget : public QGraphicsView {
	Q_OBJECT
public:
 	GraphicsWidget(QGraphicsScene*, MainWindow* parent);
	~GraphicsWidget();
	void clear();

	Node* hasNode(QString text);
//	Node* hasNode(int number);
	bool setMarkedNode(QString text);
	
	void removeItem(Edge*);
	void removeItem(Node*);
	void removeItem(NodeNumber*);
	void removeItem(NodeLabel*);
	void nodeMoved(int, int, int);

	void setInitNodeColor(QString);
	void setInitLinkColor(QString);
	void setInitNodeSize(int);
	void setInitNumberDistance(int);
	void setInitLabelDistance(int);

	void setNumbersInsideNodes(bool);
	
	bool setNodeColor(long int, QString);
	
	bool setEdgeColor(int, int, QString);
	
	bool setEdgeWeight(int, int, float);
	
	void setAllItemsVisibility(int, bool);
	
	void removeAllItems(int);
protected:
	void wheelEvent(QWheelEvent *event);
	void mouseDoubleClickEvent ( QMouseEvent * e );
	void mousePressEvent ( QMouseEvent * e );
	//void mouseReleaseEvent(QMouseEvent * e );
	void resizeEvent( QResizeEvent *e );
	void paintEvent ( QPaintEvent * event );

public slots:
	void drawNode(	int i, int size, QString aColor, 
					QString nColor, int nSize, 
					QString label, QString lColor, int lSize, 
					QPointF p, 
					QString nodeShape, 
					bool showLabels, bool labelIn, bool showNumbers
					);
	void eraseNode(long int doomedJim);
	void drawEdge(int, int, float, bool, bool, QString, bool);
	void eraseEdge(int, int);
	void setEdgeVisibility ( int, int, bool);
	void setNodeVisibility(long int, bool );	//Called from Graph via MW
	
	void nodeClicked(Node *);
	void edgeClicked(Edge *);
	void openNodeContextMenu();
	void openEdgeContextMenu();
	
	void moveNode(int, int, int);			//Called from Graph when creating random nets.
	void changeZoom(const int value); 
	void startEdge(Node *node);	
	void drawEdgeReciprocal(int, int);
	void unmakeEdgeReciprocal(int, int);

	void clearBackgrCircles();
	void addBackgrCircle( int x0, int y0, int radius);
	void addBackgrHLine(int y0);
	void zoomIn();
	void zoomOut();
	void rot(int angle);

signals:
	void windowResized(int,int);
	void userDoubleClicked(int, QPointF);
	void userMiddleClicked(int, int, float);
	void openNodeMenu();
	void openEdgeMenu();
	void updateNodeCoords(int, int, int);
	void selectedNode(Node *);
	void selectedEdge(Edge *);
	void zoomChanged(int);
	
private:
	hash_in nodeHash;			//This is used in drawEdge() method
	StringToEdgeMap edgesMap;
	int timerId,  layoutType, m_nodeSize, m_numberDistance, m_labelDistance;
	double m_currentScaleFactor;
	int m_currentRotationAngle;
	int zoomIndex, originalNodeSize;
	QString m_nodeLabel, m_numberColor, m_nodeColor, m_labelColor, m_linkColor;
	bool secondDoubleClick, dynamicMovement, markedNodeExists;
	QGraphicsItem *moving;
	QPointF startPoint, endPoint;
	Node *firstNode, *secondNode, *markedNode, *tempNode ;

};

#endif