Skip to content

Commit 9c4f735

Browse files
committed
fix: conflicts with implot_internal
1 parent 98631d6 commit 9c4f735

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

implot3d.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,16 @@ void AddTextCentered(ImDrawList* draw_list, ImVec2 top_center, ImU32 col, const
195195
ImVec2 GetLocationPos(const ImRect& outer_rect, const ImVec2& inner_size, ImPlot3DLocation loc, const ImVec2& pad) {
196196
ImVec2 pos;
197197
// Legend x coordinate
198-
if (ImHasFlag(loc, ImPlot3DLocation_West) && !ImHasFlag(loc, ImPlot3DLocation_East))
198+
if (ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_West) && !ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_East))
199199
pos.x = outer_rect.Min.x + pad.x;
200-
else if (!ImHasFlag(loc, ImPlot3DLocation_West) && ImHasFlag(loc, ImPlot3DLocation_East))
200+
else if (!ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_West) && ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_East))
201201
pos.x = outer_rect.Max.x - pad.x - inner_size.x;
202202
else
203203
pos.x = outer_rect.GetCenter().x - inner_size.x * 0.5f;
204204
// Legend y coordinate
205-
if (ImHasFlag(loc, ImPlot3DLocation_North) && !ImHasFlag(loc, ImPlot3DLocation_South))
205+
if (ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_North) && !ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_South))
206206
pos.y = outer_rect.Min.y + pad.y;
207-
else if (!ImHasFlag(loc, ImPlot3DLocation_North) && ImHasFlag(loc, ImPlot3DLocation_South))
207+
else if (!ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_North) && ImPlot3D::ImHasFlag(loc, ImPlot3DLocation_South))
208208
pos.y = outer_rect.Max.y - pad.y - inner_size.y;
209209
else
210210
pos.y = outer_rect.GetCenter().y - inner_size.y * 0.5f;
@@ -267,18 +267,18 @@ void ShowLegendEntries(ImPlot3DItemGroup& items, const ImRect& legend_bb, bool h
267267

268268
bool item_hov = false;
269269
bool item_hld = false;
270-
bool item_clk = ImHasFlag(items.Legend.Flags, ImPlot3DLegendFlags_NoButtons)
270+
bool item_clk = ImPlot3D::ImHasFlag(items.Legend.Flags, ImPlot3DLegendFlags_NoButtons)
271271
? false
272272
: ImGui::ButtonBehavior(button_bb, item->ID, &item_hov, &item_hld);
273273

274274
if (item_clk)
275275
item->Show = !item->Show;
276276

277-
const bool hovering = item_hov && !ImHasFlag(items.Legend.Flags, ImPlot3DLegendFlags_NoHighlightItem);
277+
const bool hovering = item_hov && !ImPlot3D::ImHasFlag(items.Legend.Flags, ImPlot3DLegendFlags_NoHighlightItem);
278278

279279
if (hovering) {
280280
item->LegendHovered = true;
281-
col_txt_hl = ImMixU32(col_txt, col_item, 64);
281+
col_txt_hl = ImPlot3D::ImMixU32(col_txt, col_item, 64);
282282
} else {
283283
item->LegendHovered = false;
284284
col_txt_hl = ImGui::GetColorU32(col_txt);
@@ -302,15 +302,15 @@ void ShowLegendEntries(ImPlot3DItemGroup& items, const ImRect& legend_bb, bool h
302302
void RenderLegend() {
303303
ImPlot3DContext& gp = *GImPlot3D;
304304
ImPlot3DPlot& plot = *gp.CurrentPlot;
305-
if (ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend) || plot.Items.GetLegendCount() == 0)
305+
if (ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend) || plot.Items.GetLegendCount() == 0)
306306
return;
307307
ImGuiContext& g = *GImGui;
308308
ImGuiWindow* window = g.CurrentWindow;
309309
ImDrawList* draw_list = window->DrawList;
310310
const ImGuiIO& IO = ImGui::GetIO();
311311

312312
ImPlot3DLegend& legend = plot.Items.Legend;
313-
const bool legend_horz = ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal);
313+
const bool legend_horz = ImPlot3D::ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal);
314314
const ImVec2 legend_size = CalcLegendSize(plot.Items, gp.Style.LegendInnerPadding, gp.Style.LegendSpacing, !legend_horz);
315315
const ImVec2 legend_pos = GetLocationPos(plot.PlotRect,
316316
legend_size,
@@ -338,7 +338,7 @@ void RenderLegend() {
338338
void RenderMousePos() {
339339
ImPlot3DContext& gp = *GImPlot3D;
340340
ImPlot3DPlot& plot = *gp.CurrentPlot;
341-
if (ImHasFlag(plot.Flags, ImPlot3DFlags_NoMouseText))
341+
if (ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_NoMouseText))
342342
return;
343343

344344
ImVec2 mouse_pos = ImGui::GetMousePos();
@@ -587,7 +587,7 @@ void RenderGrid(ImDrawList* draw_list, const ImPlot3DPlot& plot, const ImPlot3DP
587587
ImPlot3DPoint v_vec = p3 - p0;
588588

589589
// Render grid lines along u axis (axis_u)
590-
if (!ImHasFlag(axis_u.Flags, ImPlot3DAxisFlags_NoGridLines))
590+
if (!ImPlot3D::ImHasFlag(axis_u.Flags, ImPlot3DAxisFlags_NoGridLines))
591591
for (int t = 0; t < axis_u.Ticker.TickCount(); ++t) {
592592
const ImPlot3DTick& tick = axis_u.Ticker.Ticks[t];
593593

@@ -608,7 +608,7 @@ void RenderGrid(ImDrawList* draw_list, const ImPlot3DPlot& plot, const ImPlot3DP
608608
}
609609

610610
// Render grid lines along v axis (axis_v)
611-
if (!ImHasFlag(axis_v.Flags, ImPlot3DAxisFlags_NoGridLines))
611+
if (!ImPlot3D::ImHasFlag(axis_v.Flags, ImPlot3DAxisFlags_NoGridLines))
612612
for (int t = 0; t < axis_v.Ticker.TickCount(); ++t) {
613613
const ImPlot3DTick& tick = axis_v.Ticker.Ticks[t];
614614

@@ -647,7 +647,7 @@ void RenderTickMarks(ImDrawList* draw_list, const ImPlot3DPlot& plot, const ImPl
647647

648648
for (int a = 0; a < 3; a++) {
649649
const ImPlot3DAxis& axis = plot.Axes[a];
650-
if (ImHasFlag(axis.Flags, ImPlot3DAxisFlags_NoTickMarks))
650+
if (ImPlot3D::ImHasFlag(axis.Flags, ImPlot3DAxisFlags_NoTickMarks))
651651
continue;
652652

653653
int idx0 = axis_corners[a][0];
@@ -739,7 +739,7 @@ void RenderTickLabels(ImDrawList* draw_list, const ImPlot3DPlot& plot, const ImP
739739

740740
for (int a = 0; a < 3; a++) {
741741
const ImPlot3DAxis& axis = plot.Axes[a];
742-
if (ImHasFlag(axis.Flags, ImPlot3DAxisFlags_NoTickLabels))
742+
if (ImPlot3D::ImHasFlag(axis.Flags, ImPlot3DAxisFlags_NoTickLabels))
743743
continue;
744744

745745
// Corner indices for this axis
@@ -1119,10 +1119,10 @@ bool ShowLegendContextMenu(ImPlot3DLegend& legend, bool visible) {
11191119
bool ret = false;
11201120
if (ImGui::Checkbox("Show", &visible))
11211121
ret = true;
1122-
if (ImGui::RadioButton("H", ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal)))
1122+
if (ImGui::RadioButton("H", ImPlot3D::ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal)))
11231123
legend.Flags |= ImPlot3DLegendFlags_Horizontal;
11241124
ImGui::SameLine();
1125-
if (ImGui::RadioButton("V", !ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal)))
1125+
if (ImGui::RadioButton("V", !ImPlot3D::ImHasFlag(legend.Flags, ImPlot3DLegendFlags_Horizontal)))
11261126
legend.Flags &= ~ImPlot3DLegendFlags_Horizontal;
11271127
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 2));
11281128
// clang-format off
@@ -1211,7 +1211,7 @@ void ShowPlotContextMenu(ImPlot3DPlot& plot) {
12111211

12121212
ImGui::Separator();
12131213
if ((ImGui::BeginMenu("Legend"))) {
1214-
if (ShowLegendContextMenu(plot.Items.Legend, !ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend)))
1214+
if (ShowLegendContextMenu(plot.Items.Legend, !ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend)))
12151215
ImFlipFlag(plot.Flags, ImPlot3DFlags_NoLegend);
12161216
ImGui::EndMenu();
12171217
}
@@ -1332,7 +1332,7 @@ void EndPlot() {
13321332
if (ImGui::BeginPopup("##LegendContext")) {
13331333
ImGui::Text("Legend");
13341334
ImGui::Separator();
1335-
if (ShowLegendContextMenu(plot.Items.Legend, !ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend)))
1335+
if (ShowLegendContextMenu(plot.Items.Legend, !ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend)))
13361336
ImFlipFlag(plot.Flags, ImPlot3DFlags_NoLegend);
13371337
ImGui::EndPopup();
13381338
}
@@ -2531,7 +2531,7 @@ ImPlot3DPoint operator*(float lhs, const ImPlot3DPoint& rhs) {
25312531
}
25322532

25332533
bool ImPlot3DPoint::IsNaN() const {
2534-
return ImNan(x) || ImNan(y) || ImNan(z);
2534+
return ImPlot3D::ImNan(x) || ImPlot3D::ImNan(y) || ImPlot3D::ImNan(z);
25352535
}
25362536

25372537
//-----------------------------------------------------------------------------
@@ -2906,23 +2906,23 @@ void ImDrawList3D::SortedMoveToImGuiDrawList() {
29062906
// [SECTION] ImPlot3DAxis
29072907
//-----------------------------------------------------------------------------
29082908

2909-
bool ImPlot3DAxis::HasLabel() const { return !Label.empty() && !ImHasFlag(Flags, ImPlot3DAxisFlags_NoLabel); }
2910-
bool ImPlot3DAxis::HasGridLines() const { return !ImHasFlag(Flags, ImPlot3DAxisFlags_NoGridLines); }
2911-
bool ImPlot3DAxis::HasTickLabels() const { return !ImHasFlag(Flags, ImPlot3DAxisFlags_NoTickLabels); }
2912-
bool ImPlot3DAxis::HasTickMarks() const { return !ImHasFlag(Flags, ImPlot3DAxisFlags_NoTickMarks); }
2913-
bool ImPlot3DAxis::IsAutoFitting() const { return ImHasFlag(Flags, ImPlot3DAxisFlags_AutoFit); }
2909+
bool ImPlot3DAxis::HasLabel() const { return !Label.empty() && !ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_NoLabel); }
2910+
bool ImPlot3DAxis::HasGridLines() const { return !ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_NoGridLines); }
2911+
bool ImPlot3DAxis::HasTickLabels() const { return !ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_NoTickLabels); }
2912+
bool ImPlot3DAxis::HasTickMarks() const { return !ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_NoTickMarks); }
2913+
bool ImPlot3DAxis::IsAutoFitting() const { return ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_AutoFit); }
29142914

