App

dwv. App

new App()

Source:
Tutorials:

Main application class.

Methods

abortLoad()

Source:

Abort the current load.

addEventListener(type, callback)

Source:

Add an event listener to this class.

Parameters:
Name Type Description
type string

The event type.

callback object

The method associated with the provided event type, will be called with the fired event.

addToUndoStack(cmd)

Source:

Add a command to the undo stack.

Parameters:
Name Type Description
cmd object

The command to add.

Fires:

canScroll() → {boolean}

Source:

Can the data be scrolled?

Returns:

True if the data has a third dimension greater than one.

Type
boolean

canWindowLevel() → {boolean}

Source:

Can window and level be applied to the data?

Returns:

True if the data is monochrome.

Type
boolean

defaultOnKeydown(event)

Source:

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
Parameters:
Name Type Description
event object

The key down event.

Fires:

deleteDraws()

Source:

Delete all Draws from all layers.

fitToContainer()

Source:

Fit the display to the given size. To be called once the image is loaded.

getActiveLayerGroup() → {dwv.gui.LayerGroup}

Source:

Get the active layer group. The layer is available after the first loaded item.

Returns:

The layer group.

Type
dwv.gui.LayerGroup

getAddedScale() → {object}

Source:

Get the layer scale on top of the base scale.

Returns:

The scale as {x,y}.

Type
object

getBaseScale() → {object}

Source:

Get the base scale.

Returns:

The scale as {x,y}.

Type
object

getDrawDisplayDetails() → {object}

Source:

Get the list of drawing display details.

Returns:

The list of draw details including id, position...

Type
object

getDrawStoreDetails() → {object}

Source:

Get a list of drawing store details.

Returns:

A list of draw details including id, text, quant...

Type
object

getElement(_name) → {object}

Source:
Deprecated:
  • Yes

Get a HTML element associated to the application.

Parameters:
Name Type Description
_name string

The name or id to find.

Returns:

The found element or null.

Type
object

getImage(index) → {Image}

Source:

Get the image.

Parameters:
Name Type Description
index number

The data index.

Returns:

The associated image.

Type
Image

getLastImage() → {Image}

Source:

Get the last loaded image.

Returns:

The image.

Type
Image

getLayerGroupById(groupId) → {dwv.gui.LayerGroup}

Source:

Get a layer group by id. The layer is available after the first loaded item.

Parameters:
Name Type Description
groupId number

The group id.

Returns:

The layer group.

Type
dwv.gui.LayerGroup

getMetaData(index) → {object}

Source:

Get the meta data.

Parameters:
Name Type Description
index number

The data index.

Returns:

The list of meta data.

Type
object

getNumberOfLayerGroups() → {number}

Source:

Get the number of layer groups.

Returns:

The number of groups.

Type
number

getNumberOfLoadedData() → {number}

Source:

Get the number of loaded data.

Returns:

The number.

Type
number

getOffset() → {object}

Source:

Get the layer offset.

Returns:

The offset.

Type
object

getState() → {object}

Source:

Get the JSON state of the app.

Returns:

The state of the app as a JSON object.

Type
object

getStyle() → {object}

Source:

Get the app style.

Returns:

The app style.

Type
object

getToolboxController() → {object}

Source:

Get the toolbox controller.

Returns:

The controller.

Type
object

getViewLayersByDataIndex(index) → {Array}

Source:

Get the view layers associated to a data index. The layer are available after the first loaded item.

Parameters:
Name Type Description
index number

The data index.

Returns:

The layers.

Type
Array

init(opt)

Source:

Initialise the application.

Parameters:
Name Type Description
opt object

The application option with:

  • dataViewConfigs: data indexed object containing the data view configurations in the form of a list of objects containing:
    • divId: the HTML div id
    • orientation: optional 'axial', 'coronal' or 'sagittal' otientation string (default undefined keeps the original slice order)
  • binders: array of layerGroup binders
  • tools: tool name indexed object containing individual tool configurations
  • viewOnFirstLoadItem: boolean flag to trigger the first data render after the first loaded data or not
  • defaultCharacterSet: the default chraracter set string used for DICOM parsing

initWLDisplay()

Source:

Init the Window/Level display

isGroupVisible(drawDetails) → {boolean}

Source:

Check the visibility of a given group.

Parameters:
Name Type Description
drawDetails object

Details of the drawing to check.

Returns:

True if the group is visible.

Type
boolean

loadFiles(files, options)

Source:

Load a list of files. Can be image files or a state file.

Parameters:
Name Type Description
files Array

The list of files to load.

options object

The options object, can contain:

  • timepoint: an object with time information
Fires:

loadImageObject(data)

Source:

Load a list of ArrayBuffers.

Parameters:
Name Type Description
data Array

The list of ArrayBuffers to load in the form of [{name: "", filename: "", data: data}].

Fires:

loadURLs(urls, options)

Source:

Load a list of URLs. Can be image files or a state file.

Parameters:
Name Type Description
urls Array

