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.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3088 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-05-29 13:46:04 +00:00
parent f639871057
commit 6f51f1eb0d
49 changed files with 777 additions and 1342 deletions

View File

@@ -30,19 +30,19 @@ ArcEditor::ArcEditor(QETElementEditor *editor, PartArc *arc, QWidget *parent) :
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 @@ CustomElementPart *ArcEditor::currentPart() const {
*/
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::updateArcA() { addChangePartCommand(tr("angle"),
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);

View File

@@ -37,7 +37,7 @@ class ArcEditor : public ElementItemEditor {
private:
PartArc *part;
StyleEditor *style_;
QLineEdit *x, *y, *h, *v;
QDoubleSpinBox *x, *y, *h, *v;
QSpinBox *angle, *start_angle;
// methods

View File

@@ -178,52 +178,3 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const {
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());
}

View File

@@ -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 @@ typedef CustomElementGraphicPart CEGP;
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 @@ class CustomElementGraphicPart : public CustomElementPart {
};
/// 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 @@ class CustomElementGraphicPart : public CustomElementPart {
};
/// 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 @@ class CustomElementGraphicPart : public CustomElementPart {
};
/// This enum lists the various line colors available to draw primitives.
Q_ENUMS(Color)
enum Color {
BlackColor, ///< Black line
WhiteColor, ///< White line
@@ -95,20 +102,26 @@ class CustomElementGraphicPart : public CustomElementPart {
// 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;
void setProperty(const QString &, const QVariant &);
QVariant property(const QString &);
virtual void setProperty(const char *name, const QVariant &value) {QObject::setProperty(name, value);}
virtual QVariant property(const char *name) const {return QObject::property(name);}
protected:
void stylesToXml(QDomElement &) const;
@@ -116,80 +129,4 @@ class CustomElementGraphicPart : public CustomElementPart {
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

View File

@@ -64,11 +64,11 @@ class CustomElementPart {
/**
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.

View File

@@ -315,7 +315,7 @@ void AddPartCommand::redo() {
ChangePartCommand::ChangePartCommand(
const QString &name,
CustomElementPart *part,
const QString &prop,
const char *prop,
const QVariant &old_v,
const QVariant &new_v,
QUndoCommand *parent

View File

@@ -176,7 +176,7 @@ class AddPartCommand : public ElementEditionCommand {
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 @@ class ChangePartCommand : public ElementEditionCommand {
/// Changed primitive
CustomElementPart *cep;
/// Changed property
QString property;
const char *property;
/// Former value
QVariant old_value;
/// New value

View File

@@ -54,7 +54,7 @@ QUndoStack &ElementItemEditor::undoStack() const {
@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;

View File

@@ -40,7 +40,7 @@ class ElementItemEditor : public QWidget {
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();

View File

@@ -31,15 +31,15 @@ EllipseEditor::EllipseEditor(QETElementEditor *editor, PartEllipse *ellipse, QWi
{
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 @@ CustomElementPart *EllipseEditor::currentPart() const {
*/
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::updateEllipseV() { addChangePartCommand(tr("diam\350tre vert
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);
}

View File

@@ -37,7 +37,7 @@ class EllipseEditor : public ElementItemEditor {
private:
PartEllipse *part;
StyleEditor *style_;
QLineEdit *x, *y, *h, *v;
QDoubleSpinBox *x, *y, *h, *v;
// methods
public:

View File

@@ -33,34 +33,31 @@ LineEditor::LineEditor(QETElementEditor *editor, PartLine *line, QWidget *parent
{
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 -> setValidator(new QDoubleValidator(end1_length));
end2_length -> setValidator(new QDoubleValidator(end2_length));
end1_length = new QDoubleSpinBox();
end2_length = new QDoubleSpinBox();
QGridLayout *grid = new QGridLayout();
grid -> addWidget(new QLabel("x1"), 0, 0);
@@ -127,40 +124,40 @@ CustomElementPart *LineEditor::currentPart() const {
*/
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 @@ void LineEditor::updateForm() {
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);
}

View File

@@ -37,9 +37,9 @@ class LineEditor : public ElementItemEditor {
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:

View File

@@ -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,77 +124,47 @@ QPointF PartArc::sceneTopLeft() const {
}
/**
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);
}
/**
@@ -211,41 +181,6 @@ QVariant PartArc::itemChange(GraphicsItemChange change, const QVariant &value) {
return(QGraphicsEllipseItem::itemChange(change, value));
}
/**
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.

View File

@@ -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 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
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 &);

View File

@@ -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,66 +106,32 @@ void PartEllipse::fromXml(const QDomElement &qde) {
);
}
/**
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);
}
/**

View File

@@ -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 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
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 &);

View File

@@ -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 @@ PartLine::~PartLine() {
@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 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
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 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
// 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 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const {
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,84 +195,54 @@ void PartLine::fromXml(const QDomElement &qde) {
)
)
);
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));
}
/**
@@ -453,11 +423,11 @@ QRectF PartLine::boundingRect() const {
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());
}
@@ -504,34 +474,6 @@ void PartLine::handleUserTransformation(const QRectF &initial_selection_rect, co
setLine(QLineF(mapFromScene(mapped_points.at(0)), mapFromScene(mapped_points.at(1))));
}
/**
@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 :
@@ -561,33 +503,3 @@ QList<QPointF> PartLine::fourEndPoints(const QPointF &end_point, const QPointF &
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);
}

View File

@@ -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 @@ class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
// 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 @@ class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
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 &);

View File

@@ -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 @@ void PartPolygon::fromXml(const QDomElement &qde) {
}
setPolygon(temp_polygon);
closed = qde.attribute("closed") != "false";
m_closed = qde.attribute("closed") != "false";
}
/**
@@ -81,7 +81,7 @@ const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const {
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,37 +99,10 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
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
@@ -144,7 +117,6 @@ QVariant PartPolygon::itemChange(GraphicsItemChange change, const QVariant &valu
return(QGraphicsPolygonItem::itemChange(change, value));
}
/**
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
conservee / enregistree.

View File

@@ -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 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
// attributes
private:
bool closed;
bool m_closed;
// methods
public:
@@ -51,15 +52,19 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
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 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
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

View File

@@ -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,63 +106,45 @@ void PartRectangle::fromXml(const QDomElement &qde) {
}
/**
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);
}
/**

View File

@@ -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 @@ class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart
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 &);

View File

@@ -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,12 +53,7 @@ void PartTerminal::fromXml(const QDomElement &xml_elmt) {
setPos(QPointF(term_x, term_y));
// lit l'orientation de la borne
_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();
m_orientation = Qet::orientationFromString(xml_elmt.attribute("orientation"));
updateSecondPoint();
}
@@ -76,11 +71,8 @@ const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
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);
}
@@ -135,122 +127,16 @@ QRectF PartTerminal::boundingRect() const {
return(br);
}
/**
@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
@@ -271,11 +157,11 @@ QVariant PartTerminal::itemChange(GraphicsItemChange change, const QVariant &val
*/
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;
}
}

View File

@@ -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 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
// attributes
private:
QET::Orientation _orientation;
Qet::Orientation m_orientation;
QPointF second_point;
QString number_, name_;
bool nameHidden_;
// methods
public:
@@ -54,21 +53,23 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
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 &);

View File

@@ -73,7 +73,7 @@ void PartText::fromXml(const QDomElement &xml_element) {
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 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const {
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");
@@ -103,36 +103,6 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const {
return(xml_element);
}
/**
@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.
*/
@@ -203,72 +173,6 @@ void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
}
}
/**
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

View File

@@ -19,6 +19,7 @@
#define PART_TEXT_H
#include <QtGui>
#include "customelementpart.h"
#include "qetapp.h"
class TextEditor;
class ElementPrimitiveDecorator;
/**
@@ -49,23 +50,35 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
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);

View File

@@ -31,6 +31,7 @@ PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QG
QGraphicsTextItem(parent, scene),
CustomElementPart(editor),
follow_parent_rotations(true),
m_tagg("none"),
previous_text(),
decorator_(0)
{
@@ -65,6 +66,8 @@ void PartTextField::fromXml(const QDomElement &xml_element) {
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 @@ const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
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) {
@@ -101,36 +106,6 @@ const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
return(xml_element);
}
/**
@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.
@@ -245,72 +220,6 @@ void PartTextField::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
}
}
/**
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

View File

@@ -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 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
// attributes
bool follow_parent_rotations;
QString m_tagg;
// methods
public:
@@ -55,24 +57,44 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
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);

View File

@@ -30,15 +30,15 @@ RectangleEditor::RectangleEditor(QETElementEditor *editor, PartRectangle *rect,
{
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 @@ CustomElementPart *RectangleEditor::currentPart() const {
*/
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::updateRectangleH() { addChangePartCommand(tr("hauteur"),
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);
}

View File

@@ -37,7 +37,7 @@ class RectangleEditor : public ElementItemEditor {
private:
PartRectangle *part;
StyleEditor *style_;
QLineEdit *x, *y, *w, *h;
QDoubleSpinBox *x, *y, *w, *h;
// methods
public:

View File

@@ -98,42 +98,34 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
/// 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);

View File

@@ -29,21 +29,17 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
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);
qle_number = new QLineEdit();
qle_name = new QLineEdit();
qcheck_name_visible = new QCheckBox(tr("Visible"));
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);
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
@@ -60,17 +56,6 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
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 @@ CustomElementPart *TerminalEditor::currentPart() const {
*/
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 @@ void TerminalEditor::activeConnections(bool active) {
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()));
}
}

View File

@@ -35,10 +35,8 @@ class TerminalEditor : public ElementItemEditor {
// 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 @@ class TerminalEditor : public ElementItemEditor {
void updateTerminalX();
void updateTerminalY();
void updateTerminalO();
void updateTerminalNum();
void updateTerminalName();
void updateTerminalNameVisible();
void updateForm();
private:

View File

@@ -30,8 +30,8 @@ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent
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 @@ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent
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 @@ void TextEditor::updateText() {
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 @@ void TextEditor::updateTextS() { addChangePartCommand(tr("taille"), part, "
/// 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::updateTextRotationAngle() { addChangePartCommand(tr("angle de r
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);
}

View File

@@ -37,7 +37,8 @@ class TextEditor : public ElementItemEditor {
// 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_;

View File

@@ -29,8 +29,8 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
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 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
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 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
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 @@ void TextFieldEditor::updateTextField() {
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 @@ void TextFieldEditor::updateTextFieldS() { addChangePartCommand(tr("taille"),
/// 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::updateTextFieldRotationAngle() { addChangePartCommand(tr("
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::updateForm() {
*/
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()));
}
}

View File

@@ -36,8 +36,10 @@ class TextFieldEditor : public ElementItemEditor {
// 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 @@ class TextFieldEditor : public ElementItemEditor {
void updateTextFieldS();
void updateTextFieldR();
void updateTextFieldRotationAngle();
void updateTagg();
void updateForm();
private: