MeshLib
 
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
7#include <imgui.h>
8
9#include <optional>
10
11namespace MR
12{
13
14class RenderNameObject : public virtual IRenderObject
15{
16 struct Task : BasicUiRenderTask
17 {
18 const VisualObject* object = nullptr;
19 const UiRenderParams* params = nullptr;
20
21 ImVec2 windowCornerA;
22 ImVec2 windowCornerB;
23
24 ImVec2 point;
25 ImVec2 point2;
26 ImVec2 textCenter;
27
28 std::string text;
29 ImVec2 textPos;
30 ImVec2 textSize;
31 ImVec2 paddingA;
32 ImVec2 paddingB;
33
34 bool prevFrameHovered = false;
35 bool isHovered = false;
36 bool isActive = false;
37
38 MRVIEWER_API void earlyBackwardPass( const BackwardPassParams& backParams ) override;
39 MRVIEWER_API void renderPass() override;
40 };
41 Task task_;
42public:
43 RenderNameObject( const VisualObject& object ) { task_.object = &object; }
44
45 MRVIEWER_API void renderUi( const UiRenderParams& params ) override;
46
47 MRVIEWER_API virtual std::string getObjectNameString( const VisualObject& object, ViewportId viewportId ) const;
48
49 // The name tag is displayed as a text bubble, attached to a specific point on the model with at most 2-segment line.
50 // The first segment offset is specified in 3d model coordinates, and the second offset is in screen coordinates.
51 // 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.
52
55
58
62
66
70};
71
72}
Definition MRIRenderObject.h:133
Definition MRRenderNameObject.h:15
Vector2f nameUiScreenOffset
Definition MRRenderNameObject.h:61
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:57
RenderNameObject(const VisualObject &object)
Definition MRRenderNameObject.h:43
MRVIEWER_API void renderUi(const UiRenderParams &params) override
std::optional< Vector3f > nameUiRotateToScreenPlaneAroundSphereCenter
Definition MRRenderNameObject.h:65
Vector3f nameUiPoint
The line attachment point in model space.
Definition MRRenderNameObject.h:54
bool nameUiRotateLocalOffset90Degrees
Definition MRRenderNameObject.h:69
Definition MRViewportId.h:16
Visual Object.
Definition MRVisualObject.h:131
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
Definition MRCameraOrientationPlugin.h:7
IRenderObject::renderUi() can emit zero or more or more of those tasks. They are sorted by depth ever...
Definition MRIRenderObject.h:60
Definition MRIRenderObject.h:106