c++ char_properties -> evaluated_format_properties

This commit is contained in:
artemp 2014-07-28 17:22:32 +01:00
parent 72fd012221
commit 0cf6e47006
22 changed files with 73 additions and 73 deletions

View file

@ -124,7 +124,7 @@ struct NodeWrap
NodeWrap()
: formatting::node(), wrapper<formatting::node>() {}
void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
python_block_auto_unblock b;
this->get_override("apply")(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output));
@ -159,7 +159,7 @@ struct TextNodeWrap
TextNodeWrap(std::string expr_text)
: formatting::text_node(expr_text), wrapper<formatting::text_node>() {}
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
if(override o = this->get_override("apply"))
{
@ -172,7 +172,7 @@ struct TextNodeWrap
}
}
void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
formatting::text_node::apply(p, feature, vars, output);
}
@ -182,7 +182,7 @@ struct TextNodeWrap
struct FormatNodeWrap
: formatting::format_node, wrapper<formatting::format_node>
{
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
if(override o = this->get_override("apply"))
{
@ -195,7 +195,7 @@ struct FormatNodeWrap
}
}
void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
formatting::format_node::apply(p, feature, vars, output);
}
@ -203,7 +203,7 @@ struct FormatNodeWrap
struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expression_format>
{
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
if(override o = this->get_override("apply"))
{
@ -216,7 +216,7 @@ struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expres
}
}
void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
formatting::expression_format::apply(p, feature, vars, output);
}
@ -224,7 +224,7 @@ struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expres
struct LayoutNodeWrap: formatting::layout_node, wrapper<formatting::layout_node>
{
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
if(override o = this->get_override("apply"))
{
@ -237,7 +237,7 @@ struct LayoutNodeWrap: formatting::layout_node, wrapper<formatting::layout_node>
}
}
void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
formatting::layout_node::apply(p, feature, vars, output);
}
@ -264,7 +264,7 @@ struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node>
// TODO: Add constructor taking variable number of arguments.
http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_function
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
if(override o = this->get_override("apply"))
{
@ -277,7 +277,7 @@ struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node>
}
}
void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
formatting::list_node::apply(p, feature, vars, output);
}
@ -346,12 +346,12 @@ void insert_expression(expression_set *set, expression_ptr p)
}
/*
char_properties_ptr get_format(text_symbolizer const& sym)
evaluated_format_properties_ptr get_format(text_symbolizer const& sym)
{
return sym.get_placement_options()->defaults.format;
}
void set_format(text_symbolizer const& sym, char_properties_ptr format)
void set_format(text_symbolizer const& sym, evaluated_format_properties_ptr format)
{
sym.get_placement_options()->defaults.format = format;
}
@ -453,25 +453,25 @@ void export_text_placement()
.def_readwrite("orientation", &text_layout_properties::orientation)
.def_readwrite("rotate_displacement", &text_layout_properties::rotate_displacement)
.add_property("displacement", &get_displacement, &set_displacement);
class_with_converter<char_properties>
/*
class_with_converter<detail::evaluated_format_properties>
("CharProperties")
.def_readwrite_convert("text_transform", &char_properties::text_transform)
.def_readwrite_convert("fontset", &char_properties::fontset)
.def(init<char_properties const&>()) //Copy constructor
.def_readwrite("face_name", &char_properties::face_name)
.def_readwrite("text_size", &char_properties::text_size)
.def_readwrite("character_spacing", &char_properties::character_spacing)
.def_readwrite("line_spacing", &char_properties::line_spacing)
.def_readwrite("text_opacity", &char_properties::text_opacity)
.def_readwrite("wrap_char", &char_properties::wrap_char)
.def_readwrite("wrap_character", &char_properties::wrap_char)
.def_readwrite("fill", &char_properties::fill)
.def_readwrite("halo_fill", &char_properties::halo_fill)
.def_readwrite("halo_radius", &char_properties::halo_radius)
/* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.*/
.def_readwrite_convert("text_transform", &detail::evaluated_format_properties::text_transform)
.def_readwrite_convert("fontset", &detail::evaluated_format_properties::fontset)
.def(init<detail::evaluated_format_properties const&>()) //Copy constructor
.def_readwrite("face_name", &detail::evaluated_format_properties::face_name)
.def_readwrite("text_size", &detail::evaluated_format_properties::text_size)
.def_readwrite("character_spacing", &detail::evaluated_format_properties::character_spacing)
.def_readwrite("line_spacing", &detail::evaluated_format_properties::line_spacing)
.def_readwrite("text_opacity", &detail::evaluated_format_properties::text_opacity)
.def_readwrite("wrap_char", &detail::evaluated_format_properties::wrap_char)
.def_readwrite("wrap_character", &detail::evaluated_format_properties::wrap_char)
.def_readwrite("fill", &detail::evaluated_format_properties::fill)
.def_readwrite("halo_fill", &detail::evaluated_format_properties::halo_fill)
.def_readwrite("halo_radius", &evaluated_format_properties::halo_radius)
//from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
;
*/
class_<TextPlacementsWrap,
std::shared_ptr<TextPlacementsWrap>,
boost::noncopyable>

