Changeset 4323


Ignore:
Timestamp:
Apr 7, 2014 1:00:38 AM (10 years ago)
Author:
ldelgass
Message:

Add "camera go" command for moving viewpoint based on screen coordinates. This
is intended to replace the server-side button 1 double click event.

Location:
trunk/packages/vizservers/geovis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/geovis/RendererCmd.cpp

    r4320 r4323  
    180180    }
    181181#endif /*USE_THREADS*/
     182    return TCL_OK;
     183}
     184
     185static int
     186CameraGoOp(ClientData clientData, Tcl_Interp *interp, int objc,
     187           Tcl_Obj *const *objv)
     188{
     189    int x, y;
     190    if (Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK ||
     191        Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) {
     192        return TCL_ERROR;
     193    }
     194    double duration = 1.0;
     195    if (objc > 4) {
     196        if (Tcl_GetDoubleFromObj(interp, objv[4], &duration) != TCL_OK) {
     197            return TCL_ERROR;
     198        }
     199    }
     200
     201    osgEarth::GeoPoint mapPoint;
     202    if (g_renderer->mapMouseCoords(x, y, mapPoint)) {
     203        osgEarth::Viewpoint vpt = g_renderer->getViewpoint();
     204        vpt.x() = mapPoint.x();
     205        vpt.y() = mapPoint.y();
     206        g_renderer->setViewpoint(vpt, duration);
     207    } else {
     208        // Out of map bounds
     209    }
    182210    return TCL_OK;
    183211}
     
    369397    {"delete",  2, CameraDeleteViewpointOp,  3, 3, "name"},
    370398    {"dist",    2, CameraSetDistanceOp,      3, 3, "distance"},
    371     {"get",     1, CameraGetViewpointOp,     2, 2, ""},
     399    {"get",     2, CameraGetViewpointOp,     2, 2, ""},
     400    {"go",      2, CameraGoOp,               4, 5, "x y ?duration?"},
    372401    {"orient",  1, CameraOrientOp,           6, 6, "qw qx qy qz"},
    373402    {"pan",     1, CameraPanOp,              4, 4, "panX panY"},
  • trunk/packages/vizservers/geovis/geovis_protocol.txt

    r4320 r4323  
    3535camera get
    3636       Request camera parameters
     37camera go <x> <y> <?duration?>
     38       Move camera to new focal point.
     39       <x>,<y> = Screen/mouse coordinates
     40       <duration> = Duration of viewpoint move animation in seconds
    3741camera orient <quatW> <quatX> <quatY> <quatZ>
    3842       Set scene orientation using a quaternion
Note: See TracChangeset for help on using the changeset viewer.