Permalink
Browse files

Remove class text_processor.

  • Loading branch information...
1 parent e4340c0 commit 1a16e9c5ab70032f50f017ef2134bc57dae0b656 @herm committed Jan 31, 2012
@@ -49,57 +49,50 @@ class text_placements;
typedef std::pair<double,double> position;
typedef std::pair<double,double> dimension_type;
-enum label_placement_enum {
- POINT_PLACEMENT,
- LINE_PLACEMENT,
- VERTEX_PLACEMENT,
- INTERIOR_PLACEMENT,
- label_placement_enum_MAX
-};
-
-DEFINE_ENUM( label_placement_e, label_placement_enum );
-
-enum vertical_alignment
-{
- V_TOP = 0,
- V_MIDDLE,
- V_BOTTOM,
- V_AUTO,
- vertical_alignment_MAX
-};
-
-DEFINE_ENUM( vertical_alignment_e, vertical_alignment );
-
-enum horizontal_alignment
-{
- H_LEFT = 0,
- H_MIDDLE,
- H_RIGHT,
- H_AUTO,
- horizontal_alignment_MAX
-};
-
-DEFINE_ENUM( horizontal_alignment_e, horizontal_alignment );
-
-enum justify_alignment
+struct char_properties
{
- J_LEFT = 0,
- J_MIDDLE,
- J_RIGHT,
- justify_alignment_MAX
+ char_properties();
+ /** Construct object from XML. */
+ void from_xml(boost::property_tree::ptree const &sym, std::map<std::string,font_set> const & fontsets);
+ /** Write object to XML ptree. */
+ void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, char_properties const &dfl=char_properties()) const;
+ std::string face_name;
+ font_set fontset;
+ float text_size;
+ double character_spacing;
+ double line_spacing; //Largest total height (fontsize+line_spacing) per line is chosen
+ double text_opacity;
+ bool wrap_before;
+ unsigned wrap_char;
+ text_transform_e text_transform; //Per expression
+ color fill;
+ color halo_fill;
+ double halo_radius;
};
-DEFINE_ENUM( justify_alignment_e, justify_alignment );
-
/** Contains all text symbolizer properties which are not directly related to text formating. */
struct text_symbolizer_properties
{
text_symbolizer_properties();
- /** Load all values and also the ```processor``` object from XML ptree. */
+ /** Load all values from XML ptree. */
void from_xml(boost::property_tree::ptree const &sym, std::map<std::string,font_set> const & fontsets);
/** Save all values to XML ptree (but does not create a new parent node!). */
void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, text_symbolizer_properties const &dfl=text_symbolizer_properties()) const;
+ /** Takes a feature and produces formated text as output.
+ * The output object has to be created by the caller and passed in for thread safety.
+ */
+ void process(processed_text &output, Feature const& feature) const;
+ /** Automatically create processing instructions for a single expression. */
+ void set_old_style_expression(expression_ptr expr);
+ /** Sets new format tree. */
+ void set_format_tree(formating::node_ptr tree);
+ /** Get format tree. */
+ formating::node_ptr format_tree() const;
+ /** Get a list of all expressions used in any placement.
+ * This function is used to collect attributes. */
+ std::set<expression_ptr> get_all_expressions() const;
+
//Per symbolizer options
expression_ptr orientation;
position displacement;
@@ -121,10 +114,39 @@ struct text_symbolizer_properties
bool allow_overlap;
unsigned text_ratio;
unsigned wrap_width;
- /** Contains everything related to text formating */
- text_processor processor;
+ /** Default values for char_properties. */
+ char_properties default_format;
+private:
+ formating::node_ptr tree_;
};
+class processed_text : boost::noncopyable
+{
+public:
+ class processed_expression
+ {
+ public:
+ processed_expression(char_properties const& properties, UnicodeString const& text) :
+ p(properties), str(text) {}
+ char_properties p;
+ UnicodeString str;
+ };
+public:
+ processed_text(face_manager<freetype_engine> & font_manager, double scale_factor);
+ void push_back(processed_expression const& exp);
+ unsigned size() const { return expr_list_.size(); }
+ unsigned empty() const { return expr_list_.empty(); }
+ void clear();
+ typedef std::list<processed_expression> expression_list;
+ expression_list::const_iterator begin() const;
+ expression_list::const_iterator end() const;
+ string_info &get_string_info();
+private:
+ expression_list expr_list_;
+ face_manager<freetype_engine> & font_manager_;
+ double scale_factor_;
+ string_info info_;
+};
/** Generate a possible placement and store results of placement_finder.
* This placement has first to be tested by placement_finder to verify it
@@ -23,6 +23,8 @@
#define MAPNIK_TEXT_PROCESSING_HPP
#include <boost/property_tree/ptree.hpp>
+#include <boost/optional.hpp>
+
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/ctrans.hpp>
@@ -37,68 +39,60 @@
#include <set>
namespace mapnik
{
+class processed_text;
+struct char_properties;
+
+enum label_placement_enum {
+ POINT_PLACEMENT,
+ LINE_PLACEMENT,
+ VERTEX_PLACEMENT,
+ INTERIOR_PLACEMENT,
+ label_placement_enum_MAX
+};
-enum text_transform
+DEFINE_ENUM( label_placement_e, label_placement_enum );
+
+enum vertical_alignment
{
- NONE = 0,
- UPPERCASE,
- LOWERCASE,
- CAPITALIZE,
- text_transform_MAX
+ V_TOP = 0,
+ V_MIDDLE,
+ V_BOTTOM,
+ V_AUTO,
+ vertical_alignment_MAX
};
-DEFINE_ENUM( text_transform_e, text_transform );
+DEFINE_ENUM( vertical_alignment_e, vertical_alignment );
-struct char_properties
+enum horizontal_alignment
{
- char_properties();
- /** Construct object from XML. */
- void from_xml(boost::property_tree::ptree const &sym, std::map<std::string,font_set> const & fontsets);
- /** Write object to XML ptree. */
- void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, char_properties const &dfl=char_properties()) const;
- std::string face_name;
- font_set fontset;
- float text_size;
- double character_spacing;
- double line_spacing; //Largest total height (fontsize+line_spacing) per line is chosen
- double text_opacity;
- bool wrap_before;
- unsigned wrap_char;
- text_transform_e text_transform; //Per expression
- color fill;
- color halo_fill;
- double halo_radius;
+ H_LEFT = 0,
+ H_MIDDLE,
+ H_RIGHT,
+ H_AUTO,
+ horizontal_alignment_MAX
};
-class processed_expression
+DEFINE_ENUM( horizontal_alignment_e, horizontal_alignment );
+
+enum justify_alignment
{
-public:
- processed_expression(char_properties const& properties, UnicodeString const& text) :
- p(properties), str(text) {}
- char_properties p;
- UnicodeString str;
+ J_LEFT = 0,
+ J_MIDDLE,
+ J_RIGHT,
+ justify_alignment_MAX
};
+DEFINE_ENUM( justify_alignment_e, justify_alignment );
-class processed_text : boost::noncopyable
+enum text_transform
{
-public:
- processed_text(face_manager<freetype_engine> & font_manager, double scale_factor);
- void push_back(processed_expression const& exp);
- unsigned size() const { return expr_list_.size(); }
- unsigned empty() const { return expr_list_.empty(); }
- void clear();
- typedef std::list<processed_expression> expression_list;
- expression_list::const_iterator begin() const;
- expression_list::const_iterator end() const;
- string_info &get_string_info();
-private:
- expression_list expr_list_;
- face_manager<freetype_engine> & font_manager_;
- double scale_factor_;
- string_info info_;
+ NONE = 0,
+ UPPERCASE,
+ LOWERCASE,
+ CAPITALIZE,
+ text_transform_MAX
};
-
+DEFINE_ENUM( text_transform_e, text_transform );
namespace formating {
class node;
@@ -180,34 +174,6 @@ class format_node: public node {
} //namespace formating
-/** Stores formating information and uses this to produce formated text for a given feature. */
-class text_processor
-{
-public:
- text_processor();
- /** Construct object from XML. */
- void from_xml(boost::property_tree::ptree const& pt, std::map<std::string,font_set> const &fontsets);
- /** Write object to XML ptree. */
- void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, text_processor const& dfl) const;
-
- /** Takes a feature and produces formated text as output.
- * The output object has to be created by the caller and passed in for thread safety.
- */
- void process(processed_text &output, Feature const& feature) const;
- /** Automatically create processing instructions for a single expression. */
- void set_old_style_expression(expression_ptr expr);
- /** Sets new format tree. */
- void set_format_tree(formating::node_ptr tree);
- /** Get format tree. */
- formating::node_ptr get_format_tree() const;
- /** Get a list of all expressions used in any placement. This function is used to collect attributes. */
- std::set<expression_ptr> get_all_expressions() const;
- /** Default values for char_properties. */
- char_properties defaults;
-private:
- formating::node_ptr tree_;
-};
-
} /* namespace mapnik*/
#endif
View
@@ -1282,7 +1282,7 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
}
placement_finder->properties.from_xml(sym, fontsets_);
- if (strict_) ensure_font_face(placement_finder->properties.processor.defaults.face_name);
+ if (strict_) ensure_font_face(placement_finder->properties.default_format.face_name);
if (list) {
ptree::const_iterator symIter = sym.begin();
ptree::const_iterator endSym = sym.end();
@@ -1296,7 +1296,7 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
ensure_attrs(symIter->second, "TextSymbolizer/Placement", s_common.str());
text_symbolizer_properties & p = list->add();
p.from_xml(symIter->second, fontsets_);
- if (strict_) ensure_font_face(p.processor.defaults.face_name);
+ if (strict_) ensure_font_face(p.default_format.face_name);
}
}
@@ -1351,7 +1351,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
}
placement_finder->properties.from_xml(sym, fontsets_);
- if (strict_) ensure_font_face(placement_finder->properties.processor.defaults.face_name);
+ if (strict_) ensure_font_face(placement_finder->properties.default_format.face_name);
if (list) {
ptree::const_iterator symIter = sym.begin();
ptree::const_iterator endSym = sym.end();
@@ -1365,7 +1365,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
ensure_attrs(symIter->second, "TextSymbolizer/Placement", s_common);
text_symbolizer_properties & p = list->add();
p.from_xml(symIter->second, fontsets_);
- if (strict_) ensure_font_face(p.processor.defaults.face_name);
+ if (strict_) ensure_font_face(p.default_format.face_name);
}
}
@@ -166,7 +166,7 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_placement()
placement_valid_ = false;
return false;
}
- placement_->properties.processor.process(text_, feature_);
+ placement_->properties.process(text_, feature_);
info_ = &(text_.get_string_info());
if (placement_->properties.orientation)
{
Oops, something went wrong.

0 comments on commit 1a16e9c

Please sign in to comment.