#ifndef WAFERGRAPHICSVIEW_H
#define WAFERGRAPHICSVIEW_H

#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsRectItem>
#include <QMouseEvent>
#include "DieItem.h"

class WaferGraphicsView : public QGraphicsView {
    Q_OBJECT

public:
    WaferGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
    void handleAction1();
    void handleAction2();

protected:
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
    void wheelEvent(QWheelEvent* event) override;

private:
    bool selecting; // 是否正在框选
    QPoint lastPos;
    QPointF selectionStart; // 框选起点
    QGraphicsRectItem* selectionRect; // 框选矩形
    double scaleFactor; // 当前缩放比例
    bool isDragging = false;
    QMap<QPair<int, int>, QGraphicsItem*> selectedItemsMap;
};

#endif // WAFERGRAPHICSVIEW_H
