rock_widget_collection  0.1
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SonarViewGL Class Reference

#include <SonarViewGL.h>

Inherits ImageViewOldGL.

Public Slots

void repaintFunc ()
 
void setXRotation (int angle)
 
void setYRotation (int angle)
 
void setZRotation (int angle)
 
void setxPosition (int value)
 
void setyPosition (int value)
 
void setzPosition (int value)
 
void setWallDist (int bearing, int dist, int dist2)
 
void keyPressEvent (QKeyEvent *event)
 
void setPosition (const double posX, const double posY, const double sigmaX=0, const double sigmaY=0)
 
void setOrientation (const double orientation)
 
void setZoomMin (float value)
 
void setZoomMax (float value)
 

Signals

void xRotationChanged (int angle)
 
void yRotationChanged (int angle)
 
void zRotationChanged (int angle)
 
void xPositionChanged (int value)
 
void yPositionChanged (int value)
 
void zPositionChanged (int value)
 

Public Member Functions

 SonarViewGL (ImageViewOld &parent, unsigned int maximumBearings=6400)
 
virtual ~SonarViewGL ()
 
QSize minimumSizeHint () const
 
QSize sizeHint () const
 
void setPosition (int xRot, int yRot, int zRot, int xMove, int yMove, int zMove, float zoom, int width, int height)
 
void setData (const std::vector< uint8_t > data, int bearing)
 
void reset (double currentScale)
 
void setGroundTrue (double sizeX, double sizeY, double posX, double posY, double rot)
 
void drawEllipse (float xradius, float yradius)
 
- Public Member Functions inherited from ImageViewOldGL
 ImageViewOldGL (ImageViewOld &parent)
 
virtual ~ImageViewOldGL ()
 
void setGLViewPoint (int display_width=0, int display_height=0)
 
void setAspectRatio (bool value)
 

Protected Member Functions

void initializeGL ()
 
void paintGL ()
 
void resizeGL (int width, int height)
 
void mousePressEvent (QMouseEvent *event)
 
void mouseMoveEvent (QMouseEvent *event)
 
void wheelEvent (QWheelEvent *event)
 
void checkGL (const char *)
 
void drawList ()
 
void drawFaces ()
 
void drawSurfaces ()
 
void paintSonar ()
 
GLuint makeObject ()
 
GLuint show_pointcloud ()
 
void normalizeAngle (int *angle)
 
void createAvalon ()
 
double max (double a, double b)
 

Protected Attributes

bool deleteSurfaces
 
int cloudSize
 
double factor
 
GLuint groundPlane
 
float zoom
 
float zoom_min
 
float zoom_max
 
int lastBearing
 
int lastWallBearing
 
double orientation
 
const unsigned int maximumBearings
 
std::vector< std::pair< GLuint, QColor > > colorList
 
GLuint * wallDist
 
GLuint * bearingList
 
GLuint groundTrue
 
GLuint avalon
 
bool * bearingChanged
 
bool * listValid
 
bool dataChanged
 
bool paintGroundTrue
 
bool paintWall
 
int xRot
 
int yRot
 
int zRot
 
int xShift
 
int yShift
 
int zShift
 
int medium_ableitung
 
int overlay_border
 
double currentScale
 
double pos [2]
 
double sigmaPos [2]
 
unsigned int oldSize
 
volatile GLuint * indices
 
volatile GLubyte * colors
 
volatile GLfloat * vertecies
 
QPoint lastPos
 
QPoint lastPosTrans
 
QTimer repaintTimer
 
QMutex mutex
 

Detailed Description

Definition at line 15 of file SonarViewGL.h.

Constructor & Destructor Documentation

SonarViewGL::SonarViewGL ( ImageViewOld parent,
unsigned int  maximumBearings = 6400 
)

Definition at line 24 of file SonarViewGL.cc.

