mirror of
https://github.com/gwm17/implot.git
synced 2024-11-22 18:28:53 -05:00
test xscale and x0
This commit is contained in:
parent
4f0a09f14d
commit
5e0e60b969
|
@ -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/09/10 (0.8) - The single array versions of PlotLine, PlotScatter, PlotStems, and PlotShaded were given additional arguments for x-scale and x0.
|
||||
- 2020/09/07 (0.8) - Plotting functions which accept a custom getter function pointer have been post-fixed with a G (e.g. PlotLineG)
|
||||
- 2020/09/06 (0.7) - Several flags under ImPlotFlags and ImPlotAxisFlags were inverted (e.g. ImPlotFlags_Legend -> ImPlotFlags_NoLegend) so that the default flagset
|
||||
is simply 0. This more closely matches ImGui's style and makes it easier to enable non-default but commonly used flags (e.g. ImPlotAxisFlags_Time).
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define sprintf sprintf_s
|
||||
|
@ -1251,9 +1252,9 @@ void Sparkline(const char* id, const float* values, int count, float min_v, floa
|
|||
ImPlot::SetNextPlotLimits(0, count - 1, min_v, max_v, ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot(id,0,0,size,ImPlotFlags_CanvasOnly|ImPlotFlags_NoChild,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations)) {
|
||||
ImPlot::PushStyleColor(ImPlotCol_Line, col);
|
||||
ImPlot::PlotLine(id, values, count, offset);
|
||||
ImPlot::PlotLine(id, values, count, 1, 0, offset);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||
ImPlot::PlotShaded(id, values, count, 0, offset);
|
||||
ImPlot::PlotShaded(id, values, count, 0, 1, 0, offset);
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::PopStyleColor();
|
||||
ImPlot::EndPlot();
|
||||
|
@ -1534,14 +1535,14 @@ void ShowBenchmarkTool() {
|
|||
}
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
||||
ImPlot::SetNextPlotLimits(0,500,0,500,ImGuiCond_Always);
|
||||
static char buffer[64];
|
||||
if (ImPlot::BeginPlot("##Stats", "Items (1,000 pts each)", "Framerate (Hz)", ImVec2(-1,0), ImPlotFlags_NoChild)) {
|
||||
for (int run = 0; run < records.size(); ++run) {
|
||||
if (records[run].Data.Size > 1) {
|
||||
sprintf(buffer, "B%d-%s%s", run + 1, names[records[run].Mode], records[run].AA ? "-AA" : "");
|
||||
ImPlot::PlotLine(buffer, &records[run].Data.Data[0].x, &records[run].Data.Data[0].y, records[run].Data.Size, 2*sizeof(double));
|
||||
ImVector<ImPlotPoint>& d = records[run].Data;
|
||||
ImPlot::PlotLine(buffer, &d[0].x, &d[0].y, d.Size, 0, 2*sizeof(double));
|
||||
}
|
||||
}
|
||||
ImPlot::EndPlot();
|
||||
|
|
|
@ -250,14 +250,15 @@ struct GetterXsYs {
|
|||
};
|
||||
|
||||
// Always returns a constant Y reference value where the X value is the index
|
||||
template <typename T>
|
||||
struct GetterYRef {
|
||||
GetterYRef(T y_ref, int count) { YRef = y_ref; Count = count; }
|
||||
GetterYRef(double y_ref, int count, double xscale, double x0) : YRef(y_ref), Count(count), XScale(xscale), X0(x0) { }
|
||||
inline ImPlotPoint operator()(int idx) const {
|
||||
return ImPlotPoint((double)idx, (double)YRef);
|
||||
return ImPlotPoint(X0 + XScale*idx, YRef);
|
||||
}
|
||||
T YRef;
|
||||
int Count;
|
||||
const double YRef;
|
||||
const int Count;
|
||||
const double XScale;
|
||||
const double X0;
|
||||
};
|
||||
|
||||
// Interprets an array of X points as ImPlotPoints where the Y value is a constant reference value
|
||||
|
@ -986,7 +987,7 @@ inline void PlotShadedEx(const char* label_id, const Getter1& getter1, const Get
|
|||
template <typename T>
|
||||
void PlotShaded(const char* label_id, const T* values, int count, double y_ref, double xscale, double x0, int offset, int stride) {
|
||||
GetterYs<T> getter1(values,count,xscale,x0,offset,stride);
|
||||
GetterYRef<double> getter2(y_ref,count);
|
||||
GetterYRef getter2(y_ref,count,xscale,x0);
|
||||
PlotShadedEx(label_id, getter1, getter2);
|
||||
}
|
||||
|
||||
|
@ -1379,7 +1380,7 @@ inline void PlotStemsEx(const char* label_id, const GetterM& get_mark, const Get
|
|||
template <typename T>
|
||||
void PlotStems(const char* label_id, const T* values, int count, double y_ref, double xscale, double x0, int offset, int stride) {
|
||||
GetterYs<T> get_mark(values,count,xscale,x0,offset,stride);
|
||||
GetterYRef<double> get_base(y_ref,count);
|
||||
GetterYRef get_base(y_ref,count,xscale,x0);
|
||||
PlotStemsEx(label_id, get_mark, get_base);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user