#ifndef IMAGEWIDGET_H #define IMAGEWIDGET_H #include #include #include namespace Ui { class ImageWidget; } class ImageWidget : public QWidget { Q_OBJECT public: explicit ImageWidget(QWidget *parent = nullptr); ~ImageWidget(); void setPixmap(const QPixmap& pixmap); void setPixmapAndPoint(const QPixmap& pixmap, double previousScaleFactor, qreal scaleFactor, QPoint mousePos); void clearPixmap(); signals: void sendDoubleClicksignal(); protected: void paintEvent(QPaintEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; private: void DrawCrossWithScale(QPainter* painter, double dImgWidth, double dImgHeight, const QSize& sourceImageSize, const QPointF& sourceImagePosition); void drawCross(QPainter* painter, QRect rect); private: Ui::ImageWidget *ui; QPixmap pixmap; QPoint lastMousePos = {}; // 上一次鼠标的位置 QPointF imageOffset = {}; // 图片的偏移量 bool isDragging = false; // 是否正在拖动 public: /**是否是SingleCameraOperationWnd */ int m_nSingleCameraOperationWnd = false; }; #endif // IMAGEWIDGET_H