mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-18 02:49:03 -06:00
Add functionality to check if the image collection has been loaded and pass that information to the GUI
This commit is contained in:
@@ -123,6 +123,7 @@ void SkyBrowserTopic::sendBrowserData() {
|
||||
target.setValue("roll", pair->targetRoll());
|
||||
target.setValue("color", pair->borderColor());
|
||||
target.setValue("cartesianDirection", cartesian);
|
||||
target.setValue("isImageCollectionLoaded", pair->isImageCollectionLoaded());
|
||||
target.setValue("isFacingCamera", pair->isFacingCamera());
|
||||
target.setValue("isUsingRae", pair->isUsingRadiusAzimuthElevation());
|
||||
target.setValue("selectedImages", selectedImagesVector);
|
||||
|
||||
@@ -86,6 +86,9 @@ protected:
|
||||
|
||||
void executeJavascript(const std::string& script) const;
|
||||
|
||||
bool _isUrlDirty = false;
|
||||
bool _isDimensionsDirty = false;
|
||||
bool _shouldReload = false;
|
||||
private:
|
||||
class RenderHandler : public WebRenderHandler {
|
||||
public:
|
||||
@@ -98,10 +101,6 @@ private:
|
||||
std::unique_ptr<BrowserInstance> _browserInstance;
|
||||
CefRefPtr<RenderHandler> _renderHandler;
|
||||
CefRefPtr<WebKeyboardHandler> _keyboardHandler;
|
||||
|
||||
bool _isUrlDirty = false;
|
||||
bool _isDimensionsDirty = false;
|
||||
bool _shouldReload = false;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -48,15 +48,14 @@ public:
|
||||
|
||||
float opacity() const;
|
||||
glm::vec2 size() const;
|
||||
glm::dvec2 fineTuneVector(const glm::dvec2& drag);
|
||||
|
||||
void setVerticalFovWithScroll(float scroll);
|
||||
void setOpacity(float opacity);
|
||||
void setScreenSpaceSize(glm::vec2 newSize);
|
||||
void updateScreenSpaceSize();
|
||||
|
||||
glm::dvec2 fineTuneVector(const glm::dvec2& drag);
|
||||
void setIdInBrowser() const;
|
||||
|
||||
void updateScreenSpaceSize();
|
||||
void updateTextureResolution();
|
||||
|
||||
// Copies rendered
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
void sendIdToBrowser() const;
|
||||
void updateBrowserSize();
|
||||
std::vector<std::pair<std::string, glm::dvec3>> renderCopies() const;
|
||||
bool isImageCollectionLoaded();
|
||||
|
||||
// Target
|
||||
void centerTargetOnScreen();
|
||||
@@ -79,6 +80,7 @@ public:
|
||||
void setBorderColor(const glm::ivec3& color);
|
||||
void setScreenSpaceSize(const glm::vec2& dimensions);
|
||||
void setVerticalFovWithScroll(float scroll);
|
||||
void setImageCollectionIsLoaded(bool isLoaded);
|
||||
|
||||
double verticalFov() const;
|
||||
glm::ivec3 borderColor() const;
|
||||
@@ -97,6 +99,7 @@ public:
|
||||
// WorldWide Telescope image handling
|
||||
void setImageOrder(int i, int order);
|
||||
void selectImage(const ImageData& image, int i);
|
||||
void addImageLayerToWwt(const std::string& url, int i);
|
||||
void removeSelectedImage(int i);
|
||||
void loadImageCollection(const std::string& collection);
|
||||
void setImageOpacity(int i, float opacity);
|
||||
|
||||
@@ -44,21 +44,22 @@ public:
|
||||
void update();
|
||||
|
||||
// WorldWide Telescope communication
|
||||
void displayImage(const std::string& url, int i);
|
||||
void selectImage(const std::string& url, int i);
|
||||
void addImageLayerToWwt(const std::string& url, int i);
|
||||
void removeSelectedImage(int i);
|
||||
void setImageOrder(int i, int order);
|
||||
void loadImageCollection(const std::string& collection);
|
||||
void setImageOpacity(int i, float opacity) const;
|
||||
void hideChromeInterface(bool shouldHide) const;
|
||||
|
||||
bool hasLoadedImages() const;
|
||||
bool isImageCollectionLoaded() const;
|
||||
double verticalFov() const;
|
||||
glm::ivec3 borderColor() const;
|
||||
glm::dvec2 equatorialAim() const;
|
||||
glm::dvec2 fieldsOfView() const;
|
||||
const std::deque<int>& getSelectedImages() const;
|
||||
|
||||
void setHasLoadedImages(bool isLoaded);
|
||||
void setImageCollectionIsLoaded(bool isLoaded);
|
||||
void setVerticalFov(double vfov);
|
||||
void setIsSyncedWithWwt(bool isSynced);
|
||||
void setEquatorialAim(glm::dvec2 equatorial);
|
||||
@@ -78,7 +79,7 @@ protected:
|
||||
glm::ivec3 _borderColor = glm::ivec3(70);
|
||||
glm::dvec2 _equatorialAim = glm::dvec2(0.0);
|
||||
double _targetRoll = 0.0;
|
||||
bool _hasLoadedImages = false;
|
||||
bool _isImageCollectionLoaded = false;
|
||||
std::deque<int> _selectedImages;
|
||||
|
||||
private:
|
||||
|
||||
@@ -296,7 +296,11 @@ TargetBrowserPair* SkyBrowserModule::getPair(const std::string& id) const {
|
||||
return foundBrowser || foundTarget || foundTargetNode;
|
||||
}
|
||||
);
|
||||
return it != _targetsBrowsers.end() ? it->get() : nullptr;
|
||||
TargetBrowserPair* found = it != _targetsBrowsers.end() ? it->get() : nullptr;
|
||||
if (found == nullptr) {
|
||||
LINFO("Identifier " + id + " not found.");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void SkyBrowserModule::startRotatingCamera(glm::dvec3 endAnimation) {
|
||||
@@ -420,7 +424,8 @@ scripting::LuaLibrary SkyBrowserModule::luaLibrary() const {
|
||||
codegen::lua::RemoveRenderCopy,
|
||||
codegen::lua::StartFinetuningTarget,
|
||||
codegen::lua::FinetuneTargetPosition,
|
||||
codegen::lua::ScrollOverBrowser
|
||||
codegen::lua::ScrollOverBrowser,
|
||||
codegen::lua::LoadingImageCollectionComplete
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,14 +51,18 @@ namespace {
|
||||
if (module->isCameraInSolarSystem()) {
|
||||
TargetBrowserPair* selected = module->getPair(module->selectedBrowserId());
|
||||
if (selected) {
|
||||
if (!selected->isImageCollectionLoaded()) {
|
||||
LINFO("Image collection is not yet loaded to AAS WorldWide Telescope");
|
||||
return;
|
||||
}
|
||||
const ImageData& image = module->getWwtDataHandler()->getImage(imageIndex);
|
||||
// Load image into browser
|
||||
std::string str = image.name;
|
||||
// Check if character is ASCII - if it isn't, remove
|
||||
str.erase(
|
||||
std::remove_if(
|
||||
str.begin(), str.end(),
|
||||
[](char c) {
|
||||
// Check if character is ASCII - if it isn't, remove
|
||||
return c < 0 || c >= 128;
|
||||
}
|
||||
),
|
||||
@@ -711,6 +715,27 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image collection as loaded in the sky browser
|
||||
*/
|
||||
[[codegen::luawrap]] void loadingImageCollectionComplete(std::string identifier) {
|
||||
using namespace openspace;
|
||||
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
TargetBrowserPair* pair = module->getPair(identifier);
|
||||
if (pair) {
|
||||
LINFO("Image collection is loaded in Screen Space Sky Browser " + identifier);
|
||||
pair->setImageCollectionIsLoaded(true);
|
||||
// Add all selected images to WorldWide Telescope
|
||||
const std::deque<int>& images = pair->selectedImages();
|
||||
std::for_each(images.rbegin(), images.rend(), [&](int index) {
|
||||
const ImageData& image = module->getWwtDataHandler()->getImage(index);
|
||||
// Index of image is used as layer ID as it is unique in the image data set
|
||||
pair->browser()->addImageLayerToWwt(image.imageUrl, index);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#include "skybrowsermodule_lua_codegen.cpp"
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -186,7 +186,7 @@ const std::deque<int>& TargetBrowserPair::selectedImages() const {
|
||||
|
||||
void TargetBrowserPair::selectImage(const ImageData& image, int i) {
|
||||
// Load image into browser
|
||||
_browser->displayImage(image.imageUrl, i);
|
||||
_browser->selectImage(image.imageUrl, i);
|
||||
|
||||
// If the image has coordinates, move the target
|
||||
if (image.hasCelestialCoords) {
|
||||
@@ -197,6 +197,10 @@ void TargetBrowserPair::selectImage(const ImageData& image, int i) {
|
||||
}
|
||||
}
|
||||
|
||||
void TargetBrowserPair::addImageLayerToWwt(const std::string& url, int i) {
|
||||
_browser->addImageLayerToWwt(url, i);
|
||||
}
|
||||
|
||||
void TargetBrowserPair::removeSelectedImage(int i) {
|
||||
_browser->removeSelectedImage(i);
|
||||
}
|
||||
@@ -225,6 +229,10 @@ std::vector<std::pair<std::string, glm::dvec3>> TargetBrowserPair::renderCopies(
|
||||
return _browser->renderCopies();
|
||||
}
|
||||
|
||||
bool TargetBrowserPair::isImageCollectionLoaded() {
|
||||
return _browser->isImageCollectionLoaded();
|
||||
}
|
||||
|
||||
void TargetBrowserPair::setIsSyncedWithWwt(bool isSynced) {
|
||||
_browser->setIsSyncedWithWwt(isSynced);
|
||||
}
|
||||
@@ -257,6 +265,10 @@ void TargetBrowserPair::setVerticalFovWithScroll(float scroll) {
|
||||
_browser->setVerticalFovWithScroll(scroll);
|
||||
}
|
||||
|
||||
void TargetBrowserPair::setImageCollectionIsLoaded(bool isLoaded) {
|
||||
_browser->setImageCollectionIsLoaded(isLoaded);
|
||||
}
|
||||
|
||||
void TargetBrowserPair::incrementallyAnimateToCoordinate() {
|
||||
// Animate the target before the field of view starts to animate
|
||||
if (_moveTarget.isAnimating()) {
|
||||
|
||||
@@ -42,18 +42,22 @@ WwtCommunicator::WwtCommunicator(const ghoul::Dictionary& dictionary)
|
||||
|
||||
WwtCommunicator::~WwtCommunicator() {}
|
||||
|
||||
void WwtCommunicator::displayImage(const std::string& url, int i) {
|
||||
void WwtCommunicator::selectImage(const std::string& url, int i) {
|
||||
// Ensure there are no duplicates
|
||||
auto it = std::find(_selectedImages.begin(), _selectedImages.end(), i);
|
||||
if (it == _selectedImages.end()) {
|
||||
// Push newly selected image to front
|
||||
_selectedImages.push_front(i);
|
||||
// Index of image is used as layer ID as it is unique in the image data set
|
||||
sendMessageToWwt(addImageMessage(std::to_string(i), url));
|
||||
sendMessageToWwt(setImageOpacityMessage(std::to_string(i), 1.0));
|
||||
addImageLayerToWwt(url, i);
|
||||
}
|
||||
}
|
||||
|
||||
void WwtCommunicator::addImageLayerToWwt(const std::string& url, int i) {
|
||||
// Index of image is used as layer ID as it is unique in the image data set
|
||||
sendMessageToWwt(addImageMessage(std::to_string(i), url));
|
||||
sendMessageToWwt(setImageOpacityMessage(std::to_string(i), 1.0));
|
||||
}
|
||||
|
||||
void WwtCommunicator::removeSelectedImage(int i) {
|
||||
// Remove from selected list
|
||||
auto it = std::find(_selectedImages.begin(), _selectedImages.end(), i);
|
||||
@@ -125,8 +129,8 @@ glm::dvec2 WwtCommunicator::fieldsOfView() const {
|
||||
return browserFov;
|
||||
}
|
||||
|
||||
bool WwtCommunicator::hasLoadedImages() const {
|
||||
return _hasLoadedImages;
|
||||
bool WwtCommunicator::isImageCollectionLoaded() const {
|
||||
return _isImageCollectionLoaded;
|
||||
}
|
||||
|
||||
glm::dvec2 WwtCommunicator::equatorialAim() const {
|
||||
@@ -150,8 +154,9 @@ void WwtCommunicator::setImageOrder(int i, int order) {
|
||||
}
|
||||
|
||||
void WwtCommunicator::loadImageCollection(const std::string& collection) {
|
||||
sendMessageToWwt(loadCollectionMessage(collection));
|
||||
_hasLoadedImages = true;
|
||||
if (!_isImageCollectionLoaded) {
|
||||
sendMessageToWwt(loadCollectionMessage(collection));
|
||||
}
|
||||
}
|
||||
|
||||
void WwtCommunicator::setImageOpacity(int i, float opacity) const {
|
||||
@@ -166,7 +171,6 @@ void WwtCommunicator::hideChromeInterface(bool shouldHide) const {
|
||||
}
|
||||
|
||||
void WwtCommunicator::update() {
|
||||
Browser::update();
|
||||
// Cap how messages are passed
|
||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
||||
std::chrono::system_clock::duration timeSinceLastUpdate = now - _lastUpdateTime;
|
||||
@@ -180,12 +184,16 @@ void WwtCommunicator::update() {
|
||||
updateBorderColor();
|
||||
_borderColorIsDirty = false;
|
||||
}
|
||||
if (_shouldReload) {
|
||||
_isImageCollectionLoaded = false;
|
||||
}
|
||||
_lastUpdateTime = std::chrono::system_clock::now();
|
||||
}
|
||||
Browser::update();
|
||||
}
|
||||
|
||||
void WwtCommunicator::setHasLoadedImages(bool isLoaded) {
|
||||
_hasLoadedImages = isLoaded;
|
||||
void WwtCommunicator::setImageCollectionIsLoaded(bool isLoaded) {
|
||||
_isImageCollectionLoaded = isLoaded;
|
||||
}
|
||||
|
||||
void WwtCommunicator::setIdInBrowser(const std::string& id) const {
|
||||
|
||||
Reference in New Issue
Block a user