mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-13 02:15:10 +02:00
Now using a separate class (RectC) for Coordinates rectangles
This commit is contained in:
42
src/rectc.h
Normal file
42
src/rectc.h
Normal file
@ -0,0 +1,42 @@
|
||||
#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
|
||||
{return _tl.isNull() || _br.isNull() || _tl == _br;}
|
||||
|
||||
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 normalized() const;
|
||||
|
||||
RectC operator|(const RectC &r) const;
|
||||
RectC &operator|=(const RectC &r) {*this = *this | r; return *this;}
|
||||
|
||||
void unite(const Coordinates &c);
|
||||
|
||||
private:
|
||||
Coordinates _tl, _br;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const RectC &rect);
|
||||
|
||||
#endif // RECTC_H
|
Reference in New Issue
Block a user