Fawkes API  Fawkes Development Version
allemaniacs_athome.cpp
1 
2 /***************************************************************************
3  * allemaniacs_athome.cpp - CairoRobotDrawer for AllemaniACs AtHome robot
4  *
5  * Created: Fri Oct 10 10:37:09 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <gui_utils/robot/allemaniacs_athome.h>
25 
26 namespace fawkes {
27 
28 /** @class AllemaniACsAtHomeCairoRobotDrawer <gui_utils/robot/allemaniacs_athome.h>
29  * Draw AllemaniACs AtHome robot.
30  * @author Tim Niemueller
31  */
32 
33 /** Constructor.
34  * @param laser_at_center if true the laser of the robot will be at (0,0) instead
35  * of the real robot center.
36  */
38 {
39  __laser_at_center = laser_at_center;
40 }
41 
42 void
43 AllemaniACsAtHomeCairoRobotDrawer::draw_robot(Glib::RefPtr<Gdk::Window> &window,
44  const Cairo::RefPtr<Cairo::Context> &cr)
45 {
46  cr->save();
47 
48  if ( __laser_at_center ) {
49  cr->translate(0, -0.12);
50  }
51 
52  // body
53  cr->set_source_rgba(0.6, 0.6, 0.6, 0.6);
54  cr->rectangle(-0.2, -0.2, 0.4, 0.38);
55  cr->fill_preserve();
56  cr->set_source_rgba(0.4, 0.4, 0.4, 0.6);
57  cr->stroke();
58 
59  // yellow arrow
60  cr->move_to(0, -0.175);
61  cr->line_to(0.18, 0.17);
62  cr->line_to(-0.18, 0.17);
63  cr->line_to(0, -0.175);
64  cr->set_source_rgba(1, 1, 0, 0.5);
65  cr->fill_preserve();
66  cr->stroke();
67 
68  // poles
69  cr->set_source_rgba(0.4, 0.4, 0.4, 0.6);
70  cr->arc(-0.19, -0.19, 0.005, 0, 2*M_PI);
71  cr->fill_preserve(); cr->stroke();
72  cr->arc(-0.19, +0.17, 0.005, 0, 2*M_PI);
73  cr->fill_preserve(); cr->stroke();
74  cr->arc(+0.19, +0.17, 0.005, 0, 2*M_PI);
75  cr->fill_preserve(); cr->stroke();
76  cr->arc(+0.19, -0.19, 0.005, 0, 2*M_PI);
77  cr->fill_preserve(); cr->stroke();
78 
79  // laser
80  cr->set_source_rgba(0.4, 0.4, 0.4, 0.2);
81  cr->arc(0, 0.12, 0.03, 0, 2*M_PI);
82  cr->fill_preserve(); cr->stroke();
83 
84  cr->restore();
85 }
86 
87 
88 }
virtual void draw_robot(Glib::RefPtr< Gdk::Window > &window, const Cairo::RefPtr< Cairo::Context > &cr)
Draw robot.
Fawkes library namespace.
AllemaniACsAtHomeCairoRobotDrawer(bool laser_at_center=false)
Constructor.