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 <QGuiApplication>
26
# include <QMouseEvent>
29
#include "QGVNavStyleBlender.h"
33
using namespace TechDrawGui;
35
namespace TechDrawGui {
37
QGVNavStyleBlender::QGVNavStyleBlender(QGVPage* qgvp) :
42
QGVNavStyleBlender::~QGVNavStyleBlender()
46
void QGVNavStyleBlender::handleKeyReleaseEvent(QKeyEvent *event)
48
if ((event->key() == Qt::Key_Shift) && panningActive) {
54
void QGVNavStyleBlender::handleMousePressEvent(QMouseEvent *event)
57
// Base::Console().Message("QGVNSBlender::handleMousePressEvent() - button: %d buttons: %d\n", event->button(), event->buttons());
60
void QGVNavStyleBlender::handleMouseMoveEvent(QMouseEvent *event)
62
// Base::Console().Message("QGVNSBlender::handleMouseMoveEvent() - buttons: %d modifiers: %X\n",
63
// QGuiApplication::mouseButtons() & Qt::MiddleButton,
64
// QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier));
66
if (getViewer()->isBalloonPlacing()) {
67
balloonCursorMovement(event);
71
if ((QGuiApplication::mouseButtons() & Qt::LeftButton) &&
72
(QGuiApplication::mouseButtons() & Qt::RightButton)) {
73
//pan mode 1 - LMB + RMB
77
startPan(event->pos());
80
} else if ((QGuiApplication::mouseButtons() & Qt::MiddleButton) &&
81
(QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) ) {
82
//pan mode 2 - Shift + MMB
86
startPan(event->pos());
92
void QGVNavStyleBlender::handleMouseReleaseEvent(QMouseEvent *event)
94
// Base::Console().Message("QGVNSBlender::handleMouseReleaseEvent() - button: %d buttons: %d\n", event->button(), event->buttons());
95
if (getViewer()->isBalloonPlacing()) {
96
placeBalloon(event->pos());
100
//pan mode 1 - LMB + RMB + mouse move
101
//stop panning if either button released
102
if ( (event->button() == Qt::LeftButton) ||
103
(event->button() == Qt::RightButton)) {
107
//pan mode 2 - Shift + MMB
108
//stop panning if MMB released
109
if (event->button() == Qt::MiddleButton) {
116
bool QGVNavStyleBlender::allowContextMenu(QContextMenuEvent *event)
118
// Base::Console().Message("QGVNSBlender::allowContextMenu()\n");
119
if (event->reason() == QContextMenuEvent::Mouse) {
120
//must check for a button combination involving context menu button
121
if (QGuiApplication::mouseButtons() & Qt::LeftButton) {
122
//LeftButton is down, so this is LMB + RMB - don't allow context menu
129
} // namespace TechDrawGui