7 #ifndef QTOPENGL_USER_FUNCTIONS_H
8 #define QTOPENGL_USER_FUNCTIONS_H
11 class CQTOpenGLUserFunctions;
17 #include <argos3/core/utility/configuration/base_configurable_resource.h>
18 #include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_main_window.h>
19 #include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h>
20 #include <argos3/core/utility/datatypes/color.h>
21 #include <argos3/core/utility/math/quaternion.h>
269 Real f_diameter = 5.0);
287 const bool b_fill =
true);
300 const std::vector<CVector2>& vec_points,
302 const bool b_fill =
true);
319 const bool b_fill =
true,
320 GLuint un_vertices = 20);
338 GLuint un_vertices = 20);
363 Real f_width = 1.0f);
374 const std::string& str_text,
376 const QFont& c_font = QFont());
395 template <
typename USER_IMPL,
typename ENTITY>
439 template <
typename USER_IMPL,
typename ENTITY>
460 template <
typename USER_IMPL,
typename ENTITY>
471 static USER_IMPL& cImpl =
static_cast<USER_IMPL&
>(*this);
473 ENTITY& cEntity =
static_cast<ENTITY&
>(c_entity);
477 (cImpl.*(cFunctionHolder.
Function))(cEntity);
480 template <
typename USER_IMPL,
typename ENTITY>
483 m_cThunks.Add<ENTITY>(&CQTOpenGLUserFunctions::Thunk<USER_IMPL,ENTITY>);
485 size_t unIdx = GetTag<ENTITY,CEntity>();
498 #define REGISTER_QTOPENGL_USER_FUNCTIONS(CLASSNAME, LABEL) \
499 REGISTER_SYMBOL(CQTOpenGLUserFunctions, \
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
This class is the base of all XML-configurable ARGoS interface.
The QTOpenGL user functions.
CQTOpenGLUserFunctions()
Class constructor.
virtual void EntityMoved(CEntity &c_entity, const CVector3 &c_old_pos, const CVector3 &c_new_pos)
Called every time an entity is moved.
std::vector< CFunctionHolder * > m_vecFunctionHolders
A vector of function holders.
void SetColor(const CColor &c_color)
Sets the current drawing color.
virtual void EntityDeselected(CEntity &c_entity)
Called every time an entity is deselected.
void SetMainWindow(CQTOpenGLMainWindow &c_main_win)
Sets the QTOpenGL main window for these user functions.
virtual void MouseKeyPressed(QMouseEvent *pc_event)
Called when a mouse key is pressed.
CVTable< CQTOpenGLUserFunctions, CEntity, TThunk > m_cThunks
The vtable storing the thunks.
virtual void EntityRotated(CEntity &c_entity, const CQuaternion &c_old_orientation, const CQuaternion &c_new_orientation)
Called every time an entity is rotated.
void Thunk(CEntity &c_entity)
A templetized thunk.
void DrawPoint(const CVector3 &c_position, const CColor &c_color=CColor::RED, Real f_diameter=5.0)
Draws a point.
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.
virtual void Destroy()
Undoes whatever was done by Init().
virtual void SelectEntity(CEntity &c_entity)
Selects the specified entity.
virtual void MouseMoved(QMouseEvent *pc_event)
Called when the mouse is moved.
virtual void KeyPressed(QKeyEvent *pc_event)
Called when a key press event occurs.
virtual ~CQTOpenGLUserFunctions()
Class destructor.
CQTOpenGLMainWindow & GetMainWindow()
Returns the QTOpenGL main window.
void RegisterUserFunction(void(USER_IMPL::*pt_function)(ENTITY &))
Registers a user method.
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
virtual void KeyReleased(QKeyEvent *pc_event)
Called when a key release event occurs.
virtual void Call(CEntity &c_entity)
Calls a user method for the given entity.
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.
void DrawBox(const CVector3 &c_position, const CQuaternion &c_orientation, const CVector3 &c_size, const CColor &c_color=CColor::RED)
Draws a box.
CQTOpenGLWidget & GetQTOpenGLWidget()
Returns the QTOpenGLWidget.
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.
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.
virtual void DrawInWorld()
Drawing hook executed after all objects have been drawn.
CEntity * GetSelectedEntity()
Returns the currently selected entity, or NULL.
virtual void EntitySelected(CEntity &c_entity)
Called every time an entity is selected.
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.
void(CQTOpenGLUserFunctions::* TThunk)(CEntity &)
Pointer-to-thunk type definition.
void DrawRay(const CRay3 &c_ray, const CColor &c_color=CColor::RED, Real f_width=1.0f)
Draws a ray, with optional endpoint markers.
virtual void Reset()
Resets the resource.
virtual void DrawOverlay(QPainter &c_painter)
Drawing hook to put graphics on top of the OpenGL window.
virtual void DeselectEntity()
Deselects the currently selected entity.
virtual void Draw(CFloorEntity &c_entity)
Drawing hook executed after the floor is drawn.
virtual void MouseKeyReleased(QMouseEvent *pc_event)
Called when a mouse key is released.
The base function holder.
The actual function holder.
void(USER_IMPL::* TFunction)(ENTITY &)
CFunctionHolderImpl(TFunction t_function)