-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawing.cpp
More file actions
39 lines (34 loc) · 875 Bytes
/
drawing.cpp
File metadata and controls
39 lines (34 loc) · 875 Bytes
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
#include <QProcess>
#include <QDebug>
#include <QtAlgorithms>
#include <exception>
#include <QWheelEvent>
#include <QInputEvent>
#include "graph.h"
#include "drawing.h"
#include "ui_scene.h"
Drawing::Drawing(QString inputFileName, QWidget *parent) :
QGraphicsView(parent),
_graph(new Graph(inputFileName))
{
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setScene(_graph);
setDragMode(QGraphicsView::ScrollHandDrag);
}
void Drawing::wheelEvent(QWheelEvent *event)
{
if (event->modifiers() == Qt::ControlModifier) {
setTransformationAnchor(QGraphicsView::AnchorViewCenter);
} else {
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
}
qreal scaleFactor = 1.2;
if (event->delta() > 0)
this->scale(scaleFactor, scaleFactor);
else
this->scale(1.0/scaleFactor, 1.0/scaleFactor);
}
Drawing::~Drawing()
{
delete _graph;
}