diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index ece66c7ca..a1c5f8bd7 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -613,63 +613,63 @@ void changeElementDataCommand::redo() { RotateElementsCommand::RotateElementsCommand(ElementScene *scene, QUndoCommand *parent) : ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent) { - m_items = scene->selectedItems(); + m_items = scene->selectedItems(); } /** - @brief RotateElementsCommand::undo + @brief RotateElementsCommand::undo */ void RotateElementsCommand::undo() { - for (QGraphicsItem *item : m_items) - { - if (item->type() == PartTerminal::Type) { - PartTerminal* term = qgraphicsitem_cast(item); - term->setRotation(term->rotation()-90); - } - else if (item->type() == PartRectangle::Type) { - PartRectangle* rect = qgraphicsitem_cast(item); - rect->setRotation(rect->rotation()-90); - } - else if (item->type() == PartLine::Type) { - PartLine* line = qgraphicsitem_cast(item); - line->setRotation(line->rotation()-90); - } - else if (item->type() == PartPolygon::Type) { - PartPolygon* poly = qgraphicsitem_cast(item); - poly->setRotation(poly->rotation()-90); - } - else { - item->setRotation(item->rotation()-90); - } - } + for (QGraphicsItem *item : m_items) + { + if (item->type() == PartTerminal::Type) { + PartTerminal* term = qgraphicsitem_cast(item); + term->setRotation(term->rotation()-90); + } + else if (item->type() == PartRectangle::Type) { + PartRectangle* rect = qgraphicsitem_cast(item); + rect->setRotation(rect->rotation()-90); + } + else if (item->type() == PartLine::Type) { + PartLine* line = qgraphicsitem_cast(item); + line->setRotation(line->rotation()-90); + } + else if (item->type() == PartPolygon::Type) { + PartPolygon* poly = qgraphicsitem_cast(item); + poly->setRotation(poly->rotation()-90); + } + else { + item->setRotation(item->rotation()-90); + } + } } /** - @brief RotateElementsCommand::redo + @brief RotateElementsCommand::redo */ void RotateElementsCommand::redo() { - for (QGraphicsItem *item : m_items) - { - if (item->type() == PartTerminal::Type) { - PartTerminal* term = qgraphicsitem_cast(item); - term->setRotation(term->rotation()+90); - } - else if (item->type() == PartRectangle::Type) { - PartRectangle* rect = qgraphicsitem_cast(item); - rect->setRotation(rect->rotation()+90); - } - else if (item->type() == PartLine::Type) { - PartLine* line = qgraphicsitem_cast(item); - line->setRotation(line->rotation()+90); - } - else if (item->type() == PartPolygon::Type) { - PartPolygon* poly = qgraphicsitem_cast(item); - poly->setRotation(poly->rotation()+90); - } - else { - item->setRotation(item->rotation()+90); - } - } + for (QGraphicsItem *item : m_items) + { + if (item->type() == PartTerminal::Type) { + PartTerminal* term = qgraphicsitem_cast(item); + term->setRotation(term->rotation()+90); + } + else if (item->type() == PartRectangle::Type) { + PartRectangle* rect = qgraphicsitem_cast(item); + rect->setRotation(rect->rotation()+90); + } + else if (item->type() == PartLine::Type) { + PartLine* line = qgraphicsitem_cast(item); + line->setRotation(line->rotation()+90); + } + else if (item->type() == PartPolygon::Type) { + PartPolygon* poly = qgraphicsitem_cast(item); + poly->setRotation(poly->rotation()+90); + } + else { + item->setRotation(item->rotation()+90); + } + } } diff --git a/sources/editor/graphicspart/partline.cpp b/sources/editor/graphicspart/partline.cpp index 06174badc..f420547b9 100644 --- a/sources/editor/graphicspart/partline.cpp +++ b/sources/editor/graphicspart/partline.cpp @@ -605,14 +605,14 @@ void PartLine::setSecondEndLength(const qreal &l) void PartLine::setRotation(qreal angle) { - QTransform rotation = QTransform().translate(m_line.p1().x(),m_line.p1().y()).rotate(angle-m_rot).translate(-m_line.p1().x(),-m_line.p1().y()); - m_rot=angle; + QTransform rotation = QTransform().translate(m_line.p1().x(),m_line.p1().y()).rotate(angle-m_rot).translate(-m_line.p1().x(),-m_line.p1().y()); + m_rot=angle; - setLine(rotation.map(m_line)); + setLine(rotation.map(m_line)); } qreal PartLine::rotation() const { - return m_rot; + return m_rot; } diff --git a/sources/editor/graphicspart/partline.h b/sources/editor/graphicspart/partline.h index 647df4c60..0462d3274 100644 --- a/sources/editor/graphicspart/partline.h +++ b/sources/editor/graphicspart/partline.h @@ -94,8 +94,8 @@ class PartLine : public CustomElementGraphicPart void setFirstEndLength(const qreal &l); qreal secondEndLength() const {return second_length;} void setSecondEndLength(const qreal &l); - void setRotation(qreal angle); - qreal rotation() const; + void setRotation(qreal angle); + qreal rotation() const; protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; diff --git a/sources/editor/graphicspart/partpolygon.cpp b/sources/editor/graphicspart/partpolygon.cpp index 0b7be6ee5..c89103c01 100644 --- a/sources/editor/graphicspart/partpolygon.cpp +++ b/sources/editor/graphicspart/partpolygon.cpp @@ -296,14 +296,14 @@ void PartPolygon::resetAllHandlerColor() void PartPolygon::setRotation(qreal angle) { - QTransform rotation = QTransform().translate(m_polygon.first().x(),m_polygon.first().y()).rotate(angle-m_rot).translate(-m_polygon.first().x(),-m_polygon.first().y()); - m_rot=angle; + QTransform rotation = QTransform().translate(m_polygon.first().x(),m_polygon.first().y()).rotate(angle-m_rot).translate(-m_polygon.first().x(),-m_polygon.first().y()); + m_rot=angle; - setPolygon(rotation.map(m_polygon)); + setPolygon(rotation.map(m_polygon)); } qreal PartPolygon::rotation() const { - return m_rot; + return m_rot; } diff --git a/sources/editor/graphicspart/partpolygon.h b/sources/editor/graphicspart/partpolygon.h index 2bfc72176..a68cbd36a 100644 --- a/sources/editor/graphicspart/partpolygon.h +++ b/sources/editor/graphicspart/partpolygon.h @@ -87,8 +87,8 @@ class PartPolygon : public CustomElementGraphicPart void setHandlerColor(QPointF pos, const QColor &color) final; void resetAllHandlerColor() final; - void setRotation (qreal angle); - qreal rotation () const; + void setRotation (qreal angle); + qreal rotation () const; protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; diff --git a/sources/editor/graphicspart/partrectangle.cpp b/sources/editor/graphicspart/partrectangle.cpp index 73e6020d3..148c877c4 100644 --- a/sources/editor/graphicspart/partrectangle.cpp +++ b/sources/editor/graphicspart/partrectangle.cpp @@ -173,14 +173,14 @@ void PartRectangle::setYRadius(qreal Y) void PartRectangle::setRotation(qreal angle) { - QTransform rotation = QTransform().rotate(angle-m_rot); - m_rot=angle; + QTransform rotation = QTransform().rotate(angle-m_rot); + m_rot=angle; - setRect(rotation.mapRect(m_rect)); + setRect(rotation.mapRect(m_rect)); } qreal PartRectangle::rotation() const { - return m_rot; + return m_rot; } /** diff --git a/sources/editor/graphicspart/partrectangle.h b/sources/editor/graphicspart/partrectangle.h index 64b743a56..22b04bdb3 100644 --- a/sources/editor/graphicspart/partrectangle.h +++ b/sources/editor/graphicspart/partrectangle.h @@ -71,8 +71,8 @@ class PartRectangle : public CustomElementGraphicPart void setXRadius(qreal X); qreal YRadius() const {return m_yRadius;} void setYRadius(qreal Y); - void setRotation(qreal angle); - qreal rotation() const; + void setRotation(qreal angle); + qreal rotation() const; QRectF sceneGeometricRect() const override; virtual QPointF sceneTopLeft() const; diff --git a/sources/editor/graphicspart/partterminal.cpp b/sources/editor/graphicspart/partterminal.cpp index 6a1c2d461..1c83e0045 100644 --- a/sources/editor/graphicspart/partterminal.cpp +++ b/sources/editor/graphicspart/partterminal.cpp @@ -154,28 +154,28 @@ void PartTerminal::setOrientation(Qet::Orientation ori) { } /** - Redéfinit la fonction de rotation pour la traduire en orientation de la borne - @param angle + Redefines setRotation to call setOrientation + @param angle */ void PartTerminal::setRotation(qreal angle) { - qreal angle_mod = std::fmod(angle,360); - Qet::Orientation new_ori = Qet::North; + qreal angle_mod = std::fmod(angle,360); + Qet::Orientation new_ori = Qet::North; - if (0 <= angle_mod && angle_mod < 90 ) new_ori = Qet::North; - else if (90 <= angle_mod && angle_mod < 180) new_ori = Qet::East; - else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South; - else new_ori = Qet::West; + if (0 <= angle_mod && angle_mod < 90 ) new_ori = Qet::North; + else if (90 <= angle_mod && angle_mod < 180) new_ori = Qet::East; + else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South; + else new_ori = Qet::West; - setOrientation(new_ori); + setOrientation(new_ori); } qreal PartTerminal::rotation() const { - switch (d->m_orientation) { - case Qet::North : return 0; - case Qet::East : return 90; - case Qet::South : return 180; - case Qet::West : return 270; - } + switch (d->m_orientation) { + case Qet::North : return 0; + case Qet::East : return 90; + case Qet::South : return 180; + case Qet::West : return 270; + } } /** diff --git a/sources/editor/graphicspart/partterminal.h b/sources/editor/graphicspart/partterminal.h index 5a1577c4f..3bcb25777 100644 --- a/sources/editor/graphicspart/partterminal.h +++ b/sources/editor/graphicspart/partterminal.h @@ -74,8 +74,8 @@ class PartTerminal : public CustomElementGraphicPart Qet::Orientation orientation() const {return d -> m_orientation;} void setOrientation(Qet::Orientation ori); - qreal rotation() const; - void setRotation(qreal angle); + qreal rotation() const; + void setRotation(qreal angle); QString name() const override { return d -> m_name; } diff --git a/sources/editor/ui/qetelementeditor.cpp b/sources/editor/ui/qetelementeditor.cpp index 0374e4b63..87d4cdbc7 100644 --- a/sources/editor/ui/qetelementeditor.cpp +++ b/sources/editor/ui/qetelementeditor.cpp @@ -1020,7 +1020,7 @@ void QETElementEditor::setupActions() addToolBar(Qt::TopToolBarArea, depth_toolbar); //Rotate action - connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));}); + connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));}); //Zoom action ui->m_zoom_in_action -> setShortcut(QKeySequence::ZoomIn);