mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 19:29:04 -05:00
Merge branch 'feature/iSWA' of github.com:OpenSpace/OpenSpace-Development into feature/iSWA
This commit is contained in:
+1
-1
Submodule ext/ghoul updated: 960bf261b1...11bac4f34a
@@ -34,6 +34,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacecygnet.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/colorbar.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/util/iswamanager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswagroup.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
@@ -47,6 +48,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacecygnet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/colorbar.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/util/iswamanager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswagroup.cpp
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
dictionary.getValue("Name", name);
|
||||
setName(name);
|
||||
|
||||
registerProperties();
|
||||
|
||||
addProperty(_useLog);
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_normValues);
|
||||
@@ -61,15 +63,15 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_transferFunctionsFile);
|
||||
addProperty(_dataOptions);
|
||||
|
||||
registerProperties();
|
||||
if(_data->groupId < 0){
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
}
|
||||
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
|
||||
_normValues.onChange([this](){
|
||||
// FOR TESTING (should be done on all onChange)
|
||||
// _avgBenchmarkTime = 0.0;
|
||||
@@ -83,6 +85,8 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
_transferFunctionsFile.onChange([this](){
|
||||
setTransferFunctions(_transferFunctionsFile.value());
|
||||
});
|
||||
|
||||
_type = ISWAManager::CygnetType::Data;
|
||||
}
|
||||
|
||||
DataPlane::~DataPlane(){}
|
||||
@@ -114,11 +118,18 @@ bool DataPlane::initialize(){
|
||||
// }
|
||||
|
||||
// _textures.push_back(nullptr);
|
||||
ISWAManager::ref().registerToGroup(_data->groupId, this, _type);
|
||||
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool DataPlane::deinitialize(){
|
||||
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().unregisterFromGroup(_data->groupId, this);
|
||||
|
||||
|
||||
unregisterProperties();
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
@@ -281,16 +292,21 @@ void DataPlane::readHeader(){
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> v(1,0);
|
||||
_dataOptions.setValue(v);
|
||||
|
||||
_dataOptions.setValue(std::vector<int>(1,0));
|
||||
|
||||
if(_data->groupId > 0)
|
||||
ISWAManager::ref().registerOptionsToGroup(_data->groupId, _dataOptions.options());
|
||||
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
LWARNING("Noting in memory buffer, are you connected to the information super highway?");
|
||||
}
|
||||
// else{
|
||||
// LWARNING("Noting in memory buffer, are you connected to the information super highway?");
|
||||
// }
|
||||
}
|
||||
|
||||
std::vector<float*> DataPlane::readData(){
|
||||
@@ -381,10 +397,10 @@ std::vector<float*> DataPlane::readData(){
|
||||
return data;
|
||||
|
||||
}
|
||||
else {
|
||||
LWARNING("Nothing in memory buffer, are you connected to the information super highway?");
|
||||
return std::vector<float*>();
|
||||
}
|
||||
// else {
|
||||
// LWARNING("Nothing in memory buffer, are you connected to the information super highway?");
|
||||
// return std::vector<float*>();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <modules/iswa/rendering/colorbar.h>
|
||||
#include <openspace/properties/selectionproperty.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
|
||||
namespace openspace{
|
||||
|
||||
class ISWAGroup;
|
||||
|
||||
class DataPlane : public CygnetPlane {
|
||||
friend class ISWAGroup;
|
||||
public:
|
||||
DataPlane(const ghoul::Dictionary& dictionary);
|
||||
~DataPlane();
|
||||
@@ -43,7 +44,17 @@ class DataPlane : public CygnetPlane {
|
||||
virtual bool deinitialize() override;
|
||||
// virtual void render(const RenderData& data) override; //moved to cygnetPlane
|
||||
// virtual void update(const UpdateData& data) override; //moved to cygnetPlane
|
||||
|
||||
|
||||
protected:
|
||||
void transferFunctionsFile(std::string tfPath){ _transferFunctionsFile.setValue(tfPath); };
|
||||
void normValues(glm::vec2 normValues){ _normValues.setValue(normValues); };
|
||||
void backgroundValues(glm::vec2 backgroundValues){ _backgroundValues.setValue(backgroundValues); };
|
||||
void useLog(bool useLog){ _useLog.setValue(useLog); };
|
||||
void useHistogram(bool useHistogram){ _useHistogram.setValue(useHistogram); };
|
||||
void dataOptions(std::vector<int> options){ _dataOptions.setValue(options); };
|
||||
|
||||
// const std::vector<openspace::properties::SelectionProperty::Option>& dataOptions() const {return _dataOptions.options(); };
|
||||
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
@@ -63,7 +74,7 @@ class DataPlane : public CygnetPlane {
|
||||
float normalizeWithStandardScore(float value, float mean, float sd);
|
||||
float normalizeWithLogarithm(float value, int logMean);
|
||||
|
||||
void setTransferFunctions(std::string id);
|
||||
void setTransferFunctions(std::string tfPath);
|
||||
|
||||
properties::SelectionProperty _dataOptions;
|
||||
properties::StringProperty _transferFunctionsFile;
|
||||
@@ -71,13 +82,6 @@ class DataPlane : public CygnetPlane {
|
||||
properties::Vec2Property _backgroundValues;
|
||||
properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
// properties::BoolProperty _useMultipleTf;
|
||||
// properties::BoolProperty _averageValues;
|
||||
|
||||
// properties::Vec4Property _topColor;
|
||||
// properties::Vec4Property _midColor;
|
||||
// properties::Vec4Property _botColor;
|
||||
// properties::Vec2Property _tfValues;
|
||||
|
||||
glm::size3_t _dimensions;
|
||||
// std::shared_ptr<ColorBar> _colorbar;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
|
||||
namespace openspace{
|
||||
class ISWACygnet;
|
||||
struct ExtensionFuture;
|
||||
|
||||
class ISWAContainer : public Renderable{
|
||||
|
||||
@@ -81,6 +81,11 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
|
||||
addProperty(_delete);
|
||||
|
||||
float groupId = -1;
|
||||
// if(dictionary.hasValue<float>("Group")){
|
||||
dictionary.getValue("Group", groupId);
|
||||
// }
|
||||
_data->groupId = groupId;
|
||||
// std::cout << _data->id << std::endl;
|
||||
// std::cout << _data->frame << std::endl;
|
||||
// std::cout << std::to_string(_data->offset) << std::endl;
|
||||
|
||||
@@ -48,9 +48,11 @@
|
||||
|
||||
|
||||
namespace openspace{
|
||||
class ISWAGroup;
|
||||
|
||||
struct Metadata {
|
||||
int id;
|
||||
int groupId;
|
||||
int updateTime;
|
||||
std::string path;
|
||||
std::string parent;
|
||||
@@ -66,7 +68,9 @@ struct Metadata {
|
||||
|
||||
|
||||
|
||||
class ISWACygnet : public Renderable{
|
||||
class ISWACygnet : public Renderable, public std::enable_shared_from_this<ISWACygnet> {
|
||||
friend class ISWAGroup;
|
||||
|
||||
public:
|
||||
ISWACygnet(const ghoul::Dictionary& dictionary);
|
||||
~ISWACygnet();
|
||||
@@ -79,6 +83,8 @@ protected:
|
||||
void unregisterProperties();
|
||||
void initializeTime();
|
||||
|
||||
void enabled(bool enabled){_enabled.setValue(enabled);};
|
||||
|
||||
properties::TriggerProperty _delete;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
@@ -97,6 +103,8 @@ protected:
|
||||
int _minRealTimeUpdateInterval;
|
||||
|
||||
std::vector<std::shared_ptr<TransferFunction>> _transferFunctions;
|
||||
|
||||
ISWAManager::CygnetType _type;
|
||||
};
|
||||
|
||||
}//namespace openspace
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
#include <modules/iswa/rendering/iswagroup.h>
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ISWAGroup";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ISWAGroup::ISWAGroup(int id, ISWAManager::CygnetType type)
|
||||
:_enabled("enabled", "Enabled", true)
|
||||
,_useLog("useLog","Use Logarithm", false)
|
||||
,_useHistogram("_useHistogram", "Use Histogram", true)
|
||||
,_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/parula.tf")
|
||||
,_dataOptions("dataOptions", "Data Options")
|
||||
,_type(type)
|
||||
{
|
||||
setName("ISWAGroup" + std::to_string(id));
|
||||
|
||||
addProperty(_enabled);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
|
||||
|
||||
_enabled.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
cygnet->enabled(_enabled.value());
|
||||
});
|
||||
|
||||
if(type == ISWAManager::CygnetType::Data){
|
||||
addProperty(_useLog);
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_normValues);
|
||||
addProperty(_backgroundValues);
|
||||
addProperty(_transferFunctionsFile);
|
||||
addProperty(_dataOptions);
|
||||
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
|
||||
_useLog.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->useLog(_useLog.value());
|
||||
});
|
||||
|
||||
_useHistogram.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->useHistogram(_useHistogram.value());
|
||||
});
|
||||
|
||||
_normValues.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->normValues(_normValues.value());
|
||||
});
|
||||
|
||||
_backgroundValues.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->backgroundValues(_backgroundValues.value());
|
||||
});
|
||||
|
||||
_transferFunctionsFile.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->transferFunctionsFile(_transferFunctionsFile.value());
|
||||
});
|
||||
|
||||
_dataOptions.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->dataOptions(_dataOptions.value());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ISWAGroup::~ISWAGroup(){
|
||||
_cygnets.clear();
|
||||
}
|
||||
|
||||
void ISWAGroup::registerCygnet(ISWACygnet* cygnet, ISWAManager::CygnetType type){
|
||||
if(type != _type){
|
||||
LERROR("Can't register cygnet with a different class from the group");
|
||||
return;
|
||||
}
|
||||
|
||||
if(type == ISWAManager::CygnetType::Data){
|
||||
DataPlane* dataplane = static_cast<DataPlane*>(cygnet);
|
||||
|
||||
dataplane->useLog(_useLog.value());
|
||||
dataplane->useHistogram(_useHistogram.value());
|
||||
dataplane->normValues(_normValues.value());
|
||||
dataplane->backgroundValues(_backgroundValues.value());
|
||||
dataplane->transferFunctionsFile(_transferFunctionsFile.value());
|
||||
dataplane->dataOptions(_dataOptions.value());
|
||||
}
|
||||
_cygnets.push_back(cygnet);
|
||||
}
|
||||
|
||||
void ISWAGroup::unregisterCygnet(ISWACygnet* cygnet){
|
||||
auto it = std::find(
|
||||
_cygnets.begin(),
|
||||
_cygnets.end(),
|
||||
cygnet
|
||||
);
|
||||
|
||||
if(it != _cygnets.end())
|
||||
_cygnets.erase(it);
|
||||
}
|
||||
|
||||
|
||||
void ISWAGroup::registerOptions(const std::vector<properties::SelectionProperty::Option>& options){
|
||||
if(_type == ISWAManager::CygnetType::Data){
|
||||
if(_dataOptions.options().empty()){
|
||||
for(auto option : options){
|
||||
_dataOptions.addOption(option);
|
||||
}
|
||||
_dataOptions.setValue(std::vector<int>(1,0));
|
||||
}
|
||||
for(auto cygnet : _cygnets)
|
||||
static_cast<DataPlane*>(cygnet)->dataOptions(_dataOptions.value());
|
||||
}
|
||||
|
||||
}
|
||||
} //namespace openspace
|
||||
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __ISWAGROUP_H__
|
||||
#define __ISWAGROUP_H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/selectionproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
// #include <modules/iswa/rendering/iswacygnet.h>
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
|
||||
|
||||
namespace openspace{
|
||||
class ISWACygnet;
|
||||
|
||||
class ISWAGroup : public properties::PropertyOwner{
|
||||
public:
|
||||
ISWAGroup(int id, ISWAManager::CygnetType type);
|
||||
~ISWAGroup();
|
||||
void registerCygnet(ISWACygnet* cygnet, ISWAManager::CygnetType type);
|
||||
void unregisterCygnet(ISWACygnet* cygnet);
|
||||
void registerOptions(const std::vector<properties::SelectionProperty::Option>& options);
|
||||
|
||||
private:
|
||||
properties::BoolProperty _enabled;
|
||||
|
||||
properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
properties::Vec2Property _normValues;
|
||||
properties::Vec2Property _backgroundValues;
|
||||
properties::StringProperty _transferFunctionsFile;
|
||||
properties::SelectionProperty _dataOptions;
|
||||
// properties::SelectionProperty _dataOptions;
|
||||
// properties::StringProperty _transferFunctionsFile;
|
||||
// properties::Vec2Property _normValues;
|
||||
// properties::Vec2Property _backgroundValues;
|
||||
// properties::BoolProperty _useLog;
|
||||
// properties::BoolProperty _useHistogram;;
|
||||
|
||||
// int groupId;
|
||||
// ISWACygnet cygnet;
|
||||
std::vector<ISWACygnet* > _cygnets;
|
||||
ISWAManager::CygnetType _type;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
#endif
|
||||
@@ -49,7 +49,7 @@ Fragment getFragment() {
|
||||
vec4 diffuse = transparent;
|
||||
float v = 0;
|
||||
|
||||
if(numTextures > numTransferFunctions){
|
||||
if((numTransferFunctions == 1) || (numTextures > numTransferFunctions)){
|
||||
for(int i=0; i<numTextures; i++){
|
||||
v += texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <modules/iswa/rendering/screenspacecygnet.h>
|
||||
#include <modules/iswa/ext/json/json.hpp>
|
||||
#include <fstream>
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
#include <modules/iswa/rendering/iswagroup.h>
|
||||
|
||||
namespace {
|
||||
using json = nlohmann::json;
|
||||
@@ -129,9 +131,9 @@ namespace openspace{
|
||||
for (auto it = _metadataFutures.begin(); it != _metadataFutures.end(); ){
|
||||
if((*it)->isFinished) {
|
||||
if((*it)->type == "TEXTURE"){
|
||||
createPlane((*it)->id,(*it)->json,std::string("TexturePlane"));
|
||||
createPlane((*it)->id,(*it)->json, std::string("TexturePlane"));
|
||||
}else if ((*it)->type == "DATA"){
|
||||
createPlane((*it)->id,(*it)->json,std::string("DataPlane"));
|
||||
createPlane((*it)->id,(*it)->json,std::string("DataPlane"), 1);
|
||||
} else {
|
||||
LERROR("\""+ (*it)->type + "\" is not a valid type");
|
||||
}
|
||||
@@ -184,7 +186,7 @@ namespace openspace{
|
||||
}
|
||||
|
||||
|
||||
std::string ISWAManager::parseJSONToLuaTable(int id, std::string jsonString, std::string type){
|
||||
std::string ISWAManager::parseJSONToLuaTable(int id, std::string name, std::string jsonString, std::string type, int group){
|
||||
if(jsonString != ""){
|
||||
json j = json::parse(jsonString);
|
||||
|
||||
@@ -215,7 +217,7 @@ namespace openspace{
|
||||
}
|
||||
|
||||
std::string table = "{"
|
||||
"Name = '" + type + std::to_string(id) +"' , "
|
||||
"Name = '" + name +"' , "
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = '" + type + "', "
|
||||
@@ -226,6 +228,7 @@ namespace openspace{
|
||||
"SpatialScale = " + std::to_string(spatialScale) + ", "
|
||||
"UpdateTime = " + std::to_string(updateTime) + ", "
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
"Group = "+ std::to_string(group) + " ,"
|
||||
"}"
|
||||
"}";
|
||||
|
||||
@@ -234,7 +237,7 @@ namespace openspace{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ISWAManager::parseKWToLuaTable(std::string kwPath){
|
||||
std::string ISWAManager::parseKWToLuaTable(std::string kwPath, int group){
|
||||
if(kwPath != ""){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
|
||||
if(extension == "cdf"){
|
||||
@@ -277,6 +280,7 @@ namespace openspace{
|
||||
"kwPath = '" + kwPath + "' ,"
|
||||
"axisCut = 'y' ,"
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
"Group = "+ std::to_string(group) + " ,"
|
||||
"}"
|
||||
"}"
|
||||
;
|
||||
@@ -288,16 +292,18 @@ namespace openspace{
|
||||
}
|
||||
|
||||
|
||||
void ISWAManager::createPlane(int id, std::string json, std::string type){
|
||||
|
||||
void ISWAManager::createPlane(int id, std::string json, std::string type, int group){
|
||||
// check if this plane already exist
|
||||
std::string name = type + std::to_string(id);
|
||||
if(group > 0)
|
||||
name += "_Group" + std::to_string(group);
|
||||
|
||||
if( OsEng.renderEngine().scene()->sceneGraphNode(name) ){
|
||||
LERROR("A node with name \"" + name +"\" already exist");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string luaTable = parseJSONToLuaTable(id, json, type);
|
||||
std::string luaTable = parseJSONToLuaTable(id, name, json, type, group);
|
||||
if(luaTable != ""){
|
||||
std::string script = "openspace.addSceneGraphNode(" + luaTable + ");";
|
||||
OsEng.scriptEngine().queueScript(script);
|
||||
@@ -310,12 +316,12 @@ namespace openspace{
|
||||
OsEng.scriptEngine().queueScript(script);
|
||||
}
|
||||
|
||||
void ISWAManager::createKameleonPlane(std::string kwPath){
|
||||
void ISWAManager::createKameleonPlane(std::string kwPath, int group){
|
||||
kwPath = "${OPENSPACE_DATA}/" + kwPath;
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(kwPath)).fileExtension();
|
||||
|
||||
if(FileSys.fileExists(absPath(kwPath)) && extension == "cdf"){
|
||||
std::string luaTable = parseKWToLuaTable(kwPath);
|
||||
std::string luaTable = parseKWToLuaTable(kwPath, group);
|
||||
if(!luaTable.empty()){
|
||||
std::cout << luaTable << std::endl;
|
||||
std::string script = "openspace.addSceneGraphNode(" + luaTable + ");";
|
||||
@@ -325,4 +331,37 @@ namespace openspace{
|
||||
LWARNING( kwPath + " is not a cdf file or can't be found.");
|
||||
}
|
||||
}
|
||||
|
||||
void ISWAManager::registerToGroup(int id, ISWACygnet* cygnet, CygnetType type){
|
||||
if(_groups.find(id) != _groups.end()){
|
||||
_groups[id]->registerCygnet(cygnet, type);
|
||||
}else{
|
||||
_groups.insert(std::pair<int, std::shared_ptr<ISWAGroup>>(id, std::make_shared<ISWAGroup>(id, type)));
|
||||
_groups[id]->registerCygnet(cygnet, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ISWAManager::unregisterFromGroup(int id, ISWACygnet* cygnet){
|
||||
if(_groups.find(id) != _groups.end()){
|
||||
_groups[id]->unregisterCygnet(cygnet);
|
||||
}
|
||||
}
|
||||
|
||||
void ISWAManager::registerOptionsToGroup(int id, const std::vector<properties::SelectionProperty::Option>& options){
|
||||
if(_groups.find(id) != _groups.end()){
|
||||
_groups[id]->registerOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<ISWAGroup> ISWAManager::iSWAGroup(std::string name){
|
||||
for(auto group : _groups){
|
||||
if(group.second->name() == name){
|
||||
return group.second;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}// namsepace openspace
|
||||
@@ -31,10 +31,15 @@
|
||||
#include <ghoul/glm.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/properties/selectionproperty.h>
|
||||
// #include <modules/iswa/rendering/iswacygnet.h>
|
||||
// #include <modules/iswa/rendering/iswagroup.h>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
class ISWACygnet;
|
||||
class ISWAGroup;
|
||||
class ISWACygnet;
|
||||
|
||||
|
||||
struct MetadataFuture {
|
||||
int id;
|
||||
@@ -48,6 +53,7 @@ class ISWAManager : public ghoul::Singleton<ISWAManager> {
|
||||
friend class ghoul::Singleton<ISWAManager>;
|
||||
|
||||
public:
|
||||
enum CygnetType {Texture, Data};
|
||||
|
||||
ISWAManager();
|
||||
~ISWAManager();
|
||||
@@ -62,19 +68,25 @@ public:
|
||||
|
||||
void update();
|
||||
|
||||
void registerToGroup(int id, ISWACygnet* cygnet, CygnetType type);
|
||||
void unregisterFromGroup(int id, ISWACygnet* cygnet);
|
||||
void registerOptionsToGroup(int id, const std::vector<properties::SelectionProperty::Option>& options);
|
||||
std::shared_ptr<ISWAGroup> iSWAGroup(std::string name);
|
||||
|
||||
private:
|
||||
std::string iSWAurl(int id, std::string type = "image");
|
||||
std::shared_ptr<MetadataFuture> downloadMetadata(int id);
|
||||
std::string parseJSONToLuaTable(int id, std::string json, std::string type);
|
||||
std::string parseKWToLuaTable(std::string kwPath);
|
||||
std::string parseJSONToLuaTable(int id, std::string name, std::string json, std::string type, int group);
|
||||
std::string parseKWToLuaTable(std::string kwPath, int group);
|
||||
|
||||
void createPlane(int id, std::string json, std::string type);
|
||||
void createPlane(int id, std::string json, std::string type, int group = -1);
|
||||
void createScreenSpace(int id);
|
||||
void createKameleonPlane(std::string kwPath);
|
||||
void createKameleonPlane(std::string kwPath, int group = -1);
|
||||
|
||||
std::map<std::string, std::string> _month;
|
||||
std::vector<std::shared_ptr<MetadataFuture>> _metadataFutures;
|
||||
|
||||
std::map<int, std::shared_ptr<ISWAGroup>> _groups;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
+7
-1
@@ -33,7 +33,7 @@
|
||||
#include <modules/iswa/rendering/iswacygnet.h>
|
||||
#include <modules/iswa/rendering/iswacontainer.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
|
||||
#include <modules/iswa/rendering/iswagroup.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -83,6 +83,12 @@ properties::Property* property(const std::string& uri) {
|
||||
properties::Property* property = ssr->property(remainingUri);
|
||||
return property;
|
||||
}
|
||||
|
||||
std::shared_ptr<ISWAGroup> group = ISWAManager::ref().iSWAGroup(nameUri);
|
||||
if(group){
|
||||
properties::Property* property = group->property(remainingUri);
|
||||
return property;
|
||||
}
|
||||
|
||||
LERROR("Node or ScreenSpaceRenderable' " << nameUri << "' did not exist");
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user