IswaDataGroup

This commit is contained in:
Sebastian Piwell
2016-06-01 14:40:00 -04:00
parent 876c86ca75
commit 27a046d81d
10 changed files with 373 additions and 238 deletions

View File

@@ -39,6 +39,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/datasphere.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacecygnet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswagroup.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswadatagroup.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturecygnet.h
)
source_group("Header Files" FILES ${HEADER_FILES})
@@ -58,6 +59,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/datasphere.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacecygnet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswagroup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswadatagroup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturecygnet.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})

View File

@@ -358,7 +358,7 @@ void DataPlane::fillOptions(){
}
_dataOptions.setValue(std::vector<int>(1,0));
if(_group)
_group->registerOptions(_dataOptions.options());
std::dynamic_pointer_cast<IswaDataGroup> (_group)->registerOptions(_dataOptions.options());
}
}// namespace openspace

View File

@@ -374,7 +374,7 @@ void DataSphere::fillOptions(){
}
_dataOptions.setValue(std::vector<int>(1,0));
if(_group)
_group->registerOptions(_dataOptions.options());
std::dynamic_pointer_cast<IswaDataGroup>(_group)->registerOptions(_dataOptions.options());
// IswaManager::ref().registerOptionsToGroup(_data->groupName, _dataOptions.options());
}

View File

