Rotation, Zooming and Translation


Introduction

Rotation, zooming and translation operations are provided based on the flexible Xt translation table mechanism. The default translation table for the rotate operation is defined as follows:

    None<Btn3Down>:   View3DRotateStart()
    None<Btn3Motion>: View3DRotate()
    None<Btn3Up>:     View3DRotateEnd()

This table indicates that the rotation operation is performed by pressing mouse Button3 and holding it down, while moving it until achieving the desired position. Actions View3DRotateStart, View3DRotate and View3DRotateEnd initiate, perform and terminate the rotate operation respectively. Resource XmNrotateSensitivity can be used to specify the sensitivity of the mouse with respect to zooming.

Similarly, the default translation table for the zoom and translate operations are defined as follows:

    Ctrl<Btn3Down>:   View3DZoomStart()
    Ctrl<Btn3Motion>: View3DZoom()
    Ctrl<Btn3Up>:     View3DZoomEnd()

    Shift<Btn3Down>:   View3DTranslateStart()
    Shift<Btn3Motion>: View3DTranslate()
    Shift<Btn3Up>:     View3DTranslateEnd()

This table indicates that the zoom and translate operations are also performed using Button 3, while pressing the Ctrl or Shift key, respectively. A complete listing of the View3D actions can be found in the Reference pages.


Modifying the Translation Table

The translation table can be redefined from the application or from a resource file. The following code fragment illustrates how to modify the translation table so that the rotation is performed with Button1, the zoom with Button2 and the translation with Button3.

    /* define new translation table */
    static char translations[] =
                               "None <Btn1Down>: View3DRotateStart()\n\
                                None <Btn1Motion>: View3DRotate()\n\
                                None <Btn1Up>: View3DRotateEnd()\n\
                                None <Btn2Down>: View3DZoomStart()\n\
                                None <Btn2Motion>: View3DZoom()\n\
                                None <Btn2Up>: View3DZoomEnd()\n\
                                None <Btn3Down>: View3DTranslateStart()\n\
                                None <Btn3Motion>: View3DTranslate()\n\
                                None <Btn3Up>:     View3DTranslateEnd()";

    Widget view3d;

    ...

    /* create a View3D widget */
    view3d = XtVaCreateManagedWidget("Viewer3D", xintView3DWidgetClass,
                                     top_level,
                                     XmNwidth,  400, 
                                     XmNheight, 400, 
                                     NULL);
    
    /* override translations table */
    XtOverrideTranslations(view3d, XtParseTranslationTable(translations));