clean some code

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5279 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-03-25 18:42:18 +00:00
parent d44ead205b
commit 37ef43b97b
6 changed files with 11 additions and 47 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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());
}
/**

View File

@@ -24,6 +24,7 @@
#include "diagramimageitem.h"
#include "diagram.h"
#include "conductor.h"
#include "qet.h"
#include <QGraphicsItem>
@@ -87,12 +88,12 @@ void RotateSelectionCommand::undo()
ConductorTextItem *cti = static_cast<ConductorTextItem *>(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<DiagramImageItem> 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<DiagramImageItem> image : m_image)