Changeset 5877
- Timestamp:
- Sep 21, 2015, 4:23:24 AM (9 years ago)
- Location:
- geovis/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/Renderer.cpp
r5876 r5877 1305 1305 bool makeShared, 1306 1306 bool visible, 1307 int minLOD,int maxLOD)1307 unsigned int minLOD, unsigned int maxLOD) 1308 1308 { 1309 1309 if (!_map.valid()) { … … 1465 1465 bool enableCache, 1466 1466 bool visible, 1467 int minLOD,int maxLOD)1467 unsigned int minLOD, unsigned int maxLOD) 1468 1468 { 1469 1469 if (!_map.valid()) { … … 2000 2000 } 2001 2001 #endif 2002 void Renderer::addModelLayer(const char *name, osgEarth::ModelSourceOptions& opts) 2002 void Renderer::addModelLayer(const char *name, 2003 osgEarth::ModelSourceOptions& opts, 2004 bool enableCache, 2005 bool lighting, 2006 bool visible) 2003 2007 { 2004 2008 if (!_map.valid()) { … … 2008 2012 TRACE("layer: %s", name); 2009 2013 osgEarth::ModelLayerOptions layerOpts(name, opts); 2014 if (!enableCache) { 2015 TRACE("Disabling cache for layer %s", name); 2016 layerOpts.cachePolicy() = osgEarth::CachePolicy(osgEarth::CachePolicy::USAGE_NO_CACHE); 2017 } 2018 if (!visible) { 2019 layerOpts.visible() = false; 2020 } 2021 layerOpts.lightingEnabled() = lighting; 2010 2022 _map->addModelLayer(new osgEarth::ModelLayer(layerOpts)); 2011 2023 _needsRedraw = true; -
geovis/trunk/Renderer.h
r5876 r5877 262 262 bool makeShared = false, 263 263 bool visible = true, 264 int minLOD = 0, int maxLOD = 23); 264 unsigned int minLOD = 0, 265 unsigned int maxLOD = 23); 265 266 266 267 void removeImageLayer(const char *name); … … 301 302 302 303 void addElevationLayer(const char *name, osgEarth::TileSourceOptions& opts, 303 bool enableCache = true, bool visible = true, 304 int minLOD = 0, int maxLOD = 23); 304 bool enableCache = true, 305 bool visible = true, 306 unsigned int minLOD = 0, 307 unsigned int maxLOD = 23); 305 308 306 309 void removeElevationLayer(const char *name); … … 332 335 } 333 336 334 void addModelLayer(const char *name, osgEarth::ModelSourceOptions& opts); 337 void addModelLayer(const char *name, osgEarth::ModelSourceOptions& opts, 338 bool enableCache = true, 339 bool lighting = true, 340 bool visible = true); 335 341 336 342 void removeModelLayer(const char *name); -
geovis/trunk/RendererCmd.cpp
r5876 r5877 25 25 #include <osgEarth/Version> 26 26 #include <osgEarth/Registry> 27 #include <osgEarth/Units> 27 28 #include <osgEarthFeatures/FeatureModelSource> 28 29 #include <osgEarthSymbology/Color> … … 39 40 #include <osgEarthDrivers/gdal/GDALOptions> 40 41 #include <osgEarthDrivers/tms/TMSOptions> 42 #include <osgEarthDrivers/wcs/WCSOptions> 41 43 #include <osgEarthDrivers/wms/WMSOptions> 42 44 #include <osgEarthDrivers/xyz/XYZOptions> … … 147 149 } 148 150 *boolPtr = (bool)value; 151 return TCL_OK; 152 } 153 #if 0 154 static short 155 GetShortFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, short *valuePtr) 156 { 157 int value; 158 159 if (Tcl_GetIntFromObj(interp, objPtr, &value) != TCL_OK) { 160 return TCL_ERROR; 161 } 162 *valuePtr = (short)value; 163 return TCL_OK; 164 } 165 #endif 166 static unsigned short 167 GetUShortFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, unsigned short *valuePtr) 168 { 169 int value; 170 171 if (Tcl_GetIntFromObj(interp, objPtr, &value) != TCL_OK) { 172 return TCL_ERROR; 173 } 174 *valuePtr = (unsigned short)value; 175 return TCL_OK; 176 } 177 178 static unsigned int 179 GetUIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, unsigned int *valuePtr) 180 { 181 long value; 182 183 if (Tcl_GetLongFromObj(interp, objPtr, &value) != TCL_OK) { 184 return TCL_ERROR; 185 } 186 *valuePtr = (unsigned int)value; 149 187 return TCL_OK; 150 188 } … … 247 285 return placement; 248 286 } 249 #if 0 287 250 288 static osgEarth::Symbology::AltitudeSymbol::Clamping 251 289 ParseClamping(const char *str, … … 283 321 return technique; 284 322 } 285 #endif 323 324 static osgEarth::Symbology::Stroke::LineCapStyle 325 ParseLineCapStyle(const char *str, 326 osgEarth::Symbology::Stroke::LineCapStyle defLineCap = 327 osgEarth::Symbology::Stroke::LINECAP_FLAT) 328 { 329 osgEarth::Symbology::Stroke::LineCapStyle lineCap = defLineCap; 330 if (str[0] == 'f' && strcmp(str, "flat") == 0) { 331 lineCap = osgEarth::Symbology::Stroke::LINECAP_FLAT; 332 } else if (str[0] == 's' && strcmp(str, "square") == 0) { 333 lineCap = osgEarth::Symbology::Stroke::LINECAP_SQUARE; 334 } else if (str[0] == 'r' && strcmp(str, "round") == 0) { 335 lineCap = osgEarth::Symbology::Stroke::LINECAP_ROUND; 336 } 337 return lineCap; 338 } 339 340 static osgEarth::Symbology::Stroke::LineJoinStyle 341 ParseLineJoinStyle(const char *str, 342 osgEarth::Symbology::Stroke::LineJoinStyle defLineJoin = 343 osgEarth::Symbology::Stroke::LINEJOIN_MITRE) 344 { 345 osgEarth::Symbology::Stroke::LineJoinStyle lineJoin = defLineJoin; 346 if (str[0] == 'm' && 347 (strcmp(str, "mitre") == 0 || strcmp(str, "miter") == 0)) { 348 lineJoin = osgEarth::Symbology::Stroke::LINEJOIN_MITRE; 349 } else if (str[0] == 'r' && strcmp(str, "round") == 0) { 350 lineJoin = osgEarth::Symbology::Stroke::LINEJOIN_ROUND; 351 } 352 return lineJoin; 353 } 354 286 355 static int 287 356 CameraDeleteViewpointOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 615 684 const char *username = NULL; 616 685 const char *hub = NULL; 617 const char *session = NULL;686 //const char *session = NULL; 618 687 for (int i = 0; i < numItems; i+=2) { 619 688 const char *name = Tcl_GetString(items[i]); … … 625 694 hub = val; 626 695 } 627 if (strcmp(name, "session") == 0) {628 session = val;629 }696 //if (strcmp(name, "session") == 0) { 697 // session = val; 698 //} 630 699 } 631 700 if (username != NULL) { … … 1194 1263 char *name = Tcl_GetString(objv[3]); 1195 1264 char *type = Tcl_GetString(objv[4]); 1265 bool cache = true; 1266 bool visible = true; 1196 1267 if (type[0] == 'i' && strcmp(type, "image") == 0) { 1197 1268 bool ret; … … 1207 1278 } 1208 1279 } 1209 bool cache = true;1210 1280 if (objc > 7) { 1211 1281 if (GetBooleanFromObj(interp, objv[7], &cache) != TCL_OK) { … … 1214 1284 } 1215 1285 bool coverage = false; 1286 if (objc > 8) { 1287 if (GetBooleanFromObj(interp, objv[8], &coverage) != TCL_OK) { 1288 return TCL_ERROR; 1289 } 1290 } 1216 1291 bool shared = false; 1217 bool visible = true; 1218 int minLOD = 0; 1219 int maxLOD = 23; 1292 unsigned int minLOD = 0; 1293 unsigned int maxLOD = 23; 1220 1294 float minRange = 0.f; 1221 1295 float maxRange = FLT_MAX; … … 1223 1297 if (driver[0] == 'c' && strcmp(driver, "colorramp") == 0) { 1224 1298 osgEarth::Drivers::ColorRampOptions colorRampOpts; 1225 char *edriver = Tcl_GetString(objv[8]); 1226 char *profile = Tcl_GetString(objv[9]); 1227 char *colormap = Tcl_GetString(objv[10]); 1228 //coverage = true; 1299 char *edriver = Tcl_GetString(objv[9]); 1300 char *profile = Tcl_GetString(objv[10]); 1301 char *colormap = Tcl_GetString(objv[11]); 1229 1302 if (edriver[0] == 'g' && strcmp(edriver, "gdal") == 0) { 1230 1303 osgEarth::Drivers::GDALOptions opts; … … 1249 1322 } else if (edriver[0] == 't' && strcmp(edriver, "tms") == 0) { 1250 1323 osgEarth::Drivers::TMSOptions opts; 1251 //char *tmsType = Tcl_GetString(objv[ 8]);1252 //char *format = Tcl_GetString(objv[ 9]);1324 //char *tmsType = Tcl_GetString(objv[9]); 1325 //char *format = Tcl_GetString(objv[10]); 1253 1326 opts.url() = url; 1254 1327 //opts.tmsType() = tmsType; … … 1277 1350 } else if (driver[0] == 't' && strcmp(driver, "tms") == 0) { 1278 1351 osgEarth::Drivers::TMSOptions opts; 1279 //char *tmsType = Tcl_GetString(objv[ 8]);1280 //char *format = Tcl_GetString(objv[ 9]);1352 //char *tmsType = Tcl_GetString(objv[9]); 1353 //char *format = Tcl_GetString(objv[10]); 1281 1354 opts.url() = url; 1282 1355 //opts.tmsType() = tmsType; … … 1286 1359 } else if (driver[0] == 'w' && strcmp(driver, "wms") == 0) { 1287 1360 osgEarth::Drivers::WMSOptions opts; 1288 char *wmsLayers = Tcl_GetString(objv[ 8]);1289 char *format = Tcl_GetString(objv[ 9]);1361 char *wmsLayers = Tcl_GetString(objv[9]); 1362 char *format = Tcl_GetString(objv[10]); 1290 1363 bool transparent; 1291 if (GetBooleanFromObj(interp, objv[1 0], &transparent) != TCL_OK) {1364 if (GetBooleanFromObj(interp, objv[11], &transparent) != TCL_OK) { 1292 1365 return TCL_ERROR; 1293 1366 } … … 1305 1378 //bool invertY = false; 1306 1379 //opts.invertY() = invertY; 1307 //opts.format() = Tcl_GetString(objv[ 8]);1380 //opts.format() = Tcl_GetString(objv[9]); 1308 1381 ret = g_renderer->addImageLayer(name, opts, cache, coverage, shared, visible, minLOD, maxLOD); 1309 1382 g_renderer->setImageLayerVisibleRange(name, minRange, maxRange); … … 1326 1399 return TCL_ERROR; 1327 1400 } 1328 bool cache = true; 1329 bool visible = true; 1401 if (objc > 7) { 1402 if (GetBooleanFromObj(interp, objv[7], &cache) != TCL_OK) { 1403 return TCL_ERROR; 1404 } 1405 } 1330 1406 int minLOD = 0; 1331 1407 int maxLOD = 23; … … 1336 1412 } else if (driver[0] == 't' && strcmp(driver, "tms") == 0) { 1337 1413 osgEarth::Drivers::TMSOptions opts; 1338 //char *tmsType = Tcl_GetString(objv[7]);1339 //char *format = Tcl_GetString(objv[8]);1340 1414 opts.url() = url; 1341 //opts.tmsType() = tmsType; 1342 //opts.format() = format; 1415 //opts.tmsType() = Tcl_GetString(objv[8]); 1416 //opts.format() = Tcl_GetString(objv[9]); 1417 g_renderer->addElevationLayer(name, opts, cache, visible, minLOD, maxLOD); 1418 } else if (driver[0] == 'w' && strcmp(driver, "wcs") == 0) { 1419 osgEarth::Drivers::WCSOptions opts; 1420 opts.url() = url; 1421 if (objc > 8) { 1422 opts.identifier() = Tcl_GetString(objv[8]); 1423 } 1424 if (objc > 9) { 1425 // default = 'm' 1426 opts.elevationUnit() = Tcl_GetString(objv[9]); 1427 } 1428 if (objc > 10) { 1429 // default = 'image/GeoTIFF' 1430 opts.format() = Tcl_GetString(objv[10]); 1431 } 1432 //opts.srs() = Tcl_GetString(objv[11]); 1433 //opts.rangeSubset() = Tcl_GetString(objv[12]); 1343 1434 g_renderer->addElevationLayer(name, opts, cache, visible, minLOD, maxLOD); 1344 1435 } else { … … 1364 1455 return TCL_ERROR; 1365 1456 } 1366 char *icon = Tcl_GetString(objv[9]); 1367 char *scaleExpr = Tcl_GetString(objv[10]); 1368 char *headingExpr = Tcl_GetString(objv[11]); 1457 if (GetBooleanFromObj(interp, objv[9], &cache) != TCL_OK) { 1458 return TCL_ERROR; 1459 } 1460 char *icon = Tcl_GetString(objv[10]); 1461 char *scaleExpr = Tcl_GetString(objv[11]); 1462 char *headingExpr = Tcl_GetString(objv[12]); 1369 1463 bool declutter = false; 1370 if (GetBooleanFromObj(interp, objv[12], &declutter) != TCL_OK) { 1371 return TCL_ERROR; 1372 } 1373 char *placementStr = Tcl_GetString(objv[13]); 1374 char *alignStr = Tcl_GetString(objv[14]); 1375 1464 if (GetBooleanFromObj(interp, objv[13], &declutter) != TCL_OK) { 1465 return TCL_ERROR; 1466 } 1467 char *placementStr = Tcl_GetString(objv[14]); 1468 char *alignStr = Tcl_GetString(objv[15]); 1469 1470 bool lighting = true; 1376 1471 osgEarth::Symbology::Style style; 1377 1472 osgEarth::Symbology::IconSymbol *is = style.getOrCreateSymbol<osgEarth::Symbology::IconSymbol>(); … … 1414 1509 geomOpts.minRange() = 0.f; 1415 1510 geomOpts.maxRange() = FLT_MAX; 1511 if (objc > 16) { 1512 float min, max; 1513 if (GetFloatFromObj(interp, objv[16], &min) != TCL_OK || 1514 GetFloatFromObj(interp, objv[17], &max) != TCL_OK) { 1515 return TCL_ERROR; 1516 } 1517 geomOpts.minRange() = min; 1518 geomOpts.maxRange() = max; 1519 } 1416 1520 //geomOpts.renderOrder() = int; 1417 1521 //geomOpts.depthTestEnabled() = bool; … … 1439 1543 return TCL_ERROR; 1440 1544 } 1441 g_renderer->addModelLayer(name, geomOpts );1545 g_renderer->addModelLayer(name, geomOpts, cache, lighting, visible); 1442 1546 } else if (type[0] == 'p' && strcmp(type, "point") == 0) { 1443 1547 char *driver = Tcl_GetString(objv[5]); … … 1457 1561 return TCL_ERROR; 1458 1562 } 1563 if (GetBooleanFromObj(interp, objv[9], &cache) != TCL_OK) { 1564 return TCL_ERROR; 1565 } 1459 1566 float r, g, b; 1460 if (GetFloatFromObj(interp, objv[ 9], &r) != TCL_OK ||1461 GetFloatFromObj(interp, objv[1 0], &g) != TCL_OK ||1462 GetFloatFromObj(interp, objv[1 1], &b) != TCL_OK) {1567 if (GetFloatFromObj(interp, objv[10], &r) != TCL_OK || 1568 GetFloatFromObj(interp, objv[11], &g) != TCL_OK || 1569 GetFloatFromObj(interp, objv[12], &b) != TCL_OK) { 1463 1570 return TCL_ERROR; 1464 1571 } 1465 1572 float ptSize; 1466 if (GetFloatFromObj(interp, objv[1 2], &ptSize) != TCL_OK) {1467 return TCL_ERROR; 1468 } 1469 1573 if (GetFloatFromObj(interp, objv[13], &ptSize) != TCL_OK) { 1574 return TCL_ERROR; 1575 } 1576 bool lighting = true; 1470 1577 osgEarth::Symbology::Style style; 1471 1578 osgEarth::Symbology::PointSymbol *ps = style.getOrCreateSymbol<osgEarth::Symbology::PointSymbol>(); 1472 1579 ps->fill()->color() = osgEarth::Symbology::Color(r, g, b); 1473 1580 ps->size() = ptSize; 1474 #if 1 1581 1582 osgEarth::Symbology::AltitudeSymbol::Clamping clamping = 1583 osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; 1584 if (objc > 14) { 1585 clamping = ParseClamping(Tcl_GetString(objv[14]), clamping); 1586 } 1587 osgEarth::Symbology::AltitudeSymbol::Technique technique = 1588 osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU; 1589 if (objc > 15) { 1590 technique = ParseClampingTechnique(Tcl_GetString(objv[15]), technique); 1591 } 1475 1592 osgEarth::Symbology::AltitudeSymbol *alt = style.getOrCreateSymbol<osgEarth::Symbology::AltitudeSymbol>(); 1476 alt->clamping() = osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; 1477 //alt->technique() = osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_DRAPE; 1478 alt->technique() = osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU; 1479 #endif 1480 #ifdef USE_DEPTH_OFFSET 1593 alt->clamping() = clamping; 1594 alt->technique() = technique; 1595 1596 #if 1 || defined(USE_DEPTH_OFFSET) 1481 1597 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); 1482 1598 rs->depthOffset()->enabled() = true; … … 1489 1605 geomOpts.minRange() = 0.f; 1490 1606 geomOpts.maxRange() = FLT_MAX; 1607 if (objc > 16) { 1608 float min, max; 1609 if (GetFloatFromObj(interp, objv[16], &min) != TCL_OK || 1610 GetFloatFromObj(interp, objv[17], &max) != TCL_OK) { 1611 return TCL_ERROR; 1612 } 1613 geomOpts.minRange() = min; 1614 geomOpts.maxRange() = max; 1615 } 1491 1616 //geomOpts.renderOrder() = int; 1492 1617 //geomOpts.depthTestEnabled() = bool; … … 1514 1639 return TCL_ERROR; 1515 1640 } 1516 g_renderer->addModelLayer(name, geomOpts );1641 g_renderer->addModelLayer(name, geomOpts, cache, lighting, visible); 1517 1642 } else if (type[0] == 'p' && strcmp(type, "polygon") == 0) { 1518 1643 char *driver = Tcl_GetString(objv[5]); … … 1532 1657 return TCL_ERROR; 1533 1658 } 1659 if (GetBooleanFromObj(interp, objv[9], &cache) != TCL_OK) { 1660 return TCL_ERROR; 1661 } 1534 1662 float r, g, b; 1535 if (GetFloatFromObj(interp, objv[9], &r) != TCL_OK || 1536 GetFloatFromObj(interp, objv[10], &g) != TCL_OK || 1537 GetFloatFromObj(interp, objv[11], &b) != TCL_OK) { 1538 return TCL_ERROR; 1539 } 1540 1663 if (GetFloatFromObj(interp, objv[10], &r) != TCL_OK || 1664 GetFloatFromObj(interp, objv[11], &g) != TCL_OK || 1665 GetFloatFromObj(interp, objv[12], &b) != TCL_OK) { 1666 return TCL_ERROR; 1667 } 1668 float lineWidth = 0.0f; 1669 if (objc > 13) { 1670 if (GetFloatFromObj(interp, objv[13], &lineWidth) != TCL_OK) { 1671 return TCL_ERROR; 1672 } 1673 } 1674 float strokeR = 0, strokeG = 0, strokeB = 0; 1675 if (objc > 14) { 1676 if (GetFloatFromObj(interp, objv[14], &strokeR) != TCL_OK || 1677 GetFloatFromObj(interp, objv[15], &strokeG) != TCL_OK || 1678 GetFloatFromObj(interp, objv[16], &strokeB) != TCL_OK) { 1679 return TCL_ERROR; 1680 } 1681 } 1682 bool lighting = true; 1541 1683 osgEarth::Symbology::Style style; 1542 1684 osgEarth::Symbology::PolygonSymbol *ps = style.getOrCreateSymbol<osgEarth::Symbology::PolygonSymbol>(); 1543 1685 ps->fill()->color() = osgEarth::Symbology::Color(r, g, b); 1544 1686 1545 osgEarth::Symbology::LineSymbol *ls = style.getOrCreateSymbol<osgEarth::Symbology::LineSymbol>(); 1546 ls->stroke()->color() = osgEarth::Symbology::Color(0, 0, 0); 1547 ls->stroke()->width() = 1.0f; 1548 ls->stroke()->widthUnits() = osgEarth::Units::PIXELS; 1549 ls->stroke()->lineCap() = osgEarth::Symbology::Stroke::LINECAP_FLAT; // _SQUARE, _ROUND 1550 //ls->stroke()->roundingRatio() = 0.4f; 1551 ls->stroke()->lineJoin() = osgEarth::Symbology::Stroke::LINEJOIN_MITRE; // _ROUND 1552 //ls->stroke()->stipplePattern() = 0; // Bitmask: unsigned short 1553 //ls->stroke()->stippleFactor() = 0; // num reps: unsigned 1554 #if 1 1687 if (lineWidth > 0.0f) { 1688 osgEarth::Symbology::LineSymbol *ls = style.getOrCreateSymbol<osgEarth::Symbology::LineSymbol>(); 1689 ls->stroke()->color() = osgEarth::Symbology::Color(strokeR, strokeG, strokeB); 1690 ls->stroke()->width() = lineWidth; 1691 ls->stroke()->widthUnits() = osgEarth::Units::PIXELS; 1692 ls->stroke()->lineCap() = osgEarth::Symbology::Stroke::LINECAP_FLAT; // _SQUARE, _ROUND 1693 //ls->stroke()->roundingRatio() = 0.4f; 1694 ls->stroke()->lineJoin() = osgEarth::Symbology::Stroke::LINEJOIN_MITRE; // _ROUND 1695 //ls->stroke()->stipplePattern() = 0; // Bitmask: unsigned short 1696 //ls->stroke()->stippleFactor() = 0; // num reps: unsigned 1697 } 1698 1699 osgEarth::Symbology::AltitudeSymbol::Clamping clamping = 1700 osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; 1701 if (objc > 17) { 1702 clamping = ParseClamping(Tcl_GetString(objv[17]), clamping); 1703 } 1704 osgEarth::Symbology::AltitudeSymbol::Technique technique = 1705 osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU; 1706 if (objc > 18) { 1707 technique = ParseClampingTechnique(Tcl_GetString(objv[18]), technique); 1708 } 1555 1709 osgEarth::Symbology::AltitudeSymbol *alt = style.getOrCreateSymbol<osgEarth::Symbology::AltitudeSymbol>(); 1556 alt->clamping() = osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; 1557 //alt->technique() = osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_DRAPE; 1558 alt->technique() = osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU; 1559 #endif 1560 #ifdef USE_DEPTH_OFFSET 1710 alt->clamping() = clamping; 1711 alt->technique() = technique; 1712 1713 #if 1 || defined(USE_DEPTH_OFFSET) 1561 1714 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); 1562 1715 rs->depthOffset()->enabled() = true; … … 1569 1722 geomOpts.minRange() = 0.f; 1570 1723 geomOpts.maxRange() = FLT_MAX; 1724 if (objc > 19) { 1725 float min, max; 1726 if (GetFloatFromObj(interp, objv[19], &min) != TCL_OK || 1727 GetFloatFromObj(interp, objv[20], &max) != TCL_OK) { 1728 return TCL_ERROR; 1729 } 1730 geomOpts.minRange() = min; 1731 geomOpts.maxRange() = max; 1732 } 1571 1733 if (driver[0] == 'o' && strcmp(driver, "ogr") == 0) { 1572 1734 osgEarth::Drivers::OGRFeatureOptions opts; … … 1592 1754 return TCL_ERROR; 1593 1755 } 1594 g_renderer->addModelLayer(name, geomOpts );1756 g_renderer->addModelLayer(name, geomOpts, cache, lighting, visible); 1595 1757 } else if (type[0] == 'l' && strcmp(type, "line") == 0) { 1596 1758 char *driver = Tcl_GetString(objv[5]); … … 1610 1772 return TCL_ERROR; 1611 1773 } 1774 if (GetBooleanFromObj(interp, objv[9], &cache) != TCL_OK) { 1775 return TCL_ERROR; 1776 } 1612 1777 float r, g, b; 1613 if (GetFloatFromObj(interp, objv[ 9], &r) != TCL_OK ||1614 GetFloatFromObj(interp, objv[1 0], &g) != TCL_OK ||1615 GetFloatFromObj(interp, objv[1 1], &b) != TCL_OK) {1778 if (GetFloatFromObj(interp, objv[10], &r) != TCL_OK || 1779 GetFloatFromObj(interp, objv[11], &g) != TCL_OK || 1780 GetFloatFromObj(interp, objv[12], &b) != TCL_OK) { 1616 1781 return TCL_ERROR; 1617 1782 } 1618 1783 float lineWidth; 1619 if (GetFloatFromObj(interp, objv[12], &lineWidth) != TCL_OK) { 1620 return TCL_ERROR; 1621 } 1622 1784 osgEarth::Units units = osgEarth::Units::PIXELS; 1785 if (!osgEarth::Units::parse(Tcl_GetString(objv[13]), lineWidth, 1786 units, osgEarth::Units::PIXELS)) { 1787 Tcl_AppendResult(interp, "Unkown units: \"", 1788 Tcl_GetString(objv[13]), "\"", (char*)NULL); 1789 return TCL_ERROR; 1790 } 1791 1792 osgEarth::Symbology::Stroke::LineCapStyle cap = osgEarth::Symbology::Stroke::LINECAP_FLAT; 1793 osgEarth::Symbology::Stroke::LineJoinStyle join = osgEarth::Symbology::Stroke::LINEJOIN_MITRE; 1794 if (objc > 14) { 1795 cap = ParseLineCapStyle(Tcl_GetString(objv[14]), cap); 1796 } 1797 if (objc > 15) { 1798 join = ParseLineJoinStyle(Tcl_GetString(objv[15]), join); 1799 } 1800 bool lighting = true; 1623 1801 osgEarth::Symbology::Style style; 1624 1802 osgEarth::Symbology::LineSymbol *ls = style.getOrCreateSymbol<osgEarth::Symbology::LineSymbol>(); 1625 1803 ls->stroke()->color() = osgEarth::Symbology::Color(r, g, b); 1626 1804 ls->stroke()->width() = lineWidth; 1627 ls->stroke()->widthUnits() = osgEarth::Units::PIXELS; 1628 ls->stroke()->lineCap() = osgEarth::Symbology::Stroke::LINECAP_FLAT; // _SQUARE, _ROUND 1805 ls->stroke()->widthUnits() = units; 1806 ls->stroke()->minPixels() = 1.0f; 1807 ls->stroke()->lineCap() = cap; 1629 1808 //ls->stroke()->roundingRatio() = 0.4f; 1630 ls->stroke()->lineJoin() = osgEarth::Symbology::Stroke::LINEJOIN_MITRE; // _ROUND 1631 //ls->stroke()->stipplePattern() = 0; // Bitmask: unsigned short 1632 //ls->stroke()->stippleFactor() = 0; // num reps: unsigned 1633 #if 1 1809 ls->stroke()->lineJoin() = join; 1810 if (objc > 16) { 1811 unsigned short stipplePattern = 0U; 1812 unsigned int stippleFactor = 1U; 1813 if (GetUShortFromObj(interp, objv[16], &stipplePattern) != TCL_OK || 1814 GetUIntFromObj(interp, objv[17], &stippleFactor) != TCL_OK) { 1815 return TCL_ERROR; 1816 } 1817 if (stipplePattern > 0U) { 1818 ls->stroke()->stipplePattern() = stipplePattern; // Bitmask: unsigned short 1819 ls->stroke()->stippleFactor() = stippleFactor; // num reps: unsigned 1820 } 1821 } 1822 1823 osgEarth::Symbology::AltitudeSymbol::Clamping clamping = 1824 osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; 1825 if (objc > 18) { 1826 clamping = ParseClamping(Tcl_GetString(objv[18]), clamping); 1827 } 1828 osgEarth::Symbology::AltitudeSymbol::Technique technique = 1829 osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU; 1830 if (objc > 18) { 1831 technique = ParseClampingTechnique(Tcl_GetString(objv[19]), technique); 1832 } 1634 1833 osgEarth::Symbology::AltitudeSymbol *alt = style.getOrCreateSymbol<osgEarth::Symbology::AltitudeSymbol>(); 1635 alt->clamping() = osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; 1636 //alt->technique() = osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_DRAPE; 1637 alt->technique() = osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU; 1638 #endif 1639 #ifdef USE_DEPTH_OFFSET 1834 alt->clamping() = clamping; 1835 alt->technique() = technique; 1836 1837 #if 1 || defined(USE_DEPTH_OFFSET) 1640 1838 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); 1641 1839 rs->depthOffset()->enabled() = true; … … 1648 1846 geomOpts.minRange() = 0.f; 1649 1847 geomOpts.maxRange() = FLT_MAX; 1650 if (objc > 13) {1848 if (objc > 20) { 1651 1849 float min, max; 1652 if (GetFloatFromObj(interp, objv[ 13], &min) != TCL_OK ||1653 GetFloatFromObj(interp, objv[ 14], &max) != TCL_OK) {1850 if (GetFloatFromObj(interp, objv[20], &min) != TCL_OK || 1851 GetFloatFromObj(interp, objv[21], &max) != TCL_OK) { 1654 1852 return TCL_ERROR; 1655 1853 } … … 1680 1878 return TCL_ERROR; 1681 1879 } 1682 g_renderer->addModelLayer(name, geomOpts );1880 g_renderer->addModelLayer(name, geomOpts, cache, lighting, visible); 1683 1881 } else if (type[0] == 't' && strcmp(type, "text") == 0) { 1684 1882 char *driver = Tcl_GetString(objv[5]); … … 1698 1896 return TCL_ERROR; 1699 1897 } 1700 char *content = Tcl_GetString(objv[9]); 1701 char *priority = Tcl_GetString(objv[10]); 1898 if (GetBooleanFromObj(interp, objv[9], &cache) != TCL_OK) { 1899 return TCL_ERROR; 1900 } 1901 char *content = Tcl_GetString(objv[10]); 1902 char *priority = Tcl_GetString(objv[11]); 1702 1903 float fgR, fgG, fgB; 1703 1904 float bgR, bgG, bgB; 1704 1905 float haloWidth, ftSize; 1705 1906 osg::Vec2s pixelOffset(0, 0); 1706 if (GetFloatFromObj(interp, objv[1 1], &fgR) != TCL_OK ||1707 GetFloatFromObj(interp, objv[1 2], &fgG) != TCL_OK ||1708 GetFloatFromObj(interp, objv[1 3], &fgB) != TCL_OK ||1709 GetFloatFromObj(interp, objv[1 4], &bgR) != TCL_OK ||1710 GetFloatFromObj(interp, objv[1 5], &bgG) != TCL_OK ||1711 GetFloatFromObj(interp, objv[1 6], &bgB) != TCL_OK ||1712 GetFloatFromObj(interp, objv[1 7], &haloWidth) != TCL_OK ||1713 GetFloatFromObj(interp, objv[1 8], &ftSize) != TCL_OK) {1907 if (GetFloatFromObj(interp, objv[12], &fgR) != TCL_OK || 1908 GetFloatFromObj(interp, objv[13], &fgG) != TCL_OK || 1909 GetFloatFromObj(interp, objv[14], &fgB) != TCL_OK || 1910 GetFloatFromObj(interp, objv[15], &bgR) != TCL_OK || 1911 GetFloatFromObj(interp, objv[16], &bgG) != TCL_OK || 1912 GetFloatFromObj(interp, objv[17], &bgB) != TCL_OK || 1913 GetFloatFromObj(interp, objv[18], &haloWidth) != TCL_OK || 1914 GetFloatFromObj(interp, objv[19], &ftSize) != TCL_OK) { 1714 1915 return TCL_ERROR; 1715 1916 } 1716 1917 bool removeDupes, declutter; 1717 if (GetBooleanFromObj(interp, objv[ 19], &removeDupes) != TCL_OK ||1718 GetBooleanFromObj(interp, objv[2 0], &declutter) != TCL_OK) {1918 if (GetBooleanFromObj(interp, objv[20], &removeDupes) != TCL_OK || 1919 GetBooleanFromObj(interp, objv[21], &declutter) != TCL_OK) { 1719 1920 return TCL_ERROR; 1720 1921 } 1721 1922 osgEarth::Symbology::TextSymbol::Alignment alignment = 1722 ParseTextAlignment(Tcl_GetString(objv[2 1]));1923 ParseTextAlignment(Tcl_GetString(objv[22])); 1723 1924 int xoff, yoff; 1724 if (Tcl_GetIntFromObj(interp, objv[2 2], &xoff) != TCL_OK ||1725 Tcl_GetIntFromObj(interp, objv[2 3], &yoff) != TCL_OK) {1925 if (Tcl_GetIntFromObj(interp, objv[23], &xoff) != TCL_OK || 1926 Tcl_GetIntFromObj(interp, objv[24], &yoff) != TCL_OK) { 1726 1927 return TCL_ERROR; 1727 1928 } 1728 1929 pixelOffset.x() = (short)xoff; 1729 1930 pixelOffset.y() = (short)yoff; 1730 1931 bool lighting = true; 1731 1932 osgEarth::Symbology::Style style; 1732 1933 osgEarth::Symbology::TextSymbol *ts = style.getOrCreateSymbol<osgEarth::Symbology::TextSymbol>(); … … 1756 1957 geomOpts.minRange() = 0.f; 1757 1958 geomOpts.maxRange() = FLT_MAX; 1758 if (objc > 2 4) {1959 if (objc > 25) { 1759 1960 float min, max; 1760 if (GetFloatFromObj(interp, objv[2 4], &min) != TCL_OK ||1761 GetFloatFromObj(interp, objv[2 5], &max) != TCL_OK) {1961 if (GetFloatFromObj(interp, objv[25], &min) != TCL_OK || 1962 GetFloatFromObj(interp, objv[26], &max) != TCL_OK) { 1762 1963 return TCL_ERROR; 1763 1964 } … … 1788 1989 return TCL_ERROR; 1789 1990 } 1790 g_renderer->addModelLayer(name, geomOpts );1991 g_renderer->addModelLayer(name, geomOpts, cache, lighting, visible); 1791 1992 } else { 1792 1993 Tcl_AppendResult(interp, "unknown map layer type \"", type, -
geovis/trunk/geovis_protocol.txt
r5873 r5877 137 137 138 138 General form: 139 map layer add <layerName> <type> <driver> <url> ... 140 <type> = image|elevation|line|point|polygon|text 141 <driver> = colorramp|debug|gdal|tms|wms|xyz 139 map layer add <layerName> <type> <driver> <?url?> <?cache?> ... 140 <type> = image|elevation|icon|line|point|polygon|text 141 <driver> = colorramp|debug|gdal|ogr|tfs|tms|wfs|wms|xyz 142 <cache> = bool indicating if tiles should be cached on disk 142 143 143 144 Specific image layer types: 144 map layer add <layerName> image colorramp <url> <cache> < elevdriver> <profile> <colormapName>145 map layer add <layerName> image colorramp <url> <cache> <coverage> <elevdriver> <profile> <colormapName> 145 146 Add a colormapped image layer from a file or URL 146 147 <url> = URL of source … … 149 150 <profile> = profile of source 150 151 <colormapName> = Name of colormap 151 map layer add <layerName> image gdal <url> < cache>152 map layer add <layerName> image gdal <url> <?cache?> <?coverage?> 152 153 Add a GDAL image layer from a file or URL 153 map layer add <layerName> image wms <url> <cache> < layers> <format> <transparent>154 map layer add <layerName> image wms <url> <cache> <coverage> <layers> <format> <transparent> 154 155 Add a WMS image layer from a URL + layer string 155 156 <url> = URL of WMS service … … 158 159 <format> = Image format to return (e.g. 'png') 159 160 <transparent> = bool 160 map layer add <layerName> image tms <url> <cache> 161 map layer add <layerName> image tms <url> <cache> <coverage> 161 162 Add a TMS image layer from a URL 162 163 <url> = URL of TMS service 163 164 <cache> = bool indicating if tiles should be cached on disk 164 map layer add <layerName> image xyz <urlPattern> <cache> 165 map layer add <layerName> image xyz <urlPattern> <cache> <coverage> 165 166 Add an image layer from a web map using a template URL 166 167 <cache> = bool indicating if tiles should be cached on disk 167 168 168 169 Elevation layers: 169 map layer add <layerName> elevation <driver> <url> 170 map layer add <layerName> elevation <driver> <url> <?cache?> 170 171 Add an elevation image layer from a file or URL 171 172 <driver> = gdal|tms|wms … … 176 177 <format> = json|gml (for tfs or wfs driver) 177 178 <typeName> = layer name for wfs driver 178 179 map layer add <layerName> icon <driver> <format> <typeName> <url> <icon> <scale> <heading> <declutter> <placement> <alignment> 179 <clamping> = none|terrain|relative|absolute 180 <clamptechnique> = drape|gpu|scene|map 181 182 map layer add <layerName> icon <driver> <format> <typeName> <url> <cache> <icon> <scale> <heading> <declutter> <placement> <alignment> <?visibilityRangeMin?> <?visibilityRangeMax?> 180 183 Add an icon feature layer from a file or URL 181 map layer add <layerName> point <driver> <format> <typeName> <url> <r> <g> <b> <size> 184 <placement> = vertex|centroid|interval|random 185 <alignment> = left_top|left_center|left_bottom|center_top|center_center|center_bottom|right_top|right_center|right_bottom 186 map layer add <layerName> line <driver> <format> <typeName> <url> <cache> <r> <g> <b> <width> <?cap?> <?join?> <?stipplePattern?> <?stippleFactor?> <?clamping?> <?clamptechnique?> <?visibilityRangeMin?> <?visibilityRangeMax?> 187 Add a line feature layer from a file or URL 188 cap/join only used if width > 1 189 <cap> = flat|square|round 190 <join> = mitre|round 191 map layer add <layerName> point <driver> <format> <typeName> <url> <cache> <r> <g> <b> <size> <?clamping?> <?clamptechnique?> <?visibilityRangeMin?> <?visibilityRangeMax?> 182 192 Add a point feature layer from a file or URL 183 map layer add <layerName> polygon <driver> <format> <typeName> <url> < r> <g> <b> <width>193 map layer add <layerName> polygon <driver> <format> <typeName> <url> <cache> <r> <g> <b> <?lineWidth?> <?strokeR?> <?strokeG?> <?strokeB?> <?clamping?> <?clamptechnique?> <?visibilityRangeMin?> <?visibilityRangeMax?> 184 194 Add a polygon feature layer from a file or URL 185 map layer add <layerName> line <driver> <format> <typeName> <url> <r> <g> <b> <width> 186 Add a line feature layer from a file or URL 187 map layer add <layerName> text <driver> <format> <typeName> <url> <content> <priority> <fgR> <fgG> <fgB> <bgR> <bgG> <bgB> <haloWidth> <fontSize> <removeDupes> <declutter> <alignment> <xoffset> <yoffset> <visibilityRangeMin> <visibilityRangeMax> 195 map layer add <layerName> text <driver> <format> <typeName> <url> <cache> <content> <priority> <fgR> <fgG> <fgB> <bgR> <bgG> <bgB> <haloWidth> <fontSize> <removeDupes> <declutter> <alignment> <xoffset> <yoffset> <?visibilityRangeMin?> <?visibilityRangeMax?> 188 196 Add a text symbol layer from a file or URL 197 <alignment> = left_top|left_center|left_bottom|center_top|center_center|center_bottom|right_top|right_center|right_bottom|left_baseline|center|baseline|right_baseline|left_bottom_baseline|center_bottom_baseline|right_bottom_baseline 189 198 190 199 map layer delete <layerName>
Note: See TracChangeset
for help on using the changeset viewer.