24  :
25 ImageViewOldGL(parent),
27 {
28  colors = new GLubyte[maximumBearings];
29  vertecies = new GLfloat[maximumBearings];
30  indices = new GLuint[maximumBearings];
31  wallDist = new GLuint[maximumBearings];
32  bearingList = new GLuint[maximumBearings];
33 
34  bearingChanged = new bool[maximumBearings];
35  listValid = new bool[maximumBearings];
36 
37  xRot = 0;//180*16;
38  yRot = 180*16;
39  zRot = 0;
40  xShift = 0;
41  yShift = 0;
42  zShift = 0;
43  zoom = 40;
44  zoom_min = -6000.0;
45  zoom_max = 6000.0;
48  factor=1;
49  //repaintTimer.setSingleShot(false);
50  //repaintTimer.setInterval(100);
51  //connect(&repaintTimer,SIGNAL(timeout()),this,SLOT(repaintFunc()));
52  //repaintTimer.start();
53 
54  for(int i=0;i<maximumBearings;i++){
55  glDeleteLists(bearingList[i], 1);
56  glDeleteLists(wallDist[i], 1);
57  bearingList[i] = glGenLists( 1 );
58  wallDist[i] = glGenLists( 1 );
59  glNewList( wallDist[i], GL_COMPILE );
60  glEndList();
61  glNewList( bearingList[i], GL_COMPILE );
62  glEndList();
63 // listValid=false;
64  }
65  createAvalon();
66  paintGroundTrue=true;
67  paintWall=true;
68  lastBearing=0;
70 }
double factor
Definition: SonarViewGL.h:60
GLuint * wallDist
Definition: SonarViewGL.h:77
ImageViewOldGL(ImageViewOld &parent)
const unsigned int maximumBearings
Definition: SonarViewGL.h:74
float zoom_max
Definition: SonarViewGL.h:66
GLuint * bearingList
Definition: SonarViewGL.h:77
int medium_ableitung
Definition: SonarViewGL.h:89
float zoom_min
Definition: SonarViewGL.h:66
int lastWallBearing
Definition: SonarViewGL.h:68
void createAvalon()
Definition: SonarViewGL.cc:679
int overlay_border
Definition: SonarViewGL.h:90
bool * bearingChanged
Definition: SonarViewGL.h:79
bool * listValid
Definition: SonarViewGL.h:79
volatile GLuint * indices
Definition: SonarViewGL.h:97
float zoom
Definition: SonarViewGL.h:66
volatile GLfloat * vertecies
Definition: SonarViewGL.h:99
int lastBearing
Definition: SonarViewGL.h:67
bool paintGroundTrue
Definition: SonarViewGL.h:81
volatile GLubyte * colors
Definition: SonarViewGL.h:98
bool paintWall
Definition: SonarViewGL.h:81
SonarViewGL::~SonarViewGL ( )
virtual

Definition at line 297 of file SonarViewGL.cc.

298 {
299  //glDeleteLists(object, 1);
300 }

Member Function Documentation

void SonarViewGL::checkGL ( const char *  msg)
protected

Definition at line 709 of file SonarViewGL.cc.

709  {
710  GLenum err = glGetError();
711  switch(err){
712  case GL_NO_ERROR:
713  break;
714  case GL_INVALID_ENUM:
715  printf("%s: Invalid enum\n",msg);
716  break;
717  case GL_INVALID_VALUE:
718  printf("%s: invalid value\n",msg);
719  break;
720  case GL_INVALID_OPERATION:
721  printf("%s: invalid operation\n",msg);
722  break;
723  case GL_STACK_OVERFLOW:
724  printf("%s: stack overflow\n",msg);
725  break;
726  case GL_STACK_UNDERFLOW:
727  printf("%s: stack underflow\n",msg);
728  break;
729  case GL_OUT_OF_MEMORY:
730  printf("%s: OpenGL Put of memoty\n",msg);
731  break;
732  case GL_TABLE_TOO_LARGE:
733  printf("%s: GL Table too large\n",msg);
734  break;
735  }
736 }
void SonarViewGL::createAvalon ( )
protected

Definition at line 679 of file SonarViewGL.cc.

679  {
680  glDeleteLists(avalon, 1);
681  avalon= glGenLists( 1 );
682  glNewList( avalon, GL_COMPILE );
683  //checkGL("after list create");
684  glPushMatrix();
685  qglColor(Qt::cyan);
686  //glTranslated(posX, posY, 0);
687  //glRotated( rotate, 0.0, 0.0, 1.0);
688  glBegin(GL_LINE_LOOP);
689  glVertex3d(-1,0.2,0);
690  glVertex3d(1,0.2,0);
691  glVertex3d(1,-0.2,0);
692  glVertex3d(-1,-0.2,0);
693  glEnd();
694  glPopMatrix();
695  glEndList();
696  //checkGL("end of set ground true:");
697 }
GLuint avalon
Definition: SonarViewGL.h:78
void SonarViewGL::drawEllipse ( float  xradius,
float  yradius 
)

Definition at line 434 of file SonarViewGL.cc.

435 {
436  glBegin(GL_LINE_LOOP);
437  for(int i=0; i < 360; i++)
438  {
439  glVertex2f(cos(i/180.0*M_PI)*xradius,sin(i/180.0*M_PI)*yradius);
440  }
441  glEnd();
442 }
void SonarViewGL::drawFaces ( )
protected
void SonarViewGL::drawList ( )
protected
void SonarViewGL::drawSurfaces ( )
protected
void SonarViewGL::initializeGL ( )
protected

Definition at line 362 of file SonarViewGL.cc.

