Minor : improve first and last segment position of conducteur

This commit is contained in:
joshua 2023-01-31 23:13:05 +01:00 committed by Laurent Trinques
parent fa52482874
commit 522e5337ee
2 changed files with 20 additions and 12 deletions

View File

@ -445,29 +445,37 @@ void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, co
} }
/** /**
Prolonge une borne. * @brief Conductor::extendTerminal
@param terminal Le point correspondant a la borne * @param terminal : point to extend (must be the docking point of a terminal)
@param terminal_orientation L'orientation de la borne * @param terminal_orientation : the orientation of the terminal
@param ext_size la taille de la prolongation * @param ext_size : how many to extrend (10 by default)
@return le point correspondant a la borne apres prolongation * @return the point with an extension of @ext_size
*/ * and rounded to nearest multiple of ten
QPointF Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation terminal_orientation, qreal ext_size) { * in order to be snapped to the grid of the diagram.
*/
QPointF Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation terminal_orientation, qreal ext_size)
{
QPointF extended_terminal; QPointF extended_terminal;
switch(terminal_orientation) { switch(terminal_orientation) {
case Qet::North: case Qet::North:
extended_terminal = QPointF(terminal.x(), terminal.y() - ext_size); extended_terminal = QPointF(terminal.x(),
std::round((terminal.y() - ext_size)/10)*10);
break; break;
case Qet::East: case Qet::East:
extended_terminal = QPointF(terminal.x() + ext_size, terminal.y()); extended_terminal = QPointF(std::round((terminal.x() + ext_size)/10)*10,
terminal.y());
break; break;
case Qet::South: case Qet::South:
extended_terminal = QPointF(terminal.x(), terminal.y() + ext_size); extended_terminal = QPointF(terminal.x(),
std::round((terminal.y() + ext_size)/10)*10);
break; break;
case Qet::West: case Qet::West:
extended_terminal = QPointF(terminal.x() - ext_size, terminal.y()); extended_terminal = QPointF(std::round((terminal.x() - ext_size)/10)*10,
terminal.y());
break; break;
default: extended_terminal = terminal; default: extended_terminal = terminal;
} }
return(extended_terminal); return(extended_terminal);
} }

View File

@ -227,7 +227,7 @@ class Conductor : public QGraphicsObject
static int getCoeff(const qreal &, const qreal &); static int getCoeff(const qreal &, const qreal &);
static int getSign(const qreal &); static int getSign(const qreal &);
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const; QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0); static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 10);
static Qt::Corner movementType(const QPointF &, const QPointF &); static Qt::Corner movementType(const QPointF &, const QPointF &);
static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &); static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
}; };