SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
chart.cpp
Go to the documentation of this file.
1#include "chart.h"
2#include <QtWidgets/QGesture>
3#include <QtWidgets/QGraphicsScene>
4#include <QtWidgets/QGraphicsView>
5
6Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
7 : QChart(QChart::ChartTypeCartesian, parent, wFlags)
8{
9
10 grabGesture(Qt::PanGesture);
11 grabGesture(Qt::PinchGesture);
12}
13
15{
16
17}
18
19bool Chart::sceneEvent(QEvent *event)
20{
21 if (event->type() == QEvent::Gesture)
22 return gestureEvent(static_cast<QGestureEvent *>(event));
23 return QChart::event(event);
24}
25
26bool Chart::gestureEvent(QGestureEvent *event)
27{
28 if (QGesture *gesture = event->gesture(Qt::PanGesture)) {
29 QPanGesture *pan = static_cast<QPanGesture *>(gesture);
30 QChart::scroll(-(pan->delta().x()), pan->delta().y());
31 }
32
33 if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
34 QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
35 if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged)
36 QChart::zoom(pinch->scaleFactor());
37 }
38
39 return true;
40}
Chart(QGraphicsItem *parent=nullptr, Qt::WindowFlags wFlags={})
Definition chart.cpp:6
bool gestureEvent(QGestureEvent *event)
Definition chart.cpp:26
bool sceneEvent(QEvent *event)
Definition chart.cpp:19
~Chart()
Definition chart.cpp:14