363 {
364  //qglClearColor(QColor(0.1,0.1,0.0));
365  //qglClearColor(purple.light());
366  //qglClearColor(white);
367  qglClearColor(QColor(0.0,0.0,0.0));
368  glShadeModel(GL_FLAT);
369 
370  glEnable(GL_DEPTH_TEST);
371  //glDisable(GL_DEPTH_TEST);
372  //glEnable(GL_CULL_FACE);
373  //glDepthFunc(GL_ALWAYS);
374  //glDepthFunc(GL_LESS);
375  glDepthFunc(GL_LEQUAL);
376 // glClearDepth(0.0);
377  //glDepthFunc(GL_GEQUAL);
378 /*
379  GLfloat fogColor[4] = {0.5,0.5,0.5,1.0};
380 
381  glFogi (GL_FOG_MODE, GL_LINEAR); //set the fog mode to GL_EXP2
382  glFogfv (GL_FOG_COLOR, fogColor ); //set the fog color to our color chosen above
383  glFogf (GL_FOG_DENSITY, 0.5); //set the density to the value above
384  glHint (GL_FOG_HINT, GL_NICEST); // set the fog to look the nicest, may slow down on older cards
385 
386  glFogf(GL_FOG_START, 1.0f); // Fog Start Depth
387  glFogf(GL_FOG_END, 100.0f); // Fog End Depth
388  glDisable(GL_FOG); // Enables GL_FOG
389 
390  glEnable (GL_BLEND);
391  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
392 
393  glEnable(GL_POINT_SMOOTH);
394  glEnable(GL_LINE_SMOOTH);
395 */
396 
397  groundPlane = glGenLists(1);
398  glNewList(groundPlane, GL_COMPILE);
399 
400  #if 1
401  // draw the grid
402  glDisable( GL_LIGHTING );
403  glDisable( GL_COLOR_MATERIAL ) ;
404 
405  float size = 50.0f;
406  float interval = 1.0f;
407 
408 
409  glColor4f(0.5f,0.5f,1.0f,0.5f);
410  glBegin(GL_LINES);
411  float x = - size*0.5f;
412  while( x <= size*0.5f ) {
413  glVertex3f(-size/2.0f, x, 0.01f);
414  glVertex3f(size/2.0f, x, 0.01f);
415  glVertex3f(x, -size/2.0f, 0.01f);
416  glVertex3f(x, size/2.0f, 0.01f);
417  x += interval;
418  }
419  glEnd();
420 
421  // draw concentric circles
422  float r;
423  for(r=0;r<size/2;r+=interval) {
424  glBegin(GL_LINES);
425  for(x=0;x<(2*3.14152);x+=(2*3.14152)/(r*100)) {
426  glVertex3f(cos(x)*r, sin(x)*r, 0.01f);
427  }
428  glEnd();
429  }
430  glEndList();
431  #endif
432 }
GLuint groundPlane
Definition: SonarViewGL.h:63
void SonarViewGL::keyPressEvent ( QKeyEvent *  event)
slot

Definition at line 606 of file SonarViewGL.cc.

606  {
607  switch (event->key()) {
608  case Qt::Key_W:
610  case Qt::Key_G:
612  break;
613  case Qt::Key_Q:
614  //Exit or do something
615  break;
616  case Qt::Key_I:
617  factor+=0.02;
618  printf("Gain %f\n",factor);
619  //Exit or do something
620  break;
621  case Qt::Key_D:
622  factor-=0.02;
623  printf("Gain %f\n",factor);
624  //Exit or do something
625  break;
626  case Qt::Key_O:
627  overlay_border+=1;
628  printf("Overlay border: %i\n",overlay_border);
629  break;
630  case Qt::Key_L:
631  overlay_border-=1;
632  printf("Overlay border: %i\n",overlay_border);
633  break;
634  case Qt::Key_A:
635  medium_ableitung+=1;
636  printf("Ableitungglaettung: %i\n",medium_ableitung);
637  break;
638  case Qt::Key_Y:
639  medium_ableitung-=1;
640  printf("Ableitungglaettung: %i\n",medium_ableitung);
641  break;
642  default:
643  return;
644  }
645  repaintFunc();
646  }
double factor
Definition: SonarViewGL.h:60
int medium_ableitung
Definition: SonarViewGL.h:89
int overlay_border
Definition: SonarViewGL.h:90
void repaintFunc()
Definition: SonarViewGL.cc:291
bool paintGroundTrue
Definition: SonarViewGL.h:81
bool paintWall
Definition: SonarViewGL.h:81
GLuint SonarViewGL::makeObject ( )
protected
double SonarViewGL::max ( double  a,
double  b 
)
inlineprotected

Definition at line 71 of file SonarViewGL.h.

71  {
72  return (a>b)?a:b;
73  }
QSize SonarViewGL::minimumSizeHint ( ) const

Definition at line 302 of file SonarViewGL.cc.

303 {
304  return QSize(50, 50);
305 }
void SonarViewGL::mouseMoveEvent ( QMouseEvent *  event)
protected

Definition at line 565 of file SonarViewGL.cc.

566  {
567  //int dx = event->x() - lastPos.x();
568  //int dy = event->y() - lastPos.y();
569 
570  int dxt = event->x() - lastPosTrans.x();
571  int dyt = event->y() - lastPosTrans.y();
572 
573  if (event->buttons() & Qt::LeftButton) {
574  //setXRotation(xRot + 8 * dy);
575  //setZRotation(zRot + 8 * dx);
576  setxPosition(xShift + dxt);
577  setyPosition(yShift - dyt);
578  }else if (event->buttons() & Qt::RightButton) {
579  zoom += (dyt+dxt)*0.05;
580  zoom = std::max<float>( std::min<float>( zoom, zoom_max ), zoom_min);
581  }
582 
583  lastPos = event->pos();
584  lastPosTrans = event->pos();
585 
586 // printf("Rot: %i,%i,%i, Pos, (%i,%i,%i), zoom: %f\n",xRot,yRot,zRot,xShift,yShift,zShift,zoom);
587 
588  repaintFunc();
589  }
void setyPosition(int value)
Definition: SonarViewGL.cc:349
QPoint lastPosTrans
Definition: SonarViewGL.h:101
void setxPosition(int value)
Definition: SonarViewGL.cc:342
float zoom_max
Definition: SonarViewGL.h:66
float zoom_min
Definition: SonarViewGL.h:66
void repaintFunc()
Definition: SonarViewGL.cc:291
float zoom
Definition: SonarViewGL.h:66
QPoint lastPos
Definition: SonarViewGL.h:100
void SonarViewGL::mousePressEvent ( QMouseEvent *  event)
protected

