avoid captures in displacement_evaluator
This commit is contained in:
parent
8eab2d31de
commit
79c1ac96b4
5 changed files with 18 additions and 37 deletions
|
@ -93,12 +93,9 @@ struct MAPNIK_DECL text_layout_properties
|
||||||
horizontal_alignment_e halign;
|
horizontal_alignment_e halign;
|
||||||
justify_alignment_e jalign;
|
justify_alignment_e jalign;
|
||||||
vertical_alignment_e valign;
|
vertical_alignment_e valign;
|
||||||
std::function<pixel_position(feature_impl const& feature, attributes const& attrs)> displacement_evaluator_ =
|
std::function<pixel_position(double,double)> displacement_evaluator_ =
|
||||||
[this](feature_impl const& feature, attributes const& attrs)
|
[](double dx, double dy) { return pixel_position(dx,dy);};
|
||||||
{ double dx_ = boost::apply_visitor(extract_value<value_double>(feature,attrs), dx);
|
|
||||||
double dy_ = boost::apply_visitor(extract_value<value_double>(feature,attrs), dy);
|
|
||||||
return pixel_position(dx_,dy_);};
|
|
||||||
;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class text_layout;
|
class text_layout;
|
||||||
|
|
|
@ -233,7 +233,9 @@ void text_layout::shape_text(text_line & line)
|
||||||
void text_layout::evaluate_properties(feature_impl const& feature, attributes const& attrs)
|
void text_layout::evaluate_properties(feature_impl const& feature, attributes const& attrs)
|
||||||
{
|
{
|
||||||
// dx,dy
|
// dx,dy
|
||||||
displacement_ = properties_.displacement_evaluator_(feature, attrs);
|
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), properties_.dx);
|
||||||
|
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), properties_.dy);
|
||||||
|
displacement_ = properties_.displacement_evaluator_(dx,dy);
|
||||||
|
|
||||||
wrap_width_ = boost::apply_visitor(extract_value<value_double>(feature,attrs), properties_.wrap_width);
|
wrap_width_ = boost::apply_visitor(extract_value<value_double>(feature,attrs), properties_.wrap_width);
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,8 @@ bool placement_finder::next_position()
|
||||||
}
|
}
|
||||||
|
|
||||||
text_layout_ptr layout = std::make_shared<text_layout>(font_manager_, scale_factor_, info_.properties.layout_defaults);
|
text_layout_ptr layout = std::make_shared<text_layout>(font_manager_, scale_factor_, info_.properties.layout_defaults);
|
||||||
layout->evaluate_properties(feature_, attr_);
|
|
||||||
info_.properties.process(*layout, feature_, attr_);
|
info_.properties.process(*layout, feature_, attr_);
|
||||||
|
layout->evaluate_properties(feature_, attr_);
|
||||||
|
|
||||||
layouts_.clear();
|
layouts_.clear();
|
||||||
layouts_.add(layout);
|
layouts_.add(layout);
|
||||||
|
|
|
@ -40,12 +40,8 @@ bool text_placement_info_list::next()
|
||||||
{
|
{
|
||||||
if (state >= parent_->list_.size() + 1) return false;
|
if (state >= parent_->list_.size() + 1) return false;
|
||||||
properties = parent_->list_[state-1];
|
properties = parent_->list_[state-1];
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs),
|
|
||||||
parent_->list_[state-1].layout_defaults.dx);
|
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs),
|
|
||||||
parent_->list_[state-1].layout_defaults.dy);
|
|
||||||
return pixel_position(dx,dy);
|
return pixel_position(dx,dy);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,70 +68,56 @@ bool text_placement_info_simple::next_position_only()
|
||||||
switch (dir)
|
switch (dir)
|
||||||
{
|
{
|
||||||
case EXACT_POSITION:
|
case EXACT_POSITION:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(dx,dy);
|
return pixel_position(dx,dy);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case NORTH:
|
case NORTH:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(0,-std::abs(dy));
|
return pixel_position(0,-std::abs(dy));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case EAST:
|
case EAST:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
return pixel_position(std::abs(dx),0);
|
return pixel_position(std::abs(dx),0);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(0,std::abs(dy));
|
return pixel_position(0,std::abs(dy));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
return pixel_position(-std::abs(dx),0);
|
return pixel_position(-std::abs(dx),0);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case NORTHEAST:
|
case NORTHEAST:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(std::abs(dx),-std::abs(dy));
|
return pixel_position(std::abs(dx),-std::abs(dy));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case SOUTHEAST:
|
case SOUTHEAST:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(std::abs(dx),std::abs(dy));
|
return pixel_position(std::abs(dx),std::abs(dy));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case NORTHWEST:
|
case NORTHWEST:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(-std::abs(dx),-std::abs(dy));
|
return pixel_position(-std::abs(dx),-std::abs(dy));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case SOUTHWEST:
|
case SOUTHWEST:
|
||||||
properties.layout_defaults.displacement_evaluator_ = [this](feature_impl const& feature, attributes const& attrs)
|
properties.layout_defaults.displacement_evaluator_ = [](double dx, double dy)
|
||||||
{
|
{
|
||||||
double dx = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dx);
|
|
||||||
double dy = boost::apply_visitor(extract_value<value_double>(feature,attrs), this->parent_->defaults.layout_defaults.dy);
|
|
||||||
return pixel_position(-std::abs(dx),std::abs(dy));
|
return pixel_position(-std::abs(dx),std::abs(dy));
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue