#include "maparea.h"
#include "maplayer.h"
#include <QPainter>
#include <QDateTime>
#pragma execution_character_set("utf-8")

void LAMPMainWidget::Maparea::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{


    painter->setPen(this->pen());
    painter->setBrush(this->brush());
    double r=mLayer->resolution();
    QPolygonF scene_points;
    foreach(QPointF point,this->mkt_points){
        scene_points.append(point/r);
    }
    painter->drawPolygon(scene_points);
}

QRectF LAMPMainWidget::Maparea::boundingRect() const
{
    if(this->mkt_points.size()==0){
        return QRectF();
    }
    double r=mLayer->resolution();
    QRectF rect= this->mkt_points.boundingRect();
    return QRectF(rect.x()/r,rect.y()/r,rect.width()/r,rect.height()/r);
}

void LAMPMainWidget::Maparea::append(QPointF mkt_point)
{
    this->mkt_points.append(mkt_point);
}

QPointF &LAMPMainWidget::Maparea::lastMktpoint()
{
    return this->mkt_points.last();
}