Definition at line 558 of file SonarViewGL.cc.

559  {
560  lastPos = event->pos();
561  lastPosTrans = event->pos();
562  repaintFunc();
563  }
QPoint lastPosTrans
Definition: SonarViewGL.h:101
void repaintFunc()
Definition: SonarViewGL.cc:291
QPoint lastPos
Definition: SonarViewGL.h:100
void SonarViewGL::normalizeAngle ( int *  angle)
protected

Definition at line 700 of file SonarViewGL.cc.

701  {
702  while (*angle < 0)
703  *angle += 360 * 16;
704  while (*angle > 360 * 16)
705  *angle -= 360 * 16;
706  }
void SonarViewGL::paintGL ( )
protected

Definition at line 446 of file SonarViewGL.cc.

446  {
447 // printf("PaintGL\n");
448  //set gui
449 // mutex.lock();
450  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
451  glLoadIdentity();
452  glTranslated(0, 0, -zoom);
453 
454  //glMultMatrixf(camera);
455  //set movments
456  glTranslated(double(xShift)/100.0+pos[0], double(yShift)/100.0+pos[1], double(zShift)/100.0);
457  glRotated(orientation, 1.0, 0.0, 0.0);
458  glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
459  glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
460  glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
461 
462 
463  QColor color("yellow");
464  qglColor(color);
466 
467  //gllDist
468  // wlCallList(point_list);
469  //glCallList(groundPlane);
470  //Wegen Nebenläufigkeit die Punkte im GUI Thread zeichnen.
471  //if(paintGroundTrue)
472 // if(glIsList(groundTrue))
473 // glCallList(groundTrue);
474  // else
475  // printf("Error gorund true is not an list\n");
476  if(glIsList(avalon))
477  glCallList(avalon);
478 
479 
480 
481  //for(unsigned int i=0;i<colorList.size();i++){
482  // glCallList(colorList[i].first);
483  //}
484 // if(paintWall)
485  for(int i=0;i<maximumBearings;i++){
486  if(glIsList(wallDist[i])){
487  glCallList(wallDist[i]);
488  }
489  }
490  for(int i=0;i<maximumBearings;i++){
491  if(glIsList(bearingList[i])){
492  glCallList(bearingList[i]);
493  }
494  }
495 
496  // mutex.unlock();
497  //printf("Paint gl end\n");
498  }
double sigmaPos[2]
Definition: SonarViewGL.h:93
GLuint * wallDist
Definition: SonarViewGL.h:77
const unsigned int maximumBearings
Definition: SonarViewGL.h:74
GLuint * bearingList
Definition: SonarViewGL.h:77
void drawEllipse(float xradius, float yradius)
Definition: SonarViewGL.cc:434
double orientation
Definition: SonarViewGL.h:69
float zoom
Definition: SonarViewGL.h:66
GLuint avalon
Definition: SonarViewGL.h:78
double pos[2]
Definition: SonarViewGL.h:92
void SonarViewGL::paintSonar ( )
protected

Definition at line 287 of file SonarViewGL.cc.

287  {
288 }
void SonarViewGL::repaintFunc ( )
slot

Definition at line 291 of file SonarViewGL.cc.

291  {
292  update();
293  updateGL(); //TODO not calling this?
294 
295 }
void SonarViewGL::reset ( double  currentScale)

Definition at line 74 of file SonarViewGL.cc.

74  {
75  this->currentScale = currentScale;
76  createAvalon();
77 // mutex.lock();
78  for(int i=0;i<maximumBearings;i++){
79  glDeleteLists(bearingList[i], 1);
80  bearingList[i] = glGenLists( 1 );
81  glNewList( bearingList[i], GL_COMPILE );
82  glEndList();
83 // listValid=false;
84  }
85 // listValid[i]=false;
86 //
87 //
88  for(int i=0;i<maximumBearings;i++){
89  glDeleteLists(wallDist[i], 1);
90  wallDist[i] = glGenLists( 1 );
91  glNewList( wallDist[i], GL_COMPILE );
92  glEndList();
93  lastBearing=0;
95  }
96 // mutex.unlock();
97 }
GLuint * wallDist
Definition: SonarViewGL.h:77
double currentScale
Definition: SonarViewGL.h:91
const unsigned int maximumBearings
Definition: SonarViewGL.h:74
GLuint * bearingList
Definition: SonarViewGL.h:77
int lastWallBearing
Definition: SonarViewGL.h:68
void createAvalon()
Definition: SonarViewGL.cc:679
int lastBearing
Definition: SonarViewGL.h:67
void SonarViewGL::resizeGL ( int  width,
int  height 
)
protected

Definition at line 549 of file SonarViewGL.cc.

