diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index d31fe8688f..8cf2470dde 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -102,6 +102,13 @@ public: */ const std::string& identifier() const; + /** + * Returns the type of this PropertyOwner. + * + * \return The type of this PropertyOwner + */ + const std::string& type() const; + /** * Sets the user-facing name of this PropertyOwner. This name does not have to be * unique, but it is recommended to be. @@ -304,6 +311,8 @@ protected: std::string _guiName; /// The description for this PropertyOwner std::string _description; + /// The type for this PropertyOwner + std::string _type; /// The owner of this PropertyOwner PropertyOwner* _owner = nullptr; diff --git a/modules/base/rotation/staticrotation.cpp b/modules/base/rotation/staticrotation.cpp index 2822eff8ca..cb0ef831f3 100644 --- a/modules/base/rotation/staticrotation.cpp +++ b/modules/base/rotation/staticrotation.cpp @@ -83,6 +83,7 @@ StaticRotation::StaticRotation() _matrixIsDirty = true; requireUpdate(); }); + _type = "StaticRotation"; } StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) : StaticRotation() { @@ -101,6 +102,7 @@ StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) : StaticRota _eulerRotation = rotationMatrixToEulerAngles(std::get(p.rotation)); } _matrixIsDirty = true; + _type = "StaticRotation"; } glm::dmat3 StaticRotation::matrix(const UpdateData&) const { diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index 4880c32849..c951c9068b 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -58,11 +58,13 @@ StaticScale::StaticScale() : _scaleValue(ScaleInfo, 1.f, 0.1f, 100.f) { _scaleValue.onChange([this]() { requireUpdate(); }); + _type = "StaticScale"; } StaticScale::StaticScale(const ghoul::Dictionary& dictionary) : StaticScale() { const Parameters p = codegen::bake(dictionary); _scaleValue = p.scale; + _type = "StaticScale"; } } // namespace openspace diff --git a/modules/base/translation/statictranslation.cpp b/modules/base/translation/statictranslation.cpp index 4af551b424..16a2007a82 100644 --- a/modules/base/translation/statictranslation.cpp +++ b/modules/base/translation/statictranslation.cpp @@ -60,6 +60,7 @@ StaticTranslation::StaticTranslation() requireUpdate(); notifyObservers(); }); + _type = "StaticTranslation"; } StaticTranslation::StaticTranslation(const ghoul::Dictionary& dictionary) @@ -67,6 +68,7 @@ StaticTranslation::StaticTranslation(const ghoul::Dictionary& dictionary) { const Parameters p = codegen::bake(dictionary); _position = p.position; + _type = "StaticTranslation"; } glm::dvec3 StaticTranslation::position(const UpdateData&) const { diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index cc00efb219..c77069c1b2 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -48,30 +48,27 @@ namespace { nlohmann::json json; json["Name"] = owner->identifier(); - if (dynamic_cast(owner)) { - json["Description"] = owner->description(); + json["Description"] = owner->description(); + json["Properties"] = nlohmann::json::array(); + json["PropertyOwners"] = nlohmann::json::array(); + json["Type"] = owner->type(); + + const std::vector& properties = owner->properties(); + for (properties::Property* p : properties) { + nlohmann::json propertyJson; + propertyJson["Name"] = p->identifier(); + propertyJson["Type"] = p->className(); + propertyJson["URI"] = p->fullyQualifiedIdentifier(); + propertyJson["Gui Name"] = p->guiName(); + propertyJson["Description"] = p->description(); + + json["Properties"].push_back(propertyJson); } - else { - json["Properties"] = nlohmann::json::array(); - json["PropertyOwners"] = nlohmann::json::array(); - const std::vector& properties = owner->properties(); - for (properties::Property* p : properties) { - nlohmann::json propertyJson; - propertyJson["Name"] = p->identifier(); - propertyJson["Type"] = p->className(); - propertyJson["URI"] = p->fullyQualifiedIdentifier(); - propertyJson["Gui Name"] = p->guiName(); - propertyJson["Description"] = p->description(); - - json["Properties"].push_back(propertyJson); - } - - auto propertyOwners = owner->propertySubOwners(); - for (properties::PropertyOwner* o : propertyOwners) { - nlohmann::json propertyOwner; - json["PropertyOwners"].push_back(createJson(o)); - } + auto propertyOwners = owner->propertySubOwners(); + for (properties::PropertyOwner* o : propertyOwners) { + nlohmann::json propertyOwner; + json["PropertyOwners"].push_back(createJson(o)); } return json; @@ -362,6 +359,10 @@ const std::string& PropertyOwner::identifier() const { return _identifier; } +const std::string& PropertyOwner::type() const { + return _type; +} + void PropertyOwner::setGuiName(std::string guiName) { _guiName = std::move(guiName); } diff --git a/src/rendering/dashboarditem.cpp b/src/rendering/dashboarditem.cpp index d941888a9d..8e60be80c1 100644 --- a/src/rendering/dashboarditem.cpp +++ b/src/rendering/dashboarditem.cpp @@ -68,6 +68,8 @@ std::unique_ptr DashboardItem::createFromDictionary( const std::string& dashboardType = dictionary.value(KeyType); DashboardItem* item = factory->create(dashboardType, std::move(dictionary)); + item->_type = dashboardType; + return std::unique_ptr(item); } diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index ccfc3dbbce..c3103dd662 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -148,6 +148,7 @@ ghoul::mm_unique_ptr Renderable::createFromDictionary( dictionary, &global::memoryManager->PersistentMemory ); + result->_type = renderableType; return ghoul::mm_unique_ptr(result); } diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index ec1c53ed18..a6302bac79 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -236,6 +236,7 @@ std::unique_ptr ScreenSpaceRenderable::createFromDictiona p.type, dictionary ); + ssr->_type = p.type; return std::unique_ptr(ssr); } diff --git a/src/scene/lightsource.cpp b/src/scene/lightsource.cpp index b20dd801c2..ddc80dbe87 100644 --- a/src/scene/lightsource.cpp +++ b/src/scene/lightsource.cpp @@ -76,6 +76,7 @@ std::unique_ptr LightSource::createFromDictionary( LightSource* source = factory->create(p.type, dictionary); source->setIdentifier(p.identifier); + source->_type = p.type; return std::unique_ptr(source); } diff --git a/src/scene/rotation.cpp b/src/scene/rotation.cpp index 0f2c55f619..b34e8e929b 100644 --- a/src/scene/rotation.cpp +++ b/src/scene/rotation.cpp @@ -61,6 +61,7 @@ ghoul::mm_unique_ptr Rotation::createFromDictionary( dictionary, &global::memoryManager->PersistentMemory ); + result->_type = p.type; return ghoul::mm_unique_ptr(result); } diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index cbc5af3bb1..1677635ecc 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -61,6 +61,8 @@ ghoul::mm_unique_ptr Scale::createFromDictionary( &global::memoryManager->PersistentMemory ); result->setIdentifier("Scale"); + result->_type = p.type; + return ghoul::mm_unique_ptr(result); } diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 2dfdd7c531..1d3792712e 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -494,6 +494,7 @@ ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( LDEBUG(fmt::format("Successfully created SceneGraphNode '{}'", result->identifier())); result->_lastScreenSpaceUpdateTime = std::chrono::high_resolution_clock::now(); + result->_type = "SceneGraphNode"; return result; } diff --git a/src/scene/timeframe.cpp b/src/scene/timeframe.cpp index 0b8d97554e..da58c24618 100644 --- a/src/scene/timeframe.cpp +++ b/src/scene/timeframe.cpp @@ -57,6 +57,8 @@ ghoul::mm_unique_ptr TimeFrame::createFromDictionary( TimeFrame* result = FactoryManager::ref().factory()->create(p.type, dict); result->setIdentifier("TimeFrame"); + result->_type = p.type; + return ghoul::mm_unique_ptr(result); } diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index d977b8cddf..a131e72774 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -59,6 +59,7 @@ ghoul::mm_unique_ptr Translation::createFromDictionary( dictionary, &global::memoryManager->PersistentMemory ); + result->_type = p.type; return ghoul::mm_unique_ptr(result); }