LayerGroup
Source: layerGroup.js:115
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: HTMLElement,
withInfoLayer?: boolean,
canvasSizeChecker?: CanvasSizeChecker,
): LayerGroupParameters
containerDiv(HTMLElement) — The associated HTML div.withInfoLayer(boolean, optional) — Optional with info layer flag, default to false.canvasSizeChecker(CanvasSizeChecker, optional) — Optional canvas size checker, shared with the view layers; defaults to a new one.
Instance Methods
getPositionHelper(): PositionHelper | undefined
Get the position helper.
Returns
PositionHelper| undefined— The position helper or undefined if no layers.
getShowCrosshair(): boolean
Get the showCrosshair flag.
Returns
boolean— True to display the crosshair.
setShowCrosshair(flag: boolean)
Set the showCrosshair flag.
Parameters
flag(boolean) — True to display the crosshair.
setImageSmoothing(flag: boolean)
Set the imageSmoothing flag value.
Parameters
flag(boolean) — True to enable smoothing.
getDivId(): string | undefined
Get the Id of the container div.
Returns
string | undefined— The id of the div.
getScale(): Scalar3D
Get the layer scale.
Returns
Scalar3D— The scale as {x,y,z}.
getBaseScale(): Scalar3D
Get the base scale.
Returns
Scalar3D— The scale as {x,y,z}.
getAddedScale(): Scalar3D
Get the added scale: the scale added to the base scale.
Returns
Scalar3D— The scale as {x,y,z}.
getOffset(): Scalar3D
Get the layer offset.
Returns
Scalar3D— The offset as {x,y,z}.
getNumberOfLayers(): number
Get the number of layers handled by this class.
Returns
number— The number of layers.
includes(id: string): boolean
Check if this layerGroup contains a layer with the input id.
Parameters
id(string) — The layer id to look for.
Returns
boolean— True if this group contains a layer with the input id.
getViewLayers(callbackFn?: function): Array.<ViewLayer>
Get the view layers that satisfy the 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.
getViewLayersFromActive(
callbackFn?: function,
): Array.<ViewLayer>
Get the view layers that satisfy the input callback function starting from the active layer.
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.
someViewLayer(callbackFn: function): boolean
Test if one of the view layers satisfies an input callbackFn.
Parameters
callbackFn(function) — A function that takes a ViewLayer as input and returns a boolean.
Returns
boolean— True if one of the ViewLayers satisfies the callbackFn.
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.
getNumberOfViewLayers(): number
Get the number of view layers handled by this class.
Returns
number— The number of layers.
getActiveLayer(): ViewLayer | DrawLayer | undefined
Get the active image layer.
Returns
getActiveViewLayer(): ViewLayer | undefined
Get the active image layer.
Returns
ViewLayer| undefined— The layer.
getBaseViewLayer(): ViewLayer | undefined
Get the base view layer.
Returns
ViewLayer| undefined— The layer.
getViewLayerById(id: string): ViewLayer | undefined
Get a view layer associated to a data id.
Parameters
id(string) — The layer id.
Returns
ViewLayer| undefined— The layer.
getViewLayersByDataId(dataId: string): Array.<ViewLayer>
Get the view layers associated to a data id.
Parameters
dataId(string) — The data id.
Returns
Array.<ViewLayer>— The layers.
searchViewLayers(meta: object): Array.<ViewLayer>
Search view layers for equal image meta data.
Parameters
meta(object) — The meta data to find.
Returns
Array.<ViewLayer>— The list of view layers that contain matched data.
getViewDataIndices(): Array.<string>
Get the view layers data indices.
Returns
Array.<string>— The list of indices.
getActiveDrawLayer(): DrawLayer | undefined
Get the active draw layer.
Returns
DrawLayer| undefined— The layer.
getDrawLayerById(id: string): DrawLayer | undefined
Get a draw layer associated to a data id.
Parameters
id(string) — The layer id.
Returns
DrawLayer| undefined— The layer.
getDrawLayersByDataId(dataId: string): Array.<DrawLayer>
Get the draw layers associated to a data id.
Parameters
dataId(string) — The data id.
Returns
Array.<DrawLayer>— The layers.
setActiveLayer(index: number)
Set the active layer.
Parameters
index(number) — The index of the layer to set as active.
setActiveLayerById(id: string)
Set the active layer with a layer id.
Parameters
id(string) — The layer id.
setActiveLayerByDataId(dataId: string)
Set the active layer with a data id.
Parameters
dataId(string) — The data id.
addViewLayer(): ViewLayer
Add a view layer.
The new layer will be marked as the active view layer.
Returns
ViewLayer— The created layer.
addDrawLayer(): DrawLayer
Add a draw layer.
The new layer will be marked as the active draw layer.
Returns
DrawLayer— The created layer.
addInfoData(data: InfoData, dataId: string)
Add info data.
Parameters
data(InfoData) — The data to add.dataId(string) — The associated data ID.
bindInfoData(dataId: string)
Bind info data.
Parameters
dataId(string) — The associated data ID.
unbindInfoData()
Unbind info data.
empty()
Empty the layer list.
removeLayersByDataId(dataId: string)
Remove all layers for a specific data.
Parameters
dataId(string) — The data to remove its layers.
removeLayer(layer: ViewLayer | DrawLayer)
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
Fires
LayerGroup#event:removelayer
showTooltip(point: Point2D)
Displays a tooltip in a temporary span. Works with css to hide/show the span only on mouse hover.
Parameters
point(Point2D) — The update point.
removeTooltipDiv()
Remove the tooltip html div.
isPositionInBounds(position: Point): boolean
Can the input position be set on one of the view layers.
Parameters
position(Point) — The input position.
Returns
boolean— True if one view layer accepts the input position.
canScroll(): boolean
Can one of the view layers be scrolled.
Returns
boolean— True if one view layer can be scrolled.
shouldBind(): boolean
Returns whether or not a layer group should have its zoom/pan/etc synced to other views. Used for things like Secondary Capture where there is no meaningful real-world scale.
Returns
boolean— Whether to sync the zoom/pan.
moreThanOne(dim: number): boolean
Does one of the view layer have more than one slice in the given dimension.
Parameters
dim(number) — The input dimension.
Returns
boolean— True if one view layer has more than one slice.
hasAnyLayerWithValidPosition(): boolean
Check if any layer has a valid position.
Returns
boolean— True if any layer has a valid position.
updateLayersToPositionChange(event: CustomEvent)
Update layers (but not the event source layer) to a position change.
Parameters
event(CustomEvent) — The position change event.
getDivToWorldSizeRatio(): number | undefined
Calculate the div to world size ratio needed to fit the largest data.
Returns
number | undefined— The ratio.
fitToContainer(divToWorldSizeRatio: number)
Fit to container: set the layers div to world size ratio.
Parameters
divToWorldSizeRatio(number) — The ratio.
getMaxWorldSize(): Scalar2D | undefined
Get the largest data world (mm) size.
Returns
Scalar2D| undefined— The largest size as {x,y}.
flipScaleZ()
Flip all layers along the Z axis without offset compensation.
addScale(scaleStep: number, center: Point3D)
Add scale to the layers. Scale cannot go lower than 0.1.
Parameters
scaleStep(number) — The scale to add.center(Point3D) — The scale center Point3D.
setScale(newScale: Scalar3D, center?: Point3D)
Set the layers' scale.
Parameters
newScale(Scalar3D) — The scale to apply as {x,y,z}.center(Point3D, optional) — The scale center Point3D.
Fires
LayerGroup#event:zoomchange
addTranslation(translation: Scalar3D)
Add translation to the layers.
Parameters
translation(Scalar3D) — The translation as {x,y,z}.
setOffset(newOffset: Scalar3D)
Set the layers' offset.
Parameters
newOffset(Scalar3D) — The offset as {x,y,z}.
Fires
LayerGroup#event:offsetchange
reset()
Reset the stage to its initial scale and no offset.
Since v0.35, prefer resetZoomPan.
resetZoomPan()
Reset the zoom and pan of all layers.
resetViews()
Reset the position and window level of all view layers.
draw()
Draw the layer.
display(flag: boolean)
Display the layer.
Parameters
flag(boolean) — Whether to display the layer or not.
Events
activelayerchange: CustomEvent
Active layer change event.
Properties
detail(object) — The event detail.detail.value(Array) — The changed value.
removelayer: CustomEvent
Remove layer event.
Properties
detail(object) — The event detail.detail.layerid(string) — The layer id.detail.layergroupid(string) — The layer group id.
zoomchange: CustomEvent
Zoom change event.
Properties
detail(object) — The event detail.detail.value(Array) — The changed value.
offsetchange: CustomEvent
Offset change event.
Properties
detail(object) — The event detail.detail.value(Array) — The changed value.