2019-01-31 01:46:53 +01:00
|
|
|
#ifndef AREA_H
|
|
|
|
#define AREA_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
2021-04-10 15:27:40 +02:00
|
|
|
#include "common/polygon.h"
|
2019-01-31 01:46:53 +01:00
|
|
|
|
2021-03-07 11:58:21 +01:00
|
|
|
class Area
|
2019-01-31 01:46:53 +01:00
|
|
|
{
|
|
|
|
public:
|
2020-12-02 23:58:11 +01:00
|
|
|
Area() {}
|
|
|
|
Area(const RectC &rect)
|
|
|
|
{
|
2021-04-10 15:27:40 +02:00
|
|
|
Polygon polygon(rect);
|
2021-03-07 11:58:21 +01:00
|
|
|
_polygons.reserve(1);
|
2021-04-10 15:27:40 +02:00
|
|
|
_polygons.append(polygon);
|
|
|
|
_boundingRect = polygon.boundingRect();
|
2021-03-07 11:58:21 +01:00
|
|
|
}
|
|
|
|
Area(const Polygon &polygon)
|
|
|
|
{
|
|
|
|
_polygons.reserve(1);
|
|
|
|
_polygons.append(polygon);
|
|
|
|
_boundingRect = polygon.boundingRect();
|
2020-12-02 23:58:11 +01:00
|
|
|
}
|
|
|
|
|
2021-03-07 11:58:21 +01:00
|
|
|
const QString &name() const {return _name;}
|
|
|
|
const QString &description() const {return _desc;}
|
|
|
|
const QList<Polygon> &polygons() const {return _polygons;}
|
|
|
|
const RectC &boundingRect() const {return _boundingRect;}
|
2019-01-31 01:46:53 +01:00
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
2021-03-07 11:58:21 +01:00
|
|
|
if (_polygons.isEmpty())
|
2019-01-31 01:46:53 +01:00
|
|
|
return false;
|
2021-03-07 11:58:21 +01:00
|
|
|
for (int i = 0; i < _polygons.size(); i++)
|
2021-04-10 15:27:40 +02:00
|
|
|
if (_polygons.at(i).isEmpty() || _polygons.at(i).first().size() < 3)
|
2019-01-31 01:46:53 +01:00
|
|
|
return false;
|
2021-04-10 15:27:40 +02:00
|
|
|
|
2019-01-31 01:46:53 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-07 11:58:21 +01:00
|
|
|
void append(const Polygon &polygon)
|
2019-01-31 01:46:53 +01:00
|
|
|
{
|
2021-03-07 11:58:21 +01:00
|
|
|
_polygons.append(polygon);
|
|
|
|
_boundingRect |= polygon.boundingRect();
|
2019-01-31 01:46:53 +01:00
|
|
|
}
|
|
|
|
|
2021-03-07 11:58:21 +01:00
|
|
|
void setName(const QString &name) {_name = name;}
|
|
|
|
void setDescription(const QString &desc) {_desc = desc;}
|
|
|
|
|
2019-01-31 01:46:53 +01:00
|
|
|
private:
|
2021-03-07 11:58:21 +01:00
|
|
|
QList<Polygon> _polygons;
|
2019-01-31 01:46:53 +01:00
|
|
|
QString _name;
|
|
|
|
QString _desc;
|
2021-03-07 11:58:21 +01:00
|
|
|
RectC _boundingRect;
|
2019-01-31 01:46:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AREA_H
|