fix for duplicate dataoptions dropdown in gui

This commit is contained in:
Michael Nilsson
2016-06-23 10:31:45 -04:00
parent cd7ce765a9
commit 4486fd9a80
6 changed files with 70 additions and 73 deletions
+26 -27
View File
@@ -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{
-1
View File
@@ -57,7 +57,6 @@ protected:
std::shared_ptr<ghoul::Event<ghoul::Dictionary> > _groupEvent;
std::shared_ptr<DataProcessor> _dataProcessor;
bool _registered;
std::string _type;
};
+2 -2
View File
@@ -124,8 +124,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){
+39 -32
View File
@@ -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";
@@ -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()){
@@ -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)){
+3 -10
View File
@@ -70,8 +70,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};
@@ -96,12 +95,10 @@ 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);
@@ -112,9 +109,7 @@ private:
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;
@@ -127,8 +122,6 @@ private:
std::map<int, std::shared_ptr<CygnetInfo>> _cygnetInformation;
std::map<std::string, std::vector<CdfInfo>> _cdfInformation;
ghoul::Event<> _iswaEvent;
};
} //namespace openspace
-1
View File
@@ -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())