mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-23 05:19:18 -06:00
Merge remote-tracking branch 'origin/feature/skybrowser-reload' into issue/2029
# Conflicts: # modules/skybrowser/include/renderableskytarget.h # modules/skybrowser/include/wwtcommunicator.h # modules/skybrowser/skybrowsermodule.cpp
This commit is contained in:
@@ -948,6 +948,12 @@ void setSgctDelegateFunctions() {
|
||||
sgctDelegate.showStatistics = [](bool enabled) {
|
||||
Engine::instance().setStatsGraphVisibility(enabled);
|
||||
};
|
||||
sgctDelegate.numberOfNodes = []() {
|
||||
return ClusterManager::instance().numberOfNodes();
|
||||
};
|
||||
sgctDelegate.currentNode = []() {
|
||||
return ClusterManager::instance().thisNodeId();
|
||||
};
|
||||
}
|
||||
|
||||
void checkCommandLineForSettings(int& argc, char** argv, bool& hasSGCT, bool& hasProfile,
|
||||
|
||||
@@ -107,6 +107,10 @@ struct WindowDelegate {
|
||||
void (*setScreenshotFolder)(std::string) = [](std::string) {};
|
||||
|
||||
void (*showStatistics)(bool) = [](bool) {};
|
||||
|
||||
int (*numberOfNodes)() = []() { return 0; };
|
||||
|
||||
int (*currentNode)() = []() { return 0; };
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
void update();
|
||||
|
||||
void updateBrowserSize();
|
||||
void reload();
|
||||
|
||||
glm::vec2 browserPixelDimensions() const;
|
||||
float browserRatio() const;
|
||||
|
||||
@@ -62,10 +62,9 @@ private:
|
||||
properties::FloatProperty _crossHairSize;
|
||||
properties::FloatProperty _showRectangleThreshold;
|
||||
properties::FloatProperty _lineWidth;
|
||||
|
||||
double _borderRadius = 0.0;
|
||||
double _verticalFov = 10.0;
|
||||
properties::DoubleProperty _verticalFov;
|
||||
|
||||
double _borderRadius = 0.0;
|
||||
glm::ivec3 _borderColor = glm::ivec3(230);
|
||||
float _ratio = 1.f;
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
glm::dvec2 fineTuneVector(const glm::dvec2& drag);
|
||||
bool isInitialized() const;
|
||||
|
||||
void setVerticalFovWithScroll(float scroll);
|
||||
double setVerticalFovWithScroll(float scroll);
|
||||
void setOpacity(float opacity);
|
||||
void setRatio(float ratio);
|
||||
void setIdInBrowser() const;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_MODULE_SKYBROWSER___WWTCOMMUNICATOR___H__
|
||||
|
||||
#include <modules/skybrowser/include/browser.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
|
||||
#include <deque>
|
||||
|
||||
@@ -71,8 +72,9 @@ protected:
|
||||
void setIdInBrowser(const std::string& id) const;
|
||||
std::deque<std::pair<int, double>>::iterator findSelectedImage(int i);
|
||||
|
||||
properties::DoubleProperty _verticalFov;
|
||||
|
||||
double _borderRadius = 0.0;
|
||||
double _verticalFov = 10.0f;
|
||||
glm::ivec3 _borderColor = glm::ivec3(70);
|
||||
glm::dvec2 _equatorialAim = glm::dvec2(0.0);
|
||||
double _targetRoll = 0.0;
|
||||
|
||||
@@ -92,6 +92,12 @@ namespace {
|
||||
"inversed"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SynchronizeAimInfo = {
|
||||
"SynchronizeAim",
|
||||
"Synchronize Aim",
|
||||
"If checked, the target and the browser will have synchronized aim."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SpaceCraftTimeInfo = {
|
||||
"SpaceCraftAnimationTime",
|
||||
"Space Craft Animation Time",
|
||||
@@ -127,6 +133,9 @@ namespace {
|
||||
// [[codegen::verbatim(InverseZoomInfo.description)]]
|
||||
std::optional<bool> inverseZoomDirection;
|
||||
|
||||
// [[codegen::verbatim(SynchronizeAimInfo.description)]]
|
||||
std::optional<bool> synchronizeAim;
|
||||
|
||||
// [[codegen::verbatim(SpaceCraftTimeInfo.description)]]
|
||||
std::optional<double> spaceCraftAnimationTime;
|
||||
|
||||
@@ -149,6 +158,7 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
, _browserAnimationSpeed(BrowserSpeedInfo, 5.0, 0.0, 10.0)
|
||||
, _hideTargetsBrowsersWithGui(HideWithGuiInfo, false)
|
||||
, _inverseZoomDirection(InverseZoomInfo, false)
|
||||
, _synchronizeAim(SynchronizeAimInfo, true)
|
||||
, _spaceCraftAnimationTime(SpaceCraftTimeInfo, 2.0, 0.0, 10.0)
|
||||
, _wwtImageCollectionUrl(
|
||||
ImageCollectionInfo,
|
||||
@@ -165,6 +175,7 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
addProperty(_inverseZoomDirection);
|
||||
addProperty(_spaceCraftAnimationTime);
|
||||
addProperty(_wwtImageCollectionUrl);
|
||||
addProperty(_synchronizeAim);
|
||||
_wwtImageCollectionUrl.setReadOnly(true);
|
||||
|
||||
// Set callback functions
|
||||
@@ -209,8 +220,10 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
}
|
||||
|
||||
if (_isCameraInSolarSystem) {
|
||||
for (const std::unique_ptr<TargetBrowserPair>& pair : _targetsBrowsers) {
|
||||
pair->synchronizeAim();
|
||||
if (_synchronizeAim) {
|
||||
for (const std::unique_ptr<TargetBrowserPair>& pair : _targetsBrowsers) {
|
||||
pair->synchronizeAim();
|
||||
}
|
||||
}
|
||||
incrementallyAnimateTargets();
|
||||
}
|
||||
@@ -230,6 +243,7 @@ void SkyBrowserModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
_browserAnimationSpeed = p.browserSpeed.value_or(_browserAnimationSpeed);
|
||||
_inverseZoomDirection = p.inverseZoomDirection.value_or(_inverseZoomDirection);
|
||||
_wwtImageCollectionUrl = p.wwtImageCollectionUrl.value_or(_wwtImageCollectionUrl);
|
||||
_synchronizeAim = p.synchronizeAim.value_or(_synchronizeAim);
|
||||
_hideTargetsBrowsersWithGui = p.hideTargetsBrowsersGui.value_or(
|
||||
_hideTargetsBrowsersWithGui
|
||||
);
|
||||
@@ -525,7 +539,8 @@ scripting::LuaLibrary SkyBrowserModule::luaLibrary() const {
|
||||
codegen::lua::PointSpaceCraft,
|
||||
codegen::lua::GetWwtImageCollectionUrl,
|
||||
codegen::lua::StopAnimations,
|
||||
codegen::lua::SetBorderRadius
|
||||
codegen::lua::SetBorderRadius,
|
||||
codegen::lua::ReloadDisplayCopyOnNode
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ private:
|
||||
properties::DoubleProperty _browserAnimationSpeed;
|
||||
properties::BoolProperty _hideTargetsBrowsersWithGui;
|
||||
properties::BoolProperty _inverseZoomDirection;
|
||||
properties::BoolProperty _synchronizeAim;
|
||||
properties::DoubleProperty _spaceCraftAnimationTime;
|
||||
properties::StringProperty _wwtImageCollectionUrl;
|
||||
|
||||
|
||||
@@ -39,6 +39,37 @@
|
||||
namespace {
|
||||
constexpr std::string_view _loggerCat = "SkyBrowserModule";
|
||||
|
||||
|
||||
/**
|
||||
* Reloads the sky browser display copy for the node index that is sent in.
|
||||
* .If no ID is sent in, it will reload all display copies on that node.
|
||||
*/
|
||||
[[codegen::luawrap]] void reloadDisplayCopyOnNode(int nodeIndex, std::string id = "all") {
|
||||
using namespace openspace;
|
||||
|
||||
if (global::windowDelegate->currentNode() != nodeIndex)
|
||||
return;
|
||||
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
if (id != "all") {
|
||||
TargetBrowserPair* pair = module->pair(id);
|
||||
if (pair) {
|
||||
pair->browser()->setIsInitialized(false);
|
||||
pair->browser()->setImageCollectionIsLoaded(false);
|
||||
pair->browser()->reload();
|
||||
}
|
||||
}
|
||||
else {
|
||||
const std::vector<std::unique_ptr<TargetBrowserPair>>& pairs = module->pairs();
|
||||
for (const std::unique_ptr<TargetBrowserPair>& pair : pairs) {
|
||||
pair->browser()->setIsInitialized(false);
|
||||
pair->browser()->setImageCollectionIsLoaded(false);
|
||||
pair->browser()->reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes an index to an image and selects that image in the currently
|
||||
* selected sky browser.
|
||||
@@ -419,6 +450,10 @@ namespace {
|
||||
[[codegen::luawrap]] void createTargetBrowserPair() {
|
||||
using namespace openspace;
|
||||
|
||||
if (!global::windowDelegate->isMaster()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
|
||||
int uniqueIdentifier = module->uniqueIdentifierCounter();
|
||||
@@ -480,23 +515,23 @@ namespace {
|
||||
|
||||
global::scriptEngine->queueScript(
|
||||
"openspace.addScreenSpaceRenderable(" + browser + ");",
|
||||
scripting::ScriptEngine::RemoteScripting::No
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
global::scriptEngine->queueScript(
|
||||
"openspace.addSceneGraphNode(" + target + ");",
|
||||
scripting::ScriptEngine::RemoteScripting::No
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
global::scriptEngine->queueScript(
|
||||
"openspace.skybrowser.addPairToSkyBrowserModule('" + idTarget + "','"
|
||||
+ idBrowser + "');",
|
||||
scripting::ScriptEngine::RemoteScripting::No
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
global::scriptEngine->queueScript(
|
||||
"openspace.skybrowser.setSelectedBrowser('" + idBrowser + "');",
|
||||
scripting::ScriptEngine::RemoteScripting::No
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,10 @@ void Browser::updateBrowserSize() {
|
||||
_browserDimensions = _texture->dimensions();
|
||||
}
|
||||
|
||||
void Browser::reload() {
|
||||
_reload.set(true);
|
||||
}
|
||||
|
||||
float Browser::browserRatio() const {
|
||||
return static_cast<float>(_texture->dimensions().x) /
|
||||
static_cast<float>(_texture->dimensions().y);
|
||||
|
||||
@@ -68,6 +68,12 @@ namespace {
|
||||
"The thickness of the line of the target. The larger number, the thicker line"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VerticalFovInfo = {
|
||||
"VerticalFov",
|
||||
"Vertical Field Of View",
|
||||
"The vertical field of view of the target."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableSkyTarget)]] Parameters {
|
||||
// [[codegen::verbatim(crossHairSizeInfo.description)]]
|
||||
std::optional<float> crossHairSize;
|
||||
@@ -77,6 +83,9 @@ namespace {
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(VerticalFovInfo.description)]]
|
||||
std::optional<double> verticalFov;
|
||||
};
|
||||
|
||||
#include "renderableskytarget_codegen.cpp"
|
||||
@@ -93,6 +102,7 @@ RenderableSkyTarget::RenderableSkyTarget(const ghoul::Dictionary& dictionary)
|
||||
, _crossHairSize(crossHairSizeInfo, 2.f, 1.f, 10.f)
|
||||
, _showRectangleThreshold(RectangleThresholdInfo, 5.f, 0.1f, 70.f)
|
||||
, _lineWidth(LineWidthInfo, 13.f, 1.f, 100.f)
|
||||
, _verticalFov(VerticalFovInfo, 10.0, 0.00000000001, 70.0)
|
||||
, _borderColor(220, 220, 220)
|
||||
{
|
||||
// Handle target dimension property
|
||||
@@ -104,7 +114,12 @@ RenderableSkyTarget::RenderableSkyTarget(const ghoul::Dictionary& dictionary)
|
||||
_showRectangleThreshold = p.rectangleThreshold.value_or(_showRectangleThreshold);
|
||||
addProperty(_showRectangleThreshold);
|
||||
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
|
||||
_verticalFov= p.verticalFov.value_or(_verticalFov);
|
||||
_verticalFov.setReadOnly(true);
|
||||
addProperty(_verticalFov);
|
||||
}
|
||||
|
||||
void RenderableSkyTarget::bindTexture() {}
|
||||
|
||||
@@ -119,6 +119,7 @@ ScreenSpaceSkyBrowser::ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary
|
||||
addProperty(_browserDimensions);
|
||||
addProperty(_reload);
|
||||
addProperty(_textureQuality);
|
||||
addProperty(_verticalFov);
|
||||
|
||||
_textureQuality.onChange([this]() { _textureDimensionsIsDirty = true; });
|
||||
|
||||
@@ -333,12 +334,13 @@ void ScreenSpaceSkyBrowser::update() {
|
||||
WwtCommunicator::update();
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::setVerticalFovWithScroll(float scroll) {
|
||||
double ScreenSpaceSkyBrowser::setVerticalFovWithScroll(float scroll) {
|
||||
// Make scroll more sensitive the smaller the FOV
|
||||
double x = _verticalFov;
|
||||
double zoomFactor = atan(x / 50.0) + exp(x / 40.0) - 0.99999999999999999999999999999;
|
||||
double zoom = scroll > 0.0 ? zoomFactor : -zoomFactor;
|
||||
_verticalFov = std::clamp(_verticalFov + zoom, 0.0, 70.0);
|
||||
return _verticalFov;
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::bindTexture() {
|
||||
|
||||
@@ -268,7 +268,8 @@ void TargetBrowserPair::setBrowserRatio(float ratio) {
|
||||
}
|
||||
|
||||
void TargetBrowserPair::setVerticalFovWithScroll(float scroll) {
|
||||
_browser->setVerticalFovWithScroll(scroll);
|
||||
double fov = _browser->setVerticalFovWithScroll(scroll);
|
||||
_targetRenderable->setVerticalFov(fov);
|
||||
}
|
||||
|
||||
void TargetBrowserPair::setImageCollectionIsLoaded(bool isLoaded) {
|
||||
|
||||
@@ -116,13 +116,31 @@ namespace {
|
||||
MessageCounter++;
|
||||
return msg;
|
||||
}
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VerticalFovInfo = {
|
||||
"VerticalFov",
|
||||
"Vertical Field Of View",
|
||||
"The vertical field of view of the target."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(WwtCommunicator)]] Parameters {
|
||||
// [[codegen::verbatim(VerticalFovInfo.description)]]
|
||||
std::optional<double> verticalFov;
|
||||
};
|
||||
#include "wwtcommunicator_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
WwtCommunicator::WwtCommunicator(const ghoul::Dictionary& dictionary)
|
||||
: Browser(dictionary)
|
||||
{}
|
||||
, _verticalFov(VerticalFovInfo, 10.0, 0.00000000001, 70.0)
|
||||
{
|
||||
// Handle target dimension property
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
_verticalFov = p.verticalFov.value_or(_verticalFov);
|
||||
_verticalFov.setReadOnly(true);
|
||||
}
|
||||
|
||||
void WwtCommunicator::update() {
|
||||
// Cap how messages are passed
|
||||
|
||||
Reference in New Issue
Block a user