MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRenderDimensions.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh/MRColor.h"
5#include "MRMesh/MRVector2.h"
7#include "MRViewer/exports.h"
8
9#include <optional>
10
11namespace MR
12{
13class Viewport;
14}
15
17{
18
20{
21 float positive = 0; // Should be positive or zero.
22 float negative = 0; // Should be negative or zero.
23};
24
26{
27 // What object to select when the label is clicked.
28 // Optional. Not clickable if this is null.
29 const VisualObject* objectToSelect = nullptr;
30
31 // Optional. If specified, this name is drawn above the measurement.
32 std::string objectName;
33};
34
36{
38
39 Vector3f point; // The world point.
40
41 // [1,1] to display the text to the bottom-right of the point, [-1,-1] to display it to the top-left.
42 // Typically either X or Y here should be 1 or -1.
43 ImVec2 align = ImVec2( 1, 1 );
44
45 // If specified, we're comparing `point` against this position.
46 std::optional<Vector3f> referencePoint;
47
48 // Only makes sense if `referencePoint` is set.
49 // If specified, we're measuring along this normal. Otherwise we're using eucledian distance.
50 // This doesn't need to be normalized.
52
53 // Tolerances. Only make sense if `referencePoint` is set.
54 // The `.negative` here only makes sense if `referenceNormal` is also set.
55 std::optional<Tolerance> tolerance;
56
57 // Whether to draw the cap or not.
58 bool capIsVisible = true;
59};
60
62{
63 Viewport* viewport_ = nullptr;
64 Color color_;
65 PointParams params_;
66
67public:
69
70 MRVIEWER_API PointTask( const UiRenderParams& uiParams, const AffineXf3f& xf, Color color, const PointParams& params );
71 MRVIEWER_API void renderPass() override;
72
73 // Implement `BasicClickableRectUiRenderTask`:
74 MRVIEWER_API void onClick() override;
75};
76
78{
80
81 // The center point.
82 Vector3f center;
83
84 // The length of this is the radius. This is also the preferred drawing direction relative to `center`.
85 Vector3f radiusAsVector = Vector3f( 1, 0, 0 );
86
87 // The preferred normal for non-spherical radiuses. The length is ignored, and this is automatically adjusted to be perpendicular to `radiusAsVector`.
88 Vector3f normal = Vector3f( 0, 0, 1 );
89
90 // Whether we should draw this as a diameter instead of a radius.
91 bool drawAsDiameter = false;
92
93 // Whether this is a sphere radius, as opposed to circle/cylinder radius.
94 bool isSpherical = false;
95
96 // The visual leader line length multiplier, relative to the radius.
97 // You're recommended to set a min absolute value for the resulting length when rendering.
98 float visualLengthMultiplier = 2 / 3.f;
99};
100
102{
103 Viewport* viewport_ = nullptr;
104 Color color_;
105 RadiusParams params_;
106
107public:
109
110 MRVIEWER_API RadiusTask( const UiRenderParams& uiParams, const AffineXf3f& xf, Color color, const RadiusParams& params );
111 MRVIEWER_API void renderPass() override;
112
113 // Implement `BasicClickableRectUiRenderTask`:
114 MRVIEWER_API void onClick() override;
115};
116
118{
120
121 // The center point.
122 Vector3f center;
123
124 // The two rays.
125 // Use the length of the shorter ray as the arc radius.
126 std::array<Vector3f, 2> rays;
127
128 // Whether this is a conical angle. The middle line between the rays is preserved, but the rays themselves can be rotated.
129 bool isConical = false;
130
131 // Whether we should draw a ray from the center point to better visualize the angle. Enable this if there isn't already a line object there.
132 std::array<bool, 2> shouldVisualizeRay{ true, true };
133};
134
136{
137 Viewport* viewport_ = nullptr;
138 Color color_;
139 AngleParams params_;
140
141public:
143 MRVIEWER_API AngleTask( const UiRenderParams& uiParams, const AffineXf3f& xf, Color color, const AngleParams& params );
144 MRVIEWER_API void renderPass() override;
145
146 // Implement `BasicClickableRectUiRenderTask`:
147 MRVIEWER_API void onClick() override;
148};
149
150
152{
154
155 // The points between which we're measuring.
156 std::array<Vector3f, 2> points;
157
158 // Whether the distance should be displayed as a negative one.
159 bool drawAsNegative = false;
160
161 // If set, use only once axis (with this index, 0..2) instead of euclidean.
162 std::optional<int> onlyOneAxis;
163
164 // If set, we're comparing the distance with a reference value.
165 std::optional<float> referenceValue;
166
167 // Tolerances. Only make sense if `referenceValue` is set.
168 std::optional<Tolerance> tolerance;
169};
170
172{
173 Viewport* viewport_ = nullptr;
174 Color color_;
175 LengthParams params_;
176
177 // For single-axis measurements, this computes the corner point.
178 MRVIEWER_API Vector3f computeCornerPoint();
179
180public:
182 MRVIEWER_API LengthTask( const UiRenderParams& uiParams, const AffineXf3f& xf, Color color, const LengthParams& params );
183 MRVIEWER_API void renderPass() override;
184
185 // Implement `BasicClickableRectUiRenderTask`:
186 MRVIEWER_API void onClick() override;
187};
188
189}
Definition MRRenderClickableRect.h:14
Definition MRRenderDimensions.h:136
AngleTask()
Definition MRRenderDimensions.h:142
MRVIEWER_API void onClick() override
MRVIEWER_API void renderPass() override
This is the main rendering pass.
MRVIEWER_API AngleTask(const UiRenderParams &uiParams, const AffineXf3f &xf, Color color, const AngleParams &params)
Definition MRRenderDimensions.h:172
LengthTask()
Definition MRRenderDimensions.h:181
MRVIEWER_API LengthTask(const UiRenderParams &uiParams, const AffineXf3f &xf, Color color, const LengthParams &params)
MRVIEWER_API void renderPass() override
This is the main rendering pass.
MRVIEWER_API void onClick() override
Definition MRRenderDimensions.h:62
MRVIEWER_API void onClick() override
PointTask()
Definition MRRenderDimensions.h:68
MRVIEWER_API void renderPass() override
This is the main rendering pass.
MRVIEWER_API PointTask(const UiRenderParams &uiParams, const AffineXf3f &xf, Color color, const PointParams &params)
Definition MRRenderDimensions.h:102
MRVIEWER_API RadiusTask(const UiRenderParams &uiParams, const AffineXf3f &xf, Color color, const RadiusParams &params)
RadiusTask()
Definition MRRenderDimensions.h:108
MRVIEWER_API void onClick() override
MRVIEWER_API void renderPass() override
This is the main rendering pass.
Definition MRViewport.h:46
Visual Object.
Definition MRVisualObject.h:119
Definition MRRenderDimensions.h:17
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh/MRColor.h:9
Definition MRRenderDimensions.h:118
std::array< Vector3f, 2 > rays
Definition MRRenderDimensions.h:126
Vector3f center
Definition MRRenderDimensions.h:122
std::array< bool, 2 > shouldVisualizeRay
Definition MRRenderDimensions.h:132
bool isConical
Definition MRRenderDimensions.h:129
CommonParams common
Definition MRRenderDimensions.h:119
Definition MRRenderDimensions.h:26
const VisualObject * objectToSelect
Definition MRRenderDimensions.h:29
std::string objectName
Definition MRRenderDimensions.h:32
Definition MRRenderDimensions.h:152
std::array< Vector3f, 2 > points
Definition MRRenderDimensions.h:156
bool drawAsNegative
Definition MRRenderDimensions.h:159
std::optional< int > onlyOneAxis
Definition MRRenderDimensions.h:162
CommonParams common
Definition MRRenderDimensions.h:153
std::optional< float > referenceValue
Definition MRRenderDimensions.h:165
std::optional< Tolerance > tolerance
Definition MRRenderDimensions.h:168
Definition MRRenderDimensions.h:36
std::optional< Tolerance > tolerance
Definition MRRenderDimensions.h:55
std::optional< Vector3f > referencePoint
Definition MRRenderDimensions.h:46
bool capIsVisible
Definition MRRenderDimensions.h:58
Vector3f referenceNormal
Definition MRRenderDimensions.h:51
ImVec2 align
Definition MRRenderDimensions.h:43
Vector3f point
Definition MRRenderDimensions.h:39
CommonParams common
Definition MRRenderDimensions.h:37
Definition MRRenderDimensions.h:78
bool drawAsDiameter
Definition MRRenderDimensions.h:91
bool isSpherical
Definition MRRenderDimensions.h:94
float visualLengthMultiplier
Definition MRRenderDimensions.h:98
Vector3f radiusAsVector
Definition MRRenderDimensions.h:85
CommonParams common
Definition MRRenderDimensions.h:79
Vector3f normal
Definition MRRenderDimensions.h:88
Vector3f center
Definition MRRenderDimensions.h:82
Definition MRRenderDimensions.h:20
float positive
Definition MRRenderDimensions.h:21
float negative
Definition MRRenderDimensions.h:22
Definition MRIRenderObject.h:107