FreeCAD

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

32

33
using namespace TechDrawGui;
34

35
namespace TechDrawGui {
36

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

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

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

53
void QGVNavStyleRevit::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
    //pan mode 1 - MMB + move
67
    if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
68
        if (panningActive) {
69
            pan(event->pos());
70
        } else {
71
            startPan(event->pos());
72
        }
73
        event->accept();
74
    }
75

76
    //pan mode 2 - LMB + RMB + move
77
    if (QGuiApplication::mouseButtons() & Qt::LeftButton &&
78
        QGuiApplication::mouseButtons() & Qt::RightButton) {
79
        if (panningActive) {
80
            pan(event->pos());
81
        } else {
82
            startPan(event->pos());
83
        }
84
        event->accept();
85
    }
86
}
87

88
void QGVNavStyleRevit::handleMouseReleaseEvent(QMouseEvent *event)
89
{
90
    if (getViewer()->isBalloonPlacing()) {
91
        placeBalloon(event->pos());
92
    }
93

94
    if ((event->button() == Qt::RightButton) &&
95
         m_clickPending &&
96
        (m_clickButton == Qt::RightButton)) {
97
        stopClick();
98
        pseudoContextEvent();
99
        event->accept();
100
        return;
101
    }
102

103
    //stop panning if any button released
104
    if ( (event->button() == Qt::LeftButton) ||
105
         (event->button() == Qt::RightButton) ||
106
         (event->button() == Qt::MiddleButton) ){
107
        if (panningActive) {
108
            stopPan();
109
            event->accept();
110
        }
111
    }
112
}
113

114
bool QGVNavStyleRevit::allowContextMenu(QContextMenuEvent *event)
115
{
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
121
            return false;
122
        } else if (m_clickPending) {
123
            //context menu request to be handled by button release
124
            return false;
125
        }
126
    }
127
    return true;
128
}
129
}  // namespace TechDrawGui
130

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

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

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

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