nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
nk::FigureManager Class Reference

Classes

struct  HandleRecord
struct  AxesCheckpoint
struct  FigureCheckpoint

Public Types

using OutputFunc = std::function<void(const std::string &)>

Public Member Functions

int createHandle (std::string type, std::string className, size_t datasetIndex=HandleRecord::kNoDataset, std::string slot="")
int createHandleAt (int figureId, size_t axesIndex, std::string type, std::string className, std::string slot="", size_t datasetIndex=HandleRecord::kNoDataset)
HandleRecord * findHandle (int id)
void deleteHandle (int id)
void removeAxes (int figureId, size_t axesIndex)
DatasetInfo * datasetOf (const HandleRecord &rec)
AxesState * axesOf (const HandleRecord &rec)
FigureState * figureOf (int figureId)
void markFigureModified (int figureId)
void invalidateHandles (int figureId, int axesIdx, bool includeAxesRecord, bool includeFigureRecord)
std::unordered_map< int, HandleRecord > & handles ()
void setOutputFunc (OutputFunc f)
 Set the output callback for figure/close markers.
FigureState & current ()
AxesState & currentAxes ()
 Convenience: current axes of current figure.
void pushDataset (DatasetInfo ds)
int newFigure ()
int setFigure (int n)
int currentFigureId () const
void setSubplot (int m, int n, int p)
 subplot(m,n,p) — set grid and switch to axes at position p
void prepareForPlot ()
void beginChartCall ()
size_t chartCallBase () const
void emitModified ()
 Emit JSON for all modified figures.
void closeFigure (int id)
void closeFigureNotify (int id)
 Close and emit notification marker.
void closeCurrent ()
void closeCurrentNotify ()
void closeAll ()
void closeAllNotify ()
const std::map< int, FigureState > & figures () const
FigureCheckpoint checkpointFigures () const
void restoreFigures (const FigureCheckpoint &cp)
DecimatedSeries getSeriesDisplayTile (int figId, int axIdx, int dsIdx, double x0, double x1, int width, int algo) const
 Display-grid tile resampler.
bool getFigureDisplayTile (int figId, int axIdx, int dsIdx, double srcR0, double srcC0, double srcH, double srcW, int displayH, int displayW, bool xLog, bool yLog, uint8_t *out) const
void ensureLOD (const DatasetInfo &ds, int targetLevel) const
 Build the LOD pyramid up to targetLevel if it isn't already cached.
bool getFigureTile (int figId, int axIdx, int dsIdx, int r0, int c0, int h, int w, int lod, std::vector< uint8_t > &out, size_t &outRows, size_t &outCols) const
 Source-grid tile fetcher (kept for Stage A/B compat tests).

Static Public Member Functions

static void maybeDownsampleSeries (DatasetInfo &ds)

Static Public Attributes

static constexpr std::size_t kSeriesPreviewThreshold = 1000000
 Append a dataset to the current axes, stamping its yside from AxesState::activeYside when yyaxis is on.
static constexpr int kSeriesPreviewCols = 2000

Detailed Description

Definition at line 465 of file figure_manager.hpp.

Member Typedef Documentation

◆ OutputFunc

using nk::FigureManager::OutputFunc = std::function<void(const std::string &)>

Definition at line 468 of file figure_manager.hpp.

Member Function Documentation

◆ axesOf()

AxesState * nk::FigureManager::axesOf ( const HandleRecord & rec)
inline

Definition at line 614 of file figure_manager.hpp.

◆ beginChartCall()

void nk::FigureManager::beginChartCall ( )
inline

Definition at line 832 of file figure_manager.hpp.

◆ chartCallBase()

size_t nk::FigureManager::chartCallBase ( ) const
inline

Definition at line 833 of file figure_manager.hpp.

◆ closeAll()

void nk::FigureManager::closeAll ( )
inline

Definition at line 1119 of file figure_manager.hpp.

◆ closeAllNotify()

void nk::FigureManager::closeAllNotify ( )
inline

Definition at line 1127 of file figure_manager.hpp.

◆ closeCurrent()

void nk::FigureManager::closeCurrent ( )
inline

