2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 Roi::Roi(QtCamDevice *device, QObject *parent) :
26 m_roi(new QtCamRoi(device)) {
28 QObject::connect(m_roi,
29 SIGNAL(regionsOfInterestUpdated(const QList<QRectF>&, const QRectF&, const QList<QRectF>&)),
31 SLOT(handleRegionsChanged(const QList<QRectF>&, const QRectF&, const QList<QRectF>&)));
35 delete m_roi; m_roi = 0;
39 void Roi::setEnabled(bool enabled) {
40 if (Roi::isEnabled() != enabled) {
41 m_roi->setEnabled(enabled);
42 emit enabledChanged();
46 bool Roi::isEnabled() {
47 return m_roi->isEnabled();
50 void Roi::setRegionOfInterest(const QRectF& region) {
51 m_roi->setRegionOfInterest(region);
54 void Roi::resetRegionOfInterest() {
55 m_roi->resetRegionOfInterest();
58 void Roi::handleRegionsChanged(const QList<QRectF>& regions, const QRectF& primary,
59 const QList<QRectF>& rest) {
61 QVariantList regionsList = variantList(regions);
62 QVariantList restList = variantList(rest);
63 QVariant primaryRect = QVariant::fromValue(primary);
65 emit regionsChanged(regionsList, primaryRect, restList);
68 QVariantList Roi::variantList(const QList<QRectF>& rects) {
71 foreach(const QRectF& rect, rects) {
72 list.append(QVariant::fromValue(rect));