From 37ef43b97b0c1fb30fddfe2c04af8c9cddbd1e3e Mon Sep 17 00:00:00 2001 From: blacksun Date: Sun, 25 Mar 2018 18:42:18 +0000 Subject: [PATCH] clean some code git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5279 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/exportdialog.cpp | 4 +- sources/qetgraphicsitem/conductor.cpp | 4 +- sources/qetgraphicsitem/diagramtextitem.cpp | 37 +------------------ sources/qetgraphicsitem/diagramtextitem.h | 4 -- .../qetgraphicsitem/independenttextitem.cpp | 2 +- .../undocommand/rotateselectioncommand.cpp | 7 ++-- 6 files changed, 11 insertions(+), 47 deletions(-) diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 51c46ed5c..1f2a4f25d 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -599,7 +599,7 @@ void ExportDialog::generateDxf(Diagram *diagram, int width, int height, bool kee qreal y = Createdxf::sheetHeight - (textItem -> pos().y() * Createdxf::yScale) - fontSize; QStringList lines = textItem->toPlainText().split('\n'); foreach (QString line, lines) { - qreal angle = 360 - (textItem -> rotationAngle()); + qreal angle = 360 - (textItem -> rotation()); if (line.size() > 0 && line != "_" ) Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0 ); @@ -628,7 +628,7 @@ void ExportDialog::generateDxf(Diagram *diagram, int width, int height, bool kee qreal y = Createdxf::sheetHeight - (dti -> pos().y() * Createdxf::yScale) - fontSize*1.05; QStringList lines = dti -> toPlainText().split('\n'); foreach (QString line, lines) { - qreal angle = 360 - (dti -> rotationAngle()); + qreal angle = 360 - (dti -> rotation()); if (line.size() > 0 && line != "_" ) Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0); diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index f1959bb82..934002b0a 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1278,8 +1278,8 @@ void Conductor::calculateTextItemPosition() { QPointF text_pos = posForText(rotation); if (!m_text_item -> wasRotateByUser()) { - rotation == Qt::Vertical ? m_text_item -> setRotationAngle(m_properties.verti_rotate_text): - m_text_item -> setRotationAngle(m_properties.horiz_rotate_text); + rotation == Qt::Vertical ? m_text_item -> setRotation(m_properties.verti_rotate_text): + m_text_item -> setRotation(m_properties.horiz_rotate_text); } //Adjust the position of text if his rotation diff --git a/sources/qetgraphicsitem/diagramtextitem.cpp b/sources/qetgraphicsitem/diagramtextitem.cpp index 4595f9e02..c09ca190a 100644 --- a/sources/qetgraphicsitem/diagramtextitem.cpp +++ b/sources/qetgraphicsitem/diagramtextitem.cpp @@ -26,8 +26,7 @@ * @param parent : parent item */ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) : - QGraphicsTextItem(parent), - m_rotation_angle(0.0) + QGraphicsTextItem(parent) { build(); } /** @@ -38,8 +37,7 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) : DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) : QGraphicsTextItem(text, parent), m_mouse_hover(false), - m_previous_html_text(text), - m_rotation_angle(0.0) + m_previous_html_text(text) { build(); } /** @@ -76,37 +74,6 @@ QDomElement DiagramTextItem::toXml(QDomDocument &) const { return QDomElement(); } -/** - @return l'angle de rotation actuel de ce texte -*/ -qreal DiagramTextItem::rotationAngle() const { - return(m_rotation_angle); -} - -/** - Permet de tourner le texte a un angle donne de maniere absolue. - Un angle de 0 degres correspond a un texte horizontal non retourne. - @param rotation Nouvel angle de rotation de ce texte - @see applyRotation -*/ -void DiagramTextItem::setRotationAngle(const qreal &rotation) { - qreal applied_rotation = QET::correctAngle(rotation); - applyRotation(applied_rotation - m_rotation_angle); - m_rotation_angle = applied_rotation; -} - -/** - Permet de tourner le texte de maniere relative. - L'angle added_rotation est ajoute a l'orientation actuelle du texte. - @param added_rotation Angle a ajouter a la rotation actuelle - @see applyRotation -*/ -void DiagramTextItem::rotateBy(const qreal &added_rotation) { - qreal applied_added_rotation = QET::correctAngle(added_rotation); - m_rotation_angle = QET::correctAngle(m_rotation_angle + applied_added_rotation); - applyRotation(applied_added_rotation); -} - /** Traduit en coordonnees de la scene un mouvement / vecteur initialement exprime en coordonnees locales. diff --git a/sources/qetgraphicsitem/diagramtextitem.h b/sources/qetgraphicsitem/diagramtextitem.h index 8bba7424e..8e7a6918f 100644 --- a/sources/qetgraphicsitem/diagramtextitem.h +++ b/sources/qetgraphicsitem/diagramtextitem.h @@ -54,9 +54,6 @@ class DiagramTextItem : public QGraphicsTextItem Diagram *diagram() const; virtual void fromXml(const QDomElement &) = 0; virtual QDomElement toXml(QDomDocument &) const; - qreal rotationAngle() const; - void setRotationAngle(const qreal &); - void rotateBy(const qreal &); void edit(); QPointF mapMovementToScene (const QPointF &) const; @@ -100,7 +97,6 @@ class DiagramTextItem : public QGraphicsTextItem QString m_previous_html_text, m_previous_text; - qreal m_rotation_angle; QPointF m_mouse_to_origin_movement; }; #endif diff --git a/sources/qetgraphicsitem/independenttextitem.cpp b/sources/qetgraphicsitem/independenttextitem.cpp index 9170a8b6a..d3e7c61ac 100644 --- a/sources/qetgraphicsitem/independenttextitem.cpp +++ b/sources/qetgraphicsitem/independenttextitem.cpp @@ -49,7 +49,7 @@ IndependentTextItem::~IndependentTextItem() { void IndependentTextItem::fromXml(const QDomElement &e) { setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble()); setHtml(e.attribute("text")); - setRotationAngle(e.attribute("rotation").toDouble()); + setRotation(e.attribute("rotation").toDouble()); } /** diff --git a/sources/undocommand/rotateselectioncommand.cpp b/sources/undocommand/rotateselectioncommand.cpp index d84542fc1..e2defacff 100644 --- a/sources/undocommand/rotateselectioncommand.cpp +++ b/sources/undocommand/rotateselectioncommand.cpp @@ -24,6 +24,7 @@ #include "diagramimageitem.h" #include "diagram.h" #include "conductor.h" +#include "qet.h" #include @@ -87,12 +88,12 @@ void RotateSelectionCommand::undo() ConductorTextItem *cti = static_cast(text.data()); cti->forceRotateByUser(m_rotate_by_user.value(text.data())); if(cti->wasRotateByUser()) - cti->rotateBy(-m_angle); + cti->setRotation(cti->rotation() - m_angle); else cti->parentConductor()->calculateTextItemPosition(); } else - text.data()->rotateBy(-m_angle); + text.data()->setRotation(text.data()->rotation() - m_angle); } } for(QPointer image : m_image) @@ -123,7 +124,7 @@ void RotateSelectionCommand::redo() m_rotate_by_user.insert(text.data(), cti->wasRotateByUser()); cti->forceRotateByUser(true); } - text.data()->rotateBy(m_angle); + text.data()->setRotation(text.data()->rotation() + m_angle); } } for(QPointer image : m_image)