31 #include <QtGui/QBrush> 32 #include <QGraphicsScene> 37 QGraphicsRectItem(rect, parent),
41 this->setAcceptHoverEvents(
true);
42 this->setFlag(QGraphicsItem::ItemIsFocusable,
true);
43 this->setFlag(QGraphicsItem::ItemIsSelectable,
true);
52 this->setPen(QPen(color));
53 this->setBrush(QBrush(color));
56 QList<QGraphicsItem *> items =
placeHolder_->childItems();
59 ((QGraphicsTextItem *)items.front())->setDefaultTextColor(this->pen().color().rgb());
74 QGraphicsTextItem * text =
new QGraphicsTextItem(
placeHolder_);
75 text->setDefaultTextColor(this->pen().color().rgb());
76 QTransform t = this->transform();
77 QPolygonF rectH = this->mapToScene(this->rect());
79 for(
int a=0; a<rectH.size(); ++a)
82 QLineF ab(rectH.at(a).x(), rectH.at(a).y(), rectH.at((a+1)%4).x(), rectH.at((a+1)%4).y());
83 QLineF cb(rectH.at((a+1)%4).x(), rectH.at((a+1)%4).y(), rectH.at((a+2)%4).x(), rectH.at((a+2)%4).y());
84 float angleTmp = ab.angle(cb);
87 angleTmp = 180.0f - angleTmp;
94 text->setPlainText(tr(
100 "Angle=%11").arg(
id_)
101 .arg(t.m11()).arg(t.m12()).arg(t.m13())
102 .arg(t.m21()).arg(t.m22()).arg(t.m23())
103 .arg(t.m31()).arg(t.m32()).arg(t.m33())
109 QPen pen = this->pen();
110 this->setPen(QPen(pen.color(), pen.width()*2));
124 this->setPen(QPen(pen().color(), pen().width()/2));
131 QGraphicsRectItem::hoverEnterEvent(event);
136 if(!this->hasFocus())
140 QGraphicsRectItem::hoverEnterEvent(event);
146 QGraphicsRectItem::focusInEvent(event);
152 QGraphicsRectItem::focusOutEvent(event);
virtual void focusOutEvent(QFocusEvent *event)
void setColor(const QColor &color)
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
virtual void focusInEvent(QFocusEvent *event)
QGraphicsRectItem * placeHolder_
RectItem(int id, const QRectF &rect, QGraphicsItem *parent=0)
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)