diff --git a/implot.h b/implot.h index acdd460..0520dd3 100644 --- a/implot.h +++ b/implot.h @@ -301,50 +301,34 @@ void EndPlot(); // Plot Items //----------------------------------------------------------------------------- -// Plots a standard 2D line plot. -// 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 double* values, int count, int offset = 0, int stride = sizeof(double)); -// 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 double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double)); -// void PlotLine(const char* label_id, const ImVec2* data, int count, int offset = 0); -// void PlotLine(const char* label_id, const ImPlotPoint* data, int count, int offset = 0); +// Supported Types for T* +// float, double, ImS8, ImU8, ImS16, ImU16, ImS32, ImU32, ImS64, ImU64 +// Plots a standard 2D line plot. template void PlotLine(const char* label_id, const T* values, int count, int offset = 0, int stride = sizeof(T)); template void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset = 0, int stride = sizeof(T)); -void PlotLineG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0); - + void PlotLineG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0); // Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle. -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 double* values, int count, int offset = 0, int stride = sizeof(double)); -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 double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double)); -void PlotScatter(const char* label_id, const ImVec2* data, int count, int offset = 0); -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); +template void PlotScatter(const char* label_id, const T* values, int count, int offset = 0, int stride = sizeof(T)); +template void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset = 0, int stride = sizeof(T)); + void PlotScatterG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0); // Plots a shaded (filled) region between two lines, or a line and a horizontal reference. -void PlotShaded(const char* label_id, const float* values, int count, float y_ref = 0, int offset = 0, int stride = sizeof(float)); -void PlotShaded(const char* label_id, const double* values, int count, double y_ref = 0, int offset = 0, int stride = sizeof(double)); -void PlotShaded(const char* label_id, const float* xs, const float* ys, int count, float y_ref = 0, int offset = 0, int stride = sizeof(float)); -void PlotShaded(const char* label_id, const double* xs, const double* ys, int count, double y_ref = 0, int offset = 0, int stride = sizeof(double)); -void PlotShaded(const char* label_id, const float* xs, const float* ys1, const float* ys2, int count, int offset = 0, int stride = sizeof(float)); -void PlotShaded(const char* label_id, const double* xs, const double* ys1, const double* ys2, int count, int offset = 0, int stride = sizeof(double)); -void PlotShaded(const char* label_id, ImPlotPoint (*getter1)(void* data, int idx), void* data1, ImPlotPoint (*getter2)(void* data, int idx), void* data2, int count, int offset = 0); +template void PlotShaded(const char* label_id, const T* values, int count, double y_ref = 0, int offset = 0, int stride = sizeof(T)); +template void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref = 0, int offset = 0, int stride = sizeof(T)); +template void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, int offset = 0, int stride = sizeof(T)); + void PlotShadedG(const char* label_id, ImPlotPoint (*getter1)(void* data, int idx), void* data1, ImPlotPoint (*getter2)(void* data, int idx), void* data2, int count, int offset = 0); // Plots a vertical bar graph. #width and #shift are in X units. -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 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 float* xs, const float* ys, int count, float width, int offset = 0, int stride = sizeof(float)); -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); +template void PlotBars(const char* label_id, const T* values, int count, double width = 0.67, double shift = 0, int offset = 0, int stride = sizeof(T)); +template void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double width, int offset = 0, int stride = sizeof(T)); + void PlotBarsG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double width, int offset = 0); // Plots a horizontal bar graph. #height and #shift are in Y units. -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 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 float* xs, const float* ys, int count, float height, int offset = 0, int stride = sizeof(float)); -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); +template void PlotBarsH(const char* label_id, const T* values, int count, double height = 0.67, double shift = 0, int offset = 0, int stride = sizeof(T)); +template void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double height, int offset = 0, int stride = sizeof(T)); + void PlotBarsHG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double height, int offset = 0); // Plots vertical error bar. The label_id should be the same as the label_id of the associated line or bar plot. void PlotErrorBars(const char* label_id, const float* xs, const float* ys, const float* err, int count, int offset = 0, int stride = sizeof(float)); diff --git a/implot_demo.cpp b/implot_demo.cpp index 84b67af..0553303 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -1069,7 +1069,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::PlotLineG("Waves", MyImPlot::SineWave, &data1, 1000); ImPlot::PlotLineG("Waves", MyImPlot::SawWave, &data2, 1000); ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f); - ImPlot::PlotShaded("Waves", MyImPlot::SineWave, &data1, MyImPlot::SawWave, &data2, 1000); + ImPlot::PlotShadedG("Waves", MyImPlot::SineWave, &data1, MyImPlot::SawWave, &data2, 1000); ImPlot::PopStyleVar(); // you can also pass C++ lambdas: // auto lamda = [](void* data, int idx) { ... return ImPlotPoint(x,y); }; diff --git a/implot_items.cpp b/implot_items.cpp index 6594d59..6d990ba 100644 --- a/implot_items.cpp +++ b/implot_items.cpp @@ -257,9 +257,9 @@ struct GetterYRef { }; // Interprets an array of X points as ImPlotPoints where the Y value is a constant reference value -template +template struct GetterXsYRef { - GetterXsYRef(const T* xs, T y_ref, int count, int offset, int stride) { + GetterXsYRef(const T* xs, Y y_ref, int count, int offset, int stride) { Xs = xs; YRef = y_ref; Count = count; @@ -267,7 +267,7 @@ struct GetterXsYRef { Stride = stride; } const T* Xs; - T YRef; + Y YRef; int Count; int Offset; int Stride; @@ -328,15 +328,15 @@ struct GetterFuncPtrImPlotPoint { template struct GetterBarV { - const T* Ys; T XShift; int Count; int Offset; int Stride; - GetterBarV(const T* ys, T xshift, int count, int offset, int stride) { Ys = ys; XShift = xshift; Count = count; Offset = offset; Stride = stride; } + const T* Ys; double XShift; int Count; int Offset; int Stride; + GetterBarV(const T* ys, double xshift, int count, int offset, int stride) { Ys = ys; XShift = xshift; Count = count; Offset = offset; Stride = stride; } inline ImPlotPoint operator()(int idx) { return ImPlotPoint((double)idx + (double)XShift, (double)OffsetAndStride(Ys, idx, Count, Offset, Stride)); } }; template struct GetterBarH { - const T* Xs; T YShift; int Count; int Offset; int Stride; - GetterBarH(const T* xs, T yshift, int count, int offset, int stride) { Xs = xs; YShift = yshift; Count = count; Offset = offset; Stride = stride; } + const T* Xs; double YShift; int Count; int Offset; int Stride; + GetterBarH(const T* xs, double yshift, int count, int offset, int stride) { Xs = xs; YShift = yshift; Count = count; Offset = offset; Stride = stride; } inline ImPlotPoint operator()(int idx) { return ImPlotPoint((double)OffsetAndStride(Xs, idx, Count, Offset, Stride), (double)idx + (double)YShift); } }; @@ -359,7 +359,6 @@ struct GetterError { //----------------------------------------------------------------------------- // Transforms convert points in plot space (i.e. ImPlotPoint) to pixel space (i.e. ImVec2) -// TODO: Cache transformation variables // Transforms points for linear x and linear y space struct TransformerLinLin { @@ -371,7 +370,6 @@ struct TransformerLinLin { return ImVec2( (float)(gp.PixelRange[YAxis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min)), (float)(gp.PixelRange[YAxis].Min.y + gp.My[YAxis] * (y - gp.CurrentPlot->YAxis[YAxis].Range.Min)) ); } - int YAxis; }; @@ -420,7 +418,6 @@ struct TransformerLogLog { return ImVec2( (float)(gp.PixelRange[YAxis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min)), (float)(gp.PixelRange[YAxis].Min.y + gp.My[YAxis] * (y - gp.CurrentPlot->YAxis[YAxis].Range.Min)) ); } - int YAxis; }; @@ -813,7 +810,7 @@ inline void RenderMarkers(Getter getter, Transformer transformer, ImDrawList& Dr } //----------------------------------------------------------------------------- -// PLOT LINES / MARKERS +// PLOT LINES //----------------------------------------------------------------------------- template @@ -881,7 +878,6 @@ void PlotLine(const char* label_id, const ImPlotPoint* data, int co } - template void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset, int stride) { GetterXsYs getter(xs,ys,count,offset,stride); @@ -936,40 +932,55 @@ inline void PlotScatterEx(const char* label_id, Getter getter) { } } -// float -void PlotScatter(const char* label_id, const float* values, int count, int offset, int stride) { - GetterYs getter(values,count,offset,stride); +template +void PlotScatter(const char* label_id, const T* values, int count, int offset, int stride) { + GetterYs getter(values,count,offset,stride); PlotScatterEx(label_id, getter); } -void PlotScatter(const char* label_id, const float* xs, const float* ys, int count, int offset, int stride) { - GetterXsYs getter(xs,ys,count,offset,stride); - return PlotScatterEx(label_id, getter); -} +template void PlotScatter(const char* label_id, const ImS8* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU8* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImS16* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU16* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImS32* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU32* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImS64* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU64* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const float* values, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const double* values, int count, int offset, int stride); -void PlotScatter(const char* label_id, const ImVec2* data, int count, int offset) { +template <> +void PlotScatter(const char* label_id, const ImVec2* data, int count, int offset, int) { GetterImVec2 getter(data, count, offset); return PlotScatterEx(label_id, getter); } -// double -void PlotScatter(const char* label_id, const double* values, int count, int offset, int stride) { - GetterYs getter(values,count,offset,stride); - PlotScatterEx(label_id, getter); -} - -void PlotScatter(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride) { - GetterXsYs getter(xs,ys,count,offset,stride); - return PlotScatterEx(label_id, getter); -} - -void PlotScatter(const char* label_id, const ImPlotPoint* data, int count, int offset) { +template <> +void PlotScatter(const char* label_id, const ImPlotPoint* data, int count, int offset, int) { GetterImPlotPoint getter(data, count, offset); return PlotScatterEx(label_id, getter); } + +template +void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset, int stride) { + GetterXsYs getter(xs,ys,count,offset,stride); + return PlotScatterEx(label_id, getter); +} + +template void PlotScatter(const char* label_id, const ImS8* xs, const ImS8* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU8* xs, const ImU8* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImS16* xs, const ImS16* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU16* xs, const ImU16* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImS32* xs, const ImS32* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU32* xs, const ImU32* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImS64* xs, const ImS64* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const ImU64* xs, const ImU64* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const float* xs, const float* ys, int count, int offset, int stride); +template void PlotScatter(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride); + // custom -void PlotScatter(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, int offset) { +void PlotScatterG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, int offset) { GetterFuncPtrImPlotPoint getter(getter_func,data, count, offset); return PlotScatterEx(label_id, getter); } @@ -1004,52 +1015,69 @@ inline void PlotShadedEx(const char* label_id, Getter1 getter1, Getter2 getter2) } } -// float -void PlotShaded(const char* label_id, const float* values, int count, float y_ref, int offset, int stride) { - GetterYs getter1(values,count,offset,stride); - GetterYRef getter2(y_ref, count); - PlotShadedEx(label_id, getter1, getter2);} - -void PlotShaded(const char* label_id, const float* xs, const float* ys1, const float* ys2, int count, int offset, int stride) { - GetterXsYs getter1(xs, ys1, count, offset, stride); - GetterXsYs getter2(xs, ys2, count, offset, stride); - PlotShadedEx(label_id, getter1, getter2); -} - -void PlotShaded(const char* label_id, const float* xs, const float* ys, int count, float y_ref, int offset, int stride) { - GetterXsYs getter1(xs, ys, count, offset, stride); - GetterXsYRef getter2(xs, y_ref, count, offset, stride); - PlotShadedEx(label_id, getter1, getter2); -} - -// double -void PlotShaded(const char* label_id, const double* values, int count, double y_ref, int offset, int stride) { - GetterYs getter1(values,count,offset,stride); +template +void PlotShaded(const char* label_id, const T* values, int count, double y_ref, int offset, int stride) { + GetterYs getter1(values,count,offset,stride); GetterYRef getter2(y_ref, count); PlotShadedEx(label_id, getter1, getter2); } -void PlotShaded(const char* label_id, const double* xs, const double* ys1, const double* ys2, int count, int offset, int stride) { - GetterXsYs getter1(xs, ys1, count, offset, stride); - GetterXsYs getter2(xs, ys2, count, offset, stride); +template void PlotShaded(const char* label_id, const ImS8* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU8* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS16* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU16* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS32* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU32* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS64* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU64* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const float* values, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const double* values, int count, double y_ref, int offset, int stride); + +template +void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref, int offset, int stride) { + GetterXsYs getter1(xs, ys, count, offset, stride); + GetterXsYRef getter2(xs, y_ref, count, offset, stride); PlotShadedEx(label_id, getter1, getter2); } -void PlotShaded(const char* label_id, const double* xs, const double* ys, int count, double y_ref, int offset, int stride) { - GetterXsYs getter1(xs, ys, count, offset, stride); - GetterXsYRef getter2(xs, y_ref, count, offset, stride); +template void PlotShaded(const char* label_id, const ImS8* xs, const ImS8* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU8* xs, const ImU8* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS16* xs, const ImS16* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU16* xs, const ImU16* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS32* xs, const ImS32* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU32* xs, const ImU32* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS64* xs, const ImS64* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU64* xs, const ImU64* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const float* xs, const float* ys, int count, double y_ref, int offset, int stride); +template void PlotShaded(const char* label_id, const double* xs, const double* ys, int count, double y_ref, int offset, int stride); + +template +void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, int offset, int stride) { + GetterXsYs getter1(xs, ys1, count, offset, stride); + GetterXsYs getter2(xs, ys2, count, offset, stride); PlotShadedEx(label_id, getter1, getter2); } +template void PlotShaded(const char* label_id, const ImS8* xs, const ImS8* ys1, const ImS8* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU8* xs, const ImU8* ys1, const ImU8* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS16* xs, const ImS16* ys1, const ImS16* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU16* xs, const ImU16* ys1, const ImU16* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS32* xs, const ImS32* ys1, const ImS32* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU32* xs, const ImU32* ys1, const ImU32* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImS64* xs, const ImS64* ys1, const ImS64* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const ImU64* xs, const ImU64* ys1, const ImU64* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const float* xs, const float* ys1, const float* ys2, int count, int offset, int stride); +template void PlotShaded(const char* label_id, const double* xs, const double* ys1, const double* ys2, int count, int offset, int stride); + // custom -void PlotShaded(const char* label_id, ImPlotPoint (*g1)(void* data, int idx), void* data1, ImPlotPoint (*g2)(void* data, int idx), void* data2, int count, int offset) { +void PlotShadedG(const char* label_id, ImPlotPoint (*g1)(void* data, int idx), void* data1, ImPlotPoint (*g2)(void* data, int idx), void* data2, int count, int offset) { GetterFuncPtrImPlotPoint getter1(g1, data1, count, offset); GetterFuncPtrImPlotPoint getter2(g2, data2, count, offset); PlotShadedEx(label_id, getter1, getter2); } //----------------------------------------------------------------------------- -// PLOT BAR V +// PLOT BAR //----------------------------------------------------------------------------- // TODO: Migrate to RenderPrimitives @@ -1087,30 +1115,42 @@ void PlotBarsEx(const char* label_id, Getter getter, TWidth width) { } } -// float -void PlotBars(const char* label_id, const float* values, int count, float width, float shift, int offset, int stride) { - GetterBarV getter(values,shift,count,offset,stride); +template +void PlotBars(const char* label_id, const T* values, int count, double width, double shift, int offset, int stride) { + GetterBarV getter(values,shift,count,offset,stride); PlotBarsEx(label_id, getter, width); } -void PlotBars(const char* label_id, const float* xs, const float* ys, int count, float width, int offset, int stride) { - GetterXsYs getter(xs,ys,count,offset,stride); +template void PlotBars(const char* label_id, const ImS8* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImU8* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImS16* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImU16* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImS32* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImU32* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImS64* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const ImU64* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const float* values, int count, double width, double shift, int offset, int stride); +template void PlotBars(const char* label_id, const double* values, int count, double width, double shift, int offset, int stride); + +template +void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double width, int offset, int stride) { + GetterXsYs getter(xs,ys,count,offset,stride); PlotBarsEx(label_id, getter, width); } -// double -void PlotBars(const char* label_id, const double* values, int count, double width, double shift, int offset, int stride) { - GetterBarV getter(values,shift,count,offset,stride); - PlotBarsEx(label_id, getter, width); -} - -void PlotBars(const char* label_id, const double* xs, const double* ys, int count, double width, int offset, int stride) { - GetterXsYs getter(xs,ys,count,offset,stride); - PlotBarsEx(label_id, getter, width); -} +template void PlotBars(const char* label_id, const ImS8* xs, const ImS8* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImU8* xs, const ImU8* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImS16* xs, const ImS16* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImU16* xs, const ImU16* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImS32* xs, const ImS32* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImU32* xs, const ImU32* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImS64* xs, const ImS64* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const ImU64* xs, const ImU64* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const float* xs, const float* ys, int count, double width, int offset, int stride); +template void PlotBars(const char* label_id, const double* xs, const double* ys, int count, double width, int offset, int stride); // custom -void PlotBars(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double width, int offset) { +void PlotBarsG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double width, int offset) { GetterFuncPtrImPlotPoint getter(getter_func, data, count, offset); PlotBarsEx(label_id, getter, width); } @@ -1154,30 +1194,41 @@ void PlotBarsHEx(const char* label_id, Getter getter, THeight height) { } } -// float -void PlotBarsH(const char* label_id, const float* values, int count, float height, float shift, int offset, int stride) { - GetterBarH getter(values,shift,count,offset,stride); +template +void PlotBarsH(const char* label_id, const T* values, int count, double height, double shift, int offset, int stride) { + GetterBarH getter(values,shift,count,offset,stride); PlotBarsHEx(label_id, getter, height); } -void PlotBarsH(const char* label_id, const float* xs, const float* ys, int count, float height, int offset, int stride) { - GetterXsYs getter(xs,ys,count,offset,stride); - PlotBarsHEx(label_id, getter, height); -} - -// double -void PlotBarsH(const char* label_id, const double* values, int count, double height, double shift, int offset, int stride) { - GetterBarH getter(values,shift,count,offset,stride); - PlotBarsHEx(label_id, getter, height); -} - -void PlotBarsH(const char* label_id, const double* xs, const double* ys, int count, double height, int offset, int stride) { - GetterXsYs getter(xs,ys,count,offset,stride); +template void PlotBarsH(const char* label_id, const ImS8* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU8* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImS16* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU16* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImS32* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU32* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImS64* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU64* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const float* values, int count, double height, double shift, int offset, int stride); +template void PlotBarsH(const char* label_id, const double* values, int count, double height, double shift, int offset, int stride); + +template +void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double height, int offset, int stride) { + GetterXsYs getter(xs,ys,count,offset,stride); PlotBarsHEx(label_id, getter, height); } +template void PlotBarsH(const char* label_id, const ImS8* xs, const ImS8* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU8* xs, const ImU8* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImS16* xs, const ImS16* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU16* xs, const ImU16* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImS32* xs, const ImS32* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU32* xs, const ImU32* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImS64* xs, const ImS64* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const ImU64* xs, const ImU64* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const float* xs, const float* ys, int count, double height, int offset, int stride); +template void PlotBarsH(const char* label_id, const double* xs, const double* ys, int count, double height, int offset, int stride); // custom -void PlotBarsH(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double height, int offset) { +void PlotBarsHG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double height, int offset) { GetterFuncPtrImPlotPoint getter(getter_func, data, count, offset); PlotBarsHEx(label_id, getter, height); } @@ -1347,13 +1398,13 @@ void PlotStems(const char* label_id, const double* values, int count, double y_r void PlotStems(const char* label_id, const float* xs, const float* ys, int count, float y_ref, int offset, int stride) { GetterXsYs get_mark(xs,ys,count,offset,stride); - GetterXsYRef get_base(xs,y_ref,count,offset,stride); + GetterXsYRef get_base(xs,y_ref,count,offset,stride); PlotStemsEx(label_id, get_mark, get_base); } void PlotStems(const char* label_id, const double* xs, const double* ys, int count, double y_ref, int offset, int stride) { GetterXsYs get_mark(xs,ys,count,offset,stride); - GetterXsYRef get_base(xs,y_ref,count,offset,stride); + GetterXsYRef get_base(xs,y_ref,count,offset,stride); PlotStemsEx(label_id, get_mark, get_base); }