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 "QGVNavStyleOpenSCAD.h"
33
using namespace TechDrawGui;
35
namespace TechDrawGui {
37
QGVNavStyleOpenSCAD::QGVNavStyleOpenSCAD(QGVPage *qgvp) :
42
QGVNavStyleOpenSCAD::~QGVNavStyleOpenSCAD()
46
void QGVNavStyleOpenSCAD::handleKeyReleaseEvent(QKeyEvent *event)
49
if ( (event->key() == Qt::Key_Shift) && zoomingActive) {
55
void QGVNavStyleOpenSCAD::handleMousePressEvent(QMouseEvent *event)
57
if (event->button() == Qt::RightButton) {
58
startClick(Qt::RightButton);
62
void QGVNavStyleOpenSCAD::handleMouseMoveEvent(QMouseEvent *event)
64
if (getViewer()->isBalloonPlacing()) {
65
balloonCursorMovement(event);
69
//if the mouse moves between press and release, then it isn't a click
75
if (QGuiApplication::mouseButtons() & Qt::RightButton &&
76
!QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
77
//pan mode - RMB + move
81
startPan(event->pos());
86
if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
87
//zoom mode 1 - MMB + move
89
zoom(mouseZoomFactor(event->pos()));
91
startZoom(event->pos());
96
if ((QGuiApplication::mouseButtons() & Qt::RightButton) &&
97
QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
98
//zoom mode 2 - SHIFT + RMB + move
100
zoom(mouseZoomFactor(event->pos()));
102
startZoom(event->pos());
108
void QGVNavStyleOpenSCAD::handleMouseReleaseEvent(QMouseEvent *event)
110
if (getViewer()->isBalloonPlacing()) {
111
placeBalloon(event->pos());
114
if ((event->button() == Qt::RightButton) &&
116
(m_clickButton == Qt::RightButton)) {
118
pseudoContextEvent();
123
if ((event->button() == Qt::RightButton) && panningActive) {
128
if ((event->button() == Qt::RightButton) && zoomingActive) {
133
if ((event->button() == Qt::MiddleButton) && zoomingActive) {
139
bool QGVNavStyleOpenSCAD::allowContextMenu(QContextMenuEvent *event)
141
// Base::Console().Message("QGVNSCAD::allowContextMenu()\n");
142
if (event->reason() == QContextMenuEvent::Mouse) {
143
//must check for a button combination involving context menu button
144
if (QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
145
//Shift down - don't allow context menu
147
} else if (m_clickPending) {
148
//context menu request to be handled by button release
156
} // namespace TechDrawGui