Changeset 6276 for geovis


Ignore:
Timestamp:
Apr 19, 2016 1:48:41 PM (8 years ago)
Author:
ldelgass
Message:

Add server response to notify clients of selection box region

Location:
geovis/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Renderer.cpp

    r6275 r6276  
    18411841    _sceneRoot->accept(spnv);
    18421842    _needsRedraw = true;
     1843}
     1844
     1845void Renderer::getBoxSelection(double *latMin, double *latMax, double *longMin, double *longMax)
     1846{
     1847    osgEarth::Annotation::FeatureNode *node = _selectionBox.get();
     1848    if (node == NULL)
     1849        return;
     1850    osgEarth::Symbology::Geometry *geom = node->getFeature()->getGeometry();
     1851    if (geom == NULL)
     1852        return;
     1853    *latMin = (*geom)[0].y();
     1854    *latMax = (*geom)[2].y();
     1855    *longMin = (*geom)[1].x();
     1856    *longMax = (*geom)[0].x();
    18431857}
    18441858
  • geovis/trunk/Renderer.h

    r6254 r6276  
    549549    void initBoxSelection(int x, int y);
    550550    void updateBoxSelection(int x, int y);
     551    void getBoxSelection(double *latMin, double *latMax, double *longMin, double *longMax);
    551552    void clearBoxSelection();
    552553
  • geovis/trunk/RendererCmd.cpp

    r6254 r6276  
    11771177
    11781178static int
    1179 MapBoxInitOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1180              Tcl_Obj *const *objv)
     1179MapBoxEndOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1180            Tcl_Obj *const *objv)
    11811181{
    11821182    int x, y;
     
    11851185        return TCL_ERROR;
    11861186    }
    1187     g_renderer->initBoxSelection(x, y);
    1188     return TCL_OK;
    1189 }
    1190 
    1191 static int
    1192 MapBoxUpdateOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1193                Tcl_Obj *const *objv)
     1187    g_renderer->updateBoxSelection(x, y);
     1188
     1189    // Notify client of selected region
     1190    double latMin, latMax, longMin, longMax;
     1191    latMin = latMax = longMin = longMax = 0;
     1192    g_renderer->getBoxSelection(&latMin, &latMax, &longMin, &longMax);
     1193
     1194    std::ostringstream oss;
     1195    oss << "nv>select region "
     1196        << longMin << " "
     1197        << latMin << " "
     1198        << longMax << " "
     1199        << latMax << "\n";
     1200    std::string ostr = oss.str();
     1201    size_t len = ostr.size();
     1202    queueResponse(ostr.c_str(), len, Response::VOLATILE);
     1203    return TCL_OK;
     1204}
     1205
     1206static int
     1207MapBoxInitOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1208             Tcl_Obj *const *objv)
    11941209{
    11951210    int x, y;
     
    11981213        return TCL_ERROR;
    11991214    }
     1215    g_renderer->initBoxSelection(x, y);
     1216    return TCL_OK;
     1217}
     1218
     1219static int
     1220MapBoxUpdateOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1221               Tcl_Obj *const *objv)
     1222{
     1223    int x, y;
     1224    if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK ||
     1225        Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) {
     1226        return TCL_ERROR;
     1227    }
    12001228    g_renderer->updateBoxSelection(x, y);
    12011229    return TCL_OK;
     
    12041232static CmdSpec mapBoxOps[] = {
    12051233    {"clear",   1, MapBoxClearOp,   3, 3, ""},
     1234    {"end",     1, MapBoxEndOp,     5, 5, "x y"},
    12061235    {"init",    1, MapBoxInitOp,    5, 5, "x y"},
    12071236    {"update",  1, MapBoxUpdateOp,  5, 5, "x y"},
  • geovis/trunk/geovis_protocol.txt

    r6255 r6276  
    355355nv>select clear
    356356nv>select feature <guid> <featureIDList> <numFeatures> <layerName>
     357nv>select region <xmin> <ymin> <xmax> <ymax>
    357358nv>ok -token <seqnum>
    358359   Reply indicated commands through <seqnum> (numbered beginning at 0) have been
Note: See TracChangeset for help on using the changeset viewer.