|
MeVisLab Web Toolkit Reference
|
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:
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.
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:
| name | type | description |
|---|---|---|
| debugRemoteMessages | no value required | Enables debugging remote messages. See Debugging Features. |
| diagnosis | no value required | Enables logging of diagnosis messages to the console. See Debugging Features. |
| plugins | STRING LIST | Additional plugins to load (comma separated list). |
| urlToMLABRoot | STRING | The root url to the MeVisLab packages |
| showIDE | no value required | Show the MeVisLab IDE on loading. |
| disableBinaryMessages | no value required | No binary messages will be send. |
Arguments for the connection settings are:
| name | type | default |
|---|---|---|
| webSocketHostName | HOSTNAME | window.location.hostname |
| webSocketPort | INTEGER | read from http:// |
| application | STRING | |
| authToken | STRING | |
| connectionTimeoutInterval | INTEGER | 10000 |
| requestTimeoutInterval | INTEGER | 5000 |
Example:
Arguments for the render settings are:
| name | type | default | description |
|---|---|---|---|
| interactiveImageType | BMP, JPG, or PNG | JPG | Sets which image format is used during interaction. |
| interactiveJpgQuality | 0..100 | 75 | Sets the JPG quality of images during interactions. |
| interactiveScaling | 0.0..1.0 | 1.0 | Sets the scale factor for the images. A value < 1.0 will reduce the image size and thus reduces the required bandwidth. |
| highQualityImageType | BMP, JPG, or PNG | PNG | Sets which image format is used for the high quality images after the interaction has finished. |
| highQualityJpgQuality | 0..100 | 100 | Sets the JPG quality of images after the interaction has finished. |
| highQualityDelayInMs | INTEGER | 500 | Sets the delay from sending the last interactive image until the high quality image is send. |
| minUpdateDelayInMs | INTEGER | 20 | Sets the lower bound of the stream update delay. New images are not sent more frequently than this delay. |
| maxUpdateDelayInMs | INTEGER | 200 | Sets the upper bound of the stream update delay. New images are not sent less frequently than this delay. |
| maxPendingImages | INTEGER | 3 | Sets the maximum number of images that the server may stream without the acknowledgment of the client. |
| streaming | 0 or 1 | 1 | Sets if streaming is enabled (1) or disabled (0). |
| useTiling | 0 or 1 | 1 | Enable (1) or disable (0) partial (tiled) updates. |
| supportHiDPI | 0 or 1 | 0 | Enable (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:
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.
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.
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:
ExamplePlugin.js: