Anti-Grain Geometry - AGG (libagg)  2.5
agg-2.5/include/agg_conv_concat.h
Go to the documentation of this file.
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_CONCAT_INCLUDED
00026 #define AGG_CONV_CONCAT_INCLUDED
00027 
00028 #include "agg_basics.h"
00029 
00030 namespace agg
00031 {
00032     //=============================================================conv_concat
00033     // Concatenation of two paths. Usually used to combine lines or curves 
00034     // with markers such as arrowheads
00035     template<class VS1, class VS2> class conv_concat
00036     {
00037     public:
00038         conv_concat(VS1& source1, VS2& source2) :
00039             m_source1(&source1), m_source2(&source2), m_status(2) {}
00040         void attach1(VS1& source) { m_source1 = &source; }
00041         void attach2(VS2& source) { m_source2 = &source; }
00042 
00043 
00044         void rewind(unsigned path_id)
00045         { 
00046             m_source1->rewind(path_id);
00047             m_source2->rewind(0);
00048             m_status = 0;
00049         }
00050 
00051         unsigned vertex(double* x, double* y)
00052         {
00053             unsigned cmd;
00054             if(m_status == 0)
00055             {
00056                 cmd = m_source1->vertex(x, y);
00057                 if(!is_stop(cmd)) return cmd;
00058                 m_status = 1;
00059             }
00060             if(m_status == 1)
00061             {
00062                 cmd = m_source2->vertex(x, y);
00063                 if(!is_stop(cmd)) return cmd;
00064                 m_status = 2;
00065             }
00066             return path_cmd_stop;
00067         }
00068 
00069     private:
00070         conv_concat(const conv_concat<VS1, VS2>&);
00071         const conv_concat<VS1, VS2>& 
00072             operator = (const conv_concat<VS1, VS2>&);
00073 
00074         VS1* m_source1;
00075         VS2* m_source2;
00076         int  m_status;
00077 
00078     };
00079 }
00080 
00081 
00082 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines