diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp
index 8434447..9c59633 100644
--- a/openbr/openbr_plugin.cpp
+++ b/openbr/openbr_plugin.cpp
@@ -717,6 +717,16 @@ void Object::load(QDataStream &stream)
init();
}
+bool Object::setPropertyRecursive(const QString & name, QVariant value)
+{
+ if (this->metaObject()->indexOfProperty(qPrintable(name)) == -1)
+ return false;
+
+ qDebug() << "Class: " << metaObject()->className() << "took property" << name;
+ setProperty(name, value);
+ return true;
+}
+
void Object::setProperty(const QString &name, QVariant value)
{
QString type;
diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h
index 639514c..70df7fe 100644
--- a/openbr/openbr_plugin.h
+++ b/openbr/openbr_plugin.h
@@ -597,6 +597,8 @@ public:
QString argument(int index) const; /*!< \brief A string value for the argument at the specified index. */
QString description() const; /*!< \brief Returns a string description of the object. */
void setProperty(const QString &name, QVariant value); /*!< \brief Overload of QObject::setProperty to handle OpenBR data types. */
+ virtual bool setPropertyRecursive(const QString & name, QVariant value); /*!< \brief Recursive version of setProperty, try to set the property on this object, or its children, returns true if successful. */
+
static QStringList parse(const QString &string, char split = ','); /*!< \brief Splits the string while respecting lexical scoping of (), [], \<\>, and {}. */
private:
diff --git a/openbr/plugins/independent.cpp b/openbr/plugins/independent.cpp
index 59c7fb5..224cbe8 100644
--- a/openbr/plugins/independent.cpp
+++ b/openbr/plugins/independent.cpp
@@ -126,6 +126,20 @@ class IndependentTransform : public MetaTransform
QList transforms;
+
+ bool setPropertyRecursive(const QString & name, QVariant value)
+ {
+ if (br::Object::setPropertyRecursive(name, value))
+ return true;
+
+ if (!transform->setPropertyRecursive(name, value))
+ return false;
+
+ for (int i=0;i < transforms.size();i++) {
+ transforms[i]->setPropertyRecursive(name, value);
+ }
+ }
+
void init()
{
transforms.clear();
diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp
index 840efdd..aeaedc6 100644
--- a/openbr/plugins/meta.cpp
+++ b/openbr/plugins/meta.cpp
@@ -493,6 +493,12 @@ class LoadStoreTransform : public MetaTransform
public:
LoadStoreTransform() : transform(NULL) {}
+ bool setPropertyRecursive(const QString & name, QVariant value)
+ {
+ if (br::Object::setPropertyRecursive(name, value))
+ return true;
+ return transform->setPropertyRecursive(name, value);
+ }
private:
void init()
{
diff --git a/openbr/plugins/openbr_internal.h b/openbr/plugins/openbr_internal.h
index 99e4dd2..9a83163 100644
--- a/openbr/plugins/openbr_internal.h
+++ b/openbr/plugins/openbr_internal.h
@@ -201,6 +201,13 @@ public:
this->trainable = transform->trainable;
}
+ bool setPropertyRecursive(const QString & name, QVariant value)
+ {
+ if (br::Object::setPropertyRecursive(name, value))
+ return true;
+
+ return transform->setPropertyRecursive(name, value);
+ }
};
/*!
@@ -293,6 +300,20 @@ public:
return output;
}
+ bool setPropertyRecursive(const QString & name, QVariant value)
+ {
+ if (br::Object::setPropertyRecursive(name, value))
+ return true;
+
+ for (int i=0; i < this->transforms.size();i++)
+ {
+ if (transforms[i]->setPropertyRecursive(name, value))
+ return true;
+ }
+ return false;
+ }
+
+
protected:
bool isTimeVarying;