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"
7#include "MRViewer/exports.h"
8#include "MRViewer/MRImGui.h"
9
10#include <optional>
11
12namespace MR
13{
14
15class MRVIEWER_CLASS RenderNameObject : public virtual IRenderObject
16{
18 {
19 const VisualObject* object = nullptr;
20 const UiRenderParams* params = nullptr;
21
22 ImVec2 point;
23 ImVec2 point2;
24 ImVec2 textCenter;
25
27 ImVec2 textPos;
28 ImVec2 paddingA;
29 ImVec2 paddingB;
30
31 // Optional.
32 // This is displayed below the primary text. This one isn't clickable, and uses the standardized background color, instead of the one copied
33 // from the target object, which helps with drawing complex colored texts.
35 float textToExtraTextSpacing = 0;
36
37 MRVIEWER_API void renderPass() override;
38 MRVIEWER_API void onClick() 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 // The text displayed as the clickable object name.
47 MRVIEWER_API virtual ImGuiMeasurementIndicators::Text getObjectNameText( const VisualObject& object, ViewportId viewportId ) const;
48
49 // Optional. This text is displayed below the object name, and isn't clickable.
50 // This uses the standardized background color, as opposed to the primary text that copies the color from the object.
51 // So if you want to draw colored text, it's easier to do it here to avoid clashes with the object color.
52 MRVIEWER_API virtual ImGuiMeasurementIndicators::Text getObjectNameExtraText( const VisualObject& object, ViewportId viewportId ) const;
53
54 // The name tag is displayed as a text bubble, attached to a specific point on the model with at most 2-segment line.
55 // The first segment offset is specified in 3d model coordinates, and the second offset is in screen coordinates.
56 // 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.
57
59 Vector3f nameUiPoint;
60
63 bool nameUiPointIsRelativeToBoundingBoxCenter = true;
64
67
71
75
78 bool nameUiRotateLocalOffset90Degrees = false;
79};
80
81}
Definition MRRenderClickableRect.h:14
Definition MRIRenderObject.h:131
Definition MRRenderNameObject.h:16
Vector2f nameUiScreenOffset
Definition MRRenderNameObject.h:70
virtual MRVIEWER_API ImGuiMeasurementIndicators::Text getObjectNameExtraText(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:66
RenderNameObject(const VisualObject &object)
Definition MRRenderNameObject.h:42
MRVIEWER_API void renderUi(const UiRenderParams &params) override
std::optional< Vector3f > nameUiRotateToScreenPlaneAroundSphereCenter
Definition MRRenderNameObject.h:74
virtual MRVIEWER_API ImGuiMeasurementIndicators::Text getObjectNameText(const VisualObject &object, ViewportId viewportId) const
Vector3f nameUiPoint
The line attachment point.
Definition MRRenderNameObject.h:59
Definition MRViewportId.h:16
Visual Object.
Definition MRVisualObject.h:119
Definition MRCameraOrientationPlugin.h:8
Definition MRImGuiMeasurementIndicators.h:131
Definition MRIRenderObject.h:107