API Documentation
Loading...
Searching...
No Matches
Selector.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: Design
28File: Selector
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Model.h>
34#include <NDEVR/Material.h>
35#include <NDEVR/SnapsManager.h>
36#include <NDEVR/ModelIterator.h>
37#include <NDEVR/DesignSelection.h>
38#include <NDEVR/SelectionArea.h>
39#include <functional>
40
41namespace NDEVR
42{
43 enum class PrimitiveMode;
44 struct GeometryVertices;
45
46 /**--------------------------------------------------------------------------------------------------
47 \brief Responsible for turning a user interaction into a selection within a DesignObjectLookup
48 **/
50 {
51 public:
69
71 void clear();
73 void pushTransform(const Matrix<fltp08>& transform, bool apply_to_original);
75 ParseResult process(Model& model) override;
76 ParseResult postProcess(Model& model) override;
77 ParseResult process(Model& model, Material& mat) override;
78 ParseResult process(Model& model, Geometry& geo) override;
79
80 bool processGeometry(const Geometry& geo, PrimitiveProperty primitive_property);
81
82 fltp08 screenClosestDistanceSqr(bool outer_bound) const;
85 void setNearestGeometry(const Geometry& geo, PrimitiveMode primitive_mode, uint04 index, uint04 vertex);
86 //returns true if recommended adjust line
87 bool setNearestScreenPosition(PrimitiveMode mode, const Vertex<3, fltp08>& screen_point, fltp08 screen_distance);
89 void setNearestModel(PrimitiveMode mode, const Model& model);
90 void setNearestMaterial(PrimitiveMode mode, const UUID& material);
91 void setNearestLayer(PrimitiveMode mode, const UUID& layer);
93 bool validModelSelection(const Model& model) const;
94 void setAllowSolidInteraction(bool allow_solid_intersection) { m_allow_solid_intersection = allow_solid_intersection; }
95 bool allowSolidInteraction() const { return m_allow_solid_intersection; }
100
102
103 UUID uuid() const { return m_id; }
104 bool operator==(const SelectionInfo&) const { return false; }
117 fltp08 min_screen_cutoff_distance = 0.0;
118 fltp08 screen_point_bias = 0.0;
119 fltp08 screen_line_bias = 0.0;
123 bool is_edit = false;
124 bool is_exact = true;
125 bool use_interaction_flag = true;
126 bool mask_added = false;
127 bool mask_subtracted = true;
128 bool allow_inverse_trans = false;
129 std::function<bool(const Model&)> selection_filter;//Once a selection is made, filters the appropriate parent, returns true if selectable
130 private:
131 struct ProcessStruct
132 {
133 Geometry geo;
134 SelectionArea<3, fltp08> perspective_selection;
135 SelectionArea<3, fltp08> linear_selection;
136 PrimitiveProperty primitive_property;
137 PrimitiveMode primitive_mode;
138 Buffer<uint04> indices;
139 Buffer<bool> selection_mask;
140 fltp04 linear_distance;
141 fltp04 perspective_distance;
142 };
143 void _processGeometryNoTree(ProcessStruct& geo);
144 void _processGeometryWithTree(ProcessStruct& geo);
145 bool _doesIntersect(const Model& model) const;
146 bool _processLineSelection(ProcessStruct& pstruct);
147 bool _processLineSelection(uint04 current_index, ProcessStruct& pstruct);
148 protected:
154 };
155}
156
157
158
159
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A simple structure for storing a collection of data.
Definition DesignSelection.h:26
A core class within the model heirarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:64
A line segment represented by two vertices, a start and end.
Definition Line.hpp:49
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:51
Definition Matrix.hpp:176
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
A base class for easily transversing a model heirarchy, applying an overritten function at each level...
Definition ModelIterator.h:43
ParseResult
Definition ModelIterator.h:46
An area of N-dimensional space that is considered selected.
Definition SelectionArea.hpp:59
uint04 nearest_vertex
Definition Selector.h:66
UUID nearest_layer
Definition Selector.h:63
UUID nearest_material
Definition Selector.h:62
fltp08 screen_distance
Definition Selector.h:64
UUID nearest_model
Definition Selector.h:61
UUID nearest_geometry
Definition Selector.h:60
uint04 nearest_index
Definition Selector.h:65
Matrix< fltp08 > geometry_transform
Definition Selector.h:58
Vertex< 3, fltp08 > screen_location
Definition Selector.h:59
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:50
DesignSelection selection
Definition Selector.h:112
bool setNearestScreenPosition(PrimitiveMode mode, const Vertex< 3, fltp08 > &screen_point, fltp08 screen_distance)
ClosestModelInfo nearest_point
Definition Selector.h:113
Buffer< Matrix< fltp08 > > m_pushed_transforms
Definition Selector.h:150
ClosestModelInfo nearest_solid
Definition Selector.h:115
ParseResult process(Model &model) override
void pushTransform(const Matrix< fltp08 > &transform, bool apply_to_original)
bool operator==(const SelectionInfo &) const
Definition Selector.h:104
Buffer< Buffer< Matrix< fltp08 > > > m_pushed_mask_transforms
Definition Selector.h:151
void setGeometryTransform(PrimitiveMode mode, const Matrix< fltp08 > &mat)
ParseResult process(Model &model, Geometry &geo) override
bool allowSolidInteraction() const
Definition Selector.h:95
void setNearestMaterial(PrimitiveMode mode, const UUID &material)
fltp08 localClosestDistanceSqr(PrimitiveMode mode) const
fltp08 screenClosestDistanceSqr(bool outer_bound) const
ParseResult postProcess(Model &model) override
void getEnclosedVertices(GeometryVertices &vertices) const
Vertex< 3, fltp08 > world_nearest_location
Definition Selector.h:111
UUID m_id
Definition Selector.h:152
Vertex< 3, fltp08 > nearestScreenLocation() const
UUID uuid() const
Definition Selector.h:103
void setNearestGeometry(const Geometry &geo, PrimitiveMode primitive_mode, uint04 index, uint04 vertex)
ParseResult process(Model &model, Material &mat) override
void setAllowSolidInteraction(bool allow_solid_intersection)
Definition Selector.h:94
WindingMode selection_winding_mode
Definition Selector.h:116
Buffer< SelectionArea< 3, fltp08 > > selection_masks
Definition Selector.h:109
fltp08 screenClosestDistanceSqr(PrimitiveMode mode) const
LineSegment< 3, fltp08 > world_selection_line
Definition Selector.h:110
bool processGeometry(const Geometry &geo, PrimitiveProperty primitive_property)
Bounds< 3, fltp08 > globalSelectionBounds() const
Material override_material
Definition Selector.h:107
SelectionArea< 3, fltp08 > current_selection
Definition Selector.h:108
Bounds< 3, fltp08 > selectionBounds() const
ClosestModelInfo nearest_line
Definition Selector.h:114
bool m_allow_solid_intersection
Definition Selector.h:153
UUID nearestModel() const
void setNearestModel(PrimitiveMode mode, const Model &model)
std::function< bool(const Model &)> selection_filter
Definition Selector.h:129
UUID nearestGeometry(PrimitiveMode mode) const
bool validModelSelection(const Model &model) const
void updateLineEndPoint(PrimitiveMode mode, Vertex< 3, fltp08 > vec)
void setNearestLayer(PrimitiveMode mode, const UUID &layer)
Buffer< Model > m_valid_model_stack
Definition Selector.h:149
Vertex< 3, fltp08 > nearestWorldLocation() const
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
A vertex or point. A specific type of Vector used primarily for spacial location information.
Definition Vertex.hpp:48
Definition ACIColor.h:37
PrimitiveProperty
Definition DesignObjectBase.h:44
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
Definition DesignObjectBase.h:116
WindingMode
Definition DesignObjectBase.h:97
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
An container for storing some number of vertices for editing.
Definition GeometryVertices.h:18