MeVisLab Web Toolkit Reference
Loading...
Searching...
No Matches
MeVisLab Web ToolKit

Contents

  1. Introduction
  2. Integration into HTML pages
  3. Application Structure
  4. Application Initialization
  5. Communication
  6. Writing Plugins

Introduction

The MeVisLab Web ToolKit allows for the creation of web based remote clients for MeVisLab applications.

It is a JavaScript framework that runs in HTML5 compatible browsers. Its main features are:

  • access to synchronized field values
  • display of remotely rendered images
  • HTML generation from MDL GUI descriptions
  • extensible via JavaScript plugins

Application Structure

The MeVisLab Web Toolkit provides web applications with a given structure. First, there is an object that loads the JavaScript files of the toolkit and handles its initialization: MLAB.GUI.Application. Next, the module creation, initialization, and communication is managed by MLAB.Core.ModuleContext. It contains an MLAB.Core.Module object, which represents the instantiated module in MeVisLab and provides access to the fields (MLAB.Core.Field). The communication with MeVisLab is implemented with a web socket in MLAB.Core.RemoteManager.

Application structure

Integration into HTML pages

The integration of the MeVisLab Web Toolkit into an HTML page is done by first including the file MeVisLab/Standard/Sources/Web/application/js/gui/Application.js. The exact URL to it depends on the web server configuration and relative location of the target HTML file. The Web Toolkit is initialized by calling MLABApp.runApplication(). It expects the name of the application, the name of the application macro module, and an optional settings dictionary as arguments. Plugins may also evaluate additional arguments.

General application arguments are:

nametypedescription
debugRemoteMessagesno value requiredEnables debugging remote messages. See Debugging Features.
diagnosisno value requiredEnables logging of diagnosis messages to the console. See Debugging Features.
pluginsSTRING LISTAdditional plugins to load (comma separated list).
urlToMLABRootSTRINGThe root url to the MeVisLab packages
showIDEno value requiredShow the MeVisLab IDE on loading.
disableBinaryMessagesno value requiredNo binary messages will be send.

Arguments for the connection settings are:

nametypedefault
webSocketHostNameHOSTNAMEwindow.location.hostname
webSocketPortINTEGERread from http:///Settings/webSocketPort
applicationSTRING
authTokenSTRING
connectionTimeoutIntervalINTEGER10000
requestTimeoutIntervalINTEGER5000
For details see \ref MLAB.Core.ConnectionSettings.

Example:

<html>
<head>
<script type="text/javascript" src="MeVisLab/Standard/Sources/Web/application/js/gui/Application.js"></script>
<script type="text/javascript">
var applicationName = "ExampleApplication"
var macroName = "ExampleMacro"
var arguments = {}
arguments["diagnosis"] = "" // enables diagnosis messages
arguments["urlToMLABRoot"] = "http://example.server.org/ExampleApplication"
MLABApp.runApplication(applicationName, macroName, arguments)
</script>
</head>
<body>
</body>
</html>

Arguments for the render settings are:

nametypedefaultdescription
interactiveImageTypeBMP, JPG, or PNGJPGSets which image format is used during interaction.
interactiveJpgQuality0..10075Sets the JPG quality of images during interactions.
interactiveScaling0.0..1.01.0Sets the scale factor for the images. A value < 1.0 will reduce the image size and thus reduces the required bandwidth.
highQualityImageTypeBMP, JPG, or PNGPNGSets which image format is used for the high quality images after the interaction has finished.
highQualityJpgQuality0..100100Sets the JPG quality of images after the interaction has finished.
highQualityDelayInMsINTEGER500Sets the delay from sending the last interactive image until the high quality image is send.
minUpdateDelayInMsINTEGER20Sets the lower bound of the stream update delay. New images are not sent more frequently than this delay.
maxUpdateDelayInMsINTEGER200Sets the upper bound of the stream update delay. New images are not sent less frequently than this delay.
maxPendingImagesINTEGER3Sets the maximum number of images that the server may stream without the acknowledgment of the client.
streaming0 or 11Sets if streaming is enabled (1) or disabled (0).
useTiling0 or 11Enable (1) or disable (0) partial (tiled) updates.
supportHiDPI0 or 10Enable (1) or disable (0) support for high resolution displays (enabling this will greatly increase bandwidth requirements for high resolution displays).

The MeVisLab Web ToolKit currently does not support auto-resizing nor the automatic update of the devicePixelRatio. As a workaround, define a ResizeObserver, set using hiPDI again, and manually update the devicePixelRatio. Example:

<html>
<head>
this.renderingWidget.setSupportHiDPI(true)
if (this.renderingWidget._slave !== undefined) {
this.renderingWidget._slave.setDevicePixelRatio(this.renderingWidget._devicePixelRatio)
}
this.renderingWidget.resizeViewport(newvalues...)
</head>
<body>
</body>
</html>

Application Initialization

The application is initialized by calling MLABApp.runApplication() in an HTML document. It loads and initializes the toolkit, and creates an MLAB.Core.ModuleContext object. The module context contains an MLAB.Core.RemoteManager object, which establishes a web socket connection with MeVisLab. Then it requests the creation of the application macro from MeVisLab, which in turn responds by sending the description of the module (name and type of its fields). After an additional request, the MDL description is also send. Any JavaScript plugin specified in the MDL will be loaded and initialized now. Finally, HTML elements are generated for the MDL controls.

Application initialization

Communication

The toolkit communicates with MeVisLab on a server using remote messages via a web socket connection. The communication is bidirectional, i.e. the toolkit and MeVisLab can both send and receive messages. For example, field values are automatically synchronized by using the MLAB.Core.ModuleSetFieldValuesMessage. Certain messages are however only used in one direction: rendered images and RPCs (remote procedure calls) are only sent from MeVisLab to the toolkit, while generic requests and mouse/key events are only sent from the toolkit to MeVisLab.

MeVisLab Web Toolkit communication

Writing Plugins

Plugins extend the MeVisLab Web Toolkit. They can customize the look and behavior of a web application. For example, they can provide custom CSS rules and replace existing widget implementations.

A plugin consists of at least one JavaScript file. Optionally, it may provide additional CSS and JavaScript files. In this case, it should provide a class derived from MLAB.GUI.PluginBase. The plugin can evaluate the application arguments in its constructor. The setup function loads the required css files and and Javascript modules using requirejs. The onload-callback function must be called after requirejs has finished loading the plugin resources. Below is a general example for writing a plugin. Other examples can be found in the MeVisLab/Private package:

  • Sources/Web/application/js/yui/Plugin.js
  • Sources/Web/application/js/jquery/Plugin.js

ExamplePlugin.js:

define({
load: function(name, parentRequire, onload, config) {
MLAB.createNamespace("Example")
MLAB.Example.deriveClass("ExamplePlugin", MLAB.GUI.PluginBase, {
ExamplePlugin: function() {
MLAB.Example.ExamplePlugin.super.constructor.call(this)
// optional handling of arguments from the config.applicationArguments dictionary
},
setup: function(finishLoadingCallback) {
var styles = ["css/example.css", ...]
this.loadStyles(styles)
require(["./ExampleModule1", "./ExampleModule2", ..], (function() {
// do something after all resources were loaded and call the finish loading callback
finishLoadingCallback(this)
}).bind(this))
},
})
var plugin = new MLAB.Example.ExamplePlugin()
plugin.setup(onload)
},
})