diff --git a/data/assets/keybindings/base.asset b/data/assets/keybindings/base.asset index 1e973b6a1c..461827ac32 100644 --- a/data/assets/keybindings/base.asset +++ b/data/assets/keybindings/base.asset @@ -1,3 +1,3 @@ asset.onInitialize(function() - dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')); + dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')); end) \ No newline at end of file diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 893af57f81..28f53541ad 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -102,8 +102,6 @@ public: void scheduleLoadSingleAsset(std::string assetPath); - - void writeDocumentation(); void toggleShutdownMode(); // Guaranteed to return a valid pointer @@ -166,6 +164,10 @@ public: std::function function ); + void writeSceneDocumentation(); + void writeStaticDocumentation(); + + /** * Returns the Lua library that contains all Lua functions available to affect the * application. @@ -182,8 +184,7 @@ private: void loadFonts(); void configureLogging(bool consoleLog); - void writeDocumentations(); - + void runGlobalCustomizationScripts(const std::string& sceneDescription); void configureLogging(); diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 60c0f7071d..66442f6bf0 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -181,8 +181,6 @@ public: */ static scripting::LuaLibrary luaLibrary(); - static documentation::Documentation Documentation(); - private: std::string generateJson() const override; diff --git a/include/openspace/util/asynchttprequest.h b/include/openspace/util/asynchttprequest.h deleted file mode 100644 index 4505906cf4..0000000000 --- a/include/openspace/util/asynchttprequest.h +++ /dev/null @@ -1,136 +0,0 @@ -/***************************************************************************************** -* * -* 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___ASYNCHTTPREQUEST___H__ -#define __OPENSPACE_CORE___ASYNCHTTPREQUEST___H__ - -#include -#include - -namespace openspace { - -class AsncHttpRequestData { -public: - std::chrono::system_clock::time_point startTime(); - std::chrono::system_clock::time_point finishTime(); -private: - std::chrono::system_clock::time_point _startTime; - std::chrono::system_clock::time_point _finishTime; -}; - -class AsyncHttpRequest { -public: - enum class ReadyState : unsigned int { - Unsent, - Loading, - Done - }; - - using StateChangeCallback = std::function; - using ProgressCallback = std::function; - using DataCallback = std::function; - - AsyncHttpRequest( - std::string url, - DataCallback dataCallback); - ~AsyncHttpRequest(); - - virtual std::future start( - StateChangeCallback stateChangeCallback, - ProgressCallback progressCallback); - void wait(); - - std::chrono::system_clock::duration timeElapsed(); - std::chrono::system_clock::duration estimatedTimeRemaining(); - float progress(); - ReadyState readyState(); -private: - std::chrono::system_clock::time_point startTime; - float _progress; -}; - -////// - -class AsncHttpDownloadData : public AsncHttpRequestData { -public: - std::string url(); -private: - std::string _url; -}; - -class AsyncHttpDownload : public AsyncHttpRequest { -public: - AsyncHttpDownload( - std::string url, - std::string path); - virtual ~AsyncHttpDownload(); - - /*std::future start( - StateChangeCallback stateChangeCallback, - ProgressCallback progressCallback) override;*/ -}; - -//// - -class AsyncHttpReadData : public AsncHttpRequestData { -public: - std::vector& buffer(); -private: - std::vector _buffer; -}; - -class AsyncHttpRead : public AsyncHttpRequest { -public: - AsyncHttpRead(std::string url); - ~AsyncHttpRead(); - /*std::future start( - StateChangeCallback stateChangeCallback, - ProgressCallback progressCallback) override;*/ -}; - -} // namespace openspace - -#endif // __OPENSPACE_CORE___ASYNCHTTPREQUEST___H__ - -/* -// start -std::ostream file(); -AsyncHttpDownload d(url, file); -std::future data = d->start(progressCallback, progressCallback); - -// in event loop -AsyncHttpRequest::ReadyState status = d.readyState(); -if (status == AsyncHttpRequest::ReadyState::Loading) { - float progress = d.progress(); - // update some progress bar.. -} - - - - -// usage: - -HTTPDownload (); - -*/ diff --git a/modules/sync/CMakeLists.txt b/modules/sync/CMakeLists.txt index 91bf5a2e15..6b42316261 100644 --- a/modules/sync/CMakeLists.txt +++ b/modules/sync/CMakeLists.txt @@ -42,24 +42,12 @@ set(SOURCE_FILES ) source_group("Source Files" FILES ${SOURCE_FILES}) -# # Libtorrent -# target_include_directories( -# openspace-module-sync -# SYSTEM PUBLIC -# ${CMAKE_CURRENT_SOURCE_DIR}/ext/libtorrent/include -# ) -# target_link_libraries( -# openspace-module-sync -# ${CMAKE_CURRENT_SOURCE_DIR}/ext/libtorrent -# ) - create_new_module( "Sync" sync_module ${HEADER_FILES} ${SOURCE_FILES} ) - ##### # Libtorrent ##### diff --git a/modules/sync/torrentclient.cpp b/modules/sync/torrentclient.cpp index c217193410..b4188f3420 100644 --- a/modules/sync/torrentclient.cpp +++ b/modules/sync/torrentclient.cpp @@ -122,7 +122,10 @@ void TorrentClient::pollAlerts() { } } -TorrentClient::TorrentId TorrentClient::addTorrentFile(std::string torrentFile, std::string destination, TorrentProgressCallback cb) { +TorrentClient::TorrentId TorrentClient::addTorrentFile(std::string torrentFile, + std::string destination, + TorrentProgressCallback cb) +{ std::lock_guard guard(_mutex); if (!_session) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43c265d3be..74b79c49c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,7 +140,6 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/scene/rotation.cpp ${OPENSPACE_BASE_DIR}/src/scene/scale.cpp ${OPENSPACE_BASE_DIR}/src/scene/scene.cpp - ${OPENSPACE_BASE_DIR}/src/scene/scene_doc.inl ${OPENSPACE_BASE_DIR}/src/scene/scene_lua.inl ${OPENSPACE_BASE_DIR}/src/scene/sceneinitializer.cpp ${OPENSPACE_BASE_DIR}/src/scene/scenelicense.cpp diff --git a/src/documentation/core_registration.cpp b/src/documentation/core_registration.cpp index 03c058e98a..febc7c368c 100644 --- a/src/documentation/core_registration.cpp +++ b/src/documentation/core_registration.cpp @@ -58,7 +58,6 @@ void registerCoreClasses(documentation::DocumentationEngine& engine) { engine.addDocumentation(Renderable::Documentation()); engine.addDocumentation(Rotation::Documentation()); engine.addDocumentation(Scale::Documentation()); - engine.addDocumentation(Scene::Documentation()); engine.addDocumentation(SceneGraphNode::Documentation()); engine.addDocumentation(ScreenSpaceRenderable::Documentation()); engine.addDocumentation(TimeRange::Documentation()); diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 8d17cf77e0..4cbc0bec05 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -306,110 +306,6 @@ std::future DownloadManager::fetchFile( return std::async(std::launch::async, downloadFunction); } -/* -std::vector> -DownloadManager::downloadRequestFiles( - const std::string& identifier, const ghoul::filesystem::Directory& destination, - int version, bool overrideFiles, DownloadFinishedCallback, DownloadProgressCallback) -{ - std::vector> futures; - FileSys.createDirectory(destination, ghoul::filesystem::FileSystem::Recursive::Yes); - // TODO: Check s ---abock - // TODO: Escaping is necessary ---abock - const std::string fullRequest =_requestURL.back() + "?" + - RequestIdentifier + "=" + identifier + "&" + - RequestFileVersion + "=" + std::to_string(version) + "&" + - RequestApplicationVersion + "=" + std::to_string(_applicationVersion); - LDEBUG("Request: " << fullRequest); - - std::string requestFile = absPath("${TEMPORARY}/" + identifier); - LDEBUG("Request File: " << requestFile); - - bool isFinished = false; - auto callback = [&](const FileFuture&) { - LDEBUG("Finished: " << requestFile); - std::ifstream temporary(requestFile); - 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 - std::string file = ghoul::filesystem::File( - line, - ghoul::filesystem::File::RawPath::Yes - ).filename(); -#else - std::string file = ghoul::filesystem::File(line).filename(); -#endif - - LDEBUG("\tLine: " << line << " ; Dest: " << destination.path() + "/" + file); - - std::shared_ptr future = downloadFile( - line, - destination.path() + "/" + file, - overrideFiles, - false, - 0, - [](const FileFuture& f) { LDEBUG("Finished: " << f.filePath); } - ); - if (future) { - futures.push_back(future); - } - } - isFinished = true; - }; - - std::shared_ptr f = downloadFile( - fullRequest, - requestFile, - true, - false, - 0, - callback - ); - - while (!isFinished) {} - - return futures; -} - -void DownloadManager::downloadRequestFilesAsync(const std::string& identifier, - const ghoul::filesystem::Directory& destination, int version, bool overrideFiles, - AsyncDownloadFinishedCallback callback) -{ - auto downloadFunction = - [this, identifier, destination, version, overrideFiles, callback]() - { - std::vector> f = downloadRequestFiles( - identifier, - destination, - version, - overrideFiles - ); - - callback(f); - }; - - if (_useMultithreadedDownload) { - using namespace ghoul::thread; - std::thread t = std::thread(downloadFunction); - ghoul::thread::setPriority( - t, ThreadPriorityClass::Idle, ThreadPriorityLevel::Lowest - ); - t.detach(); - } - else { - downloadFunction(); - } -}*/ - void DownloadManager::getFileExtension(const std::string& url, RequestFinishedCallback finishedCallback){ diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 843b6b712b..3249920d67 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -554,7 +554,7 @@ void OpenSpaceEngine::initialize() { // TODO: Maybe move all scenegraph and renderengine stuff to initializeGL scriptEngine().initialize(); - writeDocumentation(); + writeStaticDocumentation(); if (configurationManager().hasKey(ConfigurationManager::KeyShutdownCountdown)) { _shutdown.waitTime = static_cast(configurationManager().value( @@ -758,7 +758,7 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { showTouchbar(); #endif // APPLE - writeDocumentations(); + writeSceneDocumentation(); LTRACE("OpenSpaceEngine::loadScene(end)"); } @@ -775,12 +775,12 @@ void OpenSpaceEngine::deinitialize() { } _navigationHandler->deinitialize(); - _renderEngine->deinitialize(); + _renderEngine->deinitialize(); LTRACE("OpenSpaceEngine::deinitialize(end)"); } -void OpenSpaceEngine::writeDocumentation() { +void OpenSpaceEngine::writeStaticDocumentation() { // If a LuaDocumentationFile was specified, generate it now if (configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentation)) { _scriptEngine->writeDocumentation( @@ -968,7 +968,7 @@ void OpenSpaceEngine::configureLogging(bool consoleLog) { #endif // GHOUL_LOGGING_ENABLE_TRACE } -void OpenSpaceEngine::writeDocumentations() { +void OpenSpaceEngine::writeSceneDocumentation() { // Write keyboard documentation. if (configurationManager().hasKey(ConfigurationManager::KeyKeyboardShortcuts)) { keyBindingManager().writeDocumentation( @@ -1277,7 +1277,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { const bool updated = _assetManager->update(); if (updated) { - writeDocumentations(); + writeSceneDocumentation(); } _renderEngine->updateScene(); diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 4fa56dc839..753fbeb983 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -55,7 +55,8 @@ int writeDocumentation(lua_State* L) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); } - OsEng.writeDocumentation(); + OsEng.writeStaticDocumentation(); + OsEng.writeSceneDocumentation(); return 0; } diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index b26ba3dade..a812a8fac4 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -59,7 +59,6 @@ #include #include -#include "scene_doc.inl" #include "scene_lua.inl" namespace { diff --git a/src/scene/scene_doc.inl b/src/scene/scene_doc.inl deleted file mode 100644 index 2ff166661d..0000000000 --- a/src/scene/scene_doc.inl +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************************** - * * - * 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 { - -documentation::Documentation Scene::Documentation() { - using namespace documentation; - - return { - "Scene Description", - "core_scene", - { - { - "ScenePath", - new StringVerifier, - Optional::Yes, - "The path to the base directory of the scene. The path is considered " - "relative to the location of the scene description file." - }, - { - "CommonFolder", - new StringAnnotationVerifier("A valid scene module folder"), - Optional::Yes, - "The path to the common folder that is loaded and will be bound to the " - "${COMMON_MODULE} path token so that assets can be reused easily." - }, - { - "Camera", - new TableVerifier({ - { - "Focus", - new StringAnnotationVerifier("A valid object in the scene"), - Optional::No, - "The initial focus node of the camera, i.e., the node around which " - "the interaction will be performed." - }, - { - "Position", - new DoubleVector3Verifier, - Optional::Yes, - "The initial camera positive relative to the focus object." - }, - { - "Rotation", - new DoubleVector4Verifier, - Optional::Yes, - "The initial camera rotation expressed as a quaternion." - } - }), - Optional::Yes, - "Definitions of the camera starting parameters, such as focus, location, and " - "orientation." - }, - { - "Assets", - new TableVerifier({ - { - "*", - new StringVerifier, - Optional::No, - "Loadable asset folders. This means that they either have to point " - "to a folder that contains a AssetFile or a folder which contains " - "other folders that eventually contain AssetFile. This second " - "recursive approach is useful for grouping modules into logical " - "units." - } - }), - Optional::Yes, - "This is the list of assets that will be loaded into the initial scene. The " - "values in this table have to correspond to folders relative to the " - "ScenePath key. The order in which the modules are loaded is the same as the " - "order in which they are specified in this table." - } - } - }; -} - -} // namespace openspace