mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 20:28:50 -05:00
Merge branch 'master' of https://github.com/epezent/implot
This commit is contained in:
commit
a3defa4881
|
@ -26,6 +26,7 @@ ImPlot is an immediate mode plotting widget for [Dear ImGui](https://github.com/
|
||||||
- support for up to three independent y-axes
|
- support for up to three independent y-axes
|
||||||
- controls for zooming, panning, box selection, and auto-fitting data
|
- controls for zooming, panning, box selection, and auto-fitting data
|
||||||
- controls for creating persistent query ranges (see demo)
|
- controls for creating persistent query ranges (see demo)
|
||||||
|
- remappable input controls
|
||||||
- several plot styling options: 10 marker types, adjustable marker sizes, line weights, outline colors, fill colors, etc.
|
- several plot styling options: 10 marker types, adjustable marker sizes, line weights, outline colors, fill colors, etc.
|
||||||
- built-in and user definable colormaps
|
- built-in and user definable colormaps
|
||||||
- optional plot titles, axis labels, and grid labels
|
- optional plot titles, axis labels, and grid labels
|
||||||
|
|
26
implot.cpp
26
implot.cpp
|
@ -3311,13 +3311,16 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of
|
||||||
const int segments = count - 1;
|
const int segments = count - 1;
|
||||||
int i1 = offset;
|
int i1 = offset;
|
||||||
int pixYMax = 0;
|
int pixYMax = 0;
|
||||||
for (int s = 0; s < segments; ++s) {
|
ImPlotPoint itemData1 = getter(0);
|
||||||
const int i2 = (i1 + 1) % count;
|
for (int i = 0; i < getter.Count; ++i) {
|
||||||
ImPlotPoint itemData1 = getter(i1);
|
ImPlotPoint itemData2 = getter(i);
|
||||||
ImPlotPoint itemData2 = getter(i2);
|
if (NanOrInf(itemData1.y)) {
|
||||||
i1 = i2;
|
itemData1 = itemData2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (NanOrInf(itemData2.y)) itemData2.y = ConstrainNan(ConstrainInf(itemData2.y));
|
||||||
int pixY_0 = (int)(line_weight);
|
int pixY_0 = (int)(line_weight);
|
||||||
itemData1.y = itemData1.y < 0 ? 0 : itemData1.y;
|
itemData1.y = ImMax(0.0, itemData1.y);
|
||||||
float pixY_1_float = gp.Style.DigitalBitHeight * (float)itemData1.y;
|
float pixY_1_float = gp.Style.DigitalBitHeight * (float)itemData1.y;
|
||||||
int pixY_1 = (int)(pixY_1_float); //allow only positive values
|
int pixY_1 = (int)(pixY_1_float); //allow only positive values
|
||||||
int pixY_chPosOffset = (int)(ImMax(gp.Style.DigitalBitHeight, pixY_1_float) + gp.Style.DigitalBitGap);
|
int pixY_chPosOffset = (int)(ImMax(gp.Style.DigitalBitHeight, pixY_1_float) + gp.Style.DigitalBitGap);
|
||||||
|
@ -3328,12 +3331,12 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of
|
||||||
pMin.y = (gp.PixelRange[y_axis].Min.y) + ((-gp.DigitalPlotOffset) - pixY_Offset);
|
pMin.y = (gp.PixelRange[y_axis].Min.y) + ((-gp.DigitalPlotOffset) - pixY_Offset);
|
||||||
pMax.y = (gp.PixelRange[y_axis].Min.y) + ((-gp.DigitalPlotOffset) - pixY_0 - pixY_1 - pixY_Offset);
|
pMax.y = (gp.PixelRange[y_axis].Min.y) + ((-gp.DigitalPlotOffset) - pixY_0 - pixY_1 - pixY_Offset);
|
||||||
//plot only one rectangle for same digital state
|
//plot only one rectangle for same digital state
|
||||||
while (((s+2) < segments) && (itemData1.y == itemData2.y)) {
|
while (((i+2) < getter.Count) && (itemData1.y == itemData2.y)) {
|
||||||
const int i3 = (i1 + 1) % count;
|
const int in = (i + 1);
|
||||||
itemData2 = getter(i3);
|
itemData2 = getter(in);
|
||||||
|
if (NanOrInf(itemData2.y)) break;
|
||||||
pMax.x = PlotToPixels(itemData2).x;
|
pMax.x = PlotToPixels(itemData2).x;
|
||||||
i1 = i3;
|
i++;
|
||||||
s++;
|
|
||||||
}
|
}
|
||||||
//do not extend plot outside plot range
|
//do not extend plot outside plot range
|
||||||
if (pMin.x < gp.PixelRange[y_axis].Min.x) pMin.x = gp.PixelRange[y_axis].Min.x;
|
if (pMin.x < gp.PixelRange[y_axis].Min.x) pMin.x = gp.PixelRange[y_axis].Min.x;
|
||||||
|
@ -3346,6 +3349,7 @@ inline void PlotDigitalEx(const char* label_id, Getter getter, int count, int of
|
||||||
colAlpha.w = item->Highlight ? 1.0f : 0.9f;
|
colAlpha.w = item->Highlight ? 1.0f : 0.9f;
|
||||||
DrawList.AddRectFilled(pMin, pMax, ImGui::GetColorU32(colAlpha));
|
DrawList.AddRectFilled(pMin, pMax, ImGui::GetColorU32(colAlpha));
|
||||||
}
|
}
|
||||||
|
itemData1 = itemData2;
|
||||||
}
|
}
|
||||||
gp.DigitalPlotItemCnt++;
|
gp.DigitalPlotItemCnt++;
|
||||||
gp.DigitalPlotOffset += pixYMax;
|
gp.DigitalPlotOffset += pixYMax;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user