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.
@param terminal Le point correspondant a la borne
@param terminal_orientation L'orientation de la borne
@param ext_size la taille de la prolongation
@return le point correspondant a la borne apres prolongation
* @brief Conductor::extendTerminal
* @param terminal : point to extend (must be the docking point of a terminal)
* @param terminal_orientation : the orientation of the terminal
* @param ext_size : how many to extrend (10 by default)
* @return the point with an extension of @ext_size
* and rounded to nearest multiple of ten
* 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 Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation terminal_orientation, qreal ext_size)
{
QPointF extended_terminal;
switch(terminal_orientation) {
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;
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;
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;
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;
default: extended_terminal = terminal;
}
return(extended_terminal);
}

View File

@ -227,7 +227,7 @@ class Conductor : public QGraphicsObject
static int getCoeff(const qreal &, const qreal &);
static int getSign(const qreal &);
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 QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
};