From 2d145faced808b2863996629e7cbcd056680beb2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 11:46:54 +0200 Subject: [PATCH 01/28] Set the fisheye border color to black --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index e2340f90e9..7adc2126a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,6 +106,8 @@ int main(int argc, char** argv) { _sgctEngine->setExternalControlCallback(mainExternalControlCallback); _sgctEngine->setCharCallbackFunction(mainCharCallback); + _sgctEngine->setFisheyeClearColor(0.f, 0.f, 0.f); + // set encode and decode functions // NOTE: starts synchronizing before init functions sgct::SharedData::instance()->setEncodeFunction(mainEncodeFun); From fc3faab5f1f1593c25ca72ee0831f95f0f43e222 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 20:33:22 +0200 Subject: [PATCH 02/28] Replace commandline argument with automatically detecting the supported OpenGL version --- include/openspace/engine/openspaceengine.h | 2 +- src/engine/openspaceengine.cpp | 15 +------- src/main.cpp | 44 ++++++++++++++-------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 11f1eee190..08a25948d9 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -59,7 +59,7 @@ namespace scripting { class OpenSpaceEngine { public: - static bool create(int argc, char** argv, std::vector& sgctArguments, std::string& openGlVersion); + static bool create(int argc, char** argv, std::vector& sgctArguments); static void destroy(); static OpenSpaceEngine& ref(); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 7197d9249d..d38555a20e 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -96,7 +96,6 @@ namespace { struct { std::string configurationName; std::string sgctConfigurationName; - std::string openGlVersion; } commandlineArgumentPlaceholders; } @@ -148,8 +147,7 @@ OpenSpaceEngine& OpenSpaceEngine::ref() { bool OpenSpaceEngine::create( int argc, char** argv, - std::vector& sgctArguments, - std::string& openGlVersion) + std::vector& sgctArguments) { ghoul::initialize(); @@ -260,10 +258,6 @@ bool OpenSpaceEngine::create( sgctConfigurationPath = commandlineArgumentPlaceholders.sgctConfigurationName; } - openGlVersion = commandlineArgumentPlaceholders.openGlVersion; - if (openGlVersion != DefaultOpenGlVersion) - LINFO("Using OpenGL version " << openGlVersion); - // Prepend the outgoing sgctArguments with the program name // as well as the configuration file that sgct is supposed to use sgctArguments.insert(sgctArguments.begin(), argv[0]); @@ -401,13 +395,6 @@ bool OpenSpaceEngine::gatherCommandlineArguments() { "the OpenSpace configuration file"); _commandlineParser->addCommand(sgctConfigFileCommand); - commandlineArgumentPlaceholders.openGlVersion = DefaultOpenGlVersion; - CommandlineCommand* openGlVersionCommand = new SingleCommand( - &commandlineArgumentPlaceholders.openGlVersion, - "-ogl", "-o", - "Sets the OpenGL version that is to be used; valid values are '4.2' and '4.3'"); - _commandlineParser->addCommand(openGlVersionCommand); - return true; } diff --git a/src/main.cpp b/src/main.cpp index 7adc2126a2..117e7d435f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,21 @@ void mainDecodeFun(); void mainExternalControlCallback(const char * receivedChars, int size); void mainLogCallback(const char* msg); +std::pair supportedOpenGLVersion () { + glfwInit(); + glfwWindowHint(GLFW_VISIBLE, GL_FALSE); + GLFWwindow* offscreen = glfwCreateWindow(128, 128, "", nullptr, nullptr); + glfwMakeContextCurrent(offscreen); + + int major, minor; + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + + glfwDestroyWindow(offscreen); + glfwWindowHint(GLFW_VISIBLE, GL_TRUE); + return { major, minor }; +} + //temporary post-FX functions, TODO make a more permanent solution to this @JK void postFXPass(); void setupPostFX(); @@ -60,13 +75,13 @@ namespace { } int main(int argc, char** argv) { + auto glVersion = supportedOpenGLVersion(); + // create the OpenSpace engine and get arguments for the sgct engine std::vector sgctArguments; - std::string openGlVersion = ""; const bool success = openspace::OpenSpaceEngine::create( argc, argv, - sgctArguments, - openGlVersion + sgctArguments ); if (!success) return EXIT_FAILURE; @@ -115,21 +130,20 @@ int main(int argc, char** argv) { // try to open a window LDEBUG("Initialize SGCT Engine"); -#ifdef __APPLE__ - sgct::Engine::RunMode rm = sgct::Engine::RunMode::OpenGL_4_1_Core_Profile; -#else - std::map versionMapping = { - { "4.2", sgct::Engine::RunMode::OpenGL_4_2_Core_Profile }, - { "4.3", sgct::Engine::RunMode::OpenGL_4_3_Core_Profile }, - { "4.4", sgct::Engine::RunMode::OpenGL_4_4_Core_Profile }, - { "4.5", sgct::Engine::RunMode::OpenGL_4_5_Core_Profile } + std::map, sgct::Engine::RunMode> versionMapping = { + { { 3, 3 }, sgct::Engine::RunMode::OpenGL_3_3_Core_Profile }, + { { 4, 0 }, sgct::Engine::RunMode::OpenGL_4_0_Core_Profile }, + { { 4, 1 }, sgct::Engine::RunMode::OpenGL_4_1_Core_Profile }, + { { 4, 2 }, sgct::Engine::RunMode::OpenGL_4_2_Core_Profile }, + { { 4, 3 }, sgct::Engine::RunMode::OpenGL_4_3_Core_Profile }, + { { 4, 4 }, sgct::Engine::RunMode::OpenGL_4_4_Core_Profile }, + { { 4, 5 }, sgct::Engine::RunMode::OpenGL_4_5_Core_Profile } }; - if (versionMapping.find(openGlVersion) == versionMapping.end()) { - LFATAL("Requested OpenGL version " << openGlVersion << " not supported"); + if (versionMapping.find(glVersion) == versionMapping.end()) { + LFATAL("Requested OpenGL version " << glVersion.first << "." << glVersion.second << " not supported"); return EXIT_FAILURE; } - sgct::Engine::RunMode rm = versionMapping[openGlVersion]; -#endif + sgct::Engine::RunMode rm = versionMapping[glVersion]; const bool initSuccess = _sgctEngine->init(rm); if (!initSuccess) { LFATAL("Initializing failed"); From 1923558f6ce48dd4c7d05ac9f7221ce69a6eac4c Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 20:43:53 +0200 Subject: [PATCH 03/28] Fix OpenSpaceTest --- tests/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/main.cpp b/tests/main.cpp index ede4213fc6..cf285d1568 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -53,8 +53,7 @@ namespace { int main(int argc, char** argv) { std::vector args; - std::string glVersion; - openspace::OpenSpaceEngine::create(argc, argv, args, glVersion); + openspace::OpenSpaceEngine::create(argc, argv, args); //LogManager::initialize(LogManager::LogLevel::Debug); From 37a54ab22b586b342fe7a625e4bdda30f8841df4 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 20:44:12 +0200 Subject: [PATCH 04/28] Move specification of RenderingMethod into renderengine --- include/openspace/rendering/renderengine.h | 2 +- src/engine/openspaceengine.cpp | 14 +++++--------- src/rendering/renderengine.cpp | 10 +++++++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 8466028514..4056dc2e56 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -51,7 +51,7 @@ public: RenderEngine(); ~RenderEngine(); - bool initialize(const std::string& renderingMethod); + bool initialize(); void setSceneGraph(Scene* sceneGraph); Scene* scene(); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index d38555a20e..dcbb2d859e 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -86,11 +86,6 @@ namespace { const std::string _sgctConfigArgumentCommand = "-config"; - const std::string KeyRenderingMethod = "RenderingMethod"; - const std::string DefaultRenderingMethod = "ABufferSingleLinked"; - - const std::string DefaultOpenGlVersion = "4.3"; - const int CacheVersion = 1; struct { @@ -336,10 +331,11 @@ bool OpenSpaceEngine::initialize() { _renderEngine->setSceneGraph(sceneGraph); // initialize the RenderEngine - if (_configurationManager->hasKeyAndValue(KeyRenderingMethod)) - _renderEngine->initialize(_configurationManager->value(KeyRenderingMethod)); - else - _renderEngine->initialize(DefaultRenderingMethod); + _renderEngine->initialize(); + // if (_configurationManager->hasKeyAndValue(KeyRenderingMethod)) + // _renderEngine->initialize(_configurationManager->value(KeyRenderingMethod)); + // else + // _renderEngine->initialize(DefaultRenderingMethod); sceneGraph->initialize(); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 60bcc157c4..63f2f0c28b 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #ifdef GHOUL_USE_DEVIL @@ -76,6 +77,9 @@ namespace { const std::string _loggerCat = "RenderEngine"; + const std::string KeyRenderingMethod = "RenderingMethod"; + const std::string DefaultRenderingMethod = "ABufferSingleLinked"; + const std::map RenderingMethods = { { "ABufferFrameBuffer", ABUFFER_FRAMEBUFFER}, { "ABufferSingleLinked", ABUFFER_SINGLE_LINKED }, @@ -130,7 +134,11 @@ RenderEngine::~RenderEngine() { ghoul::SharedMemory::remove(PerformanceMeasurementSharedData); } -bool RenderEngine::initialize(const std::string& renderingMethod) { +bool RenderEngine::initialize() { + std::string renderingMethod = DefaultRenderingMethod; + if (OsEng.configurationManager()->hasKeyAndValue(KeyRenderingMethod)) + renderingMethod = OsEng.configurationManager()->value(KeyRenderingMethod); + auto it = RenderingMethods.find(renderingMethod); if (it == RenderingMethods.end()) { LFATAL("Rendering method '" << renderingMethod << "' not among the available " From f9d4e0e1f1af97d8bba68fe675c78ef03ff8246a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 22:25:58 +0200 Subject: [PATCH 05/28] Clean test main.cpp --- tests/main.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/tests/main.cpp b/tests/main.cpp index cf285d1568..40252d4f44 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -55,25 +55,6 @@ int main(int argc, char** argv) { std::vector args; openspace::OpenSpaceEngine::create(argc, argv, args); - - //LogManager::initialize(LogManager::LogLevel::Debug); - //LogMgr.addLog(new ConsoleLog); - - //FileSystem::initialize(); - //std::string configurationFilePath = ""; - //LDEBUG("Finding configuration"); - //if (!openspace::OpenSpaceEngine::findConfiguration(configurationFilePath)) { - // LFATAL("Could not find OpenSpace configuration file!"); - // assert(false); - //} - ////LINFO("Configuration file found: " << FileSys.absolutePath(configurationFilePath)); - - //openspace::ConfigurationManager manager; - //manager.loadFromFile(configurationFilePath); - - - //openspace::FactoryManager::initialize(); - testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } From 4373cb2fbc3511e5a2939242bb3d4777bd59f83d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 22:35:49 +0200 Subject: [PATCH 06/28] Update ghoul version --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index c660e8dd75..1b751cb854 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit c660e8dd75beae2a827cbc04d19987e45b23f4fb +Subproject commit 1b751cb854857effa7ba7648476633913bb60d6c From f8fedb4426aa7103a36716332ea267096bd574dd Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 28 May 2015 22:50:37 +0200 Subject: [PATCH 07/28] Move openspace-data to data --- .gitmodules | 4 ++-- openspace-data => data | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename openspace-data => data (100%) diff --git a/.gitmodules b/.gitmodules index e78869f917..60281862f8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,8 @@ [submodule "ext/ghoul"] path = ext/ghoul url = https://github.com/OpenSpace/Ghoul.git -[submodule "openspace-data"] - path = openspace-data +[submodule "data"] + path = data url = git@openspace.itn.liu.se:/openspace-data [submodule "modules/kameleon/ext/kameleon"] path = modules/kameleon/ext/kameleon diff --git a/openspace-data b/data similarity index 100% rename from openspace-data rename to data From 2efe1d0dc4011596728dff26a9a5b78cf893d18e Mon Sep 17 00:00:00 2001 From: Joakim Kilby Date: Wed, 3 Jun 2015 10:13:29 +0200 Subject: [PATCH 08/28] Fixed the function to get supported OGL version so that it works on OS X --- src/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 117e7d435f..f2a8805202 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,17 @@ void mainLogCallback(const char* msg); std::pair supportedOpenGLVersion () { glfwInit(); + + //On OS X we need to explicitly set the version and specify that we are using CORE profile + //to be able to use glGetIntegerv(GL_MAJOR_VERSION, &major) and glGetIntegerv(GL_MINOR_VERSION, &minor) + //explicitly setting to OGL 3.3 CORE works since all Mac's now support at least 3.3 +#if __APPLE__ + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); +#endif + glfwWindowHint(GLFW_VISIBLE, GL_FALSE); GLFWwindow* offscreen = glfwCreateWindow(128, 128, "", nullptr, nullptr); glfwMakeContextCurrent(offscreen); From a9e3044d6ad0a39a72211e5dbe3a3bd4ee1928d5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 3 Jun 2015 12:36:20 +0200 Subject: [PATCH 09/28] Changed openspace-data file token to point to correct data folder Print detected OpenGL version --- openspace.cfg | 2 +- src/main.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openspace.cfg b/openspace.cfg index 1fb1965c3e..2f7446833a 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -14,7 +14,7 @@ return { SCRIPTS = "${BASE_PATH}/scripts", SHADERS = "${BASE_PATH}/shaders", SHADERS_GENERATED = "${SHADERS}/generated", - OPENSPACE_DATA = "${BASE_PATH}/openspace-data", + OPENSPACE_DATA = "${BASE_PATH}/data", MODULES = "${BASE_PATH}/modules", TESTDIR = "${BASE_PATH}/tests", CONFIG = "${BASE_PATH}/config", diff --git a/src/main.cpp b/src/main.cpp index f2a8805202..0edbe2edc9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,6 +96,8 @@ int main(int argc, char** argv) { ); if (!success) return EXIT_FAILURE; + + LINFO("Detected OpenGL version: " << glVersion.first << "." << glVersion.second); // create sgct engine c arguments int newArgc = static_cast(sgctArguments.size()); From 8ad7702b75d108b87c6988ff9c9764a7e21cf109 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 3 Jun 2015 13:31:42 +0200 Subject: [PATCH 10/28] Automatically detect which rendering method to use based on the available OpenGL version --- ext/ghoul | 2 +- include/openspace/abuffer/abuffer.h | 1 - openspace.cfg | 3 +-- src/engine/openspaceengine.cpp | 2 +- src/rendering/renderengine.cpp | 15 ++++++++++++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 1b751cb854..712da50047 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 1b751cb854857effa7ba7648476633913bb60d6c +Subproject commit 712da500477f762a443c09fd23198e93f3958a7a diff --git a/include/openspace/abuffer/abuffer.h b/include/openspace/abuffer/abuffer.h index 82d50e37dd..f8e1550a29 100644 --- a/include/openspace/abuffer/abuffer.h +++ b/include/openspace/abuffer/abuffer.h @@ -45,7 +45,6 @@ namespace openspace { class ABuffer { public: - struct fragmentData { GLfloat _position[3]; GLfloat _color[4]; diff --git a/openspace.cfg b/openspace.cfg index 2f7446833a..7b156a7b68 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -53,6 +53,5 @@ return { Type = "text", File = "${BASE_PATH}/Properties.txt" }, - RenderingMethod = "ABufferSingleLinked" -- On Windows and Unix - -- RenderingMethod = "ABufferFrameBuffer" -- On Mac due to OpenGL 4.1 restrictions + -- RenderingMethod = "ABufferFrameBuffer" } \ No newline at end of file diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index dcbb2d859e..6264d9db7c 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -289,7 +289,7 @@ bool OpenSpaceEngine::initialize() { SysCap.addComponent(new ghoul::systemcapabilities::OpenGLCapabilitiesComponent); SysCap.detectCapabilities(); SysCap.logCapabilities(); - + // Load SPICE time kernel bool success = loadSpiceKernels(); if (!success) diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 63f2f0c28b..f4677942f7 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #ifdef GHOUL_USE_DEVIL @@ -136,8 +138,19 @@ RenderEngine::~RenderEngine() { bool RenderEngine::initialize() { std::string renderingMethod = DefaultRenderingMethod; - if (OsEng.configurationManager()->hasKeyAndValue(KeyRenderingMethod)) + bool overwritingDefaultRenderingMethod = false; + if (OsEng.configurationManager()->hasKeyAndValue(KeyRenderingMethod)) { renderingMethod = OsEng.configurationManager()->value(KeyRenderingMethod); + overwritingDefaultRenderingMethod = true; + } + else { + using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version; + + if (OpenGLCap.openGLVersion() < Version(4,3)) { + LINFO("Falling back to framebuffer implementation due to OpenGL limitations"); + renderingMethod = "ABufferFrameBuffer"; + } + } auto it = RenderingMethods.find(renderingMethod); if (it == RenderingMethods.end()) { From f3b18d53f1f29312dbbb0cfe0974d0eae0ebd0f2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 3 Jun 2015 15:56:51 +0200 Subject: [PATCH 11/28] Make the moduleregistration file not depend on the absolute path --- support/cmake/module_definition.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/support/cmake/module_definition.cmake b/support/cmake/module_definition.cmake index 59b381864f..ee16a9e8dd 100644 --- a/support/cmake/module_definition.cmake +++ b/support/cmake/module_definition.cmake @@ -189,8 +189,11 @@ endfunction () function (write_module_name module_name) string(TOLOWER ${module_name} module_name_lower) + set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${module_name_lower}module.h) + string(REPLACE "${OPENSPACE_BASE_DIR}/" "" MODULE_PATH ${MODULE_PATH}) + file(WRITE ${CMAKE_BINARY_DIR}/modules/${module_name_lower}/modulename.cmake "set(MODULE_NAME ${module_name}Module)\n" - "set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${module_name_lower}module.h)" + "set(MODULE_PATH ${MODULE_PATH})" ) endfunction () From 68ef7c939cb18808ae61b72acc396c33f0017263 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 3 Jun 2015 17:45:05 +0200 Subject: [PATCH 12/28] Cleanup moduleregistration file --- support/cmake/module_registration.template | 4 +--- support/cmake/support_macros.cmake | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/support/cmake/module_registration.template b/support/cmake/module_registration.template index 58d73f69a7..5349553d0b 100644 --- a/support/cmake/module_registration.template +++ b/support/cmake/module_registration.template @@ -6,12 +6,10 @@ #define __MODULE_REGISTRATION_H__ @MODULE_HEADERS@ - namespace openspace { std::vector AllModules = { -@MODULE_CLASSES@ -}; +@MODULE_CLASSES@}; } // namespace openspace diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index 048f9249f3..1c538ad3fc 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -324,10 +324,7 @@ function (handle_internal_modules) #"#endif\n\n" ) - list(APPEND MODULE_CLASSES - "new ${MODULE_NAME},\n" - ) - + list(APPEND MODULE_CLASSES " new ${MODULE_NAME},\n") endif () endforeach () From 7492fa2f6ccd33a2ef1e59bd0b798e11a36efcdf Mon Sep 17 00:00:00 2001 From: Michal Marcinkowski Date: Wed, 3 Jun 2015 19:10:34 -0400 Subject: [PATCH 13/28] New Additions: Shadow cylinders extending from planet terminator in opposite dir of sun Plane that displays the global texture map of a planet as projections appear ^latter is an addition to RenderablePlane class, a renderable plane can have boolean keyword "ProjectionListener" - determines whether or not it displays --- data | 2 +- include/openspace/util/spicemanager.h | 36 ++++ modules/base/rendering/renderableplane.cpp | 36 +++- modules/base/rendering/renderableplane.h | 2 + modules/newhorizons/newhorizonsmodule.cpp | 2 + .../newhorizons/rendering/renderablefov.cpp | 12 +- .../rendering/renderableplanetprojection.h | 2 +- .../rendering/renderableshadowcylinder.cpp | 202 ++++++++++++++++++ .../rendering/renderableshadowcylinder.h | 97 +++++++++ .../shaders/terminatorshadow_fs.glsl | 47 ++++ .../shaders/terminatorshadow_vs.glsl | 60 ++++++ scripts/bind_keys.lua | 2 + scripts/default_settings.lua | 1 + src/util/spicemanager.cpp | 39 ++++ 14 files changed, 530 insertions(+), 10 deletions(-) create mode 100644 modules/newhorizons/rendering/renderableshadowcylinder.cpp create mode 100644 modules/newhorizons/rendering/renderableshadowcylinder.h create mode 100644 modules/newhorizons/shaders/terminatorshadow_fs.glsl create mode 100644 modules/newhorizons/shaders/terminatorshadow_vs.glsl diff --git a/data b/data index 54af421ff5..f3928948f2 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 54af421ff583392c559748983251da6521c73c8a +Subproject commit f3928948f25ac520240a4c7a6ac280b278ddf3b7 diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index c03113dc79..a0d2a1001c 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -630,6 +630,42 @@ public: */ bool getFieldOfView(int instrument, std::string& fovShape, std::string& frameName, glm::dvec3& boresightVector, std::vector& bounds) const; + + /** + This routine computes a set of points on the umbral or penumbral terminator of + a specified target body, where SPICE models the target shape as an ellipsoid. + \param numberOfPoints - number of points along terminator returned by this method + \param terminatorType - is a string indicating the type of terminator to compute: + umbral or penumbral. The umbral terminator is the boundary of the portion of the + ellipsoid surface in total shadow. The penumbral terminator is the boundary of + the portion of the surface that is completely illuminated. Note that in astronomy + references, the unqualified word "terminator" refers to the umbral terminator. + Here, the unqualified word refers to either type of terminator. + \param lightSource - name of body acting as light source + \param observer - name of bodserving body + \param target - name of target body + \param frame - name of the reference frame relative to which the output terminator + points are expressed. + \param aberrationCorrection - correction for light time and/or stellar aberration + \param ephemerisTime - the epoch of participation of the observer + \param targetEpoch - is the "target epoch.", time it takes for + \param observerPosition - is the vector from the target body at targetEpoch + \param terminatorPoints - an array of points on the umbral or penumbral terminator + of the ellipsoid, as specified by the input argument `numberOfPoints' + For further, more specific details please refer to + http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/edterm_c.html + */ + bool getTerminatorEllipse(const int numberOfPoints, + const std::string terminatorType, + const std::string lightSource, + const std::string observer, + const std::string target, + const std::string frame, + const std::string aberrationCorrection, + double ephemerisTime, + double& targetEpoch, + glm::dvec3& observerPosition, + std::vector& terminatorPoints); /** * This function adds a frame to a body diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 4bb27bf458..ef7108646b 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -28,6 +28,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -51,6 +55,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _texturePath("texture", "Texture") , _billboard("billboard", "Billboard", false) + , _projectionListener("projectionListener", "DisplayProjections", false) , _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f)) , _origin(Origin::Center) , _shader(nullptr) @@ -63,6 +68,10 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) dictionary.getValue("Size", size); _size = size; + if (dictionary.hasKey("Name")){ + dictionary.getValue("Name", _nodeName); + } + std::string origin; if (dictionary.getValue("Origin", origin)) { if (origin == "LowerLeft") { @@ -87,6 +96,13 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) if (dictionary.getValue("Billboard", billboard)) { _billboard = billboard; } + if (dictionary.hasKey("ProjectionListener")){ + bool projectionListener = false; + if (dictionary.getValue("ProjectionListener", projectionListener)) { + _projectionListener = projectionListener; + } + } + std::string texturePath = ""; bool success = dictionary.getValue("Texture", texturePath); @@ -147,8 +163,12 @@ bool RenderablePlane::deinitialize() { glDeleteBuffers(1, &_vertexPositionBuffer); _vertexPositionBuffer = 0; - delete _texture; - _texture = nullptr; + if (!_projectionListener){ + // its parents job to kill texture + // iff projectionlistener + delete _texture; + _texture = nullptr; + } delete _textureFile; _textureFile = nullptr; @@ -166,6 +186,18 @@ void RenderablePlane::render(const RenderData& data) { // Activate shader _shader->activate(); + if (_projectionListener){ + //get parent node-texture and set with correct dimensions + SceneGraphNode* textureNode = OsEng.renderEngine()->scene()->sceneGraphNode(_nodeName)->parent(); + if (textureNode != nullptr){ + RenderablePlanetProjection *t = static_cast(textureNode->renderable()); + _texture = t->baseTexture(); + float h = _texture->height(); + float w = _texture->width(); + float scale = h / w; + transform = glm::scale(transform, glm::vec3(1.f, scale, 1.f)); + } + } _shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _shader->setUniform("ModelTransform", transform); diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index 60effc4c5e..e4301cd7f0 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -68,9 +68,11 @@ private: properties::StringProperty _texturePath; properties::BoolProperty _billboard; + properties::BoolProperty _projectionListener; properties::Vec2Property _size; Origin _origin; + std::string _nodeName; bool _planeIsDirty; diff --git a/modules/newhorizons/newhorizonsmodule.cpp b/modules/newhorizons/newhorizonsmodule.cpp index 4ec0ff04d6..8a1570fcf2 100644 --- a/modules/newhorizons/newhorizonsmodule.cpp +++ b/modules/newhorizons/newhorizonsmodule.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -63,6 +64,7 @@ bool NewHorizonsModule::initialize() { auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "No renderable factory existed"); + fRenderable->registerClass("RenderableShadowCylinder"); fRenderable->registerClass("RenderableCrawlingLine"); fRenderable->registerClass("RenderableFov"); fRenderable->registerClass("RenderablePlaneProjection"); diff --git a/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index 43e8a941a4..bc5f378de9 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -531,12 +531,12 @@ void RenderableFov::render(const RenderData& data) { psc position; double lt; SpiceManager::ref().getTargetPosition(_fovTarget, - _spacecraft, - _frame, - _aberrationCorrection, - _time, - position, - lt); + _spacecraft, + _frame, + _aberrationCorrection, + _time, + position, + lt); //if aimed 80 deg away from target, dont draw white square if (glm::dot(glm::normalize(aim), glm::normalize(position.vec3())) < 0.2){ diff --git a/modules/newhorizons/rendering/renderableplanetprojection.h b/modules/newhorizons/rendering/renderableplanetprojection.h index 01c8971fb3..de9a15d541 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.h +++ b/modules/newhorizons/rendering/renderableplanetprojection.h @@ -67,6 +67,7 @@ public: void render(const RenderData& data) override; void update(const UpdateData& data) override; + ghoul::opengl::Texture* baseTexture() { return _texture; }; protected: @@ -91,7 +92,6 @@ private: properties::BoolProperty _performProjection; properties::BoolProperty _clearAllProjections; - ghoul::opengl::ProgramObject* _programObject; ghoul::opengl::ProgramObject* _fboProgramObject; diff --git a/modules/newhorizons/rendering/renderableshadowcylinder.cpp b/modules/newhorizons/rendering/renderableshadowcylinder.cpp new file mode 100644 index 0000000000..e0cda86132 --- /dev/null +++ b/modules/newhorizons/rendering/renderableshadowcylinder.cpp @@ -0,0 +1,202 @@ +/***************************************************************************************** +* * +* 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +namespace { + const std::string _loggerCat = "RenderablePlane"; + const std::string _keyType = "TerminatorType"; + const std::string _keyLightSource = "LightSource"; + const std::string _keyObserver = "Observer"; + const std::string _keyBody = "Body"; + const std::string _keyBodyFrame = "BodyFrame"; + const std::string _keyMainFrame = "MainFrame"; + const std::string _keyAberration = "Aberration"; +} + +namespace openspace { + RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _numberOfPoints("amountOfPoints", "Points", 190, 1, 300) + , _shadowLength("shadowLength", "Shadow Length", 0.1, 0.0, 0.5) + , _shader(nullptr) + , _vao(0) + , _vbo(0) +{ + addProperty(_numberOfPoints); + addProperty(_shadowLength); + + bool success = dictionary.getValue(_keyType, _terminatorType); + ghoul_assert(success, ""); + success = dictionary.getValue(_keyLightSource, _lightSource); + ghoul_assert(success, ""); + success = dictionary.getValue(_keyObserver, _observer); + ghoul_assert(success, ""); + success = dictionary.getValue(_keyBody, _body); + ghoul_assert(success, ""); + success = dictionary.getValue(_keyBodyFrame, _bodyFrame); + ghoul_assert(success, ""); + success = dictionary.getValue(_keyMainFrame, _mainFrame); + ghoul_assert(success, ""); + success = dictionary.getValue(_keyAberration, _aberration); + ghoul_assert(success, ""); +} + +RenderableShadowCylinder::~RenderableShadowCylinder() { +} + +bool RenderableShadowCylinder::isReady() const { + bool ready = true; + if (!_shader) + ready &= false; + return ready; +} + +bool RenderableShadowCylinder::initialize() { + glGenVertexArrays(1, &_vao); // generate array + glGenBuffers(1, &_vbo); // generate buffer + createCylinder(); + + bool completeSuccess = true; + _shader = ghoul::opengl::ProgramObject::Build("ShadowProgram", + "${MODULE_NEWHORIZONS}/shaders/terminatorshadow_vs.glsl", + "${MODULE_NEWHORIZONS}/shaders/terminatorshadow_fs.glsl"); + if (!_shader) + return false; + return completeSuccess; +} + +bool RenderableShadowCylinder::deinitialize() { + glDeleteVertexArrays(1, &_vao); + _vao = 0; + glDeleteBuffers(1, &_vbo); + _vbo = 0; + delete _shader; + _shader = nullptr; + return true; +} + +void RenderableShadowCylinder::render(const RenderData& data){ + glm::mat4 _transform = glm::mat4(1.0); + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 3; j++){ + _transform[i][j] = static_cast(_stateMatrix[i][j]); + } + } + // Activate shader + _shader->activate(); + + _shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); + _shader->setUniform("ModelTransform", _transform); + setPscUniforms(_shader, &data.camera, data.position); + + glBindVertexArray(_vao); + glDrawArrays(GL_TRIANGLE_STRIP, 0, static_cast(_vertices.size())); + glBindVertexArray(0); + + _shader->deactivate(); +} + +void RenderableShadowCylinder::update(const UpdateData& data) { + openspace::SpiceManager::ref().getPositionTransformMatrix(_bodyFrame, _mainFrame, data.time, _stateMatrix); + _time = data.time; + if (_shader->isDirty()) + _shader->rebuildFromFile(); + createCylinder(); +} + +glm::vec4 psc_addition(glm::vec4 v1, glm::vec4 v2) { + float k = 10.f; + float ds = v2.w - v1.w; + if (ds >= 0) { + float p = pow(k, -ds); + return glm::vec4(v1.x*p + v2.x, v1.y*p + v2.y, v1.z*p + v2.z, v2.w); + } + else { + float p = pow(k, ds); + return glm::vec4(v1.x + v2.x*p, v1.y + v2.y*p, v1.z + v2.z*p, v1.w); + } +} + +void RenderableShadowCylinder::createCylinder() { + double targetEpoch; + glm::dvec3 observerPosition; + std::vector terminatorPoints; + SpiceManager::ref().getTerminatorEllipse(_numberOfPoints, + _terminatorType, + _lightSource, + _observer, + _body, + _bodyFrame, + _aberration, + _time, + targetEpoch, + observerPosition, + terminatorPoints); + + glm::dvec3 vecLightSource; + double lt; + bool performs = SpiceManager::ref().getTargetPosition(_body, _lightSource, _mainFrame, _aberration, _time, vecLightSource, lt); + + glm::dmat3 _stateMatrix; + openspace::SpiceManager::ref().getPositionTransformMatrix(_bodyFrame, _mainFrame, _time, _stateMatrix); + + _stateMatrix = glm::inverse(_stateMatrix); + vecLightSource = _stateMatrix * vecLightSource; + + vecLightSource *= _shadowLength; + _vertices.clear(); + + psc endpoint = psc::CreatePowerScaledCoordinate(vecLightSource.x, vecLightSource.y, vecLightSource.z); + for (auto v : terminatorPoints){ + _vertices.push_back(CylinderVBOLayout(v[0], v[1], v[2], v[3])); + glm::vec4 f = psc_addition(v.vec4(), endpoint.vec4()); + _vertices.push_back(CylinderVBOLayout(f[0], f[1], f[2], f[3])); + } + _vertices.push_back(_vertices[0]); + _vertices.push_back(_vertices[1]); + + glBindVertexArray(_vao); // bind array + glBindBuffer(GL_ARRAY_BUFFER, _vbo); // bind buffer + glBufferData(GL_ARRAY_BUFFER, _vertices.size() * sizeof(CylinderVBOLayout), NULL, GL_DYNAMIC_DRAW); // orphaning the buffer, sending NULL data. + glBufferSubData(GL_ARRAY_BUFFER, 0, _vertices.size() * sizeof(CylinderVBOLayout), &_vertices[0]); + + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); + glBindVertexArray(0); +} + +} // namespace openspace diff --git a/modules/newhorizons/rendering/renderableshadowcylinder.h b/modules/newhorizons/rendering/renderableshadowcylinder.h new file mode 100644 index 0000000000..b5caac7f9f --- /dev/null +++ b/modules/newhorizons/rendering/renderableshadowcylinder.h @@ -0,0 +1,97 @@ +/***************************************************************************************** + * * + * 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 RENDERABLESHADOWCYLINDER_H_ +#define RENDERABLESHADOWCYLINDER_H_ + +#include + +#include +#include +#include + +namespace ghoul { + namespace filesystem { + class File; + } + namespace opengl { + class ProgramObject; + class Texture; + } +} + +namespace openspace { + struct LinePoint; + class RenderableShadowCylinder : public Renderable { + + public: + RenderableShadowCylinder(const ghoul::Dictionary& dictionary); + ~RenderableShadowCylinder(); + + bool initialize() override; + bool deinitialize() override; + + bool isReady() const override; + + void render(const RenderData& data) override; + void update(const UpdateData& data) override; + + private: + struct CylinderVBOLayout { + CylinderVBOLayout(double a1, double a2, double a3, double a4){ + x = a1; + y = a2; + z = a3; + e = a4; + } + float x, y, z, e; + }; + + void createCylinder(); + properties::IntProperty _numberOfPoints; + properties::FloatProperty _shadowLength; + + ghoul::opengl::ProgramObject* _shader; + + glm::dmat3 _stateMatrix; + + GLuint _vao; + GLuint _vbo; + + std::vector _vertices; + + std::string _terminatorType; + std::string _lightSource; + std::string _observer; + std::string _body; + std::string _bodyFrame; + std::string _mainFrame; + std::string _aberration; + + double _time; + }; + +} // namespace openspace +#endif // RENDERABLESHADOWCYLINDER_H_ + diff --git a/modules/newhorizons/shaders/terminatorshadow_fs.glsl b/modules/newhorizons/shaders/terminatorshadow_fs.glsl new file mode 100644 index 0000000000..6fcfc4d90c --- /dev/null +++ b/modules/newhorizons/shaders/terminatorshadow_fs.glsl @@ -0,0 +1,47 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * 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. * + ****************************************************************************************/ + +#version __CONTEXT__ + +in vec4 vs_point_position; +in vec4 vs_point_velocity; +//in float fade; +//uniform float forceFade; + +uniform vec3 color; + +in vec4 vs_color; + +#include "ABuffer/abufferStruct.hglsl" +#include "ABuffer/abufferAddToBuffer.hglsl" +#include "PowerScaling/powerScaling_fs.hglsl" + +void main() { + vec4 position = vs_point_position; + float depth = pscDepth(position); + + vec4 c = vs_color; + ABufferStruct_t frag = createGeometryFragment(c, position, depth); + addToBuffer(frag); +} \ No newline at end of file diff --git a/modules/newhorizons/shaders/terminatorshadow_vs.glsl b/modules/newhorizons/shaders/terminatorshadow_vs.glsl new file mode 100644 index 0000000000..7f5398e74f --- /dev/null +++ b/modules/newhorizons/shaders/terminatorshadow_vs.glsl @@ -0,0 +1,60 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * 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. * + ****************************************************************************************/ + +#version __CONTEXT__ + +uniform mat4 ViewProjection; +uniform mat4 ModelTransform; +uniform vec4 objectVelocity; + + + +layout(location = 0) in vec4 in_point_position; + +out vec4 vs_point_position; +out vec4 vs_color; +//out float fade; + +uniform uint nVertices; +//uniform float lineFade; + +#include "PowerScaling/powerScaling_vs.hglsl" + +void main() { + //float id = float(gl_VertexID) / float(nVertices * lineFade); + //fade = 1.0 - id; + + if(mod(gl_VertexID,2) == 0.f){ + vs_color = vec4(1,1,1,0.5); + }else{ + vs_color = vec4(0); + } + + vec4 tmp = in_point_position; + //tmp = psc_to_meter(tmp, vec2(1,0.f)); + vec4 position = pscTransform(tmp, ModelTransform); + vs_point_position = tmp; + position = ViewProjection * position; + gl_Position = z_normalization(position); +} \ No newline at end of file diff --git a/scripts/bind_keys.lua b/scripts/bind_keys.lua index 2c7e85b413..63a4b18286 100644 --- a/scripts/bind_keys.lua +++ b/scripts/bind_keys.lua @@ -53,6 +53,8 @@ openspace.bindKey("6", "openspace.time.setTime('2015-07-14T12:04:35.00'); opensp openspace.bindKey("7", "openspace.time.setTime('2015-07-14T15:02:46.00'); openspace.time.setDeltaTime(100)") ]]-- +openspace.bindKey("i", "local b = openspace.getPropertyValue('PlutoTexture.renderable.enabled'); openspace.setPropertyValue('PlutoTexture.renderable.enabled', not b)") + openspace.bindKey("q", "local b = openspace.getPropertyValue('SunMarker.renderable.enabled'); openspace.setPropertyValue('SunMarker.renderable.enabled', not b)") openspace.bindKey("e", "local b = openspace.getPropertyValue('EarthMarker.renderable.enabled'); openspace.setPropertyValue('EarthMarker.renderable.enabled', not b)") diff --git a/scripts/default_settings.lua b/scripts/default_settings.lua index 38a6dcc523..0f3f2ffcb1 100644 --- a/scripts/default_settings.lua +++ b/scripts/default_settings.lua @@ -8,6 +8,7 @@ openspace.setPropertyValue("SunMarker.renderable.enabled", true) openspace.setPropertyValue("EarthMarker.renderable.enabled", true) openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false) openspace.setPropertyValue("PlutoTrail.renderable.enabled", false) +openspace.setPropertyValue("PlutoTexture.renderable.enabled", false) openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.75) openspace.setPropertyValue("MilkyWay.renderable.segments", 50) diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 1e5219021c..912d9f7cf2 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -957,6 +957,45 @@ bool SpiceManager::getFieldOfView(int instrument, return true; } +bool SpiceManager::getTerminatorEllipse(const int numberOfPoints, + const std::string terminatorType, + const std::string lightSource, + const std::string observer, + const std::string target, + const std::string frame, + const std::string aberrationCorrection, + double ephemerisTime, + double& targetEpoch, + glm::dvec3& observerPosition, + std::vector& terminatorPoints){ + + double(*tpoints)[3] = new double[numberOfPoints][3]; + + edterm_c(terminatorType.c_str(), + lightSource.c_str(), + target.c_str(), + ephemerisTime, + frame.c_str(), + aberrationCorrection.c_str(), + observer.c_str(), + numberOfPoints, + &targetEpoch, + glm::value_ptr(observerPosition), + (double(*)[3])tpoints ); + + bool hasError = checkForError("Error getting " + terminatorType + + "terminator for'" + target + "'"); + if (hasError) + return false; + + for (int i = 0; i < numberOfPoints; i++){ + psc point = psc::CreatePowerScaledCoordinate(tpoints[i][0], tpoints[i][1], tpoints[i][2]); + point[3] += 3; + terminatorPoints.push_back(point); + } + + return true; +} std::string SpiceManager::frameFromBody(const std::string body) const { From 16e09e5802fe29b2ad1d666fd4cd6894b1a61c0b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 4 Jun 2015 01:44:31 +0200 Subject: [PATCH 14/28] Remove static code analysis warnings --- modules/base/rendering/renderablepath.cpp | 4 ++-- src/rendering/renderengine.cpp | 14 ++++++++------ src/util/spicemanager.cpp | 16 +++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/base/rendering/renderablepath.cpp b/modules/base/rendering/renderablepath.cpp index 4321bcccf5..9ccdf8622b 100644 --- a/modules/base/rendering/renderablepath.cpp +++ b/modules/base/rendering/renderablepath.cpp @@ -212,7 +212,7 @@ void RenderablePath::calculatePath(std::string observer) { return; double lightTime; - bool correctPosition = true; +// bool correctPosition = true; psc pscPos; double currentTime = _start; @@ -222,7 +222,7 @@ void RenderablePath::calculatePath(std::string observer) { //float g = _lineColor[1]; //float b = _lineColor[2]; for (int i = 0; i < segments; i++) { - correctPosition = SpiceManager::ref().getTargetPosition(_target, observer, _frame, "NONE", currentTime, pscPos, lightTime); + SpiceManager::ref().getTargetPosition(_target, observer, _frame, "NONE", currentTime, pscPos, lightTime); pscPos[3] += 3; //if (!correctPosition) { diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index f4677942f7..d915d3d1bb 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -138,14 +138,15 @@ RenderEngine::~RenderEngine() { bool RenderEngine::initialize() { std::string renderingMethod = DefaultRenderingMethod; - bool overwritingDefaultRenderingMethod = false; - if (OsEng.configurationManager()->hasKeyAndValue(KeyRenderingMethod)) { + + // If the user specified a rendering method that he would like to use, use that + if (OsEng.configurationManager()->hasKeyAndValue(KeyRenderingMethod)) renderingMethod = OsEng.configurationManager()->value(KeyRenderingMethod); - overwritingDefaultRenderingMethod = true; - } else { using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version; - + + // The default rendering method has a requirement of OpenGL 4.3, so if we are + // below that, we will fall back to frame buffer operation if (OpenGLCap.openGLVersion() < Version(4,3)) { LINFO("Falling back to framebuffer implementation due to OpenGL limitations"); renderingMethod = "ABufferFrameBuffer"; @@ -329,7 +330,8 @@ void RenderEngine::postSynchronizationPreDraw() { } // converts the quaternion used to rotation matrices - _mainCamera->compileViewRotationMatrix(); + if (_mainCamera) + _mainCamera->compileViewRotationMatrix(); // update and evaluate the scene starting from the root node _sceneGraph->update({ diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 1e5219021c..9ac6933b6b 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -316,9 +316,9 @@ bool SpiceManager::getNaifId(const std::string& body, int& id) const { } else { SpiceBoolean success; - SpiceInt sid = id; - bods2c_c(body.c_str(), &sid, &success); - id = sid; +// SpiceInt sid = id; + bods2c_c(body.c_str(), &id, &success); +// id = sid; if (success == SPICEFALSE) LERROR("Could not find NAIF ID of body '" + body + "'"); return (success == SPICETRUE); @@ -331,9 +331,7 @@ bool SpiceManager::getFrameId(const std::string& frame, int& id) const { return false; } else { - SpiceInt sid = id; - namfrm_c(frame.c_str(), &sid); - id = sid; + namfrm_c(frame.c_str(), &id); bool hasError = SpiceManager::checkForError("Error getting id for frame '" + frame + "'"); return !hasError; } @@ -403,7 +401,7 @@ bool SpiceManager::getValue(const std::string& body, const std::string& value, } bool SpiceManager::spacecraftClockToET(const std::string& craftIdCode, double& craftTicks, double& et){ - int craftID; + int craftID = -1; getNaifId(craftIdCode, craftID); sct2e_c(craftID, craftTicks, &et); bool hasError = checkForError("Error transforming spacecraft clock of '" + craftIdCode + "' at time " + std::to_string(craftTicks)); @@ -1010,8 +1008,8 @@ bool SpiceManager::checkForError(std::string errorMessage) { bool SpiceManager::getPlanetEllipsoid(std::string planetName, float &a, float &b, float &c) { SpiceDouble radii[3]; - SpiceInt n; - int id; + SpiceInt n = -1; + int id = -1; getNaifId(planetName, id); if (bodfnd_c(id, "RADII")) { From 0069b88f7ca3bc9d12df1e234f3a6c18434a6654 Mon Sep 17 00:00:00 2001 From: Michal Marcinkowski Date: Wed, 3 Jun 2015 19:53:40 -0400 Subject: [PATCH 15/28] Fixing jenkins error --- modules/newhorizons/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/newhorizons/CMakeLists.txt b/modules/newhorizons/CMakeLists.txt index d25a88fd44..d2ae173fa3 100644 --- a/modules/newhorizons/CMakeLists.txt +++ b/modules/newhorizons/CMakeLists.txt @@ -25,6 +25,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometryprojection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.h @@ -45,6 +46,7 @@ set(HEADER_FILES source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometryprojection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.cpp @@ -64,6 +66,8 @@ set(SOURCE_FILES source_group("Source Files" FILES ${SOURCE_FILES}) set(SHADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_fs.glsl From 0953b35bb661854a99dfebedd9f960f3f091abab Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 4 Jun 2015 01:54:59 +0200 Subject: [PATCH 16/28] Add RenderableShadowCylinders to the New Horizons CMakeLists file --- modules/newhorizons/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/newhorizons/CMakeLists.txt b/modules/newhorizons/CMakeLists.txt index d25a88fd44..fa6a7a06b4 100644 --- a/modules/newhorizons/CMakeLists.txt +++ b/modules/newhorizons/CMakeLists.txt @@ -30,6 +30,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneprojection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanetprojection.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometryprojection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/writeToTexture.h ${CMAKE_CURRENT_SOURCE_DIR}/util/decoder.h @@ -50,6 +51,7 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneprojection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanetprojection.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometryprojection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/decoder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/hongkangparser.cpp @@ -70,6 +72,8 @@ set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectiveTexture_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectiveTexture_vs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_vs.glsl ) source_group("Shader Files" FILES ${SHADER_FILES}) From d8f7db46e85d38af3640cc5db9868035985840b8 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 4 Jun 2015 01:57:21 +0200 Subject: [PATCH 17/28] Fix CMakeLists to be in proper order --- modules/newhorizons/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/newhorizons/CMakeLists.txt b/modules/newhorizons/CMakeLists.txt index eb1e729a23..fa6a7a06b4 100644 --- a/modules/newhorizons/CMakeLists.txt +++ b/modules/newhorizons/CMakeLists.txt @@ -25,7 +25,6 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometryprojection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.h @@ -47,7 +46,6 @@ set(HEADER_FILES source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableshadowcylinder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometryprojection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.cpp @@ -68,8 +66,6 @@ set(SOURCE_FILES source_group("Source Files" FILES ${SOURCE_FILES}) set(SHADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_fs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/terminatorshadow_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_fs.glsl From 17498c28c637c54445b9929f61af5bebed918463 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 5 Jun 2015 01:45:15 +0200 Subject: [PATCH 18/28] Minor cleanups --- include/openspace/scripting/scriptengine.h | 2 +- src/engine/openspaceengine.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index f1f2e79754..e8aa0e0c52 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -92,7 +92,7 @@ private: lua_State* _state; std::set _registeredLibraries; - + //sync variables std::mutex _mutex; std::vector _queuedScripts; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 6264d9db7c..a1547d463a 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -484,7 +484,6 @@ void OpenSpaceEngine::runSettingsScripts() { runScripts(scripts); } - void OpenSpaceEngine::loadFonts() { sgct_text::FontManager::FontPath local = sgct_text::FontManager::FontPath::FontPath_Local; From a798edf19858738bee34cf7c82a85d41ffa4eeed Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 5 Jun 2015 16:27:31 +0200 Subject: [PATCH 19/28] Added missing space for a message logging of model geometry Update Ghoul --- ext/ghoul | 2 +- modules/base/rendering/modelgeometry.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 712da50047..03983ed78e 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 712da500477f762a443c09fd23198e93f3958a7a +Subproject commit 03983ed78edab3e068c2c3a1f4457a9a163f3161 diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index a390bae9a2..7630c78c30 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -155,7 +155,7 @@ bool ModelGeometry::loadObj(const std::string& filename){ // file for the next run } else { - LINFO("Cache for Model'" << filename << "' not found"); + LINFO("Cache for Model '" << filename << "' not found"); } LINFO("Loading Model file '" << filename << "'"); bool success = loadModel(filename); From d231a5f681a174d81e9a8311a54ae1d0a361a705 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 6 Jun 2015 11:48:07 +0200 Subject: [PATCH 20/28] Move openspace-based applications into their own subfolder --- CMakeLists.txt | 5 ++- apps/OpenSpace/CMakeLists.txt | 46 +++++++++++++++++++ {src => apps/OpenSpace}/main.cpp | 0 src/CMakeLists.txt | 4 -- support/cmake/support_macros.cmake | 72 +++++++++++++++++------------- 5 files changed, 91 insertions(+), 36 deletions(-) create mode 100644 apps/OpenSpace/CMakeLists.txt rename {src => apps/OpenSpace}/main.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8144a87665..87a8e22943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ project (OpenSpace) message(STATUS "Generating OpenSpace project") set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}") +set(OPENSPACE_APPS_DIR "${OPENSPACE_BASE_DIR}/apps") set(OPENSPACE_EXT_DIR "${OPENSPACE_BASE_DIR}/ext") set(OPENSPACE_MODULE_DIR "${OPENSPACE_BASE_DIR}/modules") set(OPENSPACE_CMAKE_EXT_DIR "${OPENSPACE_BASE_DIR}/support/cmake") @@ -48,9 +49,9 @@ option(OPENSPACE_BUILD_GUI_APPLICATIONS "Build GUI Applications" OFF) include(src/CMakeLists.txt) -create_openspace_targets() -set_compile_settings() +create_openspace_target() add_external_dependencies() +handle_applications() if (MSVC) option(OPENSPACE_ENABLE_VLD "Enable the Visual Leak Detector" OFF) diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt new file mode 100644 index 0000000000..066514f85b --- /dev/null +++ b/apps/OpenSpace/CMakeLists.txt @@ -0,0 +1,46 @@ +######################################################################################### +# # +# 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. # +######################################################################################### + +add_executable(OpenSpace ${OPENSPACE_APPS_DIR}/OpenSpace/main.cpp) +target_include_directories(OpenSpace PUBLIC ${OPENSPACE_BASE_DIR}/include) +target_link_libraries(OpenSpace libOpenSpace) + +if (MSVC) + if (OPENSPACE_WARNINGS_AS_ERRORS) + target_compile_options(OpenSpace PUBLIC "/WX") + endif () + + set_target_properties(OpenSpace PROPERTIES LINK_FLAGS + "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" + ) +elseif (APPLE) + if (OPENSPACE_WARNINGS_AS_ERRORS) + target_compile_options(OpenSpace PUBLIC "-Werror") + endif () +elseif (UNIX) + if (OPENSPACE_WARNINGS_AS_ERRORS) + target_compile_options(OpenSpace PUBLIC "-Werror") + endif () + target_compile_options(OpenSpace PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") +endif () diff --git a/src/main.cpp b/apps/OpenSpace/main.cpp similarity index 100% rename from src/main.cpp rename to apps/OpenSpace/main.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2c1f8518cb..f8134bd3b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,10 +83,6 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/util/time_lua.inl ) -set(OPENSPACE_MAIN - ${OPENSPACE_BASE_DIR}/src/main.cpp -) - set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abuffer.h ${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abufferdynamic.h diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index 1c538ad3fc..3029a03653 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -64,59 +64,51 @@ endfunction () -function (create_openspace_targets) +function (create_openspace_target) add_library(libOpenSpace STATIC ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE}) target_include_directories(libOpenSpace PUBLIC ${OPENSPACE_BASE_DIR}/include) target_include_directories(libOpenSpace PUBLIC ${OPENSPACE_BASE_DIR}) target_include_directories(libOpenSpace PUBLIC ${CMAKE_BINARY_DIR}/_generated/include) - add_executable(OpenSpace ${OPENSPACE_MAIN}) - target_include_directories(OpenSpace PUBLIC ${OPENSPACE_BASE_DIR}/include) - target_link_libraries(OpenSpace libOpenSpace) + set_compile_settings(libOpenSpace) endfunction () -function (set_compile_settings) +function (set_compile_settings project) if (MSVC) - target_compile_options(libOpenSpace PUBLIC "/MP" "/wd4201" "/wd4127") + target_compile_options(${project} PUBLIC "/MP" "/wd4201" "/wd4127") if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(libOpenSpace PUBLIC "/WX") - target_compile_options(OpenSpace PUBLIC "/WX") + target_compile_options(${project} PUBLIC "/WX") endif () - - set_target_properties(OpenSpace PROPERTIES LINK_FLAGS - "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" - ) elseif (APPLE) - target_compile_definitions(libOpenSpace PUBLIC "__APPLE__") + target_compile_definitions(${project} PUBLIC "__APPLE__") include (CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) mark_as_advanced(COMPILER_SUPPORTS_CXX11, COMPILER_SUPPORTS_CXX0X) if (COMPILER_SUPPORTS_CXX11) - target_compile_options(libOpenSpace PUBLIC "-std=c++11") + target_compile_options(${project} PUBLIC "-std=c++11") elseif (COMPILER_SUPPORTS_CXX0X) - target_compile_options(libOpenSpace PUBLIC "-std=c++0x") + target_compile_options(${project} PUBLIC "-std=c++0x") else () message(FATAL_ERROR "Compiler does not have C++11 support") endif () if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(libOpenSpace PUBLIC "-Werror") - target_compile_options(OpenSpace PUBLIC "-Werror") + target_compile_options(${project} PUBLIC "-Werror") endif () - target_compile_options(libOpenSpace PUBLIC "-stdlib=libc++") + target_compile_options(${project} PUBLIC "-stdlib=libc++") - target_include_directories(libOpenSpace PUBLIC "/Developer/Headers/FlatCarbon") + target_include_directories(${project} PUBLIC "/Developer/Headers/FlatCarbon") find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(CARBON_LIBRARY Carbon) find_library(COCOA_LIBRARY Carbon) find_library(APP_SERVICES_LIBRARY ApplicationServices) mark_as_advanced(CARBON_LIBRARY COCOA_LIBRARY APP_SERVICES_LIBRARY) - target_link_libraries(libOpenSpace + target_link_libraries(${project} ${CARBON_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COCOA_LIBRARY} @@ -128,20 +120,18 @@ function (set_compile_settings) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) mark_as_advanced(COMPILER_SUPPORTS_CXX11, COMPILER_SUPPORTS_CXX0X) if (COMPILER_SUPPORTS_CXX11) - target_compile_options(libOpenSpace PUBLIC "-std=c++11") + target_compile_options(${project} PUBLIC "-std=c++11") elseif (COMPILER_SUPPORTS_CXX0X) - target_compile_options(libOpenSpace PUBLIC "-std=c++0x") + target_compile_options(${project} PUBLIC "-std=c++0x") else () message(FATAL_ERROR "Compiler does not have C++11 support") endif () if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(libOpenSpace PUBLIC "-Werror") - target_compile_options(OpenSpace PUBLIC "-Werror") + target_compile_options(${project} PUBLIC "-Werror") endif () - target_compile_options(libOpenSpace PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") - target_compile_options(OpenSpace PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") + target_compile_options(${project} PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") endif () endfunction () @@ -172,18 +162,35 @@ function (add_external_dependencies) find_package(Spice REQUIRED) target_include_directories(libOpenSpace SYSTEM PUBLIC ${SPICE_INCLUDE_DIRS}) target_link_libraries(libOpenSpace ${SPICE_LIBRARIES}) - endfunction () +function (handle_applications) + set(applications "") + option(OPENSPACE_APPLICATION_OPENSPACE "Main OpenSpace Application" ON) + if (OPENSPACE_APPLICATION_OPENSPACE) + include(${OPENSPACE_APPS_DIR}/OpenSpace/CMakeLists.txt) + list(APPEND applications "OpenSpace") + endif () + set(OPENSPACE_APPLICATIONS ${applications} PARENT_SCOPE) + + message(STATUS "Applications:") + foreach (app ${applications}) + message(STATUS "\t${app}") + endforeach () +endfunction() + + function (handle_option_vld) if (OPENSPACE_ENABLE_VLD) target_compile_definitions(libOpenSpace PUBLIC "OPENSPACE_ENABLE_VLD") target_link_libraries(libOpenSpace ${OPENSPACE_EXT_DIR}/vld/lib/vld.lib) target_include_directories(libOpenSpace PUBLIC ${OPENSPACE_EXT_DIR}/vld) - copy_files(OpenSpace "${OPENSPACE_EXT_DIR}/vld/bin/vld_x64.dll") + foreach (app ${OPENSPACE_APPLCATIONS}) + copy_files(${app} "${OPENSPACE_EXT_DIR}/vld/bin/vld_x64.dll") + endforeach () endif () endfunction () @@ -298,7 +305,10 @@ function (handle_internal_modules) set(MODULE_HEADERS "") set(MODULE_CLASSES "") - message(STATUS ${sortedModules}) + message(STATUS "Included modules:") + foreach (module ${sortedModules}) + message(STATUS "\t${module}") + endforeach () # Add subdirectories in the correct order foreach (module ${sortedModules}) @@ -306,7 +316,9 @@ function (handle_internal_modules) if (${optionName}) create_library_name(${module} libraryName) add_subdirectory(${OPENSPACE_MODULE_DIR}/${module}) - target_link_libraries(OpenSpace ${libraryName}) + foreach (app ${OPENSPACE_APPLICATIONS}) + target_link_libraries(${app} ${libraryName}) + endforeach () target_link_libraries(libOpenSpace ${libraryName}) create_define_name(${module} defineName) target_compile_definitions(libOpenSpace PUBLIC "${defineName}") From e56d58a54899c40b21f145c1b41c874c2c36376e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 7 Jun 2015 19:15:45 +0200 Subject: [PATCH 21/28] Move timelineview application into app folder --- CMakeLists.txt | 2 +- apps/OpenSpace/CMakeLists.txt | 24 ++----- apps/TimelineView/CMakeLists.txt | 62 +++++++++++++++++ .../TimelineView}/common.h | 0 .../TimelineView}/configurationwidget.cpp | 0 .../TimelineView}/configurationwidget.h | 0 .../TimelineView}/controlwidget.cpp | 0 .../TimelineView}/controlwidget.h | 0 .../TimelineView}/informationwidget.cpp | 0 .../TimelineView}/informationwidget.h | 0 .../TimelineView}/main.cpp | 0 .../TimelineView}/mainwindow.cpp | 0 .../TimelineView}/mainwindow.h | 0 .../TimelineView}/timelinewidget.cpp | 0 .../TimelineView}/timelinewidget.h | 0 gui/CMakeLists.txt | 3 - gui/timelineview/CMakeLists.txt | 22 ------ support/cmake/support_macros.cmake | 69 ++++++++++++++++--- 18 files changed, 128 insertions(+), 54 deletions(-) create mode 100644 apps/TimelineView/CMakeLists.txt rename {gui/timelineview => apps/TimelineView}/common.h (100%) rename {gui/timelineview => apps/TimelineView}/configurationwidget.cpp (100%) rename {gui/timelineview => apps/TimelineView}/configurationwidget.h (100%) rename {gui/timelineview => apps/TimelineView}/controlwidget.cpp (100%) rename {gui/timelineview => apps/TimelineView}/controlwidget.h (100%) rename {gui/timelineview => apps/TimelineView}/informationwidget.cpp (100%) rename {gui/timelineview => apps/TimelineView}/informationwidget.h (100%) rename {gui/timelineview => apps/TimelineView}/main.cpp (100%) rename {gui/timelineview => apps/TimelineView}/mainwindow.cpp (100%) rename {gui/timelineview => apps/TimelineView}/mainwindow.h (100%) rename {gui/timelineview => apps/TimelineView}/timelinewidget.cpp (100%) rename {gui/timelineview => apps/TimelineView}/timelinewidget.h (100%) delete mode 100644 gui/CMakeLists.txt delete mode 100644 gui/timelineview/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 87a8e22943..f6735892f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ######################################################################################### -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required (VERSION 3.0 FATAL_ERROR) project (OpenSpace) message(STATUS "Generating OpenSpace project") diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 066514f85b..a49ee281e8 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -22,25 +22,15 @@ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ######################################################################################### -add_executable(OpenSpace ${OPENSPACE_APPS_DIR}/OpenSpace/main.cpp) -target_include_directories(OpenSpace PUBLIC ${OPENSPACE_BASE_DIR}/include) -target_link_libraries(OpenSpace libOpenSpace) +set(APPLICATION_NAME OpenSpace) +set(APPLICATION_LINK_TO_OPENSPACE ON) + +add_executable(${APPLICATION_NAME} ${OPENSPACE_APPS_DIR}/OpenSpace/main.cpp) +target_include_directories(${APPLICATION_NAME} PUBLIC ${OPENSPACE_BASE_DIR}/include) +target_link_libraries(${APPLICATION_NAME} libOpenSpace) if (MSVC) - if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(OpenSpace PUBLIC "/WX") - endif () - - set_target_properties(OpenSpace PROPERTIES LINK_FLAGS + set_target_properties(${APPLICATION_NAME} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" ) -elseif (APPLE) - if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(OpenSpace PUBLIC "-Werror") - endif () -elseif (UNIX) - if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(OpenSpace PUBLIC "-Werror") - endif () - target_compile_options(OpenSpace PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") endif () diff --git a/apps/TimelineView/CMakeLists.txt b/apps/TimelineView/CMakeLists.txt new file mode 100644 index 0000000000..284192421e --- /dev/null +++ b/apps/TimelineView/CMakeLists.txt @@ -0,0 +1,62 @@ +######################################################################################### +# # +# 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. # +######################################################################################### + +set(APPLICATION_NAME TimelineView) +set(APPLICATION_LINK_TO_OPENSPACE OFF) + +set(SOURCE_FILES + ${OPENSPACE_APPS_DIR}/TimelineView/main.cpp + ${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.cpp + ${OPENSPACE_APPS_DIR}/TimelineView/configurationwidget.cpp + ${OPENSPACE_APPS_DIR}/TimelineView/informationwidget.cpp + ${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.cpp + ${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.cpp +) + +set(HEADER_FILES + ${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.h + ${OPENSPACE_APPS_DIR}/TimelineView/configurationwidget.h + ${OPENSPACE_APPS_DIR}/TimelineView/informationwidget.h + ${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.h + ${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.h +) + +find_package(Qt5Widgets) +find_package(Qt5Network) + +qt5_wrap_cpp(MOC_FILES ${HEADER_FILES}) + +add_executable(${APPLICATION_NAME} MACOSX_BUNDLE ${SOURCE_FILES} ${HEADER_FILES} ${MOC_FILES}) + +target_link_libraries(${APPLICATION_NAME} + Qt5::Widgets + Qt5::Network +) + +if (APPLE) +INSTALL(CODE " + include(BundleUtilities) + fixup_bundle(\"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/MacOS/TimelineView\" \"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") + " COMPONENT Runtime) +endif () diff --git a/gui/timelineview/common.h b/apps/TimelineView/common.h similarity index 100% rename from gui/timelineview/common.h rename to apps/TimelineView/common.h diff --git a/gui/timelineview/configurationwidget.cpp b/apps/TimelineView/configurationwidget.cpp similarity index 100% rename from gui/timelineview/configurationwidget.cpp rename to apps/TimelineView/configurationwidget.cpp diff --git a/gui/timelineview/configurationwidget.h b/apps/TimelineView/configurationwidget.h similarity index 100% rename from gui/timelineview/configurationwidget.h rename to apps/TimelineView/configurationwidget.h diff --git a/gui/timelineview/controlwidget.cpp b/apps/TimelineView/controlwidget.cpp similarity index 100% rename from gui/timelineview/controlwidget.cpp rename to apps/TimelineView/controlwidget.cpp diff --git a/gui/timelineview/controlwidget.h b/apps/TimelineView/controlwidget.h similarity index 100% rename from gui/timelineview/controlwidget.h rename to apps/TimelineView/controlwidget.h diff --git a/gui/timelineview/informationwidget.cpp b/apps/TimelineView/informationwidget.cpp similarity index 100% rename from gui/timelineview/informationwidget.cpp rename to apps/TimelineView/informationwidget.cpp diff --git a/gui/timelineview/informationwidget.h b/apps/TimelineView/informationwidget.h similarity index 100% rename from gui/timelineview/informationwidget.h rename to apps/TimelineView/informationwidget.h diff --git a/gui/timelineview/main.cpp b/apps/TimelineView/main.cpp similarity index 100% rename from gui/timelineview/main.cpp rename to apps/TimelineView/main.cpp diff --git a/gui/timelineview/mainwindow.cpp b/apps/TimelineView/mainwindow.cpp similarity index 100% rename from gui/timelineview/mainwindow.cpp rename to apps/TimelineView/mainwindow.cpp diff --git a/gui/timelineview/mainwindow.h b/apps/TimelineView/mainwindow.h similarity index 100% rename from gui/timelineview/mainwindow.h rename to apps/TimelineView/mainwindow.h diff --git a/gui/timelineview/timelinewidget.cpp b/apps/TimelineView/timelinewidget.cpp similarity index 100% rename from gui/timelineview/timelinewidget.cpp rename to apps/TimelineView/timelinewidget.cpp diff --git a/gui/timelineview/timelinewidget.h b/apps/TimelineView/timelinewidget.h similarity index 100% rename from gui/timelineview/timelinewidget.h rename to apps/TimelineView/timelinewidget.h diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt deleted file mode 100644 index bcaf2ef502..0000000000 --- a/gui/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) - -add_subdirectory(timelineview) \ No newline at end of file diff --git a/gui/timelineview/CMakeLists.txt b/gui/timelineview/CMakeLists.txt deleted file mode 100644 index 241d78d868..0000000000 --- a/gui/timelineview/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) - -project(TimelineView) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -find_package(Qt5Widgets) -find_package(Qt5Network) -if (APPLE) -add_executable(TimelineView MACOSX_BUNDLE main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp controlwidget.cpp timelinewidget.cpp) -else (APPLE) -add_executable(TimelineView main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp controlwidget.cpp timelinewidget.cpp) -endif () - -target_link_libraries(TimelineView Qt5::Widgets Qt5::Network) - -if (APPLE) -INSTALL(CODE " - include(BundleUtilities) - fixup_bundle(\"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/MacOS/TimelineView\" \"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") - " COMPONENT Runtime) -endif () diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index 3029a03653..6b703962a2 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -168,17 +168,55 @@ endfunction () function (handle_applications) set(applications "") - option(OPENSPACE_APPLICATION_OPENSPACE "Main OpenSpace Application" ON) - if (OPENSPACE_APPLICATION_OPENSPACE) - include(${OPENSPACE_APPS_DIR}/OpenSpace/CMakeLists.txt) - list(APPEND applications "OpenSpace") - endif () + set(applications_link_to_openspace "") + + file(GLOB appDirs RELATIVE ${OPENSPACE_APPS_DIR} ${OPENSPACE_APPS_DIR}/*) + list(REMOVE_ITEM appDirs ".DS_Store") # Removing the .DS_Store present on Mac + + set(DEFAULT_APPLICATIONS + "OpenSpace" + ) + mark_as_advanced(DEFAULT_APPLICATIONS) + + foreach (app ${appDirs}) + string(TOUPPER ${app} upper_app) + list (FIND DEFAULT_APPLICATIONS "${app}" _index) + if (${_index} GREATER -1) + # App is a default application + option(OPENSPACE_APPLICATION_${upper_app} "${app} Application" ON) + else () + option(OPENSPACE_APPLICATION_${upper_app} "${app} Application" OFF) + endif() + if (OPENSPACE_APPLICATION_${upper_app}) + unset(APPLICATION_NAME) + unset(APPLICATION_LINK_TO_OPENSPACE) + include(${OPENSPACE_APPS_DIR}/${app}/CMakeLists.txt) + set_compile_settings(${APPLICATION_NAME}) + list(APPEND applications ${APPLICATION_NAME}) + list(APPEND applications_link_to_openspace ${APPLICATION_LINK_TO_OPENSPACE}) + unset(APPLICATION_NAME) + unset(APPLICATION_LINK_TO_OPENSPACE) + endif () + endforeach () + + + # option(OPENSPACE_APPLICATION_OPENSPACE "Main OpenSpace Application" ON) + # if (OPENSPACE_APPLICATION_OPENSPACE) + # include(${OPENSPACE_APPS_DIR}/OpenSpace/CMakeLists.txt) + # list(APPEND applications "OpenSpace") + # endif () set(OPENSPACE_APPLICATIONS ${applications} PARENT_SCOPE) + set(OPENSPACE_APPLICATIONS_LINK_REQUEST ${applications_link_to_openspace} PARENT_SCOPE) message(STATUS "Applications:") - foreach (app ${applications}) - message(STATUS "\t${app}") - endforeach () + list(LENGTH applications len1) + math(EXPR len2 "${len1} - 1") + + foreach(val RANGE ${len2}) + list(GET applications ${val} val1) + list(GET applications_link_to_openspace ${val} val2) + message(STATUS "\t${val1} (Link: ${val2})") + endforeach() endfunction() @@ -316,9 +354,18 @@ function (handle_internal_modules) if (${optionName}) create_library_name(${module} libraryName) add_subdirectory(${OPENSPACE_MODULE_DIR}/${module}) - foreach (app ${OPENSPACE_APPLICATIONS}) - target_link_libraries(${app} ${libraryName}) - endforeach () + + list(LENGTH OPENSPACE_APPLICATIONS len1) + math(EXPR len2 "${len1} - 1") + + foreach(val RANGE ${len2}) + list(GET OPENSPACE_APPLICATIONS ${val} val1) + list(GET OPENSPACE_APPLICATIONS_LINK_REQUEST ${val} val2) + if (${val2}) + target_link_libraries(${app} ${libraryName}) + endif () + endforeach() + target_link_libraries(libOpenSpace ${libraryName}) create_define_name(${module} defineName) target_compile_definitions(libOpenSpace PUBLIC "${defineName}") From 94ed72bce785023cd7e5694a402531c953aac4e3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 7 Jun 2015 19:19:20 +0200 Subject: [PATCH 22/28] Update copyright notice --- apps/TimelineView/main.cpp | 2 +- apps/TimelineView/mainwindow.cpp | 2 +- apps/TimelineView/mainwindow.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/TimelineView/main.cpp b/apps/TimelineView/main.cpp index f864703957..9bdce7b3ab 100644 --- a/apps/TimelineView/main.cpp +++ b/apps/TimelineView/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * 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 * diff --git a/apps/TimelineView/mainwindow.cpp b/apps/TimelineView/mainwindow.cpp index 242f916a53..87c030c662 100644 --- a/apps/TimelineView/mainwindow.cpp +++ b/apps/TimelineView/mainwindow.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * 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 * diff --git a/apps/TimelineView/mainwindow.h b/apps/TimelineView/mainwindow.h index 23d85fec0b..c998082e39 100644 --- a/apps/TimelineView/mainwindow.h +++ b/apps/TimelineView/mainwindow.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * 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 * From e17b39a851c128fea33b36f507f1118cc87d94d4 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 7 Jun 2015 19:20:56 +0200 Subject: [PATCH 23/28] Cleanup string generation --- apps/TimelineView/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/TimelineView/main.cpp b/apps/TimelineView/main.cpp index 9bdce7b3ab..463578f67e 100644 --- a/apps/TimelineView/main.cpp +++ b/apps/TimelineView/main.cpp @@ -149,8 +149,6 @@ int main(int argc, char** argv) { app.setStyleSheet(style); - std::string s = style.toStdString(); - MainWindow window; window.show(); From b19069547464c609e1e6a47d6f889965108605e2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 8 Jun 2015 01:08:58 +0200 Subject: [PATCH 24/28] Add initial version of launcher --- apps/Launcher/CMakeLists.txt | 66 +++++ apps/Launcher/files.qrc | 5 + apps/Launcher/images/header.png | Bin 0 -> 13192 bytes apps/Launcher/informationwidget.cpp | 29 +++ apps/Launcher/informationwidget.h | 36 +++ apps/Launcher/main.cpp | 155 ++++++++++++ apps/Launcher/mainwindow.cpp | 377 ++++++++++++++++++++++++++++ apps/Launcher/mainwindow.h | 82 ++++++ apps/Launcher/shortcutwidget.cpp | 29 +++ apps/Launcher/shortcutwidget.h | 36 +++ apps/Launcher/syncwidget.cpp | 25 ++ apps/Launcher/syncwidget.h | 34 +++ 12 files changed, 874 insertions(+) create mode 100644 apps/Launcher/CMakeLists.txt create mode 100644 apps/Launcher/files.qrc create mode 100644 apps/Launcher/images/header.png create mode 100644 apps/Launcher/informationwidget.cpp create mode 100644 apps/Launcher/informationwidget.h create mode 100644 apps/Launcher/main.cpp create mode 100644 apps/Launcher/mainwindow.cpp create mode 100644 apps/Launcher/mainwindow.h create mode 100644 apps/Launcher/shortcutwidget.cpp create mode 100644 apps/Launcher/shortcutwidget.h create mode 100644 apps/Launcher/syncwidget.cpp create mode 100644 apps/Launcher/syncwidget.h diff --git a/apps/Launcher/CMakeLists.txt b/apps/Launcher/CMakeLists.txt new file mode 100644 index 0000000000..f0c902e10d --- /dev/null +++ b/apps/Launcher/CMakeLists.txt @@ -0,0 +1,66 @@ +######################################################################################### +# # +# 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. # +######################################################################################### + +set(APPLICATION_NAME Launcher) +set(APPLICATION_LINK_TO_OPENSPACE ON) + +set(SOURCE_FILES + ${OPENSPACE_APPS_DIR}/Launcher/main.cpp + ${OPENSPACE_APPS_DIR}/Launcher/informationwidget.cpp + ${OPENSPACE_APPS_DIR}/Launcher/mainwindow.cpp + ${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.cpp + ${OPENSPACE_APPS_DIR}/Launcher/syncwidget.cpp +) + +set(HEADER_FILES + ${OPENSPACE_APPS_DIR}/Launcher/informationwidget.h + ${OPENSPACE_APPS_DIR}/Launcher/mainwindow.h + ${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.h + ${OPENSPACE_APPS_DIR}/Launcher/syncwidget.h +) + +find_package(Qt5Widgets) +find_package(Qt5Network) + +qt5_wrap_cpp(MOC_FILES ${HEADER_FILES}) +qt5_add_resources(RESOURCE_FILES ${OPENSPACE_APPS_DIR}/Launcher/files.qrc) + +add_executable(${APPLICATION_NAME} MACOSX_BUNDLE + ${SOURCE_FILES} + ${HEADER_FILES} + ${MOC_FILES} + ${RESOURCE_FILES} +) + +target_link_libraries(${APPLICATION_NAME} + Qt5::Widgets + Qt5::Network +) + +if (APPLE) +INSTALL(CODE " + include(BundleUtilities) + fixup_bundle(\"/Users/alex/Development/OpenSpace/bin/openspace/Debug/Launcher.app/Contents/MacOS/Launcher\" \"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") + " COMPONENT Runtime) +endif () diff --git a/apps/Launcher/files.qrc b/apps/Launcher/files.qrc new file mode 100644 index 0000000000..5661c6a39f --- /dev/null +++ b/apps/Launcher/files.qrc @@ -0,0 +1,5 @@ + + + images/header.png + + diff --git a/apps/Launcher/images/header.png b/apps/Launcher/images/header.png new file mode 100644 index 0000000000000000000000000000000000000000..21ced755c89b5a0a44e690bfb1850408da984cf8 GIT binary patch literal 13192 zcmeHtWmH^S(pwX5pvUC&e1gsCV=qaYC=K|w*G$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#s!uI6Q7KH2UA+-3yY&RsxGl2} z9RPz#&#`E(#}ei2<~sd5x7{#rb8P81D;ihg(>N>#!mw!7bhF$TF~``-&E`Y$Tp~u; z_-C(m%I;b+xonf$fGlm~XSTcXwC{aWnT$`9+YT(Mf;yUWBzvu{8V z{bEmNhAk`1RxZyb&Is$T<%N@3tK=U{Oc&~`C#sA^=Ig8zv>Al~zZ<@P5|cIqI(M>x zbu5=vb2dVoAN?VZ&Vx*i{T3;PG{ge#3QIG*+b=h88l%=7e09=g5gr*xVklJ35f0111=teDGMIA`M#EW;@A-p5m;4yD1_Wp_6xaTjmon&7N>5dJoRG&UOU4Qt{pSbbwiZLv09Y8}&;0ef(eX5PEf^?w(As4P z|GQy5$0CsCdAN-^3NiP{YU{3!w-@lsZ?{LWCo-_14CF=iJ ziT<=3&CiMc)w1qJitT@wWG3(*0|Awx3V=E6Ua0@-rJDjI<^TFHu0f!RKcwL$&JXrI Q{lq0JsU%VP$|UH20s7Q2NdN!< literal 0 HcmV?d00001 diff --git a/apps/Launcher/informationwidget.cpp b/apps/Launcher/informationwidget.cpp new file mode 100644 index 0000000000..50769447ec --- /dev/null +++ b/apps/Launcher/informationwidget.cpp @@ -0,0 +1,29 @@ +/***************************************************************************************** + * * + * 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 "informationwidget.h" + +InformationWidget::InformationWidget(QWidget* parent) + : QTextEdit(parent) +{} diff --git a/apps/Launcher/informationwidget.h b/apps/Launcher/informationwidget.h new file mode 100644 index 0000000000..21565322ea --- /dev/null +++ b/apps/Launcher/informationwidget.h @@ -0,0 +1,36 @@ +/***************************************************************************************** + * * + * 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 __INFORMATIONWIDGET_H__ +#define __INFORMATIONWIDGET_H__ + +#include + +class InformationWidget : public QTextEdit { +Q_OBJECT +public: + InformationWidget(QWidget* parent); +}; + +#endif // __INFORMATIONWIDGET_H__ diff --git a/apps/Launcher/main.cpp b/apps/Launcher/main.cpp new file mode 100644 index 0000000000..b4c17f6d04 --- /dev/null +++ b/apps/Launcher/main.cpp @@ -0,0 +1,155 @@ +/***************************************************************************************** + * * + * 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 + +#include "mainwindow.h" + +//static const QString style = R"style( +//QWidget { +// background-color: rgb(80, 80, 80); +// font-family: Helvetica; +//} +// +//QGroupBox { +// background-color: qlineargradient( +// x1: 0, y1: 0, x2: 0, y2: 1, +// stop: 0 #858585, +// stop: 1 #959595); +// border: 2px solid gray; +// border-radius: 5px; +// margin-top: 4ex; +// font-size: bold 12px; +//} +// +//QGroupBox::title { +// background-color: #E0E0E0; +// border: 2px solid gray; +// border-radius: 5px; +// subcontrol-origin: margin; +// subcontrol-position: top center; +// padding: 0 10px; +//} +// +//QLineEdit { +// color: lightgray; +//} +// +//QSlider::groove:horizontal { +// border: 1px solid #999999; +// height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */ +// background: qlineargradient( +// x1:0, y1:0, x2:1, y2:0, +// stop:0 #c4c4c4, +// stop:0.5 #555555, +// stop:1 #c4c4c4 +// ); +// margin: 2px 0; +//} +// +//QSlider::handle:horizontal { +// background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); +// border: 1px solid #5c5c5c; +// width: 18px; +// margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */ +// border-radius: 3px; +//} +// +//QPushButton { +// background-color: lightgray; +// border-style: outset; +// border-width: 0.5px; +// border-radius: 5px; +// border-color: black; +// font: bold 12px; +// min-width: 10em; +//} +// +//QPushButton#connection { +// background-color: lightgreen; +//} +// +//QPushButton#connection:pressed { +// background-color: green; +//} +// +// +//QPushButton#pause, QPushButton#play { +// padding: 5px; +//} +// +//QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed { +// background-color: darkgray; +// border-style: inset; +//} +// +//QCombobox { +// border: 1px solid gray; +// border-radius: 3px; +// padding: 1px 18px 1px 3px; +// min-width: 6em; +//} +// +//QComboBox:editable { +// background: lightgrey; +//} +// +//QComboBox QAbstractItemView { +// border: 2px solid darkgray; +// border-radius: 5px; +// background-color: #a8a8a8; +// selection-background-color: #a8a8a8; +//} +// +//QLabel#label { +// font-size: 13px; +// background-color: transparent; +// font-variant: small-caps; +//} +// +//QLabel#value { +// font-family: monospace; +// font-weight: bold; +// font-size: 14px; +// background-color: transparent; +//} +// +//QWidget#background { +// background-color: transparent; +//} +// +//QTextEdit { +// font-family: monospace; +//} +//)style"; + +int main(int argc, char** argv) { + QApplication app(argc, argv); + +// app.setStyleSheet(style); + MainWindow window; + window.show(); + + return app.exec(); +} diff --git a/apps/Launcher/mainwindow.cpp b/apps/Launcher/mainwindow.cpp new file mode 100644 index 0000000000..70b8624581 --- /dev/null +++ b/apps/Launcher/mainwindow.cpp @@ -0,0 +1,377 @@ +/***************************************************************************************** + * * + * 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 "mainwindow.h" + +#include "informationwidget.h" + +#include +#include +#include +#include +#include +#include + +namespace { + const QSize WindowSize = QSize(640, 480); +} + +MainWindow::MainWindow() + : QWidget(nullptr) + , _informationWidget(nullptr) +{ + setFixedSize(WindowSize); + + QGridLayout* layout = new QGridLayout; + + QLabel* image = new QLabel; + QPixmap p = QPixmap(":/images/header.png"); + image->setPixmap(p.scaledToWidth(WindowSize.width())); + layout->addWidget(image, 0, 0, 1, 2); + + _informationWidget = new InformationWidget(this); + layout->addWidget(_informationWidget, 1, 0, 2, 1); + + QWidget* container = new QWidget; + { + QGridLayout* layout = new QGridLayout; + + QLabel* shortcutLabel = new QLabel("Keyboard Shortcuts:"); + layout->addWidget(shortcutLabel, 0, 0); + QPushButton* shortcutButton = new QPushButton("Open..."); + QObject::connect(shortcutButton, SIGNAL(clicked(bool)), + this, SLOT(shortcutButtonPressed()) + ); + layout->addWidget(shortcutButton, 0, 1); + + QLabel* sceneSelectionLabel = new QLabel("Scenes:"); + layout->addWidget(sceneSelectionLabel, 1, 0); + QComboBox* sceneSelection = new QComboBox; + layout->addWidget(sceneSelection); + + container->setLayout(layout); + } + layout->addWidget(container, 1, 1); + + container = new QWidget; + { + QBoxLayout* layout = new QHBoxLayout; + + QPushButton* cancelButton = new QPushButton("Cancel"); + layout->addWidget(cancelButton); + + QPushButton* syncButton = new QPushButton("Sync"); + layout->addWidget(syncButton); + + QPushButton* startButton = new QPushButton("Start"); + layout->addWidget(startButton); + + container->setLayout(layout); + } + layout->addWidget(container, 2, 1); + + setLayout(layout); +} + +MainWindow::~MainWindow() { + delete _informationWidget; +} + +void MainWindow::shortcutButtonPressed() { + +} + +//MainWindow::MainWindow() +// : QWidget(nullptr) +// , _configurationWidget(nullptr) +// , _timeControlWidget(nullptr) +// , _informationWidget(nullptr) +// , _timelineWidget(nullptr) +// , _socket(nullptr) +//{ +// setWindowTitle("OpenSpace Timeline"); +// +// _configurationWidget = new ConfigurationWidget(this); +// _configurationWidget->setMinimumWidth(350); +// _timeControlWidget = new ControlWidget(this); +// _timeControlWidget->setMinimumWidth(350); +// _informationWidget = new InformationWidget(this); +// _informationWidget->setMinimumWidth(350); +// _timelineWidget = new TimelineWidget(this); +// +// QGridLayout* layout = new QGridLayout; +// layout->addWidget(_configurationWidget, 0, 0); +// layout->addWidget(_timeControlWidget, 1, 0); +// layout->addWidget(_informationWidget, 2, 0); +// layout->addWidget(_timelineWidget, 0, 1, 3, 1); +// +// layout->setColumnStretch(1, 5); +// +// +// QObject::connect( +// _configurationWidget, SIGNAL(connect(QString, QString)), +// this, SLOT(onConnect(QString, QString)) +// ); +// QObject::connect( +// _configurationWidget, SIGNAL(disconnect()), +// this, SLOT(onDisconnect()) +// ); +// +// QObject::connect( +// _timeControlWidget, SIGNAL(scriptActivity(QString)), +// this, SLOT(sendScript(QString)) +// ); +// +// setLayout(layout); +// +// _configurationWidget->socketDisconnected(); +// _timeControlWidget->socketDisconnected(); +// _informationWidget->socketDisconnected(); +// _timelineWidget->socketDisconnected(); +//} +// +//MainWindow::~MainWindow() { +// delete _socket; +//} +// +//void MainWindow::onConnect(QString host, QString port) { +// delete _socket; +// +// _socket = new QTcpSocket(this); +// QObject::connect(_socket, SIGNAL(readyRead()), SLOT(readTcpData())); +// QObject::connect(_socket, SIGNAL(connected()), SLOT(onSocketConnected())); +// QObject::connect(_socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); +// +// _socket->connectToHost(host, port.toUInt()); +//} +// +//void MainWindow::onDisconnect() { +// delete _socket; +// _socket = nullptr; +//} +// +//void MainWindow::readTcpData() { +// static const uint16_t MessageTypeStatus = 0; +// static const uint16_t MessageTypePlayBookHongKang = 2; +// static const uint16_t MessageTypePlayBookLabel = 3; +// +// QByteArray data = _socket->readAll(); +// +// if (QString(data) == "Connected to SGCT!\r\n") +// return; +// if (QString(data) == "OK\r\n") +// return; +// +// QByteArray messageTypeData = data.left(2); +// union { +// uint16_t value; +// std::array data; +// } messageType; +// std::memcpy(messageType.data.data(), messageTypeData.data(), sizeof(uint16_t)); +// +// switch (messageType.value) { +// case MessageTypeStatus: +// break; +// case MessageTypePlayBookHongKang: +// qDebug() << "Hong Kang Playbook received"; +// break; +// case MessageTypePlayBookLabel: +// qDebug() << "Label Playbook received"; +// break; +// default: +// qDebug() << "Unknown message of type '" << messageType.value << "'"; +// } +// +// switch (messageType.value) { +// case MessageTypeStatus: +// { +// if (_hasHongKangTimeline && _hasLabelTimeline) +// handleStatusMessage(data.mid(2)); +// break; +// } +// case MessageTypePlayBookHongKang: +// case MessageTypePlayBookLabel: +// { +// const char* payloadDebug = data.mid(2).data(); +// +// size_t beginning = 0; +// uint32_t size = readFromBuffer(data.mid(2).data(), beginning); +// +// //qDebug() << "Begin reading data"; +// while (_socket->waitForReadyRead() && data.size() < int(size)) { +// //qDebug() << "."; +// data = data.append(_socket->readAll()); +// //data = data.append(_socket->read(int(size) - data.size())); +// QThread::msleep(50); +// } +// //qDebug() << "Finished reading data. Handling playbook"; +// +// handlePlaybook(data.mid(2)); +// +// //qDebug() << "Finished handling playbook"; +// +// if (messageType.value == MessageTypePlayBookHongKang) +// _hasHongKangTimeline = true; +// if (messageType.value == MessageTypePlayBookLabel) +// _hasLabelTimeline = true; +// +// if (_hasHongKangTimeline && _hasLabelTimeline) { +// fullyConnected(); +// } +// +// break; +// } +// default: +// qDebug() << QString(data); +// } +// +//} +// +//void MainWindow::handleStatusMessage(QByteArray data) { +// const char* buffer = data.data(); +// +// union { +// double value; +// std::array buffer; +// } et; +// std::memmove(et.buffer.data(), buffer, sizeof(double)); +// +// std::vector timeString(24); +// std::memmove(timeString.data(), buffer + sizeof(double), 24); +// +// union { +// double value; +// std::array buffer; +// } delta; +// std::memmove(delta.buffer.data(), buffer + sizeof(double) + 24, sizeof(double)); +// +// _timeControlWidget->update( +// QString::fromStdString(std::string(timeString.begin(), timeString.end())), +// QString::number(delta.value) +// ); +// _timelineWidget->setCurrentTime(std::string(timeString.begin(), timeString.end()), et.value); +//} +// +//std::vector instrumentsFromId(uint16_t instrumentId, std::map instrumentMap) { +// std::vector results; +// for (int i = 0; i < 16; ++i) { +// uint16_t testValue = 1 << i; +// if ((testValue & instrumentId) != 0) { +// std::string t = instrumentMap.at(testValue); +// if (t.empty()) +// qDebug() << "Empty instrument"; +// results.push_back(t); +// } +// } +// return results; +//} +// +//void MainWindow::handlePlaybook(QByteArray data) { +// char* buffer = data.data(); +// size_t currentReadLocation = 0; +// +// uint32_t totalData = readFromBuffer(buffer, currentReadLocation); +// +// uint8_t nTargets = readFromBuffer(buffer, currentReadLocation); +// qDebug() << "Targets: " << nTargets; +// std::map targetMap; +// for (uint8_t i = 0; i < nTargets; ++i) { +// uint8_t id = readFromBuffer(buffer, currentReadLocation); +// std::string value = readFromBuffer(buffer, currentReadLocation); +// qDebug() << QString::fromStdString(value); +// targetMap[id] = value; +// } +// +// uint8_t nInstruments = readFromBuffer(buffer, currentReadLocation); +// qDebug() << "Instruments: " << nInstruments; +// std::map instrumentMap; +// for (uint8_t i = 0; i < nInstruments; ++i) { +// uint16_t id = readFromBuffer(buffer, currentReadLocation); +// std::string value = readFromBuffer(buffer, currentReadLocation); +// qDebug() << QString::fromStdString(value); +// instrumentMap[id] = value; +// } +// +// uint32_t nImages = readFromBuffer(buffer, currentReadLocation); +// std::vector images; +// for (uint32_t i = 0; i < nImages; ++i) { +// Image image; +// image.beginning = readFromBuffer(buffer, currentReadLocation); +// image.ending = readFromBuffer(buffer, currentReadLocation); +// +// image.beginningString = readFromBuffer(buffer, currentReadLocation); +// image.endingString = readFromBuffer(buffer, currentReadLocation); +// +// uint8_t targetId = readFromBuffer(buffer, currentReadLocation); +// uint16_t instrumentId = readFromBuffer(buffer, currentReadLocation); +// image.target = targetMap[targetId]; +// image.instruments = instrumentsFromId(instrumentId, instrumentMap); +// if (image.instruments.empty()) +// qDebug() << "Instruments were empty"; +// images.push_back(image); +// } +// +// _timelineWidget->setData(std::move(images), std::move(targetMap), std::move(instrumentMap)); +// +//} +// +//void MainWindow::sendScript(QString script) { +// if (_socket) { +// _socket->write(("0" + script + "\r\n").toLatin1()); +// //QByteArray data = (QString("0") + script).toLocal8Bit(); +// //qDebug() << data; +// //_socket->write(data); +// //QThread::msleep(25); +// } +// //_socket->write(("0" + script + "\r\n").toLatin1()); +// //_socket->write(("0" + script + "\0").toLatin1()); +//} +// +//void MainWindow::onSocketConnected() { +// _socket->write(QString("1\r\n").toLatin1()); +// //_socket->write(QString("1").toLatin1()); +// +//} +// +//void MainWindow::onSocketDisconnected() { +// _configurationWidget->socketDisconnected(); +// _timeControlWidget->socketDisconnected(); +// _informationWidget->socketDisconnected(); +// _timelineWidget->socketDisconnected(); +// +// _informationWidget->logInformation("Disconnected."); +//} +// +//std::string MainWindow::nextTarget() const { +// return _timelineWidget->nextTarget(); +//} +// +//void MainWindow::fullyConnected() { +// _informationWidget->logInformation("Connected to " + _socket->peerName() + " on port " + QString::number(_socket->peerPort()) + "."); +// +// _configurationWidget->socketConnected(); +// _timeControlWidget->socketConnected(); +// _informationWidget->socketConnected(); +// _timelineWidget->socketConnected(); +//} diff --git a/apps/Launcher/mainwindow.h b/apps/Launcher/mainwindow.h new file mode 100644 index 0000000000..89d2a21ce8 --- /dev/null +++ b/apps/Launcher/mainwindow.h @@ -0,0 +1,82 @@ +/***************************************************************************************** + * * + * 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 __MAINWINDOW_H__ +#define __MAINWINDOW_H__ + +#include +#include + +class InformationWidget; + +class MainWindow : public QWidget { +Q_OBJECT +public: + MainWindow(); + ~MainWindow(); + +private slots: + void shortcutButtonPressed(); + +private: + InformationWidget* _informationWidget; +}; + +//class MainWindow : public QWidget { +//Q_OBJECT +//public: +// MainWindow(); +// ~MainWindow(); +// +// std::string nextTarget() const; +// +//public slots: +// void sendScript(QString script); +// +//private slots: +// void onConnect(QString host, QString port); +// void onDisconnect(); +// +// void onSocketConnected(); +// void onSocketDisconnected(); +// +// void readTcpData(); +// void handleStatusMessage(QByteArray data); +// void handlePlaybook(QByteArray data); +// +// void fullyConnected(); +// +//private: +// ConfigurationWidget* _configurationWidget; +// ControlWidget* _timeControlWidget; +// InformationWidget* _informationWidget; +// TimelineWidget* _timelineWidget; +// +// QTcpSocket* _socket; +// +// bool _hasHongKangTimeline = false; +// bool _hasLabelTimeline = false; +//}; + +#endif // __MAINWINDOW_H__ diff --git a/apps/Launcher/shortcutwidget.cpp b/apps/Launcher/shortcutwidget.cpp new file mode 100644 index 0000000000..899b60c82e --- /dev/null +++ b/apps/Launcher/shortcutwidget.cpp @@ -0,0 +1,29 @@ +/***************************************************************************************** + * * + * 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 "shortcutwidget.h" + +ShortcutWidget::ShortcutWidget(QWidget* parent) + : QWidget(parent) +{} diff --git a/apps/Launcher/shortcutwidget.h b/apps/Launcher/shortcutwidget.h new file mode 100644 index 0000000000..5a06a0d388 --- /dev/null +++ b/apps/Launcher/shortcutwidget.h @@ -0,0 +1,36 @@ +/***************************************************************************************** + * * + * 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 __SHORTCUTWIDGET_H__ +#define __SHORTCUTWIDGET_H__ + +#include + +class ShortcutWidget : public QWidget { +Q_OBJECT +public: + ShortcutWidget(QWidget* parent); +}; + +#endif // __SHORTCUTWIDGET_H__ diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp new file mode 100644 index 0000000000..d7414b95da --- /dev/null +++ b/apps/Launcher/syncwidget.cpp @@ -0,0 +1,25 @@ +/***************************************************************************************** + * * + * 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 "syncwidget.h" diff --git a/apps/Launcher/syncwidget.h b/apps/Launcher/syncwidget.h new file mode 100644 index 0000000000..a5744859da --- /dev/null +++ b/apps/Launcher/syncwidget.h @@ -0,0 +1,34 @@ +/***************************************************************************************** + * * + * 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 __SYNCWIDGET_H__ +#define __SYNCWIDGET_H__ + +#include + +class SyncWidget : public QWidget { + +}; + +#endif // __SYNCWIDGET_H__ From 4c415ef50257b4d59a1ec9f11a271aeb6b1d8337 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 8 Jun 2015 01:55:38 +0200 Subject: [PATCH 25/28] Some more work restructuring the launcher --- apps/Launcher/CMakeLists.txt | 2 -- apps/Launcher/informationwidget.cpp | 29 -------------------- apps/Launcher/informationwidget.h | 36 ------------------------- apps/Launcher/mainwindow.cpp | 42 ++++++++++++++++++++++++++--- apps/Launcher/mainwindow.h | 17 +++++++++--- 5 files changed, 53 insertions(+), 73 deletions(-) delete mode 100644 apps/Launcher/informationwidget.cpp delete mode 100644 apps/Launcher/informationwidget.h diff --git a/apps/Launcher/CMakeLists.txt b/apps/Launcher/CMakeLists.txt index f0c902e10d..2cf98ae128 100644 --- a/apps/Launcher/CMakeLists.txt +++ b/apps/Launcher/CMakeLists.txt @@ -27,14 +27,12 @@ set(APPLICATION_LINK_TO_OPENSPACE ON) set(SOURCE_FILES ${OPENSPACE_APPS_DIR}/Launcher/main.cpp - ${OPENSPACE_APPS_DIR}/Launcher/informationwidget.cpp ${OPENSPACE_APPS_DIR}/Launcher/mainwindow.cpp ${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.cpp ${OPENSPACE_APPS_DIR}/Launcher/syncwidget.cpp ) set(HEADER_FILES - ${OPENSPACE_APPS_DIR}/Launcher/informationwidget.h ${OPENSPACE_APPS_DIR}/Launcher/mainwindow.h ${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.h ${OPENSPACE_APPS_DIR}/Launcher/syncwidget.h diff --git a/apps/Launcher/informationwidget.cpp b/apps/Launcher/informationwidget.cpp deleted file mode 100644 index 50769447ec..0000000000 --- a/apps/Launcher/informationwidget.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/***************************************************************************************** - * * - * 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 "informationwidget.h" - -InformationWidget::InformationWidget(QWidget* parent) - : QTextEdit(parent) -{} diff --git a/apps/Launcher/informationwidget.h b/apps/Launcher/informationwidget.h deleted file mode 100644 index 21565322ea..0000000000 --- a/apps/Launcher/informationwidget.h +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************************** - * * - * 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 __INFORMATIONWIDGET_H__ -#define __INFORMATIONWIDGET_H__ - -#include - -class InformationWidget : public QTextEdit { -Q_OBJECT -public: - InformationWidget(QWidget* parent); -}; - -#endif // __INFORMATIONWIDGET_H__ diff --git a/apps/Launcher/mainwindow.cpp b/apps/Launcher/mainwindow.cpp index 70b8624581..70c07e54b5 100644 --- a/apps/Launcher/mainwindow.cpp +++ b/apps/Launcher/mainwindow.cpp @@ -24,22 +24,25 @@ #include "mainwindow.h" -#include "informationwidget.h" - #include #include #include #include +#include #include #include namespace { const QSize WindowSize = QSize(640, 480); + + const QString NewsURL = "http://openspace.itn.liu.se/news.txt"; } MainWindow::MainWindow() : QWidget(nullptr) + , _newsReply(nullptr) , _informationWidget(nullptr) + , _networkManager(new QNetworkAccessManager) { setFixedSize(WindowSize); @@ -50,7 +53,9 @@ MainWindow::MainWindow() image->setPixmap(p.scaledToWidth(WindowSize.width())); layout->addWidget(image, 0, 0, 1, 2); - _informationWidget = new InformationWidget(this); + + _informationWidget = new QTextEdit(this); + _informationWidget->setReadOnly(true); layout->addWidget(_informationWidget, 1, 0, 2, 1); QWidget* container = new QWidget; @@ -92,16 +97,47 @@ MainWindow::MainWindow() layout->addWidget(container, 2, 1); setLayout(layout); + + initialize(); } MainWindow::~MainWindow() { delete _informationWidget; + delete _networkManager; +} + +void MainWindow::initialize() { + // Get the news information + QNetworkRequest request; + request.setUrl(QUrl(NewsURL)); + + _newsReply = _networkManager->get(request); + connect(_newsReply, SIGNAL(finished()), + this, SLOT(newsReadyRead()) + ); + connect(_newsReply, SIGNAL(error(QNetworkReply::NetworkError)), + this, SLOT(newsNetworkError()) + ); } void MainWindow::shortcutButtonPressed() { } +void MainWindow::newsNetworkError() { + QString error = _newsReply->errorString(); + _informationWidget->setText(error); + _newsReply->deleteLater(); +} + +void MainWindow::newsReadyRead() { + QByteArray data = _newsReply->readAll(); + QString news = QString::fromLatin1(data); + _informationWidget->setText(news); + _newsReply->deleteLater(); +} + + //MainWindow::MainWindow() // : QWidget(nullptr) // , _configurationWidget(nullptr) diff --git a/apps/Launcher/mainwindow.h b/apps/Launcher/mainwindow.h index 89d2a21ce8..e30f0815a7 100644 --- a/apps/Launcher/mainwindow.h +++ b/apps/Launcher/mainwindow.h @@ -26,9 +26,11 @@ #define __MAINWINDOW_H__ #include -#include -class InformationWidget; +#include +#include + +class QNetworkAccessManager; class MainWindow : public QWidget { Q_OBJECT @@ -38,9 +40,18 @@ public: private slots: void shortcutButtonPressed(); + + void newsNetworkError(); + void newsReadyRead(); private: - InformationWidget* _informationWidget; + void initialize(); + + QNetworkReply* _newsReply; + + QTextEdit* _informationWidget; + + QNetworkAccessManager* _networkManager; }; //class MainWindow : public QWidget { From 511f103430e953e1e67ec0ae29dc671dd6a9303d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 10 Jun 2015 02:04:41 +0200 Subject: [PATCH 26/28] Make APPLICATION_LINK_TO_OPENSPACE actually include the libOpenSpace and Ghoul as well --- support/cmake/support_macros.cmake | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index 6b703962a2..bf3a1d45c0 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -192,6 +192,29 @@ function (handle_applications) unset(APPLICATION_LINK_TO_OPENSPACE) include(${OPENSPACE_APPS_DIR}/${app}/CMakeLists.txt) set_compile_settings(${APPLICATION_NAME}) + + if (APPLICATION_LINK_TO_OPENSPACE) + get_property( + OPENSPACE_INCLUDE_DIR + TARGET libOpenSpace + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + ) + target_include_directories(${APPLICATION_NAME} PUBLIC + "${OPENSPACE_BASE_DIR}" + ${OPENSPACE_INCLUDE_DIR} + ) + + get_property( + OPENSPACE_DEFINES + TARGET libOpenSpace + PROPERTY INTERFACE_COMPILE_DEFINITIONS + ) + target_compile_definitions(${APPLICATION_NAME} PUBLIC ${OPENSPACE_DEFINES}) + + target_link_libraries(${APPLICATION_NAME} Ghoul) + target_link_libraries(${APPLICATION_NAME} libOpenSpace) + endif () + list(APPEND applications ${APPLICATION_NAME}) list(APPEND applications_link_to_openspace ${APPLICATION_LINK_TO_OPENSPACE}) unset(APPLICATION_NAME) @@ -362,7 +385,7 @@ function (handle_internal_modules) list(GET OPENSPACE_APPLICATIONS ${val} val1) list(GET OPENSPACE_APPLICATIONS_LINK_REQUEST ${val} val2) if (${val2}) - target_link_libraries(${app} ${libraryName}) + target_link_libraries(${app} ${libraryName}) endif () endforeach() From fab3b3e177fc53daab6536e05ef717b4489a3ede Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 10 Jun 2015 02:05:20 +0200 Subject: [PATCH 27/28] Move FileSystem initialization into ghoul::initialize --- ext/ghoul | 2 +- src/engine/openspaceengine.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 03983ed78e..eb66778e0a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 03983ed78edab3e068c2c3a1f4457a9a163f3161 +Subproject commit eb66778e0aaf1809fff1a1476872594a24ac0ac3 diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index a1547d463a..a95e058501 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -157,7 +157,6 @@ bool OpenSpaceEngine::create( LogMgr.addLog(new ConsoleLog); LDEBUG("Initialize FileSystem"); - ghoul::filesystem::FileSystem::initialize(); #ifdef __APPLE__ ghoul::filesystem::File app(argv[0]); From 726a8e84efe30eac4b4d120e19d35b22bc037f56 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 10 Jun 2015 02:05:52 +0200 Subject: [PATCH 28/28] Adding parsing of scene files to Launcher application --- apps/Launcher/mainwindow.cpp | 66 ++++++++++++++++++++----- apps/Launcher/mainwindow.h | 17 ++++++- apps/Launcher/syncwidget.cpp | 95 ++++++++++++++++++++++++++++++++++++ apps/Launcher/syncwidget.h | 8 +++ 4 files changed, 174 insertions(+), 12 deletions(-) diff --git a/apps/Launcher/mainwindow.cpp b/apps/Launcher/mainwindow.cpp index 70c07e54b5..138a083a13 100644 --- a/apps/Launcher/mainwindow.cpp +++ b/apps/Launcher/mainwindow.cpp @@ -24,11 +24,13 @@ #include "mainwindow.h" +#include #include +#include #include #include #include -#include +#include #include #include @@ -36,13 +38,23 @@ namespace { const QSize WindowSize = QSize(640, 480); const QString NewsURL = "http://openspace.itn.liu.se/news.txt"; + + const QString ModulesDirectory = "../data/scene"; // temporary ---abock + +#ifdef WIN32 + const QString OpenSpaceExecutable = "OpenSpace.exe"; +#else + const QString OpenSpaceExecutable = "OpenSpace"; +#endif } MainWindow::MainWindow() : QWidget(nullptr) , _newsReply(nullptr) , _informationWidget(nullptr) - , _networkManager(new QNetworkAccessManager) + , _scenes(nullptr) + , _shortcutWidget(nullptr) + , _syncWidget(nullptr) { setFixedSize(WindowSize); @@ -53,7 +65,6 @@ MainWindow::MainWindow() image->setPixmap(p.scaledToWidth(WindowSize.width())); layout->addWidget(image, 0, 0, 1, 2); - _informationWidget = new QTextEdit(this); _informationWidget->setReadOnly(true); layout->addWidget(_informationWidget, 1, 0, 2, 1); @@ -72,8 +83,8 @@ MainWindow::MainWindow() QLabel* sceneSelectionLabel = new QLabel("Scenes:"); layout->addWidget(sceneSelectionLabel, 1, 0); - QComboBox* sceneSelection = new QComboBox; - layout->addWidget(sceneSelection); + _scenes = new QComboBox; + layout->addWidget(_scenes); container->setLayout(layout); } @@ -84,12 +95,24 @@ MainWindow::MainWindow() QBoxLayout* layout = new QHBoxLayout; QPushButton* cancelButton = new QPushButton("Cancel"); + QObject::connect( + cancelButton, SIGNAL(clicked(bool)), + QApplication::instance(), SLOT(quit()) + ); layout->addWidget(cancelButton); QPushButton* syncButton = new QPushButton("Sync"); + QObject::connect( + syncButton, SIGNAL(clicked(bool)), + this, SLOT(syncButtonPressed()) + ); layout->addWidget(syncButton); QPushButton* startButton = new QPushButton("Start"); + QObject::connect( + startButton, SIGNAL(clicked(bool)), + this, SLOT(startButtonPressed()) + ); layout->addWidget(startButton); container->setLayout(layout); @@ -103,7 +126,6 @@ MainWindow::MainWindow() MainWindow::~MainWindow() { delete _informationWidget; - delete _networkManager; } void MainWindow::initialize() { @@ -111,17 +133,40 @@ void MainWindow::initialize() { QNetworkRequest request; request.setUrl(QUrl(NewsURL)); - _newsReply = _networkManager->get(request); - connect(_newsReply, SIGNAL(finished()), + _newsReply = _networkManager.get(request); + QObject::connect(_newsReply, SIGNAL(finished()), this, SLOT(newsReadyRead()) ); - connect(_newsReply, SIGNAL(error(QNetworkReply::NetworkError)), + QObject::connect(_newsReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(newsNetworkError()) ); + + _shortcutWidget.hide(); + _syncWidget.hide(); + + QDir d(ModulesDirectory); + d.setFilter(QDir::Files); + + QFileInfoList list = d.entryInfoList(); + for (const QFileInfo& i : list) { + _sceneFiles.insert(i.fileName(), i.absoluteFilePath()); + _scenes->addItem(i.fileName()); + } } void MainWindow::shortcutButtonPressed() { - + _shortcutWidget.show(); +} + +void MainWindow::syncButtonPressed() { + QString currentScene = _scenes->currentText(); + _syncWidget.setSceneFile(_sceneFiles[currentScene]); + _syncWidget.show(); +} + +void MainWindow::startButtonPressed() { + QProcess* p = new QProcess(this); + p->start(OpenSpaceExecutable); } void MainWindow::newsNetworkError() { @@ -137,7 +182,6 @@ void MainWindow::newsReadyRead() { _newsReply->deleteLater(); } - //MainWindow::MainWindow() // : QWidget(nullptr) // , _configurationWidget(nullptr) diff --git a/apps/Launcher/mainwindow.h b/apps/Launcher/mainwindow.h index e30f0815a7..109bc4b0b4 100644 --- a/apps/Launcher/mainwindow.h +++ b/apps/Launcher/mainwindow.h @@ -27,9 +27,15 @@ #include +#include "shortcutwidget.h" +#include "syncwidget.h" + +#include +#include #include #include +class QComboBox; class QNetworkAccessManager; class MainWindow : public QWidget { @@ -40,6 +46,8 @@ public: private slots: void shortcutButtonPressed(); + void syncButtonPressed(); + void startButtonPressed(); void newsNetworkError(); void newsReadyRead(); @@ -50,8 +58,15 @@ private: QNetworkReply* _newsReply; QTextEdit* _informationWidget; + + QComboBox* _scenes; + QMap _sceneFiles; + + ShortcutWidget _shortcutWidget; + SyncWidget _syncWidget; + - QNetworkAccessManager* _networkManager; + QNetworkAccessManager _networkManager; }; //class MainWindow : public QWidget { diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp index d7414b95da..30babbe899 100644 --- a/apps/Launcher/syncwidget.cpp +++ b/apps/Launcher/syncwidget.cpp @@ -23,3 +23,98 @@ ****************************************************************************************/ #include "syncwidget.h" + +#include +#include +#include + +#include +#include +#include + +namespace { +} + +SyncWidget::SyncWidget(QWidget* parent) + : QWidget(parent) +{ + setFixedSize(500, 500); + + ghoul::initialize(); + +} + +void SyncWidget::setSceneFile(QString scene) { + clear(); + + qDebug() << scene; + + ghoul::Dictionary sceneDictionary; + ghoul::lua::loadDictionaryFromFile( + scene.toStdString(), + sceneDictionary + ); + + ghoul::Dictionary modules; + bool success = sceneDictionary.getValue("Modules", modules); + qDebug() << success; + + QStringList modulesList; + for (int i = 1; i < modules.size(); ++i) { + std::string module = modules.value(std::to_string(i)); + modulesList.append(QString::fromStdString(module)); + } + qDebug() << modulesList; + + QDir sceneDir(scene); + sceneDir.cdUp(); + for (QString module : modulesList) { + QString moduleFile = sceneDir.absoluteFilePath(module + "/" + module + ".mod"); + QString dataFile = sceneDir.absoluteFilePath(module + "/" + module + ".data"); + + qDebug() << module; + qDebug() << moduleFile << QFileInfo(moduleFile).exists(); + qDebug() << dataFile << QFileInfo(dataFile).exists(); + + if (QFileInfo(dataFile).exists()) { + ghoul::Dictionary dataDictionary; + ghoul::lua::loadDictionaryFromFile(dataFile.toStdString(), dataDictionary); + + ghoul::Dictionary directFiles; + ghoul::Dictionary torrentFiles; + + bool found = dataDictionary.getValue("Files", directFiles); + if (found) { + QStringList files; + for (int i = 1; i < directFiles.size(); ++i) { + std::string f = directFiles.value(std::to_string(i)); + files.append(QString::fromStdString(f)); + } + handleDirectFiles(module, files); + } + + found = dataDictionary.getValue("Torrents", torrentFiles); + if (found) { + QStringList torrents; + for (int i = 1; i < torrentFiles.size(); ++i) { + std::string f = torrentFiles.value(std::to_string(i)); + torrents.append(QString::fromStdString(f)); + } + handleTorrentFiles(module, torrents); + } + } + } +} + +void SyncWidget::clear() { + + +} + +void SyncWidget::handleDirectFiles(QString module, QStringList files) { + qDebug() << files; +} + +void SyncWidget::handleTorrentFiles(QString module, QStringList torrents) { + qDebug() << torrents; +} diff --git a/apps/Launcher/syncwidget.h b/apps/Launcher/syncwidget.h index a5744859da..ef206914f4 100644 --- a/apps/Launcher/syncwidget.h +++ b/apps/Launcher/syncwidget.h @@ -28,7 +28,15 @@ #include class SyncWidget : public QWidget { +public: + SyncWidget(QWidget* parent); + void setSceneFile(QString scene); + +private: + void clear(); + void handleDirectFiles(QString module, QStringList files); + void handleTorrentFiles(QString module, QStringList torrents); }; #endif // __SYNCWIDGET_H__