21 #include <QGraphicsItem> 31 if (! item->parentItem()) {
32 qDebug() <<
"Qet::centerToParentBottom : item have not parent";
36 QPointF p = item -> parentItem() -> boundingRect().center();
37 p.ry() += item -> parentItem() -> boundingRect().height()/2;
38 p.rx() -= (item -> boundingRect().width()/2 + item->boundingRect().left());
55 if (! element_to_follow -> diagram()) {
56 qDebug() <<
"qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
60 QRectF border = element_to_follow -> diagram() -> border_and_titleblock.insideBorderRect();
61 QPointF point = element_to_follow -> sceneBoundingRect().center();
63 point.setY(border.bottom() - item_to_center -> boundingRect().height() - offset );
64 point.rx() -= (item_to_center -> boundingRect().width()/2);
71 item_to_center -> setPos(0,0);
72 item_to_center -> setRotation(0);
74 item_to_center->setPos(item_to_center->mapFromScene(point));
76 qreal rot = item_to_center->rotation();
77 QGraphicsItem *parent = item_to_center->parentItem();
79 rot += parent->rotation();
80 parent = parent->parentItem();
83 item_to_center->setRotation(item_to_center->rotation() - rot);
QRectF boundingRect() const override
bool centerToBottomDiagram(QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset)
centerToBottomDiagram Set item pos to the bottom of diagram and centered vertically to element_to_fol...
bool centerToParentBottom(QGraphicsItem *item)
centerToParentBottom Center the item at the bottom of is parent.