Viewport

.View. Viewport

new Viewport(options, readyCallbackopt, failCallbackopt)

Source:
Tutorials:
Creates a new viewer
Parameters:
Name Type Attributes Description
options Object Initialization properties
Properties
Name Type Attributes Default Description
caller string Downstream application identifier
element string | HTMLElement The element that hosts the viewer. It can be either a valid CSS selector or an HTMLElement instance
image string The path or UID of the image to load
serverUrls Array An array of one or more PMA.core URLs to attempt to connect to. The viewer will loop through all the provided URLs until an accessible one is found.
username string <optional>
The PMA.core username to use to authenticate, in order to obtain a sessionID. If a username and password pair is provided, then a sessionID is not required.
password string <optional>
The PMA.core password to use to authenticate, in order to obtain a sessionID. If a username and password pair is provided, then a sessionID is not required.
sessionID string <optional>
The PMA.core sessionID to use to interact with PMA.core. If a sessionID is provided, then a username and password pair is not required.
keyboardPanFactor Number <optional>
0.5 A factor to calculate pan delta when pressing a keyboard arrow. The actual pan in pixels is calculated as keyboardPanFactor * viewportWidth.
theme PMA.UI.View.Themes <optional>
"default" The theme to use
overview boolean | Object <optional>
true Whether or not to display an overview map
Properties
Name Type Attributes Description
collapsed boolean <optional>
Whether or not to start the overview in collapsed state
dimensions boolean | Object <optional>
true Whether or not to display the dimensions selector for images that have more than one channel, z-stack or timeframe
Properties
Name Type Attributes Description
collapsed boolean <optional>
Whether or not to start the dimensions selector in collapsed state
flip PMA.UI.View.Viewport~flipOptions <optional>
Image flip options
barcode boolean | Object <optional>
false Whether or not to display the image's barcode if it exists
Properties
Name Type Attributes Description
collapsed boolean <optional>
Whether or not to start the barcode in collapsed state
rotation Number <optional>
Rotation in steps of 90 degrees
loadingBar boolean | Object <optional>
true Whether or not to display a loading bar while the image is loading
position PMA.UI.View.Viewport~position <optional>
The initial position of the viewport within the image
snapshot boolean <optional>
false Whether or not to display a button that generates a snapshot image
annotations PMA.UI.View.Viewport~annotationOptions <optional>
Annotation options
digitalZoomLevels Number <optional>
0 The number of digital zoom levels to add
scaleLine boolean <optional>
true Whether or not to display a scale line when resolution information is available
colorAdjustments boolean <optional>
false Whether or not to add a control that allows color adjustments
annotationsLayers boolean | Object <optional>
true Whether or not to show server side annotation layers
Properties
Name Type Attributes Default Description
collapsed boolean <optional>
false Whether or not to show the annotation layers control collapsed
loadLayers boolean <optional>
false Whether or not to show all the annotation layers control on slide load
magnifier Object | boolean <optional>
false Whether or not to show the magnifier control
Properties
Name Type Attributes Description
collapsed Object | boolean <optional>
Whether or not to show the magnifier control in collapsed state
grid Object <optional>
Options for measurement grid
Properties
Name Type Attributes Description
size Array.<number> <optional>
Grid cell width and height in micrometers
filename string | PMA.UI.View.Viewport~filenameCallback <optional>
A string to display as the file name or a callback function. If no value is supplied, no file name is displayed.
attributions boolean | PMA.UI.View.Viewport~attributionOptions <optional>
Whether or not to display Pathomation attribution in the viewer
customButtons Array.<PMA.UI.View.Viewport~customButton> <optional>
An array of one or more custom buttons to add to the viewer
fov PMA.UI.View.Viewport~fov <optional>
A specified field of view to load
zoomSlider boolean <optional>
Whether or not to show the zoomSlider control
readyCallback function <optional>
Called when the slide has finished loading
failCallback function <optional>
Called when loading the slide failed

Members

barcodeControl :PMA.UI.View.Controls.AssociatedImage

Source:
The barcode control
Type:

colorAdjustmentsControl :PMA.UI.View.Controls.ColorAdjustment

Source:
The color adjustment control
Type:

dimensionsControl :PMA.UI.View.Controls.DimensionSelector

Source:
The dimension selector control
Type:

layerSwitcher :PMA.UI.View.Controls.LayerSwitch

Source:
The server side annotation layers control
Type:

map

Source:
The underlying OpenLayers map

overviewControl :PMA.UI.View.Controls.Overview

Source:
The overview control
Type:

Methods

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.<PMA.UI.View.Viewport~ControlConfiguration>}

Source:
Gets the current configuration of the controls of the viewport
Returns:
configuration - The control configuration object
Type
Array.<PMA.UI.View.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() → {PMA.UI.View.Viewport~flipOptions}

Source:
Gets the image flip options
Returns:
Type
PMA.UI.View.Viewport~flipOptions

getGamma() → {number}

Source:
Gets the current gamma value of the viewer
Returns:
Type
number

getPosition() → {PMA.UI.View.Viewport~position}

Source:
Gets the current viewport position
Returns:
position
Type
PMA.UI.View.Viewport~position

getSessionID() → {string}

Source:
Gets the currently used sessionID
Returns:
Type
string

getSnapshot(formatopt)

Source:
Generates an image with a snapshot of the current viewport
Parameters:
Name Type Attributes Default Description
format string <optional>
png The snapshot image format, one of "png", "jpg"

getSnapshotCoordinates() → {PMA.UI.View.Viewport~SnapshotCoordinates}

Source:
Generates viewing coordinates for the current view
Returns:
An object with the current view coordinates
Type
PMA.UI.View.Viewport~SnapshotCoordinates

getSnapshotUrl(download, formatopt)

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
format string <optional>
jpg The snapshot image format

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.<PMA.UI.View.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)

Source:
Reloads annotations from the server
Parameters:
Name Type Attributes Description
readyCallback function <optional>
Called when the annotations have finished loading

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:

setActiveLayer(layer)

Source:
Sets the active layer (z-stack)
Parameters:
Name Type Description
layer number The index of the layer to activate
Fires:

setActiveTimeFrame(timeframe)

Source:
Sets the active time frame
Parameters:
Name Type Description
timeframe number The index of the time frame to activate
Fires:

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

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.<PMA.UI.View.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 PMA.UI.View.Viewport~position

setSessionID(sessionID)

Source:
Overrides the current sessionID and forces the viewer to redraw
Parameters:
Name Type Description
sessionID string

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

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
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 PMA.UI.Types.Controls The control to configure
boolean visible - The visibility of the control
boolean collapsed - 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 PMA.UI.View.ButtonLocations <optional>
PMA.UI.View.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
Name Type Description
serverUrl string The URL of the current PMA.core server
fileName string The full path of the currently loaded image
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 PMA.UI.View.Viewport~flipOptions Whether the image is flipped
An object for configuring the visible and collapse state of a control