mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Ajout de l'editeur d'elements
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@94 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
97
element.h
97
element.h
@@ -2,6 +2,7 @@
|
||||
#define ELEMENT_H
|
||||
#include <QtGui>
|
||||
#include "terminal.h"
|
||||
#include "orientationset.h"
|
||||
/**
|
||||
Cette classe abstraite represente un element electrique.
|
||||
*/
|
||||
@@ -21,12 +22,7 @@ class Element : public QGraphicsItem {
|
||||
enum { Type = UserType + 1000 };
|
||||
|
||||
protected:
|
||||
bool ori_n;
|
||||
bool ori_s;
|
||||
bool ori_e;
|
||||
bool ori_w;
|
||||
Terminal::Orientation ori_d;
|
||||
Terminal::Orientation ori;
|
||||
OrientationSet ori;
|
||||
|
||||
private:
|
||||
QSize dimensions;
|
||||
@@ -74,12 +70,8 @@ class Element : public QGraphicsItem {
|
||||
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);
|
||||
bool setOrientation(QET::Orientation o);
|
||||
const OrientationSet &orientation() const;
|
||||
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
@@ -89,8 +81,6 @@ class Element : public QGraphicsItem {
|
||||
bool peut_relier_ses_propres_terminals;
|
||||
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void updatePixmap();
|
||||
Terminal::Orientation nextOrientation(Terminal::Orientation o) const;
|
||||
Terminal::Orientation previousOrientation(Terminal::Orientation o) const;
|
||||
static QList<QDomElement> findInDomElement(QDomElement, QString, QString);
|
||||
};
|
||||
|
||||
@@ -117,85 +107,8 @@ inline void Element::setConnexionsInternesAcceptees(bool cia) {
|
||||
Permet de connaitre l'orientation actuelle de l'element
|
||||
@return L'orientation actuelle de l'element
|
||||
*/
|
||||
inline Terminal::Orientation Element::orientation() const {
|
||||
inline const OrientationSet & Element::orientation() const {
|
||||
return(ori);
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de savoir si l'element peut etre positionne dans une orientation
|
||||
donnee.
|
||||
@param o L'orientation en question
|
||||
@return true si l'orientation est utilisable, false sinon
|
||||
*/
|
||||
inline bool Element::acceptOrientation(Terminal::Orientation o) const {
|
||||
switch(o) {
|
||||
case Terminal::Nord: return(ori_n);
|
||||
case Terminal::Est: return(ori_e);
|
||||
case Terminal::Sud: return(ori_s);
|
||||
case Terminal::Ouest: return(ori_w);
|
||||
default: return(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de connaitre l'orientation par defaut de l'element
|
||||
@return l'orientation par defaut de l'element
|
||||
*/
|
||||
inline Terminal::Orientation Element::defaultOrientation() const {
|
||||
return(ori_d);
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de connaitre la prochaine orientation autorisee pour cet element
|
||||
@return la prochaine orientation autorisee pour cet element
|
||||
*/
|
||||
inline Terminal::Orientation Element::nextAcceptableOrientation() const {
|
||||
Terminal::Orientation retour = nextOrientation(ori);
|
||||
for (int i = 0 ; i < 4 ; ++ i) {
|
||||
if (acceptOrientation(retour)) return(retour);
|
||||
retour = nextOrientation(retour);
|
||||
}
|
||||
// on ne devrait pas arriver la : renvoi d'une valeur par defaut = nord
|
||||
return(Terminal::Nord);
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de connaitre la precedente orientation autorisee pour cet element
|
||||
@return la precedente orientation autorisee pour cet element
|
||||
*/
|
||||
inline Terminal::Orientation Element::previousAcceptableOrientation() const {
|
||||
Terminal::Orientation retour = previousOrientation(ori);
|
||||
for (int i = 0 ; i < 4 ; ++ i) {
|
||||
if (acceptOrientation(retour)) return(retour);
|
||||
retour = previousOrientation(retour);
|
||||
}
|
||||
// on ne devrait pas arriver la : renvoi d'une valeur par defaut = nord
|
||||
return(Terminal::Nord);
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de connaitre l'orientation suivante apres celle donnee en parametre.
|
||||
Les orientations sont generalement presentees dans l'ordre suivant : Nord,
|
||||
Est, Sud, Ouest.
|
||||
@param o une orientation
|
||||
@return l'orientation suivante
|
||||
*/
|
||||
inline Terminal::Orientation Element::nextOrientation(Terminal::Orientation o) const {
|
||||
if (o < 0 || o > 2) return(Terminal::Nord);
|
||||
return((Terminal::Orientation)(o + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de connaitre l'orientation precedant celle donnee en parametre.
|
||||
Les orientations sont generalement presentees dans l'ordre suivant : Nord,
|
||||
Est, Sud, Ouest.
|
||||
@param o une orientation
|
||||
@return l'orientation precedente
|
||||
*/
|
||||
inline Terminal::Orientation Element::previousOrientation(Terminal::Orientation o) const {
|
||||
if (o < 0 || o > 3) return(Terminal::Nord);
|
||||
if (o == Terminal::Nord) return(Terminal::Ouest);
|
||||
return((Terminal::Orientation)(o - 1));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user