General code cleanup (#3445)

This commit is contained in:
Alexander Bock
2024-10-10 09:49:02 +02:00
committed by GitHub
parent 125114cad5
commit ff345006d1
108 changed files with 938 additions and 1189 deletions
-1
View File
@@ -42,7 +42,6 @@ This repository contains the source code and example profiles for OpenSpace, but
Requirements for compiling are:
- CMake version 3.25 or above
- C++ compiler supporting C++20/C++23 (Visual Studio 2022 17.11, GCC13, Clang17, AppleClang 15.0.0)
- [Boost](http://www.boost.org/)
- [Qt](http://www.qt.io/download)
@@ -39,6 +39,7 @@ namespace openspace::documentation {
class Verifier;
BooleanType(Optional);
BooleanType(Private);
/**
* The TestResult structure returns the information from the #testSpecification method. It
@@ -161,16 +162,20 @@ struct DocumentationEntry {
* contains this DocumentationEntry will be matched
* \param v The Verifier that is used to test the \p k%'s value to determine if it is
* a valid value
* \param doc The textual documentation that describes the DocumentationEntry in a
* human readable format
* \param opt Determines whether the Documentation containing this DocumentationEntry
* must have a key \p key, or whether it is optional
* \param priv Determines whether the DocumentationEntry is considered private. If it
* is, then shall not be reported in a user-facing manner, but its values
* should still be checked when verifying the correctness and completeness of
* an entry
* \param doc The textual documentation that describes the DocumentationEntry in a
* human readable format
*
* \pre \p k must not be empty
* \pre \p v must not be nullptr
*/
DocumentationEntry(std::string k, std::shared_ptr<Verifier> v,
Optional opt, std::string doc = "");
Optional opt = Optional::No, Private priv = Private::No, std::string doc = "");
/**
* The constructor for a DocumentationEntry describing a key \p k in a Documentation.
@@ -187,15 +192,20 @@ struct DocumentationEntry {
* \param v The Verifier that is used to test the \p key%'s value to determine if it
* is a valid value. The DocumentationEntry will take ownership of the passed
* object
* \param doc The textual documentation that describes the DocumentationEntry in a
* human readable format
* \param opt Determines whether the Documentation containing this DocumentationEntry
* must have a key \p key, or whether it is optional
* \param priv Determines whether the DocumentationEntry is considered private. If it
* is, then shall not be reported in a user-facing manner, but its values
* should still be checked when verifying the correctness and completeness of
* an entry
* \param doc The textual documentation that describes the DocumentationEntry in a
* human readable format
*
* \pre \p k must not be empty
* \pre \p v must not be nullptr
*/
DocumentationEntry(std::string k, Verifier* v, Optional opt, std::string doc = "");
DocumentationEntry(std::string k, Verifier* v, Optional opt = Optional::No,
Private priv = Private::No, std::string doc = "");
/// The key that is described by this DocumentationEntry
std::string key;
@@ -203,6 +213,8 @@ struct DocumentationEntry {
std::shared_ptr<Verifier> verifier;
/// Determines whether the described DocumentationEntry is optional or not
Optional optional;
/// Determines if the entry should be visible to the user
Private isPrivate;
/// The textual description of this DocumentationEntry
std::string documentation;
};
+21 -3
View File
@@ -369,7 +369,13 @@ class Vector2ListVerifier : public TableVerifier {
public:
Vector2ListVerifier(std::string elementDocumentation = "")
: TableVerifier({
{ "*", new Vector2Verifier<T>, Optional::No, std::move(elementDocumentation) }
{
"*",
new Vector2Verifier<T>,
Optional::No,
Private::No,
std::move(elementDocumentation)
}
})
{}
@@ -387,7 +393,13 @@ class Vector3ListVerifier : public TableVerifier {
public:
Vector3ListVerifier(std::string elementDocumentation = "")
: TableVerifier({
{ "*", new Vector3Verifier<T>, Optional::No, std::move(elementDocumentation) }
{
"*",
new Vector3Verifier<T>,
Optional::No,
Private::No,
std::move(elementDocumentation)
}
})
{}
@@ -405,7 +417,13 @@ class Vector4ListVerifier : public TableVerifier {
public:
Vector4ListVerifier(std::string elementDocumentation = "")
: TableVerifier({
{ "*", new Vector4Verifier<T>, Optional::No, std::move(elementDocumentation) }
{
"*",
new Vector4Verifier<T>,
Optional::No,
Private::No,
std::move(elementDocumentation)
}
})
{}
+2 -4
View File
@@ -422,7 +422,7 @@ NotInListVerifier<T>::NotInListVerifier(std::vector<typename T::Type> vals)
template <typename T>
TestResult NotInListVerifier<T>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const
const std::string& key) const
{
TestResult res = T::operator()(dict, key);
if (res.success) {
@@ -686,9 +686,7 @@ std::string NotInRangeVerifier<T>::documentation() const {
template <typename T>
AnnotationVerifier<T>::AnnotationVerifier(std::string a)
: annotation(std::move(a))
{
}
{}
template <typename T>
std::string AnnotationVerifier<T>::documentation() const {
+1 -1
View File
@@ -156,7 +156,7 @@ struct Configuration {
// Values not read from the openspace.cfg file
std::string sgctConfigNameInitialized;
static documentation::Documentation Documentation;
static documentation::Documentation Documentation();
ghoul::lua::LuaState state;
};
+6
View File
@@ -39,6 +39,7 @@ namespace openspace {
class OpenSpaceModule;
namespace documentation { struct Documentation; }
namespace scripting { struct LuaLibrary; }
/**
@@ -122,6 +123,11 @@ public:
*/
static scripting::LuaLibrary luaLibrary();
/**
* Returns the list of all documentations for all modules.
*/
std::vector<documentation::Documentation> moduleDocumentations() const;
private:
/// The list of all names of all registered OpenSpaceModules
properties::StringListProperty _allModules;
+1 -1
View File
@@ -76,7 +76,7 @@ public:
/// A callback that will be called when the script finishes executing and that
/// provides access to the return value of the script
Callback callback;
Callback callback = Callback();
};
static constexpr std::string_view OpenSpaceLibraryName = "openspace";
+6
View File
@@ -92,6 +92,12 @@ public:
*/
virtual std::vector<documentation::Documentation> documentations() const;
/**
* Returns the documentation that describes the parameters that can be passed to the
* initialize function of this module.
*/
static documentation::Documentation Documentation();
/**
* Returns the Lua library with functions defined by this OpenSpaceModule. The default
* implementation returns an empty library.
+6
View File
@@ -320,6 +320,7 @@ list(REMOVE_DUPLICATES topologically_sorted)
set(MODULE_HEADERS "")
set(MODULE_CLASSES "")
set(MODULE_DOCUMENTATION "")
foreach (key RANGE ${enabled_module_count})
list(GET topologically_sorted ${key} name)
@@ -335,6 +336,7 @@ foreach (key RANGE ${enabled_module_count})
list(APPEND MODULE_HEADERS "#include <${header_filepath}>\n")
list(APPEND MODULE_CLASSES " new ${class_name},\n")
list(APPEND MODULE_DOCUMENTATION " ${class_name}::Documentation(),\n")
endforeach ()
get_unique_include_paths(
@@ -359,6 +361,10 @@ if (NOT "${MODULE_CLASSES}" STREQUAL "")
string(REPLACE ";" "" MODULE_CLASSES ${MODULE_CLASSES})
endif ()
if (NOT "${MODULE_DOCUMENTATION}" STREQUAL "")
string(REPLACE ";" "" MODULE_DOCUMENTATION ${MODULE_DOCUMENTATION})
endif ()
configure_file(
${PROJECT_SOURCE_DIR}/support/cmake/module_registration.template
${CMAKE_BINARY_DIR}/_generated/include/openspace/moduleregistration.h
+4
View File
@@ -47,6 +47,10 @@ namespace {
namespace openspace {
documentation::Documentation AudioModule::Documentation() {
return codegen::doc<Parameters>("module_audio");
}
AudioModule::AudioModule()
: OpenSpaceModule(Name)
, _engine(std::make_unique<SoLoud::Soloud>())
+2
View File
@@ -287,6 +287,8 @@ public:
*/
glm::vec3 speakerPosition(int channel) const;
static documentation::Documentation Documentation();
private:
struct Info {
std::unique_ptr<SoLoud::Wav> sound;
@@ -163,7 +163,7 @@ void RenderableBoxGrid::deinitializeGL() {
_gridProgram = nullptr;
}
void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){
void RenderableBoxGrid::render(const RenderData& data, RendererTasks&) {
_gridProgram->activate();
auto [modelTransform, modelViewTransform, modelViewProjectionTransform] =
@@ -237,7 +237,7 @@ void RenderableGrid::deinitializeGL() {
_gridProgram = nullptr;
}
void RenderableGrid::render(const RenderData& data, RendererTasks&){
void RenderableGrid::render(const RenderData& data, RendererTasks&) {
_gridProgram->activate();
const glm::dmat4 modelTransform = calcModelTransform(data);
@@ -179,7 +179,7 @@ void RenderableSphericalGrid::deinitializeGL() {
_gridProgram = nullptr;
}
void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&) {
_gridProgram->activate();
auto [modelTransform, modelViewTransform, modelViewProjectionTransform] =
@@ -184,7 +184,7 @@ void RenderableCartesianAxes::deinitializeGL() {
_program = nullptr;
}
void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){
void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&) {
_program->activate();
const glm::dmat4 modelViewTransform = calcModelViewTransform(data);
@@ -44,14 +44,18 @@ namespace {
constexpr openspace::properties::Property::PropertyInfo SourceFolderInfo = {
"SourceFolder",
"Source Folder",
"An image directory that is loaded from disk and contains the textures to use "
"for this plane.",
"An image directory that is loaded from disk and contains the textures to use "
"for this plane.",
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(RenderablePlaneTimeVaryingImage)]] Parameters {
// [[codegen::verbatim(SourceFolderInfo.description)]]
std::string sourceFolder;
// If set to `true` the images are only loaded when it is about to be shown
// instead of preloading them
std::optional<bool> lazyLoading;
};
#include "renderableplanetimevaryingimage_codegen.cpp"
} // namespace
@@ -83,20 +87,17 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage(
addProperty(_sourceFolder);
_sourceFolder.onChange([this]() { _texture = loadTexture(); });
if (dictionary.hasKey(KeyLazyLoading)) {
_isLoadingLazily = dictionary.value<bool>(KeyLazyLoading);
if (_isLoadingLazily) {
_enabled.onChange([this]() {
if (_enabled) {
_textureIsDirty = true;
}
else {
BaseModule::TextureManager.release(_texture);
_texture = nullptr;
}
});
}
_isLoadingLazily = p.lazyLoading.value_or(_isLoadingLazily);
if (_isLoadingLazily) {
_enabled.onChange([this]() {
if (_enabled) {
_textureIsDirty = true;
}
else {
BaseModule::TextureManager.release(_texture);
_texture = nullptr;
}
});
}
}
+1 -3
View File
@@ -219,9 +219,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
setRenderBin(RenderBin::Overlay);
addProperty(Fadeable::_opacity);
_translation = Translation::createFromDictionary(
dictionary.value<ghoul::Dictionary>("Translation")
);
_translation = Translation::createFromDictionary(p.translation);
addPropertySubOwner(_translation.get());
_appearance.lineColor = p.color;
@@ -46,6 +46,8 @@ namespace {
};
struct [[codegen::Dictionary(ScreenSpaceDashboard)]] Parameters {
std::optional<std::string> identifier;
// [[codegen::verbatim(UseMainInfo.description)]]
std::optional<bool> useMainDashboard;
@@ -72,15 +74,8 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
std::string identifier;
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
identifier = dictionary.value<std::string>(KeyIdentifier);
}
else {
identifier = "ScreenSpaceDashboard";
}
identifier = makeUniqueIdentifier(identifier);
setIdentifier(std::move(identifier));
std::string identifier = p.identifier.value_or("ScreenSpaceDashboard");
setIdentifier(makeUniqueIdentifier(std::move(identifier)));
_useMainDashboard = p.useMainDashboard.value_or(_useMainDashboard);
addProperty(_useMainDashboard);
@@ -52,6 +52,8 @@ namespace {
// To load an image from a web URL, see
// [ScreenSpaceImageOnline](#base_screenspace_image_online).
struct [[codegen::Dictionary(ScreenSpaceImageLocal)]] Parameters {
std::optional<std::string> identifier;
// [[codegen::verbatim(TexturePathInfo.description)]]
std::optional<std::string> texturePath;
};
@@ -70,15 +72,8 @@ ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary
{
const Parameters p = codegen::bake<Parameters>(dictionary);
std::string identifier;
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
identifier = dictionary.value<std::string>(KeyIdentifier);
}
else {
identifier = "ScreenSpaceImageLocal";
}
identifier = makeUniqueIdentifier(identifier);
setIdentifier(identifier);
std::string identifier = p.identifier.value_or("ScreenSpaceImageLocal");
setIdentifier(makeUniqueIdentifier(std::move(identifier)));
_texturePath.onChange([this]() {
if (!std::filesystem::is_regular_file(absPath(_texturePath))) {
@@ -52,6 +52,8 @@ namespace {
// To load an image from a local file on disk, see
// [`ScreenSpaceImageLocal`](#base_screenspace_image_local).
struct [[codegen::Dictionary(ScreenSpaceImageOnline)]] Parameters {
std::optional<std::string> identifier;
// [[codegen::verbatim(TextureInfo.description)]]
std::optional<std::string> url [[codegen::key("URL")]];
};
@@ -71,15 +73,8 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona
{
const Parameters p = codegen::bake<Parameters>(dictionary);
std::string identifier;
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
identifier = dictionary.value<std::string>(KeyIdentifier);
}
else {
identifier = "ScreenSpaceImageOnline";
}
identifier = makeUniqueIdentifier(identifier);
setIdentifier(std::move(identifier));
std::string identifier = p.identifier.value_or("ScreenSpaceImageOnline");
setIdentifier(makeUniqueIdentifier(std::move(identifier)));
_texturePath.onChange([this]() { _textureIsDirty = true; });
_texturePath = p.url.value_or(_texturePath);
+23 -12
View File
@@ -28,6 +28,7 @@
#include <modules/cefwebgui/include/guirenderhandler.h>
#include <modules/cefwebgui/include/guikeyboardhandler.h>
#include <modules/webbrowser/include/browserinstance.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/globalscallbacks.h>
#include <openspace/engine/moduleengine.h>
@@ -72,10 +73,27 @@ namespace {
"GUI scale multiplier.",
openspace::properties::Property::Visibility::Always
};
struct [[codegen::Dictionary(CefWebGuiModule)]] Parameters {
// [[codegen::verbatim(GuiScaleInfo.description)]]
std::optional<float> guiScale;
// [[codegen::verbatim(EnabledInfo.description)]]
std::optional<bool> enabled;
// [[codegen::verbatim(VisibleInfo.description)]]
std::optional<bool> visible;
};
#include "cefwebguimodule_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation CefWebGuiModule::Documentation() {
return codegen::doc<Parameters>("module_cefwebgui");
}
CefWebGuiModule::CefWebGuiModule()
: OpenSpaceModule(CefWebGuiModule::Name)
, _enabled(EnabledInfo, true)
@@ -200,17 +218,10 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
}
);
if (configuration.hasValue<double>(GuiScaleInfo.identifier)) {
_guiScale = static_cast<float>(
configuration.value<double>(GuiScaleInfo.identifier)
);
}
_enabled = configuration.hasValue<bool>(EnabledInfo.identifier) &&
configuration.value<bool>(EnabledInfo.identifier);
_visible = configuration.hasValue<bool>(VisibleInfo.identifier) &&
configuration.value<bool>(VisibleInfo.identifier);
const Parameters p = codegen::bake<Parameters>(configuration);
_guiScale = p.guiScale.value_or(_guiScale);
_enabled = p.enabled.value_or(_enabled);
_visible = p.visible.value_or(_visible);
global::callback::initializeGL->emplace_back([this]() {
startOrStopGui();
@@ -218,7 +229,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
global::callback::postDraw->emplace_back([this]() {
bool windowChanged = global::windowDelegate->windowHasResized();
if (_instance && (windowChanged || _instance->_shouldReshape)){
if (_instance && (windowChanged || _instance->_shouldReshape)) {
const glm::ivec2 res = global::windowDelegate->guiWindowResolution();
_instance->reshape(static_cast<glm::ivec2>(
glm::vec2(res) * global::windowDelegate->dpiScaling()
+2
View File
@@ -46,6 +46,8 @@ public:
void internalInitialize(const ghoul::Dictionary& configuration) override;
static documentation::Documentation Documentation();
private:
void startOrStopGui();
@@ -30,7 +30,7 @@ in vec4 fs_vertexPosition;
uniform vec4 color;
Fragment getFragment(){
Fragment getFragment() {
Fragment frag;
frag.color = color;
frag.depth = fs_vertexPosition.w;
@@ -30,7 +30,7 @@ layout(location = 0) in vec4 vertexPositionClippingSpace;
out vec4 fs_vertexPosition;
void main(){
void main() {
fs_vertexPosition = z_normalization(vertexPositionClippingSpace);
gl_Position = fs_vertexPosition;
}
+4
View File
@@ -225,6 +225,10 @@ namespace openspace {
using namespace exoplanets;
documentation::Documentation ExoplanetsModule::Documentation() {
return codegen::doc<Parameters>("module_exoplanets");
}
ExoplanetsModule::ExoplanetsModule()
: OpenSpaceModule(Name)
, _enabled(EnabledInfo)
+1
View File
@@ -63,6 +63,7 @@ public:
scripting::LuaLibrary luaLibrary() const override;
std::vector<documentation::Documentation> documentations() const override;
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary& dict) override;
@@ -81,7 +81,7 @@ std::shared_ptr<ImageData<T>> FitsFileReader::readImage(const std::filesystem::p
}
// Extension HDU Object
return readImageInternal<T>(_infile->currentExtension());
} catch (const FitsException& e){
} catch (const FitsException& e) {
LERROR("Could not read FITS image from table. " + e.message());
}
@@ -406,7 +406,7 @@ namespace {
std::optional<int> lastRow;
// [codegen::verbatim(ColumnNamesInfo.description)]]
std::optional<std::vector<std::string>> columnNames;
std::optional<ghoul::Dictionary> columnNames;
// [codegen::verbatim(LodPixelThresholdInfo.description)]]
std::optional<float> lodPixelThreshold;
@@ -636,9 +636,7 @@ RenderableGaiaStars::RenderableGaiaStars(const ghoul::Dictionary& dictionary)
addProperty(_lastRow);
if (p.columnNames.has_value()) {
const ghoul::Dictionary tmpDict = dictionary.value<ghoul::Dictionary>(
ColumnNamesInfo.identifier
);
const ghoul::Dictionary tmpDict = *p.columnNames;
// Ugly fix for ASCII sorting when there are more columns read than 10.
std::set<int> intKeys;
+1 -1
View File
@@ -176,7 +176,7 @@ void main() {
// Remove stars without position, happens when VBO chunk is stuffed with zeros.
// Has to be done in Geometry shader because Vertices cannot be discarded here.
if (length(in_position) > EPS){
if (length(in_position) > EPS) {
vs_gPosition = vec4(model * objectPosition);
gl_Position = vec4(projection * viewPosition);
}
+2 -3
View File
@@ -72,7 +72,7 @@ namespace {
// A list of strings with the names of all the additional columns that are to be
// read from the specified FITS file(s). These columns can be used for filtering
// while constructing Octree later
std::optional<std::vector<std::string>> filterColumnNames;
std::optional<ghoul::Dictionary> filterColumnNames;
};
#include "readfitstask_codegen.cpp"
} // namespace
@@ -90,8 +90,7 @@ ReadFitsTask::ReadFitsTask(const ghoul::Dictionary& dictionary) {
_lastRow = p.lastRow.value_or(_lastRow);
if (p.filterColumnNames.has_value()) {
const ghoul::Dictionary d =
dictionary.value<ghoul::Dictionary>(KeyFilterColumnNames);
const ghoul::Dictionary d = *p.filterColumnNames;
// Ugly fix for ASCII sorting when there are more columns read than 10.
std::set<int> intKeys;
+20 -31
View File
@@ -31,35 +31,31 @@
#include <ghoul/misc/dictionary.h>
namespace {
constexpr std::string_view KeyInFilenamePrefix = "InFilenamePrefix";
constexpr std::string_view KeyInFilenameSuffix = "InFilenameSuffix";
constexpr std::string_view KeyInFirstIndex = "InFirstIndex";
constexpr std::string_view KeyInNSlices = "InNSlices";
constexpr std::string_view KeyOutFilename = "OutFilename";
constexpr std::string_view KeyOutDimensions = "OutDimensions";
struct [[codegen::Dictionary(MilkywayConversionTask)]] Parameters {
std::string inFilenamePrefix;
std::string inFilenameSuffix;
int inFirstIndex;
int inNSlices;
std::string outFilename;
glm::ivec3 outDimensions;
};
#include "milkywayconversiontask_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation MilkywayConversionTask::Documentation() {
return codegen::doc<Parameters>("galaxy_milkywayconversiontask");
}
MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary) {
if (dictionary.hasKey(KeyInFilenamePrefix)) {
_inFilenamePrefix = dictionary.value<std::string>(KeyInFilenamePrefix);
}
if (dictionary.hasKey(KeyInFilenameSuffix)) {
_inFilenameSuffix = dictionary.value<std::string>(KeyInFilenameSuffix);
}
if (dictionary.hasKey(KeyInFirstIndex)) {
_inFirstIndex = static_cast<size_t>(dictionary.value<int>(KeyInFirstIndex));
}
if (dictionary.hasKey(KeyInNSlices)) {
_inNSlices = static_cast<size_t>(dictionary.value<int>(KeyInNSlices));
}
if (dictionary.hasKey(KeyOutFilename)) {
_outFilename = dictionary.value<std::string>(KeyOutFilename);
}
if (dictionary.hasKey(KeyOutDimensions)) {
_outDimensions = dictionary.value<glm::ivec3>(KeyOutDimensions);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
_inFilenamePrefix = p.inFilenamePrefix;
_inFilenameSuffix = p.inFilenameSuffix;
_inFirstIndex = p.inFirstIndex;
_inNSlices = p.inNSlices;
_outFilename = p.outFilename;
_outDimensions = p.outDimensions;
}
std::string MilkywayConversionTask::description() {
@@ -99,11 +95,4 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& onProgress) {
rawWriter.write(sampleFunction, onProgress);
}
documentation::Documentation MilkywayConversionTask::Documentation() {
return {
"MilkywayConversionTask",
"galaxy_milkywayconversiontask"
};
}
} // namespace openspace
@@ -197,6 +197,10 @@ namespace {
namespace openspace {
documentation::Documentation GlobeBrowsingModule::Documentation() {
return codegen::doc<Parameters>("module_globebrowsing");
}
GlobeBrowsingModule::GlobeBrowsingModule()
: OpenSpaceModule(Name)
, _tileCacheSizeMB(TileCacheSizeInfo, 1024)
@@ -330,7 +334,6 @@ std::vector<documentation::Documentation> GlobeBrowsingModule::documentations()
return {
globebrowsing::Layer::Documentation(),
globebrowsing::LayerAdjustment::Documentation(),
globebrowsing::LayerManager::Documentation(),
globebrowsing::GlobeTranslation::Documentation(),
globebrowsing::GlobeRotation::Documentation(),
globebrowsing::RenderableGlobe::Documentation(),
@@ -343,7 +346,6 @@ std::vector<documentation::Documentation> GlobeBrowsingModule::documentations()
globebrowsing::TileProviderByDate::Documentation(),
globebrowsing::TileProviderByIndex::Documentation(),
globebrowsing::TileProviderByLevel::Documentation(),
globebrowsing::GeoJsonManager::Documentation(),
globebrowsing::GeoJsonComponent::Documentation(),
globebrowsing::GeoJsonProperties::Documentation(),
GlobeLabelsComponent::Documentation(),
@@ -71,6 +71,7 @@ public:
globebrowsing::cache::MemoryAwareTileCache* tileCache();
scripting::LuaLibrary luaLibrary() const override;
std::vector<documentation::Documentation> documentations() const override;
static documentation::Documentation Documentation();
const globebrowsing::RenderableGlobe* castFocusNodeRenderableToGlobe();
@@ -363,7 +363,7 @@ GeoJsonComponent::GeoJsonComponent(const ghoul::Dictionary& dictionary,
_defaultProperties.pointTexture.onChange([this]() {
const std::filesystem::path texturePath = _defaultProperties.pointTexture.value();
// Not ethat an empty texture is also valid => use default texture from module
// Note that an empty texture is also valid => use default texture from module
if (std::filesystem::is_regular_file(texturePath) || texturePath.empty()) {
_textureIsDirty = true;
}
@@ -378,9 +378,7 @@ GeoJsonComponent::GeoJsonComponent(const ghoul::Dictionary& dictionary,
_defaultProperties.tessellation.enabled.onChange([this]() { _dataIsDirty = true; });
_defaultProperties.tessellation.useLevel.onChange([this]() { _dataIsDirty = true; });
_defaultProperties.tessellation.level.onChange([this]() { _dataIsDirty = true; });
_defaultProperties.tessellation.distance.onChange([this]() {
_dataIsDirty = true;
});
_defaultProperties.tessellation.distance.onChange([this]() { _dataIsDirty = true; });
_forceUpdateHeightData.onChange([this]() {
for (GlobeGeometryFeature& f : _geometryFeatures) {
@@ -36,17 +36,6 @@ namespace {
namespace openspace::globebrowsing {
documentation::Documentation GeoJsonManager::Documentation() {
using namespace documentation;
return {
"GeoJsonManager",
"globebrowsing_geojsonmanager",
"",
{}
};
}
// TODO: Gui name and description
GeoJsonManager::GeoJsonManager() : properties::PropertyOwner({ "GeoJson" }) {}
void GeoJsonManager::initialize(RenderableGlobe* globe) {
@@ -75,13 +64,6 @@ void GeoJsonManager::addGeoJsonLayer(const ghoul::Dictionary& layerDict) {
ZoneScoped;
try {
// Parse dictionary
documentation::testSpecificationAndThrow(
GeoJsonComponent::Documentation(),
layerDict,
"GeoJsonComponent"
);
const std::string identifier = layerDict.value<std::string>("Identifier");
if (hasPropertySubOwner(identifier)) {
LERROR("GeoJson layer with identifier '" + identifier + "' already exists");
@@ -54,16 +54,11 @@ public:
bool isReady() const;
void addGeoJsonLayer(const ghoul::Dictionary& layerDict);
//void addGeoJsonLayer(const std::string& filePath); // TODO: just add from file
void deleteLayer(const std::string& layerIdentifier);
void update();
void render(const RenderData& data);
//void onChange(std::function<void(Layer* l)> callback);
static documentation::Documentation Documentation();
private:
std::vector<std::unique_ptr<GeoJsonComponent>> _geoJsonObjects;
RenderableGlobe* _parentGlobe = nullptr;
+6 -26
View File
@@ -44,7 +44,6 @@ namespace {
constexpr std::string_view KeyName = "Name";
constexpr std::string_view KeyDesc = "Description";
constexpr std::string_view KeyLayerGroupID = "LayerGroupID";
constexpr std::string_view KeyAdjustment = "Adjustment";
constexpr openspace::properties::Property::PropertyInfo TypeInfo = {
"Type",
@@ -158,25 +157,9 @@ namespace {
// Specifies the render settings that should be applied to this layer
std::optional<Settings> settings;
struct LayerAdjustment {
enum class Type {
None,
ChromaKey,
TransferFunction
};
// Specifies the type of the adjustment that is applied
std::optional<Type> type;
// Specifies the chroma key used when selecting 'ChromaKey' for the 'Type'
std::optional<glm::dvec3> chromaKeyColor;
// Specifies the tolerance to match the color to the chroma key when the
// 'ChromaKey' type is selected for the 'Type'
std::optional<double> chromaKeyTolerance;
};
// Parameters that set individual adjustment parameters for this layer
std::optional<LayerAdjustment> adjustment;
std::optional<ghoul::Dictionary> adjustment
[[codegen::reference("globebrowsing_layeradjustment")]];
enum class BlendMode {
Normal,
@@ -211,7 +194,6 @@ Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGrou
, _guiDescription(GuiDescriptionInfo)
, _solidColor(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _layerGroupId(id)
{
const Parameters p = codegen::bake<Parameters>(layerDict);
@@ -265,10 +247,8 @@ Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGrou
p.settings->multiplier.value_or(_renderSettings.multiplier);
_renderSettings.offset = p.settings->offset.value_or(_renderSettings.offset);
}
if (layerDict.hasValue<ghoul::Dictionary>(KeyAdjustment)) {
_layerAdjustment.setValuesFromDictionary(
layerDict.value<ghoul::Dictionary>(KeyAdjustment)
);
if (p.adjustment.has_value()) {
_layerAdjustment.setValuesFromDictionary(*p.adjustment);
}
// Add options to option properties
@@ -530,7 +510,7 @@ void Layer::initializeBasedOnType(layers::Layer::ID id, ghoul::Dictionary initDi
const std::string name = initDict.value<std::string>(KeyName);
LDEBUG("Initializing tile provider for layer: '" + name + "'");
}
_tileProvider = TileProvider::createFromDictionary(id, initDict);
_tileProvider = TileProvider::createFromDictionary(initDict);
break;
case layers::Layer::ID::SolidColor:
if (initDict.hasValue<glm::dvec3>(ColorInfo.identifier)) {
@@ -541,7 +521,7 @@ void Layer::initializeBasedOnType(layers::Layer::ID id, ghoul::Dictionary initDi
}
void Layer::addVisibleProperties() {
switch (type()) {
switch (_typeId) {
// Intentional fall through. Same for all tile layers
case layers::Layer::ID::DefaultTileProvider:
case layers::Layer::ID::SingleImageProvider:
@@ -138,7 +138,7 @@ layers::Adjustment::ID LayerAdjustment::type() const {
}
void LayerAdjustment::addVisibleProperties() {
switch (type()) {
switch (_typeId) {
case layers::Adjustment::ID::None:
break;
case layers::Adjustment::ID::ChromaKey:
-13
View File
@@ -57,19 +57,6 @@ LayerGroup::LayerGroup(layers::Group group)
addProperty(_levelBlendingEnabled);
}
void LayerGroup::setLayersFromDict(const ghoul::Dictionary& dict) {
for (size_t i = 1; i <= dict.size(); i++) {
const ghoul::Dictionary layer = dict.value<ghoul::Dictionary>(std::to_string(i));
try {
addLayer(layer);
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
}
void LayerGroup::initialize() {
ZoneScoped;
-2
View File
@@ -41,8 +41,6 @@ struct TileProvider;
struct LayerGroup : public properties::PropertyOwner {
LayerGroup(layers::Group group);
void setLayersFromDict(const ghoul::Dictionary& dict);
void initialize();
void deinitialize();
+22 -38
View File
@@ -35,54 +35,38 @@
namespace openspace::globebrowsing {
documentation::Documentation LayerManager::Documentation() {
using namespace documentation;
return {
"LayerManager",
"globebrowsing_layermanager",
"",
{
{
"*",
new ReferencingVerifier("globebrowsing_layer"),
Optional::Yes,
"Specifies an individual layer"
}
}
};
}
LayerManager::LayerManager() : properties::PropertyOwner({ "Layers" }) {}
void LayerManager::initialize(const ghoul::Dictionary& layerGroupsDict) {
void LayerManager::initialize(const std::map<layers::Group::ID, ghoul::Dictionary>& dict)
{
ZoneScoped;
// First create empty layer groups in case not all are specified
for (size_t i = 0; i < _layerGroups.size(); i++) {
_layerGroups[i] = std::make_unique<LayerGroup>(layers::Groups[i]);
}
// Create all the layer groups
for (std::string_view group : layerGroupsDict.keys()) {
using namespace layers;
const Group::ID id = ghoul::from_string<Group::ID>(group);
if (id != Group::ID::Unknown) {
const ghoul::Dictionary d = layerGroupsDict.value<ghoul::Dictionary>(group);
_layerGroups[static_cast<int>(id)]->setLayersFromDict(d);
addPropertySubOwner(_layerGroups[i].get());
_layerGroups[i]->initialize();
auto it = dict.find(layers::Groups[i].id);
if (!dict.empty() && it == dict.end()) {
LWARNINGC(
"LayerManager",
std::format("Unknown layer group '{}'", layers::Groups[i].identifier)
);
continue;
}
else {
LWARNINGC("LayerManager", std::format("Unknown layer group '{}'", group));
for (size_t j = 1; j <= dict.size(); j++) {
const ghoul::Dictionary layer =
it->second.value<ghoul::Dictionary>(std::to_string(j));
try {
_layerGroups[i]->addLayer(layer);
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
}
for (const std::unique_ptr<LayerGroup>& layerGroup : _layerGroups) {
addPropertySubOwner(layerGroup.get());
}
for (const std::unique_ptr<LayerGroup>& lg : _layerGroups) {
lg->initialize();
}
}
void LayerManager::deinitialize() {
+1 -3
View File
@@ -52,7 +52,7 @@ public:
LayerManager();
void initialize(const ghoul::Dictionary& layerGroupsDict);
void initialize(const std::map<layers::Group::ID, ghoul::Dictionary>& dict);
void deinitialize();
Layer* addLayer(layers::Group::ID id, const ghoul::Dictionary& layerDict);
@@ -70,8 +70,6 @@ public:
void onChange(const std::function<void(Layer* l)>& callback);
static documentation::Documentation Documentation();
private:
std::array<std::unique_ptr<LayerGroup>, NumLayerGroups> _layerGroups;
};
+18 -13
View File
@@ -294,9 +294,17 @@ namespace {
// [[codegen::verbatim(OrenNayarRoughnessInfo.description)]]
std::optional<float> orenNayarRoughness;
enum class [[codegen::map(openspace::globebrowsing::layers::Group::ID)]] Group {
HeightLayers,
ColorLayers,
Overlays,
NightLayers,
WaterMasks,
};
// A list of layers that should be added to the globe.
std::optional<std::map<std::string, ghoul::Dictionary>> layers
[[codegen::reference("globebrowsing_layermanager")]];
std::optional<std::map<Group, ghoul::Dictionary>> layers
[[codegen::reference("globebrowsing_layer")]];
// Specifies information about planetary labels that can be rendered on the
// object's surface.
@@ -636,16 +644,13 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
setInteractionSphere(boundingSphere());
// Init layer manager
// @TODO (abock, 2021-03-25) The layermanager should be changed to take a
// std::map<std::string, ghoul::Dictionary> instead and then we don't need to get it
// as a bare dictionary anymore and can use the value from the struct directly
if (dictionary.hasValue<ghoul::Dictionary>("Layers")) {
const ghoul::Dictionary dict = dictionary.value<ghoul::Dictionary>("Layers");
_layerManager.initialize(dict);
}
else {
_layerManager.initialize(ghoul::Dictionary());
std::map<layers::Group::ID, ghoul::Dictionary> layers;
if (p.layers.has_value()) {
for (const auto& [key, value] : *p.layers) {
layers[codegen::map<layers::Group::ID>(key)] = value;
}
}
_layerManager.initialize(layers);
addProperty(Fadeable::_opacity);
@@ -764,14 +769,14 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
// Components
if (p.rings.has_value()) {
_ringsComponent = std::make_unique<RingsComponent>(dictionary);
_ringsComponent = std::make_unique<RingsComponent>(*p.rings);
_ringsComponent->setParentFadeable(this);
_ringsComponent->initialize();
addPropertySubOwner(_ringsComponent.get());
}
if (p.shadows.has_value()) {
_shadowComponent = std::make_unique<ShadowComponent>(dictionary);
_shadowComponent = std::make_unique<ShadowComponent>(*p.shadows);
_shadowComponent->initialize();
addPropertySubOwner(_shadowComponent.get());
_shadowMappingProperties.shadowMapping = true;
+9 -21
View File
@@ -223,29 +223,17 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary)
, _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f)
, _colorFilter(ColorFilterInfo, 0.15f, 0.f, 1.f)
, _enabled(EnabledInfo, true)
, _zFightingPercentage(ZFightingPercentageInfo, 0.995f, 0.000001f, 1.f)
, _zFightingPercentage(ZFightingPercentageInfo, 0.95f, 0.000001f, 1.f)
, _nShadowSamples(NumberShadowSamplesInfo, 2, 1, 7)
// @TODO (abock, 2019-12-16) It would be better to not store the dictionary long
// term and rather extract the values directly here. This would require a bit of
// a rewrite in the RenderableGlobe class to not create the RingsComponent in the
// class-initializer list though
// @TODO (abock, 2021-03-25) Righto! The RenderableGlobe passes this dictionary
// in as-is so it would be easy to just pass it directly to the initialize method
// instead
, _ringsDictionary(dictionary)
{
using ghoul::filesystem::File;
if (dictionary.hasValue<ghoul::Dictionary>("Rings")) {
// @TODO (abock, 2019-12-16) It would be better to not store the dictionary long
// term and rather extract the values directly here. This would require a bit of
// a rewrite in the RenderableGlobe class to not create the RingsComponent in the
// class-initializer list though
// @TODO (abock, 2021-03-25) Righto! The RenderableGlobe passes this dictionary
// in as-is so it would be easy to just pass it directly to the initialize method
// instead
_ringsDictionary = dictionary.value<ghoul::Dictionary>("Rings");
documentation::testSpecificationAndThrow(
Documentation(),
_ringsDictionary,
"RingsComponent"
);
}
}
{}
void RingsComponent::initialize() {
ZoneScoped;
@@ -186,12 +186,7 @@ ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary)
// coded into the RenderableGlobe. Instead, the parent should unpack the dictionary
// and pass the unpacked dictionary in here; Or maybe we don't want a dictionary at
// this state anyway?
if (!dictionary.hasValue<ghoul::Dictionary>("Shadows")) {
return;
}
const ghoul::Dictionary d = dictionary.value<ghoul::Dictionary>("Shadows");
const Parameters p = codegen::bake<Parameters>(d);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_enabled);
@@ -70,11 +70,16 @@ Tile DefaultTile = Tile { nullptr, std::nullopt, Tile::Status::Unavailable };
unsigned int TileProvider::NumTileProviders = 0;
std::unique_ptr<TileProvider> TileProvider::createFromDictionary(
layers::Layer::ID layerTypeID,
const ghoul::Dictionary& dictionary)
{
ZoneScoped;
layers::Layer::ID layerTypeID = layers::Layer::ID::DefaultTileProvider;
if (dictionary.hasValue<std::string>("Type")) {
const std::string type = dictionary.value<std::string>("Type");
layerTypeID = ghoul::from_string<layers::Layer::ID>(type);
}
const std::string_view type =
layers::Layers[static_cast<int>(layerTypeID)].identifier;
@@ -75,7 +75,7 @@ struct TileProvider : public properties::PropertyOwner {
static unsigned int NumTileProviders;
static std::unique_ptr<TileProvider> createFromDictionary(
layers::Layer::ID layerTypeID, const ghoul::Dictionary& dictionary);
const ghoul::Dictionary& dictionary);
static void initializeDefaultTile();
static void deinitializeDefaultTile();
@@ -32,6 +32,12 @@
namespace {
struct [[codegen::Dictionary(TileProviderByDate)]] Parameters {
// The layer needs to know about the LayerGroupID this but we don't want it to be
// part of the parameters struct as that would mean it would be visible to the end
// user, which we don't want since this value just comes from whoever creates it,
// not the user.
int layerGroupID [[codegen::private()]];
// Specifies the list of tile providers and for which times they are used for. The
// tile provider with the earliest time will be used for all dates prior to that
// date and the provider with the latest time will be used for all dates
@@ -53,16 +59,8 @@ TileProviderByDate::TileProviderByDate(const ghoul::Dictionary& dictionary) {
Parameters p = codegen::bake<Parameters>(dictionary);
// For now we need to inject the LayerGroupID this way. We don't want it to be part of
// the parameters struct as that would mean it would be visible to the end user, which
// we don't want since this value just comes from whoever creates it, not the user
ghoul_assert(dictionary.hasValue<int>("LayerGroupID"), "No Layer Group ID provided");
const layers::Group::ID group = static_cast<layers::Group::ID>(
dictionary.value<int>("LayerGroupID")
);
for (std::pair<const std::string, ghoul::Dictionary>& prov : p.providers) {
prov.second.setValue("LayerGroupID", static_cast<int>(group));
prov.second.setValue("LayerGroupID", p.layerGroupID);
// Pass down the caching information from the enclosing dictionary
if (dictionary.hasValue<std::string>("GlobeName")) {
@@ -70,12 +68,7 @@ TileProviderByDate::TileProviderByDate(const ghoul::Dictionary& dictionary) {
}
layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider;
if (prov.second.hasValue<std::string>("Type")) {
const std::string type = prov.second.value<std::string>("Type");
typeID = ghoul::from_string<layers::Layer::ID>(type);
}
std::unique_ptr<TileProvider> tp = createFromDictionary(typeID, prov.second);
std::unique_ptr<TileProvider> tp = createFromDictionary(prov.second);
const std::string provId = prov.second.value<std::string>("Identifier");
tp->setIdentifier(provId);
const std::string providerName = prov.second.value<std::string>("Name");
@@ -71,6 +71,12 @@ namespace {
// The list of all TileProviders and the indices at which they are used.
std::vector<IndexProvider> tileProviders;
// The layer needs to know about the LayerGroupID this but we don't want it to be
// part of the parameters struct as that would mean it would be visible to the end
// user, which we don't want since this value just comes from whoever creates it,
// not the user.
int layerGroupID [[codegen::private()]];
};
#include "tileproviderbyindex_codegen.cpp"
} // namespace
@@ -86,22 +92,8 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) {
Parameters p = codegen::bake<Parameters>(dictionary);
// For now we need to inject the LayerGroupID this way. We don't want it to be part of
// the parameters struct as that would mean it would be visible to the end user, which
// we don't want since this value just comes from whoever creates it, not the user
ghoul_assert(dictionary.hasValue<int>("LayerGroupID"), "No Layer Group ID provided");
const layers::Group::ID group = static_cast<layers::Group::ID>(
dictionary.value<int>("LayerGroupID")
);
layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider;
if (p.defaultTileProvider.hasValue<std::string>("Type")) {
const std::string type = p.defaultTileProvider.value<std::string>("Type");
typeID = ghoul::from_string<layers::Layer::ID>(type);
}
p.defaultTileProvider.setValue("LayerGroupID", static_cast<int>(group));
_defaultTileProvider = createFromDictionary(typeID, p.defaultTileProvider);
p.defaultTileProvider.setValue("LayerGroupID", p.layerGroupID);
_defaultTileProvider = createFromDictionary(p.defaultTileProvider);
for (Parameters::IndexProvider& ip : p.tileProviders) {
const TileIndex tileIndex = TileIndex(
@@ -110,17 +102,9 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) {
static_cast<uint8_t>(ip.index.level)
);
layers::Layer::ID providerID = layers::Layer::ID::DefaultTileProvider;
if (ip.tileProvider.hasValue<std::string>("Type")) {
const std::string type = ip.tileProvider.value<std::string>("Type");
providerID = ghoul::from_string<layers::Layer::ID>(type);
}
ip.tileProvider.setValue("LayerGroupID", static_cast<int>(group));
std::unique_ptr<TileProvider> stp = createFromDictionary(
providerID,
ip.tileProvider
);
ip.tileProvider.setValue("LayerGroupID", p.layerGroupID);
std::unique_ptr<TileProvider> stp = createFromDictionary(ip.tileProvider);
const TileIndex::TileHashKey key = tileIndex.hashKey();
_providers.emplace(key, std::move(stp));
}
@@ -50,6 +50,12 @@ namespace {
// The list of all tile providers that are used by this TileProviderByLevel.
std::vector<Provider> levelTileProviders;
// The layer needs to know about the LayerGroupID this but we don't want it to be
// part of the parameters struct as that would mean it would be visible to the end
// user, which we don't want since this value just comes from whoever creates it,
// not the user.
int layerGroupID [[codegen::private()]];
};
#include "tileproviderbylevel_codegen.cpp"
} // namespace
@@ -65,17 +71,9 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
const Parameters p = codegen::bake<Parameters>(dictionary);
// For now we need to inject the LayerGroupID this way. We don't want it to be part of
// the parameters struct as that would mean it would be visible to the end user, which
// we don't want since this value just comes from whoever creates it, not the user
ghoul_assert(dictionary.hasValue<int>("LayerGroupID"), "No Layer Group ID provided");
const layers::Group::ID group = static_cast<layers::Group::ID>(
dictionary.value<int>("LayerGroupID")
);
for (Parameters::Provider provider : p.levelTileProviders) {
ghoul::Dictionary& tileProviderDict = provider.tileProvider;
tileProviderDict.setValue("LayerGroupID", static_cast<int>(group));
tileProviderDict.setValue("LayerGroupID", p.layerGroupID);
// Pass down the caching information from the enclosing dictionary
if (dictionary.hasValue<std::string>("GlobeName")) {
@@ -84,13 +82,8 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
dictionary.value<std::string>("GlobeName")
);
}
layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider;
if (tileProviderDict.hasValue<std::string>("Type")) {
const std::string type = tileProviderDict.value<std::string>("Type");
typeID = ghoul::from_string<layers::Layer::ID>(type);
}
std::unique_ptr<TileProvider> tp = createFromDictionary(typeID, tileProviderDict);
std::unique_ptr<TileProvider> tp = createFromDictionary(tileProviderDict);
const std::string provId = tileProviderDict.value<std::string>("Identifier");
tp->setIdentifier(provId);
+2 -5
View File
@@ -420,12 +420,9 @@ void GuiSpaceTimeComponent::render() {
if (_slidingDelta != 0.f) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
const std::string script = std::format(
global::scriptEngine->queueScript(std::format(
"openspace.time.setDeltaTime({})", _oldDeltaTime
);
using Script = scripting::ScriptEngine::Script;
global::scriptEngine->queueScript(script);
));
}
_slidingDelta = 0.f;
+1 -1
View File
@@ -144,7 +144,7 @@ void DataPlane::setUniforms() {
_shader->setUniform("transparency", _alpha);
}
std::vector<float*> DataPlane::textureData(){
std::vector<float*> DataPlane::textureData() {
// if the buffer in the datafile is empty, do not proceed
if (_dataBuffer.empty()) {
return std::vector<float*>();
+2 -2
View File
@@ -172,8 +172,8 @@ void IswaCygnet::render(const RenderData& data, RendererTasks&) {
}
glm::mat4 transform = glm::mat4(1.f);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
+2 -2
View File
@@ -553,7 +553,7 @@ void IswaManager::createSphere(MetadataFuture& data) {
// check if this sphere already exist
std::string name = _type[data.type] + _geom[data.geom] + std::to_string(data.id);
if (!data.group.empty()){
if (!data.group.empty()) {
std::string type = typeid(DataSphere).name();
registerGroup(data.group, type);
@@ -693,7 +693,7 @@ void IswaManager::addCdfFiles(std::string cdfpath) {
if (jsonFile.is_open()) {
nlohmann::json cdfGroups = nlohmann::json::parse(jsonFile);
for(size_t i = 0; i < cdfGroups.size(); i++) {
for (size_t i = 0; i < cdfGroups.size(); i++) {
nlohmann::json cdfGroup = cdfGroups.at(i);
std::string groupName = cdfGroup["group"];
+1 -1
View File
@@ -78,7 +78,7 @@ double getTime(ccmc::Kameleon* kameleon, double manualOffset) {
// redundant!
std::string seqStartStr;
if (kameleon->doesAttributeExist("start_time")){
if (kameleon->doesAttributeExist("start_time")) {
seqStartStr =
kameleon->getGlobalAttribute("start_time").getAttributeString();
}
+2 -2
View File
@@ -303,7 +303,7 @@ float* KameleonWrapper::uniformSampledValues(const std::string& var,
const double dist = ((varMax - varMin) / NBins) * stop;
const double varMaxNew = varMin + dist;
for(size_t i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
const double normalizedVal = (doubleData[i] - varMin) / (varMaxNew - varMin);
data[i] = static_cast<float>(glm::clamp(normalizedVal, 0.0, 1.0));
@@ -362,7 +362,7 @@ float* KameleonWrapper::uniformSliceValues(const std::string& var,
for (size_t x = 0; x < outDimensions.x; ++x) {
for (size_t y = 0; y < outDimensions.y; ++y) {
for(size_t z = 0; z < outDimensions.z; ++z){
for (size_t z = 0; z < outDimensions.z; ++z) {
const float xi = (hasXSlice) ? slice : x;
const float yi = (hasYSlice) ? slice : y;
@@ -27,7 +27,6 @@
#include <modules/volume/rendering/basicvolumeraycaster.h>
#include <modules/volume/rawvolume.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/rendering/transferfunction.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <modules/kameleonvolume/kameleonvolumereader.h>
#include <modules/volume/rawvolumereader.h>
@@ -37,8 +36,10 @@
#include <modules/volume/transferfunctionhandler.h>
#include <modules/volume/volumegridtype.h>
#include <openspace/engine/globals.h>
#include <openspace/documentation/documentation.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/raycastermanager.h>
#include <openspace/rendering/transferfunction.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/file.h>
@@ -50,21 +51,6 @@
namespace {
constexpr std::string_view _loggerCat = "RenderableKameleonVolume";
constexpr std::string_view KeyDimensions = "Dimensions";
constexpr std::string_view KeyStepSize = "StepSize";
constexpr std::string_view KeyTransferFunction = "TransferFunction";
constexpr std::string_view KeySource = "Source";
constexpr std::string_view KeyVariable = "Variable";
constexpr std::string_view KeyLowerDomainBound = "LowerDomainBound";
constexpr std::string_view KeyUpperDomainBound = "UpperDomainBound";
constexpr std::string_view KeyDomainScale = "DomainScale";
constexpr std::string_view KeyLowerValueBound = "LowerValueBound";
constexpr std::string_view KeyUpperValueBound = "UpperValueBound";
constexpr std::string_view KeyClipPlanes = "ClipPlanes";
constexpr std::string_view KeyCache = "Cache";
constexpr std::string_view KeyGridType = "GridType";
constexpr std::string_view ValueSphericalGridType = "Spherical";
constexpr openspace::properties::Property::PropertyInfo DimensionsInfo = {
"Dimensions",
"Dimensions",
@@ -148,6 +134,50 @@ namespace {
"", // @TODO Missing documentation
openspace::properties::Property::Visibility::Developer
};
struct [[codegen::Dictionary(RenderableKameleonVolume)]] Parameters {
// [[codegen::verbatim(DimensionsInfo.description)]]
glm::ivec3 dimensions [[codegen::greater(glm::ivec3(0))]];
// [[codegen::verbatim(StepSizeInfo.description)]]
float stepSize;
// [[codegen::verbatim(TransferFunctionInfo.description)]]
std::optional<std::filesystem::path> transferFunction;
// [[codegen::verbatim(SourcePathInfo.description)]]
std::optional<std::filesystem::path> source;
// [[codegen::verbatim(VariableInfo.description)]]
std::optional<std::string> variable;
// [[codegen::verbatim(LowerDomainBoundInfo.description)]]
std::optional<glm::vec3> lowerDomainBound;
// [[codegen::verbatim(UpperDomainBoundInfo.description)]]
std::optional<glm::vec3> upperDomainBound;
// [[codegen::verbatim(DomainScaleInfo.description)]]
std::optional<glm::vec3> domainScale;
// [[codegen::verbatim(LowerValueBoundInfo.description)]]
std::optional<float> lowerValueBound;
// [[codegen::verbatim(UpperValueBoundInfo.description)]]
std::optional<float> upperValueBound;
std::optional<ghoul::Dictionary> clipPlanes;
// [[codegen::verbatim(CacheInfo.description)]]
std::optional<bool> cache;
enum class GridType {
Cartesian,
Spherical
};
std::optional<GridType> gridType;
};
#include "renderablekameleonvolume_codegen.cpp"
} // namespace
namespace openspace::kameleonvolume {
@@ -167,78 +197,42 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict
, _transferFunctionPath(TransferFunctionInfo)
, _cache(CacheInfo)
{
if (dictionary.hasValue<glm::dvec3>(KeyDimensions)) {
_dimensions = dictionary.value<glm::dvec3>(KeyDimensions);
}
else {
LWARNING("No dimensions specified for volumetric data, falling back to 32^3");
_dimensions = glm::uvec3(32);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
_stepSize = static_cast<float>(dictionary.value<double>(KeyStepSize));
_dimensions = p.dimensions;
_stepSize = p.stepSize;
if (dictionary.hasValue<std::string>(KeyTransferFunction)) {
_transferFunctionPath = dictionary.value<std::string>(KeyTransferFunction);
if (p.transferFunction.has_value()) {
_transferFunctionPath = p.transferFunction->string();
_transferFunction = std::make_shared<openspace::TransferFunction>(
_transferFunctionPath.value()
);
}
if (dictionary.hasValue<std::string>(KeySource)) {
_sourcePath = absPath(dictionary.value<std::string>(KeySource)).string();
if (p.source.has_value()) {
_sourcePath = p.source->string();
}
if (dictionary.hasValue<std::string>(KeyVariable)) {
_variable = dictionary.value<std::string>(KeyVariable);
}
_variable = p.variable.value_or(_variable);
_lowerDomainBound = p.lowerDomainBound.value_or(_lowerDomainBound);
_upperDomainBound = p.upperDomainBound.value_or(_upperDomainBound);
_autoDomainBounds =
!p.lowerDomainBound.has_value() || !p.upperDomainBound.has_value();
if (dictionary.hasValue<glm::dvec3>(KeyLowerDomainBound)) {
_lowerDomainBound = dictionary.value<glm::dvec3>(KeyLowerDomainBound);
}
else {
_autoDomainBounds = true;
}
_domainScale = p.domainScale.value_or(_domainScale);
if (dictionary.hasValue<glm::dvec3>(KeyUpperDomainBound)) {
_upperDomainBound = dictionary.value<glm::dvec3>(KeyUpperDomainBound);
}
else {
_autoDomainBounds = true;
}
_lowerValueBound = p.lowerValueBound.value_or(_lowerValueBound);
_upperValueBound = p.upperValueBound.value_or(_upperValueBound);
_autoValueBounds = !p.lowerValueBound.has_value() || !p.upperValueBound.has_value();
if (dictionary.hasValue<glm::dvec3>(KeyDomainScale)) {
_domainScale = dictionary.value<glm::dvec3>(KeyDomainScale);
}
if (dictionary.hasValue<double>(KeyLowerValueBound)) {
_lowerValueBound = static_cast<float>(
dictionary.value<double>(KeyLowerValueBound)
);
}
else {
_autoValueBounds = true;
}
if (dictionary.hasValue<double>(KeyUpperValueBound)) {
_upperValueBound = static_cast<float>(
dictionary.value<double>(KeyUpperValueBound)
);
}
else {
_autoValueBounds = true;
}
ghoul::Dictionary clipPlanesDictionary;
if (dictionary.hasValue<ghoul::Dictionary>(KeyClipPlanes)) {
clipPlanesDictionary = dictionary.value<ghoul::Dictionary>(KeyClipPlanes);
}
_clipPlanes = std::make_shared<volume::VolumeClipPlanes>(clipPlanesDictionary);
_clipPlanes = std::make_shared<volume::VolumeClipPlanes>(
p.clipPlanes.value_or(ghoul::Dictionary())
);
_clipPlanes->setIdentifier("clipPlanes");
_clipPlanes->setGuiName("Clip Planes");
if (dictionary.hasValue<bool>(KeyCache)) {
_cache = dictionary.value<bool>(KeyCache);
}
_cache = p.cache.value_or(_cache);
_gridType.addOption(
static_cast<int>(volume::VolumeGridType::Cartesian),
@@ -248,17 +242,17 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict
static_cast<int>(volume::VolumeGridType::Spherical),
"Spherical grid"
);
_gridType.setValue(static_cast<int>(volume::VolumeGridType::Cartesian));
if (dictionary.hasValue<std::string>(KeyGridType)) {
const std::string& gridType = dictionary.value<std::string>(KeyGridType);
if (gridType == ValueSphericalGridType) {
Parameters::GridType type = p.gridType.value_or(Parameters::GridType::Cartesian);
switch (type) {
case Parameters::GridType::Cartesian:
_gridType.setValue(static_cast<int>(volume::VolumeGridType::Cartesian));
break;
case Parameters::GridType::Spherical:
_gridType.setValue(static_cast<int>(volume::VolumeGridType::Spherical));
}
else {
_autoGridType = true;
}
break;
}
_autoGridType = !p.gridType.has_value();
}
RenderableKameleonVolume::~RenderableKameleonVolume() {}
@@ -35,6 +35,7 @@
#include <modules/multiresvolume/rendering/simpletfbrickselector.h>
#include <modules/multiresvolume/rendering/tfbrickselector.h>
#include <modules/multiresvolume/rendering/tsp.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/raycastermanager.h>
@@ -60,13 +61,6 @@
namespace {
constexpr std::string_view _loggerCat = "RenderableMultiresVolume";
constexpr std::string_view KeyDataSource = "Source";
constexpr std::string_view KeyErrorHistogramsSource = "ErrorHistogramsSource";
constexpr std::string_view KeyTransferFunction = "TransferFunction";
constexpr std::string_view KeyBrickSelector = "BrickSelector";
constexpr std::string_view KeyStartTime = "StartTime";
constexpr std::string_view KeyEndTime = "EndTime";
constexpr openspace::properties::Property::PropertyInfo StepSizeCoefficientInfo = {
"StepSizeCoefficient",
@@ -158,6 +152,24 @@ namespace {
"", // @TODO Missing documentation
openspace::properties::Property::Visibility::Developer
};
struct [[codegen::Dictionary(RenderableMultiresVolume)]] Parameters {
std::filesystem::path source;
std::optional<std::filesystem::path> errorHistogramsSource;
std::optional<int> scalingExponent;
std::optional<float> stepSizeCoefficient;
std::optional<glm::vec3> scaling;
std::optional<glm::vec3> translation;
std::optional<glm::vec3> rotation;
std::optional<std::string> startTime;
std::optional<std::string> endTime;
std::filesystem::path transferFunction;
std::optional<std::string> brickSelector;
};
#include "renderablemultiresvolume_codegen.cpp"
} // namespace
namespace openspace {
@@ -183,49 +195,19 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict
)
, _scaling(ScalingInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(10.f))
{
if (dictionary.hasValue<std::string>(KeyDataSource)) {
_filename = absPath(dictionary.value<std::string>(KeyDataSource));
}
else {
LERROR(std::format("Node did not contain a valid '{}'", KeyDataSource));
return;
}
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasValue<std::string>(KeyErrorHistogramsSource)) {
_errorHistogramsPath = absPath(
dictionary.value<std::string>(KeyErrorHistogramsSource)
);
}
_filename = p.source;
_errorHistogramsPath = p.errorHistogramsSource.value_or(_errorHistogramsPath);
_scalingExponent = p.scalingExponent.value_or(_scalingExponent);
_stepSizeCoefficient = p.stepSizeCoefficient.value_or(_stepSizeCoefficient);
_scaling = p.scaling.value_or(_scaling);
_translation = p.translation.value_or(_translation);
_rotation = p.rotation.value_or(_rotation);
if (dictionary.hasValue<double>("ScalingExponent")) {
_scalingExponent = static_cast<int>(dictionary.value<double>("ScalingExponent"));
}
if (dictionary.hasValue<double>("StepSizeCoefficient")) {
_stepSizeCoefficient = static_cast<float>(
dictionary.value<double>("StepSizeCoefficient")
);
}
if (dictionary.hasValue<glm::dvec3>("Scaling")) {
_scaling = dictionary.value<glm::dvec3>("Scaling");
}
if (dictionary.hasValue<glm::dvec3>("Translation")) {
_translation = dictionary.value<glm::dvec3>("Translation");
}
if (dictionary.hasValue<glm::dvec3>("Rotation")) {
_rotation = dictionary.value<glm::dvec3>("Rotation");
}
if (dictionary.hasValue<std::string>(KeyStartTime) &&
dictionary.hasValue<std::string>(KeyEndTime))
{
std::string startTimeString = dictionary.value<std::string>(KeyStartTime);
std::string endTimeString = dictionary.value<std::string>(KeyEndTime);
_startTime = SpiceManager::ref().ephemerisTimeFromDate(startTimeString);
_endTime = SpiceManager::ref().ephemerisTimeFromDate(endTimeString);
if (p.startTime.has_value() && p.endTime.has_value()) {
_startTime = SpiceManager::ref().ephemerisTimeFromDate(*p.startTime);
_endTime = SpiceManager::ref().ephemerisTimeFromDate(*p.endTime);
_loop = false;
}
else {
@@ -233,44 +215,13 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict
LWARNING("Node does not provide time information. Viewing one image / frame");
}
if (dictionary.hasValue<std::string>(KeyTransferFunction)) {
_transferFunctionPath = absPath(
dictionary.value<std::string>(KeyTransferFunction)
);
_transferFunction = std::make_shared<TransferFunction>(_transferFunctionPath);
}
else {
LERROR(std::format("Node did not contain a valid '{}'", KeyTransferFunction));
return;
}
//_pscOffset = psc(glm::vec4(0.f));
//_boxScaling = glm::vec3(1.f);
/*if (dictionary.hasKey(KeyBoxScaling)) {
glm::vec4 scalingVec4(_boxScaling, _w);
success = dictionary.getValue(KeyBoxScaling, scalingVec4);
if (success) {
_boxScaling = scalingVec4.xyz;
_w = scalingVec4.w;
}
else {
success = dictionary.getValue(KeyBoxScaling, _boxScaling);
if (!success) {
LERROR("Node '" << name << "' did not contain a valid '" <<
KeyBoxScaling << "'");
return;
}
}
}*/
_transferFunctionPath = p.transferFunction;
_transferFunction = std::make_shared<TransferFunction>(_transferFunctionPath);
_tsp = std::make_shared<TSP>(_filename);
_atlasManager = std::make_shared<AtlasManager>(_tsp.get());
if (dictionary.hasValue<std::string>(KeyBrickSelector)) {
_selectorName = dictionary.value<std::string>(KeyBrickSelector);
}
_selectorName = p.brickSelector.value_or(_selectorName);
std::string selectorName = _selectorName;
if (selectorName == "simple") {
+18 -20
View File
@@ -28,6 +28,7 @@
#include <modules/server/include/serverinterface.h>
#include <modules/server/include/connection.h>
#include <modules/server/include/topics/topic.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globalscallbacks.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/windowdelegate.h>
@@ -41,11 +42,20 @@
#include <ghoul/misc/templatefactory.h>
namespace {
constexpr std::string_view KeyInterfaces = "Interfaces";
struct [[codegen::Dictionary(ServerModule)]] Parameters {
std::optional<ghoul::Dictionary> interfaces;
std::optional<std::vector<std::string>> allowAddresses;
std::optional<int> skyBrowserUpdateTime;
};
#include "servermodule_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation ServerModule::Documentation() {
return codegen::doc<Parameters>("module_server");
}
ServerModule::ServerModule()
: OpenSpaceModule(ServerModule::Name)
, _interfaceOwner({"Interfaces", "Interfaces", "Server Interfaces"})
@@ -93,26 +103,17 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
preSync();
});
if (!configuration.hasValue<ghoul::Dictionary>(KeyInterfaces)) {
const Parameters p = codegen::bake<Parameters>(configuration);
if (!p.interfaces.has_value()) {
return;
}
const ghoul::Dictionary interfaces =
configuration.value<ghoul::Dictionary>(KeyInterfaces);
for (const std::string_view key : interfaces.keys()) {
ghoul::Dictionary interfaceDictionary = interfaces.value<ghoul::Dictionary>(key);
// @TODO (abock, 2019-09-17); This is a hack to make the parsing of the
// openspace.cfg file not corrupt the heap and cause a potential crash at shutdown
// (see ticket https://github.com/OpenSpace/OpenSpace/issues/982)
// The AllowAddresses are specified externally and are injected here
interfaceDictionary.setValue(
"AllowAddresses",
configuration.value<ghoul::Dictionary>("AllowAddresses")
);
for (const std::string_view key : p.interfaces->keys()) {
ghoul::Dictionary interface = p.interfaces->value<ghoul::Dictionary>(key);
std::unique_ptr<ServerInterface> serverInterface =
ServerInterface::createFromDictionary(interfaceDictionary);
ServerInterface::createFromDictionary(interface);
serverInterface->initialize();
@@ -122,11 +123,8 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
_interfaces.push_back(std::move(serverInterface));
}
}
if (configuration.hasValue<double>("SkyBrowserUpdateTime")) {
_skyBrowserUpdateTime = static_cast<int>(
configuration.value<double>("SkyBrowserUpdateTime")
);
}
_skyBrowserUpdateTime = p.skyBrowserUpdateTime.value_or(_skyBrowserUpdateTime);
}
void ServerModule::preSync() {
+2
View File
@@ -62,6 +62,8 @@ public:
CallbackHandle addPreSyncCallback(CallbackFunction cb);
void removePreSyncCallback(CallbackHandle handle);
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary& configuration) override;
+81 -64
View File
@@ -23,20 +23,14 @@
****************************************************************************************/
#include <modules/server/include/serverinterface.h>
#include <ghoul/io/socket/socketserver.h>
#include <openspace/documentation/documentation.h>
#include <ghoul/io/socket/socketserver.h>
#include <ghoul/io/socket/tcpsocketserver.h>
#include <ghoul/io/socket/websocketserver.h>
#include <functional>
namespace {
constexpr std::string_view KeyIdentifier = "Identifier";
constexpr std::string_view TcpSocketType = "TcpSocket";
constexpr std::string_view WebSocketType = "WebSocket";
constexpr std::string_view DenyAccess = "Deny";
constexpr std::string_view RequirePassword = "RequirePassword";
constexpr std::string_view AllowAccess = "Allow";
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
"Enabled",
"Enabled",
@@ -94,6 +88,45 @@ namespace {
"Password for connecting to this interface.",
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(ServerInterface)]] Parameters {
enum class [[codegen::stringify()]] Access {
Allow,
Deny,
RequirePassword
};
// [[codegen::verbatim(DefaultAccessInfo.description)]]
std::optional<Access> defaultAccess;
std::string identifier;
// [[codegen::verbatim(AllowAddressesInfo.description)]]
std::optional<std::vector<std::string>> allowAddresses;
// [[codegen::verbatim(DenyAddressesInfo.description)]]
std::optional<std::vector<std::string>> denyAddresses;
// [[codegen::verbatim(RequirePasswordAddressesInfo.description)]]
std::optional<std::vector<std::string>> requirePasswordAddresses;
enum class [[codegen::stringify()]] Type {
TcpSocket,
WebSocket
};
// [[codegen::verbatim(TypeInfo.description)]]
Type type;
// [[codegen::verbatim(PasswordInfo.description)]]
std::optional<std::string> password;
// [[codegen::verbatim(PortInfo.description)]]
int port;
// [[codegen::verbatim(EnabledInfo.description)]]
bool enabled;
};
#include "serverinterface_codegen.cpp"
} // namespace
namespace openspace {
@@ -117,80 +150,65 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& dictionary)
, _defaultAccess(DefaultAccessInfo)
, _password(PasswordInfo)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_socketType.addOption(
static_cast<int>(InterfaceType::TcpSocket),
std::string(TcpSocketType)
"TcpSocket"
);
_socketType.addOption(
static_cast<int>(InterfaceType::WebSocket),
std::string(WebSocketType)
"WebSocket"
);
_defaultAccess.addOption(
static_cast<int>(Access::Deny),
std::string(DenyAccess)
"Deny"
);
_defaultAccess.addOption(
static_cast<int>(Access::RequirePassword),
std::string(RequirePassword)
"RequirePassword"
);
_defaultAccess.addOption(
static_cast<int>(Access::Allow),
std::string(AllowAccess)
"Allow"
);
if (dictionary.hasKey(DefaultAccessInfo.identifier)) {
const std::string access = dictionary.value<std::string>(
DefaultAccessInfo.identifier
);
if (access == DenyAccess) {
_defaultAccess.setValue(static_cast<int>(Access::Deny));
}
else if (access == RequirePassword) {
_defaultAccess.setValue(static_cast<int>(Access::RequirePassword));
}
else if (access == AllowAccess) {
_defaultAccess.setValue(static_cast<int>(Access::Allow));
if (p.defaultAccess.has_value()) {
switch (*p.defaultAccess) {
case Parameters::Access::Allow:
_defaultAccess.setValue(static_cast<int>(Access::Allow));
break;
case Parameters::Access::Deny:
_defaultAccess.setValue(static_cast<int>(Access::Deny));
break;
case Parameters::Access::RequirePassword:
_defaultAccess.setValue(static_cast<int>(Access::RequirePassword));
break;
}
}
const std::string identifier = dictionary.value<std::string>(KeyIdentifier);
_allowAddresses = p.allowAddresses.value_or(_allowAddresses);
_denyAddresses = p.denyAddresses.value_or(_denyAddresses);
_requirePasswordAddresses =
p.requirePasswordAddresses.value_or(_requirePasswordAddresses);
auto readList =
[dictionary](const std::string& key, properties::StringListProperty& list) {
if (dictionary.hasValue<ghoul::Dictionary>(key)) {
const ghoul::Dictionary& dict = dictionary.value<ghoul::Dictionary>(key);
std::vector<std::string> v;
for (const std::string_view k : dict.keys()) {
v.push_back(dict.value<std::string>(k));
}
list = v;
}
};
setIdentifier(p.identifier);
setGuiName(p.identifier);
setDescription("Settings for server interface " + p.identifier);
readList(AllowAddressesInfo.identifier, _allowAddresses);
readList(DenyAddressesInfo.identifier, _denyAddresses);
readList(RequirePasswordAddressesInfo.identifier, _requirePasswordAddresses);
setIdentifier(identifier);
setGuiName(identifier);
setDescription("Settings for server interface " + identifier);
const std::string type = dictionary.value<std::string>(TypeInfo.identifier);
if (type == TcpSocketType) {
_socketType = static_cast<int>(InterfaceType::TcpSocket);
}
else if (type == WebSocketType) {
_socketType = static_cast<int>(InterfaceType::WebSocket);
switch (p.type) {
case Parameters::Type::TcpSocket:
_socketType = static_cast<int>(InterfaceType::TcpSocket);
break;
case Parameters::Type::WebSocket:
_socketType = static_cast<int>(InterfaceType::WebSocket);
break;
}
if (dictionary.hasValue<std::string>(PasswordInfo.identifier)) {
_password = dictionary.value<std::string>(PasswordInfo.identifier);
}
_port = static_cast<int>(dictionary.value<double>(PortInfo.identifier));
_enabled = dictionary.value<bool>(EnabledInfo.identifier);
_password = p.password.value_or(_password);
_port = p.port;
_enabled = p.enabled;
auto reinitialize = [this]() {
deinitialize();
@@ -198,19 +216,18 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& dictionary)
};
_socketType.onChange(reinitialize);
_port.onChange(reinitialize);
_enabled.onChange(reinitialize);
_defaultAccess.onChange(reinitialize);
_allowAddresses.onChange(reinitialize);
_requirePasswordAddresses.onChange(reinitialize);
_denyAddresses.onChange(reinitialize);
addProperty(_socketType);
_port.onChange(reinitialize);
addProperty(_port);
_enabled.onChange(reinitialize);
addProperty(_enabled);
_defaultAccess.onChange(reinitialize);
addProperty(_defaultAccess);
_allowAddresses.onChange(reinitialize);
addProperty(_allowAddresses);
_requirePasswordAddresses.onChange(reinitialize);
addProperty(_requirePasswordAddresses);
_denyAddresses.onChange(reinitialize);
addProperty(_denyAddresses);
addProperty(_password);
}
+4
View File
@@ -160,6 +160,10 @@ namespace {
namespace openspace {
documentation::Documentation SkyBrowserModule::Documentation() {
return codegen::doc<Parameters>("module_skybrowser");
}
SkyBrowserModule::SkyBrowserModule()
: OpenSpaceModule(SkyBrowserModule::Name)
, _enabled(EnabledInfo)
+1
View File
@@ -87,6 +87,7 @@ public:
scripting::LuaLibrary luaLibrary() const override;
std::vector<documentation::Documentation> documentations() const override;
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary& dict) override;
+1 -1
View File
@@ -800,7 +800,7 @@ std::pair<std::string, std::string> HorizonsFile::parseValidTimeRange(
"{} T {}", words[words.size() - 2], words[words.size() - 1]
);
}
else if (words.size() > 2){
else if (words.size() > 2) {
// Sometimes the format can be yyyy-mon-dd without time
startTime = words[words.size() - 2];
endTime = words[words.size() - 1];
+1 -1
View File
@@ -440,7 +440,7 @@ std::vector<Parameters> readTleFile(const std::filesystem::path& file) {
// patch it to the full year
{
const std::string id = firstLine.substr(9, 6);
const std::string prefix = [y = id.substr(0, 2)](){
const std::string prefix = [y = id.substr(0, 2)]() {
const int year = std::atoi(y.c_str());
return year >= 57 ? "19" : "20";
}();
+6 -2
View File
@@ -451,14 +451,18 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
properties::StringProperty(TextureInfo),
properties::FloatProperty(MultiplierInfo, 1.f, 0.f, 20.f),
properties::FloatProperty(GammaInfo, 1.f, 0.f, 5.f),
properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f)
properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f),
nullptr,
nullptr
}
, _glare {
properties::PropertyOwner(GlareOwnerInfo),
properties::StringProperty(TextureInfo),
properties::FloatProperty(MultiplierInfo, 1.f, 0.f, 20.f),
properties::FloatProperty(GammaInfo, 1.f, 0.f, 5.f),
properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f)
properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f),
nullptr,
nullptr
}
, _parameters {
properties::PropertyOwner(SizeCompositionInfo),
+2 -7
View File
@@ -111,13 +111,8 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
_fixedDate = p.fixedDate.value_or(_fixedDate);
addProperty(_fixedDate);
if (dictionary.hasKey(TimeFrameInfo.identifier)) {
const ghoul::Dictionary timeFrameDictionary =
dictionary.value<ghoul::Dictionary>(TimeFrameInfo.identifier);
_timeFrame = TimeFrame::createFromDictionary(timeFrameDictionary);
if (_timeFrame == nullptr) {
throw ghoul::RuntimeError("Invalid dictionary for TimeFrame");
}
if (p.timeFrame.has_value()) {
_timeFrame = TimeFrame::createFromDictionary(*p.timeFrame);
addPropertySubOwner(_timeFrame.get());
}
+2 -2
View File
@@ -152,7 +152,7 @@ void setEarthProximitySettings() {
if (usingPulse) {
int speed = 2;
int modulusResult = int(speed * time) % 2;
if (fluxValue > thresholdFlux){
if (fluxValue > thresholdFlux) {
if (modulusResult == 1) {
vs_color.a = 0.01;
}
@@ -199,7 +199,7 @@ void main() {
vs_color.a = 0.0;
}
}
else if (colorMode == uniformColor){
else if (colorMode == uniformColor) {
vs_color = streamColor;
}
setEarthProximitySettings();
+13 -3
View File
@@ -59,12 +59,23 @@ namespace {
"disabled, the errors will be ignored silently.",
openspace::properties::Property::Visibility::Developer
};
struct [[codegen::Dictionary(SpaceModule)]] Parameters {
// [[codegen::verbatim(SpiceExceptionInfo.description)]]
std::optional<bool> showExceptions;
};
#include "spacemodule_codegen.cpp"
} // namespace
namespace openspace {
ghoul::opengl::ProgramObjectManager SpaceModule::ProgramObjectManager;
documentation::Documentation SpaceModule::Documentation() {
return codegen::doc<Parameters>("module_space");
}
SpaceModule::SpaceModule()
: OpenSpaceModule(Name)
, _showSpiceExceptions(SpiceExceptionInfo, true)
@@ -109,9 +120,8 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) {
fRotation->registerClass<SpiceRotation>("SpiceRotation");
if (dictionary.hasValue<bool>(SpiceExceptionInfo.identifier)) {
_showSpiceExceptions = dictionary.value<bool>(SpiceExceptionInfo.identifier);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
_showSpiceExceptions = p.showExceptions.value_or(_showSpiceExceptions);
}
void SpaceModule::internalDeinitializeGL() {
+1
View File
@@ -43,6 +43,7 @@ public:
static ghoul::opengl::ProgramObjectManager ProgramObjectManager;
scripting::LuaLibrary luaLibrary() const override;
static documentation::Documentation Documentation();
private:
void internalInitialize(const ghoul::Dictionary&) override;
@@ -142,7 +142,7 @@ bool InstrumentTimesParser::create() {
};
_subsetMap[_target]._subset.push_back(std::move(image));
}
if (successfulRead){
if (successfulRead) {
_subsetMap[_target]._range.include(instrumentActiveTimeRange);
_instrumentTimes.emplace_back(instrumentID, instrumentActiveTimeRange);
}
+4
View File
@@ -59,6 +59,10 @@ namespace {
namespace openspace {
documentation::Documentation SyncModule::Documentation() {
return codegen::doc<Parameters>("module_sync");
}
SyncModule::SyncModule() : OpenSpaceModule(Name) {}
void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
+1 -1
View File
@@ -40,8 +40,8 @@ public:
std::filesystem::path synchronizationRoot() const;
std::vector<documentation::Documentation> documentations() const override;
scripting::LuaLibrary luaLibrary() const override;
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary& configuration) override;
+1 -1
View File
@@ -117,7 +117,7 @@ bool TouchModule::isDefaultDirectTouchType(std::string_view renderableType) cons
_sortedDefaultRenderableTypes.end();
}
void TouchModule::internalInitialize(const ghoul::Dictionary&){
void TouchModule::internalInitialize(const ghoul::Dictionary&) {
_ear.reset(new TuioEar());
global::callback::initializeGL->push_back([this]() {
@@ -25,6 +25,7 @@
#include <modules/toyvolume/rendering/renderabletoyvolume.h>
#include <modules/toyvolume/rendering/toyvolumeraycaster.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/raycastermanager.h>
@@ -83,6 +84,33 @@ namespace {
"The downscaling factor used when rendering the current volume.",
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(RenderableToyVolume)]] Parameters {
// [[codegen::verbatim(ScalingExponentInfo.description)]]
std::optional<int> scalingExponent;
// [[codegen::verbatim(SizeInfo.description)]]
std::optional<glm::vec3> size;
// [[codegen::verbatim(TranslationInfo.description)]]
std::optional<glm::vec3> translation;
// [[codegen::verbatim(RotationInfo.description)]]
std::optional<glm::vec3> rotation;
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color [[codegen::color()]];
// [[codegen::verbatim(StepSizeInfo.description)]]
std::optional<float> stepSize;
// Raycast steps
std::optional<int> steps;
// [[codegen::verbatim(DownscaleVolumeRenderingInfo.description)]]
std::optional<float> downscale;
};
#include "renderabletoyvolume_codegen.cpp"
} // namespace
namespace openspace {
@@ -102,47 +130,18 @@ RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary)
, _color(ColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
, _downScaleVolumeRendering(DownscaleVolumeRenderingInfo, 1.f, 0.1f, 1.f)
{
if (dictionary.hasValue<double>(ScalingExponentInfo.identifier)) {
_scalingExponent = static_cast<int>(
dictionary.value<double>(ScalingExponentInfo.identifier)
);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasValue<glm::dvec3>(SizeInfo.identifier)) {
_size = dictionary.value<glm::dvec3>(SizeInfo.identifier);
}
if (dictionary.hasValue<glm::dvec3>(TranslationInfo.identifier)) {
_translation = dictionary.value<glm::dvec3>(TranslationInfo.identifier);
}
if (dictionary.hasValue<glm::dvec3>(RotationInfo.identifier)) {
_rotation = dictionary.value<glm::dvec3>(RotationInfo.identifier);
}
if (dictionary.hasValue<glm::dvec3>(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
if (dictionary.hasValue<double>(StepSizeInfo.identifier)) {
_stepSize = static_cast<float>(dictionary.value<double>(StepSizeInfo.identifier));
}
_scalingExponent = p.scalingExponent.value_or(_scalingExponent);
_size = p.size.value_or(_size);
_translation = p.translation.value_or(_translation);
_rotation = p.rotation.value_or(_rotation);
_color = p.color.value_or(_color);
_stepSize = p.stepSize.value_or(_stepSize);
_rayCastSteps = p.steps.value_or(_rayCastSteps);
_downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer);
if (dictionary.hasKey("Downscale")) {
_downScaleVolumeRendering = static_cast<float>(
dictionary.value<double>("Downscale")
);
}
if (dictionary.hasKey("Steps")) {
_rayCastSteps = static_cast<int>(dictionary.value<double>("Steps"));
}
else {
LINFO(
"Number of raycasting steps not specified for ToyVolume. Using default value"
);
}
_downScaleVolumeRendering = p.downscale.value_or(_downScaleVolumeRendering);
}
RenderableToyVolume::~RenderableToyVolume() {}
-1
View File
@@ -41,7 +41,6 @@ documentation::Documentation ScreenSpaceVideo::Documentation() {
documentation::Documentation doc = VideoPlayer::Documentation();
doc.name = "ScreenSpaceVideo";
doc.id = "video_screenspacevideo";
return doc;
}
+4
View File
@@ -50,6 +50,10 @@ namespace {
namespace openspace {
documentation::Documentation VideoModule::Documentation() {
return codegen::doc<Parameters>("module_video");
}
VideoModule::VideoModule()
: OpenSpaceModule(VideoModule::Name)
, _enabled(EnabledInfo)
+1
View File
@@ -38,6 +38,7 @@ public:
VideoModule();
std::vector<documentation::Documentation> documentations() const override;
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary& dict) override;
+32 -4
View File
@@ -24,29 +24,57 @@
#include <modules/volume/rendering/volumeclipplanes.h>
#include <openspace/documentation/documentation.h>
#include <ghoul/misc/dictionary.h>
namespace {
constexpr openspace::properties::Property::PropertyInfo NormalInfo = {
"Normal",
"Normal",
// @TODO Missing documentation
""
};
constexpr openspace::properties::Property::PropertyInfo OffsetsInfo = {
"Offsets",
"Offsets",
// @TODO Missing documentation
""
};
struct [[codegen::Dictionary(VolumeClipPlane)]] Parameters {
// [[codegen::verbatim(NormalInfo.description)]]
glm::vec3 normal;
// [[codegen::verbatim(OffsetsInfo.description)]]
glm::vec3 offsets;
};
#include "volumeclipplane_codegen.cpp"
} // namespace
namespace openspace::volume {
VolumeClipPlane::VolumeClipPlane(const ghoul::Dictionary& dictionary)
: properties::PropertyOwner({ "" }) // @TODO Missing name
, _normal(
{ "Normal", "Normal", "" }, // @TODO Missing documentation
NormalInfo,
glm::vec3(1.f, 0.f, 0.f),
glm::vec3(-1.f),
glm::vec3(1.f)
)
, _offsets(
{ "Offsets", "Offsets", "" }, // @TODO Missing documentation
OffsetsInfo,
glm::vec2(-2.f, 0.f),
glm::vec2(-2.f, 0.f),
glm::vec2(2.f, 1.f)
)
{
_normal = dictionary.value<glm::dvec3>("Normal");
_offsets = dictionary.value<glm::dvec2>("Offsets");
const Parameters p = codegen::bake<Parameters>(dictionary);
_normal = p.normal;
addProperty(_normal);
_offsets = p.offsets;
addProperty(_offsets);
}
+3 -4
View File
@@ -82,10 +82,9 @@ bool BrowserClient::NoContextMenuHandler::RunContextMenu(CefRefPtr<CefBrowser>,
return true;
}
bool BrowserClient::DisplayHandler::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle,
cef_cursor_type_t type,
const CefCursorInfo&)
bool BrowserClient::DisplayHandler::OnCursorChange(CefRefPtr<CefBrowser>, CefCursorHandle,
cef_cursor_type_t type,
const CefCursorInfo&)
{
WindowDelegate::Cursor newCursor;
switch (type) {
@@ -96,9 +96,9 @@ documentation::Documentation ScreenSpaceBrowser::Documentation() {
ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary& dictionary)
: ScreenSpaceRenderable(dictionary)
, _dimensions(DimensionsInfo, glm::uvec2(0), glm::uvec2(0), glm::uvec2(3000))
, _renderHandler(new ScreenSpaceRenderHandler)
, _url(UrlInfo)
, _reload(ReloadInfo)
, _renderHandler(new ScreenSpaceRenderHandler)
, _keyboardHandler(new WebKeyboardHandler)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
+1 -6
View File
@@ -27,11 +27,6 @@
#include <ghoul/glm.h>
#include <ghoul/logging/logmanager.h>
namespace {
constexpr std::string_view _loggerCat = "WebRenderHandler";
} // namespace
namespace openspace {
WebRenderHandler::WebRenderHandler(bool accelerate)
@@ -259,7 +254,7 @@ bool WebRenderHandler::hasContent(int x, int y) {
glBindTexture(GL_TEXTURE_2D, _texture);
// Read the texture data into the PBO
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
// Map the PBO to the CPU memory space
GLubyte* pixels = reinterpret_cast<GLubyte*>(
+44 -38
View File
@@ -90,10 +90,29 @@ namespace {
return execLocation;
}
struct [[codegen::Dictionary(WebBrowserModule)]] Parameters {
// The location of the web helper application
std::optional<std::filesystem::path> webHelperLocation;
// Determines whether the WebBrowser module is enabled
std::optional<bool> enabled;
// [[codegen::verbatim(UpdateBrowserBetweenRenderablesInfo.description)]]
std::optional<bool> updateBrowserBetweenRenderables;
// [[codegen::verbatim(BrowserUpdateIntervalInfo.description)]]
std::optional<float> browserUpdateInterval;
};
#include "webbrowsermodule_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation WebBrowserModule::Documentation() {
return codegen::doc<Parameters>("module_webbrowser");
}
WebBrowserModule::WebBrowserModule()
: OpenSpaceModule(WebBrowserModule::Name)
, _updateBrowserBetweenRenderables(UpdateBrowserBetweenRenderablesInfo, true)
@@ -127,6 +146,31 @@ WebBrowserModule::WebBrowserModule()
WebBrowserModule::~WebBrowserModule() {}
void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) {
ZoneScoped;
const Parameters p = codegen::bake<Parameters>(dictionary);
_webHelperLocation = p.webHelperLocation.value_or(findHelperExecutable());
_enabled = p.enabled.value_or(_enabled);
LDEBUG(std::format("CEF using web helper executable: {}", _webHelperLocation));
_cefHost = std::make_unique<CefHost>(_webHelperLocation.string());
LDEBUG("Starting CEF... done");
_updateBrowserBetweenRenderables =
p.updateBrowserBetweenRenderables.value_or(_updateBrowserBetweenRenderables);
_browserUpdateInterval = p.browserUpdateInterval.value_or(_browserUpdateInterval);
_eventHandler->initialize();
// register ScreenSpaceBrowser
ghoul::TemplateFactory<ScreenSpaceRenderable>* fScreenSpaceRenderable =
FactoryManager::ref().factory<ScreenSpaceRenderable>();
ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created");
fScreenSpaceRenderable->registerClass<ScreenSpaceBrowser>("ScreenSpaceBrowser");
}
void WebBrowserModule::internalDeinitialize() {
ZoneScoped;
@@ -142,44 +186,6 @@ void WebBrowserModule::internalDeinitialize() {
}
}
void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) {
ZoneScoped;
if (dictionary.hasValue<bool>("WebHelperLocation")) {
_webHelperLocation = absPath(dictionary.value<std::string>("WebHelperLocation"));
}
else {
_webHelperLocation = findHelperExecutable();
}
if (dictionary.hasValue<bool>("Enabled")) {
_enabled = dictionary.value<bool>("Enabled");
}
LDEBUG(std::format("CEF using web helper executable: {}", _webHelperLocation));
_cefHost = std::make_unique<CefHost>(_webHelperLocation.string());
LDEBUG("Starting CEF... done");
if (dictionary.hasValue<bool>(UpdateBrowserBetweenRenderablesInfo.identifier)) {
_updateBrowserBetweenRenderables =
dictionary.value<bool>(UpdateBrowserBetweenRenderablesInfo.identifier);
}
if (dictionary.hasValue<double>(BrowserUpdateIntervalInfo.identifier)) {
_browserUpdateInterval = static_cast<float>(
dictionary.value<double>(BrowserUpdateIntervalInfo.identifier)
);
}
_eventHandler->initialize();
// register ScreenSpaceBrowser
ghoul::TemplateFactory<ScreenSpaceRenderable>* fScreenSpaceRenderable =
FactoryManager::ref().factory<ScreenSpaceRenderable>();
ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created");
fScreenSpaceRenderable->registerClass<ScreenSpaceBrowser>("ScreenSpaceBrowser");
}
void WebBrowserModule::addBrowser(BrowserInstance* browser) {
ZoneScoped;
+1
View File
@@ -61,6 +61,7 @@ public:
static bool canUseAcceleratedRendering();
std::vector<documentation::Documentation> documentations() const override;
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary& dictionary) override;
+4
View File
@@ -119,6 +119,10 @@ namespace {
namespace openspace {
documentation::Documentation WebGuiModule::Documentation() {
return codegen::doc<Parameters>("module_webgui");
}
WebGuiModule::WebGuiModule()
: OpenSpaceModule(WebGuiModule::Name)
, _enabled(ServerProcessEnabledInfo, true)
+2
View File
@@ -50,6 +50,8 @@ public:
CallbackHandle addEndpointChangeCallback(EndpointCallback cb);
void removeEndpointChangeCallback(CallbackHandle);
static documentation::Documentation Documentation();
protected:
void internalInitialize(const ghoul::Dictionary&) override;
+2 -1
View File
@@ -139,7 +139,6 @@ ModuleConfigurations = {
}
},
Server = {
AllowAddresses = { "127.0.0.1", "localhost" },
SkyBrowserUpdateTime = 50,
Interfaces = {
{
@@ -148,6 +147,7 @@ ModuleConfigurations = {
Port = 4681,
Enabled = true,
DefaultAccess = "Deny",
AllowAddresses = { "127.0.0.1", "localhost" },
RequirePasswordAddresses = {},
Password = ""
},
@@ -157,6 +157,7 @@ ModuleConfigurations = {
Port = 4682,
Enabled = true,
DefaultAccess = "Deny",
AllowAddresses = { "127.0.0.1", "localhost" },
RequirePasswordAddresses = {},
Password = ""
}
+4 -3
View File
@@ -178,10 +178,11 @@ void logError(const SpecificationError& error, std::string component) {
}
DocumentationEntry::DocumentationEntry(std::string k, std::shared_ptr<Verifier> v,
Optional opt, std::string doc)
Optional opt, Private priv, std::string doc)
: key(std::move(k))
, verifier(std::move(v))
, optional(opt)
, isPrivate(priv)
, documentation(std::move(doc))
{
ghoul_assert(!key.empty(), "Key must not be empty");
@@ -189,8 +190,8 @@ DocumentationEntry::DocumentationEntry(std::string k, std::shared_ptr<Verifier>
}
DocumentationEntry::DocumentationEntry(std::string k, Verifier* v, Optional opt,
std::string doc)
: DocumentationEntry(std::move(k), std::shared_ptr<Verifier>(v), opt,
Private priv, std::string doc)
: DocumentationEntry(std::move(k), std::shared_ptr<Verifier>(v), opt, priv,
std::move(doc))
{}
+14 -2
View File
@@ -689,7 +689,13 @@ std::string TableVerifier::type() const {
StringListVerifier::StringListVerifier(std::string elementDocumentation)
: TableVerifier({
{ "*", new StringVerifier, Optional::No, std::move(elementDocumentation) }
{
"*",
new StringVerifier,
Optional::No,
Private::No,
std::move(elementDocumentation)
}
})
{}
@@ -699,7 +705,13 @@ std::string StringListVerifier::type() const {
IntListVerifier::IntListVerifier(std::string elementDocumentation)
: TableVerifier({
{ "*", new IntVerifier, Optional::No, std::move(elementDocumentation) }
{
"*",
new IntVerifier,
Optional::No,
Private::No,
std::move(elementDocumentation)
}
})
{}
+43 -9
View File
@@ -25,7 +25,9 @@
#include <openspace/engine/configuration.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/settings.h>
#include <openspace/engine/moduleengine.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
@@ -327,9 +329,6 @@ namespace {
// Values in this table describe the behavior of the loading screen that is
// displayed while the scene graph is created and initialized
std::optional<LoadingScreen> loadingScreen;
// Configurations for each module
std::optional<std::map<std::string, ghoul::Dictionary>> moduleConfigurations;
};
#include "configuration_codegen.cpp"
} // namespace
@@ -522,9 +521,7 @@ void parseLuaState(Configuration& configuration) {
// We go through all of the entries and lift them from global scope into the table on
// the stack so that we can create a ghoul::Dictionary from this new table
const documentation::Documentation doc = codegen::doc<Parameters>(
"core_configuration"
);
const documentation::Documentation doc = Configuration::Documentation();
for (const documentation::DocumentationEntry& e : doc.entries) {
lua_pushstring(s, e.key.c_str());
lua_getglobal(s, e.key.c_str());
@@ -611,7 +608,14 @@ void parseLuaState(Configuration& configuration) {
l.showLogMessages.value_or(c.loadingScreen.isShowingLogMessages);
}
c.moduleConfigurations = p.moduleConfigurations.value_or(c.moduleConfigurations);
// ModuleConfigurations depend on the list of modules that are added, which has to be
// done dynamically. Hence we can't have it written directly into the struct
if (d.hasValue<ghoul::Dictionary>("ModuleConfigurations")) {
ghoul::Dictionary dict = d.value<ghoul::Dictionary>("ModuleConfigurations");
for (std::string_view key : dict.keys()) {
c.moduleConfigurations[std::string(key)] = dict.value<ghoul::Dictionary>(key);
}
}
if (p.openGLDebugContext.has_value()) {
const Parameters::OpenGLDebugContext& l = *p.openGLDebugContext;
@@ -691,8 +695,38 @@ void patchConfiguration(Configuration& configuration, const Settings& settings)
}
}
documentation::Documentation Configuration::Documentation =
codegen::doc<Parameters>("core_configuration");
documentation::Documentation Configuration::Documentation() {
using namespace documentation;
documentation::Documentation doc = codegen::doc<Parameters>("core_configuration");
auto moduleConfiguration = std::make_shared<TableVerifier>();
for (OpenSpaceModule* mod : global::moduleEngine->modules()) {
std::string name = mod->identifier();
std::string id = mod->Documentation().id;
if (id.empty()) {
continue;
}
moduleConfiguration->documentations.push_back({
name,
new ReferencingVerifier(id),
Optional::Yes,
Private::No,
mod->Documentation().description
});
}
doc.entries.push_back({
"ModuleConfigurations",
std::move(moduleConfiguration),
Optional::Yes,
Private::No,
"Configurations for each module"
});
return doc;
}
std::filesystem::path findConfiguration(const std::string& filename) {
std::filesystem::path directory = absPath("${BIN}");
+4
View File
@@ -185,4 +185,8 @@ scripting::LuaLibrary ModuleEngine::luaLibrary() {
};
}
std::vector<documentation::Documentation> ModuleEngine::moduleDocumentations() const {
return AllModuleDocumentation();
}
} // namespace openspace
+4 -1
View File
@@ -404,12 +404,15 @@ void OpenSpaceEngine::initialize() {
// After registering the modules, the documentations for the available classes
// can be added as well
for (documentation::Documentation d : global::moduleEngine->moduleDocumentations()) {
DocEng.addDocumentation(std::move(d));
}
for (OpenSpaceModule* m : global::moduleEngine->modules()) {
for (const documentation::Documentation& doc : m->documentations()) {
DocEng.addDocumentation(doc);
}
}
DocEng.addDocumentation(Configuration::Documentation);
DocEng.addDocumentation(Configuration::Documentation());
// Register the provided shader directories
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
@@ -107,6 +107,7 @@ documentation::Documentation ConvertRecFileVersionTask::documentation() {
"InputFilePath",
new StringAnnotationVerifier("A valid filename to convert"),
Optional::No,
Private::No,
"The filename to update to the current file format",
},
},
@@ -314,12 +314,14 @@ documentation::Documentation ConvertRecFormatTask::documentation() {
"InputFilePath",
new StringAnnotationVerifier("A valid filename to convert"),
Optional::No,
Private::No,
"The filename to convert to the opposite format",
},
{
"OutputFilePath",
new StringAnnotationVerifier("A valid output filename"),
Optional::No,
Private::No,
"The filename containing the converted result",
},
},
+1 -1
View File
@@ -127,10 +127,10 @@ ParallelPeer::ParallelPeer()
: properties::PropertyOwner({ "ParallelPeer", "Parallel Peer" })
, _password(PasswordInfo)
, _hostPassword(HostPasswordInfo)
, _serverName(ServerNameInfo)
, _port(PortInfo)
, _address(AddressInfo)
, _name(NameInfo)
, _serverName(ServerNameInfo)
, _bufferTime(BufferTimeInfo, 0.2f, 0.01f, 5.0f)
, _timeKeyframeInterval(TimeKeyFrameInfo, 0.1f, 0.f, 1.f)
, _cameraKeyframeInterval(CameraKeyFrameInfo, 0.1f, 0.f, 1.f)
+1 -1
View File
@@ -129,7 +129,7 @@ void TransferFunction::setTextureFromTxt() {
float intensity = 0.f;
glm::vec4 rgba;
iss >> intensity;
for(int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {
iss >> rgba[i];
}
mappingKeys.emplace_back(intensity, rgba);
+3 -3
View File
@@ -86,7 +86,7 @@ bool Histogram::add(float value, float repeat) {
return true;
}
void Histogram::changeRange(float minValue, float maxValue){
void Histogram::changeRange(float minValue, float maxValue) {
if (minValue > _minValue && maxValue < _maxValue) {
return;
}
@@ -96,7 +96,7 @@ void Histogram::changeRange(float minValue, float maxValue){
const float oldMax = _maxValue;
float* newData = new float[_numBins]{0.0};
for(int i=0; i<_numBins; i++){
for (int i = 0; i < _numBins; i++) {
const float unNormalizedValue = i * (oldMax - oldMin) + oldMin;
const float normalizedValue = (unNormalizedValue - _minValue) /
(_maxValue - _minValue); // [0.0, 1.0]
@@ -297,7 +297,7 @@ void Histogram::print() const {
//// std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl;
}
float Histogram::highestBinValue(bool equalized, int overBins){
float Histogram::highestBinValue(bool equalized, int overBins) {
int highestBin = 0;
float highestValue = 0;

Some files were not shown because too many files have changed in this diff Show More