1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 13:41:16 +01:00
GPXSee/src/data/area.h

53 lines
1015 B
C
Raw Normal View History

2019-01-31 01:46:53 +01:00
#ifndef AREA_H
#define AREA_H
#include <QString>
#include <QList>
#include "polygon.h"
class Area : public QList<Polygon>
{
public:
2020-12-02 23:58:11 +01:00
Area() {}
Area(const RectC &rect)
{
Polygon polygon;
QVector<Coordinates> v(4);
v[0] = Coordinates(rect.left(), rect.top());
v[1] = Coordinates(rect.right(), rect.top());
v[2] = Coordinates(rect.right(), rect.bottom());
v[3] = Coordinates(rect.left(), rect.bottom());
polygon.append(v);
append(polygon);
}
2019-01-31 01:46:53 +01:00
const QString& name() const {return _name;}
const QString& description() const {return _desc;}
void setName(const QString &name) {_name = name;}
void setDescription(const QString &desc) {_desc = desc;}
bool isValid() const
{
if (isEmpty())
return false;
for (int i = 0; i < size(); i++)
if (!at(i).isValid())
return false;
return true;
}
RectC boundingRect() const
{
RectC ret;
for (int i = 0; i < size(); i++)
ret |= at(i).boundingRect();
return ret;
}
private:
QString _name;
QString _desc;
};
#endif // AREA_H