Contenuto principale

cameratoolbar

R2026b

Control camera toolbar programmatically

    Description

    Display Camera Toolbar

    Note

    In most cases, you do not need the cameratoolbar function to access the camera tools. To access the camera tools, click Camera Tools on the Tools tab in the figure. (since R2025a)

    cameratoolbar displays an interactive camera toolbar in the current figure. To use this syntax, the ToolBar property of the figure must be set to "figure" or "none".

    Set Camera Toolbar Parameters

    cameratoolbar(state) sets the visibility of the camera toolbar. To use this syntax, the ToolBar property of the figure must be set to "figure" or "none".

    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.

    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.

    Examples

    collapse all

    Create a surface plot in a figure. To display the camera toolbar, set the figure's ToolBar property to "figure" and call the cameratoolbar function.

    fig = figure;
    surf(peaks)
    fig.ToolBar = "figure";
    cameratoolbar(fig)

    Top section of a figure window that displays a figure toolbar and a camera toolbar

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

    cameratoolbar(fig,SetMode="zoom")

    Top section of a figure window that displays a figure toolbar and a camera toolbar. The camera toolbar has 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 Tools.

    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 Tools.

    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.

    Tips

    • Interacting with the camera toolbar disables the built-in axes interactions within the figure.

    • Showing the camera toolbar automatically changes the aspect ratio of the axes in the figure to avoid distortion as you move the camera around the scene. Hiding the toolbar does not revert the impacted Axes properties.

    Version History

    Introduced before R2006a

    expand all