Update textureplane and delete dataplane

This commit is contained in:
Sebastian Piwell
2016-04-19 16:59:40 -04:00
6 changed files with 87 additions and 78 deletions
+1
View File
@@ -5,6 +5,7 @@ tmp/
ext/SGCT
.DS_Store
*.swp
.vscode
# Windows system files:
Thumbs.db
+1
View File
@@ -75,6 +75,7 @@ bool ColorBar::deinitialize(){
renderEngine.removeRenderProgram(_shader);
_shader = nullptr;
}
return true;
}
void ColorBar::render(){
+4 -1
View File
@@ -53,7 +53,10 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
,_dataSlice(nullptr)
{
_id = id();
setName("DataPlane" + std::to_string(_id));
std::string name;
dictionary.getValue("Name", name);
setName(name);
addProperty(_dataOptions);
// addProperty(_topColor);
+6 -6
View File
@@ -59,12 +59,12 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
addProperty(_updateInterval);
addProperty(_delete);
std::cout << _data->id << std::endl;
std::cout << std::to_string(_data->offset) << std::endl;
std::cout << std::to_string(_data->scale) << std::endl;
std::cout << _data->path << std::endl;
std::cout << _data->parent << std::endl;
std::cout << _data->frame << std::endl;
// std::cout << _data->id << std::endl;
// std::cout << std::to_string(_data->offset) << std::endl;
// std::cout << std::to_string(_data->scale) << std::endl;
// std::cout << _data->path << std::endl;
// std::cout << _data->parent << std::endl;
// std::cout << _data->frame << std::endl;
_delete.onChange([this](){ISWAManager::ref().deleteISWACygnet(name());});
}
+6 -5
View File
@@ -153,7 +153,6 @@ void TexturePlane::render(const RenderData& data){
_shader->deactivate();
}
}
void TexturePlane::update(const UpdateData& data){
@@ -180,9 +179,10 @@ void TexturePlane::update(const UpdateData& data){
void TexturePlane::loadTexture() {
// std::cout << _data->path << std::endl;
// std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_data->path));
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath("${OPENSPACE_DATA}/GM_openspace_Z0_20150315_000000.png"));
// if(_memorybuffer != ""){
// std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTextureFromMemory(_memorybuffer);
//std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath("${OPENSPACE_DATA}/GM_openspace_Z0_20150315_000000.png"));
if(_memorybuffer != ""){
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTextureFromMemory(_memorybuffer);
if (texture) {
// LDEBUG("Loaded texture from '" << absPath(_data->path) << "'");
texture->uploadTexture();
@@ -191,10 +191,11 @@ void TexturePlane::loadTexture() {
_texture = std::move(texture);
}
// }
}
}
void TexturePlane::updateTexture(){
_memorybuffer = "";
std::shared_ptr<DownloadManager::FileFuture> future = ISWAManager::ref().downloadImageToMemory(_data->id, _memorybuffer);
// std::shared_ptr<DownloadManager::FileFuture> future = ISWAManager::ref().downloadImage(_data->id, absPath(_data->path));
+69 -66
View File
@@ -164,16 +164,16 @@ namespace openspace{
//download metadata to texture plane
std::shared_ptr<MetadataFuture> extFuture = downloadMetadata(id);
extFuture->type = "TEXTURE";
extFuture->id = -id;
extFuture->id = id;
// extFuture->parent = info;
// _extFutures.push_back(extFuture);
// std::shared_ptr<ExtensionFuture> extFuture
_metaFutures.push_back(extFuture);
}
else {
std::shared_ptr<MetadataFuture> extFuture = downloadMetadata(-1);
std::shared_ptr<MetadataFuture> extFuture = downloadMetadata(-2);
extFuture->type = "DATA";
extFuture->id = -1;
extFuture->id = -2;
// std::shared_ptr<Metadata> mdata = std::make_shared<Metadata>();
// mdata->id = 0;
// mdata->path = absPath("${OPENSPACE_DATA}/"+info);
@@ -224,15 +224,15 @@ namespace openspace{
std::shared_ptr<MetadataFuture> metaFuture = std::make_shared<MetadataFuture>();
metaFuture->id = id;
std::ifstream file(absPath("${OPENSPACE_DATA}/GM_openspace_Y0_info.txt"));
if(file.is_open()){
std::string json( (std::istreambuf_iterator<char>(file) ),
(std::istreambuf_iterator<char>()));
metaFuture->isFinished = true;
metaFuture->json = json;
}
DlManager.downloadToMemory(
"http://128.183.168.116:3000/" + std::to_string(-id),
metaFuture->json,
[metaFuture](const DownloadManager::FileFuture& f){
LDEBUG("Download to memory finished");
metaFuture->isFinished = true;
}
);
return metaFuture;
}
@@ -269,7 +269,13 @@ namespace openspace{
}
std::string ISWAManager::iSWAurl(int id){
std::string url = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?timestamp=";
std::string url;
if(id < 0){
url = "http://128.183.168.116:3000/image/" + std::to_string(-id) + "/";
} else {
url = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?window=-1&cygnetId="+ std::to_string(id) +"&timestamp=";
}
std::string t = Time::ref().currentTimeUTC();
std::stringstream ss(t);
@@ -284,9 +290,6 @@ namespace openspace{
std::getline(ss, token, '.');
url += token;
url += "&window=-1&cygnetId=";
url += std::to_string(id);
//std::cout << url << std::endl;
return url;
@@ -345,61 +348,61 @@ namespace openspace{
}
}
std::string ISWAManager::getDictionaryTable(int id, std::string path){
json j;
std::ifstream file(path);
if(file.is_open()){
j = json::parse(file);
}
// std::string ISWAManager::getDictionaryTable(int id, std::string path){
// json j;
// std::ifstream file(path);
// if(file.is_open()){
// j = json::parse(file);
// }
std::string parent = j["Central Body"];
std::string frame = j["Coordinates"];
// 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"];
// 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;
}
// 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 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 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::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;
}
// // std::cout << table << std::endl;
// // ghoul::Dictionary dic;
// return table;
// }
std::string ISWAManager::parseJSONToLuaTable(int id, std::string jsonString, std::string type){
if(jsonString != ""){
@@ -448,7 +451,7 @@ namespace openspace{
"}"
;
std::cout << table << std::endl;
// std::cout << table << std::endl;
// ghoul::Dictionary dic;
return table;
}
@@ -480,7 +483,7 @@ namespace openspace{
"}"
"}"
;
std::cout << table << std::endl;
// std::cout << table << std::endl;
return table;
}
}