Constructor
new App()
- Source
// create the dwv app
const app = new dwv.App();
// initialise
const viewConfig0 = new dwv.ViewConfig('layerGroup0');
const viewConfigs = {'*': [viewConfig0]};
const options = new dwv.AppOptions(viewConfigs);
app.init(options);
// load dicom data
app.loadURLs([
'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
]);
Methods
abortAllLoads()
Abort all the current loads.
- Source
abortLoad(dataId)
Abort an individual data load.
Name | Type | Description |
---|---|---|
dataId | string | The data to stop loading. |
- Source
addDataViewConfig(dataId, config)
Add a data view config.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
config | ViewConfig | The view configuration. |
- Source
addEventListener(type, callback)
Add an event listener to this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type, will be called with the fired event. |
- Source
addNewImage(image, meta, source) → {string}
Add a new image.
Name | Type | Description |
---|---|---|
image | Image | The new image. |
meta | object | The image meta. |
source | string | The source of the new image, will be passed with load events. |
- Source
The new image data id.
- Type:
- string
addToUndoStack(cmd)
Add a command to the undo stack.
Name | Type | Description |
---|---|---|
cmd | object | The command to add. |
- Source
applyJsonState(jsonState)
Apply a JSON state to this app.
Name | Type | Description |
---|---|---|
jsonState | string | The state of the app as a JSON string. |
- Source
canScroll() → {boolean}
Can the data (of the active view of the active layer) be scrolled?
- Deprecated
- Please use the ViewController equivalent directly instead.
- Source
True if the data has a third dimension greater than one.
- Type:
- boolean
canWindowLevel() → {boolean}
Can window and level be applied to the data (of the active view of the active layer)?
- Deprecated
- Please use the ViewController equivalent directly instead.
- Source
True if the data is monochrome.
- Type:
- boolean
defaultOnKeydown(event)
Key down event handler example.
- CRTL-Z: undo,
- CRTL-Y: redo,
- CRTL-ARROW_LEFT: next element on fourth dim,
- CRTL-ARROW_UP: next element on third dim,
- CRTL-ARROW_RIGHT: previous element on fourth dim,
- CRTL-ARROW_DOWN: previous element on third dim.
Applies to the active view of the active layer group.
Name | Type | Description |
---|---|---|
event | KeyboardEvent | The key down event. |
- Source
fitToContainer()
Fit the display to the data of each layer group. To be called once the image is loaded.
- Source
getActiveLayerGroup() → {LayerGroup|undefined}
Get the active layer group. The layer is available after the first loaded item.
- Source
The layer group.
- Type:
- LayerGroup |
undefined
getAddedScale() → {Scalar3D}
Get the active layer group scale on top of the base scale.
- Source
The scale as {x,y,z}.
- Type:
- Scalar3D
getBaseScale() → {Scalar3D}
Get the base scale of the active layer group.
- Source
The scale as {x,y,z}.
- Type:
- Scalar3D
getCurrentStackIndex() → {number}
Get the current undo stack index.
- Source
The stack index.
- Type:
- number
getDataIds() → {Array.<string>}
Get the list of ids in the data storage.
- Source
The list of data ids.
- Type:
- Array.<string>
getDataIdsFromSopUids(uids) → {Array.<string>}
Get the list of dataIds that contain the input UIDs.
Name | Type | Description |
---|---|---|
uids | Array.<string> | A list of UIDs. |
- Source
The list of dataIds that contain the UIDs.
- Type:
- Array.<string>
getDataViewConfigs() → {Object.<string, Array.<ViewConfig>>}
Get the data view config. Carefull, returns a reference, do not modify without resetting.
- Source
The configuration list.
- Type:
- Object.<string, Array.<ViewConfig>>
getDrawLayersByDataId(dataId) → {Array.<DrawLayer>}
Get the draw layers associated to a data id. The layer are available after the first loaded item.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
- Source
The layers.
- Type:
- Array.<DrawLayer>
getImage(dataId) → {Image|undefined}
Get the image.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
- Source
The associated image.
- Type:
- Image |
undefined
getJsonState() → {string}
Get the JSON state of the app.
- Source
The state of the app as a JSON string.
- Type:
- string
getLayerGroupByDivId(divId) → {LayerGroup}
Get a layer group by div id. The layer is available after the first loaded item.
Name | Type | Description |
---|---|---|
divId | string | The div id. |
- Source
The layer group.
- Type:
- LayerGroup
getMetaData(dataId) → {Object.<string, DataElement>|undefined}
Get the meta data.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
- Source
The list of meta data.
- Type:
- Object.<string, DataElement> |
undefined
getNumberOfLayerGroups() → {number}
Get the number of layer groups.
- Source
The number of groups.
- Type:
- number
getOffset() → {Scalar3D}
Get the layer offset of the active layer group.
- Source
The offset as {x,y,z}.
- Type:
- Scalar3D
getOverlayData(dataId) → {OverlayData|undefined}
Get the overlay data for a data id.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
- Source
The overlay data.
- Type:
- OverlayData |
undefined
getStackSize() → {number}
Get the undo stack size.
- Source
The size of the stack.
- Type:
- number
getStyle() → {object}
Get the app style.
- Source
The app style.
- Type:
- object
getToolboxController() → {ToolboxController}
Get the toolbox controller.
- Source
The controller.
- Type:
- ToolboxController
getViewConfig(dataId, groupDivId, excludeStarConfigopt) → {ViewConfig|undefined}
Get the layer group configuration for a data id and group div id.
Name | Type | Attributes | Description |
---|---|---|---|
dataId | string | The data id. | |
groupDivId | string | The layer group div id. | |
excludeStarConfig | boolean | <optional> | Exclude the star config (default to false). |
- Source
The associated config.
- Type:
- ViewConfig |
undefined
getViewConfigs(dataId, excludeStarConfigopt) → {Array.<ViewConfig>}
Get the layer group configuration from a data id.
Name | Type | Attributes | Description |
---|---|---|---|
dataId | string | The data id. | |
excludeStarConfig | boolean | <optional> | Exclude the star config (default to false). |
- Source
The list of associated configs.
- Type:
- Array.<ViewConfig>
getViewLayersByDataId(dataId) → {Array.<ViewLayer>}
Get the view layers associated to a data id. The layer are available after the first loaded item.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
- Source
The layers.
- Type:
- Array.<ViewLayer>
init(opt)
Initialise the application.
Name | Type | Description |
---|---|---|
opt | AppOptions | The application options. |
- Source
// create the dwv app
const app = new dwv.App();
// initialise
const viewConfig0 = new dwv.ViewConfig('layerGroup0');
const viewConfigs = {'*': [viewConfig0]};
const options = new dwv.AppOptions(viewConfigs);
options.viewOnFirstLoadItem = false;
app.init(options);
// render button
const button = document.createElement('button');
button.id = 'render';
button.disabled = true;
button.appendChild(document.createTextNode('render'));
document.body.appendChild(button);
app.addEventListener('load', function () {
const button = document.getElementById('render');
button.disabled = false;
button.onclick = function () {
// render data #0
app.render(0);
};
});
// load dicom data
app.loadURLs([
'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
]);
initWLDisplay()
Init the Window/Level display (of the active layer of the active layer group).
- Deprecated
- Please set the opacity of the desired view layer directly.
- Source
loadFiles(files)
Load a list of files. Can be image files or a state file.
Name | Type | Description |
---|---|---|
files | Array.<File> | The list of files to load. |
- Source
loadFromUri(uri, optionsopt)
Load from an input uri.
Name | Type | Attributes | Description |
---|---|---|---|
uri | string | The input uri, for example: 'window.location.href'. | |
options | object | <optional> | Optional url request options. |
- Source
loadImageObject(data)
Load a list of ArrayBuffers.
Name | Type | Description |
---|---|---|
data | Array | The list of ArrayBuffers to load in the form of [{name: "", filename: "", data: data}]. |
- Source
loadURLs(urls, optionsopt)
Load a list of URLs. Can be image files or a state file.
Name | Type | Attributes | Description |
---|---|---|---|
urls | Array.<string> | The list of urls to load. | |
options | object | <optional> | The options object, can contain:
|
- Source
onKeydown(event)
Key down callback. Meant to be used in tools.
Name | Type | Description |
---|---|---|
event | KeyboardEvent | The key down event. |
- Source
onResize()
Handle resize: fit the display to the window. To be called once the image is loaded. Can be connected to a window 'resize' event.
- Source
redo()
Redo the last action.
- Source
removeDataViewConfig(dataId, divId)
Remove a data view config.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
divId | string | The div id. |
- Source
removeEventListener(type, callback)
Remove an event listener from this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type. |
- Source
render(dataId, viewConfigsopt)
Render the current data.
Name | Type | Attributes | Description |
---|---|---|---|
dataId | string | The data id to render. | |
viewConfigs | Array.<ViewConfig> | <optional> | The list of configs to render. |
- Source
reset()
Reset the application.
- Source
resetDisplay()
Reset the display.
- Source
resetLayout()
Reset the layout of the application.
- Source
resetZoom()
Reset the app zoom.
- Source
setActiveLayerGroup(index)
Set the active layer group.
Name | Type | Description |
---|---|---|
index | number | The layer group index. |
- Source
setColourMap(name)
Set the colour map of the active view of the active layer group.
Name | Type | Description |
---|---|---|
name | string | The colour map name. |
- Deprecated
- Please use the ViewController equivalent directly instead.
- Source
setDataViewConfigs(configs)
Set the data view configuration. Resets the stage and recreates all the views.
Name | Type | Description |
---|---|---|
configs | Object.<string, Array.<ViewConfig>> | The configuration list. |
- Source
setDrawings(drawings, drawingsDetails)
Set the drawings of the active layer group.
Name | Type | Description |
---|---|---|
drawings | Array | An array of drawings. |
drawingsDetails | Array | An array of drawings details. |
- Source
setImage(dataId, img)
Set the image at the given id.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
img | Image | The associated image. |
- Source
setImageSmoothing(flag)
Set the imageSmoothing flag value. Default is false.
Name | Type | Description |
---|---|---|
flag | boolean | True to enable smoothing. |
- Source
setLayerGroupsBinders(list)
Set the layer groups binders.
Name | Type | Description |
---|---|---|
list | Array.<string> | The list of binder names. |
- Source
setOpacity(alpha)
Set the active view layer (of the active layer group) opacity.
Name | Type | Description |
---|---|---|
alpha | number | The opacity ([0:1] range). |
- Deprecated
- Please set the opacity of the desired view layer directly.
- Source
setTool(tool)
Set the tool.
Name | Type | Description |
---|---|---|
tool | string | The tool. |
- Source
setToolFeatures(list)
Set the tool live features.
Name | Type | Description |
---|---|---|
list | object | The list of features. |
- Source
setWindowLevelPreset(preset)
Set the window/level preset of the active view of the active layer group.
Name | Type | Description |
---|---|---|
preset | string | The window/level preset. |
- Deprecated
- Please use the ViewController equivalent directly instead.
- Source
toggleOverlayListeners(dataId)
Toggle overlay listeners.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
- Source
translate(tx, ty)
Apply a translation to the layers of the active layer group.
Name | Type | Description |
---|---|---|
tx | number | The translation along X. |
ty | number | The translation along Y. |
- Source
undo()
Undo the last action.
- Source
updateDataViewConfig(dataId, divId, config)
Update an existing data view config. Removes and re-creates the layer if found.
Name | Type | Description |
---|---|---|
dataId | string | The data id. |
divId | string | The div id. |
config | ViewConfig | The view configuration. |
- Source
zoom(step, cx, cy)
Zoom the layers of the active layer group.
Name | Type | Description |
---|---|---|
step | number | The step to add to the current zoom. |
cx | number | The zoom center X coordinate. |
cy | number | The zoom center Y coordinate. |
- Source
Events
abort
Load abort event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: abort. |
loadType | string | The load type: image or state. |
source | * | The load source: string for an url, File for a file. |
- Source
error
Load error event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: error. |
loadType | string | The load type: image or state. |
source | * | The load source: string for an url, File for a file. |
error | object | The error. |
target | object | The event target. |
- Source
keydown
Key down event.
- KeyboardEvent
Name | Type | Description |
---|---|---|
type | string | The event type: keydown. |
context | string | The tool where the event originated. |
- Source
load
Load event: fired when a load finishes successfully.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: load. |
loadType | string | The load type: image or state. |
- Source
loadend
Main load end event: fired when the load finishes, successfully or not.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: loadend. |
loadType | string | The load type: image or state. |
source | * | The load source: string for an url, File for a file. |
- Source
loaditem
Load item event: fired when a load item is successfull.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: loaditem. |
loadType | string | The load type: image or state. |
source | * | The load source: string for an url, File for a file. |
data | object | The loaded meta data. |
- Source
loadprogress
Load progress event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: loadprogress. |
loadType | string | The load type: image or state. |
source | * | The load source: string for an url, File for a file. |
loaded | number | The loaded percentage. |
total | number | The total percentage. |
- Source
loadstart
Load start event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type: loadstart. |
loadType | string | The load type: image or state. |
source | * | The load source: string for an url, File for a file. |
- Source
opacitychange
Opacity change event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source
renderend
Render end event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source
renderstart
Render start event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source