Move more variables from text_placements_info to placement_finder.
Refs #1048.
This commit is contained in:
parent
4638b28c36
commit
46272d836b
7 changed files with 27 additions and 22 deletions
|
@ -430,8 +430,6 @@ void export_text_placement()
|
|||
.def_readwrite("scale_factor", &text_placement_info::scale_factor)
|
||||
.def_readwrite("has_dimensions", &text_placement_info::has_dimensions)
|
||||
.def_readwrite("dimensions", &text_placement_info::dimensions)
|
||||
.def_readwrite("collect_extents", &text_placement_info::collect_extents)
|
||||
.def_readwrite("additional_boxes", &text_placement_info::additional_boxes)
|
||||
;
|
||||
register_ptr_to_python<boost::shared_ptr<text_placement_info> >();
|
||||
|
||||
|
|
|
@ -69,6 +69,15 @@ public:
|
|||
|
||||
inline placements_type &get_results() { return placements_; }
|
||||
|
||||
/** Additional boxes to take into account when finding placement.
|
||||
* Used for finding line placements where multiple placements are returned.
|
||||
* Boxes are relative to starting point of current placement.
|
||||
*/
|
||||
std::vector<box2d<double> > additional_boxes;
|
||||
|
||||
void set_collect_extents(bool collect) { collect_extents_ = collect; }
|
||||
bool get_collect_extents() const { return collect_extents_; }
|
||||
|
||||
private:
|
||||
///Helpers for find_line_placement
|
||||
|
||||
|
@ -132,6 +141,8 @@ private:
|
|||
placements_type placements_;
|
||||
/** Bounding box of all texts placed. */
|
||||
box2d<double> extents_;
|
||||
/** Collect a bounding box of all texts placed. */
|
||||
bool collect_extents_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ public:
|
|||
placement_ = sym_.get_placement_options()->get_placement_info(
|
||||
scale_factor, std::make_pair(width, height), false);
|
||||
//TODO: has_dimensions? Why? When?
|
||||
if (writer_.first) placement_->collect_extents = true;
|
||||
next_placement();
|
||||
initialize_points();
|
||||
}
|
||||
|
|
|
@ -74,15 +74,6 @@ public:
|
|||
double get_actual_minimum_distance() const { return scale_factor * properties.minimum_distance; }
|
||||
/** Get minimum padding taking the scale factor into account. */
|
||||
double get_actual_minimum_padding() const { return scale_factor * properties.minimum_padding; }
|
||||
|
||||
/** Collect a bounding box of all texts placed. */
|
||||
bool collect_extents;
|
||||
|
||||
/** Additional boxes to take into account when finding placement.
|
||||
* Used for finding line placements where multiple placements are returned.
|
||||
* Boxes are relative to starting point of current placement.
|
||||
*/
|
||||
std::vector<box2d<double> > additional_boxes;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<text_placement_info> text_placement_info_ptr;
|
||||
|
|
|
@ -116,7 +116,8 @@ placement_finder<DetectorT>::placement_finder(Feature const& feature,
|
|||
valign_(V_AUTO),
|
||||
halign_(H_AUTO),
|
||||
line_breaks_(),
|
||||
line_sizes_()
|
||||
line_sizes_(),
|
||||
collect_extents_(false)
|
||||
{
|
||||
init_string_size();
|
||||
init_alignment();
|
||||
|
@ -472,9 +473,9 @@ void placement_finder<DetectorT>::find_point_placement(double label_x, double la
|
|||
}
|
||||
|
||||
// check the placement of any additional envelopes
|
||||
if (!p.allow_overlap && !pi.additional_boxes.empty())
|
||||
if (!p.allow_overlap && !additional_boxes.empty())
|
||||
{
|
||||
BOOST_FOREACH(box2d<double> box, pi.additional_boxes)
|
||||
BOOST_FOREACH(box2d<double> box, additional_boxes)
|
||||
{
|
||||
box2d<double> pt(box.minx() + current_placement->center.x,
|
||||
box.miny() + current_placement->center.y,
|
||||
|
@ -881,8 +882,8 @@ bool placement_finder<DetectorT>::test_placement(const std::auto_ptr<text_path>
|
|||
if (orientation < 0)
|
||||
{
|
||||
// rotate in place
|
||||
x += cwidth*cosa - string_height_*sina;
|
||||
y -= cwidth*sina + string_height_*cosa;
|
||||
x += cwidth * cosa - string_height_ * sina;
|
||||
y -= cwidth * sina + string_height_ * cosa;
|
||||
angle += M_PI;
|
||||
//sin(x+PI) = -sin(x)
|
||||
sina = -sina;
|
||||
|
@ -991,15 +992,15 @@ void placement_finder<DetectorT>::find_line_circle_intersection(
|
|||
template <typename DetectorT>
|
||||
void placement_finder<DetectorT>::update_detector()
|
||||
{
|
||||
if (collect_extents_) extents_.init(0,0,0,0);
|
||||
// add the bboxes to the detector and remove from the placement
|
||||
while (!envelopes_.empty())
|
||||
{
|
||||
box2d<double> e = envelopes_.front();
|
||||
detector_.insert(e, info_.get_string());
|
||||
envelopes_.pop();
|
||||
extents_.init(0,0,0,0);
|
||||
|
||||
if (pi.collect_extents)
|
||||
if (collect_extents_)
|
||||
{
|
||||
extents_.expand_to_include(e);
|
||||
}
|
||||
|
|
|
@ -226,8 +226,13 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_placement()
|
|||
} else {
|
||||
angle_ = 0.0;
|
||||
}
|
||||
|
||||
|
||||
finder_ = boost::shared_ptr<placement_finder<DetectorT> >(new placement_finder<DetectorT>(feature_, *placement_, *info_, detector_, dims_));
|
||||
// boost::make_shared<placement_finder<DetectorT> >(feature_, *placement_, *info_, detector_, dims_);
|
||||
|
||||
if (writer_.first) finder_->set_collect_extents(true);
|
||||
|
||||
placement_valid_ = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -320,8 +325,9 @@ template <typename FaceManagerT, typename DetectorT>
|
|||
bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_line_placement()
|
||||
{
|
||||
position const& pos = placement_->properties.displacement;
|
||||
finder_->additional_boxes.clear();
|
||||
//Markers are automatically centered
|
||||
placement_->additional_boxes.push_back(
|
||||
finder_->additional_boxes.push_back(
|
||||
box2d<double>(-0.5 * marker_ext_.width() - pos.first,
|
||||
-0.5 * marker_ext_.height() - pos.second,
|
||||
0.5 * marker_ext_.width() - pos.first,
|
||||
|
|
|
@ -39,8 +39,7 @@ text_placement_info::text_placement_info(text_placements const* parent,
|
|||
: properties(parent->defaults),
|
||||
scale_factor(scale_factor_),
|
||||
has_dimensions(has_dimensions_),
|
||||
dimensions(dim),
|
||||
collect_extents(false)
|
||||
dimensions(dim)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue