PluginLayerApi
ctx.layers: the viewer's rendering primitives, scoped to one plugin.
A plugin says "draw these cells in these colours" or "draw this geometry" and core draws it; the plugin never builds a renderer of its own. Every id a plugin registers is prefixed with its name, so two plugins cannot collide, and everything a plugin drew is removed when it is torn down.
Properties
list() => LayerRecord[]requiredEvery layer of the sample, in compositing order.
find(query: {kind?: string, modality?: string}) => LayerRecord[]requiredLayers matching a kind, a modality, or both. kind is how a layer is drawn; modality is what it means. The same vocabulary as plexora.api.layers on the server.
get(id: string) => ObjectrequiredThe layer stack's own record for one layer.
describe() => ObjectrequiredA summary of the whole layer stack.
viewport() => ObjectrequiredThe visible region in image coordinates.
visibleCells() => number[]requiredIds of the cells currently on screen, from the centroid tiles already loaded (no request).
setColorLUT(layerId: string, lut: Object) => voidrequiredColour cells: the plugin computes a lookup table, core draws it. Pass "cells" for this plugin's own cell layer.
setVisible(id: string, on: boolean) => voidrequiredShow or hide a layer.
setOpacity(id: string, value: number) => voidrequiredSet a layer's opacity, 0 to 1.
claim(id: string) => booleanrequiredSay "I draw this layer", which gives it an ordinary card (eye, opacity, drag) whose changes arrive through onLayerChange. Released automatically at teardown.
release(id: string) => booleanrequiredUndo claim.
setOrder(ids: string[]) => booleanrequiredReorder layers; returns whether anything changed.
setTransform(id: string, transform: number[]) => voidrequiredPlace a layer with an affine transform.
addOverlay(spec: Object) => ObjectrequiredDraw temporary geometry. Returns a handle with remove().
removeOverlay(id: string) => voidrequiredRemove an overlay added with the same id.
addTiled(spec: Object) => ?{remove: Function, setStyle: Function, setVisible: Function}requiredAdd a tiled layer this plugin draws (for example a density raster). Core owns placement and z-order; the plugin owns the tiles. Returns null when the transform cannot be expressed.
removeTiled(id: string) => voidrequiredRemove a tiled layer.
repaint() => voidrequiredRedraw overlays now.
onViewportChange(fn: Function) => FunctionrequiredCalled at most once per animation frame while the view moves. Returns an unsubscribe function; also removed at teardown.
onLayerChange(fn: Function) => FunctionrequiredCalled when any layer is shown, hidden, faded, reordered or added. Returns an unsubscribe function.