wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementOrientation Class Reference

Owns the rotation angle and flip flags of a GraphicElement, and the transform math that applies them to the item and its ports. More...

#include <ElementOrientation.h>

Public Member Functions

qreal angle () const
 Returns the current rotation angle in degrees.
void applyLoadedOrientation ()
 ElementOrientation (GraphicElement *owner)
 Constructs the orientation state bound to its owning owner element.
bool isFlippedX () const
 Returns true if this element is mirrored along the X axis (horizontal flip).
bool isFlippedY () const
 Returns true if this element is mirrored along the Y axis (vertical flip).
void orientPort (Port *port)
 Orients port for the current rotation + flip state.
void rotatePorts ()
void setAngleRaw (qreal angle)
 Sets the angle without re-applying the transform. Load-time only.
void setFlippedX (bool flipped)
 Sets the horizontal mirror state and updates the item transform.
void setFlippedXRaw (bool flipped)
 Sets the horizontal flip flag without re-applying the transform. Load-time only.
void setFlippedY (bool flipped)
 Sets the vertical mirror state and updates the item transform.
void setFlippedYRaw (bool flipped)
 Sets the vertical flip flag without re-applying the transform. Load-time only.
void setRotation (qreal angle)
 Rotates to angle degrees (normalised to [0, 360)) and updates port positions.

Detailed Description

Owns the rotation angle and flip flags of a GraphicElement, and the transform math that applies them to the item and its ports.

Extracted from GraphicElement, mirroring the ElementAppearance / ElementSimState pattern (owner back-pointer, used through the element's public interface). Rotatable elements rotate the whole QGraphicsItem; non-rotatable elements keep their pixmap fixed and instead re-transform each port individually — both paths are implemented here.

Definition at line 25 of file ElementOrientation.h.

Constructor & Destructor Documentation

◆ ElementOrientation()

ElementOrientation::ElementOrientation ( GraphicElement * owner)
inlineexplicit

Constructs the orientation state bound to its owning owner element.

Definition at line 29 of file ElementOrientation.h.

Member Function Documentation

◆ angle()

qreal ElementOrientation::angle ( ) const
inline

Returns the current rotation angle in degrees.

Definition at line 35 of file ElementOrientation.h.

Referenced by setAngleRaw(), and setRotation().

◆ applyLoadedOrientation()

void ElementOrientation::applyLoadedOrientation ( )
inline

Applies the raw-loaded angle/flip state to the item, reproducing the historical setRotation()+applyFlipTransform() load sequence byte-for-byte.

Definition at line 77 of file ElementOrientation.h.

References setRotation().

Referenced by GraphicElementSerializer::load().

◆ isFlippedX()

bool ElementOrientation::isFlippedX ( ) const
inline

Returns true if this element is mirrored along the X axis (horizontal flip).

Definition at line 41 of file ElementOrientation.h.

◆ isFlippedY()

bool ElementOrientation::isFlippedY ( ) const
inline

Returns true if this element is mirrored along the Y axis (vertical flip).

Definition at line 44 of file ElementOrientation.h.

◆ orientPort()

void ElementOrientation::orientPort ( Port * port)

Orients port for the current rotation + flip state.

Used by non-rotatable elements, which keep their pixmap fixed. Applies Rotate(centre, angle) then Flip about the pixmap centre to the port, so the port moves to the mirrored/rotated side while the element graphic stays upright. Recomputed from the flags each call, so it is involutive.

Definition at line 34 of file ElementOrientation.cpp.

References Port::updateConnections().

Referenced by rotatePorts().

◆ rotatePorts()

void ElementOrientation::rotatePorts ( )

Re-applies the combined rotation + flip orientation to every port. Used by non-rotatable elements, which keep their pixmap fixed and move only their ports around the centre.

Definition at line 27 of file ElementOrientation.cpp.

References orientPort().

Referenced by setRotation().

◆ setAngleRaw()

void ElementOrientation::setAngleRaw ( qreal angle)
inline

Sets the angle without re-applying the transform. Load-time only.

Definition at line 69 of file ElementOrientation.h.

References angle().

◆ setFlippedX()

void ElementOrientation::setFlippedX ( bool flipped)

Sets the horizontal mirror state and updates the item transform.

Definition at line 58 of file ElementOrientation.cpp.

◆ setFlippedXRaw()

void ElementOrientation::setFlippedXRaw ( bool flipped)
inline

Sets the horizontal flip flag without re-applying the transform. Load-time only.

Definition at line 71 of file ElementOrientation.h.

◆ setFlippedY()

void ElementOrientation::setFlippedY ( bool flipped)

Sets the vertical mirror state and updates the item transform.

Definition at line 64 of file ElementOrientation.cpp.

◆ setFlippedYRaw()

void ElementOrientation::setFlippedYRaw ( bool flipped)
inline

Sets the vertical flip flag without re-applying the transform. Load-time only.

Definition at line 73 of file ElementOrientation.h.

◆ setRotation()

void ElementOrientation::setRotation ( qreal angle)

Rotates to angle degrees (normalised to [0, 360)) and updates port positions.

Definition at line 11 of file ElementOrientation.cpp.

References angle(), and rotatePorts().

Referenced by applyLoadedOrientation().


The documentation for this class was generated from the following files: