Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

zoom_graphic_context.hxx Source File
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

zoom_graphic_context.hxx

Go to the documentation of this file.
00001 //  $Id: zoom_graphic_context.hxx,v 1.11 2003/01/09 22:10:24 grumbel Exp $
00002 // 
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 // 
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 /* EOF */

Generated on Thu Jul 24 10:24:32 2003 for Construo by doxygen1.3-rc3