## Gwy3DView

Gwy3DView — OpenGL 3D data display

## Synopsis

    #include <libgwydgets/gwydgets.h>

                        Gwy3DView;
                        Gwy3DViewClass;
    GtkWidget*          gwy_3d_view_new                     (GwyContainer *data);
    const gchar*        gwy_3d_view_get_setup_prefix        (Gwy3DView *gwy3dview);
    void                gwy_3d_view_set_setup_prefix        (Gwy3DView *gwy3dview,
                                                             const gchar *key);
    const gchar*        gwy_3d_view_get_data_key            (Gwy3DView *gwy3dview);
    void                gwy_3d_view_set_data_key            (Gwy3DView *gwy3dview,
                                                             const gchar *key);
    const gchar*        gwy_3d_view_get_gradient_key        (Gwy3DView *gwy3dview);
    void                gwy_3d_view_set_gradient_key        (Gwy3DView *gwy3dview,
                                                             const gchar *key);
    const gchar*        gwy_3d_view_get_material_key        (Gwy3DView *gwy3dview);
    void                gwy_3d_view_set_material_key        (Gwy3DView *gwy3dview,
                                                             const gchar *key);
    guint               gwy_3d_view_get_reduced_size        (Gwy3DView *gwy3dview);
    void                gwy_3d_view_set_reduced_size        (Gwy3DView *gwy3dview,
                                                             guint reduced_size);
    Gwy3DMovement       gwy_3d_view_get_movement_type       (Gwy3DView *gwy3dview);
    void                gwy_3d_view_set_movement_type       (Gwy3DView *gwy3dview,
                                                             Gwy3DMovement movement);
    GdkPixbuf*          gwy_3d_view_get_pixbuf              (Gwy3DView *gwy3dview);
    Gwy3DLabel*         gwy_3d_view_get_label               (Gwy3DView *gwy3dview,
                                                             Gwy3DViewLabel label);
    Gwy3DSetup*         gwy_3d_view_get_setup               (Gwy3DView *gwy3dview);
    GwyContainer*       gwy_3d_view_get_data                (Gwy3DView *gwy3dview);
    void                gwy_3d_view_get_scale_range         (Gwy3DView *gwy3dview,
                                                             gdouble *min_scale,
                                                             gdouble *max_scale);
    void                gwy_3d_view_set_scale_range         (Gwy3DView *gwy3dview,
                                                             gdouble min_scale,
                                                             gdouble max_scale);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----Gwy3DView

## Implemented Interfaces

Gwy3DView implements AtkImplementorIface and GtkBuildable.

## Properties

      "data-key"                 gchar*                : Read / Write
      "gradient-key"             gchar*                : Read / Write
      "material-key"             gchar*                : Read / Write
      "movement-type"            Gwy3DMovement         : Read / Write
      "reduced-size"             guint                 : Read / Write
      "setup-prefix"             gchar*                : Read / Write

## Description

Gwy3DView displays a data field as a threedimensional heightfield using OpenGL. You can create a new 3D view for a data container with `gwy_3d_view_new()`. By default, it inherits properties like palette from data view settings, but supports separate settings -- see `gwy_3d_view_set_palette()` et al.

Gwy3DView allows the user to interactively rotate, scale, z-scale the data or move lights, depending on its movement state. There are no controls provided for mode change, you have to provide some yourself and set the movement mode with `gwy_3d_view_set_movement_type()`.

You have initialize GtkGLExt with `gtk_gl_init_check()` and then Gwyddion's OpenGL with `gwy_widgets_gl_init()` before you can use Gwy3DView. These functions may not always succeed, see their description for more. If OpenGL initialization fails (possibly because its support was not compiled in) Gwy3DView cannot be even instantiated.

## Details

### Gwy3DView

    typedef struct _Gwy3DView Gwy3DView;

### Gwy3DViewClass

    typedef struct {
        GtkWidgetClass parent_class;

        gpointer list_pool;

        void (*reserved1)(void);
        void (*reserved2)(void);
        void (*reserved3)(void);
        void (*reserved4)(void);
        void (*reserved5)(void);
        void (*reserved6)(void);
    } Gwy3DViewClass;

