diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index f97fb97ec..4eb9009bc 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -228,9 +228,6 @@ void Conductor::segmentsToPath() @param o2 Orientation de la borne 2 */ void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) { - Q_UNUSED(o1); - Q_UNUSED(o2); - ConductorProfile &conductor_profile = conductor_profiles[currentPathType()]; Q_ASSERT_X(conductor_profile.segmentsCount(QET::Both) > 1, "Conductor::priv_modifieConductor", "pas de points a modifier"); @@ -252,6 +249,25 @@ void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, cons qreal h_diff = (qAbs(new_rect.width()) - qAbs(profile_width) ) * getSign(profile_width); qreal v_diff = (qAbs(new_rect.height()) - qAbs(profile_height)) * getSign(profile_height); + // A profile with no segment of non-zero length along an axis has nowhere + // to put a difference along that axis: it would be dropped and the last + // point would join the terminal diagonally. Every straight conductor + // loaded from a file is like this, as a zero-length segment is saved as + // horizontal (bugtracker #105). Generate a new path instead, as when + // there is no profile for this path type. + const auto can_absorb = [](qreal diff, const QList &segments_list) { + if (qAbs(diff) <= 0.01) return(true); + for (ConductorSegmentProfile *csp : segments_list) { + if (csp -> length) return(true); + } + return(false); + }; + if (!can_absorb(h_diff, conductor_profile.horizontalSegments()) || + !can_absorb(v_diff, conductor_profile.verticalSegments())) { + generateConductorPath(p1, o1, p2, o2); + return; + } + // applique les differences aux segments // apply the differences to the segments QMultiHash segments_lengths;