2015-10-05 01:43:48 +02:00
|
|
|
#include <QPainter>
|
|
|
|
#include "markeritem.h"
|
|
|
|
|
2015-11-25 23:58:46 +01:00
|
|
|
|
2016-10-29 10:49:28 +02:00
|
|
|
#define SIZE 8
|
|
|
|
#define WIDTH 2
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-17 01:33:02 +02:00
|
|
|
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2017-12-03 00:36:52 +01:00
|
|
|
_color = Qt::red;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QRectF MarkerItem::boundingRect() const
|
|
|
|
{
|
|
|
|
return QRectF(-SIZE/2, -SIZE/2, SIZE, SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget)
|
|
|
|
{
|
|
|
|
Q_UNUSED(option);
|
|
|
|
Q_UNUSED(widget);
|
|
|
|
|
2016-10-17 23:14:07 +02:00
|
|
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
2017-12-03 00:36:52 +01:00
|
|
|
painter->setPen(QPen(_color, WIDTH));
|
2015-10-05 01:43:48 +02:00
|
|
|
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
|
|
|
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
|
|
|
|
|
|
|
// painter->drawRect(boundingRect());
|
|
|
|
}
|
2017-12-03 00:36:52 +01:00
|
|
|
|
|
|
|
void MarkerItem::setColor(const QColor &color)
|
|
|
|
{
|
|
|
|
_color = color;
|
|
|
|
update();
|
|
|
|
}
|