Skip to content

pg_detail

Types

Name Description
ImagePlane A single image plane for preview (sender side).
TuiProcess Manages the forgeview child process lifecycle.
jsonl_sink spdlog sink that writes JSONL log messages to PG_JSONL_DEST().

Type Aliases

Name Description
jsonl_sink_mt Thread-safe (mutex-guarded) JSONL sink for spdlog.
jsonl_stderr_sink_mt Backward-compatibility alias for jsonl_sink_mt.

Functions

Name Description
base64_encode Base64 encode a byte buffer (no line wrapping).
box_downsample Box-filter downsample (or nearest-neighbor upscale) a 2D float array.
extract_preview_planes Extract preview planes from a complex image vector.
find_forgeview Locate the forgeview binary.
fit_aspect Compute aspect-ratio-preserving target dimensions.
get_exe_dir Get the directory containing the currently running executable.
iso8601_now Format current time as ISO 8601 with milliseconds.
json_escape Escape a string for JSON output (handles ", \, newlines, tabs).
level_name Get the spdlog level name as a lowercase string.

Type Alias Details

jsonl_sink_mt

using jsonl_sink_mt = jsonl_sink<std::mutex>

Thread-safe (mutex-guarded) JSONL sink for spdlog.

jsonl_stderr_sink_mt

using jsonl_stderr_sink_mt = jsonl_sink_mt

Backward-compatibility alias for jsonl_sink_mt.

Function Details

base64_encode

inline std::string base64_encode(const uint8_t* data, size_t len)

Base64 encode a byte buffer (no line wrapping).

box_downsample

inline std::vector<float> box_downsample( const std::vector<float>& src, size_t src_w, size_t src_h, size_t target_w, size_t target_h)

Box-filter downsample (or nearest-neighbor upscale) a 2D float array.

Supports non-square targets to preserve aspect ratio.

src : Source pixels in row-major order.

src_w : Source width.

src_h : Source height.

target_w : Target width.

target_h : Target height.

Return : Downsampled array of target_w × target_h floats.

extract_preview_planes

template <typename T1> inline std::vector<ImagePlane> extract_preview_planes( const std::complex<T1>* x_data, size_t n_elem, size_t Nx, size_t Ny, size_t Nz, size_t preview_max_dim = 128)

Extract preview planes from a complex image vector.

For 2D (Nz==1): returns 1 plane ("Image") — the full Nx×Ny magnitude. For 3D (Nz>1): returns 3 planes for MPR display: - "Axial" — z = Nz/2, showing Nx × Ny - "Coronal" — y = Ny/2, showing Nx × Nz - "Sagittal" — x = Nx/2, showing Ny × Nz

Each plane is box-filter downsampled to fit within preview_max_dim while preserving aspect ratio, then normalized to [0, 1] using a global max.

T1 : Floating-point precision (float or double).

x_data : Pointer to complex image data (column-major, Nx×Ny×Nz).

n_elem : Number of complex elements.

Nx, : Ny, Nz Image dimensions.

preview_max_dim : Maximum preview dimension (default 128).

Return : Vector of ImagePlane structs.

find_forgeview

inline std::string find_forgeview()

Locate the forgeview binary. Search order: 1. Same directory as the current executable (installed layout: both in bin/) 2. Relative to exe dir: ../tools/forgeview/forgeview (CMake build tree layout) 3. FORGEVIEW_PATH environment variable (explicit override) 4. PATH search

fit_aspect

inline std::pair<size_t, size_t> fit_aspect(size_t src_w, size_t src_h, size_t max_dim)

Compute aspect-ratio-preserving target dimensions.

Fits src_w × src_h into max_dim × max_dim while preserving aspect ratio. The longer dimension gets max_dim; the shorter is scaled proportionally.

get_exe_dir

inline std::string get_exe_dir()

Get the directory containing the currently running executable.

iso8601_now

inline std::string iso8601_now()

Format current time as ISO 8601 with milliseconds.

json_escape

inline std::string json_escape(const std::string& s)

Escape a string for JSON output (handles ", \, newlines, tabs).

level_name

inline const char* level_name(spdlog::level::level_enum lvl)

Get the spdlog level name as a lowercase string.