1
/**************************************************************************\
3
* This file is part of the Coin 3D visualization library.
4
* Copyright (C) 1998-2005 by Systems in Motion. All rights reserved.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* ("GPL") version 2 as published by the Free Software Foundation.
9
* See the file LICENSE.GPL at the root directory of this source
10
* distribution for additional information about the GNU GPL.
12
* For using Coin with software that can not be combined with the GNU
13
* GPL, and for taking advantage of the additional benefits of our
14
* support services, please contact Systems in Motion about acquiring
15
* a Coin Professional Edition License.
17
* See <URL:http://www.coin3d.org/> for more information.
19
* Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
20
* <URL:http://www.sim.no/>.
22
\**************************************************************************/
26
#endif // HAVE_CONFIG_H
28
#include <Inventor/Qt/devices/SoQtMouse.h>
29
#include <Inventor/Qt/devices/SoGuiMouseP.h>
30
#include <Inventor/events/SoMouseButtonEvent.h>
31
#include <Inventor/events/SoLocation2Event.h>
34
\class SoQtMouse SoQtMouse.h Inventor/Qt/devices/SoQtMouse.h
35
\brief The SoQtMouse class is the mouse input device abstraction.
38
The SoQtMouse class is the glue between native mouse handling and
39
mouse interaction in the Inventor scenegraph.
41
All components derived from the SoQtRenderArea have got an
42
SoQtMouse device attached by default.
44
One important note for application programmers: our mappings to
45
SoMouseButtonEvent::BUTTON2 and SoMouseButtonEvent::BUTTON3 do not
46
match the mappings in SGI's InventorXt library or TGS's SoWin
47
library for 3-button mice. They map mouse buttons like this:
50
<li>left button: SoMouseButtonEvent::BUTTON1</li>
51
<li>middle button: SoMouseButtonEvent::BUTTON2</li>
52
<li>right button: SoMouseButtonEvent::BUTTON3</li>
55
While in this SIM SoQt library the mappings are:
58
<li>left button: SoMouseButtonEvent::BUTTON1</li>
59
<li>middle button: SoMouseButtonEvent::BUTTON3</li>
60
<li>right button: SoMouseButtonEvent::BUTTON2</li>
63
This is a conscious design decision we've made. The reason is that
64
BUTTON2 should be the right mouse button whether you have a 2-button
65
mouse or a 3-button mouse.
68
// *************************************************************************
70
SOQT_OBJECT_SOURCE(SoQtMouse);
72
// *************************************************************************
75
\enum SoQtMouse::Events
76
Enumeration over supported mouse events.
79
\var SoQtMouse::Events SoQtMouse::BUTTON_PRESS
80
Maskbit for mousebutton press events.
83
\var SoQtMouse::Events SoQtMouse::BUTTON_RELEASE
84
Maskbit for mousebutton release events.
87
\var SoQtMouse::Events SoQtMouse::POINTER_MOTION
88
Maskbit for mousepointer motion events.
91
\var SoQtMouse::Events SoQtMouse::BUTTON_MOTION
92
Maskbit for mousepointer motion events with one or more mousebuttons
96
\var SoQtMouse::Events SoQtMouse::ALL_EVENTS
98
Mask which includes all the maskbits in the enum (ie use this to
99
signal interest in all kinds of events for the mouse device).
102
// *************************************************************************
105
\fn SoQtMouse::SoQtMouse(int mask)
107
Constructor. The \a mask argument should contain the set of
108
SoQtMouse::Events one is interested in tracking.
112
\fn SoQtMouse::~SoQtMouse()
117
\fn const SoEvent * SoQtMouse::translateEvent(QEvent * event)
119
Translates a native event from the underlying toolkit into a generic
122
This is then returned in the form of an instance of a subclass of
123
the Inventor API's SoEvent class, either an SoMouseButtonEvent or an
124
SoLocation2Event, depending on whether the native event is a
125
mousebutton press / release, or a mousecursor movement event.
127
The mapping of the mousebuttons upon generation of
128
SoMouseButtonEvent events will be done as follows:
131
<li>left mousebutton: SoMouseButtonEvent::BUTTON1</li>
132
<li>right mousebutton: SoMouseButtonEvent::BUTTON2</li>
133
<li>middle mousebutton, if available: SoMouseButtonEvent::BUTTON3</li>
134
<li>forward motion on a wheel mouse: SoMouseButtonEvent::BUTTON4</li>
135
<li>backward motion on a wheel mouse: SoMouseButtonEvent::BUTTON5</li>
138
Note that the rightmost mousebutton will always map to
139
SoMouseButtonEvent::BUTTON2, even on a 3-button mouse.
142
// *************************************************************************
144
#ifndef DOXYGEN_SKIP_THIS
146
SoGuiMouseP::SoGuiMouseP(SoQtMouse * p)
150
// Allocate system-neutral event objects once and reuse.
151
this->buttonevent = new SoMouseButtonEvent;
152
this->locationevent = new SoLocation2Event;
155
SoGuiMouseP::~SoGuiMouseP()
157
delete this->buttonevent;
158
delete this->locationevent;
161
#endif // !DOXYGEN_SKIP_THIS
163
// *************************************************************************