WaferGraphicsView.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef WAFERGRAPHICSVIEW_H
  2. #define WAFERGRAPHICSVIEW_H
  3. #include <QGraphicsView>
  4. #include <QGraphicsScene>
  5. #include <QGraphicsRectItem>
  6. #include <QMouseEvent>
  7. #include "DieItem.h"
  8. #include <QLabel>
  9. #include <QPointer>
  10. class WaferGraphicsView : public QGraphicsView {
  11. Q_OBJECT
  12. public:
  13. WaferGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
  14. protected:
  15. void mousePressEvent(QMouseEvent* event) override;
  16. void mouseMoveEvent(QMouseEvent* event) override;
  17. void mouseReleaseEvent(QMouseEvent* event) override;
  18. void wheelEvent(QWheelEvent* event) override;
  19. bool eventFilter(QObject *obj, QEvent *event) override;
  20. private:
  21. bool selecting; // 是否正在框选
  22. QPoint lastPos;
  23. QPointF selectionStart; // 框选起点
  24. QGraphicsRectItem* selectionRect; // 框选矩形
  25. double scaleFactor; // 当前缩放比例
  26. bool isDragging = false;
  27. QMap<QPair<int, int>, QGraphicsItem*> selectedItemsMap;
  28. QLabel *thumbnailLabel; // 缩略图标签
  29. bool thumbnailVisible; // 缩略图可见状态
  30. QPair<int, int> topLeftIndex;
  31. QPair<int, int> bottomRightIndex;
  32. QPointer<DieItem> selectedItem;
  33. QPointer<DieItem> topLeftItem;
  34. QPointer<DieItem> bottomRightItem;
  35. void showThumbnail();
  36. void hideThumbnail();
  37. void checkAndCreateRegion();
  38. void clearRegion();
  39. void setRegion();
  40. };
  41. #endif // WAFERGRAPHICSVIEW_H