Definition at line 1109 of file figure_manager.hpp.

◆ closeCurrentNotify()

void nk::FigureManager::closeCurrentNotify ( )
inline

Definition at line 1111 of file figure_manager.hpp.

◆ closeFigure()

void nk::FigureManager::closeFigure ( int id)
inline

Definition at line 1089 of file figure_manager.hpp.

◆ closeFigureNotify()

void nk::FigureManager::closeFigureNotify ( int id)
inline

Close and emit notification marker.

Definition at line 1102 of file figure_manager.hpp.

◆ createHandle()

int nk::FigureManager::createHandle ( std::string type,
std::string className,
size_t datasetIndex = HandleRecord::kNoDataset,
std::string slot = "" )
inline

Definition at line 508 of file figure_manager.hpp.

◆ createHandleAt()

int nk::FigureManager::createHandleAt ( int figureId,
size_t axesIndex,
std::string type,
std::string className,
std::string slot = "",
size_t datasetIndex = HandleRecord::kNoDataset )
inline

Definition at line 522 of file figure_manager.hpp.

◆ current()

FigureState & nk::FigureManager::current ( )
inline

Definition at line 669 of file figure_manager.hpp.

◆ currentAxes()

AxesState & nk::FigureManager::currentAxes ( )
inline

Convenience: current axes of current figure.

Definition at line 681 of file figure_manager.hpp.

◆ currentFigureId()

int nk::FigureManager::currentFigureId ( ) const
inline

Definition at line 762 of file figure_manager.hpp.

◆ datasetOf()

DatasetInfo * nk::FigureManager::datasetOf ( const HandleRecord & rec)
inline

Definition at line 601 of file figure_manager.hpp.

◆ deleteHandle()

void nk::FigureManager::deleteHandle ( int id)
inline

Definition at line 546 of file figure_manager.hpp.

◆ emitModified()

void nk::FigureManager::emitModified ( )
inline

Emit JSON for all modified figures.

Definition at line 836 of file figure_manager.hpp.

◆ ensureLOD()

void nk::FigureManager::ensureLOD ( const DatasetInfo & ds,
int targetLevel ) const
inline

Build the LOD pyramid up to targetLevel if it isn't already cached.

Each level halves dims via 2×2 mean-pooling of the parent (NaN-skip). Idempotent — repeated calls with smaller targetLevel are no-ops.

Stops early if a level would shrink below 32×32 (further pooling is useless detail-wise) or if memory allocation throws.

Definition at line 1331 of file figure_manager.hpp.

◆ figureOf()

FigureState * nk::FigureManager::figureOf ( int figureId)
inline

Definition at line 622 of file figure_manager.hpp.

◆ figures()

const std::map< int, FigureState > & nk::FigureManager::figures ( ) const
inline

Definition at line 1134 of file figure_manager.hpp.

◆ findHandle()

HandleRecord * nk::FigureManager::findHandle ( int id)
inline

Definition at line 538 of file figure_manager.hpp.

◆ getFigureDisplayTile()

bool nk::FigureManager::getFigureDisplayTile ( int figId,
int axIdx,
int dsIdx,
double srcR0,
double srcC0,
double srcH,
double srcW,
int displayH,
int displayW,
bool xLog,
bool yLog,
uint8_t * out ) const
inline

Definition at line 1210 of file figure_manager.hpp.

◆ getFigureTile()

bool nk::FigureManager::getFigureTile ( int figId,
int axIdx,
int dsIdx,
int r0,
int c0,
int h,
int w,
int lod,
std::vector< uint8_t > & out,
size_t & outRows,
size_t & outCols ) const
inline

Source-grid tile fetcher (kept for Stage A/B compat tests).

Reads a sub-rectangle rows [r0, r0+h) × cols [c0, c0+w) from zQuantized, mean-pools by lod×lod, writes row-major uint8 indices to out. Stage C uses getFigureDisplayTile instead — that one resamples to display-pixel grid in one pass.

Definition at line 1381 of file figure_manager.hpp.

◆ getSeriesDisplayTile()

