mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-28 14:59:31 -05:00
Merge branch 'master' into feature/launcherconfigs
* master: Updated version number to 0.7.0 (prerelease-12 NAOJ) Windows compile fix Reduce dependency of onscreengui module in libOpenspace Add check to `check_style_guide` that reports wrong dependencies Reduce the dependency of libOpenSpace on modules - Enable module callbacks for OpenSpaceEngine - Add OpenSpaceModule function that returns a Lua library
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -92,10 +93,7 @@ public:
|
||||
ghoul::fontrendering::FontManager& fontManager();
|
||||
DownloadManager& downloadManager();
|
||||
TimeManager& timeManager();
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
gui::GUI& gui();
|
||||
#endif
|
||||
SettingsEngine& settingsEngine();
|
||||
|
||||
// SGCT callbacks
|
||||
bool initialize();
|
||||
@@ -124,6 +122,70 @@ public:
|
||||
|
||||
void runPostInitializationScripts(const std::string& sceneDescription);
|
||||
|
||||
|
||||
|
||||
// This method is only to be called from Modules
|
||||
|
||||
enum class CallbackOption {
|
||||
Initialize = 0, // Callback for the end of the initialization
|
||||
Deinitialize, // Callback for the end of the deinitialization
|
||||
InitializeGL, // Callback for the end of the OpenGL initialization
|
||||
DeinitializeGL, // Callback for the end of the OpenGL deinitialization
|
||||
PreSync, // Callback for the end of the pre-sync function
|
||||
PostSyncPreDraw, // Callback for the end of the post-sync-pre-draw function
|
||||
Render, // Callback for the end of the render function
|
||||
PostDraw // Callback for the end of the post-draw function
|
||||
};
|
||||
|
||||
// Registers a callback for a specific CallbackOption
|
||||
void registerModuleCallback(CallbackOption option, std::function<void()> function) {
|
||||
switch (option) {
|
||||
case CallbackOption::Initialize:
|
||||
_moduleCallbacks.initialize.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::Deinitialize:
|
||||
_moduleCallbacks.deinitialize.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::InitializeGL:
|
||||
_moduleCallbacks.initializeGL.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::DeinitializeGL:
|
||||
_moduleCallbacks.deinitializeGL.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::PreSync:
|
||||
_moduleCallbacks.preSync.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::PostSyncPreDraw:
|
||||
_moduleCallbacks.postSyncPreDraw.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::Render:
|
||||
_moduleCallbacks.render.push_back(std::move(function));
|
||||
break;
|
||||
case CallbackOption::PostDraw:
|
||||
_moduleCallbacks.postDraw.push_back(std::move(function));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Registers a callback that is called when a new keyboard event is received
|
||||
void registerModuleKeyboardCallback(
|
||||
std::function<bool (Key, KeyModifier, KeyAction)> function);
|
||||
|
||||
// Registers a callback that is called when a new character event is received
|
||||
void registerModuleCharCallback(
|
||||
std::function<bool (unsigned int, KeyModifier)> function);
|
||||
|
||||
// Registers a callback that is called when a new mouse button is received
|
||||
void registerModuleMouseButtonCallback(
|
||||
std::function<bool (MouseButton, MouseAction)> function);
|
||||
|
||||
// Registers a callback that is called when a new mouse movement is received
|
||||
void registerModuleMousePositionCallback(
|
||||
std::function<void (double, double)> function);
|
||||
|
||||
// Registers a callback that is called when a scroll wheel change is received
|
||||
void registerModuleMouseScrollWheelCallback(std::function<bool (double)> function);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* application.
|
||||
@@ -155,9 +217,6 @@ private:
|
||||
std::unique_ptr<SettingsEngine> _settingsEngine;
|
||||
std::unique_ptr<TimeManager> _timeManager;
|
||||
std::unique_ptr<DownloadManager> _downloadManager;
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
std::unique_ptr<gui::GUI> _gui;
|
||||
#endif
|
||||
std::unique_ptr<ParallelConnection> _parallelConnection;
|
||||
std::unique_ptr<WindowWrapper> _windowWrapper;
|
||||
std::unique_ptr<ghoul::fontrendering::FontManager> _fontManager;
|
||||
@@ -165,6 +224,30 @@ private:
|
||||
// Others
|
||||
std::unique_ptr<properties::PropertyOwner> _globalPropertyNamespace;
|
||||
|
||||
struct {
|
||||
std::vector<std::function<void()>> initialize;
|
||||
std::vector<std::function<void()>> deinitialize;
|
||||
|
||||
std::vector<std::function<void()>> initializeGL;
|
||||
std::vector<std::function<void()>> deinitializeGL;
|
||||
|
||||
std::vector<std::function<void()>> preSync;
|
||||
std::vector<std::function<void()>> postSyncPreDraw;
|
||||
std::vector<std::function<void()>> render;
|
||||
std::vector<std::function<void()>> postDraw;
|
||||
|
||||
std::vector<std::function<bool (Key, KeyModifier, KeyAction)>> keyboard;
|
||||
std::vector<std::function<bool (unsigned int, KeyModifier)>> character;
|
||||
|
||||
std::vector<std::function<bool (MouseButton, MouseAction)>> mouseButton;
|
||||
std::vector<std::function<void (double, double)>> mousePosition;
|
||||
std::vector<std::function<bool (double)>> mouseScrollWheel;
|
||||
|
||||
|
||||
|
||||
|
||||
} _moduleCallbacks;
|
||||
|
||||
bool _isMaster;
|
||||
double _runTime;
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ namespace openspace {
|
||||
std::string licenseText();
|
||||
|
||||
const int OPENSPACE_VERSION_MAJOR = 0;
|
||||
const int OPENSPACE_VERSION_MINOR = 6;
|
||||
const int OPENSPACE_VERSION_MINOR = 7;
|
||||
const int OPENSPACE_VERSION_PATCH = 0;
|
||||
|
||||
const std::string OPENSPACE_VERSION_STRING = "prerelease-11 (AGU)";
|
||||
const std::string OPENSPACE_VERSION_STRING = "prerelease-12 (NAOJ)";
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
|
||||
#include <ghoul/systemcapabilities/openglcapabilitiescomponent.h>
|
||||
|
||||
@@ -73,6 +74,13 @@ public:
|
||||
* \return A list of Documentation classes that are valid for this OpenSapceModule
|
||||
*/
|
||||
virtual std::vector<Documentation> documentations() const;
|
||||
|
||||
/**
|
||||
* Returns the Lua library with functions defined by this OpenSpaceModule. The default
|
||||
* implementation returns an empty library.
|
||||
* \return The Lua library with functions defined by this OpenSpaceModule
|
||||
*/
|
||||
virtual scripting::LuaLibrary luaLibrary() const;
|
||||
|
||||
/**
|
||||
* Returns the minimum required OpenGL version of this OpenSpaceModule. Unless
|
||||
|
||||
@@ -40,7 +40,18 @@ namespace openspace {
|
||||
|
||||
IswaModule::IswaModule()
|
||||
: OpenSpaceModule("ISWA")
|
||||
{}
|
||||
{
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::Initialize,
|
||||
[](){
|
||||
IswaManager::initialize();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
scripting::LuaLibrary IswaModule::luaLibrary() const {
|
||||
return IswaManager::luaLibrary();
|
||||
}
|
||||
|
||||
void IswaModule::internalInitialize(){
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
class IswaModule : public OpenSpaceModule {
|
||||
public:
|
||||
IswaModule();
|
||||
|
||||
scripting::LuaLibrary luaLibrary() const override;
|
||||
|
||||
protected:
|
||||
void internalInitialize() override;
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace gui {
|
||||
class GUI : public GuiComponent {
|
||||
public:
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
|
||||
@@ -27,13 +27,158 @@
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/settingsengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
gui::GUI OnScreenGUIModule::gui;
|
||||
|
||||
OnScreenGUIModule::OnScreenGUIModule()
|
||||
: OpenSpaceModule("OnScreenGUI")
|
||||
{
|
||||
addPropertySubOwner(OsEng.gui());
|
||||
}
|
||||
addPropertySubOwner(gui);
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::Initialize,
|
||||
[](){
|
||||
LDEBUGC("OnScreenGUIModule", "Initializing GUI");
|
||||
gui.initialize();
|
||||
|
||||
gui._globalProperty.setSource(
|
||||
[]() {
|
||||
std::vector<properties::PropertyOwner*> res = {
|
||||
&(OsEng.settingsEngine()),
|
||||
&(OsEng.interactionHandler()),
|
||||
&(OsEng.renderEngine())
|
||||
};
|
||||
return res;
|
||||
}
|
||||
);
|
||||
|
||||
gui._screenSpaceProperty.setSource(
|
||||
[]() {
|
||||
const auto& ssr = OsEng.renderEngine().screenSpaceRenderables();
|
||||
return std::vector<properties::PropertyOwner*>(ssr.begin(), ssr.end());
|
||||
}
|
||||
);
|
||||
|
||||
gui._property.setSource(
|
||||
[]() {
|
||||
const auto& nodes = OsEng.renderEngine().scene()->allSceneGraphNodes();
|
||||
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::Deinitialize,
|
||||
[](){
|
||||
LDEBUGC("OnScreenGui", "Deinitialize GUI");
|
||||
gui.deinitialize();
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::InitializeGL,
|
||||
[](){
|
||||
LDEBUGC("OnScreenGui", "Initializing GUI OpenGL");
|
||||
gui.initializeGL();
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::DeinitializeGL,
|
||||
[](){
|
||||
LDEBUGC("OnScreenGui", "Deinitialize GUI OpenGL");
|
||||
gui.deinitializeGL();
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::PostSyncPreDraw,
|
||||
[](){
|
||||
WindowWrapper& wrapper = OsEng.windowWrapper();
|
||||
if (OsEng.isMaster() && wrapper.isRegularRendering()) {
|
||||
glm::vec2 mousePosition = wrapper.mousePosition();
|
||||
//glm::ivec2 drawBufferResolution = _windowWrapper->currentDrawBufferResolution();
|
||||
glm::ivec2 windowSize = wrapper.currentWindowSize();
|
||||
glm::ivec2 renderingSize = wrapper.currentWindowResolution();
|
||||
uint32_t mouseButtons = wrapper.mouseButtons(2);
|
||||
|
||||
double dt = std::max(wrapper.averageDeltaTime(), 0.0);
|
||||
|
||||
gui.startFrame(
|
||||
static_cast<float>(dt),
|
||||
glm::vec2(windowSize),
|
||||
wrapper.dpiScaling(),
|
||||
mousePosition,
|
||||
mouseButtons
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::PostDraw,
|
||||
[](){
|
||||
WindowWrapper& wrapper = OsEng.windowWrapper();
|
||||
bool showGui = wrapper.hasGuiWindow() ? wrapper.isGuiWindow() : true;
|
||||
if (OsEng.isMaster() && wrapper.isRegularRendering() && showGui) {
|
||||
gui.endFrame();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleKeyboardCallback(
|
||||
[](Key key, KeyModifier mod, KeyAction action) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.keyCallback(key, mod, action);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleCharCallback(
|
||||
[](unsigned int codepoint, KeyModifier modifier) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.charCallback(codepoint, modifier);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleMouseButtonCallback(
|
||||
[](MouseButton button, MouseAction action) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.mouseButtonCallback(button, action);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.registerModuleMouseScrollWheelCallback(
|
||||
[](double pos) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.mouseWheelCallback(pos);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -27,11 +27,15 @@
|
||||
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
namespace openspace {
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class OnScreenGUIModule : public OpenSpaceModule {
|
||||
public:
|
||||
OnScreenGUIModule();
|
||||
|
||||
static gui::GUI gui;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
#include <modules/onscreengui/onscreenguimodule.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/keys.h>
|
||||
@@ -237,10 +239,6 @@ GUI::GUI()
|
||||
addPropertySubOwner(_iswa);
|
||||
}
|
||||
|
||||
GUI::~GUI() {
|
||||
ImGui::Shutdown();
|
||||
}
|
||||
|
||||
void GUI::initialize() {
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
|
||||
configurationFile, "", ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
@@ -322,6 +320,8 @@ void GUI::initialize() {
|
||||
}
|
||||
|
||||
void GUI::deinitialize() {
|
||||
ImGui::Shutdown();
|
||||
|
||||
_iswa.deinitialize();
|
||||
_help.deinitialize();
|
||||
_performance.deinitialize();
|
||||
|
||||
@@ -39,7 +39,7 @@ int show(lua_State* L) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OsEng.gui().setEnabled(true);
|
||||
OnScreenGUIModule::gui.setEnabled(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ int hide(lua_State* L) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OsEng.gui().setEnabled(false);
|
||||
OnScreenGUIModule::gui.setEnabled(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ int toggle(lua_State* L) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OsEng.gui().setEnabled(!OsEng.gui().isEnabled());
|
||||
OnScreenGUIModule::gui.setEnabled(!OnScreenGUIModule::gui.isEnabled());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timerange.h>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#endif
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void registerCoreClasses(documentation::DocumentationEngine& engine) {
|
||||
|
||||
+108
-143
@@ -75,15 +75,6 @@
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#endif
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
#include <modules/iswa/rendering/iswabasegroup.h>
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(OPENSPACE_ENABLE_VLD)
|
||||
#include <vld.h>
|
||||
#endif
|
||||
@@ -145,9 +136,6 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
, _settingsEngine(new SettingsEngine)
|
||||
, _timeManager(new TimeManager)
|
||||
, _downloadManager(nullptr)
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
, _gui(new gui::GUI)
|
||||
#endif
|
||||
, _parallelConnection(new ParallelConnection)
|
||||
, _windowWrapper(std::move(windowWrapper))
|
||||
, _globalPropertyNamespace(new properties::PropertyOwner)
|
||||
@@ -189,9 +177,6 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
OpenSpaceEngine::~OpenSpaceEngine() {
|
||||
LINFO("_windowWrapper->isUsingSwapGroups(): " << _windowWrapper->isUsingSwapGroups());
|
||||
LINFO("_windowWrapper->isSwapGroupMaster(): " << _windowWrapper->isSwapGroupMaster());
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
_gui->deinitializeGL();
|
||||
#endif
|
||||
_interactionHandler->deinitialize();
|
||||
_renderEngine->deinitialize();
|
||||
|
||||
@@ -208,9 +193,6 @@ OpenSpaceEngine::~OpenSpaceEngine() {
|
||||
_console = nullptr;
|
||||
_moduleEngine = nullptr;
|
||||
_settingsEngine = nullptr;
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
_gui = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
OpenSpaceEngine& OpenSpaceEngine::ref() {
|
||||
@@ -400,6 +382,14 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::destroy() {
|
||||
for (const auto& func : _engine->_moduleCallbacks.deinitializeGL) {
|
||||
func();
|
||||
}
|
||||
|
||||
for (const auto& func : _engine->_moduleCallbacks.deinitialize) {
|
||||
func();
|
||||
}
|
||||
|
||||
_engine->_moduleEngine->deinitialize();
|
||||
_engine->_console->deinitialize();
|
||||
|
||||
@@ -471,11 +461,11 @@ bool OpenSpaceEngine::initialize() {
|
||||
// Register Lua script functions
|
||||
LDEBUG("Registering Lua libraries");
|
||||
registerCoreClasses(*_scriptEngine);
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_scriptEngine->addLibrary(IswaManager::luaLibrary());
|
||||
#endif
|
||||
|
||||
|
||||
for (OpenSpaceModule* module : _moduleEngine->modules()) {
|
||||
_scriptEngine->addLibrary(module->luaLibrary());
|
||||
}
|
||||
|
||||
// TODO: Maybe move all scenegraph and renderengine stuff to initializeGL
|
||||
scriptEngine().initialize();
|
||||
|
||||
@@ -518,6 +508,10 @@ bool OpenSpaceEngine::initialize() {
|
||||
_renderEngine->initialize();
|
||||
_renderEngine->setGlobalBlackOutFactor(0.0);
|
||||
_renderEngine->startFading(1, 3.0);
|
||||
|
||||
for (const auto& func : _moduleCallbacks.initialize) {
|
||||
func();
|
||||
}
|
||||
|
||||
// Run start up scripts
|
||||
try {
|
||||
@@ -527,58 +521,6 @@ bool OpenSpaceEngine::initialize() {
|
||||
LFATALC(e.component, e.message);
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
LINFO("Initializing GUI");
|
||||
_gui->initialize();
|
||||
_gui->_globalProperty.setSource(
|
||||
[&]() {
|
||||
std::vector<properties::PropertyOwner*> res = {
|
||||
_settingsEngine.get(),
|
||||
_interactionHandler.get(),
|
||||
_renderEngine.get()
|
||||
};
|
||||
return res;
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.gui()._screenSpaceProperty.setSource(
|
||||
[&]() {
|
||||
const auto& ssr = renderEngine().screenSpaceRenderables();
|
||||
return std::vector<properties::PropertyOwner*>(ssr.begin(), ssr.end());
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.gui()._property.setSource(
|
||||
[&]() {
|
||||
const auto& nodes = renderEngine().scene()->allSceneGraphNodes();
|
||||
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
|
||||
}
|
||||
);
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
OsEng.gui()._iswa.setSource(
|
||||
[&]() {
|
||||
const auto& groups = IswaManager::ref().groups();
|
||||
std::vector<properties::PropertyOwner*> res;
|
||||
std::transform(
|
||||
groups.begin(),
|
||||
groups.end(),
|
||||
std::back_inserter(res),
|
||||
[](const auto& val) {
|
||||
return val.second.get();
|
||||
}
|
||||
);
|
||||
return res;
|
||||
}
|
||||
);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
IswaManager::initialize();
|
||||
#endif
|
||||
|
||||
_syncEngine->addSyncables(Time::ref().getSyncables());
|
||||
_syncEngine->addSyncables(_renderEngine->getSyncables());
|
||||
_syncEngine->addSyncable(_scriptEngine.get());
|
||||
@@ -850,15 +792,11 @@ void OpenSpaceEngine::configureLogging() {
|
||||
bool OpenSpaceEngine::initializeGL() {
|
||||
LINFO("Initializing Rendering Engine");
|
||||
bool success = _renderEngine->initializeGL();
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
LINFO("Initializing OnScreen GUI GL");
|
||||
try {
|
||||
_gui->initializeGL();
|
||||
|
||||
for (const auto& func : _moduleCallbacks.initializeGL) {
|
||||
func();
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR(e.what());
|
||||
}
|
||||
#endif
|
||||
|
||||
LINFO("Finished initializing OpenGL");
|
||||
|
||||
// If using swapgroups,
|
||||
@@ -867,19 +805,19 @@ bool OpenSpaceEngine::initializeGL() {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::isMaster(){
|
||||
bool OpenSpaceEngine::isMaster() {
|
||||
return _isMaster;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::setMaster(bool master){
|
||||
void OpenSpaceEngine::setMaster(bool master) {
|
||||
_isMaster = master;
|
||||
}
|
||||
|
||||
double OpenSpaceEngine::runTime(){
|
||||
double OpenSpaceEngine::runTime() {
|
||||
return _runTime;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::setRunTime(double d){
|
||||
void OpenSpaceEngine::setRunTime(double d) {
|
||||
_runTime = d;
|
||||
}
|
||||
|
||||
@@ -911,6 +849,10 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
_parallelConnection->preSynchronization();
|
||||
|
||||
}
|
||||
|
||||
for (const auto& func : _moduleCallbacks.preSync) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
@@ -936,26 +878,10 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
// Step the camera using the current mouse velocities which are synced
|
||||
//_interactionHandler->updateCamera();
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_isMaster && _windowWrapper->isRegularRendering()) {
|
||||
glm::vec2 mousePosition = _windowWrapper->mousePosition();
|
||||
//glm::ivec2 drawBufferResolution = _windowWrapper->currentDrawBufferResolution();
|
||||
glm::ivec2 windowSize = _windowWrapper->currentWindowSize();
|
||||
glm::ivec2 renderingSize = _windowWrapper->currentWindowResolution();
|
||||
uint32_t mouseButtons = _windowWrapper->mouseButtons(2);
|
||||
|
||||
double dt = std::max(_windowWrapper->averageDeltaTime(), 0.0);
|
||||
|
||||
_gui->startFrame(
|
||||
static_cast<float>(dt),
|
||||
glm::vec2(windowSize),
|
||||
_windowWrapper->dpiScaling(),
|
||||
mousePosition,
|
||||
mouseButtons
|
||||
);
|
||||
for (const auto& func : _moduleCallbacks.postSyncPreDraw) {
|
||||
func();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Testing this every frame has minimal impact on the performance --- abock
|
||||
// Debug build: 1-2 us ; Release build: <= 1 us
|
||||
using ghoul::logging::LogManager;
|
||||
@@ -963,35 +889,42 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
int errorCounter = LogMgr.messageCounter(LogLevel::Error);
|
||||
int fatalCounter = LogMgr.messageCounter(LogLevel::Fatal);
|
||||
|
||||
if (warningCounter > 0)
|
||||
if (warningCounter > 0) {
|
||||
LWARNINGC("Logging", "Number of Warnings raised: " << warningCounter);
|
||||
if (errorCounter > 0)
|
||||
}
|
||||
if (errorCounter > 0) {
|
||||
LWARNINGC("Logging", "Number of Errors raised: " << errorCounter);
|
||||
if (fatalCounter > 0)
|
||||
}
|
||||
if (fatalCounter > 0) {
|
||||
LWARNINGC("Logging", "Number of Fatals raised: " << fatalCounter);
|
||||
}
|
||||
|
||||
LogMgr.resetMessageCounters();
|
||||
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix) {
|
||||
LTRACE("OpenSpaceEngine::render(begin)");
|
||||
_renderEngine->render(projectionMatrix, viewMatrix);
|
||||
|
||||
for (const auto& func : _moduleCallbacks.render) {
|
||||
func();
|
||||
}
|
||||
|
||||
LTRACE("OpenSpaceEngine::render(end)");
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postDraw() {
|
||||
_renderEngine->postDraw();
|
||||
|
||||
for (const auto& func : _moduleCallbacks.postDraw) {
|
||||
func();
|
||||
}
|
||||
|
||||
bool showGui = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true;
|
||||
if (showGui) {
|
||||
_renderEngine->renderScreenLog();
|
||||
if (_console->isVisible())
|
||||
_console->render();
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_isMaster && _windowWrapper->isRegularRendering())
|
||||
_gui->endFrame();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_isInShutdownMode) {
|
||||
@@ -1007,14 +940,13 @@ void OpenSpaceEngine::postDraw() {
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) {
|
||||
if (_isMaster) {
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->keyCallback(key, mod, action);
|
||||
if (isConsumed) {
|
||||
for (const auto& func : _moduleCallbacks.keyboard) {
|
||||
bool consumed = func(key, mod, action);
|
||||
if (consumed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (key == _console->commandInputButton()) {
|
||||
if (action == KeyAction::Press) {
|
||||
_console->toggleMode();
|
||||
@@ -1029,13 +961,13 @@ void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction actio
|
||||
|
||||
void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) {
|
||||
if (_isMaster) {
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->charCallback(codepoint, modifier);
|
||||
if (isConsumed)
|
||||
for (const auto& func : _moduleCallbacks.character) {
|
||||
bool consumed = func(codepoint, modifier);
|
||||
if (consumed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_console->isVisible()) {
|
||||
_console->charCallback(codepoint, modifier);
|
||||
}
|
||||
@@ -1044,32 +976,36 @@ void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier)
|
||||
|
||||
void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action) {
|
||||
if (_isMaster) {
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->mouseButtonCallback(button, action);
|
||||
if (isConsumed /*&& action != MouseAction::Release*/)
|
||||
for (const auto& func : _moduleCallbacks.mouseButton) {
|
||||
bool consumed = func(button, action);
|
||||
if (consumed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_interactionHandler->mouseButtonCallback(button, action);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mousePositionCallback(double x, double y) {
|
||||
if (_isMaster) {
|
||||
for (const auto& func : _moduleCallbacks.mousePosition) {
|
||||
func(x, y);
|
||||
}
|
||||
|
||||
_interactionHandler->mousePositionCallback(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseScrollWheelCallback(double pos) {
|
||||
if (_isMaster) {
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->mouseWheelCallback(pos);
|
||||
if (isConsumed)
|
||||
for (const auto& func : _moduleCallbacks.mouseScrollWheel) {
|
||||
bool consumed = func(pos);
|
||||
if (consumed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_interactionHandler->mouseScrollWheelCallback(pos);
|
||||
}
|
||||
}
|
||||
@@ -1088,8 +1024,9 @@ void OpenSpaceEngine::decode() {
|
||||
void OpenSpaceEngine::externalControlCallback(const char* receivedChars, int size,
|
||||
int clientId)
|
||||
{
|
||||
if (size == 0)
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_networkEngine->handleMessage(std::string(receivedChars, size));
|
||||
}
|
||||
@@ -1144,6 +1081,37 @@ void OpenSpaceEngine::enableBarrier() {
|
||||
void OpenSpaceEngine::disableBarrier() {
|
||||
_windowWrapper->setBarrier(false);
|
||||
}
|
||||
|
||||
|
||||
void OpenSpaceEngine::registerModuleKeyboardCallback(
|
||||
std::function<bool (Key, KeyModifier, KeyAction)> function)
|
||||
{
|
||||
_moduleCallbacks.keyboard.push_back(std::move(function));
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::registerModuleCharCallback(
|
||||
std::function<bool (unsigned int, KeyModifier)> function)
|
||||
{
|
||||
_moduleCallbacks.character.push_back(std::move(function));
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::registerModuleMouseButtonCallback(
|
||||
std::function<bool (MouseButton, MouseAction)> function)
|
||||
{
|
||||
_moduleCallbacks.mouseButton.push_back(std::move(function));
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::registerModuleMousePositionCallback(
|
||||
std::function<void (double, double)> function)
|
||||
{
|
||||
_moduleCallbacks.mousePosition.push_back(std::move(function));
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::registerModuleMouseScrollWheelCallback(
|
||||
std::function<bool (double)> function)
|
||||
{
|
||||
_moduleCallbacks.mouseScrollWheel.push_back(std::move(function));
|
||||
}
|
||||
|
||||
NetworkEngine& OpenSpaceEngine::networkEngine() {
|
||||
ghoul_assert(_networkEngine, "NetworkEngine must not be nullptr");
|
||||
@@ -1185,13 +1153,6 @@ LuaConsole& OpenSpaceEngine::console() {
|
||||
return *_console;
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
gui::GUI& OpenSpaceEngine::gui() {
|
||||
ghoul_assert(_gui, "GUI must not be nullptr");
|
||||
return *_gui;
|
||||
}
|
||||
#endif
|
||||
|
||||
ParallelConnection& OpenSpaceEngine::parallelConnection() {
|
||||
ghoul_assert(_parallelConnection, "ParallelConnection must not be nullptr");
|
||||
return *_parallelConnection;
|
||||
@@ -1224,6 +1185,10 @@ TimeManager& OpenSpaceEngine::timeManager() {
|
||||
ghoul_assert(_timeManager, "Download Manager must not be nullptr");
|
||||
return *_timeManager;
|
||||
}
|
||||
|
||||
|
||||
SettingsEngine& OpenSpaceEngine::settingsEngine() {
|
||||
ghoul_assert(_settingsEngine, "Settings Engine must not be nullptr");
|
||||
return *_settingsEngine;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -54,10 +54,6 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#endif
|
||||
|
||||
#include "scene_doc.inl"
|
||||
#include "scene_lua.inl"
|
||||
|
||||
|
||||
@@ -66,6 +66,10 @@ void OpenSpaceModule::deinitialize() {
|
||||
std::vector<Documentation> OpenSpaceModule::documentations() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
scripting::LuaLibrary OpenSpaceModule::luaLibrary() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version
|
||||
OpenSpaceModule::requiredOpenGLVersion() const
|
||||
|
||||
@@ -229,6 +229,17 @@ def check_glm_header(lines, file):
|
||||
else:
|
||||
return ''
|
||||
|
||||
def check_core_dependency(lines, component):
|
||||
if component != "openspace_core":
|
||||
return ''
|
||||
|
||||
index = [i for i,s in enumerate(lines) if 'OPENSPACE_MODULE_' in s]
|
||||
|
||||
if len(index) > 0:
|
||||
return lines[index[0]][:-1]
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
||||
previousSymbols = {}
|
||||
def check_header_file(file, component):
|
||||
@@ -255,7 +266,6 @@ def check_header_file(file, component):
|
||||
print(file, '\t', 'Filename styling check failed', '\t', styling_filename)
|
||||
return
|
||||
|
||||
|
||||
comment = check_comment(lines)
|
||||
if comment:
|
||||
print(file, '\t', 'Comment check failed', '\t', comment)
|
||||
@@ -278,16 +288,20 @@ def check_header_file(file, component):
|
||||
|
||||
duplicates, symbol = check_duplicates(lines, previousSymbols)
|
||||
if not duplicates:
|
||||
print(file, '\t', 'Duplicate include guard', symbol, 'first in', previousSymbols[symbol])
|
||||
print(file, '\t', 'Duplicate include guard', symbol, 'first in', previousSymbols[symbol])
|
||||
return
|
||||
else:
|
||||
previousSymbols[symbol] = file
|
||||
|
||||
header = check_glm_header(lines, file)
|
||||
if header:
|
||||
print(file, '\t', 'Illegal glm header include', header)
|
||||
print(file, '\t', 'Illegal glm header include', header)
|
||||
return
|
||||
|
||||
core_dependency = check_core_dependency(lines, component)
|
||||
if core_dependency:
|
||||
print(file, '\t' 'Wrong core dependency', core_dependency)
|
||||
|
||||
|
||||
def check_source_file(file, component):
|
||||
with open(file, 'r+') as f:
|
||||
@@ -298,6 +312,10 @@ def check_source_file(file, component):
|
||||
print(file, '\t', 'Illegal glm header include', header)
|
||||
return
|
||||
|
||||
core_dependency = check_core_dependency(lines, component)
|
||||
if core_dependency:
|
||||
print(file, '\t' 'Wrong core dependency', core_dependency)
|
||||
|
||||
|
||||
|
||||
def check_files(positiveList, negativeList, component, check_function):
|
||||
|
||||
Reference in New Issue
Block a user