GraphicComponent¶
- src/ui/graphic_component.h
This class can be thought of as a graphical front-end to Component.
-
class
Ohmcha::GraphicComponent: public QGraphicsItem Subclassed by Ohmcha::GraphicBranch, Ohmcha::GraphicCurrentSource, Ohmcha::GraphicEmf, Ohmcha::GraphicNode, Ohmcha::GraphicResistor
Public Types
-
enum
Anchor Values:
-
enumerator
NW
-
enumerator
N
-
enumerator
NE
-
enumerator
W
-
enumerator
C
-
enumerator
E
-
enumerator
SW
-
enumerator
S
-
enumerator
SE
-
enumerator
Public Functions
-
GraphicComponent()
-
GraphicComponent(const GraphicComponent &original)
-
const QPointF *
findNearestTerminal(QPointF point) const Return the terminal that is within a certain distance to the specified point. If there is no such terminal, return null. The point is specified in this item’s coordinate system.
-
GraphicComponent *
copy() const = 0
-
void
synchronize()
-
QVariant
itemChange(GraphicsItemChange change, const QVariant &value) override
-
void
setName(QString name)
-
void
setCenter(QPointF center)
-
void
setRotation(float angle)
-
void
setTextAnchor(Anchor anchor)
-
void
setTextPosition(QPointF pos)
-
void
setTextRotation(float angle)
-
void
setTextRotationIndependent(bool independent)
-
void
setComponent(Component *component)
-
QSizeF
getSize() const
-
QString
getName() const
-
QPointF
getCenter() const
-
Anchor
getTextAnchor() const
-
QPointF
getTextPosition() const
-
float
getTextRotation() const
-
bool
isTextRotationIndependent() const
-
Component *
getComponent() const
-
CircuitViewScene *
getScene() const
-
int
getTerminalId(const QPointF &terminal) const
-
QList<QPointF>
getTerminals() const
-
void
onTerminalClicked(QPointF position)
-
void
hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
-
void
hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
-
void
hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
-
void
mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Public Static Functions
-
GraphicComponent *
newFromComponent(Component *component) Dynamically allocate a GraphicComponent wrapper around the specified Component. The type of the resulting object is determined based on the type of Component. TODO: implement.
Protected Functions
-
void
applyColors(QPainter *painter, const QStyleOptionGraphicsItem *option)
-
void
drawText(QPainter *painter)
Protected Attributes
-
QList<QPointF>
terminals
-
bool
branch1= false
-
bool
branch2= false
-
QSizeF
size
-
Component *
component= nullptr
-
QPointF
textPos
-
float
textAngle= 0
-
bool
textRotationIndependent= false
-
const QPointF *
_selectedTerminal= nullptr
Friends
- friend class GraphicBranch
- friend class CircuitView
-
enum
GraphicResistor¶
- src/ui/graphic_resistor.h
-
class
Ohmcha::GraphicResistor: public Ohmcha::GraphicComponent Public Functions
-
GraphicResistor()
-
GraphicResistor(Resistor *resistor)
-
GraphicResistor(QPointF node1, QPointF node2)
-
GraphicResistor(const GraphicResistor &original)
-
QRectF
boundingRect() const override
-
void
paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override
-
GraphicComponent *
copy() const override
-
void
setCenter(QPointF center) override
-
Resistor *
getComponent()
Private Members
-
float
terminalSize= 10
-
QPen
pen
-