Main Content

cameratoolbar

Control camera toolbar programmatically

    Description

    Display Camera Toolbar

    cameratoolbar displays a camera toolbar in the current figure that enables interactive manipulation of the axes camera and light. If no figure is available, then MATLAB® calls the figure function to create one. Interacting with the camera toolbar disables the default set of interactions built into axes in the figure.

    Set Camera Toolbar Parameters

    cameratoolbar(state) sets the visibility of the camera toolbar.

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

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

    example

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

    cameratoolbar(fig,___) sets parameters for the camera toolbar in the specified figure. Specify the figure before any of the input argument combinations in the previous syntaxes.

    example

    tb = cameratoolbar(___) returns the Toolbar object.

    example

    Get Camera Toolbar Parameters

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

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

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

    ___ = cameratoolbar(fig,___) gets parameters for the camera toolbar in the specified figure.

    example

    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 View menu of the figure window. The camera toolbar appears below the default figure toolbar.

    fig = figure;
    tb = cameratoolbar(fig);

    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 Control View Using 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 more information about the principal axes, see Control View Using Camera Toolbar.

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

    Target figure, specified as a Figure object.

    Output Arguments

    collapse all

    Camera toolbar visibility, returned as 1 or 0 of data type logical. 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