The QTOpenGL user functions. More...
#include <qtopengl_user_functions.h>
Classes | |
class | CFunctionHolder |
The base function holder. More... | |
class | CFunctionHolderImpl |
The actual function holder. More... | |
Public Member Functions | |
CQTOpenGLUserFunctions () | |
Class constructor. More... | |
virtual | ~CQTOpenGLUserFunctions () |
Class destructor. More... | |
virtual void | Init (TConfigurationNode &t_tree) |
Initializes the resource. More... | |
virtual void | Reset () |
Resets the resource. More... | |
virtual void | Destroy () |
Undoes whatever was done by Init(). More... | |
virtual void | KeyPressed (QKeyEvent *pc_event) |
Called when a key press event occurs. More... | |
virtual void | KeyReleased (QKeyEvent *pc_event) |
Called when a key release event occurs. More... | |
virtual void | MouseKeyPressed (QMouseEvent *pc_event) |
Called when a mouse key is pressed. More... | |
virtual void | MouseKeyReleased (QMouseEvent *pc_event) |
Called when a mouse key is released. More... | |
virtual void | MouseMoved (QMouseEvent *pc_event) |
Called when the mouse is moved. More... | |
virtual void | EntitySelected (CEntity &c_entity) |
Called every time an entity is selected. More... | |
virtual void | EntityDeselected (CEntity &c_entity) |
Called every time an entity is deselected. More... | |
virtual void | EntityMoved (CEntity &c_entity, const CVector3 &c_old_pos, const CVector3 &c_new_pos) |
Called every time an entity is moved. More... | |
virtual void | EntityRotated (CEntity &c_entity, const CQuaternion &c_old_orientation, const CQuaternion &c_new_orientation) |
Called every time an entity is rotated. More... | |
CEntity * | GetSelectedEntity () |
Returns the currently selected entity, or NULL. More... | |
virtual void | SelectEntity (CEntity &c_entity) |
Selects the specified entity. More... | |
virtual void | DeselectEntity () |
Deselects the currently selected entity. More... | |
virtual void | Draw (CFloorEntity &c_entity) |
Drawing hook executed after the floor is drawn. More... | |
virtual void | DrawInWorld () |
Drawing hook executed after all objects have been drawn. More... | |
virtual void | DrawOverlay (QPainter &c_painter) |
Drawing hook to put graphics on top of the OpenGL window. More... | |
CQTOpenGLMainWindow & | GetMainWindow () |
Returns the QTOpenGL main window. More... | |
void | SetMainWindow (CQTOpenGLMainWindow &c_main_win) |
Sets the QTOpenGL main window for these user functions. More... | |
CQTOpenGLWidget & | GetQTOpenGLWidget () |
Returns the QTOpenGLWidget. More... | |
void | SetColor (const CColor &c_color) |
Sets the current drawing color. More... | |
void | DrawPoint (const CVector3 &c_position, const CColor &c_color=CColor::RED, Real f_diameter=5.0) |
Draws a point. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | DrawBox (const CVector3 &c_position, const CQuaternion &c_orientation, const CVector3 &c_size, const CColor &c_color=CColor::RED) |
Draws a box. More... | |
void | DrawRay (const CRay3 &c_ray, const CColor &c_color=CColor::RED, Real f_width=1.0f) |
Draws a ray, with optional endpoint markers. More... | |
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. More... | |
template<typename USER_IMPL , typename ENTITY > | |
void | RegisterUserFunction (void(USER_IMPL::*pt_function)(ENTITY &)) |
Registers a user method. More... | |
virtual void | Call (CEntity &c_entity) |
Calls a user method for the given entity. More... | |
Public Member Functions inherited from argos::CBaseConfigurableResource | |
virtual | ~CBaseConfigurableResource () |
Class destructor. More... | |
Protected Types | |
typedef void(CQTOpenGLUserFunctions::* | TThunk) (CEntity &) |
Pointer-to-thunk type definition. More... | |
Protected Member Functions | |
template<typename USER_IMPL , typename ENTITY > | |
void | Thunk (CEntity &c_entity) |
A templetized thunk. More... | |
Protected Attributes | |
CVTable< CQTOpenGLUserFunctions, CEntity, TThunk > | m_cThunks |
The vtable storing the thunks. More... | |
std::vector< CFunctionHolder * > | m_vecFunctionHolders |
A vector of function holders. More... | |
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); ... };
<p<blockquote>
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); ... }
<p<blockquote>
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 74 of file qtopengl_user_functions.h.
|
protected |
Pointer-to-thunk type definition.
Definition at line 384 of file qtopengl_user_functions.h.
argos::CQTOpenGLUserFunctions::CQTOpenGLUserFunctions | ( | ) |
Class constructor.
Definition at line 39 of file qtopengl_user_functions.cpp.
|
virtual |
Class destructor.
Definition at line 48 of file qtopengl_user_functions.cpp.
|
virtual |
Calls a user method for the given entity.
The | method to pass as parameter. |
Definition at line 490 of file qtopengl_user_functions.cpp.
|
virtual |
Deselects the currently selected entity.
Definition at line 86 of file qtopengl_user_functions.cpp.
|
inlinevirtual |
Undoes whatever was done by Init().
Implements argos::CBaseConfigurableResource.
Definition at line 90 of file qtopengl_user_functions.h.
|
inlinevirtual |
Drawing hook executed after the floor is drawn.
Definition at line 218 of file qtopengl_user_functions.h.
void argos::CQTOpenGLUserFunctions::DrawBox | ( | const CVector3 & | c_position, |
const CQuaternion & | c_orientation, | ||
const CVector3 & | c_size, | ||
const CColor & | c_color = CColor::RED |
||
) |
Draws a box.
By default the box is red and positioned in the origin. The reference system is positioned at the center of mass.
c_position | The position of the box center. |
c_orientation | The orientation of the box. |
c_size | The size of the box. |
c_color | The box color. |
Definition at line 306 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::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.
By default the circle is parallel to the XY plane and filled in red. The circle reference system is positioned at the circle center.
c_position | The circle position. |
c_orientation | The circle orientation. |
f_radius | The circle radius. |
c_color | The circle color. |
b_fill | When true , the triangle is filled. |
un_vertices | The number of vertices used to draw the circle. |
Definition at line 220 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::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.
By default the cylinder is red and positioned in the origin. The reference system is positioned at the center of mass.
c_position | The cylinder position. |
c_orientation | The cylinder orientation of the cylinder. |
f_radius | The cylinder radius. |
f_height | The cylinder height. |
c_color | The cylinder color. |
un_vertices | The number of vertices used to draw the cylinder bases. |
Definition at line 256 of file qtopengl_user_functions.cpp.
|
inlinevirtual |
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 225 of file qtopengl_user_functions.h.
|
inlinevirtual |
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 234 of file qtopengl_user_functions.h.
void argos::CQTOpenGLUserFunctions::DrawPoint | ( | const CVector3 & | c_position, |
const CColor & | c_color = CColor::RED , |
||
Real | f_diameter = 5.0 |
||
) |
Draws a point.
By default the point drawn in red.
c_position | The point position. |
c_color | The point color. |
f_diameter | The point diameter. |
Definition at line 130 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::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.
By default the polygon is parallel to the XY plane and its fill color is red.
c_position | The polygon position. |
c_orientation | The polygon orientation. |
vec_points | The polygon vertices. |
c_color | The polygon color. |
b_fill | When true , the polygon is filled. |
Definition at line 184 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::DrawRay | ( | const CRay3 & | c_ray, |
const CColor & | c_color = CColor::RED , |
||
Real | f_width = 1.0f |
||
) |
Draws a ray, with optional endpoint markers.
By default the ray is drawn in red without end points markers. The end point markers default color is red.
c_ray | The ray coordinates. |
c_color | The ray color. |
f_width | The ray width. |
Definition at line 366 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::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.
By default the text is black and aligned left.
c_position | The text position. |
str_text | The text to display |
c_color | The text color |
c_font | A Qt font configuration |
Definition at line 421 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::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.
By default the triangle is parallel to the XY plane, equilateral, with the height along the X axis. The triangle reference system is positioned in at the center of the triangle base.
c_position | The triangle position. |
c_orientation | The triangle orientation. |
f_base | The length of the triangle base. |
f_height | The length of the triangle height. |
c_color | The triangle color. |
b_fill | When true , the triangle is filled. |
Definition at line 151 of file qtopengl_user_functions.cpp.
|
inlinevirtual |
Called every time an entity is deselected.
c_entity | The deselected entity. |
Definition at line 170 of file qtopengl_user_functions.h.
|
inlinevirtual |
Called every time an entity is moved.
c_entity | The moved entity. |
c_old_pos | The old position of the entity. |
c_new_pos | The new position of the entity. |
Definition at line 178 of file qtopengl_user_functions.h.
|
inlinevirtual |
Called every time an entity is rotated.
c_entity | The rotated entity. |
c_old_orientation | The old orientation of the entity. |
c_new_orientation | The new orientation of the entity. |
Definition at line 188 of file qtopengl_user_functions.h.
|
inlinevirtual |
Called every time an entity is selected.
c_entity | The selected entity. |
Definition at line 164 of file qtopengl_user_functions.h.
CQTOpenGLMainWindow & argos::CQTOpenGLUserFunctions::GetMainWindow | ( | ) |
Returns the QTOpenGL main window.
Definition at line 93 of file qtopengl_user_functions.cpp.
CQTOpenGLWidget & argos::CQTOpenGLUserFunctions::GetQTOpenGLWidget | ( | ) |
Returns the QTOpenGLWidget.
Definition at line 107 of file qtopengl_user_functions.cpp.
CEntity * argos::CQTOpenGLUserFunctions::GetSelectedEntity | ( | ) |
Returns the currently selected entity, or NULL.
Definition at line 72 of file qtopengl_user_functions.cpp.
|
inlinevirtual |
Initializes the resource.
t_tree | the base of the XML configuration tree to parse |
CARGoSException | if an error occurs |
Implements argos::CBaseConfigurableResource.
Definition at line 88 of file qtopengl_user_functions.h.
|
virtual |
Called when a key press event occurs.
The focus must be on the QTOpenGL widget. QTOpenGL reserves the following keys for camera movement:
pc_event | The key press event. |
Definition at line 58 of file qtopengl_user_functions.cpp.
|
virtual |
Called when a key release event occurs.
The focus must be on the QTOpenGL widget. QTOpenGL reserves the following keys for camera movement:
pc_event | The key release event. |
Definition at line 65 of file qtopengl_user_functions.cpp.
|
inlinevirtual |
Called when a mouse key is pressed.
The focus must be on the QTOpenGL widget.
QTOpenGL reserves the following events:
Other combinations, e.g., mouse pressed while alt is pressed, are available.
Definition at line 133 of file qtopengl_user_functions.h.
|
inlinevirtual |
Called when a mouse key is released.
The focus must be on the QTOpenGL widget.
QTOpenGL reserves the following events:
Other combinations, e.g., mouse released while alt is pressed, are available.
Definition at line 148 of file qtopengl_user_functions.h.
|
inlinevirtual |
Called when the mouse is moved.
The focus must be on the QTOpenGL widget.
QTOpenGL reserves the following events:
Definition at line 158 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 481 of file qtopengl_user_functions.h.
|
inlinevirtual |
Resets the resource.
Implements argos::CBaseConfigurableResource.
Definition at line 89 of file qtopengl_user_functions.h.
|
virtual |
Selects the specified entity.
Definition at line 79 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::SetColor | ( | const CColor & | c_color | ) |
Sets the current drawing color.
c_color | The desired color. |
Definition at line 114 of file qtopengl_user_functions.cpp.
void argos::CQTOpenGLUserFunctions::SetMainWindow | ( | CQTOpenGLMainWindow & | c_main_win | ) |
Sets the QTOpenGL main window for these user functions.
c_widget | The QTOpenGL main window. |
Definition at line 100 of file qtopengl_user_functions.cpp.
|
protected |
A templetized thunk.
This is a trampoline function that internally performs the dispatch to a user-defined method.
USER_IMPL | A user-defined subclass of CQTOpenGLUserFunctions. |
ENTITY | The entity type to pass as a parameter to the user-defined method. |
c_entity | The entity to pass as parameter. |
Definition at line 461 of file qtopengl_user_functions.h.
|
protected |
The vtable storing the thunks.
Definition at line 423 of file qtopengl_user_functions.h.
|
protected |
A vector of function holders.
Definition at line 429 of file qtopengl_user_functions.h.