#ifndef DISPLAY_SCHEMA_H #define DISPLAY_SCHEMA_H #include #include #include #include #include #include #include "component_display.h" namespace display { class BusConnection; class Schema : public QGraphicsView { Q_OBJECT public: QBrush selectedBrush = QBrush(QColor::fromRgb(50, 50, 150, 100), Qt::BrushStyle::SolidPattern); QPen selectedPen = QPen(QColor::fromRgb(50, 50, 150), 1, Qt::PenStyle::SolidLine); QPen activeLinePen = QPen(QColor::fromRgb(250, 100, 100)); 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 populateAttributes(std::vector& attributes); std::vector populateSingleAutomaticConnection(domain::Connection connection); void clearSelectable(); }; } // namespace display #endif // DISPLAY_SCHEMA_H