diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index d9539488e6..84aacfa531 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -165,13 +165,15 @@ namespace openspace{ void ISWAManager::addISWACygnet(int id, std::string info){ getDictionaryTable(absPath("${OPENSPACE_DATA}/GM_openspace_Y0_info.txt"), id); - if(id != 0){ + if(id > 0){ std::shared_ptr extFuture = fileExtension(id); extFuture->parent = info; _extFutures.push_back(extFuture); // _container->addISWACygnet(cygnetId, data); + }else if(id < 0){ + } - else{ + else { std::shared_ptr mdata = std::make_shared(); mdata->id = 0; mdata->path = absPath("${OPENSPACE_DATA}/"+info); @@ -337,4 +339,71 @@ namespace openspace{ // ghoul::Dictionary dic; return table; } + + std::string ISWAManager::parseJSONToLuaTable(std::string jsonString, int id){ + if(jsonString != ""){ + json j = json::parse(jsonString); + + std::string parent = j["Central Body"]; + std::string frame = j["Coordinates"]; + + int xmax = j["Plot XMAX"]; + int ymax = j["Plot YMAX"]; + int zmax = j["Plot ZMAX"]; + int xmin = j["Plot XMIN"]; + int ymin = j["Plot YMIN"]; + int zmin = j["Plot ZMIN"]; + + float spatScale=1, scalew=10; + std::string spatialScale = j["Spatial Scale (Custom)"]; + if(spatialScale == "R_E"){ + spatScale = 6.371f; + scalew = 6; + } + + std::string scale = "{" + + std::to_string(spatScale*(xmax-xmin)) + "," + + std::to_string(spatScale*(ymax-ymin)) + "," + + std::to_string(spatScale*(zmax-zmin)) + "," + + std::to_string(scalew) + + "}"; + + std::string offset ="{" + + std::to_string(spatScale*(xmin + (std::abs(xmin)+std::abs(xmax))/2.0f)) + "," + + std::to_string(spatScale*(ymin + (std::abs(ymin)+std::abs(ymax))/2.0f)) + "," + + std::to_string(spatScale*(zmin + (std::abs(zmin)+std::abs(zmax))/2.0f)) + "," + + std::to_string(scalew) + + "}"; + + std::string table = "{" + "Name : 'TexturePlane' , " + "Parent : '" + parent + "', " + "Renderable = {" + "Type = 'TexturePlane', " + "Id = " + std::to_string(id) + ", " + "Frame = '" + frame + "' , " + "Scale = " + scale + ", " + "Offset = " + offset + + "}" + "}" + ; + + std::cout << table << std::endl; + // ghoul::Dictionary dic; + return table; + } + return ""; + } + + void createDataPlane(std::string path){ + + } + + void createTexturePlane(std::string table){ + + } + + void createScreenSpace(int id){ + + } }// namsepace openspace \ No newline at end of file diff --git a/modules/iswa/util/iswamanager.h b/modules/iswa/util/iswamanager.h index b5c8c12411..1898400b95 100644 --- a/modules/iswa/util/iswamanager.h +++ b/modules/iswa/util/iswamanager.h @@ -82,6 +82,7 @@ public: private: std::string iSWAurl(int); std::string getDictionaryTable(std::string path, int id); + std::string parseJSONToLuaTable(std::string json, int id); std::map _month; ISWAContainer* _container; std::vector> _extFutures;