Skip to content

Commit

Permalink
Apply PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Poooel committed Dec 26, 2024
1 parent 17a69f8 commit 29fb9d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions implot3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,12 @@ void ShowAxisContextMenu(ImPlot3DAxis& axis) {
ImGui::CheckboxFlags("Auto-Fit", (unsigned int*)&axis.Flags, ImPlot3DAxisFlags_AutoFit);
ImGui::Separator();

bool inverted = ImPlot3D::ImHasFlag(axis.Flags, ImPlot3DAxisFlags_Invert);
if (ImGui::Checkbox("Invert", &inverted))
ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_Invert);

ImGui::Separator();

ImGui::BeginDisabled(axis.Label.empty());
if (ImGui::Checkbox("Label", &label))
ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_NoLabel);
Expand All @@ -1190,12 +1196,6 @@ void ShowAxisContextMenu(ImPlot3DAxis& axis) {
ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_NoTickMarks);
if (ImGui::Checkbox("Tick Labels", &labels))
ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_NoTickLabels);

ImGui::Separator();

bool inverted = ImPlot3D::ImHasFlag(axis.Flags, ImPlot3DAxisFlags_Invert);
if (ImGui::Checkbox("Invert Axis", &inverted))
ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_Invert);
}

void ShowPlotContextMenu(ImPlot3DPlot& plot) {
Expand Down Expand Up @@ -1413,6 +1413,16 @@ void SetupAxisLimits(ImAxis3D idx, double min_lim, double max_lim, ImPlot3DCond
}
}

void SetupAxisFormat(ImAxis3D idx, ImPlot3DFormatter formatter, void* data) {
ImPlot3DContext& gp = *GImPlot3D;
IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr && !gp.CurrentPlot->SetupLocked,
"Setup needs to be called after BeginPlot and before any setup locking functions (e.g. PlotX)!");
ImPlot3DPlot& plot = *gp.CurrentPlot;
ImPlot3DAxis& axis = plot.Axes[idx];
axis.Formatter = formatter;
axis.FormatterData = data;
}

void SetupAxes(const char* x_label, const char* y_label, const char* z_label, ImPlot3DAxisFlags x_flags, ImPlot3DAxisFlags y_flags, ImPlot3DAxisFlags z_flags) {
SetupAxis(ImAxis3D_X, x_label, x_flags);
SetupAxis(ImAxis3D_Y, y_label, y_flags);
Expand All @@ -1427,16 +1437,6 @@ void SetupAxesLimits(double x_min, double x_max, double y_min, double y_max, dou
GImPlot3D->CurrentPlot->FitThisFrame = false;
}

void SetupAxisFormat(ImAxis3D idx, ImPlot3DFormatter formatter, void* data) {
ImPlot3DContext& gp = *GImPlot3D;
IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr && !gp.CurrentPlot->SetupLocked,
"Setup needs to be called after BeginPlot and before any setup locking functions (e.g. PlotX)!");
ImPlot3DPlot& plot = *gp.CurrentPlot;
ImPlot3DAxis& axis = plot.Axes[idx];
axis.Formatter = formatter;
axis.FormatterData = data;
}

void SetupLegend(ImPlot3DLocation location, ImPlot3DLegendFlags flags) {
ImPlot3DContext& gp = *GImPlot3D;
IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr && !gp.CurrentPlot->SetupLocked,
Expand Down
4 changes: 2 additions & 2 deletions implot3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,14 @@ IMPLOT3D_API void SetupAxis(ImAxis3D axis, const char* label = nullptr, ImPlot3D

IMPLOT3D_API void SetupAxisLimits(ImAxis3D axis, double v_min, double v_max, ImPlot3DCond cond = ImPlot3DCond_Once);

IMPLOT3D_API void SetupAxisFormat(ImAxis3D idx, ImPlot3DFormatter formatter, void* data = nullptr);

// Sets the label and/or flags for primary X/Y/Z axes (shorthand for three calls to SetupAxis)
IMPLOT3D_API void SetupAxes(const char* x_label, const char* y_label, const char* z_label, ImPlot3DAxisFlags x_flags = 0, ImPlot3DAxisFlags y_flags = 0, ImPlot3DAxisFlags z_flags = 0);

// Sets the X/Y/Z axes range limits. If ImPlotCond_Always is used, the axes limits will be locked (shorthand for two calls to SetupAxisLimits)
IMPLOT3D_API void SetupAxesLimits(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max, ImPlot3DCond cond = ImPlot3DCond_Once);

IMPLOT3D_API void SetupAxisFormat(ImAxis3D idx, ImPlot3DFormatter formatter, void* data = nullptr);

IMPLOT3D_API void SetupLegend(ImPlot3DLocation location, ImPlot3DLegendFlags flags = 0);

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 29fb9d9

Please sign in to comment.