solve merge conflict

This commit is contained in:
Michael Nilsson
2016-04-04 16:02:27 -04:00
20 changed files with 197 additions and 57 deletions

View File

@@ -104,6 +104,7 @@ public:
void registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::string name);
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(std::string name);
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
@@ -179,6 +180,7 @@ private:
std::vector<ghoul::opengl::ProgramObject*> _programs;
std::vector<std::shared_ptr<ScreenSpaceRenderable>> _screenSpaceRenderables;
std::vector<std::shared_ptr<ScreenSpaceRenderable>> _deletedScreenSpaceRenderables;
std::shared_ptr<ghoul::fontrendering::Font> _fontInfo = nullptr;
std::shared_ptr<ghoul::fontrendering::Font> _fontDate = nullptr;

View File

@@ -30,6 +30,7 @@
#include <openspace/properties/vectorproperty.h>
#include <openspace/properties/scalarproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <ghoul/opengl/texture.h>
#include <modules/onscreengui/include/gui.h>
#include <openspace/rendering/renderengine.h>
@@ -88,6 +89,8 @@ protected:
*/
glm::vec2 toSpherical(glm::vec2 euclidean);
void registerProperties();
void unregisterProperties();
void createShaders();
glm::mat4 scaleMatrix();
glm::mat4 rotationMatrix();
@@ -101,6 +104,7 @@ protected:
properties::FloatProperty _depth;
properties::FloatProperty _scale;
properties::FloatProperty _alpha;
properties::TriggerProperty _delete;
GLuint _quad;
GLuint _vertexPositionBuffer;
@@ -115,7 +119,8 @@ protected:
const float _planeDepth = -2.0;
glm::vec2 _originalViewportSize;
float _radius;
float _radius;
bool _toDelete;
};
} // namespace openspace
#endif // __SCREENSPACERENDERABLE_H__

View File

