Skip to content

Commit 8a0bbaa

Browse files
andrestrakerSSingh5845
authored andcommitted
Updating to v0.17
1 parent 2cb0692 commit 8a0bbaa

File tree

7 files changed

+789
-371
lines changed

7 files changed

+789
-371
lines changed

dependencies/third-party/imgui/implot/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ A: Maybe. Check the demo, gallery, or Announcements ([2020](https://github.com/e
155155

156156
**Q: Does ImPlot support 3D plots?**
157157

158-
A: No, and likely never will since ImGui only deals in 2D rendering.
158+
A: An experimental extension to ImPlot, [ImPlot3D](https://github.com/brenocq/implot3d), provides a similar API for plotting and interacting with 3D data.
159159

160160
**Q: Does ImPlot provide analytic tools?**
161161

@@ -165,6 +165,10 @@ A: Not exactly, but it does give you the ability to query plot sub-ranges, with
165165

166166
A: Not currently. Use your OS's screen capturing mechanisms if you need to capture a plot. ImPlot is not suitable for rendering publication quality plots; it is only intended to be used as a visualization tool. Post-process your data with MATLAB or matplotlib for these purposes.
167167

168+
**Q: Why are my plot lines showing aliasing?**
169+
170+
A: You probably need to enable `ImGuiStyle::AntiAliasedLinesUseTex` (or possibly `ImGuiStyle:AntiAliasedLines`). If those settings are already enabled, then you must ensure your backend supports texture based anti-aliasing (i.e. uses bilinear sampling). Most of the default ImGui backends support this feature out of the box. Learn more [here](https://github.com/ocornut/imgui/issues/3245). Alternatively, you can enable MSAA at the application level if your hardware supports it (4x should do).
171+
168172
**Q: Can I compile ImPlot as a dynamic library?**
169173

170174
A: Like ImGui, it is recommended that you compile and link ImPlot as a *static* library or directly as a part of your sources. However, if you must and are compiling ImPlot and ImGui as separate DLLs, make sure you set the current *ImGui* context with `ImPlot::SetImGuiContext(ImGuiContext* ctx)`. This ensures that global ImGui variables are correctly shared across the DLL boundary.

dependencies/third-party/imgui/implot/TODO.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ The list below represents a combination of high-priority work, nice-to-have feat
1515

1616
- add `PlotBubbles` (see MATLAB bubble chart)
1717
- add non-zero references for `PlotBars` etc.
18-
- add exploding to `PlotPieChart` (on hover-highlight?)
1918
- fix appearance of `PlotBars` spacing
2019

2120
## Styling
@@ -31,9 +30,9 @@ The list below represents a combination of high-priority work, nice-to-have feat
3130

3231
## Legend
3332

34-
- `ImPlotLegendFlags_Scroll`
3533
- improve legend icons (e.g. adopt markers, gradients, etc)
36-
- make legend frame use ButtonBehavior (maybe impossible)
34+
- generalize legend rendering for plots and subplots
35+
- add draggable scroll bar if users need it
3736

3837
## Tools / Misc.
3938

@@ -80,6 +79,7 @@ Ideally every `PlotX` function should use our faster rendering pipeline when it
8079
|PlotDummy|-|-|-|-|
8180

8281
## Completed
82+
- add exploding to `PlotPieChart` (on legend hover)
8383
- make BeginPlot take fewer args:
8484
- make query a tool -> `DragRect`
8585
- rework DragLine/Point to use ButtonBehavior
@@ -98,3 +98,5 @@ Ideally every `PlotX` function should use our faster rendering pipeline when it
9898
- add `PlotBarGroups` wrapper that makes rendering groups of bars easier, with stacked bar support
9999
- `PlotBars` restore outlines
100100
- add hover/active color for plot axes
101+
- make legend frame use ButtonBehavior
102+
- `ImPlotLegendFlags_Scroll` (default behavior)

dependencies/third-party/imgui/implot/implot.cpp

Lines changed: 310 additions & 169 deletions
Large diffs are not rendered by default.

dependencies/third-party/imgui/implot/implot.h

Lines changed: 69 additions & 53 deletions
Large diffs are not rendered by default.

dependencies/third-party/imgui/implot/implot_demo.cpp

Lines changed: 110 additions & 58 deletions
Large diffs are not rendered by default.

dependencies/third-party/imgui/implot/implot_internal.h

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// MIT License
22

3-
// Copyright (c) 2023 Evan Pezent
3+
// Copyright (c) 2020-2024 Evan Pezent
4+
// Copyright (c) 2025 Breno Cunha Queiroz
45

56
// Permission is hereby granted, free of charge, to any person obtaining a copy
67
// of this software and associated documentation files (the "Software"), to deal
@@ -20,7 +21,7 @@
2021
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2122
// SOFTWARE.
2223

23-
// ImPlot v0.16
24+
// ImPlot v0.17
2425

2526
// You may use this file to debug, understand or extend ImPlot features but we
2627
// don't provide any guarantee of forward compatibility!
@@ -31,13 +32,13 @@
3132

3233
#pragma once
3334

34-
#include <time.h>
35-
#include "imgui_internal.h"
36-
3735
#ifndef IMPLOT_VERSION
3836
#error Must include implot.h before implot_internal.h
3937
#endif
4038

39+
#ifndef IMGUI_DISABLE
40+
#include <time.h>
41+
#include "imgui_internal.h"
4142

4243
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
4344
#if (IMGUI_VERSION_NUM < 18303)
@@ -51,7 +52,7 @@
5152
// Constants can be changed unless stated otherwise. We may move some of these
5253
// to ImPlotStyleVar_ over time.
5354

54-
// Mimimum allowable timestamp value 01/01/1970 @ 12:00am (UTC) (DO NOT DECREASE THIS)
55+
// Minimum allowable timestamp value 01/01/1970 @ 12:00am (UTC) (DO NOT DECREASE THIS)
5556
#define IMPLOT_MIN_TIME 0
5657
// Maximum allowable timestamp value 01/01/3000 @ 12:00am (UTC) (DO NOT INCREASE THIS)
5758
#define IMPLOT_MAX_TIME 32503680000
@@ -198,7 +199,7 @@ static inline ImU32 ImMixU32(ImU32 a, ImU32 b, ImU32 s) {
198199
#endif
199200
}
200201

201-
// Lerp across an array of 32-bit collors given t in [0.0 1.0]
202+
// Lerp across an array of 32-bit colors given t in [0.0 1.0]
202203
static inline ImU32 ImLerpU32(const ImU32* colors, int size, float t) {
203204
int i1 = (int)((size - 1 ) * t);
204205
int i2 = i1 + 1;
@@ -420,6 +421,7 @@ struct ImPlotColormapData {
420421
// ImPlotPoint with positive/negative error values
421422
struct ImPlotPointError {
422423
double X, Y, Neg, Pos;
424+
ImPlotPointError() { X = 0; Y = 0; Neg = 0; Pos = 0; }
423425
ImPlotPointError(double x, double y, double neg, double pos) {
424426
X = x; Y = y; Neg = neg; Pos = pos;
425427
}
@@ -486,6 +488,14 @@ struct ImPlotTag {
486488
ImU32 ColorBg;
487489
ImU32 ColorFg;
488490
int TextOffset;
491+
492+
ImPlotTag() {
493+
Axis = 0;
494+
Value = 0;
495+
ColorBg = 0;
496+
ColorFg = 0;
497+
TextOffset = 0;
498+
}
489499
};
490500

491501
struct ImPlotTagCollection {
@@ -540,6 +550,17 @@ struct ImPlotTick
540550
int Level;
541551
int Idx;
542552

553+
ImPlotTick() {
554+
PlotPos = 0;
555+
PixelPos = 0;
556+
LabelSize = ImVec2(0,0);
557+
TextOffset = -1;
558+
Major = false;
559+
ShowLabel = false;
560+
Level = 0;
561+
Idx = -1;
562+
}
563+
543564
ImPlotTick(double value, bool major, int level, bool show_label) {
544565
PixelPos = 0;
545566
PlotPos = value;
@@ -966,9 +987,11 @@ struct ImPlotLegend
966987
ImPlotLegendFlags PreviousFlags;
967988
ImPlotLocation Location;
968989
ImPlotLocation PreviousLocation;
990+
ImVec2 Scroll;
969991
ImVector<int> Indices;
970992
ImGuiTextBuffer Labels;
971993
ImRect Rect;
994+
ImRect RectClamped;
972995
bool Hovered;
973996
bool Held;
974997
bool CanGoInside;
@@ -978,6 +1001,7 @@ struct ImPlotLegend
9781001
CanGoInside = true;
9791002
Hovered = Held = false;
9801003
Location = PreviousLocation = ImPlotLocation_NorthWest;
1004+
Scroll = ImVec2(0,0);
9811005
}
9821006

9831007
void Reset() { Indices.shrink(0); Labels.Buf.shrink(0); }
@@ -1215,9 +1239,6 @@ struct ImPlotContext {
12151239
ImPlotAnnotationCollection Annotations;
12161240
ImPlotTagCollection Tags;
12171241

1218-
// Flags
1219-
bool ChildWindowMade;
1220-
12211242
// Style and Colormaps
12221243
ImPlotStyle Style;
12231244
ImVector<ImGuiColorMod> ColorModifiers;
@@ -1414,13 +1435,15 @@ IMPLOT_API void ShowAxisContextMenu(ImPlotAxis& axis, ImPlotAxis* equal_axis, bo
14141435

14151436
// Gets the position of an inner rect that is located inside of an outer rect according to an ImPlotLocation and padding amount.
14161437
IMPLOT_API ImVec2 GetLocationPos(const ImRect& outer_rect, const ImVec2& inner_size, ImPlotLocation location, const ImVec2& pad = ImVec2(0,0));
1417-
// Calculates the bounding box size of a legend
1438+
// Calculates the bounding box size of a legend _before_ clipping.
14181439
IMPLOT_API ImVec2 CalcLegendSize(ImPlotItemGroup& items, const ImVec2& pad, const ImVec2& spacing, bool vertical);
1440+
// Clips calculated legend size
1441+
IMPLOT_API bool ClampLegendRect(ImRect& legend_rect, const ImRect& outer_rect, const ImVec2& pad);
14191442
// Renders legend entries into a bounding box
14201443
IMPLOT_API bool ShowLegendEntries(ImPlotItemGroup& items, const ImRect& legend_bb, bool interactable, const ImVec2& pad, const ImVec2& spacing, bool vertical, ImDrawList& DrawList);
1421-
// Shows an alternate legend for the plot identified by #title_id, outside of the plot frame (can be called before or after of Begin/EndPlot but must occur in the same ImGui window!).
1444+
// Shows an alternate legend for the plot identified by #title_id, outside of the plot frame (can be called before or after of Begin/EndPlot but must occur in the same ImGui window! This is not thoroughly tested nor scrollable!).
14221445
IMPLOT_API void ShowAltLegend(const char* title_id, bool vertical = true, const ImVec2 size = ImVec2(0,0), bool interactable = true);
1423-
// Shows an legends's context menu.
1446+
// Shows a legend's context menu.
14241447
IMPLOT_API bool ShowLegendContextMenu(ImPlotLegend& legend, bool visible);
14251448

14261449
//-----------------------------------------------------------------------------
@@ -1562,11 +1585,24 @@ IMPLOT_API tm* GetLocTime(const ImPlotTime& t, tm* ptm);
15621585
// NB: The following functions only work if there is a current ImPlotContext because the
15631586
// internal tm struct is owned by the context! They are aware of ImPlotStyle.UseLocalTime.
15641587

1588+
// // Make a UNIX timestamp from a tm struct according to the current ImPlotStyle.UseLocalTime setting.
1589+
static inline ImPlotTime MkTime(struct tm *ptm) {
1590+
if (GetStyle().UseLocalTime) return MkLocTime(ptm);
1591+
else return MkGmtTime(ptm);
1592+
}
1593+
// Get a tm struct from a UNIX timestamp according to the current ImPlotStyle.UseLocalTime setting.
1594+
static inline tm* GetTime(const ImPlotTime& t, tm* ptm) {
1595+
if (GetStyle().UseLocalTime) return GetLocTime(t,ptm);
1596+
else return GetGmtTime(t,ptm);
1597+
}
1598+
15651599
// Make a timestamp from time components.
15661600
// year[1970-3000], month[0-11], day[1-31], hour[0-23], min[0-59], sec[0-59], us[0,999999]
15671601
IMPLOT_API ImPlotTime MakeTime(int year, int month = 0, int day = 1, int hour = 0, int min = 0, int sec = 0, int us = 0);
15681602
// Get year component from timestamp [1970-3000]
15691603
IMPLOT_API int GetYear(const ImPlotTime& t);
1604+
// Get month component from timestamp [0-11]
1605+
IMPLOT_API int GetMonth(const ImPlotTime& t);
15701606

15711607
// Adds or subtracts time from a timestamp. #count > 0 to add, < 0 to subtract.
15721608
IMPLOT_API ImPlotTime AddTime(const ImPlotTime& t, ImPlotTimeUnit unit, int count);
@@ -1579,6 +1615,11 @@ IMPLOT_API ImPlotTime RoundTime(const ImPlotTime& t, ImPlotTimeUnit unit);
15791615
// Combines the date of one timestamp with the time-of-day of another timestamp.
15801616
IMPLOT_API ImPlotTime CombineDateTime(const ImPlotTime& date_part, const ImPlotTime& time_part);
15811617

1618+
// Get the current time as a timestamp.
1619+
static inline ImPlotTime Now() { return ImPlotTime::FromDouble((double)time(nullptr)); }
1620+
// Get the current date as a timestamp.
1621+
static inline ImPlotTime Today() { return ImPlot::FloorTime(Now(), ImPlotTimeUnit_Day); }
1622+
15821623
// Formats the time part of timestamp t into a buffer according to #fmt
15831624
IMPLOT_API int FormatTime(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt, bool use_24_hr_clk);
15841625
// Formats the date part of timestamp t into a buffer according to #fmt
@@ -1659,9 +1700,11 @@ static inline int Formatter_Time(double, char* buff, int size, void* data) {
16591700
// [SECTION] Locator
16601701
//------------------------------------------------------------------------------
16611702

1662-
void Locator_Default(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1663-
void Locator_Time(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1664-
void Locator_Log10(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1665-
void Locator_SymLog(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1703+
IMPLOT_API void Locator_Default(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1704+
IMPLOT_API void Locator_Time(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1705+
IMPLOT_API void Locator_Log10(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
1706+
IMPLOT_API void Locator_SymLog(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
16661707

16671708
} // namespace ImPlot
1709+
1710+
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)