Merge pull request #3016 from mapycz/text-null-bbox

Null text collision box
This commit is contained in:
Artem Pavlenko 2015-08-10 12:18:31 +02:00
commit e68da0d083
2 changed files with 6 additions and 5 deletions

View file

@ -74,7 +74,7 @@ private:
// Checks for collision.
bool collision(box2d<double> const& box, const value_unicode_string &repeat_key, bool line_placement) const;
// Adds marker to glyph_positions and to collision detector. Returns false if there is a collision.
bool add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const;
bool add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos, std::vector<box2d<double>> & bboxes) const;
// Maps upright==auto, left-only and right-only to left,right to simplify processing.
// angle = angle of at start of line (to estimate best option for upright==auto)
text_upright_e simplify_upright(text_upright_e upright, double angle) const;

View file

@ -143,7 +143,7 @@ bool placement_finder::find_point_placement(pixel_position const& pos)
/* For point placements it is faster to just check the bounding box. */
if (collision(bbox, layouts_.text(), false)) return false;
if (layout.num_lines()) bboxes.push_back(std::move(bbox));
if (layout.glyphs_count()) bboxes.push_back(std::move(bbox));
pixel_position layout_offset = layout_center - glyphs->get_base_point();
layout_offset.y = -layout_offset.y;
@ -178,7 +178,7 @@ bool placement_finder::find_point_placement(pixel_position const& pos)
}
// add_marker first checks for collision and then updates the detector.
if (has_marker_ && !add_marker(glyphs, pos)) return false;
if (has_marker_ && !add_marker(glyphs, pos, bboxes)) return false;
box2d<double> label_box;
bool first = true;
@ -418,14 +418,15 @@ void placement_finder::set_marker(marker_info_ptr m, box2d<double> box, bool mar
}
bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const
bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos, std::vector<box2d<double>> & bboxes) const
{
pixel_position real_pos = (marker_unlocked_ ? pos : glyphs->get_base_point()) + marker_displacement_;
box2d<double> bbox = marker_box_;
bbox.move(real_pos.x, real_pos.y);
glyphs->set_marker(marker_, real_pos);
if (collision(bbox, layouts_.text(), false)) return false;
detector_.insert(bbox);
bboxes.push_back(std::move(bbox));
glyphs->set_marker(marker_, real_pos);
return true;
}