geom_drawing_area.h

00001
00002 /***************************************************************************
00003  *  geom_drawing_area.h - A Gtk::DrawingArea for objects of the Fawkes
00004  *  geometry library
00005  *
00006  *  Created: Wed Oct 08 18:35:19 2008
00007  *  Copyright  2008  Daniel Beck
00008  *
00009  ****************************************************************************/
00010
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version. A runtime exception applies to
00015  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00023  */
00024
00025 #ifndef __GEOMETRY_GEOM_DRAWING_AREA_H_
00026 #define __GEOMETRY_GEOM_DRAWING_AREA_H_
00027 
00028 #include <gtkmm.h>
00029 #include <libglademm/xml.h>
00030
00031 #include <vector>
00032
00033 namespace fawkes{
00034 class GeomDrawer;
00035 class HomPoint;
00036 class HomVector;
00037 class LineSegment;
00038 class Bezier;
00039 class Spline;
00040 class DrawingManipulator;
00041
00042 class GeomDrawingArea : public Gtk::DrawingArea
00043 {
00044  public:
00045   GeomDrawingArea( float max_x =  5.0,
00046                    float max_y =  5.0,
00047                    float min_x = -5.0,
00048                    float min_y = -5.0 );
00049   GeomDrawingArea(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& ref_xml);
00050   virtual ~GeomDrawingArea();
00051
00052   void clear();
00053
00054   GeomDrawingArea& operator<<(fawkes::HomPoint& p);
00055   GeomDrawingArea& operator<<(const fawkes::HomPoint& p);
00056   GeomDrawingArea& operator<<(std::pair<HomVector, HomPoint> v);
00057   GeomDrawingArea& operator<<(fawkes::LineSegment& l);
00058   GeomDrawingArea& operator<<(fawkes::Bezier& b);
00059   GeomDrawingArea& operator<<(fawkes::Spline& s);
00060   GeomDrawingArea& operator<<(const fawkes::Spline& s);
00061   GeomDrawingArea& operator<<(fawkes::DrawingManipulator* m);
00062
00063   virtual void to_drawing_coords(int window_x, int window_y, float& drawing_x, float& drawing_y);
00064
00065  protected:
00066   virtual void pre_draw(Cairo::RefPtr<Cairo::Context>& context);
00067   virtual void post_draw(Cairo::RefPtr<Cairo::Context>& context);
00068
00069  private:
00070   virtual bool on_expose_event(GdkEventExpose* event);
00071
00072   std::vector<fawkes::GeomDrawer*> m_drawers;
00073   fawkes::DrawingManipulator*      m_cur_drawing_manipulator;
00074
00075   float m_max_x;
00076   float m_max_y;
00077   float m_min_x;
00078   float m_min_y;
00079
00080   float m_unit;
00081
00082   int m_window_width;
00083   int m_window_height;
00084 };
00085
00086 } // end namespace fawkes
00087
00088 #endif /* __GEOMETRY_GEOM_DRAWING_AREA_H_ */