Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

worldview_zoom_tool.cxx

Go to the documentation of this file.
00001 //  $Id: worldview_zoom_tool.cxx,v 1.5 2003/01/05 15:29:15 grumbel Exp $
00002 //
00003 //  Construo - A wire-frame construction gamee
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 #include "colors.hxx"
00021 #include "construo.hxx"
00022 #include "input_context.hxx"
00023 #include "math.hxx"
00024 #include "worldview_component.hxx"
00025 #include "worldview_zoom_tool.hxx"
00026 
00027 WorldViewZoomTool::WorldViewZoomTool ()
00028 {
00029   creating_zoom_rectangle = false;
00030 }
00031 
00032 WorldViewZoomTool::~WorldViewZoomTool ()
00033 {
00034 }
00035 
00036 void
00037 WorldViewZoomTool::activate ()
00038 {
00039   creating_zoom_rectangle = false;
00040 }
00041 
00042 void
00043 WorldViewZoomTool::draw_foreground (ZoomGraphicContext* gc)
00044 {
00045   if (creating_zoom_rectangle)
00046     {
00047       float x = WorldViewComponent::instance()->get_gc()->screen_to_world_x (input_context->get_mouse_x ());
00048       float y = WorldViewComponent::instance()->get_gc()->screen_to_world_y (input_context->get_mouse_y ());               
00049       
00050       gc->draw_rect (Math::min(x, click_pos.x),
00051                      Math::min(y, click_pos.y),
00052                      Math::max(x, click_pos.x),
00053                      Math::max(y, click_pos.y),
00054                      Colors::new_spring);
00055     }
00056 }
00057 
00058 void
00059 WorldViewZoomTool::on_primary_button_press (int screen_x, int screen_y)
00060 {
00061   creating_zoom_rectangle = true;
00062   click_pos.x = WorldViewComponent::instance()->get_gc()->screen_to_world_x (screen_x);
00063   click_pos.y = WorldViewComponent::instance()->get_gc()->screen_to_world_y (screen_y);
00064 }  
00065 
00066 void
00067 WorldViewZoomTool::on_primary_button_release (int screen_x, int screen_y)
00068 {
00069   creating_zoom_rectangle = false;
00070 
00071   float x = WorldViewComponent::instance()->get_gc()->screen_to_world_x (screen_x);
00072   float y = WorldViewComponent::instance()->get_gc()->screen_to_world_y (screen_y);
00073   
00074   WorldViewComponent::instance()->get_gc()->zoom_to((int)Math::min(x, click_pos.x),
00075                                                     (int)Math::min(y, click_pos.y),
00076                                                     (int)Math::max(x, click_pos.x),
00077                                                     (int)Math::max(y, click_pos.y));
00078 }
00079 
00080 /* EOF */

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

Rabisu Mirror Service We provide mirrors to support Open source communities. Our mirror server is located in Istanbul/Turkey region.

Please do not hesitate to contact mirror@rabisu.com for new open source mirror submissions.