### gwy_3d_view_new ()

    GtkWidget*          gwy_3d_view_new                     (GwyContainer *data);

Creates a new threedimensional OpenGL display of `data`.

The widget is initialized from container `data`.

`data` : | A GwyContainer containing the data to display.
Returns : | The new OpenGL 3D widget as a GtkWidget.

### gwy_3d_view_get_setup_prefix ()

    const gchar*        gwy_3d_view_get_setup_prefix        (Gwy3DView *gwy3dview);

Gets prefix identifying 3D view setup in the container.

`gwy3dview` : | A 3D data view widget.
Returns : | The setup key prefix.

### gwy_3d_view_set_setup_prefix ()

    void                gwy_3d_view_set_setup_prefix        (Gwy3DView *gwy3dview,
                                                             const gchar *key);

Sets the prefix of 3D view parameters in the container.

`gwy3dview` : | A 3D data view widget.
`key` : | Container string prefix for keys identifying the view setup parameters. The Gwy3DSetup is stored at key `"/setup"` under this prefix. Label objects are also stored under this prefix.

### gwy_3d_view_get_data_key ()

    const gchar*        gwy_3d_view_get_data_key            (Gwy3DView *gwy3dview);

Gets the container key identifying the data field to visualize in a 3D view.

`gwy3dview` : | A 3D data view widget.
Returns : | The string key, or `NULL` if it isn't set.

### gwy_3d_view_set_data_key ()

    void                gwy_3d_view_set_data_key            (Gwy3DView *gwy3dview,
                                                             const gchar *key);

Sets the container key identifying the data field to visualize in a 3D view.

`gwy3dview` : | A 3D data view widget.
`key` : | Container string key identifying the data field to visualize.

### gwy_3d_view_get_gradient_key ()

    const gchar*        gwy_3d_view_get_gradient_key        (Gwy3DView *gwy3dview);

Gets the container key identifying the colour gradient used to visualize data in a 3D view.

`gwy3dview` : | A 3D data view widget.
Returns : | The string key, or `NULL` if it isn't set.

### gwy_3d_view_set_gradient_key ()

    void                gwy_3d_view_set_gradient_key        (Gwy3DView *gwy3dview,
                                                             const gchar *key);

Sets the container key identifying the color gradient to use to visualize data in a 3D view.

`gwy3dview` : | A 3D data view widget.
`key` : | Container string key identifying the color gradient to use for gradient visualization mode.

### gwy_3d_view_get_material_key ()

    const gchar*        gwy_3d_view_get_material_key        (Gwy3DView *gwy3dview);

Gets the key identifying the GL material used to visualize data in a 3D view.

`gwy3dview` : | A 3D data view widget.
Returns : | The string key, or `NULL` if it isn't set.

### gwy_3d_view_set_material_key ()

    void                gwy_3d_view_set_material_key        (Gwy3DView *gwy3dview,
                                                             const gchar *key);

Sets the container key of the GL material used to visualize data in a 3D view.

`gwy3dview` : | A 3D data view widget.
`key` : | Container string key identifying the color material to use for material visualization mode.

### gwy_3d_view_get_reduced_size ()

    guint               gwy_3d_view_get_reduced_size        (Gwy3DView *gwy3dview);

Returns the reduced data size of a 3D view.

See `gwy_3d_view_set_reduced_size()` for details.

`gwy3dview` : | A 3D data view widget.
Returns : | The reduced data size.

### gwy_3d_view_set_reduced_size ()

    void                gwy_3d_view_set_reduced_size        (Gwy3DView *gwy3dview,
                                                             guint reduced_size);

Sets the reduced data size of a 3D view.

Data larger than reduced size are show downsampled during transforms and other changes to speed up the rendering. Final, full-size rendering is then performed after a timeout.

In case of the original data are not square, the `reduced_size` is the greater size of the downsampled data, the other dimension is proportional to the original size.

Changes in reduced size do not cause immediate redraw when an operation is pending and the view is shown in reduced size. It only affects future downsampling.

`gwy3dview` : | A 3D data view widget.
`reduced_size` : | New reduced data size.

### gwy_3d_view_get_movement_type ()

    Gwy3DMovement       gwy_3d_view_get_movement_type       (Gwy3DView *gwy3dview);

