|
|
|
|
|
#ifndef _H_LPIMGVIEWER_H_
|
|
|
|
|
|
#define _H_LPIMGVIEWER_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
|
|
|
|
typedef QImage (*ImageScaleFun)(QImage, double, int);
|
|
|
|
|
|
|
|
|
|
|
|
class lpImgViewer : public QGraphicsView
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
static QString pixelInfoStr(QPoint pos, QRgb rgb);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
lpImgViewer(QGraphicsScene *scene, QWidget *parent = 0);
|
|
|
|
|
|
lpImgViewer(QWidget* parent = 0);
|
|
|
|
|
|
virtual ~lpImgViewer(){
|
|
|
|
|
|
if (mpImg)
|
|
|
|
|
|
delete mpImg;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual QGraphicsPixmapItem* setImg(QImage& img);
|
|
|
|
|
|
void setInfoLabel(QLabel* ipLabel){ mpInfoLabel = ipLabel; }
|
|
|
|
|
|
void setResetCenter();
|
|
|
|
|
|
const QImage* img() { return mpImg; }
|
|
|
|
|
|
QGraphicsPixmapItem* imgItem() { return mpImgItem; }
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
virtual const qreal getScale(void) const { return m_scale; };
|
|
|
|
|
|
virtual void setChannel(const QString& channel) { m_channel = channel; }
|
|
|
|
|
|
virtual QString getChannel() const { return m_channel; }
|
|
|
|
|
|
bool isFixedSizeScale() const { return mIsFixedSizeScale; }
|
|
|
|
|
|
void setIsFixedSizeScale(bool val) { mIsFixedSizeScale = val; }
|
|
|
|
|
|
qreal fixedSizeScale() const { return mFixedSizeScale; }
|
|
|
|
|
|
void setFixedSizeScale(qreal val) { mFixedSizeScale = val; }
|
|
|
|
|
|
ImageScaleFun imgScaleFunc() const { return mImgScaleFunc; }
|
|
|
|
|
|
void setImgScaleFunc(ImageScaleFun val) { mImgScaleFunc = val; }
|
|
|
|
|
|
void setInitScale(qreal val);
|
|
|
|
|
|
|
|
|
|
|
|
bool isAutoResetTransform() const { return mIsAutoResetTransform; }
|
|
|
|
|
|
void setIsAutoResetTransform(bool val) { mIsAutoResetTransform = val; }
|
|
|
|
|
|
bool isAutoResetToWindowSize() const { return mIsAutoResetToWindowSize; }
|
|
|
|
|
|
void setIsAutoResetToWindowSize(bool val) { mIsAutoResetToWindowSize = val; }
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void imgScaled(QTransform tf, QPointF center);
|
|
|
|
|
|
void imgMoved(QPointF pos);
|
|
|
|
|
|
void pixelSelected(QPoint pos);
|
|
|
|
|
|
void imgScaledWithFixedSize(qreal scale);
|
|
|
|
|
|
void sgImageScale(qreal);
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
void scaleImg(QTransform tf, QPointF center);
|
|
|
|
|
|
void moveImg(QPointF pos);
|
|
|
|
|
|
void selectPixel(QPoint pos);
|
|
|
|
|
|
void scaleImageWithFixedViewSize();
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
QGraphicsPixmapItem* mpImgItem{ nullptr };
|
|
|
|
|
|
QSize mImgOriSize;
|
|
|
|
|
|
qreal mMinScaleThre;
|
|
|
|
|
|
QLabel* mpInfoLabel{ nullptr };
|
|
|
|
|
|
QImage* mpImg{ nullptr };
|
|
|
|
|
|
|
|
|
|
|
|
void scaleImg2(qreal scale);
|
|
|
|
|
|
qreal m_scale;
|
|
|
|
|
|
QString m_channel;
|
|
|
|
|
|
|
|
|
|
|
|
bool mIsFixedSizeScale;
|
|
|
|
|
|
qreal mFixedSizeScale;
|
|
|
|
|
|
bool mIsAutoResetTransform;
|
|
|
|
|
|
bool mIsAutoResetToWindowSize;
|
|
|
|
|
|
|
|
|
|
|
|
ImageScaleFun mImgScaleFunc;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|