MCPcopy Create free account
hub / github.com/brenocq/implot3d / EndPlot

Function EndPlot

implot3d.cpp:1759–1870  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1757}
1758
1759void EndPlot() {
1760 IMPLOT3D_CHECK_CTX();
1761 ImPlot3DContext& gp = *GImPlot3D;
1762 IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr, "Mismatched BeginPlot()/EndPlot()!");
1763 ImPlot3DPlot& plot = *gp.CurrentPlot;
1764
1765 // Move triangles from 3D draw list to ImGui draw list
1766 plot.DrawList.SortedMoveToImGuiDrawList();
1767
1768 // Handle data fitting
1769 if (plot.FitThisFrame) {
1770 plot.FitThisFrame = false;
1771
1772 const bool axis_equal = ImHasFlag(plot.Flags, ImPlot3DFlags_Equal);
1773 if (!axis_equal) {
1774 // Apply fit to all axes independently
1775 for (int i = 0; i < 3; i++) {
1776 if (plot.Axes[i].FitThisFrame) {
1777 plot.Axes[i].FitThisFrame = false;
1778 plot.Axes[i].ApplyFit();
1779 }
1780 }
1781 } else {
1782 // Find the fitted axis with the highest aspect ratio (units per NDC unit) after fit
1783 // This axis will require the most space and should be used as reference
1784 ImAxis3D ref_axis = ImAxis3D_X;
1785 double max_aspect = 0.0;
1786
1787 // First, apply fit to all axes
1788 for (int i = 0; i < 3; i++) {
1789 if (plot.Axes[i].FitThisFrame) {
1790 plot.Axes[i].FitThisFrame = false;
1791 plot.Axes[i].ApplyFit();
1792
1793 // Get aspect ratio for this axis
1794 double aspect = plot.Axes[i].GetAspect();
1795 if (aspect > max_aspect) {
1796 max_aspect = aspect;
1797 ref_axis = (ImAxis3D)i;
1798 }
1799 }
1800 }
1801
1802 // Then, apply equal aspect constraint if enabled
1803 // This ensures data remains centered and visible
1804 plot.ApplyEqualAspect(ref_axis);
1805 }
1806 }
1807
1808 // Lock setup if not already done
1809 SetupLock();
1810
1811 // Pop plot rect clipping
1812 ImGui::PopClipRect();
1813
1814 // Reset legend hover
1815 plot.Items.Legend.Hovered = false;
1816

Callers 15

DemoLinePlotsFunction · 0.85
DemoScatterPlotsFunction · 0.85
DemoTrianglePlotsFunction · 0.85
DemoQuadPlotsFunction · 0.85
DemoSurfacePlotsFunction · 0.85
DemoMeshPlotsFunction · 0.85
DemoImagePlotsFunction · 0.85
DemoRealtimePlotsFunction · 0.85
DemoPlotFlagsFunction · 0.85
DemoOffsetAndStrideFunction · 0.85
DemoLegendOptionsFunction · 0.85
DemoMarkersAndTextFunction · 0.85

Calls 15

ImHasFlagFunction · 0.85
SetupLockFunction · 0.85
RenderLegendFunction · 0.85
RenderMousePosFunction · 0.85
ShowLegendContextMenuFunction · 0.85
ImFlipFlagFunction · 0.85
ShowAxisContextMenuFunction · 0.85
ShowPlaneContextMenuFunction · 0.85
ShowPlotContextMenuFunction · 0.85
ApplyFitMethod · 0.80
GetAspectMethod · 0.80

Tested by

no test coverage detected