mirror of
https://github.com/gwm17/implot.git
synced 2024-11-23 02:38:53 -05:00
Fix vertically-flipped 2D histograms
This commit is contained in:
parent
5f11a7875d
commit
bef982f0b6
|
@ -53,8 +53,8 @@ struct HeatmapData
|
||||||
HeatmapShader* ShaderProgram; ///< Shader to be used by this heatmap (either ShaderInt or ShaderFloat)
|
HeatmapShader* ShaderProgram; ///< Shader to be used by this heatmap (either ShaderInt or ShaderFloat)
|
||||||
GLuint HeatmapTexID; ///< Texture ID of the heatmap 2D texture
|
GLuint HeatmapTexID; ///< Texture ID of the heatmap 2D texture
|
||||||
GLuint ColormapTexID; ///< Texture ID of the colormap 1D texture
|
GLuint ColormapTexID; ///< Texture ID of the colormap 1D texture
|
||||||
ImVec2 MinBounds; ///< Minimum bounds of the heatmap
|
ImPlotPoint MinBounds; ///< Minimum bounds of the heatmap
|
||||||
ImVec2 MaxBounds; ///< Maximum bounds of the heatmap
|
ImPlotPoint MaxBounds; ///< Maximum bounds of the heatmap
|
||||||
float MinValue; ///< Minimum value of the colormap
|
float MinValue; ///< Minimum value of the colormap
|
||||||
float MaxValue; ///< Maximum value of the colormap
|
float MaxValue; ///< Maximum value of the colormap
|
||||||
bool AxisLogX; ///< Whether the X axis is logarithmic or not
|
bool AxisLogX; ///< Whether the X axis is logarithmic or not
|
||||||
|
@ -332,7 +332,7 @@ void SetHeatmapData(int itemID, const ImU64* values, int rows, int cols)
|
||||||
SetTextureData(itemID, Context.temp3.Data, rows, cols, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT);
|
SetTextureData(itemID, Context.temp3.Data, rows, cols, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImVec2& bounds_min, const ImVec2& bounds_max)
|
void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max)
|
||||||
{
|
{
|
||||||
ContextData& Context = *((ContextData*)GImPlot->backendCtx);
|
ContextData& Context = *((ContextData*)GImPlot->backendCtx);
|
||||||
int idx = Context.ItemIDs.GetInt(itemID, -1);
|
int idx = Context.ItemIDs.GetInt(itemID, -1);
|
||||||
|
@ -344,7 +344,7 @@ void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImVec2& bounds_m
|
||||||
data.MaxBounds = bounds_max;
|
data.MaxBounds = bounds_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderHeatmap(int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max, float scale_min, float scale_max, ImPlotColormap colormap)
|
void RenderHeatmap(int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max, float scale_min, float scale_max, ImPlotColormap colormap, bool reverse_y)
|
||||||
{
|
{
|
||||||
ContextData& Context = *((ContextData*)GImPlot->backendCtx);
|
ContextData& Context = *((ContextData*)GImPlot->backendCtx);
|
||||||
int idx = Context.ItemIDs.GetInt(itemID, Context.HeatmapDataList.Size);
|
int idx = Context.ItemIDs.GetInt(itemID, Context.HeatmapDataList.Size);
|
||||||
|
@ -367,7 +367,7 @@ void RenderHeatmap(int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, c
|
||||||
|
|
||||||
DrawList.AddCallback(RenderCallback, (void*)(intptr_t)itemID);
|
DrawList.AddCallback(RenderCallback, (void*)(intptr_t)itemID);
|
||||||
DrawList.PrimReserve(6, 4);
|
DrawList.PrimReserve(6, 4);
|
||||||
DrawList.PrimRectUV(bounds_min, bounds_max, ImVec2(0.0f, 1.0f), ImVec2(1.0f, 0.0f), 0);
|
DrawList.PrimRectUV(bounds_min, bounds_max, ImVec2(0.0f, reverse_y ? 1.0f : 0.0f), ImVec2(1.0f, reverse_y ? 0.0f : 1.0f), 0);
|
||||||
DrawList.AddCallback(ResetState, nullptr);
|
DrawList.AddCallback(ResetState, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ IMPLOT_API void SetHeatmapData(int itemID, const ImU64* values, int rows, int c
|
||||||
*/
|
*/
|
||||||
IMPLOT_API void RenderHeatmap(
|
IMPLOT_API void RenderHeatmap(
|
||||||
int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max,
|
int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max,
|
||||||
float scale_min, float scale_max, ImPlotColormap colormap);
|
float scale_min, float scale_max, ImPlotColormap colormap, bool reverse_y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set logarithmic axis
|
* @brief Set logarithmic axis
|
||||||
|
@ -202,7 +202,7 @@ IMPLOT_API void RenderHeatmap(
|
||||||
* @param bounds_min Minimum bounds (for X & Y) of the heatmap
|
* @param bounds_min Minimum bounds (for X & Y) of the heatmap
|
||||||
* @param bounds_min Maximum bounds (for X & Y) of the heatmap
|
* @param bounds_min Maximum bounds (for X & Y) of the heatmap
|
||||||
*/
|
*/
|
||||||
void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImVec2& bounds_min, const ImVec2& bounds_max);
|
void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1895,15 +1895,14 @@ void RenderHeatmap(Transformer transformer, ImDrawList& DrawList, const T* value
|
||||||
#ifdef IMPLOT_BACKEND_HAS_HEATMAP
|
#ifdef IMPLOT_BACKEND_HAS_HEATMAP
|
||||||
ImVec2 bmin = transformer(bounds_min);
|
ImVec2 bmin = transformer(bounds_min);
|
||||||
ImVec2 bmax = transformer(bounds_max);
|
ImVec2 bmax = transformer(bounds_max);
|
||||||
|
|
||||||
ImPlotScale scale = GetCurrentScale();
|
ImPlotScale scale = GetCurrentScale();
|
||||||
|
|
||||||
// NOTE: Order is important!
|
// NOTE: Order is important!
|
||||||
Backend::RenderHeatmap(gp.CurrentItem->ID, DrawList, bmin, bmax, scale_min, scale_max, gp.Style.Colormap);
|
Backend::RenderHeatmap(gp.CurrentItem->ID, DrawList, bmin, bmax, scale_min, scale_max, gp.Style.Colormap, reverse_y);
|
||||||
Backend::SetAxisLog(gp.CurrentItem->ID,
|
Backend::SetAxisLog(gp.CurrentItem->ID,
|
||||||
scale == ImPlotScale_LogLin || scale == ImPlotScale_LogLog,
|
scale == ImPlotScale_LogLin || scale == ImPlotScale_LogLog,
|
||||||
scale == ImPlotScale_LinLog || scale == ImPlotScale_LogLog,
|
scale == ImPlotScale_LinLog || scale == ImPlotScale_LogLog,
|
||||||
ImVec2(bounds_min.x, bounds_min.y), ImVec2(bounds_max.x, bounds_max.y));
|
bounds_min, bounds_max);
|
||||||
Backend::SetHeatmapData(gp.CurrentItem->ID, values, rows, cols);
|
Backend::SetHeatmapData(gp.CurrentItem->ID, values, rows, cols);
|
||||||
#else
|
#else
|
||||||
GetterHeatmap<T> getter(values, rows, cols, scale_min, scale_max, (bounds_max.x - bounds_min.x) / cols, (bounds_max.y - bounds_min.y) / rows, bounds_min.x, yref, ydir);
|
GetterHeatmap<T> getter(values, rows, cols, scale_min, scale_max, (bounds_max.x - bounds_min.x) / cols, (bounds_max.y - bounds_min.y) / rows, bounds_min.x, yref, ydir);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user