mirror of
https://github.com/gwm17/implot.git
synced 2025-01-30 10:58:51 -05:00
general reorginzation to plot item rendering
This commit is contained in:
parent
e2fd883224
commit
07aed7d079
857
implot.cpp
857
implot.cpp
File diff suppressed because it is too large
Load Diff
9
implot.h
9
implot.h
|
@ -91,7 +91,7 @@ enum ImPlotStyleVar_ {
|
|||
ImPlotStyleVar_Marker, // int, marker specification
|
||||
ImPlotStyleVar_MarkerSize, // float, marker size in pixels (roughly the marker's "radius")
|
||||
ImPlotStyleVar_MarkerWeight, // float, outline weight of markers in pixels
|
||||
ImPlotStyleVar_FillAlpha, // float, alpha modifier applied to plot fills
|
||||
ImPlotStyleVar_FillAlpha, // float, alpha modifier applied to all plot item fills
|
||||
ImPlotStyleVar_ErrorBarSize, // float, error bar whisker width in pixels
|
||||
ImPlotStyleVar_ErrorBarWeight, // float, error bar whisker weight in pixels
|
||||
ImPlotStyleVar_DigitalBitHeight, // float, digital channels bit height (at 1) in pixels
|
||||
|
@ -289,6 +289,9 @@ ImPlotLimits GetPlotQuery(int y_axis = -1);
|
|||
// Provides access to plot style structure for permanant modifications to colors, sizes, etc.
|
||||
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!
|
||||
void PushStyleColor(ImPlotCol idx, ImU32 col);
|
||||
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
||||
|
@ -307,9 +310,9 @@ void PopStyleVar(int count = 1);
|
|||
void SetColormap(ImPlotColormap colormap, int samples = 0);
|
||||
// Sets a custom colormap.
|
||||
void SetColormap(const ImVec4* colors, int num_colors);
|
||||
// Returns the size of the current colormap
|
||||
// Returns the size of the current colormap.
|
||||
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);
|
||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||
ImVec4 LerpColormap(float t);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
/// 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.
|
||||
|
||||
// #define IMPLOT_DEMO_USE_DOUBLE
|
||||
#define IMPLOT_DEMO_USE_DOUBLE
|
||||
#ifdef IMPLOT_DEMO_USE_DOUBLE
|
||||
typedef double t_float;
|
||||
typedef ImPlotPoint t_float2;
|
||||
|
@ -171,7 +171,6 @@ void ShowDemoWindow(bool* p_open) {
|
|||
#else
|
||||
ImGui::BulletText("The demo data precision is: float");
|
||||
#endif
|
||||
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Line Plots")) {
|
||||
|
@ -198,7 +197,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Filled Line Plots")) {
|
||||
if (ImGui::CollapsingHeader("Filled Line Plots")) {
|
||||
static t_float xs1[101], ys1[101], ys2[101], ys3[101];
|
||||
srand(0);
|
||||
for (int i = 0; i < 101; ++i) {
|
||||
|
@ -238,9 +237,9 @@ void ShowDemoWindow(bool* p_open) {
|
|||
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]);
|
||||
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);
|
||||
|
@ -272,11 +271,9 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImPlot::PlotScatter("Data 1", xs1, ys1, 100);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 6);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square);
|
||||
ImPlot::PushStyleColor(ImPlotCol_MarkerFill, ImVec4(1,0,0,0.25f));
|
||||
ImPlot::PushStyleColor(ImPlotCol_MarkerOutline, ImVec4(0,0,0,0));
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||
ImPlot::PlotScatter("Data 2", xs2, ys2, 50);
|
||||
ImPlot::PopStyleColor(2);
|
||||
ImPlot::PopStyleVar(2);
|
||||
ImPlot::PopStyleVar(3);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +305,6 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImPlot::PlotBars("Final Exam", final, 10, 0.2f, 0);
|
||||
ImPlot::PlotBars("Course Grade", grade, 10, 0.2f, 0.2f);
|
||||
}
|
||||
ImPlot::SetColormap(ImPlotColormap_Default);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +327,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImPlot::PushStyleVar(ImPlotStyleVar_ErrorBarSize, size);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_ErrorBarWeight, weight);
|
||||
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::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3);
|
||||
|
|
Loading…
Reference in New Issue
Block a user