mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
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:
@@ -39,9 +39,9 @@ class ConductorProfile {
|
|||||||
/// Segments composing the conductor
|
/// Segments composing the conductor
|
||||||
QList<ConductorSegmentProfile *> segments;
|
QList<ConductorSegmentProfile *> segments;
|
||||||
/// Orientation of the start terminal
|
/// Orientation of the start terminal
|
||||||
QET::Orientation beginOrientation;
|
Qet::Orientation beginOrientation;
|
||||||
/// Orientation of the end terminal.
|
/// Orientation of the end terminal.
|
||||||
QET::Orientation endOrientation;
|
Qet::Orientation endOrientation;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -30,19 +30,19 @@ ArcEditor::ArcEditor(QETElementEditor *editor, PartArc *arc, QWidget *parent) :
|
|||||||
part(arc)
|
part(arc)
|
||||||
{
|
{
|
||||||
style_ = new StyleEditor(editor);
|
style_ = new StyleEditor(editor);
|
||||||
x = new QLineEdit();
|
x = new QDoubleSpinBox();
|
||||||
y = new QLineEdit();
|
y = new QDoubleSpinBox();
|
||||||
h = new QLineEdit();
|
h = new QDoubleSpinBox();
|
||||||
v = new QLineEdit();
|
v = new QDoubleSpinBox();
|
||||||
start_angle = new QSpinBox();
|
start_angle = new QSpinBox();
|
||||||
angle = new QSpinBox();
|
angle = new QSpinBox();
|
||||||
start_angle -> setRange(-360, 360);
|
start_angle -> setRange(-360, 360);
|
||||||
angle -> setRange(-360, 360);
|
angle -> setRange(-360, 360);
|
||||||
|
|
||||||
x -> setValidator(new QDoubleValidator(x));
|
x->setRange(-1000, 1000);
|
||||||
y -> setValidator(new QDoubleValidator(y));
|
y->setRange(-1000, 1000);
|
||||||
h -> setValidator(new QDoubleValidator(h));
|
h->setRange(-1000, 1000);
|
||||||
v -> setValidator(new QDoubleValidator(v));
|
v->setRange(-1000, 1000);
|
||||||
|
|
||||||
QVBoxLayout *v_layout = new QVBoxLayout(this);
|
QVBoxLayout *v_layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -110,22 +110,22 @@ CustomElementPart *ArcEditor::currentPart() const {
|
|||||||
*/
|
*/
|
||||||
void ArcEditor::updateArc() {
|
void ArcEditor::updateArc() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setProperty("x", x -> text().toDouble());
|
part -> setProperty("x", x -> value());
|
||||||
part -> setProperty("y", y -> text().toDouble());
|
part -> setProperty("y", y -> value());
|
||||||
part -> setProperty("diameter_h", h -> text().toDouble());
|
part -> setProperty("diameter_h", h -> value());
|
||||||
part -> setProperty("diameter_v", v -> text().toDouble());
|
part -> setProperty("diameter_v", v -> value());
|
||||||
part -> setProperty("start_angle", -start_angle -> value() + 90);
|
part -> setProperty("start_angle", -start_angle -> value() + 90);
|
||||||
part -> setProperty("angle", -angle -> value());
|
part -> setProperty("angle", -angle -> value());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Met a jour l'abscisse du centre de l'arc et cree un objet d'annulation
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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); }
|
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
|
/// 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() {
|
void ArcEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
x -> setText(part -> property("x").toString());
|
x->setValue(part->property("x").toReal());
|
||||||
y -> setText(part -> property("y").toString());
|
y->setValue(part->property("y").toReal());
|
||||||
h -> setText(part -> property("diameter_h").toString());
|
h->setValue(part->property("diameter_h").toReal());
|
||||||
v -> setText(part -> property("diameter_v").toString());
|
v->setValue(part->property("diameter_v").toReal());
|
||||||
start_angle -> setValue(-part -> startAngle() + 90);
|
start_angle -> setValue(-part -> startAngle() + 90);
|
||||||
angle -> setValue(-part -> angle());
|
angle -> setValue(-part -> angle());
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ArcEditor : public ElementItemEditor {
|
|||||||
private:
|
private:
|
||||||
PartArc *part;
|
PartArc *part;
|
||||||
StyleEditor *style_;
|
StyleEditor *style_;
|
||||||
QLineEdit *x, *y, *h, *v;
|
QDoubleSpinBox *x, *y, *h, *v;
|
||||||
QSpinBox *angle, *start_angle;
|
QSpinBox *angle, *start_angle;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
|||||||
@@ -178,52 +178,3 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const {
|
|||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
painter.setBrush(brush);
|
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());
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#ifndef CUSTOM_ELEMENT_GRAPHIC_PART_H
|
#ifndef CUSTOM_ELEMENT_GRAPHIC_PART_H
|
||||||
#define CUSTOM_ELEMENT_GRAPHIC_PART_H
|
#define CUSTOM_ELEMENT_GRAPHIC_PART_H
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QObject>
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "styleeditor.h"
|
#include "styleeditor.h"
|
||||||
class QETElementEditor;
|
class QETElementEditor;
|
||||||
@@ -26,9 +27,12 @@ typedef CustomElementGraphicPart CEGP;
|
|||||||
This class represents an element visual/geometric primitive. It provides
|
This class represents an element visual/geometric primitive. It provides
|
||||||
methods to manage style attributes common to most primitives.
|
methods to manage style attributes common to most primitives.
|
||||||
*/
|
*/
|
||||||
class CustomElementGraphicPart : public CustomElementPart {
|
class CustomElementGraphicPart : public QObject, public CustomElementPart {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// This enum lists the various line styles available to draw primitives.
|
/// This enum lists the various line styles available to draw primitives.
|
||||||
|
Q_ENUMS(LineStyle)
|
||||||
enum LineStyle {
|
enum LineStyle {
|
||||||
NormalStyle, ///< Normal line
|
NormalStyle, ///< Normal line
|
||||||
DashedStyle, ///< Dashed line
|
DashedStyle, ///< Dashed line
|
||||||
@@ -37,6 +41,7 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// This enum lists the various line weights available to draw primitives.
|
/// This enum lists the various line weights available to draw primitives.
|
||||||
|
Q_ENUMS(LineWeight)
|
||||||
enum LineWeight {
|
enum LineWeight {
|
||||||
NoneWeight, ///< Invisible line
|
NoneWeight, ///< Invisible line
|
||||||
ThinWeight, ///< Thin line
|
ThinWeight, ///< Thin line
|
||||||
@@ -47,6 +52,7 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// This enum lists the various filling colors available to draw primitives.
|
/// This enum lists the various filling colors available to draw primitives.
|
||||||
|
Q_ENUMS(Filling)
|
||||||
enum Filling {
|
enum Filling {
|
||||||
NoneFilling, ///< No filling (i.e. transparent)
|
NoneFilling, ///< No filling (i.e. transparent)
|
||||||
BlackFilling, ///< Black filling
|
BlackFilling, ///< Black filling
|
||||||
@@ -57,6 +63,7 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// This enum lists the various line colors available to draw primitives.
|
/// This enum lists the various line colors available to draw primitives.
|
||||||
|
Q_ENUMS(Color)
|
||||||
enum Color {
|
enum Color {
|
||||||
BlackColor, ///< Black line
|
BlackColor, ///< Black line
|
||||||
WhiteColor, ///< White line
|
WhiteColor, ///< White line
|
||||||
@@ -95,20 +102,26 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
void setLineStyle(LineStyle);
|
|
||||||
void setLineWeight(LineWeight);
|
/// PROPERTY
|
||||||
void setFilling(Filling);
|
Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
|
||||||
void setColor(Color);
|
LineStyle lineStyle() const {return _linestyle;}
|
||||||
void setAntialiased(bool);
|
void setLineStyle(const LineStyle ls) {_linestyle = ls;}
|
||||||
|
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
||||||
|
LineWeight lineWeight() const {return _lineweight;}
|
||||||
|
void setLineWeight(const LineWeight lw) {_lineweight = lw;}
|
||||||
|
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||||
|
Filling filling() const {return _filling;}
|
||||||
|
void setFilling(const Filling f) {_filling = f;}
|
||||||
|
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||||
|
Color color() const {return _color;}
|
||||||
|
void setColor(const Color c) {_color = c;}
|
||||||
|
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||||
|
bool antialiased() const {return _antialiased;}
|
||||||
|
void setAntialiased(const bool b) {_antialiased = b;}
|
||||||
|
|
||||||
LineStyle lineStyle() const;
|
virtual void setProperty(const char *name, const QVariant &value) {QObject::setProperty(name, value);}
|
||||||
LineWeight lineWeight() const;
|
virtual QVariant property(const char *name) const {return QObject::property(name);}
|
||||||
Filling filling() const;
|
|
||||||
Color color() const;
|
|
||||||
bool antialiased() const;
|
|
||||||
|
|
||||||
void setProperty(const QString &, const QVariant &);
|
|
||||||
QVariant property(const QString &);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void stylesToXml(QDomElement &) const;
|
void stylesToXml(QDomElement &) const;
|
||||||
@@ -116,80 +129,4 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
void resetStyles();
|
void resetStyles();
|
||||||
void applyStylesToQPainter(QPainter &) const;
|
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
|
#endif
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ class CustomElementPart {
|
|||||||
/**
|
/**
|
||||||
Set a specific property of the primitive
|
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
|
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)
|
@return whether the primitive appears to be useless (e.g. 0-length line)
|
||||||
Typically, useless primitives are discarded when saving the element.
|
Typically, useless primitives are discarded when saving the element.
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ void AddPartCommand::redo() {
|
|||||||
ChangePartCommand::ChangePartCommand(
|
ChangePartCommand::ChangePartCommand(
|
||||||
const QString &name,
|
const QString &name,
|
||||||
CustomElementPart *part,
|
CustomElementPart *part,
|
||||||
const QString &prop,
|
const char *prop,
|
||||||
const QVariant &old_v,
|
const QVariant &old_v,
|
||||||
const QVariant &new_v,
|
const QVariant &new_v,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ class AddPartCommand : public ElementEditionCommand {
|
|||||||
class ChangePartCommand : public ElementEditionCommand {
|
class ChangePartCommand : public ElementEditionCommand {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
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();
|
virtual ~ChangePartCommand();
|
||||||
private:
|
private:
|
||||||
ChangePartCommand(const ChangePartCommand &);
|
ChangePartCommand(const ChangePartCommand &);
|
||||||
@@ -191,7 +191,7 @@ class ChangePartCommand : public ElementEditionCommand {
|
|||||||
/// Changed primitive
|
/// Changed primitive
|
||||||
CustomElementPart *cep;
|
CustomElementPart *cep;
|
||||||
/// Changed property
|
/// Changed property
|
||||||
QString property;
|
const char *property;
|
||||||
/// Former value
|
/// Former value
|
||||||
QVariant old_value;
|
QVariant old_value;
|
||||||
/// New value
|
/// New value
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ QUndoStack &ElementItemEditor::undoStack() const {
|
|||||||
@param prop propriete modifiee
|
@param prop propriete modifiee
|
||||||
@param new_v nouvelle valeur
|
@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
|
// ne fait rien si part vaut 0
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class ElementItemEditor : public QWidget {
|
|||||||
virtual QETElementEditor *elementEditor() const;
|
virtual QETElementEditor *elementEditor() const;
|
||||||
virtual ElementScene *elementScene() const;
|
virtual ElementScene *elementScene() const;
|
||||||
virtual QUndoStack &undoStack() 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 QString elementTypeName() const;
|
||||||
virtual void setElementTypeName(const QString &);
|
virtual void setElementTypeName(const QString &);
|
||||||
virtual void detach();
|
virtual void detach();
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ EllipseEditor::EllipseEditor(QETElementEditor *editor, PartEllipse *ellipse, QWi
|
|||||||
{
|
{
|
||||||
style_ = new StyleEditor(editor);
|
style_ = new StyleEditor(editor);
|
||||||
|
|
||||||
x = new QLineEdit();
|
x = new QDoubleSpinBox();
|
||||||
y = new QLineEdit();
|
y = new QDoubleSpinBox();
|
||||||
h = new QLineEdit();
|
h = new QDoubleSpinBox();
|
||||||
v = new QLineEdit();
|
v = new QDoubleSpinBox();
|
||||||
|
|
||||||
x -> setValidator(new QDoubleValidator(x));
|
x->setRange(-1000, 1000);
|
||||||
y -> setValidator(new QDoubleValidator(y));
|
y->setRange(-1000, 1000);
|
||||||
h -> setValidator(new QDoubleValidator(h));
|
h->setRange(-1000, 1000);
|
||||||
v -> setValidator(new QDoubleValidator(v));
|
v->setRange(-1000, 1000);
|
||||||
|
|
||||||
QVBoxLayout *v_layout = new QVBoxLayout(this);
|
QVBoxLayout *v_layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -102,20 +102,20 @@ CustomElementPart *EllipseEditor::currentPart() const {
|
|||||||
*/
|
*/
|
||||||
void EllipseEditor::updateEllipse() {
|
void EllipseEditor::updateEllipse() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setProperty("x", x -> text().toDouble());
|
part -> setProperty("x", x -> value());
|
||||||
part -> setProperty("y", y -> text().toDouble());
|
part -> setProperty("y", y -> value());
|
||||||
part -> setProperty("diameter_h", h -> text().toDouble());
|
part -> setProperty("diameter_h", h -> value());
|
||||||
part -> setProperty("diameter_v", v -> text().toDouble());
|
part -> setProperty("diameter_v", v -> value());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Met a jour l'abscisse du centre de l'ellipse et cree un objet d'annulation
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
Met a jour le formulaire d'edition
|
||||||
@@ -123,10 +123,10 @@ void EllipseEditor::updateEllipseV() { addChangePartCommand(tr("diam\350tre vert
|
|||||||
void EllipseEditor::updateForm() {
|
void EllipseEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
x -> setText(part -> property("x").toString());
|
x->setValue(part->property("x").toReal());
|
||||||
y -> setText(part -> property("y").toString());
|
y->setValue(part->property("y").toReal());
|
||||||
h -> setText(part -> property("diameter_h").toString());
|
h->setValue(part->property("diameter_h").toReal());
|
||||||
v -> setText(part -> property("diameter_v").toString());
|
v->setValue(part->property("diameter_v").toReal());
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class EllipseEditor : public ElementItemEditor {
|
|||||||
private:
|
private:
|
||||||
PartEllipse *part;
|
PartEllipse *part;
|
||||||
StyleEditor *style_;
|
StyleEditor *style_;
|
||||||
QLineEdit *x, *y, *h, *v;
|
QDoubleSpinBox *x, *y, *h, *v;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -33,34 +33,31 @@ LineEditor::LineEditor(QETElementEditor *editor, PartLine *line, QWidget *parent
|
|||||||
{
|
{
|
||||||
style_ = new StyleEditor(editor);
|
style_ = new StyleEditor(editor);
|
||||||
|
|
||||||
x1 = new QLineEdit();
|
x1 = new QDoubleSpinBox();
|
||||||
y1 = new QLineEdit();
|
y1 = new QDoubleSpinBox();
|
||||||
x2 = new QLineEdit();
|
x2 = new QDoubleSpinBox();
|
||||||
y2 = new QLineEdit();
|
y2 = new QDoubleSpinBox();
|
||||||
|
|
||||||
x1 -> setValidator(new QDoubleValidator(x1));
|
x1 -> setRange(-1000, 1000);
|
||||||
y1 -> setValidator(new QDoubleValidator(y1));
|
y1 -> setRange(-1000, 1000);
|
||||||
x2 -> setValidator(new QDoubleValidator(x2));
|
x2 -> setRange(-1000, 1000);
|
||||||
y2 -> setValidator(new QDoubleValidator(y2));
|
y2 -> setRange(-1000, 1000);
|
||||||
|
|
||||||
end1_type = new QComboBox();
|
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::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::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::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::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::EndLineDiamond, tr("Carr\351", "type of the 1st end of a line"), Qet::Diamond );
|
||||||
end2_type = new QComboBox();
|
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::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::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::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::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::EndLineDiamond, tr("Carr\351", "type of the 2nd end of a line"), Qet::Diamond );
|
||||||
|
|
||||||
end1_length = new QLineEdit();
|
end1_length = new QDoubleSpinBox();
|
||||||
end2_length = new QLineEdit();
|
end2_length = new QDoubleSpinBox();
|
||||||
|
|
||||||
end1_length -> setValidator(new QDoubleValidator(end1_length));
|
|
||||||
end2_length -> setValidator(new QDoubleValidator(end2_length));
|
|
||||||
|
|
||||||
QGridLayout *grid = new QGridLayout();
|
QGridLayout *grid = new QGridLayout();
|
||||||
grid -> addWidget(new QLabel("x1"), 0, 0);
|
grid -> addWidget(new QLabel("x1"), 0, 0);
|
||||||
@@ -127,40 +124,40 @@ CustomElementPart *LineEditor::currentPart() const {
|
|||||||
*/
|
*/
|
||||||
void LineEditor::updateLine() {
|
void LineEditor::updateLine() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setFirstEndType(static_cast<QET::EndType>(end1_type -> currentIndex()));
|
part -> setProperty("end1", end1_type -> itemData(end1_type->currentIndex()));
|
||||||
part -> setFirstEndLength(end1_length -> text().toDouble());
|
part -> setProperty("length1", end1_length -> value());
|
||||||
part -> setSecondEndType(static_cast<QET::EndType>(end2_type -> currentIndex()));
|
part -> setProperty("end2", end2_type -> itemData(end2_type->currentIndex()));
|
||||||
part -> setSecondEndLength(end2_length -> text().toDouble());
|
part -> setProperty("length2", end2_length -> value());
|
||||||
part -> setLine(
|
part -> setLine(
|
||||||
QLineF(
|
QLineF(
|
||||||
part -> mapFromScene(
|
part -> mapFromScene(
|
||||||
x1 -> text().toDouble(),
|
x1 -> value(),
|
||||||
y1 -> text().toDouble()
|
y1 -> value()
|
||||||
),
|
),
|
||||||
part -> mapFromScene(
|
part -> mapFromScene(
|
||||||
x2 -> text().toDouble(),
|
x2 -> value(),
|
||||||
y2 -> text().toDouble()
|
y2 -> value()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Met a jour l'abscisse du premier point de la ligne et cree un objet d'annulation
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
Met a jour le formulaire d'edition
|
||||||
@@ -170,14 +167,14 @@ void LineEditor::updateForm() {
|
|||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
QPointF p1(part -> sceneP1());
|
QPointF p1(part -> sceneP1());
|
||||||
QPointF p2(part -> sceneP2());
|
QPointF p2(part -> sceneP2());
|
||||||
x1 -> setText(QString("%1").arg(p1.x()));
|
x1 -> setValue(p1.x());
|
||||||
y1 -> setText(QString("%1").arg(p1.y()));
|
y1 -> setValue(p1.y());
|
||||||
x2 -> setText(QString("%1").arg(p2.x()));
|
x2 -> setValue(p2.x());
|
||||||
y2 -> setText(QString("%1").arg(p2.y()));
|
y2 -> setValue(p2.y());
|
||||||
end1_type -> setCurrentIndex(part -> firstEndType());
|
end1_type -> setCurrentIndex(end1_type->findData(part -> firstEndType()));
|
||||||
end1_length -> setText(QString("%1").arg(part -> firstEndLength()));
|
end1_length -> setValue(part -> firstEndLength());
|
||||||
end2_type -> setCurrentIndex(part -> secondEndType());
|
end2_type -> setCurrentIndex(end2_type->findData(part -> secondEndType()));
|
||||||
end2_length -> setText(QString("%1").arg(part -> secondEndLength()));
|
end2_length -> setValue(part -> secondEndLength());
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ class LineEditor : public ElementItemEditor {
|
|||||||
private:
|
private:
|
||||||
PartLine *part;
|
PartLine *part;
|
||||||
StyleEditor *style_;
|
StyleEditor *style_;
|
||||||
QLineEdit *x1, *y1, *x2, *y2;
|
QDoubleSpinBox *x1, *y1, *x2, *y2;
|
||||||
QComboBox *end1_type, *end2_type;
|
QComboBox *end1_type, *end2_type;
|
||||||
QLineEdit *end1_length, *end2_length;
|
QDoubleSpinBox*end1_length, *end2_length;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
@param scene La scene sur laquelle figure cet arc
|
@param scene La scene sur laquelle figure cet arc
|
||||||
*/
|
*/
|
||||||
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
QGraphicsEllipseItem(parent, scene),
|
|
||||||
CustomElementGraphicPart(editor),
|
CustomElementGraphicPart(editor),
|
||||||
|
QGraphicsEllipseItem(parent, scene),
|
||||||
_angle(-90),
|
_angle(-90),
|
||||||
start_angle(0)
|
start_angle(0)
|
||||||
{
|
{
|
||||||
@@ -124,77 +124,47 @@ QPointF PartArc::sceneTopLeft() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Specifie la valeur d'une propriete donnee de l'arc
|
* @brief PartArc::setX
|
||||||
@param property propriete a modifier. Valeurs acceptees :
|
* @param x is the center of the rect bounding this ellipse
|
||||||
* x : abscisse du centre de l'ellipse dont fait partie l'arc
|
*/
|
||||||
* y : ordonnee du centre de l'ellipse dont fait partie l'arc
|
void PartArc::setX(const qreal x) {
|
||||||
* diameter_h : diametre horizontal de l'ellipse dont fait partie l'arc
|
QRectF current_rect = rect();
|
||||||
* diameter_v : diametre vertical de l'ellipse dont fait partie l'arc
|
QPointF current_pos = mapToScene(current_rect.center());
|
||||||
* start_angle : angle de depart
|
setRect(current_rect.translated(x - current_pos.x(), 0.0));
|
||||||
* angle : taille de l'arc de cercle
|
|
||||||
@param value Valeur a attribuer a la propriete
|
|
||||||
*/
|
|
||||||
void PartArc::setProperty(const QString &property, const QVariant &value) {
|
|
||||||
CustomElementGraphicPart::setProperty(property, value);
|
|
||||||
if (!value.canConvert(QVariant::Double)) return;
|
|
||||||
if (property == "x") {
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
QPointF current_pos = mapToScene(current_rect.center());
|
|
||||||
setRect(current_rect.translated(value.toDouble() - current_pos.x(), 0.0));
|
|
||||||
} else if (property == "y") {
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
QPointF current_pos = mapToScene(current_rect.center());
|
|
||||||
setRect(current_rect.translated(0.0, value.toDouble() - current_pos.y()));
|
|
||||||
} else if (property == "diameter_h") {
|
|
||||||
qreal new_width = qAbs(value.toDouble());
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
|
|
||||||
current_rect.setWidth(new_width);
|
|
||||||
setRect(current_rect);
|
|
||||||
} else if (property == "diameter_v") {
|
|
||||||
qreal new_height = qAbs(value.toDouble());
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
|
|
||||||
current_rect.setHeight(new_height);
|
|
||||||
setRect(current_rect);
|
|
||||||
} else if (property == "start_angle") {
|
|
||||||
setStartAngle(value.toInt() );
|
|
||||||
} else if (property == "angle") {
|
|
||||||
setAngle(value.toInt());
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet d'acceder a la valeur d'une propriete donnee de l'arc de cercle
|
* @brief PartArc::setY
|
||||||
@param property propriete lue. Valeurs acceptees :
|
* @param y is the center of the rect bounding this ellipse
|
||||||
* x : abscisse du centre de l'ellipse dont fait partie l'arc
|
*/
|
||||||
* y : ordonnee du centre de l'ellipse dont fait partie l'arc
|
void PartArc::setY(const qreal y) {
|
||||||
* diameter_h : diametre horizontal de l'ellipse dont fait partie l'arc
|
QRectF current_rect = rect();
|
||||||
* diameter_v : diametre vertical de l'ellipse dont fait partie l'arc
|
QPointF current_pos = mapToScene(current_rect.center());
|
||||||
* start_angle : angle de depart
|
setRect(current_rect.translated(0.0, y - current_pos.y()));
|
||||||
* angle : taille de l'arc de cercle
|
}
|
||||||
@return La valeur de la propriete property
|
|
||||||
*/
|
/**
|
||||||
QVariant PartArc::property(const QString &property) {
|
* @brief PartArc::setWidth
|
||||||
// appelle la methode property de CustomElementGraphicpart pour les styles
|
* @param w is the width of the rect bounding this ellipse
|
||||||
QVariant style_property = CustomElementGraphicPart::property(property);
|
*/
|
||||||
if (style_property != QVariant()) return(style_property);
|
void PartArc::setWidth(const qreal w) {
|
||||||
|
qreal new_width = qAbs(w);
|
||||||
if (property == "x") {
|
QRectF current_rect = rect();
|
||||||
return(mapToScene(rect().center()).x());
|
current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
|
||||||
} else if (property == "y") {
|
current_rect.setWidth(new_width);
|
||||||
return(mapToScene(rect().center()).y());
|
setRect(current_rect);
|
||||||
} else if (property == "diameter_h") {
|
}
|
||||||
return(rect().width());
|
|
||||||
} else if (property == "diameter_v") {
|
/**
|
||||||
return(rect().height());
|
* @brief PartArc::setHeight
|
||||||
} else if (property == "start_angle") {
|
* @param h is the heigth of the rect bounding this ellipse
|
||||||
return(start_angle);
|
*/
|
||||||
} else if (property == "angle") {
|
void PartArc::setHeight(const qreal h) {
|
||||||
return(_angle);
|
qreal new_height = qAbs(h);
|
||||||
}
|
QRectF current_rect = rect();
|
||||||
return(QVariant());
|
current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
|
||||||
|
current_rect.setHeight(new_height);
|
||||||
|
setRect(current_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,41 +181,6 @@ QVariant PartArc::itemChange(GraphicsItemChange change, const QVariant &value) {
|
|||||||
return(QGraphicsEllipseItem::itemChange(change, value));
|
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
|
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
||||||
conservee / enregistree.
|
conservee / enregistree.
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
This class represents an elliptical arc primitive which may be used to
|
This class represents an elliptical arc primitive which may be used to
|
||||||
compose the drawing of an electrical element within the element editor.
|
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
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartArc(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartArc(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
@@ -53,16 +54,37 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
|||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
virtual QRectF boundingRect() 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 bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, 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:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
@param parent Le QGraphicsItem parent de cette ellipse
|
@param parent Le QGraphicsItem parent de cette ellipse
|
||||||
@param scene La scene sur laquelle figure 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);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
#if QT_VERSION >= 0x040600
|
#if QT_VERSION >= 0x040600
|
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
@@ -106,66 +106,32 @@ void PartEllipse::fromXml(const QDomElement &qde) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void PartEllipse::setX(const qreal x) {
|
||||||
Specifie la valeur d'une propriete donnee de l'ellipse
|
QRectF current_rect = rect();
|
||||||
@param property propriete a modifier. Valeurs acceptees :
|
QPointF current_pos = mapToScene(current_rect.center());
|
||||||
* x : abscisse du centre de l'ellipse
|
setRect(current_rect.translated(x - current_pos.x(), 0.0));
|
||||||
* y : ordonnee du centre de l'ellipse
|
|
||||||
* diameter_h : diametre horizontal de l'ellipse
|
|
||||||
* diameter_v : diametre vertical de l'ellipse
|
|
||||||
@param value Valeur a attribuer a la propriete
|
|
||||||
*/
|
|
||||||
void PartEllipse::setProperty(const QString &property, const QVariant &value) {
|
|
||||||
CustomElementGraphicPart::setProperty(property, value);
|
|
||||||
if (!value.canConvert(QVariant::Double)) return;
|
|
||||||
if (property == "x") {
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
QPointF current_pos = mapToScene(current_rect.center());
|
|
||||||
setRect(current_rect.translated(value.toDouble() - current_pos.x(), 0.0));
|
|
||||||
} else if (property == "y") {
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
QPointF current_pos = mapToScene(current_rect.center());
|
|
||||||
setRect(current_rect.translated(0.0, value.toDouble() - current_pos.y()));
|
|
||||||
} else if (property == "diameter_h") {
|
|
||||||
qreal new_width = qAbs(value.toDouble());
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
|
|
||||||
current_rect.setWidth(new_width);
|
|
||||||
setRect(current_rect);
|
|
||||||
} else if (property == "diameter_v") {
|
|
||||||
qreal new_height = qAbs(value.toDouble());
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
|
|
||||||
current_rect.setHeight(new_height);
|
|
||||||
setRect(current_rect);
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void PartEllipse::setY(const qreal y) {
|
||||||
Permet d'acceder a la valeur d'une propriete donnee de l'ellipse
|
QRectF current_rect = rect();
|
||||||
@param property propriete lue. Valeurs acceptees :
|
QPointF current_pos = mapToScene(current_rect.center());
|
||||||
* x : abscisse du centre de l'ellipse
|
setRect(current_rect.translated(0.0, y - current_pos.y()));
|
||||||
* y : ordonnee du centre de l'ellipse
|
}
|
||||||
* diameter_h : diametre horizontal de l'ellipse
|
|
||||||
* diameter_v : diametre vertical de l'ellipse
|
void PartEllipse::setWidth(const qreal w) {
|
||||||
@return La valeur de la propriete property
|
qreal new_width = qAbs(w);
|
||||||
*/
|
QRectF current_rect = rect();
|
||||||
QVariant PartEllipse::property(const QString &property) {
|
current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
|
||||||
// appelle la methode property de CustomElementGraphicpart pour les styles
|
current_rect.setWidth(new_width);
|
||||||
QVariant style_property = CustomElementGraphicPart::property(property);
|
setRect(current_rect);
|
||||||
if (style_property != QVariant()) return(style_property);
|
}
|
||||||
|
|
||||||
if (property == "x") {
|
void PartEllipse::setHeight(const qreal h) {
|
||||||
return(mapToScene(rect().center()).x());
|
qreal new_height = qAbs(h);
|
||||||
} else if (property == "y") {
|
QRectF current_rect = rect();
|
||||||
return(mapToScene(rect().center()).y());
|
current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
|
||||||
} else if (property == "diameter_h") {
|
current_rect.setHeight(new_height);
|
||||||
return(rect().width());
|
setRect(current_rect);
|
||||||
} else if (property == "diameter_v") {
|
|
||||||
return(rect().height());
|
|
||||||
}
|
|
||||||
return(QVariant());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
This class represents an ellipse primitive which may be used to compose the
|
This class represents an ellipse primitive which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
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
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartEllipse(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartEllipse(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
@@ -48,12 +49,28 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
|||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual void setProperty(const QString &, const QVariant &);
|
|
||||||
virtual QVariant property(const QString &);
|
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, 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:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
QGraphicsLineItem(parent, scene),
|
QGraphicsLineItem(parent, scene),
|
||||||
CustomElementGraphicPart(editor),
|
CustomElementGraphicPart(editor),
|
||||||
first_end(QET::None),
|
first_end(Qet::None),
|
||||||
first_length(1.5),
|
first_length(1.5),
|
||||||
second_end(QET::None),
|
second_end(Qet::None),
|
||||||
second_length(1.5)
|
second_length(1.5)
|
||||||
{
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
@@ -47,11 +47,11 @@ PartLine::~PartLine() {
|
|||||||
@param end_type Type d'extremite
|
@param end_type Type d'extremite
|
||||||
@return Le nombre de "longueurs" requises pour dessiner une extremite de type end_type
|
@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;
|
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;
|
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;
|
length_count_required = 1;
|
||||||
}
|
}
|
||||||
return(length_count_required);
|
return(length_count_required);
|
||||||
@@ -102,23 +102,23 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
QPointF start_point, stop_point;
|
QPointF start_point, stop_point;
|
||||||
if (draw_1st_end) {
|
if (draw_1st_end) {
|
||||||
QList<QPointF> four_points1(fourEndPoints(point1, point2, length1));
|
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)));
|
painter -> drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
|
||||||
start_point = four_points1[1];
|
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]);
|
painter -> drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
|
||||||
start_point = four_points1[1];
|
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]);
|
painter -> drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
|
||||||
start_point = point1;
|
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]);
|
painter -> drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
|
||||||
start_point = four_points1[0];
|
start_point = four_points1[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajuste le depart selon l'epaisseur du trait
|
// 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);
|
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -128,22 +128,22 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
// dessine la seconde extremite
|
// dessine la seconde extremite
|
||||||
if (draw_2nd_end) {
|
if (draw_2nd_end) {
|
||||||
QList<QPointF> four_points2(fourEndPoints(point2, point1, length2));
|
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)));
|
painter -> drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
|
||||||
stop_point = four_points2[1];
|
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]);
|
painter -> drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
|
||||||
stop_point = 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]);
|
painter -> drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
|
||||||
stop_point = point2;
|
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]);
|
painter -> drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
|
||||||
stop_point = four_points2[0];
|
stop_point = four_points2[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajuste l'arrivee selon l'epaisseur du trait
|
// 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);
|
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
|
||||||
}
|
}
|
||||||
} else {
|
} 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("y1", QString("%1").arg(p1.y()));
|
||||||
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
||||||
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
|
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("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));
|
xml_element.setAttribute("length2", QString("%1").arg(second_length));
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
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();
|
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();
|
second_length = qde.attribute("length2", "1.5").toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Specifie la valeur d'une propriete donnee de la ligne
|
* @brief PartLine::setX1
|
||||||
@param property propriete a modifier. Valeurs acceptees :
|
* set X of P1
|
||||||
* x1 : abscisse du premier point
|
* @param x1
|
||||||
* y1 : ordonnee du second point
|
*/
|
||||||
* x2 : abscisse du premier point
|
void PartLine::setX1(qreal x1) {
|
||||||
* y2 : ordonnee du second point
|
QPointF p = line().p1();
|
||||||
*end1 : type d'embout du premier point
|
p.setX(x1);
|
||||||
*end2 : type d'embout du second point
|
setLine(QLineF(p, line().p2()));
|
||||||
@param value Valeur a attribuer a la propriete
|
|
||||||
*/
|
|
||||||
void PartLine::setProperty(const QString &property, const QVariant &value) {
|
|
||||||
CustomElementGraphicPart::setProperty(property, value);
|
|
||||||
if (!value.canConvert(QVariant::Double)) return;
|
|
||||||
QPointF new_p1(sceneP1()), new_p2(sceneP2());
|
|
||||||
bool setline = true;
|
|
||||||
if (property == "x1") {
|
|
||||||
new_p1.setX(value.toDouble());
|
|
||||||
} else if (property == "y1") {
|
|
||||||
new_p1.setY(value.toDouble());
|
|
||||||
} else if (property == "x2") {
|
|
||||||
new_p2.setX(value.toDouble());
|
|
||||||
} else if (property == "y2") {
|
|
||||||
new_p2.setY(value.toDouble());
|
|
||||||
} else {
|
|
||||||
setline = false;
|
|
||||||
if (property == "end1") {
|
|
||||||
setFirstEndType(static_cast<QET::EndType>(value.toUInt()));
|
|
||||||
} else if (property == "end2") {
|
|
||||||
setSecondEndType(static_cast<QET::EndType>(value.toUInt()));
|
|
||||||
} else if (property == "length1") {
|
|
||||||
setFirstEndLength(value.toDouble());
|
|
||||||
} else if (property == "length2") {
|
|
||||||
setSecondEndLength(value.toDouble());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (setline) setLine(QLineF(mapFromScene(new_p1), mapFromScene(new_p2)));
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet d'acceder a la valeur d'une propriete donnee de la ligne
|
* @brief PartLine::setY1
|
||||||
@param property propriete lue. Valeurs acceptees :
|
* set y of P1
|
||||||
* x1 : abscisse du premier point
|
* @param y1
|
||||||
* y1 : ordonnee du second point
|
*/
|
||||||
* x2 : abscisse du premier point
|
void PartLine::setY1(qreal y1) {
|
||||||
* y2 : ordonnee du second point
|
QPointF p = line().p1();
|
||||||
@return La valeur de la propriete property
|
p.setY(y1);
|
||||||
*/
|
setLine(QLineF(p, line().p2()));
|
||||||
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);
|
* @brief PartLine::setX2
|
||||||
|
* set x of P2
|
||||||
if (property == "x1") {
|
* @param x2
|
||||||
return(sceneP1().x());
|
*/
|
||||||
} else if (property == "y1") {
|
void PartLine::setX2(qreal x2) {
|
||||||
return(sceneP1().y());
|
QPointF p = line().p2();
|
||||||
} else if (property == "x2") {
|
p.setX(x2);
|
||||||
return(sceneP2().x());
|
setLine(QLineF(line().p2(), p));
|
||||||
} else if (property == "y2") {
|
}
|
||||||
return(sceneP2().y());
|
|
||||||
} else if (property == "end1") {
|
/**
|
||||||
return(firstEndType());
|
* @brief PartLine::setY2
|
||||||
} else if (property == "end2") {
|
* set y of P2
|
||||||
return(secondEndType());
|
* @param y2
|
||||||
} else if (property == "length1") {
|
*/
|
||||||
return(firstEndLength());
|
void PartLine::setY2(qreal y2) {
|
||||||
} else if (property == "length2") {
|
QPointF p = line().p2();
|
||||||
return(secondEndLength());
|
p.setY(y2);
|
||||||
}
|
setLine(QLineF(line().p2(), p));
|
||||||
return(QVariant());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,11 +423,11 @@ QRectF PartLine::boundingRect() const {
|
|||||||
r.adjust(0.0, 0.0, 0.1, 0.1);
|
r.adjust(0.0, 0.0, 0.1, 0.1);
|
||||||
|
|
||||||
// cas special : les embouts sortent largement du bounding rect originel
|
// cas special : les embouts sortent largement du bounding rect originel
|
||||||
if (first_end != QET::None) {
|
if (first_end != Qet::None) {
|
||||||
r = r.united(firstEndCircleRect());
|
r = r.united(firstEndCircleRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (second_end != QET::None) {
|
if (second_end != Qet::None) {
|
||||||
r = r.united(secondEndCircleRect());
|
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))));
|
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
|
@return Les quatre points interessants a l'extremite d'une droite
|
||||||
Ces points sont, dans l'ordre :
|
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);
|
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);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
drawn if the required length for their drawing is longer than the line itself.
|
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.
|
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
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartLine(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartLine(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
@@ -40,9 +41,9 @@ class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QET::EndType first_end;
|
Qet::EndType first_end;
|
||||||
qreal first_length;
|
qreal first_length;
|
||||||
QET::EndType second_end;
|
Qet::EndType second_end;
|
||||||
qreal second_length;
|
qreal second_length;
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
|
|
||||||
@@ -65,22 +66,48 @@ class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
|||||||
virtual QPointF sceneP2() const;
|
virtual QPointF sceneP2() const;
|
||||||
virtual QPainterPath shape() const;
|
virtual QPainterPath shape() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual void setProperty(const QString &, const QVariant &);
|
|
||||||
virtual QVariant property(const QString &);
|
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
||||||
virtual void setFirstEndType(const QET::EndType &);
|
static uint requiredLengthForEndType(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 QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
|
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:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
@param scene La scene sur laquelle figure ce polygone
|
@param scene La scene sur laquelle figure ce polygone
|
||||||
*/
|
*/
|
||||||
PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
QGraphicsPolygonItem(parent, scene),
|
|
||||||
CustomElementGraphicPart(editor),
|
CustomElementGraphicPart(editor),
|
||||||
closed(false)
|
QGraphicsPolygonItem(parent, scene),
|
||||||
|
m_closed(false)
|
||||||
{
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
#if QT_VERSION >= 0x040600
|
#if QT_VERSION >= 0x040600
|
||||||
@@ -64,7 +64,7 @@ void PartPolygon::fromXml(const QDomElement &qde) {
|
|||||||
}
|
}
|
||||||
setPolygon(temp_polygon);
|
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()));
|
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
|
||||||
++ i;
|
++ i;
|
||||||
}
|
}
|
||||||
if (!closed) xml_element.setAttribute("closed", "false");
|
if (!m_closed) xml_element.setAttribute("closed", "false");
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -99,37 +99,10 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||||
if (isSelected()) t.setColor(Qt::red);
|
if (isSelected()) t.setColor(Qt::red);
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
if (closed) painter -> drawPolygon(polygon());
|
if (m_closed) painter -> drawPolygon(polygon());
|
||||||
else painter -> drawPolyline(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
|
Gere les changements intervenant sur cette partie
|
||||||
@param change Type de changement
|
@param change Type de changement
|
||||||
@@ -144,7 +117,6 @@ QVariant PartPolygon::itemChange(GraphicsItemChange change, const QVariant &valu
|
|||||||
return(QGraphicsPolygonItem::itemChange(change, value));
|
return(QGraphicsPolygonItem::itemChange(change, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
||||||
conservee / enregistree.
|
conservee / enregistree.
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
This class represents a polygon primitive which may be used to compose the
|
This class represents a polygon primitive which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
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
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartPolygon(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartPolygon(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
@@ -34,7 +35,7 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
bool closed;
|
bool m_closed;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -51,15 +52,19 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
|||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
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 bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
||||||
virtual QET::ScalingMethod preferredScalingMethod() const;
|
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:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
@@ -67,21 +72,4 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
|||||||
private:
|
private:
|
||||||
QList<QPointF> saved_points_;
|
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
|
#endif
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
@param parent Le QGraphicsItem parent de ce rectangle
|
@param parent Le QGraphicsItem parent de ce rectangle
|
||||||
@param scene La scene sur laquelle figure 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);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
#if QT_VERSION >= 0x040600
|
#if QT_VERSION >= 0x040600
|
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
@@ -106,63 +106,45 @@ void PartRectangle::fromXml(const QDomElement &qde) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Specifie la valeur d'une propriete donnee du rectangle
|
* @brief PartRectangle::setX
|
||||||
@param property propriete a modifier. Valeurs acceptees :
|
* @param x new value
|
||||||
* x : abscisse du coin superieur gauche du rectangle
|
*/
|
||||||
* y : ordonnee du coin superieur gauche du rectangle
|
void PartRectangle::setX(qreal x) {
|
||||||
* width : largeur du rectangle
|
QRectF current_rect = rect();
|
||||||
* height : hauteur du rectangle
|
QPointF current_pos = mapToScene(current_rect.topLeft());
|
||||||
@param value Valeur a attribuer a la propriete
|
setRect(current_rect.translated(x - current_pos.x(), 0.0));
|
||||||
*/
|
|
||||||
void PartRectangle::setProperty(const QString &property, const QVariant &value) {
|
|
||||||
CustomElementGraphicPart::setProperty(property, value);
|
|
||||||
if (!value.canConvert(QVariant::Double)) return;
|
|
||||||
if (property == "x") {
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
QPointF current_pos = mapToScene(current_rect.topLeft());
|
|
||||||
setRect(current_rect.translated(value.toDouble() - current_pos.x(), 0.0));
|
|
||||||
} else if (property == "y") {
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
QPointF current_pos = mapToScene(current_rect.topLeft());
|
|
||||||
setRect(current_rect.translated(0.0, value.toDouble() - current_pos.y()));
|
|
||||||
} else if (property == "width") {
|
|
||||||
qreal new_width = qAbs(value.toDouble());
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
current_rect.setWidth(new_width);
|
|
||||||
setRect(current_rect);
|
|
||||||
} else if (property == "height") {
|
|
||||||
qreal new_height = qAbs(value.toDouble());
|
|
||||||
QRectF current_rect = rect();
|
|
||||||
current_rect.setHeight(new_height);
|
|
||||||
setRect(current_rect);
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet d'acceder a la valeur d'une propriete donnee du rectangle
|
* @brief PartRectangle::setY
|
||||||
@param property propriete lue. Valeurs acceptees :
|
* @param y new value
|
||||||
* x : abscisse du coin superieur gauche du rectangle
|
*/
|
||||||
* y : ordonnee du coin superieur gauche du rectangle
|
void PartRectangle::setY(qreal y) {
|
||||||
* width : largeur du rectangle
|
QRectF current_rect = rect();
|
||||||
* height : hauteur du rectangle
|
QPointF current_pos = mapToScene(current_rect.topLeft());
|
||||||
@return La valeur de la propriete property
|
setRect(current_rect.translated(0.0, y - current_pos.y()));
|
||||||
*/
|
}
|
||||||
QVariant PartRectangle::property(const QString &property) {
|
|
||||||
// appelle la methode property de CustomElementGraphicpart pour les styles
|
/**
|
||||||
QVariant style_property = CustomElementGraphicPart::property(property);
|
* @brief PartRectangle::setWidth
|
||||||
if (style_property != QVariant()) return(style_property);
|
* @param w new value
|
||||||
|
*/
|
||||||
if (property == "x") {
|
void PartRectangle::setWidth(qreal w) {
|
||||||
return(mapToScene(rect().topLeft()).x());
|
qreal new_width = qAbs(w);
|
||||||
} else if (property == "y") {
|
QRectF current_rect = rect();
|
||||||
return(mapToScene(rect().topLeft()).y());
|
current_rect.setWidth(new_width);
|
||||||
} else if (property == "width") {
|
setRect(current_rect);
|
||||||
return(rect().width());
|
}
|
||||||
} else if (property == "height") {
|
|
||||||
return(rect().height());
|
/**
|
||||||
}
|
* @brief PartRectangle::setHeight
|
||||||
return(QVariant());
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
This class represents a rectangle primitive which may be used to compose the
|
This class represents a rectangle primitive which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
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
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartRectangle(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartRectangle(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
@@ -48,12 +49,28 @@ class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart
|
|||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual void setProperty(const QString &, const QVariant &);
|
|
||||||
virtual QVariant property(const QString &);
|
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, 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:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
@param scene La scene sur laquelle figure cette borne
|
@param scene La scene sur laquelle figure cette borne
|
||||||
*/
|
*/
|
||||||
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
CustomElementPart(editor),
|
CustomElementGraphicPart(editor),
|
||||||
QGraphicsItem(parent, scene),
|
QGraphicsItem(parent, scene),
|
||||||
_orientation(QET::North)
|
m_orientation(Qet::North)
|
||||||
{
|
{
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
@@ -53,12 +53,7 @@ void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
|||||||
setPos(QPointF(term_x, term_y));
|
setPos(QPointF(term_x, term_y));
|
||||||
|
|
||||||
// lit l'orientation de la borne
|
// lit l'orientation de la borne
|
||||||
_orientation = QET::orientationFromString(xml_elmt.attribute("orientation"));
|
m_orientation = Qet::orientationFromString(xml_elmt.attribute("orientation"));
|
||||||
|
|
||||||
// Read number and name of terminal from XML
|
|
||||||
number_ = xml_elmt.attribute("number");
|
|
||||||
name_ = xml_elmt.attribute("name");
|
|
||||||
nameHidden_ = xml_elmt.attribute("nameHidden").toInt();
|
|
||||||
|
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
}
|
}
|
||||||
@@ -76,11 +71,8 @@ const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
|||||||
xml_element.setAttribute("y", QString("%1").arg(scenePos().y()));
|
xml_element.setAttribute("y", QString("%1").arg(scenePos().y()));
|
||||||
|
|
||||||
// ecrit l'orientation de la borne
|
// 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
|
// Write name and number to XML
|
||||||
xml_element.setAttribute("number", number_);
|
|
||||||
xml_element.setAttribute("name", name_);
|
|
||||||
xml_element.setAttribute("nameHidden", nameHidden_);
|
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -135,122 +127,16 @@ QRectF PartTerminal::boundingRect() const {
|
|||||||
return(br);
|
return(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@return L'orientation de la borne
|
|
||||||
*/
|
|
||||||
QET::Orientation PartTerminal::orientation() const {
|
|
||||||
return(_orientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Definit l'orientation de la borne
|
Definit l'orientation de la borne
|
||||||
@param ori la nouvelle 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();
|
prepareGeometryChange();
|
||||||
_orientation = ori;
|
m_orientation = ori;
|
||||||
updateSecondPoint();
|
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
|
Gere les changements intervenant sur cette partie
|
||||||
@param change Type de changement
|
@param change Type de changement
|
||||||
@@ -271,11 +157,11 @@ QVariant PartTerminal::itemChange(GraphicsItemChange change, const QVariant &val
|
|||||||
*/
|
*/
|
||||||
void PartTerminal::updateSecondPoint() {
|
void PartTerminal::updateSecondPoint() {
|
||||||
qreal ts = 4.0; // terminal size
|
qreal ts = 4.0; // terminal size
|
||||||
switch(_orientation) {
|
switch(m_orientation) {
|
||||||
case QET::North: second_point = QPointF(0.0, ts); break;
|
case Qet::North: second_point = QPointF(0.0, ts); break;
|
||||||
case QET::East : second_point = QPointF(-ts, 0.0); break;
|
case Qet::East : second_point = QPointF(-ts, 0.0); break;
|
||||||
case QET::South: second_point = QPointF(0.0, -ts); break;
|
case Qet::South: second_point = QPointF(0.0, -ts); break;
|
||||||
case QET::West : second_point = QPointF(ts, 0.0); break;
|
case Qet::West : second_point = QPointF(ts, 0.0); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef PART_TERMINAL_H
|
#ifndef PART_TERMINAL_H
|
||||||
#define PART_TERMINAL_H
|
#define PART_TERMINAL_H
|
||||||
#include "customelementpart.h"
|
#include "customelementgraphicpart.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
This class represents a terminal which may be used to compose the drawing of
|
This class represents a terminal which may be used to compose the drawing of
|
||||||
an electrical element within the element editor.
|
an electrical element within the element editor.
|
||||||
*/
|
*/
|
||||||
class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
class PartTerminal : public CustomElementGraphicPart, public QGraphicsItem {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
PartTerminal(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartTerminal(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
@@ -34,10 +35,8 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QET::Orientation _orientation;
|
Qet::Orientation m_orientation;
|
||||||
QPointF second_point;
|
QPointF second_point;
|
||||||
QString number_, name_;
|
|
||||||
bool nameHidden_;
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -54,21 +53,23 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
|||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
virtual QRectF boundingRect() const;
|
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 void setProperty(const QString &, const QVariant &);
|
||||||
virtual QVariant property(const QString &);
|
virtual QVariant property(const QString &);*/
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, 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:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ void PartText::fromXml(const QDomElement &xml_element) {
|
|||||||
|
|
||||||
qreal default_rotation_angle = 0.0;
|
qreal default_rotation_angle = 0.0;
|
||||||
if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
|
if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
|
||||||
setRotationAngle(default_rotation_angle);
|
setRotation(default_rotation_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPos(
|
setPos(
|
||||||
@@ -94,8 +94,8 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const {
|
|||||||
xml_element.setAttribute("text", toPlainText());
|
xml_element.setAttribute("text", toPlainText());
|
||||||
xml_element.setAttribute("size", font().pointSize());
|
xml_element.setAttribute("size", font().pointSize());
|
||||||
// angle de rotation du champ de texte
|
// angle de rotation du champ de texte
|
||||||
if (rotationAngle()) {
|
if (rotation()) {
|
||||||
xml_element.setAttribute("rotation", QString("%1").arg(rotationAngle()));
|
xml_element.setAttribute("rotation", QString("%1").arg(rotation()));
|
||||||
}
|
}
|
||||||
if (!isBlack()) {
|
if (!isBlack()) {
|
||||||
xml_element.setAttribute("color", "white");
|
xml_element.setAttribute("color", "white");
|
||||||
@@ -103,36 +103,6 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const {
|
|||||||
return(xml_element);
|
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.
|
@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
|
Gere les changements intervenant sur cette partie
|
||||||
@param change Type de changement
|
@param change Type de changement
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define PART_TEXT_H
|
#define PART_TEXT_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
|
#include "qetapp.h"
|
||||||
class TextEditor;
|
class TextEditor;
|
||||||
class ElementPrimitiveDecorator;
|
class ElementPrimitiveDecorator;
|
||||||
/**
|
/**
|
||||||
@@ -49,23 +50,35 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual QString xmlName() const { return(QString("text")); }
|
virtual QString xmlName() const { return(QString("text")); }
|
||||||
void fromXml(const QDomElement &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
qreal rotationAngle() const;
|
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||||
void setRotationAngle(const qreal &);
|
|
||||||
bool isBlack() const;
|
|
||||||
void setBlack(bool);
|
|
||||||
virtual void setProperty(const QString &, const QVariant &);
|
|
||||||
virtual QVariant property(const QString &);
|
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
||||||
|
|
||||||
virtual void setDecorator(ElementPrimitiveDecorator *);
|
virtual void setDecorator(ElementPrimitiveDecorator *);
|
||||||
virtual bool singleItemPressEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
virtual bool singleItemPressEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
||||||
virtual bool singleItemMoveEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
virtual bool singleItemMoveEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
||||||
virtual bool singleItemReleaseEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
virtual bool singleItemReleaseEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
||||||
virtual bool singleItemDoubleClickEvent(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:
|
public slots:
|
||||||
void adjustItemPosition(int = 0);
|
void adjustItemPosition(int = 0);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QG
|
|||||||
QGraphicsTextItem(parent, scene),
|
QGraphicsTextItem(parent, scene),
|
||||||
CustomElementPart(editor),
|
CustomElementPart(editor),
|
||||||
follow_parent_rotations(true),
|
follow_parent_rotations(true),
|
||||||
|
m_tagg("none"),
|
||||||
previous_text(),
|
previous_text(),
|
||||||
decorator_(0)
|
decorator_(0)
|
||||||
{
|
{
|
||||||
@@ -65,6 +66,8 @@ void PartTextField::fromXml(const QDomElement &xml_element) {
|
|||||||
|
|
||||||
setProperty("size", font_size);
|
setProperty("size", font_size);
|
||||||
setPlainText(xml_element.attribute("text"));
|
setPlainText(xml_element.attribute("text"));
|
||||||
|
|
||||||
|
m_tagg = xml_element.attribute("tagg", "none");
|
||||||
|
|
||||||
qreal default_rotation_angle = 0.0;
|
qreal default_rotation_angle = 0.0;
|
||||||
if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
|
if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
|
||||||
@@ -90,9 +93,11 @@ const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
|
|||||||
xml_element.setAttribute("y", QString("%1").arg(pos().y()));
|
xml_element.setAttribute("y", QString("%1").arg(pos().y()));
|
||||||
xml_element.setAttribute("text", toPlainText());
|
xml_element.setAttribute("text", toPlainText());
|
||||||
xml_element.setAttribute("size", font().pointSize());
|
xml_element.setAttribute("size", font().pointSize());
|
||||||
|
xml_element.setAttribute("tagg", m_tagg);
|
||||||
|
|
||||||
// angle de rotation du champ de texte
|
// angle de rotation du champ de texte
|
||||||
if (rotationAngle()) {
|
if (rotation()) {
|
||||||
xml_element.setAttribute("rotation", QString("%1").arg(rotationAngle()));
|
xml_element.setAttribute("rotation", QString("%1").arg(rotation()));
|
||||||
}
|
}
|
||||||
// suivi (ou non) des rotations de l'element parent par le champ de texte
|
// suivi (ou non) des rotations de l'element parent par le champ de texte
|
||||||
if (follow_parent_rotations) {
|
if (follow_parent_rotations) {
|
||||||
@@ -101,36 +106,6 @@ const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
|
|||||||
return(xml_element);
|
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
|
@return le decalage entre l'origine du QGraphicsItem et l'origine du champ de
|
||||||
texte.
|
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
|
Gere les changements intervenant sur cette partie
|
||||||
@param change Type de changement
|
@param change Type de changement
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define PART_TEXTFIELD_H
|
#define PART_TEXTFIELD_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
|
#include "qetapp.h"
|
||||||
class TextFieldEditor;
|
class TextFieldEditor;
|
||||||
class QETElementEditor;
|
class QETElementEditor;
|
||||||
class ElementPrimitiveDecorator;
|
class ElementPrimitiveDecorator;
|
||||||
@@ -41,6 +42,7 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
bool follow_parent_rotations;
|
bool follow_parent_rotations;
|
||||||
|
QString m_tagg;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -55,24 +57,44 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual QString xmlName() const { return(QString("input")); }
|
virtual QString xmlName() const { return(QString("input")); }
|
||||||
void fromXml(const QDomElement &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
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 bool isUseless() const;
|
||||||
virtual QRectF sceneGeometricRect() const;
|
virtual QRectF sceneGeometricRect() const;
|
||||||
virtual void startUserTransformation(const QRectF &);
|
virtual void startUserTransformation(const QRectF &);
|
||||||
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
virtual void handleUserTransformation(const QRectF &, const QRectF &);
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
||||||
|
|
||||||
virtual void setDecorator(ElementPrimitiveDecorator *);
|
virtual void setDecorator(ElementPrimitiveDecorator *);
|
||||||
virtual bool singleItemPressEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
virtual bool singleItemPressEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
||||||
virtual bool singleItemMoveEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
virtual bool singleItemMoveEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
||||||
virtual bool singleItemReleaseEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
virtual bool singleItemReleaseEvent(ElementPrimitiveDecorator *, QGraphicsSceneMouseEvent *);
|
||||||
virtual bool singleItemDoubleClickEvent(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:
|
public slots:
|
||||||
void adjustItemPosition(int = 0);
|
void adjustItemPosition(int = 0);
|
||||||
void setEditable(bool);
|
void setEditable(bool);
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ RectangleEditor::RectangleEditor(QETElementEditor *editor, PartRectangle *rect,
|
|||||||
{
|
{
|
||||||
style_ = new StyleEditor(editor);
|
style_ = new StyleEditor(editor);
|
||||||
|
|
||||||
x = new QLineEdit();
|
x = new QDoubleSpinBox();
|
||||||
y = new QLineEdit();
|
y = new QDoubleSpinBox();
|
||||||
w = new QLineEdit();
|
w = new QDoubleSpinBox();
|
||||||
h = new QLineEdit();
|
h = new QDoubleSpinBox();
|
||||||
|
|
||||||
x -> setValidator(new QDoubleValidator(x));
|
x->setRange(-1000, 1000);
|
||||||
y -> setValidator(new QDoubleValidator(y));
|
y->setRange(-1000, 1000);
|
||||||
w -> setValidator(new QDoubleValidator(w));
|
w->setRange(-1000, 1000);
|
||||||
h -> setValidator(new QDoubleValidator(h));
|
h->setRange(-1000, 1000);
|
||||||
|
|
||||||
QVBoxLayout *v_layout = new QVBoxLayout(this);
|
QVBoxLayout *v_layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -101,20 +101,20 @@ CustomElementPart *RectangleEditor::currentPart() const {
|
|||||||
*/
|
*/
|
||||||
void RectangleEditor::updateRectangle() {
|
void RectangleEditor::updateRectangle() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setProperty("x", x -> text().toDouble());
|
part -> setProperty("x", x -> value());
|
||||||
part -> setProperty("y", y -> text().toDouble());
|
part -> setProperty("y", y -> value());
|
||||||
part -> setProperty("width", w -> text().toDouble());
|
part -> setProperty("width", w -> value());
|
||||||
part -> setProperty("height", h -> text().toDouble());
|
part -> setProperty("height", h -> value());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Met a jour l'abscisse du coin superieur gauche du rectangle et cree un objet d'annulation
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
Met a jour le formulaire d'edition
|
||||||
@@ -122,10 +122,10 @@ void RectangleEditor::updateRectangleH() { addChangePartCommand(tr("hauteur"),
|
|||||||
void RectangleEditor::updateForm() {
|
void RectangleEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
x -> setText(part -> property("x").toString());
|
x->setValue(part->property("x").toReal());
|
||||||
y -> setText(part -> property("y").toString());
|
y->setValue(part->property("y").toReal());
|
||||||
w -> setText(part -> property("width").toString());
|
w->setValue(part->property("width").toReal());
|
||||||
h -> setText(part -> property("height").toString());
|
h->setValue(part->property("height").toReal());
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class RectangleEditor : public ElementItemEditor {
|
|||||||
private:
|
private:
|
||||||
PartRectangle *part;
|
PartRectangle *part;
|
||||||
StyleEditor *style_;
|
StyleEditor *style_;
|
||||||
QLineEdit *x, *y, *w, *h;
|
QDoubleSpinBox *x, *y, *w, *h;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -98,42 +98,34 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
|
|||||||
/// Destructeur
|
/// Destructeur
|
||||||
StyleEditor::~StyleEditor() {
|
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() {
|
void StyleEditor::updatePart() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
// applique l'antialiasing
|
part->setProperty("antialias", antialiasing -> isChecked());
|
||||||
part -> setAntialiased(antialiasing -> isChecked());
|
part->setProperty("color", outline_color -> itemData(outline_color -> currentIndex()));
|
||||||
|
part->setProperty("line_style", line_style -> itemData(line_style -> currentIndex()));
|
||||||
// applique la couleur
|
part->setProperty("line_weight", size_weight -> itemData(size_weight -> currentIndex()));
|
||||||
part -> setColor(static_cast<CEGP::Color>(outline_color -> currentIndex()));
|
part->setProperty("filling", filling_color -> itemData(filling_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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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()); }
|
void StyleEditor::updatePartAntialiasing() { addChangePartCommand(tr("style antialiasing"), part, "antialias", antialiasing -> isChecked()); }
|
||||||
/// Met a jour la couleur du trait et cree un objet d'annulation
|
/// Update color with undo command
|
||||||
void StyleEditor::updatePartColor() { addChangePartCommand(tr("style couleur"), part, "color", outline_color -> currentIndex());}
|
void StyleEditor::updatePartColor() { addChangePartCommand(tr("style couleur"), part, "color", outline_color->itemData(outline_color -> currentIndex()));}
|
||||||
/// Met a jour le style du trait et cree un objet d'annulation
|
/// Update style with undo command
|
||||||
void StyleEditor::updatePartLineStyle() { addChangePartCommand(tr("style ligne"), part, "line-style", line_style -> currentIndex());}
|
void StyleEditor::updatePartLineStyle() { addChangePartCommand(tr("style ligne"), part, "line_style", line_style->itemData(line_style -> currentIndex()));}
|
||||||
/// Met a jour l'epaisseur du trait et cree un objet d'annulation
|
/// Update weight with undo command
|
||||||
void StyleEditor::updatePartLineWeight() { addChangePartCommand(tr("style epaisseur"), part, "line-weight", size_weight -> currentIndex());}
|
void StyleEditor::updatePartLineWeight() { addChangePartCommand(tr("style epaisseur"), part, "line_weight", size_weight->itemData(size_weight -> currentIndex()));}
|
||||||
/// Met a jour la couleur de fond et cree un objet d'annulation
|
/// Update color filling with undo command
|
||||||
void StyleEditor::updatePartFilling() { addChangePartCommand(tr("style remplissage"), part, "filling", filling_color -> currentIndex());}
|
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() {
|
void StyleEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
|
|||||||
@@ -29,21 +29,17 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
|||||||
ElementItemEditor(editor, parent),
|
ElementItemEditor(editor, parent),
|
||||||
part(term)
|
part(term)
|
||||||
{
|
{
|
||||||
qle_x = new QLineEdit();
|
qle_x = new QDoubleSpinBox();
|
||||||
qle_y = new QLineEdit();
|
qle_y = new QDoubleSpinBox();
|
||||||
|
|
||||||
qle_x -> setValidator(new QDoubleValidator(qle_x));
|
qle_x -> setRange(-1000, 1000);
|
||||||
qle_y -> setValidator(new QDoubleValidator(qle_y));
|
qle_y -> setRange(-1000, 1000);
|
||||||
|
|
||||||
orientation = new QComboBox();
|
orientation = new QComboBox();
|
||||||
orientation -> addItem(QET::Icons::North, tr("Nord"), QET::North);
|
orientation -> addItem(QET::Icons::North, tr("Nord"), Qet::North);
|
||||||
orientation -> addItem(QET::Icons::East, tr("Est"), QET::East);
|
orientation -> addItem(QET::Icons::East, tr("Est"), Qet::East);
|
||||||
orientation -> addItem(QET::Icons::South, tr("Sud"), QET::South);
|
orientation -> addItem(QET::Icons::South, tr("Sud"), Qet::South);
|
||||||
orientation -> addItem(QET::Icons::West, tr("Ouest"), QET::West);
|
orientation -> addItem(QET::Icons::West, tr("Ouest"), Qet::West);
|
||||||
|
|
||||||
qle_number = new QLineEdit();
|
|
||||||
qle_name = new QLineEdit();
|
|
||||||
qcheck_name_visible = new QCheckBox(tr("Visible"));
|
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||||
@@ -60,17 +56,6 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
|||||||
ori -> addWidget(orientation );
|
ori -> addWidget(orientation );
|
||||||
main_layout -> addLayout(ori);
|
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();
|
main_layout -> addStretch();
|
||||||
setLayout(main_layout);
|
setLayout(main_layout);
|
||||||
|
|
||||||
@@ -116,51 +101,34 @@ CustomElementPart *TerminalEditor::currentPart() const {
|
|||||||
*/
|
*/
|
||||||
void TerminalEditor::updateTerminal() {
|
void TerminalEditor::updateTerminal() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setPos(qle_x -> text().toDouble(), qle_y -> text().toDouble());
|
part -> setPos(qle_x -> value(), qle_y -> value());
|
||||||
part -> setOrientation(
|
part -> setOrientation(
|
||||||
static_cast<QET::Orientation>(
|
static_cast<Qet::Orientation>(
|
||||||
orientation -> itemData(
|
orientation -> itemData(
|
||||||
orientation -> currentIndex()
|
orientation -> currentIndex()
|
||||||
).toInt()
|
).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 /:;,?...)
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
Met a jour le formulaire d'edition
|
||||||
*/
|
*/
|
||||||
void TerminalEditor::updateForm() {
|
void TerminalEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
qle_x -> setText(part -> property("x").toString());
|
qle_x -> setValue(part->property("x").toReal());
|
||||||
qle_y -> setText(part -> property("y").toString());
|
qle_y -> setValue(part->property("y").toReal());
|
||||||
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
orientation -> setCurrentIndex(orientation->findData(part->property("orientation")));
|
||||||
qle_number -> setText(part -> number() );
|
|
||||||
qle_name -> setText(part -> nameOfTerminal() );
|
|
||||||
qcheck_name_visible ->setChecked( !part -> nameIsHidden() );
|
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,15 +141,9 @@ void TerminalEditor::activeConnections(bool active) {
|
|||||||
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
||||||
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
||||||
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
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 {
|
} else {
|
||||||
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
||||||
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
||||||
disconnect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
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()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,8 @@ class TerminalEditor : public ElementItemEditor {
|
|||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
PartTerminal *part;
|
PartTerminal *part;
|
||||||
QLineEdit *qle_x, *qle_y;
|
QDoubleSpinBox *qle_x, *qle_y;
|
||||||
QComboBox *orientation;
|
QComboBox *orientation;
|
||||||
QLineEdit *qle_number, *qle_name;
|
|
||||||
QCheckBox *qcheck_name_visible;
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -50,9 +48,6 @@ class TerminalEditor : public ElementItemEditor {
|
|||||||
void updateTerminalX();
|
void updateTerminalX();
|
||||||
void updateTerminalY();
|
void updateTerminalY();
|
||||||
void updateTerminalO();
|
void updateTerminalO();
|
||||||
void updateTerminalNum();
|
|
||||||
void updateTerminalName();
|
|
||||||
void updateTerminalNameVisible();
|
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent
|
|||||||
ElementItemEditor(editor, parent),
|
ElementItemEditor(editor, parent),
|
||||||
part(text)
|
part(text)
|
||||||
{
|
{
|
||||||
qle_x = new QLineEdit();
|
qle_x = new QDoubleSpinBox();
|
||||||
qle_y = new QLineEdit();
|
qle_y = new QDoubleSpinBox();
|
||||||
qle_text = new QLineEdit();
|
qle_text = new QLineEdit();
|
||||||
font_size = new QSpinBox();
|
font_size = new QSpinBox();
|
||||||
font_size -> setRange(0, 144);
|
font_size -> setRange(0, 144);
|
||||||
@@ -45,8 +45,8 @@ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent
|
|||||||
rotation_angle_label -> setWordWrap(true);
|
rotation_angle_label -> setWordWrap(true);
|
||||||
rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
|
rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
|
||||||
|
|
||||||
qle_x -> setValidator(new QDoubleValidator(qle_x));
|
qle_x -> setRange(-1000, 1000);
|
||||||
qle_y -> setValidator(new QDoubleValidator(qle_y));
|
qle_y -> setRange(-1000, 1000);
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||||
@@ -128,13 +128,13 @@ void TextEditor::updateText() {
|
|||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setProperty("size", font_size -> value());
|
part -> setProperty("size", font_size -> value());
|
||||||
part -> setPlainText(qle_text -> text());
|
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
|
/// 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
|
/// 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
|
/// Met a jour le texte et cree un objet d'annulation
|
||||||
void TextEditor::updateTextT() { addChangePartCommand(tr("contenu"), part, "text", qle_text -> text()); }
|
void TextEditor::updateTextT() { addChangePartCommand(tr("contenu"), part, "text", qle_text -> text()); }
|
||||||
/// Met a jour la taille du texte et cree un objet d'annulation
|
/// 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
|
/// Update the text color and create an undo object
|
||||||
void TextEditor::updateTextC() { addChangePartCommand(tr("couleur", "undo caption"), part, "color", color_ -> checkedId()); }
|
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
|
/// 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
|
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() {
|
void TextEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
qle_x -> setText(part -> property("x").toString());
|
qle_x -> setValue(part->property("x").toReal());
|
||||||
qle_y -> setText(part -> property("y").toString());
|
qle_y -> setValue(part->property("y").toReal());
|
||||||
qle_text -> setText(part -> property("text").toString());
|
qle_text -> setText(part -> property("text").toString());
|
||||||
font_size -> setValue(part -> property("size").toInt());
|
font_size -> setValue(part -> property("size").toInt());
|
||||||
if (QAbstractButton *button = color_ -> button(part -> property("color").toBool())) {
|
if (QAbstractButton *button = color_ -> button(part -> property("color").toBool())) {
|
||||||
button -> setChecked(true);
|
button -> setChecked(true);
|
||||||
}
|
}
|
||||||
rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
|
rotation_angle_ -> setValue(part -> property("rotation").toReal());
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ class TextEditor : public ElementItemEditor {
|
|||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
PartText *part;
|
PartText *part;
|
||||||
QLineEdit *qle_x, *qle_y, *qle_text;
|
QLineEdit *qle_text;
|
||||||
|
QDoubleSpinBox *qle_x, *qle_y;
|
||||||
QSpinBox *font_size;
|
QSpinBox *font_size;
|
||||||
QButtonGroup *color_;
|
QButtonGroup *color_;
|
||||||
QRadioButton *black_color_, *white_color_;
|
QRadioButton *black_color_, *white_color_;
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
|
|||||||
ElementItemEditor(editor, parent),
|
ElementItemEditor(editor, parent),
|
||||||
part(textfield)
|
part(textfield)
|
||||||
{
|
{
|
||||||
qle_x = new QLineEdit();
|
qle_x = new QDoubleSpinBox();
|
||||||
qle_y = new QLineEdit();
|
qle_y = new QDoubleSpinBox();
|
||||||
qle_text = new QLineEdit();
|
qle_text = new QLineEdit();
|
||||||
font_size = new QSpinBox();
|
font_size = new QSpinBox();
|
||||||
font_size -> setRange(0, 144);
|
font_size -> setRange(0, 144);
|
||||||
@@ -40,8 +40,8 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
|
|||||||
rotation_angle_label -> setWordWrap(true);
|
rotation_angle_label -> setWordWrap(true);
|
||||||
rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
|
rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
|
||||||
|
|
||||||
qle_x -> setValidator(new QDoubleValidator(qle_x));
|
qle_x -> setRange (-1000, 1000);
|
||||||
qle_y -> setValidator(new QDoubleValidator(qle_y));
|
qle_y -> setRange (-1000, 1000);
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||||
@@ -62,6 +62,14 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
|
|||||||
t -> addWidget(new QLabel(tr("Texte par d\351faut : ")));
|
t -> addWidget(new QLabel(tr("Texte par d\351faut : ")));
|
||||||
t -> addWidget(qle_text);
|
t -> addWidget(qle_text);
|
||||||
main_layout -> addLayout(t);
|
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();
|
QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
|
||||||
rotation_angle_layout -> addWidget(rotation_angle_label);
|
rotation_angle_layout -> addWidget(rotation_angle_label);
|
||||||
@@ -117,14 +125,15 @@ void TextFieldEditor::updateTextField() {
|
|||||||
if (!part) return;
|
if (!part) return;
|
||||||
part -> setProperty("size", font_size -> value());
|
part -> setProperty("size", font_size -> value());
|
||||||
part -> setPlainText(qle_text -> text());
|
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 -> 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
|
/// 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
|
/// 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
|
/// 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()); }
|
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
|
/// 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
|
/// 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()); }
|
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
|
/// 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
|
Met a jour le formulaire d'edition
|
||||||
@@ -140,12 +150,14 @@ void TextFieldEditor::updateTextFieldRotationAngle() { addChangePartCommand(tr("
|
|||||||
void TextFieldEditor::updateForm() {
|
void TextFieldEditor::updateForm() {
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
qle_x -> setText(part -> property("x").toString());
|
qle_x -> setValue(part->property("x").toReal());
|
||||||
qle_y -> setText(part -> property("y").toString());
|
qle_y -> setValue(part->property("y").toReal());
|
||||||
qle_text -> setText(part -> property("text").toString());
|
qle_text -> setText(part -> property("text").toString());
|
||||||
font_size -> setValue(part -> property("size").toInt());
|
font_size -> setValue(part -> property("size").toInt());
|
||||||
rotate -> setChecked(!part -> property("rotate").toBool());
|
rotate -> setChecked(!part -> property("rotate").toBool());
|
||||||
rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
|
rotation_angle_ -> setValue(part -> property("rotation angle").toDouble());
|
||||||
|
m_tagg_cb->setCurrentIndex(m_tagg_cb->findData(part->property("tagg")));
|
||||||
|
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,18 +167,20 @@ void TextFieldEditor::updateForm() {
|
|||||||
*/
|
*/
|
||||||
void TextFieldEditor::activeConnections(bool active) {
|
void TextFieldEditor::activeConnections(bool active) {
|
||||||
if (active) {
|
if (active) {
|
||||||
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
|
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
|
||||||
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
|
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
|
||||||
connect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
|
connect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
|
||||||
connect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
|
connect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
|
||||||
connect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
|
connect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
|
||||||
connect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextFieldRotationAngle()));
|
connect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextFieldRotationAngle()));
|
||||||
|
connect(m_tagg_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTagg()));
|
||||||
} else {
|
} else {
|
||||||
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
|
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
|
||||||
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
|
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
|
||||||
disconnect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
|
disconnect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
|
||||||
disconnect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
|
disconnect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
|
||||||
disconnect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
|
disconnect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
|
||||||
disconnect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextFieldRotationAngle()));
|
disconnect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextFieldRotationAngle()));
|
||||||
|
connect(m_tagg_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTagg()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ class TextFieldEditor : public ElementItemEditor {
|
|||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
PartTextField *part;
|
PartTextField *part;
|
||||||
QLineEdit *qle_x, *qle_y, *qle_text;
|
QLineEdit *qle_text;
|
||||||
|
QComboBox *m_tagg_cb;
|
||||||
QSpinBox *font_size;
|
QSpinBox *font_size;
|
||||||
|
QDoubleSpinBox *qle_x, *qle_y;
|
||||||
QCheckBox *rotate;
|
QCheckBox *rotate;
|
||||||
QTextOrientationSpinBoxWidget *rotation_angle_;
|
QTextOrientationSpinBoxWidget *rotation_angle_;
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ class TextFieldEditor : public ElementItemEditor {
|
|||||||
void updateTextFieldS();
|
void updateTextFieldS();
|
||||||
void updateTextFieldR();
|
void updateTextFieldR();
|
||||||
void updateTextFieldRotationAngle();
|
void updateTextFieldRotationAngle();
|
||||||
|
void updateTagg();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ OrientationSet::OrientationSet() :
|
|||||||
east_ori(true),
|
east_ori(true),
|
||||||
south_ori(true),
|
south_ori(true),
|
||||||
west_ori(true),
|
west_ori(true),
|
||||||
default_ori(QET::North),
|
default_ori(Qet::North),
|
||||||
current_ori(QET::North)
|
current_ori(Qet::North)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,8 +42,8 @@ bool OrientationSet::setNorth (bool ori) {
|
|||||||
north_ori = ori;
|
north_ori = ori;
|
||||||
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
||||||
if (!ori) {
|
if (!ori) {
|
||||||
if (default_ori == QET::North) default_ori = next();
|
if (default_ori == Qet::North) default_ori = next();
|
||||||
if (current_ori == QET::North) current_ori = next();
|
if (current_ori == Qet::North) current_ori = next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(can_set_ori);
|
return(can_set_ori);
|
||||||
@@ -60,8 +60,8 @@ bool OrientationSet::setEast (bool ori) {
|
|||||||
east_ori = ori;
|
east_ori = ori;
|
||||||
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
||||||
if (!ori) {
|
if (!ori) {
|
||||||
if (default_ori == QET::East) default_ori = next();
|
if (default_ori == Qet::East) default_ori = next();
|
||||||
if (current_ori == QET::East) current_ori = next();
|
if (current_ori == Qet::East) current_ori = next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(can_set_ori);
|
return(can_set_ori);
|
||||||
@@ -78,8 +78,8 @@ bool OrientationSet::setSouth (bool ori) {
|
|||||||
south_ori = ori;
|
south_ori = ori;
|
||||||
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
||||||
if (!ori) {
|
if (!ori) {
|
||||||
if (default_ori == QET::South) default_ori = next();
|
if (default_ori == Qet::South) default_ori = next();
|
||||||
if (current_ori == QET::South) current_ori = next();
|
if (current_ori == Qet::South) current_ori = next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(can_set_ori);
|
return(can_set_ori);
|
||||||
@@ -96,8 +96,8 @@ bool OrientationSet::setWest (bool ori) {
|
|||||||
west_ori = ori;
|
west_ori = ori;
|
||||||
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
// en cas de desactivation d'une orientation, il faut verifier voire corriger les orientations courante et par defaut
|
||||||
if (!ori) {
|
if (!ori) {
|
||||||
if (default_ori == QET::West) default_ori = next();
|
if (default_ori == Qet::West) default_ori = next();
|
||||||
if (current_ori == QET::West) current_ori = next();
|
if (current_ori == Qet::West) current_ori = next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(can_set_ori);
|
return(can_set_ori);
|
||||||
@@ -108,7 +108,7 @@ bool OrientationSet::setWest (bool ori) {
|
|||||||
@param ori nouvelle orientation courante
|
@param ori nouvelle orientation courante
|
||||||
@return true si le changement d'orientation a reussi, false sinon
|
@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);
|
bool can_set_ori = accept(ori);
|
||||||
if (can_set_ori) current_ori = ori;
|
if (can_set_ori) current_ori = ori;
|
||||||
return(can_set_ori);
|
return(can_set_ori);
|
||||||
@@ -117,18 +117,18 @@ bool OrientationSet::setCurrent(QET::Orientation ori) {
|
|||||||
/**
|
/**
|
||||||
@return l'orientation suivant l'orientation courante
|
@return l'orientation suivant l'orientation courante
|
||||||
*/
|
*/
|
||||||
QET::Orientation OrientationSet::next() const {
|
Qet::Orientation OrientationSet::next() const {
|
||||||
QET::Orientation result = current_ori;
|
Qet::Orientation result = current_ori;
|
||||||
do result = QET::nextOrientation(result); while (!accept(result));
|
do result = Qet::nextOrientation(result); while (!accept(result));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return l'orientation precedant l'orientation courante
|
@return l'orientation precedant l'orientation courante
|
||||||
*/
|
*/
|
||||||
QET::Orientation OrientationSet::previous() const {
|
Qet::Orientation OrientationSet::previous() const {
|
||||||
QET::Orientation result = current_ori;
|
Qet::Orientation result = current_ori;
|
||||||
do result = QET::previousOrientation(result); while (!accept(result));
|
do result = Qet::previousOrientation(result); while (!accept(result));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,13 +157,13 @@ const OrientationSet OrientationSet::operator--(int) {
|
|||||||
@param ori L'orientation en question
|
@param ori L'orientation en question
|
||||||
@return true si l'orientation est utilisable, false sinon
|
@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;
|
bool accepted_ori = false;
|
||||||
switch(ori) {
|
switch(ori) {
|
||||||
case QET::North: accepted_ori = north_ori; break;
|
case Qet::North: accepted_ori = north_ori; break;
|
||||||
case QET::East : accepted_ori = east_ori; break;
|
case Qet::East : accepted_ori = east_ori; break;
|
||||||
case QET::South: accepted_ori = south_ori; break;
|
case Qet::South: accepted_ori = south_ori; break;
|
||||||
case QET::West : accepted_ori = west_ori; break;
|
case Qet::West : accepted_ori = west_ori; break;
|
||||||
}
|
}
|
||||||
return(accepted_ori);
|
return(accepted_ori);
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ bool OrientationSet::accept(QET::Orientation ori) const {
|
|||||||
Definit l'orientation suivante comme etant l'orientation courante
|
Definit l'orientation suivante comme etant l'orientation courante
|
||||||
@return la nouvelle orientation courante
|
@return la nouvelle orientation courante
|
||||||
*/
|
*/
|
||||||
QET::Orientation OrientationSet::setNext() {
|
Qet::Orientation OrientationSet::setNext() {
|
||||||
setCurrent(next());
|
setCurrent(next());
|
||||||
return(current_ori);
|
return(current_ori);
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ QET::Orientation OrientationSet::setNext() {
|
|||||||
Definit l'orientation precedente comme etant l'orientation courante
|
Definit l'orientation precedente comme etant l'orientation courante
|
||||||
@return la nouvelle orientation courante
|
@return la nouvelle orientation courante
|
||||||
*/
|
*/
|
||||||
QET::Orientation OrientationSet::setPrevious() {
|
Qet::Orientation OrientationSet::setPrevious() {
|
||||||
setCurrent(previous());
|
setCurrent(previous());
|
||||||
return(current_ori);
|
return(current_ori);
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ bool OrientationSet::fromString(const QString &str) {
|
|||||||
if (matches.count("d") != 1) return(false);
|
if (matches.count("d") != 1) return(false);
|
||||||
|
|
||||||
bool *ori_pointers[4] = { &north_ori, &east_ori, &south_ori, &west_ori };
|
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) {
|
for(int i = 0 ; i < 4 ; ++ i) {
|
||||||
QString current = matches.at(i + 1);
|
QString current = matches.at(i + 1);
|
||||||
if (current == "d") {
|
if (current == "d") {
|
||||||
@@ -263,7 +263,7 @@ bool OrientationSet::fromString(const QString &str) {
|
|||||||
*/
|
*/
|
||||||
QString OrientationSet::toString() const {
|
QString OrientationSet::toString() const {
|
||||||
bool ori_pointers[4] = { north_ori, east_ori, south_ori, west_ori };
|
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("");
|
QString result("");
|
||||||
for(int i = 0 ; i < 4 ; ++ i) {
|
for(int i = 0 ; i < 4 ; ++ i) {
|
||||||
if (default_ori == ori_ints[i]) result += "d";
|
if (default_ori == ori_ints[i]) result += "d";
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ class OrientationSet {
|
|||||||
bool east_ori;
|
bool east_ori;
|
||||||
bool south_ori;
|
bool south_ori;
|
||||||
bool west_ori;
|
bool west_ori;
|
||||||
QET::Orientation default_ori;
|
Qet::Orientation default_ori;
|
||||||
QET::Orientation current_ori;
|
Qet::Orientation current_ori;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -51,15 +51,15 @@ class OrientationSet {
|
|||||||
bool setEast(bool);
|
bool setEast(bool);
|
||||||
bool setSouth(bool);
|
bool setSouth(bool);
|
||||||
bool setWest(bool);
|
bool setWest(bool);
|
||||||
QET::Orientation defaultOrientation() const;
|
Qet::Orientation defaultOrientation() const;
|
||||||
void setDefaultOrientation(const QET::Orientation &);
|
void setDefaultOrientation(const Qet::Orientation &);
|
||||||
QET::Orientation current() const;
|
Qet::Orientation current() const;
|
||||||
bool setCurrent(QET::Orientation);
|
bool setCurrent(Qet::Orientation);
|
||||||
QET::Orientation next() const;
|
Qet::Orientation next() const;
|
||||||
QET::Orientation previous() const;
|
Qet::Orientation previous() const;
|
||||||
QET::Orientation setNext();
|
Qet::Orientation setNext();
|
||||||
QET::Orientation setPrevious();
|
Qet::Orientation setPrevious();
|
||||||
bool accept(QET::Orientation) const;
|
bool accept(Qet::Orientation) const;
|
||||||
const OrientationSet operator++(int);
|
const OrientationSet operator++(int);
|
||||||
const OrientationSet operator--(int);
|
const OrientationSet operator--(int);
|
||||||
const OrientationSet operator++();
|
const OrientationSet operator++();
|
||||||
@@ -101,21 +101,21 @@ inline bool OrientationSet::west() const {
|
|||||||
/**
|
/**
|
||||||
@param new_default_orientation The new default orientation
|
@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;
|
default_ori = new_default_orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the default orientation
|
@return the default orientation
|
||||||
*/
|
*/
|
||||||
inline QET::Orientation OrientationSet::defaultOrientation() const {
|
inline Qet::Orientation OrientationSet::defaultOrientation() const {
|
||||||
return(default_ori);
|
return(default_ori);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the current orientation
|
@return the current orientation
|
||||||
*/
|
*/
|
||||||
inline QET::Orientation OrientationSet::current() const {
|
inline Qet::Orientation OrientationSet::current() const {
|
||||||
return(current_ori);
|
return(current_ori);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,30 +22,30 @@
|
|||||||
/**
|
/**
|
||||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
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.
|
retourne.
|
||||||
@param s Chaine de caractere cense representer une orientation
|
@param s Chaine de caractere cense representer une orientation
|
||||||
@return l'orientation designee par la chaine de caractere
|
@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];
|
QChar c = s[0];
|
||||||
if (c == 'e') return(QET::East);
|
if (c == 'e') return(Qet::East);
|
||||||
else if (c == 's') return(QET::South);
|
else if (c == 's') return(Qet::South);
|
||||||
else if (c == 'w') return (QET::West);
|
else if (c == 'w') return (Qet::West);
|
||||||
else return(QET::North);
|
else return(Qet::North);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param o une orientation
|
@param o une orientation
|
||||||
@return une chaine de caractere representant l'orientation
|
@return une chaine de caractere representant l'orientation
|
||||||
*/
|
*/
|
||||||
QString QET::orientationToString(QET::Orientation o) {
|
QString Qet::orientationToString(Qet::Orientation o) {
|
||||||
QString ret;
|
QString ret;
|
||||||
switch(o) {
|
switch(o) {
|
||||||
case QET::North: ret = "n"; break;
|
case Qet::North: ret = "n"; break;
|
||||||
case QET::East : ret = "e"; break;
|
case Qet::East : ret = "e"; break;
|
||||||
case QET::South: ret = "s"; break;
|
case Qet::South: ret = "s"; break;
|
||||||
case QET::West : ret = "w"; break;
|
case Qet::West : ret = "w"; break;
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@@ -56,9 +56,9 @@ QString QET::orientationToString(QET::Orientation o) {
|
|||||||
@param b La seconde orientation de Borne
|
@param b La seconde orientation de Borne
|
||||||
@return Un booleen a true si les deux orientations de bornes sont sur le meme axe
|
@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) {
|
bool Qet::surLeMemeAxe(Qet::Orientation a, Qet::Orientation b) {
|
||||||
if ((a == QET::North || a == QET::South) && (b == QET::North || b == QET::South)) return(true);
|
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 if ((a == Qet::East || a == Qet::West) && (b == Qet::East || b == Qet::West)) return(true);
|
||||||
else return(false);
|
else return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ bool QET::surLeMemeAxe(QET::Orientation a, QET::Orientation b) {
|
|||||||
@param a L'orientation de borne
|
@param a L'orientation de borne
|
||||||
@return True si l'orientation de borne est horizontale, false sinon
|
@return True si l'orientation de borne est horizontale, false sinon
|
||||||
*/
|
*/
|
||||||
bool QET::estHorizontale(QET::Orientation a) {
|
bool Qet::estHorizontale(Qet::Orientation a) {
|
||||||
return(a == QET::East || a == QET::West);
|
return(a == Qet::East || a == Qet::West);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,8 +76,8 @@ bool QET::estHorizontale(QET::Orientation a) {
|
|||||||
@param a L'orientation de borne
|
@param a L'orientation de borne
|
||||||
@return True si l'orientation de borne est verticale, false sinon
|
@return True si l'orientation de borne est verticale, false sinon
|
||||||
*/
|
*/
|
||||||
bool QET::estVerticale(QET::Orientation a) {
|
bool Qet::estVerticale(Qet::Orientation a) {
|
||||||
return(a == QET::North || a == QET::South);
|
return(a == Qet::North || a == Qet::South);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,9 +87,9 @@ bool QET::estVerticale(QET::Orientation a) {
|
|||||||
@param o une orientation
|
@param o une orientation
|
||||||
@return l'orientation suivante
|
@return l'orientation suivante
|
||||||
*/
|
*/
|
||||||
QET::Orientation QET::nextOrientation(QET::Orientation o) {
|
Qet::Orientation Qet::nextOrientation(Qet::Orientation o) {
|
||||||
if (o < 0 || o > 2) return(QET::North);
|
if (o < 0 || o > 2) return(Qet::North);
|
||||||
return((QET::Orientation)(o + 1));
|
return((Qet::Orientation)(o + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,10 +99,10 @@ QET::Orientation QET::nextOrientation(QET::Orientation o) {
|
|||||||
@param o une orientation
|
@param o une orientation
|
||||||
@return l'orientation precedente
|
@return l'orientation precedente
|
||||||
*/
|
*/
|
||||||
QET::Orientation QET::previousOrientation(QET::Orientation o) {
|
Qet::Orientation Qet::previousOrientation(Qet::Orientation o) {
|
||||||
if (o < 0 || o > 3) return(QET::North);
|
if (o < 0 || o > 3) return(Qet::North);
|
||||||
if (o == QET::North) return(QET::West);
|
if (o == Qet::North) return(Qet::West);
|
||||||
return((QET::Orientation)(o - 1));
|
return((Qet::Orientation)(o - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -465,13 +465,13 @@ QStringList QET::splitWithSpaces(const QString &string) {
|
|||||||
@param end_type un type d'extremite
|
@param end_type un type d'extremite
|
||||||
@return une chaine representant le 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) {
|
switch(end_type) {
|
||||||
case QET::Simple: return("simple");
|
case Qet::Simple: return("simple");
|
||||||
case QET::Triangle: return("triangle");
|
case Qet::Triangle: return("triangle");
|
||||||
case QET::Circle: return("circle");
|
case Qet::Circle: return("circle");
|
||||||
case QET::Diamond: return("diamond");
|
case Qet::Diamond: return("diamond");
|
||||||
case QET::None:
|
case Qet::None:
|
||||||
default:
|
default:
|
||||||
return("none");
|
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,
|
@return le type d'extremite correspondant ; si la chaine est invalide,
|
||||||
QET::None est retourne.
|
QET::None est retourne.
|
||||||
*/
|
*/
|
||||||
QET::EndType QET::endTypeFromString(const QString &string) {
|
Qet::EndType Qet::endTypeFromString(const QString &string) {
|
||||||
if (string == "simple") return(QET::Simple);
|
if (string == "simple") return(Qet::Simple);
|
||||||
else if (string == "triangle") return(QET::Triangle);
|
else if (string == "triangle") return(Qet::Triangle);
|
||||||
else if (string == "circle") return(QET::Circle);
|
else if (string == "circle") return(Qet::Circle);
|
||||||
else if (string == "diamond") return(QET::Diamond);
|
else if (string == "diamond") return(Qet::Diamond);
|
||||||
else return(QET::None);
|
else return(Qet::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#ifndef _QET_H
|
#ifndef _QET_H
|
||||||
#define _QET_H
|
#define _QET_H
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
#include <QObject>
|
||||||
/**
|
/**
|
||||||
This file provides useful functions and enums that may be used from
|
This file provides useful functions and enums that may be used from
|
||||||
anywhere else within the QElectroTech application.
|
anywhere else within the QElectroTech application.
|
||||||
@@ -28,8 +29,6 @@ namespace QET {
|
|||||||
/// QElectroTech displayed version
|
/// QElectroTech displayed version
|
||||||
const QString displayedVersion = "0.4-dev";
|
const QString displayedVersion = "0.4-dev";
|
||||||
QString license();
|
QString license();
|
||||||
/// Orientation (used for electrical elements and their terminals)
|
|
||||||
enum Orientation {North, East, South, West};
|
|
||||||
|
|
||||||
/// Oriented movements
|
/// Oriented movements
|
||||||
enum OrientedMovement {
|
enum OrientedMovement {
|
||||||
@@ -73,17 +72,6 @@ namespace QET {
|
|||||||
Both = 3 ///< Invalid segment
|
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
|
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
|
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 lineContainsPoint(const QLineF &, const QPointF &);
|
||||||
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = 0);
|
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = 0);
|
||||||
bool attributeIsAnInteger(const QDomElement &, QString , int * = NULL);
|
bool attributeIsAnInteger(const QDomElement &, QString , int * = NULL);
|
||||||
@@ -163,8 +144,6 @@ namespace QET {
|
|||||||
QString unescapeSpaces(const QString &);
|
QString unescapeSpaces(const QString &);
|
||||||
QString joinWithSpaces(const QStringList &);
|
QString joinWithSpaces(const QStringList &);
|
||||||
QStringList splitWithSpaces(const QString &);
|
QStringList splitWithSpaces(const QString &);
|
||||||
QString endTypeToString(const QET::EndType &);
|
|
||||||
QET::EndType endTypeFromString(const QString &);
|
|
||||||
QString diagramAreaToString(const QET::DiagramArea &);
|
QString diagramAreaToString(const QET::DiagramArea &);
|
||||||
QET::DiagramArea diagramAreaFromString(const QString &);
|
QET::DiagramArea diagramAreaFromString(const QString &);
|
||||||
QString pointerString(void *);
|
QString pointerString(void *);
|
||||||
@@ -176,4 +155,35 @@ namespace QET {
|
|||||||
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
|
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
|
||||||
QPointF graphicsSceneEventPos(QEvent *);
|
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
|
#endif
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ void Conductor::segmentsToPath() {
|
|||||||
@param p2 Coordonnees du point d'amarrage de la borne 2
|
@param p2 Coordonnees du point d'amarrage de la borne 2
|
||||||
@param o2 Orientation 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(o1);
|
||||||
Q_UNUSED(o2);
|
Q_UNUSED(o2);
|
||||||
|
|
||||||
@@ -290,9 +290,9 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
|||||||
@param p2 Coordonnees du point d'amarrage de la borne 2
|
@param p2 Coordonnees du point d'amarrage de la borne 2
|
||||||
@param o2 Orientation 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;
|
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
|
// s'assure qu'il n'y a ni points
|
||||||
QList<QPointF> points;
|
QList<QPointF> points;
|
||||||
@@ -331,38 +331,38 @@ void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, co
|
|||||||
// commence le vrai trajet
|
// commence le vrai trajet
|
||||||
if (depart.y() < arrivee.y()) {
|
if (depart.y() < arrivee.y()) {
|
||||||
// trajet descendant
|
// 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"
|
// cas "3"
|
||||||
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||||
points << QPointF(ligne_inter_x, depart.y());
|
points << QPointF(ligne_inter_x, depart.y());
|
||||||
points << QPointF(ligne_inter_x, arrivee.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"
|
// cas "4"
|
||||||
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||||
points << QPointF(depart.x(), ligne_inter_y);
|
points << QPointF(depart.x(), ligne_inter_y);
|
||||||
points << QPointF(arrivee.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"
|
points << QPointF(arrivee.x(), depart.y()); // cas "2"
|
||||||
} else {
|
} else {
|
||||||
points << QPointF(depart.x(), arrivee.y()); // cas "1"
|
points << QPointF(depart.x(), arrivee.y()); // cas "1"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// trajet montant
|
// 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"
|
// cas "3"
|
||||||
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||||
points << QPointF(depart.x(), ligne_inter_y);
|
points << QPointF(depart.x(), ligne_inter_y);
|
||||||
points << QPointF(arrivee.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"
|
// cas "4"
|
||||||
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||||
points << QPointF(ligne_inter_x, depart.y());
|
points << QPointF(ligne_inter_x, depart.y());
|
||||||
points << QPointF(ligne_inter_x, arrivee.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"
|
points << QPointF(depart.x(), arrivee.y()); // cas "2"
|
||||||
} else {
|
} else {
|
||||||
points << QPointF(arrivee.x(), depart.y()); // cas "1"
|
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
|
@param ext_size la taille de la prolongation
|
||||||
@return le point correspondant a la borne apres 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;
|
QPointF extended_terminal;
|
||||||
switch(terminal_orientation) {
|
switch(terminal_orientation) {
|
||||||
case QET::North:
|
case Qet::North:
|
||||||
extended_terminal = QPointF(terminal.x(), terminal.y() - ext_size);
|
extended_terminal = QPointF(terminal.x(), terminal.y() - ext_size);
|
||||||
break;
|
break;
|
||||||
case QET::East:
|
case Qet::East:
|
||||||
extended_terminal = QPointF(terminal.x() + ext_size, terminal.y());
|
extended_terminal = QPointF(terminal.x() + ext_size, terminal.y());
|
||||||
break;
|
break;
|
||||||
case QET::South:
|
case Qet::South:
|
||||||
extended_terminal = QPointF(terminal.x(), terminal.y() + ext_size);
|
extended_terminal = QPointF(terminal.x(), terminal.y() + ext_size);
|
||||||
break;
|
break;
|
||||||
case QET::West:
|
case Qet::West:
|
||||||
extended_terminal = QPointF(terminal.x() - ext_size, terminal.y());
|
extended_terminal = QPointF(terminal.x() - ext_size, terminal.y());
|
||||||
break;
|
break;
|
||||||
default: extended_terminal = terminal;
|
default: extended_terminal = terminal;
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
private:
|
private:
|
||||||
void segmentsToPath();
|
void segmentsToPath();
|
||||||
void saveProfile(bool = true);
|
void saveProfile(bool = true);
|
||||||
void generateConductorPath(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);
|
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||||
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
||||||
QList<QPointF> segmentsToPoints() const;
|
QList<QPointF> segmentsToPoints() const;
|
||||||
QSet<Conductor *> relatedConductors() const;
|
QSet<Conductor *> relatedConductors() const;
|
||||||
@@ -161,7 +161,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
static int getCoeff(const qreal &, const qreal &);
|
static int getCoeff(const qreal &, const qreal &);
|
||||||
static int getSign(const qreal &);
|
static int getSign(const qreal &);
|
||||||
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
|
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, qreal, qreal = 0.0);
|
||||||
static qreal conductor_bound(qreal, qreal, bool);
|
static qreal conductor_bound(qreal, qreal, bool);
|
||||||
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
||||||
|
|||||||
@@ -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("x2"), &x2)) return(false);
|
||||||
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
|
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
|
||||||
|
|
||||||
QET::EndType first_end = QET::endTypeFromString(e.attribute("end1"));
|
Qet::EndType first_end = Qet::endTypeFromString(e.attribute("end1"));
|
||||||
QET::EndType second_end = QET::endTypeFromString(e.attribute("end2"));
|
Qet::EndType second_end = Qet::endTypeFromString(e.attribute("end2"));
|
||||||
qreal length1, length2;
|
qreal length1, length2;
|
||||||
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
|
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
|
||||||
if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 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;
|
QPointF start_point, stop_point;
|
||||||
if (draw_1st_end) {
|
if (draw_1st_end) {
|
||||||
QList<QPointF> four_points1(PartLine::fourEndPoints(point1, point2, length1));
|
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)));
|
qp.drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
|
||||||
start_point = four_points1[1];
|
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]);
|
qp.drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
|
||||||
start_point = four_points1[1];
|
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]);
|
qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
|
||||||
start_point = point1;
|
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]);
|
qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
|
||||||
start_point = four_points1[0];
|
start_point = four_points1[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajuste le depart selon l'epaisseur du trait
|
// 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);
|
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -388,22 +388,22 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
|
|||||||
// dessine la seconde extremite
|
// dessine la seconde extremite
|
||||||
if (draw_2nd_end) {
|
if (draw_2nd_end) {
|
||||||
QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2));
|
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)));
|
qp.drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
|
||||||
stop_point = four_points2[1];
|
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]);
|
qp.drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
|
||||||
stop_point = 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]);
|
qp.drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
|
||||||
stop_point = point2;
|
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]);
|
qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
|
||||||
stop_point = four_points2[0];
|
stop_point = four_points2[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajuste l'arrivee selon l'epaisseur du trait
|
// 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);
|
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -749,14 +749,14 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
|
|||||||
Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
||||||
// verifie la presence et la validite des attributs obligatoires
|
// verifie la presence et la validite des attributs obligatoires
|
||||||
qreal terminalx, terminaly;
|
qreal terminalx, terminaly;
|
||||||
QET::Orientation terminalo;
|
Qet::Orientation terminalo;
|
||||||
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
|
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
|
||||||
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
|
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
|
||||||
if (!e.hasAttribute("orientation")) return(0);
|
if (!e.hasAttribute("orientation")) return(0);
|
||||||
if (e.attribute("orientation") == "n") terminalo = QET::North;
|
if (e.attribute("orientation") == "n") terminalo = Qet::North;
|
||||||
else if (e.attribute("orientation") == "s") terminalo = QET::South;
|
else if (e.attribute("orientation") == "s") terminalo = Qet::South;
|
||||||
else if (e.attribute("orientation") == "e") terminalo = QET::East;
|
else if (e.attribute("orientation") == "e") terminalo = Qet::East;
|
||||||
else if (e.attribute("orientation") == "w") terminalo = QET::West;
|
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
|
||||||
else return(0);
|
else return(0);
|
||||||
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
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
|
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
|
||||||
|
|||||||
@@ -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
|
// modifie certains attributs pour que l'analyse par la classe CustomElement reussisse
|
||||||
int previous_x_value = qde.attribute("x").toInt();
|
int previous_x_value = qde.attribute("x").toInt();
|
||||||
int previous_y_value = qde.attribute("y").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;
|
qreal x_add = 0.0, y_add = 0.0;
|
||||||
if (previous_ori_value == QET::North) y_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::East) x_add = Terminal::terminalSize;
|
||||||
else if (previous_ori_value == QET::South) y_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;
|
else if (previous_ori_value == Qet::West) x_add = -Terminal::terminalSize;
|
||||||
qde.setAttribute("x", previous_x_value + x_add);
|
qde.setAttribute("x", previous_x_value + x_add);
|
||||||
qde.setAttribute("y", previous_y_value + y_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)) {
|
if (Terminal *new_terminal = CustomElement::parseTerminal(qde)) {
|
||||||
table_id_adr.insert(qde.attribute("id").toInt(), new_terminal);
|
table_id_adr.insert(qde.attribute("id").toInt(), new_terminal);
|
||||||
|
|||||||
@@ -35,21 +35,21 @@ const qreal Terminal::terminalSize = 4.0;
|
|||||||
@param number of terminal
|
@param number of terminal
|
||||||
@param name 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
|
// definition du pount d'amarrage pour un conducteur
|
||||||
dock_conductor_ = pf;
|
dock_conductor_ = pf;
|
||||||
|
|
||||||
// definition de l'orientation de la borne (par defaut : sud)
|
// 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;
|
else ori_ = o;
|
||||||
|
|
||||||
// calcul de la position du point d'amarrage a l'element
|
// calcul de la position du point d'amarrage a l'element
|
||||||
dock_elmt_ = dock_conductor_;
|
dock_elmt_ = dock_conductor_;
|
||||||
switch(ori_) {
|
switch(ori_) {
|
||||||
case QET::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
|
case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
|
||||||
case QET::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
||||||
case QET::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
||||||
case QET::South:
|
case Qet::South:
|
||||||
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
||||||
}
|
}
|
||||||
// Number of terminal
|
// 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 e Element auquel cette borne appartient
|
||||||
@param s Scene sur laquelle figure cette borne
|
@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),
|
QGraphicsItem(e, s),
|
||||||
parent_element_(e),
|
parent_element_(e),
|
||||||
hovered_color_(Terminal::neutralColor)
|
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 e Element auquel cette borne appartient
|
||||||
@param s Scene sur laquelle figure cette borne
|
@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),
|
QGraphicsItem(e, s),
|
||||||
parent_element_(e),
|
parent_element_(e),
|
||||||
hovered_color_(Terminal::neutralColor)
|
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 e Element auquel cette borne appartient
|
||||||
@param s Scene sur laquelle figure cette borne
|
@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),
|
QGraphicsItem(e, s),
|
||||||
parent_element_(e),
|
parent_element_(e),
|
||||||
hovered_color_(Terminal::neutralColor)
|
hovered_color_(Terminal::neutralColor)
|
||||||
@@ -135,7 +135,7 @@ Terminal::~Terminal() {
|
|||||||
pivote. Sinon elle renvoie son sens normal.
|
pivote. Sinon elle renvoie son sens normal.
|
||||||
@return L'orientation actuelle de la Terminal.
|
@return L'orientation actuelle de la Terminal.
|
||||||
*/
|
*/
|
||||||
QET::Orientation Terminal::orientation() const {
|
Qet::Orientation Terminal::orientation() const {
|
||||||
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
|
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
|
||||||
// orientations actuelle et par defaut de l'element
|
// orientations actuelle et par defaut de l'element
|
||||||
int ori_cur = elt -> orientation();
|
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
|
// angle de rotation de la borne sur la scene, divise par 90
|
||||||
int angle = ori_cur + ori_;
|
int angle = ori_cur + ori_;
|
||||||
while (angle >= 4) angle -= 4;
|
while (angle >= 4) angle -= 4;
|
||||||
return((QET::Orientation)angle);
|
return((Qet::Orientation)angle);
|
||||||
}
|
}
|
||||||
} else return(ori_);
|
} else return(ori_);
|
||||||
}
|
}
|
||||||
@@ -513,7 +513,7 @@ bool Terminal::valideXml(QDomElement &terminal) {
|
|||||||
// parse l'orientation
|
// parse l'orientation
|
||||||
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
||||||
if (!conv_ok) return(false);
|
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
|
// a ce stade, la borne est syntaxiquement correcte
|
||||||
return(true);
|
return(true);
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ class Terminal : public QGraphicsItem {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Terminal(QPointF, QET::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(QPointF, Qet::Orientation, Element * = 0, Diagram * = 0);
|
||||||
Terminal(qreal, qreal, 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, QString number, QString name, bool hiddenName, Element * = 0, Diagram * = 0);
|
||||||
virtual ~Terminal();
|
virtual ~Terminal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -60,7 +60,7 @@ class Terminal : public QGraphicsItem {
|
|||||||
Element *parentElement() const;
|
Element *parentElement() const;
|
||||||
|
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
QET::Orientation orientation() const;
|
Qet::Orientation orientation() const;
|
||||||
QPointF dockConductor() const;
|
QPointF dockConductor() const;
|
||||||
QString number() const;
|
QString number() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
@@ -108,7 +108,7 @@ class Terminal : public QGraphicsItem {
|
|||||||
/// docking point for parent element
|
/// docking point for parent element
|
||||||
QPointF dock_elmt_;
|
QPointF dock_elmt_;
|
||||||
/// terminal orientation
|
/// terminal orientation
|
||||||
QET::Orientation ori_;
|
Qet::Orientation ori_;
|
||||||
/// List of conductors attached to the terminal
|
/// List of conductors attached to the terminal
|
||||||
QList<Conductor *> conductors_;
|
QList<Conductor *> conductors_;
|
||||||
/// Pointer to a rectangle representing the terminal bounding rect;
|
/// Pointer to a rectangle representing the terminal bounding rect;
|
||||||
@@ -128,7 +128,7 @@ class Terminal : public QGraphicsItem {
|
|||||||
bool name_terminal_hidden;
|
bool name_terminal_hidden;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(QPointF, QET::Orientation, QString number, QString name, bool hiddenName);
|
void init(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user