#include "../misc/fixc11.h"
#include "PlotGPS.h"
#include <QPainter>

PlotGPS::PlotGPS(QWidget *parent) : QWidget(parent) {

	setMinimumWidth(32);
	setMinimumHeight(96);

}

void PlotGPS::add(const Timestamp ts, const GPSData& data) {
	(void) ts;
	this->gpsData = data;
}

void PlotGPS::paintEvent(QPaintEvent* evt) {

	(void) evt;
	QPainter p(this);

	// frame
	p.fillRect(0,0,width(),height(),QColor(255,255,255,192));
	p.setPen(Qt::black);
	p.drawRect(0,0,width()-1,height()-1);

	// turn [relative]
	const QPen pen(Qt::black);
	p.setPen(pen);
	p.drawText(4, 1*12, QString::number(gpsData.tsReceived.ms()));
	p.drawText(4, 2*12, QString::number(gpsData.lat));
	p.drawText(4, 3*12, QString::number(gpsData.lon));
	p.drawText(4, 4*12, QString::number(gpsData.alt));
	p.drawText(4, 5*12, QString::number(gpsData.accuracy));

	p.end();

}
