mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
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:
@@ -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;
|
qreal y = Createdxf::sheetHeight - (textItem -> pos().y() * Createdxf::yScale) - fontSize;
|
||||||
QStringList lines = textItem->toPlainText().split('\n');
|
QStringList lines = textItem->toPlainText().split('\n');
|
||||||
foreach (QString line, lines) {
|
foreach (QString line, lines) {
|
||||||
qreal angle = 360 - (textItem -> rotationAngle());
|
qreal angle = 360 - (textItem -> rotation());
|
||||||
if (line.size() > 0 && line != "_" )
|
if (line.size() > 0 && line != "_" )
|
||||||
Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0 );
|
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;
|
qreal y = Createdxf::sheetHeight - (dti -> pos().y() * Createdxf::yScale) - fontSize*1.05;
|
||||||
QStringList lines = dti -> toPlainText().split('\n');
|
QStringList lines = dti -> toPlainText().split('\n');
|
||||||
foreach (QString line, lines) {
|
foreach (QString line, lines) {
|
||||||
qreal angle = 360 - (dti -> rotationAngle());
|
qreal angle = 360 - (dti -> rotation());
|
||||||
if (line.size() > 0 && line != "_" )
|
if (line.size() > 0 && line != "_" )
|
||||||
Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0);
|
Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -1278,8 +1278,8 @@ void Conductor::calculateTextItemPosition() {
|
|||||||
QPointF text_pos = posForText(rotation);
|
QPointF text_pos = posForText(rotation);
|
||||||
|
|
||||||
if (!m_text_item -> wasRotateByUser()) {
|
if (!m_text_item -> wasRotateByUser()) {
|
||||||
rotation == Qt::Vertical ? m_text_item -> setRotationAngle(m_properties.verti_rotate_text):
|
rotation == Qt::Vertical ? m_text_item -> setRotation(m_properties.verti_rotate_text):
|
||||||
m_text_item -> setRotationAngle(m_properties.horiz_rotate_text);
|
m_text_item -> setRotation(m_properties.horiz_rotate_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Adjust the position of text if his rotation
|
//Adjust the position of text if his rotation
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
* @param parent : parent item
|
* @param parent : parent item
|
||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
|
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(parent),
|
QGraphicsTextItem(parent)
|
||||||
m_rotation_angle(0.0)
|
|
||||||
{ build(); }
|
{ build(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,8 +37,7 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
|
|||||||
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) :
|
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(text, parent),
|
QGraphicsTextItem(text, parent),
|
||||||
m_mouse_hover(false),
|
m_mouse_hover(false),
|
||||||
m_previous_html_text(text),
|
m_previous_html_text(text)
|
||||||
m_rotation_angle(0.0)
|
|
||||||
{ build(); }
|
{ build(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,37 +74,6 @@ QDomElement DiagramTextItem::toXml(QDomDocument &) const {
|
|||||||
return QDomElement();
|
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
|
Traduit en coordonnees de la scene un mouvement / vecteur initialement
|
||||||
exprime en coordonnees locales.
|
exprime en coordonnees locales.
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
virtual void fromXml(const QDomElement &) = 0;
|
virtual void fromXml(const QDomElement &) = 0;
|
||||||
virtual QDomElement toXml(QDomDocument &) const;
|
virtual QDomElement toXml(QDomDocument &) const;
|
||||||
qreal rotationAngle() const;
|
|
||||||
void setRotationAngle(const qreal &);
|
|
||||||
void rotateBy(const qreal &);
|
|
||||||
void edit();
|
void edit();
|
||||||
|
|
||||||
QPointF mapMovementToScene (const QPointF &) const;
|
QPointF mapMovementToScene (const QPointF &) const;
|
||||||
@@ -100,7 +97,6 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
QString m_previous_html_text,
|
QString m_previous_html_text,
|
||||||
m_previous_text;
|
m_previous_text;
|
||||||
|
|
||||||
qreal m_rotation_angle;
|
|
||||||
QPointF m_mouse_to_origin_movement;
|
QPointF m_mouse_to_origin_movement;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ IndependentTextItem::~IndependentTextItem() {
|
|||||||
void IndependentTextItem::fromXml(const QDomElement &e) {
|
void IndependentTextItem::fromXml(const QDomElement &e) {
|
||||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||||
setHtml(e.attribute("text"));
|
setHtml(e.attribute("text"));
|
||||||
setRotationAngle(e.attribute("rotation").toDouble());
|
setRotation(e.attribute("rotation").toDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "diagramimageitem.h"
|
#include "diagramimageitem.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
|
#include "qet.h"
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
@@ -87,12 +88,12 @@ void RotateSelectionCommand::undo()
|
|||||||
ConductorTextItem *cti = static_cast<ConductorTextItem *>(text.data());
|
ConductorTextItem *cti = static_cast<ConductorTextItem *>(text.data());
|
||||||
cti->forceRotateByUser(m_rotate_by_user.value(text.data()));
|
cti->forceRotateByUser(m_rotate_by_user.value(text.data()));
|
||||||
if(cti->wasRotateByUser())
|
if(cti->wasRotateByUser())
|
||||||
cti->rotateBy(-m_angle);
|
cti->setRotation(cti->rotation() - m_angle);
|
||||||
else
|
else
|
||||||
cti->parentConductor()->calculateTextItemPosition();
|
cti->parentConductor()->calculateTextItemPosition();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
text.data()->rotateBy(-m_angle);
|
text.data()->setRotation(text.data()->rotation() - m_angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(QPointer<DiagramImageItem> image : m_image)
|
for(QPointer<DiagramImageItem> image : m_image)
|
||||||
@@ -123,7 +124,7 @@ void RotateSelectionCommand::redo()
|
|||||||
m_rotate_by_user.insert(text.data(), cti->wasRotateByUser());
|
m_rotate_by_user.insert(text.data(), cti->wasRotateByUser());
|
||||||
cti->forceRotateByUser(true);
|
cti->forceRotateByUser(true);
|
||||||
}
|
}
|
||||||
text.data()->rotateBy(m_angle);
|
text.data()->setRotation(text.data()->rotation() + m_angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(QPointer<DiagramImageItem> image : m_image)
|
for(QPointer<DiagramImageItem> image : m_image)
|
||||||
|
|||||||
Reference in New Issue
Block a user