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 "QGVNavStyleRevit.h"
33
using namespace TechDrawGui;
35
namespace TechDrawGui {
37
QGVNavStyleRevit::QGVNavStyleRevit(QGVPage *qgvp) :
42
QGVNavStyleRevit::~QGVNavStyleRevit()
46
void QGVNavStyleRevit::handleMousePressEvent(QMouseEvent *event)
48
if (event->button() == Qt::RightButton) {
49
startClick(Qt::RightButton);
53
void QGVNavStyleRevit::handleMouseMoveEvent(QMouseEvent *event)
55
if (getViewer()->isBalloonPlacing()) {
56
balloonCursorMovement(event);
60
//if the mouse moves between press and release, then it isn't a click
66
//pan mode 1 - MMB + move
67
if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
71
startPan(event->pos());
76
//pan mode 2 - LMB + RMB + move
77
if (QGuiApplication::mouseButtons() & Qt::LeftButton &&
78
QGuiApplication::mouseButtons() & Qt::RightButton) {
82
startPan(event->pos());
88
void QGVNavStyleRevit::handleMouseReleaseEvent(QMouseEvent *event)
90
if (getViewer()->isBalloonPlacing()) {
91
placeBalloon(event->pos());
94
if ((event->button() == Qt::RightButton) &&
96
(m_clickButton == Qt::RightButton)) {
103
//stop panning if any button released
104
if ( (event->button() == Qt::LeftButton) ||
105
(event->button() == Qt::RightButton) ||
106
(event->button() == Qt::MiddleButton) ){
114
bool QGVNavStyleRevit::allowContextMenu(QContextMenuEvent *event)
116
// Base::Console().Message("QGVNSRevit::allowContextMenu()\n");
117
if (event->reason() == QContextMenuEvent::Mouse) {
118
//must check for a button combination involving context menu button
119
if (QGuiApplication::mouseButtons() & Qt::LeftButton) {
120
//LMB down - don't allow context menu
122
} else if (m_clickPending) {
123
//context menu request to be handled by button release
129
} // namespace TechDrawGui