schema_editor/comdel/display/schema_display.h

58 lines
967 B
C++

#ifndef DISPLAY_SCHEMA_H
#define DISPLAY_SCHEMA_H
#include <QGraphicsView>
#include <QWidget>
#include <comdel/domain/schema.h>
#include <comdel/domain/library.h>
namespace display {
class BusConnection;
class Schema: public QGraphicsView
{
Q_OBJECT
public:
enum State {
DEFAULT,
CREATING_CONNECTION
};
struct Context {
display::Pin *pin;
QPointF startingPoint;
};
State state = DEFAULT;
Context context;
Schema();
std::vector<BusConnection*> connections;
void setSchema(domain::Schema* schema, domain::Library* library);
void updateConnections();
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
private:
QGraphicsScene scene;
domain::Schema* schema;
domain::Library* library;
};
} // namespace display
#endif // DISPLAY_SCHEMA_H