mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 12:18:52 -05:00
Merge branch 'master' into backends
This commit is contained in:
commit
06d7298b48
16
README.md
16
README.md
|
@ -33,7 +33,7 @@ ImPlot is an immediate mode, GPU accelerated plotting library for [Dear ImGui](h
|
||||||
- subplots
|
- subplots
|
||||||
- time formatted x-axes (US formatted or ISO 8601)
|
- time formatted x-axes (US formatted or ISO 8601)
|
||||||
- reversible and lockable axes
|
- reversible and lockable axes
|
||||||
- up to three independent y-axes
|
- multiple x-axes and y-axes
|
||||||
- controls for zooming, panning, box selection, and auto-fitting data
|
- controls for zooming, panning, box selection, and auto-fitting data
|
||||||
- controls for creating persistent query ranges (see demo)
|
- controls for creating persistent query ranges (see demo)
|
||||||
- several plot styling options: 10 marker types, adjustable marker sizes, line weights, outline colors, fill colors, etc.
|
- several plot styling options: 10 marker types, adjustable marker sizes, line weights, outline colors, fill colors, etc.
|
||||||
|
@ -110,20 +110,20 @@ A: ImGui is an incredibly powerful tool for rapid prototyping and development, b
|
||||||
|
|
||||||
**Q: Is ImPlot the right plotting library for me?**
|
**Q: Is ImPlot the right plotting library for me?**
|
||||||
|
|
||||||
A: If you're looking to generate publication quality plots and/or export plots to a file, ImPlot is NOT the library for you. ImPlot is geared toward plotting application data at realtime speeds. ImPlot does its best to create pretty plots (indeed, there are quite a few styling options available), but it will always favor function over form.
|
A: If you're looking to generate publication quality plots and/or export plots to a file, ImPlot is NOT the library for you! ImPlot is geared toward plotting application data at realtime speeds with high levels of interactivity. ImPlot does its best to create pretty plots (indeed, there are quite a few styling options available), but it will always favor function over form.
|
||||||
|
|
||||||
**Q: Where is the documentation?**
|
**Q: Where is the documentation?**
|
||||||
|
|
||||||
A: The API is thoroughly commented in `implot.h`, and the demo in `implot_demo.cpp` should be more than enough to get you started.
|
A: The API is thoroughly commented in `implot.h`, and the demo in `implot_demo.cpp` should be more than enough to get you started. Also take a look at the [implot_demos](https://github.com/epezent/implot_demos) repository.
|
||||||
|
|
||||||
**Q: Is ImPlot suitable for plotting large datasets?**
|
**Q: Is ImPlot suitable for plotting large datasets?**
|
||||||
|
|
||||||
A: Yes, within reason. You can plot tens to hundreds of thousands of points without issue, but don't expect millions to be a buttery smooth experience. That said, you can always downsample extremely large datasets by telling ImPlot to stride your data at larger intervals if needed.
|
A: Yes, within reason. You can plot tens to hundreds of thousands of points without issue, but don't expect millions to be a buttery smooth experience. That said, you can always downsample extremely large datasets by telling ImPlot to stride your data at larger intervals if needed. Also try the experimental `backends` branch which aims to provide GPU acceleration support.
|
||||||
|
|
||||||
**Q: What data types can I plot?**
|
**Q: What data types can I plot?**
|
||||||
|
|
||||||
A: ImPlot plotting functions accept most scalar types:
|
A: ImPlot plotting functions accept most scalar types:
|
||||||
`float`, `double`, `int8`, `uint8`, `int16`, `uint16`, `int32`, `uint32`, `int64`, `uint64`. Arrays of custom structs or classes (e.g. `Vector2f` or similar) are easily passed to ImPlot functions using the built in striding features (see `implot.h` for documentation).
|
`float`, `double`, `int8`, `uint8`, `int16`, `uint16`, `int32`, `uint32`, `int64`, `uint64`. Arrays of custom structs or classes (e.g. `Vector2f` or similar) are easily passed to ImPlot functions using the built in striding features (see `implot.h` for documentation), and many plotters provide a "getter" overload which accepts data generating callbacks.
|
||||||
|
|
||||||
**Q: Can plot styles be modified?**
|
**Q: Can plot styles be modified?**
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ A: Yep! Both logscale and timescale are supported.
|
||||||
|
|
||||||
**Q: Does ImPlot support multiple y-axes? x-axes?**
|
**Q: Does ImPlot support multiple y-axes? x-axes?**
|
||||||
|
|
||||||
A: Yes. Up to three y-axes can be enabled. Multiple x-axes are not supported.
|
A: Yes. Up to three x-axes and three y-axes can be enabled.
|
||||||
|
|
||||||
**Q: Does ImPlot support [insert plot type]?**
|
**Q: Does ImPlot support [insert plot type]?**
|
||||||
|
|
||||||
|
@ -157,9 +157,9 @@ A: Not exactly, but it does give you the ability to query plot sub-ranges, with
|
||||||
|
|
||||||
A: Not currently. Use your OS's screen capturing mechanisms if you need to capture a plot. ImPlot is not suitable for rendering publication quality plots; it is only intended to be used as a visualization tool. Post-process your data with MATLAB or matplotlib for these purposes.
|
A: Not currently. Use your OS's screen capturing mechanisms if you need to capture a plot. ImPlot is not suitable for rendering publication quality plots; it is only intended to be used as a visualization tool. Post-process your data with MATLAB or matplotlib for these purposes.
|
||||||
|
|
||||||
**Q: Can a compile ImPlot as a dynamic library?**
|
**Q: Can I compile ImPlot as a dynamic library?**
|
||||||
|
|
||||||
A: Like ImGui, it is recommended that you compile and link ImPlot as a *static* library or directly as a part of your sources. However, if you are compiling ImPlot and ImGui as separate DLLs, make sure you set the current *ImGui* context with `ImPlot::SetImGuiContext(ImGuiContext* ctx)`. This ensures that global ImGui variables are correctly shared across the DLL boundary.
|
A: Like ImGui, it is recommended that you compile and link ImPlot as a *static* library or directly as a part of your sources. However, if you must and are compiling ImPlot and ImGui as separate DLLs, make sure you set the current *ImGui* context with `ImPlot::SetImGuiContext(ImGuiContext* ctx)`. This ensures that global ImGui variables are correctly shared across the DLL boundary.
|
||||||
|
|
||||||
**Q: Can ImPlot be used with other languages/bindings?**
|
**Q: Can ImPlot be used with other languages/bindings?**
|
||||||
|
|
||||||
|
|
51
TODO.md
51
TODO.md
|
@ -1,46 +1,69 @@
|
||||||
The list below represents a combination of high-priority work, nice-to-have features, and random ideas. We make no guarantees that all of this work will be completed or even started. If you see something that you need or would like to have, let us know, or better yet consider submitting a PR for the feature.
|
The list below represents a combination of high-priority work, nice-to-have features, and random ideas. We make no guarantees that all of this work will be completed or even started. If you see something that you need or would like to have, let us know, or better yet consider submitting a PR for the feature.
|
||||||
|
|
||||||
## Plots
|
## API
|
||||||
|
|
||||||
- remove axis-related args from signature of `BeginPlot` and add `SetupNextAxis` API
|
- add shortcut/legacy overloads for BeginPlot
|
||||||
- add a few overloads of `BeginPlot` that bypass `SetupNextAxis` for common scenarios
|
|
||||||
- make current `BeginPlot` a wrapper to this API
|
|
||||||
|
|
||||||
## Axes
|
## Axes
|
||||||
|
|
||||||
- add support for multiple x-axes and don't limit count to 3
|
|
||||||
- will require `SetupNextAxis` API
|
|
||||||
- make axis side configurable (top/left, right/bottom) via new flag `ImPlotAxisFlags_Opposite`
|
|
||||||
- add support for setting tick label strings via callback
|
|
||||||
- add flag to remove weekends on Time axis
|
- add flag to remove weekends on Time axis
|
||||||
|
- pixel space scale (`ImPlotTransform_Display`), normalized space scale (`ImPlotTransform_Axes`), data space scale (`ImPloTransform_Data`)
|
||||||
|
- make ImPlotFlags_Equal not a flag -> `SetupEqual(ImPlotAxis x, ImPlotAxis y)`
|
||||||
|
- allow inverted arguments `SetAxes` to transpose data?
|
||||||
|
- `SetupAxisColors()`
|
||||||
|
- `SetupAxisConstraints()`
|
||||||
|
- `SetupAxisHome()`
|
||||||
|
|
||||||
## Plot Items
|
## Plot Items
|
||||||
|
|
||||||
- add `ImPlotLineFlags`, `ImPlotBarsFlags`, etc. for each plot type
|
- add `ImPlotLineFlags`, `ImPlotBarsFlags`, etc. for each plot type
|
||||||
- add `PlotBarGroups` wrapper that makes rendering groups of bars easier
|
- add `PlotBarGroups` wrapper that makes rendering groups of bars easier, with stacked bar support
|
||||||
|
- add `PlotBubbles` (see MATLAB bubble chart)
|
||||||
- add non-zero references for `PlotBars` etc.
|
- add non-zero references for `PlotBars` etc.
|
||||||
|
- add exploding to `PlotPieChart` (on hover-highlight?)
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
- support gradient and/or colormap sampled fills (e.g. ImPlotFillStyle_)
|
- support gradient and/or colormap sampled fills (e.g. ImPlotFillStyle_)
|
||||||
- add hover/active color for plot
|
- add hover/active color for plot axes
|
||||||
|
- API for setting different fonts for plot elements
|
||||||
|
|
||||||
|
## Colormaps
|
||||||
|
|
||||||
|
- gradient editing tool
|
||||||
|
- `RemoveColormap`
|
||||||
|
|
||||||
## Legend
|
## Legend
|
||||||
|
|
||||||
- change `SetLegendLocation` API to be more consistent, i.e. `SetNextLegendLocation`
|
- `ImPlotLegendFlags_SortItems`
|
||||||
- add legend scroll
|
- `ImPlotLegendFlags_Scroll`
|
||||||
- improve legend icons (e.g. adopt markers, gradients, etc)
|
- improve legend icons (e.g. adopt markers, gradients, etc)
|
||||||
- `ImPlotLegendFlags`
|
- make legend frame use ButtonBehavior (maybe impossible)
|
||||||
|
|
||||||
## Tools / Misc.
|
## Tools / Misc.
|
||||||
|
|
||||||
- add `IsPlotChanging` to detect change in limits
|
- add `IsPlotChanging` to detect change in limits
|
||||||
- add ability to extend plot/axis context menus
|
- add ability to extend plot/axis context menus
|
||||||
- add LTTB downsampling for lines
|
- add LTTB downsampling for lines
|
||||||
|
- add box selection to axes
|
||||||
|
- first frame render delay might fix "fit pop" effect
|
||||||
|
- move some code to new `implot_tools.cpp`
|
||||||
|
|
||||||
## Optimizations
|
## Optimizations
|
||||||
|
|
||||||
- find faster way to buffer data into ImDrawList (very slow)
|
- find faster way to buffer data into ImDrawList (very slow)
|
||||||
- reduce number of calls to `PushClipRect`
|
- reduce number of calls to `PushClipRect`
|
||||||
- explore SIMD operations for high density plot items
|
- explore SIMD operations for high density plot items
|
||||||
|
|
||||||
|
## Completed
|
||||||
|
- make BeginPlot take fewer args:
|
||||||
|
- make query a tool -> `DragRect`
|
||||||
|
- rework DragLine/Point to use ButtonBehavior
|
||||||
|
- add support for multiple x-axes and don't limit count to 3
|
||||||
|
- make axis side configurable (top/left, right/bottom) via new flag `ImPlotAxisFlags_Opposite`
|
||||||
|
- add support for setting tick label strings via callback
|
||||||
|
- give each axis an ID, remove ad-hoc DND solution
|
||||||
|
- allow axis to be drag to opposite side (ala ImGui Table headers)
|
||||||
|
- legend items can be hovered even if plot is not
|
||||||
|
- fix frame delay on DragX tools
|
||||||
|
- remove tag from drag line/point -> add `Tag` tool
|
||||||
|
|
3865
implot.cpp
3865
implot.cpp
File diff suppressed because it is too large
Load Diff
659
implot.h
659
implot.h
|
@ -20,13 +20,35 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
// ImPlot v0.12 WIP
|
// ImPlot v0.13 WIP
|
||||||
|
|
||||||
|
// Table of Contents:
|
||||||
|
//
|
||||||
|
// [SECTION] Macros and Defines
|
||||||
|
// [SECTION] Enums and Types
|
||||||
|
// [SECTION] Callbacks
|
||||||
|
// [SECTION] Contexts
|
||||||
|
// [SECTION] Begin/End Plot
|
||||||
|
// [SECTION] Begin/End Subplot
|
||||||
|
// [SECTION] Setup
|
||||||
|
// [SECTION] SetNext
|
||||||
|
// [SECTION] Plot Items
|
||||||
|
// [SECTION] Plot Tools
|
||||||
|
// [SECTION] Plot Utils
|
||||||
|
// [SECTION] Legend Utils
|
||||||
|
// [SECTION] Drag and Drop
|
||||||
|
// [SECTION] Styling
|
||||||
|
// [SECTION] Colormaps
|
||||||
|
// [SECTION] Input Mapping
|
||||||
|
// [SECTION] Miscellaneous
|
||||||
|
// [SECTION] Demo
|
||||||
|
// [SECTION] Obsolete API
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Macros and Defines
|
// [SECTION] Macros and Defines
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||||
|
@ -37,70 +59,87 @@
|
||||||
#define IMPLOT_API
|
#define IMPLOT_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ImPlot version string
|
// ImPlot version string.
|
||||||
#define IMPLOT_VERSION "0.12 WIP"
|
#define IMPLOT_VERSION "0.13 WIP"
|
||||||
// Indicates variable should deduced automatically.
|
// Indicates variable should deduced automatically.
|
||||||
#define IMPLOT_AUTO -1
|
#define IMPLOT_AUTO -1
|
||||||
// Special color used to indicate that a color should be deduced automatically.
|
// Special color used to indicate that a color should be deduced automatically.
|
||||||
#define IMPLOT_AUTO_COL ImVec4(0,0,0,-1)
|
#define IMPLOT_AUTO_COL ImVec4(0,0,0,-1)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Forward Declarations and Basic Types
|
// [SECTION] Enums and Types
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
struct ImPlotContext; // ImPlot context (opaque struct, see implot_internal.h)
|
struct ImPlotContext; // ImPlot context (opaque struct, see implot_internal.h)
|
||||||
|
|
||||||
// Enums/Flags
|
// Enums/Flags
|
||||||
typedef int ImPlotFlags; // -> enum ImPlotFlags_
|
typedef int ImAxis; // -> enum ImAxis_
|
||||||
typedef int ImPlotAxisFlags; // -> enum ImPlotAxisFlags_
|
typedef int ImPlotFlags; // -> enum ImPlotFlags_
|
||||||
typedef int ImPlotSubplotFlags; // -> enum ImPlotSubplotFlags_
|
typedef int ImPlotAxisFlags; // -> enum ImPlotAxisFlags_
|
||||||
typedef int ImPlotCol; // -> enum ImPlotCol_
|
typedef int ImPlotSubplotFlags; // -> enum ImPlotSubplotFlags_
|
||||||
typedef int ImPlotStyleVar; // -> enum ImPlotStyleVar_
|
typedef int ImPlotLegendFlags; // -> enum ImPlotLegendFlags_
|
||||||
typedef int ImPlotMarker; // -> enum ImPlotMarker_
|
typedef int ImPlotMouseTextFlags; // -> enum ImPlotMouseTextFlags_
|
||||||
typedef int ImPlotColormap; // -> enum ImPlotColormap_
|
typedef int ImPlotDragToolFlags; // -> ImPlotDragToolFlags_
|
||||||
typedef int ImPlotLocation; // -> enum ImPlotLocation_
|
typedef int ImPlotCond; // -> enum ImPlotCond_
|
||||||
typedef int ImPlotOrientation; // -> enum ImPlotOrientation_
|
typedef int ImPlotCol; // -> enum ImPlotCol_
|
||||||
typedef int ImPlotYAxis; // -> enum ImPlotYAxis_;
|
typedef int ImPlotStyleVar; // -> enum ImPlotStyleVar_
|
||||||
typedef int ImPlotBin; // -> enum ImPlotBin_
|
typedef int ImPlotMarker; // -> enum ImPlotMarker_
|
||||||
|
typedef int ImPlotColormap; // -> enum ImPlotColormap_
|
||||||
|
typedef int ImPlotLocation; // -> enum ImPlotLocation_
|
||||||
|
typedef int ImPlotBin; // -> enum ImPlotBin_
|
||||||
|
|
||||||
|
// Axis indices. The values assigned may change; NEVER hardcode these.
|
||||||
|
enum ImAxis_ {
|
||||||
|
// horizontal axes
|
||||||
|
ImAxis_X1 = 0, // enabled by default
|
||||||
|
ImAxis_X2, // disabled by default
|
||||||
|
ImAxis_X3, // disabled by default
|
||||||
|
// vertical axes
|
||||||
|
ImAxis_Y1, // enabled by default
|
||||||
|
ImAxis_Y2, // disabled by default
|
||||||
|
ImAxis_Y3, // disabled by default
|
||||||
|
// bookeeping
|
||||||
|
ImAxis_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
// Options for plots (see BeginPlot).
|
// Options for plots (see BeginPlot).
|
||||||
enum ImPlotFlags_ {
|
enum ImPlotFlags_ {
|
||||||
ImPlotFlags_None = 0, // default
|
ImPlotFlags_None = 0, // default
|
||||||
ImPlotFlags_NoTitle = 1 << 0, // the plot title will not be displayed (titles are also hidden if preceeded by double hashes, e.g. "##MyPlot")
|
ImPlotFlags_NoTitle = 1 << 0, // the plot title will not be displayed (titles are also hidden if preceeded by double hashes, e.g. "##MyPlot")
|
||||||
ImPlotFlags_NoLegend = 1 << 1, // the legend will not be displayed
|
ImPlotFlags_NoLegend = 1 << 1, // the legend will not be displayed
|
||||||
ImPlotFlags_NoMenus = 1 << 2, // the user will not be able to open context menus with right-click
|
ImPlotFlags_NoMouseText = 1 << 2, // the mouse position, in plot coordinates, will not be displayed inside of the plot
|
||||||
ImPlotFlags_NoBoxSelect = 1 << 3, // the user will not be able to box-select with right-click drag
|
ImPlotFlags_NoInputs = 1 << 3, // the user will not be able to interact with the plot
|
||||||
ImPlotFlags_NoMousePos = 1 << 4, // the mouse position, in plot coordinates, will not be displayed inside of the plot
|
ImPlotFlags_NoMenus = 1 << 4, // the user will not be able to open context menus
|
||||||
ImPlotFlags_NoHighlight = 1 << 5, // plot items will not be highlighted when their legend entry is hovered
|
ImPlotFlags_NoBoxSelect = 1 << 5, // the user will not be able to box-select
|
||||||
ImPlotFlags_NoChild = 1 << 6, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
ImPlotFlags_NoChild = 1 << 6, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||||
ImPlotFlags_Equal = 1 << 7, // primary x and y axes will be constrained to have the same units/pixel (does not apply to auxiliary y-axes)
|
ImPlotFlags_Equal = 1 << 7, // x and y axes pairs will be constrained to have the same units/pixel
|
||||||
ImPlotFlags_YAxis2 = 1 << 8, // enable a 2nd y-axis on the right side
|
ImPlotFlags_Crosshairs = 1 << 8, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||||
ImPlotFlags_YAxis3 = 1 << 9, // enable a 3rd y-axis on the right side
|
ImPlotFlags_AntiAliased = 1 << 9, // plot items will be software anti-aliased (not recommended for high density plots, prefer MSAA)
|
||||||
ImPlotFlags_Query = 1 << 10, // the user will be able to draw query rects with middle-mouse or CTRL + right-click drag
|
ImPlotFlags_CanvasOnly = ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText
|
||||||
ImPlotFlags_Crosshairs = 1 << 11, // the default mouse cursor will be replaced with a crosshair when hovered
|
|
||||||
ImPlotFlags_AntiAliased = 1 << 12, // plot lines will be software anti-aliased (not recommended for high density plots, prefer MSAA)
|
|
||||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options for plot axes (see BeginPlot).
|
// 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 also hidden if the supplied string name is NULL)
|
ImPlotAxisFlags_NoLabel = 1 << 0, // the axis label will not be displayed (axis labels also hidden if the supplied string name is NULL)
|
||||||
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
|
||||||
ImPlotAxisFlags_Foreground = 1 << 4, // grid lines will be displayed in the foreground (i.e. on top of data) in stead of the background
|
ImPlotAxisFlags_NoInitialFit = 1 << 4, // axis will not be initially fit to data extents on the first rendered frame
|
||||||
ImPlotAxisFlags_LogScale = 1 << 5, // a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
|
ImPlotAxisFlags_NoMenus = 1 << 5, // the user will not be able to open context menus with right-click
|
||||||
ImPlotAxisFlags_Time = 1 << 6, // axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
|
ImPlotAxisFlags_Opposite = 1 << 6, // axis ticks and labels will be rendered on conventionally opposite side (i.e, right or top)
|
||||||
ImPlotAxisFlags_Invert = 1 << 7, // the axis will be inverted
|
ImPlotAxisFlags_Foreground = 1 << 7, // grid lines will be displayed in the foreground (i.e. on top of data) in stead of the background
|
||||||
ImPlotAxisFlags_NoInitialFit = 1 << 8, // axis will not be initially fit to data extents on the first rendered frame (also the case if SetNextPlotLimits explicitly called)
|
ImPlotAxisFlags_LogScale = 1 << 8, // a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
|
||||||
ImPlotAxisFlags_AutoFit = 1 << 9, // axis will be auto-fitting to data extents
|
ImPlotAxisFlags_Time = 1 << 9, // axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
|
||||||
ImPlotAxisFlags_RangeFit = 1 << 10, // axis will only fit points if the point is in the visible range of the **orthoganol** axis
|
ImPlotAxisFlags_Invert = 1 << 10, // the axis will be inverted
|
||||||
ImPlotAxisFlags_LockMin = 1 << 11, // the axis minimum value will be locked when panning/zooming
|
ImPlotAxisFlags_AutoFit = 1 << 11, // axis will be auto-fitting to data extents
|
||||||
ImPlotAxisFlags_LockMax = 1 << 12, // the axis maximum value will be locked when panning/zooming
|
ImPlotAxisFlags_RangeFit = 1 << 12, // axis will only fit points if the point is in the visible range of the **orthogonal** axis
|
||||||
|
ImPlotAxisFlags_LockMin = 1 << 13, // the axis minimum value will be locked when panning/zooming
|
||||||
|
ImPlotAxisFlags_LockMax = 1 << 14, // the axis maximum value will be locked when panning/zooming
|
||||||
ImPlotAxisFlags_Lock = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax,
|
ImPlotAxisFlags_Lock = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax,
|
||||||
ImPlotAxisFlags_NoDecorations = ImPlotAxisFlags_NoLabel | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels
|
ImPlotAxisFlags_NoDecorations = ImPlotAxisFlags_NoLabel | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels,
|
||||||
|
ImPlotAxisFlags_AuxDefault = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_Opposite
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options for subplots (see BeginSubplot).
|
// Options for subplots (see BeginSubplot).
|
||||||
|
@ -112,13 +151,49 @@ enum ImPlotSubplotFlags_ {
|
||||||
ImPlotSubplotFlags_NoResize = 1 << 3, // resize splitters between subplot cells will be not be provided
|
ImPlotSubplotFlags_NoResize = 1 << 3, // resize splitters between subplot cells will be not be provided
|
||||||
ImPlotSubplotFlags_NoAlign = 1 << 4, // subplot edges will not be aligned vertically or horizontally
|
ImPlotSubplotFlags_NoAlign = 1 << 4, // subplot edges will not be aligned vertically or horizontally
|
||||||
ImPlotSubplotFlags_ShareItems = 1 << 5, // items across all subplots will be shared and rendered into a single legend entry
|
ImPlotSubplotFlags_ShareItems = 1 << 5, // items across all subplots will be shared and rendered into a single legend entry
|
||||||
ImPlotSubplotFlags_LinkRows = 1 << 6, // link the y-axis limits of all plots in each row (does not apply auxiliary y-axes)
|
ImPlotSubplotFlags_LinkRows = 1 << 6, // link the y-axis limits of all plots in each row (does not apply to auxiliary axes)
|
||||||
ImPlotSubplotFlags_LinkCols = 1 << 7, // link the x-axis limits of all plots in each column
|
ImPlotSubplotFlags_LinkCols = 1 << 7, // link the x-axis limits of all plots in each column (does not apply to auxiliary axes)
|
||||||
ImPlotSubplotFlags_LinkAllX = 1 << 8, // link the x-axis limits in every plot in the subplot
|
ImPlotSubplotFlags_LinkAllX = 1 << 8, // link the x-axis limits in every plot in the subplot (does not apply to auxiliary axes)
|
||||||
ImPlotSubplotFlags_LinkAllY = 1 << 9 , // link the y-axis limits in every plot in the subplot (does not apply to auxiliary y-axes)
|
ImPlotSubplotFlags_LinkAllY = 1 << 9, // link the y-axis limits in every plot in the subplot (does not apply to auxiliary axes)
|
||||||
ImPlotSubplotFlags_ColMajor = 1 << 10 // subplots are added in column major order instead of the default row major order
|
ImPlotSubplotFlags_ColMajor = 1 << 10 // subplots are added in column major order instead of the default row major order
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Options for legends (see SetupLegend)
|
||||||
|
enum ImPlotLegendFlags_ {
|
||||||
|
ImPlotLegendFlags_None = 0, // default
|
||||||
|
ImPlotLegendFlags_NoButtons = 1 << 0, // legend icons will not function as hide/show buttons
|
||||||
|
ImPlotLegendFlags_NoHighlightItem = 1 << 1, // plot items will not be highlighted when their legend entry is hovered
|
||||||
|
ImPlotLegendFlags_NoHighlightAxis = 1 << 2, // axes will not be highlighted when legend entries are hovered (only relevant if x/y-axis count > 1)
|
||||||
|
ImPlotLegendFlags_NoMenus = 1 << 3, // the user will not be able to open context menus with right-click
|
||||||
|
ImPlotLegendFlags_Outside = 1 << 4, // legend will be rendered outside of the plot area
|
||||||
|
ImPlotLegendFlags_Horizontal = 1 << 5, // legend entries will be displayed horizontally
|
||||||
|
};
|
||||||
|
|
||||||
|
// Options for mouse hover text (see SetupMouseText)
|
||||||
|
enum ImPlotMouseTextFlags_ {
|
||||||
|
ImPlotMouseTextFlags_None = 0, // default
|
||||||
|
ImPlotMouseTextFlags_NoAuxAxes = 1 << 0, // only show the mouse position for primary axes
|
||||||
|
ImPlotMouseTextFlags_NoFormat = 1 << 1, // axes label formatters won't be used to render text
|
||||||
|
ImPlotMouseTextFlags_ShowAlways = 1 << 2, // always display mouse position even if plot not hovered
|
||||||
|
};
|
||||||
|
|
||||||
|
// Options for DragPoint, DragLine, DragRect
|
||||||
|
enum ImPlotDragToolFlags_ {
|
||||||
|
ImPlotDragToolFlags_None = 0, // default
|
||||||
|
ImPlotDragToolFlags_NoCursors = 1 << 0, // drag tools won't change cursor icons when hovered or held
|
||||||
|
ImPlotDragToolFlags_NoFit = 1 << 1, // the drag tool won't be considered for plot fits
|
||||||
|
ImPlotDragToolFlags_NoInputs = 1 << 2, // lock the tool from user inputs
|
||||||
|
ImPlotDragToolFlags_Delayed = 1 << 3, // tool rendering will be delayed one frame; useful when applying position-constraints
|
||||||
|
};
|
||||||
|
|
||||||
|
// Represents a condition for SetupAxisLimits etc. (same as ImGuiCond, but we only support a subset of those enums)
|
||||||
|
enum ImPlotCond_
|
||||||
|
{
|
||||||
|
ImPlotCond_None = ImGuiCond_None, // No condition (always set the variable), same as _Always
|
||||||
|
ImPlotCond_Always = ImGuiCond_Always, // No condition (always set the variable)
|
||||||
|
ImPlotCond_Once = ImGuiCond_Once, // Set the variable once per runtime session (only the first call will succeed)
|
||||||
|
};
|
||||||
|
|
||||||
// Plot styling colors.
|
// Plot styling colors.
|
||||||
enum ImPlotCol_ {
|
enum ImPlotCol_ {
|
||||||
// item styling colors
|
// item styling colors
|
||||||
|
@ -136,16 +211,12 @@ enum ImPlotCol_ {
|
||||||
ImPlotCol_LegendText, // legend text color (defaults to ImPlotCol_InlayText)
|
ImPlotCol_LegendText, // legend text color (defaults to ImPlotCol_InlayText)
|
||||||
ImPlotCol_TitleText, // plot title text color (defaults to ImGuiCol_Text)
|
ImPlotCol_TitleText, // plot title text color (defaults to ImGuiCol_Text)
|
||||||
ImPlotCol_InlayText, // color of text appearing inside of plots (defaults to ImGuiCol_Text)
|
ImPlotCol_InlayText, // color of text appearing inside of plots (defaults to ImGuiCol_Text)
|
||||||
ImPlotCol_XAxis, // x-axis label and tick lables color (defaults to ImGuiCol_Text)
|
ImPlotCol_AxisText, // axis label and tick lables color (defaults to ImGuiCol_Text)
|
||||||
ImPlotCol_XAxisGrid, // x-axis grid color (defaults to 25% ImPlotCol_XAxis)
|
ImPlotCol_AxisGrid, // axis grid and tick color (defaults to 25% ImPlotCol_XAxis)
|
||||||
ImPlotCol_YAxis, // y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
ImPlotCol_AxisBg, // background color of axis hover region (defaults to transparent)
|
||||||
ImPlotCol_YAxisGrid, // y-axis grid color (defaults to 25% ImPlotCol_YAxis)
|
ImPlotCol_AxisBgHovered, // axis hover color (defaults to ImGuiCol_ButtonHovered)
|
||||||
ImPlotCol_YAxis2, // 2nd y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
ImPlotCol_AxisBgActive, // axis active color (defaults to ImGuiCol_ButtonActive)
|
||||||
ImPlotCol_YAxisGrid2, // 2nd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis2)
|
|
||||||
ImPlotCol_YAxis3, // 3rd y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
|
||||||
ImPlotCol_YAxisGrid3, // 3rd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis3)
|
|
||||||
ImPlotCol_Selection, // box-selection color (defaults to yellow)
|
ImPlotCol_Selection, // box-selection color (defaults to yellow)
|
||||||
ImPlotCol_Query, // box-query color (defaults to green)
|
|
||||||
ImPlotCol_Crosshairs, // crosshairs color (defaults to ImPlotCol_PlotBorder)
|
ImPlotCol_Crosshairs, // crosshairs color (defaults to ImPlotCol_PlotBorder)
|
||||||
ImPlotCol_COUNT
|
ImPlotCol_COUNT
|
||||||
};
|
};
|
||||||
|
@ -233,19 +304,6 @@ enum ImPlotLocation_ {
|
||||||
ImPlotLocation_SouthEast = ImPlotLocation_South | ImPlotLocation_East // bottom-right
|
ImPlotLocation_SouthEast = ImPlotLocation_South | ImPlotLocation_East // bottom-right
|
||||||
};
|
};
|
||||||
|
|
||||||
// Used to orient items on a plot (e.g. legends, labels, etc.)
|
|
||||||
enum ImPlotOrientation_ {
|
|
||||||
ImPlotOrientation_Horizontal, // left/right
|
|
||||||
ImPlotOrientation_Vertical // up/down
|
|
||||||
};
|
|
||||||
|
|
||||||
// Enums for different y-axes.
|
|
||||||
enum ImPlotYAxis_ {
|
|
||||||
ImPlotYAxis_1 = 0, // left (default)
|
|
||||||
ImPlotYAxis_2 = 1, // first on right side
|
|
||||||
ImPlotYAxis_3 = 2 // second on right side
|
|
||||||
};
|
|
||||||
|
|
||||||
// Enums for different automatic histogram binning methods (k = bin count or w = bin width)
|
// Enums for different automatic histogram binning methods (k = bin count or w = bin width)
|
||||||
enum ImPlotBin_ {
|
enum ImPlotBin_ {
|
||||||
ImPlotBin_Sqrt = -1, // k = sqrt(n)
|
ImPlotBin_Sqrt = -1, // k = sqrt(n)
|
||||||
|
@ -257,8 +315,8 @@ enum ImPlotBin_ {
|
||||||
// Double precision version of ImVec2 used by ImPlot. Extensible by end users.
|
// Double precision version of ImVec2 used by ImPlot. Extensible by end users.
|
||||||
struct ImPlotPoint {
|
struct ImPlotPoint {
|
||||||
double x, y;
|
double x, y;
|
||||||
ImPlotPoint() { x = y = 0.0; }
|
ImPlotPoint() { x = y = 0.0; }
|
||||||
ImPlotPoint(double _x, double _y) { x = _x; y = _y; }
|
ImPlotPoint(double _x, double _y) { x = _x; y = _y; }
|
||||||
ImPlotPoint(const ImVec2& p) { x = p.x; y = p.y; }
|
ImPlotPoint(const ImVec2& p) { x = p.x; y = p.y; }
|
||||||
double operator[] (size_t idx) const { return (&x)[idx]; }
|
double operator[] (size_t idx) const { return (&x)[idx]; }
|
||||||
double& operator[] (size_t idx) { return (&x)[idx]; }
|
double& operator[] (size_t idx) { return (&x)[idx]; }
|
||||||
|
@ -268,24 +326,28 @@ struct ImPlotPoint {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// A range defined by a min/max value. Used for plot axes ranges.
|
// Range defined by a min/max value.
|
||||||
struct ImPlotRange {
|
struct ImPlotRange {
|
||||||
double Min, Max;
|
double Min, Max;
|
||||||
ImPlotRange() { Min = 0; Max = 0; }
|
ImPlotRange() { Min = 0; Max = 0; }
|
||||||
ImPlotRange(double _min, double _max) { Min = _min; Max = _max; }
|
ImPlotRange(double _min, double _max) { Min = _min; Max = _max; }
|
||||||
bool Contains(double value) const { return value >= Min && value <= Max; };
|
bool Contains(double value) const { return value >= Min && value <= Max; }
|
||||||
double Size() const { return Max - Min; };
|
double Size() const { return Max - Min; }
|
||||||
|
double Clamp(double value) const { return (value < Min) ? Min : (value > Max) ? Max : value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Combination of two ranges for X and Y axes.
|
// Combination of two range limits for X and Y axes. Also an AABB defined by Min()/Max().
|
||||||
struct ImPlotLimits {
|
struct ImPlotRect {
|
||||||
ImPlotRange X, Y;
|
ImPlotRange X, Y;
|
||||||
ImPlotLimits() { }
|
ImPlotRect() { }
|
||||||
ImPlotLimits(double x_min, double x_max, double y_min, double y_max) { X.Min = x_min; X.Max = x_max; Y.Min = y_min; Y.Max = y_max; }
|
ImPlotRect(double x_min, double x_max, double y_min, double y_max) { X.Min = x_min; X.Max = x_max; Y.Min = y_min; Y.Max = y_max; }
|
||||||
bool Contains(const ImPlotPoint& p) const { return Contains(p.x, p.y); }
|
bool Contains(const ImPlotPoint& p) const { return Contains(p.x, p.y); }
|
||||||
bool Contains(double x, double y) const { return X.Contains(x) && Y.Contains(y); }
|
bool Contains(double x, double y) const { return X.Contains(x) && Y.Contains(y); }
|
||||||
ImPlotPoint Min() const { return ImPlotPoint(X.Min, Y.Min); }
|
ImPlotPoint Size() const { return ImPlotPoint(X.Size(), Y.Size()); }
|
||||||
ImPlotPoint Max() const { return ImPlotPoint(X.Max, Y.Max); }
|
ImPlotPoint Clamp(const ImPlotPoint& p) { return Clamp(p.x, p.y); }
|
||||||
|
ImPlotPoint Clamp(double x, double y) { return ImPlotPoint(X.Clamp(x),Y.Clamp(y)); }
|
||||||
|
ImPlotPoint Min() const { return ImPlotPoint(X.Min, Y.Min); }
|
||||||
|
ImPlotPoint Max() const { return ImPlotPoint(X.Max, Y.Max); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Plot style structure
|
// Plot style structure
|
||||||
|
@ -332,14 +394,37 @@ struct ImPlotStyle {
|
||||||
IMPLOT_API ImPlotStyle();
|
IMPLOT_API ImPlotStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Input mapping structure. Default values listed. See also MapInputDefault, MapInputReverse.
|
||||||
|
struct ImPlotInputMap {
|
||||||
|
ImGuiMouseButton Pan; // LMB enables panning when held,
|
||||||
|
ImGuiKeyModFlags PanMod; // none optional modifier that must be held for panning/fitting
|
||||||
|
ImGuiMouseButton Fit; // LMB initiates fit when double clicked
|
||||||
|
ImGuiMouseButton Select; // RMB begins box selection when pressed and confirms selection when released
|
||||||
|
ImGuiMouseButton SelectCancel; // LMB cancels active box selection when pressed; cannot be same as Select
|
||||||
|
ImGuiKeyModFlags SelectMod; // none optional modifier that must be held for box selection
|
||||||
|
ImGuiKeyModFlags SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
|
||||||
|
ImGuiKeyModFlags SelectVertMod; // Shift expands active box selection vertically to plot edge when held
|
||||||
|
ImGuiMouseButton Menu; // RMB opens context menus (if enabled) when clicked
|
||||||
|
ImGuiKeyModFlags OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
|
||||||
|
ImGuiKeyModFlags ZoomMod; // none optional modifier that must be held for scroll wheel zooming
|
||||||
|
float ZoomRate; // 0.1f zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click); make negative to invert
|
||||||
|
IMPLOT_API ImPlotInputMap();
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ImPlot End-User API
|
// [SECTION] Callbacks
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Callback signature for axis tick label formatter.
|
||||||
|
typedef void (*ImPlotFormatter)(double value, char* buff, int size, void* user_data);
|
||||||
|
|
||||||
|
// Callback signature for data getter.
|
||||||
|
typedef ImPlotPoint (*ImPlotGetter)(void* user_data, int idx);
|
||||||
|
|
||||||
namespace ImPlot {
|
namespace ImPlot {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ImPlot Context
|
// [SECTION] Contexts
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Creates a new ImPlot context. Call this after ImGui::CreateContext.
|
// Creates a new ImPlot context. Call this after ImGui::CreateContext.
|
||||||
|
@ -358,14 +443,14 @@ IMPLOT_API void SetCurrentContext(ImPlotContext* ctx);
|
||||||
IMPLOT_API void SetImGuiContext(ImGuiContext* ctx);
|
IMPLOT_API void SetImGuiContext(ImGuiContext* ctx);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Begin/End Plot
|
// [SECTION] Begin/End Plot
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Starts a 2D plotting context. If this function returns true, EndPlot() MUST
|
// Starts a 2D plotting context. If this function returns true, EndPlot() MUST
|
||||||
// be called! You are encouraged to use the following convention:
|
// be called! You are encouraged to use the following convention:
|
||||||
//
|
//
|
||||||
// if (BeginPlot(...)) {
|
// if (BeginPlot(...)) {
|
||||||
// ImPlot::PlotLine(...);
|
// PlotLine(...);
|
||||||
// ...
|
// ...
|
||||||
// EndPlot();
|
// EndPlot();
|
||||||
// }
|
// }
|
||||||
|
@ -375,31 +460,16 @@ IMPLOT_API void SetImGuiContext(ImGuiContext* ctx);
|
||||||
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
|
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
|
||||||
// collisions or don't want to display a title in the plot, use double hashes
|
// collisions or don't want to display a title in the plot, use double hashes
|
||||||
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
|
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
|
||||||
// - If #x_label and/or #y_label are provided, axes labels will be displayed.
|
|
||||||
// - #size is the **frame** size of the plot widget, not the plot area. The default
|
// - #size is the **frame** size of the plot widget, not the plot area. The default
|
||||||
// size of plots (i.e. when ImVec2(0,0)) can be modified in your ImPlotStyle
|
// size of plots (i.e. when ImVec2(0,0)) can be modified in your ImPlotStyle.
|
||||||
// (default is 400x300 px).
|
IMPLOT_API bool BeginPlot(const char* title_id, const ImVec2& size = ImVec2(-1,0), ImPlotFlags flags = ImPlotFlags_None);
|
||||||
// - Auxiliary y-axes must be enabled with ImPlotFlags_YAxis2/3 to be displayed.
|
|
||||||
// - See ImPlotFlags and ImPlotAxisFlags for more available options.
|
|
||||||
|
|
||||||
IMPLOT_API bool BeginPlot(const char* title_id,
|
|
||||||
const char* x_label = NULL,
|
|
||||||
const char* y_label = NULL,
|
|
||||||
const ImVec2& size = ImVec2(-1,0),
|
|
||||||
ImPlotFlags flags = ImPlotFlags_None,
|
|
||||||
ImPlotAxisFlags x_flags = ImPlotAxisFlags_None,
|
|
||||||
ImPlotAxisFlags y_flags = ImPlotAxisFlags_None,
|
|
||||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_NoGridLines,
|
|
||||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_NoGridLines,
|
|
||||||
const char* y2_label = NULL,
|
|
||||||
const char* y3_label = NULL);
|
|
||||||
|
|
||||||
// Only call EndPlot() if BeginPlot() returns true! Typically called at the end
|
// Only call EndPlot() if BeginPlot() returns true! Typically called at the end
|
||||||
// of an if statement conditioned on BeginPlot(). See example above.
|
// of an if statement conditioned on BeginPlot(). See example above.
|
||||||
IMPLOT_API void EndPlot();
|
IMPLOT_API void EndPlot();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Begin/EndSubplots
|
// [SECTION] Begin/End Subplots
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Starts a subdivided plotting context. If the function returns true,
|
// Starts a subdivided plotting context. If the function returns true,
|
||||||
|
@ -422,14 +492,15 @@ IMPLOT_API void EndPlot();
|
||||||
//
|
//
|
||||||
// Produces:
|
// Produces:
|
||||||
//
|
//
|
||||||
// [0][1][2]
|
// [0] | [1] | [2]
|
||||||
// [3][4][5]
|
// ----|-----|----
|
||||||
|
// [3] | [4] | [5]
|
||||||
//
|
//
|
||||||
// Important notes:
|
// Important notes:
|
||||||
//
|
//
|
||||||
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
|
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
|
||||||
// collisions or don't want to display a title in the plot, use double hashes
|
// collisions or don't want to display a title in the plot, use double hashes
|
||||||
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
|
// (e.g. "MySubplot##HiddenIdText" or "##NoTitle").
|
||||||
// - #rows and #cols must be greater than 0.
|
// - #rows and #cols must be greater than 0.
|
||||||
// - #size is the size of the entire grid of subplots, not the individual plots
|
// - #size is the size of the entire grid of subplots, not the individual plots
|
||||||
// - #row_ratios and #col_ratios must have AT LEAST #rows and #cols elements,
|
// - #row_ratios and #col_ratios must have AT LEAST #rows and #cols elements,
|
||||||
|
@ -460,10 +531,107 @@ IMPLOT_API bool BeginSubplots(const char* title_id,
|
||||||
IMPLOT_API void EndSubplots();
|
IMPLOT_API void EndSubplots();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Plot Items
|
// [SECTION] Setup
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// The template functions below are explicitly instantiated in implot_items.cpp.
|
// The following API allows you to setup and customize various aspects of the
|
||||||
|
// current plot. The functions should be called immediately after BeginPlot
|
||||||
|
// and before any other API calls. Typical usage is as follows:
|
||||||
|
|
||||||
|
// if (BeginPlot(...)) { 1) begin a new plot
|
||||||
|
// SetupAxis(ImAxis_X1, "My X-Axis"); 2) make Setup calls
|
||||||
|
// SetupAxis(ImAxis_Y1, "My Y-Axis");
|
||||||
|
// SetupLegend(ImPlotLocation_North);
|
||||||
|
// ...
|
||||||
|
// SetupFinish(); 3) [optional] explicitly finish setup
|
||||||
|
// PlotLine(...); 4) plot items
|
||||||
|
// ...
|
||||||
|
// EndPlot(); 5) end the plot
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Important notes:
|
||||||
|
//
|
||||||
|
// - Always call Setup code at the top of your BeginPlot conditional statement.
|
||||||
|
// - Setup is locked once you start plotting or explicitly call SetupFinish.
|
||||||
|
// Do NOT call Setup code after you begin plotting or after you make
|
||||||
|
// any non-Setup API calls (e.g. utils like PlotToPixels also lock Setup)
|
||||||
|
// - Calling SetupFinish is OPTIONAL, but probably good practice. If you do not
|
||||||
|
// call it yourself, then the first subsequent plotting or utility function will
|
||||||
|
// call it for you.
|
||||||
|
|
||||||
|
// Enables an axis or sets the label and/or flags for an existing axis. Leave #label = NULL for no label.
|
||||||
|
IMPLOT_API void SetupAxis(ImAxis axis, const char* label = NULL, ImPlotAxisFlags flags = ImPlotAxisFlags_None);
|
||||||
|
// 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);
|
||||||
|
// Links an axis range limits to external values. Set to NULL for no linkage. The pointer data must remain valid until EndPlot.
|
||||||
|
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).
|
||||||
|
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.
|
||||||
|
IMPLOT_API void SetupAxisFormat(ImAxis axis, ImPlotFormatter formatter, void* data = NULL);
|
||||||
|
// 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);
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// Sets the label and/or flags for primary X and Y axes (shorthand for two calls to SetupAxis).
|
||||||
|
IMPLOT_API void SetupAxes(const char* x_label, const char* y_label, ImPlotAxisFlags x_flags = ImPlotAxisFlags_None, ImPlotAxisFlags y_flags = ImPlotAxisFlags_None);
|
||||||
|
// Sets the primary X and Y axes range limits. If ImPlotCond_Always is used, the axes limits will be locked (shorthand for two calls to SetupAxisLimits).
|
||||||
|
IMPLOT_API void SetupAxesLimits(double x_min, double x_max, double y_min, double y_max, ImPlotCond cond = ImPlotCond_Once);
|
||||||
|
|
||||||
|
// Sets up the plot legend.
|
||||||
|
IMPLOT_API void SetupLegend(ImPlotLocation location, ImPlotLegendFlags flags = ImPlotLegendFlags_None);
|
||||||
|
// Set the location of the current plot's mouse position text (default = South|East).
|
||||||
|
IMPLOT_API void SetupMouseText(ImPlotLocation location, ImPlotMouseTextFlags flags = ImPlotMouseTextFlags_None);
|
||||||
|
|
||||||
|
// Explicitly finalize plot setup. Once you call this, you cannot make anymore Setup calls for the current plot!
|
||||||
|
// Note that calling this function is OPTIONAL; it will be called by the first subsequent setup-locking API call.
|
||||||
|
IMPLOT_API void SetupFinish();
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] SetNext
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Though you should default to the `Setup` API above, there are some scenarios
|
||||||
|
// where (re)configuring a plot or axis before `BeginPlot` is needed (e.g. if
|
||||||
|
// using a preceding button or slider widget to change the plot limits). In
|
||||||
|
// this case, you can use the `SetNext` API below. While this is not as feature
|
||||||
|
// rich as the Setup API, most common needs are provided. These functions can be
|
||||||
|
// called anwhere except for inside of `Begin/EndPlot`. For example:
|
||||||
|
|
||||||
|
// if (ImGui::Button("Center Plot"))
|
||||||
|
// ImPlot::SetNextPlotLimits(-1,1,-1,1);
|
||||||
|
// if (ImPlot::BeginPlot(...)) {
|
||||||
|
// ...
|
||||||
|
// ImPlot::EndPlot();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Important notes:
|
||||||
|
//
|
||||||
|
// - You must still enable non-default axes with SetupAxis for these functions
|
||||||
|
// to work properly.
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// Links an upcoming axis range limits to external values. Set to NULL for no linkage. The pointer data must remain valid until EndPlot!
|
||||||
|
IMPLOT_API void SetNextAxisLinks(ImAxis axis, double* link_min, double* link_max);
|
||||||
|
// Set an upcoming axis to auto fit to its data.
|
||||||
|
IMPLOT_API void SetNextAxisToFit(ImAxis axis);
|
||||||
|
|
||||||
|
// Sets the upcoming primary X and Y axes range limits. If ImPlotCond_Always is used, the axes limits will be locked (shorthand for two calls to SetupAxisLimits).
|
||||||
|
IMPLOT_API void SetNextAxesLimits(double x_min, double x_max, double y_min, double y_max, ImPlotCond cond = ImPlotCond_Once);
|
||||||
|
// Sets all upcoming axes to auto fit to their data.
|
||||||
|
IMPLOT_API void SetNextAxesToFit();
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Plot Items
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// The main plotting API is provied below. Call these functions between
|
||||||
|
// Begin/EndPlot and after any Setup API calls. Each plots data on the current
|
||||||
|
// x and y axes, which can be changed with `SetAxis/Axes`.
|
||||||
|
//
|
||||||
|
// The templates are explicitly instantiated in implot_items.cpp.
|
||||||
// They are not intended to be used generically with custom types. You will get
|
// They are not intended to be used generically with custom types. You will get
|
||||||
// a linker error if you try! All functions support the following scalar types:
|
// a linker error if you try! All functions support the following scalar types:
|
||||||
//
|
//
|
||||||
|
@ -510,33 +678,33 @@ IMPLOT_API void EndSubplots();
|
||||||
// Plots a standard 2D line plot.
|
// Plots a standard 2D line plot.
|
||||||
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotLineG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count);
|
IMPLOT_API void PlotLineG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
||||||
|
|
||||||
// Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle.
|
// Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle.
|
||||||
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotScatterG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count);
|
IMPLOT_API void PlotScatterG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
||||||
|
|
||||||
// Plots a a stairstep graph. The y value is continued constantly from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i].
|
// Plots a a stairstep graph. The y value is continued constantly from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i].
|
||||||
template <typename T> IMPLOT_API void PlotStairs(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotStairs(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotStairs(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotStairs(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotStairsG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count);
|
IMPLOT_API void PlotStairsG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
||||||
|
|
||||||
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference. Set y_ref to +/-INFINITY for infinite fill extents.
|
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference. Set y_ref to +/-INFINITY for infinite fill extents.
|
||||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* values, int count, double y_ref=0, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* values, int count, double y_ref=0, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotShadedG(const char* label_id, ImPlotPoint (*getter1)(void* data, int idx), void* data1, ImPlotPoint (*getter2)(void* data, int idx), void* data2, int count);
|
IMPLOT_API void PlotShadedG(const char* label_id, ImPlotGetter getter1, void* data1, ImPlotGetter getter2, void* data2, int count);
|
||||||
|
|
||||||
// Plots a vertical bar graph. #width and #shift are in X units.
|
// Plots a vertical bar graph. #width and #shift are in X units.
|
||||||
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* values, int count, double width=0.67, double shift=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* values, int count, double width=0.67, double shift=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double width, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double width, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotBarsG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double width);
|
IMPLOT_API void PlotBarsG(const char* label_id, ImPlotGetter getter, void* data, int count, double width);
|
||||||
|
|
||||||
// Plots a horizontal bar graph. #height and #shift are in Y units.
|
// Plots a horizontal bar graph. #height and #shift are in Y units.
|
||||||
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* values, int count, double height=0.67, double shift=0, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* values, int count, double height=0.67, double shift=0, int offset=0, int stride=sizeof(T));
|
||||||
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double height, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double height, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotBarsHG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double height);
|
IMPLOT_API void PlotBarsHG(const char* label_id, ImPlotGetter getter, void* data, int count, double height);
|
||||||
|
|
||||||
// Plots vertical error bar. The label_id should be the same as the label_id of the associated line or bar plot.
|
// Plots vertical error bar. The label_id should be the same as the label_id of the associated line or bar plot.
|
||||||
template <typename T> IMPLOT_API void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset=0, int stride=sizeof(T));
|
||||||
|
@ -566,13 +734,13 @@ template <typename T> IMPLOT_API void PlotHeatmap(const char* label_id, const T*
|
||||||
template <typename T> IMPLOT_API double PlotHistogram(const char* label_id, const T* values, int count, int bins=ImPlotBin_Sturges, bool cumulative=false, bool density=false, ImPlotRange range=ImPlotRange(), bool outliers=true, double bar_scale=1.0);
|
template <typename T> IMPLOT_API double PlotHistogram(const char* label_id, const T* values, int count, int bins=ImPlotBin_Sturges, bool cumulative=false, bool density=false, ImPlotRange range=ImPlotRange(), bool outliers=true, double bar_scale=1.0);
|
||||||
|
|
||||||
// Plots two dimensional, bivariate histogram as a heatmap. #x_bins and #y_bins can be a positive integer or an ImPlotBin. If #density is true, the PDF is visualized.
|
// Plots two dimensional, bivariate histogram as a heatmap. #x_bins and #y_bins can be a positive integer or an ImPlotBin. If #density is true, the PDF is visualized.
|
||||||
// If #range is left unspecified, the min/max of #xs an #ys will be used as the ranges. If #range is specified, outlier values outside of range are not binned.
|
// If #bounds is left unspecified, the min/max of #xs an #ys will be used as the ranges. If #bounds is specified, outlier values outside of range are not binned.
|
||||||
// However, outliers still count toward the normalizing count for density plots unless #outliers is false. The largest bin count or density is returned.
|
// However, outliers still count toward the normalizing count for density plots unless #outliers is false. The largest bin count or density is returned.
|
||||||
template <typename T> IMPLOT_API double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count, int x_bins=ImPlotBin_Sturges, int y_bins=ImPlotBin_Sturges, bool density=false, ImPlotLimits range=ImPlotLimits(), bool outliers=true);
|
template <typename T> IMPLOT_API double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count, int x_bins=ImPlotBin_Sturges, int y_bins=ImPlotBin_Sturges, bool density=false, ImPlotRect range=ImPlotRect(), bool outliers=true);
|
||||||
|
|
||||||
// Plots digital data. Digital plots do not respond to y drag or zoom, and are always referenced to the bottom of the plot.
|
// Plots digital data. Digital plots do not respond to y drag or zoom, and are always referenced to the bottom of the plot.
|
||||||
template <typename T> IMPLOT_API void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
template <typename T> IMPLOT_API void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count);
|
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
||||||
|
|
||||||
// Plots an axis-aligned image. #bounds_min/bounds_max are in plot coordinates (y-up) and #uv0/uv1 are in texture coordinates (y-down).
|
// Plots an axis-aligned image. #bounds_min/bounds_max are in plot coordinates (y-up) and #uv0/uv1 are in texture coordinates (y-down).
|
||||||
IMPLOT_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max, const ImVec2& uv0=ImVec2(0,0), const ImVec2& uv1=ImVec2(1,1), const ImVec4& tint_col=ImVec4(1,1,1,1));
|
IMPLOT_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max, const ImVec2& uv0=ImVec2(0,0), const ImVec2& uv1=ImVec2(1,1), const ImVec4& tint_col=ImVec4(1,1,1,1));
|
||||||
|
@ -584,145 +752,111 @@ IMPLOT_API void PlotText(const char* text, double x, double y, bool vertical=fal
|
||||||
IMPLOT_API void PlotDummy(const char* label_id);
|
IMPLOT_API void PlotDummy(const char* label_id);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Plot Utils
|
// [SECTION] Plot Tools
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// The following functions MUST be called BEFORE BeginPlot!
|
// The following can be used to render interactive elements and/or annotations.
|
||||||
|
// Like the item plotting functions above, they apply to the current x and y
|
||||||
|
// axes, which can be changed with `SetAxis/SetAxes`.
|
||||||
|
|
||||||
// Set the axes range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the axes limits will be locked.
|
// Shows a draggable point at x,y. #col defaults to ImGuiCol_Text.
|
||||||
IMPLOT_API void SetNextPlotLimits(double xmin, double xmax, double ymin, double ymax, ImGuiCond cond = ImGuiCond_Once);
|
IMPLOT_API bool DragPoint(int id, double* x, double* y, const ImVec4& col, float size = 4, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
||||||
// Set the X axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the X axis limits will be locked.
|
// Shows a draggable vertical guide line at an x-value. #col defaults to ImGuiCol_Text.
|
||||||
IMPLOT_API void SetNextPlotLimitsX(double xmin, double xmax, ImGuiCond cond = ImGuiCond_Once);
|
IMPLOT_API bool DragLineX(int id, double* x, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
||||||
// Set the Y axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the Y axis limits will be locked.
|
// Shows a draggable horizontal guide line at a y-value. #col defaults to ImGuiCol_Text.
|
||||||
IMPLOT_API void SetNextPlotLimitsY(double ymin, double ymax, ImGuiCond cond = ImGuiCond_Once, ImPlotYAxis y_axis = ImPlotYAxis_1);
|
IMPLOT_API bool DragLineY(int id, double* y, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
||||||
// Links the next plot limits to external values. Set to NULL for no linkage. The pointer data must remain valid until the matching call to EndPlot.
|
// Shows a draggable and resizeable rectangle.
|
||||||
IMPLOT_API void LinkNextPlotLimits(double* xmin, double* xmax, double* ymin, double* ymax, double* ymin2 = NULL, double* ymax2 = NULL, double* ymin3 = NULL, double* ymax3 = NULL);
|
IMPLOT_API bool DragRect(int id, double* x_min, double* y_min, double* x_max, double* y_max, const ImVec4& col, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
||||||
// Fits the next plot axes to all plotted data if they are unlocked (equivalent to double-clicks).
|
|
||||||
IMPLOT_API void FitNextPlotAxes(bool x = true, bool y = true, bool y2 = true, bool y3 = true);
|
|
||||||
|
|
||||||
// Set the X axis ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
|
// Shows an annotation callout at a chosen point. Clamping keeps annotations in the plot area. Annotations are always rendered on top.
|
||||||
IMPLOT_API void SetNextPlotTicksX(const double* values, int n_ticks, const char* const labels[] = NULL, bool keep_default = false);
|
IMPLOT_API void Annotation(double x, double y, const ImVec4& color, const ImVec2& pix_offset, bool clamp, bool round = false);
|
||||||
IMPLOT_API void SetNextPlotTicksX(double x_min, double x_max, int n_ticks, const char* const labels[] = NULL, bool keep_default = false);
|
IMPLOT_API void Annotation(double x, double y, const ImVec4& color, const ImVec2& pix_offset, bool clamp, const char* fmt, ...) IM_FMTARGS(6);
|
||||||
// Set the Y axis ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
|
IMPLOT_API void AnnotationV(double x, double y, const ImVec4& color, const ImVec2& pix_offset, bool clamp, const char* fmt, va_list args) IM_FMTLIST(6);
|
||||||
IMPLOT_API void SetNextPlotTicksY(const double* values, int n_ticks, const char* const labels[] = NULL, bool keep_default = false, ImPlotYAxis y_axis = ImPlotYAxis_1);
|
|
||||||
IMPLOT_API void SetNextPlotTicksY(double y_min, double y_max, int n_ticks, const char* const labels[] = NULL, bool keep_default = false, ImPlotYAxis y_axis = ImPlotYAxis_1);
|
|
||||||
|
|
||||||
// Set the format for numeric X axis labels (default="%g"). Formated values will be doubles (i.e. don't supply %d, %i, etc.). Not applicable if ImPlotAxisFlags_Time enabled.
|
// Shows a x-axis tag at the specified coordinate value.
|
||||||
IMPLOT_API void SetNextPlotFormatX(const char* fmt);
|
IMPLOT_API void TagX(double x, const ImVec4& color, bool round = false);
|
||||||
// Set the format for numeric Y axis labels (default="%g"). Formated values will be doubles (i.e. don't supply %d, %i, etc.).
|
IMPLOT_API void TagX(double x, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(3);
|
||||||
IMPLOT_API void SetNextPlotFormatY(const char* fmt, ImPlotYAxis y_axis=ImPlotYAxis_1);
|
IMPLOT_API void TagXV(double x, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||||
|
|
||||||
// The following functions MUST be called BETWEEN Begin/EndPlot!
|
// Shows a y-axis tag at the specified coordinate value.
|
||||||
|
IMPLOT_API void TagY(double y, const ImVec4& color, bool round = false);
|
||||||
|
IMPLOT_API void TagY(double y, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(3);
|
||||||
|
IMPLOT_API void TagYV(double y, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||||
|
|
||||||
// Select which Y axis will be used for subsequent plot elements. The default is ImPlotYAxis_1, or the first (left) Y axis. Enable 2nd and 3rd axes with ImPlotFlags_YAxisX.
|
//-----------------------------------------------------------------------------
|
||||||
IMPLOT_API void SetPlotYAxis(ImPlotYAxis y_axis);
|
// [SECTION] Plot Utils
|
||||||
// Hides or shows the next plot item (i.e. as if it were toggled from the legend). Use ImGuiCond_Always if you need to forcefully set this every frame.
|
//-----------------------------------------------------------------------------
|
||||||
IMPLOT_API void HideNextItem(bool hidden = true, ImGuiCond cond = ImGuiCond_Once);
|
|
||||||
|
// Select which axis/axes will be used for subsequent plot elements.
|
||||||
|
IMPLOT_API void SetAxis(ImAxis axis);
|
||||||
|
IMPLOT_API void SetAxes(ImAxis x_axis, ImAxis y_axis);
|
||||||
|
|
||||||
|
// Convert pixels to a position in the current plot's coordinate system. Passing IMPLOT_AUTO uses the current axes.
|
||||||
|
IMPLOT_API ImPlotPoint PixelsToPlot(const ImVec2& pix, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
IMPLOT_API ImPlotPoint PixelsToPlot(float x, float y, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
|
||||||
|
// Convert a position in the current plot's coordinate system to pixels. Passing IMPLOT_AUTO uses the current axes.
|
||||||
|
IMPLOT_API ImVec2 PlotToPixels(const ImPlotPoint& plt, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
IMPLOT_API ImVec2 PlotToPixels(double x, double y, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
|
||||||
// Convert pixels to a position in the current plot's coordinate system. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
|
||||||
IMPLOT_API ImPlotPoint PixelsToPlot(const ImVec2& pix, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
IMPLOT_API ImPlotPoint PixelsToPlot(float x, float y, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
// Convert a position in the current plot's coordinate system to pixels. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
|
||||||
IMPLOT_API ImVec2 PlotToPixels(const ImPlotPoint& plt, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
IMPLOT_API ImVec2 PlotToPixels(double x, double y, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
// Get the current Plot position (top-left) in pixels.
|
// Get the current Plot position (top-left) in pixels.
|
||||||
IMPLOT_API ImVec2 GetPlotPos();
|
IMPLOT_API ImVec2 GetPlotPos();
|
||||||
// Get the curent Plot size in pixels.
|
// Get the curent Plot size in pixels.
|
||||||
IMPLOT_API ImVec2 GetPlotSize();
|
IMPLOT_API ImVec2 GetPlotSize();
|
||||||
|
|
||||||
|
// Returns the mouse position in x,y coordinates of the current plot. Passing IMPLOT_AUTO uses the current axes.
|
||||||
|
IMPLOT_API ImPlotPoint GetPlotMousePos(ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
// Returns the current plot axis range.
|
||||||
|
IMPLOT_API ImPlotRect GetPlotLimits(ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
|
||||||
// Returns true if the plot area in the current plot is hovered.
|
// Returns true if the plot area in the current plot is hovered.
|
||||||
IMPLOT_API bool IsPlotHovered();
|
IMPLOT_API bool IsPlotHovered();
|
||||||
// Returns true if the XAxis plot area in the current plot is hovered.
|
// Returns true if the axis label area in the current plot is hovered.
|
||||||
IMPLOT_API bool IsPlotXAxisHovered();
|
IMPLOT_API bool IsAxisHovered(ImAxis axis);
|
||||||
// Returns true if the YAxis[n] plot area in the current plot is hovered.
|
// Returns true if the bounding frame of a subplot is hovered.
|
||||||
IMPLOT_API bool IsPlotYAxisHovered(ImPlotYAxis y_axis = 0);
|
IMPLOT_API bool IsSubplotsHovered();
|
||||||
// Returns the mouse position in x,y coordinates of the current plot. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
|
||||||
IMPLOT_API ImPlotPoint GetPlotMousePos(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
// Returns the current plot axis range. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
|
||||||
IMPLOT_API ImPlotLimits GetPlotLimits(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
|
|
||||||
// Returns true if the current plot is being box selected.
|
// Returns true if the current plot is being box selected.
|
||||||
IMPLOT_API bool IsPlotSelected();
|
IMPLOT_API bool IsPlotSelected();
|
||||||
// Returns the current plot box selection bounds.
|
// Returns the current plot box selection bounds. Passing IMPLOT_AUTO uses the current axes.
|
||||||
IMPLOT_API ImPlotLimits GetPlotSelection(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
IMPLOT_API ImPlotRect GetPlotSelection(ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO);
|
||||||
|
// Cancels a the current plot box selection.
|
||||||
|
IMPLOT_API void CancelPlotSelection();
|
||||||
|
|
||||||
// Returns true if the current plot is being queried or has an active query. Query must be enabled with ImPlotFlags_Query.
|
// Hides or shows the next plot item (i.e. as if it were toggled from the legend).
|
||||||
IMPLOT_API bool IsPlotQueried();
|
// Use ImPlotCond_Always if you need to forcefully set this every frame.
|
||||||
// Returns the current plot query bounds. Query must be enabled with ImPlotFlags_Query.
|
IMPLOT_API void HideNextItem(bool hidden = true, ImPlotCond cond = ImPlotCond_Once);
|
||||||
IMPLOT_API ImPlotLimits GetPlotQuery(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
// Set the current plot query bounds. Query must be enabled with ImPlotFlags_Query.
|
|
||||||
IMPLOT_API void SetPlotQuery(const ImPlotLimits& query, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
|
||||||
|
|
||||||
// Returns true if the bounding frame of a subplot is hovered/
|
|
||||||
IMPLOT_API bool IsSubplotsHovered();
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Aligned Plots
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
// Use the following around calls to Begin/EndPlot to align l/r/t/b padding.
|
||||||
// Consider using Begin/EndSubplots first. They are more feature rich and
|
// Consider using Begin/EndSubplots first. They are more feature rich and
|
||||||
// accomplish the same behaviour by default. The functions below offer lower
|
// accomplish the same behaviour by default. The functions below offer lower
|
||||||
// level control of plot alignment.
|
// level control of plot alignment.
|
||||||
|
|
||||||
// Align axis padding over multiple plots in a single row or column. If this function returns true, EndAlignedPlots() must be called. #group_id must be unique.
|
// Align axis padding over multiple plots in a single row or column. #group_id must
|
||||||
IMPLOT_API bool BeginAlignedPlots(const char* group_id, ImPlotOrientation orientation = ImPlotOrientation_Vertical);
|
// be unique. If this function returns true, EndAlignedPlots() must be called.
|
||||||
|
IMPLOT_API bool BeginAlignedPlots(const char* group_id, bool vertical = true);
|
||||||
// Only call EndAlignedPlots() if BeginAlignedPlots() returns true!
|
// Only call EndAlignedPlots() if BeginAlignedPlots() returns true!
|
||||||
IMPLOT_API void EndAlignedPlots();
|
IMPLOT_API void EndAlignedPlots();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Plot Tools
|
// [SECTION] Legend Utils
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// The following functions MUST be called BETWEEN Begin/EndPlot!
|
|
||||||
|
|
||||||
// Shows an annotation callout at a chosen point.
|
|
||||||
IMPLOT_API void Annotate(double x, double y, const ImVec2& pix_offset, const char* fmt, ...) IM_FMTARGS(4);
|
|
||||||
IMPLOT_API void Annotate(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(5);
|
|
||||||
IMPLOT_API void AnnotateV(double x, double y, const ImVec2& pix_offset, const char* fmt, va_list args) IM_FMTLIST(4);
|
|
||||||
IMPLOT_API void AnnotateV(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(5);
|
|
||||||
|
|
||||||
// Same as above, but the annotation will always be clamped to stay inside the plot area.
|
|
||||||
IMPLOT_API void AnnotateClamped(double x, double y, const ImVec2& pix_offset, const char* fmt, ...) IM_FMTARGS(4);
|
|
||||||
IMPLOT_API void AnnotateClamped(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(5);
|
|
||||||
IMPLOT_API void AnnotateClampedV(double x, double y, const ImVec2& pix_offset, const char* fmt, va_list args) IM_FMTLIST(4);
|
|
||||||
IMPLOT_API void AnnotateClampedV(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(5);
|
|
||||||
|
|
||||||
// Shows a draggable vertical guide line at an x-value. #col defaults to ImGuiCol_Text.
|
|
||||||
IMPLOT_API bool DragLineX(const char* id, double* x_value, bool show_label = true, const ImVec4& col = IMPLOT_AUTO_COL, float thickness = 1);
|
|
||||||
// Shows a draggable horizontal guide line at a y-value. #col defaults to ImGuiCol_Text.
|
|
||||||
IMPLOT_API bool DragLineY(const char* id, double* y_value, bool show_label = true, const ImVec4& col = IMPLOT_AUTO_COL, float thickness = 1);
|
|
||||||
// Shows a draggable point at x,y. #col defaults to ImGuiCol_Text.
|
|
||||||
IMPLOT_API bool DragPoint(const char* id, double* x, double* y, bool show_label = true, const ImVec4& col = IMPLOT_AUTO_COL, float radius = 4);
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Legend Utils and Tools
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// The following functions MUST be called BETWEEN Begin/EndPlot!
|
|
||||||
|
|
||||||
// Set the location of the current plot's (or subplot's) legend.
|
|
||||||
IMPLOT_API void SetLegendLocation(ImPlotLocation location, ImPlotOrientation orientation = ImPlotOrientation_Vertical, bool outside = false);
|
|
||||||
// Set the location of the current plot's mouse position text (default = South|East).
|
|
||||||
IMPLOT_API void SetMousePosLocation(ImPlotLocation location);
|
|
||||||
// Returns true if a plot item legend entry is hovered.
|
|
||||||
IMPLOT_API bool IsLegendEntryHovered(const char* label_id);
|
|
||||||
|
|
||||||
// Begin a popup for a legend entry.
|
// Begin a popup for a legend entry.
|
||||||
IMPLOT_API bool BeginLegendPopup(const char* label_id, ImGuiMouseButton mouse_button = 1);
|
IMPLOT_API bool BeginLegendPopup(const char* label_id, ImGuiMouseButton mouse_button = 1);
|
||||||
// End a popup for a legend entry.
|
// End a popup for a legend entry.
|
||||||
IMPLOT_API void EndLegendPopup();
|
IMPLOT_API void EndLegendPopup();
|
||||||
|
// Returns true if a plot item legend entry is hovered.
|
||||||
|
IMPLOT_API bool IsLegendEntryHovered(const char* label_id);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Drag and Drop Utils
|
// [SECTION] Drag and Drop
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// The following functions MUST be called BETWEEN Begin/EndPlot!
|
|
||||||
|
|
||||||
// Turns the current plot's plotting area into a drag and drop target. Don't forget to call EndDragDropTarget!
|
// Turns the current plot's plotting area into a drag and drop target. Don't forget to call EndDragDropTarget!
|
||||||
IMPLOT_API bool BeginDragDropTarget();
|
IMPLOT_API bool BeginDragDropTargetPlot();
|
||||||
// Turns the current plot's X-axis into a drag and drop target. Don't forget to call EndDragDropTarget!
|
// Turns the current plot's X-axis into a drag and drop target. Don't forget to call EndDragDropTarget!
|
||||||
IMPLOT_API bool BeginDragDropTargetX();
|
IMPLOT_API bool BeginDragDropTargetAxis(ImAxis axis);
|
||||||
// Turns the current plot's Y-Axis into a drag and drop target. Don't forget to call EndDragDropTarget!
|
|
||||||
IMPLOT_API bool BeginDragDropTargetY(ImPlotYAxis axis = ImPlotYAxis_1);
|
|
||||||
// Turns the current plot's legend into a drag and drop target. Don't forget to call EndDragDropTarget!
|
// Turns the current plot's legend into a drag and drop target. Don't forget to call EndDragDropTarget!
|
||||||
IMPLOT_API bool BeginDragDropTargetLegend();
|
IMPLOT_API bool BeginDragDropTargetLegend();
|
||||||
// Ends a drag and drop target (currently just an alias for ImGui::EndDragDropTarget).
|
// Ends a drag and drop target (currently just an alias for ImGui::EndDragDropTarget).
|
||||||
|
@ -731,19 +865,17 @@ IMPLOT_API void EndDragDropTarget();
|
||||||
// NB: By default, plot and axes drag and drop *sources* require holding the Ctrl modifier to initiate the drag.
|
// NB: By default, plot and axes drag and drop *sources* require holding the Ctrl modifier to initiate the drag.
|
||||||
// You can change the modifier if desired. If ImGuiKeyModFlags_None is provided, the axes will be locked from panning.
|
// You can change the modifier if desired. If ImGuiKeyModFlags_None is provided, the axes will be locked from panning.
|
||||||
|
|
||||||
// Turns the current plot's plotting area into a drag and drop source. Don't forget to call EndDragDropSource!
|
// Turns the current plot's plotting area into a drag and drop source. You must hold Ctrl. Don't forget to call EndDragDropSource!
|
||||||
IMPLOT_API bool BeginDragDropSource(ImGuiKeyModFlags key_mods = ImGuiKeyModFlags_Ctrl, ImGuiDragDropFlags flags = 0);
|
IMPLOT_API bool BeginDragDropSourcePlot(ImGuiDragDropFlags flags = 0);
|
||||||
// Turns the current plot's X-axis into a drag and drop source. Don't forget to call EndDragDropSource!
|
// Turns the current plot's X-axis into a drag and drop source. You must hold Ctrl. Don't forget to call EndDragDropSource!
|
||||||
IMPLOT_API bool BeginDragDropSourceX(ImGuiKeyModFlags key_mods = ImGuiKeyModFlags_Ctrl, ImGuiDragDropFlags flags = 0);
|
IMPLOT_API bool BeginDragDropSourceAxis(ImAxis axis, ImGuiDragDropFlags flags = 0);
|
||||||
// Turns the current plot's Y-axis into a drag and drop source. Don't forget to call EndDragDropSource!
|
|
||||||
IMPLOT_API bool BeginDragDropSourceY(ImPlotYAxis axis = ImPlotYAxis_1, ImGuiKeyModFlags key_mods = ImGuiKeyModFlags_Ctrl, ImGuiDragDropFlags flags = 0);
|
|
||||||
// Turns an item in the current plot's legend into drag and drop source. Don't forget to call EndDragDropSource!
|
// Turns an item in the current plot's legend into drag and drop source. Don't forget to call EndDragDropSource!
|
||||||
IMPLOT_API bool BeginDragDropSourceItem(const char* label_id, ImGuiDragDropFlags flags = 0);
|
IMPLOT_API bool BeginDragDropSourceItem(const char* label_id, ImGuiDragDropFlags flags = 0);
|
||||||
// Ends a drag and drop source (currently just an alias for ImGui::EndDragDropSource).
|
// Ends a drag and drop source (currently just an alias for ImGui::EndDragDropSource).
|
||||||
IMPLOT_API void EndDragDropSource();
|
IMPLOT_API void EndDragDropSource();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Plot and Item Styling
|
// [SECTION] Styling
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Styling colors in ImPlot works similarly to styling colors in ImGui, but
|
// Styling colors in ImPlot works similarly to styling colors in ImGui, but
|
||||||
|
@ -829,7 +961,7 @@ IMPLOT_API const char* GetStyleColorName(ImPlotCol idx);
|
||||||
IMPLOT_API const char* GetMarkerName(ImPlotMarker idx);
|
IMPLOT_API const char* GetMarkerName(ImPlotMarker idx);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Colormaps
|
// [SECTION] Colormaps
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Item styling is based on colormaps when the relevant ImPlotCol_XXX is set to
|
// Item styling is based on colormaps when the relevant ImPlotCol_XXX is set to
|
||||||
|
@ -879,7 +1011,7 @@ IMPLOT_API ImVec4 GetColormapColor(int idx, ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
IMPLOT_API ImVec4 SampleColormap(float t, ImPlotColormap cmap = IMPLOT_AUTO);
|
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").
|
// Shows a vertical color scale with linear spaced ticks using the specified color map. Use double hashes to hide label (e.g. "##NoLabel").
|
||||||
IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), ImPlotColormap cmap = IMPLOT_AUTO, const char* fmt = "%g");
|
IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), ImPlotColormap cmap = IMPLOT_AUTO, const char* format = "%g");
|
||||||
// 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 = NULL, const char* format = "", ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Shows a button with a colormap gradient brackground.
|
// Shows a button with a colormap gradient brackground.
|
||||||
|
@ -895,7 +1027,19 @@ IMPLOT_API bool ColormapButton(const char* label, const ImVec2& size = ImVec2(0,
|
||||||
IMPLOT_API void BustColorCache(const char* plot_title_id = NULL);
|
IMPLOT_API void BustColorCache(const char* plot_title_id = NULL);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Miscellaneous
|
// [SECTION] Input Mapping
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Provides access to input mapping structure for permanant modifications to controls for pan, select, etc.
|
||||||
|
IMPLOT_API ImPlotInputMap& GetInputMap();
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Miscellaneous
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Render icons similar to those that appear in legends (nifty for data lists).
|
// Render icons similar to those that appear in legends (nifty for data lists).
|
||||||
|
@ -914,6 +1058,8 @@ IMPLOT_API void PopPlotClipRect();
|
||||||
IMPLOT_API bool ShowStyleSelector(const char* label);
|
IMPLOT_API bool ShowStyleSelector(const char* label);
|
||||||
// Shows ImPlot colormap selector dropdown menu.
|
// Shows ImPlot colormap selector dropdown menu.
|
||||||
IMPLOT_API bool ShowColormapSelector(const char* label);
|
IMPLOT_API bool ShowColormapSelector(const char* label);
|
||||||
|
// Shows ImPlot input map selector dropdown menu.
|
||||||
|
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 = NULL);
|
||||||
// Add basic help/info block for end users (not a window).
|
// Add basic help/info block for end users (not a window).
|
||||||
|
@ -922,10 +1068,59 @@ IMPLOT_API void ShowUserGuide();
|
||||||
IMPLOT_API void ShowMetricsWindow(bool* p_popen = NULL);
|
IMPLOT_API void ShowMetricsWindow(bool* p_popen = NULL);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Demo (add implot_demo.cpp to your sources!)
|
// [SECTION] Demo
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Shows the ImPlot demo window.
|
// 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 = NULL);
|
||||||
|
|
||||||
} // namespace ImPlot
|
} // namespace ImPlot
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Obsolete API
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// The following functions will be removed! Keep your copy of implot up to date!
|
||||||
|
// Occasionally set '#define IMPLOT_DISABLE_OBSOLETE_FUNCTIONS' to stay ahead.
|
||||||
|
// If you absolutely must use these functions and do not want to receive compiler
|
||||||
|
// warnings, set '#define IMPLOT_DISABLE_OBSOLETE_WARNINGS'.
|
||||||
|
|
||||||
|
#ifndef IMPLOT_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
|
||||||
|
#ifndef IMPLOT_DISABLE_DEPRECATED_WARNINGS
|
||||||
|
#if __cplusplus > 201402L
|
||||||
|
#define IMPLOT_DEPRECATED(method) [[deprecated]] method
|
||||||
|
#elif defined( __GNUC__ ) && !defined( __INTEL_COMPILER ) && ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 1 ) )
|
||||||
|
#define IMPLOT_DEPRECATED(method) method __attribute__( ( deprecated ) )
|
||||||
|
#elif defined( _MSC_VER )
|
||||||
|
#define IMPLOT_DEPRECATED(method) __declspec(deprecated) method
|
||||||
|
#else
|
||||||
|
#define IMPLOT_DEPRECATED(method) method
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define IMPLOT_DEPRECATED(method) method
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum ImPlotFlagsObsolete_ {
|
||||||
|
ImPlotFlags_YAxis2 = 1 << 10,
|
||||||
|
ImPlotFlags_YAxis3 = 1 << 11,
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace ImPlot {
|
||||||
|
|
||||||
|
// OBSOLETED in v0.13 -> PLANNED REMOVAL in v1.0
|
||||||
|
IMPLOT_DEPRECATED( IMPLOT_API bool BeginPlot(const char* title_id,
|
||||||
|
const char* x_label, // = NULL,
|
||||||
|
const char* y_label, // = NULL,
|
||||||
|
const ImVec2& size = ImVec2(-1,0),
|
||||||
|
ImPlotFlags flags = ImPlotFlags_None,
|
||||||
|
ImPlotAxisFlags x_flags = ImPlotAxisFlags_None,
|
||||||
|
ImPlotAxisFlags y_flags = ImPlotAxisFlags_None,
|
||||||
|
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_AuxDefault,
|
||||||
|
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_AuxDefault,
|
||||||
|
const char* y2_label = NULL,
|
||||||
|
const char* y3_label = NULL) );
|
||||||
|
|
||||||
|
} // namespace ImPlot
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
847
implot_demo.cpp
847
implot_demo.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
201
implot_items.cpp
201
implot_items.cpp
|
@ -20,7 +20,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
// ImPlot v0.12 WIP
|
// ImPlot v0.13 WIP
|
||||||
|
|
||||||
#include "implot.h"
|
#include "implot.h"
|
||||||
#include "implot_internal.h"
|
#include "implot_internal.h"
|
||||||
|
@ -52,9 +52,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined __SSE__ || defined __x86_64__ || defined _M_X64
|
#if defined __SSE__ || defined __x86_64__ || defined _M_X64
|
||||||
static IMPLOT_INLINE float ImInvSqrt(float x) { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); }
|
#ifndef IMGUI_ENABLE_SSE
|
||||||
|
#include <immintrin.h>
|
||||||
|
#endif
|
||||||
|
static IMPLOT_INLINE float ImInvSqrt(float x) { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); }
|
||||||
#else
|
#else
|
||||||
static IMPLOT_INLINE float ImInvSqrt(float x) { return 1.0f / sqrtf(x); }
|
static IMPLOT_INLINE float ImInvSqrt(float x) { return 1.0f / sqrtf(x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IMPLOT_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImInvSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
#define IMPLOT_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImInvSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
||||||
|
@ -168,13 +171,6 @@ ImVec4 GetLastItemColor() {
|
||||||
return ImVec4();
|
return ImVec4();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HideNextItem(bool hidden, ImGuiCond cond) {
|
|
||||||
ImPlotContext& gp = *GImPlot;
|
|
||||||
gp.NextItemData.HasHidden = true;
|
|
||||||
gp.NextItemData.Hidden = hidden;
|
|
||||||
gp.NextItemData.HiddenCond = cond;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BustItemCache() {
|
void BustItemCache() {
|
||||||
ImPlotContext& gp = *GImPlot;
|
ImPlotContext& gp = *GImPlot;
|
||||||
Backend::BustItemCache();
|
Backend::BustItemCache();
|
||||||
|
@ -210,10 +206,14 @@ void BustColorCache(const char* plot_title_id) {
|
||||||
// Begin/EndItem
|
// Begin/EndItem
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static const float ITEM_HIGHLIGHT_LINE_SCALE = 2.0f;
|
||||||
|
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, ImPlotCol recolor_from) {
|
bool BeginItem(const char* label_id, 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 != NULL, "PlotX() needs to be called between BeginPlot() and EndPlot()!");
|
||||||
|
SetupLock();
|
||||||
bool just_created;
|
bool just_created;
|
||||||
ImPlotItem* item = RegisterOrGetItem(label_id, &just_created);
|
ImPlotItem* item = RegisterOrGetItem(label_id, &just_created);
|
||||||
// set current item
|
// set current item
|
||||||
|
@ -263,12 +263,21 @@ bool BeginItem(const char* label_id, ImPlotCol recolor_from) {
|
||||||
s.DigitalBitGap = s.DigitalBitGap < 0 ? gp.Style.DigitalBitGap : s.DigitalBitGap;
|
s.DigitalBitGap = s.DigitalBitGap < 0 ? gp.Style.DigitalBitGap : s.DigitalBitGap;
|
||||||
// apply alpha modifier(s)
|
// apply alpha modifier(s)
|
||||||
s.Colors[ImPlotCol_Fill].w *= s.FillAlpha;
|
s.Colors[ImPlotCol_Fill].w *= s.FillAlpha;
|
||||||
// s.Colors[ImPlotCol_MarkerFill].w *= s.FillAlpha; // TODO: this should be separate, if it at all
|
s.Colors[ImPlotCol_MarkerFill].w *= s.FillAlpha; // TODO: this should be separate, if it at all
|
||||||
// apply highlight mods
|
// apply highlight mods
|
||||||
if (item->LegendHovered && !ImHasFlag(gp.CurrentPlot->Flags, ImPlotFlags_NoHighlight)) {
|
if (item->LegendHovered) {
|
||||||
s.LineWeight *= 2;
|
if (!ImHasFlag(gp.CurrentItems->Legend.Flags, ImPlotLegendFlags_NoHighlightItem)) {
|
||||||
s.MarkerWeight *= 2;
|
s.LineWeight *= ITEM_HIGHLIGHT_LINE_SCALE;
|
||||||
// TODO: highlight fills?
|
s.MarkerSize *= ITEM_HIGHLIGHT_MARK_SCALE;
|
||||||
|
s.MarkerWeight *= ITEM_HIGHLIGHT_LINE_SCALE;
|
||||||
|
// TODO: how to highlight fills?
|
||||||
|
}
|
||||||
|
if (!ImHasFlag(gp.CurrentItems->Legend.Flags, ImPlotLegendFlags_NoHighlightAxis)) {
|
||||||
|
if (gp.CurrentPlot->EnabledAxesX() > 1)
|
||||||
|
gp.CurrentPlot->Axes[gp.CurrentPlot->CurrentX].ColorHiLi = item->Color;
|
||||||
|
if (gp.CurrentPlot->EnabledAxesY() > 1)
|
||||||
|
gp.CurrentPlot->Axes[gp.CurrentPlot->CurrentY].ColorHiLi = item->Color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// set render flags
|
// set render flags
|
||||||
s.RenderLine = s.Colors[ImPlotCol_Line].w > 0 && s.LineWeight > 0;
|
s.RenderLine = s.Colors[ImPlotCol_Line].w > 0 && s.LineWeight > 0;
|
||||||
|
@ -496,18 +505,34 @@ struct TransformerLog {
|
||||||
|
|
||||||
template <typename TransformerX, typename TransformerY>
|
template <typename TransformerX, typename TransformerY>
|
||||||
struct TransformerXY {
|
struct TransformerXY {
|
||||||
TransformerXY() :
|
TransformerXY(const ImPlotAxis& x_axis, const ImPlotAxis& y_axis) :
|
||||||
YAxis(GetCurrentYAxis()),
|
|
||||||
Tx(GImPlot->PixelRange[YAxis].Min.x, GImPlot->CurrentPlot->XAxis.Range.Min, GImPlot->CurrentPlot->XAxis.Range.Max, GImPlot->Mx, GImPlot->LogDenX),
|
Tx(x_axis.PixelMin,
|
||||||
Ty(GImPlot->PixelRange[YAxis].Min.y, GImPlot->CurrentPlot->YAxis[YAxis].Range.Min, GImPlot->CurrentPlot->YAxis[YAxis].Range.Max, GImPlot->My[YAxis], GImPlot->LogDenY[YAxis])
|
x_axis.Range.Min,
|
||||||
|
x_axis.Range.Max,
|
||||||
|
x_axis.LinM,
|
||||||
|
x_axis.LogD),
|
||||||
|
Ty(y_axis.PixelMin,
|
||||||
|
y_axis.Range.Min,
|
||||||
|
y_axis.Range.Max,
|
||||||
|
y_axis.LinM,
|
||||||
|
y_axis.LogD)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
TransformerXY(const ImPlotPlot& plot) :
|
||||||
|
TransformerXY(plot.Axes[plot.CurrentX], plot.Axes[plot.CurrentY])
|
||||||
|
{ }
|
||||||
|
|
||||||
|
TransformerXY() :
|
||||||
|
TransformerXY(*GImPlot->CurrentPlot)
|
||||||
|
{ }
|
||||||
|
|
||||||
template <typename P> IMPLOT_INLINE ImVec2 operator()(const P& plt) const {
|
template <typename P> IMPLOT_INLINE ImVec2 operator()(const P& plt) const {
|
||||||
ImVec2 out;
|
ImVec2 out;
|
||||||
out.x = Tx(plt.x);
|
out.x = Tx(plt.x);
|
||||||
out.y = Ty(plt.y);
|
out.y = Ty(plt.y);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
int YAxis;
|
|
||||||
TransformerX Tx;
|
TransformerX Tx;
|
||||||
TransformerY Ty;
|
TransformerY Ty;
|
||||||
};
|
};
|
||||||
|
@ -964,8 +989,9 @@ IMPLOT_INLINE void PlotLineEx(const char* label_id, const Getter& getter) {
|
||||||
}
|
}
|
||||||
// render markers
|
// render markers
|
||||||
if (s.Marker != ImPlotMarker_None) {
|
if (s.Marker != ImPlotMarker_None) {
|
||||||
PopPlotClipRect();
|
// uncomment lines below to render markers over plot rect border
|
||||||
PushPlotClipRect(s.MarkerSize);
|
// PopPlotClipRect();
|
||||||
|
// PushPlotClipRect(s.MarkerSize);
|
||||||
const ImU32 col_line = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerOutline]);
|
const ImU32 col_line = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerOutline]);
|
||||||
const ImU32 col_fill = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerFill]);
|
const ImU32 col_fill = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerFill]);
|
||||||
switch (GetCurrentScale()) {
|
switch (GetCurrentScale()) {
|
||||||
|
@ -1015,7 +1041,7 @@ template IMPLOT_API void PlotLine<float>(const char* label_id, const float* xs,
|
||||||
template IMPLOT_API void PlotLine<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
template IMPLOT_API void PlotLine<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotLineG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count) {
|
void PlotLineG(const char* label_id, ImPlotGetter getter_func, void* data, int count) {
|
||||||
GetterFuncPtr getter(getter_func,data, count);
|
GetterFuncPtr getter(getter_func,data, count);
|
||||||
return PlotLineEx(label_id, getter);
|
return PlotLineEx(label_id, getter);
|
||||||
}
|
}
|
||||||
|
@ -1038,8 +1064,9 @@ IMPLOT_INLINE void PlotScatterEx(const char* label_id, const Getter& getter) {
|
||||||
// render markers
|
// render markers
|
||||||
ImPlotMarker marker = s.Marker == ImPlotMarker_None ? ImPlotMarker_Circle : s.Marker;
|
ImPlotMarker marker = s.Marker == ImPlotMarker_None ? ImPlotMarker_Circle : s.Marker;
|
||||||
if (marker != ImPlotMarker_None) {
|
if (marker != ImPlotMarker_None) {
|
||||||
PopPlotClipRect();
|
// uncomment lines below to render markers over plot rect border
|
||||||
PushPlotClipRect(s.MarkerSize);
|
// PopPlotClipRect();
|
||||||
|
// PushPlotClipRect(s.MarkerSize);
|
||||||
const ImU32 col_line = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerOutline]);
|
const ImU32 col_line = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerOutline]);
|
||||||
const ImU32 col_fill = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerFill]);
|
const ImU32 col_fill = ImGui::GetColorU32(s.Colors[ImPlotCol_MarkerFill]);
|
||||||
switch (GetCurrentScale()) {
|
switch (GetCurrentScale()) {
|
||||||
|
@ -1088,7 +1115,7 @@ template IMPLOT_API void PlotScatter<float>(const char* label_id, const float* x
|
||||||
template IMPLOT_API void PlotScatter<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
template IMPLOT_API void PlotScatter<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotScatterG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count) {
|
void PlotScatterG(const char* label_id, ImPlotGetter getter_func, void* data, int count) {
|
||||||
GetterFuncPtr getter(getter_func,data, count);
|
GetterFuncPtr getter(getter_func,data, count);
|
||||||
return PlotScatterEx(label_id, getter);
|
return PlotScatterEx(label_id, getter);
|
||||||
}
|
}
|
||||||
|
@ -1169,7 +1196,7 @@ template IMPLOT_API void PlotStairs<float>(const char* label_id, const float* xs
|
||||||
template IMPLOT_API void PlotStairs<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
template IMPLOT_API void PlotStairs<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotStairsG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count) {
|
void PlotStairsG(const char* label_id, ImPlotGetter getter_func, void* data, int count) {
|
||||||
GetterFuncPtr getter(getter_func,data, count);
|
GetterFuncPtr getter(getter_func,data, count);
|
||||||
return PlotStairsEx(label_id, getter);
|
return PlotStairsEx(label_id, getter);
|
||||||
}
|
}
|
||||||
|
@ -1209,11 +1236,11 @@ void PlotShaded(const char* label_id, const T* values, int count, double y_ref,
|
||||||
bool fit2 = true;
|
bool fit2 = true;
|
||||||
if (y_ref == -HUGE_VAL) {
|
if (y_ref == -HUGE_VAL) {
|
||||||
fit2 = false;
|
fit2 = false;
|
||||||
y_ref = GetPlotLimits().Y.Min;
|
y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Min;
|
||||||
}
|
}
|
||||||
if (y_ref == HUGE_VAL) {
|
if (y_ref == HUGE_VAL) {
|
||||||
fit2 = false;
|
fit2 = false;
|
||||||
y_ref = GetPlotLimits().Y.Max;
|
y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Max;
|
||||||
}
|
}
|
||||||
GetterYs<T> getter1(values,count,xscale,x0,offset,stride);
|
GetterYs<T> getter1(values,count,xscale,x0,offset,stride);
|
||||||
GetterYRef getter2(y_ref,count,xscale,x0);
|
GetterYRef getter2(y_ref,count,xscale,x0);
|
||||||
|
@ -1236,11 +1263,11 @@ void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, doubl
|
||||||
bool fit2 = true;
|
bool fit2 = true;
|
||||||
if (y_ref == -HUGE_VAL) {
|
if (y_ref == -HUGE_VAL) {
|
||||||
fit2 = false;
|
fit2 = false;
|
||||||
y_ref = GetPlotLimits().Y.Min;
|
y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Min;
|
||||||
}
|
}
|
||||||
if (y_ref == HUGE_VAL) {
|
if (y_ref == HUGE_VAL) {
|
||||||
fit2 = false;
|
fit2 = false;
|
||||||
y_ref = GetPlotLimits().Y.Max;
|
y_ref = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO).Y.Max;
|
||||||
}
|
}
|
||||||
GetterXsYs<T> getter1(xs, ys, count, offset, stride);
|
GetterXsYs<T> getter1(xs, ys, count, offset, stride);
|
||||||
GetterXsYRef<T> getter2(xs, y_ref, count, offset, stride);
|
GetterXsYRef<T> getter2(xs, y_ref, count, offset, stride);
|
||||||
|
@ -1277,9 +1304,9 @@ template IMPLOT_API void PlotShaded<float>(const char* label_id, const float* xs
|
||||||
template IMPLOT_API void PlotShaded<double>(const char* label_id, const double* xs, const double* ys1, const double* ys2, int count, int offset, int stride);
|
template IMPLOT_API void PlotShaded<double>(const char* label_id, const double* xs, const double* ys1, const double* ys2, int count, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotShadedG(const char* label_id, ImPlotPoint (*g1)(void* data, int idx), void* data1, ImPlotPoint (*g2)(void* data, int idx), void* data2, int count) {
|
void PlotShadedG(const char* label_id, ImPlotGetter getter_func1, void* data1, ImPlotGetter getter_func2, void* data2, int count) {
|
||||||
GetterFuncPtr getter1(g1, data1, count);
|
GetterFuncPtr getter1(getter_func1, data1, count);
|
||||||
GetterFuncPtr getter2(g2, data2, count);
|
GetterFuncPtr getter2(getter_func2, data2, count);
|
||||||
PlotShadedEx(label_id, getter1, getter2, true);
|
PlotShadedEx(label_id, getter1, getter2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,8 +1338,8 @@ void PlotBarsEx(const char* label_id, const Getter& getter, double width) {
|
||||||
ImPlotPoint p = getter(i);
|
ImPlotPoint p = getter(i);
|
||||||
if (p.y == 0)
|
if (p.y == 0)
|
||||||
continue;
|
continue;
|
||||||
ImVec2 a = PlotToPixels(p.x - half_width, p.y);
|
ImVec2 a = PlotToPixels(p.x - half_width, p.y,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImVec2 b = PlotToPixels(p.x + half_width, 0);
|
ImVec2 b = PlotToPixels(p.x + half_width, 0,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
float width_px = ImAbs(a.x-b.x);
|
float width_px = ImAbs(a.x-b.x);
|
||||||
if (width_px < 1.0f) {
|
if (width_px < 1.0f) {
|
||||||
a.x += a.x > b.x ? (1-width_px) / 2 : (width_px-1) / 2;
|
a.x += a.x > b.x ? (1-width_px) / 2 : (width_px-1) / 2;
|
||||||
|
@ -1364,7 +1391,7 @@ template IMPLOT_API void PlotBars<float>(const char* label_id, const float* xs,
|
||||||
template IMPLOT_API void PlotBars<double>(const char* label_id, const double* xs, const double* ys, int count, double width, int offset, int stride);
|
template IMPLOT_API void PlotBars<double>(const char* label_id, const double* xs, const double* ys, int count, double width, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotBarsG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double width) {
|
void PlotBarsG(const char* label_id, ImPlotGetter getter_func, void* data, int count, double width) {
|
||||||
GetterFuncPtr getter(getter_func, data, count);
|
GetterFuncPtr getter(getter_func, data, count);
|
||||||
PlotBarsEx(label_id, getter, width);
|
PlotBarsEx(label_id, getter, width);
|
||||||
}
|
}
|
||||||
|
@ -1397,8 +1424,8 @@ void PlotBarsHEx(const char* label_id, const Getter& getter, THeight height) {
|
||||||
ImPlotPoint p = getter(i);
|
ImPlotPoint p = getter(i);
|
||||||
if (p.x == 0)
|
if (p.x == 0)
|
||||||
continue;
|
continue;
|
||||||
ImVec2 a = PlotToPixels(0, p.y - half_height);
|
ImVec2 a = PlotToPixels(0, p.y - half_height,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImVec2 b = PlotToPixels(p.x, p.y + half_height);
|
ImVec2 b = PlotToPixels(p.x, p.y + half_height,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
if (s.RenderFill)
|
if (s.RenderFill)
|
||||||
DrawList.AddRectFilled(a, b, col_fill);
|
DrawList.AddRectFilled(a, b, col_fill);
|
||||||
if (rend_line)
|
if (rend_line)
|
||||||
|
@ -1443,7 +1470,7 @@ template IMPLOT_API void PlotBarsH<float>(const char* label_id, const float* xs,
|
||||||
template IMPLOT_API void PlotBarsH<double>(const char* label_id, const double* xs, const double* ys, int count, double height, int offset, int stride);
|
template IMPLOT_API void PlotBarsH<double>(const char* label_id, const double* xs, const double* ys, int count, double height, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotBarsHG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count, double height) {
|
void PlotBarsHG(const char* label_id, ImPlotGetter getter_func, void* data, int count, double height) {
|
||||||
GetterFuncPtr getter(getter_func, data, count);
|
GetterFuncPtr getter(getter_func, data, count);
|
||||||
PlotBarsHEx(label_id, getter, height);
|
PlotBarsHEx(label_id, getter, height);
|
||||||
}
|
}
|
||||||
|
@ -1469,8 +1496,8 @@ void PlotErrorBarsEx(const char* label_id, const Getter& getter) {
|
||||||
const float half_whisker = s.ErrorBarSize * 0.5f;
|
const float half_whisker = s.ErrorBarSize * 0.5f;
|
||||||
for (int i = 0; i < getter.Count; ++i) {
|
for (int i = 0; i < getter.Count; ++i) {
|
||||||
ImPlotPointError e = getter(i);
|
ImPlotPointError e = getter(i);
|
||||||
ImVec2 p1 = PlotToPixels(e.X, e.Y - e.Neg);
|
ImVec2 p1 = PlotToPixels(e.X, e.Y - e.Neg,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImVec2 p2 = PlotToPixels(e.X, e.Y + e.Pos);
|
ImVec2 p2 = PlotToPixels(e.X, e.Y + e.Pos,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
DrawList.AddLine(p1,p2,col, s.ErrorBarWeight);
|
DrawList.AddLine(p1,p2,col, s.ErrorBarWeight);
|
||||||
if (rend_whisker) {
|
if (rend_whisker) {
|
||||||
DrawList.AddLine(p1 - ImVec2(half_whisker, 0), p1 + ImVec2(half_whisker, 0), col, s.ErrorBarWeight);
|
DrawList.AddLine(p1 - ImVec2(half_whisker, 0), p1 + ImVec2(half_whisker, 0), col, s.ErrorBarWeight);
|
||||||
|
@ -1536,8 +1563,8 @@ void PlotErrorBarsHEx(const char* label_id, const Getter& getter) {
|
||||||
const float half_whisker = s.ErrorBarSize * 0.5f;
|
const float half_whisker = s.ErrorBarSize * 0.5f;
|
||||||
for (int i = 0; i < getter.Count; ++i) {
|
for (int i = 0; i < getter.Count; ++i) {
|
||||||
ImPlotPointError e = getter(i);
|
ImPlotPointError e = getter(i);
|
||||||
ImVec2 p1 = PlotToPixels(e.X - e.Neg, e.Y);
|
ImVec2 p1 = PlotToPixels(e.X - e.Neg, e.Y,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImVec2 p2 = PlotToPixels(e.X + e.Pos, e.Y);
|
ImVec2 p2 = PlotToPixels(e.X + e.Pos, e.Y,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
DrawList.AddLine(p1, p2, col, s.ErrorBarWeight);
|
DrawList.AddLine(p1, p2, col, s.ErrorBarWeight);
|
||||||
if (rend_whisker) {
|
if (rend_whisker) {
|
||||||
DrawList.AddLine(p1 - ImVec2(0, half_whisker), p1 + ImVec2(0, half_whisker), col, s.ErrorBarWeight);
|
DrawList.AddLine(p1 - ImVec2(0, half_whisker), p1 + ImVec2(0, half_whisker), col, s.ErrorBarWeight);
|
||||||
|
@ -1668,7 +1695,7 @@ template IMPLOT_API void PlotStems<double>(const char* label_id, const double* x
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PlotVLines(const char* label_id, const T* xs, int count, int offset, int stride) {
|
void PlotVLines(const char* label_id, const T* xs, int count, int offset, int stride) {
|
||||||
if (BeginItem(label_id, ImPlotCol_Line)) {
|
if (BeginItem(label_id, ImPlotCol_Line)) {
|
||||||
const ImPlotLimits lims = GetPlotLimits();
|
const ImPlotRect lims = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
GetterXsYRef<T> get_min(xs,lims.Y.Min,count,offset,stride);
|
GetterXsYRef<T> get_min(xs,lims.Y.Min,count,offset,stride);
|
||||||
GetterXsYRef<T> get_max(xs,lims.Y.Max,count,offset,stride);
|
GetterXsYRef<T> get_max(xs,lims.Y.Max,count,offset,stride);
|
||||||
if (FitThisFrame()) {
|
if (FitThisFrame()) {
|
||||||
|
@ -1706,7 +1733,7 @@ template IMPLOT_API void PlotVLines<double>(const char* label_id, const double*
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PlotHLines(const char* label_id, const T* ys, int count, int offset, int stride) {
|
void PlotHLines(const char* label_id, const T* ys, int count, int offset, int stride) {
|
||||||
if (BeginItem(label_id, ImPlotCol_Line)) {
|
if (BeginItem(label_id, ImPlotCol_Line)) {
|
||||||
const ImPlotLimits lims = GetPlotLimits();
|
const ImPlotRect lims = GetPlotLimits(IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
GetterXRefYs<T> get_min(lims.X.Min,ys,count,offset,stride);
|
GetterXRefYs<T> get_min(lims.X.Min,ys,count,offset,stride);
|
||||||
GetterXRefYs<T> get_max(lims.X.Max,ys,count,offset,stride);
|
GetterXRefYs<T> get_max(lims.X.Max,ys,count,offset,stride);
|
||||||
if (FitThisFrame()) {
|
if (FitThisFrame()) {
|
||||||
|
@ -1747,12 +1774,12 @@ template IMPLOT_API void PlotHLines<double>(const char* label_id, const double*
|
||||||
IMPLOT_INLINE void RenderPieSlice(ImDrawList& DrawList, const ImPlotPoint& center, double radius, double a0, double a1, ImU32 col) {
|
IMPLOT_INLINE void RenderPieSlice(ImDrawList& DrawList, const ImPlotPoint& center, double radius, double a0, double a1, ImU32 col) {
|
||||||
static const float resolution = 50 / (2 * IM_PI);
|
static const float resolution = 50 / (2 * IM_PI);
|
||||||
static ImVec2 buffer[50];
|
static ImVec2 buffer[50];
|
||||||
buffer[0] = PlotToPixels(center);
|
buffer[0] = PlotToPixels(center,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
int n = ImMax(3, (int)((a1 - a0) * resolution));
|
int n = ImMax(3, (int)((a1 - a0) * resolution));
|
||||||
double da = (a1 - a0) / (n - 1);
|
double da = (a1 - a0) / (n - 1);
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
double a = a0 + i * da;
|
double a = a0 + i * da;
|
||||||
buffer[i + 1] = PlotToPixels(center.x + radius * cos(a), center.y + radius * sin(a));
|
buffer[i + 1] = PlotToPixels(center.x + radius * cos(a), center.y + radius * sin(a),IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
}
|
}
|
||||||
DrawList.AddConvexPolyFilled(buffer, n + 1, col);
|
DrawList.AddConvexPolyFilled(buffer, n + 1, col);
|
||||||
}
|
}
|
||||||
|
@ -1801,7 +1828,7 @@ void PlotPieChart(const char* const label_ids[], const T* values, int count, dou
|
||||||
sprintf(buffer, fmt, (double)values[i]);
|
sprintf(buffer, fmt, (double)values[i]);
|
||||||
ImVec2 size = ImGui::CalcTextSize(buffer);
|
ImVec2 size = ImGui::CalcTextSize(buffer);
|
||||||
double angle = a0 + (a1 - a0) * 0.5;
|
double angle = a0 + (a1 - a0) * 0.5;
|
||||||
ImVec2 pos = PlotToPixels(center.x + 0.5 * radius * cos(angle), center.y + 0.5 * radius * sin(angle));
|
ImVec2 pos = PlotToPixels(center.x + 0.5 * radius * cos(angle), center.y + 0.5 * radius * sin(angle),IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImU32 col = CalcTextColor(ImGui::ColorConvertU32ToFloat4(item->Color));
|
ImU32 col = CalcTextColor(ImGui::ColorConvertU32ToFloat4(item->Color));
|
||||||
DrawList.AddText(pos - size * 0.5f, col, buffer);
|
DrawList.AddText(pos - size * 0.5f, col, buffer);
|
||||||
}
|
}
|
||||||
|
@ -2025,8 +2052,8 @@ 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->Temp1;
|
ImVector<double>& bin_centers = GImPlot->TempDouble1;
|
||||||
ImVector<double>& bin_counts = GImPlot->Temp2;
|
ImVector<double>& bin_counts = GImPlot->TempDouble2;
|
||||||
bin_centers.resize(bins);
|
bin_centers.resize(bins);
|
||||||
bin_counts.resize(bins);
|
bin_counts.resize(bins);
|
||||||
int below = 0;
|
int below = 0;
|
||||||
|
@ -2093,7 +2120,7 @@ template IMPLOT_API double PlotHistogram<double>(const char* label_id, const dou
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers) {
|
double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers) {
|
||||||
|
|
||||||
if (count <= 0 || x_bins == 0 || y_bins == 0)
|
if (count <= 0 || x_bins == 0 || y_bins == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2123,7 +2150,7 @@ 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->Temp1;
|
ImVector<double>& bin_counts = GImPlot->TempDouble1;
|
||||||
bin_counts.resize(bins);
|
bin_counts.resize(bins);
|
||||||
|
|
||||||
for (int b = 0; b < bins; ++b)
|
for (int b = 0; b < bins; ++b)
|
||||||
|
@ -2166,16 +2193,16 @@ double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count
|
||||||
return max_count;
|
return max_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
template IMPLOT_API double PlotHistogram2D<ImS8>(const char* label_id, const ImS8* xs, const ImS8* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImS8>(const char* label_id, const ImS8* xs, const ImS8* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImU8>(const char* label_id, const ImU8* xs, const ImU8* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImU8>(const char* label_id, const ImU8* xs, const ImU8* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImS16>(const char* label_id, const ImS16* xs, const ImS16* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImS16>(const char* label_id, const ImS16* xs, const ImS16* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImU16>(const char* label_id, const ImU16* xs, const ImU16* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImU16>(const char* label_id, const ImU16* xs, const ImU16* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImS32>(const char* label_id, const ImS32* xs, const ImS32* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImS32>(const char* label_id, const ImS32* xs, const ImS32* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImU32>(const char* label_id, const ImU32* xs, const ImU32* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImU32>(const char* label_id, const ImU32* xs, const ImU32* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImS64>(const char* label_id, const ImS64* xs, const ImS64* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImS64>(const char* label_id, const ImS64* xs, const ImS64* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<ImU64>(const char* label_id, const ImU64* xs, const ImU64* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<ImU64>(const char* label_id, const ImU64* xs, const ImU64* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<float>(const char* label_id, const float* xs, const float* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<float>(const char* label_id, const float* xs, const float* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
template IMPLOT_API double PlotHistogram2D<double>(const char* label_id, const double* xs, const double* ys, int count, int x_bins, int y_bins, bool density, ImPlotLimits range, bool outliers);
|
template IMPLOT_API double PlotHistogram2D<double>(const char* label_id, const double* xs, const double* ys, int count, int x_bins, int y_bins, bool density, ImPlotRect range, bool outliers);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// PLOT DIGITAL
|
// PLOT DIGITAL
|
||||||
|
@ -2190,7 +2217,10 @@ IMPLOT_INLINE void PlotDigitalEx(const char* label_id, Getter getter) {
|
||||||
ImDrawList& DrawList = *GetPlotDrawList();
|
ImDrawList& DrawList = *GetPlotDrawList();
|
||||||
const ImPlotNextItemData& s = GetItemData();
|
const ImPlotNextItemData& s = GetItemData();
|
||||||
if (getter.Count > 1 && s.RenderFill) {
|
if (getter.Count > 1 && s.RenderFill) {
|
||||||
const int y_axis = GetCurrentYAxis();
|
ImPlotPlot& plot = *gp.CurrentPlot;
|
||||||
|
ImPlotAxis& x_axis = plot.Axes[plot.CurrentX];
|
||||||
|
ImPlotAxis& y_axis = plot.Axes[plot.CurrentY];
|
||||||
|
|
||||||
int pixYMax = 0;
|
int pixYMax = 0;
|
||||||
ImPlotPoint itemData1 = getter(0);
|
ImPlotPoint itemData1 = getter(0);
|
||||||
for (int i = 0; i < getter.Count; ++i) {
|
for (int i = 0; i < getter.Count; ++i) {
|
||||||
|
@ -2206,24 +2236,24 @@ IMPLOT_INLINE void PlotDigitalEx(const char* label_id, Getter getter) {
|
||||||
int pixY_1 = (int)(pixY_1_float); //allow only positive values
|
int pixY_1 = (int)(pixY_1_float); //allow only positive values
|
||||||
int pixY_chPosOffset = (int)(ImMax(s.DigitalBitHeight, pixY_1_float) + s.DigitalBitGap);
|
int pixY_chPosOffset = (int)(ImMax(s.DigitalBitHeight, pixY_1_float) + s.DigitalBitGap);
|
||||||
pixYMax = ImMax(pixYMax, pixY_chPosOffset);
|
pixYMax = ImMax(pixYMax, pixY_chPosOffset);
|
||||||
ImVec2 pMin = PlotToPixels(itemData1);
|
ImVec2 pMin = PlotToPixels(itemData1,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImVec2 pMax = PlotToPixels(itemData2);
|
ImVec2 pMax = PlotToPixels(itemData2,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
int pixY_Offset = 20; //20 pixel from bottom due to mouse cursor label
|
int pixY_Offset = 0; //20 pixel from bottom due to mouse cursor label
|
||||||
pMin.y = (gp.PixelRange[y_axis].Min.y) + ((-gp.DigitalPlotOffset) - pixY_Offset);
|
pMin.y = (y_axis.PixelMin) + ((-gp.DigitalPlotOffset) - pixY_Offset);
|
||||||
pMax.y = (gp.PixelRange[y_axis].Min.y) + ((-gp.DigitalPlotOffset) - pixY_0 - pixY_1 - pixY_Offset);
|
pMax.y = (y_axis.PixelMin) + ((-gp.DigitalPlotOffset) - pixY_0 - pixY_1 - pixY_Offset);
|
||||||
//plot only one rectangle for same digital state
|
//plot only one rectangle for same digital state
|
||||||
while (((i+2) < getter.Count) && (itemData1.y == itemData2.y)) {
|
while (((i+2) < getter.Count) && (itemData1.y == itemData2.y)) {
|
||||||
const int in = (i + 1);
|
const int in = (i + 1);
|
||||||
itemData2 = getter(in);
|
itemData2 = getter(in);
|
||||||
if (ImNanOrInf(itemData2.y)) break;
|
if (ImNanOrInf(itemData2.y)) break;
|
||||||
pMax.x = PlotToPixels(itemData2).x;
|
pMax.x = PlotToPixels(itemData2,IMPLOT_AUTO,IMPLOT_AUTO).x;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
//do not extend plot outside plot range
|
//do not extend plot outside plot range
|
||||||
if (pMin.x < gp.PixelRange[y_axis].Min.x) pMin.x = gp.PixelRange[y_axis].Min.x;
|
if (pMin.x < x_axis.PixelMin) pMin.x = x_axis.PixelMin;
|
||||||
if (pMax.x < gp.PixelRange[y_axis].Min.x) pMax.x = gp.PixelRange[y_axis].Min.x;
|
if (pMax.x < x_axis.PixelMin) pMax.x = x_axis.PixelMin;
|
||||||
if (pMin.x > gp.PixelRange[y_axis].Max.x) pMin.x = gp.PixelRange[y_axis].Max.x;
|
if (pMin.x > x_axis.PixelMax) pMin.x = x_axis.PixelMax;
|
||||||
if (pMax.x > gp.PixelRange[y_axis].Max.x) pMax.x = gp.PixelRange[y_axis].Max.x;
|
if (pMax.x > x_axis.PixelMax) pMax.x = x_axis.PixelMax;
|
||||||
//plot a rectangle that extends up to x2 with y1 height
|
//plot a rectangle that extends up to x2 with y1 height
|
||||||
if ((pMax.x > pMin.x) && (gp.CurrentPlot->PlotRect.Contains(pMin) || gp.CurrentPlot->PlotRect.Contains(pMax))) {
|
if ((pMax.x > pMin.x) && (gp.CurrentPlot->PlotRect.Contains(pMin) || gp.CurrentPlot->PlotRect.Contains(pMax))) {
|
||||||
// ImVec4 colAlpha = item->Color;
|
// ImVec4 colAlpha = item->Color;
|
||||||
|
@ -2258,7 +2288,7 @@ template IMPLOT_API void PlotDigital<float>(const char* label_id, const float* x
|
||||||
template IMPLOT_API void PlotDigital<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
template IMPLOT_API void PlotDigital<double>(const char* label_id, const double* xs, const double* ys, int count, int offset, int stride);
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
void PlotDigitalG(const char* label_id, ImPlotPoint (*getter_func)(void* data, int idx), void* data, int count) {
|
void PlotDigitalG(const char* label_id, ImPlotGetter getter_func, void* data, int count) {
|
||||||
GetterFuncPtr getter(getter_func,data,count);
|
GetterFuncPtr getter(getter_func,data,count);
|
||||||
return PlotDigitalEx(label_id, getter);
|
return PlotDigitalEx(label_id, getter);
|
||||||
}
|
}
|
||||||
|
@ -2276,8 +2306,8 @@ void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPo
|
||||||
ImU32 tint_col32 = ImGui::ColorConvertFloat4ToU32(tint_col);
|
ImU32 tint_col32 = ImGui::ColorConvertFloat4ToU32(tint_col);
|
||||||
GetCurrentItem()->Color = tint_col32;
|
GetCurrentItem()->Color = tint_col32;
|
||||||
ImDrawList& DrawList = *GetPlotDrawList();
|
ImDrawList& DrawList = *GetPlotDrawList();
|
||||||
ImVec2 p1 = PlotToPixels(bmin.x, bmax.y);
|
ImVec2 p1 = PlotToPixels(bmin.x, bmax.y,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
ImVec2 p2 = PlotToPixels(bmax.x, bmin.y);
|
ImVec2 p2 = PlotToPixels(bmax.x, bmin.y,IMPLOT_AUTO,IMPLOT_AUTO);
|
||||||
PushPlotClipRect();
|
PushPlotClipRect();
|
||||||
DrawList.AddImage(user_texture_id, p1, p2, uv0, uv1, tint_col32);
|
DrawList.AddImage(user_texture_id, p1, p2, uv0, uv1, tint_col32);
|
||||||
PopPlotClipRect();
|
PopPlotClipRect();
|
||||||
|
@ -2292,16 +2322,27 @@ void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPo
|
||||||
// double
|
// double
|
||||||
void PlotText(const char* text, double x, double y, bool vertical, const ImVec2& pixel_offset) {
|
void PlotText(const char* text, double x, double y, bool vertical, const ImVec2& pixel_offset) {
|
||||||
IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != NULL, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
|
IM_ASSERT_USER_ERROR(GImPlot->CurrentPlot != NULL, "PlotText() needs to be called between BeginPlot() and EndPlot()!");
|
||||||
|
SetupLock();
|
||||||
ImDrawList & DrawList = *GetPlotDrawList();
|
ImDrawList & DrawList = *GetPlotDrawList();
|
||||||
PushPlotClipRect();
|
PushPlotClipRect();
|
||||||
ImU32 colTxt = GetStyleColorU32(ImPlotCol_InlayText);
|
ImU32 colTxt = GetStyleColorU32(ImPlotCol_InlayText);
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
ImVec2 ctr = CalcTextSizeVertical(text) * 0.5f;
|
ImVec2 siz = CalcTextSizeVertical(text) * 0.5f;
|
||||||
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y)) + ImVec2(-ctr.x, ctr.y) + pixel_offset;
|
ImVec2 ctr = siz * 0.5f;
|
||||||
|
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) + ImVec2(-ctr.x, ctr.y) + pixel_offset;
|
||||||
|
if (FitThisFrame()) {
|
||||||
|
FitPoint(PixelsToPlot(pos));
|
||||||
|
FitPoint(PixelsToPlot(pos.x + siz.x, pos.y - siz.y));
|
||||||
|
}
|
||||||
AddTextVertical(&DrawList, pos, colTxt, text);
|
AddTextVertical(&DrawList, pos, colTxt, text);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y)) - ImGui::CalcTextSize(text) * 0.5f + pixel_offset;
|
ImVec2 siz = ImGui::CalcTextSize(text);
|
||||||
|
ImVec2 pos = PlotToPixels(ImPlotPoint(x,y),IMPLOT_AUTO,IMPLOT_AUTO) - siz * 0.5f + pixel_offset;
|
||||||
|
if (FitThisFrame()) {
|
||||||
|
FitPoint(PixelsToPlot(pos));
|
||||||
|
FitPoint(PixelsToPlot(pos+siz));
|
||||||
|
}
|
||||||
DrawList.AddText(pos, colTxt, text);
|
DrawList.AddText(pos, colTxt, text);
|
||||||
}
|
}
|
||||||
PopPlotClipRect();
|
PopPlotClipRect();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user