1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 15:47:26 -04:00

removed ImVec2* custom getters, use ImPlotPoint* getter functions

This commit is contained in:
Evan Pezent 2020-05-31 09:07:24 -05:00
parent 165c3b892d
commit 0aa21d4b3f
2 changed files with 26 additions and 42 deletions

View File

@ -31,6 +31,7 @@ Below is a change-log of API breaking changes only. If you are using one of the
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all implot files.
You can read releases logs https://github.com/epezent/implot/releases for more details.
- 2020/05/31 (0.3) - Plot functions taking custom ImVec2* getters were removed. Use the ImPlotPoint* getter versions instead.
- 2020/05/29 (0.3) - The signature of ImPlotLimits::Contains was changed to take two doubles instead of ImVec2
- 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.). `Bar` is not `PlotBars`, to indicate
@ -2208,13 +2209,6 @@ struct GetterImVec2 {
const ImVec2* Data;
};
struct GetterFuncPtrImVec2 {
GetterFuncPtrImVec2(ImVec2 (*g)(void* data, int idx), void* d) { getter = g; data = d;}
inline ImPlotPoint operator()(int idx) { ImVec2 p = getter(data, idx); return ImPlotPoint(p.x,p.y); }
ImVec2 (*getter)(void* data, int idx);
void* data;
};
//-----------------------------------------------------------------------------
// PLOT
//-----------------------------------------------------------------------------
@ -2297,10 +2291,6 @@ void PlotLine(const char* label_id, const ImVec2* data, int count, int offset) {
return PlotEx(label_id, getter, count, offset);
}
void PlotLine(const char* label_id, ImVec2 (*getter_func)(void* data, int idx), void* data, int count, int offset) {
GetterFuncPtrImVec2 getter(getter_func,data);
return PlotEx(label_id, getter, count, offset);
}
//-----------------------------------------------------------------------------
// double
@ -2320,6 +2310,9 @@ void PlotLine(const char* label_id, const ImPlotPoint* data, int count, int offs
return PlotEx(label_id, getter, count, offset);
}
//-----------------------------------------------------------------------------
// custom
void PlotLine(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, int offset) {
GetterFuncPtrImPlotPoint getter(getter_func,data);
return PlotEx(label_id, getter, count, offset);
@ -2360,12 +2353,6 @@ void PlotScatter(const char* label_id, const ImVec2* data, int count, int offset
PopStyleVar(vars);
}
void PlotScatter(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, int offset) {
int vars = PushScatterStyle();
PlotLine(label_id, getter, data, count, offset);
PopStyleVar(vars);
}
//-----------------------------------------------------------------------------
// double
@ -2387,6 +2374,9 @@ void PlotScatter(const char* label_id, const ImPlotPoint* data, int count, int o
PopStyleVar(vars);
}
//-----------------------------------------------------------------------------
// custom
void PlotScatter(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset) {
int vars = PushScatterStyle();
PlotLine(label_id, getter, data, count, offset);
@ -2478,11 +2468,6 @@ void PlotBars(const char* label_id, const float* xs, const float* ys, int count,
PlotBarsEx(label_id, getter, count, width, 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);
PlotBarsEx(label_id, getter, count, width, offset);
}
//-----------------------------------------------------------------------------
// double
@ -2496,6 +2481,9 @@ void PlotBars(const char* label_id, const double* xs, const double* ys, int coun
PlotBarsEx(label_id, getter, count, width, offset);
}
//-----------------------------------------------------------------------------
// custom
void PlotBars(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double width, int offset) {
GetterFuncPtrImPlotPoint getter(getter_func, data);
PlotBarsEx(label_id, getter, count, width, offset);
@ -2571,11 +2559,6 @@ void PlotBarsH(const char* label_id, const float* xs, const float* ys, int count
PlotBarsHEx(label_id, getter, count, height, 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);
PlotBarsHEx(label_id, getter, count, height, offset);
}
//-----------------------------------------------------------------------------
// double
@ -2589,6 +2572,9 @@ void PlotBarsH(const char* label_id, const double* xs, const double* ys, int cou
PlotBarsHEx(label_id, getter, count, height, offset);
}
//-----------------------------------------------------------------------------
// custom
void PlotBarsH(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double height, int offset) {
GetterFuncPtrImPlotPoint getter(getter_func, data);
PlotBarsHEx(label_id, getter, count, height, offset);
@ -2855,11 +2841,6 @@ void PlotDigital(const char* label_id, const float* xs, const float* ys, int cou
return PlotDigitalEx(label_id, getter, count, offset);
}
void PlotDigital(const char* label_id, ImVec2 (*getter_func)(void* data, int idx), void* data, int count, int offset) {
GetterFuncPtrImVec2 getter(getter_func,data);
return PlotDigitalEx(label_id, getter, count, offset);
}
//-----------------------------------------------------------------------------
// double
@ -2868,6 +2849,9 @@ void PlotDigital(const char* label_id, const double* xs, const double* ys, int c
return PlotDigitalEx(label_id, getter, count, offset);
}
//-----------------------------------------------------------------------------
// custom
void PlotDigital(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, int offset) {
GetterFuncPtrImPlotPoint getter(getter_func,data);
return PlotDigitalEx(label_id, getter, count, offset);

View File

@ -187,20 +187,16 @@ void EndPlot();
void PlotLine(const char* label_id, const float* values, int count, int offset = 0, int stride = sizeof(float));
void PlotLine(const char* label_id, const float* xs, const float* ys, int count, int offset = 0, int stride = sizeof(float));
void PlotLine(const char* label_id, const ImVec2* data, int count, int offset = 0);
void PlotLine(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, int offset = 0);
// Plots a standard 2D scatter plot.
void PlotScatter(const char* label_id, const float* values, int count, int offset = 0, int stride = sizeof(float));
void PlotScatter(const char* label_id, const float* xs, const float* ys, int count, int offset = 0, int stride = sizeof(float));
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 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));
@ -208,7 +204,6 @@ void PlotErrorBars(const char* label_id, const float* xs, const float* ys, const
void PlotPieChart(const char** label_ids, float* values, int count, float x, float y, float radius, bool show_percents = true, float angle0 = 90);
// Plots digital data.
void PlotDigital(const char* label_id, const float* xs, const float* ys, int count, int offset = 0, int stride = sizeof(float));
void PlotDigital(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* data, int count, int offset = 0);
// Plots a text label at point x,y.
void PlotText(const char* text, float x, float y, bool vertical = false, const ImVec2& pixel_offset = ImVec2(0,0));
@ -220,20 +215,16 @@ void PlotText(const char* text, float x, float y, bool vertical = false, const I
void PlotLine(const char* label_id, const double* values, int count, int offset = 0, int stride = sizeof(double));
void PlotLine(const char* label_id, const double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double));
void PlotLine(const char* label_id, const ImPlotPoint* data, int count, int offset = 0);
void PlotLine(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
// Plots a standard 2D scatter plot.
void PlotScatter(const char* label_id, const double* values, int count, int offset = 0, int stride = sizeof(double));
void PlotScatter(const char* label_id, const double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double));
void PlotScatter(const char* label_id, const ImPlotPoint* data, int count, int offset = 0);
void PlotScatter(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
// Plots a vertical bar graph.
void PlotBars(const char* label_id, const double* values, int count, double width = 0.67f, double shift = 0, int offset = 0, int stride = sizeof(double));
void PlotBars(const char* label_id, const double* xs, const double* ys, int count, double width, int offset = 0, int stride = sizeof(double));
void PlotBars(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double width, int offset = 0);
// Plots a horizontal bar graph.
void PlotBarsH(const char* label_id, const double* values, int count, double height = 0.67f, double shift = 0, int offset = 0, int stride = sizeof(double));
void PlotBarsH(const char* label_id, const double* xs, const double* ys, int count, double height, int offset = 0, int stride = sizeof(double));
void PlotBarsH(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double height, int offset = 0);
// Plots vertical error bar.
void PlotErrorBars(const char* label_id, const double* xs, const double* ys, const double* err, int count, int offset = 0, int stride = sizeof(double));
void PlotErrorBars(const char* label_id, const double* xs, const double* ys, const double* neg, const double* pos, int count, int offset = 0, int stride = sizeof(double));
@ -241,10 +232,19 @@ void PlotErrorBars(const char* label_id, const double* xs, const double* ys, con
void PlotPieChart(const char** label_ids, double* values, int count, double x, double y, double radius, bool show_percents = true, double angle0 = 90);
// Plots digital data.
void PlotDigital(const char* label_id, const double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double));
void PlotDigital(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
// Plots a text label at point x,y.
void PlotText(const char* text, double x, double y, bool vertical = false, const ImVec2& pixel_offset = ImVec2(0,0));
//-----------------------------------------------------------------------------
// Plot Items (custom getters)
//-----------------------------------------------------------------------------
void PlotLine(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
void PlotScatter(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
void PlotBars(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double width, int offset = 0);
void PlotBarsH(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double height, int offset = 0);
void PlotDigital(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
//-----------------------------------------------------------------------------
// Plot Queries
//-----------------------------------------------------------------------------