mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 12:10:52 -06:00
Add visibility toggle to Property base class
Restructure GuiPropertyComponent to take a source function that returns a list of PropertyOwner%s instead of registering individual properties Apply restructuring
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
static Renderable* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
|
||||
// constructors & destructor
|
||||
Renderable();
|
||||
Renderable();
|
||||
Renderable(const ghoul::Dictionary& dictionary);
|
||||
virtual ~Renderable();
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
void unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
|
||||
void unregisterScreenSpaceRenderable(std::string name);
|
||||
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(std::string name);
|
||||
std::vector<ScreenSpaceRenderable*> screenSpaceRenderables() const;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
|
||||
std::string name,
|
||||
|
||||
@@ -83,9 +83,6 @@ protected:
|
||||
glm::vec2 toSpherical(const glm::vec2& euclidean);
|
||||
|
||||
|
||||
void registerProperties();
|
||||
void unregisterProperties();
|
||||
|
||||
void createShaders();
|
||||
glm::mat4 scaleMatrix();
|
||||
glm::mat4 rotationMatrix();
|
||||
|
||||
@@ -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 <modules/base/rendering/screenspaceframebuffer.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#include <openspace/util/camera.h>
|
||||
|
||||
#include <openspace/rendering/renderer.h>
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
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;
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
#include <modules/iswa/util/dataprocessortext.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
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<DataProcessorText>();
|
||||
|
||||
//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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
#include <modules/iswa/util/dataprocessorjson.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
@@ -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<DataProcessorJson>();
|
||||
//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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <modules/iswa/rendering/kameleonplane.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "IswaBaseGroup";
|
||||
using json = nlohmann::json;
|
||||
@@ -88,9 +86,6 @@ std::shared_ptr<ghoul::Event<ghoul::Dictionary> > 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/transformationmanager.h>
|
||||
#include <modules/iswa/rendering/iswabasegroup.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
|
||||
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(){
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <modules/iswa/rendering/kameleonplane.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
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()}}));
|
||||
});
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <modules/iswa/rendering/kameleonplane.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
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<int> 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){
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
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<DataProcessorKameleon>();
|
||||
|
||||
//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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <modules/onscreengui/include/guicomponent.h>
|
||||
#include <modules/onscreengui/include/guipropertycomponent.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
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;
|
||||
|
||||
@@ -27,70 +27,32 @@
|
||||
|
||||
#include <modules/onscreengui/include/guicomponent.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
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<std::vector<properties::PropertyOwner*>()>;
|
||||
|
||||
// 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<PropertyInfo> properties;
|
||||
};
|
||||
|
||||
PropertyType toPropertyType(const std::string& name) const;
|
||||
|
||||
void renderProperty(const PropertyInfo& info) const;
|
||||
|
||||
std::set<properties::Property*> _boolProperties;
|
||||
std::set<properties::Property*> _intProperties;
|
||||
std::set<properties::Property*> _floatProperties;
|
||||
std::set<properties::Property*> _vec2Properties;
|
||||
std::set<properties::Property*> _vec3Properties;
|
||||
std::set<properties::Property*> _vec4Properties;
|
||||
std::set<properties::Property*> _stringProperties;
|
||||
std::set<properties::Property*> _optionProperties;
|
||||
std::set<properties::Property*> _selectionProperties;
|
||||
std::set<properties::Property*> _triggerProperties;
|
||||
std::map<std::string, std::vector<properties::Property*>> _propertiesByOwner;
|
||||
|
||||
//std::vector<Property> _properties;
|
||||
SourceFunction _function;
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -25,22 +25,26 @@
|
||||
#ifndef __RENDERPROPERTIES_H__
|
||||
#define __RENDERPROPERTIES_H__
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/properties/property.h>
|
||||
#include <string>
|
||||
|
||||
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__
|
||||
} // namespace
|
||||
|
||||
#endif __RENDERPROPERTIES_H__
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<properties::Property*>::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<properties::Property*>::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<properties::PropertyOwner*>& 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<BoolProperty*>(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<void(properties::Property*, const std::string&)>;
|
||||
static std::map<std::string, Func> 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
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
@@ -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<BoolProperty*>(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<OptionProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
int value = *p;
|
||||
std::vector<OptionProperty::Option> 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<BoolProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
void renderSelectionProperty(Property* prop, const std::string& ownerName) {
|
||||
SelectionProperty* p = static_cast<SelectionProperty*>(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<SelectionProperty::Option>& options = p->options();
|
||||
std::vector<int> newSelectedIndices;
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(), value ? "true": "false");
|
||||
ImGui::PopID();
|
||||
}
|
||||
std::vector<int> selectedIndices = p->value();
|
||||
|
||||
void renderOptionProperty(Property* prop, const std::string& ownerName) {
|
||||
OptionProperty* p = static_cast<OptionProperty*>(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<OptionProperty::Option> 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<SelectionProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
if (ImGui::CollapsingHeader(name.c_str())) {
|
||||
const std::vector<SelectionProperty::Option>& options = p->options();
|
||||
std::vector<int> newSelectedIndices;
|
||||
|
||||
std::vector<int> 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<StringProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
void renderStringProperty(Property* prop, const std::string& ownerName) {
|
||||
StringProperty* p = static_cast<StringProperty*>(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<IntProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
void renderIntProperty(Property* prop, const std::string& ownerName) {
|
||||
IntProperty* p = static_cast<IntProperty*>(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<FloatProperty*>(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<FloatProperty*>(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<Vec2Property*>(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<Vec2Property*>(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<Vec3Property*>(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<Vec3Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
void renderVec4Property(Property* prop, const std::string& ownerName) {
|
||||
Vec4Property* p = static_cast<Vec4Property*>(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<Vec4Property*>(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<BoolProperty*>(prop);
|
||||
@@ -310,4 +314,6 @@ using namespace openspace::properties;
|
||||
// bool pressed = ImGui::Button(name.c_str());
|
||||
// if (pressed)
|
||||
// prop->set(0);
|
||||
//}
|
||||
//}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -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<properties::PropertyOwner*> res = { _settingsEngine.get() };
|
||||
return res;
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.gui()._screenSpaceProperty.setSource(
|
||||
[&]() {
|
||||
auto& ssr = renderEngine().screenSpaceRenderables();
|
||||
return std::vector<properties::PropertyOwner*>(ssr.begin(), ssr.end());
|
||||
}
|
||||
);
|
||||
|
||||
OsEng.gui()._property.setSource(
|
||||
[&]() {
|
||||
auto& nodes = renderEngine().scene()->allSceneGraphNodes();
|
||||
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1155,6 +1155,17 @@ std::shared_ptr<ScreenSpaceRenderable> RenderEngine::screenSpaceRenderable(std::
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<ScreenSpaceRenderable*> RenderEngine::screenSpaceRenderables() const {
|
||||
std::vector<ScreenSpaceRenderable*> res(_screenSpaceRenderables.size());
|
||||
std::transform(
|
||||
_screenSpaceRenderables.begin(),
|
||||
_screenSpaceRenderables.end(),
|
||||
res.begin(),
|
||||
[](std::shared_ptr<ScreenSpaceRenderable> p) { return p.get(); }
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
RenderEngine::RendererImplementation RenderEngine::rendererFromString(const std::string& impl) {
|
||||
const std::map<std::string, RenderEngine::RendererImplementation> RenderingMethods = {
|
||||
{ "ABuffer", RendererImplementation::ABuffer },
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
@@ -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();
|
||||
|
||||
@@ -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<std::string>("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::Property*> 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);
|
||||
|
||||
Reference in New Issue
Block a user