ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
The QTOpenGL user functions. More...
#include <qtopengl_user_functions.h>
Classes | |
class | CFunctionHolder |
The base function holder. | |
class | CFunctionHolderImpl |
The actual function holder. | |
Public Member Functions | |
CQTOpenGLUserFunctions () | |
Class constructor. | |
virtual | ~CQTOpenGLUserFunctions () |
Class destructor. | |
virtual void | Draw (CFloorEntity &c_entity) |
Drawing hook executed after the floor is drawn. | |
virtual void | DrawInWorld () |
Drawing hook executed after all objects have been drawn. | |
virtual void | DrawOverlay (QPainter &c_painter) |
Drawing hook to put graphics on top of the OpenGL window. | |
CQTOpenGLWidget & | GetOpenGLWidget () |
Returns the QTOpenGL widget. | |
void | SetOpenGLWidget (CQTOpenGLWidget &c_widget) |
Sets the QTOpenGL widget for these user functions. | |
void | DrawTriangle (const CVector3 &c_center_offset=CVector3::ZERO, const CColor &c_color=CColor::RED, const bool b_fill=true, const CQuaternion &c_orientation=CQuaternion(), Real f_base=0.2f, Real f_height=0.1732050808f) |
Draws a triangle, parallel to the XY plane. | |
void | DrawCircle (Real f_radius=0.1f, const CVector3 &c_center_offset=CVector3::ZERO, const CColor &c_color=CColor::RED, const bool b_fill=true, const CQuaternion &c_orientation=CQuaternion(), GLuint un_vertices=20) |
Draws a circle, parallel to the XY plane. | |
void | DrawCylinder (Real f_radius=0.1f, Real f_height=0.1f, const CVector3 &c_center_offset=CVector3::ZERO, const CColor &c_color=CColor::RED, const CQuaternion &c_orientation=CQuaternion(), GLuint un_vertices=20) |
Draws a cylinder, with the height perpendicular to the XY plane. | |
void | DrawSegment (const CVector3 &c_end_point=CVector3(1.0f, 0.0f, 1.0f), const CVector3 &c_start_point=CVector3::ZERO, const CColor &c_segment_color=CColor::RED, const Real &f_line_width=1.0f, bool b_draw_end_point=false, bool b_draw_start_point=false, const CColor &c_end_point_color=CColor::RED, const CColor &c_start_point_color=CColor::RED) |
Draws a segment, with optional endpoint markers. | |
void | DrawPolygon (const std::vector< CVector3 > &vec_points, const CColor &c_color=CColor::RED) |
Draws a polygon. | |
void | DrawPoint (const CVector3 &c_position=CVector3(1.0f, 0.0f, 1.0f), const CColor &c_color=CColor::RED, const Real f_point_diameter=5.0) |
Draws a point. | |
template<typename USER_IMPL , typename ENTITY > | |
void | RegisterUserFunction (void(USER_IMPL::*pt_function)(ENTITY &)) |
Registers a user method. | |
void | Call (CEntity &c_entity) |
Calls a user method for the given entity. |
The QTOpenGL user functions.
The QTOpenGL user functions allows you to draw objects on the graphical widget that shows the 3D robot arena (CQTOpenGLWidget). You have three ways to draw stuff.
The first is to use DrawInWorld(). This method is called after everything else has been drawn in the 3D world, and it allows you to draw custom objects anywhere in the world. When you use this method, coordinates are relative to the origin of the 3D arena, and you must use OpenGL primitives.
The second way to draw custom stuff is to use DrawOverlay(). This method is called after DrawInWorld(). It allows you to draw stuff as overlay of the 3D arena widget. This method requires you to use the methods in the Qt class QPainter.
The third way to draw custom stuff is to define an entity-specific method, as follows:
class MyOpenGLUserFunctions : public CQTOpenGLUserFunctions { public: MyOpenGLUserFunctions(); void Draw(CFootBotEntity& c_entity); ... };
The signature of the method must be as in the example, i.e., the return value must be void
, and the function must have as a unique argument an entity (i.e., a descendant of CEntity). The actual name of the function (e.g., Draw
) can be anything you like. To tell ARGoS to use this function, you need to register it in the class constructor as in this example:
MyOpenGLUserFunctions::MyOpenGLUserFunctions() { ... RegisterUserFunction<MyOpenGLUserFunctions,CFootBotEntity>(&MyOpenGLUserFunctions::Draw); ... }
After registration, ARGoS will call your method right after drawing an entity of the corresponding type. The method allows you to draw additional information around the robot. You must use OpenGL primitives. The coordinate system is relative to the robot reference point, which, for robots, is usually its base.
Definition at line 72 of file qtopengl_user_functions.h.
Class constructor.
Definition at line 15 of file qtopengl_user_functions.cpp.
argos::CQTOpenGLUserFunctions::~CQTOpenGLUserFunctions | ( | ) | [virtual] |
Class destructor.
Definition at line 24 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::Call | ( | CEntity & | c_entity | ) |
Calls a user method for the given entity.
The | method to pass as parameter. |
Definition at line 312 of file qtopengl_user_functions.cpp.
virtual void argos::CQTOpenGLUserFunctions::Draw | ( | CFloorEntity & | c_entity | ) | [inline, virtual] |
Drawing hook executed after the floor is drawn.
Definition at line 89 of file qtopengl_user_functions.h.
void argos::CQTOpenGLUserFunctions::DrawCircle | ( | Real | f_radius = 0.1f , |
const CVector3 & | c_center_offset = CVector3::ZERO , |
||
const CColor & | c_color = CColor::RED , |
||
const bool | b_fill = true , |
||
const CQuaternion & | c_orientation = CQuaternion() , |
||
GLuint | un_vertices = 20 |
||
) |
Draws a circle, parallel to the XY plane.
By default the circle is red, with a radius of 0.1m and positioned in the origin. The circle reference system is positioned the center of the circle.
f_radius | radius of the circle. |
v_center_offset | circle's center offset with respect to the origin. |
c_color | color of the circle. |
b_fill | when true (default) the circle is filled with color |
c_orientation | defines the 3D rotation of the circle |
un_vertices | number of vertices to be used for approximating the circle. |
Definition at line 87 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::DrawCylinder | ( | Real | f_radius = 0.1f , |
Real | f_height = 0.1f , |
||
const CVector3 & | c_center_offset = CVector3::ZERO , |
||
const CColor & | c_color = CColor::RED , |
||
const CQuaternion & | c_orientation = CQuaternion() , |
||
GLuint | un_vertices = 20 |
||
) |
Draws a cylinder, with the height perpendicular to the XY plane.
By default the cylinder is red, with a radius of 0.1m, an height of 0.1m and positioned in the origin. The cylinder reference system is positioned at half the way along the segment connecting the center of the 2 circular faces, with the z axis along the segment.
f_radius | radius of the cylinder. |
f_height | height of the cylinder. |
v_center_offset | offset with respect to the origin where the circle will be drawn. |
c_color | color of the cylinder. |
c_orientation | defines the 3D rotation of the cylinder |
un_vertices | number of vertices to be used for approximating the circle. |
Definition at line 138 of file qtopengl_user_functions.cpp.
virtual void argos::CQTOpenGLUserFunctions::DrawInWorld | ( | ) | [inline, virtual] |
Drawing hook executed after all objects have been drawn.
Use this hook to draw your own stuff in the world. You must use OpenGL primitives. Coordinates are expressed wrt the world's origin.
Definition at line 96 of file qtopengl_user_functions.h.
virtual void argos::CQTOpenGLUserFunctions::DrawOverlay | ( | QPainter & | c_painter | ) | [inline, virtual] |
Drawing hook to put graphics on top of the OpenGL window.
Extend this method to draw stuff on top of the 3D graphical window. Use the methods in the Qt4 QPainter class to add all the stuff you want, such as text, shapes and so on.
c_painter | The QPainter object to draw the overlay. |
Definition at line 105 of file qtopengl_user_functions.h.
void argos::CQTOpenGLUserFunctions::DrawPoint | ( | const CVector3 & | c_position = CVector3(1.0f,0.0f,1.0f) , |
const CColor & | c_color = CColor::RED , |
||
const Real | f_point_diameter = 5.0 |
||
) |
Draws a point.
By default the point is positioned in the origin, drawn in red.
c_position | vector specifying the position of the point |
c_color | color of the point. |
f_point_diameter | diameter of the point. |
Definition at line 265 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::DrawPolygon | ( | const std::vector< CVector3 > & | vec_points, |
const CColor & | c_color = CColor::RED |
||
) |
Draws a polygon.
By default the polygon's color is red.
vec_points | vector of vectors defining the vertices of the polygon |
c_color | color of the polygon. |
Definition at line 284 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::DrawSegment | ( | const CVector3 & | c_end_point = CVector3(1.0f,0.0f,1.0f) , |
const CVector3 & | c_start_point = CVector3::ZERO , |
||
const CColor & | c_segment_color = CColor::RED , |
||
const Real & | f_line_width = 1.0f , |
||
bool | b_draw_end_point = false , |
||
bool | b_draw_start_point = false , |
||
const CColor & | c_end_point_color = CColor::RED , |
||
const CColor & | c_start_point_color = CColor::RED |
||
) |
Draws a segment, with optional endpoint markers.
By default the segment starts in the origin and ends in (1,0,1), it is drawn in red without end points markers. The end point markers default color is red.
c_end_point | vector specifying the end point of the segment. |
c_start_point | vector specifying the start point of the segment. |
c_segment_color | color of the segment. |
b_draw_end_point | when true the end point of the segment is drawn. |
b_draw_start_point | when true the start point of the segment is drawn. |
c_end_point_color | color of the end point if drawn. |
c_start_point_color | color of the end point if drawn. |
Definition at line 220 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::DrawTriangle | ( | const CVector3 & | c_center_offset = CVector3::ZERO , |
const CColor & | c_color = CColor::RED , |
||
const bool | b_fill = true , |
||
const CQuaternion & | c_orientation = CQuaternion() , |
||
Real | f_base = 0.2f , |
||
Real | f_height = 0.1732050808f |
||
) |
Draws a triangle, parallel to the XY plane.
By default the triangle is equilateral (edge length: 0.2m), red, with the height along the X axis, positioned in the origin. The triangle reference system is positioned in (h/2,b/2,0), with the X axis along the height of the triangle.
v_center_offset | triangle's center offset with respect to the origin. |
c_color | color of the triangle. |
b_fill | when true (default) the triangle is filled with color |
c_orientation | defines the 3D rotation of the triangle |
f_base | base of the the triangle |
f_height | height of the triangle |
Definition at line 34 of file qtopengl_user_functions.cpp.
Returns the QTOpenGL widget.
Definition at line 111 of file qtopengl_user_functions.h.
void argos::CQTOpenGLUserFunctions::RegisterUserFunction | ( | void(USER_IMPL::*)(ENTITY &) | pt_function | ) |
Registers a user method.
USER_IMPL | A user-defined subclass of CQTOpenGLUserFunctions. |
ENTITY | The entity type to pass as a parameter to the user-defined method. |
pt_function | The actual user-defined pointer-to-method. |
Definition at line 323 of file qtopengl_user_functions.h.
void argos::CQTOpenGLUserFunctions::SetOpenGLWidget | ( | CQTOpenGLWidget & | c_widget | ) | [inline] |
Sets the QTOpenGL widget for these user functions.
c_widget | The QTOpenGL widget. |
Definition at line 119 of file qtopengl_user_functions.h.