Add message for loading images and functionality to show a target

This commit is contained in:
Ylva Selling
2021-03-08 08:46:57 +01:00
parent 913e975acb
commit 72a6b3623d
3 changed files with 45 additions and 4 deletions
+32
View File
@@ -107,6 +107,14 @@ scripting::LuaLibrary SkybrowserModule::luaLibrary() const {
"string or list of strings",
"Add one or multiple exoplanet systems to the scene, as specified by the "
"input. An input string should be the name of the system host star"
},
{
"loacImgCollection",
&skybrowser::luascriptfunctions::loadImgCollection,
{},
"string or list of strings",
"Add one or multiple exoplanet systems to the scene, as specified by the "
"input. An input string should be the name of the system host star"
}
};
@@ -161,6 +169,17 @@ ghoul::Dictionary SkybrowserModule::createMessageForMovingWWTCamera(const glm::d
return msg;
}
ghoul::Dictionary SkybrowserModule::createMessageForLoadingWWTImgColl(const std::string& url) const {
using namespace std::string_literals;
ghoul::Dictionary msg;
msg.setValue("event", "center_on_coordinates"s);
msg.setValue("url", url);
return msg;
}
ghoul::Dictionary SkybrowserModule::createMessageForPausingWWTTime() const {
using namespace std::string_literals;
ghoul::Dictionary msg;
@@ -197,6 +216,19 @@ glm::dvec2 SkybrowserModule::convertGalacticToCelestial(glm::dvec3 rGal) const {
return glm::dvec2(glm::degrees(ra), glm::degrees(dec));
}
void SkybrowserModule::showTarget() const {
using namespace std::string_literals;
ghoul::Dictionary node;
node.setValue("Type", "ScreenSpaceImageLocal"s);
node.setValue("Identifier", "Target"s);
node.setValue("TexturePath", "D:/Ylvas/OpenSpace/modules/skybrowser/target.png"s);
node.setValue("Scale", 0.07);
openspace::global::scriptEngine->queueScript(
"openspace.addScreenSpaceRenderable(" + ghoul::formatLua(node) + ")",
scripting::ScriptEngine::RemoteScripting::Yes
);
}
/*
std::vector<documentation::Documentation> SkybrowserModule::documentations() const {
return {
+2
View File
@@ -47,9 +47,11 @@ public:
float zoomFactor() const;
glm::dvec2 convertGalacticToCelestial(glm::dvec3 coords) const;
void WWTfollowCamera();
void showTarget() const;
ghoul::Dictionary createMessageForMovingWWTCamera(const glm::dvec2 celestCoords, const float fov, const bool moveInstantly = true) const;
ghoul::Dictionary createMessageForPausingWWTTime() const;
ghoul::Dictionary createMessageForLoadingWWTImgColl(const std::string& url) const;
bool sendMessageToWWT(const ghoul::Dictionary& msg);
+11 -4
View File
@@ -28,6 +28,15 @@ namespace {
namespace openspace::skybrowser::luascriptfunctions {
int loadImgCollection(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadCollection");
// https://docs.worldwidetelescope.org/data-guide/1/data-file-formats/collections/sample-blank-collection.wtml
std::string url = ghoul::lua::value<std::string>(L, 1);
SkybrowserModule* module = global::moduleEngine->module<SkybrowserModule>();
module->sendMessageToWWT(module->createMessageForLoadingWWTImgColl(url));
return 1;
}
int followCamera(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::followCamera");
@@ -35,6 +44,7 @@ namespace openspace::skybrowser::luascriptfunctions {
SkybrowserModule* module = global::moduleEngine->module<SkybrowserModule>();
//ghoul::Dictionary message = module->createMessageForPausingWWTTime();
//module->sendMessageToWWT(message);
module->showTarget();
std::thread thread(&SkybrowserModule::WWTfollowCamera, module);
thread.detach();
@@ -48,7 +58,6 @@ namespace openspace::skybrowser::luascriptfunctions {
SkybrowserModule* module = global::moduleEngine->module<SkybrowserModule>();
ScreenSpaceBrowser* browser = dynamic_cast<ScreenSpaceBrowser*>(global::renderEngine->screenSpaceRenderable("ScreenSpaceBowser"));
module->initializeBrowser(browser);
//ScreenSpaceBrowser* browser = dynamic_cast<ScreenSpaceBrowser*>(global::renderEngine->screenSpaceRenderable("ScreenSpaceBowser"));
module->skyBrowser()->setFaceCameraPropertyToFalse();
module->skyBrowser()->translate(glm::vec3(-0.8, -0.4, 0.0));
@@ -57,9 +66,7 @@ namespace openspace::skybrowser::luascriptfunctions {
}
int createBrowser(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::createBrowser");
ghoul::lua::value<std::string>(L, 1);
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::createBrowser");
SkybrowserModule* module = global::moduleEngine->module<SkybrowserModule>();