mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Add the ability to specify dashboarditems for ScreenSpaceDashboard at construction time. Improve error messages and export DashboardItem documentation
This commit is contained in:
@@ -48,6 +48,12 @@ namespace {
|
||||
struct [[codegen::Dictionary(ScreenSpaceDashboard)]] Parameters {
|
||||
// [[codegen::verbatim(UseMainInfo.description)]]
|
||||
std::optional<bool> 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<std::vector<ghoul::Dictionary>>
|
||||
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<DashboardItem> i = DashboardItem::createFromDictionary(item);
|
||||
_dashboard.addDashboardItem(std::move(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ScreenSpaceDashboard::initializeGL() {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
#include <openspace/rendering/colormappingcomponent.h>
|
||||
#include <openspace/rendering/dashboard.h>
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
#include <openspace/rendering/labelscomponent.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
@@ -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());
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openspace/interaction/sessionrecording.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user