From 3421c262703c0112ee2dbc6f4de276f5ab39e477 Mon Sep 17 00:00:00 2001 From: Evan Pezent Date: Sat, 16 May 2020 09:14:48 -0500 Subject: [PATCH] change PlotBar to PlotBars --- implot.cpp | 33 +++++++++++++++++---------------- implot.h | 24 ++++++++++++------------ implot_demo.cpp | 16 ++++++++-------- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/implot.cpp b/implot.cpp index e87dfdf..b781efb 100644 --- a/implot.cpp +++ b/implot.cpp @@ -32,11 +32,12 @@ When you are not sure about a old symbol or function name, try using the Search/ You can read releases logs https://github.com/epezent/implot/releases for more details. - 2020/05/16 (0.2) - All plotting functions were reverted to being prefixed with "Plot" to maintain a consistent VerbNoun style. `Plot` was split into `PlotLine` - and `PlotScatter` (however, `PlotLine` can still be used to plot scatter points as `Plot` did before.) + and `PlotScatter` (however, `PlotLine` can still be used to plot scatter points as `Plot` did before.). `Bar` is not `PlotBars`, to indicate + that multiple bars will be plotted. - 2020/05/13 (0.2) - `ImMarker` was change to `ImPlotMarker` and `ImAxisFlags` was changed to `ImPlotAxisFlags`. - 2020/05/11 (0.2) - `ImPlotFlags_Selection` was changed to `ImPlotFlags_BoxSelect` - 2020/05/11 (0.2) - The namespace ImGui:: was replaced with ImPlot::. As a result, the following additional changes were made: - - Functions that were prefixed or decorated with the word "Plot" have been truncated. E.g., `ImGui::PlotBar` is now just `ImPlot::Bar`. + - Functions that were prefixed or decorated with the word "Plot" have been truncated. E.g., `ImGui::PlotBars` is now just `ImPlot::Bar`. It should be fairly obvious what was what. - Some functions have been given names that would have otherwise collided with the ImGui namespace. This has been done to maintain a consistent style with ImGui. E.g., 'ImGui::PushPlotStyleVar` is now 'ImPlot::PushStyleVar'. @@ -2333,7 +2334,7 @@ struct GetterBarH { template -void PlotBarEx(const char* label_id, Getter getter, int count, float width, int offset) { +void PlotBarsEx(const char* label_id, Getter getter, int count, float width, int offset) { IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Bar() Needs to be called between BeginPlot() and EndPlot()!"); @@ -2385,25 +2386,25 @@ void PlotBarEx(const char* label_id, Getter getter, int count, float width, int PopPlotClipRect(); } -void PlotBar(const char* label_id, const float* values, int count, float width, float shift, int offset, int stride) { +void PlotBars(const char* label_id, const float* values, int count, float width, float shift, int offset, int stride) { GetterBarV getter(values,shift,stride); - PlotBarEx(label_id, getter, count, width, offset); + PlotBarsEx(label_id, getter, count, width, offset); } -void PlotBar(const char* label_id, const float* xs, const float* ys, int count, float width, int offset, int stride) { +void PlotBars(const char* label_id, const float* xs, const float* ys, int count, float width, int offset, int stride) { Getter2D getter(xs,ys,stride); - PlotBarEx(label_id, getter, count, width, offset); + PlotBarsEx(label_id, getter, count, width, offset); } -void PlotBar(const char* label_id, ImVec2 (*getter_func)(void* data, int idx), void* data, int count, float width, int offset) { +void PlotBars(const char* label_id, ImVec2 (*getter_func)(void* data, int idx), void* data, int count, float width, int offset) { GetterFuncPtrImVec2 getter(getter_func, data); - PlotBarEx(label_id, getter, count, width, offset); + PlotBarsEx(label_id, getter, count, width, offset); } //----------------------------------------------------------------------------- template -void PlotBarHEx(const char* label_id, Getter getter, int count, float height, int offset) { +void PlotBarsHEx(const char* label_id, Getter getter, int count, float height, int offset) { IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "BarH() Needs to be called between BeginPlot() and EndPlot()!"); @@ -2455,19 +2456,19 @@ void PlotBarHEx(const char* label_id, Getter getter, int count, float height, i PopPlotClipRect(); } -void PlotBarH(const char* label_id, const float* values, int count, float height, float shift, int offset, int stride) { +void PlotBarsH(const char* label_id, const float* values, int count, float height, float shift, int offset, int stride) { GetterBarH getter(values,shift,stride); - PlotBarHEx(label_id, getter, count, height, offset); + PlotBarsHEx(label_id, getter, count, height, offset); } -void PlotBarH(const char* label_id, const float* xs, const float* ys, int count, float height, int offset, int stride) { +void PlotBarsH(const char* label_id, const float* xs, const float* ys, int count, float height, int offset, int stride) { Getter2D getter(xs,ys,stride); - PlotBarHEx(label_id, getter, count, height, offset); + PlotBarsHEx(label_id, getter, count, height, offset); } -void PlotBarH(const char* label_id, ImVec2 (*getter_func)(void* data, int idx), void* data, int count, float height, int offset) { +void PlotBarsH(const char* label_id, ImVec2 (*getter_func)(void* data, int idx), void* data, int count, float height, int offset) { GetterFuncPtrImVec2 getter(getter_func, data); - PlotBarHEx(label_id, getter, count, height, offset); + PlotBarsHEx(label_id, getter, count, height, offset); } //----------------------------------------------------------------------------- diff --git a/implot.h b/implot.h index 69ffc4e..7fe3837 100644 --- a/implot.h +++ b/implot.h @@ -156,10 +156,10 @@ namespace ImPlot { // title in the plot, use double hashes (e.g. "MyPlot##Hidden"). If #x_label // and/or #y_label are provided, axes labels will be displayed. bool BeginPlot(const char* title_id, - const char* x_label = NULL, - const char* y_label = NULL, - const ImVec2& size = ImVec2(-1,0), - ImPlotFlags flags = ImPlotFlags_Default, + const char* x_label = NULL, + const char* y_label = NULL, + const ImVec2& size = ImVec2(-1,0), + ImPlotFlags flags = ImPlotFlags_Default, ImPlotAxisFlags x_flags = ImPlotAxisFlags_Default, ImPlotAxisFlags y_flags = ImPlotAxisFlags_Default, ImPlotAxisFlags y2_flags = ImPlotAxisFlags_Auxiliary, @@ -183,14 +183,14 @@ void PlotScatter(const char* label_id, const float* xs, const float* ys, int cou void PlotScatter(const char* label_id, const ImVec2* data, int count, int offset = 0); void PlotScatter(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, int offset = 0); // Plots a vertical bar graph. -void PlotBar(const char* label_id, const float* values, int count, float width = 0.67f, float shift = 0, int offset = 0, int stride = sizeof(float)); -void PlotBar(const char* label_id, const float* xs, const float* ys, int count, float width, int offset = 0, int stride = sizeof(float)); -void PlotBar(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, float width, int offset = 0); -// Plots a horizontal bars graph. -void PlotBarH(const char* label_id, const float* values, int count, float height = 0.67f, float shift = 0, int offset = 0, int stride = sizeof(float)); -void PlotBarH(const char* label_id, const float* xs, const float* ys, int count, float height, int offset = 0, int stride = sizeof(float)); -void PlotBarH(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, float height, int offset = 0); -// Plots vertical error bars. +void PlotBars(const char* label_id, const float* values, int count, float width = 0.67f, float shift = 0, int offset = 0, int stride = sizeof(float)); +void PlotBars(const char* label_id, const float* xs, const float* ys, int count, float width, int offset = 0, int stride = sizeof(float)); +void PlotBars(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, float width, int offset = 0); +// Plots a horizontal bar graph. +void PlotBarsH(const char* label_id, const float* values, int count, float height = 0.67f, float shift = 0, int offset = 0, int stride = sizeof(float)); +void PlotBarsH(const char* label_id, const float* xs, const float* ys, int count, float height, int offset = 0, int stride = sizeof(float)); +void PlotBarsH(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, float height, int offset = 0); +// Plots vertical error bar. void PlotErrorBars(const char* label_id, const float* xs, const float* ys, const float* err, int count, int offset = 0, int stride = sizeof(float)); void PlotErrorBars(const char* label_id, const float* xs, const float* ys, const float* neg, const float* pos, int count, int offset = 0, int stride = sizeof(float)); void PlotErrorBars(const char* label_id, ImVec4 (*getter)(void* data, int idx), void* data, int count, int offset = 0); diff --git a/implot_demo.cpp b/implot_demo.cpp index 6e762f2..13dfd57 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -200,14 +200,14 @@ void ShowDemoWindow(bool* p_open) { static float final[10] = {80, 62, 56, 99, 55, 78, 88, 78, 90, 100}; static float grade[10] = {80, 69, 52, 92, 72, 78, 75, 76, 89, 95}; if (horz) { - ImPlot::PlotBarH("Midterm Exam", midtm, 10, 0.2f, -0.2f); - ImPlot::PlotBarH("Final Exam", final, 10, 0.2f, 0); - ImPlot::PlotBarH("Course Grade", grade, 10, 0.2f, 0.2f); + ImPlot::PlotBarsH("Midterm Exam", midtm, 10, 0.2f, -0.2f); + ImPlot::PlotBarsH("Final Exam", final, 10, 0.2f, 0); + ImPlot::PlotBarsH("Course Grade", grade, 10, 0.2f, 0.2f); } else { - ImPlot::PlotBar("Midterm Exam", midtm, 10, 0.2f, -0.2f); - ImPlot::PlotBar("Final Exam", final, 10, 0.2f, 0); - ImPlot::PlotBar("Course Grade", grade, 10, 0.2f, 0.2f); + ImPlot::PlotBars("Midterm Exam", midtm, 10, 0.2f, -0.2f); + ImPlot::PlotBars("Final Exam", final, 10, 0.2f, 0); + ImPlot::PlotBars("Course Grade", grade, 10, 0.2f, 0.2f); } ImPlot::EndPlot(); } @@ -222,7 +222,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::SetNextPlotLimits(0, 6, 0, 10); if (ImPlot::BeginPlot("##ErrorBars",NULL,NULL)) { - ImPlot::PlotBar("Bar", xs, bar, 5, 0.5f); + ImPlot::PlotBars("Bar", xs, bar, 5, 0.5f); ImPlot::PlotErrorBars("Bar", xs, bar, err1, 5); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); @@ -747,7 +747,7 @@ void ShowDemoWindow(bool* p_open) { float lin[10] = {8,8,9,7,8,8,8,9,7,8}; float bar[10] = {1,2,5,3,4,1,2,5,3,4}; float dot[10] = {7,6,6,7,8,5,6,5,8,7}; - ImPlot::PlotBar("Bar", bar, 10, 0.5f); + ImPlot::PlotBars("Bar", bar, 10, 0.5f); ImPlot::PlotLine("Line", lin, 10); ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square);