Fix issue with constellation labels and selection, closes #2382

This commit is contained in:
Malin E
2023-03-14 15:46:00 +01:00
parent 5fec405b70
commit 148f010a9a
4 changed files with 24 additions and 4 deletions
+4
View File
@@ -237,6 +237,10 @@ void LabelsComponent::render(const RenderData& data,
glm::vec4 textColor = glm::vec4(glm::vec3(_color), _opacity * fadeInVariable);
for (const speck::Labelset::Entry& e : _labelset.entries) {
if (!e.isEnabled) {
continue;
}
glm::vec3 scaledPos(e.position);
scaledPos *= scale;
ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render(
@@ -139,12 +139,28 @@ void RenderableConstellationLines::selectionPropertyHasChanged() {
{
pair.second.isEnabled = true;
}
if (_hasLabels) {
for (speck::Labelset::Entry& e : _labels->labelSet().entries) {
e.isEnabled = true;
}
}
}
else {
// Enable all constellations that are selected
for (ConstellationKeyValuePair& pair : _renderingConstellationsMap)
{
pair.second.isEnabled = _selection.isSelected(pair.second.name);
bool isSelected = _selection.isSelected(pair.second.name);
pair.second.isEnabled = isSelected;
if (_hasLabels) {
for (speck::Labelset::Entry& e : _labels->labelSet().entries) {
if (constellationFullName(e.identifier) == pair.second.name) {
e.isEnabled = isSelected;
break;
}
}
}
}
}
}
@@ -86,6 +86,8 @@ protected:
// Labels
bool _hasLabels = false;
properties::BoolProperty _drawLabels;
// Everything related to the labels is handled by LabelsComponent
std::unique_ptr<LabelsComponent> _labels;
private:
// Map over the constellations names and their abbreviations
@@ -103,9 +105,6 @@ private:
// The file containing constellation names and abbreviations
properties::StringProperty _namesFilename;
// Everything related to the labels is handled by LabelsComponent
std::unique_ptr<LabelsComponent> _labels;
};
} // namespace openspace
+1
View File
@@ -70,6 +70,7 @@ struct Labelset {
glm::vec3 position = glm::vec3(0.f);
std::string identifier;
std::string text;
bool isEnabled = true;
};
std::vector<Entry> entries;
};