⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imageview.h

📁 c++的guiQt做的开发
💻 H
字号:
#ifndef __IMAGEVIEW_H__#define __IMAGEVIEW_H__#include "guitypes.h"#include <QScrollArea>#include <QWidget>#include <QString>#include <QSize>#include <QMap>class QPaintEvent;class QKeyEvent;class QMouseEvent;class QWheelEvent;class QPixmap;namespace gui {class Image;class ImageViewPrivate;/** Artificial limit for minimal allowed zoom. Minimum is 1 percent zoom (this mean 128000x102400 pixel (13 gigapixel) image shown on 1280x1024 screen. Should suffice for all. And for viewing sattelite imagery you need better format than classical JPEG or PNG anyway.*/const int MIN_ZOOM=1;/** Artificial limit for maximal allowed zoom. 80x magnification should be enough for everybody :)*/const int MAX_ZOOM=8000;/** enum specifying all possible modes for the widget */typedef enum { /** Just view the image */ view=0, /** Crosshair */ crosshair,} ImageViewMode;/** ImageView - class for widget displaying an image \brief Widget for viewing image*/class ImageView : public QScrollArea { Q_OBJECTpublic: ImageView(QWidget *parent=0); void loadImage(const QString &name); void loadImage(QPixmap px); bool loadImagePaste(); void saveImage(const QString &name); void cancelPicks(); bool haveImage() const; bool haveSelection() const; Image* getImage(); void setFeature(const QString &name,bool state); bool isSet(const QString &name) const; void setMode(ImageViewMode m); ~ImageView(); virtual QSize sizeHint() const; QSize minSize() const; void repaint(int x,int y,QPainter &p,const QRect &src); virtual void update(); void updateFullScreen(); void setZoom(int nzoom); void zoomStep(bool zoomIn); void zoomSteps(int steps); void mouseCoordEvent(QMouseEvent *e); void selRect(const QRect &r); QString getRect(int coord=0); QRect selectionToImageCoords(const QRect &selectionRect); QRect selectionFromImageCoords(const QRect &selectionRect); void cancelRect(); static QString channelsToString(int c);protected: virtual void resizeEvent(QResizeEvent *e); void flushImage(); void setDataRect(); void zoomStepInternal(bool zoomIn); void rectCheck(); void selText(const QString &txt); void mouseMoveEvent(QMouseEvent *e); void keyPressEvent(QKeyEvent *e); void keyReleaseEvent(QKeyEvent *e); void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); void wheelEvent (QWheelEvent *e); void scrollBy(int x,int y); void applyZoom();signals: /**  Signal emitted when the picker is cancelled  (for example by pressing ESC) */ void cancelledPick(); /**  Signal emitted when selection is changed */ void selectionChanged(); /**  Signal emitted when zoom level is changed and also when image is loaded  @param zoom new zoom level */ void zoomChanged(int zoom); /**  Info emitted (information about current pixel, etc ...)  @param txt info text */ void info(const QString &txt); /**  Information about selection coordinates emitted  @param txt info text */ void selectionInfo(const QString &txt);private: /** Rectangle in which the actual data are drawn */ QRect data_rect; /** X Mouse coordinate in image */ int mouse_x; /** Y Mouse coordinate in image */ int mouse_y; /** X mouse coordinate in the window at "last event" */ int mouse_ex; /** Y mouse coordinate in the window at "last event" */ int mouse_ey; /** current mode */ ImageViewMode mode; /** current image */ Image *image; /** Internal subwidget */ ImageViewPrivate *d; /** Zoom level in percent */ int zoom; /** Selection rectangle (in image coordinates) */ QRect selection; /** Selection text string */ QString selectionText; /** Friend class */ friend class ImageViewPrivate;};} // namespace gui#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -