NDEVR
API Documentation
MouseController.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: Design
28File: MouseController
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Camera.h>
34#if NDEVR_VIEWPORT
35#include <NDEVR/SoftwareService.h>
36#include <NDEVR/Resource.h>
37#include <NDEVR/Event.h>
38#include <NDEVR/INIInterface.h>
39namespace NDEVR
40{
41 class SelectionInfo;
46 {
52 : mouse_event(event)
53 {
54 }
57 Camera* camera = nullptr;
59 };
60
64 class NDEVR_DESIGN_API MouseControllerBase : public SoftwareService
65 {
66 public:
73 virtual bool processMouseEvent(MouseControllerEvent& event, SelectionInfo& info) = 0;
74 };
75 class SnapController;
76
78
89 {
90 public:
100
117
128
154 public:
158 NDEVR_DESIGN_API MouseController();
162 NDEVR_DESIGN_API virtual ~MouseController();
167
168 public:
172 NDEVR_DESIGN_API void setNDEVRDefaults();
178 NDEVR_DESIGN_API MouseAction getAction(const MouseEvent& event) const;
191
199 NDEVR_DESIGN_API bool processMouseEvent(MouseControllerEvent& event, SelectionInfo& info) override;
200
206 NDEVR_DESIGN_API void addController(UUID id, MouseControllerBase* controller);
211 NDEVR_DESIGN_API void removeController(UUID id);
234 const MouseEvent& lastMouseEvent() const { return m_last_mouse_event; }
242 private:
243 Matrix<fltp08> m_parent_transform;
244 CameraAnimation m_original_camera;
245 Vector<2, fltp08> m_screen_percent_0;
246 fltp08 m_last_valid_distance;
247 bool m_is_dragging;
248 bool m_is_mouse_scrolling;
249 bool m_is_touch_scrolling;
250
251 MouseEvent m_last_mouse_event;
252 private:
253
254
259 void getINI(INIFactory& factory) override;
265 void setReferencePoint(ReferencePoint ref, Camera* camera);
274 bool processGrips(MouseControllerEvent& event, const Buffer<UUID>& grips);
275 //void updateCenterOfScreen(DesignObjectLookup* lookup);
283 void updateCenterOfMouse(DesignObjectLookup* lookup, Camera* camera, SelectionInfo& selection, bool update_distance);
291 void setView(MouseAction act, ReferencePoint ref, const Vector<2, fltp08>& screen_percent, Camera* camera);
297 void mouseScrolled(fltp04 scroll_distance, Camera* camera);
303 void touchScrolled(fltp04 scroll_distance, Camera* camera);
310 void mouseClicked(const MouseEvent& e, DesignObjectLookup* lookup, Camera* camera);
316 void mouseChangeView(const MouseEvent& e, Camera* camera);
317 protected:
324 };
325};
326#endif
327
328
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
A core class where all Design Objects including models, materials, and geometries are stored.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:107
INIInterface()
Constructs an INIInterface with no default INI file.
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A base class for adding functionality to the user mouse inputs.
virtual bool processMouseEvent(MouseControllerEvent &event, SelectionInfo &info)=0
Processes a mouse event and updates selection info accordingly.
Holds the configurable action bindings and settings for a single mouse button.
Resource< MouseAction > double_click_action
The action to perform on a double click.
Resource< ReferencePoint > preferred_reference
The preferred reference point for camera operations.
MouseActions()
Default constructor.
MouseActions(const MouseActions &actions)
Copy constructor.
Resource< Vector< 2, bool > > inverted
Whether the X and/or Y axes are inverted for this button.
Resource< MouseSelectionMode > selection_mode
The selection mode used when selecting with this button.
Resource< ReferencePoint > double_click_reference
The reference point used specifically on double-click actions.
Resource< MouseAction > click_action
The action to perform on a single click.
Resource< fltp04 > sensitivity
The sensitivity multiplier for this button's actions.
Resource< MouseAction > drag_action
The action to perform when dragging with this button.
void resetContextMenuRequested()
Resets the context menu request flag to false.
Dictionary< UUID, MouseControllerBase * > m_controller_lookup
Maps controller UUIDs to their instances.
bool m_request_context_menu
Flag indicating a context menu has been requested.
MouseAction getAction(const MouseEvent &event) const
Determines the action to perform for a given mouse event based on current bindings.
bool m_request_selection
Flag indicating a selection has been requested.
bool selectionRequested() const
Checks whether a selection has been requested by a recent mouse event.
void getINI(INIFactory &factory) override
Serializes and deserializes mouse controller settings to/from INI configuration.
bool contextMenuRequested() const
Checks whether a context menu has been requested by a recent mouse event.
const MouseActions & getDefaultAction(MouseEvent::MouseClickType type) const
Gets the const MouseActions for a given mouse click type.
MouseActions wheel_mouse_action
Action bindings for the mouse wheel.
Resource< uint04 > number_of_mouse_events
Counter for total mouse events processed.
Resource< Buffer< UUID > > selected
The currently selected object UUIDs.
void addController(UUID id, MouseControllerBase *controller)
Registers a mouse sub-controller with a given identifier.
MouseActions right_mouse_action
Action bindings for the right mouse button.
DynamicPointer< SnapController > m_snap_controller
Pointer to the snap controller for snapping behavior.
void setNDEVRDefaults()
Resets all mouse action bindings to the NDEVR default configuration.
Resource< UUID > selected_layer
The UUID of the currently selected layer.
Resource< UUID > focus
The UUID of the currently focused object.
MouseActions left_mouse_action
Action bindings for the left mouse button.
bool processMouseEvent(MouseControllerEvent &event, SelectionInfo &info) override
Processes a mouse event, delegating to registered sub-controllers and handling camera manipulation,...
Resource< uint04 > number_of_mouse_clicks
Counter for total mouse clicks processed.
ReferencePoint
Defines the reference point used for camera operations such as orbit and zoom.
@ e_screen_center
Use the center of the screen as the reference point.
@ e_mouse_center
Use the current mouse position as the reference point.
@ e_map_center
Use the center of the map as the reference point.
void removeController(UUID id)
Removes a previously registered mouse sub-controller.
MouseController()
Constructs a MouseController with default settings.
bool m_ignore_next_event_if_click
If true, the next click event will be ignored.
Buffer< MouseControllerBase * > m_controllers
Ordered list of registered sub-controllers.
Resource< String > cursor
The current cursor icon name.
const MouseEvent & lastMouseEvent() const
Returns the last mouse event that was processed.
MouseActions & getDefaultAction(MouseEvent::MouseClickType type)
Gets the mutable MouseActions for a given mouse click type.
void resetSelectionRequested()
Resets the selection request flag to false.
MouseSelectionMode
Defines which type of design object is targeted during mouse selection.
@ e_select_model_base
Select model base objects.
@ e_select_model
Select whole models.
@ e_select_geometry
Select individual geometry.
@ e_select_bone
Select bone/skeleton elements.
@ e_select_material
Select materials.
virtual ~MouseController()
Destructor.
MouseActions center_mouse_action
Action bindings for the center (middle) mouse button.
MouseAction
Defines the possible actions that can be bound to a mouse button interaction.
@ e_context_menu
Show a context menu.
@ e_look_around
Rotate the camera view direction (first-person look).
@ e_zoom
Zoom the camera toward the reference point.
@ e_orbit
Orbit the camera around the reference point.
@ e_inv_select
Inverted selection (deselect or toggle selection).
@ e_inv_zoom
Zoom the camera away from the reference point (inverted zoom).
@ e_ignore
No action; the mouse input is ignored.
@ e_pan
Pan the camera in the view plane.
@ e_select
Select the object under the cursor.
@ e_command
Execute a custom command.
Resource< String > information
Informational text associated with current mouse state.
Describes a mouse or touch input event with position, button, and modifier information.
Definition Event.h:316
MouseClickType
Identifies which mouse button was involved in the event.
Definition Event.h:338
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Resource.h:42
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:52
Allows for mouse snaps to certain key points of interest in the software.
Software Service Managers take a Software service to modify the behavior of the software.
Base interface for services that extend or modify software behavior through modules.
The core String class for the NDEVR API.
Definition String.h:95
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
Definition Model.h:58
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
A container for information relating to a Camera 3D animation such as zooming or rotating around a ta...
A wrapper for a mouse event that is used by MouseControllerBase.
String cursor
The cursor icon name to display for this event.
MouseControllerEvent(const MouseEvent &event)
Constructs a MouseControllerEvent from a MouseEvent.
const MouseEvent mouse_event
The original mouse event data.
DesignObjectLookup * lookup
Pointer to the design object lookup context.
Camera * camera
Pointer to the camera associated with this event.