diff --git a/CMakeLists.txt b/CMakeLists.txt index eee822a3f8..65f32fa11d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2016 # +# # +# 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. # +########################################################################################## cmake_minimum_required (VERSION 3.4 FATAL_ERROR) diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..57ff97f0f2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,74 @@ +def modules = [ + "base", + "debugging", + "fieldlines", + "galaxy", + "globebrowsing", + "iswa", + "kameleon", + "kameleonvolume", + "multiresvolume", + "newhorizons", + "onscreengui", + "space", + "toyvolume", + "volume" +]; + +def flags = "-DGHOUL_USE_DEVIL=OFF " + +for (module in modules) { + flags += "-DOPENSPACE_OPENSPACE_MODULE_" + module.toUpperCase() + "=ON " +} + +echo flags + +stage('Build') { + parallel linux: { + node('linux') { + checkout scm + sh 'git submodule update --init --recursive' + sh ''' + mkdir -p build + cd build + cmake .. ''' + + flags + ''' .. + make + ''' + } + }, + windows: { + node('windows') { + checkout scm + bat ''' + git submodule update --init --recursive + if not exist "build" mkdir "build" + cd build + cmake -G "Visual Studio 14 2015 Win64" .. ''' + + flags + ''' .. + msbuild.exe OpenSpace.sln /m:8 /p:Configuration=Debug + ''' + } + }, + osx: { + node('osx') { + checkout scm + sh 'git submodule update --init --recursive' + sh ''' + export PATH=${PATH}:/usr/local/bin:/Applications/CMake.app/Contents/bin + export CMAKE_BUILD_TOOL=/Applications/CMake.app/Contents/bin/CMake + srcDir=$PWD + if [ ! -d ${srcDir} ]; then + mkdir ${srcDir} + fi + if [ ! -d ${srcDir}/build ]; then + mkdir ${srcDir}/build + fi + cd ${srcDir}/build + /Applications/CMake.app/Contents/bin/cmake -G Xcode -D NASM=/usr/local/Cellar/nasm/2.11.08/bin/nasm ${srcDir} .. ''' + + flags + ''' + xcodebuild + ''' + } + } +} \ No newline at end of file diff --git a/apps/DataConverter/conversiontask.h b/apps/DataConverter/conversiontask.h deleted file mode 100644 index 4719803e40..0000000000 --- a/apps/DataConverter/conversiontask.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __CONVERSIONTASK_H__ -#define __CONVERSIONTASK_H__ - -#include - -namespace openspace { -namespace dataconverter { - -class ConversionTask { -public: - virtual void perform(const std::function& onProgress) = 0; -}; - -} -} - -#endif diff --git a/apps/DataConverter/milkywayconversiontask.cpp b/apps/DataConverter/milkywayconversiontask.cpp deleted file mode 100644 index 6537070b8e..0000000000 --- a/apps/DataConverter/milkywayconversiontask.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include -#include - -namespace openspace { -namespace dataconverter { - -MilkyWayConversionTask::MilkyWayConversionTask( - const std::string& inFilenamePrefix, - const std::string& inFilenameSuffix, - size_t inFirstIndex, - size_t inNSlices, - const std::string& outFilename, - const glm::ivec3& outDimensions) - : _inFilenamePrefix(inFilenamePrefix) - , _inFilenameSuffix(inFilenameSuffix) - , _inFirstIndex(inFirstIndex) - , _inNSlices(inNSlices) - , _outFilename(outFilename) - , _outDimensions(outDimensions) {} - - -void MilkyWayConversionTask::perform(const std::function& onProgress) { - std::vector filenames; - for (int i = 0; i < _inNSlices; i++) { - filenames.push_back(_inFilenamePrefix + std::to_string(i + _inFirstIndex) + _inFilenameSuffix); - } - - TextureSliceVolumeReader> sliceReader(filenames, _inNSlices, 10); - sliceReader.initialize(); - - RawVolumeWriter> rawWriter(_outFilename); - rawWriter.setDimensions(_outDimensions); - - glm::vec3 resolutionRatio = - static_cast(sliceReader.dimensions()) / static_cast(rawWriter.dimensions()); - - VolumeSampler>> sampler(sliceReader, resolutionRatio); - std::function(glm::ivec3)> sampleFunction = [&](glm::ivec3 outCoord) { - glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5)) * resolutionRatio) - glm::vec3(0.5); - glm::tvec4 value = sampler.sample(inCoord); - return value; - }; - - rawWriter.write(sampleFunction, onProgress); -} - -} -} diff --git a/apps/DataConverter/milkywayconversiontask.h b/apps/DataConverter/milkywayconversiontask.h deleted file mode 100644 index 3927debd90..0000000000 --- a/apps/DataConverter/milkywayconversiontask.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __MILKYWAYCONVERSIONTASK_H__ -#define __MILKYWAYCONVERSIONTASK_H__ - -#include -#include -#include -#include -#include -#include - - -namespace openspace { -namespace dataconverter { - -/** - * Converts a set of exr image slices to a raw volume - * with floating point RGBA data (32 bit per channel). - */ -class MilkyWayConversionTask : public ConversionTask { -public: - MilkyWayConversionTask(const std::string& inFilenamePrefix, - const std::string& inFilenameSuffix, - size_t inFirstIndex, - size_t inNSlices, - const std::string& outFilename, - const glm::ivec3& outDimensions); - - void perform(const std::function& onProgress) override; -private: - std::string _inFilenamePrefix; - std::string _inFilenameSuffix; - size_t _inFirstIndex; - size_t _inNSlices; - std::string _outFilename; - glm::ivec3 _outDimensions; -}; - -} -} - -#endif diff --git a/apps/DataConverter/milkywaypointsconversiontask.cpp b/apps/DataConverter/milkywaypointsconversiontask.cpp deleted file mode 100644 index 0287bbf80b..0000000000 --- a/apps/DataConverter/milkywaypointsconversiontask.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include -#include -#include - -namespace openspace { -namespace dataconverter { - - - -MilkyWayPointsConversionTask::MilkyWayPointsConversionTask( - const std::string& inFilename, - const std::string& outFilename) - : _inFilename(inFilename) - , _outFilename(outFilename) {} - - -void MilkyWayPointsConversionTask::perform(const std::function& onProgress) { - std::ifstream in(_inFilename, std::ios::in); - std::ofstream out(_outFilename, std::ios::out | std::ios::binary); - - std::string format; - int64_t nPoints; - in >> format >> nPoints; - - - - size_t nFloats = nPoints * 7; - - float* pointData = new float[nFloats]; - - float x, y, z, r, g, b, a; - for (size_t i = 0; i < nPoints; ++i) { - in >> x >> y >> z >> r >> g >> b >> a; - if (in.good()) { - pointData[i * 7 + 0] = x; - pointData[i * 7 + 1] = y; - pointData[i * 7 + 2] = z; - pointData[i * 7 + 3] = r; - pointData[i * 7 + 4] = g; - pointData[i * 7 + 5] = b; - pointData[i * 7 + 6] = a; - onProgress(static_cast(i + 1) / nPoints); - } else { - std::cout << "Failed to convert point data."; - return; - } - } - - out.write(reinterpret_cast(&nPoints), sizeof(int64_t)); - out.write(reinterpret_cast(pointData), nFloats * sizeof(float)); - - in.close(); - out.close(); -} - - - -} -} diff --git a/apps/DataConverter/milkywaypointsconversiontask.h b/apps/DataConverter/milkywaypointsconversiontask.h deleted file mode 100644 index 3b5e8abb15..0000000000 --- a/apps/DataConverter/milkywaypointsconversiontask.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __MILKYWAYPOINTSCONVERSIONTASK_H__ -#define __MILKYWAYPOINTSCONVERSIONTASK_H__ - -#include -#include -#include -#include -#include -#include - - -namespace openspace { -namespace dataconverter { - -/** - * Converts ascii based point data - * int64_t n - * (float x, float y, float z, float r, float g, float b) * n - * to a binary (floating point) representation with the same layout. - */ -class MilkyWayPointsConversionTask : public ConversionTask { -public: - MilkyWayPointsConversionTask(const std::string& inFilename, - const std::string& outFilename); - - void perform(const std::function& onProgress) override; -private: - std::string _inFilename; - std::string _outFilename; -}; - -} -} - -#endif diff --git a/apps/Launcher/infowidget.cpp b/apps/Launcher/infowidget.cpp index ddde63591a..af5c89b8a1 100644 --- a/apps/Launcher/infowidget.cpp +++ b/apps/Launcher/infowidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/Launcher/infowidget.h b/apps/Launcher/infowidget.h index 2eaec279b9..9bbc17e1a6 100644 --- a/apps/Launcher/infowidget.h +++ b/apps/Launcher/infowidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __INFOWIDGET_H__ -#define __INFOWIDGET_H__ +#ifndef __OPENSPACE_APP_LAUNCHER___INFOWIDGET___H__ +#define __OPENSPACE_APP_LAUNCHER___INFOWIDGET___H__ //#include #include @@ -58,4 +58,4 @@ private: int _totalBytes; }; -#endif // __INFOWIDGET_H__ +#endif // __OPENSPACE_APP_LAUNCHER___INFOWIDGET___H__ diff --git a/apps/Launcher/main.cpp b/apps/Launcher/main.cpp index c802f468cc..ccf862687c 100644 --- a/apps/Launcher/main.cpp +++ b/apps/Launcher/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -82,18 +82,17 @@ QCheckBox::indicator { } QCheckBox::indicator::unchecked { border: 1px solid #5A5A5A; - background: transparent; + background: #A0A0A0; } QCheckBox::indicator:unchecked:hover { border: 1px solid #DDDDDD; } QCheckBox::indicator::checked { - border: 1px solid #AAAAAA; - background: #666666; + border: 1px solid #5A5A5A; + background: #5AB65A; } QCheckBox::indicator:checked:hover { border: 1px solid #DDDDDD; - background: #555555; } QGroupBox, QScrollArea { border: 0px; diff --git a/apps/Launcher/mainwindow.cpp b/apps/Launcher/mainwindow.cpp index 502c97a400..d1f6012f14 100644 --- a/apps/Launcher/mainwindow.cpp +++ b/apps/Launcher/mainwindow.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -134,7 +134,7 @@ MainWindow::MainWindow() { QBoxLayout* innerLayout = new QHBoxLayout; - QPushButton* cancelButton = new QPushButton("Cancel"); + QPushButton* cancelButton = new QPushButton("Exit"); QObject::connect( cancelButton, SIGNAL(clicked(bool)), QApplication::instance(), SLOT(quit()) diff --git a/apps/Launcher/mainwindow.h b/apps/Launcher/mainwindow.h index 9b9d9bd10e..9fd2626d4d 100644 --- a/apps/Launcher/mainwindow.h +++ b/apps/Launcher/mainwindow.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __MAINWINDOW_H__ -#define __MAINWINDOW_H__ +#ifndef __OPENSPACE_APP_LAUNCHER___MAINWINDOW___H__ +#define __OPENSPACE_APP_LAUNCHER___MAINWINDOW___H__ #include @@ -112,4 +112,4 @@ private: // bool _hasLabelTimeline = false; //}; -#endif // __MAINWINDOW_H__ +#endif // __OPENSPACE_APP_LAUNCHER___MAINWINDOW___H__ diff --git a/apps/Launcher/shortcutwidget.cpp b/apps/Launcher/shortcutwidget.cpp index 3f26becb99..3e4885ab34 100644 --- a/apps/Launcher/shortcutwidget.cpp +++ b/apps/Launcher/shortcutwidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/Launcher/shortcutwidget.h b/apps/Launcher/shortcutwidget.h index 1601be7843..82d96fa118 100644 --- a/apps/Launcher/shortcutwidget.h +++ b/apps/Launcher/shortcutwidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __SHORTCUTWIDGET_H__ -#define __SHORTCUTWIDGET_H__ +#ifndef __OPENSPACE_APP_LAUNCHER___SHORTCUTWIDGET___H__ +#define __OPENSPACE_APP_LAUNCHER___SHORTCUTWIDGET___H__ #include @@ -33,4 +33,4 @@ public: ShortcutWidget(QWidget* parent, Qt::WindowFlags f = 0); }; -#endif // __SHORTCUTWIDGET_H__ +#endif // __OPENSPACE_APP_LAUNCHER___SHORTCUTWIDGET___H__ diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp index 1f4099ac4e..f0eef99760 100644 --- a/apps/Launcher/syncwidget.cpp +++ b/apps/Launcher/syncwidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -225,8 +225,10 @@ void SyncWidget::setSceneFiles(QMap sceneFiles) { const QString& sceneName = keys[i]; QCheckBox* checkbox = new QCheckBox(sceneName); - checkbox->setChecked(true); - + QString defaultName = "default"; + if (sceneName == defaultName){ + checkbox->setChecked(true); + } _sceneLayout->addWidget(checkbox, i / nColumns, i % nColumns); } } diff --git a/apps/Launcher/syncwidget.h b/apps/Launcher/syncwidget.h index 6306fea1f3..f9a77e2861 100644 --- a/apps/Launcher/syncwidget.h +++ b/apps/Launcher/syncwidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __SYNCWIDGET_H__ -#define __SYNCWIDGET_H__ +#ifndef __OPENSPACE_APP_LAUNCHER___SYNCWIDGET___H__ +#define __OPENSPACE_APP_LAUNCHER___SYNCWIDGET___H__ #include @@ -121,4 +121,4 @@ private: }; -#endif // __SYNCWIDGET_H__ +#endif // __OPENSPACE_APP_LAUNCHER___SYNCWIDGET___H__ diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 45f08811fe..f4df34ab38 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -29,15 +29,51 @@ if (WIN32) set(RESOURCE_FILE ${OPENSPACE_APPS_DIR}/OpenSpace/openspace.rc) endif () +##OpenVR section start#################### +option(OPENSPACE_OPENVR_SUPPORT "Build OpenSpace application with OpenVR support" OFF) + +if(OPENSPACE_OPENVR_SUPPORT) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OPENSPACE_EXT_DIR}/sgct/cmake/modules/") + + find_package(OpenVR REQUIRED) + + set(SGCT_OPENVR_DEFINITIONS OPENVR_SUPPORT) + + if(NOT SGCT_OPENVR_INCLUDE_DIRECTORY) + if( WIN32 ) + find_path(SGCT_OPENVR_INCLUDE_DIRECTORY + NAMES SGCTOpenVR.h + PATHS $ENV{SGCT_ROOT_DIR}/additional_includes/openvr ${OPENSPACE_EXT_DIR}/sgct/additional_includes/openvr NO_DEFAULT_PATH + REQUIRED) + else() + find_path(SGCT_OPENVR_INCLUDE_DIRECTORY + NAMES SGCTOpenVR.h + PATH_SUFFIXES SGCTOpenVR + PATHS $ENV{SGCT_ROOT_DIR}/additional_includes/openvr ${OPENSPACE_EXT_DIR}/sgct/additional_includes/openvr + REQUIRED) + endif() + else() + set(SGCT_OPENVR_FILES ${SGCT_OPENVR_INCLUDE_DIRECTORY}/SGCTOpenVR.h ${SGCT_OPENVR_INCLUDE_DIRECTORY}/SGCTOpenVR.cpp) + endif() +else() + set(OPENVR_INCLUDE_DIRS "") + set(SGCT_OPENVR_INCLUDE_DIRECTORY "") + set(OPENVR_LIBRARY "") + set(SGCT_OPENVR_DEFINITIONS "") +endif() +##OpenVR section end#################### + add_executable(${APPLICATION_NAME} + ${SGCT_OPENVR_FILES} ${OPENSPACE_APPS_DIR}/OpenSpace/main.cpp ${RESOURCE_FILE} ) -target_include_directories(${APPLICATION_NAME} PUBLIC ${OPENSPACE_BASE_DIR}/include) -target_link_libraries(${APPLICATION_NAME} libOpenSpace) +target_include_directories(${APPLICATION_NAME} PUBLIC ${OPENSPACE_BASE_DIR}/include ${OPENVR_INCLUDE_DIRS} ${SGCT_OPENVR_INCLUDE_DIRECTORY}) +target_link_libraries(${APPLICATION_NAME} libOpenSpace ${OPENVR_LIBRARY}) +target_compile_definitions(${APPLICATION_NAME} PUBLIC ${SGCT_OPENVR_DEFINITIONS}) if (MSVC) set_target_properties(${APPLICATION_NAME} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" ) -endif () +endif() diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 601e083df1..16b05b6ed4 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,36 +25,30 @@ #include #include #include -#include + #include #include #include -#include - #include -#include -#include +#ifdef OPENVR_SUPPORT +#include +#endif // OPENVR_SUPPORT -sgct::Engine* _sgctEngine; +namespace { + +const char* _loggerCat = "main"; -void mainInitFunc(); -void mainPreSyncFunc(); -void mainPostSyncPreDrawFunc(); -void mainRenderFunc(); -void mainPostDrawFunc(); -void mainKeyboardCallback(int key, int scancode, int action, int mods); -void mainCharCallback(unsigned int codepoint, int mods); -void mainMouseButtonCallback(int key, int action); -void mainMousePosCallback(double x, double y); -void mainMouseScrollCallback(double posX, double posY); -void mainEncodeFun(); -void mainDecodeFun(); -void mainExternalControlCallback(const char * receivedChars, int size); -void mainLogCallback(const char* msg); +sgct::Engine* SgctEngine; + +#ifdef OPENVR_SUPPORT +sgct::SGCTWindow* FirstOpenVRWindow = nullptr; +#endif std::pair supportedOpenGLVersion() { + // Just create a window in order to retrieve the available OpenGL version before we + // create the real window glfwInit(); // On OS X we need to explicitly set the version and specify that we are using CORE @@ -69,83 +63,282 @@ std::pair supportedOpenGLVersion() { #endif glfwWindowHint(GLFW_VISIBLE, GL_FALSE); + + // By creating an offscreen window, the user will not know that we created this window GLFWwindow* offscreen = glfwCreateWindow(128, 128, "", nullptr, nullptr); glfwMakeContextCurrent(offscreen); + // Get the OpenGL version int major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); + // And get rid of the window again glfwDestroyWindow(offscreen); glfwWindowHint(GLFW_VISIBLE, GL_TRUE); + return { major, minor }; } -namespace { - const std::string _loggerCat = "main"; +void mainInitFunc() { + LTRACE("main::mainInitFunc(begin)"); + + LDEBUG("Initializing OpenSpace Engine started"); + OsEng.initialize(); + LDEBUG("Initializing OpenSpace Engine finished"); + + LDEBUG("Initializing OpenGL in OpenSpace Engine started"); + OsEng.initializeGL(); + LDEBUG("Initializing OpenGL in OpenSpace Engine finished"); + + // Find if we have at least one OpenVR window + // Save reference to first OpenVR window, which is the one we will copy to the HMD. + for (size_t i = 0; i < SgctEngine->getNumberOfWindows(); ++i) { + if (SgctEngine->getWindowPtr(i)->checkIfTagExists("OpenVR")) { +#ifdef OPENVR_SUPPORT + FirstOpenVRWindow = SgctEngine->getWindowPtr(i); + + // If we have an OpenVRWindow, initialize OpenVR. + sgct::SGCTOpenVR::initialize( + SgctEngine->getNearClippingPlane(), _sgctEngine->getFarClippingPlane() + ); +#else + LWARNING( + "OpenVR was requested, but OpenSpace was compiled without VR support." + ); +#endif + + break; + } + } + + // Set the clear color for all non-linear projection viewports + // @CLEANUP: Why is this necessary? We can set the clear color in the configuration + // files --- abock + size_t nWindows = SgctEngine->getNumberOfWindows(); + for (size_t i = 0; i < nWindows; ++i) { + sgct::SGCTWindow* w = SgctEngine->getWindowPtr(i); + size_t nViewports = w->getNumberOfViewports(); + for (size_t j = 0; j < nViewports; ++j) { + sgct_core::Viewport* v = w->getViewport(j); + ghoul_assert(v != nullptr, "Number of reported viewports was incorrect"); + sgct_core::NonLinearProjection* p = v->getNonLinearProjectionPtr(); + if (p) + p->setClearColor(glm::vec4(0.f, 0.f, 0.f, 1.f)); + } + } + LTRACE("main::mainInitFunc(end)"); } -int main(int argc, char** argv) { - auto glVersion = supportedOpenGLVersion(); +void mainPreSyncFunc() { + LTRACE("main::mainPreSyncFunc(begin)"); + OsEng.setRunTime(sgct::Engine::getTime()); + OsEng.preSynchronization(); + LTRACE("main::mainPreSyncFunc(end)"); +} + +void mainPostSyncPreDrawFunc() { + LTRACE("main::postSynchronizationPreDraw(begin)"); + OsEng.postSynchronizationPreDraw(); + +#ifdef OPENVR_SUPPORT + if (FirstOpenVRWindow) { + // Update pose matrices for all tracked OpenVR devices once per frame + sgct::SGCTOpenVR::updatePoses(); + } +#endif + + LTRACE("main::postSynchronizationPreDraw(end)"); +} + +void mainRenderFunc() { + LTRACE("main::mainRenderFunc(begin)"); + + glm::mat4 viewMatrix = + SgctEngine->getCurrentViewMatrix() * + // User matrix + glm::translate( + glm::mat4(1.f), + SgctEngine->getDefaultUserPtr()->getPos() + ) + ; + + glm::mat4 projectionMatrix = SgctEngine->getCurrentProjectionMatrix(); +#ifdef OPENVR_SUPPORT + bool currentWindowIsHMD = FirstOpenVRWindow == _sgctEngine->getCurrentWindowPtr(); + if (sgct::SGCTOpenVR::isHMDActive() && currentWindowIsHMD) { + projectionMatrix = sgct::SGCTOpenVR::getHMDCurrentViewProjectionMatrix( + _sgctEngine->getCurrentFrustumMode() + ); + } +#endif + + if (SgctEngine->isMaster()) { + OsEng.render(viewMatrix, projectionMatrix); + } + else { + glm::mat4 sceneMatrix = SgctEngine->getModelMatrix(); + OsEng.render(viewMatrix * sceneMatrix, projectionMatrix); + } + LTRACE("main::mainRenderFunc(end)"); +} + +void mainPostDrawFunc() { + LTRACE("main::mainPostDrawFunc(begin)"); + +#ifdef OPENVR_SUPPORT + if (FirstOpenVRWindow) { + // Copy the first OpenVR window to the HMD + sgct::SGCTOpenVR::copyWindowToHMD(FirstOpenVRWindow); + } +#endif + + OsEng.postDraw(); + LTRACE("main::mainPostDrawFunc(end)"); +} + +void mainExternalControlCallback(const char* receivedChars, int size) { + LTRACE("main::mainExternalControlCallback(begin)"); + if (SgctEngine->isMaster()) { + OsEng.externalControlCallback(receivedChars, size, 0); + } + LTRACE("main::mainExternalControlCallback(end)"); +} + +void mainKeyboardCallback(int key, int, int action, int mods) { + LTRACE("main::mainKeyboardCallback(begin)"); + if (SgctEngine->isMaster()) { + OsEng.keyboardCallback( + openspace::Key(key), + openspace::KeyModifier(mods), + openspace::KeyAction(action) + ); + } + LTRACE("main::mainKeyboardCallback(begin)"); +} + +void mainMouseButtonCallback(int key, int action) { + LTRACE("main::mainMouseButtonCallback(begin)"); + if (SgctEngine->isMaster()) { + OsEng.mouseButtonCallback( + openspace::MouseButton(key), + openspace::MouseAction(action) + ); + } + LTRACE("main::mainMouseButtonCallback(end)"); +} + +void mainMousePosCallback(double x, double y) { + if (SgctEngine->isMaster()) { + OsEng.mousePositionCallback(x, y); + } +} + +void mainMouseScrollCallback(double posX, double posY) { + LTRACE("main::mainMouseScrollCallback(begin"); + if (SgctEngine->isMaster()) { + OsEng.mouseScrollWheelCallback(posY); + } + LTRACE("main::mainMouseScrollCallback(end)"); +} + +void mainCharCallback(unsigned int codepoint, int mods) { + if (SgctEngine->isMaster()) { + OsEng.charCallback(codepoint, openspace::KeyModifier(mods)); + } +} + +void mainEncodeFun() { + LTRACE("main::mainEncodeFun(begin)"); + OsEng.encode(); + LTRACE("main::mainEncodeFun(end)"); +} + +void mainDecodeFun() { + LTRACE("main::mainDecodeFun(begin)"); + OsEng.decode(); + LTRACE("main::mainDecodeFun(end)"); +} + +void mainLogCallback(const char* msg) { + std::string message = msg; + if (message.empty() || message == ".") { + // We don't want the empty '.' message that SGCT sends while it is waiting for + // connections from other network nodes + return; + } + // Remove the trailing \n that is passed along + LINFOC("SGCT", message.substr(0, message.size() - 1)); +} + +int main_main(int argc, char** argv) { + std::pair glVersion = supportedOpenGLVersion(); - // create the OpenSpace engine and get arguments for the sgct engine + // Create the OpenSpace engine and get arguments for the SGCT engine + // @CLEANUP: Replace the return valua with throwing an exception --abock std::vector sgctArguments; - const bool success = openspace::OpenSpaceEngine::create( + bool requestQuit = false; + openspace::OpenSpaceEngine::create( argc, argv, std::make_unique(), - sgctArguments + sgctArguments, + requestQuit ); - if (!success) - return EXIT_FAILURE; + + if (requestQuit) { + return EXIT_SUCCESS; + } LINFO("Detected OpenGL version: " << glVersion.first << "." << glVersion.second); - - // create sgct engine c arguments + + // Create sgct engine c arguments int newArgc = static_cast(sgctArguments.size()); + char** newArgv = new char*[newArgc]; - for (int i = 0; i < newArgc; ++i) + for (int i = 0; i < newArgc; ++i) { newArgv[i] = const_cast(sgctArguments.at(i).c_str()); - + } + // Need to set this before the creation of the sgct::Engine sgct::MessageHandler::instance()->setLogToConsole(false); sgct::MessageHandler::instance()->setShowTime(false); sgct::MessageHandler::instance()->setLogToCallback(true); sgct::MessageHandler::instance()->setLogCallback(mainLogCallback); - + #ifdef __APPLE__ glfwWindowHint(GLFW_STENCIL_BITS, 8); #endif LDEBUG("Creating SGCT Engine"); - _sgctEngine = new sgct::Engine(newArgc, newArgv); - - // deallocate sgct c arguments + SgctEngine = new sgct::Engine(newArgc, newArgv); + + // Deallocate sgct c arguments delete[] newArgv; - + // Bind functions - _sgctEngine->setInitOGLFunction(mainInitFunc); - _sgctEngine->setPreSyncFunction(mainPreSyncFunc); - _sgctEngine->setPostSyncPreDrawFunction(mainPostSyncPreDrawFunc); - _sgctEngine->setDrawFunction(mainRenderFunc); - _sgctEngine->setPostDrawFunction(mainPostDrawFunc); - _sgctEngine->setKeyboardCallbackFunction(mainKeyboardCallback); - _sgctEngine->setMouseButtonCallbackFunction(mainMouseButtonCallback); - _sgctEngine->setMousePosCallbackFunction(mainMousePosCallback); - _sgctEngine->setMouseScrollCallbackFunction(mainMouseScrollCallback); - _sgctEngine->setExternalControlCallback(mainExternalControlCallback); - _sgctEngine->setCharCallbackFunction(mainCharCallback); - + SgctEngine->setInitOGLFunction(mainInitFunc); + SgctEngine->setPreSyncFunction(mainPreSyncFunc); + SgctEngine->setPostSyncPreDrawFunction(mainPostSyncPreDrawFunc); + SgctEngine->setDrawFunction(mainRenderFunc); + SgctEngine->setPostDrawFunction(mainPostDrawFunc); + SgctEngine->setKeyboardCallbackFunction(mainKeyboardCallback); + SgctEngine->setMouseButtonCallbackFunction(mainMouseButtonCallback); + SgctEngine->setMousePosCallbackFunction(mainMousePosCallback); + SgctEngine->setMouseScrollCallbackFunction(mainMouseScrollCallback); + SgctEngine->setExternalControlCallback(mainExternalControlCallback); + SgctEngine->setCharCallbackFunction(mainCharCallback); + // Disable the immediate exit of the application when the ESC key is pressed - _sgctEngine->setExitKey(SGCT_KEY_UNKNOWN); - + SgctEngine->setExitKey(SGCT_KEY_UNKNOWN); + sgct::MessageHandler::instance()->setNotifyLevel(sgct::MessageHandler::NOTIFY_ALL); - - // set encode and decode functions + + // Set encode and decode functions // NOTE: starts synchronizing before init functions sgct::SharedData::instance()->setEncodeFunction(mainEncodeFun); sgct::SharedData::instance()->setDecodeFunction(mainDecodeFun); - - // try to open a window + + // Try to open a window LDEBUG("Initialize SGCT Engine"); std::map, sgct::Engine::RunMode> versionMapping = { { { 3, 3 }, sgct::Engine::RunMode::OpenGL_3_3_Core_Profile }, @@ -160,236 +353,73 @@ int main(int argc, char** argv) { versionMapping.find(glVersion) != versionMapping.end(), "Unknown OpenGL version. Missing statement in version mapping map" ); - sgct::Engine::RunMode rm = versionMapping[glVersion]; - const bool initSuccess = _sgctEngine->init(rm); - + + auto cleanup = [&](){ + OsEng.deinitialize(); + + // Clear function bindings to avoid crash after destroying the OpenSpace Engine + sgct::MessageHandler::instance()->setLogToCallback(false); + sgct::MessageHandler::instance()->setLogCallback(nullptr); + + LDEBUG("Destroying OpenSpaceEngine"); + openspace::OpenSpaceEngine::destroy(); + + LDEBUG("Destroying SGCT Engine"); + delete SgctEngine; + }; + + bool initSuccess = SgctEngine->init(versionMapping[glVersion]); + if (!initSuccess) { LFATAL("Initializing failed"); - // could not open a window, deallocates and exits - delete _sgctEngine; - openspace::OpenSpaceEngine::destroy(); + cleanup(); return EXIT_FAILURE; } - + // Main loop LDEBUG("Starting rendering loop"); - try { - _sgctEngine->render(); - } - catch (const ghoul::RuntimeError& e) { - // Write out all of the information about the exception, flush the logs, and throw - LFATALC(e.component, e.message); - LogMgr.flushLogs(); - throw; - } - catch (const std::exception& e) { - // Write out all of the information about the exception, flush the logs, and throw - LFATALC("Exception", e.what()); - LogMgr.flushLogs(); - throw; - } - catch (...) { - // Write out all of the information about the exception, flush the logs, and throw - LFATALC("Exception", "Unknown exception"); - LogMgr.flushLogs(); - throw; - } - - //clear function bindings to avoid crash after destroying the OpenSpace Engine - sgct::MessageHandler::instance()->setLogToCallback(false); - sgct::MessageHandler::instance()->setLogCallback(nullptr); - - LDEBUG("Destroying OpenSpaceEngine"); - openspace::OpenSpaceEngine::destroy(); - - // Clean up (deallocate) - LDEBUG("Destroying SGCT Engine"); - delete _sgctEngine; - + SgctEngine->render(); + LDEBUG("Ending rendering loop"); + + cleanup(); + +#ifdef OPENVR_SUPPORT + // Clean up OpenVR + sgct::SGCTOpenVR::shutdown(); +#endif + // Exit program exit(EXIT_SUCCESS); } - -void mainInitFunc() { - //is this node the master? (must be set after call to _sgctEngine->init()) - OsEng.setMaster(_sgctEngine->isMaster()); - bool success = OsEng.initialize(); - if (success) - success = OsEng.initializeGL(); +} // namespace - if (!success) { - LFATAL("Initializing OpenSpaceEngine failed"); - exit(EXIT_FAILURE); +int main(int argc, char** argv) { + return main_main(argc, argv); + // We wrap the actual main function in a try catch block so that we can get and print + // some additional information in case an exception is raised + try { + return main_main(argc, argv); } - - // Set the clear color for all non-linear projection viewports - size_t nWindows = _sgctEngine->getNumberOfWindows(); - for (size_t i = 0; i < nWindows; ++i) { - sgct::SGCTWindow* w = _sgctEngine->getWindowPtr(i); - size_t nViewports = w->getNumberOfViewports(); - for (size_t j = 0; j < nViewports; ++j) { - sgct_core::Viewport* v = w->getViewport(j); - ghoul_assert(v != nullptr, "Number of reported viewports was incorrect"); - sgct_core::NonLinearProjection* p = v->getNonLinearProjectionPtr(); - if (p) - p->setClearColor(glm::vec4(0.f, 0.f, 0.f, 1.f)); - } + catch (const ghoul::RuntimeError& e) { + // Write out all of the information about the exception and flush the logs + LFATALC(e.component, e.message); + LogMgr.flushLogs(); + return EXIT_FAILURE; } - -} - -struct FunctionLogKey { - char begin, end; -}; - -#include - - -std::stringstream& operator<<(std::stringstream& o, const FunctionLogKey& l) { - o << l.begin << l.end; - return o; -} - - - -const FunctionLogKey PRE_SYNC = { '1', '2' }; -const FunctionLogKey ENCODE = { 'E', 'e' }; -const FunctionLogKey DECODE = { 'D', 'd' }; -const FunctionLogKey POST_SYNC = { '3', '4' }; -const FunctionLogKey RENDER = { 'R', 'r' }; -const FunctionLogKey POST_DRAW = { 'P', 'p' }; - -std::stringstream minilog; -std::stringstream masterlog; -std::stringstream slavelog; - -const std::string EXPECTED_MASTER_LOG = (masterlog << PRE_SYNC << ENCODE << POST_SYNC << RENDER << POST_DRAW).str(); -const std::string EXPECTED_SLAVE_LOG = (slavelog << PRE_SYNC << DECODE << POST_SYNC << RENDER << POST_DRAW).str(); - -#define LOG_BEGIN(x) minilog << (x).begin -#define LOG_END(x) minilog << (x).end - - -void mainPreSyncFunc() { - LOG_BEGIN(PRE_SYNC); - OsEng.setRunTime(sgct::Engine::getTime()); - OsEng.preSynchronization(); - LOG_END(PRE_SYNC); -} - -volatile bool busyWaitDecode = false; -void mainPostSyncPreDrawFunc() { - if (OsEng.useBusyWaitForDecode() && !sgct::Engine::instance()->isMaster()) { - while (minilog.str().size() && minilog.str().back() != DECODE.end) { - std::this_thread::sleep_for(std::chrono::microseconds(10)); - } + catch (const ghoul::AssertionException& e) { + // We don't want to catch the assertion exception as we won't be able to add a + // breakpoint for debugging + LFATALC("Assertion failed", e.what()); + throw; + } catch (const std::exception& e) { + LFATALC("Exception", e.what()); + LogMgr.flushLogs(); + return EXIT_FAILURE; } - LOG_BEGIN(POST_SYNC); - OsEng.postSynchronizationPreDraw(); - LOG_END(POST_SYNC); -} - -void mainRenderFunc() { - LOG_BEGIN(RENDER); - using glm::mat4; - using glm::translate; - //not the most efficient, but for clarity @JK - - mat4 userMatrix = translate(mat4(1.f), _sgctEngine->getDefaultUserPtr()->getPos()); - mat4 sceneMatrix = _sgctEngine->getModelMatrix(); - mat4 viewMatrix = _sgctEngine->getCurrentViewMatrix() * userMatrix; - - //dont shift nav-direction on master, makes it very tricky to navigate @JK - if (!OsEng.ref().isMaster()) - viewMatrix = viewMatrix * sceneMatrix; - - mat4 projectionMatrix = _sgctEngine->getCurrentProjectionMatrix(); - OsEng.render(projectionMatrix, viewMatrix); - LOG_END(RENDER); -} - -void mainPostDrawFunc() { - LOG_BEGIN(POST_DRAW); - OsEng.postDraw(); - LOG_END(POST_DRAW); - - if (OsEng.logSGCTOutOfOrderErrors()) { - if (sgct::Engine::instance()->isMaster()) { - if (minilog.str() != EXPECTED_MASTER_LOG) { - LERRORC("Minilog", "Bad combination: " << minilog.str()); - } - } - else { - if (minilog.str() != EXPECTED_SLAVE_LOG) { - LERRORC("Minilog", "Bad combination: " << minilog.str()); - } - } - } - - - // clear - minilog.str(std::string()); -} - -void mainExternalControlCallback(const char* receivedChars, int size) { - if (OsEng.isMaster()) - OsEng.externalControlCallback(receivedChars, size, 0); -} - -void mainKeyboardCallback(int key, int, int action, int mods) { - if (OsEng.isMaster()) { - OsEng.keyboardCallback( - openspace::Key(key), - openspace::KeyModifier(mods), - openspace::KeyAction(action) - ); + catch (...) { + LFATALC("Exception", "Unknown exception"); + LogMgr.flushLogs(); + return EXIT_FAILURE; } } - -void mainMouseButtonCallback(int key, int action) { - if (OsEng.isMaster()) { - OsEng.mouseButtonCallback( - openspace::MouseButton(key), - openspace::MouseAction(action) - ); - } -} - -void mainMousePosCallback(double x, double y) { - if (OsEng.isMaster()) - OsEng.mousePositionCallback(x, y); -} - -void mainMouseScrollCallback(double posX, double posY) { - if (OsEng.isMaster()) - OsEng.mouseScrollWheelCallback(posY); -} - -void mainCharCallback(unsigned int codepoint, int mods) { - if (OsEng.isMaster()) - OsEng.charCallback(codepoint, openspace::KeyModifier(mods)); -} - -void mainEncodeFun() { - LOG_BEGIN(ENCODE); - OsEng.encode(); - LOG_END(ENCODE); -} - -void mainDecodeFun() { - LOG_BEGIN(DECODE); - OsEng.decode(); - LOG_END(DECODE); - -} - -void mainLogCallback(const char* msg) { - std::string message = msg; - if (message.empty() || message == ".") - // We don't want the empty '.' message that SGCT sends while it is waiting for - // connections from other network nodes - return; - // Remove the trailing \n that is passed along - LINFOC("SGCT", message.substr(0, std::max(message.size() - 1, 0))); -} diff --git a/apps/DataConverter/CMakeLists.txt b/apps/TaskRunner/CMakeLists.txt similarity index 85% rename from apps/DataConverter/CMakeLists.txt rename to apps/TaskRunner/CMakeLists.txt index 24bfdc7968..69f23771d3 100644 --- a/apps/DataConverter/CMakeLists.txt +++ b/apps/TaskRunner/CMakeLists.txt @@ -22,26 +22,18 @@ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ######################################################################################### -set(APPLICATION_NAME DataConverter) +set(APPLICATION_NAME TaskRunner) set(APPLICATION_LINK_TO_OPENSPACE ON) include (${GHOUL_BASE_DIR}/support/cmake/handle_external_library.cmake) -set(application_path ${OPENSPACE_APPS_DIR}/DataConverter) +set(application_path ${OPENSPACE_APPS_DIR}/TaskRunner) set(SOURCE_FILES ${application_path}/main.cpp - ${application_path}/milkywayconversiontask.cpp - ${application_path}/milkywaypointsconversiontask.cpp -) -set(HEADER_FILES - ${application_path}/conversiontask.h - ${application_path}/milkywayconversiontask.h - ${application_path}/milkywaypointsconversiontask.h ) add_executable(${APPLICATION_NAME} MACOSX_BUNDLE ${SOURCE_FILES} - ${HEADER_FILES} ) diff --git a/apps/DataConverter/main.cpp b/apps/TaskRunner/main.cpp similarity index 52% rename from apps/DataConverter/main.cpp rename to apps/TaskRunner/main.cpp index d0f8579a0a..5edbd82b41 100644 --- a/apps/DataConverter/main.cpp +++ b/apps/TaskRunner/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -33,50 +33,98 @@ #include #include +#include + +#include + #include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include - -int main(int argc, char** argv) { - using namespace openspace; - using namespace dataconverter; - - ghoul::initialize(); +namespace { + const std::string ConfigurationFile = "openspace.cfg"; + const std::string _loggerCat = "TaskRunner Main"; +} +void initTextureReaders() { #ifdef GHOUL_USE_DEVIL ghoul::io::TextureReader::ref().addReader(std::make_shared()); #endif // GHOUL_USE_DEVIL #ifdef GHOUL_USE_FREEIMAGE ghoul::io::TextureReader::ref().addReader(std::make_shared()); #endif // GHOUL_USE_FREEIMAGE +} - openspace::ProgressBar pb(100); - std::function onProgress = [&](float progress) { - pb.print(progress * 100); - }; +int main(int argc, char** argv) { + using namespace openspace; - // TODO: Make the converter configurable using either - // config files (json, lua dictionaries), - // lua scripts, - // or at the very least: a command line interface. - - MilkyWayConversionTask mwConversionTask( - "F:/mw_june2016/volumeslices/img/comp/v003/frames/primary/0100/cam2_main.", - ".exr", - 1385, - 512, - "F:/mw_june2016/mw_512_512_64_june.rawvolume", - glm::vec3(512, 512, 64)); + ghoul::initialize(); + initTextureReaders(); + + FactoryManager::initialize(); + FactoryManager::ref().addFactory( + std::make_unique>(), + "Renderable" + ); + FactoryManager::ref().addFactory( + std::make_unique>(), + "Task" + ); + FactoryManager::ref().addFactory( + std::make_unique>(), + "Translation" + ); + + FactoryManager::ref().addFactory( + std::make_unique>(), + "Rotation" + ); + + FactoryManager::ref().addFactory( + std::make_unique>(), + "Scale" + ); + + openspace::ConfigurationManager configuration; + std::string configurationFile = configuration.findConfiguration(ConfigurationFile); + configuration.loadFromFile(configurationFile); + + ModuleEngine moduleEngine; + moduleEngine.initialize(); + + std::string tasksPath; + configuration.getValue(ConfigurationManager::KeyConfigTask, tasksPath); + + LINFO("Initialization done."); + + TaskLoader taskLoader; + std::vector> tasks = taskLoader.tasksFromFile(tasksPath); - //MilkyWayPointsConversionTask mwpConversionTask("F:/mw_june2016/points.off", "F:/mw_june2016/points.off.binary"); + size_t nTasks = tasks.size(); + if (nTasks == 1) { + LINFO("Task queue has 1 item"); + } else { + LINFO("Task queue has " << tasks.size() << " items"); + } + for (size_t i = 0; i < tasks.size(); i++) { + Task& task = *tasks[i].get(); + LINFO("Performing task " << (i+1) << " out of " << tasks.size() << ": " << task.description()); + ProgressBar progressBar(100); + auto onProgress = [&progressBar](float progress) { + progressBar.print(progress * 100); + }; + task.perform(onProgress); + } - mwConversionTask.perform(onProgress); - //mwpConversionTask.perform(onProgress); - - - std::cout << "Done." << std::endl; + std::cout << "Done performing tasks." << std::endl; std::cin.get(); return 0; diff --git a/apps/TimelineView/common.h b/apps/TimelineView/common.h index ddc0bad206..bf0506a02a 100644 --- a/apps/TimelineView/common.h +++ b/apps/TimelineView/common.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __COMMON_H__ -#define __COMMON_H__ +#ifndef __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__ +#define __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__ struct Image { double beginning; @@ -34,4 +34,4 @@ struct Image { std::vector instruments; }; -#endif // __COMMON_H__ +#endif // __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__ diff --git a/apps/TimelineView/configurationwidget.cpp b/apps/TimelineView/configurationwidget.cpp index 97961abf20..9537b21953 100644 --- a/apps/TimelineView/configurationwidget.cpp +++ b/apps/TimelineView/configurationwidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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/configurationwidget.h b/apps/TimelineView/configurationwidget.h index 1f7ff034c2..4b59ddd8f0 100644 --- a/apps/TimelineView/configurationwidget.h +++ b/apps/TimelineView/configurationwidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __CONFIGURATIONWIDGET_H__ -#define __CONFIGURATIONWIDGET_H__ +#ifndef __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__ +#define __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__ #include #include @@ -50,4 +50,4 @@ private: QPushButton* _connect; }; -#endif // __CONFIGURATIONWIDGET_H__ +#endif // __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__ diff --git a/apps/TimelineView/controlwidget.cpp b/apps/TimelineView/controlwidget.cpp index b082de3f13..010e00a9cd 100644 --- a/apps/TimelineView/controlwidget.cpp +++ b/apps/TimelineView/controlwidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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/controlwidget.h b/apps/TimelineView/controlwidget.h index 5c6e99e5df..da52b729fb 100644 --- a/apps/TimelineView/controlwidget.h +++ b/apps/TimelineView/controlwidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __CONTROLWIDGET_H__ -#define __CONTROLWIDGET_H__ +#ifndef __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ +#define __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ #include @@ -66,4 +66,4 @@ private: QPushButton* _setFocusToNewHorizons; }; -#endif // __CONTROLWIDGET_H__ +#endif // __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ diff --git a/apps/TimelineView/informationwidget.cpp b/apps/TimelineView/informationwidget.cpp index ac7ae9935a..ca357ff538 100644 --- a/apps/TimelineView/informationwidget.cpp +++ b/apps/TimelineView/informationwidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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/informationwidget.h b/apps/TimelineView/informationwidget.h index 811151a415..5d87292856 100644 --- a/apps/TimelineView/informationwidget.h +++ b/apps/TimelineView/informationwidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __INFORMATIONWIDGET_H__ -#define __INFORMATIONWIDGET_H__ +#ifndef __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ +#define __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ #include @@ -38,4 +38,4 @@ public slots: void logInformation(QString text); }; -#endif // __INFORMATIONWIDGET_H__ +#endif // __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ diff --git a/apps/TimelineView/main.cpp b/apps/TimelineView/main.cpp index f9bd72520c..420f02fcd7 100644 --- a/apps/TimelineView/main.cpp +++ b/apps/TimelineView/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 dc5e623e88..088f4f3a95 100644 --- a/apps/TimelineView/mainwindow.cpp +++ b/apps/TimelineView/mainwindow.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 9c23cf8448..5bb3774885 100644 --- a/apps/TimelineView/mainwindow.h +++ b/apps/TimelineView/mainwindow.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __MAINWINDOW_H__ -#define __MAINWINDOW_H__ +#ifndef __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ +#define __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ #include #include @@ -71,4 +71,4 @@ private: bool _isConnected = false; }; -#endif // __MAINWINDOW_H__ +#endif // __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ diff --git a/apps/TimelineView/timelinewidget.cpp b/apps/TimelineView/timelinewidget.cpp index 791e90dba1..1003a82d24 100644 --- a/apps/TimelineView/timelinewidget.cpp +++ b/apps/TimelineView/timelinewidget.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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/timelinewidget.h b/apps/TimelineView/timelinewidget.h index be3a880d00..3ad24c33b5 100644 --- a/apps/TimelineView/timelinewidget.h +++ b/apps/TimelineView/timelinewidget.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __TIMELINEWIDGET_H__ -#define __TIMELINEWIDGET_H__ +#ifndef __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__ +#define __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__ #include @@ -67,4 +67,4 @@ private: } _currentTime; }; -#endif // __TIMELINEWIDGET_H__ +#endif // __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__ diff --git a/config/sgct/VRArenaSimCenter.xml b/config/sgct/VRArenaSimCenter.xml deleted file mode 100644 index f57ec51789..0000000000 --- a/config/sgct/VRArenaSimCenter.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/sgct/ccmc_lab_all.xml b/config/sgct/ccmc_lab_all.xml deleted file mode 100644 index 9c2fcd4958..0000000000 --- a/config/sgct/ccmc_lab_all.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/sgct/ccmc_lab_work.xml b/config/sgct/ccmc_lab_work.xml deleted file mode 100644 index 0c9f4069b6..0000000000 --- a/config/sgct/ccmc_lab_work.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/sgct/openvr_htcVive.xml b/config/sgct/openvr_htcVive.xml new file mode 100644 index 0000000000..e663b11521 --- /dev/null +++ b/config/sgct/openvr_htcVive.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/sgct/openvr_oculusRiftCv1.xml b/config/sgct/openvr_oculusRiftCv1.xml new file mode 100644 index 0000000000..e264dd3788 --- /dev/null +++ b/config/sgct/openvr_oculusRiftCv1.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/sgct/single.xml b/config/sgct/single.xml index 7b20bcb10c..6f8f58b23b 100644 --- a/config/sgct/single.xml +++ b/config/sgct/single.xml @@ -4,7 +4,7 @@ - + diff --git a/config/sgct/single_4k.xml b/config/sgct/single_4k.xml deleted file mode 100644 index cb4dd6339c..0000000000 --- a/config/sgct/single_4k.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/sgct/single_gui.xml b/config/sgct/single_gui.xml index a3956e40f6..129232a9ea 100644 --- a/config/sgct/single_gui.xml +++ b/config/sgct/single_gui.xml @@ -4,7 +4,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/config/sgct/single_sbs_stereo.xml b/config/sgct/single_sbs_stereo.xml deleted file mode 100644 index d92f95ed66..0000000000 --- a/config/sgct/single_sbs_stereo.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/sgct/single_stereo.xml b/config/sgct/single_stereo.xml deleted file mode 100644 index 8497af6188..0000000000 --- a/config/sgct/single_stereo.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/sgct/single_two_win.xml b/config/sgct/single_two_win.xml index 4cd802423a..2f7f49efc6 100644 --- a/config/sgct/single_two_win.xml +++ b/config/sgct/single_two_win.xml @@ -3,34 +3,26 @@ - + - - - - - - - - + + + + - + - - - - - - - - + + + + diff --git a/config/sgct/two_nodes.xml b/config/sgct/two_nodes.xml index 9ec00bf7bc..bbcd4a63e5 100644 --- a/config/sgct/two_nodes.xml +++ b/config/sgct/two_nodes.xml @@ -4,18 +4,13 @@ - - + - - - - - - - - + + + + @@ -23,18 +18,14 @@ - + - - - - - - - - + + + + diff --git a/data/scene/atmosphereearth.scene b/data/scene/atmosphereearth.scene index 914c040ca7..e00b18fc74 100644 --- a/data/scene/atmosphereearth.scene +++ b/data/scene/atmosphereearth.scene @@ -6,7 +6,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime(openspace.time.currentWallTime()) diff --git a/data/scene/dawn.scene b/data/scene/dawn.scene index 6ae70e3fb9..78c03cece5 100644 --- a/data/scene/dawn.scene +++ b/data/scene/dawn.scene @@ -6,7 +6,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime("2011 AUG 06 00:00:00") diff --git a/data/scene/default.scene b/data/scene/default.scene index d2344f3ab0..b28458aa52 100644 --- a/data/scene/default.scene +++ b/data/scene/default.scene @@ -6,7 +6,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime(openspace.time.currentWallTime()) diff --git a/data/scene/fieldlines.scene b/data/scene/fieldlines.scene index 3cee4bf1e3..cf494fe43c 100644 --- a/data/scene/fieldlines.scene +++ b/data/scene/fieldlines.scene @@ -6,7 +6,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime("2015 JAN 01 12:00:00.000") diff --git a/data/scene/globebrowsing.scene b/data/scene/globebrowsing.scene index c03c92d1b7..23506f5df1 100644 --- a/data/scene/globebrowsing.scene +++ b/data/scene/globebrowsing.scene @@ -7,7 +7,7 @@ function preInitialization() ]]-- --openspace.time.setTime(openspace.time.currentWallTime()) - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime(openspace.time.currentWallTime()) diff --git a/data/scene/juno.scene b/data/scene/juno.scene index f63276e744..403b508435 100755 --- a/data/scene/juno.scene +++ b/data/scene/juno.scene @@ -5,7 +5,7 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime("2016-07-05T10:05:00.00") diff --git a/data/scene/mercury/mercury.mod b/data/scene/mercury/mercury.mod index 75bf33560e..aa4be9675d 100644 --- a/data/scene/mercury/mercury.mod +++ b/data/scene/mercury/mercury.mod @@ -1,3 +1,5 @@ +MercuryRadius = 2.4397E6; + return { -- Mercury barycenter module { @@ -22,7 +24,7 @@ return { Body = "MERCURY", Geometry = { Type = "SimpleSphere", - Radius = { 2.440, 6 }, + Radius = {MercuryRadius, 1.0}, Segments = 100 }, Textures = { diff --git a/data/scene/missions/juno/juno/juno.mod b/data/scene/missions/juno/juno/juno.mod index 12c2d45131..c9e4cc56df 100644 --- a/data/scene/missions/juno/juno/juno.mod +++ b/data/scene/missions/juno/juno/juno.mod @@ -126,19 +126,16 @@ return { Name = "JunoTrail", Parent = "JupiterBarycenter", Renderable = { - Type = "RenderableTrail", - Body = "JUNO", - Frame = "GALACTIC", - Observer = "JUPITER BARYCENTER", - RGB = { 0.70,0.50,0.20 }, - TropicalOrbitPeriod = 394250.0, - EarthOrbitRatio = 4.5, - DayLength = 9.9259, - TimeStamps = false, - Textures = { - Type = "simple", - Color = "textures/glare_blue.png", - }, + Type = "RenderableTrailTrajectory", + Translation = { + Type = "SpiceTranslation", + Body = "JUNO", + Observer = "JUPITER BARYCENTER" + }, + Color = { 0.70, 0.50, 0.20 }, + StartTime = "2016 JUN 28", + EndTime = "2016 APR 01", + SampleInterval = 3600 }, }, } diff --git a/data/scene/missions/newhorizons/pluto/pluto/pluto.mod b/data/scene/missions/newhorizons/pluto/pluto/pluto.mod index e512b74708..53118f9e84 100644 --- a/data/scene/missions/newhorizons/pluto/pluto/pluto.mod +++ b/data/scene/missions/newhorizons/pluto/pluto/pluto.mod @@ -30,9 +30,9 @@ return { }, }, }, - -- PlutoProjection module + -- Pluto module { - Name = "PlutoProjection", + Name = "Pluto", Parent = "PlutoBarycenter", Renderable = { Type = "RenderablePlanetProjection", @@ -184,7 +184,7 @@ return { }, { Name = "PlutoText", - Parent = "PlutoProjection", + Parent = "Pluto", Renderable = { Type = "RenderablePlane", Size = {1.0, 6.3}, @@ -202,7 +202,7 @@ return { }, { Name = "PlutoTexture", - Parent = "PlutoProjection", + Parent = "Pluto", Renderable = { Type = "RenderablePlane", Size = {1.0, 6.4}, @@ -220,7 +220,7 @@ return { }, { Name = "PlutoShadow", - Parent = "PlutoProjection", + Parent = "Pluto", Renderable = { Type = "RenderableShadowCylinder", TerminatorType = "PENUMBRAL", diff --git a/data/scene/newhorizons.scene b/data/scene/newhorizons.scene index ca5e4106c9..3ce05ababc 100644 --- a/data/scene/newhorizons.scene +++ b/data/scene/newhorizons.scene @@ -11,7 +11,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime("2015-07-14T10:05:00.00") diff --git a/data/scene/osirisrex.scene b/data/scene/osirisrex.scene index e59ce808d3..f5fff215a9 100644 --- a/data/scene/osirisrex.scene +++ b/data/scene/osirisrex.scene @@ -9,7 +9,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") dofile(openspace.absPath('${SCRIPTS}/bind_keys_osirisrex.lua')) @@ -61,7 +61,7 @@ return { "sun", "mercury", "venus", - "lodglobes/lodearth", + "lodglobes/earth", "moon", "mars", "jupiter", diff --git a/data/scene/rosetta.scene b/data/scene/rosetta.scene index 361397876f..3ba32966e7 100644 --- a/data/scene/rosetta.scene +++ b/data/scene/rosetta.scene @@ -6,7 +6,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") -- Usual start diff --git a/data/scene/saturn/saturn/saturn.mod b/data/scene/saturn/saturn/saturn.mod index aea907718b..4dc0a215c6 100644 --- a/data/scene/saturn/saturn/saturn.mod +++ b/data/scene/saturn/saturn/saturn.mod @@ -1,3 +1,6 @@ +SaturnRadius = 5.8232E7; + + return { -- Saturn barycenter module { @@ -23,7 +26,7 @@ return { Body = "SATURN BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = { 5.8232, 7 }, + Radius = {SaturnRadius, 0}, Segments = 100 }, Textures = { diff --git a/data/scene/volumetricmilkyway.scene b/data/scene/volumetricmilkyway.scene index 9d6c9ba91d..3a4f4d71c2 100644 --- a/data/scene/volumetricmilkyway.scene +++ b/data/scene/volumetricmilkyway.scene @@ -6,7 +6,7 @@ function preInitialization() critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") openspace.time.setTime(openspace.time.currentWallTime()) diff --git a/data/spice/iSWAKernels/openspace_mercury.ti b/data/spice/iSWAKernels/openspace_mercury.ti new file mode 100644 index 0000000000..218f8c3ec2 --- /dev/null +++ b/data/spice/iSWAKernels/openspace_mercury.ti @@ -0,0 +1,33 @@ +OpenSpace ecliptic frames: +Mercury-centric Solar Ecliptic (MERCURYSE) frame + +These frames are only defined as helper frames for OpenSpace. + + +X is parallel to the geometric planet-sun position vector. + + -Y axis is the normalized component of the planet's orbital vector + + +Z axis is parallel to the cross product of the frame's +X axis + and the frame's +Y axis. + +\begindata + + FRAME_MERCURYSE = 4600199 + FRAME_4600199_NAME = 'MERCURYSE' + FRAME_4600199_CLASS = 5 + FRAME_4600199_CLASS_ID = 4600199 + FRAME_4600199_CENTER = 199 + FRAME_4600199_RELATIVE = 'J2000' + FRAME_4600199_DEF_STYLE = 'PARAMETERIZED' + FRAME_4600199_FAMILY = 'TWO-VECTOR' + FRAME_4600199_PRI_AXIS = 'X' + FRAME_4600199_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION' + FRAME_4600199_PRI_OBSERVER = 'MERCURY' + FRAME_4600199_PRI_TARGET = 'SUN' + FRAME_4600199_PRI_ABCORR = 'NONE' + FRAME_4600199_SEC_AXIS = 'Y' + FRAME_4600199_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY' + FRAME_4600199_SEC_OBSERVER = 'MERCURY' + FRAME_4600199_SEC_TARGET = 'SUN' + FRAME_4600199_SEC_ABCORR = 'NONE' + FRAME_4600199_SEC_FRAME = 'J2000' diff --git a/data/spice/iSWAKernels/openspace_saturn.ti b/data/spice/iSWAKernels/openspace_saturn.ti new file mode 100644 index 0000000000..46a81299ef --- /dev/null +++ b/data/spice/iSWAKernels/openspace_saturn.ti @@ -0,0 +1,33 @@ +OpenSpace ecliptic frames: +Saturn-centric Solar Ecliptic (SATURNSE) frame + +These frames are only defined as helper frames for OpenSpace. + + +X is parallel to the geometric planet-sun position vector. + + -Y axis is the normalized component of the planet's orbital vector + + +Z axis is parallel to the cross product of the frame's +X axis + and the frame's +Y axis. + +\begindata + + FRAME_SATURNSE = 4500699 + FRAME_4500699_NAME = 'SATURNSE' + FRAME_4500699_CLASS = 5 + FRAME_4500699_CLASS_ID = 4500699 + FRAME_4500699_CENTER = 6 + FRAME_4500699_RELATIVE = 'J2000' + FRAME_4500699_DEF_STYLE = 'PARAMETERIZED' + FRAME_4500699_FAMILY = 'TWO-VECTOR' + FRAME_4500699_PRI_AXIS = 'X' + FRAME_4500699_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION' + FRAME_4500699_PRI_OBSERVER = 'SATURN BARYCENTER' + FRAME_4500699_PRI_TARGET = 'SUN' + FRAME_4500699_PRI_ABCORR = 'NONE' + FRAME_4500699_SEC_AXIS = 'Y' + FRAME_4500699_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY' + FRAME_4500699_SEC_OBSERVER = 'SATURN BARYCENTER' + FRAME_4500699_SEC_TARGET = 'SUN' + FRAME_4500699_SEC_ABCORR = 'NONE' + FRAME_4500699_SEC_FRAME = 'J2000' diff --git a/data/spice/naif0011.tls b/data/spice/naif0012.tls similarity index 95% rename from data/spice/naif0011.tls rename to data/spice/naif0012.tls index 58fcbcbd7f..e1afdee1b6 100644 --- a/data/spice/naif0011.tls +++ b/data/spice/naif0012.tls @@ -7,6 +7,9 @@ LEAPSECONDS KERNEL FILE Modifications: -------------- +2016, Jul. 14 NJB Modified file to account for the leapsecond that + will occur on December 31, 2016. + 2015, Jan. 5 NJB Modified file to account for the leapsecond that will occur on June 30, 2015. @@ -141,7 +144,8 @@ DELTET/DELTA_AT = ( 10, @1972-JAN-1 33, @2006-JAN-1 34, @2009-JAN-1 35, @2012-JUL-1 - 36, @2015-JUL-1 ) + 36, @2015-JUL-1 + 37, @2017-JAN-1 ) \begintext diff --git a/data/tasks/default.task b/data/tasks/default.task new file mode 100644 index 0000000000..1170166620 --- /dev/null +++ b/data/tasks/default.task @@ -0,0 +1,3 @@ +return { + "kameleonmetadatatojson" +} diff --git a/data/web/kameleondocumentation/main.hbs b/data/web/kameleondocumentation/main.hbs new file mode 100644 index 0000000000..a12a1a9931 --- /dev/null +++ b/data/web/kameleondocumentation/main.hbs @@ -0,0 +1,59 @@ +
+ +
+
+

OpenSpace Kameleon Documentation

+

Version: {{version}}

+

CDF File: {{input}}

+

Global Attributes

+ {{#each kameleon.globalAttributes}} +
+
+
+

+ + {{@key}} + +

{{this}}

+

+
+
+
+ {{/each}} +

Variable Attributes

+ {{#each kameleon.variableAttributes}} +

{{@key}}

+ {{#each this}} +
+
+
+

+ + {{@key}} + +

{{this}}

+

+
+
+
+ {{/each}} + {{/each}} +
+
+
\ No newline at end of file diff --git a/data/web/kameleondocumentation/script.js b/data/web/kameleondocumentation/script.js new file mode 100644 index 0000000000..84f9665e59 --- /dev/null +++ b/data/web/kameleondocumentation/script.js @@ -0,0 +1,23 @@ +window.onload = function () { + var mainTemplateElement = document.getElementById('mainTemplate'); + var mainTemplate = Handlebars.compile(mainTemplateElement.innerHTML); + + Handlebars.registerHelper('urlify', function(options, context) { + var data = context.data; + var identifier = options.replace(" ", "-").toLowerCase(); + + while (data = data._parent) { + if (data.key !== undefined) { + identifier = data.key + "-" + identifier; + } + } + + return identifier; + }); + + var dataElement = document.getElementById('data'); + var data = JSON.parse(dataElement.innerHTML); + + var contents = mainTemplate(data); + document.body.innerHTML = contents; +} \ No newline at end of file diff --git a/data/web/log/script.js b/data/web/log/script.js index fea743117f..ac198a1189 100644 --- a/data/web/log/script.js +++ b/data/web/log/script.js @@ -1,4 +1,4 @@ -var levels = ['debug', 'info', 'warning', 'error', 'fatal']; +var levels = ['trace', 'debug', 'info', 'warning', 'error', 'fatal']; var filterLevel = 0; function insertAfter(newNode, referenceNode) { diff --git a/data/web/log/style.css b/data/web/log/style.css index 3aa140b30e..80a17198ed 100644 --- a/data/web/log/style.css +++ b/data/web/log/style.css @@ -27,6 +27,15 @@ label { margin-right: 0.5em; } +.log-level-trace { + color: #eeeeee; + background-color: #aaaaaa; + border-bottom: 1px solid #eaeaea; +} +.log-level-trace td:first-child { + border-left: 10px solid #eaeaea; +} + .log-level-debug { background-color: #bbdda9; border-bottom: 1px solid #7bc142; diff --git a/ext/ghoul b/ext/ghoul index 57f9d38b3a..445ed6353f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 57f9d38b3a36eb9295feae9f4036c7a4b19312fa +Subproject commit 445ed6353fe53ffc2f799de29328ca44de9e3ffb diff --git a/ext/sgct b/ext/sgct index d47e9d6d1d..0bea7bdb11 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit d47e9d6d1d55a1730a6f3a8f58abee4a4a0b95de +Subproject commit 0bea7bdb11fe060b39194801646fb1b8a7ff597d diff --git a/include/openspace/documentation/core_registration.h b/include/openspace/documentation/core_registration.h index 5688a6c24e..9cac4fca85 100644 --- a/include/openspace/documentation/core_registration.h +++ b/include/openspace/documentation/core_registration.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___REGISTRATION___H__ -#define __OPENSPACE_CORE___REGISTRATION___H__ +#ifndef __OPENSPACE_CORE___CORE_REGISTRATION___H__ +#define __OPENSPACE_CORE___CORE_REGISTRATION___H__ namespace openspace { @@ -35,4 +35,4 @@ void registerCoreClasses(scripting::ScriptEngine& engine); } // namespace openspace -#endif // __OPENSPACE_CORE___REGISTRATION___H__ +#endif // __OPENSPACE_CORE___CORE_REGISTRATION___H__ diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 2c4e39fcf2..5e64e3b4bc 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,13 +26,14 @@ #define __OPENSPACE_CORE___DOCUMENTATION___H__ #include -#include #include #include #include #include +namespace ghoul { class Dictionary; } + namespace openspace { namespace documentation { @@ -304,10 +305,6 @@ void testSpecificationAndThrow(const Documentation& documentation, } // namespace documentation -// We want to make it easier for people to use it, so we pull the Documentation class into -// the openspace namespace -using documentation::Documentation; - } // namespace openspace // Make the overload for std::to_string available for the Offense::Reason for easier @@ -316,6 +313,7 @@ using documentation::Documentation; namespace std { std::string to_string(openspace::documentation::TestResult::Offense::Reason reason); +std::string to_string(openspace::documentation::TestResult::Warning::Reason reason); } // namespace std diff --git a/include/openspace/documentation/documentationengine.h b/include/openspace/documentation/documentationengine.h index 95fcca5f98..4841c3efc4 100644 --- a/include/openspace/documentation/documentationengine.h +++ b/include/openspace/documentation/documentationengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 22ae0452d5..61a7cb5b47 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,6 +27,8 @@ #include +#include + #include #include diff --git a/include/openspace/documentation/verifier.inl b/include/openspace/documentation/verifier.inl index 8df5f6e3f6..70751ac380 100644 --- a/include/openspace/documentation/verifier.inl +++ b/include/openspace/documentation/verifier.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,7 +22,10 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include + #include +#include namespace std { std::string to_string(std::string value); @@ -55,86 +58,62 @@ std::string TemplateVerifier::documentation() const { template std::string Vector2Verifier::type() const { - using namespace std::string_literals; - - return "Vector2<"s + typeid(T).name() + ">"; + return std::string("Vector2<") + typeid(T).name() + ">"; } template std::string Vector3Verifier::type() const { - using namespace std::string_literals; - - return "Vector3<"s + typeid(T).name() + ">"; + return std::string("Vector3<") + typeid(T).name() + ">"; } template std::string Vector4Verifier::type() const { - using namespace std::string_literals; - - return "Vector4<"s + typeid(T).name() + ">"; + return std::string("Vector4<") + typeid(T).name() + ">"; } template std::string Matrix2x2Verifier::type() const { - using namespace std::string_literals; - - return "Matrix2x2<"s + typeid(T).name() + ">"; + return std::string("Matrix2x2<") + typeid(T).name() + ">"; } template std::string Matrix2x3Verifier::type() const { - using namespace std::string_literals; - - return "Matrix2x3<"s + typeid(T).name() + ">"; + return std::string("Matrix2x3<") + typeid(T).name() + ">"; } template std::string Matrix2x4Verifier::type() const { - using namespace std::string_literals; - - return "Matrix2x4<"s + typeid(T).name() + ">"; + return std::string("Matrix2x4<") + typeid(T).name() + ">"; } template std::string Matrix3x2Verifier::type() const { - using namespace std::string_literals; - - return "Matrix3x2<"s + typeid(T).name() + ">"; + return std::string("Matrix3x2<") + typeid(T).name() + ">"; } template std::string Matrix3x3Verifier::type() const { - using namespace std::string_literals; - - return "Matrix3x3<"s + typeid(T).name() + ">"; + return std::string("Matrix3x3<") + typeid(T).name() + ">"; } template std::string Matrix3x4Verifier::type() const { - using namespace std::string_literals; - - return "Matrix3x4<"s + typeid(T).name() + ">"; + return std::string("Matrix3x4<") + typeid(T).name() + ">"; } template std::string Matrix4x2Verifier::type() const { - using namespace std::string_literals; - - return "Matrix4x2<"s + typeid(T).name() + ">"; + return std::string("Matrix4x2<") + typeid(T).name() + ">"; } template std::string Matrix4x3Verifier::type() const { - using namespace std::string_literals; - - return "Matrix4x3<"s + typeid(T).name() + ">"; + return std::string("Matrix4x3<") + typeid(T).name() + ">"; } template std::string Matrix4x4Verifier::type() const { - using namespace std::string_literals; - - return "Matrix4x4<"s + typeid(T).name() + ">"; + return std::string("Matrix4x4<") + typeid(T).name() + ">"; } template diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index 3fef274c62..f67b55bc6e 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,11 +25,10 @@ #ifndef __OPENSPACE_CORE___CONFIGURATIONMANAGER___H__ #define __OPENSPACE_CORE___CONFIGURATIONMANAGER___H__ -#include - #include namespace openspace { +namespace documentation { struct Documentation; } /** * The ConfigurationManager takes care of loading the major configuration file @@ -69,6 +68,8 @@ public: static const std::string KeyFactoryDocumentation; /// The key that stores the location of the scene file that is initially loaded static const std::string KeyConfigScene; + /// The key that stores the location of the tasks file that is initially loaded + static const std::string KeyConfigTask; /// The key that stores the subdirectory containing a list of all startup scripts to /// be executed on application start before the scene file is loaded static const std::string KeyStartupScript; @@ -142,29 +143,19 @@ public: * that are specified in the configuration file will automatically be registered in * the ghoul::filesystem::FileSystem. * \param filename The filename to be loaded - * \throw ghoul::FileNotFoundException If the \p filename did not exist - * \throw ghoul::RuntimeError If the configuration file was not complete (i.e., did + * \throw SpecificationError If the configuration file was not complete (i.e., did * not specify the necessary keys KeyPaths, KeyPaths.KeyCache, KeyFonts, and * KeyConfigSgct) * \throw ghoul::lua::LuaRuntimeException If there was Lua-based error loading the * configuration file * \pre \p filename must not be empty + * \pre \p filename must exist */ void loadFromFile(const std::string& filename); - static openspace::Documentation Documentation(); - -private: - /** - * Checks whether the loaded configuration file is complete, that is specifying the - * necessary keys KeyPaths, KeyPaths.KeyCache, KeyFonts, and KeyConfigSgct. The method - * will log fatal errors if a key is missing. - * \return true if the configuration file was complete; - * false otherwise - */ - bool checkCompleteness() const; + static documentation::Documentation Documentation(); }; } // namespace openspace -#endif // __OPENSPACE_CORE___CONFIGURATIONMANAGER___H__ +#endif // __OPENSPACE_CORE___CONFIGURATIONMANAGER___H__ diff --git a/include/openspace/engine/downloadmanager.h b/include/openspace/engine/downloadmanager.h index 900c99eebc..366ff8ea58 100644 --- a/include/openspace/engine/downloadmanager.h +++ b/include/openspace/engine/downloadmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/engine/logfactory.h b/include/openspace/engine/logfactory.h index a2fb2b3c21..026208f33d 100644 --- a/include/openspace/engine/logfactory.h +++ b/include/openspace/engine/logfactory.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,12 +28,16 @@ #include namespace ghoul { + class Dictionary; namespace logging { class Log; } -} + +} // namespace ghoul namespace openspace { +namespace documentation { struct Documentation; } + /** * This function provides the capabilities to create a new ghoul::logging::Log from the * provided ghoul::Dictionary%. The Dictionary must at least contain a Type @@ -44,15 +48,24 @@ namespace openspace { * created . Both logs can be customized using the Append, * TimeStamping, DateStamping, CategoryStamping, * and LogLevelStamping values. - * \param dictionary The dictionary from which the ghoul::logging::Log should be created + * + * \param dictionary The dictionary from which the ghoul::logging::Log should be created * \return The created ghoul::logging::Log - * \post The return value will not be nullptr - * \throw ghoul::RuntimeError If there was an error creating the ghoul::logging::Log - * \sa ghoul::logging::TextLeg - * \sa ghoul::logging::HTMLLog + * \post The return value will not be nullptr + * \throw ghoul::RuntimeError If there was an error creating the ghoul::logging::Log + * \sa ghoul::logging::TextLog + * \sa ghoul::logging::HTMLLog */ std::unique_ptr createLog(const ghoul::Dictionary& dictionary); +/** + * Returns the Documentation that describes a Dictionary used to create a log by using the + * function createLog. + * \return The Documentation that describes an acceptable Dictionary for the method + * createLog + */ +documentation::Documentation LogFactoryDocumentation(); + } // namespace openspace #endif // __OPENSPACE_CORE___LOGFACTORY___H__ diff --git a/include/openspace/engine/moduleengine.h b/include/openspace/engine/moduleengine.h index df40f23983..ab3a118ecc 100644 --- a/include/openspace/engine/moduleengine.h +++ b/include/openspace/engine/moduleengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,14 +25,23 @@ #ifndef __OPENSPACE_CORE___MODULEENGINE___H__ #define __OPENSPACE_CORE___MODULEENGINE___H__ -#include -#include - #include #include +#include + +namespace ghoul { +namespace systemcapabilities { + +struct Version; + +} // namespace systemcapabilities +} // namespace ghoul + namespace openspace { +namespace scripting { struct LuaLibrary; } + /** * The ModuleEngine is the central repository for registering and accessing * OpenSpaceModule for the current application run. By initializing (#initialize) the @@ -80,8 +89,7 @@ public: * version of all registered modules' OpenGL versions. * \return The combined minimum OpenGL version */ - ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version - requiredOpenGLVersion() const; + ghoul::systemcapabilities::Version requiredOpenGLVersion() const; /** * Returns the Lua library that contains all Lua functions available to affect the diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index e9311c053a..552b2e895b 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -30,81 +30,65 @@ #include +#include #include #include #include namespace ghoul { + class Dictionary; + namespace cmdparser { class CommandlineParser; } namespace fontrendering { class FontManager; } -} + +} // namespace ghoul namespace openspace { class ConfigurationManager; class DownloadManager; -class LuaConsole; -class NetworkEngine; class GUI; -class RenderEngine; +class LuaConsole; class ModuleEngine; -class WindowWrapper; -class SettingsEngine; -class TimeManager; -class SceneManager; -class SyncEngine; +class NetworkEngine; class ParallelConnection; +class RenderEngine; +class SettingsEngine; +class SceneManager; + +class SyncEngine; +class TimeManager; +class WindowWrapper; namespace interaction { class InteractionHandler; } namespace gui { class GUI; } -//namespace scripting { class ScriptEngine; } namespace properties { class PropertyOwner; } -namespace scripting { struct LuaLibrary; } -namespace scripting { class ScriptScheduler; } -namespace scripting { class ScriptEngine; } - +namespace scripting { + struct LuaLibrary; + class ScriptEngine; + class ScriptScheduler; +} // namespace scripting + class OpenSpaceEngine { public: - static bool create(int argc, char** argv, + static void create(int argc, char** argv, std::unique_ptr windowWrapper, - std::vector& sgctArguments); + std::vector& sgctArguments, bool& requestClose); static void destroy(); - static bool isInitialized(); static OpenSpaceEngine& ref(); - bool isMaster(); - void setMaster(bool master); double runTime(); void setRunTime(double t); void loadScene(const std::string& scenePath); - // Guaranteed to return a valid pointer - ConfigurationManager& configurationManager(); - interaction::InteractionHandler& interactionHandler(); - RenderEngine& renderEngine(); - scripting::ScriptEngine& scriptEngine(); - scripting::ScriptScheduler& scriptScheduler(); - NetworkEngine& networkEngine(); - LuaConsole& console(); - ModuleEngine& moduleEngine(); - ParallelConnection& parallelConnection(); - properties::PropertyOwner& globalPropertyOwner(); - WindowWrapper& windowWrapper(); - ghoul::fontrendering::FontManager& fontManager(); - DownloadManager& downloadManager(); - TimeManager& timeManager(); - -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - gui::GUI& gui(); -#endif - - // SGCT callbacks - bool initialize(); - bool initializeGL(); + // callbacks + void initialize(); + void initializeGL(); + void deinitialize(); void preSynchronization(); void postSynchronizationPreDraw(); - void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix); + void render(const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix); void postDraw(); void keyboardCallback(Key key, KeyModifier mod, KeyAction action); void charCallback(unsigned int codepoint, KeyModifier mod); @@ -118,29 +102,77 @@ public: void enableBarrier(); void disableBarrier(); - + void writeDocumentation(); void toggleShutdownMode(); - bool useBusyWaitForDecode(); - bool logSGCTOutOfOrderErrors(); - void runPostInitializationScripts(const std::string& sceneDescription); + // Guaranteed to return a valid pointer + ConfigurationManager& configurationManager(); + LuaConsole& console(); + DownloadManager& downloadManager(); + ModuleEngine& moduleEngine(); + NetworkEngine& networkEngine(); + ParallelConnection& parallelConnection(); + RenderEngine& renderEngine(); + SettingsEngine& settingsEngine(); + TimeManager& timeManager(); + WindowWrapper& windowWrapper(); + ghoul::fontrendering::FontManager& fontManager(); + interaction::InteractionHandler& interactionHandler(); + properties::PropertyOwner& globalPropertyOwner(); + scripting::ScriptEngine& scriptEngine(); + scripting::ScriptScheduler& scriptScheduler(); + + + // This method is only to be called from Modules + enum class CallbackOption { + Initialize = 0, // Callback for the end of the initialization + Deinitialize, // Callback for the end of the deinitialization + InitializeGL, // Callback for the end of the OpenGL initialization + DeinitializeGL, // Callback for the end of the OpenGL deinitialization + PreSync, // Callback for the end of the pre-sync function + PostSyncPreDraw, // Callback for the end of the post-sync-pre-draw function + Render, // Callback for the end of the render function + PostDraw // Callback for the end of the post-draw function + }; + + // Registers a callback for a specific CallbackOption + void registerModuleCallback(CallbackOption option, std::function function); + + // Registers a callback that is called when a new keyboard event is received + void registerModuleKeyboardCallback( + std::function function); + + // Registers a callback that is called when a new character event is received + void registerModuleCharCallback( + std::function function); + + // Registers a callback that is called when a new mouse button is received + void registerModuleMouseButtonCallback( + std::function function); + + // Registers a callback that is called when a new mouse movement is received + void registerModuleMousePositionCallback( + std::function function); + + // Registers a callback that is called when a scroll wheel change is received + void registerModuleMouseScrollWheelCallback(std::function function); + /** - * Returns the Lua library that contains all Lua functions available to affect the - * application. - */ + * Returns the Lua library that contains all Lua functions available to affect the + * application. + */ static scripting::LuaLibrary luaLibrary(); private: - OpenSpaceEngine(std::string programName, std::unique_ptr windowWrapper); - ~OpenSpaceEngine(); + OpenSpaceEngine(std::string programName, + std::unique_ptr windowWrapper); + ~OpenSpaceEngine() = default; - void clearAllWindows(); void gatherCommandlineArguments(); void loadFonts(); - void runScripts(const ghoul::Dictionary& scripts); void runPreInitializationScripts(const std::string& sceneDescription); void configureLogging(); @@ -154,15 +186,12 @@ private: std::unique_ptr _networkEngine; std::unique_ptr _syncEngine; std::unique_ptr _commandlineParser; + std::unique_ptr _downloadManager; std::unique_ptr _console; std::unique_ptr _moduleEngine; + std::unique_ptr _parallelConnection; std::unique_ptr _settingsEngine; std::unique_ptr _timeManager; - std::unique_ptr _downloadManager; -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - std::unique_ptr _gui; -#endif - std::unique_ptr _parallelConnection; std::unique_ptr _windowWrapper; std::unique_ptr _fontManager; @@ -173,18 +202,43 @@ private: std::string _scenePath; bool _isMaster; + + struct { + std::vector> initialize; + std::vector> deinitialize; + + std::vector> initializeGL; + std::vector> deinitializeGL; + + std::vector> preSync; + std::vector> postSyncPreDraw; + std::vector> render; + std::vector> postDraw; + + std::vector> keyboard; + std::vector> character; + + std::vector> mouseButton; + std::vector> mousePosition; + std::vector> mouseScrollWheel; + } _moduleCallbacks; + double _runTime; - // Whether the application is currently in shutdown mode (i.e. counting down the timer - // and closing it at '0' - bool _isInShutdownMode; - // The total amount of time the application will wait before actually shutting down - float _shutdownWait; - // The current state of the countdown; if it reaches '0', the application will close - float _shutdownCountdown; + // Structure that is responsible for the delayed shutdown of the application + struct { + // Whether the application is currently in shutdown mode (i.e. counting down the + // timer and closing it at '0' + bool inShutdown; + // Total amount of time the application will wait before actually shutting down + float waitTime; + // Current state of the countdown; if it reaches '0', the application will + // close + float timer; + } _shutdown; // The first frame might take some more time in the update loop, so we need to know to - // disable the synchronization; otherwise a hardware sync will kill us after 1 sec + // disable the synchronization; otherwise a hardware sync will kill us after 1 minute bool _isFirstRenderingFirstFrame; static OpenSpaceEngine* _engine; @@ -194,4 +248,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_CORE___OPENSPACEENGINE___H__ +#endif // __OPENSPACE_CORE___OPENSPACEENGINE___H__ diff --git a/include/openspace/engine/settingsengine.h b/include/openspace/engine/settingsengine.h index e42ab81f23..e040192928 100644 --- a/include/openspace/engine/settingsengine.h +++ b/include/openspace/engine/settingsengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -43,28 +43,18 @@ public: void initialize(); - void setModules(std::vector modules); + void setModules(const std::vector& modules); bool busyWaitForDecode(); bool logSGCTOutOfOrderErrors(); bool useDoubleBuffering(); private: - void initEyeSeparation(); - void initSceneFiles(); - void initShowFrameNumber(); - void initBusyWaitForDecode(); - void initLogSGCTOutOfOrderErrors(); - void initUseDoubleBuffering(); - - properties::FloatProperty _eyeSeparation; properties::OptionProperty _scenes; - properties::BoolProperty _showFrameNumber; properties::BoolProperty _busyWaitForDecode; properties::BoolProperty _logSGCTOutOfOrderErrors; properties::BoolProperty _useDoubleBuffering; properties::BoolProperty _spiceUseExceptions; - }; } // namespace openspace diff --git a/include/openspace/engine/syncengine.h b/include/openspace/engine/syncengine.h index a099a24d22..8d2c92711e 100644 --- a/include/openspace/engine/syncengine.h +++ b/include/openspace/engine/syncengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,64 +25,68 @@ #ifndef __OPENSPACE_CORE___SYNCENGINE___H__ #define __OPENSPACE_CORE___SYNCENGINE___H__ +#include + +#include + #include #include namespace openspace { class Syncable; -class SyncBuffer; /** -* Manages a collection of Syncables and ensures they are synchronized -* over SGCT nodes. Encoding/Decoding order is handles internally. -*/ + * Manages a collection of Syncables and ensures they are synchronized + * over SGCT nodes. Encoding/Decoding order is handles internally. + */ class SyncEngine { public: + using IsMaster = ghoul::Boolean; /** - * Dependency injection: a SyncEngine relies on a SyncBuffer to encode the sync data. - */ - SyncEngine(SyncBuffer* syncBuffer); - + * Creates a new SyncEngine which a buffer size of \p syncBufferSize + * \pre syncBufferSize must be bigger than 0 + */ + SyncEngine(unsigned int syncBufferSize); /** - * Encodes all added Syncables in the injected SyncBuffer. - * This method is only called on the SGCT master node - */ + * Encodes all added Syncables in the injected SyncBuffer. + * This method is only called on the SGCT master node + */ void encodeSyncables(); /** - * Decodes the SyncBuffer into the added Syncables. - * This method is only called on the SGCT slave nodes - */ + * Decodes the SyncBuffer into the added Syncables. + * This method is only called on the SGCT slave nodes + */ void decodeSyncables(); /** - * Invokes the presync method of all added Syncables - */ - void presync(bool isMaster); + * Invokes the presync method of all added Syncables + */ + void preSynchronization(IsMaster isMaster); /** - * Invokes the postsync method of all added Syncables - */ - void postsync(bool isMaster); + * Invokes the postsync method of all added Syncables + */ + void postSynchronization(IsMaster isMaster); - - /** - * Add a Syncable to be synchronized over the SGCT cluster - */ + * Add a Syncable to be synchronized over the SGCT cluster. + * \pre syncable must not be nullptr + */ void addSyncable(Syncable* syncable); /** - * Add multiple Syncables to be synchronized over the SGCT cluster - */ + * Add multiple Syncables to be synchronized over the SGCT cluster + * \pre syncables must not contain any nullptr + */ void addSyncables(const std::vector& syncables); /** - * Remove a Syncable from being synchronized over the SGCT cluster - */ + * Remove a Syncable from being synchronized over the SGCT cluster + */ void removeSyncable(Syncable* syncable); /** @@ -91,19 +95,17 @@ public: void removeSyncables(const std::vector& syncables); private: - /** - * Vector of Syncables. The vectors ensures consistent encode/decode order - */ + * Vector of Syncables. The vectors ensures consistent encode/decode order + */ std::vector _syncables; /** - * Databuffer used in encoding/decoding - */ - std::unique_ptr _syncBuffer; + * Databuffer used in encoding/decoding + */ + SyncBuffer _syncBuffer; }; - } // namespace openspace #endif // __OPENSPACE_CORE___SYNCENGINE___H__ diff --git a/include/openspace/engine/wrapper/sgctwindowwrapper.h b/include/openspace/engine/wrapper/sgctwindowwrapper.h index 377bda3f42..7dc3db262b 100644 --- a/include/openspace/engine/wrapper/sgctwindowwrapper.h +++ b/include/openspace/engine/wrapper/sgctwindowwrapper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,6 +27,9 @@ #include +#include +#include + namespace openspace { /** @@ -36,6 +39,8 @@ namespace openspace { */ class SGCTWindowWrapper : public WindowWrapper { public: + SGCTWindowWrapper(); + void terminate() override; void setBarrier(bool enabled) override; void setSynchronization(bool enabled) override; @@ -55,6 +60,7 @@ public: bool isRegularRendering() const override; bool hasGuiWindow() const override; bool isGuiWindow() const override; + bool isMaster() const override; bool isUsingSwapGroups() const override; bool isSwapGroupMaster() const override; @@ -71,6 +77,10 @@ public: bool isSimpleRendering() const override; void takeScreenshot(bool applyWarping = false) const override; + +private: + properties::FloatProperty _eyeSeparation; + properties::BoolProperty _showStatsGraph; }; } // namespace openspace diff --git a/include/openspace/engine/wrapper/windowwrapper.h b/include/openspace/engine/wrapper/windowwrapper.h index 89c92121f9..252eb4258a 100644 --- a/include/openspace/engine/wrapper/windowwrapper.h +++ b/include/openspace/engine/wrapper/windowwrapper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,6 +25,8 @@ #ifndef __OPENSPACE_CORE___WINDOWWRAPPER___H__ #define __OPENSPACE_CORE___WINDOWWRAPPER___H__ +#include + #include #include @@ -42,8 +44,11 @@ namespace scripting { struct LuaLibrary; } * Every new windowing framework needs to have its own WindowWrapper subclass exposing the * required features. */ -class WindowWrapper { +class WindowWrapper : public properties::PropertyOwner { public: + /// Default constructor + WindowWrapper(); + /** * Returns the Lua library that contains all Lua functions available to affect the * windowing system. @@ -175,6 +180,13 @@ public: * \return Whether the current rendering window is GUI-only */ virtual bool isGuiWindow() const; + + /** + * Returns true if this application is the master for a clustered + * environment. + * \return Whether this applicaiton is the master for a clustered environment. + */ + virtual bool isMaster() const; /** * Returns true if the current rendering window is using swap groups. diff --git a/include/openspace/interaction/controller.h b/include/openspace/interaction/controller.h index 5daf93cd01..4e262a0287 100644 --- a/include/openspace/interaction/controller.h +++ b/include/openspace/interaction/controller.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h index 50845e73ed..34c398186c 100644 --- a/include/openspace/interaction/interactionhandler.h +++ b/include/openspace/interaction/interactionhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___INTERACTIONHANDLER___H__ #define __OPENSPACE_CORE___INTERACTIONHANDLER___H__ -#include #include #include #include diff --git a/include/openspace/interaction/interactionmode.h b/include/openspace/interaction/interactionmode.h index a3a479453f..6a0b383403 100644 --- a/include/openspace/interaction/interactionmode.h +++ b/include/openspace/interaction/interactionmode.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___INTERACTIONMODE___H__ #define __OPENSPACE_CORE___INTERACTIONMODE___H__ -#include #include #include #include @@ -33,6 +32,7 @@ #ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED #include #include +#include #endif #include diff --git a/include/openspace/interaction/luaconsole.h b/include/openspace/interaction/luaconsole.h index cf863107b3..119134e7e3 100644 --- a/include/openspace/interaction/luaconsole.h +++ b/include/openspace/interaction/luaconsole.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,9 +25,10 @@ #ifndef __OPENSPACE_CORE___LUACONSOLE___H__ #define __OPENSPACE_CORE___LUACONSOLE___H__ -#include #include - +#include +#include +#include #include #include @@ -35,50 +36,35 @@ namespace openspace { -class LuaConsole { +class LuaConsole : public properties::PropertyOwner { public: LuaConsole(); void initialize(); void deinitialize(); - void keyboardCallback(Key key, KeyModifier modifier, KeyAction action); + bool keyboardCallback(Key key, KeyModifier modifier, KeyAction action); void charCallback(unsigned int codepoint, KeyModifier modifier); void render(); - Key commandInputButton(); - - bool isVisible() const; - void setVisible(bool visible); - bool isRemoteScripting() const; - void setRemoteScripting(bool remoteScripting); - - void toggleMode(); - - static scripting::LuaLibrary luaLibrary(); - - private: void parallelConnectionChanged(const ParallelConnection::Status& status); void addToCommand(std::string c); - std::string UnicodeToUTF8(unsigned int codepoint); + + properties::BoolProperty _isVisible; + bool _remoteScripting; size_t _inputPosition; std::vector _commandsHistory; size_t _activeCommand; std::vector _commands; - std::string _filename; - struct { int lastIndex; bool hasInitialValue; std::string initialValue; } _autoCompleteInfo; - - bool _isVisible; - bool _remoteScripting; }; } // namespace openspace diff --git a/include/openspace/mission/mission.h b/include/openspace/mission/mission.h index 5783461813..914afb040c 100644 --- a/include/openspace/mission/mission.h +++ b/include/openspace/mission/mission.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___MISSION___H__ #define __OPENSPACE_CORE___MISSION___H__ -#include #include #include @@ -35,6 +34,7 @@ namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; } /** * Used to represent a named period of time within a mission. Allows nested phases, i.e. @@ -101,7 +101,7 @@ public: * MissionPhase can be constructed from. * \return The Documentation that describes the required structure for a Dictionary */ - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: /** diff --git a/include/openspace/mission/missionmanager.h b/include/openspace/mission/missionmanager.h index 56fee42f45..2d31f89ba4 100644 --- a/include/openspace/mission/missionmanager.h +++ b/include/openspace/mission/missionmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/network/messagestructures.h b/include/openspace/network/messagestructures.h index 8b06233f2c..5f85c57bcb 100644 --- a/include/openspace/network/messagestructures.h +++ b/include/openspace/network/messagestructures.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/network/networkengine.h b/include/openspace/network/networkengine.h index e3f92e3264..8d0008b406 100644 --- a/include/openspace/network/networkengine.h +++ b/include/openspace/network/networkengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -23,7 +23,7 @@ ****************************************************************************************/ #ifndef __OPENSPACE_CORE___NETWORKENGINE___H__ -#define PARALLELCONNECTION__OPENSPACE_CORE___NETWORKENGINE___H__ +#define __OPENSPACE_CORE___NETWORKENGINE___H__ #include #include diff --git a/include/openspace/network/parallelconnection.h b/include/openspace/network/parallelconnection.h index 2822b1e398..d95060d7c0 100644 --- a/include/openspace/network/parallelconnection.h +++ b/include/openspace/network/parallelconnection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/openspace.h b/include/openspace/openspace.h index 5359b5f360..199359475a 100644 --- a/include/openspace/openspace.h +++ b/include/openspace/openspace.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,10 +32,10 @@ namespace openspace { std::string licenseText(); const int OPENSPACE_VERSION_MAJOR = 0; -const int OPENSPACE_VERSION_MINOR = 6; +const int OPENSPACE_VERSION_MINOR = 7; const int OPENSPACE_VERSION_PATCH = 0; -const std::string OPENSPACE_VERSION_STRING = "prerelease-11 (AGU)"; +const std::string OPENSPACE_VERSION_STRING = "prerelease-12 (NAOJ)"; } // namespace openspace diff --git a/include/openspace/performance/performancelayout.h b/include/openspace/performance/performancelayout.h index 29feabaca5..de9f5a450f 100644 --- a/include/openspace/performance/performancelayout.h +++ b/include/openspace/performance/performancelayout.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/performance/performancemanager.h b/include/openspace/performance/performancemanager.h index ebad4f61ff..55fca53f5b 100644 --- a/include/openspace/performance/performancemanager.h +++ b/include/openspace/performance/performancemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/performance/performancemeasurement.h b/include/openspace/performance/performancemeasurement.h index 3be224cf1e..c820f81230 100644 --- a/include/openspace/performance/performancemeasurement.h +++ b/include/openspace/performance/performancemeasurement.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/dmat2property.h b/include/openspace/properties/matrix/dmat2property.h index d50900234a..978090b4a3 100644 --- a/include/openspace/properties/matrix/dmat2property.h +++ b/include/openspace/properties/matrix/dmat2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/dmat2x3property.h b/include/openspace/properties/matrix/dmat2x3property.h index c6ec775b38..69603e57c4 100644 --- a/include/openspace/properties/matrix/dmat2x3property.h +++ b/include/openspace/properties/matrix/dmat2x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DMAT2x3PROPERTY___H__ -#define __OPENSPACE_CORE___DMAT2x3PROPERTY___H__ +#ifndef __OPENSPACE_CORE___DMAT2X3PROPERTY___H__ +#define __OPENSPACE_CORE___DMAT2X3PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(DMat2x3Property, glm::dmat2x3); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___DMAT2x3PROPERTY___H__ +#endif // __OPENSPACE_CORE___DMAT2X3PROPERTY___H__ diff --git a/include/openspace/properties/matrix/dmat2x4property.h b/include/openspace/properties/matrix/dmat2x4property.h index 060569bdb9..3300ec67d7 100644 --- a/include/openspace/properties/matrix/dmat2x4property.h +++ b/include/openspace/properties/matrix/dmat2x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DMAT2x4PROPERTY___H__ -#define __OPENSPACE_CORE___DMAT2x4PROPERTY___H__ +#ifndef __OPENSPACE_CORE___DMAT2X4PROPERTY___H__ +#define __OPENSPACE_CORE___DMAT2X4PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(DMat2x4Property, glm::dmat2x4); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___DMAT2x4PROPERTY___H__ +#endif // __OPENSPACE_CORE___DMAT2X4PROPERTY___H__ diff --git a/include/openspace/properties/matrix/dmat3property.h b/include/openspace/properties/matrix/dmat3property.h index c94c94694b..4052005316 100644 --- a/include/openspace/properties/matrix/dmat3property.h +++ b/include/openspace/properties/matrix/dmat3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/dmat3x2property.h b/include/openspace/properties/matrix/dmat3x2property.h index e94c0f7f13..15a01d557a 100644 --- a/include/openspace/properties/matrix/dmat3x2property.h +++ b/include/openspace/properties/matrix/dmat3x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DMAT3x2PROPERTY___H__ -#define __OPENSPACE_CORE___DMAT3x2PROPERTY___H__ +#ifndef __OPENSPACE_CORE___DMAT3X2PROPERTY___H__ +#define __OPENSPACE_CORE___DMAT3X2PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(DMat3x2Property, glm::dmat3x2); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___DMAT3x2PROPERTY___H__ +#endif // __OPENSPACE_CORE___DMAT3X2PROPERTY___H__ diff --git a/include/openspace/properties/matrix/dmat3x4property.h b/include/openspace/properties/matrix/dmat3x4property.h index 7d6c190766..ba460f5714 100644 --- a/include/openspace/properties/matrix/dmat3x4property.h +++ b/include/openspace/properties/matrix/dmat3x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DMAT3x4PROPERTY___H__ -#define __OPENSPACE_CORE___DMAT3x4PROPERTY___H__ +#ifndef __OPENSPACE_CORE___DMAT3X4PROPERTY___H__ +#define __OPENSPACE_CORE___DMAT3X4PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(DMat3x4Property, glm::dmat3x4); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___DMAT3x4PROPERTY___H__ +#endif // __OPENSPACE_CORE___DMAT3X4PROPERTY___H__ diff --git a/include/openspace/properties/matrix/dmat4property.h b/include/openspace/properties/matrix/dmat4property.h index 927587f1eb..3124aa57d8 100644 --- a/include/openspace/properties/matrix/dmat4property.h +++ b/include/openspace/properties/matrix/dmat4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/dmat4x2property.h b/include/openspace/properties/matrix/dmat4x2property.h index 3ab7f82af6..1d0e1bfc94 100644 --- a/include/openspace/properties/matrix/dmat4x2property.h +++ b/include/openspace/properties/matrix/dmat4x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DMAT4x2PROPERTY___H__ -#define __OPENSPACE_CORE___DMAT4x2PROPERTY___H__ +#ifndef __OPENSPACE_CORE___DMAT4X2PROPERTY___H__ +#define __OPENSPACE_CORE___DMAT4X2PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(DMat4x2Property, glm::dmat4x2); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___DMAT4x2PROPERTY___H__ +#endif // __OPENSPACE_CORE___DMAT4X2PROPERTY___H__ diff --git a/include/openspace/properties/matrix/dmat4x3property.h b/include/openspace/properties/matrix/dmat4x3property.h index 013fe01794..0843a3c944 100644 --- a/include/openspace/properties/matrix/dmat4x3property.h +++ b/include/openspace/properties/matrix/dmat4x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DMAT4x3PROPERTY___H__ -#define __OPENSPACE_CORE___DMAT4x3PROPERTY___H__ +#ifndef __OPENSPACE_CORE___DMAT4X3PROPERTY___H__ +#define __OPENSPACE_CORE___DMAT4X3PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(DMat4x3Property, glm::dmat4x3); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___DMAT4x3PROPERTY___H__ +#endif // __OPENSPACE_CORE___DMAT4X3PROPERTY___H__ diff --git a/include/openspace/properties/matrix/mat2property.h b/include/openspace/properties/matrix/mat2property.h index f8deb63b3d..8b48a60c3a 100644 --- a/include/openspace/properties/matrix/mat2property.h +++ b/include/openspace/properties/matrix/mat2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/mat2x3property.h b/include/openspace/properties/matrix/mat2x3property.h index 822a11d5b5..406834f057 100644 --- a/include/openspace/properties/matrix/mat2x3property.h +++ b/include/openspace/properties/matrix/mat2x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___MAT2x3PROPERTY___H__ -#define __OPENSPACE_CORE___MAT2x3PROPERTY___H__ +#ifndef __OPENSPACE_CORE___MAT2X3PROPERTY___H__ +#define __OPENSPACE_CORE___MAT2X3PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(Mat2x3Property, glm::mat2x3); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___MAT2x3PROPERTY___H__ +#endif // __OPENSPACE_CORE___MAT2X3PROPERTY___H__ diff --git a/include/openspace/properties/matrix/mat2x4property.h b/include/openspace/properties/matrix/mat2x4property.h index 19230ac699..a678da4051 100644 --- a/include/openspace/properties/matrix/mat2x4property.h +++ b/include/openspace/properties/matrix/mat2x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___MAT2x4PROPERTY___H__ -#define __OPENSPACE_CORE___MAT2x4PROPERTY___H__ +#ifndef __OPENSPACE_CORE___MAT2X4PROPERTY___H__ +#define __OPENSPACE_CORE___MAT2X4PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(Mat2x4Property, glm::mat2x4); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___MAT2x4PROPERTY___H__ +#endif // __OPENSPACE_CORE___MAT2X4PROPERTY___H__ diff --git a/include/openspace/properties/matrix/mat3property.h b/include/openspace/properties/matrix/mat3property.h index b9451c2d55..8c428fce4f 100644 --- a/include/openspace/properties/matrix/mat3property.h +++ b/include/openspace/properties/matrix/mat3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/mat3x2property.h b/include/openspace/properties/matrix/mat3x2property.h index a8caac4361..bfc5e2ef58 100644 --- a/include/openspace/properties/matrix/mat3x2property.h +++ b/include/openspace/properties/matrix/mat3x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___MAT3x2PROPERTY___H__ -#define __OPENSPACE_CORE___MAT3x2PROPERTY___H__ +#ifndef __OPENSPACE_CORE___MAT3X2PROPERTY___H__ +#define __OPENSPACE_CORE___MAT3X2PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(Mat3x2Property, glm::mat3x2); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___MAT3x2PROPERTY___H__ +#endif // __OPENSPACE_CORE___MAT3X2PROPERTY___H__ diff --git a/include/openspace/properties/matrix/mat3x4property.h b/include/openspace/properties/matrix/mat3x4property.h index bf65b1857a..8f87c3ca52 100644 --- a/include/openspace/properties/matrix/mat3x4property.h +++ b/include/openspace/properties/matrix/mat3x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___MAT3x4PROPERTY___H__ -#define __OPENSPACE_CORE___MAT3x4PROPERTY___H__ +#ifndef __OPENSPACE_CORE___MAT3X4PROPERTY___H__ +#define __OPENSPACE_CORE___MAT3X4PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(Mat3x4Property, glm::mat3x4); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___MAT3x4PROPERTY___H__ +#endif // __OPENSPACE_CORE___MAT3X4PROPERTY___H__ diff --git a/include/openspace/properties/matrix/mat4property.h b/include/openspace/properties/matrix/mat4property.h index edbab9cda2..da2175ec20 100644 --- a/include/openspace/properties/matrix/mat4property.h +++ b/include/openspace/properties/matrix/mat4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/matrix/mat4x2property.h b/include/openspace/properties/matrix/mat4x2property.h index 19ae107a6c..e57ecdaaee 100644 --- a/include/openspace/properties/matrix/mat4x2property.h +++ b/include/openspace/properties/matrix/mat4x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___MAT4x2PROPERTY___H__ -#define __OPENSPACE_CORE___MAT4x2PROPERTY___H__ +#ifndef __OPENSPACE_CORE___MAT4X2PROPERTY___H__ +#define __OPENSPACE_CORE___MAT4X2PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(Mat4x2Property, glm::mat4x2); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___MAT4x2PROPERTY___H__ +#endif // __OPENSPACE_CORE___MAT4X2PROPERTY___H__ diff --git a/include/openspace/properties/matrix/mat4x3property.h b/include/openspace/properties/matrix/mat4x3property.h index 17621ab924..cd8931479b 100644 --- a/include/openspace/properties/matrix/mat4x3property.h +++ b/include/openspace/properties/matrix/mat4x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___MAT4x3PROPERTY___H__ -#define __OPENSPACE_CORE___MAT4x3PROPERTY___H__ +#ifndef __OPENSPACE_CORE___MAT4X3PROPERTY___H__ +#define __OPENSPACE_CORE___MAT4X3PROPERTY___H__ #include @@ -37,4 +37,4 @@ REGISTER_NUMERICALPROPERTY_HEADER(Mat4x3Property, glm::mat4x3); } // namespace properties } // namespace openspace -#endif // __OPENSPACE_CORE___MAT4x3PROPERTY___H__ +#endif // __OPENSPACE_CORE___MAT4X3PROPERTY___H__ diff --git a/include/openspace/properties/matrixproperty.h b/include/openspace/properties/matrixproperty.h index 2b26259c11..f45db10f9a 100644 --- a/include/openspace/properties/matrixproperty.h +++ b/include/openspace/properties/matrixproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index 2a5a5a3c7a..77ee822063 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index 89a47f9b66..e7d46cf07e 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 4263120deb..60d2fdc12f 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/property.h b/include/openspace/properties/property.h index 0baa569612..4f40070f44 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -314,10 +314,10 @@ public: * Property::ViewOptions::PowerScaledCoordinate = powerScaledCoordinate. */ struct ViewOptions { - static const std::string Color; - static const std::string LightPosition; - static const std::string PowerScaledScalar; - static const std::string PowerScaledCoordinate; + static const char* Color; + static const char* LightPosition; + static const char* PowerScaledScalar; + static const char* PowerScaledCoordinate; }; /** @@ -329,10 +329,10 @@ public: const ghoul::Dictionary& metaData() const; protected: - static const std::string IdentifierKey; - static const std::string NameKey; - static const std::string TypeKey; - static const std::string MetaDataKey; + static const char* IdentifierKey; + static const char* NameKey; + static const char* TypeKey; + static const char* MetaDataKey; /** * Creates the information that is general to every Property and adds the diff --git a/include/openspace/properties/propertydelegate.h b/include/openspace/properties/propertydelegate.h index ff63e25fa7..9611d8f1f4 100644 --- a/include/openspace/properties/propertydelegate.h +++ b/include/openspace/properties/propertydelegate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/propertydelegate.inl b/include/openspace/properties/propertydelegate.inl index a4740d4707..36ac0ed6ea 100644 --- a/include/openspace/properties/propertydelegate.inl +++ b/include/openspace/properties/propertydelegate.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index 51b26dac96..e26af2db6f 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___PROPERTYOWNER___H__ #define __OPENSPACE_CORE___PROPERTYOWNER___H__ -#include #include #include #include @@ -33,6 +32,8 @@ namespace openspace { namespace properties { +class Property; + /** * A PropertyOwner can own Propertys or other PropertyOwner and provide access to both in * a unified way. The identifiers and names of Propertys and @@ -53,7 +54,7 @@ public: static const char URISeparator = '.'; /// The constructor initializing the PropertyOwner's name to "" - PropertyOwner(); + PropertyOwner(std::string name = ""); /** * The destructor will remove all Propertys and PropertyOwners it owns along with diff --git a/include/openspace/properties/scalar/boolproperty.h b/include/openspace/properties/scalar/boolproperty.h index e615368b1c..35ead669c1 100644 --- a/include/openspace/properties/scalar/boolproperty.h +++ b/include/openspace/properties/scalar/boolproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/charproperty.h b/include/openspace/properties/scalar/charproperty.h index 3357d47c7e..c8a2c9910e 100644 --- a/include/openspace/properties/scalar/charproperty.h +++ b/include/openspace/properties/scalar/charproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/doubleproperty.h b/include/openspace/properties/scalar/doubleproperty.h index f47abe8b85..27401c7422 100644 --- a/include/openspace/properties/scalar/doubleproperty.h +++ b/include/openspace/properties/scalar/doubleproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/floatproperty.h b/include/openspace/properties/scalar/floatproperty.h index 11acdebbb4..fc780787a4 100644 --- a/include/openspace/properties/scalar/floatproperty.h +++ b/include/openspace/properties/scalar/floatproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/intproperty.h b/include/openspace/properties/scalar/intproperty.h index 3aa9f82b62..4c55848994 100644 --- a/include/openspace/properties/scalar/intproperty.h +++ b/include/openspace/properties/scalar/intproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/longdoubleproperty.h b/include/openspace/properties/scalar/longdoubleproperty.h index 40358f602b..47db702438 100644 --- a/include/openspace/properties/scalar/longdoubleproperty.h +++ b/include/openspace/properties/scalar/longdoubleproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/longlongproperty.h b/include/openspace/properties/scalar/longlongproperty.h index 65e176e09d..b95de8c278 100644 --- a/include/openspace/properties/scalar/longlongproperty.h +++ b/include/openspace/properties/scalar/longlongproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/longproperty.h b/include/openspace/properties/scalar/longproperty.h index 444fc6c15a..5b09507df9 100644 --- a/include/openspace/properties/scalar/longproperty.h +++ b/include/openspace/properties/scalar/longproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/shortproperty.h b/include/openspace/properties/scalar/shortproperty.h index da37c72a60..7a2dd2c6a5 100644 --- a/include/openspace/properties/scalar/shortproperty.h +++ b/include/openspace/properties/scalar/shortproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/signedcharproperty.h b/include/openspace/properties/scalar/signedcharproperty.h index 2ff7ff0d03..d808e1bb4d 100644 --- a/include/openspace/properties/scalar/signedcharproperty.h +++ b/include/openspace/properties/scalar/signedcharproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/ucharproperty.h b/include/openspace/properties/scalar/ucharproperty.h index c91b5051b5..8460a72710 100644 --- a/include/openspace/properties/scalar/ucharproperty.h +++ b/include/openspace/properties/scalar/ucharproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/uintproperty.h b/include/openspace/properties/scalar/uintproperty.h index bf83adc31f..53c11668a0 100644 --- a/include/openspace/properties/scalar/uintproperty.h +++ b/include/openspace/properties/scalar/uintproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/ulonglongproperty.h b/include/openspace/properties/scalar/ulonglongproperty.h index 045da7a9b9..7e57f0c28a 100644 --- a/include/openspace/properties/scalar/ulonglongproperty.h +++ b/include/openspace/properties/scalar/ulonglongproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/ulongproperty.h b/include/openspace/properties/scalar/ulongproperty.h index 4350c0ae46..8be77cc026 100644 --- a/include/openspace/properties/scalar/ulongproperty.h +++ b/include/openspace/properties/scalar/ulongproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/ushortproperty.h b/include/openspace/properties/scalar/ushortproperty.h index 9c2d20320d..890ca2b881 100644 --- a/include/openspace/properties/scalar/ushortproperty.h +++ b/include/openspace/properties/scalar/ushortproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalar/wcharproperty.h b/include/openspace/properties/scalar/wcharproperty.h index d19a460884..07f10d03cb 100644 --- a/include/openspace/properties/scalar/wcharproperty.h +++ b/include/openspace/properties/scalar/wcharproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/scalarproperty.h b/include/openspace/properties/scalarproperty.h index 16c620c3e9..4b4fe36b5e 100644 --- a/include/openspace/properties/scalarproperty.h +++ b/include/openspace/properties/scalarproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index 39dc560508..672659ebdb 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/stringproperty.h b/include/openspace/properties/stringproperty.h index d6840cd016..43b7761722 100644 --- a/include/openspace/properties/stringproperty.h +++ b/include/openspace/properties/stringproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/templateproperty.h b/include/openspace/properties/templateproperty.h index a562b59020..feddc84167 100644 --- a/include/openspace/properties/templateproperty.h +++ b/include/openspace/properties/templateproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl index bacccfafe6..7e4c2b790e 100644 --- a/include/openspace/properties/templateproperty.inl +++ b/include/openspace/properties/templateproperty.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/triggerproperty.h b/include/openspace/properties/triggerproperty.h index c6bcf6c9e9..47afb82b25 100644 --- a/include/openspace/properties/triggerproperty.h +++ b/include/openspace/properties/triggerproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/bvec2property.h b/include/openspace/properties/vector/bvec2property.h index 79d94c97e8..5f5164ea2f 100644 --- a/include/openspace/properties/vector/bvec2property.h +++ b/include/openspace/properties/vector/bvec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/bvec3property.h b/include/openspace/properties/vector/bvec3property.h index 4dbfc678b0..f50fccbfb0 100644 --- a/include/openspace/properties/vector/bvec3property.h +++ b/include/openspace/properties/vector/bvec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/bvec4property.h b/include/openspace/properties/vector/bvec4property.h index 9912c72506..0bd80ad32f 100644 --- a/include/openspace/properties/vector/bvec4property.h +++ b/include/openspace/properties/vector/bvec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/dvec2property.h b/include/openspace/properties/vector/dvec2property.h index 2ad7df993f..84cd253505 100644 --- a/include/openspace/properties/vector/dvec2property.h +++ b/include/openspace/properties/vector/dvec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/dvec3property.h b/include/openspace/properties/vector/dvec3property.h index 57463d6c41..63a057d8fb 100644 --- a/include/openspace/properties/vector/dvec3property.h +++ b/include/openspace/properties/vector/dvec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/dvec4property.h b/include/openspace/properties/vector/dvec4property.h index eae10fe920..6fbd0b337d 100644 --- a/include/openspace/properties/vector/dvec4property.h +++ b/include/openspace/properties/vector/dvec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/ivec2property.h b/include/openspace/properties/vector/ivec2property.h index 3c70c7a915..e9c986dfc7 100644 --- a/include/openspace/properties/vector/ivec2property.h +++ b/include/openspace/properties/vector/ivec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/ivec3property.h b/include/openspace/properties/vector/ivec3property.h index f1a61401c9..d6242dd434 100644 --- a/include/openspace/properties/vector/ivec3property.h +++ b/include/openspace/properties/vector/ivec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/ivec4property.h b/include/openspace/properties/vector/ivec4property.h index c4baa75d08..8d234e7f5c 100644 --- a/include/openspace/properties/vector/ivec4property.h +++ b/include/openspace/properties/vector/ivec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/uvec2property.h b/include/openspace/properties/vector/uvec2property.h index 48a2629432..fd0cad517b 100644 --- a/include/openspace/properties/vector/uvec2property.h +++ b/include/openspace/properties/vector/uvec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/uvec3property.h b/include/openspace/properties/vector/uvec3property.h index defc195ec1..b46ed1e6d9 100644 --- a/include/openspace/properties/vector/uvec3property.h +++ b/include/openspace/properties/vector/uvec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/uvec4property.h b/include/openspace/properties/vector/uvec4property.h index e750f00e6a..367ffea1a5 100644 --- a/include/openspace/properties/vector/uvec4property.h +++ b/include/openspace/properties/vector/uvec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/vec2property.h b/include/openspace/properties/vector/vec2property.h index ad26b1e9c4..3476c013c7 100644 --- a/include/openspace/properties/vector/vec2property.h +++ b/include/openspace/properties/vector/vec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/vec3property.h b/include/openspace/properties/vector/vec3property.h index 0daceaad4a..5c43e59606 100644 --- a/include/openspace/properties/vector/vec3property.h +++ b/include/openspace/properties/vector/vec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vector/vec4property.h b/include/openspace/properties/vector/vec4property.h index ae019c0e22..85bf3a3e87 100644 --- a/include/openspace/properties/vector/vec4property.h +++ b/include/openspace/properties/vector/vec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/properties/vectorproperty.h b/include/openspace/properties/vectorproperty.h index d7792f1915..4fce75374c 100644 --- a/include/openspace/properties/vectorproperty.h +++ b/include/openspace/properties/vectorproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/query/query.h b/include/openspace/query/query.h index 8941b8823e..52fafb8d85 100644 --- a/include/openspace/query/query.h +++ b/include/openspace/query/query.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/rendering/abufferrenderer.h b/include/openspace/rendering/abufferrenderer.h index 4d3972d38e..2a3fc3a8fd 100644 --- a/include/openspace/rendering/abufferrenderer.h +++ b/include/openspace/rendering/abufferrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -43,14 +43,14 @@ namespace ghoul { - namespace filesystem { - class File; - } - namespace opengl { - class ProgramObject; - class Texture; - } -} +namespace filesystem { class File; } + +namespace opengl { + class ProgramObject; + class Texture; +} // namepsace opengl + +} // namespace ghoul namespace openspace { @@ -71,8 +71,8 @@ public: void setResolution(glm::ivec2 res) override; void setNAaSamples(int nAaSamples) override; - void preRaycast(ghoul::opengl::ProgramObject& programObject); - void postRaycast(ghoul::opengl::ProgramObject& programObject); + void preRaycast(const RaycasterTask& raycasterTask); + void postRaycast(const RaycasterTask& raycasterTask); void update(); void render(float blackoutFactor, bool doPerformanceMeasurements) override; @@ -130,9 +130,6 @@ private: GLuint _vertexPositionBuffer; int _nAaSamples; - - std::unique_ptr _rendererTasks; - std::unique_ptr _renderData; float _blackoutFactor; ghoul::Dictionary _rendererData; @@ -140,4 +137,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_CORE___ABUFFERRENDERER___H__ +#endif // __OPENSPACE_CORE___ABUFFERRENDERER___H__ diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index 9ec20629d2..2bc0ec760e 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/rendering/raycasterlistener.h b/include/openspace/rendering/raycasterlistener.h index 9c5b2df027..3efa452113 100644 --- a/include/openspace/rendering/raycasterlistener.h +++ b/include/openspace/rendering/raycasterlistener.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -36,4 +36,4 @@ public: } // openspace -#endif // __OPENSPACE_CORE___RAYCASTERLISTENER___H__ +#endif // __OPENSPACE_CORE___RAYCASTERLISTENER___H__ diff --git a/include/openspace/rendering/raycastermanager.h b/include/openspace/rendering/raycastermanager.h index 8108ab756a..64792e48e1 100644 --- a/include/openspace/rendering/raycastermanager.h +++ b/include/openspace/rendering/raycastermanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -50,4 +50,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_CORE___RAYCASTERMANAGER___H__ +#endif // __OPENSPACE_CORE___RAYCASTERMANAGER___H__ diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index fc3b9c61d9..c4b1e731c2 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,9 +33,6 @@ #include -#include - - // Forward declare to minimize dependencies namespace ghoul { namespace opengl { @@ -46,6 +43,8 @@ namespace ghoul { namespace openspace { +namespace documentation { struct Documentation; } + // Forward declare to minimize dependencies class Camera; @@ -60,7 +59,7 @@ public: Overlay = 8 }; - static Renderable* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary(const ghoul::Dictionary& dictionary); // constructors & destructor Renderable(); @@ -93,7 +92,7 @@ public: static void setPscUniforms(ghoul::opengl::ProgramObject& program, const Camera& camera, const PowerScaledCoordinate& position); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: properties::BoolProperty _enabled; diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 614f1418ae..d9d5f681db 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,7 +29,11 @@ #include #include +#include #include +#include +#include +#include #include @@ -55,7 +59,6 @@ class Camera; class SyncBuffer; class Scene; class SceneManager; -class Renderer; class RaycasterManager; class ScreenLog; class ScreenSpaceRenderable; @@ -74,15 +77,12 @@ public: FPSAvg }; - static const std::string KeyFontMono; - static const std::string KeyFontLight; - static const std::vector FrametimeTypes; - RenderEngine(); ~RenderEngine() = default; - bool initialize(); - bool deinitialize(); + void initialize(); + void initializeGL(); + void deinitialize(); void setScene(Scene* scene); Scene* scene(); @@ -94,32 +94,24 @@ public: RaycasterManager& raycasterManager(); // sgct wrapped functions - bool initializeGL(); void updateShaderPrograms(); void updateFade(); void updateRenderer(); void updateScreenSpaceRenderables(); - void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix); + void render(const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix); void renderScreenLog(); void renderShutdownInformation(float timer, float fullTime); void postDraw(); - void takeScreenshot(bool applyWarping = false); - void toggleInfoText(bool b); - // Performance measurements bool doesPerformanceMeasurements() const; performance::PerformanceManager* performanceManager(); float globalBlackOutFactor(); void setGlobalBlackOutFactor(float factor); - void setNAaSamples(int nAaSamples); - void setShowFrameNumber(bool enabled); - - void setDisableRenderingOnMaster(bool enabled); void registerScreenSpaceRenderable(std::shared_ptr s); void unregisterScreenSpaceRenderable(std::shared_ptr s); @@ -213,18 +205,21 @@ private: //FrametimeType _frametimeType; - bool _showInfo; - bool _showLog; - bool _takeScreenshot; - bool _applyWarping; - bool _showFrameNumber; + properties::BoolProperty _showInfo; + properties::BoolProperty _showLog; + + properties::TriggerProperty _takeScreenshot; + bool _shouldTakeScreenshot; + properties::BoolProperty _applyWarping; + properties::BoolProperty _showFrameNumber; + properties::BoolProperty _disableMasterRendering; float _globalBlackOutFactor; float _fadeDuration; float _currentFadeTime; int _fadeDirection; - int _nAaSamples; - unsigned int _frameNumber; + properties::IntProperty _nAaSamples; + uint64_t _frameNumber; std::vector _programs; std::vector> _screenSpaceRenderables; @@ -233,8 +228,6 @@ private: std::shared_ptr _fontInfo = nullptr; std::shared_ptr _fontDate = nullptr; std::shared_ptr _fontLog = nullptr; - - bool _disableMasterRendering = false; }; } // namespace openspace diff --git a/include/openspace/rendering/renderer.h b/include/openspace/rendering/renderer.h index a09a433497..825a2ce5ad 100644 --- a/include/openspace/rendering/renderer.h +++ b/include/openspace/rendering/renderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/rendering/screenspacerenderable.h b/include/openspace/rendering/screenspacerenderable.h index aaebcb64b3..bd9b4ebafc 100644 --- a/include/openspace/rendering/screenspacerenderable.h +++ b/include/openspace/rendering/screenspacerenderable.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -36,10 +36,12 @@ #include #include -#include +#include namespace openspace { +namespace documentation { struct Documentation; } + /** * The base class for screen space images and screen space framebuffers. * This base class handles general functionality specific to planes that are rendered in @@ -49,7 +51,7 @@ namespace openspace { */ class ScreenSpaceRenderable : public properties::PropertyOwner { public: - static ScreenSpaceRenderable* createFromDictionary( + static std::unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); ScreenSpaceRenderable(const ghoul::Dictionary& dictionary); @@ -66,7 +68,7 @@ public: glm::vec3 sphericalPosition() const; float depth() const; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: void createPlane(); diff --git a/include/openspace/rendering/transferfunction.h b/include/openspace/rendering/transferfunction.h index 1bccef366e..2c462f7845 100644 --- a/include/openspace/rendering/transferfunction.h +++ b/include/openspace/rendering/transferfunction.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,7 @@ #define __OPENSPACE_CORE___TRANSFERFUNCTION___H__ #include -#include +#include #include #include #include diff --git a/include/openspace/rendering/volume.h b/include/openspace/rendering/volume.h index 0a01f23c34..f175a029e0 100644 --- a/include/openspace/rendering/volume.h +++ b/include/openspace/rendering/volume.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -129,4 +129,4 @@ public: } // namespace openspace -#endif // __OPENSPACE_CORE___VOLUME___H__ +#endif // __OPENSPACE_CORE___VOLUME___H__ diff --git a/include/openspace/rendering/volumeraycaster.h b/include/openspace/rendering/volumeraycaster.h index 652d906e6e..4315ebc5cc 100644 --- a/include/openspace/rendering/volumeraycaster.h +++ b/include/openspace/rendering/volumeraycaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -126,4 +126,4 @@ public: } // namespace openspace -#endif // __OPENSPACE_CORE___VOLUMERAYCASTER___H__ +#endif // __OPENSPACE_CORE___VOLUMERAYCASTER___H__ diff --git a/include/openspace/scene/rotation.h b/include/openspace/scene/rotation.h index d831046280..140f95d9df 100644 --- a/include/openspace/scene/rotation.h +++ b/include/openspace/scene/rotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,16 +27,19 @@ #include -#include #include -#include +#include + +namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; } + class Rotation : public properties::PropertyOwner { public: - static Rotation* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary(const ghoul::Dictionary& dictionary); Rotation(const ghoul::Dictionary& dictionary); virtual ~Rotation(); @@ -44,7 +47,7 @@ public: const glm::dmat3& matrix() const; virtual void update(const UpdateData& data); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: Rotation(); diff --git a/include/openspace/scene/scale.h b/include/openspace/scene/scale.h index f3af6473fd..b6c0f27a1a 100644 --- a/include/openspace/scene/scale.h +++ b/include/openspace/scene/scale.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,23 +27,24 @@ #include -#include #include -#include - +namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; }; + class Scale : public properties::PropertyOwner { public: - static Scale* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary(const ghoul::Dictionary& dictionary); + Scale(); virtual ~Scale(); virtual bool initialize(); virtual double scaleValue() const = 0; virtual void update(const UpdateData& data); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); }; } // namespace openspace diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 2db72e10e5..b397e921be 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -30,16 +30,17 @@ #include #include -#include - #include #include #include #include -#include + +namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; } + class SceneGraphNode; // Notifications: diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 703a081137..b13a6161e7 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,9 +25,6 @@ #ifndef __OPENSPACE_CORE___SCENEGRAPHNODE___H__ #define __OPENSPACE_CORE___SCENEGRAPHNODE___H__ -// open space includes -#include - #include #include #include @@ -35,17 +32,19 @@ #include #include -#include #include -// std includes #include #include #include #include +namespace ghoul { class Dictionary; } + namespace openspace { +namespace documentation { struct Documentation; } + class SceneGraphNode : public properties::PropertyOwner { public: using UpdateScene = ghoul::Boolean; @@ -112,7 +111,7 @@ public: const PerformanceRecord& performanceRecord() const { return _performanceRecord; } - void setRenderable(Renderable* renderable); + void setRenderable(std::unique_ptr renderable); const Renderable* renderable() const; Renderable* renderable(); @@ -131,7 +130,7 @@ private: PerformanceRecord _performanceRecord; - Renderable* _renderable; + std::unique_ptr _renderable; bool _renderableVisible; bool _boundingSphereVisible; diff --git a/include/openspace/scene/scenemanager.h b/include/openspace/scene/scenemanager.h index 48f515fe7e..1045994066 100644 --- a/include/openspace/scene/scenemanager.h +++ b/include/openspace/scene/scenemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/scene/translation.h b/include/openspace/scene/translation.h index b8b2e211bf..3cc355be03 100644 --- a/include/openspace/scene/translation.h +++ b/include/openspace/scene/translation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,17 +27,21 @@ #include -#include #include -#include +#include + +namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; } + class Translation : public properties::PropertyOwner { public: - static Translation* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary(const ghoul::Dictionary& dictionary); + Translation(); virtual ~Translation(); virtual bool initialize(); @@ -50,7 +54,7 @@ public: // invalidates potentially stored points, for example in trails void onParameterChange(std::function callback); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: void notifyObservers(); diff --git a/include/openspace/scripting/lualibrary.h b/include/openspace/scripting/lualibrary.h index 7c9f25c3a9..4f881f21ad 100644 --- a/include/openspace/scripting/lualibrary.h +++ b/include/openspace/scripting/lualibrary.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,6 +27,9 @@ #include +#include +#include + namespace openspace { namespace scripting { diff --git a/include/openspace/scripting/script_helper.h b/include/openspace/scripting/script_helper.h index cee943a0c1..a2c9231a26 100644 --- a/include/openspace/scripting/script_helper.h +++ b/include/openspace/scripting/script_helper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __SCRIPT_HELPER_H__ -#define __SCRIPT_HELPER_H__ +#ifndef __OPENSPACE_CORE___SCRIPT_HELPER___H__ +#define __OPENSPACE_CORE___SCRIPT_HELPER___H__ #define SCRIPT_CHECK_ARGUMENTS(__category__, __stack__, __reqArg__, __realArg__) \ if (__realArg__ != __reqArg__) { \ @@ -32,5 +32,4 @@ return 0; \ } - -#endif // __SCRIPT_HELPER_H__ +#endif // __OPENSPACE_CORE___SCRIPT_HELPER___H__ diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index c87beddaa8..b28a8fb2ba 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include @@ -93,8 +95,9 @@ public: //bool shouldScriptBeSent(const std::string &library, const std::string &function); //void cacheScript(const std::string &library, const std::string &function, const std::string &script); + static std::string OpenSpaceLibraryName; + private: - bool registerLuaLibrary(lua_State* state, const LuaLibrary& library); void addLibraryFunctions(lua_State* state, const LuaLibrary& library, bool replace); @@ -103,7 +106,7 @@ private: void addBaseLibrary(); void remapPrintFunction(); - lua_State* _state = nullptr; + ghoul::lua::LuaState _state; std::set _registeredLibraries; //sync variables diff --git a/include/openspace/scripting/scriptscheduler.h b/include/openspace/scripting/scriptscheduler.h index 3f9f44916d..fce3028caf 100644 --- a/include/openspace/scripting/scriptscheduler.h +++ b/include/openspace/scripting/scriptscheduler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___SCRIPTSCHEDULER___H__ #define __OPENSPACE_CORE___SCRIPTSCHEDULER___H__ -#include #include #include @@ -36,6 +35,7 @@ class Dictionary; } // namespace ghoul namespace openspace { +namespace documentation { struct Documentation; } namespace scripting { /** @@ -111,7 +111,7 @@ public: static LuaLibrary luaLibrary(); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: std::vector _timings; diff --git a/include/openspace/scripting/systemcapabilitiesbinding.h b/include/openspace/scripting/systemcapabilitiesbinding.h new file mode 100644 index 0000000000..107b97b5c3 --- /dev/null +++ b/include/openspace/scripting/systemcapabilitiesbinding.h @@ -0,0 +1,39 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___SYSTEMCAPABILITIESBINDING___H__ +#define __OPENSPACE_CORE___SYSTEMCAPABILITIESBINDING___H__ + +#include + +namespace openspace { +namespace scripting { + +LuaLibrary generalSystemCapabilities(); +LuaLibrary openglSystemCapabilities(); + +} // namespace scripting +} // namespace openspace + +#endif // __OPENSPACE_CORE___SYSTEMCAPABILITIESBINDING___H__ diff --git a/include/openspace/util/blockplaneintersectiongeometry.h b/include/openspace/util/blockplaneintersectiongeometry.h index 70117c36cd..c861cb8835 100644 --- a/include/openspace/util/blockplaneintersectiongeometry.h +++ b/include/openspace/util/blockplaneintersectiongeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,7 @@ #define __OPENSPACE_CORE___BLOCKPLANEINTERSECTIONGEOMETRY___H__ #include -#include +#include #include diff --git a/include/openspace/util/boxgeometry.h b/include/openspace/util/boxgeometry.h index 8b87f29397..7016f87435 100644 --- a/include/openspace/util/boxgeometry.h +++ b/include/openspace/util/boxgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,7 @@ #define __OPENSPACE_CORE___BOXGEOMETRY___H__ #include -#include +#include namespace openspace { diff --git a/include/openspace/util/camera.h b/include/openspace/util/camera.h index 7a394c15f3..d2436ab93d 100644 --- a/include/openspace/util/camera.h +++ b/include/openspace/util/camera.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___CAMERA___H__ #define __OPENSPACE_CORE___CAMERA___H__ diff --git a/include/openspace/util/distanceconstants.h b/include/openspace/util/distanceconstants.h new file mode 100644 index 0000000000..a7a368f7ba --- /dev/null +++ b/include/openspace/util/distanceconstants.h @@ -0,0 +1,39 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___DISTANCECONSTANTS___H__ +#define __OPENSPACE_CORE___DISTANCECONSTANTS___H__ + +namespace openspace { + +namespace distanceconstants { + const float EarthRadius = 6371; + const float LightYear = 9.4607304725808E15; + const float AstronomicalUnit = 1.495978707E11; + const float Parsec = 3.0856776E16; +} + +} + +#endif // __OPENSPACE_CORE___DISTANCECONSTANTS___H__ diff --git a/include/openspace/util/factorymanager.h b/include/openspace/util/factorymanager.h index 663376d7f1..7b815ca065 100644 --- a/include/openspace/util/factorymanager.h +++ b/include/openspace/util/factorymanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/factorymanager.inl b/include/openspace/util/factorymanager.inl index dde01bcef5..56034150b8 100644 --- a/include/openspace/util/factorymanager.inl +++ b/include/openspace/util/factorymanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/gpudata.h b/include/openspace/util/gpudata.h index aac40f5ba8..31b7ff8e03 100644 --- a/include/openspace/util/gpudata.h +++ b/include/openspace/util/gpudata.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -34,9 +34,6 @@ namespace openspace { -using namespace ghoul::opengl; - - /** * Very simple class maintaining a uniform location. */ @@ -47,7 +44,7 @@ public: * Updates the uniform location of the uniform variable named * in the provided shader program. */ - void bind(ProgramObject* program, const std::string& name); + void bind(ghoul::opengl::ProgramObject* program, const std::string& name); protected: GLint _uniformLocation = -1; @@ -67,7 +64,7 @@ public: * Sets the value of T to its corresponding GPU value. * OBS! Users must ensure bind has been called before using this method */ - void setValue(ProgramObject* program, T val){ + void setValue(ghoul::opengl::ProgramObject* program, T val){ program->setUniform(_uniformLocation, val); } @@ -86,8 +83,8 @@ public: * program. * OBS! Users must ensure bind has been called before using this method. */ - void setValue(ProgramObject* program, std::shared_ptr texture){ - _texUnit = std::make_unique(); + void setValue(ghoul::opengl::ProgramObject* program, std::shared_ptr texture){ + _texUnit = std::make_unique(); _texUnit->activate(); texture->bind(); program->setUniform(_uniformLocation, *_texUnit); @@ -99,7 +96,7 @@ public: private: - std::unique_ptr _texUnit; + std::unique_ptr _texUnit; }; diff --git a/include/openspace/util/histogram.h b/include/openspace/util/histogram.h index 1324b08096..f26cd80beb 100644 --- a/include/openspace/util/histogram.h +++ b/include/openspace/util/histogram.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -90,4 +90,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_CORE___HISTOGRAM___H__ +#endif // __OPENSPACE_CORE___HISTOGRAM___H__ diff --git a/include/openspace/util/keys.h b/include/openspace/util/keys.h index f65c13a261..3f53df38bf 100644 --- a/include/openspace/util/keys.h +++ b/include/openspace/util/keys.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -218,7 +218,6 @@ struct KeyWithModifier { KeyWithModifier stringToKey(std::string str); bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs); - static const std::map KeyModifierMapping = { { "SHIFT", KeyModifier::Shift }, { "ALT", KeyModifier::Alt }, diff --git a/include/openspace/util/mouse.h b/include/openspace/util/mouse.h index c616ec73a4..8dcbaed06f 100644 --- a/include/openspace/util/mouse.h +++ b/include/openspace/util/mouse.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/openspacemodule.h b/include/openspace/util/openspacemodule.h index 266c07a0c9..ee8ff15e83 100644 --- a/include/openspace/util/openspacemodule.h +++ b/include/openspace/util/openspacemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,14 +27,15 @@ #include -#include +#include -#include +#include #include #include namespace openspace { +namespace documentation { struct Documentation; } /** * This class is the base class for an OpenSpace module. A module groups functionality @@ -72,15 +73,21 @@ public: * Returns a list of Documentation classes that are valid for this OpenSpaceModule. * \return A list of Documentation classes that are valid for this OpenSapceModule */ - virtual std::vector documentations() const; + virtual std::vector documentations() const; + + /** + * Returns the Lua library with functions defined by this OpenSpaceModule. The default + * implementation returns an empty library. + * \return The Lua library with functions defined by this OpenSpaceModule + */ + virtual scripting::LuaLibrary luaLibrary() const; /** * Returns the minimum required OpenGL version of this OpenSpaceModule. Unless * overwritten, it returns an OpenGL version of 3.3. * \return The minimum required OpenGL version of this OpenSpaceModule */ - virtual ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version - requiredOpenGLVersion() const; + virtual ghoul::systemcapabilities::Version requiredOpenGLVersion() const; protected: /** diff --git a/include/openspace/util/powerscaledcoordinate.h b/include/openspace/util/powerscaledcoordinate.h index 75cfb94e85..24b9925abc 100644 --- a/include/openspace/util/powerscaledcoordinate.h +++ b/include/openspace/util/powerscaledcoordinate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/powerscaledscalar.h b/include/openspace/util/powerscaledscalar.h index 2fe2aea57d..3e1e06e1a2 100644 --- a/include/openspace/util/powerscaledscalar.h +++ b/include/openspace/util/powerscaledscalar.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/powerscaledsphere.h b/include/openspace/util/powerscaledsphere.h index da8e80ba90..0e51bb4364 100644 --- a/include/openspace/util/powerscaledsphere.h +++ b/include/openspace/util/powerscaledsphere.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/progressbar.h b/include/openspace/util/progressbar.h index 92f988958f..cbc0afe3d3 100644 --- a/include/openspace/util/progressbar.h +++ b/include/openspace/util/progressbar.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/screenlog.h b/include/openspace/util/screenlog.h index f800991555..b9769f7b01 100644 --- a/include/openspace/util/screenlog.h +++ b/include/openspace/util/screenlog.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index 6350a26a43..5327b8004a 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/syncbuffer.h b/include/openspace/util/syncbuffer.h index 2e00eba951..a64ee9191e 100644 --- a/include/openspace/util/syncbuffer.h +++ b/include/openspace/util/syncbuffer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/syncdata.h b/include/openspace/util/syncdata.h index 4c491b539c..daeeaeedc0 100644 --- a/include/openspace/util/syncdata.h +++ b/include/openspace/util/syncdata.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/interaction/keyboardcontroller.h b/include/openspace/util/task.h similarity index 70% rename from include/openspace/interaction/keyboardcontroller.h rename to include/openspace/util/task.h index 07933e5bc7..dc5cc69c7f 100644 --- a/include/openspace/interaction/keyboardcontroller.h +++ b/include/openspace/util/task.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,36 +22,32 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___KEYBOARDCONTROLLER___H__ -#define __OPENSPACE_CORE___KEYBOARDCONTROLLER___H__ +#ifndef __OPENSPACE_CORE___TASK___H__ +#define __OPENSPACE_CORE___TASK___H__ -#include +#include +#include -#include +namespace ghoul { class Dictionary; } namespace openspace { -namespace interaction { -class KeyboardController : public Controller { +namespace documentation { struct Documentation; } + +class Task { public: - virtual ~KeyboardController() {}; - virtual void keyPressed(KeyAction action, Key key, KeyModifier modifier) = 0; + using ProgressCallback = std::function; + + virtual ~Task() = default; + virtual void perform(const ProgressCallback& onProgress) = 0; + virtual std::string description() = 0; + + static std::unique_ptr createFromDictionary( + const ghoul::Dictionary& dictionary + ); + static documentation::Documentation documentation(); }; -class KeyboardControllerFixed : public KeyboardController { -public: - void keyPressed(KeyAction action, Key key, KeyModifier modifier); -}; - -class KeyboardControllerLua : public KeyboardController { -public: - void keyPressed(KeyAction action, Key key, KeyModifier modifier); - -protected: - std::string keyToString(Key key, KeyModifier mod) const; -}; - -} // namespace interaction } // namespace openspace -#endif // __OPENSPACE_CORE___KEYBOARDCONTROLLER___H__ +#endif // __OPENSPACE_CORE___TASK___H__ diff --git a/include/openspace/util/taskloader.h b/include/openspace/util/taskloader.h new file mode 100644 index 0000000000..4081523c7d --- /dev/null +++ b/include/openspace/util/taskloader.h @@ -0,0 +1,42 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___TASKLOADER___H__ +#define __OPENSPACE_CORE___TASKLOADER___H__ + +#include +#include +#include + +namespace openspace { + +class TaskLoader { +public: + std::vector> tasksFromDictionary(const ghoul::Dictionary& dictionary); + std::vector> tasksFromFile(const std::string& path); +}; + +} // namespace openspace + +#endif // __OPENSPACE_CORE___TASKLOADER___H__ diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index e8b525539b..5241d21a61 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/include/openspace/util/timemanager.h b/include/openspace/util/timemanager.h index fb9468bcc9..376e8d35e5 100644 --- a/include/openspace/util/timemanager.h +++ b/include/openspace/util/timemanager.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___TIMEMANAGER___H__ #define __OPENSPACE_CORE___TIMEMANAGER___H__ diff --git a/include/openspace/util/timerange.h b/include/openspace/util/timerange.h index 80a99c1fbf..b7739f1322 100644 --- a/include/openspace/util/timerange.h +++ b/include/openspace/util/timerange.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,12 +25,12 @@ #ifndef __OPENSPACE_CORE___TIMERANGE___H__ #define __OPENSPACE_CORE___TIMERANGE___H__ -#include - namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; } + struct TimeRange { /** @@ -70,7 +70,7 @@ struct TimeRange { bool includes(const TimeRange& o) const; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); double start; double end; @@ -78,4 +78,4 @@ struct TimeRange { } // namespace openspace -#endif //__OPENSPACE_CORE___TIMERANGE___H__ +#endif // __OPENSPACE_CORE___TIMERANGE___H__ diff --git a/include/openspace/util/transformationmanager.h b/include/openspace/util/transformationmanager.h index c2b655fd5b..1c0c93f9d1 100644 --- a/include/openspace/util/transformationmanager.h +++ b/include/openspace/util/transformationmanager.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___TRANSFORMATIONMANAGER___H__ #define __OPENSPACE_CORE___TRANSFORMATIONMANAGER___H__ @@ -61,4 +61,4 @@ private: } // namespace openspace - #endif //__OPENSPACE_CORE___TRANSFORMATIONMANAGER___H__ +#endif // __OPENSPACE_CORE___TRANSFORMATIONMANAGER___H__ diff --git a/include/openspace/util/updatestructures.h b/include/openspace/util/updatestructures.h index 6708532276..423b30e37a 100644 --- a/include/openspace/util/updatestructures.h +++ b/include/openspace/util/updatestructures.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/libgdal.dylib b/libgdal.dylib deleted file mode 120000 index ea01525cd6..0000000000 --- a/libgdal.dylib +++ /dev/null @@ -1 +0,0 @@ -libgdal.1.dylib \ No newline at end of file diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index 87bfff60d8..751cb25587 100644 --- a/modules/base/CMakeLists.txt +++ b/modules/base/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index 73c6a5779b..fc8f383a3d 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -103,7 +104,7 @@ void BaseModule::internalInitialize() { fModelGeometry->registerClass("MultiModelGeometry"); } -std::vector BaseModule::documentations() const { +std::vector BaseModule::documentations() const { return { StaticScale::Documentation(), StaticTranslation::Documentation(), diff --git a/modules/base/basemodule.h b/modules/base/basemodule.h index ab115abb1a..257cdec7ce 100644 --- a/modules/base/basemodule.h +++ b/modules/base/basemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,8 +32,8 @@ namespace openspace { class BaseModule : public OpenSpaceModule { public: BaseModule(); - - std::vector documentations() const override; + virtual ~BaseModule() = default; + std::vector documentations() const override; protected: void internalInitialize() override; diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index 28e90ed083..82e3ee0074 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,12 +28,13 @@ #include #include #include +#include #include namespace { - const std::string _loggerCat = "ModelGeometry"; - const std::string keyGeomModelFile = "GeometryFile"; + const char* _loggerCat = "ModelGeometry"; + const char* keyGeomModelFile = "GeometryFile"; const int8_t CurrentCacheVersion = 3; const char* keyType = "Type"; const char* keyName = "Name"; @@ -42,7 +43,7 @@ namespace { namespace openspace { namespace modelgeometry { -Documentation ModelGeometry::Documentation() { +documentation:: Documentation ModelGeometry::Documentation() { using namespace documentation; return { "Model Geometry", @@ -67,7 +68,9 @@ Documentation ModelGeometry::Documentation() { } -ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) { +std::unique_ptr ModelGeometry::createFromDictionary( + const ghoul::Dictionary& dictionary) +{ if (!dictionary.hasKeyAndValue(keyType)) { throw ghoul::RuntimeError("Dictionary did not contain a key 'Type'"); } @@ -75,7 +78,7 @@ ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dict std::string geometryType = dictionary.value(keyType); auto factory = FactoryManager::ref().factory(); - ModelGeometry* result = factory->create(geometryType, dictionary); + std::unique_ptr result = factory->create(geometryType, dictionary); if (result == nullptr) { throw ghoul::RuntimeError( "Failed to create a ModelGeometry object of type '" + geometryType + "'" @@ -85,7 +88,8 @@ ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dict } ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) - : _parent(nullptr) + : properties::PropertyOwner("ModelGeometry") + , _parent(nullptr) , _mode(GL_TRIANGLES) { documentation::testSpecificationAndThrow( @@ -94,8 +98,6 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) "ModelGeometry" ); - setName("ModelGeometry"); - std::string name; bool success = dictionary.getValue(keyName, name); ghoul_assert(success, "Name tag was not present"); diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index 8cd5a9abba..508b523101 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,17 +27,20 @@ #include -#include #include -#include + +namespace ghoul { class Dictionary; } namespace openspace { +namespace documentation { struct Documentation; } namespace modelgeometry { class ModelGeometry : public properties::PropertyOwner { public: - static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary( + const ghoul::Dictionary& dictionary + ); struct Vertex { GLfloat location[4]; @@ -59,7 +62,7 @@ public: virtual void setUniforms(ghoul::opengl::ProgramObject& program); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: Renderable* _parent; @@ -81,4 +84,4 @@ protected: } // namespace modelgeometry } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__ +#endif // __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__ diff --git a/modules/base/rendering/multimodelgeometry.cpp b/modules/base/rendering/multimodelgeometry.cpp index 27bf69034b..49e5b77e43 100644 --- a/modules/base/rendering/multimodelgeometry.cpp +++ b/modules/base/rendering/multimodelgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/multimodelgeometry.h b/modules/base/rendering/multimodelgeometry.h index ce4d8436e7..dedd7f256c 100644 --- a/modules/base/rendering/multimodelgeometry.h +++ b/modules/base/rendering/multimodelgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index aab085b9ae..1adca3f960 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -85,7 +85,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) if (success) _colorTexturePath = absPath(texturePath); - addPropertySubOwner(_geometry); + addPropertySubOwner(_geometry.get()); addProperty(_colorTexturePath); _colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this)); @@ -153,7 +153,6 @@ bool RenderableModel::initialize() { bool RenderableModel::deinitialize() { if (_geometry) { _geometry->deinitialize(); - delete _geometry; _geometry = nullptr; } _texture = nullptr; @@ -226,7 +225,7 @@ void RenderableModel::render(const RenderData& data) { void RenderableModel::update(const UpdateData& data) { if (_programObject->isDirty()) _programObject->rebuildFromFile(); - double _time = data.time; +// double _time = data.time; //if (_isGhost){ // futureTime = openspace::ImageSequencer::ref().getNextCaptureTime(); diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 2921b47ee4..153964d60a 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -36,6 +36,8 @@ #include #include +#include + namespace openspace { namespace modelgeometry { @@ -65,7 +67,7 @@ private: std::unique_ptr _programObject; std::unique_ptr _texture; - modelgeometry::ModelGeometry* _geometry; + std::unique_ptr _geometry; glm::dmat3 _modelTransform; @@ -87,4 +89,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___RENDERABLEMODEL___H__ +#endif // __OPENSPACE_MODULE_BASE___RENDERABLEMODEL___H__ diff --git a/modules/base/rendering/renderablepath.cpp b/modules/base/rendering/renderablepath.cpp index f0e3623950..ebea0891cb 100644 --- a/modules/base/rendering/renderablepath.cpp +++ b/modules/base/rendering/renderablepath.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderablepath.h b/modules/base/rendering/renderablepath.h index e83fc305da..44c7dfb1b8 100644 --- a/modules/base/rendering/renderablepath.h +++ b/modules/base/rendering/renderablepath.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 3c88efce3a..744c94e83e 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index 3b8ce519dd..3c26807882 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index ce5049df5a..5453db84c6 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderablesphere.h b/modules/base/rendering/renderablesphere.h index b423a864a7..e697ca7f5a 100644 --- a/modules/base/rendering/renderablesphere.h +++ b/modules/base/rendering/renderablesphere.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index 6fc2743814..4af5bc3a82 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderablesphericalgrid.h b/modules/base/rendering/renderablesphericalgrid.h index 47bfabc849..1980018c48 100644 --- a/modules/base/rendering/renderablesphericalgrid.h +++ b/modules/base/rendering/renderablesphericalgrid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 0313f59687..7085abd948 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -56,8 +57,8 @@ namespace { namespace openspace { -Documentation RenderableTrail::Documentation() { -using namespace documentation; +documentation::Documentation RenderableTrail::Documentation() { + using namespace documentation; return { "RenderableTrail", "base_renderable_renderabletrail", diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index 4b421cf88a..c8a73fdb10 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -41,11 +40,13 @@ namespace ghoul { namespace opengl { class ProgramObject; class Texture; -} -} +} // namespace opengl +} // namespace ghoul namespace openspace { +namespace documentation { struct Documentation; } + class Translation; /** @@ -89,7 +90,7 @@ protected: explicit RenderableTrail(const ghoul::Dictionary& dictionary); /// Returns the documentation entries that the con - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); /// The layout of the VBOs struct TrailVBOLayout { diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index 7215c17ab0..9f08db6fcc 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include @@ -83,9 +84,9 @@ namespace { namespace openspace { -openspace::Documentation RenderableTrailOrbit::Documentation() { +documentation::Documentation RenderableTrailOrbit::Documentation() { using namespace documentation; - openspace::Documentation doc{ + documentation::Documentation doc { "RenderableTrailOrbit", "base_renderable_renderabletrailorbit", { @@ -118,7 +119,7 @@ openspace::Documentation RenderableTrailOrbit::Documentation() { // Insert the parents documentation entries until we have a verifier that can deal // with class hierarchy - openspace::Documentation parentDoc = RenderableTrail::Documentation(); + documentation::Documentation parentDoc = RenderableTrail::Documentation(); doc.entries.insert( doc.entries.end(), parentDoc.entries.begin(), diff --git a/modules/base/rendering/renderabletrailorbit.h b/modules/base/rendering/renderabletrailorbit.h index 79371ce5d9..5bcd5b0887 100644 --- a/modules/base/rendering/renderabletrailorbit.h +++ b/modules/base/rendering/renderabletrailorbit.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,12 +27,13 @@ #include -#include #include #include namespace openspace { +namespace documentation { struct Documentation; } + /** * This concrete implementation of a RenderableTrail renders an updated trail behind an * object that is likely to have an orbit-like path. However, this is not required and @@ -52,7 +53,7 @@ public: void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: /** diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 89f2f7d947..2fcc079b79 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -51,9 +52,10 @@ namespace { namespace openspace { -openspace::Documentation RenderableTrailTrajectory::Documentation() { +documentation::Documentation RenderableTrailTrajectory::Documentation() { using namespace documentation; - openspace::Documentation doc { + + documentation::Documentation doc { "RenderableTrailTrajectory", "base_renderable_renderabletrailtrajectory", { @@ -110,7 +112,7 @@ openspace::Documentation RenderableTrailTrajectory::Documentation() { // Insert the parents documentation entries until we have a verifier that can deal // with class hierarchy - openspace::Documentation parentDoc = RenderableTrail::Documentation(); + documentation::Documentation parentDoc = RenderableTrail::Documentation(); doc.entries.insert( doc.entries.end(), parentDoc.entries.begin(), diff --git a/modules/base/rendering/renderabletrailtrajectory.h b/modules/base/rendering/renderabletrailtrajectory.h index 519b505c6c..2e02ee6f3a 100644 --- a/modules/base/rendering/renderabletrailtrajectory.h +++ b/modules/base/rendering/renderabletrailtrajectory.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -35,6 +34,8 @@ namespace openspace { +namespace documentation { struct Documentation; } + /** * This concrete implementation of a RenderableTrail renders a fixed trail, regardless of * its shape. The trail is sampled equitemporal (with an interval of _sampleInterval in @@ -55,7 +56,7 @@ public: void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: /// The start time of the trail diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 1e9502a9f1..630bb6d39b 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/screenspaceframebuffer.h b/modules/base/rendering/screenspaceframebuffer.h index ab408e77ba..33a04a3655 100644 --- a/modules/base/rendering/screenspaceframebuffer.h +++ b/modules/base/rendering/screenspaceframebuffer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -68,4 +68,4 @@ private: } //namespace openspace -#endif //__OPENSPACE_MODULE_BASE___SCREENSPACEFRAMEBUFFER___H__ +#endif // __OPENSPACE_MODULE_BASE___SCREENSPACEFRAMEBUFFER___H__ diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index d68bd151c0..d5822c567c 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/screenspaceimage.h b/modules/base/rendering/screenspaceimage.h index 190598b430..7316722608 100644 --- a/modules/base/rendering/screenspaceimage.h +++ b/modules/base/rendering/screenspaceimage.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -61,6 +61,6 @@ private: properties::StringProperty _texturePath; }; -} //namespace openspace +} // namespace openspace -#endif //__OPENSPACE_MODULE_BASE___SCREENSPACEIMAGE___H__ +#endif // __OPENSPACE_MODULE_BASE___SCREENSPACEIMAGE___H__ diff --git a/modules/base/rendering/wavefrontgeometry.cpp b/modules/base/rendering/wavefrontgeometry.cpp index c24014f7ee..bb4debc3ee 100644 --- a/modules/base/rendering/wavefrontgeometry.cpp +++ b/modules/base/rendering/wavefrontgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/rendering/wavefrontgeometry.h b/modules/base/rendering/wavefrontgeometry.h index 5bc949942f..862efb26ed 100644 --- a/modules/base/rendering/wavefrontgeometry.h +++ b/modules/base/rendering/wavefrontgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __WAVEFRONTGEOMETRY_H__ -#define __WAVEFRONTGEOMETRY_H__ +#ifndef __OPENSPACE_MODULE_BASE___WAVEFRONTGEOMETRY___H__ +#define __OPENSPACE_MODULE_BASE___WAVEFRONTGEOMETRY___H__ #include @@ -45,7 +45,7 @@ namespace modelgeometry { bool loadModel(const std::string& filename); }; -} // namespace modelgeometry -} // namespace openspace +} // namespace modelgeometry +} // namespace openspace -#endif // __WAVEFRONTOBJECT_H__ +#endif // __OPENSPACE_MODULE_BASE___WAVEFRONTGEOMETRY___H__ diff --git a/modules/base/rotation/staticrotation.cpp b/modules/base/rotation/staticrotation.cpp index 5c645d4143..e8aa408dd8 100644 --- a/modules/base/rotation/staticrotation.cpp +++ b/modules/base/rotation/staticrotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include namespace { @@ -32,7 +33,7 @@ namespace { namespace openspace { -Documentation StaticRotation::Documentation() { +documentation::Documentation StaticRotation::Documentation() { using namespace openspace::documentation; return { "Static Rotation", diff --git a/modules/base/rotation/staticrotation.h b/modules/base/rotation/staticrotation.h index c2439edde1..f03fa79681 100644 --- a/modules/base/rotation/staticrotation.h +++ b/modules/base/rotation/staticrotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,17 +27,18 @@ #include -#include #include namespace openspace { +namespace documentation { struct Documentation; } + class StaticRotation : public Rotation { public: StaticRotation(); StaticRotation(const ghoul::Dictionary& dictionary); - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: properties::DMat3Property _rotationMatrix; diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index b868291e43..ef6a448dba 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include namespace { @@ -33,7 +34,7 @@ namespace { namespace openspace { -Documentation StaticScale::Documentation() { +documentation::Documentation StaticScale::Documentation() { using namespace openspace::documentation; return { "Static Scaling", diff --git a/modules/base/scale/staticscale.h b/modules/base/scale/staticscale.h index 8ab3e36c3e..d2c14ab760 100644 --- a/modules/base/scale/staticscale.h +++ b/modules/base/scale/staticscale.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,18 +27,19 @@ #include -#include #include namespace openspace { +namespace documentation { struct Documentation; } + class StaticScale : public Scale { public: StaticScale(); StaticScale(const ghoul::Dictionary& dictionary); double scaleValue() const; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: properties::FloatProperty _scaleValue; diff --git a/modules/base/shaders/imageplane_fs.glsl b/modules/base/shaders/imageplane_fs.glsl index 581ebb46ef..0673ba4782 100644 --- a/modules/base/shaders/imageplane_fs.glsl +++ b/modules/base/shaders/imageplane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/imageplane_vs.glsl b/modules/base/shaders/imageplane_vs.glsl index e98713c544..4b0bb8424d 100644 --- a/modules/base/shaders/imageplane_vs.glsl +++ b/modules/base/shaders/imageplane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/model_fs.glsl b/modules/base/shaders/model_fs.glsl index c3f87451ec..3a14dc24dd 100644 --- a/modules/base/shaders/model_fs.glsl +++ b/modules/base/shaders/model_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/model_vs.glsl b/modules/base/shaders/model_vs.glsl index be60d9162e..2837c67a44 100644 --- a/modules/base/shaders/model_vs.glsl +++ b/modules/base/shaders/model_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/path_fs.glsl b/modules/base/shaders/path_fs.glsl index f2c701ae64..101d592048 100644 --- a/modules/base/shaders/path_fs.glsl +++ b/modules/base/shaders/path_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/path_gs.glsl b/modules/base/shaders/path_gs.glsl index 871001236f..b5305ff15f 100644 --- a/modules/base/shaders/path_gs.glsl +++ b/modules/base/shaders/path_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/path_vs.glsl b/modules/base/shaders/path_vs.glsl index b8f9697e9d..e492beaa3e 100644 --- a/modules/base/shaders/path_vs.glsl +++ b/modules/base/shaders/path_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/plane_fs.glsl b/modules/base/shaders/plane_fs.glsl index bfabe1ccb9..aa2902a829 100644 --- a/modules/base/shaders/plane_fs.glsl +++ b/modules/base/shaders/plane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/plane_vs.glsl b/modules/base/shaders/plane_vs.glsl index 45d0125d7e..b64c7c2423 100644 --- a/modules/base/shaders/plane_vs.glsl +++ b/modules/base/shaders/plane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/pscstandard_fs.glsl b/modules/base/shaders/pscstandard_fs.glsl index c32305121c..8eb494e4d5 100644 --- a/modules/base/shaders/pscstandard_fs.glsl +++ b/modules/base/shaders/pscstandard_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/pscstandard_vs.glsl b/modules/base/shaders/pscstandard_vs.glsl index 030d74cc15..936d7cece4 100644 --- a/modules/base/shaders/pscstandard_vs.glsl +++ b/modules/base/shaders/pscstandard_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -54,4 +54,4 @@ void main() vs_position = tmp; position = ViewProjection * position; gl_Position = z_normalization(position); -} \ No newline at end of file +} diff --git a/modules/base/shaders/renderabletrail_fs.glsl b/modules/base/shaders/renderabletrail_fs.glsl index 288aa5dc12..600ccb8240 100644 --- a/modules/base/shaders/renderabletrail_fs.glsl +++ b/modules/base/shaders/renderabletrail_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/renderabletrail_vs.glsl b/modules/base/shaders/renderabletrail_vs.glsl index 2db1690fda..3aa70b8575 100644 --- a/modules/base/shaders/renderabletrail_vs.glsl +++ b/modules/base/shaders/renderabletrail_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/screenspace_fs.glsl b/modules/base/shaders/screenspace_fs.glsl index 9ab37b56af..11aae2042f 100644 --- a/modules/base/shaders/screenspace_fs.glsl +++ b/modules/base/shaders/screenspace_fs.glsl @@ -1,27 +1,29 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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__ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 sampler2D texture1; uniform float OcclusionDepth; uniform float Alpha; diff --git a/modules/base/shaders/screenspace_vs.glsl b/modules/base/shaders/screenspace_vs.glsl index 02849b3537..cdeafae745 100644 --- a/modules/base/shaders/screenspace_vs.glsl +++ b/modules/base/shaders/screenspace_vs.glsl @@ -1,27 +1,26 @@ - /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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__ diff --git a/modules/base/shaders/sphere_fs.glsl b/modules/base/shaders/sphere_fs.glsl index f059466731..0fb59c43f2 100644 --- a/modules/base/shaders/sphere_fs.glsl +++ b/modules/base/shaders/sphere_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/shaders/sphere_vs.glsl b/modules/base/shaders/sphere_vs.glsl index 7c64455d68..6add629a6d 100644 --- a/modules/base/shaders/sphere_vs.glsl +++ b/modules/base/shaders/sphere_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/base/translation/statictranslation.cpp b/modules/base/translation/statictranslation.cpp index e0e3e85b42..ead533d1c8 100644 --- a/modules/base/translation/statictranslation.cpp +++ b/modules/base/translation/statictranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include namespace { @@ -32,8 +33,8 @@ namespace { namespace openspace { -Documentation StaticTranslation::Documentation() { - using namespace openspace::documentation; +documentation::Documentation StaticTranslation::Documentation() { + using namespace documentation; return { "Static Translation", "base_transform_translation_static", diff --git a/modules/base/translation/statictranslation.h b/modules/base/translation/statictranslation.h index a699497888..665e89f123 100644 --- a/modules/base/translation/statictranslation.h +++ b/modules/base/translation/statictranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,10 +27,11 @@ #include -#include #include namespace openspace { + +namespace documentation { struct Documentation; } class StaticTranslation : public Translation { public: @@ -40,7 +41,7 @@ public: virtual glm::dvec3 position() const; virtual void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: properties::DVec3Property _position; diff --git a/modules/debugging/CMakeLists.txt b/modules/debugging/CMakeLists.txt index a79423ab84..0b2400b4f9 100644 --- a/modules/debugging/CMakeLists.txt +++ b/modules/debugging/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/debugging/debuggingmodule.cpp b/modules/debugging/debuggingmodule.cpp index b1e28763ac..4793bbb81e 100644 --- a/modules/debugging/debuggingmodule.cpp +++ b/modules/debugging/debuggingmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/debugging/debuggingmodule.h b/modules/debugging/debuggingmodule.h index 8ea478a4d0..a626899a89 100644 --- a/modules/debugging/debuggingmodule.h +++ b/modules/debugging/debuggingmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_BASE___DEBUGGINGMODULE___H__ -#define __OPENSPACE_MODULE_BASE___DEBUGGINGMODULE___H__ +#ifndef __OPENSPACE_MODULE_DEBUGGING___DEBUGGINGMODULE___H__ +#define __OPENSPACE_MODULE_DEBUGGING___DEBUGGINGMODULE___H__ #include @@ -39,4 +39,4 @@ protected: } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___DEBUGGINGMODULE___H__ +#endif // __OPENSPACE_MODULE_DEBUGGING___DEBUGGINGMODULE___H__ diff --git a/modules/debugging/rendering/debugrenderer.cpp b/modules/debugging/rendering/debugrenderer.cpp index de3305a842..3f028ecb6a 100644 --- a/modules/debugging/rendering/debugrenderer.cpp +++ b/modules/debugging/rendering/debugrenderer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include diff --git a/modules/debugging/rendering/debugrenderer.h b/modules/debugging/rendering/debugrenderer.h index 95e143e87c..31145a9eeb 100644 --- a/modules/debugging/rendering/debugrenderer.h +++ b/modules/debugging/rendering/debugrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_BASE___DEBUGRENDERER___H__ -#define __OPENSPACE_MODULE_BASE___DEBUGRENDERER___H__ +#ifndef __OPENSPACE_MODULE_DEBUGGING___DEBUGRENDERER___H__ +#define __OPENSPACE_MODULE_DEBUGGING___DEBUGRENDERER___H__ #include #include @@ -31,8 +31,7 @@ #include #include - -#include +#include #include #include @@ -162,4 +161,4 @@ protected: } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___DEBUGRENDERER___H__ +#endif // __OPENSPACE_MODULE_DEBUGGING___DEBUGRENDERER___H__ diff --git a/modules/debugging/rendering/debugshader_fs.glsl b/modules/debugging/rendering/debugshader_fs.glsl index 5a395b10e7..e119339bef 100644 --- a/modules/debugging/rendering/debugshader_fs.glsl +++ b/modules/debugging/rendering/debugshader_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -35,4 +35,4 @@ Fragment getFragment(){ frag.color = color; frag.depth = fs_vertexPosition.w; return frag; -} \ No newline at end of file +} diff --git a/modules/debugging/rendering/debugshader_vs.glsl b/modules/debugging/rendering/debugshader_vs.glsl index b68e20f682..45f4357ad8 100644 --- a/modules/debugging/rendering/debugshader_vs.glsl +++ b/modules/debugging/rendering/debugshader_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,4 +33,4 @@ out vec4 fs_vertexPosition; void main(){ fs_vertexPosition = z_normalization(vertexPositionClippingSpace); gl_Position = fs_vertexPosition; -} \ No newline at end of file +} diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 98077c7a7b..e40dd68cd5 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/debugging/rendering/renderabledebugplane.h b/modules/debugging/rendering/renderabledebugplane.h index ffa476d0e9..96df652354 100644 --- a/modules/debugging/rendering/renderabledebugplane.h +++ b/modules/debugging/rendering/renderabledebugplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_BASE___RENDERABLEDEBUGPLANE___H__ -#define __OPENSPACE_MODULE_BASE___RENDERABLEDEBUGPLANE___H__ +#ifndef __OPENSPACE_MODULE_DEBUGGING___RENDERABLEDEBUGPLANE___H__ +#define __OPENSPACE_MODULE_DEBUGGING___RENDERABLEDEBUGPLANE___H__ #include @@ -82,4 +82,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___RENDERABLEDEBUGPLANE___H__ +#endif // __OPENSPACE_MODULE_DEBUGGING___RENDERABLEDEBUGPLANE___H__ diff --git a/modules/fieldlines/CMakeLists.txt b/modules/fieldlines/CMakeLists.txt index e8c847c274..ca28a3c37e 100644 --- a/modules/fieldlines/CMakeLists.txt +++ b/modules/fieldlines/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/fieldlines/fieldlinesmodule.cpp b/modules/fieldlines/fieldlinesmodule.cpp index 734ede9741..bc74add3d4 100644 --- a/modules/fieldlines/fieldlinesmodule.cpp +++ b/modules/fieldlines/fieldlinesmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/fieldlines/fieldlinesmodule.h b/modules/fieldlines/fieldlinesmodule.h index 4d6731383c..ef06ed869c 100644 --- a/modules/fieldlines/fieldlinesmodule.h +++ b/modules/fieldlines/fieldlinesmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index c9ed83c96e..1d855b278a 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/fieldlines/rendering/renderablefieldlines.h b/modules/fieldlines/rendering/renderablefieldlines.h index 6ffbf0ed09..a6b28821b2 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.h +++ b/modules/fieldlines/rendering/renderablefieldlines.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/fieldlines/shaders/fieldline_fs.glsl b/modules/fieldlines/shaders/fieldline_fs.glsl index 1bbaf74cba..879b1cfbc7 100644 --- a/modules/fieldlines/shaders/fieldline_fs.glsl +++ b/modules/fieldlines/shaders/fieldline_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -69,4 +69,4 @@ Fragment getFragment() // float depth = pscDepth(gs_position); // ABufferStruct_t frag = createGeometryFragment(fragColor, gs_position, depth); // addToBuffer(frag); -// } \ No newline at end of file +// } diff --git a/modules/fieldlines/shaders/fieldline_gs.glsl b/modules/fieldlines/shaders/fieldline_gs.glsl index 32be0f108c..35845bcc4e 100644 --- a/modules/fieldlines/shaders/fieldline_gs.glsl +++ b/modules/fieldlines/shaders/fieldline_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -96,4 +96,4 @@ void main() { gs_normal = normals[2]; ABufferEmitVertex(prismoid[2]); EndPrimitive(); -} \ No newline at end of file +} diff --git a/modules/fieldlines/shaders/fieldline_vs.glsl b/modules/fieldlines/shaders/fieldline_vs.glsl index 9fcdcb5bcb..394a48c14b 100644 --- a/modules/fieldlines/shaders/fieldline_vs.glsl +++ b/modules/fieldlines/shaders/fieldline_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -37,4 +37,4 @@ out vec4 vs_color; void main() { vs_color = in_color; gl_Position = vec4(in_position, 0); -} \ No newline at end of file +} diff --git a/modules/galaxy/CMakeLists.txt b/modules/galaxy/CMakeLists.txt index afb55cfbb3..a70b4b03d6 100644 --- a/modules/galaxy/CMakeLists.txt +++ b/modules/galaxy/CMakeLists.txt @@ -1,40 +1,44 @@ -######################################################################################### -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/galaxymodule.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/galaxyraycaster.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablegalaxy.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablegalaxy.h + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/milkywayconversiontask.h + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/milkywaypointsconversiontask.h ) source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/galaxymodule.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/galaxyraycaster.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablegalaxy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablegalaxy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/milkywayconversiontask.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/milkywaypointsconversiontask.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/galaxy/galaxymodule.cpp b/modules/galaxy/galaxymodule.cpp index 193cf9f5bb..636055634c 100644 --- a/modules/galaxy/galaxymodule.cpp +++ b/modules/galaxy/galaxymodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,6 +27,8 @@ #include #include #include +#include +#include namespace openspace { @@ -36,6 +38,11 @@ void GalaxyModule::internalInitialize() { auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "No renderable factory existed"); fRenderable->registerClass("RenderableGalaxy"); + + auto fTask = FactoryManager::ref().factory(); + ghoul_assert(fRenderable, "No task factory existed"); + fTask->registerClass("MilkywayConversionTask"); + fTask->registerClass("MilkywayPointsConversionTask"); } } // namespace openspace diff --git a/modules/galaxy/galaxymodule.h b/modules/galaxy/galaxymodule.h index 0171435b68..6525a9a5a8 100644 --- a/modules/galaxy/galaxymodule.h +++ b/modules/galaxy/galaxymodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/galaxy/rendering/galaxyraycaster.cpp b/modules/galaxy/rendering/galaxyraycaster.cpp index 84b12f6be8..81be4f08b2 100644 --- a/modules/galaxy/rendering/galaxyraycaster.cpp +++ b/modules/galaxy/rendering/galaxyraycaster.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,8 +24,9 @@ #include -#include +#include #include + #include #include #include diff --git a/modules/galaxy/rendering/galaxyraycaster.h b/modules/galaxy/rendering/galaxyraycaster.h index fce9370fb5..dcd34063e6 100644 --- a/modules/galaxy/rendering/galaxyraycaster.h +++ b/modules/galaxy/rendering/galaxyraycaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -85,4 +85,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_GALAXY___GALAXYRAYCASTER___H__ +#endif // __OPENSPACE_MODULE_GALAXY___GALAXYRAYCASTER___H__ diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index cd891e87eb..812dc33619 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index fc104b36e4..77c5608a0a 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/galaxy/shaders/points.fs b/modules/galaxy/shaders/points.fs index 74548099fe..5ab9374fc8 100644 --- a/modules/galaxy/shaders/points.fs +++ b/modules/galaxy/shaders/points.fs @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/galaxy/shaders/points.vs b/modules/galaxy/shaders/points.vs index 2e1170fdcd..b4b3f5dfb3 100644 --- a/modules/galaxy/shaders/points.vs +++ b/modules/galaxy/shaders/points.vs @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/galaxy/shaders/raycasterbounds.fs b/modules/galaxy/shaders/raycasterbounds.fs index a335c00b51..76b85b859b 100644 --- a/modules/galaxy/shaders/raycasterbounds.fs +++ b/modules/galaxy/shaders/raycasterbounds.fs @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/galaxy/tasks/milkywayconversiontask.cpp b/modules/galaxy/tasks/milkywayconversiontask.cpp new file mode 100644 index 0000000000..9a32d4cce8 --- /dev/null +++ b/modules/galaxy/tasks/milkywayconversiontask.cpp @@ -0,0 +1,115 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace { + const char* KeyInFilenamePrefix = "InFilenamePrefix"; + const char* KeyInFilenameSuffix = "InFilenameSuffix"; + const char* KeyInFirstIndex = "InFirstIndex"; + const char* KeyInNSlices = "InNSlices"; + const char* KeyOutFilename = "OutFilename"; + const char* KeyOutDimensions = "OutDimensions"; +} // namespace + +namespace openspace { + +MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary) { + std::string inFilenamePrefix; + if (dictionary.getValue(KeyInFilenamePrefix, inFilenamePrefix)) { + _inFilenamePrefix = inFilenamePrefix; + } + + std::string inFilenameSuffix; + if (dictionary.getValue(KeyInFilenameSuffix, inFilenameSuffix)) { + _inFilenameSuffix = inFilenameSuffix; + } + + size_t inFirstIndex; + if (dictionary.getValue(KeyInFirstIndex, inFirstIndex)) { + _inFirstIndex = inFirstIndex; + } + + size_t inNSlices; + if (dictionary.getValue(KeyInNSlices, inNSlices)) { + _inNSlices = inNSlices; + } + + std::string outFilename; + if (dictionary.getValue(KeyOutFilename, outFilename)) { + _outFilename = outFilename; + } + + glm::ivec3 outDimensions; + if (dictionary.getValue(KeyOutDimensions, outDimensions)) { + _outDimensions = outDimensions; + } +} + +MilkywayConversionTask::~MilkywayConversionTask() {} + +std::string MilkywayConversionTask::description() +{ + return std::string(); +} + +void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallback) { + std::vector filenames; + for (int i = 0; i < _inNSlices; i++) { + filenames.push_back(_inFilenamePrefix + std::to_string(i + _inFirstIndex) + _inFilenameSuffix); + } + + TextureSliceVolumeReader> sliceReader(filenames, _inNSlices, 10); + sliceReader.initialize(); + + RawVolumeWriter> rawWriter(_outFilename); + rawWriter.setDimensions(_outDimensions); + + glm::vec3 resolutionRatio = + static_cast(sliceReader.dimensions()) / static_cast(rawWriter.dimensions()); + + VolumeSampler>> sampler(sliceReader, resolutionRatio); + std::function(glm::ivec3)> sampleFunction = [&](glm::ivec3 outCoord) { + glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5)) * resolutionRatio) - glm::vec3(0.5); + glm::tvec4 value = sampler.sample(inCoord); + return value; + }; + + rawWriter.write(sampleFunction, progressCallback); +} + +documentation::Documentation MilkywayConversionTask::documentation() +{ + return documentation::Documentation(); +} + +} diff --git a/modules/galaxy/tasks/milkywayconversiontask.h b/modules/galaxy/tasks/milkywayconversiontask.h new file mode 100644 index 0000000000..4e00b9c975 --- /dev/null +++ b/modules/galaxy/tasks/milkywayconversiontask.h @@ -0,0 +1,63 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GALAXY___MILKYWAYCONVERSIONTASK___H__ +#define __OPENSPACE_MODULE_GALAXY___MILKYWAYCONVERSIONTASK___H__ + +#include +#include +#include +#include +#include +#include + + +namespace openspace { + +namespace documentation { struct Documentation; } + +/** + * Converts a set of exr image slices to a raw volume + * with floating point RGBA data (32 bit per channel). + */ +class MilkywayConversionTask : public Task { +public: + MilkywayConversionTask(const ghoul::Dictionary& dictionary); + virtual ~MilkywayConversionTask(); + std::string description() override; + void perform(const Task::ProgressCallback& onProgress) override; + static documentation::Documentation documentation(); + +private: + std::string _inFilenamePrefix; + std::string _inFilenameSuffix; + size_t _inFirstIndex; + size_t _inNSlices; + std::string _outFilename; + glm::ivec3 _outDimensions; +}; + +} + +#endif // __OPENSPACE_MODULE_GALAXY___MILKYWAYCONVERSIONTASK___H__ diff --git a/modules/galaxy/tasks/milkywaypointsconversiontask.cpp b/modules/galaxy/tasks/milkywaypointsconversiontask.cpp new file mode 100644 index 0000000000..0df1bcdb1f --- /dev/null +++ b/modules/galaxy/tasks/milkywaypointsconversiontask.cpp @@ -0,0 +1,97 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { + +/*MilkywayPointsConversionTask::MilkywayPointsConversionTask( + const std::string& inFilename, + const std::string& outFilename) + : _inFilename(inFilename) + , _outFilename(outFilename) {}*/ + +MilkywayPointsConversionTask::MilkywayPointsConversionTask(const ghoul::Dictionary & dictionary) {} + +MilkywayPointsConversionTask::~MilkywayPointsConversionTask() {} + +std::string MilkywayPointsConversionTask::description() +{ + return std::string(); +} + +void MilkywayPointsConversionTask::perform(const Task::ProgressCallback & progressCallback) { + std::ifstream in(_inFilename, std::ios::in); + std::ofstream out(_outFilename, std::ios::out | std::ios::binary); + + std::string format; + int64_t nPoints; + in >> format >> nPoints; + + size_t nFloats = nPoints * 7; + + std::vector pointData(nFloats); + + float x, y, z, r, g, b, a; + for (size_t i = 0; i < nPoints; ++i) { + in >> x >> y >> z >> r >> g >> b >> a; + if (in.good()) { + pointData[i * 7 + 0] = x; + pointData[i * 7 + 1] = y; + pointData[i * 7 + 2] = z; + pointData[i * 7 + 3] = r; + pointData[i * 7 + 4] = g; + pointData[i * 7 + 5] = b; + pointData[i * 7 + 6] = a; + progressCallback(static_cast(i + 1) / nPoints); + } + else { + std::cout << "Failed to convert point data."; + return; + } + } + + out.write(reinterpret_cast(&nPoints), sizeof(int64_t)); + out.write(reinterpret_cast(pointData.data()), nFloats * sizeof(float)); + + in.close(); + out.close(); +} + +documentation::Documentation MilkywayPointsConversionTask::documentation() +{ + return documentation::Documentation(); +} + +} diff --git a/modules/galaxy/tasks/milkywaypointsconversiontask.h b/modules/galaxy/tasks/milkywaypointsconversiontask.h new file mode 100644 index 0000000000..d20eb4bcef --- /dev/null +++ b/modules/galaxy/tasks/milkywaypointsconversiontask.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GALAXY___MILKYWAYPOINTSCONVERSIONTASK_H__ +#define __OPENSPACE_MODULE_GALAXY___MILKYWAYPOINTSCONVERSIONTASK_H__ + +#include +#include +#include +#include +#include +#include + + +namespace openspace { + +namespace documentation { struct Documentation; } + +/** + * Converts ascii based point data + * int64_t n + * (float x, float y, float z, float r, float g, float b) * n + * to a binary (floating point) representation with the same layout. + */ +class MilkywayPointsConversionTask : public Task { +public: + MilkywayPointsConversionTask(const ghoul::Dictionary& dictionary); + virtual ~MilkywayPointsConversionTask(); + std::string description() override; + void perform(const Task::ProgressCallback& progressCallback) override; + static documentation::Documentation documentation(); + +private: + std::string _inFilename; + std::string _outFilename; +}; + +} + +#endif // __OPENSPACE_MODULE_GALAXY___MILKYWAYPOINTSCONVERSIONTASK_H__ diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index d5859f8bed..08ab6695c5 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -1,41 +1,47 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunk.h - ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator.h ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunknode.h - ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/chunklevelevaluator.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/availabletiledataevaluator.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/distanceevaluator.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/projectedareaevaluator.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling/chunkculler.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling/frustumculler.h + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling/horizonculler.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/aabb.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/angle.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/angle.inl - ${CMAKE_CURRENT_SOURCE_DIR}/geometry/convexhull.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/ellipsoid.h ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodetic2.h + ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodetic3.h + ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodeticpatch.h ${CMAKE_CURRENT_SOURCE_DIR}/globes/chunkedlodglobe.h ${CMAKE_CURRENT_SOURCE_DIR}/globes/pointglobe.h @@ -58,24 +64,45 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layermanager.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layershadermanager.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpuchunktile.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpuchunktilepile.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpuheightlayer.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayer.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayergroup.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayermanager.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayerrendersettings.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gputiledepthtransform.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gputileuvtransform.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layer.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layergroup.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layermanager.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layerrendersettings.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/chunktile.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/rawtile.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/textureformat.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tile.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledatalayout.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledataset.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledatatype.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledepthtransform.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tilediskcache.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileindex.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tilemetadata.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileselector.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileuvtransform.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/diskcachedtileloadjob.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/loadjob.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/tileloadjob.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/cachingtileprovider.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/singleimageprovider.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/sizereferencetileprovider.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/temporaltileprovider.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/texttileprovider.h + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileindextileprovider.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileprovider.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileproviderbyindex.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileproviderbylevel.h @@ -83,14 +110,19 @@ set(HEADER_FILES set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunk.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunknode.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/availabletiledataevaluator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/distanceevaluator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator/projectedareaevaluator.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling/frustumculler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling/horizonculler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/geometry/aabb.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/geometry/convexhull.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geometry/ellipsoid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodetic2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/geometry/geodeticpatch.cpp ${CMAKE_CURRENT_SOURCE_DIR}/globes/chunkedlodglobe.cpp ${CMAKE_CURRENT_SOURCE_DIR}/globes/pointglobe.cpp @@ -106,22 +138,40 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layershadermanager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layermanager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpuchunktile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpuchunktilepile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpuheightlayer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayergroup.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayermanager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gpulayerrendersettings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gputiledepthtransform.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpu/gputileuvtransform.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layergroup.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layermanager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/layer/layerrendersettings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/rawtile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledatalayout.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledataset.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledatatype.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tilediskcache.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileindex.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tilemetadata.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileselector.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/diskcachedtileloadjob.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/tileloadjob.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/cachingtileprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/singleimageprovider.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/sizereferencetileprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/temporaltileprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/texttileprovider.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileindextileprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileproviderbyindex.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/tileproviderbylevel.cpp diff --git a/modules/globebrowsing/chunk/chunk.cpp b/modules/globebrowsing/chunk/chunk.cpp index a70509c48c..54284da290 100644 --- a/modules/globebrowsing/chunk/chunk.cpp +++ b/modules/globebrowsing/chunk/chunk.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,8 +26,9 @@ #include #include -#include +#include #include +#include namespace openspace { namespace globebrowsing { @@ -58,34 +59,34 @@ bool Chunk::isVisible() const { } Chunk::Status Chunk::update(const RenderData& data) { - auto savedCamera = _owner.savedCamera(); + const auto& savedCamera = _owner.savedCamera(); const Camera& camRef = savedCamera != nullptr ? *savedCamera : data.camera; RenderData myRenderData = { camRef, data.position, data.doPerformanceMeasurement }; _isVisible = true; if (_owner.chunkedLodGlobe()->testIfCullable(*this, myRenderData)) { _isVisible = false; - return Status::WANT_MERGE; + return Status::WantMerge; } int desiredLevel = _owner.chunkedLodGlobe()->getDesiredLevel(*this, myRenderData); if (desiredLevel < _tileIndex.level) { - return Status::WANT_MERGE; + return Status::WantMerge; } else if (_tileIndex.level < desiredLevel) { - return Status::WANT_SPLIT; + return Status::WantSplit; } else { - return Status::DO_NOTHING; + return Status::DoNothing; } } Chunk::BoundingHeights Chunk::getBoundingHeights() const { - BoundingHeights boundingHeights; - boundingHeights.max = 0; - boundingHeights.min = 0; - boundingHeights.available = false; + BoundingHeights boundingHeights { + 0.f, 0.f, + false + }; // In the future, this should be abstracted away and more easily queryable. // One must also handle how to sample pick one out of multiplte heightmaps @@ -94,48 +95,48 @@ Chunk::BoundingHeights Chunk::getBoundingHeights() const { // The raster of a height map is the first one. We assume that the height map is // a single raster image. If it is not we will just use the first raster // (that is channel 0). - size_t HEIGHT_CHANNEL = 0; + const size_t HeightChannel = 0; const LayerGroup& heightmaps = layerManager->layerGroup(LayerManager::HeightLayers); - std::vector chunkTiles = TileSelector::getTilesSortedByHighestResolution( + std::vector chunkTiles = tileselector::getTilesSortedByHighestResolution( heightmaps, _tileIndex ); bool lastHadMissingData = true; - for (auto chunkTile : chunkTiles) { - bool goodTile = chunkTile.tile.status == Tile::Status::OK; - bool hastileMetaData = chunkTile.tile.metaData != nullptr; + for (const auto& chunkTile : chunkTiles) { + bool goodTile = (chunkTile.tile.status == Tile::Status::OK); + bool hasTileMetaData = (chunkTile.tile.metaData != nullptr); - if (goodTile && hastileMetaData) { + if (goodTile && hasTileMetaData) { auto tileMetaData = chunkTile.tile.metaData; if (!boundingHeights.available) { - if (tileMetaData->hasMissingData[HEIGHT_CHANNEL]) { + if (tileMetaData->hasMissingData[HeightChannel]) { boundingHeights.min = std::min( DEFAULT_HEIGHT, - tileMetaData->minValues[HEIGHT_CHANNEL] + tileMetaData->minValues[HeightChannel] ); boundingHeights.max = std::max( DEFAULT_HEIGHT, - tileMetaData->maxValues[HEIGHT_CHANNEL] + tileMetaData->maxValues[HeightChannel] ); } else { - boundingHeights.min = tileMetaData->minValues[HEIGHT_CHANNEL]; - boundingHeights.max = tileMetaData->maxValues[HEIGHT_CHANNEL]; + boundingHeights.min = tileMetaData->minValues[HeightChannel]; + boundingHeights.max = tileMetaData->maxValues[HeightChannel]; } boundingHeights.available = true; } else { boundingHeights.min = std::min( boundingHeights.min, - tileMetaData->minValues[HEIGHT_CHANNEL] + tileMetaData->minValues[HeightChannel] ); boundingHeights.max = std::max( boundingHeights.max, - tileMetaData->maxValues[HEIGHT_CHANNEL] + tileMetaData->maxValues[HeightChannel] ); } - lastHadMissingData = tileMetaData->hasMissingData[HEIGHT_CHANNEL]; + lastHadMissingData = tileMetaData->hasMissingData[HeightChannel]; } // Allow for early termination @@ -192,7 +193,7 @@ std::vector Chunk::getBoundingPolyhedronCorners() const { double latDiff = latCloseToEquator - pGeodetic.lat; for (size_t i = 0; i < 8; ++i) { - Quad q = (Quad)(i % 4); + Quad q = static_cast(i % 4); double cornerHeight = i < 4 ? minCornerHeight : maxCornerHeight; Geodetic3 cornerGeodetic = { patch.getCorner(q), cornerHeight }; @@ -204,6 +205,7 @@ std::vector Chunk::getBoundingPolyhedronCorners() const { corners[i] = glm::dvec4(ellipsoid.cartesianPosition(cornerGeodetic), 1); } + return corners; } diff --git a/modules/globebrowsing/chunk/chunk.h b/modules/globebrowsing/chunk/chunk.h index d32955adf7..c235fa4525 100644 --- a/modules/globebrowsing/chunk/chunk.h +++ b/modules/globebrowsing/chunk/chunk.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,10 +25,11 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___CHUNK___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___CHUNK___H__ -#include +#include #include -#include +#include + #include namespace openspace { @@ -37,7 +38,6 @@ struct RenderData; namespace globebrowsing { -class GeodeticPatch; class RenderableGlobe; struct TileIndex; @@ -51,9 +51,9 @@ public: }; enum class Status { - DO_NOTHING, - WANT_MERGE, - WANT_SPLIT, + DoNothing, + WantMerge, + WantSplit, }; Chunk(const RenderableGlobe& owner, const TileIndex& tileIndex, @@ -73,8 +73,8 @@ public: Status update(const RenderData& data); /** - * Returns a convex polyhedron of eight vertices tightly bounding the volume of - * the Chunk. + * Returns a convex polyhedron of eight vertices tightly bounding the volume of + * the Chunk. */ std::vector getBoundingPolyhedronCorners() const; @@ -84,13 +84,13 @@ public: bool isVisible() const; /** - * Returns BoundingHeights that fits the Chunk as tightly as possible. - * - * If the Chunk uses more than one HightLayer, the BoundingHeights will be set - * to cover all HightLayers. If the Chunk has a higher level than its highest - * resolution HightLayer Tile, it will base its BoundingHeights on that Tile. - * This means that high level Chunks can have BoundingHeights that are not - * tightly fitting. + * Returns BoundingHeights that fits the Chunk as tightly as possible. + * + * If the Chunk uses more than one HightLayer, the BoundingHeights will be set + * to cover all HeightLayers. If the Chunk has a higher level than its highest + * resolution HightLayer Tile, it will base its BoundingHeights on that Tile. + * This means that high level Chunks can have BoundingHeights that are not + * tightly fitting. */ BoundingHeights getBoundingHeights() const; diff --git a/modules/globebrowsing/chunk/chunklevelevaluator/availabletiledataevaluator.cpp b/modules/globebrowsing/chunk/chunklevelevaluator/availabletiledataevaluator.cpp new file mode 100644 index 0000000000..835f61a5cd --- /dev/null +++ b/modules/globebrowsing/chunk/chunklevelevaluator/availabletiledataevaluator.cpp @@ -0,0 +1,57 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { +namespace chunklevelevaluator { + +int AvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData& data) const { + auto layerManager = chunk.owner().chunkedLodGlobe()->layerManager(); + // auto layers = layerManager->layerGroup(LayerManager::HeightLayers).activeLayers(); + int currLevel = chunk.tileIndex().level; + + for (size_t i = 0; i < LayerManager::NUM_LAYER_GROUPS; ++i) { + for (const auto& layer : layerManager->layerGroup(i).activeLayers()) { + Tile::Status status = layer->tileProvider()->getTileStatus(chunk.tileIndex()); + if (status == Tile::Status::OK) { + return UnknownDesiredLevel; + } + } + } + + return currLevel - 1; +} + +} // namespace chunklevelevaluator +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/chunk/chunklevelevaluator/availabletiledataevaluator.h b/modules/globebrowsing/chunk/chunklevelevaluator/availabletiledataevaluator.h new file mode 100644 index 0000000000..f3d144997c --- /dev/null +++ b/modules/globebrowsing/chunk/chunklevelevaluator/availabletiledataevaluator.h @@ -0,0 +1,48 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___AVAILABLETILEDATAEVALUATOR___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___AVAILABLETILEDATAEVALUATOR___H__ + +#include + +namespace openspace { +namespace globebrowsing { +namespace chunklevelevaluator { + +/** + * If this chunk has available tile data for any LayerGroup on any of its active + * Layers it will return an UNKNOWN_DESIRED_LEVEL. If no data is available it will + * evaluate to a level that is current level -1. +*/ +class AvailableTileData : public Evaluator { +public: + int getDesiredLevel(const Chunk& chunk, const RenderData& data) const override; +}; + +} // namespace chunklevelevaluator +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___AVAILABLETILEDATAEVALUATOR___H__ diff --git a/modules/globebrowsing/chunk/chunklevelevaluator/chunklevelevaluator.h b/modules/globebrowsing/chunk/chunklevelevaluator/chunklevelevaluator.h new file mode 100644 index 0000000000..40c511d2aa --- /dev/null +++ b/modules/globebrowsing/chunk/chunklevelevaluator/chunklevelevaluator.h @@ -0,0 +1,54 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKLEVELEVALUATOR___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKLEVELEVALUATOR___H__ + +namespace openspace { + +struct RenderData; + +namespace globebrowsing { + +class Chunk; + +namespace chunklevelevaluator { + +/** + * Abstract class defining an interface for accessing a desired level of a Chunk. + * The desired level can be used in the process of determining whether a Chunk should + * want to split, merge or do nothing. +*/ +class Evaluator { +public: + static const int UnknownDesiredLevel = -1; + + virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const = 0; +}; + +} // namespace chunklevelevaluator +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKLEVELEVALUATOR___H__ diff --git a/modules/globebrowsing/chunk/chunklevelevaluator/distanceevaluator.cpp b/modules/globebrowsing/chunk/chunklevelevaluator/distanceevaluator.cpp new file mode 100644 index 0000000000..d1cc671b49 --- /dev/null +++ b/modules/globebrowsing/chunk/chunklevelevaluator/distanceevaluator.cpp @@ -0,0 +1,75 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { +namespace chunklevelevaluator { + +int Distance::getDesiredLevel(const Chunk& chunk, const RenderData& data) const { + // Calculations are done in the reference frame of the globe + // (model space). Hence, the camera position needs to be transformed + // with the inverse model matrix + glm::dmat4 inverseModelTransform = chunk.owner().inverseModelTransform(); + const RenderableGlobe& globe = chunk.owner(); + const Ellipsoid& ellipsoid = globe.ellipsoid(); + + glm::dvec3 cameraPosition = + glm::dvec3(inverseModelTransform * glm::dvec4(data.camera.positionVec3(), 1)); + + Geodetic2 pointOnPatch = chunk.surfacePatch().closestPoint( + ellipsoid.cartesianToGeodetic2(cameraPosition) + ); + glm::dvec3 patchNormal = ellipsoid.geodeticSurfaceNormal(pointOnPatch); + glm::dvec3 patchPosition = ellipsoid.cartesianSurfacePosition(pointOnPatch); + + Chunk::BoundingHeights heights = chunk.getBoundingHeights(); + double heightToChunk = heights.min; + + // Offset position according to height + patchPosition += patchNormal * heightToChunk; + + glm::dvec3 cameraToChunk = patchPosition - cameraPosition; + + // Calculate desired level based on distance + double distanceToPatch = glm::length(cameraToChunk); + double distance = distanceToPatch; + + double scaleFactor = + globe.generalProperties().lodScaleFactor * ellipsoid.minimumRadius(); + double projectedScaleFactor = scaleFactor / distance; + int desiredLevel = ceil(log2(projectedScaleFactor)); + return desiredLevel; +} + +} // namespace chunklevelevaluator +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/chunk/chunklevelevaluator/distanceevaluator.h b/modules/globebrowsing/chunk/chunklevelevaluator/distanceevaluator.h new file mode 100644 index 0000000000..ead3ba050d --- /dev/null +++ b/modules/globebrowsing/chunk/chunklevelevaluator/distanceevaluator.h @@ -0,0 +1,48 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___DISTANCEEVALUATOR___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___DISTANCEEVALUATOR___H__ + +#include + +namespace openspace { +namespace globebrowsing { +namespace chunklevelevaluator { + +/** + * Evaluate the Chunk level depending on the distance from the Camera to the Chunk. + * This evaluation method aims to keep the screen size (horizontal length and not + * area) of all chunks constant. +*/ +class Distance : public Evaluator { +public: + int getDesiredLevel(const Chunk& chunk, const RenderData& data) const override; +}; + +} // namespace chunklevelevaluator +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___DISTANCEEVALUATOR___H__ diff --git a/modules/globebrowsing/chunk/chunklevelevaluator.cpp b/modules/globebrowsing/chunk/chunklevelevaluator/projectedareaevaluator.cpp similarity index 67% rename from modules/globebrowsing/chunk/chunklevelevaluator.cpp rename to modules/globebrowsing/chunk/chunklevelevaluator/projectedareaevaluator.cpp index b536df2dfa..a92a9c62e8 100644 --- a/modules/globebrowsing/chunk/chunklevelevaluator.cpp +++ b/modules/globebrowsing/chunk/chunklevelevaluator/projectedareaevaluator.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,58 +22,19 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include #include -#include +#include #include namespace openspace { namespace globebrowsing { +namespace chunklevelevaluator { -int EvaluateChunkLevelByDistance::getDesiredLevel(const Chunk& chunk, - const RenderData& data) const -{ - // Calculations are done in the reference frame of the globe - // (model space). Hence, the camera position needs to be transformed - // with the inverse model matrix - glm::dmat4 inverseModelTransform = chunk.owner().inverseModelTransform(); - const RenderableGlobe& globe = chunk.owner(); - const Ellipsoid& ellipsoid = globe.ellipsoid(); - - glm::dvec3 cameraPosition = - glm::dvec3(inverseModelTransform * glm::dvec4(data.camera.positionVec3(), 1)); - - Geodetic2 pointOnPatch = chunk.surfacePatch().closestPoint( - ellipsoid.cartesianToGeodetic2(cameraPosition) - ); - glm::dvec3 patchNormal = ellipsoid.geodeticSurfaceNormal(pointOnPatch); - glm::dvec3 patchPosition = ellipsoid.cartesianSurfacePosition(pointOnPatch); - - Chunk::BoundingHeights heights = chunk.getBoundingHeights(); - double heightToChunk = heights.min; - - // Offset position according to height - patchPosition += patchNormal * heightToChunk; - - glm::dvec3 cameraToChunk = patchPosition - cameraPosition; - - // Calculate desired level based on distance - double distanceToPatch = glm::length(cameraToChunk); - double distance = distanceToPatch; - - double scaleFactor = - globe.generalProperties().lodScaleFactor * ellipsoid.minimumRadius(); - double projectedScaleFactor = scaleFactor / distance; - int desiredLevel = ceil(log2(projectedScaleFactor)); - return desiredLevel; -} - -int EvaluateChunkLevelByProjectedArea::getDesiredLevel(const Chunk& chunk, - const RenderData& data) const -{ +int ProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) const { // Calculations are done in the reference frame of the globe // (model space). Hence, the camera position needs to be transformed // with the inverse model matrix @@ -163,25 +124,6 @@ int EvaluateChunkLevelByProjectedArea::getDesiredLevel(const Chunk& chunk, return chunk.tileIndex().level + round(scaledArea - 1); } -int EvaluateChunkLevelByAvailableTileData::getDesiredLevel(const Chunk& chunk, - const RenderData& data) const -{ - auto layerManager = chunk.owner().chunkedLodGlobe()->layerManager(); - auto heightLayers = layerManager->layerGroup(LayerManager::HeightLayers).activeLayers(); - int currLevel = chunk.tileIndex().level; - - for (size_t i = 0; i < LayerManager::NUM_LAYER_GROUPS; ++i) { - for (auto& layer : layerManager->layerGroup(i).activeLayers()) { - Tile::Status tileStatus = - layer->tileProvider()->getTileStatus(chunk.tileIndex()); - if (tileStatus == Tile::Status::OK) { - return UNKNOWN_DESIRED_LEVEL; - } - } - } - - return currLevel - 1; -} - +} // namespace chunklevelevaluator } // namespace globebrowsing } // namespace openspace diff --git a/src/interaction/luaconsole_lua.inl b/modules/globebrowsing/chunk/chunklevelevaluator/projectedareaevaluator.h similarity index 67% rename from src/interaction/luaconsole_lua.inl rename to modules/globebrowsing/chunk/chunklevelevaluator/projectedareaevaluator.h index 97d6ec0b51..0bd0bee3f1 100644 --- a/src/interaction/luaconsole_lua.inl +++ b/modules/globebrowsing/chunk/chunklevelevaluator/projectedareaevaluator.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,52 +22,30 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___PROJECTEDAREAEVALUATOR___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___PROJECTEDAREAEVALUATOR___H__ + +#include + namespace openspace { - -namespace luascriptfunctions { - +namespace globebrowsing { +namespace chunklevelevaluator { + /** - * \ingroup LuaScripts - * show(): - * Shows the console - */ -int show(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + * Evaluate the chunk level using the area of the non-heightmapped Chunk projected + * on a sphere with the center in the position of the camera. A Chunk near the + * horizon will have a small projected area and hence a lower desired level. This + * evaluation is more forgiving than EvaluateChunkLevelByDistance, meaning it results + * in lower desired levels. +*/ +class ProjectedArea : public Evaluator { +public: + virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const; +}; - OsEng.console().setVisible(true); - return 0; -} - -/** - * \ingroup LuaScripts - * hide(): - * Hides the console - */ -int hide(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - - OsEng.console().setVisible(false); - return 0; -} - -/** - * \ingroup LuaScripts - * toggle(): - * Toggles the console - */ -int toggle(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - - OsEng.console().toggleMode(); - return 0; -} - -} // namespace luascriptfunctions +} // namespace chunklevelevaluator +} // namespace globebrowsing } // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PROJECTEDAREAEVALUATOR___H__ diff --git a/modules/globebrowsing/chunk/chunknode.cpp b/modules/globebrowsing/chunk/chunknode.cpp index 9d67ebcbe8..408fd613a9 100644 --- a/modules/globebrowsing/chunk/chunknode.cpp +++ b/modules/globebrowsing/chunk/chunknode.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,19 +32,11 @@ namespace openspace { namespace globebrowsing { -int ChunkNode::chunkNodeCount = 0; - ChunkNode::ChunkNode(const Chunk& chunk, ChunkNode* parent) : _chunk(chunk) , _parent(parent) , _children({ nullptr, nullptr, nullptr, nullptr }) -{ - chunkNodeCount++; -} - -ChunkNode::~ChunkNode() { - chunkNodeCount--; -} +{} bool ChunkNode::isRoot() const { return _parent == nullptr; @@ -57,10 +49,10 @@ bool ChunkNode::isLeaf() const { bool ChunkNode::updateChunkTree(const RenderData& data) { if (isLeaf()) { Chunk::Status status = _chunk.update(data); - if (status == Chunk::Status::WANT_SPLIT) { + if (status == Chunk::Status::WantSplit) { split(); } - return status == Chunk::Status::WANT_MERGE; + return status == Chunk::Status::WantMerge; } else { char requestedMergeMask = 0; @@ -71,7 +63,7 @@ bool ChunkNode::updateChunkTree(const RenderData& data) { } bool allChildrenWantsMerge = requestedMergeMask == 0xf; - bool thisChunkWantsSplit = _chunk.update(data) == Chunk::Status::WANT_SPLIT; + bool thisChunkWantsSplit = _chunk.update(data) == Chunk::Status::WantSplit; if (allChildrenWantsMerge && !thisChunkWantsSplit) { merge(); @@ -166,7 +158,7 @@ const ChunkNode& ChunkNode::getChild(Quad quad) const { void ChunkNode::split(int depth) { if (depth > 0 && isLeaf()) { - for (size_t i = 0; i < _children.size(); i++) { + for (size_t i = 0; i < _children.size(); ++i) { Chunk chunk(_chunk.owner(), _chunk.tileIndex().child((Quad)i)); _children[i] = std::make_unique(chunk, this); } diff --git a/modules/globebrowsing/chunk/chunknode.h b/modules/globebrowsing/chunk/chunknode.h index 8f4d59f023..09ff70d302 100644 --- a/modules/globebrowsing/chunk/chunknode.h +++ b/modules/globebrowsing/chunk/chunknode.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -39,19 +39,18 @@ class ChunkedLodGlobe; class ChunkNode { public: ChunkNode(const Chunk& chunk, ChunkNode* parent = nullptr); - ~ChunkNode(); /** * Recursively split the ChunkNode. * * \param depth defines how deep the recursion should go. If depth == 1 (default), * the ChunkNode will only split once. - */ + */ void split(int depth = 1); /** * Deletes all children of the ChunkNode recursively. - */ + */ void merge(); bool isRoot() const; @@ -74,9 +73,7 @@ public: */ bool updateChunkTree(const RenderData& data); - static int chunkNodeCount; - -private: +private: ChunkNode* _parent; std::array, 4> _children; diff --git a/modules/globebrowsing/chunk/culling/chunkculler.h b/modules/globebrowsing/chunk/culling/chunkculler.h new file mode 100644 index 0000000000..0321544d01 --- /dev/null +++ b/modules/globebrowsing/chunk/culling/chunkculler.h @@ -0,0 +1,52 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKCULLER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKCULLER___H__ + +namespace openspace { + +struct RenderData; + +namespace globebrowsing { + +class Chunk; + +namespace culling { + +class ChunkCuller { +public: + /** + * Determine if the Chunk is cullable. That is return true if removing the + * Chunk 'culling it' will not have any result on the final rendering. Culling + * it will make the rendering faster. + */ + virtual bool isCullable(const Chunk& chunk, const RenderData& renderData) = 0; +}; + +} // namespace culling +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKCULLER___H__ diff --git a/modules/volume/rendering/renderablevolumegl.h b/modules/globebrowsing/chunk/culling/frustumculler.cpp similarity index 60% rename from modules/volume/rendering/renderablevolumegl.h rename to modules/globebrowsing/chunk/culling/frustumculler.cpp index c3d484edad..03410a4dd0 100644 --- a/modules/volume/rendering/renderablevolumegl.h +++ b/modules/globebrowsing/chunk/culling/frustumculler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,65 +22,42 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __RENDERABLEVOLUMEGL_H__ -#define __RENDERABLEVOLUMEGL_H__ +#include -#include -#include - -// Forward declare to minimize dependencies -namespace ghoul { - namespace filesystem { - class File; - } - namespace opengl { - class ProgramObject; - class Texture; - } -} +#include +#include namespace openspace { +namespace globebrowsing { +namespace culling { -class RenderableVolumeGL: public RenderableVolume { -public: - RenderableVolumeGL(const ghoul::Dictionary& dictionary); - ~RenderableVolumeGL(); - - bool initialize() override; - bool deinitialize() override; +FrustumCuller::FrustumCuller(AABB3 viewFrustum) + : _viewFrustum(std::move(viewFrustum)) +{} - bool isReady() const override; +bool FrustumCuller::isCullable(const Chunk& chunk, const RenderData& data) { + // Calculate the MVP matrix + glm::dmat4 modelTransform = chunk.owner().modelTransform(); + glm::dmat4 viewTransform = glm::dmat4(data.camera.combinedViewMatrix()); + glm::dmat4 modelViewProjectionTransform = glm::dmat4(data.camera.projectionMatrix()) + * viewTransform * modelTransform; - virtual void render(const RenderData& data) override; - virtual void update(const UpdateData& data) override; + const std::vector& corners = chunk.getBoundingPolyhedronCorners(); + + // Create a bounding box that fits the patch corners + AABB3 bounds; // in screen space + std::vector clippingSpaceCorners(8); + for (size_t i = 0; i < 8; ++i) { + glm::dvec4 cornerClippingSpace = modelViewProjectionTransform * corners[i]; + clippingSpaceCorners[i] = cornerClippingSpace; -private: - ghoul::Dictionary _hintsDictionary; - - std::string _filename; - - std::string _transferFunctionName; - std::string _volumeName; - - std::string _transferFunctionPath; - std::string _samplerFilename; - - ghoul::filesystem::File* _transferFunctionFile; - - ghoul::opengl::Texture* _volume; - ghoul::opengl::Texture* _transferFunction; - - GLuint _boxArray; - GLuint _vertexPositionBuffer; - ghoul::opengl::ProgramObject* _boxProgram; - glm::vec3 _boxScaling; - psc _pscOffset; - float _w; - - bool _updateTransferfunction; - int _id; -}; + glm::dvec3 ndc = (1.0f / glm::abs(cornerClippingSpace.w)) * cornerClippingSpace; + bounds.expand(ndc); + } + + return !(_viewFrustum.intersects(bounds)); +} +} // namespace culling +} // namespace globebrowsing } // namespace openspace - -#endif diff --git a/modules/globebrowsing/chunk/culling/frustumculler.h b/modules/globebrowsing/chunk/culling/frustumculler.h new file mode 100644 index 0000000000..6f86d073cd --- /dev/null +++ b/modules/globebrowsing/chunk/culling/frustumculler.h @@ -0,0 +1,62 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___FRUSTUMCULLER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___FRUSTUMCULLER___H__ + +#include + +#include + +namespace openspace { +namespace globebrowsing { +namespace culling { + +/** + * Culls all chunks that are completely outside the view frustum. + * + * The frustum culling uses a 2D axis aligned bounding box for the Chunk in + * screen space. This is calculated from a bounding polyhedron bounding the + * Chunk. Hence the culling will not be 'perfect' but fast and good enough for + * culling chunks outside the frustum with some margin. + */ +class FrustumCuller : public ChunkCuller { +public: + /** + * \param viewFrustum is the view space in normalized device coordinates space. + * Hence it is an axis aligned bounding box and not a real frustum. + */ + FrustumCuller(AABB3 viewFrustum); + + bool isCullable(const Chunk& chunk, const RenderData& renderData) override; + +private: + const AABB3 _viewFrustum; +}; + +} // namespace culling +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___FRUSTUMCULLER___H__ diff --git a/modules/globebrowsing/chunk/culling.cpp b/modules/globebrowsing/chunk/culling/horizonculler.cpp similarity index 81% rename from modules/globebrowsing/chunk/culling.cpp rename to modules/globebrowsing/chunk/culling/horizonculler.cpp index cac47f264b..5e7e09b989 100644 --- a/modules/globebrowsing/chunk/culling.cpp +++ b/modules/globebrowsing/chunk/culling/horizonculler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,39 +22,14 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include namespace openspace { namespace globebrowsing { - -FrustumCuller::FrustumCuller(const AABB3 viewFrustum) : _viewFrustum(viewFrustum) {} - -bool FrustumCuller::isCullable(const Chunk& chunk, const RenderData& data) { - // Calculate the MVP matrix - glm::dmat4 modelTransform = chunk.owner().modelTransform(); - glm::dmat4 viewTransform = glm::dmat4(data.camera.combinedViewMatrix()); - glm::dmat4 modelViewProjectionTransform = glm::dmat4(data.camera.projectionMatrix()) - * viewTransform * modelTransform; - - const std::vector& corners = chunk.getBoundingPolyhedronCorners(); - - // Create a bounding box that fits the patch corners - AABB3 bounds; // in screen space - std::vector clippingSpaceCorners(8); - for (size_t i = 0; i < 8; i++) { - glm::dvec4 cornerClippingSpace = modelViewProjectionTransform * corners[i]; - clippingSpaceCorners[i] = cornerClippingSpace; - - glm::dvec3 cornerNDC = - (1.0f / glm::abs(cornerClippingSpace.w)) * cornerClippingSpace; - bounds.expand(cornerNDC); - } - - return !_viewFrustum.intersects(bounds); -} +namespace culling { bool HorizonCuller::isCullable(const Chunk& chunk, const RenderData& data) { // Calculations are done in the reference frame of the globe. Hence, the camera @@ -110,16 +85,20 @@ bool HorizonCuller::isCullable(const glm::dvec3& cameraPosition, double distanceToHorizon = sqrt(pow(length(cameraPosition - globePosition), 2) - pow(minimumGlobeRadius, 2)); + double minimumAllowedDistanceToObjectFromHorizon = sqrt( pow(length(objectPosition - globePosition), 2) - pow(minimumGlobeRadius - objectBoundingSphereRadius, 2)); + // Minimum allowed for the object to be occluded double minimumAllowedDistanceToObjectSquared = pow(distanceToHorizon + minimumAllowedDistanceToObjectFromHorizon, 2) + pow(objectBoundingSphereRadius, 2); + double distanceToObjectSquared = pow(length(objectPosition - cameraPosition), 2); return distanceToObjectSquared > minimumAllowedDistanceToObjectSquared; } +} // namespace culling } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/chunk/culling.h b/modules/globebrowsing/chunk/culling/horizonculler.h similarity index 66% rename from modules/globebrowsing/chunk/culling.h rename to modules/globebrowsing/chunk/culling/horizonculler.h index 36105980ef..8ee695ab7d 100644 --- a/modules/globebrowsing/chunk/culling.h +++ b/modules/globebrowsing/chunk/culling/horizonculler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,50 +22,16 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___CULLING___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___CULLING___H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___HORIZONCULLER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___HORIZONCULLER___H__ -#include +#include + +#include namespace openspace { - -struct RenderData; - namespace globebrowsing { - -class Chunk; - -class ChunkCuller { -public: - /** - * Determine if the Chunk is cullable. That is return true if removing the - * Chunk 'culling it' will not have any result on the final rendering. Culling - * it will make the rendering faster. - */ - virtual bool isCullable(const Chunk& chunk, const RenderData& renderData) = 0; -}; - - /** - * Culls all chunks that are completely outside the view frustum. - * - * The frustum culling uses a 2D axis aligned bounding box for the Chunk in - * screen space. This is calculated from a bounding polyhedron bounding the - * Chunk. Hence the culling will not be 'perfect' but fast and good enough for - * culling chunks outside the frustum with some margin. - */ -class FrustumCuller : public ChunkCuller { -public: - /** - * \param viewFrustum is the view space in normalized device coordinates space. - * Hence it is an axis aligned bounding box and not a real frustum. - */ - FrustumCuller(const AABB3 viewFrustum); - - bool isCullable(const Chunk& chunk, const RenderData& renderData) override; - -private: - const AABB3 _viewFrustum; -}; +namespace culling { /** * In this implementation of the horizon culling, the closer the ellipsoid is to a @@ -77,12 +43,14 @@ class HorizonCuller : public ChunkCuller { public: bool isCullable(const Chunk& chunk, const RenderData& renderData) override; +private: bool isCullable(const glm::dvec3& cameraPosition, const glm::dvec3& globePosition, const glm::dvec3& objectPosition, double objectBoundingSphereRadius, double minimumGlobeRadius); }; +} // namespace culling } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CULLING___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___HORIZONCULLER___H__ diff --git a/modules/globebrowsing/geometry/aabb.cpp b/modules/globebrowsing/geometry/aabb.cpp index 0eab00c376..d9e47cc691 100644 --- a/modules/globebrowsing/geometry/aabb.cpp +++ b/modules/globebrowsing/geometry/aabb.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -63,17 +63,17 @@ bool AABB1::intersects(const AABB1& o) const { return (min <= o.max) && (o.min <= max); } -AABBSpatialRelation AABB1::relationTo(const AABB1& o) const { +AABB1::AABBSpatialRelation AABB1::relationTo(const AABB1& o) const { if (intersects(o)) { if (contains(o)) { - return AABBSpatialRelation::Containing; + return AABB1::AABBSpatialRelation::Containing; } if (o.contains(*this)) { - return AABBSpatialRelation::Contained; + return AABB1::AABBSpatialRelation::Contained; } - return AABBSpatialRelation::Intersecting; + return AABB1::AABBSpatialRelation::Intersecting; } - return AABBSpatialRelation::None; + return AABB1::AABBSpatialRelation::None; } AABB2::AABB2() @@ -83,9 +83,9 @@ AABB2::AABB2() ) {} -AABB2::AABB2(const glm::vec2& min, const glm::vec2& max) - : min(min) - , max(max) +AABB2::AABB2(glm::vec2 min, glm::vec2 max) + : min(std::move(min)) + , max(std::move(max)) {} void AABB2::expand(const glm::vec2& p) { @@ -116,17 +116,17 @@ bool AABB2::intersects(const AABB2& o) const { && (min.y <= o.max.y) && (o.min.y <= max.y); } -AABBSpatialRelation AABB2::relationTo(const AABB2& o) const { +AABB2::AABBSpatialRelation AABB2::relationTo(const AABB2& o) const { if (intersects(o)) { if (contains(o)) { - return AABBSpatialRelation::Containing; + return AABB2::AABBSpatialRelation::Containing; } if (o.contains(*this)) { - return AABBSpatialRelation::Contained; + return AABB2::AABBSpatialRelation::Contained; } - return AABBSpatialRelation::Intersecting; + return AABB2::AABBSpatialRelation::Intersecting; } - return AABBSpatialRelation::None; + return AABB2::AABBSpatialRelation::None; } AABB3::AABB3() @@ -136,9 +136,9 @@ AABB3::AABB3() ) {} -AABB3::AABB3(const glm::vec3& min, const glm::vec3& max) - : min(min), - max(max) +AABB3::AABB3(glm::vec3 min, glm::vec3 max) + : min(std::move(min)) + , max(std::move(max)) {} void AABB3::expand(const glm::vec3 p) { @@ -172,17 +172,17 @@ bool AABB3::intersects(const AABB3& o) const { && (min.z <= o.max.z) && (o.min.z <= max.z); } -AABBSpatialRelation AABB3::relationTo(const AABB3& o) const { +AABB3::AABBSpatialRelation AABB3::relationTo(const AABB3& o) const { if (intersects(o)) { if (contains(o)) { - return AABBSpatialRelation::Containing; + return AABB3::AABBSpatialRelation::Containing; } if (o.contains(*this)) { - return AABBSpatialRelation::Contained; + return AABB3::AABBSpatialRelation::Contained; } - return AABBSpatialRelation::Intersecting; + return AABB3::AABBSpatialRelation::Intersecting; } - return AABBSpatialRelation::None; + return AABB3::AABBSpatialRelation::None; } } // namespace globebrowsing diff --git a/modules/globebrowsing/geometry/aabb.h b/modules/globebrowsing/geometry/aabb.h index a50ea6a6c1..5277230fcb 100644 --- a/modules/globebrowsing/geometry/aabb.h +++ b/modules/globebrowsing/geometry/aabb.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,19 +25,19 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___AABB___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___AABB___H__ -#include +#include namespace openspace { namespace globebrowsing { -enum class AABBSpatialRelation { - None, - Intersecting, - Contained, - Containing -}; - struct AABB1 { + enum class AABBSpatialRelation { + None, + Intersecting, + Contained, + Containing + }; + AABB1(); AABB1(float min, float max); @@ -54,8 +54,15 @@ struct AABB1 { }; struct AABB2 { + enum class AABBSpatialRelation { + None, + Intersecting, + Contained, + Containing + }; + AABB2(); - AABB2(const glm::vec2& min, const glm::vec2& max); + AABB2(glm::vec2 min, glm::vec2 max); void expand(const glm::vec2& p); glm::vec2 center() const; @@ -70,8 +77,15 @@ struct AABB2 { }; struct AABB3 { + enum class AABBSpatialRelation { + None, + Intersecting, + Contained, + Containing + }; + AABB3(); - AABB3(const glm::vec3& min, const glm::vec3& max); + AABB3(glm::vec3 min, glm::vec3 max); void expand(const glm::vec3 p); glm::vec3 center() const; @@ -88,4 +102,4 @@ struct AABB3 { } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___AABB___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___AABB___H__ diff --git a/modules/globebrowsing/geometry/angle.h b/modules/globebrowsing/geometry/angle.h index 3af8e78cde..1963f0d0a2 100644 --- a/modules/globebrowsing/geometry/angle.h +++ b/modules/globebrowsing/geometry/angle.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___ANGLE___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___ANGLE___H__ -#include +#include #include #include diff --git a/modules/globebrowsing/geometry/angle.inl b/modules/globebrowsing/geometry/angle.inl index 341b35893b..f84431f91f 100644 --- a/modules/globebrowsing/geometry/angle.inl +++ b/modules/globebrowsing/geometry/angle.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/geometry/convexhull.cpp b/modules/globebrowsing/geometry/convexhull.cpp deleted file mode 100644 index 48411c55ec..0000000000 --- a/modules/globebrowsing/geometry/convexhull.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 - -namespace openspace { -namespace globebrowsing { - -glm::vec2 ConvexHull2::p0(0,0); - -ConvexHull2 ConvexHull2::grahamScan_NOT_THREAD_SAFE(std::vector& points, - int yMinIndex) -{ - ConvexHull2 hull; - - if (yMinIndex == -1) { - yMinIndex = 0; - float ymin = points[0].y; - for (int i = 1; i < points.size(); i++) { - float y = points[i].y; - // Pick the bottom-most or chose the left most point in case of tie - if ((y < ymin) || (ymin == y && points[i].x < points[yMinIndex].x)) { - ymin = points[i].y; - yMinIndex = i; - } - } - } - - // Place the bottom-most point at first position - swap(points[0], points[yMinIndex]); - - // Sort n-1 points with respect to the first point. A point p1 comes - // before p2 in sorted ouput if p2 has larger polar angle (in - // counterclockwise direction) than p1 - hull.p0 = points[0]; - - // Replace with std::sort - qsort(&(points.data()[1]), points.size()-1, sizeof(glm::vec2), &(hull.compare)); - - // Create an empty stack and push first three points to it. - std::stack S; - S.push(points[0]); - S.push(points[1]); - S.push(points[2]); - - // Process remaining n-3 points - for (int i = 3; i < points.size(); i++) { - // Keep removing top while the angle formed by points next-to-top, - // top, and points[i] makes a non-left turn - while (orientation(oneBelowTop(S), S.top(), points[i]) == 1) - S.pop(); - S.push(points[i]); - } - - // Now stack has the output points, print contents of stack - while (!S.empty()) { - glm::vec2 p = S.top(); - hull._points.push_back(p); - S.pop(); - } - - return hull; -} - -bool ConvexHull2::intersects(const ConvexHull2& other) const { - // uses Separating Axis Theorem - // ref: http://stackoverflow.com/questions/753140/how-do-i-determine-if-two-convex-polygons-intersect - return this->hasPerpendicularLineWhereProjectedPointsOverlap(other) || - other.hasPerpendicularLineWhereProjectedPointsOverlap(*this); -} - - -bool ConvexHull2::hasPerpendicularLineWhereProjectedPointsOverlap(const ConvexHull2& other) const { - for (size_t i = 1; i < _points.size(); i++) { - glm::vec2 dividingAxis = _points[i] - _points[i - 1]; - // project all points onto the vector perpendicular to the dividing axis - glm::vec2 projAxis(glm::normalize(glm::vec2(-dividingAxis.y, dividingAxis.x))); - const AABB1& myBounds = projectedRegion(projAxis); - const AABB1& otherBounds = other.projectedRegion(projAxis); - if (!myBounds.intersects(otherBounds)) { - return false; - } - } - - // test line defined by last-to-first point - glm::vec2 dividingAxis = _points[0] - _points.back(); - glm::vec2 projAxis(glm::normalize(glm::vec2(-dividingAxis.y, dividingAxis.x))); - const AABB1& myBounds = projectedRegion(projAxis); - const AABB1& otherBounds = other.projectedRegion(projAxis); - if (!myBounds.intersects(otherBounds)) { - return false; - } - - return true; -} - -AABB1 ConvexHull2::projectedRegion(glm::vec2 direction) const { - AABB1 projectedRegion; - for (const glm::vec2& p : _points) { - projectedRegion.expand(glm::dot(p, direction)); - } - //for (size_t i = 0; i < _points.size(); i++) { - // projectedRegion.expand(glm::dot(_points[i], direction)); - //} - return projectedRegion; -} - -glm::vec2 ConvexHull2::oneBelowTop(std::stack& S) { - glm::vec2 p = S.top(); - S.pop(); - glm::vec2 res = S.top(); - S.push(p); - return res; -} - -void ConvexHull2::swap(glm::vec2& p1, glm::vec2& p2) { - glm::vec2 temp = p1; - p1 = p2; - p2 = temp; -} - -const std::vector ConvexHull2::points() const { - return _points; -} - -int ConvexHull2::orientation(const glm::vec2& p, const glm::vec2& q, const glm::vec2& r) { - float val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); - return (val == 0) ? 0 : (val > 0) ? 1 : 2; -} - -float ConvexHull2::dist(const glm::vec2& p1, const glm::vec2& p2) { - return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y); -} - -int ConvexHull2::compare(const void *vp1, const void *vp2) { - glm::vec2* p1 = (glm::vec2 *)vp1; - glm::vec2* p2 = (glm::vec2 *)vp2; - - // Find orientation - int o = orientation(p0, *p1, *p2); - if (o == 0) { - return (dist(p0, *p2) >= dist(p0, *p1)) ? -1 : 1; - } - - return (o == 2) ? -1 : 1; -} - -} // namespace globebrowsing -} // namespace openspace \ No newline at end of file diff --git a/modules/globebrowsing/geometry/ellipsoid.cpp b/modules/globebrowsing/geometry/ellipsoid.cpp index f89f15e84a..4f756f575b 100644 --- a/modules/globebrowsing/geometry/ellipsoid.cpp +++ b/modules/globebrowsing/geometry/ellipsoid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/geometry/ellipsoid.h b/modules/globebrowsing/geometry/ellipsoid.h index f4931a85d9..9dac318f5b 100644 --- a/modules/globebrowsing/geometry/ellipsoid.h +++ b/modules/globebrowsing/geometry/ellipsoid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,6 +26,7 @@ #define __OPENSPACE_MODULE_GLOBEBROWSING___ELLIPSOID___H__ #include +#include #include diff --git a/modules/globebrowsing/geometry/geodetic2.cpp b/modules/globebrowsing/geometry/geodetic2.cpp index b0f7f81d98..b97d0a2e5e 100644 --- a/modules/globebrowsing/geometry/geodetic2.cpp +++ b/modules/globebrowsing/geometry/geodetic2.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,8 +24,6 @@ #include -#include - namespace openspace { namespace globebrowsing { @@ -62,213 +60,5 @@ Geodetic2 Geodetic2::operator/(double scalar) const { return Geodetic2(lat / scalar, lon / scalar); } -GeodeticPatch::GeodeticPatch(double centerLat, double centerLon, double halfSizeLat, - double halfSizeLon) - : _center(Geodetic2(centerLat, centerLon)) - , _halfSize(Geodetic2(halfSizeLat, halfSizeLon)) -{} - -GeodeticPatch::GeodeticPatch(const Geodetic2& center, const Geodetic2& halfSize) - : _center(center) - , _halfSize(halfSize) -{} - -GeodeticPatch::GeodeticPatch(const GeodeticPatch& patch) - : _center(patch._center) - , _halfSize(patch._halfSize) -{} - -GeodeticPatch::GeodeticPatch(const TileIndex& tileIndex) { - double deltaLat = (2 * glm::pi()) / ((double)(1 << tileIndex.level)); - double deltaLon = (2 * glm::pi()) / ((double)(1 << tileIndex.level)); - Geodetic2 nwCorner(glm::pi() / 2 - deltaLat * tileIndex.y, -glm::pi() + deltaLon * tileIndex.x); - _halfSize = Geodetic2(deltaLat / 2, deltaLon / 2); - _center = Geodetic2(nwCorner.lat - _halfSize.lat, nwCorner.lon + _halfSize.lon); -} - -void GeodeticPatch::setCenter(const Geodetic2& center) { - _center = center; -} - -void GeodeticPatch::setHalfSize(const Geodetic2& halfSize) { - _halfSize = halfSize; -} - -double GeodeticPatch::maximumTileLevel() const { - // Numerator is just pi, not 2*pi, since we are dealing with HALF sizes - return log2(glm::pi() / glm::min(_halfSize.lat, _halfSize.lon)); -} - -double GeodeticPatch::minimumTileLevel() const { - // Numerator is just pi, not 2*pi, since we are dealing with HALF sizes - return log2(glm::pi() / glm::max(_halfSize.lat, _halfSize.lon)); -} - -const Geodetic2& GeodeticPatch::center() const { - return _center; -} - -const Geodetic2& GeodeticPatch::halfSize() const { - return _halfSize; -} - -Geodetic2 GeodeticPatch::size() const { - return Geodetic2(2 * _halfSize.lat, 2 * _halfSize.lon); -} - -Geodetic2 GeodeticPatch::getCorner(Quad q) const { - switch (q) { - case NORTH_WEST: return Geodetic2(maxLat(), minLon());// northWestCorner(); - case NORTH_EAST: return Geodetic2(maxLat(), maxLon());// northEastCorner(); - case SOUTH_WEST: return Geodetic2(minLat(), minLon());// southWestCorner(); - case SOUTH_EAST: return Geodetic2(minLat(), maxLon());// southEastCorner(); - } -} - -Geodetic2 GeodeticPatch::getSize() const { - return _halfSize * 2; -} - -double GeodeticPatch::minLat() const { - return _center.lat - _halfSize.lat; -} - -double GeodeticPatch::maxLat() const { - return _center.lat + _halfSize.lat; -} - -double GeodeticPatch::minLon() const { - return _center.lon - _halfSize.lon; -} - -double GeodeticPatch::maxLon() const { - return _center.lon + _halfSize.lon; -} - -bool GeodeticPatch::contains(const Geodetic2& p) const { - Geodetic2 diff = _center - p; - return glm::abs(diff.lat) <= _halfSize.lat && glm::abs(diff.lon) <= _halfSize.lon; -} - -double GeodeticPatch::edgeLatitudeNearestEquator() const { - return _center.lat + _halfSize.lat * (isNorthern() ? -1 : 1); -} - -double GeodeticPatch::isNorthern() const { - return _center.lat > 0.0; -} - -Geodetic2 GeodeticPatch::clamp(const Geodetic2& p) const { - using Ang = Angle; - - // Convert to Angles for normalization - Ang centerLat = Ang::fromRadians(_center.lat); - Ang centerLon = Ang::fromRadians(_center.lon); - Ang pointLat = Ang::fromRadians(p.lat); - Ang pointLon = Ang::fromRadians(p.lon); - - // Normalize w.r.t. the center in order for the clamping to done correctly - // - // Example: - // centerLat = 0 deg, halfSize.lat = 10 deg, pointLat = 330 deg - // --> Just clamping pointLat would be clamp(330, -10, 10) = 10 // WRONG! - // Instead, if we first normalize 330 deg around 0, we get -30 deg - // --> clamp(-30, -10, 10) = -10 // CORRECT! - pointLat.normalizeAround(centerLat); - pointLon.normalizeAround(centerLon); - - return Geodetic2( - glm::clamp(pointLat.asRadians(), minLat(), maxLat()), - glm::clamp(pointLon.asRadians(), minLon(), maxLon()) - ); -} - -Geodetic2 GeodeticPatch::closestCorner(const Geodetic2& p) const { - using Ang = Angle; - - // LatLon vector from patch center to the point - Geodetic2 centerToPoint = p - _center; - - // Normalize the difference angles to be centered around 0. - Ang latDiff = Ang::fromRadians(centerToPoint.lat).normalizeAround(Ang::ZERO); - Ang lonDiff = Ang::fromRadians(centerToPoint.lon).normalizeAround(Ang::ZERO); - - // If latDiff > 0 - // --> point p is north of the patch center - // --> the closest corner to the point must be a northern one - // --> set the corner's latitude coordinate to center.lat + halfSize.lat - // else - // --> set corner's latidude coordinate to center.lat - halfSize.lat - double cornerLat = _center.lat + _halfSize.lat * (latDiff > Ang::ZERO ? 1 : -1); - - // We then assigned the corner's longitude coordinate in a similar fashion - double cornerLon = _center.lon + _halfSize.lon * (lonDiff > Ang::ZERO ? 1 : -1); - - return Geodetic2(cornerLat, cornerLon); -} - -Geodetic2 GeodeticPatch::closestPoint(const Geodetic2& p) const { - // This method finds the closest point on the patch, to the provided - // point p. As we are deali ng with latitude-longitude patches, distance in this - // context refers to great-circle distance. - // (https://en.wikipedia.org/wiki/Great-circle_distance) - // - // This uses a simple clamping approach to find the closest point on the - // patch. A naive castesian clamp is not sufficient for this purpose, - // as illustrated with an example below. - - // Example: (degrees are used for latidude, longitude) - // patchCenter = (0,0), patchHalfSize = (45,45), point = (5, 170) - // Note, the point and the patch are on opposite sides of the sphere - // - // cartesian clamp: - // --> clampedPointLat = clamp(5, -45, 45) = 5 - // --> clampedPointLon = clamp(170, -45, 45) = 45 - // --> result: (5, 45) - // --> closest point is actually (45, 45) - // --> The error is significant - // - // This method simply adds an extra clamp on the latitude in these cases. In the - // above example, that would be the following: - // --> clampedPointLat = clamp(180 - 5, -45, 45) = 45 - // - // Just doing this actually makes points returned from this methods being the - // true closest point, great-circle distance-wise. - - - using Ang = Angle; - - // Convert to Angles for normalization - Ang centerLat = Ang::fromRadians(_center.lat); - Ang centerLon = Ang::fromRadians(_center.lon); - Ang pointLat = Ang::fromRadians(p.lat); - Ang pointLon = Ang::fromRadians(p.lon); - - // Normalize point with respect to center. This is done because the point - // will later be clamped. See LatLonPatch::clamp(const LatLon&) for explanation - pointLat.normalizeAround(centerLat); - pointLon.normalizeAround(centerLon); - - // Calculate the longitud difference between center and point. We normalize around - // zero because we want the "shortest distance" difference, i.e the difference - // should be in the interval [-180 deg, 180 deg] - Ang centerToPointLon = (centerLon - pointLon).normalizeAround(Ang::ZERO); - - // Calculate the longitudinal distance to the closest patch edge - Ang longitudeDistanceToClosestPatchEdge = centerToPointLon.abs() - Ang::fromRadians(_halfSize.lon); - - // If the longitude distance to the closest patch edge is larger than 90 deg - // the latitude will have to be clamped to its closest corner, as explained in - // the example above. - double clampedLat = longitudeDistanceToClosestPatchEdge > Ang::QUARTER ? - clampedLat = glm::clamp((Ang::HALF - pointLat).normalizeAround(centerLat).asRadians(), minLat(), maxLat()) : - clampedLat = glm::clamp(pointLat.asRadians(), minLat(), maxLat()); - - // Longitude is just clamped normally - double clampedLon = glm::clamp(pointLon.asRadians(), minLon(), maxLon()); - - return Geodetic2(clampedLat, clampedLon); -} - } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/geometry/geodetic2.h b/modules/globebrowsing/geometry/geodetic2.h index d9732077c7..9c4e029fb5 100644 --- a/modules/globebrowsing/geometry/geodetic2.h +++ b/modules/globebrowsing/geometry/geodetic2.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,15 +25,11 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___GEODETIC2___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___GEODETIC2___H__ -#include - #include namespace openspace { namespace globebrowsing { -class Ellipsoid; - struct Geodetic2 { Geodetic2(double latitude = 0.0, double longitude = 0.0); Geodetic2(const Geodetic2& src); @@ -55,89 +51,6 @@ struct Geodetic2 { double lon; }; -struct Geodetic3 { - Geodetic2 geodetic2; - double height; -}; - -class GeodeticPatch { -public: - GeodeticPatch( - double centerLat, - double centerLon, - double halfSizeLat, - double halfSizeLon); - - GeodeticPatch( - const Geodetic2& center, - const Geodetic2& halfSize); - - GeodeticPatch(const GeodeticPatch& patch); - - GeodeticPatch(const TileIndex& tileIndex); - - void setCenter(const Geodetic2&); - void setHalfSize(const Geodetic2&); - - /** - returns the latitude boundary which is closest to the equator - */ - double edgeLatitudeNearestEquator() const; - - /** - Returns true if the center above the equator - */ - double isNorthern() const; - - Geodetic2 getCorner(Quad q) const; - Geodetic2 getSize() const; - - double minLat() const; - double maxLat() const; - double minLon() const; - double maxLon() const; - - /** - * returns true if the specified coordinate is contained within the patch - */ - bool contains(const Geodetic2& p) const; - - - /** - * Clamps a point to the patch region - */ - Geodetic2 clamp(const Geodetic2& p) const; - - /** - * Returns the corner of the patch that is closest to the given point p - */ - Geodetic2 closestCorner(const Geodetic2& p) const; - - /** - * Returns a point on the patch that minimizes the great-circle distance to - * the given point p. - */ - Geodetic2 closestPoint(const Geodetic2& p) const; - - /** - * Returns the minimum tile level of the patch (based on largest side) - */ - double minimumTileLevel() const; - - /** - * Returns the maximum level of the patch (based on smallest side) - */ - double maximumTileLevel() const; - - const Geodetic2& center() const; - const Geodetic2& halfSize() const; - Geodetic2 size() const; - -private: - Geodetic2 _center; - Geodetic2 _halfSize; -}; - } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/geometry/geodetic3.h b/modules/globebrowsing/geometry/geodetic3.h new file mode 100644 index 0000000000..e0d6bb337d --- /dev/null +++ b/modules/globebrowsing/geometry/geodetic3.h @@ -0,0 +1,41 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GEODETIC3___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GEODETIC3___H__ + +#include + +namespace openspace { +namespace globebrowsing { + +struct Geodetic3 { + Geodetic2 geodetic2; + double height; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GEODETIC3___H__ diff --git a/modules/globebrowsing/geometry/geodeticpatch.cpp b/modules/globebrowsing/geometry/geodeticpatch.cpp new file mode 100644 index 0000000000..8aca1219fb --- /dev/null +++ b/modules/globebrowsing/geometry/geodeticpatch.cpp @@ -0,0 +1,242 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +GeodeticPatch::GeodeticPatch(double centerLat, double centerLon, double halfSizeLat, + double halfSizeLon) + : _center(Geodetic2(centerLat, centerLon)) + , _halfSize(Geodetic2(halfSizeLat, halfSizeLon)) +{} + +GeodeticPatch::GeodeticPatch(const Geodetic2& center, const Geodetic2& halfSize) + : _center(center) + , _halfSize(halfSize) +{} + +GeodeticPatch::GeodeticPatch(const GeodeticPatch& patch) + : _center(patch._center) + , _halfSize(patch._halfSize) +{} + +GeodeticPatch::GeodeticPatch(const TileIndex& tileIndex) { + double deltaLat = (2 * glm::pi()) / ((double)(1 << tileIndex.level)); + double deltaLon = (2 * glm::pi()) / ((double)(1 << tileIndex.level)); + Geodetic2 nwCorner(glm::pi() / 2 - deltaLat * tileIndex.y, -glm::pi() + deltaLon * tileIndex.x); + _halfSize = Geodetic2(deltaLat / 2, deltaLon / 2); + _center = Geodetic2(nwCorner.lat - _halfSize.lat, nwCorner.lon + _halfSize.lon); +} + +void GeodeticPatch::setCenter(const Geodetic2& center) { + _center = center; +} + +void GeodeticPatch::setHalfSize(const Geodetic2& halfSize) { + _halfSize = halfSize; +} + +double GeodeticPatch::maximumTileLevel() const { + // Numerator is just pi, not 2*pi, since we are dealing with HALF sizes + return log2(glm::pi() / glm::min(_halfSize.lat, _halfSize.lon)); +} + +double GeodeticPatch::minimumTileLevel() const { + // Numerator is just pi, not 2*pi, since we are dealing with HALF sizes + return log2(glm::pi() / glm::max(_halfSize.lat, _halfSize.lon)); +} + +const Geodetic2& GeodeticPatch::center() const { + return _center; +} + +const Geodetic2& GeodeticPatch::halfSize() const { + return _halfSize; +} + +Geodetic2 GeodeticPatch::size() const { + return Geodetic2(2 * _halfSize.lat, 2 * _halfSize.lon); +} + +Geodetic2 GeodeticPatch::getCorner(Quad q) const { + switch (q) { + case NORTH_WEST: return Geodetic2(maxLat(), minLon());// northWestCorner(); + case NORTH_EAST: return Geodetic2(maxLat(), maxLon());// northEastCorner(); + case SOUTH_WEST: return Geodetic2(minLat(), minLon());// southWestCorner(); + case SOUTH_EAST: return Geodetic2(minLat(), maxLon());// southEastCorner(); + } +} + +Geodetic2 GeodeticPatch::getSize() const { + return _halfSize * 2; +} + +double GeodeticPatch::minLat() const { + return _center.lat - _halfSize.lat; +} + +double GeodeticPatch::maxLat() const { + return _center.lat + _halfSize.lat; +} + +double GeodeticPatch::minLon() const { + return _center.lon - _halfSize.lon; +} + +double GeodeticPatch::maxLon() const { + return _center.lon + _halfSize.lon; +} + +bool GeodeticPatch::contains(const Geodetic2& p) const { + Geodetic2 diff = _center - p; + return glm::abs(diff.lat) <= _halfSize.lat && glm::abs(diff.lon) <= _halfSize.lon; +} + +double GeodeticPatch::edgeLatitudeNearestEquator() const { + return _center.lat + _halfSize.lat * (isNorthern() ? -1 : 1); +} + +double GeodeticPatch::isNorthern() const { + return _center.lat > 0.0; +} + +Geodetic2 GeodeticPatch::clamp(const Geodetic2& p) const { + using Ang = Angle; + + // Convert to Angles for normalization + Ang centerLat = Ang::fromRadians(_center.lat); + Ang centerLon = Ang::fromRadians(_center.lon); + Ang pointLat = Ang::fromRadians(p.lat); + Ang pointLon = Ang::fromRadians(p.lon); + + // Normalize w.r.t. the center in order for the clamping to done correctly + // + // Example: + // centerLat = 0 deg, halfSize.lat = 10 deg, pointLat = 330 deg + // --> Just clamping pointLat would be clamp(330, -10, 10) = 10 // WRONG! + // Instead, if we first normalize 330 deg around 0, we get -30 deg + // --> clamp(-30, -10, 10) = -10 // CORRECT! + pointLat.normalizeAround(centerLat); + pointLon.normalizeAround(centerLon); + + return Geodetic2( + glm::clamp(pointLat.asRadians(), minLat(), maxLat()), + glm::clamp(pointLon.asRadians(), minLon(), maxLon()) + ); +} + +Geodetic2 GeodeticPatch::closestCorner(const Geodetic2& p) const { + using Ang = Angle; + + // LatLon vector from patch center to the point + Geodetic2 centerToPoint = p - _center; + + // Normalize the difference angles to be centered around 0. + Ang latDiff = Ang::fromRadians(centerToPoint.lat).normalizeAround(Ang::ZERO); + Ang lonDiff = Ang::fromRadians(centerToPoint.lon).normalizeAround(Ang::ZERO); + + // If latDiff > 0 + // --> point p is north of the patch center + // --> the closest corner to the point must be a northern one + // --> set the corner's latitude coordinate to center.lat + halfSize.lat + // else + // --> set corner's latidude coordinate to center.lat - halfSize.lat + double cornerLat = _center.lat + _halfSize.lat * (latDiff > Ang::ZERO ? 1 : -1); + + // We then assigned the corner's longitude coordinate in a similar fashion + double cornerLon = _center.lon + _halfSize.lon * (lonDiff > Ang::ZERO ? 1 : -1); + + return Geodetic2(cornerLat, cornerLon); +} + +Geodetic2 GeodeticPatch::closestPoint(const Geodetic2& p) const { + // This method finds the closest point on the patch, to the provided + // point p. As we are deali ng with latitude-longitude patches, distance in this + // context refers to great-circle distance. + // (https://en.wikipedia.org/wiki/Great-circle_distance) + // + // This uses a simple clamping approach to find the closest point on the + // patch. A naive castesian clamp is not sufficient for this purpose, + // as illustrated with an example below. + + // Example: (degrees are used for latidude, longitude) + // patchCenter = (0,0), patchHalfSize = (45,45), point = (5, 170) + // Note, the point and the patch are on opposite sides of the sphere + // + // cartesian clamp: + // --> clampedPointLat = clamp(5, -45, 45) = 5 + // --> clampedPointLon = clamp(170, -45, 45) = 45 + // --> result: (5, 45) + // --> closest point is actually (45, 45) + // --> The error is significant + // + // This method simply adds an extra clamp on the latitude in these cases. In the + // above example, that would be the following: + // --> clampedPointLat = clamp(180 - 5, -45, 45) = 45 + // + // Just doing this actually makes points returned from this methods being the + // true closest point, great-circle distance-wise. + + + using Ang = Angle; + + // Convert to Angles for normalization + Ang centerLat = Ang::fromRadians(_center.lat); + Ang centerLon = Ang::fromRadians(_center.lon); + Ang pointLat = Ang::fromRadians(p.lat); + Ang pointLon = Ang::fromRadians(p.lon); + + // Normalize point with respect to center. This is done because the point + // will later be clamped. See LatLonPatch::clamp(const LatLon&) for explanation + pointLat.normalizeAround(centerLat); + pointLon.normalizeAround(centerLon); + + // Calculate the longitud difference between center and point. We normalize around + // zero because we want the "shortest distance" difference, i.e the difference + // should be in the interval [-180 deg, 180 deg] + Ang centerToPointLon = (centerLon - pointLon).normalizeAround(Ang::ZERO); + + // Calculate the longitudinal distance to the closest patch edge + Ang longitudeDistanceToClosestPatchEdge = centerToPointLon.abs() - Ang::fromRadians(_halfSize.lon); + + // If the longitude distance to the closest patch edge is larger than 90 deg + // the latitude will have to be clamped to its closest corner, as explained in + // the example above. + double clampedLat = longitudeDistanceToClosestPatchEdge > Ang::QUARTER ? + clampedLat = glm::clamp((Ang::HALF - pointLat).normalizeAround(centerLat).asRadians(), minLat(), maxLat()) : + clampedLat = glm::clamp(pointLat.asRadians(), minLat(), maxLat()); + + // Longitude is just clamped normally + double clampedLon = glm::clamp(pointLon.asRadians(), minLon(), maxLon()); + + return Geodetic2(clampedLat, clampedLon); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/geometry/geodeticpatch.h b/modules/globebrowsing/geometry/geodeticpatch.h new file mode 100644 index 0000000000..e47cd5de3d --- /dev/null +++ b/modules/globebrowsing/geometry/geodeticpatch.h @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GEODETICPATCH___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GEODETICPATCH___H__ + +#include +#include + +namespace openspace { +namespace globebrowsing { + +struct TileIndex; + +class GeodeticPatch { +public: + GeodeticPatch( + double centerLat, + double centerLon, + double halfSizeLat, + double halfSizeLon); + + GeodeticPatch( + const Geodetic2& center, + const Geodetic2& halfSize); + + GeodeticPatch(const GeodeticPatch& patch); + + GeodeticPatch(const TileIndex& tileIndex); + + void setCenter(const Geodetic2&); + void setHalfSize(const Geodetic2&); + + /** + * Returns the latitude boundary which is closest to the equator + */ + double edgeLatitudeNearestEquator() const; + + /** + * Returns \c true if the center above the equator + */ + double isNorthern() const; + + Geodetic2 getCorner(Quad q) const; + Geodetic2 getSize() const; + + double minLat() const; + double maxLat() const; + double minLon() const; + double maxLon() const; + + /** + * Returns \c true if the specified coordinate is contained within the patch + */ + bool contains(const Geodetic2& p) const; + + + /** + * Clamps a point to the patch region + */ + Geodetic2 clamp(const Geodetic2& p) const; + + /** + * Returns the corner of the patch that is closest to the given point p + */ + Geodetic2 closestCorner(const Geodetic2& p) const; + + /** + * Returns a point on the patch that minimizes the great-circle distance to + * the given point p. + */ + Geodetic2 closestPoint(const Geodetic2& p) const; + + /** + * Returns the minimum tile level of the patch (based on largest side) + */ + double minimumTileLevel() const; + + /** + * Returns the maximum level of the patch (based on smallest side) + */ + double maximumTileLevel() const; + + const Geodetic2& center() const; + const Geodetic2& halfSize() const; + Geodetic2 size() const; + +private: + Geodetic2 _center; + Geodetic2 _halfSize; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GEODETICPATCH___H__ diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index c251b976eb..808e5ce072 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,8 +28,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -52,17 +54,17 @@ void GlobeBrowsingModule::internalInitialize() { fRenderable->registerClass("RenderableGlobe"); // add Tile Provider factory - auto fTileProvider = std::make_unique>(); + auto fTileProvider = std::make_unique>(); - fTileProvider->registerClass("LRUCaching"); - fTileProvider->registerClass("SingleImage"); - fTileProvider->registerClass("Temporal"); - fTileProvider->registerClass("TileIndex"); - fTileProvider->registerClass("SizeReference"); + fTileProvider->registerClass("LRUCaching"); + fTileProvider->registerClass("SingleImage"); + fTileProvider->registerClass("Temporal"); + fTileProvider->registerClass("TileIndex"); + fTileProvider->registerClass("SizeReference"); // Combining Tile Providers - fTileProvider->registerClass("ByLevel"); - fTileProvider->registerClass("ByIndex"); + fTileProvider->registerClass("ByLevel"); + fTileProvider->registerClass("ByIndex"); FactoryManager::ref().addFactory(std::move(fTileProvider)); } diff --git a/modules/globebrowsing/globebrowsingmodule.h b/modules/globebrowsing/globebrowsingmodule.h index 9431aa8bce..942aea1819 100644 --- a/modules/globebrowsing/globebrowsingmodule.h +++ b/modules/globebrowsing/globebrowsingmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___GLOBEBROWSING___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___GLOBEBROWSING___H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___GLOBEBROWSING_MODULE___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GLOBEBROWSING_MODULE___H__ #include @@ -39,4 +39,4 @@ protected: } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GLOBEBROWSING___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GLOBEBROWSING_MODULE___H__ diff --git a/modules/globebrowsing/globes/chunkedlodglobe.cpp b/modules/globebrowsing/globes/chunkedlodglobe.cpp index 296c69ebe1..a4a6c6e823 100644 --- a/modules/globebrowsing/globes/chunkedlodglobe.cpp +++ b/modules/globebrowsing/globes/chunkedlodglobe.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,19 +25,27 @@ #include #include -#include +#include +#include +#include +#include #include -#include +#include +#include +#include #include #include #include #include -#include +#include +#include #include +#include #include #include +#include #include @@ -66,17 +74,17 @@ ChunkedLodGlobe::ChunkedLodGlobe(const RenderableGlobe& owner, size_t segmentsPe TriangleSoup::Normals::No ); - _chunkCullers.push_back(std::make_unique()); - _chunkCullers.push_back(std::make_unique( + _chunkCullers.push_back(std::make_unique()); + _chunkCullers.push_back(std::make_unique( AABB3(glm::vec3(-1, -1, 0), glm::vec3(1, 1, 1e35))) ); _chunkEvaluatorByAvailableTiles = - std::make_unique(); + std::make_unique(); _chunkEvaluatorByProjectedArea = - std::make_unique(); + std::make_unique(); _chunkEvaluatorByDistance = - std::make_unique(); + std::make_unique(); _renderer = std::make_unique(geometry, layerManager); } @@ -135,7 +143,7 @@ int ChunkedLodGlobe::getDesiredLevel( int desiredLevelByAvailableData = _chunkEvaluatorByAvailableTiles->getDesiredLevel( chunk, renderData ); - if (desiredLevelByAvailableData != ChunkLevelEvaluator::UNKNOWN_DESIRED_LEVEL) { + if (desiredLevelByAvailableData != chunklevelevaluator::Evaluator::UnknownDesiredLevel) { desiredLevel = glm::min(desiredLevel, desiredLevelByAvailableData); } @@ -166,7 +174,7 @@ float ChunkedLodGlobe::getHeight(glm::dvec3 position) const { const auto& heightMapLayers = _layerManager->layerGroup(LayerManager::HeightLayers).activeLayers(); for (const auto& layer : heightMapLayers) { - TileProvider* tileProvider = layer->tileProvider(); + tileprovider::TileProvider* tileProvider = layer->tileProvider(); // Transform the uv coordinates to the current tile texture ChunkTile chunkTile = tileProvider->getChunkTile(tileIndex); const auto& tile = chunkTile.tile; diff --git a/modules/globebrowsing/globes/chunkedlodglobe.h b/modules/globebrowsing/globes/chunkedlodglobe.h index 74a820f921..7578bcb481 100644 --- a/modules/globebrowsing/globes/chunkedlodglobe.h +++ b/modules/globebrowsing/globes/chunkedlodglobe.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,18 +29,25 @@ #include #include +#include #include namespace openspace { namespace globebrowsing { +namespace chunklevelevaluator { + class Evaluator; +} // namespace chunklevelevaluator + +namespace culling { + class ChunkCuller; +} // namespace culling + class Chunk; -class ChunkCuller; -class ChunkLevelEvaluator; class ChunkNode; class ChunkRenderer; -class Geodetic2; +struct Geodetic2; class LayerManager; class RenderableGlobe; @@ -61,13 +68,13 @@ public: * Traverse the chunk tree and find the highest level chunk node. * * \param location is given in geodetic coordinates and must be in the range - * latitude [-90. 90] and longitude [-180, 180]. In other words, it must be a + * latitude [-90, 90] and longitude [-180, 180]. In other words, it must be a * position defined on the globe in georeferenced coordinates. */ const ChunkNode& findChunkNode(const Geodetic2& location) const; /** - * Test if a specific chunk can saefely be culled without affecting the rendered + * Test if a specific chunk can saf;ely be culled without affecting the rendered * image. * * Goes through all available ChunkCullers and check if any of them @@ -123,11 +130,11 @@ private: // the patch used for actual rendering std::unique_ptr _renderer; - std::vector> _chunkCullers; + std::vector> _chunkCullers; - std::unique_ptr _chunkEvaluatorByAvailableTiles; - std::unique_ptr _chunkEvaluatorByProjectedArea; - std::unique_ptr _chunkEvaluatorByDistance; + std::unique_ptr _chunkEvaluatorByAvailableTiles; + std::unique_ptr _chunkEvaluatorByProjectedArea; + std::unique_ptr _chunkEvaluatorByDistance; std::shared_ptr _layerManager; @@ -137,4 +144,4 @@ private: } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKED_LOD_GLOBE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKED_LOD_GLOBE___H__ diff --git a/modules/globebrowsing/globes/pointglobe.cpp b/modules/globebrowsing/globes/pointglobe.cpp index 5e47fdede8..d4d796c18f 100644 --- a/modules/globebrowsing/globes/pointglobe.cpp +++ b/modules/globebrowsing/globes/pointglobe.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/globes/pointglobe.h b/modules/globebrowsing/globes/pointglobe.h index a377ad27e2..2c41a38e8a 100644 --- a/modules/globebrowsing/globes/pointglobe.h +++ b/modules/globebrowsing/globes/pointglobe.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,7 +29,7 @@ namespace ghoul { namespace opengl { class ProgramObject; -}} +} } namespace openspace { namespace globebrowsing { @@ -59,4 +59,4 @@ private: } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___POINTGLOBE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___POINTGLOBE___H__ diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index 3441fc86fa..40de2649eb 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,7 @@ #include #include -#include +#include namespace { const char* keyFrame = "Frame"; @@ -51,6 +51,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) FloatProperty("lodScaleFactor", "lodScaleFactor",10.0f, 1.0f, 50.0f), FloatProperty("cameraMinHeight", "cameraMinHeight", 100.0f, 0.0f, 1000.0f) }) + , _debugPropertyOwner("Debug") , _debugProperties({ BoolProperty("saveOrThrowCamera", "save or throw camera", false), BoolProperty("showChunkEdges", "show chunk edges", false), @@ -66,6 +67,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) BoolProperty("collectStats", "collect stats", false), BoolProperty("onlyModelSpaceRendering", "Only Model Space Rendering", false) }) + , _texturePropertyOwner("Textures") { setName("RenderableGlobe"); @@ -105,9 +107,6 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) double distance = res * _ellipsoid.maximumRadius() / tan(fov / 2); _distanceSwitch.addSwitchValue(_chunkedLodGlobe, distance); - _debugPropertyOwner.setName("Debug"); - _texturePropertyOwner.setName("Textures"); - addProperty(_generalProperties.isEnabled); addProperty(_generalProperties.atmosphereEnabled); addProperty(_generalProperties.performShading); diff --git a/modules/globebrowsing/globes/renderableglobe.h b/modules/globebrowsing/globes/renderableglobe.h index 2305f9246c..bd5c5b4ea3 100644 --- a/modules/globebrowsing/globes/renderableglobe.h +++ b/modules/globebrowsing/globes/renderableglobe.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -128,4 +128,4 @@ private: } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___RENDERABLEGLOBE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___RENDERABLEGLOBE___H__ diff --git a/modules/globebrowsing/meshes/basicgrid.cpp b/modules/globebrowsing/meshes/basicgrid.cpp index 6f86f2a672..7bd91dea3d 100644 --- a/modules/globebrowsing/meshes/basicgrid.cpp +++ b/modules/globebrowsing/meshes/basicgrid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -36,22 +36,22 @@ BasicGrid::BasicGrid(unsigned int xSegments, unsigned int ySegments, : Grid(xSegments, ySegments, usePositions, useTextureCoordinates, useNormals) { _geometry = std::make_unique( - CreateElements(xSegments, ySegments), + createElements(xSegments, ySegments), usePositions, useTextureCoordinates, useNormals ); if (usePositions) { - _geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments)); + _geometry->setVertexPositions(createPositions(_xSegments, _ySegments)); } if (useTextureCoordinates) { _geometry->setVertexTextureCoordinates( - CreateTextureCoordinates(_xSegments, _ySegments) + createTextureCoordinates(_xSegments, _ySegments) ); } if (useNormals) { - _geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments)); + _geometry->setVertexNormals(createNormals(_xSegments, _ySegments)); } } @@ -64,8 +64,11 @@ int BasicGrid::ySegments() const { } void BasicGrid::validate(int xSegments, int ySegments) { - ghoul_assert(xSegments > 0 && ySegments > 0, - "Resolution must be at least 1x1. (" << xSegments << ", " << ySegments << ")"); + ghoul_assert( + xSegments > 0 && ySegments > 0, + std::string("Resolution must be at least 1x1. (") + + std::to_string(xSegments) + ", " + std::to_string(ySegments) + ")" + ); } inline size_t BasicGrid::numElements(int xSegments, int ySegments) { @@ -76,7 +79,7 @@ inline size_t BasicGrid::numVertices(int xSegments, int ySegments) { return (xSegments + 1) * (ySegments + 1); } -std::vector BasicGrid::CreateElements(int xSegments, int ySegments) { +std::vector BasicGrid::createElements(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector elements; @@ -111,13 +114,13 @@ std::vector BasicGrid::CreateElements(int xSegments, int ySegments) { return elements; } -std::vector BasicGrid::CreatePositions(int xSegments, int ySegments) { +std::vector BasicGrid::createPositions(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector positions; positions.reserve(numVertices(xSegments, ySegments)); // Copy from 2d texture coordinates and use as template to create positions - std::vector templateTextureCoords = CreateTextureCoordinates( + std::vector templateTextureCoords = createTextureCoordinates( xSegments, ySegments ); for (const glm::vec2& coords : templateTextureCoords) { @@ -133,7 +136,7 @@ std::vector BasicGrid::CreatePositions(int xSegments, int ySegments) return positions; } -std::vector BasicGrid::CreateTextureCoordinates(int xSegments, int ySegments) { +std::vector BasicGrid::createTextureCoordinates(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector textureCoordinates; textureCoordinates.reserve(numVertices(xSegments, ySegments)); @@ -149,7 +152,7 @@ std::vector BasicGrid::CreateTextureCoordinates(int xSegments, int yS return textureCoordinates; } -std::vector BasicGrid::CreateNormals(int xSegments, int ySegments) { +std::vector BasicGrid::createNormals(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector normals; normals.reserve(numVertices(xSegments, ySegments)); diff --git a/modules/globebrowsing/meshes/basicgrid.h b/modules/globebrowsing/meshes/basicgrid.h index 648d423daf..73514cdf77 100644 --- a/modules/globebrowsing/meshes/basicgrid.h +++ b/modules/globebrowsing/meshes/basicgrid.h @@ -1,33 +1,33 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___BASICGRIDGEOMETRY___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___BASICGRIDGEOMETRY___H__ #include -#include +#include #include @@ -47,18 +47,19 @@ public: * to the GPU. */ BasicGrid(unsigned int xSegments, unsigned int ySegments, - TriangleSoup::Positions usePositions, - TriangleSoup::TextureCoordinates useTextureCoordinates, - TriangleSoup::Normals useNormals); + TriangleSoup::Positions usePositions, + TriangleSoup::TextureCoordinates useTextureCoordinates, + TriangleSoup::Normals useNormals); virtual int xSegments() const; virtual int ySegments() const; private: - virtual std::vector CreateElements(int xRes, int yRes); - virtual std::vector CreatePositions(int xRes, int yRes); - virtual std::vector CreateTextureCoordinates(int xRes, int yRes); - virtual std::vector CreateNormals(int xRes, int yRes); + std::vector createElements(int xRes, int yRes) override; + std::vector createPositions(int xRes, int yRes) override; + std::vector createTextureCoordinates(int xRes, int yRes) + override; + std::vector createNormals(int xRes, int yRes) override; void validate(int xSegments, int ySegments); diff --git a/modules/globebrowsing/meshes/grid.cpp b/modules/globebrowsing/meshes/grid.cpp index f6d6a1f2e3..4673e787aa 100644 --- a/modules/globebrowsing/meshes/grid.cpp +++ b/modules/globebrowsing/meshes/grid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/meshes/grid.h b/modules/globebrowsing/meshes/grid.h index 37d169d696..d0058ec51f 100644 --- a/modules/globebrowsing/meshes/grid.h +++ b/modules/globebrowsing/meshes/grid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,7 @@ #include -#include +#include #include #include @@ -46,7 +46,7 @@ public: Grid(int xSegments, int ySegments, TriangleSoup::Positions usePositions = TriangleSoup::Positions::No, TriangleSoup::TextureCoordinates useTextures = - TriangleSoup::TextureCoordinates::No, + TriangleSoup::TextureCoordinates::No, TriangleSoup::Normals useNormals = TriangleSoup::Normals::No); virtual ~Grid() = default; @@ -71,14 +71,14 @@ protected: * ySegments. Where the number of vertices in each direction is the number * of segments + 1. */ - virtual std::vector CreateElements(int xSegments, int ySegments) = 0; + virtual std::vector createElements(int xSegments, int ySegments) = 0; /** * Should return the positions of vertices for a grid with size xSegments * * ySegments. Where the number of vertices in each direction is the * number of segments + 1. */ - virtual std::vector CreatePositions(int xSegments, int ySegments) = 0; + virtual std::vector createPositions(int xSegments, int ySegments) = 0; /** * Should return the texture coordinates of vertices for a grid with size @@ -86,14 +86,14 @@ protected: * each direction is the number of segments + 1. */ virtual std::vector - CreateTextureCoordinates(int xSegments, int ySegments) = 0; + createTextureCoordinates(int xSegments, int ySegments) = 0; /** * Should return the normals of vertices for a grid with size xSegments * * ySegments. Where the number of vertices in each direction is the number * of segments + 1. */ - virtual std::vector CreateNormals(int xSegments, int ySegments) = 0; + virtual std::vector createNormals(int xSegments, int ySegments) = 0; std::unique_ptr _geometry; diff --git a/modules/globebrowsing/meshes/skirtedgrid.cpp b/modules/globebrowsing/meshes/skirtedgrid.cpp index 9ccea91d28..ee632af4b6 100644 --- a/modules/globebrowsing/meshes/skirtedgrid.cpp +++ b/modules/globebrowsing/meshes/skirtedgrid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -40,20 +40,20 @@ SkirtedGrid::SkirtedGrid(unsigned int xSegments, unsigned int ySegments, : Grid(xSegments, ySegments, usePositions, useTextureCoordinates, useNormals) { _geometry = std::make_unique( - CreateElements(xSegments, ySegments), + createElements(xSegments, ySegments), usePositions, useTextureCoordinates, useNormals ); if (usePositions) { - _geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments)); + _geometry->setVertexPositions(createPositions(_xSegments, _ySegments)); } if (useTextureCoordinates) { - _geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments)); + _geometry->setVertexTextureCoordinates(createTextureCoordinates(_xSegments, _ySegments)); } if (useNormals) { - _geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments)); + _geometry->setVertexNormals(createNormals(_xSegments, _ySegments)); } } @@ -80,7 +80,7 @@ inline size_t SkirtedGrid::numVertices(int xSegments, int ySegments) { return (xSegments + 1) * (ySegments + 1); } -std::vector SkirtedGrid::CreateElements(int xSegments, int ySegments) { +std::vector SkirtedGrid::createElements(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector elements; @@ -115,13 +115,13 @@ std::vector SkirtedGrid::CreateElements(int xSegments, int ySegments) { return elements; } -std::vector SkirtedGrid::CreatePositions(int xSegments, int ySegments) { +std::vector SkirtedGrid::createPositions(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector positions; positions.reserve(numVertices(xSegments, ySegments)); // Copy from 2d texture coordinates and use as template to create positions - std::vector templateTextureCoords = CreateTextureCoordinates( + std::vector templateTextureCoords = createTextureCoordinates( xSegments, ySegments ); for (const auto& c : templateTextureCoords) { @@ -137,7 +137,7 @@ std::vector SkirtedGrid::CreatePositions(int xSegments, int ySegments return positions; } -std::vector SkirtedGrid::CreateTextureCoordinates(int xSegments, int ySegments) +std::vector SkirtedGrid::createTextureCoordinates(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector textureCoordinates; @@ -162,7 +162,7 @@ std::vector SkirtedGrid::CreateTextureCoordinates(int xSegments, int return textureCoordinates; } -std::vector SkirtedGrid::CreateNormals(int xSegments, int ySegments) { +std::vector SkirtedGrid::createNormals(int xSegments, int ySegments) { validate(xSegments, ySegments); std::vector normals; normals.reserve(numVertices(xSegments + 2, ySegments + 2)); diff --git a/modules/globebrowsing/meshes/skirtedgrid.h b/modules/globebrowsing/meshes/skirtedgrid.h index 1119c206f9..06749e2719 100644 --- a/modules/globebrowsing/meshes/skirtedgrid.h +++ b/modules/globebrowsing/meshes/skirtedgrid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,7 @@ #include -#include +#include #include namespace openspace { @@ -61,10 +61,10 @@ public: virtual int ySegments() const; private: - virtual std::vector CreateElements(int xRes, int yRes); - virtual std::vector CreatePositions(int xRes, int yRes); - virtual std::vector CreateTextureCoordinates(int xRes, int yRes); - virtual std::vector CreateNormals(int xRes, int yRes); + std::vector createElements(int xRes, int yRes) override; + std::vector createPositions(int xRes, int yRes) override; + std::vector createTextureCoordinates(int xRes, int yRes) override; + std::vector createNormals(int xRes, int yRes) override; void validate(int xSegments, int ySegments); diff --git a/modules/globebrowsing/meshes/trianglesoup.cpp b/modules/globebrowsing/meshes/trianglesoup.cpp index 74e9508d96..91b17e075a 100644 --- a/modules/globebrowsing/meshes/trianglesoup.cpp +++ b/modules/globebrowsing/meshes/trianglesoup.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/meshes/trianglesoup.h b/modules/globebrowsing/meshes/trianglesoup.h index dd84ef078f..d754b0b244 100644 --- a/modules/globebrowsing/meshes/trianglesoup.h +++ b/modules/globebrowsing/meshes/trianglesoup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -54,6 +54,7 @@ public: Positions usePositions = Positions::No, TextureCoordinates useTextures = TextureCoordinates::No, Normals useNormals = Normals::No); + ~TriangleSoup(); // Setters @@ -78,14 +79,13 @@ protected: bool _useTextureCoordinates; bool _useVertexNormals; - typedef struct { - public: + struct Vertex { GLfloat position[4]; GLfloat texture[2]; GLfloat normal[3]; private: GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase - } Vertex; + }; // Vertex data std::vector _vertexData; diff --git a/modules/globebrowsing/other/concurrentjobmanager.h b/modules/globebrowsing/other/concurrentjobmanager.h index 5020d0682e..4f0ba44136 100644 --- a/modules/globebrowsing/other/concurrentjobmanager.h +++ b/modules/globebrowsing/other/concurrentjobmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/concurrentjobmanager.inl b/modules/globebrowsing/other/concurrentjobmanager.inl index 58c75a7a9c..b7b862fd87 100644 --- a/modules/globebrowsing/other/concurrentjobmanager.inl +++ b/modules/globebrowsing/other/concurrentjobmanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/concurrentqueue.h b/modules/globebrowsing/other/concurrentqueue.h index 7495b0124d..e66f64e734 100644 --- a/modules/globebrowsing/other/concurrentqueue.h +++ b/modules/globebrowsing/other/concurrentqueue.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/concurrentqueue.inl b/modules/globebrowsing/other/concurrentqueue.inl index 17b610c997..f493cacc7f 100644 --- a/modules/globebrowsing/other/concurrentqueue.inl +++ b/modules/globebrowsing/other/concurrentqueue.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/distanceswitch.cpp b/modules/globebrowsing/other/distanceswitch.cpp index 2cee681bc6..971f2e32d0 100644 --- a/modules/globebrowsing/other/distanceswitch.cpp +++ b/modules/globebrowsing/other/distanceswitch.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,9 +24,13 @@ #include +#include + namespace openspace { namespace globebrowsing { +DistanceSwitch::~DistanceSwitch() {} + bool DistanceSwitch::initialize() { for (int i = 0; i < _renderables.size(); ++i) { _renderables[i]->initialize(); diff --git a/modules/globebrowsing/other/distanceswitch.h b/modules/globebrowsing/other/distanceswitch.h index 009a3300ae..59a87d41c8 100644 --- a/modules/globebrowsing/other/distanceswitch.h +++ b/modules/globebrowsing/other/distanceswitch.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,13 +25,12 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___DISTANCESWITCH___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___DISTANCESWITCH___H__ -#include - #include #include namespace openspace { +class Renderable; struct RenderData; struct UpdateData; @@ -43,6 +42,8 @@ namespace globebrowsing { */ class DistanceSwitch { public: + ~DistanceSwitch(); + bool initialize(); bool deinitialize(); @@ -67,4 +68,4 @@ private: } // namespace globebrowsing } // openspace -#endif //__OPENSPACE_MODULE_GLOBEBROWSING___DISTANCESWITCH___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___DISTANCESWITCH___H__ diff --git a/modules/globebrowsing/other/lrucache.h b/modules/globebrowsing/other/lrucache.h index 2758ed0c3d..d410ab4985 100644 --- a/modules/globebrowsing/other/lrucache.h +++ b/modules/globebrowsing/other/lrucache.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -46,8 +46,6 @@ public: private: void clean(); -// Member varialbes -private: std::list> _itemList; std::unordered_map _itemMap; size_t _cacheSize; diff --git a/modules/globebrowsing/other/lrucache.inl b/modules/globebrowsing/other/lrucache.inl index 83c37bbc88..4aacc3132e 100644 --- a/modules/globebrowsing/other/lrucache.inl +++ b/modules/globebrowsing/other/lrucache.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/statscollector.cpp b/modules/globebrowsing/other/statscollector.cpp index 721a24b092..cd074b089b 100644 --- a/modules/globebrowsing/other/statscollector.cpp +++ b/modules/globebrowsing/other/statscollector.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/statscollector.h b/modules/globebrowsing/other/statscollector.h index 447e308ee4..1d78e81eb9 100644 --- a/modules/globebrowsing/other/statscollector.h +++ b/modules/globebrowsing/other/statscollector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___STATS_TRACKER___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___STATS_TRACKER___H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___STATS_COLLECTOR___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___STATS_COLLECTOR___H__ #include @@ -35,14 +35,6 @@ namespace openspace { namespace globebrowsing { -template -using StatsRecord = std::unordered_map; - -template -struct StatsCollection : public std::vector> { - std::set keys; -}; - template class TemplatedStatsCollector { public: @@ -67,6 +59,14 @@ public: void writeNextRecord(std::ostream& os); private: + template + using StatsRecord = std::unordered_map; + + template + struct StatsCollection : public std::vector> { + std::set keys; + }; + StatsCollection _data; T _dummy; // used when disabled bool& _enabled; @@ -121,4 +121,4 @@ private: #include "statscollector.inl" -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___STATS_TRACKER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___STATS_COLLECTOR___H__ diff --git a/modules/globebrowsing/other/statscollector.inl b/modules/globebrowsing/other/statscollector.inl index bd41627cb2..f1ce37ec71 100644 --- a/modules/globebrowsing/other/statscollector.inl +++ b/modules/globebrowsing/other/statscollector.inl @@ -1,9 +1,8 @@ -#include "statscollector.h" /***************************************************************************************** * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/threadpool.cpp b/modules/globebrowsing/other/threadpool.cpp index 517fa183c6..10de678202 100644 --- a/modules/globebrowsing/other/threadpool.cpp +++ b/modules/globebrowsing/other/threadpool.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/other/threadpool.h b/modules/globebrowsing/other/threadpool.h index 683d0064e7..97bf25190b 100644 --- a/modules/globebrowsing/other/threadpool.h +++ b/modules/globebrowsing/other/threadpool.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/rendering/chunkrenderer.cpp b/modules/globebrowsing/rendering/chunkrenderer.cpp index cca9bd191c..d7296db626 100644 --- a/modules/globebrowsing/rendering/chunkrenderer.cpp +++ b/modules/globebrowsing/rendering/chunkrenderer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,7 +28,8 @@ #include #include #include -#include +#include +#include namespace { const char* keyFrame = "Frame"; @@ -82,10 +83,10 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData( { const TileIndex& tileIndex = chunk.tileIndex(); - LayerShaderPreprocessingData layeredTexturePreprocessingData; + LayerShaderManager::LayerShaderPreprocessingData layeredTexturePreprocessingData; for (size_t i = 0; i < LayerManager::NUM_LAYER_GROUPS; i++) { - LayerGroupPreprocessingData layeredTextureInfo; + LayerShaderManager::LayerShaderPreprocessingData::LayerGroupPreprocessingData layeredTextureInfo; auto layerGroup = _layerManager->layerGroup(i); layeredTextureInfo.lastLayerIdx = layerGroup.activeLayers().size() - 1; layeredTextureInfo.layerBlendingEnabled = layerGroup.layerBlendingEnabled(); @@ -111,7 +112,7 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData( std::to_string(Chunk::DEFAULT_HEIGHT))); // Now the shader program can be accessed - ProgramObject* programObject = + ghoul::opengl::ProgramObject* programObject = layeredShaderManager->programObject( layeredTexturePreprocessingData); @@ -142,7 +143,7 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData( void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data){ - ProgramObject* programObject = getActivatedProgramWithTileData( + ghoul::opengl::ProgramObject* programObject = getActivatedProgramWithTileData( _globalLayerShaderManager, _globalGpuLayerManager, chunk); @@ -216,7 +217,7 @@ void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& da void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& data) { - ProgramObject* programObject = getActivatedProgramWithTileData( + ghoul::opengl::ProgramObject* programObject = getActivatedProgramWithTileData( _localLayerShaderManager, _localGpuLayerManager, chunk); diff --git a/modules/globebrowsing/rendering/chunkrenderer.h b/modules/globebrowsing/rendering/chunkrenderer.h index 2086f29d2d..026263905f 100644 --- a/modules/globebrowsing/rendering/chunkrenderer.h +++ b/modules/globebrowsing/rendering/chunkrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -100,4 +100,4 @@ private: } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNK_RENDERER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNK_RENDERER___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpuchunktile.cpp b/modules/globebrowsing/rendering/gpu/gpuchunktile.cpp new file mode 100644 index 0000000000..b5a92339b7 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpuchunktile.cpp @@ -0,0 +1,52 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPUChunkTile::setValue(ghoul::opengl::ProgramObject* programObject, + const ChunkTile& chunkTile) +{ + gpuTexture.setValue(programObject, chunkTile.tile.texture); + gpuTileUvTransform.setValue(programObject, chunkTile.uvTransform); +} + +void GPUChunkTile::bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase) +{ + gpuTexture.bind(programObject, nameBase + "textureSampler"); + gpuTileUvTransform.bind(programObject, nameBase + "uvTransform."); +} + +void GPUChunkTile::deactivate() { + gpuTexture.deactivate(); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/include/openspace/interaction/deviceidentifier.h b/modules/globebrowsing/rendering/gpu/gpuchunktile.h similarity index 59% rename from include/openspace/interaction/deviceidentifier.h rename to modules/globebrowsing/rendering/gpu/gpuchunktile.h index 828bf4fa42..490c7a81bd 100644 --- a/include/openspace/interaction/deviceidentifier.h +++ b/modules/globebrowsing/rendering/gpu/gpuchunktile.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,58 +22,57 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___DEVICEIDENTIFIER___H__ -#define __OPENSPACE_CORE___DEVICEIDENTIFIER___H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___GPUCHUNKTILE___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPUCHUNKTILE___H__ -// std includes -#include -#include -#include +#include + +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} namespace openspace { +namespace globebrowsing { -#define MAXDEVICES 16 +struct ChunkTile; -enum class InputDevice {NONE, UNKNOWN, SPACENAVIGATOR, XBOX}; - -class DeviceIdentifier { +/** + * Manages a GPU representation of a ChunkTile + */ +class GPUChunkTile { public: - static DeviceIdentifier& ref(); - virtual ~DeviceIdentifier(); - static void init(); - static void deinit(); - static bool isInitialized(); - - void scanDevices(); - const int numberOfDevices() const; - const InputDevice type(const int device) const; - - void update(); - void update(const int device); + /** + * Sets the value of ChunkTile to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + void setValue(ghoul::opengl::ProgramObject* programObject, + const ChunkTile& chunkTile); + + /** + * Binds GLSL variables with identifiers starting with + * nameBase within the provided shader program with this object. + * After this method has been called, users may invoke setValue. + */ + void bind(ghoul::opengl::ProgramObject* programObject, const std::string& nameBase); + + /** + * Deactivates any TextureUnits assigned by this object. + * This method should be called after the OpenGL draw call. + */ + void deactivate(); - const int getButtons(const int device, unsigned char **buttons = nullptr) const; - const int getAxes(const int device, float **axespos = nullptr) const; - void get(const int device, unsigned char **buttons, float **axespos) const; - private: - // singleton - static DeviceIdentifier* this_; - DeviceIdentifier(void); - DeviceIdentifier(const DeviceIdentifier& src); - DeviceIdentifier& operator=(const DeviceIdentifier& rhs); - - - // member variables - int devices_; - std::array inputDevice_; - std::array numberOfAxes_; - std::array numberOfButtons_; - std::array axesPos_; - std::array buttons_; - + GPUTexture gpuTexture; + GPUTileUvTransform gpuTileUvTransform; }; +} // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_CORE___DEVICEIDENTIFIER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPUCHUNKTILE___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpuchunktilepile.cpp b/modules/globebrowsing/rendering/gpu/gpuchunktilepile.cpp new file mode 100644 index 0000000000..a07cd46857 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpuchunktilepile.cpp @@ -0,0 +1,60 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + + +namespace openspace { +namespace globebrowsing { + +void GPUChunkTilePile::setValue(ghoul::opengl::ProgramObject* programObject, + const ChunkTilePile& chunkTilePile) +{ + ghoul_assert( + _gpuChunkTiles.size() == chunkTilePile.size(), + "GPU and CPU ChunkTilePile must have same size!" + ); + for (size_t i = 0; i < _gpuChunkTiles.size(); ++i) { + _gpuChunkTiles[i].setValue(programObject, chunkTilePile[i]); + } +} + +void GPUChunkTilePile::bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase, int pileSize) +{ + _gpuChunkTiles.resize(pileSize); + for (size_t i = 0; i < _gpuChunkTiles.size(); ++i) { + std::string nameExtension = "chunkTile" + std::to_string(i) + "."; + _gpuChunkTiles[i].bind(programObject, nameBase + nameExtension); + } +} + +void GPUChunkTilePile::deactivate() { + for (auto& t : _gpuChunkTiles) { + t.deactivate(); + } +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gpuchunktilepile.h b/modules/globebrowsing/rendering/gpu/gpuchunktilepile.h new file mode 100644 index 0000000000..e09b516370 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpuchunktilepile.h @@ -0,0 +1,77 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPUCHUNKTILEPILE___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPUCHUNKTILEPILE___H__ + +#include + +#include + +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +/** + * Manages a GPU representation of a ChunkTilePile + */ +class GPUChunkTilePile { +public: + + /** + * Sets the value of ChunkTilePile to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + void setValue(ghoul::opengl::ProgramObject* programObject, + const ChunkTilePile& chunkTilePile); + + /** + * Binds this object with GLSL variables with identifiers starting + * with nameBase within the provided shader program. + * After this method has been called, users may invoke setValue. + */ + void bind(ghoul::opengl::ProgramObject* programObject, const std::string& nameBase, + int pileSize); + /** + * Deactivates any TextureUnits assigned by this object. + * This method should be called after the OpenGL draw call. + */ + void deactivate(); + +private: + std::vector _gpuChunkTiles; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPUCHUNKTILEPILE___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpuheightlayer.cpp b/modules/globebrowsing/rendering/gpu/gpuheightlayer.cpp new file mode 100644 index 0000000000..5b77c34f9b --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpuheightlayer.cpp @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPUHeightLayer::setValue(ghoul::opengl::ProgramObject* programObject, + const Layer& layer, const TileIndex& tileIndex, + int pileSize) +{ + GPULayer::setValue(programObject, layer, tileIndex, pileSize); + _gpuDepthTransform.setValue(programObject, layer.tileProvider()->depthTransform()); +} + +void GPUHeightLayer::bind(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const std::string& nameBase, int pileSize) +{ + GPULayer::bind(programObject, layer, nameBase, pileSize); + _gpuDepthTransform.bind(programObject, nameBase + "depthTransform."); +} + + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gpuheightlayer.h b/modules/globebrowsing/rendering/gpu/gpuheightlayer.h new file mode 100644 index 0000000000..d2fca786cf --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpuheightlayer.h @@ -0,0 +1,74 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPUHEIGHTLAYER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPUHEIGHTLAYER___H__ + +#include + +#include +#include +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +class Layer; +struct TileIndex; + +/** + * Manages a GPU representation of a Layer representing + * a height map. + */ +class GPUHeightLayer : public GPULayer { +public: + + /** + * Sets the value of Layer to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + virtual void setValue(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const TileIndex& tileIndex, int pileSize); + + /** + * Binds this object with GLSL variables with identifiers starting + * with nameBase within the provided shader program. + * After this method has been called, users may invoke setValue. + */ + virtual void bind(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const std::string& nameBase, int pileSize); + +private: + GPUTileDepthTransform _gpuDepthTransform; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPUHEIGHTLAYER___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpulayer.cpp b/modules/globebrowsing/rendering/gpu/gpulayer.cpp new file mode 100644 index 0000000000..99fb35e915 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayer.cpp @@ -0,0 +1,52 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPULayer::setValue(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const TileIndex& tileIndex, int pileSize) +{ + ChunkTilePile chunkTilePile = layer.getChunkTilePile(tileIndex, pileSize); + gpuChunkTilePile.setValue(programObject, chunkTilePile); + gpuRenderSettings.setValue(programObject, layer.renderSettings()); +} + +void GPULayer::bind(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const std::string& nameBase, int pileSize) +{ + gpuChunkTilePile.bind(programObject, nameBase + "pile.", pileSize); + gpuRenderSettings.bind(programObject, nameBase + "settings."); +} + +void GPULayer::deactivate() { + gpuChunkTilePile.deactivate(); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gpulayer.h b/modules/globebrowsing/rendering/gpu/gpulayer.h new file mode 100644 index 0000000000..7fb7f2914c --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayer.h @@ -0,0 +1,79 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYER___H__ + +#include +#include +#include +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +class Layer; +struct TileIndex; + +/** + * Manages a GPU representation of a Layer + */ +class GPULayer { +public: + + /** + * Sets the value of Layer to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + virtual void setValue(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const TileIndex& tileIndex, int pileSize); + + /** + * Binds this object with GLSL variables with identifiers starting + * with nameBase within the provided shader program. + * After this method has been called, users may invoke setValue. + */ + virtual void bind(ghoul::opengl::ProgramObject* programObject, const Layer& layer, + const std::string& nameBase, int pileSize); + + /** + * Deactivates any TextureUnits assigned by this object. + * This method should be called after the OpenGL draw call. + */ + virtual void deactivate(); + +private: + GPUChunkTilePile gpuChunkTilePile; + GPULayerRenderSettings gpuRenderSettings; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYER___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpulayergroup.cpp b/modules/globebrowsing/rendering/gpu/gpulayergroup.cpp new file mode 100644 index 0000000000..f18d21e52c --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayergroup.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPULayerGroup::setValue(ghoul::opengl::ProgramObject* programObject, + const LayerGroup& layerGroup, const TileIndex& tileIndex) +{ + auto& activeLayers = layerGroup.activeLayers(); + ghoul_assert( + activeLayers.size() == _gpuActiveLayers.size(), + "GPU and CPU active layers must have same size!" + ); + for (int i = 0; i < activeLayers.size(); ++i) { + _gpuActiveLayers[i]->setValue( + programObject, + *activeLayers[i], + tileIndex, + layerGroup.pileSize() + ); + } +} + +void GPULayerGroup::bind(ghoul::opengl::ProgramObject* programObject, + const LayerGroup& layerGroup, const std::string& nameBase, + int category) +{ + auto activeLayers = layerGroup.activeLayers(); + _gpuActiveLayers.resize(activeLayers.size()); + int pileSize = layerGroup.pileSize(); + for (size_t i = 0; i < _gpuActiveLayers.size(); ++i) { + // should maybe a proper GPULayer factory + _gpuActiveLayers[i] = (category == LayerManager::HeightLayers) ? + std::make_unique() : + std::make_unique(); + std::string nameExtension = "[" + std::to_string(i) + "]."; + _gpuActiveLayers[i]->bind( + programObject, + *activeLayers[i], + nameBase + nameExtension, + pileSize + ); + } +} + +void GPULayerGroup::deactivate() { + for (std::unique_ptr& l : _gpuActiveLayers) { + l->deactivate(); + } +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gpulayergroup.h b/modules/globebrowsing/rendering/gpu/gpulayergroup.h new file mode 100644 index 0000000000..753cd6a6e5 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayergroup.h @@ -0,0 +1,86 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERGROUP___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERGROUP___H__ + +#include +#include + +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +struct ChunkTile; +class Layer; +class LayerRenderSettings; +struct TileDepthTransform; +struct TileUvTransform; + +struct LayerGroup; +struct TileIndex; + +/** + * Manages a GPU representation of a LayerGroup + */ +class GPULayerGroup { +public: + + /** + * Sets the value of LayerGroup to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + virtual void setValue(ghoul::opengl::ProgramObject* programObject, + const LayerGroup& layerGroup, const TileIndex& tileIndex); + + /** + * Binds this object with GLSL variables with identifiers starting + * with nameBase within the provided shader program. + * After this method has been called, users may invoke setValue. + */ + virtual void bind(ghoul::opengl::ProgramObject* programObject, + const LayerGroup& layerGroup, const std::string& nameBase, int category); + + /** + * Deactivates any TextureUnits assigned by this object. + * This method should be called after the OpenGL draw call. + */ + virtual void deactivate(); + +private: + std::vector> _gpuActiveLayers; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERGROUP___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpulayermanager.cpp b/modules/globebrowsing/rendering/gpu/gpulayermanager.cpp new file mode 100644 index 0000000000..0f908031a6 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayermanager.cpp @@ -0,0 +1,66 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPULayerManager::setValue(ghoul::opengl::ProgramObject* programObject, + const LayerManager& layerManager, + const TileIndex& tileIndex) +{ + auto layerGroups = layerManager.layerGroups(); + for (size_t i = 0; i < layerGroups.size(); ++i) { + _gpuLayerGroups[i]->setValue(programObject, *layerGroups[i], tileIndex); + } +} + +void GPULayerManager::bind(ghoul::opengl::ProgramObject* programObject, + const LayerManager& layerManager) +{ + auto layerGroups = layerManager.layerGroups(); + if (_gpuLayerGroups.size() != layerGroups.size()) { + _gpuLayerGroups.resize(layerGroups.size()); + for (auto& gpuLayerGroup : _gpuLayerGroups){ + gpuLayerGroup = std::make_unique(); + } + } + + for (size_t i = 0; i < layerGroups.size(); ++i) { + std::string nameBase = LayerManager::LAYER_GROUP_NAMES[i]; + _gpuLayerGroups[i]->bind(programObject, *layerGroups[i], nameBase, i); + } +} + +void GPULayerManager::deactivate() { + for (std::unique_ptr& l : _gpuLayerGroups) { + l->deactivate(); + } +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gpulayermanager.h b/modules/globebrowsing/rendering/gpu/gpulayermanager.h new file mode 100644 index 0000000000..ee065e8f2f --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayermanager.h @@ -0,0 +1,76 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERMANAGER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERMANAGER___H__ + +#include +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +class LayerManager; + +/** + * Manages a GPU representation of a LayerGroup + */ +class GPULayerManager { +public: + /** + * Sets the value of LayerGroup to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + virtual void setValue(ghoul::opengl::ProgramObject* programObject, + const LayerManager& layerManager, const TileIndex& tileIndex); + + /** + * Binds this object with GLSL variables with identifiers starting + * with nameBase within the provided shader program. + * After this method has been called, users may invoke setValue. + */ + virtual void bind(ghoul::opengl::ProgramObject* programObject, + const LayerManager& layerManager); + + /** + * Deactivates any TextureUnits assigned by this object. + * This method should be called after the OpenGL draw call. + */ + virtual void deactivate(); + +private: + std::vector> _gpuLayerGroups; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERMANAGER___H__ diff --git a/modules/globebrowsing/rendering/gpu/gpulayerrendersettings.cpp b/modules/globebrowsing/rendering/gpu/gpulayerrendersettings.cpp new file mode 100644 index 0000000000..f849df1c20 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayerrendersettings.cpp @@ -0,0 +1,49 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPULayerRenderSettings::setValue(ghoul::opengl::ProgramObject* programObject, + const LayerRenderSettings& layerSettings) +{ + gpuOpacity.setValue(programObject, layerSettings.opacity.value()); + gpuGamma.setValue(programObject, layerSettings.gamma.value()); + gpuMultiplier.setValue(programObject, layerSettings.multiplier.value()); +} + +void GPULayerRenderSettings::bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase) +{ + gpuOpacity.bind(programObject, nameBase + "opacity"); + gpuGamma.bind(programObject, nameBase + "gamma"); + gpuMultiplier.bind(programObject, nameBase + "multiplier"); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gpulayerrendersettings.h b/modules/globebrowsing/rendering/gpu/gpulayerrendersettings.h new file mode 100644 index 0000000000..53ba536b42 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gpulayerrendersettings.h @@ -0,0 +1,70 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERRENDERSETTINGS___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERRENDERSETTINGS___H__ + +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +class LayerRenderSettings; + +/** + * Manages a GPU representation of a LayerRenderSettings + */ +class GPULayerRenderSettings{ +public: + /** + * Sets the value of LayerRenderSettings to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + void setValue(ghoul::opengl::ProgramObject* programObject, + const LayerRenderSettings& layerSettings); + + /** + * Binds this object with GLSL variables with identifiers starting + * with nameBase within the provided shader program. + * After this method has been called, users may invoke setValue. + */ + void bind(ghoul::opengl::ProgramObject* programObject, const std::string& nameBase); + +private: + GPUData gpuOpacity; + GPUData gpuGamma; + GPUData gpuMultiplier; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPULAYERRENDERSETTINGS___H__ diff --git a/modules/globebrowsing/rendering/gpu/gputiledepthtransform.cpp b/modules/globebrowsing/rendering/gpu/gputiledepthtransform.cpp new file mode 100644 index 0000000000..deb14fabc7 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gputiledepthtransform.cpp @@ -0,0 +1,47 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void GPUTileDepthTransform::setValue(ghoul::opengl::ProgramObject* programObject, + const TileDepthTransform& depthTransform) +{ + _gpuDepthOffset.setValue(programObject, depthTransform.depthOffset); + _gpuDepthScale.setValue(programObject, depthTransform.depthScale); +} + +void GPUTileDepthTransform::bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase) +{ + _gpuDepthOffset.bind(programObject, nameBase + "depthOffset"); + _gpuDepthScale.bind(programObject, nameBase + "depthScale"); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpu/gputiledepthtransform.h b/modules/globebrowsing/rendering/gpu/gputiledepthtransform.h new file mode 100644 index 0000000000..4e16940280 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gputiledepthtransform.h @@ -0,0 +1,70 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPUTILEDEPTHTRANSFORM___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPUTILEDEPTHTRANSFORM___H__ + +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +struct TileDepthTransform; + +/** + * Manages a GPU representation of a TileDepthTransform + */ +class GPUTileDepthTransform { +public: + /** + * Sets the value of TileDepthTransform to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + void setValue(ghoul::opengl::ProgramObject* programObject, + const TileDepthTransform& depthTransform); + + /** + * Binds GLSL variables with identifiers starting with + * nameBase within the provided shader program with this object. + * After this method has been called, users may invoke setValue. + */ + void bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase); + +private: + GPUData _gpuDepthOffset; + GPUData _gpuDepthScale; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPUTILEDEPTHTRANSFORM___H__ diff --git a/modules/newhorizons/rendering/writeToTexture.h b/modules/globebrowsing/rendering/gpu/gputileuvtransform.cpp similarity index 66% rename from modules/newhorizons/rendering/writeToTexture.h rename to modules/globebrowsing/rendering/gpu/gputileuvtransform.cpp index cd0e584f60..477b02b75b 100644 --- a/modules/newhorizons/rendering/writeToTexture.h +++ b/modules/globebrowsing/rendering/gpu/gputileuvtransform.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,50 +22,30 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __RENDERABLEPLANET_H__ -#define __RENDERABLEPLANET_H__ +#include -// open space includes -#include - -#include -#include - -// ghoul includes -#include -#include +//#include +//#include +//#include +//#include +#include namespace openspace { +namespace globebrowsing { -namespace planetgeometry { -class PlanetGeometry; +void GPUTileUvTransform::setValue(ghoul::opengl::ProgramObject* programObject, + const TileUvTransform& tileUvTransform) +{ + _gpuUvOffset.setValue(programObject, tileUvTransform.uvOffset); + _gpuUvScale.setValue(programObject, tileUvTransform.uvScale); } -class RenderablePlanet : public Renderable { -public: - RenderablePlanet(const ghoul::Dictionary& dictionary); - ~RenderablePlanet(); - - bool initialize() override; - bool deinitialize() override; - - void render(const RenderData& data) override; - void update(const UpdateData& data) override; - -protected: - void loadTexture(); - -private: - properties::StringProperty _colorTexturePath; - ghoul::opengl::ProgramObject* _programObject; - ghoul::opengl::Texture* _texture; - planetgeometry::PlanetGeometry* _geometry; - - glm::dmat3 _stateMatrix; - - std::string _target; -}; +void GPUTileUvTransform::bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase) +{ + _gpuUvOffset.bind(programObject, nameBase + "uvOffset"); + _gpuUvScale.bind(programObject, nameBase + "uvScale"); +} +} // namespace globebrowsing } // namespace openspace - -#endif // __RENDERABLEPLANET_H__ \ No newline at end of file diff --git a/modules/globebrowsing/rendering/gpu/gputileuvtransform.h b/modules/globebrowsing/rendering/gpu/gputileuvtransform.h new file mode 100644 index 0000000000..066eebfc47 --- /dev/null +++ b/modules/globebrowsing/rendering/gpu/gputileuvtransform.h @@ -0,0 +1,70 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPUTILEUVTRANSFORM___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___GPUTILEUVTRANSFORM___H__ + +#include + +#include + +namespace ghoul { namespace opengl { +class ProgramObject; +}} + +namespace openspace { +namespace globebrowsing { + +struct TileUvTransform; + +/** + * Manages a GPU representation of a TileUvTransform + */ +class GPUTileUvTransform { +public: + /** + * Sets the value of TileUvTransform to its corresponding + * GPU struct. OBS! Users must ensure bind has been + * called before setting using this method. + */ + void setValue(ghoul::opengl::ProgramObject* programObject, + const TileUvTransform& uvTransform); + + /** + * Binds GLSL variables with identifiers starting with + * nameBase within the provided shader program with this object. + * After this method has been called, users may invoke setValue. + */ + void bind(ghoul::opengl::ProgramObject* programObject, + const std::string& nameBase); + +private: + GPUData _gpuUvOffset; + GPUData _gpuUvScale; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPUTILEUVTRANSFORM___H__ diff --git a/modules/globebrowsing/rendering/gpulayermanager.cpp b/modules/globebrowsing/rendering/gpulayermanager.cpp deleted file mode 100644 index 355b0af5ae..0000000000 --- a/modules/globebrowsing/rendering/gpulayermanager.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 - -namespace openspace { -namespace globebrowsing { - -void GPUTileUvTransform::setValue(ProgramObject* programObject, - const TileUvTransform& tileUvTransform) -{ - gpuUvOffset.setValue(programObject, tileUvTransform.uvOffset); - gpuUvScale.setValue(programObject, tileUvTransform.uvScale); -} - -void GPUTileUvTransform::bind(ProgramObject* programObject, const std::string& nameBase) { - gpuUvOffset.bind(programObject, nameBase + "uvOffset"); - gpuUvScale.bind(programObject, nameBase + "uvScale"); -} - -void GPUTileDepthTransform::setValue(ProgramObject* programObject, - const TileDepthTransform& depthTransform) -{ - gpuDepthOffset.setValue(programObject, depthTransform.depthOffset); - gpuDepthScale.setValue(programObject, depthTransform.depthScale); -} - -void GPUTileDepthTransform::bind(ProgramObject* programObject, - const std::string& nameBase) -{ - gpuDepthOffset.bind(programObject, nameBase + "depthOffset"); - gpuDepthScale.bind(programObject, nameBase + "depthScale"); -} - -void GPUChunkTile::setValue(ProgramObject* programObject, const ChunkTile& chunkTile) { - gpuTexture.setValue(programObject, chunkTile.tile.texture); - gpuTileUvTransform.setValue(programObject, chunkTile.uvTransform); -} - -void GPUChunkTile::bind(ProgramObject* programObject, const std::string& nameBase) { - gpuTexture.bind(programObject, nameBase + "textureSampler"); - gpuTileUvTransform.bind(programObject, nameBase + "uvTransform."); -} - -void GPUChunkTile::deactivate() { - gpuTexture.deactivate(); -} - -void GPUChunkTilePile::setValue(ProgramObject* programObject, - const ChunkTilePile& chunkTilePile) -{ - ghoul_assert( - gpuChunkTiles.size() == chunkTilePile.chunkTiles.size(), - "GPU and CPU ChunkTilePile must have same size!" - ); - for (size_t i = 0; i < gpuChunkTiles.size(); ++i) { - gpuChunkTiles[i].setValue(programObject, chunkTilePile.chunkTiles[i]); - } -} - -void GPUChunkTilePile::bind(ProgramObject* programObject, const std::string& nameBase, - int pileSize) -{ - gpuChunkTiles.resize(pileSize); - for (size_t i = 0; i < gpuChunkTiles.size(); ++i) { - std::string nameExtension = "chunkTile" + std::to_string(i) + "."; - gpuChunkTiles[i].bind(programObject, nameBase + nameExtension); - } -} - -void GPUChunkTilePile::deactivate() { - for (auto& gpuChunkTile : gpuChunkTiles) { - gpuChunkTile.deactivate(); - } -} - - -void GPULayerRenderSettings::setValue(ProgramObject* programObject, - const LayerRenderSettings& layerSettings) -{ - gpuOpacity.setValue(programObject, layerSettings.opacity.value()); - gpuGamma.setValue(programObject, layerSettings.gamma.value()); - gpuMultiplier.setValue(programObject, layerSettings.multiplier.value()); -} - -void GPULayerRenderSettings::bind(ProgramObject* programObject, - const std::string& nameBase) -{ - gpuOpacity.bind(programObject, nameBase + "opacity"); - gpuGamma.bind(programObject, nameBase + "gamma"); - gpuMultiplier.bind(programObject, nameBase + "multiplier"); -} - -void GPULayer::setValue(ProgramObject* programObject, const Layer& layer, - const TileIndex& tileIndex, int pileSize) -{ - ChunkTilePile chunkTilePile = layer.getChunkTilePile(tileIndex, pileSize); - gpuChunkTilePile.setValue(programObject, chunkTilePile); - gpuRenderSettings.setValue(programObject, layer.renderSettings()); -} - -void GPULayer::bind(ProgramObject* programObject, const Layer& layer, - const std::string& nameBase, int pileSize) -{ - gpuChunkTilePile.bind(programObject, nameBase + "pile.", pileSize); - gpuRenderSettings.bind(programObject, nameBase + "settings."); -} - -void GPULayer::deactivate() { - gpuChunkTilePile.deactivate(); -} - -void GPUHeightLayer::setValue(ProgramObject* programObject, const Layer& layer, - const TileIndex& tileIndex, int pileSize) -{ - GPULayer::setValue(programObject, layer, tileIndex, pileSize); - gpuDepthTransform.setValue(programObject, layer.tileProvider()->depthTransform()); -} - -void GPUHeightLayer::bind(ProgramObject* programObject, const Layer& layer, - const std::string& nameBase, int pileSize) -{ - GPULayer::bind(programObject, layer, nameBase, pileSize); - gpuDepthTransform.bind(programObject, nameBase + "depthTransform."); -} - -void GPULayerGroup::setValue(ProgramObject* programObject, const LayerGroup& layerGroup, - const TileIndex& tileIndex) -{ - auto& activeLayers = layerGroup.activeLayers(); - ghoul_assert( - activeLayers.size() == gpuActiveLayers.size(), - "GPU and CPU active layers must have same size!" - ); - for (int i = 0; i < activeLayers.size(); ++i) { - gpuActiveLayers[i]->setValue( - programObject, - *activeLayers[i], - tileIndex, - layerGroup.pileSize() - ); - } -} - -void GPULayerGroup::bind(ProgramObject* programObject, const LayerGroup& layerGroup, - const std::string& nameBase, int category) -{ - auto activeLayers = layerGroup.activeLayers(); - gpuActiveLayers.resize(activeLayers.size()); - int pileSize = layerGroup.pileSize(); - for (size_t i = 0; i < gpuActiveLayers.size(); ++i) { - // should maybe a proper GPULayer factory - gpuActiveLayers[i] = (category == LayerManager::HeightLayers) ? - std::make_unique() : - std::make_unique(); - std::string nameExtension = "[" + std::to_string(i) + "]."; - gpuActiveLayers[i]->bind( - programObject, - *activeLayers[i], - nameBase + nameExtension, - pileSize - ); - } -} - -void GPULayerGroup::deactivate() { - for (size_t i = 0; i < gpuActiveLayers.size(); ++i) { - gpuActiveLayers[i]->deactivate(); - } -} - -void GPULayerManager::setValue(ProgramObject* programObject, - const LayerManager& layerManager, - const TileIndex& tileIndex) -{ - auto layerGroups = layerManager.layerGroups(); - for (size_t i = 0; i < layerGroups.size(); ++i) { - gpuLayerGroups[i]->setValue(programObject, *layerGroups[i], tileIndex); - } -} - -void GPULayerManager::bind(ProgramObject* programObject, const LayerManager& layerManager) -{ - auto layerGroups = layerManager.layerGroups(); - if (gpuLayerGroups.size() != layerGroups.size()) { - gpuLayerGroups.resize(layerGroups.size()); - for (auto& gpuLayerGroup : gpuLayerGroups){ - gpuLayerGroup = std::make_unique(); - } - } - - for (size_t i = 0; i < layerGroups.size(); ++i) { - std::string nameBase = LayerManager::LAYER_GROUP_NAMES[i]; - gpuLayerGroups[i]->bind(programObject, *layerGroups[i], nameBase, i); - } -} - -void GPULayerManager::deactivate() { - for (size_t i = 0; i < gpuLayerGroups.size(); ++i) { - gpuLayerGroups[i]->deactivate(); - } -} - -} // namespace globebrowsing -} // namespace openspace diff --git a/modules/globebrowsing/rendering/gpulayermanager.h b/modules/globebrowsing/rendering/gpulayermanager.h deleted file mode 100644 index ec9834a610..0000000000 --- a/modules/globebrowsing/rendering/gpulayermanager.h +++ /dev/null @@ -1,320 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 __OPENSPACE_MODULE_GLOBEBROWSING___GPU_LAYER_MANAGER___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___GPU_LAYER_MANAGER___H__ - -#include - -#include - -namespace ghoul { namespace opengl { -class ProgramObject; -}} - -namespace openspace { -namespace globebrowsing { - -struct ChunkTile; -struct ChunkTilePile; -class Layer; -class LayerRenderSettings; -struct TileDepthTransform; -struct TileIndex; -struct TileUvTransform; - -/** - * Manages a GPU representation of a TileUvTransform - */ -class GPUTileUvTransform { -public: - /** - * Sets the value of TileUvTransform to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - void setValue(ProgramObject* programObject, const TileUvTransform& uvTransform); - - /** - * Binds GLSL variables with identifiers starting with - * nameBase within the provided shader program with this object. - * After this method has been called, users may invoke setValue. - */ - void bind(ProgramObject* programObject, const std::string& nameBase); - -private: - GPUData gpuUvOffset; - GPUData gpuUvScale; -}; - - -/** - * Manages a GPU representation of a TileDepthTransform - */ -class GPUTileDepthTransform { -public: - /** - * Sets the value of TileDepthTransform to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - void setValue(ProgramObject* programObject, const TileDepthTransform& depthTransform); - - /** - * Binds GLSL variables with identifiers starting with - * nameBase within the provided shader program with this object. - * After this method has been called, users may invoke setValue. - */ - void bind(ProgramObject* programObject, const std::string& nameBase); - -private: - GPUData gpuDepthOffset; - GPUData gpuDepthScale; -}; - -/** - * Manages a GPU representation of a ChunkTile - */ -class GPUChunkTile { -public: - - /** - * Sets the value of ChunkTile to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - void setValue(ProgramObject* programObject, const ChunkTile& chunkTile); - - /** - * Binds GLSL variables with identifiers starting with - * nameBase within the provided shader program with this object. - * After this method has been called, users may invoke setValue. - */ - void bind(ProgramObject* programObject, const std::string& nameBase); - - /** - * Deactivates any TextureUnits assigned by this object. - * This method should be called after the OpenGL draw call. - */ - void deactivate(); - -private: - GPUTexture gpuTexture; - GPUTileUvTransform gpuTileUvTransform; -}; - -/** - * Manages a GPU representation of a ChunkTilePile - */ -class GPUChunkTilePile{ -public: - - /** - * Sets the value of ChunkTilePile to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - void setValue(ProgramObject* programObject, const ChunkTilePile& chunkTilePile); - - /** - * Binds this object with GLSL variables with identifiers starting - * with nameBase within the provided shader program. - * After this method has been called, users may invoke setValue. - */ - void bind(ProgramObject* programObject, const std::string& nameBase, - int pileSize); - /** - * Deactivates any TextureUnits assigned by this object. - * This method should be called after the OpenGL draw call. - */ - void deactivate(); - -private: - std::vector gpuChunkTiles; -}; - - -class LayerRenderSettings; - -/** - * Manages a GPU representation of a LayerRenderSettings - */ -class GPULayerRenderSettings{ -public: - - /** - * Sets the value of LayerRenderSettings to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - void setValue(ProgramObject* programObject, const LayerRenderSettings& layerSettings); - - /** - * Binds this object with GLSL variables with identifiers starting - * with nameBase within the provided shader program. - * After this method has been called, users may invoke setValue. - */ - void bind(ProgramObject* programObject, const std::string& nameBase); - -private: - GPUData gpuOpacity; - GPUData gpuGamma; - GPUData gpuMultiplier; -}; - - -class Layer; - -/** - * Manages a GPU representation of a Layer - */ -class GPULayer { -public: - - /** - * Sets the value of Layer to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - virtual void setValue(ProgramObject* programObject, const Layer& layer, - const TileIndex& tileIndex, int pileSize); - - /** - * Binds this object with GLSL variables with identifiers starting - * with nameBase within the provided shader program. - * After this method has been called, users may invoke setValue. - */ - virtual void bind(ProgramObject* programObject, const Layer& layer, - const std::string& nameBase, int pileSize); - - /** - * Deactivates any TextureUnits assigned by this object. - * This method should be called after the OpenGL draw call. - */ - virtual void deactivate(); - -private: - GPUChunkTilePile gpuChunkTilePile; - GPULayerRenderSettings gpuRenderSettings; -}; - - -/** - * Manages a GPU representation of a Layer representing - * a height map. - */ -class GPUHeightLayer : public GPULayer { -public: - - /** - * Sets the value of Layer to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - virtual void setValue(ProgramObject* programObject, const Layer& layer, - const TileIndex& tileIndex, int pileSize); - - /** - * Binds this object with GLSL variables with identifiers starting - * with nameBase within the provided shader program. - * After this method has been called, users may invoke setValue. - */ - virtual void bind(ProgramObject* programObject, const Layer& layer, - const std::string& nameBase, int pileSize); - -private: - GPUTileDepthTransform gpuDepthTransform; -}; - -class LayerGroup; - -/** - * Manages a GPU representation of a LayerGroup - */ -class GPULayerGroup{ -public: - - /** - * Sets the value of LayerGroup to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - virtual void setValue(ProgramObject* programObject, const LayerGroup& layerGroup, - const TileIndex& tileIndex); - - /** - * Binds this object with GLSL variables with identifiers starting - * with nameBase within the provided shader program. - * After this method has been called, users may invoke setValue. - */ - virtual void bind(ProgramObject* programObject, const LayerGroup& layerGroup, - const std::string& nameBase, int category); - - /** - * Deactivates any TextureUnits assigned by this object. - * This method should be called after the OpenGL draw call. - */ - virtual void deactivate(); - -private: - std::vector> gpuActiveLayers; -}; - -class LayerManager; - -/** - * Manages a GPU representation of a LayerGroup - */ -class GPULayerManager{ -public: - - /** - * Sets the value of LayerGroup to its corresponding - * GPU struct. OBS! Users must ensure bind has been - * called before setting using this method. - */ - virtual void setValue(ProgramObject* programObject, const LayerManager& layerManager, - const TileIndex& tileIndex); - - /** - * Binds this object with GLSL variables with identifiers starting - * with nameBase within the provided shader program. - * After this method has been called, users may invoke setValue. - */ - virtual void bind(ProgramObject* programObject, const LayerManager& layerManager); - - /** - * Deactivates any TextureUnits assigned by this object. - * This method should be called after the OpenGL draw call. - */ - virtual void deactivate(); - -private: - std::vector> gpuLayerGroups; -}; - -} // namespace globebrowsing -} // namespace openspace - -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___GPU_LAYER_MANAGER___H__ diff --git a/modules/globebrowsing/rendering/layer/layer.cpp b/modules/globebrowsing/rendering/layer/layer.cpp new file mode 100644 index 0000000000..ba8eb7a39f --- /dev/null +++ b/modules/globebrowsing/rendering/layer/layer.cpp @@ -0,0 +1,57 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +Layer::Layer(const ghoul::Dictionary& layerDict) + : properties::PropertyOwner(layerDict.value("Name")) + , _enabled(properties::BoolProperty("enabled", "enabled", false)) +{ + _tileProvider = std::shared_ptr( + tileprovider::TileProvider::createFromDictionary(layerDict)); + + // Something else went wrong and no exception was thrown + if (_tileProvider == nullptr) { + throw ghoul::RuntimeError("Unable to create TileProvider '" + name() + "'"); + } + + bool enabled = false; // defaults to false if unspecified + layerDict.getValue("Enabled", enabled); + _enabled.setValue(enabled); + addProperty(_enabled); + + addPropertySubOwner(_renderSettings); +} + +ChunkTilePile Layer::getChunkTilePile(const TileIndex& tileIndex, int pileSize) const { + return std::move(_tileProvider->getChunkTilePile(tileIndex, pileSize)); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/layer/layer.h b/modules/globebrowsing/rendering/layer/layer.h new file mode 100644 index 0000000000..e933a70836 --- /dev/null +++ b/modules/globebrowsing/rendering/layer/layer.h @@ -0,0 +1,66 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___LAYER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYER___H__ + +#include + +#include +#include + +#include + +namespace openspace { +namespace globebrowsing { + +namespace tileprovider { + class TileProvider; +} + +/** + * Simple struct which is used to enable/disable TileProvider + * and associate is with a name. It also holds layer specific information + * which is used in rendering of layer. + */ +class Layer : public properties::PropertyOwner { +public: + Layer(const ghoul::Dictionary& layerDict); + + ChunkTilePile getChunkTilePile(const TileIndex& tileIndex, int pileSize) const; + + bool enabled() const { return _enabled.value(); } + tileprovider::TileProvider* tileProvider() const { return _tileProvider.get(); } + const LayerRenderSettings& renderSettings() const { return _renderSettings; } + +private: + properties::BoolProperty _enabled; + std::shared_ptr _tileProvider; + LayerRenderSettings _renderSettings; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYER___H__ diff --git a/modules/globebrowsing/rendering/layer/layergroup.cpp b/modules/globebrowsing/rendering/layer/layergroup.cpp new file mode 100644 index 0000000000..a5ff471a98 --- /dev/null +++ b/modules/globebrowsing/rendering/layer/layergroup.cpp @@ -0,0 +1,85 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +LayerGroup::LayerGroup(std::string name) + : properties::PropertyOwner(std::move(name)) + , _levelBlendingEnabled("blendTileLevels", "blend tile levels", true) +{ + addProperty(_levelBlendingEnabled); +} + +LayerGroup::LayerGroup(std::string name, const ghoul::Dictionary& dict) + : LayerGroup(std::move(name)) +{ + for (size_t i = 0; i < dict.size(); i++) { + std::string dictKey = std::to_string(i + 1); + ghoul::Dictionary layerDict = dict.value(dictKey); + + try { + _layers.push_back(std::make_shared(layerDict)); + } + catch (const ghoul::RuntimeError& e) { + LERRORC(e.component, e.message); + continue; + } + //_layers.push_back(std::make_shared(layerDict)); + } + + for (const auto& layer : _layers) { + addPropertySubOwner(layer.get()); + } +} + +void LayerGroup::update() { + _activeLayers.clear(); + + for (const auto& layer : _layers) { + if (layer->enabled()) { + layer->tileProvider()->update(); + _activeLayers.push_back(layer); + } + } +} + +const std::vector>& LayerGroup::layers() const { + return _layers; +} + +const std::vector>& LayerGroup::activeLayers() const { + return _activeLayers; +} + +int LayerGroup::pileSize() const{ + return _levelBlendingEnabled.value() ? 3 : 1; +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/geometry/convexhull.h b/modules/globebrowsing/rendering/layer/layergroup.h similarity index 61% rename from modules/globebrowsing/geometry/convexhull.h rename to modules/globebrowsing/rendering/layer/layergroup.h index 7fc1da2c86..be7241de2c 100644 --- a/modules/globebrowsing/geometry/convexhull.h +++ b/modules/globebrowsing/rendering/layer/layergroup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,51 +22,50 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___CONVEX_HULL___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___CONVEX_HULL___H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___LAYERGROUP___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYERGROUP___H__ -#include +#include -#include -#include - -#include +#include +#include namespace openspace { namespace globebrowsing { -// Implementation based on -// http://www.sanfoundry.com/cpp-program-implement-graham-scan-algorithm-find-convex-hull/ +namespace tileprovider { + class TileProvider; +} -class ConvexHull2 { -public: - static ConvexHull2 grahamScan_NOT_THREAD_SAFE(std::vector& points, - int yMinIndex = -1); +/** + * Convenience class for dealing with multiple Layers. + */ +struct LayerGroup : public properties::PropertyOwner { + LayerGroup(std::string name); + LayerGroup(std::string name, const ghoul::Dictionary& dict); - const std::vector points() const; + /// Updates all layers tile providers within this group + void update(); - bool intersects(const ConvexHull2& o) const; + /// @returns const vector of all layers + const std::vector>& layers() const; - AABB1 projectedRegion(glm::vec2 direction) const; - -private: - bool hasPerpendicularLineWhereProjectedPointsOverlap(const ConvexHull2& other) const; + /// @returns const vector of all active layers + const std::vector>& activeLayers() const; - static int compare(const void* vp1, const void* vp2); + /// @returns the size of the pile to be used in rendering of this layer + int pileSize() const; - static glm::vec2 oneBelowTop(std::stack&); - static void swap(glm::vec2& p1, glm::vec2& p2); - - // returns 0 = colinear, 1 = clockwise, 2 = counterclockwise - static int orientation(const glm::vec2& p, const glm::vec2& q, const glm::vec2& r); - static float dist(const glm::vec2& p1, const glm::vec2& p2); + bool layerBlendingEnabled() const { return _levelBlendingEnabled.value(); } private: - static glm::vec2 p0; - std::vector _points; + std::vector> _layers; + std::vector> _activeLayers; + + properties::BoolProperty _levelBlendingEnabled; }; -} // namespace globebrowsing +} // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CONVEX_HULL___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYERGROUP___H__ diff --git a/modules/globebrowsing/rendering/layermanager.cpp b/modules/globebrowsing/rendering/layer/layermanager.cpp similarity index 59% rename from modules/globebrowsing/rendering/layermanager.cpp rename to modules/globebrowsing/rendering/layer/layermanager.cpp index b4dc908b5a..3dce21ede6 100644 --- a/modules/globebrowsing/rendering/layermanager.cpp +++ b/modules/globebrowsing/rendering/layer/layermanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,104 +22,14 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include +#include #include namespace openspace { namespace globebrowsing { -LayerRenderSettings::LayerRenderSettings() - : opacity(properties::FloatProperty("opacity", "opacity", 1.f, 0.f, 1.f)) - , gamma(properties::FloatProperty("gamma", "gamma", 1, 0, 5)) - , multiplier(properties::FloatProperty("multiplier", "multiplier", 1.f, 0.f, 20.f)) -{ - setName("settings"); - - addProperty(opacity); - addProperty(gamma); - addProperty(multiplier); -} - -Layer::Layer(const ghoul::Dictionary& layerDict) - : _enabled(properties::BoolProperty("enabled", "enabled", false)) -{ - std::string layerName = "error!"; - layerDict.getValue("Name", layerName); - setName(layerName); - - _tileProvider = std::shared_ptr( - TileProvider::createFromDictionary(layerDict)); - - // Something else went wrong and no exception was thrown - if (_tileProvider == nullptr) { - throw ghoul::RuntimeError("Unable to create TileProvider '" + name() + "'"); - } - - bool enabled = false; // defaults to false if unspecified - layerDict.getValue("Enabled", enabled); - _enabled.setValue(enabled); - addProperty(_enabled); - - addPropertySubOwner(_renderSettings); -} - -ChunkTilePile Layer::getChunkTilePile(const TileIndex& tileIndex, int pileSize) const { - return std::move(_tileProvider->getChunkTilePile(tileIndex, pileSize)); -} - -LayerGroup::LayerGroup(std::string name) - : _levelBlendingEnabled("blendTileLevels", "blend tile levels", true) -{ - setName(std::move(name)); - addProperty(_levelBlendingEnabled); -} - -LayerGroup::LayerGroup(std::string name, const ghoul::Dictionary& dict) - : LayerGroup(std::move(name)) -{ - for (size_t i = 0; i < dict.size(); i++) { - std::string dictKey = std::to_string(i + 1); - ghoul::Dictionary layerDict = dict.value(dictKey); - - try { - _layers.push_back(std::make_shared(layerDict)); - } - catch (const ghoul::RuntimeError& e) { - LERRORC(e.component, e.message); - continue; - } - //_layers.push_back(std::make_shared(layerDict)); - } - - for (const auto& layer : _layers) { - addPropertySubOwner(layer.get()); - } -} - -void LayerGroup::update() { - _activeLayers.clear(); - - for (const auto& layer : _layers) { - if (layer->enabled()) { - layer->tileProvider()->update(); - _activeLayers.push_back(layer); - } - } -} - -const std::vector>& LayerGroup::layers() const { - return _layers; -} - -const std::vector>& LayerGroup::activeLayers() const { - return _activeLayers; -} - -int LayerGroup::pileSize() const{ - return _levelBlendingEnabled.value() ? 3 : 1; -} - const char* LayerManager::LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = { "HeightLayers", "ColorLayers", @@ -130,9 +40,9 @@ const char* LayerManager::LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = { "WaterMasks" }; -LayerManager::LayerManager(const ghoul::Dictionary& layerGroupsDict) { - setName("Layers"); - +LayerManager::LayerManager(const ghoul::Dictionary& layerGroupsDict) + : properties::PropertyOwner("Layers") +{ if (NUM_LAYER_GROUPS != layerGroupsDict.size()) { throw ghoul::RuntimeError( "Number of Layer Groups must be equal to " + NUM_LAYER_GROUPS); diff --git a/modules/globebrowsing/rendering/layer/layermanager.h b/modules/globebrowsing/rendering/layer/layermanager.h new file mode 100644 index 0000000000..dfcc2b916c --- /dev/null +++ b/modules/globebrowsing/rendering/layer/layermanager.h @@ -0,0 +1,73 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___LAYERMANAGER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYERMANAGER___H__ + +#include + +#include + +namespace openspace { +namespace globebrowsing { + +struct LayerGroup; + +/** + * Manages multiple LayerGroups. + */ +class LayerManager : public properties::PropertyOwner { +public: + static const size_t NUM_LAYER_GROUPS = 7; + static const char* LAYER_GROUP_NAMES[NUM_LAYER_GROUPS]; + enum LayerGroupId { + HeightLayers, + ColorLayers, + ColorOverlays, + GrayScaleLayers, + GrayScaleColorOverlays, + NightLayers, + WaterMasks + }; + + LayerManager(const ghoul::Dictionary& textureCategoriesDictionary); + + const LayerGroup& layerGroup(size_t groupId); + const LayerGroup& layerGroup(LayerGroupId); + + bool hasAnyBlendingLayersEnabled() const; + + const std::vector>& layerGroups() const; + + void update(); + void reset(bool includingDisabled = false); + +private: + std::vector> _layerGroups; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYERMANAGER___H__ diff --git a/modules/globebrowsing/rendering/layer/layerrendersettings.cpp b/modules/globebrowsing/rendering/layer/layerrendersettings.cpp new file mode 100644 index 0000000000..17c0784d6f --- /dev/null +++ b/modules/globebrowsing/rendering/layer/layerrendersettings.cpp @@ -0,0 +1,42 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +LayerRenderSettings::LayerRenderSettings() + : properties::PropertyOwner("Settings") + , opacity(properties::FloatProperty("opacity", "opacity", 1.f, 0.f, 1.f)) + , gamma(properties::FloatProperty("gamma", "gamma", 1, 0, 5)) + , multiplier(properties::FloatProperty("multiplier", "multiplier", 1.f, 0.f, 20.f)) +{ + addProperty(opacity); + addProperty(gamma); + addProperty(multiplier); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/rendering/layer/layerrendersettings.h b/modules/globebrowsing/rendering/layer/layerrendersettings.h new file mode 100644 index 0000000000..7b794d8b3b --- /dev/null +++ b/modules/globebrowsing/rendering/layer/layerrendersettings.h @@ -0,0 +1,45 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___LAYERRENDERSETTINGS___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYERRENDERSETTINGS___H__ + +#include + +#include + +namespace openspace { +namespace globebrowsing { + +struct LayerRenderSettings : public properties::PropertyOwner { + LayerRenderSettings(); + properties::FloatProperty opacity; + properties::FloatProperty gamma; + properties::FloatProperty multiplier; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYERRENDERSETTINGS___H__ diff --git a/modules/globebrowsing/rendering/layermanager.h b/modules/globebrowsing/rendering/layermanager.h deleted file mode 100644 index 71963643a0..0000000000 --- a/modules/globebrowsing/rendering/layermanager.h +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 __OPENSPACE_MODULE_GLOBEBROWSING___LAYERMANAGER___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYERMANAGER___H__ - -#include - -#include - -#include -#include - -namespace openspace { -namespace globebrowsing { - -class TileProvider; - -struct LayerRenderSettings : public properties::PropertyOwner { - LayerRenderSettings(); - properties::FloatProperty opacity; - properties::FloatProperty gamma; - properties::FloatProperty multiplier; -}; - -/** - * Simple struct which is used to enable/disable TileProvider - * and associate is with a name. It also holds layer specific information - * which is used in rendering of layer. - */ -class Layer : public properties::PropertyOwner { -public: - Layer(const ghoul::Dictionary& layerDict); - - ChunkTilePile getChunkTilePile(const TileIndex& tileIndex, int pileSize) const; - - bool enabled() const { return _enabled.value(); } - TileProvider* tileProvider() const { return _tileProvider.get(); } - const LayerRenderSettings& renderSettings() const { return _renderSettings; } - -private: - properties::BoolProperty _enabled; - std::shared_ptr _tileProvider; - LayerRenderSettings _renderSettings; -}; - -/** - * Convenience class for dealing with multiple Layers. - */ -struct LayerGroup : public properties::PropertyOwner { - LayerGroup(std::string name); - LayerGroup(std::string name, const ghoul::Dictionary& dict); - - /// Updates all layers tile providers within this group - void update(); - - /// @returns const vector of all layers - const std::vector>& layers() const; - - /// @returns const vector of all active layers - const std::vector>& activeLayers() const; - - /// @returns the size of the pile to be used in rendering of this layer - int pileSize() const; - - bool layerBlendingEnabled() const { return _levelBlendingEnabled.value(); } - -private: - std::vector> _layers; - std::vector> _activeLayers; - - properties::BoolProperty _levelBlendingEnabled; -}; - -/** - * Manages multiple LayerGroups. - */ -class LayerManager : public properties::PropertyOwner { -public: - static const size_t NUM_LAYER_GROUPS = 7; - static const char* LAYER_GROUP_NAMES[NUM_LAYER_GROUPS]; - enum LayerGroupId { - HeightLayers, - ColorLayers, - ColorOverlays, - GrayScaleLayers, - GrayScaleColorOverlays, - NightLayers, - WaterMasks - }; - - LayerManager(const ghoul::Dictionary& textureCategoriesDictionary); - - const LayerGroup& layerGroup(size_t groupId); - const LayerGroup& layerGroup(LayerGroupId); - - bool hasAnyBlendingLayersEnabled() const; - - const std::vector>& layerGroups() const; - - void update(); - void reset(bool includingDisabled = false); - -private: - std::vector> _layerGroups; -}; - -} // namespace globebrowsing -} // namespace openspace - -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYERMANAGER___H__ diff --git a/modules/globebrowsing/rendering/layershadermanager.cpp b/modules/globebrowsing/rendering/layershadermanager.cpp index f43b73068a..419699eaef 100644 --- a/modules/globebrowsing/rendering/layershadermanager.cpp +++ b/modules/globebrowsing/rendering/layershadermanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,13 +32,13 @@ namespace openspace { namespace globebrowsing { -bool LayerGroupPreprocessingData::operator==( +bool LayerShaderManager::LayerShaderPreprocessingData::LayerGroupPreprocessingData::operator==( const LayerGroupPreprocessingData& other) const { return lastLayerIdx == other.lastLayerIdx && layerBlendingEnabled == other.layerBlendingEnabled; } -bool LayerShaderPreprocessingData::operator==( +bool LayerShaderManager::LayerShaderPreprocessingData::operator==( const LayerShaderPreprocessingData& other) const { if (layeredTextureInfo.size() != other.layeredTextureInfo.size() || keyValuePairs.size() != other.keyValuePairs.size()) { @@ -73,7 +73,7 @@ LayerShaderManager::~LayerShaderManager() { } } -ProgramObject* LayerShaderManager::programObject( +ghoul::opengl::ProgramObject* LayerShaderManager::programObject( LayerShaderPreprocessingData preprocessingData) { _updatedOnLastCall = false; @@ -128,7 +128,7 @@ void LayerShaderManager::recompileShaderProgram( ); ghoul_assert(_programObject != nullptr, "Failed to initialize programObject!"); - using IgnoreError = ProgramObject::IgnoreError; + using IgnoreError = ghoul::opengl::ProgramObject::ProgramObject::IgnoreError; _programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes); } diff --git a/modules/globebrowsing/rendering/layershadermanager.h b/modules/globebrowsing/rendering/layershadermanager.h index 4138bdd55b..2a5572841c 100644 --- a/modules/globebrowsing/rendering/layershadermanager.h +++ b/modules/globebrowsing/rendering/layershadermanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___LAYER_SHADER_MANAGER___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___LAYER_SHADER_MANAGER___H__ -#include +#include #include #include @@ -35,40 +35,41 @@ namespace opengl { class ProgramObject; } } + namespace openspace { namespace globebrowsing { -/** - * Settings per texture group that contains shader preprocessing information. - */ -struct LayerGroupPreprocessingData { - int lastLayerIdx; - bool layerBlendingEnabled; - bool operator==(const LayerGroupPreprocessingData& other) const; -}; - -/** - * Data needed for shader preprocessing before compiling a layered texture shader - * program. - * - * If a LayerShaderPreprocessingData is compared with another it can - * be determined wheter or not a LayerShaderManager needs to - * recompile its shader program. For each TextureGroup there is - * information about how many layers it has and whether or not to blend the texture - * levels. - */ -struct LayerShaderPreprocessingData { - std::array - layeredTextureInfo; - std::vector > keyValuePairs; - bool operator==(const LayerShaderPreprocessingData& other) const; -}; - /** * This class has ownership of an updated shader program for rendering tiles. */ class LayerShaderManager { public: + /** + * Data needed for shader preprocessing before compiling a layered texture shader + * program. + * + * If a LayerShaderPreprocessingData is compared with another it can + * be determined wheter or not a LayerShaderManager needs to + * recompile its shader program. For each TextureGroup there is + * information about how many layers it has and whether or not to blend the texture + * levels. + */ + struct LayerShaderPreprocessingData { + /** + * Settings per texture group that contains shader preprocessing information. + */ + struct LayerGroupPreprocessingData { + int lastLayerIdx; + bool layerBlendingEnabled; + bool operator==(const LayerGroupPreprocessingData& other) const; + }; + + std::array + layeredTextureInfo; + std::vector > keyValuePairs; + bool operator==(const LayerShaderPreprocessingData& other) const; + }; + LayerShaderManager( const std::string& shaderName, const std::string& vsPath, @@ -82,7 +83,7 @@ public: * from the last time this function was called the shader program will be * recompiled before returned. */ - ProgramObject* programObject( + ghoul::opengl::ProgramObject* programObject( LayerShaderPreprocessingData preprocessingData); bool updatedOnLastCall(); @@ -91,7 +92,7 @@ private: void recompileShaderProgram(LayerShaderPreprocessingData preprocessingData); - std::unique_ptr _programObject; + std::unique_ptr _programObject; LayerShaderPreprocessingData _preprocessingData; const std::string _shaderName; @@ -104,4 +105,4 @@ private: } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYER_SHADER_MANAGER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYER_SHADER_MANAGER___H__ diff --git a/modules/globebrowsing/shaders/blending.hglsl b/modules/globebrowsing/shaders/blending.hglsl index 595758cfe6..e6b6b64bfd 100644 --- a/modules/globebrowsing/shaders/blending.hglsl +++ b/modules/globebrowsing/shaders/blending.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -145,4 +145,4 @@ vec3 hsv2rgb(vec3 c) return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } -#endif \ No newline at end of file +#endif diff --git a/modules/globebrowsing/shaders/ellipsoid.hglsl b/modules/globebrowsing/shaders/ellipsoid.hglsl index 779c951de8..19c702e2e2 100644 --- a/modules/globebrowsing/shaders/ellipsoid.hglsl +++ b/modules/globebrowsing/shaders/ellipsoid.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -103,4 +103,4 @@ Intersection rayIntersectEllipsoid( return Intersection(true, min(root1, root2), max(root1, root2)); } -#endif // ELLIPSOID_HGLSL \ No newline at end of file +#endif // ELLIPSOID_HGLSL diff --git a/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl b/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl index 9b1764e690..0bdf633ec6 100644 --- a/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl +++ b/modules/globebrowsing/shaders/globalchunkedlodpatch_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl b/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl index f9aefe6daf..86904a5db8 100644 --- a/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl +++ b/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -85,4 +85,4 @@ void main() { gl_Position = fs_position; ellipsoidNormalCameraSpace = mat3(modelViewTransform) * pair.normal; positionCameraSpace = vec3(modelViewTransform * vec4(pair.position, 1)); -} \ No newline at end of file +} diff --git a/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl b/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl index 7776e071db..4601915b0c 100644 --- a/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl +++ b/modules/globebrowsing/shaders/localchunkedlodpatch_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl b/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl index 901c2c3b67..8665e88030 100644 --- a/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl +++ b/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -91,4 +91,4 @@ void main() { gl_Position = fs_position; ellipsoidNormalCameraSpace = patchNormalCameraSpace; positionCameraSpace = p; -} \ No newline at end of file +} diff --git a/modules/globebrowsing/shaders/pointglobe_fs.glsl b/modules/globebrowsing/shaders/pointglobe_fs.glsl index 539f2bacb3..cafeb66d3b 100644 --- a/modules/globebrowsing/shaders/pointglobe_fs.glsl +++ b/modules/globebrowsing/shaders/pointglobe_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/globebrowsing/shaders/pointglobe_vs.glsl b/modules/globebrowsing/shaders/pointglobe_vs.glsl index 041d021d01..011e9bdf07 100644 --- a/modules/globebrowsing/shaders/pointglobe_vs.glsl +++ b/modules/globebrowsing/shaders/pointglobe_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -51,4 +51,4 @@ void main() { gl_PointSize = pointSizeNDC.x * 2 * windowWidth; gl_Position = vs_positionClipSpace; -} \ No newline at end of file +} diff --git a/modules/globebrowsing/shaders/texturetilemapping.hglsl b/modules/globebrowsing/shaders/texturetilemapping.hglsl index ffc8e8ebf8..ed1fe063d0 100644 --- a/modules/globebrowsing/shaders/texturetilemapping.hglsl +++ b/modules/globebrowsing/shaders/texturetilemapping.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -386,4 +386,4 @@ vec4 calculateWater( return currentColor + vec4(specularTotal, 1); } -#endif // TEXTURETILEMAPPING_HGLSL \ No newline at end of file +#endif // TEXTURETILEMAPPING_HGLSL diff --git a/modules/globebrowsing/shaders/tile.hglsl b/modules/globebrowsing/shaders/tile.hglsl index 8f390c07ca..b48e79486b 100644 --- a/modules/globebrowsing/shaders/tile.hglsl +++ b/modules/globebrowsing/shaders/tile.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -156,4 +156,4 @@ vec4 getTexVal(const ChunkTilePile chunkTilePile, const LevelWeights w, const ve } -#endif // TEXTURETILE_HGLSL \ No newline at end of file +#endif // TEXTURETILE_HGLSL diff --git a/modules/globebrowsing/shaders/tilefragcolor.hglsl b/modules/globebrowsing/shaders/tilefragcolor.hglsl index 26fa48c32e..2b3252becd 100644 --- a/modules/globebrowsing/shaders/tilefragcolor.hglsl +++ b/modules/globebrowsing/shaders/tilefragcolor.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -232,4 +232,4 @@ vec4 getTileFragColor(){ } -#endif ///TILE_FRAG_COLOR_HGLSL \ No newline at end of file +#endif ///TILE_FRAG_COLOR_HGLSL diff --git a/modules/globebrowsing/shaders/tilevertexheight.hglsl b/modules/globebrowsing/shaders/tilevertexheight.hglsl index ac4e4d4bf1..6733b30c96 100644 --- a/modules/globebrowsing/shaders/tilevertexheight.hglsl +++ b/modules/globebrowsing/shaders/tilevertexheight.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -123,4 +123,4 @@ float getTileVertexSkirtLength(){ return tileVertexIsSkirtVertex() ? skirtLength : 0.0; } -#endif // TILE_VERTEX_HEIGHT_HGLSL \ No newline at end of file +#endif // TILE_VERTEX_HEIGHT_HGLSL diff --git a/modules/globebrowsing/tile/asynctilereader.cpp b/modules/globebrowsing/tile/asynctilereader.cpp index e79744ab33..893bf70b58 100644 --- a/modules/globebrowsing/tile/asynctilereader.cpp +++ b/modules/globebrowsing/tile/asynctilereader.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,69 +24,13 @@ #include +#include #include #include namespace openspace { namespace globebrowsing { -void TileLoadJob::execute() { - _rawTile = _tileDataset->readTileData(_chunkIndex); -} - -std::shared_ptr TileLoadJob::product() const { - return _rawTile; -} - -DiskCachedTileLoadJob::DiskCachedTileLoadJob( - std::shared_ptr textureDataProvider, - const TileIndex& tileIndex, - std::shared_ptr tdc, - CacheMode m) - : TileLoadJob(textureDataProvider, tileIndex) - , _tileDiskCache(tdc) - , _mode(m) -{} - -void DiskCachedTileLoadJob::execute() { - _rawTile = nullptr; - - switch (_mode) { - case CacheMode::Disabled: - _rawTile = _tileDataset->readTileData(_chunkIndex); - break; - - case CacheMode::ReadOnly: - _rawTile = _tileDiskCache->get(_chunkIndex); - if (_rawTile == nullptr) { - _rawTile = _tileDataset->readTileData(_chunkIndex); - } - break; - - case CacheMode::ReadAndWrite: - _rawTile = _tileDiskCache->get(_chunkIndex); - if (_rawTile == nullptr) { - _rawTile = _tileDataset->readTileData(_chunkIndex); - _tileDiskCache->put(_chunkIndex, _rawTile); - } - break; - - case CacheMode::WriteOnly: - _rawTile = _tileDataset->readTileData(_chunkIndex); - _tileDiskCache->put(_chunkIndex, _rawTile); - break; - - case CacheMode::CacheHitsOnly: - _rawTile = _tileDiskCache->get(_chunkIndex); - if (_rawTile == nullptr) { - RawTile res = RawTile::createDefaultRes(); - res.tileIndex = _chunkIndex; - _rawTile = std::make_shared(res); - } - break; - } -} - AsyncTileDataProvider::AsyncTileDataProvider(std::shared_ptr tileDataset, std::shared_ptr pool) : _tileDataset(tileDataset) diff --git a/modules/globebrowsing/tile/asynctilereader.h b/modules/globebrowsing/tile/asynctilereader.h index 748c95c62d..445cd0c6f0 100644 --- a/modules/globebrowsing/tile/asynctilereader.h +++ b/modules/globebrowsing/tile/asynctilereader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,65 +22,21 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___ASYNC_TILE_DATA_PROVIDER___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___ASYNC_TILE_DATA_PROVIDER___H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___ASYNC_TILE_READER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___ASYNC_TILE_READER___H__ #include -#include + +#include #include namespace openspace { namespace globebrowsing { - + +class RawTile; class TileDataset; -struct LoadJob : public Job { - virtual void execute() = 0; - virtual std::shared_ptr product() const = 0; -}; - -struct TileLoadJob : LoadJob { - TileLoadJob(std::shared_ptr textureDataProvider, - const TileIndex& tileIndex) - : _tileDataset(textureDataProvider) - , _chunkIndex(tileIndex) - {} - - virtual ~TileLoadJob() = default; - - virtual void execute() override; - - virtual std::shared_ptr product() const override; - -protected: - TileIndex _chunkIndex; - std::shared_ptr _tileDataset; - std::shared_ptr _rawTile; -}; - -class TileDiskCache; - -struct DiskCachedTileLoadJob : public TileLoadJob { - enum CacheMode { - Disabled, - ReadOnly, - ReadAndWrite, - WriteOnly, - CacheHitsOnly, - }; - - DiskCachedTileLoadJob(std::shared_ptr textureDataProvider, - const TileIndex& tileIndex, std::shared_ptr tdc, - CacheMode cacheMode = CacheMode::ReadOnly); - - void execute() override; - -protected: - std::shared_ptr _tileDiskCache; - CacheMode _mode; -}; - class AsyncTileDataProvider { public: AsyncTileDataProvider(std::shared_ptr textureDataProvider, @@ -101,10 +57,10 @@ protected: private: std::shared_ptr _tileDataset; ConcurrentJobManager _concurrentJobManager; - std::unordered_map _enqueuedTileRequests; + std::unordered_map _enqueuedTileRequests; }; } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___ASYNC_TILE_DATA_PROVIDER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___ASYNC_TILE_READER___H__ diff --git a/modules/globebrowsing/tile/chunktile.h b/modules/globebrowsing/tile/chunktile.h index 05f765c449..5679123b9a 100644 --- a/modules/globebrowsing/tile/chunktile.h +++ b/modules/globebrowsing/tile/chunktile.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -39,11 +39,9 @@ struct ChunkTile { TileDepthTransform depthTransform; }; -struct ChunkTilePile { - std::vector chunkTiles; -}; +using ChunkTilePile = std::vector; } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKTILE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKTILE___H__ diff --git a/modules/globebrowsing/chunk/chunklevelevaluator.h b/modules/globebrowsing/tile/loadjob/diskcachedtileloadjob.cpp similarity index 51% rename from modules/globebrowsing/chunk/chunklevelevaluator.h rename to modules/globebrowsing/tile/loadjob/diskcachedtileloadjob.cpp index f8998a0cbf..41a16afb6b 100644 --- a/modules/globebrowsing/chunk/chunklevelevaluator.h +++ b/modules/globebrowsing/tile/loadjob/diskcachedtileloadjob.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,61 +22,63 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKLEVELEVALUATOR___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKLEVELEVALUATOR___H__ +#include + +#include +#include +#include namespace openspace { - -struct RenderData; - namespace globebrowsing { -class Chunk; +DiskCachedTileLoadJob::DiskCachedTileLoadJob( + std::shared_ptr textureDataProvider, + const TileIndex& tileIndex, + std::shared_ptr tdc, + CacheMode m) + : TileLoadJob(textureDataProvider, tileIndex) + , _tileDiskCache(tdc) + , _mode(m) +{} -/** - * Abstract class defining an interface for accessing a desired level of a Chunk. - * The desired level can be used in the process of determining whether a Chunk should - * want to split, merge or do nothing. -*/ -class ChunkLevelEvaluator { -public: - virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const = 0; - static const int UNKNOWN_DESIRED_LEVEL = -1; -}; +void DiskCachedTileLoadJob::execute() { + _rawTile = nullptr; -/** - * Evaluate the Chunk level depending on the distance from the Camera to the Chunk. - * This evaluation method aims to keep the screen size (horizontal length and not - * area) of all chunks constant. -*/ -class EvaluateChunkLevelByDistance : public ChunkLevelEvaluator { -public: - virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const; -}; + switch (_mode) { + case CacheMode::Disabled: + _rawTile = _tileDataset->readTileData(_chunkIndex); + break; -/** - * Evaluate the chunk level using the area of the non-heightmapped Chunk projected - * on a sphere with the center in the position of the camera. A Chunk near the - * horizon will have a small projected area and hence a lower desired level. This - * evaluation is more forgiving than EvaluateChunkLevelByDistance, meaning it results - * in lower desired levels. -*/ -class EvaluateChunkLevelByProjectedArea : public ChunkLevelEvaluator { -public: - virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const; -}; + case CacheMode::ReadOnly: + _rawTile = _tileDiskCache->get(_chunkIndex); + if (_rawTile == nullptr) { + _rawTile = _tileDataset->readTileData(_chunkIndex); + } + break; -/** - * If this chunk has available tile data for any LayerGroup on any of its active - * Layers it will return an UNKNOWN_DESIRED_LEVEL. If no data is available it will - * evaluate to a level that is current level -1. -*/ -class EvaluateChunkLevelByAvailableTileData : public ChunkLevelEvaluator { -public: - virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const; -}; + case CacheMode::ReadAndWrite: + _rawTile = _tileDiskCache->get(_chunkIndex); + if (_rawTile == nullptr) { + _rawTile = _tileDataset->readTileData(_chunkIndex); + _tileDiskCache->put(_chunkIndex, _rawTile); + } + break; + + case CacheMode::WriteOnly: + _rawTile = _tileDataset->readTileData(_chunkIndex); + _tileDiskCache->put(_chunkIndex, _rawTile); + break; + + case CacheMode::CacheHitsOnly: + _rawTile = _tileDiskCache->get(_chunkIndex); + if (_rawTile == nullptr) { + RawTile res = RawTile::createDefaultRes(); + res.tileIndex = _chunkIndex; + _rawTile = std::make_shared(res); + } + break; + } +} } // namespace globebrowsing } // namespace openspace - -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CHUNKLEVELEVALUATOR___H__ diff --git a/modules/globebrowsing/tile/loadjob/diskcachedtileloadjob.h b/modules/globebrowsing/tile/loadjob/diskcachedtileloadjob.h new file mode 100644 index 0000000000..98c25e8598 --- /dev/null +++ b/modules/globebrowsing/tile/loadjob/diskcachedtileloadjob.h @@ -0,0 +1,58 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___DISKCACHEDTILELOADJOB___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___DISKCACHEDTILELOADJOB___H__ + +#include + +namespace openspace { +namespace globebrowsing { + +class TileDiskCache; + +struct DiskCachedTileLoadJob : public TileLoadJob { + enum CacheMode { + Disabled, + ReadOnly, + ReadAndWrite, + WriteOnly, + CacheHitsOnly, + }; + + DiskCachedTileLoadJob(std::shared_ptr textureDataProvider, + const TileIndex& tileIndex, std::shared_ptr tdc, + CacheMode cacheMode = CacheMode::ReadOnly); + + void execute() override; + +protected: + std::shared_ptr _tileDiskCache; + CacheMode _mode; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___DISKCACHEDTILELOADJOB___H__ diff --git a/include/openspace/properties/wcharproperty.h b/modules/globebrowsing/tile/loadjob/loadjob.h similarity index 78% rename from include/openspace/properties/wcharproperty.h rename to modules/globebrowsing/tile/loadjob/loadjob.h index 38d12030ce..28aec76b70 100644 --- a/include/openspace/properties/wcharproperty.h +++ b/modules/globebrowsing/tile/loadjob/loadjob.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,32 +22,24 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __WCHARPROPERTY_H__ -#define __WCHARPROPERTY_H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___LOADJOB___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___LOADJOB___H__ - /** - * \file wcharproperty.h - * - * \addtogroup openspace - * @{ - * \addtogroup properties - * @{ - - * \class WCharProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type wchar_t. +#include - * @} @} - */ - -#include "openspace/properties/numericalproperty.h" +#include namespace openspace { -namespace properties { +namespace globebrowsing { -//REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t); +class RawTile; -} // namespace properties +struct LoadJob : public Job { + virtual void execute() = 0; + virtual std::shared_ptr product() const = 0; +}; + +} // namespace globebrowsing } // namespace openspace -#endif // __WCHARPROPERTY_H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LOADJOB___H__ diff --git a/modules/globebrowsing/tile/loadjob/tileloadjob.cpp b/modules/globebrowsing/tile/loadjob/tileloadjob.cpp new file mode 100644 index 0000000000..20be5d229b --- /dev/null +++ b/modules/globebrowsing/tile/loadjob/tileloadjob.cpp @@ -0,0 +1,41 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void TileLoadJob::execute() { + _rawTile = _tileDataset->readTileData(_chunkIndex); +} + +std::shared_ptr TileLoadJob::product() const { + return _rawTile; +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/volume/rendering/renderablevolume.h b/modules/globebrowsing/tile/loadjob/tileloadjob.h similarity index 67% rename from modules/volume/rendering/renderablevolume.h rename to modules/globebrowsing/tile/loadjob/tileloadjob.h index 1b82fa25a5..a02538d1b7 100644 --- a/modules/volume/rendering/renderablevolume.h +++ b/modules/globebrowsing/tile/loadjob/tileloadjob.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,42 +22,40 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __RENDERABLEVOLUME_H__ -#define __RENDERABLEVOLUME_H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILELOADJOB___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILELOADJOB___H__ -// open space includes -#include +#include -// ghoul includes -#include - -// Forward declare to minimize dependencies -namespace ghoul { - namespace filesystem { - class File; - } - namespace opengl { - class Texture; - } -} +#include +#include namespace openspace { +namespace globebrowsing { + +class TileDataset; +class RawTile; + +struct TileLoadJob : LoadJob { + TileLoadJob(std::shared_ptr textureDataProvider, + const TileIndex& tileIndex) + : _tileDataset(textureDataProvider) + , _chunkIndex(tileIndex) + {} + + virtual ~TileLoadJob() = default; + + virtual void execute() override; + + virtual std::shared_ptr product() const override; -class RenderableVolume: public Renderable { -public: - // constructors & destructor - RenderableVolume(const ghoul::Dictionary& dictionary); - ~RenderableVolume(); - protected: - ghoul::opengl::Texture* loadVolume(const std::string& filepath, const ghoul::Dictionary& hintsDictionary); - glm::vec3 getVolumeOffset(const std::string& filepath, const ghoul::Dictionary& hintsDictionary); - ghoul::RawVolumeReader::ReadHints readHints(const ghoul::Dictionary& dictionary); - ghoul::opengl::Texture* loadTransferFunction(const std::string& filepath); - -private: + TileIndex _chunkIndex; + std::shared_ptr _tileDataset; + std::shared_ptr _rawTile; }; +} // namespace globebrowsing } // namespace openspace -#endif +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILELOADJOB___H__ diff --git a/modules/globebrowsing/tile/pixelregion.cpp b/modules/globebrowsing/tile/pixelregion.cpp index 9649803e41..63b62f5312 100644 --- a/modules/globebrowsing/tile/pixelregion.cpp +++ b/modules/globebrowsing/tile/pixelregion.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -42,18 +42,18 @@ PixelRegion::PixelRegion(const PixelRegion& o) void PixelRegion::setSide(Side side, int pos) { switch (side) { - case LEFT: - setLeft(pos); - break; - case TOP: - setTop(pos); - break; - case RIGHT: - setRight(pos); - break; - case BOTTOM: - setBottom(pos); - break; + case Side::LEFT: + setLeft(pos); + break; + case Side::TOP: + setTop(pos); + break; + case Side::RIGHT: + setRight(pos); + break; + case Side::BOTTOM: + setBottom(pos); + break; } } @@ -77,18 +77,18 @@ void PixelRegion::setBottom(int y) { void PixelRegion::align(Side side, int pos) { switch (side) { - case LEFT: - alignLeft(pos); - break; - case TOP: - alignTop(pos); - break; - case RIGHT: - alignRight(pos); - break; - case BOTTOM: - alignBottom(pos); - break; + case Side::LEFT: + alignLeft(pos); + break; + case Side::TOP: + alignTop(pos); + break; + case Side::RIGHT: + alignRight(pos); + break; + case Side::BOTTOM: + alignBottom(pos); + break; } } @@ -137,18 +137,18 @@ void PixelRegion::upscalePow2(int exponent, PixelCoordinate wrt) { void PixelRegion::move(Side side, int amount) { switch (side) { - case LEFT: - start.x -= amount; - break; - case TOP: - start.y -= amount; - break; - case RIGHT: - start.x += amount; - break; - case BOTTOM: - start.y += amount; - break; + case Side::LEFT: + start.x -= amount; + break; + case Side::TOP: + start.y -= amount; + break; + case Side::RIGHT: + start.x += amount; + break; + case Side::BOTTOM: + start.y += amount; + break; } } @@ -165,12 +165,12 @@ void PixelRegion::clampTo(const PixelRegion& boundingRegion) { void PixelRegion::forceNumPixelToDifferByNearestMultipleOf(unsigned int multiple) { ghoul_assert(multiple > 0, "multiple must be 1 or larger"); int sizeDiff = numPixels.x - numPixels.y; - if (std::abs(sizeDiff) > 0) { + if (static_cast(std::abs(static_cast(sizeDiff))) > 0) { if (sizeDiff > 0) { numPixels.y += sizeDiff % multiple; } else { - numPixels.x += std::abs(sizeDiff) % multiple; + numPixels.x += static_cast(std::abs(static_cast(sizeDiff))) % multiple; } } } @@ -198,19 +198,19 @@ PixelRegion PixelRegion::globalCut(Side side, int p) { PixelRegion cutOff(*this); int cutSize = 0; switch (side) { - case LEFT: + case Side::LEFT: setLeft(p); cutOff.setRight(p - cutSize); break; - case TOP: + case Side::TOP: setTop(p); cutOff.setBottom(p - cutSize); break; - case RIGHT: + case Side::RIGHT: setRight(p); cutOff.setLeft(p + cutSize); break; - case BOTTOM: + case Side::BOTTOM: setBottom(p); cutOff.setTop(p + cutSize); break; @@ -233,30 +233,34 @@ int PixelRegion::area() const { int PixelRegion::edge(Side side) const { switch (side) { - case LEFT: return start.x; - case TOP: return start.y; - case RIGHT: return start.x + numPixels.x; - case BOTTOM: return start.y + numPixels.y; + case Side::LEFT: + return start.x; + case Side::TOP: + return start.y; + case Side::RIGHT: + return start.x + numPixels.x; + case Side::BOTTOM: + return start.y + numPixels.y; } } int PixelRegion::edgeDirectionSign(Side side) const { - return side < RIGHT ? -1 : 1; + return side < Side::RIGHT ? -1 : 1; } -PixelCoordinate PixelRegion::end() const { +PixelRegion::PixelCoordinate PixelRegion::end() const { return start + numPixels; } bool PixelRegion::lineIntersect(Side side, int p) { switch (side) { - case PixelRegion::LEFT: - case PixelRegion::RIGHT: - return start.x <= p && p <= (start.x + numPixels.x); + case Side::LEFT: + case Side::RIGHT: + return start.x <= p && p <= (start.x + numPixels.x); - case PixelRegion::TOP: - case PixelRegion::BOTTOM: - return start.y <= p && p <= (start.y + numPixels.y); + case Side::TOP: + case Side::BOTTOM: + return start.y <= p && p <= (start.y + numPixels.y); } } diff --git a/modules/globebrowsing/tile/pixelregion.h b/modules/globebrowsing/tile/pixelregion.h index 84fbca1d0d..9a86a82270 100644 --- a/modules/globebrowsing/tile/pixelregion.h +++ b/modules/globebrowsing/tile/pixelregion.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,16 +25,16 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___PIXELREGION___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___PIXELREGION___H__ -#include +#include namespace openspace { namespace globebrowsing { -using PixelCoordinate = glm::ivec2; -using PixelRange= glm::ivec2; - struct PixelRegion { - enum Side { + using PixelCoordinate = glm::ivec2; + using PixelRange = glm::ivec2; + + enum class Side { LEFT = 0, TOP, RIGHT, @@ -103,4 +103,4 @@ struct PixelRegion { } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PIXELREGION___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PIXELREGION___H__ diff --git a/modules/globebrowsing/tile/quad.h b/modules/globebrowsing/tile/quad.h new file mode 100644 index 0000000000..9d06ac0759 --- /dev/null +++ b/modules/globebrowsing/tile/quad.h @@ -0,0 +1,42 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___QUAD___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___QUAD___H__ + +namespace openspace { +namespace globebrowsing { + +enum Quad { + NORTH_WEST = 0, + NORTH_EAST, + SOUTH_WEST, + SOUTH_EAST +}; + + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___QUAD___H__ diff --git a/modules/globebrowsing/tile/rawtile.cpp b/modules/globebrowsing/tile/rawtile.cpp new file mode 100644 index 0000000000..80471264db --- /dev/null +++ b/modules/globebrowsing/tile/rawtile.cpp @@ -0,0 +1,96 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace { + const std::string _loggerCat = "Tile"; +} + +namespace openspace { +namespace globebrowsing { + +RawTile::RawTile() + : imageData(nullptr) + , dimensions(0, 0, 0) + , tileMetaData(nullptr) + , tileIndex(0, 0, 0) + , error(CE_None) + , nBytesImageData(0) +{} + +RawTile RawTile::createDefaultRes() { + RawTile defaultRes; + int w = 8; + int h = 8; + defaultRes.dimensions = glm::uvec3(w, h, 1); + defaultRes.nBytesImageData = w * h * 1 * 3 * 4; // assume max 3 channels, max 4 bytes per pixel + defaultRes.imageData = new char[defaultRes.nBytesImageData]; + std::fill_n((char*)defaultRes.imageData, defaultRes.nBytesImageData, 0); + return std::move(defaultRes); +} + +void RawTile::serializeMetaData(std::ostream& os) { + os << dimensions.x << " " << dimensions.y << " " << dimensions.z << std::endl; + os << tileIndex.x << " " << tileIndex.y << " " << tileIndex.level << std::endl; + os << error << std::endl; + + // preprocess data + os << (tileMetaData != nullptr) << std::endl; + if (tileMetaData != nullptr) { + tileMetaData->serialize(os); + } + + os << nBytesImageData << std::endl; +} + +RawTile RawTile::deserializeMetaData(std::istream& is) { + RawTile res; + is >> res.dimensions.x >> res.dimensions.y >> res.dimensions.z; + is >> res.tileIndex.x >> res.tileIndex.y >> res.tileIndex.level; + int err; is >> err; res.error = (CPLErr) err; + + res.tileMetaData = nullptr; + bool hastileMetaData; + is >> hastileMetaData; + if (hastileMetaData) { + TileMetaData tileMetaData = TileMetaData::deserialize(is); + res.tileMetaData = std::make_shared(tileMetaData); + } + + is >> res.nBytesImageData; + + char binaryDataSeparator; + is >> binaryDataSeparator; // not used + +// char* buffer = new char[res.nBytesImageData](); + return std::move(res); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/tile/rawtile.h b/modules/globebrowsing/tile/rawtile.h new file mode 100644 index 0000000000..fa436957f1 --- /dev/null +++ b/modules/globebrowsing/tile/rawtile.h @@ -0,0 +1,62 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___RAWTILE___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___RAWTILE___H__ + +#include + +#include + +#include +#include + +#include + +namespace openspace { +namespace globebrowsing { + +struct TileMetaData; + +struct RawTile { + RawTile(); + + char* imageData; + glm::uvec3 dimensions; + std::shared_ptr tileMetaData; + TileIndex tileIndex; + CPLErr error; + size_t nBytesImageData; + + void serializeMetaData(std::ostream& s); + static RawTile deserializeMetaData(std::istream& s); + + static RawTile createDefaultRes(); +}; + +} // namespace globebrowsing +} // namespace openspace + + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___RAWTILE___H__ diff --git a/modules/globebrowsing/tile/textureformat.h b/modules/globebrowsing/tile/textureformat.h new file mode 100644 index 0000000000..4149b14a33 --- /dev/null +++ b/modules/globebrowsing/tile/textureformat.h @@ -0,0 +1,43 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__ + +#include +#include + +namespace openspace { +namespace globebrowsing { + +struct TextureFormat { + ghoul::opengl::Texture::Format ghoulFormat; + GLuint glFormat; +}; + + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__ diff --git a/modules/globebrowsing/tile/tile.cpp b/modules/globebrowsing/tile/tile.cpp index 0ef46ef91e..fb9307557e 100644 --- a/modules/globebrowsing/tile/tile.cpp +++ b/modules/globebrowsing/tile/tile.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,90 +33,6 @@ namespace { namespace openspace { namespace globebrowsing { -void TileMetaData::serialize(std::ostream& os) { - os << maxValues.size() << std::endl; - for (float f : maxValues) { - os << f << " "; - } - os << std::endl; - for (float f : minValues) { - os << f << " "; - } - os << std::endl; -} - -TileMetaData TileMetaData::deserialize(std::istream& is) { - TileMetaData res; - int n; is >> n; - res.maxValues.resize(n); - for (int i = 0; i < n; i++) { - is >> res.maxValues[i]; - } - res.minValues.resize(n); - for (int i = 0; i < n; i++) { - is >> res.minValues[i]; - } - - return std::move(res); -} - -RawTile::RawTile() - : imageData(nullptr) - , dimensions(0, 0, 0) - , tileMetaData(nullptr) - , tileIndex(0, 0, 0) - , error(CE_None) - , nBytesImageData(0) -{} - -RawTile RawTile::createDefaultRes() { - RawTile defaultRes; - int w = 8; - int h = 8; - defaultRes.dimensions = glm::uvec3(w, h, 1); - defaultRes.nBytesImageData = w * h * 1 * 3 * 4; // assume max 3 channels, max 4 bytes per pixel - defaultRes.imageData = new char[defaultRes.nBytesImageData]; - std::fill_n((char*)defaultRes.imageData, defaultRes.nBytesImageData, 0); - return std::move(defaultRes); -} - -void RawTile::serializeMetaData(std::ostream& os) { - os << dimensions.x << " " << dimensions.y << " " << dimensions.z << std::endl; - os << tileIndex.x << " " << tileIndex.y << " " << tileIndex.level << std::endl; - os << error << std::endl; - - // preprocess data - os << (tileMetaData != nullptr) << std::endl; - if (tileMetaData != nullptr) { - tileMetaData->serialize(os); - } - - os << nBytesImageData << std::endl; -} - -RawTile RawTile::deserializeMetaData(std::istream& is) { - RawTile res; - is >> res.dimensions.x >> res.dimensions.y >> res.dimensions.z; - is >> res.tileIndex.x >> res.tileIndex.y >> res.tileIndex.level; - int err; is >> err; res.error = (CPLErr) err; - - res.tileMetaData = nullptr; - bool hastileMetaData; - is >> hastileMetaData; - if (hastileMetaData) { - TileMetaData tileMetaData = TileMetaData::deserialize(is); - res.tileMetaData = std::make_shared(tileMetaData); - } - - is >> res.nBytesImageData; - - char binaryDataSeparator; - is >> binaryDataSeparator; // not used - - char* buffer = new char[res.nBytesImageData](); - return std::move(res); -} - const Tile Tile::TileUnavailable = {nullptr, nullptr, Tile::Status::Unavailable }; Tile Tile::createPlainTile(const glm::uvec2& size, const glm::uvec4& color) { @@ -160,7 +76,7 @@ glm::vec2 Tile::compensateSourceTextureSampling(glm::vec2 startOffset, glm::vec2 return tileUV; } -glm::vec2 Tile::TileUvToTextureSamplePosition(const TileUvTransform uvTransform, +glm::vec2 Tile::TileUvToTextureSamplePosition(const TileUvTransform& uvTransform, glm::vec2 tileUV, glm::uvec2 resolution) { glm::vec2 uv = uvTransform.uvOffset + uvTransform.uvScale * tileUV; diff --git a/modules/globebrowsing/tile/tile.h b/modules/globebrowsing/tile/tile.h index dc478a93d5..5db9f53385 100644 --- a/modules/globebrowsing/tile/tile.h +++ b/modules/globebrowsing/tile/tile.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,57 +27,25 @@ #include -#include +#include -#include #include -#include + +namespace ghoul { namespace opengl { + class Texture; +}} namespace openspace { namespace globebrowsing { -struct TileMetaData { - std::vector maxValues; - std::vector minValues; - std::vector hasMissingData; - - void serialize(std::ostream& s); - static TileMetaData deserialize(std::istream& s); -}; - -struct TextureFormat { - ghoul::opengl::Texture::Format ghoulFormat; - GLuint glFormat; -}; - -using namespace ghoul::opengl; - -struct RawTile { - RawTile(); - - char* imageData; - glm::uvec3 dimensions; - std::shared_ptr tileMetaData; - TileIndex tileIndex; - CPLErr error; - size_t nBytesImageData; - - void serializeMetaData(std::ostream& s); - static RawTile deserializeMetaData(std::istream& s); - - static RawTile createDefaultRes(); -}; - -struct TileUvTransform { - glm::vec2 uvOffset; - glm::vec2 uvScale; -}; +struct TileMetaData; +struct TileUvTransform; /** * Defines a status and may have a Texture and TileMetaData */ struct Tile { - std::shared_ptr texture; + std::shared_ptr texture; std::shared_ptr metaData; /** @@ -126,7 +94,7 @@ struct Tile { static glm::vec2 compensateSourceTextureSampling(glm::vec2 startOffset, glm::vec2 sizeDiff, glm::uvec2 resolution, glm::vec2 tileUV); - static glm::vec2 TileUvToTextureSamplePosition(const TileUvTransform uvTransform, + static glm::vec2 TileUvToTextureSamplePosition(const TileUvTransform& uvTransform, glm::vec2 tileUV, glm::uvec2 resolution); /** @@ -140,4 +108,4 @@ struct Tile { } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE___H__ diff --git a/modules/globebrowsing/tile/tiledatalayout.cpp b/modules/globebrowsing/tile/tiledatalayout.cpp new file mode 100644 index 0000000000..f20a626f3e --- /dev/null +++ b/modules/globebrowsing/tile/tiledatalayout.cpp @@ -0,0 +1,92 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 // abspath +#include + +#include +#include + + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + const std::string _loggerCat = "TileDataset"; +} + +namespace openspace { +namespace globebrowsing { + +TileDataLayout::TileDataLayout() {} + +TileDataLayout::TileDataLayout(GDALDataset* dataSet, GLuint preferredGlType) { + // Assume all raster bands have the same data type + gdalType =preferredGlType != 0 ? + tiledatatype::getGdalDataType(preferredGlType) : + dataSet->GetRasterBand(1)->GetRasterDataType(); + + glType = tiledatatype::getOpenGLDataType(gdalType); + numRasters = dataSet->GetRasterCount(); + bytesPerDatum = tiledatatype::numberOfBytes(gdalType); + bytesPerPixel = bytesPerDatum * numRasters; + textureFormat = tiledatatype::getTextureFormat(numRasters, gdalType); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/tile/tiledatalayout.h b/modules/globebrowsing/tile/tiledatalayout.h new file mode 100644 index 0000000000..a030b13c13 --- /dev/null +++ b/modules/globebrowsing/tile/tiledatalayout.h @@ -0,0 +1,57 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___TILEDATALAYOUT___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEDATALAYOUT___H__ + +#include + +#include +#include + +#include + +class GDALDataset; + +namespace openspace { +namespace globebrowsing { + +struct TileDataLayout { + TileDataLayout(); + TileDataLayout(GDALDataset* dataSet, GLuint preferredGlType); + + GDALDataType gdalType; + GLuint glType; + + size_t bytesPerDatum; + size_t numRasters; + size_t bytesPerPixel; + + TextureFormat textureFormat; +}; + +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEDATALAYOUT___H__ diff --git a/modules/globebrowsing/tile/tiledataset.cpp b/modules/globebrowsing/tile/tiledataset.cpp index 0cc2912cea..9934234346 100644 --- a/modules/globebrowsing/tile/tiledataset.cpp +++ b/modules/globebrowsing/tile/tiledataset.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,7 +24,6 @@ #include - #include #include @@ -62,8 +61,10 @@ #include #include #include +#include +#include #include - +#include namespace { const std::string _loggerCat = "TileDataset"; @@ -76,22 +77,7 @@ std::ostream& operator<<(std::ostream& os, const PixelRegion& pr) { return os << pr.start.x << ", " << pr.start.y << " with size " << pr.numPixels.x << ", " << pr.numPixels.y; } -TileDataLayout::TileDataLayout() {} - -TileDataLayout::TileDataLayout(GDALDataset* dataSet, GLuint preferredGlType) { - // Assume all raster bands have the same data type - gdalType =preferredGlType != 0 ? - TileDataType::getGdalDataType(preferredGlType) : - dataSet->GetRasterBand(1)->GetRasterDataType(); - - glType = TileDataType::getOpenGLDataType(gdalType); - numRasters = dataSet->GetRasterCount(); - bytesPerDatum = TileDataType::numberOfBytes(gdalType); - bytesPerPixel = bytesPerDatum * numRasters; - textureFormat = TileDataType::getTextureFormat(numRasters, gdalType); -} - -IODescription IODescription::cut(PixelRegion::Side side, int pos) { +TileDataset::IODescription TileDataset::IODescription::cut(PixelRegion::Side side, int pos) { PixelRegion readPreCut = read.region; PixelRegion writePreCut = write.region; @@ -99,15 +85,15 @@ IODescription IODescription::cut(PixelRegion::Side side, int pos) { ratio.x = write.region.numPixels.x / (double) read.region.numPixels.x; ratio.y = write.region.numPixels.y / (double) read.region.numPixels.y; - double ratioRatio = ratio.x / ratio.y; +// double ratioRatio = ratio.x / ratio.y; //ghoul_assert(glm::abs(ratioRatio - 1.0) < 0.01, "Different read/write aspect ratio!"); IODescription whatCameOff = *this; whatCameOff.read.region = read.region.globalCut(side, pos); - PixelRange cutSize = whatCameOff.read.region.numPixels; - PixelRange localWriteCutSize = ratio * glm::dvec2(cutSize); + PixelRegion::PixelRange cutSize = whatCameOff.read.region.numPixels; + PixelRegion::PixelRange localWriteCutSize = ratio * glm::dvec2(cutSize); if (cutSize.x == 0 || cutSize.y == 0) { ghoul_assert( @@ -120,7 +106,8 @@ IODescription IODescription::cut(PixelRegion::Side side, int pos) { ); } - int localWriteCutPos = (side % 2 == 0) ? localWriteCutSize.x : localWriteCutSize.y; + int localWriteCutPos = (side == PixelRegion::Side::LEFT || side == PixelRegion::Side::RIGHT) + ? localWriteCutSize.x : localWriteCutSize.y; whatCameOff.write.region = write.region.localCut(side, localWriteCutPos); return whatCameOff; @@ -321,7 +308,10 @@ std::shared_ptr TileDataset::readTileData(TileIndex tileIndex) { std::shared_ptr TileDataset::defaultTileData() { ensureInitialized(); - PixelRegion pixelRegion = { PixelCoordinate(0, 0), PixelRange(16, 16) }; + PixelRegion pixelRegion = { + PixelRegion::PixelCoordinate(0, 0), + PixelRegion::PixelRange(16, 16) + }; std::shared_ptr rawTile = std::make_shared(); rawTile->tileIndex = { 0, 0, 0 }; rawTile->dimensions = glm::uvec3(pixelRegion.numPixels, 1); @@ -385,7 +375,7 @@ TileDepthTransform TileDataset::calculateTileDepthTransform() { bool isFloat = (_dataLayout.gdalType == GDT_Float32 || _dataLayout.gdalType == GDT_Float64); double maximumValue = - isFloat ? 1.0 : TileDataType::getMaximumValue(_dataLayout.gdalType); + isFloat ? 1.0 : tiledatatype::getMaximumValue(_dataLayout.gdalType); TileDepthTransform transform; transform.depthOffset = firstBand->GetOffset(); @@ -397,7 +387,7 @@ bool TileDataset::gdalHasOverviews() const { return _dataset->GetRasterBand(1)->GetOverviewCount() > 0; } -int TileDataset::gdalOverview(const PixelRange& regionSizeOverviewZero) const { +int TileDataset::gdalOverview(const PixelRegion::PixelRange& regionSizeOverviewZero) const { GDALRasterBand* firstBand = _dataset->GetRasterBand(1); int minNumPixels0 = glm::min(regionSizeOverviewZero.x, regionSizeOverviewZero.y); @@ -441,15 +431,15 @@ PixelRegion TileDataset::gdalPixelRegion(GDALRasterBand* rasterBand) const { PixelRegion TileDataset::gdalPixelRegion(const GeodeticPatch& geodeticPatch) const { Geodetic2 nwCorner = geodeticPatch.getCorner(Quad::NORTH_WEST); Geodetic2 swCorner = geodeticPatch.getCorner(Quad::SOUTH_EAST); - PixelCoordinate pixelStart = geodeticToPixel(nwCorner); - PixelCoordinate pixelEnd = geodeticToPixel(swCorner); + PixelRegion::PixelCoordinate pixelStart = geodeticToPixel(nwCorner); + PixelRegion::PixelCoordinate pixelEnd = geodeticToPixel(swCorner); PixelRegion gdalRegion(pixelStart, pixelEnd - pixelStart); return gdalRegion; } GDALRasterBand* TileDataset::gdalRasterBand(int overview, int raster) const { GDALRasterBand* rasterBand = _dataset->GetRasterBand(raster); - int numberOfOverviews = rasterBand->GetOverviewCount(); +// int numberOfOverviews = rasterBand->GetOverviewCount(); rasterBand = gdalHasOverviews() ? rasterBand->GetOverview(overview) : rasterBand; ghoul_assert(rasterBand != nullptr, "Rasterband is null"); return rasterBand; @@ -474,7 +464,7 @@ std::array TileDataset::getGeoTransform() const { return padfTransform; } -PixelCoordinate TileDataset::geodeticToPixel(const Geodetic2& geo) const { +PixelRegion::PixelCoordinate TileDataset::geodeticToPixel(const Geodetic2& geo) const { std::array padfTransform = getGeoTransform(); double Y = Angle::fromRadians(geo.lat).asDegrees(); @@ -505,10 +495,10 @@ PixelCoordinate TileDataset::geodeticToPixel(const Geodetic2& geo) const { ghoul_assert(abs(X - Xp) < 1e-10, "inverse should yield X as before"); ghoul_assert(abs(Y - Yp) < 1e-10, "inverse should yield Y as before"); - return PixelCoordinate(glm::round(P), glm::round(L)); + return PixelRegion::PixelCoordinate(glm::round(P), glm::round(L)); } -Geodetic2 TileDataset::pixelToGeodetic(const PixelCoordinate& p) const { +Geodetic2 TileDataset::pixelToGeodetic(const PixelRegion::PixelCoordinate& p) const { std::array padfTransform = getGeoTransform(); Geodetic2 geodetic; // Should be using radians and not degrees? @@ -517,7 +507,7 @@ Geodetic2 TileDataset::pixelToGeodetic(const PixelCoordinate& p) const { return geodetic; } -IODescription TileDataset::getIODescription(const TileIndex& tileIndex) const { +TileDataset::IODescription TileDataset::getIODescription(const TileIndex& tileIndex) const { IODescription io; io.read.region = gdalPixelRegion(tileIndex); @@ -541,14 +531,14 @@ IODescription TileDataset::getIODescription(const TileIndex& tileIndex) const { // For correct sampling in height dataset, we need to pad the texture tile io.write.region.pad(padding); - PixelRange preRound = io.write.region.numPixels; + PixelRegion::PixelRange preRound = io.write.region.numPixels; io.write.region.roundDownToQuadratic(); io.write.region.roundUpNumPixelToNearestMultipleOf(2); if (preRound != io.write.region.numPixels) { LDEBUG(tileIndex << " | " << preRound.x << ", " << preRound.y << " --> " << io.write.region.numPixels.x << ", " << io.write.region.numPixels.y); } - io.write.region.start = PixelCoordinate(0, 0); // write region starts in origin + io.write.region.start = PixelRegion::PixelCoordinate(0, 0); // write region starts in origin io.write.bytesPerLine = _dataLayout.bytesPerPixel * io.write.region.numPixels.x; io.write.totalNumBytes = io.write.bytesPerLine * io.write.region.numPixels.y; @@ -647,7 +637,7 @@ CPLErr TileDataset::repeatedRasterIO(GDALRasterBand* rasterBand, const IODescrip // +--------------+ if (cutoff.read.region.area() > 0) { - didCutOff = true; +// didCutOff = true; // Wrap by repeating PixelRegion::Side oppositeSide = (PixelRegion::Side) ((i + 2) % 4); @@ -686,7 +676,7 @@ CPLErr TileDataset::repeatedRasterIO(GDALRasterBand* rasterBand, const IODescrip } CPLErr err = rasterIO(rasterBand, io, dataDestination); - worstError = std::max(worstError, err); +// worstError = std::max(worstError, err); // The return error from a repeated rasterIO is ONLY based on the main region, // which in the usual case will cover the main area of the patch anyway @@ -705,7 +695,7 @@ CPLErr TileDataset::rasterIO(GDALRasterBand* rasterBand, const IODescription& io "Invalid write region" ); - PixelCoordinate end = io.write.region.end(); + PixelRegion::PixelCoordinate end = io.write.region.end(); size_t largestIndex = (end.y - 1) * io.write.bytesPerLine + (end.x - 1) * _dataLayout.bytesPerPixel; ghoul_assert(largestIndex <= io.write.totalNumBytes, "Invalid write region"); @@ -742,7 +732,7 @@ std::shared_ptr TileDataset::getTileMetaData( const PixelRegion& region) const { size_t bytesPerLine = _dataLayout.bytesPerPixel * region.numPixels.x; - size_t totalNumBytes = bytesPerLine * region.numPixels.y; +// size_t totalNumBytes = bytesPerLine * region.numPixels.y; TileMetaData* preprocessData = new TileMetaData(); preprocessData->maxValues.resize(_dataLayout.numRasters); @@ -765,7 +755,7 @@ std::shared_ptr TileDataset::getTileMetaData( for (size_t x = 0; x < region.numPixels.x; x++) { for (size_t c = 0; c < _dataLayout.numRasters; c++) { float noDataValue = _dataset->GetRasterBand(c + 1)->GetNoDataValue(); - float val = TileDataType::interpretFloat( + float val = tiledatatype::interpretFloat( _dataLayout.gdalType, &(rawTile->imageData[yi + i]) ); @@ -818,7 +808,7 @@ CPLErr TileDataset::postProcessErrorCheck(std::shared_ptr rawTile return CE_Fatal; } // ugly test for heightmap overlay - if (_dataLayout.textureFormat.ghoulFormat == Texture::Format::RG) { + if (_dataLayout.textureFormat.ghoulFormat == ghoul::opengl::Texture::Format::RG) { // check the alpha if (rawTile->tileMetaData->maxValues[1] == 0.0 && rawTile->tileMetaData->minValues[1] == 0.0) diff --git a/modules/globebrowsing/tile/tiledataset.h b/modules/globebrowsing/tile/tiledataset.h index 96b7c4dcc9..6bc692884d 100644 --- a/modules/globebrowsing/tile/tiledataset.h +++ b/modules/globebrowsing/tile/tiledataset.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,13 +25,16 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATASET___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATASET___H__ +#include #include #include +#include #include #include #include #include +#include #include #include @@ -42,37 +45,9 @@ class GDALRasterBand; namespace openspace { namespace globebrowsing { +class RawTile; class GeodeticPatch; -struct TileDataLayout { - TileDataLayout(); - TileDataLayout(GDALDataset* dataSet, GLuint preferredGlType); - - GDALDataType gdalType; - GLuint glType; - - size_t bytesPerDatum; - size_t numRasters; - size_t bytesPerPixel; - - TextureFormat textureFormat; -}; - -struct IODescription { - struct ReadData { - int overview; - PixelRegion region; - } read; - - struct WriteData { - PixelRegion region; - size_t bytesPerLine; - size_t totalNumBytes; - } write; - - IODescription cut(PixelRegion::Side side, int pos); -}; - class TileDataset { public: struct Configuration { @@ -113,6 +88,21 @@ public: private: + struct IODescription { + struct ReadData { + int overview; + PixelRegion region; + } read; + + struct WriteData { + PixelRegion region; + size_t bytesPerLine; + size_t totalNumBytes; + } write; + + IODescription cut(PixelRegion::Side side, int pos); + }; + ////////////////////////////////////////////////////////////////////////////////// // Initialization // @@ -132,7 +122,7 @@ private: void setGdalProxyConfiguration(); GDALDataset* gdalDataset(const std::string& gdalDatasetDesc); bool gdalHasOverviews() const; - int gdalOverview(const PixelRange& baseRegionSize) const; + int gdalOverview(const PixelRegion::PixelRange& baseRegionSize) const; int gdalOverview(const TileIndex& tileIndex) const; int gdalVirtualOverview(const TileIndex& tileIndex) const; PixelRegion gdalPixelRegion(const GeodeticPatch& geodeticPatch) const; @@ -153,8 +143,8 @@ private: */ std::array getGeoTransform() const; - PixelCoordinate geodeticToPixel(const Geodetic2& geo) const; - Geodetic2 pixelToGeodetic(const PixelCoordinate& p) const; + PixelRegion::PixelCoordinate geodeticToPixel(const Geodetic2& geo) const; + Geodetic2 pixelToGeodetic(const PixelRegion::PixelCoordinate& p) const; IODescription getIODescription(const TileIndex& tileIndex) const; char* readImageData(IODescription& io, CPLErr& worstError) const; CPLErr rasterIO(GDALRasterBand* rasterBand, const IODescription& io, char* dst) const; @@ -195,4 +185,4 @@ private: } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATASET___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATASET___H__ diff --git a/modules/globebrowsing/tile/tiledatatype.cpp b/modules/globebrowsing/tile/tiledatatype.cpp index 5f1b8e798d..8cebef5b31 100644 --- a/modules/globebrowsing/tile/tiledatatype.cpp +++ b/modules/globebrowsing/tile/tiledatatype.cpp @@ -1,26 +1,26 @@ - /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 @@ -44,8 +44,9 @@ namespace { namespace openspace { namespace globebrowsing { +namespace tiledatatype { -float TileDataType::interpretFloat(GDALDataType gdalType, const char* src) { +float interpretFloat(GDALDataType gdalType, const char* src) { switch (gdalType) { case GDT_Byte: return static_cast(*reinterpret_cast(src)); @@ -66,7 +67,7 @@ float TileDataType::interpretFloat(GDALDataType gdalType, const char* src) { } } -size_t TileDataType::numberOfBytes(GDALDataType gdalType) { +size_t numberOfBytes(GDALDataType gdalType) { switch (gdalType) { case GDT_Byte: return sizeof(GLubyte); @@ -88,7 +89,7 @@ size_t TileDataType::numberOfBytes(GDALDataType gdalType) { } } -size_t TileDataType::getMaximumValue(GDALDataType gdalType) { +size_t getMaximumValue(GDALDataType gdalType) { switch (gdalType) { case GDT_Byte: return 1 << 8; @@ -97,7 +98,7 @@ size_t TileDataType::getMaximumValue(GDALDataType gdalType) { case GDT_Int16: return 1 << 15; case GDT_UInt32: - return 1 << 32; + return size_t(1) << 32; case GDT_Int32: return 1 << 31; default: @@ -106,14 +107,12 @@ size_t TileDataType::getMaximumValue(GDALDataType gdalType) { } } -TextureFormat TileDataType::getTextureFormat( - int rasterCount, GDALDataType gdalType) -{ +TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) { TextureFormat format; switch (rasterCount) { case 1: // Red - format.ghoulFormat = Texture::Format::Red; + format.ghoulFormat = ghoul::opengl::Texture::Format::Red; switch (gdalType) { case GDT_Byte: format.glFormat = GL_R8; @@ -142,7 +141,7 @@ TextureFormat TileDataType::getTextureFormat( } break; case 2: - format.ghoulFormat = Texture::Format::RG; + format.ghoulFormat = ghoul::opengl::Texture::Format::RG; switch (gdalType) { case GDT_Byte: format.glFormat = GL_RG8; @@ -170,7 +169,7 @@ TextureFormat TileDataType::getTextureFormat( } break; case 3: - format.ghoulFormat = Texture::Format::RGB; + format.ghoulFormat = ghoul::opengl::Texture::Format::RGB; switch (gdalType) { case GDT_Byte: format.glFormat = GL_RGB8; @@ -199,7 +198,7 @@ TextureFormat TileDataType::getTextureFormat( } break; case 4: - format.ghoulFormat = Texture::Format::RGBA; + format.ghoulFormat = ghoul::opengl::Texture::Format::RGBA; switch (gdalType) { case GDT_Byte: format.glFormat = GL_RGBA8; @@ -234,7 +233,7 @@ TextureFormat TileDataType::getTextureFormat( return format; } -GLuint TileDataType::getOpenGLDataType(GDALDataType gdalType) { +GLuint getOpenGLDataType(GDALDataType gdalType) { switch (gdalType) { case GDT_Byte: return GL_UNSIGNED_BYTE; @@ -256,7 +255,7 @@ GLuint TileDataType::getOpenGLDataType(GDALDataType gdalType) { } } -GDALDataType TileDataType::getGdalDataType(GLuint glType) { +GDALDataType getGdalDataType(GLuint glType) { switch (glType) { case GL_UNSIGNED_BYTE: return GDT_Byte; @@ -278,5 +277,6 @@ GDALDataType TileDataType::getGdalDataType(GLuint glType) { } } +} // namespace tiledatatype } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tiledatatype.h b/modules/globebrowsing/tile/tiledatatype.h index 5c26df5a37..fd92aa07e0 100644 --- a/modules/globebrowsing/tile/tiledatatype.h +++ b/modules/globebrowsing/tile/tiledatatype.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,28 +27,30 @@ #include +#include + #include #include namespace openspace { namespace globebrowsing { +namespace tiledatatype { -struct TileDataType { - static GLuint getOpenGLDataType(GDALDataType gdalType); +GLuint getOpenGLDataType(GDALDataType gdalType); - static GDALDataType getGdalDataType(GLuint glType); +GDALDataType getGdalDataType(GLuint glType); - static TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType); +TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType); - static size_t getMaximumValue(GDALDataType gdalType); +size_t getMaximumValue(GDALDataType gdalType); - static size_t numberOfBytes(GDALDataType gdalType); +size_t numberOfBytes(GDALDataType gdalType); - static float interpretFloat(GDALDataType gdalType, const char* src); -}; +float interpretFloat(GDALDataType gdalType, const char* src); +} // namespace tiledatatype } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__ diff --git a/modules/globebrowsing/tile/tiledepthtransform.h b/modules/globebrowsing/tile/tiledepthtransform.h index 2d71672b17..9212863b72 100644 --- a/modules/globebrowsing/tile/tiledepthtransform.h +++ b/modules/globebrowsing/tile/tiledepthtransform.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___TILEDEPTHTRANSFORM___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___TILEDEPTHTRANSFORM___H__ diff --git a/modules/globebrowsing/tile/tilediskcache.cpp b/modules/globebrowsing/tile/tilediskcache.cpp index 63e172f0fe..f8627df68d 100644 --- a/modules/globebrowsing/tile/tilediskcache.cpp +++ b/modules/globebrowsing/tile/tilediskcache.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include diff --git a/modules/globebrowsing/tile/tilediskcache.h b/modules/globebrowsing/tile/tilediskcache.h index 71880d8036..7b01d0ecb5 100644 --- a/modules/globebrowsing/tile/tilediskcache.h +++ b/modules/globebrowsing/tile/tilediskcache.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -54,10 +54,9 @@ private: std::string getFilePath(const TileIndex& tileIndex) const; ghoul::filesystem::File getMetaDataFile(const TileIndex& tileIndex) const; ghoul::filesystem::File getDataFile(const TileIndex& tileIndex) const; - }; } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DISK_CACHE___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DISK_CACHE___H__ diff --git a/modules/globebrowsing/tile/tileindex.cpp b/modules/globebrowsing/tile/tileindex.cpp index 4ae8590415..f5ca66ab3a 100644 --- a/modules/globebrowsing/tile/tileindex.cpp +++ b/modules/globebrowsing/tile/tileindex.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,6 +28,8 @@ #include +#include + namespace { const char* KeyLevel = "Level"; const char* KeyX = "X"; @@ -122,7 +124,7 @@ Creates a hash which can be used as key in hash maps. +-------+------------+-------+------------+ */ -TileHashKey TileIndex::hashKey() const { +TileIndex::TileHashKey TileIndex::hashKey() const { TileHashKey key = 0LL; key |= level; key |= x << 5; diff --git a/modules/globebrowsing/tile/tileindex.h b/modules/globebrowsing/tile/tileindex.h index d8d3314c2f..6de6c20da1 100644 --- a/modules/globebrowsing/tile/tileindex.h +++ b/modules/globebrowsing/tile/tileindex.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,6 +25,8 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_INDEX___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_INDEX___H__ +#include + #include #include @@ -35,14 +37,7 @@ namespace ghoul { namespace openspace { namespace globebrowsing { -class Geodetic2; - -enum Quad { - NORTH_WEST = 0, - NORTH_EAST, - SOUTH_WEST, - SOUTH_EAST -}; +struct Geodetic2; enum CardinalDirection { WEST = 0, @@ -51,9 +46,9 @@ enum CardinalDirection { SOUTH, }; -using TileHashKey = uint64_t; - struct TileIndex { + using TileHashKey = uint64_t; + int x, y, level; TileIndex(int x = 0, int y = 0, int level = 0); diff --git a/modules/globebrowsing/tile/tilemetadata.cpp b/modules/globebrowsing/tile/tilemetadata.cpp new file mode 100644 index 0000000000..6c6c2b344e --- /dev/null +++ b/modules/globebrowsing/tile/tilemetadata.cpp @@ -0,0 +1,60 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { + +void TileMetaData::serialize(std::ostream& os) { + os << maxValues.size() << std::endl; + for (float f : maxValues) { + os << f << " "; + } + os << std::endl; + for (float f : minValues) { + os << f << " "; + } + os << std::endl; +} + +TileMetaData TileMetaData::deserialize(std::istream& is) { + TileMetaData res; + int n; is >> n; + res.maxValues.resize(n); + for (int i = 0; i < n; i++) { + is >> res.maxValues[i]; + } + res.minValues.resize(n); + for (int i = 0; i < n; i++) { + is >> res.minValues[i]; + } + + return std::move(res); +} + +} // namespace globebrowsing +} // namespace openspace diff --git a/include/openspace/properties/uintproperty.h b/modules/globebrowsing/tile/tilemetadata.h similarity index 78% rename from include/openspace/properties/uintproperty.h rename to modules/globebrowsing/tile/tilemetadata.h index 2e4b50b103..64c82db2e3 100644 --- a/include/openspace/properties/uintproperty.h +++ b/modules/globebrowsing/tile/tilemetadata.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,32 +22,26 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __UINTPROPERTY_H__ -#define __UINTPROPERTY_H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEMETADATA___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEMETADATA___H__ - /** - * \file uintproperty.h - * - * \addtogroup openspace - * @{ - * \addtogroup properties - * @{ - - * \class UIntProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned int. - - * @} @} - */ - -#include "openspace/properties/numericalproperty.h" +#include +#include namespace openspace { -namespace properties { +namespace globebrowsing { -REGISTER_NUMERICALPROPERTY_HEADER(UIntProperty, unsigned int); +struct TileMetaData { + std::vector maxValues; + std::vector minValues; + std::vector hasMissingData; -} // namespace properties + void serialize(std::ostream& s); + static TileMetaData deserialize(std::istream& s); +}; + +} // namespace globebrowsing } // namespace openspace -#endif // __UINTPROPERTY_H__ + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEMETADATA___H__ diff --git a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp index 1b0efa1eff..407843dabd 100644 --- a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -42,7 +43,8 @@ namespace { namespace openspace { namespace globebrowsing { - +namespace tileprovider { + CachingTileProvider::CachingTileProvider(const ghoul::Dictionary& dictionary) : _framesSinceLastRequestFlush(0) { @@ -134,7 +136,7 @@ Tile CachingTileProvider::getTile(const TileIndex& tileIndex) { return tile; } - TileHashKey key = tileIndex.hashKey(); + TileIndex::TileHashKey key = tileIndex.hashKey(); if (_tileCache->exist(key)) { return _tileCache->get(key); @@ -162,7 +164,7 @@ Tile CachingTileProvider::getDefaultTile() { void CachingTileProvider::initTexturesFromLoadedData() { auto rawTiles = _asyncTextureDataProvider->getRawTiles(); for (auto rawTile : rawTiles){ - TileHashKey key = rawTile->tileIndex.hashKey(); + TileIndex::TileHashKey key = rawTile->tileIndex.hashKey(); Tile tile = createTile(rawTile); _tileCache->put(key, tile); } @@ -179,7 +181,7 @@ Tile::Status CachingTileProvider::getTileStatus(const TileIndex& tileIndex) { return Tile::Status::OutOfRange; } - TileHashKey key = tileIndex.hashKey(); + TileIndex::TileHashKey key = tileIndex.hashKey(); if (_tileCache->exist(key)) { return _tileCache->get(key).status; @@ -197,11 +199,12 @@ Tile CachingTileProvider::createTile(std::shared_ptr rawTile) { return{ nullptr, nullptr, Tile::Status::IOError }; } - TileHashKey key = rawTile->tileIndex.hashKey(); +// TileIndex::TileHashKey key = rawTile->tileIndex.hashKey(); TileDataLayout dataLayout = _asyncTextureDataProvider->getTextureDataProvider()->getDataLayout(); // The texture should take ownership of the data + using ghoul::opengl::Texture; std::shared_ptr texture = std::make_shared( rawTile->imageData, rawTile->dimensions, @@ -225,5 +228,6 @@ Tile CachingTileProvider::createTile(std::shared_ptr rawTile) { return tile; } +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h index 5531c6e9d2..8a1669cf96 100644 --- a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -31,6 +31,9 @@ namespace openspace { namespace globebrowsing { class AsyncTileDataProvider; +class RawTile; + +namespace tileprovider { /** * Provides tiles loaded by AsyncTileDataProvider and @@ -92,7 +95,8 @@ private: Tile _defaultTile; }; +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CACHING_TILE_PROVIDER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___CACHING_TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp b/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp index 240779820a..a2beeb5fe9 100644 --- a/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,6 +26,7 @@ #include #include +#include namespace { const char* KeyFilePath = "FilePath"; @@ -33,7 +34,8 @@ namespace { namespace openspace { namespace globebrowsing { - +namespace tileprovider { + SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary) { // Required input if (!dictionary.getValue(KeyFilePath, _imagePath)) { @@ -74,7 +76,9 @@ void SingleImageProvider::update() { void SingleImageProvider::reset() { _tile = Tile(); - _tile.texture = std::shared_ptr(ghoul::io::TextureReader::ref().loadTexture(_imagePath).release()); + _tile.texture = std::shared_ptr( + std::move(ghoul::io::TextureReader::ref().loadTexture(_imagePath)) + ); _tile.status = _tile.texture != nullptr ? Tile::Status::OK : Tile::Status::IOError; _tile.metaData = nullptr; @@ -86,5 +90,6 @@ int SingleImageProvider::maxLevel() { return 1337; // unlimited } +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/singleimageprovider.h b/modules/globebrowsing/tile/tileprovider/singleimageprovider.h index 793337a0c4..eacf9d63d8 100644 --- a/modules/globebrowsing/tile/tileprovider/singleimageprovider.h +++ b/modules/globebrowsing/tile/tileprovider/singleimageprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,8 +29,7 @@ namespace openspace { namespace globebrowsing { - -using namespace ghoul::opengl; +namespace tileprovider { class SingleImageProvider : public TileProvider { public: @@ -51,7 +50,8 @@ private: std::string _imagePath; }; +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___SINGLE_IMAGE_PROVIDER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___SINGLE_IMAGE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/sizereferencetileprovider.cpp b/modules/globebrowsing/tile/tileprovider/sizereferencetileprovider.cpp new file mode 100644 index 0000000000..80a944405e --- /dev/null +++ b/modules/globebrowsing/tile/tileprovider/sizereferencetileprovider.cpp @@ -0,0 +1,154 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +using namespace ghoul::fontrendering; + +namespace openspace { +namespace globebrowsing { +namespace tileprovider { + +namespace { + const char* KeyRadii = "Radii"; + const char* KeyBackgroundImagePath = "BackgroundImagePath"; +} + +SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& dictionary) +{ + _fontSize = 50; + _font = OsEng.fontManager().font("Mono", _fontSize); + + glm::dvec3 radii(1,1,1); + if (!dictionary.getValue(KeyRadii, radii)) { + throw std::runtime_error("Must define key '" + std::string(KeyRadii) + "'"); + } + _ellipsoid = Ellipsoid(radii); + + _backgroundTile.status = Tile::Status::Unavailable; + std::string backgroundImagePath; + if (dictionary.getValue(KeyBackgroundImagePath, backgroundImagePath)) { + using namespace ghoul::io; + std::string imgAbsPath = absPath(backgroundImagePath); + _backgroundTile.texture = TextureReader::ref().loadTexture(imgAbsPath); + _backgroundTile.texture->uploadTexture(); + _backgroundTile.texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); + _backgroundTile.status = Tile::Status::OK; + } +} + +void SizeReferenceTileProvider::renderText(const ghoul::fontrendering::FontRenderer& + fontRenderer, + const TileIndex& tileIndex) const +{ + GeodeticPatch patch(tileIndex); + bool aboveEquator = patch.isNorthern(); + + double tileLongitudalLength = roundedLongitudalLength(tileIndex); + + std::string unit = "m"; + if (tileLongitudalLength > 9999) { + tileLongitudalLength *= 0.001; + unit = "km"; + } + + glm::vec2 textPosition; + textPosition.x = 0; + textPosition.y = aboveEquator ? _fontSize / 2 : _textureSize.y - 3 * _fontSize / 2; + glm::vec4 color(1.0, 1.0, 1.0, 1.0); + + fontRenderer.render( + *_font, + textPosition, + color, + " %.0f %s", + tileLongitudalLength, unit.c_str() + ); +} + +int SizeReferenceTileProvider::roundedLongitudalLength(const TileIndex& tileIndex) const { + GeodeticPatch patch(tileIndex); + bool aboveEquator = patch.isNorthern(); + double lat = aboveEquator ? patch.minLat() : patch.maxLat(); + double lon1 = patch.minLon(); + double lon2 = patch.maxLon(); + int l = static_cast(_ellipsoid.longitudalDistance(lat, lon1, lon2)); + + bool useKm = l > 9999; + if (useKm) { + l /= 1000; + } + l = std::round(l); + if (useKm) { + l *= 1000; + } + + return l; +} + +TileIndex::TileHashKey SizeReferenceTileProvider::toHash(const TileIndex& tileIndex) const { + int l = roundedLongitudalLength(tileIndex); + TileIndex::TileHashKey key = static_cast(l); + return key; +} + +Tile SizeReferenceTileProvider::backgroundTile(const TileIndex& tileIndex) const { + if (_backgroundTile.status == Tile::Status::OK) { + Tile tile; + auto t = _backgroundTile.texture; + void* pixelData = new char[t->expectedPixelDataSize()]; + memcpy(pixelData, t->pixelData(), t->expectedPixelDataSize()); + tile.texture = std::make_shared( + pixelData, + t->dimensions(), + t->format(), + t->internalFormat(), + t->dataType(), + t->filter(), + t->wrapping() + ); + tile.texture->uploadTexture(); + tile.texture->setDataOwnership(ghoul::opengl::Texture::TakeOwnership::Yes); + tile.status = Tile::Status::OK; + return tile; + } + else { + // use default background + return TextTileProvider::backgroundTile(tileIndex); + } +} + +} // namespace tileprovider +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/sizereferencetileprovider.h b/modules/globebrowsing/tile/tileprovider/sizereferencetileprovider.h new file mode 100644 index 0000000000..20997490e8 --- /dev/null +++ b/modules/globebrowsing/tile/tileprovider/sizereferencetileprovider.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___SIZEREFERENCE_TILE_PROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___SIZEREFERENCE_TILE_PROVIDER___H__ + +#include + +#include + +namespace openspace { +namespace globebrowsing { +namespace tileprovider { + +/** + * Constructed with an ellipsoid and uses that to render the longitudal length of each + * of each tile. + */ +class SizeReferenceTileProvider : public TextTileProvider { +public: + SizeReferenceTileProvider(const ghoul::Dictionary& dictionary); + + virtual void renderText(const ghoul::fontrendering::FontRenderer& fontRenderer, + const TileIndex& tileIndex) const; + virtual Tile backgroundTile(const TileIndex& tileIndex) const; + + virtual TileIndex::TileHashKey toHash(const TileIndex& tileIndex) const; + +private: + int roundedLongitudalLength(const TileIndex& tileIndex) const; + + Ellipsoid _ellipsoid; + Tile _backgroundTile; +}; + +} // namespace tileprovider +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___SIZEREFERENCE_TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp index 3e187dc95f..8e8024872d 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -43,7 +43,8 @@ namespace { namespace openspace { namespace globebrowsing { - +namespace tileprovider { + const char* TemporalTileProvider::URL_TIME_PLACEHOLDER("${OpenSpaceTimeId}"); const char* TemporalTileProvider::TemporalXMLTags::TIME_START = "OpenSpaceTimeStart"; @@ -286,7 +287,7 @@ TimeFormat* TimeIdProviderFactory::getProvider(const std::string& format) { } ghoul_assert( _timeIdProviderMap.find(format) != _timeIdProviderMap.end(), - "Unsupported Time format: " << format + "Unsupported Time format: " + format ); return _timeIdProviderMap[format].get(); } @@ -347,5 +348,6 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) const { } } +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h index fa7b08103d..f6be2ee126 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -30,6 +30,8 @@ #include #include +#include + #include #include #include @@ -38,7 +40,8 @@ struct CPLXMLNode; namespace openspace { namespace globebrowsing { - +namespace tileprovider { + /** * Interface for stringifying OpenSpace Time instances. * @@ -292,7 +295,8 @@ private: TimeQuantizer _timeQuantizer; }; +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEMPORAL_TILE_PROVIDER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEMPORAL_TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/texttileprovider.cpp b/modules/globebrowsing/tile/tileprovider/texttileprovider.cpp index 278a7d4234..917443a41b 100644 --- a/modules/globebrowsing/tile/tileprovider/texttileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/texttileprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,9 @@ #include +#include +#include + #include #include @@ -36,7 +39,8 @@ using namespace ghoul::fontrendering; namespace openspace { namespace globebrowsing { - +namespace tileprovider { + TextTileProvider::TextTileProvider(const glm::uvec2& textureSize, size_t fontSize) : _tileCache(500) , _textureSize(textureSize) @@ -55,7 +59,7 @@ TextTileProvider::~TextTileProvider() { } Tile TextTileProvider::getTile(const TileIndex& tileIndex) { - TileHashKey key = tileIndex.hashKey(); + TileIndex::TileHashKey key = tileIndex.hashKey(); if (!_tileCache.exist(key)) { _tileCache.put(key, createChunkIndexTile(tileIndex)); @@ -104,8 +108,6 @@ Tile TextTileProvider::createChunkIndexTile(const TileIndex& tileIndex) { 0 ); - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - glViewport( 0, 0, static_cast(tile.texture->width()), @@ -126,7 +128,7 @@ int TextTileProvider::maxLevel() { return 1337; // unlimited } -TileHashKey TextTileProvider::toHash(const TileIndex& tileIndex) const { +TileIndex::TileHashKey TextTileProvider::toHash(const TileIndex& tileIndex) const { return tileIndex.hashKey(); } @@ -135,127 +137,6 @@ Tile TextTileProvider::backgroundTile(const TileIndex& tileIndex) const { return Tile::createPlainTile(_textureSize, color); } -void TileIndexTileProvider::renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const { - fontRenderer.render( - *_font, - glm::vec2( - _textureSize.x / 4 - (_textureSize.x / 32) * log10(1 << tileIndex.level), - _textureSize.y / 2 + _fontSize), - glm::vec4(1.0, 0.0, 0.0, 1.0), - "level: %i \nx: %i \ny: %i", - tileIndex.level, tileIndex.x, tileIndex.y - ); -} - -namespace { - const char* KeyRadii = "Radii"; - const char* KeyBackgroundImagePath = "BackgroundImagePath"; -} - -SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& dictionary) -{ - _fontSize = 50; - FontManager& fm = OsEng.fontManager(); - _font = fm.font("Mono", _fontSize); - - glm::dvec3 radii(1,1,1); - if (!dictionary.getValue(KeyRadii, radii)) { - throw std::runtime_error("Must define key '" + std::string(KeyRadii) + "'"); - } - _ellipsoid = Ellipsoid(radii); - - _backgroundTile.status = Tile::Status::Unavailable; - std::string backgroundImagePath; - if (dictionary.getValue(KeyBackgroundImagePath, backgroundImagePath)) { - using namespace ghoul::io; - std::string imgAbsPath = absPath(backgroundImagePath); - _backgroundTile.texture = TextureReader::ref().loadTexture(imgAbsPath); - _backgroundTile.texture->uploadTexture(); - _backgroundTile.texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); - _backgroundTile.status = Tile::Status::OK; - } - -} - -void SizeReferenceTileProvider::renderText(const FontRenderer& fontRenderer, - const TileIndex& tileIndex) const -{ - GeodeticPatch patch(tileIndex); - bool aboveEquator = patch.isNorthern(); - - double tileLongitudalLength = roundedLongitudalLength(tileIndex); - - std::string unit = "m"; - if (tileLongitudalLength > 9999) { - tileLongitudalLength *= 0.001; - unit = "km"; - } - - glm::vec2 textPosition; - textPosition.x = 0; - textPosition.y = aboveEquator ? _fontSize / 2 : _textureSize.y - 3 * _fontSize / 2; - glm::vec4 color(1.0, 1.0, 1.0, 1.0); - - fontRenderer.render( - *_font, - textPosition, - color, - " %.0f %s", - tileLongitudalLength, unit.c_str() - ); -} - -int SizeReferenceTileProvider::roundedLongitudalLength(const TileIndex& tileIndex) const { - GeodeticPatch patch(tileIndex); - bool aboveEquator = patch.isNorthern(); - double lat = aboveEquator ? patch.minLat() : patch.maxLat(); - double lon1 = patch.minLon(); - double lon2 = patch.maxLon(); - int l = static_cast(_ellipsoid.longitudalDistance(lat, lon1, lon2)); - - bool useKm = l > 9999; - if (useKm) { - l /= 1000; - } - l = std::round(l); - if (useKm) { - l *= 1000; - } - - return l; -} - -TileHashKey SizeReferenceTileProvider::toHash(const TileIndex& tileIndex) const { - int l = roundedLongitudalLength(tileIndex); - TileHashKey key = static_cast(l); - return key; -} - -Tile SizeReferenceTileProvider::backgroundTile(const TileIndex& tileIndex) const { - if (_backgroundTile.status == Tile::Status::OK) { - Tile tile; - auto t = _backgroundTile.texture; - void* pixelData = new char[t->expectedPixelDataSize()]; - memcpy(pixelData, t->pixelData(), t->expectedPixelDataSize()); - tile.texture = std::make_shared( - pixelData, - t->dimensions(), - t->format(), - t->internalFormat(), - t->dataType(), - t->filter(), - t->wrapping() - ); - tile.texture->uploadTexture(); - tile.texture->setDataOwnership(Texture::TakeOwnership::Yes); - tile.status = Tile::Status::OK; - return tile; - } - else { - // use default background - return TextTileProvider::backgroundTile(tileIndex); - } -} - +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/texttileprovider.h b/modules/globebrowsing/tile/tileprovider/texttileprovider.h index a158fb7416..1da75a3f2a 100644 --- a/modules/globebrowsing/tile/tileprovider/texttileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/texttileprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,17 +27,16 @@ #include -#include +#include namespace ghoul { namespace fontrendering { - class Font; class FontRenderer; - }} namespace openspace { namespace globebrowsing { +namespace tileprovider { /** * Enables a simple way of providing tiles with any type of rendered text. @@ -75,7 +74,7 @@ public: * \param tileIndex tileIndex to hash * \returns hashkey used for in LRU cache for this tile */ - virtual TileHashKey toHash(const TileIndex& tileIndex) const; + virtual TileIndex::TileHashKey toHash(const TileIndex& tileIndex) const; /** * Uses the fontRenderer to render some text onto the tile texture provided in @@ -100,38 +99,8 @@ private: GLuint _fbo; }; -/** - * Provides Tiles with the chunk index rendered as text onto its tiles. - */ -class TileIndexTileProvider : public TextTileProvider { -public: - virtual void renderText(const ghoul::fontrendering::FontRenderer& fontRenderer, - const TileIndex& tileIndex) const; -}; - -/** - * Constructed with an ellipsoid and uses that to render the longitudal length of each - * of each tile. - */ -class SizeReferenceTileProvider : public TextTileProvider { -public: - SizeReferenceTileProvider(const ghoul::Dictionary& dictionary); - - virtual void renderText(const ghoul::fontrendering::FontRenderer& fontRenderer, - const TileIndex& tileIndex) const; - virtual Tile backgroundTile(const TileIndex& tileIndex) const; - - virtual TileHashKey toHash(const TileIndex& tileIndex) const; - -private: - - int roundedLongitudalLength(const TileIndex& tileIndex) const; - - Ellipsoid _ellipsoid; - Tile _backgroundTile; -}; - +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEXT_TILE_PROVIDER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEXT_TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/tileindextileprovider.cpp b/modules/globebrowsing/tile/tileprovider/tileindextileprovider.cpp new file mode 100644 index 0000000000..eda42ee4f1 --- /dev/null +++ b/modules/globebrowsing/tile/tileprovider/tileindextileprovider.cpp @@ -0,0 +1,51 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { +namespace globebrowsing { +namespace tileprovider { + +TileIndexTileProvider::TileIndexTileProvider(const ghoul::Dictionary& dict) {} + +void TileIndexTileProvider::renderText(const ghoul::fontrendering::FontRenderer& + fontRenderer, const TileIndex& tileIndex) const +{ + fontRenderer.render( + *_font, + glm::vec2( + _textureSize.x / 4 - (_textureSize.x / 32) * log10(1 << tileIndex.level), + _textureSize.y / 2 + _fontSize), + glm::vec4(1.0, 0.0, 0.0, 1.0), + "level: %i \nx: %i \ny: %i", + tileIndex.level, tileIndex.x, tileIndex.y + ); +} + +} // namespace tileprovider +} // namespace globebrowsing +} // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/tileindextileprovider.h b/modules/globebrowsing/tile/tileprovider/tileindextileprovider.h new file mode 100644 index 0000000000..ef1f8337eb --- /dev/null +++ b/modules/globebrowsing/tile/tileprovider/tileindextileprovider.h @@ -0,0 +1,49 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_GLOBEBROWSING___TILEINDEX_TILE_PROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEINDEX_TILE_PROVIDER___H__ + +#include + +namespace openspace { +namespace globebrowsing { +namespace tileprovider { + +/** + * Provides Tiles with the chunk index rendered as text onto its tiles. + */ +class TileIndexTileProvider : public TextTileProvider { +public: + TileIndexTileProvider(const ghoul::Dictionary& dict); + + virtual void renderText(const ghoul::fontrendering::FontRenderer& fontRenderer, + const TileIndex& tileIndex) const; +}; + +} // namespace tileprovider +} // namespace globebrowsing +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEINDEX_TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/tileprovider.cpp b/modules/globebrowsing/tile/tileprovider/tileprovider.cpp index b3f25fbc66..bf44816fe3 100644 --- a/modules/globebrowsing/tile/tileprovider/tileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/tileprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -39,12 +39,13 @@ namespace { namespace openspace { namespace globebrowsing { - -TileProvider* TileProvider::createFromDictionary(const ghoul::Dictionary& dictionary) { +namespace tileprovider { + +std::unique_ptr TileProvider::createFromDictionary(const ghoul::Dictionary& dictionary) { std::string type = "LRUCaching"; dictionary.getValue(KeyType, type); auto factory = FactoryManager::ref().factory(); - TileProvider* result = factory->create(type, dictionary); + std::unique_ptr result = factory->create(type, dictionary); if (result == nullptr) { LERROR("Failed creating TileProvider of type '" << type << "'"); @@ -67,7 +68,7 @@ ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxPa // Step 1. Traverse 0 or more parents up the chunkTree as requested by the caller for (int i = 0; i < parents && tileIndex.level > 1; i++) { - TileSelector::ascendToParent(tileIndex, uvTransform); + tileselector::ascendToParent(tileIndex, uvTransform); } maxParents -= parents; @@ -75,7 +76,7 @@ ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxPa // the range of defined data. int maximumLevel = maxLevel(); while (tileIndex.level > maximumLevel){ - TileSelector::ascendToParent(tileIndex, uvTransform); + tileselector::ascendToParent(tileIndex, uvTransform); maxParents--; } if(maxParents < 0){ @@ -90,7 +91,7 @@ ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxPa if (--maxParents < 0){ return{ Tile::TileUnavailable, uvTransform }; } - TileSelector::ascendToParent(tileIndex, uvTransform); + tileselector::ascendToParent(tileIndex, uvTransform); } else { return { tile, uvTransform }; @@ -103,24 +104,25 @@ ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxPa ChunkTilePile TileProvider::getChunkTilePile(TileIndex tileIndex, int pileSize){ ghoul_assert(pileSize >= 0, "pileSize must be positive"); ChunkTilePile chunkTilePile; - chunkTilePile.chunkTiles.resize(pileSize); + chunkTilePile.resize(pileSize); for (size_t i = 0; i < pileSize; ++i) { - chunkTilePile.chunkTiles[i] = getChunkTile(tileIndex, i); - if (chunkTilePile.chunkTiles[i].tile.status == Tile::Status::Unavailable) { + chunkTilePile[i] = getChunkTile(tileIndex, i); + if (chunkTilePile[i].tile.status == Tile::Status::Unavailable) { if (i>0) { - chunkTilePile.chunkTiles[i].tile = chunkTilePile.chunkTiles[i-1].tile; - chunkTilePile.chunkTiles[i].uvTransform.uvOffset = chunkTilePile.chunkTiles[i-1].uvTransform.uvOffset; - chunkTilePile.chunkTiles[i].uvTransform.uvScale = chunkTilePile.chunkTiles[i-1].uvTransform.uvScale; + chunkTilePile[i].tile = chunkTilePile[i-1].tile; + chunkTilePile[i].uvTransform.uvOffset = chunkTilePile[i-1].uvTransform.uvOffset; + chunkTilePile[i].uvTransform.uvScale = chunkTilePile[i-1].uvTransform.uvScale; } else { - chunkTilePile.chunkTiles[i].tile = getDefaultTile(); - chunkTilePile.chunkTiles[i].uvTransform.uvOffset = { 0, 0 }; - chunkTilePile.chunkTiles[i].uvTransform.uvScale = { 1, 1 }; + chunkTilePile[i].tile = getDefaultTile(); + chunkTilePile[i].uvTransform.uvOffset = { 0, 0 }; + chunkTilePile[i].uvTransform.uvScale = { 1, 1 }; } } } return std::move(chunkTilePile); } +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/tileprovider.h b/modules/globebrowsing/tile/tileprovider/tileprovider.h index 7a43c24482..2efc34b9bb 100644 --- a/modules/globebrowsing/tile/tileprovider/tileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/tileprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,6 +33,7 @@ namespace openspace { namespace globebrowsing { +namespace tileprovider { /** * Interface for providing Tiles given a @@ -46,7 +47,7 @@ public: * define a key specifying what implementation of TileProvider * to be instantiated. */ - static TileProvider* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary(const ghoul::Dictionary& dictionary); /** * Empty default constructor @@ -141,9 +142,10 @@ public: virtual float noDataValueAsFloat(); }; -using TileCache = LRUCache; +using TileCache = LRUCache; +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.cpp b/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.cpp index 44e4eda06c..b785d1c12f 100644 --- a/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.cpp +++ b/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 @@ -37,16 +37,16 @@ namespace { namespace openspace { namespace globebrowsing { +namespace tileprovider { TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { ghoul::Dictionary defaultProviderDict = dictionary.value( KeyDefaultProvider ); - TileProvider* defaultProvider = TileProvider::createFromDictionary( + _defaultTileProvider = TileProvider::createFromDictionary( defaultProviderDict ); - _defaultTileProvider = std::shared_ptr(defaultProvider); - + ghoul::Dictionary indexProvidersDict = dictionary.value( KeyProviders ); @@ -63,9 +63,10 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { ); TileIndex tileIndex(tileIndexDict); - TileProvider* tileProvider = TileProvider::createFromDictionary(providerDict); - std::shared_ptr stp = std::shared_ptr(tileProvider); - TileHashKey key = tileIndex.hashKey(); + std::shared_ptr stp = TileProvider::createFromDictionary( + providerDict + ); + TileIndex::TileHashKey key = tileIndex.hashKey(); _tileProviderMap.insert(std::make_pair(key, stp)); } } @@ -113,5 +114,6 @@ TileProvider* TileProviderByIndex::indexProvider(const TileIndex& tileIndex) con return (it != _tileProviderMap.end()) ? it->second.get() : nullptr; } +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.h b/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.h index 09e4922e71..c20a047390 100644 --- a/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.h +++ b/modules/globebrowsing/tile/tileprovider/tileproviderbyindex.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,6 +29,7 @@ namespace openspace { namespace globebrowsing { +namespace tileprovider { class TileProviderByIndex : public TileProvider { public: @@ -47,11 +48,12 @@ public: private: TileProvider* indexProvider(const TileIndex& tileIndex) const; - std::unordered_map> _tileProviderMap; + std::unordered_map> _tileProviderMap; std::shared_ptr _defaultTileProvider; }; +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER_BY_INDEX___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER_BY_INDEX___H__ diff --git a/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.cpp b/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.cpp index 7a0edaf313..50553e8caa 100644 --- a/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.cpp +++ b/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,8 +27,6 @@ #include namespace { - const std::string _loggerCat = "TileProviderByLevel"; - const char* KeyProviders = "LevelTileProviders"; const char* KeyMaxLevel = "MaxLevel"; const char* KeyTileProvider = "TileProvider"; @@ -36,15 +34,14 @@ namespace { namespace openspace { namespace globebrowsing { +namespace tileprovider { TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { - ghoul::Dictionary levelProvidersDict = dictionary.value( - KeyProviders - ); + ghoul::Dictionary providers = dictionary.value(KeyProviders); - for (size_t i = 0; i < levelProvidersDict.size(); i++) { + for (size_t i = 0; i < providers.size(); i++) { std::string dictKey = std::to_string(i + 1); - ghoul::Dictionary levelProviderDict = levelProvidersDict.value( + ghoul::Dictionary levelProviderDict = providers.value( dictKey ); double floatMaxLevel; @@ -64,9 +61,10 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { ); } - TileProvider* tileProvider = TileProvider::createFromDictionary(providerDict); - _levelTileProviders.push_back(std::shared_ptr(tileProvider)); - + _levelTileProviders.push_back( + std::shared_ptr(TileProvider::createFromDictionary(providerDict)) + ); + // Ensure we can represent the max level if(_providerIndices.size() < maxLevel){ _providerIndices.resize(maxLevel+1, -1); @@ -128,5 +126,6 @@ TileProvider* TileProviderByLevel::levelProvider(int level) const { return _levelTileProviders[providerIndex(level)].get(); } +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.h b/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.h index 3477c92e86..1e1f54a805 100644 --- a/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.h +++ b/modules/globebrowsing/tile/tileprovider/tileproviderbylevel.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,6 +29,7 @@ namespace openspace { namespace globebrowsing { +namespace tileprovider { class TileProviderByLevel : public TileProvider { public: @@ -51,7 +52,8 @@ private: std::vector> _levelTileProviders; }; +} // namespace tileprovider } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER_BY_LEVEL___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER_BY_LEVEL___H__ diff --git a/modules/globebrowsing/tile/tileselector.cpp b/modules/globebrowsing/tile/tileselector.cpp index 870c706645..de2ca3a070 100644 --- a/modules/globebrowsing/tile/tileselector.cpp +++ b/modules/globebrowsing/tile/tileselector.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,15 +24,14 @@ #include -#include +#include #include namespace openspace { namespace globebrowsing { +namespace tileselector { -ChunkTile TileSelector::getHighestResolutionTile(const LayerGroup& layerGroup, - TileIndex tileIndex) -{ +ChunkTile getHighestResolutionTile(const LayerGroup& layerGroup, TileIndex tileIndex) { ChunkTile mostHighResolution; mostHighResolution.tile = Tile::TileUnavailable; mostHighResolution.uvTransform.uvScale.x = 0; @@ -51,9 +50,8 @@ ChunkTile TileSelector::getHighestResolutionTile(const LayerGroup& layerGroup, return mostHighResolution; } -std::vector TileSelector::getTilesSortedByHighestResolution( - const LayerGroup& layerGroup, - const TileIndex& tileIndex) +std::vector getTilesSortedByHighestResolution(const LayerGroup& layerGroup, + const TileIndex& tileIndex) { std::vector tiles; for (const auto& layer : layerGroup.activeLayers()) { @@ -71,7 +69,7 @@ std::vector TileSelector::getTilesSortedByHighestResolution( return tiles; } -void TileSelector::ascendToParent(TileIndex& tileIndex, TileUvTransform& uv) { +void ascendToParent(TileIndex& tileIndex, TileUvTransform& uv) { uv.uvOffset *= 0.5; uv.uvScale *= 0.5; @@ -80,5 +78,6 @@ void TileSelector::ascendToParent(TileIndex& tileIndex, TileUvTransform& uv) { --tileIndex; } +} // namespace tileselector¢ } // namespace globebrowsing } // namespace openspace diff --git a/modules/globebrowsing/tile/tileselector.h b/modules/globebrowsing/tile/tileselector.h index 3a5b960b36..9af20b18dd 100644 --- a/modules/globebrowsing/tile/tileselector.h +++ b/modules/globebrowsing/tile/tileselector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,6 @@ #define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_SELECTOR___H__ #include -#include #include @@ -34,19 +33,19 @@ namespace openspace { namespace globebrowsing { struct LayerGroup; -class TileProvider; +struct TileIndex; -class TileSelector { -public: - static ChunkTile getHighestResolutionTile(const LayerGroup& layerGroup, - TileIndex tileIndex); - static std::vector getTilesSortedByHighestResolution( - const LayerGroup& layerGroup, const TileIndex& tileIndex); +namespace tileselector { - static void ascendToParent(TileIndex& tileIndex, TileUvTransform& uv); -}; +ChunkTile getHighestResolutionTile(const LayerGroup& layerGroup, TileIndex& tileIndex); +std::vector getTilesSortedByHighestResolution(const LayerGroup& layerGroup, + const TileIndex& tileIndex); + +void ascendToParent(TileIndex& tileIndex, TileUvTransform& uv); + +} // namespace tileselector } // namespace globebrowsing } // namespace openspace -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_SELECTOR___H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_SELECTOR___H__ diff --git a/include/openspace/properties/ucharproperty.h b/modules/globebrowsing/tile/tileuvtransform.h similarity index 78% rename from include/openspace/properties/ucharproperty.h rename to modules/globebrowsing/tile/tileuvtransform.h index f0d7de59ef..533bcfa88a 100644 --- a/include/openspace/properties/ucharproperty.h +++ b/modules/globebrowsing/tile/tileuvtransform.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,32 +22,20 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __UCHARPROPERTY_H__ -#define __UCHARPROPERTY_H__ +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEUVTRANSFORM___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEUVTRANSFORM___H__ - /** - * \file ucharproperty.h - * - * \addtogroup openspace - * @{ - * \addtogroup properties - * @{ - - * \class UCharProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned char. - - * @} @} - */ - -#include "openspace/properties/numericalproperty.h" +#include namespace openspace { -namespace properties { +namespace globebrowsing { -REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char); +struct TileUvTransform { + glm::vec2 uvOffset; + glm::vec2 uvScale; +}; -} // namespace properties +} // namespace globebrowsing } // namespace openspace -#endif // __UCHARPROPERTY_H__ +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEUVTRANSFORM___H__ diff --git a/modules/iswa/CMakeLists.txt b/modules/iswa/CMakeLists.txt index c97f1dd0c3..2d05f0775a 100644 --- a/modules/iswa/CMakeLists.txt +++ b/modules/iswa/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/iswa/iswamodule.cpp b/modules/iswa/iswamodule.cpp index 98d0094eef..e9c1b5004b 100644 --- a/modules/iswa/iswamodule.cpp +++ b/modules/iswa/iswamodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -40,7 +40,18 @@ namespace openspace { IswaModule::IswaModule() : OpenSpaceModule("ISWA") -{} +{ + OsEng.registerModuleCallback( + OpenSpaceEngine::CallbackOption::Initialize, + [](){ + IswaManager::initialize(); + } + ); +} + +scripting::LuaLibrary IswaModule::luaLibrary() const { + return IswaManager::luaLibrary(); +} void IswaModule::internalInitialize(){ auto fRenderable = FactoryManager::ref().factory(); diff --git a/modules/iswa/iswamodule.h b/modules/iswa/iswamodule.h index 5d1bbb19a9..6b92f37634 100644 --- a/modules/iswa/iswamodule.h +++ b/modules/iswa/iswamodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,6 +32,8 @@ class IswaModule : public OpenSpaceModule { public: IswaModule(); + + scripting::LuaLibrary luaLibrary() const override; protected: void internalInitialize() override; diff --git a/modules/iswa/rendering/datacygnet.cpp b/modules/iswa/rendering/datacygnet.cpp index 9c765cde09..aebb3bedd1 100644 --- a/modules/iswa/rendering/datacygnet.cpp +++ b/modules/iswa/rendering/datacygnet.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/datacygnet.h b/modules/iswa/rendering/datacygnet.h index 2fd73b17e1..fcd5f2389f 100644 --- a/modules/iswa/rendering/datacygnet.h +++ b/modules/iswa/rendering/datacygnet.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -113,4 +113,4 @@ private: } //namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___DATACYGNET___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATACYGNET___H__ diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index c53bdc6381..299beea1fc 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/dataplane.h b/modules/iswa/rendering/dataplane.h index fcd609c6dd..149ba8f2d2 100644 --- a/modules/iswa/rendering/dataplane.h +++ b/modules/iswa/rendering/dataplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -59,4 +59,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___DATAPLANE___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATAPLANE___H__ diff --git a/modules/iswa/rendering/datasphere.cpp b/modules/iswa/rendering/datasphere.cpp index fde4d90932..2f4d2f2da7 100644 --- a/modules/iswa/rendering/datasphere.cpp +++ b/modules/iswa/rendering/datasphere.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/datasphere.h b/modules/iswa/rendering/datasphere.h index c50ea616d8..57aac2fcfd 100644 --- a/modules/iswa/rendering/datasphere.h +++ b/modules/iswa/rendering/datasphere.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -58,4 +58,4 @@ protected: } // namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___DATASPHERE___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATASPHERE___H__ diff --git a/modules/iswa/rendering/iswabasegroup.cpp b/modules/iswa/rendering/iswabasegroup.cpp index 6050cd7e87..64fe7532c8 100644 --- a/modules/iswa/rendering/iswabasegroup.cpp +++ b/modules/iswa/rendering/iswabasegroup.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -41,16 +41,16 @@ namespace { } namespace openspace { -IswaBaseGroup::IswaBaseGroup(std::string name, std::string type) - :_enabled("enabled", "Enabled", true) - ,_alpha("alpha", "Alpha", 0.9f, 0.0f, 1.0f) - ,_delete("delete", "Delete") - ,_registered(false) - ,_type(type) - ,_dataProcessor(nullptr) -{ - setName(name); +IswaBaseGroup::IswaBaseGroup(std::string name, std::string type) + : properties::PropertyOwner(std::move(name)) + , _enabled("enabled", "Enabled", true) + , _alpha("alpha", "Alpha", 0.9f, 0.0f, 1.0f) + , _delete("delete", "Delete") + , _registered(false) + , _type(type) + , _dataProcessor(nullptr) +{ addProperty(_enabled); addProperty(_alpha); addProperty(_delete); diff --git a/modules/iswa/rendering/iswabasegroup.h b/modules/iswa/rendering/iswabasegroup.h index 0a97234dff..cae941a3da 100644 --- a/modules/iswa/rendering/iswabasegroup.h +++ b/modules/iswa/rendering/iswabasegroup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 3f2e844672..39f595ae71 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/iswacygnet.h b/modules/iswa/rendering/iswacygnet.h index 11172e28bd..24cc04071b 100644 --- a/modules/iswa/rendering/iswacygnet.h +++ b/modules/iswa/rendering/iswacygnet.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/iswadatagroup.cpp b/modules/iswa/rendering/iswadatagroup.cpp index eaa26b2362..cfe57695e3 100644 --- a/modules/iswa/rendering/iswadatagroup.cpp +++ b/modules/iswa/rendering/iswadatagroup.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/iswadatagroup.h b/modules/iswa/rendering/iswadatagroup.h index 07f37e05ec..34543e734c 100644 --- a/modules/iswa/rendering/iswadatagroup.h +++ b/modules/iswa/rendering/iswadatagroup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/iswakameleongroup.cpp b/modules/iswa/rendering/iswakameleongroup.cpp index 9f57bbb6ab..31cf174525 100644 --- a/modules/iswa/rendering/iswakameleongroup.cpp +++ b/modules/iswa/rendering/iswakameleongroup.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/iswakameleongroup.h b/modules/iswa/rendering/iswakameleongroup.h index 26e7c921b1..973310761b 100644 --- a/modules/iswa/rendering/iswakameleongroup.h +++ b/modules/iswa/rendering/iswakameleongroup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/kameleonplane.cpp b/modules/iswa/rendering/kameleonplane.cpp index 55fce2c729..4a59995f0e 100644 --- a/modules/iswa/rendering/kameleonplane.cpp +++ b/modules/iswa/rendering/kameleonplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/kameleonplane.h b/modules/iswa/rendering/kameleonplane.h index 702a7f5aa7..4b6be6c4c3 100644 --- a/modules/iswa/rendering/kameleonplane.h +++ b/modules/iswa/rendering/kameleonplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -106,4 +106,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___KAMELEONPLANE___H__ +#endif // __OPENSPACE_MODULE_ISWA___KAMELEONPLANE___H__ diff --git a/modules/iswa/rendering/screenspacecygnet.cpp b/modules/iswa/rendering/screenspacecygnet.cpp index 32c2c340a0..997ec14f55 100644 --- a/modules/iswa/rendering/screenspacecygnet.cpp +++ b/modules/iswa/rendering/screenspacecygnet.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 @@ -87,4 +87,4 @@ void ScreenSpaceCygnet::update(){ loadTexture(); } } -} \ No newline at end of file +} diff --git a/modules/iswa/rendering/screenspacecygnet.h b/modules/iswa/rendering/screenspacecygnet.h index a34e51dd50..924a74fc70 100644 --- a/modules/iswa/rendering/screenspacecygnet.h +++ b/modules/iswa/rendering/screenspacecygnet.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -56,4 +56,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___SCREENSPACECYGNET___H__ +#endif // __OPENSPACE_MODULE_ISWA___SCREENSPACECYGNET___H__ diff --git a/modules/iswa/rendering/texturecygnet.cpp b/modules/iswa/rendering/texturecygnet.cpp index 7a601e55d3..d1a94de9ca 100644 --- a/modules/iswa/rendering/texturecygnet.cpp +++ b/modules/iswa/rendering/texturecygnet.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/texturecygnet.h b/modules/iswa/rendering/texturecygnet.h index c432ae3abb..65351125be 100644 --- a/modules/iswa/rendering/texturecygnet.h +++ b/modules/iswa/rendering/texturecygnet.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -58,4 +58,4 @@ private: }; } //namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___TEXTURECYGNET___H__ +#endif // __OPENSPACE_MODULE_ISWA___TEXTURECYGNET___H__ diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 5704a1bae5..e6106e7e38 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/rendering/textureplane.h b/modules/iswa/rendering/textureplane.h index 3f812e1847..753b2cc5e0 100644 --- a/modules/iswa/rendering/textureplane.h +++ b/modules/iswa/rendering/textureplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/shaders/dataplane_fs.glsl b/modules/iswa/shaders/dataplane_fs.glsl index 7307cf0e6e..c6c64765fd 100644 --- a/modules/iswa/shaders/dataplane_fs.glsl +++ b/modules/iswa/shaders/dataplane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/shaders/dataplane_vs.glsl b/modules/iswa/shaders/dataplane_vs.glsl index c13225412f..d79e72a5e0 100644 --- a/modules/iswa/shaders/dataplane_vs.glsl +++ b/modules/iswa/shaders/dataplane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/shaders/datasphere_fs.glsl b/modules/iswa/shaders/datasphere_fs.glsl index 7331a347e4..3a350eeee7 100644 --- a/modules/iswa/shaders/datasphere_fs.glsl +++ b/modules/iswa/shaders/datasphere_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/shaders/textureplane_fs.glsl b/modules/iswa/shaders/textureplane_fs.glsl index d290d159c3..74e3727cb5 100644 --- a/modules/iswa/shaders/textureplane_fs.glsl +++ b/modules/iswa/shaders/textureplane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/shaders/textureplane_vs.glsl b/modules/iswa/shaders/textureplane_vs.glsl index c13225412f..d79e72a5e0 100644 --- a/modules/iswa/shaders/textureplane_vs.glsl +++ b/modules/iswa/shaders/textureplane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/util/dataprocessor.cpp b/modules/iswa/util/dataprocessor.cpp index b61fa59315..482318a754 100644 --- a/modules/iswa/util/dataprocessor.cpp +++ b/modules/iswa/util/dataprocessor.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/iswa/util/dataprocessor.h b/modules/iswa/util/dataprocessor.h index 8a84fcd8f3..3f62a8557a 100644 --- a/modules/iswa/util/dataprocessor.h +++ b/modules/iswa/util/dataprocessor.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -78,4 +78,4 @@ protected: } // namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___DATAPROCESSOR___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATAPROCESSOR___H__ diff --git a/modules/iswa/util/dataprocessorjson.cpp b/modules/iswa/util/dataprocessorjson.cpp index b966fefe09..ecd6ea1b95 100644 --- a/modules/iswa/util/dataprocessorjson.cpp +++ b/modules/iswa/util/dataprocessorjson.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -80,7 +80,7 @@ void DataProcessorJson::addDataValues(std::string data, properties::SelectionPro for(int i=0; i DataProcessorJson::processData(std::string data, properties: json variables = j["variables"]; std::vector selectedOptions = dataOptions.value(); - int numSelected = selectedOptions.size(); +// int numSelected = selectedOptions.size(); auto options = dataOptions.options(); int numOptions = options.size(); diff --git a/modules/iswa/util/dataprocessorjson.h b/modules/iswa/util/dataprocessorjson.h index 98f29aae4c..a2f1a411de 100644 --- a/modules/iswa/util/dataprocessorjson.h +++ b/modules/iswa/util/dataprocessorjson.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -39,6 +39,6 @@ public: virtual std::vector processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override; }; -}// namespace openspace +} // namespace openspace -#endif __OPENSPACE_MODULE_ISWA___DATAPROCESSORJSON___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATAPROCESSORJSON___H__ diff --git a/modules/iswa/util/dataprocessorkameleon.cpp b/modules/iswa/util/dataprocessorkameleon.cpp index b1078cab58..c36763b66d 100644 --- a/modules/iswa/util/dataprocessorkameleon.cpp +++ b/modules/iswa/util/dataprocessorkameleon.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -112,7 +112,7 @@ std::vector DataProcessorKameleon::processData(std::string path, propert initializeKameleonWrapper(path); std::vector selectedOptions = dataOptions.value(); - int numSelected = selectedOptions.size(); +// int numSelected = selectedOptions.size(); auto options = dataOptions.options(); int numOptions = options.size(); diff --git a/modules/iswa/util/dataprocessorkameleon.h b/modules/iswa/util/dataprocessorkameleon.h index aa29aa0dc9..f7206bea11 100644 --- a/modules/iswa/util/dataprocessorkameleon.h +++ b/modules/iswa/util/dataprocessorkameleon.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -54,4 +54,4 @@ private: } // namespace openspace -#endif __OPENSPACE_MODULE_ISWA___DATAPROCESSORKAMELEON___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATAPROCESSORKAMELEON___H__ diff --git a/modules/iswa/util/dataprocessortext.cpp b/modules/iswa/util/dataprocessortext.cpp index 8e8e724844..96a6fb27bf 100644 --- a/modules/iswa/util/dataprocessortext.cpp +++ b/modules/iswa/util/dataprocessortext.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -150,7 +150,7 @@ std::vector DataProcessorText::processData(std::string data, properties: std::stringstream memorystream(data); std::vector selectedOptions = dataOptions.value(); - int numSelected = selectedOptions.size(); +// int numSelected = selectedOptions.size(); int numOptions = dataOptions.options().size(); std::vector values; @@ -195,7 +195,7 @@ std::vector DataProcessorText::processData(std::string data, properties: // } // ----------- OLD METHODS ------------------------ - first = 0; +// first = 0; last = 0; option = -3; lineSize = line.size(); diff --git a/modules/iswa/util/dataprocessortext.h b/modules/iswa/util/dataprocessortext.h index d4648d5018..6e67aee407 100644 --- a/modules/iswa/util/dataprocessortext.h +++ b/modules/iswa/util/dataprocessortext.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -46,4 +46,4 @@ private: } // namespace openspace -#endif __OPENSPACE_MODULE_ISWA___DATAPROCESSORTEXT___H__ +#endif // __OPENSPACE_MODULE_ISWA___DATAPROCESSORTEXT___H__ diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 7e243fea85..d8db3c4c62 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -59,8 +59,10 @@ namespace { namespace openspace{ IswaManager::IswaManager() - : _iswaEvent() + : properties::PropertyOwner("IswaManager") + , _iswaEvent() { + // @CLEANUP: Make this staticly allocated ---abock _month["JAN"] = "01"; _month["FEB"] = "02"; _month["MAR"] = "03"; @@ -89,9 +91,6 @@ IswaManager::IswaManager() "http://iswa3.ccmc.gsfc.nasa.gov/IswaSystemWebApp/CygnetHealthServlet", [this](const DownloadManager::MemoryFile& file){ fillCygnetInfo(std::string(file.buffer)); - }, - [](const std::string& err){ - LWARNING("Download to memory was aborted: " + err); } ); } @@ -102,19 +101,16 @@ IswaManager::~IswaManager(){ } void IswaManager::addIswaCygnet(int id, std::string type, std::string group){ - if(id > 0){ - + if (id > 0) { createScreenSpace(id); - - }else if(id < 0){ - + } else if(id < 0) { // create metadata object and assign group and id std::shared_ptr metaFuture = std::make_shared(); metaFuture->id = id; metaFuture->group = group; // Assign type of cygnet Texture/Data - if(type == _type[CygnetType::Texture]){ + if (type == _type[CygnetType::Texture]) { metaFuture->type = CygnetType::Texture; } else if (type == _type[CygnetType::Data]) { metaFuture->type = CygnetType::Data; @@ -125,7 +121,7 @@ void IswaManager::addIswaCygnet(int id, std::string type, std::string group){ // This callback determines what geometry should be used and creates the right cygbet auto metadataCallback = - [this, metaFuture](const DownloadManager::MemoryFile& file){ + [this, metaFuture](const DownloadManager::MemoryFile& file) { //Create a string from downloaded file std::string res; res.append(file.buffer, file.size); diff --git a/modules/iswa/util/iswamanager.h b/modules/iswa/util/iswamanager.h index 24d926c05f..3af0a8048f 100644 --- a/modules/iswa/util/iswamanager.h +++ b/modules/iswa/util/iswamanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -139,4 +139,4 @@ private: } //namespace openspace -#endif //__OPENSPACE_MODULE_ISWA___ISWAMANAGER___H__ +#endif // __OPENSPACE_MODULE_ISWA___ISWAMANAGER___H__ diff --git a/modules/iswa/util/iswamanager_lua.inl b/modules/iswa/util/iswamanager_lua.inl index 1a704b8aee..6fd5763881 100644 --- a/modules/iswa/util/iswamanager_lua.inl +++ b/modules/iswa/util/iswamanager_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/kameleon/CMakeLists.txt b/modules/kameleon/CMakeLists.txt index 22b1e2c13b..c362cea5f5 100644 --- a/modules/kameleon/CMakeLists.txt +++ b/modules/kameleon/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) @@ -63,7 +63,7 @@ create_new_module( endif () set_property(TARGET ccmc PROPERTY FOLDER "External") if (TARGET cdf) - if (OPENSPACE_DISABLE_EXTERNAL_WARNINGS) + if (GHOUL_DISABLE_EXTERNAL_WARNINGS) if (MSVC) target_compile_options(cdf PUBLIC "/W0" "/MP") else () diff --git a/modules/kameleon/include/kameleonwrapper.h b/modules/kameleon/include/kameleonwrapper.h index 08f717c8e1..1b4149e95f 100644 --- a/modules/kameleon/include/kameleonwrapper.h +++ b/modules/kameleon/include/kameleonwrapper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_ISWA___KAMELEONWRAPPER___H__ -#define __OPENSPACE_MODULE_ISWA___KAMELEONWRAPPER___H__ +#ifndef __OPENSPACE_MODULE_KAMELEON___KAMELEONWRAPPER___H__ +#define __OPENSPACE_MODULE_KAMELEON___KAMELEONWRAPPER___H__ #include @@ -179,4 +179,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_ISWA___KAMELEONWRAPPER___H__ +#endif // __OPENSPACE_MODULE_KAMELEON___KAMELEONWRAPPER___H__ diff --git a/modules/kameleon/kameleonmodule.cpp b/modules/kameleon/kameleonmodule.cpp index 735d08248d..35950630f3 100644 --- a/modules/kameleon/kameleonmodule.cpp +++ b/modules/kameleon/kameleonmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/kameleon/kameleonmodule.h b/modules/kameleon/kameleonmodule.h index 458157ef79..fce0c25746 100644 --- a/modules/kameleon/kameleonmodule.h +++ b/modules/kameleon/kameleonmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_ISWA___KAMELEONMODULE___H__ -#define __OPENSPACE_MODULE_ISWA___KAMELEONMODULE___H__ +#ifndef __OPENSPACE_MODULE_KAMELEON___KAMELEONMODULE___H__ +#define __OPENSPACE_MODULE_KAMELEON___KAMELEONMODULE___H__ #include @@ -36,4 +36,4 @@ public: } // namespace openspace -#endif // __OPENSPACE_MODULE_ISWA___KAMELEONMODULE___H__ +#endif // __OPENSPACE_MODULE_KAMELEON___KAMELEONMODULE___H__ diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index 3a08b6c153..e835c8b758 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -1008,38 +1008,34 @@ glm::vec4 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEn return color; } -std::string KameleonWrapper::getParent(){ - if( _type == KameleonWrapper::Model::BATSRUS || - _type == KameleonWrapper::Model::OpenGGCM || - _type == KameleonWrapper::Model::LFM) - { +std::string KameleonWrapper::getParent() { + switch (_type) { + case KameleonWrapper::Model::BATSRUS: + case KameleonWrapper::Model::OpenGGCM: + case KameleonWrapper::Model::LFM: return "Earth"; - }else if( - _type == KameleonWrapper::Model::ENLIL || - _type == KameleonWrapper::Model::MAS || - _type == KameleonWrapper::Model::Adapt3D || - _type == KameleonWrapper::Model::SWMF) - { + case KameleonWrapper::Model::ENLIL: + case KameleonWrapper::Model::MAS: + case KameleonWrapper::Model::Adapt3D: + case KameleonWrapper::Model::SWMF: return "Sun"; - }else{ + default: return ""; } } -std::string KameleonWrapper::getFrame(){ - if( _type == KameleonWrapper::Model::BATSRUS || - _type == KameleonWrapper::Model::OpenGGCM || - _type == KameleonWrapper::Model::LFM) - { +std::string KameleonWrapper::getFrame() { + switch (_type) { + case KameleonWrapper::Model::BATSRUS: + case KameleonWrapper::Model::OpenGGCM: + case KameleonWrapper::Model::LFM: return "GSM"; - }else if( - _type == KameleonWrapper::Model::ENLIL || - _type == KameleonWrapper::Model::MAS || - _type == KameleonWrapper::Model::Adapt3D || - _type == KameleonWrapper::Model::SWMF) - { + case KameleonWrapper::Model::ENLIL: + case KameleonWrapper::Model::MAS: + case KameleonWrapper::Model::Adapt3D: + case KameleonWrapper::Model::SWMF: return "HEEQ"; - }else{ + default: return ""; } } @@ -1050,8 +1046,6 @@ std::vector KameleonWrapper::getVariables(){ int numVariables = _model->getNumberOfVariables(); for(int i=0; igetVariableName(i) << " "; - // std::cout << _model->getVariableName(i) << std::endl; variableNames.push_back(_model->getVariableName(i));; } return variableNames; diff --git a/modules/kameleonvolume/CMakeLists.txt b/modules/kameleonvolume/CMakeLists.txt new file mode 100644 index 0000000000..b2321582fe --- /dev/null +++ b/modules/kameleonvolume/CMakeLists.txt @@ -0,0 +1,49 @@ +######################################################################################### +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +######################################################################################### + +include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) + +set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/kameleonvolumereader.h + ${CMAKE_CURRENT_SOURCE_DIR}/kameleonvolumereader.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablekameleonvolume.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/kameleonvolumeraycaster.h + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/kameleondocumentationtask.h + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/kameleonmetadatatojsontask.h +) +source_group("Header Files" FILES ${HEADER_FILES}) + +set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablekameleonvolume.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/kameleonvolumeraycaster.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/kameleondocumentationtask.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tasks/kameleonmetadatatojsontask.cpp +) +source_group("Source Files" FILES ${SOURCE_FILES}) + +create_new_module( + "KameleonVolume" + kameleonvolume_module + ${HEADER_FILES} ${SOURCE_FILES} +) diff --git a/modules/kameleonvolume/include.cmake b/modules/kameleonvolume/include.cmake new file mode 100644 index 0000000000..e01e83854b --- /dev/null +++ b/modules/kameleonvolume/include.cmake @@ -0,0 +1,6 @@ +set (DEFAULT_MODULE ON) + +set (OPENSPACE_DEPENDENCIES + kameleon + volume +) \ No newline at end of file diff --git a/modules/kameleonvolume/kameleonvolumemodule.cpp b/modules/kameleonvolume/kameleonvolumemodule.cpp new file mode 100644 index 0000000000..c521538492 --- /dev/null +++ b/modules/kameleonvolume/kameleonvolumemodule.cpp @@ -0,0 +1,58 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { + +KameleonVolumeModule::KameleonVolumeModule() : OpenSpaceModule("KameleonVolume") {} + +void KameleonVolumeModule::internalInitialize() { + auto fRenderable = FactoryManager::ref().factory(); + ghoul_assert(fRenderable, "No renderable factory existed"); + fRenderable->registerClass("RenderableKameleonVolume"); + + auto fTask = FactoryManager::ref().factory(); + ghoul_assert(fTask, "No task factory existed"); + fTask->registerClass("KameleonMetadataToJsonTask"); + fTask->registerClass("KameleonDocumentationTask"); + + +} + +std::vector KameleonVolumeModule::documentations() const +{ + return std::vector{KameleonMetadataToJsonTask::documentation()}; +} + +} // namespace openspace diff --git a/modules/kameleonvolume/kameleonvolumemodule.h b/modules/kameleonvolume/kameleonvolumemodule.h new file mode 100644 index 0000000000..adae6f1320 --- /dev/null +++ b/modules/kameleonvolume/kameleonvolumemodule.h @@ -0,0 +1,43 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEMODULE___H__ +#define __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEMODULE___H__ + +#include +#include + +namespace openspace { + +class KameleonVolumeModule : public OpenSpaceModule { +public: + KameleonVolumeModule(); + virtual ~KameleonVolumeModule() = default; + void internalInitialize() override; + std::vector documentations() const override; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEMODULE___H__ diff --git a/modules/kameleonvolume/kameleonvolumereader.cpp b/modules/kameleonvolume/kameleonvolumereader.cpp new file mode 100644 index 0000000000..8b3a13bc82 --- /dev/null +++ b/modules/kameleonvolume/kameleonvolumereader.cpp @@ -0,0 +1,195 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace { + const char* _loggerCat = "KameleonVolumeReader"; +} + +namespace openspace { + +KameleonVolumeReader::KameleonVolumeReader(const std::string& path) + : _path(path) +{ + if (!FileSys.fileExists(path)) { + LERROR(_path << "does not exist"); + return; + } + + long status = _kameleon.open(_path); + if (status != ccmc::FileReader::OK) { + LERROR("Failed to open file " << _path << " with kameleon"); + return; + } + + _model = _kameleon.model; + _interpolator = std::unique_ptr(_model->createNewInterpolator()); +} + +std::unique_ptr> KameleonVolumeReader::readFloatVolume( + const glm::uvec3 & dimensions, + const std::string & variable, + const glm::vec3 & lowerBound, + const glm::vec3 & upperBound) const +{ + auto volume = std::make_unique>(dimensions); + const glm::vec3 dims = volume->dimensions(); + const glm::vec3 diff = upperBound - lowerBound; + + _model->loadVariable(variable); + + float* data = volume->data(); + for (size_t index = 0; index < volume->nCells(); index++) { + glm::vec3 coords = volume->indexToCoords(index); + glm::vec3 coordsZeroToOne = coords / dims; + glm::vec3 volumeCoords = lowerBound + diff * coordsZeroToOne; + + data[index] = _interpolator->interpolate( + variable, + static_cast(volumeCoords[0]), + static_cast(volumeCoords[1]), + static_cast(volumeCoords[2])); + } + + return volume; +} + +std::vector KameleonVolumeReader::gridVariableNames() const { + // get the grid system string + std::string gridSystem = _model->getGlobalAttribute("grid_system_1").getAttributeString(); + + // remove leading and trailing brackets + gridSystem = gridSystem.substr(1, gridSystem.length() - 2); + + // remove all whitespaces + gridSystem.erase(remove_if(gridSystem.begin(), gridSystem.end(), isspace), gridSystem.end()); + + // replace all comma signs with whitespaces + std::replace(gridSystem.begin(), gridSystem.end(), ',', ' '); + + // tokenize + std::istringstream iss(gridSystem); + std::vector tokens{ std::istream_iterator{iss},std::istream_iterator{} }; + + // validate + if (tokens.size() != 3) { + throw ghoul::RuntimeError( + "Expected three dimensional grid system. Got " + + std::to_string(tokens.size()) + + "dimensions"); + } + + std::string x = tokens.at(0); + std::string y = tokens.at(1); + std::string z = tokens.at(2); + + std::transform(x.begin(), x.end(), x.begin(), ::tolower); + std::transform(y.begin(), y.end(), y.begin(), ::tolower); + std::transform(z.begin(), z.end(), z.begin(), ::tolower); + + return std::vector{x, y, z}; +} + +std::vector KameleonVolumeReader::variableNames() const { + std::vector variableNames; + const int nVariables = _model->getNumberOfVariables(); + for (int i = 0; i < nVariables; ++i) { + variableNames.push_back(_model->getVariableName(i)); + } + return variableNames; +} + +std::vector KameleonVolumeReader::variableAttributeNames() const { + return _model->getVariableAttributeNames(); +} + +std::vector KameleonVolumeReader::globalAttributeNames() const { + std::vector attributeNames; + const int nAttributes = _model->getNumberOfGlobalAttributes(); + for (int i = 0; i < nAttributes; ++i) { + attributeNames.push_back(_model->getGlobalAttributeName(i)); + } + return attributeNames; +} + +void KameleonVolumeReader::addAttributeToDictionary(ghoul::Dictionary& dictionary, const std::string& key, ccmc::Attribute& attr) { + ccmc::Attribute::AttributeType type = attr.getAttributeType(); + switch (type) { + case ccmc::Attribute::AttributeType::FLOAT: + dictionary.setValue(key, attr.getAttributeFloat()); + return; + case ccmc::Attribute::AttributeType::INT: + dictionary.setValue(key, attr.getAttributeInt()); + return; + case ccmc::Attribute::AttributeType::STRING: + dictionary.setValue(key, attr.getAttributeString()); + return; + } +} + +ghoul::Dictionary KameleonVolumeReader::readMetaData() const { + ghoul::Dictionary globalAttributesDictionary; + for (const std::string& attributeName : globalAttributeNames()) { + ccmc::Attribute attribute = _model->getGlobalAttribute(attributeName); + addAttributeToDictionary(globalAttributesDictionary, attributeName, attribute); + } + + ghoul::Dictionary variableDictionary; + std::vector varAttrNames = variableAttributeNames(); + for (const std::string& variableName : variableNames()) { + ghoul::Dictionary variableAttributesDictionary; + for (const std::string& attributeName : varAttrNames) { + ccmc::Attribute attribute = _model->getVariableAttribute(variableName, attributeName); + addAttributeToDictionary(variableAttributesDictionary, attributeName, attribute); + } + variableDictionary.setValue(variableName, variableAttributesDictionary); + } + + return { + {"globalAttributes", std::move(globalAttributesDictionary) }, + {"variableAttributes", std::move(variableDictionary) } + }; +} + +float KameleonVolumeReader::minValue(const std::string & variable) const { + return _model->getVariableAttribute(variable, "actual_min").getAttributeFloat(); +} + +float KameleonVolumeReader::maxValue(const std::string & variable) const { + return _model->getVariableAttribute(variable, "actual_max").getAttributeFloat(); +} + + + + +} \ No newline at end of file diff --git a/modules/kameleonvolume/kameleonvolumereader.h b/modules/kameleonvolume/kameleonvolumereader.h new file mode 100644 index 0000000000..9666e5de80 --- /dev/null +++ b/modules/kameleonvolume/kameleonvolumereader.h @@ -0,0 +1,73 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEREADER___H__ +#define __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEREADER___H__ + +#include +#include +#include +#include + +#include +#include + +namespace ccmc { + class Model; +} + +namespace openspace { + +class KameleonVolumeReader { +public: + KameleonVolumeReader(const std::string& path); + //KameleonMetaData readMetaData(); + + std::unique_ptr> readFloatVolume( + const glm::uvec3& dimensions, + const std::string& variable, + const glm::vec3& lowerBound, + const glm::vec3& upperBound) const; + ghoul::Dictionary readMetaData() const; + float minValue(const std::string& variable) const; + float maxValue(const std::string& variable) const; + + std::vector gridVariableNames() const; + std::vector gridUnits() const; + std::vector variableNames() const; + std::vector variableAttributeNames() const; + std::vector globalAttributeNames() const; + +private: + static void addAttributeToDictionary(ghoul::Dictionary& dictionary, const std::string& key, ccmc::Attribute& attr); + std::string _path; + ccmc::Kameleon _kameleon; + ccmc::Model* _model; + std::unique_ptr _interpolator; + +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEREADER___H__ diff --git a/modules/kameleonvolume/rendering/kameleonvolumeraycaster.cpp b/modules/kameleonvolume/rendering/kameleonvolumeraycaster.cpp new file mode 100644 index 0000000000..10957bcb67 --- /dev/null +++ b/modules/kameleonvolume/rendering/kameleonvolumeraycaster.cpp @@ -0,0 +1,179 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + + +namespace { + const char* GlslRaycastPath = "${MODULES}/kameleonvolume/shaders/raycast.glsl"; + const char* GlslHelperPath = "${MODULES}/kameleonvolume/shaders/helper.glsl"; + const char* GlslBoundsVsPath = "${MODULES}/kameleonvolume/shaders/boundsvs.glsl"; + const char* GlslBoundsFsPath = "${MODULES}/kameleonvolume/shaders/boundsfs.glsl"; +} + +namespace openspace { + +KameleonVolumeRaycaster::KameleonVolumeRaycaster( + std::shared_ptr texture, + std::shared_ptr transferFunction, + std::shared_ptr clipPlanes) + : _volumeTexture(texture) + , _transferFunction(transferFunction) + , _clipPlanes(clipPlanes) + , _boundingBox(glm::vec3(1.0)) {} + +KameleonVolumeRaycaster::~KameleonVolumeRaycaster() {} + +void KameleonVolumeRaycaster::initialize() { + _boundingBox.initialize(); +} + +void KameleonVolumeRaycaster::deinitialize() { +} + +void KameleonVolumeRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) { + glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation + glm::dmat4(data.modelTransform.rotation) * // Spice rotation + glm::dmat4(glm::scale(glm::dmat4(_modelTransform), glm::dvec3(data.modelTransform.scale))); + glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; + + program.setUniform("modelViewTransform", glm::mat4(modelViewTransform)); + program.setUniform("projectionTransform", data.camera.projectionMatrix()); + + // Cull back face + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + + // Render bounding geometry + _boundingBox.render(); +} + +void KameleonVolumeRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) { + glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * + glm::dmat4(glm::scale(glm::dmat4(_modelTransform), glm::dvec3(data.modelTransform.scale))); + glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; + + program.setUniform("modelViewTransform", glm::mat4(modelViewTransform)); + program.setUniform("projectionTransform", data.camera.projectionMatrix()); + + // Cull front face + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + + // Render bounding geometry + _boundingBox.render(); + + // Restore defaults + glCullFace(GL_BACK); +} + +void KameleonVolumeRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) { + std::string stepSizeUniformName = "maxStepSize" + std::to_string(data.id); + program.setUniform(stepSizeUniformName, _stepSize); + + std::string id = std::to_string(data.id); + + _tfUnit = std::make_unique(); + _tfUnit->activate(); + _transferFunction->getTexture().bind(); + program.setUniform("transferFunction_" + id, _tfUnit->unitNumber()); + + _textureUnit = std::make_unique(); + _textureUnit->activate(); + _volumeTexture->bind(); + program.setUniform("volumeTexture_" + id, _textureUnit->unitNumber()); + + program.setUniform("gridType_" + id, static_cast(_gridType)); + + std::vector clipNormals = _clipPlanes->normals(); + std::vector clipOffsets = _clipPlanes->offsets(); + int nClips = clipNormals.size(); + + program.setUniform("nClips_" + id, nClips); + program.setUniform("clipNormals_" + id, clipNormals.data(), nClips); + program.setUniform("clipOffsets_" + id, clipOffsets.data(), nClips); +} + +void KameleonVolumeRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) { + // For example: release texture units + _textureUnit = nullptr; + _tfUnit = nullptr; +} + +bool KameleonVolumeRaycaster::cameraIsInside(const RenderData & data, glm::vec3 & localPosition) +{ + glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * + glm::dmat4(glm::scale(glm::dmat4(_modelTransform), glm::dvec3(data.modelTransform.scale))); + glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; + + glm::vec4 modelPos = glm::inverse(modelViewTransform) * glm::vec4(0.0, 0.0, 0.0, 1.0); + + localPosition = (glm::vec3(modelPos) + glm::vec3(0.5)); + return (localPosition.x > 0 && localPosition.y > 0 && localPosition.z > 0 && localPosition.x < 1 && localPosition.y < 1 && localPosition.z < 1); +} + +std::string KameleonVolumeRaycaster::getBoundsVsPath() const { + return GlslBoundsVsPath; +} + +std::string KameleonVolumeRaycaster::getBoundsFsPath() const { + return GlslBoundsFsPath; +} + +std::string KameleonVolumeRaycaster::getRaycastPath() const { + return GlslRaycastPath; +} + +std::string KameleonVolumeRaycaster::getHelperPath() const { + return GlslHelperPath; +} + +void KameleonVolumeRaycaster::setStepSize(float stepSize) { + _stepSize = stepSize; +} + +void KameleonVolumeRaycaster::setGridType(VolumeGridType gridType) { + _gridType = gridType; +} + +void KameleonVolumeRaycaster::setModelTransform(const glm::mat4 & transform) { + _modelTransform = transform; +} + +} diff --git a/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h b/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h new file mode 100644 index 0000000000..95f4ecb656 --- /dev/null +++ b/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h @@ -0,0 +1,95 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMERAYCASTER___H__ +#define __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMERAYCASTER___H__ + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +namespace ghoul { + namespace opengl { + class Texture; + class ProgramObject; + class TextureUnit; + } +} + +namespace openspace { + +class RenderData; +class RaycastData; + +class KameleonVolumeRaycaster : public VolumeRaycaster { +public: + + KameleonVolumeRaycaster( + std::shared_ptr texture, + std::shared_ptr transferFunction, + std::shared_ptr clipPlanes); + + virtual ~KameleonVolumeRaycaster(); + void initialize(); + void deinitialize(); + void renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override; + void renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override; + void preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override; + void postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override; + bool cameraIsInside(const RenderData& data, glm::vec3& localPosition) override; + + std::string getBoundsVsPath() const override; + std::string getBoundsFsPath() const override; + std::string getRaycastPath() const override; + std::string getHelperPath() const override; + + void setStepSize(float stepSize); + void setGridType(VolumeGridType gridType); + void setModelTransform(const glm::mat4& transform); +private: + std::shared_ptr _clipPlanes; + std::shared_ptr _volumeTexture; + std::shared_ptr _transferFunction; + BoxGeometry _boundingBox; + VolumeGridType _gridType; + glm::mat4 _modelTransform; + + std::unique_ptr _tfUnit; + std::unique_ptr _textureUnit; + float _stepSize; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMERAYCASTER___H__ diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp new file mode 100644 index 0000000000..45e6e8d75a --- /dev/null +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -0,0 +1,392 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 +#include + +#include +#include +#include + +namespace { + const char* _loggerCat = "RenderableKameleonVolume"; +} + +namespace { + const char* KeyDimensions = "Dimensions"; + const char* KeyStepSize = "StepSize"; + const char* KeyTransferFunction = "TransferFunction"; + const char* KeySource = "Source"; + const char* KeyVariable = "Variable"; + const char* KeyLowerDomainBound = "LowerDomainBound"; + const char* KeyUpperDomainBound = "UpperDomainBound"; + const char* KeyDomainScale = "DomainScale"; + const char* KeyLowerValueBound = "LowerValueBound"; + const char* KeyUpperValueBound = "UpperValueBound"; + const char* KeyClipPlanes = "ClipPlanes"; + const char* KeyCache = "Cache"; + const char* KeyGridType = "GridType"; + const char* ValueSphericalGridType = "Spherical"; +} + +namespace openspace { + +RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _dimensions("dimensions", "Dimensions") + , _variable("variable", "Variable") + , _lowerDomainBound("lowerDomainBound", "Lower Domain Bound") + , _upperDomainBound("upperDomainBound", "Upper Domain Bound") + , _domainScale("domainScale", "Domain scale") + , _autoDomainBounds(false) + , _lowerValueBound("lowerValueBound", "Lower Value Bound", 0.0, 0.0, 1) + , _upperValueBound("upperValueBound", "Upper Value Bound", 1, 0.01, 1) + , _autoValueBounds(false) + , _gridType("gridType", "Grid Type", properties::OptionProperty::DisplayType::Dropdown) + , _autoGridType(false) + , _clipPlanes(nullptr) + , _stepSize("stepSize", "Step Size", 0.02, 0.01, 1) + , _sourcePath("sourcePath", "Source Path") + , _transferFunctionPath("transferFunctionPath", "Transfer Function Path") + , _raycaster(nullptr) + , _transferFunction(nullptr) + , _cache("cache", "Cache") { + + glm::vec3 dimensions; + if (dictionary.getValue(KeyDimensions, dimensions)) { + _dimensions = dimensions; + } else { + LWARNING("No dimensions specified for volumetric data, falling back to 32^3"); + _dimensions = glm::uvec3(32, 32, 32); + } + + float stepSize; + if (dictionary.getValue(KeyStepSize, stepSize)) { + _stepSize = stepSize; + } + + std::string transferFunctionPath; + if (dictionary.getValue(KeyTransferFunction, transferFunctionPath)) { + _transferFunctionPath = transferFunctionPath; + _transferFunction = std::make_shared(absPath(transferFunctionPath)); + } + + std::string sourcePath; + if (dictionary.getValue(KeySource, sourcePath)) { + _sourcePath = absPath(sourcePath); + } + + std::string variable; + if (dictionary.getValue(KeyVariable, variable)) { + _variable = variable; + } + + glm::vec3 lowerDomainBound; + if (dictionary.getValue(KeyLowerDomainBound, lowerDomainBound)) { + _lowerDomainBound = lowerDomainBound; + } + else { + _autoDomainBounds = true; + } + + glm::vec3 upperDomainBound; + if (dictionary.getValue(KeyUpperDomainBound, upperDomainBound)) { + _upperDomainBound = upperDomainBound; + } + else { + _autoDomainBounds = true; + } + + glm::vec3 domainScale; + if (dictionary.getValue(KeyDomainScale, domainScale)) { + _domainScale = domainScale; + } else { + _domainScale = glm::vec3(1, 1, 1); // Assume meters if nothing else is specified. + } + + float lowerValueBound; + if (dictionary.getValue(KeyLowerValueBound, lowerValueBound)) { + _lowerValueBound = lowerValueBound; + } + else { + _autoValueBounds = true; + } + + float upperValueBound; + if (dictionary.getValue(KeyUpperValueBound, upperValueBound)) { + _upperValueBound = upperValueBound; + } + else { + _autoValueBounds = true; + } + + ghoul::Dictionary clipPlanesDictionary; + dictionary.getValue(KeyClipPlanes, clipPlanesDictionary); + _clipPlanes = std::make_shared(clipPlanesDictionary); + _clipPlanes->setName("clipPlanes"); + + bool cache; + if (dictionary.getValue(KeyCache, cache)) { + _cache = cache; + } + + _gridType.addOption(static_cast(VolumeGridType::Cartesian), "Cartesian grid"); + _gridType.addOption(static_cast(VolumeGridType::Spherical), "Spherical grid"); + _gridType.setValue(static_cast(VolumeGridType::Cartesian)); + + std::string gridType; + if (dictionary.getValue(KeyGridType, gridType)) { + if (gridType == ValueSphericalGridType) { + _gridType.setValue(static_cast(VolumeGridType::Spherical)); + } else { + _autoGridType = true; + } + } +} + +RenderableKameleonVolume::~RenderableKameleonVolume() {} + +bool RenderableKameleonVolume::initialize() { + load(); + + _volumeTexture->uploadTexture(); + _transferFunction->update(); + + _raycaster = std::make_unique(_volumeTexture, _transferFunction, _clipPlanes); + + _raycaster->setStepSize(_stepSize); + _gridType.onChange([this] { + _raycaster->setStepSize(_stepSize); + }); + _raycaster->setGridType(static_cast(_gridType.value())); + _gridType.onChange([this] { + _raycaster->setGridType(static_cast(_gridType.value())); + }); + + updateRaycasterModelTransform(); + _lowerDomainBound.onChange([this] { + updateRaycasterModelTransform(); + }); + _upperDomainBound.onChange([this] { + updateRaycasterModelTransform(); + }); + + _raycaster->initialize(); + + OsEng.renderEngine().raycasterManager().attachRaycaster(*_raycaster.get()); + + auto onChange = [&](bool enabled) { + if (enabled) { + OsEng.renderEngine().raycasterManager().attachRaycaster(*_raycaster.get()); + } + else { + OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get()); + } + }; + + onEnabledChange(onChange); + + _clipPlanes->initialize(); + + addProperty(_dimensions); + addProperty(_stepSize); + addProperty(_transferFunctionPath); + addProperty(_sourcePath); + addProperty(_variable); + addProperty(_lowerDomainBound); + addProperty(_upperDomainBound); + addProperty(_domainScale); + addProperty(_lowerValueBound); + addProperty(_upperValueBound); + addProperty(_gridType); + addProperty(_cache); + addPropertySubOwner(_clipPlanes.get()); + return true; +} + +void RenderableKameleonVolume::updateRaycasterModelTransform() { + glm::vec3 lowerBoundingBoxBound = _domainScale.value() * _lowerDomainBound.value(); + glm::vec3 upperBoundingBoxBound = _domainScale.value() * _upperDomainBound.value(); + + glm::vec3 scale = upperBoundingBoxBound - lowerBoundingBoxBound; + glm::vec3 translation = (lowerBoundingBoxBound + upperBoundingBoxBound) * 0.5f; + + glm::mat4 modelTransform = glm::translate(glm::mat4(1.0), translation); + modelTransform = glm::scale(modelTransform, scale); + _raycaster->setModelTransform(modelTransform); +} + + +bool RenderableKameleonVolume::cachingEnabled() { + return _cache; +} + +void RenderableKameleonVolume::load() { + if (!FileSys.fileExists(_sourcePath)) { + LERROR("File " << _sourcePath << " does not exist."); + return; + } + if (!cachingEnabled()) { + loadFromPath(_sourcePath); + return; + } + ghoul::filesystem::File sourceFile(_sourcePath); + std::string cachePath = FileSys.cacheManager()->cachedFilename( + sourceFile.baseName(), + cacheSuffix(), + ghoul::filesystem::CacheManager::Persistent::Yes + ); + if (FileSys.fileExists(cachePath)) { + loadRaw(cachePath); + } else { + loadFromPath(_sourcePath); + storeRaw(cachePath); + } +} + +std::string RenderableKameleonVolume::cacheSuffix() { + glm::vec3 dims = _dimensions.value(); + return "." + _variable.value() + + "." + std::to_string(dims[0]) + + "x" + std::to_string(dims[1]) + + "x" + std::to_string(dims[2]); +} + +void RenderableKameleonVolume::loadFromPath(const std::string& path) { + ghoul::filesystem::File file(path); + std::string extension = file.fileExtension(); + std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); + if (extension == "cdf") { + loadCdf(path); + } else { + loadRaw(path); + } +} + +void RenderableKameleonVolume::loadRaw(const std::string& path) { + RawVolumeReader reader(path, _dimensions); + _rawVolume = reader.read(); + updateTextureFromVolume(); +} + +void RenderableKameleonVolume::loadCdf(const std::string& path) { + KameleonVolumeReader reader(path); + + if (_autoValueBounds) { + _lowerValueBound = reader.minValue(_variable); + _upperValueBound = reader.maxValue(_variable); + } + + std::vector variables = reader.gridVariableNames(); + + if (variables.size() == 3 && _autoDomainBounds) { + _lowerDomainBound = glm::vec3( + reader.minValue(variables[0]), + reader.minValue(variables[1]), + reader.minValue(variables[2])); + + _upperDomainBound = glm::vec3( + reader.maxValue(variables[0]), + reader.maxValue(variables[1]), + reader.maxValue(variables[2])); + } + + if (variables.size() == 3 && _autoGridType) { + if (variables[0] == "r" && variables[0] == "theta" && variables[0] == "phi") { + _gridType.setValue(static_cast(VolumeGridType::Spherical)); + } + else { + _gridType.setValue(static_cast(VolumeGridType::Cartesian)); + } + } + + ghoul::Dictionary dict = reader.readMetaData(); + _rawVolume = reader.readFloatVolume(_dimensions, _variable, _lowerDomainBound, _upperDomainBound); + updateTextureFromVolume(); +} + +void RenderableKameleonVolume::updateTextureFromVolume() { + _normalizedVolume = std::make_unique>(_dimensions); + float* in = _rawVolume->data(); + GLfloat* out = _normalizedVolume->data(); + float min = _lowerValueBound; + float diff = _upperValueBound - _lowerValueBound; + + for (size_t i = 0; i < _normalizedVolume->nCells(); ++i) { + out[i] = glm::clamp((in[i] - min) / diff, 0.0f, 1.0f); + } + + _volumeTexture = std::make_shared( + _dimensions, + ghoul::opengl::Texture::Format::Red, + GL_RED, + GL_FLOAT, + ghoul::opengl::Texture::FilterMode::Linear, + ghoul::opengl::Texture::WrappingMode::Repeat + ); + + void* data = reinterpret_cast(_normalizedVolume->data()); + _volumeTexture->setPixelData(data, ghoul::opengl::Texture::TakeOwnership::No); +} + +void RenderableKameleonVolume::storeRaw(const std::string& path) { + RawVolumeWriter writer(path); + writer.write(*_rawVolume); +} + +bool RenderableKameleonVolume::deinitialize() { + if (_raycaster) { + OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get()); + _raycaster = nullptr; + } + return true; +} + +bool RenderableKameleonVolume::isReady() const { + return true; +} + +void RenderableKameleonVolume::update(const UpdateData& data) { + if (_raycaster) { + _raycaster->setStepSize(_stepSize); + } +} + +void RenderableKameleonVolume::render(const RenderData& data, RendererTasks& tasks) { + tasks.raycasterTasks.push_back({ _raycaster.get(), data }); +} + +} diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.h b/modules/kameleonvolume/rendering/renderablekameleonvolume.h new file mode 100644 index 0000000000..e96a9e2a14 --- /dev/null +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.h @@ -0,0 +1,103 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_KAMELEONVOLUME___RENDERABLEKAMELEONVOLUME___H__ +#define __OPENSPACE_MODULE_KAMELEONVOLUME___RENDERABLEKAMELEONVOLUME___H__ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + + +namespace openspace { + +struct RenderData; + +class RenderableKameleonVolume : public Renderable { +public: + RenderableKameleonVolume(const ghoul::Dictionary& dictionary); + ~RenderableKameleonVolume(); + + bool initialize() override; + bool deinitialize() override; + bool isReady() const override; + void render(const RenderData& data, RendererTasks& tasks) override; + void update(const UpdateData& data) override; + bool cachingEnabled(); + +private: + void load(); + void loadFromPath(const std::string& path); + void loadRaw(const std::string& path); + void loadCdf(const std::string& path); + void storeRaw(const std::string& path); + + std::string cacheSuffix(); + void updateTextureFromVolume(); + void updateRaycasterModelTransform(); + + properties::UVec3Property _dimensions; + properties::StringProperty _variable; + properties::Vec3Property _lowerDomainBound; + properties::Vec3Property _upperDomainBound; + properties::Vec3Property _domainScale; + bool _autoDomainBounds; + + properties::FloatProperty _lowerValueBound; + properties::FloatProperty _upperValueBound; + bool _autoValueBounds; + + properties::OptionProperty _gridType; + bool _autoGridType; + + std::shared_ptr _clipPlanes; + + properties::FloatProperty _stepSize; + properties::StringProperty _sourcePath; + properties::StringProperty _transferFunctionPath; + properties::BoolProperty _cache; + + + std::unique_ptr> _rawVolume; + std::unique_ptr> _normalizedVolume; + std::unique_ptr _raycaster; + + std::shared_ptr _volumeTexture; + std::shared_ptr _transferFunction; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___RENDERABLEKAMELEONVOLUME___H__ diff --git a/modules/kameleonvolume/shaders/boundsfs.glsl b/modules/kameleonvolume/shaders/boundsfs.glsl new file mode 100644 index 0000000000..f56b7319a7 --- /dev/null +++ b/modules/kameleonvolume/shaders/boundsfs.glsl @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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. * + ****************************************************************************************/ + +in vec4 positionLocalSpace; +in vec4 positionCameraSpace; + +#include "PowerScaling/powerScaling_fs.hglsl" +#include "fragment.glsl" + +Fragment getFragment() { + vec4 fragColor = vec4(positionLocalSpace.xyz+0.5, 1.0); + vec4 position = positionCameraSpace; + float depth = pscDepth(position); + + Fragment frag; + frag.color = fragColor; + frag.depth = depth; + return frag; +} diff --git a/modules/kameleonvolume/shaders/boundsvs.glsl b/modules/kameleonvolume/shaders/boundsvs.glsl new file mode 100644 index 0000000000..4d10ec054a --- /dev/null +++ b/modules/kameleonvolume/shaders/boundsvs.glsl @@ -0,0 +1,48 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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__ + +layout(location = 0) in vec3 vertPosition; + +uniform mat4 modelViewTransform; +uniform mat4 projectionTransform; + +out vec4 positionLocalSpace; +out vec4 positionCameraSpace; + +#include "PowerScaling/powerScaling_vs.hglsl" + +void main() { + + positionLocalSpace = vec4(vertPosition, 1.0); + positionCameraSpace = modelViewTransform * positionLocalSpace; + + vec4 positionClipSpace = projectionTransform * positionCameraSpace; + vec4 positionScreenSpace = z_normalization(positionClipSpace); + + //positionScreenSpace.z = 1.0; + // project the position to view space + gl_Position = positionScreenSpace; +} diff --git a/modules/kameleonvolume/shaders/helper.glsl b/modules/kameleonvolume/shaders/helper.glsl new file mode 100644 index 0000000000..53b011a31d --- /dev/null +++ b/modules/kameleonvolume/shaders/helper.glsl @@ -0,0 +1,42 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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. * + ****************************************************************************************/ + +#define KAMELEON_PI 3.14159265358979323846 /* pi */ +#define KAMELEON_SQRT1_3 0.57735026919 /* 1/sqrt(3) */ + +vec3 kameleon_cartesianToSpherical(vec3 zeroToOneCoords) { + // Put cartesian in [-1..1] range first + const vec3 cartesian = vec3(-1.0,-1.0,-1.0) + zeroToOneCoords * 2.0f; + + const float r = length(cartesian); + float theta, phi; + + if (r == 0.0) { + theta = phi = 0.0; + } else { + theta = acos(cartesian.z/r) / KAMELEON_PI; + phi = (KAMELEON_PI + atan(cartesian.y, cartesian.x)) / (2.0*KAMELEON_PI ); + } + return vec3(r * KAMELEON_SQRT1_3, theta, phi); +} \ No newline at end of file diff --git a/modules/kameleonvolume/shaders/raycast.glsl b/modules/kameleonvolume/shaders/raycast.glsl new file mode 100644 index 0000000000..0d21ab261b --- /dev/null +++ b/modules/kameleonvolume/shaders/raycast.glsl @@ -0,0 +1,80 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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. * + ****************************************************************************************/ + +uniform float maxStepSize#{id} = 0.02; +uniform sampler3D volumeTexture_#{id}; +uniform sampler1D transferFunction_#{id}; +uniform int gridType_#{id} = 0; + +uniform int nClips_#{id}; +uniform vec3 clipNormals_#{id}[8]; +uniform vec2 clipOffsets_#{id}[8]; + + +void sample#{id}(vec3 samplePos, + vec3 dir, + inout vec3 accumulatedColor, + inout vec3 accumulatedAlpha, + inout float stepSize) { + + vec3 transformedPos = samplePos; + if (gridType_#{id} == 1) { + transformedPos = kameleon_cartesianToSpherical(samplePos); + } + + + float clipAlpha = 1.0; + vec3 centerToPos = transformedPos - vec3(0.5); + + + for (int i = 0; i < nClips_#{id} && i < 8; i++) { + vec3 clipNormal = clipNormals_#{id}[i]; + float clipBegin = clipOffsets_#{id}[i].x; + float clipEnd = clipBegin + clipOffsets_#{id}[i].y; + clipAlpha *= smoothstep(clipBegin, clipEnd, dot(centerToPos, clipNormal)); + } + + if (clipAlpha > 0) { + float val = texture(volumeTexture_#{id}, transformedPos).r; + vec4 color = texture(transferFunction_#{id}, val); + vec3 backColor = color.rgb; + vec3 backAlpha = color.aaa; + + backColor *= stepSize * clipAlpha; + backAlpha *= stepSize * clipAlpha; + + backColor = clamp(backColor, 0.0, 1.0); + backAlpha = clamp(backAlpha, 0.0, 1.0); + + vec3 oneMinusFrontAlpha = vec3(1.0) - accumulatedAlpha; + accumulatedColor += oneMinusFrontAlpha * backColor; + accumulatedAlpha += oneMinusFrontAlpha * backAlpha; + } + + stepSize = maxStepSize#{id}; +} + +float stepSize#{id}(vec3 samplePos, vec3 dir) { + return maxStepSize#{id}; +} diff --git a/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp b/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp new file mode 100644 index 0000000000..3d0901b5f1 --- /dev/null +++ b/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp @@ -0,0 +1,164 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace { + const char* KeyInput = "Input"; + const char* KeyOutput = "Output"; + const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/kameleondocumentation/main.hbs"; + const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; + const char* JsFilename = "${OPENSPACE_DATA}/web/kameleondocumentation/script.js"; + const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; + const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; +} + +namespace openspace { + +KameleonDocumentationTask::KameleonDocumentationTask(const ghoul::Dictionary& dictionary) { + openspace::documentation::testSpecificationAndThrow( + documentation(), + dictionary, + "KameleonDocumentationTask" + ); + + _inputPath = absPath(dictionary.value(KeyInput)); + _outputPath = absPath(dictionary.value(KeyOutput)); +} + +std::string KameleonDocumentationTask::description() { + return "Extract metadata from cdf-file " + _inputPath + + " and output html documentation to " + _outputPath; +} + +void KameleonDocumentationTask::perform(const Task::ProgressCallback & progressCallback) { + KameleonVolumeReader reader(_inputPath); + ghoul::Dictionary kameleonDictionary = reader.readMetaData(); + progressCallback(0.33f); + ghoul::DictionaryJsonFormatter formatter; + + + ghoul::Dictionary dictionary = { + {"kameleon", std::move(kameleonDictionary)}, + {"version", + std::to_string(OPENSPACE_VERSION_MAJOR) + "." + + std::to_string(OPENSPACE_VERSION_MINOR) + "." + + std::to_string(OPENSPACE_VERSION_PATCH) + }, + {"input", _inputPath} + }; + + std::string json = formatter.format(dictionary); + progressCallback(0.66f); + + std::ifstream handlebarsInput(absPath(HandlebarsFilename)); + std::ifstream jsInput(absPath(JsFilename)); + + std::string jsContent; + std::back_insert_iterator jsInserter(jsContent); + + std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter); + std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter); + + std::ifstream bootstrapInput(absPath(BootstrapFilename)); + std::ifstream cssInput(absPath(CssFilename)); + + std::string cssContent; + std::back_insert_iterator cssInserter(cssContent); + + std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter); + std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter); + + std::ifstream mainTemplateInput(absPath(MainTemplateFilename)); + std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput}, + std::istreambuf_iterator{}}; + + std::ofstream file; + file.exceptions(~std::ofstream::goodbit); + file.open(_outputPath); + + std::stringstream html; + html << "\n" + << "\n" + << "\t\n" + << "\t\t\n" + << "\t\t\n" + << "\t\n" + << "\t\n" + << "\t\tDocumentation\n" + << "\t\n" + << "\t\n" + << "\t\n" + << "\n"; + + file << html.str(); + + progressCallback(1.0f); +} + +documentation::Documentation KameleonDocumentationTask::documentation() { + using namespace documentation; + return { + "KameleonDocumentationTask", + "kameleon_documentation_task", + { + { + "Type", + new StringEqualVerifier("KameleonDocumentationTask"), + "The type of this task" + }, + { + KeyInput, + new StringAnnotationVerifier("A file path to a cdf file"), + "The cdf file to extract data from" + }, + { + KeyOutput, + new StringAnnotationVerifier("A valid filepath"), + "The html file to write documentation to" + } + } + }; +} + +} // namespace openspace diff --git a/modules/kameleonvolume/tasks/kameleondocumentationtask.h b/modules/kameleonvolume/tasks/kameleondocumentationtask.h new file mode 100644 index 0000000000..9938f29979 --- /dev/null +++ b/modules/kameleonvolume/tasks/kameleondocumentationtask.h @@ -0,0 +1,48 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONDOCUMENTATIONTASK___H__ +#define __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONDOCUMENTATIONTASK___H__ + +#include + +#include + +namespace openspace { + +class KameleonDocumentationTask : public Task { +public: + KameleonDocumentationTask(const ghoul::Dictionary& dictionary); + std::string description() override; + void perform(const Task::ProgressCallback& progressCallback) override; + static documentation::Documentation documentation(); + +private: + std::string _inputPath; + std::string _outputPath; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONDOCUMENTATIONTASK___H__ diff --git a/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp new file mode 100644 index 0000000000..19b8c81679 --- /dev/null +++ b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp @@ -0,0 +1,98 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace { + const char* KeyInput = "Input"; + const char* KeyOutput = "Output"; +} + +namespace openspace { + +KameleonMetadataToJsonTask::KameleonMetadataToJsonTask( + const ghoul::Dictionary& dictionary) +{ + openspace::documentation::testSpecificationAndThrow( + documentation(), + dictionary, + "KameleonMetadataToJsonTask" + ); + + _inputPath = absPath(dictionary.value(KeyInput)); + _outputPath = absPath(dictionary.value(KeyOutput)); +} + +std::string KameleonMetadataToJsonTask::description() { + return "Extract metadata from cdf-file " + _inputPath + + " and write as json to " + _outputPath; +} + +void KameleonMetadataToJsonTask::perform(const Task::ProgressCallback& progressCallback) { + KameleonVolumeReader reader(_inputPath); + ghoul::Dictionary dictionary = reader.readMetaData(); + progressCallback(0.5f); + + ghoul::DictionaryJsonFormatter formatter; + std::string json = formatter.format(dictionary); + std::ofstream output(_outputPath); + output << json; + progressCallback(1.0f); +} + +documentation::Documentation KameleonMetadataToJsonTask::documentation() { + using namespace documentation; + return { + "KameleonMetadataToJsonTask", + "kameleon_metadata_to_json_task", + { + { + "Type", + new StringEqualVerifier("KameleonMetadataToJsonTask"), + "The type of this task" + }, + { + KeyInput, + new StringAnnotationVerifier("A file path to a cdf file"), + "The cdf file to extract data from" + }, + { + KeyOutput, + new StringAnnotationVerifier("A valid filepath"), + "The json file to export data into" + } + } + }; +} + +} // namespace openspace diff --git a/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.h b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.h new file mode 100644 index 0000000000..42bf6a84b3 --- /dev/null +++ b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.h @@ -0,0 +1,48 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONMETADATATOJSONTASK___H__ +#define __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONMETADATATOJSONTASK___H__ + +#include + +#include + +namespace openspace { + +class KameleonMetadataToJsonTask : public Task { +public: + KameleonMetadataToJsonTask(const ghoul::Dictionary& dictionary); + std::string description() override; + void perform(const Task::ProgressCallback& progressCallback) override; + static documentation::Documentation documentation(); + +private: + std::string _inputPath; + std::string _outputPath; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONMETADATATOJSONTASK___H__ diff --git a/modules/multiresvolume/CMakeLists.txt b/modules/multiresvolume/CMakeLists.txt index a316db5dc3..da1585653c 100644 --- a/modules/multiresvolume/CMakeLists.txt +++ b/modules/multiresvolume/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/multiresvolume/multiresvolumemodule.cpp b/modules/multiresvolume/multiresvolumemodule.cpp index 13f988638c..e5c64dabcb 100644 --- a/modules/multiresvolume/multiresvolumemodule.cpp +++ b/modules/multiresvolume/multiresvolumemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/multiresvolumemodule.h b/modules/multiresvolume/multiresvolumemodule.h index 5f12395790..9d0a504c0d 100644 --- a/modules/multiresvolume/multiresvolumemodule.h +++ b/modules/multiresvolume/multiresvolumemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/atlasmanager.cpp b/modules/multiresvolume/rendering/atlasmanager.cpp index ad54463c76..761ab98184 100644 --- a/modules/multiresvolume/rendering/atlasmanager.cpp +++ b/modules/multiresvolume/rendering/atlasmanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/atlasmanager.h b/modules/multiresvolume/rendering/atlasmanager.h index 5da58ae0c0..9abf4c55d4 100644 --- a/modules/multiresvolume/rendering/atlasmanager.h +++ b/modules/multiresvolume/rendering/atlasmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/brickcover.h b/modules/multiresvolume/rendering/brickcover.h index 463712e169..dee71e7fc4 100644 --- a/modules/multiresvolume/rendering/brickcover.h +++ b/modules/multiresvolume/rendering/brickcover.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/brickmanager.cpp b/modules/multiresvolume/rendering/brickmanager.cpp index 7d4d284c07..56a66f1ccd 100644 --- a/modules/multiresvolume/rendering/brickmanager.cpp +++ b/modules/multiresvolume/rendering/brickmanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -424,14 +424,12 @@ bool BrickManager::DiskToPBO(BUFFER_INDEX _pboIndex) { } } - - delete[] seqBuffer; - } // if in pbo // Update the brick index brickIndex += sequence; + delete[] seqBuffer; } glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); diff --git a/modules/multiresvolume/rendering/brickmanager.h b/modules/multiresvolume/rendering/brickmanager.h index e0be43600f..75e010041b 100644 --- a/modules/multiresvolume/rendering/brickmanager.h +++ b/modules/multiresvolume/rendering/brickmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/brickselection.h b/modules/multiresvolume/rendering/brickselection.h index 27d899e3ba..7175497b4b 100644 --- a/modules/multiresvolume/rendering/brickselection.h +++ b/modules/multiresvolume/rendering/brickselection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/brickselector.h b/modules/multiresvolume/rendering/brickselector.h index 80e5978060..b9dab1d1fb 100644 --- a/modules/multiresvolume/rendering/brickselector.h +++ b/modules/multiresvolume/rendering/brickselector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/errorhistogrammanager.cpp b/modules/multiresvolume/rendering/errorhistogrammanager.cpp index 9db36064b4..03e8f78fbf 100644 --- a/modules/multiresvolume/rendering/errorhistogrammanager.cpp +++ b/modules/multiresvolume/rendering/errorhistogrammanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -94,7 +94,7 @@ bool ErrorHistogramManager::buildFromLeaf(unsigned int bstOffset, unsigned int o int numOtNodes = _tsp->numOTNodes(); unsigned int leafIndex = bstOffset * numOtNodes + octreeOffset; std::vector leafValues = readValues(leafIndex); - int numVoxels = leafValues.size(); +// int numVoxels = leafValues.size(); int bstNode = bstOffset; bool bstRightOnly = true; diff --git a/modules/multiresvolume/rendering/errorhistogrammanager.h b/modules/multiresvolume/rendering/errorhistogrammanager.h index 4237335a3a..973c4af441 100644 --- a/modules/multiresvolume/rendering/errorhistogrammanager.h +++ b/modules/multiresvolume/rendering/errorhistogrammanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/histogrammanager.cpp b/modules/multiresvolume/rendering/histogrammanager.cpp index d0ad52c000..4464a13ce1 100644 --- a/modules/multiresvolume/rendering/histogrammanager.cpp +++ b/modules/multiresvolume/rendering/histogrammanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/histogrammanager.h b/modules/multiresvolume/rendering/histogrammanager.h index fbdafaee11..f14a909101 100644 --- a/modules/multiresvolume/rendering/histogrammanager.h +++ b/modules/multiresvolume/rendering/histogrammanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp b/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp index 1b3926457b..fac133e991 100644 --- a/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp +++ b/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/localerrorhistogrammanager.h b/modules/multiresvolume/rendering/localerrorhistogrammanager.h index c76b859aea..86f82a30cc 100644 --- a/modules/multiresvolume/rendering/localerrorhistogrammanager.h +++ b/modules/multiresvolume/rendering/localerrorhistogrammanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/localtfbrickselector.cpp b/modules/multiresvolume/rendering/localtfbrickselector.cpp index dcfa208c41..b20c1c7a48 100644 --- a/modules/multiresvolume/rendering/localtfbrickselector.cpp +++ b/modules/multiresvolume/rendering/localtfbrickselector.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -91,7 +91,7 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) unsigned int brickIndex = bs.brickIndex; priorityQueue.pop_back(); if (bs.splitType == BrickSelection::SplitType::Temporal) { - int timeSpanCenter = bs.centerT(); +// int timeSpanCenter = bs.centerT(); unsigned int childBrickIndex; bool pickRightTimeChild = bs.timestepInRightChild(timestep); diff --git a/modules/multiresvolume/rendering/localtfbrickselector.h b/modules/multiresvolume/rendering/localtfbrickselector.h index 62990e10f9..823cab52c9 100644 --- a/modules/multiresvolume/rendering/localtfbrickselector.h +++ b/modules/multiresvolume/rendering/localtfbrickselector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp b/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp index 332e5d3ce9..73b694918d 100644 --- a/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp +++ b/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -47,7 +47,8 @@ namespace { namespace openspace { -MultiresVolumeRaycaster::MultiresVolumeRaycaster(std::shared_ptr tsp, +MultiresVolumeRaycaster::MultiresVolumeRaycaster( + std::shared_ptr tsp, std::shared_ptr atlasManager, std::shared_ptr transferFunction) : _tsp(tsp) @@ -112,11 +113,9 @@ void MultiresVolumeRaycaster::preRaycast(const RaycastData& data, ghoul::opengl: _atlasManager->textureAtlas().bind(); program.setUniform("textureAtlas_" + id, _atlasUnit->unitNumber()); - _atlasMapBinding = std::make_unique>(); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, _atlasMapBinding->bindingNumber(), _atlasManager->atlasMapBuffer()); program.setSsboBinding("atlasMapBlock_" + id, _atlasMapBinding->bindingNumber()); - program.setUniform("gridType_" + id, static_cast(_tsp->header().gridType_)); program.setUniform("maxNumBricksPerAxis_" + id, static_cast(_tsp->header().xNumBricks_)); @@ -155,7 +154,8 @@ bool MultiresVolumeRaycaster::cameraIsInside(const RenderData& data, glm::vec3& } void MultiresVolumeRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) { - // For example: release texture units + _atlasUnit = nullptr; + _tfUnit = nullptr; } std::string MultiresVolumeRaycaster::getBoundsVsPath() const { diff --git a/modules/multiresvolume/rendering/multiresvolumeraycaster.h b/modules/multiresvolume/rendering/multiresvolumeraycaster.h index bd8784d00b..c08a75e0c4 100644 --- a/modules/multiresvolume/rendering/multiresvolumeraycaster.h +++ b/modules/multiresvolume/rendering/multiresvolumeraycaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -95,4 +95,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_MULTIRESVOLUME___MULTIRESVOLUMERAYCASTER___H__ +#endif // __OPENSPACE_MODULE_MULTIRESVOLUME___MULTIRESVOLUMERAYCASTER___H__ diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index 2da28a3a05..7da992b017 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.h b/modules/multiresvolume/rendering/renderablemultiresvolume.h index a24315d8de..c1c8556686 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.h +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/shenbrickselector.cpp b/modules/multiresvolume/rendering/shenbrickselector.cpp index e0549b4859..89e346aa22 100644 --- a/modules/multiresvolume/rendering/shenbrickselector.cpp +++ b/modules/multiresvolume/rendering/shenbrickselector.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/shenbrickselector.h b/modules/multiresvolume/rendering/shenbrickselector.h index 3001b94b56..3dfe2b7645 100644 --- a/modules/multiresvolume/rendering/shenbrickselector.h +++ b/modules/multiresvolume/rendering/shenbrickselector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/simpletfbrickselector.cpp b/modules/multiresvolume/rendering/simpletfbrickselector.cpp index c409e23666..63cf1b98e5 100644 --- a/modules/multiresvolume/rendering/simpletfbrickselector.cpp +++ b/modules/multiresvolume/rendering/simpletfbrickselector.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/simpletfbrickselector.h b/modules/multiresvolume/rendering/simpletfbrickselector.h index 11bbae032d..7b7463a1a4 100644 --- a/modules/multiresvolume/rendering/simpletfbrickselector.h +++ b/modules/multiresvolume/rendering/simpletfbrickselector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/tfbrickselector.cpp b/modules/multiresvolume/rendering/tfbrickselector.cpp index b0d889bb20..3057459047 100644 --- a/modules/multiresvolume/rendering/tfbrickselector.cpp +++ b/modules/multiresvolume/rendering/tfbrickselector.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/tfbrickselector.h b/modules/multiresvolume/rendering/tfbrickselector.h index e411b453c6..4cc9a16706 100644 --- a/modules/multiresvolume/rendering/tfbrickselector.h +++ b/modules/multiresvolume/rendering/tfbrickselector.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/tsp.cpp b/modules/multiresvolume/rendering/tsp.cpp index 74c1cf0400..003c2af590 100644 --- a/modules/multiresvolume/rendering/tsp.cpp +++ b/modules/multiresvolume/rendering/tsp.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/rendering/tsp.h b/modules/multiresvolume/rendering/tsp.h index d182238284..9c7e34cb17 100644 --- a/modules/multiresvolume/rendering/tsp.h +++ b/modules/multiresvolume/rendering/tsp.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/multiresvolume/shaders/boundsFs.glsl b/modules/multiresvolume/shaders/boundsFs.glsl index bb4f9c8cd3..e54fa90dbc 100644 --- a/modules/multiresvolume/shaders/boundsFs.glsl +++ b/modules/multiresvolume/shaders/boundsFs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/CMakeLists.txt b/modules/newhorizons/CMakeLists.txt index ee275651ac..5d94356edf 100644 --- a/modules/newhorizons/CMakeLists.txt +++ b/modules/newhorizons/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/newhorizons/newhorizonsmodule.cpp b/modules/newhorizons/newhorizonsmodule.cpp index 59168a207c..476e948ad1 100644 --- a/modules/newhorizons/newhorizonsmodule.cpp +++ b/modules/newhorizons/newhorizonsmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -69,7 +70,7 @@ void NewHorizonsModule::internalInitialize() { fDecoder->registerClass("Target"); } -std::vector NewHorizonsModule::documentations() const { +std::vector NewHorizonsModule::documentations() const { return { RenderableModelProjection::Documentation(), RenderablePlanetProjection::Documentation(), diff --git a/modules/newhorizons/newhorizonsmodule.h b/modules/newhorizons/newhorizonsmodule.h index 8bd39cbce4..20acee08cb 100644 --- a/modules/newhorizons/newhorizonsmodule.h +++ b/modules/newhorizons/newhorizonsmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __NEWHORIZONSMODULE_H__ -#define __NEWHORIZONSMODULE_H__ +#ifndef __OPENSPACE_MODULE_NEWHORIZONS___NEWHORIZONS_MODULE___H__ +#define __OPENSPACE_MODULE_NEWHORIZONS___NEWHORIZONS_MODULE___H__ #include @@ -33,7 +33,7 @@ class NewHorizonsModule : public OpenSpaceModule { public: NewHorizonsModule(); - std::vector documentations() const override; + std::vector documentations() const override; protected: void internalInitialize() override; @@ -41,4 +41,4 @@ protected: } // namespace openspace -#endif // __NEWHORIZONSMODULE_H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___NEWHORIZONS_MODULE___H__ diff --git a/modules/newhorizons/rendering/renderablecrawlingline.cpp b/modules/newhorizons/rendering/renderablecrawlingline.cpp index 7a78fa451c..ebbc4183c1 100644 --- a/modules/newhorizons/rendering/renderablecrawlingline.cpp +++ b/modules/newhorizons/rendering/renderablecrawlingline.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/rendering/renderablecrawlingline.h b/modules/newhorizons/rendering/renderablecrawlingline.h index 3b8728914e..06753a995c 100644 --- a/modules/newhorizons/rendering/renderablecrawlingline.h +++ b/modules/newhorizons/rendering/renderablecrawlingline.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index f906129321..fe5048d60a 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/rendering/renderablefov.h b/modules/newhorizons/rendering/renderablefov.h index 58292e39d1..c57091cd09 100644 --- a/modules/newhorizons/rendering/renderablefov.h +++ b/modules/newhorizons/rendering/renderablefov.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -84,7 +84,7 @@ public: // instance variables int _nrInserted = 0; bool _rebuild = false; - bool _interceptTag[8]; + bool _interceptTag[35]; bool _withinFOV; std::vector _projectionBounds; psc _interceptVector; diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index 29b5b5a05e..498ad2aea2 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -41,7 +42,7 @@ #include namespace { - const std::string _loggerCat = "RenderableModelProjection"; + const char* _loggerCat = "RenderableModelProjection"; const char* keySource = "Rotation.Source"; const char* keyDestination = "Rotation.Destination"; const char* keyGeometry = "Geometry"; @@ -55,7 +56,7 @@ namespace { namespace openspace { -Documentation RenderableModelProjection::Documentation() { +documentation::Documentation RenderableModelProjection::Documentation() { using namespace documentation; return { diff --git a/modules/newhorizons/rendering/renderablemodelprojection.h b/modules/newhorizons/rendering/renderablemodelprojection.h index 4beaa8a52e..ac85b7df0d 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.h +++ b/modules/newhorizons/rendering/renderablemodelprojection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,7 +29,6 @@ #include -#include #include #include @@ -43,6 +42,7 @@ class Texture; } namespace openspace { +namespace documentation { struct Documentation; } struct RenderData; struct UpdateData; @@ -66,7 +66,7 @@ public: ghoul::opengl::Texture& baseTexture() const; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: bool loadTextures(); @@ -110,4 +110,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_NEWHORIZONS___RENDERABLEMODELPROJECTION___H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___RENDERABLEMODELPROJECTION___H__ diff --git a/modules/newhorizons/rendering/renderableplaneprojection.cpp b/modules/newhorizons/rendering/renderableplaneprojection.cpp index 82adbd6acd..efbae8d9a7 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.cpp +++ b/modules/newhorizons/rendering/renderableplaneprojection.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 diff --git a/modules/newhorizons/rendering/renderableplaneprojection.h b/modules/newhorizons/rendering/renderableplaneprojection.h index b38298833a..72a5413e5b 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.h +++ b/modules/newhorizons/rendering/renderableplaneprojection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index c53065bf0f..15e4b424bc 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -56,6 +57,7 @@ namespace { const char* keyGeometry = "Geometry"; const char* keyProjection = "Projection"; + const char* keyMeridianShift = "Textures.MeridianShift"; const char* keyColorTexture = "Textures.Color"; const char* keyHeightTexture = "Textures.Height"; @@ -66,7 +68,7 @@ namespace { namespace openspace { -Documentation RenderablePlanetProjection::Documentation() { +documentation::Documentation RenderablePlanetProjection::Documentation() { using namespace openspace::documentation; return { "Renderable Planet Projection", @@ -90,6 +92,13 @@ Documentation RenderablePlanetProjection::Documentation() { "Contains information about projecting onto this planet.", Optional::No }, + { + keyMeridianShift, + new BoolVerifier, + "Determines whether the meridian of the planet should be shifted by 180 " + "degrees. The default value is 'false'", + Optional::Yes + }, { keyColorTexture, new StringVerifier, @@ -117,6 +126,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _heightMapTexturePath("heightMap", "Heightmap Texture") , _rotation("rotation", "Rotation", 0, 0, 360) , _heightExaggeration("heightExaggeration", "Height Exaggeration", 1.f, 0.f, 100.f) + , _shiftMeridianBy180("shiftMeiridian", "Shift Meridian by 180 deg", false) , _debugProjectionTextureRotation("debug.projectionTextureRotation", "Projection Texture Rotation", 0.f, 0.f, 360.f) , _programObject(nullptr) , _fboProgramObject(nullptr) @@ -151,14 +161,19 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& // as the requirements are fixed (ab) std::string texturePath = ""; success = dictionary.getValue("Textures.Color", texturePath); - if (success){ + if (success) { _colorTexturePath = absPath(texturePath); } std::string heightMapPath = ""; success = dictionary.getValue("Textures.Height", heightMapPath); - if (success) + if (success) { _heightMapTexturePath = absPath(heightMapPath); + } + + if (dictionary.hasKeyAndValue(keyMeridianShift)) { + _shiftMeridianBy180 = dictionary.value(keyMeridianShift); + } glm::vec2 radius = glm::vec2(1.0, 9.0); dictionary.getValue(keyRadius, radius); @@ -175,6 +190,8 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& addProperty(_heightExaggeration); addProperty(_debugProjectionTextureRotation); + + addProperty(_shiftMeridianBy180); } RenderablePlanetProjection::~RenderablePlanetProjection() {} @@ -415,7 +432,9 @@ void RenderablePlanetProjection::render(const RenderData& data) { //_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value())); //setPscUniforms(*_programObject.get(), data.camera, data.position); - + + _programObject->setUniform("shiftMeridian", _shiftMeridianBy180); + ghoul::opengl::TextureUnit unit[3]; unit[0].activate(); _baseTexture->bind(); diff --git a/modules/newhorizons/rendering/renderableplanetprojection.h b/modules/newhorizons/rendering/renderableplanetprojection.h index 5cc7c6d425..8c09ba32bd 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.h +++ b/modules/newhorizons/rendering/renderableplanetprojection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,6 +32,7 @@ #include namespace openspace { +namespace documentation { struct Documentation; } struct Image; @@ -52,7 +53,7 @@ public: void update(const UpdateData& data) override; ghoul::opengl::Texture& baseTexture() const; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: bool loadTextures(); @@ -75,6 +76,8 @@ private: std::unique_ptr _baseTexture; std::unique_ptr _heightMapTexture; + properties::BoolProperty _shiftMeridianBy180; + properties::FloatProperty _heightExaggeration; properties::FloatProperty _debugProjectionTextureRotation; @@ -103,4 +106,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_NEWHORIZONS___RENDERABLEPLANETPROJECTION___H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___RENDERABLEPLANETPROJECTION___H__ diff --git a/modules/newhorizons/rendering/renderableshadowcylinder.cpp b/modules/newhorizons/rendering/renderableshadowcylinder.cpp index 2c1d588011..2350cb5e5f 100644 --- a/modules/newhorizons/rendering/renderableshadowcylinder.cpp +++ b/modules/newhorizons/rendering/renderableshadowcylinder.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/rendering/renderableshadowcylinder.h b/modules/newhorizons/rendering/renderableshadowcylinder.h index 8d33d95168..9e214a3581 100644 --- a/modules/newhorizons/rendering/renderableshadowcylinder.h +++ b/modules/newhorizons/rendering/renderableshadowcylinder.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/crawlingline_fs.glsl b/modules/newhorizons/shaders/crawlingline_fs.glsl index a01baaf749..9f0eb3b8ad 100644 --- a/modules/newhorizons/shaders/crawlingline_fs.glsl +++ b/modules/newhorizons/shaders/crawlingline_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/crawlingline_vs.glsl b/modules/newhorizons/shaders/crawlingline_vs.glsl index d5e5b1b681..8145739af4 100644 --- a/modules/newhorizons/shaders/crawlingline_vs.glsl +++ b/modules/newhorizons/shaders/crawlingline_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/dilation_fs.glsl b/modules/newhorizons/shaders/dilation_fs.glsl index d5a740d681..f81ca0518f 100644 --- a/modules/newhorizons/shaders/dilation_fs.glsl +++ b/modules/newhorizons/shaders/dilation_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/dilation_vs.glsl b/modules/newhorizons/shaders/dilation_vs.glsl index 2efb3027e4..71ecd298d7 100644 --- a/modules/newhorizons/shaders/dilation_vs.glsl +++ b/modules/newhorizons/shaders/dilation_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/fov_fs.glsl b/modules/newhorizons/shaders/fov_fs.glsl index fcd3bd2c65..0b29147ea5 100644 --- a/modules/newhorizons/shaders/fov_fs.glsl +++ b/modules/newhorizons/shaders/fov_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/fov_vs.glsl b/modules/newhorizons/shaders/fov_vs.glsl index 757b7dc336..be0a93f3a5 100644 --- a/modules/newhorizons/shaders/fov_vs.glsl +++ b/modules/newhorizons/shaders/fov_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderableModelDepth_fs.glsl b/modules/newhorizons/shaders/renderableModelDepth_fs.glsl index 2b7bcfdaec..d1fe2340d8 100644 --- a/modules/newhorizons/shaders/renderableModelDepth_fs.glsl +++ b/modules/newhorizons/shaders/renderableModelDepth_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderableModelProjection_fs.glsl b/modules/newhorizons/shaders/renderableModelProjection_fs.glsl index 7c69bc65bf..22313e8869 100644 --- a/modules/newhorizons/shaders/renderableModelProjection_fs.glsl +++ b/modules/newhorizons/shaders/renderableModelProjection_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderableModelProjection_vs.glsl b/modules/newhorizons/shaders/renderableModelProjection_vs.glsl index 2be32b0119..96e8832484 100644 --- a/modules/newhorizons/shaders/renderableModelProjection_vs.glsl +++ b/modules/newhorizons/shaders/renderableModelProjection_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderableModel_fs.glsl b/modules/newhorizons/shaders/renderableModel_fs.glsl index efe16cf13c..2b9f770cc0 100644 --- a/modules/newhorizons/shaders/renderableModel_fs.glsl +++ b/modules/newhorizons/shaders/renderableModel_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderableModel_vs.glsl b/modules/newhorizons/shaders/renderableModel_vs.glsl index 02e5a2831d..1870205549 100644 --- a/modules/newhorizons/shaders/renderableModel_vs.glsl +++ b/modules/newhorizons/shaders/renderableModel_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl b/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl index ff8698c866..34020b7eef 100644 --- a/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl +++ b/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -83,8 +83,6 @@ void main() { inRange(projected.y, 0, 1)) && dot(v_b, normal) < 0 ) { - // The 1-x is in this texture call because of flipped textures - // to be fixed soon ---abock color = texture(projectionTexture, vec2(projected.x, projected.y)); stencil = vec4(1.0); } @@ -92,4 +90,4 @@ void main() { color = vec4(0.0); stencil = vec4(0.0); } -} \ No newline at end of file +} diff --git a/modules/newhorizons/shaders/renderablePlanetProjection_vs.glsl b/modules/newhorizons/shaders/renderablePlanetProjection_vs.glsl index d709738859..121226ca23 100644 --- a/modules/newhorizons/shaders/renderablePlanetProjection_vs.glsl +++ b/modules/newhorizons/shaders/renderablePlanetProjection_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/renderablePlanet_fs.glsl b/modules/newhorizons/shaders/renderablePlanet_fs.glsl index c2a2b841ad..01952d4030 100644 --- a/modules/newhorizons/shaders/renderablePlanet_fs.glsl +++ b/modules/newhorizons/shaders/renderablePlanet_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,6 +32,7 @@ in vec2 vs_st; uniform sampler2D baseTexture; uniform sampler2D projectionTexture; +uniform bool shiftMeridian; uniform float _projectionFading; @@ -39,6 +40,11 @@ uniform vec4 objpos; uniform vec3 sun_pos; Fragment getFragment() { + vec2 st = vs_st; + if (shiftMeridian) { + st.s += 0.5; + } + // directional lighting vec3 origin = vec3(0.0); vec4 spec = vec4(0.0); @@ -49,13 +55,12 @@ Fragment getFragment() { vec3 l_dir = normalize(l_pos-objpos.xyz); float terminatorBrightness = 0.4; float intensity = min(max(5*dot(n,l_dir), terminatorBrightness), 1); - float shine = 0.0001; vec4 specular = vec4(0.1); vec4 ambient = vec4(0.f,0.f,0.f,1); - vec4 textureColor = texture(baseTexture, vs_st); + vec4 textureColor = texture(baseTexture, st); vec4 projectionColor = texture(projectionTexture, vs_st); if (projectionColor.a != 0.0) { textureColor.rgb = mix( diff --git a/modules/newhorizons/shaders/renderablePlanet_vs.glsl b/modules/newhorizons/shaders/renderablePlanet_vs.glsl index a4670af960..002a2a889c 100644 --- a/modules/newhorizons/shaders/renderablePlanet_vs.glsl +++ b/modules/newhorizons/shaders/renderablePlanet_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -44,9 +44,16 @@ uniform mat4 modelViewProjectionTransform; uniform bool _hasHeightMap; uniform float _heightExaggeration; uniform sampler2D heightTexture; +uniform bool shiftMeridian; void main() { vs_st = in_st; + + vec2 st = in_st; + if (shiftMeridian) { + st.s += 0.5; + } + vec4 tmp = in_position; // this is wrong for the normal. @@ -55,7 +62,7 @@ void main() { if (_hasHeightMap) { - float height = texture(heightTexture, in_st).r; + float height = texture(heightTexture, st).s; vec3 displacementDirection = (normalize(tmp.xyz)); float displacementFactor = height * _heightExaggeration / 750.0; tmp.xyz = tmp.xyz + displacementDirection * displacementFactor; diff --git a/modules/newhorizons/shaders/terminatorshadow_fs.glsl b/modules/newhorizons/shaders/terminatorshadow_fs.glsl index 82af216b65..4160925e9f 100644 --- a/modules/newhorizons/shaders/terminatorshadow_fs.glsl +++ b/modules/newhorizons/shaders/terminatorshadow_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/shaders/terminatorshadow_vs.glsl b/modules/newhorizons/shaders/terminatorshadow_vs.glsl index 5b1c864925..8a215f8063 100644 --- a/modules/newhorizons/shaders/terminatorshadow_vs.glsl +++ b/modules/newhorizons/shaders/terminatorshadow_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/decoder.cpp b/modules/newhorizons/util/decoder.cpp index 76874d7e79..e820da47ba 100644 --- a/modules/newhorizons/util/decoder.cpp +++ b/modules/newhorizons/util/decoder.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -35,7 +35,7 @@ std::unique_ptr Decoder::createFromDictionary( const ghoul::Dictionary& dictionary, const std::string& type) { ghoul::TemplateFactory* factory = FactoryManager::ref().factory(); - Decoder* result = factory->create(type, dictionary); + std::unique_ptr result = factory->create(type, dictionary); if (result == nullptr) { throw ghoul::RuntimeError( @@ -43,7 +43,7 @@ std::unique_ptr Decoder::createFromDictionary( "Decoder" ); } - return std::unique_ptr(result); + return result; } Decoder::~Decoder() {} diff --git a/modules/newhorizons/util/decoder.h b/modules/newhorizons/util/decoder.h index dc112edbec..e7290112fa 100644 --- a/modules/newhorizons/util/decoder.h +++ b/modules/newhorizons/util/decoder.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/hongkangparser.cpp b/modules/newhorizons/util/hongkangparser.cpp index 1d0f6fdd83..5e5ad9d345 100644 --- a/modules/newhorizons/util/hongkangparser.cpp +++ b/modules/newhorizons/util/hongkangparser.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -120,6 +120,7 @@ bool HongKangParser::create() { if (extension == "txt") { // Hong Kang. pre-parsed playbook std::ifstream file; file.exceptions(std::ofstream::failbit | std::ofstream::badbit); + file.open(absPath(_fileName)); //std::ifstream file(_fileName , std::ios::binary); //if (!file.good()){ // LERROR("Failed to open event file '" << _fileName << "'"); @@ -273,12 +274,11 @@ bool HongKangParser::augmentWithSpice(Image& image, std::string spacecraft, } for (int i = 0; i < potentialTargets.size(); ++i) { - bool _withinFOV = false; for (int j = 0; j < image.activeInstruments.size(); ++j) { double time = image.timeRange.start; for (int k = 0; k < exposureTime; k++) { time += k; - _withinFOV = SpiceManager::ref().isTargetInFieldOfView( + bool withinFOV = SpiceManager::ref().isTargetInFieldOfView( potentialTargets[i], spacecraft, image.activeInstruments[j], @@ -287,9 +287,8 @@ bool HongKangParser::augmentWithSpice(Image& image, std::string spacecraft, time ); - if (_withinFOV) { + if (withinFOV) { image.target = potentialTargets[i]; - _withinFOV = false; } } } @@ -327,4 +326,4 @@ double HongKangParser::getMetFromET(double et) { } } -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/modules/newhorizons/util/hongkangparser.h b/modules/newhorizons/util/hongkangparser.h index d8ba56ba30..8a20e21faa 100644 --- a/modules/newhorizons/util/hongkangparser.h +++ b/modules/newhorizons/util/hongkangparser.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -58,4 +58,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_NEWHORIZONS___HONGKANGPARSER___H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___HONGKANGPARSER___H__ diff --git a/modules/newhorizons/util/imagesequencer.cpp b/modules/newhorizons/util/imagesequencer.cpp index 641d171fe5..70883e2a85 100644 --- a/modules/newhorizons/util/imagesequencer.cpp +++ b/modules/newhorizons/util/imagesequencer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,9 +33,10 @@ #include #include -#include +#include #include #include +#include #include #include @@ -387,7 +388,8 @@ void ImageSequencer::runSequenceParser(SequenceParser* parser){ std::vector captureProgression = parser->getCaptureProgression(); //in5 // check for sanity - if (translations.empty() || imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) { + //if (translations.empty() || imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) { + if (imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) { LERROR("Missing sequence data"); return; } diff --git a/modules/newhorizons/util/imagesequencer.h b/modules/newhorizons/util/imagesequencer.h index 3b4c85a28a..3f776c68ad 100644 --- a/modules/newhorizons/util/imagesequencer.h +++ b/modules/newhorizons/util/imagesequencer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/instrumentdecoder.cpp b/modules/newhorizons/util/instrumentdecoder.cpp index 3f6b168c09..33372a28fe 100644 --- a/modules/newhorizons/util/instrumentdecoder.cpp +++ b/modules/newhorizons/util/instrumentdecoder.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/instrumentdecoder.h b/modules/newhorizons/util/instrumentdecoder.h index a8c871bd60..14b3689706 100644 --- a/modules/newhorizons/util/instrumentdecoder.h +++ b/modules/newhorizons/util/instrumentdecoder.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/instrumenttimesparser.cpp b/modules/newhorizons/util/instrumenttimesparser.cpp index f36fe308e5..fd1d3e3a90 100644 --- a/modules/newhorizons/util/instrumenttimesparser.cpp +++ b/modules/newhorizons/util/instrumenttimesparser.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/instrumenttimesparser.h b/modules/newhorizons/util/instrumenttimesparser.h index 30f3ab2372..0238bb20ec 100644 --- a/modules/newhorizons/util/instrumenttimesparser.h +++ b/modules/newhorizons/util/instrumenttimesparser.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -59,4 +59,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_NEWHORIZONS___INSTRUMENTTIMESPARSER___H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___INSTRUMENTTIMESPARSER___H__ diff --git a/modules/newhorizons/util/labelparser.cpp b/modules/newhorizons/util/labelparser.cpp index aee435c75c..6f3a72986c 100644 --- a/modules/newhorizons/util/labelparser.cpp +++ b/modules/newhorizons/util/labelparser.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -184,12 +185,13 @@ bool LabelParser::create() { do { std::getline(file, line); - std::string read = line.substr(0, line.find_first_of(" ")); line.erase(std::remove(line.begin(), line.end(), '"'), line.end()); line.erase(std::remove(line.begin(), line.end(), ' '), line.end()); line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); + std::string read = line.substr(0, line.find_first_of("=")); + _detectorType = "CAMERA"; //default value /* Add more */ @@ -217,15 +219,19 @@ bool LabelParser::create() { if (read == "START_TIME"){ - std::string start = line.substr(line.find("=") + 2); + std::string start = line.substr(line.find("=") + 1); start.erase(std::remove(start.begin(), start.end(), ' '), start.end()); startTime = SpiceManager::ref().ephemerisTimeFromDate(start); count++; getline(file, line); - read = line.substr(0, line.find_first_of(" ")); + line.erase(std::remove(line.begin(), line.end(), '"'), line.end()); + line.erase(std::remove(line.begin(), line.end(), ' '), line.end()); + line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); + + read = line.substr(0, line.find_first_of("=")); if (read == "STOP_TIME"){ - std::string stop = line.substr(line.find("=") + 2); + std::string stop = line.substr(line.find("=") + 1); stop.erase( std::remove_if( stop.begin(), @@ -331,4 +337,4 @@ void LabelParser::createImage(Image& image, double startTime, double stopTime, s image.projected = false; } -} \ No newline at end of file +} diff --git a/modules/newhorizons/util/labelparser.h b/modules/newhorizons/util/labelparser.h index 6d914dce77..d55c555022 100644 --- a/modules/newhorizons/util/labelparser.h +++ b/modules/newhorizons/util/labelparser.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -72,4 +72,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_NEWHORIZONS___LABELPARSER___H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___LABELPARSER___H__ diff --git a/modules/newhorizons/util/projectioncomponent.cpp b/modules/newhorizons/util/projectioncomponent.cpp index bb4a7b8d64..e6e542c16a 100644 --- a/modules/newhorizons/util/projectioncomponent.cpp +++ b/modules/newhorizons/util/projectioncomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -76,7 +77,7 @@ namespace openspace { using ghoul::Dictionary; using glm::ivec2; -Documentation ProjectionComponent::Documentation() { +documentation::Documentation ProjectionComponent::Documentation() { using namespace documentation; return { "Projection Component", @@ -165,7 +166,7 @@ Documentation ProjectionComponent::Documentation() { } ProjectionComponent::ProjectionComponent() - : properties::PropertyOwner() + : properties::PropertyOwner("ProjectionComponent") , _performProjection("performProjection", "Perform Projections", true) , _clearAllProjections("clearAllProjections", "Clear Projections", false) , _projectionFading("projectionFading", "Projection Fading", 1.f, 0.f, 1.f) @@ -174,8 +175,6 @@ ProjectionComponent::ProjectionComponent() , _textureSizeDirty(false) , _projectionTexture(nullptr) { - setName("ProjectionComponent"); - _shadowing.isEnabled = false; _dilation.isEnabled = false; @@ -242,7 +241,7 @@ void ProjectionComponent::initialize(const ghoul::Dictionary& dictionary) { if (foundSequence) { sequenceSource = absPath(sequenceSource); - foundSequence = dictionary.getValue(keySequenceType, sequenceType); + dictionary.getValue(keySequenceType, sequenceType); //Important: client must define translation-list in mod file IFF playbook if (dictionary.hasKey(keyTranslation)) { ghoul::Dictionary translationDictionary; @@ -271,7 +270,7 @@ void ProjectionComponent::initialize(const ghoul::Dictionary& dictionary) { translationDictionary)); std::string _eventFile; - bool foundEventFile = dictionary.getValue("Projection.EventFile", _eventFile); + bool foundEventFile = dictionary.getValue("EventFile", _eventFile); if (foundEventFile) { //then read playbook _eventFile = absPath(_eventFile); diff --git a/modules/newhorizons/util/projectioncomponent.h b/modules/newhorizons/util/projectioncomponent.h index 6d82b6d0c2..7325a293bf 100644 --- a/modules/newhorizons/util/projectioncomponent.h +++ b/modules/newhorizons/util/projectioncomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -50,6 +49,8 @@ class ProgramObject; namespace openspace { +namespace documentation { struct Documentation; } + class ProjectionComponent : public properties::PropertyOwner { public: ProjectionComponent(); @@ -105,7 +106,7 @@ public: float fieldOfViewY() const; float aspectRatio() const; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: bool generateProjectionLayerTexture(const glm::ivec2& size); diff --git a/modules/newhorizons/util/scannerdecoder.cpp b/modules/newhorizons/util/scannerdecoder.cpp index c1aaa49c80..cd87074f83 100644 --- a/modules/newhorizons/util/scannerdecoder.cpp +++ b/modules/newhorizons/util/scannerdecoder.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/scannerdecoder.h b/modules/newhorizons/util/scannerdecoder.h index bd593ff691..b0453e2def 100644 --- a/modules/newhorizons/util/scannerdecoder.h +++ b/modules/newhorizons/util/scannerdecoder.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/sequenceparser.cpp b/modules/newhorizons/util/sequenceparser.cpp index 65d05b64d8..5254643707 100644 --- a/modules/newhorizons/util/sequenceparser.cpp +++ b/modules/newhorizons/util/sequenceparser.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,6 +29,8 @@ #include +#include + namespace { const std::string _loggerCat = "SequenceParser"; const char* keyTranslation = "DataInputTranslation"; @@ -170,4 +172,4 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) { OsEng.networkEngine().setInitialConnectionMessage(_messageIdentifier, buffer); } -} \ No newline at end of file +} diff --git a/modules/newhorizons/util/sequenceparser.h b/modules/newhorizons/util/sequenceparser.h index fb42910e98..974046cacb 100644 --- a/modules/newhorizons/util/sequenceparser.h +++ b/modules/newhorizons/util/sequenceparser.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -74,4 +74,4 @@ protected: } // namespace openspace -#endif //__OPENSPACE_MODULE_NEWHORIZONS___SEQUENCEPARSER___H__ +#endif // __OPENSPACE_MODULE_NEWHORIZONS___SEQUENCEPARSER___H__ diff --git a/modules/newhorizons/util/targetdecoder.cpp b/modules/newhorizons/util/targetdecoder.cpp index 4bc27c8eff..a9870dd160 100644 --- a/modules/newhorizons/util/targetdecoder.cpp +++ b/modules/newhorizons/util/targetdecoder.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/newhorizons/util/targetdecoder.h b/modules/newhorizons/util/targetdecoder.h index 04d65f3a56..6a3807b6e0 100644 --- a/modules/newhorizons/util/targetdecoder.h +++ b/modules/newhorizons/util/targetdecoder.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/CMakeLists.txt b/modules/onscreengui/CMakeLists.txt index e0064f6c70..b6a8bfb9ac 100644 --- a/modules/onscreengui/CMakeLists.txt +++ b/modules/onscreengui/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/onscreengui/ext/imgui/CMakeLists.txt b/modules/onscreengui/ext/imgui/CMakeLists.txt index 69ee237b3a..38adca106c 100644 --- a/modules/onscreengui/ext/imgui/CMakeLists.txt +++ b/modules/onscreengui/ext/imgui/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# 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. # +########################################################################################## project(Imgui) message(STATUS "Generating Imgui project") diff --git a/modules/onscreengui/include/gui.h b/modules/onscreengui/include/gui.h index dcbffff069..e1b3b45484 100644 --- a/modules/onscreengui/include/gui.h +++ b/modules/onscreengui/include/gui.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -44,7 +44,6 @@ namespace gui { class GUI : public GuiComponent { public: GUI(); - ~GUI(); void initialize(); void deinitialize(); diff --git a/modules/onscreengui/include/guicomponent.h b/modules/onscreengui/include/guicomponent.h index 7aed19c3d6..98896a4e56 100644 --- a/modules/onscreengui/include/guicomponent.h +++ b/modules/onscreengui/include/guicomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/guihelpcomponent.h b/modules/onscreengui/include/guihelpcomponent.h index 3f046405e6..2b55ccf0b3 100644 --- a/modules/onscreengui/include/guihelpcomponent.h +++ b/modules/onscreengui/include/guihelpcomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/guiiswacomponent.h b/modules/onscreengui/include/guiiswacomponent.h index 6f27fbf6de..379f33fda1 100644 --- a/modules/onscreengui/include/guiiswacomponent.h +++ b/modules/onscreengui/include/guiiswacomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/guiorigincomponent.h b/modules/onscreengui/include/guiorigincomponent.h index 79ec27f278..c97ffc4985 100644 --- a/modules/onscreengui/include/guiorigincomponent.h +++ b/modules/onscreengui/include/guiorigincomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/guiperformancecomponent.h b/modules/onscreengui/include/guiperformancecomponent.h index 241613c614..f81a072639 100644 --- a/modules/onscreengui/include/guiperformancecomponent.h +++ b/modules/onscreengui/include/guiperformancecomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/guipropertycomponent.h b/modules/onscreengui/include/guipropertycomponent.h index a97fe0e154..4fc0bb83ea 100644 --- a/modules/onscreengui/include/guipropertycomponent.h +++ b/modules/onscreengui/include/guipropertycomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/guitimecomponent.h b/modules/onscreengui/include/guitimecomponent.h index 4598eee0d1..a363bb390e 100644 --- a/modules/onscreengui/include/guitimecomponent.h +++ b/modules/onscreengui/include/guitimecomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/include/renderproperties.h b/modules/onscreengui/include/renderproperties.h index acbf461a8f..8f6cb2de88 100644 --- a/modules/onscreengui/include/renderproperties.h +++ b/modules/onscreengui/include/renderproperties.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -54,4 +54,4 @@ void renderTriggerProperty(properties::Property* prop, const std::string& ownerN } // namespace openspace -#endif __OPENSPACE_MODULE_ONSCREENGUI___RENDERPROPERTIES___H__ +#endif // __OPENSPACE_MODULE_ONSCREENGUI___RENDERPROPERTIES___H__ diff --git a/modules/onscreengui/onscreenguimodule.cpp b/modules/onscreengui/onscreenguimodule.cpp index 118beeb259..324d084c45 100644 --- a/modules/onscreengui/onscreenguimodule.cpp +++ b/modules/onscreengui/onscreenguimodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,13 +27,155 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + +#include namespace openspace { +gui::GUI OnScreenGUIModule::gui; + OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule("OnScreenGUI") { - addPropertySubOwner(OsEng.gui()); -} + addPropertySubOwner(gui); + + OsEng.registerModuleCallback( + OpenSpaceEngine::CallbackOption::Initialize, + [](){ + LDEBUGC("OnScreenGUIModule", "Initializing GUI"); + gui.initialize(); + + gui._globalProperty.setSource( + []() { + std::vector res = { + &(OsEng.windowWrapper()), + &(OsEng.settingsEngine()), + &(OsEng.interactionHandler()), + &(OsEng.renderEngine()) + }; + return res; + } + ); + + gui._screenSpaceProperty.setSource( + []() { + const auto& ssr = OsEng.renderEngine().screenSpaceRenderables(); + return std::vector(ssr.begin(), ssr.end()); + } + ); + + gui._property.setSource( + []() { + const auto& nodes = OsEng.renderEngine().scene()->allSceneGraphNodes(); + return std::vector(nodes.begin(), nodes.end()); + } + ); + } + ); + + OsEng.registerModuleCallback( + OpenSpaceEngine::CallbackOption::Deinitialize, + [](){ + LDEBUGC("OnScreenGui", "Deinitialize GUI"); + gui.deinitialize(); + } + ); + + OsEng.registerModuleCallback( + OpenSpaceEngine::CallbackOption::InitializeGL, + [](){ + LDEBUGC("OnScreenGui", "Initializing GUI OpenGL"); + gui.initializeGL(); + } + ); + + OsEng.registerModuleCallback( + OpenSpaceEngine::CallbackOption::DeinitializeGL, + [](){ + LDEBUGC("OnScreenGui", "Deinitialize GUI OpenGL"); + gui.deinitializeGL(); + } + ); + OsEng.registerModuleCallback( + OpenSpaceEngine::CallbackOption::Render, + [](){ + WindowWrapper& wrapper = OsEng.windowWrapper(); + bool showGui = wrapper.hasGuiWindow() ? wrapper.isGuiWindow() : true; + if (wrapper.isMaster() && wrapper.isRegularRendering() && showGui ) { + glm::vec2 mousePosition = wrapper.mousePosition(); + //glm::ivec2 drawBufferResolution = _windowWrapper->currentDrawBufferResolution(); + glm::ivec2 windowSize = wrapper.currentWindowSize(); + glm::ivec2 renderingSize = wrapper.currentWindowResolution(); + uint32_t mouseButtons = wrapper.mouseButtons(2); + + double dt = std::max(wrapper.averageDeltaTime(), 0.0); + + // We don't do any collection of immediate mode user interface, so it is + // fine to open and close a frame immediately + gui.startFrame( + static_cast(dt), + glm::vec2(windowSize), + wrapper.dpiScaling(), + mousePosition, + mouseButtons + ); + + gui.endFrame(); + } + } + ); + + OsEng.registerModuleKeyboardCallback( + [](Key key, KeyModifier mod, KeyAction action) -> bool { + if (gui.isEnabled()) { + return gui.keyCallback(key, mod, action); + } + else { + return false; + } + } + ); + + OsEng.registerModuleCharCallback( + [](unsigned int codepoint, KeyModifier modifier) -> bool { + if (gui.isEnabled()) { + return gui.charCallback(codepoint, modifier); + } + else { + return false; + } + } + ); + + OsEng.registerModuleMouseButtonCallback( + [](MouseButton button, MouseAction action) -> bool { + if (gui.isEnabled()) { + return gui.mouseButtonCallback(button, action); + } + else { + return false; + } + } + ); + + OsEng.registerModuleMouseScrollWheelCallback( + [](double pos) -> bool { + if (gui.isEnabled()) { + return gui.mouseWheelCallback(pos); + } + else { + return false; + } + } + ); +} + } // namespace openspace diff --git a/modules/onscreengui/onscreenguimodule.h b/modules/onscreengui/onscreenguimodule.h index ca6c59c18e..6576843c68 100644 --- a/modules/onscreengui/onscreenguimodule.h +++ b/modules/onscreengui/onscreenguimodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,11 +27,15 @@ #include -namespace openspace { +#include +namespace openspace { + class OnScreenGUIModule : public OpenSpaceModule { public: OnScreenGUIModule(); + + static gui::GUI gui; }; } // namespace openspace diff --git a/modules/onscreengui/shaders/gui_fs.glsl b/modules/onscreengui/shaders/gui_fs.glsl index 6201873727..0a53791213 100644 --- a/modules/onscreengui/shaders/gui_fs.glsl +++ b/modules/onscreengui/shaders/gui_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/shaders/gui_vs.glsl b/modules/onscreengui/shaders/gui_vs.glsl index 1b3b67d860..ac38f75c29 100644 --- a/modules/onscreengui/shaders/gui_vs.glsl +++ b/modules/onscreengui/shaders/gui_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/src/gui.cpp b/modules/onscreengui/src/gui.cpp index d0802a4a9d..fa34ff997f 100644 --- a/modules/onscreengui/src/gui.cpp +++ b/modules/onscreengui/src/gui.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -237,10 +239,6 @@ GUI::GUI() addPropertySubOwner(_iswa); } -GUI::~GUI() { - ImGui::Shutdown(); -} - void GUI::initialize() { std::string cachedFile = FileSys.cacheManager()->cachedFilename( configurationFile, "", ghoul::filesystem::CacheManager::Persistent::Yes @@ -322,6 +320,8 @@ void GUI::initialize() { } void GUI::deinitialize() { + ImGui::Shutdown(); + _iswa.deinitialize(); _help.deinitialize(); _performance.deinitialize(); @@ -408,9 +408,15 @@ void GUI::deinitializeGL() { _program = nullptr; _fontTexture = nullptr; - glDeleteVertexArrays(1, &vao); - glDeleteBuffers(1, &vbo); - glDeleteBuffers(1, &vboElements); + if (vao) { + glDeleteVertexArrays(1, &vao); + } + if (vbo) { + glDeleteBuffers(1, &vbo); + } + if (vboElements) { + glDeleteBuffers(1, &vboElements); + } _iswa.deinitializeGL(); _help.deinitializeGL(); diff --git a/modules/onscreengui/src/gui_lua.inl b/modules/onscreengui/src/gui_lua.inl index 49d4e02fc6..9155ba5d2e 100644 --- a/modules/onscreengui/src/gui_lua.inl +++ b/modules/onscreengui/src/gui_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -39,7 +39,7 @@ int show(lua_State* L) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); } - OsEng.gui().setEnabled(true); + OnScreenGUIModule::gui.setEnabled(true); return 0; } @@ -54,7 +54,7 @@ int hide(lua_State* L) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); } - OsEng.gui().setEnabled(false); + OnScreenGUIModule::gui.setEnabled(false); return 0; } @@ -69,7 +69,7 @@ int toggle(lua_State* L) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); } - OsEng.gui().setEnabled(!OsEng.gui().isEnabled()); + OnScreenGUIModule::gui.setEnabled(!OnScreenGUIModule::gui.isEnabled()); return 0; } diff --git a/modules/onscreengui/src/guicomponent.cpp b/modules/onscreengui/src/guicomponent.cpp index 27373aadf7..3c26242c6d 100644 --- a/modules/onscreengui/src/guicomponent.cpp +++ b/modules/onscreengui/src/guicomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,10 +28,9 @@ namespace openspace { namespace gui { GuiComponent::GuiComponent(std::string name) - : _isEnabled("enabled", "Is Enabled", false) + : properties::PropertyOwner(std::move(name)) + , _isEnabled("enabled", "Is Enabled", false) { - setName(std::move(name)); - addProperty(_isEnabled); } diff --git a/modules/onscreengui/src/guihelpcomponent.cpp b/modules/onscreengui/src/guihelpcomponent.cpp index f7a7bf7aad..9fb1e86bda 100644 --- a/modules/onscreengui/src/guihelpcomponent.cpp +++ b/modules/onscreengui/src/guihelpcomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/src/guiiswacomponent.cpp b/modules/onscreengui/src/guiiswacomponent.cpp index 61d5b4548d..f21ab65189 100644 --- a/modules/onscreengui/src/guiiswacomponent.cpp +++ b/modules/onscreengui/src/guiiswacomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/src/guiorigincomponent.cpp b/modules/onscreengui/src/guiorigincomponent.cpp index 1e6efdd7aa..80032549bc 100644 --- a/modules/onscreengui/src/guiorigincomponent.cpp +++ b/modules/onscreengui/src/guiorigincomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -59,7 +59,11 @@ void GuiOriginComponent::render() { } auto iCurrentFocus = std::find(nodes.begin(), nodes.end(), currentFocus); - ghoul_assert(iCurrentFocus != nodes.end(), "Focus node not found"); + if (!nodes.empty()) { + // Only check if we found the current focus node if we have any nodes at all + // only then it would be a real error + ghoul_assert(iCurrentFocus != nodes.end(), "Focus node not found"); + } int currentPosition = static_cast(std::distance(iCurrentFocus, nodes.begin())); bool hasChanged = ImGui::Combo("Origin", ¤tPosition, nodeNames.c_str()); diff --git a/modules/onscreengui/src/guiperformancecomponent.cpp b/modules/onscreengui/src/guiperformancecomponent.cpp index d11430f056..864c76c65e 100644 --- a/modules/onscreengui/src/guiperformancecomponent.cpp +++ b/modules/onscreengui/src/guiperformancecomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/src/guipropertycomponent.cpp b/modules/onscreengui/src/guipropertycomponent.cpp index edf2a1ed87..1730c48f55 100644 --- a/modules/onscreengui/src/guipropertycomponent.cpp +++ b/modules/onscreengui/src/guipropertycomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/src/guitimecomponent.cpp b/modules/onscreengui/src/guitimecomponent.cpp index 43178a2270..29ad93e8ce 100644 --- a/modules/onscreengui/src/guitimecomponent.cpp +++ b/modules/onscreengui/src/guitimecomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/onscreengui/src/renderproperties.cpp b/modules/onscreengui/src/renderproperties.cpp index 21489500ae..5a8b4dab1b 100644 --- a/modules/onscreengui/src/renderproperties.cpp +++ b/modules/onscreengui/src/renderproperties.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/CMakeLists.txt b/modules/space/CMakeLists.txt index b4fc052ad4..2964adab1d 100644 --- a/modules/space/CMakeLists.txt +++ b/modules/space/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/space/rendering/planetgeometry.cpp b/modules/space/rendering/planetgeometry.cpp index 8d437fb539..4b2ed0653b 100644 --- a/modules/space/rendering/planetgeometry.cpp +++ b/modules/space/rendering/planetgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -23,8 +23,10 @@ ****************************************************************************************/ #include + #include +#include #include namespace { @@ -35,7 +37,7 @@ namespace { namespace openspace { namespace planetgeometry { -Documentation PlanetGeometry::Documentation() { +documentation::Documentation PlanetGeometry::Documentation() { using namespace documentation; return { "Planet Geometry", @@ -51,7 +53,7 @@ Documentation PlanetGeometry::Documentation() { }; } -PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) +std::unique_ptr PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow( Documentation(), @@ -62,7 +64,7 @@ PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& di std::string geometryType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - PlanetGeometry* result = factory->create(geometryType, dictionary); + std::unique_ptr result = factory->create(geometryType, dictionary); if (result == nullptr) { throw ghoul::RuntimeError( "Failed to create a PlanetGeometry object of type '" + geometryType + "'" @@ -72,10 +74,9 @@ PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& di } PlanetGeometry::PlanetGeometry() - : _parent(nullptr) -{ - setName("PlanetGeometry"); -} + : properties::PropertyOwner("PlanetGeometry") + , _parent(nullptr) +{} PlanetGeometry::~PlanetGeometry() {} diff --git a/modules/space/rendering/planetgeometry.h b/modules/space/rendering/planetgeometry.h index d1690a4924..98b93841c9 100644 --- a/modules/space/rendering/planetgeometry.h +++ b/modules/space/rendering/planetgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,16 +27,22 @@ #include -#include +#include + +namespace ghoul { class Dictionary; } namespace openspace { + class Renderable; +namespace documentation { struct Documentation; } namespace planetgeometry { class PlanetGeometry : public properties::PropertyOwner { public: - static PlanetGeometry* createFromDictionary(const ghoul::Dictionary& dictionary); + static std::unique_ptr createFromDictionary( + const ghoul::Dictionary& dictionary + ); PlanetGeometry(); virtual ~PlanetGeometry(); @@ -44,7 +50,7 @@ public: virtual void deinitialize(); virtual void render() = 0; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: Renderable* _parent; @@ -53,4 +59,4 @@ protected: } // namespace planetgeometry } // namespace openspace -#endif // __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__ +#endif // __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__ diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index 49e7f01968..7e6ada817e 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/rendering/renderableconstellationbounds.h b/modules/space/rendering/renderableconstellationbounds.h index 68a1014513..d000c0c3d5 100644 --- a/modules/space/rendering/renderableconstellationbounds.h +++ b/modules/space/rendering/renderableconstellationbounds.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index f113d78f72..a5a9e7a691 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -83,8 +83,11 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) { std::string name; bool success = dictionary.getValue(SceneGraphNode::KeyName, name); - ghoul_assert(success, - "RenderablePlanet need the '" << SceneGraphNode::KeyName<<"' be specified"); + ghoul_assert( + success, + std::string("RenderablePlanet need the '") + SceneGraphNode::KeyName + + "' be specified" + ); ghoul::Dictionary geometryDictionary; success = dictionary.getValue(keyGeometry, geometryDictionary); @@ -125,7 +128,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) _heightMapTexturePath = absPath(heightMapTexturePath); } - addPropertySubOwner(_geometry); + addPropertySubOwner(_geometry.get()); addProperty(_colorTexturePath); _colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this)); @@ -309,7 +312,7 @@ bool RenderablePlanet::initialize() { bool RenderablePlanet::deinitialize() { if(_geometry) { _geometry->deinitialize(); - delete _geometry; + _geometry = nullptr; } RenderEngine& renderEngine = OsEng.renderEngine(); diff --git a/modules/space/rendering/renderableplanet.h b/modules/space/rendering/renderableplanet.h index 4c324cda3c..88fd81b7ad 100644 --- a/modules/space/rendering/renderableplanet.h +++ b/modules/space/rendering/renderableplanet.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -35,8 +35,9 @@ #include -#include +#include #include +#include namespace ghoul { namespace opengl { @@ -93,7 +94,7 @@ private: properties::FloatProperty _heightExaggeration; - planetgeometry::PlanetGeometry* _geometry; + std::unique_ptr _geometry; properties::BoolProperty _performShading; properties::IntProperty _rotation; float _alpha; @@ -111,6 +112,6 @@ private: bool tempPic; }; -} // namespace openspace +} // namespace openspace -#endif // __OPENSPACE_MODULE_SPACE___RENDERABLEPLANET___H__ +#endif // __OPENSPACE_MODULE_SPACE___RENDERABLEPLANET___H__ diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 75c3f8c08a..ffc6e99951 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -43,7 +44,7 @@ namespace { namespace openspace { -Documentation RenderableRings::Documentation() { +documentation::Documentation RenderableRings::Documentation() { using namespace documentation; return { "Renderable Rings", diff --git a/modules/space/rendering/renderablerings.h b/modules/space/rendering/renderablerings.h index 2df2c64a21..c606f44b7f 100644 --- a/modules/space/rendering/renderablerings.h +++ b/modules/space/rendering/renderablerings.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -44,6 +43,7 @@ namespace ghoul { } namespace openspace { +namespace documentation { struct Documentation; } class RenderableRings : public Renderable { public: @@ -57,7 +57,7 @@ public: void render(const RenderData& data) override; void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: void loadTexture(); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 108bb4639b..d233addc7b 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -82,7 +83,7 @@ namespace { namespace openspace { -openspace::Documentation RenderableStars::Documentation() { +documentation::Documentation RenderableStars::Documentation() { using namespace documentation; return { "RenderableStars", diff --git a/modules/space/rendering/renderablestars.h b/modules/space/rendering/renderablestars.h index 69e24517b3..7a8244f2cd 100644 --- a/modules/space/rendering/renderablestars.h +++ b/modules/space/rendering/renderablestars.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,23 +27,20 @@ #include -#include #include #include #include namespace ghoul { -namespace filesystem { -class File; -} -} +namespace filesystem { class File; } +namespace opengl { + class ProgramObject; + class Texture; +} // namespace opengl +} // namespace ghoul namespace openspace { - -namespace opengl { -class ProgramObject; -class Texture; -} +namespace documentation { struct Documentation; } class RenderableStars : public Renderable { public: @@ -58,7 +55,7 @@ public: void render(const RenderData& data) override; void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: enum ColorOption { @@ -105,4 +102,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_SPACE___RENDERABLESTARS___H__ +#endif // __OPENSPACE_MODULE_SPACE___RENDERABLESTARS___H__ diff --git a/modules/space/rendering/simplespheregeometry.cpp b/modules/space/rendering/simplespheregeometry.cpp index 468bc6403f..03d5aefbb8 100644 --- a/modules/space/rendering/simplespheregeometry.cpp +++ b/modules/space/rendering/simplespheregeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/rendering/simplespheregeometry.h b/modules/space/rendering/simplespheregeometry.h index c9b38220f2..35740746df 100644 --- a/modules/space/rendering/simplespheregeometry.h +++ b/modules/space/rendering/simplespheregeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/rotation/spicerotation.cpp b/modules/space/rotation/spicerotation.cpp index d6efccae16..24d2af5c12 100644 --- a/modules/space/rotation/spicerotation.cpp +++ b/modules/space/rotation/spicerotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,14 +24,14 @@ #include +#include #include #include #include namespace { - const std::string _loggerCat = "SpiceRotation"; - //const std::string keyGhosting = "EphmerisGhosting"; + const char* _loggerCat = "SpiceRotation"; const char* KeySourceFrame = "SourceFrame"; const char* KeyDestinationFrame = "DestinationFrame"; @@ -40,7 +40,7 @@ namespace { namespace openspace { -Documentation SpiceRotation::Documentation() { +documentation::Documentation SpiceRotation::Documentation() { using namespace openspace::documentation; return { "Spice Rotation", @@ -123,7 +123,7 @@ void SpiceRotation::update(const UpdateData& data) { data.time ); } - catch (...) { + catch (const SpiceManager::SpiceException&) { _matrix = glm::dmat3(1.0); } } diff --git a/modules/space/rotation/spicerotation.h b/modules/space/rotation/spicerotation.h index 94a1ec0101..b0988f1801 100644 --- a/modules/space/rotation/spicerotation.h +++ b/modules/space/rotation/spicerotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,18 +26,19 @@ #define __OPENSPACE_MODULE_SPACE___SPICEROTATION___H__ #include -#include #include namespace openspace { +namespace documentation { struct Documentation; } + class SpiceRotation : public Rotation { public: SpiceRotation(const ghoul::Dictionary& dictionary); const glm::dmat3& matrix() const; void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: properties::StringProperty _sourceFrame; diff --git a/modules/space/shaders/constellationbounds_fs.glsl b/modules/space/shaders/constellationbounds_fs.glsl index b970189e84..2c7421248f 100644 --- a/modules/space/shaders/constellationbounds_fs.glsl +++ b/modules/space/shaders/constellationbounds_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/constellationbounds_vs.glsl b/modules/space/shaders/constellationbounds_vs.glsl index 7c05a3c178..bfd6d12b0f 100644 --- a/modules/space/shaders/constellationbounds_vs.glsl +++ b/modules/space/shaders/constellationbounds_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/nighttexture_fs.glsl b/modules/space/shaders/nighttexture_fs.glsl index 94175a9f7b..22874edf3e 100644 --- a/modules/space/shaders/nighttexture_fs.glsl +++ b/modules/space/shaders/nighttexture_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/nighttexture_vs.glsl b/modules/space/shaders/nighttexture_vs.glsl index 8056fd63ad..d22246fb3f 100644 --- a/modules/space/shaders/nighttexture_vs.glsl +++ b/modules/space/shaders/nighttexture_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -65,4 +65,4 @@ void main() { vs_position = z_normalization(position); gl_Position = vs_position; -} \ No newline at end of file +} diff --git a/modules/space/shaders/renderableplanet_fs.glsl b/modules/space/shaders/renderableplanet_fs.glsl index f275091d76..9240ff32de 100644 --- a/modules/space/shaders/renderableplanet_fs.glsl +++ b/modules/space/shaders/renderableplanet_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/renderableplanet_vs.glsl b/modules/space/shaders/renderableplanet_vs.glsl index e726d0149a..b819ebcbd2 100644 --- a/modules/space/shaders/renderableplanet_vs.glsl +++ b/modules/space/shaders/renderableplanet_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -55,4 +55,4 @@ void main() { gl_Position = vs_position; -} \ No newline at end of file +} diff --git a/modules/space/shaders/rings_fs.glsl b/modules/space/shaders/rings_fs.glsl index 6de4b8503f..84c363be0c 100644 --- a/modules/space/shaders/rings_fs.glsl +++ b/modules/space/shaders/rings_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/rings_vs.glsl b/modules/space/shaders/rings_vs.glsl index 86ecefef8e..97c65e94c3 100644 --- a/modules/space/shaders/rings_vs.glsl +++ b/modules/space/shaders/rings_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/shadow_fs.glsl b/modules/space/shaders/shadow_fs.glsl index 056d8c6c00..536b6d6718 100644 --- a/modules/space/shaders/shadow_fs.glsl +++ b/modules/space/shaders/shadow_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/shadow_nighttexture_fs.glsl b/modules/space/shaders/shadow_nighttexture_fs.glsl index 2400d5a4be..b8d5b32819 100644 --- a/modules/space/shaders/shadow_nighttexture_fs.glsl +++ b/modules/space/shaders/shadow_nighttexture_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/shadow_nighttexture_vs.glsl b/modules/space/shaders/shadow_nighttexture_vs.glsl index 82c8f5545c..cb2dc8c1b1 100644 --- a/modules/space/shaders/shadow_nighttexture_vs.glsl +++ b/modules/space/shaders/shadow_nighttexture_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -65,4 +65,4 @@ void main() // coordinates. position = ViewProjection * position; gl_Position = z_normalization(position); -} \ No newline at end of file +} diff --git a/modules/space/shaders/shadow_vs.glsl b/modules/space/shaders/shadow_vs.glsl index 82c8f5545c..cb2dc8c1b1 100644 --- a/modules/space/shaders/shadow_vs.glsl +++ b/modules/space/shaders/shadow_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -65,4 +65,4 @@ void main() // coordinates. position = ViewProjection * position; gl_Position = z_normalization(position); -} \ No newline at end of file +} diff --git a/modules/space/shaders/star_fs.glsl b/modules/space/shaders/star_fs.glsl index 39cdcd0bc9..e81cb9e89b 100644 --- a/modules/space/shaders/star_fs.glsl +++ b/modules/space/shaders/star_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/star_ge.glsl b/modules/space/shaders/star_ge.glsl index 0315797b0a..4cd6b5ea5b 100644 --- a/modules/space/shaders/star_ge.glsl +++ b/modules/space/shaders/star_ge.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/shaders/star_vs.glsl b/modules/space/shaders/star_vs.glsl index c0ff07a8a9..4186923954 100644 --- a/modules/space/shaders/star_vs.glsl +++ b/modules/space/shaders/star_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index 48cb89e9ff..9fe3f5c77a 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -79,7 +80,7 @@ void SpaceModule::internalInitialize() { fPlanetGeometry->registerClass("SimpleSphere"); } -std::vector SpaceModule::documentations() const { +std::vector SpaceModule::documentations() const { return { SpiceRotation::Documentation(), SpiceTranslation::Documentation(), diff --git a/modules/space/spacemodule.h b/modules/space/spacemodule.h index 02bb96f1c1..3d954c30a9 100644 --- a/modules/space/spacemodule.h +++ b/modules/space/spacemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_SPACE___BASEMODULE___H__ -#define __OPENSPACE_MODULE_SPACE___BASEMODULE___H__ +#ifndef __OPENSPACE_MODULE_SPACE___SPACEMODULE___H__ +#define __OPENSPACE_MODULE_SPACE___SPACEMODULE___H__ #include @@ -32,8 +32,8 @@ namespace openspace { class SpaceModule : public OpenSpaceModule { public: SpaceModule(); - - std::vector documentations() const override; + virtual ~SpaceModule() = default; + std::vector documentations() const override; protected: void internalInitialize() override; @@ -41,4 +41,4 @@ protected: } // namespace openspace -#endif // __OPENSPACE_MODULE_SPACE___BASEMODULE___H__ +#endif // __OPENSPACE_MODULE_SPACE___SPACEMODULE___H__ diff --git a/modules/space/translation/keplertranslation.cpp b/modules/space/translation/keplertranslation.cpp index eb184ee198..333d24fb70 100644 --- a/modules/space/translation/keplertranslation.cpp +++ b/modules/space/translation/keplertranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -64,7 +64,7 @@ KeplerTranslation::RangeError::RangeError(std::string offender) , offender(std::move(offender)) {} -Documentation KeplerTranslation::Documentation() { +documentation::Documentation KeplerTranslation::Documentation() { using namespace openspace::documentation; return{ "Kepler Translation", diff --git a/modules/space/translation/keplertranslation.h b/modules/space/translation/keplertranslation.h index 8e74394fa0..2d2ac0ce47 100644 --- a/modules/space/translation/keplertranslation.h +++ b/modules/space/translation/keplertranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -83,7 +83,7 @@ public: * \return The openspace::Documentation that describes the ghoul::Dicitonary that can * be passed to the constructor */ - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); protected: /// Default construct that initializes all the properties and member variables diff --git a/modules/space/translation/spicetranslation.cpp b/modules/space/translation/spicetranslation.cpp index 7d1d9e451e..816385ed17 100644 --- a/modules/space/translation/spicetranslation.cpp +++ b/modules/space/translation/spicetranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,12 +24,13 @@ #include +#include +#include #include #include #include -#include namespace { const char* KeyBody = "Body"; @@ -42,7 +43,7 @@ namespace { namespace openspace { -Documentation SpiceTranslation::Documentation() { +documentation::Documentation SpiceTranslation::Documentation() { using namespace openspace::documentation; return{ diff --git a/modules/space/translation/spicetranslation.h b/modules/space/translation/spicetranslation.h index d815a4613f..539cabe0d4 100644 --- a/modules/space/translation/spicetranslation.h +++ b/modules/space/translation/spicetranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,7 +27,6 @@ #include -#include #include namespace openspace { @@ -38,7 +37,7 @@ public: glm::dvec3 position() const; void update(const UpdateData& data) override; - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: properties::StringProperty _target; diff --git a/modules/space/translation/tletranslation.cpp b/modules/space/translation/tletranslation.cpp index c61d7519ac..5fa236dc41 100644 --- a/modules/space/translation/tletranslation.cpp +++ b/modules/space/translation/tletranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -224,7 +224,7 @@ namespace { namespace openspace { -Documentation TLETranslation::Documentation() { +documentation::Documentation TLETranslation::Documentation() { using namespace openspace::documentation; return { "TLE Translation", @@ -279,6 +279,15 @@ void TLETranslation::readTLEFile(const std::string& filename) { double meanMotion; double epoch; } keplerElements; + + enum class State { + Initial = 0, + ReadFirstLine, + ReadSecondLine, + Finished = ReadSecondLine + }; + + State state = State::Initial; std::string line; while (std::getline(file, line)) { @@ -301,8 +310,15 @@ void TLETranslation::readTLEFile(const std::string& filename) { // 14 69-69 Checksum (modulo 10) keplerElements.epoch = epochFromSubstring(line.substr(18, 14)); + state = State::ReadFirstLine; } else if (line[0] == '2') { + if (state != State::ReadFirstLine) { + throw ghoul::RuntimeError( + "Malformed TLE file: '" + filename + "'. Line 2 before line 1", + "TLETranslation" + ); + } // Second line //Field Columns Content // 1 01-01 Line number @@ -348,10 +364,18 @@ void TLETranslation::readTLEFile(const std::string& filename) { stream.str(line.substr(52, 11)); stream >> keplerElements.meanMotion; + state = State::ReadSecondLine; break; } } + if (state != State::Finished) { + throw ghoul::RuntimeError( + "Malformed TLE file: Line 1 or 2 missing", + "TLETranslation" + ); + } + // Calculate the semi major axis based on the mean motion using kepler's laws keplerElements.semiMajorAxis = calculateSemiMajorAxis(keplerElements.meanMotion); diff --git a/modules/space/translation/tletranslation.h b/modules/space/translation/tletranslation.h index ba8a5cb023..730fbbe677 100644 --- a/modules/space/translation/tletranslation.h +++ b/modules/space/translation/tletranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -52,7 +52,7 @@ public: * \return The openspace::Documentation that describes the ghoul::Dicitonary that can * be passed to the constructor */ - static openspace::Documentation Documentation(); + static documentation::Documentation Documentation(); private: /** diff --git a/modules/toyvolume/CMakeLists.txt b/modules/toyvolume/CMakeLists.txt index 56d52a4d2f..7b53b2699f 100644 --- a/modules/toyvolume/CMakeLists.txt +++ b/modules/toyvolume/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# OpenSpace # -# # -# Copyright (c) 2014-2016 # -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index 45e23a47af..0f16045129 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/modules/toyvolume/rendering/renderabletoyvolume.h b/modules/toyvolume/rendering/renderabletoyvolume.h index 68f39da10a..b5e1390ffc 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.h +++ b/modules/toyvolume/rendering/renderabletoyvolume.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/toyvolume/rendering/toyvolumeraycaster.cpp b/modules/toyvolume/rendering/toyvolumeraycaster.cpp index 66944a1fbe..49f6dfb469 100644 --- a/modules/toyvolume/rendering/toyvolumeraycaster.cpp +++ b/modules/toyvolume/rendering/toyvolumeraycaster.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,7 +24,7 @@ #include -#include +#include #include #include #include diff --git a/modules/toyvolume/rendering/toyvolumeraycaster.h b/modules/toyvolume/rendering/toyvolumeraycaster.h index b6159b0baf..08569987bf 100644 --- a/modules/toyvolume/rendering/toyvolumeraycaster.h +++ b/modules/toyvolume/rendering/toyvolumeraycaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -77,4 +77,4 @@ private: } // openspace -#endif // __OPENSPACE_MODULE_TOYVOLUME___TOYVOLUMERAYCASTER___H__ +#endif // __OPENSPACE_MODULE_TOYVOLUME___TOYVOLUMERAYCASTER___H__ diff --git a/modules/toyvolume/shaders/boundsfs.glsl b/modules/toyvolume/shaders/boundsfs.glsl index bb4f9c8cd3..e54fa90dbc 100644 --- a/modules/toyvolume/shaders/boundsfs.glsl +++ b/modules/toyvolume/shaders/boundsfs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/toyvolume/toyvolumemodule.cpp b/modules/toyvolume/toyvolumemodule.cpp index f700830085..a5b62d5183 100644 --- a/modules/toyvolume/toyvolumemodule.cpp +++ b/modules/toyvolume/toyvolumemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/toyvolume/toyvolumemodule.h b/modules/toyvolume/toyvolumemodule.h index f4fb27661e..458ad42aeb 100644 --- a/modules/toyvolume/toyvolumemodule.h +++ b/modules/toyvolume/toyvolumemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/volume/CMakeLists.txt b/modules/volume/CMakeLists.txt index 95cb375fb8..11da446b0e 100644 --- a/modules/volume/CMakeLists.txt +++ b/modules/volume/CMakeLists.txt @@ -1,26 +1,26 @@ -######################################################################################### -# # -# 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. # -######################################################################################### +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2017 # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy of this # +# software and associated documentation files (the "Software"), to deal in the Software # +# without restriction, including without limitation the rights to use, copy, modify, # +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the following # +# conditions: # +# # +# The above copyright notice and this permission notice shall be included in all copies # +# or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +########################################################################################## include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) @@ -35,9 +35,12 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/textureslicevolumereader.inl ${CMAKE_CURRENT_SOURCE_DIR}/lrucache.h ${CMAKE_CURRENT_SOURCE_DIR}/linearlrucache.h + ${CMAKE_CURRENT_SOURCE_DIR}/volumegridtype.h ${CMAKE_CURRENT_SOURCE_DIR}/volumesampler.h ${CMAKE_CURRENT_SOURCE_DIR}/volumesampler.inl ${CMAKE_CURRENT_SOURCE_DIR}/volumeutils.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/volumeclipplane.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/volumeclipplanes.h ) source_group("Header Files" FILES ${HEADER_FILES}) @@ -48,6 +51,8 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/textureslicevolumereader.inl ${CMAKE_CURRENT_SOURCE_DIR}/volumesampler.inl ${CMAKE_CURRENT_SOURCE_DIR}/volumeutils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/volumeclipplane.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/volumeclipplanes.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/volume/linearlrucache.h b/modules/volume/linearlrucache.h index b3f7e4083b..8dad14e140 100644 --- a/modules/volume/linearlrucache.h +++ b/modules/volume/linearlrucache.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_VOLUME___LINEARLRUCACHE___H__ #define __OPENSPACE_MODULE_VOLUME___LINEARLRUCACHE___H__ -#include +#include #include #include diff --git a/modules/volume/lrucache.h b/modules/volume/lrucache.h index 94d5a0deed..5959ea128f 100644 --- a/modules/volume/lrucache.h +++ b/modules/volume/lrucache.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_VOLUME___LRUCACHE___H__ #define __OPENSPACE_MODULE_VOLUME___LRUCACHE___H__ -#include +#include #include #include diff --git a/modules/volume/rawvolume.h b/modules/volume/rawvolume.h index 7cce0ae066..30be87bcd6 100644 --- a/modules/volume/rawvolume.h +++ b/modules/volume/rawvolume.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,25 +25,31 @@ #ifndef __OPENSPACE_MODULE_VOLUME___RAWVOLUME___H__ #define __OPENSPACE_MODULE_VOLUME___RAWVOLUME___H__ +#include +#include +#include + namespace openspace { template class RawVolume { public: typedef Voxel VoxelType; - RawVolume(const glm::ivec3& dimensions); - glm::ivec3 dimensions() const; - void setDimensions(const glm::ivec3& dimensions); - VoxelType get(const glm::ivec3& coordinates) const; + RawVolume(const glm::uvec3& dimensions); + glm::uvec3 dimensions() const; + void setDimensions(const glm::uvec3& dimensions); + size_t nCells() const; + VoxelType get(const glm::uvec3& coordinates) const; VoxelType get(const size_t index) const; - void set(const glm::ivec3& coordinates, const VoxelType& value); + void set(const glm::uvec3& coordinates, const VoxelType& value); void set(size_t index, const VoxelType& value); - void forEachVoxel(const std::function& fn); + void forEachVoxel(const std::function& fn); + const VoxelType* data() const; + size_t coordsToIndex(const glm::uvec3& cartesian) const; + glm::uvec3 indexToCoords(size_t linear) const; VoxelType* data(); private: - size_t coordsToIndex(const glm::ivec3& cartesian) const; - glm::ivec3 indexToCoords(size_t linear) const; - glm::ivec3 _dimensions; + glm::uvec3 _dimensions; std::vector _data; }; diff --git a/modules/volume/rawvolume.inl b/modules/volume/rawvolume.inl index ba913e84bb..3606e2cd0f 100644 --- a/modules/volume/rawvolume.inl +++ b/modules/volume/rawvolume.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -23,31 +23,39 @@ ****************************************************************************************/ #include +#include "rawvolume.h" namespace openspace { template -RawVolume::RawVolume(const glm::ivec3& dimensions) +RawVolume::RawVolume(const glm::uvec3& dimensions) : _dimensions(dimensions) , _data(static_cast(dimensions.x) * static_cast(dimensions.y) * static_cast(dimensions.z)) {} template -glm::ivec3 RawVolume::dimensions() const { +glm::uvec3 RawVolume::dimensions() const { return _dimensions; } template -void RawVolume::setDimensions(const glm::ivec3& dimensions) { +void RawVolume::setDimensions(const glm::uvec3& dimensions) { _dimensions = dimensions; - _data.resize(static_cast(dimensions.x) * - static_cast(dimensions.y) * - static_cast(dimensions.z)); + _data.resize(nCells()); +} + +template +size_t RawVolume::nCells() const +{ + return static_cast( + static_cast(_dimensions.x) * + static_cast(_dimensions.y) * + static_cast(_dimensions.z)); } template -VoxelType RawVolume::get(const glm::ivec3& coordinates) const { +VoxelType RawVolume::get(const glm::uvec3& coordinates) const { return get(coordsToIndex(coordinates, dimensions())); } @@ -57,7 +65,7 @@ VoxelType RawVolume::get(size_t index) const { } template -void RawVolume::set(const glm::ivec3& coordinates, const VoxelType& value) { +void RawVolume::set(const glm::uvec3& coordinates, const VoxelType& value) { return set(coordsToIndex(coordinates, dimensions()), value); } @@ -68,27 +76,21 @@ void RawVolume::set(size_t index, const VoxelType& value) { template void RawVolume::forEachVoxel( - const std::function& fn) + const std::function& fn) { - - glm::ivec3 dims = dimensions(); - size_t nVals = static_cast(dims.x) * - static_cast(dims.y) * - static_cast(dims.z); - - for (size_t i = 0; i < nVals; i++) { + for (size_t i = 0; i < nCells(); i++) { glm::ivec3 coords = indexToCoords(i); fn(coords, _data[i]); } } template -size_t RawVolume::coordsToIndex(const glm::ivec3& cartesian) const { +size_t RawVolume::coordsToIndex(const glm::uvec3& cartesian) const { return volumeutils::coordsToIndex(cartesian, dimensions()); } template -glm::ivec3 RawVolume::indexToCoords(size_t linear) const { +glm::uvec3 RawVolume::indexToCoords(size_t linear) const { return volumeutils::indexToCoords(linear, dimensions()); } @@ -96,5 +98,11 @@ template VoxelType* RawVolume::data() { return _data.data(); } + +template +const VoxelType* RawVolume::data() const { + return _data.data(); +} + } diff --git a/modules/volume/rawvolumereader.h b/modules/volume/rawvolumereader.h index 75ecb0b694..d696ca763d 100644 --- a/modules/volume/rawvolumereader.h +++ b/modules/volume/rawvolumereader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -34,18 +34,18 @@ template class RawVolumeReader { public: typedef Voxel VoxelType; - RawVolumeReader(const std::string& path, const glm::ivec3& dimensions); - glm::ivec3 dimensions() const; + RawVolumeReader(const std::string& path, const glm::uvec3& dimensions); + glm::uvec3 dimensions() const; std::string path() const; void setPath(const std::string& path); - void setDimensions(const glm::ivec3& dimensions); + void setDimensions(const glm::uvec3& dimensions); //VoxelType get(const glm::ivec3& coordinates) const; // TODO: Implement this //VoxelType get(const size_t index) const; // TODO: Implement this std::unique_ptr> read(); private: - size_t coordsToIndex(const glm::ivec3& cartesian) const; - glm::ivec3 indexToCoords(size_t linear) const; - glm::ivec3 _dimensions; + size_t coordsToIndex(const glm::uvec3& cartesian) const; + glm::uvec3 indexToCoords(size_t linear) const; + glm::uvec3 _dimensions; std::string _path; }; diff --git a/modules/volume/rawvolumereader.inl b/modules/volume/rawvolumereader.inl index 135a046c8a..a00a464503 100644 --- a/modules/volume/rawvolumereader.inl +++ b/modules/volume/rawvolumereader.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,18 +28,18 @@ namespace openspace { template RawVolumeReader::RawVolumeReader(const std::string& path, - const glm::ivec3& dimensions) + const glm::uvec3& dimensions) : _path(path) , _dimensions(dimensions) {} template -glm::ivec3 RawVolumeReader::dimensions() const { +glm::uvec3 RawVolumeReader::dimensions() const { return _dimensions; } template -void RawVolumeReader::setDimensions(const glm::ivec3& dimensions) { +void RawVolumeReader::setDimensions(const glm::uvec3& dimensions) { _dimensions = dimensions; } @@ -68,19 +68,19 @@ VoxelType RawVolumeReader::get(size_t index) const { }*/ template -size_t RawVolumeReader::coordsToIndex(const glm::ivec3& cartesian) const { +size_t RawVolumeReader::coordsToIndex(const glm::uvec3& cartesian) const { return volumeutils::coordsToIndex(cartesian, dimensions()); } template -glm::ivec3 RawVolumeReader::indexToCoords(size_t linear) const { +glm::uvec3 RawVolumeReader::indexToCoords(size_t linear) const { return volumeutils::indexToCoords(linear, dimensions()); } template std::unique_ptr> RawVolumeReader::read() { - glm::ivec3 dims = dimensions(); + glm::uvec3 dims = dimensions(); std::unique_ptr> volume = std::make_unique>(dims); diff --git a/modules/volume/rawvolumewriter.h b/modules/volume/rawvolumewriter.h index a173f53d9b..ec0cdf28f1 100644 --- a/modules/volume/rawvolumewriter.h +++ b/modules/volume/rawvolumewriter.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -36,13 +36,13 @@ class RawVolumeWriter { public: RawVolumeWriter(std::string path, size_t bufferSize = 1024); void setPath(const std::string& path); - glm::ivec3 dimensions() const; - void setDimensions(const glm::ivec3& dimensions); - void write(const std::function& fn, + glm::uvec3 dimensions() const; + void setDimensions(const glm::uvec3& dimensions); + void write(const std::function& fn, const std::function& onProgress = [](float t) {}); void write(const RawVolume& volume); - size_t coordsToIndex(const glm::ivec3& coords) const; + size_t coordsToIndex(const glm::uvec3& coords) const; glm::ivec3 indexToCoords(size_t linear) const; private: glm::ivec3 _dimensions; diff --git a/modules/volume/rawvolumewriter.inl b/modules/volume/rawvolumewriter.inl index 1e1fc8294d..3709368361 100644 --- a/modules/volume/rawvolumewriter.inl +++ b/modules/volume/rawvolumewriter.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -33,7 +33,7 @@ template , _bufferSize(bufferSize) {} template -size_t RawVolumeWriter::coordsToIndex(const glm::ivec3& cartesian) const { +size_t RawVolumeWriter::coordsToIndex(const glm::uvec3& cartesian) const { return volumeutils::coordsToIndex(cartesian, dimensions()); } @@ -43,21 +43,21 @@ glm::ivec3 RawVolumeWriter::indexToCoords(size_t linear) const { } template - void RawVolumeWriter::setDimensions(const glm::ivec3& dimensions) { +void RawVolumeWriter::setDimensions(const glm::uvec3& dimensions) { _dimensions = dimensions; } template - glm::ivec3 RawVolumeWriter::dimensions() const { +glm::uvec3 RawVolumeWriter::dimensions() const { return _dimensions; } template -void RawVolumeWriter::write(const std::function& fn, +void RawVolumeWriter::write(const std::function& fn, const std::function& onProgress) { - glm::ivec3 dims = dimensions(); + glm::uvec3 dims = dimensions(); size_t size = static_cast(dims.x) * static_cast(dims.y) * @@ -86,14 +86,11 @@ void RawVolumeWriter::write(const std::function void RawVolumeWriter::write(const RawVolume& volume) { - glm::ivec3 dims = dimensions(); - ghoul_assert(dims == volume.dims(), "Dimensions of input and output volume must agree"); + setDimensions(volume.dimensions()); + reinterpret_cast(volume.data()); - const char* buffer = reinterpret_cast(volume.data()); - size_t length = static_cast(dims.x) * - static_cast(dims.y) * - static_cast(dims.z) * - sizeof(VoxelType); + const char* const buffer = reinterpret_cast(volume.data()); + size_t length = volume.nCells() * sizeof(VoxelType); std::ofstream file(_path, std::ios::binary); file.write(buffer, length); diff --git a/modules/volume/rendering/renderablevolume.cpp b/modules/volume/rendering/renderablevolume.cpp deleted file mode 100644 index 33dce60490..0000000000 --- a/modules/volume/rendering/renderablevolume.cpp +++ /dev/null @@ -1,461 +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. * - ****************************************************************************************/ - -// open space includes -#include -#include -#include -#include - -// ghoul includes -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace { - const std::string _loggerCat = "RenderableVolume"; - - bool hasExtension (std::string const &filepath, std::string const &extension) - { - std::string ending = "." + extension; - if (filepath.length() > ending.length()) { - return (0 == filepath.compare (filepath.length() - ending.length(), ending.length(), ending)); - } else { - return false; - } - } - - template - T stringToNumber(const std::string& number, std::function f = nullptr) { - static_assert(std::is_integral::value || std::is_floating_point::value, - "Must be integral or floating point"); - std::stringstream ss; - T templateNumber = {0}; - ss << number; - ss >> templateNumber; - if( ! f) - return templateNumber; - - return f(templateNumber); - - } -} - -namespace openspace { - -RenderableVolume::RenderableVolume(const ghoul::Dictionary& dictionary) : Renderable(dictionary) { -} - -RenderableVolume::~RenderableVolume() { -} - -ghoul::opengl::Texture* RenderableVolume::loadVolume( - const std::string& filepath, - const ghoul::Dictionary& hintsDictionary) { - - if( ! FileSys.fileExists(filepath)) { - LWARNING("Could not load volume, could not find '" << filepath << "'"); - return nullptr; - } - - if(hasExtension(filepath, "raw")) { - ghoul::RawVolumeReader::ReadHints hints = readHints(hintsDictionary); - ghoul::RawVolumeReader rawReader(hints); - return rawReader.read(filepath); - } else if(hasExtension(filepath, "cdf")) { - - ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear; - ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge; - - glm::size3_t dimensions(1,1,1); - double tempValue; - if (hintsDictionary.hasKey("Dimensions.1") && - hintsDictionary.getValue("Dimensions.1", tempValue)) { - int intVal = static_cast(tempValue); - if(intVal > 0) - dimensions[0] = intVal; - } - if (hintsDictionary.hasKey("Dimensions.2") && - hintsDictionary.getValue("Dimensions.2", tempValue)) { - int intVal = static_cast(tempValue); - if(intVal > 0) - dimensions[1] = intVal; - } - if (hintsDictionary.hasKey("Dimensions.3") && - hintsDictionary.getValue("Dimensions.3", tempValue)) { - int intVal = static_cast(tempValue); - if(intVal > 0) - dimensions[2] = intVal; - } - - std::string variableCacheString = ""; - if (hintsDictionary.hasKey("Variable")) { - hintsDictionary.getValue("Variable", variableCacheString); - } else if(hintsDictionary.hasKey("Variables")) { - std::string xVariable, yVariable, zVariable; - bool xVar, yVar, zVar; - xVar = hintsDictionary.getValue("Variables.1", xVariable); - yVar = hintsDictionary.getValue("Variables.2", yVariable); - zVar = hintsDictionary.getValue("Variables.3", zVariable); - if (xVar && yVar && zVar) { - variableCacheString = xVariable + "." + yVariable + "." + zVariable; - } - } - - bool cache = false; - hintsDictionary.hasKey("Cache"); - if (hintsDictionary.hasKey("Cache")) - hintsDictionary.getValue("Cache", cache); - - std::stringstream ss; - ss << "." << dimensions[0] << "x" << dimensions[1] << "x" << dimensions[2] << "." << "." << variableCacheString << ".cache"; - - // = filepath + ss.str(); - ghoul::filesystem::File ghlFile(filepath); - std::string cachepath = FileSys.cacheManager()->cachedFilename(ghlFile.baseName(), - ss.str(), true); - if (cache && FileSys.fileExists(cachepath)) { - -#define VOLUME_LOAD_PROGRESSBAR - std::ifstream file(cachepath, std::ios::binary | std::ios::in); - if (file.is_open()) { - size_t length = dimensions[0] * dimensions[1] * dimensions[2]; - float* data = new float[length]; -#ifdef VOLUME_LOAD_PROGRESSBAR - LINFO("Loading cache: " << cachepath); - ProgressBar pb(static_cast(dimensions[2])); - for (size_t i = 0; i < dimensions[2]; ++i) { - size_t offset = length / dimensions[2]; - std::streamsize offsetsize = sizeof(float)*offset; - file.read(reinterpret_cast(data + offset * i), offsetsize); - pb.print(static_cast(i)); - } -#else - file.read(reinterpret_cast(data), sizeof(float)*length); -#endif - file.close(); - return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode); - } else { - return nullptr; - } - } - - KameleonWrapper kw(filepath); - std::string variableString; - if (hintsDictionary.hasKey("Variable") && hintsDictionary.getValue("Variable", variableString)) { - float* data = kw.getUniformSampledValues(variableString, dimensions); - if(cache) { - std::ofstream file(cachepath, std::ios::binary | std::ios::out); - if (file.is_open()) { - size_t length = dimensions[0] * dimensions[1] * dimensions[2]; - file.write(reinterpret_cast(data), sizeof(float)*length); - file.close(); - } - } - return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode); - } else if (hintsDictionary.hasKey("Variables")) { - std::string xVariable, yVariable, zVariable; - bool xVar, yVar, zVar; - xVar = hintsDictionary.getValue("Variables.1", xVariable); - yVar = hintsDictionary.getValue("Variables.2", yVariable); - zVar = hintsDictionary.getValue("Variables.3", zVariable); - - if (!xVar || !yVar || !zVar) { - LERROR("Error reading variables! Must be 3 and must exist in CDF data"); - } else { - - float* data = kw.getUniformSampledVectorValues(xVariable, yVariable, zVariable, dimensions); - if(cache) { - //FILE* file = fopen (cachepath.c_str(), "wb"); - std::ofstream file(cachepath, std::ios::in | std::ios::binary); - size_t length = dimensions[0] * dimensions[1] * dimensions[2]; - file.write(reinterpret_cast(data), sizeof(float)*length); - file.close(); - } - - return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::RGBA, GL_RGBA, GL_FLOAT, filtermode, wrappingmode); - } - - } else { - LWARNING("Hints does not specify a 'Variable' or 'Variables'"); - } - } else { - LWARNING("No valid file extension."); - } - return nullptr; -} - -glm::vec3 RenderableVolume::getVolumeOffset( - const std::string& filepath, - const ghoul::Dictionary& hintsDictionary) { - - KameleonWrapper kw(filepath); - return kw.getModelBarycenterOffset(); -} - -ghoul::RawVolumeReader::ReadHints RenderableVolume::readHints(const ghoul::Dictionary& dictionary) { - ghoul::RawVolumeReader::ReadHints hints; - hints._dimensions = glm::ivec3(1, 1, 1); - hints._format = ghoul::opengl::Texture::Format::Red; - hints._internalFormat = GL_R8; - - // parse hints - double tempValue; - if (dictionary.hasKey("Dimensions.1") && dictionary.getValue("Dimensions.1", tempValue)) { - int intVal = static_cast(tempValue); - if(intVal > 0) - hints._dimensions[0] = intVal; - } - if (dictionary.hasKey("Dimensions.2") && dictionary.getValue("Dimensions.2", tempValue)) { - int intVal = static_cast(tempValue); - if(intVal > 0) - hints._dimensions[1] = intVal; - } - if (dictionary.hasKey("Dimensions.3") && dictionary.getValue("Dimensions.3", tempValue)) { - int intVal = static_cast(tempValue); - if(intVal > 0) - hints._dimensions[2] = intVal; - } - - std::string format; - if (dictionary.hasKey("Format") && dictionary.getValue("Format", format)) { - if(format == "RED") { - hints._format = ghoul::opengl::Texture::Format::Red; - } else if(format == "RG") { - hints._format = ghoul::opengl::Texture::Format::RG; - } else if(format == "RGB") { - hints._format = ghoul::opengl::Texture::Format::RGB; - } else if(format == "RGBA") { - hints._format = ghoul::opengl::Texture::Format::RGBA; - } - } - - format = ""; - if (dictionary.hasKey("InternalFormat") && dictionary.getValue("InternalFormat", format)) { - if(format == "R8") { - hints._internalFormat = GL_R8; - } else if(format == "RG8") { - hints._internalFormat = GL_RG8; - } else if(format == "RGB8") { - hints._internalFormat = GL_RGB8; - } else if(format == "RGBA8") { - hints._internalFormat = GL_RGB8; - } else if(format == "R32F") { - hints._internalFormat = GL_R32F; - } else if(format == "RG32F") { - hints._internalFormat = GL_RG32F; - } else if(format == "RGB32F") { - hints._internalFormat = GL_RGB32F; - } else if(format == "RGBA32F") { - hints._internalFormat = GL_RGB32F; - } - } - return hints; -} - -ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string& filepath) { - - std::string f = absPath(filepath); - - if ( ! FileSys.fileExists(f)) { - return nullptr; - } - ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear; - ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge; - - - // check if not a txt based texture - if ( ! hasExtension(filepath, "txt")) { - ghoul::opengl::Texture* t = ghoul::io::TextureReader::ref().loadTexture(f).get(); - t->setWrapping(wrappingmode); - return t; - } - - // it is a txt based texture - std::ifstream in; - in.open(filepath.c_str()); - if (!in.is_open()) { - LERROR("Could not open file " << f); - return nullptr; - } - - int width = 512; - float lower = 0.0f; - float upper = 1.0f; - - struct mappingKey { - float position{0.0f}; - glm::vec4 color{0.0f,0.0f,0.0f,0.0f}; - - mappingKey(float p, const glm::vec4& c): position(p), color(c){}; - mappingKey(float p): position(p), color(glm::vec4(0.0f)){}; - bool operator<(const mappingKey& rhs) {return position < rhs.position;}; - }; - - std::vector mappingKeys; - - auto widthValidator = [](size_t in) { if(in > 0) return in; return static_cast(1); }; - auto upperLowerValidator = [](float in) { return glm::clamp(in, 0.0f, 1.0f); }; - auto intensityValidator = [](float in) { return glm::clamp(in, 0.0f, 1.0f); }; - - std::string line; - while (std::getline(in, line)) { - - glm::vec4 rgba = glm::vec4(0.0f); - // tokenize the line - std::istringstream iss(line); - std::vector tokens{std::istream_iterator{iss},std::istream_iterator{}}; - - size_t tokenSize =tokens.size(); - if (tokenSize > 0) { - std::string key = tokens.at(0); - if(key == "width" && tokenSize == 2) { - width = static_cast(stringToNumber(tokens.at(1), widthValidator)); - } else if(key == "lower" && tokenSize == 2) { - lower = stringToNumber(tokens.at(1), upperLowerValidator); - } else if(key == "upper" && tokenSize == 2) { - upper = stringToNumber(tokens.at(1),upperLowerValidator); - } else if(key == "mappingkey" && tokenSize == 6) { - float intensity = stringToNumber(tokens.at(1), intensityValidator); - for(int i = 0; i < 4; ++i) - rgba[i] = stringToNumber(tokens.at(i+2)); - - mappingKeys.push_back({intensity, rgba}); - } - } - } - in.close(); - - - if (mappingKeys.size() < 1) { - return nullptr; - } - - // for(auto key: mappingKeys) { - // glm::vec4 rgba = key.color; - // LDEBUG("i: " << key.position << ", rgba: (" << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << ")"); - // } - // LDEBUG("insert...."); - - if (mappingKeys.front().position > lower){ - mappingKeys.insert(mappingKeys.begin(), {lower,mappingKeys.front().color}); - } - - if (mappingKeys.back().position < upper){ - mappingKeys.push_back({upper,mappingKeys.back().color}); - } - - - // for(auto key: mappingKeys) { - // glm::vec4 rgba = key.color; - // LDEBUG("i: " << key.position << ", rgba: (" << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << ")"); - // } - - // allocate new float array with zeros - float* transferFunction = new float[width*4](); - for (int i = 0; i < 4*width; ++i) { - transferFunction[i] = 0.0f; - } - - size_t lowerIndex = static_cast(floorf(lower*static_cast(width-1))); - size_t upperIndex = static_cast(floorf(upper*static_cast(width-1))); - -// LDEBUG("width: " << width); -// LDEBUG("lower: " << lower); -// LDEBUG("upper: " << upper); -// LDEBUG("lowerIndex: " << lowerIndex); -// LDEBUG("upperIndex: " << upperIndex); - - - auto prevKey = mappingKeys.begin(); - auto currentKey = prevKey + 1; - auto lastKey = mappingKeys.end() -1; - - for (size_t i=lowerIndex; i<=upperIndex; i++) { - - float fpos = static_cast(i)/static_cast(width-1); - - if (fpos > (*currentKey).position) { - prevKey = currentKey; - currentKey++; - if (currentKey == mappingKeys.end()) { - currentKey = lastKey; - } - } - - float dist = fpos-(*prevKey).position; - float weight = dist/((*currentKey).position-(*prevKey).position); - - //LDEBUG("fpos: " << fpos); - //LDEBUG("(*prevKey).position: " << (*prevKey).position); - //LDEBUG("(*currentKey).position: " << (*currentKey).position); - //LDEBUG("weight: " << weight); - - for (size_t channel=0; channel<4; ++channel) { - size_t position = 4*i + channel; - // Interpolate linearly between prev and next mapping key - - //LDEBUG("i: " << i); - //LDEBUG("position: " << position); - //LDEBUG("(*prevKey).first " << (*prevKey).first); - //LDEBUG("(*currentKey).first " << (*currentKey).first); - //LDEBUG("dist: " << dist); - //LDEBUG("weight: " << weight); - float value = - ((*prevKey).color[channel]*(1.f-weight) + (*currentKey).color[channel]*weight)/255.f; - transferFunction[position] = value; - - //LDEBUG("["<< position <<"] " << value); - - } - // LDEBUG(std::fixed << std::setw(10) << std::left << std::setprecision(8) << weight << ", (" << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+0] << ", " << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+1] << ", " << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+2] << ", " << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+3] << ")"); - } - - // for (int i = 0; i <= width; ++i) { - - // LDEBUG(std::fixed << "(" << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+0] << ", " << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+1] << ", " << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+2] << ", " << - // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+3] << ")"); - // } - - return new ghoul::opengl::Texture(transferFunction, - glm::size3_t(width,1,1),ghoul::opengl::Texture::Format::RGBA, - GL_RGBA, GL_FLOAT,filtermode, wrappingmode); -} - -} // namespace openspace diff --git a/modules/volume/rendering/renderablevolumegl.cpp b/modules/volume/rendering/renderablevolumegl.cpp deleted file mode 100644 index b6e6e22aa9..0000000000 --- a/modules/volume/rendering/renderablevolumegl.cpp +++ /dev/null @@ -1,323 +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 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace { - const std::string _loggerCat = "RenderableVolumeGL"; - const std::string KeyVolume = "Volume"; - const std::string KeyHints = "Hints"; - const std::string KeyTransferFunction = "TransferFunction"; - const std::string KeySampler = "Sampler"; - const std::string KeyBoxScaling = "BoxScaling"; - const std::string KeyVolumeName = "VolumeName"; - const std::string KeyTransferFunctionName = "TransferFunctionName"; -} - -namespace openspace { - -RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary) - : RenderableVolume(dictionary) - , _transferFunctionName("") - , _volumeName("") - , _volume(nullptr) - , _transferFunction(nullptr) - , _boxArray(0) - , _vertexPositionBuffer(0) - , _boxProgram(nullptr) - , _boxScaling(1.0, 1.0, 1.0) - , _w(0.f) - , _updateTransferfunction(false) - , _id(-1) -{ - std::string name; - bool success = dictionary.getValue(SceneGraphNode::KeyName, name); - assert(success); - - _filename = ""; - success = dictionary.getValue(KeyVolume, _filename); - if (!success) { - LERROR("Node '" << name << "' did not contain a valid '" << KeyVolume << "'"); - return; - } - _filename = absPath(_filename); - if (_filename == "") { - return; - } - - LDEBUG("Volume Filename: " << _filename); - - dictionary.getValue(KeyHints, _hintsDictionary); - - _transferFunction = nullptr; - _transferFunctionFile = nullptr; - _transferFunctionPath = ""; - success = dictionary.getValue(KeyTransferFunction, _transferFunctionPath); - if (!success) { - LERROR("Node '" << name << "' did not contain a valid '" << - KeyTransferFunction << "'"); - return; - } - _transferFunctionPath = absPath(_transferFunctionPath); - _transferFunctionFile = new ghoul::filesystem::File(_transferFunctionPath, true); - - _samplerFilename = ""; - success = dictionary.getValue(KeySampler, _samplerFilename); - if (!success) { - LERROR("Node '" << name << "' did not contain a valid '" << KeySampler << "'"); - return; - } - _samplerFilename = absPath(_samplerFilename); - - KameleonWrapper kw(_filename); - auto t = kw.getGridUnits(); - if (dictionary.hasKey(KeyBoxScaling)) { - glm::vec4 scalingVec4(_boxScaling, _w); - success = dictionary.getValue(KeyBoxScaling, scalingVec4); - if (success) { - _boxScaling = scalingVec4.xyz(); - _w = scalingVec4.w; - } - else { - success = dictionary.getValue(KeyBoxScaling, _boxScaling); - if (!success) { - LERROR("Node '" << name << "' did not contain a valid '" << - KeyBoxScaling << "'"); - return; - } - } - } - else { - // Automatic scale detection from model - _boxScaling = kw.getModelScale(); - if (std::get<0>(t) == "R" && std::get<1>(t) == "R" && std::get<2>(t) == "R") { - // Earth radius - _boxScaling.x *= 6.371f; - _boxScaling.y *= 6.371f; - _boxScaling.z *= 6.371f; - _w = 6; - } - else if (std::get<0>(t) == "m" && std::get<1>(t) == "radian" && std::get<2>(t) == "radian") { - // For spherical coordinate systems the radius is in meter - _w = -log10(1.0f/kw.getGridMax().x); - } - else { - LWARNING("Unsupported units for automatic scale detection"); - } - } - - _pscOffset = kw.getModelBarycenterOffset(); - if (std::get<0>(t) == "R" && std::get<1>(t) == "R" && std::get<2>(t) == "R") { - // Earth radius - _pscOffset[0] *= 6.371f; - _pscOffset[1] *= 6.371f; - _pscOffset[2] *= 6.371f; - _pscOffset[3] = 6; - } - else { - // Current spherical models no need for offset - } - - dictionary.getValue(KeyVolumeName, _volumeName); - dictionary.getValue(KeyTransferFunctionName, _transferFunctionName); - - setBoundingSphere(PowerScaledScalar::CreatePSS(glm::length(_boxScaling)*pow(10,_w))); -} - -RenderableVolumeGL::~RenderableVolumeGL() { -} - -bool RenderableVolumeGL::isReady() const { - bool ready = true; - ready &= (_boxProgram != nullptr); - ready &= (_volume != nullptr); - ready &= (_transferFunction != nullptr); - return ready; -} - -bool RenderableVolumeGL::initialize() { - // @TODO fix volume and transferfunction names --jonasstrandstedt - if(_filename != "") { - _volume = loadVolume(_filename, _hintsDictionary); - _volume->uploadTexture(); - OsEng.renderEngine().aBuffer()->addVolume(_volumeName, _volume); - } - - if(_transferFunctionPath != "") { - _transferFunction = loadTransferFunction(_transferFunctionPath); - _transferFunction->uploadTexture(); - OsEng.renderEngine().aBuffer()->addTransferFunction(_transferFunctionName, _transferFunction); - - auto textureCallback = [this](const ghoul::filesystem::File& file) { - _updateTransferfunction = true; - }; - _transferFunctionFile->setCallback(textureCallback); - } - - // add the sampler and get the ID - _id = OsEng.renderEngine().aBuffer()->addSamplerfile(_samplerFilename); - - OsEng.configurationManager().getValue("RaycastProgram", _boxProgram); - - // ============================ - // GEOMETRY (box) - // ============================ - const GLfloat size = 0.5f; - const GLfloat vertex_data[] = { - // x, y, z, s, - -size, -size, size, _w, - size, size, size, _w, - -size, size, size, _w, - -size, -size, size, _w, - size, -size, size, _w, - size, size, size, _w, - - -size, -size, -size, _w, - size, size, -size, _w, - -size, size, -size, _w, - -size, -size, -size, _w, - size, -size, -size, _w, - size, size, -size, _w, - - size, -size, -size, _w, - size, size, size, _w, - size, -size, size, _w, - size, -size, -size, _w, - size, size, -size, _w, - size, size, size, _w, - - -size, -size, -size, _w, - -size, size, size, _w, - -size, -size, size, _w, - -size, -size, -size, _w, - -size, size, -size, _w, - -size, size, size, _w, - - -size, size, -size, _w, - size, size, size, _w, - -size, size, size, _w, - -size, size, -size, _w, - size, size, -size, _w, - size, size, size, _w, - - -size, -size, -size, _w, - size, -size, size, _w, - -size, -size, size, _w, - -size, -size, -size, _w, - size, -size, -size, _w, - size, -size, size, _w, - }; - - glGenVertexArrays(1, &_boxArray); // generate array - glBindVertexArray(_boxArray); // bind array - glGenBuffers(1, &_vertexPositionBuffer); // generate buffer - glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer - glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*4, reinterpret_cast(0)); - glEnableVertexAttribArray(0); - - return isReady(); -} - -bool RenderableVolumeGL::deinitialize() { - if (_volume) - delete _volume; - if (_transferFunctionFile) - delete _transferFunctionFile; - if (_transferFunction) - delete _transferFunction; - _volume = nullptr; - _transferFunctionFile = nullptr; - _transferFunction = nullptr; - - glDeleteVertexArrays(1, &_boxArray); - glGenBuffers(1, &_vertexPositionBuffer); - - return true; -} - -void RenderableVolumeGL::render(const RenderData& data) { - if(_updateTransferfunction) { - _updateTransferfunction = false; - ghoul::opengl::Texture* transferFunction = loadTransferFunction(_transferFunctionPath); - if(transferFunction) { - const void* data = transferFunction->pixelData(); - glBindBuffer(GL_COPY_READ_BUFFER, *transferFunction); - _transferFunction->bind(); - glTexImage1D( GL_TEXTURE_1D, 0, _transferFunction->internalFormat(), - static_cast(_transferFunction->width()),0, _transferFunction->format(), - _transferFunction->dataType(), data); - delete transferFunction; - LDEBUG("Updated transferfunction!"); - } - } - - glm::mat4 transform = glm::mat4(1.0); - transform = glm::scale(transform, _boxScaling); - - // fetch data - psc currentPosition = data.position; - currentPosition += _pscOffset; // Move box to model barycenter - - _boxProgram->activate(); - _boxProgram->setUniform("volumeType", _id); - _boxProgram->setUniform("modelViewProjection", data.camera.viewProjectionMatrix()); - _boxProgram->setUniform("modelTransform", transform); - setPscUniforms(_boxProgram, &data.camera, currentPosition); - - // make sure GL_CULL_FACE is enabled (it should be) - glEnable(GL_CULL_FACE); - - // Draw backface - glCullFace(GL_FRONT); - glBindVertexArray(_boxArray); - glDrawArrays(GL_TRIANGLES, 0, 6*6); - - // Draw frontface (now the normal cull face is is set) - glCullFace(GL_BACK); - glDrawArrays(GL_TRIANGLES, 0, 6*6); - - _boxProgram->deactivate(); -} - -void RenderableVolumeGL::update(const UpdateData& data) { -} - -} // namespace openspace diff --git a/modules/volume/rendering/volumeclipplane.cpp b/modules/volume/rendering/volumeclipplane.cpp new file mode 100644 index 0000000000..e3ae029752 --- /dev/null +++ b/modules/volume/rendering/volumeclipplane.cpp @@ -0,0 +1,59 @@ + +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + + +namespace openspace { + +VolumeClipPlane::VolumeClipPlane(const ghoul::Dictionary& dictionary) + : _normal("normal", "Normal", glm::vec3(1.0, 0.0, 0.0), glm::vec3(-1.0), glm::vec3(1.0)) + , _offsets("offsets", "Offsets", glm::vec2(-2.0, 0.0), glm::vec2(-2.0, 0.0), glm::vec2(2.0, 1.0)) +{ + glm::vec3 normal; + glm::vec2 offsets; + dictionary.getValue("Normal", normal); + dictionary.getValue("Offsets", offsets); + + _normal = normal; + _offsets = offsets; +} + +void VolumeClipPlane::initialize() +{ + addProperty(_normal); + addProperty(_offsets); +} + +glm::vec3 VolumeClipPlane::normal() { + return glm::normalize(_normal.value()); +} + +glm::vec2 VolumeClipPlane::offsets() { + return _offsets; +} + +} // namespace openspace \ No newline at end of file diff --git a/modules/volume/rendering/volumeclipplane.h b/modules/volume/rendering/volumeclipplane.h new file mode 100644 index 0000000000..1c8721a099 --- /dev/null +++ b/modules/volume/rendering/volumeclipplane.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_VOLUME___VOLUMECLIPPLANE___H__ +#define __OPENSPACE_MODULE_VOLUME___VOLUMECLIPPLANE___H__ + +#include +#include + +// Forward declare to minimize dependencies +namespace ghoul { + class Dictionary; +} + +namespace openspace { + +class VolumeClipPlane : public properties::PropertyOwner { +public: + VolumeClipPlane(const ghoul::Dictionary& dictionary); + virtual ~VolumeClipPlane() = default; + virtual void initialize(); + glm::vec3 normal(); + glm::vec2 offsets(); +private: + properties::Vec3Property _normal; + properties::Vec2Property _offsets; + +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_VOLUME___VOLUMECLIPPLANE___H__ diff --git a/modules/volume/rendering/volumeclipplanes.cpp b/modules/volume/rendering/volumeclipplanes.cpp new file mode 100644 index 0000000000..3a2f14d285 --- /dev/null +++ b/modules/volume/rendering/volumeclipplanes.cpp @@ -0,0 +1,72 @@ + +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + + +namespace openspace { + +VolumeClipPlanes::VolumeClipPlanes(const ghoul::Dictionary& dictionary) + : _nClipPlanes("nClipPlanes", "Number of clip planes", 0, 0, 10) +{ + std::vector keys = dictionary.keys(); + for (const std::string& key : keys) { + ghoul::Dictionary cutPlaneDictionary; + dictionary.getValue(key, cutPlaneDictionary); + auto clipPlane = std::make_shared(cutPlaneDictionary); + clipPlane->setName(key); + _clipPlanes.push_back(clipPlane); + } + _nClipPlanes = keys.size(); +} + +void VolumeClipPlanes::initialize() { + addProperty(_nClipPlanes); + for (const auto& clipPlane : _clipPlanes) { + addPropertySubOwner(clipPlane.get()); + clipPlane->initialize(); + } +} + +void VolumeClipPlanes::deinitialize() {} + +std::vector VolumeClipPlanes::normals() { + std::vector normals; + for (const auto& clipPlane : _clipPlanes) { + normals.push_back(clipPlane->normal()); + } + return normals; +} + +std::vector VolumeClipPlanes::offsets() { + std::vector offsets; + for (const auto& clipPlane : _clipPlanes) { + offsets.push_back(clipPlane->offsets()); + } + return offsets; +} + +} // namespace openspace diff --git a/modules/volume/rendering/volumeclipplanes.h b/modules/volume/rendering/volumeclipplanes.h new file mode 100644 index 0000000000..e398cac429 --- /dev/null +++ b/modules/volume/rendering/volumeclipplanes.h @@ -0,0 +1,57 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_VOLUME___VOLUMECLIPPLANES___H__ +#define __OPENSPACE_MODULE_VOLUME___VOLUMECLIPPLANES___H__ + +#include +#include + +#include + +#include +#include + +namespace ghoul { + class Dictionary; +} + +namespace openspace { + +class VolumeClipPlanes : public properties::PropertyOwner { +public: + VolumeClipPlanes(const ghoul::Dictionary& dictionary); + virtual ~VolumeClipPlanes() = default; + void initialize(); + void deinitialize(); + std::vector normals(); + std::vector offsets(); +private: + properties::IntProperty _nClipPlanes; + std::vector> _clipPlanes; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_VOLUME___VOLUMECLIPPLANES___H__ diff --git a/modules/volume/textureslicevolumereader.h b/modules/volume/textureslicevolumereader.h index c8a96a1e6d..b6f48b9a85 100644 --- a/modules/volume/textureslicevolumereader.h +++ b/modules/volume/textureslicevolumereader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,6 +26,7 @@ #define __OPENSPACE_MODULE_VOLUME___TEXTURESLICEVOLUMEREADER___H__ #include +#include #include #include #include diff --git a/modules/volume/textureslicevolumereader.inl b/modules/volume/textureslicevolumereader.inl index 9c859905cf..0366096d1e 100644 --- a/modules/volume/textureslicevolumereader.inl +++ b/modules/volume/textureslicevolumereader.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,7 +29,7 @@ namespace openspace { template VoxelType TextureSliceVolumeReader::get(const glm::ivec3& coordinates) const { ghoul::opengl::Texture& slice = getSlice(coordinates.z); - return slice.texel(coordinates.xy()); + return slice.texel(glm::uvec2(coordinates.x, coordinates.y)); } template @@ -52,7 +52,8 @@ void TextureSliceVolumeReader::initialize() { std::shared_ptr firstSlice = ghoul::io::TextureReader::ref().loadTexture(_paths[0]); - _sliceDimensions = firstSlice->dimensions().xy(); + glm::uvec3 dimensions = firstSlice->dimensions(); + _sliceDimensions = glm::uvec2(dimensions.x, dimensions.y); _initialized = true; _cache.set(0, firstSlice); } @@ -72,7 +73,8 @@ ghoul::opengl::Texture& TextureSliceVolumeReader::getSlice(int sliceI std::shared_ptr texture = ghoul::io::TextureReader::ref().loadTexture(_paths[sliceIndex]); - glm::ivec2 dims = texture->dimensions().xy(); + glm::uvec3 dimensions = texture->dimensions(); + glm::ivec2 dims = glm::uvec2(dimensions.x, dimensions.y); ghoul_assert(dims == _sliceDimensions, "Slice dimensions do not agree."); _cache.set(sliceIndex, std::move(texture)); } diff --git a/modules/volume/volumegridtype.h b/modules/volume/volumegridtype.h new file mode 100644 index 0000000000..33e39261fc --- /dev/null +++ b/modules/volume/volumegridtype.h @@ -0,0 +1,33 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ +#define __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ + +enum class VolumeGridType : int { + Cartesian = 0, + Spherical = 1 +}; + +#endif // __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ diff --git a/modules/volume/volumemodule.cpp b/modules/volume/volumemodule.cpp index 10098fe698..1a2a7b9115 100644 --- a/modules/volume/volumemodule.cpp +++ b/modules/volume/volumemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -29,8 +29,6 @@ #include -#include - namespace openspace { VolumeModule::VolumeModule() @@ -38,8 +36,7 @@ VolumeModule::VolumeModule() {} void VolumeModule::internalInitialize() { - auto fRenderable = FactoryManager::ref().factory(); - ghoul_assert(fRenderable, "No renderable factory existed"); + } } // namespace openspace diff --git a/modules/volume/volumemodule.h b/modules/volume/volumemodule.h index f21de012d3..31df179c3c 100644 --- a/modules/volume/volumemodule.h +++ b/modules/volume/volumemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/volume/volumesampler.h b/modules/volume/volumesampler.h index cc6bff50d5..f855e84572 100644 --- a/modules/volume/volumesampler.h +++ b/modules/volume/volumesampler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/volume/volumesampler.inl b/modules/volume/volumesampler.inl index a214dbd82b..82583189fb 100644 --- a/modules/volume/volumesampler.inl +++ b/modules/volume/volumesampler.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/modules/volume/volumeutils.cpp b/modules/volume/volumeutils.cpp index ab9ef9c500..0e4b4c60ac 100644 --- a/modules/volume/volumeutils.cpp +++ b/modules/volume/volumeutils.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -27,19 +27,19 @@ namespace openspace { namespace volumeutils { -size_t coordsToIndex(const glm::vec3& coords, const glm::ivec3& dims) { +size_t coordsToIndex(const glm::uvec3& coords, const glm::uvec3& dims) { size_t w = dims.x; size_t h = dims.y; - size_t d = dims.z; - - size_t x = coords.x; - size_t y = coords.y; - size_t z = coords.z; +// size_t d = dims.z; +// +// size_t x = coords.x; +// size_t y = coords.y; +// size_t z = coords.z; return coords.z * (h * w) + coords.y * w + coords.x; } -glm::vec3 indexToCoords(size_t index, const glm::ivec3& dims) { +glm::uvec3 indexToCoords(size_t index, const glm::uvec3& dims) { size_t w = dims.x; size_t h = dims.y; size_t d = dims.z; @@ -48,7 +48,7 @@ glm::vec3 indexToCoords(size_t index, const glm::ivec3& dims) { size_t y = (index / w) % h; size_t z = index / w / h; - return glm::ivec3(x, y, z); + return glm::uvec3(x, y, z); } } // namespace volumeutils diff --git a/modules/volume/volumeutils.h b/modules/volume/volumeutils.h index 6d7b3fce26..a8cab23b72 100644 --- a/modules/volume/volumeutils.h +++ b/modules/volume/volumeutils.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,13 +25,13 @@ #ifndef __OPENSPACE_MODULE_VOLUME___VOLUMEUTILS___H__ #define __OPENSPACE_MODULE_VOLUME___VOLUMEUTILS___H__ -#include +#include namespace openspace { namespace volumeutils { -size_t coordsToIndex(const glm::vec3& coords, const glm::ivec3& dimensions); -glm::vec3 indexToCoords(size_t index, const glm::ivec3& dimensions); +size_t coordsToIndex(const glm::uvec3& coords, const glm::uvec3& dimensions); +glm::uvec3 indexToCoords(size_t index, const glm::uvec3& dimensions); } // namespace volumeutils diff --git a/openspace.cfg b/openspace.cfg index 277e10f809..43e33fac12 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -1,26 +1,44 @@ +-- The configuration has an implict +-- require('scripts/configuration_helper.lua') +-- which defines helper functions useful to customize the configuration + return { -- Determines which SGCT configuration file is loaded, that is, if there rendering -- occurs in a single window, a fisheye projection, or a dome cluster system - SGCTConfig = "${SGCT}/single.xml", - --SGCTConfig = "${SGCT}/single_fisheye.xml", - --SGCTConfig = "${SGCT}/two_nodes.xml", + + -- A regular 1280x720 window + SGCTConfig = sgct.config.single{}, + + -- A regular 1920x1080 window + -- SGCTConfig = sgct.config.single{1920, 1080}, + + -- A 1k fisheye rendering + -- SGCTConfig = sgct.config.fisheye{1024, 1024}, + + -- A 4k fisheye rendering in a 1024x1024 window + -- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27}, + + --SGCTConfig = "${SGCT}/openvr_oculusRiftCv1.xml", + --SGCTConfig = "${SGCT}/openvr_htcVive.xml", -- Sets the scene that is to be loaded by OpenSpace. A scene file is a description -- of all entities that will be visible during an instance of OpenSpace Scene = "${SCENE}/default.scene", - -- Scene = "${SCENE}/globebrowsing.scene", -- Scene = "${SCENE}/rosetta.scene", -- Scene = "${SCENE}/dawn.scene", -- Scene = "${SCENE}/newhorizons.scene", -- Scene = "${SCENE}/osirisrex.scene", + Task = "${TASKS}/default.task", + Paths = { SGCT = "${BASE_PATH}/config/sgct", SCRIPTS = "${BASE_PATH}/scripts", SHADERS = "${BASE_PATH}/shaders", - OPENSPACE_DATA = "${BASE_PATH}/data", + OPENSPACE_DATA = "${BASE_PATH}/data-minimal", SCENE = "${OPENSPACE_DATA}/scene", + TASKS = "${OPENSPACE_DATA}/tasks", SPICE = "${OPENSPACE_DATA}/spice", MODULES = "${BASE_PATH}/modules", TESTDIR = "${BASE_PATH}/tests", @@ -34,8 +52,9 @@ return { Light = "${FONTS}/Roboto/Roboto-Regular.ttf" }, Logging = { + -- LogLevel = "Trace", LogLevel = "Debug", - ImmediateFlush = false, + ImmediateFlush = true, Logs = { { Type = "html", File = "${BASE_PATH}/log.html", Append = false } }, @@ -68,8 +87,8 @@ return { ShutdownCountdown = 3, -- OnScreenTextScaling = "framebuffer", -- PerSceneCache = true, + -- DisableRenderingOnMaster = true, DownloadRequestURL = "http://data.openspaceproject.com/request.cgi", RenderingMethod = "Framebuffer" --RenderingMethod = "ABuffer" -- alternative: "Framebuffer" - -} \ No newline at end of file +} diff --git a/scripts/bind_keys_newhorizons.lua b/scripts/bind_keys_newhorizons.lua index 4d0310a146..f48117f86b 100644 --- a/scripts/bind_keys_newhorizons.lua +++ b/scripts/bind_keys_newhorizons.lua @@ -17,7 +17,7 @@ openspace.bindKey( ) openspace.bindKey( "s", - "openspace.setPropertyValue('Interaction.origin', 'PlutoProjection')", + "openspace.setPropertyValue('Interaction.origin', 'Pluto')", "Sets the focus of the camera on 'Pluto'" ) openspace.bindKey( @@ -38,7 +38,7 @@ openspace.bindKey( openspace.bindKey( "F8", - "openspace.setPropertyValue('PlutoProjection.renderable.ProjectionComponent.clearAllProjections', true);" .. + "openspace.setPropertyValue('Pluto.renderable.ProjectionComponent.clearAllProjections', true);" .. "openspace.setPropertyValue('Charon.renderable.ProjectionComponent.clearAllProjections', true);", "Removes all image projections from Pluto and Charon." ) @@ -46,19 +46,19 @@ openspace.bindKey( openspace.bindKey( "F9", "openspace.time.setTime('2015-07-14T09:00:00.00');" .. - "openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true);" .. + "openspace.setPropertyValue('Pluto.renderable.clearAllProjections', true);" .. "openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);", "Jumps to the 14th of July 2015 at 0900 UTC and clears all projections." ) openspace.bindKey( "KP_8", - helper.property.increment('PlutoProjection.renderable.heightExaggeration', 2), + helper.property.increment('Pluto.renderable.heightExaggeration', 0.1), "Increases the height map exaggeration on Pluto." ) openspace.bindKey( "KP_2", - helper.property.decrement('PlutoProjection.renderable.heightExaggeration', 2), + helper.property.decrement('Pluto.renderable.heightExaggeration', 0.1), "Decreases the height map exaggeration on Pluto." ) openspace.bindKey( @@ -129,7 +129,7 @@ openspace.bindKey("p", helper.property.invert('Ganymede.renderable.performProjection') .. helper.property.invert('Europa.renderable.performProjection') .. helper.property.invert('Callisto.renderable.performProjection') .. - helper.property.invert('PlutoProjection.renderable.performProjection') .. + helper.property.invert('Pluto.renderable.performProjection') .. helper.property.invert('Charon.renderable.performProjection'), "Enables or disables the image projection on the different available objects." ) diff --git a/scripts/configuration_helper.lua b/scripts/configuration_helper.lua new file mode 100644 index 0000000000..8ce25c0330 --- /dev/null +++ b/scripts/configuration_helper.lua @@ -0,0 +1,667 @@ +-- Helper functions that are useful to customize the openspace.cfg loading + +--[[ +########################################################################################## + Public functions +########################################################################################## +]]-- + +-- SGCT related functions +sgct = {} +sgct.config = {} + +-- This function takes a text definition for an SGCT configuration file and returns the path +-- to a temporary file containing the string which SGCT can use +function sgct.makeConfig(config) end + +-- Creates a configuration file similar to the default 'single.xml': +-- The parameter is a table and can contain the follow attributes: + +-- first argument: horizontal window size {default: 1280} +-- second argument: vertical window size {default: 720} +-- res: A table containing the horizontal and vertical resolution [example: res={3840, 2160}] +-- windowPos: The position of the window on the screen [example: windowPos={50, 100}] {default: {50, 50}} +-- fullScreen: Whether the application should run in exclusive full screen [example: fullScreen=true] {default: false} +-- border: Whether the application should have window decorations (aka. border) [example: border=false] {default: true} +-- monitor: Determines the monitor on which the application is started [example: monitor=2] {default: 0} + +-- Expert settings: +-- name: The name of the window [example: window="Foobar"] {defualt: "OpenSpace"} +-- vsync: Whether the rendering speed is locked to the refreshrate [example: vsync=true] {default: false} +-- refreshRate: If vsync is enabled, this is the target framerate [example: refreshRate=30] {default: infinity} +-- stereo: Select the stereo rendering mode as supported by SGCT [example: stereo='anaglyph_red_cyan'] {default: 'none'} +-- msaa: The multisampling anti-aliasing factor [example: msaa=4] {default: 8} +-- eyeSep: The base eye separation in m [example: eyeSep=0.1] {default: 0.065} +-- eyePos: The location of the user [example: eyePos={0.0, 1.0, 0.0}] {default: {0.0, 0.0, 0.0}} +-- scene: Global settings to all scene objects (offset, orientation, scaling; each optional) +-- [example: scene = {offset = {x = 1.0, y = 1.0, z = 2.0}, orientation = { yaw = 120, pitch = 15, roll = 0.0 }, scale = 10.0}] +-- capture: Settings to configure the image capture [example: capture = { path = "./images"] +-- sgctDebug: Determines whether a higher debug level in SGCT is enabled [example: sgctDebug=true] {default: false} +-- fov: The field of view settings [example: fov={ left=20, right=30, up=10, down=50}] {default: { left=30.0, right=30.0, up=16.875, down=16.875}} + +-- Thus this function can be called the following ways: +-- sgct.config.single() -> Leading to a 1280x720 resolution window +-- sgct.config.single(1920, 1080) -> Leading to a 1920x1080 resolution window +-- sgct.config.single(640, 360, res={3840, 2160}) -> 640x360 window with 4K rendering resolution +-- sgct.config.single(msaa=1) -> 1280x720 resolution without multisampling +function sgct.config.single(arg) end + +-- Creates a configuration file similar to the default 'single_fisheye.xml' +-- The parameter is a table and can contain the follow attributes: + +-- first argument: horizontal window size {default: 1280} +-- second argument: vertical window size {default: 720} +-- res: A table containing the horizontal and vertical resolution [example: res={3840, 2160}] +-- windowPos: The position of the window on the screen [example: windowPos={50, 100}] {default: {50, 50}} +-- fullScreen: Whether the application should run in exclusive full screen [example: fullScreen=true] {default: false} +-- border: Whether the application should have window decorations (aka. border) [example: border=false] {default: true} +-- monitor: Determines the monitor on which the application is started [example: monitor=2] {default: 0} + +-- Expert settings: +-- name: The name of the window [example: window="Foobar"] {defualt: "OpenSpace"} +-- vsync: Whether the rendering speed is locked to the refreshrate [example: vsync=true] {default: false} +-- refreshRate: If vsync is enabled, this is the target framerate [example: refreshRate=30] {default: infinity} +-- stereo: Select the stereo rendering mode as supported by SGCT [example: stereo='anaglyph_red_cyan'] {default: 'none'} +-- msaa: The multisampling anti-aliasing factor [example: msaa=4] {default: 8} +-- eyeSep: The base eye separation in m [example: eyeSep=0.1] {default: 0.065} +-- eyePos: The location of the user [example: eyePos={0.0, 1.0, 0.0}] {default: {0.0, 0.0, 0.0}} +-- scene: Global settings to all scene objects (offset, orientation, scaling; each optional) +-- [example: scene = {offset = {x = 1.0, y = 1.0, z = 2.0}, orientation = { yaw = 120, pitch = 15, roll = 0.0 }, scale = 10.0}] +-- capture: Settings to configure the image capture [example: capture = { path = "./images"] +-- sgctDebug: Determines whether a higher debug level in SGCT is enabled [example: sgctDebug=true] {default: false} +-- fov: The field of view for the fisheye [example: fov=360] {default: 180} +-- quality: The quality setting for the cubemap textures [example: quality="4k"] {default: "1k"} +-- tilt: The forwards tilt of the fisheye, relative to the center [example: tilt=90] {default: 0.0} +-- background: The background color used outside of the fisheye rendering [example: backgruound={r=1.0, g=0.25, b=0.25, a=1.0}] {default: {r=0.1, g=0.1, b=0.1, a=1.0}} + +-- Thus this function can be called the following ways: +-- sgct.config.fisheye() -> Leading to a 1280x720 resolution window +-- sgct.config.fisheye(640, 640) -> Leading to a 640x650 resolution window +-- sgct.config.fisheye(640, 360, res={3840, 3840}) -> 640x360 window with 4K rendering resolution +-- sgct.config.fisheye(msaa=1) -> 1280x720 resolution without multisampling +function sgct.config.fisheye(arg) end + +--[[ +########################################################################################## + Internal helper functions +########################################################################################## +]]-- + +function generateSingleViewport(down, up, left, right) + return +[[ + + + + + + + + +]] +end + + + +function generateFisheyeViewport(fov, quality, tilt, background, crop, offset) + local b = [[ + +]] + + local c = "" + if crop then + c = [[ + +]] + end + + local o = "" + if offset then + o = [[ + +]] + end + + return [[ + + + + +]]..b..[[ +]]..c..[[ +]]..o..[[ + + +]] +end + + + +function generateWindow(arg) + local resolution = "" + if arg["res"] then + arg["res"][1] = arg["res"][1] or arg["windowSize"][1] + arg["res"][2] = arg["res"][2] or arg["windowSize"][2] + + resolution = +[[ + +]] + end + + return +[[ + + + + +]]..resolution.. +[[ +]].. +arg["viewport"].. +[[ + +]] +end + + + +function generateUser(arg) + return [[ + + + +]] +end + + + +function generateScene(arg) + local scene = arg["scene"] + + if scene == nil then + return "" + else + local offset = "" + if scene["offset"] then + local o = scene["offset"] + offset = [[]] + end + + local orientation = "" + if scene["orientation"] then + local o = scene["orientation"] + orientation = [[]] + end + + local scale = "" + if scene["scale"] then + scale = [[]] + end + + return [[ + + ]]..offset..[[ + ]]..orientation..[[ + ]]..scale..[[ + + + +]] +end + + + +function generateCapture(arg) + if arg["capture"] == nil then + return "" + else + local path = "" + if arg["capture"]["path"] then + path = 'path="' .. arg["capture"]["path"] .. '" ' + end + + local monoPath = "" + if arg["capture"]["monoPath"] then + path = 'monoPath="' .. arg["capture"]["monoPath"] .. '" ' + end + + local leftPath = "" + if arg["capture"]["leftPath"] then + path = 'leftPath="' .. arg["capture"]["leftPath"] .. '" ' + end + + local rightPath = "" + if arg["capture"]["rightPath"] then + path = 'rightPath="' .. arg["capture"]["rightPath"] .. '" ' + end + + local format = "" + if arg["capture"]["format"] then + path = 'format="' .. arg["capture"]["format"] .. '" ' + end + end +end + + + +function generateCluster(arg) + return [[ + + +]]..arg["settings"]..[[ +]]..arg["scene"]..[[ + +]].. arg["window"] ..[[ + +]] .. arg["user"] .. [[ +]] .. arg["capture"] .. [[ + +]] +end + + + +function generateSingleWindowConfig(arg) + -- First some type checking + assert( + type(arg[1]) == "number" or type(arg[1]) == "nil", + "First argument must be a number or nil" + ) + assert( + type(arg[2]) == "number" or type(arg[2]) == "nil", + "Second argument must be a number or nil" + ) + + assert( + type(arg["res"]) == "table" or type(arg["res"]) == "nil", + "res must be a table or nil" + ) + if (type(arg["res"]) == "table") then + assert(type(arg["res"][1]) == "number", "res[1] must be a number") + assert(type(arg["res"][2]) == "number", "res[2] must be a number") + end + + assert( + type(arg["windowSize"]) == "table" or type(arg["windowSize"]) == "nil", + "windowSize must be a table or nil" + ) + if (type(arg["windowSize"]) == "table") then + assert(type(arg["windowSize"][1]) == "number", "windowPos[1] must be a number") + assert(type(arg["windowSize"][2]) == "number", "windowPos[2] must be a number") + assert( + type(arg[1]) == "nil" and type(arg[2]) == "nil", + "Only windowSize or the first and second arguments can be set. Not both" + ) + end + + assert( + type(arg["windowPos"]) == "table" or type(arg["windowPos"]) == "nil", + "windowPos must be a table or nil" + ) + if (type(arg["windowPos"]) == "table") then + assert(type(arg["windowPos"][1]) == "number", "windowPos[1] must be a number") + assert(type(arg["windowPos"][2]) == "number", "windowPos[2] must be a number") + end + + assert( + type(arg["name"]) == "string" or type(arg["name"]) == "nil", + "name must be a string or nil" + ) + + assert( + type(arg["fullScreen"]) == "boolean" or type(arg["fullScreen"]) == "nil", + "fullScreen must be a boolean or nil" + ) + + assert( + type(arg["monitor"]) == "number" or type(arg["monitor"]) == "nil", + "monitor must be a number or nil" + ) + + assert( + type(arg["border"]) == "boolean" or type(arg["border"]) == "nil", + "border must be a boolean or nil" + ) + + assert( + type(arg["msaa"]) == "number" or type(arg["msaa"]) == "nil", + "msaa must be a number or nil" + ) + + assert( + type(arg["vsync"]) == "boolean" or type(arg["vsync"]) == "nil", + "vsync must be a boolean or nil" + ) + + assert( + type(arg["refreshRate"]) == "number" or type(arg["refreshRate"]) == "nil", + "refreshRate must be a number or nil" + ) + + assert( + type(arg["stereo"]) == "string" or type(arg["stereo"]) == "nil", + "stereo must be a boolean or nil" + ) + + assert( + type(arg["eyeSep"]) == "number" or type(arg["eyeSep"]) == "nil", + "eyeSep must be a number or nil" + ) + + assert( + type(arg["eyePos"]) == "table" or type(arg["eyePos"]) == "nil", + "eyePos must be a table or nil" + ) + if (type(arg["eyePos"]) == "table") then + assert(type(arg["eyePos"][1]) == "number", "eyePos[1] must be a number") + assert(type(arg["eyePos"][2]) == "number", "eyePos[2] must be a number") + assert(type(arg["eyePos"][3]) == "number", "eyePos[3] must be a number") + end + + assert( + type(arg["sgctDebug"]) == "boolean" or type(arg["sgctDebug"]) == "nil", + "sgctDebug must be a boolean or nil" + ) + + assert( + type(arg["scene"]) == "table" or type(arg["scene"]) == "nil", + "scene must be a table or nil" + ) + if type(arg["scene"]) == "table" then + local offset = arg["scene"]["offset"] + assert( + type(offset) == "table" or type(offset) == "nil", + "scene['offset'] must be a table or nil" + ) + if type(offset) == "table" then + assert(type(offset["x"]) == "number", "scene['offset']['x'] must be a number") + assert(type(offset["y"]) == "number", "scene['offset']['y'] must be a number") + assert(type(offset["z"]) == "number", "scene['offset']['z'] must be a number") + end + + local orientation = arg["scene"]["orientation"] + assert( + type(orientation) == "table" or type(orientation) == "nil", + "scene['orientation] must be a table or nil" + ) + if type(orientation) == "table" then + assert(type(orientation["yaw"]) == "number", "orientation['yaw'] must be a number") + assert(type(orientation["pitch"]) == "number", "orientation['pitch'] must be a number") + assert(type(orientation["roll"]) == "number", "orientation['roll'] must be a number") + end + + local scale = arg["scene"]["scale"] + assert( + type(scale) == "number" or type(scale) == "nil", + "scene['scale'] must be a number or nil" + ) + end + + assert( + type(arg["capture"]) == "table" or type(arg["capture"]) == "nil", + "capture must be a table or nil" + ) + if type(arg["capture"]) == "table" then + local c = arg["capture"] + assert( + type(c["path"]) == "string" or type(c["path"]) == "nil", + "capture['path'] must be a string or nil" + ) + assert( + type(c["monoPath"]) == "string" or type(c["monoPath"]) == "nil", + "capture['monoPath'] must be a string or nil" + ) + assert( + type(c["leftPath"]) == "string" or type(c["leftPath"]) == "nil", + "capture['leftPath'] must be a string or nil" + ) + assert( + type(c["rightPath"]) == "string" or type(c["rightPath"]) == "nil", + "capture['rightPath'] must be a string or nil" + ) + assert( + type(c["format"]) == "string" or type(c["format"]) == "nil", + "capture['format'] must be a string or nil" + ) + end + + assert(type(arg["viewport"]) == "string", "viewport must be a string") + + -- Then setting reasonable default values + if arg["vsync"] == nil then + arg["vsync"] = false + end + + if arg["fullScreen"] == nil then + arg["fullScreen"] = false + end + + if arg["monitor"] == nil then + arg["monitor"] = 0 + end + + if arg["msaa"] == nil then + arg["msaa"] = 8 + end + + if arg["border"] == nil then + arg["border"] = true + end + + if arg["name"] == nil then + arg["name"] = "OpenSpace" + end + + if arg["stereo"] == nil then + arg["stereo"] = "none" + end + + if arg["windowPos"] == nil then + arg["windowPos"] = { 50, 50 } + end + + if arg["eyeSep"] == nil then + arg["eyeSep"] = 0.065 + end + + if arg["eyePos"] == nil then + arg["eyePos"] = { 0.0, 0.0, 0.0 } + end + + if arg["sgctDebug"] == nil then + arg["sgctDebug"] = false + end + + if not arg["windowSize"] then + arg["windowSize"] = {} + arg["windowSize"][1] = arg[1] or 1280 + arg["windowSize"][2] = arg[2] or 720 + end + + arg["scene"] = generateScene(arg) + arg["settings"] = generateSettings(arg) + arg["window"] = generateWindow(arg) + arg["user"] = generateUser(arg) + arg["capture"] = generateCapture(arg) + + return generateCluster(arg) +end + + + +function sgct.makeConfig(config) + local configFile = os.tmpname() + + local file = io.open(configFile, "w+") + + file:write(config) + + io.close(file) + return configFile +end + + + +function sgct.config.single(arg) + arg = arg or {} + + assert( + type(arg["fov"]) == "table" or type(arg["fov"]) == "nil", + "fov must be a table or nil" + ) + if (type(arg["fov"]) == "table") then + assert(type(arg["fov"]["left"]) == "number", "fov['left'] must be a number") + assert(type(arg["fov"]["right"]) == "number", "fov['right'] must be a number") + assert(type(arg["fov"]["up"]) == "number", "fov['up'] must be a number") + assert(type(arg["fov"]["down"]) == "number", "fov['down'] must be a number") + end + + arg["fov"] = arg["fov"] or { down = 16.875, up = 16.875, left = 30.0, right = 30.0 } + arg["viewport"] = generateSingleViewport( + arg["fov"]["down"], + arg["fov"]["up"], + arg["fov"]["left"], + arg["fov"]["right"] + ) + + return sgct.makeConfig(generateSingleWindowConfig(arg)) +end + + + +function sgct.config.fisheye(arg) + arg = arg or {} + + assert( + type(arg["fov"]) == "number" or type(arg["fov"]) == "nil", + "fov must be a number or nil" + ) + + assert( + type(arg["quality"]) == "string" or type(arg["quality"]) == "nil", + "quality must be a string or nil" + ) + + assert( + type(arg["tilt"]) == "number" or type(arg["tilt"]) == "nil", + "tilt must be a number or nil" + ) + + assert( + type(arg["background"]) == "table" or type(arg["background"]) == "nil", + "background must be a table or nil" + ) + if type(arg["background"]) == "table" then + assert(type(background["r"]) == "number", "backgroud['r'] must be a number") + assert(type(background["g"]) == "number", "backgroud['g'] must be a number") + assert(type(background["b"]) == "number", "backgroud['b'] must be a number") + assert(type(background["a"]) == "number", "backgroud['a'] must be a number") + end + + assert( + type(arg["crop"]) == "table" or type(arg["crop"]) == "nil", + "crop must be a table or nil" + ) + if type(arg["crop"]) == "table" then + assert( + type(arg["crop"]["left"]) == "number", "crop['left'] must be a number" + ) + assert( + type(arg["crop"]["right"]) == "number", "crop['right'] must be a number" + ) + assert( + type(arg["crop"]["top"]) == "number", "crop['top'] must be a number" + ) + assert( + type(arg["crop"]["bottom"]) == "number", "crop['bottom'] must be a number" + ) + end + + assert( + type(arg["offset"]) == "table" or type(arg["offset"]) == "nil", + "offset must be a table or nil" + ) + if type(arg["offset"]) == "table" then + assert(type(arg["offset"]["x"]) == "number", "offset['x'] must be a number") + assert(type(arg["offset"]["y"]) == "number", "offset['y'] must be a number") + assert(type(arg["offset"]["z"]) == "number", "offset['z'] must be a number") + end + + if arg["fov"] == nil then + arg["fov"] = 180 + end + + if arg["quality"] == nil then + arg["quality"] = "1k" + end + + if arg["tilt"] == nil then + arg["tilt"] = 0 + end + + if arg["background"] == nil then + arg["background"] = { r = 0.1, g = 0.1, b = 0.1, a = 1.0 } + end + + arg["viewport"] = generateFisheyeViewport( + arg["fov"], + arg["quality"], + arg["tilt"], + arg["background"], + arg["crop"], + arg["offset"] + ) + + return sgct.makeConfig(generateSingleWindowConfig(arg)) +end diff --git a/shaders/PowerScaling/powerScalingMath.hglsl b/shaders/PowerScaling/powerScalingMath.hglsl index 58ffd0d978..b275aaf989 100644 --- a/shaders/PowerScaling/powerScalingMath.hglsl +++ b/shaders/PowerScaling/powerScalingMath.hglsl @@ -80,47 +80,6 @@ vec4 z_normalization(vec4 v_in) { return v_out; } -/** - * Compute the length of a vector. - * Supporting huge vectors, where the square of any of the components is too large to represent as a float. - */ -float safeLength(vec4 v) { - float m = max(max(max(abs(v.x), abs(v.y)), abs(v.z)), abs(v.w)); - if (m > 0.0) { - return length(v / m) * m; - } else { - return 0; - } -} - -float safeLength(vec3 v) { - float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); - if (m > 0.0) { - return length(v / m) * m; - } else { - return 0; - } -} - -float safeLength(vec2 v) { - float m = max(abs(v.x), abs(v.y)); - if (m > 0.0) { - return length(v / m) * m; - } else { - return 0; - } -} - -/** - * Normalize a vector - * Supporting huge vectors, where the square of any of the components is too large to represent as a float. - */ -vec3 safeNormalize(vec3 v) { - float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); - return normalize(v / m); -} - - /** * Convert a psc vector to a float */ @@ -135,27 +94,4 @@ float pscToLinear(vec2 position) { return pow(k, position.y) * position.x; } -/** - * Convert a positive floating point distance [0, 10^27] - * (size of observable universe) - * to a float in the range [-1, 1], suitable for depth buffer storage. - * Note: This needs to be a monotonic function, so that the value can - * still be used for depth comparison. - */ -float normalizeFloat(float inpt) { - if (inpt > 1.0) { - return inpt / pow(10, 27); - } else { - return inpt - 1.0; - } -} - -float denormalizeFloat(float inpt) { - if (inpt < 0.0) { - return inpt + 1.0; - } else { - return inpt * pow(10, 27); - } -} - #endif diff --git a/shaders/PowerScaling/powerScaling_fs.hglsl b/shaders/PowerScaling/powerScaling_fs.hglsl index 855c98707a..98a648eb56 100644 --- a/shaders/PowerScaling/powerScaling_fs.hglsl +++ b/shaders/PowerScaling/powerScaling_fs.hglsl @@ -25,6 +25,8 @@ #ifndef POWERSCALING_FS_H_HGLSL #define POWERSCALING_FS_H_HGLSL +#include "floatoperations.glsl" + // Observable universe is 10^27m, setting the far value to extremely high, aka 30!! ERMAHGERD! #include "powerScalingMath.hglsl" diff --git a/shaders/abuffer/abufferresources.glsl b/shaders/abuffer/abufferresources.glsl index 4241885318..efa0401c73 100644 --- a/shaders/abuffer/abufferresources.glsl +++ b/shaders/abuffer/abufferresources.glsl @@ -80,7 +80,4 @@ void storeFragments(uint nFrags) { } - - - #endif diff --git a/shaders/abuffer/renderabuffer.frag b/shaders/abuffer/renderabuffer.frag index 0dfd046983..1e94efe35f 100644 --- a/shaders/abuffer/renderabuffer.frag +++ b/shaders/abuffer/renderabuffer.frag @@ -26,6 +26,7 @@ #include <#{fragmentPath}> #include "abufferfragment.glsl" #include "abufferresources.glsl" +#include "floatoperations.glsl" out vec4 _out_color_; diff --git a/shaders/abuffer/resolveabuffer.frag b/shaders/abuffer/resolveabuffer.frag index a722c4f02d..453e656c9b 100644 --- a/shaders/abuffer/resolveabuffer.frag +++ b/shaders/abuffer/resolveabuffer.frag @@ -29,7 +29,7 @@ #include "abufferfragment.glsl" #include "abufferresources.glsl" #include "fragment.glsl" -#include "PowerScaling/powerScalingMath.hglsl" +#include "floatoperations.glsl" #include "blending.glsl" #include "rand.glsl" diff --git a/shaders/floatoperations.glsl b/shaders/floatoperations.glsl new file mode 100644 index 0000000000..c3d52a5300 --- /dev/null +++ b/shaders/floatoperations.glsl @@ -0,0 +1,93 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2017 * + * * + * 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 _FLOATOPERATIONS_GLSL_ +#define _FLOATOPERATIONS_GLSL_ + + +/** + * Convert a positive floating point distance [0, 10^27] + * (size of observable universe) + * to a float in the range [-1, 1], suitable for depth buffer storage. + * Note: This needs to be a monotonic function, so that the value can + * still be used for depth comparison. + */ +float normalizeFloat(float inpt) { + if (inpt > 1.0) { + return inpt / pow(10, 27); + } else { + return inpt - 1.0; + } +} + +float denormalizeFloat(float inpt) { + if (inpt < 0.0) { + return inpt + 1.0; + } else { + return inpt * pow(10, 27); + } +} + +/** + * Compute the length of a vector. + * Supporting huge vectors, where the square of any of the components is too large to represent as a float. + */ +float safeLength(vec4 v) { + float m = max(max(max(abs(v.x), abs(v.y)), abs(v.z)), abs(v.w)); + if (m > 0.0) { + return length(v / m) * m; + } else { + return 0; + } +} + +float safeLength(vec3 v) { + float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); + if (m > 0.0) { + return length(v / m) * m; + } else { + return 0; + } +} + +float safeLength(vec2 v) { + float m = max(abs(v.x), abs(v.y)); + if (m > 0.0) { + return length(v / m) * m; + } else { + return 0; + } +} + +/** + * Normalize a vector + * Supporting huge vectors, where the square of any of the components is too large to represent as a float. + */ +vec3 safeNormalize(vec3 v) { + float m = max(max(abs(v.x), abs(v.y)), abs(v.z)); + return normalize(v / m); +} + + +#endif diff --git a/shaders/framebuffer/exitframebuffer.frag b/shaders/framebuffer/exitframebuffer.frag index e65beb9460..19956df740 100644 --- a/shaders/framebuffer/exitframebuffer.frag +++ b/shaders/framebuffer/exitframebuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,7 +25,7 @@ #version __CONTEXT__ -#include "PowerScaling/powerScalingMath.hglsl" +#include "floatoperations.glsl" #include <#{fragmentPath}> out vec4 _out_color_; diff --git a/shaders/framebuffer/inside.glsl b/shaders/framebuffer/inside.glsl new file mode 100644 index 0000000000..9c5587c325 --- /dev/null +++ b/shaders/framebuffer/inside.glsl @@ -0,0 +1,29 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 - 2017 * + * * + * 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. * + ****************************************************************************************/ + + +void getEntry(inout vec3 entryPos, inout float entryDepth) { + entryPos = cameraPosInRaycaster; + entryDepth = 0; +} diff --git a/shaders/framebuffer/outside.glsl b/shaders/framebuffer/outside.glsl new file mode 100644 index 0000000000..d1ebf5d7e9 --- /dev/null +++ b/shaders/framebuffer/outside.glsl @@ -0,0 +1,32 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2017 * + * * + * 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 <#{fragmentPath}> + +void getEntry(inout vec3 entryPos, inout float entryDepth) { + // fetch entry point from rendered fragment + Fragment f = getFragment(); + entryPos = f.color.xyz; + entryDepth = f.depth; +} diff --git a/shaders/framebuffer/raycastframebuffer.frag b/shaders/framebuffer/raycastframebuffer.frag index 375bed06b7..eecd97baa0 100644 --- a/shaders/framebuffer/raycastframebuffer.frag +++ b/shaders/framebuffer/raycastframebuffer.frag @@ -34,9 +34,7 @@ uniform vec2 windowSize; #include "blending.glsl" #include "rand.glsl" -#include "PowerScaling/powerScalingMath.hglsl" -#include <#{fragmentPath}> - +#include "floatoperations.glsl" #for id, helperPath in helperPaths #include <#{helperPath}> @@ -46,19 +44,17 @@ uniform vec2 windowSize; out vec4 finalColor; - #define ALPHA_LIMIT 0.99 #define RAYCAST_MAX_STEPS 1000 #define MAX_AA_SAMPLES 8 uniform int nAaSamples; +#include <#{getEntryPath}> void main() { - vec2 texCoord = vec2(gl_FragCoord.xy / windowSize); - vec4 exitColorTexture = texture(exitColorTexture, texCoord); if (exitColorTexture.a < 1.0) { discard; @@ -68,22 +64,11 @@ void main() { vec3 exitPos = exitColorTexture.rgb; float exitDepth = denormalizeFloat(texture(exitDepthTexture, texCoord).x); - - float jitterFactor = 0.5 + 0.5 * rand(gl_FragCoord.xy); // should be between 0.5 and 1.0 vec3 entryPos; float entryDepth; - - if (insideRaycaster) { - entryPos = cameraPosInRaycaster; - entryDepth = 0; - } else { - // fetch entry point from rendered fragment - Fragment f = getFragment(); - entryPos = f.color.xyz; - entryDepth = f.depth; - } + getEntry(entryPos, entryDepth); vec3 position = entryPos; vec3 diff = exitPos - entryPos; diff --git a/shaders/framebuffer/renderframebuffer.frag b/shaders/framebuffer/renderframebuffer.frag index 98905b9952..0f671765ea 100644 --- a/shaders/framebuffer/renderframebuffer.frag +++ b/shaders/framebuffer/renderframebuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "PowerScaling/powerScalingMath.hglsl" +#include "floatoperations.glsl" #include <#{fragmentPath}> out vec4 _out_color_; diff --git a/shaders/framebuffer/resolveframebuffer.frag b/shaders/framebuffer/resolveframebuffer.frag index df8b872298..7f32534df1 100644 --- a/shaders/framebuffer/resolveframebuffer.frag +++ b/shaders/framebuffer/resolveframebuffer.frag @@ -24,8 +24,6 @@ #version __CONTEXT__ -#include "PowerScaling/powerScalingMath.hglsl" - layout (location = 0) out vec4 finalColor; uniform float blackoutFactor; uniform int nAaSamples; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e906ca5a9a..2a71d95f78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,13 +40,10 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/engine/wrapper/sgctwindowwrapper.cpp ${OPENSPACE_BASE_DIR}/src/engine/wrapper/windowwrapper.cpp ${OPENSPACE_BASE_DIR}/src/interaction/controller.cpp - ${OPENSPACE_BASE_DIR}/src/interaction/deviceidentifier.cpp ${OPENSPACE_BASE_DIR}/src/interaction/interactionhandler.cpp ${OPENSPACE_BASE_DIR}/src/interaction/interactionmode.cpp ${OPENSPACE_BASE_DIR}/src/interaction/interactionhandler_lua.inl - ${OPENSPACE_BASE_DIR}/src/interaction/keyboardcontroller.cpp ${OPENSPACE_BASE_DIR}/src/interaction/luaconsole.cpp - ${OPENSPACE_BASE_DIR}/src/interaction/luaconsole_lua.inl ${OPENSPACE_BASE_DIR}/src/mission/mission.cpp ${OPENSPACE_BASE_DIR}/src/mission/missionmanager.cpp ${OPENSPACE_BASE_DIR}/src/mission/missionmanager_lua.inl @@ -136,6 +133,7 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/scripting/scriptengine_lua.inl ${OPENSPACE_BASE_DIR}/src/scripting/scriptscheduler.cpp ${OPENSPACE_BASE_DIR}/src/scripting/scriptscheduler_lua.inl + ${OPENSPACE_BASE_DIR}/src/scripting/systemcapabilitiesbinding.cpp ${OPENSPACE_BASE_DIR}/src/util/blockplaneintersectiongeometry.cpp ${OPENSPACE_BASE_DIR}/src/util/boxgeometry.cpp ${OPENSPACE_BASE_DIR}/src/util/camera.cpp @@ -152,6 +150,8 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/util/syncbuffer.cpp ${OPENSPACE_BASE_DIR}/src/util/syncdata.cpp ${OPENSPACE_BASE_DIR}/src/util/histogram.cpp + ${OPENSPACE_BASE_DIR}/src/util/task.cpp + ${OPENSPACE_BASE_DIR}/src/util/taskloader.cpp ${OPENSPACE_BASE_DIR}/src/util/time.cpp ${OPENSPACE_BASE_DIR}/src/util/timemanager.cpp ${OPENSPACE_BASE_DIR}/src/util/time_lua.inl @@ -177,10 +177,8 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/engine/wrapper/sgctwindowwrapper.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/wrapper/windowwrapper.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/controller.h - ${OPENSPACE_BASE_DIR}/include/openspace/interaction/deviceidentifier.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/interactionhandler.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/interactionmode.h - ${OPENSPACE_BASE_DIR}/include/openspace/interaction/keyboardcontroller.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/luaconsole.h ${OPENSPACE_BASE_DIR}/include/openspace/mission/mission.h ${OPENSPACE_BASE_DIR}/include/openspace/mission/missionmanager.h @@ -277,6 +275,7 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/scripting/script_helper.h ${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptengine.h ${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptscheduler.h + ${OPENSPACE_BASE_DIR}/include/openspace/scripting/systemcapabilitiesbinding.h ${OPENSPACE_BASE_DIR}/include/openspace/util/blockplaneintersectiongeometry.h ${OPENSPACE_BASE_DIR}/include/openspace/util/boxgeometry.h ${OPENSPACE_BASE_DIR}/include/openspace/util/camera.h @@ -293,6 +292,8 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/util/spicemanager.h ${OPENSPACE_BASE_DIR}/include/openspace/util/syncbuffer.h ${OPENSPACE_BASE_DIR}/include/openspace/util/syncdata.h + ${OPENSPACE_BASE_DIR}/include/openspace/util/task.h + ${OPENSPACE_BASE_DIR}/include/openspace/util/taskloader.h ${OPENSPACE_BASE_DIR}/include/openspace/util/time.h ${OPENSPACE_BASE_DIR}/include/openspace/util/timemanager.h ${OPENSPACE_BASE_DIR}/include/openspace/util/timerange.h diff --git a/src/documentation/core_registration.cpp b/src/documentation/core_registration.cpp index 946a87e494..a7b40181c2 100644 --- a/src/documentation/core_registration.cpp +++ b/src/documentation/core_registration.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,11 +26,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -42,18 +42,16 @@ #include #include #include +#include #include #include #include -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED -#include -#endif - namespace openspace { void registerCoreClasses(documentation::DocumentationEngine& engine) { engine.addDocumentation(ConfigurationManager::Documentation()); + engine.addDocumentation(LogFactoryDocumentation()); engine.addDocumentation(Mission::Documentation()); engine.addDocumentation(Renderable::Documentation()); engine.addDocumentation(Rotation::Documentation()); @@ -72,12 +70,14 @@ void registerCoreClasses(scripting::ScriptEngine& engine) { engine.addLibrary(Scene::luaLibrary()); engine.addLibrary(Time::luaLibrary()); engine.addLibrary(interaction::InteractionHandler::luaLibrary()); - engine.addLibrary(LuaConsole::luaLibrary()); engine.addLibrary(ParallelConnection::luaLibrary()); engine.addLibrary(ModuleEngine::luaLibrary()); engine.addLibrary(scripting::ScriptScheduler::luaLibrary()); engine.addLibrary(WindowWrapper::luaLibrary()); engine.addLibrary(MissionManager::luaLibrary()); + + engine.addLibrary(scripting::generalSystemCapabilities()); + engine.addLibrary(scripting::openglSystemCapabilities()); } } // namespace openspace diff --git a/src/documentation/documentation.cpp b/src/documentation/documentation.cpp index a866edd869..f33368b971 100644 --- a/src/documentation/documentation.cpp +++ b/src/documentation/documentation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,6 +25,8 @@ #include #include +#include + #include namespace { @@ -78,6 +80,13 @@ std::string to_string(openspace::documentation::TestResult::Offense::Reason reas return "Wrong type"; } } + +std::string to_string(openspace::documentation::TestResult::Warning::Reason reason) { + switch (reason) { + case openspace::documentation::TestResult::Warning::Reason::Deprecated: + return "Deprecated"; + } +} } // namespace std @@ -91,6 +100,12 @@ SpecificationError::SpecificationError(TestResult res, std::string component) , result(std::move(res)) { ghoul_assert(!result.success, "Result's success must be false"); + + message += " ("; + for (const TestResult::Offense& o : result.offenses) { + message += o.offender + ','; + } + message.back() = ')'; } DocumentationEntry::DocumentationEntry(std::string k, std::shared_ptr v, diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index 0181f0178d..2f90737a73 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index 28b83f13d1..85db8531ff 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -225,25 +225,25 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary, [this](const Documentation& doc) { return doc.id == identifier; } ); - if (it == documentations.end()) { - return { false, { { key, TestResult::Offense::Reason::UnknownIdentifier } } }; + ghoul_assert( + it != documentations.end(), + "Did not find referencing identifier '" + identifier + "'" + ); + + ghoul::Dictionary d = dictionary.value(key); + TestResult res = testSpecification(*it, d); + + // Add the 'key' as a prefix to make the offender a fully qualified identifer + for (TestResult::Offense& s : res.offenses) { + s.offender = key + "." + s.offender; } - else { - ghoul::Dictionary d = dictionary.value(key); - TestResult res = testSpecification(*it, d); - // Add the 'key' as a prefix to make the offender a fully qualified identifer - for (TestResult::Offense& s : res.offenses) { - s.offender = key + "." + s.offender; - } - - // Add the 'key' as a prefix to make the warning a fully qualified identifer - for (TestResult::Warning& w : res.warnings) { - w.offender = key + "." + w.offender; - } - - return res; + // Add the 'key' as a prefix to make the warning a fully qualified identifer + for (TestResult::Warning& w : res.warnings) { + w.offender = key + "." + w.offender; } + + return res; } else { return res; diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index 8463283a9a..dc532650d7 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,20 +24,22 @@ #include -#include -#include +#include + #include #include - -#include +#include +#include +#include using std::string; #include "configurationmanager_doc.inl" namespace { - const string _configurationFile = "openspace.cfg"; - const string _keyBasePath = "BASE_PATH"; + const char* _configurationFile = "openspace.cfg"; + const char* _keyBasePath = "BASE_PATH"; + const char* _initialConfigHelper = "${BASE_PATH}/scripts/configuration_helper.lua"; } namespace openspace { @@ -57,6 +59,7 @@ const string ConfigurationManager::KeyKeyboardShortcuts = "KeyboardShortcuts"; const string ConfigurationManager::KeyDocumentation = "Documentation"; const string ConfigurationManager::KeyFactoryDocumentation = "FactoryDocumentation"; const string ConfigurationManager::KeyConfigScene = "Scene"; +const string ConfigurationManager::KeyConfigTask = "Task"; const string ConfigurationManager::KeyLogging = "Logging"; const string ConfigurationManager::PartLogLevel = "LogLevel"; @@ -87,15 +90,20 @@ string ConfigurationManager::findConfiguration(const string& filename) { using ghoul::filesystem::Directory; Directory directory = FileSys.currentDirectory(); - std::string configurationName = _configurationFile; while (true) { - std::string&& fullPath = FileSys.pathByAppendingComponent(directory, - configurationName); - bool exists = FileSys.fileExists(fullPath); - if (exists) + std::string fullPath = FileSys.pathByAppendingComponent( + directory, + _configurationFile + ); + + if (FileSys.fileExists(fullPath)) { + // We have found the configuration file and can bail out return fullPath; + } + // Otherwise, we traverse the directory tree up + Directory nextDirectory = directory.parentDirectory( ghoul::filesystem::Directory::AbsolutePath::Yes ); @@ -114,10 +122,9 @@ string ConfigurationManager::findConfiguration(const string& filename) { void ConfigurationManager::loadFromFile(const string& filename) { using ghoul::filesystem::FileSystem; - if (!FileSys.fileExists(filename)) { - throw ghoul::FileNotFoundError(filename, "ConfigurationManager"); - } - + ghoul_assert(!filename.empty(), "Filename must not be empty"); + ghoul_assert(FileSys.fileExists(filename), "File must exist"); + // ${BASE_PATH} string basePathToken = FileSystem::TokenOpeningBraces + _keyBasePath + FileSystem::TokenClosingBraces; @@ -126,9 +133,15 @@ void ConfigurationManager::loadFromFile(const string& filename) { string absolutePath = FileSys.absolutePath(filename); string basePath = ghoul::filesystem::File(absolutePath).directoryName(); FileSys.registerPathToken(basePathToken, basePath); + + ghoul::lua::LuaState state; + + if (FileSys.fileExists(absPath(_initialConfigHelper))) { + ghoul::lua::runScriptFile(state, absPath(_initialConfigHelper)); + } // Loading the configuration file into ourselves - ghoul::lua::loadDictionaryFromFile(filename, *this); + ghoul::lua::loadDictionaryFromFile(filename, *this, state); // Perform testing against the documentation/specification openspace::documentation::testSpecificationAndThrow( @@ -140,32 +153,22 @@ void ConfigurationManager::loadFromFile(const string& filename) { // Register all the paths ghoul::Dictionary dictionary = value(KeyPaths); - std::vector pathKeys = dictionary.keys(); - for (std::string key : pathKeys) { - std::string p; - if (dictionary.getValue(key, p)) { - std::string fullKey = - FileSystem::TokenOpeningBraces + key + FileSystem::TokenClosingBraces; - LDEBUGC("ConfigurationManager", "Registering path " << fullKey << ": " << p); - - bool override = (basePathToken == fullKey); - if (override) - LINFOC("ConfigurationManager", "Overriding base path with '" << p << "'"); - - using Override = ghoul::filesystem::FileSystem::Override; - FileSys.registerPathToken( - std::move(fullKey), - std::move(p), - override ? Override::Yes : Override::No - ); + for (std::string key : dictionary.keys()) { + std::string p = dictionary.value(key); + std::string fullKey = + FileSystem::TokenOpeningBraces + key + FileSystem::TokenClosingBraces; + LDEBUGC("ConfigurationManager", "Registering path " << fullKey << ": " << p); + + bool override = (basePathToken == fullKey); + if (override) { + LINFOC("ConfigurationManager", "Overriding base path with '" << p << "'"); } - } - bool complete = checkCompleteness(); - if (!complete) { - throw ghoul::RuntimeError( - "Configuration file '" + filename + "' was not complete", - "ConfigurationManager" + using Override = ghoul::filesystem::FileSystem::Override; + FileSys.registerPathToken( + std::move(fullKey), + std::move(p), + override ? Override::Yes : Override::No ); } @@ -174,29 +177,4 @@ void ConfigurationManager::loadFromFile(const string& filename) { removeKey(KeyPaths); } -bool ConfigurationManager::checkCompleteness() const { - std::vector requiredTokens = { - KeyPaths, - KeyPaths + "." + KeyCache, - KeyFonts, - KeyConfigSgct - }; - - bool totalSuccess = true; - for (const std::string& token : requiredTokens) { - bool success = hasKey(token); - - if (!success) { - LFATALC( - "ConfigurationManager", - "Configuration file did not contain required key '" << token << "'" - ); - } - - totalSuccess &= success; - } - - return totalSuccess; -} - } // namespace openspace diff --git a/src/engine/configurationmanager_doc.inl b/src/engine/configurationmanager_doc.inl index 28c2980a6e..c00eb44b83 100644 --- a/src/engine/configurationmanager_doc.inl +++ b/src/engine/configurationmanager_doc.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,11 +22,12 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include #include namespace openspace { -Documentation ConfigurationManager::Documentation() { +documentation::Documentation ConfigurationManager::Documentation() { using namespace documentation; return { @@ -37,7 +38,8 @@ Documentation ConfigurationManager::Documentation() { ConfigurationManager::KeyConfigSgct, new StringAnnotationVerifier("A valid SGCT configuration file"), "The SGCT configuration file that determines the window and view frustum " - "settings that are being used when OpenSpace is started." + "settings that are being used when OpenSpace is started.", + Optional::No }, { ConfigurationManager::KeyConfigScene, @@ -47,7 +49,16 @@ Documentation ConfigurationManager::Documentation() { "The scene description that is used to populate the application after " "startup. The scene determines which objects are loaded, the startup " "time and other scene-specific settings. More information is provided in " - "the Scene documentation." + "the Scene documentation.", + Optional::No + }, + { + ConfigurationManager::KeyConfigTask, + new StringAnnotationVerifier( + "A valid task file as described in the Task documentation"), + "The root task to be performed when launching the task runner " + "applicaition.", + Optional::Yes }, { ConfigurationManager::KeyPaths, @@ -55,7 +66,14 @@ Documentation ConfigurationManager::Documentation() { "A list of paths that are automatically registered with the file system. " "If a key X is used in the table, it is then useable by referencing ${X} " "in all other configuration files or scripts.", - Optional::Yes + Optional::No + }, + { + ConfigurationManager::KeyPaths + '.' + ConfigurationManager::KeyCache, + new StringVerifier, + "The path to be used as a cache folder. If per scene caching is enabled, the " + "name of the scene will be appended to this folder", + Optional::No }, { ConfigurationManager::KeyFonts, @@ -72,7 +90,7 @@ Documentation ConfigurationManager::Documentation() { ConfigurationManager::PartLogLevel, new StringInListVerifier( // List from logmanager.cpp::levelFromString - { "Debug", "Info", "Warning", "Error", "Fatal", "None" } + { "Trace", "Debug", "Info", "Warning", "Error", "Fatal", "None" } ), "The severity of log messages that will be displayed. Only " "messages of the selected level or higher will be displayed. All " @@ -95,31 +113,8 @@ Documentation ConfigurationManager::Documentation() { new TableVerifier({ { "*", - new TableVerifier({ - { - ConfigurationManager::PartType, - new StringInListVerifier({ - // List from logfactory.cpp::createLog - "text", "html" - }), - "The type of the new log to be generated." - }, - { - ConfigurationManager::PartFile, - new StringVerifier, - "The filename to which the log will be written." - }, - { - ConfigurationManager::PartAppend, - new BoolVerifier, - "Determines whether the file will be cleared at " - "startup or if the contents will be appended to " - "previous runs.", - Optional::Yes - } - }), - "Additional log files", - Optional::Yes + new ReferencingVerifier("core_logfactory"), + "Additional log files" } }), "Per default, log messages are written to the console, the " @@ -386,4 +381,4 @@ Documentation ConfigurationManager::Documentation() { }; -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 8f56ba23d0..42d6c7afac 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -162,7 +162,10 @@ std::shared_ptr DownloadManager::downloadFile( std::shared_ptr future = std::make_shared(file.filename()); errno = 0; FILE* fp = fopen(file.path().c_str(), "wb"); // write binary - ghoul_assert(fp != nullptr, "Could not open/create file:\n" << file.path().c_str() << " \nerrno: " << errno); + ghoul_assert( + fp != nullptr, + "Could not open/create file:\n" + file.path() + " \nerrno: " + std::to_string(errno) + ); //LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'"); @@ -299,6 +302,12 @@ std::vector> DownloadManager::downl std::string line; int nFiles = 0; while (std::getline(temporary, line)) { + if (line.empty()) { + // This might occur if someone added multiple newlines + // or mixing carriage return and newlines + continue; + } + ++nFiles; #ifdef __APPLE__ // @TODO: Fix this so that the ifdef is not necessary anymore ---abock diff --git a/src/engine/logfactory.cpp b/src/engine/logfactory.cpp index 7cf10928ee..cddfd946b2 100644 --- a/src/engine/logfactory.cpp +++ b/src/engine/logfactory.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,9 @@ #include +#include +#include + #include #include #include @@ -51,37 +54,105 @@ namespace { namespace openspace { +documentation::Documentation LogFactoryDocumentation() { + using namespace documentation; + + return { + "LogFactory", + "core_logfactory", + { + { + keyType, + new StringInListVerifier({ + // List from createLog + valueTextLog, valueHtmlLog + }), + "The type of the new log to be generated." + }, + { + keyFilename, + new StringVerifier, + "The filename to which the log will be written." + }, + { + keyAppend, + new BoolVerifier, + "Determines whether the file will be cleared at startup or if the " + "contents will be appended to previous runs.", + Optional::Yes + }, + { + keyTimeStamping, + new BoolVerifier, + "Determines whether the log entires should be stamped with the time at " + "which the message was logged.", + Optional::Yes + }, + { + keyDateStamping, + new BoolVerifier, + "Determines whether the log entries should be stamped with the date at " + "which the message was logged.", + Optional::Yes + }, + { + keyCategoryStamping, + new BoolVerifier, + "Determines whether the log entries should be stamped with the " + "category that creates the log message.", + Optional::Yes + }, + { + keyLogLevelStamping, + new BoolVerifier, + "Determines whether the log entries should be stamped with the log level " + "that was used to create the log message.", + Optional::Yes + } + }, + Exhaustive::Yes + }; +} + std::unique_ptr createLog(const ghoul::Dictionary& dictionary) { using namespace std::string_literals; - std::string type; - bool typeSuccess = dictionary.getValue(keyType, type); - if (!typeSuccess) { - throw ghoul::RuntimeError( - "Requested log did not contain key '"s + keyType + "'", "LogFactory" - ); - } - std::string filename; - bool filenameSuccess = dictionary.getValue(keyFilename, filename); - if (!filenameSuccess) { - throw ghoul::RuntimeError( - "Requested log did not contain key '"s + keyFilename + "'", "LogFactory" - ); - } - filename = absPath(filename); + documentation::testSpecificationAndThrow( + LogFactoryDocumentation(), + dictionary, + "LogFactory" + ); + // 'type' and 'filename' are required keys + std::string type = dictionary.value(keyType); + std::string filename = absPath(dictionary.value(keyFilename)); + + // the rest are optional bool append = true; - dictionary.getValue(keyAppend, append); + if (dictionary.hasKeyAndValue(keyAppend)) { + append = dictionary.value(keyAppend); + } bool timeStamp = true; - dictionary.getValue(keyTimeStamping, timeStamp); + if (dictionary.hasKeyAndValue(keyTimeStamping)) { + timeStamp = dictionary.value(keyTimeStamping); + } bool dateStamp = true; - dictionary.getValue(keyDateStamping, dateStamp); + if (dictionary.hasKeyAndValue(keyDateStamping)) { + dateStamp = dictionary.value(keyDateStamping); + } bool categoryStamp = true; - dictionary.getValue(keyCategoryStamping, categoryStamp); + if (dictionary.hasKeyAndValue(keyCategoryStamping)) { + categoryStamp = dictionary.value(keyCategoryStamping); + } bool logLevelStamp = true; - dictionary.getValue(keyLogLevelStamping, logLevelStamp); + if (dictionary.hasKeyAndValue(keyLogLevelStamping)) { + logLevelStamp = dictionary.value(keyLogLevelStamping); + } std::string logLevel; - dictionary.getValue(keyLogLevel, logLevel); + if (dictionary.hasKeyAndValue(keyLogLevel)) { + logLevel = dictionary.value(keyLogLevel); + } + using Append = ghoul::logging::TextLog::Append; using TimeStamping = ghoul::logging::Log::TimeStamping; @@ -90,7 +161,6 @@ std::unique_ptr createLog(const ghoul::Dictionary& dictiona using LogLevelStamping = ghoul::logging::Log::LogLevelStamping; if (type == valueHtmlLog) { - std::vector cssFiles{absPath(BootstrapPath), absPath(CssPath)}; std::vector jsFiles{absPath(JsPath)}; @@ -102,7 +172,8 @@ std::unique_ptr createLog(const ghoul::Dictionary& dictiona dateStamp ? DateStamping::Yes : DateStamping::No, categoryStamp ? CategoryStamping::Yes : CategoryStamping::No, logLevelStamp ? LogLevelStamping::Yes : LogLevelStamping::No, - cssFiles, jsFiles + cssFiles, + jsFiles ); } else { @@ -141,11 +212,7 @@ std::unique_ptr createLog(const ghoul::Dictionary& dictiona ); } } - else { - throw ghoul::RuntimeError( - "Log with type '" + type + "' did not name a valid log", "LogFactory" - ); - } + ghoul_assert(false, "Missing case in the documentation for LogFactory"); } } // namespace openspace diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index 4527c6041f..8abb756e1b 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -34,7 +35,7 @@ #include "moduleengine_lua.inl" namespace { - const std::string _loggerCat = "ModuleEngine"; + const char* _loggerCat = "ModuleEngine"; } namespace openspace { @@ -48,7 +49,7 @@ void ModuleEngine::initialize() { void ModuleEngine::deinitialize() { LDEBUG("Deinitializing modules"); for (auto& m : _modules) { - LDEBUG("Deinitialieing module '" << m->name() << "'"); + LDEBUG("Deinitializing module '" << m->name() << "'"); m->deinitialize(); } _modules.clear(); @@ -67,12 +68,14 @@ void ModuleEngine::registerModule(std::unique_ptr module) { ); if (it != _modules.end()) { throw ghoul::RuntimeError( - "Module name '" + module->name() + "' was registered before", "ModuleEngine" + "Module name '" + module->name() + "' was registered before", + "ModuleEngine" ); } LDEBUG("Registering module '" << module->name() << "'"); module->initialize(); + LDEBUG("Registered module '" << module->name() << "'"); _modules.push_back(std::move(module)); } @@ -84,11 +87,8 @@ std::vector ModuleEngine::modules() const { return result; } -ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version -ModuleEngine::requiredOpenGLVersion() const -{ - using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version; - Version version = { 0,0 }; +ghoul::systemcapabilities::Version ModuleEngine::requiredOpenGLVersion() const { + ghoul::systemcapabilities::Version version = { 0, 0 }; for (const auto& m : _modules) { version = std::max(version, m->requiredOpenGLVersion()); diff --git a/src/engine/moduleengine_lua.inl b/src/engine/moduleengine_lua.inl index a0524891e0..bd33e3875c 100644 --- a/src/engine/moduleengine_lua.inl +++ b/src/engine/moduleengine_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 99604ca209..7463aaf40a 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -36,58 +36,44 @@ #include #include #include -#include #include -#include #include -#include #include -#include -#include -#include #include +#include + +#include +#include +#include #include #include + #include +#include +#include #include #include #include -#include #include #include +#include #include #include #include -#include #include #include #include #include -#include -#include -#include -#include #include -#include -#include - -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED -#include -#endif - -#ifdef OPENSPACE_MODULE_ISWA_ENABLED -#include -#include -#endif #if defined(_MSC_VER) && defined(OPENSPACE_ENABLE_VLD) #include #endif #ifdef WIN32 -#include +#include #endif #include "openspaceengine_lua.inl" @@ -98,14 +84,13 @@ using namespace ghoul::logging; using namespace ghoul::cmdparser; namespace { - const std::string _loggerCat = "OpenSpaceEngine"; - const std::string _sgctDefaultConfigFile = "${SGCT}/single.xml"; - const std::string _defaultCacheLocation = "${BASE_PATH}/cache"; + const char* _loggerCat = "OpenSpaceEngine"; + const char* SgctDefaultConfigFile = "${SGCT}/single.xml"; - const std::string _sgctConfigArgumentCommand = "-config"; + const char* SgctConfigArgumentCommand = "-config"; - const std::string PreInitializeFunction = "preInitialization"; - const std::string PostInitializationFunction = "postInitialization"; + const char* PreInitializeFunction = "preInitialization"; + const char* PostInitializationFunction = "postInitialization"; const int CacheVersion = 1; const int DownloadVersion = 1; @@ -138,7 +123,7 @@ OpenSpaceEngine::OpenSpaceEngine( , _scriptEngine(new scripting::ScriptEngine) , _scriptScheduler(new scripting::ScriptScheduler) , _networkEngine(new NetworkEngine) - , _syncEngine(std::make_unique(new SyncBuffer(4096))) + , _syncEngine(std::make_unique(4096)) , _commandlineParser(new ghoul::cmdparser::CommandlineParser( programName, ghoul::cmdparser::CommandlineParser::AllowUnknownCommands::Yes )) @@ -147,25 +132,23 @@ OpenSpaceEngine::OpenSpaceEngine( , _settingsEngine(new SettingsEngine) , _timeManager(new TimeManager) , _downloadManager(nullptr) -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - , _gui(new gui::GUI) -#endif , _parallelConnection(new ParallelConnection) , _windowWrapper(std::move(windowWrapper)) - , _globalPropertyNamespace(new properties::PropertyOwner) + , _globalPropertyNamespace(new properties::PropertyOwner("")) , _switchScene(false) , _scenePath("") , _isMaster(false) , _runTime(0.0) - , _isInShutdownMode(false) - , _shutdownCountdown(0.f) - , _shutdownWait(0.f) + , _shutdown({false, 0.f, 0.f}) , _isFirstRenderingFirstFrame(true) { _interactionHandler->setPropertyOwner(_globalPropertyNamespace.get()); + + // New property subowners also have to be added to the OnScreenGuiModule callback! _globalPropertyNamespace->addPropertySubOwner(_interactionHandler.get()); _globalPropertyNamespace->addPropertySubOwner(_settingsEngine.get()); _globalPropertyNamespace->addPropertySubOwner(_renderEngine.get()); + _globalPropertyNamespace->addPropertySubOwner(_windowWrapper.get()); FactoryManager::initialize(); FactoryManager::ref().addFactory( @@ -184,55 +167,29 @@ OpenSpaceEngine::OpenSpaceEngine( std::make_unique>(), "Scale" ); + FactoryManager::ref().addFactory( + std::make_unique>(), + "Task" + ); SpiceManager::initialize(); Time::initialize(); TransformationManager::initialize(); } -OpenSpaceEngine::~OpenSpaceEngine() { - LINFO("_windowWrapper->isUsingSwapGroups(): " << _windowWrapper->isUsingSwapGroups()); - LINFO("_windowWrapper->isSwapGroupMaster(): " << _windowWrapper->isSwapGroupMaster()); -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - _gui->deinitializeGL(); -#endif - - _renderEngine->setScene(nullptr); - _renderEngine->setCamera(nullptr); - _sceneManager = nullptr; - - _interactionHandler->deinitialize(); - _renderEngine->deinitialize(); - - _globalPropertyNamespace = nullptr; - _windowWrapper = nullptr; - _parallelConnection = nullptr; - _configurationManager = nullptr; - _interactionHandler = nullptr; - _renderEngine = nullptr; - _scriptEngine = nullptr; - _networkEngine = nullptr; - _syncEngine = nullptr; - _commandlineParser = nullptr; - _console = nullptr; - _moduleEngine = nullptr; - _settingsEngine = nullptr; -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - _gui = nullptr; -#endif -} - OpenSpaceEngine& OpenSpaceEngine::ref() { ghoul_assert(_engine, "OpenSpaceEngine not created"); return *_engine; } -bool OpenSpaceEngine::create(int argc, char** argv, - std::unique_ptr windowWrapper, - std::vector& sgctArguments) +void OpenSpaceEngine::create(int argc, char** argv, + std::unique_ptr windowWrapper, + std::vector& sgctArguments, bool& requestClose) { ghoul_assert(!_engine, "OpenSpaceEngine was already created"); ghoul_assert(windowWrapper != nullptr, "No Window Wrapper was provided"); + + requestClose = false; ghoul::initialize(); @@ -258,14 +215,18 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Sanity check of values if (argc < 1 || argv == nullptr) { - LFATAL("No arguments were passed to this function"); - return false; + throw ghoul::RuntimeError( + "No arguments were passed to this function", + "OpenSpaceEngine" + ); } // Create other objects LDEBUG("Creating OpenSpaceEngine"); _engine = new OpenSpaceEngine(std::string(argv[0]), std::move(windowWrapper)); + registerCoreClasses(DocEng); + // Query modules for commandline arguments _engine->gatherCommandlineArguments(); @@ -277,7 +238,8 @@ bool OpenSpaceEngine::create(int argc, char** argv, bool showHelp = _engine->_commandlineParser->execute(); if (showHelp) { _engine->_commandlineParser->displayHelp(); - return false; + requestClose = true; + return; } sgctArguments = *arguments; @@ -285,15 +247,16 @@ bool OpenSpaceEngine::create(int argc, char** argv, std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName; if (configurationFilePath.empty()) { LDEBUG("Finding configuration"); - try { - configurationFilePath = - ConfigurationManager::findConfiguration(configurationFilePath); - } - catch (const ghoul::RuntimeError& e) { - LFATALC(e.component, e.message); - } + configurationFilePath = + ConfigurationManager::findConfiguration(configurationFilePath); } configurationFilePath = absPath(configurationFilePath); + + if (!FileSys.fileExists(configurationFilePath)) { + throw ghoul::FileNotFoundError( + "Configuration file '" + configurationFilePath + "' not found" + ); + } LINFO("Configuration Path: '" << configurationFilePath << "'"); // Loading configuration from disk @@ -301,19 +264,29 @@ bool OpenSpaceEngine::create(int argc, char** argv, try { _engine->configurationManager().loadFromFile(configurationFilePath); } + catch (const documentation::SpecificationError& e) { + LFATAL("Loading of configuration file '" << configurationFilePath << "' failed"); + for (const documentation::TestResult::Offense& o : e.result.offenses) { + LERRORC(o.offender, std::to_string(o.reason)); + } + for (const documentation::TestResult::Warning& w : e.result.warnings) { + LWARNINGC(w.offender, std::to_string(w.reason)); + } + throw; + } catch (const ghoul::RuntimeError& e) { LFATAL("Loading of configuration file '" << configurationFilePath << "' failed"); - LFATALC(e.component, e.message); - return false; + throw; } - bool hasCacheCommandline = !commandlineArgumentPlaceholders.cacheFolder.empty(); - bool hasCacheConfiguration = _engine->configurationManager().hasKeyAndValue( + const bool hasCacheCommandline = !commandlineArgumentPlaceholders.cacheFolder.empty(); + const bool hasCacheConfiguration = _engine->configurationManager().hasKeyAndValue( ConfigurationManager::KeyPerSceneCache ); std::string cacheFolder = absPath("${CACHE}"); if (hasCacheCommandline) { cacheFolder = commandlineArgumentPlaceholders.cacheFolder; + // @CLEANUP: Why is this commented out? ---abock //FileSys.registerPathToken( // "${CACHE}", // commandlineArgumentPlaceholders.cacheFolder, @@ -343,7 +316,9 @@ bool OpenSpaceEngine::create(int argc, char** argv, LINFOC("OpenSpace Version", OPENSPACE_VERSION_MAJOR << "." << OPENSPACE_VERSION_MINOR << "." << - OPENSPACE_VERSION_PATCH << " (" << OPENSPACE_VERSION_STRING << ")"); + OPENSPACE_VERSION_PATCH << + " (" << OPENSPACE_VERSION_STRING << ")" + ); // Create directories that doesn't exist auto tokens = FileSys.tokens(); @@ -358,7 +333,6 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Register modules _engine->_moduleEngine->initialize(); - registerCoreClasses(DocEng); // After registering the modules, the documentations for the available classes // can be added as well for (OpenSpaceModule* m : _engine->_moduleEngine->modules()) { @@ -378,7 +352,7 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Determining SGCT configuration file LDEBUG("Determining SGCT configuration file"); - std::string sgctConfigurationPath = _sgctDefaultConfigFile; + std::string sgctConfigurationPath = SgctDefaultConfigFile; _engine->configurationManager().getValue( ConfigurationManager::KeyConfigSgct, sgctConfigurationPath); @@ -391,13 +365,20 @@ bool OpenSpaceEngine::create(int argc, char** argv, // 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]); - sgctArguments.insert(sgctArguments.begin() + 1, _sgctConfigArgumentCommand); + sgctArguments.insert(sgctArguments.begin() + 1, SgctConfigArgumentCommand); sgctArguments.insert(sgctArguments.begin() + 2, absPath(sgctConfigurationPath)); - - return true; } void OpenSpaceEngine::destroy() { + LTRACE("OpenSpaceEngine::destroy(begin)"); + for (const auto& func : _engine->_moduleCallbacks.deinitializeGL) { + func(); + } + + for (const auto& func : _engine->_moduleCallbacks.deinitialize) { + func(); + } + _engine->_moduleEngine->deinitialize(); _engine->_console->deinitialize(); @@ -412,13 +393,17 @@ void OpenSpaceEngine::destroy() { LogManager::deinitialize(); ghoul::deinitialize(); + LTRACE("OpenSpaceEngine::destroy(end)"); } -bool OpenSpaceEngine::initialize() { +void OpenSpaceEngine::initialize() { + LTRACE("OpenSpaceEngine::initialize(begin)"); // clear the screen so the user don't have to see old buffer contents from the // graphics card - clearAllWindows(); + LDEBUG("Clearing all Windows"); + _windowWrapper->clearAllWindows(glm::vec4(0.f, 0.f, 0.f, 1.f)); + LDEBUG("Adding system components"); // Detect and log OpenCL and OpenGL versions and available devices SysCap.addComponent( std::make_unique() @@ -426,68 +411,79 @@ bool OpenSpaceEngine::initialize() { SysCap.addComponent( std::make_unique() ); + + LDEBUG("Detecting capabilities"); SysCap.detectCapabilities(); using Verbosity = ghoul::systemcapabilities::SystemCapabilitiesComponent::Verbosity; Verbosity verbosity = Verbosity::Default; - if (configurationManager().hasKeyAndValue( - - ConfigurationManager::KeyCapabilitiesVerbosity)) { - std::map verbosityMap = { + if (configurationManager().hasKey(ConfigurationManager::KeyCapabilitiesVerbosity)) { + static const std::map VerbosityMap = { { "None", Verbosity::None }, { "Minimal", Verbosity::Minimal }, { "Default", Verbosity::Default }, { "Full", Verbosity::Full } }; - std::string v = configurationManager().value(ConfigurationManager::KeyCapabilitiesVerbosity); - if (verbosityMap.find(v) != verbosityMap.end()) - verbosity = verbosityMap[v]; + std::string v = configurationManager().value( + ConfigurationManager::KeyCapabilitiesVerbosity + ); + ghoul_assert( + VerbosityMap.find(v) != VerbosityMap.end(), + "Missing check for syscaps verbosity in openspace.cfg documentation" + ); + verbosity = VerbosityMap.find(v)->second; } SysCap.logCapabilities(verbosity); // Check the required OpenGL versions of the registered modules - ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version version = + ghoul::systemcapabilities::Version version = _engine->_moduleEngine->requiredOpenGLVersion(); - LINFO("Required OpenGL version: " << version.toString()); + LINFO("Required OpenGL version: " << std::to_string(version)); if (OpenGLCap.openGLVersion() < version) { - LFATAL("Module required higher OpenGL version than is supported"); - return false; + throw ghoul::RuntimeError( + "Module required higher OpenGL version than is supported", + "OpenSpaceEngine" + ); } - std::string requestURL = ""; - bool success = configurationManager().getValue(ConfigurationManager::KeyDownloadRequestURL, requestURL); - if (success) { - _downloadManager = std::make_unique(requestURL, DownloadVersion); + if (configurationManager().hasKey(ConfigurationManager::KeyDownloadRequestURL)) { + const std::string requestUrl = configurationManager().value( + ConfigurationManager::KeyDownloadRequestURL + ); + + _downloadManager = std::make_unique( + requestUrl, + DownloadVersion + ); } // Register Lua script functions LDEBUG("Registering Lua libraries"); registerCoreClasses(*_scriptEngine); - -#ifdef OPENSPACE_MODULE_ISWA_ENABLED - _scriptEngine->addLibrary(IswaManager::luaLibrary()); -#endif - + + for (OpenSpaceModule* module : _moduleEngine->modules()) { + _scriptEngine->addLibrary(module->luaLibrary()); + } + // TODO: Maybe move all scenegraph and renderengine stuff to initializeGL scriptEngine().initialize(); writeDocumentation(); - bool disableMasterRendering = false; - configurationManager().getValue( - ConfigurationManager::KeyDisableMasterRendering, disableMasterRendering); - _renderEngine->setDisableRenderingOnMaster(disableMasterRendering); + if (configurationManager().hasKey(ConfigurationManager::KeyShutdownCountdown)) { + _shutdown.waitTime = configurationManager().value( + ConfigurationManager::KeyShutdownCountdown + ); + } - configurationManager().getValue( - ConfigurationManager::KeyShutdownCountdown, _shutdownWait - ); - - if (!commandlineArgumentPlaceholders.sceneName.empty()) + if (!commandlineArgumentPlaceholders.sceneName.empty()) { configurationManager().setValue( ConfigurationManager::KeyConfigScene, - commandlineArgumentPlaceholders.sceneName); + commandlineArgumentPlaceholders.sceneName + ); + } // Initialize the SettingsEngine _settingsEngine->initialize(); @@ -503,10 +499,10 @@ bool OpenSpaceEngine::initialize() { configurationManager().getValue(ConfigurationManager::KeyConfigScene, scenePath); _renderEngine->initialize(); + scheduleLoadScene(scenePath); LINFO("Finished initializing"); - return true; } void OpenSpaceEngine::scheduleLoadScene(const std::string& scenePath) { @@ -610,64 +606,32 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) { scene->writePropertyDocumentation(propertyDocumentationFile, propertyDocumentationType, scenePath); } + _renderEngine->setGlobalBlackOutFactor(0.0); + _renderEngine->startFading(1, 3.0); -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - LINFO("Initializing GUI"); - _gui->initialize(); - _gui->_globalProperty.setSource( - [&]() { - std::vector res = { - _settingsEngine.get(), - _interactionHandler.get(), - _renderEngine.get() - }; - return res; - } - ); + for (const auto& func : _moduleCallbacks.initialize) { + func(); + } - OsEng.gui()._screenSpaceProperty.setSource( - [&]() { - const auto& ssr = renderEngine().screenSpaceRenderables(); - return std::vector(ssr.begin(), ssr.end()); - } - ); - - OsEng.gui()._property.setSource( - [&]() { - const auto& nodes = renderEngine().scene()->allSceneGraphNodes(); - return std::vector(nodes.begin(), nodes.end()); - } - ); - -#ifdef OPENSPACE_MODULE_ISWA_ENABLED - OsEng.gui()._iswa.setSource( - [&]() { - const auto& groups = IswaManager::ref().groups(); - std::vector res; - std::transform( - groups.begin(), - groups.end(), - std::back_inserter(res), - [](const auto& val) { - return val.second.get(); - } - ); - return res; - } - ); -#endif - -#endif - -#ifdef OPENSPACE_MODULE_ISWA_ENABLED - IswaManager::initialize(); -#endif + // Run start up scripts + runPreInitializationScripts(scenePath); _syncEngine->addSyncables(Time::ref().getSyncables()); _syncEngine->addSyncables(_renderEngine->getSyncables()); _syncEngine->addSyncable(_scriptEngine.get()); + + LINFO("Finished initializing"); + LTRACE("OpenSpaceEngine::initialize(end)"); } +void OpenSpaceEngine::deinitialize() { + LTRACE("OpenSpaceEngine::deinitialize(begin)"); + + _interactionHandler->deinitialize(); + _renderEngine->deinitialize(); + + LTRACE("OpenSpaceEngine::deinitialize(end)"); +} void OpenSpaceEngine::writeDocumentation() { // If a LuaDocumentationFile was specified, generate it now @@ -679,13 +643,17 @@ void OpenSpaceEngine::writeDocumentation() { const bool hasLuaDocType = configurationManager().hasKey(LuaDocumentationType); const bool hasLuaDocFile = configurationManager().hasKey(LuaDocumentationFile); if (hasLuaDocType && hasLuaDocFile) { - std::string luaDocumentationType; - configurationManager().getValue(LuaDocumentationType, luaDocumentationType); - std::string luaDocumentationFile; - configurationManager().getValue(LuaDocumentationFile, luaDocumentationFile); + std::string luaDocumentationType = configurationManager().value( + LuaDocumentationType + ); + std::string luaDocumentationFile = configurationManager().value( + LuaDocumentationFile + ); - luaDocumentationFile = absPath(luaDocumentationFile); - _scriptEngine->writeDocumentation(luaDocumentationFile, luaDocumentationType); + _scriptEngine->writeDocumentation( + absPath(luaDocumentationFile), + luaDocumentationType + ); } // If a general documentation was specified, generate it now @@ -697,37 +665,45 @@ void OpenSpaceEngine::writeDocumentation() { const bool hasDocumentationType = configurationManager().hasKey(DocumentationType); const bool hasDocumentationFile = configurationManager().hasKey(DocumentationFile); if (hasDocumentationType && hasDocumentationFile) { - std::string documentationType; - configurationManager().getValue(DocumentationType, documentationType); - std::string documentationFile; - configurationManager().getValue(DocumentationFile, documentationFile); - documentationFile = absPath(documentationFile); - DocEng.writeDocumentation(documentationFile, documentationType); + std::string documentationType = configurationManager().value( + DocumentationType + ); + std::string documentationFile = configurationManager().value( + DocumentationFile + ); + + DocEng.writeDocumentation( + absPath(documentationFile), + documentationType + ); } const std::string FactoryDocumentationType = - ConfigurationManager::KeyFactoryDocumentation + '.' + ConfigurationManager::PartType; + ConfigurationManager::KeyFactoryDocumentation + '.' + + ConfigurationManager::PartType; const std::string FactoryDocumentationFile = - ConfigurationManager::KeyFactoryDocumentation + '.' + ConfigurationManager::PartFile; - bool hasFactoryDocumentationType = configurationManager().hasKey(FactoryDocumentationType); - bool hasFactoryDocumentationFile = configurationManager().hasKey(FactoryDocumentationFile); + ConfigurationManager::KeyFactoryDocumentation + '.' + + ConfigurationManager::PartFile; + + bool hasFactoryDocumentationType = configurationManager().hasKey( + FactoryDocumentationType + ); + bool hasFactoryDocumentationFile = configurationManager().hasKey( + FactoryDocumentationFile + ); if (hasFactoryDocumentationType && hasFactoryDocumentationFile) { - std::string type = configurationManager().value(FactoryDocumentationType); - std::string file = configurationManager().value(FactoryDocumentationFile); + std::string type = configurationManager().value( + FactoryDocumentationType + ); + std::string file = configurationManager().value( + FactoryDocumentationFile + ); FactoryManager::ref().writeDocumentation(absPath(file), type); } } -bool OpenSpaceEngine::isInitialized() { - return _engine != nullptr; -} - -void OpenSpaceEngine::clearAllWindows() { - _windowWrapper->clearAllWindows(glm::vec4(0.f, 0.f, 0.f, 1.f)); -} - void OpenSpaceEngine::gatherCommandlineArguments() { commandlineArgumentPlaceholders.configurationName = ""; _commandlineParser->addCommand(std::make_unique>( @@ -756,83 +732,65 @@ void OpenSpaceEngine::gatherCommandlineArguments() { )); } -void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) { - for (size_t i = 1; i <= scripts.size(); ++i) { - std::stringstream stream; - stream << i; - const std::string& key = stream.str(); - const bool hasKey = scripts.hasKeyAndValue(key); - if (!hasKey) { - LERROR("The startup scripts have to be declared in a simple array format." - " Startup scripts did not contain the key '" << key << "'"); - break; - } - - std::string scriptPath; - scripts.getValue(key, scriptPath); - std::string&& absoluteScriptPath = absPath(scriptPath); - _engine->scriptEngine().runScriptFile(absoluteScriptPath); - } -} - - void OpenSpaceEngine::runPreInitializationScripts(const std::string& sceneDescription) { + // @CLEANUP: Move this into the scene loading? ---abock LINFO("Running Initialization scripts"); - lua_State* state = ghoul::lua::createNewLuaState(); - OnExit( - // Delete the Lua state at the end of the scope, no matter what - [state](){ghoul::lua::destroyLuaState(state);} - ); + + ghoul::lua::LuaState state; OsEng.scriptEngine().initializeLuaState(state); // First execute the script to get all global variables ghoul::lua::runScriptFile(state, absPath(sceneDescription)); // Get the preinitialize function - lua_getglobal(state, PreInitializeFunction.c_str()); + lua_getglobal(state, PreInitializeFunction); bool isFunction = lua_isfunction(state, -1); if (!isFunction) { - LERROR("Error executing startup script '" << sceneDescription << "'. Scene '" << - sceneDescription << "' does not have a function '" << - PreInitializeFunction << "'"); + LERROR( + "Error executing startup script '" << sceneDescription << "'. Scene '" << + sceneDescription << "' does not have a function '" << + PreInitializeFunction << "'" + ); return; } // And execute the preinitialize function int success = lua_pcall(state, 0, 0, 0); if (success != 0) { - LERROR("Error executing '" << PreInitializeFunction << "': " << - lua_tostring(state, -1)); + LERROR( + "Error executing '" << PreInitializeFunction << "': " << + lua_tostring(state, -1) + ); } } void OpenSpaceEngine::runPostInitializationScripts(const std::string& sceneDescription) { + // @CLEANUP: Move this into the scene loading? ---abock LINFO("Running Setup scripts"); - lua_State* state = ghoul::lua::createNewLuaState(); - OnExit( - // Delete the Lua state at the end of the scope, no matter what - [state](){ghoul::lua::destroyLuaState(state);} - ); + ghoul::lua::LuaState state; OsEng.scriptEngine().initializeLuaState(state); // First execute the script to get all global variables ghoul::lua::runScriptFile(state, absPath(sceneDescription)); // Get the preinitialize function - lua_getglobal(state, PostInitializationFunction.c_str()); + lua_getglobal(state, PostInitializationFunction); bool isFunction = lua_isfunction(state, -1); if (!isFunction) { - LERROR("Error executing startup script '" << sceneDescription << "'. Scene '" << - sceneDescription << "' does not have a function '" << - PostInitializationFunction << "'"); + LERROR( + "Error executing startup script '" << sceneDescription << "'. Scene '" << + sceneDescription << "' does not have a function '" << + PostInitializationFunction << "'" + ); return; } // And execute the preinitialize function int success = lua_pcall(state, 0, 0, 0); if (success != 0) { - LERROR("Error executing '" << PostInitializationFunction << "': " << - lua_tostring(state, -1) + LERROR( + "Error executing '" << PostInitializationFunction << "': " << + lua_tostring(state, -1) ); } } @@ -841,12 +799,11 @@ void OpenSpaceEngine::loadFonts() { ghoul::Dictionary fonts; configurationManager().getValue(ConfigurationManager::KeyFonts, fonts); - const glm::ivec3 fontAtlasSize{1024, 1024, 1}; + glm::ivec3 fontAtlasSize{1024, 1024, 1}; _fontManager = std::make_unique(fontAtlasSize); for (const std::string& key : fonts.keys()) { - std::string font; - fonts.getValue(key, font); + std::string font = fonts.value(key); font = absPath(font); if (!FileSys.fileExists(font)) { @@ -884,7 +841,7 @@ void OpenSpaceEngine::configureLogging() { ConfigurationManager::KeyLogging + '.' + ConfigurationManager::PartLogs; if (configurationManager().hasKeyAndValue(KeyLogLevel)) { - std::string logLevel; + std::string logLevel = "Info"; configurationManager().getValue(KeyLogLevel, logLevel); bool immediateFlush = false; @@ -897,16 +854,15 @@ void OpenSpaceEngine::configureLogging() { level, immediateFlush ? ImmediateFlush::Yes : ImmediateFlush::No ); + LogMgr.addLog(std::make_unique()); } if (configurationManager().hasKeyAndValue(KeyLogs)) { - ghoul::Dictionary logs; - configurationManager().getValue(KeyLogs, logs); + ghoul::Dictionary logs = configurationManager().value(KeyLogs); for (size_t i = 1; i <= logs.size(); ++i) { - ghoul::Dictionary logInfo; - logs.getValue(std::to_string(i), logInfo); + ghoul::Dictionary logInfo = logs.value(std::to_string(i)); try { LogMgr.addLog(createLog(logInfo)); @@ -922,45 +878,52 @@ void OpenSpaceEngine::configureLogging() { LogMgr.addLog(std::make_unique()); } #endif // WIN32 + +#ifndef GHOUL_LOGGING_ENABLE_TRACE + std::string logLevel = "Info"; + configurationManager().getValue(KeyLogLevel, logLevel); + LogLevel level = ghoul::logging::levelFromString(logLevel); + + if (level == ghoul::logging::LogLevel::Trace) { + LWARNING( + "Desired logging level is set to 'Trace' but application was " << + "compiled without Trace support" + ); + } +#endif // GHOUL_LOGGING_ENABLE_TRACE } -bool OpenSpaceEngine::initializeGL() { +void OpenSpaceEngine::initializeGL() { + LTRACE("OpenSpaceEngine::initializeGL(begin)"); + LINFO("Initializing Rendering Engine"); - bool success = _renderEngine->initializeGL(); -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - LINFO("Initializing OnScreen GUI GL"); - try { - _gui->initializeGL(); + // @CLEANUP: Remove the return statement and replace with exceptions ---abock + _renderEngine->initializeGL(); + + for (const auto& func : _moduleCallbacks.initializeGL) { + func(); } - catch (const ghoul::RuntimeError& e) { - LERROR(e.what()); - } -#endif + LINFO("Finished initializing OpenGL"); - // If using swapgroups, - LINFO("_windowWrapper->isUsingSwapGroups(): " << _windowWrapper->isUsingSwapGroups()); - LINFO("_windowWrapper->isSwapGroupMaster(): " << _windowWrapper->isSwapGroupMaster()); - return success; -} - -bool OpenSpaceEngine::isMaster(){ - return _isMaster; -} - -void OpenSpaceEngine::setMaster(bool master){ - _isMaster = master; -} + // If using swapgroups, -double OpenSpaceEngine::runTime(){ + LINFO("IsUsingSwapGroups: " << _windowWrapper->isUsingSwapGroups()); + LINFO("IsSwapGroupMaster: " << _windowWrapper->isSwapGroupMaster()); + + LTRACE("OpenSpaceEngine::initializeGL(end)"); +} + +double OpenSpaceEngine::runTime() { return _runTime; } -void OpenSpaceEngine::setRunTime(double d){ +void OpenSpaceEngine::setRunTime(double d) { _runTime = d; } void OpenSpaceEngine::preSynchronization() { + LTRACE("OpenSpaceEngine::preSynchronization(begin)"); FileSys.triggerFilesystemEvents(); if (_switchScene) { @@ -972,8 +935,10 @@ void OpenSpaceEngine::preSynchronization() { _windowWrapper->setSynchronization(false); } - _syncEngine->presync(_isMaster); - if (_isMaster) { + bool master = _windowWrapper->isMaster(); + + _syncEngine->preSynchronization(SyncEngine::IsMaster(master)); + if (master) { double dt = _windowWrapper->averageDeltaTime(); _timeManager->preSynchronization(dt); @@ -993,16 +958,24 @@ void OpenSpaceEngine::preSynchronization() { _parallelConnection->preSynchronization(); } + + for (const auto& func : _moduleCallbacks.preSync) { + func(); + } + LTRACE("OpenSpaceEngine::preSynchronization(end)"); } void OpenSpaceEngine::postSynchronizationPreDraw() { - _syncEngine->postsync(_isMaster); + LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)"); + + bool master = _windowWrapper->isMaster(); + _syncEngine->postSynchronization(SyncEngine::IsMaster(master)); - if (_isInShutdownMode) { - if (_shutdownCountdown <= 0.f) { + if (_shutdown.inShutdown) { + if (_shutdown.timer <= 0.f) { _windowWrapper->terminate(); } - _shutdownCountdown -= _windowWrapper->averageDeltaTime(); + _shutdown.timer -= _windowWrapper->averageDeltaTime(); } _renderEngine->updateScene(); @@ -1011,33 +984,17 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { _renderEngine->updateScreenSpaceRenderables(); _renderEngine->updateShaderPrograms(); - if (!_isMaster) { + if (!master) { _renderEngine->camera()->invalidateCache(); } // Step the camera using the current mouse velocities which are synced //_interactionHandler->updateCamera(); -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - if (_isMaster && _windowWrapper->isRegularRendering()) { - glm::vec2 mousePosition = _windowWrapper->mousePosition(); - //glm::ivec2 drawBufferResolution = _windowWrapper->currentDrawBufferResolution(); - glm::ivec2 windowSize = _windowWrapper->currentWindowSize(); - glm::ivec2 renderingSize = _windowWrapper->currentWindowResolution(); - uint32_t mouseButtons = _windowWrapper->mouseButtons(2); - - double dt = std::max(_windowWrapper->averageDeltaTime(), 0.0); - - _gui->startFrame( - static_cast(dt), - glm::vec2(windowSize), - _windowWrapper->dpiScaling(), - mousePosition, - mouseButtons - ); + for (const auto& func : _moduleCallbacks.postSyncPreDraw) { + func(); } -#endif - + // Testing this every frame has minimal impact on the performance --- abock // Debug build: 1-2 us ; Release build: <= 1 us using ghoul::logging::LogManager; @@ -1045,113 +1002,118 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { int errorCounter = LogMgr.messageCounter(LogLevel::Error); int fatalCounter = LogMgr.messageCounter(LogLevel::Fatal); - if (warningCounter > 0) + if (warningCounter > 0) { LWARNINGC("Logging", "Number of Warnings raised: " << warningCounter); - if (errorCounter > 0) + } + if (errorCounter > 0) { LWARNINGC("Logging", "Number of Errors raised: " << errorCounter); - if (fatalCounter > 0) + } + if (fatalCounter > 0) { LWARNINGC("Logging", "Number of Fatals raised: " << fatalCounter); + } LogMgr.resetMessageCounters(); - + + LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(end)"); } -void OpenSpaceEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix) { - _renderEngine->render(projectionMatrix, viewMatrix); +void OpenSpaceEngine::render(const glm::mat4& viewMatrix, + const glm::mat4& projectionMatrix) +{ + LTRACE("OpenSpaceEngine::render(begin)"); + _renderEngine->render(viewMatrix, projectionMatrix); + + for (const auto& func : _moduleCallbacks.render) { + func(); + } + + // @CLEANUP: Replace the two windows by a single call to whether a gui should be + // rendered ---abock + bool showGui = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true; + if (showGui && _windowWrapper->isMaster() && _windowWrapper->isRegularRendering()) { + _renderEngine->renderScreenLog(); + _console->render(); + } + + if (_shutdown.inShutdown) { + _renderEngine->renderShutdownInformation(_shutdown.timer, _shutdown.waitTime); + } + + LTRACE("OpenSpaceEngine::render(end)"); } void OpenSpaceEngine::postDraw() { + LTRACE("OpenSpaceEngine::postDraw(begin)"); + _renderEngine->postDraw(); - bool showGui = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true; - if (showGui) { - _renderEngine->renderScreenLog(); - if (_console->isVisible()) - _console->render(); -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - if (_isMaster && _windowWrapper->isRegularRendering()) - _gui->endFrame(); -#endif + for (const auto& func : _moduleCallbacks.postDraw) { + func(); } - - if (_isInShutdownMode) { - _renderEngine->renderShutdownInformation(_shutdownCountdown, _shutdownWait); - } - + if (_isFirstRenderingFirstFrame) { _windowWrapper->setSynchronization(true); _isFirstRenderingFirstFrame = false; } + LTRACE("OpenSpaceEngine::postDraw(end)"); } void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) { - if (_isMaster) { -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - if (_gui->isEnabled()) { - bool isConsumed = _gui->keyCallback(key, mod, action); - if (isConsumed) { - return; - } - } -#endif - if (key == _console->commandInputButton()) { - if (action == KeyAction::Press) { - _console->toggleMode(); - } - } else if (!_console->isVisible()) { - _interactionHandler->keyboardCallback(key, mod, action); - } else { - _console->keyboardCallback(key, mod, action); + for (const auto& func : _moduleCallbacks.keyboard) { + const bool consumed = func(key, mod, action); + if (consumed) { + return; } } + + const bool consoleConsumed = _console->keyboardCallback(key, mod, action); + if (consoleConsumed) { + return; + } + + _interactionHandler->keyboardCallback(key, mod, action); } void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) { - if (_isMaster) { -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - if (_gui->isEnabled()) { - const bool isConsumed = _gui->charCallback(codepoint, modifier); - if (isConsumed) - return; - } -#endif - if (_console->isVisible()) { - _console->charCallback(codepoint, modifier); + for (const auto& func : _moduleCallbacks.character) { + bool consumed = func(codepoint, modifier); + if (consumed) { + return; } } + + _console->charCallback(codepoint, modifier); } void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action) { - if (_isMaster) { -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - if (_gui->isEnabled()) { - const bool isConsumed = _gui->mouseButtonCallback(button, action); - if (isConsumed /*&& action != MouseAction::Release*/) - return; + for (const auto& func : _moduleCallbacks.mouseButton) { + bool consumed = func(button, action); + if (consumed) { + return; } -#endif - _interactionHandler->mouseButtonCallback(button, action); } + + _interactionHandler->mouseButtonCallback(button, action); } void OpenSpaceEngine::mousePositionCallback(double x, double y) { - if (_isMaster) { - _interactionHandler->mousePositionCallback(x, y); + for (const auto& func : _moduleCallbacks.mousePosition) { + func(x, y); } + + _interactionHandler->mousePositionCallback(x, y); } void OpenSpaceEngine::mouseScrollWheelCallback(double pos) { - if (_isMaster) { -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED - if (_gui->isEnabled()) { - const bool isConsumed = _gui->mouseWheelCallback(pos); - if (isConsumed) - return; + for (const auto& func : _moduleCallbacks.mouseScrollWheel) { + bool consumed = func(pos); + if (consumed) { + return; } -#endif - _interactionHandler->mouseScrollWheelCallback(pos); } + + _interactionHandler->mouseScrollWheelCallback(pos); } void OpenSpaceEngine::encode() { @@ -1168,23 +1130,24 @@ void OpenSpaceEngine::decode() { void OpenSpaceEngine::externalControlCallback(const char* receivedChars, int size, int clientId) { - if (size == 0) + if (size == 0) { return; + } _networkEngine->handleMessage(std::string(receivedChars, size)); } void OpenSpaceEngine::toggleShutdownMode() { - if (_isInShutdownMode) { - // If we are already in shutdown mode, we want to disable it instead + if (_shutdown.inShutdown) { + // If we are already in shutdown mode, we want to disable it LINFO("Disabled shutdown mode"); - _isInShutdownMode = false; + _shutdown.inShutdown = false; } else { - // Else, we hav eto enable it + // Else, we have to enable it LINFO("Shutting down OpenSpace"); - _shutdownCountdown = _shutdownWait; - _isInShutdownMode = true; + _shutdown.timer = _shutdown.waitTime; + _shutdown.inShutdown = true; } } @@ -1209,14 +1172,6 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() { }; } -bool OpenSpaceEngine::useBusyWaitForDecode() { - return _settingsEngine->busyWaitForDecode(); -} - -bool OpenSpaceEngine::logSGCTOutOfOrderErrors() { - return _settingsEngine->logSGCTOutOfOrderErrors(); -} - void OpenSpaceEngine::enableBarrier() { _windowWrapper->setBarrier(true); } @@ -1225,6 +1180,85 @@ void OpenSpaceEngine::disableBarrier() { _windowWrapper->setBarrier(false); } +// Registers a callback for a specific CallbackOption +void OpenSpaceEngine::registerModuleCallback(OpenSpaceEngine::CallbackOption option, + std::function function) +{ + switch (option) { + case CallbackOption::Initialize: + _moduleCallbacks.initialize.push_back(std::move(function)); + break; + case CallbackOption::Deinitialize: + _moduleCallbacks.deinitialize.push_back(std::move(function)); + break; + case CallbackOption::InitializeGL: + _moduleCallbacks.initializeGL.push_back(std::move(function)); + break; + case CallbackOption::DeinitializeGL: + _moduleCallbacks.deinitializeGL.push_back(std::move(function)); + break; + case CallbackOption::PreSync: + _moduleCallbacks.preSync.push_back(std::move(function)); + break; + case CallbackOption::PostSyncPreDraw: + _moduleCallbacks.postSyncPreDraw.push_back(std::move(function)); + break; + case CallbackOption::Render: + _moduleCallbacks.render.push_back(std::move(function)); + break; + case CallbackOption::PostDraw: + _moduleCallbacks.postDraw.push_back(std::move(function)); + break; + default: + ghoul_assert(false, "Missing case label"); + } +} + +void OpenSpaceEngine::registerModuleKeyboardCallback( + std::function function) +{ + _moduleCallbacks.keyboard.push_back(std::move(function)); +} + +void OpenSpaceEngine::registerModuleCharCallback( + std::function function) +{ + _moduleCallbacks.character.push_back(std::move(function)); +} + +void OpenSpaceEngine::registerModuleMouseButtonCallback( + std::function function) +{ + _moduleCallbacks.mouseButton.push_back(std::move(function)); +} + +void OpenSpaceEngine::registerModuleMousePositionCallback( + std::function function) +{ + _moduleCallbacks.mousePosition.push_back(std::move(function)); +} + +void OpenSpaceEngine::registerModuleMouseScrollWheelCallback( + std::function function) +{ + _moduleCallbacks.mouseScrollWheel.push_back(std::move(function)); +} + +ConfigurationManager& OpenSpaceEngine::configurationManager() { + ghoul_assert(_configurationManager, "ConfigurationManager must not be nullptr"); + return *_configurationManager; +} + +LuaConsole& OpenSpaceEngine::console() { + ghoul_assert(_console, "LuaConsole must not be nullptr"); + return *_console; +} + +DownloadManager& OpenSpaceEngine::downloadManager() { + ghoul_assert(_downloadManager, "Download Manager must not be nullptr"); + return *_downloadManager; +} + NetworkEngine& OpenSpaceEngine::networkEngine() { ghoul_assert(_networkEngine, "NetworkEngine must not be nullptr"); return *_networkEngine; @@ -1235,9 +1269,34 @@ ModuleEngine& OpenSpaceEngine::moduleEngine() { return *_moduleEngine; } -ConfigurationManager& OpenSpaceEngine::configurationManager() { - ghoul_assert(_configurationManager, "ConfigurationManager must not be nullptr"); - return *_configurationManager; +ParallelConnection& OpenSpaceEngine::parallelConnection() { + ghoul_assert(_parallelConnection, "ParallelConnection must not be nullptr"); + return *_parallelConnection; +} + +RenderEngine& OpenSpaceEngine::renderEngine() { + ghoul_assert(_renderEngine, "RenderEngine must not be nullptr"); + return *_renderEngine; +} + +SettingsEngine& OpenSpaceEngine::settingsEngine() { + ghoul_assert(_settingsEngine, "Settings Engine must not be nullptr"); + return *_settingsEngine; +} + +TimeManager& OpenSpaceEngine::timeManager() { + ghoul_assert(_timeManager, "Download Manager must not be nullptr"); + return *_timeManager; +} + +WindowWrapper& OpenSpaceEngine::windowWrapper() { + ghoul_assert(_windowWrapper, "Window Wrapper must not be nullptr"); + return *_windowWrapper; +} + +ghoul::fontrendering::FontManager& OpenSpaceEngine::fontManager() { + ghoul_assert(_fontManager, "Font Manager must not be nullptr"); + return *_fontManager; } interaction::InteractionHandler& OpenSpaceEngine::interactionHandler() { @@ -1245,38 +1304,6 @@ interaction::InteractionHandler& OpenSpaceEngine::interactionHandler() { return *_interactionHandler; } -RenderEngine& OpenSpaceEngine::renderEngine() { - ghoul_assert(_renderEngine, "RenderEngine must not be nullptr"); - return *_renderEngine; -} - -ScriptEngine& OpenSpaceEngine::scriptEngine() { - ghoul_assert(_scriptEngine, "ScriptEngine must not be nullptr"); - return *_scriptEngine; -} - -ScriptScheduler& OpenSpaceEngine::scriptScheduler(){ - ghoul_assert(_scriptScheduler, "ScriptScheduler must not be nullptr"); - return *_scriptScheduler; -} - -LuaConsole& OpenSpaceEngine::console() { - ghoul_assert(_console, "LuaConsole must not be nullptr"); - return *_console; -} - -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED -gui::GUI& OpenSpaceEngine::gui() { - ghoul_assert(_gui, "GUI must not be nullptr"); - return *_gui; -} -#endif - -ParallelConnection& OpenSpaceEngine::parallelConnection() { - ghoul_assert(_parallelConnection, "ParallelConnection must not be nullptr"); - return *_parallelConnection; -} - properties::PropertyOwner& OpenSpaceEngine::globalPropertyOwner() { ghoul_assert( _globalPropertyNamespace, @@ -1285,25 +1312,14 @@ properties::PropertyOwner& OpenSpaceEngine::globalPropertyOwner() { return *_globalPropertyNamespace; } -WindowWrapper& OpenSpaceEngine::windowWrapper() { - ghoul_assert(_windowWrapper, "Window Wrapper must not be nullptr"); - return *_windowWrapper; -} - -ghoul::fontrendering::FontManager& OpenSpaceEngine::fontManager() { - ghoul_assert(_fontManager, "Font Manager must not be nullptr"); - return *_fontManager; +ScriptEngine& OpenSpaceEngine::scriptEngine() { + ghoul_assert(_scriptEngine, "ScriptEngine must not be nullptr"); + return *_scriptEngine; } -DownloadManager& OpenSpaceEngine::downloadManager() { - ghoul_assert(_downloadManager, "Download Manager must not be nullptr"); - return *_downloadManager; +ScriptScheduler& OpenSpaceEngine::scriptScheduler() { + ghoul_assert(_scriptScheduler, "ScriptScheduler must not be nullptr"); + return *_scriptScheduler; } -TimeManager& OpenSpaceEngine::timeManager() { - ghoul_assert(_timeManager, "Download Manager must not be nullptr"); - return *_timeManager; -} - - } // namespace openspace diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 3d4de94b78..b83b472aa0 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/engine/settingsengine.cpp b/src/engine/settingsengine.cpp index 81557134e0..a0596ea49b 100644 --- a/src/engine/settingsengine.cpp +++ b/src/engine/settingsengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -40,101 +40,73 @@ namespace { - const std::string _loggerCat = "SettingsEngine"; + const char* _loggerCat = "SettingsEngine"; } namespace openspace { SettingsEngine::SettingsEngine() - : _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f) + : properties::PropertyOwner("Global Properties") , _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::Dropdown) - , _showFrameNumber("showFrameNumber", "Show frame number", false) , _busyWaitForDecode("busyWaitForDecode", "Busy Wait for decode", false) , _logSGCTOutOfOrderErrors("logSGCTOutOfOrderErrors", "Log SGCT out-of-order", false) , _useDoubleBuffering("useDoubleBuffering", "Use double buffering", false) , _spiceUseExceptions("enableSpiceExceptions", "Enable Spice Exceptions", false) { - setName("Global Properties"); - - _spiceUseExceptions.onChange([this]{ + _spiceUseExceptions.onChange([this] { if (_spiceUseExceptions) { SpiceManager::ref().setExceptionHandling(SpiceManager::UseException::Yes); - } - else { + } else { SpiceManager::ref().setExceptionHandling(SpiceManager::UseException::No); } }); addProperty(_spiceUseExceptions); + addProperty(_busyWaitForDecode); + addProperty(_logSGCTOutOfOrderErrors); + addProperty(_useDoubleBuffering); + addProperty(_scenes); } void SettingsEngine::initialize() { - initEyeSeparation(); - initSceneFiles(); - initShowFrameNumber(); - initBusyWaitForDecode(); - initLogSGCTOutOfOrderErrors(); - initUseDoubleBuffering(); + // Load all matching files in the Scene + // TODO: match regex with either with new ghoul readFiles or local code + std::string sceneDir = "${SCENE}"; + std::vector scenes = ghoul::filesystem::Directory(sceneDir).readFiles(); + for (std::size_t i = 0; i < scenes.size(); ++i) { + std::size_t found = scenes[i].find_last_of("/\\"); + _scenes.addOption(i, scenes[i].substr(found + 1)); + } + + // Set interaction to change ConfigurationManager and schedule the load + _scenes.onChange( + [this]() { + std::string sceneFile = _scenes.getDescriptionByValue(_scenes); + OsEng.configurationManager().setValue( + ConfigurationManager::KeyConfigScene, sceneFile); + OsEng.loadScene(sceneFile); + } + ); } - -void SettingsEngine::setModules(std::vector modules) { + +void SettingsEngine::setModules(const std::vector& modules) { for (OpenSpaceModule* m : modules) { addPropertySubOwner(m); } } -void SettingsEngine::initEyeSeparation() { - addProperty(_eyeSeparation); - - // Set interaction to change the window's (SGCT's) eye separation - _eyeSeparation.onChange( - [this]() { OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); }); -} - -void SettingsEngine::initShowFrameNumber() { - addProperty(_showFrameNumber); - - _showFrameNumber.onChange( - [this]() { OsEng.renderEngine().setShowFrameNumber(_showFrameNumber.value()); } ); -} - -void SettingsEngine::initBusyWaitForDecode() { - addProperty(_busyWaitForDecode); - _busyWaitForDecode.onChange( - [this]() { - LINFO((_busyWaitForDecode.value() ? "Busy wait for decode" : "Async decode")); - }); -} - bool SettingsEngine::busyWaitForDecode() { return _busyWaitForDecode.value(); } -void SettingsEngine::initLogSGCTOutOfOrderErrors() { - addProperty(_logSGCTOutOfOrderErrors); - _logSGCTOutOfOrderErrors.onChange( - [this]() { - LINFO("Turn " << (_logSGCTOutOfOrderErrors.value() ? "on" : "off") << " SGCT out of order logging"); - }); -} - bool SettingsEngine::logSGCTOutOfOrderErrors() { return _logSGCTOutOfOrderErrors.value(); } - -void SettingsEngine::initUseDoubleBuffering() { - addProperty(_useDoubleBuffering); - _useDoubleBuffering.onChange( - [this]() { - LINFO("Turn " << (_useDoubleBuffering.value() ? "on" : "off") << " double buffering"); - }); -} - - bool SettingsEngine::useDoubleBuffering() { return _useDoubleBuffering.value(); } +/* void SettingsEngine::initSceneFiles() { addProperty(_scenes); @@ -151,15 +123,15 @@ void SettingsEngine::initSceneFiles() { // Set interaction to change ConfigurationManager and schedule the load _scenes.onChange( - [this, sceneDir, pathSep]() { + [sceneDir, pathSep]() { std::string sceneFile = _scenes.getDescriptionByValue(_scenes); OsEng.configurationManager().setValue( ConfigurationManager::KeyConfigScene, sceneFile); std::string fullPath = sceneDir + pathSep + sceneFile; - OsEng.scheduleLoadScene(fullPath); + OsEng.loadScene(sceneFile); } ); -} +}*/ -} +} // namespace openspace diff --git a/src/engine/syncengine.cpp b/src/engine/syncengine.cpp index c2add63f16..1690e0852d 100644 --- a/src/engine/syncengine.cpp +++ b/src/engine/syncengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -23,76 +23,73 @@ ****************************************************************************************/ #include + #include -#include -#include + +#include #include -#include - - -namespace { - const std::string _loggerCat = "SyncEngine"; -} - namespace openspace { - SyncEngine::SyncEngine(SyncBuffer* syncBuffer) - : _syncBuffer(syncBuffer) - { - - } - - void SyncEngine::presync(bool isMaster) { - for (const auto& syncable : _syncables) { - syncable->presync(isMaster); - } - } - - // should be called on sgct master - void SyncEngine::encodeSyncables() { - for (const auto& syncable : _syncables) { - syncable->encode(_syncBuffer.get()); - } - _syncBuffer->write(); - } - - //should be called on sgct slaves - void SyncEngine::decodeSyncables() { - _syncBuffer->read(); - for (const auto& syncable : _syncables) { - syncable->decode(_syncBuffer.get()); - } - } - - void SyncEngine::postsync(bool isMaster) { - for (const auto& syncable : _syncables) { - syncable->postsync(isMaster); - } - } - - void SyncEngine::addSyncable(Syncable* syncable) { - _syncables.push_back(syncable); - } - - void SyncEngine::addSyncables(const std::vector& syncables) { - for (const auto& syncable : syncables) { - addSyncable(syncable); - } - } - - void SyncEngine::removeSyncable(Syncable* syncable) { - _syncables.erase( - std::remove(_syncables.begin(), _syncables.end(), syncable), - _syncables.end() - ); - } - - void SyncEngine::removeSyncables(const std::vector& syncables) { - for (const auto& syncable : syncables) { - removeSyncable(syncable); - } - } - +SyncEngine::SyncEngine(unsigned int syncBufferSize) + : _syncBuffer(syncBufferSize) +{ + ghoul_assert(syncBufferSize > 0, "syncBufferSize must be bigger than 0"); } + +// should be called on sgct master +void SyncEngine::encodeSyncables() { + for (Syncable* syncable : _syncables) { + syncable->encode(&_syncBuffer); + } + _syncBuffer.write(); +} + +//should be called on sgct slaves +void SyncEngine::decodeSyncables() { + _syncBuffer.read(); + for (Syncable* syncable : _syncables) { + syncable->decode(&_syncBuffer); + } +} + +void SyncEngine::preSynchronization(IsMaster isMaster) { + for (Syncable* syncable : _syncables) { + syncable->presync(isMaster); + } +} + +void SyncEngine::postSynchronization(IsMaster isMaster) { + for (Syncable* syncable : _syncables) { + syncable->postsync(isMaster); + } +} + +void SyncEngine::addSyncable(Syncable* syncable) { + ghoul_assert(syncable, "synable must not be nullptr"); + + _syncables.push_back(syncable); +} + +void SyncEngine::addSyncables(const std::vector& syncables) { + for (Syncable* syncable : syncables) { + ghoul_assert(syncable, "syncables must not contain any nullptr"); + addSyncable(syncable); + } +} + +void SyncEngine::removeSyncable(Syncable* syncable) { + _syncables.erase( + std::remove(_syncables.begin(), _syncables.end(), syncable), + _syncables.end() + ); +} + +void SyncEngine::removeSyncables(const std::vector& syncables) { + for (const auto& syncable : syncables) { + removeSyncable(syncable); + } +} + +} // namespace openspace diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index d70db6044d..b9c9fbdd2e 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -31,10 +31,25 @@ #undef far namespace { - const std::string GuiWindowName = "GUI"; + const char* GuiWindowTag = "GUI"; } namespace openspace { + +SGCTWindowWrapper::SGCTWindowWrapper() + : _showStatsGraph("showStatsGraph", "Show Stats Graph", false) + , _eyeSeparation("eyeSeparation", "Eye Separation", 0.f, 0.f, 10.f) +{ + _showStatsGraph.onChange([this](){ + sgct::Engine::instance()->setStatsGraphVisibility(_showStatsGraph); + }); + addProperty(_showStatsGraph); + + addProperty(_eyeSeparation); + _eyeSeparation.onChange([this](){ + setEyeSeparationDistance(_eyeSeparation); + }); +} void SGCTWindowWrapper::terminate() { sgct::Engine::instance()->terminate(); @@ -110,9 +125,9 @@ glm::ivec2 SGCTWindowWrapper::currentWindowSize() const { } glm::ivec2 SGCTWindowWrapper::currentWindowResolution() const { - auto window = sgct::Engine::instance()->getCurrentWindowPtr(); int x, y; - sgct::Engine::instance()->getCurrentWindowPtr()->getFinalFBODimensions(x, y); + auto window = sgct::Engine::instance()->getCurrentWindowPtr(); + window->getFinalFBODimensions(x, y); return glm::ivec2(x, y); } @@ -153,14 +168,21 @@ bool SGCTWindowWrapper::isRegularRendering() const { bool SGCTWindowWrapper::hasGuiWindow() const { auto engine = sgct::Engine::instance(); for (size_t i = 0; i < engine->getNumberOfWindows(); ++i) { - if (engine->getWindowPtr(i)->getName() == GuiWindowName) + if (engine->getWindowPtr(i)->checkIfTagExists(GuiWindowTag)) { return true; + } } return false; } bool SGCTWindowWrapper::isGuiWindow() const { - return sgct::Engine::instance()->getCurrentWindowPtr()->getName() == GuiWindowName; + return sgct::Engine::instance()->getCurrentWindowPtr()->checkIfTagExists( + GuiWindowTag + ); +} + +bool SGCTWindowWrapper::isMaster() const { + return sgct::Engine::instance()->isMaster(); } bool SGCTWindowWrapper::isSwapGroupMaster() const { @@ -170,7 +192,6 @@ bool SGCTWindowWrapper::isSwapGroupMaster() const { bool SGCTWindowWrapper::isUsingSwapGroups() const { return sgct::Engine::instance()->getCurrentWindowPtr()->isUsingSwapGroups(); } - glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const { return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix(); diff --git a/src/engine/wrapper/windowwrapper.cpp b/src/engine/wrapper/windowwrapper.cpp index 436c34d87f..8f2164b16a 100644 --- a/src/engine/wrapper/windowwrapper.cpp +++ b/src/engine/wrapper/windowwrapper.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -52,6 +52,10 @@ WindowWrapper::WindowWrapperException::WindowWrapperException(const std::string& : ghoul::RuntimeError(msg, "WindowWrapper") {} +WindowWrapper::WindowWrapper() + : properties::PropertyOwner("WindowWrapper") +{} + scripting::LuaLibrary WindowWrapper::luaLibrary() { return { "cluster", @@ -129,6 +133,10 @@ bool WindowWrapper::isGuiWindow() const { return false; } +bool WindowWrapper::isMaster() const { + return false; +} + bool WindowWrapper::isSwapGroupMaster() const { return false; } diff --git a/src/interaction/controller.cpp b/src/interaction/controller.cpp index 0b46d4d82f..5e844f6a1d 100644 --- a/src/interaction/controller.cpp +++ b/src/interaction/controller.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/interaction/deviceidentifier.cpp b/src/interaction/deviceidentifier.cpp deleted file mode 100644 index 2da4ec2509..0000000000 --- a/src/interaction/deviceidentifier.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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. * - ****************************************************************************************/ - -// open space includes -#include - -#include - -namespace openspace { - - -DeviceIdentifier* DeviceIdentifier::this_ = nullptr; - -DeviceIdentifier::DeviceIdentifier() { - - // scan for devices on init - devices_ = 0; - for(int i = 0; i < MAXDEVICES; ++i) { - inputDevice_[i] = InputDevice::NONE; - } -} - -DeviceIdentifier::~DeviceIdentifier() { - - // deallocates memory on exit - for(int i = 0; i < MAXDEVICES; ++i) { - if(inputDevice_[i] != InputDevice::NONE) { - delete axesPos_[i]; - delete buttons_[i]; - } - } -} - -void DeviceIdentifier::init() { - assert( ! this_); - this_ = new DeviceIdentifier(); -} - -void DeviceIdentifier::deinit() { - assert(this_); - delete this_; - this_ = nullptr; -} - -DeviceIdentifier& DeviceIdentifier::ref() { - assert(this_); - return *this_; -} - -bool DeviceIdentifier::isInitialized() { - return this_ != nullptr; -} - -void DeviceIdentifier::scanDevices() { - assert(this_); - - // sgct/glfw supports 16 joysticks, scans all of them - for (int i = 0; i < MAXDEVICES; ++i) - { - void* joystickName = NULL; - if( joystickName != NULL ) { - - // allocate - axesPos_[i] = new float[numberOfAxes_[i]]; - buttons_[i] = new unsigned char[numberOfButtons_[i]]; - - // increment the device count - ++devices_; - - // identify what device it is - if(numberOfAxes_[i] == 6 && numberOfButtons_[i] == 10) { - printf("XBOX controller "); - inputDevice_[i] = InputDevice::XBOX; - } else if(numberOfAxes_[i] == 6 && numberOfButtons_[i] == 4) { - printf("SPACENAVIGATOR "); - inputDevice_[i] = InputDevice::SPACENAVIGATOR; - } else { - printf("UNKNOWN device "); - inputDevice_[i] = InputDevice::UNKNOWN; - } - printf("found at position %i, b=%i, a=%i\n", i, numberOfButtons_[i], numberOfAxes_[i]); - - - } else { - inputDevice_[i] = InputDevice::NONE; - } - - } -} - -const int DeviceIdentifier::numberOfDevices() const { - assert(this_); - return devices_; -} - -const InputDevice DeviceIdentifier::type(const int device) const { - assert(this_); - return inputDevice_[device]; -} - -void DeviceIdentifier::update() { - assert(this_); - for(int i = 0; i < devices_; ++i) { - update(i); - } -} - -void DeviceIdentifier::update(const int device) { - assert(this_); - if(inputDevice_[device] != InputDevice::NONE) { - } -} - -const int DeviceIdentifier::getButtons(const int device, unsigned char **buttons) const { - assert(this_); - if(inputDevice_[device] != InputDevice::NONE) { - if(buttons) - *buttons = buttons_[device]; - return numberOfButtons_[device]; - } - return 0; -} - -const int DeviceIdentifier::getAxes(const int device, float **axespos) const { - assert(this_); - if(inputDevice_[device] != InputDevice::NONE) { - if(axespos) - *axespos = axesPos_[device]; - return numberOfAxes_[device]; - } - return 0; -} - -void DeviceIdentifier::get(const int device, unsigned char **buttons, float **axespos) const { - assert(this_); - if(inputDevice_[device] != InputDevice::NONE) { - *axespos = axesPos_[device]; - *buttons = buttons_[device]; - } -} - -} // namespace openspace diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index b37e5040c2..7c4a9f8b77 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -50,19 +51,19 @@ #include namespace { - const std::string _loggerCat = "InteractionHandler"; + const char* _loggerCat = "InteractionHandler"; - const std::string KeyFocus = "Focus"; - const std::string KeyPosition = "Position"; - const std::string KeyRotation = "Rotation"; + const char* KeyFocus = "Focus"; + const char* KeyPosition = "Position"; + const char* KeyRotation = "Rotation"; - const std::string MainTemplateFilename = "${OPENSPACE_DATA}/web/keybindings/main.hbs"; - const std::string KeybindingTemplateFilename = "${OPENSPACE_DATA}/web/keybindings/keybinding.hbs"; - const std::string HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; - const std::string JsFilename = "${OPENSPACE_DATA}/web/keybindings/script.js"; - const std::string BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; - const std::string CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; -} + const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/keybindings/main.hbs"; + const char* KeybindingTemplateFilename = "${OPENSPACE_DATA}/web/keybindings/keybinding.hbs"; + const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; + const char* JsFilename = "${OPENSPACE_DATA}/web/keybindings/script.js"; + const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; + const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; +} // namespace #include "interactionhandler_lua.inl" @@ -71,15 +72,14 @@ namespace interaction { // InteractionHandler InteractionHandler::InteractionHandler() - : _origin("origin", "Origin", "") + : properties::PropertyOwner("Interaction") + , _origin("origin", "Origin", "") , _rotationalFriction("rotationalFriction", "Rotational Friction", true) , _horizontalFriction("horizontalFriction", "Horizontal Friction", true) , _verticalFriction("verticalFriction", "Vertical Friction", true) , _sensitivity("sensitivity", "Sensitivity", 0.5, 0.001, 1) , _rapidness("rapidness", "Rapidness", 1, 0.1, 60) { - setName("Interaction"); - _origin.onChange([this]() { SceneGraphNode* node = sceneGraphNode(_origin.value()); if (!node) { diff --git a/src/interaction/interactionhandler_lua.inl b/src/interaction/interactionhandler_lua.inl index b810761ecb..50e99139e0 100644 --- a/src/interaction/interactionhandler_lua.inl +++ b/src/interaction/interactionhandler_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/interaction/interactionmode.cpp b/src/interaction/interactionmode.cpp index 70274c1876..a04d6303de 100644 --- a/src/interaction/interactionmode.cpp +++ b/src/interaction/interactionmode.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/src/interaction/keyboardcontroller.cpp b/src/interaction/keyboardcontroller.cpp deleted file mode 100644 index 0a5d69bc76..0000000000 --- a/src/interaction/keyboardcontroller.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 - -namespace { - const std::string _loggerCat = "KeyboardController"; -} - -namespace openspace { -namespace interaction { - -void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier modifier) { - // TODO package in script - /* - const float dt = static_cast( _handler->deltaTime()); - if(action == KeyAction::Press|| action == KeyAction::Repeat) { - const float speed = 2.75; - if (key == Key::S) { - glm::vec3 euler(speed * dt, 0.0, 0.0); - glm::quat rot = glm::quat(euler); - _handler->orbitDelta(rot); - } - if (key == Key::W) { - glm::vec3 euler(-speed * dt, 0.0, 0.0); - glm::quat rot = glm::quat(euler); - _handler->orbitDelta(rot); - } - if (key == Key::A) { - glm::vec3 euler(0.0, -speed * dt, 0.0); - glm::quat rot = glm::quat(euler); - _handler->orbitDelta(rot); - } - if (key == Key::D) { - glm::vec3 euler(0.0, speed * dt, 0.0); - glm::quat rot = glm::quat(euler); - _handler->orbitDelta(rot); - } - if (key == Key::Q) { - Time::ref().advanceTime(dt); - } - if (key == Key::Right) { - glm::vec3 euler(0.0, speed * dt, 0.0); - glm::quat rot = glm::quat(euler); - _handler->rotateDelta(rot); - } - if (key == Key::Left) { - glm::vec3 euler(0.0, -speed * dt, 0.0); - glm::quat rot = glm::quat(euler); - _handler->rotateDelta(rot); - } - if (key == Key::Down) { - glm::vec3 euler(speed * dt, 0.0, 0.0); - glm::quat rot = glm::quat(euler); - _handler->rotateDelta(rot); - } - if (key == Key::Up) { - glm::vec3 euler(-speed * dt, 0.0, 0.0); - glm::quat rot = glm::quat(euler); - _handler->rotateDelta(rot); - } - if (key == Key::R) { - PowerScaledScalar dist(-speed * dt, 0.0); - _handler->distanceDelta(dist); - } - if (key == Key::F) { - PowerScaledScalar dist(speed * dt, 0.0); - _handler->distanceDelta(dist); - } - if (key == Key::T) { - PowerScaledScalar dist(-speed * pow(10.0f, 11.0f) * dt, 0.0f); - _handler->distanceDelta(dist); - } - //if (key == Keys::G) { - // acc += 0.001; - // PowerScaledScalar dist(speed * pow(10, 8 * acc) * dt, 0.0); - // distanceDelta(dist); - //} - if (key == Key::Y) { - PowerScaledScalar dist(-speed * 100.0f * dt, 6.0f); - _handler->distanceDelta(dist); - } - if (key == Key::H) { - PowerScaledScalar dist(speed * 100.0f * dt, 6.0f); - _handler->distanceDelta(dist); - } - - if (key == Key::KeypadSubtract) { - glm::vec2 s = OsEng.renderEngine().camera()->scaling(); - s[1] -= 0.5; - OsEng.renderEngine().camera()->setScaling(s); - } - if (key == Key::KeypadAdd) { - glm::vec2 s = OsEng.renderEngine().camera()->scaling(); - s[1] += 0.5; - OsEng.renderEngine().camera()->setScaling(s); - } - } - */ - /* - if (key == '1') { - SceneGraphNode* node = getSceneGraphNode("sun"); - - setFocusNode(node); - getCamera()->setPosition(node->getWorldPosition() + psc(0.0, 0.0, 0.5, 10.0)); - getCamera()->setCameraDirection(glm::vec3(0.0, 0.0, -1.0)); - } - - if (key == '2') { - SceneGraphNode* node = getSceneGraphNode("earth"); - - setFocusNode(node); - getCamera()->setPosition(node->getWorldPosition() + psc(0.0, 0.0, 1.0, 8.0)); - getCamera()->setCameraDirection(glm::vec3(0.0, 0.0, -1.0)); - } - - - if (key == '3') { - SceneGraphNode* node = getSceneGraphNode("moon"); - - setFocusNode(node); - getCamera()->setPosition(node->getWorldPosition() + psc(0.0, 0.0, 0.5, 8.0)); - getCamera()->setCameraDirection(glm::vec3(0.0, 0.0, -1.0)); - } - */ -} - -void KeyboardControllerLua::keyPressed(KeyAction action, Key key, KeyModifier modifier) { - lua_State* s = luaL_newstate(); - luaL_openlibs(s); - - int status = luaL_loadfile(s, absPath("${SCRIPTS}/default_keybinding.lua").c_str()); - if (status != LUA_OK) { - LERROR("Error loading script: '" << lua_tostring(s, -1) << "'"); - return; - } - - if (lua_pcall(s, 0, LUA_MULTRET, 0)) { - LERROR("Error executing script: " << lua_tostring(s, -1)); - return; - } - - auto start = std::chrono::high_resolution_clock::now(); - - lua_getfield(s, -1, keyToString(key, modifier).c_str()); - if (!lua_isnil(s, -1)) - lua_pcall(s, 0, 0, 0); - else - LINFO("Key not found"); - - auto end = std::chrono::high_resolution_clock::now(); - LINFO("Keyboard timing: " << std::chrono::duration_cast(end - start).count() << "ns"); - - -} - -std::string KeyboardControllerLua::keyToString(Key key, KeyModifier mod) const { - std::string result = ""; - int intMod = static_cast(mod); - if (intMod & static_cast(KeyModifier::Control)) - result += "CTRL + "; - if (intMod & static_cast(KeyModifier::Super)) - result += "SUPER + "; - if (intMod & static_cast(KeyModifier::Alt)) - result += "ALT + "; - if (intMod & static_cast(KeyModifier::Shift)) - result += "SHIFT + "; - - switch (key) { - case Key::Unknown: result += "Unknown"; break; - case Key::Space: result += "Space"; break; - case Key::Apostrophe: result += "Apostrophe"; break; - case Key::Comma: result += "Comma"; break; - case Key::Minus: result += "Minus"; break; - case Key::Period: result += "Period"; break; - case Key::Slash: result += "Slash"; break; - case Key::Num0: result += "0"; break; - case Key::Num1: result += "1"; break; - case Key::Num2: result += "2"; break; - case Key::Num3: result += "3"; break; - case Key::Num4: result += "4"; break; - case Key::Num5: result += "5"; break; - case Key::Num6: result += "6"; break; - case Key::Num7: result += "7"; break; - case Key::Num8: result += "8"; break; - case Key::Num9: result += "9"; break; - case Key::SemiColon: result += "SemiColon"; break; - case Key::Equal: result += "Equal"; break; - case Key::A: result += "A"; break; - case Key::B: result += "B"; break; - case Key::C: result += "C"; break; - case Key::D: result += "D"; break; - case Key::E: result += "E"; break; - case Key::F: result += "F"; break; - case Key::G: result += "G"; break; - case Key::H: result += "H"; break; - case Key::I: result += "I"; break; - case Key::J: result += "J"; break; - case Key::K: result += "K"; break; - case Key::L: result += "L"; break; - case Key::M: result += "M"; break; - case Key::N: result += "N"; break; - case Key::O: result += "O"; break; - case Key::P: result += "P"; break; - case Key::Q: result += "Q"; break; - case Key::R: result += "R"; break; - case Key::S: result += "S"; break; - case Key::T: result += "T"; break; - case Key::U: result += "U"; break; - case Key::V: result += "V"; break; - case Key::W: result += "W"; break; - case Key::X: result += "X"; break; - case Key::Y: result += "Y"; break; - case Key::Z: result += "Z"; break; - case Key::LeftBracket: result += "LeftBracket"; break; - case Key::BackSlash: result += "BackSlash"; break; - case Key::RightBracket: result += "RightBracket"; break; - case Key::GraveAccent: result += "GraveAccent"; break; - case Key::World1: result += "World1"; break; - case Key::World2: result += "World2"; break; - case Key::Escape: result += "Escape"; break; - case Key::Enter: result += "Enter"; break; - case Key::Tab: result += "Tab"; break; - case Key::BackSpace: result += "BackSpace"; break; - case Key::Insert: result += "Insert"; break; - case Key::Delete: result += "Delete"; break; - case Key::Right: result += "Right"; break; - case Key::Left: result += "Left"; break; - case Key::Down: result += "Down"; break; - case Key::Up: result += "Up"; break; - case Key::PageUp: result += "PageUp"; break; - case Key::PageDown: result += "PageDown"; break; - case Key::Home: result += "Home"; break; - case Key::End: result += "End"; break; - case Key::CapsLock: result += "CapsLock"; break; - case Key::ScrollLock: result += "ScrollLock"; break; - case Key::NumLock: result += "NumLock"; break; - case Key::PrintScreen: result += "PrintScreen"; break; - case Key::Pause: result += "Pause"; break; - case Key::F1: result += "F1"; break; - case Key::F2: result += "F2"; break; - case Key::F3: result += "F3"; break; - case Key::F4: result += "F4"; break; - case Key::F5: result += "F5"; break; - case Key::F6: result += "F6"; break; - case Key::F7: result += "F7"; break; - case Key::F8: result += "F8"; break; - case Key::F9: result += "F9"; break; - case Key::F10: result += "F10"; break; - case Key::F11: result += "F11"; break; - case Key::F12: result += "F12"; break; - case Key::F13: result += "F13"; break; - case Key::F14: result += "F14"; break; - case Key::F15: result += "F15"; break; - case Key::F16: result += "F16"; break; - case Key::F17: result += "F17"; break; - case Key::F18: result += "F18"; break; - case Key::F19: result += "F19"; break; - case Key::F20: result += "F20"; break; - case Key::F21: result += "F21"; break; - case Key::F22: result += "F22"; break; - case Key::F23: result += "F23"; break; - case Key::F24: result += "F24"; break; - case Key::F25: result += "F25"; break; - case Key::Keypad0: result += "Keypad0"; break; - case Key::Keypad1: result += "Keypad1"; break; - case Key::Keypad2: result += "Keypad2"; break; - case Key::Keypad3: result += "Keypad3"; break; - case Key::Keypad4: result += "Keypad4"; break; - case Key::Keypad5: result += "Keypad5"; break; - case Key::Keypad6: result += "Keypad6"; break; - case Key::Keypad7: result += "Keypad7"; break; - case Key::Keypad8: result += "Keypad8"; break; - case Key::Keypad9: result += "Keypad9"; break; - case Key::KeypadDecimal: result += "KeypadDecimal"; break; - case Key::KeypadDivide: result += "KeypadDivide"; break; - case Key::KeypadMultiply: result += "KeypadMultiply"; break; - case Key::KeypadSubtract: result += "KeypadSubtract"; break; - case Key::KeypadAdd: result += "KeypadAdd"; break; - case Key::KeypadEnter: result += "KeypadEnter"; break; - case Key::LeftShift: result += "LeftShift"; break; - case Key::LeftControl: result += "LeftControl"; break; - case Key::LeftAlt: result += "LeftAlt"; break; - case Key::LeftSuper: result += "LeftSuper"; break; - case Key::RightShift: result += "RightShift"; break; - case Key::RightControl: result += "RightControl"; break; - case Key::RightAlt: result += "RightAlt"; break; - case Key::RightSuper: result += "RightSuper"; break; - case Key::Menu: result += "Menu"; break; - default: - assert(false); - } - return result; -} - -} // namespace interaction -} // namespace openspace \ No newline at end of file diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 2a5b8847b3..ec77923ce7 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,280 +24,350 @@ #include -#include #include -#include -#include #include -#include -#include -#include +#include #include #include #include +#include +#include -#include -#include -#include #include +#include namespace { - const std::string _loggerCat = "LuaConsole"; - const std::string historyFile = "ConsoleHistory"; + const char* HistoryFile = "ConsoleHistory"; const int NoAutoComplete = -1; -} -#include "luaconsole_lua.inl" + const openspace::Key CommandInputButton = openspace::Key::GraveAccent; +} // namespace namespace openspace { -LuaConsole::LuaConsole() - : _inputPosition(0) - , _activeCommand(0) - , _filename("") - , _autoCompleteInfo({NoAutoComplete, false, ""}) - , _isVisible(false) +LuaConsole::LuaConsole() + : properties::PropertyOwner("LuaConsole") + , _isVisible("isVisible", "Is Visible", false) , _remoteScripting(true) + , _inputPosition(0) + , _activeCommand(0) + , _autoCompleteInfo({NoAutoComplete, false, ""}) { -// _commands.push_back(""); -// _activeCommand = _commands.size() - 1; + _isVisible.onChange([this](){ + if (_isVisible) { + _remoteScripting = false; + } else { + _remoteScripting = OsEng.parallelConnection().isHost(); + } + }); + addProperty(_isVisible); } void LuaConsole::initialize() { - _filename = FileSys.cacheManager()->cachedFilename( - historyFile, + std::string filename = FileSys.cacheManager()->cachedFilename( + HistoryFile, "", ghoul::filesystem::CacheManager::Persistent::Yes ); - std::ifstream file(_filename, std::ios::binary | std::ios::in); - if (file.good()) { - int64_t nCommands; - file.read(reinterpret_cast(&nCommands), sizeof(int64_t)); + std::ifstream file; + file.exceptions(~std::ofstream::goodbit); + file.open(filename, std::ios::binary | std::ios::in); - std::vector tmp; - for (int64_t i = 0; i < nCommands; ++i) { - int64_t length; - file.read(reinterpret_cast(&length), sizeof(int64_t)); - tmp.resize(length + 1); - file.read(tmp.data(), length); - tmp[length] = '\0'; - _commandsHistory.emplace_back(std::string(tmp.begin(), tmp.end())); - } - file.close(); - _commands = _commandsHistory; + // Read the number of commands from the history + int64_t nCommands; + file.read(reinterpret_cast(&nCommands), sizeof(int64_t)); + + for (int64_t i = 0; i < nCommands; ++i) { + int64_t length; + file.read(reinterpret_cast(&length), sizeof(int64_t)); + + std::vector tmp(length + 1); + file.read(tmp.data(), length); + tmp[length] = '\0'; + _commandsHistory.emplace_back(std::string(tmp.begin(), tmp.end())); } + + file.close(); + + _commands = _commandsHistory; _commands.push_back(""); _activeCommand = _commands.size() - 1; - OsEng.parallelConnection().connectionEvent()->subscribe("luaConsole", - "statusChanged", [this]() { - ParallelConnection::Status status = OsEng.parallelConnection().status(); - parallelConnectionChanged(status); - }); - + OsEng.parallelConnection().connectionEvent()->subscribe( + "luaConsole", + "statusChanged", + [this]() { + ParallelConnection::Status status = OsEng.parallelConnection().status(); + parallelConnectionChanged(status); + } + ); } void LuaConsole::deinitialize() { - std::ofstream file(_filename, std::ios::binary | std::ios::out); - if (file.good()) { - int64_t nCommands = _commandsHistory.size(); - file.write(reinterpret_cast(&nCommands), sizeof(int64_t)); - for (const std::string& s : _commandsHistory) { - int64_t length = s.length(); - file.write(reinterpret_cast(&length), sizeof(int64_t)); - file.write(s.c_str(), length); - } + std::string filename = FileSys.cacheManager()->cachedFilename( + HistoryFile, + "", + ghoul::filesystem::CacheManager::Persistent::Yes + ); + + std::ofstream file; + file.exceptions(~std::ofstream::goodbit); + file.open(filename, std::ios::binary | std::ios::in); + + int64_t nCommands = _commandsHistory.size(); + file.write(reinterpret_cast(&nCommands), sizeof(int64_t)); + + for (const std::string& s : _commandsHistory) { + int64_t length = s.length(); + file.write(reinterpret_cast(&length), sizeof(int64_t)); + // We don't write the \0 at the end on purpose + file.write(s.c_str(), length); } OsEng.parallelConnection().connectionEvent()->unsubscribe("luaConsole"); } -void LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction action) { - if (action == KeyAction::Press || action == KeyAction::Repeat) { - const bool modifierControl = (modifier == KeyModifier::Control); - const bool modifierShift = (modifier == KeyModifier::Shift); +bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction action) { + if (action != KeyAction::Press && action != KeyAction::Repeat) { + return false; + } - // Paste from clipboard - if (modifierControl && (key == Key::V)) - addToCommand(ghoul::clipboardText()); + if (key == CommandInputButton) { + // Button left of 1 and above TAB + // How to deal with different keyboard languages? ---abock + _isVisible = !_isVisible; + return true; + } - // Copy to clipboard - if (modifierControl && (key == Key::C)) - ghoul::setClipboardText(_commands.at(_activeCommand)); + if (!_isVisible) { + return false; + } - // Go to the previous character - if ((key == Key::Left) && (_inputPosition > 0)) + const bool modifierControl = (modifier == KeyModifier::Control); + const bool modifierShift = (modifier == KeyModifier::Shift); + + // Paste from clipboard + if (modifierControl && (key == Key::V)) { + addToCommand(ghoul::clipboardText()); + return true; + } + + // Copy to clipboard + if (modifierControl && (key == Key::C)) { + ghoul::setClipboardText(_commands.at(_activeCommand)); + return true; + } + + // Go to the previous character + if ((key == Key::Left) && (_inputPosition > 0)) { + --_inputPosition; + return true; + } + + // Go to the next character + if (key == Key::Right) { + //&& _inputPosition < _commands.at(_activeCommand).length()) + //++_inputPosition; + _inputPosition = std::min( + _inputPosition + 1, + _commands.at(_activeCommand).length() + ); + return true; + } + + // Go to previous command + if (key == Key::Up) { + if (_activeCommand > 0) { + --_activeCommand; + } + _inputPosition = _commands.at(_activeCommand).length(); + return true; + } + + // Go to next command (the last is empty) + if (key == Key::Down) { + if (_activeCommand < _commands.size() - 1) { + ++_activeCommand; + } + _inputPosition = _commands.at(_activeCommand).length(); + return true; + } + + // Remove character before _inputPosition + if (key == Key::BackSpace) { + if (_inputPosition > 0) { + _commands.at(_activeCommand).erase(_inputPosition - 1, 1); --_inputPosition; - - // Go to the next character - if ((key == Key::Right) && _inputPosition < _commands.at(_activeCommand).length()) - ++_inputPosition; - - // Go to previous command - if (key == Key::Up) { - if (_activeCommand > 0) - --_activeCommand; - _inputPosition = _commands.at(_activeCommand).length(); } + return true; + } - // Go to next command (the last is empty) - if (key == Key::Down) { - if (_activeCommand < _commands.size() - 1) - ++_activeCommand; - _inputPosition = _commands.at(_activeCommand).length(); - } - - // Remove character before _inputPosition - if (key == Key::BackSpace) { - if (_inputPosition > 0) { - _commands.at(_activeCommand).erase(_inputPosition - 1, 1); - --_inputPosition; - } - } - - // Remove character after _inputPosition - if (key == Key::Delete) { - if (_inputPosition <= _commands.at(_activeCommand).size()) - _commands.at(_activeCommand).erase(_inputPosition, 1); + // Remove character after _inputPosition + if (key == Key::Delete) { + if (_inputPosition <= _commands.at(_activeCommand).size()) { + _commands.at(_activeCommand).erase(_inputPosition, 1); } + return true; + } - // Go to the beginning of command string - if (key == Key::Home) - _inputPosition = 0; + // Go to the beginning of command string + if (key == Key::Home) { + _inputPosition = 0; + return true; + } - // Go to the end of command string - if (key == Key::End) - _inputPosition = _commands.at(_activeCommand).size(); + // Go to the end of command string + if (key == Key::End) { + _inputPosition = _commands.at(_activeCommand).size(); + return true; + } - if (key == Key::Enter) { - // SHIFT+ENTER == new line - if (modifierShift) - addToCommand("\n"); - // ENTER == run lua script - else { - std::string cmd = _commands.at(_activeCommand); - if (cmd != "") { - OsEng.scriptEngine().queueScript(cmd, - _remoteScripting ? scripting::ScriptEngine::RemoteScripting::Yes : scripting::ScriptEngine::RemoteScripting::No); + if (key == Key::Enter) { + // SHIFT+ENTER == new line + if (modifierShift) { + addToCommand("\n"); + } + // ENTER == run lua script + else { + std::string cmd = _commands.at(_activeCommand); + if (cmd != "") { + using RemoteScripting = scripting::ScriptEngine::RemoteScripting; + OsEng.scriptEngine().queueScript( + cmd, + _remoteScripting ? RemoteScripting::Yes : RemoteScripting::No + ); - // Only add the current command to the history if it hasn't been - // executed before. We don't want two of the same commands in a row - if (_commandsHistory.empty() || (cmd != _commandsHistory.back())) - _commandsHistory.push_back(_commands.at(_activeCommand)); + // Only add the current command to the history if it hasn't been + // executed before. We don't want two of the same commands in a row + if (_commandsHistory.empty() || (cmd != _commandsHistory.back())) { + _commandsHistory.push_back(_commands.at(_activeCommand)); } - - // Some clean up after the execution of the command - _commands = _commandsHistory; - _commands.push_back(""); - _activeCommand = _commands.size() - 1; - _inputPosition = 0; - setVisible(false); } + + // Some clean up after the execution of the command + _commands = _commandsHistory; + _commands.push_back(""); + _activeCommand = _commands.size() - 1; + _inputPosition = 0; + _isVisible = false; + } + return true; + } + + if (key == Key::Tab) { + // We get a list of all the available commands and initially find the first + // command that starts with how much we typed sofar. We store the index so + // that in subsequent "tab" presses, we will discard previous commands. This + // implements the 'hop-over' behavior. As soon as another key is pressed, + // everything is set back to normal + + // If the shift key is pressed, we decrement the current index so that we will + // find the value before the one that was previously found + if (_autoCompleteInfo.lastIndex != NoAutoComplete && modifierShift) { + _autoCompleteInfo.lastIndex -= 2; + } + std::vector allCommands = OsEng.scriptEngine().allLuaFunctions(); + std::sort(allCommands.begin(), allCommands.end()); + + std::string currentCommand = _commands.at(_activeCommand); + + // Check if it is the first time the tab has been pressed. If so, we need to + // store the already entered command so that we can later start the search + // from there. We will overwrite the 'currentCommand' thus making the storage + // necessary + if (!_autoCompleteInfo.hasInitialValue) { + _autoCompleteInfo.initialValue = currentCommand; + _autoCompleteInfo.hasInitialValue = true; } - if (key == Key::Tab) { - // We get a list of all the available commands and initially find the first - // command that starts with how much we typed sofar. We store the index so - // that in subsequent "tab" presses, we will discard previous commands. This - // implements the 'hop-over' behavior. As soon as another key is pressed, - // everything is set back to normal + for (int i = 0; i < static_cast(allCommands.size()); ++i) { + const std::string& command = allCommands[i]; - // If the shift key is pressed, we decrement the current index so that we will - // find the value before the one that was previously found - if (_autoCompleteInfo.lastIndex != NoAutoComplete && modifierShift) - _autoCompleteInfo.lastIndex -= 2; - std::vector allCommands = OsEng.scriptEngine().allLuaFunctions(); - std::sort(allCommands.begin(), allCommands.end()); + // Check if the command has enough length (we don't want crashes here) + // Then check if the iterator-command's start is equal to what we want + // then check if we need to skip the first found values as the user has + // pressed TAB repeatedly + size_t fullLength = _autoCompleteInfo.initialValue.length(); + bool correctLength = command.length() >= fullLength; - std::string currentCommand = _commands.at(_activeCommand); - - // Check if it is the first time the tab has been pressed. If so, we need to - // store the already entered command so that we can later start the search - // from there. We will overwrite the 'currentCommand' thus making the storage - // necessary - if (!_autoCompleteInfo.hasInitialValue) { - _autoCompleteInfo.initialValue = currentCommand; - _autoCompleteInfo.hasInitialValue = true; - } - - for (int i = 0; i < static_cast(allCommands.size()); ++i) { - const std::string& command = allCommands[i]; - - // Check if the command has enough length (we don't want crashes here) - // Then check if the iterator-command's start is equal to what we want - // then check if we need to skip the first found values as the user has - // pressed TAB repeatedly - size_t fullLength = _autoCompleteInfo.initialValue.length(); - bool correctLength = command.length() >= fullLength; - - std::string commandLowerCase; - std::transform( - command.begin(), command.end(), - std::back_inserter(commandLowerCase), - ::tolower - ); + std::string commandLowerCase; + std::transform( + command.begin(), command.end(), + std::back_inserter(commandLowerCase), + ::tolower + ); - std::string initialValueLowerCase; - std::transform( - _autoCompleteInfo.initialValue.begin(), - _autoCompleteInfo.initialValue.end(), - std::back_inserter(initialValueLowerCase), - ::tolower - ); + std::string initialValueLowerCase; + std::transform( + _autoCompleteInfo.initialValue.begin(), + _autoCompleteInfo.initialValue.end(), + std::back_inserter(initialValueLowerCase), + ::tolower + ); - bool correctCommand = - commandLowerCase.substr(0, fullLength) == initialValueLowerCase; + bool correctCommand = + commandLowerCase.substr(0, fullLength) == initialValueLowerCase; - if (correctLength && correctCommand && (i > _autoCompleteInfo.lastIndex)){ - // We found our index, so store it - _autoCompleteInfo.lastIndex = i; + if (correctLength && correctCommand && (i > _autoCompleteInfo.lastIndex)){ + // We found our index, so store it + _autoCompleteInfo.lastIndex = i; - // We only want to auto-complete until the next separator "." - size_t pos = command.find('.', fullLength); - if (pos == std::string::npos) { - // If we don't find a separator, we autocomplete until the end - // Set the found command as active command - _commands.at(_activeCommand) = command + "();"; - // Set the cursor position to be between the brackets - _inputPosition = _commands.at(_activeCommand).size() - 2; + // We only want to auto-complete until the next separator "." + size_t pos = command.find('.', fullLength); + if (pos == std::string::npos) { + // If we don't find a separator, we autocomplete until the end + // Set the found command as active command + _commands.at(_activeCommand) = command + "();"; + // Set the cursor position to be between the brackets + _inputPosition = _commands.at(_activeCommand).size() - 2; + } + else { + // If we find a separator, we autocomplete until and including the + // separator unless the autocompletion would be the same that we + // already have (the case if there are multiple commands in the + // same group + std::string subCommand = command.substr(0, pos + 1); + if (subCommand == _commands.at(_activeCommand)) { + continue; } else { - // If we find a separator, we autocomplete until and including the - // separator unless the autocompletion would be the same that we - // already have (the case if there are multiple commands in the - // same group - std::string subCommand = command.substr(0, pos + 1); - if (subCommand == _commands.at(_activeCommand)) - continue; - else { - _commands.at(_activeCommand) = command.substr(0, pos + 1); - _inputPosition = _commands.at(_activeCommand).length(); - // We only want to remove the autocomplete info if we just - // entered the 'default' openspace namespace - if (command.substr(0, pos + 1) == "openspace.") - _autoCompleteInfo = { NoAutoComplete, false, "" }; + _commands.at(_activeCommand) = command.substr(0, pos + 1); + _inputPosition = _commands.at(_activeCommand).length(); + // We only want to remove the autocomplete info if we just + // entered the 'default' openspace namespace + if (command.substr(0, pos + 1) == "openspace.") { + _autoCompleteInfo = { NoAutoComplete, false, "" }; } } - - break; } + + break; } } - else { - // If any other key is pressed, we want to remove our previous findings - // The special case for Shift is necessary as we want to allow Shift+TAB - if (!modifierShift) - _autoCompleteInfo = { NoAutoComplete, false, ""}; + return true; + } + else { + // If any other key is pressed, we want to remove our previous findings + // The special case for Shift is necessary as we want to allow Shift+TAB + if (!modifierShift) { + _autoCompleteInfo = { NoAutoComplete, false, "" }; } } + + return true; } void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) { - if (codepoint == static_cast(commandInputButton())) + if (!_isVisible) { return; + } + + if (codepoint == static_cast(CommandInputButton)) { + return; + } #ifndef WIN32 const bool modifierControl = (modifier == KeyModifier::Control); @@ -308,50 +378,84 @@ void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) { return; } #endif - addToCommand(UnicodeToUTF8(codepoint)); + // Disallow all non ASCII characters for now + if (codepoint > 0x7f) { + return; + } + + addToCommand(std::string(1, codepoint)); } void LuaConsole::render() { - const float font_size = 10.0f; - - int ySize = OsEng.renderEngine().fontResolution().y; - //int ySize = OsEng.windowWrapper().currentWindowSize().y; - //int ySize = OsEng.windowWrapper().viewportPixelCoordinates().w; + const float FontSize = 10.0f; - float startY = static_cast(ySize) - 2.0f * font_size; - startY = startY - font_size * 15.0f * 2.0f; + if (!_isVisible) { + return; + } + + const int ySize = OsEng.renderEngine().fontResolution().y; + + const float startY = + static_cast(ySize) - 2.0f * FontSize - FontSize * 15.0f * 2.0f;; const glm::vec4 red(1, 0, 0, 1); const glm::vec4 lightBlue(0.4, 0.4, 1, 1); const glm::vec4 green(0, 1, 0, 1); const glm::vec4 white(1, 1, 1, 1); - std::shared_ptr font = OsEng.fontManager().font("Mono", font_size); + std::shared_ptr font = OsEng.fontManager().font( + "Mono", FontSize + ); using ghoul::fontrendering::RenderFont; if (_remoteScripting) { int nClients = OsEng.parallelConnection().nConnections() - 1; if (nClients == 1) { - RenderFont(*font, glm::vec2(15.f, startY + 20.0f), red, "Broadcasting script to 1 client"); + RenderFont( + *font, + glm::vec2(15.f, startY + 20.0f), + red, + "Broadcasting script to 1 client" + ); } else { - RenderFont(*font, glm::vec2(15.f, startY + 20.0f), red, ("Broadcasting script to " + std::to_string(nClients) + " clients").c_str()); + RenderFont( + *font, + glm::vec2(15.f, startY + 20.0f), + red, + ("Broadcasting script to " + std::to_string(nClients) + " clients").c_str() + ); } RenderFont(*font, glm::vec2(15.f, startY), red, "$"); } else { if (OsEng.parallelConnection().isHost()) { - RenderFont(*font, glm::vec2(15.f, startY + 20.0f), lightBlue, "Local script execution"); + RenderFont( + *font, + glm::vec2(15.f, startY + 20.0f), + lightBlue, + "Local script execution" + ); } RenderFont(*font, glm::vec2(15.f, startY), lightBlue, "$"); } - RenderFont(*font, glm::vec2(15.f + font_size, startY), white, "%s", _commands.at(_activeCommand).c_str()); + RenderFont( + *font, + glm::vec2(15.f + FontSize, startY), + white, + "%s", + _commands.at(_activeCommand).c_str() + ); - size_t n = std::count(_commands.at(_activeCommand).begin(), _commands.at(_activeCommand).begin() + _inputPosition, '\n'); + const size_t n = std::count( + _commands.at(_activeCommand).begin(), + _commands.at(_activeCommand).begin() + _inputPosition, + '\n' + ); size_t p = _commands.at(_activeCommand).find_last_of('\n', _inputPosition); size_t linepos = _inputPosition; - if (n>0) { + if (n > 0) { if (p == _inputPosition) { p = _commands.at(_activeCommand).find_last_of('\n', _inputPosition - 1); if (p != std::string::npos) { @@ -361,107 +465,30 @@ void LuaConsole::render() { linepos = _inputPosition - 1; } } - else{ + else { linepos -= p + 1; } } std::stringstream ss; ss << "%" << linepos + 1 << "s"; - RenderFont(*font, glm::vec2(15.f + font_size * 0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f), green, ss.str().c_str(), "^"); - -// sgct_text::print(font, 15.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, green, ss.str().c_str(), "^"); -} - -Key LuaConsole::commandInputButton() { - // Button left of 1 and above TAB - // How to deal with different keyboard languages? ---abock - return Key::GraveAccent; + RenderFont( + *font, + glm::vec2(15.f + FontSize * 0.5f, startY - (FontSize) * (n + 1) * 3.0f / 2.0f), + green, + ss.str().c_str(), + "^" + ); } void LuaConsole::addToCommand(std::string c) { - size_t length = c.length(); - _commands.at(_activeCommand).insert(_inputPosition, c); + const size_t length = c.length(); + _commands.at(_activeCommand).insert(_inputPosition, std::move(c)); _inputPosition += length; } -std::string LuaConsole::UnicodeToUTF8(unsigned int codepoint) { - std::string out; - - if (codepoint <= 0x7f) - out.append(1, static_cast(codepoint)); - else if (codepoint <= 0x7ff) - { - out.append(1, static_cast(0xc0 | ((codepoint >> 6) & 0x1f))); - out.append(1, static_cast(0x80 | (codepoint & 0x3f))); - } - else if (codepoint <= 0xffff) - { - out.append(1, static_cast(0xe0 | ((codepoint >> 12) & 0x0f))); - out.append(1, static_cast(0x80 | ((codepoint >> 6) & 0x3f))); - out.append(1, static_cast(0x80 | (codepoint & 0x3f))); - } - else - { - out.append(1, static_cast(0xf0 | ((codepoint >> 18) & 0x07))); - out.append(1, static_cast(0x80 | ((codepoint >> 12) & 0x3f))); - out.append(1, static_cast(0x80 | ((codepoint >> 6) & 0x3f))); - out.append(1, static_cast(0x80 | (codepoint & 0x3f))); - } - return out; -} - -bool LuaConsole::isVisible() const { - return _isVisible; -} - -void LuaConsole::setVisible(bool visible) { - _isVisible = visible; -} - -void LuaConsole::toggleMode() { - if (_isVisible) { - if (_remoteScripting) { - _remoteScripting = false; - } else { - _isVisible = false; - } - } else { - _remoteScripting = OsEng.parallelConnection().isHost(); - _isVisible = true; - } -} - void LuaConsole::parallelConnectionChanged(const ParallelConnection::Status& status) { - _remoteScripting = status == ParallelConnection::Status::Host; + _remoteScripting = (status == ParallelConnection::Status::Host); } - -scripting::LuaLibrary LuaConsole::luaLibrary() { - return { - "console", - { - { - "show", - &luascriptfunctions::show, - "", - "Shows the console" - }, - { - "hide", - &luascriptfunctions::hide, - "", - "Hides the console" - }, - { - "toggle", - &luascriptfunctions::toggle, - "", - "Toggles the console" - } - } - }; -} - - } // namespace openspace diff --git a/src/mission/mission.cpp b/src/mission/mission.cpp index b8bdb20db8..714db21982 100644 --- a/src/mission/mission.cpp +++ b/src/mission/mission.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -30,15 +30,15 @@ #include namespace { - const std::string KeyName = "Name"; - const std::string KeyDescription = "Description"; - const std::string KeyPhases = "Phases"; - const std::string KeyTimeRange = "TimeRange"; + const char* KeyName = "Name"; + const char* KeyDescription = "Description"; + const char* KeyPhases = "Phases"; + const char* KeyTimeRange = "TimeRange"; } namespace openspace { -Documentation MissionPhase::Documentation() { +documentation::Documentation MissionPhase::Documentation() { using namespace documentation; return { @@ -188,7 +188,11 @@ Mission missionFromFile(std::string filename) { ghoul::Dictionary missionDict; ghoul::lua::loadDictionaryFromFile(filename, missionDict); - documentation::testSpecificationAndThrow(Documentation(), missionDict, "Mission"); + documentation::testSpecificationAndThrow( + MissionPhase::Documentation(), + missionDict, + "Mission" + ); return MissionPhase(missionDict); } diff --git a/src/mission/missionmanager.cpp b/src/mission/missionmanager.cpp index 56cb58be64..ee028078e3 100644 --- a/src/mission/missionmanager.cpp +++ b/src/mission/missionmanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/mission/missionmanager_lua.inl b/src/mission/missionmanager_lua.inl index 75840b3f27..9d2bcee237 100644 --- a/src/mission/missionmanager_lua.inl +++ b/src/mission/missionmanager_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/network/networkengine.cpp b/src/network/networkengine.cpp index a3a9c3e375..b7f2573657 100644 --- a/src/network/networkengine.cpp +++ b/src/network/networkengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index 9eb0a8d60c..23c97a114a 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/network/parallelconnection_lua.inl b/src/network/parallelconnection_lua.inl index 13b3b4bcf8..2646581aed 100644 --- a/src/network/parallelconnection_lua.inl +++ b/src/network/parallelconnection_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,19 +32,18 @@ namespace luascriptfunctions { * Set the port for parallel connection */ int setPort(lua_State* L) { - - const bool isFunction = (lua_isfunction(L, -1) != 0); + bool isFunction = (lua_isfunction(L, -1) != 0); if (isFunction) { // If the top of the stack is a function, it is ourself const char* msg = lua_pushfstring(L, "method called without argument"); return luaL_error(L, "bad argument (%s)", msg); } - const bool isNumber = (lua_isnumber(L, -1) != 0); + bool isNumber = (lua_isnumber(L, -1) != 0); if (isNumber) { int value = lua_tonumber(L, -1); std::string port = std::to_string(value); - if(OsEng.isMaster()){ + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().setPort(port); } return 0; @@ -59,18 +58,17 @@ int setPort(lua_State* L) { } int setAddress(lua_State* L) { - - const bool isFunction = (lua_isfunction(L, -1) != 0); + bool isFunction = (lua_isfunction(L, -1) != 0); if (isFunction) { // If the top of the stack is a function, it is ourself const char* msg = lua_pushfstring(L, "method called without argument"); return luaL_error(L, "bad argument (%s)", msg); } - const int type = lua_type(L, -1); + int type = lua_type(L, -1); if (type == LUA_TSTRING) { std::string address = luaL_checkstring(L, -1); - if(OsEng.isMaster()){ + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().setAddress(address); } return 0; @@ -85,18 +83,17 @@ int setAddress(lua_State* L) { } int setPassword(lua_State* L) { - - const bool isFunction = (lua_isfunction(L, -1) != 0); + bool isFunction = (lua_isfunction(L, -1) != 0); if (isFunction) { // If the top of the stack is a function, it is ourself const char* msg = lua_pushfstring(L, "method called without argument"); return luaL_error(L, "bad argument (%s)", msg); } - const int type = lua_type(L, -1); + int type = lua_type(L, -1); if (type == LUA_TSTRING) { std::string pwd = luaL_checkstring(L, -1); - if(OsEng.isMaster()){ + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().setPassword(pwd); } return 0; @@ -111,18 +108,17 @@ int setPassword(lua_State* L) { } int setDisplayName(lua_State* L) { - - const bool isFunction = (lua_isfunction(L, -1) != 0); + bool isFunction = (lua_isfunction(L, -1) != 0); if (isFunction) { // If the top of the stack is a function, it is ourself const char* msg = lua_pushfstring(L, "method called without argument"); return luaL_error(L, "bad argument (%s)", msg); } - const int type = lua_type(L, -1); + int type = lua_type(L, -1); if (type == LUA_TSTRING) { std::string name = luaL_checkstring(L, -1); - if(OsEng.isMaster()){ + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().setName(name); } return 0; @@ -137,40 +133,39 @@ int setDisplayName(lua_State* L) { } int connect(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) + if (nArguments != 0) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - if(OsEng.isMaster()){ + } + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().clientConnect(); } return 0; } int disconnect(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - if(OsEng.isMaster()){ + if (nArguments != 0) { + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + } + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().signalDisconnect(); } return 0; } int requestHostship(lua_State* L) { - - const bool isFunction = (lua_isfunction(L, -1) != 0); + bool isFunction = (lua_isfunction(L, -1) != 0); if (isFunction) { // If the top of the stack is a function, it is ourself const char* msg = lua_pushfstring(L, "method called without argument"); return luaL_error(L, "bad argument (%s)", msg); } - const int type = lua_type(L, -1); + int type = lua_type(L, -1); if (type == LUA_TSTRING) { std::string pwd = luaL_checkstring(L, -1); - if(OsEng.isMaster()){ + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().requestHostship(pwd); } return 0; @@ -185,11 +180,11 @@ int requestHostship(lua_State* L) { } int resignHostship(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) + if (nArguments != 0) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - if (OsEng.isMaster()) { + } + if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().resignHostship(); } return 0; diff --git a/src/openspace.cpp b/src/openspace.cpp index 8fa5d3e266..6bfda13b32 100644 --- a/src/openspace.cpp +++ b/src/openspace.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/performance/performancelayout.cpp b/src/performance/performancelayout.cpp index 5856f9f7e4..f432f543f0 100644 --- a/src/performance/performancelayout.cpp +++ b/src/performance/performancelayout.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp index fae9acafbc..383cb25e4f 100644 --- a/src/performance/performancemanager.cpp +++ b/src/performance/performancemanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/performance/performancemeasurement.cpp b/src/performance/performancemeasurement.cpp index 722d7b965d..ae6465cd4f 100644 --- a/src/performance/performancemeasurement.cpp +++ b/src/performance/performancemeasurement.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat2property.cpp b/src/properties/matrix/dmat2property.cpp index 5803a22efa..0696ab916d 100644 --- a/src/properties/matrix/dmat2property.cpp +++ b/src/properties/matrix/dmat2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat2x3property.cpp b/src/properties/matrix/dmat2x3property.cpp index d19e4c2ab5..4451261c25 100644 --- a/src/properties/matrix/dmat2x3property.cpp +++ b/src/properties/matrix/dmat2x3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat2x4property.cpp b/src/properties/matrix/dmat2x4property.cpp index c98c3c6457..b0b4eff710 100644 --- a/src/properties/matrix/dmat2x4property.cpp +++ b/src/properties/matrix/dmat2x4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat3property.cpp b/src/properties/matrix/dmat3property.cpp index 5b5bed6e59..77ee5324e2 100644 --- a/src/properties/matrix/dmat3property.cpp +++ b/src/properties/matrix/dmat3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat3x2property.cpp b/src/properties/matrix/dmat3x2property.cpp index 1bd04eb146..70935e2d14 100644 --- a/src/properties/matrix/dmat3x2property.cpp +++ b/src/properties/matrix/dmat3x2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat3x4property.cpp b/src/properties/matrix/dmat3x4property.cpp index 99dfe5283a..a5ac727045 100644 --- a/src/properties/matrix/dmat3x4property.cpp +++ b/src/properties/matrix/dmat3x4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat4property.cpp b/src/properties/matrix/dmat4property.cpp index 2d9c24003c..6951f9e81c 100644 --- a/src/properties/matrix/dmat4property.cpp +++ b/src/properties/matrix/dmat4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat4x2property.cpp b/src/properties/matrix/dmat4x2property.cpp index b4b132d47b..86412db0c1 100644 --- a/src/properties/matrix/dmat4x2property.cpp +++ b/src/properties/matrix/dmat4x2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/dmat4x3property.cpp b/src/properties/matrix/dmat4x3property.cpp index 306e259976..ea2d21d3d3 100644 --- a/src/properties/matrix/dmat4x3property.cpp +++ b/src/properties/matrix/dmat4x3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat2property.cpp b/src/properties/matrix/mat2property.cpp index f2736c6a9e..afffaac69f 100644 --- a/src/properties/matrix/mat2property.cpp +++ b/src/properties/matrix/mat2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat2x3property.cpp b/src/properties/matrix/mat2x3property.cpp index cf42b7261a..85ef35813a 100644 --- a/src/properties/matrix/mat2x3property.cpp +++ b/src/properties/matrix/mat2x3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat2x4property.cpp b/src/properties/matrix/mat2x4property.cpp index fac1405f6a..c38c138cbd 100644 --- a/src/properties/matrix/mat2x4property.cpp +++ b/src/properties/matrix/mat2x4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat3property.cpp b/src/properties/matrix/mat3property.cpp index fb8f473434..a38a07db76 100644 --- a/src/properties/matrix/mat3property.cpp +++ b/src/properties/matrix/mat3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat3x2property.cpp b/src/properties/matrix/mat3x2property.cpp index e230b7904d..2becdb6934 100644 --- a/src/properties/matrix/mat3x2property.cpp +++ b/src/properties/matrix/mat3x2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat3x4property.cpp b/src/properties/matrix/mat3x4property.cpp index f17c44d825..6a0dbee999 100644 --- a/src/properties/matrix/mat3x4property.cpp +++ b/src/properties/matrix/mat3x4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat4property.cpp b/src/properties/matrix/mat4property.cpp index 1d7ff0b614..3c40d1b979 100644 --- a/src/properties/matrix/mat4property.cpp +++ b/src/properties/matrix/mat4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat4x2property.cpp b/src/properties/matrix/mat4x2property.cpp index ca90cf41f6..3fccfdd740 100644 --- a/src/properties/matrix/mat4x2property.cpp +++ b/src/properties/matrix/mat4x2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/matrix/mat4x3property.cpp b/src/properties/matrix/mat4x3property.cpp index bdc1fecb21..c9f00f8cb9 100644 --- a/src/properties/matrix/mat4x3property.cpp +++ b/src/properties/matrix/mat4x3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/optionproperty.cpp b/src/properties/optionproperty.cpp index 8c24ba9036..0eb83a96fc 100644 --- a/src/properties/optionproperty.cpp +++ b/src/properties/optionproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/property.cpp b/src/properties/property.cpp index aee0f405a8..a70540dea4 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -32,24 +32,24 @@ namespace openspace { namespace properties { namespace { - const std::string _loggerCat = "Property"; - const std::string MetaDataKeyGuiName = "guiName"; - const std::string MetaDataKeyGroup = "Group"; - const std::string MetaDataKeyVisibility = "Visibility"; - const std::string MetaDataKeyReadOnly = "isReadOnly"; + const char* _loggerCat = "Property"; + const char* MetaDataKeyGuiName = "guiName"; + const char* MetaDataKeyGroup = "Group"; + const char* MetaDataKeyVisibility = "Visibility"; + const char* MetaDataKeyReadOnly = "isReadOnly"; - const std::string _metaDataKeyViewPrefix = "view."; + const char* _metaDataKeyViewPrefix = "view."; } -const std::string Property::ViewOptions::Color = "color"; -const std::string Property::ViewOptions::LightPosition = "lightPosition"; -const std::string Property::ViewOptions::PowerScaledCoordinate = "powerScaledCoordinate"; -const std::string Property::ViewOptions::PowerScaledScalar = "powerScaledScalar"; +const char* Property::ViewOptions::Color = "color"; +const char* Property::ViewOptions::LightPosition = "lightPosition"; +const char* Property::ViewOptions::PowerScaledCoordinate = "powerScaledCoordinate"; +const char* Property::ViewOptions::PowerScaledScalar = "powerScaledScalar"; -const std::string Property::IdentifierKey = "Identifier"; -const std::string Property::NameKey = "Name"; -const std::string Property::TypeKey = "Type"; -const std::string Property::MetaDataKey = "MetaData"; +const char* Property::IdentifierKey = "Identifier"; +const char* Property::NameKey = "Name"; +const char* Property::TypeKey = "Type"; +const char* Property::MetaDataKey = "MetaData"; Property::Property(std::string identifier, std::string guiName, Visibility visibility) : _owner(nullptr) @@ -181,7 +181,7 @@ void Property::notifyListener() { std::string Property::generateBaseDescription() const { return - TypeKey + " = \"" + className() + "\", " + + std::string(TypeKey) + " = \"" + className() + "\", " + IdentifierKey + " = \"" + fullyQualifiedIdentifier() + "\", " + NameKey + " = \"" + guiName() + "\", " + generateMetaDataDescription() + ", " + @@ -201,7 +201,7 @@ std::string Property::generateMetaDataDescription() const { std::string vis = VisibilityConverter.at(visibility); return - MetaDataKey + " = {" + + std::string(MetaDataKey) + " = {" + MetaDataKeyGroup + " = '" + groupIdentifier() + "'," + MetaDataKeyVisibility + " = " + vis + "," + MetaDataKeyReadOnly +" = " + (isReadOnly ? "true" : "false") + "}"; diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index 24221357a5..e45cd9279f 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,33 +24,33 @@ #include +#include #include +#include #include -#include namespace openspace { namespace properties { namespace { -const std::string _loggerCat = "PropertyOwner"; + const char* _loggerCat = "PropertyOwner"; -bool propertyLess(Property* lhs, Property* rhs) -{ - return lhs->identifier() < rhs->identifier(); -} + bool propertyLess(Property* lhs, Property* rhs) + { + return lhs->identifier() < rhs->identifier(); + } -bool subOwnerLess(PropertyOwner* lhs, PropertyOwner* rhs) { - return lhs->name() < rhs->name(); -} + bool subOwnerLess(PropertyOwner* lhs, PropertyOwner* rhs) { + return lhs->name() < rhs->name(); + } -} +} // namespace -PropertyOwner::PropertyOwner() - : _name("") +PropertyOwner::PropertyOwner(std::string name) + : _name(std::move(name)) , _owner(nullptr) -{ -} +{} PropertyOwner::~PropertyOwner() { _properties.clear(); @@ -73,14 +73,20 @@ std::vector PropertyOwner::propertiesRecursive() const { } Property* PropertyOwner::property(const std::string& id) const { - assert(std::is_sorted(_properties.begin(), _properties.end(), propertyLess)); + ghoul_assert( + std::is_sorted(_properties.begin(), _properties.end(), propertyLess), + "Property list must be sorted" + ); // As the _properties list is sorted, just finding the lower bound is sufficient - std::vector::const_iterator it - = std::lower_bound(_properties.begin(), _properties.end(), id, - [](Property* prop, const std::string& str) { - return prop->identifier() < str; - }); + std::vector::const_iterator it = std::lower_bound( + _properties.begin(), + _properties.end(), + id, + [](Property* prop, const std::string& str) { + return prop->identifier() < str; + } + ); if (it == _properties.end() || (*it)->identifier() != id) { // if we do not own the searched property, it must consist of a concatenated @@ -118,19 +124,27 @@ std::vector PropertyOwner::propertySubOwners() const { } PropertyOwner* PropertyOwner::propertySubOwner(const std::string& name) const { - assert(std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess)); + ghoul_assert( + std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess), + "List of subowners must be sorted" + ); // As the _subOwners list is sorted, getting the lower bound is sufficient - std::vector::const_iterator it - = std::lower_bound(_subOwners.begin(), _subOwners.end(), name, - [](PropertyOwner* owner, const std::string& str) { - return owner->name() < str; - }); + std::vector::const_iterator it = std::lower_bound( + _subOwners.begin(), + _subOwners.end(), + name, + [](PropertyOwner* owner, const std::string& str) { + return owner->name() < str; + } + ); - if (it == _subOwners.end() || (*it)->name() != name) + if (it == _subOwners.end() || (*it)->name() != name) { return nullptr; - else + } + else { return *it; + } } bool PropertyOwner::hasPropertySubOwner(const std::string& name) const { @@ -143,17 +157,24 @@ void PropertyOwner::setPropertyGroupName(std::string groupID, std::string name) std::string PropertyOwner::propertyGroupName(const std::string& groupID) const { auto it = _groupNames.find(groupID); - if (it == _groupNames.end()) + if (it == _groupNames.end()) { return groupID; - else + } + else { return it->second; + } } -void PropertyOwner::addProperty(Property* prop) -{ - assert(prop != nullptr); - assert(std::is_sorted(_properties.begin(), _properties.end(), propertyLess)); - assert(std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess)); +void PropertyOwner::addProperty(Property* prop) { + ghoul_assert(prop != nullptr, "prop must not be nullptr"); + ghoul_assert( + std::is_sorted(_properties.begin(), _properties.end(), propertyLess), + "Property list must be sorted" + ); + ghoul_assert( + std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess), + "Subowner list must be sorted" + ); if (prop->identifier().empty()) { LERROR("No property identifier specified"); @@ -162,23 +183,25 @@ void PropertyOwner::addProperty(Property* prop) // See if we can find the identifier of the property to add in the properties list // The _properties list is sorted, so getting the lower bound is sufficient - std::vector::iterator it - = std::lower_bound(_properties.begin(), _properties.end(), prop->identifier(), - [](Property* prop, const std::string& str) { - return prop->identifier() < str; - }); + std::vector::iterator it = std::lower_bound( + _properties.begin(), + _properties.end(), + prop->identifier(), + [](Property* prop, const std::string& str) { + return prop->identifier() < str; + } + ); // If we found the property identifier, we need to bail out if (it != _properties.end() && (*it)->identifier() == prop->identifier()) { - LERROR("Property identifier '" << prop->identifier() - << "' already present in PropertyOwner '" - << name() << "'"); + LERROR("Property identifier '" << prop->identifier() << + "' already present in PropertyOwner '" << name() << "'"); return; } else { // Otherwise we still have to look if there is a PropertyOwner with the same name const bool hasOwner = hasPropertySubOwner(prop->identifier()); if (hasOwner) { - LERROR("Property identifier '" << prop->identifier() << "' already names a" + LERROR("Property identifier '" << prop->identifier() << "' already names a " << "registed PropertyOwner"); return; } @@ -195,26 +218,30 @@ void PropertyOwner::addProperty(Property& prop) { } void PropertyOwner::addPropertySubOwner(openspace::properties::PropertyOwner* owner) { - assert(owner != nullptr); - assert(std::is_sorted(_properties.begin(), _properties.end(), propertyLess)); - assert(std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess)); + ghoul_assert(owner != nullptr, "owner must not be nullptr"); + ghoul_assert( + std::is_sorted(_properties.begin(), _properties.end(), propertyLess), + "Property list must be sorted" + ); + ghoul_assert( + std::is_sorted(_subOwners.begin(), _subOwners.end(), subOwnerLess), + "Subowner list must be sorted" + ); - if (owner->name().empty()) { - LERROR("PropertyOwner did not have a name"); - return; - } + ghoul_assert(!owner->name().empty(), "PropertyOwner must have a name"); // See if we can find the name of the propertyowner to add using the lower bound - std::vector::iterator it - = std::lower_bound(_subOwners.begin(), _subOwners.end(), owner->name(), - [](PropertyOwner* owner, const std::string& str) { - return owner->name() < str; - }); + std::vector::iterator it = std::lower_bound( + _subOwners.begin(), _subOwners.end(), owner->name(), + [](PropertyOwner* owner, const std::string& str) { + return owner->name() < str; + } + ); // If we found the propertyowner's name, we need to bail out if (it != _subOwners.end() && (*it)->name() == owner->name()) { - LERROR("PropertyOwner '" << owner->name() - << "' already present in PropertyOwner '" << name() << "'"); + LERROR("PropertyOwner '" << owner->name() << + "' already present in PropertyOwner '" << name() << "'"); return; } else { // We still need to check if the PropertyOwners name is used in a Property @@ -230,7 +257,6 @@ void PropertyOwner::addPropertySubOwner(openspace::properties::PropertyOwner* ow owner->setPropertyOwner(this); } } - } void PropertyOwner::addPropertySubOwner(openspace::properties::PropertyOwner& owner) { @@ -238,22 +264,26 @@ void PropertyOwner::addPropertySubOwner(openspace::properties::PropertyOwner& ow } void PropertyOwner::removeProperty(Property* prop) { - assert(prop != nullptr); + ghoul_assert(prop != nullptr, "prop must not be nullptr"); // See if we can find the identifier of the property to add in the properties list - std::vector::iterator it - = std::lower_bound(_properties.begin(), _properties.end(), prop->identifier(), - [](Property* prop, const std::string& str) { - return prop->identifier() < str; - }); + std::vector::iterator it = std::lower_bound( + _properties.begin(), + _properties.end(), + prop->identifier(), + [](Property* prop, const std::string& str) { + return prop->identifier() < str; + } + ); // If we found the property identifier, we can delete it if (it != _properties.end() && (*it)->identifier() == prop->identifier()) { (*it)->setPropertyOwner(nullptr); _properties.erase(it); - } else - LERROR("Property with identifier '" << prop->identifier() - << "' not found for removal."); + } else { + LERROR("Property with identifier '" << prop->identifier() << + "' not found for removal."); + } } void PropertyOwner::removeProperty(Property& prop) { @@ -261,21 +291,25 @@ void PropertyOwner::removeProperty(Property& prop) { } void PropertyOwner::removePropertySubOwner(openspace::properties::PropertyOwner* owner) { - assert(owner != nullptr); + ghoul_assert(owner != nullptr, "owner must not be nullptr"); // See if we can find the name of the propertyowner to add - std::vector::iterator it - = std::lower_bound(_subOwners.begin(), _subOwners.end(), owner->name(), - [](PropertyOwner* owner, const std::string& str) { - return owner->name() < str; - }); + std::vector::iterator it = std::lower_bound( + _subOwners.begin(), + _subOwners.end(), + owner->name(), + [](PropertyOwner* owner, const std::string& str) { + return owner->name() < str; + } + ); // If we found the propertyowner, we can delete it if (it != _subOwners.end() && (*it)->name() == owner->name()) { _subOwners.erase(it); - } else - LERROR("PropertyOwner with name '" << owner->name() - << "' not found for removal."); + } else { + LERROR("PropertyOwner with name '" << owner->name() << + "' not found for removal."); + } } void PropertyOwner::removePropertySubOwner(openspace::properties::PropertyOwner& owner) { diff --git a/src/properties/scalar/boolproperty.cpp b/src/properties/scalar/boolproperty.cpp index c150cf276b..d61df03e23 100644 --- a/src/properties/scalar/boolproperty.cpp +++ b/src/properties/scalar/boolproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/charproperty.cpp b/src/properties/scalar/charproperty.cpp index 57e3b78ff0..f266f1829e 100644 --- a/src/properties/scalar/charproperty.cpp +++ b/src/properties/scalar/charproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/doubleproperty.cpp b/src/properties/scalar/doubleproperty.cpp index 0e6d97eb5b..535b3ba60c 100644 --- a/src/properties/scalar/doubleproperty.cpp +++ b/src/properties/scalar/doubleproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/floatproperty.cpp b/src/properties/scalar/floatproperty.cpp index c42df70e76..5cc0f4c4f3 100644 --- a/src/properties/scalar/floatproperty.cpp +++ b/src/properties/scalar/floatproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/intproperty.cpp b/src/properties/scalar/intproperty.cpp index 43ac9a85f2..52b85fbf74 100644 --- a/src/properties/scalar/intproperty.cpp +++ b/src/properties/scalar/intproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/longdoubleproperty.cpp b/src/properties/scalar/longdoubleproperty.cpp index 2917978abd..be16d8ea79 100644 --- a/src/properties/scalar/longdoubleproperty.cpp +++ b/src/properties/scalar/longdoubleproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/longlongproperty.cpp b/src/properties/scalar/longlongproperty.cpp index 706ed6cba2..ea67efb837 100644 --- a/src/properties/scalar/longlongproperty.cpp +++ b/src/properties/scalar/longlongproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/longproperty.cpp b/src/properties/scalar/longproperty.cpp index 2e3ddf76f9..fbf1ce7311 100644 --- a/src/properties/scalar/longproperty.cpp +++ b/src/properties/scalar/longproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/shortproperty.cpp b/src/properties/scalar/shortproperty.cpp index d95b09bbee..33b31ca106 100644 --- a/src/properties/scalar/shortproperty.cpp +++ b/src/properties/scalar/shortproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/signedcharproperty.cpp b/src/properties/scalar/signedcharproperty.cpp index 3f0e7e068a..fbe17b194c 100644 --- a/src/properties/scalar/signedcharproperty.cpp +++ b/src/properties/scalar/signedcharproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/ucharproperty.cpp b/src/properties/scalar/ucharproperty.cpp index 17ecca1c52..be8e9e674a 100644 --- a/src/properties/scalar/ucharproperty.cpp +++ b/src/properties/scalar/ucharproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/uintproperty.cpp b/src/properties/scalar/uintproperty.cpp index f60782cbd8..3957fd5431 100644 --- a/src/properties/scalar/uintproperty.cpp +++ b/src/properties/scalar/uintproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/ulonglongproperty.cpp b/src/properties/scalar/ulonglongproperty.cpp index 6dc195639c..363dc66cc5 100644 --- a/src/properties/scalar/ulonglongproperty.cpp +++ b/src/properties/scalar/ulonglongproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/ulongproperty.cpp b/src/properties/scalar/ulongproperty.cpp index 974204164d..6cffb80d0d 100644 --- a/src/properties/scalar/ulongproperty.cpp +++ b/src/properties/scalar/ulongproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/ushortproperty.cpp b/src/properties/scalar/ushortproperty.cpp index 3369f51f44..dd1f5e0a01 100644 --- a/src/properties/scalar/ushortproperty.cpp +++ b/src/properties/scalar/ushortproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/scalar/wcharproperty.cpp b/src/properties/scalar/wcharproperty.cpp index 9a8c60b1a3..e48924f5b2 100644 --- a/src/properties/scalar/wcharproperty.cpp +++ b/src/properties/scalar/wcharproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/selectionproperty.cpp b/src/properties/selectionproperty.cpp index adeefb3f5b..b1029fd910 100644 --- a/src/properties/selectionproperty.cpp +++ b/src/properties/selectionproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/stringproperty.cpp b/src/properties/stringproperty.cpp index 125469beec..435394b95b 100644 --- a/src/properties/stringproperty.cpp +++ b/src/properties/stringproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/triggerproperty.cpp b/src/properties/triggerproperty.cpp index 9f40a36345..ddb99b2649 100644 --- a/src/properties/triggerproperty.cpp +++ b/src/properties/triggerproperty.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/bvec2property.cpp b/src/properties/vector/bvec2property.cpp index 4e48dd1de5..a80ea44176 100644 --- a/src/properties/vector/bvec2property.cpp +++ b/src/properties/vector/bvec2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/bvec3property.cpp b/src/properties/vector/bvec3property.cpp index 9891b42f2f..74e99f3e36 100644 --- a/src/properties/vector/bvec3property.cpp +++ b/src/properties/vector/bvec3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/bvec4property.cpp b/src/properties/vector/bvec4property.cpp index 9ec01527e2..4c0da13839 100644 --- a/src/properties/vector/bvec4property.cpp +++ b/src/properties/vector/bvec4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/dvec2property.cpp b/src/properties/vector/dvec2property.cpp index 2c70902f22..104a4789af 100644 --- a/src/properties/vector/dvec2property.cpp +++ b/src/properties/vector/dvec2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/dvec3property.cpp b/src/properties/vector/dvec3property.cpp index 80d9b4db3f..7a2c88925b 100644 --- a/src/properties/vector/dvec3property.cpp +++ b/src/properties/vector/dvec3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/dvec4property.cpp b/src/properties/vector/dvec4property.cpp index 2a8393437b..6b388a390d 100644 --- a/src/properties/vector/dvec4property.cpp +++ b/src/properties/vector/dvec4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/ivec2property.cpp b/src/properties/vector/ivec2property.cpp index 3949a09bb1..4f62edee53 100644 --- a/src/properties/vector/ivec2property.cpp +++ b/src/properties/vector/ivec2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/ivec3property.cpp b/src/properties/vector/ivec3property.cpp index f7e4207e87..fce00ab2dc 100644 --- a/src/properties/vector/ivec3property.cpp +++ b/src/properties/vector/ivec3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/ivec4property.cpp b/src/properties/vector/ivec4property.cpp index 2c357001d6..7beb3a4cb8 100644 --- a/src/properties/vector/ivec4property.cpp +++ b/src/properties/vector/ivec4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/uvec2property.cpp b/src/properties/vector/uvec2property.cpp index 50bc166cba..d375eb0437 100644 --- a/src/properties/vector/uvec2property.cpp +++ b/src/properties/vector/uvec2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/uvec3property.cpp b/src/properties/vector/uvec3property.cpp index 0feb1188e8..62baf60b65 100644 --- a/src/properties/vector/uvec3property.cpp +++ b/src/properties/vector/uvec3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/uvec4property.cpp b/src/properties/vector/uvec4property.cpp index 333907eb7c..b1e6cb3222 100644 --- a/src/properties/vector/uvec4property.cpp +++ b/src/properties/vector/uvec4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/vec2property.cpp b/src/properties/vector/vec2property.cpp index 4cef6f2c28..c974e0333f 100644 --- a/src/properties/vector/vec2property.cpp +++ b/src/properties/vector/vec2property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/vec3property.cpp b/src/properties/vector/vec3property.cpp index 3c237bea2a..b4673383b1 100644 --- a/src/properties/vector/vec3property.cpp +++ b/src/properties/vector/vec3property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/properties/vector/vec4property.cpp b/src/properties/vector/vec4property.cpp index 196fc28036..1d61039d22 100644 --- a/src/properties/vector/vec4property.cpp +++ b/src/properties/vector/vec4property.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/query/query.cpp b/src/query/query.cpp index 224fd7fb1c..12bbc7ebd8 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/rendering/abufferrenderer.cpp b/src/rendering/abufferrenderer.cpp index 2cc1c2025e..a29a4fd69f 100644 --- a/src/rendering/abufferrenderer.cpp +++ b/src/rendering/abufferrenderer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -268,9 +268,6 @@ void ABufferRenderer::render(float blackoutFactor, bool doPerformanceMeasurement RenderData data{ *_camera, psc(), doPerformanceMeasurements, renderBinMask }; RendererTasks tasks; _scene->render(data, tasks); - - _rendererTasks = std::make_unique(tasks); - _renderData = std::make_unique(data); _blackoutFactor = blackoutFactor; glBindFramebuffer(GL_FRAMEBUFFER, defaultFbo); @@ -314,10 +311,21 @@ void ABufferRenderer::render(float blackoutFactor, bool doPerformanceMeasurement // END TEMPORARY GAMMA CORRECTION. - preRaycast(*_resolveProgram); + _resolveProgram->setUniform("mainColorTexture", _mainColorTextureUnit->unitNumber()); + _resolveProgram->setUniform("mainDepthTexture", _mainDepthTextureUnit->unitNumber()); + _resolveProgram->setUniform("blackoutFactor", _blackoutFactor); + _resolveProgram->setUniform("nAaSamples", _nAaSamples); + + for (const RaycasterTask& raycasterTask : tasks.raycasterTasks) { + preRaycast(raycasterTask); + } + glBindVertexArray(_screenQuad); glDrawArrays(GL_TRIANGLES, 0, 6); - postRaycast(*_resolveProgram); + + for (const RaycasterTask& raycasterTask : tasks.raycasterTasks) { + postRaycast(raycasterTask); + } _resolveProgram->deactivate(); @@ -326,32 +334,27 @@ void ABufferRenderer::render(float blackoutFactor, bool doPerformanceMeasurement } -void ABufferRenderer::preRaycast(ghoul::opengl::ProgramObject& program) { +void ABufferRenderer::preRaycast(const RaycasterTask& raycasterTask) { + VolumeRaycaster& raycaster = *raycasterTask.raycaster; + const RaycastData& raycastData = _raycastData[&raycaster]; + const RenderData& renderData = raycasterTask.renderData; - program.setUniform("mainColorTexture", _mainColorTextureUnit->unitNumber()); - program.setUniform("mainDepthTexture", _mainDepthTextureUnit->unitNumber()); - - for (const auto& raycastData : _raycastData) { - raycastData.first->preRaycast(raycastData.second, program); + raycaster.preRaycast(raycastData, *_resolveProgram); - glm::vec3 localCameraPosition; - bool cameraIsInside = raycastData.first->cameraIsInside(*_renderData, localCameraPosition); - int uniformIndex = raycastData.second.id + 1; // uniforms are indexed from 1 (not from 0) - program.setUniform("insideRaycaster" + std::to_string(uniformIndex), cameraIsInside); - if (cameraIsInside) { - program.setUniform("cameraPosInRaycaster" + std::to_string(uniformIndex), localCameraPosition); - } + glm::vec3 localCameraPosition; + bool cameraIsInside = raycaster.cameraIsInside(renderData, localCameraPosition); + int uniformIndex = raycastData.id + 1; // uniforms are indexed from 1 (not from 0) + _resolveProgram->setUniform("insideRaycaster" + std::to_string(uniformIndex), cameraIsInside); + if (cameraIsInside) { + _resolveProgram->setUniform("cameraPosInRaycaster" + std::to_string(uniformIndex), localCameraPosition); } - - // 3b: Set "global" uniforms, and start the resolve pass. - program.setUniform("blackoutFactor", _blackoutFactor); - program.setUniform("nAaSamples", _nAaSamples); } -void ABufferRenderer::postRaycast(ghoul::opengl::ProgramObject& program) { - for (const auto& raycastData : _raycastData) { - raycastData.first->postRaycast(raycastData.second, program); - } +void ABufferRenderer::postRaycast(const RaycasterTask& raycasterTask) { + VolumeRaycaster& raycaster = *raycasterTask.raycaster; + const RaycastData& raycastData = _raycastData[&raycaster]; + + raycaster.postRaycast(raycastData, *_resolveProgram); } void ABufferRenderer::setScene(Scene* scene) { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 63041636f3..d5769de82f 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -46,6 +46,8 @@ namespace { const std::string _loggerCat = "FramebufferRenderer"; const std::string ExitFragmentShaderPath = "${SHADERS}/framebuffer/exitframebuffer.frag"; const std::string RaycastFragmentShaderPath = "${SHADERS}/framebuffer/raycastframebuffer.frag"; + const std::string GetEntryInsidePath = "${SHADERS}/framebuffer/inside.glsl"; + const std::string GetEntryOutsidePath = "${SHADERS}/framebuffer/outside.glsl"; const std::string RenderFragmentShaderPath = "${SHADERS}/framebuffer/renderframebuffer.frag"; } @@ -286,20 +288,28 @@ void FramebufferRenderer::updateRaycastData() { try { _exitPrograms[raycaster] = ghoul::opengl::ProgramObject::Build("Volume " + std::to_string(data.id) + " exit", vsPath, ExitFragmentShaderPath, dict); - } - catch (ghoul::RuntimeError e) { - LERROR(e.message); - } - try { - _raycastPrograms[raycaster] = ghoul::opengl::ProgramObject::Build("Volume " + std::to_string(data.id) + " raycast", vsPath, RaycastFragmentShaderPath, dict); } catch (ghoul::RuntimeError e) { LERROR(e.message); } try { + ghoul::Dictionary outsideDict = dict; + outsideDict.setValue("getEntryPath", GetEntryOutsidePath); + _raycastPrograms[raycaster] = ghoul::opengl::ProgramObject::Build( + "Volume " + std::to_string(data.id) + " raycast", + vsPath, + RaycastFragmentShaderPath, + outsideDict); + } catch (ghoul::RuntimeError e) { + LERROR(e.message); + } + try { + ghoul::Dictionary insideDict = dict; + insideDict.setValue("getEntryPath", GetEntryInsidePath); _insideRaycastPrograms[raycaster] = ghoul::opengl::ProgramObject::Build( "Volume " + std::to_string(data.id) + " inside raycast", "${SHADERS}/framebuffer/resolveframebuffer.vert", - RaycastFragmentShaderPath, dict); + RaycastFragmentShaderPath, + insideDict); } catch (ghoul::RuntimeError e) { LERROR(e.message); @@ -359,26 +369,22 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure } glBindFramebuffer(GL_FRAMEBUFFER, _mainFramebuffer); - - - ghoul::opengl::ProgramObject* insideRaycastProgram = _raycastPrograms[raycaster].get(); - glm::vec3 cameraPosition; bool cameraIsInside = raycaster->cameraIsInside(raycasterTask.renderData, cameraPosition); ghoul::opengl::ProgramObject* raycastProgram = nullptr; if (cameraIsInside) { - raycastProgram = _insideRaycastPrograms[raycaster].get(); + if (raycastProgram = _insideRaycastPrograms[raycaster].get()) { + raycastProgram->activate(); + raycastProgram->setUniform("cameraPosInRaycaster", cameraPosition); + } } else { - raycastProgram = _raycastPrograms[raycaster].get(); + if (raycastProgram = _raycastPrograms[raycaster].get()) { + raycastProgram->activate(); + } } if (raycastProgram) { - raycastProgram->activate(); - - raycastProgram->setUniform("insideRaycaster", cameraIsInside); - raycastProgram->setUniform("cameraPosInRaycaster", cameraPosition); - raycaster->preRaycast(_raycastData[raycaster], *raycastProgram); ghoul::opengl::TextureUnit exitColorTextureUnit; diff --git a/src/rendering/raycastermanager.cpp b/src/rendering/raycastermanager.cpp index 0b0f65ef71..f5ca284d2c 100644 --- a/src/rendering/raycastermanager.cpp +++ b/src/rendering/raycastermanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 58826b0b0d..ab22ebe710 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -36,15 +37,15 @@ #include namespace { - const std::string _loggerCat = "Renderable"; - const std::string keyStart = "StartTime"; - const std::string keyEnd = "EndTime"; - const std::string KeyType = "Type"; + const char* _loggerCat = "Renderable"; + const char* keyStart = "StartTime"; + const char* keyEnd = "EndTime"; + const char* KeyType = "Type"; } namespace openspace { -Documentation Renderable::Documentation() { +documentation::Documentation Renderable::Documentation() { using namespace openspace::documentation; return { @@ -64,7 +65,9 @@ Documentation Renderable::Documentation() { }; } -Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary) { +std::unique_ptr Renderable::createFromDictionary( + const ghoul::Dictionary& dictionary) +{ // The name is passed down from the SceneGraphNode std::string name; bool success = dictionary.getValue(SceneGraphNode::KeyName, name); @@ -75,7 +78,7 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary std::string renderableType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - Renderable* result = factory->create(renderableType, dictionary); + std::unique_ptr result = factory->create(renderableType, dictionary); if (result == nullptr) { LERROR("Failed to create a Renderable object of type '" << renderableType << "'"); return nullptr; @@ -85,7 +88,8 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary } Renderable::Renderable() - : _enabled("enabled", "Is Enabled", true) + : properties::PropertyOwner("renderable") + , _enabled("enabled", "Is Enabled", true) , _renderBin(RenderBin::Opaque) , _startTime("") , _endTime("") @@ -93,17 +97,16 @@ Renderable::Renderable() {} Renderable::Renderable(const ghoul::Dictionary& dictionary) - : _enabled("enabled", "Is Enabled", true) + : properties::PropertyOwner("renderable") + , _enabled("enabled", "Is Enabled", true) , _renderBin(RenderBin::Opaque) , _startTime("") , _endTime("") , _hasTimeInterval(false) { - setName("renderable"); - ghoul_assert( dictionary.hasKeyAndValue(SceneGraphNode::KeyName), - "SceneGraphNode must specify '" << SceneGraphNode::KeyName << "'" + std::string("SceneGraphNode must specify '") + SceneGraphNode::KeyName + "'" ); dictionary.getValue(keyStart, _startTime); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index dd430e7f79..a2b3867fb2 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,65 +24,60 @@ #include -#include - #ifdef OPENSPACE_MODULE_NEWHORIZONS_ENABLED #include #endif -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include +//#include +//#include +//#include -#include +//#include -#include -#include +//#include +//#include #include + +//#include + #include #include #include #include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include +#include +#include +#include + #ifdef GHOUL_USE_DEVIL #include #endif //GHOUL_USE_DEVIL #ifdef GHOUL_USE_FREEIMAGE #include #endif // GHOUL_USE_FREEIMAGE -#include -#include #ifdef GHOUL_USE_SOIL #include +#include #include #endif //GHOUL_USE_SOIL #include -#include #include // ABuffer defines @@ -92,27 +87,24 @@ #include "renderengine_lua.inl" namespace { - const std::string _loggerCat = "RenderEngine"; + const char* _loggerCat = "RenderEngine"; - const std::string KeyRenderingMethod = "RenderingMethod"; - std::chrono::seconds ScreenLogTimeToLive(15); - const std::string DefaultRenderingMethod = "ABuffer"; - const std::string RenderFsPath = "${SHADERS}/render.frag"; -} + const char* KeyRenderingMethod = "RenderingMethod"; + const std::chrono::seconds ScreenLogTimeToLive(15); + const char* DefaultRenderingMethod = "ABuffer"; + const char* RenderFsPath = "${SHADERS}/render.frag"; + + const char* KeyFontMono = "Mono"; + const char* KeyFontLight = "Light"; +} // namespace namespace openspace { -const std::string RenderEngine::KeyFontMono = "Mono"; -const std::string RenderEngine::KeyFontLight = "Light"; -const std::vector RenderEngine::FrametimeTypes({ - RenderEngine::FrametimeType::DtTimeAvg, - RenderEngine::FrametimeType::FPS, - RenderEngine::FrametimeType::FPSAvg -}); - RenderEngine::RenderEngine() - : _camera(nullptr) + : properties::PropertyOwner("RenderEngine") + , _camera(nullptr) + , _raycasterManager(nullptr) , _performanceMeasurements("performanceMeasurements", "Performance Measurements") , _frametimeType( "frametimeType", @@ -120,23 +112,24 @@ RenderEngine::RenderEngine() properties::OptionProperty::DisplayType::Dropdown ) , _scene(nullptr) + , _showInfo("showInfo", "Show Render Information", true) + , _showLog("showLog", "Show the OnScreen log", true) + , _nAaSamples("nAaSamples", "Number of Antialiasing samples", 8, 1, 16) + , _applyWarping("applyWarpingScreenshot", "Apply Warping to Screenshots", false) + , _takeScreenshot("takeScreenshot", "Take Screenshot") + , _showFrameNumber("showFrameNumber", "Show Frame Number", false) + , _disableMasterRendering("disableMasterRendering", "Disable Master Rendering", false) + , _shouldTakeScreenshot(false) , _renderer(nullptr) , _rendererImplementation(RendererImplementation::Invalid) , _performanceManager(nullptr) , _log(nullptr) - , _showInfo(true) - , _showLog(true) - , _takeScreenshot(false) - , _showFrameNumber(false) , _globalBlackOutFactor(1.f) , _fadeDuration(2.f) , _currentFadeTime(0.f) , _fadeDirection(0) , _frameNumber(0) - //, _frametimeType(FrametimeType::DtTimeAvg) { - setName("RenderEngine"); - _performanceMeasurements.onChange([this](){ if (_performanceMeasurements) { if (!_performanceManager) { @@ -163,14 +156,26 @@ RenderEngine::RenderEngine() "Average frames per second" ); addProperty(_frametimeType); -} - -bool RenderEngine::deinitialize() { - for (auto screenspacerenderable : _screenSpaceRenderables) { - screenspacerenderable->deinitialize(); - } - MissionManager::deinitialize(); - return true; + + addProperty(_showInfo); + addProperty(_showLog); + + _nAaSamples.onChange([this](){ + if (_renderer) { + _renderer->setNAaSamples(_nAaSamples); + } + }); + addProperty(_nAaSamples); + addProperty(_applyWarping); + + _takeScreenshot.onChange([this](){ + _shouldTakeScreenshot = true; + }); + addProperty(_takeScreenshot); + + addProperty(_showFrameNumber); + + addProperty(_disableMasterRendering); } void RenderEngine::setRendererFromString(const std::string& renderingMethod) { @@ -186,29 +191,36 @@ void RenderEngine::setRendererFromString(const std::string& renderingMethod) { break; case RendererImplementation::Invalid: LFATAL("Rendering method '" << renderingMethod << "' not among the available " - << "rendering methods"); + << "rendering methods"); } setRenderer(std::move(newRenderer)); } -bool RenderEngine::initialize() { +void RenderEngine::initialize() { _frameNumber = 0; std::string renderingMethod = DefaultRenderingMethod; - - // Set rendering method to the user-defined one if any. - if (OsEng.configurationManager().hasKeyAndValue(KeyRenderingMethod)) { - renderingMethod = OsEng.configurationManager().value(KeyRenderingMethod); + + // If the user specified a rendering method that he would like to use, use that + auto& confManager = OsEng.configurationManager(); + if (confManager.hasKeyAndValue(KeyRenderingMethod)) { + renderingMethod = confManager.value(KeyRenderingMethod); } else { - using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version; + using Version = ghoul::systemcapabilities::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,0}) { + if (OpenGLCap.openGLVersion() < Version{ 4,3,0 }) { LINFO("Falling back to framebuffer implementation due to OpenGL limitations"); renderingMethod = "Framebuffer"; } } + + if (confManager.hasKey(ConfigurationManager::KeyDisableMasterRendering)) { + _disableMasterRendering = confManager.value( + ConfigurationManager::KeyDisableMasterRendering + ); + } _raycasterManager = std::make_unique(); _nAaSamples = OsEng.windowWrapper().currentNumberOfAaSamples(); @@ -226,22 +238,20 @@ bool RenderEngine::initialize() { ghoul::io::TextureReader::ref().addReader(std::make_shared()); ghoul::io::TextureWriter::ref().addWriter(std::make_shared()); #endif // GHOUL_USE_SOIL - + ghoul::io::TextureReader::ref().addReader(std::make_shared()); MissionManager::initialize(); - - return true; } -bool RenderEngine::initializeGL() { +void RenderEngine::initializeGL() { // TODO: Fix the power scaled coordinates in such a way that these // values can be set to more realistic values // set the close clip plane and the far clip plane to extreme values while in // development OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 1000.f); - + try { const float fontSizeBig = 50.f; _fontBig = OsEng.fontManager().font(KeyFontMono, fontSizeBig); @@ -251,19 +261,25 @@ bool RenderEngine::initializeGL() { _fontInfo = OsEng.fontManager().font(KeyFontMono, fontSizeMono); const float fontSizeLight = 8.f; _fontLog = OsEng.fontManager().font(KeyFontLight, fontSizeLight); - } - catch (const ghoul::fontrendering::Font::FreeTypeException& e) { + } catch (const ghoul::fontrendering::Font::FreeTypeException& e) { LERROR(e.what()); throw; } - + LINFO("Initializing Log"); std::unique_ptr log = std::make_unique(ScreenLogTimeToLive); _log = log.get(); ghoul::logging::LogManager::ref().addLog(std::move(log)); LINFO("Finished initializing GL"); - return true; +} + +void RenderEngine::deinitialize() { + for (auto screenspacerenderable : _screenSpaceRenderables) { + screenspacerenderable->deinitialize(); + } + + MissionManager::deinitialize(); } void RenderEngine::updateScene() { @@ -279,10 +295,12 @@ void RenderEngine::updateScene() { }); _scene->evaluate(_camera); + + LTRACE("RenderEngine::updateSceneGraph(end)"); } void RenderEngine::updateShaderPrograms() { - for (auto program : _programs) { + for (ghoul::opengl::ProgramObject* program : _programs) { try { if (program->isDirty()) { program->rebuildFromFile(); @@ -309,7 +327,7 @@ void RenderEngine::updateRenderer() { } void RenderEngine::updateScreenSpaceRenderables() { - for (auto screenspacerenderable : _screenSpaceRenderables) { + for (auto& screenspacerenderable : _screenSpaceRenderables) { screenspacerenderable->update(); } } @@ -340,12 +358,13 @@ glm::ivec2 RenderEngine::fontResolution() const { void RenderEngine::updateFade() { - //temporary fade funtionality - float fadedIn = 1.0; - float fadedOut = 0.0; + // Temporary fade funtionality + const float fadedIn = 1.0; + const float fadedOut = 0.0; // Don't restart the fade if you've already done it in that direction - if ((_fadeDirection > 0 && _globalBlackOutFactor == fadedIn) - || (_fadeDirection < 0 && _globalBlackOutFactor == fadedOut)) { + const bool isFadedIn = (_fadeDirection > 0 && _globalBlackOutFactor == fadedIn); + const bool isFadedOut = (_fadeDirection < 0 && _globalBlackOutFactor == fadedOut); + if (isFadedIn || isFadedOut) { _fadeDirection = 0; } @@ -355,25 +374,41 @@ void RenderEngine::updateFade() { _fadeDirection = 0; } else { - if (_fadeDirection < 0) - _globalBlackOutFactor = glm::smoothstep(1.f, 0.f, _currentFadeTime / _fadeDuration); - else - _globalBlackOutFactor = glm::smoothstep(0.f, 1.f, _currentFadeTime / _fadeDuration); - _currentFadeTime += static_cast(OsEng.windowWrapper().averageDeltaTime()); + if (_fadeDirection < 0) { + _globalBlackOutFactor = glm::smoothstep( + 1.f, + 0.f, + _currentFadeTime / _fadeDuration + ); + } else { + _globalBlackOutFactor = glm::smoothstep( + 0.f, + 1.f, + _currentFadeTime / _fadeDuration + ); + } + _currentFadeTime += static_cast( + OsEng.windowWrapper().averageDeltaTime() + ); } } } -void RenderEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix){ + + +void RenderEngine::render(const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix) { + LTRACE("RenderEngine::render(begin)"); _camera->sgctInternal.setViewMatrix(viewMatrix); _camera->sgctInternal.setProjectionMatrix(projectionMatrix); + + WindowWrapper& wrapper = OsEng.windowWrapper(); - if (!(OsEng.isMaster() && _disableMasterRendering) && !OsEng.windowWrapper().isGuiWindow()) { + if (!(wrapper.isMaster() && _disableMasterRendering) && !wrapper.isGuiWindow()) { _renderer->render(_globalBlackOutFactor, _performanceManager != nullptr); } // Print some useful information on the master viewport - if (OsEng.isMaster() && OsEng.windowWrapper().isSimpleRendering()) { + if (wrapper.isMaster() && wrapper.isSimpleRendering()) { renderInformation(); } @@ -382,17 +417,18 @@ void RenderEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& vi OsEng.windowWrapper().viewportPixelCoordinates().w / 3 ); - if(_showFrameNumber) { + if (_showFrameNumber) { RenderFontCr(*_fontBig, penPosition, "%i", _frameNumber); } _frameNumber++; - - for (auto screenSpaceRenderable : _screenSpaceRenderables) { - if (screenSpaceRenderable->isEnabled() && screenSpaceRenderable->isReady()) + for (auto& screenSpaceRenderable : _screenSpaceRenderables) { + if (screenSpaceRenderable->isEnabled() && screenSpaceRenderable->isReady()) { screenSpaceRenderable->render(); + } } + LTRACE("RenderEngine::render(end)"); } void RenderEngine::renderShutdownInformation(float timer, float fullTime) { @@ -425,25 +461,18 @@ void RenderEngine::postDraw() { Time::ref().setTimeJumped(false); } - if (_takeScreenshot) { + if (_shouldTakeScreenshot) { OsEng.windowWrapper().takeScreenshot(_applyWarping); - _takeScreenshot = false; + _shouldTakeScreenshot = false; } if (_performanceManager) { - _performanceManager->storeScenePerformanceMeasurements(scene()->allSceneGraphNodes()); + _performanceManager->storeScenePerformanceMeasurements( + scene()->allSceneGraphNodes() + ); } } -void RenderEngine::takeScreenshot(bool applyWarping) { - _takeScreenshot = true; - _applyWarping = applyWarping; -} - -void RenderEngine::toggleInfoText(bool b) { - _showInfo = b; -} - Scene* RenderEngine::scene() { return _scene; } @@ -496,10 +525,9 @@ void RenderEngine::startFading(int direction, float fadeDuration) { * Build a program object for rendering with the used renderer */ std::unique_ptr RenderEngine::buildRenderProgram( - std::string name, - std::string vsPath, - std::string fsPath, - const ghoul::Dictionary& data) { + std::string name, std::string vsPath, + std::string fsPath, const ghoul::Dictionary& data) +{ ghoul::Dictionary dict = data; @@ -510,11 +538,13 @@ std::unique_ptr RenderEngine::buildRenderProgram( // instead of a void main() setting glFragColor, glFragDepth, etc. dict.setValue("fragmentPath", fsPath); - std::unique_ptr program = ghoul::opengl::ProgramObject::Build( + using namespace ghoul::opengl; + std::unique_ptr program = ProgramObject::Build( name, vsPath, RenderFsPath, - dict); + dict + ); if (program) { _programs.push_back(program.get()); @@ -526,12 +556,10 @@ std::unique_ptr RenderEngine::buildRenderProgram( * Build a program object for rendering with the used renderer */ std::unique_ptr RenderEngine::buildRenderProgram( - std::string name, - std::string vsPath, - std::string fsPath, - std::string csPath, - const ghoul::Dictionary& data) { - + std::string name, std::string vsPath, + std::string fsPath, std::string csPath, + const ghoul::Dictionary& data) +{ ghoul::Dictionary dict = data; dict.setValue("rendererData", _rendererData); @@ -540,12 +568,14 @@ std::unique_ptr RenderEngine::buildRenderProgram( // instead of a void main() setting glFragColor, glFragDepth, etc. dict.setValue("fragmentPath", fsPath); - std::unique_ptr program = ghoul::opengl::ProgramObject::Build( + using namespace ghoul::opengl; + std::unique_ptr program = ProgramObject::Build( name, vsPath, RenderFsPath, csPath, - dict); + dict + ); if (program) { _programs.push_back(program.get()); @@ -553,16 +583,18 @@ std::unique_ptr RenderEngine::buildRenderProgram( return program; } -void RenderEngine::removeRenderProgram(const std::unique_ptr& program) { - if (!program) +void RenderEngine::removeRenderProgram( + const std::unique_ptr& program) +{ + if (!program) { return; + } - ghoul::opengl::ProgramObject* ptr = program.get(); auto it = std::find( _programs.begin(), _programs.end(), - ptr - ); + program.get() + ); if (it != _programs.end()) { _programs.erase(it); @@ -576,7 +608,7 @@ void RenderEngine::removeRenderProgram(const std::unique_ptrdictionary(); dict.setValue("rendererData", _rendererData); program->setDictionary(dict); @@ -591,7 +623,7 @@ void RenderEngine::setRendererData(const ghoul::Dictionary& data) { */ void RenderEngine::setResolveData(const ghoul::Dictionary& data) { _resolveData = data; - for (auto program : _programs) { + for (ghoul::opengl::ProgramObject* program : _programs) { ghoul::Dictionary dict = program->dictionary(); dict.setValue("resolveData", _resolveData); program->setDictionary(dict); @@ -612,8 +644,6 @@ void RenderEngine::postRaycast(ghoul::opengl::ProgramObject& programObject) { _renderer->postRaycast(programObject); } - - /** * Set renderer */ @@ -630,44 +660,16 @@ void RenderEngine::setRenderer(std::unique_ptr renderer) { _renderer->setScene(_scene); } - -void RenderEngine::setNAaSamples(int nAaSamples) { - _nAaSamples = nAaSamples; - if (_renderer) { - _renderer->setNAaSamples(_nAaSamples); - } -} - scripting::LuaLibrary RenderEngine::luaLibrary() { return { "", { - { - "takeScreenshot", - &luascriptfunctions::takeScreenshot, - "(optional bool)", - "Renders the current image to a file on disk. If the boolean parameter " - "is set to 'true', the screenshot will include the blending and the " - "meshes. If it is 'false', the straight FBO will be recorded." - }, { "setRenderer", &luascriptfunctions::setRenderer, "string", "Sets the renderer (ABuffer or FrameBuffer)" }, - { - "setNAaSamples", - &luascriptfunctions::setNAaSamples, - "int", - "Sets the number of anti-aliasing (MSAA) samples" - }, - { - "showRenderInformation", - &luascriptfunctions::showRenderInformation, - "bool", - "Toggles the showing of render information on-screen text" - }, { "toggleFade", &luascriptfunctions::toggleFade, @@ -711,26 +713,20 @@ performance::PerformanceManager* RenderEngine::performanceManager() { return _performanceManager.get(); } -void RenderEngine::setShowFrameNumber(bool enabled){ - _showFrameNumber = enabled; -} - -void RenderEngine::setDisableRenderingOnMaster(bool enabled) { - _disableMasterRendering = enabled; -} - void RenderEngine::registerScreenSpaceRenderable(std::shared_ptr s) { s->initialize(); _screenSpaceRenderables.push_back(s); } -void RenderEngine::unregisterScreenSpaceRenderable(std::shared_ptr s){ +void RenderEngine::unregisterScreenSpaceRenderable( + std::shared_ptr s) +{ auto it = std::find( _screenSpaceRenderables.begin(), _screenSpaceRenderables.end(), s - ); + ); if (it != _screenSpaceRenderables.end()) { s->deinitialize(); @@ -740,13 +736,16 @@ void RenderEngine::unregisterScreenSpaceRenderable(std::shared_ptr RenderEngine::screenSpaceRenderable(std::string name){ - for(auto s : _screenSpaceRenderables){ - if(s->name() == name){ +std::shared_ptr RenderEngine::screenSpaceRenderable( + std::string name) +{ + for (auto s : _screenSpaceRenderables) { + if (s->name() == name) { return s; } } @@ -764,27 +763,33 @@ std::vector RenderEngine::screenSpaceRenderables() const return res; } -RenderEngine::RendererImplementation RenderEngine::rendererFromString(const std::string& impl) { +RenderEngine::RendererImplementation RenderEngine::rendererFromString( + const std::string& impl) +{ const std::map RenderingMethods = { { "ABuffer", RendererImplementation::ABuffer }, { "Framebuffer", RendererImplementation::Framebuffer } }; - if (RenderingMethods.find(impl) != RenderingMethods.end()) + if (RenderingMethods.find(impl) != RenderingMethods.end()) { return RenderingMethods.at(impl); - else + } + else { return RendererImplementation::Invalid; + } } std::string RenderEngine::progressToStr(int size, double t) { std::string progress = "|"; int g = static_cast((t * (size - 1)) + 1); g = std::max(g, 0); - for (int i = 0; i < g; i++) + for (int i = 0; i < g; i++) { progress.append("-"); + } progress.append(">"); - for (int i = 0; i < size - g; i++) + for (int i = 0; i < size - g; i++) { progress.append(" "); + } progress.append("|"); return progress; } @@ -803,47 +808,53 @@ void RenderEngine::renderInformation() { penPosition.y -= _fontDate->height(); if (_showInfo && _fontDate) { - RenderFontCr(*_fontDate, + RenderFontCr( + *_fontDate, penPosition, "Date: %s", Time::ref().UTC().c_str() ); } if (_showInfo && _fontInfo) { - RenderFontCr(*_fontInfo, - penPosition, - "Simulation increment (s): %.0f", - Time::ref().deltaTime() + RenderFontCr( + *_fontInfo, + penPosition, + "Simulation increment (s): %.0f", + Time::ref().deltaTime() ); FrametimeType frametimeType = FrametimeType(_frametimeType.value()); switch (frametimeType) { case FrametimeType::DtTimeAvg: - RenderFontCr(*_fontInfo, - penPosition, - "Avg. Frametime: %.5f", - OsEng.windowWrapper().averageDeltaTime() + RenderFontCr( + *_fontInfo, + penPosition, + "Avg. Frametime: %.5f", + OsEng.windowWrapper().averageDeltaTime() ); break; case FrametimeType::FPS: - RenderFontCr(*_fontInfo, - penPosition, - "FPS: %3.2f", - 1.0 / OsEng.windowWrapper().deltaTime() + RenderFontCr( + *_fontInfo, + penPosition, + "FPS: %3.2f", + 1.0 / OsEng.windowWrapper().deltaTime() ); break; case FrametimeType::FPSAvg: - RenderFontCr(*_fontInfo, - penPosition, - "Avg. FPS: %3.2f", - 1.0 / OsEng.windowWrapper().averageDeltaTime() + RenderFontCr( + *_fontInfo, + penPosition, + "Avg. FPS: %3.2f", + 1.0 / OsEng.windowWrapper().averageDeltaTime() ); break; default: - RenderFontCr(*_fontInfo, - penPosition, - "Avg. Frametime: %.5f", - OsEng.windowWrapper().averageDeltaTime() + RenderFontCr( + *_fontInfo, + penPosition, + "Avg. Frametime: %.5f", + OsEng.windowWrapper().averageDeltaTime() ); break; } @@ -859,7 +870,8 @@ void RenderEngine::renderInformation() { if (nClients == 1) { connectionInfo = "Hosting session with 1 client"; } else { - connectionInfo = "Hosting session with " + std::to_string(nClients) + " clients"; + connectionInfo = + "Hosting session with " + std::to_string(nClients) + " clients"; } } else if (status == ParallelConnection::Status::ClientWithHost) { nClients--; @@ -872,16 +884,19 @@ void RenderEngine::renderInformation() { status == ParallelConnection::Status::ClientWithoutHost) { connectionInfo += "\n"; if (nClients > 2) { - connectionInfo += "You and " + std::to_string(nClients - 1) + " more clients are tuned in"; + std::string c = std::to_string(nClients - 1); + connectionInfo += "You and " + c + " more clients are tuned in"; } else if (nClients == 2) { - connectionInfo += "You and " + std::to_string(nClients - 1) + " more client are tuned in"; + std::string c = std::to_string(nClients - 1); + connectionInfo += "You and " + c + " more client are tuned in"; } else if (nClients == 1) { connectionInfo += "You are the only client"; } } if (connectionInfo != "") { - RenderFontCr(*_fontInfo, + RenderFontCr( + *_fontInfo, penPosition, connectionInfo.c_str() ); @@ -897,7 +912,6 @@ void RenderEngine::renderInformation() { const Mission& mission = MissionManager::ref().currentMission(); if (mission.phases().size() > 0) { - static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1); //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1); static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1); @@ -998,6 +1012,8 @@ void RenderEngine::renderInformation() { penPosition.y -= _fontInfo->height(); } catch (...) { + // @CLEANUP: This is bad as it will discard all exceptions + // without telling us about it! ---abock } } @@ -1154,8 +1170,9 @@ void RenderEngine::renderInformation() { } void RenderEngine::renderScreenLog() { - if (!_showLog) + if (!_showLog) { return; + } _log->removeExpiredEntries(); @@ -1165,25 +1182,11 @@ void RenderEngine::renderScreenLog() { std::chrono::seconds fade(5); auto entries = _log->entries(); - auto lastEntries = entries.size() > max ? std::make_pair(entries.rbegin(), entries.rbegin() + max) : std::make_pair(entries.rbegin(), entries.rend()); + auto lastEntries = + entries.size() > max ? + std::make_pair(entries.rbegin(), entries.rbegin() + max) : + std::make_pair(entries.rbegin(), entries.rend()); - // if (entries.size() > max) - - //ScreenLog::const_range ScreenLog::last(size_t n) { - // if (_entries.size() > n) { - // return std::make_pair(_entries.rbegin(), _entries.rbegin() + n); - // } else { - // return std::make_pair(_entries.rbegin(), _entries.rend()); - // } - //} - - // auto entries = _log->last(max); - - const glm::vec4 white(0.9, 0.9, 0.9, 1); - const glm::vec4 red(1, 0, 0, 1); - const glm::vec4 yellow(1, 1, 0, 1); - const glm::vec4 green(0, 1, 0, 1); - const glm::vec4 blue(0, 0, 1, 1); size_t nr = 1; auto now = std::chrono::steady_clock::now(); @@ -1209,26 +1212,44 @@ void RenderEngine::renderScreenLog() { const std::string& message = e->message.substr(0, msg_length); nr += std::count(message.begin(), message.end(), '\n'); - RenderFont(*_fontLog, - glm::vec2(10.f, _fontLog->pointSize() * nr * 2), - white * alpha, - "%-14s %s%s", // Format - e->timeString.c_str(), // Time string - e->category.substr(0, category_length).c_str(), // Category string (up to category_length) - e->category.length() > 20 ? "..." : ""); // Pad category with "..." if exceeds category_length + const glm::vec4 White(0.9f, 0.9f, 0.9f, 1.0f); - glm::vec4 color = white; - if (e->level == ghoul::logging::LogLevel::Debug) - color = green; - if (e->level == ghoul::logging::LogLevel::Warning) - color = yellow; - if (e->level == ghoul::logging::LogLevel::Error) - color = red; - if (e->level == ghoul::logging::LogLevel::Fatal) - color = blue; + RenderFont( + *_fontLog, + glm::vec2(10.f, _fontLog->pointSize() * nr * 2), + White * alpha, + "%-14s %s%s", // Format + e->timeString.c_str(), // Time string + e->category.substr(0, category_length).c_str(), // Category string + e->category.length() > 20 ? "..." : ""); // Pad category with "..." + + const glm::vec4 Red(1.f, 0.f, 0.f, 1.f); + const glm::vec4 Yellow(1.f, 1.f, 0.f, 1.f); + const glm::vec4 Green(0.f, 1.f, 0.f, 1.f); + const glm::vec4 Blue(0.f, 0.f, 1.f, 1.f); + + glm::vec4 color(glm::uninitialize); + switch (e->level) { + case ghoul::logging::LogLevel::Debug: + color = Green; + break; + case ghoul::logging::LogLevel::Warning: + color = Yellow; + break; + case ghoul::logging::LogLevel::Error: + color = Red; + break; + case ghoul::logging::LogLevel::Fatal: + color = Blue; + break; + default: + color = White; + break; + } // const float font_with_light = 5; - RenderFont(*_fontLog, + RenderFont( + *_fontLog, glm::vec2(static_cast(10 + 39 * _fontLog->pointSize()), _fontLog->pointSize() * nr * 2), color * alpha, "%s", // Format @@ -1236,7 +1257,7 @@ void RenderEngine::renderScreenLog() { RenderFont(*_fontLog, glm::vec2(static_cast(10 + 53 * _fontLog->pointSize()), _fontLog->pointSize() * nr * 2), - white * alpha, + White * alpha, "%s", // Format message.c_str()); // Pad category with "..." if exceeds category_length ++nr; diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index 4134ce44fc..2806e8eb36 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,27 +26,6 @@ namespace openspace { namespace luascriptfunctions { -/** - * \ingroup LuaScripts - * takeScreenshot(): - * Save the rendering to an image file - */ -int takeScreenshot(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments == 0) { - OsEng.renderEngine().takeScreenshot(); - return 0; - } - else if (nArguments == 1) { - bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().takeScreenshot(b); - return 0; - } - else { - return luaL_error(L, "Expected %i or %i arguments, got %i", 0, 1, nArguments); - } -} - /** * \ingroup LuaScripts * setRenderer(string): @@ -67,44 +46,6 @@ int setRenderer(lua_State* L) { return 0; } -/** -* \ingroup LuaScripts -* setNAaSamples(int): -* set the number of anti-aliasing samples (msaa) -*/ -int setNAaSamples(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } - - double t = luaL_checknumber(L, -1); - - OsEng.renderEngine().setNAaSamples(static_cast(t)); - return 0; -} - - -/** -* \ingroup LuaScripts -* visualizeABuffer(bool): -* Toggle heads-up info display on master node -*/ -int showRenderInformation(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } - - const int type = lua_type(L, -1); - if (type != LUA_TBOOLEAN) { - return luaL_error(L, "Expected argument of type 'bool'"); - } - bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().toggleInfoText(b); - return 0; -} - /** * \ingroup LuaScripts * toggleFade(float): diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index a48ed62025..cc89ab046d 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,35 +24,36 @@ #include +#include +#include #include #include #include #include #include -#include - #ifdef WIN32 - #define _USE_MATH_DEFINES - #include - #endif +#ifdef WIN32 +#define _USE_MATH_DEFINES +#include +#endif namespace { - const std::string _loggerCat = "ScreenSpaceRenderable"; + const char* _loggerCat = "ScreenSpaceRenderable"; - const std::string KeyType = "Type"; - const std::string KeyFlatScreen = "FlatScreen"; - const std::string KeyPosition = "Position"; - const std::string KeyScale = "Scale"; - const std::string KeyDepth = "Depth"; - const std::string KeyAlpha = "Alpha"; + const char* KeyType = "Type"; + const char* KeyFlatScreen = "FlatScreen"; + const char* KeyPosition = "Position"; + const char* KeyScale = "Scale"; + const char* KeyDepth = "Depth"; + const char* KeyAlpha = "Alpha"; const float PlaneDepth = -2.f; } namespace openspace { -Documentation ScreenSpaceRenderable::Documentation() { +documentation::Documentation ScreenSpaceRenderable::Documentation() { using namespace openspace::documentation; return { @@ -72,8 +73,8 @@ Documentation ScreenSpaceRenderable::Documentation() { }; } -ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary( - const ghoul::Dictionary& dictionary) +std::unique_ptr ScreenSpaceRenderable::createFromDictionary( + const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow( Documentation(), @@ -84,7 +85,7 @@ ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary( std::string renderableType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - ScreenSpaceRenderable* result = factory->create(renderableType, dictionary); + std::unique_ptr result = factory->create(renderableType, dictionary); if (result == nullptr) { LERROR("Failed to create a ScreenSpaceRenderable object of type '" << renderableType << "'" @@ -95,9 +96,9 @@ ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary( return result; } - ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary) - : _enabled("enabled", "Is Enabled", true) + : properties::PropertyOwner("") + , _enabled("enabled", "Is Enabled", true) , _useFlatScreen("flatScreen", "Flat Screen", true) , _euclideanPosition( "euclideanPosition", @@ -130,14 +131,15 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary addProperty(_alpha); addProperty(_delete); - dictionary.getValue(KeyFlatScreen, _useFlatScreen); useEuclideanCoordinates(_useFlatScreen); - if (_useFlatScreen) + if (_useFlatScreen) { dictionary.getValue(KeyPosition, _euclideanPosition); - else + } + else { dictionary.getValue(KeyPosition, _sphericalPosition); + } dictionary.getValue(KeyScale, _scale); diff --git a/src/rendering/transferfunction.cpp b/src/rendering/transferfunction.cpp index 5a596fe8c5..edb3e55749 100644 --- a/src/rendering/transferfunction.cpp +++ b/src/rendering/transferfunction.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2015 * + * Copyright (c) 2014-2017 * * * * 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/src/scene/rotation.cpp b/src/scene/rotation.cpp index ac814c8ec2..413a41354e 100644 --- a/src/scene/rotation.cpp +++ b/src/scene/rotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -23,19 +23,22 @@ ****************************************************************************************/ #include + +#include +#include #include + +#include #include -#include - namespace { - const std::string _loggerCat = "Rotation"; - const std::string KeyType = "Type"; + const char* _loggerCat = "Rotation"; + const char* KeyType = "Type"; } namespace openspace { -Documentation Rotation::Documentation() { +documentation::Documentation Rotation::Documentation() { using namespace openspace::documentation; return { @@ -55,12 +58,12 @@ Documentation Rotation::Documentation() { }; } -Rotation* Rotation::createFromDictionary(const ghoul::Dictionary& dictionary) { +std::unique_ptr Rotation::createFromDictionary(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Rotation"); std::string rotationType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - Rotation* result = factory->create(rotationType, dictionary); + std::unique_ptr result = factory->create(rotationType, dictionary); if (result == nullptr) { LERROR("Failed creating Rotation object of type '" << rotationType << "'"); return nullptr; @@ -69,11 +72,13 @@ Rotation* Rotation::createFromDictionary(const ghoul::Dictionary& dictionary) { return result; } -Rotation::Rotation() { - setName("Rotation"); -} +Rotation::Rotation() + : properties::PropertyOwner("Rotation") +{} -Rotation::Rotation(const ghoul::Dictionary& dictionary) {} +Rotation::Rotation(const ghoul::Dictionary& dictionary) + : properties::PropertyOwner("Rotation") +{} Rotation::~Rotation() {} @@ -87,4 +92,4 @@ const glm::dmat3& Rotation::matrix() const { void Rotation::update(const UpdateData& data) {} -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index ef43e0b4f6..868499f3b8 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -23,19 +23,22 @@ ****************************************************************************************/ #include -#include -#include +#include #include +#include + +#include +#include namespace { - const std::string _loggerCat = "Scale"; - const std::string KeyType = "Type"; + const char* _loggerCat = "Scale"; + const char* KeyType = "Type"; } namespace openspace { -Documentation Scale::Documentation() { +documentation::Documentation Scale::Documentation() { using namespace openspace::documentation; return { @@ -57,13 +60,13 @@ Documentation Scale::Documentation() { } -Scale* Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { +std::unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Scale"); std::string scaleType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - Scale* result = factory->create(scaleType, dictionary); + std::unique_ptr result = factory->create(scaleType, dictionary); result->setName("Scale"); if (result == nullptr) { LERROR("Failed creating Scale object of type '" << scaleType << "'"); @@ -73,6 +76,10 @@ Scale* Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { return result; } +Scale::Scale() + : properties::PropertyOwner("Scale") +{} + Scale::~Scale() {} bool Scale::initialize() { @@ -81,4 +88,4 @@ bool Scale::initialize() { void Scale::update(const UpdateData& data) {} -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 28eb1610c3..d890576195 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -57,31 +58,27 @@ #include #include -#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED -#include -#endif - #include "scene_doc.inl" #include "scene_lua.inl" namespace { - const std::string _loggerCat = "Scene"; - const std::string _moduleExtension = ".mod"; - const std::string _commonModuleToken = "${COMMON_MODULE}"; + const char* _loggerCat = "Scene"; + const char* _moduleExtension = ".mod"; + const char* _commonModuleToken = "${COMMON_MODULE}"; - const std::string KeyCamera = "Camera"; - const std::string KeyFocusObject = "Focus"; - const std::string KeyPositionObject = "Position"; - const std::string KeyViewOffset = "Offset"; + const char* KeyCamera = "Camera"; + const char* KeyFocusObject = "Focus"; + const char* KeyPositionObject = "Position"; + const char* KeyViewOffset = "Offset"; - const std::string MainTemplateFilename = "${OPENSPACE_DATA}/web/properties/main.hbs"; - const std::string PropertyOwnerTemplateFilename = "${OPENSPACE_DATA}/web/properties/propertyowner.hbs"; - const std::string PropertyTemplateFilename = "${OPENSPACE_DATA}/web/properties/property.hbs"; - const std::string HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; - const std::string JsFilename = "${OPENSPACE_DATA}/web/properties/script.js"; - const std::string BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; - const std::string CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; -} + const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/properties/main.hbs"; + const char* PropertyOwnerTemplateFilename = "${OPENSPACE_DATA}/web/properties/propertyowner.hbs"; + const char* PropertyTemplateFilename = "${OPENSPACE_DATA}/web/properties/property.hbs"; + const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; + const char* JsFilename = "${OPENSPACE_DATA}/web/properties/script.js"; + const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; + const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; +} // namespace namespace openspace { @@ -148,9 +145,7 @@ void Scene::sortTopologically() { if (!root) { throw Scene::InvalidSceneError("No root node found"); } - - - + std::unordered_map inDegrees; for (SceneGraphNode* node : _topologicallySortedNodes) { size_t inDegree = node->dependencies().size(); @@ -208,7 +203,7 @@ void Scene::initialize() { LWARNING(node->name() << " not initialized."); } catch (const ghoul::RuntimeError& e) { - LERRORC(_loggerCat + "(" + e.component + ")", e.what()); + LERRORC(std::string(_loggerCat) + "(" + e.component + ")", e.what()); } } } @@ -216,7 +211,9 @@ void Scene::initialize() { void Scene::update(const UpdateData& data) { for (auto& node : _topologicallySortedNodes) { try { + LTRACE("Scene::update(begin '" + node->name() + "')"); node->update(data); + LTRACE("Scene::update(end '" + node->name() + "')"); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.what()); @@ -227,7 +224,9 @@ void Scene::update(const UpdateData& data) { void Scene::evaluate(Camera* camera) { for (auto& node : _topologicallySortedNodes) { try { + LTRACE("Scene::evaluate(begin '" + node->name() + "')"); node->evaluate(camera); + LTRACE("Scene::evaluate(end '" + node->name() + "')"); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.what()); @@ -238,7 +237,9 @@ void Scene::evaluate(Camera* camera) { void Scene::render(const RenderData& data, RendererTasks& tasks) { for (auto& node : _topologicallySortedNodes) { try { + LTRACE("Scene::render(begin '" + node->name() + "')"); node->render(data, tasks); + LTRACE("Scene::render(end '" + node->name() + "')"); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.what()); diff --git a/src/scene/scene_doc.inl b/src/scene/scene_doc.inl index 5968782602..c6be2cc5a2 100644 --- a/src/scene/scene_doc.inl +++ b/src/scene/scene_doc.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,11 +22,12 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include #include namespace openspace { -Documentation Scene::Documentation() { +documentation::Documentation Scene::Documentation() { using namespace documentation; return { diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 1a36ae2ded..9d2c2b6d98 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 0207cdc761..56fdcacf17 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,8 +24,6 @@ #include -#include - #include #include #include @@ -33,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +89,7 @@ std::unique_ptr SceneGraphNode::createFromDictionary(const ghoul << result->name() << "'"); return nullptr; } - result->addPropertySubOwner(result->_renderable); + result->addPropertySubOwner(result->_renderable.get()); LDEBUG("Successfully created renderable for '" << result->name() << "'"); } @@ -142,7 +141,8 @@ std::unique_ptr SceneGraphNode::createFromDictionary(const ghoul } SceneGraphNode::SceneGraphNode() - : _parent(nullptr) + : properties::PropertyOwner("") + , _parent(nullptr) , _scene(nullptr) , _transform { std::make_unique(), @@ -184,7 +184,6 @@ bool SceneGraphNode::deinitialize() { if (_renderable) { _renderable->deinitialize(); - delete _renderable; _renderable = nullptr; } _children.clear(); @@ -631,16 +630,18 @@ PowerScaledScalar SceneGraphNode::boundingSphere() const{ return _boundingSphere; } -void SceneGraphNode::setRenderable(Renderable* renderable) { - _renderable = renderable; +// renderable +void SceneGraphNode::setRenderable(std::unique_ptr renderable) { + _renderable = std::move(renderable); } -const Renderable* SceneGraphNode::renderable() const { - return _renderable; +const Renderable* SceneGraphNode::renderable() const +{ + return _renderable.get(); } Renderable* SceneGraphNode::renderable() { - return _renderable; + return _renderable.get(); } /* diff --git a/src/scene/scenegraphnode_doc.inl b/src/scene/scenegraphnode_doc.inl index ba183dd42f..2766c91ee4 100644 --- a/src/scene/scenegraphnode_doc.inl +++ b/src/scene/scenegraphnode_doc.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -22,11 +22,12 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include #include namespace openspace { -Documentation SceneGraphNode::Documentation() { +documentation::Documentation SceneGraphNode::Documentation() { using namespace documentation; return { diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index 0f0c19fefd..2272f5bb40 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,18 +26,19 @@ #include #include +#include #include namespace { - const std::string _loggerCat = "Translation"; - const std::string KeyType = "Type"; + const char* _loggerCat = "Translation"; + const char* KeyType = "Type"; } namespace openspace { -Documentation Translation::Documentation() { - using namespace openspace::documentation; +documentation::Documentation Translation::Documentation() { + using namespace documentation; return { "Transformation Translation", @@ -57,7 +58,9 @@ Documentation Translation::Documentation() { }; } -Translation* Translation::createFromDictionary(const ghoul::Dictionary& dictionary) { +std::unique_ptr Translation::createFromDictionary( + const ghoul::Dictionary& dictionary) +{ if (!dictionary.hasValue(KeyType)) { LERROR("Translation did not have key '" << KeyType << "'"); return nullptr; @@ -67,7 +70,7 @@ Translation* Translation::createFromDictionary(const ghoul::Dictionary& dictiona dictionary.getValue(KeyType, translationType); ghoul::TemplateFactory* factory = FactoryManager::ref().factory(); - Translation* result = factory->create(translationType, dictionary); + std::unique_ptr result = factory->create(translationType, dictionary); result->setName("Translation"); if (result == nullptr) { LERROR("Failed creating Translation object of type '" << translationType << "'"); @@ -77,6 +80,10 @@ Translation* Translation::createFromDictionary(const ghoul::Dictionary& dictiona return result; } +Translation::Translation() + : properties::PropertyOwner("Translation") +{} + Translation::~Translation() {} bool Translation::initialize() { diff --git a/src/scripting/lualibrary.cpp b/src/scripting/lualibrary.cpp index 4aff78390c..359ee27f4e 100644 --- a/src/scripting/lualibrary.cpp +++ b/src/scripting/lualibrary.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 4bb3892a4a..72e9536eeb 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -41,12 +41,12 @@ #include "scriptengine_lua.inl" namespace { - const std::string MainTemplateFilename = "${OPENSPACE_DATA}/web/luascripting/main.hbs"; - const std::string ScriptingTemplateFilename = "${OPENSPACE_DATA}/web/luascripting/scripting.hbs"; - const std::string HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; - const std::string JsFilename = "${OPENSPACE_DATA}/web/luascripting/script.js"; - const std::string BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; - const std::string CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; + const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/luascripting/main.hbs"; + const char* ScriptingTemplateFilename = "${OPENSPACE_DATA}/web/luascripting/scripting.hbs"; + const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; + const char* JsFilename = "${OPENSPACE_DATA}/web/luascripting/script.js"; + const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; + const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; } namespace openspace { @@ -56,40 +56,35 @@ namespace scripting { namespace { const std::string _loggerCat = "ScriptEngine"; - const std::string _openspaceLibraryName = "openspace"; - const std::string _luaGlobalNamespace = "_G"; - const std::string _printFunctionName = "print"; + const char* LuaGlobalNamespace = "_G"; + const char* PrintFunctionName = "print"; //const lua_CFunction _printFunctionReplacement = luascriptfunctions::printInfo; - const int _setTableOffset = -3; // -1 (top) -1 (first argument) -1 (second argument) + const int TableOffset = -3; // -1 (top) -1 (first argument) -1 (second argument) } +std::string ScriptEngine::OpenSpaceLibraryName = "openspace"; + void ScriptEngine::initialize() { LDEBUG("Adding base library"); addBaseLibrary(); - LDEBUG("Creating new Lua state"); - _state = ghoul::lua::createNewLuaState(); LDEBUG("Initializing Lua state"); initializeLuaState(_state); LDEBUG("Remapping Print functions"); remapPrintFunction(); } -void ScriptEngine::deinitialize() { - if (_state) { - lua_close(_state); - _state = nullptr; - } -} +void ScriptEngine::deinitialize() {} void ScriptEngine::initializeLuaState(lua_State* state) { LDEBUG("Create openspace base library"); lua_newtable(state); - lua_setglobal(state, _openspaceLibraryName.c_str()); + lua_setglobal(state, OpenSpaceLibraryName.c_str()); LDEBUG("Add OpenSpace modules"); - for (const LuaLibrary& lib : _registeredLibraries) + for (const LuaLibrary& lib : _registeredLibraries) { registerLuaLibrary(state, lib); + } } void ScriptEngine::addLibrary(LuaLibrary library) { @@ -294,7 +289,7 @@ bool ScriptEngine::parseLibraryAndFunctionNames(std::string &library, std::strin */ bool ScriptEngine::isLibraryNameAllowed(lua_State* state, const std::string& name) { bool result = false; - lua_getglobal(state, _openspaceLibraryName.c_str()); + lua_getglobal(state, OpenSpaceLibraryName.c_str()); const bool hasOpenSpaceLibrary = lua_istable(state, -1); if (!hasOpenSpaceLibrary) { LFATAL("OpenSpace library was not created in initialize method"); @@ -360,7 +355,7 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, const LuaLibrary& libra //ghoul::lua::logStack(_state); lua_pushcfunction(state, p.function); //ghoul::lua::logStack(_state); - lua_settable(state, _setTableOffset); + lua_settable(state, TableOffset); //ghoul::lua::logStack(_state); } } @@ -369,6 +364,13 @@ void ScriptEngine::addBaseLibrary() { LuaLibrary lib = { "", { + { + "printTrace", + &luascriptfunctions::printTrace, + "*", + "Logs the passed value to the installed LogManager with a LogLevel of " + "'Trace'" + }, { "printDebug", &luascriptfunctions::printDebug, @@ -436,14 +438,15 @@ void ScriptEngine::remapPrintFunction() { } bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& library) { - assert(state); + ghoul_assert(state, "State must not be nullptr"); + if (library.functions.empty()) { LERROR("Lua library '" << library.name << "' does not have any functions"); return false; } //ghoul::lua::logStack(_state); - lua_getglobal(state, _openspaceLibraryName.c_str()); + lua_getglobal(state, OpenSpaceLibraryName.c_str()); //ghoul::lua::logStack(_state); if (library.name.empty()) { //ghoul::lua::logStack(_state); @@ -454,8 +457,9 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& librar } else { const bool allowed = isLibraryNameAllowed(state, library.name); - if (!allowed) + if (!allowed) { return false; + } //ghoul::lua::logStack(_state); @@ -464,7 +468,7 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& librar lua_newtable(state); //ghoul::lua::logStack(_state); addLibraryFunctions(state, library, false); - lua_settable(state, _setTableOffset); + lua_settable(state, TableOffset); //ghoul::lua::logStack(_state); //_registeredLibraries.insert(library); diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 7f6e8865df..0f5fe9355b 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -59,6 +59,17 @@ namespace luascriptfunctions { return 0; } + /** + * \ingroup LuaScripts + * printTrace(*): + * Logs the passed value to the installed LogManager with a LogLevel of 'Trace'. + * For Boolean, numbers, and strings, the internal values are printed, for all other + * types, the type is printed instead + */ + int printTrace(lua_State* L) { + return printInternal(ghoul::logging::LogLevel::Trace, L); + } + /** * \ingroup LuaScripts * printDebug(*): diff --git a/src/scripting/scriptscheduler.cpp b/src/scripting/scriptscheduler.cpp index 05eb6fb76e..974db87af5 100644 --- a/src/scripting/scriptscheduler.cpp +++ b/src/scripting/scriptscheduler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -31,6 +31,7 @@ #include #include +#include #include namespace { @@ -46,7 +47,7 @@ namespace openspace { namespace scripting { -openspace::Documentation ScriptScheduler::Documentation() { +documentation::Documentation ScriptScheduler::Documentation() { using namespace openspace::documentation; using TimeVerifier = StringVerifier; diff --git a/src/scripting/scriptscheduler_lua.inl b/src/scripting/scriptscheduler_lua.inl index a041e8a172..cca380d9c0 100644 --- a/src/scripting/scriptscheduler_lua.inl +++ b/src/scripting/scriptscheduler_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/scripting/systemcapabilitiesbinding.cpp b/src/scripting/systemcapabilitiesbinding.cpp new file mode 100644 index 0000000000..6f7b3b7cd7 --- /dev/null +++ b/src/scripting/systemcapabilitiesbinding.cpp @@ -0,0 +1,347 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +using namespace ghoul::lua; +using namespace ghoul::systemcapabilities; + +namespace luascripting { +namespace general { + +int operatingSystem(lua_State* L) { + lua_pushstring(L, CpuCap.operatingSystemString().c_str()); + return 1; +} + +int fullOperatingSystem(lua_State* L) { + lua_pushstring(L, CpuCap.fullOperatingSystem().c_str()); + return 1; +} + +int installedMainMemory(lua_State* L) { + lua_pushnumber(L, CpuCap.installedMainMemory()); + return 1; +} + +int cores(lua_State* L) { + lua_pushnumber(L, CpuCap.cores()); + return 1; +} + +int cacheLineSize(lua_State* L) { + lua_pushnumber(L, CpuCap.cacheLineSize()); + return 1; +} + +int L2Associativity(lua_State* L) { + lua_pushnumber(L, CpuCap.L2Associativity()); + return 1; +} + +int cacheSize(lua_State* L) { + lua_pushnumber(L, CpuCap.cacheSize()); + return 1; +} + +int extensions(lua_State* L) { + lua_pushstring(L, CpuCap.extensions().c_str()); + return 1; + +} + +} // namespace general + +namespace opengl { + +int hasOpenGLVersion(lua_State* L) { + int nArguments = lua_gettop(L); + SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments); + + std::vector v = ghoul::tokenizeString(luaL_checkstring(L, -1)); + if (v.size() != 2 && v.size() != 3) { + LERRORC("hasVersion", ghoul::lua::errorLocation(L) << "Malformed version string"); + return 0; + } + + for (const std::string& i : v) { + for (char c : i) { + if (!std::isdigit(c)) { + LERRORC( + "hasVersion", + ghoul::lua::errorLocation(L) << "Malformed version string" + ); + return 0; + + } + } + } + + int major = std::stoi(v[0]); + int minor = std::stoi(v[1]); + int release = v.size() == 3 ? std::stoi(v[2]) : 0; + Version version = { major, minor, release }; + + bool supported = OpenGLCap.openGLVersion() >= version; + + lua_pushboolean(L, supported); + + return 1; +} + +int openGLVersion(lua_State* L) { + lua_pushstring(L, std::to_string(OpenGLCap.openGLVersion()).c_str()); + return 1; +} + +int glslCompiler(lua_State* L) { + lua_pushstring(L, OpenGLCap.glslCompiler().c_str()); + return 1; +} + +int gpuVendor(lua_State* L) { + lua_pushstring(L, OpenGLCap.gpuVendorString().c_str()); + return 1; +} + +int extensions(lua_State* L) { + const std::vector& extensions = OpenGLCap.extensions(); + + lua_newtable(L); + + for (int i = 1; i <= extensions.size(); ++i) { + lua_pushstring(L, extensions[i].c_str()); + lua_rawseti(L, -2, i); + } + return 1; +} + +int isExtensionSupported(lua_State* L) { + int nArguments = lua_gettop(L); + SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments); + + std::string extension = luaL_checkstring(L, -1); + + lua_pushboolean(L, OpenGLCap.isExtensionSupported(extension)); + return 1; +} + +int maxTextureUnits(lua_State* L) { + lua_pushnumber(L, OpenGLCap.maxTextureUnits()); + return 1; +} + +int max2DTextureSize(lua_State* L) { + lua_pushnumber(L, OpenGLCap.max2DTextureSize()); + return 1; +} + +int max3DTextureSize(lua_State* L) { + lua_pushnumber(L, OpenGLCap.max3DTextureSize()); + return 1; +} + +int maxAtomicCounterBufferBindings(lua_State* L) { + lua_pushnumber(L, OpenGLCap.maxAtomicCounterBufferBindings()); + return 1; +} + +int maxShaderStorageBufferBindings(lua_State* L) { + lua_pushnumber(L, OpenGLCap.maxShaderStorageBufferBindings()); + return 1; +} + +int maxUniformBufferBindings(lua_State* L) { + lua_pushnumber(L, OpenGLCap.maxUniformBufferBindings()); + return 1; +} + + +} // namespace opengl +} // namespace luascripting + +namespace openspace { +namespace scripting { + +LuaLibrary generalSystemCapabilities() { + return { + "systemCapabilities", + { + { + "operatingSystem", + &luascripting::general::operatingSystem, + "", + "Returns a parsed string of the operating system type, for example " + "Windows, Linux, MacOS, or others, together with the specific version, " + "where available." + }, + { + "fullOperatingSystem", + &luascripting::general::fullOperatingSystem, + "", + "Returns the operating system as a string. The exact format of the " + "returned string is implementation and operating system-dependent but it " + "should contain the manufacturer and the version." + }, + { + "installedMainMemory", + &luascripting::general::installedMainMemory, + "", + "Returns the amount of available, installed main memory (RAM) on the " + "system in MB." + }, + { + "cores", + &luascripting::general::cores, + "", + "Returns the number of cores." + }, + { + "cacheLineSize", + &luascripting::general::cacheLineSize, + "", + "Returns the cache line size." + }, + { + "L2Associativity", + &luascripting::general::L2Associativity, + "", + "Returns the L2 associativity." + }, + { + "cacheSize", + &luascripting::general::cacheSize, + "", + "Returns the cache size." + }, + { + "extensions", + &luascripting::general::extensions, + "", + "Returns all supported exteions as comma-separated string." + } + } + }; +} + +LuaLibrary openglSystemCapabilities() { + return { + "openglCapabilities", + { + { + "hasOpenGLVersion", + &luascripting::opengl::hasOpenGLVersion, + "string", + "Tests whether the current instance supports the passed OpenGL version. " + "The parameter has to have the form 'X.Y' or 'X.Y.Z'." + }, + { + "openGLVersion", + &luascripting::opengl::openGLVersion, + "", + "Returns the maximum OpenGL version that is supported on this platform." + }, + { + "glslCompiler", + &luascripting::opengl::glslCompiler, + "", + "Returns the value of a call to glGetString(GL_VENDOR). " + "This will give detailed information about the vendor of the main " + "graphics card. This string can be used if the automatic Vendor " + "detection failed." + }, + { + "gpuVendor", + &luascripting::opengl::gpuVendor, + "", + "Returns the vendor of the main graphics card." + }, + { + "extensions", + &luascripting::opengl::extensions, + "", + "Returns all available extensions as a list of names." + }, + { + "isExtensionSupported", + &luascripting::opengl::isExtensionSupported, + "string", + "Checks is a specific extension is supported or not." + }, + { + "maxTextureUnits", + &luascripting::opengl::maxTextureUnits, + "", + "Returns the maximum number of texture units that are available on the " + "main graphics card." + }, + { + "max2DTextureSize", + &luascripting::opengl::max2DTextureSize, + "", + "Returns the largest dimension for a 2D texture on this graphics card." + }, + { + "max3DTextureSize", + &luascripting::opengl::max3DTextureSize, + "", + "Returns the largest dimension for a 3D texture on this graphics card." + }, + { + "maxAtomicCounterBufferBindings", + &luascripting::opengl::maxAtomicCounterBufferBindings, + "", + "Returns the maximum number of atomic counter buffer bindings that are " + "available on the main graphics card." + }, + { + "maxShaderStorageBufferBindings", + &luascripting::opengl::maxShaderStorageBufferBindings, + "", + "Returns the maximum number of shader storage bindings that are " + "available on the main graphics card." + }, + { + "maxUniformBufferBindings", + &luascripting::opengl::maxUniformBufferBindings, + "", + "Returns the maximum number of uniform buffer bindings that are " + "available on the main graphics card." + } + } + }; +} + +} // namespace scripting +} // namespace openspace diff --git a/src/util/blockplaneintersectiongeometry.cpp b/src/util/blockplaneintersectiongeometry.cpp index 92e7bc2537..a3e5bcb2eb 100644 --- a/src/util/blockplaneintersectiongeometry.cpp +++ b/src/util/blockplaneintersectiongeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -26,7 +26,7 @@ #include -#include +#include #include #include diff --git a/src/util/boxgeometry.cpp b/src/util/boxgeometry.cpp index ded5c4c954..fbb795981c 100644 --- a/src/util/boxgeometry.cpp +++ b/src/util/boxgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/camera.cpp b/src/util/camera.cpp index a1725f8d04..20ab863a52 100644 --- a/src/util/camera.cpp +++ b/src/util/camera.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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. * + ****************************************************************************************/ // open space includes #include diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index 4d979bbad6..3c13b6fcc8 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -30,15 +30,16 @@ #include #include +#include namespace { - const std::string MainTemplateFilename = "${OPENSPACE_DATA}/web/factories/main.hbs"; - const std::string FactoryTemplateFilename = "${OPENSPACE_DATA}/web/factories/factory.hbs"; - const std::string HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; - const std::string JsFilename = "${OPENSPACE_DATA}/web/factories/script.js"; - const std::string BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; - const std::string CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; -} + const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/factories/main.hbs"; + const char* FactoryTemplateFilename = "${OPENSPACE_DATA}/web/factories/factory.hbs"; + const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js"; + const char* JsFilename = "${OPENSPACE_DATA}/web/factories/script.js"; + const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css"; + const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css"; +} // namespace namespace openspace { diff --git a/src/util/gpudata.cpp b/src/util/gpudata.cpp index 1aa901f8b3..b362bb2dc6 100644 --- a/src/util/gpudata.cpp +++ b/src/util/gpudata.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -28,7 +28,8 @@ namespace openspace { -void UniformLocation::bind(ProgramObject* program, const std::string& name){ +void UniformLocation::bind(ghoul::opengl::ProgramObject* program, const std::string& name) +{ _uniformLocation = program->uniformLocation(name); } diff --git a/src/util/histogram.cpp b/src/util/histogram.cpp index 31600c1b0b..395396c217 100644 --- a/src/util/histogram.cpp +++ b/src/util/histogram.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2015 * + * Copyright (c) 2014-2017 * * * * 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/src/util/keys.cpp b/src/util/keys.cpp index ecf3d2b65d..108f64fff8 100644 --- a/src/util/keys.cpp +++ b/src/util/keys.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 @@ -65,7 +65,7 @@ KeyModifier operator|(KeyModifier lhs, KeyModifier rhs) { return static_cast( static_cast>(lhs) | static_cast>(rhs) - ); + ); } KeyModifier operator|=(KeyModifier& lhs, KeyModifier rhs) { @@ -82,8 +82,9 @@ KeyWithModifier stringToKey(std::string str) { // default is unknown Key k = Key::Unknown; auto it = KeyMapping.find(tokens.back()); - if (it != KeyMapping.end()) + if (it != KeyMapping.end()) { k = it->second; + } KeyModifier m = KeyModifier::NoModifier; @@ -92,10 +93,12 @@ KeyWithModifier stringToKey(std::string str) { tokens.end() - 1, [&m](const std::string& s) { auto it = KeyModifierMapping.find(s); - if (it != KeyModifierMapping.end()) + if (it != KeyModifierMapping.end()) { m |= it->second; - else + } + else { LERROR("Unknown modifier key '" << s << "'"); + } } ); @@ -103,10 +106,12 @@ KeyWithModifier stringToKey(std::string str) { } bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs) { - if (lhs.modifier == rhs.modifier) + if (lhs.modifier == rhs.modifier) { return lhs.key < rhs.key; - else + } + else { return lhs.modifier < rhs.modifier; + } } } // namespace openspace @@ -115,8 +120,9 @@ namespace std { std::string to_string(openspace::Key key) { for (const auto& p : openspace::KeyMapping) { - if (p.second == key) + if (p.second == key) { return p.first; + } } ghoul_assert(false, "Missing key in KeyMapping"); } @@ -124,8 +130,9 @@ std::string to_string(openspace::Key key) { std::string to_string(openspace::KeyModifier mod) { using namespace openspace; - if (mod == KeyModifier::NoModifier) + if (mod == KeyModifier::NoModifier) { return ""; + } std::string result; for (const auto& p : KeyModifierMapping) { @@ -139,10 +146,12 @@ std::string to_string(openspace::KeyModifier mod) { } std::string to_string(openspace::KeyWithModifier key) { - if (key.modifier == openspace::KeyModifier::NoModifier) + if (key.modifier == openspace::KeyModifier::NoModifier) { return to_string(key.key); - else + } + else { return to_string(key.modifier) + "+" + to_string(key.key); + } } } // namespace std diff --git a/src/util/openspacemodule.cpp b/src/util/openspacemodule.cpp index c326e3256c..b4ef33b833 100644 --- a/src/util/openspacemodule.cpp +++ b/src/util/openspacemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,23 +24,23 @@ #include +#include + #include #include #include namespace { - const std::string _loggerCat = "OpenSpaceModule"; - const std::string ModuleBaseToken = "MODULE_"; + const char* _loggerCat = "OpenSpaceModule"; + const char* ModuleBaseToken = "MODULE_"; } namespace openspace { -OpenSpaceModule::OpenSpaceModule(std::string name) { - ghoul_assert(!name.empty(), "Name must not be empty"); - - setName(name); -} +OpenSpaceModule::OpenSpaceModule(std::string name) + : properties::PropertyOwner(std::move(name)) +{} void OpenSpaceModule::initialize() { std::string upperName = name(); @@ -63,13 +63,15 @@ void OpenSpaceModule::deinitialize() { internalDeinitialize(); } -std::vector OpenSpaceModule::documentations() const { +std::vector OpenSpaceModule::documentations() const { + return {}; +} + +scripting::LuaLibrary OpenSpaceModule::luaLibrary() const { return {}; } -ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version -OpenSpaceModule::requiredOpenGLVersion() const -{ +ghoul::systemcapabilities::Version OpenSpaceModule::requiredOpenGLVersion() const { return { 3, 3 }; } @@ -77,8 +79,9 @@ std::string OpenSpaceModule::modulePath() const { std::string moduleName = name(); std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), tolower); - if (FileSys.directoryExists("${MODULES}/" + moduleName)) + if (FileSys.directoryExists("${MODULES}/" + moduleName)) { return absPath("${MODULES}/" + moduleName); + } #ifdef EXTERNAL_MODULES_PATHS diff --git a/src/util/powerscaledcoordinate.cpp b/src/util/powerscaledcoordinate.cpp index c86544d48f..aa0595b305 100644 --- a/src/util/powerscaledcoordinate.cpp +++ b/src/util/powerscaledcoordinate.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/powerscaledscalar.cpp b/src/util/powerscaledscalar.cpp index 4828e3d97d..dcf78e00e0 100644 --- a/src/util/powerscaledscalar.cpp +++ b/src/util/powerscaledscalar.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/powerscaledsphere.cpp b/src/util/powerscaledsphere.cpp index 0373332a7a..9d646a78ec 100644 --- a/src/util/powerscaledsphere.cpp +++ b/src/util/powerscaledsphere.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/progressbar.cpp b/src/util/progressbar.cpp index d38dd33c82..3d9b78d76b 100644 --- a/src/util/progressbar.cpp +++ b/src/util/progressbar.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -42,7 +42,7 @@ ProgressBar::~ProgressBar() { } void ProgressBar::print(int current) { - float progress = static_cast(current) / static_cast(_end - 1); + float progress = static_cast(current) / static_cast(_end); int iprogress = static_cast(progress*100.0f); if (iprogress != _previous) { int pos = static_cast(static_cast(_width)* progress); diff --git a/src/util/screenlog.cpp b/src/util/screenlog.cpp index 6299b87a7b..d6fff903f4 100644 --- a/src/util/screenlog.cpp +++ b/src/util/screenlog.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index dbaf862d15..c0fa008399 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/spicemanager_lua.inl b/src/util/spicemanager_lua.inl index 87e8c58e3a..b820f3078c 100644 --- a/src/util/spicemanager_lua.inl +++ b/src/util/spicemanager_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/syncbuffer.cpp b/src/util/syncbuffer.cpp index ceb0886476..a870486251 100644 --- a/src/util/syncbuffer.cpp +++ b/src/util/syncbuffer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/syncdata.cpp b/src/util/syncdata.cpp index dbbb4b8f11..83e25d0c85 100644 --- a/src/util/syncdata.cpp +++ b/src/util/syncdata.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/task.cpp b/src/util/task.cpp new file mode 100644 index 0000000000..891614c1c2 --- /dev/null +++ b/src/util/task.cpp @@ -0,0 +1,68 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace openspace { + +documentation::Documentation Task::documentation() { + using namespace documentation; + return { + "Task", + "core_task", + { + { + "Type", + new StringAnnotationVerifier("A valid Task created by a factory"), + "This key specifies the type of Task that gets created. It has to be one" + "of the valid Tasks that are available for creation (see the " + "FactoryDocumentation for a list of possible Tasks), which depends on " + "the configration of the application", + Optional::No + } + } + }; +} + +std::unique_ptr Task::createFromDictionary(const ghoul::Dictionary& dictionary) { + openspace::documentation::testSpecificationAndThrow( + documentation::Documentation(), + dictionary, + "Task" + ); + + std::string taskType = dictionary.value("Type"); + auto factory = FactoryManager::ref().factory(); + + std::unique_ptr task = factory->create(taskType, dictionary); + return task; +} + +} // namespace openspace diff --git a/src/util/taskloader.cpp b/src/util/taskloader.cpp new file mode 100644 index 0000000000..b2867d27eb --- /dev/null +++ b/src/util/taskloader.cpp @@ -0,0 +1,87 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +namespace { + const char* _loggerCat = "TaskRunner"; +} + +namespace openspace { + +std::vector> TaskLoader::tasksFromDictionary(const ghoul::Dictionary& tasksDictionary) { + std::vector> tasks; + std::vector keys = tasksDictionary.keys(); + for (const std::string key : keys) { + std::string taskName; + ghoul::Dictionary subTask; + if (tasksDictionary.getValue(key, taskName)) { + std::string path = "${TASKS}/" + taskName + ".task"; + std::vector> subTasks = tasksFromFile(path); + std::move(subTasks.begin(), subTasks.end(), std::back_inserter(tasks)); + } else if (tasksDictionary.getValue(key, subTask)) { + std::string taskType = subTask.value("Type"); + std::unique_ptr task = Task::createFromDictionary(subTask); + if (task == nullptr) { + LERROR("Failed to create a Task object of type '" << taskType << "'"); + } + tasks.push_back(std::move(task)); + } + } + return tasks; +} + +std::vector> TaskLoader::tasksFromFile(const std::string& path) { + std::string absTasksFile = absPath(path); + using RawPath = ghoul::filesystem::FileSystem::RawPath; + if (!FileSys.fileExists(absTasksFile, RawPath::Yes)) { + LERROR("Could not load tasks file '" << absTasksFile << "'. " << + "File not found"); + return std::vector>(); + } + + ghoul::Dictionary tasksDictionary; + try { + ghoul::lua::loadDictionaryFromFile( + absTasksFile, + tasksDictionary + ); + } catch (...) { + LERROR("Could not load tasks file '" << absTasksFile << "'. " << + "Lua parse error"); + return std::vector>(); + } + return tasksFromDictionary(tasksDictionary); +} + +} // namespace openspace diff --git a/src/util/time.cpp b/src/util/time.cpp index 89204ab623..1d3fd6ba02 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/time_lua.inl b/src/util/time_lua.inl index 3a5a935d69..1b1d6f5e06 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/src/util/timemanager.cpp b/src/util/timemanager.cpp index c70ca0d934..d99aed73f7 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 @@ -35,7 +35,7 @@ namespace openspace { using datamessagestructures::TimeKeyframe; void TimeManager::preSynchronization(double dt) { - double now = OsEng.runTime(); +// double now = OsEng.runTime(); removeKeyframesBefore(_latestConsumedTimestamp); if (_keyframes.size() == 0) { Time::ref().advanceTime(dt); @@ -150,4 +150,4 @@ bool TimeManager::compareKeyframeTimes(const TimeKeyframe& a, const TimeKeyframe return a._timestamp < b._timestamp; } -} \ No newline at end of file +} diff --git a/src/util/timerange.cpp b/src/util/timerange.cpp index 1df1c08661..5569cfab75 100644 --- a/src/util/timerange.cpp +++ b/src/util/timerange.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -24,6 +24,7 @@ #include +#include #include #include @@ -36,7 +37,7 @@ namespace { namespace openspace { -openspace::Documentation TimeRange::Documentation() { +documentation::Documentation TimeRange::Documentation() { using namespace documentation; return { "Time Range", diff --git a/src/util/transformationmanager.cpp b/src/util/transformationmanager.cpp index 0838c1318c..53a975f09b 100644 --- a/src/util/transformationmanager.cpp +++ b/src/util/transformationmanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -21,6 +21,7 @@ * 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 diff --git a/support/cmake/module_common.cmake b/support/cmake/module_common.cmake index db2d954043..74e58d6c4e 100644 --- a/support/cmake/module_common.cmake +++ b/support/cmake/module_common.cmake @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2016 # +# Copyright (c) 2014-2017 # # # # 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/support/cmake/module_definition.cmake b/support/cmake/module_definition.cmake index fc8da28aa2..a060121f17 100644 --- a/support/cmake/module_definition.cmake +++ b/support/cmake/module_definition.cmake @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2016 # +# Copyright (c) 2014-2017 # # # # 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/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index ce84b0d9c8..c97971b989 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2016 # +# Copyright (c) 2014-2017 # # # # 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 # @@ -179,7 +179,11 @@ function (add_external_dependencies) # Unfortunately, we have to set this value manually; sigh # In the future, if the Qt version is updated, just add to this variable ---abock if (APPLE) - set(CMAKE_PREFIX_PATH "~/Qt/5.6/clang_64/lib/cmake" PARENT_SCOPE) + set(CMAKE_PREFIX_PATH + "~/Qt/5.6/clang_64/lib/cmake" + "~/Qt/5.7/clang_64/lib/cmake" + PARENT_SCOPE + ) endif () endfunction () diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py new file mode 100644 index 0000000000..c8b6bb2604 --- /dev/null +++ b/support/coding/check_style_guide.py @@ -0,0 +1,406 @@ +""" +OpenSpace + +Copyright (c) 2014-2017 + +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. + + +This script traverses the file tree of OpenSpace and will check all files' include +guards for correctness. At the moment this includes: + * Correctness (file has a #ifndef. #define, and #endif lines) + * Equality (using the same name for the #ifdef and #define) + * Styling + * no empty line between #ifndef and #define lines + * Empty lines before and after #ifndef #define block + * Files end with an empty line + * Copyright header is correctly indented + * Include guard correctly uses the filename + * Include guard is all upper case + * Correct usage of the name in the final comment of the file + * Correct year of copyright notice + * Naming convention + * OpenSpace include guards start with OPENSPACE, Ghoul with GHOUL, + module includes have the module name in it + * The correct submodule is used + * Checking for duplicates between all files + * Checking that no file includes glm header directly + +If this script is executed from the base directory of OpenSpace, no arguments need to +be passed, otherwise the first and only argument has to point to the base directory. +Thus, the default value of the first argument is '.' +""" + +import fnmatch +import glob +import os +import re +import sys + +current_year = '2017' + +def get_ifndef_symbol(lines): + index = [i for i,s in enumerate(lines) if '#ifndef ' in s] + + if len(index) == 0: + return '', -1 + + result = re.search('#ifndef (.*)\n', lines[index[0]]) + return result.group(1), index[0] + + + +def get_define_symbol(lines): + index = [i for i,s in enumerate(lines) if '#define ' in s] + + if len(index) == 0: + return '', -1 + + result = re.search('#define (.*)\n', lines[index[0]]) + return result.group(1), index[0] + + + +def check_correctness(lines): + ifndef_symbol, line_number = get_ifndef_symbol(lines) + if line_number == -1: + return 'No #ifndef in file' + + define_symbol, line_number = get_define_symbol(lines) + if (line_number == -1): + return 'No #define in file' + + index = [i for i,s in enumerate(lines) if '#endif' in s] + if len(index) == 0: + return 'No #endif in file' + + return '' + + + +def check_equality(lines): + ifndef, _ = get_ifndef_symbol(lines) + define, _ = get_define_symbol(lines) + + if ifndef == define: + return '' + else: + return ifndef + ' ' + define + + + +def check_styling(lines): + ifndef_symbol, ifndef_line = get_ifndef_symbol(lines) + _, define_line = get_define_symbol(lines) + + if abs(ifndef_line - define_line) != 1: + return '#ifndef and #define lines are not subsequent' + + if lines[ifndef_line - 1].strip() != '': + return 'Preceding line is not empty' + + if lines[define_line + 1].strip() != '': + return 'Following line is not empty' + + if not lines[-1][-1] in ['\n', '\r']: + return 'Last line must end with a newline' + + for l in lines[2:23]: + if l[0] != ' ': + return 'Copyright header must be indented' + + if ifndef_symbol != ifndef_symbol.upper(): + return 'Include guard is not all upper case' + + return '' + + + +def check_styling_filename(lines, filename): + ifndef_symbol, _ = get_ifndef_symbol(lines) + file = os.path.splitext(os.path.basename(filename))[0].upper() + + if not (file in ifndef_symbol or file in ifndef_symbol.replace('_', '')): + return 'Malformed include guard: ' + ifndef_symbol + ' || ' + file + + + +def check_comment(lines): + ifndef_symbol, _ = get_ifndef_symbol(lines) + + index = [i for i,s in enumerate(lines) if '#endif' in s] + endif_line = lines[index[-1]].strip() + + if endif_line != '#endif // ' + ifndef_symbol: + return '#endif line is not correctly formatted' + else: + return '' + + + +def check_copyright(lines): + index = [i for i,s in enumerate(lines[0:23]) if 'Copyright' in s] + + if len(index) == 0: + return 'No copyright header found' + + beginning_string = ' * Copyright (c) 2012-' + # * Copyright (c) 2014- + + year = lines[index[0]][len(beginning_string) : len(beginning_string) + 4] + + if year != current_year: + return 'Out of date copyright notice ' + year + ' || ' + current_year + + if lines[index[0] + 1][0] != ' ': + return 'Copyright header is not correctly indented' + + return '' + + + +def check_naming_convention_component(lines, component): + ifndef_symbol, _ = get_ifndef_symbol(lines) + + component_part = ifndef_symbol[2:2 + len(component)] + + if component_part != component.upper(): + return '#ifndef naming convention broken: ' + ifndef_symbol + ' || ' + component.upper() + else: + return '' + + + +def check_naming_convention_subcomponent(lines, component, file): + ifndef_symbol, _ = get_ifndef_symbol(lines) + + if component == "ghoul" or component == "openspace_core": + return + + subcomponent_part = ifndef_symbol[2 + len(component) + 1 :] + subcomponent_part = subcomponent_part[: subcomponent_part.find('_')] + + path_part = file.split(os.sep)[2] + + if path_part.upper() != subcomponent_part: + return 'Subcomponent naming convention broken: ' + ifndef_symbol + else: + return '' + + + +def check_duplicates(lines, previousSymbols): + ifndef_symbol, _ = get_ifndef_symbol(lines) + + if ifndef_symbol in previousSymbols: + return False, ifndef_symbol + else: + return True, ifndef_symbol + + + +def check_glm_header(lines, file): + Allowed_Files = [ + 'ghoul/glm.h' + ] + + for f in Allowed_Files: + if f in file: + return '' + + index = [i for i,s in enumerate(lines) + if '#include ' in s or + '#include "glm/glm.hpp>"' in s] + + if len(index) > 0: + return 'File used wrong glm include. Use "#include " instead' + else: + return '' + +def check_core_dependency(lines, component): + if component != "openspace_core": + return '' + + index = [i for i,s in enumerate(lines) if 'OPENSPACE_MODULE_' in s] + + if len(index) > 0: + return lines[index[0]][:-1] + else: + return '' + +def check_using_namespace(lines): + index = [i for i,s in enumerate(lines) if "using namespace" in s.strip()] + + if len(index) > 0: + return lines[index[0]] + else: + return '' + + +previousSymbols = {} +def check_header_file(file, component): + with open(file, 'r+') as f: + lines = f.readlines() + + correctness = check_correctness(lines) + if correctness: + print(file, '\t', 'Correctness check failed', '\t', correctness) + return + + equality = check_equality(lines) + if equality: + print(file, '\t', 'Equality check failed', '\t', equality) + return + + styling = check_styling(lines) + if styling: + print(file, '\t', 'Styling check failed', '\t', styling) + return + + styling_filename = check_styling_filename(lines, file) + if styling_filename: + print(file, '\t', 'Filename styling check failed', '\t', styling_filename) + return + + comment = check_comment(lines) + if comment: + print(file, '\t', 'Comment check failed', '\t', comment) + return + + copyright = check_copyright(lines) + if copyright: + print(file, '\t', 'Copyright check failed', '\t', copyright) + return + + naming_component = check_naming_convention_component(lines, component) + if naming_component: + print(file, '\t', 'Naming convention broken', '\t', naming_component) + return + + naming_subcomponent = check_naming_convention_subcomponent(lines, component, file) + if naming_subcomponent: + print(file, '\t', 'Naming convention broken', '\t', naming_subcomponent) + return + + duplicates, symbol = check_duplicates(lines, previousSymbols) + if not duplicates: + print(file, '\t', 'Duplicate include guard', symbol, 'first in', previousSymbols[symbol]) + return + else: + previousSymbols[symbol] = file + + header = check_glm_header(lines, file) + if header: + print(file, '\t', 'Illegal glm header include', header) + return + + core_dependency = check_core_dependency(lines, component) + if core_dependency: + print(file, '\t', 'Wrong dependency (core depends on module)', core_dependency) + + using_namespaces = check_using_namespace(lines) + if using_namespaces: + print(file, '\t', 'Using namespace found in header file') + +def check_inline_file(file, component): + with open(file, 'r+') as f: + lines = f.readlines() + + copyright = check_copyright(lines) + if copyright: + print(file, '\t', 'Copyright check failed', '\t', copyright) + return + + header = check_glm_header(lines, file) + if header: + print(file, '\t', 'Illegal glm header include', header) + return + + core_dependency = check_core_dependency(lines, component) + if core_dependency: + print(file, '\t', 'Wrong dependency (core depends on module)', core_dependency) + + if (not '_doc.inl' in file): + # The _doc.inl files are allowed to use using namespace as they are inclued + # from the cpp files and thus don't leak it + using_namespaces = check_using_namespace(lines) + if using_namespaces: + print(file, '\t', 'Using namespace found in inline file') + + +def check_source_file(file, component): + with open(file, 'r+') as f: + lines = f.readlines() + + header = check_glm_header(lines, file) + if header: + print(file, '\t', 'Illegal glm header include', header) + return + + core_dependency = check_core_dependency(lines, component) + if core_dependency: + print(file, '\t' 'Wrong core dependency', core_dependency) + + copyright = check_copyright(lines) + if copyright: + print(file, '\t', 'Copyright check failed', '\t', copyright) + return + + + + +def check_files(positiveList, negativeList, component, check_function): + files = glob.glob(positiveList, recursive=True) + negativeFiles = glob.glob(negativeList, recursive=True) + + files = [f for f in files if f not in negativeFiles] + + for file in files: + check_function(file, component) + + + + +basePath = './' +if len(sys.argv) > 1: + basePath = sys.argv[1] + '/' + +# Check header files +print("Checking header files") +print("=====================") +check_files(basePath + 'include/**/*.h', '', 'openspace_core', check_header_file) +check_files(basePath + 'apps/**/*.h', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_header_file) +check_files(basePath + 'modules/**/*.h', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_header_file) +check_files(basePath + 'ext/ghoul/include/**/*.h', '', 'ghoul', check_header_file) +print("") + +print("Checking inline files") +print("=====================") +check_files(basePath + 'include/**/*.inl', '', 'openspace_core', check_inline_file) +check_files(basePath + 'src/**/*.inl', '', 'openspace_core', check_inline_file) +check_files(basePath + 'apps/**/*.inl', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_inline_file) +check_files(basePath + 'modules/**/*.inl', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_inline_file) +check_files(basePath + 'ext/ghoul/include/**/*.inl', '', 'ghoul', check_inline_file) +print("") + +print("Checking source files") +print("=====================") +check_files(basePath + 'src/**/*.cpp', '', 'openspace_core', check_source_file) +check_files(basePath + 'apps/**/*.cpp', basePath + 'apps/**/ext/**/*.cpp', 'openspace_app', check_source_file) +check_files(basePath + 'modules/**/*.cpp', basePath + 'modules/**/ext/**/*.cpp', 'openspace_module', check_source_file) +check_files(basePath + 'ext/ghoul/src/**/*.cpp', '', 'ghoul', check_source_file) diff --git a/support/coding/convert_tabs.py b/support/coding/convert_tabs.py index 82813b5858..8e386a81dd 100644 --- a/support/coding/convert_tabs.py +++ b/support/coding/convert_tabs.py @@ -1,7 +1,7 @@ """ OpenSpace -Copyright (c) 2014-2016 +Copyright (c) 2014-2017 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/support/coding/count_includes.py b/support/coding/count_includes.py new file mode 100644 index 0000000000..5fc22f883e --- /dev/null +++ b/support/coding/count_includes.py @@ -0,0 +1,66 @@ +""" +OpenSpace + +Copyright (c) 2014-2017 + +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. + +This file takes the output of compiling in Visual Studio with /showIncludes enabled and +counts the number of times that each header file is included (excluding system headers). +This gives an indicator as to which header files can be made more efficient the most +efficiently + +The script requires one argument, which is the text file of one or many runs of the +Visual Studio compiler +""" + +import sys + +if len(sys.argv) != 2: + print("Usage: count_includes.py #include #include -#include #include //#include @@ -84,7 +83,8 @@ namespace { int main(int argc, char** argv) { std::vector args; - openspace::OpenSpaceEngine::create(argc, argv, std::make_unique(), args); + bool close; + openspace::OpenSpaceEngine::create(argc, argv, std::make_unique(), args, close); testing::InitGoogleTest(&argc, argv); diff --git a/tests/test_aabb.inl b/tests/test_aabb.inl index 8d49293335..b0eb5e00c1 100644 --- a/tests/test_aabb.inl +++ b/tests/test_aabb.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 * @@ -56,8 +56,8 @@ TEST_F(AABBTest, Contains2) { EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2"; EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1"; - EXPECT_EQ(AABBSpatialRelation::Containing, a1.relationTo(a2)) << "a1 contains a2"; - EXPECT_EQ(AABBSpatialRelation::Contained, a2.relationTo(a1)) << "a2 contained by a1"; + EXPECT_EQ(AABB2::AABBSpatialRelation::Containing, a1.relationTo(a2)) << "a1 contains a2"; + EXPECT_EQ(AABB2::AABBSpatialRelation::Contained, a2.relationTo(a1)) << "a2 contained by a1"; } @@ -90,8 +90,8 @@ TEST_F(AABBTest, Intersects2) { EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2"; EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1"; - EXPECT_EQ(AABBSpatialRelation::Intersecting, a1.relationTo(a2)) << "They should intersect"; - EXPECT_EQ(AABBSpatialRelation::Intersecting, a2.relationTo(a1)) << "They should intersect"; + EXPECT_EQ(AABB2::AABBSpatialRelation::Intersecting, a1.relationTo(a2)) << "They should intersect"; + EXPECT_EQ(AABB2::AABBSpatialRelation::Intersecting, a2.relationTo(a1)) << "They should intersect"; } @@ -111,8 +111,8 @@ TEST_F(AABBTest, Contains3) { EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2"; EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1"; - EXPECT_EQ(AABBSpatialRelation::Containing, a1.relationTo(a2)) << "a1 contains a2"; - EXPECT_EQ(AABBSpatialRelation::Contained, a2.relationTo(a1)) << "a2 contained by a1"; + EXPECT_EQ(AABB3::AABBSpatialRelation::Containing, a1.relationTo(a2)) << "a1 contains a2"; + EXPECT_EQ(AABB3::AABBSpatialRelation::Contained, a2.relationTo(a1)) << "a2 contained by a1"; } @@ -133,7 +133,7 @@ TEST_F(AABBTest, Intersects3) { EXPECT_FALSE(a1.contains(a2)) << "a1 should not contain a2"; EXPECT_FALSE(a2.contains(a1)) << "a2 should not contain a1"; - EXPECT_EQ(AABBSpatialRelation::Intersecting, a1.relationTo(a2)) << "They should intersect"; - EXPECT_EQ(AABBSpatialRelation::Intersecting, a2.relationTo(a1)) << "They should intersect"; + EXPECT_EQ(AABB3::AABBSpatialRelation::Intersecting, a1.relationTo(a2)) << "They should intersect"; + EXPECT_EQ(AABB3::AABBSpatialRelation::Intersecting, a2.relationTo(a1)) << "They should intersect"; } diff --git a/tests/test_angle.inl b/tests/test_angle.inl index 9658982f89..5f1746c68e 100644 --- a/tests/test_angle.inl +++ b/tests/test_angle.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_chunknode.inl b/tests/test_chunknode.inl index 35f12a0890..56d29d9b6f 100644 --- a/tests/test_chunknode.inl +++ b/tests/test_chunknode.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_common.inl b/tests/test_common.inl index 60093e7325..460bf019dc 100644 --- a/tests/test_common.inl +++ b/tests/test_common.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_concurrentjobmanager.inl b/tests/test_concurrentjobmanager.inl index a84ab45fee..1938cfbdee 100644 --- a/tests/test_concurrentjobmanager.inl +++ b/tests/test_concurrentjobmanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_concurrentqueue.inl b/tests/test_concurrentqueue.inl index fda05e577d..5aecfe171d 100644 --- a/tests/test_concurrentqueue.inl +++ b/tests/test_concurrentqueue.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_configurationmanager.inl b/tests/test_configurationmanager.inl index a43cf73e9b..e54a198400 100644 --- a/tests/test_configurationmanager.inl +++ b/tests/test_configurationmanager.inl @@ -3,7 +3,7 @@ * GHOUL * * General Helpful Open Utility Library * * * - * Copyright (c) 2012-2016 * + * Copyright (c) 2012-2017 * * * * 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/tests/test_convexhull.inl b/tests/test_convexhull.inl deleted file mode 100644 index df6493ccb5..0000000000 --- a/tests/test_convexhull.inl +++ /dev/null @@ -1,122 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 "gtest/gtest.h" - -#include -#include - -#include -#include - -class ConvexHull2Test : public testing::Test {}; - -TEST_F(ConvexHull2Test, basic) { - using namespace openspace::globebrowsing; - - // points - // 2 x - // 1 x - // 0 x x - // -1 0 1 - - std::vector points = { - { -1.0, 0.0 }, - { 1.0, 0.0 }, - { 0.0, 2.0 }, - { 0.0, 1.0 } - }; - - - // Convex hull - // 2 x - // 1 / \ - // 0 x ___ x - // -1 0 1 - - ConvexHull2 hull = ConvexHull2::grahamScan_NOT_THREAD_SAFE(points); - - - - EXPECT_EQ(3, hull.points().size()) << "Should have 3 points"; - EXPECT_EQ(4, points.size()) << "Should have 4 points"; - -} - -TEST_F(ConvexHull2Test, intersection) { - using namespace openspace::globebrowsing; - std::vector points1 = { - { -1.0, 0.0 }, - { 1.0, 0.0 }, - { 0.0, 2.0 }, - { 0.0, 1.0 } - }; - ConvexHull2 hull1 = ConvexHull2::grahamScan_NOT_THREAD_SAFE(points1); - - std::vector points2 = { - { 0.0, 0.0 }, - { 2.0, 0.0 }, - { 1.0, 2.0 }, - { 1.0, 1.0 } - }; - ConvexHull2 hull2 = ConvexHull2::grahamScan_NOT_THREAD_SAFE(points2); - - - // Convex hull - // 3 - // 2 x x - // 1 / /\ \ - // 0 x _x__x__x - // -1 0 1 2 3 - - EXPECT_TRUE(hull1.intersects(hull2)) << "They should intersect"; -} - - -TEST_F(ConvexHull2Test, non_intersection) { - using namespace openspace::globebrowsing; - std::vector points1 = { - { -2.0, 0.0 }, - { 2.0, 0.0 }, - { 0.0, 2.0 }, - }; - ConvexHull2 hull1 = ConvexHull2::grahamScan_NOT_THREAD_SAFE(points1); - - std::vector points2 = { - { 1.0, 2.0 }, - { 3.0, 0.0 }, - { 5.0, 2.0 } - }; - ConvexHull2 hull2 = ConvexHull2::grahamScan_NOT_THREAD_SAFE(points2); - - - // Convex hull - // 3 - // 2 x x-----------x - // 1 _-' '-_'-_ _-' - // 0 x___________x x - // -2 -1 0 1 2 3 4 5 - - EXPECT_FALSE(hull1.intersects(hull2)) << "They should not intersect"; -} diff --git a/tests/test_documentation.inl b/tests/test_documentation.inl index c14af8d1df..2f1f168c0d 100644 --- a/tests/test_documentation.inl +++ b/tests/test_documentation.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_ellipsoid.inl b/tests/test_ellipsoid.inl index cc7a4aa8e1..a70d5a7ada 100644 --- a/tests/test_ellipsoid.inl +++ b/tests/test_ellipsoid.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_gdalwms.inl b/tests/test_gdalwms.inl index fa082702d8..f1cfc0261d 100644 --- a/tests/test_gdalwms.inl +++ b/tests/test_gdalwms.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_iswamanager.inl b/tests/test_iswamanager.inl index 89541198c5..46299808f0 100644 --- a/tests/test_iswamanager.inl +++ b/tests/test_iswamanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_latlonpatch.inl b/tests/test_latlonpatch.inl index 55eccc9df5..d8e38b3a11 100644 --- a/tests/test_latlonpatch.inl +++ b/tests/test_latlonpatch.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_lrucache.inl b/tests/test_lrucache.inl index 53151b86ee..29000b820c 100644 --- a/tests/test_lrucache.inl +++ b/tests/test_lrucache.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_luaconversions.inl b/tests/test_luaconversions.inl index 0b907d00ad..ef86b6ca6b 100644 --- a/tests/test_luaconversions.inl +++ b/tests/test_luaconversions.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_patchcoverageprovider.inl b/tests/test_patchcoverageprovider.inl index 732a718681..b249bcd701 100644 --- a/tests/test_patchcoverageprovider.inl +++ b/tests/test_patchcoverageprovider.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_powerscalecoordinates.inl b/tests/test_powerscalecoordinates.inl index 946ee7afc4..88f666d9be 100644 --- a/tests/test_powerscalecoordinates.inl +++ b/tests/test_powerscalecoordinates.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_screenspaceimage.inl b/tests/test_screenspaceimage.inl index f031038da7..5f1b724277 100644 --- a/tests/test_screenspaceimage.inl +++ b/tests/test_screenspaceimage.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_scriptscheduler.inl b/tests/test_scriptscheduler.inl index 1dee4d8cc8..0515055c1e 100644 --- a/tests/test_scriptscheduler.inl +++ b/tests/test_scriptscheduler.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_spicemanager.inl b/tests/test_spicemanager.inl index 8fd60a96a8..74c78f0a84 100644 --- a/tests/test_spicemanager.inl +++ b/tests/test_spicemanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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/tests/test_temporaltileprovider.inl b/tests/test_temporaltileprovider.inl index 081d19425d..5ae94b6101 100644 --- a/tests/test_temporaltileprovider.inl +++ b/tests/test_temporaltileprovider.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2017 * * * * 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 *