ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CQTOpenGLUserFunctions Class Reference

The QTOpenGL user functions. More...

#include <qtopengl_user_functions.h>

List of all members.

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.
CQTOpenGLWidgetGetOpenGLWidget ()
 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.

Detailed Description

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.


Constructor & Destructor Documentation

Class constructor.

Definition at line 15 of file qtopengl_user_functions.cpp.

Class destructor.

Definition at line 24 of file qtopengl_user_functions.cpp.


Member Function Documentation

Calls a user method for the given entity.

Parameters:
Themethod 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.

Parameters:
f_radiusradius of the circle.
v_center_offsetcircle's center offset with respect to the origin.
c_colorcolor of the circle.
b_fillwhen true (default) the circle is filled with color
c_orientationdefines the 3D rotation of the circle
un_verticesnumber 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.

Parameters:
f_radiusradius of the cylinder.
f_heightheight of the cylinder.
v_center_offsetoffset with respect to the origin where the circle will be drawn.
c_colorcolor of the cylinder.
c_orientationdefines the 3D rotation of the cylinder
un_verticesnumber 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.

Parameters:
c_painterThe 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.

Parameters:
c_positionvector specifying the position of the point
c_colorcolor of the point.
f_point_diameterdiameter 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.

Parameters:
vec_pointsvector of vectors defining the vertices of the polygon
c_colorcolor 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.

Parameters:
c_end_pointvector specifying the end point of the segment.
c_start_pointvector specifying the start point of the segment.
c_segment_colorcolor of the segment.
b_draw_end_pointwhen true the end point of the segment is drawn.
b_draw_start_pointwhen true the start point of the segment is drawn.
c_end_point_colorcolor of the end point if drawn.
c_start_point_colorcolor 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.

Parameters:
v_center_offsettriangle's center offset with respect to the origin.
c_colorcolor of the triangle.
b_fillwhen true (default) the triangle is filled with color
c_orientationdefines the 3D rotation of the triangle
f_basebase of the the triangle
f_heightheight of the triangle

Definition at line 34 of file qtopengl_user_functions.cpp.

Returns the QTOpenGL widget.

Returns:
The QTOpenGL widget.

Definition at line 111 of file qtopengl_user_functions.h.

template<typename USER_IMPL , typename ENTITY >
void argos::CQTOpenGLUserFunctions::RegisterUserFunction ( void(USER_IMPL::*)(ENTITY &)  pt_function)

Registers a user method.

Parameters:
USER_IMPLA user-defined subclass of CQTOpenGLUserFunctions.
ENTITYThe entity type to pass as a parameter to the user-defined method.
pt_functionThe actual user-defined pointer-to-method.

Definition at line 323 of file qtopengl_user_functions.h.

Sets the QTOpenGL widget for these user functions.

Parameters:
c_widgetThe QTOpenGL widget.

Definition at line 119 of file qtopengl_user_functions.h.


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