[qet] [818] Il est desormais possible de pivoter les textes dynamiques des elements dans l 'editeur d'element.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 818
Author:   xavier
Date:     2009-12-20 02:59:44 +0100 (Sun, 20 Dec 2009)
Log Message:
-----------
Il est desormais possible de pivoter les textes dynamiques des elements dans l'editeur d'element.

Modified Paths:
--------------
    branches/0.3/sources/editor/parttextfield.cpp
    branches/0.3/sources/editor/parttextfield.h
    branches/0.3/sources/editor/textfieldeditor.cpp
    branches/0.3/sources/editor/textfieldeditor.h

Modified: branches/0.3/sources/editor/parttextfield.cpp
===================================================================
--- branches/0.3/sources/editor/parttextfield.cpp	2009-12-19 02:12:55 UTC (rev 817)
+++ branches/0.3/sources/editor/parttextfield.cpp	2009-12-20 01:59:44 UTC (rev 818)
@@ -29,7 +29,8 @@
 PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
 	QGraphicsTextItem(parent, scene),
 	CustomElementPart(editor),
-	follow_parent_rotations(true)
+	follow_parent_rotations(true),
+	rotation_angle_(0.0)
 {
 	setDefaultTextColor(Qt::black);
 	setFont(QETApp::diagramTextsFont());
@@ -56,6 +57,12 @@
 	
 	setFont(QETApp::diagramTextsFont(font_size));
 	setPlainText(xml_element.attribute("text"));
+	
+	qreal default_rotation_angle = 0.0;
+	if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
+		setRotationAngle(default_rotation_angle);
+	}
+	
 	setPos(
 		xml_element.attribute("x").toDouble(),
 		xml_element.attribute("y").toDouble()
@@ -75,7 +82,14 @@
 	xml_element.setAttribute("y", QString("%1").arg(pos().y()));
 	xml_element.setAttribute("text", toPlainText());
 	xml_element.setAttribute("size", font().pointSize());
-	if (follow_parent_rotations) xml_element.setAttribute("rotate", "true");
+	// angle de rotation du champ de texte
+	if (rotationAngle()) {
+		xml_element.setAttribute("rotation", QString("%1").arg(rotationAngle()));
+	}
+	// suivi (ou non) des rotations de l'element parent par le champ de texte
+	if (follow_parent_rotations) {
+		xml_element.setAttribute("rotate", "true");
+	}
 	return(xml_element);
 }
 
@@ -113,6 +127,31 @@
 }
 
 /**
+	@return l'angle de rotation de ce champ de texte
+*/
+qreal PartTextField::rotationAngle() const {
+	return(rotation_angle_);
+}
+
+/**
+	@param angle Le nouvel angle de rotation de ce champ de texte
+*/
+void PartTextField::setRotationAngle(const qreal &angle) {
+	rotation_angle_ = QET::correctAngle(angle);
+	
+	// annule toute rotation precedente
+	resetTransform();
+	
+	QPointF pos_margin = margin();
+	QTransform rotation;
+	rotation.translate(pos_margin.x(), pos_margin.y());
+	rotation.rotate(rotation_angle_);
+	rotation.translate(-pos_margin.x(), -pos_margin.y());
+	
+	QGraphicsTextItem::setTransform(rotation, true);
+}
+
+/**
 	@return true si le champ de texte suit les rotation de l'element, false
 	sinon
 */
@@ -197,6 +236,8 @@
 		setFont(QETApp::diagramTextsFont(value.toInt()));
 	} else if (property == "text") {
 		setPlainText(value.toString());
+	} else if (property == "rotation angle") {
+		setRotationAngle(value.toDouble());
 	} else if (property == "rotate") {
 		follow_parent_rotations = value.toBool();
 	}
@@ -222,6 +263,8 @@
 		return(font().pointSize());
 	} else if (property == "text") {
 		return(toPlainText());
+	} else if (property == "rotation angle") {
+		return(rotation_angle_);
 	} else if (property == "rotate") {
 		return(follow_parent_rotations);
 	}

Modified: branches/0.3/sources/editor/parttextfield.h
===================================================================
--- branches/0.3/sources/editor/parttextfield.h	2009-12-19 02:12:55 UTC (rev 817)
+++ branches/0.3/sources/editor/parttextfield.h	2009-12-20 01:59:44 UTC (rev 818)
@@ -39,6 +39,7 @@
 	// attributs
 	TextFieldEditor *infos;
 	bool follow_parent_rotations;
