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;
46 {
47 public:
65
67 void clear();
68 void clearLastSelection();
69 void pushTransform(const Matrix<fltp08>& transform, bool apply_to_original);
70 void popTransform();
71 ParseResult process(Model& model) override;
72 ParseResult postProcess(Model& model) override;
73 ParseResult process(Model& model, Material& mat) override;
74 ParseResult process(Model& model, Geometry& geo) override;
75
76 bool processGeometry(const Geometry& geo, PrimitiveProperty primitive_property);
77
78 fltp08 screenClosestDistanceSqr(bool outer_bound) const;
79 fltp08 screenClosestDistanceSqr(PrimitiveMode mode) const;
80 fltp08 localClosestDistanceSqr(PrimitiveMode mode) const;
81 void setNearestGeometry(const Geometry& geo, PrimitiveMode primitive_mode, uint04 index, uint04 vertex);
82 //returns true if recommended adjust line
83 bool setNearestScreenPosition(PrimitiveMode mode, const Vertex<3, fltp08>& screen_point, fltp08 screen_distance);
84 void setGeometryTransform(PrimitiveMode mode, const Matrix<fltp08>& mat);
85 void setNearestModel(PrimitiveMode mode, const Model& model);
86 void setNearestMaterial(PrimitiveMode mode, const UUID& material);
87 void setNearestLayer(PrimitiveMode mode, const UUID& layer);
88 void updateLineEndPoint(PrimitiveMode mode, Vertex<3, fltp08> vec);
89 bool validModelSelection(const Model& model) const;
90 void setAllowSolidInteraction(bool allow_solid_intersection) { m_allow_solid_intersection = allow_solid_intersection; }
91 bool allowSolidInteraction() const { return m_allow_solid_intersection; }
92 UUID nearestModel() const;
93 Vertex<3, fltp08> nearestScreenLocation() const;
94 Vertex<3, fltp08> nearestWorldLocation() const;
95 UUID nearestGeometry(PrimitiveMode mode) const;
96
97 void getEnclosedVertices(GeometryVertices& vertices) const;
98
99 UUID uuid() const { return m_id; }
100 bool operator==(const SelectionInfo&) const { return false; }
101 Bounds<3, fltp08> selectionBounds() const;
102 Bounds<3, fltp08> globalSelectionBounds() const;
113 fltp08 min_screen_cutoff_distance = 0.0;
114 fltp08 screen_point_bias = 0.0;
115 fltp08 screen_line_bias = 0.0;
116 UUID current_model = Constant<UUID>::NaN;
119 bool is_edit = false;
120 bool is_exact = true;
121 bool use_interaction_flag = true;
122 bool mask_added = false;
123 bool mask_subtracted = true;
124 bool allow_inverse_trans = false;
125 std::function<bool(const Model&)> selection_filter;//Once a selection is made, filters the appropriate parent, returns true if selectable
126 protected:
139 void _processGeometryNoTree(ProcessStruct& geo);
140 void _processGeometryWithTree(ProcessStruct& geo);
141 bool _doesIntersect(const Model& model) const;
142 bool _processLineSelection(ProcessStruct& pstruct);
143 bool _processLineSelection(uint04 current_index, ProcessStruct& pstruct);
144 protected:
150 };
151}
152
153
154
155
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition DesignSelection.h:19
Definition Geometry.h:64
A line segment represented by two vertices, a start and end.
Definition Line.hpp:55
Definition Material.h:45
Definition Matrix.hpp:173
Definition Model.h:54
Definition ModelIterator.h:39
ParseResult
Definition ModelIterator.h:42
Definition SelectionArea.hpp:52
uint04 nearest_vertex
Definition Selector.h:62
UUID nearest_layer
Definition Selector.h:59
UUID nearest_material
Definition Selector.h:58
fltp08 screen_distance
Definition Selector.h:60
UUID nearest_model
Definition Selector.h:57
UUID nearest_geometry
Definition Selector.h:56
uint04 nearest_index
Definition Selector.h:61
Matrix< fltp08 > geometry_transform
Definition Selector.h:54
Vertex< 3, fltp08 > screen_location
Definition Selector.h:55
Definition Selector.h:46
DesignSelection selection
Definition Selector.h:108
ClosestModelInfo nearest_point
Definition Selector.h:109
Buffer< Matrix< fltp08 > > m_pushed_transforms
Definition Selector.h:146
ClosestModelInfo nearest_solid
Definition Selector.h:111
bool operator==(const SelectionInfo &) const
Definition Selector.h:100
Buffer< Buffer< Matrix< fltp08 > > > m_pushed_mask_transforms
Definition Selector.h:147
bool allowSolidInteraction() const
Definition Selector.h:91
Vertex< 3, fltp08 > world_nearest_location
Definition Selector.h:107
UUID m_id
Definition Selector.h:148
UUID uuid() const
Definition Selector.h:99
void setAllowSolidInteraction(bool allow_solid_intersection)
Definition Selector.h:90
WindingMode selection_winding_mode
Definition Selector.h:112
Buffer< SelectionArea< 3, fltp08 > > selection_masks
Definition Selector.h:105
LineSegment< 3, fltp08 > world_selection_line
Definition Selector.h:106
Material override_material
Definition Selector.h:103
SelectionArea< 3, fltp08 > current_selection
Definition Selector.h:104
ClosestModelInfo nearest_line
Definition Selector.h:110
bool m_allow_solid_intersection
Definition Selector.h:149
std::function< bool(const Model &)> selection_filter
Definition Selector.h:125
Buffer< Model > m_valid_model_stack
Definition Selector.h:145
Definition UUID.h:66
A vertex.
Definition Vertex.hpp:54
Definition ACIColor.h:37
PrimitiveProperty
Definition DesignObjectBase.h:44
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
PrimitiveMode
Definition DesignObjectBase.h:113
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:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition BaseValues.hpp:272
Definition GeometryVertices.h:14
Definition Selector.h:128
fltp04 perspective_distance
Definition Selector.h:137
SelectionArea< 3, fltp08 > linear_selection
Definition Selector.h:131
PrimitiveMode primitive_mode
Definition Selector.h:133
Geometry geo
Definition Selector.h:129
SelectionArea< 3, fltp08 > perspective_selection
Definition Selector.h:130
PrimitiveProperty primitive_property
Definition Selector.h:132
Buffer< bool > selection_mask
Definition Selector.h:135
Buffer< uint04 > indices
Definition Selector.h:134
fltp04 linear_distance
Definition Selector.h:136