Added missing include and merged master into NewAtmosphere.

This commit is contained in:
Jonathas Costa
2017-11-25 22:39:18 -05:00
142 changed files with 5565 additions and 4414 deletions
@@ -66,7 +66,12 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictiona
);
_id = id();
setName("ScreenSpaceFramebuffer" + std::to_string(_id));
if (_id == 0) {
setName("ScreenSpaceFramebuffer");
}
else {
setName("ScreenSpaceFramebuffer " + std::to_string(_id));
}
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
addProperty(_size);
@@ -89,7 +89,12 @@ ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary
}
else {
static int id = 0;
setName("ScreenSpaceImageLocal " + std::to_string(id));
if (id == 0) {
setName("ScreenSpaceImageLocal");
}
else {
setName("ScreenSpaceImageLocal " + std::to_string(id));
}
++id;
}
@@ -89,7 +89,12 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona
}
else {
static int id = 0;
setName("ScreenSpaceImageOnline " + std::to_string(id));
if (id == 0) {
setName("ScreenSpaceImageOnline");
}
else {
setName("ScreenSpaceImageOnline " + std::to_string(id));
}
++id;
}
+1 -1
View File
@@ -544,7 +544,7 @@ void FixedRotation::update(const UpdateData&) {
glm::vec3 y = yAxis();
glm::vec3 z = zAxis();
static const float Epsilon = 1e-3;
static const float Epsilon = 1e-3f;
if (glm::dot(x, y) > 1.f - Epsilon ||
glm::dot(y, z) > 1.f - Epsilon ||
+3 -1
View File
@@ -110,7 +110,9 @@ void LuaRotation::update(const UpdateData& data) {
auto now = high_resolution_clock::now();
lua_pushnumber(
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
static_cast<lua_Number>(
duration_cast<milliseconds>(now.time_since_epoch()).count()
)
);
// Execute the scaling function
+1 -1
View File
@@ -64,7 +64,7 @@ documentation::Documentation StaticRotation::Documentation() {
}
StaticRotation::StaticRotation()
: _rotationMatrix(RotationInfo, glm::dmat3(1.0))
: _rotationMatrix(RotationInfo, glm::dmat3(1.0), glm::dmat3(-1.0), glm::dmat3(1.0))
{
addProperty(_rotationMatrix);
_rotationMatrix.onChange([this]() { _matrix = _rotationMatrix; });
+3 -1
View File
@@ -101,7 +101,9 @@ void LuaScale::update(const UpdateData& data) {
auto now = high_resolution_clock::now();
lua_pushnumber(
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
static_cast<lua_Number>(
duration_cast<milliseconds>(now.time_since_epoch()).count()
)
);
// Execute the scaling function
+3 -1
View File
@@ -118,7 +118,9 @@ void LuaTranslation::update(const UpdateData& data) {
auto now = high_resolution_clock::now();
lua_pushnumber(
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
static_cast<lua_Number>(
duration_cast<milliseconds>(now.time_since_epoch()).count()
)
);
// Execute the scaling function
@@ -303,8 +303,12 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
LERROR(_name << ": The field " << std::string(KeyInputFileType) << " is missing!");
return false;
} else {
std::transform(inputFileTypeString.begin(), inputFileTypeString.end(),
inputFileTypeString.begin(), ::tolower);
std::transform(
inputFileTypeString.begin(),
inputFileTypeString.end(),
inputFileTypeString.begin(),
[](char c) { return static_cast<char>(tolower(c)); }
);
// Verify that the input type is correct
if (inputFileTypeString == ValueInputFileTypeCdf) {
sourceFileType = SourceFileType::Cdf;
@@ -373,7 +373,7 @@ void FieldlinesState::saveStateToJson(const std::string& absPath) {
// Returns one of the extra quantity vectors, _extraQuantities[index].
// If index is out of scope an empty vector is returned and the referenced bool is false.
const std::vector<float>& FieldlinesState::extraQuantity(const size_t index,
std::vector<float> FieldlinesState::extraQuantity(const size_t index,
bool& isSuccessful) const {
if (index < _extraQuantities.size()) {
isSuccessful = true;
@@ -64,7 +64,7 @@ public:
const std::vector<glm::vec3>& vertexPositions() const;
// Special getter. Returns extraQuantities[INDEX].
const std::vector<float>& extraQuantity(const size_t INDEX, bool& isSuccesful) const;
std::vector<float> extraQuantity(const size_t INDEX, bool& isSuccesful) const;
void setModel(const fls::Model m) { _model = m; }
void setTriggerTime(const double t) { _triggerTime = t; }
+1 -3
View File
@@ -115,9 +115,7 @@ void GalaxyRaycaster::preRaycast(const RaycastData& data,
program.setUniform(galaxyTextureUniformName, *_textureUnit);
}
void GalaxyRaycaster::postRaycast(const RaycastData& data,
ghoul::opengl::ProgramObject& program)
{
void GalaxyRaycaster::postRaycast(const RaycastData&, ghoul::opengl::ProgramObject&) {
_textureUnit = nullptr; // release texture unit.
}
@@ -340,22 +340,22 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
float maxDim = std::max(std::max(galaxySize.x, galaxySize.y), galaxySize.z);
float lowerRampStart = maxDim * 0.02;
float lowerRampEnd = maxDim * 0.5;
float lowerRampStart = maxDim * 0.02f;
float lowerRampEnd = maxDim * 0.5f;
float upperRampStart = maxDim * 2.0;
float upperRampEnd = maxDim * 10;
float upperRampStart = maxDim * 2.f;
float upperRampEnd = maxDim * 10.f;
float opacityCoefficient = 1.0;
float opacityCoefficient = 1.f;
if (length < lowerRampStart) {
opacityCoefficient = 0; // camera really close
opacityCoefficient = 0.f; // camera really close
} else if (length < lowerRampEnd) {
opacityCoefficient = (length - lowerRampStart) / (lowerRampEnd - lowerRampStart);
} else if (length < upperRampStart) {
opacityCoefficient = 1.0; // sweet spot (max)
opacityCoefficient = 1.f; // sweet spot (max)
} else if (length < upperRampEnd) {
opacityCoefficient = 1.0 - (length - upperRampStart) /
opacityCoefficient = 1.f - (length - upperRampStart) /
(upperRampEnd - upperRampStart); //fade out
} else {
opacityCoefficient = 0;
@@ -363,7 +363,7 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
_opacityCoefficient = opacityCoefficient;
ghoul_assert(
_opacityCoefficient >= 0.0 && _opacityCoefficient <= 1.0,
_opacityCoefficient >= 0.f && _opacityCoefficient <= 1.f,
"Opacity coefficient was not between 0 and 1"
);
if (opacityCoefficient > 0) {
+4 -2
View File
@@ -301,7 +301,8 @@ void MemoryAwareTileCache::update() {
size_t MemoryAwareTileCache::getGPUAllocatedDataSize() const {
return std::accumulate(
_textureContainerMap.cbegin(),
_textureContainerMap.cend(), 0,
_textureContainerMap.cend(),
size_t(0),
[](size_t s, const std::pair<const TileTextureInitData::HashKey,
TextureContainerTileCache>& p)
{
@@ -316,7 +317,8 @@ size_t MemoryAwareTileCache::getGPUAllocatedDataSize() const {
size_t MemoryAwareTileCache::getCPUAllocatedDataSize() const {
size_t dataSize = std::accumulate(
_textureContainerMap.cbegin(),
_textureContainerMap.cend(), 0,
_textureContainerMap.cend(),
size_t(0),
[](size_t s, const std::pair<const TileTextureInitData::HashKey,
TextureContainerTileCache>& p)
{
@@ -162,8 +162,8 @@ int goToGeo(lua_State* L) {
return luaL_error(L, "Expected 2 or 3 arguments.");
}
double latitude = static_cast<double>(lua_tonumber(L, 1));
double longitude = static_cast<double>(lua_tonumber(L, 2));
double latitude = lua_tonumber(L, 1);
double longitude = lua_tonumber(L, 2);
if (nArguments == 2) {
OsEng.moduleEngine().module<GlobeBrowsingModule>()->goToGeo(latitude, longitude);
@@ -87,7 +87,7 @@ void TriangleSoup::setElements(std::vector<unsigned int> elements) {
_elementData.resize(elements.size());
_gpuDataNeedUpdate = true;
for (size_t i = 0; i < elements.size(); i++) {
_elementData[i] = static_cast<GLuint>(elements[i]);
_elementData[i] = elements[i];
}
}
@@ -128,8 +128,8 @@ bool TriangleSoup::updateDataOnGPU() {
// Positions at location 0
if (_useVertexPositions) {
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, position)));
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr);
//reinterpret_cast<const GLvoid*>(offsetof(Vertex, position)));
}
// Textures at location 1
if (_useTextureCoordinates) {
+1 -1
View File
@@ -38,7 +38,7 @@ PixelBuffer::PixelBuffer(size_t numBytes, Usage usage)
{
glGenBuffers(1, &_id);
bind();
glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, 0, static_cast<GLenum>(_usage));
glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, nullptr, static_cast<GLenum>(_usage));
unbind();
}
@@ -399,7 +399,7 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat
glm::dvec3 cornerModelSpace = ellipsoid.cartesianSurfacePosition(corner);
cornersModelSpace[i] = cornerModelSpace;
glm::dvec3 cornerCameraSpace =
glm::dvec3(dmat4(modelViewTransform) * glm::dvec4(cornerModelSpace, 1));
glm::dvec3(modelViewTransform * glm::dvec4(cornerModelSpace, 1));
cornersCameraSpace[i] = cornerCameraSpace;
programObject->setUniform(cornerNames[i], vec3(cornerCameraSpace));
+4 -4
View File
@@ -118,12 +118,12 @@ void PixelRegion::scale(double s) {
void PixelRegion::downscalePow2(int exponent, PixelCoordinate wrt) {
start += wrt;
start.x = ceil(start.x / static_cast<float>(pow(2, exponent)));// >>= exponent;
start.y = ceil(start.y / static_cast<float>(pow(2, exponent)));// >>= exponent;
start.x = static_cast<int>(ceil(start.x / static_cast<float>(pow(2, exponent))));
start.y = static_cast<int>(ceil(start.y / static_cast<float>(pow(2, exponent))));
numPixels.x =
ceil(numPixels.x / static_cast<float>(pow(2, exponent)));// >>= exponent;
static_cast<int>(ceil(numPixels.x / static_cast<float>(pow(2, exponent))));
numPixels.y =
ceil(numPixels.y / static_cast<float>(pow(2, exponent)));// >>= exponent;
static_cast<int>(ceil(numPixels.y / static_cast<float>(pow(2, exponent))));
start -= wrt;
}
@@ -126,12 +126,17 @@ void GdalRawTileDataReader::initialize() {
// Assume all raster bands have the same data type
_gdalDatasetMetaDataCached.rasterCount = _dataset->GetRasterCount();
_gdalDatasetMetaDataCached.scale = _dataset->GetRasterBand(1)->GetScale();
_gdalDatasetMetaDataCached.offset = _dataset->GetRasterBand(1)->GetOffset();
_gdalDatasetMetaDataCached.scale = static_cast<float>(
_dataset->GetRasterBand(1)->GetScale()
);
_gdalDatasetMetaDataCached.offset = static_cast<float>(
_dataset->GetRasterBand(1)->GetOffset()
);
_gdalDatasetMetaDataCached.rasterXSize = _dataset->GetRasterXSize();
_gdalDatasetMetaDataCached.rasterYSize = _dataset->GetRasterYSize();
_gdalDatasetMetaDataCached.noDataValue =
_dataset->GetRasterBand(1)->GetNoDataValue();
_gdalDatasetMetaDataCached.noDataValue = static_cast<float>(
_dataset->GetRasterBand(1)->GetNoDataValue()
);
_gdalDatasetMetaDataCached.dataType =
tiledatatype::getGdalDataType(_initData.glType());
@@ -145,7 +150,7 @@ void GdalRawTileDataReader::initialize() {
calculateTileLevelDifference(_initData.dimensions().x);
int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount();
_cached._maxLevel = -_cached._tileLevelDifference;
_cached._maxLevel = static_cast<int>(-_cached._tileLevelDifference);
if (numOverviews > 0) {
_cached._maxLevel += numOverviews - 1;
}
@@ -162,7 +167,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
);
PixelRegion::PixelCoordinate end = io.write.region.end();
size_t largestIndex =
[[maybe_unused]] size_t largestIndex =
(end.y - 1) * io.write.bytesPerLine + (end.x - 1) * _initData.bytesPerPixel();
ghoul_assert(largestIndex <= io.write.totalNumBytes, "Invalid write region");
@@ -191,7 +196,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
io.write.region.numPixels.y, // width to write y in destination
_gdalDatasetMetaDataCached.dataType, // Type
static_cast<int>(_initData.bytesPerPixel()), // Pixel spacing
static_cast<int>(-io.write.bytesPerLine) // Line spacing
-static_cast<int>(io.write.bytesPerLine) // Line spacing
);
// Convert error to RawTile::ReadError
@@ -236,7 +241,7 @@ int GdalRawTileDataReader::calculateTileLevelDifference(int minimumPixelSize) co
}
int sizeLevel0 = maxOverview->GetXSize();
double diff = log2(minimumPixelSize) - log2(sizeLevel0);
return diff;
return static_cast<int>(diff);
}
} // namespace openspace::globebrowsing
@@ -577,7 +577,7 @@ TileDepthTransform RawTileDataReader::calculateTileDepthTransform() {
TileDepthTransform transform;
transform.depthOffset = depthOffset();
transform.depthScale = depthScale() * maximumValue;
transform.depthScale = static_cast<float>(depthScale() * maximumValue);
return transform;
}
@@ -115,14 +115,16 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead(
y * _initData.bytesPerLine() +
x * _initData.bytesPerPixel();
int xInSource =
int xInSource = static_cast<int>(
io.read.region.start.x +
static_cast<float>(x) / io.write.region.numPixels.x *
io.read.region.numPixels.x;
int yInSource =
io.read.region.numPixels.x
);
int yInSource = static_cast<int>(
io.read.region.start.y +
static_cast<float>(y) / io.write.region.numPixels.y *
io.read.region.numPixels.y;
io.read.region.numPixels.y
);
glm::vec4 sourceTexel = _dataTexture->texelAsFloat(xInSource, yInSource);
@@ -141,7 +143,7 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead(
char value = static_cast<char>(
sourceTexel[rasterBand - 1] * 255
);
*reinterpret_cast<char*>(pixelWriteDestination) = value;
*pixelWriteDestination = value;
break;
}
case GL_UNSIGNED_SHORT: {
@@ -141,6 +141,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 2:
@@ -169,6 +170,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 3:
@@ -198,6 +200,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 4:
@@ -227,11 +230,12 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
default:
LERROR("Unknown number of channels for OpenGL texture: " << rasterCount);
break;
throw ghoul::MissingCaseException();
}
return format;
}
@@ -267,6 +271,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 2:
@@ -295,6 +300,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 3:
@@ -324,6 +330,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 4:
@@ -353,11 +360,12 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
default:
LERROR("Unknown number of channels for OpenGL texture: " << rasterCount);
break;
throw ghoul::MissingCaseException();
}
return format;
}
@@ -380,7 +388,7 @@ GLenum getOpenGLDataType(GDALDataType gdalType) {
return GL_DOUBLE;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
return GL_UNSIGNED_BYTE;
throw ghoul::MissingCaseException();
}
}
@@ -402,7 +410,7 @@ GDALDataType getGdalDataType(GLenum glType) {
return GDT_Float64;
default:
LERROR("OpenGL data type unknown to GDAL: " << glType);
return GDT_Unknown;
throw ghoul::MissingCaseException();
}
}
@@ -410,12 +418,16 @@ GDALDataType getGdalDataType(GLenum glType) {
size_t numberOfRasters(ghoul::opengl::Texture::Format format) {
switch (format) {
case ghoul::opengl::Texture::Format::Red: return 1;
case ghoul::opengl::Texture::Format::RG: return 2;
case ghoul::opengl::Texture::Format::RGB:;
[[fallthrough]]; case ghoul::opengl::Texture::Format::BGR: return 3;
case ghoul::opengl::Texture::Format::RGBA:;
[[fallthrough]]; case ghoul::opengl::Texture::Format::BGRA: return 4;
case ghoul::opengl::Texture::Format::Red:
return 1;
case ghoul::opengl::Texture::Format::RG:
return 2;
case ghoul::opengl::Texture::Format::RGB:
case ghoul::opengl::Texture::Format::BGR:
return 3;
case ghoul::opengl::Texture::Format::RGBA:
case ghoul::opengl::Texture::Format::BGRA:
return 4;
default: {
ghoul_assert(false, "Unknown format");
return 0;
@@ -436,7 +448,7 @@ size_t numberOfBytes(GLenum glType) {
case GL_DOUBLE: return sizeof(GLdouble);
default: {
ghoul_assert(false, "Unknown data type");
return 0;
throw ghoul::MissingCaseException();
}
}
}
@@ -455,7 +467,7 @@ size_t getMaximumValue(GLenum glType) {
return 1ULL << 31ULL;
default: {
ghoul_assert(false, "Unknown data type");
return 0ULL;
throw ghoul::MissingCaseException();
}
}
}
@@ -480,7 +492,7 @@ float interpretFloat(GLenum glType, const char* src) {
return static_cast<float>(*reinterpret_cast<const GLdouble*>(src));
default: {
ghoul_assert(false, "Unknown data type");
return 0;
throw ghoul::MissingCaseException();
}
}
}
@@ -504,7 +516,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::RG:
switch (glType) {
@@ -523,7 +535,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::RGB:
switch (glType) {
@@ -542,7 +554,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::RGBA:
switch (glType) {
@@ -561,7 +573,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::BGR:
switch (glType) {
@@ -580,7 +592,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::BGRA:
switch (glType) {
@@ -599,16 +611,16 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
default:
LERROR(
"Unknown format for OpenGL texture: " <<
static_cast<std::underlying_type_t<
ghoul::opengl::Texture::Format>
>(format)
static_cast<std::underlying_type_t<ghoul::opengl::Texture::Format>>(
format
)
);
return GLenum(0);
throw ghoul::MissingCaseException();
}
}
+4 -4
View File
@@ -46,8 +46,8 @@ TileIndex::TileIndex(const TileIndex& other)
: x(other.x), y(other.y), level(other.level)
{}
TileIndex::TileIndex(const Geodetic2& point, int level)
: level(level)
TileIndex::TileIndex(const Geodetic2& point, int level_)
: level(level_)
{
int numIndicesAtLevel = 1 << level;
double u = 0.5 + point.lon / (2 * glm::pi<double>());
@@ -55,8 +55,8 @@ TileIndex::TileIndex(const Geodetic2& point, int level)
double xIndexSpace = u * numIndicesAtLevel;
double yIndexSpace = v * numIndicesAtLevel;
x = floor(xIndexSpace);
y = floor(yIndexSpace);
x = static_cast<int>(floor(xIndexSpace));
y = static_cast<int>(floor(yIndexSpace));
}
TileIndex::TileIndex(const ghoul::Dictionary& dict) {
@@ -500,7 +500,7 @@ std::vector<Time> TimeQuantizer::quantized(const Time& start, const Time& end) c
const double delta = endSeconds - startSeconds;
ghoul_assert(int(delta) % int(_resolution) == 0, "Quantization error");
const int nSteps = delta / _resolution;
const int nSteps = static_cast<int>(delta / _resolution);
std::vector<Time> result(nSteps + 1);
for (int i = 0; i <= nSteps; ++i) {
@@ -61,7 +61,7 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
"Must define key '" + std::string(KeyMaxLevel) + "'"
);
}
maxLevel = std::round(floatMaxLevel);
maxLevel = static_cast<int>(std::round(floatMaxLevel));
ghoul::Dictionary providerDict;
if (!levelProviderDict.getValue<ghoul::Dictionary>(KeyTileProvider, providerDict))
+4 -4
View File
@@ -189,7 +189,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
OsEng.registerModuleKeyboardCallback(
[&](Key key, KeyModifier mod, KeyAction action) -> bool {
if (gui.isEnabled()) {
if (gui.isEnabled() || gui._performance.isEnabled()) {
return gui.keyCallback(key, mod, action);
}
else {
@@ -200,7 +200,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
OsEng.registerModuleCharCallback(
[&](unsigned int codepoint, KeyModifier modifier) -> bool {
if (gui.isEnabled()) {
if (gui.isEnabled() || gui._performance.isEnabled()) {
return gui.charCallback(codepoint, modifier);
}
else {
@@ -211,7 +211,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
OsEng.registerModuleMouseButtonCallback(
[&](MouseButton button, MouseAction action) -> bool {
if (gui.isEnabled()) {
if (gui.isEnabled() || gui._performance.isEnabled()) {
return gui.mouseButtonCallback(button, action);
}
else {
@@ -222,7 +222,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
OsEng.registerModuleMouseScrollWheelCallback(
[&](double, double posY) -> bool {
if (gui.isEnabled()) {
if (gui.isEnabled() || gui._performance.isEnabled()) {
return gui.mouseWheelCallback(posY);
}
else {
+6
View File
@@ -41,6 +41,8 @@
#include <openspace/util/keys.h>
#include <openspace/util/mouse.h>
struct ImGuiContext;
namespace openspace::gui {
class GUI : public GuiComponent {
@@ -85,11 +87,15 @@ public:
bool _showInternals;
properties::BoolProperty _showHelpText;
private:
void renderAndUpdatePropertyVisibility();
properties::Property::Visibility _currentVisibility;
std::vector<ImGuiContext*> _contexts;
};
void CaptionText(const char* text);
@@ -59,6 +59,7 @@ public:
void setVisibility(properties::Property::Visibility visibility);
void setHasRegularProperties(bool hasOnlyRegularProperties);
void setShowHelpTooltip(bool showHelpTooltip);
void render() override;
@@ -76,6 +77,7 @@ protected:
UseTreeLayout _useTreeLayout;
bool _currentUseTreeLayout;
IsTopLevelWindow _isTopLevel;
bool _showHelpTooltip;
};
} // namespace openspace::gui
+47 -17
View File
@@ -36,60 +36,90 @@ namespace openspace::properties {
namespace openspace {
using IsRegularProperty = ghoul::Boolean;
using ShowToolTip = ghoul::Boolean;
void executeScript(const std::string& id, const std::string& value,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderBoolProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderOptionProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderSelectionProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderStringProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderIntProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderIVec2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderIVec3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderIVec4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderFloatProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderVec2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderVec3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderVec4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDVec2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDVec3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDVec4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDMat2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDMat3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderDMat4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
void renderTriggerProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
IsRegularProperty isRegular = IsRegularProperty::Yes,
ShowToolTip showTooltip = ShowToolTip::Yes);
} // namespace openspace
+135 -88
View File
@@ -27,6 +27,7 @@
#include <modules/imgui/imguimodule.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/mission/missionmanager.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/keys.h>
@@ -245,6 +246,13 @@ void addScreenSpaceRenderableOnline(std::string texturePath) {
);
}
static const openspace::properties::Property::PropertyInfo ShowHelpInfo = {
"ShowHelpText",
"Show tooltip help",
"If this value is enabled these kinds of tooltips are shown for most properties "
"explaining what impact they have on the visuals."
};
} // namespace
namespace openspace::gui {
@@ -268,6 +276,7 @@ GUI::GUI()
GuiPropertyComponent::UseTreeLayout::No,
GuiPropertyComponent::IsTopLevelWindow::Yes)
, _showInternals(false)
, _showHelpText(ShowHelpInfo, true)
, _currentVisibility(properties::Property::Visibility::Developer)
{
addPropertySubOwner(_help);
@@ -285,6 +294,14 @@ GUI::GUI()
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
addPropertySubOwner(_iswa);
#endif // OPENSPACE_MODULE_ISWA_ENABLED
addProperty(_showHelpText);
_showHelpText.onChange([this](){
_globalProperty.setShowHelpTooltip(_showHelpText);
_property.setShowHelpTooltip(_showHelpText);
_screenSpaceProperty.setShowHelpTooltip(_showHelpText);
_virtualProperty.setShowHelpTooltip(_showHelpText);
});
}
void GUI::initialize() {
@@ -300,96 +317,105 @@ void GUI::initialize() {
strcpy(iniFileBuffer, cachedFile.c_str());
#endif
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = iniFileBuffer;
io.DeltaTime = 1.f / 60.f;
io.KeyMap[ImGuiKey_Tab] = static_cast<int>(Key::Tab);
io.KeyMap[ImGuiKey_LeftArrow] = static_cast<int>(Key::Left);
io.KeyMap[ImGuiKey_RightArrow] = static_cast<int>(Key::Right);
io.KeyMap[ImGuiKey_UpArrow] = static_cast<int>(Key::Up);
io.KeyMap[ImGuiKey_DownArrow] = static_cast<int>(Key::Down);
io.KeyMap[ImGuiKey_Home] = static_cast<int>(Key::Home);
io.KeyMap[ImGuiKey_End] = static_cast<int>(Key::End);
io.KeyMap[ImGuiKey_Delete] = static_cast<int>(Key::Delete);
io.KeyMap[ImGuiKey_Backspace] = static_cast<int>(Key::BackSpace);
io.KeyMap[ImGuiKey_Enter] = static_cast<int>(Key::Enter);
io.KeyMap[ImGuiKey_Escape] = static_cast<int>(Key::Escape);
io.KeyMap[ImGuiKey_A] = static_cast<int>(Key::A);
io.KeyMap[ImGuiKey_C] = static_cast<int>(Key::C);
io.KeyMap[ImGuiKey_V] = static_cast<int>(Key::V);
io.KeyMap[ImGuiKey_X] = static_cast<int>(Key::X);
io.KeyMap[ImGuiKey_Y] = static_cast<int>(Key::Y);
io.KeyMap[ImGuiKey_Z] = static_cast<int>(Key::Z);
int nWindows = OsEng.windowWrapper().nWindows();
_contexts.resize(nWindows);
io.RenderDrawListsFn = RenderDrawLists;
io.Fonts->AddFontFromFileTTF(
absPath(GuiFont).c_str(),
FontSize
);
for (int i = 0; i < nWindows; ++i) {
_contexts[i] = ImGui::CreateContext();
ImGui::SetCurrentContext(_contexts[i]);
//}
captionFont = io.Fonts->AddFontFromFileTTF(
absPath(GuiFont).c_str(),
FontSize * 1.5f
);
ImGuiStyle& style = ImGui::GetStyle();
style.WindowPadding = { 4.f, 4.f };
style.WindowRounding = 0.f;
style.FramePadding = { 3.f, 3.f };
style.FrameRounding = 0.f;
style.ItemSpacing = { 3.f, 2.f };
style.ItemInnerSpacing = { 3.f, 2.f };
style.TouchExtraPadding = { 1.f, 1.f };
style.IndentSpacing = 15.f;
style.ScrollbarSize = 10.f;
style.ScrollbarRounding = 0.f;
style.GrabMinSize = 10.f;
style.GrabRounding = 16.f;
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = iniFileBuffer;
io.DeltaTime = 1.f / 60.f;
io.KeyMap[ImGuiKey_Tab] = static_cast<int>(Key::Tab);
io.KeyMap[ImGuiKey_LeftArrow] = static_cast<int>(Key::Left);
io.KeyMap[ImGuiKey_RightArrow] = static_cast<int>(Key::Right);
io.KeyMap[ImGuiKey_UpArrow] = static_cast<int>(Key::Up);
io.KeyMap[ImGuiKey_DownArrow] = static_cast<int>(Key::Down);
io.KeyMap[ImGuiKey_Home] = static_cast<int>(Key::Home);
io.KeyMap[ImGuiKey_End] = static_cast<int>(Key::End);
io.KeyMap[ImGuiKey_Delete] = static_cast<int>(Key::Delete);
io.KeyMap[ImGuiKey_Backspace] = static_cast<int>(Key::BackSpace);
io.KeyMap[ImGuiKey_Enter] = static_cast<int>(Key::Enter);
io.KeyMap[ImGuiKey_Escape] = static_cast<int>(Key::Escape);
io.KeyMap[ImGuiKey_A] = static_cast<int>(Key::A);
io.KeyMap[ImGuiKey_C] = static_cast<int>(Key::C);
io.KeyMap[ImGuiKey_V] = static_cast<int>(Key::V);
io.KeyMap[ImGuiKey_X] = static_cast<int>(Key::X);
io.KeyMap[ImGuiKey_Y] = static_cast<int>(Key::Y);
io.KeyMap[ImGuiKey_Z] = static_cast<int>(Key::Z);
style.Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.13f, 0.13f, 0.96f);
style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_PopupBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
style.Colors[ImGuiCol_Border] = ImVec4(0.65f, 0.65f, 0.65f, 0.59f);
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f);
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.91f, 0.94f, 0.99f, 0.40f);
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.90f, 0.90f, 0.45f);
style.Colors[ImGuiCol_TitleBg] = ImVec4(0.71f, 0.81f, 1.00f, 0.45f);
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.71f, 0.81f, 1.00f, 0.45f);
style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.51f, 0.69f, 1.00f, 0.63f);
style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.26f, 0.27f, 0.33f, 0.80f);
style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.75f, 0.80f, 0.43f);
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.75f, 0.80f, 0.65f);
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.40f, 0.75f, 0.80f, 0.65f);
style.Colors[ImGuiCol_ComboBg] = ImVec4(0.36f, 0.46f, 0.56f, 1.00f);
style.Colors[ImGuiCol_CheckMark] = ImVec4(1.00f, 1.00f, 1.00f, 0.50f);
style.Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.50f, 0.80f, 0.76f, 1.00f);
style.Colors[ImGuiCol_Button] = ImVec4(0.36f, 0.54f, 0.68f, 0.62f);
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.36f, 0.54f, 0.68f, 1.00f);
style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.36f, 0.61f, 0.81f, 1.00f);
style.Colors[ImGuiCol_Header] = ImVec4(0.69f, 0.69f, 0.69f, 0.45f);
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.36f, 0.54f, 0.68f, 0.62f);
style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.63f, 0.87f, 0.80f);
style.Colors[ImGuiCol_Column] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.70f, 0.60f, 0.60f, 1.00f);
style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.90f, 0.70f, 0.70f, 1.00f);
style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
style.Colors[ImGuiCol_CloseButton] = ImVec4(0.75f, 0.75f, 0.75f, 1.00f);
style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.52f, 0.52f, 0.52f, 0.60f);
style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
style.Colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.44f, 0.63f, 1.00f, 0.35f);
style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
io.RenderDrawListsFn = RenderDrawLists;
io.Fonts->AddFontFromFileTTF(
absPath(GuiFont).c_str(),
FontSize
);
captionFont = io.Fonts->AddFontFromFileTTF(
absPath(GuiFont).c_str(),
FontSize * 1.5f
);
ImGuiStyle& style = ImGui::GetStyle();
style.WindowPadding = { 4.f, 4.f };
style.WindowRounding = 0.f;
style.FramePadding = { 3.f, 3.f };
style.FrameRounding = 0.f;
style.ItemSpacing = { 3.f, 2.f };
style.ItemInnerSpacing = { 3.f, 2.f };
style.TouchExtraPadding = { 1.f, 1.f };
style.IndentSpacing = 15.f;
style.ScrollbarSize = 10.f;
style.ScrollbarRounding = 0.f;
style.GrabMinSize = 10.f;
style.GrabRounding = 16.f;
style.Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.13f, 0.13f, 0.96f);
style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_PopupBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
style.Colors[ImGuiCol_Border] = ImVec4(0.65f, 0.65f, 0.65f, 0.59f);
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f);
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.91f, 0.94f, 0.99f, 0.40f);
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.90f, 0.90f, 0.45f);
style.Colors[ImGuiCol_TitleBg] = ImVec4(0.71f, 0.81f, 1.00f, 0.45f);
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.71f, 0.81f, 1.00f, 0.45f);
style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.51f, 0.69f, 1.00f, 0.63f);
style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.26f, 0.27f, 0.33f, 0.80f);
style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.75f, 0.80f, 0.43f);
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.75f, 0.80f, 0.65f);
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.40f, 0.75f, 0.80f, 0.65f);
style.Colors[ImGuiCol_ComboBg] = ImVec4(0.36f, 0.46f, 0.56f, 1.00f);
style.Colors[ImGuiCol_CheckMark] = ImVec4(1.00f, 1.00f, 1.00f, 0.50f);
style.Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.50f, 0.80f, 0.76f, 1.00f);
style.Colors[ImGuiCol_Button] = ImVec4(0.36f, 0.54f, 0.68f, 0.62f);
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.36f, 0.54f, 0.68f, 1.00f);
style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.36f, 0.61f, 0.81f, 1.00f);
style.Colors[ImGuiCol_Header] = ImVec4(0.69f, 0.69f, 0.69f, 0.45f);
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.36f, 0.54f, 0.68f, 0.62f);
style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.63f, 0.87f, 0.80f);
style.Colors[ImGuiCol_Column] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.70f, 0.60f, 0.60f, 1.00f);
style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.90f, 0.70f, 0.70f, 1.00f);
style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
style.Colors[ImGuiCol_CloseButton] = ImVec4(0.75f, 0.75f, 0.75f, 1.00f);
style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.52f, 0.52f, 0.52f, 0.60f);
style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
style.Colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.44f, 0.63f, 1.00f, 0.35f);
style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
}
_property.initialize();
_property.setHasRegularProperties(true);
_screenSpaceProperty.initialize();
@@ -415,6 +441,11 @@ void GUI::initialize() {
void GUI::deinitialize() {
ImGui::Shutdown();
int nWindows = OsEng.windowWrapper().nWindows();
for (int i = 0; i < nWindows; ++i) {
ImGui::DestroyContext(_contexts[i]);
}
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
_iswa.deinitialize();
#endif // OPENSPACE_MODULE_ISWA_ENABLED
@@ -447,8 +478,13 @@ void GUI::initializeGL() {
unsigned char* pngData;
glm::ivec2 textureSize;
ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pngData, &textureSize.x, &textureSize.y);
int nWindows = OsEng.windowWrapper().nWindows();
for (int i = 0; i < nWindows; ++i) {
//_contexts[i] = ImGui::CreateContext();
ImGui::SetCurrentContext(_contexts[i]);
ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pngData, &textureSize.x, &textureSize.y);
}
_fontTexture = std::make_unique<ghoul::opengl::Texture>(
pngData,
glm::uvec3(textureSize.x, textureSize.y, 1)
@@ -458,7 +494,12 @@ void GUI::initializeGL() {
_fontTexture->uploadTexture();
GLuint id = *_fontTexture;
uint64_t tmp = id;
ImGui::GetIO().Fonts->TexID = reinterpret_cast<void*>(tmp);
for (int i = 0; i < nWindows; ++i) {
//_contexts[i] = ImGui::CreateContext();
ImGui::SetCurrentContext(_contexts[i]);
ImGui::GetIO().Fonts->TexID = reinterpret_cast<void*>(tmp);
}
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
@@ -553,6 +594,9 @@ void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
const glm::vec2& dpiScaling, const glm::vec2& mousePos,
uint32_t mouseButtonsPressed)
{
int iWindow = OsEng.windowWrapper().currentWindowId();
ImGui::SetCurrentContext(_contexts[iWindow]);
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(windowSize.x, windowSize.y);
io.DisplayFramebufferScale = ImVec2(dpiScaling.x, dpiScaling.y);
@@ -571,7 +615,10 @@ void GUI::endFrame() {
_program->rebuildFromFile();
}
if (OsEng.renderEngine().doesPerformanceMeasurements()) {
bool perf = OsEng.renderEngine().doesPerformanceMeasurements();
_performance.setEnabled(perf);
if (_performance.isEnabled()) {
_performance.render();
}
+2 -2
View File
@@ -35,7 +35,7 @@
#include <openspace/util/timemanager.h>
namespace {
const ImVec2 size = ImVec2(350, 500);
static const ImVec2 Size = ImVec2(350, 500);
void renderMission(const openspace::Mission& mission) {
// The hashname is necessary since ImGui computes a hash based off the name of the
@@ -99,7 +99,7 @@ GuiMissionComponent::GuiMissionComponent() : GuiComponent("Mission Information")
void GuiMissionComponent::render() {
bool v = _isEnabled;
ImGui::Begin(name().c_str(), &v, size, 0.75f);
ImGui::Begin(name().c_str(), &v, Size, 0.75f);
_isEnabled = v;
ghoul_assert(
+13 -3
View File
@@ -166,6 +166,10 @@ void GuiPropertyComponent::setHasRegularProperties(bool hasOnlyRegularProperties
_hasOnlyRegularProperties = hasOnlyRegularProperties;
}
void GuiPropertyComponent::setShowHelpTooltip(bool showHelpTooltip) {
_showHelpTooltip = showHelpTooltip;
}
void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) {
if (owner->propertiesRecursive().empty()) {
return;
@@ -263,6 +267,7 @@ void GuiPropertyComponent::render() {
dynamic_cast<SceneGraphNode*>(owner),
"When using the tree layout, all owners must be SceneGraphNodes"
);
(void)owner; // using [[maybe_unused]] in the for loop gives an error
}
// Sort:
@@ -373,7 +378,7 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop,
properties::PropertyOwner* owner)
{
using Func = std::function<
void(properties::Property*, const std::string&, IsRegularProperty)
void(properties::Property*, const std::string&, IsRegularProperty, ShowToolTip)
>;
static const std::map<std::string, Func> FunctionMapping = {
{ "BoolProperty", &renderBoolProperty },
@@ -389,6 +394,9 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop,
{ "DVec2Property", &renderDVec2Property },
{ "DVec3Property", &renderDVec3Property },
{ "DVec4Property", &renderDVec4Property },
{ "DMat2Property", &renderDMat2Property },
{ "DMat3Property", &renderDMat3Property },
{ "DMat4Property", &renderDMat4Property },
{ "StringProperty", &renderStringProperty },
{ "OptionProperty", &renderOptionProperty },
{ "TriggerProperty", &renderTriggerProperty },
@@ -406,14 +414,16 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop,
it->second(
prop,
owner->name(),
IsRegularProperty(_hasOnlyRegularProperties)
IsRegularProperty(_hasOnlyRegularProperties),
ShowToolTip(_showHelpTooltip)
);
}
else {
it->second(
prop,
"",
IsRegularProperty(_hasOnlyRegularProperties)
IsRegularProperty(_hasOnlyRegularProperties),
ShowToolTip(_showHelpTooltip)
);
}
}
+2 -2
View File
@@ -37,7 +37,7 @@
#include <openspace/scene/scene.h>
namespace {
const ImVec2 size = ImVec2(350, 500);
static const ImVec2 Size = ImVec2(350, 500);
} // namespace
namespace openspace::gui {
@@ -45,7 +45,7 @@ namespace openspace::gui {
GuiSpaceTimeComponent::GuiSpaceTimeComponent() : GuiComponent("Space/Time") {}
void GuiSpaceTimeComponent::render() {
ImGui::Begin(name().c_str(), nullptr, size, 0.5f, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Begin(name().c_str(), nullptr, Size, 0.5f, ImGuiWindowFlags_AlwaysAutoResize);
std::vector<SceneGraphNode*> nodes =
OsEng.renderEngine().scene()->allSceneGraphNodes();
+236 -101
View File
@@ -28,6 +28,7 @@
#include <openspace/engine/openspaceengine.h>
#include <openspace/properties/scalarproperty.h>
#include <openspace/properties/matrixproperty.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/selectionproperty.h>
#include <openspace/properties/stringproperty.h>
@@ -35,6 +36,7 @@
#include <openspace/scripting/scriptengine.h>
#include <ghoul/filesystem/filesystem.h>
#include <glm/ext.hpp>
namespace openspace {
@@ -85,7 +87,7 @@ void executeScript(const std::string& id, const std::string& value,
}
void renderBoolProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
BoolProperty* p = static_cast<BoolProperty*>(prop);
@@ -94,7 +96,9 @@ void renderBoolProperty(Property* prop, const std::string& ownerName,
BoolProperty::ValueType value = *p;
ImGui::Checkbox(name.c_str(), &value);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), value ? "true" : "false", isRegular);
@@ -103,7 +107,7 @@ void renderBoolProperty(Property* prop, const std::string& ownerName,
}
void renderOptionProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
OptionProperty* p = static_cast<OptionProperty*>(prop);
@@ -120,7 +124,9 @@ void renderOptionProperty(Property* prop, const std::string& ownerName,
ImGui::Separator();
for (const OptionProperty::Option& o : options) {
ImGui::RadioButton(o.description.c_str(), &value, o.value);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
}
ImGui::Separator();
break;
@@ -134,13 +140,13 @@ void renderOptionProperty(Property* prop, const std::string& ownerName,
}
nodeNames += '\0';
int idx = std::distance(
int idx = static_cast<int>(std::distance(
options.begin(),
std::find_if(
options.begin(),
options.end(),
[value](const OptionProperty::Option& o) { return o.value == value; }
));
)));
int oldIdx = idx;
ImGui::Combo(name.c_str(), &idx, nodeNames.c_str());
@@ -159,7 +165,7 @@ void renderOptionProperty(Property* prop, const std::string& ownerName,
}
void renderSelectionProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
SelectionProperty* p = static_cast<SelectionProperty*>(prop);
@@ -179,7 +185,9 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName,
) != selectedIndices.end();
ImGui::Checkbox(description.c_str(), &selected);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (selected) {
newSelectedIndices.push_back(i);
@@ -200,14 +208,14 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName,
}
void renderStringProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
StringProperty* p = static_cast<StringProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
std::string value = FileSys.convertPathSeparator(p->value(), '/');
const std::string value = p->value();
static const int bufferSize = 256;
static char buffer[bufferSize];
@@ -222,13 +230,14 @@ void renderStringProperty(Property* prop, const std::string& ownerName,
bufferSize,
ImGuiInputTextFlags_EnterReturnsTrue
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (hasNewValue) {
executeScript(
p->fullyQualifiedIdentifier(),
"'" + std::string(buffer) + "'",
"[[" + std::string(buffer) + "]]",
isRegular
);
}
@@ -237,7 +246,7 @@ void renderStringProperty(Property* prop, const std::string& ownerName,
}
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DoubleProperty* p = static_cast<DoubleProperty*>(prop);
@@ -249,7 +258,9 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa
float max = static_cast<float>(p->maxValue());
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f");
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != static_cast<float>(p->value())) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
@@ -259,7 +270,7 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa
}
void renderIntProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
IntProperty* p = static_cast<IntProperty*>(prop);
@@ -271,7 +282,9 @@ void renderIntProperty(Property* prop, const std::string& ownerName,
int max = p->maxValue();
ImGui::SliderInt(name.c_str(), &value, min, max);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
@@ -281,7 +294,7 @@ void renderIntProperty(Property* prop, const std::string& ownerName,
}
void renderIVec2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
IVec2Property* p = static_cast<IVec2Property*>(prop);
@@ -289,20 +302,22 @@ void renderIVec2Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
IVec2Property::ValueType value = *p;
int min = std::min(p->minValue().x, p->minValue().y);
int max = std::max(p->maxValue().x, p->maxValue().y);
int min = glm::compMin(p->minValue());
int max = glm::compMax(p->maxValue());
ImGui::SliderInt2(
name.c_str(),
&value.x,
min,
max
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}",
std::to_string(value),
isRegular
);
}
@@ -311,7 +326,7 @@ void renderIVec2Property(Property* prop, const std::string& ownerName,
}
void renderIVec3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
IVec3Property* p = static_cast<IVec3Property*>(prop);
@@ -319,8 +334,8 @@ void renderIVec3Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
IVec3Property::ValueType value = *p;
int min = std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z);
int max = std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z);
int min = glm::compMin(p->minValue());
int max = glm::compMax(p->maxValue());
ImGui::SliderInt3(
name.c_str(),
@@ -328,13 +343,14 @@ void renderIVec3Property(Property* prop, const std::string& ownerName,
min,
max
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "," +
std::to_string(value.z) + "}",
std::to_string(value),
isRegular
);
}
@@ -342,7 +358,7 @@ void renderIVec3Property(Property* prop, const std::string& ownerName,
}
void renderIVec4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
IVec4Property* p = static_cast<IVec4Property*>(prop);
@@ -350,12 +366,8 @@ void renderIVec4Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
IVec4Property::ValueType value = *p;
int min = std::min(std::min(std::min(
p->minValue().x, p->minValue().y), p->minValue().z), p->minValue().w
);
int max = std::max(std::max(std::max(
p->maxValue().x, p->maxValue().y), p->maxValue().z), p->maxValue().w
);
int min = glm::compMin(p->minValue());
int max = glm::compMax(p->maxValue());
ImGui::SliderInt4(
name.c_str(),
@@ -363,15 +375,14 @@ void renderIVec4Property(Property* prop, const std::string& ownerName,
min,
max
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}",
std::to_string(value),
isRegular
);
}
@@ -379,7 +390,7 @@ void renderIVec4Property(Property* prop, const std::string& ownerName,
}
void renderFloatProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
FloatProperty* p = static_cast<FloatProperty*>(prop);
@@ -390,7 +401,9 @@ void renderFloatProperty(Property* prop, const std::string& ownerName,
float min = p->minValue();
float max = p->maxValue();
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f");
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
@@ -400,7 +413,7 @@ void renderFloatProperty(Property* prop, const std::string& ownerName,
}
void renderVec2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
Vec2Property* p = static_cast<Vec2Property*>(prop);
@@ -408,8 +421,9 @@ void renderVec2Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
Vec2Property::ValueType value = *p;
float min = std::min(p->minValue().x, p->minValue().y);
float max = std::max(p->maxValue().x, p->maxValue().y);
float min = static_cast<float>(glm::compMin(p->minValue()));
float max = static_cast<float>(glm::compMax(p->maxValue()));
ImGui::SliderFloat2(
name.c_str(),
&value.x,
@@ -417,12 +431,14 @@ void renderVec2Property(Property* prop, const std::string& ownerName,
max,
"%.5f"
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}",
std::to_string(value),
isRegular
);
}
@@ -431,7 +447,7 @@ void renderVec2Property(Property* prop, const std::string& ownerName,
}
void renderVec3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
Vec3Property* p = static_cast<Vec3Property*>(prop);
@@ -439,10 +455,8 @@ void renderVec3Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
Vec3Property::ValueType value = *p;
float min = std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z);
float max = std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z);
float min = static_cast<float>(glm::compMin(p->minValue()));
float max = static_cast<float>(glm::compMax(p->maxValue()));
if (prop->viewOption(Property::ViewOptions::Color)) {
ImGui::ColorEdit3(
@@ -459,14 +473,14 @@ void renderVec3Property(Property* prop, const std::string& ownerName,
"%.5f"
);
}
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "}",
std::to_string(value),
isRegular
);
}
@@ -475,7 +489,7 @@ void renderVec3Property(Property* prop, const std::string& ownerName,
}
void renderVec4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
Vec4Property* p = static_cast<Vec4Property*>(prop);
@@ -483,10 +497,8 @@ void renderVec4Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
Vec4Property::ValueType value = *p;
float min = std::min(std::min(std::min(
p->minValue().x, p->minValue().y), p->minValue().z), p->minValue().w);
float max = std::max(std::max(std::max(
p->maxValue().x, p->maxValue().y), p->maxValue().z), p->maxValue().w);
float min = static_cast<float>(glm::compMin(p->minValue()));
float max = static_cast<float>(glm::compMax(p->maxValue()));
if (prop->viewOption(Property::ViewOptions::Color)) {
ImGui::ColorEdit4(
@@ -503,16 +515,14 @@ void renderVec4Property(Property* prop, const std::string& ownerName,
"%.5f"
);
}
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}",
std::to_string(value),
isRegular
);
}
@@ -521,7 +531,7 @@ void renderVec4Property(Property* prop, const std::string& ownerName,
}
void renderDVec2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DVec2Property* p = static_cast<DVec2Property*>(prop);
@@ -529,8 +539,8 @@ void renderDVec2Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
glm::vec2 value = glm::dvec2(*p);
float min = static_cast<float>(std::min(p->minValue().x, p->minValue().y));
float max = static_cast<float>(std::max(p->maxValue().x, p->maxValue().y));
float min = static_cast<float>(glm::compMin(p->minValue()));
float max = static_cast<float>(glm::compMax(p->maxValue()));
ImGui::SliderFloat2(
name.c_str(),
&value.x,
@@ -538,12 +548,14 @@ void renderDVec2Property(Property* prop, const std::string& ownerName,
max,
"%.5f"
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (glm::dvec2(value) != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}",
std::to_string(value),
isRegular
);
}
@@ -552,7 +564,7 @@ void renderDVec2Property(Property* prop, const std::string& ownerName,
}
void renderDVec3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DVec3Property* p = static_cast<DVec3Property*>(prop);
@@ -560,12 +572,8 @@ void renderDVec3Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
glm::vec3 value = glm::dvec3(*p);
float min = static_cast<float>(
std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z)
);
float max = static_cast<float>(
std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z)
);
float min = static_cast<float>(glm::compMin(p->minValue()));
float max = static_cast<float>(glm::compMax(p->maxValue()));
bool changed = ImGui::SliderFloat3(
name.c_str(),
@@ -574,14 +582,14 @@ void renderDVec3Property(Property* prop, const std::string& ownerName,
max,
"%.5f"
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (changed) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "}",
std::to_string(value),
isRegular
);
}
@@ -590,7 +598,7 @@ void renderDVec3Property(Property* prop, const std::string& ownerName,
}
void renderDVec4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DVec4Property* p = static_cast<DVec4Property*>(prop);
@@ -598,16 +606,8 @@ void renderDVec4Property(Property* prop, const std::string& ownerName,
ImGui::PushID((ownerName + "." + name).c_str());
glm::vec4 value = glm::dvec4(*p);
float min = static_cast<float>(
std::min(std::min(std::min(
p->minValue().x, p->minValue().y), p->minValue().z), p->minValue().w
)
);
float max = static_cast<float>(
std::max(std::max(std::max(
p->maxValue().x, p->maxValue().y), p->maxValue().z), p->maxValue().w
)
);
float min = static_cast<float>(glm::compMin(p->minValue()));
float max = static_cast<float>(glm::compMax(p->maxValue()));
ImGui::SliderFloat4(
name.c_str(),
@@ -616,15 +616,148 @@ void renderDVec4Property(Property* prop, const std::string& ownerName,
max,
"%.5f"
);
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
if (glm::dvec4(value) != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}",
std::to_string(value),
isRegular
);
}
ImGui::PopID();
}
void renderDMat2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DMat2Property* p = static_cast<DMat2Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
ImGui::Text("%s", name.c_str());
glm::mat2 value = glm::dmat2(*p);
glm::dvec2 minValues = {
glm::compMin(p->minValue()[0]),
glm::compMin(p->minValue()[1])
};
float min = static_cast<float>(glm::compMin(minValues));
glm::dvec2 maxValues = {
glm::compMax(p->maxValue()[0]),
glm::compMax(p->maxValue()[1])
};
float max = static_cast<float>(glm::compMax(maxValues));
ImGui::SliderFloat2("[0]", glm::value_ptr(value[0]), min, max);
ImGui::SliderFloat2("[1]", glm::value_ptr(value[1]), min, max);
if (showTooltip) {
renderTooltip(prop);
}
if (glm::dmat2(value) != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
std::to_string(value),
isRegular
);
}
ImGui::PopID();
}
void renderDMat3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DMat3Property* p = static_cast<DMat3Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
ImGui::Text("%s", name.c_str());
glm::mat3 value = glm::dmat3(*p);
glm::dvec3 minValues = {
glm::compMin(p->minValue()[0]),
glm::compMin(p->minValue()[1]),
glm::compMin(p->minValue()[2])
};
float min = static_cast<float>(glm::compMin(minValues));
glm::dvec3 maxValues = {
glm::compMax(p->maxValue()[0]),
glm::compMax(p->maxValue()[1]),
glm::compMax(p->maxValue()[2])
};
float max = static_cast<float>(glm::compMax(maxValues));
ImGui::SliderFloat3("[0]", glm::value_ptr(value[0]), min, max);
ImGui::SliderFloat3("[1]", glm::value_ptr(value[1]), min, max);
ImGui::SliderFloat3("[2]", glm::value_ptr(value[2]), min, max);
if (showTooltip) {
renderTooltip(prop);
}
if (glm::dmat3(value) != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
std::to_string(value),
isRegular
);
}
ImGui::PopID();
}
void renderDMat4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
DMat4Property* p = static_cast<DMat4Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
ImGui::Text("%s", name.c_str());
glm::mat4 value = glm::dmat4(*p);
glm::dvec4 minValues = {
glm::compMin(p->minValue()[0]),
glm::compMin(p->minValue()[1]),
glm::compMin(p->minValue()[2]),
glm::compMin(p->minValue()[3])
};
float min = static_cast<float>(glm::compMin(minValues));
glm::dvec4 maxValues = {
glm::compMax(p->maxValue()[0]),
glm::compMax(p->maxValue()[1]),
glm::compMax(p->maxValue()[2]),
glm::compMax(p->maxValue()[3])
};
float max = static_cast<float>(glm::compMax(maxValues));
ImGui::SliderFloat4("[0]", glm::value_ptr(value[0]), min, max);
ImGui::SliderFloat4("[1]", glm::value_ptr(value[1]), min, max);
ImGui::SliderFloat4("[2]", glm::value_ptr(value[2]), min, max);
ImGui::SliderFloat4("[3]", glm::value_ptr(value[3]), min, max);
if (showTooltip) {
renderTooltip(prop);
}
if (glm::dmat4(value) != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
std::to_string(value),
isRegular
);
}
@@ -633,7 +766,7 @@ void renderDVec4Property(Property* prop, const std::string& ownerName,
}
void renderTriggerProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
IsRegularProperty isRegular, ShowToolTip showTooltip)
{
ghoul_assert(prop, "prop must not be nullptr");
std::string name = prop->guiName();
@@ -643,7 +776,9 @@ void renderTriggerProperty(Property* prop, const std::string& ownerName,
if (pressed) {
executeScript(prop->fullyQualifiedIdentifier(), "nil", isRegular);
}
renderTooltip(prop);
if (showTooltip) {
renderTooltip(prop);
}
ImGui::PopID();
}
+8 -8
View File
@@ -148,9 +148,7 @@ void DataProcessor::initializeVectors(int numOptions){
}
void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions) {
int numSelected = selectedOptions.size();
std::shared_ptr<Histogram> histogram;
float mean, standardDeviation, filterMid, filterWidth;
int numSelected = static_cast<int>(selectedOptions.size());
_filterValues = glm::vec2(0.0);
if (numSelected <= 0) {
@@ -159,10 +157,12 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions) {
if (!_histograms.empty()) {
for (int option : selectedOptions) {
float filterMid;
float filterWidth;
if (!_useHistogram) {
mean = (1.0/_numValues[option])*_sum[option];
standardDeviation = _standardDeviation[option];
histogram = _histograms[option];
float mean = (1.f / _numValues[option]) * _sum[option];
float standardDeviation = _standardDeviation[option];
std::shared_ptr<Histogram> histogram = _histograms[option];
filterMid = histogram->highestBinValue(_useHistogram);
filterWidth = mean+histogram->binWidth();
@@ -196,13 +196,13 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions) {
void DataProcessor::add(std::vector<std::vector<float>>& optionValues,
std::vector<float>& sum)
{
int numOptions = optionValues.size();
int numOptions = static_cast<int>(optionValues.size());
int numValues;
float mean, value, variance, standardDeviation;
for (int i=0; i<numOptions; i++) {
std::vector<float> values = optionValues[i];
numValues = values.size();
numValues = static_cast<int>(values.size());
variance = 0;
mean = (1.0f/numValues)*sum[i];
+10 -9
View File
@@ -68,7 +68,7 @@ std::vector<std::string> DataProcessorJson::readMetadata(std::string data,
void DataProcessorJson::addDataValues(std::string data,
properties::SelectionProperty& dataOptions)
{
int numOptions = dataOptions.options().size();
int numOptions = static_cast<int>(dataOptions.options().size());
initializeVectors(numOptions);
if (!data.empty()) {
@@ -87,7 +87,7 @@ void DataProcessorJson::addDataValues(std::string data,
for(int y=0; y<row.size(); y++){
json col = row.at(y);
int colsize = col.size();
int colsize = static_cast<int>(col.size());
for(int x=0; x<colsize; x++){
value = col.at(x);
@@ -105,32 +105,33 @@ void DataProcessorJson::addDataValues(std::string data,
}
std::vector<float*> DataProcessorJson::processData(std::string data,
properties::SelectionProperty& dataOptions,
properties::SelectionProperty& optionProp,
glm::size3_t& dimensions)
{
if (!data.empty()) {
json j = json::parse(data);
json variables = j["variables"];
std::vector<int> selectedOptions = dataOptions.value();
std::vector<int> selectedOptions = optionProp.value();
// int numSelected = selectedOptions.size();
auto options = dataOptions.options();
int numOptions = options.size();
const std::vector<properties::SelectionProperty::Option>& options =
optionProp.options();
int numOptions = static_cast<int>(options.size());
float value;
int rowsize, colsize, i;
std::vector<float*> dataOptions(numOptions, nullptr);
for(int option : selectedOptions){
dataOptions[option] = new float[dimensions.x*dimensions.y]{0.f};
dataOptions[option] = new float[dimensions.x*dimensions.y]{ 0.f };
json row = variables[options[option].description];
rowsize = row.size();
rowsize = static_cast<int>(row.size());
for(int y=0; y<rowsize; y++){
json col = row.at(y);
colsize = col.size();
colsize = static_cast<int>(col.size());
for(int x=0; x<colsize; x++){
value = col.at(x);
+11 -10
View File
@@ -25,6 +25,7 @@
#include <modules/iswa/util/dataprocessorkameleon.h>
//#include <algorithm>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/glm.h>
namespace {
const char* _loggerCat = "DataProcessorKameleon";
@@ -43,7 +44,7 @@ DataProcessorKameleon::DataProcessorKameleon()
DataProcessorKameleon::~DataProcessorKameleon(){}
std::vector<std::string> DataProcessorKameleon::readMetadata(std::string path,
glm::size3_t& dimensions)
glm::size3_t&)
{
if (!path.empty()) {
if (path != _kwPath || !_kw) {
@@ -71,7 +72,7 @@ std::vector<std::string> DataProcessorKameleon::readMetadata(std::string path,
void DataProcessorKameleon::addDataValues(std::string path,
properties::SelectionProperty& dataOptions)
{
int numOptions = dataOptions.options().size();
int numOptions = static_cast<int>(dataOptions.options().size());
initializeVectors(numOptions);
if (!path.empty()) {
@@ -83,7 +84,7 @@ void DataProcessorKameleon::addDataValues(std::string path,
std::vector<std::vector<float>> optionValues(numOptions, std::vector<float>());
auto options = dataOptions.options();
int numValues = _dimensions.x*_dimensions.y*_dimensions.z;
int numValues = static_cast<int>(_dimensions.x * _dimensions.y * _dimensions.z);
float* values;
float value;
@@ -120,23 +121,23 @@ std::vector<float*> DataProcessorKameleon::processData(std::string path,
}
std::vector<float*> DataProcessorKameleon::processData(std::string path,
properties::SelectionProperty& dataOptions,
properties::SelectionProperty& optionProp,
glm::size3_t& dimensions)
{
int numOptions = dataOptions.options().size();
int numOptions = static_cast<int>(optionProp.options().size());
if (!path.empty()) {
if (path != _kwPath || !_kw) {
initializeKameleonWrapper(path);
}
std::vector<int> selectedOptions = dataOptions.value();
std::vector<int> selectedOptions = optionProp.value();
// int numSelected = selectedOptions.size();
auto options = dataOptions.options();
int numOptions = options.size();
const std::vector<properties::SelectionProperty::Option>& options =
optionProp.options();
int numValues = dimensions.x*dimensions.y*dimensions.z;
int numValues = static_cast<int>(glm::compMul(dimensions));
float value;
@@ -148,7 +149,7 @@ std::vector<float*> DataProcessorKameleon::processData(std::string path,
_slice
);
for (int i=0; i<numValues; i++) {
for (int i = 0; i < numValues; i++) {
value = dataOptions[option][i];
dataOptions[option][i] = processDataPoint(value, option);
}
+9 -10
View File
@@ -91,7 +91,7 @@ std::vector<std::string> DataProcessorText::readMetadata(std::string data,
void DataProcessorText::addDataValues(std::string data,
properties::SelectionProperty& dataOptions)
{
int numOptions = dataOptions.options().size();
int numOptions = static_cast<int>(dataOptions.options().size());
initializeVectors(numOptions);
if (!data.empty()) {
@@ -147,16 +147,16 @@ void DataProcessorText::addDataValues(std::string data,
}
std::vector<float*> DataProcessorText::processData(std::string data,
properties::SelectionProperty& dataOptions,
properties::SelectionProperty& options,
glm::size3_t& dimensions)
{
if (!data.empty()) {
std::string line;
std::stringstream memorystream(data);
std::vector<int> selectedOptions = dataOptions.value();
std::vector<int> selectedOptions = options.value();
// int numSelected = selectedOptions.size();
int numOptions = dataOptions.options().size();
int numOptions = static_cast<int>(options.options().size());
std::vector<float> values;
float value;
@@ -164,8 +164,8 @@ std::vector<float*> DataProcessorText::processData(std::string data,
int first, last, option, lineSize;
std::vector<float*> dataOptions(numOptions, nullptr);
for (int option : selectedOptions) {
dataOptions[option] = new float[dimensions.x*dimensions.y]{0.0f};
for (int o : selectedOptions) {
dataOptions[o] = new float[dimensions.x * dimensions.y] { 0.f };
}
int numValues = 0;
@@ -203,12 +203,11 @@ std::vector<float*> DataProcessorText::processData(std::string data,
// first = 0;
last = 0;
option = -3;
lineSize = line.size();
lineSize = static_cast<int>(line.size());
while (last < lineSize) {
first = line.find_first_not_of(" \t", last);
last = line.find_first_of(" \t", first);
first = static_cast<int>(line.find_first_not_of(" \t", last));
last = static_cast<int>(line.find_first_of(" \t", first));
last = (last > 0)? last : lineSize;
auto it = std::find(
+16 -18
View File
@@ -184,12 +184,12 @@ bool KameleonWrapper::open(const std::string& filename) {
}
void KameleonWrapper::close() {
if (_kameleon)
if (_kameleon) {
_kameleon->close();
if (_interpolator)
delete _interpolator;
if (_kameleon)
delete _kameleon;
}
delete _interpolator;
delete _kameleon;
_kameleon = nullptr;
_interpolator = nullptr;
@@ -202,8 +202,7 @@ float* KameleonWrapper::getUniformSampledValues(
const std::string& var,
const glm::size3_t& outDimensions)
{
assert(_model && _interpolator);
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
ghoul_assert(_model && _interpolator, "Model and interpolator must exist");
LINFO("Loading variable " << var << " from CDF data with a uniform sampling");
unsigned int size = static_cast<unsigned int>(
@@ -384,8 +383,7 @@ float* KameleonWrapper::getUniformSliceValues(const std::string& var,
const glm::size3_t& outDimensions,
const float& slice)
{
assert(_model && _interpolator);
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
ghoul_assert(_model && _interpolator, "Model and interpolator must exist");
LINFO("Loading variable " << var << " from CDF data with a uniform sampling");
unsigned int size = static_cast<unsigned int>(
@@ -414,8 +412,8 @@ float* KameleonWrapper::getUniformSliceValues(const std::string& var,
LDEBUG(var << "Min: " << varMin);
LDEBUG(var << "Max: " << varMax);
double maxValue = 0.0;
double minValue = std::numeric_limits<double>::max();
//double maxValue = 0.0;
//double minValue = std::numeric_limits<double>::max();
float missingValue = _model->getMissingValue();
@@ -517,8 +515,7 @@ float* KameleonWrapper::getUniformSampledVectorValues(const std::string& xVar,
const std::string& zVar,
const glm::size3_t& outDimensions)
{
assert(_model && _interpolator);
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
ghoul_assert(_model && _interpolator, "Model and interpolator must exist");
LINFO(
"Loading variables " << xVar << " " << yVar << " " << zVar <<
" from CDF data with a uniform sampling"
@@ -597,7 +594,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getClassifiedFieldLines(
const std::vector<glm::vec3>& seedPoints,
float stepSize )
{
assert(_model && _interpolator);
ghoul_assert(_model && _interpolator, "Model and interpolator must exist");
LINFO(
"Creating " << seedPoints.size() << " fieldlines from variables " <<
xVar << " " << yVar << " " << zVar
@@ -654,7 +651,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(const std::string& xV
const std::string& yVar, const std::string& zVar,
const std::vector<glm::vec3>& seedPoints, float stepSize, const glm::vec4& color)
{
assert(_model && _interpolator);
ghoul_assert(_model && _interpolator, "Model and interpolator must exist");
LINFO(
"Creating " << seedPoints.size() << " fieldlines from variables " <<
xVar << " " << yVar << " " << zVar
@@ -744,7 +741,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories(
glm::vec3 KameleonWrapper::getModelBarycenterOffset() {
// ENLIL is centered, no need for offset
if (_type == Model::ENLIL) {
return glm::vec3(0,0,0);
return glm::vec3(0.f);
}
glm::vec3 offset;
@@ -770,8 +767,9 @@ glm::vec4 KameleonWrapper::getModelBarycenterOffsetScaled() {
}
glm::vec3 KameleonWrapper::getModelScale() {
if (_type == Model::ENLIL)
return glm::vec3(1.0f, 1.0f, 1.0f);
if (_type == Model::ENLIL) {
return glm::vec3(1.f);
}
glm::vec3 scale;
scale.x = _xMax - _xMin;
@@ -394,8 +394,8 @@ void RenderableKameleonVolume::loadCdf(const std::string& path) {
KameleonVolumeReader reader(path);
if (_autoValueBounds) {
_lowerValueBound = reader.minValue(_variable);
_upperValueBound = reader.maxValue(_variable);
_lowerValueBound = static_cast<float>(reader.minValue(_variable));
_upperValueBound = static_cast<float>(reader.maxValue(_variable));
}
std::vector<std::string> variables = reader.gridVariableNames();
@@ -130,8 +130,14 @@ void KameleonVolumeToRawTask::perform(const Task::ProgressCallback& progressCall
outputMetadata.setValue<glm::vec3>(KeyDimensions, _dimensions);
outputMetadata.setValue<glm::vec3>(KeyLowerDomainBound, _lowerDomainBound);
outputMetadata.setValue<glm::vec3>(KeyUpperDomainBound, _upperDomainBound);
outputMetadata.setValue<float>(KeyMinValue, reader.minValue(_variable));
outputMetadata.setValue<float>(KeyMaxValue, reader.maxValue(_variable));
outputMetadata.setValue<float>(
KeyMinValue,
static_cast<float>(reader.minValue(_variable))
);
outputMetadata.setValue<float>(
KeyMaxValue,
static_cast<float>(reader.maxValue(_variable))
);
ghoul::DictionaryLuaFormatter formatter;
std::string metadataString = formatter.format(outputMetadata);
@@ -170,7 +170,7 @@ void AtlasManager::addToAtlas(int firstBrickIndex, int lastBrickIndex, float* ma
unsigned int atlasCoords = _freeAtlasCoords.back();
_freeAtlasCoords.pop_back();
int level = _nOtLevels - floor(log((7.0 * (float(brickIndex % _nOtNodes)) + 1.0))/log(8)) - 1;
assert(atlasCoords <= 0x0FFFFFFF);
ghoul_assert(atlasCoords <= 0x0FFFFFFF, "@MISSING");
unsigned int atlasData = (level << 28) + atlasCoords;
_brickMap.insert(std::pair<unsigned int, unsigned int>(brickIndex, atlasData));
_nStreamedBricks++;
@@ -358,8 +358,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() {
for (int i = 0; i < gradients.size(); i++) {
float x = (i + 0.5f) / tfWidth;
float sample = histogram->interpolate(x);
assert(sample >= 0);
assert(gradients[i] >= 0);
ghoul_assert(sample >= 0, "@MISSING");
ghoul_assert(gradients[i] >= 0, "@MISSING");
error += sample * gradients[i];
}
_brickErrors[brickIndex].spatial = error;
@@ -375,8 +375,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() {
for (int i = 0; i < gradients.size(); i++) {
float x = (i + 0.5f) / tfWidth;
float sample = histogram->interpolate(x);
assert(sample >= 0);
assert(gradients[i] >= 0);
ghoul_assert(sample >= 0, "@MISSING");
ghoul_assert(gradients[i] >= 0, "@MISSING");
error += sample * gradients[i];
}
_brickErrors[brickIndex].temporal = error;
@@ -187,8 +187,6 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic
, _rotation(RotationInfo, glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(6.28f))
{
std::string name;
//bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
//assert(success);
_filename = "";
bool success = dictionary.getValue(KeyDataSource, _filename);
@@ -513,7 +511,8 @@ bool RenderableMultiresVolume::initializeSelector() {
} else {
// Build histograms from tsp file.
LWARNING("Failed to open " << cacheFilename);
if (success &= _errorHistogramManager->buildHistograms(nHistograms)) {
success &= _errorHistogramManager->buildHistograms(nHistograms);
if (success) {
LINFO("Writing cache to " << cacheFilename);
_errorHistogramManager->saveToFile(cacheFilename);
}
@@ -539,7 +538,11 @@ bool RenderableMultiresVolume::initializeSelector() {
} else {
// Build histograms from tsp file.
LWARNING("Failed to open " << cacheFilename);
if (success &= _histogramManager->buildHistograms(_tsp.get(), nHistograms)) {
success &= _histogramManager->buildHistograms(
_tsp.get(),
nHistograms
);
if (success) {
LINFO("Writing cache to " << cacheFilename);
_histogramManager->saveToFile(cacheFilename);
}
@@ -565,7 +568,8 @@ bool RenderableMultiresVolume::initializeSelector() {
} else {
// Build histograms from tsp file.
LWARNING("Failed to open " << cacheFilename);
if (success &= _localErrorHistogramManager->buildHistograms(nHistograms)) {
success &= _localErrorHistogramManager->buildHistograms(nHistograms);
if (success) {
LINFO("Writing cache to " << cacheFilename);
_localErrorHistogramManager->saveToFile(cacheFilename);
}
@@ -678,7 +682,7 @@ void RenderableMultiresVolume::update(const UpdateData& data) {
}
else if (_useGlobalTime) {
double t = (_time - _startTime) / (_endTime - _startTime);
currentTimestep = t * numTimesteps;
currentTimestep = static_cast<int>(t * numTimesteps);
visible = currentTimestep >= 0 && currentTimestep < numTimesteps;
}
else {
@@ -311,7 +311,7 @@ bool SimpleTfBrickSelector::calculateBrickImportances() {
float x = static_cast<float>(i) / static_cast<float>(tfWidth);
float sample = histogram->interpolate(x);
assert(sample >= 0);
ghoul_assert(sample >= 0, "@MISSING");
dotProduct += sample * tf->sample(i).w;
}
_brickImportances[brickIndex] = dotProduct;
@@ -367,8 +367,8 @@ bool TfBrickSelector::calculateBrickErrors() {
for (int i = 0; i < gradients.size(); i++) {
float x = (i + 0.5f) / tfWidth;
float sample = histogram->interpolate(x);
assert(sample >= 0);
assert(gradients[i] >= 0);
ghoul_assert(sample >= 0, "@MISSING");
ghoul_assert(gradients[i] >= 0, "@MISSING");
error += sample * gradients[i];
}
_brickErrors[brickIndex] = error;
+43 -22
View File
@@ -360,7 +360,6 @@ void TouchInteraction::directControl(const std::vector<TuioCursor>& list) {
dvec3 centerPos = ptr->node->worldPosition();
dvec3 directionToCenter = normalize(centerPos - camPos);
dvec3 centerToCamera = camPos - centerPos;
dvec3 lookUp = ptr->camera->lookUpVectorWorldSpace();
dvec3 camDirection = ptr->camera->viewDirectionWorldSpace();
@@ -386,6 +385,8 @@ void TouchInteraction::directControl(const std::vector<TuioCursor>& list) {
{ // Orbit (global rotation)
dvec3 eulerAngles(q[1], q[0], 0);
dquat rotationDiffCamSpace = dquat(eulerAngles);
dvec3 centerToCamera = camPos - centerPos;
dquat rotationDiffWorldSpace =
globalCamRot * rotationDiffCamSpace * inverse(globalCamRot);
@@ -393,11 +394,11 @@ void TouchInteraction::directControl(const std::vector<TuioCursor>& list) {
centerToCamera * rotationDiffWorldSpace - centerToCamera;
camPos += rotationDiffVec3;
dvec3 centerToCamera = camPos - centerPos;
centerToCamera = camPos - centerPos;
directionToCenter = normalize(-centerToCamera);
dvec3 lookUpWhenFacingCenter =
globalCamRot * dvec3(ptr->camera->lookUpVectorCameraSpace());
dmat4 lookAtMat = lookAt(
lookAtMat = lookAt(
dvec3(0, 0, 0),
directionToCenter,
lookUpWhenFacingCenter);
@@ -757,12 +758,12 @@ int TouchInteraction::interpretInteraction(const std::vector<TuioCursor>& list,
double minDiff = 1000;
int id = 0;
for (const TuioCursor& c : list) {
TuioPoint point = std::find_if(
TuioPoint itPoint = std::find_if(
lastProcessed.begin(),
lastProcessed.end(),
[&c](const Point& p) { return p.first == c.getSessionID(); }
)->second;
double diff = c.getX() - point.getX() + c.getY() - point.getY();
double diff = c.getX() - itPoint.getX() + c.getY() - itPoint.getY();
if (!c.isMoving()) {
diff = minDiff = 0.0;
id = c.getSessionID();
@@ -784,8 +785,14 @@ int TouchInteraction::interpretInteraction(const std::vector<TuioCursor>& list,
[&c](const Point& p) { return p.first == c.getSessionID(); }
)->second;
double res = 0.0;
float lastAngle = point.getAngle(_centroid.x, _centroid.y);
float currentAngle = c.getAngle(_centroid.x, _centroid.y);
float lastAngle = point.getAngle(
static_cast<float>(_centroid.x),
static_cast<float>(_centroid.y)
);
float currentAngle = c.getAngle(
static_cast<float>(_centroid.x),
static_cast<float>(_centroid.y)
);
if (lastAngle > currentAngle + 1.5 * M_PI) {
res = currentAngle + (2 * M_PI - lastAngle);
}
@@ -811,7 +818,9 @@ int TouchInteraction::interpretInteraction(const std::vector<TuioCursor>& list,
return ROT;
}
else {
float avgDistance = std::abs(dist - lastDist) / list.at(0).getMotionSpeed();
float avgDistance = static_cast<float>(
std::abs(dist - lastDist) / list.at(0).getMotionSpeed()
);
// if average distance between 3 fingers are constant we have panning
if (avgDistance < _interpretPan && list.size() == 3) {
return PAN;
@@ -854,7 +863,10 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
list.end(),
0.0,
[&](double d, const TuioCursor& c) {
return d + c.getDistance(_centroid.x, _centroid.y);
return d + c.getDistance(
static_cast<float>(_centroid.x),
static_cast<float>(_centroid.y)
);
}
) / list.size();
double lastDistance = std::accumulate(
@@ -862,7 +874,10 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
lastProcessed.end(),
0.0f,
[&](float d, const Point& p) {
return d + p.second.getDistance(_centroid.x, _centroid.y);
return d + p.second.getDistance(
static_cast<float>(_centroid.x),
static_cast<float>(_centroid.y)
);
}
) / lastProcessed.size();
@@ -886,8 +901,14 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
[&c](const Point& p) { return p.first == c.getSessionID(); }
)->second;
double res = diff;
double lastAngle = point.getAngle(_centroid.x, _centroid.y);
double currentAngle = c.getAngle(_centroid.x, _centroid.y);
double lastAngle = point.getAngle(
static_cast<float>(_centroid.x),
static_cast<float>(_centroid.y)
);
double currentAngle = c.getAngle(
static_cast<float>(_centroid.x),
static_cast<float>(_centroid.y)
);
// if's used to set angles 359 + 1 = 0 and 0 - 1 = 359
if (lastAngle > currentAngle + 1.5 * M_PI) {
res += currentAngle + (2 * M_PI - lastAngle);
@@ -1009,8 +1030,8 @@ void TouchInteraction::step(double dt) {
centerToCamera;
camPos += rotationDiffVec3;
dvec3 centerToCamera = camPos - centerPos;
directionToCenter = normalize(-centerToCamera);
dvec3 centerToCam = camPos - centerPos;
directionToCenter = normalize(-centerToCam);
dvec3 lookUpWhenFacingCenter = globalCamRot *
dvec3(_camera->lookUpVectorCameraSpace());
dmat4 lookAtMat = lookAt(
@@ -1021,11 +1042,11 @@ void TouchInteraction::step(double dt) {
}
{ // Zooming
centerToBoundingSphere = -directionToCenter * boundingSphere;
dvec3 centerToCamera = camPos - centerPos;
double distToSurface = length(centerToCamera - centerToBoundingSphere);
dvec3 centerToCam = camPos - centerPos;
double distToSurface = length(centerToCam - centerToBoundingSphere);
if (length(_vel.zoom * dt) < distToSurface &&
length(centerToCamera + directionToCenter*_vel.zoom * dt) >
length(centerToCam + directionToCenter*_vel.zoom * dt) >
length(centerToBoundingSphere))
{
camPos += directionToCenter * _vel.zoom * dt;
@@ -1054,12 +1075,12 @@ void TouchInteraction::unitTest() {
// set _selected pos and new pos (on screen)
std::vector<TuioCursor> lastFrame = {
{ TuioCursor(0, 10, 0.45, 0.4) }, // session id, cursor id, x, y
{ TuioCursor(1, 11, 0.55, 0.6) }
{ TuioCursor(0, 10, 0.45f, 0.4f) }, // session id, cursor id, x, y
{ TuioCursor(1, 11, 0.55f, 0.6f) }
};
std::vector<TuioCursor> currFrame = {
{ TuioCursor(0, 10, 0.2, 0.6) }, // (-0.6,-0.2)
{ TuioCursor(1, 11, 0.8, 0.4) } // (0.6, 0.2)
{ TuioCursor(0, 10, 0.2f, 0.6f) }, // (-0.6,-0.2)
{ TuioCursor(1, 11, 0.8f, 0.4f) } // (0.6, 0.2)
};
// call update
@@ -1098,7 +1119,7 @@ void TouchInteraction::decelerate(double dt) {
double frequency = 1.0 / _deceleratesPerSecond;
// Number of times velocities should decelerate, depending on chosen frequency and
// time slack over from last frame
int times = (dt + _timeSlack) / frequency;
int times = static_cast<int>((dt + _timeSlack) / frequency);
// Save the new time slack for the next frame
_timeSlack = fmod((dt + _timeSlack), frequency);
+1 -1
View File
@@ -68,7 +68,7 @@ void RawVolumeWriter<VoxelType>::write(
std::vector<VoxelType> buffer(_bufferSize);
std::ofstream file(_path, std::ios::binary);
int nChunks = size / _bufferSize;
int nChunks = static_cast<int>(size / _bufferSize);
if (size % _bufferSize > 0) {
nChunks++;
}
@@ -157,20 +157,20 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _clipPlanes(nullptr)
, _stepSize(StepSizeInfo, 0.02, 0.01, 1)
, _stepSize(StepSizeInfo, 0.02f, 0.001f, 1.f)
, _gridType(GridTypeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _secondsBefore(SecondsBeforeInfo, 0.0, 0.01, SecondsInOneDay)
, _secondsAfter(SecondsAfterInfo, 0.0, 0.01, SecondsInOneDay)
, _secondsBefore(SecondsBeforeInfo, 0.f, 0.01f, SecondsInOneDay)
, _secondsAfter(SecondsAfterInfo, 0.f, 0.01f, SecondsInOneDay)
, _sourceDirectory(SourceDirectoryInfo)
, _transferFunctionPath(TransferFunctionInfo)
, _triggerTimeJump(TriggerTimeJumpInfo)
, _jumpToTimestep(JumpToTimestepInfo, 0, 0, 256)
, _currentTimestep(CurrentTimeStepInfo, 0, 0, 256)
, _opacity(OpacityInfo, 10.0f, 0.0f, 50.0f)
, _rNormalization(rNormalizationInfo, 0.0f, 0.0f, 2.0f)
, _rUpperBound(rUpperBoundInfo, 1.0f, 0.0f, 2.0f)
, _lowerValueBound(lowerValueBoundInfo, 0.0f, 0.0f, 1000000.0f)
, _upperValueBound(upperValueBoundInfo, 0.0f, 0.0f, 1000000.0f)
, _opacity(OpacityInfo, 10.f, 0.f, 500.f)
, _rNormalization(rNormalizationInfo, 0.f, 0.f, 2.f)
, _rUpperBound(rUpperBoundInfo, 1.f, 0.f, 2.f)
, _lowerValueBound(lowerValueBoundInfo, 0.f, 0.f, 1000000.f)
, _upperValueBound(upperValueBoundInfo, 0.f, 0.f, 1000000.f)
, _raycaster(nullptr)
, _transferFunction(nullptr)
{
@@ -192,6 +192,10 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
});
_gridType.setValue(static_cast<int>(volume::VolumeGridType::Cartesian));
if (dictionary.hasValue<float>(KeyStepSize)) {
_stepSize = dictionary.value<float>(KeyStepSize);
}
if (dictionary.hasValue<float>(KeySecondsBefore)) {
_secondsBefore = dictionary.value<float>(KeySecondsBefore);
}
@@ -296,7 +300,7 @@ void RenderableTimeVaryingVolume::initializeGL() {
});
const int lastTimestep = (_volumeTimesteps.size() > 0) ?
(_volumeTimesteps.size() - 1) :
static_cast<int>(_volumeTimesteps.size() - 1) :
0;
_currentTimestep.setMaxValue(lastTimestep);
_jumpToTimestep.setMaxValue(lastTimestep);
@@ -326,6 +330,12 @@ void RenderableTimeVaryingVolume::initializeGL() {
VolumeGridType::Cartesian
);
});
_transferFunctionPath.onChange([this] {
_transferFunction =
std::make_shared<TransferFunction>(_transferFunctionPath);
_raycaster->setTransferFunction(_transferFunction);
});
}
void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path) {
@@ -425,7 +435,8 @@ void RenderableTimeVaryingVolume::jumpToTimestep(int target) {
OsEng.timeManager().setTimeNextFrame(t->time);
}
void RenderableTimeVaryingVolume::update(const UpdateData& data) {
void RenderableTimeVaryingVolume::update(const UpdateData&) {
_transferFunction->update();
if (_raycaster) {
Timestep* t = currentTimestep();
_currentTimestep = timestepIndex(t);
@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_VOLUME___RENDERABLEKAMELEONVOLUME___H__
#define __OPENSPACE_MODULE_VOLUME___RENDERABLEKAMELEONVOLUME___H__
#ifndef __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__
#define __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__
#include <openspace/rendering/renderable.h>
@@ -106,4 +106,4 @@ private:
} // namespace volume
} // namespace openspace
#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___RENDERABLEKAMELEONVOLUME___H__
#endif // __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__
@@ -43,6 +43,8 @@ public:
TextureSliceVolumeReader(std::vector<std::string> paths, size_t sliceCacheMaxItems,
size_t sliceCacheSize);
virtual ~TextureSliceVolumeReader() = default;
VoxelType get(const glm::ivec3& coordinates) const;
virtual glm::ivec3 dimensions() const;
void setPaths(const std::vector<std::string> paths);
+4 -4
View File
@@ -56,20 +56,20 @@ typename VolumeType::VoxelType VolumeSampler<VolumeType>::sample(
for (int y = minCoords.y; y <= maxCoords.y; y++) {
for (int x = minCoords.x; x <= maxCoords.x; x++) {
glm::ivec3 sampleCoords = glm::ivec3(x, y, z);
float filterCoefficient = 1.0;
float filterCoefficient = 1.f;
if (x == minCoords.x) {
filterCoefficient *= (1.0 - t.x);
filterCoefficient *= (1.f - t.x);
} else if (x == maxCoords.x) {
filterCoefficient *= t.x;
}
if (y == minCoords.y) {
filterCoefficient *= (1.0 - t.y);
filterCoefficient *= (1.f - t.y);
} else if (y == maxCoords.y) {
filterCoefficient *= t.y;
}
if (z == minCoords.z) {
filterCoefficient *= (1.0 - t.z);
filterCoefficient *= (1.f - t.z);
} else if (z == maxCoords.z) {
filterCoefficient *= t.z;
}