mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-14 17:44:13 +02:00
Routing: follow up scorpio810's review of #1245
- Rename the `near` lambda in Conductor::setPathPoints() to `isNear`: `near` and `far` are empty macros in the Windows headers (minwindef.h). - Reword the log when setPathPoints() refuses a route. "does not join the two terminals" named only one of its reasons; the router always returns the two terminals and at least one exit point, so a refusal means the route is not a run of horizontal and vertical segments between them. - README: running along another wire is penalised, not forbidden, so two wires can end up drawn on top of each other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1402,11 +1402,11 @@ bool Conductor::moveSegment(int index, qreal dx, qreal dy)
|
||||
bool Conductor::setPathPoints(const QList<QPointF> &scene_points)
|
||||
{
|
||||
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;
|
||||
};
|
||||
if (!near(scene_points.first(), terminal1->dockConductor()) ||
|
||||
!near(scene_points.last(), terminal2->dockConductor()))
|
||||
if (!isNear(scene_points.first(), terminal1->dockConductor()) ||
|
||||
!isNear(scene_points.last(), terminal2->dockConductor()))
|
||||
return false;
|
||||
QList<QPointF> points;
|
||||
for (int i = 0; i < scene_points.size(); ++i) {
|
||||
|
||||
@@ -1264,8 +1264,13 @@ QString QetScriptApi::applyRoute(Conductor *conductor, const QString &caller)
|
||||
return QStringLiteral("no-route");
|
||||
}
|
||||
if (!conductor->setPathPoints(route.points)) {
|
||||
log(QStringLiteral("qet.%1: the route found does not join the two terminals; "
|
||||
"the conductor keeps its path").arg(caller));
|
||||
// ConductorRouter always gives at least the two terminals and an
|
||||
// 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("routed");
|
||||
|
||||
Reference in New Issue
Block a user