diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 590e85b7b4..1e32157e71 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -48,6 +48,12 @@ namespace { struct [[codegen::Dictionary(ScreenSpaceDashboard)]] Parameters { // [[codegen::verbatim(UseMainInfo.description)]] std::optional useMainDashboard; + + // A list of DashboardItems that are added automatically upon construction of the + // ScreenSpaceDashboard. This value must not be specified if `UseMainDashboard` is + // specified. + std::optional> + items [[codegen::reference("dashboarditem")]]; }; #include "screenspacedashboard_codegen.cpp" } // namespace @@ -81,6 +87,18 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary) _scale = 1.f; _scale.setMaxValue(15.f); + + if (_useMainDashboard && p.items.has_value()) { + throw ghoul::RuntimeError("Cannot specify items when using the main dashboard"); + } + + if (p.items.has_value()) { + ghoul_assert(_useMainDashboard, "Cannot add items to the main dashboard"); + for (const ghoul::Dictionary& item : *p.items) { + std::unique_ptr i = DashboardItem::createFromDictionary(item); + _dashboard.addDashboardItem(std::move(i)); + } + } } bool ScreenSpaceDashboard::initializeGL() { diff --git a/src/documentation/core_registration.cpp b/src/documentation/core_registration.cpp index c06b267191..3c0138453c 100644 --- a/src/documentation/core_registration.cpp +++ b/src/documentation/core_registration.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,8 @@ namespace openspace { void registerCoreClasses(documentation::DocumentationEngine& engine) { engine.addDocumentation(LogFactoryDocumentation()); + engine.addDocumentation(DashboardItem::Documentation()); + engine.addDocumentation(ColorMappingComponent::Documentation()); engine.addDocumentation(LabelsComponent::Documentation()); engine.addDocumentation(LightSource::Documentation()); diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index fa90a3eaa3..1c44e9e149 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +199,14 @@ bool ScriptEngine::runScript(const std::string& script, const ScriptCallback& ca } return false; } + catch (const documentation::SpecificationError& e) { + LERRORC(e.component, e.message); + documentation::logError(e, e.component); + if (callback) { + callback(ghoul::Dictionary()); + } + return false; + } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); if (callback) {