diff --git a/modules/skybrowser/skybrowsermodule.cpp b/modules/skybrowser/skybrowsermodule.cpp index 288540da27..0dfaa533b5 100644 --- a/modules/skybrowser/skybrowsermodule.cpp +++ b/modules/skybrowser/skybrowsermodule.cpp @@ -101,6 +101,12 @@ namespace { "pointed to where the target is aiming." }; + constexpr const openspace::properties::Property::PropertyInfo ImageCollectionInfo = { + "WwtImageCollectionUrl", + "AAS WorldWide Telescope Image Collection Url", + "The url of the image collection which is loaded into AAS WorldWide Telescope." + }; + struct [[codegen::Dictionary(SkyBrowserModule)]] Parameters { // [[codegen::verbatim(EnabledInfo.description)]] std::optional enabled; @@ -125,6 +131,9 @@ namespace { // [[codegen::verbatim(SpaceCraftTimeInfo.description)]] std::optional spaceCraftAnimationTime; + + // [[codegen::verbatim(SpaceCraftTimeInfo.description)]] + std::optional wwtImageCollectionUrl; }; #include "skybrowsermodule_codegen.cpp" @@ -143,6 +152,8 @@ SkyBrowserModule::SkyBrowserModule() , _hideTargetsBrowsersWithGui(HideWithGuiInfo, false) , _inverseZoomDirection(InverseZoomInfo, false) , _spaceCraftAnimationTime(SpaceCraftTimeInfo, 2.0, 0.0, 10.0) + , _wwtImageCollectionUrl(ImageCollectionInfo, + "https://data.openspaceproject.com/wwt/1/imagecollection.wtml") { addProperty(_enabled); addProperty(_showTitleInGuiBrowser); @@ -153,6 +164,8 @@ SkyBrowserModule::SkyBrowserModule() addProperty(_hideTargetsBrowsersWithGui); addProperty(_inverseZoomDirection); addProperty(_spaceCraftAnimationTime); + addProperty(_wwtImageCollectionUrl); + _wwtImageCollectionUrl.setReadOnly(true); // Set callback functions global::callback::mouseButton->emplace(global::callback::mouseButton->begin(), @@ -421,6 +434,10 @@ double SkyBrowserModule::spaceCraftAnimationTime() const { return _spaceCraftAnimationTime; } +std::string SkyBrowserModule::wwtImageCollectionUrl() const { + return _wwtImageCollectionUrl; +} + void SkyBrowserModule::setSelectedBrowser(const std::string& id) { TargetBrowserPair* found = getPair(id); if (found) { @@ -519,7 +536,8 @@ scripting::LuaLibrary SkyBrowserModule::luaLibrary() const { codegen::lua::ScrollOverBrowser, codegen::lua::LoadingImageCollectionComplete, codegen::lua::ShowAllTargetsAndBrowsers, - codegen::lua::PointSpaceCraft + codegen::lua::PointSpaceCraft, + codegen::lua::GetWwtImageCollectionUrl } }; } diff --git a/modules/skybrowser/skybrowsermodule.h b/modules/skybrowser/skybrowsermodule.h index fa3b8e872c..b680c60b40 100644 --- a/modules/skybrowser/skybrowsermodule.h +++ b/modules/skybrowser/skybrowsermodule.h @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace openspace { @@ -71,6 +72,7 @@ public: double targetAnimationSpeed() const; double browserAnimationSpeed() const; double spaceCraftAnimationTime() const; + std::string wwtImageCollectionUrl() const; bool isCameraInSolarSystem() const; bool isSelectedPairFacingCamera() const; @@ -107,6 +109,7 @@ private: properties::DoubleProperty _targetAnimationSpeed; properties::DoubleProperty _browserAnimationSpeed; properties::DoubleProperty _spaceCraftAnimationTime; + properties::StringProperty _wwtImageCollectionUrl; glm::ivec3 _highlightAddition = glm::ivec3(35); // Highlight object when mouse hovers // The browsers and targets diff --git a/modules/skybrowser/skybrowsermodule_lua.inl b/modules/skybrowser/skybrowsermodule_lua.inl index a122026c66..4200a41415 100644 --- a/modules/skybrowser/skybrowsermodule_lua.inl +++ b/modules/skybrowser/skybrowsermodule_lua.inl @@ -140,13 +140,11 @@ namespace { LINFO("Loading image collections to " + identifier); // Load the collections here because we know that the browser can execute javascript - std::string root = "https://data.openspaceproject.com/wwt/1/imagecollection.wtml"; - SkyBrowserModule* module = global::moduleEngine->module(); TargetBrowserPair* pair = module->getPair(identifier); if (pair) { pair->hideChromeInterface(true); - pair->loadImageCollection(root); + pair->loadImageCollection(module->wwtImageCollectionUrl()); } } @@ -233,6 +231,17 @@ namespace { module->addTargetBrowserPair(targetId, browserId); } +/** + * Returns the AAS WorldWide Telescope image collection url. + */ +[[codegen::luawrap]] ghoul::Dictionary getWwtImageCollectionUrl() { + using namespace openspace; + SkyBrowserModule* module = global::moduleEngine->module(); + ghoul::Dictionary url; + url.setValue("url", module->wwtImageCollectionUrl()); + return url; +} + /** * Returns a list of all the loaded AAS WorldWide Telescope images that have been loaded. * Each image has a name, thumbnail url, equatorial spherical coordinates RA and Dec, @@ -244,13 +253,11 @@ namespace { // Send image list to GUI SkyBrowserModule* module = global::moduleEngine->module(); - + std::string url = module->wwtImageCollectionUrl(); // If no data has been loaded yet, download the data from the web! if (module->nLoadedImages() == 0) { - std::string root = "https://data.openspaceproject.com/wwt/1/imagecollection.wtml"; - std::filesystem::path directory = absPath("${MODULE_SKYBROWSER}/wwtimagedata/"); - module->loadImages(root, directory); + module->loadImages(url, directory); } // Create Lua table to send to the GUI