View file

@ -20,15 +20,15 @@
*
*****************************************************************************/
#ifndef CHAR_PROPERTIES_PTR_HPP
#define CHAR_PROPERTIES_PTR_HPP
#ifndef EVALUATED_FORMAT_PROPERTIES_PTR_HPP
#define EVALUATED_FORMAT_PROPERTIES_PTR_HPP
#include <memory>
namespace mapnik
{
struct char_properties;
using char_properties_ptr = std::shared_ptr<char_properties>;
namespace mapnik { namespace detail {
struct evaluated_format_properties;
}
using evaluated_format_properties_ptr = std::shared_ptr<detail::evaluated_format_properties>;
}
#endif // CHAR_PROPERTIES_PTR_HPP
#endif // EVALUATED_FORMAT_PROPERTIES_PTR_HPP

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/expression.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/text/char_properties_ptr.hpp>
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
// boost
#include <boost/property_tree/ptree_fwd.hpp>
@ -47,7 +47,7 @@ public:
virtual ~node() {}
virtual void to_xml(boost::property_tree::ptree & xml) const = 0;
static node_ptr from_xml(xml_node const& xml);
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const = 0;
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const = 0;
virtual void add_expressions(expression_set & output) const = 0;
};
} //ns formatting

View file

@ -37,7 +37,7 @@ class MAPNIK_DECL 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_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const;
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const;
virtual void add_expressions(expression_set & output) const;
void set_child(node_ptr child);

View file

@ -35,7 +35,7 @@ class MAPNIK_DECL layout_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_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void add_expressions(expression_set &output) const;
void set_child(node_ptr child);
node_ptr get_child() const;

View file

