#ifndef DISPLAY_SCHEMA_H #define DISPLAY_SCHEMA_H #include #include #include #include #include #include "component_display.h" namespace display { class BusConnection; class Schema : public QGraphicsView { Q_OBJECT public: QBrush selectedBrush; QPen selectedPen; enum State { DEFAULT, CREATING_CONNECTION }; struct Context { display::Pin *pin = nullptr; QPointF startingPoint; QGraphicsLineItem *line = nullptr; std::vector selectable; }; std::map components; std::map buses; std::map pins; State state = DEFAULT; Context context; Schema(); std::vector busConnections; std::vector directConnections; void updateConnections(); void removeConnectable(QPointF f); void showConnectable(Pin *pin); void refreshContent(); protected: void dragEnterEvent(QDragEnterEvent *event) override; void dropEvent(QDropEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; private: QGraphicsScene scene; domain::Schema *schema{}; std::optional library; std::vector getAvailableConnectionBusses(domain::ComponentInstance *instance, domain::Pin &pin); std::vector getAvailableConnectionPins(domain::ComponentInstance *instance, domain::Pin &pin); }; } // namespace display #endif // DISPLAY_SCHEMA_H