YARP
Yet Another Robot Platform
Loading...
Searching...
No Matches
QGraphicsViewEc.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3
* SPDX-License-Identifier: GPL-3.0-or-later
4
*/
5
6
#include "
QGraphicsViewEc.h
"
7
#include "moc_QGraphicsViewEc.cpp"
8
#include <QWheelEvent>
9
#include <qmath.h>
10
11
QGraphicsViewEc::QGraphicsViewEc
(QWidget* parent) : QGraphicsView(parent)
12
{
13
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
14
}
15
16
17
void
QGraphicsViewEc::wheelEvent
(QWheelEvent* event)
18
{
19
qreal scaleFactor = qPow(2.0, event->angleDelta().y() / 240.0);
//How fast we zoom
20
qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
21
if
(0.05 < factor && factor < 10) {
//Zoom factor limitation
22
scale(scaleFactor, scaleFactor);
23
}
24
}
QGraphicsViewEc.h
QGraphicsViewEc::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition
QGraphicsViewEc.cpp:17
QGraphicsViewEc::QGraphicsViewEc
QGraphicsViewEc(QWidget *parent=0)
Definition
QGraphicsViewEc.cpp:11
YARP
3.11.100+20250603.4+gitaa77f8b5c
src
guis
yarpviz
src
QGraphicsViewEc.cpp
Generated on Wed Jun 4 2025 02:40:10 for YARP by
1.9.8