+	qreal rotation_angle_;
 	
 	// methodes
 	public:
@@ -55,6 +56,8 @@
 	QPointF pos() const;
 	void setPos(const QPointF &);
 	void setPos(qreal, qreal);
+	qreal rotationAngle() const;
+	void setRotationAngle(const qreal &);
 	bool followParentRotations();
 	void setFollowParentRotations(bool);
 	virtual void setProperty(const QString &, const QVariant &);

Modified: branches/0.3/sources/editor/textfieldeditor.cpp
===================================================================
--- branches/0.3/sources/editor/textfieldeditor.cpp	2009-12-19 02:12:55 UTC (rev 817)
+++ branches/0.3/sources/editor/textfieldeditor.cpp	2009-12-20 01:59:44 UTC (rev 818)
@@ -32,8 +32,12 @@
 	qle_text  = new QLineEdit();
 	font_size = new QSpinBox();
 	font_size -> setRange(0, 144);
-	rotate    = new QCheckBox(tr("Maintenir horizontal malgr\351\n les rotations de l'\351l\351ment"));
+	rotate    = new QCheckBox(tr("Ne pas subir les rotations de l'\351l\351ment parent"));
 	rotate -> setChecked(true);
+	rotation_angle_ = new QDoubleSpinBox();
+	rotation_angle_ -> setRange(-360.0, 360.0);
+	rotation_angle_ -> setSingleStep(-90.0);
+	rotation_angle_ -> setSuffix("\260");
 	
 	qle_x -> setValidator(new QDoubleValidator(qle_x));
 	qle_y -> setValidator(new QDoubleValidator(qle_y));
@@ -58,6 +62,11 @@
 	t -> addWidget(qle_text);
 	main_layout -> addLayout(t);
 	
+	QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
+	rotation_angle_layout -> addWidget(new QLabel(tr("Angle de rotation par d\351faut : ")));
+	rotation_angle_layout -> addWidget(rotation_angle_);
+	main_layout -> addLayout(rotation_angle_layout);
+	
 	QHBoxLayout *r = new QHBoxLayout();
 	r -> addWidget(rotate);
 	main_layout -> addLayout(r);
@@ -91,6 +100,8 @@
 void TextFieldEditor::updateTextFieldS() { addChangePartCommand(tr("taille"),          part, "size",   font_size -> value());       }
 /// Met a jour la taille du champ de texte et cree un objet d'annulation
 void TextFieldEditor::updateTextFieldR() { addChangePartCommand(tr("propri\351t\351"), part, "rotate", !rotate -> isChecked());     }
+/// Met a jour l'angle de rotation du champ de texte et cree un objet d'annulation
+void TextFieldEditor::updateTextFieldRotationAngle() { addChangePartCommand(tr("angle de rotation"), part, "rotation angle", rotation_angle_ -> value()); }
 
 /**
 	Met a jour le formulaire d'edition
@@ -102,6 +113,7 @@
 	qle_text  -> setText(part -> property("text").toString());
 	font_size -> setValue(part -> property("size").toInt());
 	rotate  -> setChecked(!part -> property("rotate").toBool());
+	rotation_angle_ -> setValue(part -> property("rotation angle").toInt());
 	activeConnections(true);
 }
 
@@ -116,11 +128,13 @@
 		connect(qle_text,  SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
 		connect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
 		connect(rotate,    SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
+		connect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextFieldRotationAngle()));
 	} else {
 		disconnect(qle_x,     SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
 		disconnect(qle_y,     SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
 		disconnect(qle_text,  SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
 		disconnect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
 		disconnect(rotate,    SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
+		disconnect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextFieldRotationAngle()));
 	}
 }

Modified: branches/0.3/sources/editor/textfieldeditor.h
===================================================================
--- branches/0.3/sources/editor/textfieldeditor.h	2009-12-19 02:12:55 UTC (rev 817)
+++ branches/0.3/sources/editor/textfieldeditor.h	2009-12-20 01:59:44 UTC (rev 818)
@@ -41,6 +41,7 @@
 	QLineEdit *qle_x, *qle_y, *qle_text;
 	QSpinBox *font_size;
 	QCheckBox *rotate;
+	QDoubleSpinBox *rotation_angle_;
 	
 	// methodes
 	public slots:
@@ -50,6 +51,7 @@
 	void updateTextFieldT();
 	void updateTextFieldS();
 	void updateTextFieldR();
+	void updateTextFieldRotationAngle();
 	void updateForm();
 	
 	private:


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/