@@ -43,7 +43,7 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer()
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
addProperty(_size);
OsEng.gui()._property.registerProperty(&_size);
OsEng.gui()._screenSpaceProperty.registerProperty(&_size);
_size.set(glm::vec4(0, 0, resolution.x,resolution.y));
_scale.setValue(1.0f);
@@ -62,6 +62,8 @@ bool ScreenSpaceFramebuffer::initialize(){
}
bool ScreenSpaceFramebuffer::deinitialize(){
unregisterProperties();
glDeleteVertexArrays(1, &_quad);
_quad = 0;
@@ -114,7 +116,10 @@ void ScreenSpaceFramebuffer::render(){
}
}
void ScreenSpaceFramebuffer::update(){}
void ScreenSpaceFramebuffer::update(){
// if(_toDelete)
// OsEng.renderEngine().unregisterScreenSpaceRenderable(name());
}
bool ScreenSpaceFramebuffer::isReady() const{
bool ready = true;

View File

@@ -41,7 +41,7 @@ ScreenSpaceImage::ScreenSpaceImage(std::string texturePath)
registerProperties();
addProperty(_texturePath);
OsEng.gui()._property.registerProperty(&_texturePath);
OsEng.gui()._screenSpaceProperty.registerProperty(&_texturePath);
_texturePath.onChange([this](){ loadTexture(); });
}
@@ -58,6 +58,8 @@ bool ScreenSpaceImage::initialize(){
}
bool ScreenSpaceImage::deinitialize(){
unregisterProperties();
glDeleteVertexArrays(1, &_quad);
_quad = 0;
@@ -85,7 +87,10 @@ void ScreenSpaceImage::render(){
draw(modelTransform);
}
void ScreenSpaceImage::update(){}
void ScreenSpaceImage::update(){
// if(_toDelete)
// OsEng.renderEngine().unregisterScreenSpaceRenderable(name());
}
bool ScreenSpaceImage::isReady() const{

View File

@@ -81,6 +81,8 @@ bool CygnetPlane::isReady(){
void CygnetPlane::render(){}
void CygnetPlane::update(){
ISWACygnet::update();
_time = Time::ref().currentTime();
_stateMatrix = SpiceManager::ref().positionTransformMatrix("GALACTIC", _frame, _time);
_openSpaceUpdateInterval = Time::ref().deltaTime()*_updateInterval;

View File

@@ -80,7 +80,9 @@ bool DataPlane::initialize(){
}
bool DataPlane::deinitialize(){
ISWACygnet::deinitialize();
CygnetPlane::deinitialize();
_kw = nullptr;
return true;
}
@@ -196,32 +198,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

@@ -42,6 +42,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");
@@ -87,6 +88,8 @@ void ISWAContainer::update(const UpdateData& data){
}
}
if(!_deletedCygnets.empty())
_deletedCygnets.clear();
for(auto& iSWACygnet : _iSWACygnets)
iSWACygnet->update();
@@ -106,6 +109,22 @@ void ISWAContainer::addISWACygnet(int id){
_extFutures.push_back(extFuture);
}
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

@@ -31,7 +31,7 @@ namespace openspace{
class ISWACygnet;
struct ExtensionFuture;
class ISWAContainer : public Renderable {
class ISWAContainer : public Renderable{
public:
ISWAContainer(const ghoul::Dictionary& dictionary);
~ISWAContainer();
@@ -47,11 +47,15 @@ public:
void addISWACygnet(std::string path);
void addISWACygnet(int id);
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<ExtensionFuture>> _extFutures;
std::vector<std::shared_ptr<ISWACygnet>> _deletedCygnets;
};
}//namespace openspace

View File

@@ -34,14 +34,19 @@ 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)
,_toDelete(false)
{
addProperty(_enabled);
addProperty(_updateInterval);
addProperty(_delete);
_delete.onChange([this](){ISWAManager::ref().deleteCygnet(name());});
}
ISWACygnet::~ISWACygnet(){}
@@ -53,6 +58,7 @@ bool ISWACygnet::initialize(){
}
bool ISWACygnet::deinitialize(){
OsEng.gui()._iSWAproperty.unregisterProperties(name());
_parent = nullptr;
return true;
}
@@ -75,8 +81,11 @@ void ISWACygnet::setPscUniforms(
}
void ISWACygnet::registerProperties(){
OsEng.gui()._property.registerProperty(&_enabled);
OsEng.gui()._property.registerProperty(&_updateInterval);
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
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>
@@ -60,6 +61,7 @@ protected:
properties::BoolProperty _enabled;
properties::FloatProperty _updateInterval;
properties::TriggerProperty _delete;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
std::unique_ptr<ghoul::opengl::Texture> _texture;
@@ -82,6 +84,8 @@ protected:
float _openSpaceUpdateInterval;
bool _toDelete;
int _id;
};

View File

@@ -44,9 +44,17 @@ 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);
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
_fileExtension = "";
_path = "";
@@ -76,6 +84,8 @@ bool ScreenSpaceCygnet::initialize(){
}
bool ScreenSpaceCygnet::deinitialize(){
OsEng.gui()._iSWAproperty.unregisterProperties(name());
glDeleteVertexArrays(1, &_quad);
_quad = 0;
@@ -99,6 +109,7 @@ bool ScreenSpaceCygnet::deinitialize(){
void ScreenSpaceCygnet::render(){
if(!isReady()) return;
if(!_enabled) return;
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
@@ -109,6 +120,8 @@ void ScreenSpaceCygnet::render(){
}
void ScreenSpaceCygnet::update(){
if(_toDelete)
OsEng.renderEngine().unregisterScreenSpaceRenderable(name());
if(_path != ""){
_time = Time::ref().currentTime();

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";
@@ -109,6 +113,20 @@ namespace openspace{
return extFuture;
}
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;
struct ExtensionFuture {
@@ -50,10 +51,19 @@ public:
std::shared_ptr<ISWACygnet> createISWACygnet(int, 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);
std::map<std::string, std::string> _month;
ISWAContainer* _container;
};
} //namespace openspace

View File

@@ -71,6 +71,8 @@ public:
GuiOriginComponent _origin;
GuiPerformanceComponent _performance;
GuiPropertyComponent _property;
GuiPropertyComponent _iSWAproperty;
GuiPropertyComponent _screenSpaceProperty;
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,8 @@ void GUI::initialize() {
//io.GetClipboardTextFn = ImImpl_GetClipboardTextFn; // @TODO implement? ---abock
_property.initialize();
_iSWAproperty.initialize();
_screenSpaceProperty.initialize();
_performance.initialize();
_help.initialize();
}
@@ -249,6 +251,8 @@ void GUI::initializeGL() {
_property.initializeGL();
_iSWAproperty.initializeGL();
_screenSpaceProperty.initializeGL();
_performance.initializeGL();
_help.initializeGL();
}
@@ -260,6 +264,8 @@ void GUI::deinitializeGL() {
glDeleteBuffers(1, &vbo);
_property.deinitializeGL();
_iSWAproperty.deinitializeGL();
_screenSpaceProperty.deinitializeGL();
_performance.deinitializeGL();
_help.deinitializeGL();
}
@@ -288,6 +294,10 @@ void GUI::endFrame() {
if (_property.isEnabled())
_property.render();
if (_iSWAproperty.isEnabled())
_iSWAproperty.render();
if (_screenSpaceProperty.isEnabled())
_screenSpaceProperty.render();
if (_performance.isEnabled())
_performance.render();
if (_help.isEnabled())
@@ -386,7 +396,9 @@ bool GUI::charCallback(unsigned int character, KeyModifier modifier) {
void GUI::renderMainWindow() {
ImGui::Begin("OpenSpace GUI", nullptr);
ImGui::Checkbox("Properties", &_property._isEnabled);
ImGui::Checkbox("Scene Graph Properties", &_property._isEnabled);
ImGui::Checkbox("ScreenSpace Properties", &_screenSpaceProperty._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";

View File

@@ -72,15 +72,7 @@ properties::Property* property(const std::string& uri) {
const std::string nameUri = uri.substr(0, nameSeparator);
const std::string remainingUri = uri.substr(nameSeparator + 1);
SceneGraphNode* node = sceneGraphNode("iSWA");
if(node){
std::shared_ptr<ISWACygnet> cygnet = static_cast <ISWAContainer*>(node->renderable())->iSWACygnet(nameUri);
if(cygnet){
return cygnet->property(remainingUri);
}
}
node = sceneGraphNode(nameUri);
SceneGraphNode* node = sceneGraphNode(nameUri);
if (node) {
properties::Property* property = node->property(remainingUri);
return property;
@@ -91,6 +83,11 @@ properties::Property* property(const std::string& uri) {
properties::Property* property = ssr->property(remainingUri);
return property;
}
std::shared_ptr<ISWACygnet> cygnet = ISWAManager::ref().iSWACygnet(nameUri);
if(cygnet){
return cygnet->property(remainingUri);
}
LERROR("Node, iSWACygnet or ScreenSpaceRenderable' " << nameUri << "' did not exist");
return nullptr;

View File

@@ -376,6 +376,9 @@ void RenderEngine::postSynchronizationPreDraw() {
}
}
if(!_deletedScreenSpaceRenderables.empty())
_deletedScreenSpaceRenderables.clear();
for (auto screenspacerenderable : _screenSpaceRenderables) {
screenspacerenderable->update();
}
@@ -1146,10 +1149,17 @@ void RenderEngine::unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRe
if (it != _screenSpaceRenderables.end()) {
s->deinitialize();
_deletedScreenSpaceRenderables.push_back(s);
_screenSpaceRenderables.erase(it);
}
}
void RenderEngine::unregisterScreenSpaceRenderable(std::string name){
auto s = screenSpaceRenderable(name);
if(s)
unregisterScreenSpaceRenderable(s);
}
std::shared_ptr<ScreenSpaceRenderable> RenderEngine::screenSpaceRenderable(std::string name){
for(auto s : _screenSpaceRenderables){
if(s->name() == name){

View File

@@ -33,6 +33,7 @@ ScreenSpaceRenderable::ScreenSpaceRenderable()
, _depth("depth", "Depth", 0, 0, 1)
, _scale("scale", "Scale" , 0.5, 0, 2)
, _alpha("alpha", "Alpha" , 1, 0, 1)
,_delete("delete", "Delete")
, _quad(0)
, _vertexPositionBuffer(0)
,_rendererPath("${SHADERS}/framebuffer/renderframebuffer.frag")
@@ -40,6 +41,7 @@ ScreenSpaceRenderable::ScreenSpaceRenderable()
,_fragmentPath("${MODULE_BASE}/shaders/screnspace_fs.glsl")
,_texture(nullptr)
,_shader(nullptr)
,_toDelete(false)
{
addProperty(_enabled);
addProperty(_useFlatScreen);
@@ -48,6 +50,7 @@ ScreenSpaceRenderable::ScreenSpaceRenderable()
addProperty(_depth);
addProperty(_scale);
addProperty(_alpha);
addProperty(_delete);
_rendererData = ghoul::Dictionary();
_rendererData.setValue("fragmentRendererPath", _rendererPath);
@@ -70,11 +73,18 @@ ScreenSpaceRenderable::ScreenSpaceRenderable()
_useFlatScreen.onChange([this](){
useEuclideanCoordinates(_useFlatScreen.value());
});
_delete.onChange([this](){OsEng.renderEngine().unregisterScreenSpaceRenderable(name());});
}
ScreenSpaceRenderable::~ScreenSpaceRenderable(){}
//deinitialzie(){
// unregisterProperies
// }
bool ScreenSpaceRenderable::isEnabled() const {
return _enabled;
}
@@ -129,13 +139,18 @@ glm::vec2 ScreenSpaceRenderable::toSpherical(glm::vec2 euclidean){
}
void ScreenSpaceRenderable::registerProperties(){
OsEng.gui()._property.registerProperty(&_enabled);
OsEng.gui()._property.registerProperty(&_useFlatScreen);
OsEng.gui()._property.registerProperty(&_euclideanPosition);
OsEng.gui()._property.registerProperty(&_sphericalPosition);
OsEng.gui()._property.registerProperty(&_depth);
OsEng.gui()._property.registerProperty(&_scale);
OsEng.gui()._property.registerProperty(&_alpha);
OsEng.gui()._screenSpaceProperty.registerProperty(&_enabled);
OsEng.gui()._screenSpaceProperty.registerProperty(&_useFlatScreen);
OsEng.gui()._screenSpaceProperty.registerProperty(&_euclideanPosition);
OsEng.gui()._screenSpaceProperty.registerProperty(&_sphericalPosition);
OsEng.gui()._screenSpaceProperty.registerProperty(&_depth);
OsEng.gui()._screenSpaceProperty.registerProperty(&_scale);
OsEng.gui()._screenSpaceProperty.registerProperty(&_alpha);
OsEng.gui()._screenSpaceProperty.registerProperty(&_delete);
}
void ScreenSpaceRenderable::unregisterProperties(){
OsEng.gui()._screenSpaceProperty.unregisterProperties(name());
}
void ScreenSpaceRenderable::createShaders(){