Returns a movement type describing actual type of response on the mouse motion event.

`gwy3dview` : | A 3D data view widget.
Returns : | Actual type of response on the mouse motion event

### gwy_3d_view_set_movement_type ()

    void                gwy_3d_view_set_movement_type       (Gwy3DView *gwy3dview,
                                                             Gwy3DMovement movement);

Sets the type of widget response on the mouse motion event.

`gwy3dview` : | A 3D data view widget.
`movement` : | A new type of response on the mouse motion event.

### gwy_3d_view_get_pixbuf ()

    GdkPixbuf*          gwy_3d_view_get_pixbuf              (Gwy3DView *gwy3dview);

Copies the contents of the framebuffer to the GdkPixbuf.

The size of the pixbuf is currently indentical with the size of the widget. `xres` and `yres` will be implemented to set the resolution of the pixbuf.

`gwy3dview` : | A 3D data view widget.
Returns : | A newly allocated GdkPixbuf with copy of the framebuffer.

### gwy_3d_view_get_label ()

    Gwy3DLabel*         gwy_3d_view_get_label               (Gwy3DView *gwy3dview,
                                                             Gwy3DViewLabel label);

Gets requested 3D label object of a 3D view.

This is a convenience method that can be used instead of fetching the label object from the data container.

`gwy3dview` : | A 3D data view widget.
`label` : | Label type to obtain.
Returns : | The 3D label object representing `label` in `gwy3dview`.

### gwy_3d_view_get_setup ()

    Gwy3DSetup*         gwy_3d_view_get_setup               (Gwy3DView *gwy3dview);

Gets the 3D setup object of a 3D view.

This is a convenience method that can be used instead of fetching the setup object from the data container.

`gwy3dview` : | A 3D data view widget.
Returns : |

### gwy_3d_view_get_data ()

    GwyContainer*       gwy_3d_view_get_data                (Gwy3DView *gwy3dview);

Returns the data container this 3D view displays.

`gwy3dview` : | A 3D data view widget.
Returns : | The container as a GwyContainer.

### gwy_3d_view_get_scale_range ()

    void                gwy_3d_view_get_scale_range         (Gwy3DView *gwy3dview,
                                                             gdouble *min_scale,
                                                             gdouble *max_scale);

Obtains the minimum and maximum zoom of a 3D data view

`gwy3dview` : | A 3D data view widget.
`min_scale` : | Location to put minimum scale, or `NULL`.
`max_scale` : | Location to put maximum scale, or `NULL`.

### gwy_3d_view_set_scale_range ()

    void                gwy_3d_view_set_scale_range         (Gwy3DView *gwy3dview,
                                                             gdouble min_scale,
                                                             gdouble max_scale);

Sets the minimum and maximum zoom of a 3D data view.

Recommended zoom values are 0.5 - 5.0.

`gwy3dview` : | A 3D data view widget.
`min_scale` : | Minimum zoom of the 3D data view, pass 0.0 to keep the current value.
`max_scale` : | Maximum zoom of the 3D data view, pass 0.0 to keep the current value.

## Property Details

### The `"data-key"` property

      "data-key"                 gchar*                : Read / Write

Key identifying data field in container.

Default value: NULL

### The `"gradient-key"` property

      "gradient-key"             gchar*                : Read / Write

Key identifying color gradient in container.

Default value: NULL

### The `"material-key"` property

      "material-key"             gchar*                : Read / Write

Key identifying GL material in container.

Default value: NULL

### The `"movement-type"` property

      "movement-type"            Gwy3DMovement         : Read / Write

The :movement-type property represents type of action on user pointer drag.

Default value: GWY_3D_MOVEMENT_NONE

### The `"reduced-size"` property

      "reduced-size"             guint                 : Read / Write

The size of downsampled data in quick view.

Allowed values: [2,G_MAXINT]

Default value: 96

### The `"setup-prefix"` property

      "setup-prefix"             gchar*                : Read / Write

Key prefix identifying view settings and labels in container.

Default value: NULL

## See Also

Gwy3DWindow -- window combining 3D view with controls, GwyGLMaterial -- OpenGL materials, Gwy3DLabel -- Labels on 3D view, Gwy3DSetup -- 3D scene setup