summaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-03-17 16:54:14 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-03-17 16:54:14 +0100
commitbf6a6001f9e82abd3aac25d8b7d3e559b0c98bd8 (patch)
tree93710be51b2d239410d31a4618a4a2d8d8c68b83 /src/text
parent1f2c71ec8bc3b228db2d90751a5bae4e269e1dd4 (diff)
downloadqtlocation-mapboxgl-bf6a6001f9e82abd3aac25d8b7d3e559b0c98bd8.tar.gz
format fixes
Diffstat (limited to 'src/text')
-rw-r--r--src/text/collision.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/text/collision.cpp b/src/text/collision.cpp
index 750495dc5b..6947635609 100644
--- a/src/text/collision.cpp
+++ b/src/text/collision.cpp
@@ -28,22 +28,23 @@ Collision::Collision() {
CollisionAnchor{m, m}, 1, {{M_PI * 2, 0}}, false, 2);
}
-
-GlyphBox getMergedGlyphs(const GlyphBoxes &glyphs, bool horizontal, const CollisionAnchor& anchor) {
+GlyphBox getMergedGlyphs(const GlyphBoxes &glyphs, bool horizontal,
+ const CollisionAnchor &anchor) {
GlyphBox mergedGlyphs;
const float inf = std::numeric_limits<float>::infinity();
- mergedGlyphs.box = {{inf,inf},{-inf,-inf}};
+ mergedGlyphs.box = {{inf, inf}, {-inf, -inf}};
mergedGlyphs.rotate = horizontal;
mergedGlyphs.anchor = anchor;
- CollisionRect& box = mergedGlyphs.box;
- for (const GlyphBox& glyph : glyphs) {
- const CollisionRect& gbox = glyph.box;
+ CollisionRect &box = mergedGlyphs.box;
+ for (const GlyphBox &glyph : glyphs) {
+ const CollisionRect &gbox = glyph.box;
box.tl.x = util::min(box.tl.x, gbox.tl.x);
box.tl.y = util::min(box.tl.y, gbox.tl.y);
box.br.x = util::max(box.br.x, gbox.br.x);
box.br.y = util::max(box.br.y, gbox.br.y);
- mergedGlyphs.minScale = util::max(mergedGlyphs.minScale, glyph.minScale);
+ mergedGlyphs.minScale =
+ util::max(mergedGlyphs.minScale, glyph.minScale);
}
return mergedGlyphs;
@@ -55,7 +56,7 @@ Placement Collision::place(const GlyphBoxes &boxes,
float padding, bool horizontal) {
float minScale = std::numeric_limits<float>::infinity();
- for (const GlyphBox& box : boxes) {
+ for (const GlyphBox &box : boxes) {
minScale = util::min(minScale, box.minScale);
}
minPlacementScale = util::max(minPlacementScale, minScale);
@@ -85,11 +86,14 @@ Placement Collision::place(const GlyphBoxes &boxes,
}
}
- // Calculate the minimum scale the entire label can be shown without collisions
- float scale = getPlacementScale(boxes, minPlacementScale, maxPlacementScale, padding);
+ // Calculate the minimum scale the entire label can be shown without
+ // collisions
+ float scale =
+ getPlacementScale(boxes, minPlacementScale, maxPlacementScale, padding);
// Return if the label can never be placed without collision
- if (scale < 0) return {};
+ if (scale < 0)
+ return {};
// Calculate the range it is safe to rotate all glyphs
PlacementRange rotationRange = getPlacementRange(glyphs, scale);
@@ -100,7 +104,6 @@ Placement Collision::place(const GlyphBoxes &boxes,
return {zoom, rotationRange};
}
-
float Collision::getPlacementScale(const GlyphBoxes &glyphs,
float minPlacementScale,
float maxPlacementScale, float pad) {