#ifndef CIRCUITCONNECTION_H #define CIRCUITCONNECTION_H #include #include #include "eConnectorType.h" class Part; class Wire; class Scene; class Label; class Connector : private QGraphicsItem { public: friend class Scene; friend class Logic; friend class Part; friend class Wire; friend class AddPart; friend class RemoveParts; friend class CopyParts; friend class MainWindow; Connector(Scene* scene, Part *parentPart, ConnectorType::ConnectorType side); Part* parentPart(); void setLabel(const QString& text = QString()); QString label() const; QRectF boundingRect() const override; // For drawing QPainterPath shape() const override; // For selection ("Hitbox") void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; ConnectorType::ConnectorType connectorType(); private: Scene* m_scene; QList m_wires; ConnectorType::ConnectorType m_connectorType; bool m_state = false; bool m_selected = false; // Separate from regular selection, for creating connections Label* m_label = nullptr; void select(); // Called by MainWindow void unselect(); // Called by MainWindow }; #endif // CIRCUITCONNECTION_H