File indexing completed on 2024-12-22 04:17:45
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include "selectionrect.h" 0014 0015 #include <QDebug> 0016 0017 SelectionRect::SelectionRect() { 0018 reset(); 0019 } 0020 0021 0022 SelectionRect::~SelectionRect() { 0023 } 0024 0025 0026 bool SelectionRect::isValid() const { 0027 return _validFrom && _validTo && _from != _to; 0028 } 0029 0030 0031 void SelectionRect::setFrom(const QPointF& point) { 0032 _from = point; 0033 _validFrom = true; 0034 } 0035 0036 0037 void SelectionRect::setTo(const QPointF& point) { 0038 _to = point; 0039 _validTo = true; 0040 } 0041 0042 0043 void SelectionRect::reset() { 0044 _from = _to = QPointF(); 0045 _validFrom = _validTo = false; 0046 } 0047 0048 0049 QRectF SelectionRect::rect() const { 0050 if (!isValid()) 0051 return QRectF(); 0052 0053 return QRectF(_from, _to).normalized(); 0054 } 0055 0056 0057 // vim: ts=2 sw=2 et