From da45e4effa1208ed382ef2b32af2050ffcf8017c Mon Sep 17 00:00:00 2001 From: OLSSON Date: Sun, 21 Feb 2021 17:21:18 -0500 Subject: [PATCH] clean up --- modules/fieldlinessequence/include.cmake | 2 +- .../renderablefieldlinessequence.cpp | 11 ++--- .../rendering/renderablelighttravel.cpp | 6 +-- .../rendering/renderablestreamnodes.cpp | 46 ++++++++++--------- .../rendering/renderabletimevaryingsphere.cpp | 8 ++-- 5 files changed, 38 insertions(+), 35 deletions(-) diff --git a/modules/fieldlinessequence/include.cmake b/modules/fieldlinessequence/include.cmake index f6e8111e4e..a746e4569e 100644 --- a/modules/fieldlinessequence/include.cmake +++ b/modules/fieldlinessequence/include.cmake @@ -1,3 +1,3 @@ set (OPENSPACE_DEPENDENCIES - kameleon + space ) diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index c4cb147769..fe690b4476 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -480,17 +480,16 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary( { // ------------------- EXTRACT OPTIONAL VALUES FROM DICTIONARY ------------------- // - bool flowEnabledValue; - if (_dictionary->getValue(KeyFlowEnabled, flowEnabledValue)) { - _pFlowEnabled = flowEnabledValue; + if (_dictionary->hasValue(KeyFlowEnabled)) { + _pFlowEnabled = _dictionary->value(KeyFlowEnabled); } float lineWidthValue; - if (_dictionary->getValue(KeyLineWidth, lineWidthValue)) { - _pLineWidth = lineWidthValue; + if (_dictionary->hasValue(KeyLineWidth)) { + _pLineWidth = stringToFloat(_dictionary->value(KeyLineWidth)); } - if (_dictionary->getValue(KeyOutputFolder, outputFolderPath)) { + if (_dictionary->hasValue(KeyOutputFolder)) { ghoul::filesystem::Directory outputFolder(outputFolderPath); if (FileSys.directoryExists(outputFolder)) { outputFolderPath = absPath(outputFolderPath); diff --git a/modules/streamnodes/rendering/renderablelighttravel.cpp b/modules/streamnodes/rendering/renderablelighttravel.cpp index 8a7195dd49..60ca087d07 100644 --- a/modules/streamnodes/rendering/renderablelighttravel.cpp +++ b/modules/streamnodes/rendering/renderablelighttravel.cpp @@ -154,7 +154,7 @@ namespace openspace { void RenderableLightTravel::initializeGL() { _dictionary.reset(); - _shaderProgram = global::renderEngine.buildRenderProgram( + _shaderProgram = global::renderEngine->buildRenderProgram( "Lighttravel", absPath("${MODULE_STREAMNODES}/shaders/lighttravel_vs.glsl"), absPath("${MODULE_STREAMNODES}/shaders/lighttravel_fs.glsl") @@ -162,7 +162,7 @@ void RenderableLightTravel::initializeGL() { if(_font == nullptr){ size_t _fontSize = 50; - _font = global::fontManager.font( + _font = global::fontManager->font( "Mono", static_cast(_fontSize), ghoul::fontrendering::FontManager::Outline::Yes, @@ -252,7 +252,7 @@ void RenderableLightTravel::deinitializeGL() _vertexPositionBuffer = 0; if (_shaderProgram) { - global::renderEngine.removeRenderProgram(_shaderProgram.get()); + global::renderEngine->removeRenderProgram(_shaderProgram.get()); _shaderProgram = nullptr; } } diff --git a/modules/streamnodes/rendering/renderablestreamnodes.cpp b/modules/streamnodes/rendering/renderablestreamnodes.cpp index 51b9cc6283..cde876449b 100644 --- a/modules/streamnodes/rendering/renderablestreamnodes.cpp +++ b/modules/streamnodes/rendering/renderablestreamnodes.cpp @@ -518,7 +518,7 @@ void RenderableStreamNodes::initializeGL() { return; } // Setup shader program - _shaderProgram = global::renderEngine.buildRenderProgram( + _shaderProgram = global::renderEngine->buildRenderProgram( "Streamnodes", absPath("${MODULE_STREAMNODES}/shaders/streamnodes_vs.glsl"), absPath("${MODULE_STREAMNODES}/shaders/streamnodes_fs.glsl") @@ -532,8 +532,9 @@ void RenderableStreamNodes::initializeGL() { ghoul::opengl::updateUniformLocations(*_shaderProgram, _uniformCache, UniformNames); ghoul::opengl::updateUniformLocations(*_shaderProgram, _uniformCache2, UniformNames2); - ghoul::Dictionary colorTablesPathsDictionary; - if (_dictionary->getValue(KeyColorTablePaths, colorTablesPathsDictionary)) { + if (_dictionary->hasValue((KeyColorTablePaths))) { + ghoul::Dictionary colorTablesPathsDictionary = + _dictionary->value(KeyColorTablePaths); const size_t nProvidedPaths = colorTablesPathsDictionary.size(); if (nProvidedPaths > 0) { // Clear the default! It is already specified in the transferFunction @@ -938,15 +939,17 @@ bool RenderableStreamNodes::loadBinaryfilesDirectly(const std::string& energybin **/ bool RenderableStreamNodes::extractMandatoryInfoFromDictionary() { - _dictionary->getValue(SceneGraphNode::KeyIdentifier, _identifier); + _identifier = _dictionary->value(SceneGraphNode::KeyIdentifier); // ------------------- EXTRACT MANDATORY VALUES FROM DICTIONARY ------------------- // std::string inputFileTypeString; - if (!_dictionary->getValue(KeyInputFileType, inputFileTypeString)) { + if (!_dictionary->hasValue(KeyInputFileType)) { LERROR(fmt::format("{}: The field {} is missing", _identifier, KeyInputFileType)); } else { // Verify that the input type is corrects + inputFileTypeString = + _dictionary->value(KeyInputFileType); if (inputFileTypeString == ValueInputFileTypeJson) { // == "json" } else if(inputFileTypeString == "") { @@ -962,17 +965,19 @@ bool RenderableStreamNodes::extractMandatoryInfoFromDictionary() //_colorTableRanges.push_back(glm::vec2(0, 1)); - std::string sourceFolderPath; - if (!_dictionary->getValue(KeySourceFolder, sourceFolderPath)) { + if (!_dictionary->hasValue(KeySourceFolder)) { LERROR(fmt::format("{}: The field {} is missing", _identifier, KeySourceFolder)); return false; } - std::string binarySourceFolderPath; - if (!_dictionary->getValue(KeyBinarySourceFolder, binarySourceFolderPath)) { + if (!_dictionary->hasValue(KeyBinarySourceFolder)) { LERROR(fmt::format("{}: The field {} is missing", _identifier, KeyBinarySourceFolder)); return false; } //constexpr const char temp = '\'; + std::string sourceFolderPath = + _dictionary->value(KeySourceFolder); + std::string binarySourceFolderPath = + _dictionary->value(KeyBinarySourceFolder); _binarySourceFilePath = binarySourceFolderPath; LDEBUG(binarySourceFolderPath); ghoul::filesystem::Directory binarySourceFolder(binarySourceFolderPath); @@ -1032,7 +1037,8 @@ bool RenderableStreamNodes::extractMandatoryInfoFromDictionary() bool RenderableStreamNodes::extractJsonInfoFromDictionary(fls::Model& model) { std::string modelStr; - if (_dictionary->getValue(KeySimulationModel, modelStr)) { + if (_dictionary->hasValue(KeySimulationModel)) { + modelStr = _dictionary->value(KeySimulationModel); std::transform( modelStr.begin(), modelStr.end(), @@ -1047,17 +1053,15 @@ bool RenderableStreamNodes::extractJsonInfoFromDictionary(fls::Model& model) { )); return false; } - float lineWidthValue; - if (_dictionary->getValue(KeyLineWidth, lineWidthValue)) { - _pLineWidth = lineWidthValue; + + if (_dictionary->hasValue(KeyLineWidth)) { + _pLineWidth = stringToFloat(_dictionary->value(KeyLineWidth)); } - float thresholdRadiusValue; - if (_dictionary->getValue(KeyThresholdRadius, thresholdRadiusValue)) { - _pThresholdFlux = thresholdRadiusValue; + if (_dictionary->hasValue(KeyThresholdRadius)) { + _pThresholdFlux = stringToFloat(_dictionary->value(KeyThresholdRadius)); } - float scaleFactor; - if (_dictionary->getValue(KeyJsonScalingFactor, scaleFactor)) { - _scalingFactor = scaleFactor; + if (_dictionary->hasValue(KeyJsonScalingFactor)) { + _scalingFactor = stringToFloat(_dictionary->value(KeyJsonScalingFactor)); } else { LWARNING(fmt::format( @@ -1184,7 +1188,7 @@ void RenderableStreamNodes::deinitializeGL() { //_arrow = 0; if (_shaderProgram) { - global::renderEngine.removeRenderProgram(_shaderProgram.get()); + global::renderEngine->removeRenderProgram(_shaderProgram.get()); _shaderProgram = nullptr; } @@ -1401,7 +1405,7 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) { _shaderProgram->setUniform(_uniformCache.particleSpeed, _pFlowSpeed); _shaderProgram->setUniform(_uniformCache2.time, - global::windowDelegate.applicationTime() * -1); + global::windowDelegate->applicationTime() * -1); _shaderProgram->setUniform(_uniformCache2.flowColoring, _pUseFlowColor); //_shaderProgram->setUniform("minNodeDistanceSize", _pMinNodeDistanceSize); _shaderProgram->setUniform(_uniformCache2.maxNodeDistanceSize, diff --git a/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp b/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp index 3fc34042b3..425cf489c2 100644 --- a/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp +++ b/modules/streamnodes/rendering/renderabletimevaryingsphere.cpp @@ -311,7 +311,7 @@ void RenderableTimeVaryingSphere::initializeGL() { _shader = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/sphere_vs.glsl"), absPath("${MODULE_BASE}/shaders/sphere_fs.glsl") @@ -346,7 +346,7 @@ void RenderableTimeVaryingSphere::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _textureFiles.clear(); @@ -448,10 +448,10 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&) glDisable(GL_CULL_FACE); } - bool usingFramebufferRenderer = global::renderEngine.rendererImplementation() == + bool usingFramebufferRenderer = global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; - bool usingABufferRenderer = global::renderEngine.rendererImplementation() == + bool usingABufferRenderer = global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::ABuffer; if (usingABufferRenderer && _useAdditiveBlending) {