mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-17 11:24:14 +02:00
Merge pull request #1256 from ispyisail/fix/route-review-followups
Fix the follow-ups from the review of wire routing (#1245)
This commit is contained in:
@@ -545,8 +545,11 @@ Python, plus the hang guard on `addConductor` and the database refresh in
|
|||||||
the cheapest found by a search that charges for length, for each bend
|
the cheapest found by a search that charges for length, for each bend
|
||||||
and, less heavily, for running along or crossing another wire. Obstacles
|
and, less heavily, for running along or crossing another wire. Obstacles
|
||||||
are each symbol's own rectangle plus half a grid step; texts, images,
|
are each symbol's own rectangle plus half a grid step; texts, images,
|
||||||
shapes and tables are not obstacles. The path is saved as a hand-edited
|
shapes and tables are not obstacles. Running along another wire costs
|
||||||
one, so it survives a reload and one undo puts the default back. Where
|
more but is not forbidden, so where there is no other way two wires
|
||||||
|
can end up drawn on top of each other. The path is saved as a
|
||||||
|
hand-edited one, so it survives a reload and one undo puts the
|
||||||
|
default back. Where
|
||||||
no route exists, the wire keeps its path: `route_conductor` returns
|
no route exists, the wire keeps its path: `route_conductor` returns
|
||||||
`"no-route"` and both ops say so in `note` -- it is not a failure, and
|
`"no-route"` and both ops say so in `note` -- it is not a failure, and
|
||||||
the run goes on. Like a hand-edited path, it is stretched rather than
|
the run goes on. Like a hand-edited path, it is stretched rather than
|
||||||
|
|||||||
@@ -1402,11 +1402,11 @@ bool Conductor::moveSegment(int index, qreal dx, qreal dy)
|
|||||||
bool Conductor::setPathPoints(const QList<QPointF> &scene_points)
|
bool Conductor::setPathPoints(const QList<QPointF> &scene_points)
|
||||||
{
|
{
|
||||||
if (scene_points.size() < 2 || !terminal1 || !terminal2) return false;
|
if (scene_points.size() < 2 || !terminal1 || !terminal2) return false;
|
||||||
const auto near = [](const QPointF &a, const QPointF &b) {
|
const auto isNear = [](const QPointF &a, const QPointF &b) {
|
||||||
return qAbs(a.x() - b.x()) < 0.5 && qAbs(a.y() - b.y()) < 0.5;
|
return qAbs(a.x() - b.x()) < 0.5 && qAbs(a.y() - b.y()) < 0.5;
|
||||||
};
|
};
|
||||||
if (!near(scene_points.first(), terminal1->dockConductor()) ||
|
if (!isNear(scene_points.first(), terminal1->dockConductor()) ||
|
||||||
!near(scene_points.last(), terminal2->dockConductor()))
|
!isNear(scene_points.last(), terminal2->dockConductor()))
|
||||||
return false;
|
return false;
|
||||||
QList<QPointF> points;
|
QList<QPointF> points;
|
||||||
for (int i = 0; i < scene_points.size(); ++i) {
|
for (int i = 0; i < scene_points.size(); ++i) {
|
||||||
|
|||||||
@@ -1266,8 +1266,13 @@ QString QetScriptApi::applyRoute(Conductor *conductor, const QString &caller)
|
|||||||
return QStringLiteral("no-route");
|
return QStringLiteral("no-route");
|
||||||
}
|
}
|
||||||
if (!conductor->setPathPoints(route.points)) {
|
if (!conductor->setPathPoints(route.points)) {
|
||||||
log(QStringLiteral("qet.%1: the route found does not join the two terminals; "
|
// ConductorRouter always gives at least the two terminals and an
|
||||||
"the conductor keeps its path").arg(caller));
|
// exit point between them, so this is a route that is not a run
|
||||||
|
// of horizontal and vertical segments from one terminal to the
|
||||||
|
// other -- a bug in the router, not something the folio did.
|
||||||
|
log(QStringLiteral("qet.%1: the route found was refused (it must run in "
|
||||||
|
"horizontal and vertical segments from one terminal to "
|
||||||
|
"the other); the conductor keeps its path").arg(caller));
|
||||||
return QStringLiteral("no-route");
|
return QStringLiteral("no-route");
|
||||||
}
|
}
|
||||||
return QStringLiteral("routed");
|
return QStringLiteral("routed");
|
||||||
|
|||||||
Reference in New Issue
Block a user