ARGoS  3
A parallel, multi-engine simulator for swarm robotics
qtopengl_user_functions.cpp
Go to the documentation of this file.
1 
9 #include <QPainter>
10 
11 namespace argos {
12 
13  /****************************************/
14  /****************************************/
15 
16  const GLfloat DEFAULT_SPECULAR[] = { 0.0f, 0.0f, 0.0f, 1.0f };
17  const GLfloat DEFAULT_SHININESS[] = { 100.0f };
18  const GLfloat DEFAULT_EMISSION[] = { 0.0f, 0.0f, 0.0f, 1.0f };
19 
20  /****************************************/
21  /****************************************/
22 
23  static void Rototranslate(const CVector3& c_position,
24  const CQuaternion& c_orientation) {
25  /* Get Euler angles */
26  CRadians cZAngle, cYAngle, cXAngle;
27  c_orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
28  /* Translate */
29  glTranslatef(c_position.GetX(), c_position.GetY(), c_position.GetZ());
30  /* Rotate */
31  glRotatef(ToDegrees(cXAngle).GetValue(), 1.0f, 0.0f, 0.0f);
32  glRotatef(ToDegrees(cYAngle).GetValue(), 0.0f, 1.0f, 0.0f);
33  glRotatef(ToDegrees(cZAngle).GetValue(), 0.0f, 0.0f, 1.0f);
34  }
35 
36  /****************************************/
37  /****************************************/
38 
40  m_vecFunctionHolders(1),
41  m_pcQTOpenGLMainWindow(NULL) {
42  m_cThunks.Add<CEntity>((TThunk)NULL);
43  }
44 
45  /****************************************/
46  /****************************************/
47 
49  while(!m_vecFunctionHolders.empty()) {
50  delete m_vecFunctionHolders.back();
51  m_vecFunctionHolders.pop_back();
52  }
53  }
54 
55  /****************************************/
56  /****************************************/
57 
58  void CQTOpenGLUserFunctions::KeyPressed(QKeyEvent* pc_event) {
59  m_pcQTOpenGLMainWindow->GetOpenGLWidget().KeyPressed(pc_event);
60  }
61 
62  /****************************************/
63  /****************************************/
64 
65  void CQTOpenGLUserFunctions::KeyReleased(QKeyEvent* pc_event) {
66  m_pcQTOpenGLMainWindow->GetOpenGLWidget().KeyReleased(pc_event);
67  }
68 
69  /****************************************/
70  /****************************************/
71 
73  return m_pcQTOpenGLMainWindow->GetOpenGLWidget().GetSelectedEntity();
74  }
75 
76  /****************************************/
77  /****************************************/
78 
80  m_pcQTOpenGLMainWindow->GetOpenGLWidget().SelectEntity(c_entity);
81  }
82 
83  /****************************************/
84  /****************************************/
85 
87  m_pcQTOpenGLMainWindow->GetOpenGLWidget().DeselectEntity();
88  }
89 
90  /****************************************/
91  /****************************************/
92 
94  return *m_pcQTOpenGLMainWindow;
95  }
96 
97  /****************************************/
98  /****************************************/
99 
101  m_pcQTOpenGLMainWindow = &c_main_win;
102  }
103 
104  /****************************************/
105  /****************************************/
106 
108  return m_pcQTOpenGLMainWindow->GetOpenGLWidget();
109  }
110 
111  /****************************************/
112  /****************************************/
113 
115  const GLfloat pfColor[] = {
116  c_color.GetRed() / 255.0f,
117  c_color.GetGreen() / 255.0f,
118  c_color.GetBlue() / 255.0f
119  };
120  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, DEFAULT_SPECULAR);
121  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, DEFAULT_SHININESS);
122  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, DEFAULT_EMISSION);
123  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
124  }
125 
126  /****************************************/
127  /****************************************/
128 
130  const CColor& c_color,
131  const Real f_diameter) {
132  /* Save attributes */
133  glPushAttrib(GL_POINT_BIT);
134  /* Set color */
135  SetColor(c_color);
136  /* Set point attributes */
137  glPointSize(f_diameter);
138  glEnable(GL_POINT_SMOOTH);
139  /* Draw */
140  glBegin(GL_POINTS);
141  glVertex3f(c_position.GetX(), c_position.GetY(), c_position.GetZ());
142  glEnd();
143  /* Restore saved attributes */
144  glPopAttrib();
145  }
146 
147  /****************************************/
148  /****************************************/
149 
151  const CQuaternion& c_orientation,
152  Real f_base,
153  Real f_height,
154  const CColor& c_color,
155  const bool b_fill) {
156  /* Save attributes and current matrix */
157  glPushAttrib(GL_POLYGON_BIT);
158  glPushMatrix();
159  /* Set color */
160  SetColor(c_color);
161  /* Disable face culling, to make the triangle visible from any angle */
162  glDisable(GL_CULL_FACE);
163  /* Set polygon attributes */
164  glEnable(GL_POLYGON_SMOOTH);
165  glPolygonMode(GL_FRONT_AND_BACK, b_fill ? GL_FILL : GL_LINE);
166  /* Set position/orientation */
167  Rototranslate(c_position, c_orientation);
168  /* Draw */
169  glBegin(GL_TRIANGLES);
170  glNormal3f(0.0f, 0.0f, 1.0f);
171  glVertex3f(-f_base * 0.5f, 0.0f, 0.0f);
172  glVertex3f( f_base * 0.5f, 0.0f, 0.0f);
173  glVertex3f( 0.0f, f_height, 0.0f);
174  glEnd();
175  /* Restore saved stuff */
176  glPopMatrix();
177  glPopAttrib();
178  }
179 
180  /****************************************/
181  /****************************************/
182 
184  const CQuaternion& c_orientation,
185  const std::vector<CVector2>& vec_points,
186  const CColor& c_color,
187  const bool b_fill) {
188  if(vec_points.size() < 2) {
189  LOGERR << "CQTOpenGLUserFunctions::DrawPolygon() needs at least 3 points." << std::endl;
190  return;
191  }
192  /* Save attributes and current matrix */
193  glPushAttrib(GL_POLYGON_BIT);
194  /* Set color */
195  SetColor(c_color);
196  /* Disable face culling, to make the triangle visible from any angle */
197  glDisable(GL_CULL_FACE);
198  /* Set polygon attributes */
199  glEnable(GL_POLYGON_SMOOTH);
200  glPolygonMode(GL_FRONT_AND_BACK, b_fill ? GL_FILL : GL_LINE);
201  /* Set position/orientation */
202  Rototranslate(c_position, c_orientation);
203  /* Draw */
204  glBegin(GL_POLYGON);
205  glNormal3f(0.0f, 0.0f, 1.0f);
206  for(size_t i = 0; i < vec_points.size(); ++i) {
207  glVertex3f(vec_points[i].GetX(), vec_points[i].GetY(), 0.0f);
208  }
209  glEnd();
210  /* Reset translation */
211  glTranslatef(-c_position.GetX(), -c_position.GetY(), -c_position.GetZ());
212  /* Restore saved stuff */
213  glPopAttrib();
214  }
215 
216  /****************************************/
217  /****************************************/
218 
220  const CQuaternion& c_orientation,
221  Real f_radius,
222  const CColor& c_color,
223  const bool b_fill,
224  GLuint un_vertices) {
225  /* Save attributes and current matrix */
226  glPushAttrib(GL_POLYGON_BIT);
227  glPushMatrix();
228  /* Set color */
229  SetColor(c_color);
230  /* Disable face culling, to make the triangle visible from any angle */
231  glDisable(GL_CULL_FACE);
232  /* Set polygon attributes */
233  glEnable(GL_POLYGON_SMOOTH);
234  glPolygonMode(GL_FRONT_AND_BACK, b_fill ? GL_FILL : GL_LINE);
235  /* Set position/orientation */
236  Rototranslate(c_position, c_orientation);
237  /* Draw */
238  CVector2 cVertex(f_radius, 0.0f);
239  CRadians cAngle(CRadians::TWO_PI / un_vertices);
240  glBegin(GL_POLYGON);
241  glNormal3f(0.0f, 0.0f, 1.0f);
242  for(size_t i = 0; i < un_vertices; ++i) {
243  glVertex3f(cVertex.GetX(), cVertex.GetY(), 0.0f);
244  cVertex.Rotate(cAngle);
245  }
246  glEnd();
247  /* Restore saved stuff */
248  glPopAttrib();
249  glPopMatrix();
250  }
251 
252  /****************************************/
253  /****************************************/
254 
256  const CQuaternion& c_orientation,
257  Real f_radius,
258  Real f_height,
259  const CColor& c_color,
260  GLuint un_vertices) {
261  /* Save current matrix */
262  glPushMatrix();
263  /* Set color */
264  SetColor(c_color);
265  /* Set position/orientation */
266  Rototranslate(c_position, c_orientation);
267  /* Draw side surface */
268  Real fHalfHeight = f_height * 0.5f;
269  CVector2 cVertex(1.0f, 0.0f);
270  CRadians cAngle(CRadians::TWO_PI / un_vertices);
271  glBegin(GL_QUAD_STRIP);
272  for(GLuint i = 0; i <= un_vertices; i++) {
273  glNormal3f(cVertex.GetX(), cVertex.GetY(), 0.0f);
274  glVertex3f(cVertex.GetX() * f_radius, cVertex.GetY() * f_radius, fHalfHeight);
275  glVertex3f(cVertex.GetX() * f_radius, cVertex.GetY() * f_radius, -fHalfHeight);
276  cVertex.Rotate(cAngle);
277  }
278  glEnd();
279  /* Draw top disk */
280  cVertex.Set(f_radius, 0.0f);
281  glBegin(GL_POLYGON);
282  glNormal3f(0.0f, 0.0f, 1.0f);
283  for(GLuint i = 0; i <= un_vertices; i++) {
284  glVertex3f(cVertex.GetX(), cVertex.GetY(), fHalfHeight);
285  cVertex.Rotate(cAngle);
286  }
287  glEnd();
288  /* Draw bottom disk */
289  cVertex.Set(f_radius, 0.0f);
290  cAngle = -cAngle;
291  glBegin(GL_POLYGON);
292  glNormal3f(0.0f, 0.0f, -1.0f);
293  for(GLuint i = 0; i <= un_vertices; i++) {
294  glVertex3f(cVertex.GetX(), cVertex.GetY(), -fHalfHeight);
295  cVertex.Rotate(cAngle);
296  }
297  glEnd();
298  /* Restore saved matrix */
299  glPopMatrix();
300  }
301 
302  /****************************************/
303  /****************************************/
304 
306  const CQuaternion& c_orientation,
307  const CVector3& c_size,
308  const CColor& c_color) {
309  /* Save current matrix */
310  glPushMatrix();
311  /* Set color */
312  SetColor(c_color);
313  /* Set position/orientation */
314  Rototranslate(c_position, c_orientation);
315  /* Draw top and bottom faces (parallel to XY) */
316  CVector3 cHalfSize = c_size * 0.5f;
317  glBegin(GL_QUADS);
318  /* Bottom face */
319  glNormal3f(0.0f, 0.0f, -1.0f);
320  glVertex3f( cHalfSize.GetX(), cHalfSize.GetY(), -cHalfSize.GetZ());
321  glVertex3f( cHalfSize.GetX(), -cHalfSize.GetY(), -cHalfSize.GetZ());
322  glVertex3f(-cHalfSize.GetX(), -cHalfSize.GetY(), -cHalfSize.GetZ());
323  glVertex3f(-cHalfSize.GetX(), cHalfSize.GetY(), -cHalfSize.GetZ());
324  /* Top face */
325  glNormal3f(0.0f, 0.0f, 1.0f);
326  glVertex3f(-cHalfSize.GetX(), -cHalfSize.GetY(), cHalfSize.GetZ());
327  glVertex3f( cHalfSize.GetX(), -cHalfSize.GetY(), cHalfSize.GetZ());
328  glVertex3f( cHalfSize.GetX(), cHalfSize.GetY(), cHalfSize.GetZ());
329  glVertex3f(-cHalfSize.GetX(), cHalfSize.GetY(), cHalfSize.GetZ());
330  glEnd();
331  /* Draw the other faces (South, East, North, West) */
332  glBegin(GL_QUADS);
333  /* North face */
334  glNormal3f(1.0f, 0.0f, 0.0f);
335  glVertex3f( cHalfSize.GetX(), -cHalfSize.GetY(), -cHalfSize.GetZ());
336  glVertex3f( cHalfSize.GetX(), cHalfSize.GetY(), -cHalfSize.GetZ());
337  glVertex3f( cHalfSize.GetX(), cHalfSize.GetY(), cHalfSize.GetZ());
338  glVertex3f( cHalfSize.GetX(), -cHalfSize.GetY(), cHalfSize.GetZ());
339  /* South face */
340  glNormal3f(-1.0f, 0.0f, 0.0f);
341  glVertex3f(-cHalfSize.GetX(), -cHalfSize.GetY(), -cHalfSize.GetZ());
342  glVertex3f(-cHalfSize.GetX(), -cHalfSize.GetY(), cHalfSize.GetZ());
343  glVertex3f(-cHalfSize.GetX(), cHalfSize.GetY(), cHalfSize.GetZ());
344  glVertex3f(-cHalfSize.GetX(), cHalfSize.GetY(), -cHalfSize.GetZ());
345  /* East face */
346  glNormal3f(0.0f, -1.0f, 0.0f);
347  glVertex3f(-cHalfSize.GetX(), -cHalfSize.GetY(), -cHalfSize.GetZ());
348  glVertex3f( cHalfSize.GetX(), -cHalfSize.GetY(), -cHalfSize.GetZ());
349  glVertex3f( cHalfSize.GetX(), -cHalfSize.GetY(), cHalfSize.GetZ());
350  glVertex3f(-cHalfSize.GetX(), -cHalfSize.GetY(), cHalfSize.GetZ());
351  /* West face */
352  glNormal3f(0.0f, 1.0f, 0.0f);
353  glVertex3f(-cHalfSize.GetX(), cHalfSize.GetY(), -cHalfSize.GetZ());
354  glVertex3f(-cHalfSize.GetX(), cHalfSize.GetY(), cHalfSize.GetZ());
355  glVertex3f( cHalfSize.GetX(), cHalfSize.GetY(), cHalfSize.GetZ());
356  glVertex3f( cHalfSize.GetX(), cHalfSize.GetY(), -cHalfSize.GetZ());
357  glEnd();
358  /* Restore saved matrix */
359  glPopMatrix();
360  }
361 
362  /****************************************/
363  /****************************************/
364 
366  const CColor& c_color,
367  Real f_width) {
368  /* Save attributes and current matrix */
369  glPushAttrib(GL_LINE_BIT | GL_ENABLE_BIT);
370  /* Set line attributes */
371  glEnable(GL_LINE_SMOOTH);
372  glLineWidth(f_width);
373  /* Unset lighting */
374  glDisable(GL_LIGHTING);
375  glDisable(GL_COLOR_MATERIAL);
376  /* Set color */
377  glColor3ub(c_color.GetRed(), c_color.GetGreen(), c_color.GetBlue());
378  /* Draw ray */
379  glBegin(GL_LINES);
380  glVertex3f(c_ray.GetStart().GetX(), c_ray.GetStart().GetY(), c_ray.GetStart().GetZ());
381  glVertex3f(c_ray.GetEnd().GetX(), c_ray.GetEnd().GetY(), c_ray.GetEnd().GetZ());
382  glEnd();
383  /* Restore saved stuff */
384  glPopAttrib();
385  }
386 
387  /****************************************/
388  /****************************************/
389 
390  static void TransformPoint(Real* pf_vec_out,
391  const Real* pf_trans,
392  const Real* pf_vec_in) {
393 #define M(row,col) pf_trans[col * 4 + row]
394  pf_vec_out[0] =
395  M(0, 0) * pf_vec_in[0] +
396  M(0, 1) * pf_vec_in[1] +
397  M(0, 2) * pf_vec_in[2] +
398  M(0, 3) * pf_vec_in[3];
399  pf_vec_out[1] =
400  M(1, 0) * pf_vec_in[0] +
401  M(1, 1) * pf_vec_in[1] +
402  M(1, 2) * pf_vec_in[2] +
403  M(1, 3) * pf_vec_in[3];
404  pf_vec_out[2] =
405  M(2, 0) * pf_vec_in[0] +
406  M(2, 1) * pf_vec_in[1] +
407  M(2, 2) * pf_vec_in[2] +
408  M(2, 3) * pf_vec_in[3];
409  pf_vec_out[3] =
410  M(3, 0) * pf_vec_in[0] +
411  M(3, 1) * pf_vec_in[1] +
412  M(3, 2) * pf_vec_in[2] +
413  M(3, 3) * pf_vec_in[3];
414 #undef M
415  }
416 
417  /****************************************/
418  /****************************************/
419 
421  const std::string& str_text,
422  const CColor& c_color,
423  const QFont& c_font) {
424  /* Get current modelview matrix */
425  GLdouble pf_mv[16];
426  glGetDoublev(GL_MODELVIEW_MATRIX, pf_mv);
427  /* Get current projection matrix */
428  GLdouble pf_proj[16];
429  glGetDoublev(GL_PROJECTION_MATRIX, pf_proj);
430  /* Get current viewport */
431  GLint pn_vp[4];
432  glGetIntegerv(GL_VIEWPORT, pn_vp);
433  /* Buffers for projection calculations */
434  GLdouble pf_v1[4], pf_v2[4];
435  /* Transform original position with modelview matrix */
436  pf_v1[0] = c_position.GetX();
437  pf_v1[1] = c_position.GetY();
438  pf_v1[2] = c_position.GetZ();
439  pf_v1[3] = 1.0;
440  TransformPoint(pf_v2, pf_mv, pf_v1);
441  /* Transform pf_v2 with projection matrix */
442  TransformPoint(pf_v1, pf_proj, pf_v2);
443  /* Failed projection? Get out */
444  if (pf_v1[3] == 0.0) return;
445  /* Rescale projection */
446  pf_v1[0] /= pf_v1[3];
447  pf_v1[1] /= pf_v1[3];
448  /* Get screen position (before mirroring) */
449  pf_v2[0] =
450  (pn_vp[0] + (1. + pf_v1[0]) * pn_vp[2] / 2.) /
451  GetMainWindow().devicePixelRatio();
452  pf_v2[1] =
453  (pn_vp[1] + (1. + pf_v1[1]) * pn_vp[3] / 2.) /
454  GetMainWindow().devicePixelRatio();
455  /* Mirror along Y because screen goes up to down */
456  pf_v2[1] = GetMainWindow().GetOpenGLWidget().height() - pf_v2[1];
457  /* Save OpenGL attributes */
458  glPushAttrib(GL_ENABLE_BIT);
459  /* Disable lighting to make text color unaffected by light */
460  glDisable(GL_LIGHTING);
461  glDisable(GL_COLOR_MATERIAL);
462  /* Disable culling to make text visibile from any angle */
463  glDisable(GL_CULL_FACE);
464  /* Initialize Qt screen painter */
465  QPainter cPainter(&GetMainWindow().GetOpenGLWidget());
466  /* Set antialiasing */
467  cPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
468  /* Set pen color */
469  cPainter.setPen(
470  QColor(c_color.GetRed(),
471  c_color.GetGreen(),
472  c_color.GetBlue(),
473  c_color.GetAlpha()));
474  /* Set font */
475  cPainter.setFont(c_font);
476  /* Render text */
477  cPainter.drawText(pf_v2[0], pf_v2[1], str_text.c_str());
478  /* Dispose of Qt screen painter */
479  cPainter.end();
480  /* Restore saved attributes */
481  glPopAttrib();
482  }
483 
484  /****************************************/
485  /****************************************/
486 
488  TThunk t_thunk = m_cThunks[c_entity.GetTag()];
489  if(t_thunk) (this->*t_thunk)(c_entity);
490  }
491 
492  /****************************************/
493  /****************************************/
494 
495 }
argos::CVector3::GetZ
Real GetZ() const
Returns the z coordinate of this vector.
Definition: vector3.h:125
argos::CQTOpenGLUserFunctions::DrawRay
void DrawRay(const CRay3 &c_ray, const CColor &c_color=CColor::RED, Real f_width=1.0f)
Draws a ray, with optional endpoint markers.
Definition: qtopengl_user_functions.cpp:365
argos::CColor::GetAlpha
UInt8 GetAlpha() const
Returns the alpha channel of the color.
Definition: color.h:112
argos::DEFAULT_EMISSION
const GLfloat DEFAULT_EMISSION[]
Definition: qtopengl_user_functions.cpp:18
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
argos::CQTOpenGLUserFunctions::DrawCircle
void DrawCircle(const CVector3 &c_position, const CQuaternion &c_orientation, Real f_radius, const CColor &c_color=CColor::RED, const bool b_fill=true, GLuint un_vertices=20)
Draws a circle.
Definition: qtopengl_user_functions.cpp:219
argos::CRadians
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
argos::CQTOpenGLUserFunctions::TThunk
void(CQTOpenGLUserFunctions::* TThunk)(CEntity &)
Pointer-to-thunk type definition.
Definition: qtopengl_user_functions.h:324
argos::CQTOpenGLWidget
Definition: qtopengl_widget.h:56
argos::ToDegrees
CDegrees ToDegrees(const CRadians &c_radians)
Converts CRadians to CDegrees.
Definition: angles.h:489
argos::CColor::GetBlue
UInt8 GetBlue() const
Returns the blue channel of the color.
Definition: color.h:101
argos::CRay3
Definition: ray3.h:19
argos::DEFAULT_SHININESS
const GLfloat DEFAULT_SHININESS[]
Definition: qtopengl_user_functions.cpp:17
argos::CQTOpenGLUserFunctions::SetColor
void SetColor(const CColor &c_color)
Sets the current drawing color.
Definition: qtopengl_user_functions.cpp:114
argos::CQTOpenGLUserFunctions::DrawText
void DrawText(const CVector3 &c_position, const std::string &str_text, const CColor &c_color=CColor::BLACK, const QFont &c_font=QFont())
Draws a string of text.
Definition: qtopengl_user_functions.cpp:420
argos::CVector2::Set
void Set(Real f_x, Real f_y)
Sets the vector contents from Cartesian coordinates.
Definition: vector2.h:111
argos::LOGERR
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
Definition: argos_log.h:180
argos::CVector2::GetY
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector2.h:94
argos::CQTOpenGLUserFunctions::CQTOpenGLUserFunctions
CQTOpenGLUserFunctions()
Class constructor.
Definition: qtopengl_user_functions.cpp:39
argos::CQTOpenGLWidget::SelectEntity
void SelectEntity(CEntity &c_entity)
Selects the passed entity.
Definition: qtopengl_widget.cpp:320
argos::CQTOpenGLUserFunctions::DeselectEntity
virtual void DeselectEntity()
Deselects the currently selected entity.
Definition: qtopengl_user_functions.cpp:86
argos::CQTOpenGLWidget::GetSelectedEntity
CEntity * GetSelectedEntity()
Returns the currently selected entity, or NULL if none is selected.
Definition: qtopengl_widget.cpp:311
argos::CVector3::GetX
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
argos::CColor::GetRed
UInt8 GetRed() const
Returns the red channel of the color.
Definition: color.h:79
argos::CQTOpenGLUserFunctions::DrawTriangle
void DrawTriangle(const CVector3 &c_position, const CQuaternion &c_orientation, Real f_base, Real f_height, const CColor &c_color=CColor::RED, const bool b_fill=true)
Draws an isosceles triangle.
Definition: qtopengl_user_functions.cpp:150
argos::CQTOpenGLUserFunctions::DrawPoint
void DrawPoint(const CVector3 &c_position, const CColor &c_color=CColor::RED, Real f_diameter=5.0)
Draws a point.
Definition: qtopengl_user_functions.cpp:129
argos::CQuaternion
Definition: quaternion.h:14
argos::CQTOpenGLUserFunctions::SelectEntity
virtual void SelectEntity(CEntity &c_entity)
Selects the specified entity.
Definition: qtopengl_user_functions.cpp:79
argos::CQTOpenGLUserFunctions::SetMainWindow
void SetMainWindow(CQTOpenGLMainWindow &c_main_win)
Sets the QTOpenGL main window for these user functions.
Definition: qtopengl_user_functions.cpp:100
argos::CQTOpenGLWidget::KeyReleased
void KeyReleased(QKeyEvent *pc_event)
Handles key release events.
Definition: qtopengl_widget.cpp:737
argos::CVector2::GetX
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector2.h:78
argos::CQTOpenGLUserFunctions::KeyPressed
virtual void KeyPressed(QKeyEvent *pc_event)
Called when a key press event occurs.
Definition: qtopengl_user_functions.cpp:58
argos::CQTOpenGLUserFunctions::m_vecFunctionHolders
std::vector< CFunctionHolder * > m_vecFunctionHolders
A vector of function holders.
Definition: qtopengl_user_functions.h:369
argos::CQTOpenGLWidget::DeselectEntity
void DeselectEntity()
Deselects the currently selected entity.
Definition: qtopengl_widget.cpp:350
argos::CRay3::GetStart
CVector3 & GetStart()
Definition: ray3.h:37
argos::CQTOpenGLUserFunctions::DrawPolygon
void DrawPolygon(const CVector3 &c_position, const CQuaternion &c_orientation, const std::vector< CVector2 > &vec_points, const CColor &c_color=CColor::RED, const bool b_fill=true)
Draws a 2D polygon.
Definition: qtopengl_user_functions.cpp:183
argos::CQTOpenGLUserFunctions::GetMainWindow
CQTOpenGLMainWindow & GetMainWindow()
Returns the QTOpenGL main window.
Definition: qtopengl_user_functions.cpp:93
argos::CVector2
A 2D vector class.
Definition: vector2.h:25
argos::CQTOpenGLUserFunctions::~CQTOpenGLUserFunctions
virtual ~CQTOpenGLUserFunctions()
Class destructor.
Definition: qtopengl_user_functions.cpp:48
argos::CQTOpenGLUserFunctions::DrawBox
void DrawBox(const CVector3 &c_position, const CQuaternion &c_orientation, const CVector3 &c_size, const CColor &c_color=CColor::RED)
Draws a box.
Definition: qtopengl_user_functions.cpp:305
argos::CQTOpenGLMainWindow
Definition: qtopengl_main_window.h:36
argos::CEntity
The basic entity type.
Definition: entity.h:89
argos::CQTOpenGLUserFunctions::Call
virtual void Call(CEntity &c_entity)
Calls a user method for the given entity.
Definition: qtopengl_user_functions.cpp:487
argos::CQTOpenGLUserFunctions::KeyReleased
virtual void KeyReleased(QKeyEvent *pc_event)
Called when a key release event occurs.
Definition: qtopengl_user_functions.cpp:65
argos::CQTOpenGLUserFunctions::m_cThunks
CVTable< CQTOpenGLUserFunctions, CEntity, TThunk > m_cThunks
The vtable storing the thunks.
Definition: qtopengl_user_functions.h:363
M
#define M(row, col)
argos::CQTOpenGLUserFunctions::DrawCylinder
void DrawCylinder(const CVector3 &c_position, const CQuaternion &c_orientation, Real f_radius, Real f_height, const CColor &c_color=CColor::RED, GLuint un_vertices=20)
Draws a cylinder, with the height perpendicular to the XY plane.
Definition: qtopengl_user_functions.cpp:255
argos::CColor
The basic color type.
Definition: color.h:25
qtopengl_user_functions.h
argos::CQTOpenGLUserFunctions::GetSelectedEntity
CEntity * GetSelectedEntity()
Returns the currently selected entity, or NULL.
Definition: qtopengl_user_functions.cpp:72
argos::CVector3::GetY
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
argos::CVector2::Rotate
CVector2 & Rotate(const CRadians &c_angle)
Rotates this vector by the wanted angle.
Definition: vector2.h:169
argos::CRadians::TWO_PI
static const CRadians TWO_PI
Set to PI * 2.
Definition: angles.h:54
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::CQTOpenGLWidget::KeyPressed
void KeyPressed(QKeyEvent *pc_event)
Handles key press events.
Definition: qtopengl_widget.cpp:691
argos::DEFAULT_SPECULAR
const GLfloat DEFAULT_SPECULAR[]
Definition: qtopengl_user_functions.cpp:16
argos::CQTOpenGLMainWindow::GetOpenGLWidget
CQTOpenGLWidget & GetOpenGLWidget()
Definition: qtopengl_main_window.h:45
argos::CColor::GetGreen
UInt8 GetGreen() const
Returns the green channel of the color.
Definition: color.h:90
argos::CRay3::GetEnd
CVector3 & GetEnd()
Definition: ray3.h:45
argos::CQTOpenGLUserFunctions::GetQTOpenGLWidget
CQTOpenGLWidget & GetQTOpenGLWidget()
Returns the QTOpenGLWidget.
Definition: qtopengl_user_functions.cpp:107