modeleditor: Add icon name to object outline for intersection

Change-Id: I09b65a675e4d2205d0be2b1ca1687f2ceffe4285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jochen Becher
2019-11-16 20:27:48 +01:00
parent b3ca796d97
commit e7784b592d
5 changed files with 55 additions and 0 deletions

View File

@@ -291,6 +291,18 @@ bool ClassItem::intersectShapeWithLine(const QLineF &line, QPointF *intersection
QList<QPolygonF> polygons = m_customIcon->outline();
for (int i = 0; i < polygons.size(); ++i)
polygons[i].translate(object()->pos() + object()->rect().topLeft());
if (shapeIcon().textAlignment() == qmt::StereotypeIcon::TextalignBelow) {
if (nameItem()) {
QPolygonF polygon(nameItem()->boundingRect());
polygon.translate(object()->pos() + nameItem()->pos());
polygons.append(polygon);
}
if (m_contextLabel) {
QPolygonF polygon(m_contextLabel->boundingRect());
polygon.translate(object()->pos() + m_contextLabel->pos());
polygons.append(polygon);
}
}
return GeometryUtilities::intersect(polygons, line, nullptr, intersectionPoint, intersectionLine);
}
QPolygonF polygon;

View File

@@ -164,6 +164,18 @@ bool ComponentItem::intersectShapeWithLine(const QLineF &line, QPointF *intersec
QList<QPolygonF> polygons = m_customIcon->outline();
for (int i = 0; i < polygons.size(); ++i)
polygons[i].translate(object()->pos() + object()->rect().topLeft());
if (shapeIcon().textAlignment() == qmt::StereotypeIcon::TextalignBelow) {
if (nameItem()) {
QPolygonF polygon(nameItem()->boundingRect());
polygon.translate(object()->pos() + nameItem()->pos());
polygons.append(polygon);
}
if (m_contextLabel) {
QPolygonF polygon(m_contextLabel->boundingRect());
polygon.translate(object()->pos() + m_contextLabel->pos());
polygons.append(polygon);
}
}
return GeometryUtilities::intersect(polygons, line, nullptr, intersectionPoint, intersectionLine);
}
QPolygonF polygon;

View File

@@ -126,6 +126,13 @@ bool DiagramItem::intersectShapeWithLine(const QLineF &line, QPointF *intersecti
QList<QPolygonF> polygons = m_customIcon->outline();
for (int i = 0; i < polygons.size(); ++i)
polygons[i].translate(object()->pos() + object()->rect().topLeft());
if (shapeIcon().textAlignment() == qmt::StereotypeIcon::TextalignBelow) {
if (nameItem()) {
QPolygonF polygon(nameItem()->boundingRect());
polygon.translate(object()->pos() + nameItem()->pos());
polygons.append(polygon);
}
}
return GeometryUtilities::intersect(polygons, line, nullptr, intersectionPoint, intersectionLine);
}
QPolygonF polygon;

View File

@@ -134,6 +134,18 @@ bool ItemItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionP
QList<QPolygonF> polygons = m_customIcon->outline();
for (int i = 0; i < polygons.size(); ++i)
polygons[i].translate(object()->pos() + object()->rect().topLeft());
if (shapeIcon().textAlignment() == qmt::StereotypeIcon::TextalignBelow) {
if (nameItem()) {
QPolygonF polygon(nameItem()->boundingRect());
polygon.translate(object()->pos() + nameItem()->pos());
polygons.append(polygon);
}
if (m_contextLabel) {
QPolygonF polygon(m_contextLabel->boundingRect());
polygon.translate(object()->pos() + m_contextLabel->pos());
polygons.append(polygon);
}
}
return GeometryUtilities::intersect(polygons, line, nullptr, intersectionPoint, intersectionLine);
}
QRectF rect = object()->rect();

View File

@@ -145,6 +145,18 @@ bool PackageItem::intersectShapeWithLine(const QLineF &line, QPointF *intersecti
QList<QPolygonF> polygons = m_customIcon->outline();
for (int i = 0; i < polygons.size(); ++i)
polygons[i].translate(object()->pos() + object()->rect().topLeft());
if (shapeIcon().textAlignment() == qmt::StereotypeIcon::TextalignBelow) {
if (nameItem()) {
QPolygonF polygon(nameItem()->boundingRect());
polygon.translate(object()->pos() + nameItem()->pos());
polygons.append(polygon);
}
if (m_contextLabel) {
QPolygonF polygon(m_contextLabel->boundingRect());
polygon.translate(object()->pos() + m_contextLabel->pos());
polygons.append(polygon);
}
}
return GeometryUtilities::intersect(polygons, line, nullptr, intersectionPoint, intersectionLine);
}
QPolygonF polygon;