FreeCAD

Форк
0
/
InputDevice.cpp 
119 строк · 3.5 Кб
1
/**************************************************************************\
2
 * Copyright (c) Kongsberg Oil & Gas Technologies AS
3
 * All rights reserved.
4
 * 
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are
7
 * met:
8
 * 
9
 * Redistributions of source code must retain the above copyright notice,
10
 * this list of conditions and the following disclaimer.
11
 * 
12
 * Redistributions in binary form must reproduce the above copyright
13
 * notice, this list of conditions and the following disclaimer in the
14
 * documentation and/or other materials provided with the distribution.
15
 * 
16
 * Neither the name of the copyright holder nor the names of its
17
 * contributors may be used to endorse or promote products derived from
18
 * this software without specific prior written permission.
19
 * 
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
\**************************************************************************/
32

33
#ifdef _MSC_VER
34
#pragma warning(disable : 4267)
35
#endif
36

37
#include <QInputEvent>
38
#include <Inventor/events/SoEvents.h>
39

40
#include "devices/InputDevice.h"
41

42

43
using namespace SIM::Coin3D::Quarter;
44

45
/*!
46
  \class SIM::Coin3D::Quarter::InputDevice InputDevice.h Quarter/devices/InputDevice.h
47

48
  \brief The InputDevice class is the base class for devices such as
49
  the Keyboard and Mouse. It can be subclassed to support other
50
  devices.
51
*/
52

53
InputDevice::InputDevice() : quarter(nullptr)
54
{
55
  this->mousepos = SbVec2s(0, 0);
56
}
57

58
InputDevice::InputDevice(QuarterWidget *quarter) : quarter(quarter)
59
{
60
    this->mousepos = SbVec2s(0, 0);
61
}
62

63
/*!
64
  Sets the mouseposition
65

66
  \param[in] pos position of mouse in pixelcoordinates
67
*/
68

69
void
70
InputDevice::setMousePosition(const SbVec2s & pos)
71
{
72
  this->mousepos = pos;
73
}
74

75
/*!
76
  Sets the window size of the owning window
77

78
  \param[in] size in pixels
79
*/
80
void
81
InputDevice::setWindowSize(const SbVec2s & size)
82
{
83
  this->windowsize = size;
84
}
85

86
/*!
87
  Transforms a qevent into an soevent
88

89
  \param[in,out] soevent the transformed event
90
  \param[in] qevent incoming qevent
91
*/
92
void
93
InputDevice::setModifiers(SoEvent * soevent, const QInputEvent * qevent)
94
{
95
  // FIXME: How do we get the time from the qevent? (20070306 frodo)
96
  soevent->setTime(SbTime::getTimeOfDay());
97

98
  // Note: On Mac OS X, the ControlModifier value corresponds to the
99
  // Command keys on the Macintosh keyboard, and the MetaModifier
100
  // value corresponds to the Control keys.
101
  soevent->setShiftDown(qevent->modifiers() & Qt::ShiftModifier);
102
  soevent->setAltDown(qevent->modifiers() & Qt::AltModifier);
103
  soevent->setCtrlDown(qevent->modifiers() & Qt::ControlModifier);
104
}
105

106
/*!
107
  \var InputDevice::mousepos
108

109
  Holds the last known position of the mouse. This should be set even
110
  for a keyboard event.
111
*/
112

113
/*!
114
  \var InputDevice::windowsize
115

116
  Holds the size of the owning window
117
*/
118

119
#undef PRIVATE
120

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

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

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

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