mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Classe CustomElementEditor renommee en QETElementEditor.
Classe EditorScene renommee en ElementScene. Ajout de la classe ElementView. Ajout de la classe ElementItemeditor, classe parente des widgets d'edition. Modification des classes relatives a l'editeur afin que toutes aient acces a l'editeur, a la scene et au QUndoStack. Tous les widgets d'edition heritent donc de ElementItemEditor. Ajout des methodes abstraites property() et setproperty() dans la classe CustomElementPart et de leur implementation dans les classes qui en derivent. Sont desormais annulables les modifications : de style, sur les arcs, sur les bornes, sur les ellipses, sur les cercles, sur les champs de texte, sur les textes et sur les lignes. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@104 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -384,7 +384,7 @@ bool CustomElement::parseInput(QDomElement &e, Diagram *s) {
|
|||||||
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this, s);
|
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this, s);
|
||||||
eti -> setFont(QFont("Sans Serif", size));
|
eti -> setFont(QFont("Sans Serif", size));
|
||||||
eti -> setPos(pos_x, pos_y);
|
eti -> setPos(pos_x, pos_y);
|
||||||
if (e.attribute("rotate") == "false") eti -> setFollowParentRotations(true);
|
if (e.attribute("rotate") == "true") eti -> setFollowParentRotations(true);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "arceditor.h"
|
#include "arceditor.h"
|
||||||
#include "partarc.h"
|
#include "partarc.h"
|
||||||
|
|
||||||
ArcEditor::ArcEditor(PartArc *arc, QWidget *parent) : QWidget(parent) {
|
ArcEditor::ArcEditor(QETElementEditor *editor, PartArc *arc, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
|
|
||||||
part = arc;
|
part = arc;
|
||||||
|
|
||||||
@@ -31,12 +31,7 @@ ArcEditor::ArcEditor(PartArc *arc, QWidget *parent) : QWidget(parent) {
|
|||||||
grid -> addWidget(angle, 6, 1);
|
grid -> addWidget(angle, 6, 1);
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArc()));
|
activeConnections(true);
|
||||||
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArc()));
|
|
||||||
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArc()));
|
|
||||||
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArc()));
|
|
||||||
connect(start_angle, SIGNAL(valueChanged(int)), this, SLOT(updateArc()));
|
|
||||||
connect(angle, SIGNAL(valueChanged(int)), this, SLOT(updateArc()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArcEditor::~ArcEditor() {
|
ArcEditor::~ArcEditor() {
|
||||||
@@ -44,33 +39,46 @@ ArcEditor::~ArcEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ArcEditor::updateArc() {
|
void ArcEditor::updateArc() {
|
||||||
qreal _x = x -> text().toDouble();
|
part -> setProperty("x", x -> text().toDouble());
|
||||||
qreal _y = y -> text().toDouble();
|
part -> setProperty("y", y -> text().toDouble());
|
||||||
qreal _h = h -> text().toDouble();
|
part -> setProperty("diameter_h", h -> text().toDouble());
|
||||||
qreal _v = v -> text().toDouble();
|
part -> setProperty("diameter_v", v -> text().toDouble());
|
||||||
_v = _v < 0 ? -_v : _v;
|
|
||||||
part -> setRect(
|
|
||||||
QRectF(
|
|
||||||
part -> mapFromScene(QPointF(_x - (_h / 2.0), _y - (_v / 2.0))),
|
|
||||||
QSizeF(_h, _v)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
part -> setStartAngle(-start_angle -> value() + 90);
|
part -> setStartAngle(-start_angle -> value() + 90);
|
||||||
part -> setAngle(-angle -> value());
|
part -> setAngle(-angle -> value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArcEditor::updateArcX() { addChangePartCommand(tr("abscisse"), part, "x", x -> text().toDouble()); }
|
||||||
|
void ArcEditor::updateArcY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> text().toDouble()); }
|
||||||
|
void ArcEditor::updateArcH() { addChangePartCommand(tr("diam\350tre horizontal"), part, "diameter_h", h -> text().toDouble()); }
|
||||||
|
void ArcEditor::updateArcV() { addChangePartCommand(tr("diam\350tre vertical"), part, "diameter_v", v -> text().toDouble()); }
|
||||||
|
void ArcEditor::updateArcS() { addChangePartCommand(tr("angle de d\351part"), part, "start_angle", -start_angle -> value() + 90); }
|
||||||
|
void ArcEditor::updateArcA() { addChangePartCommand(tr("angle"), part, "angle", -angle -> value()); }
|
||||||
|
|
||||||
void ArcEditor::updateForm() {
|
void ArcEditor::updateForm() {
|
||||||
qreal _h = part -> rect().width();
|
activeConnections(false);
|
||||||
qreal _v = part -> rect().height();
|
x -> setText(part -> property("x").toString());
|
||||||
QPointF top_left(part -> sceneTopLeft());
|
y -> setText(part -> property("y").toString());
|
||||||
x -> setText(QString("%1").arg(top_left.x() + (_h / 2.0)));
|
h -> setText(part -> property("diameter_h").toString());
|
||||||
y -> setText(QString("%1").arg(top_left.y() + (_v / 2.0)));
|
v -> setText(part -> property("diameter_v").toString());
|
||||||
h -> setText(QString("%1").arg(_h));
|
|
||||||
v -> setText(QString("%1").arg(_v));
|
|
||||||
disconnect(start_angle, SIGNAL(valueChanged(int)), this, SLOT(updateArc()));
|
|
||||||
disconnect(angle, SIGNAL(valueChanged(int)), this, SLOT(updateArc()));
|
|
||||||
start_angle -> setValue(-part -> startAngle() + 90);
|
start_angle -> setValue(-part -> startAngle() + 90);
|
||||||
angle -> setValue(-part -> angle());
|
angle -> setValue(-part -> angle());
|
||||||
connect(start_angle, SIGNAL(valueChanged(int)), this, SLOT(updateArc()));
|
activeConnections(true);
|
||||||
connect(angle, SIGNAL(valueChanged(int)), this, SLOT(updateArc()));
|
}
|
||||||
|
|
||||||
|
void ArcEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArcX()));
|
||||||
|
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArcY()));
|
||||||
|
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArcH()));
|
||||||
|
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArcV()));
|
||||||
|
connect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
|
||||||
|
connect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
|
||||||
|
} else {
|
||||||
|
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateArcX()));
|
||||||
|
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateArcY()));
|
||||||
|
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateArcH()));
|
||||||
|
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateArcV()));
|
||||||
|
disconnect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
|
||||||
|
disconnect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#ifndef ARC_EDITOR_H
|
#ifndef ARC_EDITOR_H
|
||||||
#define ARC_EDITOR_H
|
#define ARC_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartArc;
|
class PartArc;
|
||||||
class ArcEditor : public QWidget {
|
class ArcEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
//constructeurs, destructeur
|
//constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ArcEditor(PartArc *, QWidget * = 0);
|
ArcEditor(QETElementEditor *, PartArc *, QWidget * = 0);
|
||||||
~ArcEditor();
|
~ArcEditor();
|
||||||
private:
|
private:
|
||||||
ArcEditor(const ArcEditor &);
|
ArcEditor(const ArcEditor &);
|
||||||
@@ -20,6 +21,15 @@ class ArcEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateArc();
|
void updateArc();
|
||||||
|
void updateArcX();
|
||||||
|
void updateArcY();
|
||||||
|
void updateArcH();
|
||||||
|
void updateArcV();
|
||||||
|
void updateArcS();
|
||||||
|
void updateArcA();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "circleeditor.h"
|
#include "circleeditor.h"
|
||||||
#include "partcircle.h"
|
#include "partcircle.h"
|
||||||
|
|
||||||
CircleEditor::CircleEditor(PartCircle *circle, QWidget *parent) : QWidget(parent) {
|
CircleEditor::CircleEditor(QETElementEditor *editor, PartCircle *circle, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
|
|
||||||
part = circle;
|
part = circle;
|
||||||
|
|
||||||
@@ -24,11 +24,8 @@ CircleEditor::CircleEditor(PartCircle *circle, QWidget *parent) : QWidget(parent
|
|||||||
grid -> addWidget(new QLabel(tr("Diam\350tre : ")), 2, 0);
|
grid -> addWidget(new QLabel(tr("Diam\350tre : ")), 2, 0);
|
||||||
grid -> addWidget(r, 2, 1);
|
grid -> addWidget(r, 2, 1);
|
||||||
|
|
||||||
|
activeConnections(true);
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
connect(x, SIGNAL(editingFinished()), this, SLOT(updateCircle()));
|
|
||||||
connect(y, SIGNAL(editingFinished()), this, SLOT(updateCircle()));
|
|
||||||
connect(r, SIGNAL(editingFinished()), this, SLOT(updateCircle()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleEditor::~CircleEditor() {
|
CircleEditor::~CircleEditor() {
|
||||||
@@ -36,21 +33,31 @@ CircleEditor::~CircleEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CircleEditor::updateCircle() {
|
void CircleEditor::updateCircle() {
|
||||||
qreal _x = x -> text().toDouble();
|
part -> setProperty("x", x -> text().toDouble());
|
||||||
qreal _y = y -> text().toDouble();
|
part -> setProperty("y", y -> text().toDouble());
|
||||||
qreal _d = r -> text().toDouble();
|
part -> setProperty("diameter", r -> text().toDouble());
|
||||||
part -> setRect(
|
|
||||||
QRectF(
|
|
||||||
part -> mapFromScene(QPointF(_x - _d / 2.0, _y - _d / 2.0)),
|
|
||||||
QSizeF(_d, _d)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CircleEditor::updateCircleX() { addChangePartCommand(tr("abscisse"), part, "x", x -> text().toDouble()); }
|
||||||
|
void CircleEditor::updateCircleY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> text().toDouble()); }
|
||||||
|
void CircleEditor::updateCircleD() { addChangePartCommand(tr("diam\350tre"), part, "diameter", r -> text().toDouble()); }
|
||||||
|
|
||||||
void CircleEditor::updateForm() {
|
void CircleEditor::updateForm() {
|
||||||
qreal _d = part -> rect().width();
|
activeConnections(false);
|
||||||
QPointF top_left(part -> sceneTopLeft());
|
x -> setText(part -> property("x").toString());
|
||||||
x -> setText(QString("%1").arg(top_left.x() + _d / 2.0));
|
y -> setText(part -> property("y").toString());
|
||||||
y -> setText(QString("%1").arg(top_left.y() + _d / 2.0));
|
r -> setText(part -> property("diameter").toString());
|
||||||
r -> setText(QString("%1").arg(_d));
|
activeConnections(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircleEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(x, SIGNAL(editingFinished()), this, SLOT(updateCircleX()));
|
||||||
|
connect(y, SIGNAL(editingFinished()), this, SLOT(updateCircleY()));
|
||||||
|
connect(r, SIGNAL(editingFinished()), this, SLOT(updateCircleD()));
|
||||||
|
} else {
|
||||||
|
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateCircleX()));
|
||||||
|
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateCircleY()));
|
||||||
|
disconnect(r, SIGNAL(editingFinished()), this, SLOT(updateCircleD()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
#ifndef CIRCLE_EDITOR_H
|
#ifndef CIRCLE_EDITOR_H
|
||||||
#define CIRCLE_EDITOR_H
|
#define CIRCLE_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartCircle;
|
class PartCircle;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un editeur de cercle.
|
Cette classe represente un editeur de cercle.
|
||||||
Elle permet d'editer a travers une interface graphique les
|
Elle permet d'editer a travers une interface graphique les
|
||||||
proprietes d'une cercle composant le dessin d'un element.
|
proprietes d'une cercle composant le dessin d'un element.
|
||||||
*/
|
*/
|
||||||
class CircleEditor : public QWidget {
|
class CircleEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeurs, destructeur
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
CircleEditor(PartCircle *, QWidget * = 0);
|
CircleEditor(QETElementEditor *, PartCircle *, QWidget * = 0);
|
||||||
virtual ~CircleEditor();
|
virtual ~CircleEditor();
|
||||||
private:
|
private:
|
||||||
CircleEditor(const CircleEditor &);
|
CircleEditor(const CircleEditor &);
|
||||||
@@ -24,6 +25,12 @@ class CircleEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateCircle();
|
void updateCircle();
|
||||||
|
void updateCircleX();
|
||||||
|
void updateCircleY();
|
||||||
|
void updateCircleD();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -131,3 +131,32 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const {
|
|||||||
QWidget *CustomElementGraphicPart::elementInformations() {
|
QWidget *CustomElementGraphicPart::elementInformations() {
|
||||||
return(style_editor);
|
return(style_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "styleeditor.h"
|
#include "styleeditor.h"
|
||||||
|
class QETElementEditor;
|
||||||
/**
|
/**
|
||||||
Cette classe represente une partie graphique d'element
|
Cette classe represente une partie graphique d'element
|
||||||
Elle encapsule des methodes afin de gerer les attributs de style communs
|
Elle encapsule des methodes afin de gerer les attributs de style communs
|
||||||
@@ -18,14 +19,15 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
CustomElementGraphicPart() :
|
CustomElementGraphicPart(QETElementEditor *editor) :
|
||||||
|
CustomElementPart(editor),
|
||||||
_linestyle(NormalStyle),
|
_linestyle(NormalStyle),
|
||||||
_lineweight(NormalWeight),
|
_lineweight(NormalWeight),
|
||||||
_filling(NoneFilling),
|
_filling(NoneFilling),
|
||||||
_color(BlackColor),
|
_color(BlackColor),
|
||||||
_antialiased(false)
|
_antialiased(false)
|
||||||
{
|
{
|
||||||
style_editor = new StyleEditor(this);
|
style_editor = new StyleEditor(elementEditor(), this);
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~CustomElementGraphicPart() {
|
virtual ~CustomElementGraphicPart() {
|
||||||
@@ -59,6 +61,8 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
bool antialiased() const;
|
bool antialiased() const;
|
||||||
|
|
||||||
QWidget *elementInformations();
|
QWidget *elementInformations();
|
||||||
|
void setProperty(const QString &, const QVariant &);
|
||||||
|
QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void stylesToXml(QDomElement &) const;
|
void stylesToXml(QDomElement &) const;
|
||||||
|
|||||||
@@ -1,6 +1,22 @@
|
|||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
|
#include "qetelementeditor.h"
|
||||||
|
|
||||||
QPicture *CustomElementPart::getCustomElementQPicture(CustomElement &ce) const {
|
QPicture *CustomElementPart::getCustomElementQPicture(CustomElement &ce) const {
|
||||||
return(&(ce.dessin));
|
return(&(ce.dessin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @return le QETElementEditor auquel cet editeur appartient
|
||||||
|
QETElementEditor *CustomElementPart::elementEditor() const {
|
||||||
|
return(element_editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return l'ElementScene contenant les parties editees par cet editeur
|
||||||
|
ElementScene *CustomElementPart::elementScene() const {
|
||||||
|
return(element_editor -> elementScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return la QUndoStack a utiliser pour les annulations
|
||||||
|
QUndoStack &CustomElementPart::undoStack() const {
|
||||||
|
return(elementScene() -> undoStack());
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
class CustomElement;
|
class CustomElement;
|
||||||
|
class QETElementEditor;
|
||||||
|
class ElementScene;
|
||||||
/**
|
/**
|
||||||
Cette classe abstraite represente une partie de la representation graphique
|
Cette classe abstraite represente une partie de la representation graphique
|
||||||
d'un element de schema electrique. Les attributs et methodes qu'elle
|
d'un element de schema electrique. Les attributs et methodes qu'elle
|
||||||
@@ -15,7 +17,7 @@ class CustomElement;
|
|||||||
class CustomElementPart {
|
class CustomElementPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
CustomElementPart() {};
|
CustomElementPart(QETElementEditor *editor) : element_editor(editor) {};
|
||||||
virtual ~CustomElementPart() {
|
virtual ~CustomElementPart() {
|
||||||
qDebug() << "~CustomElementPart()";
|
qDebug() << "~CustomElementPart()";
|
||||||
};
|
};
|
||||||
@@ -24,6 +26,7 @@ class CustomElementPart {
|
|||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
|
QETElementEditor *element_editor;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -33,6 +36,12 @@ class CustomElementPart {
|
|||||||
//virtual void renderToCustomElement(CustomElement &) const = 0;
|
//virtual void renderToCustomElement(CustomElement &) const = 0;
|
||||||
//virtual void toEditorPart(const EditorPart &);
|
//virtual void toEditorPart(const EditorPart &);
|
||||||
//virtual void fromEditorPart(const EditorPart &) = 0;
|
//virtual void fromEditorPart(const EditorPart &) = 0;
|
||||||
|
virtual void setProperty(const QString &, const QVariant &) = 0;
|
||||||
|
virtual QVariant property(const QString &) = 0;
|
||||||
|
virtual QETElementEditor *elementEditor() const;
|
||||||
|
virtual ElementScene *elementScene() const;
|
||||||
|
virtual QUndoStack &undoStack() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPicture *getCustomElementQPicture(CustomElement &ce) const;
|
QPicture *getCustomElementQPicture(CustomElement &ce) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
/*** DeletePartsCommand ***/
|
/*** DeletePartsCommand ***/
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param scene EditorScene concernee
|
@param scene ElementScene concernee
|
||||||
@param parts Liste des parties supprimees
|
@param parts Liste des parties supprimees
|
||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
DeletePartsCommand::DeletePartsCommand(
|
DeletePartsCommand::DeletePartsCommand(
|
||||||
EditorScene *scene,
|
ElementScene *scene,
|
||||||
const QList<QGraphicsItem *> parts,
|
const QList<QGraphicsItem *> parts,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
@@ -46,13 +46,13 @@ void DeletePartsCommand::redo() {
|
|||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param m Mouvement sous forme de QPointF
|
@param m Mouvement sous forme de QPointF
|
||||||
@param scene EditorScene concernee
|
@param scene ElementScene concernee
|
||||||
@param parts Liste des parties deplacees
|
@param parts Liste des parties deplacees
|
||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
MovePartsCommand::MovePartsCommand(
|
MovePartsCommand::MovePartsCommand(
|
||||||
const QPointF &m,
|
const QPointF &m,
|
||||||
EditorScene *scene,
|
ElementScene *scene,
|
||||||
const QList<QGraphicsItem *> parts,
|
const QList<QGraphicsItem *> parts,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
@@ -92,7 +92,7 @@ void MovePartsCommand::redo() {
|
|||||||
*/
|
*/
|
||||||
AddPartCommand::AddPartCommand(
|
AddPartCommand::AddPartCommand(
|
||||||
const QString &name,
|
const QString &name,
|
||||||
EditorScene *scene,
|
ElementScene *scene,
|
||||||
QGraphicsItem *p,
|
QGraphicsItem *p,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
@@ -123,3 +123,42 @@ void AddPartCommand::redo() {
|
|||||||
}
|
}
|
||||||
editor_scene -> addItem(part);
|
editor_scene -> addItem(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param name nom de la propriete modifiee
|
||||||
|
@param part partie modifiee
|
||||||
|
@param prop propriete modifiee
|
||||||
|
@param old_v ancienne valeur
|
||||||
|
@param new_v nouvelle valeur
|
||||||
|
@param parent qUndoCommand parent
|
||||||
|
*/
|
||||||
|
ChangePartCommand::ChangePartCommand(
|
||||||
|
const QString &name,
|
||||||
|
CustomElementPart *part,
|
||||||
|
const QString &prop,
|
||||||
|
const QVariant &old_v,
|
||||||
|
const QVariant &new_v,
|
||||||
|
QUndoCommand *parent
|
||||||
|
) :
|
||||||
|
QUndoCommand(QObject::tr("modification ") + name, parent),
|
||||||
|
cep(part),
|
||||||
|
property(prop),
|
||||||
|
old_value(old_v),
|
||||||
|
new_value(new_v)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destructeur
|
||||||
|
ChangePartCommand::~ChangePartCommand() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Annule le changement
|
||||||
|
void ChangePartCommand::undo() {
|
||||||
|
cep -> setProperty(property, old_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Refait le changement
|
||||||
|
void ChangePartCommand::redo() {
|
||||||
|
cep -> setProperty(property, new_value);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef EDITOR_COMMANDS_H
|
#ifndef EDITOR_COMMANDS_H
|
||||||
#define EDITOR_COMMANDS_H
|
#define EDITOR_COMMANDS_H
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "editorscene.h"
|
#include "elementscene.h"
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
class DeletePartsCommand : public QUndoCommand {
|
class DeletePartsCommand : public QUndoCommand {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
DeletePartsCommand(EditorScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
DeletePartsCommand(ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
||||||
virtual ~DeletePartsCommand();
|
virtual ~DeletePartsCommand();
|
||||||
private:
|
private:
|
||||||
DeletePartsCommand(const DeletePartsCommand &);
|
DeletePartsCommand(const DeletePartsCommand &);
|
||||||
@@ -25,7 +25,7 @@ class DeletePartsCommand : public QUndoCommand {
|
|||||||
/// Liste des parties supprimees
|
/// Liste des parties supprimees
|
||||||
QList<QGraphicsItem *> deleted_parts;
|
QList<QGraphicsItem *> deleted_parts;
|
||||||
/// scene sur laquelle se produisent les actions
|
/// scene sur laquelle se produisent les actions
|
||||||
EditorScene *editor_scene;
|
ElementScene *editor_scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +35,7 @@ class DeletePartsCommand : public QUndoCommand {
|
|||||||
class MovePartsCommand : public QUndoCommand {
|
class MovePartsCommand : public QUndoCommand {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
MovePartsCommand(const QPointF &, EditorScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
MovePartsCommand(const QPointF &, ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
||||||
virtual ~MovePartsCommand();
|
virtual ~MovePartsCommand();
|
||||||
private:
|
private:
|
||||||
MovePartsCommand(const MovePartsCommand &);
|
MovePartsCommand(const MovePartsCommand &);
|
||||||
@@ -49,7 +49,7 @@ class MovePartsCommand : public QUndoCommand {
|
|||||||
/// Liste des parties supprimees
|
/// Liste des parties supprimees
|
||||||
QList<QGraphicsItem *> moved_parts;
|
QList<QGraphicsItem *> moved_parts;
|
||||||
/// scene sur laquelle se produisent les actions
|
/// scene sur laquelle se produisent les actions
|
||||||
EditorScene *editor_scene;
|
ElementScene *editor_scene;
|
||||||
/// translation appliquee
|
/// translation appliquee
|
||||||
QPointF movement;
|
QPointF movement;
|
||||||
/// booleen pour eviter d'appeler redo() lors de la construction de l'objet
|
/// booleen pour eviter d'appeler redo() lors de la construction de l'objet
|
||||||
@@ -63,7 +63,7 @@ class MovePartsCommand : public QUndoCommand {
|
|||||||
class AddPartCommand : public QUndoCommand {
|
class AddPartCommand : public QUndoCommand {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
AddPartCommand(const QString &, EditorScene *, QGraphicsItem *, QUndoCommand * = 0);
|
AddPartCommand(const QString &, ElementScene *, QGraphicsItem *, QUndoCommand * = 0);
|
||||||
virtual ~AddPartCommand();
|
virtual ~AddPartCommand();
|
||||||
private:
|
private:
|
||||||
AddPartCommand(const AddPartCommand &);
|
AddPartCommand(const AddPartCommand &);
|
||||||
@@ -77,9 +77,36 @@ class AddPartCommand : public QUndoCommand {
|
|||||||
/// Liste des parties supprimees
|
/// Liste des parties supprimees
|
||||||
QGraphicsItem *part;
|
QGraphicsItem *part;
|
||||||
/// scene sur laquelle se produisent les actions
|
/// scene sur laquelle se produisent les actions
|
||||||
EditorScene *editor_scene;
|
ElementScene *editor_scene;
|
||||||
/// booleen pour eviter d'appeler redo() lors de la construction de l'objet
|
/// booleen pour eviter d'appeler redo() lors de la construction de l'objet
|
||||||
bool first_redo;
|
bool first_redo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Cette classe represente l'action de modifier une propriete d'une partie
|
||||||
|
lors de l'edition d'un element
|
||||||
|
*/
|
||||||
|
class ChangePartCommand : public QUndoCommand {
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
ChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &, const QVariant &, QUndoCommand * = 0);
|
||||||
|
virtual ~ChangePartCommand();
|
||||||
|
private:
|
||||||
|
ChangePartCommand(const ChangePartCommand &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
private:
|
||||||
|
/// Partie modifiee
|
||||||
|
CustomElementPart *cep;
|
||||||
|
/// Propriete modifiee
|
||||||
|
QString property;
|
||||||
|
/// ancienne valeur
|
||||||
|
QVariant old_value;
|
||||||
|
/// nouvelle valeur
|
||||||
|
QVariant new_value;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
61
editor/elementitemeditor.cpp
Normal file
61
editor/elementitemeditor.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#include "elementitemeditor.h"
|
||||||
|
#include "qetelementeditor.h"
|
||||||
|
#include "editorcommands.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param editor QETElementEditor auquel cet editeur appartient
|
||||||
|
@param parent QWidget parent de cet editeur
|
||||||
|
*/
|
||||||
|
ElementItemEditor::ElementItemEditor(QETElementEditor *editor, QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
element_editor(editor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return le QETElementEditor auquel cet editeur appartient
|
||||||
|
QETElementEditor *ElementItemEditor::elementEditor() const {
|
||||||
|
return(element_editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return l'ElementScene contenant les parties editees par cet editeur
|
||||||
|
ElementScene *ElementItemEditor::elementScene() const {
|
||||||
|
return(element_editor -> elementScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return la QUndoStack a utiliser pour les annulations
|
||||||
|
QUndoStack &ElementItemEditor::undoStack() const {
|
||||||
|
return(elementScene() -> undoStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Ajoute une ChangePartCommand a l'UndoStack. L'ancienne valeur sera
|
||||||
|
automatiquement recuperee.
|
||||||
|
@param name nom de la propriete modifiee
|
||||||
|
@param part partie modifiee
|
||||||
|
@param prop propriete modifiee
|
||||||
|
@param new_v nouvelle valeur
|
||||||
|
*/
|
||||||
|
void ElementItemEditor::addChangePartCommand(const QString &desc, CustomElementPart *part, const QString &prop, const QVariant &new_v) {
|
||||||
|
QVariant old_v = part -> property(prop);
|
||||||
|
if (old_v == new_v) return;
|
||||||
|
undoStack().push(
|
||||||
|
new ChangePartCommand(
|
||||||
|
desc + " " + element_type_name,
|
||||||
|
part,
|
||||||
|
prop,
|
||||||
|
old_v,
|
||||||
|
new_v
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return Le nom du type d'element edite
|
||||||
|
QString ElementItemEditor::elementTypeName() const {
|
||||||
|
return(element_type_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param name Nom du type d'element edite
|
||||||
|
void ElementItemEditor::setElementTypeName(const QString &name) {
|
||||||
|
element_type_name = name;
|
||||||
|
}
|
||||||
30
editor/elementitemeditor.h
Normal file
30
editor/elementitemeditor.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef ELEMENT_ITEM_EDITOR_H
|
||||||
|
#define ELEMENT_ITEM_EDITOR_H
|
||||||
|
#include <QtGui>
|
||||||
|
class QETElementEditor;
|
||||||
|
class ElementScene;
|
||||||
|
class CustomElementPart;
|
||||||
|
class ElementItemEditor : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
ElementItemEditor(QETElementEditor *, QWidget * = 0);
|
||||||
|
virtual ~ElementItemEditor() {};
|
||||||
|
private:
|
||||||
|
ElementItemEditor(const ElementItemEditor &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
|
virtual QETElementEditor *elementEditor() const;
|
||||||
|
virtual ElementScene *elementScene() const;
|
||||||
|
virtual QUndoStack &undoStack() const;
|
||||||
|
virtual void addChangePartCommand(const QString &, CustomElementPart *, const QString &, const QVariant &);
|
||||||
|
virtual QString elementTypeName() const;
|
||||||
|
virtual void setElementTypeName(const QString &);
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
private:
|
||||||
|
QETElementEditor *element_editor;
|
||||||
|
QString element_type_name;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "editorscene.h"
|
#include "elementscene.h"
|
||||||
|
#include "qetelementeditor.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "partline.h"
|
#include "partline.h"
|
||||||
#include "partellipse.h"
|
#include "partellipse.h"
|
||||||
@@ -13,58 +14,59 @@
|
|||||||
#define GRILLE_X 10
|
#define GRILLE_X 10
|
||||||
#define GRILLE_Y 10
|
#define GRILLE_Y 10
|
||||||
|
|
||||||
EditorScene::EditorScene(QObject *parent) :
|
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||||
QGraphicsScene(parent),
|
QGraphicsScene(parent),
|
||||||
_width(3),
|
_width(3),
|
||||||
_height(7),
|
_height(7),
|
||||||
_hotspot(15, 35),
|
_hotspot(15, 35),
|
||||||
qgi_manager(this)
|
qgi_manager(this),
|
||||||
|
element_editor(editor)
|
||||||
{
|
{
|
||||||
current_polygon = NULL;
|
current_polygon = NULL;
|
||||||
connect(this, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(slot_checkSelectionChanged()));
|
connect(this, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(slot_checkSelectionChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorScene::~EditorScene() {
|
ElementScene::~ElementScene() {
|
||||||
qDebug() << "~EditorScene()";
|
qDebug() << "~ElementScene()";
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_move() {
|
void ElementScene::slot_move() {
|
||||||
behavior = Normal;
|
behavior = Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addLine() {
|
void ElementScene::slot_addLine() {
|
||||||
behavior = Line;
|
behavior = Line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addCircle() {
|
void ElementScene::slot_addCircle() {
|
||||||
behavior = Circle;
|
behavior = Circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addEllipse() {
|
void ElementScene::slot_addEllipse() {
|
||||||
behavior = Ellipse;
|
behavior = Ellipse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addPolygon() {
|
void ElementScene::slot_addPolygon() {
|
||||||
behavior = Polygon;
|
behavior = Polygon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addText() {
|
void ElementScene::slot_addText() {
|
||||||
behavior = Text;
|
behavior = Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addTerminal() {
|
void ElementScene::slot_addTerminal() {
|
||||||
behavior = Terminal;
|
behavior = Terminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addArc() {
|
void ElementScene::slot_addArc() {
|
||||||
behavior = Arc;
|
behavior = Arc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_addTextField() {
|
void ElementScene::slot_addTextField() {
|
||||||
behavior = TextField;
|
behavior = TextField;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
||||||
QRectF temp_rect;
|
QRectF temp_rect;
|
||||||
qreal radius;
|
qreal radius;
|
||||||
@@ -116,7 +118,7 @@ void EditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
} else QGraphicsScene::mouseMoveEvent(e);
|
} else QGraphicsScene::mouseMoveEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
||||||
QPolygonF temp_polygon;
|
QPolygonF temp_polygon;
|
||||||
if (e -> button() & Qt::LeftButton) {
|
if (e -> button() & Qt::LeftButton) {
|
||||||
@@ -125,24 +127,24 @@ void EditorScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
QGraphicsScene::mousePressEvent(e);
|
QGraphicsScene::mousePressEvent(e);
|
||||||
break;
|
break;
|
||||||
case Line:
|
case Line:
|
||||||
current_line = new PartLine(0, this);
|
current_line = new PartLine(element_editor, 0, this);
|
||||||
current_line -> setLine(QLineF(e -> scenePos(), e -> scenePos()));
|
current_line -> setLine(QLineF(e -> scenePos(), e -> scenePos()));
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
current_ellipse = new PartEllipse(0, this);
|
current_ellipse = new PartEllipse(element_editor, 0, this);
|
||||||
current_ellipse -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
current_ellipse -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
||||||
break;
|
break;
|
||||||
case Arc:
|
case Arc:
|
||||||
current_arc = new PartArc(0, this);
|
current_arc = new PartArc(element_editor, 0, this);
|
||||||
current_arc -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
current_arc -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
||||||
break;
|
break;
|
||||||
case Circle:
|
case Circle:
|
||||||
current_circle = new PartCircle(0, this);
|
current_circle = new PartCircle(element_editor, 0, this);
|
||||||
current_circle -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
current_circle -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
||||||
break;
|
break;
|
||||||
case Polygon:
|
case Polygon:
|
||||||
if (current_polygon == NULL) {
|
if (current_polygon == NULL) {
|
||||||
current_polygon = new PartPolygon(0, this);
|
current_polygon = new PartPolygon(element_editor, 0, this);
|
||||||
temp_polygon = QPolygonF(0);
|
temp_polygon = QPolygonF(0);
|
||||||
} else temp_polygon = current_polygon -> polygon();
|
} else temp_polygon = current_polygon -> polygon();
|
||||||
// au debut, on insere deux points
|
// au debut, on insere deux points
|
||||||
@@ -156,7 +158,7 @@ void EditorScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
} else QGraphicsScene::mousePressEvent(e);
|
} else QGraphicsScene::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
PartTerminal *terminal;
|
PartTerminal *terminal;
|
||||||
PartText *text;
|
PartText *text;
|
||||||
PartTextField *textfield;
|
PartTextField *textfield;
|
||||||
@@ -179,17 +181,17 @@ void EditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
||||||
break;
|
break;
|
||||||
case Terminal:
|
case Terminal:
|
||||||
terminal = new PartTerminal(0, this);
|
terminal = new PartTerminal(element_editor, 0, this);
|
||||||
terminal -> setPos(e -> scenePos());
|
terminal -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
||||||
break;
|
break;
|
||||||
case Text:
|
case Text:
|
||||||
text = new PartText(0, this);
|
text = new PartText(element_editor, 0, this);
|
||||||
text -> setPos(e -> scenePos());
|
text -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
||||||
break;
|
break;
|
||||||
case TextField:
|
case TextField:
|
||||||
textfield = new PartTextField(0, this);
|
textfield = new PartTextField(element_editor, 0, this);
|
||||||
textfield -> setPos(e -> scenePos());
|
textfield -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
||||||
break;
|
break;
|
||||||
@@ -219,7 +221,7 @@ void EditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@param p Le QPainter a utiliser pour dessiner
|
@param p Le QPainter a utiliser pour dessiner
|
||||||
@param r Le rectangle de la zone a dessiner
|
@param r Le rectangle de la zone a dessiner
|
||||||
*/
|
*/
|
||||||
void EditorScene::drawBackground(QPainter *p, const QRectF &r) {
|
void ElementScene::drawBackground(QPainter *p, const QRectF &r) {
|
||||||
p -> save();
|
p -> save();
|
||||||
|
|
||||||
// desactive tout antialiasing, sauf pour le texte
|
// desactive tout antialiasing, sauf pour le texte
|
||||||
@@ -264,7 +266,7 @@ void EditorScene::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
@param p Le QPainter a utiliser pour dessiner
|
@param p Le QPainter a utiliser pour dessiner
|
||||||
@param r Le rectangle de la zone a dessiner
|
@param r Le rectangle de la zone a dessiner
|
||||||
*/
|
*/
|
||||||
void EditorScene::drawForeground(QPainter *p, const QRectF &) {
|
void ElementScene::drawForeground(QPainter *p, const QRectF &) {
|
||||||
p -> save();
|
p -> save();
|
||||||
|
|
||||||
// desactive tout antialiasing, sauf pour le texte
|
// desactive tout antialiasing, sauf pour le texte
|
||||||
@@ -279,7 +281,7 @@ void EditorScene::drawForeground(QPainter *p, const QRectF &) {
|
|||||||
p -> restore();
|
p -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDomDocument EditorScene::toXml() const {
|
const QDomDocument ElementScene::toXml() const {
|
||||||
// document XML
|
// document XML
|
||||||
QDomDocument xml_document;
|
QDomDocument xml_document;
|
||||||
|
|
||||||
@@ -308,7 +310,7 @@ const QDomDocument EditorScene::toXml() const {
|
|||||||
return(xml_document);
|
return(xml_document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::fromXml(const QDomDocument &xml_document) {
|
void ElementScene::fromXml(const QDomDocument &xml_document) {
|
||||||
|
|
||||||
QString error_message;
|
QString error_message;
|
||||||
bool state = true;
|
bool state = true;
|
||||||
@@ -365,14 +367,14 @@ void EditorScene::fromXml(const QDomDocument &xml_document) {
|
|||||||
QDomElement qde = n.toElement();
|
QDomElement qde = n.toElement();
|
||||||
if (qde.isNull()) continue;
|
if (qde.isNull()) continue;
|
||||||
CustomElementPart *cep;
|
CustomElementPart *cep;
|
||||||
if (qde.tagName() == "line") cep = new PartLine (0, this);
|
if (qde.tagName() == "line") cep = new PartLine (element_editor, 0, this);
|
||||||
else if (qde.tagName() == "ellipse") cep = new PartEllipse (0, this);
|
else if (qde.tagName() == "ellipse") cep = new PartEllipse (element_editor, 0, this);
|
||||||
else if (qde.tagName() == "circle") cep = new PartCircle (0, this);
|
else if (qde.tagName() == "circle") cep = new PartCircle (element_editor, 0, this);
|
||||||
else if (qde.tagName() == "polygon") cep = new PartPolygon (0, this);
|
else if (qde.tagName() == "polygon") cep = new PartPolygon (element_editor, 0, this);
|
||||||
else if (qde.tagName() == "terminal") cep = new PartTerminal (0, this);
|
else if (qde.tagName() == "terminal") cep = new PartTerminal (element_editor, 0, this);
|
||||||
else if (qde.tagName() == "text") cep = new PartText (0, this);
|
else if (qde.tagName() == "text") cep = new PartText (element_editor, 0, this);
|
||||||
else if (qde.tagName() == "input") cep = new PartTextField(0, this);
|
else if (qde.tagName() == "input") cep = new PartTextField(element_editor, 0, this);
|
||||||
else if (qde.tagName() == "arc") cep = new PartArc (0, this);
|
else if (qde.tagName() == "arc") cep = new PartArc (element_editor, 0, this);
|
||||||
else continue;
|
else continue;
|
||||||
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) qgi -> setZValue(z++);
|
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) qgi -> setZValue(z++);
|
||||||
cep -> fromXml(qde);
|
cep -> fromXml(qde);
|
||||||
@@ -382,34 +384,34 @@ void EditorScene::fromXml(const QDomDocument &xml_document) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack &EditorScene::undoStack() {
|
QUndoStack &ElementScene::undoStack() {
|
||||||
return(undo_stack);
|
return(undo_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
QGIManager &EditorScene::qgiManager() {
|
QGIManager &ElementScene::qgiManager() {
|
||||||
return(qgi_manager);
|
return(qgi_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_checkSelectionChanged() {
|
void ElementScene::slot_checkSelectionChanged() {
|
||||||
static QList<QGraphicsItem *> cache_selecteditems = QList<QGraphicsItem *>();
|
static QList<QGraphicsItem *> cache_selecteditems = QList<QGraphicsItem *>();
|
||||||
QList<QGraphicsItem *> selecteditems = selectedItems();
|
QList<QGraphicsItem *> selecteditems = selectedItems();
|
||||||
if (cache_selecteditems != selecteditems) emit(selectionChanged());
|
if (cache_selecteditems != selecteditems) emit(selectionChanged());
|
||||||
cache_selecteditems = selecteditems;
|
cache_selecteditems = selecteditems;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_selectAll() {
|
void ElementScene::slot_selectAll() {
|
||||||
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(true);
|
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_deselectAll() {
|
void ElementScene::slot_deselectAll() {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_invertSelection() {
|
void ElementScene::slot_invertSelection() {
|
||||||
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(!qgi -> isSelected());
|
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(!qgi -> isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_delete() {
|
void ElementScene::slot_delete() {
|
||||||
// verifie qu'il y a qqc de selectionne
|
// verifie qu'il y a qqc de selectionne
|
||||||
QList<QGraphicsItem *> selected_items = selectedItems();
|
QList<QGraphicsItem *> selected_items = selectedItems();
|
||||||
if (selected_items.isEmpty()) return;
|
if (selected_items.isEmpty()) return;
|
||||||
@@ -418,7 +420,7 @@ void EditorScene::slot_delete() {
|
|||||||
undo_stack.push(new DeletePartsCommand(this, selected_items));
|
undo_stack.push(new DeletePartsCommand(this, selected_items));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_editSizeHotSpot() {
|
void ElementScene::slot_editSizeHotSpot() {
|
||||||
// cree un dialogue
|
// cree un dialogue
|
||||||
QDialog dialog_sh;
|
QDialog dialog_sh;
|
||||||
dialog_sh.setModal(true);
|
dialog_sh.setModal(true);
|
||||||
@@ -456,7 +458,7 @@ void EditorScene::slot_editSizeHotSpot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_editOrientations() {
|
void ElementScene::slot_editOrientations() {
|
||||||
|
|
||||||
// cree un dialogue
|
// cree un dialogue
|
||||||
QDialog dialog_ori;
|
QDialog dialog_ori;
|
||||||
@@ -486,7 +488,7 @@ void EditorScene::slot_editOrientations() {
|
|||||||
if (dialog_ori.exec() == QDialog::Accepted) ori = ori_widget -> orientationSet();
|
if (dialog_ori.exec() == QDialog::Accepted) ori = ori_widget -> orientationSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorScene::slot_editNames() {
|
void ElementScene::slot_editNames() {
|
||||||
|
|
||||||
// cree un dialogue
|
// cree un dialogue
|
||||||
QDialog dialog;
|
QDialog dialog;
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
#ifndef EDITOR_SCNE_H
|
#ifndef ELEMENT_SCENE_H
|
||||||
#define EDITOR_SCNE_H
|
#define ELEMENT_SCENE_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include "nameslistwidget.h"
|
#include "nameslistwidget.h"
|
||||||
#include "orientationsetwidget.h"
|
#include "orientationsetwidget.h"
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
|
class QETElementEditor;
|
||||||
class PartLine;
|
class PartLine;
|
||||||
class PartEllipse;
|
class PartEllipse;
|
||||||
class PartCircle;
|
class PartCircle;
|
||||||
class PartPolygon;
|
class PartPolygon;
|
||||||
class PartArc;
|
class PartArc;
|
||||||
class EditorScene : public QGraphicsScene {
|
class ElementScene : public QGraphicsScene {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// enum
|
// enum
|
||||||
@@ -18,11 +19,11 @@ class EditorScene : public QGraphicsScene {
|
|||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
EditorScene(QObject * = 0);
|
ElementScene(QETElementEditor *, QObject * = 0);
|
||||||
virtual ~EditorScene();
|
virtual ~ElementScene();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EditorScene(const EditorScene &);
|
ElementScene(const ElementScene &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -48,6 +49,7 @@ class EditorScene : public QGraphicsScene {
|
|||||||
PartCircle *current_circle;
|
PartCircle *current_circle;
|
||||||
PartPolygon *current_polygon;
|
PartPolygon *current_polygon;
|
||||||
PartArc *current_arc;
|
PartArc *current_arc;
|
||||||
|
QETElementEditor *element_editor;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -97,47 +99,47 @@ class EditorScene : public QGraphicsScene {
|
|||||||
void needNormalMode();
|
void needNormalMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void EditorScene::setWidth(const uint &wid) {
|
inline void ElementScene::setWidth(const uint &wid) {
|
||||||
_width = wid;
|
_width = wid;
|
||||||
while (_width % 10) ++ _width;
|
while (_width % 10) ++ _width;
|
||||||
_width /= 10;
|
_width /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint EditorScene::width() const {
|
inline uint ElementScene::width() const {
|
||||||
return(_width * 10);
|
return(_width * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void EditorScene::setHeight(const uint &hei) {
|
inline void ElementScene::setHeight(const uint &hei) {
|
||||||
_height = hei;
|
_height = hei;
|
||||||
while (_height % 10) ++ _height;
|
while (_height % 10) ++ _height;
|
||||||
_height /= 10;
|
_height /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint EditorScene::height() const {
|
inline uint ElementScene::height() const {
|
||||||
return(_height * 10);
|
return(_height * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void EditorScene::setHotspot(const QPoint &hs) {
|
inline void ElementScene::setHotspot(const QPoint &hs) {
|
||||||
_hotspot = hs;
|
_hotspot = hs;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPoint EditorScene::hotspot() const {
|
inline QPoint ElementScene::hotspot() const {
|
||||||
return(_hotspot);
|
return(_hotspot);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void EditorScene::setNames(const NamesList nameslist) {
|
inline void ElementScene::setNames(const NamesList nameslist) {
|
||||||
_names = nameslist;
|
_names = nameslist;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline NamesList EditorScene::names() const {
|
inline NamesList ElementScene::names() const {
|
||||||
return(_names);
|
return(_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline OrientationSet EditorScene::orientations() {
|
inline OrientationSet ElementScene::orientations() {
|
||||||
return(ori);
|
return(ori);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void EditorScene::setOrientations(const OrientationSet &orientation_set) {
|
inline void ElementScene::setOrientations(const OrientationSet &orientation_set) {
|
||||||
ori = orientation_set;
|
ori = orientation_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
35
editor/elementview.cpp
Normal file
35
editor/elementview.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "elementview.h"
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param scene ElementScene visualisee par cette ElementView
|
||||||
|
@param parent QWidget parent de cette ElementView
|
||||||
|
*/
|
||||||
|
ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
||||||
|
QGraphicsView(scene, parent),
|
||||||
|
_scene(scene)
|
||||||
|
{
|
||||||
|
setInteractive(true);
|
||||||
|
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
//setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
//setSceneRect(QRectF(0.0, 0.0, 50.0, 200.0));
|
||||||
|
scale(4.0, 4.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destructeur
|
||||||
|
ElementView::~ElementView() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return l'ElementScene visualisee par cette ElementView
|
||||||
|
ElementScene *ElementView::scene() const {
|
||||||
|
return(_scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Definit l'ElementScene visualisee par cette ElementView
|
||||||
|
@param s l'ElementScene visualisee par cette ElementView
|
||||||
|
*/
|
||||||
|
void ElementView::setScene(ElementScene *s) {
|
||||||
|
QGraphicsView::setScene(s);
|
||||||
|
_scene = s;
|
||||||
|
}
|
||||||
24
editor/elementview.h
Normal file
24
editor/elementview.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef ELEMENT_VIEW_H
|
||||||
|
#define ELEMENT_VIEW_H
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include "elementscene.h"
|
||||||
|
class ElementView : public QGraphicsView {
|
||||||
|
Q_OBJECT
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
ElementView(ElementScene *, QWidget * = 0);
|
||||||
|
virtual ~ElementView();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElementView(const ElementView &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
|
ElementScene *scene() const;
|
||||||
|
void setScene(ElementScene *);
|
||||||
|
|
||||||
|
//attributs
|
||||||
|
private:
|
||||||
|
ElementScene *_scene;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "ellipseeditor.h"
|
#include "ellipseeditor.h"
|
||||||
#include "partellipse.h"
|
#include "partellipse.h"
|
||||||
|
|
||||||
EllipseEditor::EllipseEditor(PartEllipse *ellipse, QWidget *parent) : QWidget(parent) {
|
EllipseEditor::EllipseEditor(QETElementEditor *editor, PartEllipse *ellipse, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
|
|
||||||
part = ellipse;
|
part = ellipse;
|
||||||
|
|
||||||
@@ -29,12 +29,8 @@ EllipseEditor::EllipseEditor(PartEllipse *ellipse, QWidget *parent) : QWidget(pa
|
|||||||
grid -> addWidget(new QLabel(tr("vertical :")), 4, 0);
|
grid -> addWidget(new QLabel(tr("vertical :")), 4, 0);
|
||||||
grid -> addWidget(v, 4, 1);
|
grid -> addWidget(v, 4, 1);
|
||||||
|
|
||||||
|
activeConnections(true);
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
connect(x, SIGNAL(editingFinished()), this, SLOT(updateEllipse()));
|
|
||||||
connect(y, SIGNAL(editingFinished()), this, SLOT(updateEllipse()));
|
|
||||||
connect(h, SIGNAL(editingFinished()), this, SLOT(updateEllipse()));
|
|
||||||
connect(v, SIGNAL(editingFinished()), this, SLOT(updateEllipse()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EllipseEditor::~EllipseEditor() {
|
EllipseEditor::~EllipseEditor() {
|
||||||
@@ -42,25 +38,36 @@ EllipseEditor::~EllipseEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EllipseEditor::updateEllipse() {
|
void EllipseEditor::updateEllipse() {
|
||||||
qreal _x = x -> text().toDouble();
|
part -> setProperty("x", x -> text().toDouble());
|
||||||
qreal _y = y -> text().toDouble();
|
part -> setProperty("y", x -> text().toDouble());
|
||||||
qreal _h = h -> text().toDouble();
|
part -> setProperty("diameter_h", x -> text().toDouble());
|
||||||
qreal _v = v -> text().toDouble();
|
part -> setProperty("diameter_v", x -> text().toDouble());
|
||||||
_v = _v < 0 ? -_v : _v;
|
|
||||||
part -> setRect(
|
|
||||||
QRectF(
|
|
||||||
part -> mapFromScene(QPointF(_x - (_h / 2.0), _y - (_v / 2.0))),
|
|
||||||
QSizeF(_h, _v)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EllipseEditor::updateEllipseX() { addChangePartCommand(tr("abscisse"), part, "x", x -> text().toDouble()); }
|
||||||
|
void EllipseEditor::updateEllipseY() { addChangePartCommand(tr("ordonn\351e"), part, "y", y -> text().toDouble()); }
|
||||||
|
void EllipseEditor::updateEllipseH() { addChangePartCommand(tr("diam\350tre horizontal"), part, "diameter_h", h -> text().toDouble()); }
|
||||||
|
void EllipseEditor::updateEllipseV() { addChangePartCommand(tr("diam\350tre vertical"), part, "diameter_v", v -> text().toDouble()); }
|
||||||
|
|
||||||
void EllipseEditor::updateForm() {
|
void EllipseEditor::updateForm() {
|
||||||
qreal _h = part -> rect().width();
|
activeConnections(false);
|
||||||
qreal _v = part -> rect().height();
|
x -> setText(part -> property("x").toString());
|
||||||
QPointF top_left(part -> sceneTopLeft());
|
y -> setText(part -> property("y").toString());
|
||||||
x -> setText(QString("%1").arg(top_left.x() + (_h / 2.0)));
|
h -> setText(part -> property("diameter_h").toString());
|
||||||
y -> setText(QString("%1").arg(top_left.y() + (_v / 2.0)));
|
v -> setText(part -> property("diameter_v").toString());
|
||||||
h -> setText(QString("%1").arg(_h));
|
activeConnections(true);
|
||||||
v -> setText(QString("%1").arg(_v));
|
}
|
||||||
|
|
||||||
|
void EllipseEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(x, SIGNAL(editingFinished()), this, SLOT(updateEllipseX()));
|
||||||
|
connect(y, SIGNAL(editingFinished()), this, SLOT(updateEllipseY()));
|
||||||
|
connect(h, SIGNAL(editingFinished()), this, SLOT(updateEllipseH()));
|
||||||
|
connect(v, SIGNAL(editingFinished()), this, SLOT(updateEllipseV()));
|
||||||
|
} else {
|
||||||
|
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateEllipseX()));
|
||||||
|
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateEllipseY()));
|
||||||
|
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateEllipseH()));
|
||||||
|
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateEllipseV()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#ifndef ELLIPSE_EDITOR_H
|
#ifndef ELLIPSE_EDITOR_H
|
||||||
#define ELLIPSE_EDITOR_H
|
#define ELLIPSE_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartEllipse;
|
class PartEllipse;
|
||||||
class EllipseEditor : public QWidget {
|
class EllipseEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
//constructeurs, destructeur
|
//constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
EllipseEditor(PartEllipse *, QWidget * = 0);
|
EllipseEditor(QETElementEditor *, PartEllipse *, QWidget * = 0);
|
||||||
~EllipseEditor();
|
~EllipseEditor();
|
||||||
private:
|
private:
|
||||||
EllipseEditor(const EllipseEditor &);
|
EllipseEditor(const EllipseEditor &);
|
||||||
@@ -19,6 +20,13 @@ class EllipseEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateEllipse();
|
void updateEllipse();
|
||||||
|
void updateEllipseX();
|
||||||
|
void updateEllipseY();
|
||||||
|
void updateEllipseH();
|
||||||
|
void updateEllipseV();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "lineeditor.h"
|
#include "lineeditor.h"
|
||||||
#include "partline.h"
|
#include "partline.h"
|
||||||
|
|
||||||
LineEditor::LineEditor(PartLine *line, QWidget *parent) : QWidget(parent) {
|
LineEditor::LineEditor(QETElementEditor *editor, PartLine *line, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
|
|
||||||
part = line;
|
part = line;
|
||||||
|
|
||||||
@@ -21,11 +21,6 @@ LineEditor::LineEditor(PartLine *line, QWidget *parent) : QWidget(parent) {
|
|||||||
grid -> addWidget(y2, 1, 3);
|
grid -> addWidget(y2, 1, 3);
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
connect(x1, SIGNAL(editingFinished()), this, SLOT(updateLine()));
|
|
||||||
connect(y1, SIGNAL(editingFinished()), this, SLOT(updateLine()));
|
|
||||||
connect(x2, SIGNAL(editingFinished()), this, SLOT(updateLine()));
|
|
||||||
connect(y2, SIGNAL(editingFinished()), this, SLOT(updateLine()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LineEditor::~LineEditor() {
|
LineEditor::~LineEditor() {
|
||||||
@@ -47,11 +42,32 @@ void LineEditor::updateLine() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LineEditor::updateLineX1() { addChangePartCommand(tr("abscisse point 1"), part, "x1", x1 -> text().toDouble()); }
|
||||||
|
void LineEditor::updateLineY1() { addChangePartCommand(tr("ordonn\351e point 1"), part, "y1", y1 -> text().toDouble()); }
|
||||||
|
void LineEditor::updateLineX2() { addChangePartCommand(tr("abscisse point 2"), part, "x2", x2 -> text().toDouble()); }
|
||||||
|
void LineEditor::updateLineY2() { addChangePartCommand(tr("ordonn\351e point 2"), part, "y2", y2 -> text().toDouble()); }
|
||||||
|
|
||||||
void LineEditor::updateForm() {
|
void LineEditor::updateForm() {
|
||||||
|
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 -> setText(QString("%1").arg(p1.x()));
|
||||||
y1 -> setText(QString("%1").arg(p1.y()));
|
y1 -> setText(QString("%1").arg(p1.y()));
|
||||||
x2 -> setText(QString("%1").arg(p2.x()));
|
x2 -> setText(QString("%1").arg(p2.x()));
|
||||||
y2 -> setText(QString("%1").arg(p2.y()));
|
y2 -> setText(QString("%1").arg(p2.y()));
|
||||||
|
activeConnections(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(x1, SIGNAL(editingFinished()), this, SLOT(updateLineX1()));
|
||||||
|
connect(y1, SIGNAL(editingFinished()), this, SLOT(updateLineY1()));
|
||||||
|
connect(x2, SIGNAL(editingFinished()), this, SLOT(updateLineX2()));
|
||||||
|
connect(y2, SIGNAL(editingFinished()), this, SLOT(updateLineY2()));
|
||||||
|
} else {
|
||||||
|
connect(x1, SIGNAL(editingFinished()), this, SLOT(updateLineX1()));
|
||||||
|
connect(y1, SIGNAL(editingFinished()), this, SLOT(updateLineY1()));
|
||||||
|
connect(x2, SIGNAL(editingFinished()), this, SLOT(updateLineX2()));
|
||||||
|
connect(y2, SIGNAL(editingFinished()), this, SLOT(updateLineY2()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#ifndef LINE_EDITOR_H
|
#ifndef LINE_EDITOR_H
|
||||||
#define LINE_EDITOR_H
|
#define LINE_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartLine;
|
class PartLine;
|
||||||
class LineEditor : public QWidget {
|
class LineEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
//constructeurs, destructeur
|
//constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
LineEditor(PartLine *, QWidget * = 0);
|
LineEditor(QETElementEditor *, PartLine *, QWidget * = 0);
|
||||||
~LineEditor();
|
~LineEditor();
|
||||||
private:
|
private:
|
||||||
LineEditor(const LineEditor &);
|
LineEditor(const LineEditor &);
|
||||||
@@ -19,6 +20,13 @@ class LineEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateLine();
|
void updateLine();
|
||||||
|
void updateLineX1();
|
||||||
|
void updateLineY1();
|
||||||
|
void updateLineX2();
|
||||||
|
void updateLineY2();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
#include "partarc.h"
|
#include "partarc.h"
|
||||||
#include "arceditor.h"
|
#include "arceditor.h"
|
||||||
|
|
||||||
PartArc::PartArc(QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
QGraphicsEllipseItem(parent, scene),
|
QGraphicsEllipseItem(parent, scene),
|
||||||
CustomElementGraphicPart(),
|
CustomElementGraphicPart(editor),
|
||||||
_angle(-90),
|
_angle(-90),
|
||||||
start_angle(0)
|
start_angle(0)
|
||||||
{
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new ArcEditor(this);
|
informations = new ArcEditor(elementEditor(), this);
|
||||||
|
informations -> setElementTypeName(QObject::tr("arc"));
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
|
style_editor -> setElementTypeName(QObject::tr("arc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
@@ -72,6 +74,57 @@ QPointF PartArc::sceneTopLeft() const {
|
|||||||
return(mapToScene(rect().topLeft()));
|
return(mapToScene(rect().topLeft()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant PartArc::property(const QString &property) {
|
||||||
|
// appelle la methode property de CustomElementGraphicpart pour les styles
|
||||||
|
QVariant style_property = CustomElementGraphicPart::property(property);
|
||||||
|
if (style_property != QVariant()) return(style_property);
|
||||||
|
|
||||||
|
if (property == "x") {
|
||||||
|
return(mapToScene(rect().center()).x());
|
||||||
|
} else if (property == "y") {
|
||||||
|
return(mapToScene(rect().center()).y());
|
||||||
|
} else if (property == "diameter_h") {
|
||||||
|
return(rect().width());
|
||||||
|
} else if (property == "diameter_v") {
|
||||||
|
return(rect().height());
|
||||||
|
} else if (property == "start_angle") {
|
||||||
|
return(start_angle);
|
||||||
|
} else if (property == "angle") {
|
||||||
|
return(_angle);
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartArc::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartArc::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class ArcEditor;
|
|||||||
class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartArc(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartArc(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartArc() {
|
virtual ~PartArc() {
|
||||||
qDebug() << "~PartArc()";
|
qDebug() << "~PartArc()";
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,8 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
|||||||
virtual void setStartAngle(int);
|
virtual void setStartAngle(int);
|
||||||
virtual int angle() const;
|
virtual int angle() const;
|
||||||
virtual int startAngle() const;
|
virtual int startAngle() const;
|
||||||
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#include "partcircle.h"
|
#include "partcircle.h"
|
||||||
#include "circleeditor.h"
|
#include "circleeditor.h"
|
||||||
|
|
||||||
PartCircle::PartCircle(QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsEllipseItem(parent, scene), CustomElementGraphicPart() {
|
PartCircle::PartCircle(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsEllipseItem(parent, scene), CustomElementGraphicPart(editor) {
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new CircleEditor(this);
|
informations = new CircleEditor(elementEditor(), this);
|
||||||
|
informations -> setElementTypeName(QObject::tr("cercle"));
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
|
style_editor -> setElementTypeName(QObject::tr("cercle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
@@ -52,6 +54,44 @@ void PartCircle::fromXml(const QDomElement &qde) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartCircle::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") {
|
||||||
|
QRectF current_rect = rect();
|
||||||
|
qreal new_diameter = qAbs(value.toDouble());
|
||||||
|
current_rect.translate(
|
||||||
|
(new_diameter - current_rect.width()) / -2.0,
|
||||||
|
(new_diameter - current_rect.height()) / -2.0
|
||||||
|
);
|
||||||
|
current_rect.setSize(QSizeF(new_diameter, new_diameter));
|
||||||
|
setRect(current_rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant PartCircle::property(const QString &property) {
|
||||||
|
// appelle la methode property de CustomElementGraphicpart pour les styles
|
||||||
|
QVariant style_property = CustomElementGraphicPart::property(property);
|
||||||
|
if (style_property != QVariant()) return(style_property);
|
||||||
|
|
||||||
|
if (property == "x") {
|
||||||
|
return(mapToScene(rect().center()).x());
|
||||||
|
} else if (property == "y") {
|
||||||
|
return(mapToScene(rect().center()).y());
|
||||||
|
} else if (property == "diameter") {
|
||||||
|
return(rect().width());
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartCircle::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartCircle::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class CircleEditor;
|
|||||||
class PartCircle : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
class PartCircle : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartCircle(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartCircle(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartCircle() {
|
virtual ~PartCircle() {
|
||||||
qDebug() << "~PartCircle()";
|
qDebug() << "~PartCircle()";
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,8 @@ class PartCircle : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
|||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
QPointF sceneCenter() const;
|
QPointF sceneCenter() const;
|
||||||
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#include "partellipse.h"
|
#include "partellipse.h"
|
||||||
#include "ellipseeditor.h"
|
#include "ellipseeditor.h"
|
||||||
|
|
||||||
PartEllipse::PartEllipse(QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsEllipseItem(parent, scene), CustomElementGraphicPart() {
|
PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsEllipseItem(parent, scene), CustomElementGraphicPart(editor) {
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new EllipseEditor(this);
|
informations = new EllipseEditor(elementEditor(), this);
|
||||||
|
informations -> setElementTypeName(QObject::tr("ellipse"));
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
|
style_editor -> setElementTypeName(QObject::tr("ellipse"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
@@ -52,6 +54,49 @@ void PartEllipse::fromXml(const QDomElement &qde) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant PartEllipse::property(const QString &property) {
|
||||||
|
// appelle la methode property de CustomElementGraphicpart pour les styles
|
||||||
|
QVariant style_property = CustomElementGraphicPart::property(property);
|
||||||
|
if (style_property != QVariant()) return(style_property);
|
||||||
|
|
||||||
|
if (property == "x") {
|
||||||
|
return(mapToScene(rect().center()).x());
|
||||||
|
} else if (property == "y") {
|
||||||
|
return(mapToScene(rect().center()).y());
|
||||||
|
} else if (property == "diameter_h") {
|
||||||
|
return(rect().width());
|
||||||
|
} else if (property == "diameter_v") {
|
||||||
|
return(rect().height());
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartEllipse::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartEllipse::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class EllipseEditor;
|
|||||||
class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartEllipse(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartEllipse(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartEllipse() {
|
virtual ~PartEllipse() {
|
||||||
qDebug() << "~PartEllipse()";
|
qDebug() << "~PartEllipse()";
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,8 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
|||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
#include "lineeditor.h"
|
#include "lineeditor.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
PartLine::PartLine(QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsLineItem(parent, scene), CustomElementGraphicPart() {
|
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsLineItem(parent, scene), CustomElementGraphicPart(editor) {
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new LineEditor(this);
|
informations = new LineEditor(elementEditor(), this);
|
||||||
|
informations -> setElementTypeName(QObject::tr("ligne"));
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
|
style_editor -> setElementTypeName(QObject::tr("ligne"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem */*q*/, QWidget */*w*/) {
|
void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem */*q*/, QWidget */*w*/) {
|
||||||
@@ -56,6 +58,40 @@ void PartLine::fromXml(const QDomElement &qde) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
setLine(QLineF(mapFromScene(new_p1), mapFromScene(new_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);
|
||||||
|
|
||||||
|
if (property == "x1") {
|
||||||
|
return(sceneP1().x());
|
||||||
|
} else if (property == "y1") {
|
||||||
|
return(sceneP1().y());
|
||||||
|
} else if (property == "x2") {
|
||||||
|
return(sceneP2().x());
|
||||||
|
} else if (property == "y2") {
|
||||||
|
return(sceneP2().y());
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartLine::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartLine::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
@@ -73,13 +109,6 @@ QPointF PartLine::sceneP2() const {
|
|||||||
return(mapToScene(line().p2()));
|
return(mapToScene(line().p2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
QPainterPath PartLine::shape() const {
|
QPainterPath PartLine::shape() const {
|
||||||
QList<QPointF> points = fourShapePoints();
|
QList<QPointF> points = fourShapePoints();
|
||||||
QPainterPath t;
|
QPainterPath t;
|
||||||
@@ -92,24 +121,6 @@ QPainterPath PartLine::shape() const {
|
|||||||
return(t);
|
return(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
QRectF PartLine::boundingRect() const {
|
|
||||||
QList<QPointF> points = fourShapePoints();
|
|
||||||
qreal min_x = points.first().x();
|
|
||||||
qreal max_x = points.first().x();
|
|
||||||
qreal min_y = points.first().y();
|
|
||||||
qreal max_y = points.first().y();
|
|
||||||
foreach(QPointF p, points) {
|
|
||||||
if (p.x() > max_x) max_x = p.x();
|
|
||||||
if (p.x() < min_x) min_x = p.x();
|
|
||||||
if (p.y() > max_y) max_y = p.y();
|
|
||||||
if (p.y() < min_y) min_y = p.y();
|
|
||||||
}
|
|
||||||
QRectF r;
|
|
||||||
r.setCoords(min_x, min_y, max_x, max_y);
|
|
||||||
return(r);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
@return une liste contenant les deux points de la droite + les 4 points entourant ces deux points
|
@return une liste contenant les deux points de la droite + les 4 points entourant ces deux points
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class LineEditor;
|
|||||||
class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartLine(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartLine(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartLine() {
|
virtual ~PartLine() {
|
||||||
qDebug() << "~PartLine()";
|
qDebug() << "~PartLine()";
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,8 @@ 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 &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
#include "partpolygon.h"
|
#include "partpolygon.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include "polygoneditor.h"
|
#include "polygoneditor.h"
|
||||||
PartPolygon::PartPolygon(QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
QGraphicsPolygonItem(parent, scene),
|
QGraphicsPolygonItem(parent, scene),
|
||||||
CustomElementGraphicPart(),
|
CustomElementGraphicPart(editor),
|
||||||
closed(false)
|
closed(false)
|
||||||
{
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
informations = new PolygonEditor(this);
|
informations = new PolygonEditor(elementEditor(), this);
|
||||||
|
informations -> setElementTypeName(QObject::tr("polygone"));
|
||||||
style_editor -> appendWidget(informations);
|
style_editor -> appendWidget(informations);
|
||||||
|
style_editor -> setElementTypeName(QObject::tr("polygone"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartPolygon::fromXml(const QDomElement &qde) {
|
void PartPolygon::fromXml(const QDomElement &qde) {
|
||||||
@@ -60,6 +62,20 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem */*q*/
|
|||||||
else painter -> drawPolyline(polygon());
|
else painter -> drawPolyline(polygon());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartPolygon::setProperty(const QString &property, const QVariant &value) {
|
||||||
|
CustomElementGraphicPart::setProperty(property, value);
|
||||||
|
if (property == "closed") closed = value.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartPolygon::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartPolygon::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class PolygonEditor;
|
|||||||
class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart {
|
class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartPolygon(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartPolygon(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartPolygon() {
|
virtual ~PartPolygon() {
|
||||||
qDebug() << "~PartPolygon()";
|
qDebug() << "~PartPolygon()";
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,8 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
|||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
void setClosed(bool c);
|
void setClosed(bool c);
|
||||||
bool isClosed() const;
|
bool isClosed() const;
|
||||||
|
void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "terminaleditor.h"
|
#include "terminaleditor.h"
|
||||||
|
|
||||||
PartTerminal::PartTerminal(QGraphicsItem *parent, QGraphicsScene *scene) :
|
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
CustomElementPart(),
|
CustomElementPart(editor),
|
||||||
QGraphicsItem(parent, scene),
|
QGraphicsItem(parent, scene),
|
||||||
_orientation(QET::North)
|
_orientation(QET::North)
|
||||||
{
|
{
|
||||||
informations = new TerminalEditor(this);
|
informations = new TerminalEditor(elementEditor(), this);
|
||||||
|
informations -> setElementTypeName(QObject::tr("borne"));
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setZValue(100000);
|
setZValue(100000);
|
||||||
@@ -97,6 +98,30 @@ void PartTerminal::setOrientation(QET::Orientation ori) {
|
|||||||
informations -> updateForm();
|
informations -> updateForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartTerminal::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartTerminal::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
class TerminalEditor;
|
class TerminalEditor;
|
||||||
|
class QETElementEditor;
|
||||||
class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
PartTerminal(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartTerminal(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartTerminal();
|
virtual ~PartTerminal();
|
||||||
private:
|
private:
|
||||||
PartTerminal(const PartTerminal &);
|
PartTerminal(const PartTerminal &);
|
||||||
@@ -27,6 +28,8 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
|||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
QET::Orientation orientation() const;
|
QET::Orientation orientation() const;
|
||||||
void setOrientation(QET::Orientation);
|
void setOrientation(QET::Orientation);
|
||||||
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#include "parttext.h"
|
#include "parttext.h"
|
||||||
#include "texteditor.h"
|
#include "texteditor.h"
|
||||||
|
#include "elementscene.h"
|
||||||
PartText::PartText(QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsTextItem(parent, scene), CustomElementPart(), can_check_changes(true) {
|
PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent, ElementScene *scene) :
|
||||||
|
QGraphicsTextItem(parent, scene),
|
||||||
|
CustomElementPart(editor)
|
||||||
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setPlainText(tr("T"));
|
setPlainText(tr("T"));
|
||||||
infos = new TextEditor(this);
|
infos = new TextEditor(elementEditor(), this);
|
||||||
|
infos -> setElementTypeName(QObject::tr("texte"));
|
||||||
}
|
}
|
||||||
|
|
||||||
PartText::~PartText() {
|
PartText::~PartText() {
|
||||||
@@ -88,8 +92,36 @@ void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
setFocus(Qt::MouseFocusReason);
|
setFocus(Qt::MouseFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(QFont(font().family(), value.toInt()));
|
||||||
|
} else if (property == "text") {
|
||||||
|
setPlainText(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant PartText::property(const QString &property) {
|
||||||
|
if (property == "x") {
|
||||||
|
return((scenePos() + margin()).x());
|
||||||
|
} else if (property == "y") {
|
||||||
|
return((scenePos() + margin()).y());
|
||||||
|
} else if (property == "size") {
|
||||||
|
return(font().pointSize());
|
||||||
|
} else if (property == "text") {
|
||||||
|
return(toPlainText());
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene() && can_check_changes) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
infos -> updateForm();
|
infos -> updateForm();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class TextEditor;
|
|||||||
class PartText : public QGraphicsTextItem, public CustomElementPart {
|
class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartText(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartText(QETElementEditor *, QGraphicsItem * = 0, ElementScene * = 0);
|
||||||
virtual ~PartText();
|
virtual ~PartText();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -23,6 +23,8 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
QPointF pos() const;
|
QPointF pos() const;
|
||||||
void setPos(const QPointF &);
|
void setPos(const QPointF &);
|
||||||
void setPos(qreal, qreal);
|
void setPos(qreal, qreal);
|
||||||
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
@@ -30,9 +32,6 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
public:
|
|
||||||
bool can_check_changes;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF margin() const;
|
QPointF margin() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,10 +2,15 @@
|
|||||||
#include "textfieldeditor.h"
|
#include "textfieldeditor.h"
|
||||||
|
|
||||||
|
|
||||||
PartTextField::PartTextField(QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsTextItem(parent, scene), CustomElementPart(), follow_parent_rotations(true), can_check_changes(true) {
|
PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||||
|
QGraphicsTextItem(parent, scene),
|
||||||
|
CustomElementPart(editor),
|
||||||
|
follow_parent_rotations(true)
|
||||||
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
setPlainText(tr("_"));
|
setPlainText(tr("_"));
|
||||||
infos = new TextFieldEditor(this);
|
infos = new TextFieldEditor(elementEditor(), this);
|
||||||
|
infos -> setElementTypeName(QObject::tr("champ de texte"));
|
||||||
}
|
}
|
||||||
|
|
||||||
PartTextField::~PartTextField() {
|
PartTextField::~PartTextField() {
|
||||||
@@ -25,7 +30,7 @@ void PartTextField::fromXml(const QDomElement &xml_element) {
|
|||||||
xml_element.attribute("y").toDouble()
|
xml_element.attribute("y").toDouble()
|
||||||
);
|
);
|
||||||
|
|
||||||
follow_parent_rotations = (xml_element.attribute("rotate") == "false");
|
follow_parent_rotations = (xml_element.attribute("rotate") == "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
|
const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
|
||||||
@@ -34,7 +39,7 @@ const QDomElement PartTextField::toXml(QDomDocument &xml_document) const {
|
|||||||
xml_element.setAttribute("y", QString("%1").arg((scenePos() + margin()).y()));
|
xml_element.setAttribute("y", QString("%1").arg((scenePos() + margin()).y()));
|
||||||
xml_element.setAttribute("text", toPlainText());
|
xml_element.setAttribute("text", toPlainText());
|
||||||
xml_element.setAttribute("size", font().pointSize());
|
xml_element.setAttribute("size", font().pointSize());
|
||||||
if (follow_parent_rotations) xml_element.setAttribute("rotate", "false");
|
if (follow_parent_rotations) xml_element.setAttribute("rotate", "true");
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +105,40 @@ void PartTextField::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
setFocus(Qt::MouseFocusReason);
|
setFocus(Qt::MouseFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(QFont(font().family(), value.toInt()));
|
||||||
|
} else if (property == "text") {
|
||||||
|
setPlainText(value.toString());
|
||||||
|
} else if (property == "rotate") {
|
||||||
|
follow_parent_rotations = value.toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant PartTextField::property(const QString &property) {
|
||||||
|
if (property == "x") {
|
||||||
|
return((scenePos() + margin()).x());
|
||||||
|
} else if (property == "y") {
|
||||||
|
return((scenePos() + margin()).y());
|
||||||
|
} else if (property == "size") {
|
||||||
|
return(font().pointSize());
|
||||||
|
} else if (property == "text") {
|
||||||
|
return(toPlainText());
|
||||||
|
} else if (property == "rotate") {
|
||||||
|
return(follow_parent_rotations);
|
||||||
|
}
|
||||||
|
return(QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
QVariant PartTextField::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartTextField::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene() && can_check_changes) {
|
if (scene()) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||||
infos -> updateForm();
|
infos -> updateForm();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
class TextFieldEditor;
|
class TextFieldEditor;
|
||||||
|
class QETElementEditor;
|
||||||
class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartTextField(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartTextField(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartTextField();
|
virtual ~PartTextField();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -26,6 +27,8 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
void setPos(qreal, qreal);
|
void setPos(qreal, qreal);
|
||||||
bool followParentRotations();
|
bool followParentRotations();
|
||||||
void setFollowParentRotations(bool);
|
void setFollowParentRotations(bool);
|
||||||
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
|
virtual QVariant property(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
@@ -33,9 +36,6 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
public:
|
|
||||||
bool can_check_changes;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF margin() const;
|
QPointF margin() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
#include "polygoneditor.h"
|
#include "polygoneditor.h"
|
||||||
#include "partpolygon.h"
|
#include "partpolygon.h"
|
||||||
|
#include "elementscene.h"
|
||||||
|
#include "editorcommands.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param p Le polygone a editer
|
@param p Le polygone a editer
|
||||||
@param parent le Widget parent
|
@param parent le Widget parent
|
||||||
*/
|
*/
|
||||||
PolygonEditor::PolygonEditor(PartPolygon *p, QWidget *parent) :
|
PolygonEditor::PolygonEditor(QETElementEditor *editor, PartPolygon *p, QWidget *parent) :
|
||||||
QWidget(parent),
|
ElementItemEditor(editor, parent),
|
||||||
points_list(this),
|
points_list(this),
|
||||||
close_polygon(tr("Polygone ferm\351"), this)
|
close_polygon(tr("Polygone ferm\351"), this)
|
||||||
{
|
{
|
||||||
@@ -50,7 +52,16 @@ void PolygonEditor::updatePolygonPoints() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PolygonEditor::updatePolygonClosedState() {
|
void PolygonEditor::updatePolygonClosedState() {
|
||||||
part -> setClosed(close_polygon.isChecked());
|
undoStack().push(
|
||||||
|
new ChangePartCommand(
|
||||||
|
tr("fermeture du polygone"),
|
||||||
|
part,
|
||||||
|
"closed",
|
||||||
|
QVariant(!close_polygon.isChecked()),
|
||||||
|
QVariant(close_polygon.isChecked())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// part -> setClosed(close_polygon.isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolygonEditor::updateForm() {
|
void PolygonEditor::updateForm() {
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#ifndef POLYGON_EDITOR_H
|
#ifndef POLYGON_EDITOR_H
|
||||||
#define POLYGON_EDITOR_H
|
#define POLYGON_EDITOR_H
|
||||||
#include <QtGui>
|
#include "elementitemeditor.h"
|
||||||
class PartPolygon;
|
class PartPolygon;
|
||||||
class PolygonEditor : public QWidget {
|
class PolygonEditor : public ElementItemEditor {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PolygonEditor(PartPolygon *, QWidget * = 0);
|
PolygonEditor(QETElementEditor *, PartPolygon *, QWidget * = 0);
|
||||||
~PolygonEditor() {
|
~PolygonEditor() {
|
||||||
qDebug() << "~PolygonEditor()";
|
qDebug() << "~PolygonEditor()";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "customelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "editorscene.h"
|
#include "elementscene.h"
|
||||||
|
#include "elementview.h"
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "newelementwizard.h"
|
#include "newelementwizard.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
CustomElementEditor::CustomElementEditor(QWidget *parent) :
|
QETElementEditor::QETElementEditor(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
read_only(false),
|
read_only(false),
|
||||||
min_title(tr("QElectroTech - \311diteur d'\351l\351ment")),
|
min_title(tr("QElectroTech - \311diteur d'\351l\351ment")),
|
||||||
@@ -20,11 +21,11 @@ CustomElementEditor::CustomElementEditor(QWidget *parent) :
|
|||||||
setupMenus();
|
setupMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomElementEditor::~CustomElementEditor() {
|
QETElementEditor::~QETElementEditor() {
|
||||||
qDebug() << "~CustomElementEditor()";
|
qDebug() << "~QETElementEditor()";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::setupActions() {
|
void QETElementEditor::setupActions() {
|
||||||
new_element = new QAction(QIcon(":/ico/new.png"), tr("&Nouveau"), this);
|
new_element = new QAction(QIcon(":/ico/new.png"), tr("&Nouveau"), this);
|
||||||
open = new QAction(QIcon(":/ico/open.png"), tr("&Ouvrir"), this);
|
open = new QAction(QIcon(":/ico/open.png"), tr("&Ouvrir"), this);
|
||||||
save = new QAction(QIcon(":/ico/save.png"), tr("&Enregistrer"), this);
|
save = new QAction(QIcon(":/ico/save.png"), tr("&Enregistrer"), this);
|
||||||
@@ -123,7 +124,7 @@ void CustomElementEditor::setupActions() {
|
|||||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
|
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::setupMenus() {
|
void QETElementEditor::setupMenus() {
|
||||||
file_menu = new QMenu(tr("Fichier"));
|
file_menu = new QMenu(tr("Fichier"));
|
||||||
edit_menu = new QMenu(tr("\311dition"));
|
edit_menu = new QMenu(tr("\311dition"));
|
||||||
display_menu = new QMenu(tr("Affichage"));
|
display_menu = new QMenu(tr("Affichage"));
|
||||||
@@ -168,21 +169,15 @@ void CustomElementEditor::setupMenus() {
|
|||||||
menuBar() -> addMenu(help_menu);
|
menuBar() -> addMenu(help_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_updateMenus() {
|
void QETElementEditor::slot_updateMenus() {
|
||||||
edit_delete -> setEnabled(!ce_scene -> selectedItems().isEmpty());
|
edit_delete -> setEnabled(!ce_scene -> selectedItems().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::setupInterface() {
|
void QETElementEditor::setupInterface() {
|
||||||
// editeur
|
// editeur
|
||||||
ce_scene = new EditorScene(this);
|
ce_scene = new ElementScene(this, this);
|
||||||
ce_scene -> slot_move();
|
ce_scene -> slot_move();
|
||||||
ce_view = new QGraphicsView(ce_scene, this);
|
ce_view = new ElementView(ce_scene, this);
|
||||||
ce_view -> setInteractive(true);
|
|
||||||
ce_view -> setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
||||||
//ce_view -> setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
|
||||||
ce_view -> setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
|
||||||
//ce_view -> setSceneRect(QRectF(0.0, 0.0, 50.0, 200.0));
|
|
||||||
ce_view -> scale(4.0, 4.0);
|
|
||||||
slot_setRubberBandToView();
|
slot_setRubberBandToView();
|
||||||
setCentralWidget(ce_view);
|
setCentralWidget(ce_view);
|
||||||
|
|
||||||
@@ -213,21 +208,21 @@ void CustomElementEditor::setupInterface() {
|
|||||||
statusBar() -> showMessage(tr("\311diteur d'\351l\351ments"));
|
statusBar() -> showMessage(tr("\311diteur d'\351l\351ments"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_setRubberBandToView() {
|
void QETElementEditor::slot_setRubberBandToView() {
|
||||||
ce_view -> setDragMode(QGraphicsView::RubberBandDrag);
|
ce_view -> setDragMode(QGraphicsView::RubberBandDrag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_setNoDragToView() {
|
void QETElementEditor::slot_setNoDragToView() {
|
||||||
ce_view -> setDragMode(QGraphicsView::NoDrag);
|
ce_view -> setDragMode(QGraphicsView::NoDrag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_setNormalMode() {
|
void QETElementEditor::slot_setNormalMode() {
|
||||||
if (!move -> isChecked()) move -> setChecked(true);
|
if (!move -> isChecked()) move -> setChecked(true);
|
||||||
ce_view -> setDragMode(QGraphicsView::RubberBandDrag);
|
ce_view -> setDragMode(QGraphicsView::RubberBandDrag);
|
||||||
ce_scene -> slot_move();
|
ce_scene -> slot_move();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_updateInformations() {
|
void QETElementEditor::slot_updateInformations() {
|
||||||
QList<QGraphicsItem *> selected_qgis = ce_scene -> selectedItems();
|
QList<QGraphicsItem *> selected_qgis = ce_scene -> selectedItems();
|
||||||
QList<CustomElementPart *> selected_parts;
|
QList<CustomElementPart *> selected_parts;
|
||||||
foreach(QGraphicsItem *qgi, selected_qgis) {
|
foreach(QGraphicsItem *qgi, selected_qgis) {
|
||||||
@@ -260,7 +255,7 @@ void CustomElementEditor::slot_updateInformations() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::xmlPreview() {
|
void QETElementEditor::xmlPreview() {
|
||||||
QMessageBox::information(
|
QMessageBox::information(
|
||||||
this,
|
this,
|
||||||
"Export XML",
|
"Export XML",
|
||||||
@@ -268,7 +263,7 @@ void CustomElementEditor::xmlPreview() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::fromFile(const QString &filepath) {
|
void QETElementEditor::fromFile(const QString &filepath) {
|
||||||
bool state = true;
|
bool state = true;
|
||||||
QString error_message;
|
QString error_message;
|
||||||
|
|
||||||
@@ -325,7 +320,7 @@ void CustomElementEditor::fromFile(const QString &filepath) {
|
|||||||
setWindowTitle(new_title);
|
setWindowTitle(new_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomElementEditor::toFile(const QString &fn) {
|
bool QETElementEditor::toFile(const QString &fn) {
|
||||||
QFile file(fn);
|
QFile file(fn);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QMessageBox::warning(this, tr("Erreur"), tr("Impossible d'ecrire dans ce fichier"));
|
QMessageBox::warning(this, tr("Erreur"), tr("Impossible d'ecrire dans ce fichier"));
|
||||||
@@ -342,7 +337,7 @@ bool CustomElementEditor::toFile(const QString &fn) {
|
|||||||
specifie si l'editeur d'element doit etre en mode lecture seule
|
specifie si l'editeur d'element doit etre en mode lecture seule
|
||||||
@param ro true pour activer le mode lecture seule, false pour le desactiver
|
@param ro true pour activer le mode lecture seule, false pour le desactiver
|
||||||
*/
|
*/
|
||||||
void CustomElementEditor::setReadOnly(bool ro) {
|
void QETElementEditor::setReadOnly(bool ro) {
|
||||||
read_only = ro;
|
read_only = ro;
|
||||||
// active / desactive les actions
|
// active / desactive les actions
|
||||||
foreach (QAction *action, parts -> actions()) action -> setEnabled(!ro);
|
foreach (QAction *action, parts -> actions()) action -> setEnabled(!ro);
|
||||||
@@ -359,16 +354,16 @@ void CustomElementEditor::setReadOnly(bool ro) {
|
|||||||
/**
|
/**
|
||||||
@return true si l'editeur d'element est en mode lecture seule
|
@return true si l'editeur d'element est en mode lecture seule
|
||||||
*/
|
*/
|
||||||
bool CustomElementEditor::isReadOnly() const {
|
bool QETElementEditor::isReadOnly() const {
|
||||||
return(read_only);
|
return(read_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_new() {
|
void QETElementEditor::slot_new() {
|
||||||
NewElementWizard new_element_wizard;
|
NewElementWizard new_element_wizard;
|
||||||
new_element_wizard.exec();
|
new_element_wizard.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_open() {
|
void QETElementEditor::slot_open() {
|
||||||
// demande un nom de fichier a ouvrir a l'utilisateur
|
// demande un nom de fichier a ouvrir a l'utilisateur
|
||||||
QString user_filename = QFileDialog::getOpenFileName(
|
QString user_filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
@@ -377,19 +372,19 @@ void CustomElementEditor::slot_open() {
|
|||||||
tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||||
);
|
);
|
||||||
if (user_filename == "") return;
|
if (user_filename == "") return;
|
||||||
CustomElementEditor *cee = new CustomElementEditor();
|
QETElementEditor *cee = new QETElementEditor();
|
||||||
cee -> fromFile(user_filename);
|
cee -> fromFile(user_filename);
|
||||||
cee -> show();
|
cee -> show();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomElementEditor::slot_save() {
|
bool QETElementEditor::slot_save() {
|
||||||
// si on ne connait pas le nom du fichier en cours, enregistrer revient a enregistrer sous
|
// si on ne connait pas le nom du fichier en cours, enregistrer revient a enregistrer sous
|
||||||
if (_filename == QString()) return(slot_saveAs());
|
if (_filename == QString()) return(slot_saveAs());
|
||||||
// sinon on enregistre dans le nom de fichier connu
|
// sinon on enregistre dans le nom de fichier connu
|
||||||
return(toFile(_filename));
|
return(toFile(_filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomElementEditor::slot_saveAs() {
|
bool QETElementEditor::slot_saveAs() {
|
||||||
// demande un nom de fichier a l'utilisateur pour enregistrer l'element
|
// demande un nom de fichier a l'utilisateur pour enregistrer l'element
|
||||||
QString fn = QFileDialog::getSaveFileName(
|
QString fn = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
@@ -409,14 +404,14 @@ bool CustomElementEditor::slot_saveAs() {
|
|||||||
return(result_save);
|
return(result_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomElementEditor::slot_quit(QCloseEvent *event) {
|
void QETElementEditor::slot_quit(QCloseEvent *event) {
|
||||||
if (close()) {
|
if (close()) {
|
||||||
if (event != NULL) event -> accept();
|
if (event != NULL) event -> accept();
|
||||||
delete(this);
|
delete(this);
|
||||||
} else if (event != NULL) event -> ignore();
|
} else if (event != NULL) event -> ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomElementEditor::close() {
|
bool QETElementEditor::close() {
|
||||||
// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
|
// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
|
||||||
QMessageBox::StandardButton answer = QMessageBox::question(
|
QMessageBox::StandardButton answer = QMessageBox::question(
|
||||||
this,
|
this,
|
||||||
@@ -438,6 +433,6 @@ bool CustomElementEditor::close() {
|
|||||||
Permet de quitter l'editeur lors de la fermeture de la fenetre principale
|
Permet de quitter l'editeur lors de la fermeture de la fenetre principale
|
||||||
@param qce Le QCloseEvent correspondant a l'evenement de fermeture
|
@param qce Le QCloseEvent correspondant a l'evenement de fermeture
|
||||||
*/
|
*/
|
||||||
void CustomElementEditor::closeEvent(QCloseEvent *qce) {
|
void QETElementEditor::closeEvent(QCloseEvent *qce) {
|
||||||
slot_quit(qce);
|
slot_quit(qce);
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
#ifndef CUSTOM_ELEMENT_EDITOR_H
|
#ifndef CUSTOM_ELEMENT_EDITOR_H
|
||||||
#define CUSTOM_ELEMENT_EDITOR_H
|
#define CUSTOM_ELEMENT_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "editorscene.h"
|
#include "elementscene.h"
|
||||||
#include "orientationset.h"
|
#include "orientationset.h"
|
||||||
class CustomElementEditor : public QMainWindow {
|
class ElementView;
|
||||||
|
class QETElementEditor : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructeur, destructeur
|
// constructeur, destructeur
|
||||||
public:
|
public:
|
||||||
CustomElementEditor(QWidget * = 0);
|
QETElementEditor(QWidget * = 0);
|
||||||
virtual ~CustomElementEditor();
|
virtual ~QETElementEditor();
|
||||||
private:
|
private:
|
||||||
CustomElementEditor(const CustomElementEditor &);
|
QETElementEditor(const QETElementEditor &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -20,9 +21,9 @@ class CustomElementEditor : public QMainWindow {
|
|||||||
/// menus
|
/// menus
|
||||||
QMenu *file_menu, *edit_menu, *display_menu, *tools_menu, *help_menu;
|
QMenu *file_menu, *edit_menu, *display_menu, *tools_menu, *help_menu;
|
||||||
/// vue sur la scene d'edition
|
/// vue sur la scene d'edition
|
||||||
QGraphicsView *ce_view;
|
ElementView *ce_view;
|
||||||
/// scene d'edition
|
/// scene d'edition
|
||||||
EditorScene *ce_scene;
|
ElementScene *ce_scene;
|
||||||
/// container pour les widgets d'edition des parties
|
/// container pour les widgets d'edition des parties
|
||||||
QDockWidget *tools_dock;
|
QDockWidget *tools_dock;
|
||||||
/// container pour la liste des annulations
|
/// container pour la liste des annulations
|
||||||
@@ -60,6 +61,7 @@ class CustomElementEditor : public QMainWindow {
|
|||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void fromFile(const QString &);
|
void fromFile(const QString &);
|
||||||
bool toFile(const QString &);
|
bool toFile(const QString &);
|
||||||
|
ElementScene *elementScene() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
@@ -84,12 +86,12 @@ class CustomElementEditor : public QMainWindow {
|
|||||||
void xmlPreview();
|
void xmlPreview();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void CustomElementEditor::setSize(const QSize &siz) {
|
inline void QETElementEditor::setSize(const QSize &siz) {
|
||||||
ce_scene -> setWidth(siz.width());
|
ce_scene -> setWidth(siz.width());
|
||||||
ce_scene -> setHeight(siz.height());
|
ce_scene -> setHeight(siz.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QSize CustomElementEditor::size() const {
|
inline QSize QETElementEditor::size() const {
|
||||||
return(
|
return(
|
||||||
QSize(
|
QSize(
|
||||||
ce_scene -> width(),
|
ce_scene -> width(),
|
||||||
@@ -98,33 +100,37 @@ inline QSize CustomElementEditor::size() const {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CustomElementEditor::setHotspot(const QPoint &hs) {
|
inline void QETElementEditor::setHotspot(const QPoint &hs) {
|
||||||
ce_scene -> setHotspot(hs);
|
ce_scene -> setHotspot(hs);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPoint CustomElementEditor::hotspot() const {
|
inline QPoint QETElementEditor::hotspot() const {
|
||||||
return(ce_scene -> hotspot());
|
return(ce_scene -> hotspot());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CustomElementEditor::setNames(const NamesList &nameslist) {
|
inline void QETElementEditor::setNames(const NamesList &nameslist) {
|
||||||
ce_scene -> setNames(nameslist);
|
ce_scene -> setNames(nameslist);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CustomElementEditor::setOrientations(const OrientationSet &orientation_set) {
|
inline void QETElementEditor::setOrientations(const OrientationSet &orientation_set) {
|
||||||
ce_scene -> setOrientations(orientation_set);
|
ce_scene -> setOrientations(orientation_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline OrientationSet CustomElementEditor::orientations() const {
|
inline OrientationSet QETElementEditor::orientations() const {
|
||||||
return(ce_scene -> orientations());
|
return(ce_scene -> orientations());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CustomElementEditor::setFileName(const QString &fn) {
|
inline void QETElementEditor::setFileName(const QString &fn) {
|
||||||
setWindowTitle(min_title + " - " + fn);
|
setWindowTitle(min_title + " - " + fn);
|
||||||
_filename = fn;
|
_filename = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString CustomElementEditor::fileName() const {
|
inline QString QETElementEditor::fileName() const {
|
||||||
return(_filename);
|
return(_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ElementScene *QETElementEditor::elementScene() const {
|
||||||
|
return(ce_scene);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,37 +1,32 @@
|
|||||||
#include "styleeditor.h"
|
#include "styleeditor.h"
|
||||||
#include "customelementgraphicpart.h"
|
#include "customelementgraphicpart.h"
|
||||||
|
|
||||||
StyleEditor::StyleEditor(CustomElementGraphicPart *p, QWidget *parent) : QWidget(parent), part(p) {
|
StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p, QWidget *parent) : ElementItemEditor(editor, parent), part(p) {
|
||||||
// couleur
|
// couleur
|
||||||
color = new QButtonGroup(this);
|
color = new QButtonGroup(this);
|
||||||
color -> addButton(black_color = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackColor);
|
color -> addButton(black_color = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackColor);
|
||||||
color -> addButton(white_color = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteColor);
|
color -> addButton(white_color = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteColor);
|
||||||
connect(color, SIGNAL(buttonClicked(int)), this, SLOT(updatePart()));
|
|
||||||
|
|
||||||
// style
|
// style
|
||||||
style = new QButtonGroup(this);
|
style = new QButtonGroup(this);
|
||||||
style -> addButton(normal_style = new QRadioButton(tr("Normal")), CustomElementGraphicPart::NormalStyle);
|
style -> addButton(normal_style = new QRadioButton(tr("Normal")), CustomElementGraphicPart::NormalStyle);
|
||||||
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351")), CustomElementGraphicPart::DashedStyle);
|
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351")), CustomElementGraphicPart::DashedStyle);
|
||||||
style -> button(part -> lineStyle()) -> setChecked(true);
|
style -> button(part -> lineStyle()) -> setChecked(true);
|
||||||
connect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePart()));
|
|
||||||
|
|
||||||
// epaisseur
|
// epaisseur
|
||||||
weight = new QButtonGroup(this);
|
weight = new QButtonGroup(this);
|
||||||
weight -> addButton(none_weight = new QRadioButton(tr("Nulle")), CustomElementGraphicPart::NoneWeight);
|
weight -> addButton(none_weight = new QRadioButton(tr("Nulle")), CustomElementGraphicPart::NoneWeight);
|
||||||
weight -> addButton(thin_weight = new QRadioButton(tr("Fine")), CustomElementGraphicPart::ThinWeight);
|
weight -> addButton(thin_weight = new QRadioButton(tr("Fine")), CustomElementGraphicPart::ThinWeight);
|
||||||
weight -> addButton(normal_weight = new QRadioButton(tr("Normale")), CustomElementGraphicPart::NormalWeight);
|
weight -> addButton(normal_weight = new QRadioButton(tr("Normale")), CustomElementGraphicPart::NormalWeight);
|
||||||
connect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePart()));
|
|
||||||
|
|
||||||
// remplissage
|
// remplissage
|
||||||
filling = new QButtonGroup(this);
|
filling = new QButtonGroup(this);
|
||||||
filling -> addButton(no_filling = new QRadioButton(tr("Aucun")), CustomElementGraphicPart::NoneFilling );
|
filling -> addButton(no_filling = new QRadioButton(tr("Aucun")), CustomElementGraphicPart::NoneFilling );
|
||||||
filling -> addButton(black_filling = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackFilling);
|
filling -> addButton(black_filling = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackFilling);
|
||||||
filling -> addButton(white_filling = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteFilling);
|
filling -> addButton(white_filling = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteFilling);
|
||||||
connect(filling, SIGNAL(buttonClicked(int)), this, SLOT(updatePart()));
|
|
||||||
|
|
||||||
// antialiasing
|
// antialiasing
|
||||||
antialiasing = new QCheckBox(tr("Antialiasing"));
|
antialiasing = new QCheckBox(tr("Antialiasing"));
|
||||||
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePart()));
|
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
@@ -97,11 +92,16 @@ void StyleEditor::updatePart() {
|
|||||||
part -> setFilling(static_cast<CEGP::Filling>(filling -> checkedId()));
|
part -> setFilling(static_cast<CEGP::Filling>(filling -> checkedId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StyleEditor::updatePartAntialiasing() { addChangePartCommand("style antialiasing", part, "antialias", antialiasing -> isChecked()); }
|
||||||
|
void StyleEditor::updatePartColor() { addChangePartCommand("style couleur", part, "color", color -> checkedId()); }
|
||||||
|
void StyleEditor::updatePartLineStyle() { addChangePartCommand("style ligne", part, "line-style", style -> checkedId()); }
|
||||||
|
void StyleEditor::updatePartLineWeight() { addChangePartCommand("style epaisseur", part, "line-weight", weight -> checkedId()); }
|
||||||
|
void StyleEditor::updatePartFilling() { addChangePartCommand("style remplissage", part, "filling", filling -> checkedId()); }
|
||||||
|
|
||||||
void StyleEditor::updateForm() {
|
void StyleEditor::updateForm() {
|
||||||
// lit l'antialiasing : deconnexion du slot pour eviter l'appel a updatePart()
|
activeConnections(false);
|
||||||
disconnect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePart()));
|
// lit l'antialiasing
|
||||||
antialiasing -> setChecked(part -> antialiased());
|
antialiasing -> setChecked(part -> antialiased());
|
||||||
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePart()));
|
|
||||||
|
|
||||||
// lit la couleur
|
// lit la couleur
|
||||||
color -> button(part -> color()) -> setChecked(true);
|
color -> button(part -> color()) -> setChecked(true);
|
||||||
@@ -114,8 +114,25 @@ void StyleEditor::updateForm() {
|
|||||||
|
|
||||||
// lit le remplissage
|
// lit le remplissage
|
||||||
filling -> button(part -> filling()) -> setChecked(true);
|
filling -> button(part -> filling()) -> setChecked(true);
|
||||||
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleEditor::appendWidget(QWidget *w) {
|
void StyleEditor::appendWidget(QWidget *w) {
|
||||||
main_layout -> insertWidget(7, w);
|
main_layout -> insertWidget(7, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StyleEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(color, SIGNAL(buttonClicked(int)), this, SLOT(updatePartColor()));
|
||||||
|
connect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineStyle()));
|
||||||
|
connect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineWeight()));
|
||||||
|
connect(filling, SIGNAL(buttonClicked(int)), this, SLOT(updatePartFilling()));
|
||||||
|
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
||||||
|
} else {
|
||||||
|
disconnect(color, SIGNAL(buttonClicked(int)), this, SLOT(updatePartColor()));
|
||||||
|
disconnect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineStyle()));
|
||||||
|
disconnect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineWeight()));
|
||||||
|
disconnect(filling, SIGNAL(buttonClicked(int)), this, SLOT(updatePartFilling()));
|
||||||
|
disconnect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#ifndef STYLE_EDITOR_H
|
#ifndef STYLE_EDITOR_H
|
||||||
#define STYLE_EDITOR_H
|
#define STYLE_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class CustomElementGraphicPart;
|
class CustomElementGraphicPart;
|
||||||
class StyleEditor : public QWidget {
|
class StyleEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
StyleEditor(CustomElementGraphicPart *, QWidget * = 0);
|
StyleEditor(QETElementEditor *, CustomElementGraphicPart *, QWidget * = 0);
|
||||||
virtual ~StyleEditor();
|
virtual ~StyleEditor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -29,5 +30,13 @@ class StyleEditor : public QWidget {
|
|||||||
public slots:
|
public slots:
|
||||||
void updatePart();
|
void updatePart();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
void updatePartAntialiasing();
|
||||||
|
void updatePartColor();
|
||||||
|
void updatePartLineStyle();
|
||||||
|
void updatePartLineWeight();
|
||||||
|
void updatePartFilling();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
@param term Borne a editer
|
@param term Borne a editer
|
||||||
@param parent QWidget parent de ce widget
|
@param parent QWidget parent de ce widget
|
||||||
*/
|
*/
|
||||||
TerminalEditor::TerminalEditor(PartTerminal *term, QWidget *parent) : QWidget(parent) {
|
TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
part = term;
|
part = term;
|
||||||
|
|
||||||
qle_x = new QLineEdit();
|
qle_x = new QLineEdit();
|
||||||
@@ -35,10 +35,7 @@ TerminalEditor::TerminalEditor(PartTerminal *term, QWidget *parent) : QWidget(pa
|
|||||||
main_layout -> addStretch();
|
main_layout -> addStretch();
|
||||||
setLayout(main_layout);
|
setLayout(main_layout);
|
||||||
|
|
||||||
connect(qle_x, SIGNAL(textEdited(const QString &)), this, SLOT(updateTerminal()));
|
activeConnections(true);
|
||||||
connect(qle_y, SIGNAL(textEdited(const QString &)), this, SLOT(updateTerminal()));
|
|
||||||
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminal()));
|
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +57,27 @@ void TerminalEditor::updateTerminal() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalEditor::updateTerminalX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
|
||||||
|
void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
||||||
|
void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex()).toInt()); }
|
||||||
|
|
||||||
void TerminalEditor::updateForm() {
|
void TerminalEditor::updateForm() {
|
||||||
qle_x -> setText(QString("%1").arg(part -> pos().x()));
|
activeConnections(false);
|
||||||
qle_y -> setText(QString("%1").arg(part -> pos().y()));
|
qDebug() << part -> pos() << part -> scenePos();
|
||||||
|
qle_x -> setText(part -> property("x").toString());
|
||||||
|
qle_y -> setText(part -> property("y").toString());
|
||||||
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
||||||
|
activeConnections(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
||||||
|
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
||||||
|
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
||||||
|
} else {
|
||||||
|
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
||||||
|
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
||||||
|
disconnect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
#ifndef TERMINAL_EDITOR_H
|
#ifndef TERMINAL_EDITOR_H
|
||||||
#define TERMINAL_EDITOR_H
|
#define TERMINAL_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartTerminal;
|
class PartTerminal;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un editeur de borne.
|
Cette classe represente un editeur de borne.
|
||||||
Elle permet d'editer a travers une interface graphique les
|
Elle permet d'editer a travers une interface graphique les
|
||||||
proprietes d'une borne d'element.
|
proprietes d'une borne d'element.
|
||||||
*/
|
*/
|
||||||
class TerminalEditor : public QWidget {
|
class TerminalEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeurs, destructeur
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
TerminalEditor(PartTerminal *, QWidget * = 0);
|
TerminalEditor(QETElementEditor *, PartTerminal *, QWidget * = 0);
|
||||||
virtual ~TerminalEditor();
|
virtual ~TerminalEditor();
|
||||||
private:
|
private:
|
||||||
TerminalEditor(const TerminalEditor &);
|
TerminalEditor(const TerminalEditor &);
|
||||||
@@ -25,6 +26,12 @@ class TerminalEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateTerminal();
|
void updateTerminal();
|
||||||
|
void updateTerminalX();
|
||||||
|
void updateTerminalY();
|
||||||
|
void updateTerminalO();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
@param term Champ de texte a editer
|
@param term Champ de texte a editer
|
||||||
@param parent QWidget parent de ce widget
|
@param parent QWidget parent de ce widget
|
||||||
*/
|
*/
|
||||||
TextEditor::TextEditor(PartText *text, QWidget *parent) : QWidget(parent) {
|
TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
part = text;
|
part = text;
|
||||||
|
|
||||||
qle_x = new QLineEdit();
|
qle_x = new QLineEdit();
|
||||||
@@ -37,12 +37,9 @@ TextEditor::TextEditor(PartText *text, QWidget *parent) : QWidget(parent) {
|
|||||||
main_layout -> addStretch();
|
main_layout -> addStretch();
|
||||||
setLayout(main_layout);
|
setLayout(main_layout);
|
||||||
|
|
||||||
connect(qle_x, SIGNAL(textEdited(const QString &)), this, SLOT(updateText()));
|
|
||||||
connect(qle_y, SIGNAL(textEdited(const QString &)), this, SLOT(updateText()));
|
|
||||||
connect(qle_text, SIGNAL(textEdited(const QString &)), this, SLOT(updateText()));
|
|
||||||
connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(updateText()));
|
|
||||||
|
|
||||||
//updateForm();
|
|
||||||
|
updateForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,17 +49,42 @@ TextEditor::~TextEditor() {
|
|||||||
qDebug() << "~TextEditor()";
|
qDebug() << "~TextEditor()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Met a jour le champ de texte a partir des donnees du formulaire
|
||||||
|
*/
|
||||||
void TextEditor::updateText() {
|
void TextEditor::updateText() {
|
||||||
part -> can_check_changes = false;
|
part -> setProperty("size", font_size -> value());
|
||||||
part -> setFont(QFont(part -> font().family(), 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 -> text().toDouble(), qle_y -> text().toDouble());
|
||||||
part -> can_check_changes = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditor::updateTextX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
|
||||||
|
void TextEditor::updateTextY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
||||||
|
void TextEditor::updateTextT() { addChangePartCommand(tr("texte"), part, "text", qle_text -> text()); }
|
||||||
|
void TextEditor::updateTextS() { addChangePartCommand(tr("taille"), part, "size", font_size -> value()); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Met a jour le formulaire a partir du champ de texte
|
||||||
|
*/
|
||||||
void TextEditor::updateForm() {
|
void TextEditor::updateForm() {
|
||||||
qle_x -> setText(QString("%1").arg(part -> pos().x()));
|
activeConnections(false);
|
||||||
qle_y -> setText(QString("%1").arg(part -> pos().y()));
|
qle_x -> setText(part -> property("x").toString());
|
||||||
qle_text -> setText(part -> toPlainText());
|
qle_y -> setText(part -> property("y").toString());
|
||||||
font_size -> setValue(part -> font().pointSize());
|
qle_text -> setText(part -> property("text").toString());
|
||||||
|
font_size -> setValue(part -> property("size").toInt());
|
||||||
|
activeConnections(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextX()));
|
||||||
|
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextY()));
|
||||||
|
connect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextT()));
|
||||||
|
connect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextS()));
|
||||||
|
} else {
|
||||||
|
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextX()));
|
||||||
|
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextY()));
|
||||||
|
disconnect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextT()));
|
||||||
|
disconnect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextS()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
#ifndef TEXT_EDITOR_H
|
#ifndef TEXT_EDITOR_H
|
||||||
#define TEXT_EDITOR_H
|
#define TEXT_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartText;
|
class PartText;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un editeur de champ de texte non editable
|
Cette classe represente un editeur de champ de texte non editable
|
||||||
Elle permet d'editer a travers une interface graphique les
|
Elle permet d'editer a travers une interface graphique les
|
||||||
proprietes d'un champ de texte non editable.
|
proprietes d'un champ de texte non editable.
|
||||||
*/
|
*/
|
||||||
class TextEditor : public QWidget {
|
class TextEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeurs, destructeur
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
TextEditor(PartText *, QWidget * = 0);
|
TextEditor(QETElementEditor *, PartText *, QWidget * = 0);
|
||||||
virtual ~TextEditor();
|
virtual ~TextEditor();
|
||||||
private:
|
private:
|
||||||
TextEditor(const TextEditor &);
|
TextEditor(const TextEditor &);
|
||||||
@@ -25,6 +26,13 @@ class TextEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateText();
|
void updateText();
|
||||||
|
void updateTextX();
|
||||||
|
void updateTextY();
|
||||||
|
void updateTextT();
|
||||||
|
void updateTextS();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
@param part Champ de texte a editer
|
@param part Champ de texte a editer
|
||||||
@param parent QWidget parent
|
@param parent QWidget parent
|
||||||
*/
|
*/
|
||||||
TextFieldEditor::TextFieldEditor(PartTextField *textfield, QWidget *parent) : QWidget(parent) {
|
TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfield, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||||
part = textfield;
|
part = textfield;
|
||||||
|
|
||||||
qle_x = new QLineEdit();
|
qle_x = new QLineEdit();
|
||||||
@@ -43,12 +43,7 @@ TextFieldEditor::TextFieldEditor(PartTextField *textfield, QWidget *parent) : QW
|
|||||||
|
|
||||||
main_layout -> addStretch();
|
main_layout -> addStretch();
|
||||||
setLayout(main_layout);
|
setLayout(main_layout);
|
||||||
|
updateForm();
|
||||||
connect(qle_x, SIGNAL(textEdited(const QString &)), this, SLOT(updateTextField()));
|
|
||||||
connect(qle_y, SIGNAL(textEdited(const QString &)), this, SLOT(updateTextField()));
|
|
||||||
connect(qle_text, SIGNAL(textEdited(const QString &)), this, SLOT(updateTextField()));
|
|
||||||
connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(updateTextField()));
|
|
||||||
connect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextField()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,21 +57,43 @@ TextFieldEditor::~TextFieldEditor() {
|
|||||||
Met a jour le champ de texte a partir des donnees du formulaire
|
Met a jour le champ de texte a partir des donnees du formulaire
|
||||||
*/
|
*/
|
||||||
void TextFieldEditor::updateTextField() {
|
void TextFieldEditor::updateTextField() {
|
||||||
part -> can_check_changes = false;
|
part -> setProperty("size", font_size -> value());
|
||||||
part -> setFont(QFont(part -> font().family(), 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 -> text().toDouble(), qle_y -> text().toDouble());
|
||||||
part -> setFollowParentRotations(!rotate -> isChecked());
|
part -> setFollowParentRotations(!rotate -> isChecked());
|
||||||
part -> can_check_changes = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextFieldEditor::updateTextFieldX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
|
||||||
|
void TextFieldEditor::updateTextFieldY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
||||||
|
void TextFieldEditor::updateTextFieldT() { addChangePartCommand(tr("texte"), part, "text", qle_text -> text()); }
|
||||||
|
void TextFieldEditor::updateTextFieldS() { addChangePartCommand(tr("taille"), part, "size", font_size -> value()); }
|
||||||
|
void TextFieldEditor::updateTextFieldR() { addChangePartCommand(tr("propri\351t\351"), part, "rotate", !rotate -> isChecked()); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour le formulaire a partir du champ de texte
|
Met a jour le formulaire a partir du champ de texte
|
||||||
*/
|
*/
|
||||||
void TextFieldEditor::updateForm() {
|
void TextFieldEditor::updateForm() {
|
||||||
qle_x -> setText(QString("%1").arg(part -> pos().x()));
|
activeConnections(false);
|
||||||
qle_y -> setText(QString("%1").arg(part -> pos().y()));
|
qle_x -> setText(part -> property("x").toString());
|
||||||
qle_text -> setText(part -> toPlainText());
|
qle_y -> setText(part -> property("y").toString());
|
||||||
font_size -> setValue(part -> font().pointSize());
|
qle_text -> setText(part -> property("text").toString());
|
||||||
rotate -> setChecked(!part -> followParentRotations());
|
font_size -> setValue(part -> property("size").toInt());
|
||||||
|
rotate -> setChecked(!part -> property("rotate").toBool());
|
||||||
|
activeConnections(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextFieldEditor::activeConnections(bool active) {
|
||||||
|
if (active) {
|
||||||
|
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
|
||||||
|
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
|
||||||
|
connect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
|
||||||
|
connect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
|
||||||
|
connect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
|
||||||
|
} else {
|
||||||
|
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTextFieldX()));
|
||||||
|
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTextFieldY()));
|
||||||
|
disconnect(qle_text, SIGNAL(editingFinished()), this, SLOT(updateTextFieldT()));
|
||||||
|
disconnect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextFieldS()));
|
||||||
|
disconnect(rotate, SIGNAL(stateChanged(int)), this, SLOT(updateTextFieldR()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef TEXTFIELD_EDITOR_H
|
#ifndef TEXTFIELD_EDITOR_H
|
||||||
#define TEXTFIELD_EDITOR_H
|
#define TEXTFIELD_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include "elementitemeditor.h"
|
||||||
class PartTextField;
|
class PartTextField;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un editeur de champ de texte
|
Cette classe represente un editeur de champ de texte
|
||||||
@@ -8,11 +9,11 @@ class PartTextField;
|
|||||||
proprietes d'un champ de texte : taille de la police, texte par
|
proprietes d'un champ de texte : taille de la police, texte par
|
||||||
defaut et position.
|
defaut et position.
|
||||||
*/
|
*/
|
||||||
class TextFieldEditor : public QWidget {
|
class TextFieldEditor : public ElementItemEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeurs, destructeur
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
TextFieldEditor(PartTextField *, QWidget * = 0);
|
TextFieldEditor(QETElementEditor *, PartTextField *, QWidget * = 0);
|
||||||
virtual ~TextFieldEditor();
|
virtual ~TextFieldEditor();
|
||||||
private:
|
private:
|
||||||
TextFieldEditor(const TextFieldEditor &);
|
TextFieldEditor(const TextFieldEditor &);
|
||||||
@@ -27,6 +28,14 @@ class TextFieldEditor : public QWidget {
|
|||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
void updateTextField();
|
void updateTextField();
|
||||||
|
void updateTextFieldX();
|
||||||
|
void updateTextFieldY();
|
||||||
|
void updateTextFieldT();
|
||||||
|
void updateTextFieldS();
|
||||||
|
void updateTextFieldR();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void activeConnections(bool);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "elementscategory.h"
|
#include "elementscategory.h"
|
||||||
#include "elementscategoryeditor.h"
|
#include "elementscategoryeditor.h"
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
#include "customelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -178,9 +178,9 @@ void ElementsPanel::slot_doubleClick(QTreeWidgetItem *qtwi, int) {
|
|||||||
|
|
||||||
if (infos_file.isFile()) {
|
if (infos_file.isFile()) {
|
||||||
// il s'agit d'un element
|
// il s'agit d'un element
|
||||||
CustomElementEditor *cee = new CustomElementEditor();
|
QETElementEditor *editor = new QETElementEditor();
|
||||||
cee -> fromFile(filename);
|
editor -> fromFile(filename);
|
||||||
cee -> show();
|
editor -> show();
|
||||||
} else if (infos_file.isDir()) {
|
} else if (infos_file.isDir()) {
|
||||||
// il s'agit d'une categorie
|
// il s'agit d'une categorie
|
||||||
ElementsCategory c(filename);
|
ElementsCategory c(filename);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "orientationsetwidget.h"
|
#include "orientationsetwidget.h"
|
||||||
#include "hotspoteditor.h"
|
#include "hotspoteditor.h"
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "customelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -308,7 +308,7 @@ bool NewElementWizard::validStep5() {
|
|||||||
Cree le nouvel element
|
Cree le nouvel element
|
||||||
*/
|
*/
|
||||||
void NewElementWizard::createNewElement() {
|
void NewElementWizard::createNewElement() {
|
||||||
CustomElementEditor *edit_new_element = new CustomElementEditor(parentWidget());
|
QETElementEditor *edit_new_element = new QETElementEditor(parentWidget());
|
||||||
edit_new_element -> setSize(hotspot_editor -> elementSize());
|
edit_new_element -> setSize(hotspot_editor -> elementSize());
|
||||||
edit_new_element -> setHotspot(hotspot_editor -> hotspot());
|
edit_new_element -> setHotspot(hotspot_editor -> hotspot());
|
||||||
edit_new_element -> setNames(element_names -> names());
|
edit_new_element -> setNames(element_names -> names());
|
||||||
|
|||||||
100
qelectrotech.pro
100
qelectrotech.pro
@@ -25,38 +25,40 @@ HEADERS += aboutqet.h \
|
|||||||
elementtextitem.h \
|
elementtextitem.h \
|
||||||
exportdialog.h \
|
exportdialog.h \
|
||||||
fixedelement.h \
|
fixedelement.h \
|
||||||
|
hotspoteditor.h \
|
||||||
nameslist.h \
|
nameslist.h \
|
||||||
nameslistwidget.h \
|
nameslistwidget.h \
|
||||||
newelementwizard.h \
|
newelementwizard.h \
|
||||||
qet.h \
|
|
||||||
qetapp.h \
|
|
||||||
terminal.h \
|
|
||||||
editor/customelementeditor.h \
|
|
||||||
editor/customelementgraphicpart.h \
|
|
||||||
editor/customelementpart.h \
|
|
||||||
editor/editorscene.h \
|
|
||||||
editor/ellipseeditor.h \
|
|
||||||
editor/lineeditor.h \
|
|
||||||
editor/partellipse.h \
|
|
||||||
editor/partline.h \
|
|
||||||
editor/styleeditor.h \
|
|
||||||
editor/partcircle.h \
|
|
||||||
editor/circleeditor.h \
|
|
||||||
orientationset.h \
|
orientationset.h \
|
||||||
orientationsetwidget.h \
|
orientationsetwidget.h \
|
||||||
|
qet.h \
|
||||||
|
qetapp.h \
|
||||||
|
qgimanager.h \
|
||||||
|
terminal.h \
|
||||||
|
editor/arceditor.h \
|
||||||
|
editor/circleeditor.h \
|
||||||
|
editor/customelementgraphicpart.h \
|
||||||
|
editor/customelementpart.h \
|
||||||
|
editor/editorcommands.h \
|
||||||
|
editor/elementitemeditor.h \
|
||||||
|
editor/elementscene.h \
|
||||||
|
editor/elementview.h \
|
||||||
|
editor/ellipseeditor.h \
|
||||||
|
editor/lineeditor.h \
|
||||||
|
editor/partarc.h \
|
||||||
|
editor/partcircle.h \
|
||||||
|
editor/partellipse.h \
|
||||||
|
editor/partline.h \
|
||||||
editor/partpolygon.h \
|
editor/partpolygon.h \
|
||||||
editor/polygoneditor.h \
|
|
||||||
editor/partterminal.h \
|
editor/partterminal.h \
|
||||||
|
editor/parttext.h \
|
||||||
|
editor/parttextfield.h \
|
||||||
|
editor/polygoneditor.h \
|
||||||
|
editor/qetelementeditor.h \
|
||||||
|
editor/styleeditor.h \
|
||||||
editor/terminaleditor.h \
|
editor/terminaleditor.h \
|
||||||
editor/parttext.h \
|
editor/texteditor.h \
|
||||||
editor/texteditor.h \
|
editor/textfieldeditor.h
|
||||||
editor/partarc.h \
|
|
||||||
editor/arceditor.h \
|
|
||||||
editor/parttextfield.h \
|
|
||||||
editor/textfieldeditor.h \
|
|
||||||
hotspoteditor.h \
|
|
||||||
editor/editorcommands.h \
|
|
||||||
qgimanager.h
|
|
||||||
SOURCES += aboutqet.cpp \
|
SOURCES += aboutqet.cpp \
|
||||||
borderinset.cpp \
|
borderinset.cpp \
|
||||||
conducer.cpp \
|
conducer.cpp \
|
||||||
@@ -74,39 +76,41 @@ SOURCES += aboutqet.cpp \
|
|||||||
elementtextitem.cpp \
|
elementtextitem.cpp \
|
||||||
exportdialog.cpp \
|
exportdialog.cpp \
|
||||||
fixedelement.cpp \
|
fixedelement.cpp \
|
||||||
|
hotspoteditor.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
nameslist.cpp \
|
nameslist.cpp \
|
||||||
nameslistwidget.cpp \
|
nameslistwidget.cpp \
|
||||||
newelementwizard.cpp \
|
newelementwizard.cpp \
|
||||||
qetapp.cpp \
|
|
||||||
terminal.cpp \
|
|
||||||
editor/customelementeditor.cpp \
|
|
||||||
editor/customelementgraphicpart.cpp \
|
|
||||||
editor/customelementpart.cpp \
|
|
||||||
editor/editorscene.cpp \
|
|
||||||
editor/ellipseeditor.cpp \
|
|
||||||
editor/lineeditor.cpp \
|
|
||||||
editor/partellipse.cpp \
|
|
||||||
editor/partline.cpp \
|
|
||||||
editor/styleeditor.cpp \
|
|
||||||
editor/qet.cpp \
|
|
||||||
editor/partcircle.cpp \
|
|
||||||
editor/circleeditor.cpp \
|
|
||||||
orientationset.cpp \
|
orientationset.cpp \
|
||||||
orientationsetwidget.cpp \
|
orientationsetwidget.cpp \
|
||||||
|
qetapp.cpp \
|
||||||
|
qgimanager.cpp \
|
||||||
|
terminal.cpp \
|
||||||
|
editor/arceditor.cpp \
|
||||||
|
editor/circleeditor.cpp \
|
||||||
|
editor/customelementgraphicpart.cpp \
|
||||||
|
editor/customelementpart.cpp \
|
||||||
|
editor/editorcommands.cpp \
|
||||||
|
editor/elementitemeditor.cpp \
|
||||||
|
editor/elementscene.cpp \
|
||||||
|
editor/elementview.cpp \
|
||||||
|
editor/ellipseeditor.cpp \
|
||||||
|
editor/lineeditor.cpp \
|
||||||
|
editor/partarc.cpp \
|
||||||
|
editor/partcircle.cpp \
|
||||||
|
editor/partellipse.cpp \
|
||||||
|
editor/partline.cpp \
|
||||||
editor/partpolygon.cpp \
|
editor/partpolygon.cpp \
|
||||||
editor/polygoneditor.cpp \
|
|
||||||
editor/partterminal.cpp \
|
editor/partterminal.cpp \
|
||||||
|
editor/parttext.cpp \
|
||||||
|
editor/parttextfield.cpp \
|
||||||
|
editor/polygoneditor.cpp \
|
||||||
|
editor/qet.cpp \
|
||||||
|
editor/qetelementeditor.cpp \
|
||||||
|
editor/styleeditor.cpp \
|
||||||
editor/terminaleditor.cpp \
|
editor/terminaleditor.cpp \
|
||||||
editor/parttext.cpp \
|
editor/texteditor.cpp \
|
||||||
editor/texteditor.cpp \
|
editor/textfieldeditor.cpp
|
||||||
editor/partarc.cpp \
|
|
||||||
editor/arceditor.cpp \
|
|
||||||
editor/parttextfield.cpp \
|
|
||||||
editor/textfieldeditor.cpp \
|
|
||||||
hotspoteditor.cpp \
|
|
||||||
editor/editorcommands.cpp \
|
|
||||||
qgimanager.cpp
|
|
||||||
RESOURCES += qelectrotech.qrc
|
RESOURCES += qelectrotech.qrc
|
||||||
TRANSLATIONS += lang/qet_en.ts lang/qt_fr.ts
|
TRANSLATIONS += lang/qet_en.ts lang/qt_fr.ts
|
||||||
QT += xml
|
QT += xml
|
||||||
|
|||||||
Reference in New Issue
Block a user