This builds on the 2D Example app
by creating a pixel value custom mouse adaptor and line measurement adaptor,
and creating a hotspot using the override mouse adaptor.
This example includes
use of Fovia.UI.HTMLViewport2D w/ repaintable viewports for rendering contents
use of setCustomMouseAdaptor to create custom pixel value mouse adaptor and line measurement adaptor
use of setOverrideMouseAdaptor to create a hotspot in the window to reset the viewport
To run the example, click http://localhost:8088/apps/hellofovia/mouseadaptors2d.html
HTMLViewport
The only different from the 2D Example app is that the HTMLViewport constructor uses an optional fourth boolean parameter to indicate that this viewport is repaintable. If it is repaintable, an internal copy of the last rendered image is preserved so the client can initiate a repaint(),
which causes the last rendered image to be painted on the canvas, and
allows the client application to trigger a redraw of the canvas without
a round trip to the server.
The Fovia.UI.HTMLViewport2D defines a set of default mouse and touch adaptors that are mapped
to specific UI actions. Specifically:
Default Mouse Operations
left-click -- window/level shift-left-click -- page through images (does not skip images) right-click -- pan shift-right-click -- zoom mouse-wheel -- page or when pressed, scroll (top of viewport is first image and bottom of viewport is last image)
The example app creates a pixelValue adaptor and maps it to ctrl-left-click which then prints out the pixel value from any given
location into the JavaScript console and in the DICOM overlay.
Alt-left-click installed a line measurement adaptor.
SetOverrideMouseAdaptor
It is sometimes useful to install a special mouse adaptor allows for an
override of all other adaptors (regardless of specific
mouse/keyboard/touch mapping). For example, defining a hot spot
or an on-screen slider control that should become active when the mouse
or finger is over the region. The design pattern is the same
except that the return value should be false to consume the event, or
true to propagate the event to the default or custom adaptor currently
defined based on the mouse/keyboard/touch mapping. The override
interface can be installed through Fovia.UI.HTMLViewport2D.setOverrideMouseAdaptor() (or Fovia.UI.HTMLViewport2D.setOverrideTouchAdaptor() for touch).
Mouse Adaptors
This builds on the 2D Example app by creating a pixel value custom mouse adaptor and line measurement adaptor, and creating a hotspot using the override mouse adaptor.This example includes
To run the example, click http://localhost:8088/apps/hellofovia/mouseadaptors2d.html
HTMLViewport
The only different from the 2D Example app is that the HTMLViewport constructor uses an optional fourth boolean parameter to indicate that this viewport is repaintable. If it is repaintable, an internal copy of the last rendered image is preserved so the client can initiate a repaint(), which causes the last rendered image to be painted on the canvas, and allows the client application to trigger a redraw of the canvas without a round trip to the server.
The Fovia.UI.HTMLViewport2D defines a set of default mouse and touch adaptors that are mapped to specific UI actions. Specifically:
Default Mouse Operations
left-click -- window/level
shift-left-click -- page through images (does not skip images)
right-click -- pan
shift-right-click -- zoom
mouse-wheel -- page or when pressed, scroll (top of viewport is first image and bottom of viewport is last image)
Default Touch Operations
single-touch -- page through images
two-finger touch -- zoom/pan
three-finger touch -- window/level
SetMouseAdaptor
The default mapping of mouse operations can be changed through Fovia.UI.HTMLViewport2D.setMouseAdaptor() (or Fovia.UI.HTMLViewport2D.setTouchAdaptor() for touch).
HTMLViewport2D.setMouseAdaptor().(Fovia.UI.MouseAdaptors, Fovia.UI.MouseButton, Fovia.UI.KeyboardModifier);
HTMLViewport2D.setTouchAdaptor().(Fovia.UI.TouchAdaptors, Fovia.UI.TouchEvents, Fovia.ViewType);
Use these methods to change the default behavior if desired.
SetCustomMouseAdatpor
A custom mouse operations installed can be changed through Fovia.UI.HTMLViewport2D.setCustomMouseAdaptor() (or Fovia.UI.HTMLViewport2D.setCustomTouchAdaptor() for touch).
HTMLViewport2D.setCustomMouseAdaptor().(Fovia.UI.MouseAdaptorInterface, Fovia.UI.MouseButton, Fovia.UI.KeyboardModifier);
HTMLViewport2D.setCustomTouchAdaptor().(Fovia.UI.TouchAdaptorInterface, Fovia.UI.TouchEvents);
The example app creates a pixelValue adaptor and maps it to ctrl-left-click which then prints out the pixel value from any given location into the JavaScript console and in the DICOM overlay.
Alt-left-click installed a line measurement adaptor.
SetOverrideMouseAdaptor
It is sometimes useful to install a special mouse adaptor allows for an override of all other adaptors (regardless of specific mouse/keyboard/touch mapping). For example, defining a hot spot or an on-screen slider control that should become active when the mouse or finger is over the region. The design pattern is the same except that the return value should be false to consume the event, or true to propagate the event to the default or custom adaptor currently defined based on the mouse/keyboard/touch mapping. The override interface can be installed through Fovia.UI.HTMLViewport2D.setOverrideMouseAdaptor() (or Fovia.UI.HTMLViewport2D.setOverrideTouchAdaptor() for touch).
HTMLViewport2D.setOverrideMouseAdaptor().(Fovia.UI.MouseAdaptorInterface);
HTMLViewport2D.setOverrideTouchAdaptor().(Fovia.UI.TouchAdaptorInterface);
The example app defines a hot spot region in left corner of the window.