Ignore:
Timestamp:
Sep 4, 2014 11:18:26 AM (10 years ago)
Author:
ldelgass
Message:

add token to map/screen coord commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/RendererCmd.cpp

    r4628 r4629  
    107107    std::string cmd(str);
    108108    cmd.erase(cmd.find_last_not_of(" \n\r\t")+1);
    109     TRACE("command %lu: '%s'", g_stats.nCommands+1, cmd.c_str());
     109    TRACE("command %lu: '%s'", g_stats.nCommands, cmd.c_str());
    110110#endif
    111111    lastCmdStatus = TCL_OK;
     
    772772{
    773773    int x, y;
    774     if (Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK ||
    775         Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) {
     774    if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK ||
     775        Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) {
    776776        return TCL_ERROR;
    777777    }
     
    779779    osgEarth::GeoPoint mapPoint;
    780780    size_t length;
    781     char mesg[256];
     781    char mesg[512];
    782782    if (g_renderer->mapMouseCoords(x, y, mapPoint)) {
    783783        std::string srsInit;
    784784        std::string verticalDatum;
    785         if (objc > 4) {
    786             srsInit = Tcl_GetString(objv[4]);
    787             if (objc > 5) {
    788                 verticalDatum = Tcl_GetString(objv[5]);
     785        if (objc > 5) {
     786            srsInit = Tcl_GetString(objv[5]);
     787            if (objc > 6) {
     788                verticalDatum = Tcl_GetString(objv[6]);
    789789            }
    790790            osgEarth::SpatialReference *outSRS =
     
    802802        // send coords to client
    803803        length = snprintf(mesg, sizeof(mesg),
    804                           "nv>map coords %g %g %g %d %d {%s} {%s}\n",
     804                          "nv>map coords %s %g %g %g %d %d {%s} {%s}\n",
     805                          Tcl_GetString(objv[2]), //g_stats.nCommands,
    805806                          mapPoint.x(), mapPoint.y(), mapPoint.z(),
    806807                          x, y,
     
    812813        // Out of range
    813814        length = snprintf(mesg, sizeof(mesg),
    814                           "nv>map coords invalid %d %d\n", x, y);
     815                          "nv>map coords %s invalid %d %d\n",
     816                          Tcl_GetString(objv[2]), //g_stats.nCommands,
     817                          x, y);
    815818
    816819        queueResponse(mesg, length, Response::VOLATILE);
     
    15471550
    15481551static CmdSpec mapOps[] = {
    1549     {"coords",   1, MapCoordsOp,          4, 6, "x y ?srs? ?verticalDatum?"},
     1552    {"coords",   1, MapCoordsOp,          5, 7, "token x y ?srs? ?verticalDatum?"},
    15501553    {"grid",     1, MapGraticuleOp,       3, 4, "bool ?type?"},
    15511554    {"layer",    2, MapLayerOp,           3, 0, "op ?params...?"},
     
    17501753{
    17511754    double x, y, z;
    1752     if (Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK ||
    1753         Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK ||
    1754         Tcl_GetDoubleFromObj(interp, objv[4], &z) != TCL_OK) {
     1755    if (Tcl_GetDoubleFromObj(interp, objv[3], &x) != TCL_OK ||
     1756        Tcl_GetDoubleFromObj(interp, objv[4], &y) != TCL_OK ||
     1757        Tcl_GetDoubleFromObj(interp, objv[5], &z) != TCL_OK) {
    17551758        return TCL_ERROR;
    17561759    }
    17571760    const osgEarth::SpatialReference *srs = NULL;
    1758     if (objc < 6) {
     1761    if (objc < 7) {
    17591762        srs = g_renderer->getMapSRS();
    17601763        if (srs == NULL) {
     
    17631766        }
    17641767    } else {
    1765         std::string srsInit(Tcl_GetString(objv[5]));
     1768        std::string srsInit(Tcl_GetString(objv[6]));
    17661769        std::string verticalDatum;
    1767         if (objc > 6) {
    1768             verticalDatum = Tcl_GetString(objv[6]);
     1770        if (objc > 7) {
     1771            verticalDatum = Tcl_GetString(objv[7]);
    17691772        }
    17701773        srs = osgEarth::SpatialReference::get(srsInit, verticalDatum);
     
    17851788        // send coords to client
    17861789        length = snprintf(mesg, sizeof(mesg),
    1787                           "nv>screen coords %g %g %g %g %g %g\n",
     1790                          "nv>screen coords %s %g %g %g %g %g %g\n",
     1791                          Tcl_GetString(objv[2]),
    17881792                          screen.x(), screen.y(), screen.z(),
    17891793                          x, y, z);
     
    17931797        // Out of range
    17941798        length = snprintf(mesg, sizeof(mesg),
    1795                           "nv>screen coords invalid %g %g %g\n", x, y, z);
     1799                          "nv>screen coords %s invalid %g %g %g\n",
     1800                          Tcl_GetString(objv[2]),
     1801                          x, y, z);
    17961802
    17971803        queueResponse(mesg, length, Response::VOLATILE);
     
    18171823static CmdSpec screenOps[] = {
    18181824    {"bgcolor", 1, ScreenBgColorOp, 5, 5, "r g b"},
    1819     {"coords",  1, ScreenCoordsOp, 5, 7, "x y z ?srs? ?verticalDatum?"},
     1825    {"coords",  1, ScreenCoordsOp, 6, 8, "token x y z ?srs? ?verticalDatum?"},
    18201826    {"size",    1, ScreenSizeOp, 4, 4, "width height"}
    18211827};
Note: See TracChangeset for help on using the changeset viewer.