Some clean up

This commit is contained in:
Malin E
2022-08-25 13:48:48 +02:00
parent b8f365e6de
commit 40267804bd
5 changed files with 23 additions and 21 deletions

View File

@@ -215,7 +215,7 @@ end
asset.meta = {
Name = "Constellation Images",
Version = "1.1",
Version = "1.2",
Description = "Artistic images depicting the constellations",
Author = "James Hedberg",
URL = "http://jameshedberg.com",

View File

@@ -85,7 +85,7 @@ namespace {
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"LineWidth",
"Line Width",
"The line width of the constellation "
"The line width of the constellation"
};
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
@@ -117,7 +117,7 @@ namespace {
std::optional<bool> drawLabels;
// [[codegen::verbatim(ConstellationInfo.description)]]
std::optional<std::string> constellationNamesFile;
std::optional<std::filesystem::path> constellationNamesFile;
// [[codegen::verbatim(TextColorInfo.description)]]
std::optional<glm::vec3> textColor [[codegen::color()]];
@@ -185,7 +185,7 @@ RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictio
_renderOption.addOption(RenderOptionViewDirection, "Camera View Direction");
_renderOption.addOption(RenderOptionPositionNormal, "Camera Position Normal");
// @TODO (abock. 2021-01-31) In the other DU classes, this is done with an enum, and
// @TODO (abock. 2021-01-31) In the other classes, this is done with an enum, and
// doing it based on the fisheye rendering seems a bit brittle?
if (global::windowDelegate->isFisheyeRendering()) {
_renderOption = RenderOptionPositionNormal;
@@ -195,9 +195,11 @@ RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictio
}
addProperty(_renderOption);
// Read all files in the initialize() instead, multithreaded
_constellationNamesFilename =
p.constellationNamesFile.value_or(_constellationNamesFilename);
// Avoid reading files here, instead do it in multithreaded initialize()
if (p.constellationNamesFile.has_value()) {
_constellationNamesFilename =
absPath(p.constellationNamesFile.value().string()).string();
}
_constellationNamesFilename.onChange([&]() { loadConstellationFile(); });
addProperty(_constellationNamesFilename);
@@ -275,7 +277,6 @@ void RenderableConstellation::loadConstellationFile() {
file.open(absPath(_constellationNamesFilename));
std::string line;
int index = 0;
while (file.good()) {
std::getline(file, line);
if (line.empty()) {
@@ -290,8 +291,6 @@ void RenderableConstellation::loadConstellationFile() {
std::getline(s, fullName);
ghoul::trimWhitespace(fullName);
_constellationNamesTranslation[abbreviation] = fullName;
++index;
}
fillSelectionProperty();

View File

@@ -57,7 +57,7 @@ namespace {
struct [[codegen::Dictionary(RenderableConstellationBounds)]] Parameters {
// [[codegen::verbatim(VertexInfo.description)]]
std::string file;
std::filesystem::path file;
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color [[codegen::color()]];
@@ -79,8 +79,8 @@ RenderableConstellationBounds::RenderableConstellationBounds(
{
const Parameters p = codegen::bake<Parameters>(dictionary);
// Avoid loading the vertex file here, do it in multithreded initialize() instead
_vertexFilename = p.file;
// Avoid reading files here, instead do it in multithreaded initialize()
_vertexFilename = absPath(p.file.string()).string();
_vertexFilename.onChange([&](){ loadVertexFile(); });
addProperty(_vertexFilename);

View File

@@ -66,7 +66,7 @@ namespace {
struct [[codegen::Dictionary(RenderableConstellationLines)]] Parameters {
// The path to the SPECK file that contains constellation lines data
std::string file;
std::filesystem::path file;
enum class [[codegen::map(openspace::DistanceUnit)]] Unit {
Meter [[codegen::key("m")]],
@@ -99,7 +99,7 @@ RenderableConstellationLines::RenderableConstellationLines(
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_speckFile = absPath(p.file).string();
_speckFile = absPath(p.file.string()).string();
_hasSpeckFile = true;
_drawElements.onChange([&]() { _hasSpeckFile = !_hasSpeckFile; });
addProperty(_drawElements);
@@ -140,7 +140,10 @@ void RenderableConstellationLines::selectionPropertyHasChanged() {
}
bool RenderableConstellationLines::isReady() const {
return (_program != nullptr) && !_renderingConstellationsMap.empty() &&
if (!_hasLabel) {
return _program && !_renderingConstellationsMap.empty();
}
return _program && !_renderingConstellationsMap.empty() &&
!_labelset.entries.empty();
}
@@ -328,10 +331,9 @@ bool RenderableConstellationLines::readSpeckFile() {
std::string dummy;
str >> dummy; // mesh command
dummy.clear();
str >> dummy; // texture index command?
str >> dummy; // color index command?
do {
if (dummy == "-c") {
dummy.clear();
str >> constellationLine.colorIndex; // color index command
}
dummy.clear();
@@ -344,8 +346,9 @@ bool RenderableConstellationLines::readSpeckFile() {
std::stringstream id(line);
std::string identifier;
id >> dummy;
std::getline(id, identifier);
id >> dummy; // id command
dummy.clear();
std::getline(id, identifier); // identifier
ghoul::trimWhitespace(identifier);
std::string name = constellationFullName(identifier);
if (!name.empty()) {

View File

@@ -82,7 +82,7 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) {
);
fRenderable->registerClass<RenderableConstellationLines>(
"RenderableConstellationLines"
);
);
fRenderable->registerClass<RenderableFluxNodes>("RenderableFluxNodes");
fRenderable->registerClass<RenderableHabitableZone>("RenderableHabitableZone");
fRenderable->registerClass<RenderableRings>("RenderableRings");