| 1 |
//---------------------------------------------------------------------------- |
| 2 |
// Anti-Grain Geometry - Version 2.4 |
| 3 |
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) |
| 4 |
// |
| 5 |
// Permission to copy, use, modify, sell and distribute this software |
| 6 |
// is granted provided this copyright notice appears in all copies. |
| 7 |
// This software is provided "as is" without express or implied |
| 8 |
// warranty, and with no claim as to its suitability for any purpose. |
| 9 |
// |
| 10 |
//---------------------------------------------------------------------------- |
| 11 |
// Contact: [email protected] |
| 12 |
// [email protected] |
| 13 |
// http://www.antigrain.com |
| 14 |
//---------------------------------------------------------------------------- |
| 15 |
// |
| 16 |
// class conv_transform |
| 17 |
// |
| 18 |
//---------------------------------------------------------------------------- |
| 19 |
#ifndef AGG_CONV_TRANSFORM_INCLUDED |
| 20 |
#define AGG_CONV_TRANSFORM_INCLUDED |
| 21 |
|
| 22 |
#include "agg_basics.h" |
| 23 |
#include "agg_trans_affine.h" |
| 24 |
|
| 25 |
namespace agg |
| 26 |
{ |
| 27 |
|
| 28 |
//----------------------------------------------------------conv_transform |
| 29 |
template<class VertexSource, class Transformer=trans_affine> class conv_transform |
| 30 |
{ |
| 31 |
public: |
| 32 |
conv_transform(VertexSource& source, Transformer& tr) : |
| 33 |
m_source(&source), m_trans(&tr) {} |
| 34 |
void attach(VertexSource& source) { m_source = &source; } |
| 35 |
|
| 36 |
void rewind(unsigned path_id) |
| 37 |
{ |
| 38 |
m_source->rewind(path_id); |
| 39 |
} |
| 40 |
|
| 41 |
unsigned vertex(double* x, double* y) |
| 42 |
{ |
| 43 |
unsigned cmd = m_source->vertex(x, y); |
| 44 |
if(is_vertex(cmd)) |
| 45 |
{ |
| 46 |
m_trans->transform(x, y); |
| 47 |
} |
| 48 |
return cmd; |
| 49 |
} |
| 50 |
|
| 51 |
void transformer(Transformer& tr) |
| 52 |
{ |
| 53 |
m_trans = &tr; |
| 54 |
} |
| 55 |
|
| 56 |
private: |
| 57 |
conv_transform(const conv_transform<VertexSource>&); |
| 58 |
const conv_transform<VertexSource>& |
| 59 |
operator = (const conv_transform<VertexSource>&); |
| 60 |
|
| 61 |
VertexSource* m_source; |
| 62 |
Transformer* m_trans; |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
#endif |