You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
|
4 years ago
|
#ifndef __lpImgViewer_h_
|
||
|
|
#define __lpImgViewer_h_
|
||
|
|
|
||
|
|
#include <QGraphicsView>
|
||
|
|
#include <QGraphicsItem>
|
||
|
|
#include <QGraphicsScene>
|
||
|
|
#include <QLabel>
|
||
|
|
|
||
|
|
class lpImgViewer : public QGraphicsView
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
public:
|
||
|
|
lpImgViewer(QGraphicsScene *scene, QWidget *parent = 0);
|
||
|
|
lpImgViewer(QWidget* parent = 0);
|
||
|
|
~lpImgViewer(){
|
||
|
|
if (mpImg)
|
||
|
|
delete mpImg;
|
||
|
|
}
|
||
|
|
|
||
|
|
QGraphicsPixmapItem* setImg(QImage& img);
|
||
|
|
void setInfoLabel(QLabel* ipLabel){ mpInfoLabel = ipLabel; }
|
||
|
|
|
||
|
|
virtual void wheelEvent(QWheelEvent *evt);
|
||
|
|
virtual void mouseMoveEvent(QMouseEvent *evt);
|
||
|
|
virtual void resizeEvent(QResizeEvent* evt);
|
||
|
|
virtual void mouseReleaseEvent(QMouseEvent *evt);
|
||
|
|
virtual void closeEvent(QCloseEvent *evt);
|
||
|
|
virtual void clear();
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void imgScaled(QTransform tf, QPointF center);
|
||
|
|
void imgMoved(QPointF pos);
|
||
|
|
void pixelSelected(QPoint pos);
|
||
|
|
|
||
|
|
public slots:
|
||
|
|
void scaleImg(QTransform tf, QPointF center);
|
||
|
|
void moveImg(QPointF pos);
|
||
|
|
void selectPixel(QPoint pos);
|
||
|
|
|
||
|
|
private:
|
||
|
|
QGraphicsPixmapItem* mpImgItem;
|
||
|
|
QSize mImgOriSize;
|
||
|
|
QLabel* mpInfoLabel;
|
||
|
|
QImage* mpImg;
|
||
|
|
QGraphicsScene* lpScene{ nullptr };
|
||
|
|
void scaleImg2(qreal scale);
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|