| 453 | //----------------------------------------------------------------------------- |
| 454 | |
| 455 | void RenderMousePos() { |
| 456 | ImPlot3DContext& gp = *GImPlot3D; |
| 457 | ImPlot3DPlot& plot = *gp.CurrentPlot; |
| 458 | if (ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_NoMouseText)) |
| 459 | return; |
| 460 | |
| 461 | ImVec2 mouse_pos = ImGui::GetMousePos(); |
| 462 | ImPlot3DPoint mouse_plot_pos = PixelsToPlotPlane(mouse_pos, ImPlane3D_YZ, true); |
| 463 | if (mouse_plot_pos.IsNaN()) |
| 464 | mouse_plot_pos = PixelsToPlotPlane(mouse_pos, ImPlane3D_XZ, true); |
| 465 | if (mouse_plot_pos.IsNaN()) |
| 466 | mouse_plot_pos = PixelsToPlotPlane(mouse_pos, ImPlane3D_XY, true); |
| 467 | |
| 468 | char buff[IMPLOT3D_LABEL_MAX_SIZE]; |
| 469 | if (!mouse_plot_pos.IsNaN()) { |
| 470 | ImGuiTextBuffer builder; |
| 471 | builder.append("("); |
| 472 | for (int i = 0; i < 3; i++) { |
| 473 | ImPlot3DAxis& axis = plot.Axes[i]; |
| 474 | if (i > 0) |
| 475 | builder.append(", "); |
| 476 | axis.Formatter(mouse_plot_pos[i], buff, IMPLOT3D_LABEL_MAX_SIZE, axis.FormatterData); |
| 477 | builder.append(buff); |
| 478 | } |
| 479 | builder.append(")"); |
| 480 | |
| 481 | const ImVec2 size = ImGui::CalcTextSize(builder.c_str()); |
| 482 | // TODO custom location/padding |
| 483 | const ImVec2 pos = GetLocationPos(plot.PlotRect, size, ImPlot3DLocation_SouthEast, ImVec2(10, 10)); |
| 484 | ImDrawList& draw_list = *ImGui::GetWindowDrawList(); |
| 485 | draw_list.AddText(pos, GetStyleColorU32(ImPlot3DCol_InlayText), builder.c_str()); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | //----------------------------------------------------------------------------- |
| 490 | // [SECTION] Plot Box Utils |
no test coverage detected