mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-23 18:50:52 +01:00
Nettoyage
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@85 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -30,6 +30,12 @@ AboutQET::AboutQET(QWidget *parent) : QDialog(parent) {
|
||||
setLayout(disposition);
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
AboutQET::~AboutQET() {
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le titre QElectroTech avec son icone
|
||||
*/
|
||||
@@ -58,7 +64,7 @@ QWidget *AboutQET::ongletAPropos() const {
|
||||
QLabel *apropos = new QLabel(
|
||||
tr("QElectroTech, une application de r\351alisation de sch\351mas \351lectriques.") +
|
||||
"<br><br>" +
|
||||
tr("\251 2006 Les d\351veloppeurs de QElectroTech") +
|
||||
tr("\251 2006-2007 Les d\351veloppeurs de QElectroTech") +
|
||||
"<br><br>"
|
||||
"<a href=\"http://qelectrotech.tuxfamily.org/\">"
|
||||
"http://qelectrotech.tuxfamily.org/</a>"
|
||||
|
||||
@@ -7,8 +7,16 @@
|
||||
*/
|
||||
class AboutQET : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
AboutQET(QWidget * = 0);
|
||||
virtual ~AboutQET();
|
||||
|
||||
private:
|
||||
AboutQET(AboutQET &);
|
||||
|
||||
// methodes
|
||||
private:
|
||||
QWidget *titre() const;
|
||||
QWidget *ongletAPropos() const;
|
||||
|
||||
@@ -10,9 +10,17 @@
|
||||
*/
|
||||
class BorderInset : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
BorderInset(QObject * = 0);
|
||||
~BorderInset();
|
||||
virtual ~BorderInset();
|
||||
|
||||
private:
|
||||
BorderInset(const BorderInset &);
|
||||
|
||||
// methodes
|
||||
public:
|
||||
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
||||
|
||||
// methodes d'acces en lecture aux dimensions
|
||||
@@ -61,6 +69,10 @@
|
||||
void displayColumns (bool dc) { display_columns = dc; }
|
||||
void displayBorder (bool db) { display_border = db; }
|
||||
|
||||
private:
|
||||
void updateRectangles();
|
||||
|
||||
// attributs
|
||||
private:
|
||||
// informations du cartouche
|
||||
QString bi_author;
|
||||
@@ -92,7 +104,5 @@
|
||||
bool display_inset;
|
||||
bool display_columns;
|
||||
bool display_border;
|
||||
|
||||
void updateRectangles();
|
||||
};
|
||||
#endif
|
||||
|
||||
19
conducer.cpp
19
conducer.cpp
@@ -51,6 +51,21 @@ Conducer::Conducer(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *
|
||||
calculateTextItemPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
Detruit le conducteur ainsi que ses segments. Il ne detruit pas les bornes
|
||||
mais s'en detache
|
||||
*/
|
||||
Conducer::~Conducer() {
|
||||
// qDebug() << "~Conducer()" << (void *)this;
|
||||
// se detache des bornes
|
||||
if (!isDestroyed()) destroy();
|
||||
|
||||
// supprime les segments
|
||||
while (segments -> hasNextSegment()) delete segments -> nextSegment();
|
||||
delete segments;
|
||||
}
|
||||
|
||||
/**
|
||||
Met a jour la representation graphique du conducteur.
|
||||
@param rect Rectangle a mettre a jour
|
||||
@@ -632,7 +647,7 @@ qreal Conducer::conducer_bound(qreal tobound, qreal bound, bool positive) {
|
||||
/**
|
||||
@return Le nombre de segments composant le conducteur.
|
||||
*/
|
||||
int Conducer::nbSegments() {
|
||||
int Conducer::nbSegments() const {
|
||||
if (segments == NULL) return(0);
|
||||
int nb_seg = 1;
|
||||
ConducerSegment *segment = segments;
|
||||
@@ -701,7 +716,7 @@ void Conducer::pointsToSegments(QList<QPointF> points_list) {
|
||||
@param point point cliquable
|
||||
@return true si l'on peut considerer que le point a ete clique, false sinon
|
||||
*/
|
||||
bool Conducer::hasClickedOn(QPointF press_point, QPointF point) {
|
||||
bool Conducer::hasClickedOn(QPointF press_point, QPointF point) const {
|
||||
return (
|
||||
press_point.x() >= point.x() - 5.0 &&\
|
||||
press_point.x() < point.x() + 5.0 &&\
|
||||
|
||||
61
conducer.h
61
conducer.h
@@ -8,36 +8,23 @@
|
||||
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
||||
*/
|
||||
class Conducer : public QGraphicsPathItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
Conducer(Terminal *, Terminal *, Element * = 0, QGraphicsScene * = 0);
|
||||
virtual ~Conducer();
|
||||
|
||||
private:
|
||||
Conducer(const Conducer &);
|
||||
|
||||
// attributs
|
||||
public:
|
||||
enum { Type = UserType + 1001 };
|
||||
virtual int type() const { return Type; }
|
||||
Conducer(Terminal *, Terminal *, Element * = 0, QGraphicsScene * = 0);
|
||||
//virtual ~Conducer();
|
||||
|
||||
void destroy();
|
||||
bool isDestroyed() const { return(destroyed); }
|
||||
void updateWithNewPos(const QRectF &, const Terminal *, const QPointF &);
|
||||
void update(const QRectF & = QRectF());
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
QRectF boundingRect() const;
|
||||
virtual QPainterPath shape() const;
|
||||
qreal length();
|
||||
ConducerSegment *middleSegment();
|
||||
static bool valideXml(QDomElement &);
|
||||
bool fromXml(QDomElement &);
|
||||
QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
||||
|
||||
///Premiere borne a laquelle le fil est rattache
|
||||
Terminal *terminal1;
|
||||
///Deuxieme borne a laquelle le fil est rattache
|
||||
Terminal *terminal2;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||
|
||||
private:
|
||||
/// booleen indiquant si le fil est encore valide
|
||||
bool destroyed;
|
||||
@@ -59,15 +46,37 @@
|
||||
static QBrush conducer_brush;
|
||||
static bool pen_and_brush_initialized;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
virtual int type() const { return Type; }
|
||||
void destroy();
|
||||
bool isDestroyed() const { return(destroyed); }
|
||||
void updateWithNewPos(const QRectF &, const Terminal *, const QPointF &);
|
||||
void update(const QRectF & = QRectF());
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
QRectF boundingRect() const;
|
||||
virtual QPainterPath shape() const;
|
||||
qreal length();
|
||||
ConducerSegment *middleSegment();
|
||||
static bool valideXml(QDomElement &);
|
||||
bool fromXml(QDomElement &);
|
||||
QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||
|
||||
private:
|
||||
void segmentsToPath();
|
||||
void updatePoints();
|
||||
void priv_calculeConducer(const QPointF &, Terminal::Orientation, const QPointF &, Terminal::Orientation);
|
||||
void priv_modifieConducer(const QPointF &, Terminal::Orientation, const QPointF &, Terminal::Orientation);
|
||||
int nbSegments();
|
||||
|
||||
int nbSegments() const;
|
||||
QList<QPointF> segmentsToPoints() const;
|
||||
void pointsToSegments(QList<QPointF>);
|
||||
bool hasClickedOn(QPointF, QPointF);
|
||||
bool hasClickedOn(QPointF, QPointF) const;
|
||||
void calculateTextItemPosition();
|
||||
static QPointF extendTerminal(const QPointF &, Terminal::Orientation, qreal = 12.0);
|
||||
static bool surLeMemeAxe(Terminal::Orientation, Terminal::Orientation);
|
||||
|
||||
@@ -8,9 +8,15 @@
|
||||
@param cs1 Le segment precedent
|
||||
@param cs2 Le segment suivant
|
||||
*/
|
||||
ConducerSegment::ConducerSegment(QPointF p1, QPointF p2, ConducerSegment *cs1, ConducerSegment *cs2) {
|
||||
setFirstPoint(p1);
|
||||
setSecondPoint(p2);
|
||||
ConducerSegment::ConducerSegment(
|
||||
const QPointF &p1,
|
||||
const QPointF &p2,
|
||||
ConducerSegment *cs1,
|
||||
ConducerSegment *cs2
|
||||
) :
|
||||
point1(p1),
|
||||
point2(p2)
|
||||
{
|
||||
setPreviousSegment(cs1);
|
||||
setNextSegment(cs2);
|
||||
}
|
||||
@@ -19,6 +25,7 @@ ConducerSegment::ConducerSegment(QPointF p1, QPointF p2, ConducerSegment *cs1, C
|
||||
Destructeur - Relie le segment precedent au suivant
|
||||
*/
|
||||
ConducerSegment::~ConducerSegment() {
|
||||
//qDebug() << "~ConducerSegment()" << (void *)this;
|
||||
if (hasPreviousSegment()) previousSegment() -> setNextSegment(nextSegment());
|
||||
if (hasNextSegment()) nextSegment() -> setPreviousSegment(previousSegment());
|
||||
}
|
||||
@@ -32,7 +39,7 @@ ConducerSegment::~ConducerSegment() {
|
||||
@param possible_dx La valeur du mouvement possible (au maximum)
|
||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
||||
*/
|
||||
bool ConducerSegment::canMove1stPointX(qreal asked_dx, qreal &possible_dx) {
|
||||
bool ConducerSegment::canMove1stPointX(const qreal &asked_dx, qreal &possible_dx) const {
|
||||
|
||||
Q_ASSERT_X(isVertical(), "ConducerSegment::canMove1stPointX", "segment non vertical");
|
||||
|
||||
@@ -91,7 +98,7 @@ bool ConducerSegment::canMove1stPointX(qreal asked_dx, qreal &possible_dx) {
|
||||
@param possible_dx La valeur du mouvement possible (au maximum)
|
||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
||||
*/
|
||||
bool ConducerSegment::canMove2ndPointX(qreal asked_dx, qreal &possible_dx) {
|
||||
bool ConducerSegment::canMove2ndPointX(const qreal &asked_dx, qreal &possible_dx) const {
|
||||
|
||||
Q_ASSERT_X(isVertical(), "ConducerSegment::canMove2ndPointX", "segment non vertical");
|
||||
|
||||
@@ -150,7 +157,7 @@ bool ConducerSegment::canMove2ndPointX(qreal asked_dx, qreal &possible_dx) {
|
||||
@param possible_dy La valeur du mouvement possible (au maximum)
|
||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
||||
*/
|
||||
bool ConducerSegment::canMove1stPointY(qreal asked_dy, qreal &possible_dy) {
|
||||
bool ConducerSegment::canMove1stPointY(const qreal &asked_dy, qreal &possible_dy) const {
|
||||
|
||||
Q_ASSERT_X(isHorizontal(), "ConducerSegment::canMove1stPointY", "segment non horizontal");
|
||||
|
||||
@@ -209,7 +216,7 @@ bool ConducerSegment::canMove1stPointY(qreal asked_dy, qreal &possible_dy) {
|
||||
@param possible_dy La valeur du mouvement possible (au maximum)
|
||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
||||
*/
|
||||
bool ConducerSegment::canMove2ndPointY(qreal asked_dy, qreal &possible_dy) {
|
||||
bool ConducerSegment::canMove2ndPointY(const qreal &asked_dy, qreal &possible_dy) const {
|
||||
|
||||
Q_ASSERT_X(isHorizontal(), "ConducerSegment::canMove2ndPointY", "segment non horizontal");
|
||||
|
||||
@@ -264,7 +271,7 @@ bool ConducerSegment::canMove2ndPointY(qreal asked_dy, qreal &possible_dy) {
|
||||
Gere les mouvements sur l'axe horizontal
|
||||
@param dx taille du deplacement en pixels
|
||||
*/
|
||||
void ConducerSegment::moveX(qreal dx) {
|
||||
void ConducerSegment::moveX(const qreal &dx) {
|
||||
if (isHorizontal()) return;
|
||||
Q_ASSERT_X(isVertical(), "ConducerSegment::moveX", "segment non vertical");
|
||||
|
||||
@@ -312,7 +319,7 @@ void ConducerSegment::moveX(qreal dx) {
|
||||
Gere les mouvements sur l'axe vertical
|
||||
@param dx taille du deplacement en pixels
|
||||
*/
|
||||
void ConducerSegment::moveY(qreal dy) {
|
||||
void ConducerSegment::moveY(const qreal &dy) {
|
||||
if (isVertical()) return;
|
||||
Q_ASSERT_X(isHorizontal(), "ConducerSegment::moveY", "segment non horizontal");
|
||||
|
||||
@@ -449,42 +456,42 @@ void ConducerSegment::setNextSegment(ConducerSegment *ns) {
|
||||
/**
|
||||
@return Le segment precedent
|
||||
*/
|
||||
ConducerSegment *ConducerSegment::previousSegment() {
|
||||
ConducerSegment *ConducerSegment::previousSegment() const {
|
||||
return(previous_segment);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le segment suivant
|
||||
*/
|
||||
ConducerSegment *ConducerSegment::nextSegment() {
|
||||
ConducerSegment *ConducerSegment::nextSegment() const {
|
||||
return(next_segment);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le segment est vertical, false sinon
|
||||
*/
|
||||
bool ConducerSegment::isVertical() {
|
||||
bool ConducerSegment::isVertical() const {
|
||||
return(point1.x() == point2.x());
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le segment est horizontal, false sinon
|
||||
*/
|
||||
bool ConducerSegment::isHorizontal() {
|
||||
bool ConducerSegment::isHorizontal() const {
|
||||
return(point1.y() == point2.y());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le premier point du segment
|
||||
*/
|
||||
QPointF ConducerSegment::firstPoint() {
|
||||
QPointF ConducerSegment::firstPoint() const {
|
||||
return(point1);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le second point du segment
|
||||
*/
|
||||
QPointF ConducerSegment::secondPoint() {
|
||||
QPointF ConducerSegment::secondPoint() const {
|
||||
return(point2);
|
||||
}
|
||||
|
||||
@@ -492,7 +499,7 @@ QPointF ConducerSegment::secondPoint() {
|
||||
Permet de changer la position du premier point du segment
|
||||
@param p La nouvelle position du premier point
|
||||
*/
|
||||
void ConducerSegment::setFirstPoint(QPointF p) {
|
||||
void ConducerSegment::setFirstPoint(const QPointF &p) {
|
||||
point1 = p;
|
||||
}
|
||||
|
||||
@@ -500,28 +507,28 @@ void ConducerSegment::setFirstPoint(QPointF p) {
|
||||
Permet de changer la position du second point du segment
|
||||
@param p La nouvelle position du second point
|
||||
*/
|
||||
void ConducerSegment::setSecondPoint(QPointF p) {
|
||||
void ConducerSegment::setSecondPoint(const QPointF &p) {
|
||||
point2 = p;
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le segment a un segment precedent, false sinon
|
||||
*/
|
||||
bool ConducerSegment::hasPreviousSegment() {
|
||||
bool ConducerSegment::hasPreviousSegment() const {
|
||||
return(previous_segment != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le segment a un segment suivant, false sinon
|
||||
*/
|
||||
bool ConducerSegment::hasNextSegment() {
|
||||
bool ConducerSegment::hasNextSegment() const {
|
||||
return(next_segment != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le centre du rectangle delimitant le conducteur
|
||||
*/
|
||||
QPointF ConducerSegment::middle() {
|
||||
QPointF ConducerSegment::middle() const {
|
||||
return(
|
||||
QPointF(
|
||||
(point1.x() + point2.x()) / 2.0,
|
||||
@@ -533,7 +540,7 @@ QPointF ConducerSegment::middle() {
|
||||
/**
|
||||
@return La longueur du conducteur
|
||||
*/
|
||||
qreal ConducerSegment::length() {
|
||||
qreal ConducerSegment::length() const {
|
||||
if (isHorizontal()) {
|
||||
return(secondPoint().x() - firstPoint().x());
|
||||
} else {
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
Cette classe represente un segment de conducteur.
|
||||
*/
|
||||
class ConducerSegment {
|
||||
// constructeurs et destructeur
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ConducerSegment(QPointF, QPointF, ConducerSegment * = NULL, ConducerSegment * = NULL);
|
||||
~ConducerSegment();
|
||||
ConducerSegment(const QPointF &, const QPointF &, ConducerSegment * = NULL, ConducerSegment * = NULL);
|
||||
virtual ~ConducerSegment();
|
||||
|
||||
private:
|
||||
ConducerSegment(const ConducerSegment &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -19,25 +23,25 @@
|
||||
|
||||
// methodes
|
||||
public:
|
||||
void moveX(qreal);
|
||||
void moveY(qreal);
|
||||
ConducerSegment *previousSegment();
|
||||
ConducerSegment *nextSegment();
|
||||
bool hasPreviousSegment();
|
||||
bool hasNextSegment();
|
||||
void moveX(const qreal &);
|
||||
void moveY(const qreal &);
|
||||
ConducerSegment *previousSegment() const;
|
||||
ConducerSegment *nextSegment() const;
|
||||
bool hasPreviousSegment() const;
|
||||
bool hasNextSegment() const;
|
||||
void setPreviousSegment(ConducerSegment *);
|
||||
void setNextSegment(ConducerSegment *);
|
||||
QPointF firstPoint();
|
||||
QPointF secondPoint();
|
||||
void setFirstPoint(QPointF);
|
||||
void setSecondPoint(QPointF);
|
||||
QPointF middle();
|
||||
bool isHorizontal();
|
||||
bool isVertical();
|
||||
qreal length();
|
||||
bool canMove1stPointX(qreal, qreal &);
|
||||
bool canMove2ndPointX(qreal, qreal &);
|
||||
bool canMove1stPointY(qreal, qreal &);
|
||||
bool canMove2ndPointY(qreal, qreal &);
|
||||
QPointF firstPoint() const;
|
||||
QPointF secondPoint() const;
|
||||
void setFirstPoint(const QPointF &);
|
||||
void setSecondPoint(const QPointF &);
|
||||
QPointF middle() const;
|
||||
bool isHorizontal() const;
|
||||
bool isVertical() const;
|
||||
qreal length() const;
|
||||
bool canMove1stPointX(const qreal &, qreal &) const;
|
||||
bool canMove2ndPointX(const qreal &, qreal &) const;
|
||||
bool canMove1stPointY(const qreal &, qreal &) const;
|
||||
bool canMove2ndPointY(const qreal &, qreal &) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -156,6 +156,12 @@ CustomElement::CustomElement(QString &nom_fichier, QGraphicsItem *qgi, Diagram *
|
||||
elmt_etat = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
CustomElement::~CustomElement() {
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nombre de bornes que l'element possede
|
||||
*/
|
||||
|
||||
@@ -9,21 +9,33 @@
|
||||
en parametre.
|
||||
*/
|
||||
class CustomElement : public FixedElement {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
CustomElement(QString &, QGraphicsItem * = 0, Diagram * = 0, int * = NULL);
|
||||
virtual int nbTerminals() const;
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
inline QString typeId() const { return(nomfichier); }
|
||||
inline QString fichier() const { return(nomfichier); }
|
||||
inline bool isNull() const { return(elmt_etat != 0); }
|
||||
inline int etat() const { return(elmt_etat); }
|
||||
inline QString nom() const { return(priv_nom); }
|
||||
virtual ~CustomElement();
|
||||
|
||||
private:
|
||||
CustomElement(const CustomElement &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
int elmt_etat; // contient le code d'erreur si l'instanciation a echoue ou 0 si l'instanciation s'est bien passe
|
||||
QString priv_nom;
|
||||
QString nomfichier;
|
||||
QPicture dessin;
|
||||
int nb_terminals;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
virtual int nbTerminals() const;
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
QString typeId() const;
|
||||
QString fichier() const;
|
||||
bool isNull() const;
|
||||
int etat() const;
|
||||
QString nom() const;
|
||||
|
||||
private:
|
||||
bool parseElement(QDomElement &, QPainter &, Diagram *);
|
||||
bool parseLine(QDomElement &, QPainter &);
|
||||
bool parseEllipse(QDomElement &, QPainter &);
|
||||
@@ -38,6 +50,53 @@
|
||||
bool attributeIsAReal(QDomElement &, QString, double * = NULL);
|
||||
bool validOrientationAttribute(QDomElement &);
|
||||
void setPainterStyle(QDomElement &, QPainter &);
|
||||
int nb_terminals;
|
||||
};
|
||||
|
||||
/**
|
||||
@return L'ID du type de l'element ; pour un CustomElement, cela revient au
|
||||
nom du fichier
|
||||
@see fichier()
|
||||
*/
|
||||
inline QString CustomElement::typeId() const {
|
||||
return(nomfichier);
|
||||
}
|
||||
|
||||
/**
|
||||
@return L'adresse du fichier contenant la description XML de cet element
|
||||
*/
|
||||
inline QString CustomElement::fichier() const {
|
||||
return(nomfichier);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si cet element est nul, c'est-a-dire si le chargement de sa
|
||||
description XML a echoue
|
||||
*/
|
||||
inline bool CustomElement::isNull() const {
|
||||
return(elmt_etat != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Un entier representant l'etat de l'element :
|
||||
- 0 : L'instanciation a reussi
|
||||
- 1 : Le fichier n'existe pas
|
||||
- 2 : Le fichier n'a pu etre ouvert
|
||||
- 3 : Le fichier n'est pas un document XML
|
||||
- 4 : Le document XML n'a pas une "definition" comme racine
|
||||
- 5 : Les attributs de la definition ne sont pas presents et / ou valides
|
||||
- 6 : La definition est vide
|
||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
||||
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||
*/
|
||||
inline int CustomElement::etat() const {
|
||||
return(elmt_etat);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nom de l'element
|
||||
*/
|
||||
inline QString CustomElement::nom() const {
|
||||
return(priv_nom);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
16
diagram.cpp
16
diagram.cpp
@@ -10,19 +10,25 @@
|
||||
*/
|
||||
Diagram::Diagram(QObject *parent) : QGraphicsScene(parent) {
|
||||
setBackgroundBrush(Qt::white);
|
||||
poseur_de_conducer = new QGraphicsLineItem(0, 0);
|
||||
poseur_de_conducer -> setZValue(1000000);
|
||||
conducer_setter = new QGraphicsLineItem(0, 0);
|
||||
conducer_setter -> setZValue(1000000);
|
||||
QPen t;
|
||||
t.setColor(Qt::black);
|
||||
t.setWidthF(1.5);
|
||||
t.setStyle(Qt::DashLine);
|
||||
poseur_de_conducer -> setPen(t);
|
||||
poseur_de_conducer -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
||||
conducer_setter -> setPen(t);
|
||||
conducer_setter -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
||||
draw_grid = true;
|
||||
use_border = true;
|
||||
connect(this, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(slot_checkSelectionEmptinessChange()));
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
Diagram::~Diagram() {
|
||||
};
|
||||
|
||||
/**
|
||||
Dessine l'arriere-plan du schema, cad la grille.
|
||||
@param p Le QPainter a utiliser pour dessiner
|
||||
@@ -41,7 +47,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
p -> setBrush(Qt::white);
|
||||
p -> drawRect(r);
|
||||
|
||||
if (draw_grid) {
|
||||
if (draw_grid && r.width() < 2500 && r.height() < 2500) {
|
||||
// dessine les points de la grille
|
||||
p -> setPen(Qt::black);
|
||||
p -> setBrush(Qt::NoBrush);
|
||||
|
||||
52
diagram.h
52
diagram.h
@@ -11,38 +11,50 @@ class Element;
|
||||
class Terminal;
|
||||
class Diagram : public QGraphicsScene {
|
||||
Q_OBJECT
|
||||
enum BorderOptions { EmptyBorder, Inset, Columns };
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
Diagram(QObject * = 0);
|
||||
virtual ~Diagram();
|
||||
|
||||
private:
|
||||
Diagram(const Diagram &diagram);
|
||||
|
||||
// attributs
|
||||
public:
|
||||
enum BorderOptions { EmptyBorder, Inset, Columns };
|
||||
BorderInset border_and_inset;
|
||||
|
||||
private:
|
||||
QGraphicsLineItem *conducer_setter;
|
||||
bool draw_grid;
|
||||
bool use_border;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
void drawBackground(QPainter *, const QRectF &);
|
||||
|
||||
// fonctions relatives a la pose de conducteurs
|
||||
void poseConducer(bool);
|
||||
|
||||
void setDepart (QPointF);
|
||||
void setArrivee(QPointF);
|
||||
void setConducer(bool);
|
||||
void setConducerStart (QPointF);
|
||||
void setConducerStop(QPointF);
|
||||
|
||||
// fonctions relatives a l'import / export XML
|
||||
QDomDocument toXml(bool = true);
|
||||
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true);
|
||||
|
||||
// fonctions relatives aux options graphiques
|
||||
void setAffichageGrille(bool);
|
||||
void setDisplayGrid(bool);
|
||||
bool displayGrid();
|
||||
void setUseBorder(bool);
|
||||
bool useBorder();
|
||||
void setBorderOptions(BorderOptions);
|
||||
BorderOptions borderOptions();
|
||||
BorderInset border_and_inset;
|
||||
|
||||
QRectF border() const;
|
||||
QImage toImage(int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
||||
QSize imageSize() const;
|
||||
|
||||
private:
|
||||
QGraphicsLineItem *poseur_de_conducer;
|
||||
bool draw_grid;
|
||||
bool use_border;
|
||||
|
||||
private slots:
|
||||
void slot_checkSelectionChange();
|
||||
void slot_checkSelectionEmptinessChange();
|
||||
@@ -58,11 +70,11 @@ class Diagram : public QGraphicsScene {
|
||||
bornes.
|
||||
@param true pour ajouter le poseur de conducteur, false pour l'enlever
|
||||
*/
|
||||
inline void Diagram::poseConducer(bool pf) {
|
||||
inline void Diagram::setConducer(bool pf) {
|
||||
if (pf) {
|
||||
if (!poseur_de_conducer -> scene()) addItem(poseur_de_conducer);
|
||||
if (!conducer_setter -> scene()) addItem(conducer_setter);
|
||||
} else {
|
||||
if (poseur_de_conducer -> scene()) removeItem(poseur_de_conducer);
|
||||
if (conducer_setter -> scene()) removeItem(conducer_setter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,23 +82,23 @@ inline void Diagram::poseConducer(bool pf) {
|
||||
Specifie les coordonnees du point de depart du poseur de conducteur
|
||||
@param d Le nouveau point de depart du poseur de conducteur
|
||||
*/
|
||||
inline void Diagram::setDepart(QPointF d) {
|
||||
poseur_de_conducer -> setLine(QLineF(d, poseur_de_conducer -> line().p2()));
|
||||
inline void Diagram::setConducerStart(QPointF d) {
|
||||
conducer_setter -> setLine(QLineF(d, conducer_setter -> line().p2()));
|
||||
}
|
||||
|
||||
/**
|
||||
Specifie les coordonnees du point d'arrivee du poseur de conducteur
|
||||
@param d Le nouveau point d'arrivee du poseur de conducteur
|
||||
*/
|
||||
inline void Diagram::setArrivee(QPointF a) {
|
||||
poseur_de_conducer -> setLine(QLineF(poseur_de_conducer -> line().p1(), a));
|
||||
inline void Diagram::setConducerStop(QPointF a) {
|
||||
conducer_setter -> setLine(QLineF(conducer_setter -> line().p1(), a));
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de specifier si la grille du schema doit etre dessinee ou non
|
||||
@param dg true pour afficher la grille, false pour ne pas l'afficher
|
||||
*/
|
||||
inline void Diagram::setAffichageGrille(bool dg) {
|
||||
inline void Diagram::setDisplayGrid(bool dg) {
|
||||
draw_grid = dg;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "diagram.h"
|
||||
#include "customelement.h"
|
||||
#include "exportdialog.h"
|
||||
#include "conducer.h"
|
||||
|
||||
/**
|
||||
Initialise le DiagramView
|
||||
@@ -40,6 +41,12 @@ DiagramView::DiagramView(QWidget *parent) : QGraphicsView(parent) {
|
||||
initialise();
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
DiagramView::~DiagramView() {
|
||||
}
|
||||
|
||||
/**
|
||||
appelle la methode select sur tous les elements de la liste d'elements
|
||||
*/
|
||||
@@ -443,9 +450,9 @@ void DiagramView::dialogPrint() {
|
||||
|
||||
if (qpd.exec() == QDialog::Accepted) {
|
||||
QPainter qp(&qprin);
|
||||
scene -> setAffichageGrille(false);
|
||||
scene -> setDisplayGrid(false);
|
||||
scene -> render(&qp);
|
||||
scene -> setAffichageGrille(true);
|
||||
scene -> setDisplayGrid(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,22 +2,28 @@
|
||||
#define DIAGRAMVIEW_H
|
||||
#include <QtGui>
|
||||
class Diagram;
|
||||
#include "element.h"
|
||||
#include "conducer.h"
|
||||
/**
|
||||
Classe representant graphiquement un schema electrique
|
||||
*/
|
||||
class DiagramView : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
// constructeurs
|
||||
DiagramView();
|
||||
DiagramView(QWidget * = 0);
|
||||
virtual ~DiagramView();
|
||||
|
||||
// nouveaux attributs
|
||||
private:
|
||||
DiagramView(const DiagramView &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
Diagram *scene;
|
||||
QList<QGraphicsItem *> garbage;
|
||||
|
||||
// methodes publiques
|
||||
// methodes
|
||||
public:
|
||||
bool ouvrir(QString, int * = NULL);
|
||||
void closeEvent(QCloseEvent *);
|
||||
QString nom_fichier;
|
||||
@@ -38,8 +44,6 @@
|
||||
private:
|
||||
bool private_enregistrer(QString &);
|
||||
void initialise();
|
||||
QList<QGraphicsItem *> garbage;
|
||||
|
||||
void throwToGarbage(QGraphicsItem *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void dragEnterEvent(QDragEnterEvent *);
|
||||
|
||||
12
element.cpp
12
element.cpp
@@ -3,8 +3,6 @@
|
||||
#include "elementtextitem.h"
|
||||
#include <QtDebug>
|
||||
|
||||
/*** Methodes publiques ***/
|
||||
|
||||
/**
|
||||
Constructeur pour un element sans scene ni parent
|
||||
*/
|
||||
@@ -13,6 +11,12 @@ Element::Element(QGraphicsItem *parent, Diagram *scene) : QGraphicsItem(parent,
|
||||
setZValue(10);
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
Element::~Element() {
|
||||
}
|
||||
|
||||
/**
|
||||
Methode principale de dessin de l'element
|
||||
@param painter Le QPainter utilise pour dessiner l'elment
|
||||
@@ -110,10 +114,6 @@ QVariant Element::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConducer(value.toPointF());
|
||||
}
|
||||
} else if (change == QGraphicsItem::ItemSelectedChange) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConducer();
|
||||
}
|
||||
}
|
||||
return(QGraphicsItem::itemChange(change, value));
|
||||
}
|
||||
|
||||
107
element.h
107
element.h
@@ -7,45 +7,20 @@
|
||||
*/
|
||||
class Diagram;
|
||||
class Element : public QGraphicsItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
Element(QGraphicsItem * = 0, Diagram * = 0);
|
||||
virtual ~Element();
|
||||
|
||||
private:
|
||||
Element(const Element &);
|
||||
|
||||
// attributs
|
||||
public:
|
||||
enum { Type = UserType + 1000 };
|
||||
virtual int type() const { return Type; }
|
||||
Element(QGraphicsItem * = 0, Diagram * = 0);
|
||||
|
||||
virtual int nbTerminals() const = 0;
|
||||
virtual int nbTerminalsMin() const = 0;
|
||||
virtual int nbTerminalsMax() const = 0;
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *) = 0;
|
||||
virtual QString typeId() const = 0;
|
||||
|
||||
virtual QString nom() const = 0;
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
QRectF boundingRect() const;
|
||||
QSize setSize(int, int);
|
||||
QPoint setHotspot(QPoint);
|
||||
QPoint hotspot() const;
|
||||
void select();
|
||||
void deselect();
|
||||
QPixmap pixmap();
|
||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||
void setPos(const QPointF &);
|
||||
void setPos(qreal, qreal);
|
||||
bool connexionsInternesAcceptees();
|
||||
void setConnexionsInternesAcceptees(bool cia);
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *>&);
|
||||
virtual QDomElement toXml (QDomDocument &, QHash<Terminal *, int>&) const;
|
||||
// methodes d'acces aux possibilites d'orientation
|
||||
Terminal::Orientation orientation() const;
|
||||
bool acceptOrientation(Terminal::Orientation o) const;
|
||||
Terminal::Orientation defaultOrientation() const;
|
||||
Terminal::Orientation nextAcceptableOrientation() const;
|
||||
Terminal::Orientation previousAcceptableOrientation() const;
|
||||
bool setOrientation(Terminal::Orientation o);
|
||||
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
bool ori_n;
|
||||
bool ori_s;
|
||||
bool ori_e;
|
||||
@@ -53,6 +28,63 @@ class Element : public QGraphicsItem {
|
||||
Terminal::Orientation ori_d;
|
||||
Terminal::Orientation ori;
|
||||
|
||||
private:
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
QPixmap apercu;
|
||||
QMenu menu;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
virtual int type() const { return Type; }
|
||||
|
||||
// methodes virtuelles pures a definir dans les classes enfants
|
||||
virtual int nbTerminals() const = 0;
|
||||
virtual int nbTerminalsMin() const = 0;
|
||||
virtual int nbTerminalsMax() const = 0;
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *) = 0;
|
||||
virtual QString typeId() const = 0;
|
||||
virtual QString nom() const = 0;
|
||||
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||
QRectF boundingRect() const;
|
||||
QSize setSize(int, int);
|
||||
QPixmap pixmap();
|
||||
|
||||
// methodes relatives au point de saisie
|
||||
QPoint setHotspot(QPoint);
|
||||
QPoint hotspot() const;
|
||||
|
||||
// methodes relatives a la selection
|
||||
void select();
|
||||
void deselect();
|
||||
|
||||
// methodes relatives a la position
|
||||
void setPos(const QPointF &);
|
||||
void setPos(qreal, qreal);
|
||||
|
||||
// methodes relatives aux connexions internes
|
||||
bool connexionsInternesAcceptees();
|
||||
void setConnexionsInternesAcceptees(bool cia);
|
||||
|
||||
// methodes relatives aux fichiers XML
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *>&);
|
||||
virtual QDomElement toXml(QDomDocument &, QHash<Terminal *, int>&) const;
|
||||
|
||||
// methodes d'acces aux possibilites d'orientation
|
||||
Terminal::Orientation orientation() const;
|
||||
Terminal::Orientation defaultOrientation() const;
|
||||
bool acceptOrientation(Terminal::Orientation o) const;
|
||||
Terminal::Orientation nextAcceptableOrientation() const;
|
||||
Terminal::Orientation previousAcceptableOrientation() const;
|
||||
bool setOrientation(Terminal::Orientation o);
|
||||
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
|
||||
private:
|
||||
bool peut_relier_ses_propres_terminals;
|
||||
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
@@ -60,11 +92,6 @@ class Element : public QGraphicsItem {
|
||||
Terminal::Orientation nextOrientation(Terminal::Orientation o) const;
|
||||
Terminal::Orientation previousOrientation(Terminal::Orientation o) const;
|
||||
static QList<QDomElement> findInDomElement(QDomElement, QString, QString);
|
||||
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
QPixmap apercu;
|
||||
QMenu menu;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ ElementsCategoriesList::ElementsCategoriesList(QWidget *parent) : QTreeWidget(pa
|
||||
Destructeur
|
||||
*/
|
||||
ElementsCategoriesList::~ElementsCategoriesList() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,23 +7,24 @@
|
||||
*/
|
||||
class ElementsCategoriesList : public QTreeWidget {
|
||||
Q_OBJECT
|
||||
// Constructeur, destructeur
|
||||
|
||||
// Constructeurs, destructeur
|
||||
public:
|
||||
ElementsCategoriesList(QWidget * = 0);
|
||||
~ElementsCategoriesList();
|
||||
|
||||
// attributs
|
||||
virtual ~ElementsCategoriesList();
|
||||
|
||||
private:
|
||||
ElementsCategoriesList(const ElementsCategoriesList &);
|
||||
|
||||
// methodes
|
||||
private:
|
||||
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
||||
QString categoryName(QDir &);
|
||||
|
||||
public:
|
||||
QString selectedCategoryPath();
|
||||
QString selectedCategoryName();
|
||||
|
||||
private:
|
||||
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
||||
QString categoryName(QDir &);
|
||||
|
||||
public slots:
|
||||
void reload();
|
||||
};
|
||||
|
||||
@@ -9,10 +9,14 @@
|
||||
class ElementsCategoriesList;
|
||||
class ElementsCategoriesWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
// Constructeur, destructeur
|
||||
|
||||
// Constructeurs, destructeur
|
||||
public:
|
||||
ElementsCategoriesWidget(QWidget * = 0);
|
||||
~ElementsCategoriesWidget();
|
||||
virtual ~ElementsCategoriesWidget();
|
||||
|
||||
private:
|
||||
ElementsCategoriesWidget(const ElementsCategoriesWidget &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -24,8 +28,6 @@ class ElementsCategoriesWidget : public QWidget {
|
||||
QAction *action_delete;
|
||||
|
||||
// methodes
|
||||
bool rmdir(const QString &);
|
||||
|
||||
public:
|
||||
ElementsCategoriesList &elementsCategoriesList() const;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ ElementsCategory::ElementsCategory(const QString &path) : QDir(path) {
|
||||
Destructeur
|
||||
*/
|
||||
ElementsCategory::~ElementsCategory() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,20 +7,19 @@
|
||||
qet_directory contenant ses caracteristiques (pour le moment : ses noms).
|
||||
*/
|
||||
class ElementsCategory : public QDir {
|
||||
// Constructeur, destructeur
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementsCategory(const QString & = QString());
|
||||
~ElementsCategory();
|
||||
virtual ~ElementsCategory();
|
||||
|
||||
private:
|
||||
ElementsCategory(const ElementsCategory &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
QHash<QString, QString> category_names;
|
||||
|
||||
// methodes
|
||||
private:
|
||||
bool rmdir(const QString &) const;
|
||||
void loadNames();
|
||||
|
||||
public:
|
||||
QString name() const;
|
||||
QHash<QString, QString> categoryNames() const;
|
||||
@@ -29,5 +28,9 @@ class ElementsCategory : public QDir {
|
||||
bool write() const;
|
||||
bool remove() const;
|
||||
//bool move(const QString &new_parent);
|
||||
|
||||
private:
|
||||
bool rmdir(const QString &) const;
|
||||
void loadNames();
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -9,11 +9,15 @@ class ElementsCategory;
|
||||
class NamesList;
|
||||
class ElementsCategoryEditor : public QDialog {
|
||||
Q_OBJECT
|
||||
//Constructeurs, destructeur
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementsCategoryEditor(QWidget * = 0);
|
||||
ElementsCategoryEditor(const QString &, bool = true, QWidget * = 0);
|
||||
~ElementsCategoryEditor();
|
||||
virtual ~ElementsCategoryEditor();
|
||||
|
||||
private:
|
||||
ElementsCategoryEditor(const ElementsCategoryEditor &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -29,6 +33,5 @@ class ElementsCategoryEditor : public QDialog {
|
||||
public slots:
|
||||
void acceptCreation();
|
||||
void acceptUpdate();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,12 @@ ElementsPanel::ElementsPanel(QWidget *parent) : QTreeWidget(parent) {
|
||||
setPalette(qp);
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
ElementsPanel::~ElementsPanel() {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le mouvement lors d'un drag'n drop
|
||||
*/
|
||||
|
||||
@@ -9,16 +9,24 @@
|
||||
*/
|
||||
class ElementsPanel : public QTreeWidget {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementsPanel(QWidget * = 0);
|
||||
static QString categoryName(QDir &);
|
||||
virtual ~ElementsPanel();
|
||||
|
||||
private:
|
||||
ElementsPanel(const ElementsPanel &);
|
||||
|
||||
// methodes
|
||||
private:
|
||||
void addFile(QTreeWidgetItem *, QString);
|
||||
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
||||
|
||||
public slots:
|
||||
void dragMoveEvent(QDragMoveEvent *);
|
||||
void dropEvent(QDropEvent *);
|
||||
void startDrag(Qt::DropActions);
|
||||
void reload();
|
||||
private:
|
||||
void addFile(QTreeWidgetItem *, QString);
|
||||
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,12 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||
setLayout(vlayout);
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
ElementsPanelWidget::~ElementsPanelWidget() {
|
||||
}
|
||||
|
||||
/**
|
||||
Appelle l'assistant de creation de nouvel element
|
||||
*/
|
||||
|
||||
@@ -10,9 +10,13 @@
|
||||
class ElementsPanelWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementsPanelWidget(QWidget * = 0);
|
||||
virtual ~ElementsPanelWidget();
|
||||
|
||||
private:
|
||||
ElementsPanelWidget(const ElementsPanelWidget &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -21,9 +25,17 @@ class ElementsPanelWidget : public QWidget {
|
||||
|
||||
// methodes
|
||||
public:
|
||||
inline ElementsPanel &elementsPanel() const { return(*elements_panel); }
|
||||
inline ElementsPanel &elementsPanel() const;
|
||||
|
||||
public slots:
|
||||
void newElement();
|
||||
};
|
||||
|
||||
/**
|
||||
@return Le panel d'elements imbrique dans ce widget
|
||||
*/
|
||||
inline ElementsPanel &ElementsPanelWidget::elementsPanel() const {
|
||||
return(*elements_panel);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@ ElementTextItem::ElementTextItem(const QString &text, QGraphicsItem *parent, QGr
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
}
|
||||
|
||||
ElementTextItem::~ElementTextItem() {
|
||||
}
|
||||
|
||||
/**
|
||||
Modifie la position du champ de texte
|
||||
@param pos La nouvelle position du champ de texte
|
||||
@@ -55,7 +58,7 @@ QPointF ElementTextItem::pos() const {
|
||||
valeur a ce champ.
|
||||
@param e L'element XML representant le champ de texte
|
||||
*/
|
||||
void ElementTextItem::fromXml(QDomElement &e) {
|
||||
void ElementTextItem::fromXml(const QDomElement &e) {
|
||||
QPointF _pos = pos();
|
||||
if (e.attribute("x").toDouble() == _pos.x() && e.attribute("y").toDouble() == _pos.y()) {
|
||||
setPlainText(e.attribute("text"));
|
||||
@@ -66,7 +69,7 @@ void ElementTextItem::fromXml(QDomElement &e) {
|
||||
@param document Le document XML a utiliser
|
||||
@return L'element XML representant ce champ de texte
|
||||
*/
|
||||
QDomElement ElementTextItem::toXml(QDomDocument &document) {
|
||||
QDomElement ElementTextItem::toXml(QDomDocument &document) const {
|
||||
QDomElement result = document.createElement("input");
|
||||
result.setAttribute("x", pos().x());
|
||||
result.setAttribute("y", pos().y());
|
||||
|
||||
@@ -8,23 +8,26 @@
|
||||
malgre les rotations de son element parent.
|
||||
*/
|
||||
class ElementTextItem : public QGraphicsTextItem {
|
||||
// constructeurs
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementTextItem(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||
ElementTextItem(const QString &, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||
virtual ~ElementTextItem();
|
||||
|
||||
// attributs
|
||||
public:
|
||||
enum { Type = UserType + 1003 };
|
||||
|
||||
private:
|
||||
bool follow_parent_rotations;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
enum { Type = UserType + 1003 };
|
||||
virtual int type() const { return Type; }
|
||||
bool followParentRotations() const;
|
||||
void setFollowParentRotations(bool);
|
||||
void fromXml(QDomElement &);
|
||||
QDomElement toXml(QDomDocument &);
|
||||
void fromXml(const QDomElement &);
|
||||
QDomElement toXml(QDomDocument &) const;
|
||||
void setPos(const QPointF &);
|
||||
void setPos(qreal, qreal);
|
||||
QPointF pos() const;
|
||||
|
||||
@@ -58,7 +58,6 @@ ExportDialog::ExportDialog(Diagram *dia, QWidget *parent) : QDialog(parent) {
|
||||
Destructeur - ne fait rien
|
||||
*/
|
||||
ExportDialog::~ExportDialog() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,7 +265,7 @@ QImage ExportDialog::generateImage() {
|
||||
|
||||
// genere l'image
|
||||
diagram -> setUseBorder(export_border -> isChecked());
|
||||
diagram -> setAffichageGrille(draw_grid -> isChecked());
|
||||
diagram -> setDisplayGrid(draw_grid -> isChecked());
|
||||
diagram -> border_and_inset.displayBorder(draw_border -> isChecked());
|
||||
diagram -> border_and_inset.displayColumns(draw_columns -> isChecked());
|
||||
diagram -> border_and_inset.displayInset(draw_inset -> isChecked());
|
||||
@@ -287,7 +286,7 @@ QImage ExportDialog::generateImage() {
|
||||
diagram -> border_and_inset.displayBorder(state_drawBorder);
|
||||
diagram -> border_and_inset.displayColumns(state_drawColumns);
|
||||
diagram -> border_and_inset.displayInset(state_drawInset);
|
||||
diagram -> setAffichageGrille(state_drawGrid);
|
||||
diagram -> setDisplayGrid(state_drawGrid);
|
||||
diagram -> setUseBorder(state_useBorder);
|
||||
|
||||
return(image);
|
||||
|
||||
@@ -8,10 +8,16 @@
|
||||
*/
|
||||
class ExportDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ExportDialog(Diagram *, QWidget * = 0);
|
||||
~ExportDialog();
|
||||
virtual ~ExportDialog();
|
||||
|
||||
private:
|
||||
ExportDialog(const ExportDialog &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
// elements graphiques
|
||||
QLineEdit *filename;
|
||||
@@ -41,6 +47,8 @@
|
||||
QString diagram_path;
|
||||
qreal diagram_ratio;
|
||||
|
||||
// methodes
|
||||
private:
|
||||
QWidget *leftPart();
|
||||
QWidget *rightPart();
|
||||
QGroupBox *setupDimensionsGroupBox();
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) {
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
FixedElement::~FixedElement() {
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nombre minimal de bornes que l'element peut avoir
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
#ifndef ELEMENTFIXE_H
|
||||
#define ELEMENTFIXE_H
|
||||
#include "element.h"
|
||||
/**
|
||||
Cette classe represente un element avec un nombre fixe de bornes.
|
||||
*/
|
||||
class FixedElement : public Element {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
FixedElement(QGraphicsItem * = 0, Diagram * = 0);
|
||||
virtual ~FixedElement();
|
||||
|
||||
// methodes
|
||||
public:
|
||||
int nbTerminalsMin() const;
|
||||
int nbTerminalsMax() const;
|
||||
virtual int nbTerminals() const = 0;
|
||||
|
||||
@@ -25,7 +25,6 @@ NamesList::NamesList(QWidget *parent) : QWidget(parent) {
|
||||
Destructeur
|
||||
*/
|
||||
NamesList::~NamesList() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,10 +7,14 @@
|
||||
*/
|
||||
class NamesList : public QWidget {
|
||||
Q_OBJECT
|
||||
//Constructeur, destructeur
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
NamesList(QWidget * = 0);
|
||||
~NamesList();
|
||||
virtual ~NamesList();
|
||||
|
||||
private:
|
||||
NamesList(const NamesList &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -23,6 +27,7 @@ class NamesList : public QWidget {
|
||||
bool checkOneName();
|
||||
QHash<QString, QString> names();
|
||||
void setNames(QHash<QString, QString> &);
|
||||
|
||||
private:
|
||||
void clean();
|
||||
void updateHash();
|
||||
|
||||
@@ -17,10 +17,14 @@ class NamesList;
|
||||
class Diagram;
|
||||
class NewElementWizard : public QDialog {
|
||||
Q_OBJECT
|
||||
// Constructeur, destructeur
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
NewElementWizard(QWidget * = 0, Qt::WindowFlags = 0);
|
||||
~NewElementWizard();
|
||||
virtual ~NewElementWizard();
|
||||
|
||||
private:
|
||||
NewElementWizard(const NewElementWizard &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
|
||||
@@ -88,6 +88,12 @@ QETApp::QETApp(QWidget *parent) : QMainWindow(parent) {
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateActions()));
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
QETApp::~QETApp() {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les evenements relatifs au QSystemTrayIcon
|
||||
@param raison un entier representant l'evenement survenu sur le systray
|
||||
@@ -604,7 +610,7 @@ bool QETApp::fermer() {
|
||||
/**
|
||||
@return Le DiagramView qui a le focus dans l'interface MDI
|
||||
*/
|
||||
DiagramView *QETApp::diagramEnCours() {
|
||||
DiagramView *QETApp::diagramEnCours() const {
|
||||
return(qobject_cast<DiagramView *>(workspace.activeWindow()));
|
||||
}
|
||||
|
||||
|
||||
24
qetapp.h
24
qetapp.h
@@ -12,8 +12,17 @@
|
||||
*/
|
||||
class QETApp : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
QETApp(QWidget * = 0);
|
||||
virtual ~QETApp();
|
||||
|
||||
private:
|
||||
QETApp(const QETApp &);
|
||||
|
||||
// methodes
|
||||
public:
|
||||
void closeEvent(QCloseEvent *);
|
||||
void addDiagramView(DiagramView *);
|
||||
static QString commonElementsDir();
|
||||
@@ -23,6 +32,14 @@
|
||||
static QString realPath(QString &);
|
||||
static QString symbolicPath(QString &);
|
||||
|
||||
protected:
|
||||
void actions();
|
||||
|
||||
private:
|
||||
DiagramView *diagramEnCours() const;
|
||||
void menus();
|
||||
void toolbar();
|
||||
|
||||
public slots:
|
||||
void systray(QSystemTrayIcon::ActivationReason);
|
||||
void systrayReduce();
|
||||
@@ -59,6 +76,7 @@
|
||||
void slot_expand();
|
||||
void slot_shrink();
|
||||
|
||||
// attributs
|
||||
protected:
|
||||
// Actions faisables au travers de menus dans l'application QElectroTech
|
||||
QAction *mode_selection;
|
||||
@@ -105,14 +123,10 @@
|
||||
QAction *f_reorganise;
|
||||
QAction *f_prec;
|
||||
QAction *f_suiv;
|
||||
|
||||
void actions();
|
||||
// menus variables
|
||||
QAction *menu_systray_masquer_restaurer;
|
||||
|
||||
private:
|
||||
QWorkspace workspace;
|
||||
DiagramView *diagramEnCours();
|
||||
QSignalMapper windowMapper;
|
||||
/// Dock pour le Panel d'Appareils
|
||||
QDockWidget *qdw_pa;
|
||||
@@ -127,8 +141,6 @@
|
||||
QSystemTrayIcon *qsti;
|
||||
/// Geometrie de la fenetre principale
|
||||
QByteArray wg;
|
||||
void menus();
|
||||
void toolbar();
|
||||
QToolBar *barre_outils;
|
||||
};
|
||||
#endif
|
||||
|
||||
15
terminal.cpp
15
terminal.cpp
@@ -77,8 +77,12 @@ Terminal::Terminal(qreal pf_x, qreal pf_y, Terminal::Orientation o, Element *e,
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
La destruction de la borne entraine la destruction des conducteurs
|
||||
associes.
|
||||
*/
|
||||
Terminal::~Terminal() {
|
||||
//qDebug() << "Terminal::~Terminal" << (void *)this;
|
||||
foreach(Conducer *c, liste_conducers) delete c;
|
||||
delete br;
|
||||
}
|
||||
|
||||
@@ -139,6 +143,7 @@ bool Terminal::addConducer(Conducer *f) {
|
||||
@param f Conducteur a enlever
|
||||
*/
|
||||
void Terminal::removeConducer(Conducer *f) {
|
||||
//qDebug() << "Terminal::removeConducer" << (void *)this;
|
||||
int index = liste_conducers.indexOf(f);
|
||||
if (index == -1) return;
|
||||
liste_conducers.removeAt(index);
|
||||
@@ -229,9 +234,9 @@ void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
*/
|
||||
void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (Diagram *s = qobject_cast<Diagram *>(scene())) {
|
||||
s -> setDepart(mapToScene(QPointF(amarrage_conducer)));
|
||||
s -> setArrivee(e -> scenePos());
|
||||
s -> poseConducer(true);
|
||||
s -> setConducerStart(mapToScene(QPointF(amarrage_conducer)));
|
||||
s -> setConducerStop(e -> scenePos());
|
||||
s -> setConducer(true);
|
||||
setCursor(Qt::CrossCursor);
|
||||
}
|
||||
}
|
||||
@@ -253,7 +258,7 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
}
|
||||
|
||||
// si la scene est un Diagram, on actualise le poseur de conducteur
|
||||
if (Diagram *s = qobject_cast<Diagram *>(scene())) s -> setArrivee(e -> scenePos());
|
||||
if (Diagram *s = qobject_cast<Diagram *>(scene())) s -> setConducerStop(e -> scenePos());
|
||||
|
||||
// on recupere la liste des qgi sous le pointeur
|
||||
QList<QGraphicsItem *> qgis = scene() -> items(e -> scenePos());
|
||||
@@ -315,7 +320,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
// verifie que la scene est bien un Diagram
|
||||
if (Diagram *s = qobject_cast<Diagram *>(scene())) {
|
||||
// on arrete de dessiner l'apercu du conducteur
|
||||
s -> poseConducer(false);
|
||||
s -> setConducer(false);
|
||||
// on recupere l'element sous le pointeur lors du MouseReleaseEvent
|
||||
QGraphicsItem *qgi = s -> itemAt(e -> scenePos());
|
||||
// s'il n'y a rien, on arrete la
|
||||
|
||||
25
terminal.h
25
terminal.h
@@ -4,28 +4,29 @@
|
||||
#include <QtGui>
|
||||
#include <QtXml>
|
||||
class Conducer;
|
||||
class Element;
|
||||
class Diagram;
|
||||
class Element;
|
||||
/**
|
||||
Classe modelisant la « borne » d'un appareil, c'est-a-dire un
|
||||
branchement possible pour un Conducteur.
|
||||
*/
|
||||
class Terminal : public QGraphicsItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
// enum definissant l'orientation de la borne
|
||||
enum Orientation {Nord, Est, Sud, Ouest};
|
||||
|
||||
// permet de caster un QGraphicsItem en Borne avec qgraphicsitem_cast
|
||||
enum { Type = UserType + 1002 };
|
||||
virtual int type() const { return Type; }
|
||||
|
||||
// constructeurs
|
||||
Terminal();
|
||||
Terminal(QPointF, Terminal::Orientation, Element * = 0, Diagram * = 0);
|
||||
Terminal(qreal, qreal, Terminal::Orientation, Element * = 0, Diagram * = 0);
|
||||
virtual ~Terminal();
|
||||
|
||||
// destructeur
|
||||
~Terminal();
|
||||
private:
|
||||
Terminal(const Terminal &);
|
||||
|
||||
// methodes
|
||||
public:
|
||||
// permet de caster un QGraphicsItem en Borne avec qgraphicsitem_cast
|
||||
virtual int type() const { return Type; }
|
||||
|
||||
// implementation des methodes virtuelles pures de QGraphicsItem
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
@@ -56,6 +57,10 @@ class Terminal : public QGraphicsItem {
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
|
||||
// attributs
|
||||
public:
|
||||
enum { Type = UserType + 1002 };
|
||||
|
||||
private:
|
||||
// pointeur vers la QGraphicsScene de type Diagram (evite quelques casts en interne)
|
||||
Diagram *diagram_scene;
|
||||
|
||||
Reference in New Issue
Block a user