Anti-Grain Geometry - AGG (libagg)
2.5
|
00001 //---------------------------------------------------------------------------- 00002 // Anti-Grain Geometry (AGG) - Version 2.5 00003 // A high quality rendering engine for C++ 00004 // Copyright (C) 2002-2006 Maxim Shemanarev 00005 // Contact: mcseem@antigrain.com 00006 // mcseemagg@yahoo.com 00007 // http://antigrain.com 00008 // 00009 // AGG is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // AGG is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with AGG; if not, write to the Free Software 00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00022 // MA 02110-1301, USA. 00023 //---------------------------------------------------------------------------- 00024 00025 #ifndef AGG_CONV_TRANSFORM_INCLUDED 00026 #define AGG_CONV_TRANSFORM_INCLUDED 00027 00028 #include "agg_basics.h" 00029 #include "agg_trans_affine.h" 00030 00031 namespace agg 00032 { 00033 00034 //----------------------------------------------------------conv_transform 00035 template<class VertexSource, class Transformer=trans_affine> class conv_transform 00036 { 00037 public: 00038 conv_transform(VertexSource& source, const Transformer& tr) : 00039 m_source(&source), m_trans(&tr) {} 00040 void attach(VertexSource& source) { m_source = &source; } 00041 00042 void rewind(unsigned path_id) 00043 { 00044 m_source->rewind(path_id); 00045 } 00046 00047 unsigned vertex(double* x, double* y) 00048 { 00049 unsigned cmd = m_source->vertex(x, y); 00050 if(is_vertex(cmd)) 00051 { 00052 m_trans->transform(x, y); 00053 } 00054 return cmd; 00055 } 00056 00057 void transformer(const Transformer& tr) 00058 { 00059 m_trans = &tr; 00060 } 00061 00062 private: 00063 conv_transform(const conv_transform<VertexSource>&); 00064 const conv_transform<VertexSource>& 00065 operator = (const conv_transform<VertexSource>&); 00066 00067 VertexSource* m_source; 00068 const Transformer* m_trans; 00069 }; 00070 00071 00072 } 00073 00074 #endif