Main Content

cameratoolbar

Control camera toolbar programmatically

    Description

    cameratoolbar displays a camera toolbar in the current figure that enables interactive manipulation of the axes camera and light. If there is no figure available, then MATLAB® calls the figure function to create one.

    cameratoolbar(state) displays a camera toolbar with the visibility option specified.

    tf = cameratoolbar('GetVisible') returns the visibility of the camera toolbar in the current figure (1 if visible, 0 if not visible).

    cameratoolbar(reset) resets the current camera, scene light, or target to the state before interactions began.

    example

    cameratoolbar('SetMode',mode) sets the camera motion control mode.

    m = cameratoolbar('GetMode') returns the current camera motion control mode.

    cameratoolbar('SetCoordSys',coordsys) sets the principal axis of camera motion.

    p = cameratoolbar('GetCoordSys') returns the current principal axis of camera motion.

    example

    cameratoolbar(parent,___) displays a camera toolbar in the specified parent figure. Specify the parent figure before any of the input argument combinations in the previous syntaxes.

    example

    tb = cameratoolbar(___) returns the Toolbar object.

    Examples

    collapse all

    Create a figure and add a camera toolbar to the figure. Note that you can also display the camera toolbar by selecting Camera Toolbar from the figure window's View menu. The camera toolbar appears below the default figure toolbar.

    f = figure;
    tb = cameratoolbar(f);

    Top portion of a figure window that displays the default figure toolbar and the camera toolbar below it

    Set the camera toolbar mode to zoom by using 'SetMode'.

    cameratoolbar('SetMode','zoom')

    Top portion of a figure window that displays the default figure toolbar and the camera toolbar below with the Zoom Camera button depressed

    Input Arguments

    collapse all

    Toolbar visibility state, specified as one of these values:

    • 'show' — Show the camera toolbar.

    • 'hide' — Hide the camera toolbar.

    • 'toggle' — Toggle the camera toolbar visibility between the 'show' and 'hide' states.

    • 'close' — Remove the camera toolbar from the figure.

    Reset option to the default state, specified as one of these values:

    • 'ResetCameraAndSceneLight' — Reset the current camera and scene light.

    • 'ResetCamera' — Reset the current camera.

    • 'ResetSceneLight' — Reset the current scene light.

    • 'ResetTarget' — Reset the current target.

    • 'NoReset' — Do not set the state of any camera controls. This option is valid only for figures created with the figure function.

    Alternatively, you can reset the camera and scene light using the toolbar, by clicking the corresponding button.

    Camera motion control mode, specified as one of these values:

    • 'orbit' — Orbit camera.

    • 'orbitscenelight' — Orbit scene light.

    • 'pan' — Pan or tilt camera.

    • 'dollyhv' — Move camera horizontally or vertically.

    • 'dollyfb' — Move camera forward or back.

    • 'zoom' — Zoom camera.

    • 'roll' — Roll camera.

    • 'nomode' — No camera mode.

    For more information about the various modes, see Camera Toolbar.

    Alternatively, you can set the camera mode using the toolbar, by clicking the corresponding button.

    Principal axis of camera motion, specified as one of these values:

    • 'x' — Principal axis X.

    • 'y' — Principal axis Y.

    • 'z' — Principal axis Z.

    • 'none' — No principal axis.

    For for more information about the principal axes, see Camera Toolbar.

    Alternatively, you can set the principal axis using the toolbar, by clicking the corresponding button.

    Parent figure, specified as a Figure object.

    Output Arguments

    collapse all

    Camera toolbar visibility, returned as a logical value. If the camera toolbar is visible, tf is logical 1 (true). Otherwise, tf is logical 0 (false).

    Camera motion control mode, returned as a character vector. See the mode input argument for the list of possible values.

    Principal axis of camera motion, returned as a character vector. See the coordsys input argument for the list of possible values.

    Camera toolbar, returned as a Toolbar object.

    Version History

    Introduced before R2006a

    expand all