From 7d58cf40c2ea56c6b49bb0473f5c78f4dd36d4a2 Mon Sep 17 00:00:00 2001 From: Ester Lindgren Date: Tue, 23 Feb 2021 14:07:34 +0100 Subject: [PATCH] Add module for skybrowser --- modules/skybrowser/CMakeLists.txt | 50 ++++++++++ modules/skybrowser/skybrowsermodule.cpp | 103 ++++++++++++++++++++ modules/skybrowser/skybrowsermodule.h | 61 ++++++++++++ modules/skybrowser/skybrowsermodule_lua.inl | 78 +++++++++++++++ 4 files changed, 292 insertions(+) create mode 100644 modules/skybrowser/CMakeLists.txt create mode 100644 modules/skybrowser/skybrowsermodule.cpp create mode 100644 modules/skybrowser/skybrowsermodule.h create mode 100644 modules/skybrowser/skybrowsermodule_lua.inl diff --git a/modules/skybrowser/CMakeLists.txt b/modules/skybrowser/CMakeLists.txt new file mode 100644 index 0000000000..04c490df01 --- /dev/null +++ b/modules/skybrowser/CMakeLists.txt @@ -0,0 +1,50 @@ +########################################################################################## +# # +# OpenSpace # +# # +# Copyright (c) 2014-2021 # +# # +# Permission is hereby 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 + + skybrowsermodule.h + +) +source_group("Header Files" FILES ${HEADER_FILES}) + +set(SOURCE_FILES + + skybrowsermodule.cpp + skybrowsermodule_lua.inl + +) +source_group("Source Files" FILES ${SOURCE_FILES}) + + +create_new_module( + "Skybrowser" + skybrowser_module + STATIC + ${HEADER_FILES} ${SOURCE_FILES} +) diff --git a/modules/skybrowser/skybrowsermodule.cpp b/modules/skybrowser/skybrowsermodule.cpp new file mode 100644 index 0000000000..9a8c1c2c55 --- /dev/null +++ b/modules/skybrowser/skybrowsermodule.cpp @@ -0,0 +1,103 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2021 * + * * + * Permission is hereby 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 "skybrowsermodule_lua.inl" + + +namespace { + constexpr const openspace::properties::Property::PropertyInfo TestInfo = + { + "TestInfo", + "Test Info", + "tjobidabidobidabidopp plopp" + }; + + struct [[codegen::Dictionary(SkybrowserModule)]] Parameters { + + // [[codegen::verbatim(TestInfo.description)]] + std::optional testString; + }; + + #include "skybrowsermodule_codegen.cpp" + + +} // namespace + +namespace openspace { + +SkybrowserModule::SkybrowserModule() + : OpenSpaceModule(Name) + , _testProperty(TestInfo) +{ + addProperty(_testProperty); +} + +scripting::LuaLibrary SkybrowserModule::luaLibrary() const { + scripting::LuaLibrary res; + res.name = "skybrowser"; + res.functions = { + { + "test", + &skybrowser::luascriptfunctions::testFunction, + {}, + "string or list of strings", + "Add one or multiple exoplanet systems to the scene, as specified by the " + "input. An input string should be the name of the system host star" + } + }; + + return res; +} + +void SkybrowserModule::internalInitialize(const ghoul::Dictionary& dict) { + const Parameters p = codegen::bake(dict); + _testProperty = p.testString.value_or(_testProperty); + + auto fBrowser = FactoryManager::ref().factory(); + ghoul_assert(fBrowser, "No browser factory existed :'-("); + fBrowser->registerClass("ScreenSpaceBrowser"); +} +/* +std::vector SkybrowserModule::documentations() const { + return { + ExoplanetsDataPreparationTask::documentation(), + RenderableOrbitDisc::Documentation() + }; +} +*/ +} // namespace openspace diff --git a/modules/skybrowser/skybrowsermodule.h b/modules/skybrowser/skybrowsermodule.h new file mode 100644 index 0000000000..6b4eb302ea --- /dev/null +++ b/modules/skybrowser/skybrowsermodule.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2021 * + * * + * Permission is hereby 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_SKYBROWSER___SKYBROWSERMODULE___H__ +#define __OPENSPACE_MODULE_SKYBROWSER___SKYBROWSERMODULE___H__ + + +#include +#include +#include + +#include +#include +#include +#include + + + +namespace openspace { + +class SkybrowserModule : public OpenSpaceModule { +public: + constexpr static const char* Name = "Skybrowser"; + + SkybrowserModule(); + virtual ~SkybrowserModule() = default; + + scripting::LuaLibrary luaLibrary() const override; + //std::vector documentations() const override; + +protected: + void internalInitialize(const ghoul::Dictionary& dict) override; + + properties::StringProperty _testProperty; + +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SKYBROWSER___SKYBROWSERMODULE___H__ diff --git a/modules/skybrowser/skybrowsermodule_lua.inl b/modules/skybrowser/skybrowsermodule_lua.inl new file mode 100644 index 0000000000..676ee684f4 --- /dev/null +++ b/modules/skybrowser/skybrowsermodule_lua.inl @@ -0,0 +1,78 @@ +#include + + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +namespace { + constexpr const char _loggerCat[] = "SkybrowserModule"; +} // namespace + + +namespace openspace::skybrowser::luascriptfunctions { + + bool testFunction() { + LINFOC(_loggerCat, "yabadadooo"); + return true; + } + + + int testFunction(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::testFunction"); + + + LINFOC(_loggerCat, "hoho"); + testFunction(); + + //std::string _url = "https://wallpaperaccess.com/full/3010132.jpg"; + // 'https://cdn.wallpapersafari.com/6/92/0nbCPw.jpg' + /* + // get url from user + const std::string _url = ghoul::lua::value(L, 1); + + using namespace std::string_literals; + + std::string identifier = "ImageTest"; + std::string guiname = "Test"; + double size = 1.E11; + + // create renderable renderableplaneimageonline + ghoul::Dictionary renderable; + renderable.setValue("Type", "RenderablePlaneImageOnline"s); + renderable.setValue("URL", _url); + renderable.setValue("Origin", "Center"s); + renderable.setValue("Size", size); + + ghoul::Dictionary gui; + gui.setValue("Name", guiname); + gui.setValue("Path", "/Software Integration"s); + + ghoul::Dictionary node; + node.setValue("Identifier", identifier); + node.setValue("Renderable", renderable); + node.setValue("GUI", gui); + + + openspace::global::scriptEngine->queueScript( + "openspace.addSceneGraphNode(" + ghoul::formatLua(node) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + */ + + return 1; + } + +} +