1#include "FindSpotGraphicsItem.h"
6#include <QGraphicsScene>
8#include "MosaicGraphicsView.h"
9#include "MosaicSceneWidget.h"
14 FindSpotGraphicsItem::FindSpotGraphicsItem(QPointF center,
15 MosaicSceneWidget *boundingRectSrc) {
16 m_centerPoint =
new QPointF(center);
17 m_mosaicScene = boundingRectSrc;
21 setBrush(QBrush(Qt::red, Qt::SolidPattern));
26 FindSpotGraphicsItem::~FindSpotGraphicsItem() {
32 void FindSpotGraphicsItem::paint(QPainter *painter,
33 const QStyleOptionGraphicsItem *style,
QWidget * widget) {
34 QRectF findRect = calcRect();
36 if(rect() != findRect)
39 QGraphicsEllipseItem::paint(painter, style, widget);
43 QRectF FindSpotGraphicsItem::calcRect()
const {
47 static const int size = 8;
48 QPoint findSpotScreen =
49 m_mosaicScene->getView()->mapFromScene(*m_centerPoint);
50 QPoint findSpotTopLeftScreen =
51 findSpotScreen - QPoint(size / 2, size / 2);
53 QRect findRectScreen(findSpotTopLeftScreen, QSize(size, size));
55 m_mosaicScene->getView()->mapToScene(findRectScreen).boundingRect();
This is free and unencumbered software released into the public domain.
Namespace for the standard library.