mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 14:29:42 -05:00
Merge branch 'thesis/2020/software-integration' of https://github.com/OpenSpace/OpenSpace into thesis/2020/software-integration
# Conflicts: # modules/softwareintegration/softwareintegrationmodule.cpp
This commit is contained in:
@@ -3,7 +3,7 @@ asset.require('./static_server')
|
||||
local guiCustomization = asset.require('customization/gui')
|
||||
|
||||
-- Select which commit hashes to use for the frontend and backend
|
||||
local frontendHash = "d85b4022813caafb0fdde18bea2c2f51768816fa"
|
||||
local frontendHash = "6b5ac33a77fff6f46088c1fffdaf04d59ec5bb5f"
|
||||
local dataProvider = "data.openspaceproject.com/files/webgui"
|
||||
|
||||
local frontend = asset.syncedResource({
|
||||
|
||||
@@ -70,6 +70,13 @@ scripting::LuaLibrary ExoplanetsModule::luaLibrary() const {
|
||||
"",
|
||||
"Prints a list with the names of all exoplanet systems that can be added to "
|
||||
"the scene graph to the OpenSpace Log. "
|
||||
},
|
||||
{
|
||||
"getListOfExoplanets",
|
||||
&exoplanets::luascriptfunctions::getListOfExoplanets,
|
||||
{},
|
||||
"",
|
||||
"Gets a list with the names of all exoplanet systems, that can be used by a GUI."
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -241,6 +241,7 @@ void createExoplanetSystem(std::string_view starName) {
|
||||
"Position = " + ghoul::to_string(starPosition) + ""
|
||||
"}"
|
||||
"},"
|
||||
"Tag = {'exoplanet_system'},"
|
||||
"GUI = {"
|
||||
"Name = '" + starNameSpeck + " (Star)',"
|
||||
"Path = '" + guiPath + "'"
|
||||
@@ -249,7 +250,7 @@ void createExoplanetSystem(std::string_view starName) {
|
||||
|
||||
openspace::global::scriptEngine.queueScript(
|
||||
"openspace.addSceneGraphNode(" + starParent + ");",
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
// Planets
|
||||
@@ -349,7 +350,7 @@ void createExoplanetSystem(std::string_view starName) {
|
||||
|
||||
openspace::global::scriptEngine.queueScript(
|
||||
"openspace.addSceneGraphNode(" + planetNode + ");",
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
const std::string planetTrailNode = "{"
|
||||
@@ -415,7 +416,7 @@ void createExoplanetSystem(std::string_view starName) {
|
||||
|
||||
openspace::global::scriptEngine.queueScript(
|
||||
"openspace.addSceneGraphNode(" + discNode + ");",
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -471,32 +472,25 @@ int removeExoplanetSystem(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int listAvailableExoplanetSystems(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::listAvailableExoplanetSystems");
|
||||
|
||||
std::ifstream file(absPath(LookUpTablePath));
|
||||
|
||||
if (!file.good()) {
|
||||
return ghoul::lua::luaError(
|
||||
L,
|
||||
fmt::format("Failed to open file '{}'", LookUpTablePath)
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<std::string> readHostStarNames(std::ifstream& lookupTableFile) {
|
||||
std::vector<std::string> names;
|
||||
// As of 2020 there are about 4000 confirmed exoplanets, so use this number
|
||||
// as a guess for the vector size
|
||||
const int nExoplanetsGuess = 4000;
|
||||
names.reserve(nExoplanetsGuess);
|
||||
|
||||
std::string line;
|
||||
while (getline(file, line)) {
|
||||
|
||||
// Read number of lines
|
||||
int nExoplanets = 0;
|
||||
while (getline(lookupTableFile, line)) {
|
||||
++nExoplanets;
|
||||
}
|
||||
lookupTableFile.clear();
|
||||
lookupTableFile.seekg(0);
|
||||
names.reserve(nExoplanets);
|
||||
|
||||
while (getline(lookupTableFile, line)) {
|
||||
std::stringstream ss(line);
|
||||
std::string name;
|
||||
getline(ss, name, ',');
|
||||
// Remove the last two characters, that specify the planet
|
||||
name = name.substr(0, name.size() - 2);
|
||||
|
||||
names.push_back(name);
|
||||
}
|
||||
|
||||
@@ -504,6 +498,44 @@ int listAvailableExoplanetSystems(lua_State* L) {
|
||||
std::sort(names.begin(), names.end());
|
||||
names.erase(std::unique(names.begin(), names.end()), names.end());
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
int getListOfExoplanets(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::getListOfExoplanets");
|
||||
|
||||
std::ifstream file(absPath(LookUpTablePath));
|
||||
if (!file.good()) {
|
||||
return ghoul::lua::luaError(
|
||||
L, fmt::format("Failed to open file '{}'", LookUpTablePath
|
||||
));
|
||||
}
|
||||
|
||||
std::vector<std::string> names = readHostStarNames(file);
|
||||
|
||||
lua_newtable(L);
|
||||
int number = 1;
|
||||
for (const std::string& s : names) {
|
||||
lua_pushstring(L, s.c_str());
|
||||
lua_rawseti(L, -2, number);
|
||||
++number;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int listAvailableExoplanetSystems(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::listAvailableExoplanetSystems");
|
||||
|
||||
std::ifstream file(absPath(LookUpTablePath));
|
||||
if (!file.good()) {
|
||||
return ghoul::lua::luaError(
|
||||
L, fmt::format("Failed to open file '{}'", LookUpTablePath
|
||||
));
|
||||
}
|
||||
|
||||
std::vector<std::string> names = readHostStarNames(file);
|
||||
|
||||
std::string output;
|
||||
for (auto it = names.begin(); it != names.end(); ++it) {
|
||||
if (it != names.end()) {
|
||||
@@ -513,8 +545,7 @@ int listAvailableExoplanetSystems(lua_State* L) {
|
||||
|
||||
LINFO(fmt::format(
|
||||
"There is data available for the following {} exoplanet systems: {}",
|
||||
names.size(),
|
||||
output
|
||||
names.size(), output
|
||||
));
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <modules/softwareintegration/rendering/renderablepointscloud.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
@@ -285,8 +286,12 @@ namespace openspace {
|
||||
SceneGraphNode* sgn = global::renderEngine.scene()->loadNode(node);
|
||||
if (!sgn) {
|
||||
LERROR("Scene", "Could not load scene graph node");
|
||||
break;
|
||||
}
|
||||
global::renderEngine.scene()->initializeNode(sgn);
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode(sgn);
|
||||
global::navigationHandler.orbitalNavigator().startRetargetAnchor();
|
||||
global::navigationHandler.orbitalNavigator().startRetargetAim();
|
||||
}
|
||||
catch (const documentation::SpecificationError& e) {
|
||||
return LERROR(fmt::format("Documentation SpecificationError: Error loading scene graph node {}",
|
||||
@@ -305,6 +310,8 @@ namespace openspace {
|
||||
case SoftwareConnection::MessageType::RemoveSceneGraphNode: {
|
||||
std::string identifier(message.begin(), message.end());
|
||||
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode("Earth");
|
||||
|
||||
openspace::global::scriptEngine.queueScript(
|
||||
"openspace.removeSceneGraphNode('" + identifier + "');",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
|
||||
Reference in New Issue
Block a user