Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * allemaniacs_athome.cpp - CairoRobotDrawer for AllemaniACs AtHome robot 00004 * 00005 * Created: Fri Oct 10 10:37:09 2008 00006 * Copyright 2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <gui_utils/robot/allemaniacs_athome.h> 00025 00026 namespace fawkes { 00027 00028 /** @class AllemaniACsAtHomeCairoRobotDrawer <gui_utils/robot/allemaniacs_athome.h> 00029 * Draw AllemaniACs AtHome robot. 00030 * @author Tim Niemueller 00031 */ 00032 00033 /** Constructor. 00034 * @param laser_at_center if true the laser of the robot will be at (0,0) instead 00035 * of the real robot center. 00036 */ 00037 AllemaniACsAtHomeCairoRobotDrawer::AllemaniACsAtHomeCairoRobotDrawer(bool laser_at_center) 00038 { 00039 __laser_at_center = laser_at_center; 00040 } 00041 00042 void 00043 AllemaniACsAtHomeCairoRobotDrawer::draw_robot(Glib::RefPtr<Gdk::Window> &window, 00044 Cairo::RefPtr<Cairo::Context> &cr) 00045 { 00046 cr->save(); 00047 00048 if ( __laser_at_center ) { 00049 cr->translate(0, -0.12); 00050 } 00051 00052 // body 00053 cr->set_source_rgba(0.6, 0.6, 0.6, 0.6); 00054 cr->rectangle(-0.2, -0.2, 0.4, 0.38); 00055 cr->fill_preserve(); 00056 cr->set_source_rgba(0.4, 0.4, 0.4, 0.6); 00057 cr->stroke(); 00058 00059 // yellow arrow 00060 cr->move_to(0, -0.175); 00061 cr->line_to(0.18, 0.17); 00062 cr->line_to(-0.18, 0.17); 00063 cr->line_to(0, -0.175); 00064 cr->set_source_rgba(1, 1, 0, 0.5); 00065 cr->fill_preserve(); 00066 cr->stroke(); 00067 00068 // poles 00069 cr->set_source_rgba(0.4, 0.4, 0.4, 0.6); 00070 cr->arc(-0.19, -0.19, 0.005, 0, 2*M_PI); 00071 cr->fill_preserve(); cr->stroke(); 00072 cr->arc(-0.19, +0.17, 0.005, 0, 2*M_PI); 00073 cr->fill_preserve(); cr->stroke(); 00074 cr->arc(+0.19, +0.17, 0.005, 0, 2*M_PI); 00075 cr->fill_preserve(); cr->stroke(); 00076 cr->arc(+0.19, -0.19, 0.005, 0, 2*M_PI); 00077 cr->fill_preserve(); cr->stroke(); 00078 00079 // laser 00080 cr->set_source_rgba(0.4, 0.4, 0.4, 0.2); 00081 cr->arc(0, 0.12, 0.03, 0, 2*M_PI); 00082 cr->fill_preserve(); cr->stroke(); 00083 00084 cr->restore(); 00085 } 00086 00087 00088 }