Add specific type to propertyowners

This commit is contained in:
Ylva Selling
2023-03-16 10:32:37 -04:00
parent 064825060c
commit bd5f1380c5
14 changed files with 50 additions and 22 deletions

View File

@@ -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;

View File

@@ -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<glm::dmat3>(p.rotation));
}
_matrixIsDirty = true;
_type = "StaticRotation";
}
glm::dmat3 StaticRotation::matrix(const UpdateData&) const {

View File

@@ -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<Parameters>(dictionary);
_scaleValue = p.scale;
_type = "StaticScale";
}
} // namespace openspace

View File

@@ -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<Parameters>(dictionary);
_position = p.position;
_type = "StaticTranslation";
}
glm::dvec3 StaticTranslation::position(const UpdateData&) const {

View File

@@ -48,30 +48,27 @@ namespace {
nlohmann::json json;
json["Name"] = owner->identifier();
if (dynamic_cast<SceneGraphNode*>(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::Property*>& 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::Property*>& 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);
}

View File

@@ -68,6 +68,8 @@ std::unique_ptr<DashboardItem> DashboardItem::createFromDictionary(
const std::string& dashboardType = dictionary.value<std::string>(KeyType);
DashboardItem* item = factory->create(dashboardType, std::move(dictionary));
item->_type = dashboardType;
return std::unique_ptr<DashboardItem>(item);
}

View File

@@ -148,6 +148,7 @@ ghoul::mm_unique_ptr<Renderable> Renderable::createFromDictionary(
dictionary,
&global::memoryManager->PersistentMemory
);
result->_type = renderableType;
return ghoul::mm_unique_ptr<Renderable>(result);
}

View File

@@ -236,6 +236,7 @@ std::unique_ptr<ScreenSpaceRenderable> ScreenSpaceRenderable::createFromDictiona
p.type,
dictionary
);
ssr->_type = p.type;
return std::unique_ptr<ScreenSpaceRenderable>(ssr);
}

View File

@@ -76,6 +76,7 @@ std::unique_ptr<LightSource> LightSource::createFromDictionary(
LightSource* source = factory->create(p.type, dictionary);
source->setIdentifier(p.identifier);
source->_type = p.type;
return std::unique_ptr<LightSource>(source);
}

View File

@@ -61,6 +61,7 @@ ghoul::mm_unique_ptr<Rotation> Rotation::createFromDictionary(
dictionary,
&global::memoryManager->PersistentMemory
);
result->_type = p.type;
return ghoul::mm_unique_ptr<Rotation>(result);
}

View File

@@ -61,6 +61,8 @@ ghoul::mm_unique_ptr<Scale> Scale::createFromDictionary(
&global::memoryManager->PersistentMemory
);
result->setIdentifier("Scale");
result->_type = p.type;
return ghoul::mm_unique_ptr<Scale>(result);
}

View File

@@ -494,6 +494,7 @@ ghoul::mm_unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
LDEBUG(fmt::format("Successfully created SceneGraphNode '{}'", result->identifier()));
result->_lastScreenSpaceUpdateTime = std::chrono::high_resolution_clock::now();
result->_type = "SceneGraphNode";
return result;
}

View File

@@ -57,6 +57,8 @@ ghoul::mm_unique_ptr<TimeFrame> TimeFrame::createFromDictionary(
TimeFrame* result = FactoryManager::ref().factory<TimeFrame>()->create(p.type, dict);
result->setIdentifier("TimeFrame");
result->_type = p.type;
return ghoul::mm_unique_ptr<TimeFrame>(result);
}

View File

@@ -59,6 +59,7 @@ ghoul::mm_unique_ptr<Translation> Translation::createFromDictionary(
dictionary,
&global::memoryManager->PersistentMemory
);
result->_type = p.type;
return ghoul::mm_unique_ptr<Translation>(result);
}