Fawkes API
Fawkes Development Version
|
Laser drawing area. More...
#include "laser_drawing_area.h"
Public Types | |
enum | draw_mode_t { MODE_LINES, MODE_POINTS, MODE_HULL } |
Draw modes. More... | |
Public Member Functions | |
LaserDrawingArea () | |
Constructor. | |
LaserDrawingArea (BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder) | |
Constructor. | |
~LaserDrawingArea () | |
Destructor. | |
void | set_laser_ifs (const std::list< fawkes::Interface * > &laser_if) |
Set new laser interfaces. | |
void | reset_laser_ifs () |
Reset laser interfaces to "no laser available". | |
void | set_objpos_if (std::list< fawkes::ObjectPositionInterface * > *l_objpos_if_persons, std::list< fawkes::ObjectPositionInterface * > *l_objpos_if_legs, std::list< fawkes::ObjectPositionInterface * > *l_objpos_if_misc, fawkes::Laser720Interface *laser_segmentation_if, std::list< fawkes::Position2DTrackInterface * > *l_track_if, fawkes::ObjectPositionInterface *target_if, fawkes::SwitchInterface *switch_if) |
Set ObjectPosition interfaces. | |
void | set_line_if (fawkes::ObjectPositionInterface *line_if) |
Set line interface. | |
void | set_visdisp_if (fawkes::VisualDisplay2DInterface *visdisp_if) |
Set visual display interface. | |
void | set_robot_drawer (fawkes::CairoRobotDrawer *robot_drawer) |
Set robot drawer. | |
void | set_resolution (unsigned int resolution) |
Set resolution. | |
void | zoom_in () |
Zoom in. | |
void | zoom_out () |
Zoom out. | |
void | set_rotation (float rot_rad) |
Set rotation. | |
void | set_draw_mode (draw_mode_t mode) |
Set the drawing mode. | |
void | set_connected (bool connected) |
Set connection status. | |
void | toggle_break_drawing () |
Set a member for breaking the drawing. | |
Protected Member Functions | |
virtual bool | on_expose_event (GdkEventExpose *event) |
Expose event handler. | |
virtual bool | on_scroll_event (GdkEventScroll *event) |
Scroll event handler. | |
virtual bool | on_motion_notify_event (GdkEventMotion *event) |
Mouse motion notify event handler. | |
virtual bool | on_button_press_event (GdkEventButton *event) |
Button press event handler. | |
void | draw_beams (const fawkes::Interface *itf, Glib::RefPtr< Gdk::Window > &window, const Cairo::RefPtr< Cairo::Context > &cr) |
Draw Beams of an interface. | |
void | draw_segments (const fawkes::Interface *itf, Glib::RefPtr< Gdk::Window > &window, const Cairo::RefPtr< Cairo::Context > &cr) |
Draw laser segments as produced by leg tracker application. | |
void | draw_scalebox (Glib::RefPtr< Gdk::Window > &window, const Cairo::RefPtr< Cairo::Context > &cr) |
Draw scale box. | |
void | draw_persons_legs (Glib::RefPtr< Gdk::Window > &window, const Cairo::RefPtr< Cairo::Context > &cr) |
Draw person legs. | |
std::pair< float, float > | transform_coords_from_fawkes (float p_x, float p_y) |
Transform a position from the fawkes coordinate system to the Cairo coordinate system. |
Laser drawing area.
Derived version of Gtk::DrawingArea that renders values of a laser interface.
Draw modes.
MODE_LINES |
Draw beams as lines. |
MODE_POINTS |
Only draw beam end points. |
MODE_HULL |
Draw hull of beams. |
Definition at line 48 of file laser_drawing_area.h.
LaserDrawingArea::LaserDrawingArea | ( | ) |
Constructor.
Definition at line 88 of file laser_drawing_area.cpp.
References MODE_LINES, on_expose_event(), on_button_press_event(), and on_motion_notify_event().
LaserDrawingArea::LaserDrawingArea | ( | BaseObjectType * | cobject, |
const Glib::RefPtr< Gtk::Builder > & | builder | ||
) |
Constructor.
Special ctor to be used with Gtk::Builder's get_widget_derived().
cobject | Gtk C object |
builder | Gtk Builder |
Definition at line 52 of file laser_drawing_area.cpp.
References MODE_LINES, on_expose_event(), on_button_press_event(), and on_motion_notify_event().
LaserDrawingArea::~LaserDrawingArea | ( | ) |
Destructor.
Definition at line 119 of file laser_drawing_area.cpp.
void LaserDrawingArea::draw_beams | ( | const fawkes::Interface * | itf, |
Glib::RefPtr< Gdk::Window > & | window, | ||
const Cairo::RefPtr< Cairo::Context > & | cr | ||
) | [protected] |
Draw Beams of an interface.
Draws the beams as lines, circles or hull, depending on draw mode.
itf | either Laser360Interface or Laser720Interface |
window | Gdk window |
cr | Cairo context to draw to. It is assumed that possible transformations have been setup before. |
Definition at line 517 of file laser_drawing_area.cpp.
References fawkes::Laser360Interface::distances(), fawkes::Laser360Interface::maxlenof_distances(), fawkes::Laser360Interface::is_clockwise_angle(), fawkes::Laser720Interface::distances(), fawkes::Laser720Interface::maxlenof_distances(), fawkes::Laser720Interface::is_clockwise_angle(), draw_scalebox(), MODE_LINES, fawkes::deg2rad(), MODE_POINTS, and fawkes::normalize_rad().
void LaserDrawingArea::draw_persons_legs | ( | Glib::RefPtr< Gdk::Window > & | window, |
const Cairo::RefPtr< Cairo::Context > & | cr | ||
) | [protected] |
Draw person legs.
Draws the legs of persons
window | Gdk window |
cr | Cairo context to draw to. It is assumed that possible transformations have been setup before. |
Definition at line 602 of file laser_drawing_area.cpp.
References transform_coords_from_fawkes(), fawkes::Interface::has_writer(), fawkes::Interface::read(), fawkes::ObjectPositionInterface::is_valid(), fawkes::ObjectPositionInterface::relative_x(), and fawkes::ObjectPositionInterface::relative_y().
void LaserDrawingArea::draw_scalebox | ( | Glib::RefPtr< Gdk::Window > & | window, |
const Cairo::RefPtr< Cairo::Context > & | cr | ||
) | [protected] |
Draw scale box.
Draws a circle with a radius of 1m around the robot.
window | Gdk window |
cr | Cairo context to draw to. It is assumed that possible transformations have been setup before. |
Definition at line 498 of file laser_drawing_area.cpp.
Referenced by draw_beams().
void LaserDrawingArea::draw_segments | ( | const fawkes::Interface * | itf, |
Glib::RefPtr< Gdk::Window > & | window, | ||
const Cairo::RefPtr< Cairo::Context > & | cr | ||
) | [protected] |
Draw laser segments as produced by leg tracker application.
itf | either Laser360Interface or Laser720Interface |
window | Gdk window |
cr | Cairo context to draw to. It is assumed that possible transformations have been setup before. |
Definition at line 897 of file laser_drawing_area.cpp.
References fawkes::Laser720Interface::maxlenof_distances(), fawkes::Laser360Interface::distances(), fawkes::Laser720Interface::distances(), fawkes::Interface::has_writer(), fawkes::Interface::read(), MODE_POINTS, and fawkes::deg2rad().
bool LaserDrawingArea::on_button_press_event | ( | GdkEventButton * | event | ) | [protected, virtual] |
Button press event handler.
event | event data |
Definition at line 995 of file laser_drawing_area.cpp.
Referenced by LaserDrawingArea().
bool LaserDrawingArea::on_expose_event | ( | GdkEventExpose * | event | ) | [protected, virtual] |
Expose event handler.
event | event info structure. |
Definition at line 343 of file laser_drawing_area.cpp.
References fawkes::Interface::has_writer(), fawkes::Interface::uid(), and fawkes::Interface::read().
Referenced by LaserDrawingArea().
bool LaserDrawingArea::on_motion_notify_event | ( | GdkEventMotion * | event | ) | [protected, virtual] |
Mouse motion notify event handler.
event | event data |
Definition at line 1020 of file laser_drawing_area.cpp.
Referenced by LaserDrawingArea().
bool LaserDrawingArea::on_scroll_event | ( | GdkEventScroll * | event | ) | [protected, virtual] |
Scroll event handler.
event | event structure |
Definition at line 972 of file laser_drawing_area.cpp.
References zoom_in(), and zoom_out().
void LaserDrawingArea::reset_laser_ifs | ( | ) |
Reset laser interfaces to "no laser available".
Definition at line 209 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_connected | ( | bool | connected | ) |
Set connection status.
connected | true if connected, false otherwise |
Definition at line 154 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_draw_mode | ( | draw_mode_t | mode | ) |
Set the drawing mode.
mode | the new drawing mode |
Definition at line 275 of file laser_drawing_area.cpp.
Referenced by LaserGuiGtkWindow::LaserGuiGtkWindow(), and LaserGuiHildonWindow::LaserGuiHildonWindow().
void LaserDrawingArea::set_laser_ifs | ( | const std::list< fawkes::Interface * > & | ifs | ) |
Set new laser interfaces.
This is also the place where colors are determined the following way:
1 000 -> 0 0 0 2 001 -> 255 0 0 3 010 -> 0 255 0 4 011 -> 255 255 0 5 100 -> 0 0 255 6 101 -> 255 0 255 7 110 -> 255 255 0 8 000 -> 0 0 0 9 001 -> 127 0 0 10 010 -> 0 127 0 11 011 -> 127 127 0 12 100 -> 0 0 127 13 101 -> 127 0 127 14 110 -> 127 127 0 ...
ifs | The interfaces of the lasers that should be visualized. |
Definition at line 185 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_line_if | ( | fawkes::ObjectPositionInterface * | line_if | ) |
Set line interface.
line_if | interface to use for line data to draw. |
Definition at line 234 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_objpos_if | ( | std::list< fawkes::ObjectPositionInterface * > * | l_objpos_if_persons, |
std::list< fawkes::ObjectPositionInterface * > * | l_objpos_if_legs, | ||
std::list< fawkes::ObjectPositionInterface * > * | l_objpos_if_misc, | ||
fawkes::Laser720Interface * | laser_segmentation_if, | ||
std::list< fawkes::Position2DTrackInterface * > * | l_track_if, | ||
fawkes::ObjectPositionInterface * | target_if, | ||
fawkes::SwitchInterface * | switch_if | ||
) |
Set ObjectPosition interfaces.
l_objpos_if_persons | list of objectposition interfaces for persons |
l_objpos_if_legs | list of objectposition interfaces for legs |
l_objpos_if_misc | list of objectposition interfaces for miscellanous objects |
laser_segmentation_if | Laser interface indicating the segmentation-borfers of the legtracker |
l_track_if | list of track interfaces |
target_if | the current target |
switch_if | used to indicate that a drawing-run is finish (so e.g. new data can be sent) |
Definition at line 134 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_resolution | ( | unsigned int | resolution | ) |
Set resolution.
Every n'th beam will be drawn where n is the resolution.
resolution | new resolution |
Definition at line 265 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_robot_drawer | ( | fawkes::CairoRobotDrawer * | robot_drawer | ) |
Set robot drawer.
robot_drawer | new robot drawer to use |
Definition at line 255 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_rotation | ( | float | rot_rad | ) |
Set rotation.
rot_rad | rotation angle in rad |
Definition at line 310 of file laser_drawing_area.cpp.
void LaserDrawingArea::set_visdisp_if | ( | fawkes::VisualDisplay2DInterface * | visdisp_if | ) |
Set visual display interface.
visdisp_if | interface to query for drawing ops |
Definition at line 244 of file laser_drawing_area.cpp.
References VisualDisplay2D::set_interface().
void LaserDrawingArea::toggle_break_drawing | ( | ) |
Set a member for breaking the drawing.
Definition at line 984 of file laser_drawing_area.cpp.
std::pair< float, float > LaserDrawingArea::transform_coords_from_fawkes | ( | float | p_x, |
float | p_y | ||
) | [protected] |
Transform a position from the fawkes coordinate system to the Cairo coordinate system.
p_x | input x |
p_y | input y |
Definition at line 1043 of file laser_drawing_area.cpp.
Referenced by draw_persons_legs().
void LaserDrawingArea::zoom_in | ( | ) |
Zoom in.
Increases zoom factor by 20, no upper limit.
Definition at line 285 of file laser_drawing_area.cpp.
Referenced by on_scroll_event(), LaserGuiGtkWindow::LaserGuiGtkWindow(), and LaserGuiHildonWindow::LaserGuiHildonWindow().
void LaserDrawingArea::zoom_out | ( | ) |
Zoom out.
Decreases zoom factor by 20 with a minimum of 1.
Definition at line 295 of file laser_drawing_area.cpp.
Referenced by on_scroll_event(), LaserGuiGtkWindow::LaserGuiGtkWindow(), and LaserGuiHildonWindow::LaserGuiHildonWindow().