2017-06-29 22:29:27 +02:00
|
|
|
#ifndef RECTC_H
|
|
|
|
#define RECTC_H
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QSizeF>
|
|
|
|
#include "coordinates.h"
|
|
|
|
|
|
|
|
class RectC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RectC() {}
|
|
|
|
RectC(const Coordinates &topLeft, const Coordinates &bottomRight)
|
|
|
|
: _tl(topLeft), _br(bottomRight) {}
|
|
|
|
|
|
|
|
bool isNull() const
|
2017-06-30 18:15:22 +02:00
|
|
|
{return _tl.isNull() && _br.isNull();}
|
|
|
|
bool isValid() const
|
2017-07-02 09:39:31 +02:00
|
|
|
{return (_tl.isValid() && _br.isValid() && _tl != _br);}
|
2017-06-29 22:29:27 +02:00
|
|
|
|
|
|
|
Coordinates topLeft() const {return _tl;}
|
|
|
|
Coordinates bottomRight() const {return _br;}
|
|
|
|
|
|
|
|
Coordinates center() const
|
|
|
|
{return Coordinates((_tl.lon() + _br.lon()) / 2.0,
|
|
|
|
(_tl.lat() + _br.lat()) / 2.0);}
|
|
|
|
qreal width() const {return _br.lon() - _tl.lon();}
|
|
|
|
qreal height() const {return _br.lat() - _tl.lat();}
|
|
|
|
|
|
|
|
QSizeF size() const {return QSizeF(width(), height());}
|
|
|
|
|
|
|
|
RectC operator|(const RectC &r) const;
|
|
|
|
RectC &operator|=(const RectC &r) {*this = *this | r; return *this;}
|
2018-04-02 23:27:42 +02:00
|
|
|
RectC operator&(const RectC &r) const;
|
|
|
|
RectC &operator&=(const RectC &r) {*this = *this & r; return *this;}
|
2017-06-29 22:29:27 +02:00
|
|
|
|
|
|
|
void unite(const Coordinates &c);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Coordinates _tl, _br;
|
|
|
|
};
|
|
|
|
|
2018-02-13 23:03:18 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2017-06-29 22:29:27 +02:00
|
|
|
QDebug operator<<(QDebug dbg, const RectC &rect);
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|
2017-06-29 22:29:27 +02:00
|
|
|
|
|
|
|
#endif // RECTC_H
|