diff --git a/implot.cpp b/implot.cpp index 35b7f08..678a1f8 100644 --- a/implot.cpp +++ b/implot.cpp @@ -2190,6 +2190,12 @@ struct GetterXsYs { } }; +struct GetterImVec2 { + GetterImVec2(const ImVec2* data) { Data = data; } + inline ImPlotPoint operator()(int idx) { return ImPlotPoint(Data[idx].x, Data[idx].y); } + const ImVec2* Data; +}; + struct GetterImPlotPoint { GetterImPlotPoint(const ImPlotPoint* data) { Data = data; } inline ImPlotPoint operator()(int idx) { return Data[idx]; } @@ -2203,12 +2209,6 @@ struct GetterFuncPtrImPlotPoint { void* data; }; -struct GetterImVec2 { - GetterImVec2(const ImVec2* data) { Data = data; } - inline ImPlotPoint operator()(int idx) { return ImPlotPoint(Data[idx].x, Data[idx].y); } - const ImVec2* Data; -}; - //----------------------------------------------------------------------------- // PLOT //----------------------------------------------------------------------------- diff --git a/implot.h b/implot.h index 78f4f7c..a9b947e 100644 --- a/implot.h +++ b/implot.h @@ -185,66 +185,55 @@ void EndPlot(); // 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); +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 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); + // 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 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); + // 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 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); + // 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 double* xs, const double* ys, const double* err, int count, int offset = 0, int stride = sizeof(double)); 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, const double* xs, const double* ys, const double* neg, const double* pos, int count, int offset = 0, int stride = sizeof(double)); + // Plots a pie chart. If the sum of values > 1, each value will be normalized. Center and radius are in plot coordinates. void PlotPieChart(const char** label_ids, float* values, int count, float x, float y, float radius, bool show_percents = true, float angle0 = 90); +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 float* xs, const float* ys, int count, int offset = 0, int stride = sizeof(float)); +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, float x, float y, bool vertical = false, const ImVec2& pixel_offset = ImVec2(0,0)); - -//----------------------------------------------------------------------------- -// Plot Items (double precision data) -//----------------------------------------------------------------------------- - -// Plots a standard 2D line plot. -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); -// 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); -// 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)); -// 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)); -// 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)); -// Plots a pie chart. If the sum of values > 1, each value will be normalized. Center and radius are in plot coordinates. -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)); -// 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 //----------------------------------------------------------------------------- diff --git a/implot_demo.cpp b/implot_demo.cpp index 1fbdb83..e0339eb 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -167,7 +167,7 @@ void ShowDemoWindow(bool* p_open) { ImGui::BulletText("The demo data precision is: double"); #else ImGui::BulletText("The demo data precision is: float"); -#endif +#endif } //-------------------------------------------------------------------------