9 #include <QtCore/QtPlugin>
10 #include <QtOpenGL/QtOpenGL>
16 #include <OpenGL/gl.h>
17 #include <GLUT/glut.h>
64 return QSize(400, 400);
70 switch (event->key()) {
87 normalizeAngle(&angle);
96 normalizeAngle(&angle);
105 normalizeAngle(&angle);
144 qglClearColor(QColor(0.0,0.0,0.0));
145 glShadeModel(GL_FLAT);
146 glEnable(GL_DEPTH_TEST);
147 glEnable(GL_CULL_FACE);
149 groundPlane = glGenLists(1);
150 glNewList(groundPlane, GL_COMPILE);
152 #if 1 // draw the grid
154 glDisable( GL_LIGHTING );
155 glDisable( GL_COLOR_MATERIAL ) ;
158 float interval = 1.0f;
161 glColor4f(0.5f,0.5f,1.0f,0.5f);
163 float x = - size*0.5f;
164 while( x <= size*0.5f ) {
165 glVertex3f(-size/2.0f, x, 0.01f);
166 glVertex3f(size/2.0f, x, 0.01f);
167 glVertex3f(x, -size/2.0f, 0.01f);
168 glVertex3f(x, size/2.0f, 0.01f);
175 for(r=0;r<size/2;r+=interval) {
177 for(x=0;x<(2*3.14152);x+=(2*3.14152)/(r*100)) {
178 glVertex3f(cos(x)*r, sin(x)*r, 0.01f);
189 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
191 glTranslated(0, 0, -zoom);
193 glTranslated(
double(xShift)/100.0,
double(yShift)/100.0,
double(zShift)/100.0);
194 glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
195 glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
196 glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
199 QColor color(value,value,value);
200 QColor red(255.0,0,0);
207 for(
int i=0;i<data.size();i++){
208 glVertex3f(data[i][0],data[i][1],data[i][2]);
218 glViewport(0, 0, width, height);
219 glMatrixMode(GL_PROJECTION);
221 gluPerspective( 45.0, (
float)width/(
float)height, 1.0, 1000.0 );
222 glMatrixMode(GL_MODELVIEW);
228 lastPos =
event->pos();
229 lastPosTrans =
event->pos();
238 int dxt =
event->x() - lastPosTrans.x();
239 int dyt =
event->y() - lastPosTrans.y();
241 if (event->buttons() & Qt::LeftButton) {
246 }
else if (event->buttons() & Qt::RightButton) {
247 zoom += (dyt+dxt)/10.0;
248 zoom = std::max<float>( std::min<float>( zoom, zoom_max), zoom_min );
251 lastPos =
event->pos();
252 lastPosTrans =
event->pos();
261 resize(width,height);
265 this->xShift = xMove;
266 this->yShift = yMove;
267 this->zShift = zMove;
275 zoom -= (2.0*(float)event->delta()/120.0)*5;
276 zoom = std::max<float>( std::min<float>( zoom, zoom_max ), zoom_min);
281 void RangeViewGL::normalizeAngle(
int *angle)
285 while (*angle > 360 * 16)
void setZoomMax(float value)
void setZRotation(int angle)
void setData(const std::vector< Eigen::Vector3d > data)
void xPositionChanged(int value)
void xRotationChanged(int angle)
void wheelEvent(QWheelEvent *)
void setYRotation(int angle)
void mouseMoveEvent(QMouseEvent *)
void keyPressEvent(QKeyEvent *event)
void setXRotation(int angle)
void yRotationChanged(int angle)
void setxPosition(int value)
void setzPosition(int value)
void setPosition(int xRot, int yRot, int zRot, int xMove, int yMove, int zMove, float zoom, int width, int height)
void yPositionChanged(int value)
void setyPosition(int value)
void mousePressEvent(QMouseEvent *)
RangeViewGL(ImageViewOld &parent)
void setZoomMin(float value)
QSize minimumSizeHint() const
void zRotationChanged(int angle)
void zPositionChanged(int value)