The list of urls to load.

options object

The options object, can contain:

  • requestHeaders: an array of {name, value} to use as request headers
  • withCredentials: boolean xhr.withCredentials flag to pass to the request
  • batchSize: the size of the request url batch
Fires:

onKeydown(event)

Source:

Key down callback. Meant to be used in tools.

Parameters:
Name Type Description
event object

The key down event.

Fires:

redo()

Source:

Redo the last action

Fires:

removeEventListener(type, callback)

Source:

Remove an event listener from this class.

Parameters:
Name Type Description
type string

The event type.

callback object

The method associated with the provided event type.

render(dataIndex)

Source:

Render the current data.

Parameters:
Name Type Description
dataIndex number

The data index to render.

reset()

Source:

Reset the application.

resetDisplay()

Source:

Reset the display

resetLayout()

Source:

Reset the layout of the application.

resetZoom()

Source:

Reset the app zoom.s

runImageFilter()

Source:

Run the selected image filter.

setColourMap(colourMap)

Source:

Set the colour map.

Parameters:
Name Type Description
colourMap string

The colour map name.

setDataViewConfig(configs)

Source:

Set the data view configuration (see the init options for details).

Parameters:
Name Type Description
configs object

The configuration list.

setDrawings(drawings, drawingsDetails)

Source:

Set the drawings on the current stage.

Parameters:
Name Type Description
drawings Array

An array of drawings.

drawingsDetails Array

An array of drawings details.

setDrawLineColour(colour)

Source:

Set the draw line colour.

Parameters:
Name Type Description
colour string

The line colour.

setDrawShape(shape)

Source:

Set the draw shape.

Parameters:
Name Type Description
shape string

The draw shape.

setFilterMinMax(range)

Source:

Set the filter min/max.

Parameters:
Name Type Description
range object

The new range of the data: {min:a, max:b}.

setImage(index, img)

Source:

Set the image.

Parameters:
Name Type Description
index number

The data index.

img Image

The associated image.

setImageFilter(filter)

Source:

Set the image filter

Parameters:
Name Type Description
filter string

The image filter.

setLastImage(img)

Source:

Set the last image.

Parameters:
Name Type Description
img Image

The associated image.

setLayerGroupsBinders(list)

Source:

Set the layer groups binders.

Parameters:
Name Type Description
list Array

The binders list.

setOpacity(alpha)

Source:

Set the image layer opacity.

Parameters:
Name Type Description
alpha number

The opacity ([0:1] range).

setTool(tool)

Source:

Set the tool

Parameters:
Name Type Description
tool string

The tool.

setWindowLevelPreset(preset)

Source:

Set the window/level preset.

Parameters:
Name Type Description
preset object

The window/level preset.

toogleGroupVisibility(drawDetails)

Source:

Toggle group visibility.

Parameters:
Name Type Description
drawDetails object

Details of the drawing to update.

translate(tx, ty)

Source:

Apply a translation to the layers.

Parameters:
Name Type Description
tx number

The translation along X.

ty number

The translation along Y.

undo()

Source:

Undo the last action

Fires:

updateDraw(drawDetails)

Source:

Update a drawing from its details.

Parameters:
Name Type Description
drawDetails object

Details of the drawing to update.

zoom(step, cx, cy)

Source:

Zoom to the layers.

Parameters:
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.

(inner) addViewLayer(dataIndex, layerGroupElementId)

Source:

Add a view layer.

Parameters:
Name Type Description
dataIndex number

The data index.

layerGroupElementId string

The layer group element id.

(inner) getViewConfigs(dataIndex) → {Array}

Source:

Get the layer group configuration from a data index. Defaults to div id 'layerGroup' if no association object has been set.

Parameters:
Name Type Description
dataIndex number

The data index.

Returns:

The list of associated configs.

Type
Array

Events

abort

Source:
Properties:
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.

Load abort event.

Type:
  • object

error

Source:
Properties:
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.

Load error event.

Type:
  • object

keydown

Source:
Properties:
Name Type Description
type string

The event type: keydown.

context string

The tool where the event originated.

Key down event.

Type:
  • KeyboardEvent

load

Source:
Properties:
Name Type Description
type string

The event type: load.

loadType string

The load type: image or state.

Load event: fired when a load finishes successfully.

Type:
  • object

loadend

Source:
Properties:
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.

Main load end event: fired when the load finishes, successfully or not.

Type:
  • object

loaditem

Source:
Properties:
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.

Load item event: fired when a load item is successfull.

Type:
  • object

loadprogress

Source:
Properties:
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.

Load progress event.

Type:
  • object

loadstart

Source:
Properties:
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.

Load start event.

Type:
  • object

opacitychange

Source:
Properties:
Name Type Description
type string

The event type.

Opacity change event.

Type:
  • object

renderend

Source:
Properties:
Name Type Description
type string

The event type.

Render end event.

Type:
  • object

renderstart

Source:
Properties:
Name Type Description
type string

The event type.

Render start event.

Type:
  • object