DecimatedSeries nk::FigureManager::getSeriesDisplayTile ( int figId,
int axIdx,
int dsIdx,
double x0,
double x1,
int width,
int algo ) const
inline

Display-grid tile resampler.

Fills a displayH × displayW row-major uint8 buffer with mean-pooled samples from the dataset's zQuantized, applying optional log10 inverse on either axis so the buffer can be blitted directly to the panel's pixel grid.

srcR0, srcC0, srcH, srcW : visible source-rect in source-cell coords (fractional allowed for log inverse) xLog, yLog : log10 axis transforms — when set, the source-cell at display-pixel u (or v) is srcC0 * (srcC1/srcC0)^(u/displayW), etc. Requires srcC0 > 0 (yLog: srcR0 > 0). out : caller-allocated, size ≥ displayH*displayW

Per display pixel:

  • compute its source-cell centre via linear or log map
  • mean-pool over a small ⌈srcStep⌉×⌈cStep⌉ block centred there
  • skip NaN sentinels (idx 255), write 255 if the block is all-NaN

Cost: O(displayH * displayW * ⌈rStep⌉ * ⌈cStep⌉) — for a 800×600 panel showing the full 10000² extent that's ~30M ops, ~30ms in WASM. The upcoming Stage D LOD pyramid drops this to ~3 ms by reading from a pre-pooled level rather than the L0 source.

Returns false if request is out of range / not imagesc / no zQuantized / log requested with non-positive source coords.

Definition at line 1187 of file figure_manager.hpp.

◆ handles()

std::unordered_map< int, HandleRecord > & nk::FigureManager::handles ( )
inline

Definition at line 661 of file figure_manager.hpp.

◆ invalidateHandles()

void nk::FigureManager::invalidateHandles ( int figureId,
int axesIdx,
bool includeAxesRecord,
bool includeFigureRecord )
inline

Definition at line 645 of file figure_manager.hpp.

◆ markFigureModified()

void nk::FigureManager::markFigureModified ( int figureId)
inline

Definition at line 628 of file figure_manager.hpp.

◆ maybeDownsampleSeries()

void nk::FigureManager::maybeDownsampleSeries ( DatasetInfo & ds)
inlinestatic

Definition at line 710 of file figure_manager.hpp.

◆ newFigure()

int nk::FigureManager::newFigure ( )
inline

Definition at line 737 of file figure_manager.hpp.

◆ prepareForPlot()

void nk::FigureManager::prepareForPlot ( )
inline

Definition at line 801 of file figure_manager.hpp.

◆ pushDataset()

void nk::FigureManager::pushDataset ( DatasetInfo ds)
inline

Definition at line 696 of file figure_manager.hpp.

◆ removeAxes()

void nk::FigureManager::removeAxes ( int figureId,
size_t axesIndex )
inline

Definition at line 578 of file figure_manager.hpp.

◆ setFigure()

int nk::FigureManager::setFigure ( int n)
inline

Definition at line 750 of file figure_manager.hpp.

◆ setOutputFunc()

void nk::FigureManager::setOutputFunc ( OutputFunc f)
inline

Set the output callback for figure/close markers.

When set, emitModified() and close notifications route through this instead of std::cout, so debug and normal paths share the same channel.

Definition at line 667 of file figure_manager.hpp.

◆ setSubplot()

void nk::FigureManager::setSubplot ( int m,
int n,
int p )
inline

subplot(m,n,p) — set grid and switch to axes at position p

Definition at line 765 of file figure_manager.hpp.

Member Data Documentation

◆ kSeriesPreviewCols

int nk::FigureManager::kSeriesPreviewCols = 2000
staticconstexpr

Definition at line 694 of file figure_manager.hpp.

◆ kSeriesPreviewThreshold

std::size_t nk::FigureManager::kSeriesPreviewThreshold = 1000000
staticconstexpr

Append a dataset to the current axes, stamping its yside from AxesState::activeYside when yyaxis is on.

All graphics builtins route through this helper instead of currentAxes().datasets.push_back directly so dual-Y routing stays consistent (no plot family forgotten).

Definition at line 693 of file figure_manager.hpp.


The documentation for this class was generated from the following file: