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
9
10namespace MR
11{
14
15
16enum class MRSYMBOLMESH_CLASS LabelVisualizePropertyType
17{
22 _count [[maybe_unused]],
23};
24template <> struct IsVisualizeMaskEnum<LabelVisualizePropertyType> : std::true_type {};
25
30{
31public:
33
34 ObjectLabel( ObjectLabel&& ) noexcept = default;
35 ObjectLabel& operator = ( ObjectLabel&& ) noexcept = default;
36
37 constexpr static const char* StaticTypeName() noexcept
38 {
39 return "ObjectLabel";
40 }
41 virtual const char* typeName() const override
42 {
43 return StaticTypeName();
44 }
45
46 MRSYMBOLMESH_API virtual void applyScale( float scaleFactor ) override;
47
48 virtual bool hasVisualRepresentation() const override { return true; }
49
50 MRSYMBOLMESH_API virtual std::shared_ptr<Object> clone() const override;
51 MRSYMBOLMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
52
54 MRSYMBOLMESH_API virtual void setFontHeight( float size );
56 float getFontHeight() const { return fontHeight_; }
57
60 const PositionedText& getLabel() const { return label_; }
61
63 MRSYMBOLMESH_API void setFontPath( const std::filesystem::path& pathToFont );
64 const std::filesystem::path& getFontPath() const { return pathToFont_; }
65
71 MRSYMBOLMESH_API void setPivotPoint( const Vector2f& pivotPoint );
72
74 const Vector2f& getPivotPoint() const { return pivotPoint_; }
75
77 const Vector2f& getPivotShift() const { return pivotShift_; }
78
82 float getLeaderLineWidth() const { return leaderLineWidth_; }
86 float getSourcePointSize() const { return sourcePointSize_; }
88 MRSYMBOLMESH_API virtual void setBackgroundPadding( float padding );
90 float getBackgroundPadding() const { return backgroundPadding_; }
91
93 MRSYMBOLMESH_API virtual void setSourcePointColor( const Color& color, ViewportId id = {} );
95 const Color& getSourcePointColor( ViewportId id = {} ) const
96 {
97 return sourcePointColor_.get( id );
98 }
99
100 MRSYMBOLMESH_API virtual void setLeaderLineColor( const Color& color, ViewportId id = {} );
102 const Color& getLeaderLineColor( ViewportId id = {} ) const
103 {
104 return leaderLineColor_.get( id );
105 }
106
107 MRSYMBOLMESH_API void setContourColor( const Color& color, ViewportId id = {} );
109 const Color& getContourColor( ViewportId id = {} ) const
110 {
111 return contourColor_.get( id );
112 }
113
116
119
122
125 {}
126
129 MRSYMBOLMESH_API virtual Box3f getWorldBox( ViewportId = {} ) const override;
130
133 const std::shared_ptr<Mesh>& labelRepresentingMesh() const { return mesh_; }
134
136 [[nodiscard]] MRSYMBOLMESH_API virtual size_t heapBytes() const override;
137
142
146
147protected:
149 std::filesystem::path pathToFont_;
150 Vector2f pivotPoint_;
151
153 float fontHeight_{ 25.0f };
155 float leaderLineWidth_{ 1.0f };
157 float sourcePointSize_{ 5.f };
159 float backgroundPadding_{ 8.f };
160
165
169
170 ObjectLabel( const ObjectLabel& other ) = default;
171
173 MRSYMBOLMESH_API virtual void swapBase_( Object& other ) override;
174
175 MRSYMBOLMESH_API virtual Box3f computeBoundingBox_() const override;
176
177 MRSYMBOLMESH_API virtual void serializeFields_( Json::Value& root ) const override;
178
179 MRSYMBOLMESH_API virtual void deserializeFields_( const Json::Value& root ) override;
180
181 MRSYMBOLMESH_API virtual void setupRenderObject_() const override;
182
184 MRSYMBOLMESH_API void setAllVisualizeProperties_( const AllVisualizeProperties& properties, std::size_t& pos ) override;
185
186private:
188 void setDefaultColors_();
189
191 void setDefaultSceneProperties_();
192
193 void updatePivotShift_() const;
194
195 mutable bool needRebuild_{ true };
196 mutable Vector2f pivotShift_;
197 mutable std::shared_ptr<Mesh> mesh_;
198 mutable Box3f meshBox_;
199};
200
201}
#define MRSYMBOLMESH_API
see explanation in MRMesh/MRMeshFwd.h
Definition MRSymbolMeshFwd.h:12
#define MRSYMBOLMESH_CLASS
Definition MRSymbolMeshFwd.h:16
Definition MRVisualObject.h:54
named object in the data model
Definition MRObject.h:61
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
Definition MRViewportProperty.h:17
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:354
Vector2f pivotPoint_
Definition MRObjectLabel.h:150
ObjectLabel(ObjectLabel &&) noexcept=default
virtual void setLeaderLineColor(const Color &color, ViewportId id={})
sets color of leader line
float backgroundPadding_
padding of background on screen in pixels
Definition MRObjectLabel.h:159
virtual void setupRenderObject_() const override
virtual void swapBase_(Object &other) override
swaps this object with other
const ViewportProperty< Color > & getSourcePointColorsForAllViewports() const
void setFontPath(const std::filesystem::path &pathToFont)
sets path to font file
ViewportProperty< Color > contourColor_
Definition MRObjectLabel.h:168
virtual void setFontHeight(float size)
sets size of label font in pixels
Contour
Definition MRObjectLabel.h:21
const PositionedText & getLabel() const
Definition MRObjectLabel.h:60
ObjectLabel(ProtectedStruct, const ObjectLabel &obj)
Definition MRObjectLabel.h:124
const std::filesystem::path & getFontPath() const
Definition MRObjectLabel.h:64
const Vector2f & getPivotShift() const
get pivot shift (pivot point * text diagonal)
Definition MRObjectLabel.h:77
virtual void setBackgroundPadding(float padding)
sets background padding in pixels
const ViewportProperty< Color > & getContourColorsForAllViewports() const
const std::shared_ptr< Mesh > & labelRepresentingMesh() const
Definition MRObjectLabel.h:133
float getSourcePointSize() const
returns size of source point in pixels
Definition MRObjectLabel.h:86
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
Background
Definition MRObjectLabel.h:20
const ViewportMask & getVisualizePropertyMask(AnyVisualizeMaskEnum type) const override
returns mask of viewports where given property is set
virtual std::shared_ptr< Object > clone() const override
virtual void setSourcePointSize(float size)
sets size of source point in pixels
ViewportMask sourcePoint_
Definition MRObjectLabel.h:161
const Vector2f & getPivotPoint() const
get pivot point
Definition MRObjectLabel.h:74
const Color & getLeaderLineColor(ViewportId id={}) const
return color of leader line
Definition MRObjectLabel.h:102
virtual Box3f computeBoundingBox_() const override
virtual const char * typeName() const override
Definition MRObjectLabel.h:41
ViewportProperty< Color > leaderLineColor_
Definition MRObjectLabel.h:167
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
ViewportProperty< Color > sourcePointColor_
Definition MRObjectLabel.h:166
_count
If true, show additional details on the name tag, such as point coordinates. Not all features use thi...
Definition MRFeatureObject.h:90
virtual void deserializeFields_(const Json::Value &root) override
float getBackgroundPadding() const
returns background padding in pixels
Definition MRObjectLabel.h:90
static constexpr const char * StaticTypeName() noexcept
Definition MRObjectLabel.h:37
virtual void setContourColorsForAllViewports(ViewportProperty< Color > val)
AllVisualizeProperties getAllVisualizeProperties() const override
get all visualize properties masks
const ViewportProperty< Color > & getLeaderLineColorsForAllViewports() const
virtual void setSourcePointColorsForAllViewports(ViewportProperty< Color > val)
void setContourColor(const Color &color, ViewportId id={})
sets contour color
float getLeaderLineWidth() const
returns width of leader line in pixels
Definition MRObjectLabel.h:82
ViewportMask background_
Definition MRObjectLabel.h:162
virtual void setLeaderLineWidth(float width)
sets width of leader line in pixels
float fontHeight_
size of label font on screen in pixels
Definition MRObjectLabel.h:153
ObjectLabel(const ObjectLabel &other)=default
virtual bool hasVisualRepresentation() const override
does the object have any visual representation (visible points, triangles, edges, etc....
Definition MRObjectLabel.h:48
float getFontHeight() const
returns size of label font on screen in pixels
Definition MRObjectLabel.h:56
ViewportMask leaderLine_
Definition MRObjectLabel.h:164
virtual std::shared_ptr< Object > shallowClone() const override
virtual void applyScale(float scaleFactor) override
scale object size (all point positions)
std::filesystem::path pathToFont_
Definition MRObjectLabel.h:149
float leaderLineWidth_
width of leader line on screen in pixels
Definition MRObjectLabel.h:155
virtual void serializeFields_(Json::Value &root) const override
void buildMeshFromText() const
PositionedText label_
Definition MRObjectLabel.h:148
float sourcePointSize_
radius of source point on screen in pixels
Definition MRObjectLabel.h:157
virtual Box3f getWorldBox(ViewportId={}) const override
const Color & getContourColor(ViewportId id={}) const
return contour color
Definition MRObjectLabel.h:109
void setLabel(const PositionedText &label)
sets text and position of label
ViewportMask contour_
Definition MRObjectLabel.h:163
SourcePoint
Definition MRObjectLabel.h:18
LeaderLine
Definition MRObjectLabel.h:19
virtual void setLeaderLineColorsForAllViewports(ViewportProperty< Color > val)
void setAllVisualizeProperties_(const AllVisualizeProperties &properties, std::size_t &pos) override
set all visualize properties masks
const Color & getSourcePointColor(ViewportId id={}) const
returns color of source point
Definition MRObjectLabel.h:95
void setPivotPoint(const Vector2f &pivotPoint)
virtual void setSourcePointColor(const Color &color, ViewportId id={})
sets color of source point
@ other
Angle, normally float. Measure in radians.
Definition MRFeatureObject.h:27
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:72
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12
Definition MRVisualObject.h:32
Definition MRObject.h:289
Definition MRPositionedText.h:13