MeshLib C++ Docs
Loading...
Searching...
No Matches
MRImGuiMeasurementIndicators.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRViewer/exports.h"
7
8#include <imgui.h>
9
10#include <cassert>
11#include <optional>
12#include <span>
13#include <variant>
14
16{
17
18// Parameters for drawing dotted lines.
19struct Stipple
20{
21 // This is the period of the stipple pattern, in pixels.
22 // This is automatically multiplied by `UI::scale()`.
23 float patternLength = 16;
24
25 struct Segment
26 {
27 // This is the start and end positions of this segment, from 0 to 1. This is automatically multiplied by `patternLength`.
28 // You must ensure `0 <= a < b <= 1`, and if there are multiple segments, that `segments[i].b < segments[i + 1].a`.
29 // The only exception to this is that the `b` of the last segment can be less than the `a` of the last segment,
30 // as long as it's also less than the `a` of the first segment. This can help with pattern wraparound.
31 float a = 0;
32 float b = 0;
33
34 [[nodiscard]] float get( bool end ) const { return end ? b : a; }
35 };
36 std::span<const Segment> segments;
37};
38
39struct Params
40{
41 ImDrawList* list = ImGui::GetBackgroundDrawList();
48
49 float pointDiameter = 6;
50
51 float width = 1.5f;
52 float smallWidth = 0.75f;
53 float outlineWidth = 1.5f;
54 float textOutlineWidth = 4.f;
56
60
61 float arrowLen = 12;
62 float arrowHalfWidth = 4;
63 // The arrow tip is moved back for this amount of pixels,
64 // to compensate for the outline that otherwise makes the tip look longer than it actually is.
65 // This only applies if the tip doesn't continue into a line.
67
68 // The spacing box around the text is extended by this amount.
69 ImVec2 textToLineSpacingA = ImVec2( 0, 0 ); // Top-left corner.
70 ImVec2 textToLineSpacingB = ImVec2( 0, 0 ); // Bottom-right corner.
71 // Further, the lines around the text are shortened by this amount.
73
74 // For a distance, when the total length is less than this, an alternative rendering method is used.
75 // If the text is added, its size can make the actual threshold larger.
77
78 // When drawing inverted (short) distances, the line is extended by this amount on both sides.
79 float invertedOverhang = 24;
80
81 // The length of the leader lines (short lines attaching text to other things).
82 float leaderLineLen = 20;
83
84 // A small perpendicular line at the end of some arrows.
85 float notchHalfLen = 8;
86
87 // We don't use those directly, but you can pass them to `LineParams::stipple` if you want:
88 // [
89
90 // --- --- ---
92 // ]
93
94 // This picks the colors based on the current color theme.
95 MRVIEWER_API Params();
96};
97
98enum class Element
99{
100 main = 1 << 0,
101 outline = 1 << 1,
102 both = main | outline, // Use this by default.
103};
105
106// Draws a point.
107MRVIEWER_API void point( Element elem, const Params& params, ImVec2 point );
108
109enum class TextIcon
110{
111 diameter,
112};
113
115{
116 // If null, resets the color.
117 std::optional<ImU32> color;
118
120 TextColor( ImVec4 color ) : color( ImGui::ColorConvertFloat4ToU32( color ) ) {}
121 TextColor( ImU32 color ) : color( color ) {}
122};
123
125{
126 // If null, resets the font to the default.
127 ImFont* font = nullptr;
128 float size = 0.f;
129};
130
131// Represents an arbitrary block of text, possibly with icons, colors, etc.
132struct Text
133{
134 using ElemVar = std::variant<std::string, TextIcon, TextColor, TextFont>;
135
136 struct Elem
137 {
139
140 // The minimum element size. Has no effect if smaller than `computedSize`.
141 // Here if Y is negative, inherits the line height.
142 ImVec2 size = ImVec2( 0, -1 );
143
144 // Alignment. Only makes sense if `size` is set.
145 // [0,0] = top-left, [1,1] = bottom-right.
146 ImVec2 align;
147
148 // If set, will increase width to the maximum of all elements with the same column id.
149 // This affects how `computedSizeWithPadding` is computed.
150 int columnId = -1;
151
152 // The computed content size. Read-only. Don't set manually, `update()` sets this.
153 mutable ImVec2 computedSize;
154
155 // Read-only, don't set manually. This is typically `max( size, computedSize )`, with additional adjustments.
157
158 [[nodiscard]] bool hasDefaultParams() const
159 {
160 return size == ImVec2( 0, -1 ) && align == ImVec2() && columnId == -1;
161 }
162 };
163
164 struct Line
165 {
166 std::vector<Elem> elems;
167
168 // The minimum element size. Has no effect if smaller than `computedSize`.
169 // Here if X is negative, inherits the text width.
170 ImVec2 size = ImVec2( -1, 0 );
171
172 // Alignment. Only makes sense if `size` is set.
173 // [0,0] = top-left, [1,1] = bottom-right.
174 ImVec2 align;
175
176 // The computed content size. Read-only. Don't set manually, `update()` sets this.
177 mutable ImVec2 computedSize;
178
179 // Read-only, don't set manually. This is typically `max( size, computedSize )`, with additional adjustments.
181 };
182
183 std::vector<Line> lines;
184
185 // The text size for alignment. Unlike `size` in other elements below, this isn't the minimum size.
186 // If this is zero, `align` will pivot the text around a point, as opposed to in a box (the math for this just happens to work automatically).
187 ImVec2 size;
188
189 // Alignment. [0,0] = top-left, [1,1] = bottom-right.
190 ImVec2 align;
191
192 using FontFunc = std::function<FontAndSize()>;
193 // Get the default value for `.defaultFont`. This can be null to default to null, which means the current font.
194 [[nodiscard]] MRVIEWER_API static const FontFunc& getStaticDefaultFontFunc();
195 MRVIEWER_API static void setStaticDefaultFontFunc( FontFunc func );
196
197 // If null, uses the current font. Currently this defaults to a monospaced font.
198 // This is here because `update()` needs to know the font too.
200
201 // The computed content size. Read-only. Don't set manually, `update()` sets this.
202 mutable ImVec2 computedSize;
203
204 // No `computedSizeWithPadding`, because for the entire `Text` we use `size` exactly, without `max( size, computedSize )`.
205
206 mutable bool dirty = false;
207
208 Text() {}
209 Text( const std::string& text ) { addText( text ); }
210 Text( std::string_view text ) { addText( text ); }
211 Text( const char* text ) { addText( text ); }
212
213 [[nodiscard]] bool isEmpty() const { return lines.empty(); }
214
215 void addLine()
216 {
217 dirty = true;
218 lines.emplace_back();
219 lines.back().elems.emplace_back().var = std::string(); // Add an empty string to force some vertical size on empty lines.
220 }
221
222 // Adds some string to the text. Automatically splits by newlines.
223 MRVIEWER_API void addText( std::string_view text );
224
225 // A low-level function for adding layout elements.
226 // For strings prefer `addText()`. This function doesn't automatically split them by newlines, and so on.
227 void addElem( Elem elem )
228 {
229 dirty = true;
230 if ( lines.empty() )
231 addLine();
232 lines.back().elems.emplace_back( std::move( elem ) );
233 }
234
235 // Adds any element type of `ElemVar`.
236 void add( auto&& elem )
237 {
238 addElem( { .var = decltype(elem)(elem) } );
239 }
240
241 // Recalculate `computedSize` in various places in this class.
242 // If `force == false`, only acts if `dirty == true`. In any case, resets the dirty flag.
243 MRVIEWER_API void update( bool force = false ) const;
244
246 {
247 ImVec2 cornerA;
248 ImVec2 cornerB;
249 };
250
251 // Draws the text to the specified draw list. Automatically calls `update()`.
252 // If `defaultTextColor` is not specified, takes it from ImGui.
253 MRVIEWER_API DrawResult draw( ImDrawList& list, ImVec2 pos, const TextColor& defaultTextColor = {} ) const;
254};
255
257{
258 none,
259 noOutline, // Almost exactly like `none`, but don't draw the tiny bit of outline at the end. This can look better in some scenarios.
260 extend, // No special decoration, but the line extends a bit after the target point.
261 arrow,
262 point, // A small circle.
263};
264
265enum class LineFlags
266{
267 narrow = 1 << 0,
268 noBackwardArrowTipOffset = 1 << 1, // Overrides `params.arrowTipBackwardOffset` to zero.
269 onlyOutline = 1 << 2, // Only draw a thin line of the outline color, don't use the normal color at all.
270};
272
274{
275 LineFlags flags{};
276
277 std::optional<Color> colorOverride;
278
279 // For drawing dotted lines. You can get presets for this parameter from `ImGuiMeasurementIndicators::Params::stipple___`.
280 std::optional<Stipple> stipple;
281};
282
284{
285 // Optional. The convention is that this should only be set if the text is possible to hover.
286 // The border is drawn only if the alpha of this isn't zero.
288
295 // Optional. Draw a line to this point from the text bubble.
296 std::optional<Line> line;
297
298 // Should imply `borderColor`.
299 bool isHovered = false;
300 // Should imply `isHovered`.
301 bool isActive = false;
302
303 // This is independent from the bools above, but currently requires `borderColor` to be meaningful.
304 bool isSelected = false;
305};
306
308{
309 ImVec2 textCornerA; // The narrow rect right around the text.
311 ImVec2 bgCornerA; // The padded rect of the text background.
312 ImVec2 bgCornerB;
313};
314
315// Draws a floating text bubble.
316// If `push` is specified, it's normalized and the text is pushed in that direction,
317// by the amount necessarily to clear a perpendicular going through the center point.
318// If `pivot` is specified, the bubble is positioned according to its size (like in ImGui::SetNextWindowPos):
319// { 0, 0 } for top left corner, { 0.5f, 0.5f } for center (default), { 1, 1 } for bottom right corner.
320MRVIEWER_API std::optional<TextResult> text(
321 Element elem, const Params& params, ImVec2 pos,
322 const Text& text, const TextParams& textParams = {},
323 ImVec2 push = {}, ImVec2 pivot = { 0.5f, 0.5f }
324);
325
326// Draws a triangle from an arrow.
327MRVIEWER_API void arrowTriangle( Element elem, const Params& params, ImVec2 point, ImVec2 dir );
328
336
338{
342
343 std::span<const ImVec2> midPoints;
344};
345
347{
348 std::optional<TextResult> capA, capB;
349};
350
351// Draws a line or an arrow.
352MRVIEWER_API std::optional<LineResult> line( Element elem, const Params& params, ImVec2 a, ImVec2 b, const LineParams& lineParams = {} );
353
355{
356 // If this is set, the text is moved from the middle of the line to one of the line ends (false = A, true = B).
357 std::optional<bool> moveTextToLineEndIndex;
358
360};
361
363{
364 std::optional<LineResult> line;
365 std::optional<TextResult> text;
366};
367
368// Draws a distance arrow between two points, automatically selecting the best visual style.
369// The `string` is optional.
370MRVIEWER_API std::optional<DistanceResult> distance( Element elem, const Params& params, ImVec2 a, ImVec2 b, const Text& text, const DistanceParams& distanceParams = {} );
371
373{
374 // How many times can be subdivide a curve (resuling in up to 2^depth segments).
376 // A curve is always subdivided at least this many times.
378 // If a curve segment is longer than this, it gets divided in two.
379 // You probably don't want to multiply this by `UI::scale()`, and we don't do it automatically.
381};
382
384{
385 ImVec2 a; // The first point.
386 ImVec2 b; // The last point.
387
388 [[nodiscard]] ImVec2 endPoint( bool second ) const { return second ? b : a; }
389
390 std::span<ImVec2> midPoints; // All the points in between.
391};
392
393// Calculates points for a custom curve, from a function you provide. You can then draw this curve as a `line()`.
394// The points are appended into `pointBuffer` (and for convenience the new points are also returned as `.midPoints`;
395// the first and the last point are not inserted into the vector and are not included in `.midPoints`, they sit in `.a` and `.b`).
396// You should reuse `pointBuffer` between calls for better performance (and `.clear()` it each time you finish drawing the resulting curve,
397// which conveniently preserves vector capacity). Or, if you don't care, just pass an empty vector, and keep it alive as long as you need the curve.
398// `stateA` and `stateB` can have any type, they describe the beginning and the end of the curve respectively. They might often be `0.f` and `1.f`.
399// Let `S` be the type of `stateA`/`stateB` (more on that belw).
400// `stateToPoint` is a lambda `(const S &s) -> ImVec2`. It converts a state into a curve point coordinates.
401// `bisectState` is a lambda `(const S &a, const S &b, int depth) -> S`. Given two states, it produces the state between them. `depth` starts at `0`.
402// `onInsertPoint`, if specified, is a lambda `(ImVec2 point, const S &state) -> void`. It's called right before a point is added into the list.
403// It's actually possible to have multiple state types instead of a single `S`, and template your functions (e.g. to track bisection depth in the type system, etc).
404// Example usage:
405// prepareCurve( params, buf, 0, PI*2, [](float x){return std::sin(x);}, [](float a, float b, int /*depth*/){return (a+b)/2;} )
406template <typename A, typename B, typename F, typename G, typename H = std::nullptr_t>
407[[nodiscard]] PreparedCurve prepareCurve( const CurveParams& curveParams, std::vector<ImVec2>& pointBuffer, const A& stateA, const B& stateB,
408 F&& stateToPoint, G&& bisectState, H&& onInsertPoint = nullptr
409)
410{
411 const float pixelStepSq = curveParams.subdivisionStepPixels * curveParams.subdivisionStepPixels;
412
413 std::size_t firstIndex = pointBuffer.size();
414
415 auto makeCurve = [&]( auto makeCurve, int depth, const auto& stateA, const auto& stateB, ImVec2 pointA, ImVec2 pointB ) -> void
416 {
417 // Check if we need to subdivide.
418 if ( depth < curveParams.maxSubdivisionDepth && ( depth < curveParams.minSubdivisionDepth || ImGuiMath::lengthSq( pointB - pointA ) > pixelStepSq ) )
419 {
420 // Do subdivide.
421
422 auto midState = bisectState( stateA, stateB, int( depth ) ); // A cast to prevent modification.
423 ImVec2 midPoint = stateToPoint( midState );
424
425 makeCurve( makeCurve, depth + 1, stateA, midState, pointA, midPoint );
426 makeCurve( makeCurve, depth + 1, midState, stateB, midPoint, pointB );
427 }
428 else
429 {
430 // No subdivide.
431
432 onInsertPoint( pointB, stateB );
433 pointBuffer.push_back( pointB );
434 }
435
436 };
437 ImVec2 firstPoint = stateToPoint( stateA );
438 makeCurve( makeCurve, 0, stateA, stateB, firstPoint, stateToPoint( stateB ) );
439
440 PreparedCurve ret{ .a = firstPoint, .b = pointBuffer.back() };
441 pointBuffer.pop_back();
442 ret.midPoints = { pointBuffer.data() + firstIndex, pointBuffer.data() + pointBuffer.size() };
443 return ret;
444}
445
446} // namespace MR::ImGuiMeasurementIndicators
#define MR_MAKE_FLAG_OPERATORS(T)
Definition MRFlagOperators.h:6
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:378
auto depth(const Box< V > &box)
returns size along z axis
Definition MRMesh/MRBox.h:355
Definition ImGuiHelpers.h:33
constexpr auto lengthSq(A a)
Definition MRImGuiVectorOperators.h:131
Definition MRImGuiMeasurementIndicators.h:16
LineCapDecoration
Definition MRImGuiMeasurementIndicators.h:257
MRVIEWER_API std::optional< LineResult > line(Element elem, const Params &params, ImVec2 a, ImVec2 b, const LineParams &lineParams={})
MRVIEWER_API void arrowTriangle(Element elem, const Params &params, ImVec2 point, ImVec2 dir)
PreparedCurve prepareCurve(const CurveParams &curveParams, std::vector< ImVec2 > &pointBuffer, const A &stateA, const B &stateB, F &&stateToPoint, G &&bisectState, H &&onInsertPoint=nullptr)
Definition MRImGuiMeasurementIndicators.h:407
LineFlags
Definition MRImGuiMeasurementIndicators.h:266
Element
Definition MRImGuiMeasurementIndicators.h:99
MRVIEWER_API std::optional< TextResult > text(Element elem, const Params &params, ImVec2 pos, const Text &text, const TextParams &textParams={}, ImVec2 push={}, ImVec2 pivot={ 0.5f, 0.5f })
TextIcon
Definition MRImGuiMeasurementIndicators.h:110
MRVIEWER_API std::optional< DistanceResult > distance(Element elem, const Params &params, ImVec2 a, ImVec2 b, const Text &text, const DistanceParams &distanceParams={})
std::pair< ImFont *, float > FontAndSize
Definition MRViewerFwd.h:89
Definition MRMesh/MRColor.h:9
static constexpr Color transparent() noexcept
Definition MRMesh/MRColor.h:34
Definition MRImGuiMeasurementIndicators.h:373
int maxSubdivisionDepth
Definition MRImGuiMeasurementIndicators.h:375
float subdivisionStepPixels
Definition MRImGuiMeasurementIndicators.h:380
int minSubdivisionDepth
Definition MRImGuiMeasurementIndicators.h:377
Definition MRImGuiMeasurementIndicators.h:355
std::optional< bool > moveTextToLineEndIndex
Definition MRImGuiMeasurementIndicators.h:357
TextParams textParams
Definition MRImGuiMeasurementIndicators.h:359
Definition MRImGuiMeasurementIndicators.h:363
std::optional< TextResult > text
Definition MRImGuiMeasurementIndicators.h:365
std::optional< LineResult > line
Definition MRImGuiMeasurementIndicators.h:364
Definition MRImGuiMeasurementIndicators.h:274
std::optional< Stipple > stipple
Definition MRImGuiMeasurementIndicators.h:280
std::optional< Color > colorOverride
Definition MRImGuiMeasurementIndicators.h:277
Definition MRImGuiMeasurementIndicators.h:330
TextParams textParams
Definition MRImGuiMeasurementIndicators.h:334
LineCapDecoration decoration
Definition MRImGuiMeasurementIndicators.h:331
Text text
Definition MRImGuiMeasurementIndicators.h:333
Definition MRImGuiMeasurementIndicators.h:338
LineCap capA
Definition MRImGuiMeasurementIndicators.h:340
LineBodyParams body
Definition MRImGuiMeasurementIndicators.h:339
std::span< const ImVec2 > midPoints
Definition MRImGuiMeasurementIndicators.h:343
LineCap capB
Definition MRImGuiMeasurementIndicators.h:341
Definition MRImGuiMeasurementIndicators.h:347
std::optional< TextResult > capA
Definition MRImGuiMeasurementIndicators.h:348
std::optional< TextResult > capB
Definition MRImGuiMeasurementIndicators.h:348
Definition MRImGuiMeasurementIndicators.h:40
Color colorTextOutlineActive
Definition MRImGuiMeasurementIndicators.h:47
float width
Definition MRImGuiMeasurementIndicators.h:51
float smallWidth
Definition MRImGuiMeasurementIndicators.h:52
Stipple stippleDashed
Definition MRImGuiMeasurementIndicators.h:91
float totalLenThreshold
Definition MRImGuiMeasurementIndicators.h:76
Color colorTextOutlineHovered
Definition MRImGuiMeasurementIndicators.h:46
float arrowHalfWidth
Definition MRImGuiMeasurementIndicators.h:62
float arrowLen
Definition MRImGuiMeasurementIndicators.h:61
float textToLineSpacingRadius
Definition MRImGuiMeasurementIndicators.h:72
float notchHalfLen
Definition MRImGuiMeasurementIndicators.h:85
float textOutlineWidth
Definition MRImGuiMeasurementIndicators.h:54
float leaderLineLen
Definition MRImGuiMeasurementIndicators.h:82
Color colorOutline
Definition MRImGuiMeasurementIndicators.h:43
float arrowTipBackwardOffset
Definition MRImGuiMeasurementIndicators.h:66
Color colorMain
Definition MRImGuiMeasurementIndicators.h:42
Color colorTextOutline
Definition MRImGuiMeasurementIndicators.h:45
float clickableLabelLineWidth
Definition MRImGuiMeasurementIndicators.h:57
ImVec2 textToLineSpacingB
Definition MRImGuiMeasurementIndicators.h:70
float pointDiameter
Definition MRImGuiMeasurementIndicators.h:49
ImDrawList * list
Definition MRImGuiMeasurementIndicators.h:41
float clickableLabelOutlineWidth
Definition MRImGuiMeasurementIndicators.h:59
Color colorText
Definition MRImGuiMeasurementIndicators.h:44
ImVec2 textToLineSpacingA
Definition MRImGuiMeasurementIndicators.h:69
float outlineWidth
Definition MRImGuiMeasurementIndicators.h:53
float clickableLabelLineWidthSelected
Definition MRImGuiMeasurementIndicators.h:58
float invertedOverhang
Definition MRImGuiMeasurementIndicators.h:79
float textOutlineRounding
Definition MRImGuiMeasurementIndicators.h:55
Definition MRImGuiMeasurementIndicators.h:384
ImVec2 a
Definition MRImGuiMeasurementIndicators.h:385
ImVec2 b
Definition MRImGuiMeasurementIndicators.h:386
std::span< ImVec2 > midPoints
Definition MRImGuiMeasurementIndicators.h:390
ImVec2 endPoint(bool second) const
Definition MRImGuiMeasurementIndicators.h:388
Definition MRImGuiMeasurementIndicators.h:26
float b
Definition MRImGuiMeasurementIndicators.h:32
float a
Definition MRImGuiMeasurementIndicators.h:31
float get(bool end) const
Definition MRImGuiMeasurementIndicators.h:34
Definition MRImGuiMeasurementIndicators.h:20
float patternLength
Definition MRImGuiMeasurementIndicators.h:23
std::span< const Segment > segments
Definition MRImGuiMeasurementIndicators.h:36
Definition MRImGuiMeasurementIndicators.h:115
TextColor(ImU32 color)
Definition MRImGuiMeasurementIndicators.h:121
TextColor()
Definition MRImGuiMeasurementIndicators.h:119
std::optional< ImU32 > color
Definition MRImGuiMeasurementIndicators.h:117
TextColor(ImVec4 color)
Definition MRImGuiMeasurementIndicators.h:120
Definition MRImGuiMeasurementIndicators.h:125
ImFont * font
Definition MRImGuiMeasurementIndicators.h:127
float size
Definition MRImGuiMeasurementIndicators.h:128
Definition MRImGuiMeasurementIndicators.h:290
LineCapDecoration capDecoration
Definition MRImGuiMeasurementIndicators.h:292
ImVec2 point
Definition MRImGuiMeasurementIndicators.h:291
LineBodyParams body
Definition MRImGuiMeasurementIndicators.h:293
Definition MRImGuiMeasurementIndicators.h:284
Color borderColor
Definition MRImGuiMeasurementIndicators.h:287
bool isSelected
Definition MRImGuiMeasurementIndicators.h:304
bool isHovered
Definition MRImGuiMeasurementIndicators.h:299
std::optional< Line > line
Definition MRImGuiMeasurementIndicators.h:296
bool isActive
Definition MRImGuiMeasurementIndicators.h:301
Definition MRImGuiMeasurementIndicators.h:308
ImVec2 bgCornerB
Definition MRImGuiMeasurementIndicators.h:312
ImVec2 bgCornerA
Definition MRImGuiMeasurementIndicators.h:311
ImVec2 textCornerB
Definition MRImGuiMeasurementIndicators.h:310
ImVec2 textCornerA
Definition MRImGuiMeasurementIndicators.h:309
Definition MRImGuiMeasurementIndicators.h:246
ImVec2 cornerA
Definition MRImGuiMeasurementIndicators.h:247
ImVec2 cornerB
Definition MRImGuiMeasurementIndicators.h:248
Definition MRImGuiMeasurementIndicators.h:137
bool hasDefaultParams() const
Definition MRImGuiMeasurementIndicators.h:158
ImVec2 computedSize
Definition MRImGuiMeasurementIndicators.h:153
ImVec2 size
Definition MRImGuiMeasurementIndicators.h:142
ElemVar var
Definition MRImGuiMeasurementIndicators.h:138
int columnId
Definition MRImGuiMeasurementIndicators.h:150
ImVec2 computedSizeWithPadding
Definition MRImGuiMeasurementIndicators.h:156
ImVec2 align
Definition MRImGuiMeasurementIndicators.h:146
Definition MRImGuiMeasurementIndicators.h:165
ImVec2 computedSizeWithPadding
Definition MRImGuiMeasurementIndicators.h:180
ImVec2 align
Definition MRImGuiMeasurementIndicators.h:174
ImVec2 size
Definition MRImGuiMeasurementIndicators.h:170
std::vector< Elem > elems
Definition MRImGuiMeasurementIndicators.h:166
ImVec2 computedSize
Definition MRImGuiMeasurementIndicators.h:177
Definition MRImGuiMeasurementIndicators.h:133
MRVIEWER_API void addText(std::string_view text)
void addElem(Elem elem)
Definition MRImGuiMeasurementIndicators.h:227
Text()
Definition MRImGuiMeasurementIndicators.h:208
FontAndSize defaultFont
Definition MRImGuiMeasurementIndicators.h:199
Text(std::string_view text)
Definition MRImGuiMeasurementIndicators.h:210
std::function< FontAndSize()> FontFunc
Definition MRImGuiMeasurementIndicators.h:192
MRVIEWER_API DrawResult draw(ImDrawList &list, ImVec2 pos, const TextColor &defaultTextColor={}) const
MRVIEWER_API void update(bool force=false) const
std::vector< Line > lines
Definition MRImGuiMeasurementIndicators.h:183
void addLine()
Definition MRImGuiMeasurementIndicators.h:215
ImVec2 size
Definition MRImGuiMeasurementIndicators.h:187
static MRVIEWER_API void setStaticDefaultFontFunc(FontFunc func)
Text(const char *text)
Definition MRImGuiMeasurementIndicators.h:211
Text(const std::string &text)
Definition MRImGuiMeasurementIndicators.h:209
void add(auto &&elem)
Definition MRImGuiMeasurementIndicators.h:236
bool isEmpty() const
Definition MRImGuiMeasurementIndicators.h:213
bool dirty
Definition MRImGuiMeasurementIndicators.h:206
ImVec2 computedSize
Definition MRImGuiMeasurementIndicators.h:202
static MRVIEWER_API const FontFunc & getStaticDefaultFontFunc()
std::variant< std::string, TextIcon, TextColor, TextFont > ElemVar
Definition MRImGuiMeasurementIndicators.h:134
ImVec2 align
Definition MRImGuiMeasurementIndicators.h:190