PcolorPlot

Overview

class omdi::PcolorPlot : public omdi::Plot

Class for creating 2D heatmap (pseudocolor) plots.

The omdi::PcolorPlot class renders 2D scalar fields (e.g. omdi::GridXY) as pseudocolor heatmaps using ImPlot. It supports:

  • GPU-accelerated heatmap rendering for interactive performance,

  • an accompanying colorbar to visualize data ranges,

  • configurable aspect ratio (equal or free),

  • selection of colormap via ImPlotColormap.

Multiple named datasets can be registered; the active dataset is selected via an internal index.

Usage example

Basic usage with a single grid:

// Assuming 'grid' is an existing omdi::GridXY
auto pcolor = omdi::PcolorPlot({
  { "field", &grid }
}, "Scalar Field", /*aspect_equal=*/true);

// Inside your ImGui/ImPlot drawing code:
pcolor.plot();

Data members

bool omdi::PcolorPlot::m_aspect_equal

Flag controlling whether the plot uses an equal aspect ratio.

When true, the X and Y axes are scaled so that units are equal on both axes, preserving the geometric shape of the grid.

int omdi::PcolorPlot::m_which

Index of the currently selected dataset in omdi::PcolorPlot::m_data.

This determines which grid is displayed when omdi::PcolorPlot::plot() is called.

ImPlotColormap omdi::PcolorPlot::m_colormap

Colormap used for the pseudocolor rendering.

Defaults to ImPlotColormap_Viridis. Other ImPlot colormaps can be selected to change the visual appearance of the heatmap and colorbar.

std::map<std::string, const omdi::GridXY*const> omdi::PcolorPlot::m_data

Map of named 2D grids to display.

The keys are dataset names (e.g. "temperature" or "pressure"), and the values are non-owning pointers to omdi::GridXY instances holding the grid coordinates and scalar values.

Constructor

omdi::PcolorPlot::PcolorPlot(const std::map<std::string, const omdi::GridXY*const> &data, const std::string &label = "PcolorPlot", bool aspect_equal = true)

Construct a pseudocolor plot from a set of 2D grids.

Parameters:
  • data – Map from dataset names to non-owning pointers to omdi::GridXY structures.

  • label – Plot label / title (used in ImPlot).

  • aspect_equal – Whether to enforce equal aspect ratio for the axes (defaults to true).

The omdi::PcolorPlot does not take ownership of the omdi::GridXY instances; the caller must ensure that the underlying grid data outlives the plot.

Plotting

void omdi::PcolorPlot::plot() override

Render the pseudocolor plot.

This method overrides omdi::Plot::plot() and:

It is typically called inside an ImGui/ImPlot context, for example within a window where plotting is performed.

Notes