Delete cygnets

This commit is contained in:
Sebastian Piwell
2016-04-04 11:58:42 -04:00
parent 66a9aeb008
commit 7eb312d10b
12 changed files with 117 additions and 37 deletions

View File

@@ -91,7 +91,9 @@ bool DataPlane::initialize(){
}
bool DataPlane::deinitialize(){
ISWACygnet::deinitialize();
CygnetPlane::deinitialize();
_kw = nullptr;
return true;
}
@@ -215,32 +217,6 @@ void DataPlane::loadTexture() {
}
// void DataPlane::createPlane() {
// // ============================
// // GEOMETRY (quad)
// // ============================
// const GLfloat x = _modelScale.x/2.0;
// const GLfloat y = _modelScale.z/2.0;
// const GLfloat w = _modelScale.w;
// const GLfloat vertex_data[] = { // square of two triangles (sigh)
// // x y z w s t
// -x, -y, 0, w, 0, 1,
// x, y, 0, w, 1, 0,
// -x, y, 0, w, 0, 0,
// -x, -y, 0, w, 0, 1,
// x, -y, 0, w, 1, 1,
// x, y, 0, w, 1, 0,
// };
// glBindVertexArray(_quad); // bind array
// glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
// glEnableVertexAttribArray(0);
// glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
// glEnableVertexAttribArray(1);
// glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
// }
void DataPlane::updateTexture(){}
int DataPlane::id(){

View File

@@ -44,6 +44,7 @@ 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");
@@ -72,6 +73,10 @@ void ISWAContainer::render(const RenderData& data){
}
void ISWAContainer::update(const UpdateData& data){
if(!_deletedCygnets.empty())
_deletedCygnets.clear();
for(auto iSWACygnet : _iSWACygnets)
iSWACygnet->update();
}
@@ -99,6 +104,22 @@ void ISWAContainer::addISWACygnet(std::string path){
// }
}
void ISWAContainer::deleteCygnet(std::string name){
std::shared_ptr<ISWACygnet> c = iSWACygnet(name);
auto it = std::find(
_iSWACygnets.begin(),
_iSWACygnets.end(),
c
);
if (it != _iSWACygnets.end()) {
c->deinitialize();
_deletedCygnets.push_back(c);
_iSWACygnets.erase(it);
}
}
std::shared_ptr<ISWACygnet> ISWAContainer::iSWACygnet(std::string name){
for(auto cygnet : _iSWACygnets){

View File

@@ -29,7 +29,7 @@
namespace openspace{
class ISWACygnet;
class ISWAContainer : public Renderable {
class ISWAContainer : public Renderable{
public:
ISWAContainer(const ghoul::Dictionary& dictionary);
~ISWAContainer();
@@ -44,11 +44,14 @@ public:
void addISWACygnet(std::string path);
void deleteCygnet(ISWACygnet*);
void deleteCygnet(std::string);
std::shared_ptr<ISWACygnet> iSWACygnet(std::string name);
private:
std::vector<std::shared_ptr<ISWACygnet>> _iSWACygnets;
std::vector<std::shared_ptr<ISWACygnet>> _deletedCygnets;
};
}//namespace openspace

View File

@@ -35,6 +35,7 @@ ISWACygnet::ISWACygnet()
:_enabled("enabled", "Is Enabled", true)
,_cygnetId("cygnetId", "CygnetID",7, 0, 10)
,_updateInterval("updateInterval", "Update Interval", 3, 1, 10)
,_delete("delete", "Delete")
,_shader(nullptr)
,_texture(nullptr)
,_frame("GALACTIC")
@@ -42,6 +43,9 @@ ISWACygnet::ISWACygnet()
addProperty(_enabled);
addProperty(_cygnetId);
addProperty(_updateInterval);
addProperty(_delete);
_delete.onChange([this](){ISWAManager::ref().deleteCygnet(name());});
}
ISWACygnet::~ISWACygnet(){}
@@ -52,6 +56,7 @@ bool ISWACygnet::initialize(){
}
bool ISWACygnet::deinitialize(){
OsEng.gui()._iSWAproperty.unregisterProperties(name());
_parent = nullptr;
return true;
}
@@ -74,9 +79,10 @@ void ISWACygnet::setPscUniforms(
}
void ISWACygnet::registerProperties(){
OsEng.gui()._property.registerProperty(&_enabled);
OsEng.gui()._property.registerProperty(&_cygnetId);
OsEng.gui()._property.registerProperty(&_updateInterval);
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
OsEng.gui()._iSWAproperty.registerProperty(&_cygnetId);
OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
}
}//namespace openspac

View File

@@ -33,6 +33,7 @@
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/properties/scalarproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/scene/scenegraphnode.h>
#include <modules/onscreengui/include/gui.h>
#include <ghoul/opengl/texture.h>
@@ -61,6 +62,7 @@ protected:
properties::BoolProperty _enabled;
properties::IntProperty _cygnetId;
properties::FloatProperty _updateInterval;
properties::TriggerProperty _delete;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
std::unique_ptr<ghoul::opengl::Texture> _texture;

View File

@@ -44,9 +44,16 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(int cygnetId)
addProperty(_cygnetId);
addProperty(_updateInterval);
registerProperties();
OsEng.gui()._property.registerProperty(&_cygnetId);
OsEng.gui()._property.registerProperty(&_updateInterval);
// registerProperties();
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
OsEng.gui()._iSWAproperty.registerProperty(&_useFlatScreen);
OsEng.gui()._iSWAproperty.registerProperty(&_euclideanPosition);
OsEng.gui()._iSWAproperty.registerProperty(&_sphericalPosition);
OsEng.gui()._iSWAproperty.registerProperty(&_depth);
OsEng.gui()._iSWAproperty.registerProperty(&_scale);
OsEng.gui()._iSWAproperty.registerProperty(&_alpha);
OsEng.gui()._iSWAproperty.registerProperty(&_cygnetId);
OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
_fileExtension = "";
_path = "";

View File

@@ -28,9 +28,13 @@
#include <modules/iswa/rendering/dataplane.h>
#include <modules/iswa/rendering/textureplane.h>
#include <openspace/util/time.h>
#include <modules/iswa/rendering/iswacontainer.h>
namespace openspace{
ISWAManager::ISWAManager(){
ISWAManager::ISWAManager()
:_container(nullptr)
{
_month["JAN"] = "01";
_month["FEB"] = "02";
_month["MAR"] = "03";
@@ -102,6 +106,20 @@ namespace openspace{
);
}
void ISWAManager::setContainer(ISWAContainer* container){
_container = container;
}
std::shared_ptr<ISWACygnet> ISWAManager::iSWACygnet(std::string name){
if(_container)
return _container->iSWACygnet(name);
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

@@ -31,6 +31,7 @@
namespace openspace {
class ISWACygnet;
class ISWAContainer;
class ISWAManager : public ghoul::Singleton<ISWAManager> {
friend class ghoul::Singleton<ISWAManager>;
@@ -42,9 +43,16 @@ public:
DownloadManager::FileFuture* downloadImage(int, std::string);
void downloadData();
void fileExtension(int, std::string*);
void setContainer(ISWAContainer*);
std::shared_ptr<ISWACygnet> iSWACygnet(std::string);
void deleteCygnet(ISWACygnet*);
void deleteCygnet(std::string);
private:
std::string iSWAurl(int);
std::map<std::string, std::string> _month;
ISWAContainer* _container;
};
} //namespace openspace

View File

@@ -71,6 +71,7 @@ public:
GuiOriginComponent _origin;
GuiPerformanceComponent _performance;
GuiPropertyComponent _property;
GuiPropertyComponent _iSWAproperty;
GuiTimeComponent _time;
bool _isEnabled;

View File

@@ -44,6 +44,7 @@ class GuiPropertyComponent : public GuiComponent {
public:
//void registerProperty(const std::string& propertyDescription);
void registerProperty(properties::Property* prop);
void unregisterProperties(std::string owner);
void render();
protected:

View File

@@ -203,6 +203,7 @@ void GUI::initialize() {
//io.GetClipboardTextFn = ImImpl_GetClipboardTextFn; // @TODO implement? ---abock
_property.initialize();
_iSWAproperty.initialize();
_performance.initialize();
_help.initialize();
}
@@ -249,6 +250,7 @@ void GUI::initializeGL() {
_property.initializeGL();
_iSWAproperty.initializeGL();
_performance.initializeGL();
_help.initializeGL();
}
@@ -260,6 +262,7 @@ void GUI::deinitializeGL() {
glDeleteBuffers(1, &vbo);
_property.deinitializeGL();
_iSWAproperty.deinitializeGL();
_performance.deinitializeGL();
_help.deinitializeGL();
}
@@ -288,6 +291,8 @@ void GUI::endFrame() {
if (_property.isEnabled())
_property.render();
if (_iSWAproperty.isEnabled())
_iSWAproperty.render();
if (_performance.isEnabled())
_performance.render();
if (_help.isEnabled())
@@ -387,6 +392,7 @@ void GUI::renderMainWindow() {
ImGui::Begin("OpenSpace GUI", nullptr);
ImGui::Checkbox("Properties", &_property._isEnabled);
ImGui::Checkbox("iSWA Properties", &_iSWAproperty._isEnabled);
ImGui::Checkbox("Performance", &_performance._isEnabled);
_origin.render();
_time.render();

View File

@@ -195,7 +195,7 @@ namespace {
std::string name = prop->guiName();
bool pressed = ImGui::Button((ownerName + "." + name).c_str());
if (pressed)
executeScript(prop->fullyQualifiedIdentifier(), "0");
executeScript(prop->fullyQualifiedIdentifier(), "nil");
}
//void renderBoolProperty(Property* prop, const std::string& ownerName) {
@@ -383,6 +383,37 @@ void GuiPropertyComponent::registerProperty(properties::Property* prop) {
//handleProperty(dictionary);
}
void GuiPropertyComponent::unregisterProperties(std::string owner){
auto it = _propertiesByOwner.find(owner);
if(it != _propertiesByOwner.end()){
for(prop : it->second){
std::string className = prop->className();
if (className == "BoolProperty")
_boolProperties.insert(prop);
else if (className == "IntProperty")
_intProperties.insert(prop);
else if (className == "FloatProperty")
_floatProperties.insert(prop);
else if (className == "StringProperty")
_stringProperties.insert(prop);
else if (className == "Vec2Property")
_vec2Properties.insert(prop);
else if (className == "Vec3Property")
_vec3Properties.insert(prop);
else if (className == "Vec4Property")
_vec4Properties.insert(prop);
else if (className == "OptionProperty")
_optionProperties.insert(prop);
else if (className == "TriggerProperty")
_triggerProperties.insert(prop);
else if (className == "SelectionProperty")
_selectionProperties.insert(prop);
}
it->second.clear();
_propertiesByOwner.erase(it);
}
}
void GuiPropertyComponent::handleProperty(const ghoul::Dictionary& dictionary) {
//static const std::string TypeKey = "Type";
//static const std::string IdentifierKey = "Identifier";