mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-07 12:00:05 -05:00
Merge pull request #2359 from OpenSpace/issue/2313
Issue/2313: Ensure all nodes in a cluster loads the image collection in the sky browser
This commit is contained in:
@@ -113,10 +113,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
|
||||
std::unique_ptr<ServerInterface> serverInterface =
|
||||
ServerInterface::createFromDictionary(interfaceDictionary);
|
||||
|
||||
|
||||
if (global::windowDelegate->isMaster()) {
|
||||
serverInterface->initialize();
|
||||
}
|
||||
serverInterface->initialize();
|
||||
|
||||
_interfaceOwner.addPropertySubOwner(serverInterface.get());
|
||||
|
||||
@@ -132,10 +129,6 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
|
||||
}
|
||||
|
||||
void ServerModule::preSync() {
|
||||
if (!global::windowDelegate->isMaster()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up new connections.
|
||||
for (std::unique_ptr<ServerInterface>& serverInterface : _interfaces) {
|
||||
if (!serverInterface->isEnabled()) {
|
||||
@@ -204,9 +197,7 @@ void ServerModule::disconnectAll() {
|
||||
ZoneScoped
|
||||
|
||||
for (std::unique_ptr<ServerInterface>& serverInterface : _interfaces) {
|
||||
if (global::windowDelegate->isMaster()) {
|
||||
serverInterface->deinitialize();
|
||||
}
|
||||
serverInterface->deinitialize();
|
||||
}
|
||||
|
||||
for (ConnectionData& connectionData : _connections) {
|
||||
|
||||
@@ -35,10 +35,34 @@
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <scn/scn.h>
|
||||
|
||||
namespace {
|
||||
constexpr std::string_view _loggerCat = "SkyBrowserModule";
|
||||
constexpr std::string_view _loggerCat = "SkyBrowserModule";
|
||||
|
||||
bool browserBelongsToCurrentNode(std::string identifier) {
|
||||
size_t found = identifier.find('_');
|
||||
std::string errorMessage = "The Sky Browser encountered a problem when it tried to "
|
||||
"initialize the browser";
|
||||
if (found == std::string::npos) {
|
||||
throw ghoul::RuntimeError(errorMessage);
|
||||
}
|
||||
else {
|
||||
std::string res = identifier.substr(found + 1, identifier.size());
|
||||
if (res.empty()) {
|
||||
throw ghoul::RuntimeError(errorMessage);
|
||||
}
|
||||
// Convert the last char to an int
|
||||
int nodeId = std::stoi(res);
|
||||
return nodeId == openspace::global::windowDelegate->currentNode();
|
||||
}
|
||||
}
|
||||
|
||||
std::string prunedIdentifier(std::string identifier) {
|
||||
// Removes the node number at the end of the identifier
|
||||
std::string res = identifier.substr(0, identifier.find('_'));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the sky browser display copy for the node index that is sent in.
|
||||
@@ -186,13 +210,17 @@ namespace {
|
||||
[[codegen::luawrap]] void loadImagesToWWT(std::string identifier) {
|
||||
using namespace openspace;
|
||||
|
||||
if (!browserBelongsToCurrentNode(identifier)) {
|
||||
return;
|
||||
}
|
||||
std::string prunedId = prunedIdentifier(identifier);
|
||||
// Load images from url
|
||||
LINFO("Connection established to WorldWide Telescope application in " + identifier);
|
||||
LINFO("Loading image collections to " + identifier);
|
||||
LINFO("Connection established to WorldWide Telescope application in " + prunedId);
|
||||
LINFO("Loading image collections to " + prunedId);
|
||||
|
||||
// Load the collections here because we know that the browser can execute javascript
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
TargetBrowserPair* pair = module->pair(identifier);
|
||||
TargetBrowserPair* pair = module->pair(prunedId);
|
||||
if (pair) {
|
||||
pair->hideChromeInterface();
|
||||
pair->browser()->loadImageCollection(module->wwtImageCollectionUrl());
|
||||
@@ -224,12 +252,11 @@ namespace {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// To ensure each node in a cluster calls its own instance of the wwt application
|
||||
// Do not send this script to the other nodes
|
||||
global::scriptEngine->queueScript(
|
||||
"openspace.skybrowser.sendOutIdsToBrowsers()",
|
||||
scripting::ScriptEngine::RemoteScripting::No
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
@@ -258,9 +285,14 @@ namespace {
|
||||
using namespace openspace;
|
||||
|
||||
// Initialize browser with ID and its corresponding target
|
||||
LINFO("Initializing sky browser " + identifier);
|
||||
if (!browserBelongsToCurrentNode(identifier)) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string prunedId = prunedIdentifier(identifier);
|
||||
LINFO("Initializing sky browser " + prunedId);
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
TargetBrowserPair* pair = module->pair(identifier);
|
||||
TargetBrowserPair* pair = module->pair(prunedId);
|
||||
if (pair) {
|
||||
pair->initialize();
|
||||
}
|
||||
@@ -479,7 +511,7 @@ namespace {
|
||||
glm::vec3 positionTarget = glm::vec3(0.9f, 0.4f, -2.1f);
|
||||
glm::dvec3 galacticTarget = skybrowser::localCameraToGalactic(positionTarget);
|
||||
if (glm::any(glm::isnan(galacticTarget))) {
|
||||
galacticTarget = glm::dvec3 (0.0, 0.0, skybrowser::CelestialSphereRadius);
|
||||
galacticTarget = glm::dvec3(0.0, 0.0, skybrowser::CelestialSphereRadius);
|
||||
}
|
||||
std::string guiPath = "/Sky Browser";
|
||||
std::string url = "http://wwt.openspaceproject.com/1/openspace/";
|
||||
@@ -777,10 +809,15 @@ namespace {
|
||||
[[codegen::luawrap]] void loadingImageCollectionComplete(std::string identifier) {
|
||||
using namespace openspace;
|
||||
|
||||
if (!browserBelongsToCurrentNode(identifier)) {
|
||||
return;
|
||||
}
|
||||
std::string prunedId = prunedIdentifier(identifier);
|
||||
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
TargetBrowserPair* pair = module->pair(identifier);
|
||||
TargetBrowserPair* pair = module->pair(prunedId);
|
||||
if (pair) {
|
||||
LINFO("Image collection is loaded in Screen Space Sky Browser " + identifier);
|
||||
LINFO("Image collection is loaded in Screen Space Sky Browser " + prunedId);
|
||||
pair->setImageCollectionIsLoaded(true);
|
||||
// Add all selected images to WorldWide Telescope
|
||||
const std::vector<std::string>& images = pair->selectedImages();
|
||||
|
||||
@@ -195,7 +195,8 @@ bool ScreenSpaceSkyBrowser::isPointingSpacecraft() const {
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::setIdInBrowser() const {
|
||||
WwtCommunicator::setIdInBrowser(identifier());
|
||||
int currentNode = global::windowDelegate->currentNode();
|
||||
WwtCommunicator::setIdInBrowser(fmt::format("{}_{}", identifier(), currentNode));
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::setIsInitialized(bool isInitialized) {
|
||||
|
||||
@@ -576,26 +576,31 @@ void ScriptEngine::writeLog(const std::string& script) {
|
||||
void ScriptEngine::preSync(bool isMaster) {
|
||||
ZoneScoped
|
||||
|
||||
if (!isMaster) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard guard(_clientScriptsMutex);
|
||||
while (!_incomingScripts.empty()) {
|
||||
QueueItem item = std::move(_incomingScripts.front());
|
||||
_incomingScripts.pop();
|
||||
if (isMaster) {
|
||||
while (!_incomingScripts.empty()) {
|
||||
QueueItem item = std::move(_incomingScripts.front());
|
||||
_incomingScripts.pop();
|
||||
|
||||
_scriptsToSync.push_back(item.script);
|
||||
const bool remoteScripting = item.remoteScripting;
|
||||
_scriptsToSync.push_back(item.script);
|
||||
const bool remoteScripting = item.remoteScripting;
|
||||
|
||||
// Not really a received script but the master also needs to run the script...
|
||||
_masterScriptQueue.push(item);
|
||||
// Not really a received script but the master also needs to run the script...
|
||||
_masterScriptQueue.push(item);
|
||||
|
||||
if (global::parallelPeer->isHost() && remoteScripting) {
|
||||
global::parallelPeer->sendScript(item.script);
|
||||
if (global::parallelPeer->isHost() && remoteScripting) {
|
||||
global::parallelPeer->sendScript(item.script);
|
||||
}
|
||||
if (global::sessionRecording->isRecording()) {
|
||||
global::sessionRecording->saveScriptKeyframeToTimeline(item.script);
|
||||
}
|
||||
}
|
||||
if (global::sessionRecording->isRecording()) {
|
||||
global::sessionRecording->saveScriptKeyframeToTimeline(item.script);
|
||||
}
|
||||
else {
|
||||
while (!_incomingScripts.empty()) {
|
||||
QueueItem item = std::move(_incomingScripts.front());
|
||||
_incomingScripts.pop();
|
||||
_clientScriptQueue.push(item.script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user