12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef BONDGRAPHICSVIEW_H
- #define BONDGRAPHICSVIEW_H
- #include <QGraphicsView>
- #include <QMap>
- #include <QLabel>
- #include <QGraphicsRectItem>
- #include <QPointer>
- #include <CBondMatrix.h>
- class BondItem : public QObject, public QGraphicsRectItem {
- public:
- BondItem(ns_mat::POINT_INFO_STRUCT point, QGraphicsItem* parent = nullptr);
- void setSelected(bool selected);
- void setLeftSelected(bool selected);
- ns_mat::POINT_INFO_STRUCT point;
- private:
- bool isSelected = false;
- // 获取单元格状态颜色
- QColor getColorByStatus(ns_mat::DIE_STATUS status);
- };
- class BondGraphicsView : public QGraphicsView {
- Q_OBJECT
- public:
- BondGraphicsView(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<int, QGraphicsItem*> selectedItemsMap;
- QLabel* thumbnailLabel; // 缩略图标签
- bool thumbnailVisible; // 缩略图可见状态
- QPointer<BondItem> selectedItem;
- void showThumbnail();
- void hideThumbnail();
- void clearRegion();
- void setRegion();
- };
- #endif // BONDGRAPHICSVIEW_H
|