#ifndef DISPLAY_COMPONENT_H #define DISPLAY_COMPONENT_H #include #include #include #include #include #include "comdel/domain/connection_instance.h" namespace display { class Pin : public QGraphicsItemGroup { private: domain::Pin pin; std::shared_ptr componentInstance; public: Pin(domain::Pin pin, std::shared_ptr componentInstance) : pin(pin), componentInstance(std::move(componentInstance)) { pin.getDisplayPin().render(this); this->setToolTip(QString::fromStdString(pin.getTooltip())); } void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; domain::Pin &getPin(); domain::ComponentInstance *getComponentInstance(); bool isSingleAutomatic(std::vector pinConnections); }; class Component : public QGraphicsItemGroup { private: std::shared_ptr instance; public: explicit Component(const std::shared_ptr &instance); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; }; class Bus : public QGraphicsItemGroup { std::shared_ptr busInstance; public: explicit Bus(const std::shared_ptr &instance); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; }; class ComponentGroup : public QGraphicsItemGroup { private: std::shared_ptr componentInstance; std::vector pins; public: std::shared_ptr getComponentInstance(); std::vector &getPins(); explicit ComponentGroup(const std::shared_ptr &instance); protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; }; class BusGroup : public QGraphicsItemGroup { private: std::shared_ptr busInstance; display::Bus *bus; public: explicit BusGroup(const std::shared_ptr &instance); protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; }; class BusConnection : public QGraphicsLineItem { private: domain::BusConnectionInstance *connection; ComponentGroup *component; BusGroup *bus; public: BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus); void updateConnection(); }; class DirectConnection : public QGraphicsLineItem { private: domain::DirectConnectionInstance *connection; ComponentGroup *first; ComponentGroup *second; public: DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first, ComponentGroup *second); void updateConnection(); }; } // namespace display #endif // DISPLAY_COMPONENT_H