DWVv0.37.0

StageController

Source: stageController.js:49

Stage controller: manages the link between the data view configs and the stage (layer groups, layers, rendering).


Constructor

new StageController( dataController: DataController, options: object, ): StageController

Parameters

  • dataController (DataController) — The data controller.
  • options (object) — The app options.

Instance Methods

setToolboxController(tc: ToolboxController)

Set the toolbox controller.

Parameters

setAddToUndoStack(fn: function)

Set the add-to-undo-stack callback.

Parameters

  • fn (function) — The callback.

setGetInfoData(fn: function)

Set the info data getter callback.

Parameters

  • fn (function) — A function (dataId) => InfoData.

getViewConfigs( dataId: string, excludeStarConfig?: boolean, ): Array.<ViewConfig>

Get the layer group configuration from a data id.

Parameters

  • dataId (string) — The data id.
  • excludeStarConfig (boolean, optional) — Exclude the star config (default to false).

Returns

  • Array.<ViewConfig> — The list of associated configs.

getViewConfig( dataId: string, groupDivId: string, excludeStarConfig?: boolean, ): ViewConfig | undefined

Get the layer group configuration for a data id and group div id.

Parameters

  • dataId (string) — The data id.
  • groupDivId (string) — The layer group div id.
  • excludeStarConfig (boolean, optional) — Exclude the star config (default to false).

Returns

  • ViewConfig | undefined — The associated config.

getDataViewConfigs(): Record.<string, Array.<ViewConfig>>

Get the data view config. Careful, returns a reference; do not modify without resetting.

Returns

  • Record.<string, Array.<ViewConfig>> — The configuration list.

setDataViewConfigs(configs: Record.<string, Array.<ViewConfig>>)

Set the data view configuration. Resets the stage and recreates all the views.

Parameters

  • configs (Record.<string, Array.<ViewConfig>>) — The configuration list.

addDataViewConfig( dataId: string, config: ViewConfig, doRender?: boolean, )

Add a data view config.

Parameters

  • dataId (string) — The data id.
  • config (ViewConfig) — The view configuration.
  • doRender (boolean, optional) — Render data after configuration add. Defaults to true.

removeDataViewConfig(dataId: string, divId: string)

Remove a data view config. Removes the associated layer if found, removes the layer group if empty.

Parameters

  • dataId (string) — The data id.
  • divId (string) — The div id.

updateDataViewConfig( dataId: string, divId: string, config: ViewConfig, )

Update an existing data view config. Removes and re-creates the layer if found.

Parameters

  • dataId (string) — The data id.
  • divId (string) — The div id.
  • config (ViewConfig) — The view configuration.

getActiveLayerGroup(): LayerGroup | undefined

Get the active layer group.

Returns

setActiveLayerGroup(index: number)

Set the active layer group.

Parameters

  • index (number) — The layer group index.

getLayerGroup(index: number): LayerGroup

Get a layer group by index.

Parameters

  • index (number) — The index.

Returns

getNumberOfLayerGroups(): number

Get the number of layer groups.

Returns

  • number — The number of groups.

getViewLayersByDataId(dataId: string): Array.<ViewLayer>

Get the view layers associated to a data id.

Parameters

  • dataId (string) — The data id.

Returns

getViewLayers(callbackFn?: function): Array.<ViewLayer>

Get a list of view layers according to an input callback function.

Parameters

  • callbackFn (function, optional) — A function that takes a ViewLayer as input and returns a boolean. If undefined, returns all view layers.

Returns

  • Array.<ViewLayer> — The layers that satisfy the callbackFn.

getDrawLayersByDataId(dataId: string): Array.<DrawLayer>

Get the draw layers associated to a data id.

Parameters

  • dataId (string) — The data id.

Returns

getDrawLayers(callbackFn?: function): Array.<DrawLayer>

Get a list of draw layers according to an input callback function.

Parameters

  • callbackFn (function, optional) — A function that takes a DrawLayer as input and returns a boolean. If undefined, returns all draw layers.

Returns

  • Array.<DrawLayer> — The layers that satisfy the callbackFn.

getLayerGroupByDivId(divId: string): LayerGroup | undefined

Get a layer group by div id.

Parameters

  • divId (string) — The div id.

Returns

getAddedScale(): Scalar3D

Get the active layer group scale on top of the base scale.

Since v0.37, please access from the active layer group.

Returns

getBaseScale(): Scalar3D

Get the base scale of the active layer group.

Since v0.37, please access from the active layer group.

Returns

getOffset(): Scalar3D

Get the layer offset of the active layer group.

Since v0.37, please access from the active layer group.

Returns

empty()

Empty the stage (remove all layer groups).

removeLayersByDataId(dataId: string)

Remove layers for a specific data id.

Parameters

  • dataId (string) — The data id.

setBinders(instances: Array.<object>)

Set the layer groups binders.

Parameters

  • instances (Array.<object>) — Binder instances.

fitToContainer()

Fit the display to the data of each layer group.

draw()

Draw all layer groups.

resetLayout()

Reset zoom and pan of the stage.

Since v0.35, prefer resetZoomPan.

resetZoomPan()

Reset the zoom and pan of the stage.

resetViews()

Reset the position and window level of the stage.

setImageSmoothing(flag: boolean)

Set the imageSmoothing flag value. Default is false.

Parameters

  • flag (boolean) — True to enable smoothing.

zoom(step: number, cx: number, cy: number)

Zoom the layers of the active layer group.

Since v0.37, please access from the active layer group.

Parameters

  • step (number) — The step to add to the current zoom.
  • cx (number) — The zoom center X coordinate.
  • cy (number) — The zoom center Y coordinate.

translate(tx: number, ty: number)

Apply a translation to the layers of the active layer group.

Parameters

  • tx (number) — The translation along X.
  • ty (number) — The translation along Y.

render(dataId: string, viewConfigs?: Array.<ViewConfig>)

Render the current data.

Parameters

  • dataId (string) — The data id to render.
  • viewConfigs (Array.<ViewConfig>, optional) — The list of configs to render.