diff --git a/modules/skybrowser/skybrowsermodule.cpp b/modules/skybrowser/skybrowsermodule.cpp index 86954f46df..99ba3bb756 100644 --- a/modules/skybrowser/skybrowsermodule.cpp +++ b/modules/skybrowser/skybrowsermodule.cpp @@ -44,15 +44,24 @@ namespace { constexpr const openspace::properties::Property::PropertyInfo TestInfo = { - "TestInfo", + "Test", "Test Info", "tjobidabidobidabidopp plopp" }; + constexpr const openspace::properties::Property::PropertyInfo ZoomInfo = + { + "Zoom", + "Zoom Info", + "tjobidabidobidabidopp plupp" + }; struct [[codegen::Dictionary(SkybrowserModule)]] Parameters { // [[codegen::verbatim(TestInfo.description)]] - std::optional testString; + std::optional test; + + // [[codegen::verbatim(ZoomInfo.description)]] + std::optional zoom; }; #include "skybrowsermodule_codegen.cpp" @@ -65,10 +74,14 @@ namespace openspace { SkybrowserModule::SkybrowserModule() : OpenSpaceModule(Name) , _testProperty(TestInfo) + , _zoomFactor(ZoomInfo, 70.f ,0.f ,150.f) { addProperty(_testProperty); + addProperty(_zoomFactor); } + + scripting::LuaLibrary SkybrowserModule::luaLibrary() const { scripting::LuaLibrary res; res.name = "skybrowser"; @@ -80,15 +93,28 @@ scripting::LuaLibrary SkybrowserModule::luaLibrary() const { "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" + }, + { + "update", + &skybrowser::luascriptfunctions::updateFunction, + {}, + "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; } +float SkybrowserModule::zoomFactor() const{ + return _zoomFactor; +} + void SkybrowserModule::internalInitialize(const ghoul::Dictionary& dict) { const Parameters p = codegen::bake(dict); - _testProperty = p.testString.value_or(_testProperty); + _testProperty = p.test.value_or(_testProperty); + _zoomFactor = p.zoom.value_or(_zoomFactor); /* auto fBrowser = FactoryManager::ref().factory(); ghoul_assert(fBrowser, "No browser factory existed :'-("); diff --git a/modules/skybrowser/skybrowsermodule.h b/modules/skybrowser/skybrowsermodule.h index 49cba25bb7..aa8c4b2efb 100644 --- a/modules/skybrowser/skybrowsermodule.h +++ b/modules/skybrowser/skybrowsermodule.h @@ -45,6 +45,8 @@ public: SkybrowserModule(); virtual ~SkybrowserModule() = default; + float zoomFactor() const; + scripting::LuaLibrary luaLibrary() const override; //std::vector documentations() const override; @@ -52,6 +54,7 @@ protected: void internalInitialize(const ghoul::Dictionary& dict) override; properties::StringProperty _testProperty; + properties::FloatProperty _zoomFactor; }; diff --git a/modules/skybrowser/skybrowsermodule_lua.inl b/modules/skybrowser/skybrowsermodule_lua.inl index 9a6ae8a79f..d276a6e53c 100644 --- a/modules/skybrowser/skybrowsermodule_lua.inl +++ b/modules/skybrowser/skybrowsermodule_lua.inl @@ -3,6 +3,8 @@ #include #include +#include +#include #include #include @@ -14,7 +16,7 @@ #include #include #include - +#include namespace { constexpr const char _loggerCat[] = "SkybrowserModule"; @@ -23,48 +25,37 @@ namespace { namespace openspace::skybrowser::luascriptfunctions { - bool testFunction() { + int updateFunction(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::updateFunction"); LINFOC(_loggerCat, "yabadadooo"); - return true; - } + ScreenSpaceBrowser* test = dynamic_cast(global::renderEngine->screenSpaceRenderable("ScreenSpaceBowser")); + test->testMessage(); + + return 1; + } int testFunction(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::testFunction"); - + const SkybrowserModule* module = global::moduleEngine->module(); LINFOC(_loggerCat, "hoho"); - testFunction(); + LINFOC(_loggerCat, std::to_string(module->zoomFactor())); //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); + node.setValue("Type", "ScreenSpaceBrowser"s); + node.setValue("Identifier", "ScreenSpaceBowser"s); + node.setValue("Name", "Screen Space Bowser"s); + node.setValue("Url", "http://localhost:8000/?origin=localhost:4690"s); - */ openspace::global::scriptEngine->queueScript( "openspace.addScreenSpaceRenderable(" + ghoul::formatLua(node) + ")", scripting::ScriptEngine::RemoteScripting::Yes diff --git a/modules/webbrowser/include/screenspacebrowser.h b/modules/webbrowser/include/screenspacebrowser.h index 9dd81e0d63..eb484b5d78 100644 --- a/modules/webbrowser/include/screenspacebrowser.h +++ b/modules/webbrowser/include/screenspacebrowser.h @@ -72,6 +72,8 @@ public: void update() override; bool isReady() const override; + void testMessage(); + private: class ScreenSpaceRenderHandler : public WebRenderHandler { public: diff --git a/modules/webbrowser/src/screenspacebrowser.cpp b/modules/webbrowser/src/screenspacebrowser.cpp index a2c4df95fe..dc52e8bc36 100644 --- a/modules/webbrowser/src/screenspacebrowser.cpp +++ b/modules/webbrowser/src/screenspacebrowser.cpp @@ -57,6 +57,32 @@ namespace { namespace openspace { +void ScreenSpaceBrowser::testMessage() { + LINFOC(_loggerCat, "TJOHO"); + //_browserInstance->reshape(glm::ivec2(1000, 1000)); + + std::string mes2 = "var frame = document.getElementsByTagName('iframe')[0].contentWindow; const message : CenterOnCoordinatesMessage = { event: 'center_on_coordinates', ra : Number(50) , dec : Number(70), fov : Number(120), instant : false,}; frame.postMessage(message, 'https://web.wwtassets.org/research/latest/');"; + + //std::string thisFrame = "var frame = window.frames[0]; "; + //std::string iFrame = "var frame = document.getElementsByTagName('iframe')[0].contentWindow;"; + std::string mes3 = "var message = {\ + event: 'center_on_coordinates',\ + ra : Number(80),\ + dec : Number(50),\ + fov : Number(70),\ + instant : false\ + };\ + window.postMessage(message, 'http://localhost:4690');"; + + + CefRefPtr frame = _browserInstance->getBrowser()->GetMainFrame(); + + frame->ExecuteJavaScript(mes3, + frame->GetURL(), 0); + + +} + void ScreenSpaceBrowser::ScreenSpaceRenderHandler::draw() {} void ScreenSpaceBrowser::ScreenSpaceRenderHandler::render() {}