1
/***************************************************************************
2
* Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
# include <QApplication>
26
# include <QGuiApplication>
27
# include <QMouseEvent>
30
#include "QGVNavStyleTouchpad.h"
34
using namespace TechDrawGui;
36
namespace TechDrawGui {
38
QGVNavStyleTouchpad::QGVNavStyleTouchpad(QGVPage *qgvp) :
43
QGVNavStyleTouchpad::~QGVNavStyleTouchpad()
47
void QGVNavStyleTouchpad::handleKeyPressEvent(QKeyEvent *event)
49
if (event->key() == Qt::Key_PageUp) {
55
if (event->key() == Qt::Key_PageDown) {
61
QGVNavStyle::handleKeyPressEvent(event);
64
void QGVNavStyleTouchpad::handleKeyReleaseEvent(QKeyEvent *event)
67
if (event->key() == Qt::Key_Shift) {
77
if (event->key() == Qt::Key_Control) {
84
void QGVNavStyleTouchpad::handleMouseMoveEvent(QMouseEvent *event)
86
if (getViewer()->isBalloonPlacing()) {
87
balloonCursorMovement(event);
91
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
92
//if shift is down then we are panning
96
startPan(event->pos());
102
if (QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) &&
103
QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier) ) {
104
//if control and shift are down, then we are zooming
106
zoom(mouseZoomFactor(event->pos()));
108
startZoom(event->pos());
114
// if the mouse moves, but we are not zooming or panning, then we should make
115
// sure that zoom and pan are turned off.
120
void QGVNavStyleTouchpad::setAnchor()
122
//this navigation style can not anchor under mouse since mouse is moving as part of zoom action
124
m_viewer->setResizeAnchor(QGraphicsView::AnchorViewCenter);
125
m_viewer->setTransformationAnchor(QGraphicsView::AnchorViewCenter);
129
} //namespace TechDrawGui