NDEVR
API Documentation
MeasurementManager.h
1#pragma once
2/*--------------------------------------------------------------------------------------------
3Copyright (c) 2019, NDEVR LLC
4tyler.parke@ndevr.org
5 __ __ ____ _____ __ __ _______
6 | \ | | | __ \ | ___|\ \ / / | __ \
7 | \ | | | | \ \ | |___ \ \ / / | |__) |
8 | . \| | | |__/ / | |___ \ V / | _ /
9 | |\ |_|_____/__|_____|___\_/____| | \ \
10 |__| \__________________________________| \__\
11
12Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
13Licensee a limited, non-exclusive, non-transferable, royalty-free license
14(without the right to sublicense) to use the API solely for the purpose of
15Licensee's internal development efforts to develop applications for which
16the API was provided.
17
18The above copyright notice and this permission notice shall be included in all
19copies or substantial portions of the Software.
20
21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
24FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26DEALINGS IN THE SOFTWARE.
27
28Library: Design
29File: GeometryMaker
30Included in API: True
31Author(s): Tyler Parke
32 *-----------------------------------------------------------------------------------------**/
33#pragma once
34#include <NDEVR/SnapController.h>
35#if NDEVR_VIEWPORT && NDEVR_MEASURE_MODELS
36#include <NDEVR/PointMeasureModel.h>
37#include <NDEVR/CrossSectionModel.h>
38#include <NDEVR/CommandLockObject.h>
39namespace NDEVR
40{
49 class NDEVR_DESIGN_API MeasurementManager : public SnapController
50 {
51 class KeyManager;
52 public:
56 enum MeasureMode : uint01
57 {
58 e_no_measurement
59 , e_measure_points
60 , e_measure_distance
61 , e_measure_angle
62 , e_measure_cross_section
63 , e_measurement_mode_size
64 };
65
69 enum AngleMode
70 {
71 e_track_mouse
72 , e_clockwise
73 , e_counter_clockwise
74 };
75
80 MeasurementManager(DesignObjectLookup* manager);
81
85 ~MeasurementManager();
86
90 void createNewModel();
91
96 void addMeasurementPoint(const Vertex<3, fltp08>& point);
97
101 virtual void cancel() override;
102
107 const UUID& rootModelID() const { return m_root_model; }
108
113 const UUID& currentModel() const { return m_current_model; }
114
119 Model rootModel() const;
120
124 void updateFont();
125
129 void discardModels();
130
134 void finishModels();
135
140 void setGenerateNormals(bool generate_normals);
141
146 void setAutoWind(bool auto_wind_shapes);
147
152 void setRootModel(UUID model);
153
158 void setIsTouch(bool touch_mode);
159
164 bool tryCommandLock();
165
170 bool hasCommandLock();
171
176 void lockMovement(bool lock_movement) { m_lock_movement = lock_movement; }
177
182 bool movementLocked() const { return m_lock_movement; }
183
188 Buffer<UUID> measurementModelIDs() const;
189
194 TranslatedString getHint() const;
195
199 void calculateCrossSection();
200
205 Buffer<PointMeasureModel> pointMeasurements() const;
206
211 void setPointNamingFormat(const TranslatedString& naming_format);
212
217 void setDistanceNamingFormat(const TranslatedString& naming_format);
218
223 void setAngleNamingFormat(const TranslatedString& naming_format);
224
229 void setPointType(const BitFlag& point_types);
230
235 void setLineEdgeType(const BitFlag& point_types);
236
241 void setMarkerScale(fltp08 thickness);
242
247 BitFlag pointType() const { return m_point_type; }
248
253 BitFlag lineEdgeType() const { return m_line_edge_type; }
254
259 Buffer<AngleMeasureModel> angleMeasurements() const;
260
265 const TranslatedString& pointNamingFormat() const { return m_point_naming_format; }
266
271 const TranslatedString& distanceNamingFormat() const { return m_distance_naming_format; }
272
277 bool useLineLeader() const { return m_use_line_leader; }
278
283 bool usePointLeader() const { return m_use_point_leader; }
284
289 void setUsePointLeader(bool use) { m_use_point_leader = use; }
290
295 void setUseLineLeader(bool use) { m_use_line_leader = use; }
296
301 const TranslatedString& rootName() const { return m_root_name; }
302
307 void setRootName(const TranslatedString& name);
308
313 void setCrossSectionSpacing(const Vector<3, fltp08>& spacing);
314
319 void setCrossSectionalCenterlineRange(const Vector<2, fltp08>& spacing);
320
325 void setCrossSectionalPointRange(const fltp08 distance);
326
331 fltp08 crossSectionalPointDistance() const { return m_max_point_distance;}
332
337 Vector<3, fltp08> crossSectionSpacing() const { return m_cross_section_spacing; }
338
343 void setUseParallelVertical(bool use) { m_cross_section_vertical_parallel = use; };
344
349 void setUseParallelHorizontal(bool use) { m_cross_section_horizontal_parallel = use; };
350
355 void setUseOrthogonal(bool use) { m_cross_section_orthogonal = use; };
356
361 void setUseVerticalOrthogonal(bool use) { m_cross_section_vertical_orthogonal = use; };
362
367 bool useParallelVertical() const { return m_cross_section_vertical_parallel; };
368
373 bool useParallelHorizontal() const { return m_cross_section_horizontal_parallel; };
374
379 bool useOrthogonal() const { return m_cross_section_orthogonal; };
380
385 bool useVerticalOrthogonal() const { return m_cross_section_vertical_orthogonal; };
386
391 Vector<2, fltp08> crossSectionalCenterlineRange() const { return m_cross_section_centerline_range; }
392
397 void setAngleMode(const AngleMode& mode) { m_angle_mode = mode; }
398
403 AngleMode angleMode() const { return m_angle_mode; }
404
409 void setAutoSetLockPlane(bool autoset_lock_plane);
410
414 virtual void finish() override;
415
419 virtual void undo();
420 public:
421 Resource<MeasureMode> measure_mode;
422 protected:
426 virtual void begin() override;
427
433 void autoName(const Model& model, uint04 index);
434
442 void calculateSolid(Geometry& mesh);
443
448 Model createRootModel();
449
456 virtual void setupSelectionInfo(const MouseEvent& event, Camera* camera, SelectionInfo& info) override;
457
463 void updatePrimitive(const Vertex<3, fltp08>& world_location, Camera* camera);
464
469 void onSelect(Camera* camera);
470
477 static Vector<3, Angle<fltp08>> getOrientation(const Vector<3, fltp08>& lookat, const Vector<3, fltp08>& up);
478
485 virtual bool processMouseEvent(MouseControllerEvent& event, SelectionInfo& info) override;
486
494 virtual bool processKeyEvent(const KeyEvent& event, DesignObjectLookup* lookup, Camera* camera) override;
495
505 void processResizeEvent(const MeasureMode& spec, Model& model, Camera* camera);
506 protected:
510 void updateSnapIcon();
511 protected:
512 CommandLockObject m_command_lock;
513 PointMeasureModel m_point_model;
514 DistanceMeasureModel m_distance_measure_model;
515 #if NDEVR_CROSS_SECTION
516 CrossSectionModel m_cross_section_model;
517 #endif
518 AngleMeasureModel m_angle_measure_model;
519 AngleMode m_angle_mode = AngleMode::e_track_mouse;
520 TranslatedString m_point_naming_format;
521 TranslatedString m_distance_naming_format;
522 TranslatedString m_angle_naming_format;
523 TranslatedString m_root_name;
524 Plane<3, fltp08> m_draw_plane;
525 Vector<3, fltp08> m_cross_section_spacing;
526 fltp08 m_max_point_distance = Constant<fltp08>::Invalid;
527 Vector<2, fltp08> m_cross_section_centerline_range = Vector<2, fltp08>(10.0, 30.0);
528 UUID m_current_model;
529 UUID m_root_model;
530 UUID m_id;
531 BitFlag m_point_type;
532 BitFlag m_line_edge_type;
533 bool m_auto_wind_shapes;
534 bool m_generate_normals;
535 bool m_lock_movement;
536 bool m_is_moving;
537 bool m_is_touch_mode;
538 bool m_use_line_leader;
539 bool m_use_point_leader;
540 bool m_cross_section_horizontal_parallel = false;
541 bool m_cross_section_vertical_parallel = false;
542 bool m_cross_section_vertical_orthogonal = true;
543 bool m_cross_section_orthogonal = false;
544 bool m_autoset_lock_plane = true;
545 };
546 template class NDEVR_DESIGN_API StringStream<MeasurementManager::MeasureMode>;
547}
548#endif
549
550
Allows for mouse snaps to certain key points of interest in the software.
Logic for reading or writing to a string or a user friendly, TranslatedString.
The primary namespace for the NDEVR SDK.
@ BitFlag
Per-vertex bit flags (selected, hidden, etc.).
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...