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 "QGVNavStyleOCC.h"
33
using namespace TechDrawGui;
35
namespace TechDrawGui {
37
QGVNavStyleOCC::QGVNavStyleOCC(QGVPage *qgvp) :
42
QGVNavStyleOCC::~QGVNavStyleOCC()
46
void QGVNavStyleOCC::handleKeyReleaseEvent(QKeyEvent *event)
49
if ( (event->key() == Qt::Key_Control) && zoomingActive) {
55
if ( (event->key() == Qt::Key_Control) && panningActive) {
61
void QGVNavStyleOCC::handleMousePressEvent(QMouseEvent *event)
66
void QGVNavStyleOCC::handleMouseMoveEvent(QMouseEvent *event)
68
if (getViewer()->isBalloonPlacing()) {
69
balloonCursorMovement(event);
73
//pan mode 1 - MMB + mouse movement
74
if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
78
startPan(event->pos());
83
//pan mode 2 - CNTL + MMB + mouse movement
84
if (QGuiApplication::mouseButtons() & Qt::MiddleButton &&
85
QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) ) {
89
startPan(event->pos());
94
//zoom mode 2 Control + LMB
95
if ((QGuiApplication::mouseButtons() & Qt::LeftButton) &&
96
QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) ) {
98
zoom(mouseZoomFactor(event->pos()));
100
startZoom(event->pos());
106
void QGVNavStyleOCC::handleMouseReleaseEvent(QMouseEvent *event)
108
if (getViewer()->isBalloonPlacing()) {
109
placeBalloon(event->pos());
112
if (event->button() == Qt::MiddleButton) {
113
//pan mode [Control] + MMB
120
if (event->button() == Qt::LeftButton) {
121
//zoom mode 2 Control + LMB
129
bool QGVNavStyleOCC::allowContextMenu(QContextMenuEvent *event)
131
// Base::Console().Message("QGVNSOCC::allowContextMenu()\n");
132
if (event->reason() == QContextMenuEvent::Mouse) {
133
//must check for a button combination involving context menu button
134
if (QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) ) {
135
//CNTL is down, so this is CNTL + RMB - don't allow context menu
143
} // namespace TechDrawGui