Add WorldWide Telescope image collection url as property to sky browser module

This commit is contained in:
Ylva Selling
2022-04-29 14:42:13 -04:00
parent db7c5ee23f
commit cb766f8f96
3 changed files with 36 additions and 8 deletions

View File

@@ -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<bool> enabled;
@@ -125,6 +131,9 @@ namespace {
// [[codegen::verbatim(SpaceCraftTimeInfo.description)]]
std::optional<double> spaceCraftAnimationTime;
// [[codegen::verbatim(SpaceCraftTimeInfo.description)]]
std::optional<std::string> 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
}
};
}

View File

@@ -33,6 +33,7 @@
#include <openspace/util/mouse.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/doubleproperty.h>
#include <openspace/properties/stringproperty.h>
#include <fstream>
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

View File

@@ -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<SkyBrowserModule>();
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<SkyBrowserModule>();
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<SkyBrowserModule>();
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