Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
geom_drawing_area.h
1 
2 /***************************************************************************
3  * geom_drawing_area.h - A Gtk::DrawingArea for objects of the Fawkes
4  * geometry library
5  *
6  * Created: Wed Oct 08 18:35:19 2008
7  * Copyright 2008 Daniel Beck
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef __GEOMETRY_GEOM_DRAWING_AREA_H_
26 #define __GEOMETRY_GEOM_DRAWING_AREA_H_
27 
28 #include <gtkmm.h>
29 #ifdef HAVE_GLADEMM
30 # include <libglademm/xml.h>
31 #endif
32 
33 #include <vector>
34 
35 namespace fawkes{
36 class GeomDrawer;
37 class HomPoint;
38 class HomVector;
39 class LineSegment;
40 class Bezier;
41 class Spline;
42 class DrawingManipulator;
43 
44 class GeomDrawingArea : public Gtk::DrawingArea
45 {
46  public:
47  GeomDrawingArea( float max_x = 5.0,
48  float max_y = 5.0,
49  float min_x = -5.0,
50  float min_y = -5.0 );
51 #ifdef HAVE_GLADEMM
52  GeomDrawingArea(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& ref_xml);
53 #endif
54  virtual ~GeomDrawingArea();
55 
56  void clear();
57 
60  GeomDrawingArea& operator<<(std::pair<HomVector, HomPoint> v);
66 
67  virtual void to_drawing_coords(int window_x, int window_y, float& drawing_x, float& drawing_y);
68 
69  protected:
70  virtual void pre_draw(Cairo::RefPtr<Cairo::Context>& context);
71  virtual void post_draw(Cairo::RefPtr<Cairo::Context>& context);
72 
73  private:
74  virtual bool on_expose_event(GdkEventExpose* event);
75 
76  std::vector<fawkes::GeomDrawer*> m_drawers;
77  fawkes::DrawingManipulator* m_cur_drawing_manipulator;
78 
79  float m_max_x;
80  float m_max_y;
81  float m_min_x;
82  float m_min_y;
83 
84  float m_unit;
85 
86  int m_window_width;
87  int m_window_height;
88 };
89 
90 } // end namespace fawkes
91 
92 #endif /* __GEOMETRY_GEOM_DRAWING_AREA_H_ */