FreeCAD

Форк
0
/
QGVNavStyleBlender.cpp 
129 строк · 4.6 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com>               *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
# include <QGuiApplication>
26
# include <QMouseEvent>
27
#endif
28

29
#include "QGVNavStyleBlender.h"
30
#include "QGVPage.h"
31

32

33
using namespace TechDrawGui;
34

35
namespace TechDrawGui {
36

37
QGVNavStyleBlender::QGVNavStyleBlender(QGVPage* qgvp) :
38
    QGVNavStyle(qgvp)
39
{
40
}
41

42
QGVNavStyleBlender::~QGVNavStyleBlender()
43
{
44
}
45

46
void QGVNavStyleBlender::handleKeyReleaseEvent(QKeyEvent *event)
47
{
48
    if ((event->key() == Qt::Key_Shift) && panningActive) {
49
        stopPan();
50
        event->accept();
51
    }
52
}
53

54
void QGVNavStyleBlender::handleMousePressEvent(QMouseEvent *event)
55
{
56
    Q_UNUSED(event)
57
//    Base::Console().Message("QGVNSBlender::handleMousePressEvent() - button: %d buttons: %d\n", event->button(), event->buttons());
58
}
59

60
void QGVNavStyleBlender::handleMouseMoveEvent(QMouseEvent *event)
61
{
62
//    Base::Console().Message("QGVNSBlender::handleMouseMoveEvent() - buttons: %d modifiers: %X\n",
63
//                            QGuiApplication::mouseButtons() & Qt::MiddleButton,
64
//                            QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier));
65

66
    if (getViewer()->isBalloonPlacing()) {
67
        balloonCursorMovement(event);
68
        return;
69
    }
70

71
    if ((QGuiApplication::mouseButtons() & Qt::LeftButton) &&
72
        (QGuiApplication::mouseButtons() & Qt::RightButton)) {
73
        //pan mode 1 - LMB + RMB
74
        if (panningActive) {
75
            pan(event->pos());
76
        } else {
77
            startPan(event->pos());
78
        }
79
        event->accept();
80
    } else if ((QGuiApplication::mouseButtons() & Qt::MiddleButton) &&
81
               (QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) ) {
82
        //pan mode 2 - Shift + MMB
83
        if (panningActive) {
84
            pan(event->pos());
85
        } else {
86
            startPan(event->pos());
87
        }
88
        event->accept();
89
    }
90
}
91

92
void QGVNavStyleBlender::handleMouseReleaseEvent(QMouseEvent *event)
93
{
94
//    Base::Console().Message("QGVNSBlender::handleMouseReleaseEvent() - button: %d buttons: %d\n", event->button(), event->buttons());
95
    if (getViewer()->isBalloonPlacing()) {
96
        placeBalloon(event->pos());
97
    }
98

99
    if (panningActive) {
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)) {
104
            stopPan();
105
            event->accept();
106
        }
107
        //pan mode 2 - Shift + MMB
108
        //stop panning if MMB released
109
        if (event->button() == Qt::MiddleButton) {
110
            stopPan();
111
            event->accept();
112
        }
113
    }
114
}
115

116
bool QGVNavStyleBlender::allowContextMenu(QContextMenuEvent *event)
117
{
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
123
            return false;
124
        }
125
    }
126
    return true;
127
}
128

129
}  // namespace TechDrawGui
130

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.