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);
|
setLayout(disposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
AboutQET::~AboutQET() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le titre QElectroTech avec son icone
|
@return Le titre QElectroTech avec son icone
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +64,7 @@ QWidget *AboutQET::ongletAPropos() const {
|
|||||||
QLabel *apropos = new QLabel(
|
QLabel *apropos = new QLabel(
|
||||||
tr("QElectroTech, une application de r\351alisation de sch\351mas \351lectriques.") +
|
tr("QElectroTech, une application de r\351alisation de sch\351mas \351lectriques.") +
|
||||||
"<br><br>" +
|
"<br><br>" +
|
||||||
tr("\251 2006 Les d\351veloppeurs de QElectroTech") +
|
tr("\251 2006-2007 Les d\351veloppeurs de QElectroTech") +
|
||||||
"<br><br>"
|
"<br><br>"
|
||||||
"<a href=\"http://qelectrotech.tuxfamily.org/\">"
|
"<a href=\"http://qelectrotech.tuxfamily.org/\">"
|
||||||
"http://qelectrotech.tuxfamily.org/</a>"
|
"http://qelectrotech.tuxfamily.org/</a>"
|
||||||
|
|||||||
20
aboutqet.h
20
aboutqet.h
@@ -1,18 +1,26 @@
|
|||||||
#ifndef ABOUTQET_H
|
#ifndef ABOUTQET_H
|
||||||
#define ABOUTQET_H
|
#define ABOUTQET_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
Cette classe represente la boite de dialogue
|
Cette classe represente la boite de dialogue
|
||||||
« A propos de QElectroTech »
|
« A propos de QElectroTech »
|
||||||
*/
|
*/
|
||||||
class AboutQET : public QDialog {
|
class AboutQET : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
AboutQET(QWidget * = 0);
|
AboutQET(QWidget * = 0);
|
||||||
|
virtual ~AboutQET();
|
||||||
|
|
||||||
|
private:
|
||||||
|
AboutQET(AboutQET &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
private:
|
private:
|
||||||
QWidget *titre() const;
|
QWidget *titre() const;
|
||||||
QWidget *ongletAPropos() const;
|
QWidget *ongletAPropos() const;
|
||||||
QWidget *ongletAuteurs() const;
|
QWidget *ongletAuteurs() const;
|
||||||
QWidget *ongletLicence() const;
|
QWidget *ongletLicence() const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,18 +1,26 @@
|
|||||||
#ifndef BORDERINSET_H
|
#ifndef BORDERINSET_H
|
||||||
#define BORDERINSET_H
|
#define BORDERINSET_H
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
/**
|
/**
|
||||||
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
||||||
schema electrique.
|
schema electrique.
|
||||||
*/
|
*/
|
||||||
class BorderInset : public QObject {
|
class BorderInset : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
BorderInset(QObject * = 0);
|
BorderInset(QObject * = 0);
|
||||||
~BorderInset();
|
virtual ~BorderInset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BorderInset(const BorderInset &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
||||||
|
|
||||||
// methodes d'acces en lecture aux dimensions
|
// methodes d'acces en lecture aux dimensions
|
||||||
@@ -61,6 +69,10 @@
|
|||||||
void displayColumns (bool dc) { display_columns = dc; }
|
void displayColumns (bool dc) { display_columns = dc; }
|
||||||
void displayBorder (bool db) { display_border = db; }
|
void displayBorder (bool db) { display_border = db; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateRectangles();
|
||||||
|
|
||||||
|
// attributs
|
||||||
private:
|
private:
|
||||||
// informations du cartouche
|
// informations du cartouche
|
||||||
QString bi_author;
|
QString bi_author;
|
||||||
@@ -92,7 +104,5 @@
|
|||||||
bool display_inset;
|
bool display_inset;
|
||||||
bool display_columns;
|
bool display_columns;
|
||||||
bool display_border;
|
bool display_border;
|
||||||
|
};
|
||||||
void updateRectangles();
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
19
conducer.cpp
19
conducer.cpp
@@ -51,6 +51,21 @@ Conducer::Conducer(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *
|
|||||||
calculateTextItemPosition();
|
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.
|
Met a jour la representation graphique du conducteur.
|
||||||
@param rect Rectangle a mettre a jour
|
@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.
|
@return Le nombre de segments composant le conducteur.
|
||||||
*/
|
*/
|
||||||
int Conducer::nbSegments() {
|
int Conducer::nbSegments() const {
|
||||||
if (segments == NULL) return(0);
|
if (segments == NULL) return(0);
|
||||||
int nb_seg = 1;
|
int nb_seg = 1;
|
||||||
ConducerSegment *segment = segments;
|
ConducerSegment *segment = segments;
|
||||||
@@ -701,7 +716,7 @@ void Conducer::pointsToSegments(QList<QPointF> points_list) {
|
|||||||
@param point point cliquable
|
@param point point cliquable
|
||||||
@return true si l'on peut considerer que le point a ete clique, false sinon
|
@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 (
|
return (
|
||||||
press_point.x() >= point.x() - 5.0 &&\
|
press_point.x() >= point.x() - 5.0 &&\
|
||||||
press_point.x() < point.x() + 5.0 &&\
|
press_point.x() < point.x() + 5.0 &&\
|
||||||
|
|||||||
79
conducer.h
79
conducer.h
@@ -1,43 +1,30 @@
|
|||||||
#ifndef CONDUCTEUR_H
|
#ifndef CONDUCTEUR_H
|
||||||
#define CONDUCTEUR_H
|
#define CONDUCTEUR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
class ConducerSegment;
|
class ConducerSegment;
|
||||||
class Element;
|
class Element;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
||||||
*/
|
*/
|
||||||
class Conducer : public QGraphicsPathItem {
|
class Conducer : public QGraphicsPathItem {
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
Conducer(Terminal *, Terminal *, Element * = 0, QGraphicsScene * = 0);
|
||||||
|
virtual ~Conducer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Conducer(const Conducer &);
|
||||||
|
|
||||||
|
// attributs
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1001 };
|
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
|
///Premiere borne a laquelle le fil est rattache
|
||||||
Terminal *terminal1;
|
Terminal *terminal1;
|
||||||
///Deuxieme borne a laquelle le fil est rattache
|
///Deuxieme borne a laquelle le fil est rattache
|
||||||
Terminal *terminal2;
|
Terminal *terminal2;
|
||||||
|
|
||||||
protected:
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// booleen indiquant si le fil est encore valide
|
/// booleen indiquant si le fil est encore valide
|
||||||
bool destroyed;
|
bool destroyed;
|
||||||
@@ -59,15 +46,37 @@
|
|||||||
static QBrush conducer_brush;
|
static QBrush conducer_brush;
|
||||||
static bool pen_and_brush_initialized;
|
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 segmentsToPath();
|
||||||
void updatePoints();
|
void updatePoints();
|
||||||
void priv_calculeConducer(const QPointF &, Terminal::Orientation, const QPointF &, Terminal::Orientation);
|
void priv_calculeConducer(const QPointF &, Terminal::Orientation, const QPointF &, Terminal::Orientation);
|
||||||
void priv_modifieConducer(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;
|
QList<QPointF> segmentsToPoints() const;
|
||||||
void pointsToSegments(QList<QPointF>);
|
void pointsToSegments(QList<QPointF>);
|
||||||
bool hasClickedOn(QPointF, QPointF);
|
bool hasClickedOn(QPointF, QPointF) const;
|
||||||
void calculateTextItemPosition();
|
void calculateTextItemPosition();
|
||||||
static QPointF extendTerminal(const QPointF &, Terminal::Orientation, qreal = 12.0);
|
static QPointF extendTerminal(const QPointF &, Terminal::Orientation, qreal = 12.0);
|
||||||
static bool surLeMemeAxe(Terminal::Orientation, Terminal::Orientation);
|
static bool surLeMemeAxe(Terminal::Orientation, Terminal::Orientation);
|
||||||
@@ -75,5 +84,5 @@
|
|||||||
static bool estVerticale(Terminal::Orientation a);
|
static bool estVerticale(Terminal::Orientation a);
|
||||||
static qreal conducer_bound(qreal tobound, qreal bound1, qreal bound2);
|
static qreal conducer_bound(qreal tobound, qreal bound1, qreal bound2);
|
||||||
static qreal conducer_bound(qreal tobound, qreal bound, bool positive);
|
static qreal conducer_bound(qreal tobound, qreal bound, bool positive);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,9 +8,15 @@
|
|||||||
@param cs1 Le segment precedent
|
@param cs1 Le segment precedent
|
||||||
@param cs2 Le segment suivant
|
@param cs2 Le segment suivant
|
||||||
*/
|
*/
|
||||||
ConducerSegment::ConducerSegment(QPointF p1, QPointF p2, ConducerSegment *cs1, ConducerSegment *cs2) {
|
ConducerSegment::ConducerSegment(
|
||||||
setFirstPoint(p1);
|
const QPointF &p1,
|
||||||
setSecondPoint(p2);
|
const QPointF &p2,
|
||||||
|
ConducerSegment *cs1,
|
||||||
|
ConducerSegment *cs2
|
||||||
|
) :
|
||||||
|
point1(p1),
|
||||||
|
point2(p2)
|
||||||
|
{
|
||||||
setPreviousSegment(cs1);
|
setPreviousSegment(cs1);
|
||||||
setNextSegment(cs2);
|
setNextSegment(cs2);
|
||||||
}
|
}
|
||||||
@@ -19,6 +25,7 @@ ConducerSegment::ConducerSegment(QPointF p1, QPointF p2, ConducerSegment *cs1, C
|
|||||||
Destructeur - Relie le segment precedent au suivant
|
Destructeur - Relie le segment precedent au suivant
|
||||||
*/
|
*/
|
||||||
ConducerSegment::~ConducerSegment() {
|
ConducerSegment::~ConducerSegment() {
|
||||||
|
//qDebug() << "~ConducerSegment()" << (void *)this;
|
||||||
if (hasPreviousSegment()) previousSegment() -> setNextSegment(nextSegment());
|
if (hasPreviousSegment()) previousSegment() -> setNextSegment(nextSegment());
|
||||||
if (hasNextSegment()) nextSegment() -> setPreviousSegment(previousSegment());
|
if (hasNextSegment()) nextSegment() -> setPreviousSegment(previousSegment());
|
||||||
}
|
}
|
||||||
@@ -32,7 +39,7 @@ ConducerSegment::~ConducerSegment() {
|
|||||||
@param possible_dx La valeur du mouvement possible (au maximum)
|
@param possible_dx La valeur du mouvement possible (au maximum)
|
||||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
@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");
|
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)
|
@param possible_dx La valeur du mouvement possible (au maximum)
|
||||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
@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");
|
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)
|
@param possible_dy La valeur du mouvement possible (au maximum)
|
||||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
@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");
|
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)
|
@param possible_dy La valeur du mouvement possible (au maximum)
|
||||||
@return true si le mouvement est possible ; false s'il doit etre limite
|
@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");
|
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
|
Gere les mouvements sur l'axe horizontal
|
||||||
@param dx taille du deplacement en pixels
|
@param dx taille du deplacement en pixels
|
||||||
*/
|
*/
|
||||||
void ConducerSegment::moveX(qreal dx) {
|
void ConducerSegment::moveX(const qreal &dx) {
|
||||||
if (isHorizontal()) return;
|
if (isHorizontal()) return;
|
||||||
Q_ASSERT_X(isVertical(), "ConducerSegment::moveX", "segment non vertical");
|
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
|
Gere les mouvements sur l'axe vertical
|
||||||
@param dx taille du deplacement en pixels
|
@param dx taille du deplacement en pixels
|
||||||
*/
|
*/
|
||||||
void ConducerSegment::moveY(qreal dy) {
|
void ConducerSegment::moveY(const qreal &dy) {
|
||||||
if (isVertical()) return;
|
if (isVertical()) return;
|
||||||
Q_ASSERT_X(isHorizontal(), "ConducerSegment::moveY", "segment non horizontal");
|
Q_ASSERT_X(isHorizontal(), "ConducerSegment::moveY", "segment non horizontal");
|
||||||
|
|
||||||
@@ -449,42 +456,42 @@ void ConducerSegment::setNextSegment(ConducerSegment *ns) {
|
|||||||
/**
|
/**
|
||||||
@return Le segment precedent
|
@return Le segment precedent
|
||||||
*/
|
*/
|
||||||
ConducerSegment *ConducerSegment::previousSegment() {
|
ConducerSegment *ConducerSegment::previousSegment() const {
|
||||||
return(previous_segment);
|
return(previous_segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le segment suivant
|
@return Le segment suivant
|
||||||
*/
|
*/
|
||||||
ConducerSegment *ConducerSegment::nextSegment() {
|
ConducerSegment *ConducerSegment::nextSegment() const {
|
||||||
return(next_segment);
|
return(next_segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si le segment est vertical, false sinon
|
@return true si le segment est vertical, false sinon
|
||||||
*/
|
*/
|
||||||
bool ConducerSegment::isVertical() {
|
bool ConducerSegment::isVertical() const {
|
||||||
return(point1.x() == point2.x());
|
return(point1.x() == point2.x());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si le segment est horizontal, false sinon
|
@return true si le segment est horizontal, false sinon
|
||||||
*/
|
*/
|
||||||
bool ConducerSegment::isHorizontal() {
|
bool ConducerSegment::isHorizontal() const {
|
||||||
return(point1.y() == point2.y());
|
return(point1.y() == point2.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le premier point du segment
|
@return le premier point du segment
|
||||||
*/
|
*/
|
||||||
QPointF ConducerSegment::firstPoint() {
|
QPointF ConducerSegment::firstPoint() const {
|
||||||
return(point1);
|
return(point1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le second point du segment
|
@return le second point du segment
|
||||||
*/
|
*/
|
||||||
QPointF ConducerSegment::secondPoint() {
|
QPointF ConducerSegment::secondPoint() const {
|
||||||
return(point2);
|
return(point2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +499,7 @@ QPointF ConducerSegment::secondPoint() {
|
|||||||
Permet de changer la position du premier point du segment
|
Permet de changer la position du premier point du segment
|
||||||
@param p La nouvelle position du premier point
|
@param p La nouvelle position du premier point
|
||||||
*/
|
*/
|
||||||
void ConducerSegment::setFirstPoint(QPointF p) {
|
void ConducerSegment::setFirstPoint(const QPointF &p) {
|
||||||
point1 = p;
|
point1 = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,28 +507,28 @@ void ConducerSegment::setFirstPoint(QPointF p) {
|
|||||||
Permet de changer la position du second point du segment
|
Permet de changer la position du second point du segment
|
||||||
@param p La nouvelle position du second point
|
@param p La nouvelle position du second point
|
||||||
*/
|
*/
|
||||||
void ConducerSegment::setSecondPoint(QPointF p) {
|
void ConducerSegment::setSecondPoint(const QPointF &p) {
|
||||||
point2 = p;
|
point2 = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si le segment a un segment precedent, false sinon
|
@return true si le segment a un segment precedent, false sinon
|
||||||
*/
|
*/
|
||||||
bool ConducerSegment::hasPreviousSegment() {
|
bool ConducerSegment::hasPreviousSegment() const {
|
||||||
return(previous_segment != NULL);
|
return(previous_segment != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si le segment a un segment suivant, false sinon
|
@return true si le segment a un segment suivant, false sinon
|
||||||
*/
|
*/
|
||||||
bool ConducerSegment::hasNextSegment() {
|
bool ConducerSegment::hasNextSegment() const {
|
||||||
return(next_segment != NULL);
|
return(next_segment != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le centre du rectangle delimitant le conducteur
|
@return Le centre du rectangle delimitant le conducteur
|
||||||
*/
|
*/
|
||||||
QPointF ConducerSegment::middle() {
|
QPointF ConducerSegment::middle() const {
|
||||||
return(
|
return(
|
||||||
QPointF(
|
QPointF(
|
||||||
(point1.x() + point2.x()) / 2.0,
|
(point1.x() + point2.x()) / 2.0,
|
||||||
@@ -533,7 +540,7 @@ QPointF ConducerSegment::middle() {
|
|||||||
/**
|
/**
|
||||||
@return La longueur du conducteur
|
@return La longueur du conducteur
|
||||||
*/
|
*/
|
||||||
qreal ConducerSegment::length() {
|
qreal ConducerSegment::length() const {
|
||||||
if (isHorizontal()) {
|
if (isHorizontal()) {
|
||||||
return(secondPoint().x() - firstPoint().x());
|
return(secondPoint().x() - firstPoint().x());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
#ifndef CONDUCER_SEGMENT_H
|
#ifndef CONDUCER_SEGMENT_H
|
||||||
#define CONDUCER_SEGMENT_H
|
#define CONDUCER_SEGMENT_H
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
/**
|
/**
|
||||||
Cette classe represente un segment de conducteur.
|
Cette classe represente un segment de conducteur.
|
||||||
*/
|
*/
|
||||||
class ConducerSegment {
|
class ConducerSegment {
|
||||||
// constructeurs et destructeur
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ConducerSegment(QPointF, QPointF, ConducerSegment * = NULL, ConducerSegment * = NULL);
|
ConducerSegment(const QPointF &, const QPointF &, ConducerSegment * = NULL, ConducerSegment * = NULL);
|
||||||
~ConducerSegment();
|
virtual ~ConducerSegment();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ConducerSegment(const ConducerSegment &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -19,25 +23,25 @@
|
|||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
void moveX(qreal);
|
void moveX(const qreal &);
|
||||||
void moveY(qreal);
|
void moveY(const qreal &);
|
||||||
ConducerSegment *previousSegment();
|
ConducerSegment *previousSegment() const;
|
||||||
ConducerSegment *nextSegment();
|
ConducerSegment *nextSegment() const;
|
||||||
bool hasPreviousSegment();
|
bool hasPreviousSegment() const;
|
||||||
bool hasNextSegment();
|
bool hasNextSegment() const;
|
||||||
void setPreviousSegment(ConducerSegment *);
|
void setPreviousSegment(ConducerSegment *);
|
||||||
void setNextSegment(ConducerSegment *);
|
void setNextSegment(ConducerSegment *);
|
||||||
QPointF firstPoint();
|
QPointF firstPoint() const;
|
||||||
QPointF secondPoint();
|
QPointF secondPoint() const;
|
||||||
void setFirstPoint(QPointF);
|
void setFirstPoint(const QPointF &);
|
||||||
void setSecondPoint(QPointF);
|
void setSecondPoint(const QPointF &);
|
||||||
QPointF middle();
|
QPointF middle() const;
|
||||||
bool isHorizontal();
|
bool isHorizontal() const;
|
||||||
bool isVertical();
|
bool isVertical() const;
|
||||||
qreal length();
|
qreal length() const;
|
||||||
bool canMove1stPointX(qreal, qreal &);
|
bool canMove1stPointX(const qreal &, qreal &) const;
|
||||||
bool canMove2ndPointX(qreal, qreal &);
|
bool canMove2ndPointX(const qreal &, qreal &) const;
|
||||||
bool canMove1stPointY(qreal, qreal &);
|
bool canMove1stPointY(const qreal &, qreal &) const;
|
||||||
bool canMove2ndPointY(qreal, qreal &);
|
bool canMove2ndPointY(const qreal &, qreal &) const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -156,6 +156,12 @@ CustomElement::CustomElement(QString &nom_fichier, QGraphicsItem *qgi, Diagram *
|
|||||||
elmt_etat = 0;
|
elmt_etat = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
CustomElement::~CustomElement() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le nombre de bornes que l'element possede
|
@return Le nombre de bornes que l'element possede
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,29 +1,41 @@
|
|||||||
#ifndef ELEMENTPERSO_H
|
#ifndef ELEMENTPERSO_H
|
||||||
#define ELEMENTPERSO_H
|
#define ELEMENTPERSO_H
|
||||||
#include "fixedelement.h"
|
#include "fixedelement.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
Cette classe represente un element electrique. Elle est utilisable
|
Cette classe represente un element electrique. Elle est utilisable
|
||||||
comme un element fixe. La difference est que l'element perso lit
|
comme un element fixe. La difference est que l'element perso lit
|
||||||
sa description (noms, dessin, comportement) dans un fichier XML a fournir
|
sa description (noms, dessin, comportement) dans un fichier XML a fournir
|
||||||
en parametre.
|
en parametre.
|
||||||
*/
|
*/
|
||||||
class CustomElement : public FixedElement {
|
class CustomElement : public FixedElement {
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
CustomElement(QString &, QGraphicsItem * = 0, Diagram * = 0, int * = NULL);
|
CustomElement(QString &, QGraphicsItem * = 0, Diagram * = 0, int * = NULL);
|
||||||
virtual int nbTerminals() const;
|
virtual ~CustomElement();
|
||||||
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); }
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
CustomElement(const CustomElement &);
|
||||||
|
|
||||||
|
// attributs
|
||||||
private:
|
private:
|
||||||
int elmt_etat; // contient le code d'erreur si l'instanciation a echoue ou 0 si l'instanciation s'est bien passe
|
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 priv_nom;
|
||||||
QString nomfichier;
|
QString nomfichier;
|
||||||
QPicture dessin;
|
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 parseElement(QDomElement &, QPainter &, Diagram *);
|
||||||
bool parseLine(QDomElement &, QPainter &);
|
bool parseLine(QDomElement &, QPainter &);
|
||||||
bool parseEllipse(QDomElement &, QPainter &);
|
bool parseEllipse(QDomElement &, QPainter &);
|
||||||
@@ -38,6 +50,53 @@
|
|||||||
bool attributeIsAReal(QDomElement &, QString, double * = NULL);
|
bool attributeIsAReal(QDomElement &, QString, double * = NULL);
|
||||||
bool validOrientationAttribute(QDomElement &);
|
bool validOrientationAttribute(QDomElement &);
|
||||||
void setPainterStyle(QDomElement &, QPainter &);
|
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
|
#endif
|
||||||
|
|||||||
16
diagram.cpp
16
diagram.cpp
@@ -10,19 +10,25 @@
|
|||||||
*/
|
*/
|
||||||
Diagram::Diagram(QObject *parent) : QGraphicsScene(parent) {
|
Diagram::Diagram(QObject *parent) : QGraphicsScene(parent) {
|
||||||
setBackgroundBrush(Qt::white);
|
setBackgroundBrush(Qt::white);
|
||||||
poseur_de_conducer = new QGraphicsLineItem(0, 0);
|
conducer_setter = new QGraphicsLineItem(0, 0);
|
||||||
poseur_de_conducer -> setZValue(1000000);
|
conducer_setter -> setZValue(1000000);
|
||||||
QPen t;
|
QPen t;
|
||||||
t.setColor(Qt::black);
|
t.setColor(Qt::black);
|
||||||
t.setWidthF(1.5);
|
t.setWidthF(1.5);
|
||||||
t.setStyle(Qt::DashLine);
|
t.setStyle(Qt::DashLine);
|
||||||
poseur_de_conducer -> setPen(t);
|
conducer_setter -> setPen(t);
|
||||||
poseur_de_conducer -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
conducer_setter -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
||||||
draw_grid = true;
|
draw_grid = true;
|
||||||
use_border = true;
|
use_border = true;
|
||||||
connect(this, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(slot_checkSelectionEmptinessChange()));
|
connect(this, SIGNAL(changed(const QList<QRectF> &)), this, SLOT(slot_checkSelectionEmptinessChange()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
Diagram::~Diagram() {
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine l'arriere-plan du schema, cad la grille.
|
Dessine l'arriere-plan du schema, cad la grille.
|
||||||
@param p Le QPainter a utiliser pour dessiner
|
@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 -> setBrush(Qt::white);
|
||||||
p -> drawRect(r);
|
p -> drawRect(r);
|
||||||
|
|
||||||
if (draw_grid) {
|
if (draw_grid && r.width() < 2500 && r.height() < 2500) {
|
||||||
// dessine les points de la grille
|
// dessine les points de la grille
|
||||||
p -> setPen(Qt::black);
|
p -> setPen(Qt::black);
|
||||||
p -> setBrush(Qt::NoBrush);
|
p -> setBrush(Qt::NoBrush);
|
||||||
|
|||||||
52
diagram.h
52
diagram.h
@@ -11,38 +11,50 @@ class Element;
|
|||||||
class Terminal;
|
class Terminal;
|
||||||
class Diagram : public QGraphicsScene {
|
class Diagram : public QGraphicsScene {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
enum BorderOptions { EmptyBorder, Inset, Columns };
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
Diagram(QObject * = 0);
|
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 &);
|
void drawBackground(QPainter *, const QRectF &);
|
||||||
|
|
||||||
// fonctions relatives a la pose de conducteurs
|
// fonctions relatives a la pose de conducteurs
|
||||||
void poseConducer(bool);
|
void setConducer(bool);
|
||||||
|
void setConducerStart (QPointF);
|
||||||
void setDepart (QPointF);
|
void setConducerStop(QPointF);
|
||||||
void setArrivee(QPointF);
|
|
||||||
|
|
||||||
// fonctions relatives a l'import / export XML
|
// fonctions relatives a l'import / export XML
|
||||||
QDomDocument toXml(bool = true);
|
QDomDocument toXml(bool = true);
|
||||||
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true);
|
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true);
|
||||||
|
|
||||||
// fonctions relatives aux options graphiques
|
// fonctions relatives aux options graphiques
|
||||||
void setAffichageGrille(bool);
|
void setDisplayGrid(bool);
|
||||||
bool displayGrid();
|
bool displayGrid();
|
||||||
void setUseBorder(bool);
|
void setUseBorder(bool);
|
||||||
bool useBorder();
|
bool useBorder();
|
||||||
void setBorderOptions(BorderOptions);
|
void setBorderOptions(BorderOptions);
|
||||||
BorderOptions borderOptions();
|
BorderOptions borderOptions();
|
||||||
BorderInset border_and_inset;
|
|
||||||
QRectF border() const;
|
QRectF border() const;
|
||||||
QImage toImage(int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
QImage toImage(int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
||||||
QSize imageSize() const;
|
QSize imageSize() const;
|
||||||
|
|
||||||
private:
|
|
||||||
QGraphicsLineItem *poseur_de_conducer;
|
|
||||||
bool draw_grid;
|
|
||||||
bool use_border;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slot_checkSelectionChange();
|
void slot_checkSelectionChange();
|
||||||
void slot_checkSelectionEmptinessChange();
|
void slot_checkSelectionEmptinessChange();
|
||||||
@@ -58,11 +70,11 @@ class Diagram : public QGraphicsScene {
|
|||||||
bornes.
|
bornes.
|
||||||
@param true pour ajouter le poseur de conducteur, false pour l'enlever
|
@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 (pf) {
|
||||||
if (!poseur_de_conducer -> scene()) addItem(poseur_de_conducer);
|
if (!conducer_setter -> scene()) addItem(conducer_setter);
|
||||||
} else {
|
} 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
|
Specifie les coordonnees du point de depart du poseur de conducteur
|
||||||
@param d Le nouveau point de depart du poseur de conducteur
|
@param d Le nouveau point de depart du poseur de conducteur
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setDepart(QPointF d) {
|
inline void Diagram::setConducerStart(QPointF d) {
|
||||||
poseur_de_conducer -> setLine(QLineF(d, poseur_de_conducer -> line().p2()));
|
conducer_setter -> setLine(QLineF(d, conducer_setter -> line().p2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Specifie les coordonnees du point d'arrivee du poseur de conducteur
|
Specifie les coordonnees du point d'arrivee du poseur de conducteur
|
||||||
@param d Le nouveau point d'arrivee du poseur de conducteur
|
@param d Le nouveau point d'arrivee du poseur de conducteur
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setArrivee(QPointF a) {
|
inline void Diagram::setConducerStop(QPointF a) {
|
||||||
poseur_de_conducer -> setLine(QLineF(poseur_de_conducer -> line().p1(), a));
|
conducer_setter -> setLine(QLineF(conducer_setter -> line().p1(), a));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de specifier si la grille du schema doit etre dessinee ou non
|
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
|
@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;
|
draw_grid = dg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
|
#include "conducer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialise le DiagramView
|
Initialise le DiagramView
|
||||||
@@ -40,6 +41,12 @@ DiagramView::DiagramView(QWidget *parent) : QGraphicsView(parent) {
|
|||||||
initialise();
|
initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
DiagramView::~DiagramView() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
appelle la methode select sur tous les elements de la liste d'elements
|
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) {
|
if (qpd.exec() == QDialog::Accepted) {
|
||||||
QPainter qp(&qprin);
|
QPainter qp(&qprin);
|
||||||
scene -> setAffichageGrille(false);
|
scene -> setDisplayGrid(false);
|
||||||
scene -> render(&qp);
|
scene -> render(&qp);
|
||||||
scene -> setAffichageGrille(true);
|
scene -> setDisplayGrid(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,29 @@
|
|||||||
#ifndef DIAGRAMVIEW_H
|
#ifndef DIAGRAMVIEW_H
|
||||||
#define DIAGRAMVIEW_H
|
#define DIAGRAMVIEW_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
class Diagram;
|
class Diagram;
|
||||||
#include "element.h"
|
/**
|
||||||
#include "conducer.h"
|
|
||||||
/**
|
|
||||||
Classe representant graphiquement un schema electrique
|
Classe representant graphiquement un schema electrique
|
||||||
*/
|
*/
|
||||||
class DiagramView : public QGraphicsView {
|
class DiagramView : public QGraphicsView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
// constructeurs
|
|
||||||
DiagramView();
|
DiagramView();
|
||||||
DiagramView(QWidget * = 0);
|
DiagramView(QWidget * = 0);
|
||||||
|
virtual ~DiagramView();
|
||||||
|
|
||||||
// nouveaux attributs
|
private:
|
||||||
|
DiagramView(const DiagramView &);
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
private:
|
||||||
Diagram *scene;
|
Diagram *scene;
|
||||||
|
QList<QGraphicsItem *> garbage;
|
||||||
|
|
||||||
// methodes publiques
|
// methodes
|
||||||
|
public:
|
||||||
bool ouvrir(QString, int * = NULL);
|
bool ouvrir(QString, int * = NULL);
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
QString nom_fichier;
|
QString nom_fichier;
|
||||||
@@ -38,8 +44,6 @@
|
|||||||
private:
|
private:
|
||||||
bool private_enregistrer(QString &);
|
bool private_enregistrer(QString &);
|
||||||
void initialise();
|
void initialise();
|
||||||
QList<QGraphicsItem *> garbage;
|
|
||||||
|
|
||||||
void throwToGarbage(QGraphicsItem *);
|
void throwToGarbage(QGraphicsItem *);
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
void dragEnterEvent(QDragEnterEvent *);
|
void dragEnterEvent(QDragEnterEvent *);
|
||||||
@@ -71,5 +75,5 @@
|
|||||||
private slots:
|
private slots:
|
||||||
void flushGarbage();
|
void flushGarbage();
|
||||||
void slot_selectionChanged();
|
void slot_selectionChanged();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
12
element.cpp
12
element.cpp
@@ -3,8 +3,6 @@
|
|||||||
#include "elementtextitem.h"
|
#include "elementtextitem.h"
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
/*** Methodes publiques ***/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur pour un element sans scene ni parent
|
Constructeur pour un element sans scene ni parent
|
||||||
*/
|
*/
|
||||||
@@ -13,6 +11,12 @@ Element::Element(QGraphicsItem *parent, Diagram *scene) : QGraphicsItem(parent,
|
|||||||
setZValue(10);
|
setZValue(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
Element::~Element() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Methode principale de dessin de l'element
|
Methode principale de dessin de l'element
|
||||||
@param painter Le QPainter utilise pour dessiner l'elment
|
@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()) {
|
foreach(QGraphicsItem *qgi, children()) {
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConducer(value.toPointF());
|
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));
|
return(QGraphicsItem::itemChange(change, value));
|
||||||
}
|
}
|
||||||
|
|||||||
107
element.h
107
element.h
@@ -7,45 +7,20 @@
|
|||||||
*/
|
*/
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class Element : public QGraphicsItem {
|
class Element : public QGraphicsItem {
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
Element(QGraphicsItem * = 0, Diagram * = 0);
|
||||||
|
virtual ~Element();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Element(const Element &);
|
||||||
|
|
||||||
|
// attributs
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1000 };
|
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:
|
protected:
|
||||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
|
||||||
bool ori_n;
|
bool ori_n;
|
||||||
bool ori_s;
|
bool ori_s;
|
||||||
bool ori_e;
|
bool ori_e;
|
||||||
@@ -53,6 +28,63 @@ class Element : public QGraphicsItem {
|
|||||||
Terminal::Orientation ori_d;
|
Terminal::Orientation ori_d;
|
||||||
Terminal::Orientation ori;
|
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:
|
private:
|
||||||
bool peut_relier_ses_propres_terminals;
|
bool peut_relier_ses_propres_terminals;
|
||||||
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
@@ -60,11 +92,6 @@ class Element : public QGraphicsItem {
|
|||||||
Terminal::Orientation nextOrientation(Terminal::Orientation o) const;
|
Terminal::Orientation nextOrientation(Terminal::Orientation o) const;
|
||||||
Terminal::Orientation previousOrientation(Terminal::Orientation o) const;
|
Terminal::Orientation previousOrientation(Terminal::Orientation o) const;
|
||||||
static QList<QDomElement> findInDomElement(QDomElement, QString, QString);
|
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
|
Destructeur
|
||||||
*/
|
*/
|
||||||
ElementsCategoriesList::~ElementsCategoriesList() {
|
ElementsCategoriesList::~ElementsCategoriesList() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,23 +7,24 @@
|
|||||||
*/
|
*/
|
||||||
class ElementsCategoriesList : public QTreeWidget {
|
class ElementsCategoriesList : public QTreeWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeur, destructeur
|
|
||||||
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementsCategoriesList(QWidget * = 0);
|
ElementsCategoriesList(QWidget * = 0);
|
||||||
~ElementsCategoriesList();
|
virtual ~ElementsCategoriesList();
|
||||||
|
|
||||||
// attributs
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElementsCategoriesList(const ElementsCategoriesList &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
private:
|
|
||||||
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
|
||||||
QString categoryName(QDir &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString selectedCategoryPath();
|
QString selectedCategoryPath();
|
||||||
QString selectedCategoryName();
|
QString selectedCategoryName();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
||||||
|
QString categoryName(QDir &);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void reload();
|
void reload();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,10 +9,14 @@
|
|||||||
class ElementsCategoriesList;
|
class ElementsCategoriesList;
|
||||||
class ElementsCategoriesWidget : public QWidget {
|
class ElementsCategoriesWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeur, destructeur
|
|
||||||
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementsCategoriesWidget(QWidget * = 0);
|
ElementsCategoriesWidget(QWidget * = 0);
|
||||||
~ElementsCategoriesWidget();
|
virtual ~ElementsCategoriesWidget();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElementsCategoriesWidget(const ElementsCategoriesWidget &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -24,8 +28,6 @@ class ElementsCategoriesWidget : public QWidget {
|
|||||||
QAction *action_delete;
|
QAction *action_delete;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
bool rmdir(const QString &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementsCategoriesList &elementsCategoriesList() const;
|
ElementsCategoriesList &elementsCategoriesList() const;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ ElementsCategory::ElementsCategory(const QString &path) : QDir(path) {
|
|||||||
Destructeur
|
Destructeur
|
||||||
*/
|
*/
|
||||||
ElementsCategory::~ElementsCategory() {
|
ElementsCategory::~ElementsCategory() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,20 +7,19 @@
|
|||||||
qet_directory contenant ses caracteristiques (pour le moment : ses noms).
|
qet_directory contenant ses caracteristiques (pour le moment : ses noms).
|
||||||
*/
|
*/
|
||||||
class ElementsCategory : public QDir {
|
class ElementsCategory : public QDir {
|
||||||
// Constructeur, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementsCategory(const QString & = QString());
|
ElementsCategory(const QString & = QString());
|
||||||
~ElementsCategory();
|
virtual ~ElementsCategory();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElementsCategory(const ElementsCategory &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
QHash<QString, QString> category_names;
|
QHash<QString, QString> category_names;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
private:
|
|
||||||
bool rmdir(const QString &) const;
|
|
||||||
void loadNames();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QHash<QString, QString> categoryNames() const;
|
QHash<QString, QString> categoryNames() const;
|
||||||
@@ -29,5 +28,9 @@ class ElementsCategory : public QDir {
|
|||||||
bool write() const;
|
bool write() const;
|
||||||
bool remove() const;
|
bool remove() const;
|
||||||
//bool move(const QString &new_parent);
|
//bool move(const QString &new_parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool rmdir(const QString &) const;
|
||||||
|
void loadNames();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,11 +9,15 @@ class ElementsCategory;
|
|||||||
class NamesList;
|
class NamesList;
|
||||||
class ElementsCategoryEditor : public QDialog {
|
class ElementsCategoryEditor : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
//Constructeurs, destructeur
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementsCategoryEditor(QWidget * = 0);
|
ElementsCategoryEditor(QWidget * = 0);
|
||||||
ElementsCategoryEditor(const QString &, bool = true, QWidget * = 0);
|
ElementsCategoryEditor(const QString &, bool = true, QWidget * = 0);
|
||||||
~ElementsCategoryEditor();
|
virtual ~ElementsCategoryEditor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElementsCategoryEditor(const ElementsCategoryEditor &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -29,6 +33,5 @@ class ElementsCategoryEditor : public QDialog {
|
|||||||
public slots:
|
public slots:
|
||||||
void acceptCreation();
|
void acceptCreation();
|
||||||
void acceptUpdate();
|
void acceptUpdate();
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ ElementsPanel::ElementsPanel(QWidget *parent) : QTreeWidget(parent) {
|
|||||||
setPalette(qp);
|
setPalette(qp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
ElementsPanel::~ElementsPanel() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere le mouvement lors d'un drag'n drop
|
Gere le mouvement lors d'un drag'n drop
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
#ifndef PANELAPPAREILS_H
|
#ifndef PANELAPPAREILS_H
|
||||||
#define PANELAPPAREILS_H
|
#define PANELAPPAREILS_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
/**
|
/**
|
||||||
Cette classe represente le panel d'appareils (en tant qu'element
|
Cette classe represente le panel d'appareils (en tant qu'element
|
||||||
graphique) dans lequel l'utilisateur choisit les composants de
|
graphique) dans lequel l'utilisateur choisit les composants de
|
||||||
son choix et les depose sur le schema par drag'n drop.
|
son choix et les depose sur le schema par drag'n drop.
|
||||||
*/
|
*/
|
||||||
class ElementsPanel : public QTreeWidget {
|
class ElementsPanel : public QTreeWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementsPanel(QWidget * = 0);
|
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:
|
public slots:
|
||||||
void dragMoveEvent(QDragMoveEvent *);
|
void dragMoveEvent(QDragMoveEvent *);
|
||||||
void dropEvent(QDropEvent *);
|
void dropEvent(QDropEvent *);
|
||||||
void startDrag(Qt::DropActions);
|
void startDrag(Qt::DropActions);
|
||||||
void reload();
|
void reload();
|
||||||
private:
|
};
|
||||||
void addFile(QTreeWidgetItem *, QString);
|
|
||||||
void addDir(QTreeWidgetItem *, QString, QString = QString());
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
setLayout(vlayout);
|
setLayout(vlayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
ElementsPanelWidget::~ElementsPanelWidget() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Appelle l'assistant de creation de nouvel element
|
Appelle l'assistant de creation de nouvel element
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,9 +10,13 @@
|
|||||||
class ElementsPanelWidget : public QWidget {
|
class ElementsPanelWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructeurs
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementsPanelWidget(QWidget * = 0);
|
ElementsPanelWidget(QWidget * = 0);
|
||||||
|
virtual ~ElementsPanelWidget();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ElementsPanelWidget(const ElementsPanelWidget &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -21,9 +25,17 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
inline ElementsPanel &elementsPanel() const { return(*elements_panel); }
|
inline ElementsPanel &elementsPanel() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newElement();
|
void newElement();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return Le panel d'elements imbrique dans ce widget
|
||||||
|
*/
|
||||||
|
inline ElementsPanel &ElementsPanelWidget::elementsPanel() const {
|
||||||
|
return(*elements_panel);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ ElementTextItem::ElementTextItem(const QString &text, QGraphicsItem *parent, QGr
|
|||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ElementTextItem::~ElementTextItem() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Modifie la position du champ de texte
|
Modifie la position du champ de texte
|
||||||
@param pos La nouvelle 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.
|
valeur a ce champ.
|
||||||
@param e L'element XML representant le champ de texte
|
@param e L'element XML representant le champ de texte
|
||||||
*/
|
*/
|
||||||
void ElementTextItem::fromXml(QDomElement &e) {
|
void ElementTextItem::fromXml(const QDomElement &e) {
|
||||||
QPointF _pos = pos();
|
QPointF _pos = pos();
|
||||||
if (e.attribute("x").toDouble() == _pos.x() && e.attribute("y").toDouble() == _pos.y()) {
|
if (e.attribute("x").toDouble() == _pos.x() && e.attribute("y").toDouble() == _pos.y()) {
|
||||||
setPlainText(e.attribute("text"));
|
setPlainText(e.attribute("text"));
|
||||||
@@ -66,7 +69,7 @@ void ElementTextItem::fromXml(QDomElement &e) {
|
|||||||
@param document Le document XML a utiliser
|
@param document Le document XML a utiliser
|
||||||
@return L'element XML representant ce champ de texte
|
@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");
|
QDomElement result = document.createElement("input");
|
||||||
result.setAttribute("x", pos().x());
|
result.setAttribute("x", pos().x());
|
||||||
result.setAttribute("y", pos().y());
|
result.setAttribute("y", pos().y());
|
||||||
|
|||||||
@@ -8,23 +8,26 @@
|
|||||||
malgre les rotations de son element parent.
|
malgre les rotations de son element parent.
|
||||||
*/
|
*/
|
||||||
class ElementTextItem : public QGraphicsTextItem {
|
class ElementTextItem : public QGraphicsTextItem {
|
||||||
// constructeurs
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementTextItem(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
ElementTextItem(QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
ElementTextItem(const QString &, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
ElementTextItem(const QString &, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
|
virtual ~ElementTextItem();
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
|
public:
|
||||||
|
enum { Type = UserType + 1003 };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool follow_parent_rotations;
|
bool follow_parent_rotations;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1003 };
|
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
bool followParentRotations() const;
|
bool followParentRotations() const;
|
||||||
void setFollowParentRotations(bool);
|
void setFollowParentRotations(bool);
|
||||||
void fromXml(QDomElement &);
|
void fromXml(const QDomElement &);
|
||||||
QDomElement toXml(QDomDocument &);
|
QDomElement toXml(QDomDocument &) const;
|
||||||
void setPos(const QPointF &);
|
void setPos(const QPointF &);
|
||||||
void setPos(qreal, qreal);
|
void setPos(qreal, qreal);
|
||||||
QPointF pos() const;
|
QPointF pos() const;
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ ExportDialog::ExportDialog(Diagram *dia, QWidget *parent) : QDialog(parent) {
|
|||||||
Destructeur - ne fait rien
|
Destructeur - ne fait rien
|
||||||
*/
|
*/
|
||||||
ExportDialog::~ExportDialog() {
|
ExportDialog::~ExportDialog() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,7 +265,7 @@ QImage ExportDialog::generateImage() {
|
|||||||
|
|
||||||
// genere l'image
|
// genere l'image
|
||||||
diagram -> setUseBorder(export_border -> isChecked());
|
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.displayBorder(draw_border -> isChecked());
|
||||||
diagram -> border_and_inset.displayColumns(draw_columns -> isChecked());
|
diagram -> border_and_inset.displayColumns(draw_columns -> isChecked());
|
||||||
diagram -> border_and_inset.displayInset(draw_inset -> 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.displayBorder(state_drawBorder);
|
||||||
diagram -> border_and_inset.displayColumns(state_drawColumns);
|
diagram -> border_and_inset.displayColumns(state_drawColumns);
|
||||||
diagram -> border_and_inset.displayInset(state_drawInset);
|
diagram -> border_and_inset.displayInset(state_drawInset);
|
||||||
diagram -> setAffichageGrille(state_drawGrid);
|
diagram -> setDisplayGrid(state_drawGrid);
|
||||||
diagram -> setUseBorder(state_useBorder);
|
diagram -> setUseBorder(state_useBorder);
|
||||||
|
|
||||||
return(image);
|
return(image);
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
#ifndef EXPORTDIALOG_H
|
#ifndef EXPORTDIALOG_H
|
||||||
#define EXPORTDIALOG_H
|
#define EXPORTDIALOG_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
/**
|
/**
|
||||||
Cette classe represente le dialogue permettant d'exporter un schema
|
Cette classe represente le dialogue permettant d'exporter un schema
|
||||||
sous forme d'image selon les desirs de l'utilisateur
|
sous forme d'image selon les desirs de l'utilisateur
|
||||||
*/
|
*/
|
||||||
class ExportDialog : public QDialog {
|
class ExportDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ExportDialog(Diagram *, QWidget * = 0);
|
ExportDialog(Diagram *, QWidget * = 0);
|
||||||
~ExportDialog();
|
virtual ~ExportDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ExportDialog(const ExportDialog &);
|
||||||
|
|
||||||
|
// attributs
|
||||||
private:
|
private:
|
||||||
// elements graphiques
|
// elements graphiques
|
||||||
QLineEdit *filename;
|
QLineEdit *filename;
|
||||||
@@ -41,6 +47,8 @@
|
|||||||
QString diagram_path;
|
QString diagram_path;
|
||||||
qreal diagram_ratio;
|
qreal diagram_ratio;
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
private:
|
||||||
QWidget *leftPart();
|
QWidget *leftPart();
|
||||||
QWidget *rightPart();
|
QWidget *rightPart();
|
||||||
QGroupBox *setupDimensionsGroupBox();
|
QGroupBox *setupDimensionsGroupBox();
|
||||||
@@ -54,5 +62,5 @@
|
|||||||
void slot_check();
|
void slot_check();
|
||||||
void slot_changeUseBorder();
|
void slot_changeUseBorder();
|
||||||
void slot_refreshPreview();
|
void slot_refreshPreview();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) {
|
FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
FixedElement::~FixedElement() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le nombre minimal de bornes que l'element peut avoir
|
@return Le nombre minimal de bornes que l'element peut avoir
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
#ifndef ELEMENTFIXE_H
|
#ifndef ELEMENTFIXE_H
|
||||||
#define ELEMENTFIXE_H
|
#define ELEMENTFIXE_H
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
class FixedElement : public Element {
|
/**
|
||||||
|
Cette classe represente un element avec un nombre fixe de bornes.
|
||||||
|
*/
|
||||||
|
class FixedElement : public Element {
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
FixedElement(QGraphicsItem * = 0, Diagram * = 0);
|
FixedElement(QGraphicsItem * = 0, Diagram * = 0);
|
||||||
|
virtual ~FixedElement();
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
int nbTerminalsMin() const;
|
int nbTerminalsMin() const;
|
||||||
int nbTerminalsMax() const;
|
int nbTerminalsMax() const;
|
||||||
virtual int nbTerminals() const = 0;
|
virtual int nbTerminals() const = 0;
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *) = 0;
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *) = 0;
|
||||||
virtual QString typeId() const = 0;
|
virtual QString typeId() const = 0;
|
||||||
virtual QString nom() const = 0;
|
virtual QString nom() const = 0;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ NamesList::NamesList(QWidget *parent) : QWidget(parent) {
|
|||||||
Destructeur
|
Destructeur
|
||||||
*/
|
*/
|
||||||
NamesList::~NamesList() {
|
NamesList::~NamesList() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,10 +7,14 @@
|
|||||||
*/
|
*/
|
||||||
class NamesList : public QWidget {
|
class NamesList : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
//Constructeur, destructeur
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
NamesList(QWidget * = 0);
|
NamesList(QWidget * = 0);
|
||||||
~NamesList();
|
virtual ~NamesList();
|
||||||
|
|
||||||
|
private:
|
||||||
|
NamesList(const NamesList &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -23,6 +27,7 @@ class NamesList : public QWidget {
|
|||||||
bool checkOneName();
|
bool checkOneName();
|
||||||
QHash<QString, QString> names();
|
QHash<QString, QString> names();
|
||||||
void setNames(QHash<QString, QString> &);
|
void setNames(QHash<QString, QString> &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clean();
|
void clean();
|
||||||
void updateHash();
|
void updateHash();
|
||||||
|
|||||||
@@ -17,10 +17,14 @@ class NamesList;
|
|||||||
class Diagram;
|
class Diagram;
|
||||||
class NewElementWizard : public QDialog {
|
class NewElementWizard : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeur, destructeur
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
NewElementWizard(QWidget * = 0, Qt::WindowFlags = 0);
|
NewElementWizard(QWidget * = 0, Qt::WindowFlags = 0);
|
||||||
~NewElementWizard();
|
virtual ~NewElementWizard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
NewElementWizard(const NewElementWizard &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -88,6 +88,12 @@ QETApp::QETApp(QWidget *parent) : QMainWindow(parent) {
|
|||||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateActions()));
|
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateActions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
QETApp::~QETApp() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les evenements relatifs au QSystemTrayIcon
|
Gere les evenements relatifs au QSystemTrayIcon
|
||||||
@param raison un entier representant l'evenement survenu sur le systray
|
@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
|
@return Le DiagramView qui a le focus dans l'interface MDI
|
||||||
*/
|
*/
|
||||||
DiagramView *QETApp::diagramEnCours() {
|
DiagramView *QETApp::diagramEnCours() const {
|
||||||
return(qobject_cast<DiagramView *>(workspace.activeWindow()));
|
return(qobject_cast<DiagramView *>(workspace.activeWindow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
40
qetapp.h
40
qetapp.h
@@ -1,19 +1,28 @@
|
|||||||
#ifndef QETAPP_H
|
#ifndef QETAPP_H
|
||||||
#define QETAPP_H
|
#define QETAPP_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
class DiagramView;
|
class DiagramView;
|
||||||
class ElementsPanelWidget;
|
class ElementsPanelWidget;
|
||||||
/**
|
/**
|
||||||
Cette classe represente la fenetre principale de QElectroTech et,
|
Cette classe represente la fenetre principale de QElectroTech et,
|
||||||
ipso facto, la plus grande partie de l'interface graphique de QElectroTech.
|
ipso facto, la plus grande partie de l'interface graphique de QElectroTech.
|
||||||
Il s'agit d'un objet QMainWindow avec un QWorkSpace contenant des objets
|
Il s'agit d'un objet QMainWindow avec un QWorkSpace contenant des objets
|
||||||
« Diagram » en guise de widget central et un « Panel d'Appareils » en guise
|
« Diagram » en guise de widget central et un « Panel d'Appareils » en guise
|
||||||
de widget « Dock ».
|
de widget « Dock ».
|
||||||
*/
|
*/
|
||||||
class QETApp : public QMainWindow {
|
class QETApp : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
QETApp(QWidget * = 0);
|
QETApp(QWidget * = 0);
|
||||||
|
virtual ~QETApp();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QETApp(const QETApp &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
void addDiagramView(DiagramView *);
|
void addDiagramView(DiagramView *);
|
||||||
static QString commonElementsDir();
|
static QString commonElementsDir();
|
||||||
@@ -23,6 +32,14 @@
|
|||||||
static QString realPath(QString &);
|
static QString realPath(QString &);
|
||||||
static QString symbolicPath(QString &);
|
static QString symbolicPath(QString &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void actions();
|
||||||
|
|
||||||
|
private:
|
||||||
|
DiagramView *diagramEnCours() const;
|
||||||
|
void menus();
|
||||||
|
void toolbar();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void systray(QSystemTrayIcon::ActivationReason);
|
void systray(QSystemTrayIcon::ActivationReason);
|
||||||
void systrayReduce();
|
void systrayReduce();
|
||||||
@@ -59,6 +76,7 @@
|
|||||||
void slot_expand();
|
void slot_expand();
|
||||||
void slot_shrink();
|
void slot_shrink();
|
||||||
|
|
||||||
|
// attributs
|
||||||
protected:
|
protected:
|
||||||
// Actions faisables au travers de menus dans l'application QElectroTech
|
// Actions faisables au travers de menus dans l'application QElectroTech
|
||||||
QAction *mode_selection;
|
QAction *mode_selection;
|
||||||
@@ -105,14 +123,10 @@
|
|||||||
QAction *f_reorganise;
|
QAction *f_reorganise;
|
||||||
QAction *f_prec;
|
QAction *f_prec;
|
||||||
QAction *f_suiv;
|
QAction *f_suiv;
|
||||||
|
|
||||||
void actions();
|
|
||||||
// menus variables
|
|
||||||
QAction *menu_systray_masquer_restaurer;
|
QAction *menu_systray_masquer_restaurer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWorkspace workspace;
|
QWorkspace workspace;
|
||||||
DiagramView *diagramEnCours();
|
|
||||||
QSignalMapper windowMapper;
|
QSignalMapper windowMapper;
|
||||||
/// Dock pour le Panel d'Appareils
|
/// Dock pour le Panel d'Appareils
|
||||||
QDockWidget *qdw_pa;
|
QDockWidget *qdw_pa;
|
||||||
@@ -127,8 +141,6 @@
|
|||||||
QSystemTrayIcon *qsti;
|
QSystemTrayIcon *qsti;
|
||||||
/// Geometrie de la fenetre principale
|
/// Geometrie de la fenetre principale
|
||||||
QByteArray wg;
|
QByteArray wg;
|
||||||
void menus();
|
|
||||||
void toolbar();
|
|
||||||
QToolBar *barre_outils;
|
QToolBar *barre_outils;
|
||||||
};
|
};
|
||||||
#endif
|
#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
|
Destructeur
|
||||||
|
La destruction de la borne entraine la destruction des conducteurs
|
||||||
|
associes.
|
||||||
*/
|
*/
|
||||||
Terminal::~Terminal() {
|
Terminal::~Terminal() {
|
||||||
|
//qDebug() << "Terminal::~Terminal" << (void *)this;
|
||||||
|
foreach(Conducer *c, liste_conducers) delete c;
|
||||||
delete br;
|
delete br;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,6 +143,7 @@ bool Terminal::addConducer(Conducer *f) {
|
|||||||
@param f Conducteur a enlever
|
@param f Conducteur a enlever
|
||||||
*/
|
*/
|
||||||
void Terminal::removeConducer(Conducer *f) {
|
void Terminal::removeConducer(Conducer *f) {
|
||||||
|
//qDebug() << "Terminal::removeConducer" << (void *)this;
|
||||||
int index = liste_conducers.indexOf(f);
|
int index = liste_conducers.indexOf(f);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
liste_conducers.removeAt(index);
|
liste_conducers.removeAt(index);
|
||||||
@@ -229,9 +234,9 @@ void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
|||||||
*/
|
*/
|
||||||
void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (Diagram *s = qobject_cast<Diagram *>(scene())) {
|
if (Diagram *s = qobject_cast<Diagram *>(scene())) {
|
||||||
s -> setDepart(mapToScene(QPointF(amarrage_conducer)));
|
s -> setConducerStart(mapToScene(QPointF(amarrage_conducer)));
|
||||||
s -> setArrivee(e -> scenePos());
|
s -> setConducerStop(e -> scenePos());
|
||||||
s -> poseConducer(true);
|
s -> setConducer(true);
|
||||||
setCursor(Qt::CrossCursor);
|
setCursor(Qt::CrossCursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +258,7 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// si la scene est un Diagram, on actualise le poseur de conducteur
|
// 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
|
// on recupere la liste des qgi sous le pointeur
|
||||||
QList<QGraphicsItem *> qgis = scene() -> items(e -> scenePos());
|
QList<QGraphicsItem *> qgis = scene() -> items(e -> scenePos());
|
||||||
@@ -315,7 +320,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
// verifie que la scene est bien un Diagram
|
// verifie que la scene est bien un Diagram
|
||||||
if (Diagram *s = qobject_cast<Diagram *>(scene())) {
|
if (Diagram *s = qobject_cast<Diagram *>(scene())) {
|
||||||
// on arrete de dessiner l'apercu du conducteur
|
// on arrete de dessiner l'apercu du conducteur
|
||||||
s -> poseConducer(false);
|
s -> setConducer(false);
|
||||||
// on recupere l'element sous le pointeur lors du MouseReleaseEvent
|
// on recupere l'element sous le pointeur lors du MouseReleaseEvent
|
||||||
QGraphicsItem *qgi = s -> itemAt(e -> scenePos());
|
QGraphicsItem *qgi = s -> itemAt(e -> scenePos());
|
||||||
// s'il n'y a rien, on arrete la
|
// s'il n'y a rien, on arrete la
|
||||||
|
|||||||
25
terminal.h
25
terminal.h
@@ -4,28 +4,29 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
class Conducer;
|
class Conducer;
|
||||||
class Element;
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
|
class Element;
|
||||||
/**
|
/**
|
||||||
Classe modelisant la « borne » d'un appareil, c'est-a-dire un
|
Classe modelisant la « borne » d'un appareil, c'est-a-dire un
|
||||||
branchement possible pour un Conducteur.
|
branchement possible pour un Conducteur.
|
||||||
*/
|
*/
|
||||||
class Terminal : public QGraphicsItem {
|
class Terminal : public QGraphicsItem {
|
||||||
|
|
||||||
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
// enum definissant l'orientation de la borne
|
|
||||||
enum Orientation {Nord, Est, Sud, Ouest};
|
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();
|
||||||
Terminal(QPointF, Terminal::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(QPointF, Terminal::Orientation, Element * = 0, Diagram * = 0);
|
||||||
Terminal(qreal, qreal, Terminal::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(qreal, qreal, Terminal::Orientation, Element * = 0, Diagram * = 0);
|
||||||
|
virtual ~Terminal();
|
||||||
|
|
||||||
// destructeur
|
private:
|
||||||
~Terminal();
|
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
|
// implementation des methodes virtuelles pures de QGraphicsItem
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
@@ -56,6 +57,10 @@ class Terminal : public QGraphicsItem {
|
|||||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *);
|
void mouseMoveEvent (QGraphicsSceneMouseEvent *);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
public:
|
||||||
|
enum { Type = UserType + 1002 };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// pointeur vers la QGraphicsScene de type Diagram (evite quelques casts en interne)
|
// pointeur vers la QGraphicsScene de type Diagram (evite quelques casts en interne)
|
||||||
Diagram *diagram_scene;
|
Diagram *diagram_scene;
|
||||||
|
|||||||
Reference in New Issue
Block a user