MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / PlotText

Function PlotText

Source/3rdParty/implot/implot_items.cpp:3464–3490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3462//-----------------------------------------------------------------------------
3463
3464void PlotText(const char* text, double x, double y, const ImVec2& pixel_offset, const ImPlotSpec& spec) {
3465 IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != nullptr, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
3466 SetupLock();
3467 ImDrawList & draw_list = *GetPlotDrawList();
3468 PushPlotClipRect();
3469 ImU32 colTxt = GetStyleColorU32(ImPlotCol_InlayText);
3470 if (ImHasFlag(spec.Flags,ImPlotTextFlags_Vertical)) {
3471 ImVec2 siz = CalcTextSizeVertical(text) * 0.5f;
3472 ImVec2 ctr = siz * 0.5f;
3473 ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) + ImVec2(-ctr.x, ctr.y) + pixel_offset;
3474 if (FitThisFrame() && !ImHasFlag(spec.Flags, ImPlotItemFlags_NoFit)) {
3475 FitPoint(PixelsToPlot(pos));
3476 FitPoint(PixelsToPlot(pos.x + siz.x, pos.y - siz.y));
3477 }
3478 AddTextVertical(&draw_list, pos, colTxt, text);
3479 }
3480 else {
3481 ImVec2 siz = ImGui::CalcTextSize(text);
3482 ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) - siz * 0.5f + pixel_offset;
3483 if (FitThisFrame() && !ImHasFlag(spec.Flags, ImPlotItemFlags_NoFit)) {
3484 FitPoint(PixelsToPlot(pos));
3485 FitPoint(PixelsToPlot(pos+siz));
3486 }
3487 draw_list.AddText(pos, colTxt, text);
3488 }
3489 PopPlotClipRect();
3490}
3491
3492//-----------------------------------------------------------------------------
3493// [SECTION] PlotDummy

Callers 1

Demo_MarkersAndTextFunction · 0.85

Calls 14

SetupLockFunction · 0.85
GetPlotDrawListFunction · 0.85
PushPlotClipRectFunction · 0.85
GetStyleColorU32Function · 0.85
ImHasFlagFunction · 0.85
CalcTextSizeVerticalFunction · 0.85
PlotToPixelsFunction · 0.85
ImVec2Function · 0.85
FitThisFrameFunction · 0.85
FitPointFunction · 0.85
PixelsToPlotFunction · 0.85
AddTextVerticalFunction · 0.85

Tested by

no test coverage detected