Main Content

images.stack.browser.CrosshairMovingEventData class

Package: images.stack.browser

Event data passed when Crosshair ROI is moving

Description

The images.stack.browser.CrosshairMovingEventData class is the class passed to listeners when the crosshair in an orthosliceViewer object is moved interactively. The orthosliceViewer object triggers an event using the notify handle class method. MATLAB® assigns values to the properties of an images.stack.browser.CrosshairMovingEventData object and passes that object to the listener callback function (the event handler). Programmatic positioning of the crosshair does not trigger this event.

The images.stack.browser.CrosshairMovingEventData class is a handle class.

Creation

The notify handle class method creates an images.stack.browser.CrosshairMovingEventData object when called to trigger an event.

Properties

expand all

Event source, specified as a handle to the object that triggered the event.

Name of the event, specified as a character vector.

Position before the crosshair moved, specified as a three-element numeric vector of the form [x y z].

Position after crosshair moved, specified as a three-element numeric vector of the form [x y z].

Examples

collapse all

Load a stack of images.

load(fullfile(toolboxdir('images'),'imdata','BrainMRILabeled','images','vol_001.mat'));

Create a custom colormap for viewing slices.

cmap = parula(256);

View the image stack in the Orthoslice Viewer.

os = orthosliceViewer(vol,'Colormap',cmap);

Set up listeners for the two Orthoslice Viewer crosshair moving events. When you move the crosshair, the Orthoslice Viewer sends notifications of these events and executes the callback function you specify.

addlistener(os,'CrosshairMoving',@allevents);
addlistener(os,'CrosshairMoved',@allevents);

The allevents callback function displays the name of each event with the previous position and the current position of the crosshair.

function allevents(src,evt)
evname = evt.EventName;
    switch(evname)
        case{'CrosshairMoved'}
            disp(['Crosshair moved previous position: ' mat2str(evt.PreviousPosition)]);
            disp(['Crosshair moved current position: ' mat2str(evt.CurrentPosition)]);
        case{'CrosshairMoving'}
            disp(['Crosshair moving previous position: ' mat2str(evt.PreviousPosition)]);
            disp(['Crosshair moving current position: ' mat2str(evt.CurrentPosition)]);
    end
 end
Introduced in R2019b