[qet] [3088] Element editor : replace home made property by Q_PROPERTY for all primitive, |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3088
Author: blacksun
Date: 2014-05-29 15:46:04 +0200 (Thu, 29 May 2014)
Log Message:
-----------
Element editor : replace home made property by Q_PROPERTY for all primitive,
Add combo box for input to set the tagg (nothing or label, actually)
Remove terminal text because unused.
Modified Paths:
--------------
trunk/sources/conductorprofile.h
trunk/sources/editor/arceditor.cpp
trunk/sources/editor/arceditor.h
trunk/sources/editor/customelementgraphicpart.cpp
trunk/sources/editor/customelementgraphicpart.h
trunk/sources/editor/customelementpart.h
trunk/sources/editor/editorcommands.cpp
trunk/sources/editor/editorcommands.h
trunk/sources/editor/elementitemeditor.cpp
trunk/sources/editor/elementitemeditor.h
trunk/sources/editor/ellipseeditor.cpp
trunk/sources/editor/ellipseeditor.h
trunk/sources/editor/lineeditor.cpp
trunk/sources/editor/lineeditor.h
trunk/sources/editor/partarc.cpp
trunk/sources/editor/partarc.h
trunk/sources/editor/partellipse.cpp
trunk/sources/editor/partellipse.h
trunk/sources/editor/partline.cpp
trunk/sources/editor/partline.h
trunk/sources/editor/partpolygon.cpp
trunk/sources/editor/partpolygon.h
trunk/sources/editor/partrectangle.cpp
trunk/sources/editor/partrectangle.h
trunk/sources/editor/partterminal.cpp
trunk/sources/editor/partterminal.h
trunk/sources/editor/parttext.cpp
trunk/sources/editor/parttext.h
trunk/sources/editor/parttextfield.cpp
trunk/sources/editor/parttextfield.h
trunk/sources/editor/rectangleeditor.cpp
trunk/sources/editor/rectangleeditor.h
trunk/sources/editor/styleeditor.cpp
trunk/sources/editor/terminaleditor.cpp
trunk/sources/editor/terminaleditor.h
trunk/sources/editor/texteditor.cpp
trunk/sources/editor/texteditor.h
trunk/sources/editor/textfieldeditor.cpp
trunk/sources/editor/textfieldeditor.h
trunk/sources/orientationset.cpp
trunk/sources/orientationset.h
trunk/sources/qet.cpp
trunk/sources/qet.h
trunk/sources/qetgraphicsitem/conductor.cpp
trunk/sources/qetgraphicsitem/conductor.h
trunk/sources/qetgraphicsitem/customelement.cpp
trunk/sources/qetgraphicsitem/ghostelement.cpp
trunk/sources/terminal.cpp
trunk/sources/terminal.h
Modified: trunk/sources/conductorprofile.h
===================================================================
--- trunk/sources/conductorprofile.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/conductorprofile.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -39,9 +39,9 @@
/// Segments composing the conductor
QList<ConductorSegmentProfile *> segments;
/// Orientation of the start terminal
- QET::Orientation beginOrientation;
+ Qet::Orientation beginOrientation;
/// Orientation of the end terminal.
- QET::Orientation endOrientation;
+ Qet::Orientation endOrientation;
// methods
public:
Modified: trunk/sources/editor/arceditor.cpp
===================================================================
--- trunk/sources/editor/arceditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/arceditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -30,19 +30,19 @@
part(arc)
{
style_ = new StyleEditor(editor);
- x = new QLineEdit();
- y = new QLineEdit();
- h = new QLineEdit();
- v = new QLineEdit();
+ x = new QDoubleSpinBox();
+ y = new QDoubleSpinBox();
+ h = new QDoubleSpinBox();
+ v = new QDoubleSpinBox();
start_angle = new QSpinBox();
angle = new QSpinBox();
start_angle -> setRange(-360, 360);
angle -> setRange(-360, 360);
- x -> setValidator(new QDoubleValidator(x));
- y -> setValidator(new QDoubleValidator(y));
- h -> setValidator(new QDoubleValidator(h));
- v -> setValidator(new QDoubleValidator(v));
+ x->setRange(-1000, 1000);
+ y->setRange(-1000, 1000);
+ h->setRange(-1000, 1000);
+ v->setRange(-1000, 1000);
QVBoxLayout *v_layout = new QVBoxLayout(this);
@@ -110,22 +110,22 @@
*/
void ArcEditor::updateArc() {
if (!part) return;
- part -> setProperty("x", x -> text().toDouble());
- part -> setProperty("y", y -> text().toDouble());
- part -> setProperty("diameter_h", h -> text().toDouble());
- part -> setProperty("diameter_v", v -> text().toDouble());
+ part -> setProperty("x", x -> value());
+ part -> setProperty("y", y -> value());
+ part -> setProperty("diameter_h", h -> value());
+ part -> setProperty("diameter_v", v -> value());
part -> setProperty("start_angle", -start_angle -> value() + 90);
part -> setProperty("angle", -angle -> value());
}
/// Met a jour l'abscisse du centre de l'arc et cree un objet d'annulation
-void ArcEditor::updateArcX() { addChangePartCommand(tr("abscisse"), part, "x", x -> text().toDouble()); }
+void ArcEditor::updateArcX() { addChangePartCommand(tr("abscisse"), part, "x", x -> value()); }
/// Met a jour l'ordonnee du centre de l'arc et cree un objet d'annulation
-void ArcEditor::updateArcY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> text().toDouble()); }
+void ArcEditor::updateArcY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> value()); }
/// Met a jour le diametre horizontal de l'arc et cree un objet d'annulation
-void ArcEditor::updateArcH() { addChangePartCommand(tr("diam\350tre horizontal"), part, "diameter_h", h -> text().toDouble()); }
+void ArcEditor::updateArcH() { addChangePartCommand(tr("diam\350tre horizontal"), part, "diameter_h", h -> value()); }
/// Met a jour le diametre vertical de l'arc et cree un objet d'annulation
-void ArcEditor::updateArcV() { addChangePartCommand(tr("diam\350tre vertical"), part, "diameter_v", v -> text().toDouble()); }
+void ArcEditor::updateArcV() { addChangePartCommand(tr("diam\350tre vertical"), part, "diameter_v", v -> value()); }
/// Met a jour l'angle de depart de l'arc et cree un objet d'annulation
void ArcEditor::updateArcS() { addChangePartCommand(tr("angle de d\351part"), part, "start_angle", -start_angle -> value() + 90); }
/// Met a jour l'etendue de l'arc et cree un objet d'annulation
@@ -137,10 +137,10 @@
void ArcEditor::updateForm() {
if (!part) return;
activeConnections(false);
- x -> setText(part -> property("x").toString());
- y -> setText(part -> property("y").toString());
- h -> setText(part -> property("diameter_h").toString());
- v -> setText(part -> property("diameter_v").toString());
+ x->setValue(part->property("x").toReal());
+ y->setValue(part->property("y").toReal());
+ h->setValue(part->property("diameter_h").toReal());
+ v->setValue(part->property("diameter_v").toReal());
start_angle -> setValue(-part -> startAngle() + 90);
angle -> setValue(-part -> angle());
activeConnections(true);
Modified: trunk/sources/editor/arceditor.h
===================================================================
--- trunk/sources/editor/arceditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/arceditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -37,7 +37,7 @@
private:
PartArc *part;
StyleEditor *style_;
- QLineEdit *x, *y, *h, *v;
+ QDoubleSpinBox *x, *y, *h, *v;
QSpinBox *angle, *start_angle;
// methods
Modified: trunk/sources/editor/customelementgraphicpart.cpp
===================================================================
--- trunk/sources/editor/customelementgraphicpart.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/customelementgraphicpart.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -178,52 +178,3 @@
painter.setPen(pen);
painter.setBrush(brush);
}
-
-/**
- Specifie la valeur d'une propriete de style donnee.
- @param property propriete a modifier. Valeurs acceptees :
- * line-style : type de trait (@see LineStyle)
- * line-weight : epaisseur du traut (@see LineWeight)
- * filling : couleur de remplissage (@see Color)
- * color : couleur du trait (@see Color)
- * antialias : utiliser l'antialiasing ou non (booleen)
- @param value Valeur a attribuer a la propriete
-*/
-void CustomElementGraphicPart::setProperty(const QString &property, const QVariant &value) {
- if (property == "line-style") {
- setLineStyle(static_cast<LineStyle>(value.toInt()));
- } else if (property == "line-weight") {
- setLineWeight(static_cast<LineWeight>(value.toInt()));
- } else if (property == "filling") {
- setFilling(static_cast<Filling>(value.toInt()));
- } else if (property == "color") {
- setColor(static_cast<Color>(value.toInt()));
- } else if (property == "antialias") {
- setAntialiased(value.toBool());
- }
-}
-
-/**
- Permet d'acceder a la valeur d'une propriete de style donnee.
- @param property propriete lue. Valeurs acceptees :
- * line-style : type de trait (@see LineStyle)
- * line-weight : epaisseur du traut (@see LineWeight)
- * filling : couleur de remplissage (@see Color)
- * color : couleur du trait (@see Color)
- * antialias : utiliser l'antialiasing ou non (booleen)
- @return La valeur de la propriete property
-*/
-QVariant CustomElementGraphicPart::property(const QString &property) {
- if (property == "line-style") {
- return(lineStyle());
- } else if (property == "line-weight") {
- return(lineWeight());
- } else if (property == "filling") {
- return(filling());
- } else if (property == "color") {
- return(color());
- } else if (property == "antialias") {
- return(antialiased());
- }
- return(QVariant());
-}
Modified: trunk/sources/editor/customelementgraphicpart.h
===================================================================
--- trunk/sources/editor/customelementgraphicpart.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/customelementgraphicpart.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -18,6 +18,7 @@
#ifndef CUSTOM_ELEMENT_GRAPHIC_PART_H
#define CUSTOM_ELEMENT_GRAPHIC_PART_H
#include <QPainter>
+#include <QObject>
#include "customelementpart.h"
#include "styleeditor.h"
class QETElementEditor;
@@ -26,9 +27,12 @@
This class represents an element visual/geometric primitive. It provides
methods to manage style attributes common to most primitives.
*/
-class CustomElementGraphicPart : public CustomElementPart {
+class CustomElementGraphicPart : public QObject, public CustomElementPart {
+ Q_OBJECT
+
public:
/// This enum lists the various line styles available to draw primitives.
+ Q_ENUMS(LineStyle)
enum LineStyle {
NormalStyle, ///< Normal line
DashedStyle, ///< Dashed line
@@ -37,6 +41,7 @@
};
/// This enum lists the various line weights available to draw primitives.
+ Q_ENUMS(LineWeight)
enum LineWeight {
NoneWeight, ///< Invisible line
ThinWeight, ///< Thin line
@@ -47,6 +52,7 @@
};
/// This enum lists the various filling colors available to draw primitives.
+ Q_ENUMS(Filling)
enum Filling {
NoneFilling, ///< No filling (i.e. transparent)
BlackFilling, ///< Black filling
@@ -57,6 +63,7 @@
};
/// This enum lists the various line colors available to draw primitives.
+ Q_ENUMS(Color)
enum Color {
BlackColor, ///< Black line
WhiteColor, ///< White line
@@ -95,101 +102,31 @@
// methods
public:
- void setLineStyle(LineStyle);
- void setLineWeight(LineWeight);
- void setFilling(Filling);
- void setColor(Color);
- void setAntialiased(bool);
+
+ /// PROPERTY
+ Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
+ LineStyle lineStyle() const {return _linestyle;}
+ void setLineStyle(const LineStyle ls) {_linestyle = ls;}
+ Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
+ LineWeight lineWeight() const {return _lineweight;}
+ void setLineWeight(const LineWeight lw) {_lineweight = lw;}
+ Q_PROPERTY(Filling filling READ filling WRITE setFilling)
+ Filling filling() const {return _filling;}
+ void setFilling(const Filling f) {_filling = f;}
+ Q_PROPERTY(Color color READ color WRITE setColor)
+ Color color() const {return _color;}
+ void setColor(const Color c) {_color = c;}
+ Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
+ bool antialiased() const {return _antialiased;}
+ void setAntialiased(const bool b) {_antialiased = b;}
- LineStyle lineStyle() const;
- LineWeight lineWeight() const;
- Filling filling() const;
- Color color() const;
- bool antialiased() const;
+ virtual void setProperty(const char *name, const QVariant &value) {QObject::setProperty(name, value);}
+ virtual QVariant property(const char *name) const {return QObject::property(name);}
- void setProperty(const QString &, const QVariant &);
- QVariant property(const QString &);
-
protected:
void stylesToXml(QDomElement &) const;
void stylesFromXml(const QDomElement &);
void resetStyles();
void applyStylesToQPainter(QPainter &) const;
};
-
-/**
- Set the primitive line style.
- @param ls the new line style
-*/
-inline void CustomElementGraphicPart::setLineStyle(LineStyle ls) {
- _linestyle = ls;
-}
-
-/**
- Set the primitive line weight.
- @param lw the new line weight
-*/
-inline void CustomElementGraphicPart::setLineWeight(LineWeight lw) {
- _lineweight = lw;
-}
-
-/**
- Set the filling color.
- @param f the new filling color
-*/
-inline void CustomElementGraphicPart::setFilling(Filling f) {
- _filling = f;
-}
-
-/**
- Set the line color.
- @param c the new line color
-*/
-inline void CustomElementGraphicPart::setColor(Color c) {
- _color = c;
-}
-
-/**
- @return the current line style
-*/
-inline CustomElementGraphicPart::LineStyle CustomElementGraphicPart::lineStyle() const {
- return(_linestyle);
-}
-
-/**
- @return the current line weight
-*/
-inline CustomElementGraphicPart::LineWeight CustomElementGraphicPart::lineWeight() const {
- return(_lineweight);
-}
-
-/**
- @return the current filling color
-*/
-inline CustomElementGraphicPart::Filling CustomElementGraphicPart::filling() const {
- return(_filling);
-}
-
-/**
- @return the current line color
-*/
-inline CustomElementGraphicPart::Color CustomElementGraphicPart::color() const {
- return(_color);
-}
-
-/**
- Set whether the primitive should be drawn antialiased.
- @param aa True to enable antialiasing, false to disable it.
-*/
-inline void CustomElementGraphicPart::setAntialiased(bool aa) {
- _antialiased = aa;
-}
-
-/**
- @return whether the primitive is drawn antialiased.
-*/
-inline bool CustomElementGraphicPart::antialiased() const {
- return(_antialiased);
-}
-
#endif
Modified: trunk/sources/editor/customelementpart.h
===================================================================
--- trunk/sources/editor/customelementpart.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/customelementpart.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -64,11 +64,11 @@
/**
Set a specific property of the primitive
*/
- virtual void setProperty(const QString &, const QVariant &) = 0;
+ virtual void setProperty(const char *name, const QVariant &value) = 0;
/**
Get the current value of a specific primitive property
*/
- virtual QVariant property(const QString &) = 0;
+ virtual QVariant property(const char *name) const = 0;
/**
@return whether the primitive appears to be useless (e.g. 0-length line)
Typically, useless primitives are discarded when saving the element.
Modified: trunk/sources/editor/editorcommands.cpp
===================================================================
--- trunk/sources/editor/editorcommands.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/editorcommands.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -315,7 +315,7 @@
ChangePartCommand::ChangePartCommand(
const QString &name,
CustomElementPart *part,
- const QString &prop,
+ const char *prop,
const QVariant &old_v,
const QVariant &new_v,
QUndoCommand *parent
Modified: trunk/sources/editor/editorcommands.h
===================================================================
--- trunk/sources/editor/editorcommands.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/editorcommands.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -176,7 +176,7 @@
class ChangePartCommand : public ElementEditionCommand {
// constructors, destructor
public:
- ChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &, const QVariant &, QUndoCommand * = 0);
+ ChangePartCommand(const QString &, CustomElementPart *, const char *, const QVariant &, const QVariant &, QUndoCommand * = 0);
virtual ~ChangePartCommand();
private:
ChangePartCommand(const ChangePartCommand &);
@@ -191,7 +191,7 @@
/// Changed primitive
CustomElementPart *cep;
/// Changed property
- QString property;
+ const char *property;
/// Former value
QVariant old_value;
/// New value
Modified: trunk/sources/editor/elementitemeditor.cpp
===================================================================
--- trunk/sources/editor/elementitemeditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/elementitemeditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -54,7 +54,7 @@
@param prop propriete modifiee
@param new_v nouvelle valeur
*/
-void ElementItemEditor::addChangePartCommand(const QString &desc, CustomElementPart *part, const QString &prop, const QVariant &new_v) {
+void ElementItemEditor::addChangePartCommand(const QString &desc, CustomElementPart *part, const char *prop, const QVariant &new_v) {
// ne fait rien si part vaut 0
if (!part) return;
Modified: trunk/sources/editor/elementitemeditor.h
===================================================================
--- trunk/sources/editor/elementitemeditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/elementitemeditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -40,7 +40,7 @@
virtual QETElementEditor *elementEditor() const;
virtual ElementScene *elementScene() const;
virtual QUndoStack &undoStack() const;
- virtual void addChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &);
+ virtual void addChangePartCommand(const QString &, CustomElementPart *, const char *, const QVariant &);
virtual QString elementTypeName() const;
virtual void setElementTypeName(const QString &);
virtual void detach();
Modified: trunk/sources/editor/ellipseeditor.cpp
===================================================================
--- trunk/sources/editor/ellipseeditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/ellipseeditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -31,15 +31,15 @@
{
style_ = new StyleEditor(editor);
- x = new QLineEdit();
- y = new QLineEdit();
- h = new QLineEdit();
- v = new QLineEdit();
+ x = new QDoubleSpinBox();
+ y = new QDoubleSpinBox();
+ h = new QDoubleSpinBox();
+ v = new QDoubleSpinBox();
- x -> setValidator(new QDoubleValidator(x));
- y -> setValidator(new QDoubleValidator(y));
- h -> setValidator(new QDoubleValidator(h));
- v -> setValidator(new QDoubleValidator(v));
+ x->setRange(-1000, 1000);
+ y->setRange(-1000, 1000);
+ h->setRange(-1000, 1000);
+ v->setRange(-1000, 1000);
QVBoxLayout *v_layout = new QVBoxLayout(this);
@@ -102,20 +102,20 @@
*/
void EllipseEditor::updateEllipse() {
if (!part) return;
- part -> setProperty("x", x -> text().toDouble());
- part -> setProperty("y", y -> text().toDouble());
- part -> setProperty("diameter_h", h -> text().toDouble());
- part -> setProperty("diameter_v", v -> text().toDouble());
+ part -> setProperty("x", x -> value());
+ part -> setProperty("y", y -> value());
+ part -> setProperty("diameter_h", h -> value());
+ part -> setProperty("diameter_v", v -> value());
}
/// Met a jour l'abscisse du centre de l'ellipse et cree un objet d'annulation
-void EllipseEditor::updateEllipseX() { addChangePartCommand(tr("abscisse"), part, "x", x -> text().toDouble()); }
+void EllipseEditor::updateEllipseX() { addChangePartCommand(tr("abscisse"), part, "x", x -> value()); }
/// Met a jour l'ordonnee du centre de l'ellipse et cree un objet d'annulation
-void EllipseEditor::updateEllipseY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> text().toDouble()); }
+void EllipseEditor::updateEllipseY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> value()); }
/// Met a jour le diametre horizontal de l'ellipse et cree un objet d'annulation
-void EllipseEditor::updateEllipseH() { addChangePartCommand(tr("diam\350tre horizontal"), part, "diameter_h", h -> text().toDouble()); }
+void EllipseEditor::updateEllipseH() { addChangePartCommand(tr("diam\350tre horizontal"), part, "diameter_h", h -> value()); }
/// Met a jour le diametre vertical de l'ellipse et cree un objet d'annulation
-void EllipseEditor::updateEllipseV() { addChangePartCommand(tr("diam\350tre vertical"), part, "diameter_v", v -> text().toDouble()); }
+void EllipseEditor::updateEllipseV() { addChangePartCommand(tr("diam\350tre vertical"), part, "diameter_v", v -> value()); }
/**
Met a jour le formulaire d'edition
@@ -123,10 +123,10 @@
void EllipseEditor::updateForm() {
if (!part) return;
activeConnections(false);
- x -> setText(part -> property("x").toString());
- y -> setText(part -> property("y").toString());
- h -> setText(part -> property("diameter_h").toString());
- v -> setText(part -> property("diameter_v").toString());
+ x->setValue(part->property("x").toReal());
+ y->setValue(part->property("y").toReal());
+ h->setValue(part->property("diameter_h").toReal());
+ v->setValue(part->property("diameter_v").toReal());
activeConnections(true);
}
Modified: trunk/sources/editor/ellipseeditor.h
===================================================================
--- trunk/sources/editor/ellipseeditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/ellipseeditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -37,7 +37,7 @@
private:
PartEllipse *part;
StyleEditor *style_;
- QLineEdit *x, *y, *h, *v;
+ QDoubleSpinBox *x, *y, *h, *v;
// methods
public:
Modified: trunk/sources/editor/lineeditor.cpp
===================================================================
--- trunk/sources/editor/lineeditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/lineeditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -33,35 +33,32 @@
{
style_ = new StyleEditor(editor);
- x1 = new QLineEdit();
- y1 = new QLineEdit();
- x2 = new QLineEdit();
- y2 = new QLineEdit();
+ x1 = new QDoubleSpinBox();
+ y1 = new QDoubleSpinBox();
+ x2 = new QDoubleSpinBox();
+ y2 = new QDoubleSpinBox();
- x1 -> setValidator(new QDoubleValidator(x1));
- y1 -> setValidator(new QDoubleValidator(y1));
- x2 -> setValidator(new QDoubleValidator(x2));
- y2 -> setValidator(new QDoubleValidator(y2));
+ x1 -> setRange(-1000, 1000);
+ y1 -> setRange(-1000, 1000);
+ x2 -> setRange(-1000, 1000);
+ y2 -> setRange(-1000, 1000);
end1_type = new QComboBox();
- end1_type -> addItem(QET::Icons::EndLineNone, tr("Normale", "type of the 1st end of a line"), QET::None );
- end1_type -> addItem(QET::Icons::EndLineSimple, tr("Fl\350che simple", "type of the 1st end of a line"), QET::Simple );
- end1_type -> addItem(QET::Icons::EndLineTriangle, tr("Fl\350che triangulaire", "type of the 1st end of a line"), QET::Triangle);
- end1_type -> addItem(QET::Icons::EndLineCircle, tr("Cercle", "type of the 1st end of a line"), QET::Circle );
- end1_type -> addItem(QET::Icons::EndLineDiamond, tr("Carr\351", "type of the 1st end of a line"), QET::Diamond );
+ end1_type -> addItem(QET::Icons::EndLineNone, tr("Normale", "type of the 1st end of a line"), Qet::None );
+ end1_type -> addItem(QET::Icons::EndLineSimple, tr("Fl\350che simple", "type of the 1st end of a line"), Qet::Simple );
+ end1_type -> addItem(QET::Icons::EndLineTriangle, tr("Fl\350che triangulaire", "type of the 1st end of a line"), Qet::Triangle);
+ end1_type -> addItem(QET::Icons::EndLineCircle, tr("Cercle", "type of the 1st end of a line"), Qet::Circle );
+ end1_type -> addItem(QET::Icons::EndLineDiamond, tr("Carr\351", "type of the 1st end of a line"), Qet::Diamond );
end2_type = new QComboBox();
- end2_type -> addItem(QET::Icons::EndLineNone, tr("Normale", "type of the 2nd end of a line"), QET::None );
- end2_type -> addItem(QET::Icons::EndLineSimple, tr("Fl\350che simple", "type of the 2nd end of a line"), QET::Simple );
- end2_type -> addItem(QET::Icons::EndLineTriangle, tr("Fl\350che triangulaire", "type of the 2nd end of a line"), QET::Triangle);
- end2_type -> addItem(QET::Icons::EndLineCircle, tr("Cercle", "type of the 2nd end of a line"), QET::Circle );
- end2_type -> addItem(QET::Icons::EndLineDiamond, tr("Carr\351", "type of the 2nd end of a line"), QET::Diamond );
+ end2_type -> addItem(QET::Icons::EndLineNone, tr("Normale", "type of the 2nd end of a line"), Qet::None );
+ end2_type -> addItem(QET::Icons::EndLineSimple, tr("Fl\350che simple", "type of the 2nd end of a line"), Qet::Simple );
+ end2_type -> addItem(QET::Icons::EndLineTriangle, tr("Fl\350che triangulaire", "type of the 2nd end of a line"), Qet::Triangle);
+ end2_type -> addItem(QET::Icons::EndLineCircle, tr("Cercle", "type of the 2nd end of a line"), Qet::Circle );
+ end2_type -> addItem(QET::Icons::EndLineDiamond, tr("Carr\351", "type of the 2nd end of a line"), Qet::Diamond );
- end1_length = new QLineEdit();
- end2_length = new QLineEdit();
+ end1_length = new QDoubleSpinBox();
+ end2_length = new QDoubleSpinBox();
- end1_length -> setValidator(new QDoubleValidator(end1_length));
- end2_length -> setValidator(new QDoubleValidator(end2_length));
-
QGridLayout *grid = new QGridLayout();
grid -> addWidget(new QLabel("x1"), 0, 0);
grid -> addWidget(x1, 0, 1);
@@ -127,40 +124,40 @@
*/
void LineEditor::updateLine() {
if (!part) return;
- part -> setFirstEndType(static_cast<QET::EndType>(end1_type -> currentIndex()));
- part -> setFirstEndLength(end1_length -> text().toDouble());
- part -> setSecondEndType(static_cast<QET::EndType>(end2_type -> currentIndex()));
- part -> setSecondEndLength(end2_length -> text().toDouble());
+ part -> setProperty("end1", end1_type -> itemData(end1_type->currentIndex()));
+ part -> setProperty("length1", end1_length -> value());
+ part -> setProperty("end2", end2_type -> itemData(end2_type->currentIndex()));
+ part -> setProperty("length2", end2_length -> value());
part -> setLine(
QLineF(
part -> mapFromScene(
- x1 -> text().toDouble(),
- y1 -> text().toDouble()
+ x1 -> value(),
+ y1 -> value()
),
part -> mapFromScene(
- x2 -> text().toDouble(),
- y2 -> text().toDouble()
+ x2 -> value(),
+ y2 -> value()
)
)
);
}
/// Met a jour l'abscisse du premier point de la ligne et cree un objet d'annulation
-void LineEditor::updateLineX1() { addChangePartCommand(tr("abscisse point 1"), part, "x1", x1 -> text().toDouble()); }
+void LineEditor::updateLineX1() { addChangePartCommand(tr("abscisse point 1"), part, "x1", x1 -> value()); }
/// Met a jour l'ordonnee du premier point de la ligne et cree un objet d'annulation
-void LineEditor::updateLineY1() { addChangePartCommand(tr("ordonn\351e point 1"), part, "y1", y1 -> text().toDouble()); }
+void LineEditor::updateLineY1() { addChangePartCommand(tr("ordonn\351e point 1"), part, "y1", y1 -> value()); }
/// Met a jour l'abscisse du second point de la ligne et cree un objet d'annulation
-void LineEditor::updateLineX2() { addChangePartCommand(tr("abscisse point 2"), part, "x2", x2 -> text().toDouble()); }
+void LineEditor::updateLineX2() { addChangePartCommand(tr("abscisse point 2"), part, "x2", x2 -> value()); }
/// Met a jour l'ordonnee du second point de la ligne et cree un objet d'annulation
-void LineEditor::updateLineY2() { addChangePartCommand(tr("ordonn\351e point 2"), part, "y2", y2 -> text().toDouble()); }
+void LineEditor::updateLineY2() { addChangePartCommand(tr("ordonn\351e point 2"), part, "y2", y2 -> value()); }
/// Met a jour le type de la premiere extremite
-void LineEditor::updateLineEndType1() { addChangePartCommand(tr("type fin 1"), part, "end1", end1_type -> currentIndex()); }
+void LineEditor::updateLineEndType1() { addChangePartCommand(tr("type fin 1"), part, "end1", end1_type -> itemData(end1_type->currentIndex())); }
/// Met a jour la longueur de la premiere extremite
-void LineEditor::updateLineEndLength1() { addChangePartCommand(tr("longueur fin 1"), part, "length1", end1_length -> text()); }
+void LineEditor::updateLineEndLength1() { addChangePartCommand(tr("longueur fin 1"), part, "length1", end1_length -> value()); }
/// Met a jour le type de la seconde extremite
-void LineEditor::updateLineEndType2() { addChangePartCommand(tr("type fin 2"), part, "end2", end2_type -> currentIndex()); }
+void LineEditor::updateLineEndType2() { addChangePartCommand(tr("type fin 2"), part, "end2", end2_type -> itemData(end2_type->currentIndex())); }
/// Met a jour la longueur de la seconde extremite
-void LineEditor::updateLineEndLength2() { addChangePartCommand(tr("longueur fin 2"), part, "length2", end2_length -> text()); }
+void LineEditor::updateLineEndLength2() { addChangePartCommand(tr("longueur fin 2"), part, "length2", end2_length -> value()); }
/**
Met a jour le formulaire d'edition
@@ -170,14 +167,14 @@
activeConnections(false);
QPointF p1(part -> sceneP1());
QPointF p2(part -> sceneP2());
- x1 -> setText(QString("%1").arg(p1.x()));
- y1 -> setText(QString("%1").arg(p1.y()));
- x2 -> setText(QString("%1").arg(p2.x()));
- y2 -> setText(QString("%1").arg(p2.y()));
- end1_type -> setCurrentIndex(part -> firstEndType());
- end1_length -> setText(QString("%1").arg(part -> firstEndLength()));
- end2_type -> setCurrentIndex(part -> secondEndType());
- end2_length -> setText(QString("%1").arg(part -> secondEndLength()));
+ x1 -> setValue(p1.x());
+ y1 -> setValue(p1.y());
+ x2 -> setValue(p2.x());
+ y2 -> setValue(p2.y());
+ end1_type -> setCurrentIndex(end1_type->findData(part -> firstEndType()));
+ end1_length -> setValue(part -> firstEndLength());
+ end2_type -> setCurrentIndex(end2_type->findData(part -> secondEndType()));
+ end2_length -> setValue(part -> secondEndLength());
activeConnections(true);
}
Modified: trunk/sources/editor/lineeditor.h
===================================================================
--- trunk/sources/editor/lineeditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/lineeditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -37,9 +37,9 @@
private:
PartLine *part;
StyleEditor *style_;
- QLineEdit *x1, *y1, *x2, *y2;
+ QDoubleSpinBox *x1, *y1, *x2, *y2;
QComboBox *end1_type, *end2_type;
- QLineEdit *end1_length, *end2_length;
+ QDoubleSpinBox*end1_length, *end2_length;
// methods
public:
Modified: trunk/sources/editor/partarc.cpp
===================================================================
--- trunk/sources/editor/partarc.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partarc.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -24,8 +24,8 @@
@param scene La scene sur laquelle figure cet arc
*/
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
- QGraphicsEllipseItem(parent, scene),
CustomElementGraphicPart(editor),
+ QGraphicsEllipseItem(parent, scene),
_angle(-90),
start_angle(0)
{
@@ -124,80 +124,50 @@
}
/**
- Specifie la valeur d'une propriete donnee de l'arc
- @param property propriete a modifier. Valeurs acceptees :
- * x : abscisse du centre de l'ellipse dont fait partie l'arc
- * y : ordonnee du centre de l'ellipse dont fait partie l'arc
- * diameter_h : diametre horizontal de l'ellipse dont fait partie l'arc
- * diameter_v : diametre vertical de l'ellipse dont fait partie l'arc
- * start_angle : angle de depart
- * angle : taille de l'arc de cercle
- @param value Valeur a attribuer a la propriete
-*/
-void PartArc::setProperty(const QString &property, const QVariant &value) {
- CustomElementGraphicPart::setProperty(property, value);
- if (!value.canConvert(QVariant::Double)) return;
- if (property == "x") {
- QRectF current_rect = rect();
- QPointF current_pos = mapToScene(current_rect.center());
- setRect(current_rect.translated(value.toDouble() - current_pos.x(), 0.0));
- } else if (property == "y") {
- QRectF current_rect = rect();
- QPointF current_pos = mapToScene(current_rect.center());
- setRect(current_rect.translated(0.0, value.toDouble() - current_pos.y()));
- } else if (property == "diameter_h") {
- qreal new_width = qAbs(value.toDouble());
- QRectF current_rect = rect();
- current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
- current_rect.setWidth(new_width);
- setRect(current_rect);
- } else if (property == "diameter_v") {
- qreal new_height = qAbs(value.toDouble());
- QRectF current_rect = rect();
- current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
- current_rect.setHeight(new_height);
- setRect(current_rect);
- } else if (property == "start_angle") {
- setStartAngle(value.toInt() );
- } else if (property == "angle") {
- setAngle(value.toInt());
- }
- update();
+ * @brief PartArc::setX
+ * @param x is the center of the rect bounding this ellipse
+ */
+void PartArc::setX(const qreal x) {
+ QRectF current_rect = rect();
+ QPointF current_pos = mapToScene(current_rect.center());
+ setRect(current_rect.translated(x - current_pos.x(), 0.0));
}
/**
- Permet d'acceder a la valeur d'une propriete donnee de l'arc de cercle
- @param property propriete lue. Valeurs acceptees :
- * x : abscisse du centre de l'ellipse dont fait partie l'arc
- * y : ordonnee du centre de l'ellipse dont fait partie l'arc
- * diameter_h : diametre horizontal de l'ellipse dont fait partie l'arc
- * diameter_v : diametre vertical de l'ellipse dont fait partie l'arc
- * start_angle : angle de depart
- * angle : taille de l'arc de cercle
- @return La valeur de la propriete property
-*/
-QVariant PartArc::property(const QString &property) {
- // appelle la methode property de CustomElementGraphicpart pour les styles
- QVariant style_property = CustomElementGraphicPart::property(property);
- if (style_property != QVariant()) return(style_property);
-
- if (property == "x") {
- return(mapToScene(rect().center()).x());
- } else if (property == "y") {
- return(mapToScene(rect().center()).y());
- } else if (property == "diameter_h") {
- return(rect().width());
- } else if (property == "diameter_v") {
- return(rect().height());
- } else if (property == "start_angle") {
- return(start_angle);
- } else if (property == "angle") {
- return(_angle);
- }
- return(QVariant());
+ * @brief PartArc::setY
+ * @param y is the center of the rect bounding this ellipse
+ */
+void PartArc::setY(const qreal y) {
+ QRectF current_rect = rect();
+ QPointF current_pos = mapToScene(current_rect.center());
+ setRect(current_rect.translated(0.0, y - current_pos.y()));
}
/**
+ * @brief PartArc::setWidth
+ * @param w is the width of the rect bounding this ellipse
+ */
+void PartArc::setWidth(const qreal w) {
+ qreal new_width = qAbs(w);
+ QRectF current_rect = rect();
+ current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
+ current_rect.setWidth(new_width);
+ setRect(current_rect);
+}
+
+/**
+ * @brief PartArc::setHeight
+ * @param h is the heigth of the rect bounding this ellipse
+ */
+void PartArc::setHeight(const qreal h) {
+ qreal new_height = qAbs(h);
+ QRectF current_rect = rect();
+ current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
+ current_rect.setHeight(new_height);
+ setRect(current_rect);
+}
+
+/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
@@ -212,41 +182,6 @@
}
/**
- Permet de modifier l'etendue de l'arc de cercle.
- Il s'agit d'un angle, exprime en degres.
- Si l'angle est positif, l'arc s'etendra dans le sens des aiguilles d'une
- montre.
- @param a la nouvelle taille de l'arc de cercle
-*/
-void PartArc::setAngle(int a) {
- _angle = a;
-}
-
-/**
- Permet de modifier la position de depart de l'arc de cercle.
- Il s'agit d'un angle, exprime en degres.
- l'angle "0 degre" est situe a "3 heures".
- @param a la nouvelle taille de l'arc de cercle
-*/
-void PartArc::setStartAngle(int a) {
- start_angle = a;
-}
-
-/**
- @return l'etendue de l'arc de cercle
-*/
-int PartArc::angle() const {
- return(_angle);
-}
-
-/**
- @return la position de depart de l'arc de cercle
-*/
-int PartArc::startAngle() const {
- return(start_angle);
-}
-
-/**
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
conservee / enregistree.
Un arc est pertinent des lors que ses dimensions et son etendue ne sont
Modified: trunk/sources/editor/partarc.h
===================================================================
--- trunk/sources/editor/partarc.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partarc.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -23,7 +23,8 @@
This class represents an elliptical arc primitive which may be used to
compose the drawing of an electrical element within the element editor.
*/
-class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
+class PartArc : public CustomElementGraphicPart, public QGraphicsEllipseItem {
+ Q_OBJECT
// constructors, destructor
public:
PartArc(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
@@ -53,16 +54,37 @@
virtual void fromXml(const QDomElement &);
virtual QPointF sceneTopLeft() const;
virtual QRectF boundingRect() const;
- virtual void setAngle(int);
- virtual void setStartAngle(int);
- virtual int angle() const;
- virtual int startAngle() const;
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
+
+ ///PROPERT
+ // X value
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ qreal x() const {return mapToScene(rect().center()).x() ;}
+ void setX(const qreal x);
+ //Y value
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ qreal y() const {return mapToScene(rect().center()).y();}
+ void setY(const qreal y);
+ // horizontal diameter
+ Q_PROPERTY(qreal diameter_h READ width WRITE setWidth)
+ qreal width() const {return rect().width();}
+ void setWidth(const qreal w);
+ // vertical diameter
+ Q_PROPERTY(qreal diameter_v READ height WRITE setHeight)
+ qreal height() const {return rect().height();}
+ void setHeight (const qreal h);
+ // start angle
+ Q_PROPERTY(int start_angle READ startAngle WRITE setStartAngle)
+ int startAngle() const {return start_angle;}
+ void setStartAngle(const int sa){start_angle = sa;}
+ // angle value
+ Q_PROPERTY(int angle READ angle WRITE setAngle)
+ int angle() const {return _angle;}
+ void setAngle(const int a) {_angle = a;}
+
protected:
QVariant itemChange(GraphicsItemChange, const QVariant &);
Modified: trunk/sources/editor/partellipse.cpp
===================================================================
--- trunk/sources/editor/partellipse.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partellipse.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -23,7 +23,7 @@
@param parent Le QGraphicsItem parent de cette ellipse
@param scene La scene sur laquelle figure cette ellipse
*/
-PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsEllipseItem(parent, scene), CustomElementGraphicPart(editor) {
+PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : CustomElementGraphicPart(editor), QGraphicsEllipseItem(parent, scene) {
setFlags(QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@@ -106,68 +106,34 @@
);
}
-/**
- Specifie la valeur d'une propriete donnee de l'ellipse
- @param property propriete a modifier. Valeurs acceptees :
- * x : abscisse du centre de l'ellipse
- * y : ordonnee du centre de l'ellipse
- * diameter_h : diametre horizontal de l'ellipse
- * diameter_v : diametre vertical de l'ellipse
- @param value Valeur a attribuer a la propriete
-*/
-void PartEllipse::setProperty(const QString &property, const QVariant &value) {
- CustomElementGraphicPart::setProperty(property, value);
- if (!value.canConvert(QVariant::Double)) return;
- if (property == "x") {
- QRectF current_rect = rect();
- QPointF current_pos = mapToScene(current_rect.center());
- setRect(current_rect.translated(value.toDouble() - current_pos.x(), 0.0));
- } else if (property == "y") {
- QRectF current_rect = rect();
- QPointF current_pos = mapToScene(current_rect.center());
- setRect(current_rect.translated(0.0, value.toDouble() - current_pos.y()));
- } else if (property == "diameter_h") {
- qreal new_width = qAbs(value.toDouble());
- QRectF current_rect = rect();
- current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
- current_rect.setWidth(new_width);
- setRect(current_rect);
- } else if (property == "diameter_v") {
- qreal new_height = qAbs(value.toDouble());
- QRectF current_rect = rect();
- current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
- current_rect.setHeight(new_height);
- setRect(current_rect);
- }
- update();
+void PartEllipse::setX(const qreal x) {
+ QRectF current_rect = rect();
+ QPointF current_pos = mapToScene(current_rect.center());
+ setRect(current_rect.translated(x - current_pos.x(), 0.0));
}
-/**
- Permet d'acceder a la valeur d'une propriete donnee de l'ellipse
- @param property propriete lue. Valeurs acceptees :
- * x : abscisse du centre de l'ellipse
- * y : ordonnee du centre de l'ellipse
- * diameter_h : diametre horizontal de l'ellipse
- * diameter_v : diametre vertical de l'ellipse
- @return La valeur de la propriete property
-*/
-QVariant PartEllipse::property(const QString &property) {
- // appelle la methode property de CustomElementGraphicpart pour les styles
- QVariant style_property = CustomElementGraphicPart::property(property);
- if (style_property != QVariant()) return(style_property);
-
- if (property == "x") {
- return(mapToScene(rect().center()).x());
- } else if (property == "y") {
- return(mapToScene(rect().center()).y());
- } else if (property == "diameter_h") {
- return(rect().width());
- } else if (property == "diameter_v") {
- return(rect().height());
- }
- return(QVariant());
+void PartEllipse::setY(const qreal y) {
+ QRectF current_rect = rect();
+ QPointF current_pos = mapToScene(current_rect.center());
+ setRect(current_rect.translated(0.0, y - current_pos.y()));
}
+void PartEllipse::setWidth(const qreal w) {
+ qreal new_width = qAbs(w);
+ QRectF current_rect = rect();
+ current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
+ current_rect.setWidth(new_width);
+ setRect(current_rect);
+}
+
+void PartEllipse::setHeight(const qreal h) {
+ qreal new_height = qAbs(h);
+ QRectF current_rect = rect();
+ current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
+ current_rect.setHeight(new_height);
+ setRect(current_rect);
+}
+
/**
Gere les changements intervenant sur cette partie
@param change Type de changement
Modified: trunk/sources/editor/partellipse.h
===================================================================
--- trunk/sources/editor/partellipse.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partellipse.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -23,7 +23,8 @@
This class represents an ellipse primitive which may be used to compose the
drawing of an electrical element within the element editor.
*/
-class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart {
+class PartEllipse : public CustomElementGraphicPart, public QGraphicsEllipseItem {
+ Q_OBJECT
// constructors, destructor
public:
PartEllipse(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
@@ -48,12 +49,28 @@
virtual void fromXml(const QDomElement &);
virtual QPointF sceneTopLeft() const;
virtual QRectF boundingRect() const;
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
+
+ ///PROPERTY
+ // X value
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ qreal x() const {return mapToScene(rect().center()).x() ;}
+ void setX(const qreal x);
+ // Y value
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ qreal y() const {return mapToScene(rect().center()).y();}
+ void setY(const qreal y);
+ // horizontal diameter
+ Q_PROPERTY(qreal diameter_h READ width WRITE setWidth)
+ qreal width() const {return rect().width();}
+ void setWidth(const qreal w);
+ // vertical diameter
+ Q_PROPERTY(qreal diameter_v READ height WRITE setHeight)
+ qreal height() const {return rect().height();}
+ void setHeight (const qreal h);
protected:
QVariant itemChange(GraphicsItemChange, const QVariant &);
Modified: trunk/sources/editor/partline.cpp
===================================================================
--- trunk/sources/editor/partline.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partline.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -27,9 +27,9 @@
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
QGraphicsLineItem(parent, scene),
CustomElementGraphicPart(editor),
- first_end(QET::None),
+ first_end(Qet::None),
first_length(1.5),
- second_end(QET::None),
+ second_end(Qet::None),
second_length(1.5)
{
setFlags(QGraphicsItem::ItemIsSelectable);
@@ -47,11 +47,11 @@
@param end_type Type d'extremite
@return Le nombre de "longueurs" requises pour dessiner une extremite de type end_type
*/
-uint PartLine::requiredLengthForEndType(const QET::EndType &end_type) {
+uint PartLine::requiredLengthForEndType(const Qet::EndType &end_type) {
uint length_count_required = 0;
- if (end_type == QET::Circle || end_type == QET::Diamond) {
+ if (end_type == Qet::Circle || end_type == Qet::Diamond) {
length_count_required = 2;
- } else if (end_type == QET::Simple || end_type == QET::Triangle) {
+ } else if (end_type == Qet::Simple || end_type == Qet::Triangle) {
length_count_required = 1;
}
return(length_count_required);
@@ -102,23 +102,23 @@
QPointF start_point, stop_point;
if (draw_1st_end) {
QList<QPointF> four_points1(fourEndPoints(point1, point2, length1));
- if (first_end == QET::Circle) {
+ if (first_end == Qet::Circle) {
painter -> drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
start_point = four_points1[1];
- } else if (first_end == QET::Diamond) {
+ } else if (first_end == Qet::Diamond) {
painter -> drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[1];
- } else if (first_end == QET::Simple) {
+ } else if (first_end == Qet::Simple) {
painter -> drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
start_point = point1;
- } else if (first_end == QET::Triangle) {
+ } else if (first_end == Qet::Triangle) {
painter -> drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[0];
}
// ajuste le depart selon l'epaisseur du trait
- if (pen_width && (first_end == QET::Simple || first_end == QET::Circle)) {
+ if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle)) {
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
}
} else {
@@ -128,22 +128,22 @@
// dessine la seconde extremite
if (draw_2nd_end) {
QList<QPointF> four_points2(fourEndPoints(point2, point1, length2));
- if (second_end == QET::Circle) {
+ if (second_end == Qet::Circle) {
painter -> drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
stop_point = four_points2[1];
- } else if (second_end == QET::Diamond) {
+ } else if (second_end == Qet::Diamond) {
painter -> drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
stop_point = four_points2[1];
- } else if (second_end == QET::Simple) {
+ } else if (second_end == Qet::Simple) {
painter -> drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
stop_point = point2;
- } else if (second_end == QET::Triangle) {
+ } else if (second_end == Qet::Triangle) {
painter -> drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
stop_point = four_points2[0];
}
// ajuste l'arrivee selon l'epaisseur du trait
- if (pen_width && (second_end == QET::Simple || second_end == QET::Circle)) {
+ if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle)) {
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
}
} else {
@@ -168,9 +168,9 @@
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
- xml_element.setAttribute("end1", QET::endTypeToString(first_end));
+ xml_element.setAttribute("end1", Qet::endTypeToString(first_end));
xml_element.setAttribute("length1", QString("%1").arg(first_length));
- xml_element.setAttribute("end2", QET::endTypeToString(second_end));
+ xml_element.setAttribute("end2", Qet::endTypeToString(second_end));
xml_element.setAttribute("length2", QString("%1").arg(second_length));
stylesToXml(xml_element);
@@ -195,87 +195,57 @@
)
)
);
- first_end = QET::endTypeFromString(qde.attribute("end1"));
+ first_end = Qet::endTypeFromString(qde.attribute("end1"));
first_length = qde.attribute("length1", "1.5").toDouble();
- second_end = QET::endTypeFromString(qde.attribute("end2"));
+ second_end = Qet::endTypeFromString(qde.attribute("end2"));
second_length = qde.attribute("length2", "1.5").toDouble();
}
/**
- Specifie la valeur d'une propriete donnee de la ligne
- @param property propriete a modifier. Valeurs acceptees :
- * x1 : abscisse du premier point
- * y1 : ordonnee du second point
- * x2 : abscisse du premier point
- * y2 : ordonnee du second point
- *end1 : type d'embout du premier point
- *end2 : type d'embout du second point
- @param value Valeur a attribuer a la propriete
-*/
-void PartLine::setProperty(const QString &property, const QVariant &value) {
- CustomElementGraphicPart::setProperty(property, value);
- if (!value.canConvert(QVariant::Double)) return;
- QPointF new_p1(sceneP1()), new_p2(sceneP2());
- bool setline = true;
- if (property == "x1") {
- new_p1.setX(value.toDouble());
- } else if (property == "y1") {
- new_p1.setY(value.toDouble());
- } else if (property == "x2") {
- new_p2.setX(value.toDouble());
- } else if (property == "y2") {
- new_p2.setY(value.toDouble());
- } else {
- setline = false;
- if (property == "end1") {
- setFirstEndType(static_cast<QET::EndType>(value.toUInt()));
- } else if (property == "end2") {
- setSecondEndType(static_cast<QET::EndType>(value.toUInt()));
- } else if (property == "length1") {
- setFirstEndLength(value.toDouble());
- } else if (property == "length2") {
- setSecondEndLength(value.toDouble());
- }
- }
- if (setline) setLine(QLineF(mapFromScene(new_p1), mapFromScene(new_p2)));
- update();
+ * @brief PartLine::setX1
+ * set X of P1
+ * @param x1
+ */
+void PartLine::setX1(qreal x1) {
+ QPointF p = line().p1();
+ p.setX(x1);
+ setLine(QLineF(p, line().p2()));
}
/**
- Permet d'acceder a la valeur d'une propriete donnee de la ligne
- @param property propriete lue. Valeurs acceptees :
- * x1 : abscisse du premier point
- * y1 : ordonnee du second point
- * x2 : abscisse du premier point
- * y2 : ordonnee du second point
- @return La valeur de la propriete property
-*/
-QVariant PartLine::property(const QString &property) {
- // appelle la methode property de CustomElementGraphicpart pour les styles
- QVariant style_property = CustomElementGraphicPart::property(property);
- if (style_property != QVariant()) return(style_property);
-
- if (property == "x1") {
- return(sceneP1().x());
- } else if (property == "y1") {
- return(sceneP1().y());
- } else if (property == "x2") {
- return(sceneP2().x());
- } else if (property == "y2") {
- return(sceneP2().y());
- } else if (property == "end1") {
- return(firstEndType());
- } else if (property == "end2") {
- return(secondEndType());
- } else if (property == "length1") {
- return(firstEndLength());
- } else if (property == "length2") {
- return(secondEndLength());
- }
- return(QVariant());
+ * @brief PartLine::setY1
+ * set y of P1
+ * @param y1
+ */
+void PartLine::setY1(qreal y1) {
+ QPointF p = line().p1();
+ p.setY(y1);
+ setLine(QLineF(p, line().p2()));
}
/**
+ * @brief PartLine::setX2
+ * set x of P2
+ * @param x2
+ */
+void PartLine::setX2(qreal x2) {
+ QPointF p = line().p2();
+ p.setX(x2);
+ setLine(QLineF(line().p2(), p));
+}
+
+/**
+ * @brief PartLine::setY2
+ * set y of P2
+ * @param y2
+ */
+void PartLine::setY2(qreal y2) {
+ QPointF p = line().p2();
+ p.setY(y2);
+ setLine(QLineF(line().p2(), p));
+}
+
+/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
@@ -453,11 +423,11 @@
r.adjust(0.0, 0.0, 0.1, 0.1);
// cas special : les embouts sortent largement du bounding rect originel
- if (first_end != QET::None) {
+ if (first_end != Qet::None) {
r = r.united(firstEndCircleRect());
}
- if (second_end != QET::None) {
+ if (second_end != Qet::None) {
r = r.united(secondEndCircleRect());
}
@@ -505,34 +475,6 @@
}
/**
- @param end_type nouveau type d'embout pour l'extremite 1
-*/
-void PartLine::setFirstEndType(const QET::EndType &end_type) {
- first_end = end_type;
-}
-
-/**
- @return le type d'embout pour l'extremite 1
-*/
-QET::EndType PartLine::firstEndType() const {
- return(first_end);
-}
-
-/**
- @param end_type Nouveau type d'embout pour l'extremite 2
-*/
-void PartLine::setSecondEndType(const QET::EndType &end_type) {
- second_end = end_type;
-}
-
-/**
- @return le type d'embout pour l'extremite 2
-*/
-QET::EndType PartLine::secondEndType() const {
- return(second_end);
-}
-
-/**
@return Les quatre points interessants a l'extremite d'une droite
Ces points sont, dans l'ordre :
* O : point sur la ligne, a une distance length de l'extremite
@@ -561,33 +503,3 @@
return(QList<QPointF>() << o << a << b << c);
}
-
-/**
- @param length nouvelle longueur de la premiere extremite
- la longueur de l'extemite ne peut exceder celle de la ligne
-*/
-void PartLine::setFirstEndLength(const qreal &length) {
- first_length = qMin(qAbs(length), line().length());
-}
-
-/**
- @return longueur de la premiere extremite
-*/
-qreal PartLine::firstEndLength() const {
- return(first_length);
-}
-
-/**
- @param length nouvelle longueur de la seconde extremite
- la longueur de l'extemite ne peut exceder celle de la ligne
-*/
-void PartLine::setSecondEndLength(const qreal &length) {
- second_length = qMin(qAbs(length), line().length());
-}
-
-/**
- @return longueur de la seconde extremite
-*/
-qreal PartLine::secondEndLength() const {
- return(second_length);
-}
Modified: trunk/sources/editor/partline.h
===================================================================
--- trunk/sources/editor/partline.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partline.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -29,7 +29,8 @@
drawn if the required length for their drawing is longer than the line itself.
In case there is room for a single end only, the first one get priority.
*/
-class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
+class PartLine : public CustomElementGraphicPart, public QGraphicsLineItem {
+ Q_OBJECT
// constructors, destructor
public:
PartLine(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
@@ -40,9 +41,9 @@
// attributes
private:
- QET::EndType first_end;
+ Qet::EndType first_end;
qreal first_length;
- QET::EndType second_end;
+ Qet::EndType second_end;
qreal second_length;
QList<QPointF> saved_points_;
@@ -65,22 +66,48 @@
virtual QPointF sceneP2() const;
virtual QPainterPath shape() const;
virtual QRectF boundingRect() const;
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
- virtual void setFirstEndType(const QET::EndType &);
- virtual QET::EndType firstEndType() const;
- virtual void setSecondEndType(const QET::EndType &);
- virtual QET::EndType secondEndType() const;
- virtual void setFirstEndLength(const qreal &);
- virtual qreal firstEndLength() const;
- virtual void setSecondEndLength(const qreal &);
- virtual qreal secondEndLength() const;
- static uint requiredLengthForEndType(const QET::EndType &);
+ static uint requiredLengthForEndType(const Qet::EndType &);
static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
+
+ ///PROPERTY
+ // X value of the first point
+ Q_PROPERTY(qreal x1 READ x1 WRITE setX1)
+ qreal x1() const {return sceneP1().x();}
+ void setX1(qreal x1);
+ // Y value of the first point
+ Q_PROPERTY(qreal y1 READ y1 WRITE setY1)
+ qreal y1() const {return sceneP1().y();}
+ void setY1(qreal y1);
+ // X value of the second point
+ Q_PROPERTY(qreal x2 READ x2 WRITE setX2)
+ qreal x2() const {return sceneP2().x();}
+ void setX2(qreal x2);
+ // Y value of the second point
+ Q_PROPERTY(qreal y2 READ y2 WRITE setY2)
+ qreal y2() const {return sceneP2().y();}
+ void setY2(qreal y2);
+ // End type of the first point
+ Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
+ Qet::EndType firstEndType() const {return first_end;}
+ void setFirstEndType(const Qet::EndType &et) {first_end = et;}
+ // End type of the second point
+ Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
+ Qet::EndType secondEndType() const {return second_end;}
+ void setSecondEndType(const Qet::EndType &et) {second_end = et;}
+ // Size of end type of first point
+ Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
+ qreal firstEndLength() const {return first_length;}
+ void setFirstEndLength(const qreal &l) {first_length = qMin(qAbs(l), line().length());}
+ // Size of end type of the second point
+ Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
+ qreal secondEndLength() const {return second_length;}
+ void setSecondEndLength(const qreal &l) {second_length = qMin(qAbs(l), line().length());}
+
+
protected:
QVariant itemChange(GraphicsItemChange, const QVariant &);
Modified: trunk/sources/editor/partpolygon.cpp
===================================================================
--- trunk/sources/editor/partpolygon.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partpolygon.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -25,9 +25,9 @@
@param scene La scene sur laquelle figure ce polygone
*/
PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
- QGraphicsPolygonItem(parent, scene),
CustomElementGraphicPart(editor),
- closed(false)
+ QGraphicsPolygonItem(parent, scene),
+ m_closed(false)
{
setFlags(QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
@@ -64,7 +64,7 @@
}
setPolygon(temp_polygon);
- closed = qde.attribute("closed") != "false";
+ m_closed = qde.attribute("closed") != "false";
}
/**
@@ -81,7 +81,7 @@
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
++ i;
}
- if (!closed) xml_element.setAttribute("closed", "false");
+ if (!m_closed) xml_element.setAttribute("closed", "false");
stylesToXml(xml_element);
return(xml_element);
}
@@ -99,38 +99,11 @@
t.setCosmetic(options && options -> levelOfDetail < 1.0);
if (isSelected()) t.setColor(Qt::red);
painter -> setPen(t);
- if (closed) painter -> drawPolygon(polygon());
+ if (m_closed) painter -> drawPolygon(polygon());
else painter -> drawPolyline(polygon());
}
/**
- Specifie la valeur d'une propriete donnee du polygone
- @param property propriete a modifier. Valeurs acceptees :
- * closed : true pour fermer le polygone, false sinon
- @param value Valeur a attribuer a la propriete
-*/
-void PartPolygon::setProperty(const QString &property, const QVariant &value) {
- CustomElementGraphicPart::setProperty(property, value);
- if (property == "closed") closed = value.toBool();
- update();
-}
-
-/**
- Permet d'acceder a la valeur d'une propriete donnee de la ligne
- @param property propriete lue. Valeurs acceptees :
- * closed : true pour fermer le polygone, false sinon
- @return La valeur de la propriete property
-*/
-QVariant PartPolygon::property(const QString &property) {
- // appelle la methode property de CustomElementGraphicpart pour les styles
- QVariant style_property = CustomElementGraphicPart::property(property);
- if (style_property != QVariant()) return(style_property);
-
- if (property == "closed") return(closed);
- return(QVariant());
-}
-
-/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
@@ -144,7 +117,6 @@
return(QGraphicsPolygonItem::itemChange(change, value));
}
-
/**
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
conservee / enregistree.
Modified: trunk/sources/editor/partpolygon.h
===================================================================
--- trunk/sources/editor/partpolygon.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partpolygon.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -23,7 +23,8 @@
This class represents a polygon primitive which may be used to compose the
drawing of an electrical element within the element editor.
*/
-class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart {
+class PartPolygon : public CustomElementGraphicPart, public QGraphicsPolygonItem {
+ Q_OBJECT
// constructors, destructor
public:
PartPolygon(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
@@ -34,7 +35,7 @@
// attributes
private:
- bool closed;
+ bool m_closed;
// methods
public:
@@ -51,15 +52,19 @@
const QDomElement toXml(QDomDocument &) const;
virtual QRectF boundingRect() const;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
- void setClosed(bool c);
- bool isClosed() const;
- void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
virtual QET::ScalingMethod preferredScalingMethod() const;
+
+ ///PROPERTY
+ // Closed (join the first and last point by a line)
+ Q_PROPERTY(bool closed READ isClosed WRITE setClosed)
+ bool isClosed() const {return m_closed;}
+ void setClosed(bool c) {m_closed = c;}
+
+
protected:
QVariant itemChange(GraphicsItemChange, const QVariant &);
@@ -67,21 +72,4 @@
private:
QList<QPointF> saved_points_;
};
-
-/**
- Whether the polygon should be closed.
- @param c true for the polygon to be closed, false otherwise
-*/
-inline void PartPolygon::setClosed(bool c) {
- closed = c;
-}
-
-/**
- Indicate whether the polygon is closed.
- @return true if the polygon is closed, false otherwise
-*/
-inline bool PartPolygon::isClosed() const {
- return(closed);
-}
-
#endif
Modified: trunk/sources/editor/partrectangle.cpp
===================================================================
--- trunk/sources/editor/partrectangle.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partrectangle.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -23,7 +23,7 @@
@param parent Le QGraphicsItem parent de ce rectangle
@param scene La scene sur laquelle figure ce rectangle
*/
-PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsRectItem(parent, scene), CustomElementGraphicPart(editor) {
+PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : CustomElementGraphicPart(editor), QGraphicsRectItem(parent, scene) {
setFlags(QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@@ -106,66 +106,48 @@
}
/**
- Specifie la valeur d'une propriete donnee du rectangle
- @param property propriete a modifier. Valeurs acceptees :
- * x : abscisse du coin superieur gauche du rectangle
- * y : ordonnee du coin superieur gauche du rectangle
- * width : largeur du rectangle
- * height : hauteur du rectangle
- @param value Valeur a attribuer a la propriete
-*/
-void PartRectangle::setProperty(const QString &property, const QVariant &value) {
- CustomElementGraphicPart::setProperty(property, value);
- if (!value.canConvert(QVariant::Double)) return;
- if (property == "x") {
- QRectF current_rect = rect();
- QPointF current_pos = mapToScene(current_rect.topLeft());
- setRect(current_rect.translated(value.toDouble() - current_pos.x(), 0.0));
- } else if (property == "y") {
- QRectF current_rect = rect();
- QPointF current_pos = mapToScene(current_rect.topLeft());
- setRect(current_rect.translated(0.0, value.toDouble() - current_pos.y()));
- } else if (property == "width") {
- qreal new_width = qAbs(value.toDouble());
- QRectF current_rect = rect();
- current_rect.setWidth(new_width);
- setRect(current_rect);
- } else if (property == "height") {
- qreal new_height = qAbs(value.toDouble());
- QRectF current_rect = rect();
- current_rect.setHeight(new_height);
- setRect(current_rect);
- }
- update();
+ * @brief PartRectangle::setX
+ * @param x new value
+ */
+void PartRectangle::setX(qreal x) {
+ QRectF current_rect = rect();
+ QPointF current_pos = mapToScene(current_rect.topLeft());
+ setRect(current_rect.translated(x - current_pos.x(), 0.0));
}
/**
- Permet d'acceder a la valeur d'une propriete donnee du rectangle
- @param property propriete lue. Valeurs acceptees :
- * x : abscisse du coin superieur gauche du rectangle
- * y : ordonnee du coin superieur gauche du rectangle
- * width : largeur du rectangle
- * height : hauteur du rectangle
- @return La valeur de la propriete property
-*/
-QVariant PartRectangle::property(const QString &property) {
- // appelle la methode property de CustomElementGraphicpart pour les styles
- QVariant style_property = CustomElementGraphicPart::property(property);
- if (style_property != QVariant()) return(style_property);
-
- if (property == "x") {
- return(mapToScene(rect().topLeft()).x());
- } else if (property == "y") {
- return(mapToScene(rect().topLeft()).y());
- } else if (property == "width") {
- return(rect().width());
- } else if (property == "height") {
- return(rect().height());
- }
- return(QVariant());
+ * @brief PartRectangle::setY
+ * @param y new value
+ */
+void PartRectangle::setY(qreal y) {
+ QRectF current_rect = rect();
+ QPointF current_pos = mapToScene(current_rect.topLeft());
+ setRect(current_rect.translated(0.0, y - current_pos.y()));
}
/**
+ * @brief PartRectangle::setWidth
+ * @param w new value
+ */
+void PartRectangle::setWidth(qreal w) {
+ qreal new_width = qAbs(w);
+ QRectF current_rect = rect();
+ current_rect.setWidth(new_width);
+ setRect(current_rect);
+}
+
+/**
+ * @brief PartRectangle::setHeight
+ * @param h new value
+ */
+void PartRectangle::setHeight(qreal h) {
+ qreal new_height = qAbs(h);
+ QRectF current_rect = rect();
+ current_rect.setHeight(new_height);
+ setRect(current_rect);
+}
+
+/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
Modified: trunk/sources/editor/partrectangle.h
===================================================================
--- trunk/sources/editor/partrectangle.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partrectangle.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -23,7 +23,8 @@
This class represents a rectangle primitive which may be used to compose the
drawing of an electrical element within the element editor.
*/
-class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart {
+class PartRectangle : public CustomElementGraphicPart, public QGraphicsRectItem {
+ Q_OBJECT
// constructors, destructor
public:
PartRectangle(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
@@ -48,12 +49,28 @@
virtual void fromXml(const QDomElement &);
virtual QPointF sceneTopLeft() const;
virtual QRectF boundingRect() const;
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
+
+ ///PROPERTY
+ // X value
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ qreal x() const {return mapToScene(rect().topLeft()).x();}
+ void setX(qreal x);
+ // Y value
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ qreal y() const {return mapToScene(rect().topLeft()).y();}
+ void setY(qreal y);
+ // Width value
+ Q_PROPERTY(qreal width READ width WRITE setWidth)
+ qreal width() const {return rect().width();}
+ void setWidth(qreal w);
+ // Height value
+ Q_PROPERTY(qreal height READ height WRITE setHeight)
+ qreal height() const { return rect().height();}
+ void setHeight(qreal h);
protected:
QVariant itemChange(GraphicsItemChange, const QVariant &);
Modified: trunk/sources/editor/partterminal.cpp
===================================================================
--- trunk/sources/editor/partterminal.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partterminal.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -25,9 +25,9 @@
@param scene La scene sur laquelle figure cette borne
*/
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
- CustomElementPart(editor),
+ CustomElementGraphicPart(editor),
QGraphicsItem(parent, scene),
- _orientation(QET::North)
+ m_orientation(Qet::North)
{
updateSecondPoint();
setFlags(QGraphicsItem::ItemIsSelectable);
@@ -53,13 +53,8 @@
setPos(QPointF(term_x, term_y));
// lit l'orientation de la borne
- _orientation = QET::orientationFromString(xml_elmt.attribute("orientation"));
+ m_orientation = Qet::orientationFromString(xml_elmt.attribute("orientation"));
- // Read number and name of terminal from XML
- number_ = xml_elmt.attribute("number");
- name_ = xml_elmt.attribute("name");
- nameHidden_ = xml_elmt.attribute("nameHidden").toInt();
-
updateSecondPoint();
}
@@ -76,11 +71,8 @@
xml_element.setAttribute("y", QString("%1").arg(scenePos().y()));
// ecrit l'orientation de la borne
- xml_element.setAttribute("orientation", orientationToString(_orientation));
+ xml_element.setAttribute("orientation", Qet::orientationToString(m_orientation));
// Write name and number to XML
- xml_element.setAttribute("number", number_);
- xml_element.setAttribute("name", name_);
- xml_element.setAttribute("nameHidden", nameHidden_);
return(xml_element);
}
@@ -136,122 +128,16 @@
}
/**
- @return L'orientation de la borne
-*/
-QET::Orientation PartTerminal::orientation() const {
- return(_orientation);
-}
-
-/**
Definit l'orientation de la borne
@param ori la nouvelle orientation de la borne
*/
-void PartTerminal::setOrientation(QET::Orientation ori) {
+void PartTerminal::setOrientation(Qet::Orientation ori) {
prepareGeometryChange();
- _orientation = ori;
+ m_orientation = ori;
updateSecondPoint();
}
/**
- @return Number of terminal
-*/
-QString PartTerminal::number() const {
- return(number_);
-}
-
-/**
- set Number of Terminal
- @param num number of terminal
-*/
-void PartTerminal::setNumber(const QString &num) {
- number_ = num;
-}
-
-/**
- @return Name of terminal
-*/
-QString PartTerminal::nameOfTerminal() const {
- return(name_);
-}
-
-/**
- set Name of Terminal
- @param na Name of terminal
-*/
-void PartTerminal::setName(const QString &na) {
- name_ = na;
-}
-
-/**
- * @brief PartTerminal::nameIsHidden
- * @return
- */
-bool PartTerminal::nameIsHidden() const {
- return(nameHidden_);
-}
-/**
- * @brief PartTerminal::setNameHidden
- */
-void PartTerminal::setNameHidden(const bool &nh) {
- nameHidden_ = nh;
-}
-
-/**
- Specifie la valeur d'une propriete donnee de la borne
- @param property propriete a modifier. Valeurs acceptees :
- * x : abscisse de la borne
- * y : ordonnee de la borne
- * orientation : orientation de la borne
- @param value Valeur a attribuer a la propriete
-*/
-void PartTerminal::setProperty(const QString &property, const QVariant &value) {
- if (property == "x") {
- if (!value.canConvert(QVariant::Double)) return;
- setPos(value.toDouble(), pos().y());
- } else if (property == "y") {
- if (!value.canConvert(QVariant::Double)) return;
- setPos(pos().x(), value.toDouble());
- } else if (property == "orientation") {
- if (!value.canConvert(QVariant::Int)) return;
- setOrientation(static_cast<QET::Orientation>(value.toInt()));
- } else if (property == "number") {
- if (!value.canConvert(QVariant::String)) return;
- setNumber(value.toString());
- } else if (property == "name") {
- if (!value.canConvert(QVariant::String)) return;
- setName(value.toString());
- } else if (property == "nameHidden") {
- if (!value.canConvert(QVariant::Int)) return;
- setNameHidden(value.toInt());
- }
-}
-
-/**
- Permet d'acceder a la valeur d'une propriete donnee de la borne
- @param property propriete lue. Valeurs acceptees :
- * x : abscisse de la borne
- * y : ordonnee de la borne
- * orientation : orientation de la borne
- @return La valeur de la propriete property
-*/
-QVariant PartTerminal::property(const QString &property) {
- if (property == "x") {
- return(scenePos().x());
- } else if (property == "y") {
- return(scenePos().y());
- } else if (property == "orientation") {
- return(_orientation);
- } else if (property == "number") {
- return(number_);
- } else if (property == "name") {
- return(name_);
- } else if (property == "nameHidden") {
- return(nameHidden_);
- }
- return(QVariant());
-}
-
-/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
@@ -271,11 +157,11 @@
*/
void PartTerminal::updateSecondPoint() {
qreal ts = 4.0; // terminal size
- switch(_orientation) {
- case QET::North: second_point = QPointF(0.0, ts); break;
- case QET::East : second_point = QPointF(-ts, 0.0); break;
- case QET::South: second_point = QPointF(0.0, -ts); break;
- case QET::West : second_point = QPointF(ts, 0.0); break;
+ switch(m_orientation) {
+ case Qet::North: second_point = QPointF(0.0, ts); break;
+ case Qet::East : second_point = QPointF(-ts, 0.0); break;
+ case Qet::South: second_point = QPointF(0.0, -ts); break;
+ case Qet::West : second_point = QPointF(ts, 0.0); break;
}
}
Modified: trunk/sources/editor/partterminal.h
===================================================================
--- trunk/sources/editor/partterminal.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/partterminal.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -17,14 +17,15 @@
*/
#ifndef PART_TERMINAL_H
#define PART_TERMINAL_H
-#include "customelementpart.h"
+#include "customelementgraphicpart.h"
#include "qet.h"
#include <QtGui>
/**
This class represents a terminal which may be used to compose the drawing of
an electrical element within the element editor.
*/
-class PartTerminal : public CustomElementPart, public QGraphicsItem {
+class PartTerminal : public CustomElementGraphicPart, public QGraphicsItem {
+ Q_OBJECT
public:
// constructors, destructor
PartTerminal(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
@@ -34,10 +35,8 @@
// attributes
private:
- QET::Orientation _orientation;
+ Qet::Orientation m_orientation;
QPointF second_point;
- QString number_, name_;
- bool nameHidden_;
// methods
public:
@@ -54,21 +53,23 @@
virtual const QDomElement toXml(QDomDocument &) const;
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual QRectF boundingRect() const;
- QET::Orientation orientation() const;
- void setOrientation(QET::Orientation);
- QString number() const;
- void setNumber(const QString &);
- QString nameOfTerminal() const;
- void setName(const QString &);
- bool nameIsHidden() const;
- void setNameHidden(const bool &);
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
+ /*virtual void setProperty(const QString &, const QVariant &);
+ virtual QVariant property(const QString &);*/
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
+
+ ///PROPERTY
+ // X value
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ // Y value
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ // Horientation value
+ Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
+ Qet::Orientation orientation() const {return m_orientation;}
+ void setOrientation(Qet::Orientation ori);
protected:
QVariant itemChange(GraphicsItemChange, const QVariant &);
Modified: trunk/sources/editor/parttext.cpp
===================================================================
--- trunk/sources/editor/parttext.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/parttext.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -73,7 +73,7 @@
qreal default_rotation_angle = 0.0;
if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
- setRotationAngle(default_rotation_angle);
+ setRotation(default_rotation_angle);
}
setPos(
@@ -94,8 +94,8 @@
xml_element.setAttribute("text", toPlainText());
xml_element.setAttribute("size", font().pointSize());
// angle de rotation du champ de texte
- if (rotationAngle()) {
- xml_element.setAttribute("rotation", QString("%1").arg(rotationAngle()));
+ if (rotation()) {
+ xml_element.setAttribute("rotation", QString("%1").arg(rotation()));
}
if (!isBlack()) {
xml_element.setAttribute("color", "white");
@@ -104,36 +104,6 @@
}
/**
- @return l'angle de rotation de ce champ de texte
-*/
-qreal PartText::rotationAngle() const {
- return(rotation());
-}
-
-/**
- @param angle Le nouvel angle de rotation de ce champ de texte
-*/
-void PartText::setRotationAngle(const qreal &angle) {
- setRotation(QET::correctAngle(angle));
-}
-
-/**
- @return true or false if this static text is rendered black or white,
- respectively.
-*/
-bool PartText::isBlack() const {
- return(defaultTextColor() == Qt::black);
-}
-
-/**
- @param color whether this static text should be rendered black (true) or white
- (false).
-*/
-void PartText::setBlack(bool color) {
- setDefaultTextColor(color ? Qt::black : Qt::white);
-}
-
-/**
@return Les coordonnees du point situe en bas a gauche du texte.
*/
QPointF PartText::margin() const {
@@ -204,72 +174,6 @@
}
/**
- Specifie la valeur d'une propriete donnee du texte statique
- @param property propriete a modifier. Valeurs acceptees :
- * x : abscisse de la position
- * y : ordonnee de la position
- * size : taille du texte
- * text : texte
- * "rotation angle" : amgle de rotation
- @param value Valeur a attribuer a la propriete
-*/
-void PartText::setProperty(const QString &property, const QVariant &value) {
- if (property == "x") {
- if (!value.canConvert(QVariant::Double)) return;
- setPos(value.toDouble(), pos().y());
- } else if (property == "y") {
- if (!value.canConvert(QVariant::Double)) return;
- setPos(pos().x(), value.toDouble());
- } else if (property == "size") {
- if (!value.canConvert(QVariant::Int)) return;
- setFont(QETApp::diagramTextsFont(value.toInt()));
- real_font_size_ = value.toInt();
- } else if (property == "real_size") {
- if (!value.canConvert(QVariant::Double)) return;
- setFont(QETApp::diagramTextsFont(value.toInt()));
- real_font_size_ = value.toDouble();
- } else if (property == "text") {
- setPlainText(value.toString());
- } else if (property == "rotation angle") {
- setRotationAngle(value.toDouble());
- } else if (property == "color") {
- setBlack(value.toBool());
- }
- // adjust item position, especially useful when changing text or size
- adjustItemPosition();
- update();
-}
-
-/**
- Permet d'acceder a la valeur d'une propriete donnee du texte statique
- @param property propriete lue. Valeurs acceptees :
- * x : abscisse de la position
- * y : ordonnee de la position
- * size : taille du texte
- * text : texte
- * "rotation angle" : amgle de rotation
- @return La valeur de la propriete property
-*/
-QVariant PartText::property(const QString &property) {
- if (property == "x") {
- return(pos().x());
- } else if (property == "y") {
- return(pos().y());
- } else if (property == "size") {
- return(font().pointSize());
- } else if (property == "real_size") {
- return(real_font_size_);
- } else if (property == "text") {
- return(toPlainText());
- } else if (property == "rotation angle") {
- return(rotation());
- } else if (property == "color") {
- return(isBlack());
- }
- return(QVariant());
-}
-
-/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
Modified: trunk/sources/editor/parttext.h
===================================================================
--- trunk/sources/editor/parttext.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/parttext.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -19,6 +19,7 @@
#define PART_TEXT_H
#include <QtGui>
#include "customelementpart.h"
+#include "qetapp.h"
class TextEditor;
class ElementPrimitiveDecorator;
/**
@@ -49,23 +50,35 @@
virtual QString xmlName() const { return(QString("text")); }
void fromXml(const QDomElement &);
const QDomElement toXml(QDomDocument &) const;
- qreal rotationAngle() const;
- void setRotationAngle(const qreal &);
- bool isBlack() const;
- void setBlack(bool);
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
+ void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
-
virtual void setDecorator(ElementPrimitiveDecorator *);
virtual bool singleItemPressEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
virtual bool singleItemMoveEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
virtual bool singleItemReleaseEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
virtual bool singleItemDoubleClickEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
+
+ ///PROPERTY
+ void setProperty(const char *name, const QVariant &value) {QGraphicsTextItem::setProperty(name, value);}
+ QVariant property(const char *name) const {return QGraphicsTextItem::property(name);}
+ // Size value
+ Q_PROPERTY(qreal size READ size WRITE setSize)
+ qreal size () const {return font().pointSize();}
+ void setSize (qreal s) {setFont(QETApp::diagramTextsFont(s));}
+ // Real size value
+ Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
+ qreal realSize() const {return real_font_size_;}
+ void setRealSize(qreal rs) {real_font_size_ = rs;}
+ // Color value (true = black , false = white)
+ Q_PROPERTY(bool color READ isBlack WRITE setBlack)
+ bool isBlack() const {return defaultTextColor() == Qt::black;}
+ void setBlack(bool b) {setDefaultTextColor(b ? Qt::black : Qt::white);}
+ // displayed string
+ Q_PROPERTY(QString text READ toPlainText WRITE setPlainText)
public slots:
void adjustItemPosition(int = 0);
Modified: trunk/sources/editor/parttextfield.cpp
===================================================================
--- trunk/sources/editor/parttextfield.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/parttextfield.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -31,6 +31,7 @@
QGraphicsTextItem(parent, scene),
CustomElementPart(editor),
follow_parent_rotations(true),
+ m_tagg("none"),
previous_text(),
decorator_(0)
{
@@ -65,6 +66,8 @@
setProperty("size", font_size);
setPlainText(xml_element.attribute("text"));
+
+ m_tagg = xml_element.attribute("tagg", "none");
qreal default_rotation_angle = 0.0;
if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
@@ -90,9 +93,11 @@
xml_element.setAttribute("y", QString("%1").arg(pos().y()));
xml_element.setAttribute("text", toPlainText());
xml_element.setAttribute("size", font().pointSize());
+ xml_element.setAttribute("tagg", m_tagg);
+
// angle de rotation du champ de texte
- if (rotationAngle()) {
- xml_element.setAttribute("rotation", QString("%1").arg(rotationAngle()));
+ if (rotation()) {
+ xml_element.setAttribute("rotation", QString("%1").arg(rotation()));
}
// suivi (ou non) des rotations de l'element parent par le champ de texte
if (follow_parent_rotations) {
@@ -102,36 +107,6 @@
}
/**
- @return l'angle de rotation de ce champ de texte
-*/
-qreal PartTextField::rotationAngle() const {
- return(rotation());
-}
-
-/**
- @param angle Le nouvel angle de rotation de ce champ de texte
-*/
-void PartTextField::setRotationAngle(const qreal &angle) {
- setRotation(QET::correctAngle(angle));
-}
-
-/**
- @return true si le champ de texte suit les rotation de l'element, false
- sinon
-*/
-bool PartTextField::followParentRotations() {
- return(follow_parent_rotations);
-}
-
-/**
- @param fpr true pour que le champ de texte suive les rotation de
- l'element, false sinon
-*/
-void PartTextField::setFollowParentRotations(bool fpr) {
- follow_parent_rotations = fpr;
-}
-
-/**
@return le decalage entre l'origine du QGraphicsItem et l'origine du champ de
texte.
*/
@@ -246,72 +221,6 @@
}
/**
- Specifie la valeur d'une propriete donnee du champ de texte
- @param property propriete a modifier. Valeurs acceptees :
- * x : abscisse de la position
- * y : ordonnee de la position
- * size : taille du texte
- * text : texte
- * rotate : suivi de la rotation de l'element parent
- @param value Valeur a attribuer a la propriete
-*/
-void PartTextField::setProperty(const QString &property, const QVariant &value) {
- if (property == "x") {
- if (!value.canConvert(QVariant::Double)) return;
- setPos(value.toDouble(), pos().y());
- } else if (property == "y") {
- if (!value.canConvert(QVariant::Double)) return;
- setPos(pos().x(), value.toDouble());
- } else if (property == "size") {
- if (!value.canConvert(QVariant::Int)) return;
- setFont(QETApp::diagramTextsFont(value.toInt()));
- real_font_size_ = value.toInt();
- } else if (property == "real_size") {
- if (!value.canConvert(QVariant::Double)) return;
- setFont(QETApp::diagramTextsFont(value.toInt()));
- real_font_size_ = value.toDouble();
- } else if (property == "text") {
- setPlainText(value.toString());
- } else if (property == "rotation angle") {
- setRotationAngle(value.toDouble());
- } else if (property == "rotate") {
- follow_parent_rotations = value.toBool();
- }
- // adjust item position, especially useful when changing text or size
- adjustItemPosition();
- update();
-}
-
-/**
- Permet d'acceder a la valeur d'une propriete donnee du champ de texte
- @param property propriete lue. Valeurs acceptees :
- * x : abscisse de la position
- * y : ordonnee de la position
- * size : taille du texte
- * text : texte
- * rotate : suivi de la rotation de l'element parent
- @return La valeur de la propriete property
-*/
-QVariant PartTextField::property(const QString &property) {
- if (property == "x") {
- return(pos().x());
- } else if (property == "y") {
- return(pos().y());
- } else if (property == "size") {
- return(font().pointSize());
- } else if (property == "real_size") {
- return(real_font_size_);
- } else if (property == "text") {
- return(toPlainText());
- } else if (property == "rotation angle") {
- return(rotation());
- } else if (property == "rotate") {
- return(follow_parent_rotations);
- }
- return(QVariant());
-}
-
-/**
Gere les changements intervenant sur cette partie
@param change Type de changement
@param value Valeur numerique relative au changement
Modified: trunk/sources/editor/parttextfield.h
===================================================================
--- trunk/sources/editor/parttextfield.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/parttextfield.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -19,6 +19,7 @@
#define PART_TEXTFIELD_H
#include <QtGui>
#include "customelementpart.h"
+#include "qetapp.h"
class TextFieldEditor;
class QETElementEditor;
class ElementPrimitiveDecorator;
@@ -41,6 +42,7 @@
// attributes
bool follow_parent_rotations;
+ QString m_tagg;
// methods
public:
@@ -55,24 +57,44 @@
virtual QString xmlName() const { return(QString("input")); }
void fromXml(const QDomElement &);
const QDomElement toXml(QDomDocument &) const;
- qreal rotationAngle() const;
- void setRotationAngle(const qreal &);
- bool followParentRotations();
- void setFollowParentRotations(bool);
- virtual void setProperty(const QString &, const QVariant &);
- virtual QVariant property(const QString &);
virtual bool isUseless() const;
virtual QRectF sceneGeometricRect() const;
virtual void startUserTransformation(const QRectF &);
virtual void handleUserTransformation(const QRectF &, const QRectF &);
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
-
virtual void setDecorator(ElementPrimitiveDecorator *);
virtual bool singleItemPressEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
virtual bool singleItemMoveEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
virtual bool singleItemReleaseEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
virtual bool singleItemDoubleClickEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
-
+
+ ///PROPERTY
+ virtual void setProperty(const char *name, const QVariant &value) {QGraphicsTextItem::setProperty(name, value);}
+ virtual QVariant property(const char *name) const {return QGraphicsTextItem::property(name);}
+
+ // displayed text
+ Q_PROPERTY(QString text READ toPlainText WRITE setPlainText)
+ // font size
+ Q_PROPERTY(int size READ size WRITE setSize)
+ int size() const {return font().pointSize();}
+ void setSize (const int value) {setFont(QETApp::diagramTextsFont(value)); real_font_size_ = value;}
+ // real size
+ Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
+ qreal realSize() const {return real_font_size_;}
+ void setRealSize(const qreal size) {real_font_size_ = size;}
+ // angle of text
+ Q_PROPERTY(qreal rotation_angle READ rotation WRITE setRotationAngle)
+ void setRotationAngle(const qreal &angle) {setRotation(QET::correctAngle(angle));}
+ // follow parent rotation
+ Q_PROPERTY(bool rotate READ followParentRotations WRITE setFollowParentRotations)
+ bool followParentRotations() const {return follow_parent_rotations;}
+ void setFollowParentRotations(bool i) {follow_parent_rotations = i;}
+ // tagg of text
+ Q_PROPERTY(QString tagg READ tagg WRITE setTagg)
+ QString tagg() const {return m_tagg;}
+ void setTagg(const QString &tagg) {m_tagg = tagg;}
+
+
public slots:
void adjustItemPosition(int = 0);
void setEditable(bool);
Modified: trunk/sources/editor/rectangleeditor.cpp
===================================================================
--- trunk/sources/editor/rectangleeditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/rectangleeditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -30,15 +30,15 @@
{
style_ = new StyleEditor(editor);
- x = new QLineEdit();
- y = new QLineEdit();
- w = new QLineEdit();
- h = new QLineEdit();
+ x = new QDoubleSpinBox();
+ y = new QDoubleSpinBox();
+ w = new QDoubleSpinBox();
+ h = new QDoubleSpinBox();
- x -> setValidator(new QDoubleValidator(x));
- y -> setValidator(new QDoubleValidator(y));
- w -> setValidator(new QDoubleValidator(w));
- h -> setValidator(new QDoubleValidator(h));
+ x->setRange(-1000, 1000);
+ y->setRange(-1000, 1000);
+ w->setRange(-1000, 1000);
+ h->setRange(-1000, 1000);
QVBoxLayout *v_layout = new QVBoxLayout(this);
@@ -101,20 +101,20 @@
*/
void RectangleEditor::updateRectangle() {
if (!part) return;
- part -> setProperty("x", x -> text().toDouble());
- part -> setProperty("y", y -> text().toDouble());
- part -> setProperty("width", w -> text().toDouble());
- part -> setProperty("height", h -> text().toDouble());
+ part -> setProperty("x", x -> value());
+ part -> setProperty("y", y -> value());
+ part -> setProperty("width", w -> value());
+ part -> setProperty("height", h -> value());
}
/// Met a jour l'abscisse du coin superieur gauche du rectangle et cree un objet d'annulation
-void RectangleEditor::updateRectangleX() { addChangePartCommand(tr("abscisse"), part, "x", x -> text().toDouble()); }
+void RectangleEditor::updateRectangleX() { addChangePartCommand(tr("abscisse"), part, "x", x -> value()); }
/// Met a jour l'ordonnee du coin superieur gauche du rectangle et cree un objet d'annulation
-void RectangleEditor::updateRectangleY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> text().toDouble()); }
+void RectangleEditor::updateRectangleY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> value()); }
/// Met a jour la largeur du rectangle et cree un objet d'annulation
-void RectangleEditor::updateRectangleW() { addChangePartCommand(tr("largeur"), part, "width", w -> text().toDouble()); }
+void RectangleEditor::updateRectangleW() { addChangePartCommand(tr("largeur"), part, "width", w -> value()); }
/// Met a jour la hauteur du rectangle et cree un objet d'annulation
-void RectangleEditor::updateRectangleH() { addChangePartCommand(tr("hauteur"), part, "height", h -> text().toDouble()); }
+void RectangleEditor::updateRectangleH() { addChangePartCommand(tr("hauteur"), part, "height", h -> value()); }
/**
Met a jour le formulaire d'edition
@@ -122,10 +122,10 @@
void RectangleEditor::updateForm() {
if (!part) return;
activeConnections(false);
- x -> setText(part -> property("x").toString());
- y -> setText(part -> property("y").toString());
- w -> setText(part -> property("width").toString());
- h -> setText(part -> property("height").toString());
+ x->setValue(part->property("x").toReal());
+ y->setValue(part->property("y").toReal());
+ w->setValue(part->property("width").toReal());
+ h->setValue(part->property("height").toReal());
activeConnections(true);
}
Modified: trunk/sources/editor/rectangleeditor.h
===================================================================
--- trunk/sources/editor/rectangleeditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/rectangleeditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -37,7 +37,7 @@
private:
PartRectangle *part;
StyleEditor *style_;
- QLineEdit *x, *y, *w, *h;
+ QDoubleSpinBox *x, *y, *w, *h;
// methods
public:
Modified: trunk/sources/editor/styleeditor.cpp
===================================================================
--- trunk/sources/editor/styleeditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/styleeditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -98,42 +98,34 @@
/// Destructeur
StyleEditor::~StyleEditor() {
}
-
/**
- Met a jour le style de la partie a partir des donnees du formulaire
-*/
+ * @brief StyleEditor::updatePart
+ * Update the part from the content of the form
+ */
void StyleEditor::updatePart() {
if (!part) return;
- // applique l'antialiasing
- part -> setAntialiased(antialiasing -> isChecked());
-
- // applique la couleur
- part -> setColor(static_cast<CEGP::Color>(outline_color -> currentIndex()));
-
- // applique le style
- part -> setLineStyle(static_cast<CEGP::LineStyle>(line_style -> currentIndex()));
-
- // applique l'epaisseur
- part -> setLineWeight(static_cast<CEGP::LineWeight>(size_weight -> currentIndex()));
-
- // applique le remplissage
- part -> setFilling(static_cast<CEGP::Filling>(filling_color -> currentIndex()));
+ part->setProperty("antialias", antialiasing -> isChecked());
+ part->setProperty("color", outline_color -> itemData(outline_color -> currentIndex()));
+ part->setProperty("line_style", line_style -> itemData(line_style -> currentIndex()));
+ part->setProperty("line_weight", size_weight -> itemData(size_weight -> currentIndex()));
+ part->setProperty("filling", filling_color -> itemData(filling_color -> currentIndex()));
}
-/// Met a jour l'antialiasing et cree un objet d'annulation
+/// Update antialiasing with undo command
void StyleEditor::updatePartAntialiasing() { addChangePartCommand(tr("style antialiasing"), part, "antialias", antialiasing -> isChecked()); }
-/// Met a jour la couleur du trait et cree un objet d'annulation
-void StyleEditor::updatePartColor() { addChangePartCommand(tr("style couleur"), part, "color", outline_color -> currentIndex());}
-/// Met a jour le style du trait et cree un objet d'annulation
-void StyleEditor::updatePartLineStyle() { addChangePartCommand(tr("style ligne"), part, "line-style", line_style -> currentIndex());}
-/// Met a jour l'epaisseur du trait et cree un objet d'annulation
-void StyleEditor::updatePartLineWeight() { addChangePartCommand(tr("style epaisseur"), part, "line-weight", size_weight -> currentIndex());}
-/// Met a jour la couleur de fond et cree un objet d'annulation
-void StyleEditor::updatePartFilling() { addChangePartCommand(tr("style remplissage"), part, "filling", filling_color -> currentIndex());}
+/// Update color with undo command
+void StyleEditor::updatePartColor() { addChangePartCommand(tr("style couleur"), part, "color", outline_color->itemData(outline_color -> currentIndex()));}
+/// Update style with undo command
+void StyleEditor::updatePartLineStyle() { addChangePartCommand(tr("style ligne"), part, "line_style", line_style->itemData(line_style -> currentIndex()));}
+/// Update weight with undo command
+void StyleEditor::updatePartLineWeight() { addChangePartCommand(tr("style epaisseur"), part, "line_weight", size_weight->itemData(size_weight -> currentIndex()));}
+/// Update color filling with undo command
+void StyleEditor::updatePartFilling() { addChangePartCommand(tr("style remplissage"), part, "filling", filling_color->itemData(filling_color -> currentIndex()));}
/**
- Met a jour le formulaire d'edition
-*/
+ * @brief StyleEditor::updateForm
+ * Update the edition form
+ */
void StyleEditor::updateForm() {
if (!part) return;
activeConnections(false);
Modified: trunk/sources/editor/terminaleditor.cpp
===================================================================
--- trunk/sources/editor/terminaleditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/terminaleditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -29,22 +29,18 @@
ElementItemEditor(editor, parent),
part(term)
{
- qle_x = new QLineEdit();
- qle_y = new QLineEdit();
+ qle_x = new QDoubleSpinBox();
+ qle_y = new QDoubleSpinBox();
- qle_x -> setValidator(new QDoubleValidator(qle_x));
- qle_y -> setValidator(new QDoubleValidator(qle_y));
+ qle_x -> setRange(-1000, 1000);
+ qle_y -> setRange(-1000, 1000);
orientation = new QComboBox();
- orientation -> addItem(QET::Icons::North, tr("Nord"), QET::North);
- orientation -> addItem(QET::Icons::East, tr("Est"), QET::East);
- orientation -> addItem(QET::Icons::South, tr("Sud"), QET::South);
- orientation -> addItem(QET::Icons::West, tr("Ouest"), QET::West);
+ orientation -> addItem(QET::Icons::North, tr("Nord"), Qet::North);
+ orientation -> addItem(QET::Icons::East, tr("Est"), Qet::East);
+ orientation -> addItem(QET::Icons::South, tr("Sud"), Qet::South);
+ orientation -> addItem(QET::Icons::West, tr("Ouest"), Qet::West);
- qle_number = new QLineEdit();
- qle_name = new QLineEdit();
- qcheck_name_visible = new QCheckBox(tr("Visible"));
-
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
@@ -60,17 +56,6 @@
ori -> addWidget(orientation );
main_layout -> addLayout(ori);
- QHBoxLayout *name = new QHBoxLayout();
- name -> addWidget(new QLabel(tr("Nom : ")));
- name -> addWidget(qle_name );
- name -> addWidget(qcheck_name_visible );
- main_layout -> addLayout(name);
-
- QHBoxLayout *num = new QHBoxLayout();
- num -> addWidget(new QLabel(tr("Num\351ro : ")));
- num -> addWidget(qle_number );
- main_layout -> addLayout(num);
-
main_layout -> addStretch();
setLayout(main_layout);
@@ -116,51 +101,34 @@
*/
void TerminalEditor::updateTerminal() {
if (!part) return;
- part -> setPos(qle_x -> text().toDouble(), qle_y -> text().toDouble());
+ part -> setPos(qle_x -> value(), qle_y -> value());
part -> setOrientation(
- static_cast<QET::Orientation>(
+ static_cast<Qet::Orientation>(
orientation -> itemData(
orientation -> currentIndex()
).toInt()
)
);
- part -> setNumber( qle_number->text() );
- part -> setName ( qle_name->text() );
- part -> setNameHidden( !qcheck_name_visible ->isChecked() );
}
/// WARNING!!!! on addChangePartCommand the prop accept only the simple string! (NOT /:;,?...)
/// Met a jour l'abscisse de la position de la borne et cree un objet d'annulation
-void TerminalEditor::updateTerminalX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
+void TerminalEditor::updateTerminalX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> value()); }
/// Met a jour l'ordonnee de la position de la borne et cree un objet d'annulation
-void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
+void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> value()); }
/// Met a jour l'orientation de la borne et cree un objet d'annulation
-void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex()).toInt()); }
+void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex())); }
/// update Number and name, create cancel object
-void TerminalEditor::updateTerminalNum() {
- addChangePartCommand(tr("num\351ro: ")+qle_number -> text(), part, "number", qle_number -> text());
- updateForm();
-}
-void TerminalEditor::updateTerminalName() {
- addChangePartCommand(tr("nom: ")+qle_name -> text(), part, "name", qle_name -> text());
- updateForm();
-}
-void TerminalEditor::updateTerminalNameVisible() {
- addChangePartCommand(tr("nom visible: ")+QString::number( qcheck_name_visible->isChecked()), part, "nameHidden", !qcheck_name_visible -> isChecked());
- updateForm();
-}
+
/**
Met a jour le formulaire d'edition
*/
void TerminalEditor::updateForm() {
if (!part) return;
activeConnections(false);
- qle_x -> setText(part -> property("x").toString());
- qle_y -> setText(part -> property("y").toString());
- orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
- qle_number -> setText(part -> number() );
- qle_name -> setText(part -> nameOfTerminal() );
- qcheck_name_visible ->setChecked( !part -> nameIsHidden() );
+ qle_x -> setValue(part->property("x").toReal());
+ qle_y -> setValue(part->property("y").toReal());
+ orientation -> setCurrentIndex(orientation->findData(part->property("orientation")));
activeConnections(true);
}
@@ -173,15 +141,9 @@
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
- connect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
- connect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
- connect(qcheck_name_visible, SIGNAL(stateChanged ( int)), this, SLOT(updateTerminalNameVisible()));
} else {
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
disconnect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
- disconnect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
- disconnect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
- disconnect(qcheck_name_visible, SIGNAL(stateChanged ( int)), this, SLOT(updateTerminalNameVisible()));
}
}
Modified: trunk/sources/editor/terminaleditor.h
===================================================================
--- trunk/sources/editor/terminaleditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/terminaleditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -35,10 +35,8 @@
// attributes
private:
PartTerminal *part;
- QLineEdit *qle_x, *qle_y;
+ QDoubleSpinBox *qle_x, *qle_y;
QComboBox *orientation;
- QLineEdit *qle_number, *qle_name;
- QCheckBox *qcheck_name_visible;
// methods
public:
@@ -50,9 +48,6 @@
void updateTerminalX();
void updateTerminalY();
void updateTerminalO();
- void updateTerminalNum();
- void updateTerminalName();
- void updateTerminalNameVisible();
void updateForm();
private:
Modified: trunk/sources/editor/texteditor.cpp
===================================================================
--- trunk/sources/editor/texteditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/texteditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -30,8 +30,8 @@
ElementItemEditor(editor, parent),
part(text)
{
- qle_x = new QLineEdit();
- qle_y = new QLineEdit();
+ qle_x = new QDoubleSpinBox();
+ qle_y = new QDoubleSpinBox();
qle_text = new QLineEdit();
font_size = new QSpinBox();
font_size -> setRange(0, 144);
@@ -45,8 +45,8 @@
rotation_angle_label -> setWordWrap(true);
rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
- qle_x -> setValidator(new QDoubleValidator(qle_x));
- qle_y -> setValidator(new QDoubleValidator(qle_y));
+ qle_x -> setRange(-1000, 1000);
+ qle_y -> setRange(-1000, 1000);
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
@@ -128,13 +128,13 @@
if (!part) return;
part -> setProperty("size", font_size -> value());
part -> setPlainText(qle_text -> text());
- part -> setPos(qle_x -> text().toDouble(), qle_y -> text().toDouble());
+ part -> setPos(qle_x -> value(), qle_y -> value());
}
/// Met a jour l'abscisse de la position du texte et cree un objet d'annulation
-void TextEditor::updateTextX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
+void TextEditor::updateTextX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> value()); }
/// Met a jour l'ordonnee de la position du texte et cree un objet d'annulation
-void TextEditor::updateTextY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
+void TextEditor::updateTextY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> value()); }
/// Met a jour le texte et cree un objet d'annulation
void TextEditor::updateTextT() { addChangePartCommand(tr("contenu"), part, "text", qle_text -> text()); }
/// Met a jour la taille du texte et cree un objet d'annulation
@@ -142,7 +142,7 @@
/// Update the text color and create an undo object
void TextEditor::updateTextC() { addChangePartCommand(tr("couleur", "undo caption"), part, "color", color_ -> checkedId()); }
/// Met a jour l'angle de rotation du champ de texte et cree un objet d'annulation
-void TextEditor::updateTextRotationAngle() { addChangePartCommand(tr("angle de rotation"), part, "rotation angle", rotation_angle_ -> value()); }
+void TextEditor::updateTextRotationAngle() { addChangePartCommand(tr("angle de rotation"), part, "rotation", rotation_angle_ -> value()); }
/**
Met a jour le formulaire a partir du champ de texte
@@ -150,14 +150,14 @@
void TextEditor::updateForm() {
if (!part) return;
activeConnections(false);
- qle_x -> setText(part -> property("x").toString());
- qle_y -> setText(part -> property("y").toString());
+ qle_x -> setValue(part->property("x").toReal());
+ qle_y -> setValue(part->property("y").toReal());
qle_text -> setText(part -> property("text").toString());
font_size -> setValue(part -> property("size").toInt());
if (QAbstractButton *button = color_ -> button(part -> property("color").toBool())) {
button -> setChecked(true);
}
- rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
+ rotation_angle_ -> setValue(part -> property("rotation").toReal());
activeConnections(true);
}
Modified: trunk/sources/editor/texteditor.h
===================================================================
--- trunk/sources/editor/texteditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/texteditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -37,7 +37,8 @@
// attributes
private:
PartText *part;
- QLineEdit *qle_x, *qle_y, *qle_text;
+ QLineEdit *qle_text;
+ QDoubleSpinBox *qle_x, *qle_y;
QSpinBox *font_size;
QButtonGroup *color_;
QRadioButton *black_color_, *white_color_;
Modified: trunk/sources/editor/textfieldeditor.cpp
===================================================================
--- trunk/sources/editor/textfieldeditor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/textfieldeditor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -29,8 +29,8 @@
ElementItemEditor(editor, parent),
part(textfield)
{
- qle_x = new QLineEdit();
- qle_y = new QLineEdit();
+ qle_x = new QDoubleSpinBox();
+ qle_y = new QDoubleSpinBox();
qle_text = new QLineEdit();
font_size = new QSpinBox();
font_size -> setRange(0, 144);
@@ -40,8 +40,8 @@
rotation_angle_label -> setWordWrap(true);
rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
- qle_x -> setValidator(new QDoubleValidator(qle_x));
- qle_y -> setValidator(new QDoubleValidator(qle_y));
+ qle_x -> setRange (-1000, 1000);
+ qle_y -> setRange (-1000, 1000);
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
@@ -62,6 +62,14 @@
t -> addWidget(new QLabel(tr("Texte par d\351faut : ")));
t -> addWidget(qle_text);
main_layout -> addLayout(t);
+
+ //add the tagg combobox
+ QHBoxLayout *tagg_layout = new QHBoxLayout();
+ tagg_layout -> addWidget(new QLabel(tr("tagg :")));
+ tagg_layout -> addWidget(m_tagg_cb = new QComboBox());
+ m_tagg_cb -> addItem(tr("Aucun"), QVariant("none"));
+ m_tagg_cb -> addItem(tr("label"), QVariant("label"));
+ main_layout -> addLayout(tagg_layout);
QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
rotation_angle_layout -> addWidget(rotation_angle_label);
@@ -117,14 +125,15 @@
if (!part) return;
part -> setProperty("size", font_size -> value());
part -> setPlainText(qle_text -> text());
- part -> setPos(qle_x -> text().toDouble(), qle_y -> text().toDouble());
+ part -> setPos(qle_x->value(), qle_y->value());
part -> setFollowParentRotations(!rotate -> isChecked());
+ part -> setTagg(m_tagg_cb->itemData(m_tagg_cb->currentIndex()).toString());
}
/// Met a jour l'abscisse de la position du champ de texte et cree un objet d'annulation
-void TextFieldEditor::updateTextFieldX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
+void TextFieldEditor::updateTextFieldX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> value()); }
/// Met a jour l'ordonnee de la position du champ de texte et cree un objet d'annulation
-void TextFieldEditor::updateTextFieldY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
+void TextFieldEditor::updateTextFieldY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> value()); }
/// Met a jour le texte du champ de texte et cree un objet d'annulation
void TextFieldEditor::updateTextFieldT() { addChangePartCommand(tr("contenu"), part, "text", qle_text -> text()); }
/// Met a jour la taille du champ de texte et cree un objet d'annulation
@@ -132,7 +141,8 @@
/// 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()); }
+void TextFieldEditor::updateTextFieldRotationAngle() { addChangePartCommand(tr("angle de rotation"), part, "rotation_angle", rotation_angle_ -> value()); }
+void TextFieldEditor::updateTagg() { addChangePartCommand(tr("tagg"), part, "tagg", m_tagg_cb->itemData(m_tagg_cb->currentIndex()).toString());}
/**
Met a jour le formulaire d'edition
@@ -140,12 +150,14 @@
void TextFieldEditor::updateForm() {
if (!part) return;
activeConnections(false);
- qle_x -> setText(part -> property("x").toString());
- qle_y -> setText(part -> property("y").toString());
+ qle_x -> setValue(part->property("x").toReal());
+ qle_y -> setValue(part->property("y").toReal());
qle_text -> setText(part -> property("text").toString());
font_size -> setValue(part -> property("size").toInt());
- rotate -> setChecked(!part -> property("rotate").toBool());
+ rotate -> setChecked(!part -> property("rotate").toBool());
rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
+ m_tagg_cb->setCurrentIndex(m_tagg_cb->findData(part->property("tagg")));
+
activeConnections(true);
}
@@ -155,18 +167,20 @@
*/
void TextFieldEditor::activeConnections(bool active) {
if (active) {
- connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
- connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
- 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()));
+ connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
+ connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
+ 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()));
+ connect(m_tagg_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTagg()));
} 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()));
+ 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()));
+ connect(m_tagg_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTagg()));
}
}
Modified: trunk/sources/editor/textfieldeditor.h
===================================================================
--- trunk/sources/editor/textfieldeditor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/editor/textfieldeditor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -36,8 +36,10 @@
// attributes
private:
PartTextField *part;
- QLineEdit *qle_x, *qle_y, *qle_text;
+ QLineEdit *qle_text;
+ QComboBox *m_tagg_cb;
QSpinBox *font_size;
+ QDoubleSpinBox *qle_x, *qle_y;
QCheckBox *rotate;
QTextOrientationSpinBoxWidget *rotation_angle_;
@@ -54,6 +56,7 @@
void updateTextFieldS();
void updateTextFieldR();
void updateTextFieldRotationAngle();
+ void updateTagg();
void updateForm();
private:
Modified: trunk/sources/orientationset.cpp
===================================================================
--- trunk/sources/orientationset.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/orientationset.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -27,8 +27,8 @@
east_ori(true),
south_ori(true),
west_ori(true),
- default_ori(QET::North),
- current_ori(QET::North)
+ default_ori(Qet::North),
+ current_ori(Qet::North)
{}
/**
@@ -42,8 +42,8 @@
north_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
- if (default_ori == QET::North) default_ori = next();
- if (current_ori == QET::North) current_ori = next();
+ if (default_ori == Qet::North) default_ori = next();
+ if (current_ori == Qet::North) current_ori = next();
}
}
return(can_set_ori);
@@ -60,8 +60,8 @@
east_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
- if (default_ori == QET::East) default_ori = next();
- if (current_ori == QET::East) current_ori = next();
+ if (default_ori == Qet::East) default_ori = next();
+ if (current_ori == Qet::East) current_ori = next();
}
}
return(can_set_ori);
@@ -78,8 +78,8 @@
south_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
- if (default_ori == QET::South) default_ori = next();
- if (current_ori == QET::South) current_ori = next();
+ if (default_ori == Qet::South) default_ori = next();
+ if (current_ori == Qet::South) current_ori = next();
}
}
return(can_set_ori);
@@ -96,8 +96,8 @@
west_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
- if (default_ori == QET::West) default_ori = next();
- if (current_ori == QET::West) current_ori = next();
+ if (default_ori == Qet::West) default_ori = next();
+ if (current_ori == Qet::West) current_ori = next();
}
}
return(can_set_ori);
@@ -108,7 +108,7 @@
@param ori nouvelle orientation courante
@return true si le changement d'orientation a reussi, false sinon
*/
-bool OrientationSet::setCurrent(QET::Orientation ori) {
+bool OrientationSet::setCurrent(Qet::Orientation ori) {
bool can_set_ori = accept(ori);
if (can_set_ori) current_ori = ori;
return(can_set_ori);
@@ -117,18 +117,18 @@
/**
@return l'orientation suivant l'orientation courante
*/
-QET::Orientation OrientationSet::next() const {
- QET::Orientation result = current_ori;
- do result = QET::nextOrientation(result); while (!accept(result));
+Qet::Orientation OrientationSet::next() const {
+ Qet::Orientation result = current_ori;
+ do result = Qet::nextOrientation(result); while (!accept(result));
return(result);
}
/**
@return l'orientation precedant l'orientation courante
*/
-QET::Orientation OrientationSet::previous() const {
- QET::Orientation result = current_ori;
- do result = QET::previousOrientation(result); while (!accept(result));
+Qet::Orientation OrientationSet::previous() const {
+ Qet::Orientation result = current_ori;
+ do result = Qet::previousOrientation(result); while (!accept(result));
return(result);
}
@@ -157,13 +157,13 @@
@param ori L'orientation en question
@return true si l'orientation est utilisable, false sinon
*/
-bool OrientationSet::accept(QET::Orientation ori) const {
+bool OrientationSet::accept(Qet::Orientation ori) const {
bool accepted_ori = false;
switch(ori) {
- case QET::North: accepted_ori = north_ori; break;
- case QET::East : accepted_ori = east_ori; break;
- case QET::South: accepted_ori = south_ori; break;
- case QET::West : accepted_ori = west_ori; break;
+ case Qet::North: accepted_ori = north_ori; break;
+ case Qet::East : accepted_ori = east_ori; break;
+ case Qet::South: accepted_ori = south_ori; break;
+ case Qet::West : accepted_ori = west_ori; break;
}
return(accepted_ori);
}
@@ -172,7 +172,7 @@
Definit l'orientation suivante comme etant l'orientation courante
@return la nouvelle orientation courante
*/
-QET::Orientation OrientationSet::setNext() {
+Qet::Orientation OrientationSet::setNext() {
setCurrent(next());
return(current_ori);
}
@@ -181,7 +181,7 @@
Definit l'orientation precedente comme etant l'orientation courante
@return la nouvelle orientation courante
*/
-QET::Orientation OrientationSet::setPrevious() {
+Qet::Orientation OrientationSet::setPrevious() {
setCurrent(previous());
return(current_ori);
}
@@ -245,7 +245,7 @@
if (matches.count("d") != 1) return(false);
bool *ori_pointers[4] = { &north_ori, &east_ori, &south_ori, &west_ori };
- QET::Orientation ori_ints[4] = { QET::North, QET::East, QET::South, QET::West };
+ Qet::Orientation ori_ints[4] = { Qet::North, Qet::East, Qet::South, Qet::West };
for(int i = 0 ; i < 4 ; ++ i) {
QString current = matches.at(i + 1);
if (current == "d") {
@@ -263,7 +263,7 @@
*/
QString OrientationSet::toString() const {
bool ori_pointers[4] = { north_ori, east_ori, south_ori, west_ori };
- QET::Orientation ori_ints[4] = { QET::North, QET::East, QET::South, QET::West };
+ Qet::Orientation ori_ints[4] = { Qet::North, Qet::East, Qet::South, Qet::West };
QString result("");
for(int i = 0 ; i < 4 ; ++ i) {
if (default_ori == ori_ints[i]) result += "d";
Modified: trunk/sources/orientationset.h
===================================================================
--- trunk/sources/orientationset.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/orientationset.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -38,8 +38,8 @@
bool east_ori;
bool south_ori;
bool west_ori;
- QET::Orientation default_ori;
- QET::Orientation current_ori;
+ Qet::Orientation default_ori;
+ Qet::Orientation current_ori;
// methods
public:
@@ -51,15 +51,15 @@
bool setEast(bool);
bool setSouth(bool);
bool setWest(bool);
- QET::Orientation defaultOrientation() const;
- void setDefaultOrientation(const QET::Orientation &);
- QET::Orientation current() const;
- bool setCurrent(QET::Orientation);
- QET::Orientation next() const;
- QET::Orientation previous() const;
- QET::Orientation setNext();
- QET::Orientation setPrevious();
- bool accept(QET::Orientation) const;
+ Qet::Orientation defaultOrientation() const;
+ void setDefaultOrientation(const Qet::Orientation &);
+ Qet::Orientation current() const;
+ bool setCurrent(Qet::Orientation);
+ Qet::Orientation next() const;
+ Qet::Orientation previous() const;
+ Qet::Orientation setNext();
+ Qet::Orientation setPrevious();
+ bool accept(Qet::Orientation) const;
const OrientationSet operator++(int);
const OrientationSet operator--(int);
const OrientationSet operator++();
@@ -101,21 +101,21 @@
/**
@param new_default_orientation The new default orientation
*/
-inline void OrientationSet::setDefaultOrientation(const QET::Orientation& new_default_orientation) {
+inline void OrientationSet::setDefaultOrientation(const Qet::Orientation& new_default_orientation) {
default_ori = new_default_orientation;
}
/**
@return the default orientation
*/
-inline QET::Orientation OrientationSet::defaultOrientation() const {
+inline Qet::Orientation OrientationSet::defaultOrientation() const {
return(default_ori);
}
/**
@return the current orientation
*/
-inline QET::Orientation OrientationSet::current() const {
+inline Qet::Orientation OrientationSet::current() const {
return(current_ori);
}
Modified: trunk/sources/qet.cpp
===================================================================
--- trunk/sources/qet.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/qet.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -22,30 +22,30 @@
/**
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
en orientation. Si la chaine fait plusieurs caracteres, seul le
- premier est pris en compte. En cas d'incoherence, QET::North est
+ premier est pris en compte. En cas d'incoherence, Qet::North est
retourne.
@param s Chaine de caractere cense representer une orientation
@return l'orientation designee par la chaine de caractere
*/
-QET::Orientation QET::orientationFromString(const QString &s) {
+Qet::Orientation Qet::orientationFromString(const QString &s) {
QChar c = s[0];
- if (c == 'e') return(QET::East);
- else if (c == 's') return(QET::South);
- else if (c == 'w') return (QET::West);
- else return(QET::North);
+ if (c == 'e') return(Qet::East);
+ else if (c == 's') return(Qet::South);
+ else if (c == 'w') return (Qet::West);
+ else return(Qet::North);
}
/**
@param o une orientation
@return une chaine de caractere representant l'orientation
*/
-QString QET::orientationToString(QET::Orientation o) {
+QString Qet::orientationToString(Qet::Orientation o) {
QString ret;
switch(o) {
- case QET::North: ret = "n"; break;
- case QET::East : ret = "e"; break;
- case QET::South: ret = "s"; break;
- case QET::West : ret = "w"; break;
+ case Qet::North: ret = "n"; break;
+ case Qet::East : ret = "e"; break;
+ case Qet::South: ret = "s"; break;
+ case Qet::West : ret = "w"; break;
}
return(ret);
}
@@ -56,9 +56,9 @@
@param b La seconde orientation de Borne
@return Un booleen a true si les deux orientations de bornes sont sur le meme axe
*/
-bool QET::surLeMemeAxe(QET::Orientation a, QET::Orientation b) {
- if ((a == QET::North || a == QET::South) && (b == QET::North || b == QET::South)) return(true);
- else if ((a == QET::East || a == QET::West) && (b == QET::East || b == QET::West)) return(true);
+bool Qet::surLeMemeAxe(Qet::Orientation a, Qet::Orientation b) {
+ if ((a == Qet::North || a == Qet::South) && (b == Qet::North || b == Qet::South)) return(true);
+ else if ((a == Qet::East || a == Qet::West) && (b == Qet::East || b == Qet::West)) return(true);
else return(false);
}
@@ -67,8 +67,8 @@
@param a L'orientation de borne
@return True si l'orientation de borne est horizontale, false sinon
*/
-bool QET::estHorizontale(QET::Orientation a) {
- return(a == QET::East || a == QET::West);
+bool Qet::estHorizontale(Qet::Orientation a) {
+ return(a == Qet::East || a == Qet::West);
}
/**
@@ -76,8 +76,8 @@
@param a L'orientation de borne
@return True si l'orientation de borne est verticale, false sinon
*/
-bool QET::estVerticale(QET::Orientation a) {
- return(a == QET::North || a == QET::South);
+bool Qet::estVerticale(Qet::Orientation a) {
+ return(a == Qet::North || a == Qet::South);
}
/**
@@ -87,9 +87,9 @@
@param o une orientation
@return l'orientation suivante
*/
-QET::Orientation QET::nextOrientation(QET::Orientation o) {
- if (o < 0 || o > 2) return(QET::North);
- return((QET::Orientation)(o + 1));
+Qet::Orientation Qet::nextOrientation(Qet::Orientation o) {
+ if (o < 0 || o > 2) return(Qet::North);
+ return((Qet::Orientation)(o + 1));
}
/**
@@ -99,10 +99,10 @@
@param o une orientation
@return l'orientation precedente
*/
-QET::Orientation QET::previousOrientation(QET::Orientation o) {
- if (o < 0 || o > 3) return(QET::North);
- if (o == QET::North) return(QET::West);
- return((QET::Orientation)(o - 1));
+Qet::Orientation Qet::previousOrientation(Qet::Orientation o) {
+ if (o < 0 || o > 3) return(Qet::North);
+ if (o == Qet::North) return(Qet::West);
+ return((Qet::Orientation)(o - 1));
}
/**
@@ -465,13 +465,13 @@
@param end_type un type d'extremite
@return une chaine representant le type d'extremite
*/
-QString QET::endTypeToString(const QET::EndType &end_type) {
+QString Qet::endTypeToString(const Qet::EndType &end_type) {
switch(end_type) {
- case QET::Simple: return("simple");
- case QET::Triangle: return("triangle");
- case QET::Circle: return("circle");
- case QET::Diamond: return("diamond");
- case QET::None:
+ case Qet::Simple: return("simple");
+ case Qet::Triangle: return("triangle");
+ case Qet::Circle: return("circle");
+ case Qet::Diamond: return("diamond");
+ case Qet::None:
default:
return("none");
}
@@ -482,12 +482,12 @@
@return le type d'extremite correspondant ; si la chaine est invalide,
QET::None est retourne.
*/
-QET::EndType QET::endTypeFromString(const QString &string) {
- if (string == "simple") return(QET::Simple);
- else if (string == "triangle") return(QET::Triangle);
- else if (string == "circle") return(QET::Circle);
- else if (string == "diamond") return(QET::Diamond);
- else return(QET::None);
+Qet::EndType Qet::endTypeFromString(const QString &string) {
+ if (string == "simple") return(Qet::Simple);
+ else if (string == "triangle") return(Qet::Triangle);
+ else if (string == "circle") return(Qet::Circle);
+ else if (string == "diamond") return(Qet::Diamond);
+ else return(Qet::None);
}
/**
Modified: trunk/sources/qet.h
===================================================================
--- trunk/sources/qet.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/qet.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -18,6 +18,7 @@
#ifndef _QET_H
#define _QET_H
#include <QtXml>
+#include <QObject>
/**
This file provides useful functions and enums that may be used from
anywhere else within the QElectroTech application.
@@ -28,8 +29,6 @@
/// QElectroTech displayed version
const QString displayedVersion = "0.4-dev";
QString license();
- /// Orientation (used for electrical elements and their terminals)
- enum Orientation {North, East, South, West};
/// Oriented movements
enum OrientedMovement {
@@ -73,17 +72,6 @@
Both = 3 ///< Invalid segment
};
- /**
- This enum lists the various available endings for line primitives when drawing
- an electrical element.
- */
- enum EndType {
- None, ///< Regular line
- Simple, ///< Base-less triangle
- Triangle, ///< Triangle
- Circle, ///< Circle
- Diamond ///< Diamond
- };
/**
This enums lists the various kind of items users can manage within the
@@ -141,13 +129,6 @@
RelativeToRemainingLength ///< the length is just a fraction of the length that is still available when other types of lengths have been removed
};
- QET::Orientation nextOrientation(QET::Orientation);
- QET::Orientation previousOrientation(QET::Orientation);
- QET::Orientation orientationFromString(const QString &);
- QString orientationToString(QET::Orientation);
- bool surLeMemeAxe(QET::Orientation, QET::Orientation);
- bool estHorizontale(QET::Orientation);
- bool estVerticale(QET::Orientation);
bool lineContainsPoint(const QLineF &, const QPointF &);
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = 0);
bool attributeIsAnInteger(const QDomElement &, QString , int * = NULL);
@@ -163,8 +144,6 @@
QString unescapeSpaces(const QString &);
QString joinWithSpaces(const QStringList &);
QStringList splitWithSpaces(const QString &);
- QString endTypeToString(const QET::EndType &);
- QET::EndType endTypeFromString(const QString &);
QString diagramAreaToString(const QET::DiagramArea &);
QET::DiagramArea diagramAreaFromString(const QString &);
QString pointerString(void *);
@@ -176,4 +155,35 @@
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
QPointF graphicsSceneEventPos(QEvent *);
}
+
+class Qet : public QObject {
+ Q_OBJECT
+ public:
+ ///This enum lists the various available endings for line primitives when drawing an electrical element.
+ Q_ENUMS(EndType)
+ enum EndType {
+ None, ///< Regular line
+ Simple, ///< Base-less triangle
+ Triangle, ///< Triangle
+ Circle, ///< Circle
+ Diamond ///< Diamond
+ };
+ static QString endTypeToString(const Qet::EndType &);
+ static Qet::EndType endTypeFromString(const QString &);
+
+ /// Orientation (used for electrical elements and their terminals)
+ Q_ENUMS(Orientation)
+ enum Orientation {North,
+ East,
+ South,
+ West};
+ static Qet::Orientation nextOrientation(Qet::Orientation);
+ static Qet::Orientation previousOrientation(Qet::Orientation);
+ static Qet::Orientation orientationFromString(const QString &);
+ static QString orientationToString(Qet::Orientation);
+ static bool surLeMemeAxe(Qet::Orientation, Qet::Orientation);
+ static bool estHorizontale(Qet::Orientation);
+ static bool estVerticale(Qet::Orientation);
+};
+
#endif
Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/qetgraphicsitem/conductor.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -162,7 +162,7 @@
@param p2 Coordonnees du point d'amarrage de la borne 2
@param o2 Orientation de la borne 2
*/
-void Conductor::updateConductorPath(const QPointF &p1, QET::Orientation o1, const QPointF &p2, QET::Orientation o2) {
+void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
Q_UNUSED(o1);
Q_UNUSED(o2);
@@ -290,9 +290,9 @@
@param p2 Coordonnees du point d'amarrage de la borne 2
@param o2 Orientation de la borne 2
*/
-void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, const QPointF &p2, QET::Orientation o2) {
+void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
QPointF sp1, sp2, depart, newp1, newp2, arrivee, depart0, arrivee0;
- QET::Orientation ori_depart, ori_arrivee;
+ Qet::Orientation ori_depart, ori_arrivee;
// s'assure qu'il n'y a ni points
QList<QPointF> points;
@@ -331,38 +331,38 @@
// commence le vrai trajet
if (depart.y() < arrivee.y()) {
// trajet descendant
- if ((ori_depart == QET::North && (ori_arrivee == QET::South || ori_arrivee == QET::West)) || (ori_depart == QET::East && ori_arrivee == QET::West)) {
+ if ((ori_depart == Qet::North && (ori_arrivee == Qet::South || ori_arrivee == Qet::West)) || (ori_depart == Qet::East && ori_arrivee == Qet::West)) {
// cas "3"
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
points << QPointF(ligne_inter_x, depart.y());
points << QPointF(ligne_inter_x, arrivee.y());
- } else if ((ori_depart == QET::South && (ori_arrivee == QET::North || ori_arrivee == QET::East)) || (ori_depart == QET::West && ori_arrivee == QET::East)) {
+ } else if ((ori_depart == Qet::South && (ori_arrivee == Qet::North || ori_arrivee == Qet::East)) || (ori_depart == Qet::West && ori_arrivee == Qet::East)) {
// cas "4"
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
points << QPointF(depart.x(), ligne_inter_y);
points << QPointF(arrivee.x(), ligne_inter_y);
- } else if ((ori_depart == QET::North || ori_depart == QET::East) && (ori_arrivee == QET::North || ori_arrivee == QET::East)) {
+ } else if ((ori_depart == Qet::North || ori_depart == Qet::East) && (ori_arrivee == Qet::North || ori_arrivee == Qet::East)) {
points << QPointF(arrivee.x(), depart.y()); // cas "2"
} else {
points << QPointF(depart.x(), arrivee.y()); // cas "1"
}
} else {
// trajet montant
- if ((ori_depart == QET::West && (ori_arrivee == QET::East || ori_arrivee == QET::South)) || (ori_depart == QET::North && ori_arrivee == QET::South)) {
+ if ((ori_depart == Qet::West && (ori_arrivee == Qet::East || ori_arrivee == Qet::South)) || (ori_depart == Qet::North && ori_arrivee == Qet::South)) {
// cas "3"
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
points << QPointF(depart.x(), ligne_inter_y);
points << QPointF(arrivee.x(), ligne_inter_y);
- } else if ((ori_depart == QET::East && (ori_arrivee == QET::West || ori_arrivee == QET::North)) || (ori_depart == QET::South && ori_arrivee == QET::North)) {
+ } else if ((ori_depart == Qet::East && (ori_arrivee == Qet::West || ori_arrivee == Qet::North)) || (ori_depart == Qet::South && ori_arrivee == Qet::North)) {
// cas "4"
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
points << QPointF(ligne_inter_x, depart.y());
points << QPointF(ligne_inter_x, arrivee.y());
- } else if ((ori_depart == QET::West || ori_depart == QET::North) && (ori_arrivee == QET::West || ori_arrivee == QET::North)) {
+ } else if ((ori_depart == Qet::West || ori_depart == Qet::North) && (ori_arrivee == Qet::West || ori_arrivee == Qet::North)) {
points << QPointF(depart.x(), arrivee.y()); // cas "2"
} else {
points << QPointF(arrivee.x(), depart.y()); // cas "1"
@@ -393,19 +393,19 @@
@param ext_size la taille de la prolongation
@return le point correspondant a la borne apres prolongation
*/
-QPointF Conductor::extendTerminal(const QPointF &terminal, QET::Orientation terminal_orientation, qreal ext_size) {
+QPointF Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation terminal_orientation, qreal ext_size) {
QPointF extended_terminal;
switch(terminal_orientation) {
- case QET::North:
+ case Qet::North:
extended_terminal = QPointF(terminal.x(), terminal.y() - ext_size);
break;
- case QET::East:
+ case Qet::East:
extended_terminal = QPointF(terminal.x() + ext_size, terminal.y());
break;
- case QET::South:
+ case Qet::South:
extended_terminal = QPointF(terminal.x(), terminal.y() + ext_size);
break;
- case QET::West:
+ case Qet::West:
extended_terminal = QPointF(terminal.x() - ext_size, terminal.y());
break;
default: extended_terminal = terminal;
Modified: trunk/sources/qetgraphicsitem/conductor.h
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/qetgraphicsitem/conductor.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -146,8 +146,8 @@
private:
void segmentsToPath();
void saveProfile(bool = true);
- void generateConductorPath(const QPointF &, QET::Orientation, const QPointF &, QET::Orientation);
- void updateConductorPath(const QPointF &, QET::Orientation, const QPointF &, QET::Orientation);
+ void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
+ void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
QList<QPointF> segmentsToPoints() const;
QSet<Conductor *> relatedConductors() const;
@@ -161,7 +161,7 @@
static int getCoeff(const qreal &, const qreal &);
static int getSign(const qreal &);
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
- static QPointF extendTerminal(const QPointF &, QET::Orientation, qreal = 9.0);
+ static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
static qreal conductor_bound(qreal, qreal, qreal, qreal = 0.0);
static qreal conductor_bound(qreal, qreal, bool);
static Qt::Corner movementType(const QPointF &, const QPointF &);
Modified: trunk/sources/qetgraphicsitem/customelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/customelement.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/qetgraphicsitem/customelement.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -323,8 +323,8 @@
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
- QET::EndType first_end = QET::endTypeFromString(e.attribute("end1"));
- QET::EndType second_end = QET::endTypeFromString(e.attribute("end2"));
+ Qet::EndType first_end = Qet::endTypeFromString(e.attribute("end1"));
+ Qet::EndType second_end = Qet::endTypeFromString(e.attribute("end2"));
qreal length1, length2;
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 1.5;
@@ -362,23 +362,23 @@
QPointF start_point, stop_point;
if (draw_1st_end) {
QList<QPointF> four_points1(PartLine::fourEndPoints(point1, point2, length1));
- if (first_end == QET::Circle) {
+ if (first_end == Qet::Circle) {
qp.drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
start_point = four_points1[1];
- } else if (first_end == QET::Diamond) {
+ } else if (first_end == Qet::Diamond) {
qp.drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[1];
- } else if (first_end == QET::Simple) {
+ } else if (first_end == Qet::Simple) {
qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
start_point = point1;
- } else if (first_end == QET::Triangle) {
+ } else if (first_end == Qet::Triangle) {
qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[0];
}
// ajuste le depart selon l'epaisseur du trait
- if (pen_width && (first_end == QET::Simple || first_end == QET::Circle)) {
+ if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle)) {
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
}
} else {
@@ -388,22 +388,22 @@
// dessine la seconde extremite
if (draw_2nd_end) {
QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2));
- if (second_end == QET::Circle) {
+ if (second_end == Qet::Circle) {
qp.drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
stop_point = four_points2[1];
- } else if (second_end == QET::Diamond) {
+ } else if (second_end == Qet::Diamond) {
qp.drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
stop_point = four_points2[1];
- } else if (second_end == QET::Simple) {
+ } else if (second_end == Qet::Simple) {
qp.drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
stop_point = point2;
- } else if (second_end == QET::Triangle) {
+ } else if (second_end == Qet::Triangle) {
qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
stop_point = four_points2[0];
}
// ajuste l'arrivee selon l'epaisseur du trait
- if (pen_width && (second_end == QET::Simple || second_end == QET::Circle)) {
+ if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle)) {
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
}
} else {
@@ -749,14 +749,14 @@
Terminal *CustomElement::parseTerminal(QDomElement &e) {
// verifie la presence et la validite des attributs obligatoires
qreal terminalx, terminaly;
- QET::Orientation terminalo;
+ Qet::Orientation terminalo;
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
if (!e.hasAttribute("orientation")) return(0);
- if (e.attribute("orientation") == "n") terminalo = QET::North;
- else if (e.attribute("orientation") == "s") terminalo = QET::South;
- else if (e.attribute("orientation") == "e") terminalo = QET::East;
- else if (e.attribute("orientation") == "w") terminalo = QET::West;
+ if (e.attribute("orientation") == "n") terminalo = Qet::North;
+ else if (e.attribute("orientation") == "s") terminalo = Qet::South;
+ else if (e.attribute("orientation") == "e") terminalo = Qet::East;
+ else if (e.attribute("orientation") == "w") terminalo = Qet::West;
else return(0);
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
Modified: trunk/sources/qetgraphicsitem/ghostelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/ghostelement.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/qetgraphicsitem/ghostelement.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -124,16 +124,16 @@
// modifie certains attributs pour que l'analyse par la classe CustomElement reussisse
int previous_x_value = qde.attribute("x").toInt();
int previous_y_value = qde.attribute("y").toInt();
- int previous_ori_value = qde.attribute("orientation").toInt();
+ Qet::Orientation previous_ori_value = static_cast<Qet::Orientation>(qde.attribute("orientation").toInt());
qreal x_add = 0.0, y_add = 0.0;
- if (previous_ori_value == QET::North) y_add = -Terminal::terminalSize;
- else if (previous_ori_value == QET::East) x_add = Terminal::terminalSize;
- else if (previous_ori_value == QET::South) y_add = Terminal::terminalSize;
- else if (previous_ori_value == QET::West) x_add = -Terminal::terminalSize;
+ if (previous_ori_value == Qet::North) y_add = -Terminal::terminalSize;
+ else if (previous_ori_value == Qet::East) x_add = Terminal::terminalSize;
+ else if (previous_ori_value == Qet::South) y_add = Terminal::terminalSize;
+ else if (previous_ori_value == Qet::West) x_add = -Terminal::terminalSize;
qde.setAttribute("x", previous_x_value + x_add);
qde.setAttribute("y", previous_y_value + y_add);
- qde.setAttribute("orientation", QET::orientationToString(static_cast<QET::Orientation>(previous_ori_value)));
+ qde.setAttribute("orientation", previous_ori_value);
if (Terminal *new_terminal = CustomElement::parseTerminal(qde)) {
table_id_adr.insert(qde.attribute("id").toInt(), new_terminal);
Modified: trunk/sources/terminal.cpp
===================================================================
--- trunk/sources/terminal.cpp 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/terminal.cpp 2014-05-29 13:46:04 UTC (rev 3088)
@@ -35,21 +35,21 @@
@param number of terminal
@param name of terminal
*/
-void Terminal::init(QPointF pf, QET::Orientation o, QString number, QString name, bool hiddenName) {
+void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName) {
// definition du pount d'amarrage pour un conducteur
dock_conductor_ = pf;
// definition de l'orientation de la borne (par defaut : sud)
- if (o < QET::North || o > QET::West) ori_ = QET::South;
+ if (o < Qet::North || o > Qet::West) ori_ = Qet::South;
else ori_ = o;
// calcul de la position du point d'amarrage a l'element
dock_elmt_ = dock_conductor_;
switch(ori_) {
- case QET::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
- case QET::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
- case QET::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
- case QET::South:
+ case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
+ case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
+ case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
+ case Qet::South:
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
}
// Number of terminal
@@ -76,7 +76,7 @@
@param e Element auquel cette borne appartient
@param s Scene sur laquelle figure cette borne
*/
-Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
+Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e, Diagram *s) :
QGraphicsItem(e, s),
parent_element_(e),
hovered_color_(Terminal::neutralColor)
@@ -92,7 +92,7 @@
@param e Element auquel cette borne appartient
@param s Scene sur laquelle figure cette borne
*/
-Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagram *s) :
+Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e, Diagram *s) :
QGraphicsItem(e, s),
parent_element_(e),
hovered_color_(Terminal::neutralColor)
@@ -110,7 +110,7 @@
@param e Element auquel cette borne appartient
@param s Scene sur laquelle figure cette borne
*/
-Terminal::Terminal(QPointF pf, QET::Orientation o, QString num, QString name, bool hiddenName, Element *e, Diagram *s) :
+Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e, Diagram *s) :
QGraphicsItem(e, s),
parent_element_(e),
hovered_color_(Terminal::neutralColor)
@@ -135,7 +135,7 @@
pivote. Sinon elle renvoie son sens normal.
@return L'orientation actuelle de la Terminal.
*/
-QET::Orientation Terminal::orientation() const {
+Qet::Orientation Terminal::orientation() const {
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
// orientations actuelle et par defaut de l'element
int ori_cur = elt -> orientation();
@@ -145,7 +145,7 @@
// angle de rotation de la borne sur la scene, divise par 90
int angle = ori_cur + ori_;
while (angle >= 4) angle -= 4;
- return((QET::Orientation)angle);
+ return((Qet::Orientation)angle);
}
} else return(ori_);
}
@@ -513,7 +513,7 @@
// parse l'orientation
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
if (!conv_ok) return(false);
- if (terminal_or != QET::North && terminal_or != QET::South && terminal_or != QET::East && terminal_or != QET::West) return(false);
+ if (terminal_or != Qet::North && terminal_or != Qet::South && terminal_or != Qet::East && terminal_or != Qet::West) return(false);
// a ce stade, la borne est syntaxiquement correcte
return(true);
Modified: trunk/sources/terminal.h
===================================================================
--- trunk/sources/terminal.h 2014-05-28 22:32:14 UTC (rev 3087)
+++ trunk/sources/terminal.h 2014-05-29 13:46:04 UTC (rev 3088)
@@ -31,9 +31,9 @@
// constructors, destructor
public:
- Terminal(QPointF, QET::Orientation, Element * = 0, Diagram * = 0);
- Terminal(qreal, qreal, QET::Orientation, Element * = 0, Diagram * = 0);
- Terminal(QPointF, QET::Orientation, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0);
+ Terminal(QPointF, Qet::Orientation, Element * = 0, Diagram * = 0);
+ Terminal(qreal, qreal, Qet::Orientation, Element * = 0, Diagram * = 0);
+ Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0);
virtual ~Terminal();
private:
@@ -60,7 +60,7 @@
Element *parentElement() const;
QList<Conductor *> conductors() const;
- QET::Orientation orientation() const;
+ Qet::Orientation orientation() const;
QPointF dockConductor() const;
QString number() const;
QString name() const;
@@ -108,7 +108,7 @@
/// docking point for parent element
QPointF dock_elmt_;
/// terminal orientation
- QET::Orientation ori_;
+ Qet::Orientation ori_;
/// List of conductors attached to the terminal
QList<Conductor *> conductors_;
/// Pointer to a rectangle representing the terminal bounding rect;
@@ -128,7 +128,7 @@
bool name_terminal_hidden;
private:
- void init(QPointF, QET::Orientation, QString number, QString name, bool hiddenName);
+ void init(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName);
};
/**