Some cleanup

This commit is contained in:
Sebastian Piwell
2016-04-05 12:13:30 -04:00
parent b1a009e1b0
commit ca9adfeb44
12 changed files with 60 additions and 153 deletions

View File

@@ -51,19 +51,14 @@ bool CygnetPlane::isReady(){
void CygnetPlane::createPlane(){
glGenVertexArrays(1, &_quad); // generate array
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
// ============================
// GEOMETRY (quad)
// ============================
// GLfloat x, y, w;
// if(!_data){
// x = _modelScale.x/2.0;
// y = _modelScale.z/2.0;
// w = _modelScale.w;
// }else{
const GLfloat x = _data->scale.x/2.0;
const GLfloat y = _data->scale.z/2.0;
const GLfloat w = _data->scale.w;
// }
const GLfloat vertex_data[] = { // square of two triangles (sigh)
// x y z w s t
-x, -y, 0, w, 0, 1,

View File

@@ -40,24 +40,6 @@ namespace {
}
namespace openspace {
// DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path)
// :CygnetPlane(1, path)
// , _kw(kw)
// {
// _id = id();
// setName("DataPlane" + std::to_string(_id));
// registerProperties();
// KameleonWrapper::Model model = _kw->model();
// if( model == KameleonWrapper::Model::BATSRUS){
// _var = "p";
// }else{
// _var = "rho";
// }
// }
DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metadata> data)
:CygnetPlane(data)
, _kw(kw)
@@ -67,18 +49,10 @@ DataPlane::DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metada
registerProperties();
KameleonWrapper::Model model = _kw->model();
if( model == KameleonWrapper::Model::BATSRUS){
if( model == KameleonWrapper::Model::BATSRUS)
_var = "p";
}else{
else
_var = "rho";
}
if(!_data){
std::cout << "No data" << std::endl;
}else{
std::cout << _data->parent << std::endl;
}
}
DataPlane::~DataPlane(){}
@@ -98,12 +72,13 @@ bool DataPlane::initialize(){
}
bool DataPlane::deinitialize(){
_parent = nullptr;
unregisterProperties();
destroyPlane();
destroyShader();
_kw = nullptr;
_parent = nullptr;
_kw = nullptr;
return true;
}
@@ -125,30 +100,24 @@ void DataPlane::render(){
}
transform = transform * rotz * roty; //BATSRUS
// transform = transform * roty;
// transform = glm::rotate(transform, _roatation.value()[0], glm::vec3(1,0,0));
// transform = glm::rotate(transform, _roatation.value()[1], glm::vec3(0,1,0));
// transform = glm::rotate(transform, _roatation.value()[2], glm::vec3(0,0,1));
if(_data->frame = "GSM"){
glm::vec4 v(1,0,0,1);
glm::vec3 xVec = glm::vec3(transform*v);
xVec = glm::normalize(xVec);
glm::vec4 v(1,0,0,1);
glm::vec3 xVec = glm::vec3(transform*v);
xVec = glm::normalize(xVec);
double lt;
glm::vec3 sunVec =
SpiceManager::ref().targetPosition("SUN", "Earth", "GALACTIC", {}, _time, lt);
sunVec = glm::normalize(sunVec);
double lt;
glm::vec3 sunVec =
SpiceManager::ref().targetPosition("SUN", "Earth", "GALACTIC", {}, _time, lt);
sunVec = glm::normalize(sunVec);
float angle = acos(glm::dot(xVec, sunVec));
glm::vec3 ref = glm::cross(xVec, sunVec);
float angle = acos(glm::dot(xVec, sunVec));
glm::vec3 ref = glm::cross(xVec, sunVec);
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), angle, ref);
transform = rotation * transform;
}
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), angle, ref);
transform = rotation * transform;
// if(!_data)
// position += transform*glm::vec4(_pscOffset.x, _pscOffset.z, _pscOffset.y, _pscOffset.w);
// else
position += transform*glm::vec4(_data->offset.x, _data->offset.z, _data->offset.y, _data->offset.w);
// Activate shader
@@ -178,10 +147,6 @@ void DataPlane::update(){
createPlane();
_time = Time::ref().currentTime();
// if(!_data)
// _stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time);
// else
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _data->frame, _time);
_openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval;
@@ -195,11 +160,11 @@ void DataPlane::update(){
}
void DataPlane::loadTexture() {
//std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear;
ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge;
std::unique_ptr<ghoul::opengl::Texture> texture =
std::make_unique<ghoul::opengl::Texture>(_dataSlice, _dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode);
if (texture) {
// LDEBUG("Loaded texture from '" << absPath(_path) << "'");
@@ -216,7 +181,7 @@ void DataPlane::loadTexture() {
void DataPlane::updateTexture(){}
int DataPlane::id(){
static int id = 0;
return id++;
static int id = 0;
return id++;
}
}// namespace openspace

View File

@@ -32,7 +32,6 @@
class DataPlane : public CygnetPlane {
public:
// DataPlane(std::shared_ptr<KameleonWrapper> kw, std::string path);
DataPlane(std::shared_ptr<KameleonWrapper> kw, std::shared_ptr<Metadata> data);
~DataPlane();

View File

@@ -30,31 +30,25 @@
#include <modules/iswa/util/iswamanager.h>
namespace openspace{
ISWAContainer::ISWAContainer(const ghoul::Dictionary& dictionary)
:Renderable(dictionary)
{
std::cout << "Created ISWAContainer" << std::endl;
}
{}
ISWAContainer::~ISWAContainer(){}
bool ISWAContainer::initialize(){
std::cout << "Initialized ISWAContainer" << std::endl;
ISWAManager::initialize();
ISWAManager::ref().setContainer(this);
// addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf");
// addISWACygnet("${OPENSPACE_DATA}/ENLIL.cdf");
//addISWACygnet("${OPENSPACE_DATA}/test.png");
addISWACygnet(5, "Screen");
// addISWACygnet(5, "Screen");
// addISWACygnet(7, "Sun");
return true;
}
bool ISWAContainer::deinitialize(){
for(auto iSWACygnet : _iSWACygnets)
iSWACygnet->deinitialize();
@@ -140,7 +134,6 @@ void ISWAContainer::deleteCygnet(std::string name){
}
}
std::shared_ptr<ISWACygnet> ISWAContainer::iSWACygnet(std::string name){
for(auto cygnet : _iSWACygnets){
if(cygnet->name() == name){

View File

@@ -57,7 +57,6 @@ private:
std::vector<std::shared_ptr<ISWACygnet>> _iSWACygnets;
std::vector<std::shared_ptr<ExtensionFuture>> _extFutures;
std::vector<std::shared_ptr<ISWACygnet>> _deletedCygnets;
};
}//namespace openspace

View File

@@ -30,33 +30,12 @@
namespace openspace{
// ISWACygnet::ISWACygnet(int cygnetId, std::string path)
// : _enabled("enabled", "Is Enabled", true)
// , _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
// , _delete("delete", "Delete")
// , _cygnetId(cygnetId)
// , _shader(nullptr)
// , _texture(nullptr)
// , _frame("GALACTIC")
// , _path(path)
// , _data(nullptr)
// {
// addProperty(_enabled);
// addProperty(_updateInterval);
// addProperty(_delete);
// _delete.onChange([this](){ISWAManager::ref().deleteCygnet(name());});
// }
ISWACygnet::ISWACygnet(std::shared_ptr<Metadata> data)
: _enabled("enabled", "Is Enabled", true)
, _updateInterval("updateInterval", "Update Interval", 3, 1, 10)
, _delete("delete", "Delete")
// , _cygnetId(data->id)
, _shader(nullptr)
, _texture(nullptr)
// , _frame(data->frame)
// , _path(data->path)
, _data(data)
{
addProperty(_enabled);

View File

@@ -46,7 +46,6 @@
namespace openspace{
class ISWACygnet : public properties::PropertyOwner{
public:
// ISWACygnet(int cygnetId, std::string path);
ISWACygnet(std::shared_ptr<Metadata> data);
~ISWACygnet();
@@ -63,7 +62,6 @@ protected:
void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position);
void registerProperties();
void unregisterProperties();
void setParent();
properties::BoolProperty _enabled;

View File

@@ -45,7 +45,6 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(int cygnetId, std::string path)
setName("ScreenSpaceCygnet" + std::to_string(_id));
addProperty(_updateInterval);
// registerProperties();
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
OsEng.gui()._iSWAproperty.registerProperty(&_useFlatScreen);
OsEng.gui()._iSWAproperty.registerProperty(&_euclideanPosition);
@@ -68,7 +67,6 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(std::shared_ptr<Metadata> data)
setName("ScreenSpaceCygnet" + std::to_string(_id));
addProperty(_updateInterval);
// registerProperties();
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
OsEng.gui()._iSWAproperty.registerProperty(&_useFlatScreen);
OsEng.gui()._iSWAproperty.registerProperty(&_euclideanPosition);
@@ -154,13 +152,6 @@ void ScreenSpaceCygnet::update(){
}
void ScreenSpaceCygnet::updateTexture(){
DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path));
if(future){
_futureTexture = future;
}
}
bool ScreenSpaceCygnet::isReady() const{
bool ready = true;
if (!_shader)
@@ -170,6 +161,13 @@ bool ScreenSpaceCygnet::isReady() const{
return ready;
}
void ScreenSpaceCygnet::updateTexture(){
DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_cygnetId, absPath(_path));
if(future){
_futureTexture = future;
}
}
void ScreenSpaceCygnet::loadTexture() {
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_path));

View File

@@ -41,16 +41,6 @@ namespace {
}
namespace openspace {
// TexturePlane::TexturePlane(int cygnetId, std::string path)
// :CygnetPlane(cygnetId, path)
// ,_futureTexture(nullptr)
// {
// _id = id();
// setName("TexturePlane" + std::to_string(_id));
// registerProperties();
// }
TexturePlane::TexturePlane(std::shared_ptr<Metadata> data)
:CygnetPlane(data)
,_futureTexture(nullptr)
@@ -60,15 +50,12 @@ TexturePlane::TexturePlane(std::shared_ptr<Metadata> data)
registerProperties();
}
TexturePlane::~TexturePlane(){}
bool TexturePlane::initialize(){
setParent();
createPlane();
createShader();
updateTexture();
return isReady();
}
@@ -153,14 +140,6 @@ void TexturePlane::update(){
}
}
void TexturePlane::updateTexture(){
DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_data->id, absPath(_data->path));
if(future){
_futureTexture = future;
}
}
void TexturePlane::loadTexture() {
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_data->path));
@@ -177,6 +156,13 @@ void TexturePlane::loadTexture() {
}
void TexturePlane::updateTexture(){
DownloadManager::FileFuture* future = ISWAManager::ref().downloadImage(_data->id, absPath(_data->path));
if(future){
_futureTexture = future;
}
}
int TexturePlane::id(){
static int id = 0;
return id++;

View File

@@ -34,7 +34,6 @@
class TexturePlane : public CygnetPlane{
public:
// TexturePlane(int cygnetId, std::string path);
TexturePlane(std::shared_ptr<Metadata> data);
~TexturePlane();

View File

@@ -51,21 +51,6 @@ namespace openspace{
ISWAManager::~ISWAManager(){}
void ISWAManager::addCygnet(std::string info){
std::string token;
std::stringstream ss(info);
getline(ss,token,',');
int cygnetId = std::stoi(token);
getline(ss,token,',');
std::string data = token;
if(cygnetId != 0)
_container->addISWACygnet(cygnetId, data);
else
_container->addISWACygnet("${OPENSPACE_DATA}/"+data);
}
std::shared_ptr<ISWACygnet> ISWAManager::createISWACygnet(std::shared_ptr<Metadata> metadata){
std::cout << "createISWACygnet " << metadata->id << std::endl;
if(metadata->path != ""){
@@ -102,6 +87,25 @@ namespace openspace{
}
}
void ISWAManager::addCygnet(std::string info){
std::string token;
std::stringstream ss(info);
getline(ss,token,',');
int cygnetId = std::stoi(token);
getline(ss,token,',');
std::string data = token;
if(cygnetId != 0)
_container->addISWACygnet(cygnetId, data);
else
_container->addISWACygnet("${OPENSPACE_DATA}/"+data);
}
void ISWAManager::deleteCygnet(std::string name){
_container->deleteCygnet(name);
}
DownloadManager::FileFuture* ISWAManager::downloadImage(int id, std::string path){
return DlManager.downloadFile(
@@ -118,7 +122,6 @@ namespace openspace{
void ISWAManager::downloadData(){}
std::shared_ptr<ExtensionFuture> ISWAManager::fileExtension(int id){
std::shared_ptr<ExtensionFuture> extFuture = std::make_shared<ExtensionFuture>();
extFuture->isFinished = false;
extFuture->id = id;
@@ -154,10 +157,6 @@ namespace openspace{
return nullptr;
}
void ISWAManager::deleteCygnet(std::string name){
_container->deleteCygnet(name);
}
std::string ISWAManager::iSWAurl(int id){
std::string url = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?timestamp=";
std::string t = Time::ref().currentTimeUTC();

View File

@@ -60,19 +60,16 @@ public:
ISWAManager();
~ISWAManager();
std::shared_ptr<ISWACygnet> createISWACygnet(int, std::string);
std::shared_ptr<ISWACygnet> createISWACygnet(std::shared_ptr<Metadata> metadata);
void addCygnet(std::string info);
void deleteCygnet(std::string);
DownloadManager::FileFuture* downloadImage(int, std::string);
void downloadData();
std::shared_ptr<ExtensionFuture> fileExtension(int);
void setContainer(ISWAContainer*);
std::shared_ptr<ISWACygnet> iSWACygnet(std::string);
void deleteCygnet(ISWACygnet*);
void deleteCygnet(std::string);
private:
std::string iSWAurl(int);