Commit 4214811c authored by Ylva Selling's avatar Ylva Selling
Browse files

Add lua function to reload a display copy on a specific node

Showing with 34 additions and 1 deletion
+34 -1
......@@ -72,6 +72,7 @@ public:
void update();
void updateBrowserSize();
void reload();
glm::vec2 browserPixelDimensions() const;
float browserRatio() const;
......
......@@ -524,7 +524,8 @@ scripting::LuaLibrary SkyBrowserModule::luaLibrary() const {
codegen::lua::ShowAllTargetsAndBrowsers,
codegen::lua::PointSpaceCraft,
codegen::lua::GetWwtImageCollectionUrl,
codegen::lua::StopAnimations
codegen::lua::StopAnimations,
codegen::lua::ReloadDisplayCopyOnNode
}
};
}
......
......@@ -39,6 +39,33 @@
namespace {
constexpr std::string_view _loggerCat = "SkyBrowserModule";
/**
* Reloads the sky browser display copy for the node index that is sent in.
* .If no ID is sent in, it will reload all display copies on that node.
*/
[[codegen::luawrap]] void reloadDisplayCopyOnNode(int nodeIndex, std::string id = "all") {
using namespace openspace;
if (global::windowDelegate->currentNode() != nodeIndex)
return;
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
if (id != "all") {
TargetBrowserPair* pair = module->pair(id);
if (pair) {
pair->browser()->reload();
}
}
else {
const std::vector<std::unique_ptr<TargetBrowserPair>>& pairs = module->pairs();
for (const std::unique_ptr<TargetBrowserPair>& pair : pairs) {
pair->browser()->reload();
}
}
}
/**
* Takes an index to an image and selects that image in the currently
* selected sky browser.
......
......@@ -179,6 +179,10 @@ void Browser::updateBrowserSize() {
_browserDimensions = _texture->dimensions();
}
void Browser::reload() {
_reload.set(true);
}
float Browser::browserRatio() const {
return static_cast<float>(_texture->dimensions().x) /
static_cast<float>(_texture->dimensions().y);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment