NDEVR
API Documentation
SnapsManager.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: SnapsManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/SnapPoint.h>
35#include <NDEVR/LineSegment.h>
36#include <NDEVR/Triangle.h>
37#include <NDEVR/Dictionary.h>
38#include <NDEVR/UUID.h>
39#include <NDEVR/Buffer.h>
40namespace NDEVR
41{
42 class DesignObjectLookup;
43 class SelectionInfo;
44 class String;
45
55 class NDEVR_DESIGN_API SnapsManager
56 {
57 public:
60
65
72
78 SnapPoint getSnapPoint(const DesignObjectLookup* manager, const SelectionInfo& info, bool use_worldspace) const;
79
85 void getSnapPoint(SnapPoint& current, const DesignObjectLookup* manager, const SelectionInfo& info, bool use_worldspace) const;
86
94 SnapPoint getSnapLinePoint(const DesignObjectLookup* manager, const SelectionInfo& info, const SnapPoint& last, const Buffer<std::pair<UUID, uint04>>& locations_of_interest, bool use_worldspace) const;
95
103 void getSnapLinePoint(SnapPoint& current, const DesignObjectLookup* manager, const SelectionInfo& info, const SnapPoint& last, const Buffer<std::pair<UUID, uint04>>& locations_of_interest, bool use_worldspace) const;
104
113 bool checkVertex(SnapPoint::SnapLocationType snap, const SelectionInfo& info, const Vertex<3, fltp08>& point, SnapPoint& closest_snap, UUID id, uint04 index) const;
114
126 bool checkLine(const SelectionInfo& info, const LineSegment<3, fltp08>& seg, bool infinite_length, SnapPoint& closest_snap, SnapPoint::SnapLocationType line_snap, SnapPoint::SnapLocationType edge_snap, UUID id, uint04 index, bool is_smooth) const;
127
136 bool checkTriangle(const SelectionInfo& info, const Triangle<3, fltp08>& tri, SnapPoint& closest_snap, UUID id, uint04 index, bool is_smooth) const;
137
142
146 void setSnapEnabled(SnapPoint::SnapLocationType snap, bool use_snap) { m_enabled_snaps[snap] = use_snap; }
147
150 void setAllEnabled(bool use_snap);
151
156 protected:
160 };
161}
162
163
164
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
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
Class: LineSegment.
Definition Line.hpp:52
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:52
Contains information about a particular point of interest created from a user mouse interaction.
Definition SnapPoint.h:46
SnapLocationType
Defines the type of geometric feature that was snapped to.
Definition SnapPoint.h:52
void getSnapLinePoint(SnapPoint &current, const DesignObjectLookup *manager, const SelectionInfo &info, const SnapPoint &last, const Buffer< std::pair< UUID, uint04 > > &locations_of_interest, bool use_worldspace) const
Finds the best snap point constrained to a line, updating an existing SnapPoint in place.
Dictionary< SnapPoint::SnapLocationType, fltp08 > m_sensitivity
Maps each snap type to its sensitivity distance threshold.
void getSnapPoint(SnapPoint &current, const DesignObjectLookup *manager, const SelectionInfo &info, bool use_worldspace) const
Finds the best snap point, updating an existing SnapPoint in place.
bool checkLine(const SelectionInfo &info, const LineSegment< 3, fltp08 > &seg, bool infinite_length, SnapPoint &closest_snap, SnapPoint::SnapLocationType line_snap, SnapPoint::SnapLocationType edge_snap, UUID id, uint04 index, bool is_smooth) const
Checks whether a line segment qualifies as a snap candidate and updates the closest snap if so.
void setSnapEnabled(SnapPoint::SnapLocationType snap, bool use_snap)
Enables or disables a specific snap location type.
static StringView SnapIcon(SnapPoint::SnapLocationType snap_type)
Returns the icon name associated with a snap location type.
bool isSnapEnabled(SnapPoint::SnapLocationType snap) const
Checks whether a specific snap location type is currently enabled.
void setAllEnabled(bool use_snap)
Enables or disables all snap location types at once.
bool checkTriangle(const SelectionInfo &info, const Triangle< 3, fltp08 > &tri, SnapPoint &closest_snap, UUID id, uint04 index, bool is_smooth) const
Checks whether a triangle qualifies as a snap candidate and updates the closest snap if so.
SnapPoint getSnapLinePoint(const DesignObjectLookup *manager, const SelectionInfo &info, const SnapPoint &last, const Buffer< std::pair< UUID, uint04 > > &locations_of_interest, bool use_worldspace) const
Finds the best snap point constrained to a line from a previous snap point.
void setSensitivity(SnapPoint::SnapLocationType type, fltp08 sensitivity)
Sets the sensitivity radius for a specific snap location type.
Dictionary< SnapPoint::SnapLocationType, bool > m_enabled_snaps
Maps each snap type to its enabled/disabled state.
Dictionary< SnapPoint::SnapLocationType, uint04 > m_priority
Maps each snap type to its priority for conflict resolution.
void setPriority(SnapPoint::SnapLocationType type, uint04 priority)
Sets the priority for a specific snap location type.
SnapsManager()
Constructs a SnapsManager with default snap settings.
bool checkVertex(SnapPoint::SnapLocationType snap, const SelectionInfo &info, const Vertex< 3, fltp08 > &point, SnapPoint &closest_snap, UUID id, uint04 index) const
Checks whether a vertex qualifies as a snap candidate and updates the closest snap if so.
SnapPoint getSnapPoint(const DesignObjectLookup *manager, const SelectionInfo &info, bool use_worldspace) const
Finds the best snap point for the given selection info.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A three-vertex polygon representing a triangle in N-dimensional space.
Definition Triangle.hpp:142
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
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...
double fltp08
Defines an alias representing an 8 byte floating-point number.