mirror of
https://github.com/gwm17/implot.git
synced 2024-11-22 18:28:53 -05:00
Compare commits
5 Commits
626e391670
...
18758e237e
Author | SHA1 | Date | |
---|---|---|---|
18758e237e | |||
fb084f3719 | |||
33c5a965f5 | |||
d875123534 | |||
fcb51d2c9c |
513
implot.cpp
513
implot.cpp
File diff suppressed because it is too large
Load Diff
66
implot.h
66
implot.h
|
@ -145,7 +145,7 @@ enum ImPlotFlags_ {
|
||||||
// Options for plot axes (see SetupAxis).
|
// Options for plot axes (see SetupAxis).
|
||||||
enum ImPlotAxisFlags_ {
|
enum ImPlotAxisFlags_ {
|
||||||
ImPlotAxisFlags_None = 0, // default
|
ImPlotAxisFlags_None = 0, // default
|
||||||
ImPlotAxisFlags_NoLabel = 1 << 0, // the axis label will not be displayed (axis labels are also hidden if the supplied string name is NULL)
|
ImPlotAxisFlags_NoLabel = 1 << 0, // the axis label will not be displayed (axis labels are also hidden if the supplied string name is nullptr)
|
||||||
ImPlotAxisFlags_NoGridLines = 1 << 1, // no grid lines will be displayed
|
ImPlotAxisFlags_NoGridLines = 1 << 1, // no grid lines will be displayed
|
||||||
ImPlotAxisFlags_NoTickMarks = 1 << 2, // no tick marks will be displayed
|
ImPlotAxisFlags_NoTickMarks = 1 << 2, // no tick marks will be displayed
|
||||||
ImPlotAxisFlags_NoTickLabels = 1 << 3, // no text labels will be displayed
|
ImPlotAxisFlags_NoTickLabels = 1 << 3, // no text labels will be displayed
|
||||||
|
@ -596,9 +596,9 @@ namespace ImPlot {
|
||||||
|
|
||||||
// Creates a new ImPlot context. Call this after ImGui::CreateContext.
|
// Creates a new ImPlot context. Call this after ImGui::CreateContext.
|
||||||
IMPLOT_API ImPlotContext* CreateContext();
|
IMPLOT_API ImPlotContext* CreateContext();
|
||||||
// Destroys an ImPlot context. Call this before ImGui::DestroyContext. NULL = destroy current context.
|
// Destroys an ImPlot context. Call this before ImGui::DestroyContext. nullptr = destroy current context.
|
||||||
IMPLOT_API void DestroyContext(ImPlotContext* ctx = NULL);
|
IMPLOT_API void DestroyContext(ImPlotContext* ctx = nullptr);
|
||||||
// Returns the current ImPlot context. NULL if no context has ben set.
|
// Returns the current ImPlot context. nullptr if no context has ben set.
|
||||||
IMPLOT_API ImPlotContext* GetCurrentContext();
|
IMPLOT_API ImPlotContext* GetCurrentContext();
|
||||||
// Sets the current ImPlot context.
|
// Sets the current ImPlot context.
|
||||||
IMPLOT_API void SetCurrentContext(ImPlotContext* ctx);
|
IMPLOT_API void SetCurrentContext(ImPlotContext* ctx);
|
||||||
|
@ -690,8 +690,8 @@ IMPLOT_API bool BeginSubplots(const char* title_id,
|
||||||
int cols,
|
int cols,
|
||||||
const ImVec2& size,
|
const ImVec2& size,
|
||||||
ImPlotSubplotFlags flags = 0,
|
ImPlotSubplotFlags flags = 0,
|
||||||
float* row_ratios = NULL,
|
float* row_ratios = nullptr,
|
||||||
float* col_ratios = NULL);
|
float* col_ratios = nullptr);
|
||||||
|
|
||||||
// Only call EndSubplots() if BeginSubplots() returns true! Typically called at the end
|
// Only call EndSubplots() if BeginSubplots() returns true! Typically called at the end
|
||||||
// of an if statement conditioned on BeginSublots(). See example above.
|
// of an if statement conditioned on BeginSublots(). See example above.
|
||||||
|
@ -726,24 +726,24 @@ IMPLOT_API void EndSubplots();
|
||||||
// call it yourself, then the first subsequent plotting or utility function will
|
// call it yourself, then the first subsequent plotting or utility function will
|
||||||
// call it for you.
|
// call it for you.
|
||||||
|
|
||||||
// Enables an axis or sets the label and/or flags for an existing axis. Leave #label = NULL for no label.
|
// Enables an axis or sets the label and/or flags for an existing axis. Leave #label = nullptr for no label.
|
||||||
IMPLOT_API void SetupAxis(ImAxis axis, const char* label=NULL, ImPlotAxisFlags flags=0);
|
IMPLOT_API void SetupAxis(ImAxis axis, const char* label=nullptr, ImPlotAxisFlags flags=0);
|
||||||
// Sets an axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
|
// Sets an axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
|
||||||
IMPLOT_API void SetupAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once);
|
IMPLOT_API void SetupAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once);
|
||||||
// Links an axis range limits to external values. Set to NULL for no linkage. The pointer data must remain valid until EndPlot.
|
// Links an axis range limits to external values. Set to nullptr for no linkage. The pointer data must remain valid until EndPlot.
|
||||||
IMPLOT_API void SetupAxisLinks(ImAxis axis, double* link_min, double* link_max);
|
IMPLOT_API void SetupAxisLinks(ImAxis axis, double* link_min, double* link_max);
|
||||||
// Sets the format of numeric axis labels via formater specifier (default="%g"). Formated values will be double (i.e. use %f).
|
// Sets the format of numeric axis labels via formater specifier (default="%g"). Formated values will be double (i.e. use %f).
|
||||||
IMPLOT_API void SetupAxisFormat(ImAxis axis, const char* fmt);
|
IMPLOT_API void SetupAxisFormat(ImAxis axis, const char* fmt);
|
||||||
// Sets the format of numeric axis labels via formatter callback. Given #value, write a label into #buff. Optionally pass user data.
|
// Sets the format of numeric axis labels via formatter callback. Given #value, write a label into #buff. Optionally pass user data.
|
||||||
IMPLOT_API void SetupAxisFormat(ImAxis axis, ImPlotFormatter formatter, void* data=NULL);
|
IMPLOT_API void SetupAxisFormat(ImAxis axis, ImPlotFormatter formatter, void* data=nullptr);
|
||||||
// Sets an axis' ticks and optionally the labels. To keep the default ticks, set #keep_default=true.
|
// Sets an axis' ticks and optionally the labels. To keep the default ticks, set #keep_default=true.
|
||||||
IMPLOT_API void SetupAxisTicks(ImAxis axis, const double* values, int n_ticks, const char* const labels[]=NULL, bool keep_default=false);
|
IMPLOT_API void SetupAxisTicks(ImAxis axis, const double* values, int n_ticks, const char* const labels[]=nullptr, bool keep_default=false);
|
||||||
// Sets an axis' ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
|
// Sets an axis' ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
|
||||||
IMPLOT_API void SetupAxisTicks(ImAxis axis, double v_min, double v_max, int n_ticks, const char* const labels[]=NULL, bool keep_default=false);
|
IMPLOT_API void SetupAxisTicks(ImAxis axis, double v_min, double v_max, int n_ticks, const char* const labels[]=nullptr, bool keep_default=false);
|
||||||
// Sets an axis' scale using built-in options.
|
// Sets an axis' scale using built-in options.
|
||||||
IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotScale scale);
|
IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotScale scale);
|
||||||
// Sets an axis' scale using user supplied forward and inverse transfroms.
|
// Sets an axis' scale using user supplied forward and inverse transfroms.
|
||||||
IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotTransform forward, ImPlotTransform inverse, void* data=NULL);
|
IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotTransform forward, ImPlotTransform inverse, void* data=nullptr);
|
||||||
// Sets an axis' limits constraints.
|
// Sets an axis' limits constraints.
|
||||||
IMPLOT_API void SetupAxisLimitsConstraints(ImAxis axis, double v_min, double v_max);
|
IMPLOT_API void SetupAxisLimitsConstraints(ImAxis axis, double v_min, double v_max);
|
||||||
// Sets an axis' zoom constraints.
|
// Sets an axis' zoom constraints.
|
||||||
|
@ -788,7 +788,7 @@ IMPLOT_API void SetupFinish();
|
||||||
|
|
||||||
// Sets an upcoming axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
|
// Sets an upcoming axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
|
||||||
IMPLOT_API void SetNextAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once);
|
IMPLOT_API void SetNextAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once);
|
||||||
// Links an upcoming axis range limits to external values. Set to NULL for no linkage. The pointer data must remain valid until EndPlot!
|
// Links an upcoming axis range limits to external values. Set to nullptr for no linkage. The pointer data must remain valid until EndPlot!
|
||||||
IMPLOT_API void SetNextAxisLinks(ImAxis axis, double* link_min, double* link_max);
|
IMPLOT_API void SetNextAxisLinks(ImAxis axis, double* link_min, double* link_max);
|
||||||
// Set an upcoming axis to auto fit to its data.
|
// Set an upcoming axis to auto fit to its data.
|
||||||
IMPLOT_API void SetNextAxisToFit(ImAxis axis);
|
IMPLOT_API void SetNextAxisToFit(ImAxis axis);
|
||||||
|
@ -890,10 +890,10 @@ IMPLOT_TMP void PlotStems(const char* label_id, const T* xs, const T* ys, int co
|
||||||
// Plots infinite vertical or horizontal lines (e.g. for references or asymptotes).
|
// Plots infinite vertical or horizontal lines (e.g. for references or asymptotes).
|
||||||
IMPLOT_TMP void PlotInfLines(const char* label_id, const T* values, int count, ImPlotInfLinesFlags flags=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotInfLines(const char* label_id, const T* values, int count, ImPlotInfLinesFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
|
|
||||||
// Plots a pie chart. Center and radius are in plot units. #label_fmt can be set to NULL for no labels.
|
// Plots a pie chart. Center and radius are in plot units. #label_fmt can be set to nullptr for no labels.
|
||||||
IMPLOT_TMP void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, const char* label_fmt="%.1f", double angle0=90, ImPlotPieChartFlags flags=0);
|
IMPLOT_TMP void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, const char* label_fmt="%.1f", double angle0=90, ImPlotPieChartFlags flags=0);
|
||||||
|
|
||||||
// Plots a 2D heatmap chart. Values are expected to be in row-major order by default. Leave #scale_min and scale_max both at 0 for automatic color scaling, or set them to a predefined range. #label_fmt can be set to NULL for no labels.
|
// Plots a 2D heatmap chart. Values are expected to be in row-major order by default. Leave #scale_min and scale_max both at 0 for automatic color scaling, or set them to a predefined range. #label_fmt can be set to nullptr for no labels.
|
||||||
IMPLOT_TMP void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min=0, double scale_max=0, const char* label_fmt="%.1f", const ImPlotPoint& bounds_min=ImPlotPoint(0,0), const ImPlotPoint& bounds_max=ImPlotPoint(1,1), ImPlotHeatmapFlags flags=0);
|
IMPLOT_TMP void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min=0, double scale_max=0, const char* label_fmt="%.1f", const ImPlotPoint& bounds_min=ImPlotPoint(0,0), const ImPlotPoint& bounds_max=ImPlotPoint(1,1), ImPlotHeatmapFlags flags=0);
|
||||||
|
|
||||||
// Plots a horizontal histogram. #bins can be a positive integer or an ImPlotBin_ method. If #range is left unspecified, the min/max of #values will be used as the range.
|
// Plots a horizontal histogram. #bins can be a positive integer or an ImPlotBin_ method. If #range is left unspecified, the min/max of #values will be used as the range.
|
||||||
|
@ -1077,13 +1077,13 @@ IMPLOT_API void EndDragDropSource();
|
||||||
IMPLOT_API ImPlotStyle& GetStyle();
|
IMPLOT_API ImPlotStyle& GetStyle();
|
||||||
|
|
||||||
// Style plot colors for current ImGui style (default).
|
// Style plot colors for current ImGui style (default).
|
||||||
IMPLOT_API void StyleColorsAuto(ImPlotStyle* dst = NULL);
|
IMPLOT_API void StyleColorsAuto(ImPlotStyle* dst = nullptr);
|
||||||
// Style plot colors for ImGui "Classic".
|
// Style plot colors for ImGui "Classic".
|
||||||
IMPLOT_API void StyleColorsClassic(ImPlotStyle* dst = NULL);
|
IMPLOT_API void StyleColorsClassic(ImPlotStyle* dst = nullptr);
|
||||||
// Style plot colors for ImGui "Dark".
|
// Style plot colors for ImGui "Dark".
|
||||||
IMPLOT_API void StyleColorsDark(ImPlotStyle* dst = NULL);
|
IMPLOT_API void StyleColorsDark(ImPlotStyle* dst = nullptr);
|
||||||
// Style plot colors for ImGui "Light".
|
// Style plot colors for ImGui "Light".
|
||||||
IMPLOT_API void StyleColorsLight(ImPlotStyle* dst = NULL);
|
IMPLOT_API void StyleColorsLight(ImPlotStyle* dst = nullptr);
|
||||||
|
|
||||||
// Use PushStyleX to temporarily modify your ImPlotStyle. The modification
|
// Use PushStyleX to temporarily modify your ImPlotStyle. The modification
|
||||||
// will last until the matching call to PopStyleX. You MUST call a pop for
|
// will last until the matching call to PopStyleX. You MUST call a pop for
|
||||||
|
@ -1150,7 +1150,7 @@ IMPLOT_API ImPlotColormap AddColormap(const char* name, const ImU32* cols, int
|
||||||
|
|
||||||
// Returns the number of available colormaps (i.e. the built-in + user-added count).
|
// Returns the number of available colormaps (i.e. the built-in + user-added count).
|
||||||
IMPLOT_API int GetColormapCount();
|
IMPLOT_API int GetColormapCount();
|
||||||
// Returns a null terminated string name for a colormap given an index. Returns NULL if index is invalid.
|
// Returns a null terminated string name for a colormap given an index. Returns nullptr if index is invalid.
|
||||||
IMPLOT_API const char* GetColormapName(ImPlotColormap cmap);
|
IMPLOT_API const char* GetColormapName(ImPlotColormap cmap);
|
||||||
// Returns an index number for a colormap given a valid string name. Returns -1 if name is invalid.
|
// Returns an index number for a colormap given a valid string name. Returns -1 if name is invalid.
|
||||||
IMPLOT_API ImPlotColormap GetColormapIndex(const char* name);
|
IMPLOT_API ImPlotColormap GetColormapIndex(const char* name);
|
||||||
|
@ -1179,18 +1179,18 @@ IMPLOT_API ImVec4 SampleColormap(float t, ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Shows a vertical color scale with linear spaced ticks using the specified color map. Use double hashes to hide label (e.g. "##NoLabel"). If scale_min > scale_max, the scale to color mapping will be reversed.
|
// Shows a vertical color scale with linear spaced ticks using the specified color map. Use double hashes to hide label (e.g. "##NoLabel"). If scale_min > scale_max, the scale to color mapping will be reversed.
|
||||||
IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), const char* format = "%g", ImPlotColormapScaleFlags flags = 0, ImPlotColormap cmap = IMPLOT_AUTO);
|
IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), const char* format = "%g", ImPlotColormapScaleFlags flags = 0, ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Shows a horizontal slider with a colormap gradient background. Optionally returns the color sampled at t in [0 1].
|
// Shows a horizontal slider with a colormap gradient background. Optionally returns the color sampled at t in [0 1].
|
||||||
IMPLOT_API bool ColormapSlider(const char* label, float* t, ImVec4* out = NULL, const char* format = "", ImPlotColormap cmap = IMPLOT_AUTO);
|
IMPLOT_API bool ColormapSlider(const char* label, float* t, ImVec4* out = nullptr, const char* format = "", ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Shows a button with a colormap gradient brackground.
|
// Shows a button with a colormap gradient brackground.
|
||||||
IMPLOT_API bool ColormapButton(const char* label, const ImVec2& size = ImVec2(0,0), ImPlotColormap cmap = IMPLOT_AUTO);
|
IMPLOT_API bool ColormapButton(const char* label, const ImVec2& size = ImVec2(0,0), ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
|
|
||||||
// When items in a plot sample their color from a colormap, the color is cached and does not change
|
// When items in a plot sample their color from a colormap, the color is cached and does not change
|
||||||
// unless explicitly overriden. Therefore, if you change the colormap after the item has already been plotted,
|
// unless explicitly overriden. Therefore, if you change the colormap after the item has already been plotted,
|
||||||
// item colors will NOT update. If you need item colors to resample the new colormap, then use this
|
// item colors will NOT update. If you need item colors to resample the new colormap, then use this
|
||||||
// function to bust the cached colors. If #plot_title_id is NULL, then every item in EVERY existing plot
|
// function to bust the cached colors. If #plot_title_id is nullptr, then every item in EVERY existing plot
|
||||||
// will be cache busted. Otherwise only the plot specified by #plot_title_id will be busted. For the
|
// will be cache busted. Otherwise only the plot specified by #plot_title_id will be busted. For the
|
||||||
// latter, this function must be called in the same ImGui ID scope that the plot is in. You should rarely if ever
|
// latter, this function must be called in the same ImGui ID scope that the plot is in. You should rarely if ever
|
||||||
// need this function, but it is available for applications that require runtime colormap swaps (e.g. Heatmaps demo).
|
// need this function, but it is available for applications that require runtime colormap swaps (e.g. Heatmaps demo).
|
||||||
IMPLOT_API void BustColorCache(const char* plot_title_id = NULL);
|
IMPLOT_API void BustColorCache(const char* plot_title_id = nullptr);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Input Mapping
|
// [SECTION] Input Mapping
|
||||||
|
@ -1200,9 +1200,9 @@ IMPLOT_API void BustColorCache(const char* plot_title_id = NULL);
|
||||||
IMPLOT_API ImPlotInputMap& GetInputMap();
|
IMPLOT_API ImPlotInputMap& GetInputMap();
|
||||||
|
|
||||||
// Default input mapping: pan = LMB drag, box select = RMB drag, fit = LMB double click, context menu = RMB click, zoom = scroll.
|
// Default input mapping: pan = LMB drag, box select = RMB drag, fit = LMB double click, context menu = RMB click, zoom = scroll.
|
||||||
IMPLOT_API void MapInputDefault(ImPlotInputMap* dst = NULL);
|
IMPLOT_API void MapInputDefault(ImPlotInputMap* dst = nullptr);
|
||||||
// Reverse input mapping: pan = RMB drag, box select = LMB drag, fit = LMB double click, context menu = RMB click, zoom = scroll.
|
// Reverse input mapping: pan = RMB drag, box select = LMB drag, fit = LMB double click, context menu = RMB click, zoom = scroll.
|
||||||
IMPLOT_API void MapInputReverse(ImPlotInputMap* dst = NULL);
|
IMPLOT_API void MapInputReverse(ImPlotInputMap* dst = nullptr);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Miscellaneous
|
// [SECTION] Miscellaneous
|
||||||
|
@ -1227,18 +1227,18 @@ IMPLOT_API bool ShowColormapSelector(const char* label);
|
||||||
// Shows ImPlot input map selector dropdown menu.
|
// Shows ImPlot input map selector dropdown menu.
|
||||||
IMPLOT_API bool ShowInputMapSelector(const char* label);
|
IMPLOT_API bool ShowInputMapSelector(const char* label);
|
||||||
// Shows ImPlot style editor block (not a window).
|
// Shows ImPlot style editor block (not a window).
|
||||||
IMPLOT_API void ShowStyleEditor(ImPlotStyle* ref = NULL);
|
IMPLOT_API void ShowStyleEditor(ImPlotStyle* ref = nullptr);
|
||||||
// Add basic help/info block for end users (not a window).
|
// Add basic help/info block for end users (not a window).
|
||||||
IMPLOT_API void ShowUserGuide();
|
IMPLOT_API void ShowUserGuide();
|
||||||
// Shows ImPlot metrics/debug information window.
|
// Shows ImPlot metrics/debug information window.
|
||||||
IMPLOT_API void ShowMetricsWindow(bool* p_popen = NULL);
|
IMPLOT_API void ShowMetricsWindow(bool* p_popen = nullptr);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Demo
|
// [SECTION] Demo
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Shows the ImPlot demo window (add implot_demo.cpp to your sources!)
|
// Shows the ImPlot demo window (add implot_demo.cpp to your sources!)
|
||||||
IMPLOT_API void ShowDemoWindow(bool* p_open = NULL);
|
IMPLOT_API void ShowDemoWindow(bool* p_open = nullptr);
|
||||||
|
|
||||||
} // namespace ImPlot
|
} // namespace ImPlot
|
||||||
|
|
||||||
|
@ -1276,16 +1276,16 @@ namespace ImPlot {
|
||||||
|
|
||||||
// OBSOLETED in v0.13 -> PLANNED REMOVAL in v1.0
|
// OBSOLETED in v0.13 -> PLANNED REMOVAL in v1.0
|
||||||
IMPLOT_DEPRECATED( IMPLOT_API bool BeginPlot(const char* title_id,
|
IMPLOT_DEPRECATED( IMPLOT_API bool BeginPlot(const char* title_id,
|
||||||
const char* x_label, // = NULL,
|
const char* x_label, // = nullptr,
|
||||||
const char* y_label, // = NULL,
|
const char* y_label, // = nullptr,
|
||||||
const ImVec2& size = ImVec2(-1,0),
|
const ImVec2& size = ImVec2(-1,0),
|
||||||
ImPlotFlags flags = ImPlotFlags_None,
|
ImPlotFlags flags = ImPlotFlags_None,
|
||||||
ImPlotAxisFlags x_flags = 0,
|
ImPlotAxisFlags x_flags = 0,
|
||||||
ImPlotAxisFlags y_flags = 0,
|
ImPlotAxisFlags y_flags = 0,
|
||||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_AuxDefault,
|
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_AuxDefault,
|
||||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_AuxDefault,
|
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_AuxDefault,
|
||||||
const char* y2_label = NULL,
|
const char* y2_label = nullptr,
|
||||||
const char* y3_label = NULL) );
|
const char* y3_label = nullptr) );
|
||||||
|
|
||||||
} // namespace ImPlot
|
} // namespace ImPlot
|
||||||
|
|
||||||
|
|
142
implot_demo.cpp
142
implot_demo.cpp
|
@ -232,11 +232,11 @@ void ModSelector(const char* label, int* k) {
|
||||||
|
|
||||||
void InputMapping(const char* label, ImGuiMouseButton* b, int* k) {
|
void InputMapping(const char* label, ImGuiMouseButton* b, int* k) {
|
||||||
ImGui::LabelText("##","%s",label);
|
ImGui::LabelText("##","%s",label);
|
||||||
if (b != NULL) {
|
if (b != nullptr) {
|
||||||
ImGui::SameLine(100);
|
ImGui::SameLine(100);
|
||||||
ButtonSelector(label,b);
|
ButtonSelector(label,b);
|
||||||
}
|
}
|
||||||
if (k != NULL) {
|
if (k != nullptr) {
|
||||||
ImGui::SameLine(300);
|
ImGui::SameLine(300);
|
||||||
ModSelector(label,k);
|
ModSelector(label,k);
|
||||||
}
|
}
|
||||||
|
@ -245,14 +245,14 @@ void InputMapping(const char* label, ImGuiMouseButton* b, int* k) {
|
||||||
void ShowInputMapping() {
|
void ShowInputMapping() {
|
||||||
ImPlotInputMap& map = ImPlot::GetInputMap();
|
ImPlotInputMap& map = ImPlot::GetInputMap();
|
||||||
InputMapping("Pan",&map.Pan,&map.PanMod);
|
InputMapping("Pan",&map.Pan,&map.PanMod);
|
||||||
InputMapping("Fit",&map.Fit,NULL);
|
InputMapping("Fit",&map.Fit,nullptr);
|
||||||
InputMapping("Select",&map.Select,&map.SelectMod);
|
InputMapping("Select",&map.Select,&map.SelectMod);
|
||||||
InputMapping("SelectHorzMod",NULL,&map.SelectHorzMod);
|
InputMapping("SelectHorzMod",nullptr,&map.SelectHorzMod);
|
||||||
InputMapping("SelectVertMod",NULL,&map.SelectVertMod);
|
InputMapping("SelectVertMod",nullptr,&map.SelectVertMod);
|
||||||
InputMapping("SelectCancel",&map.SelectCancel,NULL);
|
InputMapping("SelectCancel",&map.SelectCancel,nullptr);
|
||||||
InputMapping("Menu",&map.Menu,NULL);
|
InputMapping("Menu",&map.Menu,nullptr);
|
||||||
InputMapping("OverrideMod",NULL,&map.OverrideMod);
|
InputMapping("OverrideMod",nullptr,&map.OverrideMod);
|
||||||
InputMapping("ZoomMod",NULL,&map.ZoomMod);
|
InputMapping("ZoomMod",nullptr,&map.ZoomMod);
|
||||||
ImGui::SliderFloat("ZoomRate",&map.ZoomRate,-1,1);
|
ImGui::SliderFloat("ZoomRate",&map.ZoomRate,-1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ void Demo_Config() {
|
||||||
ImGui::Checkbox("Use 24 Hour Clock", &ImPlot::GetStyle().Use24HourClock);
|
ImGui::Checkbox("Use 24 Hour Clock", &ImPlot::GetStyle().Use24HourClock);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImPlot::BeginPlot("Preview")) {
|
if (ImPlot::BeginPlot("Preview")) {
|
||||||
static double now = (double)time(0);
|
static double now = (double)time(nullptr);
|
||||||
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
|
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
|
||||||
ImPlot::SetupAxisLimits(ImAxis_X1, now, now + 24*3600);
|
ImPlot::SetupAxisLimits(ImAxis_X1, now, now + 24*3600);
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
@ -530,7 +530,7 @@ void Demo_BarStacks() {
|
||||||
ImPlot::PushColormap(Liars);
|
ImPlot::PushColormap(Liars);
|
||||||
if (ImPlot::BeginPlot("PolitiFact: Who Lies More?",ImVec2(-1,400),ImPlotFlags_NoMouseText)) {
|
if (ImPlot::BeginPlot("PolitiFact: Who Lies More?",ImVec2(-1,400),ImPlotFlags_NoMouseText)) {
|
||||||
ImPlot::SetupLegend(ImPlotLocation_South, ImPlotLegendFlags_Outside|ImPlotLegendFlags_Horizontal);
|
ImPlot::SetupLegend(ImPlotLocation_South, ImPlotLegendFlags_Outside|ImPlotLegendFlags_Horizontal);
|
||||||
ImPlot::SetupAxes(NULL,NULL,ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_Invert);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_Invert);
|
||||||
ImPlot::SetupAxisTicks(ImAxis_Y1,0,19,20,politicians,false);
|
ImPlot::SetupAxisTicks(ImAxis_Y1,0,19,20,politicians,false);
|
||||||
if (diverging)
|
if (diverging)
|
||||||
ImPlot::PlotBarGroups(labels_div,data_div,9,20,0.75,0,ImPlotBarGroupsFlags_Stacked|ImPlotBarGroupsFlags_Horizontal);
|
ImPlot::PlotBarGroups(labels_div,data_div,9,20,0.75,0,ImPlotBarGroupsFlags_Stacked|ImPlotBarGroupsFlags_Horizontal);
|
||||||
|
@ -595,7 +595,7 @@ void Demo_StemPlots() {
|
||||||
void Demo_InfiniteLines() {
|
void Demo_InfiniteLines() {
|
||||||
static double vals[] = {0.25, 0.5, 0.75};
|
static double vals[] = {0.25, 0.5, 0.75};
|
||||||
if (ImPlot::BeginPlot("##Infinite")) {
|
if (ImPlot::BeginPlot("##Infinite")) {
|
||||||
ImPlot::SetupAxes(NULL,NULL,ImPlotAxisFlags_NoInitialFit,ImPlotAxisFlags_NoInitialFit);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_NoInitialFit,ImPlotAxisFlags_NoInitialFit);
|
||||||
ImPlot::PlotInfLines("Vertical",vals,3);
|
ImPlot::PlotInfLines("Vertical",vals,3);
|
||||||
ImPlot::PlotInfLines("Horizontal",vals,3,ImPlotInfLinesFlags_Horizontal);
|
ImPlot::PlotInfLines("Horizontal",vals,3,ImPlotInfLinesFlags_Horizontal);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
|
@ -616,7 +616,7 @@ void Demo_PieCharts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##Pie1", ImVec2(250,250), ImPlotFlags_Equal | ImPlotFlags_NoMouseText)) {
|
if (ImPlot::BeginPlot("##Pie1", ImVec2(250,250), ImPlotFlags_Equal | ImPlotFlags_NoMouseText)) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
||||||
ImPlot::SetupAxesLimits(0, 1, 0, 1);
|
ImPlot::SetupAxesLimits(0, 1, 0, 1);
|
||||||
ImPlot::PlotPieChart(labels1, data1, 4, 0.5, 0.5, 0.4, "%.2f", 90, flags);
|
ImPlot::PlotPieChart(labels1, data1, 4, 0.5, 0.5, 0.4, "%.2f", 90, flags);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
|
@ -629,7 +629,7 @@ void Demo_PieCharts() {
|
||||||
|
|
||||||
ImPlot::PushColormap(ImPlotColormap_Pastel);
|
ImPlot::PushColormap(ImPlotColormap_Pastel);
|
||||||
if (ImPlot::BeginPlot("##Pie2", ImVec2(250,250), ImPlotFlags_Equal | ImPlotFlags_NoMouseText)) {
|
if (ImPlot::BeginPlot("##Pie2", ImVec2(250,250), ImPlotFlags_Equal | ImPlotFlags_NoMouseText)) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
||||||
ImPlot::SetupAxesLimits(0, 1, 0, 1);
|
ImPlot::SetupAxesLimits(0, 1, 0, 1);
|
||||||
ImPlot::PlotPieChart(labels2, data2, 5, 0.5, 0.5, 0.4, "%.0f", 180, flags);
|
ImPlot::PlotPieChart(labels2, data2, 5, 0.5, 0.5, 0.4, "%.0f", 180, flags);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
|
@ -676,7 +676,7 @@ void Demo_Heatmaps() {
|
||||||
ImPlot::PushColormap(map);
|
ImPlot::PushColormap(map);
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##Heatmap1",ImVec2(225,225),ImPlotFlags_NoLegend|ImPlotFlags_NoMouseText)) {
|
if (ImPlot::BeginPlot("##Heatmap1",ImVec2(225,225),ImPlotFlags_NoLegend|ImPlotFlags_NoMouseText)) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, axes_flags, axes_flags);
|
ImPlot::SetupAxes(nullptr, nullptr, axes_flags, axes_flags);
|
||||||
ImPlot::SetupAxisTicks(ImAxis_X1,0 + 1.0/14.0, 1 - 1.0/14.0, 7, xlabels);
|
ImPlot::SetupAxisTicks(ImAxis_X1,0 + 1.0/14.0, 1 - 1.0/14.0, 7, xlabels);
|
||||||
ImPlot::SetupAxisTicks(ImAxis_Y1,1 - 1.0/14.0, 0 + 1.0/14.0, 7, ylabels);
|
ImPlot::SetupAxisTicks(ImAxis_Y1,1 - 1.0/14.0, 0 + 1.0/14.0, 7, ylabels);
|
||||||
ImPlot::PlotHeatmap("heat",values1[0],7,7,scale_min,scale_max,"%g",ImPlotPoint(0,0),ImPlotPoint(1,1),hm_flags);
|
ImPlot::PlotHeatmap("heat",values1[0],7,7,scale_min,scale_max,"%g",ImPlotPoint(0,0),ImPlotPoint(1,1),hm_flags);
|
||||||
|
@ -694,10 +694,10 @@ void Demo_Heatmaps() {
|
||||||
values2[i] = RandomRange(0.0,1.0);
|
values2[i] = RandomRange(0.0,1.0);
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##Heatmap2",ImVec2(225,225))) {
|
if (ImPlot::BeginPlot("##Heatmap2",ImVec2(225,225))) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
||||||
ImPlot::SetupAxesLimits(-1,1,-1,1);
|
ImPlot::SetupAxesLimits(-1,1,-1,1);
|
||||||
ImPlot::PlotHeatmap("heat1",values2,size,size,0,1,NULL);
|
ImPlot::PlotHeatmap("heat1",values2,size,size,0,1,nullptr);
|
||||||
ImPlot::PlotHeatmap("heat2",values2,size,size,0,1,NULL, ImPlotPoint(-1,-1), ImPlotPoint(0,0));
|
ImPlot::PlotHeatmap("heat2",values2,size,size,0,1,nullptr, ImPlotPoint(-1,-1), ImPlotPoint(0,0));
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
ImPlot::PopColormap();
|
ImPlot::PopColormap();
|
||||||
|
@ -756,7 +756,7 @@ void Demo_Histogram() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##Histograms")) {
|
if (ImPlot::BeginPlot("##Histograms")) {
|
||||||
ImPlot::SetupAxes(NULL,NULL,ImPlotAxisFlags_AutoFit,ImPlotAxisFlags_AutoFit);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_AutoFit,ImPlotAxisFlags_AutoFit);
|
||||||
ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL,0.5f);
|
ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL,0.5f);
|
||||||
ImPlot::PlotHistogram("Empirical", dist.Data, 10000, bins, 1.0, range ? ImPlotRange(rmin,rmax) : ImPlotRange(), hist_flags);
|
ImPlot::PlotHistogram("Empirical", dist.Data, 10000, bins, 1.0, range ? ImPlotRange(rmin,rmax) : ImPlotRange(), hist_flags);
|
||||||
if ((hist_flags & ImPlotHistogramFlags_Density) && !(hist_flags & ImPlotHistogramFlags_NoOutliers)) {
|
if ((hist_flags & ImPlotHistogramFlags_Density) && !(hist_flags & ImPlotHistogramFlags_NoOutliers)) {
|
||||||
|
@ -788,7 +788,7 @@ void Demo_Histogram2D() {
|
||||||
ImPlotAxisFlags flags = ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_Foreground;
|
ImPlotAxisFlags flags = ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_Foreground;
|
||||||
ImPlot::PushColormap("Hot");
|
ImPlot::PushColormap("Hot");
|
||||||
if (ImPlot::BeginPlot("##Hist2D",ImVec2(ImGui::GetContentRegionAvail().x-100-ImGui::GetStyle().ItemSpacing.x,0))) {
|
if (ImPlot::BeginPlot("##Hist2D",ImVec2(ImGui::GetContentRegionAvail().x-100-ImGui::GetStyle().ItemSpacing.x,0))) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, flags, flags);
|
ImPlot::SetupAxes(nullptr, nullptr, flags, flags);
|
||||||
ImPlot::SetupAxesLimits(-6,6,-6,6);
|
ImPlot::SetupAxesLimits(-6,6,-6,6);
|
||||||
max_count = ImPlot::PlotHistogram2D("Hist2D",dist1.Data,dist2.Data,count,xybins[0],xybins[1],ImPlotRect(-6,6,-6,6), hist_flags);
|
max_count = ImPlot::PlotHistogram2D("Hist2D",dist1.Data,dist2.Data,count,xybins[0],xybins[1],ImPlotRect(-6,6,-6,6), hist_flags);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
|
@ -837,13 +837,13 @@ void Demo_DigitalPlots() {
|
||||||
ImPlot::SetupAxisLimits(ImAxis_Y1, -1, 1);
|
ImPlot::SetupAxisLimits(ImAxis_Y1, -1, 1);
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
if (showDigital[i] && dataDigital[i].Data.size() > 0) {
|
if (showDigital[i] && dataDigital[i].Data.size() > 0) {
|
||||||
sprintf(label, "digital_%d", i);
|
snprintf(label, sizeof(label), "digital_%d", i);
|
||||||
ImPlot::PlotDigital(label, &dataDigital[i].Data[0].x, &dataDigital[i].Data[0].y, dataDigital[i].Data.size(), 0, dataDigital[i].Offset, 2 * sizeof(float));
|
ImPlot::PlotDigital(label, &dataDigital[i].Data[0].x, &dataDigital[i].Data[0].y, dataDigital[i].Data.size(), 0, dataDigital[i].Offset, 2 * sizeof(float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
if (showAnalog[i]) {
|
if (showAnalog[i]) {
|
||||||
sprintf(label, "analog_%d", i);
|
snprintf(label, sizeof(label), "analog_%d", i);
|
||||||
if (dataAnalog[i].Data.size() > 0)
|
if (dataAnalog[i].Data.size() > 0)
|
||||||
ImPlot::PlotLine(label, &dataAnalog[i].Data[0].x, &dataAnalog[i].Data[0].y, dataAnalog[i].Data.size(), 0, dataAnalog[i].Offset, 2 * sizeof(float));
|
ImPlot::PlotLine(label, &dataAnalog[i].Data[0].x, &dataAnalog[i].Data[0].y, dataAnalog[i].Data.size(), 0, dataAnalog[i].Offset, 2 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
@ -897,7 +897,7 @@ void Demo_RealtimePlots() {
|
||||||
static ImPlotAxisFlags flags = ImPlotAxisFlags_NoTickLabels;
|
static ImPlotAxisFlags flags = ImPlotAxisFlags_NoTickLabels;
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##Scrolling", ImVec2(-1,150))) {
|
if (ImPlot::BeginPlot("##Scrolling", ImVec2(-1,150))) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, flags, flags);
|
ImPlot::SetupAxes(nullptr, nullptr, flags, flags);
|
||||||
ImPlot::SetupAxisLimits(ImAxis_X1,t - history, t, ImGuiCond_Always);
|
ImPlot::SetupAxisLimits(ImAxis_X1,t - history, t, ImGuiCond_Always);
|
||||||
ImPlot::SetupAxisLimits(ImAxis_Y1,0,1);
|
ImPlot::SetupAxisLimits(ImAxis_Y1,0,1);
|
||||||
ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL,0.5f);
|
ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL,0.5f);
|
||||||
|
@ -906,7 +906,7 @@ void Demo_RealtimePlots() {
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
if (ImPlot::BeginPlot("##Rolling", ImVec2(-1,150))) {
|
if (ImPlot::BeginPlot("##Rolling", ImVec2(-1,150))) {
|
||||||
ImPlot::SetupAxes(NULL, NULL, flags, flags);
|
ImPlot::SetupAxes(nullptr, nullptr, flags, flags);
|
||||||
ImPlot::SetupAxisLimits(ImAxis_X1,0,history, ImGuiCond_Always);
|
ImPlot::SetupAxisLimits(ImAxis_X1,0,history, ImGuiCond_Always);
|
||||||
ImPlot::SetupAxisLimits(ImAxis_Y1,0,1);
|
ImPlot::SetupAxisLimits(ImAxis_Y1,0,1);
|
||||||
ImPlot::PlotLine("Mouse X", &rdata1.Data[0].x, &rdata1.Data[0].y, rdata1.Data.size(), 0, 0, 2 * sizeof(float));
|
ImPlot::PlotLine("Mouse X", &rdata1.Data[0].x, &rdata1.Data[0].y, rdata1.Data.size(), 0, 0, 2 * sizeof(float));
|
||||||
|
@ -925,7 +925,7 @@ void Demo_MarkersAndText() {
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##MarkerStyles", ImVec2(-1,0), ImPlotFlags_CanvasOnly)) {
|
if (ImPlot::BeginPlot("##MarkerStyles", ImVec2(-1,0), ImPlotFlags_CanvasOnly)) {
|
||||||
|
|
||||||
ImPlot::SetupAxes(NULL, NULL, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
|
||||||
ImPlot::SetupAxesLimits(0, 10, 0, 12);
|
ImPlot::SetupAxesLimits(0, 10, 0, 12);
|
||||||
|
|
||||||
ImS8 xs[2] = {1,4};
|
ImS8 xs[2] = {1,4};
|
||||||
|
@ -1040,8 +1040,8 @@ void Demo_TimeScale() {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox("24 Hour Clock",&ImPlot::GetStyle().Use24HourClock);
|
ImGui::Checkbox("24 Hour Clock",&ImPlot::GetStyle().Use24HourClock);
|
||||||
|
|
||||||
static HugeTimeData* data = NULL;
|
static HugeTimeData* data = nullptr;
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Generate Huge Data (~500MB!)")) {
|
if (ImGui::Button("Generate Huge Data (~500MB!)")) {
|
||||||
static HugeTimeData sdata(t_min);
|
static HugeTimeData sdata(t_min);
|
||||||
|
@ -1052,7 +1052,7 @@ void Demo_TimeScale() {
|
||||||
if (ImPlot::BeginPlot("##Time", ImVec2(-1,0))) {
|
if (ImPlot::BeginPlot("##Time", ImVec2(-1,0))) {
|
||||||
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
|
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
|
||||||
ImPlot::SetupAxesLimits(t_min,t_max,0,1);
|
ImPlot::SetupAxesLimits(t_min,t_max,0,1);
|
||||||
if (data != NULL) {
|
if (data != nullptr) {
|
||||||
// downsample our data
|
// downsample our data
|
||||||
int downsample = (int)ImPlot::GetPlotLimits().X.Size() / 1000 + 1;
|
int downsample = (int)ImPlot::GetPlotLimits().X.Size() / 1000 + 1;
|
||||||
int start = (int)(ImPlot::GetPlotLimits().X.Min - t_min);
|
int start = (int)(ImPlot::GetPlotLimits().X.Min - t_min);
|
||||||
|
@ -1064,7 +1064,7 @@ void Demo_TimeScale() {
|
||||||
ImPlot::PlotLine("Time Series", &data->Ts[start], &data->Ys[start], size, 0, 0, sizeof(double)*downsample);
|
ImPlot::PlotLine("Time Series", &data->Ts[start], &data->Ys[start], size, 0, 0, sizeof(double)*downsample);
|
||||||
}
|
}
|
||||||
// plot time now
|
// plot time now
|
||||||
double t_now = (double)time(0);
|
double t_now = (double)time(nullptr);
|
||||||
double y_now = HugeTimeData::GetY(t_now);
|
double y_now = HugeTimeData::GetY(t_now);
|
||||||
ImPlot::PlotScatter("Now",&t_now,&y_now,1);
|
ImPlot::PlotScatter("Now",&t_now,&y_now,1);
|
||||||
ImPlot::Annotation(t_now,y_now,ImPlot::GetLastItemColor(),ImVec2(10,10),false,"Now");
|
ImPlot::Annotation(t_now,y_now,ImPlot::GetLastItemColor(),ImVec2(10,10),false,"Now");
|
||||||
|
@ -1169,14 +1169,14 @@ void Demo_LinkedAxes() {
|
||||||
|
|
||||||
if (BeginAlignedPlots("AlignedGroup")) {
|
if (BeginAlignedPlots("AlignedGroup")) {
|
||||||
if (ImPlot::BeginPlot("Plot A")) {
|
if (ImPlot::BeginPlot("Plot A")) {
|
||||||
ImPlot::SetupAxisLinks(ImAxis_X1, linkx ? &lims.X.Min : NULL, linkx ? &lims.X.Max : NULL);
|
ImPlot::SetupAxisLinks(ImAxis_X1, linkx ? &lims.X.Min : nullptr, linkx ? &lims.X.Max : nullptr);
|
||||||
ImPlot::SetupAxisLinks(ImAxis_Y1, linky ? &lims.Y.Min : NULL, linky ? &lims.Y.Max : NULL);
|
ImPlot::SetupAxisLinks(ImAxis_Y1, linky ? &lims.Y.Min : nullptr, linky ? &lims.Y.Max : nullptr);
|
||||||
ImPlot::PlotLine("Line",data,2);
|
ImPlot::PlotLine("Line",data,2);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
if (ImPlot::BeginPlot("Plot B")) {
|
if (ImPlot::BeginPlot("Plot B")) {
|
||||||
ImPlot::SetupAxisLinks(ImAxis_X1, linkx ? &lims.X.Min : NULL, linkx ? &lims.X.Max : NULL);
|
ImPlot::SetupAxisLinks(ImAxis_X1, linkx ? &lims.X.Min : nullptr, linkx ? &lims.X.Max : nullptr);
|
||||||
ImPlot::SetupAxisLinks(ImAxis_Y1, linky ? &lims.Y.Min : NULL, linky ? &lims.Y.Max : NULL);
|
ImPlot::SetupAxisLinks(ImAxis_Y1, linky ? &lims.Y.Min : nullptr, linky ? &lims.Y.Max : nullptr);
|
||||||
ImPlot::PlotLine("Line",data,2);
|
ImPlot::PlotLine("Line",data,2);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
|
@ -1215,8 +1215,8 @@ void Demo_EqualAxes() {
|
||||||
float xs2[] = {-1,0,1,0,-1};
|
float xs2[] = {-1,0,1,0,-1};
|
||||||
float ys2[] = {0,1,0,-1,0};
|
float ys2[] = {0,1,0,-1,0};
|
||||||
if (ImPlot::BeginPlot("##EqualAxes",ImVec2(-1,0),ImPlotFlags_Equal)) {
|
if (ImPlot::BeginPlot("##EqualAxes",ImVec2(-1,0),ImPlotFlags_Equal)) {
|
||||||
ImPlot::SetupAxis(ImAxis_X2, NULL, ImPlotAxisFlags_AuxDefault);
|
ImPlot::SetupAxis(ImAxis_X2, nullptr, ImPlotAxisFlags_AuxDefault);
|
||||||
ImPlot::SetupAxis(ImAxis_Y2, NULL, ImPlotAxisFlags_AuxDefault);
|
ImPlot::SetupAxis(ImAxis_Y2, nullptr, ImPlotAxisFlags_AuxDefault);
|
||||||
ImPlot::PlotLine("Circle",xs1,ys1,360);
|
ImPlot::PlotLine("Circle",xs1,ys1,360);
|
||||||
ImPlot::SetAxes(ImAxis_X2, ImAxis_Y2);
|
ImPlot::SetAxes(ImAxis_X2, ImAxis_Y2);
|
||||||
ImPlot::PlotLine("Diamond",xs2,ys2,5);
|
ImPlot::PlotLine("Diamond",xs2,ys2,5);
|
||||||
|
@ -1274,12 +1274,12 @@ void Demo_SubplotsSizing() {
|
||||||
ImGui::SliderInt("Cols",&cols,1,5);
|
ImGui::SliderInt("Cols",&cols,1,5);
|
||||||
static float rratios[] = {5,1,1,1,1,1};
|
static float rratios[] = {5,1,1,1,1,1};
|
||||||
static float cratios[] = {5,1,1,1,1,1};
|
static float cratios[] = {5,1,1,1,1,1};
|
||||||
ImGui::DragScalarN("Row Ratios",ImGuiDataType_Float,rratios,rows,0.01f,0);
|
ImGui::DragScalarN("Row Ratios",ImGuiDataType_Float,rratios,rows,0.01f,nullptr);
|
||||||
ImGui::DragScalarN("Col Ratios",ImGuiDataType_Float,cratios,cols,0.01f,0);
|
ImGui::DragScalarN("Col Ratios",ImGuiDataType_Float,cratios,cols,0.01f,nullptr);
|
||||||
if (ImPlot::BeginSubplots("My Subplots", rows, cols, ImVec2(-1,400), flags, rratios, cratios)) {
|
if (ImPlot::BeginSubplots("My Subplots", rows, cols, ImVec2(-1,400), flags, rratios, cratios)) {
|
||||||
for (int i = 0; i < rows*cols; ++i) {
|
for (int i = 0; i < rows*cols; ++i) {
|
||||||
if (ImPlot::BeginPlot("",ImVec2(),ImPlotFlags_NoLegend)) {
|
if (ImPlot::BeginPlot("",ImVec2(),ImPlotFlags_NoLegend)) {
|
||||||
ImPlot::SetupAxes(NULL,NULL,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
|
||||||
float fi = 0.01f * (i+1);
|
float fi = 0.01f * (i+1);
|
||||||
ImPlot::SetNextLineStyle(SampleColormap((float)i/(float)(rows*cols-1),ImPlotColormap_Jet));
|
ImPlot::SetNextLineStyle(SampleColormap((float)i/(float)(rows*cols-1),ImPlotColormap_Jet));
|
||||||
ImPlot::PlotLineG("data",SinewaveGetter,&fi,1000);
|
ImPlot::PlotLineG("data",SinewaveGetter,&fi,1000);
|
||||||
|
@ -1310,11 +1310,11 @@ void Demo_SubplotItemSharing() {
|
||||||
if (id[j] == i) {
|
if (id[j] == i) {
|
||||||
char label[8];
|
char label[8];
|
||||||
float fj = 0.01f * (j+2);
|
float fj = 0.01f * (j+2);
|
||||||
sprintf(label, "data%d", j);
|
snprintf(label, sizeof(label), "data%d", j);
|
||||||
ImPlot::PlotLineG(label,SinewaveGetter,&fj,1000);
|
ImPlot::PlotLineG(label,SinewaveGetter,&fj,1000);
|
||||||
if (ImPlot::BeginDragDropSourceItem(label)) {
|
if (ImPlot::BeginDragDropSourceItem(label)) {
|
||||||
curj = j;
|
curj = j;
|
||||||
ImGui::SetDragDropPayload("MY_DND",NULL,0);
|
ImGui::SetDragDropPayload("MY_DND",nullptr,0);
|
||||||
ImPlot::ItemIcon(GetLastItemColor()); ImGui::SameLine();
|
ImPlot::ItemIcon(GetLastItemColor()); ImGui::SameLine();
|
||||||
ImGui::TextUnformatted(label);
|
ImGui::TextUnformatted(label);
|
||||||
ImPlot::EndDragDropSource();
|
ImPlot::EndDragDropSource();
|
||||||
|
@ -1404,7 +1404,7 @@ void Demo_DragPoints() {
|
||||||
ImGui::CheckboxFlags("NoInput", (unsigned int*)&flags, ImPlotDragToolFlags_NoInputs);
|
ImGui::CheckboxFlags("NoInput", (unsigned int*)&flags, ImPlotDragToolFlags_NoInputs);
|
||||||
ImPlotAxisFlags ax_flags = ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoTickMarks;
|
ImPlotAxisFlags ax_flags = ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoTickMarks;
|
||||||
if (ImPlot::BeginPlot("##Bezier",ImVec2(-1,0),ImPlotFlags_CanvasOnly)) {
|
if (ImPlot::BeginPlot("##Bezier",ImVec2(-1,0),ImPlotFlags_CanvasOnly)) {
|
||||||
ImPlot::SetupAxes(0,0,ax_flags,ax_flags);
|
ImPlot::SetupAxes(nullptr,nullptr,ax_flags,ax_flags);
|
||||||
ImPlot::SetupAxesLimits(0,1,0,1);
|
ImPlot::SetupAxesLimits(0,1,0,1);
|
||||||
static ImPlotPoint P[] = {ImPlotPoint(.05f,.05f), ImPlotPoint(0.2,0.4), ImPlotPoint(0.8,0.6), ImPlotPoint(.95f,.95f)};
|
static ImPlotPoint P[] = {ImPlotPoint(.05f,.05f), ImPlotPoint(0.2,0.4), ImPlotPoint(0.8,0.6), ImPlotPoint(.95f,.95f)};
|
||||||
|
|
||||||
|
@ -1492,7 +1492,7 @@ void Demo_DragRects() {
|
||||||
ImGui::CheckboxFlags("NoInput", (unsigned int*)&flags, ImPlotDragToolFlags_NoInputs);
|
ImGui::CheckboxFlags("NoInput", (unsigned int*)&flags, ImPlotDragToolFlags_NoInputs);
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("##Main",ImVec2(-1,150))) {
|
if (ImPlot::BeginPlot("##Main",ImVec2(-1,150))) {
|
||||||
ImPlot::SetupAxes(NULL,NULL,ImPlotAxisFlags_NoTickLabels,ImPlotAxisFlags_NoTickLabels);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_NoTickLabels,ImPlotAxisFlags_NoTickLabels);
|
||||||
ImPlot::SetupAxesLimits(0,0.01,-1,1);
|
ImPlot::SetupAxesLimits(0,0.01,-1,1);
|
||||||
ImPlot::PlotLine("Signal 1", x_data, y_data1, 512);
|
ImPlot::PlotLine("Signal 1", x_data, y_data1, 512);
|
||||||
ImPlot::PlotLine("Signal 2", x_data, y_data2, 512);
|
ImPlot::PlotLine("Signal 2", x_data, y_data2, 512);
|
||||||
|
@ -1501,7 +1501,7 @@ void Demo_DragRects() {
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
if (ImPlot::BeginPlot("##rect",ImVec2(-1,150), ImPlotFlags_CanvasOnly)) {
|
if (ImPlot::BeginPlot("##rect",ImVec2(-1,150), ImPlotFlags_CanvasOnly)) {
|
||||||
ImPlot::SetupAxes(NULL,NULL,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
|
||||||
ImPlot::SetupAxesLimits(rect.X.Min, rect.X.Max, rect.Y.Min, rect.Y.Max, ImGuiCond_Always);
|
ImPlot::SetupAxesLimits(rect.X.Min, rect.X.Max, rect.Y.Min, rect.Y.Max, ImGuiCond_Always);
|
||||||
ImPlot::PlotLine("Signal 1", x_data, y_data1, 512);
|
ImPlot::PlotLine("Signal 1", x_data, y_data1, 512);
|
||||||
ImPlot::PlotLine("Signal 2", x_data, y_data2, 512);
|
ImPlot::PlotLine("Signal 2", x_data, y_data2, 512);
|
||||||
|
@ -1665,7 +1665,7 @@ void Demo_DragAndDrop() {
|
||||||
Idx = i++;
|
Idx = i++;
|
||||||
Plt = 0;
|
Plt = 0;
|
||||||
Yax = ImAxis_Y1;
|
Yax = ImAxis_Y1;
|
||||||
sprintf(Label, "%02d Hz", Idx+1);
|
snprintf(Label, sizeof(Label), "%02d Hz", Idx+1);
|
||||||
Color = RandomColor();
|
Color = RandomColor();
|
||||||
Data.reserve(1001);
|
Data.reserve(1001);
|
||||||
for (int k = 0; k < 1001; ++k) {
|
for (int k = 0; k < 1001; ++k) {
|
||||||
|
@ -1678,15 +1678,15 @@ void Demo_DragAndDrop() {
|
||||||
|
|
||||||
const int k_dnd = 20;
|
const int k_dnd = 20;
|
||||||
static MyDndItem dnd[k_dnd];
|
static MyDndItem dnd[k_dnd];
|
||||||
static MyDndItem* dndx = NULL; // for plot 2
|
static MyDndItem* dndx = nullptr; // for plot 2
|
||||||
static MyDndItem* dndy = NULL; // for plot 2
|
static MyDndItem* dndy = nullptr; // for plot 2
|
||||||
|
|
||||||
// child window to serve as initial source for our DND items
|
// child window to serve as initial source for our DND items
|
||||||
ImGui::BeginChild("DND_LEFT",ImVec2(100,400));
|
ImGui::BeginChild("DND_LEFT",ImVec2(100,400));
|
||||||
if (ImGui::Button("Reset Data")) {
|
if (ImGui::Button("Reset Data")) {
|
||||||
for (int k = 0; k < k_dnd; ++k)
|
for (int k = 0; k < k_dnd; ++k)
|
||||||
dnd[k].Reset();
|
dnd[k].Reset();
|
||||||
dndx = dndy = NULL;
|
dndx = dndy = nullptr;
|
||||||
}
|
}
|
||||||
for (int k = 0; k < k_dnd; ++k) {
|
for (int k = 0; k < k_dnd; ++k) {
|
||||||
if (dnd[k].Plt > 0)
|
if (dnd[k].Plt > 0)
|
||||||
|
@ -1713,7 +1713,7 @@ void Demo_DragAndDrop() {
|
||||||
// plot 1 (time series)
|
// plot 1 (time series)
|
||||||
ImPlotAxisFlags flags = ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoHighlight;
|
ImPlotAxisFlags flags = ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoHighlight;
|
||||||
if (ImPlot::BeginPlot("##DND1", ImVec2(-1,195))) {
|
if (ImPlot::BeginPlot("##DND1", ImVec2(-1,195))) {
|
||||||
ImPlot::SetupAxis(ImAxis_X1, NULL, flags|ImPlotAxisFlags_Lock);
|
ImPlot::SetupAxis(ImAxis_X1, nullptr, flags|ImPlotAxisFlags_Lock);
|
||||||
ImPlot::SetupAxis(ImAxis_Y1, "[drop here]", flags);
|
ImPlot::SetupAxis(ImAxis_Y1, "[drop here]", flags);
|
||||||
ImPlot::SetupAxis(ImAxis_Y2, "[drop here]", flags|ImPlotAxisFlags_Opposite);
|
ImPlot::SetupAxis(ImAxis_Y2, "[drop here]", flags|ImPlotAxisFlags_Opposite);
|
||||||
ImPlot::SetupAxis(ImAxis_Y3, "[drop here]", flags|ImPlotAxisFlags_Opposite);
|
ImPlot::SetupAxis(ImAxis_Y3, "[drop here]", flags|ImPlotAxisFlags_Opposite);
|
||||||
|
@ -1759,12 +1759,12 @@ void Demo_DragAndDrop() {
|
||||||
}
|
}
|
||||||
// plot 2 (Lissajous)
|
// plot 2 (Lissajous)
|
||||||
if (ImPlot::BeginPlot("##DND2", ImVec2(-1,195))) {
|
if (ImPlot::BeginPlot("##DND2", ImVec2(-1,195))) {
|
||||||
ImPlot::PushStyleColor(ImPlotCol_AxisBg, dndx != NULL ? dndx->Color : ImPlot::GetStyle().Colors[ImPlotCol_AxisBg]);
|
ImPlot::PushStyleColor(ImPlotCol_AxisBg, dndx != nullptr ? dndx->Color : ImPlot::GetStyle().Colors[ImPlotCol_AxisBg]);
|
||||||
ImPlot::SetupAxis(ImAxis_X1, dndx == NULL ? "[drop here]" : dndx->Label, flags);
|
ImPlot::SetupAxis(ImAxis_X1, dndx == nullptr ? "[drop here]" : dndx->Label, flags);
|
||||||
ImPlot::PushStyleColor(ImPlotCol_AxisBg, dndy != NULL ? dndy->Color : ImPlot::GetStyle().Colors[ImPlotCol_AxisBg]);
|
ImPlot::PushStyleColor(ImPlotCol_AxisBg, dndy != nullptr ? dndy->Color : ImPlot::GetStyle().Colors[ImPlotCol_AxisBg]);
|
||||||
ImPlot::SetupAxis(ImAxis_Y1, dndy == NULL ? "[drop here]" : dndy->Label, flags);
|
ImPlot::SetupAxis(ImAxis_Y1, dndy == nullptr ? "[drop here]" : dndy->Label, flags);
|
||||||
ImPlot::PopStyleColor(2);
|
ImPlot::PopStyleColor(2);
|
||||||
if (dndx != NULL && dndy != NULL) {
|
if (dndx != nullptr && dndy != nullptr) {
|
||||||
ImVec4 mixed((dndx->Color.x + dndy->Color.x)/2,(dndx->Color.y + dndy->Color.y)/2,(dndx->Color.z + dndy->Color.z)/2,(dndx->Color.w + dndy->Color.w)/2);
|
ImVec4 mixed((dndx->Color.x + dndy->Color.x)/2,(dndx->Color.y + dndy->Color.y)/2,(dndx->Color.z + dndy->Color.z)/2,(dndx->Color.w + dndy->Color.w)/2);
|
||||||
ImPlot::SetNextLineStyle(mixed);
|
ImPlot::SetNextLineStyle(mixed);
|
||||||
ImPlot::PlotLine("##dndxy", &dndx->Data[0].y, &dndy->Data[0].y, dndx->Data.size(), 0, 0, 2 * sizeof(float));
|
ImPlot::PlotLine("##dndxy", &dndx->Data[0].y, &dndy->Data[0].y, dndx->Data.size(), 0, 0, 2 * sizeof(float));
|
||||||
|
@ -1777,7 +1777,7 @@ void Demo_DragAndDrop() {
|
||||||
ImPlot::EndDragDropTarget();
|
ImPlot::EndDragDropTarget();
|
||||||
}
|
}
|
||||||
// allow the x-axis to be a DND source
|
// allow the x-axis to be a DND source
|
||||||
if (dndx != NULL && ImPlot::BeginDragDropSourceAxis(ImAxis_X1)) {
|
if (dndx != nullptr && ImPlot::BeginDragDropSourceAxis(ImAxis_X1)) {
|
||||||
ImGui::SetDragDropPayload("MY_DND", &dndx->Idx, sizeof(int));
|
ImGui::SetDragDropPayload("MY_DND", &dndx->Idx, sizeof(int));
|
||||||
ImPlot::ItemIcon(dndx->Color); ImGui::SameLine();
|
ImPlot::ItemIcon(dndx->Color); ImGui::SameLine();
|
||||||
ImGui::TextUnformatted(dndx->Label);
|
ImGui::TextUnformatted(dndx->Label);
|
||||||
|
@ -1791,7 +1791,7 @@ void Demo_DragAndDrop() {
|
||||||
ImPlot::EndDragDropTarget();
|
ImPlot::EndDragDropTarget();
|
||||||
}
|
}
|
||||||
// allow the y-axis to be a DND source
|
// allow the y-axis to be a DND source
|
||||||
if (dndy != NULL && ImPlot::BeginDragDropSourceAxis(ImAxis_Y1)) {
|
if (dndy != nullptr && ImPlot::BeginDragDropSourceAxis(ImAxis_Y1)) {
|
||||||
ImGui::SetDragDropPayload("MY_DND", &dndy->Idx, sizeof(int));
|
ImGui::SetDragDropPayload("MY_DND", &dndy->Idx, sizeof(int));
|
||||||
ImPlot::ItemIcon(dndy->Color); ImGui::SameLine();
|
ImPlot::ItemIcon(dndy->Color); ImGui::SameLine();
|
||||||
ImGui::TextUnformatted(dndy->Label);
|
ImGui::TextUnformatted(dndy->Label);
|
||||||
|
@ -1878,9 +1878,9 @@ void Demo_OffsetAndStride() {
|
||||||
ImGui::SliderInt("Offset", &offset, -2*k_points_per, 2*k_points_per);
|
ImGui::SliderInt("Offset", &offset, -2*k_points_per, 2*k_points_per);
|
||||||
if (ImPlot::BeginPlot("##strideoffset",ImVec2(-1,0),ImPlotFlags_Equal)) {
|
if (ImPlot::BeginPlot("##strideoffset",ImVec2(-1,0),ImPlotFlags_Equal)) {
|
||||||
ImPlot::PushColormap(ImPlotColormap_Jet);
|
ImPlot::PushColormap(ImPlotColormap_Jet);
|
||||||
char buff[16];
|
char buff[32];
|
||||||
for (int c = 0; c < k_circles; ++c) {
|
for (int c = 0; c < k_circles; ++c) {
|
||||||
sprintf(buff, "Circle %d", c);
|
snprintf(buff, sizeof(buff), "Circle %d", c);
|
||||||
ImPlot::PlotLine(buff, &interleaved_data[c*2 + 0], &interleaved_data[c*2 + 1], k_points_per, 0, offset, 2*k_circles*sizeof(double));
|
ImPlot::PlotLine(buff, &interleaved_data[c*2 + 0], &interleaved_data[c*2 + 1], k_points_per, 0, offset, 2*k_circles*sizeof(double));
|
||||||
}
|
}
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
|
@ -1907,7 +1907,7 @@ void Demo_CustomDataAndGetters() {
|
||||||
ImPlot::PlotLine("Vector2f", &vec2_data[0].x, &vec2_data[0].y, 2, 0, 0, sizeof(MyImPlot::Vector2f) /* or sizeof(float) * 2 */);
|
ImPlot::PlotLine("Vector2f", &vec2_data[0].x, &vec2_data[0].y, 2, 0, 0, sizeof(MyImPlot::Vector2f) /* or sizeof(float) * 2 */);
|
||||||
|
|
||||||
// custom getter example 1:
|
// custom getter example 1:
|
||||||
ImPlot::PlotLineG("Spiral", MyImPlot::Spiral, NULL, 1000);
|
ImPlot::PlotLineG("Spiral", MyImPlot::Spiral, nullptr, 1000);
|
||||||
|
|
||||||
// custom getter example 2:
|
// custom getter example 2:
|
||||||
static MyImPlot::WaveData data1(0.001, 0.2, 2, 0.75);
|
static MyImPlot::WaveData data1(0.001, 0.2, 2, 0.75);
|
||||||
|
@ -1962,8 +1962,8 @@ void Demo_TickLabels() {
|
||||||
static const char* ylabels_aux[] = {"A","B","C","D","E","F"};
|
static const char* ylabels_aux[] = {"A","B","C","D","E","F"};
|
||||||
if (ImPlot::BeginPlot("##Ticks")) {
|
if (ImPlot::BeginPlot("##Ticks")) {
|
||||||
ImPlot::SetupAxesLimits(2.5,5,0,1000);
|
ImPlot::SetupAxesLimits(2.5,5,0,1000);
|
||||||
ImPlot::SetupAxis(ImAxis_Y2, NULL, ImPlotAxisFlags_AuxDefault);
|
ImPlot::SetupAxis(ImAxis_Y2, nullptr, ImPlotAxisFlags_AuxDefault);
|
||||||
ImPlot::SetupAxis(ImAxis_Y3, NULL, ImPlotAxisFlags_AuxDefault);
|
ImPlot::SetupAxis(ImAxis_Y3, nullptr, ImPlotAxisFlags_AuxDefault);
|
||||||
if (custom_fmt) {
|
if (custom_fmt) {
|
||||||
ImPlot::SetupAxisFormat(ImAxis_X1, "%g ms");
|
ImPlot::SetupAxisFormat(ImAxis_X1, "%g ms");
|
||||||
ImPlot::SetupAxisFormat(ImAxis_Y1, MetricFormatter, (void*)"Hz");
|
ImPlot::SetupAxisFormat(ImAxis_Y1, MetricFormatter, (void*)"Hz");
|
||||||
|
@ -1971,10 +1971,10 @@ void Demo_TickLabels() {
|
||||||
ImPlot::SetupAxisFormat(ImAxis_Y3, MetricFormatter, (void*)"m");
|
ImPlot::SetupAxisFormat(ImAxis_Y3, MetricFormatter, (void*)"m");
|
||||||
}
|
}
|
||||||
if (custom_ticks) {
|
if (custom_ticks) {
|
||||||
ImPlot::SetupAxisTicks(ImAxis_X1, &pi,1,custom_labels ? pi_str : NULL, true);
|
ImPlot::SetupAxisTicks(ImAxis_X1, &pi,1,custom_labels ? pi_str : nullptr, true);
|
||||||
ImPlot::SetupAxisTicks(ImAxis_Y1, yticks, 4, custom_labels ? ylabels : NULL, false);
|
ImPlot::SetupAxisTicks(ImAxis_Y1, yticks, 4, custom_labels ? ylabels : nullptr, false);
|
||||||
ImPlot::SetupAxisTicks(ImAxis_Y2, yticks_aux, 3, custom_labels ? ylabels_aux : NULL, false);
|
ImPlot::SetupAxisTicks(ImAxis_Y2, yticks_aux, 3, custom_labels ? ylabels_aux : nullptr, false);
|
||||||
ImPlot::SetupAxisTicks(ImAxis_Y3, 0, 1, 6, custom_labels ? ylabels_aux : NULL, false);
|
ImPlot::SetupAxisTicks(ImAxis_Y3, 0, 1, 6, custom_labels ? ylabels_aux : nullptr, false);
|
||||||
}
|
}
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
|
@ -2116,7 +2116,7 @@ void Demo_CustomPlottersAndTooltips() {
|
||||||
ImPlot::GetStyle().UseLocalTime = false;
|
ImPlot::GetStyle().UseLocalTime = false;
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("Candlestick Chart",ImVec2(-1,0))) {
|
if (ImPlot::BeginPlot("Candlestick Chart",ImVec2(-1,0))) {
|
||||||
ImPlot::SetupAxes(NULL,NULL,0,ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_RangeFit);
|
ImPlot::SetupAxes(nullptr,nullptr,0,ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_RangeFit);
|
||||||
ImPlot::SetupAxesLimits(1546300800, 1571961600, 1250, 1600);
|
ImPlot::SetupAxesLimits(1546300800, 1571961600, 1250, 1600);
|
||||||
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
|
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
|
||||||
ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 1546300800, 1571961600);
|
ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 1546300800, 1571961600);
|
||||||
|
@ -2170,12 +2170,12 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
ImGui::Begin("ImPlot Demo", p_open, ImGuiWindowFlags_MenuBar);
|
ImGui::Begin("ImPlot Demo", p_open, ImGuiWindowFlags_MenuBar);
|
||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
if (ImGui::BeginMenu("Tools")) {
|
if (ImGui::BeginMenu("Tools")) {
|
||||||
ImGui::MenuItem("Metrics", NULL, &show_implot_metrics);
|
ImGui::MenuItem("Metrics", nullptr, &show_implot_metrics);
|
||||||
ImGui::MenuItem("Style Editor", NULL, &show_implot_style_editor);
|
ImGui::MenuItem("Style Editor", nullptr, &show_implot_style_editor);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::MenuItem("ImGui Metrics", NULL, &show_imgui_metrics);
|
ImGui::MenuItem("ImGui Metrics", nullptr, &show_imgui_metrics);
|
||||||
ImGui::MenuItem("ImGui Style Editor", NULL, &show_imgui_style_editor);
|
ImGui::MenuItem("ImGui Style Editor", nullptr, &show_imgui_style_editor);
|
||||||
ImGui::MenuItem("ImGui Demo", NULL, &show_imgui_demo);
|
ImGui::MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
|
@ -2300,7 +2300,7 @@ ImPlotPoint Spiral(int idx, void*) {
|
||||||
void Sparkline(const char* id, const float* values, int count, float min_v, float max_v, int offset, const ImVec4& col, const ImVec2& size) {
|
void Sparkline(const char* id, const float* values, int count, float min_v, float max_v, int offset, const ImVec4& col, const ImVec2& size) {
|
||||||
ImPlot::PushStyleVar(ImPlotStyleVar_PlotPadding, ImVec2(0,0));
|
ImPlot::PushStyleVar(ImPlotStyleVar_PlotPadding, ImVec2(0,0));
|
||||||
if (ImPlot::BeginPlot(id,size,ImPlotFlags_CanvasOnly|ImPlotFlags_NoChild)) {
|
if (ImPlot::BeginPlot(id,size,ImPlotFlags_CanvasOnly|ImPlotFlags_NoChild)) {
|
||||||
ImPlot::SetupAxes(0,0,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
|
ImPlot::SetupAxes(nullptr,nullptr,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
|
||||||
ImPlot::SetupAxesLimits(0, count - 1, min_v, max_v, ImGuiCond_Always);
|
ImPlot::SetupAxesLimits(0, count - 1, min_v, max_v, ImGuiCond_Always);
|
||||||
ImPlot::SetNextLineStyle(col);
|
ImPlot::SetNextLineStyle(col);
|
||||||
ImPlot::SetNextFillStyle(col, 0.25);
|
ImPlot::SetNextFillStyle(col, 0.25);
|
||||||
|
|
|
@ -31,10 +31,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
|
||||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
|
@ -400,18 +396,18 @@ struct ImPlotColormapData {
|
||||||
_AppendTable(i);
|
_AppendTable(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsQual(ImPlotColormap cmap) const { return Quals[cmap]; }
|
inline bool IsQual(ImPlotColormap cmap) const { return Quals[cmap]; }
|
||||||
inline const char* GetName(ImPlotColormap cmap) const { return cmap < Count ? Text.Buf.Data + TextOffsets[cmap] : NULL; }
|
inline const char* GetName(ImPlotColormap cmap) const { return cmap < Count ? Text.Buf.Data + TextOffsets[cmap] : nullptr; }
|
||||||
inline ImPlotColormap GetIndex(const char* name) const { ImGuiID key = ImHashStr(name); return Map.GetInt(key,-1); }
|
inline ImPlotColormap GetIndex(const char* name) const { ImGuiID key = ImHashStr(name); return Map.GetInt(key,-1); }
|
||||||
|
|
||||||
inline const ImU32* GetKeys(ImPlotColormap cmap) const { return &Keys[KeyOffsets[cmap]]; }
|
inline const ImU32* GetKeys(ImPlotColormap cmap) const { return &Keys[KeyOffsets[cmap]]; }
|
||||||
inline int GetKeyCount(ImPlotColormap cmap) const { return KeyCounts[cmap]; }
|
inline int GetKeyCount(ImPlotColormap cmap) const { return KeyCounts[cmap]; }
|
||||||
inline ImU32 GetKeyColor(ImPlotColormap cmap, int idx) const { return Keys[KeyOffsets[cmap]+idx]; }
|
inline ImU32 GetKeyColor(ImPlotColormap cmap, int idx) const { return Keys[KeyOffsets[cmap]+idx]; }
|
||||||
inline void SetKeyColor(ImPlotColormap cmap, int idx, ImU32 value) { Keys[KeyOffsets[cmap]+idx] = value; RebuildTables(); }
|
inline void SetKeyColor(ImPlotColormap cmap, int idx, ImU32 value) { Keys[KeyOffsets[cmap]+idx] = value; RebuildTables(); }
|
||||||
|
|
||||||
inline const ImU32* GetTable(ImPlotColormap cmap) const { return &Tables[TableOffsets[cmap]]; }
|
inline const ImU32* GetTable(ImPlotColormap cmap) const { return &Tables[TableOffsets[cmap]]; }
|
||||||
inline int GetTableSize(ImPlotColormap cmap) const { return TableSizes[cmap]; }
|
inline int GetTableSize(ImPlotColormap cmap) const { return TableSizes[cmap]; }
|
||||||
inline ImU32 GetTableColor(ImPlotColormap cmap, int idx) const { return Tables[TableOffsets[cmap]+idx]; }
|
inline ImU32 GetTableColor(ImPlotColormap cmap, int idx) const { return Tables[TableOffsets[cmap]+idx]; }
|
||||||
|
|
||||||
inline ImU32 LerpTable(ImPlotColormap cmap, float t) const {
|
inline ImU32 LerpTable(ImPlotColormap cmap, float t) const {
|
||||||
int off = TableOffsets[cmap];
|
int off = TableOffsets[cmap];
|
||||||
|
@ -568,7 +564,7 @@ struct ImPlotTicker {
|
||||||
|
|
||||||
ImPlotTick& AddTick(double value, bool major, int level, bool show_label, const char* label) {
|
ImPlotTick& AddTick(double value, bool major, int level, bool show_label, const char* label) {
|
||||||
ImPlotTick tick(value, major, level, show_label);
|
ImPlotTick tick(value, major, level, show_label);
|
||||||
if (show_label && label != NULL) {
|
if (show_label && label != nullptr) {
|
||||||
tick.TextOffset = TextBuffer.size();
|
tick.TextOffset = TextBuffer.size();
|
||||||
TextBuffer.append(label, label + strlen(label) + 1);
|
TextBuffer.append(label, label + strlen(label) + 1);
|
||||||
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
|
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
|
||||||
|
@ -578,7 +574,7 @@ struct ImPlotTicker {
|
||||||
|
|
||||||
ImPlotTick& AddTick(double value, bool major, int level, bool show_label, ImPlotFormatter formatter, void* data) {
|
ImPlotTick& AddTick(double value, bool major, int level, bool show_label, ImPlotFormatter formatter, void* data) {
|
||||||
ImPlotTick tick(value, major, level, show_label);
|
ImPlotTick tick(value, major, level, show_label);
|
||||||
if (show_label && formatter != NULL) {
|
if (show_label && formatter != nullptr) {
|
||||||
char buff[IMPLOT_LABEL_MAX_SIZE];
|
char buff[IMPLOT_LABEL_MAX_SIZE];
|
||||||
tick.TextOffset = TextBuffer.size();
|
tick.TextOffset = TextBuffer.size();
|
||||||
formatter(tick.PlotPos, buff, sizeof(buff), data);
|
formatter(tick.PlotPos, buff, sizeof(buff), data);
|
||||||
|
@ -677,23 +673,23 @@ struct ImPlotAxis
|
||||||
Range.Min = 0;
|
Range.Min = 0;
|
||||||
Range.Max = 1;
|
Range.Max = 1;
|
||||||
Scale = ImPlotScale_Linear;
|
Scale = ImPlotScale_Linear;
|
||||||
TransformForward = TransformInverse = NULL;
|
TransformForward = TransformInverse = nullptr;
|
||||||
TransformData = NULL;
|
TransformData = nullptr;
|
||||||
FitExtents.Min = HUGE_VAL;
|
FitExtents.Min = HUGE_VAL;
|
||||||
FitExtents.Max = -HUGE_VAL;
|
FitExtents.Max = -HUGE_VAL;
|
||||||
OrthoAxis = NULL;
|
OrthoAxis = nullptr;
|
||||||
ConstraintRange = ImPlotRange(-INFINITY,INFINITY);
|
ConstraintRange = ImPlotRange(-INFINITY,INFINITY);
|
||||||
ConstraintZoom = ImPlotRange(DBL_MIN,INFINITY);
|
ConstraintZoom = ImPlotRange(DBL_MIN,INFINITY);
|
||||||
LinkedMin = LinkedMax = NULL;
|
LinkedMin = LinkedMax = nullptr;
|
||||||
PickerLevel = 0;
|
PickerLevel = 0;
|
||||||
Datum1 = Datum2 = 0;
|
Datum1 = Datum2 = 0;
|
||||||
PixelMin = PixelMax = 0;
|
PixelMin = PixelMax = 0;
|
||||||
LabelOffset = -1;
|
LabelOffset = -1;
|
||||||
ColorMaj = ColorMin = ColorTick = ColorTxt = ColorBg = ColorHov = ColorAct = 0;
|
ColorMaj = ColorMin = ColorTick = ColorTxt = ColorBg = ColorHov = ColorAct = 0;
|
||||||
ColorHiLi = IM_COL32_BLACK_TRANS;
|
ColorHiLi = IM_COL32_BLACK_TRANS;
|
||||||
Formatter = NULL;
|
Formatter = nullptr;
|
||||||
FormatterData = NULL;
|
FormatterData = nullptr;
|
||||||
Locator = NULL;
|
Locator = nullptr;
|
||||||
Enabled = Hovered = Held = FitThisFrame = HasRange = HasFormatSpec = false;
|
Enabled = Hovered = Held = FitThisFrame = HasRange = HasFormatSpec = false;
|
||||||
ShowDefaultTicks = true;
|
ShowDefaultTicks = true;
|
||||||
}
|
}
|
||||||
|
@ -701,18 +697,18 @@ struct ImPlotAxis
|
||||||
inline void Reset() {
|
inline void Reset() {
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
Scale = ImPlotScale_Linear;
|
Scale = ImPlotScale_Linear;
|
||||||
TransformForward = TransformInverse = NULL;
|
TransformForward = TransformInverse = nullptr;
|
||||||
TransformData = NULL;
|
TransformData = nullptr;
|
||||||
LabelOffset = -1;
|
LabelOffset = -1;
|
||||||
HasFormatSpec = false;
|
HasFormatSpec = false;
|
||||||
Formatter = NULL;
|
Formatter = nullptr;
|
||||||
FormatterData = NULL;
|
FormatterData = nullptr;
|
||||||
Locator = NULL;
|
Locator = nullptr;
|
||||||
ShowDefaultTicks = true;
|
ShowDefaultTicks = true;
|
||||||
FitThisFrame = false;
|
FitThisFrame = false;
|
||||||
FitExtents.Min = HUGE_VAL;
|
FitExtents.Min = HUGE_VAL;
|
||||||
FitExtents.Max = -HUGE_VAL;
|
FitExtents.Max = -HUGE_VAL;
|
||||||
OrthoAxis = NULL;
|
OrthoAxis = nullptr;
|
||||||
ConstraintRange = ImPlotRange(-INFINITY,INFINITY);
|
ConstraintRange = ImPlotRange(-INFINITY,INFINITY);
|
||||||
ConstraintZoom = ImPlotRange(DBL_MIN,INFINITY);
|
ConstraintZoom = ImPlotRange(DBL_MIN,INFINITY);
|
||||||
Ticker.Reset();
|
Ticker.Reset();
|
||||||
|
@ -810,7 +806,7 @@ struct ImPlotAxis
|
||||||
|
|
||||||
inline void UpdateTransformCache() {
|
inline void UpdateTransformCache() {
|
||||||
ScaleToPixel = (PixelMax - PixelMin) / Range.Size();
|
ScaleToPixel = (PixelMax - PixelMin) / Range.Size();
|
||||||
if (TransformForward != NULL) {
|
if (TransformForward != nullptr) {
|
||||||
ScaleMin = TransformForward(Range.Min, TransformData);
|
ScaleMin = TransformForward(Range.Min, TransformData);
|
||||||
ScaleMax = TransformForward(Range.Max, TransformData);
|
ScaleMax = TransformForward(Range.Max, TransformData);
|
||||||
}
|
}
|
||||||
|
@ -821,7 +817,7 @@ struct ImPlotAxis
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float PlotToPixels(double plt) const {
|
inline float PlotToPixels(double plt) const {
|
||||||
if (TransformForward != NULL) {
|
if (TransformForward != nullptr) {
|
||||||
double s = TransformForward(plt, TransformData);
|
double s = TransformForward(plt, TransformData);
|
||||||
double t = (s - ScaleMin) / (ScaleMax - ScaleMin);
|
double t = (s - ScaleMin) / (ScaleMax - ScaleMin);
|
||||||
plt = Range.Min + Range.Size() * t;
|
plt = Range.Min + Range.Size() * t;
|
||||||
|
@ -832,7 +828,7 @@ struct ImPlotAxis
|
||||||
|
|
||||||
inline double PixelsToPlot(float pix) const {
|
inline double PixelsToPlot(float pix) const {
|
||||||
double plt = (pix - PixelMin) / ScaleToPixel + Range.Min;
|
double plt = (pix - PixelMin) / ScaleToPixel + Range.Min;
|
||||||
if (TransformInverse != NULL) {
|
if (TransformInverse != nullptr) {
|
||||||
double t = (plt - Range.Min) / Range.Size();
|
double t = (plt - Range.Min) / Range.Size();
|
||||||
double s = t * (ScaleMax - ScaleMin) + ScaleMin;
|
double s = t * (ScaleMax - ScaleMin) + ScaleMin;
|
||||||
plt = TransformInverse(s, TransformData);
|
plt = TransformInverse(s, TransformData);
|
||||||
|
@ -1071,7 +1067,7 @@ struct ImPlotPlot
|
||||||
inline void ClearTextBuffer() { TextBuffer.Buf.shrink(0); }
|
inline void ClearTextBuffer() { TextBuffer.Buf.shrink(0); }
|
||||||
|
|
||||||
inline void SetTitle(const char* title) {
|
inline void SetTitle(const char* title) {
|
||||||
if (title && ImGui::FindRenderedTextEnd(title, NULL) != title) {
|
if (title && ImGui::FindRenderedTextEnd(title, nullptr) != title) {
|
||||||
TitleOffset = TextBuffer.size();
|
TitleOffset = TextBuffer.size();
|
||||||
TextBuffer.append(title, title + strlen(title) + 1);
|
TextBuffer.append(title, title + strlen(title) + 1);
|
||||||
}
|
}
|
||||||
|
@ -1102,7 +1098,7 @@ struct ImPlotPlot
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SetAxisLabel(ImPlotAxis& axis, const char* label) {
|
inline void SetAxisLabel(ImPlotAxis& axis, const char* label) {
|
||||||
if (label && ImGui::FindRenderedTextEnd(label, NULL) != label) {
|
if (label && ImGui::FindRenderedTextEnd(label, nullptr) != label) {
|
||||||
axis.LabelOffset = TextBuffer.size();
|
axis.LabelOffset = TextBuffer.size();
|
||||||
TextBuffer.append(label, label + strlen(label) + 1);
|
TextBuffer.append(label, label + strlen(label) + 1);
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1162,7 @@ struct ImPlotNextPlotData
|
||||||
for (int i = 0; i < ImAxis_COUNT; ++i) {
|
for (int i = 0; i < ImAxis_COUNT; ++i) {
|
||||||
HasRange[i] = false;
|
HasRange[i] = false;
|
||||||
Fit[i] = false;
|
Fit[i] = false;
|
||||||
LinkedMin[i] = LinkedMax[i] = NULL;
|
LinkedMin[i] = LinkedMax[i] = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,9 +1288,10 @@ IMPLOT_API void ShowPlotContextMenu(ImPlotPlot& plot);
|
||||||
|
|
||||||
// Lock Setup and call SetupFinish if necessary.
|
// Lock Setup and call SetupFinish if necessary.
|
||||||
static inline void SetupLock() {
|
static inline void SetupLock() {
|
||||||
if (!GImPlot->CurrentPlot->SetupLocked)
|
ImPlotContext& gp = *GImPlot;
|
||||||
|
if (!gp.CurrentPlot->SetupLocked)
|
||||||
SetupFinish();
|
SetupFinish();
|
||||||
GImPlot->CurrentPlot->SetupLocked = true;
|
gp.CurrentPlot->SetupLocked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1330,7 +1327,7 @@ bool BeginItemEx(const char* label_id, const _Fitter& fitter, ImPlotItemFlags fl
|
||||||
IMPLOT_API void EndItem();
|
IMPLOT_API void EndItem();
|
||||||
|
|
||||||
// Register or get an existing item from the current plot.
|
// Register or get an existing item from the current plot.
|
||||||
IMPLOT_API ImPlotItem* RegisterOrGetItem(const char* label_id, ImPlotItemFlags flags, bool* just_created = NULL);
|
IMPLOT_API ImPlotItem* RegisterOrGetItem(const char* label_id, ImPlotItemFlags flags, bool* just_created = nullptr);
|
||||||
// Get a plot item from the current plot.
|
// Get a plot item from the current plot.
|
||||||
IMPLOT_API ImPlotItem* GetItem(const char* label_id);
|
IMPLOT_API ImPlotItem* GetItem(const char* label_id);
|
||||||
// Gets the current item.
|
// Gets the current item.
|
||||||
|
@ -1442,7 +1439,7 @@ static inline const ImPlotNextItemData& GetItemData() { return GImPlot->NextItem
|
||||||
|
|
||||||
// Returns true if a color is set to be automatically determined
|
// Returns true if a color is set to be automatically determined
|
||||||
static inline bool IsColorAuto(const ImVec4& col) { return col.w == -1; }
|
static inline bool IsColorAuto(const ImVec4& col) { return col.w == -1; }
|
||||||
// Returns true if a style color is set to be automaticaly determined
|
// Returns true if a style color is set to be automatically determined
|
||||||
static inline bool IsColorAuto(ImPlotCol idx) { return IsColorAuto(GImPlot->Style.Colors[idx]); }
|
static inline bool IsColorAuto(ImPlotCol idx) { return IsColorAuto(GImPlot->Style.Colors[idx]); }
|
||||||
// Returns the automatically deduced style color
|
// Returns the automatically deduced style color
|
||||||
IMPLOT_API ImVec4 GetAutoColor(ImPlotCol idx);
|
IMPLOT_API ImVec4 GetAutoColor(ImPlotCol idx);
|
||||||
|
@ -1452,9 +1449,9 @@ static inline ImVec4 GetStyleColorVec4(ImPlotCol idx) { return IsColorAuto(idx)
|
||||||
static inline ImU32 GetStyleColorU32(ImPlotCol idx) { return ImGui::ColorConvertFloat4ToU32(GetStyleColorVec4(idx)); }
|
static inline ImU32 GetStyleColorU32(ImPlotCol idx) { return ImGui::ColorConvertFloat4ToU32(GetStyleColorVec4(idx)); }
|
||||||
|
|
||||||
// Draws vertical text. The position is the bottom left of the text rect.
|
// Draws vertical text. The position is the bottom left of the text rect.
|
||||||
IMPLOT_API void AddTextVertical(ImDrawList *DrawList, ImVec2 pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
IMPLOT_API void AddTextVertical(ImDrawList *DrawList, ImVec2 pos, ImU32 col, const char* text_begin, const char* text_end = nullptr);
|
||||||
// Draws multiline horizontal text centered.
|
// Draws multiline horizontal text centered.
|
||||||
IMPLOT_API void AddTextCentered(ImDrawList* DrawList, ImVec2 top_center, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
IMPLOT_API void AddTextCentered(ImDrawList* DrawList, ImVec2 top_center, ImU32 col, const char* text_begin, const char* text_end = nullptr);
|
||||||
// Calculates the size of vertical text
|
// Calculates the size of vertical text
|
||||||
static inline ImVec2 CalcTextSizeVertical(const char *text) {
|
static inline ImVec2 CalcTextSizeVertical(const char *text) {
|
||||||
ImVec2 sz = ImGui::CalcTextSize(text);
|
ImVec2 sz = ImGui::CalcTextSize(text);
|
||||||
|
@ -1593,7 +1590,7 @@ IMPLOT_API int FormatDateTime(const ImPlotTime& t, char* buffer, int size, ImPlo
|
||||||
// #level = 0 for day, 1 for month, 2 for year. Modified by user interaction.
|
// #level = 0 for day, 1 for month, 2 for year. Modified by user interaction.
|
||||||
// #t will be set when a day is clicked and the function will return true.
|
// #t will be set when a day is clicked and the function will return true.
|
||||||
// #t1 and #t2 are optional dates to highlight.
|
// #t1 and #t2 are optional dates to highlight.
|
||||||
IMPLOT_API bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime* t1 = NULL, const ImPlotTime* t2 = NULL);
|
IMPLOT_API bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime* t1 = nullptr, const ImPlotTime* t2 = nullptr);
|
||||||
// Shows a time picker widget block (hour/min/sec).
|
// Shows a time picker widget block (hour/min/sec).
|
||||||
// #t will be set when a new hour, minute, or sec is selected or am/pm is toggled, and the function will return true.
|
// #t will be set when a new hour, minute, or sec is selected or am/pm is toggled, and the function will return true.
|
||||||
IMPLOT_API bool ShowTimePicker(const char* id, ImPlotTime* t);
|
IMPLOT_API bool ShowTimePicker(const char* id, ImPlotTime* t);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
// ImPlot v0.14
|
// ImPlot v0.14
|
||||||
|
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
#include "implot.h"
|
#include "implot.h"
|
||||||
#include "implot_internal.h"
|
#include "implot_internal.h"
|
||||||
|
|
||||||
|
@ -284,15 +285,15 @@ ImPlotItem* RegisterOrGetItem(const char* label_id, ImPlotItemFlags flags, bool*
|
||||||
ImPlotContext& gp = *GImPlot;
|
ImPlotContext& gp = *GImPlot;
|
||||||
ImPlotItemGroup& Items = *gp.CurrentItems;
|
ImPlotItemGroup& Items = *gp.CurrentItems;
|
||||||
ImGuiID id = Items.GetItemID(label_id);
|
ImGuiID id = Items.GetItemID(label_id);
|
||||||
if (just_created != NULL)
|
if (just_created != nullptr)
|
||||||
*just_created = Items.GetItem(id) == NULL;
|
*just_created = Items.GetItem(id) == nullptr;
|
||||||
ImPlotItem* item = Items.GetOrAddItem(id);
|
ImPlotItem* item = Items.GetOrAddItem(id);
|
||||||
if (item->SeenThisFrame)
|
if (item->SeenThisFrame)
|
||||||
return item;
|
return item;
|
||||||
item->SeenThisFrame = true;
|
item->SeenThisFrame = true;
|
||||||
int idx = Items.GetItemIndex(item);
|
int idx = Items.GetItemIndex(item);
|
||||||
item->ID = id;
|
item->ID = id;
|
||||||
if (!ImHasFlag(flags, ImPlotItemFlags_NoLegend) && ImGui::FindRenderedTextEnd(label_id, NULL) != label_id) {
|
if (!ImHasFlag(flags, ImPlotItemFlags_NoLegend) && ImGui::FindRenderedTextEnd(label_id, nullptr) != label_id) {
|
||||||
Items.Legend.Indices.push_back(idx);
|
Items.Legend.Indices.push_back(idx);
|
||||||
item->NameOffset = Items.Legend.Labels.size();
|
item->NameOffset = Items.Legend.Labels.size();
|
||||||
Items.Legend.Labels.append(label_id, label_id + strlen(label_id) + 1);
|
Items.Legend.Labels.append(label_id, label_id + strlen(label_id) + 1);
|
||||||
|
@ -310,7 +311,7 @@ ImPlotItem* GetItem(const char* label_id) {
|
||||||
|
|
||||||
bool IsItemHidden(const char* label_id) {
|
bool IsItemHidden(const char* label_id) {
|
||||||
ImPlotItem* item = GetItem(label_id);
|
ImPlotItem* item = GetItem(label_id);
|
||||||
return item != NULL && !item->Show;
|
return item != nullptr && !item->Show;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImPlotItem* GetCurrentItem() {
|
ImPlotItem* GetCurrentItem() {
|
||||||
|
@ -367,17 +368,17 @@ void BustItemCache() {
|
||||||
|
|
||||||
void BustColorCache(const char* plot_title_id) {
|
void BustColorCache(const char* plot_title_id) {
|
||||||
ImPlotContext& gp = *GImPlot;
|
ImPlotContext& gp = *GImPlot;
|
||||||
if (plot_title_id == NULL) {
|
if (plot_title_id == nullptr) {
|
||||||
BustItemCache();
|
BustItemCache();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImGuiID id = ImGui::GetCurrentWindow()->GetID(plot_title_id);
|
ImGuiID id = ImGui::GetCurrentWindow()->GetID(plot_title_id);
|
||||||
ImPlotPlot* plot = gp.Plots.GetByKey(id);
|
ImPlotPlot* plot = gp.Plots.GetByKey(id);
|
||||||
if (plot != NULL)
|
if (plot != nullptr)
|
||||||
plot->Items.Reset();
|
plot->Items.Reset();
|
||||||
else {
|
else {
|
||||||
ImPlotSubplot* subplot = gp.Subplots.GetByKey(id);
|
ImPlotSubplot* subplot = gp.Subplots.GetByKey(id);
|
||||||
if (subplot != NULL)
|
if (subplot != nullptr)
|
||||||
subplot->Items.Reset();
|
subplot->Items.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +394,7 @@ static const float ITEM_HIGHLIGHT_MARK_SCALE = 1.25f;
|
||||||
// Begins a new item. Returns false if the item should not be plotted.
|
// Begins a new item. Returns false if the item should not be plotted.
|
||||||
bool BeginItem(const char* label_id, ImPlotItemFlags flags, ImPlotCol recolor_from) {
|
bool BeginItem(const char* label_id, ImPlotItemFlags flags, ImPlotCol recolor_from) {
|
||||||
ImPlotContext& gp = *GImPlot;
|
ImPlotContext& gp = *GImPlot;
|
||||||
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotX() needs to be called between BeginPlot() and EndPlot()!");
|
IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr, "PlotX() needs to be called between BeginPlot() and EndPlot()!");
|
||||||
SetupLock();
|
SetupLock();
|
||||||
bool just_created;
|
bool just_created;
|
||||||
ImPlotItem* item = RegisterOrGetItem(label_id, flags, &just_created);
|
ImPlotItem* item = RegisterOrGetItem(label_id, flags, &just_created);
|
||||||
|
@ -421,7 +422,7 @@ bool BeginItem(const char* label_id, ImPlotItemFlags flags, ImPlotCol recolor_fr
|
||||||
// reset next item data
|
// reset next item data
|
||||||
gp.NextItemData.Reset();
|
gp.NextItemData.Reset();
|
||||||
gp.PreviousItem = item;
|
gp.PreviousItem = item;
|
||||||
gp.CurrentItem = NULL;
|
gp.CurrentItem = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -480,7 +481,7 @@ void EndItem() {
|
||||||
gp.NextItemData.Reset();
|
gp.NextItemData.Reset();
|
||||||
// set current item
|
// set current item
|
||||||
gp.PreviousItem = gp.CurrentItem;
|
gp.PreviousItem = gp.CurrentItem;
|
||||||
gp.CurrentItem = NULL;
|
gp.CurrentItem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -784,7 +785,7 @@ struct Transformer1 {
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template <typename T> IMPLOT_INLINE float operator()(T p) const {
|
template <typename T> IMPLOT_INLINE float operator()(T p) const {
|
||||||
if (TransformFwd != NULL) {
|
if (TransformFwd != nullptr) {
|
||||||
double s = TransformFwd(p, TransformData);
|
double s = TransformFwd(p, TransformData);
|
||||||
double t = (s - ScaMin) / (ScaMax - ScaMin);
|
double t = (s - ScaMin) / (ScaMax - ScaMin);
|
||||||
p = PltMin + (PltMax - PltMin) * t;
|
p = PltMin + (PltMax - PltMin) * t;
|
||||||
|
@ -1899,8 +1900,9 @@ void PlotBarGroups(const char* const label_ids[], const T* values, int item_coun
|
||||||
const bool stack = ImHasFlag(flags, ImPlotBarGroupsFlags_Stacked);
|
const bool stack = ImHasFlag(flags, ImPlotBarGroupsFlags_Stacked);
|
||||||
if (stack) {
|
if (stack) {
|
||||||
SetupLock();
|
SetupLock();
|
||||||
GImPlot->TempDouble1.resize(4*group_count);
|
ImPlotContext& gp = *GImPlot;
|
||||||
double* temp = GImPlot->TempDouble1.Data;
|
gp.TempDouble1.resize(4*group_count);
|
||||||
|
double* temp = gp.TempDouble1.Data;
|
||||||
double* neg = &temp[0];
|
double* neg = &temp[0];
|
||||||
double* pos = &temp[group_count];
|
double* pos = &temp[group_count];
|
||||||
double* curr_min = &temp[group_count*2];
|
double* curr_min = &temp[group_count*2];
|
||||||
|
@ -2171,7 +2173,7 @@ IMPLOT_INLINE void RenderPieSlice(ImDrawList& draw_list, const ImPlotPoint& cent
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, const char* fmt, double angle0, ImPlotPieChartFlags flags) {
|
void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, const char* fmt, double angle0, ImPlotPieChartFlags flags) {
|
||||||
IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != NULL, "PlotPieChart() needs to be called between BeginPlot() and EndPlot()!");
|
IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != nullptr, "PlotPieChart() needs to be called between BeginPlot() and EndPlot()!");
|
||||||
ImDrawList & draw_list = *GetPlotDrawList();
|
ImDrawList & draw_list = *GetPlotDrawList();
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
|
@ -2199,7 +2201,7 @@ void PlotPieChart(const char* const label_ids[], const T* values, int count, dou
|
||||||
}
|
}
|
||||||
a0 = a1;
|
a0 = a1;
|
||||||
}
|
}
|
||||||
if (fmt != NULL) {
|
if (fmt != nullptr) {
|
||||||
a0 = angle0 * 2 * IM_PI / 360.0;
|
a0 = angle0 * 2 * IM_PI / 360.0;
|
||||||
a1 = angle0 * 2 * IM_PI / 360.0;
|
a1 = angle0 * 2 * IM_PI / 360.0;
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
@ -2253,7 +2255,8 @@ struct GetterHeatmapRowMaj {
|
||||||
rect.Pos = p;
|
rect.Pos = p;
|
||||||
rect.HalfSize = HalfSize;
|
rect.HalfSize = HalfSize;
|
||||||
const float t = ImClamp((float)ImRemap01(val, ScaleMin, ScaleMax),0.0f,1.0f);
|
const float t = ImClamp((float)ImRemap01(val, ScaleMin, ScaleMax),0.0f,1.0f);
|
||||||
rect.Color = GImPlot->ColormapData.LerpTable(GImPlot->Style.Colormap, t);
|
ImPlotContext& gp = *GImPlot;
|
||||||
|
rect.Color = gp.ColormapData.LerpTable(gp.Style.Colormap, t);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
const T* const Values;
|
const T* const Values;
|
||||||
|
@ -2287,7 +2290,8 @@ struct GetterHeatmapColMaj {
|
||||||
rect.Pos = p;
|
rect.Pos = p;
|
||||||
rect.HalfSize = HalfSize;
|
rect.HalfSize = HalfSize;
|
||||||
const float t = ImClamp((float)ImRemap01(val, ScaleMin, ScaleMax),0.0f,1.0f);
|
const float t = ImClamp((float)ImRemap01(val, ScaleMin, ScaleMax),0.0f,1.0f);
|
||||||
rect.Color = GImPlot->ColormapData.LerpTable(GImPlot->Style.Colormap, t);
|
ImPlotContext& gp = *GImPlot;
|
||||||
|
rect.Color = gp.ColormapData.LerpTable(gp.Style.Colormap, t);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
const T* const Values;
|
const T* const Values;
|
||||||
|
@ -2324,7 +2328,7 @@ void RenderHeatmap(ImDrawList& draw_list, const T* values, int rows, int cols, d
|
||||||
RenderPrimitives1<RendererRectC>(getter);
|
RenderPrimitives1<RendererRectC>(getter);
|
||||||
}
|
}
|
||||||
// labels
|
// labels
|
||||||
if (fmt != NULL) {
|
if (fmt != nullptr) {
|
||||||
const double w = (bounds_max.x - bounds_min.x) / cols;
|
const double w = (bounds_max.x - bounds_min.x) / cols;
|
||||||
const double h = (bounds_max.y - bounds_min.y) / rows;
|
const double h = (bounds_max.y - bounds_min.y) / rows;
|
||||||
const ImPlotPoint half_size(w*0.5,h*0.5);
|
const ImPlotPoint half_size(w*0.5,h*0.5);
|
||||||
|
@ -2408,8 +2412,9 @@ double PlotHistogram(const char* label_id, const T* values, int count, int bins,
|
||||||
else
|
else
|
||||||
width = range.Size() / bins;
|
width = range.Size() / bins;
|
||||||
|
|
||||||
ImVector<double>& bin_centers = GImPlot->TempDouble1;
|
ImPlotContext& gp = *GImPlot;
|
||||||
ImVector<double>& bin_counts = GImPlot->TempDouble2;
|
ImVector<double>& bin_centers = gp.TempDouble1;
|
||||||
|
ImVector<double>& bin_counts = gp.TempDouble2;
|
||||||
bin_centers.resize(bins);
|
bin_centers.resize(bins);
|
||||||
bin_counts.resize(bins);
|
bin_counts.resize(bins);
|
||||||
int below = 0;
|
int below = 0;
|
||||||
|
@ -2506,7 +2511,8 @@ double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count
|
||||||
|
|
||||||
const int bins = x_bins * y_bins;
|
const int bins = x_bins * y_bins;
|
||||||
|
|
||||||
ImVector<double>& bin_counts = GImPlot->TempDouble1;
|
ImPlotContext& gp = *GImPlot;
|
||||||
|
ImVector<double>& bin_counts = gp.TempDouble1;
|
||||||
bin_counts.resize(bins);
|
bin_counts.resize(bins);
|
||||||
|
|
||||||
for (int b = 0; b < bins; ++b)
|
for (int b = 0; b < bins; ++b)
|
||||||
|
@ -2534,7 +2540,7 @@ double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count
|
||||||
|
|
||||||
if (BeginItemEx(label_id, FitterRect(range))) {
|
if (BeginItemEx(label_id, FitterRect(range))) {
|
||||||
ImDrawList& draw_list = *GetPlotDrawList();
|
ImDrawList& draw_list = *GetPlotDrawList();
|
||||||
RenderHeatmap(draw_list, &bin_counts.Data[0], y_bins, x_bins, 0, max_count, NULL, range.Min(), range.Max(), false, col_maj);
|
RenderHeatmap(draw_list, &bin_counts.Data[0], y_bins, x_bins, 0, max_count, nullptr, range.Min(), range.Max(), false, col_maj);
|
||||||
EndItem();
|
EndItem();
|
||||||
}
|
}
|
||||||
return max_count;
|
return max_count;
|
||||||
|
@ -2647,7 +2653,7 @@ void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPo
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void PlotText(const char* text, double x, double y, const ImVec2& pixel_offset, ImPlotTextFlags flags) {
|
void PlotText(const char* text, double x, double y, const ImVec2& pixel_offset, ImPlotTextFlags flags) {
|
||||||
IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != NULL, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
|
IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != nullptr, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
|
||||||
SetupLock();
|
SetupLock();
|
||||||
ImDrawList & draw_list = *GetPlotDrawList();
|
ImDrawList & draw_list = *GetPlotDrawList();
|
||||||
PushPlotClipRect();
|
PushPlotClipRect();
|
||||||
|
@ -2656,7 +2662,7 @@ void PlotText(const char* text, double x, double y, const ImVec2& pixel_offset,
|
||||||
ImVec2 siz = CalcTextSizeVertical(text) * 0.5f;
|
ImVec2 siz = CalcTextSizeVertical(text) * 0.5f;
|
||||||
ImVec2 ctr = siz * 0.5f;
|
ImVec2 ctr = siz * 0.5f;
|
||||||
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) + ImVec2(-ctr.x, ctr.y) + pixel_offset;
|
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) + ImVec2(-ctr.x, ctr.y) + pixel_offset;
|
||||||
if (FitThisFrame()) {
|
if (FitThisFrame() && !ImHasFlag(flags, ImPlotItemFlags_NoFit)) {
|
||||||
FitPoint(PixelsToPlot(pos));
|
FitPoint(PixelsToPlot(pos));
|
||||||
FitPoint(PixelsToPlot(pos.x + siz.x, pos.y - siz.y));
|
FitPoint(PixelsToPlot(pos.x + siz.x, pos.y - siz.y));
|
||||||
}
|
}
|
||||||
|
@ -2665,7 +2671,7 @@ void PlotText(const char* text, double x, double y, const ImVec2& pixel_offset,
|
||||||
else {
|
else {
|
||||||
ImVec2 siz = ImGui::CalcTextSize(text);
|
ImVec2 siz = ImGui::CalcTextSize(text);
|
||||||
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) - siz * 0.5f + pixel_offset;
|
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) - siz * 0.5f + pixel_offset;
|
||||||
if (FitThisFrame()) {
|
if (FitThisFrame() && !ImHasFlag(flags, ImPlotItemFlags_NoFit)) {
|
||||||
FitPoint(PixelsToPlot(pos));
|
FitPoint(PixelsToPlot(pos));
|
||||||
FitPoint(PixelsToPlot(pos+siz));
|
FitPoint(PixelsToPlot(pos+siz));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user