Desktop/sourceforge/geometria/src/kernel/geo_point.cpp

Go to the documentation of this file.
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 "geo_point.hpp"
00022 #include "free_point_algorithm.hpp"
00023 
00024 geo_point::geo_point(const std::string& name, boost::shared_ptr<point_algorithm> algo,
00025                                          boost::shared_ptr<point_formater_strategy> paint_strategy)
00026 :       m_parent_algorithm(algo), 
00027         m_paint_strategy(paint_strategy),
00028         geo_element(name)
00029 {
00030         m_parent_algorithm->register_observer(this);
00031         m_parent_algorithm->update();
00032 }
00033 
00034 geo_point::~geo_point(void)
00035 {
00036         m_parent_algorithm->unregister_observer(this);
00037 }
00038 
00039 std::ostream& geo_point::put(std::ostream& s)
00040 {
00041         return s << "Point: " << "(" << get_point().get_x() << "|" 
00042                 << get_point().get_y() << ")" << std::endl;
00043 }
00044 
00045 point geo_point::get_point() const
00046 {
00047         return m_parent_algorithm->get_point();
00048 }
00049 
00050 void geo_point::change_parent_algo(boost::shared_ptr<point_algorithm> new_algo)
00051 {
00052         m_parent_algorithm = new_algo;
00053         m_parent_algorithm->update();
00054         notice_all_observers();
00055 }
00056 
00057 void geo_point::update()
00058 {
00059         notice_all_observers();
00060 }
00061 
00062 void geo_point::draw(boost::shared_ptr<drawing_context> context)
00063 {
00064         m_paint_strategy->draw(get_point(), context);
00065 }
00066 
00067 bool geo_point::is_free_point()
00068 {
00069         return m_parent_algorithm->is_free();
00070 }

Generated on Fri May 19 19:30:28 2006 for geometria by  doxygen 1.4.6-NO