Test to setup message communication

This commit is contained in:
Ester Lindgren
2021-02-25 11:03:22 +01:00
parent 7c83c4e3da
commit a00013af1c
5 changed files with 77 additions and 29 deletions

View File

@@ -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<std::string> testString;
std::optional<std::string> test;
// [[codegen::verbatim(ZoomInfo.description)]]
std::optional<float> 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<Parameters>(dict);
_testProperty = p.testString.value_or(_testProperty);
_testProperty = p.test.value_or(_testProperty);
_zoomFactor = p.zoom.value_or(_zoomFactor);
/*
auto fBrowser = FactoryManager::ref().factory<ScreenSpaceBrowser>();
ghoul_assert(fBrowser, "No browser factory existed :'-(");

View File

@@ -45,6 +45,8 @@ public:
SkybrowserModule();
virtual ~SkybrowserModule() = default;
float zoomFactor() const;
scripting::LuaLibrary luaLibrary() const override;
//std::vector<documentation::Documentation> documentations() const override;
@@ -52,6 +54,7 @@ protected:
void internalInitialize(const ghoul::Dictionary& dict) override;
properties::StringProperty _testProperty;
properties::FloatProperty _zoomFactor;
};

View File

@@ -3,6 +3,8 @@
#include <openspace/documentation/documentation.h>
#include <modules/skybrowser/skybrowsermodule.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/scripting/scriptengine.h>
#include <ghoul/misc/dictionaryluaformatter.h>
@@ -14,7 +16,7 @@
#include <ghoul/misc/assert.h>
#include <fstream>
#include <sstream>
#include <modules/webbrowser/include/screenspacebrowser.h>
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<ScreenSpaceBrowser*>(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<SkybrowserModule>();
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<std::string>(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