mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-11 07:48:37 -05:00
Merge branch 'feature/iSWA' of github.com:OpenSpace/OpenSpace-Development into feature/iSWA
This commit is contained in:
@@ -30,10 +30,10 @@ function postInitialization()
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
|
||||
openspace.iswa.addCygnet("-4,Data,Ion");
|
||||
--openspace.iswa.addCygnet("-1,Data,GM");
|
||||
--openspace.iswa.addCygnet("-2,Data,GM");
|
||||
--openspace.iswa.addCygnet("-3,Data,GM");
|
||||
openspace.iswa.addCygnet(-4,"Data");
|
||||
--openspace.iswa.addCygnet(-1,"Data","GM");
|
||||
--openspace.iswa.addCygnet(-2,"Data","GM");
|
||||
--openspace.iswa.addCygnet(-3,"Data","GM");
|
||||
|
||||
--[[
|
||||
openspace.iswa.addScreenSpaceCygnet(
|
||||
|
||||
@@ -71,11 +71,15 @@ public:
|
||||
float equalize (float);
|
||||
float entropy();
|
||||
|
||||
float highestBinValue(bool equalized);
|
||||
float binWidth();
|
||||
|
||||
private:
|
||||
int _numBins;
|
||||
float _minValue;
|
||||
float _maxValue;
|
||||
|
||||
|
||||
float* _data;
|
||||
std::vector<float> _equalizer;
|
||||
int _numValues;
|
||||
|
||||
@@ -148,6 +148,8 @@ bool DataPlane::loadTexture() {
|
||||
if(data.empty())
|
||||
return false;
|
||||
|
||||
_backgroundValues.setValue(_dataProcessor->filterValues());
|
||||
|
||||
bool texturesReady = false;
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
|
||||
|
||||
@@ -145,6 +145,11 @@ bool DataSphere::loadTexture(){
|
||||
if(data.empty())
|
||||
return false;
|
||||
|
||||
|
||||
// auto v = _dataProcessor->filterValues();
|
||||
// std::cout << std::to_string(v) << std::endl;
|
||||
_backgroundValues.setValue(_dataProcessor->filterValues());
|
||||
|
||||
bool texturesReady = false;
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ DataProcessor::DataProcessor(bool useLog, bool useHistogram, glm::vec2 normValue
|
||||
:_useLog(useLog)
|
||||
,_useHistogram(useHistogram)
|
||||
,_normValues(normValues)
|
||||
,_filterValues(glm::vec2(0))
|
||||
{
|
||||
_coordinateVariables = {"x", "y", "z", "phi", "theta"};
|
||||
};
|
||||
@@ -311,6 +312,14 @@ void DataProcessor::processData(float* outputData, std::vector<float>& inputData
|
||||
v = normalizeWithStandardScore(v, mean, standardDeviation);
|
||||
outputData[i] += v;
|
||||
}
|
||||
|
||||
if(_useHistogram){
|
||||
float val = histogram.highestBinValue(_useHistogram);
|
||||
val = normalizeWithStandardScore(val, mean, standardDeviation);
|
||||
float width = normalizeWithStandardScore(1, mean, standardDeviation);
|
||||
_filterValues = glm::vec2( val, width);
|
||||
}
|
||||
|
||||
// Histogram equalized = histogram.equalize();
|
||||
// histogram.print();
|
||||
// equalized.print();
|
||||
@@ -326,4 +335,9 @@ float DataProcessor::normalizeWithStandardScore(float value, float mean, float s
|
||||
//return and normalize
|
||||
return ( standardScore + zScoreMin )/(zScoreMin + zScoreMax );
|
||||
}
|
||||
|
||||
glm::vec2 DataProcessor::filterValues(){
|
||||
return _filterValues;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
std::vector<std::string> readJSONHeader(std::string& dataBuffer);
|
||||
std::vector<float*> readJSONData(std::string& dataBuffer, properties::SelectionProperty dataOptions);
|
||||
|
||||
glm::vec2 filterValues();
|
||||
|
||||
private:
|
||||
void processData(
|
||||
@@ -77,6 +78,7 @@ private:
|
||||
bool _useLog;
|
||||
bool _useHistogram;
|
||||
glm::vec2 _normValues;
|
||||
glm::vec2 _filterValues;
|
||||
|
||||
std::set<std::string> _coordinateVariables;
|
||||
};
|
||||
|
||||
@@ -87,29 +87,6 @@ IswaManager::~IswaManager(){
|
||||
_cygnetInformation.clear();
|
||||
}
|
||||
|
||||
void IswaManager::addIswaCygnet(std::string info){
|
||||
std::string token;
|
||||
std::stringstream ss(info);
|
||||
getline(ss,token,',');
|
||||
int cygnetId = std::stoi(token);
|
||||
|
||||
if(!ss.eof()){
|
||||
getline(ss,token,',');
|
||||
std::string data = token;
|
||||
|
||||
if(!ss.eof()){
|
||||
getline(ss, token, ',');
|
||||
addIswaCygnet(cygnetId, data, token);
|
||||
return;
|
||||
}
|
||||
|
||||
addIswaCygnet(cygnetId, data);
|
||||
return;
|
||||
}
|
||||
|
||||
addIswaCygnet(cygnetId);
|
||||
}
|
||||
|
||||
void IswaManager::addIswaCygnet(int id, std::string type, std::string group){
|
||||
if(id > 0){
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ public:
|
||||
IswaManager();
|
||||
~IswaManager();
|
||||
|
||||
void addIswaCygnet(std::string info);
|
||||
void addIswaCygnet(int id, std::string type = "Texture", std::string group = "");
|
||||
// void deleteIswaCygnet(std::string);
|
||||
|
||||
|
||||
@@ -27,8 +27,23 @@ namespace openspace {
|
||||
namespace luascriptfunctions {
|
||||
|
||||
int iswa_addCygnet(lua_State* L) {
|
||||
std::string s = luaL_checkstring(L, -1);
|
||||
IswaManager::ref().addIswaCygnet(s);
|
||||
int nArguments = lua_gettop(L);
|
||||
|
||||
int id = -1;
|
||||
std::string type = "Texture";
|
||||
std::string group = "";
|
||||
|
||||
if(nArguments > 0)
|
||||
id = lua_tonumber(L, 1);
|
||||
|
||||
if(nArguments > 1)
|
||||
type = luaL_checkstring(L, 2);
|
||||
|
||||
if(nArguments > 2)
|
||||
group = luaL_checkstring(L, 3);
|
||||
|
||||
IswaManager::ref().addIswaCygnet(id, type, group);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,13 +231,13 @@ void GuiIswaComponent::render() {
|
||||
ImGui::InputText("addCynget", addCygnetBuffer, addCygnetBufferSize);
|
||||
|
||||
if(ImGui::SmallButton("Add Cygnet"))
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet('"+std::string(addCygnetBuffer)+"');");
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet("+std::string(addCygnetBuffer)+");");
|
||||
|
||||
if(gmdata != gmdatavalue){
|
||||
if(gmdata){
|
||||
std::string x = "openspace.iswa.addCygnet('-1,Data,GMData');";
|
||||
std::string y = "openspace.iswa.addCygnet('-2,Data,GMData');";
|
||||
std::string z = "openspace.iswa.addCygnet('-3,Data,GMData');";
|
||||
std::string x = "openspace.iswa.addCygnet(-1,'Data','GMData');";
|
||||
std::string y = "openspace.iswa.addCygnet(-2,'Data','GMData');";
|
||||
std::string z = "openspace.iswa.addCygnet(-3,'Data','GMData');";
|
||||
OsEng.scriptEngine().queueScript(x+y+z);
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('GMData');");
|
||||
@@ -246,9 +246,9 @@ void GuiIswaComponent::render() {
|
||||
|
||||
if(gmimage != gmimagevalue){
|
||||
if(gmimage){
|
||||
std::string x = "openspace.iswa.addCygnet('-1,Texture,GMImage');";
|
||||
std::string y = "openspace.iswa.addCygnet('-2,Texture,GMImage');";
|
||||
std::string z = "openspace.iswa.addCygnet('-3,Texture,GMImage');";
|
||||
std::string x = "openspace.iswa.addCygnet(-1,'Texture','GMImage');";
|
||||
std::string y = "openspace.iswa.addCygnet(-2,'Texture','GMImage');";
|
||||
std::string z = "openspace.iswa.addCygnet(-3,'Texture','GMImage');";
|
||||
OsEng.scriptEngine().queueScript(x+y+z);
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('GMImage');");
|
||||
@@ -257,7 +257,7 @@ void GuiIswaComponent::render() {
|
||||
|
||||
if(iondata != iondatavalue){
|
||||
if(iondata){
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet('-4,Data,Ionosphere');");
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet(-4,'Data','Ionosphere');");
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('Ionosphere');");
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ bool Histogram::add(float value, float repeat) {
|
||||
|
||||
_data[binIndex] += repeat;
|
||||
_numValues += repeat;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -281,4 +282,25 @@ void Histogram::print() const {
|
||||
std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl;
|
||||
}
|
||||
|
||||
float Histogram::highestBinValue(bool equalized){
|
||||
int highestBin = 0;
|
||||
for(int i=0; i<_numBins; i++){
|
||||
if(_data[i] > _data[highestBin])
|
||||
highestBin = i;
|
||||
}
|
||||
|
||||
float low = _minValue + float(highestBin) / _numBins * (_maxValue - _minValue);
|
||||
float high = low + (_maxValue - _minValue) / float(_numBins);
|
||||
|
||||
if(!equalized){
|
||||
return (high+low)/2.0;
|
||||
}else{
|
||||
return equalize((high+low)/2.0);
|
||||
}
|
||||
}
|
||||
|
||||
float Histogram::binWidth(){
|
||||
return (_maxValue-_minValue)/_numBins;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user