31 #include <QtGui/QBrush> 32 #include <QGraphicsScene> 38 QGraphicsEllipseItem(kpt.pt.
x-(kpt.size==0?3.0
f:kpt.size)/2.0
f, kpt.pt.y-(kpt.size==0?3.0
f:kpt.size)/2.0
f, kpt.size==0?3.0
f:kpt.size, kpt.size==0?3.0
f:kpt.size, parent),
45 this->setAcceptHoverEvents(
true);
46 this->setFlag(QGraphicsItem::ItemIsFocusable,
true);
57 this->setPen(QPen(color));
58 this->setBrush(QBrush(color));
67 if(qGray(pen().color().rgb()) > 255/2)
73 _placeHolder->setBrush(QBrush(QColor ( 255, 255, 255, 170 )));
75 QGraphicsTextItem * text =
new QGraphicsTextItem(
_placeHolder);
76 text->setDefaultTextColor(this->pen().color().rgb());
78 int octave =
_kpt.octave & 255;
79 octave = octave < 128 ? octave : (-128 | octave);
80 float scale = octave >= 0 ? 1.f/(1 << octave) : (
float)(1 << -octave);
83 text->setPlainText(QString(
"Id = %1\n" 90 "Scale = %9").arg(
_id).arg(
_kpt.angle).arg(
_kpt.response).arg(
_kpt.pt.x).arg(
_kpt.pt.y).arg(
_kpt.size).arg(octave).arg(scale));
94 text->setPlainText(QString(
"Id = %1\n" 102 "Depth = %10 m").arg(
_id).arg(
_kpt.angle).arg(
_kpt.response).arg(
_kpt.pt.x).arg(
_kpt.pt.y).arg(
_kpt.size).arg(octave).arg(scale).arg(
_depth));
112 QPen pen = this->pen();
113 this->setPen(QPen(pen.color(),
_width+2));
125 this->setPen(QPen(pen().color(),
_width));
130 QGraphicsScene * scene = this->scene();
131 if(scene && scene->focusItem() == 0)
137 this->setPen(QPen(pen().color(),
_width+2));
139 QGraphicsEllipseItem::hoverEnterEvent(event);
144 if(!this->hasFocus())
148 QGraphicsEllipseItem::hoverEnterEvent(event);
154 QGraphicsEllipseItem::focusInEvent(event);
160 QGraphicsEllipseItem::focusOutEvent(event);
void setColor(const QColor &color)
QGraphicsRectItem * _placeHolder
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
virtual void focusOutEvent(QFocusEvent *event)
KeypointItem(int id, const cv::KeyPoint &kpt, float depth=0, const QColor &color=Qt::green, QGraphicsItem *parent=0)
virtual void focusInEvent(QFocusEvent *event)
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
ULogger class and convenient macros.