DWVv0.37.0

Scroll

Source: scroll.js:86

Scroll class. A tap sets the current position and fires a tap event with the annotations and segments under it (see PositionSetTapBehavior).

Example

CODE
import {App, AppOptions, ViewConfig, ToolConfig} from '//esm.sh/dwv';
// create the dwv app
const app = new App();
// initialise
const viewConfig0 = new ViewConfig('layerGroup0');
const viewConfigs = {'*': [viewConfig0]};
const options = new AppOptions(viewConfigs);
options.tools = {Scroll: new ToolConfig()};
app.init(options);
// activate tool
app.addEventListener('load', function () {
  app.setTool('Scroll');
});
// load dicom data
app.loadURLs([
  'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm',
  'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323707.dcm',
  'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323563.dcm'
]);

Example with slider

CODE
import {App, AppOptions, ViewConfig, ToolConfig, Index} from '//esm.sh/dwv';
// create the dwv app
const app = new App();
// initialise
const viewConfig0 = new ViewConfig('layerGroup0');
const viewConfigs = {'*': [viewConfig0]};
const options = new AppOptions(viewConfigs);
options.tools = {Scroll: new ToolConfig()};
app.init(options);
// create range
const range = document.createElement('input');
range.type = 'range';
range.min = 0;
range.id = 'sliceRange';
document.body.appendChild(range);
// update app on slider change
range.oninput = function () {
  const stgCtrl = app.getStageController();
  const lg = stgCtrl.getLayerGroupByDivId('layerGroup0');
  const vl = lg.getBaseViewLayer();
  const vc = vl.getViewController();
  const index = vc.getCurrentIndex();
  const values = index.getValues();
  values[2] = this.value;
  vc.setCurrentIndex(new Index(values));
}
// activate tool and update range max on load
app.addEventListener('load', function () {
  app.setTool('Scroll');
  const dataCtrl = app.getDataController();
  const size = dataCtrl.get(0).image.getGeometry().getSize();
  range.max = size.get(2) - 1;
});
// update slider on slice change (for ex via mouse wheel)
app.addEventListener('positionchange', function () {
  const stgCtrl = app.getStageController();
  const lg = stgCtrl.getLayerGroupByDivId('layerGroup0');
  const vl = lg.getBaseViewLayer();
  const vc = vl.getViewController();
  range.value = vc.getCurrentIndex().get(2);
});
// load dicom data
app.loadURLs([
  'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm',
  'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323707.dcm',
  'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323563.dcm'
]);

Constructor

new Scroll(app: App): Scroll

Parameters

  • app (App) — The associated application.

Instance Methods

activate(bool: boolean)

Activate the tool.

Parameters

  • bool (boolean) — The flag to activate or not.

setFeatures(features: object)

Set the tool live features: slice tooltip on hover.

Parameters

  • features (object) — The list of features.
    • features.displayTooltip (boolean, optional) — Show tooltip on mouse move.

init()

Initialise the tool.

getEventNames(): Array.<string>

Get the list of event names that this tool can fire.

Returns

  • Array.<string> — The list of event names.

Instance Fields

keydown

Handle key down event.

Parameters

  • event (object) — The key down event.