mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-13 17:09:05 -05:00
Fix constellation bounds render issue
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,7 @@ protected:
|
||||
*/
|
||||
virtual void selectionPropertyHasChanged() = 0;
|
||||
|
||||
// Map over the constellations names and theis abbreviations
|
||||
// key = abbreviations, value = full name
|
||||
std::map<std::string, std::string> _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<std::string, std::string> _constellationNamesTranslation;
|
||||
|
||||
std::vector<std::string> _assetSelectedMeshes;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<GLsizei>(
|
||||
_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<GLsizei>(_vertexValues.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user