MeshLib C++ Docs
Loading...
Searching...
No Matches
MRObjectLabel.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRSymbolMeshFwd.h"
4#include "MRSymbolMesh.h"
5
8
9namespace MR
10{
11
12enum class MRSYMBOLMESH_CLASS LabelVisualizePropertyType
13{
18 _count [[maybe_unused]],
19};
20template <> struct IsVisualizeMaskEnum<LabelVisualizePropertyType> : std::true_type {};
21
26{
27public:
29
30 ObjectLabel( ObjectLabel&& ) noexcept = default;
31 ObjectLabel& operator = ( ObjectLabel&& ) noexcept = default;
32
33 constexpr static const char* StaticTypeName() noexcept
34 {
35 return "ObjectLabel";
36 }
37 virtual const char* typeName() const override
38 {
39 return StaticTypeName();
40 }
41
42 MRSYMBOLMESH_API virtual void applyScale( float scaleFactor ) override;
43
44 virtual bool hasVisualRepresentation() const override { return true; }
45
46 MRSYMBOLMESH_API virtual std::shared_ptr<Object> clone() const override;
47 MRSYMBOLMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
48
50 MRSYMBOLMESH_API virtual void setFontHeight( float size );
52 float getFontHeight() const { return fontHeight_; }
53
55 MRSYMBOLMESH_API void setLabel( const PositionedText& label );
56 const PositionedText& getLabel() const { return label_; }
57
59 MRSYMBOLMESH_API void setFontPath( const std::filesystem::path& pathToFont );
60 const std::filesystem::path& getFontPath() const { return pathToFont_; }
61
67 MRSYMBOLMESH_API void setPivotPoint( const Vector2f& pivotPoint );
68
70 const Vector2f& getPivotPoint() const { return pivotPoint_; }
71
73 const Vector2f& getPivotShift() const { return pivotShift_; }
74
76 MRSYMBOLMESH_API virtual void setLeaderLineWidth( float width );
78 float getLeaderLineWidth() const { return leaderLineWidth_; }
80 MRSYMBOLMESH_API virtual void setSourcePointSize( float size );
82 float getSourcePointSize() const { return sourcePointSize_; }
84 MRSYMBOLMESH_API virtual void setBackgroundPadding( float padding );
86 float getBackgroundPadding() const { return backgroundPadding_; }
87
89 MRSYMBOLMESH_API virtual void setSourcePointColor( const Color& color, ViewportId id = {} );
91 const Color& getSourcePointColor( ViewportId id = {} ) const
92 {
93 return sourcePointColor_.get( id );
94 }
96 MRSYMBOLMESH_API virtual void setLeaderLineColor( const Color& color, ViewportId id = {} );
98 const Color& getLeaderLineColor( ViewportId id = {} ) const
99 {
100 return leaderLineColor_.get( id );
101 }
103 MRSYMBOLMESH_API void setContourColor( const Color& color, ViewportId id = {} );
105 const Color& getContourColor( ViewportId id = {} ) const
106 {
107 return contourColor_.get( id );
108 }
109
110 MRSYMBOLMESH_API const ViewportProperty<Color>& getSourcePointColorsForAllViewports() const;
111 MRSYMBOLMESH_API virtual void setSourcePointColorsForAllViewports( ViewportProperty<Color> val );
112
113 MRSYMBOLMESH_API const ViewportProperty<Color>& getLeaderLineColorsForAllViewports() const;
114 MRSYMBOLMESH_API virtual void setLeaderLineColorsForAllViewports( ViewportProperty<Color> val );
115
116 MRSYMBOLMESH_API const ViewportProperty<Color>& getContourColorsForAllViewports() const;
117 MRSYMBOLMESH_API virtual void setContourColorsForAllViewports( ViewportProperty<Color> val );
118
120 ObjectLabel( ProtectedStruct, const ObjectLabel& obj ) : ObjectLabel( obj )
121 {}
122
125 MRSYMBOLMESH_API virtual Box3f getWorldBox( ViewportId = {} ) const override;
126
129 const std::shared_ptr<Mesh>& labelRepresentingMesh() const { return mesh_; }
130
132 [[nodiscard]] MRSYMBOLMESH_API virtual size_t heapBytes() const override;
133
135 MRSYMBOLMESH_API AllVisualizeProperties getAllVisualizeProperties() const override;
137 MRSYMBOLMESH_API const ViewportMask& getVisualizePropertyMask( AnyVisualizeMaskEnum type ) const override;
138
141 MRSYMBOLMESH_API void buildMeshFromText() const;
142
143protected:
144 PositionedText label_;
145 std::filesystem::path pathToFont_;
146 Vector2f pivotPoint_;
147
149 float fontHeight_{ 25.0f };
151 float leaderLineWidth_{ 1.0f };
153 float sourcePointSize_{ 5.f };
155 float backgroundPadding_{ 8.f };
156
157 ViewportMask sourcePoint_;
158 ViewportMask background_;
159 ViewportMask contour_;
160 ViewportMask leaderLine_;
161
162 ViewportProperty<Color> sourcePointColor_;
163 ViewportProperty<Color> leaderLineColor_;
164 ViewportProperty<Color> contourColor_;
165
166 ObjectLabel( const ObjectLabel& other ) = default;
167
169 MRSYMBOLMESH_API virtual void swapBase_( Object& other ) override;
170
171 MRSYMBOLMESH_API virtual Box3f computeBoundingBox_() const override;
172
173 MRSYMBOLMESH_API virtual void serializeFields_( Json::Value& root ) const override;
174
175 MRSYMBOLMESH_API virtual void deserializeFields_( const Json::Value& root ) override;
176
177 MRSYMBOLMESH_API virtual void setupRenderObject_() const override;
178
180 MRSYMBOLMESH_API void setAllVisualizeProperties_( const AllVisualizeProperties& properties, std::size_t& pos ) override;
181
182private:
184 void setDefaultColors_();
185
187 void setDefaultSceneProperties_();
188
189 void updatePivotShift_() const;
190
191 mutable bool needRebuild_{ true };
192 mutable Vector2f pivotShift_;
193 mutable std::shared_ptr<Mesh> mesh_;
194 mutable Box3f meshBox_; // needed for pivot update
195};
196
197}
_count
Definition MRFeatureObject.h:87
Contour
Definition MRObjectLabel.h:17
Background
Definition MRObjectLabel.h:16
SourcePoint
Definition MRObjectLabel.h:14
LeaderLine
Definition MRObjectLabel.h:15
#define MRSYMBOLMESH_API
Definition MRSymbolMeshFwd.h:12
#define MRSYMBOLMESH_CLASS
Definition MRSymbolMeshFwd.h:16
Definition MRObjectLabel.h:26
Definition MRVisualObject.h:119
Definition MRCameraOrientationPlugin.h:8
AllVisualizeProperties
int heapBytes(FloatGrid grid)
Definition MRVisualObject.h:32