Changeset 4632 for geovis/trunk/RendererCmd.cpp
- Timestamp:
- Sep 10, 2014, 1:49:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/RendererCmd.cpp
r4629 r4632 1277 1277 } 1278 1278 return TCL_OK; 1279 } 1280 1281 static int 1282 MapPinAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1283 Tcl_Obj *const *objv) 1284 { 1285 int x, y; 1286 if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || 1287 Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) { 1288 return TCL_ERROR; 1289 } 1290 char *label = NULL; 1291 if (objc > 5) { 1292 label = Tcl_GetString(objv[5]); 1293 } 1294 1295 if (g_renderer->getMapSRS() == NULL) { 1296 Tcl_AppendResult(interp, "Could not get map SRS", (char*)NULL); 1297 return TCL_ERROR; 1298 } 1299 1300 // Get lat/long 1301 double latitude, longitude; 1302 const osgEarth::SpatialReference *outSRS = 1303 g_renderer->getMapSRS()->getGeographicSRS(); 1304 osgEarth::GeoPoint mapPoint; 1305 if (g_renderer->mapMouseCoords(x, y, mapPoint)) { 1306 mapPoint = mapPoint.transform(outSRS); 1307 longitude = mapPoint.x(); 1308 latitude = mapPoint.y(); 1309 } else { 1310 USER_ERROR("Can't add pin here"); 1311 return TCL_OK; 1312 } 1313 1314 g_renderer->addPlaceNode(latitude, longitude, label); 1315 return TCL_OK; 1316 } 1317 1318 static int 1319 MapPinDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1320 Tcl_Obj *const *objv) 1321 { 1322 int x, y; 1323 if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || 1324 Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) { 1325 return TCL_ERROR; 1326 } 1327 1328 g_renderer->deletePlaceNode(x, y); 1329 return TCL_OK; 1330 } 1331 1332 static int 1333 MapPinHoverOp(ClientData clientData, Tcl_Interp *interp, int objc, 1334 Tcl_Obj *const *objv) 1335 { 1336 int x, y; 1337 if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || 1338 Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) { 1339 return TCL_ERROR; 1340 } 1341 1342 g_renderer->hoverPlaceNode(x, y); 1343 return TCL_OK; 1344 } 1345 1346 static CmdSpec mapPinOps[] = { 1347 {"add", 1, MapPinAddOp, 5, 6, "x y ?label?"}, 1348 {"delete", 1, MapPinDeleteOp, 5, 5, "x y"}, 1349 {"hover", 1, MapPinHoverOp, 5, 5, "x y"}, 1350 }; 1351 static int nMapPinOps = NumCmdSpecs(mapPinOps); 1352 1353 static int 1354 MapPinOp(ClientData clientData, Tcl_Interp *interp, int objc, 1355 Tcl_Obj *const *objv) 1356 { 1357 Tcl_ObjCmdProc *proc; 1358 1359 proc = GetOpFromObj(interp, nMapPinOps, mapPinOps, 1360 CMDSPEC_ARG2, objc, objv, 0); 1361 if (proc == NULL) { 1362 return TCL_ERROR; 1363 } 1364 return (*proc) (clientData, interp, objc, objv); 1279 1365 } 1280 1366 … … 1554 1640 {"layer", 2, MapLayerOp, 3, 0, "op ?params...?"}, 1555 1641 {"load", 2, MapLoadOp, 4, 5, "options"}, 1556 {"posdisp", 1, MapPositionDisplayOp, 3, 5, "bool ?format? ?precision?"}, 1642 {"pin", 2, MapPinOp, 3, 0, "op ?params...?"}, 1643 {"posdisp", 2, MapPositionDisplayOp, 3, 5, "bool ?format? ?precision?"}, 1557 1644 {"reset", 1, MapResetOp, 3, 8, "type ?profile xmin ymin xmax ymax?"}, 1558 1645 {"scalebar", 1, MapScaleBarOp, 3, 4, "bool ?units?"}, … … 1951 2038 struct timeval start, finish; 1952 2039 gettimeofday(&start, NULL); 2040 g_stats.nCommands++; 1953 2041 status = ExecuteCommand(interp, &command); 1954 2042 gettimeofday(&finish, NULL); 1955 2043 g_stats.cmdTime += (MSECS_ELAPSED(start, finish) / 1.0e+3); 1956 g_stats.nCommands++;1957 2044 if (status == TCL_BREAK) { 1958 2045 return 2; /* This was caused by a "imgflush"
Note: See TracChangeset
for help on using the changeset viewer.