Fixes to remove some warnings

This commit is contained in:
Emma Broman
2022-02-10 14:28:08 +01:00
parent 893c523517
commit 72110be88c
7 changed files with 35 additions and 27 deletions

View File

@@ -1026,7 +1026,8 @@ std::vector<float> RenderableBillboardsCloud::createDataSlice() {
case DistanceUnit::Gigalightyear:
unitValue = 6;
break;
default: ghoul::MissingCaseException();
default:
throw ghoul::MissingCaseException();
}
glm::vec4 position(transformedPos, unitValue);
@@ -1057,7 +1058,7 @@ std::vector<float> RenderableBillboardsCloud::createDataSlice() {
}
if (_isColorMapExact) {
int colorIndex = variableColor + cmin;
int colorIndex = static_cast<int>(variableColor + cmin);
for (int j = 0; j < 4; ++j) {
result.push_back(_colorMap.entries[colorIndex][j]);
}
@@ -1090,11 +1091,14 @@ std::vector<float> RenderableBillboardsCloud::createDataSlice() {
}
else {
float ncmap = static_cast<float>(_colorMap.entries.size());
float normalization = ((cmax != cmin) && (ncmap > 2)) ?
(ncmap - 2) / (cmax - cmin) : 0;
int colorIndex = (variableColor - cmin) * normalization + 1;
float normalization = ((cmax != cmin) && (ncmap > 2.f)) ?
(ncmap - 2.f) / (cmax - cmin) : 0;
int colorIndex = static_cast<int>(
(variableColor - cmin) * normalization + 1.f
);
colorIndex = colorIndex < 0 ? 0 : colorIndex;
colorIndex = colorIndex >= ncmap ? ncmap - 1 : colorIndex;
colorIndex = colorIndex >= ncmap ?
static_cast<int>(ncmap - 1.f) : colorIndex;
for (int j = 0; j < 4; ++j) {
result.push_back(_colorMap.entries[colorIndex][j]);

View File

@@ -358,7 +358,7 @@ void RenderableDUMeshes::renderLabels(const RenderData& data,
const glm::vec3& orthoRight,
const glm::vec3& orthoUp)
{
float scale = toMeter(_unit);
float scale = static_cast<float>(toMeter(_unit));
ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo;
labelInfo.orthoRight = orthoRight;
@@ -581,7 +581,7 @@ void RenderableDUMeshes::createMeshes() {
LDEBUG("Creating planes");
for (std::pair<const int, RenderingMesh>& p : _renderingMeshesMap) {
float scale = toMeter(_unit);
float scale = static_cast<float>(toMeter(_unit));
for (GLfloat& v : p.second.vertices) {
v *= scale;

View File

@@ -30,11 +30,11 @@ namespace {
struct [[codegen::Dictionary(TileProviderByLevel)]] Parameters {
int layerGroupID;
struct Providers {
struct Provider {
int maxLevel [[codegen::greaterequal(0)]];
ghoul::Dictionary tileProvider;
};
std::vector<Providers> levelTileProviders;
std::vector<Provider> levelTileProviders;
};
#include "tileproviderbylevel_codegen.cpp"
} // namespace
@@ -51,13 +51,14 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
const Parameters p = codegen::bake<Parameters>(dictionary);
layergroupid::GroupID layerGroup = static_cast<layergroupid::GroupID>(p.layerGroupID);
for (Parameters::Providers p : p.levelTileProviders) {
p.tileProvider.setValue("LayerGroupID", static_cast<int>(layerGroup));
for (Parameters::Provider provider : p.levelTileProviders) {
ghoul::Dictionary& tileProviderDict = provider.tileProvider;
tileProviderDict.setValue("LayerGroupID", static_cast<int>(layerGroup));
layergroupid::TypeID typeID = layergroupid::TypeID::DefaultTileLayer;
if (p.tileProvider.hasValue<std::string>("Type")) {
std::string type = p.tileProvider.value<std::string>("Type");
if (tileProviderDict.hasValue<std::string>("Type")) {
std::string type = tileProviderDict.value<std::string>("Type");
typeID = ghoul::from_string<layergroupid::TypeID>(type);
if (typeID == layergroupid::TypeID::Unknown) {
@@ -65,23 +66,24 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
}
}
std::unique_ptr<TileProvider> tp = createFromDictionary(typeID, p.tileProvider);
std::unique_ptr<TileProvider> tp = createFromDictionary(typeID, tileProviderDict);
std::string provId = p.tileProvider.value<std::string>("Identifier");
std::string provId = tileProviderDict.value<std::string>("Identifier");
tp->setIdentifier(provId);
std::string providerName = p.tileProvider.value<std::string>("Name");
std::string providerName = tileProviderDict.value<std::string>("Name");
tp->setGuiName(providerName);
addPropertySubOwner(tp.get());
_levelTileProviders.push_back(std::move(tp));
// Ensure we can represent the max level
if (static_cast<int>(_providerIndices.size()) < p.maxLevel) {
_providerIndices.resize(p.maxLevel + 1, -1);
if (static_cast<int>(_providerIndices.size()) < provider.maxLevel) {
_providerIndices.resize(provider.maxLevel + 1, -1);
}
// map this level to the tile provider index
_providerIndices[p.maxLevel] = static_cast<int>(_levelTileProviders.size()) - 1;
_providerIndices[provider.maxLevel] =
static_cast<int>(_levelTileProviders.size()) - 1;
}
// Fill in the gaps (value -1 ) in provider indices, from back to end

View File

@@ -110,8 +110,10 @@ std::unique_ptr<RawVolume<VoxelType>> RawVolumeReader<VoxelType>::read(bool inve
const glm::uvec3& coords = volume->indexToCoords(i);
glm::uvec3 newcoords = glm::uvec3(coords.x, coords.y, dims.z - coords.z - 1);
size_t newIndex = volume->coordsToIndex(newcoords);
size_t oldIndex = volume->coordsToIndex(coords);
// @TODO (emmbr, 2022-02-10) Not sure why they are here, but commented them
// out for now as they aren't used
//size_t newIndex = volume->coordsToIndex(newcoords);
//size_t oldIndex = volume->coordsToIndex(coords);
newVolume->set(newcoords, volume->get(coords));
}

View File

@@ -142,7 +142,7 @@ namespace {
std::optional<float> opacity;
// [[codegen::verbatim(StepSizeInfo.description)]]
std::optional<double> stepSize;
std::optional<float> stepSize;
// [[codegen::verbatim(GridTypeInfo.description)]]
std::optional<std::string> gridType;