Send processed text directly to text_layout.
This commit is contained in:
parent
1c9babf9e2
commit
62ccc7d313
16 changed files with 47 additions and 38 deletions
|
@ -29,7 +29,7 @@
|
|||
#include <mapnik/formatting/list.hpp>
|
||||
#include <mapnik/formatting/format.hpp>
|
||||
#include <mapnik/formatting/expression.hpp>
|
||||
#include <mapnik/processed_text.hpp>
|
||||
#include <mapnik/text/layout.hpp>
|
||||
#include <mapnik/expression_string.hpp>
|
||||
#include <mapnik/text_symbolizer.hpp>
|
||||
|
||||
|
@ -83,7 +83,7 @@ struct NodeWrap: formatting::node, wrapper<formatting::node>
|
|||
|
||||
}
|
||||
|
||||
void apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
python_block_auto_unblock b;
|
||||
this->get_override("apply")(ptr(&p), ptr(&feature), ptr(&output));
|
||||
|
@ -121,7 +121,7 @@ struct TextNodeWrap: formatting::text_node, wrapper<formatting::text_node>
|
|||
|
||||
}
|
||||
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
if(override o = this->get_override("apply"))
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ struct TextNodeWrap: formatting::text_node, wrapper<formatting::text_node>
|
|||
}
|
||||
}
|
||||
|
||||
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void default_apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
formatting::text_node::apply(p, feature, output);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ struct TextNodeWrap: formatting::text_node, wrapper<formatting::text_node>
|
|||
|
||||
struct FormatNodeWrap: formatting::format_node, wrapper<formatting::format_node>
|
||||
{
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
if(override o = this->get_override("apply"))
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ struct FormatNodeWrap: formatting::format_node, wrapper<formatting::format_node>
|
|||
}
|
||||
}
|
||||
|
||||
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void default_apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
formatting::format_node::apply(p, feature, output);
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ struct FormatNodeWrap: formatting::format_node, wrapper<formatting::format_node>
|
|||
|
||||
struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expression_format>
|
||||
{
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
if(override o = this->get_override("apply"))
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expres
|
|||
}
|
||||
}
|
||||
|
||||
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void default_apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
formatting::expression_format::apply(p, feature, output);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node>
|
|||
http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_function */
|
||||
|
||||
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
if(override o = this->get_override("apply"))
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node>
|
|||
}
|
||||
}
|
||||
|
||||
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void default_apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
formatting::list_node::apply(p, feature, output);
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ void export_text_placement()
|
|||
;
|
||||
register_ptr_to_python<boost::shared_ptr<text_placement_info> >();
|
||||
|
||||
|
||||
#if 0
|
||||
class_<processed_text,
|
||||
boost::shared_ptr<processed_text>,
|
||||
boost::noncopyable>
|
||||
|
@ -440,7 +440,7 @@ void export_text_placement()
|
|||
.def("push_back", &processed_text::push_back)
|
||||
.def("clear", &processed_text::clear)
|
||||
;
|
||||
|
||||
#endif
|
||||
|
||||
class_<expression_set,
|
||||
boost::shared_ptr<expression_set>,
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
namespace mapnik {
|
||||
|
||||
typedef std::set<expression_ptr> expression_set;
|
||||
class processed_text;
|
||||
class text_layout;
|
||||
class xml_node;
|
||||
struct char_properties;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
virtual ~node() {}
|
||||
virtual void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const = 0;
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const = 0;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
};
|
||||
} //ns formatting
|
||||
|
|
|
@ -32,7 +32,7 @@ class expression_format: public node {
|
|||
public:
|
||||
void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
void set_child(node_ptr child);
|
||||
|
|
|
@ -32,7 +32,7 @@ class format_node: public node {
|
|||
public:
|
||||
void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
void set_child(node_ptr child);
|
||||
|
|
|
@ -30,7 +30,7 @@ class list_node: public node {
|
|||
public:
|
||||
list_node() : node(), children_() {}
|
||||
virtual void to_xml(boost::property_tree::ptree &xml) const;
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
void push_back(node_ptr n);
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
text_node(std::string text): node(), text_(parse_expression(text)) {}
|
||||
void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void apply(char_properties const& p, Feature const& feature, text_layout &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
void set_text(expression_ptr text);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/processed_text.hpp>
|
||||
#include <mapnik/text/layout.hpp>
|
||||
#include <mapnik/text_path.hpp>
|
||||
|
||||
//boost
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
writer_(sym.get_metawriter()),
|
||||
dims_(0, 0, width, height),
|
||||
query_extent_(query_extent),
|
||||
text_(font_manager, scale_factor),
|
||||
layout_(),
|
||||
angle_(0.0),
|
||||
placement_valid_(false),
|
||||
points_on_line_(false),
|
||||
|
@ -104,7 +104,7 @@ protected:
|
|||
box2d<double> dims_;
|
||||
box2d<double> const& query_extent_;
|
||||
//Processing
|
||||
processed_text text_;
|
||||
text_layout layout_;
|
||||
/* Using list instead of vector, because we delete random elements and need iterators to stay valid. */
|
||||
/** Remaining geometries to be processed. */
|
||||
std::list<geometry_type*> geometries_to_process_;
|
||||
|
|
|
@ -20,7 +20,7 @@ struct glyph_info
|
|||
class text_layout
|
||||
{
|
||||
public:
|
||||
text_layout(double text_ratio, double wrap_width);
|
||||
text_layout();
|
||||
inline void add_text(UnicodeString const& str, char_properties const& format)
|
||||
{
|
||||
itemizer.add_text(str, format);
|
||||
|
@ -28,12 +28,10 @@ public:
|
|||
|
||||
void break_lines();
|
||||
void shape_text();
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
text_itemizer itemizer;
|
||||
double text_ratio_;
|
||||
double wrap_width_;
|
||||
std::vector<glyph_info> glyphs_;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ enum justify_alignment
|
|||
DEFINE_ENUM(justify_alignment_e, justify_alignment);
|
||||
|
||||
typedef std::pair<double, double> position;
|
||||
class processed_text;
|
||||
class text_layout;
|
||||
|
||||
|
||||
/** Contains all text symbolizer properties which are not directly related to text formatting. */
|
||||
|
@ -132,7 +132,7 @@ struct text_symbolizer_properties
|
|||
/** 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;
|
||||
void process(text_layout &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. */
|
||||
|
|
|
@ -80,7 +80,7 @@ expression_ptr expression_format::get_expression(xml_node const& xml, std::strin
|
|||
}
|
||||
|
||||
|
||||
void expression_format::apply(char_properties const& p, const Feature &feature, processed_text &output) const
|
||||
void expression_format::apply(char_properties const& p, const Feature &feature, text_layout &output) const
|
||||
{
|
||||
char_properties new_properties = p;
|
||||
if (face_name) new_properties.face_name =
|
||||
|
|
|
@ -74,7 +74,7 @@ node_ptr format_node::from_xml(xml_node const& xml)
|
|||
}
|
||||
|
||||
|
||||
void format_node::apply(char_properties const& p, const Feature &feature, processed_text &output) const
|
||||
void format_node::apply(char_properties const& p, const Feature &feature, text_layout &output) const
|
||||
{
|
||||
char_properties new_properties = p;
|
||||
if (face_name) new_properties.face_name = *face_name;
|
||||
|
|
|
@ -38,7 +38,7 @@ void list_node::to_xml(boost::property_tree::ptree &xml) const
|
|||
}
|
||||
|
||||
|
||||
void list_node::apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void list_node::apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
std::vector<node_ptr>::const_iterator itr = children_.begin();
|
||||
std::vector<node_ptr>::const_iterator end = children_.end();
|
||||
|
|
|
@ -25,8 +25,11 @@
|
|||
#include <mapnik/expression_evaluator.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/text_properties.hpp>
|
||||
#include <mapnik/processed_text.hpp>
|
||||
#include <mapnik/xml_node.hpp>
|
||||
#include <mapnik/text/layout.hpp>
|
||||
|
||||
//boost
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -50,7 +53,7 @@ node_ptr text_node::from_xml(xml_node const& xml)
|
|||
return boost::make_shared<text_node>(parse_expression(data, "utf8"));
|
||||
}
|
||||
|
||||
void text_node::apply(char_properties const& p, Feature const& feature, processed_text &output) const
|
||||
void text_node::apply(char_properties const& p, Feature const& feature, text_layout &output) const
|
||||
{
|
||||
UnicodeString text_str = boost::apply_visitor(evaluate<Feature,value_type>(feature), *text_).to_unicode();
|
||||
if (p.text_transform == UPPERCASE)
|
||||
|
@ -66,7 +69,7 @@ void text_node::apply(char_properties const& p, Feature const& feature, processe
|
|||
text_str = text_str.toTitle(NULL);
|
||||
}
|
||||
if (text_str.length() > 0) {
|
||||
output.push_back(p, text_str);
|
||||
output.add_text(text_str, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <mapnik/symbolizer_helpers.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/placement_finder.hpp>
|
||||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
@ -225,8 +226,9 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_placement()
|
|||
placement_valid_ = false;
|
||||
return false;
|
||||
}
|
||||
placement_->properties.process(text_, feature_);
|
||||
info_ = &(text_.get_string_info());
|
||||
placement_->properties.process(layout_, feature_);
|
||||
//TODO
|
||||
// info_ = &(text_.get_string_info());
|
||||
if (placement_->properties.orientation)
|
||||
{
|
||||
angle_ = boost::apply_visitor(
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
text_layout::text_layout(double text_ratio, double wrap_width) : text_ratio_(text_ratio), wrap_width_(wrap_width)
|
||||
text_layout::text_layout()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -58,4 +58,10 @@ void text_layout::shape_text()
|
|||
}
|
||||
}
|
||||
|
||||
void text_layout::clear()
|
||||
{
|
||||
itemizer.clear();
|
||||
glyphs_.clear();
|
||||
}
|
||||
|
||||
} //ns mapnik
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*****************************************************************************/
|
||||
// mapnik
|
||||
#include <mapnik/text_properties.hpp>
|
||||
#include <mapnik/processed_text.hpp>
|
||||
#include <mapnik/text/layout.hpp>
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/expression_string.hpp>
|
||||
#include <mapnik/formatting/text.hpp>
|
||||
|
@ -60,7 +60,7 @@ text_symbolizer_properties::text_symbolizer_properties() :
|
|||
|
||||
}
|
||||
|
||||
void text_symbolizer_properties::process(processed_text &output, Feature const& feature) const
|
||||
void text_symbolizer_properties::process(text_layout &output, Feature const& feature) const
|
||||
{
|
||||
output.clear();
|
||||
if (tree_) {
|
||||
|
|
Loading…
Add table
Reference in a new issue