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