Fawkes API  Fawkes Development Version
hom_point_drawer.cpp
00001 
00002 /***************************************************************************
00003  *  hom_point_drawer.cpp - Drawer for the HomPoint class
00004  *
00005  *  Created: Thu Oct 09 14:34:19 2008
00006  *  Copyright  2008  Daniel Beck
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 <geometry/gtk/hom_point_drawer.h>
00025 #include <geometry/hom_point.h>
00026 
00027 /** @class fawkes::HomPointDrawer <geometry/gtk/hom_point_drawer.h>
00028  * Drawer for HomPoint objects.
00029  * @author Daniel Beck
00030  */
00031 
00032 /** @var fawkes::HomPointDrawer::m_point_size
00033  * The radius of the point.
00034  */
00035 
00036 namespace fawkes {
00037 
00038 /** Constructor.
00039  * @param p the HomPoint to draw
00040  */
00041 HomPointDrawer::HomPointDrawer(const HomPoint& p)
00042 {
00043   m_hom_point = new HomPoint(p);
00044   m_point_size = 0.1;
00045 }
00046 
00047 /** Destructor. */
00048 HomPointDrawer::~HomPointDrawer()
00049 {
00050   delete m_hom_point;
00051 }
00052 
00053 /** Set the point size with which points a drawn by this drawer.
00054  * @param s the point size
00055  */
00056 void
00057 HomPointDrawer::set_point_size(float s)
00058 {
00059   m_point_size = s;
00060 }
00061 
00062 void
00063 HomPointDrawer::draw(Cairo::RefPtr<Cairo::Context>& context)
00064 {
00065   float x = m_hom_point->x();
00066   float y = m_hom_point->y();
00067 
00068   context->save();
00069   context->move_to(x, y);
00070   context->arc(x, y, m_point_size, 0.0, 2.0 * M_PI);
00071   context->fill();
00072   context->restore();
00073   context->stroke();
00074 }
00075 
00076 } // end namespace fawkes