14 m_angle = std::fmod(
angle, 360);
19 if (m_owner->rotatesGraphic()) {
20 m_owner->QGraphicsItem::setRotation(m_angle);
21 m_owner->reapplyAppearanceOrientation();
29 for (
auto *port : m_owner->allPorts()) {
41 port->setTransformOriginPoint(QPointF());
46 const QPointF origin = m_owner->pixmapCenter() - port->pos();
49 t.translate(origin.x(), origin.y());
51 t.scale(m_flippedX ? -1 : 1, m_flippedY ? -1 : 1);
52 t.translate(-origin.x(), -origin.y());
53 port->setTransform(t);
70void ElementOrientation::applyFlipTransform()
80 if (!m_flippedX && !m_flippedY) {
81 m_owner->setTransform(QTransform());
83 const auto center = m_owner->pixmapCenter();
85 t.translate(center.x(), center.y());
86 t.scale(m_flippedX ? -1 : 1, m_flippedY ? -1 : 1);
87 t.translate(-center.x(), -center.y());
88 m_owner->setTransform(t);
95 m_owner->reapplyAppearanceOrientation();
Owns a GraphicElement's rotation angle and flip (mirror) state.
Abstract base class for all graphical circuit elements.
Port classes: Port (base), InputPort, and OutputPort.
void orientPort(Port *port)
Orients port for the current rotation + flip state.
void setFlippedX(bool flipped)
Sets the horizontal mirror state and updates the item transform.
void setFlippedY(bool flipped)
Sets the vertical mirror state and updates the item transform.
void setRotation(qreal angle)
Rotates to angle degrees (normalised to [0, 360)) and updates port positions.
qreal angle() const
Returns the current rotation angle in degrees.
bool rotatesGraphic() const
Abstract base class for circuit element ports (connection endpoints).
void updateConnections()
Triggers a path update on all attached connections.