1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef BONDGRAPHICSVIEW_H
- #define BONDGRAPHICSVIEW_H
- #include <QGraphicsView>
- #include <QMap>
- #include <QLabel>
- #include <QGraphicsRectItem>
- #include <QPointer>
- #include <CBondMatrix.h>
- #include <CViewInterface.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);
- void setRightSelected(bool selected);
- ns_mat::POINT_INFO_STRUCT point;
- int getDieIndex();
- private:
- QPair<int, int> topLeftIndex;
- QPair<int, int> bottomRightIndex;
- QPointer<BondItem> selectedItem;
- QPointer<BondItem> topLeftItem;
- QPointer<BondItem> bottomRightItem;
- bool isSelected = false;
- int dieIndex;
- POINT_INFO_STRUCT m_info;
- // 获取单元格状态颜色
- QColor getColorByStatus();
- protected:
- void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
- };
- class BondGraphicsView : public QGraphicsView {
- Q_OBJECT
- public:
- BondGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
- QPixmap convertToPixmap(const ImageInfo& imgData);
- void yuv422_to_rgb888(const unsigned char* src, unsigned char* dst, int width, int height);
- void setCViewInterface(ns_module::CViewInterface* CViewInterface);
- 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;
- ns_module::CViewInterface* m_pCViewInterface;
- QPointer<BondItem> topLeftItem;
- QPointer<BondItem> bottomRightItem;
- void showThumbnail();
- void hideThumbnail();
- void clearRegion();
- void setRegion();
- void checkAndCreateRegion();
- };
- #endif // BONDGRAPHICSVIEW_H
|