550  {
551  glViewport(0, 0, width, height);
552  glMatrixMode(GL_PROJECTION);
553  glLoadIdentity();
554  gluPerspective( 45.0, (float)width/(float)height, 1.0, 1000.0 );
555  glMatrixMode(GL_MODELVIEW);
556  }
void SonarViewGL::setData ( const std::vector< uint8_t >  data,
int  bearing 
)

Definition at line 102 of file SonarViewGL.cc.

102  {
103 // printf("Bearing %i\n",bearing);
104  //for(int i=0;i<data.size();i++){
105  // if(data[i]!= 0){
106  // printf("Got data value :%i\n",data[i]);
107  //}
108  //}
109 
110  if(bearing < 0 || bearing > maximumBearings){
111  fprintf(stderr,"Cannot Set bearing is out of range\n");
112  }
113 
114  if(data.size() != oldSize){
115  printf("deleteing lists new Size is: %i\n",(int)data.size());
116  oldSize = data.size();
117  delete colors;
118  delete indices;
119  delete vertecies;
120  colors = new GLubyte[data.size()*3*maximumBearings];
121  vertecies = new GLfloat[data.size()*3*maximumBearings];
122  indices = new GLuint[data.size()*3*maximumBearings];
123  //uint16_t c=0;
124  for(unsigned int i=0;i<data.size()*3*maximumBearings; i++){
125  colors[i]=0;
126  vertecies[i]=0;
127 
128  //if((i%3)==0){
129  // vertecies[i]=0.001*(i%6399);
130  // colors[i]=++c;
131  //}else{
132  // colors[i]=c;
133  // vertecies[i]=0;
134  //}
135  indices[i]=i;
136  }
137  }
138  int begin,end;
139  if(lastBearing-bearing>0 || lastBearing-bearing < -3000){
140  begin = lastBearing;
141  end = lastBearing-bearing;
142  }else{
143  begin = bearing;
144  end = bearing-lastBearing;
145  }
146 
147 
148  for(int j=0;j<end;j++){
149  int i = ((begin+j));
150  if(i < 0 || i > 6399){
151  fprintf(stderr,"Error in glwidet, please check value make no sense, prevent crash, not displaying data for index %i (%s:%i)\n",i,__FILE__,__LINE__);
152  break;
153  }
154 
155 
156  for(unsigned int k=0; k<data.size(); k+=3){
157  int value=data[k]*factor;
158  if(value<0)value=0;
159  if(value>255)value=255;
160  colors[k+0 + i*data.size()*3] = value;
161  colors[k+1 + i*data.size()*3 ] = value;
162  colors[k+2 + i*data.size()*3 ] = value;
163  }
164 
165  for(unsigned int k=0; k<data.size(); k+=3){
166  vertecies[k+0 + i*data.size()*3] = k*currentScale;
167  vertecies[k+1 + i*data.size()*3] = 0;
168  vertecies[k+2 + i*data.size()*3] = 0;
169  }
170  glDeleteLists(wallDist[i],1);
171  wallDist[i] = glGenLists( 1 );
172  glNewList( wallDist[i], GL_COMPILE );
173  glEndList();
174 
175  glDeleteLists(bearingList[i], 1);
176  bearingList[i] = glGenLists( 1 );
177  glNewList( bearingList[i], GL_COMPILE );
178  glEnableClientState(GL_COLOR_ARRAY);
179  glEnableClientState(GL_VERTEX_ARRAY);
180  glColorPointer(3,GL_UNSIGNED_BYTE,0,(void*)colors);
181  glVertexPointer(3,GL_FLOAT,0,(void*)vertecies);
182  glPushMatrix();
183  double rotate = (double)i/6399.0*360.0;
184  glRotated( rotate , 0.0, 0.0, 1.0);
185  //if(i == 300){
186  // printf("Making for bearing: %i Color: %i, value: %f index: %i\n ",i, colors[300+i*data.size()],vertecies[300+i*data.size()],indices[300+i*data.size()]);
187  if(i*data.size() > data.size()*3*maximumBearings){
188  fprintf(stderr,"CRITIACAL ERROR\n");
189  }
190  //glPolygonOffset(i,1e-10);
191  volatile GLuint *baseIndex = &indices[i*(data.size())];
192  //glDrawElements(GL_LINES, data.size(), GL_UNSIGNED_INT, (void*)baseIndex);
193  //glDrawElements(GL_LINES, data.size(), GL_UNSIGNED_INT, (void*)baseIndex);
194  //glDrawElements(GL_LINE_STRIP, data.size(), GL_UNSIGNED_INT, (void*)baseIndex);
195  glDrawElements(GL_POINTS, data.size(), GL_UNSIGNED_INT, (void*)baseIndex);
196  //
197 /*
198  glBegin(GL_LINE_STRIP);
199  for(unsigned int k=0; k<data.size(); k++){
200  double value=colors[k + i*data.size()]; //data[k]*factor;
201  if(value<0)value=0;
202  if(value>255)value=255;
203  QColor color(value,value,value);
204  qglColor(color);
205  double pos = vertecies[k + i*data.size()];
206  glVertex3f(k*currentScale,0,0);
207  }
208  glEnd();
209  */
210 
211  //}
212  checkGL((const char*)"after Draw");
213  glPopMatrix();
214  glDisableClientState(GL_COLOR_ARRAY);
215  glDisableClientState(GL_VERTEX_ARRAY);
216  glEndList();
217  }
218 
219 
220 
221 /*
222 
223  for(unsigned int k=0; k<data.size(); k++){
224  double value=data[k]*factor;
225  if(value<0)value=0;
226  if(value>255)value=255;
227  QColor color(value,value,value);
228  qglColor(color);
229  glVertex3f(k*currentScale,0,0);
230  }
231  glEnd();
232  */
233 
234 
235 #if 0
236  if(false){ //Paint the overlay
237  glBegin(GL_LINE_STRIP);
238  int p_max = 0;
239  int point;
240  for(unsigned int k=medium_ableitung; k<data.size()-medium_ableitung; k++){
241  int prevalues =0;
242  int aftervalues=0;
243  for(int p=1;p<medium_ableitung;p++){
244 
245  prevalues += max((data[k-p] - data[(int)max((k/2-p),0)]),0);
246  aftervalues += max((data[k+p] - data[(k/2+p)]),0);
247  }
248  double value= (((prevalues - aftervalues)*data[k])) *factor;
249  if(value<0)value=0;
250  if(value>255)value=255.0;
251 
252  if(value > p_max && k >10){
253  p_max=value;
254  point = k*currentScale;
255  }
256  QColor color(value,value,value);
257  qglColor(color);
258 
259  glVertex3f(k*currentScale,0,0);
260  /*
261  if(overlay_border >0){
262  if(value >= overlay_border)
263  glVertex3f(k*currentScale,0,0);
264  }else{
265  if(value < overlay_border)
266  glVertex3f(k*currentScale,0,0);
267 
268  }
269  */
270  }
271  glEnd();
272 
273  glBegin(GL_LINE_STRIP);//;GL_POINTS);
274  QColor color("red");
275  qglColor(color);
276  glVertex3f(0,0,0);
277  glVertex3f(point,0,0);
278  glEnd();
279  }
280 #endif
281 // }
282 
283  lastBearing = bearing;
284 // mutex.unlock();
285 }
double factor
Definition: SonarViewGL.h:60
GLuint * wallDist
Definition: SonarViewGL.h:77
double currentScale
Definition: SonarViewGL.h:91
const unsigned int maximumBearings
Definition: SonarViewGL.h:74
GLuint * bearingList
Definition: SonarViewGL.h:77
int medium_ableitung
Definition: SonarViewGL.h:89
double max(double a, double b)
Definition: SonarViewGL.h:71
volatile GLuint * indices
Definition: SonarViewGL.h:97
void checkGL(const char *)
Definition: SonarViewGL.cc:709
volatile GLfloat * vertecies
Definition: SonarViewGL.h:99
int lastBearing
Definition: SonarViewGL.h:67
unsigned int oldSize
Definition: SonarViewGL.h:96
volatile GLubyte * colors
Definition: SonarViewGL.h:98
void SonarViewGL::setGroundTrue ( double  sizeX,
double  sizeY,
double  posX,
double  posY,
double  rot 
)

