/home/martin/workspace/OpenStreetNav/src/displayer/MapDrawingArea.h
Go to the documentation of this file.
00001 /*
00002  * MapDrawingArea.h
00003  *
00004  *  Created on: Nov 14, 2011
00005  *      Author: martin
00006  */
00007 
00008 #ifndef MAPDRAWINGAREA_H_
00009 #define MAPDRAWINGAREA_H_
00010 
00011 #include <gtkmm/drawingarea.h>
00012 #include <gtkmm/builder.h>
00013 #include <boost/signal.hpp>
00014 #include <memory>
00015 #include "../projection/projection.h"
00016 #include "DisplayProvider.h"
00017 
00018 namespace display
00019 {
00020 
00025 class MapDrawingArea : public Gtk::DrawingArea
00026 {
00027 public:
00033     MapDrawingArea(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> const&);
00040     void add_dp(int priority, std::shared_ptr<DisplayProvider> dp);
00045     void set_latitude(double lat);
00050     void set_longitude(double lon);
00056     int set_zoom(int zoom);
00061     int get_zoom();
00065     boost::signal<void (int)> zoom_changed;
00070     boost::signal<void (std::vector<std::unique_ptr<osm::Element> > const& elem)> element_clicked;
00071     virtual ~MapDrawingArea();
00072 protected:
00073     bool on_draw(Cairo::RefPtr<Cairo::Context> const& cr);
00074     bool on_button_press_event(GdkEventButton* event);
00075     bool on_button_release_event(GdkEventButton* event);
00076     bool on_motion_notify_event(GdkEventMotion* event);
00077     bool on_leave_notify_event(GdkEventCrossing* event);
00078     bool on_enter_notify_event(GdkEventCrossing* event);
00079     bool on_scroll_event(GdkEventScroll* event);
00080     void on_size_allocate(Gtk::Allocation& alloc);
00081 private:
00082     std::multimap<int, std::shared_ptr<DisplayProvider> > dps;
00083     bool pressed;
00084     double press_x;
00085     double press_y;
00086     int zoom;
00087     double tran_x, tran_y;
00088     std::unique_ptr<proj::MapProjection> proj;
00089     Cairo::RefPtr<Cairo::ImageSurface> surface;
00090     proj::FlatPoint topleft;
00091     proj::FlatPoint bottomright;
00092     double lat;
00093     double lon;
00094     Cairo::Matrix matrix;
00095     Cairo::Matrix inverse;
00096 
00097     void move_center(double x, double y);
00098     void setup_surfaces();
00099 
00100     void after_change();
00101     void setup_projection();
00102     void setup_bounds();
00103     void setup_db();
00104 
00105     void redraw_from_db();
00106     void invalidate();
00107 
00108     double get_radius_for_zoom();
00109 
00110     std::vector<std::unique_ptr<osm::Element> > get_selected(geo::Point const& p1, geo::Point const& p2, int zoom);
00111 };
00112 
00113 } /* namespace display */
00114 #endif /* MAPDRAWINGAREA_H_ */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines