Constructor
new Viewport(options, readyCallbackopt, failCallbackopt)
- Source:
- Tutorials:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Initialization properties
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
readyCallback |
function |
<optional> |
Called when the slide has finished loading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
failCallback |
function |
<optional> |
Called when loading the slide failed |
Members
barcodeControl :AssociatedImage
- Source:
The barcode control
Type:
colorAdjustmentsControl :ColorAdjustment
- Source:
The color adjustment control
Type:
dimensionsControl :DimensionSelector
- Source:
The dimension selector control
Type:
layerSwitcher :LayerSwitch
- Source:
The server side annotation layers control
Type:
map
- Source:
The underlying OpenLayers map
overviewControl :Overview
- Source:
The overview control
Type:
rotationControl :RotationControl
- Source:
The rotation control
Type:
Methods
addTileTransformer(transformer)
- Source:
Adding tile transformer to the list of transformers
Parameters:
Name | Type | Description |
---|---|---|
transformer |
PMA.UI.View.tileTransformer | function that gets pixels as an input parameter and returns nothing, it should adjust pixels values directly in array from parameters |
calculateArea(geom) → {number}
- Source:
Calculates the area of an OpenLayers geometry
Parameters:
Name | Type | Description |
---|---|---|
geom |
ol.geom | The geometry to calculate the area of |
Returns:
The area in squared microns or zero if resolution information is not available
- Type
- number
calculateLength(geom) → {number}
- Source:
Calculates the length of an OpenLayers geometry
Parameters:
Name | Type | Description |
---|---|---|
geom |
ol.geom | The geometry to calculate the length of |
Returns:
The length in microns or zero if resolution information is not available
- Type
- number
fitToExtent(extent, constrainResolution)
- Source:
Fits the view to supplied extent
Parameters:
Name | Type | Description |
---|---|---|
extent |
ol.geom.SimpleGeometry | Array.<number> | An array of numbers representing an extent: `[minx, miny, maxx, maxy]` or a simple geometry |
constrainResolution |
bool | Whether to fit at any resolution even outside the allowed range |
focusToAnnotation(annotationId)
- Source:
Pans and zooms the viewer appropriately to focus around an annotation
Parameters:
Name | Type | Description |
---|---|---|
annotationId |
number | The id of the annotation to which the viewport should focus |
formatArea(area) → {number}
- Source:
Formats the area of an OpenLayers geometry
Parameters:
Name | Type | Description |
---|---|---|
area |
number | The area of the geometry to format |
Returns:
The string with the formatted area and unit
- Type
- number
formatLength(length) → {number}
- Source:
Formats the length of an OpenLayers geometry
Parameters:
Name | Type | Description |
---|---|---|
length |
number | The length of the geometry to format |
Returns:
The string with the formatted length and unit
- Type
- number
getActiveChannels() → {Array}
- Source:
Gets an array that contains the indices of the currently active channels
Returns:
- Type
- Array
getActiveLayer() → {number}
- Source:
Gets the index of the active layer (z-stack)
Returns:
- Type
- number
getActiveServerUrl() → {string}
- Source:
Gets the URL of the PMA.core server currently connected to
Returns:
- Type
- string
getActiveTimeFrame() → {number}
- Source:
Gets the index of the active time frame
Returns:
- Type
- number
getAnnotationFormattedLabel(featureopt) → {String}
- Source:
Returns the text of an annotation. This method is not meant to be used by PMA.UI consumers.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
feature |
ol.Feature |
<optional> |
The ol.Feature associated with the annotation |
Returns:
The annotation text
- Type
- String
getAnnotationLabelsVisible()
- Source:
Gets a value indicating whether or not the text of the annotations is rendered in the viewer
getAnnotations() → {Array}
- Source:
Returns all the annotations
Returns:
An array of ol.Feature instances
- Type
- Array
getAnnotationsLayersNames()
- Source:
Returns the supported annotation layer names for the loaded slide
getAnnotationStyle(styleopt, featureopt) → {function}
- Source:
Returns a style that contatins the text of an annotation. This method is not meant to be used by PMA.UI consumers.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
style |
ol.style.Style |
<optional> |
The ol.style.Style associated with the annotation |
feature |
ol.Feature |
<optional> |
The ol.Feature associated with the annotation |
Returns:
The annotation style function
- Type
- function
getAnnotationTextStyle(featureopt) → {ol.style.Text}
- Source:
Returns the text style to be used to render the text part (labels) of annotations. This method is not meant to be used by PMA.UI consumers.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
feature |
ol.Feature |
<optional> |
The ol.Feature associated with the annotation |
Returns:
A text style instance
- Type
- ol.style.Text
getBrightness() → {number}
- Source:
Gets the current brightness value of the viewer
Returns:
- Type
- number
getContrast() → {number}
- Source:
Gets the current contrast value of the viewer
Returns:
- Type
- number
getControlsConfiguration() → {Array.<Viewport~ControlConfiguration>}
- Source:
Gets the current configuration of the controls of the viewport
Returns:
configuration - The control configuration object
- Type
- Array.<Viewport~ControlConfiguration>
getCurrentExtent(unrotate) → {Array.<number>}
- Source:
Gets the currently visible extent
Parameters:
Name | Type | Description |
---|---|---|
unrotate |
bool | Whether to unrotate the extend back to axis aligned |
Returns:
An array of numbers representing an extent: `[minx, miny, maxx, maxy]`
- Type
- Array.<number>
getFlip() → {Viewport~flipOptions}
- Source:
Gets the image flip options
Returns:
- Type
- Viewport~flipOptions
getGamma() → {number}
- Source:
Gets the current gamma value of the viewer
Returns:
- Type
- number
getPosition() → {Viewport~position}
- Source:
Gets the current viewport position
Returns:
position
- Type
- Viewport~position
getSessionID() → {string}
- Source:
Gets the currently used sessionID
Returns:
- Type
- string
getSnapshot(formatopt) → {Promise.<Blob>}
- Source:
Generates an image with a snapshot of the current viewport and saves it if format is "png" or "jpg"
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
format |
string |
<optional> |
png
|
The snapshot image format, one of "png", "jpg", "blob" |
Returns:
A promise to the blob object
- Type
- Promise.<Blob>
getSnapshotParameters() → {PMA.UI.Components~snapshotParameters}
- Source:
Generates the parameters required for generating a snapshot url using getSnapshotUrl
Returns:
- Type
- PMA.UI.Components~snapshotParameters
getSnapshotUrl(download, objectiveResolutionopt, formatopt, drawScaleBaropt) → {PMA.UI.View~SnapshotResult}
- Source:
Generates a URL where a snapshot of the current viewport is rendered
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
download |
boolean | True to prompt the user to save the snapshot instead of viewing it within the browser | ||
objectiveResolution |
PMA.UI.View.ObjectiveResolutions |
<optional> |
The desired objective resolution. If not passed the viewport scale will be used | |
format |
string |
<optional> |
jpg
|
The snapshot image format |
drawScaleBar |
boolean |
<optional> |
false
|
Whether or not to draw a scalebar |
Returns:
- An object containing the url, width and height of the final image
getTileTransformers() → {Array.<PMA.UI.View.tileTransformer>}
- Source:
Gets the current list of tile transformers
Returns:
- Type
- Array.<PMA.UI.View.tileTransformer>
getViewportCoordinates() → {Array.<Array.<number>>}
- Source:
Generates a rectangle for the current view
Returns:
An array of the x, y coordinates of the 4 corners of viewing rectangle
- Type
- Array.<Array.<number>>
hideGrid()
- Source:
Hides the measurement grid if visible or does nothing
initializeFeatures(annotations, projection)
- Source:
Converts an array of pma.core annotations to open layers features
Parameters:
Name | Type | Description |
---|---|---|
annotations |
Array.<Viewport~annotation> | An annotation array as returned by pma.core |
projection |
Object | The projection used for diplay |
listen(eventName, callback)
- Source:
Attaches an event listener to the viewer
Parameters:
Name | Type | Description |
---|---|---|
eventName |
PMA.UI.View.Events | The name of the event to listen to |
callback |
function | The function to call when the event occurs |
login(username, password)
- Source:
Authenticates and forces the viewer to redraw
Parameters:
Name | Type | Description |
---|---|---|
username |
string | |
password |
string |
redraw()
- Source:
Forces the viewer to refresh
reloadAnnotations(readyCallbackopt, fingerprintopt)
- Source:
Reloads annotations from the server
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
readyCallback |
function |
<optional> |
Called when the annotations have finished loading |
fingerprint |
string |
<optional> |
If exists, will reload annotations by fingerprint |
setActiveChannels(channels)
- Source:
Sets the active channels
Parameters:
Name | Type | Description |
---|---|---|
channels |
Array | An array that contains the indices of the channels to display |
Fires:
- PMA.UI.View.Events#event:DimensionsChanged
setActiveLayer(layer)
- Source:
Sets the active layer (z-stack)
Parameters:
Name | Type | Description |
---|---|---|
layer |
number | The index of the layer to activate |
Fires:
- PMA.UI.View.Events#event:DimensionsChanged
setActiveTimeFrame(timeframe)
- Source:
Sets the active time frame
Parameters:
Name | Type | Description |
---|---|---|
timeframe |
number | The index of the time frame to activate |
Fires:
- PMA.UI.View.Events#event:DimensionsChanged
setBrightness(brightness)
- Source:
Sets the brightness of the viewer
Parameters:
Name | Type | Description |
---|---|---|
brightness |
number |
setBrightnessContrastGamma(brightness, contrast, gamma)
- Source:
Sets the brightness and contrast of the viewer
Parameters:
Name | Type | Description |
---|---|---|
brightness |
number | |
contrast |
number | |
gamma |
number |
setChannelRenderingOptions(options)
- Source:
Sets the rendering options for a channel
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | An object that determines the channel and the options to be set
Properties
|
setContrast(contrast)
- Source:
Sets the contrast of the viewer
Parameters:
Name | Type | Description |
---|---|---|
contrast |
number |
setControlsConfiguration(configuration)
- Source:
Sets a new configuration for the controls of the viewport
Parameters:
Name | Type | Description |
---|---|---|
configuration |
Array.<Viewport~ControlConfiguration> | The control configuration object |
setFlip(horizontally, vertically)
- Source:
Sets the image flip options
Parameters:
Name | Type | Description |
---|---|---|
horizontally |
bool | Whether or not to flip the image horizontally |
vertically |
bool | Whether or not to flip the image vertically |
setGamma(gamma)
- Source:
Sets the gamma of the viewer
Parameters:
Name | Type | Description |
---|---|---|
gamma |
number |
setPosition(position)
- Source:
sets the current viewport position
Parameters:
Name | Type | Description |
---|---|---|
position |
Viewport~position |
setSessionID(sessionID)
- Source:
Overrides the current sessionID and forces the viewer to redraw
Parameters:
Name | Type | Description |
---|---|---|
sessionID |
string |
setTileTransformers(transformers)
- Source:
Setting list of tile transformers
Parameters:
Name | Type | Description |
---|---|---|
transformers |
Array.<PMA.UI.View.tileTransformer> | list of transformer function that gets pixels as an input parameter and returns nothing, it should adjust pixels values directly in array from parameters |
showAnnotation(id, show)
- Source:
Toggles the visibility of an annotation
Parameters:
Name | Type | Description |
---|---|---|
id |
number | The id of the annotation to hide or show |
show |
boolean | True to show the annotation, otherwise hide it |
showAnnotations(show)
- Source:
Toggles the visibility of the annotations layer in total
Parameters:
Name | Type | Description |
---|---|---|
show |
boolean | True to show the annotations, otherwise hide them |
showAnnotationsByFingerprint(show)
- Source:
Toggles the visibility of annotations loaded by fingerprint and loads them if not already loaded
Parameters:
Name | Type | Description |
---|---|---|
show |
boolean | True to show the annotation, otherwise hide it |
showAnnotationsLabels(visible, showMeasurementsopt)
- Source:
Toggles the text of the annotations visibility
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
visible |
boolean | True to show the annotation labels, otherwise hide them | |
showMeasurements |
boolean |
<optional> |
True to show the annotation measurements, otherwise hide them |
showGrid(size)
- Source:
Shows a measurement grid
Parameters:
Name | Type | Description |
---|---|---|
size |
Array.<number> | The size of the grid cells in micrometers |
unlisten(eventName, callback) → {bool}
- Source:
Detaches an event listener from the viewer
Parameters:
Name | Type | Description |
---|---|---|
eventName |
PMA.UI.View.Events | The name of the event to remove the callback from |
callback |
function | The function to remove from the event listener list |
Returns:
Whether or not the callback was actually found and removed
- Type
- bool
updateSize()
- Source:
Forces the viewer to recalculate the viewport size
zoomToObjective(objective)
- Source:
Zooms the view to a specific objective
Parameters:
Name | Type | Description |
---|---|---|
objective |
string | 1:1, 1X, 2X, 5X, 10X etc. |
Type Definitions
annotation
- Source:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
AnnotationID |
Number | The annotation id | |
LayerID |
Number | The layer id | |
Geometry |
string | The annotation geometry in wkt format | |
Notes |
string |
<optional> |
Optional notes for the annotation |
Classification |
string |
<optional> |
Optional classification string (Necrosis, tumor etc) |
Color |
string |
<optional> |
Optional color |
CreatedBy |
string |
<optional> |
Optional created by string |
UpdateInfo |
string |
<optional> |
Optional update info |
Updatedby |
string |
<optional> |
Optional updated by info |
FillColor |
string |
<optional> |
Optional fill color |
Dimensions |
Number |
<optional> |
Optional dimensionality of the annotation |
An annotation as returned by pma.core
annotationOptions
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
visible |
boolean |
<optional> |
true
|
Whether or not to display the loaded annotations |
labels |
boolean |
<optional> |
false
|
Whether or not to render the text label of each annotation in the viewer |
imageBaseUrl |
boolean |
<optional> |
""
|
The base URL from which to load images |
imageScale |
number |
<optional> |
NaN
|
Scale factor for images |
alwaysDisplayInMicrons |
boolean |
<optional> |
false
|
Whether or not to automatically select the appropriate units for annotations (μm(^2) or mm(^2)) depending on the value |
showMeasurements |
boolean |
<optional> |
true
|
Whether to show the length and area of an annotation |
loadAnnotationsByFingerprint |
boolean |
<optional> |
false
|
Whether to load annotations based on image's fingerprint |
Annotation display options
Type:
- Object
attributionOptions
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
html |
string | The HTML contents to add inside the attribution container element | ||
className |
string |
<optional> |
"ol-attr"
|
The CSS class to assign to the attribution container element |
Attribution display options
Type:
- Object
ControlConfiguration
- Source:
Properties:
Name | Type | Description |
---|---|---|
control |
Controls | The control to configure |
visible |
boolean | The visibility of the control |
collapsed |
boolean | Whether the control is collapsed or not |
An object for configuring the visible and collapse state of a control
customButton
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string | The title of the button | ||
content |
string | The inner html of the button | ||
class |
string | The class of the button | ||
location |
ButtonLocations |
<optional> |
ButtonLocations.S
|
The location in the viewport of the custom button |
callback |
function | The callback to call when the button is clicked with this referring to the viewer |
A custom button to be added to the viewer
Type:
- Object
filenameCallback(options) → {string}
- Source:
Function that returns a file name to display in the viewer
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
- Type
- string
flipOptions
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
horizontally |
boolean |
<optional> |
false
|
Whether or not to flip the image horizontally |
vertically |
boolean |
<optional> |
false
|
Whether or not to flip the image vertically |
Image flip options
Type:
- Object
fov
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
extent |
Array | The extent of the viewport [minx, miny, maxx, maxy] | ||
rotation |
number | The rotation of the viewport | ||
constrainResolution |
bool |
<optional> |
Whether to contain the resolution to allowed values when fitting to extent | |
channels |
Array |
<optional> |
The selected channels | |
layer |
number |
<optional> |
0
|
The selected layer |
timeframe |
number |
<optional> |
0
|
The selected timeframe |
Viewport Field of view
Type:
- Object
position
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
center |
Array | The x and y coordinates of the center point | ||
zoom |
number | The zoom level. Can be omitted if resolution is specified | ||
resolution |
number |
<optional> |
Can be omitted if zoom is specified | |
rotation |
number |
<optional> |
0
|
Viewport position
Type:
- Object
SnapshotCoordinates
- Source:
Properties:
Name | Type | Description |
---|---|---|
x |
Integer | The x coordinate |
y |
Integer | The y coordinate |
w |
Integer | The width |
h |
Integer | The height |
scale |
Number | The scale of the current view in radians |
rotation |
Number | The rotation of the current view in radians |
flip |
Viewport~flipOptions | Whether the image is flipped |
An object for configuring the visible and collapse state of a control