mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Merge branch 'feature/iSWA' of github.com:OpenSpace/OpenSpace-Development into feature/iSWA
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* 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/iswabasegroup.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
@@ -35,7 +36,6 @@ IswaBaseGroup::IswaBaseGroup(std::string name, std::string type)
|
||||
:_enabled("enabled", "Enabled", true)
|
||||
,_alpha("alpha", "Alpha", 0.9f, 0.0f, 1.0f)
|
||||
,_delete("delete", "Delete")
|
||||
,_registered(false)
|
||||
,_type(type)
|
||||
,_dataProcessor(nullptr)
|
||||
{
|
||||
@@ -64,7 +64,9 @@ void IswaBaseGroup::updateGroup(){
|
||||
void IswaBaseGroup::clearGroup(){
|
||||
_groupEvent->publish("clearGroup", ghoul::Dictionary());
|
||||
LDEBUG("Group " + name() + " published clearGroup");
|
||||
|
||||
unregisterProperties();
|
||||
IswaManager::ref().unregisterGroup(name());
|
||||
}
|
||||
|
||||
std::shared_ptr<DataProcessor> IswaBaseGroup::dataProcessor(){
|
||||
@@ -94,14 +96,11 @@ void IswaBaseGroup::registerProperties(){
|
||||
OsEng.gui()._iswa.registerProperty(&_delete);
|
||||
_delete.onChange([this]{
|
||||
clearGroup();
|
||||
});
|
||||
|
||||
_registered = true;
|
||||
});
|
||||
}
|
||||
|
||||
void IswaBaseGroup::unregisterProperties(){
|
||||
OsEng.gui()._iswa.unregisterProperties(name());
|
||||
_registered = false;
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::Dictionary> IswaBaseGroup::propertyValues() const{
|
||||
|
||||
@@ -57,7 +57,6 @@ protected:
|
||||
std::shared_ptr<ghoul::Event<ghoul::Dictionary> > _groupEvent;
|
||||
std::shared_ptr<DataProcessor> _dataProcessor;
|
||||
|
||||
bool _registered;
|
||||
std::string _type;
|
||||
};
|
||||
|
||||
|
||||
@@ -134,8 +134,8 @@ void IswaDataGroup::registerProperties(){
|
||||
}
|
||||
|
||||
void IswaDataGroup::registerOptions(const std::vector<properties::SelectionProperty::Option>& options){
|
||||
if(!_registered)
|
||||
registerProperties();
|
||||
// if(!_registered)
|
||||
// registerProperties();
|
||||
|
||||
if(_dataOptions.options().empty()){
|
||||
for(auto option : options){
|
||||
|
||||
@@ -133,13 +133,16 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions){
|
||||
if (!_useHistogram) {
|
||||
mean = (1.0/_numValues[option])*_sum[option];
|
||||
standardDeviation = _standardDeviation[option];
|
||||
histogram = _histograms[option];
|
||||
histogram = _unNormalizedhistograms[option];
|
||||
|
||||
filterMid = histogram->highestBinValue(_useHistogram);
|
||||
filterWidth = histogram->binWidth();
|
||||
|
||||
//at least one pixel value width. 1/512 above mid and 1/512 below mid => 1/256 filtered
|
||||
filterWidth = std::max(filterWidth, 1.0f/512.0f);
|
||||
|
||||
filterMid = normalizeWithStandardScore(filterMid, mean, standardDeviation, _normValues);
|
||||
filterWidth = normalizeWithStandardScore(filterWidth, mean, standardDeviation, _normValues);
|
||||
}else{
|
||||
Histogram hist = _histograms[option]->equalize();
|
||||
filterMid = hist.highestBinValue(true);
|
||||
@@ -163,7 +166,7 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
|
||||
//set min, max for the unnormalized histogram
|
||||
if(!_unNormalizedhistograms[i]){
|
||||
_unNormalizedhistograms[i] = std::make_shared<Histogram>(_min[i], _max[i], 512);
|
||||
_unNormalizedhistograms[i] = std::make_shared<Histogram>(_min[i], _max[i], NumBins);
|
||||
}else{
|
||||
_unNormalizedhistograms[i]->changeRange(_min[i], _max[i]);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 __DATAPROCESSOR_H__
|
||||
#define __DATAPROCESSOR_H__
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
~DataProcessor();
|
||||
|
||||
/**
|
||||
* Reads and returns the metadata from the data file.
|
||||
* Reads and returns the necessary metadata from the data file.
|
||||
*
|
||||
* @param data The data file content to read metadata from
|
||||
* @param dimensions the dimensions of the data, will be modified
|
||||
@@ -81,28 +81,35 @@ public:
|
||||
void clear();
|
||||
protected:
|
||||
float processDataPoint(float value, int option);
|
||||
float normalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
float unnormalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
|
||||
void initializeVectors(int numOptions);
|
||||
void calculateFilterValues(std::vector<int> selectedOptions);
|
||||
void add(std::vector<std::vector<float>>& optionValues, std::vector<float>& sum);
|
||||
|
||||
glm::size3_t _dimensions;
|
||||
bool _useLog;
|
||||
bool _useHistogram;
|
||||
glm::vec2 _normValues;
|
||||
glm::vec2 _filterValues;
|
||||
|
||||
std::vector<float> _min;
|
||||
std::vector<float> _max;
|
||||
std::set<std::string> _coordinateVariables;
|
||||
glm::size3_t _dimensions;
|
||||
|
||||
//glm::vec2 _histNormValues;
|
||||
private:
|
||||
float normalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
float unnormalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
|
||||
bool _useLog;
|
||||
bool _useHistogram;
|
||||
|
||||
glm::vec2 _normValues;
|
||||
glm::vec2 _filterValues;
|
||||
|
||||
std::vector<float> _sum;
|
||||
std::vector<float> _standardDeviation;
|
||||
std::vector<float> _numValues;
|
||||
std::vector<float> _fitValues;
|
||||
|
||||
std::vector<std::shared_ptr<Histogram>> _histograms;
|
||||
|
||||
std::vector<std::shared_ptr<Histogram>> _unNormalizedhistograms;
|
||||
std::set<std::string> _coordinateVariables;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 *
|
||||
|
||||
@@ -100,7 +100,6 @@ void DataProcessorKameleon::addDataValues(const std::string& path, const propert
|
||||
}
|
||||
std::vector<float*> DataProcessorKameleon::processData(const std::string path, const properties::SelectionProperty& dataOptions, const glm::size3_t& dimensions, float slice){
|
||||
_slice = slice;
|
||||
// _dimensions = dimensions;
|
||||
return processData(path, dataOptions, dimensions);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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/util/dataprocessor.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
|
||||
@@ -52,7 +52,6 @@ private:
|
||||
std::vector<std::string> _loadedVariables;
|
||||
bool _initialized;
|
||||
float _slice;
|
||||
// std::vector<float*> _data;
|
||||
};
|
||||
|
||||
}// namespace
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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/util/dataprocessortext.h>
|
||||
//#include <algorithm>
|
||||
//#include <boost/iostreams/device/mapped_file.hpp>
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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/util/dataprocessor.h>
|
||||
|
||||
#ifndef __DATAPROCESSORTEXT_H__
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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/util/iswamanager.h>
|
||||
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
@@ -33,18 +33,14 @@
|
||||
#include <modules/iswa/rendering/iswakameleongroup.h>
|
||||
|
||||
#include <fstream>
|
||||
//#include <algorithm>
|
||||
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
//#include <openspace/scripting/script_helper.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
//#include <ghoul/lua/ghoul_lua.h>
|
||||
//#include <ghoul/lua/lua_helper.h>
|
||||
|
||||
#include "iswamanager_lua.inl";
|
||||
|
||||
@@ -58,7 +54,6 @@ namespace {
|
||||
namespace openspace{
|
||||
|
||||
IswaManager::IswaManager()
|
||||
: _iswaEvent()
|
||||
{
|
||||
_month["JAN"] = "01";
|
||||
_month["FEB"] = "02";
|
||||
@@ -169,7 +164,7 @@ void IswaManager::addKameleonCdf(std::string groupName, int pos){
|
||||
createKameleonPlane(_cdfInformation[groupName][pos], "x");
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id, double timestamp){
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id, double timestamp) const{
|
||||
return std::move( DlManager.fetchFile(
|
||||
iswaUrl(id, timestamp, "image"),
|
||||
[id](const DownloadManager::MemoryFile& file){
|
||||
@@ -181,7 +176,7 @@ std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id, d
|
||||
) );
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id, double timestamp){
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id, double timestamp) const{
|
||||
return std::move( DlManager.fetchFile(
|
||||
iswaUrl(id, timestamp, "data"),
|
||||
[id](const DownloadManager::MemoryFile& file){
|
||||
@@ -193,7 +188,7 @@ std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id, do
|
||||
) );
|
||||
}
|
||||
|
||||
std::string IswaManager::iswaUrl(int id, double timestamp, std::string type){
|
||||
std::string IswaManager::iswaUrl(int id, double timestamp, std::string type) const{
|
||||
std::string url;
|
||||
if(id < 0){
|
||||
url = baseUrl+type+"/" + std::to_string(-id) + "/";
|
||||
@@ -209,7 +204,7 @@ std::string IswaManager::iswaUrl(int id, double timestamp, std::string type){
|
||||
std::getline(ss, token, ' ');
|
||||
url += token + "-";
|
||||
std::getline(ss, token, ' ');
|
||||
url += _month[token] + "-";
|
||||
url += _month.at(token) + "-";
|
||||
std::getline(ss, token, 'T');
|
||||
url += token + "%20";
|
||||
std::getline(ss, token, '.');
|
||||
@@ -231,11 +226,18 @@ void IswaManager::registerGroup(std::string groupName, std::string type){
|
||||
}else{
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(groupName, std::make_shared<IswaBaseGroup>(groupName, type)));
|
||||
}
|
||||
} else if(!_groups[groupName]->isType(type)){
|
||||
LWARNING("Can't add cygnet to groups with diffent type");
|
||||
} else {
|
||||
LWARNING("Trying to add Group with name: '" + groupName + "' but it already exist.");
|
||||
}
|
||||
}
|
||||
|
||||
void IswaManager::unregisterGroup(std::string groupName){
|
||||
if(_groups.find(groupName) != _groups.end()){
|
||||
_groups.erase(groupName);
|
||||
} else {
|
||||
LWARNING("Trying to erase Group with name: '" + groupName + "' but it does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IswaBaseGroup> IswaManager::iswaGroup(std::string name){
|
||||
if(_groups.find(name) != _groups.end()){
|
||||
@@ -245,15 +247,15 @@ std::shared_ptr<IswaBaseGroup> IswaManager::iswaGroup(std::string name){
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::map<int, std::shared_ptr<CygnetInfo>>& IswaManager::cygnetInformation(){
|
||||
return _cygnetInformation;
|
||||
std::map<int, std::shared_ptr<CygnetInfo>>& IswaManager::cygnetInformation() {
|
||||
return _cygnetInformation;
|
||||
}
|
||||
|
||||
std::map<std::string, std::shared_ptr<IswaBaseGroup>>& IswaManager::groups(){
|
||||
std::map<std::string, std::shared_ptr<IswaBaseGroup>>& IswaManager::groups() {
|
||||
return _groups;
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<CdfInfo>>& IswaManager::cdfInformation(){
|
||||
std::map<std::string, std::vector<CdfInfo>>& IswaManager::cdfInformation() {
|
||||
return _cdfInformation;
|
||||
}
|
||||
|
||||
@@ -274,7 +276,7 @@ std::shared_ptr<MetadataFuture> IswaManager::downloadMetadata(int id){
|
||||
return metaFuture;
|
||||
}
|
||||
|
||||
std::string IswaManager::jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> data){
|
||||
std::string IswaManager::jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> data) const {
|
||||
if(data->json != ""){
|
||||
json j = json::parse(data->json);
|
||||
|
||||
@@ -316,7 +318,7 @@ std::string IswaManager::jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
"Name = '" + data->name +"' , "
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = '" + _type[data->type] + _geom[data->geom] + "', "
|
||||
"Type = '" + _type.at(data->type) + _geom.at(data->geom) + "', "
|
||||
"Id = " + std::to_string(data->id) + ", "
|
||||
"Frame = '" + frame + "' , "
|
||||
"GridMin = " + std::to_string(min) + ", "
|
||||
@@ -334,7 +336,7 @@ std::string IswaManager::jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut){
|
||||
std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut) const {
|
||||
if(info.path != ""){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(info.path)).fileExtension();
|
||||
if(extension == "cdf"){
|
||||
@@ -388,7 +390,7 @@ std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut){
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string IswaManager::jsonSphereToLuaTable(std::shared_ptr<MetadataFuture> data){
|
||||
std::string IswaManager::jsonSphereToLuaTable(std::shared_ptr<MetadataFuture> data) const {
|
||||
if(data->json == ""){
|
||||
LWARNING("jsonSphereToLuaTable: no content in metadata json");
|
||||
return "";
|
||||
@@ -421,7 +423,7 @@ std::string IswaManager::jsonSphereToLuaTable(std::shared_ptr<MetadataFuture> da
|
||||
"Name = '" + data->name +"' , "
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = '" + _type[data->type] + _geom[data->geom] + "', "
|
||||
"Type = '" + _type.at(data->type) + _geom.at(data->geom) + "', "
|
||||
"Id = " + std::to_string(data->id) + ", "
|
||||
"Frame = '" + frame + "' , "
|
||||
"GridMin = " + std::to_string(min) + ", "
|
||||
@@ -455,7 +457,8 @@ void IswaManager::createPlane(std::shared_ptr<MetadataFuture> data){
|
||||
type = typeid(TexturePlane).name();
|
||||
}
|
||||
|
||||
registerGroup(data->group, type);
|
||||
if(_groups.find(data->group) == _groups.end())
|
||||
registerGroup(data->group, type);
|
||||
|
||||
auto it = _groups.find(data->group);
|
||||
if(it == _groups.end() || (*it).second->isType(type)){
|
||||
@@ -485,7 +488,9 @@ void IswaManager::createSphere(std::shared_ptr<MetadataFuture> data){
|
||||
|
||||
if(!data->group.empty()){
|
||||
std::string type = typeid(DataSphere).name();
|
||||
registerGroup(data->group, type);
|
||||
|
||||
if(_groups.find(data->group) == _groups.end())
|
||||
registerGroup(data->group, type);
|
||||
|
||||
auto it = _groups.find(data->group);
|
||||
if(it == _groups.end() || (*it).second->isType(type)){
|
||||
@@ -516,7 +521,9 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut){
|
||||
|
||||
if(!info.group.empty()){
|
||||
std::string type = typeid(KameleonPlane).name();
|
||||
registerGroup(info.group, type);
|
||||
|
||||
if(_groups.find(info.group) == _groups.end())
|
||||
registerGroup(info.group, type);
|
||||
|
||||
auto it = _groups.find(info.group);
|
||||
if(it == _groups.end() || (*it).second->isType(type)){
|
||||
@@ -543,7 +550,7 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut){
|
||||
}
|
||||
}
|
||||
|
||||
void IswaManager::createFieldline(std::string name, std::string cdfPath, std::string seedPath){
|
||||
void IswaManager::createFieldline(std::string name, std::string cdfPath, std::string seedPath) const {
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(cdfPath)).fileExtension();
|
||||
|
||||
if(FileSys.fileExists(absPath(cdfPath)) && extension == "cdf"){
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 __ISWAMANAGER_H__
|
||||
#define __ISWAMANAGER_H__
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <ccmc/Kameleon.h>
|
||||
#endif
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
//#include <openspace/properties/propertyowner.h>
|
||||
#include <modules/iswa/ext/json/json.hpp>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
@@ -70,8 +69,7 @@ struct MetadataFuture {
|
||||
};
|
||||
|
||||
|
||||
class IswaManager : public ghoul::Singleton<IswaManager> { //, public properties::PropertyOwner {
|
||||
//friend class ghoul::Singleton<IswaManager>;
|
||||
class IswaManager : public ghoul::Singleton<IswaManager> {
|
||||
|
||||
public:
|
||||
enum CygnetType {Texture, Data, Kameleon, NoType};
|
||||
@@ -82,11 +80,11 @@ public:
|
||||
|
||||
void addIswaCygnet(int id, std::string type = "Texture", std::string group = "");
|
||||
void addKameleonCdf(std::string group, int pos);
|
||||
void createFieldline(std::string name, std::string cdfPath, std::string seedPath);
|
||||
void createFieldline(std::string name, std::string cdfPath, std::string seedPath) const ;
|
||||
|
||||
std::future<DownloadManager::MemoryFile> fetchImageCygnet(int id, double timestamp);
|
||||
std::future<DownloadManager::MemoryFile> fetchDataCygnet(int id, double timestamp);
|
||||
std::string iswaUrl(int id, double timestamp = Time::ref().currentTime(), std::string type = "image");
|
||||
std::future<DownloadManager::MemoryFile> fetchImageCygnet(int id, double timestamp) const;
|
||||
std::future<DownloadManager::MemoryFile> fetchDataCygnet(int id, double timestamp) const;
|
||||
std::string iswaUrl(int id, double timestamp = Time::ref().currentTime(), std::string type = "image") const;
|
||||
|
||||
std::shared_ptr<IswaBaseGroup> iswaGroup(std::string name);
|
||||
|
||||
@@ -96,25 +94,21 @@ public:
|
||||
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
ghoul::Event<>& iswaEvent(){
|
||||
return _iswaEvent;
|
||||
}
|
||||
|
||||
void addCdfFiles(std::string path);
|
||||
void setBaseUrl(std::string bUrl);
|
||||
void registerGroup(std::string groupName, std::string type);
|
||||
void unregisterGroup(std::string groupName);
|
||||
private:
|
||||
std::shared_ptr<MetadataFuture> downloadMetadata(int id);
|
||||
std::string jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> data);
|
||||
std::string jsonSphereToLuaTable(std::shared_ptr<MetadataFuture> data);
|
||||
std::string parseKWToLuaTable(CdfInfo info, std::string cut="z");
|
||||
std::string jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> data) const;
|
||||
std::string jsonSphereToLuaTable(std::shared_ptr<MetadataFuture> data) const;
|
||||
std::string parseKWToLuaTable(CdfInfo info, std::string cut="z") const;
|
||||
|
||||
void createScreenSpace(int id);
|
||||
void createPlane(std::shared_ptr<MetadataFuture> data);
|
||||
void createSphere(std::shared_ptr<MetadataFuture> data);
|
||||
void createKameleonPlane(CdfInfo info, std::string cut);
|
||||
|
||||
void fillCygnetInfo(std::string jsonString);
|
||||
void registerGroup(std::string groupName, std::string type);
|
||||
|
||||
std::map<std::string, std::string> _month;
|
||||
std::map<int, std::string> _type;
|
||||
@@ -126,9 +120,6 @@ private:
|
||||
std::map<std::string, std::shared_ptr<IswaBaseGroup>> _groups;
|
||||
std::map<int, std::shared_ptr<CygnetInfo>> _cygnetInformation;
|
||||
std::map<std::string, std::vector<CdfInfo>> _cdfInformation;
|
||||
|
||||
ghoul::Event<> _iswaEvent;
|
||||
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
@@ -140,7 +140,6 @@ int iswa_removeScrenSpaceCygnet(lua_State* L){
|
||||
|
||||
int iswa_removeGroup(lua_State* L){
|
||||
std::string name = luaL_checkstring(L, -1);
|
||||
// IswaManager::ref().unregisterGroup(id);
|
||||
|
||||
auto groups = IswaManager::ref().groups();
|
||||
if(groups.find(name) != groups.end())
|
||||
|
||||
Reference in New Issue
Block a user