00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #ifndef HEADER_ZOOM_GRAPHIC_CONTEXT_HXX
00021 #define HEADER_ZOOM_GRAPHIC_CONTEXT_HXX
00022 
00023 #include "vector2d.hxx"
00024 #include "graphic_context.hxx"
00025 
00028 class ZoomGraphicContext : public GraphicContext
00029 {
00030 private:
00031   int x1;
00032   int y1;
00033   int x2;
00034   int y2;
00035 
00036   GraphicContext* parent_gc;
00037 
00038   float x_offset;
00039   float y_offset;
00040   float zoom;
00041 
00042   int translate_x (int);
00043   int translate_y (int);
00044 public:
00045   ZoomGraphicContext ();
00046   ZoomGraphicContext (int x1_, int y1_, int x2_, int y2_);
00047 
00048   void set_clip_rect (int x1_, int y1_, int x2_, int y2_);
00049 
00051   void lock ();
00052 
00054   void unlock ();
00055   
00056   void draw_lines (std::vector<Line>& lines, Color color, int wide = 0);
00057   void draw_line(float x1, float y1, float x2, float y2, Color color, int wide = 0);
00058   void draw_rect(float x1, float y1, float x2, float y2, Color color);
00059   void draw_circle(float x, float y, float r, Color color);
00060   void draw_circles(std::vector<Circle>& circles, Color color);
00061   void draw_fill_circle(float x, float y, float r, Color color);
00062   void draw_fill_rect(float x1, float y1, float x2, float y2, Color color);
00063   void draw_string(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF));
00064   void draw_string_centered(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF));
00065 
00066   int get_width ();
00067   int get_height ();
00068 
00069   void clear ()  { parent_gc->clear (); }
00070 
00072   void flip () { parent_gc->flip (); }
00073 
00074   void set_parent_gc (GraphicContext* gc);
00075 
00076   bool zoom_in (int x, int y);
00077   bool zoom_out (int x, int y);
00078   void zoom_to (int x1, int y1, int x2, int y2);
00079 
00082   GraphicContext* get_parent_gc () { return parent_gc; }
00083 
00085   void translate_offset (int x, int y);
00086 
00087   void set_offset (float x, float y);
00088 
00090   void move_to (float x, float y);
00091 
00092   float get_x_offset () { return x_offset; }
00093   float get_y_offset () { return y_offset; }
00094 
00095   float get_zoom () const { return zoom; }
00096 
00100   bool  set_zoom (const float& z);
00101 
00102   float screen_to_world_x (float);
00103   float screen_to_world_y (float);
00104 
00105   float world_to_screen_x (float);
00106   float world_to_screen_y (float);
00107 
00108   Vector2d screen_to_world (const Vector2d&);
00109   Vector2d world_to_screen (const Vector2d&);
00110 
00111   void flip (int x1, int y1, int x2, int y2);
00112 };
00113 
00114 #endif
00115 
00116