00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef RENDERERWIDGET_H_
00024 #define RENDERERWIDGET_H_
00025
00026 #include <gui/AbstractRenderer.h>
00027
00028 #include <QtOpenGL/QGLWidget>
00029 #include <QtGui/QMouseEvent>
00030 #include <vector>
00031 #include <algorithm>
00032 #include <iostream>
00033
00034 class RendererWidget: public QGLWidget{
00035 Q_OBJECT
00036 public:
00037 RendererWidget(QWidget *_parent = 0);
00038 inline void addRenderer(AbstractRenderer* _renderer)
00039 {m_renderObject.push_back(_renderer);}
00040 inline void removeRenderer(AbstractRenderer* _renderer)
00041 {m_renderObject.erase(std::find(m_renderObject.begin(), m_renderObject.end(), _renderer));}
00042
00043 void unprojectCoordinates(GLdouble viewX, GLdouble viewY, GLdouble viewZ, GLdouble* worldX, GLdouble* worldY, GLdouble* worldZ);
00044 void unprojectCoordinates(GLdouble viewX, GLdouble viewY, GLdouble* worldX, GLdouble* worldY, GLdouble* worldZ);
00045
00046 signals:
00047 void mousePressedGL(int button, int x, int y);
00048 void mouseMovedGL(int button, int x1, int y1, int x2, int y2);
00049
00050 public slots:
00051 void setLaserPose(float _x, float _y, float _theta = 0);
00052 void setRotation(float _x, float _y, float _z);
00053 void setOffset(float _x, float _y, float _z);
00054 void setScale(float _scale);
00055 void makeSnapshot(const char * _filename);
00056
00057 protected:
00058 virtual void initializeGL();
00059 virtual void resizeGL(int _width, int _height);
00060 virtual void paintGL();
00061
00062 virtual void mousePressEvent(QMouseEvent *_event);
00063 virtual void mouseReleaseEvent(QMouseEvent *_event);
00064 virtual void mouseMoveEvent(QMouseEvent *_event);
00065 virtual void wheelEvent(QWheelEvent *_event);
00066
00067 std::vector<AbstractRenderer * > m_renderObject;
00068
00069 GLdouble m_GLdefaultDepth;
00070
00071 float m_laserPoseX;
00072 float m_laserPoseY;
00073 float m_laserPoseTheta;
00074
00075 float m_rotationX;
00076 float m_rotationY;
00077 float m_rotationZ;
00078 float m_offsetX;
00079 float m_offsetY;
00080 float m_offsetZ;
00081 float m_scale;
00082
00083 QPoint m_lastMousePosition;
00084 QPoint m_lastMousePressPosition;
00085 };
00086
00087 #endif