| 3462 | //----------------------------------------------------------------------------- |
| 3463 | |
| 3464 | void 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 |
no test coverage detected