NDEVR
API Documentation
NDEVRMouseManager.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: NDEVRMouseManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/WidgetOptions.h>
35#include <NDEVR/WindowInstance.h>
36#include <NDEVR/Thread.h>
37#include <NDEVR/TimeSpan.h>
38#include <QMouseEvent>
39#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
40#define position pos
41#define points touchPoints
42#endif
43#if NDEVR_SUPPORTS_THREADING
44#define RUN_MOUSE_MANAGER_THREADED 0
45#else
46#define RUN_MOUSE_MANAGER_THREADED 0
47#endif
48#if NDEVR_VIEWPORT
49namespace NDEVR
50{
54 class NDEVR_API NDEVRMouseManager
55#if NDEVR_SUPPORTS_THREADING
56 : public Thread
57#endif
58 {
59 public:
60 NDEVRMouseManager();
65 void setUseMouseClicks(bool use_mouse_clicks);
83 static NDEVRMouseManager& defaultInstance();
88 void clearEvents(const WindowInstance* instance);
89#if RUN_MOUSE_MANAGER_THREADED
90 void stopThread() override;
91 virtual void run() override;
92#endif
100 void addTouchEvent(Buffer<Vector<2, fltp04>> location, Vector<2, uint04> size, bool touch_pressed, WindowInstance* instance = nullptr);
113 bool addMouseEvent(QEvent* event, Vector<2, uint04> size, WindowInstance* instance = nullptr);
118 void addMouseEvent(MouseEvent& mouse_event);
125 protected:
128#if RUN_MOUSE_MANAGER_THREADED
129 mutable std::mutex m_critical_section;
130#endif
133
134
136
137 fltp08 m_last_touch_scale_factor = Constant<fltp08>::Invalid;
139 };
140}
141#endif
The default object to store data of any type that should persist through sessions of the application.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Describes a mouse or touch input event with position, button, and modifier information.
Definition Event.h:316
void setUseMouseClicks(bool use_mouse_clicks)
Sets whether mouse click events should be processed.
void processMouseEvent()
Processes the next queued mouse event and dispatches it to the appropriate window.
const Buffer< MouseEvent > & mouseEvents() const
Gets the current buffer of queued mouse events.
Buffer< Vector< 2, fltp04 > > m_last_touch_press_points
The screen locations of active touch points.
bool m_use_mouse_clicks
Whether mouse click events are being processed.
bool m_is_init
Whether the mouse manager has been initialized.
static NDEVRMouseManager & defaultInstance()
Gets the singleton instance of the mouse manager.
void addTouchEvent(Buffer< Vector< 2, fltp04 > > location, Vector< 2, uint04 > size, bool touch_pressed, WindowInstance *instance=nullptr)
Adds a touch event to the queue from raw touch data.
Vector< 2, fltp04 > m_last_mouse_press_point
The screen location of the last mouse press.
fltp08 m_last_touch_scale_factor
The last computed pinch-zoom scale factor.
uint08 m_last_mouse_press_time
The timestamp of the last mouse press event.
Buffer< MouseEvent > m_last_mouse_events
The queue of pending mouse events.
static ApplicationOption< bool > seperate_mouse_thread
Application option controlling whether mouse processing runs on a separate thread.
void clearTouchEvent(WindowInstance *instance)
Clears the active touch event state for the given window instance.
void eraseOldestEvent()
Removes the oldest event from the queue.
MouseEvent oldestEvent() const
Gets the oldest queued mouse event without removing it.
bool addMouseEvent(QEvent *event, Vector< 2, uint04 > size, WindowInstance *instance=nullptr)
Converts a QEvent into a MouseEvent and adds it to the queue.
void addMouseEvent(MouseEvent &mouse_event)
Adds a pre-constructed MouseEvent directly to the queue.
void clearEvents(const WindowInstance *instance)
Clears all queued events associated with the given window instance.
virtual void stopThread()
Stops the thread and waits for it to finish.
Thread()
Constructs a Thread with a default name.
virtual void run()
The main execution body of the thread.
Definition Thread.h:216
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
Contains core information about a Viewport.
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
double fltp08
Defines an alias representing an 8 byte floating-point number.