Feature/gb gui (#390)

Implemented new GUI component to handle WMS servers
* Add Lua scripts to support adding GIBS datasets (closes #222)
* Add Lua function to load WMS servers from a predefined file

* Workaround for Visual Studio 15.3 compile fix in Windows headers

* Initial support for parsing GetCapabilities file and automatically add layers

* Add a Trigger property to remove a layer

* Support default servers

* Add default file

* Move WMS server code from GUI component into GlobeBrowsingModule

* Add Lua scripts for loading and removing WMS servers
Automatically load default servers on startup

* Reset tile provider before removing a layer tolimit the crash risk
Add "From focus" button to switch globebrowsing gui to the same node as the focus

* Remove warnings
Remove compile error with nonexisting GDALOpenEx function
This commit is contained in:
Alexander Bock
2017-08-19 20:23:08 -04:00
committed by GitHub
parent 09a94e6bf5
commit 222bbe22ab
17 changed files with 813 additions and 28 deletions
@@ -148,17 +148,17 @@ int goToChunk(lua_State* L) {
OsEng.moduleEngine().module<GlobeBrowsingModule>()->goToChunk(x, y, level);
return 0;
return 0;
}
int goToGeo(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 2 && nArguments != 3) {
return luaL_error(L, "Expected 2 or 3 arguments.");
}
double latitude = static_cast<double>(lua_tonumber(L, 1));
double longitude = static_cast<double>(lua_tonumber(L, 2));
@@ -168,20 +168,20 @@ int goToGeo(lua_State* L) {
else if (nArguments == 3) {
double altitude = static_cast<int>(lua_tonumber(L, 3));
OsEng.moduleEngine().module<GlobeBrowsingModule>()->goToGeo(latitude, longitude,
altitude);
altitude);
}
return 0;
}
int getGeoPosition(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 0) {
return luaL_error(L, "Expected 0 arguments.");
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
}
RenderableGlobe* globe =
OsEng.moduleEngine().module<GlobeBrowsingModule>()->castFocusNodeRenderableToGlobe();
OsEng.moduleEngine().module<GlobeBrowsingModule>()->castFocusNodeRenderableToGlobe();
if (!globe) {
return luaL_error(L, "Focus node must be a RenderableGlobe");
}
@@ -192,16 +192,79 @@ int getGeoPosition(lua_State* L) {
glm::dvec3 cameraPositionModelSpace =
inverseModelTransform * glm::dvec4(cameraPosition, 1.0);
SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
cameraPositionModelSpace);
cameraPositionModelSpace);
Geodetic2 geo2 = globe->ellipsoid().cartesianToGeodetic2(posHandle.centerToReferenceSurface);
double altitude = glm::length(cameraPositionModelSpace - posHandle.centerToReferenceSurface);
lua_pushnumber(L, Angle<double>::fromRadians(geo2.lat).asDegrees());
lua_pushnumber(L, Angle<double>::fromRadians(geo2.lon).asDegrees());
lua_pushnumber(L, altitude);
return 3;
}
int loadWMSCapabilities(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 3) {
return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments);
}
std::string name = lua_tostring(L, -3);
std::string globe = lua_tostring(L, -2);
std::string url = lua_tostring(L, -1);
OsEng.moduleEngine().module<GlobeBrowsingModule>()->loadWMSCapabilities(
std::move(name),
std::move(globe),
std::move(url)
);
return 0;
}
int removeWMSServer(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
}
std::string name = lua_tostring(L, -1);
OsEng.moduleEngine().module<GlobeBrowsingModule>()->removeWMSServer(name);
return 0;
}
int capabilities(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
}
std::string name = lua_tostring(L, -1);
GlobeBrowsingModule::Capabilities cap =
OsEng.moduleEngine().module<GlobeBrowsingModule>()->capabilities(name);
lua_newtable(L);
for (int i = 0; i < cap.size(); ++i) {
const GlobeBrowsingModule::Layer& l = cap[i];
lua_newtable(L);
lua_pushstring(L, "Name");
lua_pushstring(L, l.name.c_str());
lua_settable(L, -3);
lua_pushstring(L, "URL");
lua_pushstring(L, l.url.c_str());
lua_settable(L, -3);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
} // namespace openspace::globebrowsing::luascriptfunctions