4#include "MRViewer/exports.h"
34 [[nodiscard]]
float get(
bool end )
const {
return end ?
b :
a; }
41 ImDrawList*
list = ImGui::GetBackgroundDrawList();
134 using ElemVar = std::variant<std::string, TextIcon, TextColor, TextFont>;
218 lines.emplace_back();
219 lines.back().elems.emplace_back().var = std::string();
232 lines.back().elems.emplace_back( std::move( elem ) );
238 addElem( { .var =
decltype(elem)(elem) } );
243 MRVIEWER_API
void update(
bool force =
false )
const;
320MRVIEWER_API std::optional<TextResult>
text(
323 ImVec2 push = {}, ImVec2 pivot = { 0.5f, 0.5f }
364 std::optional<LineResult>
line;
365 std::optional<TextResult>
text;
388 [[nodiscard]] ImVec2
endPoint(
bool second )
const {
return second ?
b :
a; }
406template <
typename A,
typename B,
typename F,
typename G,
typename H = std::
nullptr_t>
408 F&& stateToPoint, G&& bisectState, H&& onInsertPoint =
nullptr
413 std::size_t firstIndex = pointBuffer.size();
415 auto makeCurve = [&](
auto makeCurve,
int depth,
const auto& stateA,
const auto& stateB, ImVec2 pointA, ImVec2 pointB ) ->
void
422 auto midState = bisectState( stateA, stateB,
int(
depth ) );
423 ImVec2 midPoint = stateToPoint( midState );
425 makeCurve( makeCurve,
depth + 1, stateA, midState, pointA, midPoint );
426 makeCurve( makeCurve,
depth + 1, midState, stateB, midPoint, pointB );
432 onInsertPoint( pointB, stateB );
433 pointBuffer.push_back( pointB );
437 ImVec2 firstPoint = stateToPoint( stateA );
438 makeCurve( makeCurve, 0, stateA, stateB, firstPoint, stateToPoint( stateB ) );
441 pointBuffer.pop_back();
442 ret.midPoints = { pointBuffer.data() + firstIndex, pointBuffer.data() + pointBuffer.size() };
#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 ¶ms, ImVec2 a, ImVec2 b, const LineParams &lineParams={})
MRVIEWER_API void arrowTriangle(Element elem, const Params ¶ms, 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
@ noBackwardArrowTipOffset
Element
Definition MRImGuiMeasurementIndicators.h:99
MRVIEWER_API std::optional< TextResult > text(Element elem, const Params ¶ms, 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 ¶ms, 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