LayerGroup

Layer group.

  • Display position: {x,y},
  • Plane position: Index (access: get(i)),
  • (world) Position: Point3D (access: getX, getY, getZ).

Display -> World:

  • planePos = viewLayer.displayToPlanePos(displayPos) -> compensate for layer scale and offset,
  • pos = viewController.getPositionFromPlanePoint(planePos).

World -> Display:

  • planePos = viewController.getOffset3DFromPlaneOffset(pos) no need yet for a planePos to displayPos...

Constructor

new LayerGroup(containerDiv)

Parameters:
NameTypeDescription
containerDivHTMLElement

The associated HTML div.

Classes

LayerGroup

Methods

addDrawLayer() → {DrawLayer}

Add a draw layer.

The new layer will be marked as the active draw layer.

Returns:

The created layer.

Type: 
DrawLayer

addEventListener(type, callback)

Add an event listener to this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

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

addScale(scaleStep, center)

Add scale to the layers. Scale cannot go lower than 0.1.

Parameters:
NameTypeDescription
scaleStepnumber

The scale to add.

centerPoint3D

The scale center Point3D.

addTranslation(translation)

Add translation to the layers.

Parameters:
NameTypeDescription
translationScalar3D

The translation as {x,y,z}.

addViewLayer() → {ViewLayer}

Add a view layer.

The new layer will be marked as the active view layer.

Returns:

The created layer.

Type: 
ViewLayer

canScroll() → {boolean}

Can one of the view layers be scrolled.

Returns:

True if one view layer can be scrolled.

Type: 
boolean

display(flag)

Display the layer.

Parameters:
NameTypeDescription
flagboolean

Whether to display the layer or not.

draw()

Draw the layer.

empty()

Empty the layer list.

fitToContainer(divToWorldSizeRatio)

Fit to container: set the layers div to world size ratio.

Parameters:
NameTypeDescription
divToWorldSizeRationumber

The ratio.

flipScaleZ()

Flip all layers along the Z axis without offset compensation.

getActiveDrawLayer() → {DrawLayer|undefined}

Get the active draw layer.

Returns:

The layer.

Type: 
DrawLayer | undefined

getActiveViewLayer() → {ViewLayer|undefined}

Get the active image layer.

Returns:

The layer.

Type: 
ViewLayer | undefined

getAddedScale() → {Scalar3D}

Get the added scale: the scale added to the base scale.

Returns:

The scale as {x,y,z}.

Type: 
Scalar3D

getBaseScale() → {Scalar3D}

Get the base scale.

Returns:

The scale as {x,y,z}.

Type: 
Scalar3D

getBaseViewLayer() → {ViewLayer|undefined}

Get the base view layer.

Returns:

The layer.

Type: 
ViewLayer | undefined

getDivId() → {string}

Get the Id of the container div.

Returns:

The id of the div.

Type: 
string

getDivToWorldSizeRatio() → {number|undefined}

Calculate the div to world size ratio needed to fit the largest data.

Returns:

The ratio.

Type: 
number | undefined

getDrawLayers(callbackFnopt) → {Array.<DrawLayer>}

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

Parameters:
NameTypeAttributesDescription
callbackFnfunction<optional>

A function that takes a DrawLayer as input and returns a boolean. If undefined, returns all draw layers.

Returns:

The layers that satisfy the callbackFn.

Type: 
Array.<DrawLayer>

getDrawLayersByDataId(dataId) → {Array.<DrawLayer>}

Get the draw layers associated to a data id.

Parameters:
NameTypeDescription
dataIdstring

The data id.

Returns:

The layers.

Type: 
Array.<DrawLayer>

getMaxWorldSize() → {Scalar2D|undefined}

Get the largest data world (mm) size.

Returns:

The largest size as {x,y}.

Type: 
Scalar2D | undefined

getNumberOfLayers() → {number}

Get the number of layers handled by this class.

Returns:

The number of layers.

Type: 
number

getNumberOfViewLayers() → {number}

Get the number of view layers handled by this class.

Returns:

The number of layers.

Type: 
number

getOffset() → {Scalar3D}

Get the layer offset.

Returns:

The offset as {x,y,z}.

Type: 
Scalar3D

getScale() → {Scalar3D}

Get the layer scale.

Returns:

The scale as {x,y,z}.

Type: 
Scalar3D

getShowCrosshair() → {boolean}

Get the showCrosshair flag.

Returns:

True to display the crosshair.

Type: 
boolean

getViewDataIndices() → {Array.<string>}

Get the view layers data indices.

