NDEVR
API Documentation
SelectionController.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: SelectionController
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/SelectionArea.h>
34#include <NDEVR/SnapController.h>
35#if NDEVR_VIEWPORT
36namespace NDEVR
37{
49
59 class NDEVR_DESIGN_API SelectionController : public SnapController
60 {
61 public:
65
68
70 virtual void begin() override;
71
73 virtual void finish() override;
74
76 virtual void cancel() override;
77
80 bool isInvertedSelection() const;
81
84 void setInvertedSelection(bool is_inside);
85
89
94
98
102
105
108 void setCameraShowGrid(bool show_grid);
109
112 void setCameraShowEnvironment(bool show_grid);
113
116 void removeMask(uint04 mask_index);
117
120 void highlightMask(uint04 mask_index);
121
124
128
132 void setMaskEnabled(uint04 index, bool enabled);
133
137
141
146
150
155 virtual bool processMouseEvent(MouseControllerEvent& event, SelectionInfo& info) override;
156
162 virtual bool processKeyEvent(const KeyEvent& event, DesignObjectLookup* lookup, Camera* camera) override;
163
167
171
175 void clear(bool clear_selection, bool clear_masks);
176
179 void setHideMaskExclusion(bool is_hidden);
180
184
187 void darkenMaskExclusion(bool darken);
188
194 void setPreModelFilter(const std::function<bool(const Model&)>& pre_model_filter);
195
201 void setPreGeometryFilter(const std::function<bool(const Model&, const Geometry&)>& pre_geometry_filter);
202
207 void setSelectionFilter(const std::function<bool(const Model&)>& selection_filter);
208
211 void setIsEditSelection(bool is_edit_selection);
212
213 protected:
217
220
223
226
227 protected:
229 UUID m_original_camera = Constant<UUID>::Invalid;
243 };
244}
245#endif
246
247
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 core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Describes a user key press event used to trigger behavior in the NDEVR API.
Definition Event.h:49
A core class that represents a node on model hierarchy.
Definition Model.h:292
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
An area of N-dimensional space that is considered selected.
void setInvertedSelection(bool is_inside)
Sets whether selection is inverted.
virtual void finish() override
Finishes and commits the current selection.
virtual void begin() override
Begins the selection interaction session.
bool selectionComplete() const
Checks whether the user has completed the selection.
void highlightMask(uint04 mask_index)
Visually highlights a specific mask.
void setCameraShowGrid(bool show_grid)
Sets whether the camera grid is shown.
uint04 m_highlighted_mask
Index of the currently highlighted mask, or invalid if none.
void setCameraShowEnvironment(bool show_grid)
Sets whether the camera environment (skybox/background scene) is shown.
SubSelectionMode subSelectionMode() const
Returns the current sub-selection mode.
void setSelectionMaskInfo(const SelectionInfo &info)
Stores the selection mask info from the given SelectionInfo.
void setSubSelectionMode(const SubSelectionMode &mode)
Sets the sub-selection mode (single model, vertex rectangle, vertex polygon, etc.).
const Buffer< SelectionArea< 3, fltp08 > > & masks() const
Returns a read-only reference to all current selection masks.
void updateSelectionMask()
Updates the visual representation of selection masks.
void updateCameraBackgrounds()
Updates all camera backgrounds to reflect the current theme or mask state.
void darkenMaskExclusion(bool darken)
Sets whether mask-excluded geometry should be darkened.
virtual bool processMouseEvent(MouseControllerEvent &event, SelectionInfo &info) override
Processes a mouse event for selection interaction.
void setHideMaskExclusion(bool is_hidden)
Sets whether geometry excluded by masks should be hidden entirely.
Buffer< UUID > m_last_mask_geometries
UUIDs of geometries created for the last set of masks.
void clear(bool clear_selection, bool clear_masks)
Clears the selection state and/or masks.
void clearMaskHighlight()
Clears any active mask highlight.
bool m_inverted_selection
Whether selection logic is inverted (select outside).
void setIsEditSelection(bool is_edit_selection)
Sets whether this selection controller is operating in edit-selection mode.
virtual bool processKeyEvent(const KeyEvent &event, DesignObjectLookup *lookup, Camera *camera) override
Processes a keyboard event for selection interaction.
void updateSelectionInfo(SelectionInfo &info)
Updates the provided SelectionInfo with the current selection state.
void setSelectionFilter(const std::function< bool(const Model &)> &selection_filter)
Sets a filter applied after a selection is made to resolve the appropriate parent.
SelectionInfo m_selection_mask_info
Selection info used only when selecting mask objects.
bool m_darken_mask_exclusion
Whether to darken geometry excluded by masks instead of hiding.
void removeMask(uint04 mask_index)
Removes a mask by index.
bool m_is_edit_selection
Whether the controller is in edit-selection mode.
bool m_temp_inverted
Temporary inversion state (e.g., while holding a modifier key).
UUID currentSelection() const
Returns the UUID of the currently selected object.
void clearMasks()
Clears all selection masks.
UUID m_original_camera
UUID of the camera state before selection began.
void setMaskEnabled(uint04 index, bool enabled)
Enables or disables a specific mask by index.
bool m_selection_complete
Whether the user has finished making a selection.
virtual void cancel() override
Cancels the current selection operation without committing.
String currentSelectionHint() const
Returns a hint string describing the current selection state.
void setPreGeometryFilter(const std::function< bool(const Model &, const Geometry &)> &pre_geometry_filter)
Sets a filter applied before testing a geometry within a model for selection.
void setThemeCameraBackgroundColor(const RGBColor &color)
Sets the fallback camera background color used when no theme default is available.
SelectionController(DesignObjectLookup *manager)
Constructs a SelectionController for the given design object lookup.
uint04 addMask(const SelectionArea< 3, fltp08 > &mask)
Adds a 3D selection area as a mask.
virtual ~SelectionController()
Destructor.
bool m_hide_mask_exclusion
Whether to hide geometry excluded by masks.
void setPreModelFilter(const std::function< bool(const Model &)> &pre_model_filter)
Sets a filter applied before testing a model for selection.
SubSelectionMode m_sub_selection_mode
The current sub-selection mode.
void clearSelection()
Clears the active selection state.
Buffer< UUID > m_last_selection_geometries
UUIDs of geometries created for the last selection.
TranslatedString defaultHint(const TranslatedString &action_hint) const
Returns a default hint string combining the action hint with selection context.
bool darkensMaskExclusion() const
Checks whether mask-excluded geometry is darkened rather than hidden.
bool isInvertedSelection() const
Checks whether the selection logic is inverted (selecting outside rather than inside).
SelectionInfo m_selection_highlight_info
Saved selection info for restoring previous highlight state.
SelectionInfo m_selection_info
The active selection info for the current interaction.
UUID m_current_selection
UUID of the currently selected object.
uint04 addCurrentAsMask()
Converts the current selection into a mask and adds it.
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:52
SnapController(DesignObjectLookup *manager)
Constructs a SnapController associated with the given DesignObjectLookup.
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
SubSelectionMode
Defines the mode of sub-selection used by the SelectionController.
@ e_no_selection
Selection is disabled.
@ e_vertex_polygon_selection
Select vertices within a polygon region.
@ e_vertex_rectangle_selection
Select vertices within a rectangular region.
@ e_sub_selection_size
The number of sub-selection modes (sentinel value).
@ e_single_model
Select a single model at a time.
A wrapper for a mouse event that is used by MouseControllerBase.