GLImageBox.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GLIMAGEBOX_H
00020 #define GLIMAGEBOX_H
00021
00022 #include <Mod/Image/App/ImageBase.h>
00023 #include <QGLWidget>
00024
00025 namespace ImageGui
00026 {
00027
00028 #define IV_DISPLAY_NOCHANGE 0 // no change to view settings when displaying a new image
00029 #define IV_DISPLAY_FITIMAGE 1 // fit-image when displaying a new image (other settings remain the same)
00030 #define IV_DISPLAY_RESET 2 // reset settings when displaying a new image (image will be displayed at 1:1 scale with no color map)
00031
00032 class ImageGuiExport GLImageBox : public QGLWidget
00033 {
00034 Q_OBJECT
00035
00036 public:
00037
00038 GLImageBox(QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0);
00039 ~GLImageBox();
00040
00041 Image::ImageBase *getImageBasePtr() { return &_image; }
00042
00043 void redraw();
00044
00045 int getImageSample(int x, int y, unsigned short sampleIndex, double &value);
00046 unsigned short getImageNumSamplesPerPix();
00047 int getImageFormat();
00048
00049 void fixBasePosCurr();
00050 double getZoomFactor() { return _zoomFactor; }
00051 void setZoomFactor(double zoomFactor, bool useCentrePt = false, int ICx = 0, int ICy = 0);
00052 void zoom(int power, bool useCentrePt = false, int ICx = 0, int ICy = 0);
00053 void stretchToFit();
00054 void setNormal();
00055 void getCentrePoint(int &ICx, int &ICy);
00056 void relMoveWC(int WCdx, int WCdy);
00057
00058 double WCToIC_X(double WidgetX);
00059 double WCToIC_Y(double WidgetY);
00060 double ICToWC_X(double ImageX);
00061 double ICToWC_Y(double ImageY);
00062
00063 void clearImage();
00064 int createImageCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, int displayMode = IV_DISPLAY_RESET);
00065 int pointImageTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership, int displayMode = IV_DISPLAY_RESET);
00066
00067 void clearColorMap();
00068 int createColorMap(int numEntriesReq = 0, bool Initialise = true);
00069 int getNumColorMapEntries() const { return _numMapEntries; }
00070 int setColorMapRGBAValue(int index, float red, float green, float blue, float alpha = 1.0);
00071 int setColorMapRedValue(int index, float value);
00072 int setColorMapGreenValue(int index, float value);
00073 int setColorMapBlueValue(int index, float value);
00074 int setColorMapAlphaValue(int index, float value);
00075 unsigned int pixValToMapIndex(double PixVal);
00076
00077 Q_SIGNALS:
00078 void drawGraphics();
00079
00080 private:
00081
00082 void initializeGL();
00083 void paintGL();
00084 void resizeGL( int w, int h );
00085
00086 void drawImage();
00087 void getDisplayedImageAreaSize(int &dx, int &dy);
00088
00089 void getPixFormat(GLenum &pixFormat, GLenum &pixType);
00090 void limitCurrPos();
00091 void limitZoomFactor();
00092 void setCurrPos(int x0, int y0);
00093 void setToFit();
00094 void resetDisplay();
00095 int calcNumColorMapEntries();
00096
00097 Image::ImageBase _image;
00098
00099 int _x0;
00100 int _y0;
00101 double _zoomFactor;
00102
00103 int _base_x0;
00104 int _base_y0;
00105
00106 float* _pColorMap;
00107 int _numMapEntries;
00108
00109 };
00110
00111
00112 }
00113
00114 #endif // GLIMAGEBOX_H