Returns:

The list of indices.

Type: 
Array.<string>

getViewLayers(callbackFnopt) → {Array.<ViewLayer>}

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

Parameters:
NameTypeAttributesDescription
callbackFnfunction<optional>

A function that takes a ViewLayer as input and returns a boolean. If undefined, returns all view layers.

Returns:

The layers that satisfy the callbackFn.

Type: 
Array.<ViewLayer>

getViewLayersByDataId(dataId) → {Array.<ViewLayer>}

Get the view layers associated to a data id.

Parameters:
NameTypeDescription
dataIdstring

The data id.

Returns:

The layers.

Type: 
Array.<ViewLayer>

includes(id) → {boolean}

Check if this layerGroup contains a layer with the input id.

Parameters:
NameTypeDescription
idstring

The layer id to look for.

Returns:

True if this group contains a layer with the input id.

Type: 
boolean

isPositionInBounds(position) → {boolean}

Can the input position be set on one of the view layers.

Parameters:
NameTypeDescription
positionPoint

The input position.

Returns:

True if one view layer accepts the input position.

Type: 
boolean

moreThanOne(dim) → {boolean}

Does one of the view layer have more than one slice in the given dimension.

Parameters:
NameTypeDescription
dimnumber

The input dimension.

Returns:

True if one view layer has more than one slice.

Type: 
boolean

removeEventListener(type, callback)

Remove an event listener from this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type.

removeLayer(layer)

Remove a layer from this layer group. Warning: if current active layer, the index will be set to undefined. Call one of the setActive methods to define the active index.

Parameters:
NameTypeDescription
layerViewLayer | DrawLayer

The layer to remove.

removeLayersByDataId(dataId)

Remove all layers for a specific data.

Parameters:
NameTypeDescription
dataIdstring

The data to remove its layers.

removeTooltipDiv()

Remove the tooltip html div.

reset()

Reset the stage to its initial scale and no offset.

searchViewLayers(meta) → {Array.<ViewLayer>}

Search view layers for equal imae meta data.

Parameters:
NameTypeDescription
metaobject

The meta data to find.

Returns:

The list of view layers that contain matched data.

Type: 
Array.<ViewLayer>

setActiveDrawLayer(index)

Set the active draw layer.

Parameters:
NameTypeDescription
indexnumber | undefined

The index of the layer to set as active or undefined to not set any.

setActiveDrawLayerByDataId(dataId)

Set the active draw layer with a data id.

Parameters:
NameTypeDescription
dataIdstring

The data id.

setActiveViewLayer(index)

Set the active view layer.

Parameters:
NameTypeDescription
indexnumber

The index of the layer to set as active.

setActiveViewLayerByDataId(dataId)

Set the active view layer with a data id.

Parameters:
NameTypeDescription
dataIdstring

The data id.

setImageSmoothing(flag)

Set the imageSmoothing flag value.

Parameters:
NameTypeDescription
flagboolean

True to enable smoothing.

setOffset(newOffset)

Set the layers' offset.

Parameters:
NameTypeDescription
newOffsetScalar3D

The offset as {x,y,z}.

setScale(newScale, centeropt)

Set the layers' scale.

Parameters:
NameTypeAttributesDescription
newScaleScalar3D

The scale to apply as {x,y,z}.

centerPoint3D<optional>

The scale center Point3D.

setShowCrosshair(flag)

Set the showCrosshair flag.

Parameters:
NameTypeDescription
flagboolean

True to display the crosshair.

showTooltip(point)

Displays a tooltip in a temporary span. Works with css to hide/show the span only on mouse hover.

Parameters:
NameTypeDescription
pointPoint2D

The update point.

someViewLayer(callbackFn) → {boolean}

Test if one of the view layers satisfies an input callbackFn.

Parameters:
NameTypeDescription
callbackFnfunction

A function that takes a ViewLayer as input and returns a boolean.

Returns:

True if one of the ViewLayers satisfies the callbackFn.

Type: 
boolean

updateLayersToPositionChange(event)

Update layers (but not the active view layer) to a position change.

Parameters:
NameTypeDescription
eventobject

The position change event.

Events

activelayerchange

Active layer change event.

Type:
  • object
Properties
NameTypeDescription
typestring

The event type.

valueArray

The changed value.

offsetchange

Offset change event.

Type:
  • object
Properties
NameTypeDescription
typestring

The event type.

valueArray

The changed value.

zoomchange

Zoom change event.

Type:
  • object
Properties
NameTypeDescription
typestring

The event type.

valueArray

The changed value.