#ifndef DOMAIN_DISPLAY_H #define DOMAIN_DISPLAY_H #include #include #include namespace domain { namespace ui { class Rect { public: int x, y, w, h; Rect(int x, int y, int w, int h) : x(x), y(y), w(w), h(h) {} void render(QGraphicsItemGroup *group); void comdel(std::ostream &buffer, int x, int y); }; class Line { public: int x1, y1, x2, y2; Line(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {} void render(QGraphicsItemGroup *group); void comdel(std::ostream &buffer, int x, int y); }; enum PinType { IN, OUT, IN_OUT }; enum PinOrientation { LEFT, RIGHT, TOP, BOTTOM }; enum BusOrientation { VERTICAL, HORIZONTAL }; class Bus { public: int x, y, w, h; BusOrientation orientation; Bus(int x, int y, int w, int h, BusOrientation orientation) : x(x), y(y), w(w), h(h), orientation(orientation) {} void render(QGraphicsItemGroup *group, int size); int getDefaultSize(); void comdel(std::ostream &buffer, int x, int y, int size); }; class Pin { public: PinOrientation orientation; PinType pinType; int x, y, w, h; Pin(int x, int y, int w, int h, PinOrientation orientation, PinType pinType) : x(x), y(y), w(w), h(h), orientation(orientation), pinType(pinType) {} public: void render(QGraphicsItemGroup *group); int getConnectionX(); int getConnectionY(); private: void renderIn(QGraphicsItemGroup *group); void renderOut(QGraphicsItemGroup *group); void renderInOut(QGraphicsItemGroup *group); }; class Item { public: Item() : rect(std::nullopt), line(std::nullopt), pin(std::nullopt), bus(std::nullopt) {} std::optional rect = std::nullopt; std::optional line = std::nullopt; std::optional pin = std::nullopt; std::optional bus = std::nullopt; void render(QGraphicsItemGroup *group, int size = 0); void comdel(std::ostream &buffer, int x, int y, int size = 0); }; } class Display { public: Display(std::vector items); void render(QGraphicsItemGroup *group); void comdel(std::ostream &buffer, int x, int y, int size = 0); std::vector &getItems() { return items; } private: std::vector items; }; } // namespace domain #endif // DOMAIN_DISPLAY_H