Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
hom_point_drawer.cpp
1 
2 /***************************************************************************
3  * hom_point_drawer.cpp - Drawer for the HomPoint class
4  *
5  * Created: Thu Oct 09 14:34:19 2008
6  * Copyright 2008 Daniel Beck
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 <geometry/gtk/hom_point_drawer.h>
25 #include <geometry/hom_point.h>
26 
27 /** @class fawkes::HomPointDrawer <geometry/gtk/hom_point_drawer.h>
28  * Drawer for HomPoint objects.
29  * @author Daniel Beck
30  */
31 
32 /** @var fawkes::HomPointDrawer::m_point_size
33  * The radius of the point.
34  */
35 
36 namespace fawkes {
37 
38 /** Constructor.
39  * @param p the HomPoint to draw
40  */
42 {
43  m_hom_point = new HomPoint(p);
44  m_point_size = 0.1;
45 }
46 
47 /** Destructor. */
49 {
50  delete m_hom_point;
51 }
52 
53 /** Set the point size with which points a drawn by this drawer.
54  * @param s the point size
55  */
56 void
58 {
59  m_point_size = s;
60 }
61 
62 void
63 HomPointDrawer::draw(Cairo::RefPtr<Cairo::Context>& context)
64 {
65  float x = m_hom_point->x();
66  float y = m_hom_point->y();
67 
68  context->save();
69  context->move_to(x, y);
70  context->arc(x, y, m_point_size, 0.0, 2.0 * M_PI);
71  context->fill();
72  context->restore();
73  context->stroke();
74 }
75 
76 } // end namespace fawkes
virtual float y() const
RO-getter for y.
Definition: hom_coord.cpp:115
float m_point_size
The radius of the point.
A homogeneous point.
Definition: hom_point.h:33
virtual ~HomPointDrawer()
Destructor.
HomPointDrawer(const HomPoint &p)
Constructor.
virtual void draw(Cairo::RefPtr< Cairo::Context > &context)
This method is called by the GeomDrawingArea.
void set_point_size(float s)
Set the point size with which points a drawn by this drawer.
virtual float x() const
RO-getter for x.
Definition: hom_coord.cpp:85