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

clean up refactors, organize implot_internal.h

This commit is contained in:
epezent 2020-08-16 18:46:59 -05:00
parent d9ae47bf2b
commit 4463fa107a
4 changed files with 84 additions and 71 deletions

View File

@ -605,11 +605,11 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
} }
// AXIS STATES ------------------------------------------------------------ // AXIS STATES ------------------------------------------------------------
gp.X = ImPlotAxisState(plot.XAxis, gp.NextPlotData.HasXRange, gp.NextPlotData.XRangeCond, true, 0); gp.X = ImPlotAxisState(&plot.XAxis, gp.NextPlotData.HasXRange, gp.NextPlotData.XRangeCond, true, 0);
gp.Y[0] = ImPlotAxisState(plot.YAxis[0], gp.NextPlotData.HasYRange[0], gp.NextPlotData.YRangeCond[0], true, 0); gp.Y[0] = ImPlotAxisState(&plot.YAxis[0], gp.NextPlotData.HasYRange[0], gp.NextPlotData.YRangeCond[0], true, 0);
gp.Y[1] = ImPlotAxisState(plot.YAxis[1], gp.NextPlotData.HasYRange[1], gp.NextPlotData.YRangeCond[1], gp.Y[1] = ImPlotAxisState(&plot.YAxis[1], gp.NextPlotData.HasYRange[1], gp.NextPlotData.YRangeCond[1],
ImHasFlag(plot.Flags, ImPlotFlags_YAxis2), gp.Y[0].PresentSoFar); ImHasFlag(plot.Flags, ImPlotFlags_YAxis2), gp.Y[0].PresentSoFar);
gp.Y[2] = ImPlotAxisState(plot.YAxis[2], gp.NextPlotData.HasYRange[2], gp.NextPlotData.YRangeCond[2], gp.Y[2] = ImPlotAxisState(&plot.YAxis[2], gp.NextPlotData.HasYRange[2], gp.NextPlotData.YRangeCond[2],
ImHasFlag(plot.Flags, ImPlotFlags_YAxis3), gp.Y[1].PresentSoFar); ImHasFlag(plot.Flags, ImPlotFlags_YAxis3), gp.Y[1].PresentSoFar);
gp.LockPlot = gp.X.Lock && gp.Y[0].Lock && gp.Y[1].Lock && gp.Y[2].Lock; gp.LockPlot = gp.X.Lock && gp.Y[0].Lock && gp.Y[1].Lock && gp.Y[2].Lock;
@ -1511,7 +1511,6 @@ ImPlotInputMap& GetInputMap() {
} }
void SetNextPlotLimits(double x_min, double x_max, double y_min, double y_max, ImGuiCond cond) { void SetNextPlotLimits(double x_min, double x_max, double y_min, double y_max, ImGuiCond cond) {
ImPlotContext& gp = *GImPlot;
IM_ASSERT_USER_ERROR(gp.CurrentPlot == NULL, "SetNextPlotLimits() needs to be called before BeginPlot()!"); IM_ASSERT_USER_ERROR(gp.CurrentPlot == NULL, "SetNextPlotLimits() needs to be called before BeginPlot()!");
SetNextPlotLimitsX(x_min, x_max, cond); SetNextPlotLimitsX(x_min, x_max, cond);
SetNextPlotLimitsY(y_min, y_max, cond); SetNextPlotLimitsY(y_min, y_max, cond);
@ -1825,8 +1824,8 @@ ImVec4 LerpColormap(float t) {
ImVec4 NextColormapColor() { ImVec4 NextColormapColor() {
ImPlotContext& gp = *GImPlot; ImPlotContext& gp = *GImPlot;
ImVec4 col = gp.Colormap[gp.CurrentPlot->ColorIdx % gp.ColormapSize]; ImVec4 col = gp.Colormap[gp.CurrentPlot->ColormapIdx % gp.ColormapSize];
gp.CurrentPlot->ColorIdx++; gp.CurrentPlot->ColormapIdx++;
return col; return col;
} }

View File

@ -733,10 +733,9 @@ void ShowDemoWindow(bool* p_open) {
} }
if (ImGui::Button(paused ? "Resume" : "Pause", ImVec2(100,0))) if (ImGui::Button(paused ? "Resume" : "Pause", ImVec2(100,0)))
paused = !paused; paused = !paused;
ImGui::Separator();
for (int i = 0; i < K_CHANNELS; ++i) { for (int i = 0; i < K_CHANNELS; ++i) {
char label[8]; char label[16];
sprintf(label, show[i] ? "data_%d*" : "data_%d", i); sprintf(label, show[i] ? "data_%d (Y%d)" : "data_%d", i, yAxis[i]+1);
ImGui::Selectable(label, false, 0, ImVec2(100, 0)); ImGui::Selectable(label, false, 0, ImVec2(100, 0));
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) { if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) {
ImGui::SetDragDropPayload("DND_PLOT", &i, sizeof(int)); ImGui::SetDragDropPayload("DND_PLOT", &i, sizeof(int));
@ -809,7 +808,6 @@ void ShowDemoWindow(bool* p_open) {
ImGui::SetNextItemWidth(100); ImGui::SetNextItemWidth(100);
static float bitGap = 4; static float bitGap = 4;
ImGui::DragFloat("##Bit Gap", &bitGap, 1, 2, 20, "%.0f px"); ImGui::DragFloat("##Bit Gap", &bitGap, 1, 2, 20, "%.0f px");
ImGui::Separator();
for (int i = 0; i < K_PLOT_DIGITAL_CH_COUNT; ++i) { for (int i = 0; i < K_PLOT_DIGITAL_CH_COUNT; ++i) {
char label[32]; char label[32];
sprintf(label, "digital_%d", i); sprintf(label, "digital_%d", i);

View File

@ -22,7 +22,8 @@
// ImPlot v0.5 WIP // ImPlot v0.5 WIP
// You may use this file to debug, understand or extend ImPlot features but we don't provide any guarantee of forward compatibility! // You may use this file to debug, understand or extend ImPlot features but we
// don't provide any guarantee of forward compatibility!
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] Header mess // [SECTION] Header mess
@ -85,7 +86,7 @@ inline void ImFlipFlag(TSet& set, TFlag flag) { ImHasFlag(set, flag) ? set &= ~f
template <typename T> template <typename T>
inline T ImRemap(T x, T x0, T x1, T y0, T y1) { return y0 + (x - x0) * (y1 - y0) / (x1 - x0); } inline T ImRemap(T x, T x0, T x1, T y0, T y1) { return y0 + (x - x0) * (y1 - y0) / (x1 - x0); }
// Returns always positive modulo (r != 0) // Returns always positive modulo (assumes r != 0)
inline int ImPosMod(int l, int r) { return (l % r + r) % r; } inline int ImPosMod(int l, int r) { return (l % r + r) % r; }
// Offset calculator helper // Offset calculator helper
@ -102,11 +103,15 @@ struct ImOffsetCalculator {
// Character buffer writer helper // Character buffer writer helper
struct ImBufferWriter struct ImBufferWriter
{ {
char* const Buffer; char* Buffer;
size_t Size;
size_t Pos; size_t Pos;
const size_t Size;
ImBufferWriter(char* buffer, size_t size) : Buffer(buffer), Pos(0), Size(size) {} ImBufferWriter(char* buffer, size_t size) {
Buffer = buffer;
Size = size;
Pos = 0;
}
void Write(const char* fmt, ...) IM_FMTARGS(2) { void Write(const char* fmt, ...) IM_FMTARGS(2) {
va_list argp; va_list argp;
@ -144,16 +149,18 @@ struct ImPlotTick
// Axis state information that must persist after EndPlot // Axis state information that must persist after EndPlot
struct ImPlotAxis struct ImPlotAxis
{ {
ImPlotAxisFlags Flags;
ImPlotAxisFlags PreviousFlags;
ImPlotRange Range;
bool Dragging; bool Dragging;
bool Hovered; bool Hovered;
ImPlotRange Range;
ImPlotAxisFlags Flags, PreviousFlags;
ImPlotAxis() { ImPlotAxis() {
Dragging = false; Flags = PreviousFlags = ImPlotAxisFlags_Default;
Hovered = false;
Range.Min = 0; Range.Min = 0;
Range.Max = 1; Range.Max = 1;
Flags = PreviousFlags = ImPlotAxisFlags_Default; Dragging = false;
Hovered = false;
} }
}; };
@ -161,30 +168,28 @@ struct ImPlotAxis
struct ImPlotAxisState struct ImPlotAxisState
{ {
ImPlotAxis* Axis; ImPlotAxis* Axis;
bool HasRange;
ImGuiCond RangeCond; ImGuiCond RangeCond;
bool Present;
int PresentSoFar; int PresentSoFar;
bool HasRange;
bool Present;
bool Invert; bool Invert;
bool LockMin; bool LockMin;
bool LockMax; bool LockMax;
bool Lock; bool Lock;
ImPlotAxisState(ImPlotAxis& axis, bool has_range, ImGuiCond range_cond, bool present, int previous_present) : ImPlotAxisState(ImPlotAxis* axis, bool has_range, ImGuiCond range_cond, bool present, int previous_present) {
Axis(&axis), Axis = axis;
HasRange(has_range), HasRange = has_range;
RangeCond(range_cond), RangeCond = range_cond;
Present(present), Present = present;
PresentSoFar(previous_present + (Present ? 1 : 0)), PresentSoFar = previous_present + (Present ? 1 : 0);
Invert(ImHasFlag(Axis->Flags, ImPlotAxisFlags_Invert)), Invert = ImHasFlag(Axis->Flags, ImPlotAxisFlags_Invert);
LockMin(ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMin) || (HasRange && RangeCond == ImGuiCond_Always)), LockMin = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMin) || (HasRange && RangeCond == ImGuiCond_Always);
LockMax(ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMax) || (HasRange && RangeCond == ImGuiCond_Always)), LockMax = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMax) || (HasRange && RangeCond == ImGuiCond_Always);
Lock(!Present || ((LockMin && LockMax) || (HasRange && RangeCond == ImGuiCond_Always))) Lock = !Present || ((LockMin && LockMax) || (HasRange && RangeCond == ImGuiCond_Always));
{} }
ImPlotAxisState() : ImPlotAxisState() { }
Axis(), HasRange(), RangeCond(), Present(), PresentSoFar(),Invert(),LockMin(), LockMax(), Lock()
{}
}; };
struct ImPlotAxisColor struct ImPlotAxisColor
@ -196,20 +201,20 @@ struct ImPlotAxisColor
// State information for Plot items // State information for Plot items
struct ImPlotItem struct ImPlotItem
{ {
bool Show;
bool SeenThisFrame;
bool Highlight;
ImVec4 Color;
int NameOffset;
ImGuiID ID; ImGuiID ID;
ImVec4 Color;
bool Show;
bool Highlight;
bool SeenThisFrame;
int NameOffset;
ImPlotItem() { ImPlotItem() {
ID = 0;
Color = ImPlot::NextColormapColor();
Show = true; Show = true;
SeenThisFrame = false; SeenThisFrame = false;
Highlight = false; Highlight = false;
Color = ImPlot::NextColormapColor();
NameOffset = -1; NameOffset = -1;
ID = 0;
} }
~ImPlotItem() { ID = 0; } ~ImPlotItem() { ID = 0; }
@ -218,27 +223,27 @@ struct ImPlotItem
// Holds Plot state information that must persist after EndPlot // Holds Plot state information that must persist after EndPlot
struct ImPlotState struct ImPlotState
{ {
ImPlotFlags Flags;
ImPlotFlags PreviousFlags;
ImPlotAxis XAxis;
ImPlotAxis YAxis[MAX_Y_AXES];
ImPool<ImPlotItem> Items; ImPool<ImPlotItem> Items;
ImRect BB_Legend;
ImVec2 SelectStart; ImVec2 SelectStart;
ImVec2 QueryStart;
ImRect QueryRect;
ImRect BB_Legend;
bool Selecting; bool Selecting;
bool Querying; bool Querying;
bool Queried; bool Queried;
bool DraggingQuery; bool DraggingQuery;
ImVec2 QueryStart; int ColormapIdx;
ImRect QueryRect;
ImPlotAxis XAxis;
ImPlotAxis YAxis[MAX_Y_AXES];
ImPlotFlags Flags, PreviousFlags;
int ColorIdx;
int CurrentYAxis; int CurrentYAxis;
ImPlotState() { ImPlotState() {
Selecting = Querying = Queried = DraggingQuery = false;
SelectStart = QueryStart = ImVec2(0,0);
Flags = PreviousFlags = ImPlotFlags_Default; Flags = PreviousFlags = ImPlotFlags_Default;
ColorIdx = 0; SelectStart = QueryStart = ImVec2(0,0);
CurrentYAxis = 0; Selecting = Querying = Queried = DraggingQuery = false;
ColormapIdx = CurrentYAxis = 0;
} }
}; };
@ -345,13 +350,15 @@ struct ImPlotContext {
ImPlotPoint LastMousePos[MAX_Y_AXES]; ImPlotPoint LastMousePos[MAX_Y_AXES];
}; };
struct ImPlotAxisScale { struct ImPlotAxisScale
{
ImPlotPoint Min, Max;
ImPlotAxisScale(int y_axis, float tx, float ty, float zoom_rate) { ImPlotAxisScale(int y_axis, float tx, float ty, float zoom_rate) {
ImPlotContext& gp = *GImPlot; ImPlotContext& gp = *GImPlot;
Min = ImPlot::PixelsToPlot(gp.BB_Plot.Min - gp.BB_Plot.GetSize() * ImVec2(tx * zoom_rate, ty * zoom_rate), y_axis); Min = ImPlot::PixelsToPlot(gp.BB_Plot.Min - gp.BB_Plot.GetSize() * ImVec2(tx * zoom_rate, ty * zoom_rate), y_axis);
Max = ImPlot::PixelsToPlot(gp.BB_Plot.Max + gp.BB_Plot.GetSize() * ImVec2((1 - tx) * zoom_rate, (1 - ty) * zoom_rate), y_axis); Max = ImPlot::PixelsToPlot(gp.BB_Plot.Max + gp.BB_Plot.GetSize() * ImVec2((1 - tx) * zoom_rate, (1 - ty) * zoom_rate), y_axis);
} }
ImPlotPoint Min, Max;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -365,14 +372,17 @@ namespace ImPlot {
void Initialize(ImPlotContext* ctx); void Initialize(ImPlotContext* ctx);
// Resets an ImPlot context for the next call to BeginPlot // Resets an ImPlot context for the next call to BeginPlot
void Reset(ImPlotContext* ctx); void Reset(ImPlotContext* ctx);
// Gets a plot from the current ImPlotContext // Gets a plot from the current ImPlotContext
ImPlotState* GetPlot(const char* title); ImPlotState* GetPlot(const char* title);
// Gets the current plot from the current ImPlotContext // Gets the current plot from the current ImPlotContext
ImPlotState* GetCurrentPlot(); ImPlotState* GetCurrentPlot();
// Updates pixel space to plot space transformation variables for the current plot
// Updates plot-to-pixel space transformation variables for the current plot
void UpdateTransformCache(); void UpdateTransformCache();
// Extends the current plots axes so that it encompasses point p // Extends the current plots axes so that it encompasses point p
void FitPoint(const ImPlotPoint& p); void FitPoint(const ImPlotPoint& p);
// Register or get an existing item from the current plot // Register or get an existing item from the current plot
ImPlotItem* RegisterItem(const char* label_id); ImPlotItem* RegisterItem(const char* label_id);
// Get the ith plot item from the current plot // Get the ith plot item from the current plot
@ -381,10 +391,12 @@ ImPlotItem* GetItem(int i);
ImPlotItem* GetItem(const char* label_id); ImPlotItem* GetItem(const char* label_id);
// Gets a plot item from a specific plot // Gets a plot item from a specific plot
ImPlotItem* GetItem(const char* plot_title, const char* item_label_id); ImPlotItem* GetItem(const char* plot_title, const char* item_label_id);
// Returns the number of entries in the current legend // Returns the number of entries in the current legend
int GetLegendCount(); int GetLegendCount();
// Gets the ith entry string for the current legend // Gets the ith entry string for the current legend
const char* GetLegendLabel(int i); const char* GetLegendLabel(int i);
// Populates a list of ImPlotTicks with automatically spaced ticks // Populates a list of ImPlotTicks with automatically spaced ticks
void AddDefaultTicks(const ImPlotRange& range, int nMajor, int nMinor, bool logscale, ImVector<ImPlotTick> &out); void AddDefaultTicks(const ImPlotRange& range, int nMajor, int nMinor, bool logscale, ImVector<ImPlotTick> &out);
// Populates a list of ImPlotTicks with custom spaced and labeled ticks // Populates a list of ImPlotTicks with custom spaced and labeled ticks
@ -393,34 +405,38 @@ void AddCustomTicks(const double* values, const char** labels, int n, ImVector<
void LabelTicks(ImVector<ImPlotTick> &ticks, bool scientific, ImGuiTextBuffer& buffer); void LabelTicks(ImVector<ImPlotTick> &ticks, bool scientific, ImGuiTextBuffer& buffer);
// Calculates the maximum width of a list of ImPlotTick // Calculates the maximum width of a list of ImPlotTick
float MaxTickLabelWidth(ImVector<ImPlotTick>& ticks); float MaxTickLabelWidth(ImVector<ImPlotTick>& ticks);
// Rounds x to powers of 2,5 and 10 for generating axis labels (from Graphics Gems 1 Chapter 11.2)
double NiceNum(double x, bool round);
// Updates axis ticks, lins, and label colors // Updates axis ticks, lins, and label colors
void UpdateAxisColor(int axis_flag, ImPlotAxisColor* col); void UpdateAxisColor(int axis_flag, ImPlotAxisColor* col);
// Sets the colormap for a particular ImPlotContext // Sets the colormap for a particular ImPlotContext
void SetColormapEx(ImPlotColormap colormap, int samples, ImPlotContext* ctx); void SetColormapEx(ImPlotColormap colormap, int samples, ImPlotContext* ctx);
void SetColormapEx(const ImVec4* colors, int num_colors, ImPlotContext* ctx); void SetColormapEx(const ImVec4* colors, int num_colors, ImPlotContext* ctx);
// Draws vertical text. The position is the bottom left of the text rect. // Draws vertical text. The position is the bottom left of the text rect.
void AddTextVertical(ImDrawList *DrawList, const char *text, ImVec2 pos, ImU32 text_color); void AddTextVertical(ImDrawList *DrawList, const char *text, ImVec2 pos, ImU32 text_color);
// Calculates the size of vertical text // Calculates the size of vertical text
ImVec2 CalcTextSizeVertical(const char *text); ImVec2 CalcTextSizeVertical(const char *text);
// Returns white or black text given background color // Returns white or black text given background color
inline ImU32 CalcTextColor(const ImVec4& bg) { return (bg.x * 0.299 + bg.y * 0.587 + bg.z * 0.114) > 0.729 ? IM_COL32_BLACK : IM_COL32_WHITE; } inline ImU32 CalcTextColor(const ImVec4& bg) { return (bg.x * 0.299 + bg.y * 0.587 + bg.z * 0.114) > 0.729 ? IM_COL32_BLACK : IM_COL32_WHITE; }
// Rounds x to powers of 2,5 and 10 for generating axis labels
// Taken from Graphics Gems 1 Chapter 11.2, "Nice Numbers for Graph Labels" // Returns true if val is NAN or INFINITY
double NiceNum(double x, bool round); inline bool NanOrInf(double val) { return val == HUGE_VAL || val == -HUGE_VAL || isnan(val); }
// Turns NANs to 0s // Turns NANs to 0s
inline double ConstrainNan(double val) { return isnan(val) ? 0 : val; } inline double ConstrainNan(double val) { return isnan(val) ? 0 : val; }
// Turns infinity to floating point maximums // Turns infinity to floating point maximums
inline double ConstrainInf(double val) { return val == HUGE_VAL ? DBL_MAX : val == -HUGE_VAL ? - DBL_MAX : val; } inline double ConstrainInf(double val) { return val == HUGE_VAL ? DBL_MAX : val == -HUGE_VAL ? - DBL_MAX : val; }
// Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?) // Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?)
inline double ConstrainLog(double val) { return val <= 0 ? 0.001f : val; } inline double ConstrainLog(double val) { return val <= 0 ? 0.001f : val; }
// Returns true if val is NAN or INFINITY
inline bool NanOrInf(double val) { return val == HUGE_VAL || val == -HUGE_VAL || isnan(val); }
// Computes order of magnitude of double. // Computes order of magnitude of double.
inline int OrderOfMagnitude(double val) { return val == 0 ? 0 : (int)(floor(log10(fabs(val)))); } inline int OrderOfMagnitude(double val) { return val == 0 ? 0 : (int)(floor(log10(fabs(val)))); }
// Returns the precision required for a order of magnitude. // Returns the precision required for a order of magnitude.
inline int OrderToPrecision(int order) { return order > 0 ? 0 : 1 - order; } inline int OrderToPrecision(int order) { return order > 0 ? 0 : 1 - order; }
// Returns a floating point precision to use given a value // Returns a floating point precision to use given a value
inline int Precision(double val) { return OrderToPrecision(OrderOfMagnitude(val)); } inline int Precision(double val) { return OrderToPrecision(OrderOfMagnitude(val)); }
// Returns the intersection point of two lines A and B (assumes they are not parallel!) // Returns the intersection point of two lines A and B (assumes they are not parallel!)
inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1, const ImVec2& b2) { inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1, const ImVec2& b2) {
float v1 = (a1.x * a2.y - a1.y * a2.x); float v1 = (a1.x * a2.y - a1.y * a2.x);
@ -428,6 +444,7 @@ inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1,
float v3 = ((a1.x - a2.x) * (b1.y - b2.y) - (a1.y - a2.y) * (b1.x - b2.x)); float v3 = ((a1.x - a2.x) * (b1.y - b2.y) - (a1.y - a2.y) * (b1.x - b2.x));
return ImVec2((v1 * (b1.x - b2.x) - v2 * (a1.x - a2.x)) / v3, (v1 * (b1.y - b2.y) - v2 * (a1.y - a2.y)) / v3); return ImVec2((v1 * (b1.x - b2.x) - v2 * (a1.x - a2.x)) / v3, (v1 * (b1.y - b2.y) - v2 * (a1.y - a2.y)) / v3);
} }
// Fills a buffer with n samples linear interpolated from vmin to vmax // Fills a buffer with n samples linear interpolated from vmin to vmax
template <typename T> template <typename T>
void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) { void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
@ -437,6 +454,7 @@ void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
buffer[i] = vmin + i * step; buffer[i] = vmin + i * step;
} }
} }
// Offsets and strides a data buffer // Offsets and strides a data buffer
template <typename T> template <typename T>
inline T OffsetAndStride(const T* data, int idx, int count, int offset, int stride) { inline T OffsetAndStride(const T* data, int idx, int count, int offset, int stride) {

View File

@ -1167,8 +1167,7 @@ inline void RenderPieSlice(ImDrawList& DrawList, const ImPlotPoint& center, doub
template <typename T> template <typename T>
void PlotPieChartEx(const char** label_ids, const T* values, int count, T x, T y, T radius, bool normalize, const char* fmt, T angle0) { void PlotPieChartEx(const char** label_ids, const T* values, int count, T x, T y, T radius, bool normalize, const char* fmt, T angle0) {
ImPlotContext& gp = *GImPlot; IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != NULL, "PlotPieChart() needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotPieChart() needs to be called between BeginPlot() and EndPlot()!");
ImDrawList & DrawList = *ImGui::GetWindowDrawList(); ImDrawList & DrawList = *ImGui::GetWindowDrawList();
T sum = 0; T sum = 0;
@ -1426,8 +1425,7 @@ void PlotText(const char* text, float x, float y, bool vertical, const ImVec2& p
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// double // double
void PlotText(const char* text, double x, double y, bool vertical, const ImVec2& pixel_offset) { void PlotText(const char* text, double x, double y, bool vertical, const ImVec2& pixel_offset) {
ImPlotContext& gp = *GImPlot; IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != NULL, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
ImDrawList & DrawList = *ImGui::GetWindowDrawList(); ImDrawList & DrawList = *ImGui::GetWindowDrawList();
PushPlotClipRect(); PushPlotClipRect();
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y)) + pixel_offset; ImVec2 pos = PlotToPixels(ImPlotPoint(x,y)) + pixel_offset;