31 #include <QtGui/QBrush> 32 #include <QGraphicsScene> 36 KeypointItem::KeypointItem(
int id, qreal x, qreal y,
int r,
const cv::KeyPoint & kpt,
int wordID,
const QColor & color, QGraphicsItem * parent) :
37 QGraphicsEllipseItem(x, y, r, r, parent),
43 this->setPen(QPen(color));
44 this->setBrush(QBrush(color));
45 this->setAcceptHoverEvents(
true);
46 this->setFlag(QGraphicsItem::ItemIsFocusable,
true);
47 this->setFlag(QGraphicsItem::ItemIsSelectable,
true);
56 this->setPen(QPen(color));
57 this->setBrush(QBrush(color));
60 QList<QGraphicsItem *> items =
placeHolder_->childItems();
63 ((QGraphicsTextItem *)items.front())->setDefaultTextColor(this->pen().color().rgb());
74 QString info = QString(
"Keypoint = %1\n" 86 QGraphicsTextItem * text =
new QGraphicsTextItem(
placeHolder_);
87 text->setDefaultTextColor(this->pen().color().rgb());
88 text->setPlainText(info);
93 QPen pen = this->pen();
94 this->setPen(QPen(pen.color(), pen.width()+2));
106 this->setPen(QPen(pen().color(), pen().width()-2));
113 QGraphicsEllipseItem::hoverEnterEvent(event);
118 if(!this->hasFocus())
122 QGraphicsEllipseItem::hoverEnterEvent(event);
128 QGraphicsEllipseItem::focusInEvent(event);
134 QGraphicsEllipseItem::focusOutEvent(event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void setColor(const QColor &color)
virtual void focusOutEvent(QFocusEvent *event)
KeypointItem(int id, qreal x, qreal y, int r, const cv::KeyPoint &kpt, int wordID=-1, const QColor &color=Qt::green, QGraphicsItem *parent=0)
virtual void focusInEvent(QFocusEvent *event)
QGraphicsRectItem * placeHolder_