MeshLib Documentation
Loading...
Searching...
No Matches
MRObjectLinesHolder.h
Go to the documentation of this file.
1#pragma once
2#include "MRVisualObject.h"
3#include "MRXfBasedCache.h"
4
5namespace MR
6{
7
8enum class MRMESH_CLASS LinesVisualizePropertyType
9{
12 _count [[maybe_unused]],
13};
14template <> struct IsVisualizeMaskEnum<LinesVisualizePropertyType> : std::true_type {};
15
19{
20public:
24
25 constexpr static const char* TypeName() noexcept { return "LinesHolder"; }
26 virtual const char* typeName() const override { return TypeName(); }
27
28 MRMESH_API virtual void applyScale( float scaleFactor ) override;
29
30 MRMESH_API virtual bool hasVisualRepresentation() const override;
31
32 [[nodiscard]] virtual bool hasModel() const override { return bool( polyline_ ); }
33
34 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
35 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
36
37 const std::shared_ptr<const Polyline3>& polyline() const
38 { return reinterpret_cast< const std::shared_ptr<const Polyline3>& >( polyline_ ); } // reinterpret_cast to avoid making a copy of shared_ptr
39
40 MRMESH_API virtual void setDirtyFlags( uint32_t mask, bool invalidateCaches = true ) override;
41
42 MRMESH_API virtual void setLineWidth( float width );
43 virtual float getLineWidth() const { return lineWidth_; }
44 MRMESH_API virtual void setPointSize( float size );
45 virtual float getPointSize() const { return pointSize_; }
46
49
50 const UndirectedEdgeColors& getLinesColorMap() const { return linesColorMap_; }
51 virtual void setLinesColorMap( UndirectedEdgeColors linesColorMap )
52 { linesColorMap_ = std::move( linesColorMap ); dirty_ |= DIRTY_PRIMITIVE_COLORMAP; }
53 virtual void updateLinesColorMap( UndirectedEdgeColors& updated )
54 { std::swap( linesColorMap_, updated ); dirty_ |= DIRTY_PRIMITIVE_COLORMAP; }
55
56 [[nodiscard]] MRMESH_API bool supportsVisualizeProperty( AnyVisualizeMaskEnum type ) const override;
61
64 MRMESH_API virtual Box3f getWorldBox( ViewportId = {} ) const override;
65
67 [[nodiscard]] MRMESH_API virtual size_t heapBytes() const override;
68
70 MRMESH_API size_t numComponents() const;
71
73 MRMESH_API float totalLength() const;
74protected:
75 ObjectLinesHolder( const ObjectLinesHolder& other ) = default;
76
78 MRMESH_API virtual void swapBase_( Object& other ) override;
79
82 MRMESH_API void serializeBaseFields_( Json::Value& root ) const;
84 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
85
88 MRMESH_API void deserializeBaseFields_( const Json::Value& root );
90 MRMESH_API virtual void deserializeFields_( const Json::Value& root ) override;
91
92 MRMESH_API virtual Box3f computeBoundingBox_() const override;
93
94 MRMESH_API virtual void setupRenderObject_() const override;
95
97 MRMESH_API void setAllVisualizeProperties_( const AllVisualizeProperties& properties, std::size_t& pos ) override;
98
99 mutable std::optional<size_t> numComponents_;
100 mutable std::optional<float> totalLength_;
102
103 UndirectedEdgeColors linesColorMap_;
104
107
109 float lineWidth_{ 1.0f };
110 float pointSize_{ 5.f };
111 std::shared_ptr<Polyline3> polyline_;
112
113private:
115 void setDefaultColors_();
116
118 void setDefaultSceneProperties_();
119};
120
121
122} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
Points
Definition MRObjectLinesHolder.h:10
Definition MRVisualObject.h:67
Definition MRObjectLinesHolder.h:19
MRMESH_API ObjectLinesHolder()
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
virtual MRMESH_API void setPointSize(float size)
virtual MRMESH_API void setLineWidth(float width)
ObjectLinesHolder & operator=(ObjectLinesHolder &&)=default
virtual MRMESH_API void setupRenderObject_() const override
const UndirectedEdgeColors & getLinesColorMap() const
Definition MRObjectLinesHolder.h:50
virtual MRMESH_API void setDirtyFlags(uint32_t mask, bool invalidateCaches=true) override
virtual MRMESH_API Box3f computeBoundingBox_() const override
UndirectedEdgeColors linesColorMap_
Definition MRObjectLinesHolder.h:103
virtual void updateLinesColorMap(UndirectedEdgeColors &updated)
Definition MRObjectLinesHolder.h:53
ViewportMask smoothConnections_
Definition MRObjectLinesHolder.h:106
MRMESH_API void serializeBaseFields_(Json::Value &root) const
MRMESH_API size_t numComponents() const
returns cached information about the number of components in the polyline
virtual const char * typeName() const override
Definition MRObjectLinesHolder.h:26
static constexpr const char * TypeName() noexcept
Definition MRObjectLinesHolder.h:25
virtual float getPointSize() const
Definition MRObjectLinesHolder.h:45
virtual bool hasModel() const override
Definition MRObjectLinesHolder.h:32
MRMESH_API void setAllVisualizeProperties_(const AllVisualizeProperties &properties, std::size_t &pos) override
set all visualize properties masks
virtual MRMESH_API void applyScale(float scaleFactor) override
scale object size (all point positions)
MRMESH_API float totalLength() const
return cached total length
virtual MRMESH_API std::shared_ptr< Object > clone() const override
virtual MRMESH_API void deserializeFields_(const Json::Value &root) override
deserializeFields_: deserializeBaseFields_ plus polyline deserialization
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...
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
ObjectLinesHolder(ObjectLinesHolder &&)=default
MRMESH_API void deserializeBaseFields_(const Json::Value &root)
MRMESH_API const ViewportMask & getVisualizePropertyMask(AnyVisualizeMaskEnum type) const override
returns mask of viewports where given property is set
virtual MRMESH_API bool hasVisualRepresentation() const override
does the object have any visual representation (visible points, triangles, edges, etc....
virtual MRMESH_API Box3f getWorldBox(ViewportId={}) const override
std::optional< size_t > numComponents_
Definition MRObjectLinesHolder.h:99
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
serializeFields_: serializeBaseFields_ plus polyline serialization
ObjectLinesHolder(const ObjectLinesHolder &other)=default
ViewportMask showPoints_
Definition MRObjectLinesHolder.h:105
virtual void setLinesColorMap(UndirectedEdgeColors linesColorMap)
Definition MRObjectLinesHolder.h:51
virtual float getLineWidth() const
Definition MRObjectLinesHolder.h:43
virtual MRMESH_API size_t heapBytes() const override
returns the amount of memory this object occupies on heap
const std::shared_ptr< const Polyline3 > & polyline() const
Definition MRObjectLinesHolder.h:37
ObjectLinesHolder(ProtectedStruct, const ObjectLinesHolder &obj)
Definition MRObjectLinesHolder.h:48
std::optional< float > totalLength_
Definition MRObjectLinesHolder.h:100
MRMESH_API AllVisualizeProperties getAllVisualizeProperties() const override
get all visualize properties masks
ViewportProperty< XfBasedCache< Box3f > > worldBox_
Definition MRObjectLinesHolder.h:101
std::shared_ptr< Polyline3 > polyline_
Definition MRObjectLinesHolder.h:111
named object in the data model
Definition MRObject.h:60
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
Definition MRViewportProperty.h:17
Visual Object.
Definition MRVisualObject.h:131
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:85
@ DIRTY_PRIMITIVE_COLORMAP
Definition MRVisualObject.h:101
Definition MRCameraOrientationPlugin.h:8
@ Smooth
create mesh using dual marching cubes from OpenVDB library
Definition MRVisualObject.h:45
Definition MRObject.h:246