123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #ifndef WAFFLEGRAPHICSVIEW_H
- #define WAFFLEGRAPHICSVIEW_H
- #include <QGraphicsView>
- #include <QGraphicsScene>
- #include <QGraphicsRectItem>
- #include <QMouseEvent>
- #include <QLabel>
- #include <QPointer>
- #include <CViewInterface.h>
- #include <QColor>
- #include <QDebug>
- #include <QPen>
- #include <QMenu>
- #include <QGraphicsSceneContextMenuEvent>
- #include <CWaferMatrix.h>
- class WaffleItem : public QObject, public QGraphicsRectItem {
- public:
- WaffleItem(ns_mat::WAFFLE_MATRIX_POINT_STRUCT point, double penSize, QGraphicsItem* parent = nullptr);
- void setSelected(bool selected);
- void setLeftSelected(bool selected);
- void setPenSize(double size);
- void WaffleItem::setRightSelected(bool selected);
- ns_mat::WAFFLE_MATRIX_POINT_STRUCT getPoint();
- private:
- // 获取单元格状态颜色
- QColor getColorByStatus();
- WAFFLE_MATRIX_POINT_STRUCT point;
- double penSize;
- protected:
- void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
- };
- class WaffleGraphicsView : public QGraphicsView {
- Q_OBJECT
- public:
- WaffleGraphicsView(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;
- QVector <QGraphicsItem*> selectedItems;
- QLabel *thumbnailLabel; // 缩略图标签
- bool thumbnailVisible; // 缩略图可见状态
- QPair<int, int> topLeftIndex;
- QPair<int, int> bottomRightIndex;
- QPointer<WaffleItem> selectedItem;
- QPointer<WaffleItem> topLeftItem;
- QPointer<WaffleItem> bottomRightItem;
- void showThumbnail();
- void hideThumbnail();
- void checkAndCreateRegion();
- void clearRegion();
- void setRegion();
- ns_module::CViewInterface* m_pCViewInterface;
- };
- #endif // WAFFLEGRAPHICSVIEW_H
|