From 6efb99e5510378edfa04aebf14390f19d4b2773a Mon Sep 17 00:00:00 2001 From: Malin E Date: Fri, 5 Aug 2022 16:59:04 +0200 Subject: [PATCH] Fix constellation bounds render issue --- .../rendering/renderableconstellation.cpp | 25 +++++++++++-------- .../space/rendering/renderableconstellation.h | 8 +++--- .../renderableconstellationbounds.cpp | 13 ++++++---- .../renderableconstellationlines.cpp | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/modules/space/rendering/renderableconstellation.cpp b/modules/space/rendering/renderableconstellation.cpp index 14d6903b3a..c7093c8009 100644 --- a/modules/space/rendering/renderableconstellation.cpp +++ b/modules/space/rendering/renderableconstellation.cpp @@ -219,6 +219,20 @@ RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictio _assetSelectedMeshes = p.constellationSelection.value_or(_assetSelectedMeshes); } +std::string RenderableConstellation::constellationFullName( + const std::string& identifier) const +{ + try { + return _constellationNamesTranslation.at(identifier); + } + catch (const std::out_of_range&) { + std::string message = fmt::format( + "Identifier '{}' could not be found in list of constellations", identifier + ); + throw ghoul::RuntimeError(message, "RenderableConstellation"); + } +} + void RenderableConstellation::loadConstellationFile() { if (_constellationNamesFilename.value().empty()) { return; @@ -305,16 +319,7 @@ void RenderableConstellation::initialize() { for (speck::Labelset::Entry& entry : _labelset.entries) { if (!entry.identifier.empty()) { - try { - entry.text = _constellationNamesTranslation.at(entry.identifier); - } - catch (const std::out_of_range&) { - std::string message = fmt::format( - "Identifier '{}' could not be found in list of constellations", - entry.identifier - ); - throw ghoul::RuntimeError(message, "RenderableConstellation"); - } + entry.text = constellationFullName(entry.identifier); } } } diff --git a/modules/space/rendering/renderableconstellation.h b/modules/space/rendering/renderableconstellation.h index 06021d4f72..b8d4b1a548 100644 --- a/modules/space/rendering/renderableconstellation.h +++ b/modules/space/rendering/renderableconstellation.h @@ -74,9 +74,7 @@ protected: */ virtual void selectionPropertyHasChanged() = 0; - // Map over the constellations names and theis abbreviations - // key = abbreviations, value = full name - std::map _constellationNamesTranslation; + std::string constellationFullName(const std::string& identifier) const; // Linewidth for the constellation bounds properties::FloatProperty _lineWidth; @@ -89,6 +87,10 @@ protected: speck::Labelset _labelset; private: + // Map over the constellations names and theis abbreviations + // key = abbreviations, value = full name + std::map _constellationNamesTranslation; + std::vector _assetSelectedMeshes; /** diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index 998e82e127..f58f038579 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -139,6 +139,9 @@ void RenderableConstellationBounds::deinitializeGL() { } bool RenderableConstellationBounds::isReady() const { + if (!_hasLabel) { + return _program && _vao != 0 && _vbo != 0; + } return _program && _vao != 0 && _vbo != 0 && !_labelset.entries.empty(); } @@ -214,8 +217,8 @@ bool RenderableConstellationBounds::loadVertexFile() { float dec; s >> dec; - std::string constellationName; - s >> constellationName; + std::string abbreviation; + s >> abbreviation; if (!s.good()) { // If this evaluates to true, the stream was not completely filled, which @@ -230,7 +233,7 @@ bool RenderableConstellationBounds::loadVertexFile() { } // Did we arrive at a new constellation? - if (constellationName != currentBound.constellationAbbreviation) { + if (abbreviation != currentBound.constellationAbbreviation) { // Store how many vertices we read during the active time of the constellation currentBound.nVertices = static_cast( _vertexValues.size() - currentBound.startIndex @@ -239,8 +242,8 @@ bool RenderableConstellationBounds::loadVertexFile() { _constellationBounds.push_back(currentBound); currentBound = ConstellationBound(); currentBound.isEnabled = true; - currentBound.constellationAbbreviation = constellationName; - currentBound.constellationFullName = constellationName; + currentBound.constellationAbbreviation = abbreviation; + currentBound.constellationFullName = constellationFullName(abbreviation); currentBound.startIndex = static_cast(_vertexValues.size()); } diff --git a/modules/space/rendering/renderableconstellationlines.cpp b/modules/space/rendering/renderableconstellationlines.cpp index 06452e2621..9a3b8984bf 100644 --- a/modules/space/rendering/renderableconstellationlines.cpp +++ b/modules/space/rendering/renderableconstellationlines.cpp @@ -371,7 +371,7 @@ bool RenderableConstellationLines::readSpeckFile() { if (dummyU == "id") { ghoul::trimWhitespace(dummyV); - mesh.identifier = _constellationNamesTranslation[dummyV]; + mesh.identifier = constellationFullName(dummyV); // Dimensions are specified in the next line as usual std::getline(file, line);