-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra_items.cpp
More file actions
55 lines (50 loc) · 1.9 KB
/
Copy pathextra_items.cpp
File metadata and controls
55 lines (50 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "extra_items.h"
MRoundRectItem::MRoundRectItem(const QRectF& rect, qreal radius, QGraphicsItem* parent, QGraphicsScene* scene):
QGraphicsPathItem(parent, scene) {
QPainterPath path;
path.addRoundedRect(rect, radius, radius);
setPath(path);
}
MRhombusItem::MRhombusItem(const QRectF& rect, QGraphicsItem* parent, QGraphicsScene* scene):
QGraphicsPolygonItem(parent, scene) {
QPolygonF poly(4);
poly[0] = QPointF(rect.center().x(), rect.top());
poly[1] = QPointF(rect.right(), rect.center().y());
poly[2] = QPointF(rect.center().x(), rect.bottom());
poly[3] = QPointF(rect.left(), rect.center().y());
setPolygon(poly);
}
MPllgramItem::MPllgramItem(const QRectF& rect, qreal slew, QGraphicsItem* parent, QGraphicsScene* scene):
QGraphicsPolygonItem(parent, scene) {
QPolygonF poly(4);
if (slew >= 0) {
poly[0] = rect.topLeft() + QPointF(slew, 0);
poly[1] = rect.topRight();
poly[2] = rect.bottomRight() - QPointF(slew, 0);
poly[3] = rect.bottomLeft();
} else {
poly[0] = rect.topLeft();
poly[1] = rect.topRight() - QPointF(slew, 0);
poly[2] = rect.bottomRight();
poly[3] = rect.bottomLeft() + QPointF(slew, 0);
}
setPolygon(poly);
}
//Protected virtual
void ElevProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent* event) {
QGraphicsProxyWidget::hoverEnterEvent(event);
QGraphicsItem* cur_item = this;
while (cur_item) {
old_z.append(QPair<QGraphicsItem*, qreal>(cur_item, cur_item->zValue()));
cur_item->setZValue(10);
cur_item = cur_item->parentItem();
}
}
//Protected virtual
void ElevProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
QGraphicsProxyWidget::hoverLeaveEvent(event);
QPair<QGraphicsItem*, qreal> cur_pair;
foreach (cur_pair, old_z) {
if (cur_pair.first) cur_pair.first->setZValue(cur_pair.second);
}
}