@ -35,7 +35,7 @@ class MAPNIK_DECL list_node: public node {
public:
list_node() : node(), children_() {}
virtual void to_xml(boost::property_tree::ptree &xml) const;
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void add_expressions(expression_set &output) const;
void push_back(node_ptr n);

View file

@ -36,7 +36,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_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void add_expressions(expression_set &output) const;
void set_text(expression_ptr text);

View file

@ -23,7 +23,7 @@
#define MAPNIK_GLYPH_INFO_HPP
//mapnik
#include <mapnik/text/char_properties_ptr.hpp>
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
#include <mapnik/pixel_position.hpp>
#include <memory>
@ -62,7 +62,7 @@ struct glyph_info
double unscaled_line_height;
double scale_multiplier;
pixel_position offset;
char_properties_ptr format;
evaluated_format_properties_ptr format;
double ymin() const { return unscaled_ymin * 64.0 * scale_multiplier; }
double ymax() const { return unscaled_ymax * 64.0 * scale_multiplier; }

View file

@ -24,7 +24,7 @@
#define MAPNIK_TEXT_ITEMIZER_HPP
//mapnik
#include <mapnik/text/char_properties_ptr.hpp>
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
#include <mapnik/value_types.hpp>
// stl
@ -47,7 +47,7 @@ struct text_item
unsigned end = 0u;
UScriptCode script = USCRIPT_INVALID_CODE;
UBiDiDirection rtl = UBIDI_LTR;
char_properties_ptr format;
evaluated_format_properties_ptr format;
};
// This class splits text into parts which all have the same
@ -59,7 +59,7 @@ class text_itemizer
{
public:
text_itemizer();
void add_text(value_unicode_string const& str, char_properties_ptr format);
void add_text(value_unicode_string const& str, evaluated_format_properties_ptr format);
std::list<text_item> const& itemize(unsigned start=0, unsigned end=0);
void clear();
value_unicode_string const& text() const { return text_; }
@ -76,7 +76,7 @@ private:
unsigned end;
T data;
};
using format_run_t = run<char_properties_ptr>;
using format_run_t = run<evaluated_format_properties_ptr>;
using direction_run_t = run<UBiDiDirection>;
using script_run_t = run<UScriptCode>;
using format_run_list = std::list<format_run_t>;

View file

