This commit is contained in:
Jonathas Costa
2018-03-16 15:17:13 -04:00
239 changed files with 2935 additions and 1734 deletions
@@ -50,7 +50,7 @@ void GPULayerManager::bind(ghoul::opengl::ProgramObject* programObject,
}
for (size_t i = 0; i < layerGroups.size(); ++i) {
const std::string& nameBase = layergroupid::LAYER_GROUP_NAMES[i];
const std::string& nameBase = layergroupid::LAYER_GROUP_IDENTIFIERS[i];
_gpuLayerGroups[i]->bind(
programObject,
*layerGroups[i],
@@ -34,6 +34,7 @@ namespace openspace::globebrowsing {
namespace {
constexpr const char* _loggerCat = "Layer";
constexpr const char* keyIdentifier = "Identifier";
constexpr const char* keyName = "Name";
constexpr const char* keyDescription = "Description";
constexpr const char* keyEnabled = "Enabled";
@@ -90,7 +91,8 @@ namespace {
Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
LayerGroup& parent)
: properties::PropertyOwner({
layerDict.value<std::string>(keyName),
layerDict.value<std::string>(keyIdentifier),
layerDict.hasKey(keyName) ? layerDict.value<std::string>(keyName) : "",
layerDict.hasKey(keyDescription) ?
layerDict.value<std::string>(keyDescription) :
""
@@ -180,7 +182,7 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
}
}
catch (...) {
_parent.deleteLayer(name());
_parent.deleteLayer(identifier());
throw;
}
});
@@ -43,7 +43,10 @@ namespace {
namespace openspace::globebrowsing {
LayerGroup::LayerGroup(layergroupid::GroupID id)
: properties::PropertyOwner({ std::move(layergroupid::LAYER_GROUP_NAMES[id]) })
: properties::PropertyOwner({
layergroupid::LAYER_GROUP_IDENTIFIERS[id],
layergroupid::LAYER_GROUP_NAMES[id]
})
, _groupId(id)
, _levelBlendingEnabled(BlendTileInfo, true)
{
@@ -104,14 +107,14 @@ void LayerGroup::update() {
}
std::shared_ptr<Layer> LayerGroup::addLayer(const ghoul::Dictionary& layerDict) {
if (!layerDict.hasKeyAndValue<std::string>("Name")) {
LERROR("'Name' must be specified for layer.");
if (!layerDict.hasKeyAndValue<std::string>("Identifier")) {
LERROR("'Identifier' must be specified for layer.");
return nullptr;
}
auto layer = std::make_shared<Layer>(_groupId, layerDict, *this);
layer->onChange(_onChangeCallback);
if (hasPropertySubOwner(layer->name())) {
LINFO("Layer with name " + layer->name() + " already exists.");
if (hasPropertySubOwner(layer->identifier())) {
LINFO("Layer with identifier " + layer->identifier() + " already exists.");
_levelBlendingEnabled.setVisibility(properties::Property::Visibility::User);
return nullptr;
}
@@ -132,7 +135,7 @@ void LayerGroup::deleteLayer(const std::string& layerName) {
it != _layers.end();
++it)
{
if (it->get()->name() == layerName) {
if (it->get()->identifier() == layerName) {
removePropertySubOwner(it->get());
(*it)->deinitialize();
_layers.erase(it);
@@ -37,7 +37,7 @@ TypeID getTypeIDFromTypeString(const std::string& typeString) {
layergroupid::GroupID getGroupIDFromName(const std::string& layerGroupName) {
for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
if (layerGroupName == layergroupid::LAYER_GROUP_NAMES[i]) {
if (layerGroupName == layergroupid::LAYER_GROUP_IDENTIFIERS[i]) {
return static_cast<layergroupid::GroupID>(i);
}
}
@@ -30,7 +30,7 @@
namespace openspace::globebrowsing::layergroupid {
static constexpr int NUM_LAYER_GROUPS = 5;
static constexpr const char* LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = {
static constexpr const char* LAYER_GROUP_IDENTIFIERS[NUM_LAYER_GROUPS] = {
"HeightLayers",
"ColorLayers",
"Overlays",
@@ -38,6 +38,14 @@ static constexpr const char* LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = {
"WaterMasks"
};
static constexpr const char* LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = {
"Height Layers",
"Color Layers",
"Overlays",
"Night Layers",
"Water Masks"
};
enum GroupID {
HeightLayers,
ColorLayers,
@@ -166,7 +166,7 @@ void LayerShaderManager::recompileShaderProgram(
for (size_t i = 0; i < textureTypes.size(); i++) {
// lastLayerIndex must be at least 0 for the shader to compile,
// the layer type is inactivated by setting use to false
std::string groupName = layergroupid::LAYER_GROUP_NAMES[i];
std::string groupName = layergroupid::LAYER_GROUP_IDENTIFIERS[i];
shaderDictionary.setValue(
"lastLayerIndex" + groupName,
glm::max(textureTypes[i].lastLayerIdx, 0)
@@ -219,7 +219,7 @@ void LayerShaderManager::recompileShaderProgram(
ghoul::Dictionary layerGroupNames;
for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
layerGroupNames.setValue(std::to_string(i), layergroupid::LAYER_GROUP_NAMES[i]);
layerGroupNames.setValue(std::to_string(i), layergroupid::LAYER_GROUP_IDENTIFIERS[i]);
}
shaderDictionary.setValue("layerGroups", layerGroupNames);