FreeCAD

Форк
0
/
QGVNavStyleOCC.cpp 
143 строки · 4.4 Кб
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 "QGVNavStyleOCC.h"
30
#include "QGVPage.h"
31

32

33
using namespace TechDrawGui;
34

35
namespace TechDrawGui {
36

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

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

46
void QGVNavStyleOCC::handleKeyReleaseEvent(QKeyEvent *event)
47
{
48
    //zoom mode 2
49
    if ( (event->key() == Qt::Key_Control) && zoomingActive) {
50
        stopZoom();
51
        event->accept();
52
    }
53

54
    //pan mode
55
    if ( (event->key() == Qt::Key_Control) && panningActive) {
56
        stopPan();
57
        event->accept();
58
    }
59
}
60

61
void QGVNavStyleOCC::handleMousePressEvent(QMouseEvent *event)
62
{
63
    Q_UNUSED(event)
64
}
65

66
void QGVNavStyleOCC::handleMouseMoveEvent(QMouseEvent *event)
67
{
68
    if (getViewer()->isBalloonPlacing()) {
69
        balloonCursorMovement(event);
70
        return;
71
    }
72

73
    //pan mode 1 - MMB + mouse movement
74
    if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
75
        if (panningActive) {
76
            pan(event->pos());
77
        } else {
78
            startPan(event->pos());
79
        }
80
        event->accept();
81
    }
82

83
    //pan mode 2 - CNTL + MMB + mouse movement
84
    if (QGuiApplication::mouseButtons() & Qt::MiddleButton &&
85
        QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) ) {
86
        if (panningActive) {
87
            pan(event->pos());
88
        } else {
89
            startPan(event->pos());
90
        }
91
        event->accept();
92
    }
93

94
    //zoom mode 2 Control + LMB
95
    if ((QGuiApplication::mouseButtons() & Qt::LeftButton) &&
96
         QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) ) {
97
        if (zoomingActive) {
98
            zoom(mouseZoomFactor(event->pos()));
99
        } else {
100
            startZoom(event->pos());
101
        }
102
        event->accept();
103
    }
104
}
105

106
void QGVNavStyleOCC::handleMouseReleaseEvent(QMouseEvent *event)
107
{
108
    if (getViewer()->isBalloonPlacing()) {
109
        placeBalloon(event->pos());
110
    }
111

112
    if (event->button() == Qt::MiddleButton) {
113
        //pan mode [Control] + MMB
114
        if (panningActive) {
115
            stopPan();
116
            event->accept();
117
        }
118
    }
119

120
    if (event->button() == Qt::LeftButton) {
121
        //zoom mode 2 Control + LMB
122
        if (zoomingActive) {
123
            stopZoom();
124
            event->accept();
125
        }
126
    }
127
}
128

129
bool QGVNavStyleOCC::allowContextMenu(QContextMenuEvent *event)
130
{
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
136
            return false;
137
        }
138
    }
139
    return true;
140
}
141

142

143
}  // namespace TechDrawGui
144

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

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

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

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