iSWA Screen Space Options

This commit is contained in:
Sebastian Piwell
2016-05-12 15:10:17 -04:00
parent c2443a9ee2
commit a28abd7774
8 changed files with 8358 additions and 13 deletions
+49 -2
View File
@@ -50,6 +50,7 @@ namespace {
namespace openspace{
IswaManager::IswaManager()
// :_iswaNames("iswaNames", "iSWA Cygnets")
{
_month["JAN"] = "01";
_month["FEB"] = "02";
@@ -70,6 +71,24 @@ IswaManager::IswaManager()
_geom[CygnetGeometry::Plane] = "Plane";
_geom[CygnetGeometry::Sphere] = "Sphere";
// setName("IswaManager");
// addProperty(_iswaNames);
// OsEng.gui()._iswa.registerProperty(&_iswaNames);
// _iswaNames.addOption({7, std::string("Red Sun")});
// _iswaNames.addOption({6, std::string("Yellow Sun")});
// _iswaNames.addOption({5, std::string("Green Sun")});
// _iswaNames.addOption({4, std::string("Blue Sun")});
// _iswaNames.onChange([this]{
// for(auto v : _iswaNames.value()){
// std::cout << v << " ";
// }
// std::cout << std::endl;
// // std::cout << std::to_string(_iswaNames.value()) << std::endl;
// });
}
IswaManager::~IswaManager(){
@@ -162,10 +181,16 @@ void IswaManager::addIswaCygnet(int id, std::string info, int group){
}
}
void IswaManager::deleteIswaCygnet(std::string name){
OsEng.scriptEngine().queueScript("openspace.removeSceneGraphNode('" + name + "')");
}
void IswaManager::deleteScreenSpaceCygnet(std::string name){
std::string script = "openspace.unregisterScreenSpaceRenderable('" + name + "');";
OsEng.scriptEngine().queueScript(script);
}
std::shared_ptr<DownloadManager::FileFuture> IswaManager::downloadImageToMemory(int id, std::string& buffer){
return DlManager.downloadToMemory(
iswaUrl(id, "image"),
@@ -264,9 +289,10 @@ std::shared_ptr<MetadataFuture> IswaManager::downloadMetadata(int id){
return metaFuture;
}
void IswaManager::createScreenSpace(int id){
void IswaManager::createScreenSpace(int id, std::string name){
if(name == "")
name = "iSWACygnet" + std::to_string(id);
std::string name = "iSWACygnet" + std::to_string(id);
if(OsEng.renderEngine().screenSpaceRenderable(name)){
LERROR("A cygnet with the name \"" + name +"\" already exist");
return;
@@ -473,6 +499,27 @@ scripting::ScriptEngine::LuaLibrary IswaManager::luaLibrary() {
"Adds a IswaCygnet",
true
},
{
"addScreenSpaceCygnet",
&luascriptfunctions::iswa_addScreenSpaceCygnet,
"int, string",
"Adds a Screen Space Cygnets",
true
},
{
"removeCygnet",
&luascriptfunctions::iswa_removeCygnet,
"string",
"Remove a Cygnets",
true
},
{
"removeScreenSpaceCygnet",
&luascriptfunctions::iswa_removeScrenSpaceCygnet,
"string",
"Remove a Screen Space Cygnets",
true
},
{
"removeGroup",
&luascriptfunctions::iswa_removeGroup,
+6 -2
View File
@@ -37,6 +37,7 @@
#include <openspace/properties/selectionproperty.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/properties/selectionproperty.h>
// #include <modules/iswa/rendering/iswacygnet.h>
// #include <modules/iswa/rendering/iswagroup.h>
@@ -58,7 +59,7 @@ struct MetadataFuture {
};
class IswaManager : public ghoul::Singleton<IswaManager> {
class IswaManager : public ghoul::Singleton<IswaManager>, public properties::PropertyOwner {
friend class ghoul::Singleton<IswaManager>;
public:
@@ -71,6 +72,7 @@ public:
void addIswaCygnet(std::string info);
void addIswaCygnet(int id, std::string info = "Texture", int group = -1);
void deleteIswaCygnet(std::string);
void deleteScreenSpaceCygnet(std::string name);
std::shared_ptr<DownloadManager::FileFuture> downloadImageToMemory(int id, std::string& buffer);
std::shared_ptr<DownloadManager::FileFuture> downloadDataToMemory(int id, std::string& buffer);
@@ -88,10 +90,10 @@ public:
static scripting::ScriptEngine::LuaLibrary luaLibrary();
std::string iswaUrl(int id, std::string type = "image");
void createScreenSpace(int id, std::string name = "");
private:
std::shared_ptr<MetadataFuture> downloadMetadata(int id);
void createScreenSpace(int id);
void createPlane(std::shared_ptr<MetadataFuture> data);
std::string parseJSONToLuaTable(std::shared_ptr<MetadataFuture> data);
@@ -106,6 +108,8 @@ private:
std::shared_ptr<ccmc::Kameleon> _kameleon;
std::set<std::string> _kameleonFrames;
// properties::SelectionProperty _iswaNames;
};
} //namespace openspace
+22
View File
@@ -32,12 +32,34 @@ int iswa_addCygnet(lua_State* L) {
return 0;
}
int iswa_addScreenSpaceCygnet(lua_State* L){
int id = lua_tonumber(L, 1);
std::string name = luaL_checkstring(L, 2);
std::cout << id << " " << name << std::endl;
IswaManager::ref().createScreenSpace(id,name);
}
int iswa_removeCygnet(lua_State* L){
std::string s = luaL_checkstring(L, -1);
IswaManager::ref().deleteIswaCygnet(s);
return 0;
}
int iswa_removeScrenSpaceCygnet(lua_State* L){
std::string s = luaL_checkstring(L, -1);
IswaManager::ref().deleteScreenSpaceCygnet(s);
return 0;
}
int iswa_removeGroup(lua_State* L){
int id = lua_tonumber(L, 1);
IswaManager::ref().unregisterGroup(id);
return 0;
}
}// namespace luascriptfunctions
}// namespace openspace
@@ -31,15 +31,25 @@
namespace openspace {
namespace gui {
struct Option {
int id;
std::string name;
std::string description;
bool selected;
};
class GuiIswaComponent : public GuiPropertyComponent {
public:
virtual void initialize() override;
virtual void render() override;
private:
bool gmdata;
bool gmimage;
bool iondata;
std::vector<Option> options;
};
+30 -4
View File
@@ -38,6 +38,8 @@
#include <ghoul/lua/lua_helper.h>
#include <ghoul/misc/assert.h>
#include <ext/json/json.hpp>
#include "imgui.h"
namespace {
@@ -204,6 +206,13 @@ namespace {
namespace openspace {
namespace gui {
void GuiIswaComponent::initialize(){
options.push_back({7,"Red Sun","This is a red sun", false});
options.push_back({6,"Yellow Sun","This is a yellow sun", false});
options.push_back({5,"Green Sun","This is a green sun", false});
options.push_back({4,"Blue Sun","This is a blue sun", false});
}
void GuiIswaComponent::render() {
bool gmdatavalue = gmdata;
bool gmimagevalue = gmimage;
@@ -254,10 +263,27 @@ void GuiIswaComponent::render() {
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup(3);");
}
}
// bool gmdata = ImGui::Button("Create Global Magnetosphere from data");
// bool gmtext = ImGui::Button("Create Global Magnetosphere from images");
// bool iodata = ImGui::Button("Create Ionosphere from data");
// ImGui::ShowUserGuide();
if (ImGui::CollapsingHeader("iSWA screen space cygntes")) {
for (int i = 0; i < options.size(); ++i) {
// std::string name = options[i].name;
bool selected = options[i].selected;//std::find(selectedIndices.begin(), selectedIndices.end(), i) != selectedIndices.end();
ImGui::Checkbox(options[i].name.c_str(), &options[i].selected);
ImGui::SameLine();
if (ImGui::CollapsingHeader(("Description" + std::to_string(options[i].id)).c_str())) {
ImGui::Text(options[i].description.c_str());
}
if(selected != options[i].selected){
if(options[i].selected){
std::string arguments = std::to_string(options[i].id) + ", '" + options[i].name + "'";
OsEng.scriptEngine().queueScript("openspace.iswa.addScreenSpaceCygnet("+arguments+");");
}else{
OsEng.scriptEngine().queueScript("openspace.iswa.removeScreenSpaceCygnet('"+options[i].name+"');");
}
}
}
}
ImGui::Spacing();