FreeCAD

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

32

33
using namespace TechDrawGui;
34

35
namespace TechDrawGui {
36

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

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

46
void QGVNavStyleGesture::handleMousePressEvent(QMouseEvent *event)
47
{
48
    if (event->button() == Qt::RightButton) {
49
        startClick(Qt::RightButton);
50
    }
51
}
52

53
void QGVNavStyleGesture::handleMouseMoveEvent(QMouseEvent *event)
54
{
55
    if (getViewer()->isBalloonPlacing()) {
56
        balloonCursorMovement(event);
57
        return;
58
    }
59

60
    //if the mouse moves between press and release, then it isn't a click
61
    if (m_clickPending) {
62
        stopClick();
63
        return;
64
    }
65

66
    if (QGuiApplication::mouseButtons() & Qt::RightButton) {
67
        //pan mode 1 - RMB + move
68
        if (panningActive) {
69
            pan(event->pos());
70
        } else {
71
            startPan(event->pos());
72
        }
73
        event->accept();
74
    }
75
}
76

77
void QGVNavStyleGesture::handleMouseReleaseEvent(QMouseEvent *event)
78
{
79
    if (getViewer()->isBalloonPlacing()) {
80
        placeBalloon(event->pos());
81
    }
82

83
    if ((event->button() == Qt::RightButton) &&
84
         m_clickPending &&
85
        (m_clickButton == Qt::RightButton)) {
86
        stopClick();
87
        pseudoContextEvent();
88
        event->accept();
89
        return;
90
    }
91

92
    if (event->button() == Qt::RightButton) {
93
        stopPan();
94
        event->accept();
95
    }
96
}
97

98
//RMB for pan conflicts with RMB for context menu
99
bool QGVNavStyleGesture::allowContextMenu(QContextMenuEvent *event)
100
{
101
    if (event->reason() == QContextMenuEvent::Mouse) {
102
        return false;
103
    }
104
    return true;
105
}
106

107
}  // namespace TechDrawGui
108

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

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

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

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