123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #ifndef WAFERGRAPHICSVIEW_H
- #define WAFERGRAPHICSVIEW_H
- #include <QGraphicsView>
- #include <QGraphicsScene>
- #include <QGraphicsRectItem>
- #include <QMouseEvent>
- #include "DieItem.h"
- #include <QLabel>
- #include <QPointer>
- class WaferGraphicsView : public QGraphicsView {
- Q_OBJECT
- public:
- WaferGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
- protected:
- void mousePressEvent(QMouseEvent* event) override;
- void mouseMoveEvent(QMouseEvent* event) override;
- void mouseReleaseEvent(QMouseEvent* event) override;
- void wheelEvent(QWheelEvent* event) override;
- bool eventFilter(QObject *obj, QEvent *event) override;
- private:
- bool selecting; // 是否正在框选
- QPoint lastPos;
- QPointF selectionStart; // 框选起点
- QGraphicsRectItem* selectionRect; // 框选矩形
- double scaleFactor; // 当前缩放比例
- bool isDragging = false;
- QMap<QPair<int, int>, QGraphicsItem*> selectedItemsMap;
- QLabel *thumbnailLabel; // 缩略图标签
- bool thumbnailVisible; // 缩略图可见状态
- QPair<int, int> topLeftIndex;
- QPair<int, int> bottomRightIndex;
- QPointer<DieItem> selectedItem;
- QPointer<DieItem> topLeftItem;
- QPointer<DieItem> bottomRightItem;
- void showThumbnail();
- void hideThumbnail();
- void checkAndCreateRegion();
- void clearRegion();
- void setRegion();
- };
- #endif // WAFERGRAPHICSVIEW_H
|