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>
249 Real f_diameter = 5.0);
267 const bool b_fill =
true);
280 const std::vector<CVector2>& vec_points,
282 const bool b_fill =
true);
299 const bool b_fill =
true,
300 GLuint un_vertices = 20);
318 GLuint un_vertices = 20);
343 Real f_width = 1.0f);
354 const std::string& str_text,
356 const QFont& c_font = QFont());
375 template <
typename USER_IMPL,
typename ENTITY>
419 template <
typename USER_IMPL,
typename ENTITY>
440 template <
typename USER_IMPL,
typename ENTITY>
451 static USER_IMPL& cImpl =
static_cast<USER_IMPL&
>(*this);
453 ENTITY& cEntity =
static_cast<ENTITY&
>(c_entity);
457 (cImpl.*(cFunctionHolder.
Function))(cEntity);
460 template <
typename USER_IMPL,
typename ENTITY>
463 m_cThunks.
Add<ENTITY>(&CQTOpenGLUserFunctions::Thunk<USER_IMPL,ENTITY>);
465 size_t unIdx = GetTag<ENTITY,CEntity>();
466 if(m_vecFunctionHolders.size() <= unIdx) {
467 m_vecFunctionHolders.resize(unIdx+1, NULL);
478 #define REGISTER_QTOPENGL_USER_FUNCTIONS(CLASSNAME, LABEL) \
479 REGISTER_SYMBOL(CQTOpenGLUserFunctions, \
void DrawBox(const CVector3 &c_position, const CQuaternion &c_orientation, const CVector3 &c_size, const CColor &c_color=CColor::RED)
Draws a box.
void DrawPoint(const CVector3 &c_position, const CColor &c_color=CColor::RED, Real f_diameter=5.0)
Draws a point.
The QTOpenGL user functions.
virtual void EntitySelected(CEntity &c_entity)
Called every time an entity is selected.
virtual void Reset()
Resets the resource.
CQTOpenGLWidget & GetQTOpenGLWidget()
Returns the QTOpenGLWidget.
void(CQTOpenGLUserFunctions::* TThunk)(CEntity &)
Pointer-to-thunk type definition.
float Real
Collects all ARGoS code.
std::vector< CFunctionHolder * > m_vecFunctionHolders
A vector of function holders.
The actual function holder.
virtual void Destroy()
Undoes whatever was done by Init().
void SetMainWindow(CQTOpenGLMainWindow &c_main_win)
Sets the QTOpenGL main window for these user functions.
void RegisterUserFunction(void(USER_IMPL::*pt_function)(ENTITY &))
Registers a user method.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
void(USER_IMPL::* TFunction)(ENTITY &)
virtual void DrawInWorld()
Drawing hook executed after all objects have been drawn.
virtual void SelectEntity(CEntity &c_entity)
Selects the specified entity.
void DrawRay(const CRay3 &c_ray, const CColor &c_color=CColor::RED, Real f_width=1.0f)
Draws a ray, with optional endpoint markers.
void SetColor(const CColor &c_color)
Sets the current drawing color.
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.
virtual void Call(CEntity &c_entity)
Calls a user method for the given entity.
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.
virtual ~CQTOpenGLUserFunctions()
Class destructor.
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 DeselectEntity()
Deselects the currently selected 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.
virtual void KeyPressed(QKeyEvent *pc_event)
Called when a key press event occurs.
CQTOpenGLUserFunctions()
Class constructor.
The base function holder.
CQTOpenGLMainWindow & GetMainWindow()
Returns the QTOpenGL main window.
CEntity * GetSelectedEntity()
Returns the currently selected entity, or NULL.
void Add(FUNCTION t_function)
CFunctionHolderImpl(TFunction t_function)
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
virtual void KeyReleased(QKeyEvent *pc_event)
Called when a key release event occurs.
virtual void Draw(CFloorEntity &c_entity)
Drawing hook executed after the floor is drawn.
virtual void MouseKeyPressed(QMouseEvent *pc_event)
Called when a mouse key is pressed.
The namespace containing all the ARGoS related code.
virtual void EntityDeselected(CEntity &c_entity)
Called every time an entity is deselected.
This class is the base of all XML-configurable ARGoS interface.
void Thunk(CEntity &c_entity)
A templetized thunk.
virtual void MouseMoved(QMouseEvent *pc_event)
Called when the mouse is moved.
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 MouseKeyReleased(QMouseEvent *pc_event)
Called when a mouse key is released.
CVTable< CQTOpenGLUserFunctions, CEntity, TThunk > m_cThunks
The vtable storing the thunks.
virtual void DrawOverlay(QPainter &c_painter)
Drawing hook to put graphics on top of the OpenGL window.