| 3441 | |
| 3442 | #ifdef IMGUI_HAS_TEXTURES |
| 3443 | void PlotImage(const char* label_id, ImTextureRef tex_ref, const ImPlotPoint& bmin, const ImPlotPoint& bmax, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImPlotSpec& spec) { |
| 3444 | #else |
| 3445 | void PlotImage(const char* label_id, ImTextureID tex_ref, const ImPlotPoint& bmin, const ImPlotPoint& bmax, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImPlotSpec& spec) { |
| 3446 | #endif |
| 3447 | if (BeginItemEx(label_id, FitterRect(bmin,bmax), spec)) { |
| 3448 | ImU32 tint_col32 = ImGui::ColorConvertFloat4ToU32(tint_col); |
| 3449 | GetCurrentItem()->Color = tint_col32; |
| 3450 | ImDrawList& draw_list = *GetPlotDrawList(); |
| 3451 | ImVec2 p1 = PlotToPixels(bmin.x, bmax.y,IMPLOT_AUTO,IMPLOT_AUTO); |
| 3452 | ImVec2 p2 = PlotToPixels(bmax.x, bmin.y,IMPLOT_AUTO,IMPLOT_AUTO); |
| 3453 | PushPlotClipRect(); |
| 3454 | draw_list.AddImage(tex_ref, p1, p2, uv0, uv1, tint_col32); |
| 3455 | PopPlotClipRect(); |
| 3456 | EndItem(); |
| 3457 | } |
| 3458 | } |
| 3459 | |
| 3460 | //----------------------------------------------------------------------------- |
| 3461 | // [SECTION] PlotText |
| 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 |
| 3494 | //----------------------------------------------------------------------------- |
| 3495 | |
| 3496 | void PlotDummy(const char* label_id, const ImPlotSpec& spec) { |
| 3497 | if (BeginItem(label_id, spec)) |
| 3498 | EndItem(); |
| 3499 | } |
| 3500 |
no test coverage detected