API Documentation
Loading...
Searching...
No Matches
NDEVRMouseManager.h
Go to the documentation of this file.
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 1
45#else
46#define RUN_MOUSE_MANAGER_THREADED 0
47#endif
48#if NDEVR_VIEWPORT
49namespace NDEVR
50{
51 /**--------------------------------------------------------------------------------------------------
52 \brief Handles converting QEvents into NDEVR MouseEvents and queuing them up appropriately.
53 **/
54 class NDEVR_API NDEVRMouseManager
55#if NDEVR_SUPPORTS_THREADING
56 : public Thread
57#endif
58 {
59 public:
60 NDEVRMouseManager();
61 void setUseMouseClicks(bool use_mouse_clicks);
62 void processMouseEvent();
63 void eraseOldestEvent();
64 MouseEvent oldestEvent() const;
65 static NDEVRMouseManager& defaultInstance();
66 void clearEvents(const WindowInstance* instance);
67#if RUN_MOUSE_MANAGER_THREADED
68 void stopThread() override;
69 virtual void run() override;
70#endif
71 void addTouchEvent(Buffer<Vector<2, fltp04>> location, Vector<2, uint04> size, bool touch_pressed, WindowInstance* instance = nullptr);
72 void clearTouchEvent(WindowInstance* instance);
73 bool addMouseEvent(QEvent* event, Vector<2, uint04> size, WindowInstance* instance = nullptr);
74 void addMouseEvent(MouseEvent& mouse_event);
75 const Buffer<MouseEvent>& mouseEvents() const;
76 static ApplicationOption<bool> seperate_mouse_thread;
77 protected:
78 bool m_is_init;
79 bool m_use_mouse_clicks;
80#if RUN_MOUSE_MANAGER_THREADED
81 mutable std::mutex m_critical_section;
82#endif
83 Buffer<MouseEvent> m_last_mouse_events;
84 Vector<2, fltp04> m_last_mouse_press_point;
85
86
87 Vector<2, Vector<2, fltp04>> m_last_touch_press_point = Constant<Vector<2, Vector<2, fltp04>>>::Invalid;
88
89 fltp08 m_last_touch_scale_factor = Constant<fltp08>::Invalid;
90 uint08 m_last_mouse_press_time;
91 };
92}
93#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
94#undef position
95#undef points
96#endif
97#endif
#define NDEVR_API
Definition DLLInfo.h:50
Definition ACIColor.h:37