@ -45,9 +45,9 @@ namespace mapnik
struct glyph_t
{
FT_Glyph image;
char_properties const* properties;
detail::evaluated_format_properties const* properties;
glyph_t(FT_Glyph image_, char_properties const* properties_)
glyph_t(FT_Glyph image_, detail::evaluated_format_properties const* properties_)
: image(image_), properties(properties_) {}
glyph_t( glyph_t && other) noexcept

View file

@ -26,7 +26,7 @@
#include <mapnik/text/itemizer.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/text/glyph_info.hpp>
#include <mapnik/text/char_properties_ptr.hpp>
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
#include <mapnik/text/harfbuzz_shaper.hpp>
#include <mapnik/text/rotation.hpp>
@ -51,7 +51,7 @@ public:
text_layout(face_manager_freetype & font_manager, double scale_factor, text_layout_properties const& properties);
// Adds a new text part. Call this function repeatedly to build the complete text.
void add_text(mapnik::value_unicode_string const& str, char_properties_ptr format);
void add_text(mapnik::value_unicode_string const& str, evaluated_format_properties_ptr format);
// Returns the complete text stored in this layout.
mapnik::value_unicode_string const& text() const;

View file

@ -23,7 +23,7 @@
#define MAPNIK_TEXT_PROPERTIES_HPP
// mapnik
#include <mapnik/text/char_properties_ptr.hpp>
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
#include <mapnik/color.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/value.hpp>
@ -41,18 +41,15 @@
#include <boost/optional.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
namespace mapnik
{
namespace mapnik { namespace detail {
using fontset_map = std::map<std::string, font_set>;
struct MAPNIK_DECL char_properties
struct evaluated_format_properties
{
std::string face_name;
boost::optional<font_set> fontset;
double text_size;
double character_spacing;
double line_spacing; //Largest total height (fontsize+line_spacing) per line is chosen
double line_spacing;
double text_opacity;
double halo_opacity;
unsigned wrap_char;
@ -62,6 +59,10 @@ struct MAPNIK_DECL char_properties
double halo_radius;
};
}
using fontset_map = std::map<std::string, font_set>;
struct MAPNIK_DECL format_properties
{
format_properties();
@ -168,7 +169,6 @@ struct MAPNIK_DECL text_symbolizer_properties
// Default values for text layouts
text_layout_properties layout_defaults;
// Default values for format_properties.
//char_properties_ptr format;
format_properties format_defaults;
private:

View file

@ -440,7 +440,7 @@ void cairo_context::add_text(glyph_positions_ptr path,
//render halo
double halo_radius = 0;
char_properties_ptr format;
evaluated_format_properties_ptr format;
set_operator(halo_comp_op);
for (auto const& glyph_pos : *path)
{

View file

@ -82,9 +82,9 @@ node_ptr format_node::from_xml(xml_node const& xml)
}
void format_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& attrs, text_layout &output) const
void format_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& attrs, text_layout &output) const
{
char_properties_ptr new_properties = std::make_shared<char_properties>(*p);
evaluated_format_properties_ptr new_properties = std::make_shared<detail::evaluated_format_properties>(*p);
if (text_size) new_properties->text_size = boost::apply_visitor(extract_value<value_double>(feature,attrs), *text_size);
if (character_spacing) new_properties->character_spacing = boost::apply_visitor(extract_value<value_double>(feature,attrs), *character_spacing);

View file

@ -78,7 +78,7 @@ node_ptr layout_node::from_xml(xml_node const& xml)
return n;
}
void layout_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const
void layout_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const
{
text_layout_properties new_properties(output.get_layout_properties());
if (dx) new_properties.dx = *dx;

View file

@ -42,7 +42,7 @@ void list_node::to_xml(boost::property_tree::ptree & xml) const
}
void list_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const
void list_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const
{
for (node_ptr const& node : children_)
{

View file

@ -49,7 +49,7 @@ node_ptr text_node::from_xml(xml_node const& xml)
return std::make_shared<text_node>(xml.get_value<expression_ptr>());
}
void text_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
void text_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
mapnik::value_unicode_string text_str = boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *text_).to_unicode();
if (p->text_transform == UPPERCASE)

View file

@ -37,7 +37,7 @@ text_itemizer::text_itemizer()
forced_line_breaks_.push_back(0);
}
void text_itemizer::add_text(mapnik::value_unicode_string const& str, char_properties_ptr format)
void text_itemizer::add_text(mapnik::value_unicode_string const& str, evaluated_format_properties_ptr format)
{
unsigned start = text_.length();
text_ += str;

View file

@ -101,7 +101,7 @@ text_placements_ptr text_placements_list::from_xml(xml_node const& xml, fontset_
{
if (itr->is_text() || !itr->is("Placement")) continue;
text_symbolizer_properties & p = list->add();
//p.format = std::make_shared<char_properties>(*(p.format)); //Make a deep copy -- FIXME
//p.format = std::make_shared<detail::evaluated_format_properties>(*(p.format)); //Make a deep copy -- FIXME
//TODO: This needs a real copy constructor for text_symbolizer_properties
p.from_xml(*itr, fontsets);
//TODO: if (strict_ && !p.format.fontset.size())

View file

@ -151,8 +151,8 @@ void agg_text_renderer<T>::render(glyph_positions const& pos)
matrix.yy = transform_.sy * 0x10000L;
matrix.yx = transform_.shy * 0x10000L;
char_properties default_props;
char_properties const* format = &default_props;
detail::evaluated_format_properties default_props;
detail::evaluated_format_properties const* format = &default_props;
for (auto const& glyph : glyphs_)
{
if (glyph.properties)

View file

@ -64,7 +64,7 @@ text_layout::text_layout(face_manager_freetype & font_manager, double scale_fact
lines_(),
properties_(properties) {}
void text_layout::add_text(mapnik::value_unicode_string const& str, char_properties_ptr format)
void text_layout::add_text(mapnik::value_unicode_string const& str, evaluated_format_properties_ptr format)
{
itemizer_.add_text(str, format);
}

View file

@ -62,7 +62,7 @@ void text_symbolizer_properties::process(text_layout & output, feature_impl cons
if (tree_)
{
//evaluate format properties
char_properties_ptr format = std::make_shared<char_properties>();
evaluated_format_properties_ptr format = std::make_shared<detail::evaluated_format_properties>();
format->text_size = boost::apply_visitor(extract_value<value_double>(feature,attrs), format_defaults.text_size);
format->character_spacing = boost::apply_visitor(extract_value<value_double>(feature,attrs), format_defaults.character_spacing);