Fixes after merging in new cef version and master

This commit is contained in:
Ylva Selling
2022-03-22 16:01:34 -04:00
parent 83ad7db147
commit 5bbf7d3d33
3 changed files with 266 additions and 436 deletions
+39 -198
View File
@@ -24,17 +24,16 @@
#include <modules/skybrowser/skybrowsermodule.h>
#include <modules/skybrowser/include/renderableskytarget.h>
#include <modules/skybrowser/include/screenspaceskybrowser.h>
#include <modules/skybrowser/include/targetbrowserpair.h>
#include <modules/skybrowser/include/RenderableSkyTarget.h>
#include <modules/skybrowser/include/wwtdatahandler.h>
#include <modules/base/rendering/screenspaceimagelocal.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/camera/camera.h>
#include <openspace/engine/globalscallbacks.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/navigation/navigationhandler.h>
#include <openspace/camera/camera.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/factorymanager.h>
#include "skybrowsermodule_lua.inl"
@@ -76,199 +75,6 @@ namespace {
} // namespace
namespace openspace {
scripting::LuaLibrary SkyBrowserModule::luaLibrary() const {
scripting::LuaLibrary res;
res.name = "skybrowser";
res.functions = {
{
"getListOfImages",
&skybrowser::luascriptfunctions::getListOfImages,
"",
"Returns a list of all the loaded AAS WorldWide Telescope images that "
"have been loaded. Each image has a name, thumbnail url, equatorial "
"spherical coordinates RA and Dec, equatorial Cartesian coordinates, "
"if the image has celestial coordinates, credits text, credits url "
"and the identifier of the image which is a unique number."
},
{
"setHoverCircle",
&skybrowser::luascriptfunctions::setHoverCircle,
"string",
"Takes an identifier to a screen space renderable and adds it to the "
"module."
},
{
"moveCircleToHoverImage",
&skybrowser::luascriptfunctions::moveCircleToHoverImage,
"int",
"Moves the hover circle to the coordinate specified by the image index."
},
{
"disableHoverCircle",
&skybrowser::luascriptfunctions::disableHoverCircle,
"",
"Disables the hover circle, if there is one added to the sky browser "
"module."
},
{
"loadImagesToWWT",
&skybrowser::luascriptfunctions::loadImagesToWWT,
"string",
"Takes an identifier to a sky browser or target and loads the WWT image "
"collection to that browser."
},
{
"selectImage",
&skybrowser::luascriptfunctions::selectImage,
"int",
"Takes an index to an image and selects that image in the currently "
"selected sky browser."
},
{
"removeSelectedImageInBrowser",
&skybrowser::luascriptfunctions::removeSelectedImageInBrowser,
"string, int",
"Takes an identifier to a sky browser or target and an index to an "
"image. Removes that image from that sky browser."
},
{
"adjustCamera",
& skybrowser::luascriptfunctions::adjustCamera,
"string",
"Takes an identifier to a sky browser or sky target. Rotates the camera "
"so that the target is placed in the center of the view."
},
{
"setSelectedBrowser",
& skybrowser::luascriptfunctions::setSelectedBrowser,
"string",
"Takes an identifier to a sky browser or target. Sets that sky browser "
"currently selected."
},
{
"getTargetData",
&skybrowser::luascriptfunctions::getTargetData,
"",
"Returns a table of data regarding the current view and the sky browsers "
"and targets."
},
{
"createTargetBrowserPair",
&skybrowser::luascriptfunctions::createTargetBrowserPair,
"",
"Creates a sky browser and a target."
},
{
"removeTargetBrowserPair",
&skybrowser::luascriptfunctions::removeTargetBrowserPair,
"string",
"Takes in identifier to a sky browser or target and removes them."
},
{
"setOpacityOfImageLayer",
&skybrowser::luascriptfunctions::setOpacityOfImageLayer,
"string, int, double",
"Takes an identifier to a sky browser or sky target, an index to an image"
"and a value for the opacity."
},
{
"sendOutIdsToBrowsers",
&skybrowser::luascriptfunctions::sendOutIdsToBrowsers,
"",
"Sends all sky browsers' identifiers to their respective CEF browser. "
},
{
"initializeBrowser",
&skybrowser::luascriptfunctions::initializeBrowser,
"string",
"Takes an identifier to a sky browser and starts the initialization "
"for that browser. That means that the browser starts to try to connect "
"to the AAS WorldWide Telescope application by sending it messages. And "
"that the target matches its appearance to its corresponding browser."
},
{
"centerTargetOnScreen",
&skybrowser::luascriptfunctions::centerTargetOnScreen,
"string",
"Takes an identifier to a sky browser and animates its corresponding "
"target to the center of the current view."
},
{
"setImageLayerOrder",
&skybrowser::luascriptfunctions::setImageLayerOrder,
"string, int, int",
"Takes an identifier to a sky browser or a sky target, an image index "
"and the order which it should have in the selected image list. The "
"image is then changed to have this order."
},
{
"addPairToSkyBrowserModule",
&skybrowser::luascriptfunctions::addPairToSkyBrowserModule,
"string, string",
"Takes the identifier of the sky target and a sky browser and adds them "
"to the sky browser module."
},
{
"setEquatorialAim",
&skybrowser::luascriptfunctions::setEquatorialAim,
"string, double, double",
"Takes the identifier of a sky browser or a sky target and equatorial "
"coordinates Right Ascension and Declination. The target will animate to "
"this coordinate and the browser will display the coordinate."
},
{
"setVerticalFov",
&skybrowser::luascriptfunctions::setVerticalFov,
"string, float",
"Takes an identifier to a sky browser or a sky target and a vertical "
"field of view. Changes the field of view as specified by the input."
},
{
"setBorderColor",
&skybrowser::luascriptfunctions::setBorderColor,
"string, int, int, int",
"Takes an identifier to a sky browser or a sky target and a rgb color "
"in the ranges [0, 255]."
},
{
"setScreenSpaceSize",
&skybrowser::luascriptfunctions::setScreenSpaceSize,
"string, float, float",
"Sets the screen space size of the sky browser to the numbers specified "
"by the input [x, y]."
},
{
"startSetup",
&skybrowser::luascriptfunctions::startSetup,
"",
"Starts the setup process of the sky browers. This function calls "
"the lua function 'sendOutIdsToBrowsers' in all nodes in the cluster."
},
{
"translateScreenSpaceRenderable",
&skybrowser::luascriptfunctions::translateScreenSpaceRenderable,
"string, float, float, float, float",
"Takes an identifier to a sky browser or sky target and the [x, y] "
"starting position and the [x, y] translation vector."
},
{
"addRenderCopy",
&skybrowser::luascriptfunctions::addRenderCopy,
"string",
"Takes an identifier to a sky browser and adds a rendered copy to it."
},
{
"removeRenderCopy",
&skybrowser::luascriptfunctions::removeRenderCopy,
"string",
"Takes an identifier to a sky browser and removes the latest added "
"rendered copy to it."
},
};
return res;
}
SkyBrowserModule::SkyBrowserModule()
: OpenSpaceModule(SkyBrowserModule::Name)
, _allowMouseInteraction(AllowInteractionInfo, true)
@@ -702,4 +508,39 @@ bool SkyBrowserModule::isSelectedPairFacingCamera() {
return false;
}
}
scripting::LuaLibrary SkyBrowserModule::luaLibrary() const {
return {
"skybrowser",
{
codegen::lua::StartSetup,
codegen::lua::InitializeBrowser,
codegen::lua::SendOutIdsToBrowsers,
codegen::lua::GetListOfImages,
codegen::lua::SetHoverCircle,
codegen::lua::MoveCircleToHoverImage,
codegen::lua::DisableHoverCircle,
codegen::lua::LoadImagesToWWT,
codegen::lua::SelectImage,
codegen::lua::RemoveSelectedImageInBrowser,
codegen::lua::AdjustCamera,
codegen::lua::SetSelectedBrowser,
codegen::lua::GetTargetData,
codegen::lua::CreateTargetBrowserPair,
codegen::lua::RemoveTargetBrowserPair,
codegen::lua::SetOpacityOfImageLayer,
codegen::lua::CenterTargetOnScreen,
codegen::lua::SetImageLayerOrder,
codegen::lua::AddPairToSkyBrowserModule,
codegen::lua::SetEquatorialAim,
codegen::lua::SetVerticalFov,
codegen::lua::SetBorderColor,
codegen::lua::TranslateScreenSpaceRenderable,
codegen::lua::AddRenderCopy,
codegen::lua::SetScreenSpaceSize,
codegen::lua::RemoveRenderCopy
}
};
}
} // namespace openspace
+225 -236
View File
@@ -25,8 +25,8 @@
#include <modules/skybrowser/skybrowsermodule.h>
#include <modules/skybrowser/include/utility.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scripting/scriptengine.h>
@@ -35,14 +35,16 @@
namespace {
constexpr const char _loggerCat[] = "SkyBrowserModule";
} // namespace
namespace openspace::skybrowser::luascriptfunctions {
using namespace openspace;
int selectImage(lua_State* L) {
/**
* Takes an index to an image and selects that image in the currently
* selected sky browser.
* \param i Index of image
*/
[[codegen::luawrap]] void selectImage(int i) {
// Load image
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::selectImage");
const int i = ghoul::lua::value<int>(L, 1);
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
if (module->isCameraInSolarSystem()) {
@@ -53,66 +55,68 @@ int selectImage(lua_State* L) {
LINFO("Loading image " + image.name);
selected->selectImage(image, i);
bool isInView = isCoordinateInView(image.equatorialCartesian);
bool isInView = skybrowser::isCoordinateInView(image.equatorialCartesian);
// If the coordinate is not in view, rotate camera
if (image.hasCelestialCoords && !isInView) {
module->startRotatingCamera(
equatorialToGalactic(
skybrowser::equatorialToGalactic(
image.equatorialCartesian * skybrowser::CelestialSphereRadius
)
);
}
}
}
return 0;
}
int setHoverCircle(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setHoverCircle");
/**
* Takes an identifier to a screen space renderable and adds it to the module.
* \param id Identifier
*/
[[codegen::luawrap]] void setHoverCircle(std::string id) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
std::string id = ghoul::lua::value<std::string>(L, 1);
SceneGraphNode* circle = global::renderEngine->scene()->sceneGraphNode(id);
module->setHoverCircle(circle);
return 0;
}
int moveCircleToHoverImage(lua_State* L) {
/**
* Moves the hover circle to the coordinate specified by the image index.
* \param i Index of image
*/
[[codegen::luawrap]] void moveCircleToHoverImage(int i) {
// Load image
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::moveCircleToHoverImage");
const int i = ghoul::lua::value<int>(L, 1);
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
module->moveHoverCircle(i);
return 0;
}
int disableHoverCircle(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::disableHoverCircle");
/**
* Disables the hover circle, if there is one added to the sky browser
* module.
*/
[[codegen::luawrap]] void disableHoverCircle() {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
module->disableHoverCircle();
return 0;
}
int setImageLayerOrder(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::setImageLayerOrder");
auto [id, i, order] = ghoul::lua::values<std::string, int, int>(L);
/**
* Takes an identifier to a sky browser or a sky target, an image index
* and the order which it should have in the selected image list. The
* image is then changed to have this order.
* \param id Identifier
* \param i Image index
* \param order Order of image
*/
[[codegen::luawrap]] void setImageLayerOrder(std::string id, int i, int order) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
if (module->getPair(id)) {
module->getPair(id)->setImageOrder(i, order);
}
return 0;
}
int loadImagesToWWT(lua_State* L) {
/**
* Takes an identifier to a sky browser or target and loads the WWT image
* collection to that browser.
* \param id Identifier
*/
[[codegen::luawrap]] void loadImagesToWWT(std::string id) {
// Load images from url
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadImagesToWWT");
const std::string id = ghoul::lua::value<std::string>(L, 1);
LINFO("Connection established to WorldWide Telescope application in " + id);
LINFO("Loading image collections to " + id);
@@ -127,14 +131,13 @@ int loadImagesToWWT(lua_State* L) {
module->getPair(id)->hideChromeInterface(true);
module->getPair(id)->loadImageCollection(root);
}
return 0;
}
int startSetup(lua_State* L) {
/**
* Starts the setup process of the sky browers. This function calls
* the lua function 'sendOutIdsToBrowsers' in all nodes in the cluster.
*/
[[codegen::luawrap]] void startSetup() {
// This is called when the sky_browser website is connected to OpenSpace
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::startSetup");
// Set all border colors to the border color in the master node
if (global::windowDelegate->isMaster()) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -162,29 +165,28 @@ int startSetup(lua_State* L) {
"openspace.skybrowser.sendOutIdsToBrowsers();",
scripting::ScriptEngine::RemoteScripting::No
);
return 0;
}
int sendOutIdsToBrowsers(lua_State* L) {
/**
* Sends all sky browsers' identifiers to their respective CEF browser.
*/
[[codegen::luawrap]] void sendOutIdsToBrowsers() {
// This is called when the sky_browser website is connected to OpenSpace
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::sendOutIdsToBrowsers");
// Send out identifiers to the browsers
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
std::vector<std::unique_ptr<TargetBrowserPair>>& pairs = module->getPairs();
for (std::unique_ptr<TargetBrowserPair>& pair : pairs) {
pair->sendIdToBrowser();
}
return 0;
}
int initializeBrowser(lua_State* L) {
/**
* Takes an identifier to a sky browser and starts the initialization
* for that browser. That means that the browser starts to try to connect
* to the AAS WorldWide Telescope application by sending it messages. And
* that the target matches its appearance to its corresponding browser.
* \param id Identifier
*/
[[codegen::luawrap]] void initializeBrowser(std::string id) {
// Initialize browser with ID and its corresponding target
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::initializeBrowser");
const std::string id = ghoul::lua::value<std::string>(L, 1);
LINFO("Initializing sky browser " + id);
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
TargetBrowserPair* found = module->getPair(id);
@@ -192,30 +194,34 @@ int initializeBrowser(lua_State* L) {
found->setIsSyncedWithWwt(true);
found->initialize();
}
return 0;
}
int addPairToSkyBrowserModule(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::addPairToSkyBrowserModule");
auto [targetId, browserId] = ghoul::lua::values<std::string, std::string>(L);
/**
* Takes the identifier of the sky target and a sky browser and adds them
* to the sky browser module.
* \param targetId Identifier of target (either SceneGraphNode or Renderable)
* \param browserId Identifier of browser
*/
[[codegen::luawrap]] void addPairToSkyBrowserModule(std::string targetId, std::string browserId) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
LINFO("Add browser " + browserId + " to sky browser module");
LINFO("Add target " + targetId + " to sky browser module");
module->addTargetBrowserPair(targetId, browserId);
return 0;
}
/**
* Returns a list of all the loaded AAS WorldWide Telescope images that
* have been loaded. Each image has a name, thumbnail url, equatorial
* spherical coordinates RA and Dec, equatorial Cartesian coordinates,
* if the image has celestial coordinates, credits text, credits url
* and the identifier of the image which is a unique number.
*/
int getListOfImages(lua_State* L) {
[[codegen::luawrap]] ghoul::Dictionary getListOfImages() {
// Send image list to GUI
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::getListOfImages");
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
// If no data has been loaded yet, download the data from the web!
if (module->nLoadedImages() == 0) {
std::string root = "https://raw.githubusercontent.com/WorldWideTelescope/"
"wwt-web-client/master/assets/webclient-explore-root.wtml";
@@ -226,79 +232,64 @@ int getListOfImages(lua_State* L) {
}
// Create Lua table to send to the GUI
lua_newtable(L);
ghoul::Dictionary list;
for (int i = 0; i < module->nLoadedImages(); i++) {
const ImageData& img = module->getWwtDataHandler()->getImage(i);
using namespace std::string_literals;
// Index for current ImageData
ghoul::lua::push(L, i + 1);
lua_newtable(L);
// Push ("Key", value)
ghoul::lua::push(L, "name", img.name);
lua_settable(L, -3);
ghoul::lua::push(L, "thumbnail", img.thumbnailUrl);
lua_settable(L, -3);
ghoul::lua::push(L, "ra", img.equatorialSpherical.x);
lua_settable(L, -3);
ghoul::lua::push(L, "dec", img.equatorialSpherical.y);
lua_settable(L, -3);
ghoul::lua::push(L, "cartesianDirection", img.equatorialCartesian);
lua_settable(L, -3);
ghoul::lua::push(L, "hasCelestialCoords", img.hasCelestialCoords);
lua_settable(L, -3);
ghoul::lua::push(L, "credits", img.credits);
lua_settable(L, -3);
ghoul::lua::push(L, "creditsUrl", img.creditsUrl);
lua_settable(L, -3);
ghoul::lua::push(L, "identifier", std::to_string(i));
lua_settable(L, -3);
ghoul::Dictionary image;
image.setValue("name", img.name);
image.setValue("thumbnail", img.thumbnailUrl);
image.setValue("ra", img.equatorialSpherical.x);
image.setValue("dec", img.equatorialSpherical.y);
image.setValue("cartesianDirection", img.equatorialCartesian);
image.setValue("hasCelestialCoords", img.hasCelestialCoords);
image.setValue("credits", img.credits);
image.setValue("creditsUrl", img.creditsUrl);
image.setValue("identifier", std::to_string(i));
// Index for current ImageData
// Set table for the current ImageData
lua_settable(L, -3);
list.setValue(std::to_string(i + 1), image);
}
return 1;
return list;
}
int getTargetData(lua_State* L) {
// Send image list to GUI
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::getTargetData");
/**
* Returns a table of data regarding the current view and the sky browsers
* and targets.
* \return Dictionary of data regarding the current targets
*/
[[codegen::luawrap]] ghoul::Dictionary getTargetData() {
using namespace std::string_literals;
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
lua_newtable(L);
ghoul::Dictionary data;
// Add the window data for OpenSpace
ghoul::lua::push(L, "OpenSpace");
lua_newtable(L);
// The current viewport data for OpenSpace
ghoul::Dictionary openSpace;
// Camera directions
glm::dvec3 cartesianCam = skybrowser::cameraDirectionEquatorial();
glm::dvec2 sphericalCam = skybrowser::cartesianToSpherical(cartesianCam);
// Calculate the smallest FOV of vertical and horizontal
glm::dvec2 fovs = skybrowser::fovWindow();
double FOV = std::min(fovs.x, fovs.y);
// Push window data
ghoul::lua::push(L, "windowHFOV", FOV);
lua_settable(L, -3);
ghoul::lua::push(L, "cartesianDirection", cartesianCam);
lua_settable(L, -3);
ghoul::lua::push(L, "ra", sphericalCam.x);
lua_settable(L, -3);
ghoul::lua::push(L, "dec", sphericalCam.y);
lua_settable(L, -3);
ghoul::lua::push(L, "selectedBrowserId", module->selectedBrowserId());
lua_settable(L, -3);
ghoul::lua::push(L, "selectedTargetId", module->selectedTargetId());
lua_settable(L, -3);
ghoul::lua::push(L, "isFacingCamera", module->isSelectedPairFacingCamera());
lua_settable(L, -3);
ghoul::lua::push(L, "isUsingRadiusAzimuthElevation", module->isSelectedPairUsingRae());
lua_settable(L, -3);
ghoul::lua::push(L, "cameraInSolarSystem", module->isCameraInSolarSystem());
lua_settable(L, -3);
// Set window data
openSpace.setValue("windowHFOV", FOV);
openSpace.setValue("cartesianDirection", cartesianCam);
openSpace.setValue("ra", sphericalCam.x);
openSpace.setValue("dec", sphericalCam.y);
openSpace.setValue("selectedBrowserId", module->selectedBrowserId());
openSpace.setValue("selectedTargetId", module->selectedTargetId());
openSpace.setValue("isFacingCamera", module->isSelectedPairFacingCamera());
openSpace.setValue("isUsingRadiusAzimuthElevation", module->isSelectedPairUsingRae());
openSpace.setValue("cameraInSolarSystem", module->isCameraInSolarSystem());
// Set table for the current ImageData
lua_settable(L, -3);
data.setValue("OpenSpace", openSpace);
// Pass data for all the browsers and the corresponding targets
if (module->isCameraInSolarSystem()) {
@@ -320,85 +311,76 @@ int getTargetData(lua_State* L) {
glm::dvec2 spherical = pair->targetDirectionEquatorial();
glm::dvec3 cartesian = skybrowser::sphericalToCartesian(spherical);
ghoul::lua::push(L, id);
lua_newtable(L);
// Push ("Key", value)
ghoul::lua::push(L, "id", id);
lua_settable(L, -3);
ghoul::lua::push(L, "name", pair->browserGuiName());
lua_settable(L, -3);
ghoul::lua::push(L, "FOV", pair->verticalFov());
lua_settable(L, -3);
ghoul::lua::push(L, "selectedImages", selectedImagesVector);
lua_settable(L, -3);
ghoul::lua::push(L, "cartesianDirection", cartesian);
lua_settable(L, -3);
ghoul::lua::push(L, "ra", spherical.x);
lua_settable(L, -3);
ghoul::lua::push(L, "dec", spherical.y);
lua_settable(L, -3);
ghoul::lua::push(L, "color", pair->borderColor());
lua_settable(L, -3);
ghoul::lua::push(L, "size", pair->size());
lua_settable(L, -3);
ghoul::Dictionary target;
// Set ("Key", value)
target.setValue("id", id);
target.setValue("name", pair->browserGuiName());
target.setValue("FOV", static_cast<double>(pair->verticalFov()));
target.setValue("selectedImages", selectedImagesVector);
target.setValue("cartesianDirection", cartesian);
target.setValue("ra", spherical.x);
target.setValue("dec", spherical.y);
target.setValue("color", pair->borderColor());
target.setValue("size", glm::dvec2(pair->size()));
// Set table for the current target
lua_settable(L, -3);
data.setValue(id, target);
}
}
return 1;
return data;
}
int adjustCamera(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::adjustCamera");
const std::string id = ghoul::lua::value<std::string>(L, 1);
/**
* Takes an identifier to a sky browser or sky target. Rotates the camera
* so that the target is placed in the center of the view.
* \param id
*/
[[codegen::luawrap]] void adjustCamera(std::string id) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
if (module->isCameraInSolarSystem()) {
module->lookAtTarget(id);
}
return 0;
}
int setOpacityOfImageLayer(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::setOpacityOfImageLayer");
auto [id, i, opacity] = ghoul::lua::values<std::string, int, double>(L);
/**
* Takes an identifier to a sky browser or sky target, an index to an image
* and a value for the opacity.
* \param id Identifier
* \param i Image index
* \param opacity
*/
[[codegen::luawrap]] void setOpacityOfImageLayer(std::string id, int i, double opacity) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
TargetBrowserPair* found = module->getPair(id);
if (found) {
found->setImageOpacity(i, opacity);
}
return 0;
}
int centerTargetOnScreen(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::centerTargetOnScreen");
const std::string id = ghoul::lua::value<std::string>(L, 1);
/**
* Takes an identifier to a sky browser and animates its corresponding
* target to the center of the current view.
* \param id Identifier
*/
[[codegen::luawrap]] void centerTargetOnScreen(std::string id) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
TargetBrowserPair* pair = module->getPair(id);
if (pair) {
pair->centerTargetOnScreen();
}
return 0;
}
int setSelectedBrowser(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setSelectedBrowser");
const std::string id = ghoul::lua::value<std::string>(L, 1);
/**
* Takes an identifier to a sky browser or target. Sets that sky browser
* currently selected.
* \param id
*/
[[codegen::luawrap]] void setSelectedBrowser(std::string id) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
module->setSelectedBrowser(id);
return 0;
}
int createTargetBrowserPair(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::createTargetBrowserPair");
/**
* Creates a sky browser and a target.
*/
[[codegen::luawrap]] void createTargetBrowserPair() {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
int noOfPairs = module->nPairs();
@@ -477,13 +459,12 @@ int createTargetBrowserPair(lua_State* L) {
"openspace.skybrowser.setSelectedBrowser('" + idBrowser + "');",
scripting::ScriptEngine::RemoteScripting::No
);
return 0;
}
int removeTargetBrowserPair(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeTargetBrowserPair");
std::string id = ghoul::lua::value<std::string>(L, 1);
/**
* Takes in identifier to a sky browser or target and removes them.
* \param id Identifier
*/
[[codegen::luawrap]] void removeTargetBrowserPair(std::string id) {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
TargetBrowserPair* found = module->getPair(id);
if (found) {
@@ -503,28 +484,32 @@ int removeTargetBrowserPair(lua_State* L) {
scripting::ScriptEngine::RemoteScripting::Yes
);
}
return 0;
}
int translateScreenSpaceRenderable(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 5, "lua::translateScreenSpaceRenderable");
auto [id, startX, startY, transX, transY] =
ghoul::lua::values<std::string, float, float, float, float>(L);
/**
* Takes an identifier to a sky browser or sky target and the [x, y]
* starting position and the [x, y] translation vector.
* \param id Identifier
* \param startX Starting x-position
* \param startY Starting y-position
* \param transX Translation x-value
* \param transY Translation y-value
*/
[[codegen::luawrap]] void translateScreenSpaceRenderable(std::string id, float startX,
float startY, float transX,
float transY) {
ScreenSpaceRenderable* renderable = global::renderEngine->screenSpaceRenderable(id);
if (renderable) {
renderable->translate(glm::vec2(transX, transY), glm::vec2(startX, startY));
}
return 0;
}
int removeSelectedImageInBrowser(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::removeSelectedImageInBrowser");
auto [id, i] = ghoul::lua::values<std::string, int>(L);
/**
* Takes an identifier to a sky browser or target and an index to an
* image. Removes that image from that sky browser.
* \param id Identifier
* \i Index of image
*/
[[codegen::luawrap]] void removeSelectedImageInBrowser(std::string id, int i) {
// Get browser
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
const ImageData& image = module->getWwtDataHandler()->getImage(i);
@@ -533,14 +518,16 @@ int removeSelectedImageInBrowser(lua_State* L) {
if (pair) {
pair->removeSelectedImage(i);
}
return 0;
}
int setEquatorialAim(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::setEquatorialAim");
auto [id, ra, dec] = ghoul::lua::values<std::string, double, double>(L);
/**
* Takes the identifier of a sky browser or a sky target and equatorial
* coordinates Right Ascension and Declination. The target will animate to
* this coordinate and the browser will display the coordinate.
* \param id Identifier
* \param ra Right Ascension
* \param dec Declination
*/
[[codegen::luawrap]] void setEquatorialAim(std::string id, double ra, double dec) {
// Get module
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -548,14 +535,14 @@ int setEquatorialAim(lua_State* L) {
if (pair) {
pair->setEquatorialAim(glm::dvec2(ra, dec));
}
return 0;
}
int setVerticalFov(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::setVerticalFov");
auto [id, vfov] = ghoul::lua::values<std::string, float>(L);
/**
* Takes an identifier to a sky browser or a sky target and a vertical
* field of view. Changes the field of view as specified by the input.
* \param id Identifier
* \param vfov Vertical Field of View
*/
[[codegen::luawrap]] void setVerticalFov(std::string id, float vfov) {
// Get module
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -563,14 +550,16 @@ int setVerticalFov(lua_State* L) {
if (pair) {
pair->setVerticalFov(vfov);
}
return 0;
}
int setBorderColor(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 4, "lua::setBorderColor");
auto [id, r, g, b] = ghoul::lua::values<std::string, int, int, int>(L);
/**
* Takes an identifier to a sky browser or a sky target and a rgb color
* in the ranges [0, 255].
* \param id Identifier
* \param r Red
* \param g Green
* \param b Blue
*/
[[codegen::luawrap]] void setBorderColor(std::string id, int r, int g, int b) {
glm::ivec3 color{ r, g, b };
// Get module
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -579,14 +568,15 @@ int setBorderColor(lua_State* L) {
if (pair) {
pair->setBorderColor(color);
}
return 0;
}
int setScreenSpaceSize(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::setScreenSpaceSize");
auto [id, sizeX, sizeY] = ghoul::lua::values<std::string, float, float>(L);
/**
* Sets the screen space size of the sky browser to the numbers specified
* by the input [x, y].
* \param id
* \param sizeX Size on the x-axis
* \param sizeY Size on the y-axis
*/
[[codegen::luawrap]] void setScreenSpaceSize(std::string id, float sizeX, float sizeY) {
// Get module
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -594,13 +584,12 @@ int setScreenSpaceSize(lua_State* L) {
if (pair) {
pair->setScreenSpaceSize(glm::vec2(sizeX, sizeY));
}
return 0;
}
int addRenderCopy(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::addRenderCopy");
auto [id] = ghoul::lua::values<std::string>(L);
/**
* Takes an identifier to a sky browser and adds a rendered copy to it.
* \param id Identifier
*/
[[codegen::luawrap]] void addRenderCopy(std::string id) {
// Get module
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -608,14 +597,13 @@ int addRenderCopy(lua_State* L) {
if (pair) {
pair->browser()->addRenderCopy();
}
return 0;
}
int removeRenderCopy(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeRenderCopy");
auto [id] = ghoul::lua::values<std::string>(L);
/**
* Takes an identifier to a sky browser and removes the latest added
* rendered copy to it.
* \param id Identifier
*/
[[codegen::luawrap]] void removeRenderCopy(std::string id) {
// Get module
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
@@ -623,7 +611,8 @@ int removeRenderCopy(lua_State* L) {
if (pair) {
pair->browser()->removeRenderCopy();
}
return 0;
}
} // namespace openspace::skybrowser::luafunctions
#include "skybrowsermodule_lua_codegen.cpp"
} // namespace
+2 -2
View File
@@ -103,8 +103,8 @@ Browser::Browser(const ghoul::Dictionary& dictionary)
_renderHandler = new RenderHandler();
_keyboardHandler = new WebKeyboardHandler();
_browserInstance = std::make_unique<BrowserInstance>(
_renderHandler,
_keyboardHandler
_renderHandler.get(),
_keyboardHandler.get()
);
WebBrowserModule* webBrowser = global::moduleEngine->module<WebBrowserModule>();