1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #ifndef WAFFLEGRAPHICSVIEW_H
- #define WAFFLEGRAPHICSVIEW_H
- #include <QGraphicsView>
- #include <QGraphicsScene>
- #include <QGraphicsRectItem>
- #include <QMouseEvent>
- #include "DieItem.h"
- #include <QLabel>
- #include <QPointer>
- class WaffleGraphicsView : public QGraphicsView {
- Q_OBJECT
- public:
- WaffleGraphicsView(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 // WAFFLEGRAPHICSVIEW_H
|