Definition at line 657 of file SonarViewGL.cc.

657  {
658  sizeX/=2.0;
659  sizeY/=2.0;
660  glDeleteLists(groundTrue, 1);
661  groundTrue = glGenLists( 1 );
662  glNewList( groundTrue, GL_COMPILE );
663  //checkGL("after list create");
664  glPushMatrix();
665  qglColor(Qt::red);
666  glTranslated(-posX, -posY, 0);
667  glRotated( rotate, 0.0, 0.0, 1.0);
668  glBegin(GL_LINE_LOOP);
669  glVertex3d(-sizeX,sizeY,0);
670  glVertex3d(sizeX,sizeY,0);
671  glVertex3d(sizeX,-sizeY,0);
672  glVertex3d(-sizeX,-sizeY,0);
673  glEnd();
674  glPopMatrix();
675  glEndList();
676  //checkGL("end of set ground true:");
677 }
GLuint groundTrue
Definition: SonarViewGL.h:78
void SonarViewGL::setOrientation ( const double  orientation)
slot

Definition at line 738 of file SonarViewGL.cc.

738  {
739  this->orientation = orientation;
740 }
double orientation
Definition: SonarViewGL.h:69
void SonarViewGL::setPosition ( int  xRot,
int  yRot,
int  zRot,
int  xMove,
int  yMove,
int  zMove,
float  zoom,
int  width,
int  height 
)

Definition at line 592 of file SonarViewGL.cc.

592  {
593  resize(width,height);
594  this->xRot = xRot;
595  this->yRot = yRot;
596  this->zRot = zRot;
597  this->xShift = xMove;
598  this->yShift = yMove;
599  this->zShift = zMove;
600  this->zoom = zoom;
601  //camera[2] = -zoom;
602 
603  }
float zoom
Definition: SonarViewGL.h:66
void SonarViewGL::setPosition ( const double  posX,
const double  posY,
const double  sigmaX = 0,
const double  sigmaY = 0 
)
slot

Definition at line 742 of file SonarViewGL.cc.

