00001 /* 00002 This file is part of geometria. 00003 00004 geometria is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published 00006 by the Free Software Foundation; either version 2 of the License, 00007 or (at your option) any later version. 00008 00009 geometria is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00011 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU General Public 00015 License along with geometria; if not, write to the Free Software 00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00017 00018 (c) Philipp Moritz, 2006 00019 */ 00020 00021 #include "kernel_fassade.hpp" 00022 00023 kernel_fassade::kernel_fassade(void) 00024 { 00025 } 00026 00027 kernel_fassade::~kernel_fassade(void) 00028 { 00029 } 00030 00031 void kernel_fassade::add_point(boost::shared_ptr<geo_point> point) 00032 { 00033 m_points.push_back(point); 00034 } 00035 00036 void kernel_fassade::add_line(boost::shared_ptr<geo_line> line) 00037 { 00038 m_lines.push_back(line); 00039 } 00040 00041 void kernel_fassade::draw_all(boost::shared_ptr<drawing_context> context) 00042 { 00043 typedef std::list<geo_point_ref>::iterator LI_P; 00044 for(LI_P iter = m_points.begin();iter != m_points.end();++iter) 00045 { 00046 (**iter).draw(context); 00047 } 00048 00049 typedef std::list<geo_line_ref>::iterator LI_L; 00050 for(LI_L iter = m_lines.begin();iter != m_lines.end();++iter) 00051 { 00052 (**iter).draw(context); 00053 } 00054 } 00055 00056 kernel_fassade& kernel_fassade::get_instance() 00057 { 00058 static kernel_fassade fas; 00059 return fas; 00060 } 00061 00062 geo_point_ref kernel_fassade::get_point_at(double x, double y) 00063 { 00064 const double scale = 10; 00065 const double tollerance = 1.5; 00066 x /= scale; y /= scale; 00067 00068 typedef std::list<geo_point_ref>::iterator LI_P; 00069 for(LI_P iter = m_points.begin();iter != m_points.end();++iter) 00070 { 00071 point p = (**iter).get_point(); 00072 if((p.get_x() + tollerance > x && p.get_x() - tollerance < x) && 00073 (p.get_y() + tollerance > y && p.get_y() - tollerance < y)) 00074 { 00075 return *iter; 00076 } 00077 } 00078 return geo_point_ref(); 00079 }