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

general reorginzation to plot item rendering

This commit is contained in:
Evan Pezent 2020-06-14 08:27:58 -05:00
parent e2fd883224
commit 07aed7d079
3 changed files with 432 additions and 454 deletions

File diff suppressed because it is too large Load Diff

View File

@ -91,7 +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 plot fills 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
@ -289,6 +289,9 @@ ImPlotLimits GetPlotQuery(int y_axis = -1);
// 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!
@ -307,9 +310,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);

View File

@ -35,7 +35,7 @@
/// 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.
// #define IMPLOT_DEMO_USE_DOUBLE #define IMPLOT_DEMO_USE_DOUBLE
#ifdef IMPLOT_DEMO_USE_DOUBLE #ifdef IMPLOT_DEMO_USE_DOUBLE
typedef double t_float; typedef double t_float;
typedef ImPlotPoint t_float2; typedef ImPlotPoint t_float2;
@ -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 Line 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) {
@ -272,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();
} }
} }
@ -308,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();
} }
} }
@ -331,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);