mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 12:18:52 -05:00
Compare commits
31 Commits
3dd7e75c7d
...
626e391670
Author | SHA1 | Date | |
---|---|---|---|
626e391670 | |||
8879c99aef | |||
6978a3e177 | |||
15e494b76a | |||
f88ad32a47 | |||
3e13c95986 | |||
4ba42f200a | |||
57149164d5 | |||
9ef3a97966 | |||
921a81f307 | |||
8c06ff0252 | |||
98c76edbb4 | |||
f719a180ff | |||
49db527db1 | |||
fd16fe001c | |||
002ffc95bc | |||
e80e42e8b4 | |||
220f5c9ab4 | |||
7a470b2e17 | |||
f33a5990d7 | |||
1fed5c2c19 | |||
b4aec718a5 | |||
8c53333489 | |||
fc0fd11246 | |||
6c00109636 | |||
0f4d4dccc3 | |||
6f4986b14f | |||
dbb461db24 | |||
63d5ed94b7 | |||
79b05d5e25 | |||
b9c0a39b08 |
95
.github/CMakeLists.txt
vendored
Normal file
95
.github/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
# This build script is not meant for general use, it is for CI use only!
|
||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
project(implot)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Global options
|
||||||
|
#
|
||||||
|
|
||||||
|
# Same as Dear ImGui
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
# Arch option for linux
|
||||||
|
if (NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND DEFINED GCC_ARCH)
|
||||||
|
if ("${GCC_ARCH}" MATCHES "Win32|x86|32")
|
||||||
|
add_compile_options(-m32)
|
||||||
|
add_link_options(-m32)
|
||||||
|
elseif ("${GCC_ARCH}" MATCHES "Win64|x64|64")
|
||||||
|
add_compile_options(-m64)
|
||||||
|
add_link_options(-m64)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Arch option for Mac: arm64 for M1 or x86_64 for intel (32 bits build are deprecated on Mac)
|
||||||
|
if(APPLE AND DEFINED OSX_ARCH)
|
||||||
|
if ("${OSX_ARCH}" MATCHES "x86_64")
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||||
|
elseif ("${OSX_ARCH}" MATCHES "arm64")
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unhandled OSX_ARCH=${OSX_ARCH}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Dear ImGui library with no backend
|
||||||
|
#
|
||||||
|
|
||||||
|
set(imgui_sources
|
||||||
|
../imgui/imconfig.h
|
||||||
|
../imgui/imgui.cpp
|
||||||
|
../imgui/imgui.h
|
||||||
|
../imgui/imgui_demo.cpp
|
||||||
|
../imgui/imgui_draw.cpp
|
||||||
|
../imgui/imgui_internal.h
|
||||||
|
../imgui/imgui_tables.cpp
|
||||||
|
../imgui/imgui_widgets.cpp
|
||||||
|
../imgui/imstb_rectpack.h
|
||||||
|
../imgui/imstb_textedit.h
|
||||||
|
../imgui/imstb_truetype.h
|
||||||
|
)
|
||||||
|
add_library(imgui ${imgui_sources})
|
||||||
|
target_include_directories(imgui PUBLIC ../imgui)
|
||||||
|
|
||||||
|
#
|
||||||
|
# ImPlot library
|
||||||
|
#
|
||||||
|
|
||||||
|
file(GLOB SOURCE_CODE ../implot*.*)
|
||||||
|
add_library(implot STATIC ${SOURCE_CODE})
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(implot PRIVATE /W4 /WX)
|
||||||
|
else()
|
||||||
|
target_compile_options(implot PRIVATE -Wall -Werror -pedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(implot PUBLIC ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
|
target_link_libraries(implot PUBLIC imgui)
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
|
target_link_libraries(implot PUBLIC m stdc++)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define supported types via command line:
|
||||||
|
# - With no choice all types are supported (so that the CI provides support for all known types)
|
||||||
|
# - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="default" the default set defined in implot_items.cpp is used
|
||||||
|
# - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="(int)(float)(double)" only int, float and double are supported
|
||||||
|
if (NOT DEFINED IMPLOT_CUSTOM_NUMERIC_TYPES)
|
||||||
|
set(IMPLOT_CUSTOM_NUMERIC_TYPES "all")
|
||||||
|
endif()
|
||||||
|
if ("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "default")
|
||||||
|
message("==== Compiling for default types ====")
|
||||||
|
elseif("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "all")
|
||||||
|
message("==== Compiling for all types ====")
|
||||||
|
target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=(signed char)(unsigned char)(signed short)(unsigned short)(signed int)(unsigned int)(signed long)(unsigned long)(signed long long)(unsigned long long)(float)(double)(long double)")
|
||||||
|
else()
|
||||||
|
message("==== Compiling for custom types: ${IMPLOT_CUSTOM_NUMERIC_TYPES} ====")
|
||||||
|
target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=${IMPLOT_CUSTOM_NUMERIC_TYPES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# implot example binary application (with no backend)
|
||||||
|
#
|
||||||
|
add_executable(example_implot example_implot.cpp)
|
||||||
|
target_link_libraries(example_implot PRIVATE implot)
|
55
.github/example_implot.cpp
vendored
Normal file
55
.github/example_implot.cpp
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
// Sample app built with Dear ImGui and ImPlot
|
||||||
|
// This app uses implot and imgui, but does not output to any backend! It only serves as a proof that an app can be built, linked, and run.
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "implot.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
printf("sample_implot: start\n");
|
||||||
|
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
ImPlot::CreateContext();
|
||||||
|
|
||||||
|
// Additional imgui initialization needed when no backend is present
|
||||||
|
ImGui::GetIO().DisplaySize = ImVec2(400.f, 400.f);
|
||||||
|
ImGui::GetIO().Fonts->Build();
|
||||||
|
|
||||||
|
// Render 500 frames
|
||||||
|
for(int counter = 0; counter < 500; ++counter)
|
||||||
|
{
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
if (ImGui::Begin("Hello, world!"))
|
||||||
|
{
|
||||||
|
ImGui::Text("Hello again");
|
||||||
|
|
||||||
|
if (ImPlot::BeginPlot("My Plot"))
|
||||||
|
{
|
||||||
|
static double values[] = {1., 3., 5.};
|
||||||
|
ImPlot::PlotLine("Values", values, 3);
|
||||||
|
ImPlot::EndPlot();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef IMPLOT_INSTANTIATE_ALL_NUMERIC_TYPES
|
||||||
|
if (ImPlot::BeginPlot("My Plot (long double)"))
|
||||||
|
{
|
||||||
|
static long double values[] = {1., 3., 5.};
|
||||||
|
ImPlot::PlotLine("Values", values, 3);
|
||||||
|
ImPlot::EndPlot();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImPlot::DestroyContext();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
printf("sample_implot: end\n");
|
||||||
|
return 0;
|
||||||
|
}
|
144
.github/workflows/build.yml
vendored
Normal file
144
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Linux:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build_type:
|
||||||
|
- debug
|
||||||
|
- release
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
- clang
|
||||||
|
arch:
|
||||||
|
- x86
|
||||||
|
- x64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: ocornut/imgui
|
||||||
|
path: imgui
|
||||||
|
|
||||||
|
- name: Dependencies
|
||||||
|
run: sudo apt-get install g++-multilib
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: cmake -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGCC_ARCH=${{ matrix.arch }} -B cmake-build -S .github
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build cmake-build --parallel $(nproc)
|
||||||
|
|
||||||
|
- name: Run
|
||||||
|
run: |
|
||||||
|
file cmake-build/example_implot
|
||||||
|
cmake-build/example_implot
|
||||||
|
|
||||||
|
MacOS:
|
||||||
|
runs-on: macos-11
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build_type:
|
||||||
|
- debug
|
||||||
|
- release
|
||||||
|
arch:
|
||||||
|
- x86_64
|
||||||
|
- arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: ocornut/imgui
|
||||||
|
path: imgui
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: bash
|
||||||
|
run: cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DOSX_ARCH=${{ matrix.arch }} -B cmake-build -S .github
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: cmake --build cmake-build --parallel $(sysctl -n hw.ncpu)
|
||||||
|
|
||||||
|
- name: Run
|
||||||
|
if: matrix.arch == 'x86_64' # github's CI hosts seem to be running intel and can not run ARM
|
||||||
|
run: |
|
||||||
|
file cmake-build/example_implot
|
||||||
|
cmake-build/example_implot
|
||||||
|
|
||||||
|
Windows_MSVC:
|
||||||
|
runs-on: windows-2022
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build_type:
|
||||||
|
- debug
|
||||||
|
- release
|
||||||
|
arch:
|
||||||
|
- Win32
|
||||||
|
- x64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: ocornut/imgui
|
||||||
|
path: imgui
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: bash
|
||||||
|
run: cmake -G 'Visual Studio 17 2022' -A ${{ matrix.arch }} -B cmake-build -S .github
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: cmake --build cmake-build -- -p:Configuration=${{ matrix.build_type }} -maxcpucount:$NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
|
- name: Run
|
||||||
|
run: .\cmake-build\${{matrix.build_type}}\example_implot.exe
|
||||||
|
|
||||||
|
Windows_MingW: # MingW on Github CI does not fully support 32 bits: link fails when it tries to link 64 bits system libraries.
|
||||||
|
runs-on: windows-2022
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build_type:
|
||||||
|
- debug
|
||||||
|
- release
|
||||||
|
arch:
|
||||||
|
- x64
|
||||||
|
# - Win32
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: ocornut/imgui
|
||||||
|
path: imgui
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: bash
|
||||||
|
run: cmake -G 'MinGW Makefiles' -DGCC_ARCH=${{ matrix.arch }} -B cmake-build -S .github
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: cmake --build cmake-build --parallel $NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
|
- name: Run (MingW)
|
||||||
|
run: .\cmake-build\example_implot.exe
|
||||||
|
|
20
README.md
20
README.md
|
@ -43,7 +43,7 @@ ImPlot is an immediate mode, GPU accelerated plotting library for [Dear ImGui](h
|
||||||
- default styling based on current ImGui theme, or completely custom plot styles
|
- default styling based on current ImGui theme, or completely custom plot styles
|
||||||
- customizable data getters and data striding (just like ImGui:PlotLine)
|
- customizable data getters and data striding (just like ImGui:PlotLine)
|
||||||
- accepts data as float, double, and 8, 16, 32, and 64-bit signed/unsigned integral types
|
- accepts data as float, double, and 8, 16, 32, and 64-bit signed/unsigned integral types
|
||||||
- and more! (see Announcements [2020](https://github.com/epezent/implot/issues/48)/[2021](https://github.com/epezent/implot/issues/168))
|
- and more! (see Announcements [2022](https://github.com/epezent/implot/discussions/370)/[2021](https://github.com/epezent/implot/issues/168)/[2020](https://github.com/epezent/implot/issues/48))
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ Of course, there's much more you can do with ImPlot...
|
||||||
|
|
||||||
## Demos
|
## Demos
|
||||||
|
|
||||||
A comprehensive example of ImPlot's features can be found in `implot_demo.h`. Add this file to your sources and call `ImPlot::ShowDemoWindow()` somewhere in your update loop. You are encouraged to use this file as a reference when needing to implement various plot types. The demo is always updated to show new plot types and features as they are added, so check back with each release!
|
A comprehensive example of ImPlot's features can be found in `implot_demo.cpp`. Add this file to your sources and call `ImPlot::ShowDemoWindow()` somewhere in your update loop. You are encouraged to use this file as a reference when needing to implement various plot types. The demo is always updated to show new plot types and features as they are added, so check back with each release!
|
||||||
|
|
||||||
An online version of the demo is hosted [here](https://traineq.org/implot_demo/src/implot_demo.html). You can view the plots and the source code that generated them. Note that this demo may not always be up to date and is not as performant as a desktop implementation, but it should give you a general taste of what's possible with ImPlot. Special thanks to [pthom](https://github.com/pthom) for creating and hosting this!
|
An online version of the demo is hosted [here](https://traineq.org/implot_demo/src/implot_demo.html). You can view the plots and the source code that generated them. Note that this demo may not always be up to date and is not as performant as a desktop implementation, but it should give you a general taste of what's possible with ImPlot. Special thanks to [pthom](https://github.com/pthom) for creating and hosting this!
|
||||||
|
|
||||||
|
@ -93,7 +93,19 @@ ImGui::DestroyContext();
|
||||||
|
|
||||||
You should be good to go!
|
You should be good to go!
|
||||||
|
|
||||||
If you want to test ImPlot quickly, consider trying [mahi-gui](https://github.com/mahilab/mahi-gui), which bundles ImGui, ImPlot, and several other packages for you.
|
## Installing ImPlot using vcpkg
|
||||||
|
|
||||||
|
You can download and install ImPlot using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/Microsoft/vcpkg.git
|
||||||
|
cd vcpkg
|
||||||
|
./bootstrap-vcpkg.sh
|
||||||
|
./vcpkg integrate install
|
||||||
|
./vcpkg install implot
|
||||||
|
```
|
||||||
|
|
||||||
|
The ImPlot port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||||
|
|
||||||
## Extremely Important Note
|
## Extremely Important Note
|
||||||
|
|
||||||
|
@ -123,7 +135,7 @@ A: Yes, within reason. You can plot tens to hundreds of thousands of points with
|
||||||
**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), and many plotters provide a "getter" overload which accepts data generating callbacks.
|
`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. You can fully customize the list of accepted types by defining `IMPLOT_CUSTOM_NUMERIC_TYPES` at compile time: see doc in `implot_items.cpp`.
|
||||||
|
|
||||||
**Q: Can plot styles be modified?**
|
**Q: Can plot styles be modified?**
|
||||||
|
|
||||||
|
|
47
TODO.md
47
TODO.md
|
@ -2,40 +2,35 @@ The list below represents a combination of high-priority work, nice-to-have feat
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
- add shortcut/legacy overloads for BeginPlot
|
|
||||||
|
|
||||||
## Axes
|
## Axes
|
||||||
|
|
||||||
- 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`)
|
- pixel space scale (`ImPlotTransform_Display`), normalized space scale (`ImPlotTransform_Axes`), data space scale (`ImPlotTransform_Data`)
|
||||||
- make ImPlotFlags_Equal not a flag -> `SetupEqual(ImPlotAxis x, ImPlotAxis y)`
|
- make ImPlotFlags_Equal not a flag -> `SetupEqual(ImPlotAxis x, ImPlotAxis y)`
|
||||||
- allow inverted arguments `SetAxes` to transpose data?
|
- allow inverted arguments `SetAxes` to transpose data?
|
||||||
- `SetupAxisColors()`
|
- `SetupAxisColors()`
|
||||||
- `SetupAxisConstraints()`
|
|
||||||
- `SetupAxisHome()`
|
- `SetupAxisHome()`
|
||||||
|
|
||||||
## Plot Items
|
## Plot Items
|
||||||
|
|
||||||
- add `ImPlotLineFlags`, `ImPlotBarsFlags`, etc. for each plot type
|
|
||||||
- add `PlotBarGroups` wrapper that makes rendering groups of bars easier, with stacked bar support
|
|
||||||
- add `PlotBubbles` (see MATLAB bubble chart)
|
- 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?)
|
- add exploding to `PlotPieChart` (on hover-highlight?)
|
||||||
|
- fix appearance of `PlotBars` spacing
|
||||||
|
|
||||||
## 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 axes
|
|
||||||
- API for setting different fonts for plot elements
|
- API for setting different fonts for plot elements
|
||||||
|
|
||||||
## Colormaps
|
## Colormaps
|
||||||
|
|
||||||
- gradient editing tool
|
- gradient editing tool
|
||||||
- `RemoveColormap`
|
- `RemoveColormap`
|
||||||
|
- `enum ImPlotColorRule_ { Solid, Faded, XValue, YValue, ZValue }`
|
||||||
|
|
||||||
## Legend
|
## Legend
|
||||||
|
|
||||||
- `ImPlotLegendFlags_SortItems`
|
|
||||||
- `ImPlotLegendFlags_Scroll`
|
- `ImPlotLegendFlags_Scroll`
|
||||||
- improve legend icons (e.g. adopt markers, gradients, etc)
|
- improve legend icons (e.g. adopt markers, gradients, etc)
|
||||||
- make legend frame use ButtonBehavior (maybe impossible)
|
- make legend frame use ButtonBehavior (maybe impossible)
|
||||||
|
@ -48,6 +43,9 @@ The list below represents a combination of high-priority work, nice-to-have feat
|
||||||
- add box selection to axes
|
- add box selection to axes
|
||||||
- first frame render delay might fix "fit pop" effect
|
- first frame render delay might fix "fit pop" effect
|
||||||
- move some code to new `implot_tools.cpp`
|
- move some code to new `implot_tools.cpp`
|
||||||
|
- ColormapSlider (see metrics)
|
||||||
|
- FillAlpha should not affect markers?
|
||||||
|
- fix mouse text for time axes
|
||||||
|
|
||||||
## Optimizations
|
## Optimizations
|
||||||
|
|
||||||
|
@ -55,6 +53,32 @@ The list below represents a combination of high-priority work, nice-to-have feat
|
||||||
- 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
|
||||||
|
|
||||||
|
## Plotter Pipeline
|
||||||
|
|
||||||
|
Ideally every `PlotX` function should use our faster rendering pipeline when it is applicable.
|
||||||
|
|
||||||
|
` User Data > Getter > Fitter > Renderer > RenderPrimitives`
|
||||||
|
|
||||||
|
|Plotter|Getter|Fitter|Renderer|RenderPrimitives|
|
||||||
|
|---|:-:|:-:|:-:|:-:|
|
||||||
|
|PlotLine|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotScatter|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotStairs|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotShaded|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotBars|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotBarGroups|:|:|:|:|
|
||||||
|
|PlotHistogram|:|:|:|:|
|
||||||
|
|PlotErrorBars|Yes|Yes|No|No|
|
||||||
|
|PlotStems|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotInfLines|Yes|Yes|Yes|Yes|
|
||||||
|
|PlotPieChart|No|No|No|No|
|
||||||
|
|PlotHeatmap|Yes|No|Yes|Mixed|
|
||||||
|
|PlotHistogram2D|:|:|:|:|
|
||||||
|
|PlotDigital|Yes|No|No|No|
|
||||||
|
|PlotImage|-|-|-|-|
|
||||||
|
|PlotText|-|-|-|-|
|
||||||
|
|PlotDummy|-|-|-|-|
|
||||||
|
|
||||||
## Completed
|
## Completed
|
||||||
- make BeginPlot take fewer args:
|
- make BeginPlot take fewer args:
|
||||||
- make query a tool -> `DragRect`
|
- make query a tool -> `DragRect`
|
||||||
|
@ -67,3 +91,10 @@ The list below represents a combination of high-priority work, nice-to-have feat
|
||||||
- legend items can be hovered even if plot is not
|
- legend items can be hovered even if plot is not
|
||||||
- fix frame delay on DragX tools
|
- fix frame delay on DragX tools
|
||||||
- remove tag from drag line/point -> add `Tag` tool
|
- remove tag from drag line/point -> add `Tag` tool
|
||||||
|
- add shortcut/legacy overloads for BeginPlot
|
||||||
|
- `SetupAxisConstraints()`
|
||||||
|
- `SetupAxisScale()`
|
||||||
|
- add `ImPlotLineFlags`, `ImPlotBarsFlags`, etc. for each plot type
|
||||||
|
- add `PlotBarGroups` wrapper that makes rendering groups of bars easier, with stacked bar support
|
||||||
|
- `PlotBars` restore outlines
|
||||||
|
- add hover/active color for plot axes
|
||||||
|
|
770
implot.cpp
770
implot.cpp
File diff suppressed because it is too large
Load Diff
412
implot.h
412
implot.h
|
@ -1,6 +1,6 @@
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
// Copyright (c) 2021 Evan Pezent
|
// Copyright (c) 2022 Evan Pezent
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -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.13 WIP
|
// ImPlot v0.14
|
||||||
|
|
||||||
// Table of Contents:
|
// Table of Contents:
|
||||||
//
|
//
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ImPlot version string.
|
// ImPlot version string.
|
||||||
#define IMPLOT_VERSION "0.13 WIP"
|
#define IMPLOT_VERSION "0.14"
|
||||||
// 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.
|
||||||
|
@ -76,22 +76,41 @@
|
||||||
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 ImAxis; // -> enum ImAxis_
|
typedef int ImAxis; // -> enum ImAxis_
|
||||||
typedef int ImPlotFlags; // -> enum ImPlotFlags_
|
typedef int ImPlotFlags; // -> enum ImPlotFlags_
|
||||||
typedef int ImPlotAxisFlags; // -> enum ImPlotAxisFlags_
|
typedef int ImPlotAxisFlags; // -> enum ImPlotAxisFlags_
|
||||||
typedef int ImPlotSubplotFlags; // -> enum ImPlotSubplotFlags_
|
typedef int ImPlotSubplotFlags; // -> enum ImPlotSubplotFlags_
|
||||||
typedef int ImPlotLegendFlags; // -> enum ImPlotLegendFlags_
|
typedef int ImPlotLegendFlags; // -> enum ImPlotLegendFlags_
|
||||||
typedef int ImPlotMouseTextFlags; // -> enum ImPlotMouseTextFlags_
|
typedef int ImPlotMouseTextFlags; // -> enum ImPlotMouseTextFlags_
|
||||||
typedef int ImPlotDragToolFlags; // -> ImPlotDragToolFlags_
|
typedef int ImPlotDragToolFlags; // -> ImPlotDragToolFlags_
|
||||||
typedef int ImPlotBarGroupsFlags; // -> ImPlotBarGroupsFlags_
|
typedef int ImPlotColormapScaleFlags; // -> ImPlotColormapScaleFlags_
|
||||||
|
|
||||||
typedef int ImPlotCond; // -> enum ImPlotCond_
|
typedef int ImPlotItemFlags; // -> ImPlotItemFlags_
|
||||||
typedef int ImPlotCol; // -> enum ImPlotCol_
|
typedef int ImPlotLineFlags; // -> ImPlotLineFlags_
|
||||||
typedef int ImPlotStyleVar; // -> enum ImPlotStyleVar_
|
typedef int ImPlotScatterFlags; // -> ImPlotScatterFlags
|
||||||
typedef int ImPlotMarker; // -> enum ImPlotMarker_
|
typedef int ImPlotStairsFlags; // -> ImPlotStairsFlags_
|
||||||
typedef int ImPlotColormap; // -> enum ImPlotColormap_
|
typedef int ImPlotShadedFlags; // -> ImPlotShadedFlags_
|
||||||
typedef int ImPlotLocation; // -> enum ImPlotLocation_
|
typedef int ImPlotBarsFlags; // -> ImPlotBarsFlags_
|
||||||
typedef int ImPlotBin; // -> enum ImPlotBin_
|
typedef int ImPlotBarGroupsFlags; // -> ImPlotBarGroupsFlags_
|
||||||
|
typedef int ImPlotErrorBarsFlags; // -> ImPlotErrorBarsFlags_
|
||||||
|
typedef int ImPlotStemsFlags; // -> ImPlotStemsFlags_
|
||||||
|
typedef int ImPlotInfLinesFlags; // -> ImPlotInfLinesFlags_
|
||||||
|
typedef int ImPlotPieChartFlags; // -> ImPlotPieChartFlags_
|
||||||
|
typedef int ImPlotHeatmapFlags; // -> ImPlotHeatmapFlags_
|
||||||
|
typedef int ImPlotHistogramFlags; // -> ImPlotHistogramFlags_
|
||||||
|
typedef int ImPlotDigitalFlags; // -> ImPlotDigitalFlags_
|
||||||
|
typedef int ImPlotImageFlags; // -> ImPlotImageFlags_
|
||||||
|
typedef int ImPlotTextFlags; // -> ImPlotTextFlags_
|
||||||
|
typedef int ImPlotDummyFlags; // -> ImPlotDummyFlags_
|
||||||
|
|
||||||
|
typedef int ImPlotCond; // -> enum ImPlotCond_
|
||||||
|
typedef int ImPlotCol; // -> enum ImPlotCol_
|
||||||
|
typedef int ImPlotStyleVar; // -> enum ImPlotStyleVar_
|
||||||
|
typedef int ImPlotScale; // -> enum ImPlotScale_
|
||||||
|
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.
|
// Axis indices. The values assigned may change; NEVER hardcode these.
|
||||||
enum ImAxis_ {
|
enum ImAxis_ {
|
||||||
|
@ -120,34 +139,34 @@ enum ImPlotFlags_ {
|
||||||
ImPlotFlags_NoFrame = 1 << 7, // the ImGui frame will not be rendered
|
ImPlotFlags_NoFrame = 1 << 7, // the ImGui frame will not be rendered
|
||||||
ImPlotFlags_Equal = 1 << 8, // x and y axes pairs will be constrained to have the same units/pixel
|
ImPlotFlags_Equal = 1 << 8, // x and y axes pairs will be constrained to have the same units/pixel
|
||||||
ImPlotFlags_Crosshairs = 1 << 9, // the default mouse cursor will be replaced with a crosshair when hovered
|
ImPlotFlags_Crosshairs = 1 << 9, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||||
ImPlotFlags_AntiAliased = 1 << 10, // plot items will be software anti-aliased (not recommended for high density plots, prefer MSAA)
|
|
||||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText
|
ImPlotFlags_CanvasOnly = ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options for plot axes (see SetupAxis).
|
// Options for plot axes (see SetupAxis).
|
||||||
enum ImPlotAxisFlags_ {
|
enum ImPlotAxisFlags_ {
|
||||||
ImPlotAxisFlags_None = 0, // default
|
ImPlotAxisFlags_None = 0, // default
|
||||||
ImPlotAxisFlags_NoLabel = 1 << 0, // the axis label will not be displayed (axis labels also hidden if the supplied string name is NULL)
|
ImPlotAxisFlags_NoLabel = 1 << 0, // the axis label will not be displayed (axis labels are also hidden if the supplied string name is 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_NoInitialFit = 1 << 4, // axis will not be initially fit to data extents on the first rendered frame
|
ImPlotAxisFlags_NoInitialFit = 1 << 4, // axis will not be initially fit to data extents on the first rendered frame
|
||||||
ImPlotAxisFlags_NoMenus = 1 << 5, // the user will not be able to open context menus with right-click
|
ImPlotAxisFlags_NoMenus = 1 << 5, // the user will not be able to open context menus with right-click
|
||||||
ImPlotAxisFlags_Opposite = 1 << 6, // axis ticks and labels will be rendered on conventionally opposite side (i.e, right or top)
|
ImPlotAxisFlags_NoSideSwitch = 1 << 6, // the user will not be able to switch the axis side by dragging it
|
||||||
ImPlotAxisFlags_Foreground = 1 << 7, // grid lines will be displayed in the foreground (i.e. on top of data) in stead of the background
|
ImPlotAxisFlags_NoHighlight = 1 << 7, // the axis will not have its background highlighted when hovered or held
|
||||||
ImPlotAxisFlags_LogScale = 1 << 8, // a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
|
ImPlotAxisFlags_Opposite = 1 << 8, // axis ticks and labels will be rendered on the conventionally opposite side (i.e, right or top)
|
||||||
ImPlotAxisFlags_Time = 1 << 9, // axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
|
ImPlotAxisFlags_Foreground = 1 << 9, // grid lines will be displayed in the foreground (i.e. on top of data) instead of the background
|
||||||
ImPlotAxisFlags_Invert = 1 << 10, // the axis will be inverted
|
ImPlotAxisFlags_Invert = 1 << 10, // the axis will be inverted
|
||||||
ImPlotAxisFlags_AutoFit = 1 << 11, // axis will be auto-fitting to data extents
|
ImPlotAxisFlags_AutoFit = 1 << 11, // axis will be auto-fitting to data extents
|
||||||
ImPlotAxisFlags_RangeFit = 1 << 12, // axis will only fit points if the point is in the visible range of the **orthogonal** axis
|
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_PanStretch = 1 << 13, // panning in a locked or constrained state will cause the axis to stretch if possible
|
||||||
ImPlotAxisFlags_LockMax = 1 << 14, // the axis maximum value will be locked when panning/zooming
|
ImPlotAxisFlags_LockMin = 1 << 14, // the axis minimum value will be locked when panning/zooming
|
||||||
|
ImPlotAxisFlags_LockMax = 1 << 15, // 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
|
ImPlotAxisFlags_AuxDefault = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_Opposite
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options for subplots (see BeginSubplot).
|
// Options for subplots (see BeginSubplot)
|
||||||
enum ImPlotSubplotFlags_ {
|
enum ImPlotSubplotFlags_ {
|
||||||
ImPlotSubplotFlags_None = 0, // default
|
ImPlotSubplotFlags_None = 0, // default
|
||||||
ImPlotSubplotFlags_NoTitle = 1 << 0, // the subplot title will not be displayed (titles are also hidden if preceeded by double hashes, e.g. "##MySubplot")
|
ImPlotSubplotFlags_NoTitle = 1 << 0, // the subplot title will not be displayed (titles are also hidden if preceeded by double hashes, e.g. "##MySubplot")
|
||||||
|
@ -172,6 +191,7 @@ enum ImPlotLegendFlags_ {
|
||||||
ImPlotLegendFlags_NoMenus = 1 << 3, // the user will not be able to open context menus with right-click
|
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_Outside = 1 << 4, // legend will be rendered outside of the plot area
|
||||||
ImPlotLegendFlags_Horizontal = 1 << 5, // legend entries will be displayed horizontally
|
ImPlotLegendFlags_Horizontal = 1 << 5, // legend entries will be displayed horizontally
|
||||||
|
ImPlotLegendFlags_Sort = 1 << 6, // legend entries will be displayed in alphabetical order
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options for mouse hover text (see SetupMouseText)
|
// Options for mouse hover text (see SetupMouseText)
|
||||||
|
@ -191,10 +211,121 @@ enum ImPlotDragToolFlags_ {
|
||||||
ImPlotDragToolFlags_Delayed = 1 << 3, // tool rendering will be delayed one frame; useful when applying position-constraints
|
ImPlotDragToolFlags_Delayed = 1 << 3, // tool rendering will be delayed one frame; useful when applying position-constraints
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImPlot::PlotBarGroups
|
// Flags for ColormapScale
|
||||||
|
enum ImPlotColormapScaleFlags_ {
|
||||||
|
ImPlotColormapScaleFlags_None = 0, // default
|
||||||
|
ImPlotColormapScaleFlags_NoLabel = 1 << 0, // the colormap axis label will not be displayed
|
||||||
|
ImPlotColormapScaleFlags_Opposite = 1 << 1, // render the colormap label and tick labels on the opposite side
|
||||||
|
ImPlotColormapScaleFlags_Invert = 1 << 2, // invert the colormap bar and axis scale (this only affects rendering; if you only want to reverse the scale mapping, make scale_min > scale_max)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for ANY PlotX function
|
||||||
|
enum ImPlotItemFlags_ {
|
||||||
|
ImPlotItemFlags_None = 0,
|
||||||
|
ImPlotItemFlags_NoLegend = 1 << 0, // the item won't have a legend entry displayed
|
||||||
|
ImPlotItemFlags_NoFit = 1 << 1, // the item won't be considered for plot fits
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotLine
|
||||||
|
enum ImPlotLineFlags_ {
|
||||||
|
ImPlotLineFlags_None = 0, // default
|
||||||
|
ImPlotLineFlags_Segments = 1 << 10, // a line segment will be rendered from every two consecutive points
|
||||||
|
ImPlotLineFlags_Loop = 1 << 11, // the last and first point will be connected to form a closed loop
|
||||||
|
ImPlotLineFlags_SkipNaN = 1 << 12, // NaNs values will be skipped instead of rendered as missing data
|
||||||
|
ImPlotLineFlags_NoClip = 1 << 13, // markers (if displayed) on the edge of a plot will not be clipped
|
||||||
|
ImPlotLineFlags_Shaded = 1 << 14, // a filled region between the line and horizontal origin will be rendered; use PlotShaded for more advanced cases
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotScatter
|
||||||
|
enum ImPlotScatterFlags_ {
|
||||||
|
ImPlotScatterFlags_None = 0, // default
|
||||||
|
ImPlotScatterFlags_NoClip = 1 << 10, // markers on the edge of a plot will not be clipped
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotStairs
|
||||||
|
enum ImPlotStairsFlags_ {
|
||||||
|
ImPlotStairsFlags_None = 0, // default
|
||||||
|
ImPlotStairsFlags_PreStep = 1 << 10, // the y value is continued constantly to the left from every x position, i.e. the interval (x[i-1], x[i]] has the value y[i]
|
||||||
|
ImPlotStairsFlags_Shaded = 1 << 11 // a filled region between the stairs and horizontal origin will be rendered; use PlotShaded for more advanced cases
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotShaded (placeholder)
|
||||||
|
enum ImPlotShadedFlags_ {
|
||||||
|
ImPlotShadedFlags_None = 0 // default
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotBars
|
||||||
|
enum ImPlotBarsFlags_ {
|
||||||
|
ImPlotBarsFlags_None = 0, // default
|
||||||
|
ImPlotBarsFlags_Horizontal = 1 << 10, // bars will be rendered horizontally on the current y-axis
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotBarGroups
|
||||||
enum ImPlotBarGroupsFlags_ {
|
enum ImPlotBarGroupsFlags_ {
|
||||||
ImPlotBarGroupsFlags_None = 0, // default
|
ImPlotBarGroupsFlags_None = 0, // default
|
||||||
ImPlotBarGroupsFlags_Stacked = 1 << 0, // items in a group will be stacked on top of each other
|
ImPlotBarGroupsFlags_Horizontal = 1 << 10, // bar groups will be rendered horizontally on the current y-axis
|
||||||
|
ImPlotBarGroupsFlags_Stacked = 1 << 11, // items in a group will be stacked on top of each other
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotErrorBars
|
||||||
|
enum ImPlotErrorBarsFlags_ {
|
||||||
|
ImPlotErrorBarsFlags_None = 0, // default
|
||||||
|
ImPlotErrorBarsFlags_Horizontal = 1 << 10, // error bars will be rendered horizontally on the current y-axis
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotStems
|
||||||
|
enum ImPlotStemsFlags_ {
|
||||||
|
ImPlotStemsFlags_None = 0, // default
|
||||||
|
ImPlotStemsFlags_Horizontal = 1 << 10, // stems will be rendered horizontally on the current y-axis
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotInfLines
|
||||||
|
enum ImPlotInfLinesFlags_ {
|
||||||
|
ImPlotInfLinesFlags_None = 0, // default
|
||||||
|
ImPlotInfLinesFlags_Horizontal = 1 << 10 // lines will be rendered horizontally on the current y-axis
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotPieChart
|
||||||
|
enum ImPlotPieChartFlags_ {
|
||||||
|
ImPlotPieChartFlags_None = 0, // default
|
||||||
|
ImPlotPieChartFlags_Normalize = 1 << 10 // force normalization of pie chart values (i.e. always make a full circle if sum < 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotHeatmap
|
||||||
|
enum ImPlotHeatmapFlags_ {
|
||||||
|
ImPlotHeatmapFlags_None = 0, // default
|
||||||
|
ImPlotHeatmapFlags_ColMajor = 1 << 10, // data will be read in column major order
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotHistogram and PlotHistogram2D
|
||||||
|
enum ImPlotHistogramFlags_ {
|
||||||
|
ImPlotHistogramFlags_None = 0, // default
|
||||||
|
ImPlotHistogramFlags_Horizontal = 1 << 10, // histogram bars will be rendered horizontally (not supported by PlotHistogram2D)
|
||||||
|
ImPlotHistogramFlags_Cumulative = 1 << 11, // each bin will contain its count plus the counts of all previous bins (not supported by PlotHistogram2D)
|
||||||
|
ImPlotHistogramFlags_Density = 1 << 12, // counts will be normalized, i.e. the PDF will be visualized, or the CDF will be visualized if Cumulative is also set
|
||||||
|
ImPlotHistogramFlags_NoOutliers = 1 << 13, // exclude values outside the specifed histogram range from the count toward normalizing and cumulative counts
|
||||||
|
ImPlotHistogramFlags_ColMajor = 1 << 14 // data will be read in column major order (not supported by PlotHistogram)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotDigital (placeholder)
|
||||||
|
enum ImPlotDigitalFlags_ {
|
||||||
|
ImPlotDigitalFlags_None = 0 // default
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotImage (placeholder)
|
||||||
|
enum ImPlotImageFlags_ {
|
||||||
|
ImPlotImageFlags_None = 0 // default
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotText
|
||||||
|
enum ImPlotTextFlags_ {
|
||||||
|
ImPlotTextFlags_None = 0, // default
|
||||||
|
ImPlotTextFlags_Vertical = 1 << 10 // text will be rendered vertically
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flags for PlotDummy (placeholder)
|
||||||
|
enum ImPlotDummyFlags_ {
|
||||||
|
ImPlotDummyFlags_None = 0 // default
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a condition for SetupAxisLimits etc. (same as ImGuiCond, but we only support a subset of those enums)
|
// Represents a condition for SetupAxisLimits etc. (same as ImGuiCond, but we only support a subset of those enums)
|
||||||
|
@ -267,10 +398,18 @@ enum ImPlotStyleVar_ {
|
||||||
ImPlotStyleVar_COUNT
|
ImPlotStyleVar_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Axis scale
|
||||||
|
enum ImPlotScale_ {
|
||||||
|
ImPlotScale_Linear = 0, // default linear scale
|
||||||
|
ImPlotScale_Time, // date/time scale
|
||||||
|
ImPlotScale_Log10, // base 10 logartithmic scale
|
||||||
|
ImPlotScale_SymLog, // symmetric log scale
|
||||||
|
};
|
||||||
|
|
||||||
// Marker specifications.
|
// Marker specifications.
|
||||||
enum ImPlotMarker_ {
|
enum ImPlotMarker_ {
|
||||||
ImPlotMarker_None = -1, // no marker
|
ImPlotMarker_None = -1, // no marker
|
||||||
ImPlotMarker_Circle, // a circle marker
|
ImPlotMarker_Circle, // a circle marker (default)
|
||||||
ImPlotMarker_Square, // a square maker
|
ImPlotMarker_Square, // a square maker
|
||||||
ImPlotMarker_Diamond, // a diamond marker
|
ImPlotMarker_Diamond, // a diamond marker
|
||||||
ImPlotMarker_Up, // an upward-pointing triangle marker
|
ImPlotMarker_Up, // an upward-pointing triangle marker
|
||||||
|
@ -398,35 +537,40 @@ struct ImPlotStyle {
|
||||||
// colormap
|
// colormap
|
||||||
ImPlotColormap Colormap; // The current colormap. Set this to either an ImPlotColormap_ enum or an index returned by AddColormap.
|
ImPlotColormap Colormap; // The current colormap. Set this to either an ImPlotColormap_ enum or an index returned by AddColormap.
|
||||||
// settings/flags
|
// settings/flags
|
||||||
bool AntiAliasedLines; // = false, enable global anti-aliasing on plot lines (overrides ImPlotFlags_AntiAliased)
|
|
||||||
bool UseLocalTime; // = false, axis labels will be formatted for your timezone when ImPlotAxisFlag_Time is enabled
|
bool UseLocalTime; // = false, axis labels will be formatted for your timezone when ImPlotAxisFlag_Time is enabled
|
||||||
bool UseISO8601; // = false, dates will be formatted according to ISO 8601 where applicable (e.g. YYYY-MM-DD, YYYY-MM, --MM-DD, etc.)
|
bool UseISO8601; // = false, dates will be formatted according to ISO 8601 where applicable (e.g. YYYY-MM-DD, YYYY-MM, --MM-DD, etc.)
|
||||||
bool Use24HourClock; // = false, times will be formatted using a 24 hour clock
|
bool Use24HourClock; // = false, times will be formatted using a 24 hour clock
|
||||||
IMPLOT_API ImPlotStyle();
|
IMPLOT_API ImPlotStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Support for legacy versions
|
||||||
#if (IMGUI_VERSION_NUM < 18716) // Renamed in 1.88
|
#if (IMGUI_VERSION_NUM < 18716) // Renamed in 1.88
|
||||||
#define ImGuiModFlags ImGuiKeyModFlags
|
#define ImGuiMod_None 0
|
||||||
#define ImGuiModFlags_None ImGuiKeyModFlags_None
|
#define ImGuiMod_Ctrl ImGuiKeyModFlags_Ctrl
|
||||||
#define ImGuiModFlags_Ctrl ImGuiKeyModFlags_Ctrl
|
#define ImGuiMod_Shift ImGuiKeyModFlags_Shift
|
||||||
#define ImGuiModFlags_Shift ImGuiKeyModFlags_Shift
|
#define ImGuiMod_Alt ImGuiKeyModFlags_Alt
|
||||||
#define ImGuiModFlags_Alt ImGuiKeyModFlags_Alt
|
#define ImGuiMod_Super ImGuiKeyModFlags_Super
|
||||||
#define ImGuiModFlags_Super ImGuiKeyModFlags_Super
|
#elif (IMGUI_VERSION_NUM < 18823) // Renamed in 1.89, sorry
|
||||||
|
#define ImGuiMod_None 0
|
||||||
|
#define ImGuiMod_Ctrl ImGuiModFlags_Ctrl
|
||||||
|
#define ImGuiMod_Shift ImGuiModFlags_Shift
|
||||||
|
#define ImGuiMod_Alt ImGuiModFlags_Alt
|
||||||
|
#define ImGuiMod_Super ImGuiModFlags_Super
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Input mapping structure. Default values listed. See also MapInputDefault, MapInputReverse.
|
// Input mapping structure. Default values listed. See also MapInputDefault, MapInputReverse.
|
||||||
struct ImPlotInputMap {
|
struct ImPlotInputMap {
|
||||||
ImGuiMouseButton Pan; // LMB enables panning when held,
|
ImGuiMouseButton Pan; // LMB enables panning when held,
|
||||||
ImGuiModFlags PanMod; // none optional modifier that must be held for panning/fitting
|
int PanMod; // none optional modifier that must be held for panning/fitting
|
||||||
ImGuiMouseButton Fit; // LMB initiates fit when double clicked
|
ImGuiMouseButton Fit; // LMB initiates fit when double clicked
|
||||||
ImGuiMouseButton Select; // RMB begins box selection when pressed and confirms selection when released
|
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
|
ImGuiMouseButton SelectCancel; // LMB cancels active box selection when pressed; cannot be same as Select
|
||||||
ImGuiModFlags SelectMod; // none optional modifier that must be held for box selection
|
int SelectMod; // none optional modifier that must be held for box selection
|
||||||
ImGuiModFlags SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
|
int SelectHorzMod; // Alt expands active box selection horizontally to plot edge when held
|
||||||
ImGuiModFlags SelectVertMod; // Shift expands active box selection vertically to plot edge when held
|
int SelectVertMod; // Shift expands active box selection vertically to plot edge when held
|
||||||
ImGuiMouseButton Menu; // RMB opens context menus (if enabled) when clicked
|
ImGuiMouseButton Menu; // RMB opens context menus (if enabled) when clicked
|
||||||
ImGuiModFlags OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
|
int OverrideMod; // Ctrl when held, all input is ignored; used to enable axis/plots as DND sources
|
||||||
ImGuiModFlags ZoomMod; // none optional modifier that must be held for scroll wheel zooming
|
int 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
|
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_API ImPlotInputMap();
|
||||||
};
|
};
|
||||||
|
@ -436,10 +580,13 @@ struct ImPlotInputMap {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Callback signature for axis tick label formatter.
|
// Callback signature for axis tick label formatter.
|
||||||
typedef void (*ImPlotFormatter)(double value, char* buff, int size, void* user_data);
|
typedef int (*ImPlotFormatter)(double value, char* buff, int size, void* user_data);
|
||||||
|
|
||||||
// Callback signature for data getter.
|
// Callback signature for data getter.
|
||||||
typedef ImPlotPoint (*ImPlotGetter)(void* user_data, int idx);
|
typedef ImPlotPoint (*ImPlotGetter)(int idx, void* user_data);
|
||||||
|
|
||||||
|
// Callback signature for axis transform.
|
||||||
|
typedef double (*ImPlotTransform)(double value, void* user_data);
|
||||||
|
|
||||||
namespace ImPlot {
|
namespace ImPlot {
|
||||||
|
|
||||||
|
@ -482,7 +629,7 @@ IMPLOT_API void SetImGuiContext(ImGuiContext* ctx);
|
||||||
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
|
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
|
||||||
// - #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.
|
||||||
IMPLOT_API bool BeginPlot(const char* title_id, const ImVec2& size = ImVec2(-1,0), ImPlotFlags flags = ImPlotFlags_None);
|
IMPLOT_API bool BeginPlot(const char* title_id, const ImVec2& size=ImVec2(-1,0), ImPlotFlags flags=0);
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -542,7 +689,7 @@ IMPLOT_API bool BeginSubplots(const char* title_id,
|
||||||
int rows,
|
int rows,
|
||||||
int cols,
|
int cols,
|
||||||
const ImVec2& size,
|
const ImVec2& size,
|
||||||
ImPlotSubplotFlags flags = ImPlotSubplotFlags_None,
|
ImPlotSubplotFlags flags = 0,
|
||||||
float* row_ratios = NULL,
|
float* row_ratios = NULL,
|
||||||
float* col_ratios = NULL);
|
float* col_ratios = NULL);
|
||||||
|
|
||||||
|
@ -580,7 +727,7 @@ IMPLOT_API void EndSubplots();
|
||||||
// call it for you.
|
// call it for you.
|
||||||
|
|
||||||
// Enables an axis or sets the label and/or flags for an existing axis. Leave #label = NULL for no label.
|
// Enables an axis or sets the label and/or flags for an existing axis. Leave #label = NULL for no label.
|
||||||
IMPLOT_API void SetupAxis(ImAxis axis, const char* label = NULL, ImPlotAxisFlags flags = ImPlotAxisFlags_None);
|
IMPLOT_API void SetupAxis(ImAxis axis, const char* label=NULL, ImPlotAxisFlags flags=0);
|
||||||
// Sets an axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
|
// Sets an axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
|
||||||
IMPLOT_API void SetupAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once);
|
IMPLOT_API void SetupAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once);
|
||||||
// Links an axis range limits to external values. Set to NULL for no linkage. The pointer data must remain valid until EndPlot.
|
// Links an axis range limits to external values. Set to NULL for no linkage. The pointer data must remain valid until EndPlot.
|
||||||
|
@ -588,21 +735,29 @@ IMPLOT_API void SetupAxisLinks(ImAxis axis, double* link_min, double* link_max);
|
||||||
// Sets the format of numeric axis labels via formater specifier (default="%g"). Formated values will be double (i.e. use %f).
|
// Sets the format of numeric axis labels via formater specifier (default="%g"). Formated values will be double (i.e. use %f).
|
||||||
IMPLOT_API void SetupAxisFormat(ImAxis axis, const char* fmt);
|
IMPLOT_API void SetupAxisFormat(ImAxis axis, const char* fmt);
|
||||||
// Sets the format of numeric axis labels via formatter callback. Given #value, write a label into #buff. Optionally pass user data.
|
// Sets the format of numeric axis labels via formatter callback. Given #value, write a label into #buff. Optionally pass user data.
|
||||||
IMPLOT_API void SetupAxisFormat(ImAxis axis, ImPlotFormatter formatter, void* data = NULL);
|
IMPLOT_API void SetupAxisFormat(ImAxis axis, ImPlotFormatter formatter, void* data=NULL);
|
||||||
// Sets an axis' ticks and optionally the labels. To keep the default ticks, set #keep_default=true.
|
// Sets an axis' ticks and optionally the labels. To keep the default ticks, set #keep_default=true.
|
||||||
IMPLOT_API void SetupAxisTicks(ImAxis axis, const double* values, int n_ticks, const char* const labels[] = NULL, bool keep_default = false);
|
IMPLOT_API void SetupAxisTicks(ImAxis axis, const double* values, int n_ticks, const char* const labels[]=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.
|
// Sets an axis' ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
|
||||||
IMPLOT_API void SetupAxisTicks(ImAxis axis, double v_min, double v_max, int n_ticks, const char* const labels[] = NULL, bool keep_default = false);
|
IMPLOT_API void SetupAxisTicks(ImAxis axis, double v_min, double v_max, int n_ticks, const char* const labels[]=NULL, bool keep_default=false);
|
||||||
|
// Sets an axis' scale using built-in options.
|
||||||
|
IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotScale scale);
|
||||||
|
// Sets an axis' scale using user supplied forward and inverse transfroms.
|
||||||
|
IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotTransform forward, ImPlotTransform inverse, void* data=NULL);
|
||||||
|
// Sets an axis' limits constraints.
|
||||||
|
IMPLOT_API void SetupAxisLimitsConstraints(ImAxis axis, double v_min, double v_max);
|
||||||
|
// Sets an axis' zoom constraints.
|
||||||
|
IMPLOT_API void SetupAxisZoomConstraints(ImAxis axis, double z_min, double z_max);
|
||||||
|
|
||||||
// Sets the label and/or flags for primary X and Y axes (shorthand for two calls to SetupAxis).
|
// 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);
|
IMPLOT_API void SetupAxes(const char* x_label, const char* y_label, ImPlotAxisFlags x_flags=0, ImPlotAxisFlags y_flags=0);
|
||||||
// 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).
|
// 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);
|
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.
|
// Sets up the plot legend.
|
||||||
IMPLOT_API void SetupLegend(ImPlotLocation location, ImPlotLegendFlags flags = ImPlotLegendFlags_None);
|
IMPLOT_API void SetupLegend(ImPlotLocation location, ImPlotLegendFlags flags=0);
|
||||||
// Set the location of the current plot's mouse position text (default = South|East).
|
// Set the location of the current plot's mouse position text (default = South|East).
|
||||||
IMPLOT_API void SetupMouseText(ImPlotLocation location, ImPlotMouseTextFlags flags = ImPlotMouseTextFlags_None);
|
IMPLOT_API void SetupMouseText(ImPlotLocation location, ImPlotMouseTextFlags flags=0);
|
||||||
|
|
||||||
// Explicitly finalize plot setup. Once you call this, you cannot make anymore Setup calls for the current plot!
|
// 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.
|
// Note that calling this function is OPTIONAL; it will be called by the first subsequent setup-locking API call.
|
||||||
|
@ -666,7 +821,7 @@ IMPLOT_API void SetNextAxesToFit();
|
||||||
// struct Vector2f { float X, Y; };
|
// struct Vector2f { float X, Y; };
|
||||||
// ...
|
// ...
|
||||||
// Vector2f data[42];
|
// Vector2f data[42];
|
||||||
// ImPlot::PlotLine("line", &data[0].x, &data[0].y, 42, 0, sizeof(Vector2f)); // or sizeof(float)*2
|
// ImPlot::PlotLine("line", &data[0].x, &data[0].y, 42, 0, 0, sizeof(Vector2f));
|
||||||
//
|
//
|
||||||
// 2. Write a custom getter C function or C++ lambda and pass it and optionally your data to
|
// 2. Write a custom getter C function or C++ lambda and pass it and optionally your data to
|
||||||
// an ImPlot function post-fixed with a G (e.g. PlotScatterG). This has a slight performance
|
// an ImPlot function post-fixed with a G (e.g. PlotScatterG). This has a slight performance
|
||||||
|
@ -680,7 +835,7 @@ IMPLOT_API void SetNextAxesToFit();
|
||||||
// return p
|
// return p
|
||||||
// }
|
// }
|
||||||
// ...
|
// ...
|
||||||
// auto my_lambda = [](void*, int idx) {
|
// auto my_lambda = [](int idx, void*) {
|
||||||
// double t = idx / 999.0;
|
// double t = idx / 999.0;
|
||||||
// return ImPlotPoint(t, 0.5+0.5*std::sin(2*PI*10*t));
|
// return ImPlotPoint(t, 0.5+0.5*std::sin(2*PI*10*t));
|
||||||
// };
|
// };
|
||||||
|
@ -696,86 +851,71 @@ IMPLOT_API void SetNextAxesToFit();
|
||||||
// if you try plotting extremely large 64-bit integral types. Proceed with caution!
|
// if you try plotting extremely large 64-bit integral types. Proceed with caution!
|
||||||
|
|
||||||
// Plots a standard 2D line plot.
|
// Plots a standard 2D line plot.
|
||||||
IMPLOT_TMP void PlotLine(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotLine(const char* label_id, const T* values, int count, double xscale=1, double xstart=0, ImPlotLineFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotLine(const char* label_id, const T* xs, const T* ys, int count, ImPlotLineFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotLineG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
IMPLOT_API void PlotLineG(const char* label_id, ImPlotGetter getter, void* data, int count, ImPlotLineFlags flags=0);
|
||||||
|
|
||||||
// Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle.
|
// Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle.
|
||||||
IMPLOT_TMP void PlotScatter(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotScatter(const char* label_id, const T* values, int count, double xscale=1, double xstart=0, ImPlotScatterFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, ImPlotScatterFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotScatterG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
IMPLOT_API void PlotScatterG(const char* label_id, ImPlotGetter getter, void* data, int count, ImPlotScatterFlags flags=0);
|
||||||
|
|
||||||
// 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 to the right from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i]
|
||||||
IMPLOT_TMP void PlotStairs(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotStairs(const char* label_id, const T* values, int count, double xscale=1, double xstart=0, ImPlotStairsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotStairs(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotStairs(const char* label_id, const T* xs, const T* ys, int count, ImPlotStairsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotStairsG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
IMPLOT_API void PlotStairsG(const char* label_id, ImPlotGetter getter, void* data, int count, ImPlotStairsFlags flags=0);
|
||||||
|
|
||||||
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference. Set yref to +/-INFINITY for infinite fill extents.
|
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference. Set yref to +/-INFINITY for infinite fill extents.
|
||||||
IMPLOT_TMP void PlotShaded(const char* label_id, const T* values, int count, double yref=0, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotShaded(const char* label_id, const T* values, int count, double yref=0, double xscale=1, double xstart=0, ImPlotShadedFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double yref=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double yref=0, ImPlotShadedFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP 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_TMP void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, ImPlotShadedFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotShadedG(const char* label_id, ImPlotGetter getter1, void* data1, ImPlotGetter getter2, void* data2, int count);
|
IMPLOT_API void PlotShadedG(const char* label_id, ImPlotGetter getter1, void* data1, ImPlotGetter getter2, void* data2, int count, ImPlotShadedFlags flags=0);
|
||||||
|
|
||||||
// Plots a vertical bar graph. #bar_width and #x0 are in X units.
|
// Plots a bar graph. Vertical by default. #bar_size and #shift are in plot units.
|
||||||
IMPLOT_TMP void PlotBars(const char* label_id, const T* values, int count, double bar_width=0.67, double x0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotBars(const char* label_id, const T* values, int count, double bar_size=0.67, double shift=0, ImPlotBarsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double bar_width, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double bar_size, ImPlotBarsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotBarsG(const char* label_id, ImPlotGetter getter, void* data, int count, double bar_width);
|
IMPLOT_API void PlotBarsG(const char* label_id, ImPlotGetter getter, void* data, int count, double bar_size, ImPlotBarsFlags flags=0);
|
||||||
|
|
||||||
// Plots a horizontal bar graph. #bar_height and #y0 are in Y units.
|
// Plots a group of bars. #values is a row-major matrix with #item_count rows and #group_count cols. #label_ids should have #item_count elements.
|
||||||
IMPLOT_TMP void PlotBarsH(const char* label_id, const T* values, int count, double bar_height=0.67, double y0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotBarGroups(const char* const label_ids[], const T* values, int item_count, int group_count, double group_size=0.67, double shift=0, ImPlotBarGroupsFlags flags=0);
|
||||||
IMPLOT_TMP void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double bar_height, int offset=0, int stride=sizeof(T));
|
|
||||||
IMPLOT_API void PlotBarsHG(const char* label_id, ImPlotGetter getter, void* data, int count, double bar_height);
|
|
||||||
|
|
||||||
// Plots a group of vertical bars. #values is a row-major matrix with #item_count rows and #group_count cols. #label_ids should have #item_count elements.
|
|
||||||
IMPLOT_TMP void PlotBarGroups(const char* const label_ids[], const T* values, int item_count, int group_count, double group_width=0.67, double x0=0, ImPlotBarGroupsFlags flags=ImPlotBarGroupsFlags_None);
|
|
||||||
|
|
||||||
// Plots a group of horizontal bars. #values is a row-major matrix with #item_count rows and #group_count cols. #label_ids should have #item_count elements.
|
|
||||||
IMPLOT_TMP void PlotBarGroupsH(const char* const label_ids[], const T* values, int item_count, int group_count, double group_height=0.67, double y0=0, ImPlotBarGroupsFlags flags=ImPlotBarGroupsFlags_None);
|
|
||||||
|
|
||||||
// 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.
|
||||||
IMPLOT_TMP void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, ImPlotErrorBarsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, ImPlotErrorBarsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
|
|
||||||
// Plots horizontal error bars. The label_id should be the same as the label_id of the associated line or bar plot.
|
// Plots stems. Vertical by default.
|
||||||
IMPLOT_TMP void PlotErrorBarsH(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotStems(const char* label_id, const T* values, int count, double ref=0, double scale=1, double start=0, ImPlotStemsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotErrorBarsH(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotStems(const char* label_id, const T* xs, const T* ys, int count, double ref=0, ImPlotStemsFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
|
|
||||||
/// Plots vertical stems.
|
// Plots infinite vertical or horizontal lines (e.g. for references or asymptotes).
|
||||||
IMPLOT_TMP void PlotStems(const char* label_id, const T* values, int count, double yref=0, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotInfLines(const char* label_id, const T* values, int count, ImPlotInfLinesFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_TMP void PlotStems(const char* label_id, const T* xs, const T* ys, int count, double yref=0, int offset=0, int stride=sizeof(T));
|
|
||||||
|
|
||||||
/// Plots infinite vertical or horizontal lines (e.g. for references or asymptotes).
|
// Plots a pie chart. Center and radius are in plot units. #label_fmt can be set to NULL for no labels.
|
||||||
IMPLOT_TMP void PlotVLines(const char* label_id, const T* xs, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, const char* label_fmt="%.1f", double angle0=90, ImPlotPieChartFlags flags=0);
|
||||||
IMPLOT_TMP void PlotHLines(const char* label_id, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
|
||||||
|
|
||||||
// Plots a pie chart. If the sum of values > 1 or normalize is true, each value will be normalized. Center and radius are in plot units. #label_fmt can be set to NULL for no labels.
|
// Plots a 2D heatmap chart. Values are expected to be in row-major order by default. Leave #scale_min and scale_max both at 0 for automatic color scaling, or set them to a predefined range. #label_fmt can be set to NULL for no labels.
|
||||||
IMPLOT_TMP void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, bool normalize=false, const char* label_fmt="%.1f", double angle0=90);
|
IMPLOT_TMP void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min=0, double scale_max=0, const char* label_fmt="%.1f", const ImPlotPoint& bounds_min=ImPlotPoint(0,0), const ImPlotPoint& bounds_max=ImPlotPoint(1,1), ImPlotHeatmapFlags flags=0);
|
||||||
|
|
||||||
// Plots a 2D heatmap chart. Values are expected to be in row-major order. Leave #scale_min and scale_max both at 0 for automatic color scaling, or set them to a predefined range. #label_fmt can be set to NULL for no labels.
|
// Plots a horizontal histogram. #bins can be a positive integer or an ImPlotBin_ method. If #range is left unspecified, the min/max of #values will be used as the range.
|
||||||
IMPLOT_TMP void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min=0, double scale_max=0, const char* label_fmt="%.1f", const ImPlotPoint& bounds_min=ImPlotPoint(0,0), const ImPlotPoint& bounds_max=ImPlotPoint(1,1));
|
// Otherwise, outlier values outside of the range are not binned. The largest bin count or density is returned.
|
||||||
|
IMPLOT_TMP double PlotHistogram(const char* label_id, const T* values, int count, int bins=ImPlotBin_Sturges, double bar_scale=1.0, ImPlotRange range=ImPlotRange(), ImPlotHistogramFlags flags=0);
|
||||||
|
|
||||||
// Plots a horizontal histogram. #bins can be a positive integer or an ImPlotBin_ method. If #cumulative is true, each bin contains its count plus the counts of all previous bins.
|
// Plots two dimensional, bivariate histogram as a heatmap. #x_bins and #y_bins can be a positive integer or an ImPlotBin. If #range is left unspecified, the min/max of
|
||||||
// If #density is true, the PDF is visualized. If both are true, the CDF is visualized. If #range is left unspecified, the min/max of #values will be used as the range.
|
// #xs an #ys will be used as the ranges. Otherwise, outlier values outside of range are not binned. The largest bin count or density is returned.
|
||||||
// If #range is specified, outlier values outside of the range are not binned. However, outliers still count toward normalizing and cumulative counts unless #outliers is false. The largest bin count or density is returned.
|
IMPLOT_TMP double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count, int x_bins=ImPlotBin_Sturges, int y_bins=ImPlotBin_Sturges, ImPlotRect range=ImPlotRect(), ImPlotHistogramFlags flags=0);
|
||||||
IMPLOT_TMP 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.
|
|
||||||
// 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.
|
|
||||||
IMPLOT_TMP 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.
|
||||||
IMPLOT_TMP void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
IMPLOT_TMP void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, ImPlotDigitalFlags flags=0, int offset=0, int stride=sizeof(T));
|
||||||
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotGetter getter, void* data, int count);
|
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotGetter getter, void* data, int count, ImPlotDigitalFlags flags=0);
|
||||||
|
|
||||||
// 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), ImPlotImageFlags flags=0);
|
||||||
|
|
||||||
// Plots a centered text label at point x,y with an optional pixel offset. Text color can be changed with ImPlot::PushStyleColor(ImPlotCol_InlayText, ...).
|
// Plots a centered text label at point x,y with an optional pixel offset. Text color can be changed with ImPlot::PushStyleColor(ImPlotCol_InlayText, ...).
|
||||||
IMPLOT_API void PlotText(const char* text, double x, double y, bool vertical=false, const ImVec2& pix_offset=ImVec2(0,0));
|
IMPLOT_API void PlotText(const char* text, double x, double y, const ImVec2& pix_offset=ImVec2(0,0), ImPlotTextFlags flags=0);
|
||||||
|
|
||||||
// Plots a dummy item (i.e. adds a legend entry colored by ImPlotCol_Line)
|
// Plots a dummy item (i.e. adds a legend entry colored by ImPlotCol_Line)
|
||||||
IMPLOT_API void PlotDummy(const char* label_id);
|
IMPLOT_API void PlotDummy(const char* label_id, ImPlotDummyFlags flags=0);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Plot Tools
|
// [SECTION] Plot Tools
|
||||||
|
@ -786,28 +926,28 @@ IMPLOT_API void PlotDummy(const char* label_id);
|
||||||
// axes, which can be changed with `SetAxis/SetAxes`.
|
// axes, which can be changed with `SetAxis/SetAxes`.
|
||||||
|
|
||||||
// Shows a draggable point at x,y. #col defaults to ImGuiCol_Text.
|
// Shows a draggable point at x,y. #col defaults to ImGuiCol_Text.
|
||||||
IMPLOT_API bool DragPoint(int id, double* x, double* y, const ImVec4& col, float size = 4, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
IMPLOT_API bool DragPoint(int id, double* x, double* y, const ImVec4& col, float size = 4, ImPlotDragToolFlags flags=0);
|
||||||
// Shows a draggable vertical guide line at an x-value. #col defaults to ImGuiCol_Text.
|
// Shows a draggable vertical guide line at an x-value. #col defaults to ImGuiCol_Text.
|
||||||
IMPLOT_API bool DragLineX(int id, double* x, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
IMPLOT_API bool DragLineX(int id, double* x, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags=0);
|
||||||
// Shows a draggable horizontal guide line at a y-value. #col defaults to ImGuiCol_Text.
|
// Shows a draggable horizontal guide line at a y-value. #col defaults to ImGuiCol_Text.
|
||||||
IMPLOT_API bool DragLineY(int id, double* y, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags = ImPlotDragToolFlags_None);
|
IMPLOT_API bool DragLineY(int id, double* y, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags=0);
|
||||||
// Shows a draggable and resizeable rectangle.
|
// Shows a draggable and resizeable rectangle.
|
||||||
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);
|
IMPLOT_API bool DragRect(int id, double* x1, double* y1, double* x2, double* y2, const ImVec4& col, ImPlotDragToolFlags flags=0);
|
||||||
|
|
||||||
// Shows an annotation callout at a chosen point. Clamping keeps annotations in the plot area. Annotations are always rendered on top.
|
// Shows an annotation callout at a chosen point. Clamping keeps annotations in the plot area. Annotations are always rendered on top.
|
||||||
IMPLOT_API void Annotation(double x, double y, const ImVec4& color, const ImVec2& pix_offset, bool clamp, bool round = false);
|
IMPLOT_API void Annotation(double x, double y, const ImVec4& col, const ImVec2& pix_offset, bool clamp, bool round = false);
|
||||||
IMPLOT_API void Annotation(double x, double y, const ImVec4& color, const ImVec2& pix_offset, bool clamp, const char* fmt, ...) IM_FMTARGS(6);
|
IMPLOT_API void Annotation(double x, double y, const ImVec4& col, const ImVec2& pix_offset, bool clamp, const char* fmt, ...) IM_FMTARGS(6);
|
||||||
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 AnnotationV(double x, double y, const ImVec4& col, const ImVec2& pix_offset, bool clamp, const char* fmt, va_list args) IM_FMTLIST(6);
|
||||||
|
|
||||||
// Shows a x-axis tag at the specified coordinate value.
|
// Shows a x-axis tag at the specified coordinate value.
|
||||||
IMPLOT_API void TagX(double x, const ImVec4& color, bool round = false);
|
IMPLOT_API void TagX(double x, const ImVec4& col, bool round = false);
|
||||||
IMPLOT_API void TagX(double x, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(3);
|
IMPLOT_API void TagX(double x, const ImVec4& col, const char* fmt, ...) IM_FMTARGS(3);
|
||||||
IMPLOT_API void TagXV(double x, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(3);
|
IMPLOT_API void TagXV(double x, const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||||
|
|
||||||
// Shows a y-axis tag at the specified coordinate value.
|
// 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& col, bool round = false);
|
||||||
IMPLOT_API void TagY(double y, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(3);
|
IMPLOT_API void TagY(double y, const ImVec4& col, const char* fmt, ...) IM_FMTARGS(3);
|
||||||
IMPLOT_API void TagYV(double y, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(3);
|
IMPLOT_API void TagYV(double y, const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Plot Utils
|
// [SECTION] Plot Utils
|
||||||
|
@ -869,7 +1009,7 @@ IMPLOT_API void EndAlignedPlots();
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// 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.
|
// Returns true if a plot item legend entry is hovered.
|
||||||
|
@ -889,14 +1029,14 @@ IMPLOT_API bool BeginDragDropTargetLegend();
|
||||||
IMPLOT_API void EndDragDropTarget();
|
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 ImGuiModFlags_None is provided, the axes will be locked from panning.
|
// You can change the modifier if desired. If ImGuiMod_None is provided, the axes will be locked from panning.
|
||||||
|
|
||||||
// Turns the current plot's plotting area into a drag and drop source. You must hold Ctrl. 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 BeginDragDropSourcePlot(ImGuiDragDropFlags flags = 0);
|
IMPLOT_API bool BeginDragDropSourcePlot(ImGuiDragDropFlags flags=0);
|
||||||
// Turns the current plot's X-axis into a drag and drop source. You must hold Ctrl. 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 BeginDragDropSourceAxis(ImAxis axis, ImGuiDragDropFlags flags = 0);
|
IMPLOT_API bool BeginDragDropSourceAxis(ImAxis axis, 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();
|
||||||
|
|
||||||
|
@ -1036,8 +1176,8 @@ IMPLOT_API ImVec4 GetColormapColor(int idx, ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Sample a color from the current colormap given t between 0 and 1.
|
// Sample a color from the current colormap given t between 0 and 1.
|
||||||
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"). If scale_min > scale_max, the scale to color mapping will be reversed.
|
||||||
IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), ImPlotColormap cmap = IMPLOT_AUTO, const char* format = "%g");
|
IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), const char* format = "%g", ImPlotColormapScaleFlags flags = 0, ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Shows a horizontal slider with a colormap gradient background. Optionally returns the color sampled at t in [0 1].
|
// Shows a horizontal slider with a colormap gradient background. Optionally returns the color sampled at t in [0 1].
|
||||||
IMPLOT_API bool ColormapSlider(const char* label, float* t, ImVec4* out = NULL, const char* format = "", ImPlotColormap cmap = IMPLOT_AUTO);
|
IMPLOT_API bool ColormapSlider(const char* label, float* t, ImVec4* out = NULL, const char* format = "", ImPlotColormap cmap = IMPLOT_AUTO);
|
||||||
// Shows a button with a colormap gradient brackground.
|
// Shows a button with a colormap gradient brackground.
|
||||||
|
@ -1140,8 +1280,8 @@ IMPLOT_DEPRECATED( IMPLOT_API bool BeginPlot(const char* title_id,
|
||||||
const char* y_label, // = NULL,
|
const char* y_label, // = NULL,
|
||||||
const ImVec2& size = ImVec2(-1,0),
|
const ImVec2& size = ImVec2(-1,0),
|
||||||
ImPlotFlags flags = ImPlotFlags_None,
|
ImPlotFlags flags = ImPlotFlags_None,
|
||||||
ImPlotAxisFlags x_flags = ImPlotAxisFlags_None,
|
ImPlotAxisFlags x_flags = 0,
|
||||||
ImPlotAxisFlags y_flags = ImPlotAxisFlags_None,
|
ImPlotAxisFlags y_flags = 0,
|
||||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_AuxDefault,
|
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_AuxDefault,
|
||||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_AuxDefault,
|
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_AuxDefault,
|
||||||
const char* y2_label = NULL,
|
const char* y2_label = NULL,
|
||||||
|
|
929
implot_demo.cpp
929
implot_demo.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
// Copyright (c) 2021 Evan Pezent
|
// Copyright (c) 2022 Evan Pezent
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -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.13 WIP
|
// ImPlot v0.14
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImPlot features but we
|
// You may use this file to debug, understand or extend ImPlot features but we
|
||||||
// don't provide any guarantee of forward compatibility!
|
// don't provide any guarantee of forward compatibility!
|
||||||
|
@ -63,8 +63,6 @@
|
||||||
#define IMPLOT_LABEL_FORMAT "%g"
|
#define IMPLOT_LABEL_FORMAT "%g"
|
||||||
// Max character size for tick labels
|
// Max character size for tick labels
|
||||||
#define IMPLOT_LABEL_MAX_SIZE 32
|
#define IMPLOT_LABEL_MAX_SIZE 32
|
||||||
// Plot values less than or equal to 0 will be replaced with this on log scale axes
|
|
||||||
#define IMPLOT_LOG_ZERO DBL_MIN
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Macros
|
// [SECTION] Macros
|
||||||
|
@ -90,6 +88,7 @@ struct ImPlotItem;
|
||||||
struct ImPlotLegend;
|
struct ImPlotLegend;
|
||||||
struct ImPlotPlot;
|
struct ImPlotPlot;
|
||||||
struct ImPlotNextPlotData;
|
struct ImPlotNextPlotData;
|
||||||
|
struct ImPlotTicker;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Context Pointer
|
// [SECTION] Context Pointer
|
||||||
|
@ -106,6 +105,10 @@ extern IMPLOT_API ImPlotContext* GImPlot; // Current implicit context pointer
|
||||||
// Computes the common (base-10) logarithm
|
// Computes the common (base-10) logarithm
|
||||||
static inline float ImLog10(float x) { return log10f(x); }
|
static inline float ImLog10(float x) { return log10f(x); }
|
||||||
static inline double ImLog10(double x) { return log10(x); }
|
static inline double ImLog10(double x) { return log10(x); }
|
||||||
|
static inline float ImSinh(float x) { return sinhf(x); }
|
||||||
|
static inline double ImSinh(double x) { return sinh(x); }
|
||||||
|
static inline float ImAsinh(float x) { return asinhf(x); }
|
||||||
|
static inline double ImAsinh(double x) { return asinh(x); }
|
||||||
// Returns true if a flag is set
|
// Returns true if a flag is set
|
||||||
template <typename TSet, typename TFlag>
|
template <typename TSet, typename TFlag>
|
||||||
static inline bool ImHasFlag(TSet set, TFlag flag) { return (set & flag) == flag; }
|
static inline bool ImHasFlag(TSet set, TFlag flag) { return (set & flag) == flag; }
|
||||||
|
@ -120,10 +123,12 @@ template <typename T>
|
||||||
static inline T ImRemap01(T x, T x0, T x1) { return (x - x0) / (x1 - x0); }
|
static inline T ImRemap01(T x, T x0, T x1) { return (x - x0) / (x1 - x0); }
|
||||||
// Returns always positive modulo (assumes r != 0)
|
// Returns always positive modulo (assumes r != 0)
|
||||||
static inline int ImPosMod(int l, int r) { return (l % r + r) % r; }
|
static inline int ImPosMod(int l, int r) { return (l % r + r) % r; }
|
||||||
|
// Returns true if val is NAN
|
||||||
|
static inline bool ImNan(double val) { return isnan(val); }
|
||||||
// Returns true if val is NAN or INFINITY
|
// Returns true if val is NAN or INFINITY
|
||||||
static inline bool ImNanOrInf(double val) { return !(val >= -DBL_MAX && val <= DBL_MAX) || isnan(val); }
|
static inline bool ImNanOrInf(double val) { return !(val >= -DBL_MAX && val <= DBL_MAX) || ImNan(val); }
|
||||||
// Turns NANs to 0s
|
// Turns NANs to 0s
|
||||||
static inline double ImConstrainNan(double val) { return isnan(val) ? 0 : val; }
|
static inline double ImConstrainNan(double val) { return ImNan(val) ? 0 : val; }
|
||||||
// Turns infinity to floating point maximums
|
// Turns infinity to floating point maximums
|
||||||
static inline double ImConstrainInf(double val) { return val >= DBL_MAX ? DBL_MAX : val <= -DBL_MAX ? - DBL_MAX : val; }
|
static inline double ImConstrainInf(double val) { return val >= DBL_MAX ? DBL_MAX : val <= -DBL_MAX ? - DBL_MAX : val; }
|
||||||
// Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?)
|
// Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?)
|
||||||
|
@ -162,7 +167,7 @@ static inline double ImMean(const T* values, int count) {
|
||||||
double den = 1.0 / count;
|
double den = 1.0 / count;
|
||||||
double mu = 0;
|
double mu = 0;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
mu += values[i] * den;
|
mu += (double)values[i] * den;
|
||||||
return mu;
|
return mu;
|
||||||
}
|
}
|
||||||
// Finds the sample standard deviation of an array
|
// Finds the sample standard deviation of an array
|
||||||
|
@ -172,7 +177,7 @@ static inline double ImStdDev(const T* values, int count) {
|
||||||
double mu = ImMean(values, count);
|
double mu = ImMean(values, count);
|
||||||
double x = 0;
|
double x = 0;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
x += (values[i] - mu) * (values[i] - mu) * den;
|
x += ((double)values[i] - mu) * ((double)values[i] - mu) * den;
|
||||||
return sqrt(x);
|
return sqrt(x);
|
||||||
}
|
}
|
||||||
// Mix color a and b by factor s in [0 256]
|
// Mix color a and b by factor s in [0 256]
|
||||||
|
@ -215,23 +220,20 @@ static inline ImU32 ImAlphaU32(ImU32 col, float alpha) {
|
||||||
return col & ~((ImU32)((1.0f-alpha)*255)<<IM_COL32_A_SHIFT);
|
return col & ~((ImU32)((1.0f-alpha)*255)<<IM_COL32_A_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true of two ranges overlap
|
||||||
|
template <typename T>
|
||||||
|
static inline bool ImOverlaps(T min_a, T max_a, T min_b, T max_b) {
|
||||||
|
return min_a <= max_b && min_b <= max_a;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] ImPlot Enums
|
// [SECTION] ImPlot Enums
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
typedef int ImPlotScale; // -> enum ImPlotScale_
|
|
||||||
typedef int ImPlotTimeUnit; // -> enum ImPlotTimeUnit_
|
typedef int ImPlotTimeUnit; // -> enum ImPlotTimeUnit_
|
||||||
typedef int ImPlotDateFmt; // -> enum ImPlotDateFmt_
|
typedef int ImPlotDateFmt; // -> enum ImPlotDateFmt_
|
||||||
typedef int ImPlotTimeFmt; // -> enum ImPlotTimeFmt_
|
typedef int ImPlotTimeFmt; // -> enum ImPlotTimeFmt_
|
||||||
|
|
||||||
// XY axes scaling combinations
|
|
||||||
enum ImPlotScale_ {
|
|
||||||
ImPlotScale_LinLin, // linear x, linear y
|
|
||||||
ImPlotScale_LogLin, // log x, linear y
|
|
||||||
ImPlotScale_LinLog, // linear x, log y
|
|
||||||
ImPlotScale_LogLog // log x, log y
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ImPlotTimeUnit_ {
|
enum ImPlotTimeUnit_ {
|
||||||
ImPlotTimeUnit_Us, // microsecond
|
ImPlotTimeUnit_Us, // microsecond
|
||||||
ImPlotTimeUnit_Ms, // millisecond
|
ImPlotTimeUnit_Ms, // millisecond
|
||||||
|
@ -259,6 +261,7 @@ enum ImPlotTimeFmt_ { // default [ 24 Hour Clock ]
|
||||||
ImPlotTimeFmt_SUs, // :29.428 552 [ :29.428 552 ]
|
ImPlotTimeFmt_SUs, // :29.428 552 [ :29.428 552 ]
|
||||||
ImPlotTimeFmt_SMs, // :29.428 [ :29.428 ]
|
ImPlotTimeFmt_SMs, // :29.428 [ :29.428 ]
|
||||||
ImPlotTimeFmt_S, // :29 [ :29 ]
|
ImPlotTimeFmt_S, // :29 [ :29 ]
|
||||||
|
ImPlotTimeFmt_MinSMs, // 21:29.428 [ 21:29.428 ]
|
||||||
ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm [ 19:21:29.428 ]
|
ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm [ 19:21:29.428 ]
|
||||||
ImPlotTimeFmt_HrMinS, // 7:21:29pm [ 19:21:29 ]
|
ImPlotTimeFmt_HrMinS, // 7:21:29pm [ 19:21:29 ]
|
||||||
ImPlotTimeFmt_HrMin, // 7:21pm [ 19:21 ]
|
ImPlotTimeFmt_HrMin, // 7:21pm [ 19:21 ]
|
||||||
|
@ -266,12 +269,19 @@ enum ImPlotTimeFmt_ { // default [ 24 Hour Clock ]
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] ImPlot Structs
|
// [SECTION] Callbacks
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef void (*ImPlotLocator)(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Structs
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Combined date/time format spec
|
// Combined date/time format spec
|
||||||
struct ImPlotDateTimeFmt {
|
struct ImPlotDateTimeSpec {
|
||||||
ImPlotDateTimeFmt(ImPlotDateFmt date_fmt, ImPlotTimeFmt time_fmt, bool use_24_hr_clk = false, bool use_iso_8601 = false) {
|
ImPlotDateTimeSpec() {}
|
||||||
|
ImPlotDateTimeSpec(ImPlotDateFmt date_fmt, ImPlotTimeFmt time_fmt, bool use_24_hr_clk = false, bool use_iso_8601 = false) {
|
||||||
Date = date_fmt;
|
Date = date_fmt;
|
||||||
Time = time_fmt;
|
Time = time_fmt;
|
||||||
UseISO8601 = use_iso_8601;
|
UseISO8601 = use_iso_8601;
|
||||||
|
@ -409,7 +419,6 @@ struct ImPlotColormapData {
|
||||||
int idx = Quals[cmap] ? ImClamp((int)(siz*t),0,siz-1) : (int)((siz - 1) * t + 0.5f);
|
int idx = Quals[cmap] ? ImClamp((int)(siz*t),0,siz-1) : (int)((siz - 1) * t + 0.5f);
|
||||||
return Tables[off + idx];
|
return Tables[off + idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ImPlotPoint with positive/negative error values
|
// ImPlotPoint with positive/negative error values
|
||||||
|
@ -428,6 +437,11 @@ struct ImPlotAnnotation {
|
||||||
ImU32 ColorFg;
|
ImU32 ColorFg;
|
||||||
int TextOffset;
|
int TextOffset;
|
||||||
bool Clamp;
|
bool Clamp;
|
||||||
|
ImPlotAnnotation() {
|
||||||
|
ColorBg = ColorFg = 0;
|
||||||
|
TextOffset = 0;
|
||||||
|
Clamp = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Collection of plot labels
|
// Collection of plot labels
|
||||||
|
@ -528,38 +542,42 @@ struct ImPlotTick
|
||||||
bool Major;
|
bool Major;
|
||||||
bool ShowLabel;
|
bool ShowLabel;
|
||||||
int Level;
|
int Level;
|
||||||
|
int Idx;
|
||||||
|
|
||||||
ImPlotTick(double value, bool major, bool show_label) {
|
ImPlotTick(double value, bool major, int level, bool show_label) {
|
||||||
|
PixelPos = 0;
|
||||||
PlotPos = value;
|
PlotPos = value;
|
||||||
Major = major;
|
Major = major;
|
||||||
ShowLabel = show_label;
|
ShowLabel = show_label;
|
||||||
|
Level = level;
|
||||||
TextOffset = -1;
|
TextOffset = -1;
|
||||||
Level = 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Collection of ticks
|
// Collection of ticks
|
||||||
struct ImPlotTickCollection {
|
struct ImPlotTicker {
|
||||||
ImVector<ImPlotTick> Ticks;
|
ImVector<ImPlotTick> Ticks;
|
||||||
ImGuiTextBuffer TextBuffer;
|
ImGuiTextBuffer TextBuffer;
|
||||||
ImVec2 MaxSize;
|
ImVec2 MaxSize;
|
||||||
ImVec2 LateSize;
|
ImVec2 LateSize;
|
||||||
int Size;
|
int Levels;
|
||||||
|
|
||||||
ImPlotTickCollection() { Reset(); }
|
ImPlotTicker() {
|
||||||
|
Reset();
|
||||||
const ImPlotTick& Append(const ImPlotTick& tick) {
|
|
||||||
if (tick.ShowLabel) {
|
|
||||||
MaxSize.x = tick.LabelSize.x > MaxSize.x ? tick.LabelSize.x : MaxSize.x;
|
|
||||||
MaxSize.y = tick.LabelSize.y > MaxSize.y ? tick.LabelSize.y : MaxSize.y;
|
|
||||||
}
|
|
||||||
Ticks.push_back(tick);
|
|
||||||
Size++;
|
|
||||||
return Ticks.back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImPlotTick& Append(double value, bool major, bool show_label, ImPlotFormatter formatter, void* data) {
|
ImPlotTick& AddTick(double value, bool major, int level, bool show_label, const char* label) {
|
||||||
ImPlotTick tick(value, major, show_label);
|
ImPlotTick tick(value, major, level, show_label);
|
||||||
|
if (show_label && label != NULL) {
|
||||||
|
tick.TextOffset = TextBuffer.size();
|
||||||
|
TextBuffer.append(label, label + strlen(label) + 1);
|
||||||
|
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
|
||||||
|
}
|
||||||
|
return AddTick(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImPlotTick& AddTick(double value, bool major, int level, bool show_label, ImPlotFormatter formatter, void* data) {
|
||||||
|
ImPlotTick tick(value, major, level, show_label);
|
||||||
if (show_label && formatter != NULL) {
|
if (show_label && formatter != NULL) {
|
||||||
char buff[IMPLOT_LABEL_MAX_SIZE];
|
char buff[IMPLOT_LABEL_MAX_SIZE];
|
||||||
tick.TextOffset = TextBuffer.size();
|
tick.TextOffset = TextBuffer.size();
|
||||||
|
@ -567,16 +585,25 @@ struct ImPlotTickCollection {
|
||||||
TextBuffer.append(buff, buff + strlen(buff) + 1);
|
TextBuffer.append(buff, buff + strlen(buff) + 1);
|
||||||
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
|
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
|
||||||
}
|
}
|
||||||
return Append(tick);
|
return AddTick(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ImPlotTick& AddTick(ImPlotTick tick) {
|
||||||
|
if (tick.ShowLabel) {
|
||||||
|
MaxSize.x = tick.LabelSize.x > MaxSize.x ? tick.LabelSize.x : MaxSize.x;
|
||||||
|
MaxSize.y = tick.LabelSize.y > MaxSize.y ? tick.LabelSize.y : MaxSize.y;
|
||||||
|
}
|
||||||
|
tick.Idx = Ticks.size();
|
||||||
|
Ticks.push_back(tick);
|
||||||
|
return Ticks.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetText(int idx) const {
|
const char* GetText(int idx) const {
|
||||||
return TextBuffer.Buf.Data + Ticks[idx].TextOffset;
|
return TextBuffer.Buf.Data + Ticks[idx].TextOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverrideSize(const ImVec2& size) {
|
const char* GetText(const ImPlotTick& tick) {
|
||||||
MaxSize.x = size.x > MaxSize.x ? size.x : MaxSize.x;
|
return GetText(tick.Idx);
|
||||||
MaxSize.y = size.y > MaxSize.y ? size.y : MaxSize.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverrideSizeLate(const ImVec2& size) {
|
void OverrideSizeLate(const ImVec2& size) {
|
||||||
|
@ -589,7 +616,11 @@ struct ImPlotTickCollection {
|
||||||
TextBuffer.Buf.shrink(0);
|
TextBuffer.Buf.shrink(0);
|
||||||
MaxSize = LateSize;
|
MaxSize = LateSize;
|
||||||
LateSize = ImVec2(0,0);
|
LateSize = ImVec2(0,0);
|
||||||
Size = 0;
|
Levels = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TickCount() const {
|
||||||
|
return Ticks.Size;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -599,24 +630,38 @@ struct ImPlotAxis
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImPlotAxisFlags Flags;
|
ImPlotAxisFlags Flags;
|
||||||
ImPlotAxisFlags PreviousFlags;
|
ImPlotAxisFlags PreviousFlags;
|
||||||
ImPlotCond RangeCond;
|
|
||||||
ImPlotTickCollection Ticks;
|
|
||||||
ImPlotRange Range;
|
ImPlotRange Range;
|
||||||
|
ImPlotCond RangeCond;
|
||||||
|
ImPlotScale Scale;
|
||||||
ImPlotRange FitExtents;
|
ImPlotRange FitExtents;
|
||||||
ImPlotAxis* OrthoAxis;
|
ImPlotAxis* OrthoAxis;
|
||||||
|
ImPlotRange ConstraintRange;
|
||||||
|
ImPlotRange ConstraintZoom;
|
||||||
|
|
||||||
|
ImPlotTicker Ticker;
|
||||||
|
ImPlotFormatter Formatter;
|
||||||
|
void* FormatterData;
|
||||||
|
char FormatSpec[16];
|
||||||
|
ImPlotLocator Locator;
|
||||||
|
|
||||||
double* LinkedMin;
|
double* LinkedMin;
|
||||||
double* LinkedMax;
|
double* LinkedMax;
|
||||||
|
|
||||||
int PickerLevel;
|
int PickerLevel;
|
||||||
ImPlotTime PickerTimeMin, PickerTimeMax;
|
ImPlotTime PickerTimeMin, PickerTimeMax;
|
||||||
float Datum1, Datum2;
|
|
||||||
|
ImPlotTransform TransformForward;
|
||||||
|
ImPlotTransform TransformInverse;
|
||||||
|
void* TransformData;
|
||||||
float PixelMin, PixelMax;
|
float PixelMin, PixelMax;
|
||||||
double LinM, LogD;
|
double ScaleMin, ScaleMax;
|
||||||
|
double ScaleToPixel;
|
||||||
|
float Datum1, Datum2;
|
||||||
|
|
||||||
ImRect HoverRect;
|
ImRect HoverRect;
|
||||||
int LabelOffset;
|
int LabelOffset;
|
||||||
ImU32 ColorMaj, ColorMin, ColorTick, ColorTxt, ColorBg, ColorHov, ColorAct, ColorHiLi;
|
ImU32 ColorMaj, ColorMin, ColorTick, ColorTxt, ColorBg, ColorHov, ColorAct, ColorHiLi;
|
||||||
char FormatSpec[16];
|
|
||||||
ImPlotFormatter Formatter;
|
|
||||||
void* FormatterData;
|
|
||||||
bool Enabled;
|
bool Enabled;
|
||||||
bool Vertical;
|
bool Vertical;
|
||||||
bool FitThisFrame;
|
bool FitThisFrame;
|
||||||
|
@ -627,12 +672,18 @@ struct ImPlotAxis
|
||||||
bool Held;
|
bool Held;
|
||||||
|
|
||||||
ImPlotAxis() {
|
ImPlotAxis() {
|
||||||
|
ID = 0;
|
||||||
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
||||||
Range.Min = 0;
|
Range.Min = 0;
|
||||||
Range.Max = 1;
|
Range.Max = 1;
|
||||||
|
Scale = ImPlotScale_Linear;
|
||||||
|
TransformForward = TransformInverse = NULL;
|
||||||
|
TransformData = NULL;
|
||||||
FitExtents.Min = HUGE_VAL;
|
FitExtents.Min = HUGE_VAL;
|
||||||
FitExtents.Max = -HUGE_VAL;
|
FitExtents.Max = -HUGE_VAL;
|
||||||
OrthoAxis = NULL;
|
OrthoAxis = NULL;
|
||||||
|
ConstraintRange = ImPlotRange(-INFINITY,INFINITY);
|
||||||
|
ConstraintZoom = ImPlotRange(DBL_MIN,INFINITY);
|
||||||
LinkedMin = LinkedMax = NULL;
|
LinkedMin = LinkedMax = NULL;
|
||||||
PickerLevel = 0;
|
PickerLevel = 0;
|
||||||
Datum1 = Datum2 = 0;
|
Datum1 = Datum2 = 0;
|
||||||
|
@ -642,32 +693,42 @@ struct ImPlotAxis
|
||||||
ColorHiLi = IM_COL32_BLACK_TRANS;
|
ColorHiLi = IM_COL32_BLACK_TRANS;
|
||||||
Formatter = NULL;
|
Formatter = NULL;
|
||||||
FormatterData = NULL;
|
FormatterData = NULL;
|
||||||
|
Locator = NULL;
|
||||||
Enabled = Hovered = Held = FitThisFrame = HasRange = HasFormatSpec = false;
|
Enabled = Hovered = Held = FitThisFrame = HasRange = HasFormatSpec = false;
|
||||||
ShowDefaultTicks = true;
|
ShowDefaultTicks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Reset() {
|
inline void Reset() {
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
|
Scale = ImPlotScale_Linear;
|
||||||
|
TransformForward = TransformInverse = NULL;
|
||||||
|
TransformData = NULL;
|
||||||
LabelOffset = -1;
|
LabelOffset = -1;
|
||||||
HasFormatSpec = false;
|
HasFormatSpec = false;
|
||||||
Formatter = NULL;
|
Formatter = NULL;
|
||||||
FormatterData = NULL;
|
FormatterData = NULL;
|
||||||
|
Locator = NULL;
|
||||||
ShowDefaultTicks = true;
|
ShowDefaultTicks = true;
|
||||||
FitThisFrame = false;
|
FitThisFrame = false;
|
||||||
FitExtents.Min = HUGE_VAL;
|
FitExtents.Min = HUGE_VAL;
|
||||||
FitExtents.Max = -HUGE_VAL;
|
FitExtents.Max = -HUGE_VAL;
|
||||||
OrthoAxis = NULL;
|
OrthoAxis = NULL;
|
||||||
Ticks.Reset();
|
ConstraintRange = ImPlotRange(-INFINITY,INFINITY);
|
||||||
|
ConstraintZoom = ImPlotRange(DBL_MIN,INFINITY);
|
||||||
|
Ticker.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetMin(double _min, bool force=false) {
|
inline bool SetMin(double _min, bool force=false) {
|
||||||
if (!force && IsLockedMin())
|
if (!force && IsLockedMin())
|
||||||
return false;
|
return false;
|
||||||
_min = ImConstrainNan(ImConstrainInf(_min));
|
_min = ImConstrainNan(ImConstrainInf(_min));
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
if (_min < ConstraintRange.Min)
|
||||||
_min = ImConstrainLog(_min);
|
_min = ConstraintRange.Min;
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
double z = Range.Max - _min;
|
||||||
_min = ImConstrainTime(_min);
|
if (z < ConstraintZoom.Min)
|
||||||
|
_min = Range.Max - ConstraintZoom.Min;
|
||||||
|
if (z > ConstraintZoom.Max)
|
||||||
|
_min = Range.Max - ConstraintZoom.Max;
|
||||||
if (_min >= Range.Max)
|
if (_min >= Range.Max)
|
||||||
return false;
|
return false;
|
||||||
Range.Min = _min;
|
Range.Min = _min;
|
||||||
|
@ -680,10 +741,13 @@ struct ImPlotAxis
|
||||||
if (!force && IsLockedMax())
|
if (!force && IsLockedMax())
|
||||||
return false;
|
return false;
|
||||||
_max = ImConstrainNan(ImConstrainInf(_max));
|
_max = ImConstrainNan(ImConstrainInf(_max));
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
if (_max > ConstraintRange.Max)
|
||||||
_max = ImConstrainLog(_max);
|
_max = ConstraintRange.Max;
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
double z = _max - Range.Min;
|
||||||
_max = ImConstrainTime(_max);
|
if (z < ConstraintZoom.Min)
|
||||||
|
_max = Range.Min + ConstraintZoom.Min;
|
||||||
|
if (z > ConstraintZoom.Max)
|
||||||
|
_max = Range.Min + ConstraintZoom.Max;
|
||||||
if (_max <= Range.Min)
|
if (_max <= Range.Min)
|
||||||
return false;
|
return false;
|
||||||
Range.Max = _max;
|
Range.Max = _max;
|
||||||
|
@ -707,7 +771,7 @@ struct ImPlotAxis
|
||||||
|
|
||||||
inline void SetAspect(double unit_per_pix) {
|
inline void SetAspect(double unit_per_pix) {
|
||||||
double new_size = unit_per_pix * PixelSize();
|
double new_size = unit_per_pix * PixelSize();
|
||||||
double delta = (new_size - Range.Size()) * 0.5f;
|
double delta = (new_size - Range.Size()) * 0.5;
|
||||||
if (IsLocked())
|
if (IsLocked())
|
||||||
return;
|
return;
|
||||||
else if (IsLockedMin() && !IsLockedMax())
|
else if (IsLockedMin() && !IsLockedMax())
|
||||||
|
@ -725,43 +789,59 @@ struct ImPlotAxis
|
||||||
inline void Constrain() {
|
inline void Constrain() {
|
||||||
Range.Min = ImConstrainNan(ImConstrainInf(Range.Min));
|
Range.Min = ImConstrainNan(ImConstrainInf(Range.Min));
|
||||||
Range.Max = ImConstrainNan(ImConstrainInf(Range.Max));
|
Range.Max = ImConstrainNan(ImConstrainInf(Range.Max));
|
||||||
if (IsLog()) {
|
if (Range.Min < ConstraintRange.Min)
|
||||||
Range.Min = ImConstrainLog(Range.Min);
|
Range.Min = ConstraintRange.Min;
|
||||||
Range.Max = ImConstrainLog(Range.Max);
|
if (Range.Max > ConstraintRange.Max)
|
||||||
|
Range.Max = ConstraintRange.Max;
|
||||||
|
double z = Range.Size();
|
||||||
|
if (z < ConstraintZoom.Min) {
|
||||||
|
double delta = (ConstraintZoom.Min - z) * 0.5;
|
||||||
|
Range.Min -= delta;
|
||||||
|
Range.Max += delta;
|
||||||
}
|
}
|
||||||
if (IsTime()) {
|
if (z > ConstraintZoom.Max) {
|
||||||
Range.Min = ImConstrainTime(Range.Min);
|
double delta = (z - ConstraintZoom.Max) * 0.5;
|
||||||
Range.Max = ImConstrainTime(Range.Max);
|
Range.Min += delta;
|
||||||
|
Range.Max -= delta;
|
||||||
}
|
}
|
||||||
if (Range.Max <= Range.Min)
|
if (Range.Max <= Range.Min)
|
||||||
Range.Max = Range.Min + DBL_EPSILON;
|
Range.Max = Range.Min + DBL_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void UpdateTransformCache() {
|
inline void UpdateTransformCache() {
|
||||||
LinM = (PixelMax - PixelMin) / Range.Size();
|
ScaleToPixel = (PixelMax - PixelMin) / Range.Size();
|
||||||
LogD = IsLog() ? ImLog10(Range.Max / Range.Min) : 0;
|
if (TransformForward != NULL) {
|
||||||
|
ScaleMin = TransformForward(Range.Min, TransformData);
|
||||||
|
ScaleMax = TransformForward(Range.Max, TransformData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ScaleMin = Range.Min;
|
||||||
|
ScaleMax = Range.Max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline float PlotToPixels(double plt) const {
|
||||||
|
if (TransformForward != NULL) {
|
||||||
|
double s = TransformForward(plt, TransformData);
|
||||||
|
double t = (s - ScaleMin) / (ScaleMax - ScaleMin);
|
||||||
|
plt = Range.Min + Range.Size() * t;
|
||||||
|
}
|
||||||
|
return (float)(PixelMin + ScaleToPixel * (plt - Range.Min));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double PixelsToPlot(float pix) const {
|
inline double PixelsToPlot(float pix) const {
|
||||||
double plt = (pix - PixelMin) / LinM + Range.Min;
|
double plt = (pix - PixelMin) / ScaleToPixel + Range.Min;
|
||||||
if (IsLog()) {
|
if (TransformInverse != NULL) {
|
||||||
double t = (plt - Range.Min) / Range.Size();
|
double t = (plt - Range.Min) / Range.Size();
|
||||||
plt = ImPow(10, t * LogD) * Range.Min;
|
double s = t * (ScaleMax - ScaleMin) + ScaleMin;
|
||||||
|
plt = TransformInverse(s, TransformData);
|
||||||
}
|
}
|
||||||
return plt;
|
return plt;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float PlotToPixels(double plt) const {
|
|
||||||
if (IsLog()) {
|
|
||||||
plt = plt <= 0.0 ? IMPLOT_LOG_ZERO : plt;
|
|
||||||
double t = ImLog10(plt / Range.Min) / LogD;
|
|
||||||
plt = ImLerp(Range.Min, Range.Max, (float)t);
|
|
||||||
}
|
|
||||||
return (float)(PixelMin + LinM * (plt - Range.Min));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ExtendFit(double v) {
|
inline void ExtendFit(double v) {
|
||||||
if (!ImNanOrInf(v) && !(IsLog() && v <= 0)) {
|
if (!ImNanOrInf(v) && v >= ConstraintRange.Min && v <= ConstraintRange.Max) {
|
||||||
FitExtents.Min = v < FitExtents.Min ? v : FitExtents.Min;
|
FitExtents.Min = v < FitExtents.Min ? v : FitExtents.Min;
|
||||||
FitExtents.Max = v > FitExtents.Max ? v : FitExtents.Max;
|
FitExtents.Max = v > FitExtents.Max ? v : FitExtents.Max;
|
||||||
}
|
}
|
||||||
|
@ -770,7 +850,7 @@ struct ImPlotAxis
|
||||||
inline void ExtendFitWith(ImPlotAxis& alt, double v, double v_alt) {
|
inline void ExtendFitWith(ImPlotAxis& alt, double v, double v_alt) {
|
||||||
if (ImHasFlag(Flags, ImPlotAxisFlags_RangeFit) && !alt.Range.Contains(v_alt))
|
if (ImHasFlag(Flags, ImPlotAxisFlags_RangeFit) && !alt.Range.Contains(v_alt))
|
||||||
return;
|
return;
|
||||||
if (!ImNanOrInf(v) && !(IsLog() && v <= 0)) {
|
if (!ImNanOrInf(v) && v >= ConstraintRange.Min && v <= ConstraintRange.Max) {
|
||||||
FitExtents.Min = v < FitExtents.Min ? v : FitExtents.Min;
|
FitExtents.Min = v < FitExtents.Min ? v : FitExtents.Min;
|
||||||
FitExtents.Max = v > FitExtents.Max ? v : FitExtents.Max;
|
FitExtents.Max = v > FitExtents.Max ? v : FitExtents.Max;
|
||||||
}
|
}
|
||||||
|
@ -802,17 +882,29 @@ struct ImPlotAxis
|
||||||
inline bool IsForeground() const { return ImHasFlag(Flags, ImPlotAxisFlags_Foreground); }
|
inline bool IsForeground() const { return ImHasFlag(Flags, ImPlotAxisFlags_Foreground); }
|
||||||
inline bool IsAutoFitting() const { return ImHasFlag(Flags, ImPlotAxisFlags_AutoFit); }
|
inline bool IsAutoFitting() const { return ImHasFlag(Flags, ImPlotAxisFlags_AutoFit); }
|
||||||
inline bool CanInitFit() const { return !ImHasFlag(Flags, ImPlotAxisFlags_NoInitialFit) && !HasRange && !LinkedMin && !LinkedMax; }
|
inline bool CanInitFit() const { return !ImHasFlag(Flags, ImPlotAxisFlags_NoInitialFit) && !HasRange && !LinkedMin && !LinkedMax; }
|
||||||
inline bool IsRangeLocked() const { return HasRange && RangeCond == ImPlotCond_Always; }
|
inline bool IsRangeLocked() const { return HasRange && RangeCond == ImPlotCond_Always; }
|
||||||
inline bool IsLockedMin() const { return !Enabled || IsRangeLocked() || ImHasFlag(Flags, ImPlotAxisFlags_LockMin); }
|
inline bool IsLockedMin() const { return !Enabled || IsRangeLocked() || ImHasFlag(Flags, ImPlotAxisFlags_LockMin); }
|
||||||
inline bool IsLockedMax() const { return !Enabled || IsRangeLocked() || ImHasFlag(Flags, ImPlotAxisFlags_LockMax); }
|
inline bool IsLockedMax() const { return !Enabled || IsRangeLocked() || ImHasFlag(Flags, ImPlotAxisFlags_LockMax); }
|
||||||
inline bool IsLocked() const { return IsLockedMin() && IsLockedMax(); }
|
inline bool IsLocked() const { return IsLockedMin() && IsLockedMax(); }
|
||||||
inline bool IsInputLockedMin() const { return IsLockedMin() || IsAutoFitting(); }
|
inline bool IsInputLockedMin() const { return IsLockedMin() || IsAutoFitting(); }
|
||||||
inline bool IsInputLockedMax() const { return IsLockedMax() || IsAutoFitting(); }
|
inline bool IsInputLockedMax() const { return IsLockedMax() || IsAutoFitting(); }
|
||||||
inline bool IsInputLocked() const { return IsLocked() || IsAutoFitting(); }
|
inline bool IsInputLocked() const { return IsLocked() || IsAutoFitting(); }
|
||||||
inline bool IsTime() const { return ImHasFlag(Flags, ImPlotAxisFlags_Time); }
|
|
||||||
inline bool IsLog() const { return ImHasFlag(Flags, ImPlotAxisFlags_LogScale); }
|
|
||||||
inline bool HasMenus() const { return !ImHasFlag(Flags, ImPlotAxisFlags_NoMenus); }
|
inline bool HasMenus() const { return !ImHasFlag(Flags, ImPlotAxisFlags_NoMenus); }
|
||||||
|
|
||||||
|
inline bool IsPanLocked(bool increasing) {
|
||||||
|
if (ImHasFlag(Flags, ImPlotAxisFlags_PanStretch)) {
|
||||||
|
return IsInputLocked();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (IsLockedMin() || IsLockedMax() || IsAutoFitting())
|
||||||
|
return false;
|
||||||
|
if (increasing)
|
||||||
|
return Range.Max == ConstraintRange.Max;
|
||||||
|
else
|
||||||
|
return Range.Min == ConstraintRange.Min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PushLinks() {
|
void PushLinks() {
|
||||||
if (LinkedMin) { *LinkedMin = Range.Min; }
|
if (LinkedMin) { *LinkedMin = Range.Min; }
|
||||||
if (LinkedMax) { *LinkedMax = Range.Max; }
|
if (LinkedMax) { *LinkedMax = Range.Max; }
|
||||||
|
@ -860,6 +952,7 @@ struct ImPlotItem
|
||||||
|
|
||||||
ImPlotItem() {
|
ImPlotItem() {
|
||||||
ID = 0;
|
ID = 0;
|
||||||
|
Color = IM_COL32_WHITE;
|
||||||
NameOffset = -1;
|
NameOffset = -1;
|
||||||
Show = true;
|
Show = true;
|
||||||
SeenThisFrame = false;
|
SeenThisFrame = false;
|
||||||
|
@ -887,7 +980,7 @@ struct ImPlotLegend
|
||||||
Flags = PreviousFlags = ImPlotLegendFlags_None;
|
Flags = PreviousFlags = ImPlotLegendFlags_None;
|
||||||
CanGoInside = true;
|
CanGoInside = true;
|
||||||
Hovered = Held = false;
|
Hovered = Held = false;
|
||||||
Location = ImPlotLocation_NorthWest;
|
Location = PreviousLocation = ImPlotLocation_NorthWest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset() { Indices.shrink(0); Labels.Buf.shrink(0); }
|
void Reset() { Indices.shrink(0); Labels.Buf.shrink(0); }
|
||||||
|
@ -901,7 +994,7 @@ struct ImPlotItemGroup
|
||||||
ImPool<ImPlotItem> ItemPool;
|
ImPool<ImPlotItem> ItemPool;
|
||||||
int ColormapIdx;
|
int ColormapIdx;
|
||||||
|
|
||||||
ImPlotItemGroup() { ColormapIdx = 0; }
|
ImPlotItemGroup() { ID = 0; ColormapIdx = 0; }
|
||||||
|
|
||||||
int GetItemCount() const { return ItemPool.GetBufSize(); }
|
int GetItemCount() const { return ItemPool.GetBufSize(); }
|
||||||
ImGuiID GetItemID(const char* label_id) { return ImGui::GetID(label_id); /* GetIDWithSeed */ }
|
ImGuiID GetItemID(const char* label_id) { return ImGui::GetID(label_id); /* GetIDWithSeed */ }
|
||||||
|
@ -1021,7 +1114,7 @@ struct ImPlotPlot
|
||||||
inline const char* GetAxisLabel(const ImPlotAxis& axis) const { return TextBuffer.Buf.Data + axis.LabelOffset; }
|
inline const char* GetAxisLabel(const ImPlotAxis& axis) const { return TextBuffer.Buf.Data + axis.LabelOffset; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Holds subplot data that must persist afer EndSubplot
|
// Holds subplot data that must persist after EndSubplot
|
||||||
struct ImPlotSubplot {
|
struct ImPlotSubplot {
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImPlotSubplotFlags Flags;
|
ImPlotSubplotFlags Flags;
|
||||||
|
@ -1044,12 +1137,16 @@ struct ImPlotSubplot {
|
||||||
bool HasTitle;
|
bool HasTitle;
|
||||||
|
|
||||||
ImPlotSubplot() {
|
ImPlotSubplot() {
|
||||||
Rows = Cols = CurrentIdx = 0;
|
ID = 0;
|
||||||
FrameHovered = false;
|
Flags = PreviousFlags = ImPlotSubplotFlags_None;
|
||||||
Items.Legend.Location = ImPlotLocation_North;
|
Rows = Cols = CurrentIdx = 0;
|
||||||
Items.Legend.Flags = ImPlotLegendFlags_Horizontal|ImPlotLegendFlags_Outside;
|
FrameHovered = false;
|
||||||
Items.Legend.CanGoInside = false;
|
Items.Legend.Location = ImPlotLocation_North;
|
||||||
HasTitle = false;
|
Items.Legend.Flags = ImPlotLegendFlags_Horizontal|ImPlotLegendFlags_Outside;
|
||||||
|
Items.Legend.CanGoInside = false;
|
||||||
|
TempSizes[0] = TempSizes[1] = 0;
|
||||||
|
FrameHovered = false;
|
||||||
|
HasTitle = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1077,23 +1174,23 @@ struct ImPlotNextPlotData
|
||||||
|
|
||||||
// Temporary data storage for upcoming item
|
// Temporary data storage for upcoming item
|
||||||
struct ImPlotNextItemData {
|
struct ImPlotNextItemData {
|
||||||
ImVec4 Colors[5]; // ImPlotCol_Line, ImPlotCol_Fill, ImPlotCol_MarkerOutline, ImPlotCol_MarkerFill, ImPlotCol_ErrorBar
|
ImVec4 Colors[5]; // ImPlotCol_Line, ImPlotCol_Fill, ImPlotCol_MarkerOutline, ImPlotCol_MarkerFill, ImPlotCol_ErrorBar
|
||||||
float LineWeight;
|
float LineWeight;
|
||||||
ImPlotMarker Marker;
|
ImPlotMarker Marker;
|
||||||
float MarkerSize;
|
float MarkerSize;
|
||||||
float MarkerWeight;
|
float MarkerWeight;
|
||||||
float FillAlpha;
|
float FillAlpha;
|
||||||
float ErrorBarSize;
|
float ErrorBarSize;
|
||||||
float ErrorBarWeight;
|
float ErrorBarWeight;
|
||||||
float DigitalBitHeight;
|
float DigitalBitHeight;
|
||||||
float DigitalBitGap;
|
float DigitalBitGap;
|
||||||
bool RenderLine;
|
bool RenderLine;
|
||||||
bool RenderFill;
|
bool RenderFill;
|
||||||
bool RenderMarkerLine;
|
bool RenderMarkerLine;
|
||||||
bool RenderMarkerFill;
|
bool RenderMarkerFill;
|
||||||
bool HasHidden;
|
bool HasHidden;
|
||||||
bool Hidden;
|
bool Hidden;
|
||||||
ImPlotCond HiddenCond;
|
ImPlotCond HiddenCond;
|
||||||
ImPlotNextItemData() { Reset(); }
|
ImPlotNextItemData() { Reset(); }
|
||||||
void Reset() {
|
void Reset() {
|
||||||
for (int i = 0; i < 5; ++i)
|
for (int i = 0; i < 5; ++i)
|
||||||
|
@ -1116,7 +1213,7 @@ struct ImPlotContext {
|
||||||
ImPlotItem* PreviousItem;
|
ImPlotItem* PreviousItem;
|
||||||
|
|
||||||
// Tick Marks and Labels
|
// Tick Marks and Labels
|
||||||
ImPlotTickCollection CTicks;
|
ImPlotTicker CTicker;
|
||||||
|
|
||||||
// Annotation and Tabs
|
// Annotation and Tabs
|
||||||
ImPlotAnnotationCollection Annotations;
|
ImPlotAnnotationCollection Annotations;
|
||||||
|
@ -1147,6 +1244,7 @@ struct ImPlotContext {
|
||||||
ImPlotInputMap InputMap;
|
ImPlotInputMap InputMap;
|
||||||
bool OpenContextThisFrame;
|
bool OpenContextThisFrame;
|
||||||
ImGuiTextBuffer MousePosStringBuilder;
|
ImGuiTextBuffer MousePosStringBuilder;
|
||||||
|
ImPlotItemGroup* SortItems;
|
||||||
|
|
||||||
// Align plots
|
// Align plots
|
||||||
ImPool<ImPlotAlignmentData> AlignmentData;
|
ImPool<ImPlotAlignmentData> AlignmentData;
|
||||||
|
@ -1214,12 +1312,25 @@ IMPLOT_API void ShowSubplotsContextMenu(ImPlotSubplot& subplot);
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Begins a new item. Returns false if the item should not be plotted. Pushes PlotClipRect.
|
// Begins a new item. Returns false if the item should not be plotted. Pushes PlotClipRect.
|
||||||
IMPLOT_API bool BeginItem(const char* label_id, ImPlotCol recolor_from = -1);
|
IMPLOT_API bool BeginItem(const char* label_id, ImPlotItemFlags flags=0, ImPlotCol recolor_from=IMPLOT_AUTO);
|
||||||
|
|
||||||
|
// Same as above but with fitting functionality.
|
||||||
|
template <typename _Fitter>
|
||||||
|
bool BeginItemEx(const char* label_id, const _Fitter& fitter, ImPlotItemFlags flags=0, ImPlotCol recolor_from=IMPLOT_AUTO) {
|
||||||
|
if (BeginItem(label_id, flags, recolor_from)) {
|
||||||
|
ImPlotPlot& plot = *GetCurrentPlot();
|
||||||
|
if (plot.FitThisFrame && !ImHasFlag(flags, ImPlotItemFlags_NoFit))
|
||||||
|
fitter.Fit(plot.Axes[plot.CurrentX], plot.Axes[plot.CurrentY]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Ends an item (call only if BeginItem returns true). Pops PlotClipRect.
|
// Ends an item (call only if BeginItem returns true). Pops PlotClipRect.
|
||||||
IMPLOT_API void EndItem();
|
IMPLOT_API void EndItem();
|
||||||
|
|
||||||
// Register or get an existing item from the current plot.
|
// Register or get an existing item from the current plot.
|
||||||
IMPLOT_API ImPlotItem* RegisterOrGetItem(const char* label_id, bool* just_created = NULL);
|
IMPLOT_API ImPlotItem* RegisterOrGetItem(const char* label_id, ImPlotItemFlags flags, bool* just_created = NULL);
|
||||||
// Get a plot item from the current plot.
|
// Get a plot item from the current plot.
|
||||||
IMPLOT_API ImPlotItem* GetItem(const char* label_id);
|
IMPLOT_API ImPlotItem* GetItem(const char* label_id);
|
||||||
// Gets the current item.
|
// Gets the current item.
|
||||||
|
@ -1265,21 +1376,6 @@ static inline bool AnyAxesHovered(ImPlotAxis* axes, int count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the XY scale for the current plot and y-axis (TODO)
|
|
||||||
static inline ImPlotScale GetCurrentScale() {
|
|
||||||
ImPlotPlot& plot = *GetCurrentPlot();
|
|
||||||
ImPlotAxis& x = plot.Axes[plot.CurrentX];
|
|
||||||
ImPlotAxis& y = plot.Axes[plot.CurrentY];
|
|
||||||
if (!x.IsLog() && !y.IsLog())
|
|
||||||
return ImPlotScale_LinLin;
|
|
||||||
else if (x.IsLog() && !y.IsLog())
|
|
||||||
return ImPlotScale_LogLin;
|
|
||||||
else if (!x.IsLog() && y.IsLog())
|
|
||||||
return ImPlotScale_LinLog;
|
|
||||||
else
|
|
||||||
return ImPlotScale_LogLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the user has requested data to be fit.
|
// Returns true if the user has requested data to be fit.
|
||||||
static inline bool FitThisFrame() {
|
static inline bool FitThisFrame() {
|
||||||
return GImPlot->CurrentPlot->FitThisFrame;
|
return GImPlot->CurrentPlot->FitThisFrame;
|
||||||
|
@ -1331,21 +1427,9 @@ IMPLOT_API void ShowAltLegend(const char* title_id, bool vertical = true, const
|
||||||
IMPLOT_API bool ShowLegendContextMenu(ImPlotLegend& legend, bool visible);
|
IMPLOT_API bool ShowLegendContextMenu(ImPlotLegend& legend, bool visible);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Tick Utils
|
// [SECTION] Label Utils
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Label a tick with time formatting.
|
|
||||||
IMPLOT_API void LabelTickTime(ImPlotTick& tick, ImGuiTextBuffer& buffer, const ImPlotTime& t, ImPlotDateTimeFmt fmt);
|
|
||||||
|
|
||||||
// Populates a list of ImPlotTicks with normal spaced and formatted ticks
|
|
||||||
IMPLOT_API void AddTicksDefault(const ImPlotRange& range, float pix, bool vertical, ImPlotTickCollection& ticks, ImPlotFormatter formatter, void* data);
|
|
||||||
// Populates a list of ImPlotTicks with logarithmic space and formatted ticks
|
|
||||||
IMPLOT_API void AddTicksLogarithmic(const ImPlotRange& range, float pix, bool vertical, ImPlotTickCollection& ticks, ImPlotFormatter formatter, void* data);
|
|
||||||
// Populates a list of ImPlotTicks with custom spaced and labeled ticks
|
|
||||||
IMPLOT_API void AddTicksCustom(const double* values, const char* const labels[], int n, ImPlotTickCollection& ticks, ImPlotFormatter formatter, void* data);
|
|
||||||
// Populates a list of ImPlotTicks with time formatted ticks.
|
|
||||||
IMPLOT_API void AddTicksTime(const ImPlotRange& range, float plot_width, ImPlotTickCollection& ticks);
|
|
||||||
|
|
||||||
// Create a a string label for a an axis value
|
// Create a a string label for a an axis value
|
||||||
IMPLOT_API void LabelAxisValue(const ImPlotAxis& axis, double value, char* buff, int size, bool round = false);
|
IMPLOT_API void LabelAxisValue(const ImPlotAxis& axis, double value, char* buff, int size, bool round = false);
|
||||||
|
|
||||||
|
@ -1503,7 +1587,7 @@ IMPLOT_API int FormatTime(const ImPlotTime& t, char* buffer, int size, ImPlotTim
|
||||||
// Formats the date part of timestamp t into a buffer according to #fmt
|
// Formats the date part of timestamp t into a buffer according to #fmt
|
||||||
IMPLOT_API int FormatDate(const ImPlotTime& t, char* buffer, int size, ImPlotDateFmt fmt, bool use_iso_8601);
|
IMPLOT_API int FormatDate(const ImPlotTime& t, char* buffer, int size, ImPlotDateFmt fmt, bool use_iso_8601);
|
||||||
// Formats the time and/or date parts of a timestamp t into a buffer according to #fmt
|
// Formats the time and/or date parts of a timestamp t into a buffer according to #fmt
|
||||||
IMPLOT_API int FormatDateTime(const ImPlotTime& t, char* buffer, int size, ImPlotDateTimeFmt fmt);
|
IMPLOT_API int FormatDateTime(const ImPlotTime& t, char* buffer, int size, ImPlotDateTimeSpec fmt);
|
||||||
|
|
||||||
// Shows a date picker widget block (year/month/day).
|
// Shows a date picker widget block (year/month/day).
|
||||||
// #level = 0 for day, 1 for month, 2 for year. Modified by user interaction.
|
// #level = 0 for day, 1 for month, 2 for year. Modified by user interaction.
|
||||||
|
@ -1514,4 +1598,73 @@ IMPLOT_API bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const
|
||||||
// #t will be set when a new hour, minute, or sec is selected or am/pm is toggled, and the function will return true.
|
// #t will be set when a new hour, minute, or sec is selected or am/pm is toggled, and the function will return true.
|
||||||
IMPLOT_API bool ShowTimePicker(const char* id, ImPlotTime* t);
|
IMPLOT_API bool ShowTimePicker(const char* id, ImPlotTime* t);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Transforms
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static inline double TransformForward_Log10(double v, void*) {
|
||||||
|
v = v <= 0.0 ? DBL_MIN : v;
|
||||||
|
return ImLog10(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double TransformInverse_Log10(double v, void*) {
|
||||||
|
return ImPow(10, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double TransformForward_SymLog(double v, void*) {
|
||||||
|
return 2.0 * ImAsinh(v / 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double TransformInverse_SymLog(double v, void*) {
|
||||||
|
return 2.0 * ImSinh(v / 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double TransformForward_Logit(double v, void*) {
|
||||||
|
v = ImClamp(v, DBL_MIN, 1.0 - DBL_EPSILON);
|
||||||
|
return ImLog10(v / (1 - v));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double TransformInverse_Logit(double v, void*) {
|
||||||
|
return 1.0 / (1.0 + ImPow(10,-v));
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Formatters
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static inline int Formatter_Default(double value, char* buff, int size, void* data) {
|
||||||
|
char* fmt = (char*)data;
|
||||||
|
return ImFormatString(buff, size, fmt, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int Formatter_Logit(double value, char* buff, int size, void*) {
|
||||||
|
if (value == 0.5)
|
||||||
|
return ImFormatString(buff,size,"1/2");
|
||||||
|
else if (value < 0.5)
|
||||||
|
return ImFormatString(buff,size,"%g", value);
|
||||||
|
else
|
||||||
|
return ImFormatString(buff,size,"1 - %g", 1 - value);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Formatter_Time_Data {
|
||||||
|
ImPlotTime Time;
|
||||||
|
ImPlotDateTimeSpec Spec;
|
||||||
|
ImPlotFormatter UserFormatter;
|
||||||
|
void* UserFormatterData;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline int Formatter_Time(double, char* buff, int size, void* data) {
|
||||||
|
Formatter_Time_Data* ftd = (Formatter_Time_Data*)data;
|
||||||
|
return FormatDateTime(ftd->Time, buff, size, ftd->Spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// [SECTION] Locator
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void Locator_Default(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
|
||||||
|
void Locator_Time(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
|
||||||
|
void Locator_Log10(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
|
||||||
|
void Locator_SymLog(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data);
|
||||||
|
|
||||||
} // namespace ImPlot
|
} // namespace ImPlot
|
||||||
|
|
2984
implot_items.cpp
2984
implot_items.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user