From 515eb7f4ee6edadf7b0ceec317ab9e39e7809116 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Mon, 29 Dec 2014 14:22:18 -0500 Subject: [PATCH] Reverted changes in Flip to maintain old functionality --- openbr/plugins/register.cpp | 78 ++++++++++++++++++++++++++++++++---------------------------------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/openbr/plugins/register.cpp b/openbr/plugins/register.cpp index 52d420b..edf5fc7 100644 --- a/openbr/plugins/register.cpp +++ b/openbr/plugins/register.cpp @@ -125,7 +125,7 @@ BR_REGISTER(Transform, AffineTransform) * \brief Flips the image about an axis. * \author Josh Klontz \cite jklontz */ -class FlipTransform : public UntrainableMetaTransform +class FlipTransform : public UntrainableTransform { Q_OBJECT Q_ENUMS(Axis) @@ -140,59 +140,45 @@ public: private: BR_PROPERTY(Axis, axis, Y) - void project(const TemplateList &src, TemplateList &dst) const + void project(const Template &src, Template &dst) const { - for (int i=0; i flippedPoints; - foreach(const QPointF &point, src[i].file.points()) { - if (axis == Y) { - flippedPoints.append(QPointF(src[i].m().cols-point.x(),point.y())); - } else if (axis == X) { - flippedPoints.append(QPointF(point.x(),src[i].m().rows-point.y())); - } else { - flippedPoints.append(QPointF(src[i].m().cols-point.x(),src[i].m().rows-point.y())); - } + flip(src, dst, axis); + + QList flippedPoints; + foreach(const QPointF &point, src.file.points()) { + if (axis == Y) { + flippedPoints.append(QPointF(src.m().cols-point.x(),point.y())); + } else if (axis == X) { + flippedPoints.append(QPointF(point.x(),src.m().rows-point.y())); + } else { + flippedPoints.append(QPointF(src.m().cols-point.x(),src.m().rows-point.y())); } + } - QList flippedRects; - foreach(const QRectF &rect, src[i].file.rects()) { - if (axis == Y) { - flippedRects.append(QRectF(src[i].m().cols-rect.right(), - rect.y(), - rect.width(), - rect.height())); - } else if (axis == X) { - flippedRects.append(QRectF(rect.x(), - src[i].m().rows-rect.bottom(), - rect.width(), - rect.height())); - } else { - flippedRects.append(QRectF(src[i].m().cols-rect.right(), - src[i].m().rows-rect.bottom(), - rect.width(), - rect.height())); - } + QList flippedRects; + foreach(const QRectF &rect, src.file.rects()) { + if (axis == Y) { + flippedRects.append(QRectF(src.m().cols-rect.right(), + rect.y(), + rect.width(), + rect.height())); + } else if (axis == X) { + flippedRects.append(QRectF(rect.x(), + src.m().rows-rect.bottom(), + rect.width(), + rect.height())); + } else { + flippedRects.append(QRectF(src.m().cols-rect.right(), + src.m().rows-rect.bottom(), + rect.width(), + rect.height())); } - - dst.last().file.setPoints(flippedPoints); - dst.last().file.setRects(flippedRects); - dst.last().file.set("Flipped",true); } - } - void project(const Template &src, Template &dst) const { - TemplateList temp; - project(TemplateList() << src, temp); - if (!temp.isEmpty()) dst = temp.first(); + dst.file.setPoints(flippedPoints); + dst.file.setRects(flippedRects); } }; - BR_REGISTER(Transform, FlipTransform) /*! -- libgit2 0.21.4