742  {
743  pos[0] = posX;
744  pos[1] = posY;
745  sigmaPos[0] = sigmaX;
746  sigmaPos[1] = sigmaY;
747  repaintFunc();
748 }
double sigmaPos[2]
Definition: SonarViewGL.h:93
void repaintFunc()
Definition: SonarViewGL.cc:291
double pos[2]
Definition: SonarViewGL.h:92
void SonarViewGL::setWallDist ( int  bearing,
int  dist,
int  dist2 
)
slot

Definition at line 501 of file SonarViewGL.cc.

501  {
502  //printf("Set Wall Dist\n");
503 // mutex.lock();
504 
505  int begin,end;
506  if(lastWallBearing-bearing>0 || lastWallBearing-bearing < -3000){
507  begin = lastWallBearing;
508  end = lastWallBearing-bearing;
509  }else{
510  begin = bearing;
511  end = bearing-lastWallBearing;
512  }
513 // printf("Maximum distance: %f\n",currentScale*data.size());
514  for(int j=0;j<end-2;j++){
515  int i = (begin+j)%6400;
516  if(i < 0 || i > 6399){
517  fprintf(stderr,"Error in glwidet, please check value make no sense, prevent crash, not displaying data for index %i (%s:%i)\n",i,__FILE__,__LINE__);
518  break;
519  }
520  //glDeleteLists(wallDist[i], 1);
521  }
522  lastWallBearing = bearing;
523 
524  glDeleteLists(wallDist[bearing], 1);
525  //generate new one
526  //checkGL("delete-list");
527  wallDist[bearing] = glGenLists( 1 );
528  //checkGL("generate-list");
529  glNewList( wallDist[bearing], GL_COMPILE );
530  //checkGL("new-list");
531  //checkGL("push-Matrix");
532  glPushMatrix();
533  double rotate = (double)bearing/6399.0*360.0;
534  glRotated( rotate, 0.0, 0.0, 1.0);
535  glPointSize(2.0);
536  glBegin(GL_POINTS);
537  QColor color("yellow");
538  qglColor(color);
539  glVertex3f(dist*currentScale,0,-0.1);
540  qglColor(QColor("green"));
541  glVertex3f(dist2*currentScale,0,-0.1);
542  glEnd();
543  glPopMatrix();
544  glEndList();
545 // mutex.unlock();
546 }
GLuint * wallDist
Definition: SonarViewGL.h:77
double currentScale
Definition: SonarViewGL.h:91
int lastWallBearing
Definition: SonarViewGL.h:68
void SonarViewGL::setxPosition ( int  value)
slot

Definition at line 342 of file SonarViewGL.cc.

343 {
344  xShift = value;
345  //printf("%d\n",xShift);
346  emit xPositionChanged(value);
347  //updateGL();
348 }
void xPositionChanged(int value)
void SonarViewGL::setXRotation ( int  angle)
slot

Definition at line 312 of file SonarViewGL.cc.

313 {
314  normalizeAngle(&angle);
315  if (angle != xRot) {
316  xRot = angle;
317  emit xRotationChanged(angle);
318  //updateGL();
319  }
320 }
void xRotationChanged(int angle)
void normalizeAngle(int *angle)
Definition: SonarViewGL.cc:700
void SonarViewGL::setyPosition ( int  value)
slot

Definition at line 349 of file SonarViewGL.cc.

350 {
351  yShift = value;
352  emit yPositionChanged(value);
353  //updateGL();
354 }
void yPositionChanged(int value)
void SonarViewGL::setYRotation ( int  angle)
slot

Definition at line 322 of file SonarViewGL.cc.

323 {
324  normalizeAngle(&angle);
325  if (angle != yRot) {
326  yRot = angle;
327  emit yRotationChanged(angle);
328  //updateGL();
329  }
330 }
void yRotationChanged(int angle)
void normalizeAngle(int *angle)
Definition: SonarViewGL.cc:700
void SonarViewGL::setZoomMax ( float  value)
slot

Definition at line 756 of file SonarViewGL.cc.

757 {
758  zoom_max = value;
759 }
float zoom_max
Definition: SonarViewGL.h:66
void SonarViewGL::setZoomMin ( float  value)
slot

Definition at line 751 of file SonarViewGL.cc.

752 {
753  zoom_min = value;
754 }
float zoom_min
Definition: SonarViewGL.h:66
void SonarViewGL::setzPosition ( int  value)
slot

Definition at line 355 of file SonarViewGL.cc.

356 {
357  zShift = value;
358  emit zPositionChanged(value);
359  //updateGL();
360 }
void zPositionChanged(int value)
void SonarViewGL::setZRotation ( int  angle)
slot

Definition at line 332 of file SonarViewGL.cc.

333 {
334  normalizeAngle(&angle);
335  if (angle != zRot) {
336  zRot = angle;
337  emit zRotationChanged(angle);
338  //updateGL();
339  }
340 }
void zRotationChanged(int angle)
void normalizeAngle(int *angle)
Definition: SonarViewGL.cc:700
GLuint SonarViewGL::show_pointcloud ( )
protected
QSize SonarViewGL::sizeHint ( ) const

Definition at line 307 of file SonarViewGL.cc.

