Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef GLImageWidget_H
00011 #define GLImageWidget_H
00012
00013 #include <vector>
00014 #include <iostream>
00015 #include <cmath>
00016 #include <QRgb>
00017 #include <QGLWidget>
00018
00019 #include "../../Workers/Puma2/ColorImageRGB8.h"
00020 #include "../../Workers/Puma2/GrayLevelImage8.h"
00021 #include "../../Workers/Puma2/ColorImageUV8.h"
00022
00023 #include "../../Devices/ImageGrabber/ImageGrabber.h"
00024 #include "Workers/Math/Box2D.h"
00025 #include "Workers/Math/Circle2D.h"
00026 #include "../../Workers/VectorGraphics/VectorObject2D.h"
00027
00032 class GLImageWidget : public QGLWidget {
00033
00034 Q_OBJECT
00035
00036 public:
00037 GLImageWidget(QGLWidget *parent = 0);
00038 ~GLImageWidget();
00039
00040 public slots:
00041
00043 void setColorImage(const unsigned char *image, unsigned width, unsigned height, float aspect=1.0 );
00044 void setColorImage(const puma2::ColorImageRGB8* image, float aspect=1.0 );
00045 void setColorImage(const puma2::GrayLevelImage8* imageY, const puma2::ColorImageUV8* imageUV, float aspect=1.0 );
00046 void setThermalImage(const puma2::GrayLevelImage8* image, float roomTemp=30.0 );
00047 void setGrayLevelImage(const puma2::GrayLevelImage8* image, float aspect=1.0 );
00048
00049 void setAnaglyphImage( const puma2::GrayLevelImage8* leftYImage, const puma2::GrayLevelImage8* rightYImage, float aspect=1.0 );
00050
00055 void setPixelAspectRatio(float ratio) { m_PixelAspectRatio=ratio; };
00056
00058 void addVectorObject( VectorObject2D vectorObject );
00059
00061 void clearForms();
00062
00063 void saveImage( std::string filename );
00064
00066 void zoom(float z);
00067
00068 private:
00069
00071 void paintImage();
00072
00074 void paintVectorObjects();
00075
00077 void initializeGL();
00078
00080 void resizeGL(int w, int h);
00081
00083 void paintGL();
00084
00085
00086
00088 void mouseDoubleClickEvent(QMouseEvent *event);
00089
00091 void mousePressEvent(QMouseEvent *event);
00092
00094 void mouseMoveEvent(QMouseEvent* event);
00095
00097 void wheelEvent(QWheelEvent *event);
00098
00099
00100
00101
00102
00103 int calcTextureSize( int width, int height );
00104
00105
00106 protected :
00107
00108 void initTexture( unsigned resolution, unsigned imageWidth, unsigned imageHeight, ImageGrabber::ColorFormat textureFormat );
00109 void updateTexture( unsigned char* imageData, unsigned width, unsigned height, ImageGrabber::ColorFormat format );
00110 void clearTexture();
00111
00112 QPoint m_MousePosOld;
00113
00114 float m_Zoom;
00115 float m_PosX;
00116 float m_PosY;
00117
00118 unsigned m_ImageWidth;
00119 unsigned m_ImageHeight;
00120
00121 unsigned m_ViewportWidth;
00122 unsigned m_ViewportHeight;
00123
00124 float m_PixelAspectRatio;
00125
00127 unsigned m_TextureResolution;
00128
00129 GLuint m_TextureId;
00130 unsigned char* m_TextureData;
00131 ImageGrabber::ColorFormat m_TextureFormat;
00132 unsigned int m_TextureByteSize;
00133
00134 std::list< VectorObject2D > m_VectorObjects;
00135
00136 };
00137
00138 #endif