MeshLib C++ Docs
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"
10#include <memory>
11#include <optional>
12
13namespace MR
14{
17
18class Object;
19class ObjectLabel;
20struct PositionedText;
21
23struct MRVIEWER_CLASS AncillaryLabel
24{
25 std::shared_ptr<ObjectLabel> obj;
26
27 AncillaryLabel() = default;
28
30 AncillaryLabel( AncillaryLabel && b ) noexcept = default;
31 AncillaryLabel & operator =( AncillaryLabel && b ) { reset(); obj = std::move( b.obj ); return *this; }
32
34 explicit AncillaryLabel( Object& parent, const PositionedText& text, bool depthTest = false )
35 { make( parent, text, depthTest ); }
36
38 MRVIEWER_API void make( Object& parent, const PositionedText& text, bool depthTest = false );
39
41 static MRVIEWER_API std::shared_ptr<ObjectLabel> makeDetached(
42 const PositionedText& text, bool depthTest = false );
43
45 MRVIEWER_API void reset();
46
49
51 MRVIEWER_API void setText( const PositionedText& text );
52
54 MRVIEWER_API void resetText();
55
57 MRVIEWER_API void setDepthTest( bool depthTest );
58
60 MRVIEWER_API void setPosition( const Vector3f& pos );
61};
62
64class MRVIEWER_CLASS AncillaryImGuiLabel : public PreDrawListener
65{
66public:
68
70 MRVIEWER_API void make( Object &parent, const PositionedText& text );
71
74 MRVIEWER_API void make( std::shared_ptr<Object> parent, const PositionedText& text );
75
77 MRVIEWER_API void make( const PositionedText& text );
78
80 MRVIEWER_API void reset();
81
85 Vector2f getPivot() const { return pivot_; }
86 void setPivot( Vector2f pivot ) { pivot_ = pivot; }
87
89 MRVIEWER_API void overrideParams( const ImGuiMeasurementIndicators::Params& params );
90
92 MRVIEWER_API void resetOverrideParams();
93private:
94 MRVIEWER_API virtual void preDraw_() override;
95
96 std::weak_ptr<Object> parent_;
97 Vector2f pivot_ = { 0.5f, 0.5f };
98 Vector3f localPos_;
99 PositionedText labelData_;
100 std::optional<ImGuiMeasurementIndicators::Params> overrideParams_;
101 boost::signals2::scoped_connection parentXfConnection_;
102};
103
104
105}
106
107#endif
Definition MRObjectLabel.h:29
named object in the data model
Definition MRObject.h:62
void setPosition(const Vector3f &pos)
Set text position.
AncillaryLabel(AncillaryLabel &&b) noexcept=default
since this uniquely owns an ancillary object, we provide only move operations, not copy
void make(const PositionedText &text)
Make label in world space coordinates.
void overrideParams(const ImGuiMeasurementIndicators::Params &params)
Optionally override rendering params for this label.
void setDepthTest(bool depthTest)
Set depth test.
void reset()
clears this instance
void make(Object &parent, const PositionedText &text)
Make label in parent space coordinates, follows parent worldXf.
std::shared_ptr< ObjectLabel > obj
Definition MRAncillaryLabels.h:25
void make(Object &parent, const PositionedText &text, bool depthTest=false)
Make not-pickable ancillary object, link it to parent object, and set label text.
void setPivot(Vector2f pivot)
Definition MRAncillaryLabels.h:86
Vector2f getPivot() const
Definition MRAncillaryLabels.h:85
void resetText()
Reset label text.
void setText(const PositionedText &text)
Set label text.
void make(std::shared_ptr< Object > parent, const PositionedText &text)
AncillaryLabel()=default
static std::shared_ptr< ObjectLabel > makeDetached(const PositionedText &text, bool depthTest=false)
Make not-pickable ancillary object without parent object, and set label text.
void resetOverrideParams()
use default parameters instead of overridden ones
~AncillaryLabel()
detach owned object from parent, stops owning it
Definition MRAncillaryLabels.h:48
void reset()
detach owned object from parent, stops owning it
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:34
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRImGuiMeasurementIndicators.h:40
Definition MRPositionedText.h:13
Definition MRViewerEventsListener.h:171