MeshLib Documentation
Loading...
Searching...
No Matches
MRAncillaryLabels.h
Go to the documentation of this file.
1#pragma once
2#ifndef MRMESH_NO_LABEL
3
4#include "exports.h"
5#include "MRMesh/MRMeshFwd.h"
6#include "MRMesh/MRVector2.h"
9#include <memory>
10
11namespace MR
12{
13class Object;
14class ObjectLabel;
15struct PositionedText;
16
18struct MRVIEWER_CLASS AncillaryLabel
19{
20 std::shared_ptr<ObjectLabel> obj;
21
22 AncillaryLabel() = default;
23
25 AncillaryLabel( AncillaryLabel && b ) noexcept : obj{ std::move( b.obj ) } {}
26 AncillaryLabel & operator =( AncillaryLabel && b ) { reset(); obj = std::move( b.obj ); return *this; }
27
29 explicit AncillaryLabel( Object& parent, const PositionedText& text, bool depthTest = false )
30 { make( parent, text, depthTest ); }
31
33 MRVIEWER_API void make( Object& parent, const PositionedText& text, bool depthTest = false );
34
36 static MRVIEWER_API std::shared_ptr<ObjectLabel> makeDetached(
37 const PositionedText& text, bool depthTest = false );
38
40 MRVIEWER_API void reset();
41
43 ~AncillaryLabel() { reset(); }
44
46 MRVIEWER_API void setText( const PositionedText& text );
47
49 MRVIEWER_API void resetText();
50
52 MRVIEWER_API void setDepthTest( bool depthTest );
53
55 MRVIEWER_API void setPosition( const Vector3f& pos );
56};
57
59class MRVIEWER_CLASS AncillaryImGuiLabel : public PreDrawListener
60{
61public:
63
65 MRVIEWER_API void make( Object &parent, const PositionedText& text );
66
69 MRVIEWER_API void make( std::shared_ptr<Object> parent, const PositionedText& text );
70
72 MRVIEWER_API void make( const PositionedText& text );
73
75 MRVIEWER_API void reset();
76
80 Vector2f getPivot() const { return pivot_; }
81 void setPivot( Vector2f pivot ) { pivot_ = pivot; }
82
83private:
84 MRVIEWER_API virtual void preDraw_() override;
85
86 std::weak_ptr<Object> parent_;
87 Vector2f pivot_ = { 0.5f, 0.5f };
88 Vector3f localPos_;
89 PositionedText labelData_;
90 boost::signals2::scoped_connection parentXfConnection_;
91};
92
93
94} //namespace MR
95
96#endif
Helper class that draws ImGui label.
Definition MRAncillaryLabels.h:60
MRVIEWER_API void make(Object &parent, const PositionedText &text)
Make label in parent space coordinates, follows parent worldXf.
void setPivot(Vector2f pivot)
Definition MRAncillaryLabels.h:81
Vector2f getPivot() const
Definition MRAncillaryLabels.h:80
MRVIEWER_API void make(std::shared_ptr< Object > parent, const PositionedText &text)
MRVIEWER_API void reset()
clears this instance
MRVIEWER_API void make(const PositionedText &text)
Make label in world space coordinates.
named object in the data model
Definition MRObject.h:60
Definition MRCameraOrientationPlugin.h:8
Helper class to manage ancillary labels used by plugins.
Definition MRAncillaryLabels.h:19
MRVIEWER_API void reset()
detach owned object from parent, stops owning it
std::shared_ptr< ObjectLabel > obj
Definition MRAncillaryLabels.h:20
MRVIEWER_API void make(Object &parent, const PositionedText &text, bool depthTest=false)
Make not-pickable ancillary object, link it to parent object, and set label text.
MRVIEWER_API void setDepthTest(bool depthTest)
Set depth test.
AncillaryLabel()=default
MRVIEWER_API void setPosition(const Vector3f &pos)
Set text position.
MRVIEWER_API void setText(const PositionedText &text)
Set label text.
static MRVIEWER_API std::shared_ptr< ObjectLabel > makeDetached(const PositionedText &text, bool depthTest=false)
Make not-pickable ancillary object without parent object, and set label text.
AncillaryLabel(AncillaryLabel &&b) noexcept
since this uniquely owns an ancillary object, we provide only move operations, not copy
Definition MRAncillaryLabels.h:25
~AncillaryLabel()
detach owned object from parent, stops owning it
Definition MRAncillaryLabels.h:43
MRVIEWER_API void resetText()
Reset label text.
AncillaryLabel(Object &parent, const PositionedText &text, bool depthTest=false)
Make not-pickable ancillary object, link it to parent object, and set label text.
Definition MRAncillaryLabels.h:29
Definition MRPositionedText.h:9
Definition MRViewerEventsListener.h:159