mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-02 16:44:16 +02:00
79a8637251
Where two wires cross without being connected, a project can now draw a small arc (a hop) on one of them, instead of the user inserting a jump symbol and splitting the wire. It is a project setting, off by default: Project properties > Général > "Croisements de conducteurs", with no hops, hops on horizontal wires, or hops on vertical wires. Choosing the orientation rather than following drawing order keeps a project consistent. Only the drawing changes: no element is added and no wire is split. A wire that ends or bends on another one is a junction and never hops, and a crossing too close to the end of a segment for the arc to fit is drawn plainly. PDF, SVG and image export and printing show the hops, since they paint through Conductor::paint(); DXF export, which writes the segments itself, does not. The setting is saved as <wire_crossings hop="..."/> under the project root, next to <usage>, and only when hops are on, so a project that never used them saves exactly as before. The geometry is in wirehops.cpp, free of any graphics item, and tested on its own. Conductor::paintedPath() feeds it the conductors of the folio from a snapshot of their scene points, rebuilt only when a conductor changes shape, moves, or enters or leaves a folio; each hop path is cached the same way. Asking the scene for the conductors in a rect instead strokes every candidate's shape, which made a 366-wire folio render 0.6 s slower; with the snapshot the difference is within measurement noise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#ifndef WIREHOPS_H
|
|
#define WIREHOPS_H
|
|
|
|
#include <QList>
|
|
#include <QPainterPath>
|
|
#include <QPointF>
|
|
#include <QString>
|
|
#include <QVector>
|
|
|
|
/**
|
|
@brief The WireHops namespace
|
|
Hops (small arcs) drawn where two wires cross without being connected
|
|
(issue #436). Only the drawing changes: no element is added and no wire
|
|
is split. Kept free of any QGraphicsItem so the geometry can be tested
|
|
on its own.
|
|
|
|
Wires in QElectroTech are made of horizontal and vertical segments
|
|
only, so a crossing is a segment of one orientation passing through a
|
|
segment of the other, away from the ends of both. A wire that ends or
|
|
bends on another one is a junction, not a crossing, and never hops.
|
|
*/
|
|
namespace WireHops
|
|
{
|
|
///Which wire of a crossing draws the hop
|
|
enum class Mode {
|
|
None, ///< no hop, the default: crossings are drawn as plain lines
|
|
Horizontal, ///< the horizontal wire hops over the vertical one
|
|
Vertical ///< the vertical wire hops over the horizontal one
|
|
};
|
|
|
|
///Radius of a hop, in scene units (a grid step is 10)
|
|
constexpr qreal radius = 4.0;
|
|
|
|
QString toString(Mode mode);
|
|
Mode fromString(const QString &string);
|
|
|
|
QList<QPointF> crossings(const QVector<QPointF> &wire,
|
|
const QList<QVector<QPointF>> &others,
|
|
Mode mode);
|
|
QPainterPath path(const QVector<QPointF> &wire,
|
|
const QList<QPointF> &hops,
|
|
Mode mode);
|
|
}
|
|
|
|
#endif // WIREHOPS_H
|