UWBMarker.cpp 874 Bytes
Newer Older
tiagos's avatar
tiagos committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "UWBMarker.h"
#include <stdio.h>

UWBMarker::UWBMarker(const UWBAnchor* const anchor, QString filename, QGraphicsItem* parent) : QGraphicsSvgItem(filename)
{
	updateMarker(anchor);
	m_width = ANCHOR_WIDTH;
	m_height = ANCHOR_HEIGHT;
}

UWBMarker::~UWBMarker()
{}

void UWBMarker::updateMarker(const UWBAnchor* const anchor)
{
	m_x = anchor->x /10;
	m_y = anchor->y /10;
	m_z = anchor->z /10;

	this->setPos(m_x * FROM_METERS_TO_UNITS, -m_y * FROM_METERS_TO_UNITS);
	this->setOpacity(ANCHOR_OPACITY);
}

QRectF UWBMarker::boundingRect() const
{
    // return QRectF(-original_width/2, -original_height/2, original_width, original_height);
    return QRectF(-m_width/2, -m_height/2, m_width, m_height);
}

void UWBMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    this->renderer()->render(painter,this->boundingRect());
}