00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __TEXT_PATH_H__
00027 #define __TEXT_PATH_H__
00028
00029 #include <boost/utility.hpp>
00030
00031 namespace mapnik
00032 {
00033 struct character_info
00034 {
00035 int character;
00036 double width, height;
00037
00038 character_info() : character(0), width(0), height(0) {}
00039 character_info(int c_, double width_, double height_) : character(c_), width(width_), height(height_) {}
00040 ~character_info() {}
00041
00042 character_info(const character_info &ci)
00043 : character(ci.character), width(ci.width), height(ci.height)
00044 {
00045 }
00046
00047 };
00048
00049 class string_info : private boost::noncopyable
00050 {
00051 protected:
00052
00053
00054 typedef boost::ptr_vector<character_info> characters_t;
00055
00056 characters_t characters_;
00057 unsigned itr_;
00058
00059 double width_;
00060 double height_;
00061 public:
00062 string_info() : itr_(0), width_(0), height_(0) {}
00063
00064 void add_info(int c, double width, double height)
00065 {
00066 characters_.push_back(new character_info(c, width, height));
00067 }
00068
00069 unsigned num_characters()
00070 {
00071 return characters_.size();
00072 }
00073
00074 character_info at(unsigned i)
00075 {
00076 return characters_[i];
00077 }
00078
00079 character_info operator[](unsigned i)
00080 {
00081 return at(i);
00082 }
00083
00084 void set_dimensions(double width, double height)
00085 {
00086 width_ = width;
00087 height_ = height;
00088 }
00089
00090 std::pair<double, double> get_dimensions()
00091 {
00092 return std::pair<double, double>(width_, height_);
00093 }
00094 };
00095
00096 struct text_path
00097 {
00098 struct character_node
00099 {
00100 int c;
00101 double x, y, angle;
00102
00103 character_node(int c_, double x_, double y_, double angle_) : c(c_), x(x_), y(y_), angle(angle_) {}
00104 ~character_node() {}
00105
00106 void vertex(int *c_, double *x_, double *y_, double *angle_)
00107 {
00108 *c_ = c;
00109 *x_ = x;
00110 *y_ = y;
00111 *angle_ = angle;
00112 }
00113 };
00114
00115 typedef std::vector<character_node> character_nodes_t;
00116
00117 character_nodes_t nodes_;
00118 int itr_;
00119
00120 std::pair<unsigned,unsigned> string_dimensions;
00121
00122 text_path() : itr_(0) {}
00123 text_path(const text_path & other) : itr_(0)
00124 {
00125 nodes_ = other.nodes_;
00126 string_dimensions = other.string_dimensions;
00127 }
00128
00129 ~text_path() {}
00130
00131 void add_node(int c, double x, double y, double angle)
00132 {
00133 nodes_.push_back(character_node(c, x, y, angle));
00134 }
00135
00136 void vertex(int *c, double *x, double *y, double *angle)
00137 {
00138 nodes_[itr_++].vertex(c, x, y, angle);
00139 }
00140
00141 int num_nodes()
00142 {
00143 return nodes_.size();
00144 }
00145
00146 void clear()
00147 {
00148 nodes_.clear();
00149 }
00150 };
00151 }
00152
00153 #endif
00154
00155