Correction d'un bug de la revision 60

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@61 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavierqet
2007-02-18 21:45:44 +00:00
parent b59040234a
commit 7da7f48ef6

View File

@@ -700,34 +700,38 @@ bool Conducer::fromXml(QDomElement &e) {
if (!segments_x.size()) return(true); if (!segments_x.size()) return(true);
// les longueurs recueillies doivent etre coherentes avec les positions des bornes // les longueurs recueillies doivent etre coherentes avec les positions des bornes
qreal width = 0.0, height= 0.0; qreal width = 0.0, height = 0.0;
foreach (qreal t, segments_x) width += t; foreach (qreal t, segments_x) width += t;
foreach (qreal t, segments_y) height += t; foreach (qreal t, segments_y) height += t;
QPointF t1 = terminal1 -> amarrageConducer(); QPointF t1 = terminal1 -> amarrageConducer();
QPointF t2 = terminal2 -> amarrageConducer(); QPointF t2 = terminal2 -> amarrageConducer();
qreal expected_width = qAbs(t2.x() - t1.x()); qreal expected_width = qAbs(t2.x() - t1.x());
qreal expected_height = qAbs(t2.y() - t1.y()); qreal expected_height = qAbs(t2.y() - t1.y());
if (
if (expected_width != width || expected_height != height) return(false); expected_width > width + 0.001 ||\
expected_width < width - 0.001 ||\
expected_height > height + 0.001 ||\
expected_height < height - 0.001
) return(false);
/* on recree les segments a partir des donnes XML */ /* on recree les segments a partir des donnes XML */
// cree la liste de points // cree la liste de points
QList<QPointF> points_list; QList<QPointF> points_list;
points_list << t1; points_list << (t1.x() < t2.x() ? t1 : t2);
for (int i = 0 ; i < segments_x.size() ; ++ i) { for (int i = 0 ; i < segments_x.size() ; ++ i) {
points_list << QPointF( points_list << QPointF(
points_list.last().x() + segments_x.at(i), points_list.last().x() + segments_x.at(i),
points_list.last().y() + segments_y.at(i) points_list.last().y() + segments_y.at(i)
); );
} }
qDebug() << points_list;
pointsToSegments(points_list); pointsToSegments(points_list);
// initialise divers parametres lies a la modification des conducteurs // initialise divers parametres lies a la modification des conducteurs
modified_path = true; modified_path = true;
moves_x = segments_x; moves_x = segments_x;
moves_y = segments_y; moves_y = segments_y;
type_trajet_x = points_list.at(0).x() < points_list.at(points_list.size() - 1).x(); type_trajet_x = t1.x() < t2.x();
orig_dist_2_terms_x = points_list.at(points_list.size() - 1).x() - points_list.at(0).x(); orig_dist_2_terms_x = points_list.at(points_list.size() - 1).x() - points_list.at(0).x();
orig_dist_2_terms_y = points_list.at(points_list.size() - 1).y() - points_list.at(0).y(); orig_dist_2_terms_y = points_list.at(points_list.size() - 1).y() - points_list.at(0).y();