308 {
309  return QSize(400, 400);
310 }
void SonarViewGL::wheelEvent ( QWheelEvent *  event)
protected

Definition at line 648 of file SonarViewGL.cc.

649  {
650  zoom -= (2.0*(float)event->delta()/120.0)*5;
651  zoom = std::max<float>( std::min<float>( zoom, zoom_max ), zoom_min);
652  event->accept();
653  // updateGL();
654  repaintFunc();
655 }
float zoom_max
Definition: SonarViewGL.h:66
float zoom_min
Definition: SonarViewGL.h:66
void repaintFunc()
Definition: SonarViewGL.cc:291
float zoom
Definition: SonarViewGL.h:66
void SonarViewGL::xPositionChanged ( int  value)
signal
void SonarViewGL::xRotationChanged ( int  angle)
signal
void SonarViewGL::yPositionChanged ( int  value)
signal
void SonarViewGL::yRotationChanged ( int  angle)
signal
void SonarViewGL::zPositionChanged ( int  value)
signal
void SonarViewGL::zRotationChanged ( int  angle)
signal

Member Data Documentation

GLuint SonarViewGL::avalon
protected

Definition at line 78 of file SonarViewGL.h.

bool* SonarViewGL::bearingChanged
protected

Definition at line 79 of file SonarViewGL.h.

GLuint * SonarViewGL::bearingList
protected

Definition at line 77 of file SonarViewGL.h.

int SonarViewGL::cloudSize
protected

Definition at line 58 of file SonarViewGL.h.

std::vector<std::pair<GLuint, QColor> > SonarViewGL::colorList
protected

Definition at line 76 of file SonarViewGL.h.

volatile GLubyte* SonarViewGL::colors
protected

Definition at line 98 of file SonarViewGL.h.

double SonarViewGL::currentScale
protected

Definition at line 91 of file SonarViewGL.h.

bool SonarViewGL::dataChanged
protected

Definition at line 80 of file SonarViewGL.h.

bool SonarViewGL::deleteSurfaces
protected

Definition at line 54 of file SonarViewGL.h.

double SonarViewGL::factor
protected

Definition at line 60 of file SonarViewGL.h.

GLuint SonarViewGL::groundPlane
protected

Definition at line 63 of file SonarViewGL.h.

GLuint SonarViewGL::groundTrue
protected

Definition at line 78 of file SonarViewGL.h.

volatile GLuint* SonarViewGL::indices
protected

Definition at line 97 of file SonarViewGL.h.

int SonarViewGL::lastBearing
protected

Definition at line 67 of file SonarViewGL.h.

QPoint SonarViewGL::lastPos
protected

Definition at line 100 of file SonarViewGL.h.

QPoint SonarViewGL::lastPosTrans
protected

Definition at line 101 of file SonarViewGL.h.

int SonarViewGL::lastWallBearing
protected

Definition at line 68 of file SonarViewGL.h.

bool * SonarViewGL::listValid
protected

Definition at line 79 of file SonarViewGL.h.

const unsigned int SonarViewGL::maximumBearings
protected

Definition at line 74 of file SonarViewGL.h.

int SonarViewGL::medium_ableitung
protected

Definition at line 89 of file SonarViewGL.h.

QMutex SonarViewGL::mutex
protected

Definition at line 103 of file SonarViewGL.h.

unsigned int SonarViewGL::oldSize
protected

Definition at line 96 of file SonarViewGL.h.

double SonarViewGL::orientation
protected

Definition at line 69 of file SonarViewGL.h.

int SonarViewGL::overlay_border
protected

Definition at line 90 of file SonarViewGL.h.

bool SonarViewGL::paintGroundTrue
protected

Definition at line 81 of file SonarViewGL.h.

bool SonarViewGL::paintWall
protected

Definition at line 81 of file SonarViewGL.h.

double SonarViewGL::pos[2]
protected

Definition at line 92 of file SonarViewGL.h.

QTimer SonarViewGL::repaintTimer
protected

Definition at line 102 of file SonarViewGL.h.

double SonarViewGL::sigmaPos[2]
protected

Definition at line 93 of file SonarViewGL.h.

volatile GLfloat* SonarViewGL::vertecies
protected

Definition at line 99 of file SonarViewGL.h.

GLuint* SonarViewGL::wallDist
protected

Definition at line 77 of file SonarViewGL.h.

int SonarViewGL::xRot
protected

Definition at line 83 of file SonarViewGL.h.

int SonarViewGL::xShift
protected

Definition at line 86 of file SonarViewGL.h.

int SonarViewGL::yRot
protected

Definition at line 84 of file SonarViewGL.h.

int SonarViewGL::yShift
protected

Definition at line 87 of file SonarViewGL.h.

float SonarViewGL::zoom
protected

Definition at line 66 of file SonarViewGL.h.

float SonarViewGL::zoom_max
protected

Definition at line 66 of file SonarViewGL.h.

float SonarViewGL::zoom_min
protected

Definition at line 66 of file SonarViewGL.h.

int SonarViewGL::zRot
protected

Definition at line 85 of file SonarViewGL.h.

int SonarViewGL::zShift
protected

Definition at line 88 of file SonarViewGL.h.


The documentation for this class was generated from the following files: