mirror of
https://github.com/gwm17/implot.git
synced 2024-11-23 02:38:53 -05:00
Changed from SetInputMap(ImPlotInputMap)
to ImPlotInputMap& GetInputMap()
per Evan's suggestion.
This commit is contained in:
parent
7f4f3ecd21
commit
f02088fef1
|
@ -13,6 +13,7 @@ ImPlot is an immediate mode plotting widget for [Dear ImGui](https://github.com/
|
||||||
|
|
||||||
- multiple plot types:
|
- multiple plot types:
|
||||||
- line plots
|
- line plots
|
||||||
|
- shaded plots
|
||||||
- scatter plots
|
- scatter plots
|
||||||
- vertical/horizontal bars graphs
|
- vertical/horizontal bars graphs
|
||||||
- vertical/horizontal error bars
|
- vertical/horizontal error bars
|
||||||
|
|
1174
implot.cpp
1174
implot.cpp
File diff suppressed because it is too large
Load Diff
75
implot.h
75
implot.h
|
@ -20,7 +20,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
// ImPlot v0.3 WIP
|
// ImPlot v0.4 WIP
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
@ -45,12 +45,11 @@ enum ImPlotFlags_ {
|
||||||
ImPlotFlags_Query = 1 << 4, // the user will be able to draw query rects with middle-mouse
|
ImPlotFlags_Query = 1 << 4, // the user will be able to draw query rects with middle-mouse
|
||||||
ImPlotFlags_ContextMenu = 1 << 5, // the user will be able to open a context menu with double-right click
|
ImPlotFlags_ContextMenu = 1 << 5, // the user will be able to open a context menu with double-right click
|
||||||
ImPlotFlags_Crosshairs = 1 << 6, // the default mouse cursor will be replaced with a crosshair when hovered
|
ImPlotFlags_Crosshairs = 1 << 6, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||||
ImPlotFlags_CullData = 1 << 7, // plot data outside the plot area will be culled from rendering
|
ImPlotFlags_AntiAliased = 1 << 7, // lines and fills will be anti-aliased (not recommended)
|
||||||
ImPlotFlags_AntiAliased = 1 << 8, // lines and fills will be anti-aliased (not recommended)
|
ImPlotFlags_NoChild = 1 << 8, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||||
ImPlotFlags_NoChild = 1 << 9, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
ImPlotFlags_YAxis2 = 1 << 9, // enable a 2nd y-axis
|
||||||
ImPlotFlags_YAxis2 = 1 << 10, // enable a 2nd y axis
|
ImPlotFlags_YAxis3 = 1 << 10, // enable a 3rd y-axis
|
||||||
ImPlotFlags_YAxis3 = 1 << 11, // enable a 3rd y axis
|
ImPlotFlags_Default = ImPlotFlags_MousePos | ImPlotFlags_Legend | ImPlotFlags_Highlight | ImPlotFlags_BoxSelect | ImPlotFlags_ContextMenu
|
||||||
ImPlotFlags_Default = ImPlotFlags_MousePos | ImPlotFlags_Legend | ImPlotFlags_Highlight | ImPlotFlags_BoxSelect | ImPlotFlags_ContextMenu | ImPlotFlags_CullData
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options for plot axes (X and Y).
|
// Options for plot axes (X and Y).
|
||||||
|
@ -61,10 +60,9 @@ enum ImPlotAxisFlags_ {
|
||||||
ImPlotAxisFlags_Invert = 1 << 3, // the axis will be inverted
|
ImPlotAxisFlags_Invert = 1 << 3, // the axis will be inverted
|
||||||
ImPlotAxisFlags_LockMin = 1 << 4, // the axis minimum value will be locked when panning/zooming
|
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_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 << 6, // a logartithmic (base 10) axis scale will be used
|
||||||
ImPlotAxisFlags_LogScale = 1 << 7, // a logartithmic (base 10) axis scale will be used
|
ImPlotAxisFlags_Scientific = 1 << 7, // scientific notation will be used for tick labels if displayed (WIP, not very good yet)
|
||||||
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_Default = ImPlotAxisFlags_GridLines | ImPlotAxisFlags_TickMarks | ImPlotAxisFlags_TickLabels | ImPlotAxisFlags_Adaptive,
|
|
||||||
ImPlotAxisFlags_Auxiliary = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_GridLines,
|
ImPlotAxisFlags_Auxiliary = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_GridLines,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,6 +91,7 @@ enum ImPlotStyleVar_ {
|
||||||
ImPlotStyleVar_Marker, // int, marker specification
|
ImPlotStyleVar_Marker, // int, marker specification
|
||||||
ImPlotStyleVar_MarkerSize, // float, marker size in pixels (roughly the marker's "radius")
|
ImPlotStyleVar_MarkerSize, // float, marker size in pixels (roughly the marker's "radius")
|
||||||
ImPlotStyleVar_MarkerWeight, // float, outline weight of markers in pixels
|
ImPlotStyleVar_MarkerWeight, // float, outline weight of markers in pixels
|
||||||
|
ImPlotStyleVar_FillAlpha, // float, alpha modifier applied to all plot item fills
|
||||||
ImPlotStyleVar_ErrorBarSize, // float, error bar whisker width in pixels
|
ImPlotStyleVar_ErrorBarSize, // float, error bar whisker width in pixels
|
||||||
ImPlotStyleVar_ErrorBarWeight, // float, error bar whisker weight in pixels
|
ImPlotStyleVar_ErrorBarWeight, // float, error bar whisker weight in pixels
|
||||||
ImPlotStyleVar_DigitalBitHeight, // float, digital channels bit height (at 1) in pixels
|
ImPlotStyleVar_DigitalBitHeight, // float, digital channels bit height (at 1) in pixels
|
||||||
|
@ -164,6 +163,7 @@ struct ImPlotStyle {
|
||||||
ImPlotMarker Marker; // = ImPlotMarker_None, marker specification
|
ImPlotMarker Marker; // = ImPlotMarker_None, marker specification
|
||||||
float MarkerSize; // = 4, marker size in pixels (roughly the marker's "radius")
|
float MarkerSize; // = 4, marker size in pixels (roughly the marker's "radius")
|
||||||
float MarkerWeight; // = 1, outline weight of markers in pixels
|
float MarkerWeight; // = 1, outline weight of markers in pixels
|
||||||
|
float FillAlpha; // = 1, alpha modifier applied to plot fills
|
||||||
float ErrorBarSize; // = 5, error bar whisker width in pixels
|
float ErrorBarSize; // = 5, error bar whisker width in pixels
|
||||||
float ErrorBarWeight; // = 1.5, error bar whisker weight in pixels
|
float ErrorBarWeight; // = 1.5, error bar whisker weight in pixels
|
||||||
float DigitalBitHeight; // = 8, digital channels bit height (at y = 1.0f) in pixels
|
float DigitalBitHeight; // = 8, digital channels bit height (at y = 1.0f) in pixels
|
||||||
|
@ -172,27 +172,27 @@ struct ImPlotStyle {
|
||||||
ImPlotStyle();
|
ImPlotStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Input mapping structure. Comments show the default input mapping.
|
// Input mapping structure, and their default values.
|
||||||
struct ImPlotInputMap {
|
struct ImPlotInputMap {
|
||||||
ImGuiMouseButton PanButton; // left mouse
|
ImGuiMouseButton PanButton = ImGuiMouseButton_Left;
|
||||||
ImGuiKeyModFlags PanMod; // none
|
ImGuiKeyModFlags PanMod = ImGuiKeyModFlags_None;
|
||||||
|
|
||||||
ImGuiMouseButton BoxSelectButton; // right mouse
|
ImGuiMouseButton BoxSelectButton = ImGuiMouseButton_Right;
|
||||||
ImGuiKeyModFlags BoxSelectMod; // none
|
ImGuiKeyModFlags BoxSelectMod = ImGuiKeyModFlags_None;
|
||||||
|
|
||||||
ImGuiMouseButton BoxCancelButton; // left mouse
|
ImGuiMouseButton BoxCancelButton = ImGuiMouseButton_Left;
|
||||||
|
|
||||||
ImGuiMouseButton QueryClickButton; // left mouse
|
ImGuiMouseButton QueryClickButton = ImGuiMouseButton_Left;
|
||||||
ImGuiKeyModFlags QueryClickMod; // ctrl
|
ImGuiKeyModFlags QueryClickMod = ImGuiKeyModFlags_Ctrl;
|
||||||
|
|
||||||
ImGuiMouseButton QueryDragButton; // middle mouse
|
ImGuiMouseButton QueryDragButton = ImGuiMouseButton_Middle;
|
||||||
ImGuiKeyModFlags QueryDragMod; // none
|
ImGuiKeyModFlags QueryDragMod = ImGuiKeyModFlags_None;
|
||||||
|
|
||||||
ImGuiMouseButton QueryDragButton2; // right mouse, alternative way to query drag, useful when middle mouse is not available
|
ImGuiMouseButton QueryDragButton2 = ImGuiMouseButton_Right;
|
||||||
ImGuiKeyModFlags QueryDragMod2; // ctrl
|
ImGuiKeyModFlags QueryDragMod2 = ImGuiKeyModFlags_Ctrl;
|
||||||
|
|
||||||
ImGuiKeyModFlags HorizontalSizeMod; // alt
|
ImGuiKeyModFlags HorizontalSizeMod = ImGuiKeyModFlags_Alt;
|
||||||
ImGuiKeyModFlags VerticalSizeMod; // shift
|
ImGuiKeyModFlags VerticalSizeMod = ImGuiKeyModFlags_Shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -201,9 +201,6 @@ struct ImPlotInputMap {
|
||||||
|
|
||||||
namespace ImPlot {
|
namespace ImPlot {
|
||||||
|
|
||||||
// Overrides the input mapping. Returns the previous input mapping.
|
|
||||||
ImPlotInputMap SetInputMap(const ImPlotInputMap& inputMap);
|
|
||||||
|
|
||||||
// Starts a 2D plotting context. If this function returns true, EndPlot() must
|
// Starts a 2D plotting context. If this function returns true, EndPlot() must
|
||||||
// be called, e.g. "if (BeginPlot(...)) { ... EndPlot(); }"". #title_id must
|
// 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
|
// be unique. If you need to avoid ID collisions or don't want to display a
|
||||||
|
@ -244,6 +241,12 @@ void PlotScatter(const char* label_id, const ImVec2* data, int count, int offset
|
||||||
void PlotScatter(const char* label_id, const ImPlotPoint* data, int count, int offset = 0);
|
void PlotScatter(const char* label_id, const ImPlotPoint* data, int count, int offset = 0);
|
||||||
void PlotScatter(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
void PlotScatter(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
||||||
|
|
||||||
|
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference.
|
||||||
|
void PlotShaded(const char* label_id, const float* xs, const float* ys1, const float* ys2, int count, int offset = 0, int stride = sizeof(float));
|
||||||
|
void PlotShaded(const char* label_id, const double* xs, const double* ys1, const double* ys2, int count, int offset = 0, int stride = sizeof(double));
|
||||||
|
void PlotShaded(const char* label_id, const float* xs, const float* ys, int count, float y_ref = 0, int offset = 0, int stride = sizeof(float));
|
||||||
|
void PlotShaded(const char* label_id, const double* xs, const double* ys, int count, double y_ref = 0, int offset = 0, int stride = sizeof(double));
|
||||||
|
|
||||||
// Plots a vertical bar graph.
|
// Plots a vertical bar graph.
|
||||||
void PlotBars(const char* label_id, const float* values, int count, float width = 0.67f, float shift = 0, int offset = 0, int stride = sizeof(float));
|
void PlotBars(const char* label_id, const float* values, int count, float width = 0.67f, float shift = 0, int offset = 0, int stride = sizeof(float));
|
||||||
void PlotBars(const char* label_id, const double* values, int count, double width = 0.67f, double shift = 0, int offset = 0, int stride = sizeof(double));
|
void PlotBars(const char* label_id, const double* values, int count, double width = 0.67f, double shift = 0, int offset = 0, int stride = sizeof(double));
|
||||||
|
@ -303,12 +306,22 @@ bool IsPlotQueried();
|
||||||
ImPlotLimits GetPlotQuery(int y_axis = -1);
|
ImPlotLimits GetPlotQuery(int y_axis = -1);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Plot Styling
|
// Plot Input Mapping
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Allows changing how keyboard/mouse interaction works.
|
||||||
|
ImPlotInputMap& GetInputMap();
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Plot Styling and Behaviour
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Provides access to plot style structure for permanant modifications to colors, sizes, etc.
|
// Provides access to plot style structure for permanant modifications to colors, sizes, etc.
|
||||||
ImPlotStyle& GetStyle();
|
ImPlotStyle& GetStyle();
|
||||||
|
|
||||||
|
// Special color used to indicate that a style color should be deduced automatically from defaults or colormaps.
|
||||||
|
#define IMPLOT_COL_AUTO ImVec4(0,0,0,-1)
|
||||||
|
|
||||||
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
||||||
void PushStyleColor(ImPlotCol idx, ImU32 col);
|
void PushStyleColor(ImPlotCol idx, ImU32 col);
|
||||||
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
||||||
|
@ -327,9 +340,9 @@ void PopStyleVar(int count = 1);
|
||||||
void SetColormap(ImPlotColormap colormap, int samples = 0);
|
void SetColormap(ImPlotColormap colormap, int samples = 0);
|
||||||
// Sets a custom colormap.
|
// Sets a custom colormap.
|
||||||
void SetColormap(const ImVec4* colors, int num_colors);
|
void SetColormap(const ImVec4* colors, int num_colors);
|
||||||
// Returns the size of the current colormap
|
// Returns the size of the current colormap.
|
||||||
int GetColormapSize();
|
int GetColormapSize();
|
||||||
// Returns a color from the Color map given an index > 0 (modulo will be performed)
|
// Returns a color from the Color map given an index >= 0 (modulo will be performed)
|
||||||
ImVec4 GetColormapColor(int index);
|
ImVec4 GetColormapColor(int index);
|
||||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||||
ImVec4 LerpColormap(float t);
|
ImVec4 LerpColormap(float t);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
// ImPlot v0.3 WIP
|
// ImPlot v0.4 WIP
|
||||||
|
|
||||||
#include "implot.h"
|
#include "implot.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -31,6 +31,8 @@
|
||||||
#define sprintf sprintf_s
|
#define sprintf sprintf_s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace ImPlot {
|
||||||
|
|
||||||
/// Choose whether the demo uses double or float versions of the ImPlot API.
|
/// Choose whether the demo uses double or float versions of the ImPlot API.
|
||||||
/// NB: You don't ever need to typdef of define values for ImPlot. This
|
/// NB: You don't ever need to typdef of define values for ImPlot. This
|
||||||
/// is only being done here for the sake of demoing both precision types.
|
/// is only being done here for the sake of demoing both precision types.
|
||||||
|
@ -54,8 +56,6 @@ typedef ImVec2 t_float2;
|
||||||
#define Fmod fmodf
|
#define Fmod fmodf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ImPlot {
|
|
||||||
|
|
||||||
t_float RandomRange(t_float min, t_float max) {
|
t_float RandomRange(t_float min, t_float max) {
|
||||||
t_float scale = rand() / (t_float) RAND_MAX;
|
t_float scale = rand() / (t_float) RAND_MAX;
|
||||||
return min + scale * ( max - min );
|
return min + scale * ( max - min );
|
||||||
|
@ -114,7 +114,7 @@ struct BenchmarkItem {
|
||||||
}
|
}
|
||||||
Col = ImVec4((float)RandomRange(0,1),(float)RandomRange(0,1),(float)RandomRange(0,1),1);
|
Col = ImVec4((float)RandomRange(0,1),(float)RandomRange(0,1),(float)RandomRange(0,1),1);
|
||||||
}
|
}
|
||||||
~BenchmarkItem() { delete Data; }
|
~BenchmarkItem() { delete[] Data; }
|
||||||
t_float2* Data;
|
t_float2* Data;
|
||||||
ImVec4 Col;
|
ImVec4 Col;
|
||||||
};
|
};
|
||||||
|
@ -137,7 +137,7 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
ImGui::Text("ImPlot says hello. (0.3 WIP)");
|
ImGui::Text("ImPlot says hello. (0.4 WIP)");
|
||||||
if (ImGui::CollapsingHeader("Help")) {
|
if (ImGui::CollapsingHeader("Help")) {
|
||||||
ImGui::Text("USER GUIDE:");
|
ImGui::Text("USER GUIDE:");
|
||||||
ImGui::BulletText("Left click and drag within the plot area to pan X and Y axes.");
|
ImGui::BulletText("Left click and drag within the plot area to pan X and Y axes.");
|
||||||
|
@ -171,7 +171,6 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
#else
|
#else
|
||||||
ImGui::BulletText("The demo data precision is: float");
|
ImGui::BulletText("The demo data precision is: float");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
if (ImGui::CollapsingHeader("Line Plots")) {
|
if (ImGui::CollapsingHeader("Line Plots")) {
|
||||||
|
@ -198,7 +197,7 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
if (ImGui::CollapsingHeader("Filled Plots")) {
|
if (ImGui::CollapsingHeader("Filled Line Plots")) {
|
||||||
static t_float xs1[101], ys1[101], ys2[101], ys3[101];
|
static t_float xs1[101], ys1[101], ys2[101], ys3[101];
|
||||||
srand(0);
|
srand(0);
|
||||||
for (int i = 0; i < 101; ++i) {
|
for (int i = 0; i < 101; ++i) {
|
||||||
|
@ -207,20 +206,51 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ys2[i] = RandomRange(275,350);
|
ys2[i] = RandomRange(275,350);
|
||||||
ys3[i] = RandomRange(150,225);
|
ys3[i] = RandomRange(150,225);
|
||||||
}
|
}
|
||||||
|
static bool show_lines = true;
|
||||||
|
static bool show_fills = true;
|
||||||
|
static float fill_ref = 0;
|
||||||
|
ImGui::Checkbox("Lines",&show_lines); ImGui::SameLine();
|
||||||
|
ImGui::Checkbox("Fills",&show_fills);
|
||||||
|
ImGui::DragFloat("Reference",&fill_ref, 1, -100, 500);
|
||||||
ImPlot::SetNextPlotLimits(0,100,0,500);
|
ImPlot::SetNextPlotLimits(0,100,0,500);
|
||||||
if (ImPlot::BeginPlot("Stock Prices", "Days", "Price")) {
|
if (ImPlot::BeginPlot("Stock Prices", "Days", "Price")) {
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Line, ImVec4(1,1,0,1));
|
if (show_fills) {
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Fill, ImVec4(1,1,0,0.25f));
|
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||||
ImPlot::PlotLine("Stock 1", xs1, ys1, 101);
|
ImPlot::PlotShaded("Stock 1", xs1, ys1, 101, fill_ref);
|
||||||
ImPlot::PopStyleColor(2);
|
ImPlot::PlotShaded("Stock 2", xs1, ys2, 101, fill_ref);
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Line, ImVec4(1,0,1,1));
|
ImPlot::PlotShaded("Stock 3", xs1, ys3, 101, fill_ref);
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Fill, ImVec4(1,0,1,0.25f));
|
ImPlot::PopStyleVar();
|
||||||
ImPlot::PlotLine("Stock 2", xs1, ys2, 101);
|
}
|
||||||
ImPlot::PopStyleColor(2);
|
if (show_lines) {
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Line, ImVec4(1,0,0,1));
|
ImPlot::PlotLine("Stock 1", xs1, ys1, 101);
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Fill, ImVec4(1,0,0,0.25f));
|
ImPlot::PlotLine("Stock 2", xs1, ys2, 101);
|
||||||
ImPlot::PlotLine("Stock 3", xs1, ys3, 101);
|
ImPlot::PlotLine("Stock 3", xs1, ys3, 101);
|
||||||
ImPlot::PopStyleColor(2);
|
}
|
||||||
|
ImPlot::EndPlot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
if (ImGui::CollapsingHeader("Shaded Plots")) {
|
||||||
|
static t_float xs[1001], ys[1001], ys1[1001], ys2[1001], ys3[1001], ys4[1001];
|
||||||
|
srand(0);
|
||||||
|
for (int i = 0; i < 1001; ++i) {
|
||||||
|
xs[i] = i * 0.001f;
|
||||||
|
ys[i] = 0.25f + 0.25f * Sin(25 * xs[i]) * Sin(5 * xs[i]) + RandomRange(-0.01f, 0.01f);
|
||||||
|
ys1[i] = ys[i] + RandomRange(0.1f, 0.12f);
|
||||||
|
ys2[i] = ys[i] - RandomRange(0.1f, 0.12f);
|
||||||
|
ys3[i] = 0.75f + 0.2f * Sin(25 * xs[i]);
|
||||||
|
ys4[i] = 0.75f + 0.1f * Cos(25 * xs[i]);
|
||||||
|
}
|
||||||
|
static float alpha = 0.25f;
|
||||||
|
ImGui::DragFloat("Alpha",&alpha,0.01f,0,1);
|
||||||
|
if (ImPlot::BeginPlot("Shaded Plots")) {
|
||||||
|
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, alpha);
|
||||||
|
ImPlot::PlotShaded("Uncertain Data",xs,ys1,ys2,1001);
|
||||||
|
ImPlot::PlotLine("Uncertain Data", xs, ys, 1001);
|
||||||
|
ImPlot::PlotShaded("Overlapping",xs,ys3,ys4,1001);
|
||||||
|
ImPlot::PlotLine("Overlapping",xs,ys3,1001);
|
||||||
|
ImPlot::PlotLine("Overlapping",xs,ys4,1001);
|
||||||
|
ImPlot::PopStyleVar();
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,11 +271,9 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ImPlot::PlotScatter("Data 1", xs1, ys1, 100);
|
ImPlot::PlotScatter("Data 1", xs1, ys1, 100);
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 6);
|
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 6);
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square);
|
ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square);
|
||||||
ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(1,0,0,0.25f));
|
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||||
ImPlot::PushStyleColor(ImPlotCol_MarkerOutline, ImVec4(0,0,0,0));
|
|
||||||
ImPlot::PlotScatter("Data 2", xs2, ys2, 50);
|
ImPlot::PlotScatter("Data 2", xs2, ys2, 50);
|
||||||
ImPlot::PopStyleColor(2);
|
ImPlot::PopStyleVar(3);
|
||||||
ImPlot::PopStyleVar(2);
|
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +305,6 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ImPlot::PlotBars("Final Exam", final, 10, 0.2f, 0);
|
ImPlot::PlotBars("Final Exam", final, 10, 0.2f, 0);
|
||||||
ImPlot::PlotBars("Course Grade", grade, 10, 0.2f, 0.2f);
|
ImPlot::PlotBars("Course Grade", grade, 10, 0.2f, 0.2f);
|
||||||
}
|
}
|
||||||
ImPlot::SetColormap(ImPlotColormap_Default);
|
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +327,7 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_ErrorBarSize, size);
|
ImPlot::PushStyleVar(ImPlotStyleVar_ErrorBarSize, size);
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_ErrorBarWeight, weight);
|
ImPlot::PushStyleVar(ImPlotStyleVar_ErrorBarWeight, weight);
|
||||||
ImPlot::PlotBars("Bar", xs, bar, 5, 0.5f);
|
ImPlot::PlotBars("Bar", xs, bar, 5, 0.5f);
|
||||||
// error bars should have the same label ID as the associated plot
|
// error bars can be grouped with the associated item by using the same label ID
|
||||||
ImPlot::PlotErrorBars("Bar", xs, bar, err1, 5);
|
ImPlot::PlotErrorBars("Bar", xs, bar, err1, 5);
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle);
|
ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle);
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3);
|
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3);
|
||||||
|
@ -415,9 +442,9 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
static int rt_axis = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels;
|
static int rt_axis = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels;
|
||||||
if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1,150), ImPlotFlags_Default, rt_axis, rt_axis | ImPlotAxisFlags_LockMin)) {
|
if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1,150), ImPlotFlags_Default, rt_axis, rt_axis | ImPlotAxisFlags_LockMin)) {
|
||||||
ImPlot::PlotLine("Data 1", &sdata1.Data[0].x, &sdata1.Data[0].y, sdata1.Data.size(), sdata1.Offset, 2 * sizeof(t_float));
|
ImPlot::PlotLine("Data 1", &sdata1.Data[0].x, &sdata1.Data[0].y, sdata1.Data.size(), sdata1.Offset, 2 * sizeof(t_float));
|
||||||
ImPlot::PushStyleColor(ImPlotCol_Fill, ImVec4(1,0,0,0.25f));
|
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||||
ImPlot::PlotLine("Data 2", &sdata2.Data[0].x, &sdata2.Data[0].y, sdata2.Data.size(), sdata2.Offset, 2 * sizeof(t_float));
|
ImPlot::PlotShaded("Data 2", &sdata2.Data[0].x, &sdata2.Data[0].y, sdata2.Data.size(), 0, sdata2.Offset, 2 * sizeof(t_float));
|
||||||
ImPlot::PopStyleColor();
|
ImPlot::PopStyleVar();
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
ImPlot::SetNextPlotLimitsX(0, history, ImGuiCond_Always);
|
ImPlot::SetNextPlotLimitsX(0, history, ImGuiCond_Always);
|
||||||
|
@ -712,6 +739,7 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
}
|
}
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
srand((unsigned int)ImGui::GetTime()*10000000);
|
||||||
static t_float t = 0;
|
static t_float t = 0;
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
t += ImGui::GetIO().DeltaTime;
|
t += ImGui::GetIO().DeltaTime;
|
||||||
|
@ -972,6 +1000,7 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
static BenchmarkItem items[n_items];
|
static BenchmarkItem items[n_items];
|
||||||
ImGui::BulletText("Make sure VSync is disabled.");
|
ImGui::BulletText("Make sure VSync is disabled.");
|
||||||
ImGui::BulletText("%d lines with %d points each @ %.3f FPS.",n_items,1000,ImGui::GetIO().Framerate);
|
ImGui::BulletText("%d lines with %d points each @ %.3f FPS.",n_items,1000,ImGui::GetIO().Framerate);
|
||||||
|
ImPlot::SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||||
if (ImPlot::BeginPlot("##Bench",NULL,NULL,ImVec2(-1,0),ImPlotFlags_Default | ImPlotFlags_NoChild)) {
|
if (ImPlot::BeginPlot("##Bench",NULL,NULL,ImVec2(-1,0),ImPlotFlags_Default | ImPlotFlags_NoChild)) {
|
||||||
char buff[16];
|
char buff[16];
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user