diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h index 900eb81dac..3ec235e341 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -262,6 +262,12 @@ public: */ void setVisible(bool state); + /** + * Returns whether this Property is visible or not. + * \return Whether this Property is visible or hidden + */ + bool isVisible() const; + /** * This method determines if this Property should be read-only in external * applications. This setting is only a hint and does not need to be followed by GUI diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index eda7d60812..7d618b1f3a 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -54,7 +54,7 @@ public: static Renderable* createFromDictionary(const ghoul::Dictionary& dictionary); // constructors & destructor - Renderable(); + Renderable(); Renderable(const ghoul::Dictionary& dictionary); virtual ~Renderable(); diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 7c7f9c5f26..e94f7a320b 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -114,6 +114,7 @@ public: void unregisterScreenSpaceRenderable(std::shared_ptr s); void unregisterScreenSpaceRenderable(std::string name); std::shared_ptr screenSpaceRenderable(std::string name); + std::vector screenSpaceRenderables() const; std::unique_ptr buildRenderProgram( std::string name, diff --git a/include/openspace/rendering/screenspacerenderable.h b/include/openspace/rendering/screenspacerenderable.h index e42605990a..9fa4c175c8 100644 --- a/include/openspace/rendering/screenspacerenderable.h +++ b/include/openspace/rendering/screenspacerenderable.h @@ -83,9 +83,6 @@ protected: glm::vec2 toSpherical(const glm::vec2& euclidean); - void registerProperties(); - void unregisterProperties(); - void createShaders(); glm::mat4 scaleMatrix(); glm::mat4 rotationMatrix(); diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 6650a7b9ed..e2a8fa1a9d 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -21,10 +21,10 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #include #include #include -#include #include #include @@ -40,11 +40,9 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictiona { _id = id(); setName("ScreenSpaceFramebuffer" + std::to_string(_id)); - registerProperties(); glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution(); addProperty(_size); - OsEng.gui()._screenSpaceProperty.registerProperty(&_size); _size.set(glm::vec4(0, 0, resolution.x,resolution.y)); _scale.setValue(1.0f); @@ -63,8 +61,6 @@ bool ScreenSpaceFramebuffer::initialize(){ } bool ScreenSpaceFramebuffer::deinitialize(){ - unregisterProperties(); - glDeleteVertexArrays(1, &_quad); _quad = 0; diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index 2c20a33f4f..f77f81ee4e 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -31,8 +31,6 @@ #include #include -#include - namespace { const std::string _loggerCat = "ScreenSpaceImage"; @@ -58,12 +56,10 @@ ScreenSpaceImage::ScreenSpaceImage(const ghoul::Dictionary& dictionary) } addProperty(_texturePath); - registerProperties(); std::string texturePath; if (dictionary.getValue(KeyTexturePath, texturePath)) { _texturePath = texturePath; - OsEng.gui()._screenSpaceProperty.registerProperty(&_texturePath); _texturePath.onChange([this](){ loadTexture(); }); } @@ -85,7 +81,6 @@ bool ScreenSpaceImage::initialize() { } bool ScreenSpaceImage::deinitialize() { - unregisterProperties(); glDeleteVertexArrays(1, &_quad); _quad = 0; diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 1ebf8b06a1..2ac68f7b7e 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -24,8 +24,6 @@ #include #include -#include - namespace { const std::string _loggerCat = "DataPlane"; } @@ -49,13 +47,6 @@ bool DataPlane::initialize(){ _dataProcessor = _group->dataProcessor(); subscribeToGroup(); }else{ - 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); _dataProcessor = std::make_shared(); //If autofiler is on, background values property should be hidden @@ -64,10 +55,10 @@ bool DataPlane::initialize(){ // and unregister backgroundvalues property. if(_autoFilter.value()){ _backgroundValues.setValue(_dataProcessor->filterValues()); - OsEng.gui()._iswa.unregisterProperty(&_backgroundValues); + _backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues } else { - OsEng.gui()._iswa.registerProperty(&_backgroundValues, &_autoFilter); + _backgroundValues.setVisible(true); } }); } diff --git a/modules/iswa/rendering/datasphere.cpp b/modules/iswa/rendering/datasphere.cpp index b96b2f7fee..9e3da7d657 100644 --- a/modules/iswa/rendering/datasphere.cpp +++ b/modules/iswa/rendering/datasphere.cpp @@ -26,8 +26,6 @@ #include #include -#include - #ifdef WIN32 #define _USE_MATH_DEFINES #include @@ -50,8 +48,6 @@ DataSphere::DataSphere(const ghoul::Dictionary& dictionary) _programName = "DataSphereProgram"; _vsPath = "${MODULE_ISWA}/shaders/datasphere_vs.glsl"; _fsPath = "${MODULE_ISWA}/shaders/datasphere_fs.glsl"; - - } DataSphere::~DataSphere(){} @@ -66,14 +62,6 @@ bool DataSphere::initialize(){ _dataProcessor = _group->dataProcessor(); subscribeToGroup(); }else{ - OsEng.gui()._iswa.registerProperty(&_useLog); - OsEng.gui()._iswa.registerProperty(&_useHistogram); - OsEng.gui()._iswa.registerProperty(&_autoFilter); - OsEng.gui()._iswa.registerProperty(&_backgroundValues); - OsEng.gui()._iswa.registerProperty(&_normValues); - OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile); - OsEng.gui()._iswa.registerProperty(&_dataOptions); - _dataProcessor = std::make_shared(); //If autofiler is on, background values property should be hidden _autoFilter.onChange([this](){ @@ -81,9 +69,10 @@ bool DataSphere::initialize(){ // and unregister backgroundvalues property. if(_autoFilter.value()){ _backgroundValues.setValue(_dataProcessor->filterValues()); + _backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues } else { - OsEng.gui()._iswa.registerProperty(&_backgroundValues, &_autoFilter); + _backgroundValues.setVisible(true); } }); } diff --git a/modules/iswa/rendering/iswabasegroup.cpp b/modules/iswa/rendering/iswabasegroup.cpp index 5f3ebd89cd..2e3e56cc83 100644 --- a/modules/iswa/rendering/iswabasegroup.cpp +++ b/modules/iswa/rendering/iswabasegroup.cpp @@ -34,8 +34,6 @@ #include #include -#include - namespace { const std::string _loggerCat = "IswaBaseGroup"; using json = nlohmann::json; @@ -88,9 +86,6 @@ std::shared_ptr > IswaBaseGroup::groupEvent(){ void IswaBaseGroup::registerProperties(){ - OsEng.gui()._iswa.registerProperty(&_enabled); - OsEng.gui()._iswa.registerProperty(&_alpha); - _enabled.onChange([this]{ LDEBUG("Group " + name() + " published enabledChanged"); _groupEvent->publish("enabledChanged", ghoul::Dictionary({{"enabled", _enabled.value()}})); @@ -102,7 +97,6 @@ void IswaBaseGroup::registerProperties(){ }); - OsEng.gui()._iswa.registerProperty(&_delete); _delete.onChange([this]{ clearGroup(); }); @@ -111,7 +105,6 @@ void IswaBaseGroup::registerProperties(){ } void IswaBaseGroup::unregisterProperties(){ - OsEng.gui()._iswa.unregisterProperties(name()); _registered = false; } diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 83937b9249..ee964d75e7 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -27,8 +27,6 @@ #include #include #include -#include - namespace { const std::string _loggerCat = "IswaCygnet"; @@ -107,9 +105,6 @@ bool IswaCygnet::initialize(){ if(!_data->groupName.empty()){ initializeGroup(); }else{ - OsEng.gui()._iswa.registerProperty(&_alpha); - OsEng.gui()._iswa.registerProperty(&_delete); - _delete.onChange([this](){ deinitialize(); OsEng.scriptEngine().queueScript("openspace.removeSceneGraphNode('" + name() + "')"); @@ -121,7 +116,7 @@ bool IswaCygnet::initialize(){ createShader(); downloadTextureResource(); - return true; + return true; } bool IswaCygnet::deinitialize(){ @@ -177,8 +172,8 @@ void IswaCygnet::render(const RenderData& data){ void IswaCygnet::update(const UpdateData& data){ - if (!_enabled) - return; + if (!_enabled) + return; // the texture resource is downloaded ahead of time, so we need to // now if we are going backwards or forwards @@ -217,16 +212,13 @@ bool IswaCygnet::destroyShader(){ renderEngine.removeRenderProgram(_shader); _shader = nullptr; } - return true; + return true; } void IswaCygnet::registerProperties(){ - OsEng.gui()._iswa.registerProperty(&_enabled); - // OsEng.gui()._iswa.registerProperty(&_delete); } void IswaCygnet::unregisterProperties(){ - OsEng.gui()._iswa.unregisterProperties(name()); } void IswaCygnet::initializeTime(){ diff --git a/modules/iswa/rendering/iswadatagroup.cpp b/modules/iswa/rendering/iswadatagroup.cpp index b780811545..6fbff8e972 100644 --- a/modules/iswa/rendering/iswadatagroup.cpp +++ b/modules/iswa/rendering/iswadatagroup.cpp @@ -34,8 +34,6 @@ #include #include -#include - namespace { const std::string _loggerCat = "IswaDataGroup"; using json = nlohmann::json; @@ -68,15 +66,15 @@ IswaDataGroup::IswaDataGroup(std::string name, std::string type) IswaDataGroup::~IswaDataGroup(){} void IswaDataGroup::registerProperties(){ - OsEng.gui()._iswa.registerProperty(&_useLog); - OsEng.gui()._iswa.registerProperty(&_useHistogram); - OsEng.gui()._iswa.registerProperty(&_autoFilter); - if(!_autoFilter.value()) - OsEng.gui()._iswa.registerProperty(&_backgroundValues); - // OsEng.gui()._iswa.registerProperty(&_autoFilter); - OsEng.gui()._iswa.registerProperty(&_normValues); - OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile); - OsEng.gui()._iswa.registerProperty(&_dataOptions); + //OsEng.gui()._iswa.registerProperty(&_useLog); + //OsEng.gui()._iswa.registerProperty(&_useHistogram); + //OsEng.gui()._iswa.registerProperty(&_autoFilter); + //if(!_autoFilter.value()) + // OsEng.gui()._iswa.registerProperty(&_backgroundValues); + //// OsEng.gui()._iswa.registerProperty(&_autoFilter); + //OsEng.gui()._iswa.registerProperty(&_normValues); + //OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile); + //OsEng.gui()._iswa.registerProperty(&_dataOptions); _useLog.onChange([this]{ @@ -96,10 +94,10 @@ void IswaDataGroup::registerProperties(){ // and unregister backgroundvalues property. if(_autoFilter.value()){ _backgroundValues.setValue(_dataProcessor->filterValues()); - OsEng.gui()._iswa.unregisterProperty(&_backgroundValues); + _backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues } else { - OsEng.gui()._iswa.registerProperty(&_backgroundValues, &_autoFilter); + _backgroundValues.setVisible(true); } _groupEvent->publish("autoFilterChanged", ghoul::Dictionary({{"autoFilter", _autoFilter.value()}})); }); diff --git a/modules/iswa/rendering/iswakameleongroup.cpp b/modules/iswa/rendering/iswakameleongroup.cpp index 513bd8000a..4273f8330e 100644 --- a/modules/iswa/rendering/iswakameleongroup.cpp +++ b/modules/iswa/rendering/iswakameleongroup.cpp @@ -33,7 +33,6 @@ #include #include #include -#include namespace { const std::string _loggerCat = "IswaDataGroup"; @@ -42,15 +41,15 @@ namespace { namespace openspace{ IswaKameleonGroup::IswaKameleonGroup(std::string name, std::string type) - :IswaDataGroup(name, type) + :IswaDataGroup(name, type) ,_resolution("resolution", "Resolution%", 100.0f, 10.0f, 200.0f) - ,_fieldlines("fieldlineSeedsIndexFile", "Fieldline Seedpoints") + ,_fieldlines("fieldlineSeedsIndexFile", "Fieldline Seedpoints") ,_fieldlineIndexFile("") ,_kameleonPath("") { addProperty(_resolution); addProperty(_fieldlines); - registerProperties(); + registerProperties(); } IswaKameleonGroup::~IswaKameleonGroup(){} @@ -61,7 +60,7 @@ void IswaKameleonGroup::clearGroup(){ } std::vector IswaKameleonGroup::fieldlineValue(){ - return _fieldlines.value(); + return _fieldlines.value(); } void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath){ @@ -79,8 +78,8 @@ void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile, std::st void IswaKameleonGroup::registerProperties(){ - OsEng.gui()._iswa.registerProperty(&_resolution); - OsEng.gui()._iswa.registerProperty(&_fieldlines); + //OsEng.gui()._iswa.registerProperty(&_resolution); + //OsEng.gui()._iswa.registerProperty(&_fieldlines); _resolution.onChange([this]{ LDEBUG("Group " + name() + " published resolutionChanged"); @@ -89,7 +88,7 @@ void IswaKameleonGroup::registerProperties(){ _fieldlines.onChange([this]{ updateFieldlineSeeds(); - }); + }); } void IswaKameleonGroup::readFieldlinePaths(std::string indexFile){ diff --git a/modules/iswa/rendering/kameleonplane.cpp b/modules/iswa/rendering/kameleonplane.cpp index e8d4e71662..9a5dab1125 100644 --- a/modules/iswa/rendering/kameleonplane.cpp +++ b/modules/iswa/rendering/kameleonplane.cpp @@ -30,8 +30,6 @@ #include #include -#include - namespace { using json = nlohmann::json; const std::string _loggerCat = "KameleonPlane"; @@ -58,9 +56,6 @@ KameleonPlane::KameleonPlane(const ghoul::Dictionary& dictionary) std::string axis; dictionary.getValue("axisCut", axis); - OsEng.gui()._iswa.registerProperty(&_slice); - - if(axis == "x") _cut = 0; else if (axis == "y") _cut = 1; else _cut = 2; @@ -104,15 +99,6 @@ bool KameleonPlane::initialize(){ _dataProcessor = _group->dataProcessor(); subscribeToGroup(); }else{ - 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(&_resolution); - OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile); - OsEng.gui()._iswa.registerProperty(&_fieldlines); - OsEng.gui()._iswa.registerProperty(&_dataOptions); _dataProcessor = std::make_shared(); //If autofiler is on, background values property should be hidden @@ -121,10 +107,10 @@ bool KameleonPlane::initialize(){ // and unregister backgroundvalues property. if(_autoFilter.value()){ _backgroundValues.setValue(_dataProcessor->filterValues()); - OsEng.gui()._iswa.unregisterProperty(&_backgroundValues); + _backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues } else { - OsEng.gui()._iswa.registerProperty(&_backgroundValues, &_autoFilter); + _backgroundValues.setVisible(true); } }); } @@ -164,7 +150,7 @@ bool KameleonPlane::initialize(){ } updateTextureResource(); - return true; + return true; } bool KameleonPlane::createGeometry() { diff --git a/modules/iswa/rendering/kameleonplane.h b/modules/iswa/rendering/kameleonplane.h index 6fd373804b..9b1ab3a933 100644 --- a/modules/iswa/rendering/kameleonplane.h +++ b/modules/iswa/rendering/kameleonplane.h @@ -40,8 +40,8 @@ namespace openspace{ */ class KameleonPlane : public DataCygnet { public: - KameleonPlane(const ghoul::Dictionary& dictionary); - ~KameleonPlane(); + KameleonPlane(const ghoul::Dictionary& dictionary); + ~KameleonPlane(); bool initialize() override; bool deinitialize() override; @@ -76,7 +76,7 @@ private: void subscribeToGroup(); void changeKwPath(std::string path); - static int id(); + static int id(); properties::FloatProperty _resolution; properties::FloatProperty _slice; diff --git a/modules/iswa/util/iswamanager_lua.inl b/modules/iswa/util/iswamanager_lua.inl index fa46ff0c27..703a053ba0 100644 --- a/modules/iswa/util/iswamanager_lua.inl +++ b/modules/iswa/util/iswamanager_lua.inl @@ -140,13 +140,13 @@ int iswa_removeScrenSpaceCygnet(lua_State* L){ int iswa_removeGroup(lua_State* L){ std::string name = luaL_checkstring(L, -1); - // IswaManager::ref().unregisterGroup(id); + // IswaManager::ref().unregisterGroup(id); auto groups = IswaManager::ref().groups(); if(groups.find(name) != groups.end()) groups[name]->clearGroup(); - return 0; + return 0; } int iswa_addCdfFiles(lua_State* L){ diff --git a/modules/onscreengui/include/guiiswacomponent.h b/modules/onscreengui/include/guiiswacomponent.h index d19c411609..693e38e8a5 100644 --- a/modules/onscreengui/include/guiiswacomponent.h +++ b/modules/onscreengui/include/guiiswacomponent.h @@ -28,6 +28,8 @@ #include #include +#include + namespace openspace { namespace gui { @@ -40,7 +42,7 @@ struct RadioOption { class GuiIswaComponent : public GuiPropertyComponent { public: GuiIswaComponent(); - virtual void render() override; + void render() override; private: bool _gmdata; diff --git a/modules/onscreengui/include/guipropertycomponent.h b/modules/onscreengui/include/guipropertycomponent.h index 4e7a7ec902..25e1661b7d 100644 --- a/modules/onscreengui/include/guipropertycomponent.h +++ b/modules/onscreengui/include/guipropertycomponent.h @@ -27,70 +27,32 @@ #include -#include -#include +#include #include -#include namespace openspace { namespace properties { class Property; + class PropertyOwner; } namespace gui { class GuiPropertyComponent : public GuiComponent { public: - void registerProperty(properties::Property* prop, properties::Property* sibling = nullptr); - void unregisterProperty(properties::Property* prop); - void unregisterProperties(std::string owner); + using SourceFunction = std::function()>; + + // This is the function that evaluates to the list of Propertyowners that this + // component should render + void setSource(SourceFunction func); + void render(); protected: - enum class PropertyType { - BoolProperty = 0, - IntProperty, - FloatProperty, - Vec2Property, - Vec3Property, - StringProperty, - OptionProperty, - SelectionProperty, - TriggerProperty, - InvalidPropertyType - }; + void renderProperty(properties::Property* prop, properties::PropertyOwner* owner); - struct PropertyInfo { - PropertyType type; - std::string identifier; - std::string name; - std::string group; - }; - typedef std::string PropertyOwner; - - struct Property { - PropertyOwner owner; - std::vector properties; - }; - - PropertyType toPropertyType(const std::string& name) const; - - void renderProperty(const PropertyInfo& info) const; - - std::set _boolProperties; - std::set _intProperties; - std::set _floatProperties; - std::set _vec2Properties; - std::set _vec3Properties; - std::set _vec4Properties; - std::set _stringProperties; - std::set _optionProperties; - std::set _selectionProperties; - std::set _triggerProperties; - std::map> _propertiesByOwner; - - //std::vector _properties; + SourceFunction _function; }; } // namespace gui diff --git a/modules/onscreengui/include/renderproperties.h b/modules/onscreengui/include/renderproperties.h index 6148c36046..8625240265 100644 --- a/modules/onscreengui/include/renderproperties.h +++ b/modules/onscreengui/include/renderproperties.h @@ -25,22 +25,26 @@ #ifndef __RENDERPROPERTIES_H__ #define __RENDERPROPERTIES_H__ -#include -#include +#include +namespace openspace { -using namespace openspace::properties; +namespace properties { + class Property; +} void executeScript(const std::string& id, const std::string& value); -void renderBoolProperty(Property* prop, const std::string& ownerName); -void renderOptionProperty(Property* prop, const std::string& ownerName); -void renderSelectionProperty(Property* prop, const std::string& ownerName); -void renderStringProperty(Property* prop, const std::string& ownerName); -void renderIntProperty(Property* prop, const std::string& ownerName); -void renderFloatProperty(Property* prop, const std::string& ownerName); -void renderVec2Property(Property* prop, const std::string& ownerName); -void renderVec3Property(Property* prop, const std::string& ownerName); -void renderVec4Property(Property* prop, const std::string& ownerName); -void renderTriggerProperty(Property* prop, const std::string& ownerName); +void renderBoolProperty(properties::Property* prop, const std::string& ownerName); +void renderOptionProperty(properties::Property* prop, const std::string& ownerName); +void renderSelectionProperty(properties::Property* prop, const std::string& ownerName); +void renderStringProperty(properties::Property* prop, const std::string& ownerName); +void renderIntProperty(properties::Property* prop, const std::string& ownerName); +void renderFloatProperty(properties::Property* prop, const std::string& ownerName); +void renderVec2Property(properties::Property* prop, const std::string& ownerName); +void renderVec3Property(properties::Property* prop, const std::string& ownerName); +void renderVec4Property(properties::Property* prop, const std::string& ownerName); +void renderTriggerProperty(properties::Property* prop, const std::string& ownerName); -#endif __RENDERPROPERTIES_H__ \ No newline at end of file +} // namespace + +#endif __RENDERPROPERTIES_H__ diff --git a/modules/onscreengui/src/guiiswacomponent.cpp b/modules/onscreengui/src/guiiswacomponent.cpp index e5fd4c33fb..69d0373db0 100644 --- a/modules/onscreengui/src/guiiswacomponent.cpp +++ b/modules/onscreengui/src/guiiswacomponent.cpp @@ -58,10 +58,10 @@ namespace { namespace openspace { namespace gui { GuiIswaComponent::GuiIswaComponent() - :GuiPropertyComponent() - ,_gmdata(false) - ,_gmimage(false) - ,_iondata(false) + : GuiPropertyComponent() + , _gmdata(false) + , _gmimage(false) + , _iondata(false) {} void GuiIswaComponent::render() { @@ -154,61 +154,8 @@ void GuiIswaComponent::render() { } #endif - for (const auto& p : _propertiesByOwner) { - if (ImGui::CollapsingHeader(p.first.c_str())) { - for (properties::Property* prop : p.second) { - if (_boolProperties.find(prop) != _boolProperties.end()) { - renderBoolProperty(prop, p.first); - continue; - } + GuiPropertyComponent::render(); - if (_intProperties.find(prop) != _intProperties.end()) { - renderIntProperty(prop, p.first); - continue; - } - - if (_floatProperties.find(prop) != _floatProperties.end()) { - renderFloatProperty(prop, p.first); - continue; - } - - if (_vec2Properties.find(prop) != _vec2Properties.end()) { - renderVec2Property(prop, p.first); - continue; - } - - if (_vec3Properties.find(prop) != _vec3Properties.end()) { - renderVec3Property(prop, p.first); - continue; - } - - if (_vec4Properties.find(prop) != _vec4Properties.end()) { - renderVec4Property(prop, p.first); - continue; - } - - if (_optionProperties.find(prop) != _optionProperties.end()) { - renderOptionProperty(prop, p.first); - continue; - } - - if (_triggerProperties.find(prop) != _triggerProperties.end()) { - renderTriggerProperty(prop, p.first); - continue; - } - - if (_selectionProperties.find(prop) != _selectionProperties.end()) { - renderSelectionProperty(prop, p.first); - continue; - } - - if (_stringProperties.find(prop) != _stringProperties.end()) { - renderStringProperty(prop, p.first); - continue; - } - } - } - } #ifdef OPENSPACE_MODULE_ISWA_ENABLED diff --git a/modules/onscreengui/src/guipropertycomponent.cpp b/modules/onscreengui/src/guipropertycomponent.cpp index 89f5014c9c..bd80e8df78 100644 --- a/modules/onscreengui/src/guipropertycomponent.cpp +++ b/modules/onscreengui/src/guipropertycomponent.cpp @@ -48,200 +48,44 @@ namespace { namespace openspace { namespace gui { -void GuiPropertyComponent::registerProperty(properties::Property* prop, properties::Property* sibling) { - //void GuiPropertyComponent::registerProperty(const std::string& propertyDescription) { - using namespace properties; - - std::string className = prop->className(); - - if (className == "BoolProperty") - _boolProperties.insert(prop); - else if (className == "IntProperty") - _intProperties.insert(prop); - else if (className == "FloatProperty") - _floatProperties.insert(prop); - else if (className == "StringProperty") - _stringProperties.insert(prop); - else if (className == "Vec2Property") - _vec2Properties.insert(prop); - else if (className == "Vec3Property") - _vec3Properties.insert(prop); - else if (className == "Vec4Property") - _vec4Properties.insert(prop); - else if (className == "OptionProperty") - _optionProperties.insert(prop); - else if (className == "TriggerProperty") - _triggerProperties.insert(prop); - else if (className == "SelectionProperty") - _selectionProperties.insert(prop); - else { - LWARNING("Class name '" << className << "' not handled in GUI generation"); - return; - } - - std::string fullyQualifiedId = prop->fullyQualifiedIdentifier(); - size_t pos = fullyQualifiedId.find('.'); - std::string owner = fullyQualifiedId.substr(0, pos); - - auto it = _propertiesByOwner.find(owner); - if (it == _propertiesByOwner.end()){ - _propertiesByOwner[owner] = { prop }; - } else { - std::vector::iterator position = std::find(it->second.begin(), it->second.end(), sibling); - if (position != it->second.end()){ - it->second.insert(++position, prop); - } else { - it->second.push_back(prop); - } - } - +void GuiPropertyComponent::setSource(SourceFunction function) { + _function = std::move(function); } -void GuiPropertyComponent::unregisterProperty(properties::Property* prop) { - using namespace properties; - - std::string className = prop->className(); - - if (className == "BoolProperty") - _boolProperties.erase(prop); - else if (className == "IntProperty") - _intProperties.erase(prop); - else if (className == "FloatProperty") - _floatProperties.erase(prop); - else if (className == "StringProperty") - _stringProperties.erase(prop); - else if (className == "Vec2Property") - _vec2Properties.erase(prop); - else if (className == "Vec3Property") - _vec3Properties.erase(prop); - else if (className == "Vec4Property") - _vec4Properties.erase(prop); - else if (className == "OptionProperty") - _optionProperties.erase(prop); - else if (className == "TriggerProperty") - _triggerProperties.erase(prop); - else if (className == "SelectionProperty") - _selectionProperties.erase(prop); - else { - LWARNING("Class name '" << className << "' not handled in GUI generation"); - return; - } - - std::string fullyQualifiedId = prop->fullyQualifiedIdentifier(); - size_t pos = fullyQualifiedId.find('.'); - std::string owner = fullyQualifiedId.substr(0, pos); - - auto it = _propertiesByOwner.find(owner); - if (it == _propertiesByOwner.end()){ - LWARNING("Cannot find owner for " + className); - } - else{ - std::vector::iterator position = std::find(it->second.begin(), it->second.end(), prop); - if (position != it->second.end()) - it->second.erase(position); - } -} - -void GuiPropertyComponent::unregisterProperties(std::string owner){ - auto it = _propertiesByOwner.find(owner); - if(it != _propertiesByOwner.end()){ - for(auto prop : it->second){ - std::string className = prop->className(); - if (className == "BoolProperty") - _boolProperties.erase(prop); - else if (className == "IntProperty") - _intProperties.erase(prop); - else if (className == "FloatProperty") - _floatProperties.erase(prop); - else if (className == "StringProperty") - _stringProperties.erase(prop); - else if (className == "Vec2Property") - _vec2Properties.erase(prop); - else if (className == "Vec3Property") - _vec3Properties.erase(prop); - else if (className == "Vec4Property") - _vec4Properties.erase(prop); - else if (className == "OptionProperty") - _optionProperties.erase(prop); - else if (className == "TriggerProperty") - _triggerProperties.erase(prop); - else if (className == "SelectionProperty") - _selectionProperties.erase(prop); - } - it->second.clear(); - _propertiesByOwner.erase(it); - } -} +//void GuiPropertyComponent::registerPropertyOwner(properties::PropertyOwner* owner) { +// _owners.push_back(owner); +//} +// +//void GuiPropertyComponent::unregisterPropertyOwner(properties::PropertyOwner* owner) { +// _owners.erase(std::find(_owners.begin(), _owners.end(), owner)); +//} void GuiPropertyComponent::render() { ImGui::Begin("Properties", &_isEnabled, size, 0.5f); ImGui::Spacing(); - for (const auto& p : _propertiesByOwner) { - auto header = [&]() -> bool { - if (_propertiesByOwner.size() > 1) { - // Create a header in case we have multiple owners - return ImGui::CollapsingHeader(p.first.c_str()); - } - else { - // Otherwise, do nothing - ImGui::Text(p.first.c_str()); - ImGui::Spacing(); - return true; - } - }; + if (_function) { + const std::vector& owners = _function(); - if (header()) { - for (properties::Property* prop : p.second) { - if (_boolProperties.find(prop) != _boolProperties.end()) { - renderBoolProperty(prop, p.first); - continue; + for (properties::PropertyOwner* pOwner : owners) { + auto header = [&]() -> bool { + if (owners.size() > 1) { + // Create a header in case we have multiple owners + return ImGui::CollapsingHeader(pOwner->name().c_str()); } - - if (_intProperties.find(prop) != _intProperties.end()) { - renderIntProperty(prop, p.first); - continue; + else { + // Otherwise, do nothing + ImGui::Text(pOwner->name().c_str()); + ImGui::Spacing(); + return true; } + }; - if (_floatProperties.find(prop) != _floatProperties.end()) { - renderFloatProperty(prop, p.first); - continue; - } - - if (_vec2Properties.find(prop) != _vec2Properties.end()) { - renderVec2Property(prop, p.first); - continue; - } - - if (_vec3Properties.find(prop) != _vec3Properties.end()) { - renderVec3Property(prop, p.first); - continue; - } - - if (_vec4Properties.find(prop) != _vec4Properties.end()) { - renderVec4Property(prop, p.first); - continue; - } - - if (_optionProperties.find(prop) != _optionProperties.end()) { - renderOptionProperty(prop, p.first); - continue; - } - - if (_triggerProperties.find(prop) != _triggerProperties.end()) { - renderTriggerProperty(prop, p.first); - continue; - } - - if (_selectionProperties.find(prop) != _selectionProperties.end()) { - renderSelectionProperty(prop, p.first); - continue; - } - - if (_stringProperties.find(prop) != _stringProperties.end()) { - renderStringProperty(prop, p.first); - continue; + if (header()) { + for (properties::Property* prop : pOwner->propertiesRecursive()) { + if (prop->isVisible()) + renderProperty(prop, pOwner); } } } @@ -250,53 +94,24 @@ void GuiPropertyComponent::render() { ImGui::End(); } -GuiPropertyComponent::PropertyType GuiPropertyComponent::toPropertyType( - const std::string& name) const -{ - if (name == "BoolProperty") - return PropertyType::BoolProperty; - if (name == "IntProperty") - return PropertyType::IntProperty; - if (name == "FloatProperty") - return PropertyType::FloatProperty; - if (name == "Vec2Property") - return PropertyType::Vec2Property; - if (name == "Vec3Property") - return PropertyType::Vec3Property; - if (name == "StringProperty") - return PropertyType::StringProperty; - if (name == "OptionProperty") - return PropertyType::OptionProperty; - if (name == "SelectionProperty") - return PropertyType::SelectionProperty; - if (name == "TriggerProperty") - return PropertyType::TriggerProperty; - - LWARNING("Unsupported property type '" << name << "'"); - return PropertyType::InvalidPropertyType; -} - -void GuiPropertyComponent::renderProperty(const PropertyInfo& info) const { - switch (info.type) { - case PropertyType::BoolProperty: - { - // BoolProperty* p = static_cast(prop); - // std::string name = p->guiName(); - - // BoolProperty::ValueType value = *p; - // ImGui::Checkbox((ownerName + "." + name).c_str(), &value); - // p->set(value); - - - - - break; - } - default: - LERROR("Missing case statement: {" << int(info.type) << "," << info.identifier << "}"); - //ghoul_assert(false, "Missing case statement"); - } +void GuiPropertyComponent::renderProperty(properties::Property* prop, properties::PropertyOwner* owner) { + using Func = std::function; + static std::map FunctionMapping = { + { "BoolProperty", &renderBoolProperty }, + { "IntProperty", &renderIntProperty }, + { "FloatProperty", &renderFloatProperty }, + { "Vec2Property", &renderVec2Property }, + { "Vec3Property", &renderVec3Property }, + { "Vec4Property", &renderVec4Property }, + { "StringProperty", &renderStringProperty }, + { "OptionProperty", &renderOptionProperty }, + { "TriggerProperty", &renderTriggerProperty }, + { "SelectionProperty", &renderSelectionProperty } + }; + auto it = FunctionMapping.find(prop->className()); + if (it != FunctionMapping.end()) + it->second(prop, owner->name()); } } // gui diff --git a/modules/onscreengui/src/renderproperties.cpp b/modules/onscreengui/src/renderproperties.cpp index 0f8f0b9901..c594c43f2b 100644 --- a/modules/onscreengui/src/renderproperties.cpp +++ b/modules/onscreengui/src/renderproperties.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include #include #include @@ -38,187 +40,189 @@ #include "imgui.h" -using namespace openspace::properties; +namespace openspace { - void executeScript(const std::string& id, const std::string& value) { - std::string script = - "openspace.setPropertyValue('" + id + "', " + value + ");"; - OsEng.scriptEngine().queueScript(script); +using namespace properties; + +void executeScript(const std::string& id, const std::string& value) { + std::string script = + "openspace.setPropertyValue('" + id + "', " + value + ");"; + OsEng.scriptEngine().queueScript(script); +} + +void renderBoolProperty(Property* prop, const std::string& ownerName) { + BoolProperty* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); + + BoolProperty::ValueType value = *p; + ImGui::Checkbox(name.c_str(), &value); + + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), value ? "true" : "false"); + ImGui::PopID(); +} + +void renderOptionProperty(Property* prop, const std::string& ownerName) { + OptionProperty* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); + + int value = *p; + std::vector options = p->options(); + for (const OptionProperty::Option& o : options) { + ImGui::RadioButton(name.c_str(), &value, o.value); + ImGui::SameLine(); + ImGui::Text(o.description.c_str()); } + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), std::to_string(value)); + ImGui::PopID(); +} - void renderBoolProperty(Property* prop, const std::string& ownerName) { - BoolProperty* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); +void renderSelectionProperty(Property* prop, const std::string& ownerName) { + SelectionProperty* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - BoolProperty::ValueType value = *p; - ImGui::Checkbox(name.c_str(), &value); + if (ImGui::CollapsingHeader(name.c_str())) { + const std::vector& options = p->options(); + std::vector newSelectedIndices; - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), value ? "true": "false"); - ImGui::PopID(); - } + std::vector selectedIndices = p->value(); - void renderOptionProperty(Property* prop, const std::string& ownerName) { - OptionProperty* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); + for (int i = 0; i < options.size(); ++i) { + std::string description = options[i].description; + bool selected = std::find(selectedIndices.begin(), selectedIndices.end(), i) != selectedIndices.end(); + ImGui::Checkbox(description.c_str(), &selected); - int value = *p; - std::vector options = p->options(); - for (const OptionProperty::Option& o : options) { - ImGui::RadioButton(name.c_str(), &value, o.value); - ImGui::SameLine(); - ImGui::Text(o.description.c_str()); + if (selected) + newSelectedIndices.push_back(i); } - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), std::to_string(value)); - ImGui::PopID(); - } - void renderSelectionProperty(Property* prop, const std::string& ownerName) { - SelectionProperty* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); - - if (ImGui::CollapsingHeader(name.c_str())) { - const std::vector& options = p->options(); - std::vector newSelectedIndices; - - std::vector selectedIndices = p->value(); - - for (int i = 0; i < options.size(); ++i) { - std::string description = options[i].description; - bool selected = std::find(selectedIndices.begin(), selectedIndices.end(), i) != selectedIndices.end(); - ImGui::Checkbox(description.c_str(), &selected); - - if (selected) - newSelectedIndices.push_back(i); - } - - if (newSelectedIndices != p->value()) { - std::string parameters = "{"; - for (int i : newSelectedIndices) - parameters += std::to_string(i) + ","; - parameters += "}"; - executeScript(p->fullyQualifiedIdentifier(), parameters); - } + if (newSelectedIndices != p->value()) { + std::string parameters = "{"; + for (int i : newSelectedIndices) + parameters += std::to_string(i) + ","; + parameters += "}"; + executeScript(p->fullyQualifiedIdentifier(), parameters); } - ImGui::PopID(); } + ImGui::PopID(); +} - void renderStringProperty(Property* prop, const std::string& ownerName) { - StringProperty* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); +void renderStringProperty(Property* prop, const std::string& ownerName) { + StringProperty* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - static const int bufferSize = 256; - static char buffer[bufferSize]; + static const int bufferSize = 256; + static char buffer[bufferSize]; #ifdef _MSC_VER - strcpy_s(buffer, p->value().length() + 1, p->value().c_str()); + strcpy_s(buffer, p->value().length() + 1, p->value().c_str()); #else - strcpy(buffer, p->value().c_str()); + strcpy(buffer, p->value().c_str()); #endif - ImGui::InputText(name.c_str(), buffer, bufferSize); - std::string newValue(buffer); + ImGui::InputText(name.c_str(), buffer, bufferSize); + std::string newValue(buffer); - if (newValue != p->value() && FileSys.fileExists(newValue)) - executeScript(p->fullyQualifiedIdentifier(), "'" + newValue + "'"); + if (newValue != p->value() && FileSys.fileExists(newValue)) + executeScript(p->fullyQualifiedIdentifier(), "'" + newValue + "'"); - ImGui::PopID(); - } + ImGui::PopID(); +} - void renderIntProperty(Property* prop, const std::string& ownerName) { - IntProperty* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); +void renderIntProperty(Property* prop, const std::string& ownerName) { + IntProperty* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - IntProperty::ValueType value = *p; - ImGui::SliderInt(name.c_str(), &value, p->minValue(), p->maxValue()); + IntProperty::ValueType value = *p; + ImGui::SliderInt(name.c_str(), &value, p->minValue(), p->maxValue()); - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), std::to_string(value)); - - ImGui::PopID(); - } + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), std::to_string(value)); - void renderFloatProperty(Property* prop, const std::string& ownerName) { - FloatProperty* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); + ImGui::PopID(); +} - FloatProperty::ValueType value = *p; - ImGui::SliderFloat(name.c_str(), &value, p->minValue(), p->maxValue()); +void renderFloatProperty(Property* prop, const std::string& ownerName) { + FloatProperty* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), std::to_string(value)); - - ImGui::PopID(); - } + FloatProperty::ValueType value = *p; + ImGui::SliderFloat(name.c_str(), &value, p->minValue(), p->maxValue()); - void renderVec2Property(Property* prop, const std::string& ownerName) { - Vec2Property* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), std::to_string(value)); - Vec2Property::ValueType value = *p; + ImGui::PopID(); +} - ImGui::SliderFloat2(name.c_str(), &value.x, std::min(p->minValue().x, p->minValue().y), std::max(p->maxValue().x, p->maxValue().y)); +void renderVec2Property(Property* prop, const std::string& ownerName) { + Vec2Property* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), - "{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}"); - - ImGui::PopID(); - } + Vec2Property::ValueType value = *p; - void renderVec3Property(Property* prop, const std::string& ownerName) { - Vec3Property* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); + ImGui::SliderFloat2(name.c_str(), &value.x, std::min(p->minValue().x, p->minValue().y), std::max(p->maxValue().x, p->maxValue().y)); - Vec3Property::ValueType value = *p; + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), + "{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}"); - ImGui::SliderFloat3(name.c_str(), &value.x, p->minValue().x, p->maxValue().x); + ImGui::PopID(); +} - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), - "{" + std::to_string(value.x) + "," + - std::to_string(value.y) + "," + - std::to_string(value.z) + "}"); - - ImGui::PopID(); - } +void renderVec3Property(Property* prop, const std::string& ownerName) { + Vec3Property* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - void renderVec4Property(Property* prop, const std::string& ownerName) { - Vec4Property* p = static_cast(prop); - std::string name = p->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); + Vec3Property::ValueType value = *p; - Vec4Property::ValueType value = *p; + ImGui::SliderFloat3(name.c_str(), &value.x, p->minValue().x, p->maxValue().x); - ImGui::SliderFloat4(name.c_str(), &value.x, p->minValue().x, p->maxValue().x); + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), + "{" + std::to_string(value.x) + "," + + std::to_string(value.y) + "," + + std::to_string(value.z) + "}"); - if (value != p->value()) - executeScript(p->fullyQualifiedIdentifier(), - "{" + std::to_string(value.x) + "," + - std::to_string(value.y) + "," + - std::to_string(value.z) + "," + - std::to_string(value.w) + "}"); + ImGui::PopID(); +} - ImGui::PopID(); - } +void renderVec4Property(Property* prop, const std::string& ownerName) { + Vec4Property* p = static_cast(prop); + std::string name = p->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); - void renderTriggerProperty(Property* prop, const std::string& ownerName) { - std::string name = prop->guiName(); - ImGui::PushID((ownerName + "." + name).c_str()); + Vec4Property::ValueType value = *p; - bool pressed = ImGui::Button(name.c_str()); - if (pressed) - executeScript(prop->fullyQualifiedIdentifier(), "nil"); - - ImGui::PopID(); - } + ImGui::SliderFloat4(name.c_str(), &value.x, p->minValue().x, p->maxValue().x); + + if (value != p->value()) + executeScript(p->fullyQualifiedIdentifier(), + "{" + std::to_string(value.x) + "," + + std::to_string(value.y) + "," + + std::to_string(value.z) + "," + + std::to_string(value.w) + "}"); + + ImGui::PopID(); +} + +void renderTriggerProperty(Property* prop, const std::string& ownerName) { + std::string name = prop->guiName(); + ImGui::PushID((ownerName + "." + name).c_str()); + + bool pressed = ImGui::Button(name.c_str()); + if (pressed) + executeScript(prop->fullyQualifiedIdentifier(), "nil"); + + ImGui::PopID(); +} //void renderBoolProperty(Property* prop, const std::string& ownerName) { // BoolProperty* p = static_cast(prop); @@ -310,4 +314,6 @@ using namespace openspace::properties; // bool pressed = ImGui::Button(name.c_str()); // if (pressed) // prop->set(0); -//} \ No newline at end of file +//} + +} // namespace openspace \ No newline at end of file diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index ba4cf1e8c7..09edbe3fab 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -437,8 +437,29 @@ bool OpenSpaceEngine::initialize() { #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED LINFO("Initializing GUI"); _gui->initialize(); - for (properties::Property* p : _settingsEngine->propertiesRecursive()) - _gui->_globalProperty.registerProperty(p); + _gui->_globalProperty.setSource( + [&]() { + std::vector res = { _settingsEngine.get() }; + return res; + } + ); + + OsEng.gui()._screenSpaceProperty.setSource( + [&]() { + auto& ssr = renderEngine().screenSpaceRenderables(); + return std::vector(ssr.begin(), ssr.end()); + } + ); + + OsEng.gui()._property.setSource( + [&]() { + auto& nodes = renderEngine().scene()->allSceneGraphNodes(); + return std::vector(nodes.begin(), nodes.end()); + } + ); + + + #endif #ifdef OPENSPACE_MODULE_ISWA_ENABLED diff --git a/src/properties/property.cpp b/src/properties/property.cpp index 4bf82fd209..305624c7bd 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -136,6 +136,12 @@ void Property::setVisible(bool state) { _metaData.setValue(_metaDataKeyVisible, state); } +bool Property::isVisible() const { + bool visible = true; + _metaData.getValue(_metaDataKeyVisible, visible); + return visible; +} + void Property::setReadOnly(bool state) { _metaData.setValue(_metaDataKeyReadOnly, state); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 6226b12d4d..5ca6d5e33f 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -1155,6 +1155,17 @@ std::shared_ptr RenderEngine::screenSpaceRenderable(std:: return nullptr; } +std::vector RenderEngine::screenSpaceRenderables() const { + std::vector res(_screenSpaceRenderables.size()); + std::transform( + _screenSpaceRenderables.begin(), + _screenSpaceRenderables.end(), + res.begin(), + [](std::shared_ptr p) { return p.get(); } + ); + return res; +} + RenderEngine::RendererImplementation RenderEngine::rendererFromString(const std::string& impl) { const std::map RenderingMethods = { { "ABuffer", RendererImplementation::ABuffer }, diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index 6f405090f4..57187b38b8 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -30,8 +30,6 @@ #include #include -#include - #ifdef WIN32 #define _USE_MATH_DEFINES #include @@ -127,22 +125,10 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary // Setting spherical/euclidean onchange handler _useFlatScreen.onChange([this](){ if (_useFlatScreen) { - OsEng.gui()._screenSpaceProperty.registerProperty( - &_euclideanPosition, - &_useFlatScreen - ); addProperty(_euclideanPosition); - - OsEng.gui()._screenSpaceProperty.unregisterProperty(&_sphericalPosition); removeProperty(_sphericalPosition); } else { - OsEng.gui()._screenSpaceProperty.unregisterProperty(&_euclideanPosition); removeProperty(_euclideanPosition); - - OsEng.gui()._screenSpaceProperty.registerProperty( - &_sphericalPosition, - &_useFlatScreen - ); addProperty(_sphericalPosition); } useEuclideanCoordinates(_useFlatScreen); @@ -237,20 +223,6 @@ glm::vec2 ScreenSpaceRenderable::toSpherical(const glm::vec2& euclidean) { return glm::vec2(theta, phi); } -void ScreenSpaceRenderable::registerProperties() { - OsEng.gui()._screenSpaceProperty.registerProperty(&_enabled); - OsEng.gui()._screenSpaceProperty.registerProperty(&_useFlatScreen); - OsEng.gui()._screenSpaceProperty.registerProperty(&_euclideanPosition); - OsEng.gui()._screenSpaceProperty.registerProperty(&_depth); - OsEng.gui()._screenSpaceProperty.registerProperty(&_scale); - OsEng.gui()._screenSpaceProperty.registerProperty(&_alpha); - OsEng.gui()._screenSpaceProperty.registerProperty(&_delete); -} - -void ScreenSpaceRenderable::unregisterProperties() { - OsEng.gui()._screenSpaceProperty.unregisterProperties(name()); -} - void ScreenSpaceRenderable::createShaders() { if (!_shader) { ghoul::Dictionary dict = ghoul::Dictionary(); diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 00165bd498..f26ff0cd0f 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -103,34 +103,6 @@ void Scene::update(const UpdateData& data) { } } - //if (!ONCE) { - // ghoul::Dictionary d = { - // {"Name", std::string("Earth_Pluto")}, - // {"Parent", std::string("PlutoBarycenter")}, - // {"Renderable", ghoul::Dictionary{ - // {"Type", std::string("RenderablePlanet")}, - // {"Frame", std::string("IAU_EARTH")}, - // {"Body", std::string("EARTH")}, - // {"Geometry", ghoul::Dictionary{ - // {"Type", std::string("SimpleSphere")}, - // {"Radius", glm::vec2(6.3f, 6.0f)}, - // {"Segments", 100.0} - // }}, - // {"Textures", ghoul::Dictionary{ - // {"Type", std::string("simple")}, - // { "Color", std::string("C:/alebo68/OpenSpace/data/scene/earth/textures/earth_bluemarble.jpg") }, - // { "Night", std::string("C:/alebo68/OpenSpace/data/scene/earth/textures/earth_night.jpg")} - // }} - // }} - // }; - - // SceneGraphNode* node = SceneGraphNode::createFromDictionary(d); - // node->setParent(sceneGraphNode(d.value("Parent"))); - // node->initialize(); - // _graph.addSceneGraphNode(node); - // ONCE = true; - //} - for (SceneGraphNode* node : _graph.nodes()) { try { node->update(data); @@ -358,14 +330,6 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) { c->preSynchronization(); c->postSynchronizationPreDraw(); - - for (SceneGraphNode* node : _graph.nodes()) { - std::vector properties = node->propertiesRecursive(); - for (properties::Property* p : properties) { - OsEng.gui()._property.registerProperty(p); - } - } - // If a PropertyDocumentationFile was specified, generate it now const bool hasType = OsEng.configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentationType); const bool hasFile = OsEng.configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentationFile);