mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Mise en place du nouveau systeme de gestion de la rotation des elements - attention : changements dans l'interpretation de certains attributs des fichiers XML => les "sens" des elements sont desormais un chiffre : 0 = nord, 1 = est, 2 = sud, 3 = ouest
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@15 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -44,7 +44,8 @@ ElementPerso::ElementPerso(QString &nom_fichier, QGraphicsItem *qgi, Schema *s,
|
||||
!attributeIsAnInteger(racine, QString("width"), &w) ||\
|
||||
!attributeIsAnInteger(racine, QString("height"), &h) ||\
|
||||
!attributeIsAnInteger(racine, QString("hotspot_x"), &hot_x) ||\
|
||||
!attributeIsAnInteger(racine, QString("hotspot_y"), &hot_y)
|
||||
!attributeIsAnInteger(racine, QString("hotspot_y"), &hot_y) ||\
|
||||
!validOrientationAttribute(racine)
|
||||
) {
|
||||
if (etat != NULL) *etat = 5;
|
||||
elmt_etat = 5;
|
||||
@@ -209,3 +210,30 @@ bool ElementPerso::attributeIsAReal(QDomElement &e, QString nom_attribut, double
|
||||
if (reel != NULL) *reel = tmp;
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool ElementPerso::validOrientationAttribute(QDomElement &e) {
|
||||
// verifie la presence de l'attribut orientation
|
||||
if (!e.hasAttribute("orientation")) return(false);
|
||||
QString t = e.attribute("orientation");
|
||||
// verification syntaxique : 4 lettres, un d, que des y ou des n pour le reste
|
||||
if (t.length() != 4) return(false);
|
||||
int d_pos = -1;
|
||||
for (int i = 0 ; i < 4 ; ++ i) {
|
||||
QChar c = t.at(i);
|
||||
if (c != 'd' && c != 'y' && c != 'n') return(false);
|
||||
if (c == 'd') {
|
||||
if (d_pos == -1) d_pos = i;
|
||||
else return(false);
|
||||
}
|
||||
}
|
||||
if (d_pos == -1) return(false);
|
||||
|
||||
// orientation : 4 lettres = nord/est/sud/ouest avec d = default, y = yes et n = no
|
||||
ori_n = (t.at(0) == 'd' || t.at(0) == 'y');
|
||||
ori_e = (t.at(1) == 'd' || t.at(1) == 'y');
|
||||
ori_s = (t.at(2) == 'd' || t.at(2) == 'y');
|
||||
ori_w = (t.at(3) == 'd' || t.at(3) == 'y');
|
||||
ori_d = (Borne::Orientation)d_pos;
|
||||
ori = ori_d;
|
||||
return(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user