MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPointMeasurementObject.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace MR
7{
8
9enum class MRMESH_CLASS PointMeasurementVisualizePropertyType
10{
12 _count [[maybe_unused]],
13};
14template <> struct IsVisualizeMaskEnum<PointMeasurementVisualizePropertyType> : std::true_type {};
15
17 : public MeasurementObject
19{
20public:
22
24 PointMeasurementObject& operator =( PointMeasurementObject&& ) noexcept = default;
25
26 constexpr static const char* TypeName() noexcept { return "PointMeasurementObject"; }
27 const char* typeName() const override { return TypeName(); }
28
29 constexpr static const char* ClassName() noexcept { return "Measure Point"; }
30 std::string className() const override { return ClassName(); }
31
32 constexpr static const char* ClassNameInPlural() noexcept { return "Measure Points"; }
33 std::string classNameInPlural() const override { return ClassNameInPlural(); }
34
38
39 MRMESH_API std::shared_ptr<Object> clone() const override;
40 MRMESH_API std::shared_ptr<Object> shallowClone() const override;
41
42 [[nodiscard]] MRMESH_API bool supportsVisualizeProperty( AnyVisualizeMaskEnum type ) const override;
45
47 [[nodiscard]] MRMESH_API Vector3f getLocalPoint( ViewportId id = {} ) const;
48 [[nodiscard]] MRMESH_API Vector3f getWorldPoint( ViewportId id = {} ) const;
50 MRMESH_API void setLocalPoint( const Vector3f& point, ViewportId id = {} );
51 MRMESH_API void setWorldPoint( const Vector3f& point, ViewportId id = {} );
52
53 // Implement `ObjectComparableWithReference`:
54 [[nodiscard]] MRMESH_API std::size_t numComparableProperties() const override;
55 [[nodiscard]] MRMESH_API std::string_view getComparablePropertyName( std::size_t i ) const override;
56 [[nodiscard]] MRMESH_API std::optional<ComparableProperty> computeComparableProperty( std::size_t i ) const override;
57 [[nodiscard]] MRMESH_API std::optional<ComparisonTolerance> getComparisonTolerence( std::size_t i ) const override;
58 MRMESH_API void setComparisonTolerance( std::size_t i, std::optional<ComparisonTolerance> newTolerance ) override;
59 [[nodiscard]] MRMESH_API bool comparisonToleranceIsAlwaysOnlyPositive( std::size_t i ) const override;
60 // This returns 2: the point, and the optional normal direction. The normal doesn't need to be normalized, its length doesn't affect calculations.
61 // If the normal isn't specified, the Euclidean distance gets used.
62 [[nodiscard]] MRMESH_API std::size_t numComparisonReferenceValues() const override;
63 [[nodiscard]] MRMESH_API std::string_view getComparisonReferenceValueName( std::size_t i ) const override;
64 [[nodiscard]] MRMESH_API ComparisonReferenceValue getComparisonReferenceValue( std::size_t i ) const override;
65 MRMESH_API void setComparisonReferenceValue( std::size_t i, std::optional<ComparisonReferenceValue::Var> value ) override;
66
67protected:
69
71 MRMESH_API void swapBase_( Object& other ) override;
72
73 MRMESH_API void serializeFields_( Json::Value& root ) const override;
74 MRMESH_API void deserializeFields_( const Json::Value& root ) override;
75
76 MRMESH_API void setupRenderObject_() const override;
77
78 private:
79 std::optional<Vector3f> referencePos_;
80 std::optional<Vector3f> referenceNormal_; // Not necessarily normalized.
81 std::optional<ComparisonTolerance> tolerance_;
82
83 ViewportMask capVisibility_ = ViewportMask::all();
84};
85
86} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:84
CapVisibility
Definition MRPointMeasurementObject.h:11
Definition MRVisualObject.h:54
Definition MRMeasurementObject.h:11
Definition MRObjectComparableWithReference.h:14
named object in the data model
Definition MRObject.h:62
Definition MRPointMeasurementObject.h:19
MRMESH_API bool supportsVisualizeProperty(AnyVisualizeMaskEnum type) const override
Returns true if this class supports the property type. Otherwise passing it to the functions below is...
MRMESH_API std::shared_ptr< Object > clone() const override
MRMESH_API Vector3f getWorldPoint(ViewportId id={}) const
MRMESH_API void setComparisonReferenceValue(std::size_t i, std::optional< ComparisonReferenceValue::Var > value) override
MRMESH_API void setupRenderObject_() const override
MRMESH_API ComparisonReferenceValue getComparisonReferenceValue(std::size_t i) const override
const char * typeName() const override
Definition MRPointMeasurementObject.h:27
MRMESH_API std::shared_ptr< Object > shallowClone() const override
PointMeasurementObject(const PointMeasurementObject &other)=default
MRMESH_API std::string_view getComparablePropertyName(std::size_t i) const override
MRMESH_API Vector3f getLocalPoint(ViewportId id={}) const
calculates point from xf
PointMeasurementObject(ProtectedStruct, const PointMeasurementObject &obj)
Definition MRPointMeasurementObject.h:36
PointMeasurementObject(PointMeasurementObject &&) noexcept=default
MRMESH_API std::string_view getComparisonReferenceValueName(std::size_t i) const override
MRMESH_API bool comparisonToleranceIsAlwaysOnlyPositive(std::size_t i) const override
MRMESH_API void setLocalPoint(const Vector3f &point, ViewportId id={})
updates xf to fit given point
MRMESH_API std::optional< ComparableProperty > computeComparableProperty(std::size_t i) const override
MRMESH_API void serializeFields_(Json::Value &root) const override
MRMESH_API std::optional< ComparisonTolerance > getComparisonTolerence(std::size_t i) const override
MRMESH_API std::size_t numComparableProperties() const override
MRMESH_API void deserializeFields_(const Json::Value &root) override
MRMESH_API void setWorldPoint(const Vector3f &point, ViewportId id={})
MRMESH_API void setComparisonTolerance(std::size_t i, std::optional< ComparisonTolerance > newTolerance) override
static constexpr const char * ClassName() noexcept
Definition MRPointMeasurementObject.h:29
MRMESH_API AllVisualizeProperties getAllVisualizeProperties() const override
get all visualize properties masks
MRMESH_API void swapBase_(Object &other) override
swaps this object with other
std::string className() const override
Definition MRPointMeasurementObject.h:30
MRMESH_API const ViewportMask & getVisualizePropertyMask(AnyVisualizeMaskEnum type) const override
returns mask of viewports where given property is set
static constexpr const char * ClassNameInPlural() noexcept
Definition MRPointMeasurementObject.h:32
std::string classNameInPlural() const override
Definition MRPointMeasurementObject.h:33
MRMESH_API std::size_t numComparisonReferenceValues() const override
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:72
Definition MRCameraOrientationPlugin.h:8
Definition MRVisualObject.h:32
Definition MRObjectComparableWithReference.h:87
Definition MRObject.h:279