mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Load cdf files at start up
This commit is contained in:
32
data/cdflist.json
Normal file
32
data/cdflist.json
Normal file
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{"group" : "CCMC-3D-CDF",
|
||||
"fieldlinefile" : "${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json",
|
||||
"cdfs" : [
|
||||
{
|
||||
"name" : "CCMC-00:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf",
|
||||
"date" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-00:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf",
|
||||
"date" : "2000-01-01T00:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf",
|
||||
"date" : "2000-01-01T10:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf",
|
||||
"date" : "2000-01-01T01:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-02:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf",
|
||||
"date" : "2000-01-01T02:00:00.00"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,5 +1,40 @@
|
||||
../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf 2000-01-01T00:00:00.00
|
||||
../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf 2000-01-01T00:30:00.00
|
||||
../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf 2000-01-01T01:00:00.00
|
||||
../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf 2000-01-01T01:30:00.00
|
||||
../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf 2000-01-01T02:00:00.00
|
||||
{"cdfgroups" : [{
|
||||
"group" : "CCMC-3D-CDF",
|
||||
"fieldlinefile" : "${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json",
|
||||
"cdfs" : [
|
||||
{
|
||||
"name" : "CCMC-00:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf"
|
||||
"time" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-00:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf"
|
||||
"time" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf"
|
||||
"time" : "2000-01-01T10:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf"
|
||||
"time" : "2000-01-01T01:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-02:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf"
|
||||
"time" : "2000-01-01T02:00:00.00"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
CCMC-3D-CDF
|
||||
${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json
|
||||
CCMC-00:00:00 ../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf 2000-01-01T00:00:00.00
|
||||
CCMC-00:30:00 ../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf 2000-01-01T00:30:00.00
|
||||
CCMC-01:00:00 ../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf 2000-01-01T01:00:00.00
|
||||
CCMC-01:30:00 ../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf 2000-01-01T01:30:00.00
|
||||
CCMC-02:00:00 ../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf 2000-01-01T02:00:00.00
|
||||
@@ -44,7 +44,7 @@ function postInitialization()
|
||||
--openspace.iswa.addCygnet(-2,"Data","GM");
|
||||
--openspace.iswa.addCygnet(-3,"Data","GM");
|
||||
|
||||
|
||||
openspace.iswa.addCdfFiles("${OPENSPACE_DATA}/cdflist.json");
|
||||
|
||||
--[[
|
||||
openspace.iswa.addScreenSpaceCygnet(
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace openspace {
|
||||
IswaGroup::IswaGroup(std::string name)
|
||||
:_enabled("enabled", "Enabled", true)
|
||||
,_useLog("useLog","Use Logarithm", false)
|
||||
,_useHistogram("_useHistogram", "Use Histogram", true)
|
||||
,_useHistogram("_useHistogram", "Use Histogram", false)
|
||||
,_normValues("normValues", "Normalize Values", glm::vec2(1.0,1.0), glm::vec2(0), glm::vec2(5.0))
|
||||
,_backgroundValues("backgroundValues", "Background Values", glm::vec2(0.0), glm::vec2(0), glm::vec2(1.0))
|
||||
,_transferFunctionsFile("transferfunctions", "Transfer Functions", "${SCENE}/iswa/tfs/hot.tf")
|
||||
|
||||
@@ -143,15 +143,24 @@ void IswaManager::addIswaCygnet(int id, std::string type, std::string group){
|
||||
LDEBUG("Download to memory was aborted for data cygnet with id "+ std::to_string(id)+": " + err);
|
||||
}
|
||||
);
|
||||
}else{
|
||||
// Kameleonplane?
|
||||
// LERROR("No cygnet with id 0");
|
||||
std::string kwPath = "${OPENSPACE_DATA}/BATSRUS.cdf";
|
||||
if(type == "x" || type == "y" || type == "z")
|
||||
createKameleonPlane(kwPath, type, group);
|
||||
else
|
||||
createKameleonPlane(kwPath, "z", group);
|
||||
}
|
||||
// else{
|
||||
// // Kameleonplane?
|
||||
// // LERROR("No cygnet with id 0");
|
||||
// std::string kwPath = "${OPENSPACE_DATA}/BATSRUS.cdf";
|
||||
// if(type == "x" || type == "y" || type == "z")
|
||||
// createKameleonPlane(kwPath, type, group);
|
||||
// else
|
||||
// createKameleonPlane(kwPath, "z", group);
|
||||
// }
|
||||
}
|
||||
|
||||
void IswaManager::addKameleonCdf(std::string group, int pos){
|
||||
// auto info = _cdfInformation[group][pos];
|
||||
// std::cout << group << " " << pos << std::endl;
|
||||
createKameleonPlane(_cdfInformation[group][pos], "z");
|
||||
createKameleonPlane(_cdfInformation[group][pos], "y");
|
||||
createKameleonPlane(_cdfInformation[group][pos], "x");
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id){
|
||||
@@ -225,11 +234,6 @@ void IswaManager::registerOptionsToGroup(std::string name, const std::vector<pro
|
||||
}
|
||||
|
||||
std::shared_ptr<IswaGroup> IswaManager::iswaGroup(std::string name){
|
||||
// for(auto group : _groups){
|
||||
// if(group.second->name() == name){
|
||||
// return group.second;
|
||||
// }
|
||||
// }
|
||||
if(_groups.find(name) != _groups.end()){
|
||||
return _groups[name];
|
||||
}
|
||||
@@ -245,6 +249,10 @@ std::map<std::string, std::shared_ptr<IswaGroup>>& IswaManager::groups(){
|
||||
return _groups;
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<CdfInfo>>& IswaManager::cdfInformation(){
|
||||
return _cdfInformation;
|
||||
}
|
||||
|
||||
std::shared_ptr<MetadataFuture> IswaManager::downloadMetadata(int id){
|
||||
std::shared_ptr<MetadataFuture> metaFuture = std::make_shared<MetadataFuture>();
|
||||
|
||||
@@ -317,11 +325,11 @@ std::string IswaManager::jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string IswaManager::parseKWToLuaTable(std::string kwPath, std::string cut, std::string group){
|
||||
if(kwPath != ""){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
|
||||
std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut){
|
||||
if(info.path != ""){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(info.path)).fileExtension();
|
||||
if(extension == "cdf"){
|
||||
KameleonWrapper kw = KameleonWrapper(absPath(kwPath));
|
||||
KameleonWrapper kw = KameleonWrapper(absPath(info.path));
|
||||
|
||||
std::string parent = kw.getParent();
|
||||
std::string frame = kw.getFrame();
|
||||
@@ -346,7 +354,7 @@ std::string IswaManager::parseKWToLuaTable(std::string kwPath, std::string cut,
|
||||
}
|
||||
|
||||
std::string table = "{"
|
||||
"Name = 'KameleonPlane-"+cut+"',"
|
||||
"Name = '"+info.name+"-"+cut+"_"+info.group+"',"
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = 'KameleonPlane', "
|
||||
@@ -356,11 +364,11 @@ std::string IswaManager::parseKWToLuaTable(std::string kwPath, std::string cut,
|
||||
"GridMax = " + std::to_string(max) + ", "
|
||||
"SpatialScale = " + std::to_string(spatialScale) + ", "
|
||||
"UpdateTime = 0, "
|
||||
"kwPath = '" + kwPath + "' ,"
|
||||
"kwPath = '" + info.path + "' ,"
|
||||
"axisCut = '"+cut+"',"
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
"Group = '"+ group + "',"
|
||||
"fieldlineSeedsIndexFile = '${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json'"
|
||||
"Group = '"+ info.group + "',"
|
||||
"fieldlineSeedsIndexFile = '"+info.fieldlineSeedsIndexFile+"'"
|
||||
"}"
|
||||
"}"
|
||||
;
|
||||
@@ -472,18 +480,20 @@ void IswaManager::createSphere(std::shared_ptr<MetadataFuture> data){
|
||||
}
|
||||
}
|
||||
|
||||
void IswaManager::createKameleonPlane(std::string kwPath, std::string cut, std::string group){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
|
||||
void IswaManager::createKameleonPlane(CdfInfo info, std::string cut){
|
||||
std::cout << info.name << " " << cut << std::endl;
|
||||
|
||||
if(FileSys.fileExists(absPath(kwPath)) && extension == "cdf"){
|
||||
std::string luaTable = parseKWToLuaTable(kwPath, cut, group);
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(info.path)).fileExtension();
|
||||
|
||||
if(FileSys.fileExists(absPath(info.path)) && extension == "cdf"){
|
||||
std::string luaTable = parseKWToLuaTable(info, cut);
|
||||
if(!luaTable.empty()){
|
||||
// std::cout << luaTable << std::endl;
|
||||
// // std::cout << luaTable << std::endl;
|
||||
std::string script = "openspace.addSceneGraphNode(" + luaTable + ");";
|
||||
OsEng.scriptEngine().queueScript(script);
|
||||
}
|
||||
}else{
|
||||
LWARNING( absPath(kwPath) + " is not a cdf file or can't be found.");
|
||||
LWARNING( absPath(info.path) + " is not a cdf file or can't be found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,6 +559,46 @@ void IswaManager::fillCygnetInfo(std::string jsonString){
|
||||
}
|
||||
}
|
||||
|
||||
void IswaManager::addCdfFiles(std::string path){
|
||||
path = absPath(path);
|
||||
if(FileSys.fileExists(path)){
|
||||
|
||||
std::string basePath = path.substr(0, path.find_last_of("/\\"));
|
||||
std::ifstream jsonFile(path);
|
||||
|
||||
if (jsonFile.is_open()){
|
||||
json cdfGroups = json::parse(jsonFile);
|
||||
for(int i=0; i<cdfGroups.size(); i++){
|
||||
json cdfGroup = cdfGroups.at(i);
|
||||
|
||||
std::string groupName = cdfGroup["group"];
|
||||
std::string fieldlineSeedsIndexFile = cdfGroup["fieldlinefile"];
|
||||
|
||||
if(_cdfInformation.find(groupName) != _cdfInformation.end()){
|
||||
LWARNING("CdfGroup with name" + groupName + " already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
_cdfInformation[groupName] = std::vector<CdfInfo>();
|
||||
|
||||
json cdfs = cdfGroup["cdfs"];
|
||||
for(int j=0; j<cdfs.size(); j++){
|
||||
json cdf = cdfs.at(j);
|
||||
|
||||
std::string name = cdf["name"];
|
||||
std::string path = cdf["path"];
|
||||
std::string date = cdf["date"];
|
||||
|
||||
_cdfInformation[groupName].push_back({name, basePath+"/"+path, groupName, date, fieldlineSeedsIndexFile});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}else{
|
||||
LWARNING( path + " is not a cdf file or can't be found.");
|
||||
}
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary IswaManager::luaLibrary() {
|
||||
return {
|
||||
"iswa",
|
||||
@@ -568,10 +618,24 @@ scripting::ScriptEngine::LuaLibrary IswaManager::luaLibrary() {
|
||||
true
|
||||
},
|
||||
{
|
||||
"addKameleonPlane",
|
||||
&luascriptfunctions::iswa_addKameleonPlane,
|
||||
"string, string, string",
|
||||
"Adds a KmaeleonPlane from cdf file.",
|
||||
"addKameleonPlanes",
|
||||
&luascriptfunctions::iswa_addKameleonPlanes,
|
||||
"string, int",
|
||||
"Adds KameleonPlanes from cdf file.",
|
||||
true
|
||||
},
|
||||
// {
|
||||
// "addKameleonPlane",
|
||||
// &luascriptfunctions::iswa_addKameleonPlane,
|
||||
// "string, string, string",
|
||||
// "Adds a KameleonPlane from cdf file.",
|
||||
// true
|
||||
// },
|
||||
{
|
||||
"addCdfFiles",
|
||||
&luascriptfunctions::iswa_addCdfFiles,
|
||||
"string",
|
||||
"Adds a cdf files to choose from.",
|
||||
true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -49,6 +49,14 @@ namespace openspace {
|
||||
class IswaGroup;
|
||||
class IswaCygnet;
|
||||
|
||||
struct CdfInfo {
|
||||
std::string name;
|
||||
std::string path;
|
||||
std::string group;
|
||||
std::string date;
|
||||
std::string fieldlineSeedsIndexFile;
|
||||
};
|
||||
|
||||
struct CygnetInfo {
|
||||
std::string name;
|
||||
std::string description;
|
||||
@@ -78,6 +86,7 @@ public:
|
||||
~IswaManager();
|
||||
|
||||
void addIswaCygnet(int id, std::string type = "Texture", std::string group = "");
|
||||
void addKameleonCdf(std::string group, int pos);
|
||||
void createFieldline(std::string name, std::string cdfPath, std::string seedPath);
|
||||
|
||||
std::future<DownloadManager::MemoryFile> fetchImageCygnet(int id);
|
||||
@@ -91,6 +100,8 @@ public:
|
||||
|
||||
std::map<int, std::shared_ptr<CygnetInfo>>& cygnetInformation();
|
||||
std::map<std::string, std::shared_ptr<IswaGroup>>& groups();
|
||||
// std::vector<CdfInfo>& cdfInformation();
|
||||
std::map<std::string, std::vector<CdfInfo>>& cdfInformation();
|
||||
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
@@ -98,16 +109,17 @@ public:
|
||||
return _iswaEvent;
|
||||
}
|
||||
|
||||
void createKameleonPlane(std::string kwPath, std::string cut="z", std::string group="");
|
||||
void addCdfFiles(std::string path);
|
||||
private:
|
||||
std::shared_ptr<MetadataFuture> downloadMetadata(int id);
|
||||
std::string jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> data);
|
||||
std::string jsonSphereToLuaTable(std::shared_ptr<MetadataFuture> data);
|
||||
std::string parseKWToLuaTable(std::string kwPath, std::string cut="z", std::string group="");
|
||||
std::string parseKWToLuaTable(CdfInfo info, std::string cut="z");
|
||||
|
||||
void createScreenSpace(int id);
|
||||
void createPlane(std::shared_ptr<MetadataFuture> data);
|
||||
void createSphere(std::shared_ptr<MetadataFuture> data);
|
||||
void createKameleonPlane(CdfInfo info, std::string cut);
|
||||
|
||||
void fillCygnetInfo(std::string jsonString);
|
||||
|
||||
@@ -120,6 +132,8 @@ private:
|
||||
|
||||
std::map<std::string, std::shared_ptr<IswaGroup>> _groups;
|
||||
std::map<int, std::shared_ptr<CygnetInfo>> _cygnetInformation;
|
||||
// std::vector<CdfInfo> _cdfInformation;
|
||||
std::map<std::string, std::vector<CdfInfo>> _cdfInformation;
|
||||
|
||||
ghoul::Event<std::string, int> _iswaEvent;
|
||||
|
||||
|
||||
@@ -92,25 +92,25 @@ int iswa_addScreenSpaceCygnet(lua_State* L){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iswa_addKameleonPlane(lua_State* L){
|
||||
int nArguments = lua_gettop(L);
|
||||
// int iswa_addKameleonPlane(lua_State* L){
|
||||
// int nArguments = lua_gettop(L);
|
||||
|
||||
std::string kwPath = "";
|
||||
std::string type = "x";
|
||||
std::string group = "";
|
||||
// std::string kwPath = "";
|
||||
// std::string type = "x";
|
||||
// std::string group = "";
|
||||
|
||||
if(nArguments > 0)
|
||||
kwPath = luaL_checkstring(L, 1);
|
||||
// if(nArguments > 0)
|
||||
// kwPath = luaL_checkstring(L, 1);
|
||||
|
||||
if(nArguments > 1)
|
||||
type = luaL_checkstring(L, 2);
|
||||
// if(nArguments > 1)
|
||||
// type = luaL_checkstring(L, 2);
|
||||
|
||||
if(nArguments > 2)
|
||||
group = luaL_checkstring(L, 3);
|
||||
// if(nArguments > 2)
|
||||
// group = luaL_checkstring(L, 3);
|
||||
|
||||
IswaManager::ref().createKameleonPlane(kwPath, type, group);
|
||||
return 0;
|
||||
}
|
||||
// IswaManager::ref().createKameleonPlane(kwPath, type, group);
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int iswa_removeCygnet(lua_State* L){
|
||||
std::string name = luaL_checkstring(L, -1);
|
||||
@@ -149,6 +149,20 @@ int iswa_removeGroup(lua_State* L){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iswa_addCdfFiles(lua_State* L){
|
||||
std::string path = luaL_checkstring(L, 1);
|
||||
IswaManager::ref().addCdfFiles(path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iswa_addKameleonPlanes(lua_State* L){
|
||||
std::string group = luaL_checkstring(L, 1);
|
||||
int pos = lua_tonumber(L, 2);
|
||||
IswaManager::ref().addKameleonCdf(group, pos);
|
||||
// auto cdfInfo =
|
||||
return 0;
|
||||
}
|
||||
|
||||
}// namespace luascriptfunctions
|
||||
|
||||
|
||||
@@ -39,16 +39,17 @@ struct RadioOption {
|
||||
|
||||
class GuiIswaComponent : public GuiPropertyComponent {
|
||||
public:
|
||||
GuiIswaComponent();
|
||||
virtual void render() override;
|
||||
|
||||
private:
|
||||
bool gmdata;
|
||||
bool gmimage;
|
||||
bool iondata;
|
||||
bool kameleon;
|
||||
|
||||
std::vector<RadioOption> _cdfOptions;
|
||||
int _cdfOption;
|
||||
std::vector<int> _cdfOptions;
|
||||
std::map<std::string, int> _cdfOptionsMap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -57,12 +57,15 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
namespace gui {
|
||||
GuiIswaComponent::GuiIswaComponent()
|
||||
:GuiPropertyComponent()
|
||||
,_cdfOption(-1)
|
||||
{}
|
||||
|
||||
void GuiIswaComponent::render() {
|
||||
bool gmdatavalue = gmdata;
|
||||
bool gmimagevalue = gmimage;
|
||||
bool iondatavalue = iondata;
|
||||
bool kameleonvalue = kameleon;
|
||||
|
||||
ImGui::Begin("ISWA", &_isEnabled, size, 0.5f);
|
||||
ImGui::Text("Global Magnetosphere");
|
||||
@@ -72,8 +75,6 @@ void GuiIswaComponent::render() {
|
||||
ImGui::Text("Ionosphere");
|
||||
ImGui::Checkbox("Ion From Data", &iondata);
|
||||
|
||||
ImGui::Text("Kameleon");
|
||||
ImGui::Checkbox("BATSRUS.cdf", &kameleon);
|
||||
|
||||
ImGui::Spacing();
|
||||
static const int addCygnetBufferSize = 256;
|
||||
@@ -83,41 +84,6 @@ void GuiIswaComponent::render() {
|
||||
if(ImGui::SmallButton("Add Cygnet"))
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet("+std::string(addCygnetBuffer)+");");
|
||||
|
||||
static const int cdfListSize = 256;
|
||||
static char cdfList[cdfListSize];
|
||||
|
||||
std::string startPath = absPath("${OPENSPACE_DATA}/cdflist.txt");
|
||||
std::copy(startPath.begin(), startPath.end(),cdfList);
|
||||
|
||||
ImGui::InputText("cdf list", cdfList, cdfListSize);
|
||||
if(ImGui::SmallButton("Add Cdf files")){
|
||||
_cdfOption = -1;
|
||||
if(FileSys.fileExists(cdfList)){
|
||||
std::string list = std::string(cdfList);
|
||||
|
||||
std::string line;
|
||||
std::string basePath = list.substr(0, list.find_last_of("/\\"));
|
||||
|
||||
std::ifstream cdfListFile(list);
|
||||
int i = 0;
|
||||
if(cdfListFile.is_open()){
|
||||
while(getline(cdfListFile, line)){
|
||||
std::string path = line.substr(0, line.find_first_of(" "));
|
||||
std::string date = line.substr(line.find_first_of(" ")+1);
|
||||
|
||||
|
||||
_cdfOptions.push_back({i, basePath+"/"+path, date});
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
LWARNING( std::string(cdfList) + " is not a cdf file or can't be found.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(gmdata != gmdatavalue){
|
||||
if(gmdata){
|
||||
std::string x = "openspace.iswa.addCygnet(-1,'Data','GMData');";
|
||||
@@ -148,38 +114,41 @@ void GuiIswaComponent::render() {
|
||||
}
|
||||
}
|
||||
|
||||
if(kameleon != kameleonvalue){
|
||||
if(kameleon){
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlane('${OPENSPACE_DATA}/BATSRUS.cdf','z','BATSRUS');");
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlane('${OPENSPACE_DATA}/BATSRUS.cdf','y','BATSRUS');");
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlane('${OPENSPACE_DATA}/BATSRUS.cdf','x','BATSRUS');");
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('BATSRUS');");
|
||||
}
|
||||
}
|
||||
|
||||
if(ImGui::CollapsingHeader("Cdf files")){
|
||||
int cdfOptionValue = _cdfOption;
|
||||
auto cdfInfo = IswaManager::ref().cdfInformation();
|
||||
|
||||
for(auto radioOption : _cdfOptions){
|
||||
std::string path = radioOption.path;
|
||||
std::string cdfName = path.substr(path.find_last_of("/\\")+1);
|
||||
ImGui::RadioButton(cdfName.c_str(), &_cdfOption, radioOption.value);
|
||||
// ImGui::Text(cdfName.c_str());
|
||||
}
|
||||
for(auto group : cdfInfo){
|
||||
std::string groupName = group.first;
|
||||
if(_cdfOptionsMap.find(groupName) == _cdfOptionsMap.end()){
|
||||
_cdfOptionsMap[groupName] = -1;
|
||||
}
|
||||
|
||||
if(_cdfOption != cdfOptionValue){
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('Kameleon');");
|
||||
if(ImGui::CollapsingHeader(groupName.c_str())){
|
||||
int cdfOptionValue = _cdfOptionsMap[groupName];
|
||||
auto cdfs = group.second;
|
||||
|
||||
std::string path = _cdfOptions[_cdfOption].path;
|
||||
std::string date = _cdfOptions[_cdfOption].date;
|
||||
for(int i=0; i<cdfs.size(); i++){
|
||||
ImGui::RadioButton(cdfs[i].name.c_str(), &_cdfOptionsMap[groupName], i);
|
||||
}
|
||||
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlane('"+path+"','z','Kameleon');");
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlane('"+path+"','y','Kameleon');");
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlane('"+path+"','x','Kameleon');");
|
||||
|
||||
OsEng.scriptEngine().queueScript("openspace.time.setTime('"+date+"');");
|
||||
OsEng.scriptEngine().queueScript("openspace.time.setDeltaTime(0);");
|
||||
int cdfOption = _cdfOptionsMap[groupName];
|
||||
if(cdfOptionValue != cdfOption){
|
||||
// std::cout << cdfOptionValue << ", " << cdfOption << std::endl;
|
||||
if(cdfOptionValue > 0){
|
||||
groupName = cdfs[cdfOptionValue].group;
|
||||
// std::cout << groupName << std::endl;
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('"+groupName+"');");
|
||||
}
|
||||
|
||||
std::string path = cdfs[cdfOption].path;
|
||||
std::string date = cdfs[cdfOption].date;
|
||||
groupName = cdfs[cdfOption].group;
|
||||
// std::cout << path << ", " << date << ", " << groupName << std::endl;
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addKameleonPlanes('"+groupName+"',"+std::to_string(cdfOption)+");");
|
||||
OsEng.scriptEngine().queueScript("openspace.time.setTime('"+date+"');");
|
||||
OsEng.scriptEngine().queueScript("openspace.time.setDeltaTime(0);");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user