Modularized the base classes

This commit is contained in:
Alexander Bock
2015-05-20 19:19:10 +02:00
parent fdead75cfa
commit 523abd6529
61 changed files with 438 additions and 99 deletions

View File

@@ -145,6 +145,7 @@ endif ()
#########################################################################################
add_subdirectory(src)
add_subdirectory(modules/base)
option(BUILD_GUI_APPLICATIONS "Build GUI Applications" OFF)
if (BUILD_GUI_APPLICATIONS)

View File

@@ -0,0 +1,50 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __MODULEENGINE_H__
#define __MODULEENGINE_H__
#include <vector>
namespace openspace {
class OpenSpaceModule;
class ModuleEngine {
public:
bool initialize();
bool deinitialize();
void registerModules(std::vector<OpenSpaceModule*> modules);
void registerModule(OpenSpaceModule* module);
const std::vector<OpenSpaceModule*> modules() const;
protected:
std::vector<OpenSpaceModule*> _modules;
};
} // namespace openspace
#endif // __MODULEENGINE_H__

View File

@@ -44,6 +44,7 @@ class NetworkEngine;
class GUI;
class RenderEngine;
class SyncBuffer;
class ModuleEngine;
namespace interaction {
class InteractionHandler;
@@ -71,6 +72,7 @@ public:
scripting::ScriptEngine* scriptEngine();
NetworkEngine* networkEngine();
LuaConsole* console();
ModuleEngine* moduleEngine();
gui::GUI* gui();
@@ -116,6 +118,7 @@ private:
NetworkEngine* _networkEngine;
ghoul::cmdparser::CommandlineParser* _commandlineParser;
LuaConsole* _console;
ModuleEngine* _moduleEngine;
gui::GUI* _gui;
bool _isMaster;

View File

@@ -0,0 +1,50 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACEMODULE_H__
#define __OPENSPACEMODULE_H__
#include <string>
namespace openspace {
class OpenSpaceModule {
public:
OpenSpaceModule() = default;
virtual ~OpenSpaceModule() = default;
virtual bool initialize() { return true; }
virtual bool deinitialize() { return true; }
std::string name() const { return _name; }
protected:
void setName(std::string name) { _name = std::move(name); }
std::string _name;
};
} // namespace openspace
#endif // __OPENSPACEMODULE_H__

View File

@@ -0,0 +1,46 @@
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefieldlines.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepath.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplane.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesphere.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesphericalgrid.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/wavefrontgeometry.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefieldlines.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepath.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplane.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesphere.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesphericalgrid.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/wavefrontgeometry.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
set(MODULE_CLASS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/basemodule.h
${CMAKE_CURRENT_SOURCE_DIR}/basemodule.cpp
)
include_directories(${OPENSPACE_BASE_DIR}/include ${OPENSPACE_BASE_DIR})
add_library(openspace-module-base ${HEADER_FILES} ${SOURCE_FILES} ${MODULE_CLASS_FILES})

View File

@@ -0,0 +1,88 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/basemodule.h>
#include <openspace/rendering/renderable.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/misc/assert.h>
#include <modules/base/rendering/renderablemodel.h>
#include <modules/base/rendering/renderableconstellationbounds.h>
#include <modules/base/rendering/renderablestars.h>
#include <modules/base/rendering/renderabletrail.h>
#include <modules/base/rendering/renderablepath.h>
#include <modules/base/rendering/renderablesphere.h>
#include <modules/base/rendering/renderablesphericalgrid.h>
#include <modules/base/rendering/renderablefieldlines.h>
#include <modules/base/rendering/renderablecrawlingline.h>
#include <modules/base/rendering/renderableplanet.h>
#include <modules/base/rendering/simplespheregeometry.h>
#include <modules/base/rendering/renderableplane.h>
#include <modules/base/rendering/simplespheregeometry.h>
#include <modules/base/rendering/modelgeometry.h>
#include <modules/base/rendering/wavefrontgeometry.h>
namespace {
const std::string _loggerCat = "BaseModule";
}
namespace openspace {
bool BaseModule::initialize() {
FactoryManager::ref().addFactory(new ghoul::TemplateFactory<planetgeometry::PlanetGeometry>);
FactoryManager::ref().addFactory(new ghoul::TemplateFactory<modelgeometry::ModelGeometry>);
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "No renderable factory existed");
fRenderable->registerClass<RenderablePlanet>("RenderablePlanet");
fRenderable->registerClass<RenderableStars>("RenderableStars");
fRenderable->registerClass<RenderableConstellationBounds>("RenderableConstellationBounds");
fRenderable->registerClass<RenderablePath>("RenderablePath");
fRenderable->registerClass<RenderableTrail>("RenderableTrail");
fRenderable->registerClass<RenderableSphere>("RenderableSphere");
fRenderable->registerClass<RenderableSphericalGrid>("RenderableSphericalGrid");
fRenderable->registerClass<RenderableModel>("RenderableModel");
fRenderable->registerClass<RenderablePlane>("RenderablePlane");
fRenderable->registerClass<RenderableFieldlines>("RenderableFieldlines");
fRenderable->registerClass<RenderableCrawlingLine>("RenderableCrawlingLine");
auto fPlanetGeometry = FactoryManager::ref().factory<planetgeometry::PlanetGeometry>();
ghoul_assert(fPlanetGeometry, "No planet geometry factory existed");
fPlanetGeometry->registerClass<planetgeometry::SimpleSphereGeometry>("SimpleSphere");
auto fModelGeometry = FactoryManager::ref().factory<modelgeometry::ModelGeometry>();
ghoul_assert(fModelGeometry, "No model geometry factory existed");
fModelGeometry->registerClass<modelgeometry::WavefrontGeometry>("WavefrontGeometry");
return true;
}
bool BaseModule::deinitialize() {
return false;
}
} // namespace openspace

