1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-13 14:38:51 -05:00

fix imgui backward compat, YAxis[3], and add new demo benchmark option for LineG

This commit is contained in:
Evan Pezent 2021-07-09 17:39:12 -07:00
parent 5ab78cbc7d
commit 51930a5ae6
4 changed files with 26 additions and 18 deletions

View File

@ -83,11 +83,6 @@ You can read releases logs https://github.com/epezent/implot/releases for more d
#define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All
#endif
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
#if (IMGUI_VERSION_NUM < 18303)
#define GetBufSize GetSize // A little bit ugly since 'GetBufSize' could technically be used elsewhere (but currently isn't). Could use a proxy define if needed.
#endif
// Global plot context
ImPlotContext* GImPlot = NULL;
@ -4483,7 +4478,7 @@ void ShowMetricsWindow(bool* p_popen) {
if (ImHasFlag(plot->Flags, ImPlotFlags_YAxis2))
fg.AddRect(plot->YAxis[1].HoverRect.Min, plot->YAxis[1].HoverRect.Max, IM_COL32(0,255,0,255));
if (ImHasFlag(plot->Flags, ImPlotFlags_YAxis3))
fg.AddRect(plot->YAxis[3].HoverRect.Min, plot->YAxis[2].HoverRect.Max, IM_COL32(0,255,0,255));
fg.AddRect(plot->YAxis[2].HoverRect.Min, plot->YAxis[2].HoverRect.Max, IM_COL32(0,255,0,255));
}
}
for (int p = 0; p < n_subplots; ++p) {

View File

@ -2063,9 +2063,10 @@ struct BenchData {
enum BenchMode {
Line = 0,
Shaded = 1,
Scatter = 2,
Bars = 3
LineG = 1,
Shaded = 2,
Scatter = 3,
Bars = 4
};
struct BenchRecord {
@ -2074,6 +2075,11 @@ struct BenchRecord {
ImVector<ImPlotPoint> Data;
};
ImPlotPoint BenchmarkGetter(void* data, int idx) {
float* values = (float*)data;
return ImPlotPoint(idx, values[idx]);
}
void ShowBenchmarkTool() {
static const int max_items = 500;
static BenchData items[max_items];
@ -2083,7 +2089,7 @@ void ShowBenchmarkTool() {
static int F = 0;
static double t1, t2;
static int mode = BenchMode::Line;
const char* names[] = {"Line","Shaded","Scatter","Bars"};
const char* names[] = {"Line","LineG","Shaded","Scatter","Bars"};
static ImVector<BenchRecord> records;
@ -2143,6 +2149,14 @@ void ShowBenchmarkTool() {
ImGui::PopID();
}
}
else if (mode == BenchMode::LineG) {
for (int i = 0; i < L; ++i) {
ImGui::PushID(i);
ImPlot::SetNextLineStyle(items[i].Col);
ImPlot::PlotLineG("##item",BenchmarkGetter,items[i].Data,1000);
ImGui::PopID();
}
}
else if (mode == BenchMode::Shaded) {
for (int i = 0; i < L; ++i) {
ImGui::PushID(i);

View File

@ -42,6 +42,11 @@
#error Must include implot.h before implot_internal.h
#endif
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
#if (IMGUI_VERSION_NUM < 18303)
#define GetBufSize GetSize
#endif
//-----------------------------------------------------------------------------
// [SECTION] Constants
//-----------------------------------------------------------------------------
@ -1264,8 +1269,8 @@ void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
// Offsets and strides a data buffer
template <typename T>
static inline T OffsetAndStride(const T* data, int idx, int count, int offset, int stride) {
idx = ImPosMod(offset + idx, count);
static inline T OffsetAndStride(const T* data, int idx, int , int , int stride) {
// idx = ImPosMod(offset + idx, count);
return *(const T*)(const void*)((const unsigned char*)data + (size_t)idx * stride);
}

View File

@ -47,12 +47,6 @@
#define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All
#endif
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
#if (IMGUI_VERSION_NUM < 18303)
#define GetBufSize GetSize // A little bit ugly since 'GetBufSize' could technically be used elsewhere (but currently isn't). Could use a proxy define if needed.
#endif
namespace ImPlot {
//-----------------------------------------------------------------------------