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

Merge pull request #49 from ozlb/patch-2

Assert messages, PlotDigital gap and data extents
This commit is contained in:
Evan Pezent 2020-06-01 15:44:30 -05:00 committed by GitHub
commit 2af65585e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,6 +91,7 @@ ImPlotStyle::ImPlotStyle() {
ErrorBarSize = 5;
ErrorBarWeight = 1.5;
DigitalBitHeight = 8;
DigitalBitGap = 4;
Colors[ImPlotCol_Line] = IM_COL_AUTO;
Colors[ImPlotCol_Fill] = IM_COL_AUTO;
@ -2479,7 +2480,7 @@ struct GetterBarH {
template <typename Getter, typename TWidth>
void PlotBarsEx(const char* label_id, Getter getter, int count, TWidth width, int offset) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Bar() Needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotBars() Needs to be called between BeginPlot() and EndPlot()!");
ImPlotItem* item = RegisterItem(label_id);
if (!item->Show)
@ -2570,7 +2571,7 @@ void PlotBars(const char* label_id, ImPlotPoint (*getter_func)(void* data, int i
template <typename Getter, typename THeight>
void PlotBarsHEx(const char* label_id, Getter getter, int count, THeight height, int offset) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "BarH() Needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotBarsH() Needs to be called between BeginPlot() and EndPlot()!");
ImPlotItem* item = RegisterItem(label_id);
if (!item->Show)
@ -2681,7 +2682,7 @@ struct GetterError {
template <typename Getter>
void PlotErrorBarsEx(const char* label_id, Getter getter, int count, int offset) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "ErrorBars() Needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotErrorBars() Needs to be called between BeginPlot() and EndPlot()!");
ImGuiID id = ImGui::GetID(label_id);
ImPlotItem* item = gp.CurrentPlot->Items.GetByKey(id);
@ -2766,7 +2767,7 @@ inline void DrawPieSlice(ImDrawList& DrawList, const ImPlotPoint& center, double
template <typename T>
void PlotPieChartEx(const char** label_ids, T* values, int count, T x, T y, T radius, bool show_percents, T angle0) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PieChart() Needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotPieChart() Needs to be called between BeginPlot() and EndPlot()!");
ImDrawList & DrawList = *ImGui::GetWindowDrawList();
T sum = 0;
@ -2829,7 +2830,7 @@ void PlotPieChart(const char** label_ids, double* values, int count, double x, d
template <typename Getter>
inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int offset)
{
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Plot() Needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotDigital() Needs to be called between BeginPlot() and EndPlot()!");
ImPlotItem* item = RegisterItem(label_id);
if (!item->Show)
@ -2842,14 +2843,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) {
ImPlotPoint p = getter(i);
FitPoint(ImPlotPoint(p.x, 0));
}
}
ImGui::PushClipRect(gp.BB_Grid.Min, gp.BB_Grid.Max, true);
bool cull = HasFlag(gp.CurrentPlot->Flags, ImPlotFlags_CullData);
@ -2943,7 +2936,7 @@ void PlotText(const char* text, float x, float y, bool vertical, const ImVec2& p
//-----------------------------------------------------------------------------
// double
void PlotText(const char* text, double x, double y, bool vertical, const ImVec2& pixel_offset) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "Text() Needs to be called between BeginPlot() and EndPlot()!");
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotText() Needs to be called between BeginPlot() and EndPlot()!");
ImDrawList & DrawList = *ImGui::GetWindowDrawList();
PushPlotClipRect();
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y)) + pixel_offset;