40
modules/base/basemodule.h Normal file
View File

@@ -0,0 +1,40 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __BASEMODULE_H__
#define __BASEMODULE_H__
#include <openspace/util/openspacemodule.h>
namespace openspace {
class BaseModule : public OpenSpaceModule {
public:
bool initialize() override;
bool deinitialize() override;
};
} // namespace openspace
#endif // __BASEMODULE_H__

View File

@@ -22,14 +22,14 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/model/modelgeometry.h>
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/constants.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <fstream>
#include <openspace/rendering/model/wavefrontgeometry.h>
#include <modules/base/rendering/wavefrontgeometry.h>
namespace {
const std::string _loggerCat = "ModelGeometry";

View File

@@ -26,7 +26,7 @@
#define __MODELGEOMETRY_H__
#include <openspace/properties/propertyowner.h>
#include <openspace/rendering/model/renderablemodel.h>
#include <modules/base/rendering/renderablemodel.h>
#include <ghoul/misc/dictionary.h>
namespace openspace {

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/planets/planetgeometry.h>
#include <modules/base/rendering/planetgeometry.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/constants.h>
#include <openspace/util/factorymanager.h>

View File

@@ -26,7 +26,7 @@
#define __PLANETGEOMETRY_H__
#include <openspace/properties/propertyowner.h>
#include <openspace/rendering/planets/renderableplanet.h>
#include <modules/base/rendering/renderableplanet.h>
#include <ghoul/misc/dictionary.h>
namespace openspace {

View File

@@ -23,7 +23,7 @@
****************************************************************************************/
// openspace
#include <openspace/rendering/stars/renderableconstellationbounds.h>
#include <modules/base/rendering/renderableconstellationbounds.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>

View File

@@ -22,13 +22,13 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderablecrawlingline.h>
#include <modules/base/rendering/renderablecrawlingline.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/imagesequencer2.h>
#include <imgui.h>
//#include <imgui.h>
namespace {
const std::string _loggerCat = "RenderableCrawlingLine";

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderablefieldlines.h>
#include <modules/base/rendering/renderablefieldlines.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/powerscaledcoordinate.h>
#include <openspace/util/kameleonwrapper.h>

View File

@@ -26,9 +26,9 @@
// ie after I see model on screen)
// open space includes
#include <openspace/rendering/model/renderablemodel.h>
#include <modules/base/rendering/renderablemodel.h>
#include <openspace/util/constants.h>
#include <openspace/rendering/model/modelgeometry.h>
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/engine/configurationmanager.h>
#include <ghoul/io/texture/texturereader.h>
@@ -41,7 +41,6 @@
#include <openspace/engine/openspaceengine.h>
#include <sgct.h>
#include "imgui.h"
#define _USE_MATH_DEFINES
#include <math.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderablepath.h>
#include <modules/base/rendering/renderablepath.h>
#include <openspace/util/time.h>
#include <openspace/util/constants.h>

View File

@@ -23,7 +23,7 @@
****************************************************************************************/
#include <openspace/engine/configurationmanager.h>
#include <openspace/rendering/renderableplane.h>
#include <modules/base/rendering/renderableplane.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/powerscaledcoordinate.h>
#include <openspace/util/constants.h>

View File

@@ -23,11 +23,11 @@
****************************************************************************************/
// open space includes
#include <openspace/rendering/planets/renderableplanet.h>
#include <modules/base/rendering/renderableplanet.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/planets/planetgeometry.h>
#include <modules/base/rendering/planetgeometry.h>
#include <openspace/util/constants.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderablesphere.h>
#include <modules/base/rendering/renderablesphere.h>
#include <openspace/util/constants.h>
#include <openspace/engine/openspaceengine.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderablesphericalgrid.h>
#include <modules/base/rendering/renderablesphericalgrid.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*****************************************************************************************/
#include <openspace/rendering/stars/renderablestars.h>
#include <modules/base/rendering/renderablestars.h>
#include <openspace/util/updatestructures.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderabletrail.h>
#include <modules/base/rendering/renderabletrail.h>
#include <openspace/util/time.h>
#include <openspace/util/constants.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/planets/simplespheregeometry.h>
#include <modules/base/rendering/simplespheregeometry.h>
#include <openspace/util/constants.h>
#include <openspace/util/powerscaledsphere.h>

View File

@@ -25,7 +25,7 @@
#ifndef __SIMPLESPHEREGEOMETRY_H__
#define __SIMPLESPHEREGEOMETRY_H__
#include <openspace/rendering/planets/planetgeometry.h>
#include <modules/base/rendering/planetgeometry.h>
#include <openspace/properties/vectorproperty.h>
#include <openspace/properties/scalarproperty.h>

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/model/wavefrontgeometry.h>
#include <modules/base/rendering/wavefrontgeometry.h>
#include <openspace/util/constants.h>
#include "ghoul/logging/logmanager.h"

View File

@@ -25,7 +25,7 @@
#ifndef __WAVEFRONTGEOMETRY_H__
#define __WAVEFRONTGEOMETRY_H__
#include <openspace/rendering/model/modelgeometry.h>
#include <modules/base/rendering/modelgeometry.h>
namespace openspace {

View File

@@ -7,7 +7,7 @@ return {
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
-- of all entities that will be visible during an instance of OpenSpace
Scene = "${OPENSPACE_DATA}/scene/default_nh.scene",
Scene = "${OPENSPACE_DATA}/scene/default.scene",
Paths = {
SGCT = "${BASE_PATH}/config/sgct",

View File

@@ -151,7 +151,11 @@ if (UNIX AND NOT APPLE)
endif (UNIX AND NOT APPLE)
set(DEPENDENT_LIBS ${DEPENDENT_LIBS} openspace-module-base)
message(${DEPENDENT_LIBS})
include_directories("${HEADER_ROOT_DIR}")
include_directories("${OPENSPACE_BASE_DIR}")
add_executable(OpenSpace ${SOURCE_ROOT_DIR}/main.cpp ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE})
target_link_libraries(OpenSpace ${DEPENDENT_LIBS})

View File

@@ -0,0 +1,76 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/engine/moduleengine.h>
#include <openspace/util/openspacemodule.h>
#include <ghoul/logging/logmanager.h>
namespace {
const std::string _loggerCat = "ModuleEngine";
}
namespace openspace {
bool ModuleEngine::initialize() {
LDEBUG("Initializing modules");
for (OpenSpaceModule* m : _modules) {
bool success = m->initialize();
if (!success) {
LERROR("Could not initialize module '" << m->name() << "'");
return false;
}
}
LDEBUG("Finished initializing modules");
return true;
}
bool ModuleEngine::deinitialize() {
LDEBUG("Deinitializing modules");
for (OpenSpaceModule* m : _modules) {
bool success = m->deinitialize();
if (!success) {
LERROR("Could not deinitialize module '" << m->name() << "'");
return false;
}
}
LDEBUG("Finished Deinitializing modules");
return true;
}
void ModuleEngine::registerModules(std::vector<OpenSpaceModule*> modules) {
_modules.insert(_modules.end(), modules.begin(), modules.end());
}
void ModuleEngine::registerModule(OpenSpaceModule* module) {
_modules.push_back(std::move(module));
}
const std::vector<OpenSpaceModule*> ModuleEngine::modules() const {
return _modules;
}
} // namespace openspace

View File

@@ -46,7 +46,7 @@
#include <openspace/util/spicemanager.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/util/imagesequencer2.h> // testing
#include <openspace/engine/moduleengine.h>
#include <ghoul/cmdparser/commandlineparser.h>
@@ -89,6 +89,7 @@ namespace {
} commandlineArgumentPlaceholders;
}
#include <modules/base/basemodule.h>
namespace openspace {
@@ -102,14 +103,19 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName)
, _networkEngine(new NetworkEngine)
, _commandlineParser(new ghoul::cmdparser::CommandlineParser(programName, true))
, _console(new LuaConsole)
, _moduleEngine(new ModuleEngine)
, _gui(new gui::GUI)
, _isMaster(false)
, _syncBuffer(nullptr)
{
SpiceManager::initialize();
Time::initialize();
FactoryManager::initialize();
ghoul::systemcapabilities::SystemCapabilities::initialize();
FactoryManager::initialize();
SpiceManager::initialize();
Time::initialize();
ghoul::systemcapabilities::SystemCapabilities::initialize();
// Register modules
_moduleEngine->registerModule(new BaseModule);
_moduleEngine->initialize();
}
OpenSpaceEngine::~OpenSpaceEngine() {
@@ -122,6 +128,7 @@ OpenSpaceEngine::~OpenSpaceEngine() {
delete _networkEngine;
delete _commandlineParser;
delete _console;
delete _moduleEngine;
delete _gui;
if(_syncBuffer)
@@ -259,6 +266,7 @@ bool OpenSpaceEngine::create(
}
void OpenSpaceEngine::destroy() {
_engine->_moduleEngine->deinitialize();
_engine->_console->deinitialize();
delete _engine;
ghoul::systemcapabilities::SystemCapabilities::deinitialize();
@@ -745,4 +753,8 @@ NetworkEngine* OpenSpaceEngine::networkEngine() {
return _networkEngine;
}
ModuleEngine* OpenSpaceEngine::moduleEngine() {
return _moduleEngine;
}
} // namespace openspace

View File

@@ -41,7 +41,8 @@
#include <openspace/util/time.h>
#include <openspace/util/screenlog.h>
#include <openspace/util/spicemanager.h>
#include <openspace/rendering/renderablepath.h>
//#include <openspace/rendering/renderablepath.h>
#include <modules/base/rendering/renderablepath.h>
#include <openspace/util/syncbuffer.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/sharedmemory.h>

View File

@@ -377,7 +377,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
// the camera position
const SceneGraphNode* fn = OsEng.interactionHandler()->focusNode();
//psc relative = fn->worldPosition() - c->position();
// Check crash for when fn == nullptr
glm::mat4 la = glm::lookAt(cameraPosition.vec3(), fn->worldPosition().vec3(), c->lookUpVector());

View File

@@ -47,8 +47,9 @@ namespace {
namespace openspace {
SceneGraph::SceneGraph() {
}
SceneGraph::SceneGraph()
: _rootNode(nullptr)
{}
void SceneGraph::clear() {
// Untested ---abock
@@ -58,6 +59,7 @@ void SceneGraph::clear() {
}
_nodes.clear();
_rootNode = nullptr;
}
bool SceneGraph::loadFromFile(const std::string& sceneDescription) {

View File

@@ -79,6 +79,7 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
if (result->_renderable == nullptr) {
LERROR("Failed to create renderable for SceneGraphNode '"
<< result->name() << "'");
delete result;
return nullptr;
}
result->addPropertySubOwner(result->_renderable);
@@ -92,6 +93,7 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
if (result->_ephemeris == nullptr) {
LERROR("Failed to create ephemeris for SceneGraphNode '"
<< result->name() << "'");
delete result;
return nullptr;
}
//result->addPropertySubOwner(result->_ephemeris);

View File

@@ -25,24 +25,25 @@
#include <openspace/util/factorymanager.h>
// renderables
#include <openspace/rendering/model/renderablemodel.h>
#include <openspace/rendering/stars/renderableconstellationbounds.h>
#include <openspace/rendering/stars/renderablestars.h>
#include <openspace/rendering/renderabletrail.h>
#include <openspace/rendering/renderablepath.h>
#include <openspace/rendering/renderablefov.h>
#include <openspace/rendering/renderablesphere.h>
#include <openspace/rendering/renderablesphericalgrid.h>
#include <openspace/rendering/renderablefieldlines.h>
#include <openspace/rendering/renderablecrawlingline.h>
#include <openspace/rendering/planets/renderableplanet.h>
#include <openspace/rendering/planets/simplespheregeometry.h>
#include <openspace/rendering/renderableplane.h>
#include <openspace/rendering/renderableplaneprojection.h>
#include <openspace/rendering/renderablevolumegl.h>
#include <openspace/rendering/planets/simplespheregeometry.h>
#include <openspace/rendering/model/modelgeometry.h>
#include <openspace/rendering/model/wavefrontgeometry.h>
#include <openspace/rendering/renderable.h>
//#include <openspace/rendering/model/renderablemodel.h>
//#include <openspace/rendering/stars/renderableconstellationbounds.h>
//#include <openspace/rendering/stars/renderablestars.h>
//#include <openspace/rendering/renderabletrail.h>
//#include <openspace/rendering/renderablepath.h>
//#include <openspace/rendering/renderablefov.h>
//#include <openspace/rendering/renderablesphere.h>
//#include <openspace/rendering/renderablesphericalgrid.h>
//#include <openspace/rendering/renderablefieldlines.h>
//#include <openspace/rendering/renderablecrawlingline.h>
//#include <openspace/rendering/planets/renderableplanet.h>
//#include <openspace/rendering/planets/simplespheregeometry.h>
//#include <openspace/rendering/renderableplane.h>
//#include <openspace/rendering/renderableplaneprojection.h>
//#include <openspace/rendering/renderablevolumegl.h>
//#include <openspace/rendering/planets/simplespheregeometry.h>
//#include <openspace/rendering/model/modelgeometry.h>
//#include <openspace/rendering/model/wavefrontgeometry.h>
// positioninformation
#include <openspace/scene/staticephemeris.h>
@@ -50,9 +51,9 @@
#include <openspace/scene/spiceephemeris.h>
// projection
#include <openspace/rendering/planets/renderableplanetprojection.h>
#include <openspace/rendering/planets/simplespheregeometryprojection.h>
#include <openspace/rendering/planets/planetgeometryprojection.h>
//#include <openspace/rendering/planets/renderableplanetprojection.h>
//#include <openspace/rendering/planets/simplespheregeometryprojection.h>
//#include <openspace/rendering/planets/planetgeometryprojection.h>
#include <openspace/util/decoder.h>
#include <openspace/util/instrumentdecoder.h>
@@ -73,37 +74,7 @@ void FactoryManager::initialize()
_manager = new FactoryManager;
assert(_manager != nullptr);
// TODO: This has to be moved into a sort of module structure (ab)
// Add Renderables
_manager->addFactory(new ghoul::TemplateFactory<Renderable>);
_manager->factory<Renderable>()->registerClass<RenderablePlanet>("RenderablePlanet");
_manager->factory<Renderable>()->registerClass<RenderablePlanetProjection>("RenderablePlanetProjection");
_manager->factory<Renderable>()->registerClass<RenderableStars>("RenderableStars");
_manager->factory<Renderable>()->registerClass<RenderableConstellationBounds>
("RenderableConstellationBounds");
//will replace ephemeris class soon...
_manager->factory<Renderable>()->registerClass<RenderablePath>(
"RenderablePath");
_manager->factory<Renderable>()->registerClass<RenderableTrail>(
"RenderableTrail");
_manager->factory<Renderable>()->registerClass<RenderableFov>(
"RenderableFov");
_manager->factory<Renderable>()->registerClass<RenderableSphere>(
"RenderableSphere");
_manager->factory<Renderable>()->registerClass<RenderableSphericalGrid>(
"RenderableSphericalGrid");
_manager->factory<Renderable>()->registerClass<RenderableModel>(
"RenderableModel");
_manager->factory<Renderable>()->registerClass<RenderablePlane>(
"RenderablePlane");
_manager->factory<Renderable>()->registerClass<RenderablePlaneProjection>(
"RenderablePlaneProjection");
_manager->factory<Renderable>()->registerClass<RenderableVolumeGL>(
"RenderableVolumeGL");
_manager->factory<Renderable>()->registerClass<RenderableFieldlines>(
"RenderableFieldlines");
_manager->factory<Renderable>()->registerClass<RenderableCrawlingLine>(
"RenderableCrawlingLine");
// Add Ephemerides
_manager->addFactory(new ghoul::TemplateFactory<Ephemeris>);
@@ -116,20 +87,14 @@ void FactoryManager::initialize()
_manager->factory<Decoder>()->registerClass<TargetDecoder>("Target");
// Add PlanetGeometry
_manager->addFactory(new ghoul::TemplateFactory<planetgeometry::PlanetGeometry>);
_manager->factory<planetgeometry::PlanetGeometry>()
->registerClass<planetgeometry::SimpleSphereGeometry>("SimpleSphere");
// Add PlanetGeometryProjection
_manager->addFactory(new ghoul::TemplateFactory<planetgeometryprojection::PlanetGeometryProjection>);
_manager->factory<planetgeometryprojection::PlanetGeometryProjection>()
->registerClass<planetgeometryprojection::SimpleSphereGeometryProjection>("SimpleSphereProjection");
// Add ModelGeometry
_manager->addFactory(new ghoul::TemplateFactory<modelgeometry::ModelGeometry>);
_manager->factory<modelgeometry::ModelGeometry>()
->registerClass<modelgeometry::WavefrontGeometry>("WavefrontGeometry");
//_manager->addFactory(new ghoul::TemplateFactory<planetgeometry::PlanetGeometry>);
//_manager->addFactory(new ghoul::TemplateFactory<modelgeometry::ModelGeometry>);
//// Add PlanetGeometryProjection
//_manager->addFactory(new ghoul::TemplateFactory<planetgeometryprojection::PlanetGeometryProjection>);
//_manager->factory<planetgeometryprojection::PlanetGeometryProjection>()
// ->registerClass<planetgeometryprojection::SimpleSphereGeometryProjection>("SimpleSphereProjection");
}
void FactoryManager::deinitialize()