29152915
void ImPlot3DAxis::ExtendFit(float value) {
29162916
FitExtents.Min = ImMin(FitExtents.Min, value);
29172917
FitExtents.Max = ImMax(FitExtents.Max, value);
29182918
}
29192919

29202920
void ImPlot3DAxis::ApplyFit() {
2921-
if (!IsLockedMin() && !ImNanOrInf(FitExtents.Min))
2921+
if (!IsLockedMin() && !ImPlot3D::ImNanOrInf(FitExtents.Min))
29222922
Range.Min = FitExtents.Min;
2923-
if (!IsLockedMax() && !ImNanOrInf(FitExtents.Max))
2923+
if (!IsLockedMax() && !ImPlot3D::ImNanOrInf(FitExtents.Max))
29242924
Range.Max = FitExtents.Max;
2925-
if (ImAlmostEqual(Range.Min, Range.Max)) {
2925+
if (ImPlot3D::ImAlmostEqual(Range.Min, Range.Max)) {
29262926
Range.Max += 0.5;
29272927
Range.Min -= 0.5;
29282928
}
@@ -2944,7 +2944,7 @@ float ImPlot3DAxis::NDCToPlot(float value) const {
29442944

29452945
void ImPlot3DPlot::ExtendFit(const ImPlot3DPoint& point) {
29462946
for (int i = 0; i < 3; i++) {
2947-
if (!ImNanOrInf(point[i]) && Axes[i].FitThisFrame)
2947+
if (!ImPlot3D::ImNanOrInf(point[i]) && Axes[i].FitThisFrame)
29482948
Axes[i].ExtendFit(point[i]);
29492949
}
29502950
}

implot3d_internal.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
// [SECTION] Generic Helpers
4949
//-----------------------------------------------------------------------------
5050

51-
#ifndef IMPLOT_VERSION
52-
// Define generic helpers if ImPlot didn't define them already
51+
namespace ImPlot3D {
5352

5453
// Computes the common (base-10) logarithm
5554
static inline float ImLog10(float x) { return log10f(x); }
@@ -62,23 +61,23 @@ static inline void ImFlipFlag(TSet& set, TFlag flag) { ImHasFlag(set, flag) ? se
6261
template <typename T>
6362
static inline T ImRemap01(T x, T x0, T x1) { return (x - x0) / (x1 - x0); }
6463
// Returns true if val is NAN
65-
static inline bool ImNan(double val) { return isnan(val); }
64+
static inline bool ImNan(float val) { return isnan(val); }
6665
// Returns true if val is NAN or INFINITY
67-
static inline bool ImNanOrInf(double val) { return !(val >= -DBL_MAX && val <= DBL_MAX) || ImNan(val); }
66+
static inline bool ImNanOrInf(float val) { return !(val >= -FLT_MAX && val <= FLT_MAX) || ImNan(val); }
6867
// Turns NANs to 0s
69-
static inline double ImConstrainNan(double val) { return ImNan(val) ? 0 : val; }
68+
static inline double ImConstrainNan(float val) { return ImNan(val) ? 0 : val; }
7069
// Turns infinity to floating point maximums
71-
static inline double ImConstrainInf(double val) { return val >= DBL_MAX ? DBL_MAX : val <= -DBL_MAX ? -DBL_MAX
70+
static inline double ImConstrainInf(double val) { return val >= FLT_MAX ? FLT_MAX : val <= -FLT_MAX ? -FLT_MAX
7271
: val; }
7372
// True if two numbers are approximately equal using units in the last place.
74-
static inline bool ImAlmostEqual(double v1, double v2, int ulp = 2) { return ImAbs(v1 - v2) < DBL_EPSILON * ImAbs(v1 + v2) * ulp || ImAbs(v1 - v2) < DBL_MIN; }
73+
static inline bool ImAlmostEqual(double v1, double v2, int ulp = 2) { return ImAbs(v1 - v2) < FLT_EPSILON * ImAbs(v1 + v2) * ulp || ImAbs(v1 - v2) < FLT_MIN; }
7574
// Set alpha channel of 32-bit color from float in range [0.0 1.0]
7675
static inline ImU32 ImAlphaU32(ImU32 col, float alpha) {
7776
return col & ~((ImU32)((1.0f - alpha) * 255) << IM_COL32_A_SHIFT);
7877
}
7978
// Mix color a and b by factor s in [0 256]
8079
static inline ImU32 ImMixU32(ImU32 a, ImU32 b, ImU32 s) {
81-
#ifdef IMPLOT_MIX64
80+
#ifdef IMPLOT3D_MIX64
8281
const ImU32 af = 256 - s;
8382
const ImU32 bf = s;
8483
const ImU64 al = (a & 0x00ff00ff) | (((ImU64)(a & 0xff00ff00)) << 24);
@@ -97,7 +96,8 @@ static inline ImU32 ImMixU32(ImU32 a, ImU32 b, ImU32 s) {
9796
return (mh & 0xff00ff00) | ((ml & 0xff00ff00) >> 8);
9897
#endif
9998
}
100-
#endif
99+
100+
} // namespace ImPlot3D
101101

102102
//-----------------------------------------------------------------------------
103103
// [SECTION] Forward Declarations
@@ -227,7 +227,7 @@ struct ImPlot3DColormapData {
227227
for (int s = 0; s < 255; ++s) {
228228
ImU32 a = keys[i];
229229
ImU32 b = keys[i + 1];
230-
ImU32 c = ImMixU32(a, b, s);
230+
ImU32 c = ImPlot3D::ImMixU32(a, b, s);
231231
// if (c != last) {
232232
Tables.push_back(c);
233233
// last = c;
@@ -465,7 +465,7 @@ struct ImPlot3DAxis {
465465
inline bool SetMin(double _min, bool force = false) {
466466
if (!force && IsLockedMin())
467467
return false;
468-
_min = ImConstrainNan(ImConstrainInf(_min));
468+
_min = ImPlot3D::ImConstrainNan(ImPlot3D::ImConstrainInf(_min));
469469
if (_min >= Range.Max)
470470
return false;
471471
Range.Min = _min;
@@ -475,16 +475,16 @@ struct ImPlot3DAxis {
475475
inline bool SetMax(double _max, bool force = false) {
476476
if (!force && IsLockedMax())
477477
return false;
478-
_max = ImConstrainNan(ImConstrainInf(_max));
478+
_max = ImPlot3D::ImConstrainNan(ImPlot3D::ImConstrainInf(_max));
479479
if (_max <= Range.Min)
480480
return false;
481481
Range.Max = _max;
482482
return true;
483483
}
484484

485485
inline bool IsRangeLocked() const { return RangeCond == ImPlot3DCond_Always; }
486-
inline bool IsLockedMin() const { return IsRangeLocked() || ImHasFlag(Flags, ImPlot3DAxisFlags_LockMin); }
487-
inline bool IsLockedMax() const { return IsRangeLocked() || ImHasFlag(Flags, ImPlot3DAxisFlags_LockMax); }
486+
inline bool IsLockedMin() const { return IsRangeLocked() || ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_LockMin); }
487+
inline bool IsLockedMax() const { return IsRangeLocked() || ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_LockMax); }
488488
inline bool IsLocked() const { return IsLockedMin() && IsLockedMax(); }
489489

490490
inline void SetLabel(const char* label) {
@@ -562,7 +562,7 @@ struct ImPlot3DPlot {
562562
if (title && ImGui::FindRenderedTextEnd(title, nullptr) != title)
563563
Title.append(title, title + strlen(title) + 1);
564564
}
565-
inline bool HasTitle() const { return !Title.empty() && !ImHasFlag(Flags, ImPlot3DFlags_NoTitle); }
565+
inline bool HasTitle() const { return !Title.empty() && !ImPlot3D::ImHasFlag(Flags, ImPlot3DFlags_NoTitle); }
566566
inline const char* GetTitle() const { return Title.Buf.Data; }
567567

568568
void ExtendFit(const ImPlot3DPoint& point);

implot3d_items.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
} while (0)
7979

8080
IMPLOT3D_INLINE void GetLineRenderProps(const ImDrawList3D& draw_list_3d, float& half_weight, ImVec2& tex_uv0, ImVec2& tex_uv1) {
81-
const bool aa = ImHasFlag(draw_list_3d._Flags, ImDrawListFlags_AntiAliasedLines) &&
82-
ImHasFlag(draw_list_3d._Flags, ImDrawListFlags_AntiAliasedLinesUseTex);
81+
const bool aa = ImPlot3D::ImHasFlag(draw_list_3d._Flags, ImDrawListFlags_AntiAliasedLines) &&
82+
ImPlot3D::ImHasFlag(draw_list_3d._Flags, ImDrawListFlags_AntiAliasedLinesUseTex);
8383
if (aa) {
8484
ImVec4 tex_uvs = draw_list_3d._SharedData->TexUvLines[(int)(half_weight * 2)];
8585
tex_uv0 = ImVec2(tex_uvs.x, tex_uvs.y);

0 commit comments

Comments
 (0)