- Timestamp:
- Mar 28, 2014, 10:56:40 PM (11 years ago)
- Location:
- trunk/packages/vizservers/geovis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/geovis/Renderer.h
r4293 r4297 172 172 } 173 173 174 void getImageLayerNames(std::vector<std::string>& names) 175 { 176 if (_map.valid()) { 177 osgEarth::ImageLayerVector layerVector; 178 _map->getImageLayers(layerVector); 179 osgEarth::ImageLayerVector::const_iterator itr; 180 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 181 //osgEarth::UID uid = (*itr)->getUID(); 182 names.push_back((*itr)->getName()); 183 } 184 } 185 } 186 174 187 void addImageLayer(const char *name, osgEarth::TileSourceOptions& opts, 175 188 bool makeShared = false, bool visible = true); … … 194 207 } 195 208 209 void getElevationLayerNames(std::vector<std::string>& names) 210 { 211 if (_map.valid()) { 212 osgEarth::ElevationLayerVector layerVector; 213 _map->getElevationLayers(layerVector); 214 osgEarth::ElevationLayerVector::const_iterator itr; 215 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 216 //osgEarth::UID uid = (*itr)->getUID(); 217 names.push_back((*itr)->getName()); 218 } 219 } 220 } 221 196 222 void addElevationLayer(const char *name, osgEarth::TileSourceOptions& opts); 197 223 … … 207 233 { 208 234 return (_map.valid() ? _map->getNumModelLayers() : 0); 235 } 236 237 void getModelLayerNames(std::vector<std::string>& names) 238 { 239 if (_map.valid()) { 240 osgEarth::ModelLayerVector layerVector; 241 _map->getModelLayers(layerVector); 242 osgEarth::ModelLayerVector::const_iterator itr; 243 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 244 //osgEarth::UID uid = (*itr)->getUID(); 245 names.push_back((*itr)->getName()); 246 } 247 } 209 248 } 210 249 -
trunk/packages/vizservers/geovis/RendererCmd.cpp
r4282 r4297 733 733 734 734 static int 735 MapLayerNamesOp(ClientData clientData, Tcl_Interp *interp, int objc, 736 Tcl_Obj *const *objv) 737 { 738 std::vector<std::string> layers; 739 if (objc < 4) { 740 g_renderer->getImageLayerNames(layers); 741 g_renderer->getElevationLayerNames(layers); 742 g_renderer->getModelLayerNames(layers); 743 } else { 744 char *type = Tcl_GetString(objv[3]); 745 if (type[0] == 'i' && strcmp(type, "image") == 0) { 746 g_renderer->getImageLayerNames(layers); 747 } else if (type[0] == 'e' && strcmp(type, "elevation") == 0) { 748 g_renderer->getElevationLayerNames(layers); 749 } else if (type[0] == 'm' && strcmp(type, "model") == 0) { 750 g_renderer->getModelLayerNames(layers); 751 } else { 752 Tcl_AppendResult(interp, "uknown type \"", type, 753 "\": must be image, elevation or model", (char*)NULL); 754 return TCL_ERROR; 755 } 756 } 757 std::ostringstream oss; 758 size_t len = 0; 759 oss << "nv>dataset names {"; 760 len += 18; 761 for (size_t i = 0; i < layers.size(); i++) { 762 oss << "\"" << layers[i] << "\""; 763 len += 2 + layers[i].length(); 764 if (i < layers.size() - 1) { 765 oss << " "; 766 len++; 767 } 768 } 769 oss << "}\n"; 770 len += 2; 771 #ifdef USE_THREADS 772 queueResponse(oss.str().c_str(), len, Response::VOLATILE); 773 #else 774 ssize_t bytesWritten = SocketWrite(oss.str().c_str(), len); 775 776 if (bytesWritten < 0) { 777 return TCL_ERROR; 778 } 779 #endif /*USE_THREADS*/ 780 return TCL_OK; 781 } 782 783 static int 735 784 MapLayerVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 736 785 Tcl_Obj *const *objv) … … 753 802 {"delete", 1, MapLayerDeleteOp, 3, 4, "?name?"}, 754 803 {"move", 1, MapLayerMoveOp, 5, 5, "pos name"}, 804 {"names", 1, MapLayerNamesOp, 3, 4, "?type?"}, 755 805 {"opacity", 1, MapLayerOpacityOp, 5, 5, "opacity ?name?"}, 756 806 {"visible", 1, MapLayerVisibleOp, 5, 5, "bool ?name?"},
Note: See TracChangeset
for help on using the changeset viewer.