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

@@ -39,9 +39,9 @@ class ConductorProfile {
/// Segments composing the conductor
QList<ConductorSegmentProfile *> segments;
/// Orientation of the start terminal
QET::Orientation beginOrientation;
Qet::Orientation beginOrientation;
/// Orientation of the end terminal.
QET::Orientation endOrientation;
Qet::Orientation endOrientation;
// methods
public:

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);
LineStyle lineStyle() const;
LineWeight lineWeight() const;
Filling filling() const;
Color color() const;
bool antialiased() const;
/// 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;}
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
* @brief PartArc::setX
* @param x is the center of the rect bounding this ellipse
*/
void PartArc::setProperty(const QString &property, const QVariant &value) {
CustomElementGraphicPart::setProperty(property, value);
if (!value.canConvert(QVariant::Double)) return;
if (property == "x") {
void PartArc::setX(const qreal 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") {
setRect(current_rect.translated(x - current_pos.x(), 0.0));
}
/**
* @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, value.toDouble() - current_pos.y()));
} else if (property == "diameter_h") {
qreal new_width = qAbs(value.toDouble());
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);
} else if (property == "diameter_v") {
qreal new_height = qAbs(value.toDouble());
}
/**
* @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);
} else if (property == "start_angle") {
setStartAngle(value.toInt() );
} else if (property == "angle") {
setAngle(value.toInt());
}
update();
}
/**
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());
}
/**
@@ -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,17 +54,38 @@ 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,67 +106,33 @@ 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") {
void PartEllipse::setX(const qreal 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") {
setRect(current_rect.translated(x - current_pos.x(), 0.0));
}
void PartEllipse::setY(const qreal 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());
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);
} else if (property == "diameter_v") {
qreal new_height = qAbs(value.toDouble());
}
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);
}
update();
}
/**
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());
}
/**
Gere les changements intervenant sur cette partie

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,13 +49,29 @@ 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
* @brief PartLine::setX1
* set X of P1
* @param x1
*/
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();
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
* @brief PartLine::setY1
* set y of P1
* @param y1
*/
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());
void PartLine::setY1(qreal y1) {
QPointF p = line().p1();
p.setY(y1);
setLine(QLineF(p, line().p2()));
}
return(QVariant());
/**
* @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,37 +52,24 @@ 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 &);
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
* @brief PartRectangle::setX
* @param x new value
*/
void PartRectangle::setProperty(const QString &property, const QVariant &value) {
CustomElementGraphicPart::setProperty(property, value);
if (!value.canConvert(QVariant::Double)) return;
if (property == "x") {
void PartRectangle::setX(qreal 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();
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
* @brief PartRectangle::setY
* @param y new value
*/
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());
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()));
}
return(QVariant());
/**
* @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,13 +49,29 @@ 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,22 +53,24 @@ 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,24 +50,36 @@ 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);
void setEditable(bool);

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)
{
@@ -66,6 +67,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)) {
setRotationAngle(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,41 +98,33 @@ 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;

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 : ")));
@@ -63,6 +63,14 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
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);
rotation_angle_layout -> addWidget(rotation_angle_);
@@ -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());
rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
m_tagg_cb->setCurrentIndex(m_tagg_cb->findData(part->property("tagg")));
activeConnections(true);
}
@@ -161,6 +173,7 @@ void TextFieldEditor::activeConnections(bool active) {
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()));
@@ -168,5 +181,6 @@ void TextFieldEditor::activeConnections(bool active) {
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:

View File

@@ -27,8 +27,8 @@ OrientationSet::OrientationSet() :
east_ori(true),
south_ori(true),
west_ori(true),
default_ori(QET::North),
current_ori(QET::North)
default_ori(Qet::North),
current_ori(Qet::North)
{}
/**
@@ -42,8 +42,8 @@ bool OrientationSet::setNorth (bool ori) {
north_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
if (default_ori == QET::North) default_ori = next();
if (current_ori == QET::North) current_ori = next();
if (default_ori == Qet::North) default_ori = next();
if (current_ori == Qet::North) current_ori = next();
}
}
return(can_set_ori);
@@ -60,8 +60,8 @@ bool OrientationSet::setEast (bool ori) {
east_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
if (default_ori == QET::East) default_ori = next();
if (current_ori == QET::East) current_ori = next();
if (default_ori == Qet::East) default_ori = next();
if (current_ori == Qet::East) current_ori = next();
}
}
return(can_set_ori);
@@ -78,8 +78,8 @@ bool OrientationSet::setSouth (bool ori) {
south_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
if (default_ori == QET::South) default_ori = next();
if (current_ori == QET::South) current_ori = next();
if (default_ori == Qet::South) default_ori = next();
if (current_ori == Qet::South) current_ori = next();
}
}
return(can_set_ori);
@@ -96,8 +96,8 @@ bool OrientationSet::setWest (bool ori) {
west_ori = ori;
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
if (!ori) {
if (default_ori == QET::West) default_ori = next();
if (current_ori == QET::West) current_ori = next();
if (default_ori == Qet::West) default_ori = next();
if (current_ori == Qet::West) current_ori = next();
}
}
return(can_set_ori);
@@ -108,7 +108,7 @@ bool OrientationSet::setWest (bool ori) {
@param ori nouvelle orientation courante
@return true si le changement d'orientation a reussi, false sinon
*/
bool OrientationSet::setCurrent(QET::Orientation ori) {
bool OrientationSet::setCurrent(Qet::Orientation ori) {
bool can_set_ori = accept(ori);
if (can_set_ori) current_ori = ori;
return(can_set_ori);
@@ -117,18 +117,18 @@ bool OrientationSet::setCurrent(QET::Orientation ori) {
/**
@return l'orientation suivant l'orientation courante
*/
QET::Orientation OrientationSet::next() const {
QET::Orientation result = current_ori;
do result = QET::nextOrientation(result); while (!accept(result));
Qet::Orientation OrientationSet::next() const {
Qet::Orientation result = current_ori;
do result = Qet::nextOrientation(result); while (!accept(result));
return(result);
}
/**
@return l'orientation precedant l'orientation courante
*/
QET::Orientation OrientationSet::previous() const {
QET::Orientation result = current_ori;
do result = QET::previousOrientation(result); while (!accept(result));
Qet::Orientation OrientationSet::previous() const {
Qet::Orientation result = current_ori;
do result = Qet::previousOrientation(result); while (!accept(result));
return(result);
}
@@ -157,13 +157,13 @@ const OrientationSet OrientationSet::operator--(int) {
@param ori L'orientation en question
@return true si l'orientation est utilisable, false sinon
*/
bool OrientationSet::accept(QET::Orientation ori) const {
bool OrientationSet::accept(Qet::Orientation ori) const {
bool accepted_ori = false;
switch(ori) {
case QET::North: accepted_ori = north_ori; break;
case QET::East : accepted_ori = east_ori; break;
case QET::South: accepted_ori = south_ori; break;
case QET::West : accepted_ori = west_ori; break;
case Qet::North: accepted_ori = north_ori; break;
case Qet::East : accepted_ori = east_ori; break;
case Qet::South: accepted_ori = south_ori; break;
case Qet::West : accepted_ori = west_ori; break;
}
return(accepted_ori);
}
@@ -172,7 +172,7 @@ bool OrientationSet::accept(QET::Orientation ori) const {
Definit l'orientation suivante comme etant l'orientation courante
@return la nouvelle orientation courante
*/
QET::Orientation OrientationSet::setNext() {
Qet::Orientation OrientationSet::setNext() {
setCurrent(next());
return(current_ori);
}
@@ -181,7 +181,7 @@ QET::Orientation OrientationSet::setNext() {
Definit l'orientation precedente comme etant l'orientation courante
@return la nouvelle orientation courante
*/
QET::Orientation OrientationSet::setPrevious() {
Qet::Orientation OrientationSet::setPrevious() {
setCurrent(previous());
return(current_ori);
}
@@ -245,7 +245,7 @@ bool OrientationSet::fromString(const QString &str) {
if (matches.count("d") != 1) return(false);
bool *ori_pointers[4] = { &north_ori, &east_ori, &south_ori, &west_ori };
QET::Orientation ori_ints[4] = { QET::North, QET::East, QET::South, QET::West };
Qet::Orientation ori_ints[4] = { Qet::North, Qet::East, Qet::South, Qet::West };
for(int i = 0 ; i < 4 ; ++ i) {
QString current = matches.at(i + 1);
if (current == "d") {
@@ -263,7 +263,7 @@ bool OrientationSet::fromString(const QString &str) {
*/
QString OrientationSet::toString() const {
bool ori_pointers[4] = { north_ori, east_ori, south_ori, west_ori };
QET::Orientation ori_ints[4] = { QET::North, QET::East, QET::South, QET::West };
Qet::Orientation ori_ints[4] = { Qet::North, Qet::East, Qet::South, Qet::West };
QString result("");
for(int i = 0 ; i < 4 ; ++ i) {
if (default_ori == ori_ints[i]) result += "d";

View File

@@ -38,8 +38,8 @@ class OrientationSet {
bool east_ori;
bool south_ori;
bool west_ori;
QET::Orientation default_ori;
QET::Orientation current_ori;
Qet::Orientation default_ori;
Qet::Orientation current_ori;
// methods
public:
@@ -51,15 +51,15 @@ class OrientationSet {
bool setEast(bool);
bool setSouth(bool);
bool setWest(bool);
QET::Orientation defaultOrientation() const;
void setDefaultOrientation(const QET::Orientation &);
QET::Orientation current() const;
bool setCurrent(QET::Orientation);
QET::Orientation next() const;
QET::Orientation previous() const;
QET::Orientation setNext();
QET::Orientation setPrevious();
bool accept(QET::Orientation) const;
Qet::Orientation defaultOrientation() const;
void setDefaultOrientation(const Qet::Orientation &);
Qet::Orientation current() const;
bool setCurrent(Qet::Orientation);
Qet::Orientation next() const;
Qet::Orientation previous() const;
Qet::Orientation setNext();
Qet::Orientation setPrevious();
bool accept(Qet::Orientation) const;
const OrientationSet operator++(int);
const OrientationSet operator--(int);
const OrientationSet operator++();
@@ -101,21 +101,21 @@ inline bool OrientationSet::west() const {
/**
@param new_default_orientation The new default orientation
*/
inline void OrientationSet::setDefaultOrientation(const QET::Orientation& new_default_orientation) {
inline void OrientationSet::setDefaultOrientation(const Qet::Orientation& new_default_orientation) {
default_ori = new_default_orientation;
}
/**
@return the default orientation
*/
inline QET::Orientation OrientationSet::defaultOrientation() const {
inline Qet::Orientation OrientationSet::defaultOrientation() const {
return(default_ori);
}
/**
@return the current orientation
*/
inline QET::Orientation OrientationSet::current() const {
inline Qet::Orientation OrientationSet::current() const {
return(current_ori);
}

View File

@@ -22,30 +22,30 @@
/**
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
en orientation. Si la chaine fait plusieurs caracteres, seul le
premier est pris en compte. En cas d'incoherence, QET::North est
premier est pris en compte. En cas d'incoherence, Qet::North est
retourne.
@param s Chaine de caractere cense representer une orientation
@return l'orientation designee par la chaine de caractere
*/
QET::Orientation QET::orientationFromString(const QString &s) {
Qet::Orientation Qet::orientationFromString(const QString &s) {
QChar c = s[0];
if (c == 'e') return(QET::East);
else if (c == 's') return(QET::South);
else if (c == 'w') return (QET::West);
else return(QET::North);
if (c == 'e') return(Qet::East);
else if (c == 's') return(Qet::South);
else if (c == 'w') return (Qet::West);
else return(Qet::North);
}
/**
@param o une orientation
@return une chaine de caractere representant l'orientation
*/
QString QET::orientationToString(QET::Orientation o) {
QString Qet::orientationToString(Qet::Orientation o) {
QString ret;
switch(o) {
case QET::North: ret = "n"; break;
case QET::East : ret = "e"; break;
case QET::South: ret = "s"; break;
case QET::West : ret = "w"; break;
case Qet::North: ret = "n"; break;
case Qet::East : ret = "e"; break;
case Qet::South: ret = "s"; break;
case Qet::West : ret = "w"; break;
}
return(ret);
}
@@ -56,9 +56,9 @@ QString QET::orientationToString(QET::Orientation o) {
@param b La seconde orientation de Borne
@return Un booleen a true si les deux orientations de bornes sont sur le meme axe
*/
bool QET::surLeMemeAxe(QET::Orientation a, QET::Orientation b) {
if ((a == QET::North || a == QET::South) && (b == QET::North || b == QET::South)) return(true);
else if ((a == QET::East || a == QET::West) && (b == QET::East || b == QET::West)) return(true);
bool Qet::surLeMemeAxe(Qet::Orientation a, Qet::Orientation b) {
if ((a == Qet::North || a == Qet::South) && (b == Qet::North || b == Qet::South)) return(true);
else if ((a == Qet::East || a == Qet::West) && (b == Qet::East || b == Qet::West)) return(true);
else return(false);
}
@@ -67,8 +67,8 @@ bool QET::surLeMemeAxe(QET::Orientation a, QET::Orientation b) {
@param a L'orientation de borne
@return True si l'orientation de borne est horizontale, false sinon
*/
bool QET::estHorizontale(QET::Orientation a) {
return(a == QET::East || a == QET::West);
bool Qet::estHorizontale(Qet::Orientation a) {
return(a == Qet::East || a == Qet::West);
}
/**
@@ -76,8 +76,8 @@ bool QET::estHorizontale(QET::Orientation a) {
@param a L'orientation de borne
@return True si l'orientation de borne est verticale, false sinon
*/
bool QET::estVerticale(QET::Orientation a) {
return(a == QET::North || a == QET::South);
bool Qet::estVerticale(Qet::Orientation a) {
return(a == Qet::North || a == Qet::South);
}
/**
@@ -87,9 +87,9 @@ bool QET::estVerticale(QET::Orientation a) {
@param o une orientation
@return l'orientation suivante
*/
QET::Orientation QET::nextOrientation(QET::Orientation o) {
if (o < 0 || o > 2) return(QET::North);
return((QET::Orientation)(o + 1));
Qet::Orientation Qet::nextOrientation(Qet::Orientation o) {
if (o < 0 || o > 2) return(Qet::North);
return((Qet::Orientation)(o + 1));
}
/**
@@ -99,10 +99,10 @@ QET::Orientation QET::nextOrientation(QET::Orientation o) {
@param o une orientation
@return l'orientation precedente
*/
QET::Orientation QET::previousOrientation(QET::Orientation o) {
if (o < 0 || o > 3) return(QET::North);
if (o == QET::North) return(QET::West);
return((QET::Orientation)(o - 1));
Qet::Orientation Qet::previousOrientation(Qet::Orientation o) {
if (o < 0 || o > 3) return(Qet::North);
if (o == Qet::North) return(Qet::West);
return((Qet::Orientation)(o - 1));
}
/**
@@ -465,13 +465,13 @@ QStringList QET::splitWithSpaces(const QString &string) {
@param end_type un type d'extremite
@return une chaine representant le type d'extremite
*/
QString QET::endTypeToString(const QET::EndType &end_type) {
QString Qet::endTypeToString(const Qet::EndType &end_type) {
switch(end_type) {
case QET::Simple: return("simple");
case QET::Triangle: return("triangle");
case QET::Circle: return("circle");
case QET::Diamond: return("diamond");
case QET::None:
case Qet::Simple: return("simple");
case Qet::Triangle: return("triangle");
case Qet::Circle: return("circle");
case Qet::Diamond: return("diamond");
case Qet::None:
default:
return("none");
}
@@ -482,12 +482,12 @@ QString QET::endTypeToString(const QET::EndType &end_type) {
@return le type d'extremite correspondant ; si la chaine est invalide,
QET::None est retourne.
*/
QET::EndType QET::endTypeFromString(const QString &string) {
if (string == "simple") return(QET::Simple);
else if (string == "triangle") return(QET::Triangle);
else if (string == "circle") return(QET::Circle);
else if (string == "diamond") return(QET::Diamond);
else return(QET::None);
Qet::EndType Qet::endTypeFromString(const QString &string) {
if (string == "simple") return(Qet::Simple);
else if (string == "triangle") return(Qet::Triangle);
else if (string == "circle") return(Qet::Circle);
else if (string == "diamond") return(Qet::Diamond);
else return(Qet::None);
}
/**

View File

@@ -18,6 +18,7 @@
#ifndef _QET_H
#define _QET_H
#include <QtXml>
#include <QObject>
/**
This file provides useful functions and enums that may be used from
anywhere else within the QElectroTech application.
@@ -28,8 +29,6 @@ namespace QET {
/// QElectroTech displayed version
const QString displayedVersion = "0.4-dev";
QString license();
/// Orientation (used for electrical elements and their terminals)
enum Orientation {North, East, South, West};
/// Oriented movements
enum OrientedMovement {
@@ -73,17 +72,6 @@ namespace QET {
Both = 3 ///< Invalid segment
};
/**
This enum lists the various available endings for line primitives when drawing
an electrical element.
*/
enum EndType {
None, ///< Regular line
Simple, ///< Base-less triangle
Triangle, ///< Triangle
Circle, ///< Circle
Diamond ///< Diamond
};
/**
This enums lists the various kind of items users can manage within the
@@ -141,13 +129,6 @@ namespace QET {
RelativeToRemainingLength ///< the length is just a fraction of the length that is still available when other types of lengths have been removed
};
QET::Orientation nextOrientation(QET::Orientation);
QET::Orientation previousOrientation(QET::Orientation);
QET::Orientation orientationFromString(const QString &);
QString orientationToString(QET::Orientation);
bool surLeMemeAxe(QET::Orientation, QET::Orientation);
bool estHorizontale(QET::Orientation);
bool estVerticale(QET::Orientation);
bool lineContainsPoint(const QLineF &, const QPointF &);
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = 0);
bool attributeIsAnInteger(const QDomElement &, QString , int * = NULL);
@@ -163,8 +144,6 @@ namespace QET {
QString unescapeSpaces(const QString &);
QString joinWithSpaces(const QStringList &);
QStringList splitWithSpaces(const QString &);
QString endTypeToString(const QET::EndType &);
QET::EndType endTypeFromString(const QString &);
QString diagramAreaToString(const QET::DiagramArea &);
QET::DiagramArea diagramAreaFromString(const QString &);
QString pointerString(void *);
@@ -176,4 +155,35 @@ namespace QET {
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
QPointF graphicsSceneEventPos(QEvent *);
}
class Qet : public QObject {
Q_OBJECT
public:
///This enum lists the various available endings for line primitives when drawing an electrical element.
Q_ENUMS(EndType)
enum EndType {
None, ///< Regular line
Simple, ///< Base-less triangle
Triangle, ///< Triangle
Circle, ///< Circle
Diamond ///< Diamond
};
static QString endTypeToString(const Qet::EndType &);
static Qet::EndType endTypeFromString(const QString &);
/// Orientation (used for electrical elements and their terminals)
Q_ENUMS(Orientation)
enum Orientation {North,
East,
South,
West};
static Qet::Orientation nextOrientation(Qet::Orientation);
static Qet::Orientation previousOrientation(Qet::Orientation);
static Qet::Orientation orientationFromString(const QString &);
static QString orientationToString(Qet::Orientation);
static bool surLeMemeAxe(Qet::Orientation, Qet::Orientation);
static bool estHorizontale(Qet::Orientation);
static bool estVerticale(Qet::Orientation);
};
#endif

View File

@@ -162,7 +162,7 @@ void Conductor::segmentsToPath() {
@param p2 Coordonnees du point d'amarrage de la borne 2
@param o2 Orientation de la borne 2
*/
void Conductor::updateConductorPath(const QPointF &p1, QET::Orientation o1, const QPointF &p2, QET::Orientation o2) {
void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
Q_UNUSED(o1);
Q_UNUSED(o2);
@@ -290,9 +290,9 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
@param p2 Coordonnees du point d'amarrage de la borne 2
@param o2 Orientation de la borne 2
*/
void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, const QPointF &p2, QET::Orientation o2) {
void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
QPointF sp1, sp2, depart, newp1, newp2, arrivee, depart0, arrivee0;
QET::Orientation ori_depart, ori_arrivee;
Qet::Orientation ori_depart, ori_arrivee;
// s'assure qu'il n'y a ni points
QList<QPointF> points;
@@ -331,38 +331,38 @@ void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, co
// commence le vrai trajet
if (depart.y() < arrivee.y()) {
// trajet descendant
if ((ori_depart == QET::North && (ori_arrivee == QET::South || ori_arrivee == QET::West)) || (ori_depart == QET::East && ori_arrivee == QET::West)) {
if ((ori_depart == Qet::North && (ori_arrivee == Qet::South || ori_arrivee == Qet::West)) || (ori_depart == Qet::East && ori_arrivee == Qet::West)) {
// cas "3"
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
points << QPointF(ligne_inter_x, depart.y());
points << QPointF(ligne_inter_x, arrivee.y());
} else if ((ori_depart == QET::South && (ori_arrivee == QET::North || ori_arrivee == QET::East)) || (ori_depart == QET::West && ori_arrivee == QET::East)) {
} else if ((ori_depart == Qet::South && (ori_arrivee == Qet::North || ori_arrivee == Qet::East)) || (ori_depart == Qet::West && ori_arrivee == Qet::East)) {
// cas "4"
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
points << QPointF(depart.x(), ligne_inter_y);
points << QPointF(arrivee.x(), ligne_inter_y);
} else if ((ori_depart == QET::North || ori_depart == QET::East) && (ori_arrivee == QET::North || ori_arrivee == QET::East)) {
} else if ((ori_depart == Qet::North || ori_depart == Qet::East) && (ori_arrivee == Qet::North || ori_arrivee == Qet::East)) {
points << QPointF(arrivee.x(), depart.y()); // cas "2"
} else {
points << QPointF(depart.x(), arrivee.y()); // cas "1"
}
} else {
// trajet montant
if ((ori_depart == QET::West && (ori_arrivee == QET::East || ori_arrivee == QET::South)) || (ori_depart == QET::North && ori_arrivee == QET::South)) {
if ((ori_depart == Qet::West && (ori_arrivee == Qet::East || ori_arrivee == Qet::South)) || (ori_depart == Qet::North && ori_arrivee == Qet::South)) {
// cas "3"
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
points << QPointF(depart.x(), ligne_inter_y);
points << QPointF(arrivee.x(), ligne_inter_y);
} else if ((ori_depart == QET::East && (ori_arrivee == QET::West || ori_arrivee == QET::North)) || (ori_depart == QET::South && ori_arrivee == QET::North)) {
} else if ((ori_depart == Qet::East && (ori_arrivee == Qet::West || ori_arrivee == Qet::North)) || (ori_depart == Qet::South && ori_arrivee == Qet::North)) {
// cas "4"
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
points << QPointF(ligne_inter_x, depart.y());
points << QPointF(ligne_inter_x, arrivee.y());
} else if ((ori_depart == QET::West || ori_depart == QET::North) && (ori_arrivee == QET::West || ori_arrivee == QET::North)) {
} else if ((ori_depart == Qet::West || ori_depart == Qet::North) && (ori_arrivee == Qet::West || ori_arrivee == Qet::North)) {
points << QPointF(depart.x(), arrivee.y()); // cas "2"
} else {
points << QPointF(arrivee.x(), depart.y()); // cas "1"
@@ -393,19 +393,19 @@ void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, co
@param ext_size la taille de la prolongation
@return le point correspondant a la borne apres prolongation
*/
QPointF Conductor::extendTerminal(const QPointF &terminal, QET::Orientation terminal_orientation, qreal ext_size) {
QPointF Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation terminal_orientation, qreal ext_size) {
QPointF extended_terminal;
switch(terminal_orientation) {
case QET::North:
case Qet::North:
extended_terminal = QPointF(terminal.x(), terminal.y() - ext_size);
break;
case QET::East:
case Qet::East:
extended_terminal = QPointF(terminal.x() + ext_size, terminal.y());
break;
case QET::South:
case Qet::South:
extended_terminal = QPointF(terminal.x(), terminal.y() + ext_size);
break;
case QET::West:
case Qet::West:
extended_terminal = QPointF(terminal.x() - ext_size, terminal.y());
break;
default: extended_terminal = terminal;

View File

@@ -146,8 +146,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
private:
void segmentsToPath();
void saveProfile(bool = true);
void generateConductorPath(const QPointF &, QET::Orientation, const QPointF &, QET::Orientation);
void updateConductorPath(const QPointF &, QET::Orientation, const QPointF &, QET::Orientation);
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
QList<QPointF> segmentsToPoints() const;
QSet<Conductor *> relatedConductors() const;
@@ -161,7 +161,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
static int getCoeff(const qreal &, const qreal &);
static int getSign(const qreal &);
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
static QPointF extendTerminal(const QPointF &, QET::Orientation, qreal = 9.0);
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
static qreal conductor_bound(qreal, qreal, qreal, qreal = 0.0);
static qreal conductor_bound(qreal, qreal, bool);
static Qt::Corner movementType(const QPointF &, const QPointF &);

View File

@@ -323,8 +323,8 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
QET::EndType first_end = QET::endTypeFromString(e.attribute("end1"));
QET::EndType second_end = QET::endTypeFromString(e.attribute("end2"));
Qet::EndType first_end = Qet::endTypeFromString(e.attribute("end1"));
Qet::EndType second_end = Qet::endTypeFromString(e.attribute("end2"));
qreal length1, length2;
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 1.5;
@@ -362,23 +362,23 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
QPointF start_point, stop_point;
if (draw_1st_end) {
QList<QPointF> four_points1(PartLine::fourEndPoints(point1, point2, length1));
if (first_end == QET::Circle) {
if (first_end == Qet::Circle) {
qp.drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
start_point = four_points1[1];
} else if (first_end == QET::Diamond) {
} else if (first_end == Qet::Diamond) {
qp.drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[1];
} else if (first_end == QET::Simple) {
} else if (first_end == Qet::Simple) {
qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
start_point = point1;
} else if (first_end == QET::Triangle) {
} else if (first_end == Qet::Triangle) {
qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[0];
}
// ajuste le depart selon l'epaisseur du trait
if (pen_width && (first_end == QET::Simple || first_end == QET::Circle)) {
if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle)) {
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
}
} else {
@@ -388,22 +388,22 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
// dessine la seconde extremite
if (draw_2nd_end) {
QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2));
if (second_end == QET::Circle) {
if (second_end == Qet::Circle) {
qp.drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
stop_point = four_points2[1];
} else if (second_end == QET::Diamond) {
} else if (second_end == Qet::Diamond) {
qp.drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
stop_point = four_points2[1];
} else if (second_end == QET::Simple) {
} else if (second_end == Qet::Simple) {
qp.drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
stop_point = point2;
} else if (second_end == QET::Triangle) {
} else if (second_end == Qet::Triangle) {
qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
stop_point = four_points2[0];
}
// ajuste l'arrivee selon l'epaisseur du trait
if (pen_width && (second_end == QET::Simple || second_end == QET::Circle)) {
if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle)) {
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
}
} else {
@@ -749,14 +749,14 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
Terminal *CustomElement::parseTerminal(QDomElement &e) {
// verifie la presence et la validite des attributs obligatoires
qreal terminalx, terminaly;
QET::Orientation terminalo;
Qet::Orientation terminalo;
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
if (!e.hasAttribute("orientation")) return(0);
if (e.attribute("orientation") == "n") terminalo = QET::North;
else if (e.attribute("orientation") == "s") terminalo = QET::South;
else if (e.attribute("orientation") == "e") terminalo = QET::East;
else if (e.attribute("orientation") == "w") terminalo = QET::West;
if (e.attribute("orientation") == "n") terminalo = Qet::North;
else if (e.attribute("orientation") == "s") terminalo = Qet::South;
else if (e.attribute("orientation") == "e") terminalo = Qet::East;
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
else return(0);
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte

View File

@@ -124,16 +124,16 @@ bool GhostElement::terminalsFromXml(QDomElement &e, QHash<int, Terminal *> &tabl
// modifie certains attributs pour que l'analyse par la classe CustomElement reussisse
int previous_x_value = qde.attribute("x").toInt();
int previous_y_value = qde.attribute("y").toInt();
int previous_ori_value = qde.attribute("orientation").toInt();
Qet::Orientation previous_ori_value = static_cast<Qet::Orientation>(qde.attribute("orientation").toInt());
qreal x_add = 0.0, y_add = 0.0;
if (previous_ori_value == QET::North) y_add = -Terminal::terminalSize;
else if (previous_ori_value == QET::East) x_add = Terminal::terminalSize;
else if (previous_ori_value == QET::South) y_add = Terminal::terminalSize;
else if (previous_ori_value == QET::West) x_add = -Terminal::terminalSize;
if (previous_ori_value == Qet::North) y_add = -Terminal::terminalSize;
else if (previous_ori_value == Qet::East) x_add = Terminal::terminalSize;
else if (previous_ori_value == Qet::South) y_add = Terminal::terminalSize;
else if (previous_ori_value == Qet::West) x_add = -Terminal::terminalSize;
qde.setAttribute("x", previous_x_value + x_add);
qde.setAttribute("y", previous_y_value + y_add);
qde.setAttribute("orientation", QET::orientationToString(static_cast<QET::Orientation>(previous_ori_value)));
qde.setAttribute("orientation", previous_ori_value);
if (Terminal *new_terminal = CustomElement::parseTerminal(qde)) {
table_id_adr.insert(qde.attribute("id").toInt(), new_terminal);

View File

@@ -35,21 +35,21 @@ const qreal Terminal::terminalSize = 4.0;
@param number of terminal
@param name of terminal
*/
void Terminal::init(QPointF pf, QET::Orientation o, QString number, QString name, bool hiddenName) {
void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName) {
// definition du pount d'amarrage pour un conducteur
dock_conductor_ = pf;
// definition de l'orientation de la borne (par defaut : sud)
if (o < QET::North || o > QET::West) ori_ = QET::South;
if (o < Qet::North || o > Qet::West) ori_ = Qet::South;
else ori_ = o;
// calcul de la position du point d'amarrage a l'element
dock_elmt_ = dock_conductor_;
switch(ori_) {
case QET::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
case QET::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
case QET::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
case QET::South:
case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
case Qet::South:
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
}
// Number of terminal
@@ -76,7 +76,7 @@ void Terminal::init(QPointF pf, QET::Orientation o, QString number, QString name
@param e Element auquel cette borne appartient
@param s Scene sur laquelle figure cette borne
*/
Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e, Diagram *s) :
QGraphicsItem(e, s),
parent_element_(e),
hovered_color_(Terminal::neutralColor)
@@ -92,7 +92,7 @@ Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
@param e Element auquel cette borne appartient
@param s Scene sur laquelle figure cette borne
*/
Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagram *s) :
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e, Diagram *s) :
QGraphicsItem(e, s),
parent_element_(e),
hovered_color_(Terminal::neutralColor)
@@ -110,7 +110,7 @@ Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagr
@param e Element auquel cette borne appartient
@param s Scene sur laquelle figure cette borne
*/
Terminal::Terminal(QPointF pf, QET::Orientation o, QString num, QString name, bool hiddenName, Element *e, Diagram *s) :
Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e, Diagram *s) :
QGraphicsItem(e, s),
parent_element_(e),
hovered_color_(Terminal::neutralColor)
@@ -135,7 +135,7 @@ Terminal::~Terminal() {
pivote. Sinon elle renvoie son sens normal.
@return L'orientation actuelle de la Terminal.
*/
QET::Orientation Terminal::orientation() const {
Qet::Orientation Terminal::orientation() const {
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
// orientations actuelle et par defaut de l'element
int ori_cur = elt -> orientation();
@@ -145,7 +145,7 @@ QET::Orientation Terminal::orientation() const {
// angle de rotation de la borne sur la scene, divise par 90
int angle = ori_cur + ori_;
while (angle >= 4) angle -= 4;
return((QET::Orientation)angle);
return((Qet::Orientation)angle);
}
} else return(ori_);
}
@@ -513,7 +513,7 @@ bool Terminal::valideXml(QDomElement &terminal) {
// parse l'orientation
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
if (!conv_ok) return(false);
if (terminal_or != QET::North && terminal_or != QET::South && terminal_or != QET::East && terminal_or != QET::West) return(false);
if (terminal_or != Qet::North && terminal_or != Qet::South && terminal_or != Qet::East && terminal_or != Qet::West) return(false);
// a ce stade, la borne est syntaxiquement correcte
return(true);

View File

@@ -31,9 +31,9 @@ class Terminal : public QGraphicsItem {
// constructors, destructor
public:
Terminal(QPointF, QET::Orientation, Element * = 0, Diagram * = 0);
Terminal(qreal, qreal, QET::Orientation, Element * = 0, Diagram * = 0);
Terminal(QPointF, QET::Orientation, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0);
Terminal(QPointF, Qet::Orientation, Element * = 0, Diagram * = 0);
Terminal(qreal, qreal, Qet::Orientation, Element * = 0, Diagram * = 0);
Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0);
virtual ~Terminal();
private:
@@ -60,7 +60,7 @@ class Terminal : public QGraphicsItem {
Element *parentElement() const;
QList<Conductor *> conductors() const;
QET::Orientation orientation() const;
Qet::Orientation orientation() const;
QPointF dockConductor() const;
QString number() const;
QString name() const;
@@ -108,7 +108,7 @@ class Terminal : public QGraphicsItem {
/// docking point for parent element
QPointF dock_elmt_;
/// terminal orientation
QET::Orientation ori_;
Qet::Orientation ori_;
/// List of conductors attached to the terminal
QList<Conductor *> conductors_;
/// Pointer to a rectangle representing the terminal bounding rect;
@@ -128,7 +128,7 @@ class Terminal : public QGraphicsItem {
bool name_terminal_hidden;
private:
void init(QPointF, QET::Orientation, QString number, QString name, bool hiddenName);
void init(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName);
};
/**