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// SedSAT3 – Sediment Source Assessment Tool, version 3
2// U.S. Geological Survey. See LICENSE.md and DISCLAIMER.md in the repository root.
3
4#include "chart.h"
5#include <QtWidgets/QGesture>
6#include <QtWidgets/QGraphicsScene>
7#include <QtWidgets/QGraphicsView>
8
9Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
10 : QChart(QChart::ChartTypeCartesian, parent, wFlags)
11{
12
13 grabGesture(Qt::PanGesture);
14 grabGesture(Qt::PinchGesture);
15}
16
18{
19
20}
21
22bool Chart::sceneEvent(QEvent *event)
23{
24 if (event->type() == QEvent::Gesture)
25 return gestureEvent(static_cast<QGestureEvent *>(event));
26 return QChart::event(event);
27}
28
29bool Chart::gestureEvent(QGestureEvent *event)
30{
31 if (QGesture *gesture = event->gesture(Qt::PanGesture)) {
32 QPanGesture *pan = static_cast<QPanGesture *>(gesture);
33 QChart::scroll(-(pan->delta().x()), pan->delta().y());
34 }
35
36 if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
37 QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
38 if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged)
39 QChart::zoom(pinch->scaleFactor());
40 }
41
42 return true;
43}
Chart(QGraphicsItem *parent=nullptr, Qt::WindowFlags wFlags={})
Definition chart.cpp:9
bool gestureEvent(QGestureEvent *event)
Definition chart.cpp:29
bool sceneEvent(QEvent *event)
Definition chart.cpp:22
~Chart()
Definition chart.cpp:17