mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
SkyBrowser Hash Handling (#2201)
* Add the loading of a hash for wwt image files and automatically force a redownload of the files if the hash has changed * Move the wwtdataimages location into the sync folder * Some general code cleanup
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
#include <modules/webbrowser/include/webrenderhandler.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/vector/vec2property.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <openspace/properties/vector/vec2property.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
explicit Browser(const ghoul::Dictionary& dictionary);
|
||||
virtual ~Browser();
|
||||
|
||||
bool initializeGL();
|
||||
void initializeGL();
|
||||
void deinitializeGL();
|
||||
bool isReady() const;
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void setCallbackDimensions(const std::function<void(const glm::dvec2&)>& function);
|
||||
|
||||
protected:
|
||||
properties::Vec2Property _browserPixeldimensions;
|
||||
properties::Vec2Property _browserDimensions;
|
||||
properties::StringProperty _url;
|
||||
properties::TriggerProperty _reload;
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <modules/skybrowser/include/wwtcommunicator.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/vec2property.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#define __OPENSPACE_MODULE_SKYBROWSER___TARGETBROWSERPAIR___H__
|
||||
|
||||
#include <modules/skybrowser/include/utility.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <deque>
|
||||
|
||||
namespace ghoul { class Dictionary; }
|
||||
|
||||
@@ -42,7 +40,6 @@ class ScreenSpaceRenderable;
|
||||
class TargetBrowserPair {
|
||||
public:
|
||||
TargetBrowserPair(SceneGraphNode* target, ScreenSpaceSkyBrowser* browser);
|
||||
TargetBrowserPair& operator=(TargetBrowserPair other);
|
||||
|
||||
// Target & Browser
|
||||
void initialize();
|
||||
@@ -60,9 +57,7 @@ public:
|
||||
|
||||
// Browser
|
||||
void sendIdToBrowser() const;
|
||||
void updateBrowserSize();
|
||||
std::vector<std::pair<std::string, glm::dvec3>> displayCopies() const;
|
||||
bool isImageCollectionLoaded();
|
||||
|
||||
// Target
|
||||
void centerTargetOnScreen();
|
||||
@@ -73,7 +68,6 @@ public:
|
||||
bool isEnabled() const;
|
||||
|
||||
void setEnabled(bool enable);
|
||||
void setOpacity(float opacity);
|
||||
void setVerticalFov(double vfov);
|
||||
void setEquatorialAim(const glm::dvec2& aim);
|
||||
void setBorderColor(const glm::ivec3& color);
|
||||
@@ -89,9 +83,7 @@ public:
|
||||
std::string browserId() const;
|
||||
std::string targetRenderableId() const;
|
||||
std::string targetNodeId() const;
|
||||
float browserRatio() const;
|
||||
|
||||
SceneGraphNode* targetNode() const;
|
||||
ScreenSpaceSkyBrowser* browser() const;
|
||||
std::vector<int> selectedImages() const;
|
||||
|
||||
@@ -106,12 +98,7 @@ public:
|
||||
void setImageOpacity(int i, float opacity);
|
||||
void hideChromeInterface();
|
||||
|
||||
friend bool operator==(const TargetBrowserPair& lhs, const TargetBrowserPair& rhs);
|
||||
friend bool operator!=(const TargetBrowserPair& lhs, const TargetBrowserPair& rhs);
|
||||
|
||||
private:
|
||||
void aimTargetGalactic(glm::dvec3 direction);
|
||||
|
||||
// Target and browser
|
||||
RenderableSkyTarget* _targetRenderable = nullptr;
|
||||
ScreenSpaceSkyBrowser* _browser = nullptr;
|
||||
|
||||
@@ -33,20 +33,7 @@ namespace openspace::skybrowser {
|
||||
|
||||
// Constants
|
||||
constexpr double ScreenSpaceZ = -2.1;
|
||||
constexpr glm::dvec3 NorthPole = { 0.0, 0.0, 1.0 };
|
||||
constexpr double CelestialSphereRadius = 4 * distanceconstants::Parsec;
|
||||
|
||||
// Conversion matrix - J2000 equatorial <-> galactic
|
||||
// https://arxiv.org/abs/1010.3773v1
|
||||
const glm::dmat3 conversionMatrix = glm::dmat3(
|
||||
-0.054875539390, 0.494109453633, -0.867666135681, // col 0
|
||||
-0.873437104725, -0.444829594298, -0.198076389622, // col 1
|
||||
-0.483834991775, 0.746982248696, 0.455983794523 // col 2
|
||||
);
|
||||
|
||||
// Galactic coordinates are projected onto the celestial sphere
|
||||
// Equatorial coordinates are unit length
|
||||
// Conversion spherical <-> Cartesian
|
||||
constexpr double CelestialSphereRadius = 4.0 * distanceconstants::Parsec;
|
||||
|
||||
/**
|
||||
* Converts from Cartesian coordinates to spherical coordinates with unit length.
|
||||
@@ -205,9 +192,8 @@ public:
|
||||
Animation(T start, T goal, double time)
|
||||
: _goal(std::move(goal))
|
||||
, _start(std::move(start))
|
||||
{
|
||||
_animationTime = std::chrono::milliseconds(static_cast<int>(time * 1000));
|
||||
}
|
||||
, _animationTime(std::chrono::milliseconds(static_cast<int>(time * 1000)))
|
||||
{}
|
||||
|
||||
void start() {
|
||||
_isStarted = true;
|
||||
@@ -219,12 +205,12 @@ public:
|
||||
}
|
||||
|
||||
bool isAnimating() const {
|
||||
bool timeLeft = timeSpent().count() < _animationTime.count() ? true : false;
|
||||
bool timeLeft = timeSpent().count() < _animationTime.count();
|
||||
return timeLeft && _isStarted;
|
||||
}
|
||||
|
||||
T getNewValue();
|
||||
glm::dmat4 getRotationMatrix();
|
||||
T newValue() const;
|
||||
glm::dmat4 rotationMatrix();
|
||||
|
||||
private:
|
||||
std::chrono::duration<double, std::milli> timeSpent() const {
|
||||
|
||||
@@ -27,10 +27,6 @@
|
||||
|
||||
#include <modules/skybrowser/include/browser.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/vector/dvec2property.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/ivec3property.h>
|
||||
#include <deque>
|
||||
|
||||
namespace openspace {
|
||||
@@ -38,8 +34,7 @@ namespace openspace {
|
||||
class WwtCommunicator : public Browser {
|
||||
public:
|
||||
explicit WwtCommunicator(const ghoul::Dictionary& dictionary);
|
||||
WwtCommunicator(const WwtCommunicator&) = default;
|
||||
~WwtCommunicator() override;
|
||||
~WwtCommunicator() override = default;
|
||||
|
||||
void update();
|
||||
|
||||
@@ -82,23 +77,10 @@ protected:
|
||||
std::deque<std::pair<int, double>> _selectedImages;
|
||||
|
||||
private:
|
||||
void setWebpageBorderColor(glm::ivec3 color) const;
|
||||
void sendMessageToWwt(const ghoul::Dictionary& msg) const;
|
||||
|
||||
// WorldWide Telescope messages
|
||||
ghoul::Dictionary moveCameraMessage(const glm::dvec2& celestCoords, double fov,
|
||||
double roll, bool shouldMoveInstantly = true) const;
|
||||
ghoul::Dictionary loadCollectionMessage(const std::string& url) const;
|
||||
ghoul::Dictionary setForegroundMessage(const std::string& name) const;
|
||||
ghoul::Dictionary addImageMessage(const std::string& id,
|
||||
const std::string& url) const;
|
||||
ghoul::Dictionary removeImageMessage(const std::string& id) const;
|
||||
ghoul::Dictionary setImageOpacityMessage(const std::string& id, double opacity) const;
|
||||
ghoul::Dictionary setLayerOrderMessage(const std::string& id, int version);
|
||||
|
||||
bool _borderColorIsDirty = false;
|
||||
bool _equatorialAimIsDirty = false;
|
||||
int messageCounter = 0;
|
||||
|
||||
// Time variables
|
||||
// For capping the message passing to WWT
|
||||
|
||||
@@ -25,51 +25,22 @@
|
||||
#ifndef __OPENSPACE_MODULE_SKYBROWSER___WWTDATAHANDLER___H__
|
||||
#define __OPENSPACE_MODULE_SKYBROWSER___WWTDATAHANDLER___H__
|
||||
|
||||
#include <modules/space/speckloader.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <unordered_map>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsuggest-override"
|
||||
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#endif
|
||||
|
||||
#include <modules/skybrowser/ext/tinyxml2/tinyxml2.h>
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
|
||||
namespace openspace::wwt {
|
||||
const std::string Thumbnail = "Thumbnail";
|
||||
const std::string Name = "Name";
|
||||
const std::string ImageSet = "ImageSet";
|
||||
const std::string Dec = "Dec";
|
||||
const std::string RA = "RA";
|
||||
const std::string Undefined = "";
|
||||
const std::string Folder = "Folder";
|
||||
const std::string Place = "Place";
|
||||
const std::string ThumbnailUrl = "ThumbnailUrl";
|
||||
const std::string Url = "Url";
|
||||
const std::string Credits = "Credits";
|
||||
const std::string CreditsUrl = "CreditsUrl";
|
||||
const std::string ZoomLevel = "ZoomLevel";
|
||||
const std::string DataSetType = "DataSetType";
|
||||
const std::string Sky = "Sky";
|
||||
} // namespace openspace::wwt
|
||||
namespace tinyxml2 { class XMLElement; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
struct ImageData {
|
||||
std::string name = wwt::Undefined;
|
||||
std::string thumbnailUrl = wwt::Undefined;
|
||||
std::string imageUrl = wwt::Undefined;
|
||||
std::string credits = wwt::Undefined;
|
||||
std::string creditsUrl = wwt::Undefined;
|
||||
std::string collection = wwt::Undefined;
|
||||
std::string name;
|
||||
std::string thumbnailUrl;
|
||||
std::string imageUrl;
|
||||
std::string credits;
|
||||
std::string creditsUrl;
|
||||
std::string collection;
|
||||
bool hasCelestialCoords = false;
|
||||
float fov = 0.f;
|
||||
glm::dvec2 equatorialSpherical = glm::dvec2(0.0);
|
||||
@@ -78,20 +49,15 @@ struct ImageData {
|
||||
|
||||
class WwtDataHandler {
|
||||
public:
|
||||
WwtDataHandler() = default;
|
||||
~WwtDataHandler();
|
||||
|
||||
void loadImages(const std::string& root, const std::filesystem::path& directory);
|
||||
int nLoadedImages() const;
|
||||
const ImageData& getImage(int i) const;
|
||||
const ImageData& image(int i) const;
|
||||
|
||||
private:
|
||||
void saveImageFromNode(tinyxml2::XMLElement* node, std::string collection);
|
||||
void saveImagesFromXml(tinyxml2::XMLElement* root, std::string collection);
|
||||
void saveImagesFromXml(const tinyxml2::XMLElement* root, std::string collection);
|
||||
|
||||
// Images
|
||||
std::vector<ImageData> _images;
|
||||
std::vector<tinyxml2::XMLDocument*> _xmls;
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user