MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRenderNameObject.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRMesh/MRVector2.h"
5#include "MRViewer/exports.h"
6#include "MRViewer/MRImGui.h"
7
8#include <optional>
9
10namespace MR
11{
12
13class RenderNameObject : public virtual IRenderObject
14{
15 struct Task : BasicUiRenderTask
16 {
17 const VisualObject* object = nullptr;
18 const UiRenderParams* params = nullptr;
19
20 ImVec2 windowCornerA;
21 ImVec2 windowCornerB;
22
23 ImVec2 point;
24 ImVec2 point2;
25 ImVec2 textCenter;
26
27 std::string text;
28 ImVec2 textPos;
29 ImVec2 textSize;
30 ImVec2 paddingA;
31 ImVec2 paddingB;
32
33 bool prevFrameHovered = false;
34 bool isHovered = false;
35 bool isActive = false;
36
37 MRVIEWER_API void earlyBackwardPass( const BackwardPassParams& backParams ) override;
38 MRVIEWER_API void renderPass() override;
39 };
40 Task task_;
41public:
42 RenderNameObject( const VisualObject& object ) { task_.object = &object; }
43
44 MRVIEWER_API void renderUi( const UiRenderParams& params ) override;
45
46 MRVIEWER_API virtual std::string getObjectNameString( const VisualObject& object, ViewportId viewportId ) const;
47
48 // The name tag is displayed as a text bubble, attached to a specific point on the model with at most 2-segment line.
49 // The first segment offset is specified in 3d model coordinates, and the second offset is in screen coordinates.
50 // The offsets can be tiny, since any non-zero offset is automatically extended to make sure the text bubble doesn't overlap the attachment point.
51
53 Vector3f nameUiPoint;
54
57
61
65
69};
70
71}
Definition MRIRenderObject.h:134
Definition MRRenderNameObject.h:14
Vector2f nameUiScreenOffset
Definition MRRenderNameObject.h:60
virtual MRVIEWER_API std::string getObjectNameString(const VisualObject &object, ViewportId viewportId) const
Vector3f nameUiLocalOffset
Which way the name is moved relative to the point, in model space. The length is respected.
Definition MRRenderNameObject.h:56
RenderNameObject(const VisualObject &object)
Definition MRRenderNameObject.h:42
MRVIEWER_API void renderUi(const UiRenderParams &params) override
std::optional< Vector3f > nameUiRotateToScreenPlaneAroundSphereCenter
Definition MRRenderNameObject.h:64
Vector3f nameUiPoint
The line attachment point in model space.
Definition MRRenderNameObject.h:53
bool nameUiRotateLocalOffset90Degrees
Definition MRRenderNameObject.h:68
Definition MRViewportId.h:16
Visual Object.
Definition MRVisualObject.h:131
IRenderObject::renderUi() can emit zero or more or more of those tasks. They are sorted by depth ever...
Definition MRIRenderObject.h:61
Definition MRIRenderObject.h:107