mirror of
https://github.com/gwm17/implot.git
synced 2024-11-13 22:48:50 -05:00
Add ImPlotFlags_Equal and simplify axis-related structs in implot_internal.h (#147)
* prototyping equal axes * equal proto * more refactors * euqal axes almost perfect * fitting axis equal working * fitting axis equal working * finish equal axis
This commit is contained in:
parent
48c0d6fe38
commit
40cbe88673
751
implot.cpp
751
implot.cpp
File diff suppressed because it is too large
Load Diff
11
implot.h
11
implot.h
|
@ -72,11 +72,12 @@ enum ImPlotFlags_ {
|
|||
ImPlotFlags_NoMousePos = 1 << 4, // the mouse position, in plot coordinates, will not be displayed inside of the plot
|
||||
ImPlotFlags_NoHighlight = 1 << 5, // plot items will not be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoChild = 1 << 6, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 7, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 8, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 9, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 10, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 11, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_Equal = 1 << 7, // primary x and y axes will be constrained to have the same units/pixel (does not apply to auxiliary y axes)
|
||||
ImPlotFlags_YAxis2 = 1 << 8, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 9, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 10, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 11, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 12, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
#define sprintf sprintf_s
|
||||
#endif
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
// Encapsulates examples for customizing ImPlot.
|
||||
namespace MyImPlot {
|
||||
|
||||
|
@ -447,7 +451,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
|
||||
ImPlot::SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot("##Pie1", NULL, NULL, ImVec2(250,250), ImPlotFlags_NoMousePos, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations)) {
|
||||
if (ImPlot::BeginPlot("##Pie1", NULL, NULL, ImVec2(250,250), ImPlotFlags_Equal | ImPlotFlags_NoMousePos, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations)) {
|
||||
ImPlot::PlotPieChart(labels1, data1, 4, 0.5, 0.5, 0.4, normalize, "%.2f");
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -459,7 +463,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
|
||||
ImPlot::PushColormap(ImPlotColormap_Pastel);
|
||||
ImPlot::SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||
if (ImPlot::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_NoMousePos, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations)) {
|
||||
if (ImPlot::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_Equal | ImPlotFlags_NoMousePos, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations)) {
|
||||
ImPlot::PlotPieChart(labels2, data2, 5, 0.5, 0.5, 0.4, true, "%.0f", 180);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
@ -737,6 +741,19 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Equal Axes")) {
|
||||
static double xs[1000], ys[1000];
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
double angle = i * 2 * PI / 999.0;
|
||||
xs[i] = cos(angle); ys[i] = sin(angle);
|
||||
}
|
||||
ImPlot::SetNextPlotLimits(-1,1,-1,1);
|
||||
if (ImPlot::BeginPlot("",0,0,ImVec2(-1,0),ImPlotFlags_Equal)) {
|
||||
ImPlot::PlotLine("Circle",xs,ys,1000);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Querying")) {
|
||||
static ImVector<ImPlotPoint> data;
|
||||
static ImPlotLimits range, query;
|
||||
|
@ -839,7 +856,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
static MyImPlot::WaveData data3(0.001, 0.2, 6, 0.5);
|
||||
ImPlot::PlotLineG("Item 1", MyImPlot::SineWave, &data1, 1000); // "Item 1" added to legend
|
||||
ImPlot::PlotLineG("Item 2##IDText", MyImPlot::SawWave, &data2, 1000); // "Item 2" added to legend, text after ## used for ID only
|
||||
ImPlot::PlotLineG("##NotDisplayed", MyImPlot::SawWave, &data3, 1000); // plotted, but not added to legend
|
||||
ImPlot::PlotLineG("##NotListed", MyImPlot::SawWave, &data3, 1000); // plotted, but not added to legend
|
||||
ImPlot::PlotLineG("Item 3", MyImPlot::SineWave, &data1, 1000); // "Item 3" added to legend
|
||||
ImPlot::PlotLineG("Item 3", MyImPlot::SawWave, &data2, 1000); // combined with previous "Item 3"
|
||||
ImPlot::EndPlot();
|
||||
|
@ -1174,7 +1191,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImGui::BulletText("The offset value indicates which circle point index is considered the first.");
|
||||
ImGui::BulletText("Offsets can be negative and/or larger than the actual data count.");
|
||||
ImGui::SliderInt("Offset", &offset, -2*k_points_per, 2*k_points_per);
|
||||
if (ImPlot::BeginPlot("##strideoffset")) {
|
||||
if (ImPlot::BeginPlot("##strideoffset",0,0,ImVec2(-1,0), ImPlotFlags_Equal)) {
|
||||
ImPlot::PushColormap(ImPlotColormap_Jet);
|
||||
char buff[16];
|
||||
for (int c = 0; c < k_circles; ++c) {
|
||||
|
|
|
@ -107,6 +107,8 @@ inline double ImConstrainInf(double val) { return val == HUGE_VAL ? DBL_MAX : v
|
|||
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); }
|
||||
// True if two numbers are approximately equal using units in the last place.
|
||||
inline bool ImAlmostEqual(double v1, double v2, int ulp = 2) { return ImAbs(v1-v2) < DBL_EPSILON * ImAbs(v1+v2) * ulp || ImAbs(v1-v2) < DBL_MIN; }
|
||||
|
||||
// Offset calculator helper
|
||||
template <int Count>
|
||||
|
@ -119,7 +121,7 @@ struct ImOffsetCalculator {
|
|||
int Offsets[Count];
|
||||
};
|
||||
|
||||
// Character buffer writer helper
|
||||
// Character buffer writer helper (FIXME: Can't we replace this with ImGuiTextBuffer?)
|
||||
struct ImBufferWriter
|
||||
{
|
||||
char* Buffer;
|
||||
|
@ -205,7 +207,7 @@ enum ImPlotTimeFmt_ { // default [ 24 Hour Clock ]
|
|||
// [SECTION] ImPlot Structs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Combined data/time format spec
|
||||
// Combined date/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;
|
||||
|
@ -379,27 +381,34 @@ struct ImPlotTickCollection {
|
|||
// 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;
|
||||
ImPlotAxisFlags Flags;
|
||||
ImPlotAxisFlags PreviousFlags;
|
||||
ImPlotRange Range;
|
||||
float Pixels;
|
||||
ImPlotOrientation Orientation;
|
||||
bool Dragging;
|
||||
bool ExtHovered;
|
||||
bool AllHovered;
|
||||
bool Present;
|
||||
bool HasRange;
|
||||
double* LinkedMin;
|
||||
double* LinkedMax;
|
||||
ImPlotTime PickerTimeMin, PickerTimeMax;
|
||||
int PickerLevel;
|
||||
ImU32 ColorMaj, ColorMin, ColorTxt;
|
||||
ImGuiCond RangeCond;
|
||||
ImRect HoverRect;
|
||||
|
||||
ImPlotAxis() {
|
||||
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
||||
Range.Min = 0;
|
||||
Range.Max = 1;
|
||||
Dragging = false;
|
||||
HoveredExt = false;
|
||||
HoveredTot = false;
|
||||
LinkedMin = LinkedMax = NULL;
|
||||
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
||||
Range.Min = 0;
|
||||
Range.Max = 1;
|
||||
Dragging = false;
|
||||
ExtHovered = false;
|
||||
AllHovered = false;
|
||||
LinkedMin = LinkedMax = NULL;
|
||||
PickerLevel = 0;
|
||||
ColorMaj = ColorMin = ColorTxt = 0;
|
||||
}
|
||||
|
||||
bool SetMin(double _min) {
|
||||
|
@ -440,6 +449,21 @@ struct ImPlotAxis
|
|||
SetRange(range.Min, range.Max);
|
||||
}
|
||||
|
||||
void SetAspect(double unit_per_pix) {
|
||||
double new_size = unit_per_pix * Pixels;
|
||||
double delta = (new_size - Range.Size()) * 0.5f;
|
||||
if (IsLocked())
|
||||
return;
|
||||
else if (IsLockedMin() && !IsLockedMax())
|
||||
SetRange(Range.Min, Range.Max + 2*delta);
|
||||
else if (!IsLockedMin() && IsLockedMax())
|
||||
SetRange(Range.Min - 2*delta, Range.Max);
|
||||
else
|
||||
SetRange(Range.Min - delta, Range.Max + delta);
|
||||
}
|
||||
|
||||
double GetAspect() const { return Range.Size() / Pixels; }
|
||||
|
||||
void Constrain() {
|
||||
Range.Min = ImConstrainNan(ImConstrainInf(Range.Min));
|
||||
Range.Max = ImConstrainNan(ImConstrainInf(Range.Max));
|
||||
|
@ -454,42 +478,15 @@ struct ImPlotAxis
|
|||
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; }
|
||||
inline bool IsLabeled() const { return !ImHasFlag(Flags, ImPlotAxisFlags_NoTickLabels); }
|
||||
inline bool IsInverted() const { return ImHasFlag(Flags, ImPlotAxisFlags_Invert); }
|
||||
inline bool IsAlwaysLocked() const { return HasRange && RangeCond == ImGuiCond_Always; }
|
||||
inline bool IsLockedMin() const { return ImHasFlag(Flags, ImPlotAxisFlags_LockMin) || IsAlwaysLocked(); }
|
||||
inline bool IsLockedMax() const { return ImHasFlag(Flags, ImPlotAxisFlags_LockMax) || IsAlwaysLocked(); }
|
||||
inline bool IsLocked() const { return !Present || ((IsLockedMin() && IsLockedMax()) || IsAlwaysLocked()); }
|
||||
inline bool IsTime() const { return ImHasFlag(Flags, ImPlotAxisFlags_Time); }
|
||||
inline bool IsLog() const { return ImHasFlag(Flags, ImPlotAxisFlags_LogScale); }
|
||||
};
|
||||
|
||||
// State information for Plot items
|
||||
|
@ -541,20 +538,26 @@ struct ImPlotPlot
|
|||
bool DraggingQuery;
|
||||
bool LegendHovered;
|
||||
bool LegendOutside;
|
||||
bool LegendFlipSide;
|
||||
bool LegendFlipSideNextFrame;
|
||||
bool FrameHovered;
|
||||
bool PlotHovered;
|
||||
int ColormapIdx;
|
||||
int CurrentYAxis;
|
||||
ImPlotLocation MousePosLocation;
|
||||
ImPlotLocation LegendLocation;
|
||||
ImPlotOrientation LegendOrientation;
|
||||
ImRect FrameRect;
|
||||
ImRect CanvasRect;
|
||||
ImRect PlotRect;
|
||||
ImRect AxesRect;
|
||||
|
||||
ImPlotPlot() {
|
||||
Flags = PreviousFlags = ImPlotFlags_None;
|
||||
XAxis.Direction = ImPlotOrientation_Horizontal;
|
||||
Flags = PreviousFlags = ImPlotFlags_None;
|
||||
XAxis.Orientation = ImPlotOrientation_Horizontal;
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; ++i)
|
||||
YAxis[i].Direction = ImPlotOrientation_Vertical;
|
||||
YAxis[i].Orientation = ImPlotOrientation_Vertical;
|
||||
SelectStart = QueryStart = ImVec2(0,0);
|
||||
Selecting = Querying = Queried = DraggingQuery = LegendHovered = LegendOutside = LegendFlipSide = false;
|
||||
Selecting = Querying = Queried = DraggingQuery = LegendHovered = LegendOutside = LegendFlipSideNextFrame = false;
|
||||
ColormapIdx = CurrentYAxis = 0;
|
||||
LegendLocation = ImPlotLocation_North | ImPlotLocation_West;
|
||||
LegendOrientation = ImPlotOrientation_Vertical;
|
||||
|
@ -564,6 +567,8 @@ struct ImPlotPlot
|
|||
int GetLegendCount() const { return LegendData.Indices.size(); }
|
||||
ImPlotItem* GetLegendItem(int i);
|
||||
const char* GetLegendLabel(int i);
|
||||
|
||||
inline bool IsLocked() const { return XAxis.IsLocked() && YAxis[0].IsLocked() && YAxis[1].IsLocked() && YAxis[2].IsLocked(); }
|
||||
};
|
||||
|
||||
// Temporary data storage for upcoming plot
|
||||
|
@ -584,7 +589,9 @@ struct ImPlotNextPlotData
|
|||
double* LinkedYmin[IMPLOT_Y_AXES];
|
||||
double* LinkedYmax[IMPLOT_Y_AXES];
|
||||
|
||||
ImPlotNextPlotData() {
|
||||
ImPlotNextPlotData() { Reset(); }
|
||||
|
||||
void Reset() {
|
||||
HasXRange = false;
|
||||
ShowDefaultTicksX = true;
|
||||
FitX = false;
|
||||
|
@ -596,6 +603,7 @@ struct ImPlotNextPlotData
|
|||
LinkedYmin[i] = LinkedYmax[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Temporary data storage for upcoming item
|
||||
|
@ -617,7 +625,8 @@ struct ImPlotNextItemData {
|
|||
bool HasHidden;
|
||||
bool Hidden;
|
||||
ImGuiCond HiddenCond;
|
||||
ImPlotNextItemData() {
|
||||
ImPlotNextItemData() { Reset(); }
|
||||
void Reset() {
|
||||
for (int i = 0; i < 5; ++i)
|
||||
Colors[i] = IMPLOT_AUTO_COL;
|
||||
LineWeight = MarkerSize = MarkerWeight = FillAlpha = ErrorBarSize = ErrorBarWeight = DigitalBitHeight = DigitalBitGap = IMPLOT_AUTO;
|
||||
|
@ -634,20 +643,6 @@ struct ImPlotContext {
|
|||
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];
|
||||
|
@ -671,16 +666,11 @@ struct ImPlotContext {
|
|||
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
|
||||
|
@ -704,17 +694,6 @@ struct ImPlotContext {
|
|||
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!
|
||||
|
|
|
@ -162,7 +162,7 @@ bool BeginItem(const char* label_id, ImPlotCol recolor_from) {
|
|||
}
|
||||
if (!item->Show) {
|
||||
// reset next item data
|
||||
gp.NextItemData = ImPlotNextItemData();
|
||||
gp.NextItemData.Reset();
|
||||
gp.PreviousItem = item;
|
||||
gp.CurrentItem = NULL;
|
||||
return false;
|
||||
|
@ -210,7 +210,7 @@ void EndItem() {
|
|||
// pop rendering clip rect
|
||||
PopPlotClipRect();
|
||||
// reset next item data
|
||||
gp.NextItemData = ImPlotNextItemData();
|
||||
gp.NextItemData.Reset();
|
||||
// set current item
|
||||
gp.PreviousItem = gp.CurrentItem;
|
||||
gp.CurrentItem = NULL;
|
||||
|
@ -730,13 +730,13 @@ inline void RenderLineStrip(const Getter& getter, const Transformer& transformer
|
|||
ImVec2 p1 = transformer(getter(0));
|
||||
for (int i = 1; i < getter.Count; ++i) {
|
||||
ImVec2 p2 = transformer(getter(i));
|
||||
if (gp.BB_Plot.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2))))
|
||||
if (gp.CurrentPlot->PlotRect.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2))))
|
||||
DrawList.AddLine(p1, p2, col, line_weight);
|
||||
p1 = p2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
RenderPrimitives(LineStripRenderer<Getter,Transformer>(getter, transformer, col, line_weight), DrawList, gp.BB_Plot);
|
||||
RenderPrimitives(LineStripRenderer<Getter,Transformer>(getter, transformer, col, line_weight), DrawList, gp.CurrentPlot->PlotRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -748,12 +748,12 @@ inline void RenderLineSegments(const Getter1& getter1, const Getter2& getter2, c
|
|||
for (int i = 0; i < I; ++i) {
|
||||
ImVec2 p1 = transformer(getter1(i));
|
||||
ImVec2 p2 = transformer(getter2(i));
|
||||
if (gp.BB_Plot.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2))))
|
||||
if (gp.CurrentPlot->PlotRect.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2))))
|
||||
DrawList.AddLine(p1, p2, col, line_weight);
|
||||
}
|
||||
}
|
||||
else {
|
||||
RenderPrimitives(LineSegmentsRenderer<Getter1,Getter2,Transformer>(getter1, getter2, transformer, col, line_weight), DrawList, gp.BB_Plot);
|
||||
RenderPrimitives(LineSegmentsRenderer<Getter1,Getter2,Transformer>(getter1, getter2, transformer, col, line_weight), DrawList, gp.CurrentPlot->PlotRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,7 +764,7 @@ inline void RenderStairs(const Getter& getter, const Transformer& transformer, I
|
|||
ImVec2 p1 = transformer(getter(0));
|
||||
for (int i = 1; i < getter.Count; ++i) {
|
||||
ImVec2 p2 = transformer(getter(i));
|
||||
if (gp.BB_Plot.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2)))) {
|
||||
if (gp.CurrentPlot->PlotRect.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2)))) {
|
||||
ImVec2 p12(p2.x, p1.y);
|
||||
DrawList.AddLine(p1, p12, col, line_weight);
|
||||
DrawList.AddLine(p12, p2, col, line_weight);
|
||||
|
@ -773,7 +773,7 @@ inline void RenderStairs(const Getter& getter, const Transformer& transformer, I
|
|||
}
|
||||
}
|
||||
else {
|
||||
RenderPrimitives(StairsRenderer<Getter,Transformer>(getter, transformer, col, line_weight), DrawList, gp.BB_Plot);
|
||||
RenderPrimitives(StairsRenderer<Getter,Transformer>(getter, transformer, col, line_weight), DrawList, gp.CurrentPlot->PlotRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ inline void RenderMarkers(Getter getter, Transformer transformer, ImDrawList& Dr
|
|||
ImPlotContext& gp = *GImPlot;
|
||||
for (int i = 0; i < getter.Count; ++i) {
|
||||
ImVec2 c = transformer(getter(i));
|
||||
if (gp.BB_Plot.Contains(c))
|
||||
if (gp.CurrentPlot->PlotRect.Contains(c))
|
||||
marker_table[marker](DrawList, c, size, rend_mk_line, col_mk_line, rend_mk_fill, col_mk_fill, weight);
|
||||
}
|
||||
}
|
||||
|
@ -1135,10 +1135,10 @@ inline void PlotShadedEx(const char* label_id, const Getter1& getter1, const Get
|
|||
if (s.RenderFill) {
|
||||
ImU32 col = ImGui::GetColorU32(s.Colors[ImPlotCol_Fill]);
|
||||
switch (GetCurrentScale()) {
|
||||
case ImPlotScale_LinLin: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLinLin>(getter1,getter2,TransformerLinLin(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LogLin: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLogLin>(getter1,getter2,TransformerLogLin(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LinLog: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLinLog>(getter1,getter2,TransformerLinLog(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LogLog: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLogLog>(getter1,getter2,TransformerLogLog(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LinLin: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLinLin>(getter1,getter2,TransformerLinLin(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
case ImPlotScale_LogLin: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLogLin>(getter1,getter2,TransformerLogLin(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
case ImPlotScale_LinLog: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLinLog>(getter1,getter2,TransformerLinLog(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
case ImPlotScale_LogLog: RenderPrimitives(ShadedRenderer<Getter1,Getter2,TransformerLogLog>(getter1,getter2,TransformerLogLog(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
}
|
||||
}
|
||||
EndItem();
|
||||
|
@ -1777,7 +1777,7 @@ inline void PlotDigitalEx(const char* label_id, Getter getter) {
|
|||
if (pMin.x > gp.PixelRange[y_axis].Max.x) pMin.x = gp.PixelRange[y_axis].Max.x;
|
||||
if (pMax.x > gp.PixelRange[y_axis].Max.x) pMax.x = gp.PixelRange[y_axis].Max.x;
|
||||
//plot a rectangle that extends up to x2 with y1 height
|
||||
if ((pMax.x > pMin.x) && (gp.BB_Plot.Contains(pMin) || gp.BB_Plot.Contains(pMax))) {
|
||||
if ((pMax.x > pMin.x) && (gp.CurrentPlot->PlotRect.Contains(pMin) || gp.CurrentPlot->PlotRect.Contains(pMax))) {
|
||||
// ImVec4 colAlpha = item->Color;
|
||||
// colAlpha.w = item->Highlight ? 1.0f : 0.9f;
|
||||
DrawList.AddRectFilled(pMin, pMax, ImGui::GetColorU32(s.Colors[ImPlotCol_Fill]));
|
||||
|
@ -1832,10 +1832,10 @@ void PlotRectsEx(const char* label_id, const Getter& getter) {
|
|||
ImDrawList& DrawList = *GetPlotDrawList();
|
||||
ImU32 col = ImGui::GetColorU32(s.Colors[ImPlotCol_Fill]);
|
||||
switch (GetCurrentScale()) {
|
||||
case ImPlotScale_LinLin: RenderPrimitives(RectRenderer<Getter,TransformerLinLin>(getter, TransformerLinLin(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LogLin: RenderPrimitives(RectRenderer<Getter,TransformerLogLin>(getter, TransformerLogLin(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LinLog: RenderPrimitives(RectRenderer<Getter,TransformerLinLog>(getter, TransformerLinLog(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LogLog: RenderPrimitives(RectRenderer<Getter,TransformerLogLog>(getter, TransformerLogLog(), col), DrawList, GImPlot->BB_Plot); break;
|
||||
case ImPlotScale_LinLin: RenderPrimitives(RectRenderer<Getter,TransformerLinLin>(getter, TransformerLinLin(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
case ImPlotScale_LogLin: RenderPrimitives(RectRenderer<Getter,TransformerLogLin>(getter, TransformerLogLin(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
case ImPlotScale_LinLog: RenderPrimitives(RectRenderer<Getter,TransformerLinLog>(getter, TransformerLinLog(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
case ImPlotScale_LogLog: RenderPrimitives(RectRenderer<Getter,TransformerLogLog>(getter, TransformerLogLog(), col), DrawList, GImPlot->CurrentPlot->PlotRect); break;
|
||||
}
|
||||
}
|
||||
EndItem();
|
||||
|
|
Loading…
Reference in New Issue
Block a user