Replaced string with enum

This commit is contained in:
Sebastian Piwell
2016-05-03 10:06:47 -04:00
parent f5ab620398
commit c57a9b7be1
8 changed files with 55 additions and 36 deletions

View File

@@ -26,7 +26,6 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacontainer.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswagroup.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/cygnetplane.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacygnet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/dataplane.h
@@ -35,12 +34,12 @@ 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})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacontainer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswagroup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/iswacygnet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/cygnetplane.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/dataplane.cpp
@@ -49,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})

View File

@@ -86,7 +86,7 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
setTransferFunctions(_transferFunctionsFile.value());
});
_type = ISWAManager::CygnetType::Data;
}
DataPlane::~DataPlane(){}
@@ -118,7 +118,7 @@ bool DataPlane::initialize(){
// }
// _textures.push_back(nullptr);
ISWAManager::ref().registerToGroup(_data->groupId, this, "data");
ISWAManager::ref().registerToGroup(_data->groupId, this, _type);
return isReady();
@@ -303,9 +303,10 @@ void DataPlane::readHeader(){
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(){
@@ -396,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*>();
// }
}

View File

@@ -104,7 +104,7 @@ protected:
std::vector<std::shared_ptr<TransferFunction>> _transferFunctions;
ISWAManager::CygnetType _type;
};
}//namespace openspace

View File

@@ -22,12 +22,15 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/iswa/rendering/iswagroup.h>
#include <modules/iswa/rendering/iswacygnet.h>
#include <modules/iswa/rendering/dataplane.h>
namespace {
const std::string _loggerCat = "ISWAGroup";
}
namespace openspace {
ISWAGroup::ISWAGroup(int id, std::string type)
ISWAGroup::ISWAGroup(int id, ISWAManager::CygnetType type)
:_enabled("enabled", "Enabled", true)
,_useLog("useLog","Use Logarithm", false)
,_useHistogram("_useHistogram", "Use Histogram", true)
@@ -47,7 +50,7 @@ ISWAGroup::ISWAGroup(int id, std::string type)
cygnet->enabled(_enabled.value());
});
if(type == "data"){
if(type == ISWAManager::CygnetType::Data){
addProperty(_useLog);
addProperty(_useHistogram);
addProperty(_normValues);
@@ -98,8 +101,13 @@ ISWAGroup::~ISWAGroup(){
_cygnets.clear();
}
void ISWAGroup::registerCygnet(ISWACygnet* cygnet, std::string type){
if(type == "data"){
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());
@@ -125,7 +133,7 @@ void ISWAGroup::unregisterCygnet(ISWACygnet* cygnet){
void ISWAGroup::registerOptions(const std::vector<properties::SelectionProperty::Option>& options){
if(_type == "data"){
if(_type == ISWAManager::CygnetType::Data){
if(_dataOptions.options().empty()){
for(auto option : options){
_dataOptions.addOption(option);

View File

@@ -30,17 +30,21 @@
#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, std::string type);
ISWAGroup(int id, ISWAManager::CygnetType type);
~ISWAGroup();
void registerCygnet(ISWACygnet* cygnet, std::string type);
void registerCygnet(ISWACygnet* cygnet, ISWAManager::CygnetType type);
void unregisterCygnet(ISWACygnet* cygnet);
void registerOptions(const std::vector<properties::SelectionProperty::Option>& options);
private:
properties::BoolProperty _enabled;
@@ -60,7 +64,7 @@ private:
// int groupId;
// ISWACygnet cygnet;
std::vector<ISWACygnet* > _cygnets;
std::string _type;
ISWAManager::CygnetType _type;
};
} //namespace openspace

View File

@@ -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;
@@ -86,7 +88,7 @@ namespace openspace{
_metadataFutures.push_back(metadataFuture);
}else{
//create kameleonplane
createKameleonPlane(info, -1);
createKameleonPlane(info);
}
}
@@ -129,7 +131,7 @@ 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"), -1);
createPlane((*it)->id,(*it)->json, std::string("TexturePlane"));
}else if ((*it)->type == "DATA"){
createPlane((*it)->id,(*it)->json,std::string("DataPlane"), 1);
} else {
@@ -328,7 +330,7 @@ namespace openspace{
}
}
void ISWAManager::registerToGroup(int id, ISWACygnet* cygnet, std::string type){
void ISWAManager::registerToGroup(int id, ISWACygnet* cygnet, CygnetType type){
if(_groups.find(id) != _groups.end()){
_groups[id]->registerCygnet(cygnet, type);
}else{
@@ -344,6 +346,12 @@ namespace openspace{
}
}
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){
@@ -354,10 +362,4 @@ namespace openspace{
return nullptr;
}
void ISWAManager::registerOptionsToGroup(int id, const std::vector<properties::SelectionProperty::Option>& options){
if(_groups.find(id) != _groups.end()){
_groups[id]->registerOptions(options);
}
}
}// namsepace openspace

View File

@@ -25,7 +25,6 @@
#define __ISWAMANAGER_H__
#include <ghoul/designpattern/singleton.h>
#include <modules/iswa/rendering/iswagroup.h>
#include <memory>
#include <map>
#include <openspace/engine/downloadmanager.h>
@@ -33,10 +32,14 @@
#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;
@@ -50,6 +53,7 @@ class ISWAManager : public ghoul::Singleton<ISWAManager> {
friend class ghoul::Singleton<ISWAManager>;
public:
enum CygnetType {Texture, Data};
ISWAManager();
~ISWAManager();
@@ -64,7 +68,7 @@ public:
void update();
void registerToGroup(int id, ISWACygnet* cygnet, std::string type);
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);
@@ -75,9 +79,9 @@ private:
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, int group);
void createPlane(int id, std::string json, std::string type, int group = -1);
void createScreenSpace(int id);
void createKameleonPlane(std::string kwPath, int group);
void createKameleonPlane(std::string kwPath, int group = -1);
std::map<std::string, std::string> _month;
std::vector<std::shared_ptr<MetadataFuture>> _metadataFutures;

View File

@@ -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 {