* Added the m_rotate_action to qetelementeditor.ui * Adding QAction to qetelementeditor.cpp and connecting it to new slot RotateElementsCommand defined in editorcommands.cpp

* Some types of elements need to specialize the setRotation method in order to behave correctly :
- PartTerminal needs to call setOrientation
- PartLine, PartRectangle and PartPolygon need a different rotation center.
This commit is contained in:
Adrien Allain
2021-09-13 20:38:39 +02:00
committed by Laurent Trinques
parent 9135099dbf
commit c640d96bca
12 changed files with 204 additions and 5 deletions

View File

@@ -30,7 +30,9 @@
*/
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
CustomElementGraphicPart(editor, parent)
{}
{
m_rot=0;
}
/**
@brief PartRectangle::~PartRectangle
@@ -169,6 +171,18 @@ void PartRectangle::setYRadius(qreal Y)
emit YRadiusChanged();
}
void PartRectangle::setRotation(qreal angle) {
QTransform rotation = QTransform().rotate(angle-m_rot);
m_rot=angle;
setRect(rotation.mapRect(m_rect));
}
qreal PartRectangle::rotation() const {
return m_rot;
}
/**
@brief PartRectangle::sceneGeometricRect
@return the minimum, margin-less rectangle this part can fit into, in scene
@@ -187,7 +201,7 @@ QRectF PartRectangle::sceneGeometricRect() const
*/
QPointF PartRectangle::sceneTopLeft() const
{
return(mapToScene(rect().topLeft()));
return(mapToScene(rect().topLeft()));
}
/**