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* TypeName() noexcept
34 {
35 return "ObjectLabel";
36 }
37 virtual const char* typeName() const override
38 {
39 return TypeName();
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
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
112
115
118
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
138
142
143protected:
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
161
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}
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:11
#define MRSYMBOLMESH_CLASS
Definition MRSymbolMeshFwd.h:12
Definition MRVisualObject.h:54
Definition MRObjectLabel.h:26
Vector2f pivotPoint_
Definition MRObjectLabel.h:146
ObjectLabel(ObjectLabel &&) noexcept=default
virtual MRSYMBOLMESH_API void setSourcePointColorsForAllViewports(ViewportProperty< Color > val)
MRSYMBOLMESH_API const ViewportProperty< Color > & getSourcePointColorsForAllViewports() const
ViewportProperty< Color > contourColor_
Definition MRObjectLabel.h:164
virtual MRSYMBOLMESH_API void deserializeFields_(const Json::Value &root) override
virtual MRSYMBOLMESH_API Box3f getWorldBox(ViewportId={}) const override
const PositionedText & getLabel() const
Definition MRObjectLabel.h:56
MRSYMBOLMESH_API const ViewportProperty< Color > & getContourColorsForAllViewports() const
virtual MRSYMBOLMESH_API std::shared_ptr< Object > shallowClone() const override
ObjectLabel(ProtectedStruct, const ObjectLabel &obj)
Definition MRObjectLabel.h:120
const std::filesystem::path & getFontPath() const
Definition MRObjectLabel.h:60
const Vector2f & getPivotShift() const
get pivot shift (pivot point * text diagonal)
Definition MRObjectLabel.h:73
virtual MRSYMBOLMESH_API void setupRenderObject_() const override
const std::shared_ptr< Mesh > & labelRepresentingMesh() const
Definition MRObjectLabel.h:129
float getSourcePointSize() const
returns size of source point in pixels
Definition MRObjectLabel.h:82
MRSYMBOLMESH_API void setLabel(const PositionedText &label)
sets text and position of label
virtual MRSYMBOLMESH_API void setContourColorsForAllViewports(ViewportProperty< Color > val)
virtual MRSYMBOLMESH_API void swapBase_(Object &other) override
swaps this object with other
virtual MRSYMBOLMESH_API void setFontHeight(float size)
sets size of label font in pixels
ViewportMask sourcePoint_
Definition MRObjectLabel.h:157
const Vector2f & getPivotPoint() const
get pivot point
Definition MRObjectLabel.h:70
MRSYMBOLMESH_API AllVisualizeProperties getAllVisualizeProperties() const override
get all visualize properties masks
const Color & getLeaderLineColor(ViewportId id={}) const
return color of leader line
Definition MRObjectLabel.h:98
virtual const char * typeName() const override
Definition MRObjectLabel.h:37
virtual MRSYMBOLMESH_API void setLeaderLineColorsForAllViewports(ViewportProperty< Color > val)
virtual MRSYMBOLMESH_API void serializeFields_(Json::Value &root) const override
ViewportProperty< Color > leaderLineColor_
Definition MRObjectLabel.h:163
MRSYMBOLMESH_API void setFontPath(const std::filesystem::path &pathToFont)
sets path to font file
ViewportProperty< Color > sourcePointColor_
Definition MRObjectLabel.h:162
virtual MRSYMBOLMESH_API void setSourcePointColor(const Color &color, ViewportId id={})
sets color of source point
virtual MRSYMBOLMESH_API void setLeaderLineColor(const Color &color, ViewportId id={})
sets color of leader line
MRSYMBOLMESH_API void setAllVisualizeProperties_(const AllVisualizeProperties &properties, std::size_t &pos) override
set all visualize properties masks
float getBackgroundPadding() const
returns background padding in pixels
Definition MRObjectLabel.h:86
virtual MRSYMBOLMESH_API void setBackgroundPadding(float padding)
sets background padding in pixels
virtual MRSYMBOLMESH_API void setLeaderLineWidth(float width)
sets width of leader line in pixels
virtual MRSYMBOLMESH_API Box3f computeBoundingBox_() const override
MRSYMBOLMESH_API const ViewportProperty< Color > & getLeaderLineColorsForAllViewports() const
virtual MRSYMBOLMESH_API void applyScale(float scaleFactor) override
scale object size (all point positions)
MRSYMBOLMESH_API void setPivotPoint(const Vector2f &pivotPoint)
MRSYMBOLMESH_API void buildMeshFromText() const
float getLeaderLineWidth() const
returns width of leader line in pixels
Definition MRObjectLabel.h:78
ViewportMask background_
Definition MRObjectLabel.h:158
ObjectLabel(const ObjectLabel &other)=default
virtual MRSYMBOLMESH_API std::shared_ptr< Object > clone() const override
virtual bool hasVisualRepresentation() const override
does the object have any visual representation (visible points, triangles, edges, etc....
Definition MRObjectLabel.h:44
float getFontHeight() const
returns size of label font on screen in pixels
Definition MRObjectLabel.h:52
ViewportMask leaderLine_
Definition MRObjectLabel.h:160
virtual MRSYMBOLMESH_API size_t heapBytes() const override
returns the amount of memory this object occupies on heap
std::filesystem::path pathToFont_
Definition MRObjectLabel.h:145
MRSYMBOLMESH_API ObjectLabel()
MRSYMBOLMESH_API void setContourColor(const Color &color, ViewportId id={})
sets contour color
PositionedText label_
Definition MRObjectLabel.h:144
virtual MRSYMBOLMESH_API void setSourcePointSize(float size)
sets size of source point in pixels
const Color & getContourColor(ViewportId id={}) const
return contour color
Definition MRObjectLabel.h:105
ViewportMask contour_
Definition MRObjectLabel.h:159
const Color & getSourcePointColor(ViewportId id={}) const
returns color of source point
Definition MRObjectLabel.h:91
MRSYMBOLMESH_API const ViewportMask & getVisualizePropertyMask(AnyVisualizeMaskEnum type) const override
returns mask of viewports where given property is set
named object in the data model
Definition MRObject.h:62
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
Definition MRViewportProperty.h:17
Visual Object.
Definition MRVisualObject.h:119
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:72
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh/MRColor.h:9
Definition MRVisualObject.h:32
Definition MRObject.h:279
Definition MRPositionedText.h:10