mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-18 16:02:14 -05:00
Rename hover circle -> hover indicator (#3960)
* Rename hover circle -> hover indicator * Fix another "circle" reference
This commit is contained in:
@@ -3,15 +3,15 @@ local transforms = asset.require("scene/solarsystem/sun/transforms")
|
||||
|
||||
|
||||
local imageFolder = asset.resource({
|
||||
Name = "Hover Circle Image",
|
||||
Name = "Hover Indicator Image",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "misc_ring_image",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
|
||||
local circle = {
|
||||
Identifier = "hoverCircle",
|
||||
local Indicator = {
|
||||
Identifier = "HoverIndicator",
|
||||
Parent = transforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderablePlaneImageLocal",
|
||||
@@ -21,10 +21,10 @@ local circle = {
|
||||
Texture = imageFolder .. "ring.png"
|
||||
},
|
||||
GUI = {
|
||||
Name = "Hover Circle",
|
||||
Description = [[A circular marker that shows the position on the night sky
|
||||
of the object hovered in the sky browser UI. The circle will hide/show up
|
||||
dynamically, depending on the interaction with the items in the UI]],
|
||||
Name = "Hover Indicator",
|
||||
Description = [[A marker that shows the position on the night sky of the object
|
||||
hovered in the sky browser UI. The marker will hide/show up dynamically, depending
|
||||
on the interaction with the items in the UI]],
|
||||
Path = "/SkyBrowser",
|
||||
Hidden = true
|
||||
}
|
||||
@@ -32,20 +32,19 @@ local circle = {
|
||||
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.addSceneGraphNode(circle)
|
||||
openspace.skybrowser.setHoverCircle("hoverCircle")
|
||||
openspace.addSceneGraphNode(Indicator)
|
||||
openspace.skybrowser.setHoverIndicator("HoverIndicator")
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
openspace.removeSceneGraphNode(circle)
|
||||
openspace.removeSceneGraphNode(Indicator)
|
||||
end)
|
||||
|
||||
asset.export(circle)
|
||||
|
||||
asset.export(Indicator)
|
||||
|
||||
|
||||
asset.meta = {
|
||||
Name = "SkyBrowser Hover Circle",
|
||||
Name = "SkyBrowser Hover Indicator",
|
||||
Description = [[Includes a circular marker that shows the position on the night sky
|
||||
of the object hovered in the sky browser UI]],
|
||||
Author = "OpenSpace Team",
|
||||
@@ -1 +1 @@
|
||||
asset.require("./hover_circle")
|
||||
asset.require("./hover_indicator")
|
||||
|
||||
@@ -216,8 +216,8 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
pair->startFading(0.f, FadeDuration);
|
||||
}
|
||||
|
||||
// Also hide the hover circle
|
||||
disableHoverCircle();
|
||||
// Also hide the hover indicator
|
||||
disableHoverIndicator();
|
||||
}
|
||||
else {
|
||||
// Camera moved into the solar system => fade in
|
||||
@@ -312,26 +312,26 @@ void SkyBrowserModule::lookAtTarget(const std::string& id) {
|
||||
}
|
||||
}
|
||||
|
||||
void SkyBrowserModule::setHoverCircle(SceneGraphNode* circle) {
|
||||
ghoul_assert(circle, "No circle specified");
|
||||
_hoverCircle = circle;
|
||||
void SkyBrowserModule::setHoverIndicator(SceneGraphNode* circle) {
|
||||
ghoul_assert(circle, "No indicator specified");
|
||||
_hoverIndicator = circle;
|
||||
|
||||
// Always disable it per default. It should only be visible on interaction
|
||||
disableHoverCircle();
|
||||
disableHoverIndicator();
|
||||
}
|
||||
|
||||
void SkyBrowserModule::moveHoverCircle(const std::string& imageUrl, bool useScript) {
|
||||
void SkyBrowserModule::moveHoverIndicator(const std::string& imageUrl, bool useScript) {
|
||||
std::optional<const ImageData> found = _dataHandler.image(imageUrl);
|
||||
if (!found.has_value()) {
|
||||
return;
|
||||
}
|
||||
const ImageData image = *found;
|
||||
// Only move and show circle if the image has coordinates
|
||||
if (!(_hoverCircle && image.hasCelestialCoords && _isCameraInSolarSystem)) {
|
||||
if (!(_hoverIndicator && image.hasCelestialCoords && _isCameraInSolarSystem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string id = _hoverCircle->identifier();
|
||||
const std::string id = _hoverIndicator->identifier();
|
||||
|
||||
// Show the circle
|
||||
if (useScript) {
|
||||
@@ -341,7 +341,7 @@ void SkyBrowserModule::moveHoverCircle(const std::string& imageUrl, bool useScri
|
||||
global::scriptEngine->queueScript(script);
|
||||
}
|
||||
else {
|
||||
Renderable* renderable = _hoverCircle->renderable();
|
||||
Renderable* renderable = _hoverIndicator->renderable();
|
||||
if (renderable) {
|
||||
renderable->setFade(1.f);
|
||||
}
|
||||
@@ -360,20 +360,20 @@ void SkyBrowserModule::moveHoverCircle(const std::string& imageUrl, bool useScri
|
||||
global::scriptEngine->queueScript(script);
|
||||
}
|
||||
|
||||
void SkyBrowserModule::disableHoverCircle(bool useScript) {
|
||||
if (!_hoverCircle || !_hoverCircle->renderable()) {
|
||||
void SkyBrowserModule::disableHoverIndicator(bool useScript) {
|
||||
if (!_hoverIndicator || !_hoverIndicator->renderable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (useScript) {
|
||||
const std::string script = std::format(
|
||||
"openspace.setPropertyValueSingle('Scene.{}.Renderable.Fade', 0.0);",
|
||||
_hoverCircle->identifier()
|
||||
_hoverIndicator->identifier()
|
||||
);
|
||||
global::scriptEngine->queueScript(script);
|
||||
}
|
||||
else {
|
||||
Property* prop = _hoverCircle->renderable()->property("Fade");
|
||||
Property* prop = _hoverIndicator->renderable()->property("Fade");
|
||||
FloatProperty* floatProp = dynamic_cast<FloatProperty*>(prop);
|
||||
ghoul_assert(floatProp, "Fade property is not a float property");
|
||||
*floatProp = 0.f;
|
||||
@@ -508,9 +508,9 @@ LuaLibrary SkyBrowserModule::luaLibrary() const {
|
||||
codegen::lua::InitializeBrowser,
|
||||
codegen::lua::SendOutIdsToBrowsers,
|
||||
codegen::lua::ListOfImages,
|
||||
codegen::lua::SetHoverCircle,
|
||||
codegen::lua::MoveCircleToHoverImage,
|
||||
codegen::lua::DisableHoverCircle,
|
||||
codegen::lua::SetHoverIndicator,
|
||||
codegen::lua::MoveIndicatorToHoverImage,
|
||||
codegen::lua::DisableHoverIndicator,
|
||||
codegen::lua::LoadImagesToWWT,
|
||||
codegen::lua::SelectImage,
|
||||
codegen::lua::RemoveSelectedImageInBrowser,
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
int uniqueIdentifierCounter() const;
|
||||
|
||||
void setSelectedBrowser(std::string_view id);
|
||||
void setHoverCircle(SceneGraphNode* circle);
|
||||
void setHoverIndicator(SceneGraphNode* circle);
|
||||
|
||||
// Rotation, animation, placement
|
||||
void lookAtTarget(const std::string& id);
|
||||
@@ -76,9 +76,9 @@ public:
|
||||
void removeTargetBrowserPair(const std::string& id);
|
||||
void addTargetBrowserPair(const std::string& targetId, const std::string& browserId);
|
||||
|
||||
// Hover circle
|
||||
void moveHoverCircle(const std::string& imageUrl, bool useScript = true);
|
||||
void disableHoverCircle(bool useScript = true);
|
||||
// Hover indicator
|
||||
void moveHoverIndicator(const std::string& imageUrl, bool useScript = true);
|
||||
void disableHoverIndicator(bool useScript = true);
|
||||
|
||||
// Image collection handling
|
||||
void loadImages(const std::string& root, const std::filesystem::path& directory);
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
|
||||
// The browsers and targets
|
||||
std::vector<std::unique_ptr<TargetBrowserPair>> _targetsBrowsers;
|
||||
SceneGraphNode* _hoverCircle = nullptr;
|
||||
SceneGraphNode* _hoverIndicator = nullptr;
|
||||
/// Currently selected browser
|
||||
std::string _selectedBrowser;
|
||||
int _uniqueIdentifierCounter = 0;
|
||||
|
||||
@@ -67,10 +67,15 @@ std::string prunedIdentifier(std::string identifier) {
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* \param nodeIndex The index of the node to reload the display copy on
|
||||
* \param id An optional browser ID to only reload the display copy for a specific browser.
|
||||
* If "all" or no ID is provided, all display copies will be reloaded
|
||||
*/
|
||||
[[codegen::luawrap]] void reloadDisplayCopyOnNode(int nodeIndex, std::string id = "all") {
|
||||
if (global::windowDelegate->currentNode() != nodeIndex)
|
||||
if (global::windowDelegate->currentNode() != nodeIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
if (id != "all") {
|
||||
@@ -94,6 +99,8 @@ std::string prunedIdentifier(std::string identifier) {
|
||||
/**
|
||||
* Takes an index to an image and selects that image in the currently selected sky
|
||||
* browser.
|
||||
*
|
||||
* \param imageUrl The url of the image to select
|
||||
*/
|
||||
[[codegen::luawrap]] void selectImage(std::string imageUrl) {
|
||||
// Load image
|
||||
@@ -144,30 +151,35 @@ std::string prunedIdentifier(std::string identifier) {
|
||||
|
||||
/**
|
||||
* Takes an identifier to a screen space renderable and adds it to the module.
|
||||
*
|
||||
* \param identifier The identifier of the renderable that should be used as hover
|
||||
* indicator
|
||||
*/
|
||||
[[codegen::luawrap]] void setHoverCircle(std::string identifier) {
|
||||
SceneGraphNode* circle = global::renderEngine->scene()->sceneGraphNode(identifier);
|
||||
if (!circle) {
|
||||
[[codegen::luawrap]] void setHoverIndicator(std::string identifier) {
|
||||
SceneGraphNode* sgn = global::renderEngine->scene()->sceneGraphNode(identifier);
|
||||
if (!sgn) {
|
||||
throw ghoul::lua::LuaError(std::format(
|
||||
"Could not find node to set as hover circle: {}", identifier
|
||||
"Could not find node to set as hover indicator: {}", identifier
|
||||
));
|
||||
}
|
||||
|
||||
global::moduleEngine->module<SkyBrowserModule>()->setHoverCircle(circle);
|
||||
global::moduleEngine->module<SkyBrowserModule>()->setHoverIndicator(sgn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the hover circle to the coordinate specified by the image index.
|
||||
* Moves the hover indicator to the coordinate specified by the image index.
|
||||
*
|
||||
* \param imageUrl The url of the image to move the hover indicator to
|
||||
*/
|
||||
[[codegen::luawrap]] void moveCircleToHoverImage(std::string imageUrl) {
|
||||
global::moduleEngine->module<SkyBrowserModule>()->moveHoverCircle(imageUrl, false);
|
||||
[[codegen::luawrap]] void moveIndicatorToHoverImage(std::string imageUrl) {
|
||||
global::moduleEngine->module<SkyBrowserModule>()->moveHoverIndicator(imageUrl, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the hover circle, if there is one added to the sky browser module.
|
||||
* Disables the hover indicator, if one is added to the sky browser module.
|
||||
*/
|
||||
[[codegen::luawrap]] void disableHoverCircle() {
|
||||
global::moduleEngine->module<SkyBrowserModule>()->disableHoverCircle(false);
|
||||
[[codegen::luawrap]] void disableHoverIndicator() {
|
||||
global::moduleEngine->module<SkyBrowserModule>()->disableHoverIndicator(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
OpenSpace_record/playback02.00A
|
||||
script 0 0 1 openspace.time.setPause(false);openspace.time.setDeltaTime(1);
|
||||
script 0 0 1 openspace.setPropertyValueSingle("Scene.hoverCircle.Renderable.Fade", 0)
|
||||
script 0 0 1 openspace.setPropertyValueSingle("Scene.HoverIndicator.Renderable.Fade", 0)
|
||||
camera 0.002065126085653901 779267322.4886187 123389190187.6973 -987938150497.865 346357762351.6706 -0.36478543 0.4468942 -0.6903772 -0.4365736 2.0395897e-08 - Venus
|
||||
camera 0.004236564040184021 779267322.4907901 123389190187.6973 -987938150497.865 346357762351.6706 -0.36478543 0.4468942 -0.6903772 -0.4365736 2.0395897e-08 - Venus
|
||||
script 8.958355146809481 779267331.4449104 1 openspace.setPropertyValueSingle('Scene.hoverCircle.Renderable.Fade', 0.0);
|
||||
script 8.958355146809481 779267331.4449104 1 openspace.setPropertyValueSingle('Scene.HoverIndicator.Renderable.Fade', 0.0);
|
||||
camera 26.381116207921878 779267348.8676736 62165003943664156672 482784744565750824960 1117492338753629847552 -0.16281216 -0.117395274 -0.6741872 0.7107617 1.7638751e-17 - Venus
|
||||
|
||||
@@ -645,7 +645,7 @@ TEST_CASE("SessionRecording: 02.00 Ascii Linux", "[sessionrecording]") {
|
||||
CHECK(e.simulationTime == 0.0);
|
||||
REQUIRE(std::holds_alternative<SessionRecording::Entry::Script>(e.value));
|
||||
const auto& script = std::get<SessionRecording::Entry::Script>(e.value);
|
||||
CHECK(script == "openspace.setPropertyValueSingle(\"Scene.hoverCircle.Renderable.Fade\", 0)");
|
||||
CHECK(script == "openspace.setPropertyValueSingle(\"Scene.HoverIndicator.Renderable.Fade\", 0)");
|
||||
}
|
||||
{
|
||||
const SessionRecording::Entry& e = rec.entries[2];
|
||||
@@ -689,7 +689,7 @@ TEST_CASE("SessionRecording: 02.00 Ascii Linux", "[sessionrecording]") {
|
||||
CHECK(e.simulationTime == 779267331.4449104);
|
||||
REQUIRE(std::holds_alternative<SessionRecording::Entry::Script>(e.value));
|
||||
const auto& script = std::get<SessionRecording::Entry::Script>(e.value);
|
||||
CHECK(script == "openspace.setPropertyValueSingle('Scene.hoverCircle.Renderable.Fade', 0.0);");
|
||||
CHECK(script == "openspace.setPropertyValueSingle('Scene.HoverIndicator.Renderable.Fade', 0.0);");
|
||||
}
|
||||
{
|
||||
const SessionRecording::Entry& e = rec.entries[5];
|
||||
|
||||
Reference in New Issue
Block a user