@@ -47,6 +47,8 @@
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/transferfunction.h>
#include <modules/iswa/rendering/iswagroup.h>
#include <modules/iswa/rendering/iswadatagroup.h>
namespace openspace{
class IswaGroup;

View File

@@ -0,0 +1,231 @@
/*****************************************************************************************
* *
* 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/iswadatagroup.h>
#include <fstream>
#include <modules/iswa/ext/json/json.hpp>
#include <modules/iswa/util/dataprocessortext.h>
#include <modules/iswa/util/dataprocessorjson.h>
#include <modules/iswa/util/dataprocessorkameleon.h>
#include <modules/iswa/rendering/dataplane.h>
#include <modules/iswa/rendering/datasphere.h>
#include <modules/iswa/rendering/kameleonplane.h>
namespace {
const std::string _loggerCat = "IswaDataGroup";
using json = nlohmann::json;
}
namespace openspace{
IswaDataGroup::IswaDataGroup(std::string name, std::string type)
:IswaGroup(name, type)
,_useLog("useLog","Use Logarithm", false)
,_useHistogram("useHistogram", "Use Histogram", false)
,_autoFilter("autoFilter", "Auto Filter", 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/hot.tf")
,_dataOptions("dataOptions", "Data Options")
,_fieldlines("fieldlineSeedsIndexFile", "Fieldline Seedpoints")
,_fieldlineIndexFile("")
{
addProperty(_useLog);
addProperty(_useHistogram);
addProperty(_autoFilter);
addProperty(_normValues);
addProperty(_backgroundValues);
addProperty(_transferFunctionsFile);
addProperty(_dataOptions);
addProperty(_fieldlines);
std::cout << "DataGroup" << std::endl;
createDataProcessor();
registerProperties();
}
IswaDataGroup::~IswaDataGroup(){}
void IswaDataGroup::clearGroup(){
IswaGroup::clearGroup();
clearFieldlines();
}
void IswaDataGroup::registerProperties(){
// IswaGroup::registerProperties();
std::cout << "register properties" << std::endl;
OsEng.gui()._iswa.registerProperty(&_useLog);
OsEng.gui()._iswa.registerProperty(&_useHistogram);
OsEng.gui()._iswa.registerProperty(&_autoFilter);
OsEng.gui()._iswa.registerProperty(&_normValues);
OsEng.gui()._iswa.registerProperty(&_backgroundValues);
OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile);
OsEng.gui()._iswa.registerProperty(&_dataOptions);
_useLog.onChange([this]{
LDEBUG("Group " + name() + " published useLogChanged");
_groupEvent->publish("useLogChanged", ghoul::Dictionary({{"useLog", _useLog.value()}}));
});
_useHistogram.onChange([this]{
LDEBUG("Group " + name() + " published useHistogramChanged");
_groupEvent->publish("useHistogramChanged", ghoul::Dictionary({{"useHistogram", _useHistogram.value()}}));
});
_autoFilter.onChange([this]{
LDEBUG("Group " + name() + " published autoFilterChanged");
_groupEvent->publish("autoFilterChanged", ghoul::Dictionary({{"autoFilter", _autoFilter.value()}}));
});
_normValues.onChange([this]{
LDEBUG("Group " + name() + " published normValuesChanged");
_groupEvent->publish("normValuesChanged", ghoul::Dictionary({{"normValues", std::make_shared<glm::vec2>(_normValues.value())}}));
});
_backgroundValues.onChange([this]{
LDEBUG("Group " + name() + " published backgroundValuesChanged");
_groupEvent->publish("backgroundValuesChanged", ghoul::Dictionary({{"backgroundValues", std::make_shared<glm::vec2>(_backgroundValues.value())}}));
});
_transferFunctionsFile.onChange([this]{
LDEBUG("Group " + name() + " published transferFunctionsChanged");
_groupEvent->publish("transferFunctionsChanged", ghoul::Dictionary({{"transferFunctions", _transferFunctionsFile.value()}}));
});
_dataOptions.onChange([this]{
LDEBUG("Group " + name() + " published dataOptionsChanged");
_groupEvent->publish("dataOptionsChanged", ghoul::Dictionary({{"dataOptions", std::make_shared<std::vector<int> >(_dataOptions.value())}}));
});
if(_type == typeid(KameleonPlane).name()){
OsEng.gui()._iswa.registerProperty(&_fieldlines);
_fieldlines.onChange([this]{
updateFieldlineSeeds();
// LDEBUG("Group " + name() + " published fieldlinesChanged");
// _groupEvent->publish("fieldlinesChanged", ghoul::Dictionary({{"fieldlines", std::make_shared<std::vector<int> >(_fieldlines.value())}}));
});
}
}
void IswaDataGroup::registerOptions(const std::vector<properties::SelectionProperty::Option>& options){
if(!_registered)
registerProperties();
if(_dataOptions.options().empty()){
for(auto option : options){
_dataOptions.addOption({option.value, option.description});
}
_dataOptions.setValue(std::vector<int>(1,0));
}
}
void IswaDataGroup::setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath){
if(fieldlineIndexFile != _fieldlineIndexFile){
_fieldlineIndexFile = fieldlineIndexFile;
readFieldlinePaths(_fieldlineIndexFile);
}
if(kameleonPath != _kameleonPath){
_kameleonPath = kameleonPath;
clearFieldlines();
updateFieldlineSeeds();
}
}
void IswaDataGroup::updateFieldlineSeeds(){
std::vector<int> selectedOptions = _fieldlines.value();
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
for (auto& seedPath: _fieldlineState) {
// if this option was turned off
if( std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)==selectedOptions.end() && std::get<2>(seedPath.second)){
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
OsEng.scriptEngine().queueScript("openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')");
std::get<2>(seedPath.second) = false;
// if this option was turned on
} else if( std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)!=selectedOptions.end() && !std::get<2>(seedPath.second)) {
LDEBUG("Created fieldlines: " + std::get<0>(seedPath.second));
IswaManager::ref().createFieldline(std::get<0>(seedPath.second), _kameleonPath, std::get<1>(seedPath.second));
std::get<2>(seedPath.second) = true;
}
}
}
void IswaDataGroup::readFieldlinePaths(std::string indexFile){
LINFO("Reading seed points paths from file '" << indexFile << "'");
// Read the index file from disk
std::ifstream seedFile(indexFile);
if (!seedFile.good())
LERROR("Could not open seed points file '" << indexFile << "'");
else {
std::string line;
std::string fileContent;
while (std::getline(seedFile, line)) {
fileContent += line;
}
try{
//Parse and add each fieldline as an selection
json fieldlines = json::parse(fileContent);
int i = 0;
for (json::iterator it = fieldlines.begin(); it != fieldlines.end(); ++it) {
_fieldlines.addOption({i, name()+"/"+it.key()});
_fieldlineState[i] = std::make_tuple(name()+"/"+it.key(), it.value(), false);
i++;
}
} catch(const std::exception& e) {
LERROR("Error when reading json file with paths to seedpoints: " + std::string(e.what()));
}
}
}
void IswaDataGroup::clearFieldlines(){
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
for (auto& seedPath: _fieldlineState) {
if(std::get<2>(seedPath.second)){
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
OsEng.scriptEngine().queueScript("openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')");
std::get<2>(seedPath.second) = false;
}
}
}
void IswaDataGroup::createDataProcessor(){
if(_type == typeid(DataPlane).name()){
_dataProcessor = std::make_shared<DataProcessorText>();
}else if(_type == typeid(DataSphere).name()){
_dataProcessor = std::make_shared<DataProcessorJson>();
}else if(_type == typeid(KameleonPlane).name()){
_dataProcessor = std::make_shared<DataProcessorKameleon>();
}
}
} //namespace openspace

View File

@@ -0,0 +1,67 @@
/*****************************************************************************************
* *
* 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 __ISWADATAGROUP_H__
#define __ISWADATAGROUP_H__
#include <modules/iswa/rendering/iswagroup.h>
namespace openspace{
class IswaDataGroup : public IswaGroup{
public:
IswaDataGroup(std::string name, std::string type);
~IswaDataGroup();
virtual void clearGroup() override;
void registerOptions(const std::vector<properties::SelectionProperty::Option>& options);
void registerFieldLineOptions(const std::vector<properties::SelectionProperty::Option>& options);
std::vector<int> dataOptionsValue();
std::vector<int> fieldlineValue();
void setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath);
private:
void registerProperties();
void createDataProcessor();
void readFieldlinePaths(std::string indexFile);
void updateFieldlineSeeds();
void clearFieldlines();
properties::BoolProperty _useLog;
properties::BoolProperty _useHistogram;
properties::BoolProperty _autoFilter;
properties::Vec2Property _normValues;
properties::Vec2Property _backgroundValues;
properties::StringProperty _transferFunctionsFile;
properties::SelectionProperty _dataOptions;
properties::SelectionProperty _fieldlines;
std::string _fieldlineIndexFile;
std::string _kameleonPath;
std::map<int, std::tuple<std::string, std::string, bool> > _fieldlineState;
};
} //namespace openspace
#endif // __ISWADATAGROUP_H__

View File

@@ -22,7 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/iswa/rendering/iswagroup.h>
#include <modules/iswa/rendering/dataplane.h>
#include <fstream>
#include <modules/iswa/ext/json/json.hpp>
@@ -39,82 +38,53 @@
namespace {
const std::string _loggerCat = "IswaGroup";
using json = nlohmann::json;
}
namespace openspace {
IswaGroup::IswaGroup(std::string name, std::string type)
:_enabled("enabled", "Enabled", true)
,_alpha("alpha", "Alpha", 0.9f, 0.0f, 1.0f)
,_useLog("useLog","Use Logarithm", false)
,_useHistogram("useHistogram", "Use Histogram", false)
,_autoFilter("autoFilter", "Auto Filter", 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/hot.tf")
,_delete("delete", "Delete")
,_dataOptions("dataOptions", "Data Options")
,_fieldlines("fieldlineSeedsIndexFile", "Fieldline Seedpoints")
,_fieldlineIndexFile("")
,_registered(false)
,_type(type)
,_dataProcessor(nullptr)
{
setName(name);
addProperty(_enabled);
addProperty(_alpha);
addProperty(_useLog);
addProperty(_useHistogram);
addProperty(_autoFilter);
addProperty(_normValues);
addProperty(_backgroundValues);
addProperty(_transferFunctionsFile);
addProperty(_dataOptions);
addProperty(_fieldlines);
addProperty(_delete);
createDataProcessor();
_groupEvent = std::make_shared<ghoul::Event<ghoul::Dictionary> >();
registerProperties();
std::cout << "BaseGroup" << std::endl;
}
IswaGroup::~IswaGroup(){}
void IswaGroup::registerOptions(const std::vector<properties::SelectionProperty::Option>& options){
if(!_registered)
registerProperties();
if(_type == typeid(DataPlane).name() || _type == typeid(DataSphere).name() ||
_type == typeid(KameleonPlane).name()){
if(_dataOptions.options().empty()){
for(auto option : options){
_dataOptions.addOption({option.value, option.description});
}
_dataOptions.setValue(std::vector<int>(1,0));
}
}
}
void IswaGroup::setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath){
if(fieldlineIndexFile != _fieldlineIndexFile){
_fieldlineIndexFile = fieldlineIndexFile;
readFieldlinePaths(_fieldlineIndexFile);
}
if(kameleonPath != _kameleonPath){
_kameleonPath = kameleonPath;
clearFieldlines();
updateFieldlineSeeds();
}
}
bool IswaGroup::isType(std::string type){
return (_type == type);
}
void IswaGroup::updateGroup(){
_groupEvent->publish("updateGroup", ghoul::Dictionary());
}
void IswaGroup::clearGroup(){
_groupEvent->publish("clearGroup", ghoul::Dictionary());
LDEBUG("Group " + name() + " published clearGroup");
unregisterProperties();
}
std::shared_ptr<DataProcessor> IswaGroup::dataProcessor(){
return _dataProcessor;
}
std::shared_ptr<ghoul::Event<ghoul::Dictionary> > IswaGroup::groupEvent(){
return _groupEvent;
};
void IswaGroup::registerProperties(){
OsEng.gui()._iswa.registerProperty(&_enabled);
OsEng.gui()._iswa.registerProperty(&_alpha);
@@ -130,67 +100,11 @@ void IswaGroup::registerProperties(){
});
if(_type == typeid(DataPlane).name() || _type == typeid(DataSphere).name() ||
_type == typeid(KameleonPlane).name() ){
OsEng.gui()._iswa.registerProperty(&_useLog);
OsEng.gui()._iswa.registerProperty(&_useHistogram);
OsEng.gui()._iswa.registerProperty(&_autoFilter);
OsEng.gui()._iswa.registerProperty(&_normValues);
OsEng.gui()._iswa.registerProperty(&_backgroundValues);
OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile);
OsEng.gui()._iswa.registerProperty(&_dataOptions);
_useLog.onChange([this]{
LDEBUG("Group " + name() + " published useLogChanged");
_groupEvent->publish("useLogChanged", ghoul::Dictionary({{"useLog", _useLog.value()}}));
});
_useHistogram.onChange([this]{
LDEBUG("Group " + name() + " published useHistogramChanged");
_groupEvent->publish("useHistogramChanged", ghoul::Dictionary({{"useHistogram", _useHistogram.value()}}));
});
_autoFilter.onChange([this]{
LDEBUG("Group " + name() + " published autoFilterChanged");
_groupEvent->publish("autoFilterChanged", ghoul::Dictionary({{"autoFilter", _autoFilter.value()}}));
});
_normValues.onChange([this]{
LDEBUG("Group " + name() + " published normValuesChanged");
_groupEvent->publish("normValuesChanged", ghoul::Dictionary({{"normValues", std::make_shared<glm::vec2>(_normValues.value())}}));
});
_backgroundValues.onChange([this]{
LDEBUG("Group " + name() + " published backgroundValuesChanged");
_groupEvent->publish("backgroundValuesChanged", ghoul::Dictionary({{"backgroundValues", std::make_shared<glm::vec2>(_backgroundValues.value())}}));
});
_transferFunctionsFile.onChange([this]{
LDEBUG("Group " + name() + " published transferFunctionsChanged");
_groupEvent->publish("transferFunctionsChanged", ghoul::Dictionary({{"transferFunctions", _transferFunctionsFile.value()}}));
});
_dataOptions.onChange([this]{
LDEBUG("Group " + name() + " published dataOptionsChanged");
_groupEvent->publish("dataOptionsChanged", ghoul::Dictionary({{"dataOptions", std::make_shared<std::vector<int> >(_dataOptions.value())}}));
});
}
if(_type == typeid(KameleonPlane).name()){
OsEng.gui()._iswa.registerProperty(&_fieldlines);
_fieldlines.onChange([this]{
updateFieldlineSeeds();
// LDEBUG("Group " + name() + " published fieldlinesChanged");
// _groupEvent->publish("fieldlinesChanged", ghoul::Dictionary({{"fieldlines", std::make_shared<std::vector<int> >(_fieldlines.value())}}));
});
}
OsEng.gui()._iswa.registerProperty(&_delete);
_delete.onChange([this]{
clearGroup();
});
_registered = true;
}
@@ -199,91 +113,4 @@ void IswaGroup::unregisterProperties(){
_registered = false;
}
void IswaGroup::updateGroup(){
_groupEvent->publish("updateGroup", ghoul::Dictionary());
}
void IswaGroup::clearGroup(){
_groupEvent->publish("clearGroup", ghoul::Dictionary());
LDEBUG("Group " + name() + " published clearGroup");
unregisterProperties();
clearFieldlines();
}
std::shared_ptr<DataProcessor> IswaGroup::dataProcessor(){
return _dataProcessor;
}
void IswaGroup::updateFieldlineSeeds(){
std::vector<int> selectedOptions = _fieldlines.value();
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
for (auto& seedPath: _fieldlineState) {
// if this option was turned off
if( std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)==selectedOptions.end() && std::get<2>(seedPath.second)){
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
OsEng.scriptEngine().queueScript("openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')");
std::get<2>(seedPath.second) = false;
// if this option was turned on
} else if( std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)!=selectedOptions.end() && !std::get<2>(seedPath.second)) {
LDEBUG("Created fieldlines: " + std::get<0>(seedPath.second));
IswaManager::ref().createFieldline(std::get<0>(seedPath.second), _kameleonPath, std::get<1>(seedPath.second));
std::get<2>(seedPath.second) = true;
}
}
}
void IswaGroup::readFieldlinePaths(std::string indexFile){
LINFO("Reading seed points paths from file '" << indexFile << "'");
// Read the index file from disk
std::ifstream seedFile(indexFile);
if (!seedFile.good())
LERROR("Could not open seed points file '" << indexFile << "'");
else {
std::string line;
std::string fileContent;
while (std::getline(seedFile, line)) {
fileContent += line;
}
try{
//Parse and add each fieldline as an selection
json fieldlines = json::parse(fileContent);
int i = 0;
for (json::iterator it = fieldlines.begin(); it != fieldlines.end(); ++it) {
_fieldlines.addOption({i, name()+"/"+it.key()});
_fieldlineState[i] = std::make_tuple(name()+"/"+it.key(), it.value(), false);
i++;
}
} catch(const std::exception& e) {
LERROR("Error when reading json file with paths to seedpoints: " + std::string(e.what()));
}
}
}
void IswaGroup::clearFieldlines(){
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
for (auto& seedPath: _fieldlineState) {
if(std::get<2>(seedPath.second)){
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
OsEng.scriptEngine().queueScript("openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')");
std::get<2>(seedPath.second) = false;
}
}
}
void IswaGroup::createDataProcessor(){
if(_type == typeid(DataPlane).name()){
_dataProcessor = std::make_shared<DataProcessorText>();
}else if(_type == typeid(DataSphere).name()){
_dataProcessor = std::make_shared<DataProcessorJson>();
}else if(_type == typeid(KameleonPlane).name()){
_dataProcessor = std::make_shared<DataProcessorKameleon>();
}
}
} //namespace openspace

View File

@@ -42,53 +42,28 @@ class IswaCygnet;
class IswaGroup : public properties::PropertyOwner{
public:
IswaGroup(std::string name, IswaManager::CygnetType type);
IswaGroup(std::string name, std::string type);
~IswaGroup();
void registerOptions(const std::vector<properties::SelectionProperty::Option>& options);
void registerFieldLineOptions(const std::vector<properties::SelectionProperty::Option>& options);
bool isType(std::string type);
void clearGroup();
void updateGroup();
virtual void clearGroup();
std::shared_ptr<DataProcessor> dataProcessor();
std::shared_ptr<ghoul::Event<ghoul::Dictionary> > groupEvent(){ return _groupEvent; };
std::vector<int> fieldlineValue() {return _fieldlines.value();}
std::vector<int> dataOptionsValue() {return _dataOptions.value();}
void setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath);
private:
void createDataProcessor();
std::shared_ptr<ghoul::Event<ghoul::Dictionary> > groupEvent();
protected:
void registerProperties();
void unregisterProperties();
void readFieldlinePaths(std::string indexFile);
void updateFieldlineSeeds();
void clearFieldlines();
properties::BoolProperty _enabled;
properties::FloatProperty _alpha;
properties::BoolProperty _useLog;
properties::BoolProperty _useHistogram;
properties::BoolProperty _autoFilter;
properties::Vec2Property _normValues;
properties::Vec2Property _backgroundValues;
properties::StringProperty _transferFunctionsFile;
properties::SelectionProperty _dataOptions;
properties::SelectionProperty _fieldlines;
properties::TriggerProperty _delete;
properties::TriggerProperty _delete;
int _id;
std::shared_ptr<ghoul::Event<ghoul::Dictionary> > _groupEvent;
std::shared_ptr<DataProcessor> _dataProcessor;
bool _registered;
std::string _fieldlineIndexFile;
std::string _kameleonPath;
std::map<int, std::tuple<std::string, std::string, bool> > _fieldlineState;
std::string _type;
};

View File

@@ -439,8 +439,8 @@ void KameleonPlane::fillOptions(){
}
}
if(_group){
_group->registerOptions(_dataOptions.options());
_dataOptions.setValue(_group->dataOptionsValue());
std::dynamic_pointer_cast<IswaDataGroup> (_group)->registerOptions(_dataOptions.options());
// _dataOptions.setValue(_group->dataOptionsValue());
}else{
_dataOptions.setValue(std::vector<int>(1,0));
// IswaManager::ref().registerOptionsToGroup(_data->groupName, _dataOptions.options());
@@ -477,7 +477,7 @@ void KameleonPlane::updateFieldlineSeeds(){
void KameleonPlane::readFieldlinePaths(std::string indexFile){
LINFO("Reading seed points paths from file '" << indexFile << "'");
if(_group){
_group->setFieldlineInfo(indexFile, _kwPath);
std::dynamic_pointer_cast<IswaDataGroup>(_group)->setFieldlineInfo(indexFile, _kwPath);
return;
}

View File

@@ -26,9 +26,12 @@
#include <modules/iswa/rendering/dataplane.h>
#include <modules/iswa/rendering/textureplane.h>
#include <modules/iswa/rendering/datasphere.h>
#include <modules/iswa/rendering/kameleonplane.h>
#include <modules/iswa/rendering/screenspacecygnet.h>
#include <modules/iswa/rendering/iswacygnet.h>
#include <modules/iswa/rendering/iswagroup.h>
#include <modules/iswa/rendering/iswadatagroup.h>
#include <fstream>
#include <algorithm>
@@ -163,8 +166,8 @@ void IswaManager::addKameleonCdf(std::string group, int pos){
// auto info = _cdfInformation[group][pos];
// std::cout << group << " " << pos << std::endl;
createKameleonPlane(_cdfInformation[group][pos], "z");
// createKameleonPlane(_cdfInformation[group][pos], "y");
// createKameleonPlane(_cdfInformation[group][pos], "x");
createKameleonPlane(_cdfInformation[group][pos], "y");
createKameleonPlane(_cdfInformation[group][pos], "x");
}
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id){
@@ -218,7 +221,17 @@ std::string IswaManager::iswaUrl(int id, std::string type){
void IswaManager::registerGroup(std::string groupName, std::string type){
if(_groups.find(groupName) == _groups.end()){
_groups.insert(std::pair<std::string, std::shared_ptr<IswaGroup>>(groupName, std::make_shared<IswaGroup>(groupName, type)));
bool dataGroup = (type == typeid(DataPlane).name()) ||
(type == typeid(DataSphere).name()) ||
(type == typeid(KameleonPlane).name());
if(dataGroup){
std::cout << "Register data group" << std::endl;
_groups.insert(std::pair<std::string, std::shared_ptr<IswaGroup>>(groupName, std::make_shared<IswaDataGroup>(groupName, type)));
}
else{
_groups.insert(std::pair<std::string, std::shared_ptr<IswaGroup>>(groupName, std::make_shared<IswaGroup>(groupName, type)));
}
} else if(!_groups[groupName]->isType(type)){
LWARNING("Can't add cygnet to groups with diffent type");
}
@@ -346,7 +359,7 @@ std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut){
}
std::string table = "{"
"Name = '" +info.group+"_"+info.name+"-"+cut+"',"
"Name = '" +info.name+ "',"
"Parent = '" + parent + "', "
"Renderable = {"
"Type = 'KameleonPlane', "
@@ -360,12 +373,11 @@ std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut){
"axisCut = '"+cut+"',"
"CoordinateType = '" + coordinateType + "', "
"Group = '"+ info.group + "',"
"Group = '',"
// "Group = '',"
"fieldlineSeedsIndexFile = '"+info.fieldlineSeedsIndexFile+"'"
"}"
"}"
;
// std::cout << table << std::endl;
;
return table;
}
}
@@ -494,11 +506,30 @@ void IswaManager::createSphere(std::shared_ptr<MetadataFuture> data){
}
void IswaManager::createKameleonPlane(CdfInfo info, std::string cut){
std::cout << info.name << " " << cut << std::endl;
const std::string& extension = ghoul::filesystem::File(absPath(info.path)).fileExtension();
if(FileSys.fileExists(absPath(info.path)) && extension == "cdf"){
if(!info.group.empty()){
std::string type = typeid(KameleonPlane).name();
registerGroup(info.group, type);
auto it = _groups.find(info.group);
if(it == _groups.end() || (*it).second->isType(type)){
info.name = info.group +"_"+info.name;
}else{
info.group="";
}
}
info.name = info.name+"-"+cut;
if( OsEng.renderEngine().scene()->sceneGraphNode(info.name) ){
LERROR("A node with name \"" + info.name +"\" already exist");
return;
}
std::string luaTable = parseKWToLuaTable(info, cut);
if(!luaTable.empty()){
// // std::cout << luaTable << std::endl;