diff --git a/modules/skybrowser/include/screenspaceskybrowser.h b/modules/skybrowser/include/screenspaceskybrowser.h index 55e12ffc42..6ed5455cc6 100644 --- a/modules/skybrowser/include/screenspaceskybrowser.h +++ b/modules/skybrowser/include/screenspaceskybrowser.h @@ -64,12 +64,14 @@ public: void addRenderCopy(const glm::vec3& raePosition, int nCopies); void removeRenderCopy(); std::vector> renderCopies() const; + std::vector> showRenderCopies() const; void moveRenderCopy(int i, glm::vec3 raePosition); private: properties::FloatProperty _textureQuality; properties::BoolProperty _isHidden; std::vector> _renderCopies; + std::vector> _showRenderCopies; void bindTexture() override; diff --git a/modules/skybrowser/src/screenspaceskybrowser.cpp b/modules/skybrowser/src/screenspaceskybrowser.cpp index 3f02887728..92eb1db53d 100644 --- a/modules/skybrowser/src/screenspaceskybrowser.cpp +++ b/modules/skybrowser/src/screenspaceskybrowser.cpp @@ -56,6 +56,12 @@ namespace { "or Cartesian, depending on if the browser uses RAE or Cartesian coordinates." }; + constexpr const openspace::properties::Property::PropertyInfo RenderCopyShowInfo = { + "ShowRenderCopy", + "Show Render Copy", + "Show the render copy." + }; + constexpr const openspace::properties::Property::PropertyInfo IsHiddenInfo = { "IsHidden", "Is hidden", @@ -203,8 +209,8 @@ void ScreenSpaceSkyBrowser::addRenderCopy(const glm::vec3& raePosition, int nCop openspace::properties::Property::PropertyInfo info = RenderCopyInfo; float azimuth = i * glm::two_pi() / nCopies; glm::vec3 position = raePosition + glm::vec3(0.f, azimuth, 0.f); - std::string id = "RenderCopy" + std::to_string(start + i); - info.identifier = id.c_str(); + std::string idRenderCopy = "RenderCopy" + std::to_string(start + i); + info.identifier = idRenderCopy.c_str(); _renderCopies.push_back( std::make_unique( info, @@ -213,7 +219,17 @@ void ScreenSpaceSkyBrowser::addRenderCopy(const glm::vec3& raePosition, int nCop glm::vec3(4.f, 4.f, glm::half_pi()) ) ); + openspace::properties::Property::PropertyInfo showInfo = RenderCopyShowInfo; + std::string idRenderCopyVisible = "ShowRenderCopy" + std::to_string(start + i); + showInfo.identifier = idRenderCopyVisible.c_str(); + _showRenderCopies.push_back( + std::make_unique( + showInfo, + true + ) + ); addProperty(_renderCopies.back().get()); + addProperty(_showRenderCopies.back().get()); } } @@ -228,20 +244,25 @@ std::vector> ScreenSpaceSkyBrowser::renderCopies() const { std::vector> vec; - std::for_each( - _renderCopies.begin(), - _renderCopies.end(), - [&](const std::unique_ptr& copy) { - std::pair pair = { - copy->identifier(), - glm::dvec3(copy->value()) - }; - vec.push_back(pair); - } - ); + using vec3Property = std::unique_ptr; + for (const vec3Property& copy : _renderCopies) { + vec.push_back({ copy->identifier(), copy->value() }); + } return vec; } +std::vector> +ScreenSpaceSkyBrowser::showRenderCopies() const +{ + std::vector> vec; + using boolProperty = std::unique_ptr; + for (const boolProperty& copy : _showRenderCopies) { + vec.push_back({copy->identifier(), copy->value()}); + } + return vec; +} + + void ScreenSpaceSkyBrowser::moveRenderCopy(int i, glm::vec3 raePosition) { if (i < static_cast(_renderCopies.size()) && i >= 0) { *_renderCopies[i].get() = raePosition; @@ -266,27 +287,29 @@ void ScreenSpaceSkyBrowser::render() { ); } - // Render a copy that is not interactive - for (const std::unique_ptr& copy : _renderCopies) { - glm::vec3 coordinates = copy->value(); - if (_useRadiusAzimuthElevation) { - coordinates = sphericalToCartesian(raeToSpherical(coordinates)); - } - glm::mat4 localRotation = glm::mat4(1.f); - if (_faceCamera) { - localRotation = glm::inverse(glm::lookAt( - glm::vec3(0.f), - glm::normalize(coordinates), - glm::vec3(0.f, 1.f, 0.f) - )); - } + // Render the display copies + for (size_t i = 0; i < _renderCopies.size(); i++) { + if (_showRenderCopies[i]->value()) { + glm::vec3 coordinates = _renderCopies[i]->value(); + if (_useRadiusAzimuthElevation) { + coordinates = sphericalToCartesian(raeToSpherical(coordinates)); + } + glm::mat4 localRotation = glm::mat4(1.f); + if (_faceCamera) { + localRotation = glm::inverse(glm::lookAt( + glm::vec3(0.f), + glm::normalize(coordinates), + glm::vec3(0.f, 1.f, 0.f) + )); + } - draw( - globalRotationMatrix() * - glm::translate(glm::mat4(1.f), coordinates) * - localRotation * - scaleMatrix() - ); + draw( + globalRotationMatrix() * + glm::translate(glm::mat4(1.f), coordinates) * + localRotation * + scaleMatrix() + ); + } } } diff --git a/modules/skybrowser/src/targetbrowserpair.cpp b/modules/skybrowser/src/targetbrowserpair.cpp index 41d6918a87..300e2c1778 100644 --- a/modules/skybrowser/src/targetbrowserpair.cpp +++ b/modules/skybrowser/src/targetbrowserpair.cpp @@ -211,9 +211,14 @@ ghoul::Dictionary TargetBrowserPair::dataAsDictionary() const { res.setValue("opacities", _browser->opacities()); std::vector> copies = renderCopies(); + std::vector> showCopies = _browser->showRenderCopies(); ghoul::Dictionary copiesData; for (size_t i = 0; i < copies.size(); i++) { - copiesData.setValue(copies[i].first, copies[i].second); + ghoul::Dictionary copy; + copy.setValue("position", copies[i].second); + copy.setValue("show", showCopies[i].second); + copy.setValue("idShowProperty", showCopies[i].first); + copiesData.setValue(copies[i].first, copy); } // Set table for the current target res.setValue("renderCopies", copiesData);