-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.h
51 lines (41 loc) · 1.12 KB
/
view.h
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
/*
MIT License
Copyright (c) 2021 Ramesh Choudhary
*/
#ifndef VIEW_H
#define VIEW_H
#include<QGraphicsView>
#include<QTimeLine>
#include<QWheelEvent>
#include<QMouseEvent>
#include<QtMath>
class GraphLayout;
class View : public QGraphicsView
{
Q_OBJECT
public:
View(QWidget *parent = nullptr);
~View();
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio);
void scaleView(int numSteps);
void enableEditing(bool set);
void setGraphLayout(GraphLayout * graphLaoyout);
signals:
void transformed();
private:
int _numScheduledScalings=0;
bool isMousPressed=false;
QPointF lastpoint;
bool m_editing=false;
GraphLayout * graphLaoyout=nullptr;
private slots:
// smoothly zoom view , code taken from https://wiki.qt.io/Smooth_Zoom_In_QGraphicsView
void scalingTime(qreal);
void animFinished();
protected:
void wheelEvent(QWheelEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
};
#endif // VIEW_H