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_line.hpp" 00022 00023 00024 geo_line::geo_line(const std::string& name, boost::shared_ptr<line_algorithm> algo, 00025 boost::shared_ptr<line_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_line::~geo_line(void) 00035 { 00036 m_parent_algorithm->unregister_observer(this); 00037 } 00038 00039 std::ostream& geo_line::put(std::ostream& s) 00040 { 00041 return s << "Line: " << "T = " << get_line().get_t() 00042 << "; M = " << get_line().get_m() << std::endl; 00043 } 00044 00045 line geo_line::get_line() const 00046 { 00047 return m_parent_algorithm->get_line(); 00048 } 00049 00050 void geo_line::change_parent_algo(boost::shared_ptr<line_algorithm> new_algo) 00051 { 00052 m_parent_algorithm = new_algo; 00053 m_parent_algorithm->update(); 00054 notice_all_observers(); 00055 } 00056 00057 void geo_line::update() 00058 { 00059 notice_all_observers(); 00060 } 00061 00062 void geo_line::draw(boost::shared_ptr<drawing_context> context) 00063 { 00064 m_paint_strategy->draw(get_line(), context); 00065 }