mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-10 06:04:12 +02:00
Merge pull request #1127 from ispyisail/fix/bugtracker-105-diagonal-wire
Fix bugtracker #105: straight wire drawn diagonally after a move
This commit is contained in:
@@ -228,9 +228,6 @@ void Conductor::segmentsToPath()
|
|||||||
@param o2 Orientation de la borne 2
|
@param o2 Orientation de la borne 2
|
||||||
*/
|
*/
|
||||||
void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
|
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()];
|
ConductorProfile &conductor_profile = conductor_profiles[currentPathType()];
|
||||||
|
|
||||||
Q_ASSERT_X(conductor_profile.segmentsCount(QET::Both) > 1, "Conductor::priv_modifieConductor", "pas de points a modifier");
|
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 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);
|
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<ConductorSegmentProfile *> &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
|
// applique les differences aux segments
|
||||||
// apply the differences to the segments
|
// apply the differences to the segments
|
||||||
QMultiHash<ConductorSegmentProfile *, qreal> segments_lengths;
|
QMultiHash<ConductorSegmentProfile *, qreal> segments_lengths;
|
||||||
|
|||||||
Reference in New Issue
Block a user