Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LaserDrawingArea Class Reference

Laser drawing area. More...

#include "laser_drawing_area.h"

List of all members.

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.

Detailed Description

Laser drawing area.

Derived version of Gtk::DrawingArea that renders values of a laser interface.

Author:
Tim Niemueller

Definition at line 43 of file laser_drawing_area.h.


Member Enumeration Documentation

Draw modes.

Enumerator:
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.


Constructor & Destructor Documentation

LaserDrawingArea::LaserDrawingArea ( )

Constructor.

Definition at line 88 of file laser_drawing_area.cpp.

References MODE_LINES, on_button_press_event(), on_expose_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().

Parameters:
cobjectGtk C object
builderGtk Builder

Definition at line 52 of file laser_drawing_area.cpp.

References MODE_LINES, on_button_press_event(), on_expose_event(), and on_motion_notify_event().

LaserDrawingArea::~LaserDrawingArea ( )

Destructor.

Definition at line 119 of file laser_drawing_area.cpp.


Member Function Documentation

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.

Parameters:
itfeither Laser360Interface or Laser720Interface
windowGdk window
crCairo 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::deg2rad(), fawkes::Laser360Interface::distances(), fawkes::Laser720Interface::distances(), draw_scalebox(), fawkes::Laser720Interface::is_clockwise_angle(), fawkes::Laser360Interface::is_clockwise_angle(), fawkes::Laser360Interface::maxlenof_distances(), fawkes::Laser720Interface::maxlenof_distances(), MODE_LINES, 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

Parameters:
windowGdk window
crCairo 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 fawkes::Interface::has_writer(), fawkes::ObjectPositionInterface::is_valid(), fawkes::Interface::read(), fawkes::ObjectPositionInterface::relative_x(), fawkes::ObjectPositionInterface::relative_y(), and transform_coords_from_fawkes().

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.

Parameters:
windowGdk window
crCairo 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.

Parameters:
itfeither Laser360Interface or Laser720Interface
windowGdk window
crCairo 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::deg2rad(), fawkes::Laser720Interface::distances(), fawkes::Laser360Interface::distances(), fawkes::Interface::has_writer(), fawkes::Laser720Interface::maxlenof_distances(), MODE_POINTS, and fawkes::Interface::read().

bool LaserDrawingArea::on_button_press_event ( GdkEventButton *  event)
protectedvirtual

Button press event handler.

Parameters:
eventevent data
Returns:
true

Definition at line 995 of file laser_drawing_area.cpp.

Referenced by LaserDrawingArea().

bool LaserDrawingArea::on_expose_event ( GdkEventExpose *  event)
protectedvirtual

Expose event handler.

Parameters:
eventevent info structure.
Returns:
signal return value

Definition at line 343 of file laser_drawing_area.cpp.

References fawkes::Interface::has_writer(), fawkes::Interface::read(), and fawkes::Interface::uid().

Referenced by LaserDrawingArea().

bool LaserDrawingArea::on_motion_notify_event ( GdkEventMotion *  event)
protectedvirtual

Mouse motion notify event handler.

Parameters:
eventevent data
Returns:
true

Definition at line 1020 of file laser_drawing_area.cpp.

Referenced by LaserDrawingArea().

bool LaserDrawingArea::on_scroll_event ( GdkEventScroll *  event)
protectedvirtual

Scroll event handler.

Parameters:
eventevent structure
Returns:
signal return value

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.

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

Parameters:
modethe 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
   ...
   
Parameters:
ifsThe 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.

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

Parameters:
l_objpos_if_personslist of objectposition interfaces for persons
l_objpos_if_legslist of objectposition interfaces for legs
l_objpos_if_misclist of objectposition interfaces for miscellanous objects
laser_segmentation_ifLaser interface indicating the segmentation-borfers of the legtracker
l_track_iflist of track interfaces
target_ifthe current target
switch_ifused 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.

Parameters:
resolutionnew resolution

Definition at line 265 of file laser_drawing_area.cpp.

void LaserDrawingArea::set_robot_drawer ( fawkes::CairoRobotDrawer robot_drawer)

Set robot drawer.

Parameters:
robot_drawernew robot drawer to use

Definition at line 255 of file laser_drawing_area.cpp.

void LaserDrawingArea::set_rotation ( float  rot_rad)

Set rotation.

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

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

Parameters:
p_xinput x
p_yinput y
Returns:
the transformed position

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 LaserGuiGtkWindow::LaserGuiGtkWindow(), LaserGuiHildonWindow::LaserGuiHildonWindow(), and on_scroll_event().

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 LaserGuiGtkWindow::LaserGuiGtkWindow(), LaserGuiHildonWindow::LaserGuiHildonWindow(), and on_scroll_event().


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