Changeset 4310 for trunk/packages
- Timestamp:
- Apr 1, 2014, 2:58:49 PM (11 years ago)
- Location:
- trunk/packages/vizservers/geovis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/geovis/Renderer.cpp
r4308 r4310 38 38 #include <osgEarthUtil/AutoClipPlaneHandler> 39 39 #include <osgEarthUtil/MouseCoordsTool> 40 #include <osgEarthUtil/UTMGraticule> 41 #include <osgEarthUtil/MGRSGraticule> 42 #include <osgEarthUtil/GeodeticGraticule> 40 43 #include <osgEarthUtil/LatLongFormatter> 41 44 #include <osgEarthUtil/GLSLColorFilter> … … 91 94 osgEarth::MapNode *mapNode = new osgEarth::MapNode(map, mapNodeOpts); 92 95 _mapNode = mapNode; 93 _sceneRoot = mapNode; 96 _sceneRoot = new osg::Group; 97 _sceneRoot->addChild(mapNode); 94 98 _viewer->setSceneData(_sceneRoot.get()); 95 99 … … 255 259 } 256 260 261 void Renderer::setGraticule(bool enable, GraticuleType type) 262 { 263 if (!_mapNode.valid() || !_sceneRoot.valid()) 264 return; 265 if (enable) { 266 if (_graticule.valid()) { 267 _sceneRoot->removeChild(_graticule.get()); 268 _graticule = NULL; 269 } 270 switch (type) { 271 case GRATICULE_UTM: { 272 osgEarth::Util::UTMGraticule *gr = new osgEarth::Util::UTMGraticule(_mapNode.get()); 273 _sceneRoot->addChild(gr); 274 _graticule = gr; 275 } 276 break; 277 case GRATICULE_MGRS: { 278 osgEarth::Util::MGRSGraticule *gr = new osgEarth::Util::MGRSGraticule(_mapNode.get()); 279 _sceneRoot->addChild(gr); 280 _graticule = gr; 281 } 282 break; 283 case GRATICULE_GEODETIC: 284 default: 285 osgEarth::Util::GeodeticGraticule *gr = new osgEarth::Util::GeodeticGraticule(_mapNode.get()); 286 osgEarth::Util::GeodeticGraticuleOptions opt = gr->getOptions(); 287 opt.lineStyle()->getOrCreate<osgEarth::Symbology::LineSymbol>()->stroke()->color().set(1,0,0,1); 288 gr->setOptions(opt); 289 _sceneRoot->addChild(gr); 290 _graticule = gr; 291 } 292 } else if (_graticule.valid()) { 293 _sceneRoot->removeChild(_graticule.get()); 294 _graticule = NULL; 295 } 296 _needsRedraw = true; 297 } 298 257 299 void Renderer::initMouseCoordsTool() 258 300 { … … 311 353 } else { 312 354 initViewer(); 313 osg::Group *group = new osg::Group; 314 group->addChild(node); 315 _sceneRoot = group; 355 _sceneRoot = new osg::Group; 356 _sceneRoot->addChild(node); 316 357 _map = mapNode->getMap(); 317 358 } … … 400 441 _sceneRoot = sky; 401 442 #else 402 osg::Group *group = new osg::Group(); 403 group->addChild(_mapNode.get()); 404 _sceneRoot = group; 405 //_sceneRoot = mapNode; 406 #endif 407 #endif 408 } else { 409 osg::Group *group = new osg::Group(); 410 group->addChild(_mapNode.get()); 411 _sceneRoot = group; 412 //_sceneRoot = mapNode; 443 _sceneRoot = new osg::Group(); 444 _sceneRoot->addChild(_mapNode.get()); 445 #endif 446 #endif 447 } else { 448 _sceneRoot = new osg::Group(); 449 _sceneRoot->addChild(_mapNode.get()); 413 450 } 414 451 -
trunk/packages/vizservers/geovis/Renderer.h
r4307 r4310 150 150 typedef std::string ColorMapId; 151 151 152 enum GraticuleType { 153 GRATICULE_UTM, 154 GRATICULE_MGRS, 155 GRATICULE_GEODETIC 156 }; 157 152 158 Renderer(); 153 159 virtual ~Renderer(); … … 172 178 173 179 // Map options 180 181 void setGraticule(bool enable, GraticuleType type = GRATICULE_GEODETIC); 174 182 175 183 void setViewerLightType(osg::View::LightingMode mode); … … 379 387 std::string _baseURI; 380 388 381 osg::ref_ptr<osg::Node> _sceneRoot; 389 osg::ref_ptr<osg::Group> _sceneRoot; 390 osg::ref_ptr<osg::Group> _graticule; 382 391 osg::ref_ptr<osgEarth::MapNode> _mapNode; 383 392 osg::ref_ptr<osgEarth::Map> _map; -
trunk/packages/vizservers/geovis/RendererCmd.cpp
r4308 r4310 531 531 } 532 532 return (*proc) (clientData, interp, objc, objv); 533 } 534 535 static int 536 MapGraticuleOp(ClientData clientData, Tcl_Interp *interp, int objc, 537 Tcl_Obj *const *objv) 538 { 539 bool state; 540 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 541 return TCL_ERROR; 542 } 543 if (objc > 3) { 544 Renderer::GraticuleType type; 545 char *typeStr = Tcl_GetString(objv[3]); 546 if (typeStr[0] == 'g' && strcmp(typeStr, "geodetic") == 0) { 547 type = Renderer::GRATICULE_GEODETIC; 548 } else if (typeStr[0] == 'u' && strcmp(typeStr, "utm") == 0) { 549 type = Renderer::GRATICULE_UTM; 550 } else if (typeStr[0] == 'm' && strcmp(typeStr, "mgrs") == 0) { 551 type = Renderer::GRATICULE_MGRS; 552 } else { 553 return TCL_ERROR; 554 } 555 g_renderer->setGraticule(state, type); 556 } else { 557 g_renderer->setGraticule(state); 558 } 559 return TCL_OK; 533 560 } 534 561 … … 1059 1086 1060 1087 static CmdSpec mapOps[] = { 1088 {"grid", 1, MapGraticuleOp, 3, 4, "bool ?type?"}, 1061 1089 {"layer", 2, MapLayerOp, 3, 0, "op ?params...?"}, 1062 1090 {"load", 2, MapLoadOp, 4, 5, "options"},
Note: See TracChangeset
for help on using the changeset viewer.