1 /*************************************************************************** 2 * * 3 * copyright : (C) 2007 The University of Toronto * 4 * netterfield@astro.utoronto.ca * 5 * * 6 * This program is free software; you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation; either version 2 of the License, or * 9 * (at your option) any later version. * 10 * * 11 ***************************************************************************/ 12 13 #include "selectionrect.h" 14 15 #include <QDebug> 16 SelectionRect()17SelectionRect::SelectionRect() { 18 reset(); 19 } 20 21 ~SelectionRect()22SelectionRect::~SelectionRect() { 23 } 24 25 isValid() const26bool SelectionRect::isValid() const { 27 return _validFrom && _validTo && _from != _to; 28 } 29 30 setFrom(const QPointF & point)31void SelectionRect::setFrom(const QPointF& point) { 32 _from = point; 33 _validFrom = true; 34 } 35 36 setTo(const QPointF & point)37void SelectionRect::setTo(const QPointF& point) { 38 _to = point; 39 _validTo = true; 40 } 41 42 reset()43void SelectionRect::reset() { 44 _from = _to = QPointF(); 45 _validFrom = _validTo = false; 46 } 47 48 rect() const49QRectF SelectionRect::rect() const { 50 if (!isValid()) 51 return QRectF(); 52 53 return QRectF(_from, _to).normalized(); 54 } 55 56 57 // vim: ts=2 sw=2 et 58