Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
line_segment_drawer.cpp
1 
2 /***************************************************************************
3  * line_segment_drawer.cpp - Drawer for the LineSegment class
4  *
5  * Created: Thu Oct 09 14:49:20 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/line_segment_drawer.h>
25 #include <geometry/line_segment.h>
26 
27 /** @class fawkes::LineSegmentDrawer <geometry/gtk/line_segment_drawer.h>
28  * Drawer for LineSegment objects.
29  * @author Daniel Beck
30  */
31 
32 namespace fawkes {
33 
34 /** Constructor.
35  * @param l the LineSegement to drawer
36  */
38 {
39  m_line_segment = new LineSegment( l );
40 }
41 
42 /** Destructor. */
44 {
45  delete m_line_segment;
46 }
47 
48 void
49 LineSegmentDrawer::draw(Cairo::RefPtr<Cairo::Context>& context)
50 {
51  context->save();
52  context->move_to( m_line_segment->p1().x(),
53  m_line_segment->p1().y() );
54  context->line_to( m_line_segment->p2().x(),
55  m_line_segment->p2().y() );
56  context->stroke();
57  context->restore();
58 }
59 
60 } // end namespace fawkes
virtual float y() const
RO-getter for y.
Definition: hom_coord.cpp:115
const HomPoint & p1() const
Get the starting point.
A line segment.
Definition: line_segment.h:34
virtual ~LineSegmentDrawer()
Destructor.
LineSegmentDrawer(LineSegment l)
Constructor.
const HomPoint & p2() const
Get the endpoint.
virtual void draw(Cairo::RefPtr< Cairo::Context > &context)
This method is called by the GeomDrawingArea.
virtual float x() const
RO-getter for x.
Definition: hom_coord.cpp:85