25 #include <geometry/gtk/geom_drawing_area.h> 26 #include <geometry/hom_point.h> 27 #include <geometry/gtk/hom_point_drawer.h> 28 #include <geometry/hom_vector.h> 29 #include <geometry/gtk/hom_vector_drawer.h> 30 #include <geometry/line_segment.h> 31 #include <geometry/gtk/line_segment_drawer.h> 32 #include <geometry/bezier.h> 33 #include <geometry/gtk/spline_drawer.h> 34 #include <geometry/spline.h> 35 #include <geometry/gtk/bezier_drawer.h> 36 #include <geometry/gtk/drawing_manipulator.h> 75 GeomDrawingArea::GeomDrawingArea(
float max_x,
84 m_cur_drawing_manipulator = NULL;
93 const Glib::RefPtr<Gnome::Glade::Xml>& ref_xml )
94 : Gtk::DrawingArea(cobject)
101 m_cur_drawing_manipulator = NULL;
115 for ( vector<GeomDrawer*>::iterator iter = m_drawers.begin();
116 iter != m_drawers.end();
124 m_cur_drawing_manipulator = NULL;
136 if (m_cur_drawing_manipulator)
139 m_drawers.push_back(d);
153 if (m_cur_drawing_manipulator)
156 m_drawers.push_back(d);
166 GeomDrawingArea::operator<<(std::pair<HomVector, HomPoint> vp)
171 m_drawers.push_back(d);
184 m_drawers.push_back(d);
197 m_drawers.push_back(d);
210 m_drawers.push_back(d);
223 m_drawers.push_back(d);
236 if (m_cur_drawing_manipulator)
237 { m->
integrate(m_cur_drawing_manipulator); }
239 m_cur_drawing_manipulator = m;
240 m_drawers.push_back(m);
250 GeomDrawingArea::on_expose_event(GdkEventExpose* event)
252 Glib::RefPtr<Gdk::Window> window = get_window();
255 Gtk::Allocation allocation = get_allocation();
256 m_window_width = allocation.get_width();
257 m_window_height = allocation.get_height();
259 Cairo::RefPtr<Cairo::Context> context = window->create_cairo_context();
263 context->rectangle( event->area.x, event->area.y,
264 event->area.width, event->area.height );
268 float unit_width = fabs(m_max_x) + fabs(m_min_x);
269 float unit_height = fabs(m_max_y) + fabs(m_min_y);
270 if ( (m_window_width / unit_width) <= (m_window_height / unit_height) )
271 { m_unit = m_window_width / unit_width; }
273 { m_unit = m_window_height / unit_height; }
277 for ( vector<GeomDrawer*>::iterator iter = m_drawers.begin();
278 iter != m_drawers.end();
301 float& drawing_x,
float& drawing_y )
303 float unit_width = fabs(m_max_x) + fabs(m_min_x);
305 float pixel_per_unit = m_window_width / unit_width;
307 drawing_x = window_x / pixel_per_unit + m_min_x;
308 drawing_y = -(window_y / pixel_per_unit + m_min_y);
320 context->translate( m_window_width / 2.0, m_window_height / 2.0 );
321 context->scale(m_unit, -m_unit);
float get_point_size() const
Get the point size.
A spline made up of cubic Bezier curves.
Drawer for HomPoint objects.
Fawkes library namespace.
Drawer for Spline objects.
Abstract base class for all drawer classes.
A Gtk::DrawingArea that allows to easily display drawable objects of the geometry library...
GeomDrawingArea(float max_x=5.0, float max_y=5.0, float min_x=-5.0, float min_y=-5.0)
Constructor.
void clear()
Clear the drawing area.
virtual void post_draw(Cairo::RefPtr< Cairo::Context > &context)
This method is called by the expose signal handler after the draw routines of the registered drawers ...
void integrate(const DrawingManipulator *m)
Integrates the parameters of another manipulator.
Drawer for HomVector objects.
Drawer for Bezier objects.
virtual void to_drawing_coords(int window_x, int window_y, float &drawing_x, float &drawing_y)
Convert the given window coordinates into the frame of the drawing area.
void set_point_size(float s)
Set the point size with which points a drawn by this drawer.
GeomDrawingArea & operator<<(fawkes::HomPoint &p)
<<-operator for HomPoint objects
Allows to control some aspects of the rendering of objects.
Drawer for LineSegment objects.
virtual ~GeomDrawingArea()
Destructor.
virtual void draw(Cairo::RefPtr< Cairo::Context > &context)=0
This method is called by the GeomDrawingArea.
virtual void pre_draw(Cairo::RefPtr< Cairo::Context > &context)
This method is called by the expose signal handler before the draw routines of the registered drawers...