ui: Added ImPlot library
This commit is contained in:
parent
f1c03f8b1d
commit
f0b392575f
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@ -3,6 +3,7 @@
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/external/nativefiledialog" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/external/xdgpp" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/external/yara/yara" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
7
external/ImGui/CMakeLists.txt
vendored
7
external/ImGui/CMakeLists.txt
vendored
@ -19,10 +19,17 @@ add_library(imgui
|
||||
source/imgui_impl_opengl3.cpp
|
||||
source/imgui_tables.cpp
|
||||
source/imgui_widgets.cpp
|
||||
|
||||
source/TextEditor.cpp
|
||||
|
||||
source/imgui_imhex_extensions.cpp
|
||||
|
||||
source/imnodes.cpp
|
||||
|
||||
source/implot.cpp
|
||||
source/implot_items.cpp
|
||||
source/implot_demo.cpp
|
||||
|
||||
fonts/fontawesome_font.c
|
||||
)
|
||||
|
||||
|
688
external/ImGui/include/implot.h
vendored
Normal file
688
external/ImGui/include/implot.h
vendored
Normal file
@ -0,0 +1,688 @@
|
||||
// MIT License
|
||||
|
||||
// Copyright (c) 2020 Evan Pezent
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Macros and Defines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||
// Using ImPlot via a shared library is not recommended, because we don't guarantee
|
||||
// backward nor forward ABI compatibility and also function call overhead. If you
|
||||
// do use ImPlot as a DLL, be sure to call SetImGuiContext (details below).
|
||||
#ifndef IMPLOT_API
|
||||
#define IMPLOT_API
|
||||
#endif
|
||||
|
||||
// ImPlot version string
|
||||
#define IMPLOT_VERSION "0.8 WIP"
|
||||
// Indicates variable should deduced automatically.
|
||||
#define IMPLOT_AUTO -1
|
||||
// Special color used to indicate that a color should be deduced automatically.
|
||||
#define IMPLOT_AUTO_COL ImVec4(0,0,0,-1)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward Declarations and Basic Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Forward declarations
|
||||
struct ImPlotContext; // ImPlot context (opaque struct, see implot_internal.h)
|
||||
|
||||
// Enums/Flags
|
||||
typedef int ImPlotFlags; // -> enum ImPlotFlags_
|
||||
typedef int ImPlotAxisFlags; // -> enum ImPlotAxisFlags_
|
||||
typedef int ImPlotCol; // -> enum ImPlotCol_
|
||||
typedef int ImPlotStyleVar; // -> enum ImPlotStyleVar_
|
||||
typedef int ImPlotMarker; // -> enum ImPlotMarker_
|
||||
typedef int ImPlotColormap; // -> enum ImPlotColormap_
|
||||
typedef int ImPlotLocation; // -> enum ImPlotLocation_
|
||||
typedef int ImPlotOrientation; // -> enum ImPlotOrientation_
|
||||
typedef int ImPlotYAxis; // -> enum ImPlotYAxis_;
|
||||
|
||||
// Options for plots.
|
||||
enum ImPlotFlags_ {
|
||||
ImPlotFlags_None = 0, // default
|
||||
ImPlotFlags_NoLegend = 1 << 0, // the top-left legend will not be displayed
|
||||
ImPlotFlags_NoMenus = 1 << 1, // the user will not be able to open context menus with double-right click
|
||||
ImPlotFlags_NoBoxSelect = 1 << 2, // the user will not be able to box-select with right-mouse
|
||||
ImPlotFlags_NoMousePos = 1 << 3, // the mouse position, in plot coordinates, will not be displayed inside of the plot
|
||||
ImPlotFlags_NoHighlight = 1 << 4, // plot items will not be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoChild = 1 << 5, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 6, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 7, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 8, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 9, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 10, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
};
|
||||
|
||||
// Options for plot axes (X and Y).
|
||||
enum ImPlotAxisFlags_ {
|
||||
ImPlotAxisFlags_None = 0, // default
|
||||
ImPlotAxisFlags_NoGridLines = 1 << 0, // no grid lines will be displayed
|
||||
ImPlotAxisFlags_NoTickMarks = 1 << 1, // no tick marks will be displayed
|
||||
ImPlotAxisFlags_NoTickLabels = 1 << 2, // no text labels will be displayed
|
||||
ImPlotAxisFlags_LogScale = 1 << 3, // a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
|
||||
ImPlotAxisFlags_Time = 1 << 4, // axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
|
||||
ImPlotAxisFlags_Invert = 1 << 5, // the axis will be inverted
|
||||
ImPlotAxisFlags_LockMin = 1 << 6, // the axis minimum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_LockMax = 1 << 7, // the axis maximum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_Lock = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax,
|
||||
ImPlotAxisFlags_NoDecorations = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels
|
||||
};
|
||||
|
||||
// Plot styling colors.
|
||||
enum ImPlotCol_ {
|
||||
// item styling colors
|
||||
ImPlotCol_Line, // plot line/outline color (defaults to next unused color in current colormap)
|
||||
ImPlotCol_Fill, // plot fill color for bars (defaults to the current line color)
|
||||
ImPlotCol_MarkerOutline, // marker outline color (defaults to the current line color)
|
||||
ImPlotCol_MarkerFill, // marker fill color (defaults to the current line color)
|
||||
ImPlotCol_ErrorBar, // error bar color (defaults to ImGuiCol_Text)
|
||||
// plot styling colors
|
||||
ImPlotCol_FrameBg, // plot frame background color (defaults to ImGuiCol_FrameBg)
|
||||
ImPlotCol_PlotBg, // plot area background color (defaults to ImGuiCol_WindowBg)
|
||||
ImPlotCol_PlotBorder, // plot area border color (defaults to ImGuiCol_Border)
|
||||
ImPlotCol_LegendBg, // legend background color (defaults to ImGuiCol_PopupBg)
|
||||
ImPlotCol_LegendBorder, // legend border color (defaults to ImPlotCol_PlotBorder)
|
||||
ImPlotCol_LegendText, // legend text color (defaults to ImPlotCol_InlayText)
|
||||
ImPlotCol_TitleText, // plot title text color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_InlayText, // color of text appearing inside of plots (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_XAxis, // x-axis label and tick lables color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_XAxisGrid, // x-axis grid color (defaults to 25% ImPlotCol_XAxis)
|
||||
ImPlotCol_YAxis, // y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_YAxisGrid, // y-axis grid color (defaults to 25% ImPlotCol_YAxis)
|
||||
ImPlotCol_YAxis2, // 2nd y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_YAxisGrid2, // 2nd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis2)
|
||||
ImPlotCol_YAxis3, // 3rd y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_YAxisGrid3, // 3rd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis3)
|
||||
ImPlotCol_Selection, // box-selection color (defaults to yellow)
|
||||
ImPlotCol_Query, // box-query color (defaults to green)
|
||||
ImPlotCol_Crosshairs, // crosshairs color (defaults to ImPlotCol_PlotBorder)
|
||||
ImPlotCol_COUNT
|
||||
};
|
||||
|
||||
// Plot styling variables.
|
||||
enum ImPlotStyleVar_ {
|
||||
// item styling variables
|
||||
ImPlotStyleVar_LineWeight, // float, plot item line weight in pixels
|
||||
ImPlotStyleVar_Marker, // int, marker specification
|
||||
ImPlotStyleVar_MarkerSize, // float, marker size in pixels (roughly the marker's "radius")
|
||||
ImPlotStyleVar_MarkerWeight, // float, plot outline weight of markers in pixels
|
||||
ImPlotStyleVar_FillAlpha, // float, alpha modifier applied to all plot item fills
|
||||
ImPlotStyleVar_ErrorBarSize, // float, error bar whisker width in pixels
|
||||
ImPlotStyleVar_ErrorBarWeight, // float, error bar whisker weight in pixels
|
||||
ImPlotStyleVar_DigitalBitHeight, // float, digital channels bit height (at 1) in pixels
|
||||
ImPlotStyleVar_DigitalBitGap, // float, digital channels bit padding gap in pixels
|
||||
// plot styling variables
|
||||
ImPlotStyleVar_PlotBorderSize, // float, thickness of border around plot area
|
||||
ImPlotStyleVar_MinorAlpha, // float, alpha multiplier applied to minor axis grid lines
|
||||
ImPlotStyleVar_MajorTickLen, // ImVec2, major tick lengths for X and Y axes
|
||||
ImPlotStyleVar_MinorTickLen, // ImVec2, minor tick lengths for X and Y axes
|
||||
ImPlotStyleVar_MajorTickSize, // ImVec2, line thickness of major ticks
|
||||
ImPlotStyleVar_MinorTickSize, // ImVec2, line thickness of minor ticks
|
||||
ImPlotStyleVar_MajorGridSize, // ImVec2, line thickness of major grid lines
|
||||
ImPlotStyleVar_MinorGridSize, // ImVec2, line thickness of minor grid lines
|
||||
ImPlotStyleVar_PlotPadding, // ImVec2, padding between widget frame and plot area, labels, or outside legends (i.e. main padding)
|
||||
ImPlotStyleVar_LabelPadding, // ImVec2, padding between axes labels, tick labels, and plot edge
|
||||
ImPlotStyleVar_LegendPadding, // ImVec2, legend padding from plot edges
|
||||
ImPlotStyleVar_LegendInnerPadding, // ImVec2, legend inner padding from legend edges
|
||||
ImPlotStyleVar_LegendSpacing, // ImVec2, spacing between legend entries
|
||||
ImPlotStyleVar_MousePosPadding, // ImVec2, padding between plot edge and interior info text
|
||||
ImPlotStyleVar_AnnotationPadding, // ImVec2, text padding around annotation labels
|
||||
ImPlotStyleVar_PlotDefaultSize, // ImVec2, default size used when ImVec2(0,0) is passed to BeginPlot
|
||||
ImPlotStyleVar_PlotMinSize, // ImVec2, minimum size plot frame can be when shrunk
|
||||
ImPlotStyleVar_COUNT
|
||||
};
|
||||
|
||||
// Marker specifications.
|
||||
enum ImPlotMarker_ {
|
||||
ImPlotMarker_None = -1, // no marker
|
||||
ImPlotMarker_Circle, // a circle marker
|
||||
ImPlotMarker_Square, // a square maker
|
||||
ImPlotMarker_Diamond, // a diamond marker
|
||||
ImPlotMarker_Up, // an upward-pointing triangle marker
|
||||
ImPlotMarker_Down, // an downward-pointing triangle marker
|
||||
ImPlotMarker_Left, // an leftward-pointing triangle marker
|
||||
ImPlotMarker_Right, // an rightward-pointing triangle marker
|
||||
ImPlotMarker_Cross, // a cross marker (not fillable)
|
||||
ImPlotMarker_Plus, // a plus marker (not fillable)
|
||||
ImPlotMarker_Asterisk, // a asterisk marker (not fillable)
|
||||
ImPlotMarker_COUNT
|
||||
};
|
||||
|
||||
// Built-in colormaps
|
||||
enum ImPlotColormap_ {
|
||||
ImPlotColormap_Default = 0, // ImPlot default colormap (n=10)
|
||||
ImPlotColormap_Deep = 1, // a.k.a. seaborn deep (n=10)
|
||||
ImPlotColormap_Dark = 2, // a.k.a. matplotlib "Set1" (n=9)
|
||||
ImPlotColormap_Pastel = 3, // a.k.a. matplotlib "Pastel1" (n=9)
|
||||
ImPlotColormap_Paired = 4, // a.k.a. matplotlib "Paired" (n=12)
|
||||
ImPlotColormap_Viridis = 5, // a.k.a. matplotlib "viridis" (n=11)
|
||||
ImPlotColormap_Plasma = 6, // a.k.a. matplotlib "plasma" (n=11)
|
||||
ImPlotColormap_Hot = 7, // a.k.a. matplotlib/MATLAB "hot" (n=11)
|
||||
ImPlotColormap_Cool = 8, // a.k.a. matplotlib/MATLAB "cool" (n=11)
|
||||
ImPlotColormap_Pink = 9, // a.k.a. matplotlib/MATLAB "pink" (n=11)
|
||||
ImPlotColormap_Jet = 10, // a.k.a. MATLAB "jet" (n=11)
|
||||
ImPlotColormap_COUNT
|
||||
};
|
||||
|
||||
// Used to position items on a plot (e.g. legends, labels, etc.)
|
||||
enum ImPlotLocation_ {
|
||||
ImPlotLocation_Center = 0, // center-center
|
||||
ImPlotLocation_North = 1 << 0, // top-center
|
||||
ImPlotLocation_South = 1 << 1, // bottom-center
|
||||
ImPlotLocation_West = 1 << 2, // center-left
|
||||
ImPlotLocation_East = 1 << 3, // center-right
|
||||
ImPlotLocation_NorthWest = ImPlotLocation_North | ImPlotLocation_West, // top-left
|
||||
ImPlotLocation_NorthEast = ImPlotLocation_North | ImPlotLocation_East, // top-right
|
||||
ImPlotLocation_SouthWest = ImPlotLocation_South | ImPlotLocation_West, // bottom-left
|
||||
ImPlotLocation_SouthEast = ImPlotLocation_South | ImPlotLocation_East // bottom-right
|
||||
};
|
||||
|
||||
// Used to orient items on a plot (e.g. legends, labels, etc.)
|
||||
enum ImPlotOrientation_ {
|
||||
ImPlotOrientation_Horizontal, // left/right
|
||||
ImPlotOrientation_Vertical // up/down
|
||||
};
|
||||
|
||||
// Enums for different y-axes.
|
||||
enum ImPlotYAxis_ {
|
||||
ImPlotYAxis_1 = 0, // left (default)
|
||||
ImPlotYAxis_2 = 1, // first on right side
|
||||
ImPlotYAxis_3 = 2 // second on right side
|
||||
};
|
||||
|
||||
// Double precision version of ImVec2 used by ImPlot. Extensible by end users.
|
||||
struct ImPlotPoint {
|
||||
double x, y;
|
||||
ImPlotPoint() { x = y = 0.0; }
|
||||
ImPlotPoint(double _x, double _y) { x = _x; y = _y; }
|
||||
ImPlotPoint(const ImVec2& p) { x = p.x; y = p.y; }
|
||||
double operator[] (size_t idx) const { return (&x)[idx]; }
|
||||
double& operator[] (size_t idx) { return (&x)[idx]; }
|
||||
#ifdef IMPLOT_POINT_CLASS_EXTRA
|
||||
IMPLOT_POINT_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h
|
||||
// to convert back and forth between your math types and ImPlotPoint.
|
||||
#endif
|
||||
};
|
||||
|
||||
// A range defined by a min/max value. Used for plot axes ranges.
|
||||
struct ImPlotRange {
|
||||
double Min, Max;
|
||||
ImPlotRange() { Min = 0; Max = 0; }
|
||||
ImPlotRange(double _min, double _max) { Min = _min; Max = _max; }
|
||||
bool Contains(double value) const { return value >= Min && value <= Max; };
|
||||
double Size() const { return Max - Min; };
|
||||
};
|
||||
|
||||
// Combination of two ranges for X and Y axes.
|
||||
struct ImPlotLimits {
|
||||
ImPlotRange X, Y;
|
||||
bool Contains(const ImPlotPoint& p) const { return Contains(p.x, p.y); }
|
||||
bool Contains(double x, double y) const { return X.Contains(x) && Y.Contains(y); }
|
||||
};
|
||||
|
||||
// Plot style structure
|
||||
struct ImPlotStyle {
|
||||
// item styling variables
|
||||
float LineWeight; // = 1, item line weight in pixels
|
||||
int Marker; // = ImPlotMarker_None, marker specification
|
||||
float MarkerSize; // = 4, marker size in pixels (roughly the marker's "radius")
|
||||
float MarkerWeight; // = 1, outline weight of markers in pixels
|
||||
float FillAlpha; // = 1, alpha modifier applied to plot fills
|
||||
float ErrorBarSize; // = 5, error bar whisker width in pixels
|
||||
float ErrorBarWeight; // = 1.5, error bar whisker weight in pixels
|
||||
float DigitalBitHeight; // = 8, digital channels bit height (at y = 1.0f) in pixels
|
||||
float DigitalBitGap; // = 4, digital channels bit padding gap in pixels
|
||||
// plot styling variables
|
||||
float PlotBorderSize; // = 1, line thickness of border around plot area
|
||||
float MinorAlpha; // = 0.25 alpha multiplier applied to minor axis grid lines
|
||||
ImVec2 MajorTickLen; // = 10,10 major tick lengths for X and Y axes
|
||||
ImVec2 MinorTickLen; // = 5,5 minor tick lengths for X and Y axes
|
||||
ImVec2 MajorTickSize; // = 1,1 line thickness of major ticks
|
||||
ImVec2 MinorTickSize; // = 1,1 line thickness of minor ticks
|
||||
ImVec2 MajorGridSize; // = 1,1 line thickness of major grid lines
|
||||
ImVec2 MinorGridSize; // = 1,1 line thickness of minor grid lines
|
||||
ImVec2 PlotPadding; // = 10,10 padding between widget frame and plot area, labels, or outside legends (i.e. main padding)
|
||||
ImVec2 LabelPadding; // = 5,5 padding between axes labels, tick labels, and plot edge
|
||||
ImVec2 LegendPadding; // = 10,10 legend padding from plot edges
|
||||
ImVec2 LegendInnerPadding; // = 5,5 legend inner padding from legend edges
|
||||
ImVec2 LegendSpacing; // = 0,0 spacing between legend entries
|
||||
ImVec2 MousePosPadding; // = 10,10 padding between plot edge and interior mouse location text
|
||||
ImVec2 AnnotationPadding; // = 2,2 text padding around annotation labels
|
||||
ImVec2 PlotDefaultSize; // = 400,300 default size used when ImVec2(0,0) is passed to BeginPlot
|
||||
ImVec2 PlotMinSize; // = 300,225 minimum size plot frame can be when shrunk
|
||||
// colors
|
||||
ImVec4 Colors[ImPlotCol_COUNT]; // array of plot specific colors
|
||||
// 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 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
|
||||
IMPLOT_API ImPlotStyle();
|
||||
};
|
||||
|
||||
// Input mapping structure, default values listed in the comments.
|
||||
struct ImPlotInputMap {
|
||||
ImGuiMouseButton PanButton; // LMB enables panning when held
|
||||
ImGuiKeyModFlags PanMod; // none optional modifier that must be held for panning
|
||||
ImGuiMouseButton FitButton; // LMB fits visible data when double clicked
|
||||
ImGuiMouseButton ContextMenuButton; // RMB opens plot context menu (if enabled) when double clicked
|
||||
ImGuiMouseButton BoxSelectButton; // RMB begins box selection when pressed and confirms selection when released
|
||||
ImGuiKeyModFlags BoxSelectMod; // none optional modifier that must be held for box selection
|
||||
ImGuiMouseButton BoxSelectCancelButton; // LMB cancels active box selection when pressed
|
||||
ImGuiMouseButton QueryButton; // MMB begins query selection when pressed and end query selection when released
|
||||
ImGuiKeyModFlags QueryMod; // none optional modifier that must be held for query selection
|
||||
ImGuiKeyModFlags QueryToggleMod; // Ctrl when held, active box selections turn into queries
|
||||
ImGuiKeyModFlags HorizontalMod; // Alt expands active box selection/query horizontally to plot edge when held
|
||||
ImGuiKeyModFlags VerticalMod; // Shift expands active box selection/query vertically to plot edge when held
|
||||
IMPLOT_API ImPlotInputMap();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImPlot End-User API
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace ImPlot {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImPlot Context
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Creates a new ImPlot context. Call this after ImGui::CreateContext.
|
||||
IMPLOT_API ImPlotContext* CreateContext();
|
||||
// Destroys an ImPlot context. Call this before ImGui::DestroyContext. NULL = destroy current context
|
||||
IMPLOT_API void DestroyContext(ImPlotContext* ctx = NULL);
|
||||
// Returns the current ImPlot context. NULL if no context has ben set.
|
||||
IMPLOT_API ImPlotContext* GetCurrentContext();
|
||||
// Sets the current ImPlot context.
|
||||
IMPLOT_API void SetCurrentContext(ImPlotContext* ctx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Begin/End Plot
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Starts a 2D plotting context. If this function returns true, EndPlot() must
|
||||
// be called, e.g. "if (BeginPlot(...)) { ... EndPlot(); }". #title_id must
|
||||
// be unique. If you need to avoid ID collisions or don't want to display a
|
||||
// title in the plot, use double hashes (e.g. "MyPlot##Hidden" or "##NoTitle").
|
||||
// If #x_label and/or #y_label are provided, axes labels will be displayed.
|
||||
IMPLOT_API bool BeginPlot(const char* title_id,
|
||||
const char* x_label = NULL,
|
||||
const char* y_label = NULL,
|
||||
const ImVec2& size = ImVec2(-1,0),
|
||||
ImPlotFlags flags = ImPlotFlags_None,
|
||||
ImPlotAxisFlags x_flags = ImPlotAxisFlags_None,
|
||||
ImPlotAxisFlags y_flags = ImPlotAxisFlags_None,
|
||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_NoGridLines,
|
||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_NoGridLines);
|
||||
|
||||
// Only call EndPlot() if BeginPlot() returns true! Typically called at the end
|
||||
// of an if statement conditioned on BeginPlot().
|
||||
IMPLOT_API void EndPlot();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot Items
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The template functions below are explicitly instantiated in implot_items.cpp.
|
||||
// They are not intended to be used generically with custom types. You will get
|
||||
// a linker error if you try! All functions support the following scalar types:
|
||||
//
|
||||
// float, double, ImS8, ImU8, ImS16, ImU16, ImS32, ImU32, ImS64, ImU64
|
||||
//
|
||||
//
|
||||
// If you need to plot custom or non-homogenous data you have a few options:
|
||||
//
|
||||
// 1. If your data is a simple struct/class (e.g. Vector2f), you can use striding.
|
||||
// This is the most performant option if applicable.
|
||||
//
|
||||
// struct Vector2f { float X, Y; };
|
||||
// ...
|
||||
// Vector2f data[42];
|
||||
// ImPlot::PlotLine("line", &data[0].x, &data[0].y, 42, 0, sizeof(Vector2f)); // or sizeof(float)*2
|
||||
//
|
||||
// 2. Write a custom getter function or C++ lambda and pass it and your data to
|
||||
// an ImPlot function post-fixed with a G (e.g. PlotScatterG). This has a
|
||||
// slight performance cost, but probably not enough to worry about.
|
||||
//
|
||||
// ImPlotPoint MyDataGetter(void* data, int idx) {
|
||||
// MyData* my_data = (MyData*)data;
|
||||
// ImPlotPoint p;
|
||||
// p.x = my_data->GetTime(idx);
|
||||
// p.y = my_data->GetValue(idx);
|
||||
// return p
|
||||
// }
|
||||
// ...
|
||||
// MyData my_data;
|
||||
// ImPlot::PlotScatterG("scatter", MyDataGetter, &my_data, my_data.Size());
|
||||
//
|
||||
// NB: All types are converted to double before plotting. You may loose information
|
||||
// if you try plotting extremely large 64-bit integral types. Proceed with caution!
|
||||
|
||||
// Plots a standard 2D line plot.
|
||||
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotLineG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset=0);
|
||||
|
||||
// Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle.
|
||||
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotScatterG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset=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].
|
||||
template <typename T> IMPLOT_API void PlotStairs(const char* label_id, const T* values, int count, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotStairs(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotStairsG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset=0);
|
||||
|
||||
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference.
|
||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* values, int count, double y_ref=0, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotShadedG(const char* label_id, ImPlotPoint (*getter1)(void* data, int idx), void* data1, ImPlotPoint (*getter2)(void* data, int idx), void* data2, int count, int offset=0);
|
||||
|
||||
// Plots a vertical bar graph. #width and #shift are in X units.
|
||||
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* values, int count, double width=0.67, double shift=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double width, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotBarsG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double width, int offset=0);
|
||||
|
||||
// Plots a horizontal bar graph. #height and #shift are in Y units.
|
||||
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* values, int count, double height=0.67, double shift=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double height, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotBarsHG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double height, int offset=0);
|
||||
|
||||
// Plots vertical error bar. The label_id should be the same as the label_id of the associated line or bar plot.
|
||||
template <typename T> IMPLOT_API void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, 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.
|
||||
template <typename T> IMPLOT_API void PlotErrorBarsH(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void 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));
|
||||
|
||||
/// Plots vertical stems.
|
||||
template <typename T> IMPLOT_API void PlotStems(const char* label_id, const T* values, int count, double y_ref=0, double xscale=1, double x0=0, int offset=0, int stride=sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotStems(const char* label_id, const T* xs, const T* ys, int count, double y_ref=0, 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.
|
||||
template <typename T> IMPLOT_API 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);
|
||||
|
||||
// Plots a 2D heatmap chart. Values are expected to be in row-major order. #label_fmt can be set to NULL for no labels.
|
||||
template <typename T> IMPLOT_API void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min, double scale_max, const char* label_fmt="%.1f", const ImPlotPoint& bounds_min=ImPlotPoint(0,0), const ImPlotPoint& bounds_max=ImPlotPoint(1,1));
|
||||
|
||||
// Plots digital data. Digital plots do not respond to y drag or zoom, and are always referenced to the bottom of the plot.
|
||||
template <typename T> IMPLOT_API void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
|
||||
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset=0);
|
||||
|
||||
// Plots an axis-aligned image. #bounds_min/bounds_max are in plot coordinatse (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));
|
||||
|
||||
// Plots a centered text label at point x,y with 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));
|
||||
|
||||
// Plots an dummy item (i.e. adds a legend entry colored by ImPlotCol_Line)
|
||||
IMPLOT_API void PlotDummy(const char* label_id);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The following functions MUST be called before BeginPlot!
|
||||
|
||||
// Set the axes range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the axes limits will be locked.
|
||||
IMPLOT_API void SetNextPlotLimits(double xmin, double xmax, double ymin, double ymax, ImGuiCond cond = ImGuiCond_Once);
|
||||
// Set the X axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the X axis limits will be locked.
|
||||
IMPLOT_API void SetNextPlotLimitsX(double xmin, double xmax, ImGuiCond cond = ImGuiCond_Once);
|
||||
// Set the Y axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the Y axis limits will be locked.
|
||||
IMPLOT_API void SetNextPlotLimitsY(double ymin, double ymax, ImGuiCond cond = ImGuiCond_Once, ImPlotYAxis y_axis = 0);
|
||||
// Links the next plot limits to external values. Set to NULL for no linkage. The pointer data must remain valid until the matching call EndPlot.
|
||||
IMPLOT_API void LinkNextPlotLimits(double* xmin, double* xmax, double* ymin, double* ymax, double* ymin2 = NULL, double* ymax2 = NULL, double* ymin3 = NULL, double* ymax3 = NULL);
|
||||
// Fits the next plot axes to all plotted data if they are unlocked (equivalent to double-clicks).
|
||||
IMPLOT_API void FitNextPlotAxes(bool x = true, bool y = true, bool y2 = true, bool y3 = true);
|
||||
|
||||
// Set the X axis ticks and optionally the labels for the next plot.
|
||||
IMPLOT_API void SetNextPlotTicksX(const double* values, int n_ticks, const char* const labels[] = NULL, bool show_default = false);
|
||||
IMPLOT_API void SetNextPlotTicksX(double x_min, double x_max, int n_ticks, const char* const labels[] = NULL, bool show_default = false);
|
||||
|
||||
// Set the Y axis ticks and optionally the labels for the next plot.
|
||||
IMPLOT_API void SetNextPlotTicksY(const double* values, int n_ticks, const char* const labels[] = NULL, bool show_default = false, ImPlotYAxis y_axis = 0);
|
||||
IMPLOT_API void SetNextPlotTicksY(double y_min, double y_max, int n_ticks, const char* const labels[] = NULL, bool show_default = false, ImPlotYAxis y_axis = 0);
|
||||
|
||||
// The following functions MUST be called between Begin/EndPlot!
|
||||
|
||||
// Select which Y axis will be used for subsequent plot elements. The default is ImPlotYAxis_1, or the first (left) Y axis. Enable 2nd and 3rd axes with ImPlotFlags_YAxisX.
|
||||
IMPLOT_API void SetPlotYAxis(ImPlotYAxis y_axis);
|
||||
// Hides or shows the next plot item (i.e. as if it were toggled from the legend). Use ImGuiCond_Always if you need to forcefully set this every frame.
|
||||
IMPLOT_API void HideNextItem(bool hidden = true, ImGuiCond cond = ImGuiCond_Once);
|
||||
|
||||
// Convert pixels to a position in the current plot's coordinate system. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
||||
IMPLOT_API ImPlotPoint PixelsToPlot(const ImVec2& pix, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
IMPLOT_API ImPlotPoint PixelsToPlot(float x, float y, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
// Convert a position in the current plot's coordinate system to pixels. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
||||
IMPLOT_API ImVec2 PlotToPixels(const ImPlotPoint& plt, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
IMPLOT_API ImVec2 PlotToPixels(double x, double y, ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
// Get the current Plot position (top-left) in pixels.
|
||||
IMPLOT_API ImVec2 GetPlotPos();
|
||||
// Get the curent Plot size in pixels.
|
||||
IMPLOT_API ImVec2 GetPlotSize();
|
||||
// Returns true if the plot area in the current plot is hovered.
|
||||
IMPLOT_API bool IsPlotHovered();
|
||||
// Returns true if the XAxis plot area in the current plot is hovered.
|
||||
IMPLOT_API bool IsPlotXAxisHovered();
|
||||
// Returns true if the YAxis[n] plot area in the current plot is hovered.
|
||||
IMPLOT_API bool IsPlotYAxisHovered(ImPlotYAxis y_axis = 0);
|
||||
// Returns the mouse position in x,y coordinates of the current plot. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
||||
IMPLOT_API ImPlotPoint GetPlotMousePos(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
// Returns the current plot axis range. A negative y_axis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
|
||||
IMPLOT_API ImPlotLimits GetPlotLimits(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
|
||||
// Returns true if the current plot is being queried. Query must be enabled with ImPlotFlags_Query.
|
||||
IMPLOT_API bool IsPlotQueried();
|
||||
// Returns the current plot query bounds. Query must be enabled with ImPlotFlags_Query.
|
||||
IMPLOT_API ImPlotLimits GetPlotQuery(ImPlotYAxis y_axis = IMPLOT_AUTO);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot Tools
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The following functions MUST be called between Begin/EndPlot!
|
||||
|
||||
// Shows an annotation callout at a chosen point.
|
||||
IMPLOT_API void Annotate(double x, double y, const ImVec2& pix_offset, const char* fmt, ...) IM_FMTARGS(4);
|
||||
IMPLOT_API void Annotate(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(5);
|
||||
IMPLOT_API void AnnotateV(double x, double y, const ImVec2& pix_offset, const char* fmt, va_list args) IM_FMTLIST(4);
|
||||
IMPLOT_API void AnnotateV(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(5);
|
||||
|
||||
// Same as above, but the annotation will always be clamped to stay inside the plot area.
|
||||
IMPLOT_API void AnnotateClamped(double x, double y, const ImVec2& pix_offset, const char* fmt, ...) IM_FMTARGS(4);
|
||||
IMPLOT_API void AnnotateClamped(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, ...) IM_FMTARGS(5);
|
||||
IMPLOT_API void AnnotateClampedV(double x, double y, const ImVec2& pix_offset, const char* fmt, va_list args) IM_FMTLIST(4);
|
||||
IMPLOT_API void AnnotateClampedV(double x, double y, const ImVec2& pix_offset, const ImVec4& color, const char* fmt, va_list args) IM_FMTLIST(5);
|
||||
|
||||
// Shows a draggable vertical guide line at an x-value. #col defaults to ImGuiCol_Text.
|
||||
IMPLOT_API bool DragLineX(const char* id, double* x_value, bool show_label = true, const ImVec4& col = IMPLOT_AUTO_COL, float thickness = 1);
|
||||
// Shows a draggable horizontal guide line at a y-value. #col defaults to ImGuiCol_Text.
|
||||
IMPLOT_API bool DragLineY(const char* id, double* y_value, bool show_label = true, const ImVec4& col = IMPLOT_AUTO_COL, float thickness = 1);
|
||||
// Shows a draggable point at x,y. #col defaults to ImGuiCol_Text.
|
||||
IMPLOT_API bool DragPoint(const char* id, double* x, double* y, bool show_label = true, const ImVec4& col = IMPLOT_AUTO_COL, float radius = 4);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Legend Utils and Tools
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The following functions MUST be called between Begin/EndPlot!
|
||||
|
||||
// Set the location of the current plot's legend.
|
||||
IMPLOT_API void SetLegendLocation(ImPlotLocation location, ImPlotOrientation orientation = ImPlotOrientation_Vertical, bool outside = false);
|
||||
// Set the location of the current plot's mouse position text (default = South|East).
|
||||
IMPLOT_API void SetMousePosLocation(ImPlotLocation location);
|
||||
// Returns true if a plot item legend entry is hovered.
|
||||
IMPLOT_API bool IsLegendEntryHovered(const char* label_id);
|
||||
// Begin a drag and drop source from a legend entry. The only supported flag is SourceNoPreviewTooltip
|
||||
IMPLOT_API bool BeginLegendDragDropSource(const char* label_id, ImGuiDragDropFlags flags = 0);
|
||||
// End legend drag and drop source.
|
||||
IMPLOT_API void EndLegendDragDropSource();
|
||||
// Begin a popup for a legend entry.
|
||||
IMPLOT_API bool BeginLegendPopup(const char* label_id, ImGuiMouseButton mouse_button = 1);
|
||||
// End a popup for a legend entry.
|
||||
IMPLOT_API void EndLegendPopup();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot and Item Styling
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Provides access to plot style structure for permanant modifications to colors, sizes, etc.
|
||||
IMPLOT_API ImPlotStyle& GetStyle();
|
||||
|
||||
// Style colors for current ImGui style (default).
|
||||
IMPLOT_API void StyleColorsAuto(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Classic".
|
||||
IMPLOT_API void StyleColorsClassic(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Dark".
|
||||
IMPLOT_API void StyleColorsDark(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Light".
|
||||
IMPLOT_API void StyleColorsLight(ImPlotStyle* dst = NULL);
|
||||
|
||||
// Use PushStyleX to temporarily modify your ImPlotStyle. The modification
|
||||
// will last until the matching call to PopStyleX. You MUST call a pop for
|
||||
// every push, otherwise you will leak memory! This behaves just like ImGui.
|
||||
|
||||
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
||||
IMPLOT_API void PushStyleColor(ImPlotCol idx, ImU32 col);
|
||||
IMPLOT_API void PushStyleColor(ImPlotCol idx, const ImVec4& col);
|
||||
// Undo temporary color modification. Undo multiple pushes at once by increasing count.
|
||||
IMPLOT_API void PopStyleColor(int count = 1);
|
||||
|
||||
// Temporarily modify a style variable of float type. Don't forget to call PopStyleVar!
|
||||
IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, float val);
|
||||
// Temporarily modify a style variable of int type. Don't forget to call PopStyleVar!
|
||||
IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, int val);
|
||||
// Temporarily modify a style variable of ImVec2 type. Don't forget to call PopStyleVar!
|
||||
IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, const ImVec2& val);
|
||||
// Undo temporary style modification. Undo multiple pushes at once by increasing count.
|
||||
IMPLOT_API void PopStyleVar(int count = 1);
|
||||
|
||||
// The following can be used to modify the style of the next plot item ONLY. They do
|
||||
// NOT require calls to PopStyleX. Leave style attributes you don't want modified to
|
||||
// IMPLOT_AUTO or IMPLOT_AUTO_COL. Automatic styles will be deduced from the current
|
||||
// values in your ImPlotStyle or from Colormap data.
|
||||
|
||||
// Set the line color and weight for the next item only.
|
||||
IMPLOT_API void SetNextLineStyle(const ImVec4& col = IMPLOT_AUTO_COL, float weight = IMPLOT_AUTO);
|
||||
// Set the fill color for the next item only.
|
||||
IMPLOT_API void SetNextFillStyle(const ImVec4& col = IMPLOT_AUTO_COL, float alpha_mod = IMPLOT_AUTO);
|
||||
// Set the marker style for the next item only.
|
||||
IMPLOT_API void SetNextMarkerStyle(ImPlotMarker marker = IMPLOT_AUTO, float size = IMPLOT_AUTO, const ImVec4& fill = IMPLOT_AUTO_COL, float weight = IMPLOT_AUTO, const ImVec4& outline = IMPLOT_AUTO_COL);
|
||||
// Set the error bar style for the next item only.
|
||||
IMPLOT_API void SetNextErrorBarStyle(const ImVec4& col = IMPLOT_AUTO_COL, float size = IMPLOT_AUTO, float weight = IMPLOT_AUTO);
|
||||
|
||||
// Gets the last item primary color (i.e. its legend icon color)
|
||||
IMPLOT_API ImVec4 GetLastItemColor();
|
||||
|
||||
// Returns the null terminated string name for an ImPlotCol.
|
||||
IMPLOT_API const char* GetStyleColorName(ImPlotCol idx);
|
||||
// Returns the null terminated string name for an ImPlotMarker.
|
||||
IMPLOT_API const char* GetMarkerName(ImPlotMarker idx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Colormaps
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Item styling is based on Colormaps when the relevant ImPlotCol is set to
|
||||
// IMPLOT_AUTO_COL (default). Several built in colormaps are available and can be
|
||||
// toggled in the demo. You can push/pop or set your own colormaps as well.
|
||||
|
||||
// The Colormap data will be ignored and a custom color will be used if you have either:
|
||||
// 1) Modified an item style color in your ImPlotStyle to anything but IMPLOT_AUTO_COL.
|
||||
// 2) Pushed an item style color using PushStyleColor().
|
||||
// 3) Set the next item style with a SetNextXStyle function.
|
||||
|
||||
// Temporarily switch to one of the built-in colormaps.
|
||||
IMPLOT_API void PushColormap(ImPlotColormap colormap);
|
||||
// Temporarily switch to your custom colormap. The pointer data must persist until the matching call to PopColormap!
|
||||
IMPLOT_API void PushColormap(const ImVec4* colormap, int size);
|
||||
// Undo temporary colormap modification.
|
||||
IMPLOT_API void PopColormap(int count = 1);
|
||||
|
||||
// Permanently sets a custom colormap. The colors will be copied to internal memory. Prefer PushColormap instead of calling this each frame.
|
||||
IMPLOT_API void SetColormap(const ImVec4* colormap, int size);
|
||||
// Permanently switch to one of the built-in colormaps. If samples is greater than 1, the map will be linearly resampled. Don't call this each frame.
|
||||
IMPLOT_API void SetColormap(ImPlotColormap colormap, int samples = 0);
|
||||
|
||||
// Returns the size of the current colormap.
|
||||
IMPLOT_API int GetColormapSize();
|
||||
// Returns a color from the Color map given an index >= 0 (modulo will be performed).
|
||||
IMPLOT_API ImVec4 GetColormapColor(int index);
|
||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||
IMPLOT_API ImVec4 LerpColormap(float t);
|
||||
// Returns the next unused colormap color and advances the colormap. Can be used to skip colors if desired.
|
||||
IMPLOT_API ImVec4 NextColormapColor();
|
||||
|
||||
// Renders a vertical color scale using the current color map. Call this outside of Begin/EndPlot.
|
||||
IMPLOT_API void ShowColormapScale(double scale_min, double scale_max, float height);
|
||||
|
||||
// Returns a null terminated string name for a built-in colormap.
|
||||
IMPLOT_API const char* GetColormapName(ImPlotColormap colormap);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Miscellaneous
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Allows changing how keyboard/mouse interaction works.
|
||||
IMPLOT_API ImPlotInputMap& GetInputMap();
|
||||
|
||||
// Get the plot draw list for rendering to the current plot area.
|
||||
IMPLOT_API ImDrawList* GetPlotDrawList();
|
||||
// Push clip rect for rendering to current plot area.
|
||||
IMPLOT_API void PushPlotClipRect();
|
||||
// Pop plot clip rect.
|
||||
IMPLOT_API void PopPlotClipRect();
|
||||
|
||||
// Shows ImPlot style selector dropdown menu.
|
||||
IMPLOT_API bool ShowStyleSelector(const char* label);
|
||||
// Shows ImPlot colormap selector dropdown menu.
|
||||
IMPLOT_API bool ShowColormapSelector(const char* label);
|
||||
// Shows ImPlot style editor block (not a window).
|
||||
IMPLOT_API void ShowStyleEditor(ImPlotStyle* ref = NULL);
|
||||
// Add basic help/info block (not a window): how to manipulate ImPlot as an end-user.
|
||||
IMPLOT_API void ShowUserGuide();
|
||||
// Shows ImPlot metrics/debug information.
|
||||
IMPLOT_API void ShowMetricsWindow(bool* p_popen = NULL);
|
||||
|
||||
// Sets the current _ImGui_ context. This is ONLY necessary if you are compiling
|
||||
// ImPlot as a DLL (not recommended) separate from your ImGui compilation. It
|
||||
// sets the global variable GImGui, which is not shared across DLL boundaries.
|
||||
// See GImGui documentation in imgui.cpp for more details.
|
||||
IMPLOT_API void SetImGuiContext(ImGuiContext* ctx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Demo (add implot_demo.cpp to your sources!)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Shows the ImPlot demo. Pass the current ImGui context if ImPlot is a DLL.
|
||||
IMPLOT_API void ShowDemoWindow(bool* p_open = NULL);
|
||||
|
||||
} // namespace ImPlot
|
981
external/ImGui/include/implot_internal.h
vendored
Normal file
981
external/ImGui/include/implot_internal.h
vendored
Normal file
@ -0,0 +1,981 @@
|
||||
// MIT License
|
||||
|
||||
// Copyright (c) 2020 Evan Pezent
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
|
||||
// You may use this file to debug, understand or extend ImPlot features but we
|
||||
// don't provide any guarantee of forward compatibility!
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Header Mess
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include "imgui_internal.h"
|
||||
|
||||
#ifndef IMPLOT_VERSION
|
||||
#error Must include implot.h before implot_internal.h
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Forward Declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct ImPlotTick;
|
||||
struct ImPlotAxis;
|
||||
struct ImPlotAxisState;
|
||||
struct ImPlotAxisColor;
|
||||
struct ImPlotItem;
|
||||
struct ImPlotLegendData;
|
||||
struct ImPlotPlot;
|
||||
struct ImPlotNextPlotData;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Context Pointer
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern IMPLOT_API ImPlotContext* GImPlot; // Current implicit context pointer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Macros and Constants
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Constants can be changed unless stated otherwise. We may move some of these
|
||||
// to ImPlotStyleVar_ over time.
|
||||
|
||||
// The maximum number of supported y-axes (DO NOT CHANGE THIS)
|
||||
#define IMPLOT_Y_AXES 3
|
||||
// The number of times to subdivided grid divisions (best if a multiple of 1, 2, and 5)
|
||||
#define IMPLOT_SUB_DIV 10
|
||||
// Zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click)
|
||||
#define IMPLOT_ZOOM_RATE 0.1f
|
||||
// Mimimum allowable timestamp value 01/01/1970 @ 12:00am (UTC) (DO NOT DECREASE THIS)
|
||||
#define IMPLOT_MIN_TIME 0
|
||||
// Maximum allowable timestamp value 01/01/3000 @ 12:00am (UTC) (DO NOT INCREASE THIS)
|
||||
#define IMPLOT_MAX_TIME 32503680000
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Generic Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Computes the common (base-10) logarithm
|
||||
static inline float ImLog10(float x) { return log10f(x); }
|
||||
static inline double ImLog10(double x) { return log10(x); }
|
||||
// Returns true if a flag is set
|
||||
template <typename TSet, typename TFlag>
|
||||
inline bool ImHasFlag(TSet set, TFlag flag) { return (set & flag) == flag; }
|
||||
// Flips a flag in a flagset
|
||||
template <typename TSet, typename TFlag>
|
||||
inline void ImFlipFlag(TSet& set, TFlag flag) { ImHasFlag(set, flag) ? set &= ~flag : set |= flag; }
|
||||
// Linearly remaps x from [x0 x1] to [y0 y1].
|
||||
template <typename T>
|
||||
inline T ImRemap(T x, T x0, T x1, T y0, T y1) { return y0 + (x - x0) * (y1 - y0) / (x1 - x0); }
|
||||
// Returns always positive modulo (assumes r != 0)
|
||||
inline int ImPosMod(int l, int r) { return (l % r + r) % r; }
|
||||
// Returns true if val is NAN or INFINITY
|
||||
inline bool ImNanOrInf(double val) { return val == HUGE_VAL || val == -HUGE_VAL || isnan(val); }
|
||||
// Turns NANs to 0s
|
||||
inline double ImConstrainNan(double val) { return isnan(val) ? 0 : val; }
|
||||
// Turns infinity to floating point maximums
|
||||
inline double ImConstrainInf(double val) { return val == HUGE_VAL ? DBL_MAX : val == -HUGE_VAL ? - DBL_MAX : val; }
|
||||
// Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?)
|
||||
inline double ImConstrainLog(double val) { return val <= 0 ? 0.001f : val; }
|
||||
// Turns numbers less than 0 to zero
|
||||
inline double ImConstrainTime(double val) { return val < IMPLOT_MIN_TIME ? IMPLOT_MIN_TIME : (val > IMPLOT_MAX_TIME ? IMPLOT_MAX_TIME : val); }
|
||||
|
||||
// Offset calculator helper
|
||||
template <int Count>
|
||||
struct ImOffsetCalculator {
|
||||
ImOffsetCalculator(const int* sizes) {
|
||||
Offsets[0] = 0;
|
||||
for (int i = 1; i < Count; ++i)
|
||||
Offsets[i] = Offsets[i-1] + sizes[i-1];
|
||||
}
|
||||
int Offsets[Count];
|
||||
};
|
||||
|
||||
// Character buffer writer helper
|
||||
struct ImBufferWriter
|
||||
{
|
||||
char* Buffer;
|
||||
int Size;
|
||||
int Pos;
|
||||
|
||||
ImBufferWriter(char* buffer, int size) {
|
||||
Buffer = buffer;
|
||||
Size = size;
|
||||
Pos = 0;
|
||||
}
|
||||
|
||||
void Write(const char* fmt, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
const int written = ::vsnprintf(&Buffer[Pos], Size - Pos - 1, fmt, argp);
|
||||
if (written > 0)
|
||||
Pos += ImMin(written, Size-Pos-1);
|
||||
va_end(argp);
|
||||
}
|
||||
};
|
||||
|
||||
// Fixed size point array
|
||||
template <int N>
|
||||
struct ImPlotPointArray {
|
||||
inline ImPlotPoint& operator[](int i) { return Data[i]; }
|
||||
inline const ImPlotPoint& operator[](int i) const { return Data[i]; }
|
||||
inline int Size() { return N; }
|
||||
ImPlotPoint Data[N];
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImPlot Enums
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef int ImPlotScale; // -> enum ImPlotScale_
|
||||
typedef int ImPlotTimeUnit; // -> enum ImPlotTimeUnit_
|
||||
typedef int ImPlotDateFmt; // -> enum ImPlotDateFmt_
|
||||
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_ {
|
||||
ImPlotTimeUnit_Us, // microsecond
|
||||
ImPlotTimeUnit_Ms, // millisecond
|
||||
ImPlotTimeUnit_S, // second
|
||||
ImPlotTimeUnit_Min, // minute
|
||||
ImPlotTimeUnit_Hr, // hour
|
||||
ImPlotTimeUnit_Day, // day
|
||||
ImPlotTimeUnit_Mo, // month
|
||||
ImPlotTimeUnit_Yr, // year
|
||||
ImPlotTimeUnit_COUNT
|
||||
};
|
||||
|
||||
enum ImPlotDateFmt_ { // default [ ISO 8601 ]
|
||||
ImPlotDateFmt_None = 0,
|
||||
ImPlotDateFmt_DayMo, // 10/3 [ --10-03 ]
|
||||
ImPlotDateFmt_DayMoYr, // 10/3/91 [ 1991-10-03 ]
|
||||
ImPlotDateFmt_MoYr, // Oct 1991 [ 1991-10 ]
|
||||
ImPlotDateFmt_Mo, // Oct [ --10 ]
|
||||
ImPlotDateFmt_Yr // 1991 [ 1991 ]
|
||||
};
|
||||
|
||||
enum ImPlotTimeFmt_ { // default [ 24 Hour Clock ]
|
||||
ImPlotTimeFmt_None = 0,
|
||||
ImPlotTimeFmt_Us, // .428 552 [ .428 552 ]
|
||||
ImPlotTimeFmt_SUs, // :29.428 552 [ :29.428 552 ]
|
||||
ImPlotTimeFmt_SMs, // :29.428 [ :29.428 ]
|
||||
ImPlotTimeFmt_S, // :29 [ :29 ]
|
||||
ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm [ 19:21:29.428 ]
|
||||
ImPlotTimeFmt_HrMinS, // 7:21:29pm [ 19:21:29 ]
|
||||
ImPlotTimeFmt_HrMin, // 7:21pm [ 19:21 ]
|
||||
ImPlotTimeFmt_Hr // 7pm [ 19:00 ]
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImPlot Structs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Combined data/time format spec
|
||||
struct ImPlotDateTimeFmt {
|
||||
ImPlotDateTimeFmt(ImPlotDateFmt date_fmt, ImPlotTimeFmt time_fmt, bool use_24_hr_clk = false, bool use_iso_8601 = false) {
|
||||
Date = date_fmt;
|
||||
Time = time_fmt;
|
||||
UseISO8601 = use_iso_8601;
|
||||
Use24HourClock = use_24_hr_clk;
|
||||
}
|
||||
ImPlotDateFmt Date;
|
||||
ImPlotTimeFmt Time;
|
||||
bool UseISO8601;
|
||||
bool Use24HourClock;
|
||||
};
|
||||
|
||||
// Two part timestamp struct.
|
||||
struct ImPlotTime {
|
||||
time_t S; // second part
|
||||
int Us; // microsecond part
|
||||
ImPlotTime() { S = 0; Us = 0; }
|
||||
ImPlotTime(time_t s, int us = 0) { S = s + us / 1000000; Us = us % 1000000; }
|
||||
void RollOver() { S = S + Us / 1000000; Us = Us % 1000000; }
|
||||
double ToDouble() const { return (double)S + (double)Us / 1000000.0; }
|
||||
static ImPlotTime FromDouble(double t) { return ImPlotTime((time_t)t, (int)(t * 1000000 - floor(t) * 1000000)); }
|
||||
};
|
||||
|
||||
static inline ImPlotTime operator+(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return ImPlotTime(lhs.S + rhs.S, lhs.Us + rhs.Us); }
|
||||
static inline ImPlotTime operator-(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return ImPlotTime(lhs.S - rhs.S, lhs.Us - rhs.Us); }
|
||||
static inline bool operator==(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs.S == rhs.S && lhs.Us == rhs.Us; }
|
||||
static inline bool operator<(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs.S == rhs.S ? lhs.Us < rhs.Us : lhs.S < rhs.S; }
|
||||
static inline bool operator>(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return rhs < lhs; }
|
||||
static inline bool operator<=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs < rhs || lhs == rhs; }
|
||||
static inline bool operator>=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs > rhs || lhs == rhs; }
|
||||
|
||||
// Storage for colormap modifiers
|
||||
struct ImPlotColormapMod {
|
||||
ImPlotColormapMod(const ImVec4* colormap, int colormap_size) {
|
||||
Colormap = colormap;
|
||||
ColormapSize = colormap_size;
|
||||
}
|
||||
const ImVec4* Colormap;
|
||||
int ColormapSize;
|
||||
};
|
||||
|
||||
// ImPlotPoint with positive/negative error values
|
||||
struct ImPlotPointError
|
||||
{
|
||||
double X, Y, Neg, Pos;
|
||||
ImPlotPointError(double x, double y, double neg, double pos) {
|
||||
X = x; Y = y; Neg = neg; Pos = pos;
|
||||
}
|
||||
};
|
||||
|
||||
// Interior plot label/annotation
|
||||
struct ImPlotAnnotation {
|
||||
ImVec2 Pos;
|
||||
ImVec2 Offset;
|
||||
ImU32 ColorBg;
|
||||
ImU32 ColorFg;
|
||||
int TextOffset;
|
||||
bool Clamp;
|
||||
};
|
||||
|
||||
// Collection of plot labels
|
||||
struct ImPlotAnnotationCollection {
|
||||
|
||||
ImVector<ImPlotAnnotation> Annotations;
|
||||
ImGuiTextBuffer TextBuffer;
|
||||
int Size;
|
||||
|
||||
ImPlotAnnotationCollection() { Reset(); }
|
||||
|
||||
void AppendV(const ImVec2& pos, const ImVec2& off, ImU32 bg, ImU32 fg, bool clamp, const char* fmt, va_list args) IM_FMTLIST(7) {
|
||||
ImPlotAnnotation an;
|
||||
an.Pos = pos; an.Offset = off;
|
||||
an.ColorBg = bg; an.ColorFg = fg;
|
||||
an.TextOffset = TextBuffer.size();
|
||||
an.Clamp = clamp;
|
||||
Annotations.push_back(an);
|
||||
TextBuffer.appendfv(fmt, args);
|
||||
const char nul[] = "";
|
||||
TextBuffer.append(nul,nul+1);
|
||||
Size++;
|
||||
}
|
||||
|
||||
void Append(const ImVec2& pos, const ImVec2& off, ImU32 bg, ImU32 fg, bool clamp, const char* fmt, ...) IM_FMTARGS(7) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
AppendV(pos, off, bg, fg, clamp, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
const char* GetText(int idx) {
|
||||
return TextBuffer.Buf.Data + Annotations[idx].TextOffset;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
Annotations.shrink(0);
|
||||
TextBuffer.Buf.shrink(0);
|
||||
Size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Tick mark info
|
||||
struct ImPlotTick
|
||||
{
|
||||
double PlotPos;
|
||||
float PixelPos;
|
||||
ImVec2 LabelSize;
|
||||
int TextOffset;
|
||||
bool Major;
|
||||
bool ShowLabel;
|
||||
int Level;
|
||||
|
||||
ImPlotTick(double value, bool major, bool show_label) {
|
||||
PlotPos = value;
|
||||
Major = major;
|
||||
ShowLabel = show_label;
|
||||
TextOffset = -1;
|
||||
Level = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Collection of ticks
|
||||
struct ImPlotTickCollection {
|
||||
ImVector<ImPlotTick> Ticks;
|
||||
ImGuiTextBuffer TextBuffer;
|
||||
float TotalWidth;
|
||||
float TotalHeight;
|
||||
float MaxWidth;
|
||||
float MaxHeight;
|
||||
int Size;
|
||||
|
||||
ImPlotTickCollection() { Reset(); }
|
||||
|
||||
void Append(const ImPlotTick& tick) {
|
||||
if (tick.ShowLabel) {
|
||||
TotalWidth += tick.ShowLabel ? tick.LabelSize.x : 0;
|
||||
TotalHeight += tick.ShowLabel ? tick.LabelSize.y : 0;
|
||||
MaxWidth = tick.LabelSize.x > MaxWidth ? tick.LabelSize.x : MaxWidth;
|
||||
MaxHeight = tick.LabelSize.y > MaxHeight ? tick.LabelSize.y : MaxHeight;
|
||||
}
|
||||
Ticks.push_back(tick);
|
||||
Size++;
|
||||
}
|
||||
|
||||
void Append(double value, bool major, bool show_label, void (*labeler)(ImPlotTick& tick, ImGuiTextBuffer& buf)) {
|
||||
ImPlotTick tick(value, major, show_label);
|
||||
if (labeler)
|
||||
labeler(tick, TextBuffer);
|
||||
Append(tick);
|
||||
}
|
||||
|
||||
const char* GetText(int idx) {
|
||||
return TextBuffer.Buf.Data + Ticks[idx].TextOffset;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
Ticks.shrink(0);
|
||||
TextBuffer.Buf.shrink(0);
|
||||
TotalWidth = TotalHeight = MaxWidth = MaxHeight = 0;
|
||||
Size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Axis state information that must persist after EndPlot
|
||||
struct ImPlotAxis
|
||||
{
|
||||
ImPlotAxisFlags Flags;
|
||||
ImPlotAxisFlags PreviousFlags;
|
||||
ImPlotRange Range;
|
||||
ImPlotOrientation Direction;
|
||||
bool Dragging;
|
||||
bool HoveredExt;
|
||||
bool HoveredTot;
|
||||
double* LinkedMin;
|
||||
double* LinkedMax;
|
||||
ImPlotTime PickerTimeMin, PickerTimeMax;
|
||||
int PickerLevel;
|
||||
|
||||
ImPlotAxis() {
|
||||
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
||||
Range.Min = 0;
|
||||
Range.Max = 1;
|
||||
Dragging = false;
|
||||
HoveredExt = false;
|
||||
HoveredTot = false;
|
||||
LinkedMin = LinkedMax = NULL;
|
||||
PickerLevel = 0;
|
||||
}
|
||||
|
||||
bool SetMin(double _min) {
|
||||
_min = ImConstrainNan(ImConstrainInf(_min));
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
||||
_min = ImConstrainLog(_min);
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
||||
_min = ImConstrainTime(_min);
|
||||
if (_min >= Range.Max)
|
||||
return false;
|
||||
Range.Min = _min;
|
||||
PickerTimeMin = ImPlotTime::FromDouble(Range.Min);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool SetMax(double _max) {
|
||||
_max = ImConstrainNan(ImConstrainInf(_max));
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
||||
_max = ImConstrainLog(_max);
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
||||
_max = ImConstrainTime(_max);
|
||||
if (_max <= Range.Min)
|
||||
return false;
|
||||
Range.Max = _max;
|
||||
PickerTimeMax = ImPlotTime::FromDouble(Range.Max);
|
||||
return true;
|
||||
};
|
||||
|
||||
void SetRange(double _min, double _max) {
|
||||
Range.Min = _min;
|
||||
Range.Max = _max;
|
||||
Constrain();
|
||||
PickerTimeMin = ImPlotTime::FromDouble(Range.Min);
|
||||
PickerTimeMax = ImPlotTime::FromDouble(Range.Max);
|
||||
}
|
||||
|
||||
void SetRange(const ImPlotRange& range) {
|
||||
SetRange(range.Min, range.Max);
|
||||
}
|
||||
|
||||
void Constrain() {
|
||||
Range.Min = ImConstrainNan(ImConstrainInf(Range.Min));
|
||||
Range.Max = ImConstrainNan(ImConstrainInf(Range.Max));
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale)) {
|
||||
Range.Min = ImConstrainLog(Range.Min);
|
||||
Range.Max = ImConstrainLog(Range.Max);
|
||||
}
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time)) {
|
||||
Range.Min = ImConstrainTime(Range.Min);
|
||||
Range.Max = ImConstrainTime(Range.Max);
|
||||
}
|
||||
if (Range.Max <= Range.Min)
|
||||
Range.Max = Range.Min + DBL_EPSILON;
|
||||
}
|
||||
};
|
||||
|
||||
// Axis state information only needed between BeginPlot/EndPlot
|
||||
struct ImPlotAxisState
|
||||
{
|
||||
ImPlotAxis* Axis;
|
||||
ImGuiCond RangeCond;
|
||||
bool HasRange;
|
||||
bool Present;
|
||||
bool HasLabels;
|
||||
bool Invert;
|
||||
bool LockMin;
|
||||
bool LockMax;
|
||||
bool Lock;
|
||||
bool IsTime;
|
||||
|
||||
ImPlotAxisState(ImPlotAxis* axis, bool has_range, ImGuiCond range_cond, bool present) {
|
||||
Axis = axis;
|
||||
HasRange = has_range;
|
||||
RangeCond = range_cond;
|
||||
Present = present;
|
||||
HasLabels = !ImHasFlag(Axis->Flags, ImPlotAxisFlags_NoTickLabels);
|
||||
Invert = ImHasFlag(Axis->Flags, ImPlotAxisFlags_Invert);
|
||||
LockMin = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMin) || (HasRange && RangeCond == ImGuiCond_Always);
|
||||
LockMax = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMax) || (HasRange && RangeCond == ImGuiCond_Always);
|
||||
Lock = !Present || ((LockMin && LockMax) || (HasRange && RangeCond == ImGuiCond_Always));
|
||||
IsTime = ImHasFlag(Axis->Flags, ImPlotAxisFlags_Time);
|
||||
}
|
||||
|
||||
ImPlotAxisState() { }
|
||||
};
|
||||
|
||||
struct ImPlotAxisColor
|
||||
{
|
||||
ImU32 Major, Minor, MajTxt, MinTxt;
|
||||
ImPlotAxisColor() { Major = Minor = MajTxt = MinTxt = 0; }
|
||||
};
|
||||
|
||||
// State information for Plot items
|
||||
struct ImPlotItem
|
||||
{
|
||||
ImGuiID ID;
|
||||
ImVec4 Color;
|
||||
int NameOffset;
|
||||
bool Show;
|
||||
bool LegendHovered;
|
||||
bool SeenThisFrame;
|
||||
|
||||
ImPlotItem() {
|
||||
ID = 0;
|
||||
Color = ImPlot::NextColormapColor();
|
||||
NameOffset = -1;
|
||||
Show = true;
|
||||
SeenThisFrame = false;
|
||||
LegendHovered = false;
|
||||
}
|
||||
|
||||
~ImPlotItem() { ID = 0; }
|
||||
};
|
||||
|
||||
// Holds Legend state labels and item references
|
||||
struct ImPlotLegendData
|
||||
{
|
||||
ImVector<int> Indices;
|
||||
ImGuiTextBuffer Labels;
|
||||
void Reset() { Indices.shrink(0); Labels.Buf.shrink(0); }
|
||||
};
|
||||
|
||||
// Holds Plot state information that must persist after EndPlot
|
||||
struct ImPlotPlot
|
||||
{
|
||||
ImGuiID ID;
|
||||
ImPlotFlags Flags;
|
||||
ImPlotFlags PreviousFlags;
|
||||
ImPlotAxis XAxis;
|
||||
ImPlotAxis YAxis[IMPLOT_Y_AXES];
|
||||
ImPlotLegendData LegendData;
|
||||
ImPool<ImPlotItem> Items;
|
||||
ImVec2 SelectStart;
|
||||
ImVec2 QueryStart;
|
||||
ImRect QueryRect;
|
||||
bool Selecting;
|
||||
bool Querying;
|
||||
bool Queried;
|
||||
bool DraggingQuery;
|
||||
bool LegendHovered;
|
||||
bool LegendOutside;
|
||||
bool LegendFlipSide;
|
||||
int ColormapIdx;
|
||||
int CurrentYAxis;
|
||||
ImPlotLocation MousePosLocation;
|
||||
ImPlotLocation LegendLocation;
|
||||
ImPlotOrientation LegendOrientation;
|
||||
|
||||
ImPlotPlot() {
|
||||
Flags = PreviousFlags = ImPlotFlags_None;
|
||||
XAxis.Direction = ImPlotOrientation_Horizontal;
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; ++i)
|
||||
YAxis[i].Direction = ImPlotOrientation_Vertical;
|
||||
SelectStart = QueryStart = ImVec2(0,0);
|
||||
Selecting = Querying = Queried = DraggingQuery = LegendHovered = LegendOutside = LegendFlipSide = false;
|
||||
ColormapIdx = CurrentYAxis = 0;
|
||||
LegendLocation = ImPlotLocation_North | ImPlotLocation_West;
|
||||
LegendOrientation = ImPlotOrientation_Vertical;
|
||||
MousePosLocation = ImPlotLocation_South | ImPlotLocation_East;
|
||||
}
|
||||
|
||||
int GetLegendCount() const { return LegendData.Indices.size(); }
|
||||
ImPlotItem* GetLegendItem(int i);
|
||||
const char* GetLegendLabel(int i);
|
||||
};
|
||||
|
||||
// Temporary data storage for upcoming plot
|
||||
struct ImPlotNextPlotData
|
||||
{
|
||||
ImGuiCond XRangeCond;
|
||||
ImGuiCond YRangeCond[IMPLOT_Y_AXES];
|
||||
ImPlotRange X;
|
||||
ImPlotRange Y[IMPLOT_Y_AXES];
|
||||
bool HasXRange;
|
||||
bool HasYRange[IMPLOT_Y_AXES];
|
||||
bool ShowDefaultTicksX;
|
||||
bool ShowDefaultTicksY[IMPLOT_Y_AXES];
|
||||
bool FitX;
|
||||
bool FitY[IMPLOT_Y_AXES];
|
||||
double* LinkedXmin;
|
||||
double* LinkedXmax;
|
||||
double* LinkedYmin[IMPLOT_Y_AXES];
|
||||
double* LinkedYmax[IMPLOT_Y_AXES];
|
||||
|
||||
ImPlotNextPlotData() {
|
||||
HasXRange = false;
|
||||
ShowDefaultTicksX = true;
|
||||
FitX = false;
|
||||
LinkedXmin = LinkedXmax = NULL;
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; ++i) {
|
||||
HasYRange[i] = false;
|
||||
ShowDefaultTicksY[i] = true;
|
||||
FitY[i] = false;
|
||||
LinkedYmin[i] = LinkedYmax[i] = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Temporary data storage for upcoming item
|
||||
struct ImPlotNextItemData {
|
||||
ImVec4 Colors[5]; // ImPlotCol_Line, ImPlotCol_Fill, ImPlotCol_MarkerOutline, ImPlotCol_MarkerFill, ImPlotCol_ErrorBar
|
||||
float LineWeight;
|
||||
ImPlotMarker Marker;
|
||||
float MarkerSize;
|
||||
float MarkerWeight;
|
||||
float FillAlpha;
|
||||
float ErrorBarSize;
|
||||
float ErrorBarWeight;
|
||||
float DigitalBitHeight;
|
||||
float DigitalBitGap;
|
||||
bool RenderLine;
|
||||
bool RenderFill;
|
||||
bool RenderMarkerLine;
|
||||
bool RenderMarkerFill;
|
||||
bool HasHidden;
|
||||
bool Hidden;
|
||||
ImGuiCond HiddenCond;
|
||||
ImPlotNextItemData() {
|
||||
for (int i = 0; i < 5; ++i)
|
||||
Colors[i] = IMPLOT_AUTO_COL;
|
||||
LineWeight = MarkerSize = MarkerWeight = FillAlpha = ErrorBarSize = ErrorBarWeight = DigitalBitHeight = DigitalBitGap = IMPLOT_AUTO;
|
||||
Marker = IMPLOT_AUTO;
|
||||
HasHidden = Hidden = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Holds state information that must persist between calls to BeginPlot()/EndPlot()
|
||||
struct ImPlotContext {
|
||||
// Plot States
|
||||
ImPool<ImPlotPlot> Plots;
|
||||
ImPlotPlot* CurrentPlot;
|
||||
ImPlotItem* CurrentItem;
|
||||
ImPlotItem* PreviousItem;
|
||||
|
||||
// Bounding Boxes
|
||||
ImRect BB_Frame;
|
||||
ImRect BB_Canvas;
|
||||
ImRect BB_Plot;
|
||||
ImRect BB_Axes;
|
||||
ImRect BB_X;
|
||||
ImRect BB_Y[IMPLOT_Y_AXES];
|
||||
|
||||
// Axis States
|
||||
ImPlotAxisColor Col_X;
|
||||
ImPlotAxisColor Col_Y[IMPLOT_Y_AXES];
|
||||
ImPlotAxisState X;
|
||||
ImPlotAxisState Y[IMPLOT_Y_AXES];
|
||||
|
||||
// Tick Marks and Labels
|
||||
ImPlotTickCollection XTicks;
|
||||
ImPlotTickCollection YTicks[IMPLOT_Y_AXES];
|
||||
float YAxisReference[IMPLOT_Y_AXES];
|
||||
|
||||
// Annotation and User Labels
|
||||
ImPlotAnnotationCollection Annotations;
|
||||
|
||||
// Transformations and Data Extents
|
||||
ImPlotScale Scales[IMPLOT_Y_AXES];
|
||||
ImRect PixelRange[IMPLOT_Y_AXES];
|
||||
double Mx;
|
||||
double My[IMPLOT_Y_AXES];
|
||||
double LogDenX;
|
||||
double LogDenY[IMPLOT_Y_AXES];
|
||||
ImPlotRange ExtentsX;
|
||||
ImPlotRange ExtentsY[IMPLOT_Y_AXES];
|
||||
|
||||
// Data Fitting Flags
|
||||
bool FitThisFrame;
|
||||
bool FitX;
|
||||
bool FitY[IMPLOT_Y_AXES];
|
||||
|
||||
// Hover states
|
||||
bool Hov_Frame;
|
||||
bool Hov_Plot;
|
||||
|
||||
// Axis Rendering Flags
|
||||
bool RenderX;
|
||||
bool RenderY[IMPLOT_Y_AXES];
|
||||
|
||||
// Axis Locking Flags
|
||||
bool LockPlot;
|
||||
bool ChildWindowMade;
|
||||
|
||||
// Style and Colormaps
|
||||
ImPlotStyle Style;
|
||||
ImVector<ImGuiColorMod> ColorModifiers;
|
||||
ImVector<ImGuiStyleMod> StyleModifiers;
|
||||
const ImVec4* Colormap;
|
||||
int ColormapSize;
|
||||
ImVector<ImPlotColormapMod> ColormapModifiers;
|
||||
|
||||
// Time
|
||||
tm Tm;
|
||||
|
||||
// Misc
|
||||
int VisibleItemCount;
|
||||
int DigitalPlotItemCnt;
|
||||
int DigitalPlotOffset;
|
||||
ImPlotNextPlotData NextPlotData;
|
||||
ImPlotNextItemData NextItemData;
|
||||
ImPlotInputMap InputMap;
|
||||
ImPlotPoint MousePos[IMPLOT_Y_AXES];
|
||||
};
|
||||
|
||||
struct ImPlotAxisScale
|
||||
{
|
||||
ImPlotPoint Min, Max;
|
||||
|
||||
ImPlotAxisScale(int y_axis, float tx, float ty, float zoom_rate) {
|
||||
ImPlotContext& gp = *GImPlot;
|
||||
Min = ImPlot::PixelsToPlot(gp.BB_Plot.Min - gp.BB_Plot.GetSize() * ImVec2(tx * zoom_rate, ty * zoom_rate), y_axis);
|
||||
Max = ImPlot::PixelsToPlot(gp.BB_Plot.Max + gp.BB_Plot.GetSize() * ImVec2((1 - tx) * zoom_rate, (1 - ty) * zoom_rate), y_axis);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Internal API
|
||||
// No guarantee of forward compatibility here!
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace ImPlot {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Context Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Initializes an ImPlotContext
|
||||
IMPLOT_API void Initialize(ImPlotContext* ctx);
|
||||
// Resets an ImPlot context for the next call to BeginPlot
|
||||
IMPLOT_API void Reset(ImPlotContext* ctx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Plot Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Gets a plot from the current ImPlotContext
|
||||
IMPLOT_API ImPlotPlot* GetPlot(const char* title);
|
||||
// Gets the current plot from the current ImPlotContext
|
||||
IMPLOT_API ImPlotPlot* GetCurrentPlot();
|
||||
// Busts the cache for every plot in the current context
|
||||
IMPLOT_API void BustPlotCache();
|
||||
|
||||
// Shows a plot's context menu.
|
||||
IMPLOT_API void ShowPlotContextMenu(ImPlotPlot& plot);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Item Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// 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);
|
||||
// Ends an item (call only if BeginItem returns true). Pops PlotClipRect.
|
||||
IMPLOT_API void EndItem();
|
||||
|
||||
// Register or get an existing item from the current plot.
|
||||
IMPLOT_API ImPlotItem* RegisterOrGetItem(const char* label_id, bool* just_created = NULL);
|
||||
// Get a plot item from the current plot.
|
||||
IMPLOT_API ImPlotItem* GetItem(const char* label_id);
|
||||
// Gets the current item.
|
||||
IMPLOT_API ImPlotItem* GetCurrentItem();
|
||||
// Busts the cache for every item for every plot in the current context.
|
||||
IMPLOT_API void BustItemCache();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Axis Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Gets the current y-axis for the current plot
|
||||
inline int GetCurrentYAxis() { return GImPlot->CurrentPlot->CurrentYAxis; }
|
||||
// Updates axis ticks, lins, and label colors
|
||||
IMPLOT_API void UpdateAxisColors(int axis_flag, ImPlotAxisColor* col);
|
||||
|
||||
// Updates plot-to-pixel space transformation variables for the current plot.
|
||||
IMPLOT_API void UpdateTransformCache();
|
||||
// Gets the XY scale for the current plot and y-axis
|
||||
inline ImPlotScale GetCurrentScale() { return GImPlot->Scales[GetCurrentYAxis()]; }
|
||||
|
||||
// Returns true if the user has requested data to be fit.
|
||||
inline bool FitThisFrame() { return GImPlot->FitThisFrame; }
|
||||
// Extends the current plots axes so that it encompasses point p
|
||||
IMPLOT_API void FitPoint(const ImPlotPoint& p);
|
||||
|
||||
// Returns true if two ranges overlap
|
||||
inline bool RangesOverlap(const ImPlotRange& r1, const ImPlotRange& r2)
|
||||
{ return r1.Min <= r2.Max && r2.Min <= r1.Max; }
|
||||
|
||||
// Updates pointers for linked axes from axis internal range.
|
||||
IMPLOT_API void PushLinkedAxis(ImPlotAxis& axis);
|
||||
// Updates axis internal range from points for linked axes.
|
||||
IMPLOT_API void PullLinkedAxis(ImPlotAxis& axis);
|
||||
|
||||
// Shows an axis's context menu.
|
||||
IMPLOT_API void ShowAxisContextMenu(ImPlotAxisState& state, bool time_allowed = false);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Legend Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Gets the position of an inner rect that is located inside of an outer rect according to an ImPlotLocation and padding amount.
|
||||
IMPLOT_API ImVec2 GetLocationPos(const ImRect& outer_rect, const ImVec2& inner_size, ImPlotLocation location, const ImVec2& pad = ImVec2(0,0));
|
||||
// Calculates the bounding box size of a legend
|
||||
IMPLOT_API ImVec2 CalcLegendSize(ImPlotPlot& plot, const ImVec2& pad, const ImVec2& spacing, ImPlotOrientation orientation);
|
||||
// Renders legend entries into a bounding box
|
||||
IMPLOT_API void ShowLegendEntries(ImPlotPlot& plot, const ImRect& legend_bb, bool interactable, const ImVec2& pad, const ImVec2& spacing, ImPlotOrientation orientation, ImDrawList& DrawList);
|
||||
// Shows an alternate legend for the plot identified by #title_id, outside of the plot frame (can be called before or after of Begin/EndPlot but must occur in the same ImGui window!).
|
||||
IMPLOT_API void ShowAltLegend(const char* title_id, ImPlotOrientation orientation = ImPlotOrientation_Vertical, const ImVec2 size = ImVec2(0,0), bool interactable = true);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Tick Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Label a tick with default formatting.
|
||||
IMPLOT_API void LabelTickDefault(ImPlotTick& tick, ImGuiTextBuffer& buffer);
|
||||
// Label a tick with scientific formating.
|
||||
IMPLOT_API void LabelTickScientific(ImPlotTick& tick, ImGuiTextBuffer& buffer);
|
||||
// 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, int nMajor, int nMinor, ImPlotTickCollection& ticks);
|
||||
// Populates a list of ImPlotTicks with logarithmic space and formatted ticks
|
||||
IMPLOT_API void AddTicksLogarithmic(const ImPlotRange& range, int nMajor, ImPlotTickCollection& ticks);
|
||||
// Populates a list of ImPlotTicks with time formatted ticks.
|
||||
IMPLOT_API void AddTicksTime(const ImPlotRange& range, int nMajor, ImPlotTickCollection& ticks);
|
||||
// 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);
|
||||
|
||||
// Create a a string label for a an axis value
|
||||
IMPLOT_API int LabelAxisValue(const ImPlotAxis& axis, const ImPlotTickCollection& ticks, double value, char* buff, int size);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Styling Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Get styling data for next item (call between Begin/EndItem)
|
||||
inline const ImPlotNextItemData& GetItemData() { return GImPlot->NextItemData; }
|
||||
|
||||
// Returns true if a color is set to be automatically determined
|
||||
inline bool IsColorAuto(const ImVec4& col) { return col.w == -1; }
|
||||
// Returns true if a style color is set to be automaticaly determined
|
||||
inline bool IsColorAuto(ImPlotCol idx) { return IsColorAuto(GImPlot->Style.Colors[idx]); }
|
||||
// Returns the automatically deduced style color
|
||||
IMPLOT_API ImVec4 GetAutoColor(ImPlotCol idx);
|
||||
|
||||
// Returns the style color whether it is automatic or custom set
|
||||
inline ImVec4 GetStyleColorVec4(ImPlotCol idx) { return IsColorAuto(idx) ? GetAutoColor(idx) : GImPlot->Style.Colors[idx]; }
|
||||
inline ImU32 GetStyleColorU32(ImPlotCol idx) { return ImGui::ColorConvertFloat4ToU32(GetStyleColorVec4(idx)); }
|
||||
|
||||
// Get built-in colormap data and size
|
||||
IMPLOT_API const ImVec4* GetColormap(ImPlotColormap colormap, int* size_out);
|
||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||
IMPLOT_API ImVec4 LerpColormap(const ImVec4* colormap, int size, float t);
|
||||
// Resamples a colormap. #size_out must be greater than 1.
|
||||
IMPLOT_API void ResampleColormap(const ImVec4* colormap_in, int size_in, ImVec4* colormap_out, int size_out);
|
||||
|
||||
// Draws vertical text. The position is the bottom left of the text rect.
|
||||
IMPLOT_API void AddTextVertical(ImDrawList *DrawList, ImVec2 pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||
// Calculates the size of vertical text
|
||||
inline ImVec2 CalcTextSizeVertical(const char *text) { ImVec2 sz = ImGui::CalcTextSize(text); return ImVec2(sz.y, sz.x); }
|
||||
// Returns white or black text given background color
|
||||
inline ImU32 CalcTextColor(const ImVec4& bg) { return (bg.x * 0.299 + bg.y * 0.587 + bg.z * 0.114) > 0.5 ? IM_COL32_BLACK : IM_COL32_WHITE; }
|
||||
|
||||
// Clamps a label position so that it fits a rect defined by Min/Max
|
||||
inline ImVec2 ClampLabelPos(ImVec2 pos, const ImVec2& size, const ImVec2& Min, const ImVec2& Max) {
|
||||
if (pos.x < Min.x) pos.x = Min.x;
|
||||
if (pos.y < Min.y) pos.y = Min.y;
|
||||
if ((pos.x + size.x) > Max.x) pos.x = Max.x - size.x;
|
||||
if ((pos.y + size.y) > Max.y) pos.y = Max.y - size.y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Math and Misc Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Rounds x to powers of 2,5 and 10 for generating axis labels (from Graphics Gems 1 Chapter 11.2)
|
||||
IMPLOT_API double NiceNum(double x, bool round);
|
||||
// Computes order of magnitude of double.
|
||||
inline int OrderOfMagnitude(double val) { return val == 0 ? 0 : (int)(floor(log10(fabs(val)))); }
|
||||
// Returns the precision required for a order of magnitude.
|
||||
inline int OrderToPrecision(int order) { return order > 0 ? 0 : 1 - order; }
|
||||
// Returns a floating point precision to use given a value
|
||||
inline int Precision(double val) { return OrderToPrecision(OrderOfMagnitude(val)); }
|
||||
|
||||
// Returns the intersection point of two lines A and B (assumes they are not parallel!)
|
||||
inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1, const ImVec2& b2) {
|
||||
float v1 = (a1.x * a2.y - a1.y * a2.x); float v2 = (b1.x * b2.y - b1.y * b2.x);
|
||||
float v3 = ((a1.x - a2.x) * (b1.y - b2.y) - (a1.y - a2.y) * (b1.x - b2.x));
|
||||
return ImVec2((v1 * (b1.x - b2.x) - v2 * (a1.x - a2.x)) / v3, (v1 * (b1.y - b2.y) - v2 * (a1.y - a2.y)) / v3);
|
||||
}
|
||||
|
||||
// Fills a buffer with n samples linear interpolated from vmin to vmax
|
||||
template <typename T>
|
||||
void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
|
||||
buffer.resize(n);
|
||||
T step = (vmax - vmin) / (n - 1);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
buffer[i] = vmin + i * step;
|
||||
}
|
||||
}
|
||||
|
||||
// Offsets and strides a data buffer
|
||||
template <typename T>
|
||||
inline T OffsetAndStride(const T* data, int idx, int count, int offset, int stride) {
|
||||
idx = ImPosMod(offset + idx, count);
|
||||
return *(const T*)(const void*)((const unsigned char*)data + (size_t)idx * stride);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Time Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Returns true if year is leap year (366 days long)
|
||||
inline bool IsLeapYear(int year) {
|
||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||
}
|
||||
// Returns the number of days in a month, accounting for Feb. leap years. #month is zero indexed.
|
||||
inline int GetDaysInMonth(int year, int month) {
|
||||
static const int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
return days[month] + (int)(month == 1 && IsLeapYear(year));
|
||||
}
|
||||
|
||||
// Make a UNIX timestamp from a tm struct expressed in UTC time (i.e. GMT timezone).
|
||||
IMPLOT_API ImPlotTime MkGmtTime(struct tm *ptm);
|
||||
// Make a tm struct expressed in UTC time (i.e. GMT timezone) from a UNIX timestamp.
|
||||
IMPLOT_API tm* GetGmtTime(const ImPlotTime& t, tm* ptm);
|
||||
|
||||
// Make a UNIX timestamp from a tm struct expressed in local time.
|
||||
IMPLOT_API ImPlotTime MkLocTime(struct tm *ptm);
|
||||
// Make a tm struct expressed in local time from a UNIX timestamp.
|
||||
IMPLOT_API tm* GetLocTime(const ImPlotTime& t, tm* ptm);
|
||||
|
||||
// NB: The following functions only work if there is a current ImPlotContext because the
|
||||
// internal tm struct is owned by the context! They are aware of ImPlotStyle.UseLocalTime.
|
||||
|
||||
// Make a timestamp from time components.
|
||||
// year[1970-3000], month[0-11], day[1-31], hour[0-23], min[0-59], sec[0-59], us[0,999999]
|
||||
IMPLOT_API ImPlotTime MakeTime(int year, int month = 0, int day = 1, int hour = 0, int min = 0, int sec = 0, int us = 0);
|
||||
// Get year component from timestamp [1970-3000]
|
||||
IMPLOT_API int GetYear(const ImPlotTime& t);
|
||||
|
||||
// Adds or subtracts time from a timestamp. #count > 0 to add, < 0 to subtract.
|
||||
IMPLOT_API ImPlotTime AddTime(const ImPlotTime& t, ImPlotTimeUnit unit, int count);
|
||||
// Rounds a timestamp down to nearest unit.
|
||||
IMPLOT_API ImPlotTime FloorTime(const ImPlotTime& t, ImPlotTimeUnit unit);
|
||||
// Rounds a timestamp up to the nearest unit.
|
||||
IMPLOT_API ImPlotTime CeilTime(const ImPlotTime& t, ImPlotTimeUnit unit);
|
||||
// Rounds a timestamp up or down to the nearest unit.
|
||||
IMPLOT_API ImPlotTime RoundTime(const ImPlotTime& t, ImPlotTimeUnit unit);
|
||||
// Combines the date of one timestamp with the time-of-day of another timestamp.
|
||||
IMPLOT_API ImPlotTime CombineDateTime(const ImPlotTime& date_part, const ImPlotTime& time_part);
|
||||
|
||||
// Formats the time part of timestamp t into a buffer according to #fmt
|
||||
IMPLOT_API int FormatTime(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt, bool use_24_hr_clk);
|
||||
// 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);
|
||||
// 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);
|
||||
|
||||
// Shows a date picker widget block (year/month/day).
|
||||
// #level = 0 for day, 1 for month, 2 for year. Modified by user interaction.
|
||||
// #t will be set when a day is clicked and the function will return true.
|
||||
// #t1 and #t2 are optional dates to highlight.
|
||||
IMPLOT_API bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime* t1 = NULL, const ImPlotTime* t2 = NULL);
|
||||
// Shows a time picker widget block (hour/min/sec).
|
||||
// #t will be set when a new hour, minute, or sec is selected or am/pm is toggled, and the function will return true.
|
||||
IMPLOT_API bool ShowTimePicker(const char* id, ImPlotTime* t);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Internal / Experimental Plotters
|
||||
// No guarantee of forward compatibility here!
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Plots axis-aligned, filled rectangles. Every two consecutive points defines opposite corners of a single rectangle.
|
||||
IMPLOT_API void PlotRects(const char* label_id, const float* xs, const float* ys, int count, int offset = 0, int stride = sizeof(float));
|
||||
IMPLOT_API void PlotRects(const char* label_id, const double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double));
|
||||
IMPLOT_API void PlotRects(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
||||
|
||||
} // namespace ImPlot
|
4109
external/ImGui/source/implot.cpp
vendored
Normal file
4109
external/ImGui/source/implot.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1691
external/ImGui/source/implot_demo.cpp
vendored
Normal file
1691
external/ImGui/source/implot_demo.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1915
external/ImGui/source/implot_items.cpp
vendored
Normal file
1915
external/ImGui/source/implot_items.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -71,6 +71,7 @@ namespace hex {
|
||||
Link("imgui_club by ocornut", "https://github.com/ocornut/imgui_club");
|
||||
Link("imnodes by Nelarius", "https://github.com/Nelarius/imnodes");
|
||||
Link("ImGuiColorTextEdit by BalazsJako", "https://github.com/BalazsJako/ImGuiColorTextEdit");
|
||||
Link("ImPlot by epezent", "https://github.com/epezent/implot");
|
||||
Link("capstone by aquynh", "https://github.com/aquynh/capstone");
|
||||
Link("JSON for Modern C++ by nlohmann", "https://github.com/nlohmann/json");
|
||||
Link("YARA by VirusTotal", "https://github.com/VirusTotal/yara");
|
||||
|
@ -8,11 +8,14 @@
|
||||
#include <typeinfo>
|
||||
|
||||
#include <imgui.h>
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include <imgui_internal.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#include <imgui_freetype.h>
|
||||
#include <imgui_imhex_extensions.h>
|
||||
#include <implot.h>
|
||||
#include <implot_internal.h>
|
||||
|
||||
#include <fontawesome_font.h>
|
||||
|
||||
@ -64,14 +67,17 @@ namespace hex {
|
||||
case 0: /* Dark theme */
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui::StyleCustomColorsDark();
|
||||
ImPlot::StyleColorsDark();
|
||||
break;
|
||||
case 1: /* Light theme */
|
||||
ImGui::StyleColorsLight();
|
||||
ImGui::StyleCustomColorsLight();
|
||||
ImPlot::StyleColorsLight();
|
||||
break;
|
||||
case 2: /* Classic theme */
|
||||
ImGui::StyleColorsClassic();
|
||||
ImGui::StyleCustomColorsClassic();
|
||||
ImPlot::StyleColorsClassic();
|
||||
break;
|
||||
}
|
||||
ImGui::GetStyle().Colors[ImGuiCol_DockingEmptyBg] = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
|
||||
@ -174,8 +180,10 @@ namespace hex {
|
||||
View::drawCommonInterfaces();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (this->m_demoWindowOpen)
|
||||
if (this->m_demoWindowOpen) {
|
||||
ImGui::ShowDemoWindow(&this->m_demoWindowOpen);
|
||||
ImPlot::ShowDemoWindow(&this->m_demoWindowOpen);
|
||||
}
|
||||
#endif
|
||||
|
||||
this->frameEnd();
|
||||
@ -616,6 +624,7 @@ namespace hex {
|
||||
IMGUI_CHECKVERSION();
|
||||
|
||||
GImGui = ImGui::CreateContext();
|
||||
GImPlot = ImPlot::CreateContext();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
@ -745,6 +754,7 @@ namespace hex {
|
||||
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImPlot::DestroyContext();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user