From 081174b91dc1e1cfa74d33040a1bde9b93b9d92b Mon Sep 17 00:00:00 2001 From: Austin Blanton Date: Thu, 16 Jul 2015 15:56:53 -0400 Subject: [PATCH] Transform to decompose rect to X, Y, Width, and Height in metadata (for universal templates) --- openbr/plugins/metadata/recttokeys.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+), 0 deletions(-) create mode 100644 openbr/plugins/metadata/recttokeys.cpp diff --git a/openbr/plugins/metadata/recttokeys.cpp b/openbr/plugins/metadata/recttokeys.cpp new file mode 100644 index 0000000..0dc3f1a --- /dev/null +++ b/openbr/plugins/metadata/recttokeys.cpp @@ -0,0 +1,35 @@ +#include + +namespace br +{ + +/*! + * \ingroup transforms + * \brief Convert a rect to X, Y, Width, and Height. Handy to + * \author Austin Blanton \cite imaus10 + */ +class RectToKeysTransform : public UntrainableMetadataTransform +{ + Q_OBJECT + Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) + BR_PROPERTY(QString, key, "") + + void projectMetadata(const File &src, File &dst) const + { + dst = src; + if (src.contains(key)) { + QRectF r = src.get(key); + dst.set("Height", r.height()); + dst.set("Width", r.width()); + dst.set("X", r.left()); + dst.set("Y", r.bottom()); + } + } + +}; + +BR_REGISTER(Transform, RectToKeysTransform) + +} // namespace br + +#include "metadata/recttokeys.moc" -- libgit2 0.21.4