/* Copyright (C) 2007 Michael Goffioul ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include "graphics-renderer.h" class lin_scaler : public base_scaler { public: Matrix scale (const Matrix& m) { return m; } }; class log_scaler : public base_scaler { public: Matrix scale (const Matrix& m) { Matrix retval (m.rows (), m.cols ()); const double *d1 = m.fortran_vec (); double *d2 = retval.fortran_vec (); for (int i = 0; i < m.numel (); i++) d2[i] = log10 (d1[i]); return retval; } }; scaler& scaler::operator= (const radio_property& p) { if (rep) { delete (rep); rep = 0; } if (p.current_value () == "log") rep = new log_scaler (); else rep = new lin_scaler (); return *this; } void graphics_renderer::draw (const graphics_object& obj) { if (obj.isa ("figure")) draw (reinterpret_cast (obj.get_properties ())); else if (obj.isa ("axes")) draw (reinterpret_cast (obj.get_properties ())); } void graphics_renderer::set_viewport (int w, int h) { width = w; height = h; } Matrix graphics_renderer::get_boundingbox (const axes::properties& props) const { Matrix bb (1, 4, 0.0); // TODO: use position, units and canvas size to compute actual bounding box bb(2) = get_width (); bb(3) = get_height (); return bb; }