From f766614db0d566b5ea645b6f702cd644b01e42f4 Mon Sep 17 00:00:00 2001 From: ozlb Date: Tue, 12 May 2020 15:26:44 +0200 Subject: [PATCH 1/7] PlotDigital vs FitThisFrame FitThisFrame in PlotDigital it' not necessary due to actual nature of digital plot. --- implot.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/implot.cpp b/implot.cpp index 98cb7e8..de8e2ad 100644 --- a/implot.cpp +++ b/implot.cpp @@ -2563,14 +2563,6 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of if (gp.Style.Colors[ImPlotCol_Line].w != -1) item->Color = gp.Style.Colors[ImPlotCol_Line]; - // find data extents - if (gp.FitThisFrame) { - for (int i = 0; i < count; ++i) { - ImVec2 p = getter(i); - FitPoint(p); - } - } - ImGui::PushClipRect(gp.BB_Grid.Min, gp.BB_Grid.Max, true); bool cull = HasFlag(gp.CurrentPlot->Flags, ImPlotFlags_CullData); From 1ea1a2664e1dd3e1d5c344bd8bdf1862241913aa Mon Sep 17 00:00:00 2001 From: ozlb Date: Wed, 13 May 2020 06:45:34 +0200 Subject: [PATCH 2/7] C++11 extension fixes warning: range-based for loop is a C++11 extension [-Wc++11-extensions] for (ImTick &xt : gp.XTicks) { for (ImTick &yt : gp.YTicks[i]) { --- implot.cpp | 168 ++++++++++++++++++++++++++---------------------- implot_demo.cpp | 75 +++++++++++---------- 2 files changed, 133 insertions(+), 110 deletions(-) diff --git a/implot.cpp b/implot.cpp index de8e2ad..43f55d8 100644 --- a/implot.cpp +++ b/implot.cpp @@ -314,7 +314,7 @@ struct ImPlotState { }; struct ImNextPlotData { - ImNextPlotData() : HasXRange{}, HasYRange{} {} + //ImNextPlotData() : HasXRange{}, HasYRange{} {} ImGuiCond XRangeCond; ImGuiCond YRangeCond[MAX_Y_AXES]; bool HasXRange; @@ -349,7 +349,8 @@ struct ImPlotContext { ImU32 Col_Frame, Col_Bg, Col_Border, Col_Txt, Col_TxtDis, Col_SlctBg, Col_SlctBd, - Col_QryBg, Col_QryBd; + Col_QryBg, Col_QryBd, + Col_QryX; struct AxisColor { AxisColor() : Major(), Minor(), Txt() {} ImU32 Major, Minor, Txt; @@ -374,7 +375,7 @@ struct ImPlotContext { ImPlotRange ExtentsY[MAX_Y_AXES]; bool FitThisFrame; bool FitX; - bool FitY[MAX_Y_AXES] = {}; + bool FitY[MAX_Y_AXES]; int VisibleItemCount; // Render flags bool RenderX, RenderY[MAX_Y_AXES]; @@ -487,8 +488,8 @@ struct Plt2PixLinLin { ImVec2 operator()(const ImVec2& plt) { return (*this)(plt.x, plt.y); } ImVec2 operator()(float x, float y) { - return { gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), - gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) }; + return ImVec2( gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), + gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) ); } int y_axis; @@ -501,8 +502,8 @@ struct Plt2PixLogLin { ImVec2 operator()(float x, float y) { float t = log10(x / gp.CurrentPlot->XAxis.Range.Min) / gp.LogDenX; x = ImLerp(gp.CurrentPlot->XAxis.Range.Min, gp.CurrentPlot->XAxis.Range.Max, t); - return { gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), - gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) }; + return ImVec2( gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), + gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) ); } int y_axis; @@ -515,8 +516,8 @@ struct Plt2PixLinLog { ImVec2 operator()(float x, float y) { float t = log10(y / gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.LogDenY[y_axis]; y = ImLerp(gp.CurrentPlot->YAxis[y_axis].Range.Min, gp.CurrentPlot->YAxis[y_axis].Range.Max, t); - return { gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), - gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) }; + return ImVec2( gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), + gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) ); } int y_axis; @@ -531,8 +532,8 @@ struct Plt2PixLogLog { x = ImLerp(gp.CurrentPlot->XAxis.Range.Min, gp.CurrentPlot->XAxis.Range.Max, t); t = log10(y / gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.LogDenY[y_axis]; y = ImLerp(gp.CurrentPlot->YAxis[y_axis].Range.Min, gp.CurrentPlot->YAxis[y_axis].Range.Max, t); - return { gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), - gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) }; + return ImVec2( gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min), + gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min) ); } int y_axis; @@ -613,15 +614,16 @@ inline void GetTicks(const ImPlotRange& scale, int nMajor, int nMinor, bool logs inline void LabelTicks(ImVector &ticks, bool scientific, ImGuiTextBuffer& buffer) { buffer.Buf.resize(0); char temp[32]; - for (ImTick &tk : ticks) { - if (tk.RenderLabel) { - tk.TextOffset = buffer.size(); + for (int t = 0; t < ticks.Size; t++) { + ImTick *tk = &ticks[t]; + if (tk->RenderLabel) { + tk->TextOffset = buffer.size(); if (scientific) - sprintf(temp, "%.0e", tk.PlotPos); + sprintf(temp, "%.0e", tk->PlotPos); else - sprintf(temp, "%g", tk.PlotPos); + sprintf(temp, "%g", tk->PlotPos); buffer.append(temp, temp + strlen(temp) + 1); - tk.Size = ImGui::CalcTextSize(buffer.Buf.Data + tk.TextOffset); + tk->Size = ImGui::CalcTextSize(buffer.Buf.Data + tk->TextOffset); } } } @@ -666,7 +668,7 @@ void UpdateAxisColor(int axis_flag, ImPlotContext::AxisColor* col) { const ImVec4 col_Axis = gp.Style.Colors[axis_flag].w == -1 ? ImGui::GetStyle().Colors[ImGuiCol_Text] * ImVec4(1, 1, 1, 0.25f) : gp.Style.Colors[axis_flag]; col->Major = ImGui::GetColorU32(col_Axis); col->Minor = ImGui::GetColorU32(col_Axis * ImVec4(1, 1, 1, 0.25f)); - col->Txt = ImGui::GetColorU32({col_Axis.x, col_Axis.y, col_Axis.z, 1}); + col->Txt = ImGui::GetColorU32(ImVec4(col_Axis.x, col_Axis.y, col_Axis.z, 1)); } ImRect GetAxisScale(int y_axis, float tx, float ty, float zoom_rate) { @@ -900,8 +902,9 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons for (int i = 0; i < MAX_Y_AXES; i++) { if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickLabels)) { LabelTicks(gp.YTicks[i], HasFlag(plot.YAxis[i].Flags, ImAxisFlags_Scientific), gp.YTickLabels[i]); - for (ImTick &yt : gp.YTicks[i]) { - max_label_width[i] = yt.Size.x > max_label_width[i] ? yt.Size.x : max_label_width[i]; + for (int t = 0; t < gp.YTicks[i].Size; t++) { + ImTick *yt = &gp.YTicks[i][t]; + max_label_width[i] = yt->Size.x > max_label_width[i] ? yt->Size.x : max_label_width[i]; } } } @@ -935,15 +938,15 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons (gp.AxisLabelReference[1] + y_axis_pad(1) + 6); ImRect yAxisRegion_bb[MAX_Y_AXES]; - yAxisRegion_bb[0] = ImRect({gp.BB_Frame.Min.x, gp.BB_Grid.Min.y}, {gp.BB_Grid.Min.x + 6, gp.BB_Grid.Max.y - 10}); + yAxisRegion_bb[0] = ImRect(ImVec2(gp.BB_Frame.Min.x, gp.BB_Grid.Min.y), ImVec2(gp.BB_Grid.Min.x + 6, gp.BB_Grid.Max.y - 10)); // The auxiliary y axes are off to the right of the BB grid. - yAxisRegion_bb[1] = ImRect({gp.BB_Grid.Max.x - 6, gp.BB_Grid.Min.y}, + yAxisRegion_bb[1] = ImRect(ImVec2(gp.BB_Grid.Max.x - 6, gp.BB_Grid.Min.y), gp.BB_Grid.Max + ImVec2(y_axis_pad(1), 0)); - yAxisRegion_bb[2] = ImRect({gp.AxisLabelReference[2] - 6, gp.BB_Grid.Min.y}, + yAxisRegion_bb[2] = ImRect(ImVec2(gp.AxisLabelReference[2] - 6, gp.BB_Grid.Min.y), yAxisRegion_bb[1].Max + ImVec2(y_axis_pad(2), 0)); - ImRect centralRegion({gp.BB_Grid.Min.x + 6, gp.BB_Grid.Min.y}, - {gp.BB_Grid.Max.x - 6, gp.BB_Grid.Max.y}); + ImRect centralRegion(ImVec2(gp.BB_Grid.Min.x + 6, gp.BB_Grid.Min.y), + ImVec2(gp.BB_Grid.Max.x - 6, gp.BB_Grid.Max.y)); const bool hov_y_axis_region[MAX_Y_AXES] = { y[0].present && (yAxisRegion_bb[0].Contains(IO.MousePos) || centralRegion.Contains(IO.MousePos)), @@ -1208,26 +1211,34 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // transform ticks if (gp.RenderX) { - for (ImTick& xt : gp.XTicks) - xt.PixelPos = PlotToPixels((float)xt.PlotPos, 0, 0).x; + for (int t = 0; t < gp.XTicks.Size; t++) { + ImTick *xt = &gp.XTicks[t]; + xt->PixelPos = PlotToPixels((float)xt->PlotPos, 0, 0).x; + } } for (int i = 0; i < MAX_Y_AXES; i++) { if (gp.RenderY[i]) { - for (ImTick& yt : gp.YTicks[i]) - yt.PixelPos = PlotToPixels(0, (float)yt.PlotPos, i).y; + for (int t = 0; t < gp.YTicks[i].Size; t++) { + ImTick *yt = &gp.YTicks[i][t]; + yt->PixelPos = PlotToPixels(0, (float)yt->PlotPos, i).y; + } } } // render grid if (HasFlag(plot.XAxis.Flags, ImAxisFlags_GridLines)) { - for (ImTick &xt : gp.XTicks) - DrawList.AddLine({xt.PixelPos, gp.BB_Grid.Min.y}, {xt.PixelPos, gp.BB_Grid.Max.y}, xt.Major ? gp.Col_X.Major : gp.Col_X.Minor, 1); + for (int t = 0; t < gp.XTicks.Size; t++) { + ImTick *xt = &gp.XTicks[t]; + DrawList.AddLine(ImVec2(xt->PixelPos, gp.BB_Grid.Min.y), ImVec2(xt->PixelPos, gp.BB_Grid.Max.y), xt->Major ? gp.Col_X.Major : gp.Col_X.Minor, 1); + } } for (int i = 0; i < MAX_Y_AXES; i++) { if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImAxisFlags_GridLines)) { - for (ImTick &yt : gp.YTicks[i]) - DrawList.AddLine({gp.BB_Grid.Min.x, yt.PixelPos}, {gp.BB_Grid.Max.x, yt.PixelPos}, yt.Major ? gp.Col_Y[i].Major : gp.Col_Y[i].Minor, 1); + for (int t = 0; t < gp.YTicks[i].Size; t++) { + ImTick *yt = &gp.YTicks[i][t]; + DrawList.AddLine(ImVec2(gp.BB_Grid.Min.x, yt->PixelPos), ImVec2(gp.BB_Grid.Max.x, yt->PixelPos), yt->Major ? gp.Col_Y[i].Major : gp.Col_Y[i].Minor, 1); + } } } @@ -1241,9 +1252,10 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // render labels if (HasFlag(plot.XAxis.Flags, ImAxisFlags_TickLabels)) { ImGui::PushClipRect(gp.BB_Frame.Min, gp.BB_Frame.Max, true); - for (ImTick &xt : gp.XTicks) { - if (xt.RenderLabel && xt.PixelPos >= gp.BB_Grid.Min.x - 1 && xt.PixelPos <= gp.BB_Grid.Max.x + 1) - DrawList.AddText({xt.PixelPos - xt.Size.x * 0.5f, gp.BB_Grid.Max.y + txt_off}, gp.Col_X.Txt, gp.XTickLabels.Buf.Data + xt.TextOffset); + for (int t = 0; t < gp.XTicks.Size; t++) { + ImTick *xt = &gp.XTicks[t]; + if (xt->RenderLabel && xt->PixelPos >= gp.BB_Grid.Min.x - 1 && xt->PixelPos <= gp.BB_Grid.Max.x + 1) + DrawList.AddText(ImVec2(xt->PixelPos - xt->Size.x * 0.5f, gp.BB_Grid.Max.y + txt_off), gp.Col_X.Txt, gp.XTickLabels.Buf.Data + xt->TextOffset); } ImGui::PopClipRect(); } @@ -1261,10 +1273,11 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons ((i == 0) ? (-txt_off - max_label_width[0]) : txt_off); - for (ImTick &yt : gp.YTicks[i]) { - if (yt.RenderLabel && yt.PixelPos >= gp.BB_Grid.Min.y - 1 && yt.PixelPos <= gp.BB_Grid.Max.y + 1) { - ImVec2 start(x_start, yt.PixelPos - 0.5f * yt.Size.y); - DrawList.AddText(start, gp.Col_Y[i].Txt, gp.YTickLabels[i].Buf.Data + yt.TextOffset); + for (int t = 0; t < gp.YTicks[i].Size; t++) { + ImTick *yt = &gp.YTicks[i][t]; + if (yt->RenderLabel && yt->PixelPos >= gp.BB_Grid.Min.y - 1 && yt->PixelPos <= gp.BB_Grid.Max.y + 1) { + ImVec2 start(x_start, yt->PixelPos - 0.5f * yt->Size.y); + DrawList.AddText(start, gp.Col_Y[i].Txt, gp.YTickLabels[i].Buf.Data + yt->TextOffset); } } } @@ -1470,12 +1483,14 @@ void EndPlot() { // render ticks PushPlotClipRect(); if (HasFlag(plot.XAxis.Flags, ImAxisFlags_TickMarks)) { - for (ImTick &xt : gp.XTicks) - DrawList.AddLine({xt.PixelPos, gp.BB_Grid.Max.y},{xt.PixelPos, gp.BB_Grid.Max.y - (xt.Major ? 10.0f : 5.0f)}, gp.Col_Border, 1); + for (int t = 0; t < gp.XTicks.Size; t++) { + ImTick *xt = &gp.XTicks[t]; + DrawList.AddLine(ImVec2(xt->PixelPos, gp.BB_Grid.Max.y),ImVec2(xt->PixelPos, gp.BB_Grid.Max.y - (xt->Major ? 10.0f : 5.0f)), gp.Col_Border, 1); + } } PopPlotClipRect(); - ImGui::PushClipRect(gp.BB_Grid.Min, {gp.BB_Frame.Max.x, gp.BB_Grid.Max.y}, true); + ImGui::PushClipRect(gp.BB_Grid.Min, ImVec2(gp.BB_Frame.Max.x, gp.BB_Grid.Max.y), true); int axis_count = 0; for (int i = 0; i < MAX_Y_AXES; i++) { if (!y[i].present) { continue; } @@ -1487,12 +1502,13 @@ void EndPlot() { float direction = (i == 0) ? 1.0f : -1.0f; bool no_major = axis_count >= 3; - for (ImTick &yt : gp.YTicks[i]) { - ImVec2 start = ImVec2(x_start, yt.PixelPos); + for (int t = 0; t < gp.YTicks[i].Size; t++) { + ImTick *yt = &gp.YTicks[i][t]; + ImVec2 start = ImVec2(x_start, yt->PixelPos); DrawList.AddLine( start, - start + ImVec2(direction * ((!no_major && yt.Major) ? 10.0f : 5.0f), 0), + start + ImVec2(direction * ((!no_major && yt->Major) ? 10.0f : 5.0f), 0), gp.Col_Border, 1); } @@ -1831,16 +1847,16 @@ void SetPalette(const ImVec4* colors, int num_colors) { /// Returns the next unused default plot color void RestorePalette() { static ImVec4 default_colors[10] = { - {(0.0F), (0.7490196228F), (1.0F), (1.0F)}, // Blues::DeepSkyBlue, - {(1.0F), (0.0F), (0.0F), (1.0F)}, // Reds::Red, - {(0.4980392158F), (1.0F), (0.0F), (1.0F)}, // Greens::Chartreuse, - {(1.0F), (1.0F), (0.0F), (1.0F)}, // Yellows::Yellow, - {(0.0F), (1.0F), (1.0F), (1.0F)}, // Cyans::Cyan, - {(1.0F), (0.6470588446F), (0.0F), (1.0F)}, // Oranges::Orange, - {(1.0F), (0.0F), (1.0F), (1.0F)}, // Purples::Magenta, - {(0.5411764979F), (0.1686274558F), (0.8862745166F), (1.0F)}, // Purples::BlueViolet, - {(0.5f), (0.5f), (0.5f), (1.0F)}, // Grays::Gray50, - {(0.8235294223F), (0.7058823705F), (0.5490196347F), (1.0F)} // Browns::Tan + ImVec4((0.0F), (0.7490196228F), (1.0F), (1.0F)), // Blues::DeepSkyBlue, + ImVec4((1.0F), (0.0F), (0.0F), (1.0F)), // Reds::Red, + ImVec4((0.4980392158F), (1.0F), (0.0F), (1.0F)), // Greens::Chartreuse, + ImVec4((1.0F), (1.0F), (0.0F), (1.0F)), // Yellows::Yellow, + ImVec4((0.0F), (1.0F), (1.0F), (1.0F)), // Cyans::Cyan, + ImVec4((1.0F), (0.6470588446F), (0.0F), (1.0F)), // Oranges::Orange, + ImVec4((1.0F), (0.0F), (1.0F), (1.0F)), // Purples::Magenta, + ImVec4((0.5411764979F), (0.1686274558F), (0.8862745166F), (1.0F)), // Purples::BlueViolet, + ImVec4((0.5f), (0.5f), (0.5f), (1.0F)), // Grays::Gray50, + ImVec4((0.8235294223F), (0.7058823705F), (0.5490196347F), (1.0F)) // Browns::Tan }; SetPalette(default_colors, 10); } @@ -1944,51 +1960,51 @@ inline void MarkerGeneral(ImDrawList& DrawList, ImVec2* points, int n, const ImV } inline void MarkerCircle(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[10] = {{1.0f, 0.0f}, - {0.809017f, 0.58778524f}, - {0.30901697f, 0.95105654f}, - {-0.30901703f, 0.9510565f}, - {-0.80901706f, 0.5877852f}, - {-1.0f, 0.0f}, - {-0.80901694f, -0.58778536f}, - {-0.3090171f, -0.9510565f}, - {0.30901712f, -0.9510565f}, - {0.80901694f, -0.5877853f}}; + ImVec2 marker[10] = {ImVec2(1.0f, 0.0f), + ImVec2(0.809017f, 0.58778524f), + ImVec2(0.30901697f, 0.95105654f), + ImVec2(-0.30901703f, 0.9510565f), + ImVec2(-0.80901706f, 0.5877852f), + ImVec2(-1.0f, 0.0f), + ImVec2(-0.80901694f, -0.58778536f), + ImVec2(-0.3090171f, -0.9510565f), + ImVec2(0.30901712f, -0.9510565f), + ImVec2(0.80901694f, -0.5877853f)}; MarkerGeneral(DrawList, marker, 10, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerDiamond(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[4] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; + ImVec2 marker[4] = {ImVec2(1, 0), ImVec2(0, -1), ImVec2(-1, 0), ImVec2(0, 1)}; MarkerGeneral(DrawList, marker, 4, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerSquare(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[4] = {{SQRT_1_2,SQRT_1_2},{SQRT_1_2,-SQRT_1_2},{-SQRT_1_2,-SQRT_1_2},{-SQRT_1_2,SQRT_1_2}}; + ImVec2 marker[4] = {ImVec2(SQRT_1_2,SQRT_1_2),ImVec2(SQRT_1_2,-SQRT_1_2),ImVec2(-SQRT_1_2,-SQRT_1_2),ImVec2(-SQRT_1_2,SQRT_1_2)}; MarkerGeneral(DrawList, marker, 4, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerUp(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[3] = {{SQRT_3_2,0.5f},{0,-1},{-SQRT_3_2,0.5f}}; + ImVec2 marker[3] = {ImVec2(SQRT_3_2,0.5f),ImVec2(0,-1),ImVec2(-SQRT_3_2,0.5f)}; MarkerGeneral(DrawList, marker, 3, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerDown(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[3] = {{SQRT_3_2,-0.5f},{0,1},{-SQRT_3_2,-0.5f}}; + ImVec2 marker[3] = {ImVec2(SQRT_3_2,-0.5f),ImVec2(0,1),ImVec2(-SQRT_3_2,-0.5f)}; MarkerGeneral(DrawList, marker, 3, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerLeft(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[3] = {{-1,0}, {0.5, SQRT_3_2}, {0.5, -SQRT_3_2}}; + ImVec2 marker[3] = {ImVec2(-1,0), ImVec2(0.5, SQRT_3_2), ImVec2(0.5, -SQRT_3_2)}; MarkerGeneral(DrawList, marker, 3, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerRight(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[3] = {{1,0}, {-0.5, SQRT_3_2}, {-0.5, -SQRT_3_2}}; + ImVec2 marker[3] = {ImVec2(1,0), ImVec2(-0.5, SQRT_3_2), ImVec2(-0.5, -SQRT_3_2)}; MarkerGeneral(DrawList, marker, 3, c, s, outline, col_outline, fill, col_fill, weight); } inline void MarkerAsterisk(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[6] = {{SQRT_3_2, 0.5f}, {0, -1}, {-SQRT_3_2, 0.5f}, {SQRT_3_2, -0.5f}, {0, 1}, {-SQRT_3_2, -0.5f}}; + ImVec2 marker[6] = {ImVec2(SQRT_3_2, 0.5f), ImVec2(0, -1), ImVec2(-SQRT_3_2, 0.5f), ImVec2(SQRT_3_2, -0.5f), ImVec2(0, 1), ImVec2(-SQRT_3_2, -0.5f)}; TransformMarker(marker, 6, c, s); DrawList.AddLine(marker[0], marker[5], col_outline, weight); DrawList.AddLine(marker[1], marker[4], col_outline, weight); @@ -1996,14 +2012,14 @@ inline void MarkerAsterisk(ImDrawList& DrawList, const ImVec2& c, float s, bool } inline void MarkerPlus(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[4] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; + ImVec2 marker[4] = {ImVec2(1, 0), ImVec2(0, -1), ImVec2(-1, 0), ImVec2(0, 1)}; TransformMarker(marker, 4, c, s); DrawList.AddLine(marker[0], marker[2], col_outline, weight); DrawList.AddLine(marker[1], marker[3], col_outline, weight); } inline void MarkerCross(ImDrawList& DrawList, const ImVec2& c, float s, bool outline, ImU32 col_outline, bool fill, ImU32 col_fill, float weight) { - ImVec2 marker[4] = {{SQRT_1_2,SQRT_1_2},{SQRT_1_2,-SQRT_1_2},{-SQRT_1_2,-SQRT_1_2},{-SQRT_1_2,SQRT_1_2}}; + ImVec2 marker[4] = {ImVec2(SQRT_1_2,SQRT_1_2),ImVec2(SQRT_1_2,-SQRT_1_2),ImVec2(-SQRT_1_2,-SQRT_1_2),ImVec2(-SQRT_1_2,SQRT_1_2)}; TransformMarker(marker, 4, c, s); DrawList.AddLine(marker[0], marker[2], col_outline, weight); DrawList.AddLine(marker[1], marker[3], col_outline, weight); @@ -2539,7 +2555,7 @@ void Text(const char* text, float x, float y, bool vertical, const ImVec2& pixel IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Text() Needs to be called between BeginPlot() and EndPlot()!"); ImDrawList & DrawList = *ImGui::GetWindowDrawList(); PushPlotClipRect(); - ImVec2 pos = PlotToPixels({x,y}) + pixel_offset; + ImVec2 pos = PlotToPixels(ImVec2(x,y)) + pixel_offset; if (vertical) AddTextVertical(&DrawList, text, pos, gp.Col_Txt); else diff --git a/implot_demo.cpp b/implot_demo.cpp index 62d3504..81221bc 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -30,7 +30,7 @@ #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #endif -#include +#include "implot.h" #include #include #include @@ -43,10 +43,14 @@ float RandomRange( float min, float max ) { } struct ScrollingData { - int MaxSize = 1000; - int Offset = 0; + int MaxSize; + int Offset; ImVector Data; - ScrollingData() { Data.reserve(MaxSize); } + ScrollingData() { + MaxSize = 1000; + Offset = 0; + Data.reserve(MaxSize); + } void AddPoint(float x, float y) { if (Data.size() < MaxSize) Data.push_back(ImVec2(x,y)); @@ -64,9 +68,12 @@ struct ScrollingData { }; struct RollingData { - float Span = 10.0f; + float Span; ImVector Data; - RollingData() { Data.reserve(1000); } + RollingData() { + Span = 10.0f; + Data.reserve(1000); + } void AddPoint(float x, float y) { float xmod = fmodf(x, Span); if (!Data.empty() && xmod < Data.back().x) @@ -147,7 +154,7 @@ void ShowDemoWindow(bool* p_open) { xs2[i] = i * 0.1f; ys2[i] = xs2[i] * xs2[i]; } - if (ImPlot::BeginPlot("Line Plot", "x", "f(x)", {-1,300})) { + if (ImPlot::BeginPlot("Line Plot", "x", "f(x)", ImVec2(-1,300))) { ImPlot::Plot("sin(50*x)", xs1, ys1, 1001); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); ImPlot::Plot("x^2", xs2, ys2, 11); @@ -168,14 +175,14 @@ void ShowDemoWindow(bool* p_open) { xs2[i] = 0.25f + 0.2f * ((float)rand() / (float)RAND_MAX); ys2[i] = 0.75f + 0.2f * ((float)rand() / (float)RAND_MAX); } - if (ImPlot::BeginPlot("Scatter Plot", NULL, NULL, {-1,300})) { + if (ImPlot::BeginPlot("Scatter Plot", NULL, NULL, ImVec2(-1,300))) { ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3); ImPlot::Plot("Data 1", xs1, ys1, 100); ImPlot::PopStyleVar(2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); - ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4{1,0,0,0.25f}); + ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(1,0,0,0.25f)); ImPlot::Plot("Data 2", xs2, ys2, 50); ImPlot::PopStyleColor(); ImPlot::PopStyleVar(2); @@ -190,7 +197,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::SetNextPlotLimits(0, 110, -0.5f, 9.5f, ImGuiCond_Always); else ImPlot::SetNextPlotLimits(-0.5f, 9.5f, 0, 110, ImGuiCond_Always); - if (ImPlot::BeginPlot("Bar Plot", horz ? "Score": "Student", horz ? "Student" : "Score", {-1, 300})) { + if (ImPlot::BeginPlot("Bar Plot", horz ? "Score": "Student", horz ? "Student" : "Score", ImVec2(-1, 300))) { static float midtm[10] = {83, 67, 23, 89, 83, 78, 91, 82, 85, 90}; static float final[10] = {80, 62, 56, 99, 55, 78, 88, 78, 90, 100}; static float grade[10] = {80, 69, 52, 92, 72, 78, 75, 76, 89, 95}; @@ -246,11 +253,11 @@ void ShowDemoWindow(bool* p_open) { ImGui::SameLine(); static ImVec4 YlOrRd[5] = { - {1.0000f, 1.0000f, 0.8000f, 1.0f}, - {0.9961f, 0.8510f, 0.4627f, 1.0f}, - {0.9961f, 0.6314f, 0.2627f, 1.0f}, - {0.9882f, 0.3059f, 0.1647f, 1.0f}, - {0.7412f, 0.0f, 0.1490f, 1.0f}, + ImVec4(1.0000f, 1.0000f, 0.8000f, 1.0f), + ImVec4(0.9961f, 0.8510f, 0.4627f, 1.0f), + ImVec4(0.9961f, 0.6314f, 0.2627f, 1.0f), + ImVec4(0.9882f, 0.3059f, 0.1647f, 1.0f), + ImVec4(0.7412f, 0.0f, 0.1490f, 1.0f), }; ImPlot::SetPalette(YlOrRd, 5); SetNextPlotLimits(0,1,0,1,ImGuiCond_Always); @@ -280,13 +287,13 @@ void ShowDemoWindow(bool* p_open) { } ImPlot::SetNextPlotLimitsX(t - 10, t, paused ? ImGuiCond_Once : ImGuiCond_Always); static int rt_axis = ImAxisFlags_Default & ~ImAxisFlags_TickLabels; - if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, {-1,150}, ImPlotFlags_Default, rt_axis, rt_axis)) { + if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1,150), ImPlotFlags_Default, rt_axis, rt_axis)) { ImPlot::Plot("Data 1", &sdata1.Data[0].x, &sdata1.Data[0].y, sdata1.Data.size(), sdata1.Offset, 2 * sizeof(float)); ImPlot::Plot("Data 2", &sdata2.Data[0].x, &sdata2.Data[0].y, sdata2.Data.size(), sdata2.Offset, 2 * sizeof(float)); ImPlot::EndPlot(); } ImPlot::SetNextPlotLimitsX(0, 10, ImGuiCond_Always); - if (ImPlot::BeginPlot("##Rolling", NULL, NULL, {-1,150}, ImPlotFlags_Default, rt_axis, rt_axis)) { + if (ImPlot::BeginPlot("##Rolling", NULL, NULL, ImVec2(-1,150), ImPlotFlags_Default, rt_axis, rt_axis)) { ImPlot::Plot("Data 1", &rdata1.Data[0].x, &rdata1.Data[0].y, rdata1.Data.size(), 0, 2 * sizeof(float)); ImPlot::Plot("Data 2", &rdata2.Data[0].x, &rdata2.Data[0].y, rdata2.Data.size(), 0, 2 * sizeof(float)); ImPlot::EndPlot(); @@ -536,20 +543,20 @@ void ShowDemoWindow(bool* p_open) { } ImGui::BulletText("Drag data items from the left column onto the plot."); ImGui::BeginGroup(); - if (ImGui::Button("Clear", {100, 0})) { + if (ImGui::Button("Clear", ImVec2(100, 0))) { for (int i = 0; i < 10; ++i) { show[i] = false; data[i].Data.shrink(0); data[i].Offset = 0; } } - if (ImGui::Button(paused ? "Resume" : "Pause", {100,0})) + if (ImGui::Button(paused ? "Resume" : "Pause", ImVec2(100,0))) paused = !paused; ImGui::Separator(); for (int i = 0; i < 10; ++i) { char label[8]; sprintf(label, "data_%d", i); - ImGui::Selectable(label, false, 0, {100, 0}); + ImGui::Selectable(label, false, 0, ImVec2(100, 0)); if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) { ImGui::SetDragDropPayload("DND_PLOT", &i, sizeof(int)); ImGui::TextUnformatted(label); @@ -603,13 +610,13 @@ void ShowDemoWindow(bool* p_open) { ImGui::Text("you can drag analog signals over the rising/falling digital edge."); ImGui::Unindent(); ImGui::BeginGroup(); - if (ImGui::Button("Clear", {100, 0})) { + if (ImGui::Button("Clear", ImVec2(100, 0))) { for (int i = 0; i < K_PLOT_DIGITAL_CH_COUNT; ++i) showDigital[i] = false; for (int i = 0; i < K_PLOT_ANALOG_CH_COUNT; ++i) showAnalog[i] = false; } - if (ImGui::Button(paused ? "Resume" : "Pause", {100,0})) + if (ImGui::Button(paused ? "Resume" : "Pause", ImVec2(100,0))) paused = !paused; ImGui::SetNextItemWidth(100); static float bitHeight = 8; @@ -708,19 +715,19 @@ void ShowDemoWindow(bool* p_open) { //------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Custom Styles")) { static ImVec4 my_palette[3] = { - {0.000f, 0.980f, 0.604f, 1.0f}, - {0.996f, 0.278f, 0.380f, 1.0f}, - {(0.1176470593F), (0.5647059083F), (1.0F), (1.0F)}, + ImVec4(0.000f, 0.980f, 0.604f, 1.0f), + ImVec4(0.996f, 0.278f, 0.380f, 1.0f), + ImVec4(0.1176470593f, 0.5647059083f, 1.0f, 1.0f), }; ImPlot::SetPalette(my_palette, 3); ImPlot::PushStyleColor(ImPlotCol_FrameBg, IM_COL32(32,51,77,255)); - ImPlot::PushStyleColor(ImPlotCol_PlotBg, {0,0,0,0}); - ImPlot::PushStyleColor(ImPlotCol_PlotBorder, {0,0,0,0}); + ImPlot::PushStyleColor(ImPlotCol_PlotBg, ImVec4(0,0,0,0)); + ImPlot::PushStyleColor(ImPlotCol_PlotBorder, ImVec4(0,0,0,0)); ImPlot::PushStyleColor(ImPlotCol_XAxis, IM_COL32(192, 192, 192, 192)); ImPlot::PushStyleColor(ImPlotCol_YAxis, IM_COL32(192, 192, 192, 192)); ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2); ImPlot::SetNextPlotLimits(-0.5f, 9.5f, -0.5f, 9.5f); - if (ImPlot::BeginPlot("##Custom", NULL, NULL, {-1,300}, ImPlotFlags_Default & ~ImPlotFlags_Legend, 0)) { + if (ImPlot::BeginPlot("##Custom", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default & ~ImPlotFlags_Legend, 0)) { float lin[10] = {8,8,9,7,8,8,8,9,7,8}; float bar[10] = {1,2,5,3,4,1,2,5,3,4}; float dot[10] = {7,6,6,7,8,5,6,5,8,7}; @@ -738,10 +745,10 @@ void ShowDemoWindow(bool* p_open) { } //------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Custom Rendering")) { - if (ImPlot::BeginPlot("##CustomRend",NULL,NULL,{-1,300})) { - ImVec2 cntr = ImPlot::PlotToPixels({0.5f, 0.5f}); - ImVec2 rmin = ImPlot::PlotToPixels({0.25f, 0.75f}); - ImVec2 rmax = ImPlot::PlotToPixels({0.75f, 0.25f}); + if (ImPlot::BeginPlot("##CustomRend",NULL,NULL,ImVec2(-1,300))) { + ImVec2 cntr = ImPlot::PlotToPixels(ImVec2(0.5f, 0.5f)); + ImVec2 rmin = ImPlot::PlotToPixels(ImVec2(0.25f, 0.75f)); + ImVec2 rmax = ImPlot::PlotToPixels(ImVec2(0.75f, 0.25f)); ImPlot::PushPlotClipRect(); ImGui::GetWindowDrawList()->AddCircleFilled(cntr,20,IM_COL32(255,255,0,255),20); ImGui::GetWindowDrawList()->AddRect(rmin, rmax, IM_COL32(128,0,255,255)); @@ -756,7 +763,7 @@ void ShowDemoWindow(bool* p_open) { ImGui::BulletText("Make sure VSync is disabled."); ImGui::BulletText("%d lines with %d points each @ %.3f FPS.",n_items,1000,ImGui::GetIO().Framerate); SetNextPlotLimits(0,1,0,1, ImGuiCond_Always); - if (ImPlot::BeginPlot("##Bench",NULL,NULL,{-1,300},ImPlotFlags_Default | ImPlotFlags_NoChild)) { + if (ImPlot::BeginPlot("##Bench",NULL,NULL,ImVec2(-1,300),ImPlotFlags_Default | ImPlotFlags_NoChild)) { char buff[16]; for (int i = 0; i < 100; ++i) { sprintf(buff, "item_%d",i); @@ -771,4 +778,4 @@ void ShowDemoWindow(bool* p_open) { ImGui::End(); } -} // namespace ImPlot +} // namespace ImGui From d0e3f80506877a7d86025189220b85a15aba9f11 Mon Sep 17 00:00:00 2001 From: ozlb Date: Wed, 13 May 2020 06:48:48 +0200 Subject: [PATCH 3/7] Col_QryX unused --- implot.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/implot.cpp b/implot.cpp index 43f55d8..29ed1c7 100644 --- a/implot.cpp +++ b/implot.cpp @@ -349,8 +349,7 @@ struct ImPlotContext { ImU32 Col_Frame, Col_Bg, Col_Border, Col_Txt, Col_TxtDis, Col_SlctBg, Col_SlctBd, - Col_QryBg, Col_QryBd, - Col_QryX; + Col_QryBg, Col_QryBd; struct AxisColor { AxisColor() : Major(), Minor(), Txt() {} ImU32 Major, Minor, Txt; From 280cbf5cd470d57d24c4193ac53239188ba60016 Mon Sep 17 00:00:00 2001 From: ozlb Date: Wed, 13 May 2020 06:57:27 +0200 Subject: [PATCH 4/7] Removed all C++11 extensions src/implot.cpp:1270:25: warning: range-based for loop is a C++11 extension [-Wc++11-extensions] for (ImTick& xt : gp.XTicks) --- implot.cpp | 176 ++++++++++++++++++++++++------------------------ implot.h | 20 +++--- implot_demo.cpp | 84 +++++++++++------------ 3 files changed, 140 insertions(+), 140 deletions(-) diff --git a/implot.cpp b/implot.cpp index 29ed1c7..929b6a5 100644 --- a/implot.cpp +++ b/implot.cpp @@ -33,14 +33,14 @@ You can read releases logs https://github.com/epezent/implot/releases for more d - 2020/05/11 (0.2) - ImPlotFlags_Selection was changed to ImPlotFlags_BoxSelect - 2020/05/11 (0.2) - The namespace ImGui:: was replaced with ImPlot::. As a result, the following additional changes were made: - - Functions that were prefixed or decorated with the word "Plot" have been truncated. E.g., `ImGui::PlotBar` is now just `ImPlot::Bar`. + - Functions that were prefixed or decorated with the word "Plot" have been truncated. E.g., `ImGui::PlotBar` is now just `ImPlot::Bar`. It should be fairly obvious what was what. - - Some functions have been given names that would have otherwise collided with the ImGui namespace. This has been done to maintain a consistent - style with ImGui. E.g., 'ImGui::PushPlotStyleVar` is now 'ImPlot::PushStyleVar'. + - Some functions have been given names that would have otherwise collided with the ImGui namespace. This has been done to maintain a consistent + style with ImGui. E.g., 'ImGui::PushPlotStyleVar` is now 'ImPlot::PushStyleVar'. - 2020/05/10 (0.2) - The following function/struct names were changes: - ImPlotRange -> ImPlotLimits - GetPlotRange() -> GetPlotLimits() - - SetNextPlotRange -> SetNextPlotLimits + - SetNextPlotRange -> SetNextPlotLimits - SetNextPlotRangeX -> SetNextPlotLimitsX - SetNextPlotRangeY -> SetNextPlotLimitsY - 2020/05/10 (0.2) - Plot queries are pixel based by default. Query rects that maintain relative plot position have been removed. This was done to support multi-y-axis. @@ -138,7 +138,7 @@ inline bool HasFlag(TSet set, TFlag flag) { } /// Flips a flag in a flagset -template +template inline void FlipFlag(TSet& set, TFlag flag) { HasFlag(set, flag) ? set &= ~flag : set |= flag; } @@ -239,7 +239,7 @@ ImVec4 NextColor(); /// Tick mark info struct ImTick { - ImTick(double value, bool major, bool render_label = true) { + ImTick(double value, bool major, bool render_label = true) { PlotPos = value; Major = major; RenderLabel = render_label; @@ -254,11 +254,11 @@ struct ImTick { struct ImPlotItem { ImPlotItem() { - Show = true; + Show = true; Highlight = false; - Color = NextColor(); - NameOffset = -1; - ID = 0; + Color = NextColor(); + NameOffset = -1; + ID = 0; } ~ImPlotItem() { ID = 0; } bool Show; @@ -270,13 +270,13 @@ struct ImPlotItem { /// Plot axis structure. You shouldn't need to construct this! struct ImPlotAxis { - ImPlotAxis() { + ImPlotAxis() { Dragging = false; Range.Min = 0; Range.Max = 1; - Divisions = 3; - Subdivisions = 10; - Flags = PreviousFlags = ImAxisFlags_Default; + Divisions = 3; + Subdivisions = 10; + Flags = PreviousFlags = ImAxisFlags_Default; } bool Dragging; ImPlotRange Range; @@ -331,14 +331,14 @@ struct ImPlotContext { RestorePalette(); } - /// ALl Plots + /// ALl Plots ImPool Plots; /// Current Plot ImPlotState* CurrentPlot; // Legend - ImVector LegendIndices; + ImVector LegendIndices; ImGuiTextBuffer LegendLabels; - // Bounding regions + // Bounding regions ImRect BB_Frame; ImRect BB_Canvas; ImRect BB_Grid; @@ -346,8 +346,8 @@ struct ImPlotContext { bool Hov_Frame; bool Hov_Grid; // Cached Colors - ImU32 Col_Frame, Col_Bg, Col_Border, - Col_Txt, Col_TxtDis, + ImU32 Col_Frame, Col_Bg, Col_Border, + Col_Txt, Col_TxtDis, Col_SlctBg, Col_SlctBd, Col_QryBg, Col_QryBd; struct AxisColor { @@ -385,7 +385,7 @@ struct ImPlotContext { ImPlotStyle Style; ImVector ColorModifiers; // Stack for PushStyleColor()/PopStyleColor() ImVector StyleModifiers; // Stack for PushStyleVar()/PopStyleVar() - ImNextPlotData NextPlotData; + ImNextPlotData NextPlotData; // Digital plot item count int DigitalPlotItemCnt; int DigitalPlotOffset; @@ -464,7 +464,7 @@ inline ImVec2 PlotToPixels(float x, float y, int y_axis_in = -1) { if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImAxisFlags_LogScale)) { float t = log10(x / gp.CurrentPlot->XAxis.Range.Min) / gp.LogDenX; x = ImLerp(gp.CurrentPlot->XAxis.Range.Min, gp.CurrentPlot->XAxis.Range.Max, t); - } + } if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) { float t = log10(y / gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.LogDenY[y_axis]; y = ImLerp(gp.CurrentPlot->YAxis[y_axis].Range.Min, gp.CurrentPlot->YAxis[y_axis].Range.Max, t); @@ -723,9 +723,9 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons const ImGuiID ID = Window->GetID(title); const ImGuiStyle &Style = G.Style; - const ImGuiIO & IO = ImGui::GetIO(); + const ImGuiIO & IO = ImGui::GetIO(); - bool just_created = gp.Plots.GetByKey(ID) == NULL; + bool just_created = gp.Plots.GetByKey(ID) == NULL; gp.CurrentPlot = gp.Plots.GetOrAddByKey(ID); ImPlotState &plot = *gp.CurrentPlot; @@ -739,10 +739,10 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons plot.YAxis[2].Flags = y3_flags; } else { - // TODO: Check which individual flags changed, and only reset those! + // TODO: Check which individual flags changed, and only reset those! // There's probably an easy bit mask trick I'm not aware of. - if (flags != plot.PreviousFlags) - plot.Flags = flags; + if (flags != plot.PreviousFlags) + plot.Flags = flags; if (y_flags != plot.YAxis[0].PreviousFlags) plot.YAxis[0].PreviousFlags = y_flags; if (y2_flags != plot.YAxis[1].PreviousFlags) @@ -826,7 +826,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons if (HasFlag(plot.XAxis.Flags, ImAxisFlags_Adaptive)) { plot.XAxis.Divisions = (int)IM_ROUND(0.003 * gp.BB_Canvas.GetWidth()); if (plot.XAxis.Divisions < 2) - plot.XAxis.Divisions = 2; + plot.XAxis.Divisions = 2; } for (int i = 0; i < MAX_Y_AXES; i++) { if (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_Adaptive)) { @@ -871,7 +871,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons ImGui::RenderFrame(gp.BB_Frame.Min, gp.BB_Frame.Max, gp.Col_Frame, true, Style.FrameRounding); // canvas bb - gp.BB_Canvas = ImRect(gp.BB_Frame.Min + Style.WindowPadding, gp.BB_Frame.Max - Style.WindowPadding); + gp.BB_Canvas = ImRect(gp.BB_Frame.Min + Style.WindowPadding, gp.BB_Frame.Max - Style.WindowPadding); gp.RenderX = (HasFlag(plot.XAxis.Flags, ImAxisFlags_GridLines) || HasFlag(plot.XAxis.Flags, ImAxisFlags_TickMarks) || @@ -879,8 +879,8 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons for (int i = 0; i < MAX_Y_AXES; i++) { gp.RenderY[i] = y[i].present && - (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_GridLines) || - HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickMarks) || + (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_GridLines) || + HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickMarks) || HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickLabels)) && plot.YAxis[i].Divisions > 1; } @@ -946,7 +946,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons ImRect centralRegion(ImVec2(gp.BB_Grid.Min.x + 6, gp.BB_Grid.Min.y), ImVec2(gp.BB_Grid.Max.x - 6, gp.BB_Grid.Max.y)); - + const bool hov_y_axis_region[MAX_Y_AXES] = { y[0].present && (yAxisRegion_bb[0].Contains(IO.MousePos) || centralRegion.Contains(IO.MousePos)), y[1].present && (yAxisRegion_bb[1].Contains(IO.MousePos) || centralRegion.Contains(IO.MousePos)), @@ -955,7 +955,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons const bool any_hov_y_axis_region = hov_y_axis_region[0] || hov_y_axis_region[1] || hov_y_axis_region[2]; // legend hovered from last frame - const bool hov_legend = HasFlag(plot.Flags, ImPlotFlags_Legend) ? gp.Hov_Frame && plot.BB_Legend.Contains(IO.MousePos) : false; + const bool hov_legend = HasFlag(plot.Flags, ImPlotFlags_Legend) ? gp.Hov_Frame && plot.BB_Legend.Contains(IO.MousePos) : false; bool hov_query = false; if (gp.Hov_Frame && gp.Hov_Grid && plot.Queried && !plot.Querying) { @@ -971,7 +971,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons if (plot.DraggingQuery && (IO.MouseReleased[0] || !IO.MouseDown[0])) { plot.DraggingQuery = false; } - if (plot.DraggingQuery) { + if (plot.DraggingQuery) { ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll); plot.QueryRect.Min += IO.MouseDelta; plot.QueryRect.Max += IO.MouseDelta; @@ -981,8 +981,8 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons const bool any_y_dragging = plot.YAxis[0].Dragging || plot.YAxis[1].Dragging || plot.YAxis[2].Dragging; if (IO.MouseDown[0] && !plot.XAxis.Dragging && !any_y_dragging) { plot.DraggingQuery = true; - } - } + } + } // DRAG INPUT ------------------------------------------------------------- @@ -990,7 +990,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // end drags if (plot.XAxis.Dragging && (IO.MouseReleased[0] || !IO.MouseDown[0])) { plot.XAxis.Dragging = false; - G.IO.MouseDragMaxDistanceSqr[0] = 0; + G.IO.MouseDragMaxDistanceSqr[0] = 0; } for (int i = 0; i < MAX_Y_AXES; i++) { if (plot.YAxis[i].Dragging && (IO.MouseReleased[0] || !IO.MouseDown[0])) { @@ -1062,8 +1062,8 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons if (gp.Hov_Frame && (hov_x_axis_region || any_hov_y_axis_region) && IO.MouseWheel != 0) { UpdateTransformCache(); float zoom_rate = 0.1f; - if (IO.MouseWheel > 0) - zoom_rate = (-zoom_rate) / (1.0f + (2.0f * zoom_rate)); + if (IO.MouseWheel > 0) + zoom_rate = (-zoom_rate) / (1.0f + (2.0f * zoom_rate)); float tx = Remap(IO.MousePos.x, gp.BB_Grid.Min.x, gp.BB_Grid.Max.x, 0, 1); float ty = Remap(IO.MousePos.y, gp.BB_Grid.Min.y, gp.BB_Grid.Max.y, 0, 1); if (hov_x_axis_region && !x.lock) { @@ -1087,7 +1087,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons if (!y[i].lock_max) plot.YAxis[i].Range.Max = y[i].flip ? plot_br.y : plot_tl.y; } - } + } } // BOX-SELECTION AND QUERY ------------------------------------------------ @@ -1111,11 +1111,11 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons if (!y[i].lock_max && !IO.KeyShift) plot.YAxis[i].Range.Max = ImMax(p1.y, p2.y); } - } + } plot.Selecting = false; } // bad selection - if (plot.Selecting && (!HasFlag(plot.Flags, ImPlotFlags_BoxSelect) || lock_plot) && ImLengthSqr(plot.SelectStart - IO.MousePos) > 4) { + if (plot.Selecting && (!HasFlag(plot.Flags, ImPlotFlags_BoxSelect) || lock_plot) && ImLengthSqr(plot.SelectStart - IO.MousePos) > 4) { ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed); } // cancel selection @@ -1169,7 +1169,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons plot.Queried = false; plot.QueryRect = ImRect(0,0,0,0); } - + // DOUBLE CLICK ----------------------------------------------------------- if ( IO.MouseDoubleClicked[0] && gp.Hov_Frame && (hov_x_axis_region || any_hov_y_axis_region) && !hov_legend && !hov_query) { @@ -1180,7 +1180,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons } } else { - gp.FitThisFrame = false; + gp.FitThisFrame = false; gp.FitX = false; for (int i = 0; i < MAX_Y_AXES; i++) { gp.FitY[i] = false; @@ -1191,7 +1191,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // focus window if ((IO.MouseClicked[0] || IO.MouseClicked[1]) && gp.Hov_Frame) - ImGui::FocusWindow(ImGui::GetCurrentWindow()); + ImGui::FocusWindow(ImGui::GetCurrentWindow()); UpdateTransformCache(); @@ -1322,7 +1322,7 @@ inline void AxisMenu(ImPlotAxis& Axis) { bool grid = HasFlag(Axis.Flags, ImAxisFlags_GridLines); bool ticks = HasFlag(Axis.Flags, ImAxisFlags_TickMarks); bool labels = HasFlag(Axis.Flags, ImAxisFlags_TickLabels); - if (ImGui::Checkbox("##LockMin", &lock_min)) + if (ImGui::Checkbox("##LockMin", &lock_min)) FlipFlag(Axis.Flags, ImAxisFlags_LockMin); ImGui::SameLine(); if (lock_min) { @@ -1360,8 +1360,8 @@ inline void AxisMenu(ImPlotAxis& Axis) { } void PlotContextMenu(ImPlotState& plot) { - if (ImGui::BeginMenu("X-Axis")) { - ImGui::PushID("X"); + if (ImGui::BeginMenu("X-Axis")) { + ImGui::PushID("X"); AxisMenu(plot.XAxis); ImGui::PopID(); ImGui::EndMenu(); @@ -1380,13 +1380,13 @@ void PlotContextMenu(ImPlotState& plot) { snprintf(buf, sizeof(buf) - 1, "Y-Axis %d", i + 1); } if (ImGui::BeginMenu(buf)) { - ImGui::PushID(i); + ImGui::PushID(i); AxisMenu(plot.YAxis[i]); ImGui::PopID(); ImGui::EndMenu(); } } - + ImGui::Separator(); if ((ImGui::BeginMenu("Settings"))) { if (ImGui::MenuItem("Box Select",NULL,HasFlag(plot.Flags, ImPlotFlags_BoxSelect))) { @@ -1455,7 +1455,7 @@ class BufferWriter { void EndPlot() { - IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Mismatched BeginPlot()/EndPlot()!"); + IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Mismatched BeginPlot()/EndPlot()!"); ImPlotState &plot = *gp.CurrentPlot; ImGuiContext &G = *GImGui; @@ -1550,7 +1550,7 @@ void EndPlot() { if (plot.QueryRect.GetWidth() > 2 && plot.QueryRect.GetHeight() > 2) { DrawList.AddRectFilled(plot.QueryRect.Min + gp.BB_Grid.Min, plot.QueryRect.Max + gp.BB_Grid.Min, gp.Col_QryBg); DrawList.AddRect( plot.QueryRect.Min + gp.BB_Grid.Min, plot.QueryRect.Max + gp.BB_Grid.Min, gp.Col_QryBd); - } + } } else if (plot.Queried) { ImRect bb_query = plot.QueryRect; @@ -1615,7 +1615,7 @@ void EndPlot() { const char* label = GetLegendLabel(i); const char* text_display_end = ImGui::FindRenderedTextEnd(label, NULL); if (label != text_display_end) - DrawList.AddText(legend_content_bb.Min + legend_padding + ImVec2(legend_icon_size, i * txt_ht), + DrawList.AddText(legend_content_bb.Min + legend_padding + ImVec2(legend_icon_size, i * txt_ht), item->Show ? (item->Highlight ? col_hl_txt : gp.Col_Txt) : gp.Col_TxtDis, label, text_display_end); } } @@ -1697,7 +1697,7 @@ void EndPlot() { // Reset next plot data gp.NextPlotData = ImNextPlotData(); // Pop ImGui::PushID at the end of BeginPlot - ImGui::PopID(); + ImGui::PopID(); // End child window if (!HasFlag(plot.Flags, ImPlotFlags_NoChild)) ImGui::EndChild(); @@ -1754,15 +1754,15 @@ void PopPlotClipRect() { ImGui::PopClipRect(); } -bool IsPlotHovered() { +bool IsPlotHovered() { IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "IsPlotHovered() Needs to be called between BeginPlot() and EndPlot()!"); - return gp.Hov_Grid; + return gp.Hov_Grid; } ImVec2 GetPlotMousePos(int y_axis_in) { IM_ASSERT_USER_ERROR(y_axis_in >= -1 && y_axis_in < MAX_Y_AXES, "y_axis needs to between -1 and MAX_Y_AXES"); IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "GetPlotMousePos() Needs to be called between BeginPlot() and EndPlot()!"); const int y_axis = y_axis_in >= 0 ? y_axis_in : gp.CurrentPlot->CurrentYAxis; - return gp.LastMousePos[y_axis]; + return gp.LastMousePos[y_axis]; } @@ -1812,7 +1812,7 @@ struct ImPlotStyleVarInfo { void* GetVarPtr(ImPlotStyle* style) const { return (void*)((unsigned char*)style + Offset); } }; -static const ImPlotStyleVarInfo GPlotStyleVarInfo[] = +static const ImPlotStyleVarInfo GPlotStyleVarInfo[] = { { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImPlotStyle, LineWeight) }, // ImPlotStyleVar_LineWeight { ImGuiDataType_S32, 1, (ImU32)IM_OFFSETOF(ImPlotStyle, Marker) }, // ImPlotStyleVar_Marker @@ -1923,8 +1923,8 @@ void PopStyleVar(int count) { ((float*)data)[0] = backup.BackupFloat[0]; } else if (info->Type == ImGuiDataType_Float && info->Count == 2) { - ((float*)data)[0] = backup.BackupFloat[0]; - ((float*)data)[1] = backup.BackupFloat[1]; + ((float*)data)[0] = backup.BackupFloat[0]; + ((float*)data)[1] = backup.BackupFloat[1]; } else if (info->Type == ImGuiDataType_S32 && info->Count == 1) { ((int*)data)[0] = backup.BackupInt[0]; @@ -2027,34 +2027,34 @@ inline void MarkerCross(ImDrawList& DrawList, const ImVec2& c, float s, bool out template inline void RenderMarkers(Transformer transformer, ImDrawList& DrawList, Getter getter, int count, int offset, bool rend_mk_line, ImU32 col_mk_line, bool rend_mk_fill, ImU32 col_mk_fill, bool cull) { int idx = offset; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { ImVec2 c; c = transformer(getter(idx)); idx = (idx + 1) % count; if (!cull || gp.BB_Grid.Contains(c)) { // TODO: Optimize the loop and if statements, this is atrocious - if (HasFlag(gp.Style.Marker, ImMarker_Circle)) + if (HasFlag(gp.Style.Marker, ImMarker_Circle)) MarkerCircle(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); if (HasFlag(gp.Style.Marker, ImMarker_Square)) - MarkerSquare(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Diamond)) + MarkerSquare(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + if (HasFlag(gp.Style.Marker, ImMarker_Diamond)) MarkerDiamond(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); if (HasFlag(gp.Style.Marker, ImMarker_Up)) - MarkerUp(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Down)) - MarkerDown(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + MarkerUp(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + if (HasFlag(gp.Style.Marker, ImMarker_Down)) + MarkerDown(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); if (HasFlag(gp.Style.Marker, ImMarker_Left)) - MarkerLeft(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Right)) - MarkerRight(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + MarkerLeft(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + if (HasFlag(gp.Style.Marker, ImMarker_Right)) + MarkerRight(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); if (HasFlag(gp.Style.Marker, ImMarker_Cross)) - MarkerCross(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + MarkerCross(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); if (HasFlag(gp.Style.Marker, ImMarker_Plus)) - MarkerPlus(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + MarkerPlus(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); if (HasFlag(gp.Style.Marker, ImMarker_Asterisk)) - MarkerAsterisk(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); + MarkerAsterisk(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); } - } + } } inline void RenderLine(ImDrawList& DrawList, const ImVec2& p1, const ImVec2& p2, float line_weight, ImU32 col_line, ImVec2 uv) { @@ -2063,7 +2063,7 @@ inline void RenderLine(ImDrawList& DrawList, const ImVec2& p1, const ImVec2& p2, float dy = p2.y - p1.y; IM_NORMALIZE2F_OVER_ZERO(dx, dy); dx *= (line_weight * 0.5f); - dy *= (line_weight * 0.5f); + dy *= (line_weight * 0.5f); DrawList._VtxWritePtr[0].pos.x = p1.x + dy; DrawList._VtxWritePtr[0].pos.y = p1.y - dx; DrawList._VtxWritePtr[0].uv = uv; @@ -2120,14 +2120,14 @@ inline void RenderLines(Transformer transformer, ImDrawList& DrawList, Getter ge p1 = transformer(getter(i1)); p2 = transformer(getter(i2)); i1 = i2; - if (!cull || gp.BB_Grid.Contains(p1) || gp.BB_Grid.Contains(p2)) - RenderLine(DrawList, p1, p2, line_weight, col_line, uv); - else - segments_culled++; + if (!cull || gp.BB_Grid.Contains(p1) || gp.BB_Grid.Contains(p2)) + RenderLine(DrawList, p1, p2, line_weight, col_line, uv); + else + segments_culled++; } - if (segments_culled > 0) - DrawList.PrimUnreserve(segments_culled * 6, segments_culled * 4); - } + if (segments_culled > 0) + DrawList.PrimUnreserve(segments_culled * 6, segments_culled * 4); + } } //----------------------------------------------------------------------------- @@ -2315,7 +2315,7 @@ void PlotBarEx(const char* label_id, Getter getter, int count, float width, int } int idx = offset; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { ImVec2 p; p = getter(idx); idx = (idx + 1) % count; @@ -2385,7 +2385,7 @@ void PlotBarHEx(const char* label_id, Getter getter, int count, float height, i } int idx = offset; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { ImVec2 p; p = getter(idx); idx = (idx + 1) % count; @@ -2426,7 +2426,7 @@ struct GetterError { Xs = xs; Ys = ys; Neg = neg; Pos = pos; Stride = stride; } ImVec4 operator()(int idx) { - return ImVec4(StrideIndex(Xs, idx, Stride), + return ImVec4(StrideIndex(Xs, idx, Stride), StrideIndex(Ys, idx, Stride), StrideIndex(Neg, idx, Stride), StrideIndex(Pos, idx, Stride)); @@ -2516,7 +2516,7 @@ void PieChart(const char** label_ids, float* values, int count, const ImVec2& ce float sum = 0; for (int i = 0; i < count; ++i) sum += values[i]; - + const bool normalize = sum > 1.0f; PushPlotClipRect(); @@ -2546,7 +2546,7 @@ void PieChart(const char** label_ids, float* values, int count, const ImVec2& ce } } a0 = a1; - } + } PopPlotClipRect(); } @@ -2614,7 +2614,7 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of pMax.x = gp.PixelRange[ax].Min.x + mx * (itemData2.x - gp.CurrentPlot->XAxis.Range.Min); i1 = i2; s++; - } + } //do not extend plot outside plot range if (pMin.x < gp.PixelRange[ax].Min.x) pMin.x = gp.PixelRange[ax].Min.x; if (pMax.x < gp.PixelRange[ax].Min.x) pMax.x = gp.PixelRange[ax].Min.x; @@ -2629,7 +2629,7 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of } gp.DigitalPlotItemCnt++; gp.DigitalPlotOffset += pixYMax; - } + } ImGui::PopClipRect(); } diff --git a/implot.h b/implot.h index d6c1121..8cb6eb2 100644 --- a/implot.h +++ b/implot.h @@ -67,7 +67,7 @@ enum ImAxisFlags_ { ImAxisFlags_Auxiliary = ImAxisFlags_Default & ~ImAxisFlags_GridLines, }; -// Plot styling colors +// Plot styling colors enum ImPlotCol_ { ImPlotCol_Line, // plot line/outline color (defaults to a rotating color set) ImPlotCol_Fill, // plot fill color for bars (defaults to the current line color) @@ -102,7 +102,7 @@ enum ImPlotStyleVar_ { // Marker specification enum ImMarker_ { ImMarker_None = 1 << 0, // no marker - ImMarker_Circle = 1 << 1, // a circle marker will be rendered at each point + ImMarker_Circle = 1 << 1, // a circle marker will be rendered at each point ImMarker_Square = 1 << 2, // a square maker will be rendered at each point ImMarker_Diamond = 1 << 3, // a diamond marker will be rendered at each point ImMarker_Up = 1 << 4, // an upward-pointing triangle marker will up rendered at each point @@ -154,13 +154,13 @@ namespace ImPlot { // be called, e.g. "if (BeginPlot(...)) { ... EndPlot(); }"". #title_id must // be unique. If you need to avoid ID collisions or don't want to display a // title in the plot, use double hashes (e.g. "MyPlot##Hidden"). If #x_label -// and/or #y_label are provided, axes labels will be displayed. -bool BeginPlot(const char* title_id, - const char* x_label = NULL, - const char* y_label = NULL, - const ImVec2& size = ImVec2(-1,-1), - ImPlotFlags flags = ImPlotFlags_Default, - ImAxisFlags x_flags = ImAxisFlags_Default, +// and/or #y_label are provided, axes labels will be displayed. +bool BeginPlot(const char* title_id, + const char* x_label = NULL, + const char* y_label = NULL, + const ImVec2& size = ImVec2(-1,-1), + ImPlotFlags flags = ImPlotFlags_Default, + ImAxisFlags x_flags = ImAxisFlags_Default, ImAxisFlags y_flags = ImAxisFlags_Default, ImAxisFlags y2_flags = ImAxisFlags_Auxiliary, ImAxisFlags y3_flags = ImAxisFlags_Auxiliary); @@ -228,7 +228,7 @@ void RestorePalette(); void PushStyleColor(ImPlotCol idx, ImU32 col); // Temporarily modify a plot color. void PushStyleColor(ImPlotCol idx, const ImVec4& col); -// Undo temporary color modification. +// Undo temporary color modification. void PopStyleColor(int count = 1); // Temporarily modify a style variable of float type. diff --git a/implot_demo.cpp b/implot_demo.cpp index 81221bc..5e1045a 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -30,7 +30,7 @@ #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #endif -#include "implot.h" +#include #include #include #include @@ -38,7 +38,7 @@ namespace { float RandomRange( float min, float max ) { - float scale = rand() / (float) RAND_MAX; + float scale = rand() / (float) RAND_MAX; return min + scale * ( max - min ); } @@ -46,10 +46,10 @@ struct ScrollingData { int MaxSize; int Offset; ImVector Data; - ScrollingData() { + ScrollingData() { MaxSize = 1000; Offset = 0; - Data.reserve(MaxSize); + Data.reserve(MaxSize); } void AddPoint(float x, float y) { if (Data.size() < MaxSize) @@ -64,15 +64,15 @@ struct ScrollingData { Data.shrink(0); Offset = 0; } - } + } }; struct RollingData { float Span; ImVector Data; - RollingData() { + RollingData() { Span = 10.0f; - Data.reserve(1000); + Data.reserve(1000); } void AddPoint(float x, float y) { float xmod = fmodf(x, Span); @@ -99,8 +99,8 @@ struct BenchmarkItem { } // private namespace -namespace ImPlot { - +namespace ImPlot { + void ShowDemoWindow(bool* p_open) { static bool show_app_metrics = false; static bool show_app_style_editor = false; @@ -177,7 +177,7 @@ void ShowDemoWindow(bool* p_open) { } if (ImPlot::BeginPlot("Scatter Plot", NULL, NULL, ImVec2(-1,300))) { ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3); ImPlot::Plot("Data 1", xs1, ys1, 100); ImPlot::PopStyleVar(2); @@ -307,50 +307,50 @@ void ShowDemoWindow(bool* p_open) { float ys[2] = {10,11}; // filled ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); - ImPlot::Plot("Circle##Fill", xs, ys, 2); + ImPlot::Plot("Circle##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Square); ys[0]--; ys[1]--; - ImPlot::Plot("Square##Fill", xs, ys, 2); + ImPlot::Plot("Square##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); ys[0]--; ys[1]--; - ImPlot::Plot("Diamond##Fill", xs, ys, 2); + ImPlot::Plot("Diamond##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Up); ys[0]--; ys[1]--; - ImPlot::Plot("Up##Fill", xs, ys, 2); + ImPlot::Plot("Up##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Down); ys[0]--; ys[1]--; - ImPlot::Plot("Down##Fill", xs, ys, 2); + ImPlot::Plot("Down##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Left); ys[0]--; ys[1]--; - ImPlot::Plot("Left##Fill", xs, ys, 2); + ImPlot::Plot("Left##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Right); ys[0]--; ys[1]--; - ImPlot::Plot("Right##Fill", xs, ys, 2); + ImPlot::Plot("Right##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); ys[0]--; ys[1]--; - ImPlot::Plot("Cross##Fill", xs, ys, 2); + ImPlot::Plot("Cross##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Plus); ys[0]--; ys[1]--; - ImPlot::Plot("Plus##Fill", xs, ys, 2); + ImPlot::Plot("Plus##Fill", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Asterisk); ys[0]--; ys[1]--; - ImPlot::Plot("Asterisk##Fill", xs, ys, 2); + ImPlot::Plot("Asterisk##Fill", xs, ys, 2); ImPlot::PopStyleVar(10); xs[0] = 6; xs[1] = 9; ys[0] = 10; ys[1] = 11; ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(0,0,0,0)); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); - ImPlot::Plot("Circle", xs, ys, 2); + ImPlot::Plot("Circle", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Square); ys[0]--; ys[1]--; - ImPlot::Plot("Square", xs, ys, 2); + ImPlot::Plot("Square", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); ys[0]--; ys[1]--; - ImPlot::Plot("Diamond", xs, ys, 2); + ImPlot::Plot("Diamond", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Up); ys[0]--; ys[1]--; - ImPlot::Plot("Up", xs, ys, 2); + ImPlot::Plot("Up", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Down); ys[0]--; ys[1]--; - ImPlot::Plot("Down", xs, ys, 2); + ImPlot::Plot("Down", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Left); ys[0]--; ys[1]--; - ImPlot::Plot("Left", xs, ys, 2); + ImPlot::Plot("Left", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Right); ys[0]--; ys[1]--; - ImPlot::Plot("Right", xs, ys, 2); + ImPlot::Plot("Right", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); ys[0]--; ys[1]--; - ImPlot::Plot("Cross", xs, ys, 2); + ImPlot::Plot("Cross", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Plus); ys[0]--; ys[1]--; - ImPlot::Plot("Plus", xs, ys, 2); + ImPlot::Plot("Plus", xs, ys, 2); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Asterisk); ys[0]--; ys[1]--; - ImPlot::Plot("Asterisk", xs, ys, 2); + ImPlot::Plot("Asterisk", xs, ys, 2); ImPlot::PopStyleColor(); ImPlot::PopStyleVar(10); @@ -360,12 +360,12 @@ void ShowDemoWindow(bool* p_open) { ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 8); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerWeight, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle | ImMarker_Cross); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle | ImMarker_Cross); ImPlot::PushStyleColor(ImPlotCol_MarkerOutline, ImVec4(0,0,0,1)); ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(1,1,1,1)); ImPlot::PushStyleColor(ImPlotCol_Line, ImVec4(0,0,0,1)); - ImPlot::Plot("Circle|Cross", xs, ys, 2); - ImPlot::PopStyleVar(4); + ImPlot::Plot("Circle|Cross", xs, ys, 2); + ImPlot::PopStyleVar(4); ImPlot::PopStyleColor(3); ImPlot::Text("Filled Markers", 1.5, 11.75); @@ -461,7 +461,7 @@ void ShowDemoWindow(bool* p_open) { static ImVector data; ImPlotLimits range, query; if (ImPlot::BeginPlot("##Drawing", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default | ImPlotFlags_Query, ImAxisFlags_GridLines, ImAxisFlags_GridLines)) { - if (ImPlot::IsPlotHovered() && ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyCtrl) + if (ImPlot::IsPlotHovered() && ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyCtrl) data.push_back(ImPlot::GetPlotMousePos()); ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); @@ -476,7 +476,7 @@ void ShowDemoWindow(bool* p_open) { avg.x += data[i].x; avg.y += data[i].y; cnt++; - } + } } if (cnt > 0) { avg.x = avg.x / cnt; @@ -570,8 +570,8 @@ void ShowDemoWindow(bool* p_open) { t += ImGui::GetIO().DeltaTime; for (int i = 0; i < 10; ++i) { if (show[i]) - data[i].AddPoint(t, data[i].Data.empty() ? - 0.25f + 0.5f * (float)rand() / float(RAND_MAX) : + data[i].AddPoint(t, data[i].Data.empty() ? + 0.25f + 0.5f * (float)rand() / float(RAND_MAX) : data[i].Data.back().y + (0.005f + 0.0002f * (float)rand() / float(RAND_MAX)) * (-1 + 2 * (float)rand() / float(RAND_MAX))); } } @@ -729,8 +729,8 @@ void ShowDemoWindow(bool* p_open) { ImPlot::SetNextPlotLimits(-0.5f, 9.5f, -0.5f, 9.5f); if (ImPlot::BeginPlot("##Custom", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default & ~ImPlotFlags_Legend, 0)) { float lin[10] = {8,8,9,7,8,8,8,9,7,8}; - float bar[10] = {1,2,5,3,4,1,2,5,3,4}; - float dot[10] = {7,6,6,7,8,5,6,5,8,7}; + float bar[10] = {1,2,5,3,4,1,2,5,3,4}; + float dot[10] = {7,6,6,7,8,5,6,5,8,7}; ImPlot::Bar("Bar", bar, 10, 0.5f); ImPlot::Plot("Line", lin, 10); ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); @@ -764,18 +764,18 @@ void ShowDemoWindow(bool* p_open) { ImGui::BulletText("%d lines with %d points each @ %.3f FPS.",n_items,1000,ImGui::GetIO().Framerate); SetNextPlotLimits(0,1,0,1, ImGuiCond_Always); if (ImPlot::BeginPlot("##Bench",NULL,NULL,ImVec2(-1,300),ImPlotFlags_Default | ImPlotFlags_NoChild)) { - char buff[16]; + char buff[16]; for (int i = 0; i < 100; ++i) { sprintf(buff, "item_%d",i); ImPlot::PushStyleColor(ImPlotCol_Line, items[i].Col); ImPlot::Plot(buff, items[i].Data, 1000); ImPlot::PopStyleColor(); - } + } ImPlot::EndPlot(); } } //------------------------------------------------------------------------- - ImGui::End(); + ImGui::End(); } } // namespace ImGui From 36e0aa3ce1d572e2c4295709cdcb25b526393fe9 Mon Sep 17 00:00:00 2001 From: ozlb Date: Wed, 13 May 2020 17:23:01 +0200 Subject: [PATCH 5/7] C++11 extensions update after enums with ImPlot --- implot.cpp | 215 +++++++++++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 99 deletions(-) diff --git a/implot.cpp b/implot.cpp index 929b6a5..fff7b98 100644 --- a/implot.cpp +++ b/implot.cpp @@ -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/13 (0.2) - ImMarker was change to ImPlotMarker and ImAxisFlags was changed to ImPlotAxisFlags - 2020/05/11 (0.2) - ImPlotFlags_Selection was changed to ImPlotFlags_BoxSelect - 2020/05/11 (0.2) - The namespace ImGui:: was replaced with ImPlot::. As a result, the following additional changes were made: - Functions that were prefixed or decorated with the word "Plot" have been truncated. E.g., `ImGui::PlotBar` is now just `ImPlot::Bar`. @@ -80,7 +81,7 @@ You can read releases logs https://github.com/epezent/implot/releases for more d ImPlotStyle::ImPlotStyle() { LineWeight = 1; - Marker = ImMarker_None; + Marker = ImPlotMarker_None; MarkerSize = 5; MarkerWeight = 1; ErrorBarSize = 5; @@ -276,13 +277,13 @@ struct ImPlotAxis { Range.Max = 1; Divisions = 3; Subdivisions = 10; - Flags = PreviousFlags = ImAxisFlags_Default; + Flags = PreviousFlags = ImPlotAxisFlags_Default; } bool Dragging; ImPlotRange Range; int Divisions; int Subdivisions; - ImAxisFlags Flags, PreviousFlags; + ImPlotAxisFlags Flags, PreviousFlags; }; /// Holds Plot state information that must persist between frames @@ -314,7 +315,6 @@ struct ImPlotState { }; struct ImNextPlotData { - //ImNextPlotData() : HasXRange{}, HasYRange{} {} ImGuiCond XRangeCond; ImGuiCond YRangeCond[MAX_Y_AXES]; bool HasXRange; @@ -426,10 +426,10 @@ inline void UpdateTransformCache() { // get pixels for transforms for (int i = 0; i < MAX_Y_AXES; i++) { - gp.PixelRange[i] = ImRect(HasFlag(gp.CurrentPlot->XAxis.Flags, ImAxisFlags_Invert) ? gp.BB_Grid.Max.x : gp.BB_Grid.Min.x, - HasFlag(gp.CurrentPlot->YAxis[i].Flags, ImAxisFlags_Invert) ? gp.BB_Grid.Min.y : gp.BB_Grid.Max.y, - HasFlag(gp.CurrentPlot->XAxis.Flags, ImAxisFlags_Invert) ? gp.BB_Grid.Min.x : gp.BB_Grid.Max.x, - HasFlag(gp.CurrentPlot->YAxis[i].Flags, ImAxisFlags_Invert) ? gp.BB_Grid.Max.y : gp.BB_Grid.Min.y); + gp.PixelRange[i] = ImRect(HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_Invert) ? gp.BB_Grid.Max.x : gp.BB_Grid.Min.x, + HasFlag(gp.CurrentPlot->YAxis[i].Flags, ImPlotAxisFlags_Invert) ? gp.BB_Grid.Min.y : gp.BB_Grid.Max.y, + HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_Invert) ? gp.BB_Grid.Min.x : gp.BB_Grid.Max.x, + HasFlag(gp.CurrentPlot->YAxis[i].Flags, ImPlotAxisFlags_Invert) ? gp.BB_Grid.Max.y : gp.BB_Grid.Min.y); gp.My[i] = (gp.PixelRange[i].Max.y - gp.PixelRange[i].Min.y) / gp.CurrentPlot->YAxis[i].Range.Size(); } @@ -446,11 +446,11 @@ inline ImVec2 PixelsToPlot(float x, float y, int y_axis_in = -1) { ImVec2 plt; plt.x = (x - gp.PixelRange[y_axis].Min.x) / gp.Mx + gp.CurrentPlot->XAxis.Range.Min; plt.y = (y - gp.PixelRange[y_axis].Min.y) / gp.My[y_axis] + gp.CurrentPlot->YAxis[y_axis].Range.Min; - if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImAxisFlags_LogScale)) { + if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_LogScale)) { float t = (plt.x - gp.CurrentPlot->XAxis.Range.Min) / gp.CurrentPlot->XAxis.Range.Size(); plt.x = pow(10.0f, t * gp.LogDenX) * gp.CurrentPlot->XAxis.Range.Min; } - if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) { + if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) { float t = (plt.y - gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.CurrentPlot->YAxis[y_axis].Range.Size(); plt.y = pow(10.0f, t * gp.LogDenY[y_axis]) * gp.CurrentPlot->YAxis[y_axis].Range.Min; } @@ -461,11 +461,11 @@ inline ImVec2 PlotToPixels(float x, float y, int y_axis_in = -1) { IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotToPixels() Needs to be called between BeginPlot() and EndPlot()!"); const int y_axis = y_axis_in >= 0 ? y_axis_in : gp.CurrentPlot->CurrentYAxis; ImVec2 pix; - if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImAxisFlags_LogScale)) { + if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_LogScale)) { float t = log10(x / gp.CurrentPlot->XAxis.Range.Min) / gp.LogDenX; x = ImLerp(gp.CurrentPlot->XAxis.Range.Min, gp.CurrentPlot->XAxis.Range.Max, t); } - if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) { + if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) { float t = log10(y / gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.LogDenY[y_axis]; y = ImLerp(gp.CurrentPlot->YAxis[y_axis].Range.Min, gp.CurrentPlot->YAxis[y_axis].Range.Max, t); } @@ -646,9 +646,9 @@ struct AxisState { range_cond(range_cond_in), present(present_in), present_so_far(previous_present + (present ? 1 : 0)), - flip(HasFlag(axis->Flags, ImAxisFlags_Invert)), - lock_min(HasFlag(axis->Flags, ImAxisFlags_LockMin)), - lock_max(HasFlag(axis->Flags, ImAxisFlags_LockMax)), + flip(HasFlag(axis->Flags, ImPlotAxisFlags_Invert)), + lock_min(HasFlag(axis->Flags, ImPlotAxisFlags_LockMin)), + lock_max(HasFlag(axis->Flags, ImPlotAxisFlags_LockMax)), lock(present && ((lock_min && lock_max) || (has_range && range_cond == ImGuiCond_Always))) {} AxisState() @@ -690,7 +690,7 @@ class YPadCalculator { if (AxisStates[y_axis].present_so_far >= 3) { pad_result += 6.0f; } - if (!HasFlag(plot.YAxis[y_axis].Flags, ImAxisFlags_TickLabels)) { + if (!HasFlag(plot.YAxis[y_axis].Flags, ImPlotAxisFlags_TickLabels)) { return pad_result; } pad_result += MaxLabelWidths[y_axis] + TxtOff; @@ -708,7 +708,7 @@ class YPadCalculator { // BeginPlot() //----------------------------------------------------------------------------- -bool BeginPlot(const char* title, const char* x_label, const char* y_label, const ImVec2& size, ImPlotFlags flags, ImAxisFlags x_flags, ImAxisFlags y_flags, ImAxisFlags y2_flags, ImAxisFlags y3_flags) { +bool BeginPlot(const char* title, const char* x_label, const char* y_label, const ImVec2& size, ImPlotFlags flags, ImPlotAxisFlags x_flags, ImPlotAxisFlags y_flags, ImPlotAxisFlags y2_flags, ImPlotAxisFlags y3_flags) { IM_ASSERT_USER_ERROR(gp.CurrentPlot == NULL, "Mismatched BeginPlot()/EndPlot()!"); @@ -804,14 +804,14 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons plot.YAxis[i].Range.Max = ConstrainNan(ConstrainInf(plot.YAxis[i].Range.Max)); } - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_LogScale)) + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LogScale)) plot.XAxis.Range.Min = ConstrainLog(plot.XAxis.Range.Min); - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_LogScale)) + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LogScale)) plot.XAxis.Range.Max = ConstrainLog(plot.XAxis.Range.Max); for (int i = 0; i < MAX_Y_AXES; i++) { - if (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_LogScale)) + if (HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LogScale)) plot.YAxis[i].Range.Min = ConstrainLog(plot.YAxis[i].Range.Min); - if (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_LogScale)) + if (HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LogScale)) plot.YAxis[i].Range.Max = ConstrainLog(plot.YAxis[i].Range.Max); } @@ -823,13 +823,13 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons } // adaptive divisions - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_Adaptive)) { + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_Adaptive)) { plot.XAxis.Divisions = (int)IM_ROUND(0.003 * gp.BB_Canvas.GetWidth()); if (plot.XAxis.Divisions < 2) plot.XAxis.Divisions = 2; } for (int i = 0; i < MAX_Y_AXES; i++) { - if (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_Adaptive)) { + if (HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_Adaptive)) { plot.YAxis[i].Divisions = (int)IM_ROUND(0.003 * gp.BB_Canvas.GetHeight()); if (plot.YAxis[i].Divisions < 2) plot.YAxis[i].Divisions = 2; @@ -873,34 +873,34 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // canvas bb gp.BB_Canvas = ImRect(gp.BB_Frame.Min + Style.WindowPadding, gp.BB_Frame.Max - Style.WindowPadding); - gp.RenderX = (HasFlag(plot.XAxis.Flags, ImAxisFlags_GridLines) || - HasFlag(plot.XAxis.Flags, ImAxisFlags_TickMarks) || - HasFlag(plot.XAxis.Flags, ImAxisFlags_TickLabels)) && plot.XAxis.Divisions > 1; + gp.RenderX = (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_GridLines) || + HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickMarks) || + HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels)) && plot.XAxis.Divisions > 1; for (int i = 0; i < MAX_Y_AXES; i++) { gp.RenderY[i] = y[i].present && - (HasFlag(plot.YAxis[i].Flags, ImAxisFlags_GridLines) || - HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickMarks) || - HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickLabels)) && plot.YAxis[i].Divisions > 1; + (HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_GridLines) || + HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickMarks) || + HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickLabels)) && plot.YAxis[i].Divisions > 1; } // get ticks if (gp.RenderX) - GetTicks(plot.XAxis.Range, plot.XAxis.Divisions, plot.XAxis.Subdivisions, HasFlag(plot.XAxis.Flags, ImAxisFlags_LogScale), gp.XTicks); + GetTicks(plot.XAxis.Range, plot.XAxis.Divisions, plot.XAxis.Subdivisions, HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LogScale), gp.XTicks); for (int i = 0; i < MAX_Y_AXES; i++) { if (gp.RenderY[i]) { - GetTicks(plot.YAxis[i].Range, plot.YAxis[i].Divisions, plot.YAxis[i].Subdivisions, HasFlag(plot.YAxis[i].Flags, ImAxisFlags_LogScale), gp.YTicks[i]); + GetTicks(plot.YAxis[i].Range, plot.YAxis[i].Divisions, plot.YAxis[i].Subdivisions, HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LogScale), gp.YTicks[i]); } } // label ticks - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_TickLabels)) - LabelTicks(gp.XTicks, HasFlag(plot.XAxis.Flags, ImAxisFlags_Scientific), gp.XTickLabels); + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels)) + LabelTicks(gp.XTicks, HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_Scientific), gp.XTickLabels); float max_label_width[MAX_Y_AXES] = {}; for (int i = 0; i < MAX_Y_AXES; i++) { - if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickLabels)) { - LabelTicks(gp.YTicks[i], HasFlag(plot.YAxis[i].Flags, ImAxisFlags_Scientific), gp.YTickLabels[i]); + if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickLabels)) { + LabelTicks(gp.YTicks[i], HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_Scientific), gp.YTickLabels[i]); for (int t = 0; t < gp.YTicks[i].Size; t++) { ImTick *yt = &gp.YTicks[i][t]; max_label_width[i] = yt->Size.x > max_label_width[i] ? yt->Size.x : max_label_width[i]; @@ -913,7 +913,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons const float txt_off = 5; const float txt_height = ImGui::GetTextLineHeight(); const float pad_top = title_size.x > 0.0f ? txt_height + txt_off : 0; - const float pad_bot = (HasFlag(plot.XAxis.Flags, ImAxisFlags_TickLabels) ? txt_height + txt_off : 0) + (x_label ? txt_height + txt_off : 0); + const float pad_bot = (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels) ? txt_height + txt_off : 0) + (x_label ? txt_height + txt_off : 0); YPadCalculator y_axis_pad(y, max_label_width, txt_off); const float pad_left = y_axis_pad(0) + (y_label ? txt_height + txt_off : 0); const float pad_right = y_axis_pad(1) + y_axis_pad(2); @@ -1225,7 +1225,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons } // render grid - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_GridLines)) { + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_GridLines)) { for (int t = 0; t < gp.XTicks.Size; t++) { ImTick *xt = &gp.XTicks[t]; DrawList.AddLine(ImVec2(xt->PixelPos, gp.BB_Grid.Min.y), ImVec2(xt->PixelPos, gp.BB_Grid.Max.y), xt->Major ? gp.Col_X.Major : gp.Col_X.Minor, 1); @@ -1233,7 +1233,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons } for (int i = 0; i < MAX_Y_AXES; i++) { - if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImAxisFlags_GridLines)) { + if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_GridLines)) { for (int t = 0; t < gp.YTicks[i].Size; t++) { ImTick *yt = &gp.YTicks[i][t]; DrawList.AddLine(ImVec2(gp.BB_Grid.Min.x, yt->PixelPos), ImVec2(gp.BB_Grid.Max.x, yt->PixelPos), yt->Major ? gp.Col_Y[i].Major : gp.Col_Y[i].Minor, 1); @@ -1249,7 +1249,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons } // render labels - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_TickLabels)) { + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels)) { ImGui::PushClipRect(gp.BB_Frame.Min, gp.BB_Frame.Max, true); for (int t = 0; t < gp.XTicks.Size; t++) { ImTick *xt = &gp.XTicks[t]; @@ -1266,7 +1266,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons } ImGui::PushClipRect(gp.BB_Frame.Min, gp.BB_Frame.Max, true); for (int i = 0; i < MAX_Y_AXES; i++) { - if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickLabels)) { + if (y[i].present && HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickLabels)) { const float x_start = gp.AxisLabelReference[i] + ((i == 0) ? @@ -1315,15 +1315,15 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons inline void AxisMenu(ImPlotAxis& Axis) { ImGui::PushItemWidth(75); - bool lock_min = HasFlag(Axis.Flags, ImAxisFlags_LockMin); - bool lock_max = HasFlag(Axis.Flags, ImAxisFlags_LockMax); - bool invert = HasFlag(Axis.Flags, ImAxisFlags_Invert); - bool logscale = HasFlag(Axis.Flags, ImAxisFlags_LogScale); - bool grid = HasFlag(Axis.Flags, ImAxisFlags_GridLines); - bool ticks = HasFlag(Axis.Flags, ImAxisFlags_TickMarks); - bool labels = HasFlag(Axis.Flags, ImAxisFlags_TickLabels); + bool lock_min = HasFlag(Axis.Flags, ImPlotAxisFlags_LockMin); + bool lock_max = HasFlag(Axis.Flags, ImPlotAxisFlags_LockMax); + bool invert = HasFlag(Axis.Flags, ImPlotAxisFlags_Invert); + bool logscale = HasFlag(Axis.Flags, ImPlotAxisFlags_LogScale); + bool grid = HasFlag(Axis.Flags, ImPlotAxisFlags_GridLines); + bool ticks = HasFlag(Axis.Flags, ImPlotAxisFlags_TickMarks); + bool labels = HasFlag(Axis.Flags, ImPlotAxisFlags_TickLabels); if (ImGui::Checkbox("##LockMin", &lock_min)) - FlipFlag(Axis.Flags, ImAxisFlags_LockMin); + FlipFlag(Axis.Flags, ImPlotAxisFlags_LockMin); ImGui::SameLine(); if (lock_min) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); @@ -1335,7 +1335,7 @@ inline void AxisMenu(ImPlotAxis& Axis) { ImGui::PopStyleVar(); } if (ImGui::Checkbox("##LockMax", &lock_max)) - FlipFlag(Axis.Flags, ImAxisFlags_LockMax); + FlipFlag(Axis.Flags, ImPlotAxisFlags_LockMax); ImGui::SameLine(); if (lock_max) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); @@ -1347,16 +1347,16 @@ inline void AxisMenu(ImPlotAxis& Axis) { } ImGui::Separator(); if (ImGui::Checkbox("Invert", &invert)) - FlipFlag(Axis.Flags, ImAxisFlags_Invert); + FlipFlag(Axis.Flags, ImPlotAxisFlags_Invert); if (ImGui::Checkbox("Log Scale", &logscale)) - FlipFlag(Axis.Flags, ImAxisFlags_LogScale); + FlipFlag(Axis.Flags, ImPlotAxisFlags_LogScale); ImGui::Separator(); if (ImGui::Checkbox("Grid Lines", &grid)) - FlipFlag(Axis.Flags, ImAxisFlags_GridLines); + FlipFlag(Axis.Flags, ImPlotAxisFlags_GridLines); if (ImGui::Checkbox("Tick Marks", &ticks)) - FlipFlag(Axis.Flags, ImAxisFlags_TickMarks); + FlipFlag(Axis.Flags, ImPlotAxisFlags_TickMarks); if (ImGui::Checkbox("Labels", &labels)) - FlipFlag(Axis.Flags, ImAxisFlags_TickLabels); + FlipFlag(Axis.Flags, ImPlotAxisFlags_TickLabels); } void PlotContextMenu(ImPlotState& plot) { @@ -1481,7 +1481,7 @@ void EndPlot() { // render ticks PushPlotClipRect(); - if (HasFlag(plot.XAxis.Flags, ImAxisFlags_TickMarks)) { + if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickMarks)) { for (int t = 0; t < gp.XTicks.Size; t++) { ImTick *xt = &gp.XTicks[t]; DrawList.AddLine(ImVec2(xt->PixelPos, gp.BB_Grid.Max.y),ImVec2(xt->PixelPos, gp.BB_Grid.Max.y - (xt->Major ? 10.0f : 5.0f)), gp.Col_Border, 1); @@ -1495,7 +1495,7 @@ void EndPlot() { if (!y[i].present) { continue; } axis_count++; - if (!HasFlag(plot.YAxis[i].Flags, ImAxisFlags_TickMarks)) { continue; } + if (!HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickMarks)) { continue; } float x_start = gp.AxisLabelReference[i]; float direction = (i == 0) ? 1.0f : -1.0f; @@ -1664,17 +1664,17 @@ void EndPlot() { // FIT DATA -------------------------------------------------------------- if (gp.FitThisFrame && (gp.VisibleItemCount > 0 || plot.Queried)) { - if (gp.FitX && !HasFlag(plot.XAxis.Flags, ImAxisFlags_LockMin) && !NanOrInf(gp.ExtentsX.Min)) { + if (gp.FitX && !HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LockMin) && !NanOrInf(gp.ExtentsX.Min)) { plot.XAxis.Range.Min = gp.ExtentsX.Min; } - if (gp.FitX && !HasFlag(plot.XAxis.Flags, ImAxisFlags_LockMax) && !NanOrInf(gp.ExtentsX.Max)) { + if (gp.FitX && !HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LockMax) && !NanOrInf(gp.ExtentsX.Max)) { plot.XAxis.Range.Max = gp.ExtentsX.Max; } for (int i = 0; i < MAX_Y_AXES; i++) { - if (gp.FitY[i] && !HasFlag(plot.YAxis[i].Flags, ImAxisFlags_LockMin) && !NanOrInf(gp.ExtentsY[i].Min)) { + if (gp.FitY[i] && !HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LockMin) && !NanOrInf(gp.ExtentsY[i].Min)) { plot.YAxis[i].Range.Min = gp.ExtentsY[i].Min; } - if (gp.FitY[i] && !HasFlag(plot.YAxis[i].Flags, ImAxisFlags_LockMax) && !NanOrInf(gp.ExtentsY[i].Max)) { + if (gp.FitY[i] && !HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LockMax) && !NanOrInf(gp.ExtentsY[i].Max)) { plot.YAxis[i].Range.Max = gp.ExtentsY[i].Max; } } @@ -2033,25 +2033,25 @@ int idx = offset; idx = (idx + 1) % count; if (!cull || gp.BB_Grid.Contains(c)) { // TODO: Optimize the loop and if statements, this is atrocious - if (HasFlag(gp.Style.Marker, ImMarker_Circle)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Circle)) MarkerCircle(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Square)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Square)) MarkerSquare(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Diamond)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Diamond)) MarkerDiamond(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Up)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Up)) MarkerUp(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Down)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Down)) MarkerDown(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Left)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Left)) MarkerLeft(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Right)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Right)) MarkerRight(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Cross)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Cross)) MarkerCross(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Plus)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Plus)) MarkerPlus(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); - if (HasFlag(gp.Style.Marker, ImMarker_Asterisk)) + if (HasFlag(gp.Style.Marker, ImPlotMarker_Asterisk)) MarkerAsterisk(DrawList, c, gp.Style.MarkerSize, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, gp.Style.MarkerWeight); } } @@ -2096,34 +2096,43 @@ inline void RenderLineAA(ImDrawList& DrawList, const ImVec2& p1, const ImVec2& p } template -inline void RenderLines(Transformer transformer, ImDrawList& DrawList, Getter getter, int count, int offset, float line_weight, ImU32 col_line, bool cull) { +inline void RenderLineStrip(Transformer transformer, ImDrawList& DrawList, Getter getter, int count, int offset, float line_weight, ImU32 col_line, bool cull) { // render line segments + offset %= count; + if (offset < 0) offset += count; // shift negative offset to positive range + int i_start = offset + 1; + if (i_start >= count ) i_start -= count; + int i_end = offset + count; + if (i_end >= count) i_end -= count; + const int segments = count - 1; - int i1 = offset; - ImVec2 p1, p2; + ImVec2 p1 = transformer(getter(offset)); + bool test1 = !cull || gp.BB_Grid.Contains(p1); if (HasFlag(gp.CurrentPlot->Flags, ImPlotFlags_AntiAliased)) { - for (int s = 0; s < segments; ++s) { - const int i2 = (i1 + 1) % count; - p1 = transformer(getter(i1)); - p2 = transformer(getter(i2)); - i1 = i2; - if (!cull || gp.BB_Grid.Contains(p1) || gp.BB_Grid.Contains(p2)) + for (int i1 = i_start; i1 != i_end; i1 = i1 + 1 < count ? i1 + 1 : i1 + 1 - count) + { + ImVec2 p2 = transformer(getter(i1)); + bool test2 = !cull || gp.BB_Grid.Contains(p2); + if (test1 | test2) RenderLineAA(DrawList, p1, p2, line_weight, col_line); + p1 = p2; + test1 = test2; } } else { const ImVec2 uv = DrawList._Data->TexUvWhitePixel; DrawList.PrimReserve(segments * 6, segments * 4); int segments_culled = 0; - for (int s = 0; s < segments; ++s) { - const int i2 = (i1 + 1) % count; - p1 = transformer(getter(i1)); - p2 = transformer(getter(i2)); - i1 = i2; - if (!cull || gp.BB_Grid.Contains(p1) || gp.BB_Grid.Contains(p2)) - RenderLine(DrawList, p1, p2, line_weight, col_line, uv); - else - segments_culled++; + for (int i1 = i_start; i1 != i_end; i1 = i1 + 1 < count ? i1 + 1 : i1 + 1 - count) + { + ImVec2 p2 = transformer(getter(i1)); + bool test2 = !cull || gp.BB_Grid.Contains(p2); + if (test1 | test2) + RenderLine(DrawList, p1, p2, line_weight, col_line, uv); + else + segments_culled++; + p1 = p2; + test1 = test2; } if (segments_culled > 0) DrawList.PrimUnreserve(segments_culled * 6, segments_culled * 4); @@ -2218,22 +2227,22 @@ inline void PlotEx(const char* label_id, Getter getter, int count, int offset) } PushPlotClipRect(); if (count > 1 && rend_line) { - if (HasFlag(plot->XAxis.Flags, ImAxisFlags_LogScale) && HasFlag(plot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) - RenderLines(Plt2PixLogLog(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); - else if (HasFlag(plot->XAxis.Flags, ImAxisFlags_LogScale)) - RenderLines(Plt2PixLogLin(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); - else if (HasFlag(plot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) - RenderLines(Plt2PixLinLog(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); + if (HasFlag(plot->XAxis.Flags, ImPlotAxisFlags_LogScale) && HasFlag(plot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) + RenderLineStrip(Plt2PixLogLog(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); + else if (HasFlag(plot->XAxis.Flags, ImPlotAxisFlags_LogScale)) + RenderLineStrip(Plt2PixLogLin(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); + else if (HasFlag(plot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) + RenderLineStrip(Plt2PixLinLog(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); else - RenderLines(Plt2PixLinLin(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); + RenderLineStrip(Plt2PixLinLin(y_axis), DrawList, getter, count, offset, line_weight, col_line, cull); } // render markers - if (gp.Style.Marker != ImMarker_None) { - if (HasFlag(plot->XAxis.Flags, ImAxisFlags_LogScale) && HasFlag(plot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) + if (gp.Style.Marker != ImPlotMarker_None) { + if (HasFlag(plot->XAxis.Flags, ImPlotAxisFlags_LogScale) && HasFlag(plot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) RenderMarkers(Plt2PixLogLog(y_axis), DrawList, getter, count, offset, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, cull); - else if (HasFlag(plot->XAxis.Flags, ImAxisFlags_LogScale)) + else if (HasFlag(plot->XAxis.Flags, ImPlotAxisFlags_LogScale)) RenderMarkers(Plt2PixLogLin(y_axis), DrawList, getter, count, offset, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, cull); - else if (HasFlag(plot->YAxis[y_axis].Flags, ImAxisFlags_LogScale)) + else if (HasFlag(plot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) RenderMarkers(Plt2PixLinLog(y_axis), DrawList, getter, count, offset, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, cull); else RenderMarkers(Plt2PixLinLin(y_axis), DrawList, getter, count, offset, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, cull); @@ -2577,6 +2586,14 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of if (gp.Style.Colors[ImPlotCol_Line].w != -1) item->Color = gp.Style.Colors[ImPlotCol_Line]; + + // find data extents + if (gp.FitThisFrame) { + for (int i = 0; i < count; ++i) { + ImVec2 p = getter(i); + FitPoint(ImVec2(p.x, 0)); + } + } ImGui::PushClipRect(gp.BB_Grid.Min, gp.BB_Grid.Max, true); bool cull = HasFlag(gp.CurrentPlot->Flags, ImPlotFlags_CullData); From ff4f27175c6152171087e5965ad7a018005de998 Mon Sep 17 00:00:00 2001 From: ozlb Date: Wed, 13 May 2020 17:23:27 +0200 Subject: [PATCH 6/7] C++11 extensions update after enums with ImPlot --- implot.h | 62 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/implot.h b/implot.h index 8cb6eb2..41bc707 100644 --- a/implot.h +++ b/implot.h @@ -30,10 +30,10 @@ //----------------------------------------------------------------------------- typedef int ImPlotFlags; -typedef int ImAxisFlags; +typedef int ImPlotAxisFlags; typedef int ImPlotCol; typedef int ImPlotStyleVar; -typedef int ImMarker; +typedef int ImPlotMarker; // Options for plots enum ImPlotFlags_ { @@ -53,18 +53,18 @@ enum ImPlotFlags_ { }; // Options for plot axes (X and Y) -enum ImAxisFlags_ { - ImAxisFlags_GridLines = 1 << 0, // grid lines will be displayed - ImAxisFlags_TickMarks = 1 << 1, // tick marks will be displayed for each grid line - ImAxisFlags_TickLabels = 1 << 2, // text labels will be displayed for each grid line - ImAxisFlags_Invert = 1 << 3, // the axis will be inverted - ImAxisFlags_LockMin = 1 << 4, // the axis minimum value will be locked when panning/zooming - ImAxisFlags_LockMax = 1 << 5, // the axis maximum value will be locked when panning/zooming - ImAxisFlags_Adaptive = 1 << 6, // grid divisions will adapt to the current pixel size the axis - ImAxisFlags_LogScale = 1 << 7, // a logartithmic (base 10) axis scale will be used - ImAxisFlags_Scientific = 1 << 8, // scientific notation will be used for tick labels if displayed (WIP, not very good yet) - ImAxisFlags_Default = ImAxisFlags_GridLines | ImAxisFlags_TickMarks | ImAxisFlags_TickLabels | ImAxisFlags_Adaptive, - ImAxisFlags_Auxiliary = ImAxisFlags_Default & ~ImAxisFlags_GridLines, +enum ImPlotAxisFlags_ { + ImPlotAxisFlags_GridLines = 1 << 0, // grid lines will be displayed + ImPlotAxisFlags_TickMarks = 1 << 1, // tick marks will be displayed for each grid line + ImPlotAxisFlags_TickLabels = 1 << 2, // text labels will be displayed for each grid line + ImPlotAxisFlags_Invert = 1 << 3, // the axis will be inverted + ImPlotAxisFlags_LockMin = 1 << 4, // the axis minimum value will be locked when panning/zooming + ImPlotAxisFlags_LockMax = 1 << 5, // the axis maximum value will be locked when panning/zooming + ImPlotAxisFlags_Adaptive = 1 << 6, // grid divisions will adapt to the current pixel size the axis + ImPlotAxisFlags_LogScale = 1 << 7, // a logartithmic (base 10) axis scale will be used + ImPlotAxisFlags_Scientific = 1 << 8, // scientific notation will be used for tick labels if displayed (WIP, not very good yet) + ImPlotAxisFlags_Default = ImPlotAxisFlags_GridLines | ImPlotAxisFlags_TickMarks | ImPlotAxisFlags_TickLabels | ImPlotAxisFlags_Adaptive, + ImPlotAxisFlags_Auxiliary = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_GridLines, }; // Plot styling colors @@ -100,18 +100,18 @@ enum ImPlotStyleVar_ { }; // Marker specification -enum ImMarker_ { - ImMarker_None = 1 << 0, // no marker - ImMarker_Circle = 1 << 1, // a circle marker will be rendered at each point - ImMarker_Square = 1 << 2, // a square maker will be rendered at each point - ImMarker_Diamond = 1 << 3, // a diamond marker will be rendered at each point - ImMarker_Up = 1 << 4, // an upward-pointing triangle marker will up rendered at each point - ImMarker_Down = 1 << 5, // an downward-pointing triangle marker will up rendered at each point - ImMarker_Left = 1 << 6, // an leftward-pointing triangle marker will up rendered at each point - ImMarker_Right = 1 << 7, // an rightward-pointing triangle marker will up rendered at each point - ImMarker_Cross = 1 << 8, // a cross marker will be rendered at each point (not filled) - ImMarker_Plus = 1 << 9, // a plus marker will be rendered at each point (not filled) - ImMarker_Asterisk = 1 << 10, // a asterisk marker will be rendered at each point (not filled) +enum ImPlotMarker_ { + ImPlotMarker_None = 1 << 0, // no marker + ImPlotMarker_Circle = 1 << 1, // a circle marker will be rendered at each point + ImPlotMarker_Square = 1 << 2, // a square maker will be rendered at each point + ImPlotMarker_Diamond = 1 << 3, // a diamond marker will be rendered at each point + ImPlotMarker_Up = 1 << 4, // an upward-pointing triangle marker will up rendered at each point + ImPlotMarker_Down = 1 << 5, // an downward-pointing triangle marker will up rendered at each point + ImPlotMarker_Left = 1 << 6, // an leftward-pointing triangle marker will up rendered at each point + ImPlotMarker_Right = 1 << 7, // an rightward-pointing triangle marker will up rendered at each point + ImPlotMarker_Cross = 1 << 8, // a cross marker will be rendered at each point (not filled) + ImPlotMarker_Plus = 1 << 9, // a plus marker will be rendered at each point (not filled) + ImPlotMarker_Asterisk = 1 << 10, // a asterisk marker will be rendered at each point (not filled) }; // A range defined by a min/max value. Used for plot axes ranges. @@ -133,7 +133,7 @@ struct ImPlotLimits { // Plot style structure struct ImPlotStyle { float LineWeight; // = 1, line weight in pixels - ImMarker Marker; // = ImMarker_None, marker specification + ImPlotMarker Marker; // = ImPlotMarker_None, marker specification float MarkerSize; // = 5, marker size in pixels (roughly the marker's "radius") float MarkerWeight; // = 1, outline weight of markers in pixels float ErrorBarSize; // = 5, error bar whisker width in pixels @@ -160,10 +160,10 @@ bool BeginPlot(const char* title_id, const char* y_label = NULL, const ImVec2& size = ImVec2(-1,-1), ImPlotFlags flags = ImPlotFlags_Default, - ImAxisFlags x_flags = ImAxisFlags_Default, - ImAxisFlags y_flags = ImAxisFlags_Default, - ImAxisFlags y2_flags = ImAxisFlags_Auxiliary, - ImAxisFlags y3_flags = ImAxisFlags_Auxiliary); + ImPlotAxisFlags x_flags = ImPlotAxisFlags_Default, + ImPlotAxisFlags y_flags = ImPlotAxisFlags_Default, + ImPlotAxisFlags y2_flags = ImPlotAxisFlags_Auxiliary, + ImPlotAxisFlags y3_flags = ImPlotAxisFlags_Auxiliary); // Only call EndPlot() if BeginPlot() returns true! Typically called at the end // of an if statement conditioned on BeginPlot(). void EndPlot(); From 595d04c0c6b6eed0b2821457f49263b703cee343 Mon Sep 17 00:00:00 2001 From: ozlb Date: Wed, 13 May 2020 17:24:11 +0200 Subject: [PATCH 7/7] C++11 extensions update after enums with ImPlot --- implot_demo.cpp | 124 +++++++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/implot_demo.cpp b/implot_demo.cpp index 5e1045a..3b9b06b 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -46,7 +46,7 @@ struct ScrollingData { int MaxSize; int Offset; ImVector Data; - ScrollingData() { + ScrollingData() { MaxSize = 1000; Offset = 0; Data.reserve(MaxSize); @@ -70,7 +70,7 @@ struct ScrollingData { struct RollingData { float Span; ImVector Data; - RollingData() { + RollingData() { Span = 10.0f; Data.reserve(1000); } @@ -156,7 +156,7 @@ void ShowDemoWindow(bool* p_open) { } if (ImPlot::BeginPlot("Line Plot", "x", "f(x)", ImVec2(-1,300))) { ImPlot::Plot("sin(50*x)", xs1, ys1, 1001); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); ImPlot::Plot("x^2", xs2, ys2, 11); ImPlot::PopStyleVar(); ImPlot::EndPlot(); @@ -177,11 +177,11 @@ void ShowDemoWindow(bool* p_open) { } if (ImPlot::BeginPlot("Scatter Plot", NULL, NULL, ImVec2(-1,300))) { ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Cross); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3); ImPlot::Plot("Data 1", xs1, ys1, 100); ImPlot::PopStyleVar(2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(1,0,0,0.25f)); ImPlot::Plot("Data 2", xs2, ys2, 50); ImPlot::PopStyleColor(); @@ -227,7 +227,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::Bar("Bar", xs, bar, 5, 0.5f); ImPlot::ErrorBars("Bar", xs, bar, err1, 5); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3); ImPlot::PushStyleColor(ImPlotCol_ErrorBar, ImVec4(1,0,0,1)); ImPlot::ErrorBars("Line", xs, lin, err1, err2, 5); @@ -286,7 +286,7 @@ void ShowDemoWindow(bool* p_open) { rdata2.AddPoint(t, mouse.y * 0.0005f); } ImPlot::SetNextPlotLimitsX(t - 10, t, paused ? ImGuiCond_Once : ImGuiCond_Always); - static int rt_axis = ImAxisFlags_Default & ~ImAxisFlags_TickLabels; + static int rt_axis = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels; if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1,150), ImPlotFlags_Default, rt_axis, rt_axis)) { ImPlot::Plot("Data 1", &sdata1.Data[0].x, &sdata1.Data[0].y, sdata1.Data.size(), sdata1.Offset, 2 * sizeof(float)); ImPlot::Plot("Data 2", &sdata2.Data[0].x, &sdata2.Data[0].y, sdata2.Data.size(), sdata2.Offset, 2 * sizeof(float)); @@ -306,51 +306,51 @@ void ShowDemoWindow(bool* p_open) { float xs[2] = {1,4}; float ys[2] = {10,11}; // filled - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); - ImPlot::Plot("Circle##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Square); ys[0]--; ys[1]--; - ImPlot::Plot("Square##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); ys[0]--; ys[1]--; - ImPlot::Plot("Diamond##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Up); ys[0]--; ys[1]--; - ImPlot::Plot("Up##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Down); ys[0]--; ys[1]--; - ImPlot::Plot("Down##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Left); ys[0]--; ys[1]--; - ImPlot::Plot("Left##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Right); ys[0]--; ys[1]--; - ImPlot::Plot("Right##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); ys[0]--; ys[1]--; - ImPlot::Plot("Cross##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Plus); ys[0]--; ys[1]--; - ImPlot::Plot("Plus##Fill", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Asterisk); ys[0]--; ys[1]--; - ImPlot::Plot("Asterisk##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); + ImPlot::Plot("Circle##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square); ys[0]--; ys[1]--; + ImPlot::Plot("Square##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Diamond); ys[0]--; ys[1]--; + ImPlot::Plot("Diamond##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Up); ys[0]--; ys[1]--; + ImPlot::Plot("Up##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Down); ys[0]--; ys[1]--; + ImPlot::Plot("Down##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Left); ys[0]--; ys[1]--; + ImPlot::Plot("Left##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Right); ys[0]--; ys[1]--; + ImPlot::Plot("Right##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Cross); ys[0]--; ys[1]--; + ImPlot::Plot("Cross##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Plus); ys[0]--; ys[1]--; + ImPlot::Plot("Plus##Fill", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Asterisk); ys[0]--; ys[1]--; + ImPlot::Plot("Asterisk##Fill", xs, ys, 2); ImPlot::PopStyleVar(10); xs[0] = 6; xs[1] = 9; ys[0] = 10; ys[1] = 11; ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(0,0,0,0)); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle); - ImPlot::Plot("Circle", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Square); ys[0]--; ys[1]--; - ImPlot::Plot("Square", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); ys[0]--; ys[1]--; - ImPlot::Plot("Diamond", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Up); ys[0]--; ys[1]--; - ImPlot::Plot("Up", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Down); ys[0]--; ys[1]--; - ImPlot::Plot("Down", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Left); ys[0]--; ys[1]--; - ImPlot::Plot("Left", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Right); ys[0]--; ys[1]--; - ImPlot::Plot("Right", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Cross); ys[0]--; ys[1]--; - ImPlot::Plot("Cross", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Plus); ys[0]--; ys[1]--; - ImPlot::Plot("Plus", xs, ys, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Asterisk); ys[0]--; ys[1]--; - ImPlot::Plot("Asterisk", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); + ImPlot::Plot("Circle", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square); ys[0]--; ys[1]--; + ImPlot::Plot("Square", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Diamond); ys[0]--; ys[1]--; + ImPlot::Plot("Diamond", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Up); ys[0]--; ys[1]--; + ImPlot::Plot("Up", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Down); ys[0]--; ys[1]--; + ImPlot::Plot("Down", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Left); ys[0]--; ys[1]--; + ImPlot::Plot("Left", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Right); ys[0]--; ys[1]--; + ImPlot::Plot("Right", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Cross); ys[0]--; ys[1]--; + ImPlot::Plot("Cross", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Plus); ys[0]--; ys[1]--; + ImPlot::Plot("Plus", xs, ys, 2); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Asterisk); ys[0]--; ys[1]--; + ImPlot::Plot("Asterisk", xs, ys, 2); ImPlot::PopStyleColor(); ImPlot::PopStyleVar(10); @@ -360,7 +360,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 8); ImPlot::PushStyleVar(ImPlotStyleVar_MarkerWeight, 2); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Circle | ImMarker_Cross); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle | ImPlotMarker_Cross); ImPlot::PushStyleColor(ImPlotCol_MarkerOutline, ImVec4(0,0,0,1)); ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(1,1,1,1)); ImPlot::PushStyleColor(ImPlotCol_Line, ImVec4(0,0,0,1)); @@ -386,7 +386,7 @@ void ShowDemoWindow(bool* p_open) { ys3[i] = pow(10.0f, xs[i]); } ImPlot::SetNextPlotLimits(0.1f, 100, 0, 10); - if (ImPlot::BeginPlot("Log Plot", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default, ImAxisFlags_Default | ImAxisFlags_LogScale )) { + if (ImPlot::BeginPlot("Log Plot", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default, ImPlotAxisFlags_Default | ImPlotAxisFlags_LogScale )) { ImPlot::Plot("f(x) = x", xs, xs, 1001); ImPlot::Plot("f(x) = sin(x)+1", xs, ys1, 1001); ImPlot::Plot("f(x) = log(x)", xs, ys2, 1001); @@ -460,11 +460,11 @@ void ShowDemoWindow(bool* p_open) { ImGui::Unindent(); static ImVector data; ImPlotLimits range, query; - if (ImPlot::BeginPlot("##Drawing", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default | ImPlotFlags_Query, ImAxisFlags_GridLines, ImAxisFlags_GridLines)) { - if (ImPlot::IsPlotHovered() && ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyCtrl) + if (ImPlot::BeginPlot("##Drawing", NULL, NULL, ImVec2(-1,300), ImPlotFlags_Default | ImPlotFlags_Query, ImPlotAxisFlags_GridLines, ImPlotAxisFlags_GridLines)) { + if (ImPlot::IsPlotHovered() && ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyCtrl) data.push_back(ImPlot::GetPlotMousePos()); ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Diamond); if (data.size() > 0) ImPlot::Plot("Points", &data[0].x, &data[0].y, data.size(), 0, 2 * sizeof(float)); if (ImPlot::IsPlotQueried() && data.size() > 0) { @@ -511,7 +511,7 @@ void ShowDemoWindow(bool* p_open) { } ImGui::BulletText("Query the first plot to render a subview in the second plot (see above for controls)."); ImPlot::SetNextPlotLimits(0,0.01f,-1,1); - ImAxisFlags flgs = ImAxisFlags_Default & ~ImAxisFlags_TickLabels; + ImPlotAxisFlags flgs = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels; ImPlotLimits query; if (ImPlot::BeginPlot("##View1",NULL,NULL,ImVec2(-1,150), ImPlotFlags_Default | ImPlotFlags_Query, flgs, flgs)) { ImPlot::Plot("Signal 1", x_data, y_data1, 512); @@ -713,6 +713,20 @@ void ShowDemoWindow(bool* p_open) { } } //------------------------------------------------------------------------- + if (ImGui::CollapsingHeader("Offset Data")) { + float xs[50], ys[50]; + for (int i = 0; i < 50; ++i) { + xs[i] = 0.5 + 0.4 * cos(i/50.f * 6.28); + ys[i] = 0.5 + 0.4 * sin(i/50.f * 6.28); + } + static int offset = 0; + ImGui::SliderInt("Offset", &offset, -100, 100); + if (ImPlot::BeginPlot("##offset")) { + ImPlot::Plot("circle", xs, ys, 50, offset); + ImPlot::EndPlot(); + } + } + //------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Custom Styles")) { static ImVec4 my_palette[3] = { ImVec4(0.000f, 0.980f, 0.604f, 1.0f), @@ -734,7 +748,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::Bar("Bar", bar, 10, 0.5f); ImPlot::Plot("Line", lin, 10); ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 0); - ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImMarker_Square); + ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square); ImPlot::Plot("Dot", dot, 10); ImPlot::PopStyleVar(2); ImPlot::EndPlot(); @@ -778,4 +792,4 @@ void ShowDemoWindow(bool* p_open) { ImGui::End(); } -} // namespace ImGui +} // namespace ImPlot